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);
|
__raw_writel(0, &tmrptr->tisr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void txx9tmr_set_mode(enum clock_event_mode mode,
|
static int txx9tmr_set_state_periodic(struct clock_event_device *evt)
|
||||||
struct clock_event_device *evt)
|
|
||||||
{
|
{
|
||||||
struct txx9_clock_event_device *txx9_cd =
|
struct txx9_clock_event_device *txx9_cd =
|
||||||
container_of(evt, struct txx9_clock_event_device, cd);
|
container_of(evt, struct txx9_clock_event_device, cd);
|
||||||
struct txx9_tmr_reg __iomem *tmrptr = txx9_cd->tmrptr;
|
struct txx9_tmr_reg __iomem *tmrptr = txx9_cd->tmrptr;
|
||||||
|
|
||||||
txx9tmr_stop_and_clear(tmrptr);
|
txx9tmr_stop_and_clear(tmrptr);
|
||||||
switch (mode) {
|
|
||||||
case CLOCK_EVT_MODE_PERIODIC:
|
__raw_writel(TXx9_TMITMR_TIIE | TXx9_TMITMR_TZCE, &tmrptr->itmr);
|
||||||
__raw_writel(TXx9_TMITMR_TIIE | TXx9_TMITMR_TZCE,
|
/* start timer */
|
||||||
&tmrptr->itmr);
|
__raw_writel(((u64)(NSEC_PER_SEC / HZ) * evt->mult) >> evt->shift,
|
||||||
/* start timer */
|
&tmrptr->cpra);
|
||||||
__raw_writel(((u64)(NSEC_PER_SEC / HZ) * evt->mult) >>
|
__raw_writel(TCR_BASE | TXx9_TMTCR_TCE, &tmrptr->tcr);
|
||||||
evt->shift,
|
return 0;
|
||||||
&tmrptr->cpra);
|
}
|
||||||
__raw_writel(TCR_BASE | TXx9_TMTCR_TCE, &tmrptr->tcr);
|
|
||||||
break;
|
static int txx9tmr_set_state_oneshot(struct clock_event_device *evt)
|
||||||
case CLOCK_EVT_MODE_SHUTDOWN:
|
{
|
||||||
case CLOCK_EVT_MODE_UNUSED:
|
struct txx9_clock_event_device *txx9_cd =
|
||||||
__raw_writel(0, &tmrptr->itmr);
|
container_of(evt, struct txx9_clock_event_device, cd);
|
||||||
break;
|
struct txx9_tmr_reg __iomem *tmrptr = txx9_cd->tmrptr;
|
||||||
case CLOCK_EVT_MODE_ONESHOT:
|
|
||||||
__raw_writel(TXx9_TMITMR_TIIE, &tmrptr->itmr);
|
txx9tmr_stop_and_clear(tmrptr);
|
||||||
break;
|
__raw_writel(TXx9_TMITMR_TIIE, &tmrptr->itmr);
|
||||||
case CLOCK_EVT_MODE_RESUME:
|
return 0;
|
||||||
__raw_writel(TIMER_CCD, &tmrptr->ccdr);
|
}
|
||||||
__raw_writel(0, &tmrptr->itmr);
|
|
||||||
break;
|
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,
|
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 = {
|
static struct txx9_clock_event_device txx9_clock_event_device = {
|
||||||
.cd = {
|
.cd = {
|
||||||
.name = "TXx9",
|
.name = "TXx9",
|
||||||
.features = CLOCK_EVT_FEAT_PERIODIC |
|
.features = CLOCK_EVT_FEAT_PERIODIC |
|
||||||
CLOCK_EVT_FEAT_ONESHOT,
|
CLOCK_EVT_FEAT_ONESHOT,
|
||||||
.rating = 200,
|
.rating = 200,
|
||||||
.set_mode = txx9tmr_set_mode,
|
.set_state_shutdown = txx9tmr_set_state_shutdown,
|
||||||
.set_next_event = txx9tmr_set_next_event,
|
.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