]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
ARM: OMAP: Adds support to clock framework to detect device id
authorTony Lindgren <tony@atomide.com>
Thu, 9 Feb 2006 19:19:23 +0000 (11:19 -0800)
committerTony Lindgren <tony@atomide.com>
Thu, 9 Feb 2006 19:19:23 +0000 (11:19 -0800)
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.

arch/arm/mach-omap1/clock.h
arch/arm/plat-omap/clock.c
drivers/mmc/omap.c
include/asm-arm/arch-omap/clock.h

index 0cb38ca64a0a150c6b8641324de75f3457c9d79e..ce207a7594a0fc83bc33b3deb33c0edb2c49193c 100644 (file)
@@ -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,
index a8b0bf26a213bbf9be0fc5c3f21e170bd910a64c..679ae12b2d81320eca714b73906fffa7b487e8ee 100644 (file)
@@ -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;
index 45a147f961041983b9f0c3a032eacf18ae626745..49b35c4fd18a4899b086eefb77bc96049909d48f 100644 (file)
@@ -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");
 
index 4bad3d6be77aff9f588f9345e8cdd50739790736..3c4eb9fbe48ac58aae335666168b0a6dc0454ad6 100644 (file)
@@ -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;