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

Merge remote-tracking branch 'linaro/clk-next' into clk-next

+3413 -837
+11 -5
Documentation/clk.txt
··· 68 68 int (*is_enabled)(struct clk_hw *hw); 69 69 unsigned long (*recalc_rate)(struct clk_hw *hw, 70 70 unsigned long parent_rate); 71 - long (*round_rate)(struct clk_hw *hw, unsigned long, 72 - unsigned long *); 71 + long (*round_rate)(struct clk_hw *hw, 72 + unsigned long rate, 73 + unsigned long *parent_rate); 73 74 long (*determine_rate)(struct clk_hw *hw, 74 75 unsigned long rate, 75 76 unsigned long *best_parent_rate, 76 77 struct clk **best_parent_clk); 77 78 int (*set_parent)(struct clk_hw *hw, u8 index); 78 79 u8 (*get_parent)(struct clk_hw *hw); 79 - int (*set_rate)(struct clk_hw *hw, unsigned long); 80 + int (*set_rate)(struct clk_hw *hw, 81 + unsigned long rate, 82 + unsigned long parent_rate); 80 83 int (*set_rate_and_parent)(struct clk_hw *hw, 81 84 unsigned long rate, 82 - unsigned long parent_rate, u8 index); 85 + unsigned long parent_rate, 86 + u8 index); 83 87 unsigned long (*recalc_accuracy)(struct clk_hw *hw, 84 - unsigned long parent_accuracy); 88 + unsigned long parent_accuracy); 85 89 void (*init)(struct clk_hw *hw); 90 + int (*debug_init)(struct clk_hw *hw, 91 + struct dentry *dentry); 86 92 }; 87 93 88 94 Part 3 - hardware clk implementations
+81 -35
Documentation/devicetree/bindings/clock/bcm-kona-clock.txt
··· 10 10 11 11 Required properties: 12 12 - compatible 13 - Shall have one of the following values: 14 - - "brcm,bcm11351-root-ccu" 15 - - "brcm,bcm11351-aon-ccu" 16 - - "brcm,bcm11351-hub-ccu" 17 - - "brcm,bcm11351-master-ccu" 18 - - "brcm,bcm11351-slave-ccu" 13 + Shall have a value of the form "brcm,<model>-<which>-ccu", 14 + where <model> is a Broadcom SoC model number and <which> is 15 + the name of a defined CCU. For example: 16 + "brcm,bcm11351-root-ccu" 17 + The compatible strings used for each supported SoC family 18 + are defined below. 19 19 - reg 20 20 Shall define the base and range of the address space 21 21 containing clock control registers ··· 26 26 Shall be an ordered list of strings defining the names of 27 27 the clocks provided by the CCU. 28 28 29 + Device tree example: 29 30 30 - BCM281XX family SoCs use Kona CCUs. The following table defines 31 - the set of CCUs and clock specifiers for BCM281XX clocks. When 32 - a clock consumer references a clocks, its symbolic specifier 33 - (rather than its numeric index value) should be used. These 34 - specifiers are defined in "include/dt-bindings/clock/bcm281xx.h". 31 + slave_ccu: slave_ccu { 32 + compatible = "brcm,bcm11351-slave-ccu"; 33 + reg = <0x3e011000 0x0f00>; 34 + #clock-cells = <1>; 35 + clock-output-names = "uartb", 36 + "uartb2", 37 + "uartb3", 38 + "uartb4"; 39 + }; 40 + 41 + ref_crystal_clk: ref_crystal { 42 + #clock-cells = <0>; 43 + compatible = "fixed-clock"; 44 + clock-frequency = <26000000>; 45 + }; 46 + 47 + uart@3e002000 { 48 + compatible = "brcm,bcm11351-dw-apb-uart", "snps,dw-apb-uart"; 49 + status = "disabled"; 50 + reg = <0x3e002000 0x1000>; 51 + clocks = <&slave_ccu BCM281XX_SLAVE_CCU_UARTB3>; 52 + interrupts = <GIC_SPI 65 IRQ_TYPE_LEVEL_HIGH>; 53 + reg-shift = <2>; 54 + reg-io-width = <4>; 55 + }; 56 + 57 + BCM281XX family 58 + --------------- 59 + CCU compatible string values for SoCs in the BCM281XX family are: 60 + "brcm,bcm11351-root-ccu" 61 + "brcm,bcm11351-aon-ccu" 62 + "brcm,bcm11351-hub-ccu" 63 + "brcm,bcm11351-master-ccu" 64 + "brcm,bcm11351-slave-ccu" 65 + 66 + The following table defines the set of CCUs and clock specifiers for 67 + BCM281XX family clocks. When a clock consumer references a clocks, 68 + its symbolic specifier (rather than its numeric index value) should 69 + be used. These specifiers are defined in: 70 + "include/dt-bindings/clock/bcm281xx.h" 35 71 36 72 CCU Clock Type Index Specifier 37 73 --- ----- ---- ----- --------- ··· 100 64 slave pwm peri 9 BCM281XX_SLAVE_CCU_PWM 101 65 102 66 103 - Device tree example: 67 + BCM21664 family 68 + --------------- 69 + CCU compatible string values for SoCs in the BCM21664 family are: 70 + "brcm,bcm21664-root-ccu" 71 + "brcm,bcm21664-aon-ccu" 72 + "brcm,bcm21664-master-ccu" 73 + "brcm,bcm21664-slave-ccu" 104 74 105 - slave_ccu: slave_ccu { 106 - compatible = "brcm,bcm11351-slave-ccu"; 107 - reg = <0x3e011000 0x0f00>; 108 - #clock-cells = <1>; 109 - clock-output-names = "uartb", 110 - "uartb2", 111 - "uartb3", 112 - "uartb4"; 113 - }; 75 + The following table defines the set of CCUs and clock specifiers for 76 + BCM21664 family clocks. When a clock consumer references a clocks, 77 + its symbolic specifier (rather than its numeric index value) should 78 + be used. These specifiers are defined in: 79 + "include/dt-bindings/clock/bcm21664.h" 114 80 115 - ref_crystal_clk: ref_crystal { 116 - #clock-cells = <0>; 117 - compatible = "fixed-clock"; 118 - clock-frequency = <26000000>; 119 - }; 81 + CCU Clock Type Index Specifier 82 + --- ----- ---- ----- --------- 83 + root frac_1m peri 0 BCM21664_ROOT_CCU_FRAC_1M 120 84 121 - uart@3e002000 { 122 - compatible = "brcm,bcm11351-dw-apb-uart", "snps,dw-apb-uart"; 123 - status = "disabled"; 124 - reg = <0x3e002000 0x1000>; 125 - clocks = <&slave_ccu BCM281XX_SLAVE_CCU_UARTB3>; 126 - interrupts = <GIC_SPI 65 IRQ_TYPE_LEVEL_HIGH>; 127 - reg-shift = <2>; 128 - reg-io-width = <4>; 129 - }; 85 + aon hub_timer peri 0 BCM21664_AON_CCU_HUB_TIMER 86 + 87 + master sdio1 peri 0 BCM21664_MASTER_CCU_SDIO1 88 + master sdio2 peri 1 BCM21664_MASTER_CCU_SDIO2 89 + master sdio3 peri 2 BCM21664_MASTER_CCU_SDIO3 90 + master sdio4 peri 3 BCM21664_MASTER_CCU_SDIO4 91 + master sdio1_sleep peri 4 BCM21664_MASTER_CCU_SDIO1_SLEEP 92 + master sdio2_sleep peri 5 BCM21664_MASTER_CCU_SDIO2_SLEEP 93 + master sdio3_sleep peri 6 BCM21664_MASTER_CCU_SDIO3_SLEEP 94 + master sdio4_sleep peri 7 BCM21664_MASTER_CCU_SDIO4_SLEEP 95 + 96 + slave uartb peri 0 BCM21664_SLAVE_CCU_UARTB 97 + slave uartb2 peri 1 BCM21664_SLAVE_CCU_UARTB2 98 + slave uartb3 peri 2 BCM21664_SLAVE_CCU_UARTB3 99 + slave uartb4 peri 3 BCM21664_SLAVE_CCU_UARTB4 100 + slave bsc1 peri 4 BCM21664_SLAVE_CCU_BSC1 101 + slave bsc2 peri 5 BCM21664_SLAVE_CCU_BSC2 102 + slave bsc3 peri 6 BCM21664_SLAVE_CCU_BSC3 103 + slave bsc4 peri 7 BCM21664_SLAVE_CCU_BSC4
+4 -5
Documentation/devicetree/bindings/clock/clock-bindings.txt
··· 44 44 clocks by index. The names should reflect the clock output signal 45 45 names for the device. 46 46 47 - clock-indices: If the identifyng number for the clocks in the node 48 - is not linear from zero, then the this mapping allows 49 - the mapping of identifiers into the clock-output-names 50 - array. 47 + clock-indices: If the identifying number for the clocks in the node 48 + is not linear from zero, then this allows the mapping of 49 + identifiers into the clock-output-names array. 51 50 52 51 For example, if we have two clocks <&oscillator 1> and <&oscillator 3>: 53 52 ··· 57 58 clock-output-names = "clka", "clkb"; 58 59 } 59 60 60 - This ensures we do not have any empty nodes in clock-output-names 61 + This ensures we do not have any empty strings in clock-output-names 61 62 62 63 63 64 ==Clock consumers==
-1
Documentation/devicetree/bindings/clock/fixed-clock.txt
··· 12 12 Optional properties: 13 13 - clock-accuracy : accuracy of clock in ppb (parts per billion). 14 14 Should be a single cell. 15 - - gpios : From common gpio binding; gpio connection to clock enable pin. 16 15 - clock-output-names : From common clock binding. 17 16 18 17 Example:
+31
Documentation/devicetree/bindings/clock/hix5hd2-clock.txt
··· 1 + * Hisilicon Hix5hd2 Clock Controller 2 + 3 + The hix5hd2 clock controller generates and supplies clock to various 4 + controllers within the hix5hd2 SoC. 5 + 6 + Required Properties: 7 + 8 + - compatible: should be "hisilicon,hix5hd2-clock" 9 + - reg: Address and length of the register set 10 + - #clock-cells: Should be <1> 11 + 12 + Each clock is assigned an identifier and client nodes use this identifier 13 + to specify the clock which they consume. 14 + 15 + All these identifier could be found in <dt-bindings/clock/hix5hd2-clock.h>. 16 + 17 + Examples: 18 + clock: clock@f8a22000 { 19 + compatible = "hisilicon,hix5hd2-clock"; 20 + reg = <0xf8a22000 0x1000>; 21 + #clock-cells = <1>; 22 + }; 23 + 24 + uart0: uart@f8b00000 { 25 + compatible = "arm,pl011", "arm,primecell"; 26 + reg = <0xf8b00000 0x1000>; 27 + interrupts = <0 49 4>; 28 + clocks = <&clock HIX5HD2_FIXED_83M>; 29 + clock-names = "apb_pclk"; 30 + status = "disabled"; 31 + };
+29
Documentation/devicetree/bindings/clock/lsi,axm5516-clks.txt
··· 1 + AXM5516 clock driver bindings 2 + ----------------------------- 3 + 4 + Required properties : 5 + - compatible : shall contain "lsi,axm5516-clks" 6 + - reg : shall contain base register location and length 7 + - #clock-cells : shall contain 1 8 + 9 + The consumer specifies the desired clock by having the clock ID in its "clocks" 10 + phandle cell. See <dt-bindings/clock/lsi,axxia-clock.h> for the list of 11 + supported clock IDs. 12 + 13 + Example: 14 + 15 + clks: clock-controller@2010020000 { 16 + compatible = "lsi,axm5516-clks"; 17 + #clock-cells = <1>; 18 + reg = <0x20 0x10020000 0 0x20000>; 19 + }; 20 + 21 + serial0: uart@2010080000 { 22 + compatible = "arm,pl011", "arm,primecell"; 23 + reg = <0x20 0x10080000 0 0x1000>; 24 + interrupts = <GIC_SPI 56 IRQ_TYPE_LEVEL_HIGH>; 25 + clocks = <&clks AXXIA_CLK_PER>; 26 + clock-names = "apb_pclk"; 27 + }; 28 + }; 29 +
+8
Documentation/devicetree/bindings/clock/mvebu-core-clock.txt
··· 29 29 2 = l2clk (L2 Cache clock derived from CPU0 clock) 30 30 3 = ddrclk (DDR controller clock derived from CPU0 clock) 31 31 32 + The following is a list of provided IDs and clock names on Orion5x: 33 + 0 = tclk (Internal Bus clock) 34 + 1 = cpuclk (CPU0 clock) 35 + 2 = ddrclk (DDR controller clock derived from CPU0 clock) 36 + 32 37 Required properties: 33 38 - compatible : shall be one of the following: 34 39 "marvell,armada-370-core-clock" - For Armada 370 SoC core clocks ··· 43 38 "marvell,dove-core-clock" - for Dove SoC core clocks 44 39 "marvell,kirkwood-core-clock" - for Kirkwood SoC (except mv88f6180) 45 40 "marvell,mv88f6180-core-clock" - for Kirkwood MV88f6180 SoC 41 + "marvell,mv88f5182-core-clock" - for Orion MV88F5182 SoC 42 + "marvell,mv88f5281-core-clock" - for Orion MV88F5281 SoC 43 + "marvell,mv88f6183-core-clock" - for Orion MV88F6183 SoC 46 44 - reg : shall be the register address of the Sample-At-Reset (SAR) register 47 45 - #clock-cells : from common clock binding; shall be set to 1 48 46
+1
Documentation/devicetree/bindings/clock/qcom,gcc.txt
··· 4 4 Required properties : 5 5 - compatible : shall contain only one of the following: 6 6 7 + "qcom,gcc-apq8064" 7 8 "qcom,gcc-msm8660" 8 9 "qcom,gcc-msm8960" 9 10 "qcom,gcc-msm8974"
+1
Documentation/devicetree/bindings/clock/renesas,cpg-mstp-clocks.txt
··· 10 10 Required Properties: 11 11 12 12 - compatible: Must be one of the following 13 + - "renesas,r8a7779-mstp-clocks" for R8A7779 (R-Car H1) MSTP gate clocks 13 14 - "renesas,r8a7790-mstp-clocks" for R8A7790 (R-Car H2) MSTP gate clocks 14 15 - "renesas,r8a7791-mstp-clocks" for R8A7791 (R-Car M2) MSTP gate clocks 15 16 - "renesas,cpg-mstp-clock" for generic MSTP gate clocks
+41
Documentation/devicetree/bindings/clock/renesas,r8a7740-cpg-clocks.txt
··· 1 + These bindings should be considered EXPERIMENTAL for now. 2 + 3 + * Renesas R8A7740 Clock Pulse Generator (CPG) 4 + 5 + The CPG generates core clocks for the R8A7740 SoC. It includes three PLLs 6 + and several fixed ratio and variable ratio dividers. 7 + 8 + Required Properties: 9 + 10 + - compatible: Must be "renesas,r8a7740-cpg-clocks" 11 + 12 + - reg: Base address and length of the memory resource used by the CPG 13 + 14 + - clocks: Reference to the three parent clocks 15 + - #clock-cells: Must be 1 16 + - clock-output-names: The names of the clocks. Supported clocks are 17 + "system", "pllc0", "pllc1", "pllc2", "r", "usb24s", "i", "zg", "b", 18 + "m1", "hp", "hpp", "usbp", "s", "zb", "m3", and "cp". 19 + 20 + - renesas,mode: board-specific settings of the MD_CK* bits 21 + 22 + 23 + Example 24 + ------- 25 + 26 + cpg_clocks: cpg_clocks@e6150000 { 27 + compatible = "renesas,r8a7740-cpg-clocks"; 28 + reg = <0xe6150000 0x10000>; 29 + clocks = <&extal1_clk>, <&extal2_clk>, <&extalr_clk>; 30 + #clock-cells = <1>; 31 + clock-output-names = "system", "pllc0", "pllc1", 32 + "pllc2", "r", 33 + "usb24s", 34 + "i", "zg", "b", "m1", "hp", 35 + "hpp", "usbp", "s", "zb", "m3", 36 + "cp"; 37 + }; 38 + 39 + &cpg_clocks { 40 + renesas,mode = <0x05>; 41 + };
+27
Documentation/devicetree/bindings/clock/renesas,r8a7779-cpg-clocks.txt
··· 1 + * Renesas R8A7779 Clock Pulse Generator (CPG) 2 + 3 + The CPG generates core clocks for the R8A7779. It includes one PLL and 4 + several fixed ratio dividers 5 + 6 + Required Properties: 7 + 8 + - compatible: Must be "renesas,r8a7779-cpg-clocks" 9 + - reg: Base address and length of the memory resource used by the CPG 10 + 11 + - clocks: Reference to the parent clock 12 + - #clock-cells: Must be 1 13 + - clock-output-names: The names of the clocks. Supported clocks are "plla", 14 + "z", "zs", "s", "s1", "p", "b", "out". 15 + 16 + 17 + Example 18 + ------- 19 + 20 + cpg_clocks: cpg_clocks@ffc80000 { 21 + compatible = "renesas,r8a7779-cpg-clocks"; 22 + reg = <0 0xffc80000 0 0x30>; 23 + clocks = <&extal_clk>; 24 + #clock-cells = <1>; 25 + clock-output-names = "plla", "z", "zs", "s", "s1", "p", 26 + "b", "out"; 27 + };
+130 -84
arch/arm/boot/dts/bcm21664.dtsi
··· 14 14 #include <dt-bindings/interrupt-controller/arm-gic.h> 15 15 #include <dt-bindings/interrupt-controller/irq.h> 16 16 17 + #include "dt-bindings/clock/bcm21664.h" 18 + 17 19 #include "skeleton.dtsi" 18 20 19 21 / { ··· 45 43 compatible = "brcm,bcm21664-dw-apb-uart", "snps,dw-apb-uart"; 46 44 status = "disabled"; 47 45 reg = <0x3e000000 0x118>; 48 - clocks = <&uartb_clk>; 46 + clocks = <&slave_ccu BCM21664_SLAVE_CCU_UARTB>; 49 47 interrupts = <GIC_SPI 67 IRQ_TYPE_LEVEL_HIGH>; 50 48 reg-shift = <2>; 51 49 reg-io-width = <4>; ··· 55 53 compatible = "brcm,bcm21664-dw-apb-uart", "snps,dw-apb-uart"; 56 54 status = "disabled"; 57 55 reg = <0x3e001000 0x118>; 58 - clocks = <&uartb2_clk>; 56 + clocks = <&slave_ccu BCM21664_SLAVE_CCU_UARTB2>; 59 57 interrupts = <GIC_SPI 66 IRQ_TYPE_LEVEL_HIGH>; 60 58 reg-shift = <2>; 61 59 reg-io-width = <4>; ··· 65 63 compatible = "brcm,bcm21664-dw-apb-uart", "snps,dw-apb-uart"; 66 64 status = "disabled"; 67 65 reg = <0x3e002000 0x118>; 68 - clocks = <&uartb3_clk>; 66 + clocks = <&slave_ccu BCM21664_SLAVE_CCU_UARTB3>; 69 67 interrupts = <GIC_SPI 65 IRQ_TYPE_LEVEL_HIGH>; 70 68 reg-shift = <2>; 71 69 reg-io-width = <4>; ··· 87 85 compatible = "brcm,kona-timer"; 88 86 reg = <0x35006000 0x1c>; 89 87 interrupts = <GIC_SPI 7 IRQ_TYPE_LEVEL_HIGH>; 90 - clocks = <&hub_timer_clk>; 88 + clocks = <&aon_ccu BCM21664_AON_CCU_HUB_TIMER>; 91 89 }; 92 90 93 91 gpio: gpio@35003000 { ··· 108 106 compatible = "brcm,kona-sdhci"; 109 107 reg = <0x3f180000 0x801c>; 110 108 interrupts = <GIC_SPI 77 IRQ_TYPE_LEVEL_HIGH>; 111 - clocks = <&sdio1_clk>; 109 + clocks = <&master_ccu BCM21664_MASTER_CCU_SDIO1>; 112 110 status = "disabled"; 113 111 }; 114 112 ··· 116 114 compatible = "brcm,kona-sdhci"; 117 115 reg = <0x3f190000 0x801c>; 118 116 interrupts = <GIC_SPI 76 IRQ_TYPE_LEVEL_HIGH>; 119 - clocks = <&sdio2_clk>; 117 + clocks = <&master_ccu BCM21664_MASTER_CCU_SDIO2>; 120 118 status = "disabled"; 121 119 }; 122 120 ··· 124 122 compatible = "brcm,kona-sdhci"; 125 123 reg = <0x3f1a0000 0x801c>; 126 124 interrupts = <GIC_SPI 74 IRQ_TYPE_LEVEL_HIGH>; 127 - clocks = <&sdio3_clk>; 125 + clocks = <&master_ccu BCM21664_MASTER_CCU_SDIO3>; 128 126 status = "disabled"; 129 127 }; 130 128 ··· 132 130 compatible = "brcm,kona-sdhci"; 133 131 reg = <0x3f1b0000 0x801c>; 134 132 interrupts = <GIC_SPI 73 IRQ_TYPE_LEVEL_HIGH>; 135 - clocks = <&sdio4_clk>; 133 + clocks = <&master_ccu BCM21664_MASTER_CCU_SDIO4>; 136 134 status = "disabled"; 137 135 }; 138 136 ··· 142 140 interrupts = <GIC_SPI 103 IRQ_TYPE_LEVEL_HIGH>; 143 141 #address-cells = <1>; 144 142 #size-cells = <0>; 145 - clocks = <&bsc1_clk>; 143 + clocks = <&slave_ccu BCM21664_SLAVE_CCU_BSC1>; 146 144 status = "disabled"; 147 145 }; 148 146 ··· 152 150 interrupts = <GIC_SPI 102 IRQ_TYPE_LEVEL_HIGH>; 153 151 #address-cells = <1>; 154 152 #size-cells = <0>; 155 - clocks = <&bsc2_clk>; 153 + clocks = <&slave_ccu BCM21664_SLAVE_CCU_BSC2>; 156 154 status = "disabled"; 157 155 }; 158 156 ··· 162 160 interrupts = <GIC_SPI 169 IRQ_TYPE_LEVEL_HIGH>; 163 161 #address-cells = <1>; 164 162 #size-cells = <0>; 165 - clocks = <&bsc3_clk>; 163 + clocks = <&slave_ccu BCM21664_SLAVE_CCU_BSC3>; 166 164 status = "disabled"; 167 165 }; 168 166 ··· 172 170 interrupts = <GIC_SPI 170 IRQ_TYPE_LEVEL_HIGH>; 173 171 #address-cells = <1>; 174 172 #size-cells = <0>; 175 - clocks = <&bsc4_clk>; 173 + clocks = <&slave_ccu BCM21664_SLAVE_CCU_BSC4>; 176 174 status = "disabled"; 177 175 }; 178 176 179 177 clocks { 180 - bsc1_clk: bsc1 { 181 - compatible = "fixed-clock"; 182 - clock-frequency = <13000000>; 183 - #clock-cells = <0>; 184 - }; 178 + #address-cells = <1>; 179 + #size-cells = <1>; 180 + ranges; 185 181 186 - bsc2_clk: bsc2 { 187 - compatible = "fixed-clock"; 188 - clock-frequency = <13000000>; 189 - #clock-cells = <0>; 190 - }; 182 + /* 183 + * Fixed clocks are defined before CCUs whose 184 + * clocks may depend on them. 185 + */ 191 186 192 - bsc3_clk: bsc3 { 193 - compatible = "fixed-clock"; 194 - clock-frequency = <13000000>; 187 + ref_32k_clk: ref_32k { 195 188 #clock-cells = <0>; 196 - }; 197 - 198 - bsc4_clk: bsc4 { 199 - compatible = "fixed-clock"; 200 - clock-frequency = <13000000>; 201 - #clock-cells = <0>; 202 - }; 203 - 204 - pmu_bsc_clk: pmu_bsc { 205 - compatible = "fixed-clock"; 206 - clock-frequency = <13000000>; 207 - #clock-cells = <0>; 208 - }; 209 - 210 - hub_timer_clk: hub_timer { 211 189 compatible = "fixed-clock"; 212 190 clock-frequency = <32768>; 213 - #clock-cells = <0>; 214 191 }; 215 192 216 - pwm_clk: pwm { 193 + bbl_32k_clk: bbl_32k { 194 + #clock-cells = <0>; 195 + compatible = "fixed-clock"; 196 + clock-frequency = <32768>; 197 + }; 198 + 199 + ref_13m_clk: ref_13m { 200 + #clock-cells = <0>; 201 + compatible = "fixed-clock"; 202 + clock-frequency = <13000000>; 203 + }; 204 + 205 + var_13m_clk: var_13m { 206 + #clock-cells = <0>; 207 + compatible = "fixed-clock"; 208 + clock-frequency = <13000000>; 209 + }; 210 + 211 + dft_19_5m_clk: dft_19_5m { 212 + #clock-cells = <0>; 213 + compatible = "fixed-clock"; 214 + clock-frequency = <19500000>; 215 + }; 216 + 217 + ref_crystal_clk: ref_crystal { 218 + #clock-cells = <0>; 217 219 compatible = "fixed-clock"; 218 220 clock-frequency = <26000000>; 219 - #clock-cells = <0>; 220 221 }; 221 222 222 - sdio1_clk: sdio1 { 223 - compatible = "fixed-clock"; 224 - clock-frequency = <48000000>; 223 + ref_52m_clk: ref_52m { 225 224 #clock-cells = <0>; 225 + compatible = "fixed-clock"; 226 + clock-frequency = <52000000>; 226 227 }; 227 228 228 - sdio2_clk: sdio2 { 229 - compatible = "fixed-clock"; 230 - clock-frequency = <48000000>; 229 + var_52m_clk: var_52m { 231 230 #clock-cells = <0>; 232 - }; 233 - 234 - sdio3_clk: sdio3 { 235 231 compatible = "fixed-clock"; 236 - clock-frequency = <48000000>; 237 - #clock-cells = <0>; 238 - }; 239 - 240 - sdio4_clk: sdio4 { 241 - compatible = "fixed-clock"; 242 - clock-frequency = <48000000>; 243 - #clock-cells = <0>; 244 - }; 245 - 246 - tmon_1m_clk: tmon_1m { 247 - compatible = "fixed-clock"; 248 - clock-frequency = <1000000>; 249 - #clock-cells = <0>; 250 - }; 251 - 252 - uartb_clk: uartb { 253 - compatible = "fixed-clock"; 254 - clock-frequency = <13000000>; 255 - #clock-cells = <0>; 256 - }; 257 - 258 - uartb2_clk: uartb2 { 259 - compatible = "fixed-clock"; 260 - clock-frequency = <13000000>; 261 - #clock-cells = <0>; 262 - }; 263 - 264 - uartb3_clk: uartb3 { 265 - compatible = "fixed-clock"; 266 - clock-frequency = <13000000>; 267 - #clock-cells = <0>; 232 + clock-frequency = <52000000>; 268 233 }; 269 234 270 235 usb_otg_ahb_clk: usb_otg_ahb { 236 + #clock-cells = <0>; 271 237 compatible = "fixed-clock"; 272 238 clock-frequency = <52000000>; 239 + }; 240 + 241 + ref_96m_clk: ref_96m { 273 242 #clock-cells = <0>; 243 + compatible = "fixed-clock"; 244 + clock-frequency = <96000000>; 245 + }; 246 + 247 + var_96m_clk: var_96m { 248 + #clock-cells = <0>; 249 + compatible = "fixed-clock"; 250 + clock-frequency = <96000000>; 251 + }; 252 + 253 + ref_104m_clk: ref_104m { 254 + #clock-cells = <0>; 255 + compatible = "fixed-clock"; 256 + clock-frequency = <104000000>; 257 + }; 258 + 259 + var_104m_clk: var_104m { 260 + #clock-cells = <0>; 261 + compatible = "fixed-clock"; 262 + clock-frequency = <104000000>; 263 + }; 264 + 265 + ref_156m_clk: ref_156m { 266 + #clock-cells = <0>; 267 + compatible = "fixed-clock"; 268 + clock-frequency = <156000000>; 269 + }; 270 + 271 + var_156m_clk: var_156m { 272 + #clock-cells = <0>; 273 + compatible = "fixed-clock"; 274 + clock-frequency = <156000000>; 275 + }; 276 + 277 + root_ccu: root_ccu { 278 + compatible = BCM21664_DT_ROOT_CCU_COMPAT; 279 + reg = <0x35001000 0x0f00>; 280 + #clock-cells = <1>; 281 + clock-output-names = "frac_1m"; 282 + }; 283 + 284 + aon_ccu: aon_ccu { 285 + compatible = BCM21664_DT_AON_CCU_COMPAT; 286 + reg = <0x35002000 0x0f00>; 287 + #clock-cells = <1>; 288 + clock-output-names = "hub_timer"; 289 + }; 290 + 291 + master_ccu: master_ccu { 292 + compatible = BCM21664_DT_MASTER_CCU_COMPAT; 293 + reg = <0x3f001000 0x0f00>; 294 + #clock-cells = <1>; 295 + clock-output-names = "sdio1", 296 + "sdio2", 297 + "sdio3", 298 + "sdio4", 299 + "sdio1_sleep", 300 + "sdio2_sleep", 301 + "sdio3_sleep", 302 + "sdio4_sleep"; 303 + }; 304 + 305 + slave_ccu: slave_ccu { 306 + compatible = BCM21664_DT_SLAVE_CCU_COMPAT; 307 + reg = <0x3e011000 0x0f00>; 308 + #clock-cells = <1>; 309 + clock-output-names = "uartb", 310 + "uartb2", 311 + "uartb3", 312 + "bsc1", 313 + "bsc2", 314 + "bsc3", 315 + "bsc4"; 274 316 }; 275 317 }; 276 318
+2
drivers/clk/Makefile
··· 12 12 # hardware specific clock types 13 13 # please keep this section sorted lexicographically by file/directory path name 14 14 obj-$(CONFIG_COMMON_CLK_AXI_CLKGEN) += clk-axi-clkgen.o 15 + obj-$(CONFIG_ARCH_AXXIA) += clk-axm5516.o 15 16 obj-$(CONFIG_ARCH_BCM2835) += clk-bcm2835.o 16 17 obj-$(CONFIG_ARCH_EFM32) += clk-efm32gg.o 17 18 obj-$(CONFIG_ARCH_HIGHBANK) += clk-highbank.o ··· 34 33 obj-$(CONFIG_ARCH_BCM_MOBILE) += bcm/ 35 34 obj-$(CONFIG_ARCH_HI3xxx) += hisilicon/ 36 35 obj-$(CONFIG_ARCH_HIP04) += hisilicon/ 36 + obj-$(CONFIG_ARCH_HIX5HD2) += hisilicon/ 37 37 obj-$(CONFIG_COMMON_CLK_KEYSTONE) += keystone/ 38 38 ifeq ($(CONFIG_COMMON_CLK), y) 39 39 obj-$(CONFIG_ARCH_MMP) += mmp/
+1 -1
drivers/clk/bcm/Kconfig
··· 6 6 help 7 7 Enable common clock framework support for Broadcom SoCs 8 8 using "Kona" style clock control units, including those 9 - in the BCM281xx family. 9 + in the BCM281xx and BCM21664 families.
+1
drivers/clk/bcm/Makefile
··· 1 1 obj-$(CONFIG_CLK_BCM_KONA) += clk-kona.o 2 2 obj-$(CONFIG_CLK_BCM_KONA) += clk-kona-setup.o 3 3 obj-$(CONFIG_CLK_BCM_KONA) += clk-bcm281xx.o 4 + obj-$(CONFIG_CLK_BCM_KONA) += clk-bcm21664.o
+290
drivers/clk/bcm/clk-bcm21664.c
··· 1 + /* 2 + * Copyright (C) 2014 Broadcom Corporation 3 + * Copyright 2014 Linaro Limited 4 + * 5 + * This program is free software; you can redistribute it and/or 6 + * modify it under the terms of the GNU General Public License as 7 + * published by the Free Software Foundation version 2. 8 + * 9 + * This program is distributed "as is" WITHOUT ANY WARRANTY of any 10 + * kind, whether express or implied; without even the implied warranty 11 + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 + * GNU General Public License for more details. 13 + */ 14 + 15 + #include "clk-kona.h" 16 + #include "dt-bindings/clock/bcm21664.h" 17 + 18 + #define BCM21664_CCU_COMMON(_name, _capname) \ 19 + KONA_CCU_COMMON(BCM21664, _name, _capname) 20 + 21 + /* Root CCU */ 22 + 23 + static struct peri_clk_data frac_1m_data = { 24 + .gate = HW_SW_GATE(0x214, 16, 0, 1), 25 + .clocks = CLOCKS("ref_crystal"), 26 + }; 27 + 28 + static struct ccu_data root_ccu_data = { 29 + BCM21664_CCU_COMMON(root, ROOT), 30 + /* no policy control */ 31 + .kona_clks = { 32 + [BCM21664_ROOT_CCU_FRAC_1M] = 33 + KONA_CLK(root, frac_1m, peri), 34 + [BCM21664_ROOT_CCU_CLOCK_COUNT] = LAST_KONA_CLK, 35 + }, 36 + }; 37 + 38 + /* AON CCU */ 39 + 40 + static struct peri_clk_data hub_timer_data = { 41 + .gate = HW_SW_GATE(0x0414, 16, 0, 1), 42 + .hyst = HYST(0x0414, 8, 9), 43 + .clocks = CLOCKS("bbl_32k", 44 + "frac_1m", 45 + "dft_19_5m"), 46 + .sel = SELECTOR(0x0a10, 0, 2), 47 + .trig = TRIGGER(0x0a40, 4), 48 + }; 49 + 50 + static struct ccu_data aon_ccu_data = { 51 + BCM21664_CCU_COMMON(aon, AON), 52 + .policy = { 53 + .enable = CCU_LVM_EN(0x0034, 0), 54 + .control = CCU_POLICY_CTL(0x000c, 0, 1, 2), 55 + }, 56 + .kona_clks = { 57 + [BCM21664_AON_CCU_HUB_TIMER] = 58 + KONA_CLK(aon, hub_timer, peri), 59 + [BCM21664_AON_CCU_CLOCK_COUNT] = LAST_KONA_CLK, 60 + }, 61 + }; 62 + 63 + /* Master CCU */ 64 + 65 + static struct peri_clk_data sdio1_data = { 66 + .gate = HW_SW_GATE(0x0358, 18, 2, 3), 67 + .clocks = CLOCKS("ref_crystal", 68 + "var_52m", 69 + "ref_52m", 70 + "var_96m", 71 + "ref_96m"), 72 + .sel = SELECTOR(0x0a28, 0, 3), 73 + .div = DIVIDER(0x0a28, 4, 14), 74 + .trig = TRIGGER(0x0afc, 9), 75 + }; 76 + 77 + static struct peri_clk_data sdio2_data = { 78 + .gate = HW_SW_GATE(0x035c, 18, 2, 3), 79 + .clocks = CLOCKS("ref_crystal", 80 + "var_52m", 81 + "ref_52m", 82 + "var_96m", 83 + "ref_96m"), 84 + .sel = SELECTOR(0x0a2c, 0, 3), 85 + .div = DIVIDER(0x0a2c, 4, 14), 86 + .trig = TRIGGER(0x0afc, 10), 87 + }; 88 + 89 + static struct peri_clk_data sdio3_data = { 90 + .gate = HW_SW_GATE(0x0364, 18, 2, 3), 91 + .clocks = CLOCKS("ref_crystal", 92 + "var_52m", 93 + "ref_52m", 94 + "var_96m", 95 + "ref_96m"), 96 + .sel = SELECTOR(0x0a34, 0, 3), 97 + .div = DIVIDER(0x0a34, 4, 14), 98 + .trig = TRIGGER(0x0afc, 12), 99 + }; 100 + 101 + static struct peri_clk_data sdio4_data = { 102 + .gate = HW_SW_GATE(0x0360, 18, 2, 3), 103 + .clocks = CLOCKS("ref_crystal", 104 + "var_52m", 105 + "ref_52m", 106 + "var_96m", 107 + "ref_96m"), 108 + .sel = SELECTOR(0x0a30, 0, 3), 109 + .div = DIVIDER(0x0a30, 4, 14), 110 + .trig = TRIGGER(0x0afc, 11), 111 + }; 112 + 113 + static struct peri_clk_data sdio1_sleep_data = { 114 + .clocks = CLOCKS("ref_32k"), /* Verify */ 115 + .gate = HW_SW_GATE(0x0358, 18, 2, 3), 116 + }; 117 + 118 + static struct peri_clk_data sdio2_sleep_data = { 119 + .clocks = CLOCKS("ref_32k"), /* Verify */ 120 + .gate = HW_SW_GATE(0x035c, 18, 2, 3), 121 + }; 122 + 123 + static struct peri_clk_data sdio3_sleep_data = { 124 + .clocks = CLOCKS("ref_32k"), /* Verify */ 125 + .gate = HW_SW_GATE(0x0364, 18, 2, 3), 126 + }; 127 + 128 + static struct peri_clk_data sdio4_sleep_data = { 129 + .clocks = CLOCKS("ref_32k"), /* Verify */ 130 + .gate = HW_SW_GATE(0x0360, 18, 2, 3), 131 + }; 132 + 133 + static struct ccu_data master_ccu_data = { 134 + BCM21664_CCU_COMMON(master, MASTER), 135 + .policy = { 136 + .enable = CCU_LVM_EN(0x0034, 0), 137 + .control = CCU_POLICY_CTL(0x000c, 0, 1, 2), 138 + }, 139 + .kona_clks = { 140 + [BCM21664_MASTER_CCU_SDIO1] = 141 + KONA_CLK(master, sdio1, peri), 142 + [BCM21664_MASTER_CCU_SDIO2] = 143 + KONA_CLK(master, sdio2, peri), 144 + [BCM21664_MASTER_CCU_SDIO3] = 145 + KONA_CLK(master, sdio3, peri), 146 + [BCM21664_MASTER_CCU_SDIO4] = 147 + KONA_CLK(master, sdio4, peri), 148 + [BCM21664_MASTER_CCU_SDIO1_SLEEP] = 149 + KONA_CLK(master, sdio1_sleep, peri), 150 + [BCM21664_MASTER_CCU_SDIO2_SLEEP] = 151 + KONA_CLK(master, sdio2_sleep, peri), 152 + [BCM21664_MASTER_CCU_SDIO3_SLEEP] = 153 + KONA_CLK(master, sdio3_sleep, peri), 154 + [BCM21664_MASTER_CCU_SDIO4_SLEEP] = 155 + KONA_CLK(master, sdio4_sleep, peri), 156 + [BCM21664_MASTER_CCU_CLOCK_COUNT] = LAST_KONA_CLK, 157 + }, 158 + }; 159 + 160 + /* Slave CCU */ 161 + 162 + static struct peri_clk_data uartb_data = { 163 + .gate = HW_SW_GATE(0x0400, 18, 2, 3), 164 + .clocks = CLOCKS("ref_crystal", 165 + "var_156m", 166 + "ref_156m"), 167 + .sel = SELECTOR(0x0a10, 0, 2), 168 + .div = FRAC_DIVIDER(0x0a10, 4, 12, 8), 169 + .trig = TRIGGER(0x0afc, 2), 170 + }; 171 + 172 + static struct peri_clk_data uartb2_data = { 173 + .gate = HW_SW_GATE(0x0404, 18, 2, 3), 174 + .clocks = CLOCKS("ref_crystal", 175 + "var_156m", 176 + "ref_156m"), 177 + .sel = SELECTOR(0x0a14, 0, 2), 178 + .div = FRAC_DIVIDER(0x0a14, 4, 12, 8), 179 + .trig = TRIGGER(0x0afc, 3), 180 + }; 181 + 182 + static struct peri_clk_data uartb3_data = { 183 + .gate = HW_SW_GATE(0x0408, 18, 2, 3), 184 + .clocks = CLOCKS("ref_crystal", 185 + "var_156m", 186 + "ref_156m"), 187 + .sel = SELECTOR(0x0a18, 0, 2), 188 + .div = FRAC_DIVIDER(0x0a18, 4, 12, 8), 189 + .trig = TRIGGER(0x0afc, 4), 190 + }; 191 + 192 + static struct peri_clk_data bsc1_data = { 193 + .gate = HW_SW_GATE(0x0458, 18, 2, 3), 194 + .clocks = CLOCKS("ref_crystal", 195 + "var_104m", 196 + "ref_104m", 197 + "var_13m", 198 + "ref_13m"), 199 + .sel = SELECTOR(0x0a64, 0, 3), 200 + .trig = TRIGGER(0x0afc, 23), 201 + }; 202 + 203 + static struct peri_clk_data bsc2_data = { 204 + .gate = HW_SW_GATE(0x045c, 18, 2, 3), 205 + .clocks = CLOCKS("ref_crystal", 206 + "var_104m", 207 + "ref_104m", 208 + "var_13m", 209 + "ref_13m"), 210 + .sel = SELECTOR(0x0a68, 0, 3), 211 + .trig = TRIGGER(0x0afc, 24), 212 + }; 213 + 214 + static struct peri_clk_data bsc3_data = { 215 + .gate = HW_SW_GATE(0x0470, 18, 2, 3), 216 + .clocks = CLOCKS("ref_crystal", 217 + "var_104m", 218 + "ref_104m", 219 + "var_13m", 220 + "ref_13m"), 221 + .sel = SELECTOR(0x0a7c, 0, 3), 222 + .trig = TRIGGER(0x0afc, 18), 223 + }; 224 + 225 + static struct peri_clk_data bsc4_data = { 226 + .gate = HW_SW_GATE(0x0474, 18, 2, 3), 227 + .clocks = CLOCKS("ref_crystal", 228 + "var_104m", 229 + "ref_104m", 230 + "var_13m", 231 + "ref_13m"), 232 + .sel = SELECTOR(0x0a80, 0, 3), 233 + .trig = TRIGGER(0x0afc, 19), 234 + }; 235 + 236 + static struct ccu_data slave_ccu_data = { 237 + BCM21664_CCU_COMMON(slave, SLAVE), 238 + .policy = { 239 + .enable = CCU_LVM_EN(0x0034, 0), 240 + .control = CCU_POLICY_CTL(0x000c, 0, 1, 2), 241 + }, 242 + .kona_clks = { 243 + [BCM21664_SLAVE_CCU_UARTB] = 244 + KONA_CLK(slave, uartb, peri), 245 + [BCM21664_SLAVE_CCU_UARTB2] = 246 + KONA_CLK(slave, uartb2, peri), 247 + [BCM21664_SLAVE_CCU_UARTB3] = 248 + KONA_CLK(slave, uartb3, peri), 249 + [BCM21664_SLAVE_CCU_BSC1] = 250 + KONA_CLK(slave, bsc1, peri), 251 + [BCM21664_SLAVE_CCU_BSC2] = 252 + KONA_CLK(slave, bsc2, peri), 253 + [BCM21664_SLAVE_CCU_BSC3] = 254 + KONA_CLK(slave, bsc3, peri), 255 + [BCM21664_SLAVE_CCU_BSC4] = 256 + KONA_CLK(slave, bsc4, peri), 257 + [BCM21664_SLAVE_CCU_CLOCK_COUNT] = LAST_KONA_CLK, 258 + }, 259 + }; 260 + 261 + /* Device tree match table callback functions */ 262 + 263 + static void __init kona_dt_root_ccu_setup(struct device_node *node) 264 + { 265 + kona_dt_ccu_setup(&root_ccu_data, node); 266 + } 267 + 268 + static void __init kona_dt_aon_ccu_setup(struct device_node *node) 269 + { 270 + kona_dt_ccu_setup(&aon_ccu_data, node); 271 + } 272 + 273 + static void __init kona_dt_master_ccu_setup(struct device_node *node) 274 + { 275 + kona_dt_ccu_setup(&master_ccu_data, node); 276 + } 277 + 278 + static void __init kona_dt_slave_ccu_setup(struct device_node *node) 279 + { 280 + kona_dt_ccu_setup(&slave_ccu_data, node); 281 + } 282 + 283 + CLK_OF_DECLARE(bcm21664_root_ccu, BCM21664_DT_ROOT_CCU_COMPAT, 284 + kona_dt_root_ccu_setup); 285 + CLK_OF_DECLARE(bcm21664_aon_ccu, BCM21664_DT_AON_CCU_COMPAT, 286 + kona_dt_aon_ccu_setup); 287 + CLK_OF_DECLARE(bcm21664_master_ccu, BCM21664_DT_MASTER_CCU_COMPAT, 288 + kona_dt_master_ccu_setup); 289 + CLK_OF_DECLARE(bcm21664_slave_ccu, BCM21664_DT_SLAVE_CCU_COMPAT, 290 + kona_dt_slave_ccu_setup);
+95 -136
drivers/clk/bcm/clk-bcm281xx.c
··· 15 15 #include "clk-kona.h" 16 16 #include "dt-bindings/clock/bcm281xx.h" 17 17 18 - /* bcm11351 CCU device tree "compatible" strings */ 19 - #define BCM11351_DT_ROOT_CCU_COMPAT "brcm,bcm11351-root-ccu" 20 - #define BCM11351_DT_AON_CCU_COMPAT "brcm,bcm11351-aon-ccu" 21 - #define BCM11351_DT_HUB_CCU_COMPAT "brcm,bcm11351-hub-ccu" 22 - #define BCM11351_DT_MASTER_CCU_COMPAT "brcm,bcm11351-master-ccu" 23 - #define BCM11351_DT_SLAVE_CCU_COMPAT "brcm,bcm11351-slave-ccu" 18 + #define BCM281XX_CCU_COMMON(_name, _ucase_name) \ 19 + KONA_CCU_COMMON(BCM281XX, _name, _ucase_name) 24 20 25 - /* Root CCU clocks */ 21 + /* Root CCU */ 26 22 27 23 static struct peri_clk_data frac_1m_data = { 28 24 .gate = HW_SW_GATE(0x214, 16, 0, 1), ··· 27 31 .clocks = CLOCKS("ref_crystal"), 28 32 }; 29 33 30 - /* AON CCU clocks */ 34 + static struct ccu_data root_ccu_data = { 35 + BCM281XX_CCU_COMMON(root, ROOT), 36 + .kona_clks = { 37 + [BCM281XX_ROOT_CCU_FRAC_1M] = 38 + KONA_CLK(root, frac_1m, peri), 39 + [BCM281XX_ROOT_CCU_CLOCK_COUNT] = LAST_KONA_CLK, 40 + }, 41 + }; 42 + 43 + /* AON CCU */ 31 44 32 45 static struct peri_clk_data hub_timer_data = { 33 46 .gate = HW_SW_GATE(0x0414, 16, 0, 1), ··· 65 60 .trig = TRIGGER(0x0a40, 2), 66 61 }; 67 62 68 - /* Hub CCU clocks */ 63 + static struct ccu_data aon_ccu_data = { 64 + BCM281XX_CCU_COMMON(aon, AON), 65 + .kona_clks = { 66 + [BCM281XX_AON_CCU_HUB_TIMER] = 67 + KONA_CLK(aon, hub_timer, peri), 68 + [BCM281XX_AON_CCU_PMU_BSC] = 69 + KONA_CLK(aon, pmu_bsc, peri), 70 + [BCM281XX_AON_CCU_PMU_BSC_VAR] = 71 + KONA_CLK(aon, pmu_bsc_var, peri), 72 + [BCM281XX_AON_CCU_CLOCK_COUNT] = LAST_KONA_CLK, 73 + }, 74 + }; 75 + 76 + /* Hub CCU */ 69 77 70 78 static struct peri_clk_data tmon_1m_data = { 71 79 .gate = HW_SW_GATE(0x04a4, 18, 2, 3), ··· 88 70 .trig = TRIGGER(0x0e84, 1), 89 71 }; 90 72 91 - /* Master CCU clocks */ 73 + static struct ccu_data hub_ccu_data = { 74 + BCM281XX_CCU_COMMON(hub, HUB), 75 + .kona_clks = { 76 + [BCM281XX_HUB_CCU_TMON_1M] = 77 + KONA_CLK(hub, tmon_1m, peri), 78 + [BCM281XX_HUB_CCU_CLOCK_COUNT] = LAST_KONA_CLK, 79 + }, 80 + }; 81 + 82 + /* Master CCU */ 92 83 93 84 static struct peri_clk_data sdio1_data = { 94 85 .gate = HW_SW_GATE(0x0358, 18, 2, 3), ··· 180 153 .trig = TRIGGER(0x0afc, 5), 181 154 }; 182 155 183 - /* Slave CCU clocks */ 156 + static struct ccu_data master_ccu_data = { 157 + BCM281XX_CCU_COMMON(master, MASTER), 158 + .kona_clks = { 159 + [BCM281XX_MASTER_CCU_SDIO1] = 160 + KONA_CLK(master, sdio1, peri), 161 + [BCM281XX_MASTER_CCU_SDIO2] = 162 + KONA_CLK(master, sdio2, peri), 163 + [BCM281XX_MASTER_CCU_SDIO3] = 164 + KONA_CLK(master, sdio3, peri), 165 + [BCM281XX_MASTER_CCU_SDIO4] = 166 + KONA_CLK(master, sdio4, peri), 167 + [BCM281XX_MASTER_CCU_USB_IC] = 168 + KONA_CLK(master, usb_ic, peri), 169 + [BCM281XX_MASTER_CCU_HSIC2_48M] = 170 + KONA_CLK(master, hsic2_48m, peri), 171 + [BCM281XX_MASTER_CCU_HSIC2_12M] = 172 + KONA_CLK(master, hsic2_12m, peri), 173 + [BCM281XX_MASTER_CCU_CLOCK_COUNT] = LAST_KONA_CLK, 174 + }, 175 + }; 176 + 177 + /* Slave CCU */ 184 178 185 179 static struct peri_clk_data uartb_data = { 186 180 .gate = HW_SW_GATE(0x0400, 18, 2, 3), ··· 309 261 .trig = TRIGGER(0x0afc, 15), 310 262 }; 311 263 312 - /* 313 - * CCU setup routines 314 - * 315 - * These are called from kona_dt_ccu_setup() to initialize the array 316 - * of clocks provided by the CCU. Once allocated, the entries in 317 - * the array are initialized by calling kona_clk_setup() with the 318 - * initialization data for each clock. They return 0 if successful 319 - * or an error code otherwise. 320 - */ 321 - static int __init bcm281xx_root_ccu_clks_setup(struct ccu_data *ccu) 322 - { 323 - struct clk **clks; 324 - size_t count = BCM281XX_ROOT_CCU_CLOCK_COUNT; 325 - 326 - clks = kzalloc(count * sizeof(*clks), GFP_KERNEL); 327 - if (!clks) { 328 - pr_err("%s: failed to allocate root clocks\n", __func__); 329 - return -ENOMEM; 330 - } 331 - ccu->data.clks = clks; 332 - ccu->data.clk_num = count; 333 - 334 - PERI_CLK_SETUP(clks, ccu, BCM281XX_ROOT_CCU_FRAC_1M, frac_1m); 335 - 336 - return 0; 337 - } 338 - 339 - static int __init bcm281xx_aon_ccu_clks_setup(struct ccu_data *ccu) 340 - { 341 - struct clk **clks; 342 - size_t count = BCM281XX_AON_CCU_CLOCK_COUNT; 343 - 344 - clks = kzalloc(count * sizeof(*clks), GFP_KERNEL); 345 - if (!clks) { 346 - pr_err("%s: failed to allocate aon clocks\n", __func__); 347 - return -ENOMEM; 348 - } 349 - ccu->data.clks = clks; 350 - ccu->data.clk_num = count; 351 - 352 - PERI_CLK_SETUP(clks, ccu, BCM281XX_AON_CCU_HUB_TIMER, hub_timer); 353 - PERI_CLK_SETUP(clks, ccu, BCM281XX_AON_CCU_PMU_BSC, pmu_bsc); 354 - PERI_CLK_SETUP(clks, ccu, BCM281XX_AON_CCU_PMU_BSC_VAR, pmu_bsc_var); 355 - 356 - return 0; 357 - } 358 - 359 - static int __init bcm281xx_hub_ccu_clks_setup(struct ccu_data *ccu) 360 - { 361 - struct clk **clks; 362 - size_t count = BCM281XX_HUB_CCU_CLOCK_COUNT; 363 - 364 - clks = kzalloc(count * sizeof(*clks), GFP_KERNEL); 365 - if (!clks) { 366 - pr_err("%s: failed to allocate hub clocks\n", __func__); 367 - return -ENOMEM; 368 - } 369 - ccu->data.clks = clks; 370 - ccu->data.clk_num = count; 371 - 372 - PERI_CLK_SETUP(clks, ccu, BCM281XX_HUB_CCU_TMON_1M, tmon_1m); 373 - 374 - return 0; 375 - } 376 - 377 - static int __init bcm281xx_master_ccu_clks_setup(struct ccu_data *ccu) 378 - { 379 - struct clk **clks; 380 - size_t count = BCM281XX_MASTER_CCU_CLOCK_COUNT; 381 - 382 - clks = kzalloc(count * sizeof(*clks), GFP_KERNEL); 383 - if (!clks) { 384 - pr_err("%s: failed to allocate master clocks\n", __func__); 385 - return -ENOMEM; 386 - } 387 - ccu->data.clks = clks; 388 - ccu->data.clk_num = count; 389 - 390 - PERI_CLK_SETUP(clks, ccu, BCM281XX_MASTER_CCU_SDIO1, sdio1); 391 - PERI_CLK_SETUP(clks, ccu, BCM281XX_MASTER_CCU_SDIO2, sdio2); 392 - PERI_CLK_SETUP(clks, ccu, BCM281XX_MASTER_CCU_SDIO3, sdio3); 393 - PERI_CLK_SETUP(clks, ccu, BCM281XX_MASTER_CCU_SDIO4, sdio4); 394 - PERI_CLK_SETUP(clks, ccu, BCM281XX_MASTER_CCU_USB_IC, usb_ic); 395 - PERI_CLK_SETUP(clks, ccu, BCM281XX_MASTER_CCU_HSIC2_48M, hsic2_48m); 396 - PERI_CLK_SETUP(clks, ccu, BCM281XX_MASTER_CCU_HSIC2_12M, hsic2_12m); 397 - 398 - return 0; 399 - } 400 - 401 - static int __init bcm281xx_slave_ccu_clks_setup(struct ccu_data *ccu) 402 - { 403 - struct clk **clks; 404 - size_t count = BCM281XX_SLAVE_CCU_CLOCK_COUNT; 405 - 406 - clks = kzalloc(count * sizeof(*clks), GFP_KERNEL); 407 - if (!clks) { 408 - pr_err("%s: failed to allocate slave clocks\n", __func__); 409 - return -ENOMEM; 410 - } 411 - ccu->data.clks = clks; 412 - ccu->data.clk_num = count; 413 - 414 - PERI_CLK_SETUP(clks, ccu, BCM281XX_SLAVE_CCU_UARTB, uartb); 415 - PERI_CLK_SETUP(clks, ccu, BCM281XX_SLAVE_CCU_UARTB2, uartb2); 416 - PERI_CLK_SETUP(clks, ccu, BCM281XX_SLAVE_CCU_UARTB3, uartb3); 417 - PERI_CLK_SETUP(clks, ccu, BCM281XX_SLAVE_CCU_UARTB4, uartb4); 418 - PERI_CLK_SETUP(clks, ccu, BCM281XX_SLAVE_CCU_SSP0, ssp0); 419 - PERI_CLK_SETUP(clks, ccu, BCM281XX_SLAVE_CCU_SSP2, ssp2); 420 - PERI_CLK_SETUP(clks, ccu, BCM281XX_SLAVE_CCU_BSC1, bsc1); 421 - PERI_CLK_SETUP(clks, ccu, BCM281XX_SLAVE_CCU_BSC2, bsc2); 422 - PERI_CLK_SETUP(clks, ccu, BCM281XX_SLAVE_CCU_BSC3, bsc3); 423 - PERI_CLK_SETUP(clks, ccu, BCM281XX_SLAVE_CCU_PWM, pwm); 424 - 425 - return 0; 426 - } 264 + static struct ccu_data slave_ccu_data = { 265 + BCM281XX_CCU_COMMON(slave, SLAVE), 266 + .kona_clks = { 267 + [BCM281XX_SLAVE_CCU_UARTB] = 268 + KONA_CLK(slave, uartb, peri), 269 + [BCM281XX_SLAVE_CCU_UARTB2] = 270 + KONA_CLK(slave, uartb2, peri), 271 + [BCM281XX_SLAVE_CCU_UARTB3] = 272 + KONA_CLK(slave, uartb3, peri), 273 + [BCM281XX_SLAVE_CCU_UARTB4] = 274 + KONA_CLK(slave, uartb4, peri), 275 + [BCM281XX_SLAVE_CCU_SSP0] = 276 + KONA_CLK(slave, ssp0, peri), 277 + [BCM281XX_SLAVE_CCU_SSP2] = 278 + KONA_CLK(slave, ssp2, peri), 279 + [BCM281XX_SLAVE_CCU_BSC1] = 280 + KONA_CLK(slave, bsc1, peri), 281 + [BCM281XX_SLAVE_CCU_BSC2] = 282 + KONA_CLK(slave, bsc2, peri), 283 + [BCM281XX_SLAVE_CCU_BSC3] = 284 + KONA_CLK(slave, bsc3, peri), 285 + [BCM281XX_SLAVE_CCU_PWM] = 286 + KONA_CLK(slave, pwm, peri), 287 + [BCM281XX_SLAVE_CCU_CLOCK_COUNT] = LAST_KONA_CLK, 288 + }, 289 + }; 427 290 428 291 /* Device tree match table callback functions */ 429 292 430 293 static void __init kona_dt_root_ccu_setup(struct device_node *node) 431 294 { 432 - kona_dt_ccu_setup(node, bcm281xx_root_ccu_clks_setup); 295 + kona_dt_ccu_setup(&root_ccu_data, node); 433 296 } 434 297 435 298 static void __init kona_dt_aon_ccu_setup(struct device_node *node) 436 299 { 437 - kona_dt_ccu_setup(node, bcm281xx_aon_ccu_clks_setup); 300 + kona_dt_ccu_setup(&aon_ccu_data, node); 438 301 } 439 302 440 303 static void __init kona_dt_hub_ccu_setup(struct device_node *node) 441 304 { 442 - kona_dt_ccu_setup(node, bcm281xx_hub_ccu_clks_setup); 305 + kona_dt_ccu_setup(&hub_ccu_data, node); 443 306 } 444 307 445 308 static void __init kona_dt_master_ccu_setup(struct device_node *node) 446 309 { 447 - kona_dt_ccu_setup(node, bcm281xx_master_ccu_clks_setup); 310 + kona_dt_ccu_setup(&master_ccu_data, node); 448 311 } 449 312 450 313 static void __init kona_dt_slave_ccu_setup(struct device_node *node) 451 314 { 452 - kona_dt_ccu_setup(node, bcm281xx_slave_ccu_clks_setup); 315 + kona_dt_ccu_setup(&slave_ccu_data, node); 453 316 } 454 317 455 - CLK_OF_DECLARE(bcm11351_root_ccu, BCM11351_DT_ROOT_CCU_COMPAT, 318 + CLK_OF_DECLARE(bcm281xx_root_ccu, BCM281XX_DT_ROOT_CCU_COMPAT, 456 319 kona_dt_root_ccu_setup); 457 - CLK_OF_DECLARE(bcm11351_aon_ccu, BCM11351_DT_AON_CCU_COMPAT, 320 + CLK_OF_DECLARE(bcm281xx_aon_ccu, BCM281XX_DT_AON_CCU_COMPAT, 458 321 kona_dt_aon_ccu_setup); 459 - CLK_OF_DECLARE(bcm11351_hub_ccu, BCM11351_DT_HUB_CCU_COMPAT, 322 + CLK_OF_DECLARE(bcm281xx_hub_ccu, BCM281XX_DT_HUB_CCU_COMPAT, 460 323 kona_dt_hub_ccu_setup); 461 - CLK_OF_DECLARE(bcm11351_master_ccu, BCM11351_DT_MASTER_CCU_COMPAT, 324 + CLK_OF_DECLARE(bcm281xx_master_ccu, BCM281XX_DT_MASTER_CCU_COMPAT, 462 325 kona_dt_master_ccu_setup); 463 - CLK_OF_DECLARE(bcm11351_slave_ccu, BCM11351_DT_SLAVE_CCU_COMPAT, 326 + CLK_OF_DECLARE(bcm281xx_slave_ccu, BCM281XX_DT_SLAVE_CCU_COMPAT, 464 327 kona_dt_slave_ccu_setup);
+168 -61
drivers/clk/bcm/clk-kona-setup.c
··· 25 25 26 26 /* Validity checking */ 27 27 28 + static bool ccu_data_offsets_valid(struct ccu_data *ccu) 29 + { 30 + struct ccu_policy *ccu_policy = &ccu->policy; 31 + u32 limit; 32 + 33 + limit = ccu->range - sizeof(u32); 34 + limit = round_down(limit, sizeof(u32)); 35 + if (ccu_policy_exists(ccu_policy)) { 36 + if (ccu_policy->enable.offset > limit) { 37 + pr_err("%s: bad policy enable offset for %s " 38 + "(%u > %u)\n", __func__, 39 + ccu->name, ccu_policy->enable.offset, limit); 40 + return false; 41 + } 42 + if (ccu_policy->control.offset > limit) { 43 + pr_err("%s: bad policy control offset for %s " 44 + "(%u > %u)\n", __func__, 45 + ccu->name, ccu_policy->control.offset, limit); 46 + return false; 47 + } 48 + } 49 + 50 + return true; 51 + } 52 + 28 53 static bool clk_requires_trigger(struct kona_clk *bcm_clk) 29 54 { 30 55 struct peri_clk_data *peri = bcm_clk->u.peri; ··· 79 54 static bool peri_clk_data_offsets_valid(struct kona_clk *bcm_clk) 80 55 { 81 56 struct peri_clk_data *peri; 57 + struct bcm_clk_policy *policy; 82 58 struct bcm_clk_gate *gate; 59 + struct bcm_clk_hyst *hyst; 83 60 struct bcm_clk_div *div; 84 61 struct bcm_clk_sel *sel; 85 62 struct bcm_clk_trig *trig; ··· 91 64 92 65 BUG_ON(bcm_clk->type != bcm_clk_peri); 93 66 peri = bcm_clk->u.peri; 94 - name = bcm_clk->name; 67 + name = bcm_clk->init_data.name; 95 68 range = bcm_clk->ccu->range; 96 69 97 70 limit = range - sizeof(u32); 98 71 limit = round_down(limit, sizeof(u32)); 99 72 73 + policy = &peri->policy; 74 + if (policy_exists(policy)) { 75 + if (policy->offset > limit) { 76 + pr_err("%s: bad policy offset for %s (%u > %u)\n", 77 + __func__, name, policy->offset, limit); 78 + return false; 79 + } 80 + } 81 + 100 82 gate = &peri->gate; 83 + hyst = &peri->hyst; 101 84 if (gate_exists(gate)) { 102 85 if (gate->offset > limit) { 103 86 pr_err("%s: bad gate offset for %s (%u > %u)\n", 104 87 __func__, name, gate->offset, limit); 105 88 return false; 106 89 } 90 + 91 + if (hyst_exists(hyst)) { 92 + if (hyst->offset > limit) { 93 + pr_err("%s: bad hysteresis offset for %s " 94 + "(%u > %u)\n", __func__, 95 + name, hyst->offset, limit); 96 + return false; 97 + } 98 + } 99 + } else if (hyst_exists(hyst)) { 100 + pr_err("%s: hysteresis but no gate for %s\n", __func__, name); 101 + return false; 107 102 } 108 103 109 104 div = &peri->div; ··· 216 167 return true; 217 168 } 218 169 170 + static bool 171 + ccu_policy_valid(struct ccu_policy *ccu_policy, const char *ccu_name) 172 + { 173 + struct bcm_lvm_en *enable = &ccu_policy->enable; 174 + struct bcm_policy_ctl *control; 175 + 176 + if (!bit_posn_valid(enable->bit, "policy enable", ccu_name)) 177 + return false; 178 + 179 + control = &ccu_policy->control; 180 + if (!bit_posn_valid(control->go_bit, "policy control GO", ccu_name)) 181 + return false; 182 + 183 + if (!bit_posn_valid(control->atl_bit, "policy control ATL", ccu_name)) 184 + return false; 185 + 186 + if (!bit_posn_valid(control->ac_bit, "policy control AC", ccu_name)) 187 + return false; 188 + 189 + return true; 190 + } 191 + 192 + static bool policy_valid(struct bcm_clk_policy *policy, const char *clock_name) 193 + { 194 + if (!bit_posn_valid(policy->bit, "policy", clock_name)) 195 + return false; 196 + 197 + return true; 198 + } 199 + 219 200 /* 220 201 * All gates, if defined, have a status bit, and for hardware-only 221 202 * gates, that's it. Gates that can be software controlled also ··· 271 192 } else { 272 193 BUG_ON(!gate_is_hw_controllable(gate)); 273 194 } 195 + 196 + return true; 197 + } 198 + 199 + static bool hyst_valid(struct bcm_clk_hyst *hyst, const char *clock_name) 200 + { 201 + if (!bit_posn_valid(hyst->en_bit, "hysteresis enable", clock_name)) 202 + return false; 203 + 204 + if (!bit_posn_valid(hyst->val_bit, "hysteresis value", clock_name)) 205 + return false; 274 206 275 207 return true; 276 208 } ··· 402 312 peri_clk_data_valid(struct kona_clk *bcm_clk) 403 313 { 404 314 struct peri_clk_data *peri; 315 + struct bcm_clk_policy *policy; 405 316 struct bcm_clk_gate *gate; 317 + struct bcm_clk_hyst *hyst; 406 318 struct bcm_clk_sel *sel; 407 319 struct bcm_clk_div *div; 408 320 struct bcm_clk_div *pre_div; ··· 422 330 return false; 423 331 424 332 peri = bcm_clk->u.peri; 425 - name = bcm_clk->name; 333 + name = bcm_clk->init_data.name; 334 + 335 + policy = &peri->policy; 336 + if (policy_exists(policy) && !policy_valid(policy, name)) 337 + return false; 338 + 426 339 gate = &peri->gate; 427 340 if (gate_exists(gate) && !gate_valid(gate, "gate", name)) 341 + return false; 342 + 343 + hyst = &peri->hyst; 344 + if (hyst_exists(hyst) && !hyst_valid(hyst, name)) 428 345 return false; 429 346 430 347 sel = &peri->sel; ··· 668 567 struct clk_init_data *init_data) 669 568 { 670 569 clk_sel_teardown(&data->sel, init_data); 671 - init_data->ops = NULL; 672 570 } 673 571 674 572 /* ··· 676 576 * that can be assigned if the clock has one or more parent clocks 677 577 * associated with it. 678 578 */ 679 - static int peri_clk_setup(struct ccu_data *ccu, struct peri_clk_data *data, 680 - struct clk_init_data *init_data) 579 + static int 580 + peri_clk_setup(struct peri_clk_data *data, struct clk_init_data *init_data) 681 581 { 682 - init_data->ops = &kona_peri_clk_ops; 683 582 init_data->flags = CLK_IGNORE_UNUSED; 684 583 685 584 return clk_sel_setup(data->clocks, &data->sel, init_data); ··· 716 617 bcm_clk_teardown(bcm_clk); 717 618 } 718 619 719 - struct clk *kona_clk_setup(struct ccu_data *ccu, const char *name, 720 - enum bcm_clk_type type, void *data) 620 + struct clk *kona_clk_setup(struct kona_clk *bcm_clk) 721 621 { 722 - struct kona_clk *bcm_clk; 723 - struct clk_init_data *init_data; 622 + struct clk_init_data *init_data = &bcm_clk->init_data; 724 623 struct clk *clk = NULL; 725 624 726 - bcm_clk = kzalloc(sizeof(*bcm_clk), GFP_KERNEL); 727 - if (!bcm_clk) { 728 - pr_err("%s: failed to allocate bcm_clk for %s\n", __func__, 729 - name); 730 - return NULL; 731 - } 732 - bcm_clk->ccu = ccu; 733 - bcm_clk->name = name; 734 - 735 - init_data = &bcm_clk->init_data; 736 - init_data->name = name; 737 - switch (type) { 625 + switch (bcm_clk->type) { 738 626 case bcm_clk_peri: 739 - if (peri_clk_setup(ccu, data, init_data)) 740 - goto out_free; 627 + if (peri_clk_setup(bcm_clk->u.data, init_data)) 628 + return NULL; 741 629 break; 742 630 default: 743 - data = NULL; 744 - break; 631 + pr_err("%s: clock type %d invalid for %s\n", __func__, 632 + (int)bcm_clk->type, init_data->name); 633 + return NULL; 745 634 } 746 - bcm_clk->type = type; 747 - bcm_clk->u.data = data; 748 635 749 636 /* Make sure everything makes sense before we set it up */ 750 637 if (!kona_clk_valid(bcm_clk)) { 751 - pr_err("%s: clock data invalid for %s\n", __func__, name); 638 + pr_err("%s: clock data invalid for %s\n", __func__, 639 + init_data->name); 752 640 goto out_teardown; 753 641 } 754 642 ··· 743 657 clk = clk_register(NULL, &bcm_clk->hw); 744 658 if (IS_ERR(clk)) { 745 659 pr_err("%s: error registering clock %s (%ld)\n", __func__, 746 - name, PTR_ERR(clk)); 660 + init_data->name, PTR_ERR(clk)); 747 661 goto out_teardown; 748 662 } 749 663 BUG_ON(!clk); ··· 751 665 return clk; 752 666 out_teardown: 753 667 bcm_clk_teardown(bcm_clk); 754 - out_free: 755 - kfree(bcm_clk); 756 668 757 669 return NULL; 758 670 } ··· 759 675 { 760 676 u32 i; 761 677 762 - for (i = 0; i < ccu->data.clk_num; i++) 763 - kona_clk_teardown(ccu->data.clks[i]); 764 - kfree(ccu->data.clks); 678 + for (i = 0; i < ccu->clk_data.clk_num; i++) 679 + kona_clk_teardown(ccu->clk_data.clks[i]); 680 + kfree(ccu->clk_data.clks); 765 681 } 766 682 767 683 static void kona_ccu_teardown(struct ccu_data *ccu) 768 684 { 769 - if (!ccu) 770 - return; 771 - 685 + kfree(ccu->clk_data.clks); 686 + ccu->clk_data.clks = NULL; 772 687 if (!ccu->base) 773 - goto done; 688 + return; 774 689 775 690 of_clk_del_provider(ccu->node); /* safe if never added */ 776 691 ccu_clks_teardown(ccu); 777 692 list_del(&ccu->links); 778 693 of_node_put(ccu->node); 694 + ccu->node = NULL; 779 695 iounmap(ccu->base); 780 - done: 781 - kfree(ccu->name); 782 - kfree(ccu); 696 + ccu->base = NULL; 697 + } 698 + 699 + static bool ccu_data_valid(struct ccu_data *ccu) 700 + { 701 + struct ccu_policy *ccu_policy; 702 + 703 + if (!ccu_data_offsets_valid(ccu)) 704 + return false; 705 + 706 + ccu_policy = &ccu->policy; 707 + if (ccu_policy_exists(ccu_policy)) 708 + if (!ccu_policy_valid(ccu_policy, ccu->name)) 709 + return false; 710 + 711 + return true; 783 712 } 784 713 785 714 /* 786 715 * Set up a CCU. Call the provided ccu_clks_setup callback to 787 716 * initialize the array of clocks provided by the CCU. 788 717 */ 789 - void __init kona_dt_ccu_setup(struct device_node *node, 790 - int (*ccu_clks_setup)(struct ccu_data *)) 718 + void __init kona_dt_ccu_setup(struct ccu_data *ccu, 719 + struct device_node *node) 791 720 { 792 - struct ccu_data *ccu; 793 721 struct resource res = { 0 }; 794 722 resource_size_t range; 723 + unsigned int i; 795 724 int ret; 796 725 797 - ccu = kzalloc(sizeof(*ccu), GFP_KERNEL); 798 - if (ccu) 799 - ccu->name = kstrdup(node->name, GFP_KERNEL); 800 - if (!ccu || !ccu->name) { 801 - pr_err("%s: unable to allocate CCU struct for %s\n", 802 - __func__, node->name); 803 - kfree(ccu); 726 + if (ccu->clk_data.clk_num) { 727 + size_t size; 804 728 805 - return; 729 + size = ccu->clk_data.clk_num * sizeof(*ccu->clk_data.clks); 730 + ccu->clk_data.clks = kzalloc(size, GFP_KERNEL); 731 + if (!ccu->clk_data.clks) { 732 + pr_err("%s: unable to allocate %u clocks for %s\n", 733 + __func__, ccu->clk_data.clk_num, node->name); 734 + return; 735 + } 806 736 } 807 737 808 738 ret = of_address_to_resource(node, 0, &res); ··· 834 736 } 835 737 836 738 ccu->range = (u32)range; 739 + 740 + if (!ccu_data_valid(ccu)) { 741 + pr_err("%s: ccu data not valid for %s\n", __func__, node->name); 742 + goto out_err; 743 + } 744 + 837 745 ccu->base = ioremap(res.start, ccu->range); 838 746 if (!ccu->base) { 839 747 pr_err("%s: unable to map CCU registers for %s\n", __func__, 840 748 node->name); 841 749 goto out_err; 842 750 } 843 - 844 - spin_lock_init(&ccu->lock); 845 - INIT_LIST_HEAD(&ccu->links); 846 751 ccu->node = of_node_get(node); 847 - 848 752 list_add_tail(&ccu->links, &ccu_list); 849 753 850 - /* Set up clocks array (in ccu->data) */ 851 - if (ccu_clks_setup(ccu)) 852 - goto out_err; 754 + /* 755 + * Set up each defined kona clock and save the result in 756 + * the clock framework clock array (in ccu->data). Then 757 + * register as a provider for these clocks. 758 + */ 759 + for (i = 0; i < ccu->clk_data.clk_num; i++) { 760 + if (!ccu->kona_clks[i].ccu) 761 + continue; 762 + ccu->clk_data.clks[i] = kona_clk_setup(&ccu->kona_clks[i]); 763 + } 853 764 854 - ret = of_clk_add_provider(node, of_clk_src_onecell_get, &ccu->data); 765 + ret = of_clk_add_provider(node, of_clk_src_onecell_get, &ccu->clk_data); 855 766 if (ret) { 856 767 pr_err("%s: error adding ccu %s as provider (%d)\n", __func__, 857 768 node->name, ret);
+203 -9
drivers/clk/bcm/clk-kona.c
··· 16 16 17 17 #include <linux/delay.h> 18 18 19 + /* 20 + * "Policies" affect the frequencies of bus clocks provided by a 21 + * CCU. (I believe these polices are named "Deep Sleep", "Economy", 22 + * "Normal", and "Turbo".) A lower policy number has lower power 23 + * consumption, and policy 2 is the default. 24 + */ 25 + #define CCU_POLICY_COUNT 4 26 + 19 27 #define CCU_ACCESS_PASSWORD 0xA5A500 20 28 #define CLK_GATE_DELAY_LOOP 2000 21 29 ··· 215 207 return true; 216 208 udelay(1); 217 209 } 210 + pr_warn("%s: %s/0x%04x bit %u was never %s\n", __func__, 211 + ccu->name, reg_offset, bit, want ? "set" : "clear"); 212 + 218 213 return false; 214 + } 215 + 216 + /* Policy operations */ 217 + 218 + static bool __ccu_policy_engine_start(struct ccu_data *ccu, bool sync) 219 + { 220 + struct bcm_policy_ctl *control = &ccu->policy.control; 221 + u32 offset; 222 + u32 go_bit; 223 + u32 mask; 224 + bool ret; 225 + 226 + /* If we don't need to control policy for this CCU, we're done. */ 227 + if (!policy_ctl_exists(control)) 228 + return true; 229 + 230 + offset = control->offset; 231 + go_bit = control->go_bit; 232 + 233 + /* Ensure we're not busy before we start */ 234 + ret = __ccu_wait_bit(ccu, offset, go_bit, false); 235 + if (!ret) { 236 + pr_err("%s: ccu %s policy engine wouldn't go idle\n", 237 + __func__, ccu->name); 238 + return false; 239 + } 240 + 241 + /* 242 + * If it's a synchronous request, we'll wait for the voltage 243 + * and frequency of the active load to stabilize before 244 + * returning. To do this we select the active load by 245 + * setting the ATL bit. 246 + * 247 + * An asynchronous request instead ramps the voltage in the 248 + * background, and when that process stabilizes, the target 249 + * load is copied to the active load and the CCU frequency 250 + * is switched. We do this by selecting the target load 251 + * (ATL bit clear) and setting the request auto-copy (AC bit 252 + * set). 253 + * 254 + * Note, we do NOT read-modify-write this register. 255 + */ 256 + mask = (u32)1 << go_bit; 257 + if (sync) 258 + mask |= 1 << control->atl_bit; 259 + else 260 + mask |= 1 << control->ac_bit; 261 + __ccu_write(ccu, offset, mask); 262 + 263 + /* Wait for indication that operation is complete. */ 264 + ret = __ccu_wait_bit(ccu, offset, go_bit, false); 265 + if (!ret) 266 + pr_err("%s: ccu %s policy engine never started\n", 267 + __func__, ccu->name); 268 + 269 + return ret; 270 + } 271 + 272 + static bool __ccu_policy_engine_stop(struct ccu_data *ccu) 273 + { 274 + struct bcm_lvm_en *enable = &ccu->policy.enable; 275 + u32 offset; 276 + u32 enable_bit; 277 + bool ret; 278 + 279 + /* If we don't need to control policy for this CCU, we're done. */ 280 + if (!policy_lvm_en_exists(enable)) 281 + return true; 282 + 283 + /* Ensure we're not busy before we start */ 284 + offset = enable->offset; 285 + enable_bit = enable->bit; 286 + ret = __ccu_wait_bit(ccu, offset, enable_bit, false); 287 + if (!ret) { 288 + pr_err("%s: ccu %s policy engine already stopped\n", 289 + __func__, ccu->name); 290 + return false; 291 + } 292 + 293 + /* Now set the bit to stop the engine (NO read-modify-write) */ 294 + __ccu_write(ccu, offset, (u32)1 << enable_bit); 295 + 296 + /* Wait for indication that it has stopped. */ 297 + ret = __ccu_wait_bit(ccu, offset, enable_bit, false); 298 + if (!ret) 299 + pr_err("%s: ccu %s policy engine never stopped\n", 300 + __func__, ccu->name); 301 + 302 + return ret; 303 + } 304 + 305 + /* 306 + * A CCU has four operating conditions ("policies"), and some clocks 307 + * can be disabled or enabled based on which policy is currently in 308 + * effect. Such clocks have a bit in a "policy mask" register for 309 + * each policy indicating whether the clock is enabled for that 310 + * policy or not. The bit position for a clock is the same for all 311 + * four registers, and the 32-bit registers are at consecutive 312 + * addresses. 313 + */ 314 + static bool policy_init(struct ccu_data *ccu, struct bcm_clk_policy *policy) 315 + { 316 + u32 offset; 317 + u32 mask; 318 + int i; 319 + bool ret; 320 + 321 + if (!policy_exists(policy)) 322 + return true; 323 + 324 + /* 325 + * We need to stop the CCU policy engine to allow update 326 + * of our policy bits. 327 + */ 328 + if (!__ccu_policy_engine_stop(ccu)) { 329 + pr_err("%s: unable to stop CCU %s policy engine\n", 330 + __func__, ccu->name); 331 + return false; 332 + } 333 + 334 + /* 335 + * For now, if a clock defines its policy bit we just mark 336 + * it "enabled" for all four policies. 337 + */ 338 + offset = policy->offset; 339 + mask = (u32)1 << policy->bit; 340 + for (i = 0; i < CCU_POLICY_COUNT; i++) { 341 + u32 reg_val; 342 + 343 + reg_val = __ccu_read(ccu, offset); 344 + reg_val |= mask; 345 + __ccu_write(ccu, offset, reg_val); 346 + offset += sizeof(u32); 347 + } 348 + 349 + /* We're done updating; fire up the policy engine again. */ 350 + ret = __ccu_policy_engine_start(ccu, true); 351 + if (!ret) 352 + pr_err("%s: unable to restart CCU %s policy engine\n", 353 + __func__, ccu->name); 354 + 355 + return ret; 219 356 } 220 357 221 358 /* Gate operations */ ··· 525 372 enable ? "enable" : "disable", name); 526 373 527 374 return -EIO; 375 + } 376 + 377 + /* Hysteresis operations */ 378 + 379 + /* 380 + * If a clock gate requires a turn-off delay it will have 381 + * "hysteresis" register bits defined. The first, if set, enables 382 + * the delay; and if enabled, the second bit determines whether the 383 + * delay is "low" or "high" (1 means high). For now, if it's 384 + * defined for a clock, we set it. 385 + */ 386 + static bool hyst_init(struct ccu_data *ccu, struct bcm_clk_hyst *hyst) 387 + { 388 + u32 offset; 389 + u32 reg_val; 390 + u32 mask; 391 + 392 + if (!hyst_exists(hyst)) 393 + return true; 394 + 395 + offset = hyst->offset; 396 + mask = (u32)1 << hyst->en_bit; 397 + mask |= (u32)1 << hyst->val_bit; 398 + 399 + reg_val = __ccu_read(ccu, offset); 400 + reg_val |= mask; 401 + __ccu_write(ccu, offset, reg_val); 402 + 403 + return true; 528 404 } 529 405 530 406 /* Trigger operations */ ··· 988 806 struct kona_clk *bcm_clk = to_kona_clk(hw); 989 807 struct bcm_clk_gate *gate = &bcm_clk->u.peri->gate; 990 808 991 - return clk_gate(bcm_clk->ccu, bcm_clk->name, gate, true); 809 + return clk_gate(bcm_clk->ccu, bcm_clk->init_data.name, gate, true); 992 810 } 993 811 994 812 static void kona_peri_clk_disable(struct clk_hw *hw) ··· 996 814 struct kona_clk *bcm_clk = to_kona_clk(hw); 997 815 struct bcm_clk_gate *gate = &bcm_clk->u.peri->gate; 998 816 999 - (void)clk_gate(bcm_clk->ccu, bcm_clk->name, gate, false); 817 + (void)clk_gate(bcm_clk->ccu, bcm_clk->init_data.name, gate, false); 1000 818 } 1001 819 1002 820 static int kona_peri_clk_is_enabled(struct clk_hw *hw) ··· 1054 872 1055 873 ret = selector_write(bcm_clk->ccu, &data->gate, sel, trig, index); 1056 874 if (ret == -ENXIO) { 1057 - pr_err("%s: gating failure for %s\n", __func__, bcm_clk->name); 875 + pr_err("%s: gating failure for %s\n", __func__, 876 + bcm_clk->init_data.name); 1058 877 ret = -EIO; /* Don't proliferate weird errors */ 1059 878 } else if (ret == -EIO) { 1060 879 pr_err("%s: %strigger failed for %s\n", __func__, 1061 880 trig == &data->pre_trig ? "pre-" : "", 1062 - bcm_clk->name); 881 + bcm_clk->init_data.name); 1063 882 } 1064 883 1065 884 return ret; ··· 1119 936 ret = divider_write(bcm_clk->ccu, &data->gate, &data->div, 1120 937 &data->trig, scaled_div); 1121 938 if (ret == -ENXIO) { 1122 - pr_err("%s: gating failure for %s\n", __func__, bcm_clk->name); 939 + pr_err("%s: gating failure for %s\n", __func__, 940 + bcm_clk->init_data.name); 1123 941 ret = -EIO; /* Don't proliferate weird errors */ 1124 942 } else if (ret == -EIO) { 1125 - pr_err("%s: trigger failed for %s\n", __func__, bcm_clk->name); 943 + pr_err("%s: trigger failed for %s\n", __func__, 944 + bcm_clk->init_data.name); 1126 945 } 1127 946 1128 947 return ret; ··· 1146 961 { 1147 962 struct ccu_data *ccu = bcm_clk->ccu; 1148 963 struct peri_clk_data *peri = bcm_clk->u.peri; 1149 - const char *name = bcm_clk->name; 964 + const char *name = bcm_clk->init_data.name; 1150 965 struct bcm_clk_trig *trig; 1151 966 1152 967 BUG_ON(bcm_clk->type != bcm_clk_peri); 1153 968 969 + if (!policy_init(ccu, &peri->policy)) { 970 + pr_err("%s: error initializing policy for %s\n", 971 + __func__, name); 972 + return false; 973 + } 1154 974 if (!gate_init(ccu, &peri->gate)) { 1155 975 pr_err("%s: error initializing gate for %s\n", __func__, name); 976 + return false; 977 + } 978 + if (!hyst_init(ccu, &peri->hyst)) { 979 + pr_err("%s: error initializing hyst for %s\n", __func__, name); 1156 980 return false; 1157 981 } 1158 982 if (!div_init(ccu, &peri->gate, &peri->div, &peri->trig)) { ··· 1208 1014 { 1209 1015 unsigned long flags; 1210 1016 unsigned int which; 1211 - struct clk **clks = ccu->data.clks; 1017 + struct clk **clks = ccu->clk_data.clks; 1212 1018 bool success = true; 1213 1019 1214 1020 flags = ccu_lock(ccu); 1215 1021 __ccu_write_enable(ccu); 1216 1022 1217 - for (which = 0; which < ccu->data.clk_num; which++) { 1023 + for (which = 0; which < ccu->clk_data.clk_num; which++) { 1218 1024 struct kona_clk *bcm_clk; 1219 1025 1220 1026 if (!clks[which])
+133 -27
drivers/clk/bcm/clk-kona.h
··· 43 43 #define FLAG_FLIP(obj, type, flag) ((obj)->flags ^= FLAG(type, flag)) 44 44 #define FLAG_TEST(obj, type, flag) (!!((obj)->flags & FLAG(type, flag))) 45 45 46 + /* CCU field state tests */ 47 + 48 + #define ccu_policy_exists(ccu_policy) ((ccu_policy)->enable.offset != 0) 49 + 46 50 /* Clock field state tests */ 51 + 52 + #define policy_exists(policy) ((policy)->offset != 0) 47 53 48 54 #define gate_exists(gate) FLAG_TEST(gate, GATE, EXISTS) 49 55 #define gate_is_enabled(gate) FLAG_TEST(gate, GATE, ENABLED) ··· 60 54 61 55 #define gate_flip_enabled(gate) FLAG_FLIP(gate, GATE, ENABLED) 62 56 57 + #define hyst_exists(hyst) ((hyst)->offset != 0) 58 + 63 59 #define divider_exists(div) FLAG_TEST(div, DIV, EXISTS) 64 60 #define divider_is_fixed(div) FLAG_TEST(div, DIV, FIXED) 65 61 #define divider_has_fraction(div) (!divider_is_fixed(div) && \ ··· 69 61 70 62 #define selector_exists(sel) ((sel)->width != 0) 71 63 #define trigger_exists(trig) FLAG_TEST(trig, TRIG, EXISTS) 64 + 65 + #define policy_lvm_en_exists(enable) ((enable)->offset != 0) 66 + #define policy_ctl_exists(control) ((control)->offset != 0) 72 67 73 68 /* Clock type, used to tell common block what it's part of */ 74 69 enum bcm_clk_type { ··· 82 71 }; 83 72 84 73 /* 85 - * Each CCU defines a mapped area of memory containing registers 86 - * used to manage clocks implemented by the CCU. Access to memory 87 - * within the CCU's space is serialized by a spinlock. Before any 88 - * (other) address can be written, a special access "password" value 89 - * must be written to its WR_ACCESS register (located at the base 90 - * address of the range). We keep track of the name of each CCU as 91 - * it is set up, and maintain them in a list. 74 + * CCU policy control for clocks. Clocks can be enabled or disabled 75 + * based on the CCU policy in effect. One bit in each policy mask 76 + * register (one per CCU policy) represents whether the clock is 77 + * enabled when that policy is effect or not. The CCU policy engine 78 + * must be stopped to update these bits, and must be restarted again 79 + * afterward. 92 80 */ 93 - struct ccu_data { 94 - void __iomem *base; /* base of mapped address space */ 95 - spinlock_t lock; /* serialization lock */ 96 - bool write_enabled; /* write access is currently enabled */ 97 - struct list_head links; /* for ccu_list */ 98 - struct device_node *node; 99 - struct clk_onecell_data data; 100 - const char *name; 101 - u32 range; /* byte range of address space */ 81 + struct bcm_clk_policy { 82 + u32 offset; /* first policy mask register offset */ 83 + u32 bit; /* bit used in all mask registers */ 102 84 }; 85 + 86 + /* Policy initialization macro */ 87 + 88 + #define POLICY(_offset, _bit) \ 89 + { \ 90 + .offset = (_offset), \ 91 + .bit = (_bit), \ 92 + } 103 93 104 94 /* 105 95 * Gating control and status is managed by a 32-bit gate register. ··· 205 193 .offset = (_offset), \ 206 194 .status_bit = (_status_bit), \ 207 195 .flags = FLAG(GATE, HW)|FLAG(GATE, EXISTS), \ 196 + } 197 + 198 + /* Gate hysteresis for clocks */ 199 + struct bcm_clk_hyst { 200 + u32 offset; /* hyst register offset (normally CLKGATE) */ 201 + u32 en_bit; /* bit used to enable hysteresis */ 202 + u32 val_bit; /* if enabled: 0 = low delay; 1 = high delay */ 203 + }; 204 + 205 + /* Hysteresis initialization macro */ 206 + 207 + #define HYST(_offset, _en_bit, _val_bit) \ 208 + { \ 209 + .offset = (_offset), \ 210 + .en_bit = (_en_bit), \ 211 + .val_bit = (_val_bit), \ 208 212 } 209 213 210 214 /* ··· 388 360 } 389 361 390 362 struct peri_clk_data { 363 + struct bcm_clk_policy policy; 391 364 struct bcm_clk_gate gate; 365 + struct bcm_clk_hyst hyst; 392 366 struct bcm_clk_trig pre_trig; 393 367 struct bcm_clk_div pre_div; 394 368 struct bcm_clk_trig trig; ··· 403 373 404 374 struct kona_clk { 405 375 struct clk_hw hw; 406 - struct clk_init_data init_data; 407 - const char *name; /* name of this clock */ 376 + struct clk_init_data init_data; /* includes name of this clock */ 408 377 struct ccu_data *ccu; /* ccu this clock is associated with */ 409 378 enum bcm_clk_type type; 410 379 union { ··· 414 385 #define to_kona_clk(_hw) \ 415 386 container_of(_hw, struct kona_clk, hw) 416 387 388 + /* Initialization macro for an entry in a CCU's kona_clks[] array. */ 389 + #define KONA_CLK(_ccu_name, _clk_name, _type) \ 390 + { \ 391 + .init_data = { \ 392 + .name = #_clk_name, \ 393 + .ops = &kona_ ## _type ## _clk_ops, \ 394 + }, \ 395 + .ccu = &_ccu_name ## _ccu_data, \ 396 + .type = bcm_clk_ ## _type, \ 397 + .u.data = &_clk_name ## _data, \ 398 + } 399 + #define LAST_KONA_CLK { .type = bcm_clk_none } 400 + 401 + /* 402 + * CCU policy control. To enable software update of the policy 403 + * tables the CCU policy engine must be stopped by setting the 404 + * software update enable bit (LVM_EN). After an update the engine 405 + * is restarted using the GO bit and either the GO_ATL or GO_AC bit. 406 + */ 407 + struct bcm_lvm_en { 408 + u32 offset; /* LVM_EN register offset */ 409 + u32 bit; /* POLICY_CONFIG_EN bit in register */ 410 + }; 411 + 412 + /* Policy enable initialization macro */ 413 + #define CCU_LVM_EN(_offset, _bit) \ 414 + { \ 415 + .offset = (_offset), \ 416 + .bit = (_bit), \ 417 + } 418 + 419 + struct bcm_policy_ctl { 420 + u32 offset; /* POLICY_CTL register offset */ 421 + u32 go_bit; 422 + u32 atl_bit; /* GO, GO_ATL, and GO_AC bits */ 423 + u32 ac_bit; 424 + }; 425 + 426 + /* Policy control initialization macro */ 427 + #define CCU_POLICY_CTL(_offset, _go_bit, _ac_bit, _atl_bit) \ 428 + { \ 429 + .offset = (_offset), \ 430 + .go_bit = (_go_bit), \ 431 + .ac_bit = (_ac_bit), \ 432 + .atl_bit = (_atl_bit), \ 433 + } 434 + 435 + struct ccu_policy { 436 + struct bcm_lvm_en enable; 437 + struct bcm_policy_ctl control; 438 + }; 439 + 440 + /* 441 + * Each CCU defines a mapped area of memory containing registers 442 + * used to manage clocks implemented by the CCU. Access to memory 443 + * within the CCU's space is serialized by a spinlock. Before any 444 + * (other) address can be written, a special access "password" value 445 + * must be written to its WR_ACCESS register (located at the base 446 + * address of the range). We keep track of the name of each CCU as 447 + * it is set up, and maintain them in a list. 448 + */ 449 + struct ccu_data { 450 + void __iomem *base; /* base of mapped address space */ 451 + spinlock_t lock; /* serialization lock */ 452 + bool write_enabled; /* write access is currently enabled */ 453 + struct ccu_policy policy; 454 + struct list_head links; /* for ccu_list */ 455 + struct device_node *node; 456 + struct clk_onecell_data clk_data; 457 + const char *name; 458 + u32 range; /* byte range of address space */ 459 + struct kona_clk kona_clks[]; /* must be last */ 460 + }; 461 + 462 + /* Initialization for common fields in a Kona ccu_data structure */ 463 + #define KONA_CCU_COMMON(_prefix, _name, _ccuname) \ 464 + .name = #_name "_ccu", \ 465 + .lock = __SPIN_LOCK_UNLOCKED(_name ## _ccu_data.lock), \ 466 + .links = LIST_HEAD_INIT(_name ## _ccu_data.links), \ 467 + .clk_data = { \ 468 + .clk_num = _prefix ## _ ## _ccuname ## _CCU_CLOCK_COUNT, \ 469 + } 470 + 417 471 /* Exported globals */ 418 472 419 473 extern struct clk_ops kona_peri_clk_ops; 420 - 421 - /* Help functions */ 422 - 423 - #define PERI_CLK_SETUP(clks, ccu, id, name) \ 424 - clks[id] = kona_clk_setup(ccu, #name, bcm_clk_peri, &name ## _data) 425 474 426 475 /* Externally visible functions */ 427 476 ··· 508 401 extern u64 scaled_div_build(struct bcm_clk_div *div, u32 div_value, 509 402 u32 billionths); 510 403 511 - extern struct clk *kona_clk_setup(struct ccu_data *ccu, const char *name, 512 - enum bcm_clk_type type, void *data); 513 - extern void __init kona_dt_ccu_setup(struct device_node *node, 514 - int (*ccu_clks_setup)(struct ccu_data *)); 404 + extern struct clk *kona_clk_setup(struct kona_clk *bcm_clk); 405 + extern void __init kona_dt_ccu_setup(struct ccu_data *ccu, 406 + struct device_node *node); 515 407 extern bool __init kona_ccu_init(struct ccu_data *ccu); 516 408 517 409 #endif /* _CLK_KONA_H */
+615
drivers/clk/clk-axm5516.c
··· 1 + /* 2 + * drivers/clk/clk-axm5516.c 3 + * 4 + * Provides clock implementations for three different types of clock devices on 5 + * the Axxia device: PLL clock, a clock divider and a clock mux. 6 + * 7 + * Copyright (C) 2014 LSI Corporation 8 + * 9 + * This program is free software; you can redistribute it and/or modify it 10 + * under the terms of the GNU General Public License version 2 as published by 11 + * the Free Software Foundation. 12 + */ 13 + #include <linux/module.h> 14 + #include <linux/kernel.h> 15 + #include <linux/slab.h> 16 + #include <linux/platform_device.h> 17 + #include <linux/of.h> 18 + #include <linux/of_address.h> 19 + #include <linux/clk-provider.h> 20 + #include <linux/regmap.h> 21 + #include <dt-bindings/clock/lsi,axm5516-clks.h> 22 + 23 + 24 + /** 25 + * struct axxia_clk - Common struct to all Axxia clocks. 26 + * @hw: clk_hw for the common clk framework 27 + * @regmap: Regmap for the clock control registers 28 + */ 29 + struct axxia_clk { 30 + struct clk_hw hw; 31 + struct regmap *regmap; 32 + }; 33 + #define to_axxia_clk(_hw) container_of(_hw, struct axxia_clk, hw) 34 + 35 + /** 36 + * struct axxia_pllclk - Axxia PLL generated clock. 37 + * @aclk: Common struct 38 + * @reg: Offset into regmap for PLL control register 39 + */ 40 + struct axxia_pllclk { 41 + struct axxia_clk aclk; 42 + u32 reg; 43 + }; 44 + #define to_axxia_pllclk(_aclk) container_of(_aclk, struct axxia_pllclk, aclk) 45 + 46 + /** 47 + * axxia_pllclk_recalc - Calculate the PLL generated clock rate given the 48 + * parent clock rate. 49 + */ 50 + static unsigned long 51 + axxia_pllclk_recalc(struct clk_hw *hw, unsigned long parent_rate) 52 + { 53 + struct axxia_clk *aclk = to_axxia_clk(hw); 54 + struct axxia_pllclk *pll = to_axxia_pllclk(aclk); 55 + unsigned long rate, fbdiv, refdiv, postdiv; 56 + u32 control; 57 + 58 + regmap_read(aclk->regmap, pll->reg, &control); 59 + postdiv = ((control >> 0) & 0xf) + 1; 60 + fbdiv = ((control >> 4) & 0xfff) + 3; 61 + refdiv = ((control >> 16) & 0x1f) + 1; 62 + rate = (parent_rate / (refdiv * postdiv)) * fbdiv; 63 + 64 + return rate; 65 + } 66 + 67 + static const struct clk_ops axxia_pllclk_ops = { 68 + .recalc_rate = axxia_pllclk_recalc, 69 + }; 70 + 71 + /** 72 + * struct axxia_divclk - Axxia clock divider 73 + * @aclk: Common struct 74 + * @reg: Offset into regmap for PLL control register 75 + * @shift: Bit position for divider value 76 + * @width: Number of bits in divider value 77 + */ 78 + struct axxia_divclk { 79 + struct axxia_clk aclk; 80 + u32 reg; 81 + u32 shift; 82 + u32 width; 83 + }; 84 + #define to_axxia_divclk(_aclk) container_of(_aclk, struct axxia_divclk, aclk) 85 + 86 + /** 87 + * axxia_divclk_recalc_rate - Calculate clock divider output rage 88 + */ 89 + static unsigned long 90 + axxia_divclk_recalc_rate(struct clk_hw *hw, unsigned long parent_rate) 91 + { 92 + struct axxia_clk *aclk = to_axxia_clk(hw); 93 + struct axxia_divclk *divclk = to_axxia_divclk(aclk); 94 + u32 ctrl, div; 95 + 96 + regmap_read(aclk->regmap, divclk->reg, &ctrl); 97 + div = 1 + ((ctrl >> divclk->shift) & ((1 << divclk->width)-1)); 98 + 99 + return parent_rate / div; 100 + } 101 + 102 + static const struct clk_ops axxia_divclk_ops = { 103 + .recalc_rate = axxia_divclk_recalc_rate, 104 + }; 105 + 106 + /** 107 + * struct axxia_clkmux - Axxia clock mux 108 + * @aclk: Common struct 109 + * @reg: Offset into regmap for PLL control register 110 + * @shift: Bit position for selection value 111 + * @width: Number of bits in selection value 112 + */ 113 + struct axxia_clkmux { 114 + struct axxia_clk aclk; 115 + u32 reg; 116 + u32 shift; 117 + u32 width; 118 + }; 119 + #define to_axxia_clkmux(_aclk) container_of(_aclk, struct axxia_clkmux, aclk) 120 + 121 + /** 122 + * axxia_clkmux_get_parent - Return the index of selected parent clock 123 + */ 124 + static u8 axxia_clkmux_get_parent(struct clk_hw *hw) 125 + { 126 + struct axxia_clk *aclk = to_axxia_clk(hw); 127 + struct axxia_clkmux *mux = to_axxia_clkmux(aclk); 128 + u32 ctrl, parent; 129 + 130 + regmap_read(aclk->regmap, mux->reg, &ctrl); 131 + parent = (ctrl >> mux->shift) & ((1 << mux->width) - 1); 132 + 133 + return (u8) parent; 134 + } 135 + 136 + static const struct clk_ops axxia_clkmux_ops = { 137 + .get_parent = axxia_clkmux_get_parent, 138 + }; 139 + 140 + 141 + /* 142 + * PLLs 143 + */ 144 + 145 + static struct axxia_pllclk clk_fab_pll = { 146 + .aclk.hw.init = &(struct clk_init_data){ 147 + .name = "clk_fab_pll", 148 + .parent_names = (const char *[]){ 149 + "clk_ref0" 150 + }, 151 + .num_parents = 1, 152 + .ops = &axxia_pllclk_ops, 153 + }, 154 + .reg = 0x01800, 155 + }; 156 + 157 + static struct axxia_pllclk clk_cpu_pll = { 158 + .aclk.hw.init = &(struct clk_init_data){ 159 + .name = "clk_cpu_pll", 160 + .parent_names = (const char *[]){ 161 + "clk_ref0" 162 + }, 163 + .num_parents = 1, 164 + .ops = &axxia_pllclk_ops, 165 + }, 166 + .reg = 0x02000, 167 + }; 168 + 169 + static struct axxia_pllclk clk_sys_pll = { 170 + .aclk.hw.init = &(struct clk_init_data){ 171 + .name = "clk_sys_pll", 172 + .parent_names = (const char *[]){ 173 + "clk_ref0" 174 + }, 175 + .num_parents = 1, 176 + .ops = &axxia_pllclk_ops, 177 + }, 178 + .reg = 0x02800, 179 + }; 180 + 181 + static struct axxia_pllclk clk_sm0_pll = { 182 + .aclk.hw.init = &(struct clk_init_data){ 183 + .name = "clk_sm0_pll", 184 + .parent_names = (const char *[]){ 185 + "clk_ref2" 186 + }, 187 + .num_parents = 1, 188 + .ops = &axxia_pllclk_ops, 189 + }, 190 + .reg = 0x03000, 191 + }; 192 + 193 + static struct axxia_pllclk clk_sm1_pll = { 194 + .aclk.hw.init = &(struct clk_init_data){ 195 + .name = "clk_sm1_pll", 196 + .parent_names = (const char *[]){ 197 + "clk_ref1" 198 + }, 199 + .num_parents = 1, 200 + .ops = &axxia_pllclk_ops, 201 + }, 202 + .reg = 0x03800, 203 + }; 204 + 205 + /* 206 + * Clock dividers 207 + */ 208 + 209 + static struct axxia_divclk clk_cpu0_div = { 210 + .aclk.hw.init = &(struct clk_init_data){ 211 + .name = "clk_cpu0_div", 212 + .parent_names = (const char *[]){ 213 + "clk_cpu_pll" 214 + }, 215 + .num_parents = 1, 216 + .ops = &axxia_divclk_ops, 217 + }, 218 + .reg = 0x10008, 219 + .shift = 0, 220 + .width = 4, 221 + }; 222 + 223 + static struct axxia_divclk clk_cpu1_div = { 224 + .aclk.hw.init = &(struct clk_init_data){ 225 + .name = "clk_cpu1_div", 226 + .parent_names = (const char *[]){ 227 + "clk_cpu_pll" 228 + }, 229 + .num_parents = 1, 230 + .ops = &axxia_divclk_ops, 231 + }, 232 + .reg = 0x10008, 233 + .shift = 4, 234 + .width = 4, 235 + }; 236 + 237 + static struct axxia_divclk clk_cpu2_div = { 238 + .aclk.hw.init = &(struct clk_init_data){ 239 + .name = "clk_cpu2_div", 240 + .parent_names = (const char *[]){ 241 + "clk_cpu_pll" 242 + }, 243 + .num_parents = 1, 244 + .ops = &axxia_divclk_ops, 245 + }, 246 + .reg = 0x10008, 247 + .shift = 8, 248 + .width = 4, 249 + }; 250 + 251 + static struct axxia_divclk clk_cpu3_div = { 252 + .aclk.hw.init = &(struct clk_init_data){ 253 + .name = "clk_cpu3_div", 254 + .parent_names = (const char *[]){ 255 + "clk_cpu_pll" 256 + }, 257 + .num_parents = 1, 258 + .ops = &axxia_divclk_ops, 259 + }, 260 + .reg = 0x10008, 261 + .shift = 12, 262 + .width = 4, 263 + }; 264 + 265 + static struct axxia_divclk clk_nrcp_div = { 266 + .aclk.hw.init = &(struct clk_init_data){ 267 + .name = "clk_nrcp_div", 268 + .parent_names = (const char *[]){ 269 + "clk_sys_pll" 270 + }, 271 + .num_parents = 1, 272 + .ops = &axxia_divclk_ops, 273 + }, 274 + .reg = 0x1000c, 275 + .shift = 0, 276 + .width = 4, 277 + }; 278 + 279 + static struct axxia_divclk clk_sys_div = { 280 + .aclk.hw.init = &(struct clk_init_data){ 281 + .name = "clk_sys_div", 282 + .parent_names = (const char *[]){ 283 + "clk_sys_pll" 284 + }, 285 + .num_parents = 1, 286 + .ops = &axxia_divclk_ops, 287 + }, 288 + .reg = 0x1000c, 289 + .shift = 4, 290 + .width = 4, 291 + }; 292 + 293 + static struct axxia_divclk clk_fab_div = { 294 + .aclk.hw.init = &(struct clk_init_data){ 295 + .name = "clk_fab_div", 296 + .parent_names = (const char *[]){ 297 + "clk_fab_pll" 298 + }, 299 + .num_parents = 1, 300 + .ops = &axxia_divclk_ops, 301 + }, 302 + .reg = 0x1000c, 303 + .shift = 8, 304 + .width = 4, 305 + }; 306 + 307 + static struct axxia_divclk clk_per_div = { 308 + .aclk.hw.init = &(struct clk_init_data){ 309 + .name = "clk_per_div", 310 + .parent_names = (const char *[]){ 311 + "clk_sm1_pll" 312 + }, 313 + .num_parents = 1, 314 + .flags = CLK_IS_BASIC, 315 + .ops = &axxia_divclk_ops, 316 + }, 317 + .reg = 0x1000c, 318 + .shift = 12, 319 + .width = 4, 320 + }; 321 + 322 + static struct axxia_divclk clk_mmc_div = { 323 + .aclk.hw.init = &(struct clk_init_data){ 324 + .name = "clk_mmc_div", 325 + .parent_names = (const char *[]){ 326 + "clk_sm1_pll" 327 + }, 328 + .num_parents = 1, 329 + .flags = CLK_IS_BASIC, 330 + .ops = &axxia_divclk_ops, 331 + }, 332 + .reg = 0x1000c, 333 + .shift = 16, 334 + .width = 4, 335 + }; 336 + 337 + /* 338 + * Clock MUXes 339 + */ 340 + 341 + static struct axxia_clkmux clk_cpu0_mux = { 342 + .aclk.hw.init = &(struct clk_init_data){ 343 + .name = "clk_cpu0", 344 + .parent_names = (const char *[]){ 345 + "clk_ref0", 346 + "clk_cpu_pll", 347 + "clk_cpu0_div", 348 + "clk_cpu0_div" 349 + }, 350 + .num_parents = 4, 351 + .ops = &axxia_clkmux_ops, 352 + }, 353 + .reg = 0x10000, 354 + .shift = 0, 355 + .width = 2, 356 + }; 357 + 358 + static struct axxia_clkmux clk_cpu1_mux = { 359 + .aclk.hw.init = &(struct clk_init_data){ 360 + .name = "clk_cpu1", 361 + .parent_names = (const char *[]){ 362 + "clk_ref0", 363 + "clk_cpu_pll", 364 + "clk_cpu1_div", 365 + "clk_cpu1_div" 366 + }, 367 + .num_parents = 4, 368 + .ops = &axxia_clkmux_ops, 369 + }, 370 + .reg = 0x10000, 371 + .shift = 2, 372 + .width = 2, 373 + }; 374 + 375 + static struct axxia_clkmux clk_cpu2_mux = { 376 + .aclk.hw.init = &(struct clk_init_data){ 377 + .name = "clk_cpu2", 378 + .parent_names = (const char *[]){ 379 + "clk_ref0", 380 + "clk_cpu_pll", 381 + "clk_cpu2_div", 382 + "clk_cpu2_div" 383 + }, 384 + .num_parents = 4, 385 + .ops = &axxia_clkmux_ops, 386 + }, 387 + .reg = 0x10000, 388 + .shift = 4, 389 + .width = 2, 390 + }; 391 + 392 + static struct axxia_clkmux clk_cpu3_mux = { 393 + .aclk.hw.init = &(struct clk_init_data){ 394 + .name = "clk_cpu3", 395 + .parent_names = (const char *[]){ 396 + "clk_ref0", 397 + "clk_cpu_pll", 398 + "clk_cpu3_div", 399 + "clk_cpu3_div" 400 + }, 401 + .num_parents = 4, 402 + .ops = &axxia_clkmux_ops, 403 + }, 404 + .reg = 0x10000, 405 + .shift = 6, 406 + .width = 2, 407 + }; 408 + 409 + static struct axxia_clkmux clk_nrcp_mux = { 410 + .aclk.hw.init = &(struct clk_init_data){ 411 + .name = "clk_nrcp", 412 + .parent_names = (const char *[]){ 413 + "clk_ref0", 414 + "clk_sys_pll", 415 + "clk_nrcp_div", 416 + "clk_nrcp_div" 417 + }, 418 + .num_parents = 4, 419 + .ops = &axxia_clkmux_ops, 420 + }, 421 + .reg = 0x10004, 422 + .shift = 0, 423 + .width = 2, 424 + }; 425 + 426 + static struct axxia_clkmux clk_sys_mux = { 427 + .aclk.hw.init = &(struct clk_init_data){ 428 + .name = "clk_sys", 429 + .parent_names = (const char *[]){ 430 + "clk_ref0", 431 + "clk_sys_pll", 432 + "clk_sys_div", 433 + "clk_sys_div" 434 + }, 435 + .num_parents = 4, 436 + .ops = &axxia_clkmux_ops, 437 + }, 438 + .reg = 0x10004, 439 + .shift = 2, 440 + .width = 2, 441 + }; 442 + 443 + static struct axxia_clkmux clk_fab_mux = { 444 + .aclk.hw.init = &(struct clk_init_data){ 445 + .name = "clk_fab", 446 + .parent_names = (const char *[]){ 447 + "clk_ref0", 448 + "clk_fab_pll", 449 + "clk_fab_div", 450 + "clk_fab_div" 451 + }, 452 + .num_parents = 4, 453 + .ops = &axxia_clkmux_ops, 454 + }, 455 + .reg = 0x10004, 456 + .shift = 4, 457 + .width = 2, 458 + }; 459 + 460 + static struct axxia_clkmux clk_per_mux = { 461 + .aclk.hw.init = &(struct clk_init_data){ 462 + .name = "clk_per", 463 + .parent_names = (const char *[]){ 464 + "clk_ref1", 465 + "clk_per_div" 466 + }, 467 + .num_parents = 2, 468 + .ops = &axxia_clkmux_ops, 469 + }, 470 + .reg = 0x10004, 471 + .shift = 6, 472 + .width = 1, 473 + }; 474 + 475 + static struct axxia_clkmux clk_mmc_mux = { 476 + .aclk.hw.init = &(struct clk_init_data){ 477 + .name = "clk_mmc", 478 + .parent_names = (const char *[]){ 479 + "clk_ref1", 480 + "clk_mmc_div" 481 + }, 482 + .num_parents = 2, 483 + .ops = &axxia_clkmux_ops, 484 + }, 485 + .reg = 0x10004, 486 + .shift = 9, 487 + .width = 1, 488 + }; 489 + 490 + /* Table of all supported clocks indexed by the clock identifiers from the 491 + * device tree binding 492 + */ 493 + static struct axxia_clk *axmclk_clocks[] = { 494 + [AXXIA_CLK_FAB_PLL] = &clk_fab_pll.aclk, 495 + [AXXIA_CLK_CPU_PLL] = &clk_cpu_pll.aclk, 496 + [AXXIA_CLK_SYS_PLL] = &clk_sys_pll.aclk, 497 + [AXXIA_CLK_SM0_PLL] = &clk_sm0_pll.aclk, 498 + [AXXIA_CLK_SM1_PLL] = &clk_sm1_pll.aclk, 499 + [AXXIA_CLK_FAB_DIV] = &clk_fab_div.aclk, 500 + [AXXIA_CLK_SYS_DIV] = &clk_sys_div.aclk, 501 + [AXXIA_CLK_NRCP_DIV] = &clk_nrcp_div.aclk, 502 + [AXXIA_CLK_CPU0_DIV] = &clk_cpu0_div.aclk, 503 + [AXXIA_CLK_CPU1_DIV] = &clk_cpu1_div.aclk, 504 + [AXXIA_CLK_CPU2_DIV] = &clk_cpu2_div.aclk, 505 + [AXXIA_CLK_CPU3_DIV] = &clk_cpu3_div.aclk, 506 + [AXXIA_CLK_PER_DIV] = &clk_per_div.aclk, 507 + [AXXIA_CLK_MMC_DIV] = &clk_mmc_div.aclk, 508 + [AXXIA_CLK_FAB] = &clk_fab_mux.aclk, 509 + [AXXIA_CLK_SYS] = &clk_sys_mux.aclk, 510 + [AXXIA_CLK_NRCP] = &clk_nrcp_mux.aclk, 511 + [AXXIA_CLK_CPU0] = &clk_cpu0_mux.aclk, 512 + [AXXIA_CLK_CPU1] = &clk_cpu1_mux.aclk, 513 + [AXXIA_CLK_CPU2] = &clk_cpu2_mux.aclk, 514 + [AXXIA_CLK_CPU3] = &clk_cpu3_mux.aclk, 515 + [AXXIA_CLK_PER] = &clk_per_mux.aclk, 516 + [AXXIA_CLK_MMC] = &clk_mmc_mux.aclk, 517 + }; 518 + 519 + static const struct regmap_config axmclk_regmap_config = { 520 + .reg_bits = 32, 521 + .reg_stride = 4, 522 + .val_bits = 32, 523 + .max_register = 0x1fffc, 524 + .fast_io = true, 525 + }; 526 + 527 + static const struct of_device_id axmclk_match_table[] = { 528 + { .compatible = "lsi,axm5516-clks" }, 529 + { } 530 + }; 531 + MODULE_DEVICE_TABLE(of, axmclk_match_table); 532 + 533 + struct axmclk_priv { 534 + struct clk_onecell_data onecell; 535 + struct clk *clks[]; 536 + }; 537 + 538 + static int axmclk_probe(struct platform_device *pdev) 539 + { 540 + void __iomem *base; 541 + struct resource *res; 542 + int i, ret; 543 + struct device *dev = &pdev->dev; 544 + struct clk *clk; 545 + struct regmap *regmap; 546 + size_t num_clks; 547 + struct axmclk_priv *priv; 548 + 549 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 550 + base = devm_ioremap_resource(dev, res); 551 + if (IS_ERR(base)) 552 + return PTR_ERR(base); 553 + 554 + regmap = devm_regmap_init_mmio(dev, base, &axmclk_regmap_config); 555 + if (IS_ERR(regmap)) 556 + return PTR_ERR(regmap); 557 + 558 + num_clks = ARRAY_SIZE(axmclk_clocks); 559 + pr_info("axmclk: supporting %u clocks\n", num_clks); 560 + priv = devm_kzalloc(dev, sizeof(*priv) + sizeof(*priv->clks) * num_clks, 561 + GFP_KERNEL); 562 + if (!priv) 563 + return -ENOMEM; 564 + 565 + priv->onecell.clks = priv->clks; 566 + priv->onecell.clk_num = num_clks; 567 + 568 + /* Update each entry with the allocated regmap and register the clock 569 + * with the common clock framework 570 + */ 571 + for (i = 0; i < num_clks; i++) { 572 + axmclk_clocks[i]->regmap = regmap; 573 + clk = devm_clk_register(dev, &axmclk_clocks[i]->hw); 574 + if (IS_ERR(clk)) 575 + return PTR_ERR(clk); 576 + priv->clks[i] = clk; 577 + } 578 + 579 + ret = of_clk_add_provider(dev->of_node, 580 + of_clk_src_onecell_get, &priv->onecell); 581 + 582 + return ret; 583 + } 584 + 585 + static int axmclk_remove(struct platform_device *pdev) 586 + { 587 + of_clk_del_provider(pdev->dev.of_node); 588 + return 0; 589 + } 590 + 591 + static struct platform_driver axmclk_driver = { 592 + .probe = axmclk_probe, 593 + .remove = axmclk_remove, 594 + .driver = { 595 + .name = "clk-axm5516", 596 + .owner = THIS_MODULE, 597 + .of_match_table = axmclk_match_table, 598 + }, 599 + }; 600 + 601 + static int __init axmclk_init(void) 602 + { 603 + return platform_driver_register(&axmclk_driver); 604 + } 605 + core_initcall(axmclk_init); 606 + 607 + static void __exit axmclk_exit(void) 608 + { 609 + platform_driver_unregister(&axmclk_driver); 610 + } 611 + module_exit(axmclk_exit); 612 + 613 + MODULE_DESCRIPTION("AXM5516 clock driver"); 614 + MODULE_LICENSE("GPL v2"); 615 + MODULE_ALIAS("platform:clk-axm5516");
+89 -4
drivers/clk/clk-divider.c
··· 43 43 return maxdiv; 44 44 } 45 45 46 + static unsigned int _get_table_mindiv(const struct clk_div_table *table) 47 + { 48 + unsigned int mindiv = UINT_MAX; 49 + const struct clk_div_table *clkt; 50 + 51 + for (clkt = table; clkt->div; clkt++) 52 + if (clkt->div < mindiv) 53 + mindiv = clkt->div; 54 + return mindiv; 55 + } 56 + 46 57 static unsigned int _get_maxdiv(struct clk_divider *divider) 47 58 { 48 59 if (divider->flags & CLK_DIVIDER_ONE_BASED) ··· 173 162 return up; 174 163 } 175 164 165 + static int _round_down_table(const struct clk_div_table *table, int div) 166 + { 167 + const struct clk_div_table *clkt; 168 + int down = _get_table_mindiv(table); 169 + 170 + for (clkt = table; clkt->div; clkt++) { 171 + if (clkt->div == div) 172 + return clkt->div; 173 + else if (clkt->div > div) 174 + continue; 175 + 176 + if ((div - clkt->div) < (div - down)) 177 + down = clkt->div; 178 + } 179 + 180 + return down; 181 + } 182 + 176 183 static int _div_round_up(struct clk_divider *divider, 177 184 unsigned long parent_rate, unsigned long rate) 178 185 { ··· 200 171 div = __roundup_pow_of_two(div); 201 172 if (divider->table) 202 173 div = _round_up_table(divider->table, div); 174 + 175 + return div; 176 + } 177 + 178 + static int _div_round_closest(struct clk_divider *divider, 179 + unsigned long parent_rate, unsigned long rate) 180 + { 181 + int up, down, div; 182 + 183 + up = down = div = DIV_ROUND_CLOSEST(parent_rate, rate); 184 + 185 + if (divider->flags & CLK_DIVIDER_POWER_OF_TWO) { 186 + up = __roundup_pow_of_two(div); 187 + down = __rounddown_pow_of_two(div); 188 + } else if (divider->table) { 189 + up = _round_up_table(divider->table, div); 190 + down = _round_down_table(divider->table, div); 191 + } 192 + 193 + return (up - div) <= (div - down) ? up : down; 194 + } 195 + 196 + static int _div_round(struct clk_divider *divider, unsigned long parent_rate, 197 + unsigned long rate) 198 + { 199 + if (divider->flags & CLK_DIVIDER_ROUND_CLOSEST) 200 + return _div_round_closest(divider, parent_rate, rate); 201 + 202 + return _div_round_up(divider, parent_rate, rate); 203 + } 204 + 205 + static bool _is_best_div(struct clk_divider *divider, 206 + int rate, int now, int best) 207 + { 208 + if (divider->flags & CLK_DIVIDER_ROUND_CLOSEST) 209 + return abs(rate - now) < abs(rate - best); 210 + 211 + return now <= rate && now > best; 212 + } 213 + 214 + static int _next_div(struct clk_divider *divider, int div) 215 + { 216 + div++; 217 + 218 + if (divider->flags & CLK_DIVIDER_POWER_OF_TWO) 219 + return __roundup_pow_of_two(div); 220 + if (divider->table) 221 + return _round_up_table(divider->table, div); 203 222 204 223 return div; 205 224 } ··· 267 190 268 191 if (!(__clk_get_flags(hw->clk) & CLK_SET_RATE_PARENT)) { 269 192 parent_rate = *best_parent_rate; 270 - bestdiv = _div_round_up(divider, parent_rate, rate); 193 + bestdiv = _div_round(divider, parent_rate, rate); 271 194 bestdiv = bestdiv == 0 ? 1 : bestdiv; 272 195 bestdiv = bestdiv > maxdiv ? maxdiv : bestdiv; 273 196 return bestdiv; ··· 279 202 */ 280 203 maxdiv = min(ULONG_MAX / rate, maxdiv); 281 204 282 - for (i = 1; i <= maxdiv; i++) { 205 + for (i = 1; i <= maxdiv; i = _next_div(divider, i)) { 283 206 if (!_is_valid_div(divider, i)) 284 207 continue; 285 208 if (rate * i == parent_rate_saved) { ··· 294 217 parent_rate = __clk_round_rate(__clk_get_parent(hw->clk), 295 218 MULT_ROUND_UP(rate, i)); 296 219 now = DIV_ROUND_UP(parent_rate, i); 297 - if (now <= rate && now > best) { 220 + if (_is_best_div(divider, rate, now, best)) { 298 221 bestdiv = i; 299 222 best = now; 300 223 *best_parent_rate = parent_rate; ··· 361 284 }; 362 285 EXPORT_SYMBOL_GPL(clk_divider_ops); 363 286 287 + const struct clk_ops clk_divider_ro_ops = { 288 + .recalc_rate = clk_divider_recalc_rate, 289 + }; 290 + EXPORT_SYMBOL_GPL(clk_divider_ro_ops); 291 + 364 292 static struct clk *_register_divider(struct device *dev, const char *name, 365 293 const char *parent_name, unsigned long flags, 366 294 void __iomem *reg, u8 shift, u8 width, ··· 391 309 } 392 310 393 311 init.name = name; 394 - init.ops = &clk_divider_ops; 312 + if (clk_divider_flags & CLK_DIVIDER_READ_ONLY) 313 + init.ops = &clk_divider_ro_ops; 314 + else 315 + init.ops = &clk_divider_ops; 395 316 init.flags = flags | CLK_IS_BASIC; 396 317 init.parent_names = (parent_name ? &parent_name: NULL); 397 318 init.num_parents = (parent_name ? 1 : 0);
+1 -1
drivers/clk/clk-si570.c
··· 526 526 module_i2c_driver(si570_driver); 527 527 528 528 MODULE_AUTHOR("Guenter Roeck <guenter.roeck@ericsson.com>"); 529 - MODULE_AUTHOR("Soeren Brinkmann <soren.brinkmann@xilinx.com"); 529 + MODULE_AUTHOR("Soeren Brinkmann <soren.brinkmann@xilinx.com>"); 530 530 MODULE_DESCRIPTION("Si570 driver"); 531 531 MODULE_LICENSE("GPL");
+20 -26
drivers/clk/clk.c
··· 106 106 if (!c) 107 107 return; 108 108 109 - seq_printf(s, "%*s%-*s %-11d %-12d %-10lu %-11lu", 109 + seq_printf(s, "%*s%-*s %11d %12d %11lu %10lu\n", 110 110 level * 3 + 1, "", 111 111 30 - level * 3, c->name, 112 112 c->enable_count, c->prepare_count, clk_get_rate(c), 113 113 clk_get_accuracy(c)); 114 - seq_printf(s, "\n"); 115 114 } 116 115 117 116 static void clk_summary_show_subtree(struct seq_file *s, struct clk *c, ··· 131 132 { 132 133 struct clk *c; 133 134 134 - seq_printf(s, " clock enable_cnt prepare_cnt rate accuracy\n"); 135 - seq_printf(s, "---------------------------------------------------------------------------------\n"); 135 + seq_puts(s, " clock enable_cnt prepare_cnt rate accuracy\n"); 136 + seq_puts(s, "--------------------------------------------------------------------------------\n"); 136 137 137 138 clk_prepare_lock(); 138 139 ··· 821 822 */ 822 823 void clk_unprepare(struct clk *clk) 823 824 { 825 + if (IS_ERR_OR_NULL(clk)) 826 + return; 827 + 824 828 clk_prepare_lock(); 825 829 __clk_unprepare(clk); 826 830 clk_prepare_unlock(); ··· 885 883 if (!clk) 886 884 return; 887 885 888 - if (WARN_ON(IS_ERR(clk))) 889 - return; 890 - 891 886 if (WARN_ON(clk->enable_count == 0)) 892 887 return; 893 888 ··· 912 913 void clk_disable(struct clk *clk) 913 914 { 914 915 unsigned long flags; 916 + 917 + if (IS_ERR_OR_NULL(clk)) 918 + return; 915 919 916 920 flags = clk_enable_lock(); 917 921 __clk_disable(clk); ··· 1117 1115 } 1118 1116 EXPORT_SYMBOL_GPL(clk_get_accuracy); 1119 1117 1118 + static unsigned long clk_recalc(struct clk *clk, unsigned long parent_rate) 1119 + { 1120 + if (clk->ops->recalc_rate) 1121 + return clk->ops->recalc_rate(clk->hw, parent_rate); 1122 + return parent_rate; 1123 + } 1124 + 1120 1125 /** 1121 1126 * __clk_recalc_rates 1122 1127 * @clk: first clk in the subtree ··· 1149 1140 if (clk->parent) 1150 1141 parent_rate = clk->parent->rate; 1151 1142 1152 - if (clk->ops->recalc_rate) 1153 - clk->rate = clk->ops->recalc_rate(clk->hw, parent_rate); 1154 - else 1155 - clk->rate = parent_rate; 1143 + clk->rate = clk_recalc(clk, parent_rate); 1156 1144 1157 1145 /* 1158 1146 * ignore NOTIFY_STOP and NOTIFY_BAD return values for POST_RATE_CHANGE ··· 1340 1334 unsigned long new_rate; 1341 1335 int ret = NOTIFY_DONE; 1342 1336 1343 - if (clk->ops->recalc_rate) 1344 - new_rate = clk->ops->recalc_rate(clk->hw, parent_rate); 1345 - else 1346 - new_rate = parent_rate; 1337 + new_rate = clk_recalc(clk, parent_rate); 1347 1338 1348 1339 /* abort rate change if a driver returns NOTIFY_BAD or NOTIFY_STOP */ 1349 1340 if (clk->notifier_count) ··· 1376 1373 new_parent->new_child = clk; 1377 1374 1378 1375 hlist_for_each_entry(child, &clk->children, child_node) { 1379 - if (child->ops->recalc_rate) 1380 - child->new_rate = child->ops->recalc_rate(child->hw, new_rate); 1381 - else 1382 - child->new_rate = new_rate; 1376 + child->new_rate = clk_recalc(child, new_rate); 1383 1377 clk_calc_subtree(child, child->new_rate, NULL, 0); 1384 1378 } 1385 1379 } ··· 1524 1524 if (!skip_set_rate && clk->ops->set_rate) 1525 1525 clk->ops->set_rate(clk->hw, clk->new_rate, best_parent_rate); 1526 1526 1527 - if (clk->ops->recalc_rate) 1528 - clk->rate = clk->ops->recalc_rate(clk->hw, best_parent_rate); 1529 - else 1530 - clk->rate = best_parent_rate; 1527 + clk->rate = clk_recalc(clk, best_parent_rate); 1531 1528 1532 1529 if (clk->notifier_count && old_rate != clk->rate) 1533 1530 __clk_notify(clk, POST_RATE_CHANGE, old_rate, clk->rate); ··· 1712 1715 1713 1716 if (!clk) 1714 1717 return 0; 1715 - 1716 - if (!clk->ops) 1717 - return -EINVAL; 1718 1718 1719 1719 /* verify ops for for multi-parent clks */ 1720 1720 if ((clk->num_parents > 1) && (!clk->ops->set_parent))
+1
drivers/clk/clk.h
··· 10 10 */ 11 11 12 12 #if defined(CONFIG_OF) && defined(CONFIG_COMMON_CLK) 13 + struct clk *of_clk_get_by_clkspec(struct of_phandle_args *clkspec); 13 14 struct clk *__of_clk_get_from_provider(struct of_phandle_args *clkspec); 14 15 void of_clk_lock(void); 15 16 void of_clk_unlock(void);
+27 -7
drivers/clk/clkdev.c
··· 27 27 static DEFINE_MUTEX(clocks_mutex); 28 28 29 29 #if defined(CONFIG_OF) && defined(CONFIG_COMMON_CLK) 30 + 31 + /** 32 + * of_clk_get_by_clkspec() - Lookup a clock form a clock provider 33 + * @clkspec: pointer to a clock specifier data structure 34 + * 35 + * This function looks up a struct clk from the registered list of clock 36 + * providers, an input is a clock specifier data structure as returned 37 + * from the of_parse_phandle_with_args() function call. 38 + */ 39 + struct clk *of_clk_get_by_clkspec(struct of_phandle_args *clkspec) 40 + { 41 + struct clk *clk; 42 + 43 + if (!clkspec) 44 + return ERR_PTR(-EINVAL); 45 + 46 + of_clk_lock(); 47 + clk = __of_clk_get_from_provider(clkspec); 48 + 49 + if (!IS_ERR(clk) && !__clk_get(clk)) 50 + clk = ERR_PTR(-ENOENT); 51 + 52 + of_clk_unlock(); 53 + return clk; 54 + } 55 + 30 56 struct clk *of_clk_get(struct device_node *np, int index) 31 57 { 32 58 struct of_phandle_args clkspec; ··· 67 41 if (rc) 68 42 return ERR_PTR(rc); 69 43 70 - of_clk_lock(); 71 - clk = __of_clk_get_from_provider(&clkspec); 72 - 73 - if (!IS_ERR(clk) && !__clk_get(clk)) 74 - clk = ERR_PTR(-ENOENT); 75 - 76 - of_clk_unlock(); 44 + clk = of_clk_get_by_clkspec(&clkspec); 77 45 of_node_put(clkspec.np); 78 46 return clk; 79 47 }
+1
drivers/clk/hisilicon/Makefile
··· 6 6 7 7 obj-$(CONFIG_ARCH_HI3xxx) += clk-hi3620.o 8 8 obj-$(CONFIG_ARCH_HIP04) += clk-hip04.o 9 + obj-$(CONFIG_ARCH_HIX5HD2) += clk-hix5hd2.o
+101
drivers/clk/hisilicon/clk-hix5hd2.c
··· 1 + /* 2 + * Copyright (c) 2014 Linaro Ltd. 3 + * Copyright (c) 2014 Hisilicon Limited. 4 + * 5 + * This program is free software; you can redistribute it and/or modify it 6 + * under the terms and conditions of the GNU General Public License, 7 + * version 2, as published by the Free Software Foundation. 8 + */ 9 + 10 + #include <linux/of_address.h> 11 + #include <dt-bindings/clock/hix5hd2-clock.h> 12 + #include "clk.h" 13 + 14 + static struct hisi_fixed_rate_clock hix5hd2_fixed_rate_clks[] __initdata = { 15 + { HIX5HD2_FIXED_1200M, "1200m", NULL, CLK_IS_ROOT, 1200000000, }, 16 + { HIX5HD2_FIXED_400M, "400m", NULL, CLK_IS_ROOT, 400000000, }, 17 + { HIX5HD2_FIXED_48M, "48m", NULL, CLK_IS_ROOT, 48000000, }, 18 + { HIX5HD2_FIXED_24M, "24m", NULL, CLK_IS_ROOT, 24000000, }, 19 + { HIX5HD2_FIXED_600M, "600m", NULL, CLK_IS_ROOT, 600000000, }, 20 + { HIX5HD2_FIXED_300M, "300m", NULL, CLK_IS_ROOT, 300000000, }, 21 + { HIX5HD2_FIXED_75M, "75m", NULL, CLK_IS_ROOT, 75000000, }, 22 + { HIX5HD2_FIXED_200M, "200m", NULL, CLK_IS_ROOT, 200000000, }, 23 + { HIX5HD2_FIXED_100M, "100m", NULL, CLK_IS_ROOT, 100000000, }, 24 + { HIX5HD2_FIXED_40M, "40m", NULL, CLK_IS_ROOT, 40000000, }, 25 + { HIX5HD2_FIXED_150M, "150m", NULL, CLK_IS_ROOT, 150000000, }, 26 + { HIX5HD2_FIXED_1728M, "1728m", NULL, CLK_IS_ROOT, 1728000000, }, 27 + { HIX5HD2_FIXED_28P8M, "28p8m", NULL, CLK_IS_ROOT, 28000000, }, 28 + { HIX5HD2_FIXED_432M, "432m", NULL, CLK_IS_ROOT, 432000000, }, 29 + { HIX5HD2_FIXED_345P6M, "345p6m", NULL, CLK_IS_ROOT, 345000000, }, 30 + { HIX5HD2_FIXED_288M, "288m", NULL, CLK_IS_ROOT, 288000000, }, 31 + { HIX5HD2_FIXED_60M, "60m", NULL, CLK_IS_ROOT, 60000000, }, 32 + { HIX5HD2_FIXED_750M, "750m", NULL, CLK_IS_ROOT, 750000000, }, 33 + { HIX5HD2_FIXED_500M, "500m", NULL, CLK_IS_ROOT, 500000000, }, 34 + { HIX5HD2_FIXED_54M, "54m", NULL, CLK_IS_ROOT, 54000000, }, 35 + { HIX5HD2_FIXED_27M, "27m", NULL, CLK_IS_ROOT, 27000000, }, 36 + { HIX5HD2_FIXED_1500M, "1500m", NULL, CLK_IS_ROOT, 1500000000, }, 37 + { HIX5HD2_FIXED_375M, "375m", NULL, CLK_IS_ROOT, 375000000, }, 38 + { HIX5HD2_FIXED_187M, "187m", NULL, CLK_IS_ROOT, 187000000, }, 39 + { HIX5HD2_FIXED_250M, "250m", NULL, CLK_IS_ROOT, 250000000, }, 40 + { HIX5HD2_FIXED_125M, "125m", NULL, CLK_IS_ROOT, 125000000, }, 41 + { HIX5HD2_FIXED_2P02M, "2m", NULL, CLK_IS_ROOT, 2000000, }, 42 + { HIX5HD2_FIXED_50M, "50m", NULL, CLK_IS_ROOT, 50000000, }, 43 + { HIX5HD2_FIXED_25M, "25m", NULL, CLK_IS_ROOT, 25000000, }, 44 + { HIX5HD2_FIXED_83M, "83m", NULL, CLK_IS_ROOT, 83333333, }, 45 + }; 46 + 47 + static const char *sfc_mux_p[] __initconst = { 48 + "24m", "150m", "200m", "100m", "75m", }; 49 + static u32 sfc_mux_table[] = {0, 4, 5, 6, 7}; 50 + 51 + static const char *sdio1_mux_p[] __initconst = { 52 + "75m", "100m", "50m", "15m", }; 53 + static u32 sdio1_mux_table[] = {0, 1, 2, 3}; 54 + 55 + static const char *fephy_mux_p[] __initconst = { "25m", "125m"}; 56 + static u32 fephy_mux_table[] = {0, 1}; 57 + 58 + 59 + static struct hisi_mux_clock hix5hd2_mux_clks[] __initdata = { 60 + { HIX5HD2_SFC_MUX, "sfc_mux", sfc_mux_p, ARRAY_SIZE(sfc_mux_p), 61 + CLK_SET_RATE_PARENT, 0x5c, 8, 3, 0, sfc_mux_table, }, 62 + { HIX5HD2_MMC_MUX, "mmc_mux", sdio1_mux_p, ARRAY_SIZE(sdio1_mux_p), 63 + CLK_SET_RATE_PARENT, 0xa0, 8, 2, 0, sdio1_mux_table, }, 64 + { HIX5HD2_FEPHY_MUX, "fephy_mux", 65 + fephy_mux_p, ARRAY_SIZE(fephy_mux_p), 66 + CLK_SET_RATE_PARENT, 0x120, 8, 2, 0, fephy_mux_table, }, 67 + }; 68 + 69 + static struct hisi_gate_clock hix5hd2_gate_clks[] __initdata = { 70 + /*sfc*/ 71 + { HIX5HD2_SFC_CLK, "clk_sfc", "sfc_mux", 72 + CLK_SET_RATE_PARENT, 0x5c, 0, 0, }, 73 + { HIX5HD2_SFC_RST, "rst_sfc", "clk_sfc", 74 + CLK_SET_RATE_PARENT, 0x5c, 4, CLK_GATE_SET_TO_DISABLE, }, 75 + /*sdio1*/ 76 + { HIX5HD2_MMC_BIU_CLK, "clk_mmc_biu", "200m", 77 + CLK_SET_RATE_PARENT, 0xa0, 0, 0, }, 78 + { HIX5HD2_MMC_CIU_CLK, "clk_mmc_ciu", "mmc_mux", 79 + CLK_SET_RATE_PARENT, 0xa0, 1, 0, }, 80 + { HIX5HD2_MMC_CIU_RST, "rst_mmc_ciu", "clk_mmc_ciu", 81 + CLK_SET_RATE_PARENT, 0xa0, 4, CLK_GATE_SET_TO_DISABLE, }, 82 + }; 83 + 84 + static void __init hix5hd2_clk_init(struct device_node *np) 85 + { 86 + struct hisi_clock_data *clk_data; 87 + 88 + clk_data = hisi_clk_init(np, HIX5HD2_NR_CLKS); 89 + if (!clk_data) 90 + return; 91 + 92 + hisi_clk_register_fixed_rate(hix5hd2_fixed_rate_clks, 93 + ARRAY_SIZE(hix5hd2_fixed_rate_clks), 94 + clk_data); 95 + hisi_clk_register_mux(hix5hd2_mux_clks, ARRAY_SIZE(hix5hd2_mux_clks), 96 + clk_data); 97 + hisi_clk_register_gate(hix5hd2_gate_clks, 98 + ARRAY_SIZE(hix5hd2_gate_clks), clk_data); 99 + } 100 + 101 + CLK_OF_DECLARE(hix5hd2_clk, "hisilicon,hix5hd2-clock", hix5hd2_clk_init);
+36 -5
drivers/clk/hisilicon/clk.c
··· 127 127 int i; 128 128 129 129 for (i = 0; i < nums; i++) { 130 - clk = clk_register_mux(NULL, clks[i].name, clks[i].parent_names, 131 - clks[i].num_parents, clks[i].flags, 132 - base + clks[i].offset, clks[i].shift, 133 - clks[i].width, clks[i].mux_flags, 134 - &hisi_clk_lock); 130 + u32 mask = BIT(clks[i].width) - 1; 131 + 132 + clk = clk_register_mux_table(NULL, clks[i].name, 133 + clks[i].parent_names, 134 + clks[i].num_parents, clks[i].flags, 135 + base + clks[i].offset, clks[i].shift, 136 + mask, clks[i].mux_flags, 137 + clks[i].table, &hisi_clk_lock); 135 138 if (IS_ERR(clk)) { 136 139 pr_err("%s: failed to register clock %s\n", 137 140 __func__, clks[i].name); ··· 164 161 clks[i].div_flags, 165 162 clks[i].table, 166 163 &hisi_clk_lock); 164 + if (IS_ERR(clk)) { 165 + pr_err("%s: failed to register clock %s\n", 166 + __func__, clks[i].name); 167 + continue; 168 + } 169 + 170 + if (clks[i].alias) 171 + clk_register_clkdev(clk, clks[i].alias, NULL); 172 + 173 + data->clk_data.clks[clks[i].id] = clk; 174 + } 175 + } 176 + 177 + void __init hisi_clk_register_gate(struct hisi_gate_clock *clks, 178 + int nums, struct hisi_clock_data *data) 179 + { 180 + struct clk *clk; 181 + void __iomem *base = data->base; 182 + int i; 183 + 184 + for (i = 0; i < nums; i++) { 185 + clk = clk_register_gate(NULL, clks[i].name, 186 + clks[i].parent_name, 187 + clks[i].flags, 188 + base + clks[i].offset, 189 + clks[i].bit_idx, 190 + clks[i].gate_flags, 191 + &hisi_clk_lock); 167 192 if (IS_ERR(clk)) { 168 193 pr_err("%s: failed to register clock %s\n", 169 194 __func__, clks[i].name);
+3
drivers/clk/hisilicon/clk.h
··· 62 62 u8 shift; 63 63 u8 width; 64 64 u8 mux_flags; 65 + u32 *table; 65 66 const char *alias; 66 67 }; 67 68 ··· 104 103 struct hisi_clock_data *); 105 104 void __init hisi_clk_register_divider(struct hisi_divider_clock *, 106 105 int, struct hisi_clock_data *); 106 + void __init hisi_clk_register_gate(struct hisi_gate_clock *, 107 + int, struct hisi_clock_data *); 107 108 void __init hisi_clk_register_gate_sep(struct hisi_gate_clock *, 108 109 int, struct hisi_clock_data *); 109 110 #endif /* __HISI_CLK_H */
+4
drivers/clk/mvebu/Kconfig
··· 34 34 config KIRKWOOD_CLK 35 35 bool 36 36 select MVEBU_CLK_COMMON 37 + 38 + config ORION_CLK 39 + bool 40 + select MVEBU_CLK_COMMON
+1
drivers/clk/mvebu/Makefile
··· 8 8 obj-$(CONFIG_ARMADA_XP_CLK) += armada-xp.o 9 9 obj-$(CONFIG_DOVE_CLK) += dove.o 10 10 obj-$(CONFIG_KIRKWOOD_CLK) += kirkwood.o 11 + obj-$(CONFIG_ORION_CLK) += orion.o
+210
drivers/clk/mvebu/orion.c
··· 1 + /* 2 + * Marvell Orion SoC clocks 3 + * 4 + * Copyright (C) 2014 Thomas Petazzoni 5 + * 6 + * Thomas Petazzoni <thomas.petazzoni@free-electrons.com> 7 + * 8 + * This file is licensed under the terms of the GNU General Public 9 + * License version 2. This program is licensed "as is" without any 10 + * warranty of any kind, whether express or implied. 11 + */ 12 + 13 + #include <linux/kernel.h> 14 + #include <linux/clk-provider.h> 15 + #include <linux/io.h> 16 + #include <linux/of.h> 17 + #include "common.h" 18 + 19 + static const struct coreclk_ratio orion_coreclk_ratios[] __initconst = { 20 + { .id = 0, .name = "ddrclk", } 21 + }; 22 + 23 + /* 24 + * Orion 5182 25 + */ 26 + 27 + #define SAR_MV88F5182_TCLK_FREQ 8 28 + #define SAR_MV88F5182_TCLK_FREQ_MASK 0x3 29 + 30 + static u32 __init mv88f5182_get_tclk_freq(void __iomem *sar) 31 + { 32 + u32 opt = (readl(sar) >> SAR_MV88F5182_TCLK_FREQ) & 33 + SAR_MV88F5182_TCLK_FREQ_MASK; 34 + if (opt == 1) 35 + return 150000000; 36 + else if (opt == 2) 37 + return 166666667; 38 + else 39 + return 0; 40 + } 41 + 42 + #define SAR_MV88F5182_CPU_FREQ 4 43 + #define SAR_MV88F5182_CPU_FREQ_MASK 0xf 44 + 45 + static u32 __init mv88f5182_get_cpu_freq(void __iomem *sar) 46 + { 47 + u32 opt = (readl(sar) >> SAR_MV88F5182_CPU_FREQ) & 48 + SAR_MV88F5182_CPU_FREQ_MASK; 49 + if (opt == 0) 50 + return 333333333; 51 + else if (opt == 1 || opt == 2) 52 + return 400000000; 53 + else if (opt == 3) 54 + return 500000000; 55 + else 56 + return 0; 57 + } 58 + 59 + static void __init mv88f5182_get_clk_ratio(void __iomem *sar, int id, 60 + int *mult, int *div) 61 + { 62 + u32 opt = (readl(sar) >> SAR_MV88F5182_CPU_FREQ) & 63 + SAR_MV88F5182_CPU_FREQ_MASK; 64 + if (opt == 0 || opt == 1) { 65 + *mult = 1; 66 + *div = 2; 67 + } else if (opt == 2 || opt == 3) { 68 + *mult = 1; 69 + *div = 3; 70 + } else { 71 + *mult = 0; 72 + *div = 1; 73 + } 74 + } 75 + 76 + static const struct coreclk_soc_desc mv88f5182_coreclks = { 77 + .get_tclk_freq = mv88f5182_get_tclk_freq, 78 + .get_cpu_freq = mv88f5182_get_cpu_freq, 79 + .get_clk_ratio = mv88f5182_get_clk_ratio, 80 + .ratios = orion_coreclk_ratios, 81 + .num_ratios = ARRAY_SIZE(orion_coreclk_ratios), 82 + }; 83 + 84 + static void __init mv88f5182_clk_init(struct device_node *np) 85 + { 86 + return mvebu_coreclk_setup(np, &mv88f5182_coreclks); 87 + } 88 + 89 + CLK_OF_DECLARE(mv88f5182_clk, "marvell,mv88f5182-core-clock", mv88f5182_clk_init); 90 + 91 + /* 92 + * Orion 5281 93 + */ 94 + 95 + static u32 __init mv88f5281_get_tclk_freq(void __iomem *sar) 96 + { 97 + /* On 5281, tclk is always 166 Mhz */ 98 + return 166666667; 99 + } 100 + 101 + #define SAR_MV88F5281_CPU_FREQ 4 102 + #define SAR_MV88F5281_CPU_FREQ_MASK 0xf 103 + 104 + static u32 __init mv88f5281_get_cpu_freq(void __iomem *sar) 105 + { 106 + u32 opt = (readl(sar) >> SAR_MV88F5281_CPU_FREQ) & 107 + SAR_MV88F5281_CPU_FREQ_MASK; 108 + if (opt == 1 || opt == 2) 109 + return 400000000; 110 + else if (opt == 3) 111 + return 500000000; 112 + else 113 + return 0; 114 + } 115 + 116 + static void __init mv88f5281_get_clk_ratio(void __iomem *sar, int id, 117 + int *mult, int *div) 118 + { 119 + u32 opt = (readl(sar) >> SAR_MV88F5281_CPU_FREQ) & 120 + SAR_MV88F5281_CPU_FREQ_MASK; 121 + if (opt == 1) { 122 + *mult = 1; 123 + *div = 2; 124 + } else if (opt == 2 || opt == 3) { 125 + *mult = 1; 126 + *div = 3; 127 + } else { 128 + *mult = 0; 129 + *div = 1; 130 + } 131 + } 132 + 133 + static const struct coreclk_soc_desc mv88f5281_coreclks = { 134 + .get_tclk_freq = mv88f5281_get_tclk_freq, 135 + .get_cpu_freq = mv88f5281_get_cpu_freq, 136 + .get_clk_ratio = mv88f5281_get_clk_ratio, 137 + .ratios = orion_coreclk_ratios, 138 + .num_ratios = ARRAY_SIZE(orion_coreclk_ratios), 139 + }; 140 + 141 + static void __init mv88f5281_clk_init(struct device_node *np) 142 + { 143 + return mvebu_coreclk_setup(np, &mv88f5281_coreclks); 144 + } 145 + 146 + CLK_OF_DECLARE(mv88f5281_clk, "marvell,mv88f5281-core-clock", mv88f5281_clk_init); 147 + 148 + /* 149 + * Orion 6183 150 + */ 151 + 152 + #define SAR_MV88F6183_TCLK_FREQ 9 153 + #define SAR_MV88F6183_TCLK_FREQ_MASK 0x1 154 + 155 + static u32 __init mv88f6183_get_tclk_freq(void __iomem *sar) 156 + { 157 + u32 opt = (readl(sar) >> SAR_MV88F6183_TCLK_FREQ) & 158 + SAR_MV88F6183_TCLK_FREQ_MASK; 159 + if (opt == 0) 160 + return 133333333; 161 + else if (opt == 1) 162 + return 166666667; 163 + else 164 + return 0; 165 + } 166 + 167 + #define SAR_MV88F6183_CPU_FREQ 1 168 + #define SAR_MV88F6183_CPU_FREQ_MASK 0x3f 169 + 170 + static u32 __init mv88f6183_get_cpu_freq(void __iomem *sar) 171 + { 172 + u32 opt = (readl(sar) >> SAR_MV88F6183_CPU_FREQ) & 173 + SAR_MV88F6183_CPU_FREQ_MASK; 174 + if (opt == 9) 175 + return 333333333; 176 + else if (opt == 17) 177 + return 400000000; 178 + else 179 + return 0; 180 + } 181 + 182 + static void __init mv88f6183_get_clk_ratio(void __iomem *sar, int id, 183 + int *mult, int *div) 184 + { 185 + u32 opt = (readl(sar) >> SAR_MV88F6183_CPU_FREQ) & 186 + SAR_MV88F6183_CPU_FREQ_MASK; 187 + if (opt == 9 || opt == 17) { 188 + *mult = 1; 189 + *div = 2; 190 + } else { 191 + *mult = 0; 192 + *div = 1; 193 + } 194 + } 195 + 196 + static const struct coreclk_soc_desc mv88f6183_coreclks = { 197 + .get_tclk_freq = mv88f6183_get_tclk_freq, 198 + .get_cpu_freq = mv88f6183_get_cpu_freq, 199 + .get_clk_ratio = mv88f6183_get_clk_ratio, 200 + .ratios = orion_coreclk_ratios, 201 + .num_ratios = ARRAY_SIZE(orion_coreclk_ratios), 202 + }; 203 + 204 + 205 + static void __init mv88f6183_clk_init(struct device_node *np) 206 + { 207 + return mvebu_coreclk_setup(np, &mv88f6183_coreclks); 208 + } 209 + 210 + CLK_OF_DECLARE(mv88f6183_clk, "marvell,mv88f6183-core-clock", mv88f6183_clk_init);
+2 -2
drivers/clk/qcom/Kconfig
··· 13 13 i2c, USB, SD/eMMC, etc. 14 14 15 15 config MSM_GCC_8960 16 - tristate "MSM8960 Global Clock Controller" 16 + tristate "APQ8064/MSM8960 Global Clock Controller" 17 17 depends on COMMON_CLK_QCOM 18 18 help 19 - Support for the global clock controller on msm8960 devices. 19 + Support for the global clock controller on apq8064/msm8960 devices. 20 20 Say Y if you want to use peripheral devices such as UART, SPI, 21 21 i2c, USB, SD/eMMC, SATA, PCIe, etc. 22 22
+1
drivers/clk/qcom/Makefile
··· 1 1 obj-$(CONFIG_COMMON_CLK_QCOM) += clk-qcom.o 2 2 3 + clk-qcom-y += common.o 3 4 clk-qcom-y += clk-regmap.o 4 5 clk-qcom-y += clk-pll.o 5 6 clk-qcom-y += clk-rcg.o
+99
drivers/clk/qcom/common.c
··· 1 + /* 2 + * Copyright (c) 2013-2014, The Linux Foundation. All rights reserved. 3 + * 4 + * This software is licensed under the terms of the GNU General Public 5 + * License version 2, as published by the Free Software Foundation, and 6 + * may be copied, distributed, and modified under those terms. 7 + * 8 + * This program is distributed in the hope that it will be useful, 9 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 + * GNU General Public License for more details. 12 + */ 13 + 14 + #include <linux/export.h> 15 + #include <linux/regmap.h> 16 + #include <linux/platform_device.h> 17 + #include <linux/clk-provider.h> 18 + #include <linux/reset-controller.h> 19 + 20 + #include "common.h" 21 + #include "clk-regmap.h" 22 + #include "reset.h" 23 + 24 + struct qcom_cc { 25 + struct qcom_reset_controller reset; 26 + struct clk_onecell_data data; 27 + struct clk *clks[]; 28 + }; 29 + 30 + int qcom_cc_probe(struct platform_device *pdev, const struct qcom_cc_desc *desc) 31 + { 32 + void __iomem *base; 33 + struct resource *res; 34 + int i, ret; 35 + struct device *dev = &pdev->dev; 36 + struct clk *clk; 37 + struct clk_onecell_data *data; 38 + struct clk **clks; 39 + struct regmap *regmap; 40 + struct qcom_reset_controller *reset; 41 + struct qcom_cc *cc; 42 + size_t num_clks = desc->num_clks; 43 + struct clk_regmap **rclks = desc->clks; 44 + 45 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 46 + base = devm_ioremap_resource(dev, res); 47 + if (IS_ERR(base)) 48 + return PTR_ERR(base); 49 + 50 + regmap = devm_regmap_init_mmio(dev, base, desc->config); 51 + if (IS_ERR(regmap)) 52 + return PTR_ERR(regmap); 53 + 54 + cc = devm_kzalloc(dev, sizeof(*cc) + sizeof(*clks) * num_clks, 55 + GFP_KERNEL); 56 + if (!cc) 57 + return -ENOMEM; 58 + 59 + clks = cc->clks; 60 + data = &cc->data; 61 + data->clks = clks; 62 + data->clk_num = num_clks; 63 + 64 + for (i = 0; i < num_clks; i++) { 65 + if (!rclks[i]) 66 + continue; 67 + clk = devm_clk_register_regmap(dev, rclks[i]); 68 + if (IS_ERR(clk)) 69 + return PTR_ERR(clk); 70 + clks[i] = clk; 71 + } 72 + 73 + ret = of_clk_add_provider(dev->of_node, of_clk_src_onecell_get, data); 74 + if (ret) 75 + return ret; 76 + 77 + reset = &cc->reset; 78 + reset->rcdev.of_node = dev->of_node; 79 + reset->rcdev.ops = &qcom_reset_ops; 80 + reset->rcdev.owner = dev->driver->owner; 81 + reset->rcdev.nr_resets = desc->num_resets; 82 + reset->regmap = regmap; 83 + reset->reset_map = desc->resets; 84 + platform_set_drvdata(pdev, &reset->rcdev); 85 + 86 + ret = reset_controller_register(&reset->rcdev); 87 + if (ret) 88 + of_clk_del_provider(dev->of_node); 89 + 90 + return ret; 91 + } 92 + EXPORT_SYMBOL_GPL(qcom_cc_probe); 93 + 94 + void qcom_cc_remove(struct platform_device *pdev) 95 + { 96 + of_clk_del_provider(pdev->dev.of_node); 97 + reset_controller_unregister(platform_get_drvdata(pdev)); 98 + } 99 + EXPORT_SYMBOL_GPL(qcom_cc_remove);
+34
drivers/clk/qcom/common.h
··· 1 + /* 2 + * Copyright (c) 2014, The Linux Foundation. All rights reserved. 3 + * 4 + * This software is licensed under the terms of the GNU General Public 5 + * License version 2, as published by the Free Software Foundation, and 6 + * may be copied, distributed, and modified under those terms. 7 + * 8 + * This program is distributed in the hope that it will be useful, 9 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 + * GNU General Public License for more details. 12 + */ 13 + #ifndef __QCOM_CLK_COMMON_H__ 14 + #define __QCOM_CLK_COMMON_H__ 15 + 16 + struct platform_device; 17 + struct regmap_config; 18 + struct clk_regmap; 19 + struct qcom_reset_map; 20 + 21 + struct qcom_cc_desc { 22 + const struct regmap_config *config; 23 + struct clk_regmap **clks; 24 + size_t num_clks; 25 + const struct qcom_reset_map *resets; 26 + size_t num_resets; 27 + }; 28 + 29 + extern int qcom_cc_probe(struct platform_device *pdev, 30 + const struct qcom_cc_desc *desc); 31 + 32 + extern void qcom_cc_remove(struct platform_device *pdev); 33 + 34 + #endif
+12 -65
drivers/clk/qcom/gcc-msm8660.c
··· 25 25 #include <dt-bindings/clock/qcom,gcc-msm8660.h> 26 26 #include <dt-bindings/reset/qcom,gcc-msm8660.h> 27 27 28 + #include "common.h" 28 29 #include "clk-regmap.h" 29 30 #include "clk-pll.h" 30 31 #include "clk-rcg.h" ··· 2702 2701 .fast_io = true, 2703 2702 }; 2704 2703 2704 + static const struct qcom_cc_desc gcc_msm8660_desc = { 2705 + .config = &gcc_msm8660_regmap_config, 2706 + .clks = gcc_msm8660_clks, 2707 + .num_clks = ARRAY_SIZE(gcc_msm8660_clks), 2708 + .resets = gcc_msm8660_resets, 2709 + .num_resets = ARRAY_SIZE(gcc_msm8660_resets), 2710 + }; 2711 + 2705 2712 static const struct of_device_id gcc_msm8660_match_table[] = { 2706 2713 { .compatible = "qcom,gcc-msm8660" }, 2707 2714 { } 2708 2715 }; 2709 2716 MODULE_DEVICE_TABLE(of, gcc_msm8660_match_table); 2710 2717 2711 - struct qcom_cc { 2712 - struct qcom_reset_controller reset; 2713 - struct clk_onecell_data data; 2714 - struct clk *clks[]; 2715 - }; 2716 - 2717 2718 static int gcc_msm8660_probe(struct platform_device *pdev) 2718 2719 { 2719 - void __iomem *base; 2720 - struct resource *res; 2721 - int i, ret; 2722 - struct device *dev = &pdev->dev; 2723 2720 struct clk *clk; 2724 - struct clk_onecell_data *data; 2725 - struct clk **clks; 2726 - struct regmap *regmap; 2727 - size_t num_clks; 2728 - struct qcom_reset_controller *reset; 2729 - struct qcom_cc *cc; 2730 - 2731 - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 2732 - base = devm_ioremap_resource(dev, res); 2733 - if (IS_ERR(base)) 2734 - return PTR_ERR(base); 2735 - 2736 - regmap = devm_regmap_init_mmio(dev, base, &gcc_msm8660_regmap_config); 2737 - if (IS_ERR(regmap)) 2738 - return PTR_ERR(regmap); 2739 - 2740 - num_clks = ARRAY_SIZE(gcc_msm8660_clks); 2741 - cc = devm_kzalloc(dev, sizeof(*cc) + sizeof(*clks) * num_clks, 2742 - GFP_KERNEL); 2743 - if (!cc) 2744 - return -ENOMEM; 2745 - 2746 - clks = cc->clks; 2747 - data = &cc->data; 2748 - data->clks = clks; 2749 - data->clk_num = num_clks; 2721 + struct device *dev = &pdev->dev; 2750 2722 2751 2723 /* Temporary until RPM clocks supported */ 2752 2724 clk = clk_register_fixed_rate(dev, "cxo", NULL, CLK_IS_ROOT, 19200000); ··· 2730 2756 if (IS_ERR(clk)) 2731 2757 return PTR_ERR(clk); 2732 2758 2733 - for (i = 0; i < num_clks; i++) { 2734 - if (!gcc_msm8660_clks[i]) 2735 - continue; 2736 - clk = devm_clk_register_regmap(dev, gcc_msm8660_clks[i]); 2737 - if (IS_ERR(clk)) 2738 - return PTR_ERR(clk); 2739 - clks[i] = clk; 2740 - } 2741 - 2742 - ret = of_clk_add_provider(dev->of_node, of_clk_src_onecell_get, data); 2743 - if (ret) 2744 - return ret; 2745 - 2746 - reset = &cc->reset; 2747 - reset->rcdev.of_node = dev->of_node; 2748 - reset->rcdev.ops = &qcom_reset_ops, 2749 - reset->rcdev.owner = THIS_MODULE, 2750 - reset->rcdev.nr_resets = ARRAY_SIZE(gcc_msm8660_resets), 2751 - reset->regmap = regmap; 2752 - reset->reset_map = gcc_msm8660_resets, 2753 - platform_set_drvdata(pdev, &reset->rcdev); 2754 - 2755 - ret = reset_controller_register(&reset->rcdev); 2756 - if (ret) 2757 - of_clk_del_provider(dev->of_node); 2758 - 2759 - return ret; 2759 + return qcom_cc_probe(pdev, &gcc_msm8660_desc); 2760 2760 } 2761 2761 2762 2762 static int gcc_msm8660_remove(struct platform_device *pdev) 2763 2763 { 2764 - of_clk_del_provider(pdev->dev.of_node); 2765 - reset_controller_unregister(platform_get_drvdata(pdev)); 2764 + qcom_cc_remove(pdev); 2766 2765 return 0; 2767 2766 } 2768 2767
+39 -68
drivers/clk/qcom/gcc-msm8960.c
··· 1 1 /* 2 - * Copyright (c) 2013, The Linux Foundation. All rights reserved. 2 + * Copyright (c) 2013-2014, The Linux Foundation. All rights reserved. 3 3 * 4 4 * This software is licensed under the terms of the GNU General Public 5 5 * License version 2, as published by the Free Software Foundation, and ··· 25 25 #include <dt-bindings/clock/qcom,gcc-msm8960.h> 26 26 #include <dt-bindings/reset/qcom,gcc-msm8960.h> 27 27 28 + #include "common.h" 28 29 #include "clk-regmap.h" 29 30 #include "clk-pll.h" 30 31 #include "clk-rcg.h" ··· 2810 2809 [PPSS_PROC_RESET] = { 0x2594, 1 }, 2811 2810 [PPSS_RESET] = { 0x2594}, 2812 2811 [DMA_BAM_RESET] = { 0x25c0, 7 }, 2813 - [SIC_TIC_RESET] = { 0x2600, 7 }, 2812 + [SPS_TIC_H_RESET] = { 0x2600, 7 }, 2814 2813 [SLIMBUS_H_RESET] = { 0x2620, 7 }, 2815 2814 [SFAB_CFPB_M_RESET] = { 0x2680, 7 }, 2816 2815 [SFAB_CFPB_S_RESET] = { 0x26c0, 7 }, ··· 2823 2822 [SFAB_SFPB_M_RESET] = { 0x2780, 7 }, 2824 2823 [SFAB_SFPB_S_RESET] = { 0x27a0, 7 }, 2825 2824 [RPM_PROC_RESET] = { 0x27c0, 7 }, 2826 - [PMIC_SSBI2_RESET] = { 0x270c, 12 }, 2825 + [PMIC_SSBI2_RESET] = { 0x280c, 12 }, 2827 2826 [SDC1_RESET] = { 0x2830 }, 2828 2827 [SDC2_RESET] = { 0x2850 }, 2829 2828 [SDC3_RESET] = { 0x2870 }, ··· 2868 2867 [RIVA_RESET] = { 0x35e0 }, 2869 2868 }; 2870 2869 2870 + static struct clk_regmap *gcc_apq8064_clks[] = { 2871 + [PLL8] = &pll8.clkr, 2872 + [PLL8_VOTE] = &pll8_vote, 2873 + [GSBI7_UART_SRC] = &gsbi7_uart_src.clkr, 2874 + [GSBI7_UART_CLK] = &gsbi7_uart_clk.clkr, 2875 + [GSBI7_QUP_SRC] = &gsbi7_qup_src.clkr, 2876 + [GSBI7_QUP_CLK] = &gsbi7_qup_clk.clkr, 2877 + [GSBI7_H_CLK] = &gsbi7_h_clk.clkr, 2878 + }; 2879 + 2871 2880 static const struct regmap_config gcc_msm8960_regmap_config = { 2872 2881 .reg_bits = 32, 2873 2882 .reg_stride = 4, ··· 2886 2875 .fast_io = true, 2887 2876 }; 2888 2877 2878 + static const struct qcom_cc_desc gcc_msm8960_desc = { 2879 + .config = &gcc_msm8960_regmap_config, 2880 + .clks = gcc_msm8960_clks, 2881 + .num_clks = ARRAY_SIZE(gcc_msm8960_clks), 2882 + .resets = gcc_msm8960_resets, 2883 + .num_resets = ARRAY_SIZE(gcc_msm8960_resets), 2884 + }; 2885 + 2886 + static const struct qcom_cc_desc gcc_apq8064_desc = { 2887 + .config = &gcc_msm8960_regmap_config, 2888 + .clks = gcc_apq8064_clks, 2889 + .num_clks = ARRAY_SIZE(gcc_apq8064_clks), 2890 + .resets = gcc_msm8960_resets, 2891 + .num_resets = ARRAY_SIZE(gcc_msm8960_resets), 2892 + }; 2893 + 2889 2894 static const struct of_device_id gcc_msm8960_match_table[] = { 2890 - { .compatible = "qcom,gcc-msm8960" }, 2895 + { .compatible = "qcom,gcc-msm8960", .data = &gcc_msm8960_desc }, 2896 + { .compatible = "qcom,gcc-apq8064", .data = &gcc_apq8064_desc }, 2891 2897 { } 2892 2898 }; 2893 2899 MODULE_DEVICE_TABLE(of, gcc_msm8960_match_table); 2894 2900 2895 - struct qcom_cc { 2896 - struct qcom_reset_controller reset; 2897 - struct clk_onecell_data data; 2898 - struct clk *clks[]; 2899 - }; 2900 - 2901 2901 static int gcc_msm8960_probe(struct platform_device *pdev) 2902 2902 { 2903 - void __iomem *base; 2904 - struct resource *res; 2905 - int i, ret; 2906 - struct device *dev = &pdev->dev; 2907 2903 struct clk *clk; 2908 - struct clk_onecell_data *data; 2909 - struct clk **clks; 2910 - struct regmap *regmap; 2911 - size_t num_clks; 2912 - struct qcom_reset_controller *reset; 2913 - struct qcom_cc *cc; 2904 + struct device *dev = &pdev->dev; 2905 + const struct of_device_id *match; 2914 2906 2915 - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 2916 - base = devm_ioremap_resource(dev, res); 2917 - if (IS_ERR(base)) 2918 - return PTR_ERR(base); 2919 - 2920 - regmap = devm_regmap_init_mmio(dev, base, &gcc_msm8960_regmap_config); 2921 - if (IS_ERR(regmap)) 2922 - return PTR_ERR(regmap); 2923 - 2924 - num_clks = ARRAY_SIZE(gcc_msm8960_clks); 2925 - cc = devm_kzalloc(dev, sizeof(*cc) + sizeof(*clks) * num_clks, 2926 - GFP_KERNEL); 2927 - if (!cc) 2928 - return -ENOMEM; 2929 - 2930 - clks = cc->clks; 2931 - data = &cc->data; 2932 - data->clks = clks; 2933 - data->clk_num = num_clks; 2907 + match = of_match_device(gcc_msm8960_match_table, &pdev->dev); 2908 + if (!match) 2909 + return -EINVAL; 2934 2910 2935 2911 /* Temporary until RPM clocks supported */ 2936 2912 clk = clk_register_fixed_rate(dev, "cxo", NULL, CLK_IS_ROOT, 19200000); ··· 2928 2930 if (IS_ERR(clk)) 2929 2931 return PTR_ERR(clk); 2930 2932 2931 - for (i = 0; i < num_clks; i++) { 2932 - if (!gcc_msm8960_clks[i]) 2933 - continue; 2934 - clk = devm_clk_register_regmap(dev, gcc_msm8960_clks[i]); 2935 - if (IS_ERR(clk)) 2936 - return PTR_ERR(clk); 2937 - clks[i] = clk; 2938 - } 2939 - 2940 - ret = of_clk_add_provider(dev->of_node, of_clk_src_onecell_get, data); 2941 - if (ret) 2942 - return ret; 2943 - 2944 - reset = &cc->reset; 2945 - reset->rcdev.of_node = dev->of_node; 2946 - reset->rcdev.ops = &qcom_reset_ops, 2947 - reset->rcdev.owner = THIS_MODULE, 2948 - reset->rcdev.nr_resets = ARRAY_SIZE(gcc_msm8960_resets), 2949 - reset->regmap = regmap; 2950 - reset->reset_map = gcc_msm8960_resets, 2951 - platform_set_drvdata(pdev, &reset->rcdev); 2952 - 2953 - ret = reset_controller_register(&reset->rcdev); 2954 - if (ret) 2955 - of_clk_del_provider(dev->of_node); 2956 - 2957 - return ret; 2933 + return qcom_cc_probe(pdev, match->data); 2958 2934 } 2959 2935 2960 2936 static int gcc_msm8960_remove(struct platform_device *pdev) 2961 2937 { 2962 - of_clk_del_provider(pdev->dev.of_node); 2963 - reset_controller_unregister(platform_get_drvdata(pdev)); 2938 + qcom_cc_remove(pdev); 2964 2939 return 0; 2965 2940 } 2966 2941
+12 -65
drivers/clk/qcom/gcc-msm8974.c
··· 25 25 #include <dt-bindings/clock/qcom,gcc-msm8974.h> 26 26 #include <dt-bindings/reset/qcom,gcc-msm8974.h> 27 27 28 + #include "common.h" 28 29 #include "clk-regmap.h" 29 30 #include "clk-pll.h" 30 31 #include "clk-rcg.h" ··· 2575 2574 .fast_io = true, 2576 2575 }; 2577 2576 2577 + static const struct qcom_cc_desc gcc_msm8974_desc = { 2578 + .config = &gcc_msm8974_regmap_config, 2579 + .clks = gcc_msm8974_clocks, 2580 + .num_clks = ARRAY_SIZE(gcc_msm8974_clocks), 2581 + .resets = gcc_msm8974_resets, 2582 + .num_resets = ARRAY_SIZE(gcc_msm8974_resets), 2583 + }; 2584 + 2578 2585 static const struct of_device_id gcc_msm8974_match_table[] = { 2579 2586 { .compatible = "qcom,gcc-msm8974" }, 2580 2587 { } 2581 2588 }; 2582 2589 MODULE_DEVICE_TABLE(of, gcc_msm8974_match_table); 2583 2590 2584 - struct qcom_cc { 2585 - struct qcom_reset_controller reset; 2586 - struct clk_onecell_data data; 2587 - struct clk *clks[]; 2588 - }; 2589 - 2590 2591 static int gcc_msm8974_probe(struct platform_device *pdev) 2591 2592 { 2592 - void __iomem *base; 2593 - struct resource *res; 2594 - int i, ret; 2595 - struct device *dev = &pdev->dev; 2596 2593 struct clk *clk; 2597 - struct clk_onecell_data *data; 2598 - struct clk **clks; 2599 - struct regmap *regmap; 2600 - size_t num_clks; 2601 - struct qcom_reset_controller *reset; 2602 - struct qcom_cc *cc; 2603 - 2604 - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 2605 - base = devm_ioremap_resource(dev, res); 2606 - if (IS_ERR(base)) 2607 - return PTR_ERR(base); 2608 - 2609 - regmap = devm_regmap_init_mmio(dev, base, &gcc_msm8974_regmap_config); 2610 - if (IS_ERR(regmap)) 2611 - return PTR_ERR(regmap); 2612 - 2613 - num_clks = ARRAY_SIZE(gcc_msm8974_clocks); 2614 - cc = devm_kzalloc(dev, sizeof(*cc) + sizeof(*clks) * num_clks, 2615 - GFP_KERNEL); 2616 - if (!cc) 2617 - return -ENOMEM; 2618 - 2619 - clks = cc->clks; 2620 - data = &cc->data; 2621 - data->clks = clks; 2622 - data->clk_num = num_clks; 2594 + struct device *dev = &pdev->dev; 2623 2595 2624 2596 /* Temporary until RPM clocks supported */ 2625 2597 clk = clk_register_fixed_rate(dev, "xo", NULL, CLK_IS_ROOT, 19200000); ··· 2605 2631 if (IS_ERR(clk)) 2606 2632 return PTR_ERR(clk); 2607 2633 2608 - for (i = 0; i < num_clks; i++) { 2609 - if (!gcc_msm8974_clocks[i]) 2610 - continue; 2611 - clk = devm_clk_register_regmap(dev, gcc_msm8974_clocks[i]); 2612 - if (IS_ERR(clk)) 2613 - return PTR_ERR(clk); 2614 - clks[i] = clk; 2615 - } 2616 - 2617 - ret = of_clk_add_provider(dev->of_node, of_clk_src_onecell_get, data); 2618 - if (ret) 2619 - return ret; 2620 - 2621 - reset = &cc->reset; 2622 - reset->rcdev.of_node = dev->of_node; 2623 - reset->rcdev.ops = &qcom_reset_ops, 2624 - reset->rcdev.owner = THIS_MODULE, 2625 - reset->rcdev.nr_resets = ARRAY_SIZE(gcc_msm8974_resets), 2626 - reset->regmap = regmap; 2627 - reset->reset_map = gcc_msm8974_resets, 2628 - platform_set_drvdata(pdev, &reset->rcdev); 2629 - 2630 - ret = reset_controller_register(&reset->rcdev); 2631 - if (ret) 2632 - of_clk_del_provider(dev->of_node); 2633 - 2634 - return ret; 2634 + return qcom_cc_probe(pdev, &gcc_msm8974_desc); 2635 2635 } 2636 2636 2637 2637 static int gcc_msm8974_remove(struct platform_device *pdev) 2638 2638 { 2639 - of_clk_del_provider(pdev->dev.of_node); 2640 - reset_controller_unregister(platform_get_drvdata(pdev)); 2639 + qcom_cc_remove(pdev); 2641 2640 return 0; 2642 2641 } 2643 2642
+11 -67
drivers/clk/qcom/mmcc-msm8960.c
··· 26 26 #include <dt-bindings/clock/qcom,mmcc-msm8960.h> 27 27 #include <dt-bindings/reset/qcom,mmcc-msm8960.h> 28 28 29 + #include "common.h" 29 30 #include "clk-regmap.h" 30 31 #include "clk-pll.h" 31 32 #include "clk-rcg.h" ··· 2223 2222 .fast_io = true, 2224 2223 }; 2225 2224 2225 + static const struct qcom_cc_desc mmcc_msm8960_desc = { 2226 + .config = &mmcc_msm8960_regmap_config, 2227 + .clks = mmcc_msm8960_clks, 2228 + .num_clks = ARRAY_SIZE(mmcc_msm8960_clks), 2229 + .resets = mmcc_msm8960_resets, 2230 + .num_resets = ARRAY_SIZE(mmcc_msm8960_resets), 2231 + }; 2232 + 2226 2233 static const struct of_device_id mmcc_msm8960_match_table[] = { 2227 2234 { .compatible = "qcom,mmcc-msm8960" }, 2228 2235 { } 2229 2236 }; 2230 2237 MODULE_DEVICE_TABLE(of, mmcc_msm8960_match_table); 2231 2238 2232 - struct qcom_cc { 2233 - struct qcom_reset_controller reset; 2234 - struct clk_onecell_data data; 2235 - struct clk *clks[]; 2236 - }; 2237 - 2238 2239 static int mmcc_msm8960_probe(struct platform_device *pdev) 2239 2240 { 2240 - void __iomem *base; 2241 - struct resource *res; 2242 - int i, ret; 2243 - struct device *dev = &pdev->dev; 2244 - struct clk *clk; 2245 - struct clk_onecell_data *data; 2246 - struct clk **clks; 2247 - struct regmap *regmap; 2248 - size_t num_clks; 2249 - struct qcom_reset_controller *reset; 2250 - struct qcom_cc *cc; 2251 - 2252 - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 2253 - base = devm_ioremap_resource(dev, res); 2254 - if (IS_ERR(base)) 2255 - return PTR_ERR(base); 2256 - 2257 - regmap = devm_regmap_init_mmio(dev, base, &mmcc_msm8960_regmap_config); 2258 - if (IS_ERR(regmap)) 2259 - return PTR_ERR(regmap); 2260 - 2261 - num_clks = ARRAY_SIZE(mmcc_msm8960_clks); 2262 - cc = devm_kzalloc(dev, sizeof(*cc) + sizeof(*clks) * num_clks, 2263 - GFP_KERNEL); 2264 - if (!cc) 2265 - return -ENOMEM; 2266 - 2267 - clks = cc->clks; 2268 - data = &cc->data; 2269 - data->clks = clks; 2270 - data->clk_num = num_clks; 2271 - 2272 - for (i = 0; i < num_clks; i++) { 2273 - if (!mmcc_msm8960_clks[i]) 2274 - continue; 2275 - clk = devm_clk_register_regmap(dev, mmcc_msm8960_clks[i]); 2276 - if (IS_ERR(clk)) 2277 - return PTR_ERR(clk); 2278 - clks[i] = clk; 2279 - } 2280 - 2281 - ret = of_clk_add_provider(dev->of_node, of_clk_src_onecell_get, data); 2282 - if (ret) 2283 - return ret; 2284 - 2285 - reset = &cc->reset; 2286 - reset->rcdev.of_node = dev->of_node; 2287 - reset->rcdev.ops = &qcom_reset_ops, 2288 - reset->rcdev.owner = THIS_MODULE, 2289 - reset->rcdev.nr_resets = ARRAY_SIZE(mmcc_msm8960_resets), 2290 - reset->regmap = regmap; 2291 - reset->reset_map = mmcc_msm8960_resets, 2292 - platform_set_drvdata(pdev, &reset->rcdev); 2293 - 2294 - ret = reset_controller_register(&reset->rcdev); 2295 - if (ret) 2296 - of_clk_del_provider(dev->of_node); 2297 - 2298 - return ret; 2241 + return qcom_cc_probe(pdev, &mmcc_msm8960_desc); 2299 2242 } 2300 2243 2301 2244 static int mmcc_msm8960_remove(struct platform_device *pdev) 2302 2245 { 2303 - of_clk_del_provider(pdev->dev.of_node); 2304 - reset_controller_unregister(platform_get_drvdata(pdev)); 2246 + qcom_cc_remove(pdev); 2305 2247 return 0; 2306 2248 } 2307 2249
+16 -64
drivers/clk/qcom/mmcc-msm8974.c
··· 25 25 #include <dt-bindings/clock/qcom,mmcc-msm8974.h> 26 26 #include <dt-bindings/reset/qcom,mmcc-msm8974.h> 27 27 28 + #include "common.h" 28 29 #include "clk-regmap.h" 29 30 #include "clk-pll.h" 30 31 #include "clk-rcg.h" ··· 2525 2524 .fast_io = true, 2526 2525 }; 2527 2526 2527 + static const struct qcom_cc_desc mmcc_msm8974_desc = { 2528 + .config = &mmcc_msm8974_regmap_config, 2529 + .clks = mmcc_msm8974_clocks, 2530 + .num_clks = ARRAY_SIZE(mmcc_msm8974_clocks), 2531 + .resets = mmcc_msm8974_resets, 2532 + .num_resets = ARRAY_SIZE(mmcc_msm8974_resets), 2533 + }; 2534 + 2528 2535 static const struct of_device_id mmcc_msm8974_match_table[] = { 2529 2536 { .compatible = "qcom,mmcc-msm8974" }, 2530 2537 { } 2531 2538 }; 2532 2539 MODULE_DEVICE_TABLE(of, mmcc_msm8974_match_table); 2533 2540 2534 - struct qcom_cc { 2535 - struct qcom_reset_controller reset; 2536 - struct clk_onecell_data data; 2537 - struct clk *clks[]; 2538 - }; 2539 - 2540 2541 static int mmcc_msm8974_probe(struct platform_device *pdev) 2541 2542 { 2542 - void __iomem *base; 2543 - struct resource *res; 2544 - int i, ret; 2545 - struct device *dev = &pdev->dev; 2546 - struct clk *clk; 2547 - struct clk_onecell_data *data; 2548 - struct clk **clks; 2543 + int ret; 2549 2544 struct regmap *regmap; 2550 - size_t num_clks; 2551 - struct qcom_reset_controller *reset; 2552 - struct qcom_cc *cc; 2553 2545 2554 - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 2555 - base = devm_ioremap_resource(dev, res); 2556 - if (IS_ERR(base)) 2557 - return PTR_ERR(base); 2558 - 2559 - regmap = devm_regmap_init_mmio(dev, base, &mmcc_msm8974_regmap_config); 2560 - if (IS_ERR(regmap)) 2561 - return PTR_ERR(regmap); 2562 - 2563 - num_clks = ARRAY_SIZE(mmcc_msm8974_clocks); 2564 - cc = devm_kzalloc(dev, sizeof(*cc) + sizeof(*clks) * num_clks, 2565 - GFP_KERNEL); 2566 - if (!cc) 2567 - return -ENOMEM; 2568 - 2569 - clks = cc->clks; 2570 - data = &cc->data; 2571 - data->clks = clks; 2572 - data->clk_num = num_clks; 2573 - 2574 - clk_pll_configure_sr_hpm_lp(&mmpll1, regmap, &mmpll1_config, true); 2575 - clk_pll_configure_sr_hpm_lp(&mmpll3, regmap, &mmpll3_config, false); 2576 - 2577 - for (i = 0; i < num_clks; i++) { 2578 - if (!mmcc_msm8974_clocks[i]) 2579 - continue; 2580 - clk = devm_clk_register_regmap(dev, mmcc_msm8974_clocks[i]); 2581 - if (IS_ERR(clk)) 2582 - return PTR_ERR(clk); 2583 - clks[i] = clk; 2584 - } 2585 - 2586 - ret = of_clk_add_provider(dev->of_node, of_clk_src_onecell_get, data); 2546 + ret = qcom_cc_probe(pdev, &mmcc_msm8974_desc); 2587 2547 if (ret) 2588 2548 return ret; 2589 2549 2590 - reset = &cc->reset; 2591 - reset->rcdev.of_node = dev->of_node; 2592 - reset->rcdev.ops = &qcom_reset_ops, 2593 - reset->rcdev.owner = THIS_MODULE, 2594 - reset->rcdev.nr_resets = ARRAY_SIZE(mmcc_msm8974_resets), 2595 - reset->regmap = regmap; 2596 - reset->reset_map = mmcc_msm8974_resets, 2597 - platform_set_drvdata(pdev, &reset->rcdev); 2550 + regmap = dev_get_regmap(&pdev->dev, NULL); 2551 + clk_pll_configure_sr_hpm_lp(&mmpll1, regmap, &mmpll1_config, true); 2552 + clk_pll_configure_sr_hpm_lp(&mmpll3, regmap, &mmpll3_config, false); 2598 2553 2599 - ret = reset_controller_register(&reset->rcdev); 2600 - if (ret) 2601 - of_clk_del_provider(dev->of_node); 2602 - 2603 - return ret; 2554 + return 0; 2604 2555 } 2605 2556 2606 2557 static int mmcc_msm8974_remove(struct platform_device *pdev) 2607 2558 { 2608 - of_clk_del_provider(pdev->dev.of_node); 2609 - reset_controller_unregister(platform_get_drvdata(pdev)); 2559 + qcom_cc_remove(pdev); 2610 2560 return 0; 2611 2561 } 2612 2562
+2
drivers/clk/shmobile/Makefile
··· 1 1 obj-$(CONFIG_ARCH_EMEV2) += clk-emev2.o 2 2 obj-$(CONFIG_ARCH_R7S72100) += clk-rz.o 3 + obj-$(CONFIG_ARCH_R8A7740) += clk-r8a7740.o 4 + obj-$(CONFIG_ARCH_R8A7779) += clk-r8a7779.o 3 5 obj-$(CONFIG_ARCH_R8A7790) += clk-rcar-gen2.o 4 6 obj-$(CONFIG_ARCH_R8A7791) += clk-rcar-gen2.o 5 7 obj-$(CONFIG_ARCH_SHMOBILE_MULTI) += clk-div6.o
+1 -1
drivers/clk/shmobile/clk-mstp.c
··· 112 112 else 113 113 value = clk_readl(group->smstpcr); 114 114 115 - return !!(value & BIT(clock->bit_index)); 115 + return !(value & BIT(clock->bit_index)); 116 116 } 117 117 118 118 static const struct clk_ops cpg_mstp_clock_ops = {
+199
drivers/clk/shmobile/clk-r8a7740.c
··· 1 + /* 2 + * r8a7740 Core CPG Clocks 3 + * 4 + * Copyright (C) 2014 Ulrich Hecht 5 + * 6 + * This program is free software; you can redistribute it and/or modify 7 + * it under the terms of the GNU General Public License as published by 8 + * the Free Software Foundation; version 2 of the License. 9 + */ 10 + 11 + #include <linux/clk-provider.h> 12 + #include <linux/clkdev.h> 13 + #include <linux/clk/shmobile.h> 14 + #include <linux/init.h> 15 + #include <linux/kernel.h> 16 + #include <linux/of.h> 17 + #include <linux/of_address.h> 18 + #include <linux/spinlock.h> 19 + 20 + struct r8a7740_cpg { 21 + struct clk_onecell_data data; 22 + spinlock_t lock; 23 + void __iomem *reg; 24 + }; 25 + 26 + #define CPG_FRQCRA 0x00 27 + #define CPG_FRQCRB 0x04 28 + #define CPG_PLLC2CR 0x2c 29 + #define CPG_USBCKCR 0x8c 30 + #define CPG_FRQCRC 0xe0 31 + 32 + #define CLK_ENABLE_ON_INIT BIT(0) 33 + 34 + struct div4_clk { 35 + const char *name; 36 + unsigned int reg; 37 + unsigned int shift; 38 + int flags; 39 + }; 40 + 41 + static struct div4_clk div4_clks[] = { 42 + { "i", CPG_FRQCRA, 20, CLK_ENABLE_ON_INIT }, 43 + { "zg", CPG_FRQCRA, 16, CLK_ENABLE_ON_INIT }, 44 + { "b", CPG_FRQCRA, 8, CLK_ENABLE_ON_INIT }, 45 + { "m1", CPG_FRQCRA, 4, CLK_ENABLE_ON_INIT }, 46 + { "hp", CPG_FRQCRB, 4, 0 }, 47 + { "hpp", CPG_FRQCRC, 20, 0 }, 48 + { "usbp", CPG_FRQCRC, 16, 0 }, 49 + { "s", CPG_FRQCRC, 12, 0 }, 50 + { "zb", CPG_FRQCRC, 8, 0 }, 51 + { "m3", CPG_FRQCRC, 4, 0 }, 52 + { "cp", CPG_FRQCRC, 0, 0 }, 53 + { NULL, 0, 0, 0 }, 54 + }; 55 + 56 + static const struct clk_div_table div4_div_table[] = { 57 + { 0, 2 }, { 1, 3 }, { 2, 4 }, { 3, 6 }, { 4, 8 }, { 5, 12 }, 58 + { 6, 16 }, { 7, 18 }, { 8, 24 }, { 9, 32 }, { 10, 36 }, { 11, 48 }, 59 + { 13, 72 }, { 14, 96 }, { 0, 0 } 60 + }; 61 + 62 + static u32 cpg_mode __initdata; 63 + 64 + static struct clk * __init 65 + r8a7740_cpg_register_clock(struct device_node *np, struct r8a7740_cpg *cpg, 66 + const char *name) 67 + { 68 + const struct clk_div_table *table = NULL; 69 + const char *parent_name; 70 + unsigned int shift, reg; 71 + unsigned int mult = 1; 72 + unsigned int div = 1; 73 + 74 + if (!strcmp(name, "r")) { 75 + switch (cpg_mode & (BIT(2) | BIT(1))) { 76 + case BIT(1) | BIT(2): 77 + /* extal1 */ 78 + parent_name = of_clk_get_parent_name(np, 0); 79 + div = 2048; 80 + break; 81 + case BIT(2): 82 + /* extal1 */ 83 + parent_name = of_clk_get_parent_name(np, 0); 84 + div = 1024; 85 + break; 86 + default: 87 + /* extalr */ 88 + parent_name = of_clk_get_parent_name(np, 2); 89 + break; 90 + } 91 + } else if (!strcmp(name, "system")) { 92 + parent_name = of_clk_get_parent_name(np, 0); 93 + if (cpg_mode & BIT(1)) 94 + div = 2; 95 + } else if (!strcmp(name, "pllc0")) { 96 + /* PLLC0/1 are configurable multiplier clocks. Register them as 97 + * fixed factor clocks for now as there's no generic multiplier 98 + * clock implementation and we currently have no need to change 99 + * the multiplier value. 100 + */ 101 + u32 value = clk_readl(cpg->reg + CPG_FRQCRC); 102 + parent_name = "system"; 103 + mult = ((value >> 24) & 0x7f) + 1; 104 + } else if (!strcmp(name, "pllc1")) { 105 + u32 value = clk_readl(cpg->reg + CPG_FRQCRA); 106 + parent_name = "system"; 107 + mult = ((value >> 24) & 0x7f) + 1; 108 + div = 2; 109 + } else if (!strcmp(name, "pllc2")) { 110 + u32 value = clk_readl(cpg->reg + CPG_PLLC2CR); 111 + parent_name = "system"; 112 + mult = ((value >> 24) & 0x3f) + 1; 113 + } else if (!strcmp(name, "usb24s")) { 114 + u32 value = clk_readl(cpg->reg + CPG_USBCKCR); 115 + if (value & BIT(7)) 116 + /* extal2 */ 117 + parent_name = of_clk_get_parent_name(np, 1); 118 + else 119 + parent_name = "system"; 120 + if (!(value & BIT(6))) 121 + div = 2; 122 + } else { 123 + struct div4_clk *c; 124 + for (c = div4_clks; c->name; c++) { 125 + if (!strcmp(name, c->name)) { 126 + parent_name = "pllc1"; 127 + table = div4_div_table; 128 + reg = c->reg; 129 + shift = c->shift; 130 + break; 131 + } 132 + } 133 + if (!c->name) 134 + return ERR_PTR(-EINVAL); 135 + } 136 + 137 + if (!table) { 138 + return clk_register_fixed_factor(NULL, name, parent_name, 0, 139 + mult, div); 140 + } else { 141 + return clk_register_divider_table(NULL, name, parent_name, 0, 142 + cpg->reg + reg, shift, 4, 0, 143 + table, &cpg->lock); 144 + } 145 + } 146 + 147 + static void __init r8a7740_cpg_clocks_init(struct device_node *np) 148 + { 149 + struct r8a7740_cpg *cpg; 150 + struct clk **clks; 151 + unsigned int i; 152 + int num_clks; 153 + 154 + if (of_property_read_u32(np, "renesas,mode", &cpg_mode)) 155 + pr_warn("%s: missing renesas,mode property\n", __func__); 156 + 157 + num_clks = of_property_count_strings(np, "clock-output-names"); 158 + if (num_clks < 0) { 159 + pr_err("%s: failed to count clocks\n", __func__); 160 + return; 161 + } 162 + 163 + cpg = kzalloc(sizeof(*cpg), GFP_KERNEL); 164 + clks = kzalloc(num_clks * sizeof(*clks), GFP_KERNEL); 165 + if (cpg == NULL || clks == NULL) { 166 + /* We're leaking memory on purpose, there's no point in cleaning 167 + * up as the system won't boot anyway. 168 + */ 169 + return; 170 + } 171 + 172 + spin_lock_init(&cpg->lock); 173 + 174 + cpg->data.clks = clks; 175 + cpg->data.clk_num = num_clks; 176 + 177 + cpg->reg = of_iomap(np, 0); 178 + if (WARN_ON(cpg->reg == NULL)) 179 + return; 180 + 181 + for (i = 0; i < num_clks; ++i) { 182 + const char *name; 183 + struct clk *clk; 184 + 185 + of_property_read_string_index(np, "clock-output-names", i, 186 + &name); 187 + 188 + clk = r8a7740_cpg_register_clock(np, cpg, name); 189 + if (IS_ERR(clk)) 190 + pr_err("%s: failed to register %s %s clock (%ld)\n", 191 + __func__, np->name, name, PTR_ERR(clk)); 192 + else 193 + cpg->data.clks[i] = clk; 194 + } 195 + 196 + of_clk_add_provider(np, of_clk_src_onecell_get, &cpg->data); 197 + } 198 + CLK_OF_DECLARE(r8a7740_cpg_clks, "renesas,r8a7740-cpg-clocks", 199 + r8a7740_cpg_clocks_init);
+180
drivers/clk/shmobile/clk-r8a7779.c
··· 1 + /* 2 + * r8a7779 Core CPG Clocks 3 + * 4 + * Copyright (C) 2013, 2014 Horms Solutions Ltd. 5 + * 6 + * Contact: Simon Horman <horms@verge.net.au> 7 + * 8 + * This program is free software; you can redistribute it and/or modify 9 + * it under the terms of the GNU General Public License as published by 10 + * the Free Software Foundation; version 2 of the License. 11 + */ 12 + 13 + #include <linux/clk-provider.h> 14 + #include <linux/clkdev.h> 15 + #include <linux/clk/shmobile.h> 16 + #include <linux/init.h> 17 + #include <linux/kernel.h> 18 + #include <linux/of.h> 19 + #include <linux/of_address.h> 20 + #include <linux/spinlock.h> 21 + 22 + #include <dt-bindings/clock/r8a7779-clock.h> 23 + 24 + #define CPG_NUM_CLOCKS (R8A7779_CLK_OUT + 1) 25 + 26 + struct r8a7779_cpg { 27 + struct clk_onecell_data data; 28 + spinlock_t lock; 29 + void __iomem *reg; 30 + }; 31 + 32 + /* ----------------------------------------------------------------------------- 33 + * CPG Clock Data 34 + */ 35 + 36 + /* 37 + * MD1 = 1 MD1 = 0 38 + * (PLLA = 1500) (PLLA = 1600) 39 + * (MHz) (MHz) 40 + *------------------------------------------------+-------------------- 41 + * clkz 1000 (2/3) 800 (1/2) 42 + * clkzs 250 (1/6) 200 (1/8) 43 + * clki 750 (1/2) 800 (1/2) 44 + * clks 250 (1/6) 200 (1/8) 45 + * clks1 125 (1/12) 100 (1/16) 46 + * clks3 187.5 (1/8) 200 (1/8) 47 + * clks4 93.7 (1/16) 100 (1/16) 48 + * clkp 62.5 (1/24) 50 (1/32) 49 + * clkg 62.5 (1/24) 66.6 (1/24) 50 + * clkb, CLKOUT 51 + * (MD2 = 0) 62.5 (1/24) 66.6 (1/24) 52 + * (MD2 = 1) 41.6 (1/36) 50 (1/32) 53 + */ 54 + 55 + #define CPG_CLK_CONFIG_INDEX(md) (((md) & (BIT(2)|BIT(1))) >> 1) 56 + 57 + struct cpg_clk_config { 58 + unsigned int z_mult; 59 + unsigned int z_div; 60 + unsigned int zs_and_s_div; 61 + unsigned int s1_div; 62 + unsigned int p_div; 63 + unsigned int b_and_out_div; 64 + }; 65 + 66 + static const struct cpg_clk_config cpg_clk_configs[4] __initconst = { 67 + { 1, 2, 8, 16, 32, 24 }, 68 + { 2, 3, 6, 12, 24, 24 }, 69 + { 1, 2, 8, 16, 32, 32 }, 70 + { 2, 3, 6, 12, 24, 36 }, 71 + }; 72 + 73 + /* 74 + * MD PLLA Ratio 75 + * 12 11 76 + *------------------------ 77 + * 0 0 x42 78 + * 0 1 x48 79 + * 1 0 x56 80 + * 1 1 x64 81 + */ 82 + 83 + #define CPG_PLLA_MULT_INDEX(md) (((md) & (BIT(12)|BIT(11))) >> 11) 84 + 85 + static const unsigned int cpg_plla_mult[4] __initconst = { 42, 48, 56, 64 }; 86 + 87 + /* ----------------------------------------------------------------------------- 88 + * Initialization 89 + */ 90 + 91 + static u32 cpg_mode __initdata; 92 + 93 + static struct clk * __init 94 + r8a7779_cpg_register_clock(struct device_node *np, struct r8a7779_cpg *cpg, 95 + const struct cpg_clk_config *config, 96 + unsigned int plla_mult, const char *name) 97 + { 98 + const char *parent_name = "plla"; 99 + unsigned int mult = 1; 100 + unsigned int div = 1; 101 + 102 + if (!strcmp(name, "plla")) { 103 + parent_name = of_clk_get_parent_name(np, 0); 104 + mult = plla_mult; 105 + } else if (!strcmp(name, "z")) { 106 + div = config->z_div; 107 + mult = config->z_mult; 108 + } else if (!strcmp(name, "zs") || !strcmp(name, "s")) { 109 + div = config->zs_and_s_div; 110 + } else if (!strcmp(name, "s1")) { 111 + div = config->s1_div; 112 + } else if (!strcmp(name, "p")) { 113 + div = config->p_div; 114 + } else if (!strcmp(name, "b") || !strcmp(name, "out")) { 115 + div = config->b_and_out_div; 116 + } else { 117 + return ERR_PTR(-EINVAL); 118 + } 119 + 120 + return clk_register_fixed_factor(NULL, name, parent_name, 0, mult, div); 121 + } 122 + 123 + static void __init r8a7779_cpg_clocks_init(struct device_node *np) 124 + { 125 + const struct cpg_clk_config *config; 126 + struct r8a7779_cpg *cpg; 127 + struct clk **clks; 128 + unsigned int i, plla_mult; 129 + int num_clks; 130 + 131 + num_clks = of_property_count_strings(np, "clock-output-names"); 132 + if (num_clks < 0) { 133 + pr_err("%s: failed to count clocks\n", __func__); 134 + return; 135 + } 136 + 137 + cpg = kzalloc(sizeof(*cpg), GFP_KERNEL); 138 + clks = kzalloc(CPG_NUM_CLOCKS * sizeof(*clks), GFP_KERNEL); 139 + if (cpg == NULL || clks == NULL) { 140 + /* We're leaking memory on purpose, there's no point in cleaning 141 + * up as the system won't boot anyway. 142 + */ 143 + return; 144 + } 145 + 146 + spin_lock_init(&cpg->lock); 147 + 148 + cpg->data.clks = clks; 149 + cpg->data.clk_num = num_clks; 150 + 151 + config = &cpg_clk_configs[CPG_CLK_CONFIG_INDEX(cpg_mode)]; 152 + plla_mult = cpg_plla_mult[CPG_PLLA_MULT_INDEX(cpg_mode)]; 153 + 154 + for (i = 0; i < num_clks; ++i) { 155 + const char *name; 156 + struct clk *clk; 157 + 158 + of_property_read_string_index(np, "clock-output-names", i, 159 + &name); 160 + 161 + clk = r8a7779_cpg_register_clock(np, cpg, config, 162 + plla_mult, name); 163 + if (IS_ERR(clk)) 164 + pr_err("%s: failed to register %s %s clock (%ld)\n", 165 + __func__, np->name, name, PTR_ERR(clk)); 166 + else 167 + cpg->data.clks[i] = clk; 168 + } 169 + 170 + of_clk_add_provider(np, of_clk_src_onecell_get, &cpg->data); 171 + } 172 + CLK_OF_DECLARE(r8a7779_cpg_clks, "renesas,r8a7779-cpg-clocks", 173 + r8a7779_cpg_clocks_init); 174 + 175 + void __init r8a7779_clocks_init(u32 mode) 176 + { 177 + cpg_mode = mode; 178 + 179 + of_clk_init(NULL); 180 + }
-1
drivers/clk/socfpga/clk-gate.c
··· 32 32 #define SOCFPGA_MMC_CLK "sdmmc_clk" 33 33 #define SOCFPGA_GPIO_DB_CLK_OFFSET 0xA8 34 34 35 - #define div_mask(width) ((1 << (width)) - 1) 36 35 #define streq(a, b) (strcmp((a), (b)) == 0) 37 36 38 37 #define to_socfpga_gate_clk(p) container_of(p, struct socfpga_gate_clk, hw.hw)
+19 -3
drivers/clk/socfpga/clk-periph.c
··· 29 29 unsigned long parent_rate) 30 30 { 31 31 struct socfpga_periph_clk *socfpgaclk = to_socfpga_periph_clk(hwclk); 32 - u32 div; 32 + u32 div, val; 33 33 34 - if (socfpgaclk->fixed_div) 34 + if (socfpgaclk->fixed_div) { 35 35 div = socfpgaclk->fixed_div; 36 - else 36 + } else { 37 + if (socfpgaclk->div_reg) { 38 + val = readl(socfpgaclk->div_reg) >> socfpgaclk->shift; 39 + val &= div_mask(socfpgaclk->width); 40 + parent_rate /= (val + 1); 41 + } 37 42 div = ((readl(socfpgaclk->hw.reg) & 0x1ff) + 1); 43 + } 38 44 39 45 return parent_rate / div; 40 46 } ··· 60 54 struct clk_init_data init; 61 55 int rc; 62 56 u32 fixed_div; 57 + u32 div_reg[3]; 63 58 64 59 of_property_read_u32(node, "reg", &reg); 65 60 ··· 69 62 return; 70 63 71 64 periph_clk->hw.reg = clk_mgr_base_addr + reg; 65 + 66 + rc = of_property_read_u32_array(node, "div-reg", div_reg, 3); 67 + if (!rc) { 68 + periph_clk->div_reg = clk_mgr_base_addr + div_reg[0]; 69 + periph_clk->shift = div_reg[1]; 70 + periph_clk->width = div_reg[2]; 71 + } else { 72 + periph_clk->div_reg = 0; 73 + } 72 74 73 75 rc = of_property_read_u32(node, "fixed-divider", &fixed_div); 74 76 if (rc)
+4
drivers/clk/socfpga/clk.h
··· 27 27 #define CLKMGR_PERPLL_SRC 0xAC 28 28 29 29 #define SOCFPGA_MAX_PARENTS 3 30 + #define div_mask(width) ((1 << (width)) - 1) 30 31 31 32 extern void __iomem *clk_mgr_base_addr; 32 33 ··· 53 52 struct clk_gate hw; 54 53 char *parent_name; 55 54 u32 fixed_div; 55 + void __iomem *div_reg; 56 + u32 width; /* only valid if div_reg != 0 */ 57 + u32 shift; /* only valid if div_reg != 0 */ 56 58 }; 57 59 58 60 #endif /* SOCFPGA_CLK_H */
+36
drivers/clk/sunxi/clk-factors.c
··· 77 77 return rate; 78 78 } 79 79 80 + static long clk_factors_determine_rate(struct clk_hw *hw, unsigned long rate, 81 + unsigned long *best_parent_rate, 82 + struct clk **best_parent_p) 83 + { 84 + struct clk *clk = hw->clk, *parent, *best_parent = NULL; 85 + int i, num_parents; 86 + unsigned long parent_rate, best = 0, child_rate, best_child_rate = 0; 87 + 88 + /* find the parent that can help provide the fastest rate <= rate */ 89 + num_parents = __clk_get_num_parents(clk); 90 + for (i = 0; i < num_parents; i++) { 91 + parent = clk_get_parent_by_index(clk, i); 92 + if (!parent) 93 + continue; 94 + if (__clk_get_flags(clk) & CLK_SET_RATE_PARENT) 95 + parent_rate = __clk_round_rate(parent, rate); 96 + else 97 + parent_rate = __clk_get_rate(parent); 98 + 99 + child_rate = clk_factors_round_rate(hw, rate, &parent_rate); 100 + 101 + if (child_rate <= rate && child_rate > best_child_rate) { 102 + best_parent = parent; 103 + best = parent_rate; 104 + best_child_rate = child_rate; 105 + } 106 + } 107 + 108 + if (best_parent) 109 + *best_parent_p = best_parent; 110 + *best_parent_rate = best; 111 + 112 + return best_child_rate; 113 + } 114 + 80 115 static int clk_factors_set_rate(struct clk_hw *hw, unsigned long rate, 81 116 unsigned long parent_rate) 82 117 { ··· 148 113 } 149 114 150 115 const struct clk_ops clk_factors_ops = { 116 + .determine_rate = clk_factors_determine_rate, 151 117 .recalc_rate = clk_factors_recalc_rate, 152 118 .round_rate = clk_factors_round_rate, 153 119 .set_rate = clk_factors_set_rate,
+37
drivers/clk/sunxi/clk-sunxi.c
··· 507 507 508 508 509 509 /** 510 + * clk_sunxi_mmc_phase_control() - configures MMC clock phase control 511 + */ 512 + 513 + void clk_sunxi_mmc_phase_control(struct clk *clk, u8 sample, u8 output) 514 + { 515 + #define to_clk_composite(_hw) container_of(_hw, struct clk_composite, hw) 516 + #define to_clk_factors(_hw) container_of(_hw, struct clk_factors, hw) 517 + 518 + struct clk_hw *hw = __clk_get_hw(clk); 519 + struct clk_composite *composite = to_clk_composite(hw); 520 + struct clk_hw *rate_hw = composite->rate_hw; 521 + struct clk_factors *factors = to_clk_factors(rate_hw); 522 + unsigned long flags = 0; 523 + u32 reg; 524 + 525 + if (factors->lock) 526 + spin_lock_irqsave(factors->lock, flags); 527 + 528 + reg = readl(factors->reg); 529 + 530 + /* set sample clock phase control */ 531 + reg &= ~(0x7 << 20); 532 + reg |= ((sample & 0x7) << 20); 533 + 534 + /* set output clock phase control */ 535 + reg &= ~(0x7 << 8); 536 + reg |= ((output & 0x7) << 8); 537 + 538 + writel(reg, factors->reg); 539 + 540 + if (factors->lock) 541 + spin_unlock_irqrestore(factors->lock, flags); 542 + } 543 + EXPORT_SYMBOL(clk_sunxi_mmc_phase_control); 544 + 545 + 546 + /** 510 547 * sunxi_factors_clk_setup() - Setup function for factor clocks 511 548 */ 512 549
+1
drivers/clk/tegra/clk-id.h
··· 233 233 tegra_clk_xusb_hs_src, 234 234 tegra_clk_xusb_ss, 235 235 tegra_clk_xusb_ss_src, 236 + tegra_clk_xusb_ss_div2, 236 237 tegra_clk_max, 237 238 }; 238 239
+32 -1
drivers/clk/tegra/clk-pll.c
··· 96 96 (PLLE_SS_MAX_VAL | PLLE_SS_INC_VAL | PLLE_SS_INCINTRV_VAL) 97 97 98 98 #define PLLE_AUX_PLLP_SEL BIT(2) 99 + #define PLLE_AUX_USE_LOCKDET BIT(3) 99 100 #define PLLE_AUX_ENABLE_SWCTL BIT(4) 101 + #define PLLE_AUX_SS_SWCTL BIT(6) 100 102 #define PLLE_AUX_SEQ_ENABLE BIT(24) 103 + #define PLLE_AUX_SEQ_START_STATE BIT(25) 101 104 #define PLLE_AUX_PLLRE_SEL BIT(28) 105 + 106 + #define XUSBIO_PLL_CFG0 0x51c 107 + #define XUSBIO_PLL_CFG0_PADPLL_RESET_SWCTL BIT(0) 108 + #define XUSBIO_PLL_CFG0_CLK_ENABLE_SWCTL BIT(2) 109 + #define XUSBIO_PLL_CFG0_PADPLL_USE_LOCKDET BIT(6) 110 + #define XUSBIO_PLL_CFG0_SEQ_ENABLE BIT(24) 111 + #define XUSBIO_PLL_CFG0_SEQ_START_STATE BIT(25) 102 112 103 113 #define PLLE_MISC_PLLE_PTS BIT(8) 104 114 #define PLLE_MISC_IDDQ_SW_VALUE BIT(13) ··· 1328 1318 pll_writel(val, PLLE_SS_CTRL, pll); 1329 1319 udelay(1); 1330 1320 1331 - /* TODO: enable hw control of xusb brick pll */ 1321 + /* Enable hw control of xusb brick pll */ 1322 + val = pll_readl_misc(pll); 1323 + val &= ~PLLE_MISC_IDDQ_SW_CTRL; 1324 + pll_writel_misc(val, pll); 1325 + 1326 + val = pll_readl(pll->params->aux_reg, pll); 1327 + val |= (PLLE_AUX_USE_LOCKDET | PLLE_AUX_SEQ_START_STATE); 1328 + val &= ~(PLLE_AUX_ENABLE_SWCTL | PLLE_AUX_SS_SWCTL); 1329 + pll_writel(val, pll->params->aux_reg, pll); 1330 + udelay(1); 1331 + val |= PLLE_AUX_SEQ_ENABLE; 1332 + pll_writel(val, pll->params->aux_reg, pll); 1333 + 1334 + val = pll_readl(XUSBIO_PLL_CFG0, pll); 1335 + val |= (XUSBIO_PLL_CFG0_PADPLL_USE_LOCKDET | 1336 + XUSBIO_PLL_CFG0_SEQ_START_STATE); 1337 + val &= ~(XUSBIO_PLL_CFG0_CLK_ENABLE_SWCTL | 1338 + XUSBIO_PLL_CFG0_PADPLL_RESET_SWCTL); 1339 + pll_writel(val, XUSBIO_PLL_CFG0, pll); 1340 + udelay(1); 1341 + val |= XUSBIO_PLL_CFG0_SEQ_ENABLE; 1342 + pll_writel(val, XUSBIO_PLL_CFG0, pll); 1332 1343 1333 1344 out: 1334 1345 if (pll->lock)
+9 -1
drivers/clk/tegra/clk-tegra-periph.c
··· 329 329 static const char *mux_clkm_48M_pllp_480M[] = { 330 330 "clk_m", "pll_u_48M", "pll_p", "pll_u_480M" 331 331 }; 332 - #define mux_clkm_48M_pllp_480M_idx NULL 332 + static u32 mux_clkm_48M_pllp_480M_idx[] = { 333 + [0] = 0, [1] = 2, [2] = 4, [3] = 6, 334 + }; 333 335 334 336 static const char *mux_clkm_pllre_clk32_480M_pllc_ref[] = { 335 337 "clk_m", "pll_re_out", "clk_32k", "pll_u_480M", "pll_c", "pll_ref" ··· 339 337 static u32 mux_clkm_pllre_clk32_480M_pllc_ref_idx[] = { 340 338 [0] = 0, [1] = 1, [2] = 3, [3] = 3, [4] = 4, [5] = 7, 341 339 }; 340 + 341 + static const char *mux_ss_60M[] = { 342 + "xusb_ss_div2", "pll_u_60M" 343 + }; 344 + #define mux_ss_60M_idx NULL 342 345 343 346 static const char *mux_d_audio_clk[] = { 344 347 "pll_a_out0", "pll_p", "clk_m", "spdif_in_sync", "i2s0_sync", ··· 506 499 XUSB("xusb_falcon_src", mux_clkm_pllp_pllc_pllre, CLK_SOURCE_XUSB_FALCON_SRC, 143, TEGRA_PERIPH_NO_RESET, tegra_clk_xusb_falcon_src), 507 500 XUSB("xusb_fs_src", mux_clkm_48M_pllp_480M, CLK_SOURCE_XUSB_FS_SRC, 143, TEGRA_PERIPH_NO_RESET, tegra_clk_xusb_fs_src), 508 501 XUSB("xusb_ss_src", mux_clkm_pllre_clk32_480M_pllc_ref, CLK_SOURCE_XUSB_SS_SRC, 143, TEGRA_PERIPH_NO_RESET, tegra_clk_xusb_ss_src), 502 + NODIV("xusb_hs_src", mux_ss_60M, CLK_SOURCE_XUSB_SS_SRC, 25, MASK(1), 143, TEGRA_PERIPH_NO_RESET, tegra_clk_xusb_hs_src, NULL), 509 503 XUSB("xusb_dev_src", mux_clkm_pllp_pllc_pllre, CLK_SOURCE_XUSB_DEV_SRC, 95, TEGRA_PERIPH_ON_APB | TEGRA_PERIPH_NO_RESET, tegra_clk_xusb_dev_src), 510 504 }; 511 505
+11 -11
drivers/clk/tegra/clk-tegra114.c
··· 142 142 #define UTMIPLL_HW_PWRDN_CFG0_IDDQ_SWCTL BIT(0) 143 143 144 144 #define CLK_SOURCE_CSITE 0x1d4 145 - #define CLK_SOURCE_XUSB_SS_SRC 0x610 146 145 #define CLK_SOURCE_EMC 0x19c 147 146 148 147 /* PLLM override registers */ ··· 833 834 [tegra_clk_xusb_falcon_src] = { .dt_id = TEGRA114_CLK_XUSB_FALCON_SRC, .present = true }, 834 835 [tegra_clk_xusb_fs_src] = { .dt_id = TEGRA114_CLK_XUSB_FS_SRC, .present = true }, 835 836 [tegra_clk_xusb_ss_src] = { .dt_id = TEGRA114_CLK_XUSB_SS_SRC, .present = true }, 837 + [tegra_clk_xusb_ss_div2] = { .dt_id = TEGRA114_CLK_XUSB_SS_DIV2, .present = true}, 836 838 [tegra_clk_xusb_dev_src] = { .dt_id = TEGRA114_CLK_XUSB_DEV_SRC, .present = true }, 837 839 [tegra_clk_xusb_dev] = { .dt_id = TEGRA114_CLK_XUSB_DEV, .present = true }, 838 840 [tegra_clk_xusb_hs_src] = { .dt_id = TEGRA114_CLK_XUSB_HS_SRC, .present = true }, ··· 1182 1182 void __iomem *pmc_base) 1183 1183 { 1184 1184 struct clk *clk; 1185 - u32 val; 1186 1185 1187 - /* xusb_hs_src */ 1188 - val = readl(clk_base + CLK_SOURCE_XUSB_SS_SRC); 1189 - val |= BIT(25); /* always select PLLU_60M */ 1190 - writel(val, clk_base + CLK_SOURCE_XUSB_SS_SRC); 1191 - 1192 - clk = clk_register_fixed_factor(NULL, "xusb_hs_src", "pll_u_60M", 0, 1193 - 1, 1); 1194 - clks[TEGRA114_CLK_XUSB_HS_SRC] = clk; 1186 + /* xusb_ss_div2 */ 1187 + clk = clk_register_fixed_factor(NULL, "xusb_ss_div2", "xusb_ss_src", 0, 1188 + 1, 2); 1189 + clks[TEGRA114_CLK_XUSB_SS_DIV2] = clk; 1195 1190 1196 1191 /* dsia mux */ 1197 1192 clk = clk_register_mux(NULL, "dsia_mux", mux_plld_out0_plld2_out0, ··· 1296 1301 {TEGRA114_CLK_GR3D, TEGRA114_CLK_PLL_C2, 300000000, 0}, 1297 1302 {TEGRA114_CLK_DSIALP, TEGRA114_CLK_PLL_P, 68000000, 0}, 1298 1303 {TEGRA114_CLK_DSIBLP, TEGRA114_CLK_PLL_P, 68000000, 0}, 1299 - 1304 + {TEGRA114_CLK_PLL_RE_VCO, TEGRA114_CLK_CLK_MAX, 612000000, 0}, 1305 + {TEGRA114_CLK_XUSB_SS_SRC, TEGRA114_CLK_PLL_RE_OUT, 122400000, 0}, 1306 + {TEGRA114_CLK_XUSB_FS_SRC, TEGRA114_CLK_PLL_U_48M, 48000000, 0}, 1307 + {TEGRA114_CLK_XUSB_HS_SRC, TEGRA114_CLK_XUSB_SS_DIV2, 61200000, 0}, 1308 + {TEGRA114_CLK_XUSB_FALCON_SRC, TEGRA114_CLK_PLL_P, 204000000, 0}, 1309 + {TEGRA114_CLK_XUSB_HOST_SRC, TEGRA114_CLK_PLL_P, 102000000, 0}, 1300 1310 /* This MUST be the last entry. */ 1301 1311 {TEGRA114_CLK_CLK_MAX, TEGRA114_CLK_CLK_MAX, 0, 0}, 1302 1312 };
+11 -10
drivers/clk/tegra/clk-tegra124.c
··· 30 30 31 31 #define CLK_SOURCE_CSITE 0x1d4 32 32 #define CLK_SOURCE_EMC 0x19c 33 - #define CLK_SOURCE_XUSB_SS_SRC 0x610 34 33 35 34 #define PLLC_BASE 0x80 36 35 #define PLLC_OUT 0x84 ··· 924 925 [tegra_clk_xusb_falcon_src] = { .dt_id = TEGRA124_CLK_XUSB_FALCON_SRC, .present = true }, 925 926 [tegra_clk_xusb_fs_src] = { .dt_id = TEGRA124_CLK_XUSB_FS_SRC, .present = true }, 926 927 [tegra_clk_xusb_ss_src] = { .dt_id = TEGRA124_CLK_XUSB_SS_SRC, .present = true }, 928 + [tegra_clk_xusb_ss_div2] = { .dt_id = TEGRA124_CLK_XUSB_SS_DIV2, .present = true }, 927 929 [tegra_clk_xusb_dev_src] = { .dt_id = TEGRA124_CLK_XUSB_DEV_SRC, .present = true }, 928 930 [tegra_clk_xusb_dev] = { .dt_id = TEGRA124_CLK_XUSB_DEV, .present = true }, 929 931 [tegra_clk_xusb_hs_src] = { .dt_id = TEGRA124_CLK_XUSB_HS_SRC, .present = true }, ··· 1105 1105 void __iomem *pmc_base) 1106 1106 { 1107 1107 struct clk *clk; 1108 - u32 val; 1109 1108 1110 - /* xusb_hs_src */ 1111 - val = readl(clk_base + CLK_SOURCE_XUSB_SS_SRC); 1112 - val |= BIT(25); /* always select PLLU_60M */ 1113 - writel(val, clk_base + CLK_SOURCE_XUSB_SS_SRC); 1114 - 1115 - clk = clk_register_fixed_factor(NULL, "xusb_hs_src", "pll_u_60M", 0, 1116 - 1, 1); 1117 - clks[TEGRA124_CLK_XUSB_HS_SRC] = clk; 1109 + /* xusb_ss_div2 */ 1110 + clk = clk_register_fixed_factor(NULL, "xusb_ss_div2", "xusb_ss_src", 0, 1111 + 1, 2); 1112 + clks[TEGRA124_CLK_XUSB_SS_DIV2] = clk; 1118 1113 1119 1114 /* dsia mux */ 1120 1115 clk = clk_register_mux(NULL, "dsia_mux", mux_plld_out0_plld2_out0, ··· 1363 1368 {TEGRA124_CLK_SBC4, TEGRA124_CLK_PLL_P, 12000000, 1}, 1364 1369 {TEGRA124_CLK_TSEC, TEGRA124_CLK_PLL_C3, 0, 0}, 1365 1370 {TEGRA124_CLK_MSENC, TEGRA124_CLK_PLL_C3, 0, 0}, 1371 + {TEGRA124_CLK_PLL_RE_VCO, TEGRA124_CLK_CLK_MAX, 672000000, 0}, 1372 + {TEGRA124_CLK_XUSB_SS_SRC, TEGRA124_CLK_PLL_U_480M, 120000000, 0}, 1373 + {TEGRA124_CLK_XUSB_FS_SRC, TEGRA124_CLK_PLL_U_48M, 48000000, 0}, 1374 + {TEGRA124_CLK_XUSB_HS_SRC, TEGRA124_CLK_PLL_U_60M, 60000000, 0}, 1375 + {TEGRA124_CLK_XUSB_FALCON_SRC, TEGRA124_CLK_PLL_RE_OUT, 224000000, 0}, 1376 + {TEGRA124_CLK_XUSB_HOST_SRC, TEGRA124_CLK_PLL_RE_OUT, 112000000, 0}, 1366 1377 /* This MUST be the last entry. */ 1367 1378 {TEGRA124_CLK_CLK_MAX, TEGRA124_CLK_CLK_MAX, 0, 0}, 1368 1379 };
+1
drivers/clk/versatile/clk-icst.c
··· 160 160 161 161 return clk; 162 162 } 163 + EXPORT_SYMBOL_GPL(icst_clk_register);
+31 -7
drivers/clk/versatile/clk-impd1.c
··· 20 20 #define IMPD1_LOCK 0x08 21 21 22 22 struct impd1_clk { 23 + char *pclkname; 24 + struct clk *pclk; 23 25 char *vco1name; 24 26 struct clk *vco1clk; 25 27 char *vco2name; ··· 33 31 struct clk *spiclk; 34 32 char *scname; 35 33 struct clk *scclk; 36 - struct clk_lookup *clks[6]; 34 + struct clk_lookup *clks[15]; 37 35 }; 38 36 39 37 /* One entry for each connected IM-PD1 LM */ ··· 88 86 { 89 87 struct impd1_clk *imc; 90 88 struct clk *clk; 89 + struct clk *pclk; 91 90 int i; 92 91 93 92 if (id > 3) { ··· 97 94 } 98 95 imc = &impd1_clks[id]; 99 96 97 + /* Register the fixed rate PCLK */ 98 + imc->pclkname = kasprintf(GFP_KERNEL, "lm%x-pclk", id); 99 + pclk = clk_register_fixed_rate(NULL, imc->pclkname, NULL, 100 + CLK_IS_ROOT, 0); 101 + imc->pclk = pclk; 102 + 100 103 imc->vco1name = kasprintf(GFP_KERNEL, "lm%x-vco1", id); 101 104 clk = icst_clk_register(NULL, &impd1_icst1_desc, imc->vco1name, NULL, 102 105 base); 103 106 imc->vco1clk = clk; 104 - imc->clks[0] = clkdev_alloc(clk, NULL, "lm%x:01000", id); 107 + imc->clks[0] = clkdev_alloc(pclk, "apb_pclk", "lm%x:01000", id); 108 + imc->clks[1] = clkdev_alloc(clk, NULL, "lm%x:01000", id); 105 109 106 110 /* VCO2 is also called "CLK2" */ 107 111 imc->vco2name = kasprintf(GFP_KERNEL, "lm%x-vco2", id); ··· 117 107 imc->vco2clk = clk; 118 108 119 109 /* MMCI uses CLK2 right off */ 120 - imc->clks[1] = clkdev_alloc(clk, NULL, "lm%x:00700", id); 110 + imc->clks[2] = clkdev_alloc(pclk, "apb_pclk", "lm%x:00700", id); 111 + imc->clks[3] = clkdev_alloc(clk, NULL, "lm%x:00700", id); 121 112 122 113 /* UART reference clock divides CLK2 by a fixed factor 4 */ 123 114 imc->uartname = kasprintf(GFP_KERNEL, "lm%x-uartclk", id); 124 115 clk = clk_register_fixed_factor(NULL, imc->uartname, imc->vco2name, 125 116 CLK_IGNORE_UNUSED, 1, 4); 126 117 imc->uartclk = clk; 127 - imc->clks[2] = clkdev_alloc(clk, NULL, "lm%x:00100", id); 128 - imc->clks[3] = clkdev_alloc(clk, NULL, "lm%x:00200", id); 118 + imc->clks[4] = clkdev_alloc(pclk, "apb_pclk", "lm%x:00100", id); 119 + imc->clks[5] = clkdev_alloc(clk, NULL, "lm%x:00100", id); 120 + imc->clks[6] = clkdev_alloc(pclk, "apb_pclk", "lm%x:00200", id); 121 + imc->clks[7] = clkdev_alloc(clk, NULL, "lm%x:00200", id); 129 122 130 123 /* SPI PL022 clock divides CLK2 by a fixed factor 64 */ 131 124 imc->spiname = kasprintf(GFP_KERNEL, "lm%x-spiclk", id); 132 125 clk = clk_register_fixed_factor(NULL, imc->spiname, imc->vco2name, 133 126 CLK_IGNORE_UNUSED, 1, 64); 134 - imc->clks[4] = clkdev_alloc(clk, NULL, "lm%x:00300", id); 127 + imc->clks[8] = clkdev_alloc(pclk, "apb_pclk", "lm%x:00300", id); 128 + imc->clks[9] = clkdev_alloc(clk, NULL, "lm%x:00300", id); 129 + 130 + /* The GPIO blocks and AACI have only PCLK */ 131 + imc->clks[10] = clkdev_alloc(pclk, "apb_pclk", "lm%x:00400", id); 132 + imc->clks[11] = clkdev_alloc(pclk, "apb_pclk", "lm%x:00500", id); 133 + imc->clks[12] = clkdev_alloc(pclk, "apb_pclk", "lm%x:00800", id); 135 134 136 135 /* Smart Card clock divides CLK2 by a fixed factor 4 */ 137 136 imc->scname = kasprintf(GFP_KERNEL, "lm%x-scclk", id); 138 137 clk = clk_register_fixed_factor(NULL, imc->scname, imc->vco2name, 139 138 CLK_IGNORE_UNUSED, 1, 4); 140 139 imc->scclk = clk; 141 - imc->clks[5] = clkdev_alloc(clk, NULL, "lm%x:00600", id); 140 + imc->clks[13] = clkdev_alloc(pclk, "apb_pclk", "lm%x:00600", id); 141 + imc->clks[14] = clkdev_alloc(clk, NULL, "lm%x:00600", id); 142 142 143 143 for (i = 0; i < ARRAY_SIZE(imc->clks); i++) 144 144 clkdev_add(imc->clks[i]); 145 145 } 146 + EXPORT_SYMBOL_GPL(integrator_impd1_clk_init); 146 147 147 148 void integrator_impd1_clk_exit(unsigned int id) 148 149 { ··· 170 149 clk_unregister(imc->uartclk); 171 150 clk_unregister(imc->vco2clk); 172 151 clk_unregister(imc->vco1clk); 152 + clk_unregister(imc->pclk); 173 153 kfree(imc->scname); 174 154 kfree(imc->spiname); 175 155 kfree(imc->uartname); 176 156 kfree(imc->vco2name); 177 157 kfree(imc->vco1name); 158 + kfree(imc->pclkname); 178 159 } 160 + EXPORT_SYMBOL_GPL(integrator_impd1_clk_exit);
+12
drivers/clk/zynq/clkc.c
··· 53 53 54 54 #define NUM_MIO_PINS 54 55 55 56 + #define DBG_CLK_CTRL_CLKACT_TRC BIT(0) 57 + #define DBG_CLK_CTRL_CPU_1XCLKACT BIT(1) 58 + 56 59 enum zynq_clk { 57 60 armpll, ddrpll, iopll, 58 61 cpu_6or4x, cpu_3or2x, cpu_2x, cpu_1x, ··· 501 498 clks[dbg_apb] = clk_register_gate(NULL, clk_output_name[dbg_apb], 502 499 clk_output_name[cpu_1x], 0, SLCR_DBG_CLK_CTRL, 1, 0, 503 500 &dbgclk_lock); 501 + 502 + /* leave debug clocks in the state the bootloader set them up to */ 503 + tmp = clk_readl(SLCR_DBG_CLK_CTRL); 504 + if (tmp & DBG_CLK_CTRL_CLKACT_TRC) 505 + if (clk_prepare_enable(clks[dbg_trc])) 506 + pr_warn("%s: trace clk enable failed\n", __func__); 507 + if (tmp & DBG_CLK_CTRL_CPU_1XCLKACT) 508 + if (clk_prepare_enable(clks[dbg_apb])) 509 + pr_warn("%s: debug APB clk enable failed\n", __func__); 504 510 505 511 /* One gated clock for all APER clocks. */ 506 512 clks[dma] = clk_register_gate(NULL, clk_output_name[dma],
+62
include/dt-bindings/clock/bcm21664.h
··· 1 + /* 2 + * Copyright (C) 2013 Broadcom Corporation 3 + * Copyright 2013 Linaro Limited 4 + * 5 + * This program is free software; you can redistribute it and/or 6 + * modify it under the terms of the GNU General Public License as 7 + * published by the Free Software Foundation version 2. 8 + * 9 + * This program is distributed "as is" WITHOUT ANY WARRANTY of any 10 + * kind, whether express or implied; without even the implied warranty 11 + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 + * GNU General Public License for more details. 13 + */ 14 + 15 + #ifndef _CLOCK_BCM21664_H 16 + #define _CLOCK_BCM21664_H 17 + 18 + /* 19 + * This file defines the values used to specify clocks provided by 20 + * the clock control units (CCUs) on Broadcom BCM21664 family SoCs. 21 + */ 22 + 23 + /* bcm21664 CCU device tree "compatible" strings */ 24 + #define BCM21664_DT_ROOT_CCU_COMPAT "brcm,bcm21664-root-ccu" 25 + #define BCM21664_DT_AON_CCU_COMPAT "brcm,bcm21664-aon-ccu" 26 + #define BCM21664_DT_MASTER_CCU_COMPAT "brcm,bcm21664-master-ccu" 27 + #define BCM21664_DT_SLAVE_CCU_COMPAT "brcm,bcm21664-slave-ccu" 28 + 29 + /* root CCU clock ids */ 30 + 31 + #define BCM21664_ROOT_CCU_FRAC_1M 0 32 + #define BCM21664_ROOT_CCU_CLOCK_COUNT 1 33 + 34 + /* aon CCU clock ids */ 35 + 36 + #define BCM21664_AON_CCU_HUB_TIMER 0 37 + #define BCM21664_AON_CCU_CLOCK_COUNT 1 38 + 39 + /* master CCU clock ids */ 40 + 41 + #define BCM21664_MASTER_CCU_SDIO1 0 42 + #define BCM21664_MASTER_CCU_SDIO2 1 43 + #define BCM21664_MASTER_CCU_SDIO3 2 44 + #define BCM21664_MASTER_CCU_SDIO4 3 45 + #define BCM21664_MASTER_CCU_SDIO1_SLEEP 4 46 + #define BCM21664_MASTER_CCU_SDIO2_SLEEP 5 47 + #define BCM21664_MASTER_CCU_SDIO3_SLEEP 6 48 + #define BCM21664_MASTER_CCU_SDIO4_SLEEP 7 49 + #define BCM21664_MASTER_CCU_CLOCK_COUNT 8 50 + 51 + /* slave CCU clock ids */ 52 + 53 + #define BCM21664_SLAVE_CCU_UARTB 0 54 + #define BCM21664_SLAVE_CCU_UARTB2 1 55 + #define BCM21664_SLAVE_CCU_UARTB3 2 56 + #define BCM21664_SLAVE_CCU_BSC1 3 57 + #define BCM21664_SLAVE_CCU_BSC2 4 58 + #define BCM21664_SLAVE_CCU_BSC3 5 59 + #define BCM21664_SLAVE_CCU_BSC4 6 60 + #define BCM21664_SLAVE_CCU_CLOCK_COUNT 7 61 + 62 + #endif /* _CLOCK_BCM21664_H */
+12
include/dt-bindings/clock/bcm281xx.h
··· 20 20 * the clock control units (CCUs) on Broadcom BCM281XX family SoCs. 21 21 */ 22 22 23 + /* 24 + * These are the bcm281xx CCU device tree "compatible" strings. 25 + * We're stuck with using "bcm11351" in the string because wild 26 + * cards aren't allowed, and that name was the first one defined 27 + * in this family of devices. 28 + */ 29 + #define BCM281XX_DT_ROOT_CCU_COMPAT "brcm,bcm11351-root-ccu" 30 + #define BCM281XX_DT_AON_CCU_COMPAT "brcm,bcm11351-aon-ccu" 31 + #define BCM281XX_DT_HUB_CCU_COMPAT "brcm,bcm11351-hub-ccu" 32 + #define BCM281XX_DT_MASTER_CCU_COMPAT "brcm,bcm11351-master-ccu" 33 + #define BCM281XX_DT_SLAVE_CCU_COMPAT "brcm,bcm11351-slave-ccu" 34 + 23 35 /* root CCU clock ids */ 24 36 25 37 #define BCM281XX_ROOT_CCU_FRAC_1M 0
+58
include/dt-bindings/clock/hix5hd2-clock.h
··· 1 + /* 2 + * Copyright (c) 2014 Linaro Ltd. 3 + * Copyright (c) 2014 Hisilicon Limited. 4 + * 5 + * This program is free software; you can redistribute it and/or modify it 6 + * under the terms and conditions of the GNU General Public License, 7 + * version 2, as published by the Free Software Foundation. 8 + */ 9 + 10 + #ifndef __DTS_HIX5HD2_CLOCK_H 11 + #define __DTS_HIX5HD2_CLOCK_H 12 + 13 + /* fixed rate */ 14 + #define HIX5HD2_FIXED_1200M 1 15 + #define HIX5HD2_FIXED_400M 2 16 + #define HIX5HD2_FIXED_48M 3 17 + #define HIX5HD2_FIXED_24M 4 18 + #define HIX5HD2_FIXED_600M 5 19 + #define HIX5HD2_FIXED_300M 6 20 + #define HIX5HD2_FIXED_75M 7 21 + #define HIX5HD2_FIXED_200M 8 22 + #define HIX5HD2_FIXED_100M 9 23 + #define HIX5HD2_FIXED_40M 10 24 + #define HIX5HD2_FIXED_150M 11 25 + #define HIX5HD2_FIXED_1728M 12 26 + #define HIX5HD2_FIXED_28P8M 13 27 + #define HIX5HD2_FIXED_432M 14 28 + #define HIX5HD2_FIXED_345P6M 15 29 + #define HIX5HD2_FIXED_288M 16 30 + #define HIX5HD2_FIXED_60M 17 31 + #define HIX5HD2_FIXED_750M 18 32 + #define HIX5HD2_FIXED_500M 19 33 + #define HIX5HD2_FIXED_54M 20 34 + #define HIX5HD2_FIXED_27M 21 35 + #define HIX5HD2_FIXED_1500M 22 36 + #define HIX5HD2_FIXED_375M 23 37 + #define HIX5HD2_FIXED_187M 24 38 + #define HIX5HD2_FIXED_250M 25 39 + #define HIX5HD2_FIXED_125M 26 40 + #define HIX5HD2_FIXED_2P02M 27 41 + #define HIX5HD2_FIXED_50M 28 42 + #define HIX5HD2_FIXED_25M 29 43 + #define HIX5HD2_FIXED_83M 30 44 + 45 + /* mux clocks */ 46 + #define HIX5HD2_SFC_MUX 64 47 + #define HIX5HD2_MMC_MUX 65 48 + #define HIX5HD2_FEPHY_MUX 66 49 + 50 + /* gate clocks */ 51 + #define HIX5HD2_SFC_RST 128 52 + #define HIX5HD2_SFC_CLK 129 53 + #define HIX5HD2_MMC_CIU_CLK 130 54 + #define HIX5HD2_MMC_BIU_CLK 131 55 + #define HIX5HD2_MMC_CIU_RST 132 56 + 57 + #define HIX5HD2_NR_CLKS 256 58 + #endif /* __DTS_HIX5HD2_CLOCK_H */
+3 -4
include/dt-bindings/clock/qcom,gcc-msm8960.h
··· 51 51 #define QDSS_TSCTR_CLK 34 52 52 #define SFAB_ADM0_M0_A_CLK 35 53 53 #define SFAB_ADM0_M1_A_CLK 36 54 - #define SFAB_ADM0_M2_A_CLK 37 54 + #define SFAB_ADM0_M2_H_CLK 37 55 55 #define ADM0_CLK 38 56 56 #define ADM0_PBUS_CLK 39 57 57 #define MSS_XPU_CLK 40 ··· 99 99 #define CFPB2_H_CLK 82 100 100 #define SFAB_CFPB_M_H_CLK 83 101 101 #define CFPB_MASTER_H_CLK 84 102 - #define SFAB_CFPB_S_HCLK 85 102 + #define SFAB_CFPB_S_H_CLK 85 103 103 #define CFPB_SPLITTER_H_CLK 86 104 104 #define TSIF_H_CLK 87 105 105 #define TSIF_INACTIVITY_TIMERS_CLK 88 ··· 110 110 #define CE1_SLEEP_CLK 93 111 111 #define CE2_H_CLK 94 112 112 #define CE2_CORE_CLK 95 113 - #define CE2_SLEEP_CLK 96 114 113 #define SFPB_H_CLK_SRC 97 115 114 #define SFPB_H_CLK 98 116 115 #define SFAB_SFPB_M_H_CLK 99 ··· 251 252 #define MSS_S_H_CLK 235 252 253 #define MSS_CXO_SRC_CLK 236 253 254 #define SATA_H_CLK 237 254 - #define SATA_SRC_CLK 238 255 + #define SATA_CLK_SRC 238 255 256 #define SATA_RXOOB_CLK 239 256 257 #define SATA_PMALIVE_CLK 240 257 258 #define SATA_PHY_REF_CLK 241
+2 -1
include/dt-bindings/clock/tegra114-car.h
··· 337 337 #define TEGRA114_CLK_CLK_OUT_3_MUX 308 338 338 #define TEGRA114_CLK_DSIA_MUX 309 339 339 #define TEGRA114_CLK_DSIB_MUX 310 340 - #define TEGRA114_CLK_CLK_MAX 311 340 + #define TEGRA114_CLK_XUSB_SS_DIV2 311 341 + #define TEGRA114_CLK_CLK_MAX 312 341 342 342 343 #endif /* _DT_BINDINGS_CLOCK_TEGRA114_CAR_H */
+2 -1
include/dt-bindings/clock/tegra124-car.h
··· 336 336 #define TEGRA124_CLK_DSIA_MUX 309 337 337 #define TEGRA124_CLK_DSIB_MUX 310 338 338 #define TEGRA124_CLK_SOR0_LVDS 311 339 - #define TEGRA124_CLK_CLK_MAX 312 339 + #define TEGRA124_CLK_XUSB_SS_DIV2 312 340 + #define TEGRA124_CLK_CLK_MAX 313 340 341 341 342 #endif /* _DT_BINDINGS_CLOCK_TEGRA124_CAR_H */
+1 -1
include/dt-bindings/reset/qcom,gcc-msm8960.h
··· 58 58 #define PPSS_PROC_RESET 41 59 59 #define PPSS_RESET 42 60 60 #define DMA_BAM_RESET 43 61 - #define SIC_TIC_RESET 44 61 + #define SPS_TIC_H_RESET 44 62 62 #define SLIMBUS_H_RESET 45 63 63 #define SFAB_CFPB_M_RESET 46 64 64 #define SFAB_CFPB_S_RESET 47
+70 -57
include/linux/clk-provider.h
··· 40 40 * through the clk_* api. 41 41 * 42 42 * @prepare: Prepare the clock for enabling. This must not return until 43 - * the clock is fully prepared, and it's safe to call clk_enable. 44 - * This callback is intended to allow clock implementations to 45 - * do any initialisation that may sleep. Called with 46 - * prepare_lock held. 43 + * the clock is fully prepared, and it's safe to call clk_enable. 44 + * This callback is intended to allow clock implementations to 45 + * do any initialisation that may sleep. Called with 46 + * prepare_lock held. 47 47 * 48 48 * @unprepare: Release the clock from its prepared state. This will typically 49 - * undo any work done in the @prepare callback. Called with 50 - * prepare_lock held. 49 + * undo any work done in the @prepare callback. Called with 50 + * prepare_lock held. 51 51 * 52 52 * @is_prepared: Queries the hardware to determine if the clock is prepared. 53 53 * This function is allowed to sleep. Optional, if this op is not ··· 58 58 * Called with prepare mutex held. This function may sleep. 59 59 * 60 60 * @enable: Enable the clock atomically. This must not return until the 61 - * clock is generating a valid clock signal, usable by consumer 62 - * devices. Called with enable_lock held. This function must not 63 - * sleep. 61 + * clock is generating a valid clock signal, usable by consumer 62 + * devices. Called with enable_lock held. This function must not 63 + * sleep. 64 64 * 65 65 * @disable: Disable the clock atomically. Called with enable_lock held. 66 - * This function must not sleep. 66 + * This function must not sleep. 67 67 * 68 68 * @is_enabled: Queries the hardware to determine if the clock is enabled. 69 - * This function must not sleep. Optional, if this op is not 70 - * set then the enable count will be used. 69 + * This function must not sleep. Optional, if this op is not 70 + * set then the enable count will be used. 71 71 * 72 72 * @disable_unused: Disable the clock atomically. Only called from 73 73 * clk_disable_unused for gate clocks with special needs. ··· 75 75 * sleep. 76 76 * 77 77 * @recalc_rate Recalculate the rate of this clock, by querying hardware. The 78 - * parent rate is an input parameter. It is up to the caller to 79 - * ensure that the prepare_mutex is held across this call. 80 - * Returns the calculated rate. Optional, but recommended - if 81 - * this op is not set then clock rate will be initialized to 0. 78 + * parent rate is an input parameter. It is up to the caller to 79 + * ensure that the prepare_mutex is held across this call. 80 + * Returns the calculated rate. Optional, but recommended - if 81 + * this op is not set then clock rate will be initialized to 0. 82 82 * 83 83 * @round_rate: Given a target rate as input, returns the closest rate actually 84 - * supported by the clock. 84 + * supported by the clock. The parent rate is an input/output 85 + * parameter. 85 86 * 86 87 * @determine_rate: Given a target rate as input, returns the closest rate 87 88 * actually supported by the clock, and optionally the parent clock 88 89 * that should be used to provide the clock rate. 89 90 * 90 - * @get_parent: Queries the hardware to determine the parent of a clock. The 91 - * return value is a u8 which specifies the index corresponding to 92 - * the parent clock. This index can be applied to either the 93 - * .parent_names or .parents arrays. In short, this function 94 - * translates the parent value read from hardware into an array 95 - * index. Currently only called when the clock is initialized by 96 - * __clk_init. This callback is mandatory for clocks with 97 - * multiple parents. It is optional (and unnecessary) for clocks 98 - * with 0 or 1 parents. 99 - * 100 91 * @set_parent: Change the input source of this clock; for clocks with multiple 101 - * possible parents specify a new parent by passing in the index 102 - * as a u8 corresponding to the parent in either the .parent_names 103 - * or .parents arrays. This function in affect translates an 104 - * array index into the value programmed into the hardware. 105 - * Returns 0 on success, -EERROR otherwise. 92 + * possible parents specify a new parent by passing in the index 93 + * as a u8 corresponding to the parent in either the .parent_names 94 + * or .parents arrays. This function in affect translates an 95 + * array index into the value programmed into the hardware. 96 + * Returns 0 on success, -EERROR otherwise. 97 + * 98 + * @get_parent: Queries the hardware to determine the parent of a clock. The 99 + * return value is a u8 which specifies the index corresponding to 100 + * the parent clock. This index can be applied to either the 101 + * .parent_names or .parents arrays. In short, this function 102 + * translates the parent value read from hardware into an array 103 + * index. Currently only called when the clock is initialized by 104 + * __clk_init. This callback is mandatory for clocks with 105 + * multiple parents. It is optional (and unnecessary) for clocks 106 + * with 0 or 1 parents. 106 107 * 107 108 * @set_rate: Change the rate of this clock. The requested rate is specified 108 109 * by the second argument, which should typically be the return 109 110 * of .round_rate call. The third argument gives the parent rate 110 111 * which is likely helpful for most .set_rate implementation. 111 112 * Returns 0 on success, -EERROR otherwise. 112 - * 113 - * @recalc_accuracy: Recalculate the accuracy of this clock. The clock accuracy 114 - * is expressed in ppb (parts per billion). The parent accuracy is 115 - * an input parameter. 116 - * Returns the calculated accuracy. Optional - if this op is not 117 - * set then clock accuracy will be initialized to parent accuracy 118 - * or 0 (perfect clock) if clock has no parent. 119 113 * 120 114 * @set_rate_and_parent: Change the rate and the parent of this clock. The 121 115 * requested rate is specified by the second argument, which ··· 121 127 * for clocks that can tolerate switching the rate and the parent 122 128 * separately via calls to .set_parent and .set_rate. 123 129 * Returns 0 on success, -EERROR otherwise. 130 + * 131 + * @recalc_accuracy: Recalculate the accuracy of this clock. The clock accuracy 132 + * is expressed in ppb (parts per billion). The parent accuracy is 133 + * an input parameter. 134 + * Returns the calculated accuracy. Optional - if this op is not 135 + * set then clock accuracy will be initialized to parent accuracy 136 + * or 0 (perfect clock) if clock has no parent. 137 + * 138 + * @init: Perform platform-specific initialization magic. 139 + * This is not not used by any of the basic clock types. 140 + * Please consider other ways of solving initialization problems 141 + * before using this callback, as its use is discouraged. 124 142 * 125 143 * @debug_init: Set up type-specific debugfs entries for this clock. This 126 144 * is called once, after the debugfs directory entry for this ··· 163 157 void (*disable_unused)(struct clk_hw *hw); 164 158 unsigned long (*recalc_rate)(struct clk_hw *hw, 165 159 unsigned long parent_rate); 166 - long (*round_rate)(struct clk_hw *hw, unsigned long, 167 - unsigned long *); 160 + long (*round_rate)(struct clk_hw *hw, unsigned long rate, 161 + unsigned long *parent_rate); 168 162 long (*determine_rate)(struct clk_hw *hw, unsigned long rate, 169 163 unsigned long *best_parent_rate, 170 164 struct clk **best_parent_clk); 171 165 int (*set_parent)(struct clk_hw *hw, u8 index); 172 166 u8 (*get_parent)(struct clk_hw *hw); 173 - int (*set_rate)(struct clk_hw *hw, unsigned long, 174 - unsigned long); 167 + int (*set_rate)(struct clk_hw *hw, unsigned long rate, 168 + unsigned long parent_rate); 175 169 int (*set_rate_and_parent)(struct clk_hw *hw, 176 170 unsigned long rate, 177 171 unsigned long parent_rate, u8 index); ··· 260 254 * 261 255 * Flags: 262 256 * CLK_GATE_SET_TO_DISABLE - by default this clock sets the bit at bit_idx to 263 - * enable the clock. Setting this flag does the opposite: setting the bit 264 - * disable the clock and clearing it enables the clock 257 + * enable the clock. Setting this flag does the opposite: setting the bit 258 + * disable the clock and clearing it enables the clock 265 259 * CLK_GATE_HIWORD_MASK - The gate settings are only in lower 16-bit 266 - * of this register, and mask of gate bits are in higher 16-bit of this 267 - * register. While setting the gate bits, higher 16-bit should also be 268 - * updated to indicate changing gate bits. 260 + * of this register, and mask of gate bits are in higher 16-bit of this 261 + * register. While setting the gate bits, higher 16-bit should also be 262 + * updated to indicate changing gate bits. 269 263 */ 270 264 struct clk_gate { 271 265 struct clk_hw hw; ··· 304 298 * 305 299 * Flags: 306 300 * CLK_DIVIDER_ONE_BASED - by default the divisor is the value read from the 307 - * register plus one. If CLK_DIVIDER_ONE_BASED is set then the divider is 308 - * the raw value read from the register, with the value of zero considered 301 + * register plus one. If CLK_DIVIDER_ONE_BASED is set then the divider is 302 + * the raw value read from the register, with the value of zero considered 309 303 * invalid, unless CLK_DIVIDER_ALLOW_ZERO is set. 310 304 * CLK_DIVIDER_POWER_OF_TWO - clock divisor is 2 raised to the value read from 311 - * the hardware register 305 + * the hardware register 312 306 * CLK_DIVIDER_ALLOW_ZERO - Allow zero divisors. For dividers which have 313 307 * CLK_DIVIDER_ONE_BASED set, it is possible to end up with a zero divisor. 314 308 * Some hardware implementations gracefully handle this case and allow a 315 309 * zero divisor by not modifying their input clock 316 310 * (divide by one / bypass). 317 311 * CLK_DIVIDER_HIWORD_MASK - The divider settings are only in lower 16-bit 318 - * of this register, and mask of divider bits are in higher 16-bit of this 319 - * register. While setting the divider bits, higher 16-bit should also be 320 - * updated to indicate changing divider bits. 312 + * of this register, and mask of divider bits are in higher 16-bit of this 313 + * register. While setting the divider bits, higher 16-bit should also be 314 + * updated to indicate changing divider bits. 315 + * CLK_DIVIDER_ROUND_CLOSEST - Makes the best calculated divider to be rounded 316 + * to the closest integer instead of the up one. 317 + * CLK_DIVIDER_READ_ONLY - The divider settings are preconfigured and should 318 + * not be changed by the clock framework. 321 319 */ 322 320 struct clk_divider { 323 321 struct clk_hw hw; ··· 337 327 #define CLK_DIVIDER_POWER_OF_TWO BIT(1) 338 328 #define CLK_DIVIDER_ALLOW_ZERO BIT(2) 339 329 #define CLK_DIVIDER_HIWORD_MASK BIT(3) 330 + #define CLK_DIVIDER_ROUND_CLOSEST BIT(4) 331 + #define CLK_DIVIDER_READ_ONLY BIT(5) 340 332 341 333 extern const struct clk_ops clk_divider_ops; 334 + extern const struct clk_ops clk_divider_ro_ops; 342 335 struct clk *clk_register_divider(struct device *dev, const char *name, 343 336 const char *parent_name, unsigned long flags, 344 337 void __iomem *reg, u8 shift, u8 width, ··· 369 356 * CLK_MUX_INDEX_ONE - register index starts at 1, not 0 370 357 * CLK_MUX_INDEX_BIT - register index is a single bit (power of two) 371 358 * CLK_MUX_HIWORD_MASK - The mux settings are only in lower 16-bit of this 372 - * register, and mask of mux bits are in higher 16-bit of this register. 373 - * While setting the mux bits, higher 16-bit should also be updated to 374 - * indicate changing mux bits. 359 + * register, and mask of mux bits are in higher 16-bit of this register. 360 + * While setting the mux bits, higher 16-bit should also be updated to 361 + * indicate changing mux bits. 375 362 */ 376 363 struct clk_mux { 377 364 struct clk_hw hw;
+3
include/linux/clk/shmobile.h
··· 1 1 /* 2 2 * Copyright 2013 Ideas On Board SPRL 3 + * Copyright 2013, 2014 Horms Solutions Ltd. 3 4 * 4 5 * Contact: Laurent Pinchart <laurent.pinchart@ideasonboard.com> 6 + * Contact: Simon Horman <horms@verge.net.au> 5 7 * 6 8 * This program is free software; you can redistribute it and/or modify 7 9 * it under the terms of the GNU General Public License as published by ··· 16 14 17 15 #include <linux/types.h> 18 16 17 + void r8a7779_clocks_init(u32 mode); 19 18 void rcar_gen2_clocks_init(u32 mode); 20 19 21 20 #endif
+22
include/linux/clk/sunxi.h
··· 1 + /* 2 + * Copyright 2013 - Hans de Goede <hdegoede@redhat.com> 3 + * 4 + * This program is free software; you can redistribute it and/or modify 5 + * it under the terms of the GNU General Public License as published by 6 + * the Free Software Foundation; either version 2 of the License, or 7 + * (at your option) any later version. 8 + * 9 + * This program is distributed in the hope that it will be useful, 10 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 + * GNU General Public License for more details. 13 + */ 14 + 15 + #ifndef __LINUX_CLK_SUNXI_H_ 16 + #define __LINUX_CLK_SUNXI_H_ 17 + 18 + #include <linux/clk.h> 19 + 20 + void clk_sunxi_mmc_phase_control(struct clk *clk, u8 sample, u8 output); 21 + 22 + #endif