ARM: OMAP: Pre-3430 clean-up for dmtimer.c

Cleanup DM timer list for OMAP2 and OMAP1 to allow
adding support for 3430.

Signed-off-by: Syed Mohammed Khasim <x0khasim@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>

authored by Syed Mohammed, Khasim and committed by Tony Lindgren 471b3aa7 f8151e5c

+41 -24
+41 -24
arch/arm/plat-omap/dmtimer.c
··· 48 48 #define OMAP_TIMER_COUNTER_REG 0x28 49 49 #define OMAP_TIMER_LOAD_REG 0x2c 50 50 #define OMAP_TIMER_TRIGGER_REG 0x30 51 - #define OMAP_TIMER_WRITE_PEND_REG 0x34 51 + #define OMAP_TIMER_WRITE_PEND_REG 0x34 52 52 #define OMAP_TIMER_MATCH_REG 0x38 53 53 #define OMAP_TIMER_CAPTURE_REG 0x3c 54 54 #define OMAP_TIMER_IF_CTRL_REG 0x40 ··· 82 82 83 83 #define omap_dm_clk_enable(x) 84 84 #define omap_dm_clk_disable(x) 85 + #define omap2_dm_timers NULL 86 + #define omap2_dm_source_names NULL 87 + #define omap2_dm_source_clocks NULL 85 88 86 - static struct omap_dm_timer dm_timers[] = { 89 + static struct omap_dm_timer omap1_dm_timers[] = { 87 90 { .phys_base = 0xfffb1400, .irq = INT_1610_GPTIMER1 }, 88 91 { .phys_base = 0xfffb1c00, .irq = INT_1610_GPTIMER2 }, 89 92 { .phys_base = 0xfffb2400, .irq = INT_1610_GPTIMER3 }, ··· 97 94 { .phys_base = 0xfffbd400, .irq = INT_1610_GPTIMER8 }, 98 95 }; 99 96 97 + static const int dm_timer_count = ARRAY_SIZE(omap1_dm_timers); 98 + 100 99 #elif defined(CONFIG_ARCH_OMAP2) 101 100 102 - #define omap_dm_clk_enable(x) clk_enable(x) 103 - #define omap_dm_clk_disable(x) clk_disable(x) 101 + #define omap_dm_clk_enable(x) clk_enable(x) 102 + #define omap_dm_clk_disable(x) clk_disable(x) 103 + #define omap1_dm_timers NULL 104 104 105 - static struct omap_dm_timer dm_timers[] = { 105 + static struct omap_dm_timer omap2_dm_timers[] = { 106 106 { .phys_base = 0x48028000, .irq = INT_24XX_GPTIMER1 }, 107 107 { .phys_base = 0x4802a000, .irq = INT_24XX_GPTIMER2 }, 108 108 { .phys_base = 0x48078000, .irq = INT_24XX_GPTIMER3 }, ··· 120 114 { .phys_base = 0x4808a000, .irq = INT_24XX_GPTIMER12 }, 121 115 }; 122 116 123 - static const char *dm_source_names[] = { 117 + static const char *omap2_dm_source_names[] __initdata = { 124 118 "sys_ck", 125 119 "func_32k_ck", 126 - "alt_ck" 120 + "alt_ck", 121 + NULL 127 122 }; 128 123 129 - static struct clk *dm_source_clocks[3]; 124 + static struct clk **omap2_dm_source_clocks[3]; 125 + static const int dm_timer_count = ARRAY_SIZE(omap2_dm_timers); 130 126 131 127 #else 132 128 ··· 136 128 137 129 #endif 138 130 139 - static const int dm_timer_count = ARRAY_SIZE(dm_timers); 131 + static struct omap_dm_timer *dm_timers; 132 + static char **dm_source_names; 133 + static struct clk **dm_source_clocks; 134 + 140 135 static spinlock_t dm_timer_lock; 141 136 142 137 static inline u32 omap_dm_timer_read_reg(struct omap_dm_timer *timer, int reg) ··· 497 486 return 0; 498 487 } 499 488 500 - int omap_dm_timer_init(void) 489 + int __init omap_dm_timer_init(void) 501 490 { 502 491 struct omap_dm_timer *timer; 503 492 int i; ··· 506 495 return -ENODEV; 507 496 508 497 spin_lock_init(&dm_timer_lock); 509 - #ifdef CONFIG_ARCH_OMAP2 510 - for (i = 0; i < ARRAY_SIZE(dm_source_names); i++) { 511 - dm_source_clocks[i] = clk_get(NULL, dm_source_names[i]); 512 - BUG_ON(dm_source_clocks[i] == NULL); 498 + 499 + if (cpu_class_is_omap1()) 500 + dm_timers = omap1_dm_timers; 501 + else if (cpu_is_omap24xx()) { 502 + dm_timers = omap2_dm_timers; 503 + dm_source_names = (char **)omap2_dm_source_names; 504 + dm_source_clocks = (struct clk **)omap2_dm_source_clocks; 513 505 } 514 - #endif 506 + 507 + if (cpu_class_is_omap2()) 508 + for (i = 0; dm_source_names[i] != NULL; i++) 509 + dm_source_clocks[i] = clk_get(NULL, dm_source_names[i]); 510 + 515 511 if (cpu_is_omap243x()) 516 512 dm_timers[0].phys_base = 0x49018000; 517 513 518 514 for (i = 0; i < dm_timer_count; i++) { 519 - #ifdef CONFIG_ARCH_OMAP2 520 - char clk_name[16]; 521 - #endif 522 - 523 515 timer = &dm_timers[i]; 524 - timer->io_base = (void __iomem *) io_p2v(timer->phys_base); 516 + timer->io_base = (void __iomem *)io_p2v(timer->phys_base); 525 517 #ifdef CONFIG_ARCH_OMAP2 526 - sprintf(clk_name, "gpt%d_ick", i + 1); 527 - timer->iclk = clk_get(NULL, clk_name); 528 - sprintf(clk_name, "gpt%d_fck", i + 1); 529 - timer->fclk = clk_get(NULL, clk_name); 518 + if (cpu_class_is_omap2()) { 519 + char clk_name[16]; 520 + sprintf(clk_name, "gpt%d_ick", i + 1); 521 + timer->iclk = clk_get(NULL, clk_name); 522 + sprintf(clk_name, "gpt%d_fck", i + 1); 523 + timer->fclk = clk_get(NULL, clk_name); 524 + } 530 525 #endif 531 526 } 532 527