mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Neil Armstrong <narmstrong@baylibre.com>
To: linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, daniel.lezcano@linaro.org,
	tglx@linutronix.de, rmk+kernel@arm.linux.org.uk,
	sudeep.holla@arm.com
Cc: Neil Armstrong <narmstrong@baylibre.com>
Subject: [PATCH v2 01/18] clocksource: sp804: Add support for non-32bit width counter
Date: Wed,  9 Mar 2016 11:24:03 +0100	[thread overview]
Message-ID: <1457519060-6038-2-git-send-email-narmstrong@baylibre.com> (raw)
In-Reply-To: <1457519060-6038-1-git-send-email-narmstrong@baylibre.com>

Some vendor variants can implement norrower counter width, add
an optional DT property changing the clocksource width and the
clockevent mask, but keeping 32bit as default for legacy interface.

Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
---
 drivers/clocksource/timer-sp804.c | 38 +++++++++++++++++++++++++++-----------
 include/clocksource/timer-sp804.h | 11 ++++++-----
 2 files changed, 33 insertions(+), 16 deletions(-)

diff --git a/drivers/clocksource/timer-sp804.c b/drivers/clocksource/timer-sp804.c
index 5f45b9a..8acf524 100644
--- a/drivers/clocksource/timer-sp804.c
+++ b/drivers/clocksource/timer-sp804.c
@@ -80,7 +80,8 @@ void __init sp804_timer_disable(void __iomem *base)
 void __init __sp804_clocksource_and_sched_clock_init(void __iomem *base,
 						     const char *name,
 						     struct clk *clk,
-						     int use_sched_clock)
+						     int use_sched_clock,
+						     unsigned width)
 {
 	long rate;
 
@@ -93,6 +94,9 @@ void __init __sp804_clocksource_and_sched_clock_init(void __iomem *base,
 		}
 	}
 
+	if (!width || width > 32)
+		width = 32;
+
 	rate = sp804_get_clock_rate(clk);
 
 	if (rate < 0)
@@ -106,11 +110,11 @@ void __init __sp804_clocksource_and_sched_clock_init(void __iomem *base,
 		base + TIMER_CTRL);
 
 	clocksource_mmio_init(base + TIMER_VALUE, name,
-		rate, 200, 32, clocksource_mmio_readl_down);
+		rate, 200, width, clocksource_mmio_readl_down);
 
 	if (use_sched_clock) {
 		sched_clock_base = base;
-		sched_clock_register(sp804_read, 32, rate);
+		sched_clock_register(sp804_read, width, rate);
 	}
 }
 
@@ -186,7 +190,9 @@ static struct irqaction sp804_timer_irq = {
 	.dev_id		= &sp804_clockevent,
 };
 
-void __init __sp804_clockevents_init(void __iomem *base, unsigned int irq, struct clk *clk, const char *name)
+void __init __sp804_clockevents_init(void __iomem *base, unsigned int irq,
+				     struct clk *clk, const char *name,
+				     unsigned width)
 {
 	struct clock_event_device *evt = &sp804_clockevent;
 	long rate;
@@ -199,6 +205,9 @@ void __init __sp804_clockevents_init(void __iomem *base, unsigned int irq, struc
 		return;
 	}
 
+	if (!width || width > 32)
+		width = 32;
+
 	rate = sp804_get_clock_rate(clk);
 	if (rate < 0)
 		return;
@@ -212,7 +221,7 @@ void __init __sp804_clockevents_init(void __iomem *base, unsigned int irq, struc
 	writel(0, base + TIMER_CTRL);
 
 	setup_irq(irq, &sp804_timer_irq);
-	clockevents_config_and_register(evt, rate, 0xf, 0xffffffff);
+	clockevents_config_and_register(evt, rate, 0xf, GENMASK(width-1, 0));
 }
 
 static void __init sp804_of_init(struct device_node *np)
@@ -223,6 +232,7 @@ static void __init sp804_of_init(struct device_node *np)
 	u32 irq_num = 0;
 	struct clk *clk1, *clk2;
 	const char *name = of_get_property(np, "compatible", NULL);
+	u32 width = 32;
 
 	base = of_iomap(np, 0);
 	if (WARN_ON(!base))
@@ -254,14 +264,19 @@ static void __init sp804_of_init(struct device_node *np)
 	if (irq <= 0)
 		goto err;
 
+	/* Some vendor variants can have a different counter width */
+	of_property_read_u32(np, "arm,timer-width", &width);
+
 	of_property_read_u32(np, "arm,sp804-has-irq", &irq_num);
 	if (irq_num == 2) {
-		__sp804_clockevents_init(base + TIMER_2_BASE, irq, clk2, name);
-		__sp804_clocksource_and_sched_clock_init(base, name, clk1, 1);
+		__sp804_clockevents_init(base + TIMER_2_BASE, irq,
+					 clk2, name, width);
+		__sp804_clocksource_and_sched_clock_init(base, name,
+							 clk1, 1, width);
 	} else {
-		__sp804_clockevents_init(base, irq, clk1 , name);
+		__sp804_clockevents_init(base, irq, clk1, name, width);
 		__sp804_clocksource_and_sched_clock_init(base + TIMER_2_BASE,
-							 name, clk2, 1);
+							 name, clk2, 1, width);
 	}
 	initialized = true;
 
@@ -293,13 +308,14 @@ static void __init integrator_cp_of_init(struct device_node *np)
 		goto err;
 
 	if (!init_count)
-		__sp804_clocksource_and_sched_clock_init(base, name, clk, 0);
+		__sp804_clocksource_and_sched_clock_init(base, name,
+							 clk, 0, 32);
 	else {
 		irq = irq_of_parse_and_map(np, 0);
 		if (irq <= 0)
 			goto err;
 
-		__sp804_clockevents_init(base, irq, clk, name);
+		__sp804_clockevents_init(base, irq, clk, name, 32);
 	}
 
 	init_count++;
diff --git a/include/clocksource/timer-sp804.h b/include/clocksource/timer-sp804.h
index 1f8a1ca..ad71fcb 100644
--- a/include/clocksource/timer-sp804.h
+++ b/include/clocksource/timer-sp804.h
@@ -4,25 +4,26 @@
 struct clk;
 
 void __sp804_clocksource_and_sched_clock_init(void __iomem *,
-					      const char *, struct clk *, int);
+					      const char *, struct clk *,
+					      int, unsigned);
 void __sp804_clockevents_init(void __iomem *, unsigned int,
-			      struct clk *, const char *);
+			      struct clk *, const char *, unsigned);
 void sp804_timer_disable(void __iomem *);
 
 static inline void sp804_clocksource_init(void __iomem *base, const char *name)
 {
-	__sp804_clocksource_and_sched_clock_init(base, name, NULL, 0);
+	__sp804_clocksource_and_sched_clock_init(base, name, NULL, 0, 32);
 }
 
 static inline void sp804_clocksource_and_sched_clock_init(void __iomem *base,
 							  const char *name)
 {
-	__sp804_clocksource_and_sched_clock_init(base, name, NULL, 1);
+	__sp804_clocksource_and_sched_clock_init(base, name, NULL, 1, 32);
 }
 
 static inline void sp804_clockevents_init(void __iomem *base, unsigned int irq, const char *name)
 {
-	__sp804_clockevents_init(base, irq, NULL, name);
+	__sp804_clockevents_init(base, irq, NULL, name, 32);
 
 }
 #endif
-- 
1.9.1

  reply	other threads:[~2016-03-09 10:25 UTC|newest]

