* [PATCH 0/7] Xilinx Zynq SLCR changes
@ 2014-01-06 14:36 Michal Simek
2014-01-06 14:36 ` [PATCH 1/7] ARM: zynq: Move clock_init from slcr to common Michal Simek
` (6 more replies)
0 siblings, 7 replies; 10+ messages in thread
From: Michal Simek @ 2014-01-06 14:36 UTC (permalink / raw)
To: linux-arm-kernel
Hi,
I have rebased and added together patches I have got from Steffen some time ago.
Steffen: I kept there your SoB. Please let me know if there is any problem
with it.
The point of this series is to use slcr as system controller
to be able to create other drivers like pinmux, etc.
These patches are based on zynq/cleanup and zynq/dt branches merged
together. (They are available in arm-soc git tree).
Let me know if you want to add the branch somewhere.
Arnd: We talked at KS about syscon early initialization which
will be really helpful for this case. Has someone done any work
around it?
Thanks,
Michal
Michal Simek (4):
ARM: zynq: Split slcr in two parts
ARM: zynq: Map I/O memory on clkc init
ARM: zynq: Add and use zynq_slcr_read/write() helper functions
ARM: zynq: Introduce zynq_slcr_unlock()
Steffen Trumtrar (3):
ARM: zynq: Move clock_init from slcr to common
ARM: zynq: Hang iomapped slcr address on device_node
ARM: zynq: Make zynq_slcr_base static
.../devicetree/bindings/clock/zynq-7000.txt | 4 +-
arch/arm/boot/dts/zynq-7000.dtsi | 42 +++++-----
arch/arm/mach-zynq/Kconfig | 1 +
arch/arm/mach-zynq/common.c | 6 +-
arch/arm/mach-zynq/common.h | 2 +-
arch/arm/mach-zynq/slcr.c | 98 +++++++++++++++++++---
drivers/clk/zynq/clkc.c | 89 ++++++++++++++------
include/linux/clk/zynq.h | 2 +-
8 files changed, 179 insertions(+), 65 deletions(-)
--
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/20140106/9c62af17/attachment.sig>
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 1/7] ARM: zynq: Move clock_init from slcr to common
2014-01-06 14:36 [PATCH 0/7] Xilinx Zynq SLCR changes Michal Simek
@ 2014-01-06 14:36 ` Michal Simek
2014-01-06 14:36 ` [PATCH 2/7] ARM: zynq: Split slcr in two parts Michal Simek
` (5 subsequent siblings)
6 siblings, 0 replies; 10+ messages in thread
From: Michal Simek @ 2014-01-06 14:36 UTC (permalink / raw)
To: linux-arm-kernel
From: Steffen Trumtrar <s.trumtrar@pengutronix.de>
Preparation step for next changes.
Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---
arch/arm/mach-zynq/common.c | 2 ++
arch/arm/mach-zynq/slcr.c | 2 --
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/arm/mach-zynq/common.c b/arch/arm/mach-zynq/common.c
index 1db2a5ca..bf6717f 100644
--- a/arch/arm/mach-zynq/common.c
+++ b/arch/arm/mach-zynq/common.c
@@ -64,6 +64,8 @@ static void __init zynq_init_machine(void)
static void __init zynq_timer_init(void)
{
zynq_slcr_init();
+
+ zynq_clock_init(zynq_slcr_base);
clocksource_of_init();
}
diff --git a/arch/arm/mach-zynq/slcr.c b/arch/arm/mach-zynq/slcr.c
index 1836d5a..59ad09f 100644
--- a/arch/arm/mach-zynq/slcr.c
+++ b/arch/arm/mach-zynq/slcr.c
@@ -106,8 +106,6 @@ int __init zynq_slcr_init(void)
pr_info("%s mapped to %p\n", np->name, zynq_slcr_base);
- zynq_clock_init(zynq_slcr_base);
-
of_node_put(np);
return 0;
--
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/20140106/8d79f305/attachment.sig>
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 2/7] ARM: zynq: Split slcr in two parts
2014-01-06 14:36 [PATCH 0/7] Xilinx Zynq SLCR changes Michal Simek
2014-01-06 14:36 ` [PATCH 1/7] ARM: zynq: Move clock_init from slcr to common Michal Simek
@ 2014-01-06 14:36 ` Michal Simek
2014-01-06 14:36 ` [PATCH 3/7] ARM: zynq: Hang iomapped slcr address on device_node Michal Simek
` (4 subsequent siblings)
6 siblings, 0 replies; 10+ messages in thread
From: Michal Simek @ 2014-01-06 14:36 UTC (permalink / raw)
To: linux-arm-kernel
Split the slcr into an early part for unlocking and cpu starting
and a later syscon driver.
Also add "syscon" compatible property for slcr.
Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---
arch/arm/boot/dts/zynq-7000.dtsi | 2 +-
arch/arm/mach-zynq/Kconfig | 1 +
arch/arm/mach-zynq/common.c | 4 +++-
arch/arm/mach-zynq/common.h | 1 +
arch/arm/mach-zynq/slcr.c | 20 ++++++++++++++++++++
5 files changed, 26 insertions(+), 2 deletions(-)
diff --git a/arch/arm/boot/dts/zynq-7000.dtsi b/arch/arm/boot/dts/zynq-7000.dtsi
index 93d1980..81e5677 100644
--- a/arch/arm/boot/dts/zynq-7000.dtsi
+++ b/arch/arm/boot/dts/zynq-7000.dtsi
@@ -123,7 +123,7 @@
} ;
slcr: slcr at f8000000 {
- compatible = "xlnx,zynq-slcr";
+ compatible = "xlnx,zynq-slcr", "syscon";
reg = <0xF8000000 0x1000>;
clocks {
diff --git a/arch/arm/mach-zynq/Kconfig b/arch/arm/mach-zynq/Kconfig
index 6b04260..323e505 100644
--- a/arch/arm/mach-zynq/Kconfig
+++ b/arch/arm/mach-zynq/Kconfig
@@ -14,5 +14,6 @@ config ARCH_ZYNQ
select SPARSE_IRQ
select CADENCE_TTC_TIMER
select ARM_GLOBAL_TIMER
+ select MFD_SYSCON
help
Support for Xilinx Zynq ARM Cortex A9 Platform
diff --git a/arch/arm/mach-zynq/common.c b/arch/arm/mach-zynq/common.c
index bf6717f..38401cf 100644
--- a/arch/arm/mach-zynq/common.c
+++ b/arch/arm/mach-zynq/common.c
@@ -59,11 +59,13 @@ static void __init zynq_init_machine(void)
of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
platform_device_register(&zynq_cpuidle_device);
+
+ zynq_slcr_init();
}
static void __init zynq_timer_init(void)
{
- zynq_slcr_init();
+ zynq_early_slcr_init();
zynq_clock_init(zynq_slcr_base);
clocksource_of_init();
diff --git a/arch/arm/mach-zynq/common.h b/arch/arm/mach-zynq/common.h
index c22c92c..1548b85 100644
--- a/arch/arm/mach-zynq/common.h
+++ b/arch/arm/mach-zynq/common.h
@@ -20,6 +20,7 @@
void zynq_secondary_startup(void);
extern int zynq_slcr_init(void);
+extern int zynq_early_slcr_init(void);
extern void zynq_slcr_system_reset(void);
extern void zynq_slcr_cpu_stop(int cpu);
extern void zynq_slcr_cpu_start(int cpu);
diff --git a/arch/arm/mach-zynq/slcr.c b/arch/arm/mach-zynq/slcr.c
index 59ad09f..9746de7 100644
--- a/arch/arm/mach-zynq/slcr.c
+++ b/arch/arm/mach-zynq/slcr.c
@@ -15,7 +15,9 @@
*/
#include <linux/io.h>
+#include <linux/mfd/syscon.h>
#include <linux/of_address.h>
+#include <linux/regmap.h>
#include <linux/clk/zynq.h>
#include "common.h"
@@ -30,6 +32,7 @@
#define SLCR_A9_CPU_RST 0x1
void __iomem *zynq_slcr_base;
+static struct regmap *zynq_slcr_regmap;
/**
* zynq_slcr_system_reset - Reset the entire system.
@@ -87,6 +90,23 @@ void zynq_slcr_cpu_stop(int cpu)
*/
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
+ * Returns 0 on success, negative errno otherwise.
+ *
+ * Called very early during boot from platform code to unlock SLCR.
+ */
+int __init zynq_early_slcr_init(void)
+{
struct device_node *np;
np = of_find_compatible_node(NULL, NULL, "xlnx,zynq-slcr");
--
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/20140106/963a3065/attachment.sig>
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 3/7] ARM: zynq: Hang iomapped slcr address on device_node
2014-01-06 14:36 [PATCH 0/7] Xilinx Zynq SLCR changes Michal Simek
2014-01-06 14:36 ` [PATCH 1/7] ARM: zynq: Move clock_init from slcr to common Michal Simek
2014-01-06 14:36 ` [PATCH 2/7] ARM: zynq: Split slcr in two parts Michal Simek
@ 2014-01-06 14:36 ` Michal Simek
2014-03-11 21:26 ` Olof Johansson
2014-01-06 14:36 ` [PATCH 4/7] ARM: zynq: Map I/O memory on clkc init Michal Simek
` (3 subsequent siblings)
6 siblings, 1 reply; 10+ messages in thread
From: Michal Simek @ 2014-01-06 14:36 UTC (permalink / raw)
To: linux-arm-kernel
From: Steffen Trumtrar <s.trumtrar@pengutronix.de>
For later usage by zynq clk driver.
Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---
arch/arm/mach-zynq/slcr.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/arch/arm/mach-zynq/slcr.c b/arch/arm/mach-zynq/slcr.c
index 9746de7..2891dcf 100644
--- a/arch/arm/mach-zynq/slcr.c
+++ b/arch/arm/mach-zynq/slcr.c
@@ -121,6 +121,8 @@ int __init zynq_early_slcr_init(void)
BUG();
}
+ np->data = (__force void *)zynq_slcr_base;
+
/* unlock the SLCR so that registers can be changed */
writel(SLCR_UNLOCK_MAGIC, zynq_slcr_base + SLCR_UNLOCK_OFFSET);
--
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/20140106/acca4a1d/attachment.sig>
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 4/7] ARM: zynq: Map I/O memory on clkc init
2014-01-06 14:36 [PATCH 0/7] Xilinx Zynq SLCR changes Michal Simek
` (2 preceding siblings ...)
2014-01-06 14:36 ` [PATCH 3/7] ARM: zynq: Hang iomapped slcr address on device_node Michal Simek
@ 2014-01-06 14:36 ` Michal Simek
2014-01-06 14:36 ` [PATCH 5/7] ARM: zynq: Make zynq_slcr_base static Michal Simek
` (2 subsequent siblings)
6 siblings, 0 replies; 10+ messages in thread
From: Michal Simek @ 2014-01-06 14:36 UTC (permalink / raw)
To: linux-arm-kernel
The clkc has its registers in the range of the slcr.
Instead of passing around the slcr base address pointer, let the clkc get the
address from the DT.
This prepares the slcr to be a real driver with multiple memory ranges
(slcr, clocks, pinctrl,...)
Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---
.../devicetree/bindings/clock/zynq-7000.txt | 4 +-
arch/arm/boot/dts/zynq-7000.dtsi | 40 +++++-----
arch/arm/mach-zynq/common.c | 2 +-
drivers/clk/zynq/clkc.c | 89 +++++++++++++++-------
include/linux/clk/zynq.h | 2 +-
5 files changed, 87 insertions(+), 50 deletions(-)
diff --git a/Documentation/devicetree/bindings/clock/zynq-7000.txt b/Documentation/devicetree/bindings/clock/zynq-7000.txt
index d99af87..401e26a 100644
--- a/Documentation/devicetree/bindings/clock/zynq-7000.txt
+++ b/Documentation/devicetree/bindings/clock/zynq-7000.txt
@@ -14,6 +14,7 @@ for all clock consumers of PS clocks.
Required properties:
- #clock-cells : Must be 1
- compatible : "xlnx,ps7-clkc"
+ - reg : SLCR offset and size taken via syscon < 0x100 0x100 >
- ps-clk-frequency : Frequency of the oscillator providing ps_clk in HZ
(usually 33 MHz oscillators are used for Zynq platforms)
- clock-output-names : List of strings used to name the clock outputs. Shall be
@@ -83,10 +84,11 @@ Clock outputs:
47: dbg_apb
Example:
- clkc: clkc {
+ clkc: clkc at 100 {
#clock-cells = <1>;
compatible = "xlnx,ps7-clkc";
ps-clk-frequency = <33333333>;
+ reg = <0x100 0x100>;
clock-output-names = "armpll", "ddrpll", "iopll", "cpu_6or4x",
"cpu_3or2x", "cpu_2x", "cpu_1x", "ddr2x", "ddr3x",
"dci", "lqspi", "smc", "pcap", "gem0", "gem1",
diff --git a/arch/arm/boot/dts/zynq-7000.dtsi b/arch/arm/boot/dts/zynq-7000.dtsi
index 81e5677..1d942e2 100644
--- a/arch/arm/boot/dts/zynq-7000.dtsi
+++ b/arch/arm/boot/dts/zynq-7000.dtsi
@@ -123,30 +123,28 @@
} ;
slcr: slcr at f8000000 {
+ #address-cells = <1>;
+ #size-cells = <1>;
compatible = "xlnx,zynq-slcr", "syscon";
reg = <0xF8000000 0x1000>;
- clocks {
- #address-cells = <1>;
- #size-cells = <0>;
-
- clkc: clkc {
- #clock-cells = <1>;
- compatible = "xlnx,ps7-clkc";
- ps-clk-frequency = <33333333>;
- fclk-enable = <0>;
- clock-output-names = "armpll", "ddrpll", "iopll", "cpu_6or4x",
- "cpu_3or2x", "cpu_2x", "cpu_1x", "ddr2x", "ddr3x",
- "dci", "lqspi", "smc", "pcap", "gem0", "gem1",
- "fclk0", "fclk1", "fclk2", "fclk3", "can0", "can1",
- "sdio0", "sdio1", "uart0", "uart1", "spi0", "spi1",
- "dma", "usb0_aper", "usb1_aper", "gem0_aper",
- "gem1_aper", "sdio0_aper", "sdio1_aper",
- "spi0_aper", "spi1_aper", "can0_aper", "can1_aper",
- "i2c0_aper", "i2c1_aper", "uart0_aper", "uart1_aper",
- "gpio_aper", "lqspi_aper", "smc_aper", "swdt",
- "dbg_trc", "dbg_apb";
- };
+ clkc: clkc at 100 {
+ #clock-cells = <1>;
+ compatible = "xlnx,ps7-clkc";
+ ps-clk-frequency = <33333333>;
+ fclk-enable = <0>;
+ clock-output-names = "armpll", "ddrpll", "iopll", "cpu_6or4x",
+ "cpu_3or2x", "cpu_2x", "cpu_1x", "ddr2x", "ddr3x",
+ "dci", "lqspi", "smc", "pcap", "gem0", "gem1",
+ "fclk0", "fclk1", "fclk2", "fclk3", "can0", "can1",
+ "sdio0", "sdio1", "uart0", "uart1", "spi0", "spi1",
+ "dma", "usb0_aper", "usb1_aper", "gem0_aper",
+ "gem1_aper", "sdio0_aper", "sdio1_aper",
+ "spi0_aper", "spi1_aper", "can0_aper", "can1_aper",
+ "i2c0_aper", "i2c1_aper", "uart0_aper", "uart1_aper",
+ "gpio_aper", "lqspi_aper", "smc_aper", "swdt",
+ "dbg_trc", "dbg_apb";
+ reg = <0x100 0x100>;
};
};
diff --git a/arch/arm/mach-zynq/common.c b/arch/arm/mach-zynq/common.c
index 38401cf..93ea19b 100644
--- a/arch/arm/mach-zynq/common.c
+++ b/arch/arm/mach-zynq/common.c
@@ -67,7 +67,7 @@ static void __init zynq_timer_init(void)
{
zynq_early_slcr_init();
- zynq_clock_init(zynq_slcr_base);
+ zynq_clock_init();
clocksource_of_init();
}
diff --git a/drivers/clk/zynq/clkc.c b/drivers/clk/zynq/clkc.c
index 10772aa..088b8fb 100644
--- a/drivers/clk/zynq/clkc.c
+++ b/drivers/clk/zynq/clkc.c
@@ -21,34 +21,35 @@
#include <linux/clk/zynq.h>
#include <linux/clk-provider.h>
#include <linux/of.h>
+#include <linux/of_address.h>
#include <linux/slab.h>
#include <linux/string.h>
#include <linux/io.h>
-static void __iomem *zynq_slcr_base_priv;
-
-#define SLCR_ARMPLL_CTRL (zynq_slcr_base_priv + 0x100)
-#define SLCR_DDRPLL_CTRL (zynq_slcr_base_priv + 0x104)
-#define SLCR_IOPLL_CTRL (zynq_slcr_base_priv + 0x108)
-#define SLCR_PLL_STATUS (zynq_slcr_base_priv + 0x10c)
-#define SLCR_ARM_CLK_CTRL (zynq_slcr_base_priv + 0x120)
-#define SLCR_DDR_CLK_CTRL (zynq_slcr_base_priv + 0x124)
-#define SLCR_DCI_CLK_CTRL (zynq_slcr_base_priv + 0x128)
-#define SLCR_APER_CLK_CTRL (zynq_slcr_base_priv + 0x12c)
-#define SLCR_GEM0_CLK_CTRL (zynq_slcr_base_priv + 0x140)
-#define SLCR_GEM1_CLK_CTRL (zynq_slcr_base_priv + 0x144)
-#define SLCR_SMC_CLK_CTRL (zynq_slcr_base_priv + 0x148)
-#define SLCR_LQSPI_CLK_CTRL (zynq_slcr_base_priv + 0x14c)
-#define SLCR_SDIO_CLK_CTRL (zynq_slcr_base_priv + 0x150)
-#define SLCR_UART_CLK_CTRL (zynq_slcr_base_priv + 0x154)
-#define SLCR_SPI_CLK_CTRL (zynq_slcr_base_priv + 0x158)
-#define SLCR_CAN_CLK_CTRL (zynq_slcr_base_priv + 0x15c)
-#define SLCR_CAN_MIOCLK_CTRL (zynq_slcr_base_priv + 0x160)
-#define SLCR_DBG_CLK_CTRL (zynq_slcr_base_priv + 0x164)
-#define SLCR_PCAP_CLK_CTRL (zynq_slcr_base_priv + 0x168)
-#define SLCR_FPGA0_CLK_CTRL (zynq_slcr_base_priv + 0x170)
-#define SLCR_621_TRUE (zynq_slcr_base_priv + 0x1c4)
-#define SLCR_SWDT_CLK_SEL (zynq_slcr_base_priv + 0x304)
+static void __iomem *zynq_clkc_base;
+
+#define SLCR_ARMPLL_CTRL (zynq_clkc_base + 0x00)
+#define SLCR_DDRPLL_CTRL (zynq_clkc_base + 0x04)
+#define SLCR_IOPLL_CTRL (zynq_clkc_base + 0x08)
+#define SLCR_PLL_STATUS (zynq_clkc_base + 0x0c)
+#define SLCR_ARM_CLK_CTRL (zynq_clkc_base + 0x20)
+#define SLCR_DDR_CLK_CTRL (zynq_clkc_base + 0x24)
+#define SLCR_DCI_CLK_CTRL (zynq_clkc_base + 0x28)
+#define SLCR_APER_CLK_CTRL (zynq_clkc_base + 0x2c)
+#define SLCR_GEM0_CLK_CTRL (zynq_clkc_base + 0x40)
+#define SLCR_GEM1_CLK_CTRL (zynq_clkc_base + 0x44)
+#define SLCR_SMC_CLK_CTRL (zynq_clkc_base + 0x48)
+#define SLCR_LQSPI_CLK_CTRL (zynq_clkc_base + 0x4c)
+#define SLCR_SDIO_CLK_CTRL (zynq_clkc_base + 0x50)
+#define SLCR_UART_CLK_CTRL (zynq_clkc_base + 0x54)
+#define SLCR_SPI_CLK_CTRL (zynq_clkc_base + 0x58)
+#define SLCR_CAN_CLK_CTRL (zynq_clkc_base + 0x5c)
+#define SLCR_CAN_MIOCLK_CTRL (zynq_clkc_base + 0x60)
+#define SLCR_DBG_CLK_CTRL (zynq_clkc_base + 0x64)
+#define SLCR_PCAP_CLK_CTRL (zynq_clkc_base + 0x68)
+#define SLCR_FPGA0_CLK_CTRL (zynq_clkc_base + 0x70)
+#define SLCR_621_TRUE (zynq_clkc_base + 0xc4)
+#define SLCR_SWDT_CLK_SEL (zynq_clkc_base + 0x204)
#define NUM_MIO_PINS 54
@@ -557,8 +558,44 @@ 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 __iomem *slcr_base)
+void __init zynq_clock_init(void)
{
- zynq_slcr_base_priv = slcr_base;
+ 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 = (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);
+
of_clk_init(NULL);
+
+ return;
+
+np_err:
+ of_node_put(np);
+ BUG();
+ return;
}
diff --git a/include/linux/clk/zynq.h b/include/linux/clk/zynq.h
index e062d31..7a5633b 100644
--- a/include/linux/clk/zynq.h
+++ b/include/linux/clk/zynq.h
@@ -22,7 +22,7 @@
#include <linux/spinlock.h>
-void zynq_clock_init(void __iomem *slcr);
+void zynq_clock_init(void);
struct clk *clk_register_zynq_pll(const char *name, const char *parent,
void __iomem *pll_ctrl, void __iomem *pll_status, u8 lock_index,
--
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/20140106/bace6ff1/attachment-0001.sig>
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 5/7] ARM: zynq: Make zynq_slcr_base static
2014-01-06 14:36 [PATCH 0/7] Xilinx Zynq SLCR changes Michal Simek
` (3 preceding siblings ...)
2014-01-06 14:36 ` [PATCH 4/7] ARM: zynq: Map I/O memory on clkc init Michal Simek
@ 2014-01-06 14:36 ` Michal Simek
2014-01-06 14:36 ` [PATCH 6/7] ARM: zynq: Add and use zynq_slcr_read/write() helper functions Michal Simek
2014-01-06 14:36 ` [PATCH 7/7] ARM: zynq: Introduce zynq_slcr_unlock() Michal Simek
6 siblings, 0 replies; 10+ messages in thread
From: Michal Simek @ 2014-01-06 14:36 UTC (permalink / raw)
To: linux-arm-kernel
From: Steffen Trumtrar <s.trumtrar@pengutronix.de>
The pointer doesn't need to be passed around any more.
Make it static.
Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---
arch/arm/mach-zynq/common.h | 1 -
arch/arm/mach-zynq/slcr.c | 2 +-
2 files changed, 1 insertion(+), 2 deletions(-)
diff --git a/arch/arm/mach-zynq/common.h b/arch/arm/mach-zynq/common.h
index 1548b85..b097844 100644
--- a/arch/arm/mach-zynq/common.h
+++ b/arch/arm/mach-zynq/common.h
@@ -34,7 +34,6 @@ extern int zynq_cpun_start(u32 address, int cpu);
extern struct smp_operations zynq_smp_ops __initdata;
#endif
-extern void __iomem *zynq_slcr_base;
extern void __iomem *zynq_scu_base;
/* Hotplug */
diff --git a/arch/arm/mach-zynq/slcr.c b/arch/arm/mach-zynq/slcr.c
index 2891dcf..a679dff 100644
--- a/arch/arm/mach-zynq/slcr.c
+++ b/arch/arm/mach-zynq/slcr.c
@@ -31,7 +31,7 @@
#define SLCR_A9_CPU_CLKSTOP 0x10
#define SLCR_A9_CPU_RST 0x1
-void __iomem *zynq_slcr_base;
+static void __iomem *zynq_slcr_base;
static struct regmap *zynq_slcr_regmap;
/**
--
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/20140106/efdfb039/attachment.sig>
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 6/7] ARM: zynq: Add and use zynq_slcr_read/write() helper functions
2014-01-06 14:36 [PATCH 0/7] Xilinx Zynq SLCR changes Michal Simek
` (4 preceding siblings ...)
2014-01-06 14:36 ` [PATCH 5/7] ARM: zynq: Make zynq_slcr_base static Michal Simek
@ 2014-01-06 14:36 ` Michal Simek
2014-01-06 14:36 ` [PATCH 7/7] ARM: zynq: Introduce zynq_slcr_unlock() Michal Simek
6 siblings, 0 replies; 10+ messages in thread
From: Michal Simek @ 2014-01-06 14:36 UTC (permalink / raw)
To: linux-arm-kernel
Use zynq_slcr_read/write helper functions for reg access
instead of readl/writel.
Also use regmap when it is ready.
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---
arch/arm/mach-zynq/slcr.c | 56 ++++++++++++++++++++++++++++++++++++++++-------
1 file changed, 48 insertions(+), 8 deletions(-)
diff --git a/arch/arm/mach-zynq/slcr.c b/arch/arm/mach-zynq/slcr.c
index a679dff..f0f6a69 100644
--- a/arch/arm/mach-zynq/slcr.c
+++ b/arch/arm/mach-zynq/slcr.c
@@ -35,6 +35,42 @@ static void __iomem *zynq_slcr_base;
static struct regmap *zynq_slcr_regmap;
/**
+ * zynq_slcr_write - Write to a register in SLCR block
+ *
+ * @val: Value to write to the register
+ * @offset: Register offset in SLCR block
+ *
+ * return: a negative value on error, 0 on success
+ */
+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);
+}
+
+/**
+ * zynq_slcr_read - Read a register in SLCR block
+ *
+ * @val: Pointer to value to be read from SLCR
+ * @offset: Register offset in SLCR block
+ *
+ * return: a negative value on error, 0 on success
+ */
+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;
+}
+
+/**
* zynq_slcr_system_reset - Reset the entire system.
*/
void zynq_slcr_system_reset(void)
@@ -53,9 +89,9 @@ void zynq_slcr_system_reset(void)
* the FSBL not loading the bitstream after soft-reboot
* This is a temporary solution until we know more.
*/
- reboot = readl(zynq_slcr_base + SLCR_REBOOT_STATUS_OFFSET);
- writel(reboot & 0xF0FFFFFF, zynq_slcr_base + SLCR_REBOOT_STATUS_OFFSET);
- writel(1, zynq_slcr_base + SLCR_PS_RST_CTRL_OFFSET);
+ zynq_slcr_read(&reboot, SLCR_REBOOT_STATUS_OFFSET);
+ zynq_slcr_write(reboot & 0xF0FFFFFF, SLCR_REBOOT_STATUS_OFFSET);
+ zynq_slcr_write(1, SLCR_PS_RST_CTRL_OFFSET);
}
/**
@@ -64,11 +100,13 @@ void zynq_slcr_system_reset(void)
*/
void zynq_slcr_cpu_start(int cpu)
{
- u32 reg = readl(zynq_slcr_base + SLCR_A9_CPU_RST_CTRL_OFFSET);
+ u32 reg;
+
+ zynq_slcr_read(®, SLCR_A9_CPU_RST_CTRL_OFFSET);
reg &= ~(SLCR_A9_CPU_RST << cpu);
- writel(reg, zynq_slcr_base + SLCR_A9_CPU_RST_CTRL_OFFSET);
+ zynq_slcr_write(reg, SLCR_A9_CPU_RST_CTRL_OFFSET);
reg &= ~(SLCR_A9_CPU_CLKSTOP << cpu);
- writel(reg, zynq_slcr_base + SLCR_A9_CPU_RST_CTRL_OFFSET);
+ zynq_slcr_write(reg, SLCR_A9_CPU_RST_CTRL_OFFSET);
}
/**
@@ -77,9 +115,11 @@ void zynq_slcr_cpu_start(int cpu)
*/
void zynq_slcr_cpu_stop(int cpu)
{
- u32 reg = readl(zynq_slcr_base + SLCR_A9_CPU_RST_CTRL_OFFSET);
+ u32 reg;
+
+ zynq_slcr_read(®, SLCR_A9_CPU_RST_CTRL_OFFSET);
reg |= (SLCR_A9_CPU_CLKSTOP | SLCR_A9_CPU_RST) << cpu;
- writel(reg, zynq_slcr_base + SLCR_A9_CPU_RST_CTRL_OFFSET);
+ zynq_slcr_write(reg, SLCR_A9_CPU_RST_CTRL_OFFSET);
}
/**
--
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/20140106/45056c3f/attachment.sig>
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 7/7] ARM: zynq: Introduce zynq_slcr_unlock()
2014-01-06 14:36 [PATCH 0/7] Xilinx Zynq SLCR changes Michal Simek
` (5 preceding siblings ...)
2014-01-06 14:36 ` [PATCH 6/7] ARM: zynq: Add and use zynq_slcr_read/write() helper functions Michal Simek
@ 2014-01-06 14:36 ` Michal Simek
6 siblings, 0 replies; 10+ messages in thread
From: Michal Simek @ 2014-01-06 14:36 UTC (permalink / raw)
To: linux-arm-kernel
Call special function for unlocking SLCR.
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---
arch/arm/mach-zynq/slcr.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/arch/arm/mach-zynq/slcr.c b/arch/arm/mach-zynq/slcr.c
index f0f6a69..c1f1499 100644
--- a/arch/arm/mach-zynq/slcr.c
+++ b/arch/arm/mach-zynq/slcr.c
@@ -71,6 +71,18 @@ static int zynq_slcr_read(u32 *val, u32 offset)
}
/**
+ * zynq_slcr_unlock - Unlock SLCR registers
+ *
+ * return: a negative value on error, 0 on success
+ */
+static inline int zynq_slcr_unlock(void)
+{
+ zynq_slcr_write(SLCR_UNLOCK_MAGIC, SLCR_UNLOCK_OFFSET);
+
+ return 0;
+}
+
+/**
* zynq_slcr_system_reset - Reset the entire system.
*/
void zynq_slcr_system_reset(void)
@@ -82,7 +94,7 @@ void zynq_slcr_system_reset(void)
* Note that this seems to require raw i/o
* functions or there's a lockup?
*/
- writel(SLCR_UNLOCK_MAGIC, zynq_slcr_base + SLCR_UNLOCK_OFFSET);
+ zynq_slcr_unlock();
/*
* Clear 0x0F000000 bits of reboot status register to workaround
@@ -164,7 +176,7 @@ int __init zynq_early_slcr_init(void)
np->data = (__force void *)zynq_slcr_base;
/* unlock the SLCR so that registers can be changed */
- writel(SLCR_UNLOCK_MAGIC, zynq_slcr_base + SLCR_UNLOCK_OFFSET);
+ zynq_slcr_unlock();
pr_info("%s mapped to %p\n", np->name, zynq_slcr_base);
--
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/20140106/38ae2957/attachment.sig>
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 3/7] ARM: zynq: Hang iomapped slcr address on device_node
2014-01-06 14:36 ` [PATCH 3/7] ARM: zynq: Hang iomapped slcr address on device_node Michal Simek
@ 2014-03-11 21:26 ` Olof Johansson
2014-03-12 11:51 ` Michal Simek
0 siblings, 1 reply; 10+ messages in thread
From: Olof Johansson @ 2014-03-11 21:26 UTC (permalink / raw)
To: linux-arm-kernel
On Mon, Jan 6, 2014 at 6:36 AM, Michal Simek <michal.simek@xilinx.com> wrote:
> From: Steffen Trumtrar <s.trumtrar@pengutronix.de>
>
> For later usage by zynq clk driver.
>
> Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
> ---
> arch/arm/mach-zynq/slcr.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/arch/arm/mach-zynq/slcr.c b/arch/arm/mach-zynq/slcr.c
> index 9746de7..2891dcf 100644
> --- a/arch/arm/mach-zynq/slcr.c
> +++ b/arch/arm/mach-zynq/slcr.c
> @@ -121,6 +121,8 @@ int __init zynq_early_slcr_init(void)
> BUG();
> }
>
> + np->data = (__force void *)zynq_slcr_base;
This is quite unusual, we normally remap again if needed. Is there a
reason you can't just have the driver request the resource and map it
like most other ones do?
-Olof
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 3/7] ARM: zynq: Hang iomapped slcr address on device_node
2014-03-11 21:26 ` Olof Johansson
@ 2014-03-12 11:51 ` Michal Simek
0 siblings, 0 replies; 10+ messages in thread
From: Michal Simek @ 2014-03-12 11:51 UTC (permalink / raw)
To: linux-arm-kernel
On 03/11/2014 10:26 PM, Olof Johansson wrote:
> On Mon, Jan 6, 2014 at 6:36 AM, Michal Simek <michal.simek@xilinx.com> wrote:
>> From: Steffen Trumtrar <s.trumtrar@pengutronix.de>
>>
>> For later usage by zynq clk driver.
>>
>> Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
>> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
>> ---
>> arch/arm/mach-zynq/slcr.c | 2 ++
>> 1 file changed, 2 insertions(+)
>>
>> diff --git a/arch/arm/mach-zynq/slcr.c b/arch/arm/mach-zynq/slcr.c
>> index 9746de7..2891dcf 100644
>> --- a/arch/arm/mach-zynq/slcr.c
>> +++ b/arch/arm/mach-zynq/slcr.c
>> @@ -121,6 +121,8 @@ int __init zynq_early_slcr_init(void)
>> BUG();
>> }
>>
>> + np->data = (__force void *)zynq_slcr_base;
>
>
> This is quite unusual, we normally remap again if needed. Is there a
> reason you can't just have the driver request the resource and map it
> like most other ones do?
I took this patch from Steffen because remapping slcr again in clock
driver is another mapping for the same IP. Use one ioremap region
seems to me better if there is a way. Of course if this is strictly
prohibited we can do another mapping in clock driver.
Here is the RFC I have sent after my discussion with Arnd
that we should use early syscon initialization and regmap.
This is just RFC to show slcr cleaning up.
http://permalink.gmane.org/gmane.linux.kernel/1651213
(Here is broken CLK part because clk subsystem uses clk_readl/clk_writel
- changing this is discussed in other threads)
>From v1 - regmap device separation was applied by Mark
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap.git tags/nodev
>From v2 - "mfd: syscon: Support early initialization"
I expected to get any comment from Arnd but I will respin this
based on Lee's comments
To summarize this for future I would like to use access with regmap
with one ioremap.
Thanks,
Michal
--
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel - Microblaze cpu - http://www.monstr.eu/fdt/
Maintainer of Linux kernel - Xilinx Zynq ARM architecture
Microblaze U-BOOT custodian and responsible for u-boot arm zynq platform
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 263 bytes
Desc: OpenPGP digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140312/f612458f/attachment.sig>
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2014-03-12 11:51 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-06 14:36 [PATCH 0/7] Xilinx Zynq SLCR changes Michal Simek
2014-01-06 14:36 ` [PATCH 1/7] ARM: zynq: Move clock_init from slcr to common Michal Simek
2014-01-06 14:36 ` [PATCH 2/7] ARM: zynq: Split slcr in two parts Michal Simek
2014-01-06 14:36 ` [PATCH 3/7] ARM: zynq: Hang iomapped slcr address on device_node Michal Simek
2014-03-11 21:26 ` Olof Johansson
2014-03-12 11:51 ` Michal Simek
2014-01-06 14:36 ` [PATCH 4/7] ARM: zynq: Map I/O memory on clkc init Michal Simek
2014-01-06 14:36 ` [PATCH 5/7] ARM: zynq: Make zynq_slcr_base static Michal Simek
2014-01-06 14:36 ` [PATCH 6/7] ARM: zynq: Add and use zynq_slcr_read/write() helper functions Michal Simek
2014-01-06 14:36 ` [PATCH 7/7] ARM: zynq: Introduce zynq_slcr_unlock() Michal Simek
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).