forked from luck/tmp_suning_uos_patched
MIPS: cevt-txx9: Migrate to new 'set-state' interface
Migrate cevt-txx9 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. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Cc: Deng-Cheng Zhu <dengcheng.zhu@imgtec.com> Cc: Daniel Lezcano <daniel.lezcano@linaro.org> Cc: linux-mips@linux-mips.org Cc: linaro-kernel@lists.linaro.org Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Viresh Kumar <viresh.kumar@linaro.org> Patchwork: https://patchwork.linux-mips.org/patch/10607/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
This commit is contained in:
parent
57e148cabb
commit
d199da550d
|
@ -85,36 +85,54 @@ static void txx9tmr_stop_and_clear(struct txx9_tmr_reg __iomem *tmrptr)
|
|||
__raw_writel(0, &tmrptr->tisr);
|
||||
}
|
||||
|
||||
static void txx9tmr_set_mode(enum clock_event_mode mode,
|
||||
struct clock_event_device *evt)
|
||||
static int txx9tmr_set_state_periodic(struct clock_event_device *evt)
|
||||
{
|
||||
struct txx9_clock_event_device *txx9_cd =
|
||||
container_of(evt, struct txx9_clock_event_device, cd);
|
||||
struct txx9_tmr_reg __iomem *tmrptr = txx9_cd->tmrptr;
|
||||
|
||||
txx9tmr_stop_and_clear(tmrptr);
|
||||
switch (mode) {
|
||||
case CLOCK_EVT_MODE_PERIODIC:
|
||||
__raw_writel(TXx9_TMITMR_TIIE | TXx9_TMITMR_TZCE,
|
||||
&tmrptr->itmr);
|
||||
/* start timer */
|
||||
__raw_writel(((u64)(NSEC_PER_SEC / HZ) * evt->mult) >>
|
||||
evt->shift,
|
||||
&tmrptr->cpra);
|
||||
__raw_writel(TCR_BASE | TXx9_TMTCR_TCE, &tmrptr->tcr);
|
||||
break;
|
||||
case CLOCK_EVT_MODE_SHUTDOWN:
|
||||
case CLOCK_EVT_MODE_UNUSED:
|
||||
__raw_writel(0, &tmrptr->itmr);
|
||||
break;
|
||||
case CLOCK_EVT_MODE_ONESHOT:
|
||||
__raw_writel(TXx9_TMITMR_TIIE, &tmrptr->itmr);
|
||||
break;
|
||||
case CLOCK_EVT_MODE_RESUME:
|
||||
__raw_writel(TIMER_CCD, &tmrptr->ccdr);
|
||||
__raw_writel(0, &tmrptr->itmr);
|
||||
break;
|
||||
}
|
||||
|
||||
__raw_writel(TXx9_TMITMR_TIIE | TXx9_TMITMR_TZCE, &tmrptr->itmr);
|
||||
/* start timer */
|
||||
__raw_writel(((u64)(NSEC_PER_SEC / HZ) * evt->mult) >> evt->shift,
|
||||
&tmrptr->cpra);
|
||||
__raw_writel(TCR_BASE | TXx9_TMTCR_TCE, &tmrptr->tcr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int txx9tmr_set_state_oneshot(struct clock_event_device *evt)
|
||||
{
|
||||
struct txx9_clock_event_device *txx9_cd =
|
||||
container_of(evt, struct txx9_clock_event_device, cd);
|
||||
struct txx9_tmr_reg __iomem *tmrptr = txx9_cd->tmrptr;
|
||||
|
||||
txx9tmr_stop_and_clear(tmrptr);
|
||||
__raw_writel(TXx9_TMITMR_TIIE, &tmrptr->itmr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int txx9tmr_set_state_shutdown(struct clock_event_device *evt)
|
||||
{
|
||||
struct txx9_clock_event_device *txx9_cd =
|
||||
container_of(evt, struct txx9_clock_event_device, cd);
|
||||
struct txx9_tmr_reg __iomem *tmrptr = txx9_cd->tmrptr;
|
||||
|
||||
txx9tmr_stop_and_clear(tmrptr);
|
||||
__raw_writel(0, &tmrptr->itmr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int txx9tmr_tick_resume(struct clock_event_device *evt)
|
||||
{
|
||||
struct txx9_clock_event_device *txx9_cd =
|
||||
container_of(evt, struct txx9_clock_event_device, cd);
|
||||
struct txx9_tmr_reg __iomem *tmrptr = txx9_cd->tmrptr;
|
||||
|
||||
txx9tmr_stop_and_clear(tmrptr);
|
||||
__raw_writel(TIMER_CCD, &tmrptr->ccdr);
|
||||
__raw_writel(0, &tmrptr->itmr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int txx9tmr_set_next_event(unsigned long delta,
|
||||
|
@ -133,12 +151,15 @@ static int txx9tmr_set_next_event(unsigned long delta,
|
|||
|
||||
static struct txx9_clock_event_device txx9_clock_event_device = {
|
||||
.cd = {
|
||||
.name = "TXx9",
|
||||
.features = CLOCK_EVT_FEAT_PERIODIC |
|
||||
CLOCK_EVT_FEAT_ONESHOT,
|
||||
.rating = 200,
|
||||
.set_mode = txx9tmr_set_mode,
|
||||
.set_next_event = txx9tmr_set_next_event,
|
||||
.name = "TXx9",
|
||||
.features = CLOCK_EVT_FEAT_PERIODIC |
|
||||
CLOCK_EVT_FEAT_ONESHOT,
|
||||
.rating = 200,
|
||||
.set_state_shutdown = txx9tmr_set_state_shutdown,
|
||||
.set_state_periodic = txx9tmr_set_state_periodic,
|
||||
.set_state_oneshot = txx9tmr_set_state_oneshot,
|
||||
.tick_resume = txx9tmr_tick_resume,
|
||||
.set_next_event = txx9tmr_set_next_event,
|
||||
},
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user