All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michal Simek <michal.simek@xilinx.com>
To: linux-arm-kernel@lists.infradead.org, Arnd Bergmann <arnd@arndb.de>
Cc: monstr@monstr.eu, Josh Cartwright <josh.cartwright@ni.com>,
	Steffen Trumtrar <s.trumtrar@pengutronix.de>,
	Rob Herring <robherring2@gmail.com>,
	Peter Crosthwaite <peter.crosthwaite@xilinx.com>,
	Rob Herring <robh+dt@kernel.org>, Pawel Moll <pawel.moll@arm.com>,
	Mark Rutland <mark.rutland@arm.com>,
	Ian Campbell <ijc+devicetree@hellion.org.uk>,
	Kumar Gala <galak@codeaurora.org>,
	Russell King <linux@arm.linux.org.uk>,
	Mike Turquette <mturquette@linaro.org>,
	Soren Brinkmann <soren.brinkmann@xilinx.com>,
	Stephen Boyd <sboyd@codeaurora.org>,
	Stephen Warren <swarren@nvidia.com>,
	James Hogan <james.hogan@imgtec.com>,
	Felipe Pena <felipensp@gmail.com>,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [RFC PATCH 3/3] ARM: zynq: Use early syscon initialization
Date: Mon, 10 Feb 2014 16:22:35 +0100	[thread overview]
Message-ID: <19fbad8c4c7d655ef73e0c7dd16a045a02a63286.1392045742.git.michal.simek@xilinx.com> (raw)
In-Reply-To: <cover.1392045742.git.michal.simek@xilinx.com>
In-Reply-To: <cover.1392045742.git.michal.simek@xilinx.com>

