Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+87 -50
+3 -1
Documentation/devicetree/bindings/clock/zynq-7000.txt
··· 14 14 Required properties: 15 15 - #clock-cells : Must be 1 16 16 - compatible : "xlnx,ps7-clkc" 17 + - reg : SLCR offset and size taken via syscon < 0x100 0x100 > 17 18 - ps-clk-frequency : Frequency of the oscillator providing ps_clk in HZ 18 19 (usually 33 MHz oscillators are used for Zynq platforms) 19 20 - clock-output-names : List of strings used to name the clock outputs. Shall be ··· 88 87 47: dbg_apb 89 88 90 89 Example: 91 - clkc: clkc { 90 + clkc: clkc@100 { 92 91 #clock-cells = <1>; 93 92 compatible = "xlnx,ps7-clkc"; 94 93 ps-clk-frequency = <33333333>; 94 + reg = <0x100 0x100>; 95 95 clock-output-names = "armpll", "ddrpll", "iopll", "cpu_6or4x", 96 96 "cpu_3or2x", "cpu_2x", "cpu_1x", "ddr2x", "ddr3x", 97 97 "dci", "lqspi", "smc", "pcap", "gem0", "gem1",
+20 -22
arch/arm/boot/dts/zynq-7000.dtsi
··· 123 123 } ; 124 124 125 125 slcr: slcr@f8000000 { 126 + #address-cells = <1>; 127 + #size-cells = <1>; 126 128 compatible = "xlnx,zynq-slcr", "syscon"; 127 129 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>; 150 148 }; 151 149 }; 152 150
+1 -1
arch/arm/mach-zynq/common.c
··· 67 67 { 68 68 zynq_early_slcr_init(); 69 69 70 - zynq_clock_init(zynq_slcr_base); 70 + zynq_clock_init(); 71 71 clocksource_of_init(); 72 72 } 73 73
+62 -25
drivers/clk/zynq/clkc.c
··· 21 21 #include <linux/clk/zynq.h> 22 22 #include <linux/clk-provider.h> 23 23 #include <linux/of.h> 24 + #include <linux/of_address.h> 24 25 #include <linux/slab.h> 25 26 #include <linux/string.h> 26 27 #include <linux/io.h> 27 28 28 - static void __iomem *zynq_slcr_base_priv; 29 + static void __iomem *zynq_clkc_base; 29 30 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) 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) 52 53 53 54 #define NUM_MIO_PINS 54 54 55 ··· 570 569 571 570 CLK_OF_DECLARE(zynq_clkc, "xlnx,ps7-clkc", zynq_clk_setup); 572 571 573 - void __init zynq_clock_init(void __iomem *slcr_base) 572 + void __init zynq_clock_init(void) 574 573 { 575 - zynq_slcr_base_priv = slcr_base; 574 + struct device_node *np; 575 + struct device_node *slcr; 576 + struct resource res; 577 + 578 + np = of_find_compatible_node(NULL, NULL, "xlnx,ps7-clkc"); 579 + if (!np) { 580 + pr_err("%s: clkc node not found\n", __func__); 581 + goto np_err; 582 + } 583 + 584 + if (of_address_to_resource(np, 0, &res)) { 585 + pr_err("%s: failed to get resource\n", np->name); 586 + goto np_err; 587 + } 588 + 589 + slcr = of_get_parent(np); 590 + 591 + if (slcr->data) { 592 + zynq_clkc_base = (__force void __iomem *)slcr->data + res.start; 593 + } else { 594 + pr_err("%s: Unable to get I/O memory\n", np->name); 595 + of_node_put(slcr); 596 + goto np_err; 597 + } 598 + 599 + pr_info("%s: clkc starts at %p\n", __func__, zynq_clkc_base); 600 + 601 + of_node_put(slcr); 602 + of_node_put(np); 603 + 576 604 of_clk_init(NULL); 605 + 606 + return; 607 + 608 + np_err: 609 + of_node_put(np); 610 + BUG(); 611 + return; 577 612 }
+1 -1
include/linux/clk/zynq.h
··· 22 22 23 23 #include <linux/spinlock.h> 24 24 25 - void zynq_clock_init(void __iomem *slcr); 25 + void zynq_clock_init(void); 26 26 27 27 struct clk *clk_register_zynq_pll(const char *name, const char *parent, 28 28 void __iomem *pll_ctrl, void __iomem *pll_status, u8 lock_index,