mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Viresh Kumar <viresh.kumar@linaro.org>
To: arm@kernel.org, olof@lixom.net
Cc: linaro-kernel@lists.linaro.org, arnd.bergmann@linaro.org,
	linux-arm-kernel@lists.infradead.org,
	Viresh Kumar <viresh.kumar@linaro.org>,
	Shiraz Hashim <shiraz.linux.kernel@gmail.com>,
	linux-kernel@vger.kernel.org (open list),
	Russell King <linux@arm.linux.org.uk>,
	spear-devel@list.st.com (open list:SPEAR PLATFORM SUPPORT),
	Viresh Kumar <viresh.linux@gmail.com>
Subject: [PATCH 15/18] ARM/SPEAr/time: Migrate to new 'set-state' interface
Date: Fri, 17 Jul 2015 10:41:09 +0530	[thread overview]
Message-ID: <7639c0b8b3d5e061253936ed5279ff674be238cb.1437101996.git.viresh.kumar@linaro.org> (raw)
In-Reply-To: <cover.1437101996.git.viresh.kumar@linaro.org>
In-Reply-To: <cover.1437101996.git.viresh.kumar@linaro.org>

Migrate SPEAr 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.

Also kill the unnecessary forward declaration of set-mode routine by
moving 'struct clock_event_device clkevt' towards the bottom of the file.

Cc: Shiraz Hashim <shiraz.linux.kernel@gmail.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 arch/arm/mach-spear/time.c | 89 ++++++++++++++++++++++++++--------------------
 1 file changed, 50 insertions(+), 39 deletions(-)

diff --git a/arch/arm/mach-spear/time.c b/arch/arm/mach-spear/time.c
index 26fda4ed4d51..94342a0966e3 100644
--- a/arch/arm/mach-spear/time.c
+++ b/arch/arm/mach-spear/time.c
@@ -66,8 +66,6 @@
 static __iomem void *gpt_base;
 static struct clk *gpt_clk;
 
-static void clockevent_set_mode(enum clock_event_mode mode,
-				struct clock_event_device *clk_event_dev);
 static int clockevent_next_event(unsigned long evt,
 				 struct clock_event_device *clk_event_dev);
 
@@ -95,54 +93,67 @@ static void __init spear_clocksource_init(void)
 		200, 16, clocksource_mmio_readw_up);
 }
 
-static struct clock_event_device clkevt = {
-	.name = "tmr0",
-	.features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT,
-	.set_mode = clockevent_set_mode,
-	.set_next_event = clockevent_next_event,
-	.shift = 0,	/* to be computed */
-};
+static inline void timer_shutdown(struct clock_event_device *evt)
+{
+	u16 val = readw(gpt_base + CR(CLKEVT));
+
+	/* stop the timer */
+	val &= ~CTRL_ENABLE;
+	writew(val, gpt_base + CR(CLKEVT));
+}
+
+static int spear_shutdown(struct clock_event_device *evt)
+{
+	timer_shutdown(evt);
+
+	return 0;
+}
+
+static int spear_set_oneshot(struct clock_event_device *evt)
+{
+	u16 val;
 
-static void clockevent_set_mode(enum clock_event_mode mode,
-				struct clock_event_device *clk_event_dev)
+	/* stop the timer */
+	timer_shutdown(evt);
+
+	val = readw(gpt_base + CR(CLKEVT));
+	val |= CTRL_ONE_SHOT;
+	writew(val, gpt_base + CR(CLKEVT));
+
+	return 0;
+}
+
+static int spear_set_periodic(struct clock_event_device *evt)
 {
 	u32 period;
 	u16 val;
 
 	/* stop the timer */
+	timer_shutdown(evt);
+
+	period = clk_get_rate(gpt_clk) / HZ;
+	period >>= CTRL_PRESCALER16;
+	writew(period, gpt_base + LOAD(CLKEVT));
+
 	val = readw(gpt_base + CR(CLKEVT));
-	val &= ~CTRL_ENABLE;
+	val &= ~CTRL_ONE_SHOT;
+	val |= CTRL_ENABLE | CTRL_INT_ENABLE;
 	writew(val, gpt_base + CR(CLKEVT));
 
-	switch (mode) {
-	case CLOCK_EVT_MODE_PERIODIC:
-		period = clk_get_rate(gpt_clk) / HZ;
-		period >>= CTRL_PRESCALER16;
-		writew(period, gpt_base + LOAD(CLKEVT));
-
-		val = readw(gpt_base + CR(CLKEVT));
-		val &= ~CTRL_ONE_SHOT;
-		val |= CTRL_ENABLE | CTRL_INT_ENABLE;
-		writew(val, gpt_base + CR(CLKEVT));
-
-		break;
-	case CLOCK_EVT_MODE_ONESHOT:
-		val = readw(gpt_base + CR(CLKEVT));
-		val |= CTRL_ONE_SHOT;
-		writew(val, gpt_base + CR(CLKEVT));
-
-		break;
-	case CLOCK_EVT_MODE_UNUSED:
-	case CLOCK_EVT_MODE_SHUTDOWN:
-	case CLOCK_EVT_MODE_RESUME:
-
-		break;
-	default:
-		pr_err("Invalid mode requested\n");
-		break;
-	}
+	return 0;
 }
 