[-- Attachment #1: Type: text/plain, Size: 6063 bytes --]

Use early syscon initialization to simplify slcr code.
- Remove two slcr inits (zynq_slcr_init, zynq_early_slcr_init)
- Directly use regmap accesses in zynq_slcr_read/write
- Remove zynq_clock_init() and use addresses from syscon
  (This is the most problematic part now because clock
  doesn't support regmap accesses that's why reading
  slcr base is ugly. There are some attempts to get
  clk regmap to work - for example:
  https://lkml.org/lkml/2013/10/16/112)

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---

Especially look at slcr.c which is much simpler than was before.
clkc.c will be simpler when regmap support is added because then
syscon_early_regmap_lookup_by_phandle() will be called
without zynq_slcr_base search.

---
 arch/arm/boot/dts/zynq-7000.dtsi |  1 +
 arch/arm/mach-zynq/common.c      |  6 ++---
 arch/arm/mach-zynq/slcr.c        | 42 ++---------------------------
 drivers/clk/zynq/clkc.c          | 57 ++++++++++++----------------------------
 4 files changed, 23 insertions(+), 83 deletions(-)

diff --git a/arch/arm/boot/dts/zynq-7000.dtsi b/arch/arm/boot/dts/zynq-7000.dtsi
index 7284499..e414489 100644
--- a/arch/arm/boot/dts/zynq-7000.dtsi
+++ b/arch/arm/boot/dts/zynq-7000.dtsi
@@ -135,6 +135,7 @@
 			compatible = "xlnx,zynq-slcr", "syscon";
 			reg = <0xF8000000 0x1000>;
 			ranges;
+			syscon = <&slcr>;
 			clkc: clkc@100 {
 				#clock-cells = <1>;
 				compatible = "xlnx,ps7-clkc";
diff --git a/arch/arm/mach-zynq/common.c b/arch/arm/mach-zynq/common.c
index 9d3c88e..78589e3 100644
--- a/arch/arm/mach-zynq/common.c
+++ b/arch/arm/mach-zynq/common.c
@@ -28,6 +28,7 @@
 #include <linux/of.h>
 #include <linux/irqchip.h>
 #include <linux/irqchip/arm-gic.h>
+#include <linux/mfd/syscon.h>
 #include <linux/slab.h>
 #include <linux/sys_soc.h>

@@ -130,15 +131,14 @@ out:
 	of_platform_populate(NULL, of_default_bus_match_table, NULL, parent);

 	platform_device_register(&zynq_cpuidle_device);
-
-	zynq_slcr_init();
 }

 static void __init zynq_timer_init(void)
 {
+	early_syscon_init();
+
 	zynq_early_slcr_init();

-	zynq_clock_init();
 	of_clk_init(NULL);
 	clocksource_of_init();
 }
diff --git a/arch/arm/mach-zynq/slcr.c b/arch/arm/mach-zynq/slcr.c
index 594b280..a89b082 100644
--- a/arch/arm/mach-zynq/slcr.c
+++ b/arch/arm/mach-zynq/slcr.c
@@ -35,7 +35,6 @@
 #define SLCR_PSS_IDCODE_DEVICE_SHIFT	12
 #define SLCR_PSS_IDCODE_DEVICE_MASK	0x1F

-static void __iomem *zynq_slcr_base;
 static struct regmap *zynq_slcr_regmap;

 /**
@@ -48,11 +47,6 @@ static struct regmap *zynq_slcr_regmap;
  */
 static int zynq_slcr_write(u32 val, u32 offset)
 {
-	if (!zynq_slcr_regmap) {
-		writel(val, zynq_slcr_base + offset);
-		return 0;
-	}
-
 	return regmap_write(zynq_slcr_regmap, offset, val);
 }

@@ -66,12 +60,7 @@ static int zynq_slcr_write(u32 val, u32 offset)
  */
 static int zynq_slcr_read(u32 *val, u32 offset)
 {
-	if (zynq_slcr_regmap)
-		return regmap_read(zynq_slcr_regmap, offset, val);
-
-	*val = readl(zynq_slcr_base + offset);
-
-	return 0;
+	return regmap_read(zynq_slcr_regmap, offset, val);
 }

 /**
@@ -169,24 +158,6 @@ void zynq_slcr_cpu_stop(int cpu)
 }

 /**
- * zynq_slcr_init - Regular slcr driver init
- *
- * Return:	0 on success, negative errno otherwise.
- *
- * Called early during boot from platform code to remap SLCR area.
- */
-int __init zynq_slcr_init(void)
-{
-	zynq_slcr_regmap = syscon_regmap_lookup_by_compatible("xlnx,zynq-slcr");
-	if (IS_ERR(zynq_slcr_regmap)) {
-		pr_err("%s: failed to find zynq-slcr\n", __func__);
-		return -ENODEV;
-	}
-
-	return 0;
-}
-
-/**
  * zynq_early_slcr_init - Early slcr init function
  *
  * Return:	0 on success, negative errno otherwise.
@@ -202,20 +173,11 @@ int __init zynq_early_slcr_init(void)
 		pr_err("%s: no slcr node found\n", __func__);
 		BUG();
 	}
-
-	zynq_slcr_base = of_iomap(np, 0);
-	if (!zynq_slcr_base) {
-		pr_err("%s: Unable to map I/O memory\n", __func__);
-		BUG();
-	}
-
-	np->data = (__force void *)zynq_slcr_base;
+	zynq_slcr_regmap = syscon_early_regmap_lookup_by_phandle(np, "syscon");

 	/* unlock the SLCR so that registers can be changed */
 	zynq_slcr_unlock();

-	pr_info("%s mapped to %p\n", np->name, zynq_slcr_base);
-
 	of_node_put(np);

 	return 0;
diff --git a/drivers/clk/zynq/clkc.c b/drivers/clk/zynq/clkc.c
index c812b93..b2fd160 100644
--- a/drivers/clk/zynq/clkc.c
+++ b/drivers/clk/zynq/clkc.c
@@ -214,6 +214,10 @@ err:
 		clks[clk1] = ERR_PTR(-ENOMEM);
 }

+struct syscon {
+	void __iomem *base;
+};
+
 static void __init zynq_clk_setup(struct device_node *np)
 {
 	int i;
@@ -227,6 +231,19 @@ static void __init zynq_clk_setup(struct device_node *np)
 	const char *periph_parents[4];
 	const char *swdt_ext_clk_mux_parents[2];
 	const char *can_mio_mux_parents[NUM_MIO_PINS];
+	struct resource res;
+	void __iomem *zynq_slcr_base;
+
+	struct device_node *slcr = of_get_parent(np);
+	struct syscon *syscon = slcr->data;
+	zynq_slcr_base = syscon->base;
+
+	if (of_address_to_resource(np, 0, &res)) {
+		pr_err("%s: failed to get resource\n", np->name);
+		return;
+	}
+
+	zynq_clkc_base = zynq_slcr_base + res.start;

 	pr_info("Zynq clock init\n");

@@ -569,43 +586,3 @@ static void __init zynq_clk_setup(struct device_node *np)
 }

 CLK_OF_DECLARE(zynq_clkc, "xlnx,ps7-clkc", zynq_clk_setup);
-
-void __init zynq_clock_init(void)
-{
-	struct device_node *np;
-	struct device_node *slcr;
-	struct resource res;
-
-	np = of_find_compatible_node(NULL, NULL, "xlnx,ps7-clkc");
-	if (!np) {
-		pr_err("%s: clkc node not found\n", __func__);
-		goto np_err;
-	}
-
-	if (of_address_to_resource(np, 0, &res)) {
-		pr_err("%s: failed to get resource\n", np->name);
-		goto np_err;
-	}
-
-	slcr = of_get_parent(np);
-
-	if (slcr->data) {
-		zynq_clkc_base = (__force void __iomem *)slcr->data + res.start;
-	} else {
-		pr_err("%s: Unable to get I/O memory\n", np->name);
-		of_node_put(slcr);
-		goto np_err;
-	}
-
-	pr_info("%s: clkc starts at %p\n", __func__, zynq_clkc_base);
-
-	of_node_put(slcr);
-	of_node_put(np);
-
-	return;
-
-np_err:
-	of_node_put(np);
-	BUG();
-	return;
-}
--
1.8.2.3


[-- Attachment #2: Type: application/pgp-signature, Size: 198 bytes --]

WARNING: multiple messages have this Message-ID (diff)
From: Michal Simek <michal.simek-gjFFaj9aHVfQT0dZR+AlfA@public.gmane.org>
To: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
	Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org>
Cc: monstr-pSz03upnqPeHXe+LvDLADg@public.gmane.org,
	Josh Cartwright <josh.cartwright-acOepvfBmUk@public.gmane.org>,
	Steffen Trumtrar
	<s.trumtrar-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>,
	Rob Herring <robherring2-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	Peter Crosthwaite
	<peter.crosthwaite-gjFFaj9aHVfQT0dZR+AlfA@public.gmane.org>,
	Rob Herring <robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	Pawel Moll <pawel.moll-5wv7dgnIgG8@public.gmane.org>,
	Mark Rutland <mark.rutland-5wv7dgnIgG8@public.gmane.org>,
	Ian Campbell
	<ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg@public.gmane.org>,
	Kumar Gala <galak-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>,
	Russell King <linux-lFZ/pmaqli7XmaaqVzeoHQ@public.gmane.org>,
	Mike Turquette
	<mturquette-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
	Soren Brinkmann
	<soren.brinkmann-gjFFaj9aHVfQT0dZR+AlfA@public.gmane.org>,
	Stephen Boyd <sboyd-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>,
	Stephen Warren <swarren-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>,
	James Hogan <james.hogan-1AXoQHu6uovQT0dZR+AlfA@public.gmane.org>,
	Felipe Pena <felipensp-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: [RFC PATCH 3/3] ARM: zynq: Use early syscon initialization
Date: Mon, 10 Feb 2014 16:22:35 +0100	[thread overview]
Message-ID: <19fbad8c4c7d655ef73e0c7dd16a045a02a63286.1392045742.git.michal.simek@xilinx.com> (raw)
In-Reply-To: <cover.1392045742.git.michal.simek-gjFFaj9aHVfQT0dZR+AlfA@public.gmane.org>
In-Reply-To: <cover.1392045742.git.michal.simek-gjFFaj9aHVfQT0dZR+AlfA@public.gmane.org>

[-- Attachment #1: Type: text/plain, Size: 6092 bytes --]

Use early syscon initialization to simplify slcr code.
- Remove two slcr inits (zynq_slcr_init, zynq_early_slcr_init)
- Directly use regmap accesses in zynq_slcr_read/write
- Remove zynq_clock_init() and use addresses from syscon
  (This is the most problematic part now because clock
  doesn't support regmap accesses that's why reading
  slcr base is ugly. There are some attempts to get
  clk regmap to work - for example:
  https://lkml.org/lkml/2013/10/16/112)

Signed-off-by: Michal Simek <michal.simek-gjFFaj9aHVfQT0dZR+AlfA@public.gmane.org>
---

Especially look at slcr.c which is much simpler than was before.
clkc.c will be simpler when regmap support is added because then
syscon_early_regmap_lookup_by_phandle() will be called
without zynq_slcr_base search.

---
 arch/arm/boot/dts/zynq-7000.dtsi |  1 +
 arch/arm/mach-zynq/common.c      |  6 ++---
 arch/arm/mach-zynq/slcr.c        | 42 ++---------------------------
 drivers/clk/zynq/clkc.c          | 57 ++++++++++++----------------------------
 4 files changed, 23 insertions(+), 83 deletions(-)

diff --git a/arch/arm/boot/dts/zynq-7000.dtsi b/arch/arm/boot/dts/zynq-7000.dtsi
index 7284499..e414489 100644
--- a/arch/arm/boot/dts/zynq-7000.dtsi
+++ b/arch/arm/boot/dts/zynq-7000.dtsi
@@ -135,6 +135,7 @@
 			compatible = "xlnx,zynq-slcr", "syscon";
 			reg = <0xF8000000 0x1000>;
 			ranges;
+			syscon = <&slcr>;
 			clkc: clkc@100 {
 				#clock-cells = <1>;
 				compatible = "xlnx,ps7-clkc";
diff --git a/arch/arm/mach-zynq/common.c b/arch/arm/mach-zynq/common.c
index 9d3c88e..78589e3 100644
--- a/arch/arm/mach-zynq/common.c
+++ b/arch/arm/mach-zynq/common.c
@@ -28,6 +28,7 @@
 #include <linux/of.h>
 #include <linux/irqchip.h>
 #include <linux/irqchip/arm-gic.h>
+#include <linux/mfd/syscon.h>
 #include <linux/slab.h>
 #include <linux/sys_soc.h>

@@ -130,15 +131,14 @@ out:
 	of_platform_populate(NULL, of_default_bus_match_table, NULL, parent);

 	platform_device_register(&zynq_cpuidle_device);
-
-	zynq_slcr_init();
 }

 static void __init zynq_timer_init(void)
 {
+	early_syscon_init();
+
 	zynq_early_slcr_init();

-	zynq_clock_init();
 	of_clk_init(NULL);
 	clocksource_of_init();
 }
diff --git a/arch/arm/mach-zynq/slcr.c b/arch/arm/mach-zynq/slcr.c
index 594b280..a89b082 100644
--- a/arch/arm/mach-zynq/slcr.c
+++ b/arch/arm/mach-zynq/slcr.c
@@ -35,7 +35,6 @@
 #define SLCR_PSS_IDCODE_DEVICE_SHIFT	12
 #define SLCR_PSS_IDCODE_DEVICE_MASK	0x1F

-static void __iomem *zynq_slcr_base;
 static struct regmap *zynq_slcr_regmap;

 /**
@@ -48,11 +47,6 @@ static struct regmap *zynq_slcr_regmap;
  */
 static int zynq_slcr_write(u32 val, u32 offset)
 {
-	if (!zynq_slcr_regmap) {
-		writel(val, zynq_slcr_base + offset);
-		return 0;
-	}
-
 	return regmap_write(zynq_slcr_regmap, offset, val);
 }

@@ -66,12 +60,7 @@ static int zynq_slcr_write(u32 val, u32 offset)
  */
 static int zynq_slcr_read(u32 *val, u32 offset)
 {
-	if (zynq_slcr_regmap)
-		return regmap_read(zynq_slcr_regmap, offset, val);
-
-	*val = readl(zynq_slcr_base + offset);
-
-	return 0;
+	return regmap_read(zynq_slcr_regmap, offset, val);
 }

 /**
@@ -169,24 +158,6 @@ void zynq_slcr_cpu_stop(int cpu)
 }

 /**
- * zynq_slcr_init - Regular slcr driver init
- *
- * Return:	0 on success, negative errno otherwise.
- *
- * Called early during boot from platform code to remap SLCR area.
- */
-int __init zynq_slcr_init(void)
-{
-	zynq_slcr_regmap = syscon_regmap_lookup_by_compatible("xlnx,zynq-slcr");
-	if (IS_ERR(zynq_slcr_regmap)) {
-		pr_err("%s: failed to find zynq-slcr\n", __func__);
-		return -ENODEV;
-	}
-
-	return 0;
-}
-
-/**
  * zynq_early_slcr_init - Early slcr init function
  *
  * Return:	0 on success, negative errno otherwise.
@@ -202,20 +173,11 @@ int __init zynq_early_slcr_init(void)
 		pr_err("%s: no slcr node found\n", __func__);
 		BUG();
 	}
-
-	zynq_slcr_base = of_iomap(np, 0);
-	if (!zynq_slcr_base) {
-		pr_err("%s: Unable to map I/O memory\n", __func__);
-		BUG();
-	}
-
-	np->data = (__force void *)zynq_slcr_base;
+	zynq_slcr_regmap = syscon_early_regmap_lookup_by_phandle(np, "syscon");

 	/* unlock the SLCR so that registers can be changed */
 	zynq_slcr_unlock();

-	pr_info("%s mapped to %p\n", np->name, zynq_slcr_base);
-
 	of_node_put(np);

 	return 0;
diff --git a/drivers/clk/zynq/clkc.c b/drivers/clk/zynq/clkc.c
index c812b93..b2fd160 100644
--- a/drivers/clk/zynq/clkc.c
+++ b/drivers/clk/zynq/clkc.c
@@ -214,6 +214,10 @@ err:
 		clks[clk1] = ERR_PTR(-ENOMEM);
 }

+struct syscon {
+	void __iomem *base;
+};
+
 static void __init zynq_clk_setup(struct device_node *np)
 {
 	int i;
@@ -227,6 +231,19 @@ static void __init zynq_clk_setup(struct device_node *np)
 	const char *periph_parents[4];
 	const char *swdt_ext_clk_mux_parents[2];
 	const char *can_mio_mux_parents[NUM_MIO_PINS];
+	struct resource res;
+	void __iomem *zynq_slcr_base;
+
+	struct device_node *slcr = of_get_parent(np);
+	struct syscon *syscon = slcr->data;
+	zynq_slcr_base = syscon->base;
+
+	if (of_address_to_resource(np, 0, &res)) {
+		pr_err("%s: failed to get resource\n", np->name);
+		return;
+	}
+
+	zynq_clkc_base = zynq_slcr_base + res.start;

 	pr_info("Zynq clock init\n");

@@ -569,43 +586,3 @@ static void __init zynq_clk_setup(struct device_node *np)
 }

 CLK_OF_DECLARE(zynq_clkc, "xlnx,ps7-clkc", zynq_clk_setup);
-
-void __init zynq_clock_init(void)
-{
-	struct device_node *np;
-	struct device_node *slcr;
-	struct resource res;
-
-	np = of_find_compatible_node(NULL, NULL, "xlnx,ps7-clkc");
-	if (!np) {
-		pr_err("%s: clkc node not found\n", __func__);
-		goto np_err;
-	}
-
-	if (of_address_to_resource(np, 0, &res)) {
-		pr_err("%s: failed to get resource\n", np->name);
-		goto np_err;
-	}
-
-	slcr = of_get_parent(np);
-
-	if (slcr->data) {
-		zynq_clkc_base = (__force void __iomem *)slcr->data + res.start;
-	} else {
-		pr_err("%s: Unable to get I/O memory\n", np->name);
-		of_node_put(slcr);
-		goto np_err;
-	}
-
-	pr_info("%s: clkc starts at %p\n", __func__, zynq_clkc_base);
-
-	of_node_put(slcr);
-	of_node_put(np);
-
-	return;
-
-np_err:
-	of_node_put(np);
-	BUG();
-	return;
-}
--
1.8.2.3


[-- Attachment #2: Type: application/pgp-signature, Size: 198 bytes --]

WARNING: multiple messages have this Message-ID (diff)
From: michal.simek@xilinx.com (Michal Simek)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC PATCH 3/3] ARM: zynq: Use early syscon initialization
Date: Mon, 10 Feb 2014 16:22:35 +0100	[thread overview]
Message-ID: <19fbad8c4c7d655ef73e0c7dd16a045a02a63286.1392045742.git.michal.simek@xilinx.com> (raw)
In-Reply-To: <cover.1392045742.git.michal.simek@xilinx.com>

Use early syscon initialization to simplify slcr code.
- Remove two slcr inits (zynq_slcr_init, zynq_early_slcr_init)
- Directly use regmap accesses in zynq_slcr_read/write
- Remove zynq_clock_init() and use addresses from syscon
  (This is the most problematic part now because clock
  doesn't support regmap accesses that's why reading
  slcr base is ugly. There are some attempts to get
  clk regmap to work - for example:
  https://lkml.org/lkml/2013/10/16/112)

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---

Especially look at slcr.c which is much simpler than was before.
clkc.c will be simpler when regmap support is added because then
syscon_early_regmap_lookup_by_phandle() will be called
without zynq_slcr_base search.

---
 arch/arm/boot/dts/zynq-7000.dtsi |  1 +
 arch/arm/mach-zynq/common.c      |  6 ++---
 arch/arm/mach-zynq/slcr.c        | 42 ++---------------------------
 drivers/clk/zynq/clkc.c          | 57 ++++++++++++----------------------------
 4 files changed, 23 insertions(+), 83 deletions(-)

diff --git a/arch/arm/boot/dts/zynq-7000.dtsi b/arch/arm/boot/dts/zynq-7000.dtsi
index 7284499..e414489 100644
--- a/arch/arm/boot/dts/zynq-7000.dtsi
+++ b/arch/arm/boot/dts/zynq-7000.dtsi
@@ -135,6 +135,7 @@
 			compatible = "xlnx,zynq-slcr", "syscon";
 			reg = <0xF8000000 0x1000>;
 			ranges;
+			syscon = <&slcr>;
 			clkc: clkc at 100 {
 				#clock-cells = <1>;
 				compatible = "xlnx,ps7-clkc";
diff --git a/arch/arm/mach-zynq/common.c b/arch/arm/mach-zynq/common.c
index 9d3c88e..78589e3 100644
--- a/arch/arm/mach-zynq/common.c
+++ b/arch/arm/mach-zynq/common.c
@@ -28,6 +28,7 @@
 #include <linux/of.h>
 #include <linux/irqchip.h>
 #include <linux/irqchip/arm-gic.h>
+#include <linux/mfd/syscon.h>
 #include <linux/slab.h>
 #include <linux/sys_soc.h>

@@ -130,15 +131,14 @@ out:
 	of_platform_populate(NULL, of_default_bus_match_table, NULL, parent);

 	platform_device_register(&zynq_cpuidle_device);
-
-	zynq_slcr_init();
 }

 static void __init zynq_timer_init(void)
 {
+	early_syscon_init();
+
 	zynq_early_slcr_init();

-	zynq_clock_init();
 	of_clk_init(NULL);
 	clocksource_of_init();
 }
diff --git a/arch/arm/mach-zynq/slcr.c b/arch/arm/mach-zynq/slcr.c
index 594b280..a89b082 100644
--- a/arch/arm/mach-zynq/slcr.c
+++ b/arch/arm/mach-zynq/slcr.c
@@ -35,7 +35,6 @@
 #define SLCR_PSS_IDCODE_DEVICE_SHIFT	12
 #define SLCR_PSS_IDCODE_DEVICE_MASK	0x1F

-static void __iomem *zynq_slcr_base;
 static struct regmap *zynq_slcr_regmap;

 /**
@@ -48,11 +47,6 @@ static struct regmap *zynq_slcr_regmap;
  */
 static int zynq_slcr_write(u32 val, u32 offset)
 {
-	if (!zynq_slcr_regmap) {
-		writel(val, zynq_slcr_base + offset);
-		return 0;
-	}
-
 	return regmap_write(zynq_slcr_regmap, offset, val);
 }

@@ -66,12 +60,7 @@ static int zynq_slcr_write(u32 val, u32 offset)
  */
 static int zynq_slcr_read(u32 *val, u32 offset)
 {
-	if (zynq_slcr_regmap)
-		return regmap_read(zynq_slcr_regmap, offset, val);
-
-	*val = readl(zynq_slcr_base + offset);
-
-	return 0;
+	return regmap_read(zynq_slcr_regmap, offset, val);
 }

 /**
@@ -169,24 +158,6 @@ void zynq_slcr_cpu_stop(int cpu)
 }

 /**
- * zynq_slcr_init - Regular slcr driver init
- *
- * Return:	0 on success, negative errno otherwise.
- *
- * Called early during boot from platform code to remap SLCR area.
- */
-int __init zynq_slcr_init(void)
-{
-	zynq_slcr_regmap = syscon_regmap_lookup_by_compatible("xlnx,zynq-slcr");
-	if (IS_ERR(zynq_slcr_regmap)) {
-		pr_err("%s: failed to find zynq-slcr\n", __func__);
-		return -ENODEV;
-	}
-
-	return 0;
-}
-
-/**
  * zynq_early_slcr_init - Early slcr init function
  *
  * Return:	0 on success, negative errno otherwise.
@@ -202,20 +173,11 @@ int __init zynq_early_slcr_init(void)
 		pr_err("%s: no slcr node found\n", __func__);
 		BUG();
 	}
-
-	zynq_slcr_base = of_iomap(np, 0);
-	if (!zynq_slcr_base) {
-		pr_err("%s: Unable to map I/O memory\n", __func__);
-		BUG();
-	}
-
-	np->data = (__force void *)zynq_slcr_base;
+	zynq_slcr_regmap = syscon_early_regmap_lookup_by_phandle(np, "syscon");

 	/* unlock the SLCR so that registers can be changed */
 	zynq_slcr_unlock();

-	pr_info("%s mapped to %p\n", np->name, zynq_slcr_base);
-
 	of_node_put(np);

 	return 0;
diff --git a/drivers/clk/zynq/clkc.c b/drivers/clk/zynq/clkc.c
index c812b93..b2fd160 100644
--- a/drivers/clk/zynq/clkc.c
+++ b/drivers/clk/zynq/clkc.c
@@ -214,6 +214,10 @@ err:
 		clks[clk1] = ERR_PTR(-ENOMEM);
 }

+struct syscon {
+	void __iomem *base;
+};
+
 static void __init zynq_clk_setup(struct device_node *np)
 {
 	int i;
@@ -227,6 +231,19 @@ static void __init zynq_clk_setup(struct device_node *np)
 	const char *periph_parents[4];
 	const char *swdt_ext_clk_mux_parents[2];
 	const char *can_mio_mux_parents[NUM_MIO_PINS];
+	struct resource res;
+	void __iomem *zynq_slcr_base;
+
+	struct device_node *slcr = of_get_parent(np);
+	struct syscon *syscon = slcr->data;
+	zynq_slcr_base = syscon->base;
+
+	if (of_address_to_resource(np, 0, &res)) {
+		pr_err("%s: failed to get resource\n", np->name);
+		return;
+	}
+
+	zynq_clkc_base = zynq_slcr_base + res.start;

 	pr_info("Zynq clock init\n");

@@ -569,43 +586,3 @@ static void __init zynq_clk_setup(struct device_node *np)
 }

 CLK_OF_DECLARE(zynq_clkc, "xlnx,ps7-clkc", zynq_clk_setup);
-
-void __init zynq_clock_init(void)
-{
-	struct device_node *np;
-	struct device_node *slcr;
-	struct resource res;
-
-	np = of_find_compatible_node(NULL, NULL, "xlnx,ps7-clkc");
-	if (!np) {
-		pr_err("%s: clkc node not found\n", __func__);
-		goto np_err;
-	}
-
-	if (of_address_to_resource(np, 0, &res)) {
-		pr_err("%s: failed to get resource\n", np->name);
-		goto np_err;
-	}
-
-	slcr = of_get_parent(np);
-
-	if (slcr->data) {
-		zynq_clkc_base = (__force void __iomem *)slcr->data + res.start;
-	} else {
-		pr_err("%s: Unable to get I/O memory\n", np->name);
-		of_node_put(slcr);
-		goto np_err;
-	}
-
-	pr_info("%s: clkc starts at %p\n", __func__, zynq_clkc_base);
-
-	of_node_put(slcr);
-	of_node_put(np);
-
-	return;
-
-np_err:
-	of_node_put(np);
-	BUG();
-	return;
-}
--
1.8.2.3

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140210/2103137c/attachment.sig>

  parent reply	other threads:[~2014-02-10 15:23 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-10 15:22 [RFC PATCH 0/3] Syscon early initialization Michal Simek
2014-02-10 15:22 ` Michal Simek
2014-02-10 15:22 ` Michal Simek
2014-02-10 15:22 ` [RFC PATCH 1/3] regmap: Separate regmap dev initialization Michal Simek
2014-02-10 15:22   ` Michal Simek
2014-02-16  1:58   ` Mark Brown
2014-02-16  1:58     ` Mark Brown
2014-02-10 15:22 ` [RFC PATCH 2/3] mfd: syscon: Support early initialization Michal Simek
2014-02-10 15:22   ` Michal Simek
2014-02-10 15:42   ` Michal Simek
2014-02-10 15:42     ` Michal Simek
2014-02-12  9:54   ` Lee Jones
2014-02-12  9:54     ` Lee Jones
2014-02-12 10:51     ` Michal Simek
2014-02-12 10:51       ` Michal Simek
2014-02-10 15:22 ` Michal Simek [this message]
2014-02-10 15:22   ` [RFC PATCH 3/3] ARM: zynq: Use early syscon initialization Michal Simek
2014-02-10 15:22   ` Michal Simek

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=19fbad8c4c7d655ef73e0c7dd16a045a02a63286.1392045742.git.michal.simek@xilinx.com \
    --to=michal.simek@xilinx.com \
    --cc=arnd@arndb.de \
    --cc=devicetree@vger.kernel.org \
    --cc=felipensp@gmail.com \
    --cc=galak@codeaurora.org \
    --cc=ijc+devicetree@hellion.org.uk \
    --cc=james.hogan@imgtec.com \
    --cc=josh.cartwright@ni.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=mark.rutland@arm.com \
    --cc=monstr@monstr.eu \
    --cc=mturquette@linaro.org \
    --cc=pawel.moll@arm.com \
    --cc=peter.crosthwaite@xilinx.com \
    --cc=robh+dt@kernel.org \
    --cc=robherring2@gmail.com \
    --cc=s.trumtrar@pengutronix.de \
    --cc=sboyd@codeaurora.org \
    --cc=soren.brinkmann@xilinx.com \
    --cc=swarren@nvidia.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 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.