diff options
author | Jon Hunter <jon-hunter@ti.com> | 2012-10-09 15:12:26 -0400 |
---|---|---|
committer | Jon Hunter <jon-hunter@ti.com> | 2012-11-02 14:16:31 -0400 |
commit | 9883f7c8dd21acb90697582ca331f3f8a66ac054 (patch) | |
tree | a17407cb037e0893c887bf33740c030e94d6ec76 /arch/arm/mach-omap2/timer.c | |
parent | 9725f4451a9ccd159b1d13f63e05896cd9bce07d (diff) |
ARM: OMAP2+: Add device-tree support for 32kHz counter
For OMAP devices, the 32kHz counter is the default clock-source for the kernel.
However, this is not the only possible clock-source the kernel can use for OMAP
devices.
When booting with device-tree, if the 32kHz counter is the desired clock-source
for the kernel, then parse the device-tree blob to ensure that the counter is
present and if so map memory for the counter using the device-tree of_iomap()
function so we are no longer reliant on the OMAP HWMOD framework to do this for
us.
Signed-off-by: Jon Hunter <jon-hunter@ti.com>
Diffstat (limited to 'arch/arm/mach-omap2/timer.c')
-rw-r--r-- | arch/arm/mach-omap2/timer.c | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/arch/arm/mach-omap2/timer.c b/arch/arm/mach-omap2/timer.c index 92447cd7a41a..0758bae3a57a 100644 --- a/arch/arm/mach-omap2/timer.c +++ b/arch/arm/mach-omap2/timer.c | |||
@@ -159,6 +159,11 @@ static struct of_device_id omap_timer_match[] __initdata = { | |||
159 | { } | 159 | { } |
160 | }; | 160 | }; |
161 | 161 | ||
162 | static struct of_device_id omap_counter_match[] __initdata = { | ||
163 | { .compatible = "ti,omap-counter32k", }, | ||
164 | { } | ||
165 | }; | ||
166 | |||
162 | /** | 167 | /** |
163 | * omap_get_timer_dt - get a timer using device-tree | 168 | * omap_get_timer_dt - get a timer using device-tree |
164 | * @match - device-tree match structure for matching a device type | 169 | * @match - device-tree match structure for matching a device type |
@@ -377,11 +382,26 @@ static u32 notrace dmtimer_read_sched_clock(void) | |||
377 | static int __init omap2_sync32k_clocksource_init(void) | 382 | static int __init omap2_sync32k_clocksource_init(void) |
378 | { | 383 | { |
379 | int ret; | 384 | int ret; |
385 | struct device_node *np = NULL; | ||
380 | struct omap_hwmod *oh; | 386 | struct omap_hwmod *oh; |
381 | void __iomem *vbase; | 387 | void __iomem *vbase; |
382 | const char *oh_name = "counter_32k"; | 388 | const char *oh_name = "counter_32k"; |
383 | 389 | ||
384 | /* | 390 | /* |
391 | * If device-tree is present, then search the DT blob | ||
392 | * to see if the 32kHz counter is supported. | ||
393 | */ | ||
394 | if (of_have_populated_dt()) { | ||
395 | np = omap_get_timer_dt(omap_counter_match, NULL); | ||
396 | if (!np) | ||
397 | return -ENODEV; | ||
398 | |||
399 | of_property_read_string_index(np, "ti,hwmods", 0, &oh_name); | ||
400 | if (!oh_name) | ||
401 | return -ENODEV; | ||
402 | } | ||
403 | |||
404 | /* | ||
385 | * First check hwmod data is available for sync32k counter | 405 | * First check hwmod data is available for sync32k counter |
386 | */ | 406 | */ |
387 | oh = omap_hwmod_lookup(oh_name); | 407 | oh = omap_hwmod_lookup(oh_name); |
@@ -390,7 +410,13 @@ static int __init omap2_sync32k_clocksource_init(void) | |||
390 | 410 | ||
391 | omap_hwmod_setup_one(oh_name); | 411 | omap_hwmod_setup_one(oh_name); |
392 | 412 | ||
393 | vbase = omap_hwmod_get_mpu_rt_va(oh); | 413 | if (np) { |
414 | vbase = of_iomap(np, 0); | ||
415 | of_node_put(np); | ||
416 | } else { | ||
417 | vbase = omap_hwmod_get_mpu_rt_va(oh); | ||
418 | } | ||
419 | |||
394 | if (!vbase) { | 420 | if (!vbase) { |
395 | pr_warn("%s: failed to get counter_32k resource\n", __func__); | 421 | pr_warn("%s: failed to get counter_32k resource\n", __func__); |
396 | return -ENXIO; | 422 | return -ENXIO; |