aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorViresh Kumar <viresh.kumar@linaro.org>2015-07-06 07:12:02 -0400
committerRalf Baechle <ralf@linux-mips.org>2015-09-03 06:07:53 -0400
commit1fed884d5f3d615d56d3b3c07d5ef95f7b49b5f5 (patch)
tree0739d334a044698c06a26d4fdc899cb8ce9eb04a
parente3280b2a54b38406563d6422685a20172382d365 (diff)
MIPS: loongsoon32: Migrate to new 'set-state' interface
Migrate loongsoon32 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: Kelvin Cheung <keguang.zhang@gmail.com> Cc: Huacai Chen <chenhc@lemote.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> Patchwork: https://patchwork.linux-mips.org/patch/10609/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
-rw-r--r--arch/mips/loongson32/common/time.c57
1 files changed, 34 insertions, 23 deletions
diff --git a/arch/mips/loongson32/common/time.c b/arch/mips/loongson32/common/time.c
index df0f850d6a5f..0996b025eeef 100644
--- a/arch/mips/loongson32/common/time.c
+++ b/arch/mips/loongson32/common/time.c
@@ -126,26 +126,34 @@ static irqreturn_t ls1x_clockevent_isr(int irq, void *devid)
126 return IRQ_HANDLED; 126 return IRQ_HANDLED;
127} 127}
128 128
129static void ls1x_clockevent_set_mode(enum clock_event_mode mode, 129static int ls1x_clockevent_set_state_periodic(struct clock_event_device *cd)
130 struct clock_event_device *cd)
131{ 130{
132 raw_spin_lock(&ls1x_timer_lock); 131 raw_spin_lock(&ls1x_timer_lock);
133 switch (mode) { 132 ls1x_pwmtimer_set_period(ls1x_jiffies_per_tick);
134 case CLOCK_EVT_MODE_PERIODIC: 133 ls1x_pwmtimer_restart();
135 ls1x_pwmtimer_set_period(ls1x_jiffies_per_tick); 134 __raw_writel(INT_EN | CNT_EN, timer_base + PWM_CTRL);
136 ls1x_pwmtimer_restart();
137 case CLOCK_EVT_MODE_RESUME:
138 __raw_writel(INT_EN | CNT_EN, timer_base + PWM_CTRL);
139 break;
140 case CLOCK_EVT_MODE_ONESHOT:
141 case CLOCK_EVT_MODE_SHUTDOWN:
142 __raw_writel(__raw_readl(timer_base + PWM_CTRL) & ~CNT_EN,
143 timer_base + PWM_CTRL);
144 break;
145 default:
146 break;
147 }
148 raw_spin_unlock(&ls1x_timer_lock); 135 raw_spin_unlock(&ls1x_timer_lock);
136
137 return 0;
138}
139
140static int ls1x_clockevent_tick_resume(struct clock_event_device *cd)
141{
142 raw_spin_lock(&ls1x_timer_lock);
143 __raw_writel(INT_EN | CNT_EN, timer_base + PWM_CTRL);
144 raw_spin_unlock(&ls1x_timer_lock);
145
146 return 0;
147}
148
149static int ls1x_clockevent_set_state_shutdown(struct clock_event_device *cd)
150{
151 raw_spin_lock(&ls1x_timer_lock);
152 __raw_writel(__raw_readl(timer_base + PWM_CTRL) & ~CNT_EN,
153 timer_base + PWM_CTRL);
154 raw_spin_unlock(&ls1x_timer_lock);
155
156 return 0;
149} 157}
150 158
151static int ls1x_clockevent_set_next(unsigned long evt, 159static int ls1x_clockevent_set_next(unsigned long evt,
@@ -160,12 +168,15 @@ static int ls1x_clockevent_set_next(unsigned long evt,
160} 168}
161 169
162static struct clock_event_device ls1x_clockevent = { 170static struct clock_event_device ls1x_clockevent = {
163 .name = "ls1x-pwmtimer", 171 .name = "ls1x-pwmtimer",
164 .features = CLOCK_EVT_FEAT_PERIODIC, 172 .features = CLOCK_EVT_FEAT_PERIODIC,
165 .rating = 300, 173 .rating = 300,
166 .irq = LS1X_TIMER_IRQ, 174 .irq = LS1X_TIMER_IRQ,
167 .set_next_event = ls1x_clockevent_set_next, 175 .set_next_event = ls1x_clockevent_set_next,
168 .set_mode = ls1x_clockevent_set_mode, 176 .set_state_shutdown = ls1x_clockevent_set_state_shutdown,
177 .set_state_periodic = ls1x_clockevent_set_state_periodic,
178 .set_state_oneshot = ls1x_clockevent_set_state_shutdown,
179 .tick_resume = ls1x_clockevent_tick_resume,
169}; 180};
170 181
171static struct irqaction ls1x_pwmtimer_irqaction = { 182static struct irqaction ls1x_pwmtimer_irqaction = {