Skip to content

Commit 84fb64c

Browse files
shenkidlezcano
authored andcommitted
clocksource/drivers/fttmr010: Parametrise shutdown
In preparation for supporting the ast2600 which uses a different method to clear bits in the control register, use a callback for performing the shutdown sequence. Reviewed-by: Cédric Le Goater <clg@kaod.org> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Joel Stanley <joel@jms.id.au> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> Link: https://lore.kernel.org/r/20191107094218.13210-2-joel@jms.id.au
1 parent 5fb1c2a commit 84fb64c

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

drivers/clocksource/timer-fttmr010.c

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ struct fttmr010 {
9797
bool is_aspeed;
9898
u32 t1_enable_val;
9999
struct clock_event_device clkevt;
100+
int (*timer_shutdown)(struct clock_event_device *evt);
100101
#ifdef CONFIG_ARM
101102
struct delay_timer delay_timer;
102103
#endif
@@ -140,9 +141,7 @@ static int fttmr010_timer_set_next_event(unsigned long cycles,
140141
u32 cr;
141142

142143
/* Stop */
143-
cr = readl(fttmr010->base + TIMER_CR);
144-
cr &= ~fttmr010->t1_enable_val;
145-
writel(cr, fttmr010->base + TIMER_CR);
144+
fttmr010->timer_shutdown(evt);
146145

147146
if (fttmr010->is_aspeed) {
148147
/*
@@ -183,9 +182,7 @@ static int fttmr010_timer_set_oneshot(struct clock_event_device *evt)
183182
u32 cr;
184183

185184
/* Stop */
186-
cr = readl(fttmr010->base + TIMER_CR);
187-
cr &= ~fttmr010->t1_enable_val;
188-
writel(cr, fttmr010->base + TIMER_CR);
185+
fttmr010->timer_shutdown(evt);
189186

190187
/* Setup counter start from 0 or ~0 */
191188
writel(0, fttmr010->base + TIMER1_COUNT);
@@ -211,9 +208,7 @@ static int fttmr010_timer_set_periodic(struct clock_event_device *evt)
211208
u32 cr;
212209

213210
/* Stop */
214-
cr = readl(fttmr010->base + TIMER_CR);
215-
cr &= ~fttmr010->t1_enable_val;
216-
writel(cr, fttmr010->base + TIMER_CR);
211+
fttmr010->timer_shutdown(evt);
217212

218213
/* Setup timer to fire at 1/HZ intervals. */
219214
if (fttmr010->is_aspeed) {
@@ -350,6 +345,8 @@ static int __init fttmr010_common_init(struct device_node *np, bool is_aspeed)
350345
fttmr010->tick_rate);
351346
}
352347

348+
fttmr010->timer_shutdown = fttmr010_timer_shutdown;
349+
353350
/*
354351
* Setup clockevent timer (interrupt-driven) on timer 1.
355352
*/
@@ -370,10 +367,10 @@ static int __init fttmr010_common_init(struct device_node *np, bool is_aspeed)
370367
fttmr010->clkevt.features = CLOCK_EVT_FEAT_PERIODIC |
371368
CLOCK_EVT_FEAT_ONESHOT;
372369
fttmr010->clkevt.set_next_event = fttmr010_timer_set_next_event;
373-
fttmr010->clkevt.set_state_shutdown = fttmr010_timer_shutdown;
370+
fttmr010->clkevt.set_state_shutdown = fttmr010->timer_shutdown;
374371
fttmr010->clkevt.set_state_periodic = fttmr010_timer_set_periodic;
375372
fttmr010->clkevt.set_state_oneshot = fttmr010_timer_set_oneshot;
376-
fttmr010->clkevt.tick_resume = fttmr010_timer_shutdown;
373+
fttmr010->clkevt.tick_resume = fttmr010->timer_shutdown;
377374
fttmr010->clkevt.cpumask = cpumask_of(0);
378375
fttmr010->clkevt.irq = irq;
379376
clockevents_config_and_register(&fttmr010->clkevt,

0 commit comments

Comments
 (0)