devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Grant Likely <grant.likely@secretlab.ca>
To: devicetree-discuss@lists.ozlabs.org,
	linux-arm-kernel@lists.infradead.org,
	Sascha Hauer <kernel@pengutronix.de>,
	Rob Herring <rob.herring@calxeda.com>
Cc: linux-kernel@vger.kernel.org, Grant Likely <grant.likely@secretlab.ca>
Subject: [RFC 8/8] dt/arm: versatile add clock parsing
Date: Tue,  8 Nov 2011 18:19:43 -0700	[thread overview]
Message-ID: <1320801583-12774-9-git-send-email-grant.likely@secretlab.ca> (raw)
In-Reply-To: <1320801583-12774-1-git-send-email-grant.likely@secretlab.ca>

Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
---
 arch/arm/boot/dts/versatile-ab.dts     |   37 ++++++++++++++++++++++++++++++++
 arch/arm/boot/dts/versatile-pb.dts     |    2 +
 arch/arm/mach-versatile/core.c         |   37 +------------------------------
 arch/arm/mach-versatile/versatile_dt.c |   33 ++++++++++++++++++++++++++++
 4 files changed, 74 insertions(+), 35 deletions(-)

diff --git a/arch/arm/boot/dts/versatile-ab.dts b/arch/arm/boot/dts/versatile-ab.dts
index 0b32925..cb8a49e 100644
--- a/arch/arm/boot/dts/versatile-ab.dts
+++ b/arch/arm/boot/dts/versatile-ab.dts
@@ -19,6 +19,35 @@
 		reg = <0x0 0x08000000>;
 	};
 
+	clocks {
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		ref24_clk: clock0 {
+			compatible = "fixed-clock";
+			#clock-cells = <1>;
+			clock-frequency = <24000000>;
+			clock-output-names = "ref";
+		};
+
+		sp804_clk: clock1 {
+			compatible = "fixed-clock";
+			#clock-cells = <1>;
+			clock-frequency = <1000000>;
+			clock-output-names = "ref";
+		};
+
+		osc4_clk: clock3 {
+			compatible = "ics,icst307";
+			#clock-cells = <1>;
+			ref = <24000>;
+			vco-max = <200000>;
+			vd-range = <12 519>;
+			rd-range = <3 129>;
+			clock-output-names = "osc4";
+		};
+	};
+
 	flash@34000000 {
 		compatible = "arm,versatile-flash";
 		reg = <0x34000000 0x4000000>;
@@ -80,18 +109,21 @@
 			compatible = "arm,pl011", "arm,primecell";
 			reg = <0x101f1000 0x1000>;
 			interrupts = <12>;
+			clock = <&ref24_clk 0>;
 		};
 
 		uart1: uart@101f2000 {
 			compatible = "arm,pl011", "arm,primecell";
 			reg = <0x101f2000 0x1000>;
 			interrupts = <13>;
+			clock = <&ref24_clk 0>;
 		};
 
 		uart2: uart@101f3000 {
 			compatible = "arm,pl011", "arm,primecell";
 			reg = <0x101f3000 0x1000>;
 			interrupts = <14>;
+			clock = <&ref24_clk 0>;
 		};
 
 		smc@10100000 {
@@ -108,6 +140,7 @@
 			compatible = "arm,pl110", "arm,primecell";
 			reg = <0x10120000 0x1000>;
 			interrupts = <16>;
+			clock = <&osc4_clk 0>;
 		};
 
 		sctl@101e0000 {
@@ -157,6 +190,7 @@
 			compatible = "arm,pl022", "arm,primecell";
 			reg = <0x101f4000 0x1000>;
 			interrupts = <11>;
+			clock = <&ref24_clk 0>;
 		};
 
 		fpga {
@@ -174,18 +208,21 @@
 				compatible = "arm,primecell";
 				reg = < 0x5000 0x1000>;
 				interrupts = <22>;
+				clock = <&ref24_clk 0>;
 			};
 			kmi@6000 {
 				compatible = "arm,pl050", "arm,primecell";
 				reg = <0x6000 0x1000>;
 				interrupt-parent = <&sic>;
 				interrupts = <3>;
+				clock = <&ref24_clk 0>;
 			};
 			kmi@7000 {
 				compatible = "arm,pl050", "arm,primecell";
 				reg = <0x7000 0x1000>;
 				interrupt-parent = <&sic>;
 				interrupts = <4>;
+				clock = <&ref24_clk 0>;
 			};
 		};
 	};
diff --git a/arch/arm/boot/dts/versatile-pb.dts b/arch/arm/boot/dts/versatile-pb.dts
index 1664610..05e014a 100644
--- a/arch/arm/boot/dts/versatile-pb.dts
+++ b/arch/arm/boot/dts/versatile-pb.dts
@@ -31,6 +31,7 @@
 				reg = <0x9000 0x1000>;
 				interrupt-parent = <&sic>;
 				interrupts = <6>;
