Skip to content

Commit eb8703e

Browse files
vireshkDaniel Lezcano
authored andcommitted
clockevents/drivers/mxs: Migrate to new 'set-state' interface
Migrate mxs 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. Also drop: - 'mxs_clockevent_mode': as we have helpers available from core for the same. same state twice and so perhaps the check wasn't required. - 'clock_event_mode_label': CLOCK_EVT_MODE_* shouldn't be used anymore by drivers and it was used just to print old-state:new-state. The debug prints are called from mxs_irq_clear() now based on the state-name passed to it. The printed name will be same for shutdown and resume states as they use the same callback pointer. Cc: Shawn Guo <shawn.guo@linaro.org> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
1 parent a2b7e10 commit eb8703e

1 file changed

Lines changed: 32 additions & 48 deletions

File tree

‎drivers/clocksource/mxs_timer.c‎

Lines changed: 32 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@
7777
#define BV_TIMROTv2_TIMCTRLn_SELECT__TICK_ALWAYS 0xf
7878

7979
static struct clock_event_device mxs_clockevent_device;
80-
static enum clock_event_mode mxs_clockevent_mode = CLOCK_EVT_MODE_UNUSED;
8180

8281
static void __iomem *mxs_timrot_base;
8382
static u32 timrot_major_version;
@@ -141,64 +140,49 @@ static struct irqaction mxs_timer_irq = {
141140
.handler = mxs_timer_interrupt,
142141
};
143142

144-
#ifdef DEBUG
145-
static const char *clock_event_mode_label[] const = {
146-
[CLOCK_EVT_MODE_PERIODIC] = "CLOCK_EVT_MODE_PERIODIC",
147-
[CLOCK_EVT_MODE_ONESHOT] = "CLOCK_EVT_MODE_ONESHOT",
148-
[CLOCK_EVT_MODE_SHUTDOWN] = "CLOCK_EVT_MODE_SHUTDOWN",
149-
[CLOCK_EVT_MODE_UNUSED] = "CLOCK_EVT_MODE_UNUSED"
150-
};
151-
#endif /* DEBUG */
152-
153-
static void mxs_set_mode(enum clock_event_mode mode,
154-
struct clock_event_device *evt)
143+
static void mxs_irq_clear(char *state)
155144
{
156145
/* Disable interrupt in timer module */
157146
timrot_irq_disable();
158147

159-
if (mode != mxs_clockevent_mode) {
160-
/* Set event time into the furthest future */
161-
if (timrot_is_v1())
162-
__raw_writel(0xffff,
163-
mxs_timrot_base + HW_TIMROT_TIMCOUNTn(1));
164-
else
165-
__raw_writel(0xffffffff,
166-
mxs_timrot_base + HW_TIMROT_FIXED_COUNTn(1));
167-
168-
/* Clear pending interrupt */
169-
timrot_irq_acknowledge();
170-
}
148+
/* Set event time into the furthest future */
149+
if (timrot_is_v1())
150+
__raw_writel(0xffff, mxs_timrot_base + HW_TIMROT_TIMCOUNTn(1));
151+
else
152+
__raw_writel(0xffffffff,
153+
mxs_timrot_base + HW_TIMROT_FIXED_COUNTn(1));
154+
155+
/* Clear pending interrupt */
156+
timrot_irq_acknowledge();
171157

172158
#ifdef DEBUG
173-
pr_info("%s: changing mode from %s to %s\n", __func__,
174-
clock_event_mode_label[mxs_clockevent_mode],
175-
clock_event_mode_label[mode]);
159+
pr_info("%s: changing mode to %s\n", __func__, state)
176160
#endif /* DEBUG */
161+
}
177162

178-
/* Remember timer mode */
179-
mxs_clockevent_mode = mode;
180-
181-
switch (mode) {
182-
case CLOCK_EVT_MODE_PERIODIC:
183-
pr_err("%s: Periodic mode is not implemented\n", __func__);
184-
break;
185-
case CLOCK_EVT_MODE_ONESHOT:
186-
timrot_irq_enable();
187-
break;
188-
case CLOCK_EVT_MODE_SHUTDOWN:
189-
case CLOCK_EVT_MODE_UNUSED:
190-
case CLOCK_EVT_MODE_RESUME:
191-
/* Left event sources disabled, no more interrupts appear */
192-
break;
193-
}
163+
static int mxs_shutdown(struct clock_event_device *evt)
164+
{
165+
mxs_irq_clear("shutdown");
166+
167+
return 0;
168+
}
169+
170+
static int mxs_set_oneshot(struct clock_event_device *evt)
171+
{
172+
if (clockevent_state_oneshot(evt))
173+
mxs_irq_clear("oneshot");
174+
timrot_irq_enable();
175+
return 0;
194176
}
195177

196178
static struct clock_event_device mxs_clockevent_device = {
197-
.name = "mxs_timrot",
198-
.features = CLOCK_EVT_FEAT_ONESHOT,
199-
.set_mode = mxs_set_mode,
200-
.set_next_event = timrotv2_set_next_event,
201-
.rating = 200,
179+
.name = "mxs_timrot",
180+
.features = CLOCK_EVT_FEAT_ONESHOT,
181+
.set_state_shutdown = mxs_shutdown,
182+
.set_state_oneshot = mxs_set_oneshot,
183+
.tick_resume = mxs_shutdown,
184+
.set_next_event = timrotv2_set_next_event,
185+
.rating = 200,
202186
};
203187

204188
static int __init mxs_clockevent_init(struct clk *timer_clk)

0 commit comments

Comments
 (0)