aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/plat-omap/dmtimer.c
diff options
context:
space:
mode:
authorAndrea Bastoni <bastoni@cs.unc.edu>2010-05-30 19:16:45 -0400
committerAndrea Bastoni <bastoni@cs.unc.edu>2010-05-30 19:16:45 -0400
commitada47b5fe13d89735805b566185f4885f5a3f750 (patch)
tree644b88f8a71896307d71438e9b3af49126ffb22b /arch/arm/plat-omap/dmtimer.c
parent43e98717ad40a4ae64545b5ba047c7b86aa44f4f (diff)
parent3280f21d43ee541f97f8cda5792150d2dbec20d5 (diff)
Merge branch 'wip-2.6.34' into old-private-masterarchived-private-master
Diffstat (limited to 'arch/arm/plat-omap/dmtimer.c')
-rw-r--r--arch/arm/plat-omap/dmtimer.c153
1 files changed, 76 insertions, 77 deletions
diff --git a/arch/arm/plat-omap/dmtimer.c b/arch/arm/plat-omap/dmtimer.c
index d325b54daeb5..4d99dfbc8bef 100644
--- a/arch/arm/plat-omap/dmtimer.c
+++ b/arch/arm/plat-omap/dmtimer.c
@@ -38,7 +38,7 @@
38#include <linux/io.h> 38#include <linux/io.h>
39#include <linux/module.h> 39#include <linux/module.h>
40#include <mach/hardware.h> 40#include <mach/hardware.h>
41#include <mach/dmtimer.h> 41#include <plat/dmtimer.h>
42#include <mach/irqs.h> 42#include <mach/irqs.h>
43 43
44/* register offsets */ 44/* register offsets */
@@ -153,8 +153,7 @@
153struct omap_dm_timer { 153struct omap_dm_timer {
154 unsigned long phys_base; 154 unsigned long phys_base;
155 int irq; 155 int irq;
156#if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3) || \ 156#ifdef CONFIG_ARCH_OMAP2PLUS
157 defined(CONFIG_ARCH_OMAP4)
158 struct clk *iclk, *fclk; 157 struct clk *iclk, *fclk;
159#endif 158#endif
160 void __iomem *io_base; 159 void __iomem *io_base;
@@ -163,20 +162,9 @@ struct omap_dm_timer {
163 unsigned posted:1; 162 unsigned posted:1;
164}; 163};
165 164
166#ifdef CONFIG_ARCH_OMAP1 165static int dm_timer_count;
167
168#define omap_dm_clk_enable(x)
169#define omap_dm_clk_disable(x)
170#define omap2_dm_timers NULL
171#define omap2_dm_source_names NULL
172#define omap2_dm_source_clocks NULL
173#define omap3_dm_timers NULL
174#define omap3_dm_source_names NULL
175#define omap3_dm_source_clocks NULL
176#define omap4_dm_timers NULL
177#define omap4_dm_source_names NULL
178#define omap4_dm_source_clocks NULL
179 166
167#ifdef CONFIG_ARCH_OMAP1
180static struct omap_dm_timer omap1_dm_timers[] = { 168static struct omap_dm_timer omap1_dm_timers[] = {
181 { .phys_base = 0xfffb1400, .irq = INT_1610_GPTIMER1 }, 169 { .phys_base = 0xfffb1400, .irq = INT_1610_GPTIMER1 },
182 { .phys_base = 0xfffb1c00, .irq = INT_1610_GPTIMER2 }, 170 { .phys_base = 0xfffb1c00, .irq = INT_1610_GPTIMER2 },
@@ -188,20 +176,14 @@ static struct omap_dm_timer omap1_dm_timers[] = {
188 { .phys_base = 0xfffbd400, .irq = INT_1610_GPTIMER8 }, 176 { .phys_base = 0xfffbd400, .irq = INT_1610_GPTIMER8 },
189}; 177};
190 178
191static const int dm_timer_count = ARRAY_SIZE(omap1_dm_timers); 179static const int omap1_dm_timer_count = ARRAY_SIZE(omap1_dm_timers);
192 180
193#elif defined(CONFIG_ARCH_OMAP2) 181#else
194
195#define omap_dm_clk_enable(x) clk_enable(x)
196#define omap_dm_clk_disable(x) clk_disable(x)
197#define omap1_dm_timers NULL 182#define omap1_dm_timers NULL
198#define omap3_dm_timers NULL 183#define omap1_dm_timer_count 0
199#define omap3_dm_source_names NULL 184#endif /* CONFIG_ARCH_OMAP1 */
200#define omap3_dm_source_clocks NULL
201#define omap4_dm_timers NULL
202#define omap4_dm_source_names NULL
203#define omap4_dm_source_clocks NULL
204 185
186#ifdef CONFIG_ARCH_OMAP2
205static struct omap_dm_timer omap2_dm_timers[] = { 187static struct omap_dm_timer omap2_dm_timers[] = {
206 { .phys_base = 0x48028000, .irq = INT_24XX_GPTIMER1 }, 188 { .phys_base = 0x48028000, .irq = INT_24XX_GPTIMER1 },
207 { .phys_base = 0x4802a000, .irq = INT_24XX_GPTIMER2 }, 189 { .phys_base = 0x4802a000, .irq = INT_24XX_GPTIMER2 },
@@ -225,20 +207,16 @@ static const char *omap2_dm_source_names[] __initdata = {
225}; 207};
226 208
227static struct clk *omap2_dm_source_clocks[3]; 209static struct clk *omap2_dm_source_clocks[3];
228static const int dm_timer_count = ARRAY_SIZE(omap2_dm_timers); 210static const int omap2_dm_timer_count = ARRAY_SIZE(omap2_dm_timers);
229
230#elif defined(CONFIG_ARCH_OMAP3)
231 211
232#define omap_dm_clk_enable(x) clk_enable(x) 212#else
233#define omap_dm_clk_disable(x) clk_disable(x)
234#define omap1_dm_timers NULL
235#define omap2_dm_timers NULL 213#define omap2_dm_timers NULL
214#define omap2_dm_timer_count 0
236#define omap2_dm_source_names NULL 215#define omap2_dm_source_names NULL
237#define omap2_dm_source_clocks NULL 216#define omap2_dm_source_clocks NULL
238#define omap4_dm_timers NULL 217#endif /* CONFIG_ARCH_OMAP2 */
239#define omap4_dm_source_names NULL
240#define omap4_dm_source_clocks NULL
241 218
219#ifdef CONFIG_ARCH_OMAP3
242static struct omap_dm_timer omap3_dm_timers[] = { 220static struct omap_dm_timer omap3_dm_timers[] = {
243 { .phys_base = 0x48318000, .irq = INT_24XX_GPTIMER1 }, 221 { .phys_base = 0x48318000, .irq = INT_24XX_GPTIMER1 },
244 { .phys_base = 0x49032000, .irq = INT_24XX_GPTIMER2 }, 222 { .phys_base = 0x49032000, .irq = INT_24XX_GPTIMER2 },
@@ -261,33 +239,29 @@ static const char *omap3_dm_source_names[] __initdata = {
261}; 239};
262 240
263static struct clk *omap3_dm_source_clocks[2]; 241static struct clk *omap3_dm_source_clocks[2];
264static const int dm_timer_count = ARRAY_SIZE(omap3_dm_timers); 242static const int omap3_dm_timer_count = ARRAY_SIZE(omap3_dm_timers);
265
266#elif defined(CONFIG_ARCH_OMAP4)
267 243
268#define omap_dm_clk_enable(x) clk_enable(x) 244#else
269#define omap_dm_clk_disable(x) clk_disable(x)
270#define omap1_dm_timers NULL
271#define omap2_dm_timers NULL
272#define omap2_dm_source_names NULL
273#define omap2_dm_source_clocks NULL
274#define omap3_dm_timers NULL 245#define omap3_dm_timers NULL
246#define omap3_dm_timer_count 0
275#define omap3_dm_source_names NULL 247#define omap3_dm_source_names NULL
276#define omap3_dm_source_clocks NULL 248#define omap3_dm_source_clocks NULL
249#endif /* CONFIG_ARCH_OMAP3 */
277 250
251#ifdef CONFIG_ARCH_OMAP4
278static struct omap_dm_timer omap4_dm_timers[] = { 252static struct omap_dm_timer omap4_dm_timers[] = {
279 { .phys_base = 0x4a318000, .irq = INT_44XX_GPTIMER1 }, 253 { .phys_base = 0x4a318000, .irq = OMAP44XX_IRQ_GPT1 },
280 { .phys_base = 0x48032000, .irq = INT_44XX_GPTIMER2 }, 254 { .phys_base = 0x48032000, .irq = OMAP44XX_IRQ_GPT2 },
281 { .phys_base = 0x48034000, .irq = INT_44XX_GPTIMER3 }, 255 { .phys_base = 0x48034000, .irq = OMAP44XX_IRQ_GPT3 },
282 { .phys_base = 0x48036000, .irq = INT_44XX_GPTIMER4 }, 256 { .phys_base = 0x48036000, .irq = OMAP44XX_IRQ_GPT4 },
283 { .phys_base = 0x40138000, .irq = INT_44XX_GPTIMER5 }, 257 { .phys_base = 0x40138000, .irq = OMAP44XX_IRQ_GPT5 },
284 { .phys_base = 0x4013a000, .irq = INT_44XX_GPTIMER6 }, 258 { .phys_base = 0x4013a000, .irq = OMAP44XX_IRQ_GPT6 },
285 { .phys_base = 0x4013a000, .irq = INT_44XX_GPTIMER7 }, 259 { .phys_base = 0x4013a000, .irq = OMAP44XX_IRQ_GPT7 },
286 { .phys_base = 0x4013e000, .irq = INT_44XX_GPTIMER8 }, 260 { .phys_base = 0x4013e000, .irq = OMAP44XX_IRQ_GPT8 },
287 { .phys_base = 0x4803e000, .irq = INT_44XX_GPTIMER9 }, 261 { .phys_base = 0x4803e000, .irq = OMAP44XX_IRQ_GPT9 },
288 { .phys_base = 0x48086000, .irq = INT_44XX_GPTIMER10 }, 262 { .phys_base = 0x48086000, .irq = OMAP44XX_IRQ_GPT10 },
289 { .phys_base = 0x48088000, .irq = INT_44XX_GPTIMER11 }, 263 { .phys_base = 0x48088000, .irq = OMAP44XX_IRQ_GPT11 },
290 { .phys_base = 0x4a320000, .irq = INT_44XX_GPTIMER12 }, 264 { .phys_base = 0x4a320000, .irq = OMAP44XX_IRQ_GPT12 },
291}; 265};
292static const char *omap4_dm_source_names[] __initdata = { 266static const char *omap4_dm_source_names[] __initdata = {
293 "sys_ck", 267 "sys_ck",
@@ -295,13 +269,14 @@ static const char *omap4_dm_source_names[] __initdata = {
295 NULL 269 NULL
296}; 270};
297static struct clk *omap4_dm_source_clocks[2]; 271static struct clk *omap4_dm_source_clocks[2];
298static const int dm_timer_count = ARRAY_SIZE(omap4_dm_timers); 272static const int omap4_dm_timer_count = ARRAY_SIZE(omap4_dm_timers);
299 273
300#else 274#else
301 275#define omap4_dm_timers NULL
302#error OMAP architecture not supported! 276#define omap4_dm_timer_count 0
303 277#define omap4_dm_source_names NULL
304#endif 278#define omap4_dm_source_clocks NULL
279#endif /* CONFIG_ARCH_OMAP4 */
305 280
306static struct omap_dm_timer *dm_timers; 281static struct omap_dm_timer *dm_timers;
307static const char **dm_source_names; 282static const char **dm_source_names;
@@ -450,8 +425,12 @@ void omap_dm_timer_enable(struct omap_dm_timer *timer)
450 if (timer->enabled) 425 if (timer->enabled)
451 return; 426 return;
452 427
453 omap_dm_clk_enable(timer->fclk); 428#ifdef CONFIG_ARCH_OMAP2PLUS
454 omap_dm_clk_enable(timer->iclk); 429 if (cpu_class_is_omap2()) {
430 clk_enable(timer->fclk);
431 clk_enable(timer->iclk);
432 }
433#endif
455 434
456 timer->enabled = 1; 435 timer->enabled = 1;
457} 436}
@@ -462,8 +441,12 @@ void omap_dm_timer_disable(struct omap_dm_timer *timer)
462 if (!timer->enabled) 441 if (!timer->enabled)
463 return; 442 return;
464 443
465 omap_dm_clk_disable(timer->iclk); 444#ifdef CONFIG_ARCH_OMAP2PLUS
466 omap_dm_clk_disable(timer->fclk); 445 if (cpu_class_is_omap2()) {
446 clk_disable(timer->iclk);
447 clk_disable(timer->fclk);
448 }
449#endif
467 450
468 timer->enabled = 0; 451 timer->enabled = 0;
469} 452}
@@ -506,8 +489,7 @@ __u32 omap_dm_timer_modify_idlect_mask(__u32 inputmask)
506} 489}
507EXPORT_SYMBOL_GPL(omap_dm_timer_modify_idlect_mask); 490EXPORT_SYMBOL_GPL(omap_dm_timer_modify_idlect_mask);
508 491
509#elif defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3) || \ 492#else
510 defined(CONFIG_ARCH_OMAP4)
511 493
512struct clk *omap_dm_timer_get_fclk(struct omap_dm_timer *timer) 494struct clk *omap_dm_timer_get_fclk(struct omap_dm_timer *timer)
513{ 495{
@@ -551,6 +533,18 @@ void omap_dm_timer_stop(struct omap_dm_timer *timer)
551 if (l & OMAP_TIMER_CTRL_ST) { 533 if (l & OMAP_TIMER_CTRL_ST) {
552 l &= ~0x1; 534 l &= ~0x1;
553 omap_dm_timer_write_reg(timer, OMAP_TIMER_CTRL_REG, l); 535 omap_dm_timer_write_reg(timer, OMAP_TIMER_CTRL_REG, l);
536#ifdef CONFIG_ARCH_OMAP2PLUS
537 /* Readback to make sure write has completed */
538 omap_dm_timer_read_reg(timer, OMAP_TIMER_CTRL_REG);
539 /*
540 * Wait for functional clock period x 3.5 to make sure that
541 * timer is stopped
542 */
543 udelay(3500000 / clk_get_rate(timer->fclk) + 1);
544 /* Ack possibly pending interrupt */
545 omap_dm_timer_write_reg(timer, OMAP_TIMER_STAT_REG,
546 OMAP_TIMER_INT_OVERFLOW);
547#endif
554 } 548 }
555} 549}
556EXPORT_SYMBOL_GPL(omap_dm_timer_stop); 550EXPORT_SYMBOL_GPL(omap_dm_timer_stop);
@@ -742,25 +736,30 @@ EXPORT_SYMBOL_GPL(omap_dm_timers_active);
742int __init omap_dm_timer_init(void) 736int __init omap_dm_timer_init(void)
743{ 737{
744 struct omap_dm_timer *timer; 738 struct omap_dm_timer *timer;
745 int i; 739 int i, map_size = SZ_8K; /* Module 4KB + L4 4KB except on omap1 */
746 740
747 if (!(cpu_is_omap16xx() || cpu_class_is_omap2())) 741 if (!(cpu_is_omap16xx() || cpu_class_is_omap2()))
748 return -ENODEV; 742 return -ENODEV;
749 743
750 spin_lock_init(&dm_timer_lock); 744 spin_lock_init(&dm_timer_lock);
751 745
752 if (cpu_class_is_omap1()) 746 if (cpu_class_is_omap1()) {
753 dm_timers = omap1_dm_timers; 747 dm_timers = omap1_dm_timers;
754 else if (cpu_is_omap24xx()) { 748 dm_timer_count = omap1_dm_timer_count;
749 map_size = SZ_2K;
750 } else if (cpu_is_omap24xx()) {
755 dm_timers = omap2_dm_timers; 751 dm_timers = omap2_dm_timers;
752 dm_timer_count = omap2_dm_timer_count;
756 dm_source_names = omap2_dm_source_names; 753 dm_source_names = omap2_dm_source_names;
757 dm_source_clocks = omap2_dm_source_clocks; 754 dm_source_clocks = omap2_dm_source_clocks;
758 } else if (cpu_is_omap34xx()) { 755 } else if (cpu_is_omap34xx()) {
759 dm_timers = omap3_dm_timers; 756 dm_timers = omap3_dm_timers;
757 dm_timer_count = omap3_dm_timer_count;
760 dm_source_names = omap3_dm_source_names; 758 dm_source_names = omap3_dm_source_names;
761 dm_source_clocks = omap3_dm_source_clocks; 759 dm_source_clocks = omap3_dm_source_clocks;
762 } else if (cpu_is_omap44xx()) { 760 } else if (cpu_is_omap44xx()) {
763 dm_timers = omap4_dm_timers; 761 dm_timers = omap4_dm_timers;
762 dm_timer_count = omap4_dm_timer_count;
764 dm_source_names = omap4_dm_source_names; 763 dm_source_names = omap4_dm_source_names;
765 dm_source_clocks = omap4_dm_source_clocks; 764 dm_source_clocks = omap4_dm_source_clocks;
766 } 765 }
@@ -774,12 +773,12 @@ int __init omap_dm_timer_init(void)
774 773
775 for (i = 0; i < dm_timer_count; i++) { 774 for (i = 0; i < dm_timer_count; i++) {
776 timer = &dm_timers[i]; 775 timer = &dm_timers[i];
777 if (cpu_class_is_omap1()) 776
778 timer->io_base = OMAP1_IO_ADDRESS(timer->phys_base); 777 /* Static mapping, never released */
779 else 778 timer->io_base = ioremap(timer->phys_base, map_size);
780 timer->io_base = OMAP2_IO_ADDRESS(timer->phys_base); 779 BUG_ON(!timer->io_base);
781#if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3) || \ 780
782 defined(CONFIG_ARCH_OMAP4) 781#ifdef CONFIG_ARCH_OMAP2PLUS
783 if (cpu_class_is_omap2()) { 782 if (cpu_class_is_omap2()) {
784 char clk_name[16]; 783 char clk_name[16];
785 sprintf(clk_name, "gpt%d_ick", i + 1); 784 sprintf(clk_name, "gpt%d_ick", i + 1);