+				clock = <&ref24_clk 0>;
 			};
 			sci@a000 {
 				compatible = "arm,primecell";
@@ -42,6 +43,7 @@
 				compatible = "arm,primecell";
 				reg = <0xb000 0x1000>;
 				interrupts = <23>;
+				clock = <&ref24_clk 0>;
 			};
 		};
 	};
diff --git a/arch/arm/mach-versatile/core.c b/arch/arm/mach-versatile/core.c
index e340a54..4cd9822 100644
--- a/arch/arm/mach-versatile/core.c
+++ b/arch/arm/mach-versatile/core.c
@@ -666,44 +666,11 @@ static struct amba_device *amba_devs[] __initdata = {
 /*
  * Lookup table for attaching a specific name and platform_data pointer to
  * devices as they get created by of_platform_populate().  Ideally this table
- * would not exist, but the current clock implementation depends on some devices
- * having a specific name.
+ * would not exist, but some devices still need platform data.
  */
 struct of_dev_auxdata versatile_auxdata_lookup[] __initdata = {
-	OF_DEV_AUXDATA("arm,primecell", VERSATILE_MMCI0_BASE, "fpga:05", NULL),
-	OF_DEV_AUXDATA("arm,primecell", VERSATILE_KMI0_BASE, "fpga:06", NULL),
-	OF_DEV_AUXDATA("arm,primecell", VERSATILE_KMI1_BASE, "fpga:07", NULL),
-	OF_DEV_AUXDATA("arm,primecell", VERSATILE_UART3_BASE, "fpga:09", NULL),
-	OF_DEV_AUXDATA("arm,primecell", VERSATILE_MMCI1_BASE, "fpga:0b", NULL),
-
-	OF_DEV_AUXDATA("arm,primecell", VERSATILE_CLCD_BASE, "dev:20", &clcd_plat_data),
-	OF_DEV_AUXDATA("arm,primecell", VERSATILE_UART0_BASE, "dev:f1", NULL),
-	OF_DEV_AUXDATA("arm,primecell", VERSATILE_UART1_BASE, "dev:f2", NULL),
-	OF_DEV_AUXDATA("arm,primecell", VERSATILE_UART2_BASE, "dev:f3", NULL),
-	OF_DEV_AUXDATA("arm,primecell", VERSATILE_SSP_BASE, "dev:f4", NULL),
 
-#if 0
-	/*
-	 * These entries are unnecessary because no clocks referencing
-	 * them.  I've left them in for now as place holders in case
-	 * any of them need to be added back, but they should be
-	 * removed before actually committing this patch.  --gcl
-	 */
-	OF_DEV_AUXDATA("arm,primecell", VERSATILE_AACI_BASE, "fpga:04", NULL),
-	OF_DEV_AUXDATA("arm,primecell", VERSATILE_SCI1_BASE, "fpga:0a", NULL),
-	OF_DEV_AUXDATA("arm,primecell", VERSATILE_SMC_BASE, "dev:00", NULL),
-	OF_DEV_AUXDATA("arm,primecell", VERSATILE_MPMC_BASE, "dev:10", NULL),
-	OF_DEV_AUXDATA("arm,primecell", VERSATILE_DMAC_BASE, "dev:30", NULL),
-
-	OF_DEV_AUXDATA("arm,primecell", VERSATILE_SCTL_BASE, "dev:e0", NULL),
-	OF_DEV_AUXDATA("arm,primecell", VERSATILE_WATCHDOG_BASE, "dev:e1", NULL),
-	OF_DEV_AUXDATA("arm,primecell", VERSATILE_GPIO0_BASE, "dev:e4", NULL),
-	OF_DEV_AUXDATA("arm,primecell", VERSATILE_GPIO1_BASE, "dev:e5", NULL),
-	OF_DEV_AUXDATA("arm,primecell", VERSATILE_GPIO2_BASE, "dev:e6", NULL),
-	OF_DEV_AUXDATA("arm,primecell", VERSATILE_GPIO3_BASE, "dev:e7", NULL),
-	OF_DEV_AUXDATA("arm,primecell", VERSATILE_RTC_BASE, "dev:e8", NULL),
-	OF_DEV_AUXDATA("arm,primecell", VERSATILE_SCI_BASE, "dev:f0", NULL),
-#endif
+	OF_DEV_AUXDATA("arm,primecell", VERSATILE_CLCD_BASE, NULL, &clcd_plat_data),
 	{}
 };
 #endif
diff --git a/arch/arm/mach-versatile/versatile_dt.c b/arch/arm/mach-versatile/versatile_dt.c
index 54e037c..f11f6d0 100644
--- a/arch/arm/mach-versatile/versatile_dt.c
+++ b/arch/arm/mach-versatile/versatile_dt.c
@@ -24,13 +24,46 @@
 #include <linux/init.h>
 #include <linux/of_irq.h>
 #include <linux/of_platform.h>
+#include <linux/of_clk.h>
+#include <linux/slab.h>
+
+#include <mach/hardware.h>
+#include <mach/clkdev.h>
+#include <asm/irq.h>
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
 
 #include "core.h"
 
+/* Scan for fixed clocks */
+static struct clk *versatile_dt_clk_get(struct of_phandle_args *a, void *data)
+{
+	return data;
+}
+
 static void __init versatile_dt_init(void)
 {
+	struct device_node *node;
+	struct clk *clk;
+	int rc;
+
+	for_each_compatible_node(node, NULL, "fixed-clock") {
+		u32 rate;
+		if (of_property_read_u32(node, "clock-frequency", &rate))
+			continue;
+
+		clk = kzalloc(sizeof(*clk), GFP_KERNEL);
+		if (!clk)
+			panic("out of memory\n");
+		clk->rate = rate;
+
+		rc = of_clk_add_provider(node, versatile_dt_clk_get, clk);
+		if (rc) {
+			kfree(clk);
+			pr_err("error adding fixed clk %s\n", node->name);
+		}
+	}
+
 	of_platform_populate(NULL, of_default_bus_match_table,
 			     versatile_auxdata_lookup, NULL);
 }
-- 
1.7.5.4

  parent reply	other threads:[~2011-11-09  1:19 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-09  1:19 [RFC 0/8] Initial DT clock bindings Grant Likely
2011-11-09  1:19 ` [RFC 1/8] gpio/microblaze: Eliminate duplication of of_get_named_gpio_flags() Grant Likely
2011-12-21 10:22   ` Michal Simek
2012-01-04 18:30     ` Grant Likely
     [not found]       ` <20120104183057.GU15503-e0URQFbLeQY2iJbIjFUEsiwD8/FfD2ys@public.gmane.org>
2012-01-05  7:28         ` Michal Simek
2011-11-09  1:19 ` [RFC 3/8] of: create of_phandle_args to simplify return of phandle parsing data Grant Likely
2011-11-14  3:59   ` Shawn Guo
     [not found]     ` <20111114035908.GA10236-+NayF8gZjK2ctlrPMvKcciBecyulp+rMXqFh9Ls21Oc@public.gmane.org>
2011-11-16 18:47       ` Grant Likely
2011-11-21 15:50   ` Shawn Guo
     [not found] ` <1320801583-12774-1-git-send-email-grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>
2011-11-09  1:19   ` [RFC 2/8] gpio/powerpc: Eliminate duplication of of_get_named_gpio_flags() Grant Likely
2011-11-09  1:19   ` [RFC 4/8] of: Add device tree selftests Grant Likely
2011-11-09  1:19   ` [RFC 5/8] of: Add of_property_match_string() to find index into a string list Grant Likely
2011-11-09  1:19   ` [RFC 6/8] of: add clock providers Grant Likely
2011-11-09 18:39     ` Tony Lindgren
     [not found]     ` <1320801583-12774-7-git-send-email-grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>
2011-11-09  2:49       ` Rob Herring
2011-11-14  2:14         ` Richard Zhao
2011-11-16 19:06           ` Grant Likely
2011-11-09  9:13       ` Sascha Hauer
     [not found]         ` <20111109091328.GY16886-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2011-11-09 11:23           ` Cousson, Benoit
     [not found]             ` <4EBA62AD.3000407-l0cyMroinI0@public.gmane.org>
2011-11-09 11:49               ` Sascha Hauer
     [not found]                 ` <20111109114936.GL16886-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2011-11-11 19:57                   ` Cousson, Benoit
2011-11-16 22:12                     ` Grant Likely
2011-11-18  7:48                       ` Sascha Hauer
2011-11-09 13:59               ` Rob Herring
     [not found]                 ` <4EBA8735.902-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2011-11-11 19:50                   ` Cousson, Benoit
2011-11-09 13:31         ` Rob Herring
2011-11-21 15:37       ` Shawn Guo
     [not found]         ` <20111121153716.GA16417-+NayF8gZjK2ctlrPMvKcciBecyulp+rMXqFh9Ls21Oc@public.gmane.org>
2011-11-30 19:38           ` Grant Likely
2011-12-01  6:34             ` Shawn Guo
2011-11-09  1:19   ` [RFC 7/8] arm/clkdev: lookup clocks from OF " Grant Likely
2011-11-09  2:36     ` Rob Herring
2011-11-16 18:54       ` Grant Likely
2011-11-09  1:19 ` Grant Likely [this message]
     [not found]   ` <1320801583-12774-9-git-send-email-grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>
2011-11-09  9:31     ` [RFC 8/8] dt/arm: versatile add clock parsing Sascha Hauer

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=1320801583-12774-9-git-send-email-grant.likely@secretlab.ca \
    --to=grant.likely@secretlab.ca \
    --cc=devicetree-discuss@lists.ozlabs.org \
    --cc=kernel@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rob.herring@calxeda.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;
as well as URLs for NNTP newsgroup(s).