From: Tony Lindgren Date: Thu, 9 Feb 2006 19:19:23 +0000 (-0800) Subject: ARM: OMAP: Adds support to clock framework to detect device id X-Git-Tag: v2.6.16-omap1~78^2 X-Git-Url: http://pilppa.com/gitweb/?a=commitdiff_plain;h=5d6ded7e6a58d833f6af4a358f4e0574e8179549;p=linux-2.6-omap-h63xx.git 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. --- diff --git a/arch/arm/mach-omap1/clock.h b/arch/arm/mach-omap1/clock.h index 0cb38ca64a0..ce207a7594a 100644 --- a/arch/arm/mach-omap1/clock.h +++ b/arch/arm/mach-omap1/clock.h @@ -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, diff --git a/arch/arm/plat-omap/clock.c b/arch/arm/plat-omap/clock.c index a8b0bf26a21..679ae12b2d8 100644 --- a/arch/arm/plat-omap/clock.c +++ b/arch/arm/plat-omap/clock.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -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; diff --git a/drivers/mmc/omap.c b/drivers/mmc/omap.c index 45a147f9610..49b35c4fd18 100644 --- a/drivers/mmc/omap.c +++ b/drivers/mmc/omap.c @@ -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"); diff --git a/include/asm-arm/arch-omap/clock.h b/include/asm-arm/arch-omap/clock.h index 4bad3d6be77..3c4eb9fbe48 100644 --- a/include/asm-arm/arch-omap/clock.h +++ b/include/asm-arm/arch-omap/clock.h @@ -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;