MIPS: cevt-txx9: Migrate to new 'set-state' interface
authorViresh Kumar <viresh.kumar@linaro.org>
Mon, 6 Jul 2015 11:12:00 +0000 (16:42 +0530)
committerRalf Baechle <ralf@linux-mips.org>
Thu, 3 Sep 2015 10:07:53 +0000 (12:07 +0200)
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>
arch/mips/kernel/cevt-txx9.c

index 723932441ecc7105864c31f3225fbd921cc92260..537eefdf838fec40cc0a947008c01ea0084ca0b3 100644 (file)
@@ -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,
        },
 };