ARM: 6927/1: SPEAr Clock: Update for single image solution
authorviresh kumar <viresh.kumar@st.com>
Fri, 20 May 2011 07:34:19 +0000 (08:34 +0100)
committerRussell King <rmk+kernel@arm.linux.org.uk>
Fri, 20 May 2011 21:32:42 +0000 (22:32 +0100)
This patch creates different clk_lookup arrays for individual machines.
These lookup arrays will be registered only if that specific machine is
current machine.

Reviewed-by: Stanley Miao <stanley.miao@windriver.com>
Signed-off-by: Viresh Kumar <viresh.kumar@st.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
arch/arm/mach-spear3xx/clock.c

index 5707772d51f7358ed311b146ad15929a0396295c..f67860cd649f3df1ee009425d5938feaf9fa0784 100644 (file)
@@ -13,6 +13,7 @@
 
 #include <linux/init.h>
 #include <linux/kernel.h>
+#include <asm/mach-types.h>
 #include <plat/clock.h>
 #include <mach/misc_regs.h>
 
@@ -688,56 +689,71 @@ static struct clk_lookup spear_clk_lookups[] = {
        { .dev_id = "adc",              .clk = &adc_clk},
        { .dev_id = "ssp-pl022.0",      .clk = &ssp0_clk},
        { .dev_id = "gpio",             .clk = &gpio_clk},
-#if defined(CONFIG_MACH_SPEAR310) || defined(CONFIG_MACH_SPEAR320)
-       { .dev_id = "physmap-flash",    .clk = &emi_clk},
-#endif
-#if defined(CONFIG_MACH_SPEAR300) || defined(CONFIG_MACH_SPEAR310) || \
-       defined(CONFIG_MACH_SPEAR320)
-       { .con_id = "fsmc",             .clk = &fsmc_clk},
-#endif
-
-/* common clocks to spear310 and spear320 */
-#if defined(CONFIG_MACH_SPEAR310) || defined(CONFIG_MACH_SPEAR320)
-       { .dev_id = "uart1",            .clk = &uart1_clk},
-       { .dev_id = "uart2",            .clk = &uart2_clk},
-#endif
-
-       /* common clock to spear300 and spear320 */
-#if defined(CONFIG_MACH_SPEAR300) || defined(CONFIG_MACH_SPEAR320)
-       { .dev_id = "clcd",             .clk = &clcd_clk},
-       { .dev_id = "sdhci",            .clk = &sdhci_clk},
-#endif /* CONFIG_MACH_SPEAR300 || CONFIG_MACH_SPEAR320 */
+};
 
-       /* spear300 machine specific clock structures */
+/* array of all spear 300 clock lookups */
 #ifdef CONFIG_MACH_SPEAR300
+static struct clk_lookup spear300_clk_lookups[] = {
+       { .dev_id = "clcd",             .clk = &clcd_clk},
+       { .con_id = "fsmc",             .clk = &fsmc_clk},
        { .dev_id = "gpio1",            .clk = &gpio1_clk},
        { .dev_id = "keyboard",         .clk = &kbd_clk},
+       { .dev_id = "sdhci",            .clk = &sdhci_clk},
+};
 #endif
 
-       /* spear310 machine specific clock structures */
+/* array of all spear 310 clock lookups */
 #ifdef CONFIG_MACH_SPEAR310
+static struct clk_lookup spear310_clk_lookups[] = {
+       { .con_id = "fsmc",             .clk = &fsmc_clk},
+       { .con_id = "emi",              .clk = &emi_clk},
+       { .dev_id = "uart1",            .clk = &uart1_clk},
+       { .dev_id = "uart2",            .clk = &uart2_clk},
        { .dev_id = "uart3",            .clk = &uart3_clk},
        { .dev_id = "uart4",            .clk = &uart4_clk},
        { .dev_id = "uart5",            .clk = &uart5_clk},
-
+};
 #endif
-       /* spear320 machine specific clock structures */
+
+/* array of all spear 320 clock lookups */
 #ifdef CONFIG_MACH_SPEAR320
+static struct clk_lookup spear320_clk_lookups[] = {
+       { .dev_id = "clcd",             .clk = &clcd_clk},
+       { .con_id = "fsmc",             .clk = &fsmc_clk},
+       { .dev_id = "i2c_designware.1", .clk = &i2c1_clk},
+       { .con_id = "emi",              .clk = &emi_clk},
+       { .dev_id = "pwm",              .clk = &pwm_clk},
+       { .dev_id = "sdhci",            .clk = &sdhci_clk},
        { .dev_id = "c_can_platform.0", .clk = &can0_clk},
        { .dev_id = "c_can_platform.1", .clk = &can1_clk},
-       { .dev_id = "i2c_designware.1", .clk = &i2c1_clk},
        { .dev_id = "ssp-pl022.1",      .clk = &ssp1_clk},
        { .dev_id = "ssp-pl022.2",      .clk = &ssp2_clk},
-       { .dev_id = "pwm",              .clk = &pwm_clk},
-#endif
+       { .dev_id = "uart1",            .clk = &uart1_clk},
+       { .dev_id = "uart2",            .clk = &uart2_clk},
 };
+#endif
 
 void __init spear3xx_clk_init(void)
 {
-       int i;
+       int i, cnt;
+       struct clk_lookup *lookups;
+
+       if (machine_is_spear300()) {
+               cnt = ARRAY_SIZE(spear300_clk_lookups);
+               lookups = spear300_clk_lookups;
+       } else if (machine_is_spear310()) {
+               cnt = ARRAY_SIZE(spear310_clk_lookups);
+               lookups = spear310_clk_lookups;
+       } else {
+               cnt = ARRAY_SIZE(spear320_clk_lookups);
+               lookups = spear320_clk_lookups;
+       }
 
        for (i = 0; i < ARRAY_SIZE(spear_clk_lookups); i++)
                clk_register(&spear_clk_lookups[i]);
 
+       for (i = 0; i < cnt; i++)
+               clk_register(&lookups[i]);
+
        clk_init();
 }