aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-omap2
diff options
context:
space:
mode:
authorOlof Johansson <olof@lixom.net>2012-11-30 01:30:11 -0500
committerOlof Johansson <olof@lixom.net>2012-11-30 01:30:11 -0500
commitc8a1ceccf394b2f99feed2b702732140e9f0f92d (patch)
tree6632d05aae22e99d7f128104b536bfdfc225a696 /arch/arm/mach-omap2
parent4c929c8a8837f4e5acdec5883a1b64a240751e2f (diff)
parent26f01998b0657a61167a819f1c37cb9f9e9d674b (diff)
Merge tag 'omap-for-v3.8/cleanup-timer-signed' of git://git.kernel.org/pub/scm/linux/kernel/git/tmlind/linux-omap into next/cleanup
Timer clean-up to get us closer to moving timer code to drivers, and to get rid of CONFIG_OMAP_32K_TIMER and rely on the board or devicetree provided timer configuration. Note that these changes are on top of the recent timer fixes. By Jon Hunter (32) and others via Tony Lindgren * tag 'omap-for-v3.8/cleanup-timer-signed' of git://git.kernel.org/pub/scm/linux/kernel/git/tmlind/linux-omap: (71 commits) ARM: OMAP3: cm-t3517: use GPTIMER for system clock ARM: OMAP2+: timer: remove CONFIG_OMAP_32K_TIMER ARM: OMAP2+: Fix compiler warning for 32k timer ARM: OMAP: Remove unnecessary inclusion of dmtimer.h ARM: OMAP: Add platform data header for DMTIMERs ARM: OMAP: Remove unnecessary omap_dm_timer structure declaration ARM: OMAP2+: Remove unnecessary local variable in timer code ARM: OMAP: Don't store timers physical address ARM: OMAP: Define omap_dm_timer_prepare function as static ARM: OMAP: Clean-up dmtimer reset code ARM: OMAP: Remove __omap_dm_timer_set_source function ARM: OMAP: Remove unnecessary call to clk_get() ARM: OMAP: Add dmtimer interrupt disable function ARM: OMAP: Fix spurious interrupts when using timer match feature ARM: OMAP: Don't restore DMTIMER interrupt status register ARM: OMAP: Don't restore of DMTIMER TISTAT register ARM: OMAP: Fix dmtimer reset for timer1 ARM: OMAP2+: Don't use __omap_dm_timer_reset() ARM: OMAP2/3: Define HWMOD software reset status for DMTIMERs ARM: OMAP3: Correct HWMOD DMTIMER SYSC register declarations ... Change/change conflict in arch/arm/mach-omap2/board-cm-t3517.c. Signed-off-by: Olof Johansson <olof@lixom.net>
Diffstat (limited to 'arch/arm/mach-omap2')
-rw-r--r--arch/arm/mach-omap2/board-cm-t3517.c2
-rw-r--r--arch/arm/mach-omap2/board-generic.c17
-rw-r--r--arch/arm/mach-omap2/common.h1
-rw-r--r--arch/arm/mach-omap2/omap_hwmod_2420_data.c1
-rw-r--r--arch/arm/mach-omap2/omap_hwmod_2430_data.c1
-rw-r--r--arch/arm/mach-omap2/omap_hwmod_2xxx_ipblock_data.c15
-rw-r--r--arch/arm/mach-omap2/omap_hwmod_3xxx_data.c41
-rw-r--r--arch/arm/mach-omap2/omap_hwmod_44xx_data.c4
-rw-r--r--arch/arm/mach-omap2/pm-debug.c1
-rw-r--r--arch/arm/mach-omap2/timer.c382
10 files changed, 322 insertions, 143 deletions
diff --git a/arch/arm/mach-omap2/board-cm-t3517.c b/arch/arm/mach-omap2/board-cm-t3517.c
index 699caec8f9e2..ebbc2adb499e 100644
--- a/arch/arm/mach-omap2/board-cm-t3517.c
+++ b/arch/arm/mach-omap2/board-cm-t3517.c
@@ -297,6 +297,6 @@ MACHINE_START(CM_T3517, "Compulab CM-T3517")
297 .handle_irq = omap3_intc_handle_irq, 297 .handle_irq = omap3_intc_handle_irq,
298 .init_machine = cm_t3517_init, 298 .init_machine = cm_t3517_init,
299 .init_late = am35xx_init_late, 299 .init_late = am35xx_init_late,
300 .timer = &omap3_timer, 300 .timer = &omap3_gp_timer,
301 .restart = omap3xxx_restart, 301 .restart = omap3xxx_restart,
302MACHINE_END 302MACHINE_END
diff --git a/arch/arm/mach-omap2/board-generic.c b/arch/arm/mach-omap2/board-generic.c
index 475e14f07216..aa6e4a19dd90 100644
--- a/arch/arm/mach-omap2/board-generic.c
+++ b/arch/arm/mach-omap2/board-generic.c
@@ -97,6 +97,23 @@ DT_MACHINE_START(OMAP3_DT, "Generic OMAP3 (Flattened Device Tree)")
97 .dt_compat = omap3_boards_compat, 97 .dt_compat = omap3_boards_compat,
98 .restart = omap3xxx_restart, 98 .restart = omap3xxx_restart,
99MACHINE_END 99MACHINE_END
100
101static const char *omap3_gp_boards_compat[] __initdata = {
102 "ti,omap3-beagle",
103 NULL,
104};
105
106DT_MACHINE_START(OMAP3_GP_DT, "Generic OMAP3-GP (Flattened Device Tree)")
107 .reserve = omap_reserve,
108 .map_io = omap3_map_io,
109 .init_early = omap3430_init_early,
110 .init_irq = omap_intc_of_init,
111 .handle_irq = omap3_intc_handle_irq,
112 .init_machine = omap_generic_init,
113 .timer = &omap3_secure_timer,
114 .dt_compat = omap3_gp_boards_compat,
115 .restart = omap_prcm_restart,
116MACHINE_END
100#endif 117#endif
101 118
102#ifdef CONFIG_SOC_AM33XX 119#ifdef CONFIG_SOC_AM33XX
diff --git a/arch/arm/mach-omap2/common.h b/arch/arm/mach-omap2/common.h
index 08c586451f93..3bbcde87dead 100644
--- a/arch/arm/mach-omap2/common.h
+++ b/arch/arm/mach-omap2/common.h
@@ -82,6 +82,7 @@ extern void omap2_init_common_infrastructure(void);
82extern struct sys_timer omap2_timer; 82extern struct sys_timer omap2_timer;
83extern struct sys_timer omap3_timer; 83extern struct sys_timer omap3_timer;
84extern struct sys_timer omap3_secure_timer; 84extern struct sys_timer omap3_secure_timer;
85extern struct sys_timer omap3_gp_timer;
85extern struct sys_timer omap3_am33xx_timer; 86extern struct sys_timer omap3_am33xx_timer;
86extern struct sys_timer omap4_timer; 87extern struct sys_timer omap4_timer;
87extern struct sys_timer omap5_timer; 88extern struct sys_timer omap5_timer;
diff --git a/arch/arm/mach-omap2/omap_hwmod_2420_data.c b/arch/arm/mach-omap2/omap_hwmod_2420_data.c
index a8b3368dca3d..e8efe3d1da6c 100644
--- a/arch/arm/mach-omap2/omap_hwmod_2420_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_2420_data.c
@@ -17,7 +17,6 @@
17#include <linux/platform_data/spi-omap2-mcspi.h> 17#include <linux/platform_data/spi-omap2-mcspi.h>
18 18
19#include <plat-omap/dma-omap.h> 19#include <plat-omap/dma-omap.h>
20#include <plat/dmtimer.h>
21 20
22#include "omap_hwmod.h" 21#include "omap_hwmod.h"
23#include "l3_2xxx.h" 22#include "l3_2xxx.h"
diff --git a/arch/arm/mach-omap2/omap_hwmod_2430_data.c b/arch/arm/mach-omap2/omap_hwmod_2430_data.c
index dc768c50e523..32d17e3fd727 100644
--- a/arch/arm/mach-omap2/omap_hwmod_2430_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_2430_data.c
@@ -18,7 +18,6 @@
18#include <linux/platform_data/spi-omap2-mcspi.h> 18#include <linux/platform_data/spi-omap2-mcspi.h>
19 19
20#include <plat-omap/dma-omap.h> 20#include <plat-omap/dma-omap.h>
21#include <plat/dmtimer.h>
22 21
23#include "omap_hwmod.h" 22#include "omap_hwmod.h"
24#include "mmc.h" 23#include "mmc.h"
diff --git a/arch/arm/mach-omap2/omap_hwmod_2xxx_ipblock_data.c b/arch/arm/mach-omap2/omap_hwmod_2xxx_ipblock_data.c
index a0116d08cf45..0db8f450bad9 100644
--- a/arch/arm/mach-omap2/omap_hwmod_2xxx_ipblock_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_2xxx_ipblock_data.c
@@ -58,8 +58,9 @@ static struct omap_hwmod_class_sysconfig omap2xxx_timer_sysc = {
58 .syss_offs = 0x0014, 58 .syss_offs = 0x0014,
59 .sysc_flags = (SYSC_HAS_SIDLEMODE | SYSC_HAS_CLOCKACTIVITY | 59 .sysc_flags = (SYSC_HAS_SIDLEMODE | SYSC_HAS_CLOCKACTIVITY |
60 SYSC_HAS_ENAWAKEUP | SYSC_HAS_SOFTRESET | 60 SYSC_HAS_ENAWAKEUP | SYSC_HAS_SOFTRESET |
61 SYSC_HAS_AUTOIDLE), 61 SYSC_HAS_AUTOIDLE | SYSS_HAS_RESET_STATUS),
62 .idlemodes = (SIDLE_FORCE | SIDLE_NO | SIDLE_SMART), 62 .idlemodes = (SIDLE_FORCE | SIDLE_NO | SIDLE_SMART),
63 .clockact = CLOCKACT_TEST_ICLK,
63 .sysc_fields = &omap_hwmod_sysc_type1, 64 .sysc_fields = &omap_hwmod_sysc_type1,
64}; 65};
65 66
@@ -268,6 +269,7 @@ struct omap_hwmod omap2xxx_timer1_hwmod = {
268 }, 269 },
269 .dev_attr = &capability_alwon_dev_attr, 270 .dev_attr = &capability_alwon_dev_attr,
270 .class = &omap2xxx_timer_hwmod_class, 271 .class = &omap2xxx_timer_hwmod_class,
272 .flags = HWMOD_SET_DEFAULT_CLOCKACT,
271}; 273};
272 274
273/* timer2 */ 275/* timer2 */
@@ -286,6 +288,7 @@ struct omap_hwmod omap2xxx_timer2_hwmod = {
286 }, 288 },
287 }, 289 },
288 .class = &omap2xxx_timer_hwmod_class, 290 .class = &omap2xxx_timer_hwmod_class,
291 .flags = HWMOD_SET_DEFAULT_CLOCKACT,
289}; 292};
290 293
291/* timer3 */ 294/* timer3 */
@@ -304,6 +307,7 @@ struct omap_hwmod omap2xxx_timer3_hwmod = {
304 }, 307 },
305 }, 308 },
306 .class = &omap2xxx_timer_hwmod_class, 309 .class = &omap2xxx_timer_hwmod_class,
310 .flags = HWMOD_SET_DEFAULT_CLOCKACT,
307}; 311};
308 312
309/* timer4 */ 313/* timer4 */
@@ -322,6 +326,7 @@ struct omap_hwmod omap2xxx_timer4_hwmod = {
322 }, 326 },
323 }, 327 },
324 .class = &omap2xxx_timer_hwmod_class, 328 .class = &omap2xxx_timer_hwmod_class,
329 .flags = HWMOD_SET_DEFAULT_CLOCKACT,
325}; 330};
326 331
327/* timer5 */ 332/* timer5 */
@@ -341,6 +346,7 @@ struct omap_hwmod omap2xxx_timer5_hwmod = {
341 }, 346 },
342 .dev_attr = &capability_dsp_dev_attr, 347 .dev_attr = &capability_dsp_dev_attr,
343 .class = &omap2xxx_timer_hwmod_class, 348 .class = &omap2xxx_timer_hwmod_class,
349 .flags = HWMOD_SET_DEFAULT_CLOCKACT,
344}; 350};
345 351
346/* timer6 */ 352/* timer6 */
@@ -360,6 +366,7 @@ struct omap_hwmod omap2xxx_timer6_hwmod = {
360 }, 366 },
361 .dev_attr = &capability_dsp_dev_attr, 367 .dev_attr = &capability_dsp_dev_attr,
362 .class = &omap2xxx_timer_hwmod_class, 368 .class = &omap2xxx_timer_hwmod_class,
369 .flags = HWMOD_SET_DEFAULT_CLOCKACT,
363}; 370};
364 371
365/* timer7 */ 372/* timer7 */
@@ -379,6 +386,7 @@ struct omap_hwmod omap2xxx_timer7_hwmod = {
379 }, 386 },
380 .dev_attr = &capability_dsp_dev_attr, 387 .dev_attr = &capability_dsp_dev_attr,
381 .class = &omap2xxx_timer_hwmod_class, 388 .class = &omap2xxx_timer_hwmod_class,
389 .flags = HWMOD_SET_DEFAULT_CLOCKACT,
382}; 390};
383 391
384/* timer8 */ 392/* timer8 */
@@ -398,6 +406,7 @@ struct omap_hwmod omap2xxx_timer8_hwmod = {
398 }, 406 },
399 .dev_attr = &capability_dsp_dev_attr, 407 .dev_attr = &capability_dsp_dev_attr,
400 .class = &omap2xxx_timer_hwmod_class, 408 .class = &omap2xxx_timer_hwmod_class,
409 .flags = HWMOD_SET_DEFAULT_CLOCKACT,
401}; 410};
402 411
403/* timer9 */ 412/* timer9 */
@@ -417,6 +426,7 @@ struct omap_hwmod omap2xxx_timer9_hwmod = {
417 }, 426 },
418 .dev_attr = &capability_pwm_dev_attr, 427 .dev_attr = &capability_pwm_dev_attr,
419 .class = &omap2xxx_timer_hwmod_class, 428 .class = &omap2xxx_timer_hwmod_class,
429 .flags = HWMOD_SET_DEFAULT_CLOCKACT,
420}; 430};
421 431
422/* timer10 */ 432/* timer10 */
@@ -436,6 +446,7 @@ struct omap_hwmod omap2xxx_timer10_hwmod = {
436 }, 446 },
437 .dev_attr = &capability_pwm_dev_attr, 447 .dev_attr = &capability_pwm_dev_attr,
438 .class = &omap2xxx_timer_hwmod_class, 448 .class = &omap2xxx_timer_hwmod_class,
449 .flags = HWMOD_SET_DEFAULT_CLOCKACT,
439}; 450};
440 451
441/* timer11 */ 452/* timer11 */
@@ -455,6 +466,7 @@ struct omap_hwmod omap2xxx_timer11_hwmod = {
455 }, 466 },
456 .dev_attr = &capability_pwm_dev_attr, 467 .dev_attr = &capability_pwm_dev_attr,
457 .class = &omap2xxx_timer_hwmod_class, 468 .class = &omap2xxx_timer_hwmod_class,
469 .flags = HWMOD_SET_DEFAULT_CLOCKACT,
458}; 470};
459 471
460/* timer12 */ 472/* timer12 */
@@ -474,6 +486,7 @@ struct omap_hwmod omap2xxx_timer12_hwmod = {
474 }, 486 },
475 .dev_attr = &capability_pwm_dev_attr, 487 .dev_attr = &capability_pwm_dev_attr,
476 .class = &omap2xxx_timer_hwmod_class, 488 .class = &omap2xxx_timer_hwmod_class,
489 .flags = HWMOD_SET_DEFAULT_CLOCKACT,
477}; 490};
478 491
479/* wd_timer2 */ 492/* wd_timer2 */
diff --git a/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c b/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
index abe66ced903f..addc1c24ca2e 100644
--- a/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
@@ -153,29 +153,16 @@ static struct omap_hwmod omap3xxx_debugss_hwmod = {
153}; 153};
154 154
155/* timer class */ 155/* timer class */
156static struct omap_hwmod_class_sysconfig omap3xxx_timer_1ms_sysc = {
157 .rev_offs = 0x0000,
158 .sysc_offs = 0x0010,
159 .syss_offs = 0x0014,
160 .sysc_flags = (SYSC_HAS_SIDLEMODE | SYSC_HAS_CLOCKACTIVITY |
161 SYSC_HAS_ENAWAKEUP | SYSC_HAS_SOFTRESET |
162 SYSC_HAS_EMUFREE | SYSC_HAS_AUTOIDLE),
163 .idlemodes = (SIDLE_FORCE | SIDLE_NO | SIDLE_SMART),
164 .sysc_fields = &omap_hwmod_sysc_type1,
165};
166
167static struct omap_hwmod_class omap3xxx_timer_1ms_hwmod_class = {
168 .name = "timer",
169 .sysc = &omap3xxx_timer_1ms_sysc,
170};
171
172static struct omap_hwmod_class_sysconfig omap3xxx_timer_sysc = { 156static struct omap_hwmod_class_sysconfig omap3xxx_timer_sysc = {
173 .rev_offs = 0x0000, 157 .rev_offs = 0x0000,
174 .sysc_offs = 0x0010, 158 .sysc_offs = 0x0010,
175 .syss_offs = 0x0014, 159 .syss_offs = 0x0014,
176 .sysc_flags = (SYSC_HAS_SIDLEMODE | SYSC_HAS_ENAWAKEUP | 160 .sysc_flags = (SYSC_HAS_SIDLEMODE | SYSC_HAS_CLOCKACTIVITY |
177 SYSC_HAS_SOFTRESET | SYSC_HAS_AUTOIDLE), 161 SYSC_HAS_ENAWAKEUP | SYSC_HAS_SOFTRESET |
162 SYSC_HAS_EMUFREE | SYSC_HAS_AUTOIDLE |
163 SYSS_HAS_RESET_STATUS),
178 .idlemodes = (SIDLE_FORCE | SIDLE_NO | SIDLE_SMART), 164 .idlemodes = (SIDLE_FORCE | SIDLE_NO | SIDLE_SMART),
165 .clockact = CLOCKACT_TEST_ICLK,
179 .sysc_fields = &omap_hwmod_sysc_type1, 166 .sysc_fields = &omap_hwmod_sysc_type1,
180}; 167};
181 168
@@ -224,7 +211,8 @@ static struct omap_hwmod omap3xxx_timer1_hwmod = {
224 }, 211 },
225 }, 212 },
226 .dev_attr = &capability_alwon_dev_attr, 213 .dev_attr = &capability_alwon_dev_attr,
227 .class = &omap3xxx_timer_1ms_hwmod_class, 214 .class = &omap3xxx_timer_hwmod_class,
215 .flags = HWMOD_SET_DEFAULT_CLOCKACT,
228}; 216};
229 217
230/* timer2 */ 218/* timer2 */
@@ -241,7 +229,8 @@ static struct omap_hwmod omap3xxx_timer2_hwmod = {
241 .idlest_idle_bit = OMAP3430_ST_GPT2_SHIFT, 229 .idlest_idle_bit = OMAP3430_ST_GPT2_SHIFT,
242 }, 230 },
243 }, 231 },
244 .class = &omap3xxx_timer_1ms_hwmod_class, 232 .class = &omap3xxx_timer_hwmod_class,
233 .flags = HWMOD_SET_DEFAULT_CLOCKACT,
245}; 234};
246 235
247/* timer3 */ 236/* timer3 */
@@ -259,6 +248,7 @@ static struct omap_hwmod omap3xxx_timer3_hwmod = {
259 }, 248 },
260 }, 249 },
261 .class = &omap3xxx_timer_hwmod_class, 250 .class = &omap3xxx_timer_hwmod_class,
251 .flags = HWMOD_SET_DEFAULT_CLOCKACT,
262}; 252};
263 253
264/* timer4 */ 254/* timer4 */
@@ -276,6 +266,7 @@ static struct omap_hwmod omap3xxx_timer4_hwmod = {
276 }, 266 },
277 }, 267 },
278 .class = &omap3xxx_timer_hwmod_class, 268 .class = &omap3xxx_timer_hwmod_class,
269 .flags = HWMOD_SET_DEFAULT_CLOCKACT,
279}; 270};
280 271
281/* timer5 */ 272/* timer5 */
@@ -294,6 +285,7 @@ static struct omap_hwmod omap3xxx_timer5_hwmod = {
294 }, 285 },
295 .dev_attr = &capability_dsp_dev_attr, 286 .dev_attr = &capability_dsp_dev_attr,
296 .class = &omap3xxx_timer_hwmod_class, 287 .class = &omap3xxx_timer_hwmod_class,
288 .flags = HWMOD_SET_DEFAULT_CLOCKACT,
297}; 289};
298 290
299/* timer6 */ 291/* timer6 */
@@ -312,6 +304,7 @@ static struct omap_hwmod omap3xxx_timer6_hwmod = {
312 }, 304 },
313 .dev_attr = &capability_dsp_dev_attr, 305 .dev_attr = &capability_dsp_dev_attr,
314 .class = &omap3xxx_timer_hwmod_class, 306 .class = &omap3xxx_timer_hwmod_class,
307 .flags = HWMOD_SET_DEFAULT_CLOCKACT,
315}; 308};
316 309
317/* timer7 */ 310/* timer7 */
@@ -330,6 +323,7 @@ static struct omap_hwmod omap3xxx_timer7_hwmod = {
330 }, 323 },
331 .dev_attr = &capability_dsp_dev_attr, 324 .dev_attr = &capability_dsp_dev_attr,
332 .class = &omap3xxx_timer_hwmod_class, 325 .class = &omap3xxx_timer_hwmod_class,
326 .flags = HWMOD_SET_DEFAULT_CLOCKACT,
333}; 327};
334 328
335/* timer8 */ 329/* timer8 */
@@ -348,6 +342,7 @@ static struct omap_hwmod omap3xxx_timer8_hwmod = {
348 }, 342 },
349 .dev_attr = &capability_dsp_pwm_dev_attr, 343 .dev_attr = &capability_dsp_pwm_dev_attr,
350 .class = &omap3xxx_timer_hwmod_class, 344 .class = &omap3xxx_timer_hwmod_class,
345 .flags = HWMOD_SET_DEFAULT_CLOCKACT,
351}; 346};
352 347
353/* timer9 */ 348/* timer9 */
@@ -366,6 +361,7 @@ static struct omap_hwmod omap3xxx_timer9_hwmod = {
366 }, 361 },
367 .dev_attr = &capability_pwm_dev_attr, 362 .dev_attr = &capability_pwm_dev_attr,
368 .class = &omap3xxx_timer_hwmod_class, 363 .class = &omap3xxx_timer_hwmod_class,
364 .flags = HWMOD_SET_DEFAULT_CLOCKACT,
369}; 365};
370 366
371/* timer10 */ 367/* timer10 */
@@ -383,7 +379,8 @@ static struct omap_hwmod omap3xxx_timer10_hwmod = {
383 }, 379 },
384 }, 380 },
385 .dev_attr = &capability_pwm_dev_attr, 381 .dev_attr = &capability_pwm_dev_attr,
386 .class = &omap3xxx_timer_1ms_hwmod_class, 382 .class = &omap3xxx_timer_hwmod_class,
383 .flags = HWMOD_SET_DEFAULT_CLOCKACT,
387}; 384};
388 385
389/* timer11 */ 386/* timer11 */
@@ -402,6 +399,7 @@ static struct omap_hwmod omap3xxx_timer11_hwmod = {
402 }, 399 },
403 .dev_attr = &capability_pwm_dev_attr, 400 .dev_attr = &capability_pwm_dev_attr,
404 .class = &omap3xxx_timer_hwmod_class, 401 .class = &omap3xxx_timer_hwmod_class,
402 .flags = HWMOD_SET_DEFAULT_CLOCKACT,
405}; 403};
406 404
407/* timer12 */ 405/* timer12 */
@@ -425,6 +423,7 @@ static struct omap_hwmod omap3xxx_timer12_hwmod = {
425 }, 423 },
426 .dev_attr = &capability_secure_dev_attr, 424 .dev_attr = &capability_secure_dev_attr,
427 .class = &omap3xxx_timer_hwmod_class, 425 .class = &omap3xxx_timer_hwmod_class,
426 .flags = HWMOD_SET_DEFAULT_CLOCKACT,
428}; 427};
429 428
430/* 429/*
diff --git a/arch/arm/mach-omap2/omap_hwmod_44xx_data.c b/arch/arm/mach-omap2/omap_hwmod_44xx_data.c
index b80bbf607ef8..f5b55a78a5f0 100644
--- a/arch/arm/mach-omap2/omap_hwmod_44xx_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_44xx_data.c
@@ -3103,6 +3103,7 @@ static struct omap_hwmod_class_sysconfig omap44xx_timer_1ms_sysc = {
3103 SYSC_HAS_SIDLEMODE | SYSC_HAS_SOFTRESET | 3103 SYSC_HAS_SIDLEMODE | SYSC_HAS_SOFTRESET |
3104 SYSS_HAS_RESET_STATUS), 3104 SYSS_HAS_RESET_STATUS),
3105 .idlemodes = (SIDLE_FORCE | SIDLE_NO | SIDLE_SMART), 3105 .idlemodes = (SIDLE_FORCE | SIDLE_NO | SIDLE_SMART),
3106 .clockact = CLOCKACT_TEST_ICLK,
3106 .sysc_fields = &omap_hwmod_sysc_type1, 3107 .sysc_fields = &omap_hwmod_sysc_type1,
3107}; 3108};
3108 3109
@@ -3156,6 +3157,7 @@ static struct omap_hwmod omap44xx_timer1_hwmod = {
3156 .name = "timer1", 3157 .name = "timer1",
3157 .class = &omap44xx_timer_1ms_hwmod_class, 3158 .class = &omap44xx_timer_1ms_hwmod_class,
3158 .clkdm_name = "l4_wkup_clkdm", 3159 .clkdm_name = "l4_wkup_clkdm",
3160 .flags = HWMOD_SET_DEFAULT_CLOCKACT,
3159 .mpu_irqs = omap44xx_timer1_irqs, 3161 .mpu_irqs = omap44xx_timer1_irqs,
3160 .main_clk = "timer1_fck", 3162 .main_clk = "timer1_fck",
3161 .prcm = { 3163 .prcm = {
@@ -3178,6 +3180,7 @@ static struct omap_hwmod omap44xx_timer2_hwmod = {
3178 .name = "timer2", 3180 .name = "timer2",
3179 .class = &omap44xx_timer_1ms_hwmod_class, 3181 .class = &omap44xx_timer_1ms_hwmod_class,
3180 .clkdm_name = "l4_per_clkdm", 3182 .clkdm_name = "l4_per_clkdm",
3183 .flags = HWMOD_SET_DEFAULT_CLOCKACT,
3181 .mpu_irqs = omap44xx_timer2_irqs, 3184 .mpu_irqs = omap44xx_timer2_irqs,
3182 .main_clk = "timer2_fck", 3185 .main_clk = "timer2_fck",
3183 .prcm = { 3186 .prcm = {
@@ -3352,6 +3355,7 @@ static struct omap_hwmod omap44xx_timer10_hwmod = {
3352 .name = "timer10", 3355 .name = "timer10",
3353 .class = &omap44xx_timer_1ms_hwmod_class, 3356 .class = &omap44xx_timer_1ms_hwmod_class,
3354 .clkdm_name = "l4_per_clkdm", 3357 .clkdm_name = "l4_per_clkdm",
3358 .flags = HWMOD_SET_DEFAULT_CLOCKACT,
3355 .mpu_irqs = omap44xx_timer10_irqs, 3359 .mpu_irqs = omap44xx_timer10_irqs,
3356 .main_clk = "timer10_fck", 3360 .main_clk = "timer10_fck",
3357 .prcm = { 3361 .prcm = {
diff --git a/arch/arm/mach-omap2/pm-debug.c b/arch/arm/mach-omap2/pm-debug.c
index 3cf4fdfd7ab0..e2c291f52f92 100644
--- a/arch/arm/mach-omap2/pm-debug.c
+++ b/arch/arm/mach-omap2/pm-debug.c
@@ -30,7 +30,6 @@
30#include "clock.h" 30#include "clock.h"
31#include "powerdomain.h" 31#include "powerdomain.h"
32#include "clockdomain.h" 32#include "clockdomain.h"
33#include <plat/dmtimer.h>
34#include "omap-pm.h" 33#include "omap-pm.h"
35 34
36#include "soc.h" 35#include "soc.h"
diff --git a/arch/arm/mach-omap2/timer.c b/arch/arm/mach-omap2/timer.c
index c5bc2cb4d8d3..b9cff72ceaec 100644
--- a/arch/arm/mach-omap2/timer.c
+++ b/arch/arm/mach-omap2/timer.c
@@ -37,6 +37,10 @@
37#include <linux/clockchips.h> 37#include <linux/clockchips.h>
38#include <linux/slab.h> 38#include <linux/slab.h>
39#include <linux/of.h> 39#include <linux/of.h>
40#include <linux/of_address.h>
41#include <linux/of_irq.h>
42#include <linux/platform_device.h>
43#include <linux/platform_data/dmtimer-omap.h>
40 44
41#include <asm/mach/time.h> 45#include <asm/mach/time.h>
42#include <asm/smp_twd.h> 46#include <asm/smp_twd.h>
@@ -62,18 +66,6 @@
62#define OMAP3_32K_SOURCE "omap_32k_fck" 66#define OMAP3_32K_SOURCE "omap_32k_fck"
63#define OMAP4_32K_SOURCE "sys_32k_ck" 67#define OMAP4_32K_SOURCE "sys_32k_ck"
64 68
65#ifdef CONFIG_OMAP_32K_TIMER
66#define OMAP2_CLKEV_SOURCE OMAP2_32K_SOURCE
67#define OMAP3_CLKEV_SOURCE OMAP3_32K_SOURCE
68#define OMAP4_CLKEV_SOURCE OMAP4_32K_SOURCE
69#define OMAP3_SECURE_TIMER 12
70#else
71#define OMAP2_CLKEV_SOURCE OMAP2_MPU_SOURCE
72#define OMAP3_CLKEV_SOURCE OMAP3_MPU_SOURCE
73#define OMAP4_CLKEV_SOURCE OMAP4_MPU_SOURCE
74#define OMAP3_SECURE_TIMER 1
75#endif
76
77#define REALTIME_COUNTER_BASE 0x48243200 69#define REALTIME_COUNTER_BASE 0x48243200
78#define INCREMENTER_NUMERATOR_OFFSET 0x10 70#define INCREMENTER_NUMERATOR_OFFSET 0x10
79#define INCREMENTER_DENUMERATOR_RELOAD_OFFSET 0x14 71#define INCREMENTER_DENUMERATOR_RELOAD_OFFSET 0x14
@@ -104,7 +96,7 @@ static int omap2_gp_timer_set_next_event(unsigned long cycles,
104 struct clock_event_device *evt) 96 struct clock_event_device *evt)
105{ 97{
106 __omap_dm_timer_load_start(&clkev, OMAP_TIMER_CTRL_ST, 98 __omap_dm_timer_load_start(&clkev, OMAP_TIMER_CTRL_ST,
107 0xffffffff - cycles, 1); 99 0xffffffff - cycles, OMAP_TIMER_POSTED);
108 100
109 return 0; 101 return 0;
110} 102}
@@ -114,7 +106,7 @@ static void omap2_gp_timer_set_mode(enum clock_event_mode mode,
114{ 106{
115 u32 period; 107 u32 period;
116 108
117 __omap_dm_timer_stop(&clkev, 1, clkev.rate); 109 __omap_dm_timer_stop(&clkev, OMAP_TIMER_POSTED, clkev.rate);
118 110
119 switch (mode) { 111 switch (mode) {
120 case CLOCK_EVT_MODE_PERIODIC: 112 case CLOCK_EVT_MODE_PERIODIC:
@@ -122,10 +114,10 @@ static void omap2_gp_timer_set_mode(enum clock_event_mode mode,
122 period -= 1; 114 period -= 1;
123 /* Looks like we need to first set the load value separately */ 115 /* Looks like we need to first set the load value separately */
124 __omap_dm_timer_write(&clkev, OMAP_TIMER_LOAD_REG, 116 __omap_dm_timer_write(&clkev, OMAP_TIMER_LOAD_REG,
125 0xffffffff - period, 1); 117 0xffffffff - period, OMAP_TIMER_POSTED);
126 __omap_dm_timer_load_start(&clkev, 118 __omap_dm_timer_load_start(&clkev,
127 OMAP_TIMER_CTRL_AR | OMAP_TIMER_CTRL_ST, 119 OMAP_TIMER_CTRL_AR | OMAP_TIMER_CTRL_ST,
128 0xffffffff - period, 1); 120 0xffffffff - period, OMAP_TIMER_POSTED);
129 break; 121 break;
130 case CLOCK_EVT_MODE_ONESHOT: 122 case CLOCK_EVT_MODE_ONESHOT:
131 break; 123 break;
@@ -145,36 +137,144 @@ static struct clock_event_device clockevent_gpt = {
145 .set_mode = omap2_gp_timer_set_mode, 137 .set_mode = omap2_gp_timer_set_mode,
146}; 138};
147 139
140static struct property device_disabled = {
141 .name = "status",
142 .length = sizeof("disabled"),
143 .value = "disabled",
144};
145
146static struct of_device_id omap_timer_match[] __initdata = {
147 { .compatible = "ti,omap2-timer", },
148 { }
149};
150
151/**
152 * omap_get_timer_dt - get a timer using device-tree
153 * @match - device-tree match structure for matching a device type
154 * @property - optional timer property to match
155 *
156 * Helper function to get a timer during early boot using device-tree for use
157 * as kernel system timer. Optionally, the property argument can be used to
158 * select a timer with a specific property. Once a timer is found then mark
159 * the timer node in device-tree as disabled, to prevent the kernel from
160 * registering this timer as a platform device and so no one else can use it.
161 */
162static struct device_node * __init omap_get_timer_dt(struct of_device_id *match,
163 const char *property)
164{
165 struct device_node *np;
166
167 for_each_matching_node(np, match) {
168 if (!of_device_is_available(np)) {
169 of_node_put(np);
170 continue;
171 }
172
173 if (property && !of_get_property(np, property, NULL)) {
174 of_node_put(np);
175 continue;
176 }
177
178 prom_add_property(np, &device_disabled);
179 return np;
180 }
181
182 return NULL;
183}
184
185/**
186 * omap_dmtimer_init - initialisation function when device tree is used
187 *
188 * For secure OMAP3 devices, timers with device type "timer-secure" cannot
189 * be used by the kernel as they are reserved. Therefore, to prevent the
190 * kernel registering these devices remove them dynamically from the device
191 * tree on boot.
192 */
193void __init omap_dmtimer_init(void)
194{
195 struct device_node *np;
196
197 if (!cpu_is_omap34xx())
198 return;
199
200 /* If we are a secure device, remove any secure timer nodes */
201 if ((omap_type() != OMAP2_DEVICE_TYPE_GP)) {
202 np = omap_get_timer_dt(omap_timer_match, "ti,timer-secure");
203 if (np)
204 of_node_put(np);
205 }
206}
207
208/**
209 * omap_dm_timer_get_errata - get errata flags for a timer
210 *
211 * Get the timer errata flags that are specific to the OMAP device being used.
212 */
213u32 __init omap_dm_timer_get_errata(void)
214{
215 if (cpu_is_omap24xx())
216 return 0;
217
218 return OMAP_TIMER_ERRATA_I103_I767;
219}
220
148static int __init omap_dm_timer_init_one(struct omap_dm_timer *timer, 221static int __init omap_dm_timer_init_one(struct omap_dm_timer *timer,
149 int gptimer_id, 222 int gptimer_id,
150 const char *fck_source) 223 const char *fck_source,
224 const char *property,
225 int posted)
151{ 226{
152 char name[10]; /* 10 = sizeof("gptXX_Xck0") */ 227 char name[10]; /* 10 = sizeof("gptXX_Xck0") */
228 const char *oh_name;
229 struct device_node *np;
153 struct omap_hwmod *oh; 230 struct omap_hwmod *oh;
154 struct resource irq_rsrc, mem_rsrc; 231 struct resource irq, mem;
155 size_t size; 232 int r = 0;
156 int res = 0; 233
157 int r; 234 if (of_have_populated_dt()) {
158 235 np = omap_get_timer_dt(omap_timer_match, NULL);
159 sprintf(name, "timer%d", gptimer_id); 236 if (!np)
160 omap_hwmod_setup_one(name); 237 return -ENODEV;
161 oh = omap_hwmod_lookup(name); 238
239 of_property_read_string_index(np, "ti,hwmods", 0, &oh_name);
240 if (!oh_name)
241 return -ENODEV;
242
243 timer->irq = irq_of_parse_and_map(np, 0);
244 if (!timer->irq)
245 return -ENXIO;
246
247 timer->io_base = of_iomap(np, 0);
248
249 of_node_put(np);
250 } else {
251 if (omap_dm_timer_reserve_systimer(gptimer_id))
252 return -ENODEV;
253
254 sprintf(name, "timer%d", gptimer_id);
255 oh_name = name;
256 }
257
258 oh = omap_hwmod_lookup(oh_name);
162 if (!oh) 259 if (!oh)
163 return -ENODEV; 260 return -ENODEV;
164 261
165 r = omap_hwmod_get_resource_byname(oh, IORESOURCE_IRQ, NULL, &irq_rsrc); 262 if (!of_have_populated_dt()) {
166 if (r) 263 r = omap_hwmod_get_resource_byname(oh, IORESOURCE_IRQ, NULL,
167 return -ENXIO; 264 &irq);
168 timer->irq = irq_rsrc.start; 265 if (r)
266 return -ENXIO;
267 timer->irq = irq.start;
169 268
170 r = omap_hwmod_get_resource_byname(oh, IORESOURCE_MEM, NULL, &mem_rsrc); 269 r = omap_hwmod_get_resource_byname(oh, IORESOURCE_MEM, NULL,
171 if (r) 270 &mem);
172 return -ENXIO; 271 if (r)
173 timer->phys_base = mem_rsrc.start; 272 return -ENXIO;
174 size = mem_rsrc.end - mem_rsrc.start; 273
274 /* Static mapping, never released */
275 timer->io_base = ioremap(mem.start, mem.end - mem.start);
276 }
175 277
176 /* Static mapping, never released */
177 timer->io_base = ioremap(timer->phys_base, size);
178 if (!timer->io_base) 278 if (!timer->io_base)
179 return -ENXIO; 279 return -ENXIO;
180 280
@@ -183,42 +283,56 @@ static int __init omap_dm_timer_init_one(struct omap_dm_timer *timer,
183 if (IS_ERR(timer->fclk)) 283 if (IS_ERR(timer->fclk))
184 return -ENODEV; 284 return -ENODEV;
185 285
186 omap_hwmod_enable(oh); 286 /* FIXME: Need to remove hard-coded test on timer ID */
187
188 if (omap_dm_timer_reserve_systimer(gptimer_id))
189 return -ENODEV;
190
191 if (gptimer_id != 12) { 287 if (gptimer_id != 12) {
192 struct clk *src; 288 struct clk *src;
193 289
194 src = clk_get(NULL, fck_source); 290 src = clk_get(NULL, fck_source);
195 if (IS_ERR(src)) { 291 if (IS_ERR(src)) {
196 res = -EINVAL; 292 r = -EINVAL;
197 } else { 293 } else {
198 res = __omap_dm_timer_set_source(timer->fclk, src); 294 r = clk_set_parent(timer->fclk, src);
199 if (IS_ERR_VALUE(res)) 295 if (IS_ERR_VALUE(r))
200 pr_warning("%s: timer%i cannot set source\n", 296 pr_warn("%s: %s cannot set source\n",
201 __func__, gptimer_id); 297 __func__, oh->name);
202 clk_put(src); 298 clk_put(src);
203 } 299 }
204 } 300 }
301
302 omap_hwmod_setup_one(oh_name);
303 omap_hwmod_enable(oh);
205 __omap_dm_timer_init_regs(timer); 304 __omap_dm_timer_init_regs(timer);
206 __omap_dm_timer_reset(timer, 1, 1);
207 timer->posted = 1;
208 305
209 timer->rate = clk_get_rate(timer->fclk); 306 if (posted)
307 __omap_dm_timer_enable_posted(timer);
308
309 /* Check that the intended posted configuration matches the actual */
310 if (posted != timer->posted)
311 return -EINVAL;
210 312
313 timer->rate = clk_get_rate(timer->fclk);
211 timer->reserved = 1; 314 timer->reserved = 1;
212 315
213 return res; 316 return r;
214} 317}
215 318
216static void __init omap2_gp_clockevent_init(int gptimer_id, 319static void __init omap2_gp_clockevent_init(int gptimer_id,
217 const char *fck_source) 320 const char *fck_source,
321 const char *property)
218{ 322{
219 int res; 323 int res;
220 324
221 res = omap_dm_timer_init_one(&clkev, gptimer_id, fck_source); 325 clkev.errata = omap_dm_timer_get_errata();
326
327 /*
328 * For clock-event timers we never read the timer counter and
329 * so we are not impacted by errata i103 and i767. Therefore,
330 * we can safely ignore this errata for clock-event timers.
331 */
332 __omap_dm_timer_override_errata(&clkev, OMAP_TIMER_ERRATA_I103_I767);
333
334 res = omap_dm_timer_init_one(&clkev, gptimer_id, fck_source, property,
335 OMAP_TIMER_POSTED);
222 BUG_ON(res); 336 BUG_ON(res);
223 337
224 omap2_gp_timer_irq.dev_id = &clkev; 338 omap2_gp_timer_irq.dev_id = &clkev;
@@ -251,7 +365,8 @@ static bool use_gptimer_clksrc;
251 */ 365 */
252static cycle_t clocksource_read_cycles(struct clocksource *cs) 366static cycle_t clocksource_read_cycles(struct clocksource *cs)
253{ 367{
254 return (cycle_t)__omap_dm_timer_read_counter(&clksrc, 1); 368 return (cycle_t)__omap_dm_timer_read_counter(&clksrc,
369 OMAP_TIMER_NONPOSTED);
255} 370}
256 371
257static struct clocksource clocksource_gpt = { 372static struct clocksource clocksource_gpt = {
@@ -265,21 +380,41 @@ static struct clocksource clocksource_gpt = {
265static u32 notrace dmtimer_read_sched_clock(void) 380static u32 notrace dmtimer_read_sched_clock(void)
266{ 381{
267 if (clksrc.reserved) 382 if (clksrc.reserved)
268 return __omap_dm_timer_read_counter(&clksrc, 1); 383 return __omap_dm_timer_read_counter(&clksrc,
384 OMAP_TIMER_NONPOSTED);
269 385
270 return 0; 386 return 0;
271} 387}
272 388
273#ifdef CONFIG_OMAP_32K_TIMER 389static struct of_device_id omap_counter_match[] __initdata = {
390 { .compatible = "ti,omap-counter32k", },
391 { }
392};
393
274/* Setup free-running counter for clocksource */ 394/* Setup free-running counter for clocksource */
275static int __init omap2_sync32k_clocksource_init(void) 395static int __init omap2_sync32k_clocksource_init(void)
276{ 396{
277 int ret; 397 int ret;
398 struct device_node *np = NULL;
278 struct omap_hwmod *oh; 399 struct omap_hwmod *oh;
279 void __iomem *vbase; 400 void __iomem *vbase;
280 const char *oh_name = "counter_32k"; 401 const char *oh_name = "counter_32k";
281 402
282 /* 403 /*
404 * If device-tree is present, then search the DT blob
405 * to see if the 32kHz counter is supported.
406 */
407 if (of_have_populated_dt()) {
408 np = omap_get_timer_dt(omap_counter_match, NULL);
409 if (!np)
410 return -ENODEV;
411
412 of_property_read_string_index(np, "ti,hwmods", 0, &oh_name);
413 if (!oh_name)
414 return -ENODEV;
415 }
416
417 /*
283 * First check hwmod data is available for sync32k counter 418 * First check hwmod data is available for sync32k counter
284 */ 419 */
285 oh = omap_hwmod_lookup(oh_name); 420 oh = omap_hwmod_lookup(oh_name);
@@ -288,7 +423,13 @@ static int __init omap2_sync32k_clocksource_init(void)
288 423
289 omap_hwmod_setup_one(oh_name); 424 omap_hwmod_setup_one(oh_name);
290 425
291 vbase = omap_hwmod_get_mpu_rt_va(oh); 426 if (np) {
427 vbase = of_iomap(np, 0);
428 of_node_put(np);
429 } else {
430 vbase = omap_hwmod_get_mpu_rt_va(oh);
431 }
432
292 if (!vbase) { 433 if (!vbase) {
293 pr_warn("%s: failed to get counter_32k resource\n", __func__); 434 pr_warn("%s: failed to get counter_32k resource\n", __func__);
294 return -ENXIO; 435 return -ENXIO;
@@ -310,23 +451,21 @@ static int __init omap2_sync32k_clocksource_init(void)
310 451
311 return ret; 452 return ret;
312} 453}
313#else
314static inline int omap2_sync32k_clocksource_init(void)
315{
316 return -ENODEV;
317}
318#endif
319 454
320static void __init omap2_gptimer_clocksource_init(int gptimer_id, 455static void __init omap2_gptimer_clocksource_init(int gptimer_id,
321 const char *fck_source) 456 const char *fck_source)
322{ 457{
323 int res; 458 int res;
324 459
325 res = omap_dm_timer_init_one(&clksrc, gptimer_id, fck_source); 460 clksrc.errata = omap_dm_timer_get_errata();
461
462 res = omap_dm_timer_init_one(&clksrc, gptimer_id, fck_source, NULL,
463 OMAP_TIMER_NONPOSTED);
326 BUG_ON(res); 464 BUG_ON(res);
327 465
328 __omap_dm_timer_load_start(&clksrc, 466 __omap_dm_timer_load_start(&clksrc,
329 OMAP_TIMER_CTRL_ST | OMAP_TIMER_CTRL_AR, 0, 1); 467 OMAP_TIMER_CTRL_ST | OMAP_TIMER_CTRL_AR, 0,
468 OMAP_TIMER_NONPOSTED);
330 setup_sched_clock(dmtimer_read_sched_clock, 32, clksrc.rate); 469 setup_sched_clock(dmtimer_read_sched_clock, 32, clksrc.rate);
331 470
332 if (clocksource_register_hz(&clocksource_gpt, clksrc.rate)) 471 if (clocksource_register_hz(&clocksource_gpt, clksrc.rate))
@@ -337,25 +476,6 @@ static void __init omap2_gptimer_clocksource_init(int gptimer_id,
337 gptimer_id, clksrc.rate); 476 gptimer_id, clksrc.rate);
338} 477}
339 478
340static void __init omap2_clocksource_init(int gptimer_id,
341 const char *fck_source)
342{
343 /*
344 * First give preference to kernel parameter configuration
345 * by user (clocksource="gp_timer").
346 *
347 * In case of missing kernel parameter for clocksource,
348 * first check for availability for 32k-sync timer, in case
349 * of failure in finding 32k_counter module or registering
350 * it as clocksource, execution will fallback to gp-timer.
351 */
352 if (use_gptimer_clksrc == true)
353 omap2_gptimer_clocksource_init(gptimer_id, fck_source);
354 else if (omap2_sync32k_clocksource_init())
355 /* Fall back to gp-timer code */
356 omap2_gptimer_clocksource_init(gptimer_id, fck_source);
357}
358
359#ifdef CONFIG_SOC_HAS_REALTIME_COUNTER 479#ifdef CONFIG_SOC_HAS_REALTIME_COUNTER
360/* 480/*
361 * The realtime counter also called master counter, is a free-running 481 * The realtime counter also called master counter, is a free-running
@@ -434,48 +554,65 @@ static inline void __init realtime_counter_init(void)
434{} 554{}
435#endif 555#endif
436 556
437#define OMAP_SYS_TIMER_INIT(name, clkev_nr, clkev_src, \ 557#define OMAP_SYS_GP_TIMER_INIT(name, clkev_nr, clkev_src, clkev_prop, \
558 clksrc_nr, clksrc_src) \
559static void __init omap##name##_gptimer_timer_init(void) \
560{ \
561 omap_dmtimer_init(); \
562 omap2_gp_clockevent_init((clkev_nr), clkev_src, clkev_prop); \
563 omap2_gptimer_clocksource_init((clksrc_nr), clksrc_src); \
564}
565
566#define OMAP_SYS_32K_TIMER_INIT(name, clkev_nr, clkev_src, clkev_prop, \
438 clksrc_nr, clksrc_src) \ 567 clksrc_nr, clksrc_src) \
439static void __init omap##name##_timer_init(void) \ 568static void __init omap##name##_sync32k_timer_init(void) \
440{ \ 569{ \
441 omap2_gp_clockevent_init((clkev_nr), clkev_src); \ 570 omap_dmtimer_init(); \
442 omap2_clocksource_init((clksrc_nr), clksrc_src); \ 571 omap2_gp_clockevent_init((clkev_nr), clkev_src, clkev_prop); \
572 /* Enable the use of clocksource="gp_timer" kernel parameter */ \
573 if (use_gptimer_clksrc) \
574 omap2_gptimer_clocksource_init((clksrc_nr), clksrc_src);\
575 else \
576 omap2_sync32k_clocksource_init(); \
443} 577}
444 578
445#define OMAP_SYS_TIMER(name) \ 579#define OMAP_SYS_TIMER(name, clksrc) \
446struct sys_timer omap##name##_timer = { \ 580struct sys_timer omap##name##_timer = { \
447 .init = omap##name##_timer_init, \ 581 .init = omap##name##_##clksrc##_timer_init, \
448}; 582};
449 583
450#ifdef CONFIG_ARCH_OMAP2 584#ifdef CONFIG_ARCH_OMAP2
451OMAP_SYS_TIMER_INIT(2, 1, OMAP2_CLKEV_SOURCE, 2, OMAP2_MPU_SOURCE) 585OMAP_SYS_32K_TIMER_INIT(2, 1, OMAP2_32K_SOURCE, "ti,timer-alwon",
452OMAP_SYS_TIMER(2) 586 2, OMAP2_MPU_SOURCE);
453#endif 587OMAP_SYS_TIMER(2, sync32k);
588#endif /* CONFIG_ARCH_OMAP2 */
454 589
455#ifdef CONFIG_ARCH_OMAP3 590#ifdef CONFIG_ARCH_OMAP3
456OMAP_SYS_TIMER_INIT(3, 1, OMAP3_CLKEV_SOURCE, 2, OMAP3_MPU_SOURCE) 591OMAP_SYS_32K_TIMER_INIT(3, 1, OMAP3_32K_SOURCE, "ti,timer-alwon",
457OMAP_SYS_TIMER(3) 592 2, OMAP3_MPU_SOURCE);
458OMAP_SYS_TIMER_INIT(3_secure, OMAP3_SECURE_TIMER, OMAP3_CLKEV_SOURCE, 593OMAP_SYS_TIMER(3, sync32k);
459 2, OMAP3_MPU_SOURCE) 594OMAP_SYS_32K_TIMER_INIT(3_secure, 12, OMAP3_32K_SOURCE, "ti,timer-secure",
460OMAP_SYS_TIMER(3_secure) 595 2, OMAP3_MPU_SOURCE);
461#endif 596OMAP_SYS_TIMER(3_secure, sync32k);
597OMAP_SYS_GP_TIMER_INIT(3_gp, 1, OMAP3_MPU_SOURCE, "ti,timer-alwon",
598 2, OMAP3_MPU_SOURCE);
599OMAP_SYS_TIMER(3_gp, gptimer);
600#endif /* CONFIG_ARCH_OMAP3 */
462 601
463#ifdef CONFIG_SOC_AM33XX 602#ifdef CONFIG_SOC_AM33XX
464OMAP_SYS_TIMER_INIT(3_am33xx, 1, OMAP4_MPU_SOURCE, 2, OMAP4_MPU_SOURCE) 603OMAP_SYS_GP_TIMER_INIT(3_am33xx, 1, OMAP4_MPU_SOURCE, "ti,timer-alwon",
465OMAP_SYS_TIMER(3_am33xx) 604 2, OMAP4_MPU_SOURCE);
466#endif 605OMAP_SYS_TIMER(3_am33xx, gptimer);
606#endif /* CONFIG_SOC_AM33XX */
467 607
468#ifdef CONFIG_ARCH_OMAP4 608#ifdef CONFIG_ARCH_OMAP4
609OMAP_SYS_32K_TIMER_INIT(4, 1, OMAP4_32K_SOURCE, "ti,timer-alwon",
610 2, OMAP4_MPU_SOURCE);
469#ifdef CONFIG_LOCAL_TIMERS 611#ifdef CONFIG_LOCAL_TIMERS
470static DEFINE_TWD_LOCAL_TIMER(twd_local_timer, 612static DEFINE_TWD_LOCAL_TIMER(twd_local_timer, OMAP44XX_LOCAL_TWD_BASE, 29);
471 OMAP44XX_LOCAL_TWD_BASE, 29); 613static void __init omap4_local_timer_init(void)
472#endif
473
474static void __init omap4_timer_init(void)
475{ 614{
476 omap2_gp_clockevent_init(1, OMAP4_CLKEV_SOURCE); 615 omap4_sync32k_timer_init();
477 omap2_clocksource_init(2, OMAP4_MPU_SOURCE);
478#ifdef CONFIG_LOCAL_TIMERS
479 /* Local timers are not supprted on OMAP4430 ES1.0 */ 616 /* Local timers are not supprted on OMAP4430 ES1.0 */
480 if (omap_rev() != OMAP4430_REV_ES1_0) { 617 if (omap_rev() != OMAP4430_REV_ES1_0) {
481 int err; 618 int err;
@@ -489,26 +626,32 @@ static void __init omap4_timer_init(void)
489 if (err) 626 if (err)
490 pr_err("twd_local_timer_register failed %d\n", err); 627 pr_err("twd_local_timer_register failed %d\n", err);
491 } 628 }
492#endif
493} 629}
494OMAP_SYS_TIMER(4) 630#else /* CONFIG_LOCAL_TIMERS */
495#endif 631static inline void omap4_local_timer_init(void)
632{
633 omap4_sync32_timer_init();
634}
635#endif /* CONFIG_LOCAL_TIMERS */
636OMAP_SYS_TIMER(4, local);
637#endif /* CONFIG_ARCH_OMAP4 */
496 638
497#ifdef CONFIG_SOC_OMAP5 639#ifdef CONFIG_SOC_OMAP5
498static void __init omap5_timer_init(void) 640OMAP_SYS_32K_TIMER_INIT(5, 1, OMAP4_32K_SOURCE, "ti,timer-alwon",
641 2, OMAP4_MPU_SOURCE);
642static void __init omap5_realtime_timer_init(void)
499{ 643{
500 int err; 644 int err;
501 645
502 omap2_gp_clockevent_init(1, OMAP4_CLKEV_SOURCE); 646 omap5_sync32k_timer_init();
503 omap2_clocksource_init(2, OMAP4_MPU_SOURCE);
504 realtime_counter_init(); 647 realtime_counter_init();
505 648
506 err = arch_timer_of_register(); 649 err = arch_timer_of_register();
507 if (err) 650 if (err)
508 pr_err("%s: arch_timer_register failed %d\n", __func__, err); 651 pr_err("%s: arch_timer_register failed %d\n", __func__, err);
509} 652}
510OMAP_SYS_TIMER(5) 653OMAP_SYS_TIMER(5, realtime);
511#endif 654#endif /* CONFIG_SOC_OMAP5 */
512 655
513/** 656/**
514 * omap_timer_init - build and register timer device with an 657 * omap_timer_init - build and register timer device with an
@@ -560,6 +703,7 @@ static int __init omap_timer_init(struct omap_hwmod *oh, void *unused)
560 if (timer_dev_attr) 703 if (timer_dev_attr)
561 pdata->timer_capability = timer_dev_attr->timer_capability; 704 pdata->timer_capability = timer_dev_attr->timer_capability;
562 705
706 pdata->timer_errata = omap_dm_timer_get_errata();
563 pdata->get_context_loss_count = omap_pm_get_dev_context_loss_count; 707 pdata->get_context_loss_count = omap_pm_get_dev_context_loss_count;
564 708
565 pdev = omap_device_build(name, id, oh, pdata, sizeof(*pdata), 709 pdev = omap_device_build(name, id, oh, pdata, sizeof(*pdata),
@@ -586,6 +730,10 @@ static int __init omap2_dm_timer_init(void)
586{ 730{
587 int ret; 731 int ret;
588 732
733 /* If dtb is there, the devices will be created dynamically */
734 if (of_have_populated_dt())
735 return -ENODEV;
736
589 ret = omap_hwmod_for_each_by_class("timer", omap_timer_init, NULL); 737 ret = omap_hwmod_for_each_by_class("timer", omap_timer_init, NULL);
590 if (unlikely(ret)) { 738 if (unlikely(ret)) {
591 pr_err("%s: device registration failed.\n", __func__); 739 pr_err("%s: device registration failed.\n", __func__);