diff options
| author | Viresh Kumar <viresh.kumar@linaro.org> | 2015-06-18 06:54:44 -0400 |
|---|---|---|
| committer | Daniel Lezcano <daniel.lezcano@linaro.org> | 2015-08-10 05:40:44 -0400 |
| commit | 85250fb89be3792c8a6793a594e30307c4e39214 (patch) | |
| tree | 57dac387eaa3ef849578111bc09c83b588a15a57 /drivers/clocksource | |
| parent | 1e729d378e75063bf3fa91c62ea372fb73012b24 (diff) | |
clockevents/drivers/atmel: Migrate to new 'set-state' interface
Migrate atmel 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: Nicolas Ferre <nicolas.ferre@atmel.com>
Cc: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Cc: Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Acked-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Diffstat (limited to 'drivers/clocksource')
| -rw-r--r-- | drivers/clocksource/timer-atmel-pit.c | 41 |
1 files changed, 18 insertions, 23 deletions
diff --git a/drivers/clocksource/timer-atmel-pit.c b/drivers/clocksource/timer-atmel-pit.c index c0304ff608b0..58753223585b 100644 --- a/drivers/clocksource/timer-atmel-pit.c +++ b/drivers/clocksource/timer-atmel-pit.c | |||
| @@ -90,33 +90,27 @@ static cycle_t read_pit_clk(struct clocksource *cs) | |||
| 90 | return elapsed; | 90 | return elapsed; |
| 91 | } | 91 | } |
| 92 | 92 | ||
| 93 | static int pit_clkevt_shutdown(struct clock_event_device *dev) | ||
| 94 | { | ||
| 95 | struct pit_data *data = clkevt_to_pit_data(dev); | ||
| 96 | |||
| 97 | /* disable irq, leaving the clocksource active */ | ||
| 98 | pit_write(data->base, AT91_PIT_MR, (data->cycle - 1) | AT91_PIT_PITEN); | ||
| 99 | return 0; | ||
| 100 | } | ||
| 101 | |||
| 93 | /* | 102 | /* |
| 94 | * Clockevent device: interrupts every 1/HZ (== pit_cycles * MCK/16) | 103 | * Clockevent device: interrupts every 1/HZ (== pit_cycles * MCK/16) |
| 95 | */ | 104 | */ |
| 96 | static void | 105 | static int pit_clkevt_set_periodic(struct clock_event_device *dev) |
| 97 | pit_clkevt_mode(enum clock_event_mode mode, struct clock_event_device *dev) | ||
| 98 | { | 106 | { |
| 99 | struct pit_data *data = clkevt_to_pit_data(dev); | 107 | struct pit_data *data = clkevt_to_pit_data(dev); |
| 100 | 108 | ||
| 101 | switch (mode) { | 109 | /* update clocksource counter */ |
| 102 | case CLOCK_EVT_MODE_PERIODIC: | 110 | data->cnt += data->cycle * PIT_PICNT(pit_read(data->base, AT91_PIT_PIVR)); |
| 103 | /* update clocksource counter */ | 111 | pit_write(data->base, AT91_PIT_MR, |
| 104 | data->cnt += data->cycle * PIT_PICNT(pit_read(data->base, AT91_PIT_PIVR)); | 112 | (data->cycle - 1) | AT91_PIT_PITEN | AT91_PIT_PITIEN); |
| 105 | pit_write(data->base, AT91_PIT_MR, | 113 | return 0; |
| 106 | (data->cycle - 1) | AT91_PIT_PITEN | AT91_PIT_PITIEN); | ||
| 107 | break; | ||
| 108 | case CLOCK_EVT_MODE_ONESHOT: | ||
| 109 | BUG(); | ||
| 110 | /* FALLTHROUGH */ | ||
| 111 | case CLOCK_EVT_MODE_SHUTDOWN: | ||
| 112 | case CLOCK_EVT_MODE_UNUSED: | ||
| 113 | /* disable irq, leaving the clocksource active */ | ||
| 114 | pit_write(data->base, AT91_PIT_MR, | ||
| 115 | (data->cycle - 1) | AT91_PIT_PITEN); | ||
| 116 | break; | ||
| 117 | case CLOCK_EVT_MODE_RESUME: | ||
| 118 | break; | ||
| 119 | } | ||
| 120 | } | 114 | } |
| 121 | 115 | ||
| 122 | static void at91sam926x_pit_suspend(struct clock_event_device *cedev) | 116 | static void at91sam926x_pit_suspend(struct clock_event_device *cedev) |
| @@ -162,7 +156,7 @@ static irqreturn_t at91sam926x_pit_interrupt(int irq, void *dev_id) | |||
| 162 | WARN_ON_ONCE(!irqs_disabled()); | 156 | WARN_ON_ONCE(!irqs_disabled()); |
| 163 | 157 | ||
| 164 | /* The PIT interrupt may be disabled, and is shared */ | 158 | /* The PIT interrupt may be disabled, and is shared */ |
| 165 | if ((data->clkevt.mode == CLOCK_EVT_MODE_PERIODIC) && | 159 | if (clockevent_state_periodic(&data->clkevt) && |
| 166 | (pit_read(data->base, AT91_PIT_SR) & AT91_PIT_PITS)) { | 160 | (pit_read(data->base, AT91_PIT_SR) & AT91_PIT_PITS)) { |
| 167 | unsigned nr_ticks; | 161 | unsigned nr_ticks; |
| 168 | 162 | ||
| @@ -227,7 +221,8 @@ static void __init at91sam926x_pit_common_init(struct pit_data *data) | |||
| 227 | data->clkevt.rating = 100; | 221 | data->clkevt.rating = 100; |
| 228 | data->clkevt.cpumask = cpumask_of(0); | 222 | data->clkevt.cpumask = cpumask_of(0); |
| 229 | 223 | ||
| 230 | data->clkevt.set_mode = pit_clkevt_mode; | 224 | data->clkevt.set_state_shutdown = pit_clkevt_shutdown; |
| 225 | data->clkevt.set_state_periodic = pit_clkevt_set_periodic; | ||
| 231 | data->clkevt.resume = at91sam926x_pit_resume; | 226 | data->clkevt.resume = at91sam926x_pit_resume; |
| 232 | data->clkevt.suspend = at91sam926x_pit_suspend; | 227 | data->clkevt.suspend = at91sam926x_pit_suspend; |
| 233 | clockevents_register_device(&data->clkevt); | 228 | clockevents_register_device(&data->clkevt); |
