diff options
author | Viresh Kumar <viresh.kumar@linaro.org> | 2015-06-30 05:00:48 -0400 |
---|---|---|
committer | Daniel Lezcano <daniel.lezcano@linaro.org> | 2015-08-10 05:40:25 -0400 |
commit | 3465f60917f2dbbc227e2a2e7913ad75bb604c12 (patch) | |
tree | 40407a43feb5b8dfc227184061d2b616740ba226 | |
parent | 0fae62eafec3c033d49160344228a4fa7d6303bc (diff) |
clockevents/drivers/asm9260: Migrate to new 'set-state' interface
Migrate asm9260 driver to the new 'set-state' interface provided by
clockevents core, the earlier 'set-mode' interface is marked obsolete
now.
As a default the timer was stopped when entering in the set_mode(RESUME)
function, now this is done explicitly with the new API.
This also enables us to implement callbacks for new states of clockevent
devices, for example: ONESHOT_STOPPED.
Cc: Oleksij Rempel <linux@rempel-privat.de>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
-rw-r--r-- | drivers/clocksource/asm9260_timer.c | 64 |
1 files changed, 39 insertions, 25 deletions
diff --git a/drivers/clocksource/asm9260_timer.c b/drivers/clocksource/asm9260_timer.c index 4c2ba59897e8..217438d39eb3 100644 --- a/drivers/clocksource/asm9260_timer.c +++ b/drivers/clocksource/asm9260_timer.c | |||
@@ -120,38 +120,52 @@ static int asm9260_timer_set_next_event(unsigned long delta, | |||
120 | return 0; | 120 | return 0; |
121 | } | 121 | } |
122 | 122 | ||
123 | static void asm9260_timer_set_mode(enum clock_event_mode mode, | 123 | static inline void __asm9260_timer_shutdown(struct clock_event_device *evt) |
124 | struct clock_event_device *evt) | ||
125 | { | 124 | { |
126 | /* stop timer0 */ | 125 | /* stop timer0 */ |
127 | writel_relaxed(BM_C0_EN, priv.base + HW_TCR + CLR_REG); | 126 | writel_relaxed(BM_C0_EN, priv.base + HW_TCR + CLR_REG); |
127 | } | ||
128 | |||
129 | static int asm9260_timer_shutdown(struct clock_event_device *evt) | ||
130 | { | ||
131 | __asm9260_timer_shutdown(evt); | ||
132 | return 0; | ||
133 | } | ||
134 | |||
135 | static int asm9260_timer_set_oneshot(struct clock_event_device *evt) | ||
136 | { | ||
137 | __asm9260_timer_shutdown(evt); | ||
138 | |||
139 | /* enable reset and stop on match */ | ||
140 | writel_relaxed(BM_MCR_RES_EN(0) | BM_MCR_STOP_EN(0), | ||
141 | priv.base + HW_MCR + SET_REG); | ||
142 | return 0; | ||
143 | } | ||
144 | |||
145 | static int asm9260_timer_set_periodic(struct clock_event_device *evt) | ||
146 | { | ||
147 | __asm9260_timer_shutdown(evt); | ||
128 | 148 | ||
129 | switch (mode) { | 149 | /* disable reset and stop on match */ |
130 | case CLOCK_EVT_MODE_PERIODIC: | 150 | writel_relaxed(BM_MCR_RES_EN(0) | BM_MCR_STOP_EN(0), |
131 | /* disable reset and stop on match */ | 151 | priv.base + HW_MCR + CLR_REG); |
132 | writel_relaxed(BM_MCR_RES_EN(0) | BM_MCR_STOP_EN(0), | 152 | /* configure match count for TC0 */ |
133 | priv.base + HW_MCR + CLR_REG); | 153 | writel_relaxed(priv.ticks_per_jiffy, priv.base + HW_MR0); |
134 | /* configure match count for TC0 */ | 154 | /* enable TC0 */ |
135 | writel_relaxed(priv.ticks_per_jiffy, priv.base + HW_MR0); | 155 | writel_relaxed(BM_C0_EN, priv.base + HW_TCR + SET_REG); |
136 | /* enable TC0 */ | 156 | return 0; |
137 | writel_relaxed(BM_C0_EN, priv.base + HW_TCR + SET_REG); | ||
138 | break; | ||
139 | case CLOCK_EVT_MODE_ONESHOT: | ||
140 | /* enable reset and stop on match */ | ||
141 | writel_relaxed(BM_MCR_RES_EN(0) | BM_MCR_STOP_EN(0), | ||
142 | priv.base + HW_MCR + SET_REG); | ||
143 | break; | ||
144 | default: | ||
145 | break; | ||
146 | } | ||
147 | } | 157 | } |
148 | 158 | ||
149 | static struct clock_event_device event_dev = { | 159 | static struct clock_event_device event_dev = { |
150 | .name = DRIVER_NAME, | 160 | .name = DRIVER_NAME, |
151 | .rating = 200, | 161 | .rating = 200, |
152 | .features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT, | 162 | .features = CLOCK_EVT_FEAT_PERIODIC | |
153 | .set_next_event = asm9260_timer_set_next_event, | 163 | CLOCK_EVT_FEAT_ONESHOT, |
154 | .set_mode = asm9260_timer_set_mode, | 164 | .set_next_event = asm9260_timer_set_next_event, |
165 | .set_state_shutdown = asm9260_timer_shutdown, | ||
166 | .set_state_periodic = asm9260_timer_set_periodic, | ||
167 | .set_state_oneshot = asm9260_timer_set_oneshot, | ||
168 | .tick_resume = asm9260_timer_shutdown, | ||
155 | }; | 169 | }; |
156 | 170 | ||
157 | static irqreturn_t asm9260_timer_interrupt(int irq, void *dev_id) | 171 | static irqreturn_t asm9260_timer_interrupt(int irq, void *dev_id) |