diff options
author | Viresh Kumar <viresh.kumar@linaro.org> | 2015-08-18 01:59:28 -0400 |
---|---|---|
committer | Ley Foon Tan <lftan@opensource.altera.com> | 2015-09-07 13:30:30 -0400 |
commit | 549a14c14b2f1868b81e5417a33b6d79e6da1d00 (patch) | |
tree | 7487404c82bc168b7c09d1868219802cd5085a7a | |
parent | 64291f7db5bd8150a74ad2036f1037e6a0428df2 (diff) |
nios2/time: Migrate to new 'set-state' interface
Migrate nios2 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: Ley Foon Tan <lftan@altera.com>
Cc: Tobias Klauser <tklauser@distanz.ch>
Cc: Herbert Xu <herbert@gondor.apana.org.au>
Cc: Dmitry Torokhov <dtor@chromium.org>
Cc: nios2-dev@lists.rocketboards.org
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Acked-by: Ley Foon Tan <lftan@altera.com>
-rw-r--r-- | arch/nios2/kernel/time.c | 49 |
1 files changed, 29 insertions, 20 deletions
diff --git a/arch/nios2/kernel/time.c b/arch/nios2/kernel/time.c index 9e3cc8a40ee9..bbc3f9157f9c 100644 --- a/arch/nios2/kernel/time.c +++ b/arch/nios2/kernel/time.c | |||
@@ -130,7 +130,7 @@ static void nios2_timer_stop(struct nios2_timer *timer) | |||
130 | } | 130 | } |
131 | 131 | ||
132 | static void nios2_timer_config(struct nios2_timer *timer, unsigned long period, | 132 | static void nios2_timer_config(struct nios2_timer *timer, unsigned long period, |
133 | enum clock_event_mode mode) | 133 | bool periodic) |
134 | { | 134 | { |
135 | u16 ctrl; | 135 | u16 ctrl; |
136 | 136 | ||
@@ -148,7 +148,7 @@ static void nios2_timer_config(struct nios2_timer *timer, unsigned long period, | |||
148 | timer_writew(timer, period >> 16, ALTERA_TIMER_PERIODH_REG); | 148 | timer_writew(timer, period >> 16, ALTERA_TIMER_PERIODH_REG); |
149 | 149 | ||
150 | ctrl |= ALTERA_TIMER_CONTROL_START_MSK | ALTERA_TIMER_CONTROL_ITO_MSK; | 150 | ctrl |= ALTERA_TIMER_CONTROL_START_MSK | ALTERA_TIMER_CONTROL_ITO_MSK; |
151 | if (mode == CLOCK_EVT_MODE_PERIODIC) | 151 | if (periodic) |
152 | ctrl |= ALTERA_TIMER_CONTROL_CONT_MSK; | 152 | ctrl |= ALTERA_TIMER_CONTROL_CONT_MSK; |
153 | else | 153 | else |
154 | ctrl &= ~ALTERA_TIMER_CONTROL_CONT_MSK; | 154 | ctrl &= ~ALTERA_TIMER_CONTROL_CONT_MSK; |
@@ -160,32 +160,38 @@ static int nios2_timer_set_next_event(unsigned long delta, | |||
160 | { | 160 | { |
161 | struct nios2_clockevent_dev *nios2_ced = to_nios2_clkevent(evt); | 161 | struct nios2_clockevent_dev *nios2_ced = to_nios2_clkevent(evt); |
162 | 162 | ||
163 | nios2_timer_config(&nios2_ced->timer, delta, evt->mode); | 163 | nios2_timer_config(&nios2_ced->timer, delta, false); |
164 | 164 | ||
165 | return 0; | 165 | return 0; |
166 | } | 166 | } |
167 | 167 | ||
168 | static void nios2_timer_set_mode(enum clock_event_mode mode, | 168 | static int nios2_timer_shutdown(struct clock_event_device *evt) |
169 | struct clock_event_device *evt) | 169 | { |
170 | struct nios2_clockevent_dev *nios2_ced = to_nios2_clkevent(evt); | ||
171 | struct nios2_timer *timer = &nios2_ced->timer; | ||
172 | |||
173 | nios2_timer_stop(timer); | ||
174 | return 0; | ||
175 | } | ||
176 | |||
177 | static int nios2_timer_set_periodic(struct clock_event_device *evt) | ||
170 | { | 178 | { |
171 | unsigned long period; | 179 | unsigned long period; |
172 | struct nios2_clockevent_dev *nios2_ced = to_nios2_clkevent(evt); | 180 | struct nios2_clockevent_dev *nios2_ced = to_nios2_clkevent(evt); |
173 | struct nios2_timer *timer = &nios2_ced->timer; | 181 | struct nios2_timer *timer = &nios2_ced->timer; |
174 | 182 | ||
175 | switch (mode) { | 183 | period = DIV_ROUND_UP(timer->freq, HZ); |
176 | case CLOCK_EVT_MODE_PERIODIC: | 184 | nios2_timer_config(timer, period, true); |
177 | period = DIV_ROUND_UP(timer->freq, HZ); | 185 | return 0; |
178 | nios2_timer_config(timer, period, CLOCK_EVT_MODE_PERIODIC); | 186 | } |
179 | break; | 187 | |
180 | case CLOCK_EVT_MODE_ONESHOT: | 188 | static int nios2_timer_resume(struct clock_event_device *evt) |
181 | case CLOCK_EVT_MODE_UNUSED: | 189 | { |
182 | case CLOCK_EVT_MODE_SHUTDOWN: | 190 | struct nios2_clockevent_dev *nios2_ced = to_nios2_clkevent(evt); |
183 | nios2_timer_stop(timer); | 191 | struct nios2_timer *timer = &nios2_ced->timer; |
184 | break; | 192 | |
185 | case CLOCK_EVT_MODE_RESUME: | 193 | nios2_timer_start(timer); |
186 | nios2_timer_start(timer); | 194 | return 0; |
187 | break; | ||
188 | } | ||
189 | } | 195 | } |
190 | 196 | ||
191 | irqreturn_t timer_interrupt(int irq, void *dev_id) | 197 | irqreturn_t timer_interrupt(int irq, void *dev_id) |
@@ -218,7 +224,10 @@ static struct nios2_clockevent_dev nios2_ce = { | |||
218 | .rating = 250, | 224 | .rating = 250, |
219 | .shift = 32, | 225 | .shift = 32, |
220 | .set_next_event = nios2_timer_set_next_event, | 226 | .set_next_event = nios2_timer_set_next_event, |
221 | .set_mode = nios2_timer_set_mode, | 227 | .set_state_shutdown = nios2_timer_shutdown, |
228 | .set_state_periodic = nios2_timer_set_periodic, | ||
229 | .set_state_oneshot = nios2_timer_shutdown, | ||
230 | .tick_resume = nios2_timer_resume, | ||
222 | }, | 231 | }, |
223 | }; | 232 | }; |
224 | 233 | ||