staging: brcm80211: decreased indentation level of brcms_c_wme_setparams function
[zen-stable.git] / arch / arm / plat-omap / dmtimer.c
blob75a847dd776a3d24ccca85c29aab32b90bbbe3e7
1 /*
2 * linux/arch/arm/plat-omap/dmtimer.c
4 * OMAP Dual-Mode Timers
6 * Copyright (C) 2005 Nokia Corporation
7 * OMAP2 support by Juha Yrjola
8 * API improvements and OMAP2 clock framework support by Timo Teras
10 * Copyright (C) 2009 Texas Instruments
11 * Added OMAP4 support - Santosh Shilimkar <santosh.shilimkar@ti.com>
13 * This program is free software; you can redistribute it and/or modify it
14 * under the terms of the GNU General Public License as published by the
15 * Free Software Foundation; either version 2 of the License, or (at your
16 * option) any later version.
18 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
19 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
20 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
21 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 * You should have received a copy of the GNU General Public License along
28 * with this program; if not, write to the Free Software Foundation, Inc.,
29 * 675 Mass Ave, Cambridge, MA 02139, USA.
32 #include <linux/init.h>
33 #include <linux/spinlock.h>
34 #include <linux/errno.h>
35 #include <linux/list.h>
36 #include <linux/clk.h>
37 #include <linux/delay.h>
38 #include <linux/io.h>
39 #include <linux/module.h>
40 #include <mach/hardware.h>
41 #include <plat/dmtimer.h>
42 #include <mach/irqs.h>
44 static int dm_timer_count;
46 #ifdef CONFIG_ARCH_OMAP1
47 static struct omap_dm_timer omap1_dm_timers[] = {
48 { .phys_base = 0xfffb1400, .irq = INT_1610_GPTIMER1 },
49 { .phys_base = 0xfffb1c00, .irq = INT_1610_GPTIMER2 },
50 { .phys_base = 0xfffb2400, .irq = INT_1610_GPTIMER3 },
51 { .phys_base = 0xfffb2c00, .irq = INT_1610_GPTIMER4 },
52 { .phys_base = 0xfffb3400, .irq = INT_1610_GPTIMER5 },
53 { .phys_base = 0xfffb3c00, .irq = INT_1610_GPTIMER6 },
54 { .phys_base = 0xfffb7400, .irq = INT_1610_GPTIMER7 },
55 { .phys_base = 0xfffbd400, .irq = INT_1610_GPTIMER8 },
58 static const int omap1_dm_timer_count = ARRAY_SIZE(omap1_dm_timers);
60 #else
61 #define omap1_dm_timers NULL
62 #define omap1_dm_timer_count 0
63 #endif /* CONFIG_ARCH_OMAP1 */
65 #ifdef CONFIG_ARCH_OMAP2
66 static struct omap_dm_timer omap2_dm_timers[] = {
67 { .phys_base = 0x48028000, .irq = INT_24XX_GPTIMER1 },
68 { .phys_base = 0x4802a000, .irq = INT_24XX_GPTIMER2 },
69 { .phys_base = 0x48078000, .irq = INT_24XX_GPTIMER3 },
70 { .phys_base = 0x4807a000, .irq = INT_24XX_GPTIMER4 },
71 { .phys_base = 0x4807c000, .irq = INT_24XX_GPTIMER5 },
72 { .phys_base = 0x4807e000, .irq = INT_24XX_GPTIMER6 },
73 { .phys_base = 0x48080000, .irq = INT_24XX_GPTIMER7 },
74 { .phys_base = 0x48082000, .irq = INT_24XX_GPTIMER8 },
75 { .phys_base = 0x48084000, .irq = INT_24XX_GPTIMER9 },
76 { .phys_base = 0x48086000, .irq = INT_24XX_GPTIMER10 },
77 { .phys_base = 0x48088000, .irq = INT_24XX_GPTIMER11 },
78 { .phys_base = 0x4808a000, .irq = INT_24XX_GPTIMER12 },
81 static const char *omap2_dm_source_names[] __initdata = {
82 "sys_ck",
83 "func_32k_ck",
84 "alt_ck",
85 NULL
88 static struct clk *omap2_dm_source_clocks[3];
89 static const int omap2_dm_timer_count = ARRAY_SIZE(omap2_dm_timers);
91 #else
92 #define omap2_dm_timers NULL
93 #define omap2_dm_timer_count 0
94 #define omap2_dm_source_names NULL
95 #define omap2_dm_source_clocks NULL
96 #endif /* CONFIG_ARCH_OMAP2 */
98 #ifdef CONFIG_ARCH_OMAP3
99 static struct omap_dm_timer omap3_dm_timers[] = {
100 { .phys_base = 0x48318000, .irq = INT_24XX_GPTIMER1 },
101 { .phys_base = 0x49032000, .irq = INT_24XX_GPTIMER2 },
102 { .phys_base = 0x49034000, .irq = INT_24XX_GPTIMER3 },
103 { .phys_base = 0x49036000, .irq = INT_24XX_GPTIMER4 },
104 { .phys_base = 0x49038000, .irq = INT_24XX_GPTIMER5 },
105 { .phys_base = 0x4903A000, .irq = INT_24XX_GPTIMER6 },
106 { .phys_base = 0x4903C000, .irq = INT_24XX_GPTIMER7 },
107 { .phys_base = 0x4903E000, .irq = INT_24XX_GPTIMER8 },
108 { .phys_base = 0x49040000, .irq = INT_24XX_GPTIMER9 },
109 { .phys_base = 0x48086000, .irq = INT_24XX_GPTIMER10 },
110 { .phys_base = 0x48088000, .irq = INT_24XX_GPTIMER11 },
111 { .phys_base = 0x48304000, .irq = INT_34XX_GPT12_IRQ },
114 static const char *omap3_dm_source_names[] __initdata = {
115 "sys_ck",
116 "omap_32k_fck",
117 NULL
120 static struct clk *omap3_dm_source_clocks[2];
121 static const int omap3_dm_timer_count = ARRAY_SIZE(omap3_dm_timers);
123 #else
124 #define omap3_dm_timers NULL
125 #define omap3_dm_timer_count 0
126 #define omap3_dm_source_names NULL
127 #define omap3_dm_source_clocks NULL
128 #endif /* CONFIG_ARCH_OMAP3 */
130 #ifdef CONFIG_ARCH_OMAP4
131 static struct omap_dm_timer omap4_dm_timers[] = {
132 { .phys_base = 0x4a318000, .irq = OMAP44XX_IRQ_GPT1 },
133 { .phys_base = 0x48032000, .irq = OMAP44XX_IRQ_GPT2 },
134 { .phys_base = 0x48034000, .irq = OMAP44XX_IRQ_GPT3 },
135 { .phys_base = 0x48036000, .irq = OMAP44XX_IRQ_GPT4 },
136 { .phys_base = 0x40138000, .irq = OMAP44XX_IRQ_GPT5 },
137 { .phys_base = 0x4013a000, .irq = OMAP44XX_IRQ_GPT6 },
138 { .phys_base = 0x4013a000, .irq = OMAP44XX_IRQ_GPT7 },
139 { .phys_base = 0x4013e000, .irq = OMAP44XX_IRQ_GPT8 },
140 { .phys_base = 0x4803e000, .irq = OMAP44XX_IRQ_GPT9 },
141 { .phys_base = 0x48086000, .irq = OMAP44XX_IRQ_GPT10 },
142 { .phys_base = 0x48088000, .irq = OMAP44XX_IRQ_GPT11 },
143 { .phys_base = 0x4a320000, .irq = OMAP44XX_IRQ_GPT12 },
145 static const char *omap4_dm_source_names[] __initdata = {
146 "sys_clkin_ck",
147 "sys_32k_ck",
148 NULL
150 static struct clk *omap4_dm_source_clocks[2];
151 static const int omap4_dm_timer_count = ARRAY_SIZE(omap4_dm_timers);
153 #else
154 #define omap4_dm_timers NULL
155 #define omap4_dm_timer_count 0
156 #define omap4_dm_source_names NULL
157 #define omap4_dm_source_clocks NULL
158 #endif /* CONFIG_ARCH_OMAP4 */
160 static struct omap_dm_timer *dm_timers;
161 static const char **dm_source_names;
162 static struct clk **dm_source_clocks;
164 static spinlock_t dm_timer_lock;
167 * Reads timer registers in posted and non-posted mode. The posted mode bit
168 * is encoded in reg. Note that in posted mode write pending bit must be
169 * checked. Otherwise a read of a non completed write will produce an error.
171 static inline u32 omap_dm_timer_read_reg(struct omap_dm_timer *timer, u32 reg)
173 return __omap_dm_timer_read(timer->io_base, reg, timer->posted);
177 * Writes timer registers in posted and non-posted mode. The posted mode bit
178 * is encoded in reg. Note that in posted mode the write pending bit must be
179 * checked. Otherwise a write on a register which has a pending write will be
180 * lost.
182 static void omap_dm_timer_write_reg(struct omap_dm_timer *timer, u32 reg,
183 u32 value)
185 __omap_dm_timer_write(timer->io_base, reg, value, timer->posted);
188 static void omap_dm_timer_wait_for_reset(struct omap_dm_timer *timer)
190 int c;
192 c = 0;
193 while (!(omap_dm_timer_read_reg(timer, OMAP_TIMER_SYS_STAT_REG) & 1)) {
194 c++;
195 if (c > 100000) {
196 printk(KERN_ERR "Timer failed to reset\n");
197 return;
202 static void omap_dm_timer_reset(struct omap_dm_timer *timer)
204 int autoidle = 0, wakeup = 0;
206 if (!cpu_class_is_omap2() || timer != &dm_timers[0]) {
207 omap_dm_timer_write_reg(timer, OMAP_TIMER_IF_CTRL_REG, 0x06);
208 omap_dm_timer_wait_for_reset(timer);
210 omap_dm_timer_set_source(timer, OMAP_TIMER_SRC_32_KHZ);
212 /* Enable autoidle on OMAP2+ */
213 if (cpu_class_is_omap2())
214 autoidle = 1;
217 * Enable wake-up on OMAP2 CPUs.
219 if (cpu_class_is_omap2())
220 wakeup = 1;
222 __omap_dm_timer_reset(timer->io_base, autoidle, wakeup);
223 timer->posted = 1;
226 void omap_dm_timer_prepare(struct omap_dm_timer *timer)
228 omap_dm_timer_enable(timer);
229 omap_dm_timer_reset(timer);
232 struct omap_dm_timer *omap_dm_timer_request(void)
234 struct omap_dm_timer *timer = NULL;
235 unsigned long flags;
236 int i;
238 spin_lock_irqsave(&dm_timer_lock, flags);
239 for (i = 0; i < dm_timer_count; i++) {
240 if (dm_timers[i].reserved)
241 continue;
243 timer = &dm_timers[i];
244 timer->reserved = 1;
245 break;
247 spin_unlock_irqrestore(&dm_timer_lock, flags);
249 if (timer != NULL)
250 omap_dm_timer_prepare(timer);
252 return timer;
254 EXPORT_SYMBOL_GPL(omap_dm_timer_request);
256 struct omap_dm_timer *omap_dm_timer_request_specific(int id)
258 struct omap_dm_timer *timer;
259 unsigned long flags;
261 spin_lock_irqsave(&dm_timer_lock, flags);
262 if (id <= 0 || id > dm_timer_count || dm_timers[id-1].reserved) {
263 spin_unlock_irqrestore(&dm_timer_lock, flags);
264 printk("BUG: warning at %s:%d/%s(): unable to get timer %d\n",
265 __FILE__, __LINE__, __func__, id);
266 dump_stack();
267 return NULL;
270 timer = &dm_timers[id-1];
271 timer->reserved = 1;
272 spin_unlock_irqrestore(&dm_timer_lock, flags);
274 omap_dm_timer_prepare(timer);
276 return timer;
278 EXPORT_SYMBOL_GPL(omap_dm_timer_request_specific);
280 void omap_dm_timer_free(struct omap_dm_timer *timer)
282 omap_dm_timer_enable(timer);
283 omap_dm_timer_reset(timer);
284 omap_dm_timer_disable(timer);
286 WARN_ON(!timer->reserved);
287 timer->reserved = 0;
289 EXPORT_SYMBOL_GPL(omap_dm_timer_free);
291 void omap_dm_timer_enable(struct omap_dm_timer *timer)
293 if (timer->enabled)
294 return;
296 #ifdef CONFIG_ARCH_OMAP2PLUS
297 if (cpu_class_is_omap2()) {
298 clk_enable(timer->fclk);
299 clk_enable(timer->iclk);
301 #endif
303 timer->enabled = 1;
305 EXPORT_SYMBOL_GPL(omap_dm_timer_enable);
307 void omap_dm_timer_disable(struct omap_dm_timer *timer)
309 if (!timer->enabled)
310 return;
312 #ifdef CONFIG_ARCH_OMAP2PLUS
313 if (cpu_class_is_omap2()) {
314 clk_disable(timer->iclk);
315 clk_disable(timer->fclk);
317 #endif
319 timer->enabled = 0;
321 EXPORT_SYMBOL_GPL(omap_dm_timer_disable);
323 int omap_dm_timer_get_irq(struct omap_dm_timer *timer)
325 return timer->irq;
327 EXPORT_SYMBOL_GPL(omap_dm_timer_get_irq);
329 #if defined(CONFIG_ARCH_OMAP1)
332 * omap_dm_timer_modify_idlect_mask - Check if any running timers use ARMXOR
333 * @inputmask: current value of idlect mask
335 __u32 omap_dm_timer_modify_idlect_mask(__u32 inputmask)
337 int i;
339 /* If ARMXOR cannot be idled this function call is unnecessary */
340 if (!(inputmask & (1 << 1)))
341 return inputmask;
343 /* If any active timer is using ARMXOR return modified mask */
344 for (i = 0; i < dm_timer_count; i++) {
345 u32 l;
347 l = omap_dm_timer_read_reg(&dm_timers[i], OMAP_TIMER_CTRL_REG);
348 if (l & OMAP_TIMER_CTRL_ST) {
349 if (((omap_readl(MOD_CONF_CTRL_1) >> (i * 2)) & 0x03) == 0)
350 inputmask &= ~(1 << 1);
351 else
352 inputmask &= ~(1 << 2);
356 return inputmask;
358 EXPORT_SYMBOL_GPL(omap_dm_timer_modify_idlect_mask);
360 #else
362 struct clk *omap_dm_timer_get_fclk(struct omap_dm_timer *timer)
364 return timer->fclk;
366 EXPORT_SYMBOL_GPL(omap_dm_timer_get_fclk);
368 __u32 omap_dm_timer_modify_idlect_mask(__u32 inputmask)
370 BUG();
372 return 0;
374 EXPORT_SYMBOL_GPL(omap_dm_timer_modify_idlect_mask);
376 #endif
378 void omap_dm_timer_trigger(struct omap_dm_timer *timer)
380 omap_dm_timer_write_reg(timer, OMAP_TIMER_TRIGGER_REG, 0);
382 EXPORT_SYMBOL_GPL(omap_dm_timer_trigger);
384 void omap_dm_timer_start(struct omap_dm_timer *timer)
386 u32 l;
388 l = omap_dm_timer_read_reg(timer, OMAP_TIMER_CTRL_REG);
389 if (!(l & OMAP_TIMER_CTRL_ST)) {
390 l |= OMAP_TIMER_CTRL_ST;
391 omap_dm_timer_write_reg(timer, OMAP_TIMER_CTRL_REG, l);
394 EXPORT_SYMBOL_GPL(omap_dm_timer_start);
396 void omap_dm_timer_stop(struct omap_dm_timer *timer)
398 unsigned long rate = 0;
400 #ifdef CONFIG_ARCH_OMAP2PLUS
401 rate = clk_get_rate(timer->fclk);
402 #endif
404 __omap_dm_timer_stop(timer->io_base, timer->posted, rate);
406 EXPORT_SYMBOL_GPL(omap_dm_timer_stop);
408 #ifdef CONFIG_ARCH_OMAP1
410 int omap_dm_timer_set_source(struct omap_dm_timer *timer, int source)
412 int n = (timer - dm_timers) << 1;
413 u32 l;
415 l = omap_readl(MOD_CONF_CTRL_1) & ~(0x03 << n);
416 l |= source << n;
417 omap_writel(l, MOD_CONF_CTRL_1);
419 return 0;
421 EXPORT_SYMBOL_GPL(omap_dm_timer_set_source);
423 #else
425 int omap_dm_timer_set_source(struct omap_dm_timer *timer, int source)
427 if (source < 0 || source >= 3)
428 return -EINVAL;
430 return __omap_dm_timer_set_source(timer->fclk,
431 dm_source_clocks[source]);
433 EXPORT_SYMBOL_GPL(omap_dm_timer_set_source);
435 #endif
437 void omap_dm_timer_set_load(struct omap_dm_timer *timer, int autoreload,
438 unsigned int load)
440 u32 l;
442 l = omap_dm_timer_read_reg(timer, OMAP_TIMER_CTRL_REG);
443 if (autoreload)
444 l |= OMAP_TIMER_CTRL_AR;
445 else
446 l &= ~OMAP_TIMER_CTRL_AR;
447 omap_dm_timer_write_reg(timer, OMAP_TIMER_CTRL_REG, l);
448 omap_dm_timer_write_reg(timer, OMAP_TIMER_LOAD_REG, load);
450 omap_dm_timer_write_reg(timer, OMAP_TIMER_TRIGGER_REG, 0);
452 EXPORT_SYMBOL_GPL(omap_dm_timer_set_load);
454 /* Optimized set_load which removes costly spin wait in timer_start */
455 void omap_dm_timer_set_load_start(struct omap_dm_timer *timer, int autoreload,
456 unsigned int load)
458 u32 l;
460 l = omap_dm_timer_read_reg(timer, OMAP_TIMER_CTRL_REG);
461 if (autoreload) {
462 l |= OMAP_TIMER_CTRL_AR;
463 omap_dm_timer_write_reg(timer, OMAP_TIMER_LOAD_REG, load);
464 } else {
465 l &= ~OMAP_TIMER_CTRL_AR;
467 l |= OMAP_TIMER_CTRL_ST;
469 __omap_dm_timer_load_start(timer->io_base, l, load, timer->posted);
471 EXPORT_SYMBOL_GPL(omap_dm_timer_set_load_start);
473 void omap_dm_timer_set_match(struct omap_dm_timer *timer, int enable,
474 unsigned int match)
476 u32 l;
478 l = omap_dm_timer_read_reg(timer, OMAP_TIMER_CTRL_REG);
479 if (enable)
480 l |= OMAP_TIMER_CTRL_CE;
481 else
482 l &= ~OMAP_TIMER_CTRL_CE;
483 omap_dm_timer_write_reg(timer, OMAP_TIMER_CTRL_REG, l);
484 omap_dm_timer_write_reg(timer, OMAP_TIMER_MATCH_REG, match);
486 EXPORT_SYMBOL_GPL(omap_dm_timer_set_match);
488 void omap_dm_timer_set_pwm(struct omap_dm_timer *timer, int def_on,
489 int toggle, int trigger)
491 u32 l;
493 l = omap_dm_timer_read_reg(timer, OMAP_TIMER_CTRL_REG);
494 l &= ~(OMAP_TIMER_CTRL_GPOCFG | OMAP_TIMER_CTRL_SCPWM |
495 OMAP_TIMER_CTRL_PT | (0x03 << 10));
496 if (def_on)
497 l |= OMAP_TIMER_CTRL_SCPWM;
498 if (toggle)
499 l |= OMAP_TIMER_CTRL_PT;
500 l |= trigger << 10;
501 omap_dm_timer_write_reg(timer, OMAP_TIMER_CTRL_REG, l);
503 EXPORT_SYMBOL_GPL(omap_dm_timer_set_pwm);
505 void omap_dm_timer_set_prescaler(struct omap_dm_timer *timer, int prescaler)
507 u32 l;
509 l = omap_dm_timer_read_reg(timer, OMAP_TIMER_CTRL_REG);
510 l &= ~(OMAP_TIMER_CTRL_PRE | (0x07 << 2));
511 if (prescaler >= 0x00 && prescaler <= 0x07) {
512 l |= OMAP_TIMER_CTRL_PRE;
513 l |= prescaler << 2;
515 omap_dm_timer_write_reg(timer, OMAP_TIMER_CTRL_REG, l);
517 EXPORT_SYMBOL_GPL(omap_dm_timer_set_prescaler);
519 void omap_dm_timer_set_int_enable(struct omap_dm_timer *timer,
520 unsigned int value)
522 __omap_dm_timer_int_enable(timer->io_base, value);
524 EXPORT_SYMBOL_GPL(omap_dm_timer_set_int_enable);
526 unsigned int omap_dm_timer_read_status(struct omap_dm_timer *timer)
528 unsigned int l;
530 l = omap_dm_timer_read_reg(timer, OMAP_TIMER_STAT_REG);
532 return l;
534 EXPORT_SYMBOL_GPL(omap_dm_timer_read_status);
536 void omap_dm_timer_write_status(struct omap_dm_timer *timer, unsigned int value)
538 __omap_dm_timer_write_status(timer->io_base, value);
540 EXPORT_SYMBOL_GPL(omap_dm_timer_write_status);
542 unsigned int omap_dm_timer_read_counter(struct omap_dm_timer *timer)
544 return __omap_dm_timer_read_counter(timer->io_base, timer->posted);
546 EXPORT_SYMBOL_GPL(omap_dm_timer_read_counter);
548 void omap_dm_timer_write_counter(struct omap_dm_timer *timer, unsigned int value)
550 omap_dm_timer_write_reg(timer, OMAP_TIMER_COUNTER_REG, value);
552 EXPORT_SYMBOL_GPL(omap_dm_timer_write_counter);
554 int omap_dm_timers_active(void)
556 int i;
558 for (i = 0; i < dm_timer_count; i++) {
559 struct omap_dm_timer *timer;
561 timer = &dm_timers[i];
563 if (!timer->enabled)
564 continue;
566 if (omap_dm_timer_read_reg(timer, OMAP_TIMER_CTRL_REG) &
567 OMAP_TIMER_CTRL_ST) {
568 return 1;
571 return 0;
573 EXPORT_SYMBOL_GPL(omap_dm_timers_active);
575 static int __init omap_dm_timer_init(void)
577 struct omap_dm_timer *timer;
578 int i, map_size = SZ_8K; /* Module 4KB + L4 4KB except on omap1 */
580 if (!(cpu_is_omap16xx() || cpu_class_is_omap2()))
581 return -ENODEV;
583 spin_lock_init(&dm_timer_lock);
585 if (cpu_class_is_omap1()) {
586 dm_timers = omap1_dm_timers;
587 dm_timer_count = omap1_dm_timer_count;
588 map_size = SZ_2K;
589 } else if (cpu_is_omap24xx()) {
590 dm_timers = omap2_dm_timers;
591 dm_timer_count = omap2_dm_timer_count;
592 dm_source_names = omap2_dm_source_names;
593 dm_source_clocks = omap2_dm_source_clocks;
594 } else if (cpu_is_omap34xx()) {
595 dm_timers = omap3_dm_timers;
596 dm_timer_count = omap3_dm_timer_count;
597 dm_source_names = omap3_dm_source_names;
598 dm_source_clocks = omap3_dm_source_clocks;
599 } else if (cpu_is_omap44xx()) {
600 dm_timers = omap4_dm_timers;
601 dm_timer_count = omap4_dm_timer_count;
602 dm_source_names = omap4_dm_source_names;
603 dm_source_clocks = omap4_dm_source_clocks;
606 if (cpu_class_is_omap2())
607 for (i = 0; dm_source_names[i] != NULL; i++)
608 dm_source_clocks[i] = clk_get(NULL, dm_source_names[i]);
610 if (cpu_is_omap243x())
611 dm_timers[0].phys_base = 0x49018000;
613 for (i = 0; i < dm_timer_count; i++) {
614 timer = &dm_timers[i];
616 /* Static mapping, never released */
617 timer->io_base = ioremap(timer->phys_base, map_size);
618 BUG_ON(!timer->io_base);
620 #ifdef CONFIG_ARCH_OMAP2PLUS
621 if (cpu_class_is_omap2()) {
622 char clk_name[16];
623 sprintf(clk_name, "gpt%d_ick", i + 1);
624 timer->iclk = clk_get(NULL, clk_name);
625 sprintf(clk_name, "gpt%d_fck", i + 1);
626 timer->fclk = clk_get(NULL, clk_name);
629 /* One or two timers may be set up early for sys_timer */
630 if (sys_timer_reserved & (1 << i)) {
631 timer->reserved = 1;
632 timer->posted = 1;
634 #endif
637 return 0;
640 arch_initcall(omap_dm_timer_init);