+static struct clock_event_device clkevt = {
+	.name = "tmr0",
+	.features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT,
+	.set_state_shutdown = spear_shutdown,
+	.set_state_periodic = spear_set_periodic,
+	.set_state_oneshot = spear_set_oneshot,
+	.tick_resume = spear_shutdown,
+	.set_next_event = clockevent_next_event,
+	.shift = 0,	/* to be computed */
+};
+
 static int clockevent_next_event(unsigned long cycles,
 				 struct clock_event_device *clk_event_dev)
 {
-- 
2.4.0


  parent reply	other threads:[~2015-07-17  5:13 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <cover.1437101996.git.viresh.kumar@linaro.org>
2015-07-17  5:10 ` [PATCH 01/18] ARM/smp_twd: " Viresh Kumar
2015-07-17  5:10 ` [PATCH 02/18] ARM/cns3xxx/timer: " Viresh Kumar
2015-07-17  5:10 ` [PATCH 03/18] ARM/davinci/time: " Viresh Kumar
2015-07-17  5:10 ` [PATCH 04/18] ARM/dc21285-timer: " Viresh Kumar
2015-07-17  5:10 ` [PATCH 05/18] ARM/gemini/time: " Viresh Kumar
2015-07-17  5:11 ` [PATCH 06/18] ARM/imx/epit: " Viresh Kumar
2015-07-17  5:11 ` [PATCH 07/18] ARM/ixp4xx/timer: " Viresh Kumar
2015-07-17  5:11 ` [PATCH 08/18] ARM/ks8695/time: " Viresh Kumar
2015-07-17  5:11 ` [PATCH 09/18] ARM/lpc32xx/timer: " Viresh Kumar
2015-07-17  5:11 ` [PATCH 10/18] ARM/mmp/time: " Viresh Kumar
2015-07-17  5:11 ` [PATCH 11/18] ARM/netx/time: " Viresh Kumar
2015-07-17  5:11 ` [PATCH 12/18] ARM/omap1/time: " Viresh Kumar
2015-07-17  5:11 ` [PATCH 13/18] ARM/omap1/timer32: " Viresh Kumar
2015-07-17  5:11 ` [PATCH 14/18] ARM/omap2/timer: " Viresh Kumar
2015-07-17  5:11 ` Viresh Kumar [this message]
2015-07-17  5:11 ` [PATCH 16/18] ARM/w90x900/time: " Viresh Kumar
2015-07-24  4:53   ` Wan ZongShun
2015-07-17  5:11 ` [PATCH 17/18] ARM/iop/time: " Viresh Kumar
2015-07-17  5:11 ` [PATCH 18/18] ARM/orion/time: " 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=7639c0b8b3d5e061253936ed5279ff674be238cb.1437101996.git.viresh.kumar@linaro.org \
    --to=viresh.kumar@linaro.org \
    --cc=arm@kernel.org \
    --cc=arnd.bergmann@linaro.org \
    --cc=linaro-kernel@lists.linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=olof@lixom.net \
    --cc=shiraz.linux.kernel@gmail.com \
    --cc=spear-devel@list.st.com \
    --cc=viresh.linux@gmail.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®