Skip to content

Commit b0504e3

Browse files
author
Michal Simek
committed
ARM: zynq: Map I/O memory on clkc init
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>
1 parent 5e21828 commit b0504e3

5 files changed

Lines changed: 88 additions & 51 deletions

File tree

‎Documentation/devicetree/bindings/clock/zynq-7000.txt‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ for all clock consumers of PS clocks.
1414
Required properties:
1515
- #clock-cells : Must be 1
1616
- compatible : "xlnx,ps7-clkc"
17+
- reg : SLCR offset and size taken via syscon < 0x100 0x100 >
1718
- ps-clk-frequency : Frequency of the oscillator providing ps_clk in HZ
1819
(usually 33 MHz oscillators are used for Zynq platforms)
1920
- clock-output-names : List of strings used to name the clock outputs. Shall be
@@ -87,10 +88,11 @@ Clock outputs:
8788
47: dbg_apb
8889

8990
Example:
90-
clkc: clkc {
91+
clkc: clkc@100 {
9192
#clock-cells = <1>;
9293
compatible = "xlnx,ps7-clkc";
9394
ps-clk-frequency = <33333333>;
95+
reg = <0x100 0x100>;
9496
clock-output-names = "armpll", "ddrpll", "iopll", "cpu_6or4x",
9597
"cpu_3or2x", "cpu_2x", "cpu_1x", "ddr2x", "ddr3x",
9698
"dci", "lqspi", "smc", "pcap", "gem0", "gem1",

‎arch/arm/boot/dts/zynq-7000.dtsi‎

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -123,30 +123,28 @@
123123
} ;
124124

125125
slcr: slcr@f8000000 {
126+
#address-cells = <1>;
127+
#size-cells = <1>;
126128
compatible = "xlnx,zynq-slcr", "syscon";
127129
reg = <0xF8000000 0x1000>;
128-
129-
clocks {
130-
#address-cells = <1>;
131-
#size-cells = <0>;
132-
133-
clkc: clkc {
134-
#clock-cells = <1>;
135-
compatible = "xlnx,ps7-clkc";
136-
ps-clk-frequency = <33333333>;
137-
fclk-enable = <0>;
138-
clock-output-names = "armpll", "ddrpll", "iopll", "cpu_6or4x",
139-
"cpu_3or2x", "cpu_2x", "cpu_1x", "ddr2x", "ddr3x",
140-
"dci", "lqspi", "smc", "pcap", "gem0", "gem1",
141-
"fclk0", "fclk1", "fclk2", "fclk3", "can0", "can1",
142-
"sdio0", "sdio1", "uart0", "uart1", "spi0", "spi1",
143-
"dma", "usb0_aper", "usb1_aper", "gem0_aper",
144-
"gem1_aper", "sdio0_aper", "sdio1_aper",
145-
"spi0_aper", "spi1_aper", "can0_aper", "can1_aper",
146-
"i2c0_aper", "i2c1_aper", "uart0_aper", "uart1_aper",
147-
"gpio_aper", "lqspi_aper", "smc_aper", "swdt",
148-
"dbg_trc", "dbg_apb";
149-
};
130+
ranges;
131+
clkc: clkc@100 {
132+
#clock-cells = <1>;
133+
compatible = "xlnx,ps7-clkc";
134+
ps-clk-frequency = <33333333>;
135+
fclk-enable = <0>;
136+
clock-output-names = "armpll", "ddrpll", "iopll", "cpu_6or4x",
137+
"cpu_3or2x", "cpu_2x", "cpu_1x", "ddr2x", "ddr3x",
138+
"dci", "lqspi", "smc", "pcap", "gem0", "gem1",
139+
"fclk0", "fclk1", "fclk2", "fclk3", "can0", "can1",
140+
"sdio0", "sdio1", "uart0", "uart1", "spi0", "spi1",
141+
"dma", "usb0_aper", "usb1_aper", "gem0_aper",
142+
"gem1_aper", "sdio0_aper", "sdio1_aper",
143+
"spi0_aper", "spi1_aper", "can0_aper", "can1_aper",
144+
"i2c0_aper", "i2c1_aper", "uart0_aper", "uart1_aper",
145+
"gpio_aper", "lqspi_aper", "smc_aper", "swdt",
146+
"dbg_trc", "dbg_apb";
147+
reg = <0x100 0x100>;
150148
};
151149
};
152150

‎arch/arm/mach-zynq/common.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ static void __init zynq_timer_init(void)
6767
{
6868
zynq_early_slcr_init();
6969

70-
zynq_clock_init(zynq_slcr_base);
70+
zynq_clock_init();
7171
clocksource_of_init();
7272
}
7373

‎drivers/clk/zynq/clkc.c‎

Lines changed: 63 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -21,34 +21,35 @@
2121
#include <linux/clk/zynq.h>
2222
#include <linux/clk-provider.h>
2323
#include <linux/of.h>
24+
#include <linux/of_address.h>
2425
#include <linux/slab.h>
2526
#include <linux/string.h>
2627
#include <linux/io.h>
2728

28-
static void __iomem *zynq_slcr_base_priv;
29-
30-
#define SLCR_ARMPLL_CTRL (zynq_slcr_base_priv + 0x100)
31-
#define SLCR_DDRPLL_CTRL (zynq_slcr_base_priv + 0x104)
32-
#define SLCR_IOPLL_CTRL (zynq_slcr_base_priv + 0x108)
33-
#define SLCR_PLL_STATUS (zynq_slcr_base_priv + 0x10c)
34-
#define SLCR_ARM_CLK_CTRL (zynq_slcr_base_priv + 0x120)
35-
#define SLCR_DDR_CLK_CTRL (zynq_slcr_base_priv + 0x124)
36-
#define SLCR_DCI_CLK_CTRL (zynq_slcr_base_priv + 0x128)
37-
#define SLCR_APER_CLK_CTRL (zynq_slcr_base_priv + 0x12c)
38-
#define SLCR_GEM0_CLK_CTRL (zynq_slcr_base_priv + 0x140)
39-
#define SLCR_GEM1_CLK_CTRL (zynq_slcr_base_priv + 0x144)
40-
#define SLCR_SMC_CLK_CTRL (zynq_slcr_base_priv + 0x148)
41-
#define SLCR_LQSPI_CLK_CTRL (zynq_slcr_base_priv + 0x14c)
42-
#define SLCR_SDIO_CLK_CTRL (zynq_slcr_base_priv + 0x150)
43-
#define SLCR_UART_CLK_CTRL (zynq_slcr_base_priv + 0x154)
44-
#define SLCR_SPI_CLK_CTRL (zynq_slcr_base_priv + 0x158)
45-
#define SLCR_CAN_CLK_CTRL (zynq_slcr_base_priv + 0x15c)
46-
#define SLCR_CAN_MIOCLK_CTRL (zynq_slcr_base_priv + 0x160)
47-
#define SLCR_DBG_CLK_CTRL (zynq_slcr_base_priv + 0x164)
48-
#define SLCR_PCAP_CLK_CTRL (zynq_slcr_base_priv + 0x168)
49-
#define SLCR_FPGA0_CLK_CTRL (zynq_slcr_base_priv + 0x170)
50-
#define SLCR_621_TRUE (zynq_slcr_base_priv + 0x1c4)
51-
#define SLCR_SWDT_CLK_SEL (zynq_slcr_base_priv + 0x304)
29+
static void __iomem *zynq_clkc_base;
30+
31+
#define SLCR_ARMPLL_CTRL (zynq_clkc_base + 0x00)
32+
#define SLCR_DDRPLL_CTRL (zynq_clkc_base + 0x04)
33+
#define SLCR_IOPLL_CTRL (zynq_clkc_base + 0x08)
34+
#define SLCR_PLL_STATUS (zynq_clkc_base + 0x0c)
35+
#define SLCR_ARM_CLK_CTRL (zynq_clkc_base + 0x20)
36+
#define SLCR_DDR_CLK_CTRL (zynq_clkc_base + 0x24)
37+
#define SLCR_DCI_CLK_CTRL (zynq_clkc_base + 0x28)
38+
#define SLCR_APER_CLK_CTRL (zynq_clkc_base + 0x2c)
39+
#define SLCR_GEM0_CLK_CTRL (zynq_clkc_base + 0x40)
40+
#define SLCR_GEM1_CLK_CTRL (zynq_clkc_base + 0x44)
41+
#define SLCR_SMC_CLK_CTRL (zynq_clkc_base + 0x48)
42+
#define SLCR_LQSPI_CLK_CTRL (zynq_clkc_base + 0x4c)
43+
#define SLCR_SDIO_CLK_CTRL (zynq_clkc_base + 0x50)
44+
#define SLCR_UART_CLK_CTRL (zynq_clkc_base + 0x54)
45+
#define SLCR_SPI_CLK_CTRL (zynq_clkc_base + 0x58)
46+
#define SLCR_CAN_CLK_CTRL (zynq_clkc_base + 0x5c)
47+
#define SLCR_CAN_MIOCLK_CTRL (zynq_clkc_base + 0x60)
48+
#define SLCR_DBG_CLK_CTRL (zynq_clkc_base + 0x64)
49+
#define SLCR_PCAP_CLK_CTRL (zynq_clkc_base + 0x68)
50+
#define SLCR_FPGA0_CLK_CTRL (zynq_clkc_base + 0x70)
51+
#define SLCR_621_TRUE (zynq_clkc_base + 0xc4)
52+
#define SLCR_SWDT_CLK_SEL (zynq_clkc_base + 0x204)
5253

5354
#define NUM_MIO_PINS 54
5455

@@ -569,8 +570,44 @@ static void __init zynq_clk_setup(struct device_node *np)
569570

570571
CLK_OF_DECLARE(zynq_clkc, "xlnx,ps7-clkc", zynq_clk_setup);
571572

572-
void __init zynq_clock_init(void __iomem *slcr_base)
573+
void __init zynq_clock_init(void)
573574
{
574-
zynq_slcr_base_priv = slcr_base;
575+
struct device_node *np;
576+
struct device_node *slcr;
577+
struct resource res;
578+
579+
np = of_find_compatible_node(NULL, NULL, "xlnx,ps7-clkc");
580+
if (!np) {
581+
pr_err("%s: clkc node not found\n", __func__);
582+
goto np_err;
583+
}
584+
585+
if (of_address_to_resource(np, 0, &res)) {
586+
pr_err("%s: failed to get resource\n", np->name);
587+
goto np_err;
588+
}
589+
590+
slcr = of_get_parent(np);
591+
592+
if (slcr->data) {
593+
zynq_clkc_base = (__force void __iomem *)slcr->data + res.start;
594+
} else {
595+
pr_err("%s: Unable to get I/O memory\n", np->name);
596+
of_node_put(slcr);
597+
goto np_err;
598+
}
599+
600+
pr_info("%s: clkc starts at %p\n", __func__, zynq_clkc_base);
601+
602+
of_node_put(slcr);
603+
of_node_put(np);
604+
575605
of_clk_init(NULL);
606+
607+
return;
608+
609+
np_err:
610+
of_node_put(np);
611+
BUG();
612+
return;
576613
}

‎include/linux/clk/zynq.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
#include <linux/spinlock.h>
2424

25-
void zynq_clock_init(void __iomem *slcr);
25+
void zynq_clock_init(void);
2626

2727
struct clk *clk_register_zynq_pll(const char *name, const char *parent,
2828
void __iomem *pll_ctrl, void __iomem *pll_status, u8 lock_index,

0 commit comments

Comments
 (0)