Commit 5d6ded7e authored by Tony Lindgren's avatar Tony Lindgren

ARM: OMAP: Adds support to clock framework to detect device id

Clock framework specifies that the selection of clock should be
done based on the device id for similar clocks. This patch adds
support for MMC clocks. Clock device id handling adapted from
mach-s3c2410/clock.c.
parent 8fc55a5b
......@@ -687,7 +687,8 @@ static struct clk bclk_16xx = {
};
static struct clk mmc1_ck = {
.name = "mmc1_ck",
.name = "mmc_ck",
.id = 1,
/* Functional clock is direct from ULPD, interface clock is ARMPER */
.parent = &armper_ck.clk,
.rate = 48000000,
......@@ -701,7 +702,8 @@ static struct clk mmc1_ck = {
};
static struct clk mmc2_ck = {
.name = "mmc2_ck",
.name = "mmc_ck",
.id = 2,
/* Functional clock is direct from ULPD, interface clock is ARMPER */
.parent = &armper_ck.clk,
.rate = 48000000,
......
......@@ -21,6 +21,7 @@
#include <linux/string.h>
#include <linux/clk.h>
#include <linux/mutex.h>
#include <linux/platform_device.h>
#include <asm/io.h>
#include <asm/semaphore.h>
......@@ -37,17 +38,37 @@ static struct clk_functions *arch_clock;
* Standard clock functions defined in include/linux/clk.h
*-------------------------------------------------------------------------*/
/*
* Returns a clock. Note that we first try to use device id on the bus
* and clock name. If this fails, we try to use clock name only.
*/
struct clk * clk_get(struct device *dev, const char *id)
{
struct clk *p, *clk = ERR_PTR(-ENOENT);
int idno;
if (dev == NULL || dev->bus != &platform_bus_type)
idno = -1;
else
idno = to_platform_device(dev)->id;
mutex_lock(&clocks_mutex);
list_for_each_entry(p, &clocks, node) {
if (strcmp(id, p->name) == 0 && try_module_get(p->owner)) {
if (p->id == idno &&
strcmp(id, p->name) == 0 && try_module_get(p->owner)) {
clk = p;
break;
}
}
list_for_each_entry(p, &clocks, node) {
if (strcmp(id, p->name) == 0 && try_module_get(p->owner)) {
clk = p;
break;
}
}
mutex_unlock(&clocks_mutex);
return clk;
......
......@@ -1191,8 +1191,7 @@ static int __init mmc_omap_probe(struct platform_device *pdev)
}
if (!cpu_is_omap24xx())
host->fclk = clk_get(&pdev->dev,
(host->id == 1) ? "mmc1_ck" : "mmc2_ck");
host->fclk = clk_get(&pdev->dev, "mmc_ck");
else
host->fclk = clk_get(&pdev->dev, "mmc_fck");
......
......@@ -19,6 +19,7 @@ struct clk {
struct list_head node;
struct module *owner;
const char *name;
int id;
struct clk *parent;
unsigned long rate;
__u32 flags;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment