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

Migrate stm32 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.

Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Tested-by: Maxime Coquelin <mcoquelin.stm32@gmail.com>
Acked-by: Maxime Coquelin <mcoquelin.stm32@gmail.com>
This commit is contained in:
Viresh Kumar 2015-06-18 16:24:50 +05:30 коммит произвёл Daniel Lezcano
Родитель 53cba06444
Коммит 8e8af4cd3b
1 изменённых файлов: 17 добавлений и 13 удалений

Просмотреть файл

@ -40,24 +40,25 @@ struct stm32_clock_event_ddata {
void __iomem *base; void __iomem *base;
}; };
static void stm32_clock_event_set_mode(enum clock_event_mode mode, static int stm32_clock_event_shutdown(struct clock_event_device *evtdev)
struct clock_event_device *evtdev)
{ {
struct stm32_clock_event_ddata *data = struct stm32_clock_event_ddata *data =
container_of(evtdev, struct stm32_clock_event_ddata, evtdev); container_of(evtdev, struct stm32_clock_event_ddata, evtdev);
void *base = data->base; void *base = data->base;
switch (mode) { writel_relaxed(0, base + TIM_CR1);
case CLOCK_EVT_MODE_PERIODIC: return 0;
writel_relaxed(data->periodic_top, base + TIM_ARR); }
writel_relaxed(TIM_CR1_ARPE | TIM_CR1_CEN, base + TIM_CR1);
break;
case CLOCK_EVT_MODE_ONESHOT: static int stm32_clock_event_set_periodic(struct clock_event_device *evtdev)
default: {
writel_relaxed(0, base + TIM_CR1); struct stm32_clock_event_ddata *data =
break; container_of(evtdev, struct stm32_clock_event_ddata, evtdev);
} void *base = data->base;
writel_relaxed(data->periodic_top, base + TIM_ARR);
writel_relaxed(TIM_CR1_ARPE | TIM_CR1_CEN, base + TIM_CR1);
return 0;
} }
static int stm32_clock_event_set_next_event(unsigned long evt, static int stm32_clock_event_set_next_event(unsigned long evt,
@ -88,7 +89,10 @@ static struct stm32_clock_event_ddata clock_event_ddata = {
.evtdev = { .evtdev = {
.name = "stm32 clockevent", .name = "stm32 clockevent",
.features = CLOCK_EVT_FEAT_ONESHOT | CLOCK_EVT_FEAT_PERIODIC, .features = CLOCK_EVT_FEAT_ONESHOT | CLOCK_EVT_FEAT_PERIODIC,
.set_mode = stm32_clock_event_set_mode, .set_state_shutdown = stm32_clock_event_shutdown,
.set_state_periodic = stm32_clock_event_set_periodic,
.set_state_oneshot = stm32_clock_event_shutdown,
.tick_resume = stm32_clock_event_shutdown,
.set_next_event = stm32_clock_event_set_next_event, .set_next_event = stm32_clock_event_set_next_event,
.rating = 200, .rating = 200,
}, },