Thread overview: 92+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-03 11:39 [PATCH 00/17] Add Initial support for PLX Technology OX810SE Neil Armstrong
2016-03-03 11:39 ` [PATCH 01/17] dt-bindings: vendor-prefixes: Add PLX Technology Neil Armstrong
2016-03-03 15:02   ` Philipp Zabel
2016-03-05  4:29     ` Rob Herring
2016-03-07  9:55       ` Philipp Zabel
2016-03-03 11:39 ` [PATCH 02/17] irqchip: Add PLX Technology RPS IRQ Controller Neil Armstrong
2016-03-03 13:01   ` Marc Zyngier
2016-03-03 13:08     ` Arnd Bergmann
2016-03-03 13:36       ` Russell King - ARM Linux
2016-03-03 17:32         ` Arnd Bergmann
2016-03-03 15:32   ` Ma Haijun
2016-03-03 16:56     ` Neil Armstrong
2016-03-03 17:17       ` Marc Zyngier
2016-03-04 11:10         ` Neil Armstrong
2016-03-03 11:39 ` [PATCH 03/17] dt-bindings: Add PLX Technology RPS IRQ Controller bindings Neil Armstrong
2016-03-03 14:53   ` Andrew Lunn
2016-03-03 14:57     ` Neil Armstrong
2016-03-03 15:06       ` Andrew Lunn
2016-03-03 11:39 ` [PATCH 04/17] clocksource: Add PLX Technology RPS Timer Neil Armstrong
2016-03-17 16:13   ` Daniel Lezcano
2016-03-03 11:39 ` [PATCH 05/17] dt-bindings: Add PLX Technology RPS Timer bindings Neil Armstrong
2016-03-03 11:39 ` [PATCH 06/17] reset: Add PLX Technology Reset Controller driver Neil Armstrong
2016-03-03 14:18   ` Philipp Zabel
2016-03-03 14:29     ` Neil Armstrong
2016-03-03 15:00       ` Philipp Zabel
2016-03-03 11:40 ` [PATCH 07/17] dt-bindings: Add PLX Technology Reset Controller bindings Neil Armstrong
2016-03-03 14:21   ` Philipp Zabel
2016-03-03 14:24     ` Neil Armstrong
2016-03-03 14:31       ` Philipp Zabel
2016-03-03 11:40 ` [PATCH 08/17] clk: Add PLX Technology OXNAS Standard Clocks Neil Armstrong
2016-03-04  2:25   ` Stephen Boyd
2016-03-07 11:24     ` Neil Armstrong
2016-03-03 11:40 ` [PATCH 09/17] dt-bindings: Add PLX Technology OXNAS Standard Clocks bindings Neil Armstrong
2016-03-03 11:40 ` [PATCH 10/17] pinctrl: Add PLX Technology OXNAS pinctrl and gpio driver Neil Armstrong
2016-03-15 14:56   ` Linus Walleij
2016-03-16 15:00     ` Neil Armstrong
2016-03-17 14:49       ` Linus Walleij
2016-03-03 11:40 ` [PATCH 11/17] dt-bindings: Add PLX Technology OXNAS pinctrl and gpio bindings Neil Armstrong
2016-03-15 14:30   ` Linus Walleij
2016-03-03 11:40 ` [PATCH 12/17] arm: Add new mach-oxnas Neil Armstrong
2016-03-03 11:49   ` Russell King - ARM Linux
2016-03-03 12:37     ` Neil Armstrong
2016-03-03 12:56   ` Arnd Bergmann
2016-03-03 13:29     ` Russell King - ARM Linux
2016-03-03 13:40       ` Arnd Bergmann
2016-03-03 11:40 ` [PATCH 13/17] arm: Add build support for mach-oxnas Neil Armstrong
2016-03-03 11:40 ` [PATCH 14/17] arm: boot: dts: Add PLX Technology OX810SE dtsi Neil Armstrong
2016-03-03 12:15   ` Arnd Bergmann
2016-03-03 13:39     ` Neil Armstrong
2016-03-03 11:40 ` [PATCH 15/17] dt-bindings: Add OXNAS bindings Neil Armstrong
2016-03-03 11:40 ` [PATCH 16/17] dt-bindings: Add Western Digital to vendor prefixes Neil Armstrong
2016-03-05  4:29   ` Rob Herring
2016-03-03 11:40 ` [PATCH 17/17] arm: boot: dts: Add Western Digital My Book World Edition device tree Neil Armstrong
2016-03-03 12:23 ` [PATCH 00/17] Add Initial support for PLX Technology OX810SE Arnd Bergmann
2016-03-03 12:36   ` Neil Armstrong
2016-03-09 10:24 ` [PATCH v2 00/18] " Neil Armstrong
2016-03-09 10:24   ` Neil Armstrong [this message]
2016-03-17 16:40     ` [PATCH v2 01/18] clocksource: sp804: Add support for non-32bit width counter Daniel Lezcano
2016-03-09 10:24   ` [PATCH v2 02/18] dt-bindings: timer: sp804: add timer-width property Neil Armstrong
2016-03-17 17:09     ` Rob Herring
2016-03-17 18:06       ` Robin Murphy
2016-03-17 19:00         ` Rob Herring
2016-03-17 19:21           ` Robin Murphy
2016-03-22  9:21             ` Neil Armstrong
2016-03-22 12:02               ` Robin Murphy
2016-03-22 14:29                 ` Neil Armstrong
2016-03-09 10:24   ` [PATCH v2 03/18] irqchip: versatile-fpga: add new arm,rps-irq compatible Neil Armstrong
2016-03-15 11:47     ` Marc Zyngier
2016-03-09 10:24   ` [PATCH v2 04/18] dt-bindings: irq: arm,versatile-fpga: add arm,rps-irq compatible string Neil Armstrong
2016-03-17 17:15     ` Rob Herring
2016-03-09 10:24   ` [PATCH v2 05/18] dt-bindings: vendor-prefixes: Add PLX Technology Neil Armstrong
2016-03-17 17:15     ` Rob Herring
2016-03-09 10:24   ` [PATCH v2 06/18] dt-bindings: Add Oxford Semiconductors to vendor prefixes Neil Armstrong
2016-03-17 17:16     ` Rob Herring
2016-03-09 10:24   ` [PATCH v2 07/18] reset: Add PLX Technology Reset Controller driver Neil Armstrong
2016-03-09 10:24   ` [PATCH v2 08/18] dt-bindings: Add PLX Technology Reset Controller bindings Neil Armstrong
2016-03-17 17:18     ` Rob Herring
2016-03-09 10:24   ` [PATCH v2 09/18] clk: Add PLX Technology OXNAS Standard Clocks Neil Armstrong
2016-03-09 10:24   ` [PATCH v2 10/18] dt-bindings: Add PLX Technology OXNAS Standard Clocks bindings Neil Armstrong
2016-03-17 17:19     ` Rob Herring
2016-03-09 10:24   ` [PATCH v2 11/18] pinctrl: Add PLX Technology OXNAS pinctrl and gpio driver Neil Armstrong
2016-03-10 14:43     ` kbuild test robot
2016-03-09 10:24   ` [PATCH v2 12/18] dt-bindings: Add PLX Technology OXNAS pinctrl and gpio bindings Neil Armstrong
2016-03-17 17:25     ` Rob Herring
2016-03-09 10:24   ` [PATCH v2 13/18] arm: Add new mach-oxnas Neil Armstrong
2016-03-09 10:24   ` [PATCH v2 14/18] arm: Add build support for mach-oxnas Neil Armstrong
2016-03-09 10:24   ` [PATCH v2 15/18] arm: boot: dts: Add PLX Technology OX810SE dtsi Neil Armstrong
2016-03-09 10:24   ` [PATCH v2 16/18] dt-bindings: Add OXNAS bindings Neil Armstrong
2016-03-17 17:27     ` Rob Herring
2016-03-23  8:37       ` Neil Armstrong
2016-03-09 10:24   ` [PATCH v2 17/18] dt-bindings: Add Western Digital to vendor prefixes Neil Armstrong
2016-03-09 10:24   ` [PATCH v2 18/18] arm: boot: dts: Add Western Digital My Book World Edition device tree Neil Armstrong

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=1457519060-6038-2-git-send-email-narmstrong@baylibre.com \
    --to=narmstrong@baylibre.com \
    --cc=daniel.lezcano@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rmk+kernel@arm.linux.org.uk \
    --cc=sudeep.holla@arm.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome