[ARM] pxa: allow clk aliases
authorRussell King <rmk@dyn-67.arm.linux.org.uk>
Mon, 30 Jun 2008 18:47:59 +0000 (19:47 +0100)
committerRussell King <rmk+kernel@arm.linux.org.uk>
Wed, 9 Jul 2008 19:54:14 +0000 (20:54 +0100)
We need to support more than one name+device for a struct clk for a
small number of peripherals.  We do this by re-using struct clk alias
to another struct clk - IOW, if we find that the entry we're using is
an alias, we return the aliased entry not the one we found.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
arch/arm/mach-pxa/clock.c
arch/arm/mach-pxa/clock.h
arch/arm/mach-pxa/pxa25x.c

index e97dc59..68afc39 100644 (file)
@@ -47,6 +47,9 @@ struct clk *clk_get(struct device *dev, const char *id)
                clk = p;
        mutex_unlock(&clocks_mutex);
 
+       if (!IS_ERR(clk) && clk->ops == NULL)
+               clk = clk->other;
+
        return clk;
 }
 EXPORT_SYMBOL(clk_get);
index bc6b77e..83cbfab 100644 (file)
@@ -15,6 +15,7 @@ struct clk {
        unsigned int            cken;
        unsigned int            delay;
        unsigned int            enabled;
+       struct clk              *other;
 };
 
 #define INIT_CKEN(_name, _cken, _rate, _delay, _dev)   \
@@ -35,6 +36,17 @@ struct clk {
                .cken   = CKEN_##_cken,                 \
        }
 
+/*
+ * This is a placeholder to alias one clock device+name pair
+ * to another struct clk.
+ */
+#define INIT_CKOTHER(_name, _other, _dev)              \
+       {                                               \
+               .name   = _name,                        \
+               .dev    = _dev,                         \
+               .other  = _other,                       \
+       }
+
 extern const struct clkops clk_cken_ops;
 
 void clk_cken_enable(struct clk *clk);
index e5b417d..09ee131 100644 (file)
@@ -117,6 +117,10 @@ static struct clk pxa25x_hwuart_clk =
        INIT_CKEN("UARTCLK", HWUART, 14745600, 1, &pxa_device_hwuart.dev)
 ;
 
+/*
+ * PXA 2xx clock declarations. Order is important (see aliases below)
+ * Please be careful not to disrupt the ordering.
+ */
 static struct clk pxa25x_clks[] = {
        INIT_CK("LCDCLK", LCD, &clk_pxa25x_lcd_ops, &pxa_device_fb.dev),
        INIT_CKEN("UARTCLK", FFUART, 14745600, 1, &pxa_device_ffuart.dev),
@@ -140,6 +144,8 @@ static struct clk pxa25x_clks[] = {
        INIT_CKEN("FICPCLK", FICP, 47923000, 0, NULL),
 };
 
+static struct clk gpio7_clk = INIT_CKOTHER("GPIO7_CK", &pxa25x_clks[4], NULL);
+
 #ifdef CONFIG_PM
 
 #define SAVE(x)                sleep_save[SLEEP_SAVE_##x] = x
@@ -311,6 +317,8 @@ static int __init pxa25x_init(void)
        if (cpu_is_pxa25x())
                ret = platform_device_register(&pxa_device_hwuart);
 
+       clks_register(&gpio7_clk, 1);
+
        return ret;
 }