Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

clockevents/drivers/integrator: Migrate to new 'set-state' interface

Migrate integrator driver to the new 'set-state' interface provided by
clockevents core, the earlier 'set-mode' interface is marked obsolete
now.

This also enables us to implement callbacks for new states of clockevent
devices, for example: ONESHOT_STOPPED.

For oneshot mode the clkevt device was first getting disabled by
clearing TIMER_CTRL_ENABLE bits in TIMER_CTRL register, followed by
clearing TIMER_CTRL_PERIODIC bit. Both these are done with a single
write operation now.

Cc: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Acked-by: Linus Walleij <linus.walleij@linaro.org>

authored by

Viresh Kumar and committed by
Daniel Lezcano
f710bdee e0d1ca33

+34 -26
+34 -26
drivers/clocksource/timer-integrator-ap.c
··· 75 75 return IRQ_HANDLED; 76 76 } 77 77 78 - static void clkevt_set_mode(enum clock_event_mode mode, struct clock_event_device *evt) 78 + static int clkevt_shutdown(struct clock_event_device *evt) 79 + { 80 + u32 ctrl = readl(clkevt_base + TIMER_CTRL) & ~TIMER_CTRL_ENABLE; 81 + 82 + /* Disable timer */ 83 + writel(ctrl, clkevt_base + TIMER_CTRL); 84 + return 0; 85 + } 86 + 87 + static int clkevt_set_oneshot(struct clock_event_device *evt) 88 + { 89 + u32 ctrl = readl(clkevt_base + TIMER_CTRL) & 90 + ~(TIMER_CTRL_ENABLE | TIMER_CTRL_PERIODIC); 91 + 92 + /* Leave the timer disabled, .set_next_event will enable it */ 93 + writel(ctrl, clkevt_base + TIMER_CTRL); 94 + return 0; 95 + } 96 + 97 + static int clkevt_set_periodic(struct clock_event_device *evt) 79 98 { 80 99 u32 ctrl = readl(clkevt_base + TIMER_CTRL) & ~TIMER_CTRL_ENABLE; 81 100 82 101 /* Disable timer */ 83 102 writel(ctrl, clkevt_base + TIMER_CTRL); 84 103 85 - switch (mode) { 86 - case CLOCK_EVT_MODE_PERIODIC: 87 - /* Enable the timer and start the periodic tick */ 88 - writel(timer_reload, clkevt_base + TIMER_LOAD); 89 - ctrl |= TIMER_CTRL_PERIODIC | TIMER_CTRL_ENABLE; 90 - writel(ctrl, clkevt_base + TIMER_CTRL); 91 - break; 92 - case CLOCK_EVT_MODE_ONESHOT: 93 - /* Leave the timer disabled, .set_next_event will enable it */ 94 - ctrl &= ~TIMER_CTRL_PERIODIC; 95 - writel(ctrl, clkevt_base + TIMER_CTRL); 96 - break; 97 - case CLOCK_EVT_MODE_UNUSED: 98 - case CLOCK_EVT_MODE_SHUTDOWN: 99 - case CLOCK_EVT_MODE_RESUME: 100 - default: 101 - /* Just leave in disabled state */ 102 - break; 103 - } 104 - 104 + /* Enable the timer and start the periodic tick */ 105 + writel(timer_reload, clkevt_base + TIMER_LOAD); 106 + ctrl |= TIMER_CTRL_PERIODIC | TIMER_CTRL_ENABLE; 107 + writel(ctrl, clkevt_base + TIMER_CTRL); 108 + return 0; 105 109 } 106 110 107 111 static int clkevt_set_next_event(unsigned long next, struct clock_event_device *evt) ··· 120 116 } 121 117 122 118 static struct clock_event_device integrator_clockevent = { 123 - .name = "timer1", 124 - .features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT, 125 - .set_mode = clkevt_set_mode, 126 - .set_next_event = clkevt_set_next_event, 127 - .rating = 300, 119 + .name = "timer1", 120 + .features = CLOCK_EVT_FEAT_PERIODIC | 121 + CLOCK_EVT_FEAT_ONESHOT, 122 + .set_state_shutdown = clkevt_shutdown, 123 + .set_state_periodic = clkevt_set_periodic, 124 + .set_state_oneshot = clkevt_set_oneshot, 125 + .tick_resume = clkevt_shutdown, 126 + .set_next_event = clkevt_set_next_event, 127 + .rating = 300, 128 128 }; 129 129 130 130 static struct irqaction integrator_timer_irq = {