[PATCHv4 2/2] clocksource: dw_apb_timer_of: Fix read_sched_clock
From: dinguyen at altera.com <hidden>
Date: 2013-09-17 22:02:41
Subsystem:
clocksource, clockevent drivers, the rest · Maintainers:
Daniel Lezcano, Thomas Gleixner, Linus Torvalds
From: Dinh Nguyen <redacted>
The read_sched_clock should return the ~value because the clock is a
countdown implementation. read_sched_clock() should be the same as
__apbt_read_clocksource().
If a separate timer for the sched_clock exist, then read_sched_clock()
will return an incorrect value. The (sched_io_base + 0x4) needs to be in
the function for both cases.
Maintain backwards compatibility for "dw-apb-timer-sp" and
"dw-apb-timer-osc".
Signed-off-by: Dinh Nguyen <redacted>
Acked-by: Jamie Iles <redacted>
Acked-by: Linus Walleij <redacted>
CC: Rob Herring <redacted>
CC: Arnd Bergmann <arnd@arndb.de>
Cc: Olof Johansson <redacted>
Cc: John Stultz <redacted>
Cc: Daniel Lezcano <redacted>
Cc: Thomas Gleixner <redacted>
Cc: Pavel Machek <redacted>
Cc: Heiko Stuebner <heiko@sntech.de>
Cc: linux-arm-kernel at lists.infradead.org
---
v3:
- Use APBTMR_N_CURRENT_VALUE define in read_sched_clock()
v2:
- Maintain backwards compatibility for "dw-apb-timer-sp" and
"dw-apb-timer-osc".
drivers/clocksource/dw_apb_timer_of.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/clocksource/dw_apb_timer_of.c b/drivers/clocksource/dw_apb_timer_of.c
index 4cbae4f..01c1238 100644
--- a/drivers/clocksource/dw_apb_timer_of.c
+++ b/drivers/clocksource/dw_apb_timer_of.c@@ -102,18 +102,17 @@ static void add_clocksource(struct device_node *source_timer) * timer is found. sched_io_base then points to the current_value * register of the clocksource timer. */ - sched_io_base = iobase + 0x04; + sched_io_base = iobase; sched_rate = rate; } static u32 read_sched_clock(void) { - return __raw_readl(sched_io_base); + return ~__raw_readl(sched_io_base + APBTMR_N_CURRENT_VALUE); } static const struct of_device_id sptimer_ids[] __initconst = { { .compatible = "picochip,pc3x2-rtc" }, - { .compatible = "snps,dw-apb-timer-sp" }, { /* Sentinel */ }, };
@@ -153,4 +152,6 @@ static void __init dw_apb_timer_init(struct device_node *timer) num_called++; } CLOCKSOURCE_OF_DECLARE(pc3x2_timer, "picochip,pc3x2-timer", dw_apb_timer_init); -CLOCKSOURCE_OF_DECLARE(apb_timer, "snps,dw-apb-timer-osc", dw_apb_timer_init); +CLOCKSOURCE_OF_DECLARE(apb_timer_osc, "snps,dw-apb-timer-osc", dw_apb_timer_init); +CLOCKSOURCE_OF_DECLARE(apb_timer_sp, "snps,dw-apb-timer-sp", dw_apb_timer_init); +CLOCKSOURCE_OF_DECLARE(apb_timer, "snps,dw-apb-timer", dw_apb_timer_init);
--
1.7.9.5