提交 8eda41b0 编写于 作者: V Viresh Kumar 提交者: Daniel Lezcano

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

Migrate i8253 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: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: NViresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: NDaniel Lezcano <daniel.lezcano@linaro.org>
上级 73766340
...@@ -34,7 +34,7 @@ static int __init init_pit_clocksource(void) ...@@ -34,7 +34,7 @@ static int __init init_pit_clocksource(void)
* - when local APIC timer is active (PIT is switched off) * - when local APIC timer is active (PIT is switched off)
*/ */
if (num_possible_cpus() > 1 || is_hpet_enabled() || if (num_possible_cpus() > 1 || is_hpet_enabled() ||
i8253_clockevent.mode != CLOCK_EVT_MODE_PERIODIC) !clockevent_state_periodic(&i8253_clockevent))
return 0; return 0;
return clocksource_i8253_init(); return clocksource_i8253_init();
......
...@@ -100,44 +100,40 @@ int __init clocksource_i8253_init(void) ...@@ -100,44 +100,40 @@ int __init clocksource_i8253_init(void)
#endif #endif
#ifdef CONFIG_CLKEVT_I8253 #ifdef CONFIG_CLKEVT_I8253
/* static int pit_shutdown(struct clock_event_device *evt)
* Initialize the PIT timer.
*
* This is also called after resume to bring the PIT into operation again.
*/
static void init_pit_timer(enum clock_event_mode mode,
struct clock_event_device *evt)
{ {
if (!clockevent_state_oneshot(evt) && !clockevent_state_periodic(evt))
return 0;
raw_spin_lock(&i8253_lock); raw_spin_lock(&i8253_lock);
switch (mode) { outb_p(0x30, PIT_MODE);
case CLOCK_EVT_MODE_PERIODIC: outb_p(0, PIT_CH0);
/* binary, mode 2, LSB/MSB, ch 0 */ outb_p(0, PIT_CH0);
outb_p(0x34, PIT_MODE);
outb_p(PIT_LATCH & 0xff , PIT_CH0); /* LSB */ raw_spin_unlock(&i8253_lock);
outb_p(PIT_LATCH >> 8 , PIT_CH0); /* MSB */ return 0;
break; }
case CLOCK_EVT_MODE_SHUTDOWN: static int pit_set_oneshot(struct clock_event_device *evt)
case CLOCK_EVT_MODE_UNUSED: {
if (evt->mode == CLOCK_EVT_MODE_PERIODIC || raw_spin_lock(&i8253_lock);
evt->mode == CLOCK_EVT_MODE_ONESHOT) { outb_p(0x38, PIT_MODE);
outb_p(0x30, PIT_MODE); raw_spin_unlock(&i8253_lock);
outb_p(0, PIT_CH0); return 0;
outb_p(0, PIT_CH0); }
}
break; static int pit_set_periodic(struct clock_event_device *evt)
{
case CLOCK_EVT_MODE_ONESHOT: raw_spin_lock(&i8253_lock);
/* One shot setup */
outb_p(0x38, PIT_MODE); /* binary, mode 2, LSB/MSB, ch 0 */
break; outb_p(0x34, PIT_MODE);
outb_p(PIT_LATCH & 0xff, PIT_CH0); /* LSB */
case CLOCK_EVT_MODE_RESUME: outb_p(PIT_LATCH >> 8, PIT_CH0); /* MSB */
/* Nothing to do here */
break;
}
raw_spin_unlock(&i8253_lock); raw_spin_unlock(&i8253_lock);
return 0;
} }
/* /*
...@@ -160,10 +156,11 @@ static int pit_next_event(unsigned long delta, struct clock_event_device *evt) ...@@ -160,10 +156,11 @@ static int pit_next_event(unsigned long delta, struct clock_event_device *evt)
* it can be solely used for the global tick. * it can be solely used for the global tick.
*/ */
struct clock_event_device i8253_clockevent = { struct clock_event_device i8253_clockevent = {
.name = "pit", .name = "pit",
.features = CLOCK_EVT_FEAT_PERIODIC, .features = CLOCK_EVT_FEAT_PERIODIC,
.set_mode = init_pit_timer, .set_state_shutdown = pit_shutdown,
.set_next_event = pit_next_event, .set_state_periodic = pit_set_periodic,
.set_next_event = pit_next_event,
}; };
/* /*
...@@ -172,8 +169,10 @@ struct clock_event_device i8253_clockevent = { ...@@ -172,8 +169,10 @@ struct clock_event_device i8253_clockevent = {
*/ */
void __init clockevent_i8253_init(bool oneshot) void __init clockevent_i8253_init(bool oneshot)
{ {
if (oneshot) if (oneshot) {
i8253_clockevent.features |= CLOCK_EVT_FEAT_ONESHOT; i8253_clockevent.features |= CLOCK_EVT_FEAT_ONESHOT;
i8253_clockevent.set_state_oneshot = pit_set_oneshot;
}
/* /*
* Start pit with the boot cpu mask. x86 might make it global * Start pit with the boot cpu mask. x86 might make it global
* when it is used as broadcast device later. * when it is used as broadcast device later.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册