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

drivers: clk: st: Remove stih415-416 clock support

STiH415 and STiH416 platforms are no longer used.
these platforms will be deprecated for the next kernel.

Signed-off-by: Gabriel Fernandez <gabriel.fernandez@st.com>
Acked-by: Rob Herring <robh@kernel.org>
Acked-by: Peter Griffin <peter.griffin@linaro.org>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>

authored by

Gabriel Fernandez and committed by
Stephen Boyd
7df404c9 f5644f10

+36 -1638
-49
Documentation/devicetree/bindings/clock/st/st,clkgen-divmux.txt
··· 1 - Binding for a ST divider and multiplexer clock driver. 2 - 3 - This binding uses the common clock binding[1]. 4 - Base address is located to the parent node. See clock binding[2] 5 - 6 - [1] Documentation/devicetree/bindings/clock/clock-bindings.txt 7 - [2] Documentation/devicetree/bindings/clock/st/st,clkgen.txt 8 - 9 - Required properties: 10 - 11 - - compatible : shall be: 12 - "st,clkgena-divmux-c65-hs", "st,clkgena-divmux" 13 - "st,clkgena-divmux-c65-ls", "st,clkgena-divmux" 14 - "st,clkgena-divmux-c32-odf0", "st,clkgena-divmux" 15 - "st,clkgena-divmux-c32-odf1", "st,clkgena-divmux" 16 - "st,clkgena-divmux-c32-odf2", "st,clkgena-divmux" 17 - "st,clkgena-divmux-c32-odf3", "st,clkgena-divmux" 18 - 19 - - #clock-cells : From common clock binding; shall be set to 1. 20 - 21 - - clocks : From common clock binding 22 - 23 - - clock-output-names : From common clock binding. 24 - 25 - Example: 26 - 27 - clockgen-a@fd345000 { 28 - reg = <0xfd345000 0xb50>; 29 - 30 - clk_m_a1_div1: clk-m-a1-div1 { 31 - #clock-cells = <1>; 32 - compatible = "st,clkgena-divmux-c32-odf1", 33 - "st,clkgena-divmux"; 34 - 35 - clocks = <&clk_m_a1_osc_prediv>, 36 - <&clk_m_a1_pll0 1>, /* PLL0 PHI1 */ 37 - <&clk_m_a1_pll1 1>; /* PLL1 PHI1 */ 38 - 39 - clock-output-names = "clk-m-rx-icn-ts", 40 - "clk-m-rx-icn-vdp-0", 41 - "", /* unused */ 42 - "clk-m-prv-t1-bus", 43 - "clk-m-icn-reg-12", 44 - "clk-m-icn-reg-10", 45 - "", /* unused */ 46 - "clk-m-icn-st231"; 47 - }; 48 - }; 49 -
+7 -11
Documentation/devicetree/bindings/clock/st/st,clkgen-mux.txt
··· 10 10 Required properties: 11 11 12 12 - compatible : shall be: 13 - "st,stih416-clkgenc-vcc-hd", "st,clkgen-mux" 14 - "st,stih416-clkgenf-vcc-fvdp", "st,clkgen-mux" 15 - "st,stih416-clkgenf-vcc-hva", "st,clkgen-mux" 16 - "st,stih416-clkgenf-vcc-hd", "st,clkgen-mux" 17 - "st,stih416-clkgenf-vcc-sd", "st,clkgen-mux" 18 - "st,stih415-clkgen-a9-mux", "st,clkgen-mux" 19 - "st,stih416-clkgen-a9-mux", "st,clkgen-mux" 20 13 "st,stih407-clkgen-a9-mux", "st,clkgen-mux" 21 14 22 15 - #clock-cells : from common clock binding; shall be set to 0. ··· 20 27 21 28 Example: 22 29 23 - clk_m_hva: clk-m-hva@fd690868 { 30 + clk_m_a9: clk-m-a9@92b0000 { 24 31 #clock-cells = <0>; 25 - compatible = "st,stih416-clkgenf-vcc-hva", "st,clkgen-mux"; 26 - reg = <0xfd690868 4>; 32 + compatible = "st,stih407-clkgen-a9-mux"; 33 + reg = <0x92b0000 0x10000>; 27 34 28 - clocks = <&clockgen_f 1>, <&clk_m_a1_div0 3>; 35 + clocks = <&clockgen_a9_pll 0>, 36 + <&clockgen_a9_pll 0>, 37 + <&clk_s_c0_flexgen 13>, 38 + <&clk_m_a9_ext2f_div2>; 29 39 };
+6 -20
Documentation/devicetree/bindings/clock/st/st,clkgen-pll.txt
··· 9 9 Required properties: 10 10 11 11 - compatible : shall be: 12 - "st,clkgena-prediv-c65", "st,clkgena-prediv" 13 - "st,clkgena-prediv-c32", "st,clkgena-prediv" 14 - 15 - "st,clkgena-plls-c65" 16 - "st,plls-c32-a1x-0", "st,clkgen-plls-c32" 17 - "st,plls-c32-a1x-1", "st,clkgen-plls-c32" 18 - "st,stih415-plls-c32-a9", "st,clkgen-plls-c32" 19 - "st,stih415-plls-c32-ddr", "st,clkgen-plls-c32" 20 - "st,stih416-plls-c32-a9", "st,clkgen-plls-c32" 21 - "st,stih416-plls-c32-ddr", "st,clkgen-plls-c32" 22 12 "st,stih407-plls-c32-a0", "st,clkgen-plls-c32" 23 13 "st,stih407-plls-c32-a9", "st,clkgen-plls-c32" 24 14 "sst,plls-c32-cx_0", "st,clkgen-plls-c32" 25 15 "sst,plls-c32-cx_1", "st,clkgen-plls-c32" 26 16 "st,stih418-plls-c28-a9", "st,clkgen-plls-c32" 27 - 28 - "st,stih415-gpu-pll-c32", "st,clkgengpu-pll-c32" 29 - "st,stih416-gpu-pll-c32", "st,clkgengpu-pll-c32" 30 17 31 18 - #clock-cells : From common clock binding; shall be set to 1. 32 19 ··· 23 36 24 37 Example: 25 38 26 - clockgen-a@fee62000 { 27 - reg = <0xfee62000 0xb48>; 39 + clockgen-a9@92b0000 { 40 + compatible = "st,clkgen-c32"; 41 + reg = <0x92b0000 0xffff>; 28 42 29 - clk_s_a0_pll: clk-s-a0-pll { 43 + clockgen_a9_pll: clockgen-a9-pll { 30 44 #clock-cells = <1>; 31 - compatible = "st,clkgena-plls-c65"; 45 + compatible = "st,stih407-plls-c32-a9", "st,clkgen-plls-c32"; 32 46 33 47 clocks = <&clk_sysin>; 34 48 35 - clock-output-names = "clk-s-a0-pll0-hs", 36 - "clk-s-a0-pll0-ls", 37 - "clk-s-a0-pll1"; 49 + clock-output-names = "clockgen-a9-pll-odf"; 38 50 }; 39 51 };
-36
Documentation/devicetree/bindings/clock/st/st,clkgen-prediv.txt
··· 1 - Binding for a ST pre-divider clock driver. 2 - 3 - This binding uses the common clock binding[1]. 4 - Base address is located to the parent node. See clock binding[2] 5 - 6 - [1] Documentation/devicetree/bindings/clock/clock-bindings.txt 7 - [2] Documentation/devicetree/bindings/clock/st/st,clkgen.txt 8 - 9 - Required properties: 10 - 11 - - compatible : shall be: 12 - "st,clkgena-prediv-c65", "st,clkgena-prediv" 13 - "st,clkgena-prediv-c32", "st,clkgena-prediv" 14 - 15 - - #clock-cells : From common clock binding; shall be set to 0. 16 - 17 - - clocks : From common clock binding 18 - 19 - - clock-output-names : From common clock binding. 20 - 21 - Example: 22 - 23 - clockgen-a@fd345000 { 24 - reg = <0xfd345000 0xb50>; 25 - 26 - clk_m_a2_osc_prediv: clk-m-a2-osc-prediv { 27 - #clock-cells = <0>; 28 - compatible = "st,clkgena-prediv-c32", 29 - "st,clkgena-prediv"; 30 - 31 - clocks = <&clk_sysin>; 32 - 33 - clock-output-names = "clk-m-a2-osc-prediv"; 34 - }; 35 - }; 36 -
-61
Documentation/devicetree/bindings/clock/st/st,clkgen-vcc.txt
··· 1 - Binding for a type of STMicroelectronics clock crossbar (VCC). 2 - 3 - The crossbar can take up to 4 input clocks and control up to 16 4 - output clocks. Not all inputs or outputs have to be in use in a 5 - particular instantiation. Each output can be individually enabled, 6 - select any of the input clocks and apply a divide (by 1,2,4 or 8) to 7 - that selected clock. 8 - 9 - This binding uses the common clock binding[1]. 10 - 11 - [1] Documentation/devicetree/bindings/clock/clock-bindings.txt 12 - 13 - Required properties: 14 - 15 - - compatible : shall be: 16 - "st,stih416-clkgenc", "st,vcc" 17 - "st,stih416-clkgenf", "st,vcc" 18 - 19 - - #clock-cells : from common clock binding; shall be set to 1. 20 - 21 - - reg : A Base address and length of the register set. 22 - 23 - - clocks : from common clock binding 24 - 25 - - clock-output-names : From common clock binding. The block has 16 26 - clock outputs but not all of them in a specific instance 27 - have to be used in the SoC. If a clock name is left as 28 - an empty string then no clock will be created for the 29 - output associated with that string index. If fewer than 30 - 16 strings are provided then no clocks will be created 31 - for the remaining outputs. 32 - 33 - Example: 34 - 35 - clockgen_c_vcc: clockgen-c-vcc@0xfe8308ac { 36 - #clock-cells = <1>; 37 - compatible = "st,stih416-clkgenc", "st,clkgen-vcc"; 38 - reg = <0xfe8308ac 12>; 39 - 40 - clocks = <&clk_s_vcc_hd>, 41 - <&clockgen_c 1>, 42 - <&clk_s_tmds_fromphy>, 43 - <&clockgen_c 2>; 44 - 45 - clock-output-names = "clk-s-pix-hdmi", 46 - "clk-s-pix-dvo", 47 - "clk-s-out-dvo", 48 - "clk-s-pix-hd", 49 - "clk-s-hddac", 50 - "clk-s-denc", 51 - "clk-s-sddac", 52 - "clk-s-pix-main", 53 - "clk-s-pix-aux", 54 - "clk-s-stfe-frc-0", 55 - "clk-s-ref-mcru", 56 - "clk-s-slave-mcru", 57 - "clk-s-tmds-hdmi", 58 - "clk-s-hdmi-reject-pll", 59 - "clk-s-thsens"; 60 - }; 61 -
+11 -43
Documentation/devicetree/bindings/clock/st/st,clkgen.txt
··· 13 13 ... 14 14 }; 15 15 16 - prediv_node { 17 - ... 18 - }; 19 - 20 - divmux_node { 21 - ... 22 - }; 23 - 24 16 quadfs_node { 25 17 ... 26 18 }; 27 19 28 20 mux_node { 29 - ... 30 - }; 31 - 32 - vcc_node { 33 21 ... 34 22 }; 35 23 ··· 31 43 Each subnode should use the binding described in [2]..[7] 32 44 33 45 [1] Documentation/devicetree/bindings/clock/clock-bindings.txt 34 - [2] Documentation/devicetree/bindings/clock/st,clkgen-divmux.txt 35 46 [3] Documentation/devicetree/bindings/clock/st,clkgen-mux.txt 36 47 [4] Documentation/devicetree/bindings/clock/st,clkgen-pll.txt 37 - [5] Documentation/devicetree/bindings/clock/st,clkgen-prediv.txt 38 - [6] Documentation/devicetree/bindings/clock/st,vcc.txt 39 48 [7] Documentation/devicetree/bindings/clock/st,quadfs.txt 40 49 [8] Documentation/devicetree/bindings/clock/st,flexgen.txt 41 50 ··· 42 57 43 58 Example: 44 59 45 - clockgen-a@fee62000 { 46 - 47 - reg = <0xfee62000 0xb48>; 60 + clockgen-a@090ff000 { 61 + compatible = "st,clkgen-c32"; 62 + reg = <0x90ff000 0x1000>; 48 63 49 64 clk_s_a0_pll: clk-s-a0-pll { 50 65 #clock-cells = <1>; 51 - compatible = "st,clkgena-plls-c65"; 52 - 53 - clocks = <&clk-sysin>; 54 - 55 - clock-output-names = "clk-s-a0-pll0-hs", 56 - "clk-s-a0-pll0-ls", 57 - "clk-s-a0-pll1"; 58 - }; 59 - 60 - clk_s_a0_osc_prediv: clk-s-a0-osc-prediv { 61 - #clock-cells = <0>; 62 - compatible = "st,clkgena-prediv-c65", 63 - "st,clkgena-prediv"; 66 + compatible = "st,stih407-plls-c32-a0", "st,clkgen-plls-c32"; 64 67 65 68 clocks = <&clk_sysin>; 66 69 67 - clock-output-names = "clk-s-a0-osc-prediv"; 70 + clock-output-names = "clk-s-a0-pll-ofd-0"; 68 71 }; 69 72 70 - clk_s_a0_hs: clk-s-a0-hs { 73 + clk_s_a0_flexgen: clk-s-a0-flexgen { 74 + compatible = "st,flexgen"; 75 + 71 76 #clock-cells = <1>; 72 - compatible = "st,clkgena-divmux-c65-hs", 73 - "st,clkgena-divmux"; 74 77 75 - clocks = <&clk-s_a0_osc_prediv>, 76 - <&clk-s_a0_pll 0>, /* pll0 hs */ 77 - <&clk-s_a0_pll 2>; /* pll1 */ 78 + clocks = <&clk_s_a0_pll 0>, 79 + <&clk_sysin>; 78 80 79 - clock-output-names = "clk-s-fdma-0", 80 - "clk-s-fdma-1", 81 - ""; /* clk-s-jit-sense */ 82 - /* fourth output unused */ 81 + clock-output-names = "clk-ic-lmi0"; 83 82 }; 84 83 }; 85 -
+11 -14
Documentation/devicetree/bindings/clock/st/st,quadfs.txt
··· 11 11 12 12 Required properties: 13 13 - compatible : shall be: 14 - "st,stih416-quadfs216", "st,quadfs" 15 - "st,stih416-quadfs432", "st,quadfs" 16 - "st,stih416-quadfs660-E", "st,quadfs" 17 - "st,stih416-quadfs660-F", "st,quadfs" 18 14 "st,stih407-quadfs660-C", "st,quadfs" 19 15 "st,stih407-quadfs660-D", "st,quadfs" 20 16 ··· 31 35 32 36 Example: 33 37 34 - clockgen_e: clockgen-e@fd3208bc { 35 - #clock-cells = <1>; 36 - compatible = "st,stih416-quadfs660-E", "st,quadfs"; 37 - reg = <0xfd3208bc 0xB0>; 38 + clk_s_c0_quadfs: clk-s-c0-quadfs@9103000 { 39 + #clock-cells = <1>; 40 + compatible = "st,stih407-quadfs660-C", "st,quadfs"; 41 + reg = <0x9103000 0x1000>; 38 42 39 - clocks = <&clk_sysin>; 40 - clock-output-names = "clk-m-pix-mdtp-0", 41 - "clk-m-pix-mdtp-1", 42 - "clk-m-pix-mdtp-2", 43 - "clk-m-mpelpc"; 44 - }; 43 + clocks = <&clk_sysin>; 44 + 45 + clock-output-names = "clk-s-c0-fs0-ch0", 46 + "clk-s-c0-fs0-ch1", 47 + "clk-s-c0-fs0-ch2", 48 + "clk-s-c0-fs0-ch3"; 49 + };
-260
drivers/clk/st/clkgen-fsyn.c
··· 42 42 unsigned long nsdiv; 43 43 }; 44 44 45 - static const struct stm_fs fs216c65_rtbl[] = { 46 - { .mdiv = 0x1f, .pe = 0x0, .sdiv = 0x7, .nsdiv = 0 }, /* 312.5 Khz */ 47 - { .mdiv = 0x17, .pe = 0x25ed, .sdiv = 0x1, .nsdiv = 0 }, /* 27 MHz */ 48 - { .mdiv = 0x1a, .pe = 0x7b36, .sdiv = 0x2, .nsdiv = 1 }, /* 36.87 MHz */ 49 - { .mdiv = 0x13, .pe = 0x0, .sdiv = 0x2, .nsdiv = 1 }, /* 48 MHz */ 50 - { .mdiv = 0x11, .pe = 0x1c72, .sdiv = 0x1, .nsdiv = 1 }, /* 108 MHz */ 51 - }; 52 - 53 - static const struct stm_fs fs432c65_rtbl[] = { 54 - { .mdiv = 0x1f, .pe = 0x0, .sdiv = 0x7, .nsdiv = 0 }, /* 625 Khz */ 55 - { .mdiv = 0x13, .pe = 0x777c, .sdiv = 0x4, .nsdiv = 1 }, /* 25.175 MHz */ 56 - { .mdiv = 0x19, .pe = 0x4d35, .sdiv = 0x2, .nsdiv = 0 }, /* 25.200 MHz */ 57 - { .mdiv = 0x11, .pe = 0x1c72, .sdiv = 0x4, .nsdiv = 1 }, /* 27.000 MHz */ 58 - { .mdiv = 0x17, .pe = 0x28f5, .sdiv = 0x2, .nsdiv = 0 }, /* 27.027 MHz */ 59 - { .mdiv = 0x16, .pe = 0x3359, .sdiv = 0x2, .nsdiv = 0 }, /* 28.320 MHz */ 60 - { .mdiv = 0x1f, .pe = 0x2083, .sdiv = 0x3, .nsdiv = 1 }, /* 30.240 MHz */ 61 - { .mdiv = 0x1e, .pe = 0x430d, .sdiv = 0x3, .nsdiv = 1 }, /* 31.500 MHz */ 62 - { .mdiv = 0x17, .pe = 0x0, .sdiv = 0x3, .nsdiv = 1 }, /* 40.000 MHz */ 63 - { .mdiv = 0x19, .pe = 0x121a, .sdiv = 0x1, .nsdiv = 0 }, /* 49.500 MHz */ 64 - { .mdiv = 0x13, .pe = 0x6667, .sdiv = 0x3, .nsdiv = 1 }, /* 50.000 MHz */ 65 - { .mdiv = 0x10, .pe = 0x1ee6, .sdiv = 0x3, .nsdiv = 1 }, /* 57.284 MHz */ 66 - { .mdiv = 0x1d, .pe = 0x3b14, .sdiv = 0x2, .nsdiv = 1 }, /* 65.000 MHz */ 67 - { .mdiv = 0x12, .pe = 0x7c65, .sdiv = 0x1, .nsdiv = 0 }, /* 71.000 MHz */ 68 - { .mdiv = 0x19, .pe = 0xecd, .sdiv = 0x2, .nsdiv = 1 }, /* 74.176 MHz */ 69 - { .mdiv = 0x19, .pe = 0x121a, .sdiv = 0x2, .nsdiv = 1 }, /* 74.250 MHz */ 70 - { .mdiv = 0x19, .pe = 0x3334, .sdiv = 0x2, .nsdiv = 1 }, /* 75.000 MHz */ 71 - { .mdiv = 0x18, .pe = 0x5138, .sdiv = 0x2, .nsdiv = 1 }, /* 78.800 MHz */ 72 - { .mdiv = 0x1d, .pe = 0x77d, .sdiv = 0x0, .nsdiv = 0 }, /* 85.500 MHz */ 73 - { .mdiv = 0x1c, .pe = 0x13d5, .sdiv = 0x0, .nsdiv = 0 }, /* 88.750 MHz */ 74 - { .mdiv = 0x11, .pe = 0x1c72, .sdiv = 0x2, .nsdiv = 1 }, /* 108.000 MHz */ 75 - { .mdiv = 0x17, .pe = 0x28f5, .sdiv = 0x0, .nsdiv = 0 }, /* 108.108 MHz */ 76 - { .mdiv = 0x10, .pe = 0x6e26, .sdiv = 0x2, .nsdiv = 1 }, /* 118.963 MHz */ 77 - { .mdiv = 0x15, .pe = 0x3e63, .sdiv = 0x0, .nsdiv = 0 }, /* 119.000 MHz */ 78 - { .mdiv = 0x1c, .pe = 0x471d, .sdiv = 0x1, .nsdiv = 1 }, /* 135.000 MHz */ 79 - { .mdiv = 0x19, .pe = 0xecd, .sdiv = 0x1, .nsdiv = 1 }, /* 148.352 MHz */ 80 - { .mdiv = 0x19, .pe = 0x121a, .sdiv = 0x1, .nsdiv = 1 }, /* 148.500 MHz */ 81 - { .mdiv = 0x19, .pe = 0x121a, .sdiv = 0x0, .nsdiv = 1 }, /* 297 MHz */ 82 - }; 83 - 84 45 static const struct stm_fs fs660c32_rtbl[] = { 85 46 { .mdiv = 0x14, .pe = 0x376b, .sdiv = 0x4, .nsdiv = 1 }, /* 25.175 MHz */ 86 47 { .mdiv = 0x14, .pe = 0x30c3, .sdiv = 0x4, .nsdiv = 1 }, /* 25.200 MHz */ ··· 105 144 unsigned long *); 106 145 }; 107 146 108 - static const struct clk_ops st_quadfs_pll_c65_ops; 109 147 static const struct clk_ops st_quadfs_pll_c32_ops; 110 - static const struct clk_ops st_quadfs_fs216c65_ops; 111 - static const struct clk_ops st_quadfs_fs432c65_ops; 112 148 static const struct clk_ops st_quadfs_fs660c32_ops; 113 149 114 - static int clk_fs216c65_get_rate(unsigned long, const struct stm_fs *, 115 - unsigned long *); 116 - static int clk_fs432c65_get_rate(unsigned long, const struct stm_fs *, 117 - unsigned long *); 118 150 static int clk_fs660c32_dig_get_rate(unsigned long, const struct stm_fs *, 119 151 unsigned long *); 120 - /* 121 - * Values for all of the standalone instances of this clock 122 - * generator found in STiH415 and STiH416 SYSCFG register banks. Note 123 - * that the individual channel standby control bits (nsb) are in the 124 - * first register along with the PLL control bits. 125 - */ 126 - static const struct clkgen_quadfs_data st_fs216c65_416 = { 127 - /* 416 specific */ 128 - .npda = CLKGEN_FIELD(0x0, 0x1, 14), 129 - .nsb = { CLKGEN_FIELD(0x0, 0x1, 10), 130 - CLKGEN_FIELD(0x0, 0x1, 11), 131 - CLKGEN_FIELD(0x0, 0x1, 12), 132 - CLKGEN_FIELD(0x0, 0x1, 13) }, 133 - .nsdiv_present = true, 134 - .nsdiv = { CLKGEN_FIELD(0x0, 0x1, 18), 135 - CLKGEN_FIELD(0x0, 0x1, 19), 136 - CLKGEN_FIELD(0x0, 0x1, 20), 137 - CLKGEN_FIELD(0x0, 0x1, 21) }, 138 - .mdiv = { CLKGEN_FIELD(0x4, 0x1f, 0), 139 - CLKGEN_FIELD(0x14, 0x1f, 0), 140 - CLKGEN_FIELD(0x24, 0x1f, 0), 141 - CLKGEN_FIELD(0x34, 0x1f, 0) }, 142 - .en = { CLKGEN_FIELD(0x10, 0x1, 0), 143 - CLKGEN_FIELD(0x20, 0x1, 0), 144 - CLKGEN_FIELD(0x30, 0x1, 0), 145 - CLKGEN_FIELD(0x40, 0x1, 0) }, 146 - .ndiv = CLKGEN_FIELD(0x0, 0x1, 15), 147 - .bwfilter_present = true, 148 - .ref_bw = CLKGEN_FIELD(0x0, 0x3, 16), 149 - .pe = { CLKGEN_FIELD(0x8, 0xffff, 0), 150 - CLKGEN_FIELD(0x18, 0xffff, 0), 151 - CLKGEN_FIELD(0x28, 0xffff, 0), 152 - CLKGEN_FIELD(0x38, 0xffff, 0) }, 153 - .sdiv = { CLKGEN_FIELD(0xC, 0x7, 0), 154 - CLKGEN_FIELD(0x1C, 0x7, 0), 155 - CLKGEN_FIELD(0x2C, 0x7, 0), 156 - CLKGEN_FIELD(0x3C, 0x7, 0) }, 157 - .pll_ops = &st_quadfs_pll_c65_ops, 158 - .rtbl = fs216c65_rtbl, 159 - .rtbl_cnt = ARRAY_SIZE(fs216c65_rtbl), 160 - .get_rate = clk_fs216c65_get_rate, 161 - }; 162 - 163 - static const struct clkgen_quadfs_data st_fs432c65_416 = { 164 - .npda = CLKGEN_FIELD(0x0, 0x1, 14), 165 - .nsb = { CLKGEN_FIELD(0x0, 0x1, 10), 166 - CLKGEN_FIELD(0x0, 0x1, 11), 167 - CLKGEN_FIELD(0x0, 0x1, 12), 168 - CLKGEN_FIELD(0x0, 0x1, 13) }, 169 - .nsdiv_present = true, 170 - .nsdiv = { CLKGEN_FIELD(0x0, 0x1, 18), 171 - CLKGEN_FIELD(0x0, 0x1, 19), 172 - CLKGEN_FIELD(0x0, 0x1, 20), 173 - CLKGEN_FIELD(0x0, 0x1, 21) }, 174 - .mdiv = { CLKGEN_FIELD(0x4, 0x1f, 0), 175 - CLKGEN_FIELD(0x14, 0x1f, 0), 176 - CLKGEN_FIELD(0x24, 0x1f, 0), 177 - CLKGEN_FIELD(0x34, 0x1f, 0) }, 178 - .en = { CLKGEN_FIELD(0x10, 0x1, 0), 179 - CLKGEN_FIELD(0x20, 0x1, 0), 180 - CLKGEN_FIELD(0x30, 0x1, 0), 181 - CLKGEN_FIELD(0x40, 0x1, 0) }, 182 - .ndiv = CLKGEN_FIELD(0x0, 0x1, 15), 183 - .bwfilter_present = true, 184 - .ref_bw = CLKGEN_FIELD(0x0, 0x3, 16), 185 - .pe = { CLKGEN_FIELD(0x8, 0xffff, 0), 186 - CLKGEN_FIELD(0x18, 0xffff, 0), 187 - CLKGEN_FIELD(0x28, 0xffff, 0), 188 - CLKGEN_FIELD(0x38, 0xffff, 0) }, 189 - .sdiv = { CLKGEN_FIELD(0xC, 0x7, 0), 190 - CLKGEN_FIELD(0x1C, 0x7, 0), 191 - CLKGEN_FIELD(0x2C, 0x7, 0), 192 - CLKGEN_FIELD(0x3C, 0x7, 0) }, 193 - .pll_ops = &st_quadfs_pll_c65_ops, 194 - .rtbl = fs432c65_rtbl, 195 - .rtbl_cnt = ARRAY_SIZE(fs432c65_rtbl), 196 - .get_rate = clk_fs432c65_get_rate, 197 - }; 198 - 199 - static const struct clkgen_quadfs_data st_fs660c32_E_416 = { 200 - .npda = CLKGEN_FIELD(0x0, 0x1, 14), 201 - .nsb = { CLKGEN_FIELD(0x0, 0x1, 10), 202 - CLKGEN_FIELD(0x0, 0x1, 11), 203 - CLKGEN_FIELD(0x0, 0x1, 12), 204 - CLKGEN_FIELD(0x0, 0x1, 13) }, 205 - .nsdiv_present = true, 206 - .nsdiv = { CLKGEN_FIELD(0x0, 0x1, 18), 207 - CLKGEN_FIELD(0x0, 0x1, 19), 208 - CLKGEN_FIELD(0x0, 0x1, 20), 209 - CLKGEN_FIELD(0x0, 0x1, 21) }, 210 - .mdiv = { CLKGEN_FIELD(0x4, 0x1f, 0), 211 - CLKGEN_FIELD(0x14, 0x1f, 0), 212 - CLKGEN_FIELD(0x24, 0x1f, 0), 213 - CLKGEN_FIELD(0x34, 0x1f, 0) }, 214 - .en = { CLKGEN_FIELD(0x10, 0x1, 0), 215 - CLKGEN_FIELD(0x20, 0x1, 0), 216 - CLKGEN_FIELD(0x30, 0x1, 0), 217 - CLKGEN_FIELD(0x40, 0x1, 0) }, 218 - .ndiv = CLKGEN_FIELD(0x0, 0x7, 15), 219 - .pe = { CLKGEN_FIELD(0x8, 0x7fff, 0), 220 - CLKGEN_FIELD(0x18, 0x7fff, 0), 221 - CLKGEN_FIELD(0x28, 0x7fff, 0), 222 - CLKGEN_FIELD(0x38, 0x7fff, 0) }, 223 - .sdiv = { CLKGEN_FIELD(0xC, 0xf, 0), 224 - CLKGEN_FIELD(0x1C, 0xf, 0), 225 - CLKGEN_FIELD(0x2C, 0xf, 0), 226 - CLKGEN_FIELD(0x3C, 0xf, 0) }, 227 - .lockstatus_present = true, 228 - .lock_status = CLKGEN_FIELD(0xAC, 0x1, 0), 229 - .pll_ops = &st_quadfs_pll_c32_ops, 230 - .rtbl = fs660c32_rtbl, 231 - .rtbl_cnt = ARRAY_SIZE(fs660c32_rtbl), 232 - .get_rate = clk_fs660c32_dig_get_rate, 233 - }; 234 - 235 - static const struct clkgen_quadfs_data st_fs660c32_F_416 = { 236 - .npda = CLKGEN_FIELD(0x0, 0x1, 14), 237 - .nsb = { CLKGEN_FIELD(0x0, 0x1, 10), 238 - CLKGEN_FIELD(0x0, 0x1, 11), 239 - CLKGEN_FIELD(0x0, 0x1, 12), 240 - CLKGEN_FIELD(0x0, 0x1, 13) }, 241 - .nsdiv_present = true, 242 - .nsdiv = { CLKGEN_FIELD(0x0, 0x1, 18), 243 - CLKGEN_FIELD(0x0, 0x1, 19), 244 - CLKGEN_FIELD(0x0, 0x1, 20), 245 - CLKGEN_FIELD(0x0, 0x1, 21) }, 246 - .mdiv = { CLKGEN_FIELD(0x4, 0x1f, 0), 247 - CLKGEN_FIELD(0x14, 0x1f, 0), 248 - CLKGEN_FIELD(0x24, 0x1f, 0), 249 - CLKGEN_FIELD(0x34, 0x1f, 0) }, 250 - .en = { CLKGEN_FIELD(0x10, 0x1, 0), 251 - CLKGEN_FIELD(0x20, 0x1, 0), 252 - CLKGEN_FIELD(0x30, 0x1, 0), 253 - CLKGEN_FIELD(0x40, 0x1, 0) }, 254 - .ndiv = CLKGEN_FIELD(0x0, 0x7, 15), 255 - .pe = { CLKGEN_FIELD(0x8, 0x7fff, 0), 256 - CLKGEN_FIELD(0x18, 0x7fff, 0), 257 - CLKGEN_FIELD(0x28, 0x7fff, 0), 258 - CLKGEN_FIELD(0x38, 0x7fff, 0) }, 259 - .sdiv = { CLKGEN_FIELD(0xC, 0xf, 0), 260 - CLKGEN_FIELD(0x1C, 0xf, 0), 261 - CLKGEN_FIELD(0x2C, 0xf, 0), 262 - CLKGEN_FIELD(0x3C, 0xf, 0) }, 263 - .lockstatus_present = true, 264 - .lock_status = CLKGEN_FIELD(0xEC, 0x1, 0), 265 - .pll_ops = &st_quadfs_pll_c32_ops, 266 - .rtbl = fs660c32_rtbl, 267 - .rtbl_cnt = ARRAY_SIZE(fs660c32_rtbl), 268 - .get_rate = clk_fs660c32_dig_get_rate, 269 - }; 270 152 271 153 static const struct clkgen_quadfs_data st_fs660c32_C = { 272 154 .nrst_present = true, ··· 409 605 return 0; 410 606 } 411 607 412 - static const struct clk_ops st_quadfs_pll_c65_ops = { 413 - .enable = quadfs_pll_enable, 414 - .disable = quadfs_pll_disable, 415 - .is_enabled = quadfs_pll_is_enabled, 416 - }; 417 - 418 608 static const struct clk_ops st_quadfs_pll_c32_ops = { 419 609 .enable = quadfs_pll_enable, 420 610 .disable = quadfs_pll_disable, ··· 593 795 __func__, clk_hw_get_name(hw), nsb); 594 796 595 797 return fs->data->standby_polarity ? !nsb : !!nsb; 596 - } 597 - 598 - #define P15 (uint64_t)(1 << 15) 599 - 600 - static int clk_fs216c65_get_rate(unsigned long input, const struct stm_fs *fs, 601 - unsigned long *rate) 602 - { 603 - uint64_t res; 604 - unsigned long ns; 605 - unsigned long nd = 8; /* ndiv stuck at 0 => val = 8 */ 606 - unsigned long s; 607 - long m; 608 - 609 - m = fs->mdiv - 32; 610 - s = 1 << (fs->sdiv + 1); 611 - ns = (fs->nsdiv ? 1 : 3); 612 - 613 - res = (uint64_t)(s * ns * P15 * (uint64_t)(m + 33)); 614 - res = res - (s * ns * fs->pe); 615 - *rate = div64_u64(P15 * nd * input * 32, res); 616 - 617 - return 0; 618 - } 619 - 620 - static int clk_fs432c65_get_rate(unsigned long input, const struct stm_fs *fs, 621 - unsigned long *rate) 622 - { 623 - uint64_t res; 624 - unsigned long nd = 16; /* ndiv value; stuck at 0 (30Mhz input) */ 625 - long m; 626 - unsigned long sd; 627 - unsigned long ns; 628 - 629 - m = fs->mdiv - 32; 630 - sd = 1 << (fs->sdiv + 1); 631 - ns = (fs->nsdiv ? 1 : 3); 632 - 633 - res = (uint64_t)(sd * ns * P15 * (uint64_t)(m + 33)); 634 - res = res - (sd * ns * fs->pe); 635 - *rate = div64_u64(P15 * nd * input * 32, res); 636 - 637 - return 0; 638 798 } 639 799 640 800 #define P20 (uint64_t)(1 << 20) ··· 820 1064 } 821 1065 822 1066 static const struct of_device_id quadfs_of_match[] = { 823 - { 824 - .compatible = "st,stih416-quadfs216", 825 - .data = &st_fs216c65_416 826 - }, 827 - { 828 - .compatible = "st,stih416-quadfs432", 829 - .data = &st_fs432c65_416 830 - }, 831 - { 832 - .compatible = "st,stih416-quadfs660-E", 833 - .data = &st_fs660c32_E_416 834 - }, 835 - { 836 - .compatible = "st,stih416-quadfs660-F", 837 - .data = &st_fs660c32_F_416 838 - }, 839 1067 { 840 1068 .compatible = "st,stih407-quadfs660-C", 841 1069 .data = &st_fs660c32_C
+1 -725
drivers/clk/st/clkgen-mux.c
··· 19 19 #include <linux/clk-provider.h> 20 20 #include "clkgen.h" 21 21 22 - static DEFINE_SPINLOCK(clkgena_divmux_lock); 23 - static DEFINE_SPINLOCK(clkgenf_lock); 24 - 25 22 static const char ** __init clkgen_mux_get_parents(struct device_node *np, 26 23 int *num_parents) 27 24 { ··· 37 40 return parents; 38 41 } 39 42 40 - /** 41 - * DOC: Clock mux with a programmable divider on each of its three inputs. 42 - * The mux has an input setting which effectively gates its output. 43 - * 44 - * Traits of this clock: 45 - * prepare - clk_(un)prepare only ensures parent is (un)prepared 46 - * enable - clk_enable and clk_disable are functional & control gating 47 - * rate - set rate is supported 48 - * parent - set/get parent 49 - */ 50 - 51 - #define NUM_INPUTS 3 52 - 53 - struct clkgena_divmux { 54 - struct clk_hw hw; 55 - /* Subclassed mux and divider structures */ 56 - struct clk_mux mux; 57 - struct clk_divider div[NUM_INPUTS]; 58 - /* Enable/running feedback register bits for each input */ 59 - void __iomem *feedback_reg[NUM_INPUTS]; 60 - int feedback_bit_idx; 61 - 62 - u8 muxsel; 63 - }; 64 - 65 - #define to_clkgena_divmux(_hw) container_of(_hw, struct clkgena_divmux, hw) 66 - 67 - struct clkgena_divmux_data { 68 - int num_outputs; 69 - int mux_offset; 70 - int mux_offset2; 71 - int mux_start_bit; 72 - int div_offsets[NUM_INPUTS]; 73 - int fb_offsets[NUM_INPUTS]; 74 - int fb_start_bit_idx; 75 - }; 76 - 77 - #define CKGAX_CLKOPSRC_SWITCH_OFF 0x3 78 - 79 - static int clkgena_divmux_is_running(struct clkgena_divmux *mux) 80 - { 81 - u32 regval = readl(mux->feedback_reg[mux->muxsel]); 82 - u32 running = regval & BIT(mux->feedback_bit_idx); 83 - return !!running; 84 - } 85 - 86 - static int clkgena_divmux_enable(struct clk_hw *hw) 87 - { 88 - struct clkgena_divmux *genamux = to_clkgena_divmux(hw); 89 - struct clk_hw *mux_hw = &genamux->mux.hw; 90 - unsigned long timeout; 91 - int ret = 0; 92 - 93 - __clk_hw_set_clk(mux_hw, hw); 94 - 95 - ret = clk_mux_ops.set_parent(mux_hw, genamux->muxsel); 96 - if (ret) 97 - return ret; 98 - 99 - timeout = jiffies + msecs_to_jiffies(10); 100 - 101 - while (!clkgena_divmux_is_running(genamux)) { 102 - if (time_after(jiffies, timeout)) 103 - return -ETIMEDOUT; 104 - cpu_relax(); 105 - } 106 - 107 - return 0; 108 - } 109 - 110 - static void clkgena_divmux_disable(struct clk_hw *hw) 111 - { 112 - struct clkgena_divmux *genamux = to_clkgena_divmux(hw); 113 - struct clk_hw *mux_hw = &genamux->mux.hw; 114 - 115 - __clk_hw_set_clk(mux_hw, hw); 116 - 117 - clk_mux_ops.set_parent(mux_hw, CKGAX_CLKOPSRC_SWITCH_OFF); 118 - } 119 - 120 - static int clkgena_divmux_is_enabled(struct clk_hw *hw) 121 - { 122 - struct clkgena_divmux *genamux = to_clkgena_divmux(hw); 123 - struct clk_hw *mux_hw = &genamux->mux.hw; 124 - 125 - __clk_hw_set_clk(mux_hw, hw); 126 - 127 - return (s8)clk_mux_ops.get_parent(mux_hw) > 0; 128 - } 129 - 130 - static u8 clkgena_divmux_get_parent(struct clk_hw *hw) 131 - { 132 - struct clkgena_divmux *genamux = to_clkgena_divmux(hw); 133 - struct clk_hw *mux_hw = &genamux->mux.hw; 134 - 135 - __clk_hw_set_clk(mux_hw, hw); 136 - 137 - genamux->muxsel = clk_mux_ops.get_parent(mux_hw); 138 - if ((s8)genamux->muxsel < 0) { 139 - pr_debug("%s: %s: Invalid parent, setting to default.\n", 140 - __func__, clk_hw_get_name(hw)); 141 - genamux->muxsel = 0; 142 - } 143 - 144 - return genamux->muxsel; 145 - } 146 - 147 - static int clkgena_divmux_set_parent(struct clk_hw *hw, u8 index) 148 - { 149 - struct clkgena_divmux *genamux = to_clkgena_divmux(hw); 150 - 151 - if (index >= CKGAX_CLKOPSRC_SWITCH_OFF) 152 - return -EINVAL; 153 - 154 - genamux->muxsel = index; 155 - 156 - /* 157 - * If the mux is already enabled, call enable directly to set the 158 - * new mux position and wait for it to start running again. Otherwise 159 - * do nothing. 160 - */ 161 - if (clkgena_divmux_is_enabled(hw)) 162 - clkgena_divmux_enable(hw); 163 - 164 - return 0; 165 - } 166 - 167 - static unsigned long clkgena_divmux_recalc_rate(struct clk_hw *hw, 168 - unsigned long parent_rate) 169 - { 170 - struct clkgena_divmux *genamux = to_clkgena_divmux(hw); 171 - struct clk_hw *div_hw = &genamux->div[genamux->muxsel].hw; 172 - 173 - __clk_hw_set_clk(div_hw, hw); 174 - 175 - return clk_divider_ops.recalc_rate(div_hw, parent_rate); 176 - } 177 - 178 - static int clkgena_divmux_set_rate(struct clk_hw *hw, unsigned long rate, 179 - unsigned long parent_rate) 180 - { 181 - struct clkgena_divmux *genamux = to_clkgena_divmux(hw); 182 - struct clk_hw *div_hw = &genamux->div[genamux->muxsel].hw; 183 - 184 - __clk_hw_set_clk(div_hw, hw); 185 - 186 - return clk_divider_ops.set_rate(div_hw, rate, parent_rate); 187 - } 188 - 189 - static long clkgena_divmux_round_rate(struct clk_hw *hw, unsigned long rate, 190 - unsigned long *prate) 191 - { 192 - struct clkgena_divmux *genamux = to_clkgena_divmux(hw); 193 - struct clk_hw *div_hw = &genamux->div[genamux->muxsel].hw; 194 - 195 - __clk_hw_set_clk(div_hw, hw); 196 - 197 - return clk_divider_ops.round_rate(div_hw, rate, prate); 198 - } 199 - 200 - static const struct clk_ops clkgena_divmux_ops = { 201 - .enable = clkgena_divmux_enable, 202 - .disable = clkgena_divmux_disable, 203 - .is_enabled = clkgena_divmux_is_enabled, 204 - .get_parent = clkgena_divmux_get_parent, 205 - .set_parent = clkgena_divmux_set_parent, 206 - .round_rate = clkgena_divmux_round_rate, 207 - .recalc_rate = clkgena_divmux_recalc_rate, 208 - .set_rate = clkgena_divmux_set_rate, 209 - }; 210 - 211 - /** 212 - * clk_register_genamux - register a genamux clock with the clock framework 213 - */ 214 - static struct clk * __init clk_register_genamux(const char *name, 215 - const char **parent_names, u8 num_parents, 216 - void __iomem *reg, 217 - const struct clkgena_divmux_data *muxdata, 218 - u32 idx) 219 - { 220 - /* 221 - * Fixed constants across all ClockgenA variants 222 - */ 223 - const int mux_width = 2; 224 - const int divider_width = 5; 225 - struct clkgena_divmux *genamux; 226 - struct clk *clk; 227 - struct clk_init_data init; 228 - int i; 229 - 230 - genamux = kzalloc(sizeof(*genamux), GFP_KERNEL); 231 - if (!genamux) 232 - return ERR_PTR(-ENOMEM); 233 - 234 - init.name = name; 235 - init.ops = &clkgena_divmux_ops; 236 - init.flags = CLK_IS_BASIC | CLK_GET_RATE_NOCACHE; 237 - init.parent_names = parent_names; 238 - init.num_parents = num_parents; 239 - 240 - genamux->mux.lock = &clkgena_divmux_lock; 241 - genamux->mux.mask = BIT(mux_width) - 1; 242 - genamux->mux.shift = muxdata->mux_start_bit + (idx * mux_width); 243 - if (genamux->mux.shift > 31) { 244 - /* 245 - * We have spilled into the second mux register so 246 - * adjust the register address and the bit shift accordingly 247 - */ 248 - genamux->mux.reg = reg + muxdata->mux_offset2; 249 - genamux->mux.shift -= 32; 250 - } else { 251 - genamux->mux.reg = reg + muxdata->mux_offset; 252 - } 253 - 254 - for (i = 0; i < NUM_INPUTS; i++) { 255 - /* 256 - * Divider config for each input 257 - */ 258 - void __iomem *divbase = reg + muxdata->div_offsets[i]; 259 - genamux->div[i].width = divider_width; 260 - genamux->div[i].reg = divbase + (idx * sizeof(u32)); 261 - 262 - /* 263 - * Mux enabled/running feedback register for each input. 264 - */ 265 - genamux->feedback_reg[i] = reg + muxdata->fb_offsets[i]; 266 - } 267 - 268 - genamux->feedback_bit_idx = muxdata->fb_start_bit_idx + idx; 269 - genamux->hw.init = &init; 270 - 271 - clk = clk_register(NULL, &genamux->hw); 272 - if (IS_ERR(clk)) { 273 - kfree(genamux); 274 - goto err; 275 - } 276 - 277 - pr_debug("%s: parent %s rate %lu\n", 278 - __clk_get_name(clk), 279 - __clk_get_name(clk_get_parent(clk)), 280 - clk_get_rate(clk)); 281 - err: 282 - return clk; 283 - } 284 - 285 - static struct clkgena_divmux_data st_divmux_c65hs = { 286 - .num_outputs = 4, 287 - .mux_offset = 0x14, 288 - .mux_start_bit = 0, 289 - .div_offsets = { 0x800, 0x900, 0xb00 }, 290 - .fb_offsets = { 0x18, 0x1c, 0x20 }, 291 - .fb_start_bit_idx = 0, 292 - }; 293 - 294 - static struct clkgena_divmux_data st_divmux_c65ls = { 295 - .num_outputs = 14, 296 - .mux_offset = 0x14, 297 - .mux_offset2 = 0x24, 298 - .mux_start_bit = 8, 299 - .div_offsets = { 0x810, 0xa10, 0xb10 }, 300 - .fb_offsets = { 0x18, 0x1c, 0x20 }, 301 - .fb_start_bit_idx = 4, 302 - }; 303 - 304 - static struct clkgena_divmux_data st_divmux_c32odf0 = { 305 - .num_outputs = 8, 306 - .mux_offset = 0x1c, 307 - .mux_start_bit = 0, 308 - .div_offsets = { 0x800, 0x900, 0xa60 }, 309 - .fb_offsets = { 0x2c, 0x24, 0x28 }, 310 - .fb_start_bit_idx = 0, 311 - }; 312 - 313 - static struct clkgena_divmux_data st_divmux_c32odf1 = { 314 - .num_outputs = 8, 315 - .mux_offset = 0x1c, 316 - .mux_start_bit = 16, 317 - .div_offsets = { 0x820, 0x980, 0xa80 }, 318 - .fb_offsets = { 0x2c, 0x24, 0x28 }, 319 - .fb_start_bit_idx = 8, 320 - }; 321 - 322 - static struct clkgena_divmux_data st_divmux_c32odf2 = { 323 - .num_outputs = 8, 324 - .mux_offset = 0x20, 325 - .mux_start_bit = 0, 326 - .div_offsets = { 0x840, 0xa20, 0xb10 }, 327 - .fb_offsets = { 0x2c, 0x24, 0x28 }, 328 - .fb_start_bit_idx = 16, 329 - }; 330 - 331 - static struct clkgena_divmux_data st_divmux_c32odf3 = { 332 - .num_outputs = 8, 333 - .mux_offset = 0x20, 334 - .mux_start_bit = 16, 335 - .div_offsets = { 0x860, 0xa40, 0xb30 }, 336 - .fb_offsets = { 0x2c, 0x24, 0x28 }, 337 - .fb_start_bit_idx = 24, 338 - }; 339 - 340 - static const struct of_device_id clkgena_divmux_of_match[] = { 341 - { 342 - .compatible = "st,clkgena-divmux-c65-hs", 343 - .data = &st_divmux_c65hs, 344 - }, 345 - { 346 - .compatible = "st,clkgena-divmux-c65-ls", 347 - .data = &st_divmux_c65ls, 348 - }, 349 - { 350 - .compatible = "st,clkgena-divmux-c32-odf0", 351 - .data = &st_divmux_c32odf0, 352 - }, 353 - { 354 - .compatible = "st,clkgena-divmux-c32-odf1", 355 - .data = &st_divmux_c32odf1, 356 - }, 357 - { 358 - .compatible = "st,clkgena-divmux-c32-odf2", 359 - .data = &st_divmux_c32odf2, 360 - }, 361 - { 362 - .compatible = "st,clkgena-divmux-c32-odf3", 363 - .data = &st_divmux_c32odf3, 364 - }, 365 - {} 366 - }; 367 - 368 - static void __iomem * __init clkgen_get_register_base(struct device_node *np) 369 - { 370 - struct device_node *pnode; 371 - void __iomem *reg; 372 - 373 - pnode = of_get_parent(np); 374 - if (!pnode) 375 - return NULL; 376 - 377 - reg = of_iomap(pnode, 0); 378 - 379 - of_node_put(pnode); 380 - return reg; 381 - } 382 - 383 - static void __init st_of_clkgena_divmux_setup(struct device_node *np) 384 - { 385 - const struct of_device_id *match; 386 - const struct clkgena_divmux_data *data; 387 - struct clk_onecell_data *clk_data; 388 - void __iomem *reg; 389 - const char **parents; 390 - int num_parents = 0, i; 391 - 392 - match = of_match_node(clkgena_divmux_of_match, np); 393 - if (WARN_ON(!match)) 394 - return; 395 - 396 - data = match->data; 397 - 398 - reg = clkgen_get_register_base(np); 399 - if (!reg) 400 - return; 401 - 402 - parents = clkgen_mux_get_parents(np, &num_parents); 403 - if (IS_ERR(parents)) 404 - goto err_parents; 405 - 406 - clk_data = kzalloc(sizeof(*clk_data), GFP_KERNEL); 407 - if (!clk_data) 408 - goto err_alloc; 409 - 410 - clk_data->clk_num = data->num_outputs; 411 - clk_data->clks = kcalloc(clk_data->clk_num, sizeof(struct clk *), 412 - GFP_KERNEL); 413 - 414 - if (!clk_data->clks) 415 - goto err_alloc_clks; 416 - 417 - for (i = 0; i < clk_data->clk_num; i++) { 418 - struct clk *clk; 419 - const char *clk_name; 420 - 421 - if (of_property_read_string_index(np, "clock-output-names", 422 - i, &clk_name)) 423 - break; 424 - 425 - /* 426 - * If we read an empty clock name then the output is unused 427 - */ 428 - if (*clk_name == '\0') 429 - continue; 430 - 431 - clk = clk_register_genamux(clk_name, parents, num_parents, 432 - reg, data, i); 433 - 434 - if (IS_ERR(clk)) 435 - goto err; 436 - 437 - clk_data->clks[i] = clk; 438 - } 439 - 440 - kfree(parents); 441 - 442 - of_clk_add_provider(np, of_clk_src_onecell_get, clk_data); 443 - return; 444 - err: 445 - kfree(clk_data->clks); 446 - err_alloc_clks: 447 - kfree(clk_data); 448 - err_alloc: 449 - kfree(parents); 450 - err_parents: 451 - iounmap(reg); 452 - } 453 - CLK_OF_DECLARE(clkgenadivmux, "st,clkgena-divmux", st_of_clkgena_divmux_setup); 454 - 455 - struct clkgena_prediv_data { 456 - u32 offset; 457 - u8 shift; 458 - struct clk_div_table *table; 459 - }; 460 - 461 - static struct clk_div_table prediv_table16[] = { 462 - { .val = 0, .div = 1 }, 463 - { .val = 1, .div = 16 }, 464 - { .div = 0 }, 465 - }; 466 - 467 - static struct clkgena_prediv_data prediv_c65_data = { 468 - .offset = 0x4c, 469 - .shift = 31, 470 - .table = prediv_table16, 471 - }; 472 - 473 - static struct clkgena_prediv_data prediv_c32_data = { 474 - .offset = 0x50, 475 - .shift = 1, 476 - .table = prediv_table16, 477 - }; 478 - 479 - static const struct of_device_id clkgena_prediv_of_match[] = { 480 - { .compatible = "st,clkgena-prediv-c65", .data = &prediv_c65_data }, 481 - { .compatible = "st,clkgena-prediv-c32", .data = &prediv_c32_data }, 482 - {} 483 - }; 484 - 485 - static void __init st_of_clkgena_prediv_setup(struct device_node *np) 486 - { 487 - const struct of_device_id *match; 488 - void __iomem *reg; 489 - const char *parent_name, *clk_name; 490 - struct clk *clk; 491 - const struct clkgena_prediv_data *data; 492 - 493 - match = of_match_node(clkgena_prediv_of_match, np); 494 - if (!match) { 495 - pr_err("%s: No matching data\n", __func__); 496 - return; 497 - } 498 - 499 - data = match->data; 500 - 501 - reg = clkgen_get_register_base(np); 502 - if (!reg) 503 - return; 504 - 505 - parent_name = of_clk_get_parent_name(np, 0); 506 - if (!parent_name) 507 - goto err; 508 - 509 - if (of_property_read_string_index(np, "clock-output-names", 510 - 0, &clk_name)) 511 - goto err; 512 - 513 - clk = clk_register_divider_table(NULL, clk_name, parent_name, 514 - CLK_GET_RATE_NOCACHE, 515 - reg + data->offset, data->shift, 1, 516 - 0, data->table, NULL); 517 - if (IS_ERR(clk)) 518 - goto err; 519 - 520 - of_clk_add_provider(np, of_clk_src_simple_get, clk); 521 - pr_debug("%s: parent %s rate %u\n", 522 - __clk_get_name(clk), 523 - __clk_get_name(clk_get_parent(clk)), 524 - (unsigned int)clk_get_rate(clk)); 525 - 526 - return; 527 - err: 528 - iounmap(reg); 529 - } 530 - CLK_OF_DECLARE(clkgenaprediv, "st,clkgena-prediv", st_of_clkgena_prediv_setup); 531 - 532 43 struct clkgen_mux_data { 533 44 u32 offset; 534 45 u8 shift; ··· 46 541 u8 mux_flags; 47 542 }; 48 543 49 - static struct clkgen_mux_data clkgen_mux_c_vcc_hd_416 = { 50 - .offset = 0, 51 - .shift = 0, 52 - .width = 1, 53 - }; 54 - 55 - static struct clkgen_mux_data clkgen_mux_f_vcc_fvdp_416 = { 56 - .offset = 0, 57 - .shift = 0, 58 - .width = 1, 59 - }; 60 - 61 - static struct clkgen_mux_data clkgen_mux_f_vcc_hva_416 = { 62 - .offset = 0, 63 - .shift = 0, 64 - .width = 1, 65 - }; 66 - 67 - static struct clkgen_mux_data clkgen_mux_f_vcc_hd_416 = { 68 - .offset = 0, 69 - .shift = 16, 70 - .width = 1, 71 - .lock = &clkgenf_lock, 72 - }; 73 - 74 - static struct clkgen_mux_data clkgen_mux_c_vcc_sd_416 = { 75 - .offset = 0, 76 - .shift = 17, 77 - .width = 1, 78 - .lock = &clkgenf_lock, 79 - }; 80 - 81 - static struct clkgen_mux_data stih415_a9_mux_data = { 82 - .offset = 0, 83 - .shift = 1, 84 - .width = 2, 85 - .lock = &clkgen_a9_lock, 86 - }; 87 - static struct clkgen_mux_data stih416_a9_mux_data = { 88 - .offset = 0, 89 - .shift = 0, 90 - .width = 2, 91 - }; 92 544 static struct clkgen_mux_data stih407_a9_mux_data = { 93 545 .offset = 0x1a4, 94 546 .shift = 0, ··· 55 593 56 594 static const struct of_device_id mux_of_match[] = { 57 595 { 58 - .compatible = "st,stih416-clkgenc-vcc-hd", 59 - .data = &clkgen_mux_c_vcc_hd_416, 60 - }, 61 - { 62 - .compatible = "st,stih416-clkgenf-vcc-fvdp", 63 - .data = &clkgen_mux_f_vcc_fvdp_416, 64 - }, 65 - { 66 - .compatible = "st,stih416-clkgenf-vcc-hva", 67 - .data = &clkgen_mux_f_vcc_hva_416, 68 - }, 69 - { 70 - .compatible = "st,stih416-clkgenf-vcc-hd", 71 - .data = &clkgen_mux_f_vcc_hd_416, 72 - }, 73 - { 74 - .compatible = "st,stih416-clkgenf-vcc-sd", 75 - .data = &clkgen_mux_c_vcc_sd_416, 76 - }, 77 - { 78 - .compatible = "st,stih415-clkgen-a9-mux", 79 - .data = &stih415_a9_mux_data, 80 - }, 81 - { 82 - .compatible = "st,stih416-clkgen-a9-mux", 83 - .data = &stih416_a9_mux_data, 84 - }, 85 - { 86 596 .compatible = "st,stih407-clkgen-a9-mux", 87 597 .data = &stih407_a9_mux_data, 88 598 }, 89 599 {} 90 600 }; 91 - 92 601 static void __init st_of_clkgen_mux_setup(struct device_node *np) 93 602 { 94 603 const struct of_device_id *match; 95 604 struct clk *clk; 96 605 void __iomem *reg; 97 606 const char **parents; 98 - int num_parents; 607 + int num_parents = 0; 99 608 const struct clkgen_mux_data *data; 100 609 101 610 match = of_match_node(mux_of_match, np); ··· 113 680 iounmap(reg); 114 681 } 115 682 CLK_OF_DECLARE(clkgen_mux, "st,clkgen-mux", st_of_clkgen_mux_setup); 116 - 117 - #define VCC_MAX_CHANNELS 16 118 - 119 - #define VCC_GATE_OFFSET 0x0 120 - #define VCC_MUX_OFFSET 0x4 121 - #define VCC_DIV_OFFSET 0x8 122 - 123 - struct clkgen_vcc_data { 124 - spinlock_t *lock; 125 - unsigned long clk_flags; 126 - }; 127 - 128 - static struct clkgen_vcc_data st_clkgenc_vcc_416 = { 129 - .clk_flags = CLK_SET_RATE_PARENT, 130 - }; 131 - 132 - static struct clkgen_vcc_data st_clkgenf_vcc_416 = { 133 - .lock = &clkgenf_lock, 134 - }; 135 - 136 - static const struct of_device_id vcc_of_match[] = { 137 - { .compatible = "st,stih416-clkgenc", .data = &st_clkgenc_vcc_416 }, 138 - { .compatible = "st,stih416-clkgenf", .data = &st_clkgenf_vcc_416 }, 139 - {} 140 - }; 141 - 142 - static void __init st_of_clkgen_vcc_setup(struct device_node *np) 143 - { 144 - const struct of_device_id *match; 145 - void __iomem *reg; 146 - const char **parents; 147 - int num_parents, i; 148 - struct clk_onecell_data *clk_data; 149 - const struct clkgen_vcc_data *data; 150 - 151 - match = of_match_node(vcc_of_match, np); 152 - if (WARN_ON(!match)) 153 - return; 154 - data = match->data; 155 - 156 - reg = of_iomap(np, 0); 157 - if (!reg) 158 - return; 159 - 160 - parents = clkgen_mux_get_parents(np, &num_parents); 161 - if (IS_ERR(parents)) 162 - goto err_parents; 163 - 164 - clk_data = kzalloc(sizeof(*clk_data), GFP_KERNEL); 165 - if (!clk_data) 166 - goto err_alloc; 167 - 168 - clk_data->clk_num = VCC_MAX_CHANNELS; 169 - clk_data->clks = kcalloc(clk_data->clk_num, sizeof(struct clk *), 170 - GFP_KERNEL); 171 - 172 - if (!clk_data->clks) 173 - goto err_alloc_clks; 174 - 175 - for (i = 0; i < clk_data->clk_num; i++) { 176 - struct clk *clk; 177 - const char *clk_name; 178 - struct clk_gate *gate; 179 - struct clk_divider *div; 180 - struct clk_mux *mux; 181 - 182 - if (of_property_read_string_index(np, "clock-output-names", 183 - i, &clk_name)) 184 - break; 185 - 186 - /* 187 - * If we read an empty clock name then the output is unused 188 - */ 189 - if (*clk_name == '\0') 190 - continue; 191 - 192 - gate = kzalloc(sizeof(*gate), GFP_KERNEL); 193 - if (!gate) 194 - goto err; 195 - 196 - div = kzalloc(sizeof(*div), GFP_KERNEL); 197 - if (!div) { 198 - kfree(gate); 199 - goto err; 200 - } 201 - 202 - mux = kzalloc(sizeof(*mux), GFP_KERNEL); 203 - if (!mux) { 204 - kfree(gate); 205 - kfree(div); 206 - goto err; 207 - } 208 - 209 - gate->reg = reg + VCC_GATE_OFFSET; 210 - gate->bit_idx = i; 211 - gate->flags = CLK_GATE_SET_TO_DISABLE; 212 - gate->lock = data->lock; 213 - 214 - div->reg = reg + VCC_DIV_OFFSET; 215 - div->shift = 2 * i; 216 - div->width = 2; 217 - div->flags = CLK_DIVIDER_POWER_OF_TWO | 218 - CLK_DIVIDER_ROUND_CLOSEST; 219 - 220 - mux->reg = reg + VCC_MUX_OFFSET; 221 - mux->shift = 2 * i; 222 - mux->mask = 0x3; 223 - 224 - clk = clk_register_composite(NULL, clk_name, parents, 225 - num_parents, 226 - &mux->hw, &clk_mux_ops, 227 - &div->hw, &clk_divider_ops, 228 - &gate->hw, &clk_gate_ops, 229 - data->clk_flags | 230 - CLK_GET_RATE_NOCACHE); 231 - if (IS_ERR(clk)) { 232 - kfree(gate); 233 - kfree(div); 234 - kfree(mux); 235 - goto err; 236 - } 237 - 238 - pr_debug("%s: parent %s rate %u\n", 239 - __clk_get_name(clk), 240 - __clk_get_name(clk_get_parent(clk)), 241 - (unsigned int)clk_get_rate(clk)); 242 - 243 - clk_data->clks[i] = clk; 244 - } 245 - 246 - kfree(parents); 247 - 248 - of_clk_add_provider(np, of_clk_src_onecell_get, clk_data); 249 - return; 250 - 251 - err: 252 - for (i = 0; i < clk_data->clk_num; i++) { 253 - struct clk_composite *composite; 254 - 255 - if (!clk_data->clks[i]) 256 - continue; 257 - 258 - composite = to_clk_composite(__clk_get_hw(clk_data->clks[i])); 259 - kfree(to_clk_gate(composite->gate_hw)); 260 - kfree(to_clk_divider(composite->rate_hw)); 261 - kfree(to_clk_mux(composite->mux_hw)); 262 - } 263 - 264 - kfree(clk_data->clks); 265 - err_alloc_clks: 266 - kfree(clk_data); 267 - err_alloc: 268 - kfree(parents); 269 - err_parents: 270 - iounmap(reg); 271 - } 272 - CLK_OF_DECLARE(clkgen_vcc, "st,clkgen-vcc", st_of_clkgen_vcc_setup);
-419
drivers/clk/st/clkgen-pll.c
··· 26 26 DEFINE_SPINLOCK(clkgen_a9_lock); 27 27 28 28 /* 29 - * Common PLL configuration register bits for PLL800 and PLL1600 C65 30 - */ 31 - #define C65_MDIV_PLL800_MASK (0xff) 32 - #define C65_MDIV_PLL1600_MASK (0x7) 33 - #define C65_NDIV_MASK (0xff) 34 - #define C65_PDIV_MASK (0x7) 35 - 36 - /* 37 29 * PLL configuration register bits for PLL3200 C32 38 30 */ 39 31 #define C32_NDIV_MASK (0xff) ··· 62 70 const struct clk_ops *ops; 63 71 }; 64 72 65 - static const struct clk_ops st_pll1600c65_ops; 66 - static const struct clk_ops st_pll800c65_ops; 67 73 static const struct clk_ops stm_pll3200c32_ops; 68 74 static const struct clk_ops stm_pll3200c32_a9_ops; 69 - static const struct clk_ops st_pll1200c32_ops; 70 75 static const struct clk_ops stm_pll4600c28_ops; 71 - 72 - static const struct clkgen_pll_data st_pll1600c65_ax = { 73 - .pdn_status = CLKGEN_FIELD(0x0, 0x1, 19), 74 - .pdn_ctrl = CLKGEN_FIELD(0x10, 0x1, 0), 75 - .locked_status = CLKGEN_FIELD(0x0, 0x1, 31), 76 - .mdiv = CLKGEN_FIELD(0x0, C65_MDIV_PLL1600_MASK, 0), 77 - .ndiv = CLKGEN_FIELD(0x0, C65_NDIV_MASK, 8), 78 - .ops = &st_pll1600c65_ops 79 - }; 80 - 81 - static const struct clkgen_pll_data st_pll800c65_ax = { 82 - .pdn_status = CLKGEN_FIELD(0x0, 0x1, 19), 83 - .pdn_ctrl = CLKGEN_FIELD(0xC, 0x1, 1), 84 - .locked_status = CLKGEN_FIELD(0x0, 0x1, 31), 85 - .mdiv = CLKGEN_FIELD(0x0, C65_MDIV_PLL800_MASK, 0), 86 - .ndiv = CLKGEN_FIELD(0x0, C65_NDIV_MASK, 8), 87 - .pdiv = CLKGEN_FIELD(0x0, C65_PDIV_MASK, 16), 88 - .ops = &st_pll800c65_ops 89 - }; 90 - 91 - static const struct clkgen_pll_data st_pll3200c32_a1x_0 = { 92 - .pdn_status = CLKGEN_FIELD(0x0, 0x1, 31), 93 - .pdn_ctrl = CLKGEN_FIELD(0x18, 0x1, 0), 94 - .locked_status = CLKGEN_FIELD(0x4, 0x1, 31), 95 - .ndiv = CLKGEN_FIELD(0x0, C32_NDIV_MASK, 0x0), 96 - .idf = CLKGEN_FIELD(0x4, C32_IDF_MASK, 0x0), 97 - .num_odfs = 4, 98 - .odf = { CLKGEN_FIELD(0x54, C32_ODF_MASK, 4), 99 - CLKGEN_FIELD(0x54, C32_ODF_MASK, 10), 100 - CLKGEN_FIELD(0x54, C32_ODF_MASK, 16), 101 - CLKGEN_FIELD(0x54, C32_ODF_MASK, 22) }, 102 - .odf_gate = { CLKGEN_FIELD(0x54, 0x1, 0), 103 - CLKGEN_FIELD(0x54, 0x1, 1), 104 - CLKGEN_FIELD(0x54, 0x1, 2), 105 - CLKGEN_FIELD(0x54, 0x1, 3) }, 106 - .ops = &stm_pll3200c32_ops, 107 - }; 108 - 109 - static const struct clkgen_pll_data st_pll3200c32_a1x_1 = { 110 - .pdn_status = CLKGEN_FIELD(0xC, 0x1, 31), 111 - .pdn_ctrl = CLKGEN_FIELD(0x18, 0x1, 1), 112 - .locked_status = CLKGEN_FIELD(0x10, 0x1, 31), 113 - .ndiv = CLKGEN_FIELD(0xC, C32_NDIV_MASK, 0x0), 114 - .idf = CLKGEN_FIELD(0x10, C32_IDF_MASK, 0x0), 115 - .num_odfs = 4, 116 - .odf = { CLKGEN_FIELD(0x58, C32_ODF_MASK, 4), 117 - CLKGEN_FIELD(0x58, C32_ODF_MASK, 10), 118 - CLKGEN_FIELD(0x58, C32_ODF_MASK, 16), 119 - CLKGEN_FIELD(0x58, C32_ODF_MASK, 22) }, 120 - .odf_gate = { CLKGEN_FIELD(0x58, 0x1, 0), 121 - CLKGEN_FIELD(0x58, 0x1, 1), 122 - CLKGEN_FIELD(0x58, 0x1, 2), 123 - CLKGEN_FIELD(0x58, 0x1, 3) }, 124 - .ops = &stm_pll3200c32_ops, 125 - }; 126 - 127 - /* 415 specific */ 128 - static const struct clkgen_pll_data st_pll3200c32_a9_415 = { 129 - .pdn_status = CLKGEN_FIELD(0x0, 0x1, 0), 130 - .pdn_ctrl = CLKGEN_FIELD(0x0, 0x1, 0), 131 - .locked_status = CLKGEN_FIELD(0x6C, 0x1, 0), 132 - .ndiv = CLKGEN_FIELD(0x0, C32_NDIV_MASK, 9), 133 - .idf = CLKGEN_FIELD(0x0, C32_IDF_MASK, 22), 134 - .num_odfs = 1, 135 - .odf = { CLKGEN_FIELD(0x0, C32_ODF_MASK, 3) }, 136 - .odf_gate = { CLKGEN_FIELD(0x0, 0x1, 28) }, 137 - .ops = &stm_pll3200c32_ops, 138 - }; 139 - 140 - static const struct clkgen_pll_data st_pll3200c32_ddr_415 = { 141 - .pdn_status = CLKGEN_FIELD(0x0, 0x1, 0), 142 - .pdn_ctrl = CLKGEN_FIELD(0x0, 0x1, 0), 143 - .locked_status = CLKGEN_FIELD(0x100, 0x1, 0), 144 - .ndiv = CLKGEN_FIELD(0x8, C32_NDIV_MASK, 0), 145 - .idf = CLKGEN_FIELD(0x0, C32_IDF_MASK, 25), 146 - .num_odfs = 2, 147 - .odf = { CLKGEN_FIELD(0x8, C32_ODF_MASK, 8), 148 - CLKGEN_FIELD(0x8, C32_ODF_MASK, 14) }, 149 - .odf_gate = { CLKGEN_FIELD(0x4, 0x1, 28), 150 - CLKGEN_FIELD(0x4, 0x1, 29) }, 151 - .ops = &stm_pll3200c32_ops, 152 - }; 153 - 154 - static const struct clkgen_pll_data st_pll1200c32_gpu_415 = { 155 - .pdn_status = CLKGEN_FIELD(0x4, 0x1, 0), 156 - .pdn_ctrl = CLKGEN_FIELD(0x4, 0x1, 0), 157 - .locked_status = CLKGEN_FIELD(0x168, 0x1, 0), 158 - .ldf = CLKGEN_FIELD(0x0, C32_LDF_MASK, 3), 159 - .idf = CLKGEN_FIELD(0x0, C32_IDF_MASK, 0), 160 - .num_odfs = 0, 161 - .odf = { CLKGEN_FIELD(0x0, C32_ODF_MASK, 10) }, 162 - .ops = &st_pll1200c32_ops, 163 - }; 164 - 165 - /* 416 specific */ 166 - static const struct clkgen_pll_data st_pll3200c32_a9_416 = { 167 - .pdn_status = CLKGEN_FIELD(0x0, 0x1, 0), 168 - .pdn_ctrl = CLKGEN_FIELD(0x0, 0x1, 0), 169 - .locked_status = CLKGEN_FIELD(0x6C, 0x1, 0), 170 - .ndiv = CLKGEN_FIELD(0x8, C32_NDIV_MASK, 0), 171 - .idf = CLKGEN_FIELD(0x0, C32_IDF_MASK, 25), 172 - .num_odfs = 1, 173 - .odf = { CLKGEN_FIELD(0x8, C32_ODF_MASK, 8) }, 174 - .odf_gate = { CLKGEN_FIELD(0x4, 0x1, 28) }, 175 - .ops = &stm_pll3200c32_ops, 176 - }; 177 - 178 - static const struct clkgen_pll_data st_pll3200c32_ddr_416 = { 179 - .pdn_status = CLKGEN_FIELD(0x0, 0x1, 0), 180 - .pdn_ctrl = CLKGEN_FIELD(0x0, 0x1, 0), 181 - .locked_status = CLKGEN_FIELD(0x10C, 0x1, 0), 182 - .ndiv = CLKGEN_FIELD(0x8, C32_NDIV_MASK, 0), 183 - .idf = CLKGEN_FIELD(0x0, C32_IDF_MASK, 25), 184 - .num_odfs = 2, 185 - .odf = { CLKGEN_FIELD(0x8, C32_ODF_MASK, 8), 186 - CLKGEN_FIELD(0x8, C32_ODF_MASK, 14) }, 187 - .odf_gate = { CLKGEN_FIELD(0x4, 0x1, 28), 188 - CLKGEN_FIELD(0x4, 0x1, 29) }, 189 - .ops = &stm_pll3200c32_ops, 190 - }; 191 - 192 - static const struct clkgen_pll_data st_pll1200c32_gpu_416 = { 193 - .pdn_status = CLKGEN_FIELD(0x8E4, 0x1, 3), 194 - .pdn_ctrl = CLKGEN_FIELD(0x8E4, 0x1, 3), 195 - .locked_status = CLKGEN_FIELD(0x90C, 0x1, 0), 196 - .ldf = CLKGEN_FIELD(0x0, C32_LDF_MASK, 3), 197 - .idf = CLKGEN_FIELD(0x0, C32_IDF_MASK, 0), 198 - .num_odfs = 0, 199 - .odf = { CLKGEN_FIELD(0x0, C32_ODF_MASK, 10) }, 200 - .ops = &st_pll1200c32_ops, 201 - }; 202 76 203 77 static const struct clkgen_pll_data st_pll3200c32_407_a0 = { 204 78 /* 407 A0 */ ··· 268 410 spin_unlock_irqrestore(pll->lock, flags); 269 411 } 270 412 271 - static unsigned long recalc_stm_pll800c65(struct clk_hw *hw, 272 - unsigned long parent_rate) 273 - { 274 - struct clkgen_pll *pll = to_clkgen_pll(hw); 275 - unsigned long mdiv, ndiv, pdiv; 276 - unsigned long rate; 277 - uint64_t res; 278 - 279 - if (!clkgen_pll_is_enabled(hw) || !clkgen_pll_is_locked(hw)) 280 - return 0; 281 - 282 - pdiv = CLKGEN_READ(pll, pdiv); 283 - mdiv = CLKGEN_READ(pll, mdiv); 284 - ndiv = CLKGEN_READ(pll, ndiv); 285 - 286 - if (!mdiv) 287 - mdiv++; /* mdiv=0 or 1 => MDIV=1 */ 288 - 289 - res = (uint64_t)2 * (uint64_t)parent_rate * (uint64_t)ndiv; 290 - rate = (unsigned long)div64_u64(res, mdiv * (1 << pdiv)); 291 - 292 - pr_debug("%s:%s rate %lu\n", clk_hw_get_name(hw), __func__, rate); 293 - 294 - return rate; 295 - 296 - } 297 - 298 - static unsigned long recalc_stm_pll1600c65(struct clk_hw *hw, 299 - unsigned long parent_rate) 300 - { 301 - struct clkgen_pll *pll = to_clkgen_pll(hw); 302 - unsigned long mdiv, ndiv; 303 - unsigned long rate; 304 - 305 - if (!clkgen_pll_is_enabled(hw) || !clkgen_pll_is_locked(hw)) 306 - return 0; 307 - 308 - mdiv = CLKGEN_READ(pll, mdiv); 309 - ndiv = CLKGEN_READ(pll, ndiv); 310 - 311 - if (!mdiv) 312 - mdiv = 1; 313 - 314 - /* Note: input is divided by 1000 to avoid overflow */ 315 - rate = ((2 * (parent_rate / 1000) * ndiv) / mdiv) * 1000; 316 - 317 - pr_debug("%s:%s rate %lu\n", clk_hw_get_name(hw), __func__, rate); 318 - 319 - return rate; 320 - } 321 - 322 413 static int clk_pll3200c32_get_params(unsigned long input, unsigned long output, 323 414 struct stm_pll *pll) 324 415 { ··· 413 606 __clkgen_pll_enable(hw); 414 607 415 608 return 0; 416 - } 417 - 418 - static unsigned long recalc_stm_pll1200c32(struct clk_hw *hw, 419 - unsigned long parent_rate) 420 - { 421 - struct clkgen_pll *pll = to_clkgen_pll(hw); 422 - unsigned long odf, ldf, idf; 423 - unsigned long rate; 424 - 425 - if (!clkgen_pll_is_enabled(hw) || !clkgen_pll_is_locked(hw)) 426 - return 0; 427 - 428 - odf = CLKGEN_READ(pll, odf[0]); 429 - ldf = CLKGEN_READ(pll, ldf); 430 - idf = CLKGEN_READ(pll, idf); 431 - 432 - if (!idf) /* idf==0 means 1 */ 433 - idf = 1; 434 - if (!odf) /* odf==0 means 1 */ 435 - odf = 1; 436 - 437 - /* Note: input is divided by 1000 to avoid overflow */ 438 - rate = (((parent_rate / 1000) * ldf) / (odf * idf)) * 1000; 439 - 440 - pr_debug("%s:%s rate %lu\n", clk_hw_get_name(hw), __func__, rate); 441 - 442 - return rate; 443 609 } 444 610 445 611 /* PLL output structure ··· 572 792 return 0; 573 793 } 574 794 575 - static const struct clk_ops st_pll1600c65_ops = { 576 - .enable = clkgen_pll_enable, 577 - .disable = clkgen_pll_disable, 578 - .is_enabled = clkgen_pll_is_enabled, 579 - .recalc_rate = recalc_stm_pll1600c65, 580 - }; 581 - 582 - static const struct clk_ops st_pll800c65_ops = { 583 - .enable = clkgen_pll_enable, 584 - .disable = clkgen_pll_disable, 585 - .is_enabled = clkgen_pll_is_enabled, 586 - .recalc_rate = recalc_stm_pll800c65, 587 - }; 588 - 589 795 static const struct clk_ops stm_pll3200c32_ops = { 590 796 .enable = clkgen_pll_enable, 591 797 .disable = clkgen_pll_disable, ··· 586 820 .recalc_rate = recalc_stm_pll3200c32, 587 821 .round_rate = round_rate_stm_pll3200c32, 588 822 .set_rate = set_rate_stm_pll3200c32, 589 - }; 590 - 591 - static const struct clk_ops st_pll1200c32_ops = { 592 - .enable = clkgen_pll_enable, 593 - .disable = clkgen_pll_disable, 594 - .is_enabled = clkgen_pll_is_enabled, 595 - .recalc_rate = recalc_stm_pll1200c32, 596 823 }; 597 824 598 825 static const struct clk_ops stm_pll4600c28_ops = { ··· 636 877 return clk; 637 878 } 638 879 639 - static struct clk * __init clkgen_c65_lsdiv_register(const char *parent_name, 640 - const char *clk_name) 641 - { 642 - struct clk *clk; 643 - 644 - clk = clk_register_fixed_factor(NULL, clk_name, parent_name, 0, 1, 2); 645 - if (IS_ERR(clk)) 646 - return clk; 647 - 648 - pr_debug("%s: parent %s rate %lu\n", 649 - __clk_get_name(clk), 650 - __clk_get_name(clk_get_parent(clk)), 651 - clk_get_rate(clk)); 652 - return clk; 653 - } 654 - 655 880 static void __iomem * __init clkgen_get_register_base( 656 881 struct device_node *np) 657 882 { ··· 651 908 of_node_put(pnode); 652 909 return reg; 653 910 } 654 - 655 - #define CLKGENAx_PLL0_OFFSET 0x0 656 - #define CLKGENAx_PLL1_OFFSET 0x4 657 - 658 - static void __init clkgena_c65_pll_setup(struct device_node *np) 659 - { 660 - const int num_pll_outputs = 3; 661 - struct clk_onecell_data *clk_data; 662 - const char *parent_name; 663 - void __iomem *reg; 664 - const char *clk_name; 665 - 666 - parent_name = of_clk_get_parent_name(np, 0); 667 - if (!parent_name) 668 - return; 669 - 670 - reg = clkgen_get_register_base(np); 671 - if (!reg) 672 - return; 673 - 674 - clk_data = kzalloc(sizeof(*clk_data), GFP_KERNEL); 675 - if (!clk_data) 676 - return; 677 - 678 - clk_data->clk_num = num_pll_outputs; 679 - clk_data->clks = kzalloc(clk_data->clk_num * sizeof(struct clk *), 680 - GFP_KERNEL); 681 - 682 - if (!clk_data->clks) 683 - goto err; 684 - 685 - if (of_property_read_string_index(np, "clock-output-names", 686 - 0, &clk_name)) 687 - goto err; 688 - 689 - /* 690 - * PLL0 HS (high speed) output 691 - */ 692 - clk_data->clks[0] = clkgen_pll_register(parent_name, 693 - (struct clkgen_pll_data *) &st_pll1600c65_ax, 694 - reg + CLKGENAx_PLL0_OFFSET, 0, clk_name, NULL); 695 - 696 - if (IS_ERR(clk_data->clks[0])) 697 - goto err; 698 - 699 - if (of_property_read_string_index(np, "clock-output-names", 700 - 1, &clk_name)) 701 - goto err; 702 - 703 - /* 704 - * PLL0 LS (low speed) output, which is a fixed divide by 2 of the 705 - * high speed output. 706 - */ 707 - clk_data->clks[1] = clkgen_c65_lsdiv_register(__clk_get_name 708 - (clk_data->clks[0]), 709 - clk_name); 710 - 711 - if (IS_ERR(clk_data->clks[1])) 712 - goto err; 713 - 714 - if (of_property_read_string_index(np, "clock-output-names", 715 - 2, &clk_name)) 716 - goto err; 717 - 718 - /* 719 - * PLL1 output 720 - */ 721 - clk_data->clks[2] = clkgen_pll_register(parent_name, 722 - (struct clkgen_pll_data *) &st_pll800c65_ax, 723 - reg + CLKGENAx_PLL1_OFFSET, 0, clk_name, NULL); 724 - 725 - if (IS_ERR(clk_data->clks[2])) 726 - goto err; 727 - 728 - of_clk_add_provider(np, of_clk_src_onecell_get, clk_data); 729 - return; 730 - 731 - err: 732 - kfree(clk_data->clks); 733 - kfree(clk_data); 734 - } 735 - CLK_OF_DECLARE(clkgena_c65_plls, 736 - "st,clkgena-plls-c65", clkgena_c65_pll_setup); 737 911 738 912 static struct clk * __init clkgen_odf_register(const char *parent_name, 739 913 void __iomem *reg, ··· 703 1043 } 704 1044 705 1045 static const struct of_device_id c32_pll_of_match[] = { 706 - { 707 - .compatible = "st,plls-c32-a1x-0", 708 - .data = &st_pll3200c32_a1x_0, 709 - }, 710 - { 711 - .compatible = "st,plls-c32-a1x-1", 712 - .data = &st_pll3200c32_a1x_1, 713 - }, 714 - { 715 - .compatible = "st,stih415-plls-c32-a9", 716 - .data = &st_pll3200c32_a9_415, 717 - }, 718 - { 719 - .compatible = "st,stih415-plls-c32-ddr", 720 - .data = &st_pll3200c32_ddr_415, 721 - }, 722 - { 723 - .compatible = "st,stih416-plls-c32-a9", 724 - .data = &st_pll3200c32_a9_416, 725 - }, 726 - { 727 - .compatible = "st,stih416-plls-c32-ddr", 728 - .data = &st_pll3200c32_ddr_416, 729 - }, 730 1046 { 731 1047 .compatible = "st,stih407-plls-c32-a0", 732 1048 .data = &st_pll3200c32_407_a0, ··· 803 1167 kfree(clk_data); 804 1168 } 805 1169 CLK_OF_DECLARE(clkgen_c32_pll, "st,clkgen-plls-c32", clkgen_c32_pll_setup); 806 - 807 - static const struct of_device_id c32_gpu_pll_of_match[] = { 808 - { 809 - .compatible = "st,stih415-gpu-pll-c32", 810 - .data = &st_pll1200c32_gpu_415, 811 - }, 812 - { 813 - .compatible = "st,stih416-gpu-pll-c32", 814 - .data = &st_pll1200c32_gpu_416, 815 - }, 816 - {} 817 - }; 818 - 819 - static void __init clkgengpu_c32_pll_setup(struct device_node *np) 820 - { 821 - const struct of_device_id *match; 822 - struct clk *clk; 823 - const char *parent_name; 824 - void __iomem *reg; 825 - const char *clk_name; 826 - struct clkgen_pll_data *data; 827 - 828 - match = of_match_node(c32_gpu_pll_of_match, np); 829 - if (!match) { 830 - pr_err("%s: No matching data\n", __func__); 831 - return; 832 - } 833 - 834 - data = (struct clkgen_pll_data *)match->data; 835 - 836 - parent_name = of_clk_get_parent_name(np, 0); 837 - if (!parent_name) 838 - return; 839 - 840 - reg = clkgen_get_register_base(np); 841 - if (!reg) 842 - return; 843 - 844 - if (of_property_read_string_index(np, "clock-output-names", 845 - 0, &clk_name)) 846 - return; 847 - 848 - /* 849 - * PLL 1200MHz output 850 - */ 851 - clk = clkgen_pll_register(parent_name, data, reg, 852 - 0, clk_name, data->lock); 853 - 854 - if (!IS_ERR(clk)) 855 - of_clk_add_provider(np, of_clk_src_simple_get, clk); 856 - 857 - return; 858 - } 859 - CLK_OF_DECLARE(clkgengpu_c32_pll, 860 - "st,clkgengpu-pll-c32", clkgengpu_c32_pll_setup);