All of lore.kernel.org
 help / color / mirror / Atom feed
From: Viresh Kumar <viresh.kumar@linaro.org>
To: Daniel Lezcano <daniel.lezcano@linaro.org>,
	linux-mips@linux-mips.org, ralf@linux-mips.org
Cc: linaro-kernel@lists.linaro.org,
	Thomas Gleixner <tglx@linutronix.de>,
	Viresh Kumar <viresh.kumar@linaro.org>,
	Kelvin Cheung <keguang.zhang@gmail.com>,
	Huacai Chen <chenhc@lemote.com>
Subject: [PATCH 11/14] MIPS/loongsoon32/time: Migrate to new 'set-state' interface
Date: Mon,  6 Jul 2015 16:42:02 +0530	[thread overview]
Message-ID: <ae6c62c9e355d50f2fe0a7c9ba1c0fe65f7c6325.1436180306.git.viresh.kumar@linaro.org> (raw)
In-Reply-To: <cover.1436180306.git.viresh.kumar@linaro.org>
In-Reply-To: <cover.1436180306.git.viresh.kumar@linaro.org>

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.

Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Kelvin Cheung <keguang.zhang@gmail.com>
Cc: Huacai Chen <chenhc@lemote.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 arch/mips/loongson32/common/time.c | 57 +++++++++++++++++++++++---------------
 1 file 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)
 	return IRQ_HANDLED;
 }
 
-static void ls1x_clockevent_set_mode(enum clock_event_mode mode,
-				     struct clock_event_device *cd)
+static int ls1x_clockevent_set_state_periodic(struct clock_event_device *cd)
 {
 	raw_spin_lock(&ls1x_timer_lock);
-	switch (mode) {
-	case CLOCK_EVT_MODE_PERIODIC:
-		ls1x_pwmtimer_set_period(ls1x_jiffies_per_tick);
-		ls1x_pwmtimer_restart();
-	case CLOCK_EVT_MODE_RESUME:
-		__raw_writel(INT_EN | CNT_EN, timer_base + PWM_CTRL);
-		break;
-	case CLOCK_EVT_MODE_ONESHOT:
-	case CLOCK_EVT_MODE_SHUTDOWN:
-		__raw_writel(__raw_readl(timer_base + PWM_CTRL) & ~CNT_EN,
-			     timer_base + PWM_CTRL);
-		break;
-	default:
-		break;
-	}
+	ls1x_pwmtimer_set_period(ls1x_jiffies_per_tick);
+	ls1x_pwmtimer_restart();
+	__raw_writel(INT_EN | CNT_EN, timer_base + PWM_CTRL);
 	raw_spin_unlock(&ls1x_timer_lock);
+
+	return 0;
+}
+
+static int ls1x_clockevent_tick_resume(struct clock_event_device *cd)
+{
+	raw_spin_lock(&ls1x_timer_lock);
+	__raw_writel(INT_EN | CNT_EN, timer_base + PWM_CTRL);
+	raw_spin_unlock(&ls1x_timer_lock);
+
+	return 0;
+}
+
+static int ls1x_clockevent_set_state_shutdown(struct clock_event_device *cd)
+{
+	raw_spin_lock(&ls1x_timer_lock);
+	__raw_writel(__raw_readl(timer_base + PWM_CTRL) & ~CNT_EN,
+		     timer_base + PWM_CTRL);
+	raw_spin_unlock(&ls1x_timer_lock);
+
+	return 0;
 }
 
 static int ls1x_clockevent_set_next(unsigned long evt,
@@ -160,12 +168,15 @@ static int ls1x_clockevent_set_next(unsigned long evt,
 }
 
 static struct clock_event_device ls1x_clockevent = {
-	.name		= "ls1x-pwmtimer",
-	.features	= CLOCK_EVT_FEAT_PERIODIC,
-	.rating		= 300,
-	.irq		= LS1X_TIMER_IRQ,
-	.set_next_event	= ls1x_clockevent_set_next,
-	.set_mode	= ls1x_clockevent_set_mode,
+	.name			= "ls1x-pwmtimer",
+	.features		= CLOCK_EVT_FEAT_PERIODIC,
+	.rating			= 300,
+	.irq			= LS1X_TIMER_IRQ,
+	.set_next_event		= ls1x_clockevent_set_next,
+	.set_state_shutdown	= ls1x_clockevent_set_state_shutdown,
+	.set_state_periodic	= ls1x_clockevent_set_state_periodic,
+	.set_state_oneshot	= ls1x_clockevent_set_state_shutdown,
+	.tick_resume		= ls1x_clockevent_tick_resume,
 };
 
 static struct irqaction ls1x_pwmtimer_irqaction = {
-- 
2.4.0

  parent reply	other threads:[~2015-07-06 11:15 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-06 11:11 [PATCH 00/14] MIPS: Migrate clockevent drivers to 'set-state' Viresh Kumar
2015-07-06 11:11 ` [PATCH 01/14] MIPS/alchemy/time: Migrate to new 'set-state' interface Viresh Kumar
2015-07-06 19:01   ` Sergei Shtylyov
2015-07-06 19:37   ` Manuel Lauss
2015-07-06 11:11 ` [PATCH 02/14] MIPS/jazz/timer: " Viresh Kumar
2015-07-06 19:03   ` Sergei Shtylyov
2015-07-06 11:11 ` [PATCH 03/14] MIPS/jz4740/time: " Viresh Kumar
2015-07-06 11:11 ` [PATCH 04/14] MIPS/cevt-bcm1480: " Viresh Kumar
2015-07-06 11:11 ` [PATCH 05/14] MIPS/cevt-ds1287: " Viresh Kumar
2015-07-06 11:11 ` [PATCH 06/14] MIPS/cevt-gt641xx: " Viresh Kumar
2015-07-06 11:11 ` [PATCH 07/14] MIPS/cevt-r4k: " Viresh Kumar
2015-07-06 18:11   ` Sergei Shtylyov
2015-07-06 18:24     ` Sergei Shtylyov
2015-07-06 20:29       ` Sergei Shtylyov
2015-07-06 11:11 ` [PATCH 08/14] MIPS/cevt-sb1250: " Viresh Kumar
2015-07-06 11:12 ` [PATCH 09/14] MIPS/cevt-txx9: " Viresh Kumar
2015-07-06 11:12 ` [PATCH 10/14] MIPS/loongson64/timer: " Viresh Kumar
2015-07-06 11:12 ` Viresh Kumar [this message]
2015-07-06 11:12 ` [PATCH 12/14] MIPS/ralink/rt3352: " Viresh Kumar
2015-07-06 11:12 ` [PATCH 13/14] MIPS/sgi-ip27/timer: " Viresh Kumar
2015-07-06 11:12 ` [PATCH 14/14] MIPS/sni/time: " Viresh Kumar
2015-07-06 20:52 ` [PATCH 00/14] MIPS: Migrate clockevent drivers to 'set-state' Sergei Shtylyov
2015-07-07  5:38   ` Viresh Kumar
2015-07-13  2:51 ` Viresh Kumar
2015-07-27  9:25   ` Ralf Baechle
2015-07-27  9:31     ` Viresh Kumar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ae6c62c9e355d50f2fe0a7c9ba1c0fe65f7c6325.1436180306.git.viresh.kumar@linaro.org \
    --to=viresh.kumar@linaro.org \
    --cc=chenhc@lemote.com \
    --cc=daniel.lezcano@linaro.org \
    --cc=keguang.zhang@gmail.com \
    --cc=linaro-kernel@lists.linaro.org \
    --cc=linux-mips@linux-mips.org \
    --cc=ralf@linux-mips.org \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.