devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Domenico Andreoli <cavokz-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
Cc: Domenico Andreoli
	<domenico.andreoli-vYTEC60ixJUAvxtiuMwx3w@public.gmane.org>,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org
Subject: [PATCH 3/6] ARM: bcm476x: Add sched clock
Date: Sun, 07 Oct 2012 03:53:03 +0200	[thread overview]
Message-ID: <20121007015406.809888002@gmail.com> (raw)
In-Reply-To: 20121007015300.828366635@gmail.com

[-- Attachment #1: arm-bcm476x-add-sched-clock.patch --]
[-- Type: text/plain, Size: 3704 bytes --]

From: Domenico Andreoli <domenico.andreoli-vYTEC60ixJUAvxtiuMwx3w@public.gmane.org>

Sched clock implementation based on the BCM476x's free runner counter.

Signed-off-by: Domenico Andreoli <domenico.andreoli-vYTEC60ixJUAvxtiuMwx3w@public.gmane.org>
---
 Documentation/devicetree/bindings/timer/brcm,bcm476x-sched-clock.txt |   18 +++
 arch/arm/boot/dts/bcm476x.dtsi                                       |    6 +
 drivers/clocksource/bcm476x_timer.c                                  |   52 ++++++++++
 3 files changed, 76 insertions(+)

Index: b/Documentation/devicetree/bindings/timer/brcm,bcm476x-sched-clock.txt
===================================================================
--- /dev/null
+++ b/Documentation/devicetree/bindings/timer/brcm,bcm476x-sched-clock.txt
@@ -0,0 +1,18 @@
+BCM476x Sched clock
+
+The BCM476x provides a 63-bit free running counter driven by a separate
+32KHz clock line.
+
+Required properties:
+
+- compatible : should be "brcm,bcm476x-sched-clock"
+- reg : Specifies base physical address and size of the registers.
+- clock-frequency : The frequency of the clock that drives the counter, in Hz.
+
+Example:
+
+sched-clock {
+	compatible = "brcm,bcm476x-sched-clock";
+	reg = <0xbc000 0x1000>;
+	clock-frequency = <32000>;
+};
Index: b/drivers/clocksource/bcm476x_timer.c
===================================================================
--- a/drivers/clocksource/bcm476x_timer.c
+++ b/drivers/clocksource/bcm476x_timer.c
@@ -54,6 +54,21 @@ struct bcm476x_timer {
 	struct irqaction act;
 };
 
+static void __iomem *system_clock __read_mostly;
+
+static u32 notrace bcm476x_sched_read(void)
+{
+	u32 hi, lo;
+
+	/* access to the counter must happen in the lo-hi order even if
+	 * only the lower 32-bit part is of interest
+	 */
+	lo = readl(system_clock);
+	hi = readl(system_clock + 4);
+
+	return lo;
+}
+
 static inline void __iomem *to_load(struct bcm476x_timer *timer)
 {
 	return timer->base + TIMER_LOAD_OFFSET;
@@ -131,6 +146,42 @@ static irqreturn_t bcm476x_timer_interru
 	return IRQ_HANDLED;
 }
 
+static struct of_device_id bcm476x_sched_clock_match[] __initconst = {
+	{ .compatible = "brcm,bcm476x-sched-clock" },
+	{}
+};
+
+static void __init bcm476x_sched_clock_init(void)
+{
+	struct device_node *node;
+	void __iomem *base;
+	u32 freq;
+
+	node = of_find_matching_node(NULL, bcm476x_sched_clock_match);
+	if (!node) {
+		pr_info("No bcm476x sched clock node");
+		return;
+	}
+
+	base = of_iomap(node, 0);
+	if (!base) {
+		pr_err("Can't remap sched clock registers");
+		return;
+	}
+
+	if (of_property_read_u32(node, "clock-frequency", &freq)) {
+		pr_err("Can't read sched clock frequency");
+		return;
+	}
+	if (freq != 32000) {
+		pr_err("Invalid sched clock frequency");
+		return;
+	}
+
+	system_clock = base;
+	setup_sched_clock(bcm476x_sched_read, 32, freq);
+}
+
 static struct of_device_id bcm476x_timer_match[] __initconst = {
 	{ .compatible = "brcm,bcm476x-system-timer" },
 	{}
@@ -180,6 +231,7 @@ static void __init bcm476x_timer_init(vo
 	if (setup_irq(irq, &timer->act))
 		panic("Can't set up timer IRQ\n");
 
+	bcm476x_sched_clock_init();
 	clockevents_config_and_register(&timer->evt, freq, 0xf, 0xffffffff);
 }
 
Index: b/arch/arm/boot/dts/bcm476x.dtsi
===================================================================
--- a/arch/arm/boot/dts/bcm476x.dtsi
+++ b/arch/arm/boot/dts/bcm476x.dtsi
@@ -22,6 +22,12 @@
 			clock-frequency = <24000000>;
 		};
 
+		sched-clock {
+			compatible = "brcm,bcm476x-sched-clock";
+			reg = <0xbc000 0x1000>;
+			clock-frequency = <32000>;
+		};
+
 		vic0: interrupt-controller@80000 {
 			compatible = "brcm,bcm476x-pl192", "arm,pl192-vic", "arm,primecell";
 			reg = <0x80000 0x1000>;

  parent reply	other threads:[~2012-10-07  1:53 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-07  1:53 [PATCH 0/6] ARM: Add support for Broadcom BCM476x SoCs Domenico Andreoli
2012-10-07  1:53 ` [PATCH 1/6] ARM: bcm476x: Add infrastructure Domenico Andreoli
2012-10-08 11:50   ` Florian Fainelli
2012-10-09  2:41     ` Stephen Warren
2012-10-08 12:14   ` Thomas Petazzoni
2012-10-09 11:52     ` Domenico Andreoli
     [not found]   ` <20121007015405.958959522-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2012-10-07 19:57     ` Jean-Christophe PLAGNIOL-VILLARD
     [not found]       ` <20121007195759.GG12801-RQcB7r2h9QmfDR2tN2SG5Ni2O/JbrIOy@public.gmane.org>
2012-10-07 22:54         ` Domenico Andreoli
2012-10-08 13:13           ` Jean-Christophe PLAGNIOL-VILLARD
2012-10-09  2:37           ` Stephen Warren
     [not found]             ` <50738DD0.5090406-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2012-10-09 11:50               ` Domenico Andreoli
2012-10-09  2:48     ` Stephen Warren
     [not found]       ` <50739074.8000001-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2012-10-09 11:54         ` Domenico Andreoli
2012-10-09  3:08     ` Stephen Warren
     [not found]       ` <50739541.2030603-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2012-10-09 11:55         ` Domenico Andreoli
2012-10-09  9:18     ` Arnd Bergmann
     [not found]       ` <201210090918.56725.arnd-r2nGTMty4D4@public.gmane.org>
2012-10-09 22:58         ` Domenico Andreoli
2012-10-10  6:29           ` Arnd Bergmann
2012-10-12  7:06     ` Domenico Andreoli
2012-10-12  7:26       ` Thomas Petazzoni
2012-10-12  8:03         ` Arnd Bergmann
2012-10-12  8:12           ` Thomas Petazzoni
2012-10-12 10:48             ` Arnd Bergmann
2012-10-12 11:01               ` Thomas Petazzoni
2012-10-12 11:17                 ` Arnd Bergmann
2012-10-07  1:53 ` [PATCH 2/6] ARM: bcm476x: Add system timer Domenico Andreoli
2012-10-08 11:50   ` Florian Fainelli
2012-10-09  2:43     ` Stephen Warren
     [not found]       ` <50738F48.5010002-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2012-10-09 23:04         ` Domenico Andreoli
2012-10-07  1:53 ` Domenico Andreoli [this message]
     [not found]   ` <20121007015406.809888002-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2012-10-09  2:54     ` [PATCH 3/6] ARM: bcm476x: Add sched clock Stephen Warren
2012-10-07  1:53 ` [PATCH 4/6] ARM: bcm476x: Add stub clock driver Domenico Andreoli
     [not found]   ` <20121007015407.154476821-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2012-10-09  3:00     ` Stephen Warren
2012-10-12 14:52     ` Mike Turquette
2012-10-12 15:28       ` Domenico Andreoli
2012-10-07  1:53 ` [PATCH 5/6] ARM: bcm476x: Add restart hook Domenico Andreoli
2012-10-07  1:53 ` [PATCH 6/6] ARM: bcm476x: Instantiate console UART Domenico Andreoli
     [not found]   ` <20121007015407.840781689-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2012-10-07 20:03     ` Jean-Christophe PLAGNIOL-VILLARD
     [not found]       ` <20121007200300.GH12801-RQcB7r2h9QmfDR2tN2SG5Ni2O/JbrIOy@public.gmane.org>
2012-10-07 23:14         ` Domenico Andreoli
2012-10-09  3:06     ` Stephen Warren
     [not found]       ` <507394CB.5080300-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2012-10-09 23:37         ` Domenico Andreoli
     [not found] ` <20121007015300.828366635-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2012-10-07  5:22   ` [PATCH 0/6] ARM: Add support for Broadcom BCM476x SoCs Stephen Warren
     [not found]     ` <5071118A.6040508-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2012-10-07 10:14       ` Domenico Andreoli
2012-10-09  2:44         ` Stephen Warren
     [not found]           ` <50738F8F.3030006-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2012-10-09 23:57             ` Domenico Andreoli
2012-10-07 19:47   ` Olof Johansson

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=20121007015406.809888002@gmail.com \
    --to=cavokz-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org \
    --cc=domenico.andreoli-vYTEC60ixJUAvxtiuMwx3w@public.gmane.org \
    --cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    /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;
as well as URLs for NNTP newsgroup(s).