clockevents/drivers/exynos_mct: Migrate to new 'set-state' interface
Migrate exynos_mct 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: Kukjin Kim <kgene.kim@samsung.com> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
This commit is contained in:
parent
cf4541c101
commit
79e436d3a7
@ -257,15 +257,14 @@ static void exynos4_mct_comp0_stop(void)
|
|||||||
exynos4_mct_write(0, EXYNOS4_MCT_G_INT_ENB);
|
exynos4_mct_write(0, EXYNOS4_MCT_G_INT_ENB);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void exynos4_mct_comp0_start(enum clock_event_mode mode,
|
static void exynos4_mct_comp0_start(bool periodic, unsigned long cycles)
|
||||||
unsigned long cycles)
|
|
||||||
{
|
{
|
||||||
unsigned int tcon;
|
unsigned int tcon;
|
||||||
cycle_t comp_cycle;
|
cycle_t comp_cycle;
|
||||||
|
|
||||||
tcon = readl_relaxed(reg_base + EXYNOS4_MCT_G_TCON);
|
tcon = readl_relaxed(reg_base + EXYNOS4_MCT_G_TCON);
|
||||||
|
|
||||||
if (mode == CLOCK_EVT_MODE_PERIODIC) {
|
if (periodic) {
|
||||||
tcon |= MCT_G_TCON_COMP0_AUTO_INC;
|
tcon |= MCT_G_TCON_COMP0_AUTO_INC;
|
||||||
exynos4_mct_write(cycles, EXYNOS4_MCT_G_COMP0_ADD_INCR);
|
exynos4_mct_write(cycles, EXYNOS4_MCT_G_COMP0_ADD_INCR);
|
||||||
}
|
}
|
||||||
@ -283,38 +282,38 @@ static void exynos4_mct_comp0_start(enum clock_event_mode mode,
|
|||||||
static int exynos4_comp_set_next_event(unsigned long cycles,
|
static int exynos4_comp_set_next_event(unsigned long cycles,
|
||||||
struct clock_event_device *evt)
|
struct clock_event_device *evt)
|
||||||
{
|
{
|
||||||
exynos4_mct_comp0_start(evt->mode, cycles);
|
exynos4_mct_comp0_start(false, cycles);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void exynos4_comp_set_mode(enum clock_event_mode mode,
|
static int mct_set_state_shutdown(struct clock_event_device *evt)
|
||||||
struct clock_event_device *evt)
|
{
|
||||||
|
exynos4_mct_comp0_stop();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int mct_set_state_periodic(struct clock_event_device *evt)
|
||||||
{
|
{
|
||||||
unsigned long cycles_per_jiffy;
|
unsigned long cycles_per_jiffy;
|
||||||
|
|
||||||
|
cycles_per_jiffy = (((unsigned long long)NSEC_PER_SEC / HZ * evt->mult)
|
||||||
|
>> evt->shift);
|
||||||
exynos4_mct_comp0_stop();
|
exynos4_mct_comp0_stop();
|
||||||
|
exynos4_mct_comp0_start(true, cycles_per_jiffy);
|
||||||
switch (mode) {
|
return 0;
|
||||||
case CLOCK_EVT_MODE_PERIODIC:
|
|
||||||
cycles_per_jiffy =
|
|
||||||
(((unsigned long long) NSEC_PER_SEC / HZ * evt->mult) >> evt->shift);
|
|
||||||
exynos4_mct_comp0_start(mode, cycles_per_jiffy);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case CLOCK_EVT_MODE_ONESHOT:
|
|
||||||
case CLOCK_EVT_MODE_UNUSED:
|
|
||||||
case CLOCK_EVT_MODE_SHUTDOWN:
|
|
||||||
case CLOCK_EVT_MODE_RESUME:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct clock_event_device mct_comp_device = {
|
static struct clock_event_device mct_comp_device = {
|
||||||
.name = "mct-comp",
|
.name = "mct-comp",
|
||||||
.features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT,
|
.features = CLOCK_EVT_FEAT_PERIODIC |
|
||||||
.rating = 250,
|
CLOCK_EVT_FEAT_ONESHOT,
|
||||||
.set_next_event = exynos4_comp_set_next_event,
|
.rating = 250,
|
||||||
.set_mode = exynos4_comp_set_mode,
|
.set_next_event = exynos4_comp_set_next_event,
|
||||||
|
.set_state_periodic = mct_set_state_periodic,
|
||||||
|
.set_state_shutdown = mct_set_state_shutdown,
|
||||||
|
.set_state_oneshot = mct_set_state_shutdown,
|
||||||
|
.tick_resume = mct_set_state_shutdown,
|
||||||
};
|
};
|
||||||
|
|
||||||
static irqreturn_t exynos4_mct_comp_isr(int irq, void *dev_id)
|
static irqreturn_t exynos4_mct_comp_isr(int irq, void *dev_id)
|
||||||
@ -390,39 +389,32 @@ static int exynos4_tick_set_next_event(unsigned long cycles,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void exynos4_tick_set_mode(enum clock_event_mode mode,
|
static int set_state_shutdown(struct clock_event_device *evt)
|
||||||
struct clock_event_device *evt)
|
{
|
||||||
|
exynos4_mct_tick_stop(this_cpu_ptr(&percpu_mct_tick));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int set_state_periodic(struct clock_event_device *evt)
|
||||||
{
|
{
|
||||||
struct mct_clock_event_device *mevt = this_cpu_ptr(&percpu_mct_tick);
|
struct mct_clock_event_device *mevt = this_cpu_ptr(&percpu_mct_tick);
|
||||||
unsigned long cycles_per_jiffy;
|
unsigned long cycles_per_jiffy;
|
||||||
|
|
||||||
|
cycles_per_jiffy = (((unsigned long long)NSEC_PER_SEC / HZ * evt->mult)
|
||||||
|
>> evt->shift);
|
||||||
exynos4_mct_tick_stop(mevt);
|
exynos4_mct_tick_stop(mevt);
|
||||||
|
exynos4_mct_tick_start(cycles_per_jiffy, mevt);
|
||||||
switch (mode) {
|
return 0;
|
||||||
case CLOCK_EVT_MODE_PERIODIC:
|
|
||||||
cycles_per_jiffy =
|
|
||||||
(((unsigned long long) NSEC_PER_SEC / HZ * evt->mult) >> evt->shift);
|
|
||||||
exynos4_mct_tick_start(cycles_per_jiffy, mevt);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case CLOCK_EVT_MODE_ONESHOT:
|
|
||||||
case CLOCK_EVT_MODE_UNUSED:
|
|
||||||
case CLOCK_EVT_MODE_SHUTDOWN:
|
|
||||||
case CLOCK_EVT_MODE_RESUME:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void exynos4_mct_tick_clear(struct mct_clock_event_device *mevt)
|
static void exynos4_mct_tick_clear(struct mct_clock_event_device *mevt)
|
||||||
{
|
{
|
||||||
struct clock_event_device *evt = &mevt->evt;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This is for supporting oneshot mode.
|
* This is for supporting oneshot mode.
|
||||||
* Mct would generate interrupt periodically
|
* Mct would generate interrupt periodically
|
||||||
* without explicit stopping.
|
* without explicit stopping.
|
||||||
*/
|
*/
|
||||||
if (evt->mode != CLOCK_EVT_MODE_PERIODIC)
|
if (!clockevent_state_periodic(&mevt->evt))
|
||||||
exynos4_mct_tick_stop(mevt);
|
exynos4_mct_tick_stop(mevt);
|
||||||
|
|
||||||
/* Clear the MCT tick interrupt */
|
/* Clear the MCT tick interrupt */
|
||||||
@ -453,7 +445,10 @@ static int exynos4_local_timer_setup(struct mct_clock_event_device *mevt)
|
|||||||
evt->name = mevt->name;
|
evt->name = mevt->name;
|
||||||
evt->cpumask = cpumask_of(cpu);
|
evt->cpumask = cpumask_of(cpu);
|
||||||
evt->set_next_event = exynos4_tick_set_next_event;
|
evt->set_next_event = exynos4_tick_set_next_event;
|
||||||
evt->set_mode = exynos4_tick_set_mode;
|
evt->set_state_periodic = set_state_periodic;
|
||||||
|
evt->set_state_shutdown = set_state_shutdown;
|
||||||
|
evt->set_state_oneshot = set_state_shutdown;
|
||||||
|
evt->tick_resume = set_state_shutdown;
|
||||||
evt->features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT;
|
evt->features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT;
|
||||||
evt->rating = 450;
|
evt->rating = 450;
|
||||||
|
|
||||||
@ -479,7 +474,7 @@ static void exynos4_local_timer_stop(struct mct_clock_event_device *mevt)
|
|||||||
{
|
{
|
||||||
struct clock_event_device *evt = &mevt->evt;
|
struct clock_event_device *evt = &mevt->evt;
|
||||||
|
|
||||||
evt->set_mode(CLOCK_EVT_MODE_UNUSED, evt);
|
evt->set_state_shutdown(evt);
|
||||||
if (mct_int_type == MCT_INT_SPI) {
|
if (mct_int_type == MCT_INT_SPI) {
|
||||||
if (evt->irq != -1)
|
if (evt->irq != -1)
|
||||||
disable_irq_nosync(evt->irq);
|
disable_irq_nosync(evt->irq);
|
||||||
|
Loading…
Reference in New Issue
Block a user