aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/clocksource/sun4i_timer.c
diff options
context:
space:
mode:
authorMaxime Ripard <maxime.ripard@free-electrons.com>2013-10-14 15:07:47 -0400
committerDaniel Lezcano <daniel.lezcano@linaro.org>2013-10-22 16:36:43 -0400
commit12e1480bcb4920c1b02b3793cb48756497919a60 (patch)
tree0919507399156a310d951b08e0be95100903bf35 /drivers/clocksource/sun4i_timer.c
parent71c568c00026f082ca16980e2d9bc506e7d3b145 (diff)
clocksource: sun4i: Report the minimum tick that we can program
We need to wait for at least 2 clock cycles whenever we reprogram our clockevent timer. Report that the minimum number of ticks we can handle is 3 ticks, and remove 3 ticks to the interval programmed to reflect this. Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Diffstat (limited to 'drivers/clocksource/sun4i_timer.c')
-rw-r--r--drivers/clocksource/sun4i_timer.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/drivers/clocksource/sun4i_timer.c b/drivers/clocksource/sun4i_timer.c
index 8ead0258740a..46008f9f49ad 100644
--- a/drivers/clocksource/sun4i_timer.c
+++ b/drivers/clocksource/sun4i_timer.c
@@ -37,6 +37,8 @@
37#define TIMER_INTVAL_REG(val) (0x10 * (val) + 0x14) 37#define TIMER_INTVAL_REG(val) (0x10 * (val) + 0x14)
38#define TIMER_CNTVAL_REG(val) (0x10 * (val) + 0x18) 38#define TIMER_CNTVAL_REG(val) (0x10 * (val) + 0x18)
39 39
40#define TIMER_SYNC_TICKS 3
41
40static void __iomem *timer_base; 42static void __iomem *timer_base;
41static u32 ticks_per_jiffy; 43static u32 ticks_per_jiffy;
42 44
@@ -50,7 +52,7 @@ static void sun4i_clkevt_sync(void)
50{ 52{
51 u32 old = readl(timer_base + TIMER_CNTVAL_REG(1)); 53 u32 old = readl(timer_base + TIMER_CNTVAL_REG(1));
52 54
53 while ((old - readl(timer_base + TIMER_CNTVAL_REG(1))) < 3) 55 while ((old - readl(timer_base + TIMER_CNTVAL_REG(1))) < TIMER_SYNC_TICKS)
54 cpu_relax(); 56 cpu_relax();
55} 57}
56 58
@@ -104,7 +106,7 @@ static int sun4i_clkevt_next_event(unsigned long evt,
104 struct clock_event_device *unused) 106 struct clock_event_device *unused)
105{ 107{
106 sun4i_clkevt_time_stop(0); 108 sun4i_clkevt_time_stop(0);
107 sun4i_clkevt_time_setup(0, evt); 109 sun4i_clkevt_time_setup(0, evt - TIMER_SYNC_TICKS);
108 sun4i_clkevt_time_start(0, false); 110 sun4i_clkevt_time_start(0, false);
109 111
110 return 0; 112 return 0;
@@ -187,8 +189,8 @@ static void __init sun4i_timer_init(struct device_node *node)
187 189
188 sun4i_clockevent.cpumask = cpumask_of(0); 190 sun4i_clockevent.cpumask = cpumask_of(0);
189 191
190 clockevents_config_and_register(&sun4i_clockevent, rate, 0x1, 192 clockevents_config_and_register(&sun4i_clockevent, rate,
191 0xffffffff); 193 TIMER_SYNC_TICKS, 0xffffffff);
192} 194}
193CLOCKSOURCE_OF_DECLARE(sun4i, "allwinner,sun4i-timer", 195CLOCKSOURCE_OF_DECLARE(sun4i, "allwinner,sun4i-timer",
194 sun4i_timer_init); 196 sun4i_timer_init);