diff options
41 files changed, 3025 insertions, 236 deletions
diff --git a/Documentation/devicetree/bindings/clock/marvell,mmp2.txt b/Documentation/devicetree/bindings/clock/marvell,mmp2.txt new file mode 100644 index 000000000000..af376a01f2b7 --- /dev/null +++ b/Documentation/devicetree/bindings/clock/marvell,mmp2.txt | |||
@@ -0,0 +1,21 @@ | |||
1 | * Marvell MMP2 Clock Controller | ||
2 | |||
3 | The MMP2 clock subsystem generates and supplies clock to various | ||
4 | controllers within the MMP2 SoC. | ||
5 | |||
6 | Required Properties: | ||
7 | |||
8 | - compatible: should be one of the following. | ||
9 | - "marvell,mmp2-clock" - controller compatible with MMP2 SoC. | ||
10 | |||
11 | - reg: physical base address of the clock subsystem and length of memory mapped | ||
12 | region. There are 3 places in SOC has clock control logic: | ||
13 | "mpmu", "apmu", "apbc". So three reg spaces need to be defined. | ||
14 | |||
15 | - #clock-cells: should be 1. | ||
16 | - #reset-cells: should be 1. | ||
17 | |||
18 | Each clock is assigned an identifier and client nodes use this identifier | ||
19 | to specify the clock which they consume. | ||
20 | |||
21 | All these identifier could be found in <dt-bindings/clock/marvell-mmp2.h>. | ||
diff --git a/Documentation/devicetree/bindings/clock/marvell,pxa168.txt b/Documentation/devicetree/bindings/clock/marvell,pxa168.txt new file mode 100644 index 000000000000..c62eb1d173a6 --- /dev/null +++ b/Documentation/devicetree/bindings/clock/marvell,pxa168.txt | |||
@@ -0,0 +1,21 @@ | |||
1 | * Marvell PXA168 Clock Controller | ||
2 | |||
3 | The PXA168 clock subsystem generates and supplies clock to various | ||
4 | controllers within the PXA168 SoC. | ||
5 | |||
6 | Required Properties: | ||
7 | |||
8 | - compatible: should be one of the following. | ||
9 | - "marvell,pxa168-clock" - controller compatible with PXA168 SoC. | ||
10 | |||
11 | - reg: physical base address of the clock subsystem and length of memory mapped | ||
12 | region. There are 3 places in SOC has clock control logic: | ||
13 | "mpmu", "apmu", "apbc". So three reg spaces need to be defined. | ||
14 | |||
15 | - #clock-cells: should be 1. | ||
16 | - #reset-cells: should be 1. | ||
17 | |||
18 | Each clock is assigned an identifier and client nodes use this identifier | ||
19 | to specify the clock which they consume. | ||
20 | |||
21 | All these identifier could be found in <dt-bindings/clock/marvell,pxa168.h>. | ||
diff --git a/Documentation/devicetree/bindings/clock/marvell,pxa910.txt b/Documentation/devicetree/bindings/clock/marvell,pxa910.txt new file mode 100644 index 000000000000..d9f41f3c03a0 --- /dev/null +++ b/Documentation/devicetree/bindings/clock/marvell,pxa910.txt | |||
@@ -0,0 +1,21 @@ | |||
1 | * Marvell PXA910 Clock Controller | ||
2 | |||
3 | The PXA910 clock subsystem generates and supplies clock to various | ||
4 | controllers within the PXA910 SoC. | ||
5 | |||
6 | Required Properties: | ||
7 | |||
8 | - compatible: should be one of the following. | ||
9 | - "marvell,pxa910-clock" - controller compatible with PXA910 SoC. | ||
10 | |||
11 | - reg: physical base address of the clock subsystem and length of memory mapped | ||
12 | region. There are 4 places in SOC has clock control logic: | ||
13 | "mpmu", "apmu", "apbc", "apbcp". So four reg spaces need to be defined. | ||
14 | |||
15 | - #clock-cells: should be 1. | ||
16 | - #reset-cells: should be 1. | ||
17 | |||
18 | Each clock is assigned an identifier and client nodes use this identifier | ||
19 | to specify the clock which they consume. | ||
20 | |||
21 | All these identifier could be found in <dt-bindings/clock/marvell-pxa910.h>. | ||
diff --git a/MAINTAINERS b/MAINTAINERS index ea4d0058fd1b..924499202dac 100644 --- a/MAINTAINERS +++ b/MAINTAINERS | |||
@@ -2491,8 +2491,9 @@ F: include/uapi/linux/coda*.h | |||
2491 | 2491 | ||
2492 | COMMON CLK FRAMEWORK | 2492 | COMMON CLK FRAMEWORK |
2493 | M: Mike Turquette <mturquette@linaro.org> | 2493 | M: Mike Turquette <mturquette@linaro.org> |
2494 | M: Stephen Boyd <sboyd@codeaurora.org> | ||
2494 | L: linux-kernel@vger.kernel.org | 2495 | L: linux-kernel@vger.kernel.org |
2495 | T: git git://git.linaro.org/people/mturquette/linux.git | 2496 | T: git git://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git |
2496 | S: Maintained | 2497 | S: Maintained |
2497 | F: drivers/clk/ | 2498 | F: drivers/clk/ |
2498 | X: drivers/clk/clkdev.c | 2499 | X: drivers/clk/clkdev.c |
diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile index 38c89cafa1ab..5b31c3f6d8e5 100644 --- a/arch/arm/boot/dts/Makefile +++ b/arch/arm/boot/dts/Makefile | |||
@@ -164,6 +164,9 @@ dtb-$(CONFIG_MACH_KIRKWOOD) += kirkwood-b3.dtb \ | |||
164 | dtb-$(CONFIG_ARCH_LPC32XX) += ea3250.dtb phy3250.dtb | 164 | dtb-$(CONFIG_ARCH_LPC32XX) += ea3250.dtb phy3250.dtb |
165 | dtb-$(CONFIG_ARCH_MARCO) += marco-evb.dtb | 165 | dtb-$(CONFIG_ARCH_MARCO) += marco-evb.dtb |
166 | dtb-$(CONFIG_MACH_MESON6) += meson6-atv1200.dtb | 166 | dtb-$(CONFIG_MACH_MESON6) += meson6-atv1200.dtb |
167 | dtb-$(CONFIG_ARCH_MMP) += pxa168-aspenite.dtb \ | ||
168 | pxa910-dkb.dtb \ | ||
169 | mmp2-brownstone.dtb | ||
167 | dtb-$(CONFIG_ARCH_MOXART) += moxart-uc7112lx.dtb | 170 | dtb-$(CONFIG_ARCH_MOXART) += moxart-uc7112lx.dtb |
168 | dtb-$(CONFIG_ARCH_MXC) += \ | 171 | dtb-$(CONFIG_ARCH_MXC) += \ |
169 | imx1-ads.dtb \ | 172 | imx1-ads.dtb \ |
diff --git a/arch/arm/boot/dts/mmp2-brownstone.dts b/arch/arm/boot/dts/mmp2-brownstone.dts index 7f70a39459f6..350208c5e1ed 100644 --- a/arch/arm/boot/dts/mmp2-brownstone.dts +++ b/arch/arm/boot/dts/mmp2-brownstone.dts | |||
@@ -8,7 +8,7 @@ | |||
8 | */ | 8 | */ |
9 | 9 | ||
10 | /dts-v1/; | 10 | /dts-v1/; |
11 | /include/ "mmp2.dtsi" | 11 | #include "mmp2.dtsi" |
12 | 12 | ||
13 | / { | 13 | / { |
14 | model = "Marvell MMP2 Brownstone Development Board"; | 14 | model = "Marvell MMP2 Brownstone Development Board"; |
diff --git a/arch/arm/boot/dts/mmp2.dtsi b/arch/arm/boot/dts/mmp2.dtsi index 4e8b08c628c7..766bbb8495b6 100644 --- a/arch/arm/boot/dts/mmp2.dtsi +++ b/arch/arm/boot/dts/mmp2.dtsi | |||
@@ -7,7 +7,8 @@ | |||
7 | * publishhed by the Free Software Foundation. | 7 | * publishhed by the Free Software Foundation. |
8 | */ | 8 | */ |
9 | 9 | ||
10 | /include/ "skeleton.dtsi" | 10 | #include "skeleton.dtsi" |
11 | #include <dt-bindings/clock/marvell,mmp2.h> | ||
11 | 12 | ||
12 | / { | 13 | / { |
13 | aliases { | 14 | aliases { |
@@ -135,6 +136,8 @@ | |||
135 | compatible = "mrvl,mmp-uart"; | 136 | compatible = "mrvl,mmp-uart"; |
136 | reg = <0xd4030000 0x1000>; | 137 | reg = <0xd4030000 0x1000>; |
137 | interrupts = <27>; | 138 | interrupts = <27>; |
139 | clocks = <&soc_clocks MMP2_CLK_UART0>; | ||
140 | resets = <&soc_clocks MMP2_CLK_UART0>; | ||
138 | status = "disabled"; | 141 | status = "disabled"; |
139 | }; | 142 | }; |
140 | 143 | ||
@@ -142,6 +145,8 @@ | |||
142 | compatible = "mrvl,mmp-uart"; | 145 | compatible = "mrvl,mmp-uart"; |
143 | reg = <0xd4017000 0x1000>; | 146 | reg = <0xd4017000 0x1000>; |
144 | interrupts = <28>; | 147 | interrupts = <28>; |
148 | clocks = <&soc_clocks MMP2_CLK_UART1>; | ||
149 | resets = <&soc_clocks MMP2_CLK_UART1>; | ||
145 | status = "disabled"; | 150 | status = "disabled"; |
146 | }; | 151 | }; |
147 | 152 | ||
@@ -149,6 +154,8 @@ | |||
149 | compatible = "mrvl,mmp-uart"; | 154 | compatible = "mrvl,mmp-uart"; |
150 | reg = <0xd4018000 0x1000>; | 155 | reg = <0xd4018000 0x1000>; |
151 | interrupts = <24>; | 156 | interrupts = <24>; |
157 | clocks = <&soc_clocks MMP2_CLK_UART2>; | ||
158 | resets = <&soc_clocks MMP2_CLK_UART2>; | ||
152 | status = "disabled"; | 159 | status = "disabled"; |
153 | }; | 160 | }; |
154 | 161 | ||
@@ -156,6 +163,8 @@ | |||
156 | compatible = "mrvl,mmp-uart"; | 163 | compatible = "mrvl,mmp-uart"; |
157 | reg = <0xd4016000 0x1000>; | 164 | reg = <0xd4016000 0x1000>; |
158 | interrupts = <46>; | 165 | interrupts = <46>; |
166 | clocks = <&soc_clocks MMP2_CLK_UART3>; | ||
167 | resets = <&soc_clocks MMP2_CLK_UART3>; | ||
159 | status = "disabled"; | 168 | status = "disabled"; |
160 | }; | 169 | }; |
161 | 170 | ||
@@ -168,6 +177,8 @@ | |||
168 | #gpio-cells = <2>; | 177 | #gpio-cells = <2>; |
169 | interrupts = <49>; | 178 | interrupts = <49>; |
170 | interrupt-names = "gpio_mux"; | 179 | interrupt-names = "gpio_mux"; |
180 | clocks = <&soc_clocks MMP2_CLK_GPIO>; | ||
181 | resets = <&soc_clocks MMP2_CLK_GPIO>; | ||
171 | interrupt-controller; | 182 | interrupt-controller; |
172 | #interrupt-cells = <1>; | 183 | #interrupt-cells = <1>; |
173 | ranges; | 184 | ranges; |
@@ -201,6 +212,8 @@ | |||
201 | compatible = "mrvl,mmp-twsi"; | 212 | compatible = "mrvl,mmp-twsi"; |
202 | reg = <0xd4011000 0x1000>; | 213 | reg = <0xd4011000 0x1000>; |
203 | interrupts = <7>; | 214 | interrupts = <7>; |
215 | clocks = <&soc_clocks MMP2_CLK_TWSI0>; | ||
216 | resets = <&soc_clocks MMP2_CLK_TWSI0>; | ||
204 | #address-cells = <1>; | 217 | #address-cells = <1>; |
205 | #size-cells = <0>; | 218 | #size-cells = <0>; |
206 | mrvl,i2c-fast-mode; | 219 | mrvl,i2c-fast-mode; |
@@ -211,6 +224,8 @@ | |||
211 | compatible = "mrvl,mmp-twsi"; | 224 | compatible = "mrvl,mmp-twsi"; |
212 | reg = <0xd4025000 0x1000>; | 225 | reg = <0xd4025000 0x1000>; |
213 | interrupts = <58>; | 226 | interrupts = <58>; |
227 | clocks = <&soc_clocks MMP2_CLK_TWSI1>; | ||
228 | resets = <&soc_clocks MMP2_CLK_TWSI1>; | ||
214 | status = "disabled"; | 229 | status = "disabled"; |
215 | }; | 230 | }; |
216 | 231 | ||
@@ -220,8 +235,20 @@ | |||
220 | interrupts = <1 0>; | 235 | interrupts = <1 0>; |
221 | interrupt-names = "rtc 1Hz", "rtc alarm"; | 236 | interrupt-names = "rtc 1Hz", "rtc alarm"; |
222 | interrupt-parent = <&intcmux5>; | 237 | interrupt-parent = <&intcmux5>; |
238 | clocks = <&soc_clocks MMP2_CLK_RTC>; | ||
239 | resets = <&soc_clocks MMP2_CLK_RTC>; | ||
223 | status = "disabled"; | 240 | status = "disabled"; |
224 | }; | 241 | }; |
225 | }; | 242 | }; |
243 | |||
244 | soc_clocks: clocks{ | ||
245 | compatible = "marvell,mmp2-clock"; | ||
246 | reg = <0xd4050000 0x1000>, | ||
247 | <0xd4282800 0x400>, | ||
248 | <0xd4015000 0x1000>; | ||
249 | reg-names = "mpmu", "apmu", "apbc"; | ||
250 | #clock-cells = <1>; | ||
251 | #reset-cells = <1>; | ||
252 | }; | ||
226 | }; | 253 | }; |
227 | }; | 254 | }; |
diff --git a/arch/arm/boot/dts/pxa168-aspenite.dts b/arch/arm/boot/dts/pxa168-aspenite.dts index e762facb3fa4..0a988b3fb248 100644 --- a/arch/arm/boot/dts/pxa168-aspenite.dts +++ b/arch/arm/boot/dts/pxa168-aspenite.dts | |||
@@ -8,7 +8,7 @@ | |||
8 | */ | 8 | */ |
9 | 9 | ||
10 | /dts-v1/; | 10 | /dts-v1/; |
11 | /include/ "pxa168.dtsi" | 11 | #include "pxa168.dtsi" |
12 | 12 | ||
13 | / { | 13 | / { |
14 | model = "Marvell PXA168 Aspenite Development Board"; | 14 | model = "Marvell PXA168 Aspenite Development Board"; |
diff --git a/arch/arm/boot/dts/pxa168.dtsi b/arch/arm/boot/dts/pxa168.dtsi index 975dad21ac38..b899e25cbb1b 100644 --- a/arch/arm/boot/dts/pxa168.dtsi +++ b/arch/arm/boot/dts/pxa168.dtsi | |||
@@ -7,7 +7,8 @@ | |||
7 | * publishhed by the Free Software Foundation. | 7 | * publishhed by the Free Software Foundation. |
8 | */ | 8 | */ |
9 | 9 | ||
10 | /include/ "skeleton.dtsi" | 10 | #include "skeleton.dtsi" |
11 | #include <dt-bindings/clock/marvell,pxa168.h> | ||
11 | 12 | ||
12 | / { | 13 | / { |
13 | aliases { | 14 | aliases { |
@@ -59,6 +60,8 @@ | |||
59 | compatible = "mrvl,mmp-uart"; | 60 | compatible = "mrvl,mmp-uart"; |
60 | reg = <0xd4017000 0x1000>; | 61 | reg = <0xd4017000 0x1000>; |
61 | interrupts = <27>; | 62 | interrupts = <27>; |
63 | clocks = <&soc_clocks PXA168_CLK_UART0>; | ||
64 | resets = <&soc_clocks PXA168_CLK_UART0>; | ||
62 | status = "disabled"; | 65 | status = "disabled"; |
63 | }; | 66 | }; |
64 | 67 | ||
@@ -66,6 +69,8 @@ | |||
66 | compatible = "mrvl,mmp-uart"; | 69 | compatible = "mrvl,mmp-uart"; |
67 | reg = <0xd4018000 0x1000>; | 70 | reg = <0xd4018000 0x1000>; |
68 | interrupts = <28>; | 71 | interrupts = <28>; |
72 | clocks = <&soc_clocks PXA168_CLK_UART1>; | ||
73 | resets = <&soc_clocks PXA168_CLK_UART1>; | ||
69 | status = "disabled"; | 74 | status = "disabled"; |
70 | }; | 75 | }; |
71 | 76 | ||
@@ -73,6 +78,8 @@ | |||
73 | compatible = "mrvl,mmp-uart"; | 78 | compatible = "mrvl,mmp-uart"; |
74 | reg = <0xd4026000 0x1000>; | 79 | reg = <0xd4026000 0x1000>; |
75 | interrupts = <29>; | 80 | interrupts = <29>; |
81 | clocks = <&soc_clocks PXA168_CLK_UART2>; | ||
82 | resets = <&soc_clocks PXA168_CLK_UART2>; | ||
76 | status = "disabled"; | 83 | status = "disabled"; |
77 | }; | 84 | }; |
78 | 85 | ||
@@ -84,6 +91,8 @@ | |||
84 | gpio-controller; | 91 | gpio-controller; |
85 | #gpio-cells = <2>; | 92 | #gpio-cells = <2>; |
86 | interrupts = <49>; | 93 | interrupts = <49>; |
94 | clocks = <&soc_clocks PXA168_CLK_GPIO>; | ||
95 | resets = <&soc_clocks PXA168_CLK_GPIO>; | ||
87 | interrupt-names = "gpio_mux"; | 96 | interrupt-names = "gpio_mux"; |
88 | interrupt-controller; | 97 | interrupt-controller; |
89 | #interrupt-cells = <1>; | 98 | #interrupt-cells = <1>; |
@@ -110,6 +119,8 @@ | |||
110 | compatible = "mrvl,mmp-twsi"; | 119 | compatible = "mrvl,mmp-twsi"; |
111 | reg = <0xd4011000 0x1000>; | 120 | reg = <0xd4011000 0x1000>; |
112 | interrupts = <7>; | 121 | interrupts = <7>; |
122 | clocks = <&soc_clocks PXA168_CLK_TWSI0>; | ||
123 | resets = <&soc_clocks PXA168_CLK_TWSI0>; | ||
113 | mrvl,i2c-fast-mode; | 124 | mrvl,i2c-fast-mode; |
114 | status = "disabled"; | 125 | status = "disabled"; |
115 | }; | 126 | }; |
@@ -118,6 +129,8 @@ | |||
118 | compatible = "mrvl,mmp-twsi"; | 129 | compatible = "mrvl,mmp-twsi"; |
119 | reg = <0xd4025000 0x1000>; | 130 | reg = <0xd4025000 0x1000>; |
120 | interrupts = <58>; | 131 | interrupts = <58>; |
132 | clocks = <&soc_clocks PXA168_CLK_TWSI1>; | ||
133 | resets = <&soc_clocks PXA168_CLK_TWSI1>; | ||
121 | status = "disabled"; | 134 | status = "disabled"; |
122 | }; | 135 | }; |
123 | 136 | ||
@@ -126,8 +139,20 @@ | |||
126 | reg = <0xd4010000 0x1000>; | 139 | reg = <0xd4010000 0x1000>; |
127 | interrupts = <5 6>; | 140 | interrupts = <5 6>; |
128 | interrupt-names = "rtc 1Hz", "rtc alarm"; | 141 | interrupt-names = "rtc 1Hz", "rtc alarm"; |
142 | clocks = <&soc_clocks PXA168_CLK_RTC>; | ||
143 | resets = <&soc_clocks PXA168_CLK_RTC>; | ||
129 | status = "disabled"; | 144 | status = "disabled"; |
130 | }; | 145 | }; |
131 | }; | 146 | }; |
147 | |||
148 | soc_clocks: clocks{ | ||
149 | compatible = "marvell,pxa168-clock"; | ||
150 | reg = <0xd4050000 0x1000>, | ||
151 | <0xd4282800 0x400>, | ||
152 | <0xd4015000 0x1000>; | ||
153 | reg-names = "mpmu", "apmu", "apbc"; | ||
154 | #clock-cells = <1>; | ||
155 | #reset-cells = <1>; | ||
156 | }; | ||
132 | }; | 157 | }; |
133 | }; | 158 | }; |
diff --git a/arch/arm/boot/dts/pxa910-dkb.dts b/arch/arm/boot/dts/pxa910-dkb.dts index 595492aa5053..c82f2810ec73 100644 --- a/arch/arm/boot/dts/pxa910-dkb.dts +++ b/arch/arm/boot/dts/pxa910-dkb.dts | |||
@@ -8,7 +8,7 @@ | |||
8 | */ | 8 | */ |
9 | 9 | ||
10 | /dts-v1/; | 10 | /dts-v1/; |
11 | /include/ "pxa910.dtsi" | 11 | #include "pxa910.dtsi" |
12 | 12 | ||
13 | / { | 13 | / { |
14 | model = "Marvell PXA910 DKB Development Board"; | 14 | model = "Marvell PXA910 DKB Development Board"; |
diff --git a/arch/arm/boot/dts/pxa910.dtsi b/arch/arm/boot/dts/pxa910.dtsi index 0247c622f580..0868f6729be1 100644 --- a/arch/arm/boot/dts/pxa910.dtsi +++ b/arch/arm/boot/dts/pxa910.dtsi | |||
@@ -7,7 +7,8 @@ | |||
7 | * publishhed by the Free Software Foundation. | 7 | * publishhed by the Free Software Foundation. |
8 | */ | 8 | */ |
9 | 9 | ||
10 | /include/ "skeleton.dtsi" | 10 | #include "skeleton.dtsi" |
11 | #include <dt-bindings/clock/marvell,pxa910.h> | ||
11 | 12 | ||
12 | / { | 13 | / { |
13 | aliases { | 14 | aliases { |
@@ -71,6 +72,8 @@ | |||
71 | compatible = "mrvl,mmp-uart"; | 72 | compatible = "mrvl,mmp-uart"; |
72 | reg = <0xd4017000 0x1000>; | 73 | reg = <0xd4017000 0x1000>; |
73 | interrupts = <27>; | 74 | interrupts = <27>; |
75 | clocks = <&soc_clocks PXA910_CLK_UART0>; | ||
76 | resets = <&soc_clocks PXA910_CLK_UART0>; | ||
74 | status = "disabled"; | 77 | status = "disabled"; |
75 | }; | 78 | }; |
76 | 79 | ||
@@ -78,6 +81,8 @@ | |||
78 | compatible = "mrvl,mmp-uart"; | 81 | compatible = "mrvl,mmp-uart"; |
79 | reg = <0xd4018000 0x1000>; | 82 | reg = <0xd4018000 0x1000>; |
80 | interrupts = <28>; | 83 | interrupts = <28>; |
84 | clocks = <&soc_clocks PXA910_CLK_UART1>; | ||
85 | resets = <&soc_clocks PXA910_CLK_UART1>; | ||
81 | status = "disabled"; | 86 | status = "disabled"; |
82 | }; | 87 | }; |
83 | 88 | ||
@@ -85,6 +90,8 @@ | |||
85 | compatible = "mrvl,mmp-uart"; | 90 | compatible = "mrvl,mmp-uart"; |
86 | reg = <0xd4036000 0x1000>; | 91 | reg = <0xd4036000 0x1000>; |
87 | interrupts = <59>; | 92 | interrupts = <59>; |
93 | clocks = <&soc_clocks PXA910_CLK_UART2>; | ||
94 | resets = <&soc_clocks PXA910_CLK_UART2>; | ||
88 | status = "disabled"; | 95 | status = "disabled"; |
89 | }; | 96 | }; |
90 | 97 | ||
@@ -97,6 +104,8 @@ | |||
97 | #gpio-cells = <2>; | 104 | #gpio-cells = <2>; |
98 | interrupts = <49>; | 105 | interrupts = <49>; |
99 | interrupt-names = "gpio_mux"; | 106 | interrupt-names = "gpio_mux"; |
107 | clocks = <&soc_clocks PXA910_CLK_GPIO>; | ||
108 | resets = <&soc_clocks PXA910_CLK_GPIO>; | ||
100 | interrupt-controller; | 109 | interrupt-controller; |
101 | #interrupt-cells = <1>; | 110 | #interrupt-cells = <1>; |
102 | ranges; | 111 | ranges; |
@@ -124,6 +133,8 @@ | |||
124 | #size-cells = <0>; | 133 | #size-cells = <0>; |
125 | reg = <0xd4011000 0x1000>; | 134 | reg = <0xd4011000 0x1000>; |
126 | interrupts = <7>; | 135 | interrupts = <7>; |
136 | clocks = <&soc_clocks PXA910_CLK_TWSI0>; | ||
137 | resets = <&soc_clocks PXA910_CLK_TWSI0>; | ||
127 | mrvl,i2c-fast-mode; | 138 | mrvl,i2c-fast-mode; |
128 | status = "disabled"; | 139 | status = "disabled"; |
129 | }; | 140 | }; |
@@ -134,6 +145,8 @@ | |||
134 | #size-cells = <0>; | 145 | #size-cells = <0>; |
135 | reg = <0xd4037000 0x1000>; | 146 | reg = <0xd4037000 0x1000>; |
136 | interrupts = <54>; | 147 | interrupts = <54>; |
148 | clocks = <&soc_clocks PXA910_CLK_TWSI1>; | ||
149 | resets = <&soc_clocks PXA910_CLK_TWSI1>; | ||
137 | status = "disabled"; | 150 | status = "disabled"; |
138 | }; | 151 | }; |
139 | 152 | ||
@@ -142,8 +155,21 @@ | |||
142 | reg = <0xd4010000 0x1000>; | 155 | reg = <0xd4010000 0x1000>; |
143 | interrupts = <5 6>; | 156 | interrupts = <5 6>; |
144 | interrupt-names = "rtc 1Hz", "rtc alarm"; | 157 | interrupt-names = "rtc 1Hz", "rtc alarm"; |
158 | clocks = <&soc_clocks PXA910_CLK_RTC>; | ||
159 | resets = <&soc_clocks PXA910_CLK_RTC>; | ||
145 | status = "disabled"; | 160 | status = "disabled"; |
146 | }; | 161 | }; |
147 | }; | 162 | }; |
163 | |||
164 | soc_clocks: clocks{ | ||
165 | compatible = "marvell,pxa910-clock"; | ||
166 | reg = <0xd4050000 0x1000>, | ||
167 | <0xd4282800 0x400>, | ||
168 | <0xd4015000 0x1000>, | ||
169 | <0xd403b000 0x1000>; | ||
170 | reg-names = "mpmu", "apmu", "apbc", "apbcp"; | ||
171 | #clock-cells = <1>; | ||
172 | #reset-cells = <1>; | ||
173 | }; | ||
148 | }; | 174 | }; |
149 | }; | 175 | }; |
diff --git a/arch/arm/mach-mmp/Kconfig b/arch/arm/mach-mmp/Kconfig index ebdba87b9671..fdbfadf00c84 100644 --- a/arch/arm/mach-mmp/Kconfig +++ b/arch/arm/mach-mmp/Kconfig | |||
@@ -86,11 +86,12 @@ config MACH_GPLUGD | |||
86 | 86 | ||
87 | config MACH_MMP_DT | 87 | config MACH_MMP_DT |
88 | bool "Support MMP (ARMv5) platforms from device tree" | 88 | bool "Support MMP (ARMv5) platforms from device tree" |
89 | select CPU_PXA168 | ||
90 | select CPU_PXA910 | ||
91 | select USE_OF | 89 | select USE_OF |
92 | select PINCTRL | 90 | select PINCTRL |
93 | select PINCTRL_SINGLE | 91 | select PINCTRL_SINGLE |
92 | select COMMON_CLK | ||
93 | select ARCH_HAS_RESET_CONTROLLER | ||
94 | select CPU_MOHAWK | ||
94 | help | 95 | help |
95 | Include support for Marvell MMP2 based platforms using | 96 | Include support for Marvell MMP2 based platforms using |
96 | the device tree. Needn't select any other machine while | 97 | the device tree. Needn't select any other machine while |
@@ -99,10 +100,12 @@ config MACH_MMP_DT | |||
99 | config MACH_MMP2_DT | 100 | config MACH_MMP2_DT |
100 | bool "Support MMP2 (ARMv7) platforms from device tree" | 101 | bool "Support MMP2 (ARMv7) platforms from device tree" |
101 | depends on !CPU_MOHAWK | 102 | depends on !CPU_MOHAWK |
102 | select CPU_MMP2 | ||
103 | select USE_OF | 103 | select USE_OF |
104 | select PINCTRL | 104 | select PINCTRL |
105 | select PINCTRL_SINGLE | 105 | select PINCTRL_SINGLE |
106 | select COMMON_CLK | ||
107 | select ARCH_HAS_RESET_CONTROLLER | ||
108 | select CPU_PJ4 | ||
106 | help | 109 | help |
107 | Include support for Marvell MMP2 based platforms using | 110 | Include support for Marvell MMP2 based platforms using |
108 | the device tree. | 111 | the device tree. |
@@ -111,21 +114,18 @@ endmenu | |||
111 | 114 | ||
112 | config CPU_PXA168 | 115 | config CPU_PXA168 |
113 | bool | 116 | bool |
114 | select COMMON_CLK | ||
115 | select CPU_MOHAWK | 117 | select CPU_MOHAWK |
116 | help | 118 | help |
117 | Select code specific to PXA168 | 119 | Select code specific to PXA168 |
118 | 120 | ||
119 | config CPU_PXA910 | 121 | config CPU_PXA910 |
120 | bool | 122 | bool |
121 | select COMMON_CLK | ||
122 | select CPU_MOHAWK | 123 | select CPU_MOHAWK |
123 | help | 124 | help |
124 | Select code specific to PXA910 | 125 | Select code specific to PXA910 |
125 | 126 | ||
126 | config CPU_MMP2 | 127 | config CPU_MMP2 |
127 | bool | 128 | bool |
128 | select COMMON_CLK | ||
129 | select CPU_PJ4 | 129 | select CPU_PJ4 |
130 | help | 130 | help |
131 | Select code specific to MMP2. MMP2 is ARMv7 compatible. | 131 | Select code specific to MMP2. MMP2 is ARMv7 compatible. |
diff --git a/arch/arm/mach-mmp/mmp-dt.c b/arch/arm/mach-mmp/mmp-dt.c index cca529ceecb7..b2296c9309b8 100644 --- a/arch/arm/mach-mmp/mmp-dt.c +++ b/arch/arm/mach-mmp/mmp-dt.c | |||
@@ -11,63 +11,42 @@ | |||
11 | 11 | ||
12 | #include <linux/irqchip.h> | 12 | #include <linux/irqchip.h> |
13 | #include <linux/of_platform.h> | 13 | #include <linux/of_platform.h> |
14 | #include <linux/clk-provider.h> | ||
14 | #include <asm/mach/arch.h> | 15 | #include <asm/mach/arch.h> |
15 | #include <asm/mach/time.h> | 16 | #include <asm/mach/time.h> |
17 | #include <asm/hardware/cache-tauros2.h> | ||
16 | 18 | ||
17 | #include "common.h" | 19 | #include "common.h" |
18 | 20 | ||
19 | extern void __init mmp_dt_init_timer(void); | 21 | extern void __init mmp_dt_init_timer(void); |
20 | 22 | ||
21 | static const struct of_dev_auxdata pxa168_auxdata_lookup[] __initconst = { | 23 | static const char *pxa168_dt_board_compat[] __initdata = { |
22 | OF_DEV_AUXDATA("mrvl,mmp-uart", 0xd4017000, "pxa2xx-uart.0", NULL), | 24 | "mrvl,pxa168-aspenite", |
23 | OF_DEV_AUXDATA("mrvl,mmp-uart", 0xd4018000, "pxa2xx-uart.1", NULL), | 25 | NULL, |
24 | OF_DEV_AUXDATA("mrvl,mmp-uart", 0xd4026000, "pxa2xx-uart.2", NULL), | ||
25 | OF_DEV_AUXDATA("mrvl,mmp-twsi", 0xd4011000, "pxa2xx-i2c.0", NULL), | ||
26 | OF_DEV_AUXDATA("mrvl,mmp-twsi", 0xd4025000, "pxa2xx-i2c.1", NULL), | ||
27 | OF_DEV_AUXDATA("marvell,mmp-gpio", 0xd4019000, "mmp-gpio", NULL), | ||
28 | OF_DEV_AUXDATA("mrvl,mmp-rtc", 0xd4010000, "sa1100-rtc", NULL), | ||
29 | {} | ||
30 | }; | 26 | }; |
31 | 27 | ||
32 | static const struct of_dev_auxdata pxa910_auxdata_lookup[] __initconst = { | 28 | static const char *pxa910_dt_board_compat[] __initdata = { |
33 | OF_DEV_AUXDATA("mrvl,mmp-uart", 0xd4017000, "pxa2xx-uart.0", NULL), | 29 | "mrvl,pxa910-dkb", |
34 | OF_DEV_AUXDATA("mrvl,mmp-uart", 0xd4018000, "pxa2xx-uart.1", NULL), | 30 | NULL, |
35 | OF_DEV_AUXDATA("mrvl,mmp-uart", 0xd4036000, "pxa2xx-uart.2", NULL), | ||
36 | OF_DEV_AUXDATA("mrvl,mmp-twsi", 0xd4011000, "pxa2xx-i2c.0", NULL), | ||
37 | OF_DEV_AUXDATA("mrvl,mmp-twsi", 0xd4037000, "pxa2xx-i2c.1", NULL), | ||
38 | OF_DEV_AUXDATA("marvell,mmp-gpio", 0xd4019000, "mmp-gpio", NULL), | ||
39 | OF_DEV_AUXDATA("mrvl,mmp-rtc", 0xd4010000, "sa1100-rtc", NULL), | ||
40 | {} | ||
41 | }; | 31 | }; |
42 | 32 | ||
43 | static void __init pxa168_dt_init(void) | 33 | static void __init mmp_init_time(void) |
44 | { | ||
45 | of_platform_populate(NULL, of_default_bus_match_table, | ||
46 | pxa168_auxdata_lookup, NULL); | ||
47 | } | ||
48 | |||
49 | static void __init pxa910_dt_init(void) | ||
50 | { | 34 | { |
51 | of_platform_populate(NULL, of_default_bus_match_table, | 35 | #ifdef CONFIG_CACHE_TAUROS2 |
52 | pxa910_auxdata_lookup, NULL); | 36 | tauros2_init(0); |
37 | #endif | ||
38 | mmp_dt_init_timer(); | ||
39 | of_clk_init(NULL); | ||
53 | } | 40 | } |
54 | 41 | ||
55 | static const char *mmp_dt_board_compat[] __initdata = { | ||
56 | "mrvl,pxa168-aspenite", | ||
57 | "mrvl,pxa910-dkb", | ||
58 | NULL, | ||
59 | }; | ||
60 | |||
61 | DT_MACHINE_START(PXA168_DT, "Marvell PXA168 (Device Tree Support)") | 42 | DT_MACHINE_START(PXA168_DT, "Marvell PXA168 (Device Tree Support)") |
62 | .map_io = mmp_map_io, | 43 | .map_io = mmp_map_io, |
63 | .init_time = mmp_dt_init_timer, | 44 | .init_time = mmp_init_time, |
64 | .init_machine = pxa168_dt_init, | 45 | .dt_compat = pxa168_dt_board_compat, |
65 | .dt_compat = mmp_dt_board_compat, | ||
66 | MACHINE_END | 46 | MACHINE_END |
67 | 47 | ||
68 | DT_MACHINE_START(PXA910_DT, "Marvell PXA910 (Device Tree Support)") | 48 | DT_MACHINE_START(PXA910_DT, "Marvell PXA910 (Device Tree Support)") |
69 | .map_io = mmp_map_io, | 49 | .map_io = mmp_map_io, |
70 | .init_time = mmp_dt_init_timer, | 50 | .init_time = mmp_init_time, |
71 | .init_machine = pxa910_dt_init, | 51 | .dt_compat = pxa910_dt_board_compat, |
72 | .dt_compat = mmp_dt_board_compat, | ||
73 | MACHINE_END | 52 | MACHINE_END |
diff --git a/arch/arm/mach-mmp/mmp2-dt.c b/arch/arm/mach-mmp/mmp2-dt.c index 023cb453f157..998c0f533abc 100644 --- a/arch/arm/mach-mmp/mmp2-dt.c +++ b/arch/arm/mach-mmp/mmp2-dt.c | |||
@@ -12,29 +12,22 @@ | |||
12 | #include <linux/io.h> | 12 | #include <linux/io.h> |
13 | #include <linux/irqchip.h> | 13 | #include <linux/irqchip.h> |
14 | #include <linux/of_platform.h> | 14 | #include <linux/of_platform.h> |
15 | #include <linux/clk-provider.h> | ||
15 | #include <asm/mach/arch.h> | 16 | #include <asm/mach/arch.h> |
16 | #include <asm/mach/time.h> | 17 | #include <asm/mach/time.h> |
18 | #include <asm/hardware/cache-tauros2.h> | ||
17 | 19 | ||
18 | #include "common.h" | 20 | #include "common.h" |
19 | 21 | ||
20 | extern void __init mmp_dt_init_timer(void); | 22 | extern void __init mmp_dt_init_timer(void); |
21 | 23 | ||
22 | static const struct of_dev_auxdata mmp2_auxdata_lookup[] __initconst = { | 24 | static void __init mmp_init_time(void) |
23 | OF_DEV_AUXDATA("mrvl,mmp-uart", 0xd4030000, "pxa2xx-uart.0", NULL), | ||
24 | OF_DEV_AUXDATA("mrvl,mmp-uart", 0xd4017000, "pxa2xx-uart.1", NULL), | ||
25 | OF_DEV_AUXDATA("mrvl,mmp-uart", 0xd4018000, "pxa2xx-uart.2", NULL), | ||
26 | OF_DEV_AUXDATA("mrvl,mmp-uart", 0xd4016000, "pxa2xx-uart.3", NULL), | ||
27 | OF_DEV_AUXDATA("mrvl,mmp-twsi", 0xd4011000, "pxa2xx-i2c.0", NULL), | ||
28 | OF_DEV_AUXDATA("mrvl,mmp-twsi", 0xd4025000, "pxa2xx-i2c.1", NULL), | ||
29 | OF_DEV_AUXDATA("marvell,mmp-gpio", 0xd4019000, "mmp2-gpio", NULL), | ||
30 | OF_DEV_AUXDATA("mrvl,mmp-rtc", 0xd4010000, "sa1100-rtc", NULL), | ||
31 | {} | ||
32 | }; | ||
33 | |||
34 | static void __init mmp2_dt_init(void) | ||
35 | { | 25 | { |
36 | of_platform_populate(NULL, of_default_bus_match_table, | 26 | #ifdef CONFIG_CACHE_TAUROS2 |
37 | mmp2_auxdata_lookup, NULL); | 27 | tauros2_init(0); |
28 | #endif | ||
29 | mmp_dt_init_timer(); | ||
30 | of_clk_init(NULL); | ||
38 | } | 31 | } |
39 | 32 | ||
40 | static const char *mmp2_dt_board_compat[] __initdata = { | 33 | static const char *mmp2_dt_board_compat[] __initdata = { |
@@ -44,7 +37,6 @@ static const char *mmp2_dt_board_compat[] __initdata = { | |||
44 | 37 | ||
45 | DT_MACHINE_START(MMP2_DT, "Marvell MMP2 (Device Tree Support)") | 38 | DT_MACHINE_START(MMP2_DT, "Marvell MMP2 (Device Tree Support)") |
46 | .map_io = mmp_map_io, | 39 | .map_io = mmp_map_io, |
47 | .init_time = mmp_dt_init_timer, | 40 | .init_time = mmp_init_time, |
48 | .init_machine = mmp2_dt_init, | ||
49 | .dt_compat = mmp2_dt_board_compat, | 41 | .dt_compat = mmp2_dt_board_compat, |
50 | MACHINE_END | 42 | MACHINE_END |
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 4896ae9e23da..5307225684eb 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c | |||
@@ -1614,7 +1614,7 @@ static struct clk *__clk_init_parent(struct clk *clk) | |||
1614 | 1614 | ||
1615 | if (clk->num_parents == 1) { | 1615 | if (clk->num_parents == 1) { |
1616 | if (IS_ERR_OR_NULL(clk->parent)) | 1616 | if (IS_ERR_OR_NULL(clk->parent)) |
1617 | ret = clk->parent = __clk_lookup(clk->parent_names[0]); | 1617 | clk->parent = __clk_lookup(clk->parent_names[0]); |
1618 | ret = clk->parent; | 1618 | ret = clk->parent; |
1619 | goto out; | 1619 | goto out; |
1620 | } | 1620 | } |
diff --git a/drivers/clk/mmp/Makefile b/drivers/clk/mmp/Makefile index 392d78044ce3..3caaf7cc169c 100644 --- a/drivers/clk/mmp/Makefile +++ b/drivers/clk/mmp/Makefile | |||
@@ -2,7 +2,12 @@ | |||
2 | # Makefile for mmp specific clk | 2 | # Makefile for mmp specific clk |
3 | # | 3 | # |
4 | 4 | ||
5 | obj-y += clk-apbc.o clk-apmu.o clk-frac.o | 5 | obj-y += clk-apbc.o clk-apmu.o clk-frac.o clk-mix.o clk-gate.o clk.o |
6 | |||
7 | obj-$(CONFIG_RESET_CONTROLLER) += reset.o | ||
8 | |||
9 | obj-$(CONFIG_MACH_MMP_DT) += clk-of-pxa168.o clk-of-pxa910.o | ||
10 | obj-$(CONFIG_MACH_MMP2_DT) += clk-of-mmp2.o | ||
6 | 11 | ||
7 | obj-$(CONFIG_CPU_PXA168) += clk-pxa168.o | 12 | obj-$(CONFIG_CPU_PXA168) += clk-pxa168.o |
8 | obj-$(CONFIG_CPU_PXA910) += clk-pxa910.o | 13 | obj-$(CONFIG_CPU_PXA910) += clk-pxa910.o |
diff --git a/drivers/clk/mmp/clk-frac.c b/drivers/clk/mmp/clk-frac.c index 23a56f561812..eeba52c2def6 100644 --- a/drivers/clk/mmp/clk-frac.c +++ b/drivers/clk/mmp/clk-frac.c | |||
@@ -22,19 +22,12 @@ | |||
22 | * numerator/denominator = Fin / (Fout * factor) | 22 | * numerator/denominator = Fin / (Fout * factor) |
23 | */ | 23 | */ |
24 | 24 | ||
25 | #define to_clk_factor(hw) container_of(hw, struct clk_factor, hw) | 25 | #define to_clk_factor(hw) container_of(hw, struct mmp_clk_factor, hw) |
26 | struct clk_factor { | ||
27 | struct clk_hw hw; | ||
28 | void __iomem *base; | ||
29 | struct clk_factor_masks *masks; | ||
30 | struct clk_factor_tbl *ftbl; | ||
31 | unsigned int ftbl_cnt; | ||
32 | }; | ||
33 | 26 | ||
34 | static long clk_factor_round_rate(struct clk_hw *hw, unsigned long drate, | 27 | static long clk_factor_round_rate(struct clk_hw *hw, unsigned long drate, |
35 | unsigned long *prate) | 28 | unsigned long *prate) |
36 | { | 29 | { |
37 | struct clk_factor *factor = to_clk_factor(hw); | 30 | struct mmp_clk_factor *factor = to_clk_factor(hw); |
38 | unsigned long rate = 0, prev_rate; | 31 | unsigned long rate = 0, prev_rate; |
39 | int i; | 32 | int i; |
40 | 33 | ||
@@ -58,8 +51,8 @@ static long clk_factor_round_rate(struct clk_hw *hw, unsigned long drate, | |||
58 | static unsigned long clk_factor_recalc_rate(struct clk_hw *hw, | 51 | static unsigned long clk_factor_recalc_rate(struct clk_hw *hw, |
59 | unsigned long parent_rate) | 52 | unsigned long parent_rate) |
60 | { | 53 | { |
61 | struct clk_factor *factor = to_clk_factor(hw); | 54 | struct mmp_clk_factor *factor = to_clk_factor(hw); |
62 | struct clk_factor_masks *masks = factor->masks; | 55 | struct mmp_clk_factor_masks *masks = factor->masks; |
63 | unsigned int val, num, den; | 56 | unsigned int val, num, den; |
64 | 57 | ||
65 | val = readl_relaxed(factor->base); | 58 | val = readl_relaxed(factor->base); |
@@ -81,11 +74,12 @@ static unsigned long clk_factor_recalc_rate(struct clk_hw *hw, | |||
81 | static int clk_factor_set_rate(struct clk_hw *hw, unsigned long drate, | 74 | static int clk_factor_set_rate(struct clk_hw *hw, unsigned long drate, |
82 | unsigned long prate) | 75 | unsigned long prate) |
83 | { | 76 | { |
84 | struct clk_factor *factor = to_clk_factor(hw); | 77 | struct mmp_clk_factor *factor = to_clk_factor(hw); |
85 | struct clk_factor_masks *masks = factor->masks; | 78 | struct mmp_clk_factor_masks *masks = factor->masks; |
86 | int i; | 79 | int i; |
87 | unsigned long val; | 80 | unsigned long val; |
88 | unsigned long prev_rate, rate = 0; | 81 | unsigned long prev_rate, rate = 0; |
82 | unsigned long flags = 0; | ||
89 | 83 | ||
90 | for (i = 0; i < factor->ftbl_cnt; i++) { | 84 | for (i = 0; i < factor->ftbl_cnt; i++) { |
91 | prev_rate = rate; | 85 | prev_rate = rate; |
@@ -97,6 +91,9 @@ static int clk_factor_set_rate(struct clk_hw *hw, unsigned long drate, | |||
97 | if (i > 0) | 91 | if (i > 0) |
98 | i--; | 92 | i--; |
99 | 93 | ||
94 | if (factor->lock) | ||
95 | spin_lock_irqsave(factor->lock, flags); | ||
96 | |||
100 | val = readl_relaxed(factor->base); | 97 | val = readl_relaxed(factor->base); |
101 | 98 | ||
102 | val &= ~(masks->num_mask << masks->num_shift); | 99 | val &= ~(masks->num_mask << masks->num_shift); |
@@ -107,21 +104,65 @@ static int clk_factor_set_rate(struct clk_hw *hw, unsigned long drate, | |||
107 | 104 | ||
108 | writel_relaxed(val, factor->base); | 105 | writel_relaxed(val, factor->base); |
109 | 106 | ||
107 | if (factor->lock) | ||
108 | spin_unlock_irqrestore(factor->lock, flags); | ||
109 | |||
110 | return 0; | 110 | return 0; |
111 | } | 111 | } |
112 | 112 | ||
113 | void clk_factor_init(struct clk_hw *hw) | ||
114 | { | ||
115 | struct mmp_clk_factor *factor = to_clk_factor(hw); | ||
116 | struct mmp_clk_factor_masks *masks = factor->masks; | ||
117 | u32 val, num, den; | ||
118 | int i; | ||
119 | unsigned long flags = 0; | ||
120 | |||
121 | if (factor->lock) | ||
122 | spin_lock_irqsave(factor->lock, flags); | ||
123 | |||
124 | val = readl(factor->base); | ||
125 | |||
126 | /* calculate numerator */ | ||
127 | num = (val >> masks->num_shift) & masks->num_mask; | ||
128 | |||
129 | /* calculate denominator */ | ||
130 | den = (val >> masks->den_shift) & masks->den_mask; | ||
131 | |||
132 | for (i = 0; i < factor->ftbl_cnt; i++) | ||
133 | if (den == factor->ftbl[i].den && num == factor->ftbl[i].num) | ||
134 | break; | ||
135 | |||
136 | if (i >= factor->ftbl_cnt) { | ||
137 | val &= ~(masks->num_mask << masks->num_shift); | ||
138 | val |= (factor->ftbl[0].num & masks->num_mask) << | ||
139 | masks->num_shift; | ||
140 | |||
141 | val &= ~(masks->den_mask << masks->den_shift); | ||
142 | val |= (factor->ftbl[0].den & masks->den_mask) << | ||
143 | masks->den_shift; | ||
144 | |||
145 | writel(val, factor->base); | ||
146 | } | ||
147 | |||
148 | if (factor->lock) | ||
149 | spin_unlock_irqrestore(factor->lock, flags); | ||
150 | } | ||
151 | |||
113 | static struct clk_ops clk_factor_ops = { | 152 | static struct clk_ops clk_factor_ops = { |
114 | .recalc_rate = clk_factor_recalc_rate, | 153 | .recalc_rate = clk_factor_recalc_rate, |
115 | .round_rate = clk_factor_round_rate, | 154 | .round_rate = clk_factor_round_rate, |
116 | .set_rate = clk_factor_set_rate, | 155 | .set_rate = clk_factor_set_rate, |
156 | .init = clk_factor_init, | ||
117 | }; | 157 | }; |
118 | 158 | ||
119 | struct clk *mmp_clk_register_factor(const char *name, const char *parent_name, | 159 | struct clk *mmp_clk_register_factor(const char *name, const char *parent_name, |
120 | unsigned long flags, void __iomem *base, | 160 | unsigned long flags, void __iomem *base, |
121 | struct clk_factor_masks *masks, struct clk_factor_tbl *ftbl, | 161 | struct mmp_clk_factor_masks *masks, |
122 | unsigned int ftbl_cnt) | 162 | struct mmp_clk_factor_tbl *ftbl, |
163 | unsigned int ftbl_cnt, spinlock_t *lock) | ||
123 | { | 164 | { |
124 | struct clk_factor *factor; | 165 | struct mmp_clk_factor *factor; |
125 | struct clk_init_data init; | 166 | struct clk_init_data init; |
126 | struct clk *clk; | 167 | struct clk *clk; |
127 | 168 | ||
@@ -142,6 +183,7 @@ struct clk *mmp_clk_register_factor(const char *name, const char *parent_name, | |||
142 | factor->ftbl = ftbl; | 183 | factor->ftbl = ftbl; |
143 | factor->ftbl_cnt = ftbl_cnt; | 184 | factor->ftbl_cnt = ftbl_cnt; |
144 | factor->hw.init = &init; | 185 | factor->hw.init = &init; |
186 | factor->lock = lock; | ||
145 | 187 | ||
146 | init.name = name; | 188 | init.name = name; |
147 | init.ops = &clk_factor_ops; | 189 | init.ops = &clk_factor_ops; |
diff --git a/drivers/clk/mmp/clk-gate.c b/drivers/clk/mmp/clk-gate.c new file mode 100644 index 000000000000..adbd9d64ded2 --- /dev/null +++ b/drivers/clk/mmp/clk-gate.c | |||
@@ -0,0 +1,133 @@ | |||
1 | /* | ||
2 | * mmp gate clock operation source file | ||
3 | * | ||
4 | * Copyright (C) 2014 Marvell | ||
5 | * Chao Xie <chao.xie@marvell.com> | ||
6 | * | ||
7 | * This file is licensed under the terms of the GNU General Public | ||
8 | * License version 2. This program is licensed "as is" without any | ||
9 | * warranty of any kind, whether express or implied. | ||
10 | */ | ||
11 | |||
12 | #include <linux/clk-provider.h> | ||
13 | #include <linux/slab.h> | ||
14 | #include <linux/io.h> | ||
15 | #include <linux/err.h> | ||
16 | #include <linux/delay.h> | ||
17 | |||
18 | #include "clk.h" | ||
19 | |||
20 | /* | ||
21 | * Some clocks will have mutiple bits to enable the clocks, and | ||
22 | * the bits to disable the clock is not same as enabling bits. | ||
23 | */ | ||
24 | |||
25 | #define to_clk_mmp_gate(hw) container_of(hw, struct mmp_clk_gate, hw) | ||
26 | |||
27 | static int mmp_clk_gate_enable(struct clk_hw *hw) | ||
28 | { | ||
29 | struct mmp_clk_gate *gate = to_clk_mmp_gate(hw); | ||
30 | struct clk *clk = hw->clk; | ||
31 | unsigned long flags = 0; | ||
32 | unsigned long rate; | ||
33 | u32 tmp; | ||
34 | |||
35 | if (gate->lock) | ||
36 | spin_lock_irqsave(gate->lock, flags); | ||
37 | |||
38 | tmp = readl(gate->reg); | ||
39 | tmp &= ~gate->mask; | ||
40 | tmp |= gate->val_enable; | ||
41 | writel(tmp, gate->reg); | ||
42 | |||
43 | if (gate->lock) | ||
44 | spin_unlock_irqrestore(gate->lock, flags); | ||
45 | |||
46 | if (gate->flags & MMP_CLK_GATE_NEED_DELAY) { | ||
47 | rate = __clk_get_rate(clk); | ||
48 | /* Need delay 2 cycles. */ | ||
49 | udelay(2000000/rate); | ||
50 | } | ||
51 | |||
52 | return 0; | ||
53 | } | ||
54 | |||
55 | static void mmp_clk_gate_disable(struct clk_hw *hw) | ||
56 | { | ||
57 | struct mmp_clk_gate *gate = to_clk_mmp_gate(hw); | ||
58 | unsigned long flags = 0; | ||
59 | u32 tmp; | ||
60 | |||
61 | if (gate->lock) | ||
62 | spin_lock_irqsave(gate->lock, flags); | ||
63 | |||
64 | tmp = readl(gate->reg); | ||
65 | tmp &= ~gate->mask; | ||
66 | tmp |= gate->val_disable; | ||
67 | writel(tmp, gate->reg); | ||
68 | |||
69 | if (gate->lock) | ||
70 | spin_unlock_irqrestore(gate->lock, flags); | ||
71 | } | ||
72 | |||
73 | static int mmp_clk_gate_is_enabled(struct clk_hw *hw) | ||
74 | { | ||
75 | struct mmp_clk_gate *gate = to_clk_mmp_gate(hw); | ||
76 | unsigned long flags = 0; | ||
77 | u32 tmp; | ||
78 | |||
79 | if (gate->lock) | ||
80 | spin_lock_irqsave(gate->lock, flags); | ||
81 | |||
82 | tmp = readl(gate->reg); | ||
83 | |||
84 | if (gate->lock) | ||
85 | spin_unlock_irqrestore(gate->lock, flags); | ||
86 | |||
87 | return (tmp & gate->mask) == gate->val_enable; | ||
88 | } | ||
89 | |||
90 | const struct clk_ops mmp_clk_gate_ops = { | ||
91 | .enable = mmp_clk_gate_enable, | ||
92 | .disable = mmp_clk_gate_disable, | ||
93 | .is_enabled = mmp_clk_gate_is_enabled, | ||
94 | }; | ||
95 | |||
96 | struct clk *mmp_clk_register_gate(struct device *dev, const char *name, | ||
97 | const char *parent_name, unsigned long flags, | ||
98 | void __iomem *reg, u32 mask, u32 val_enable, u32 val_disable, | ||
99 | unsigned int gate_flags, spinlock_t *lock) | ||
100 | { | ||
101 | struct mmp_clk_gate *gate; | ||
102 | struct clk *clk; | ||
103 | struct clk_init_data init; | ||
104 | |||
105 | /* allocate the gate */ | ||
106 | gate = kzalloc(sizeof(*gate), GFP_KERNEL); | ||
107 | if (!gate) { | ||
108 | pr_err("%s:%s could not allocate gate clk\n", __func__, name); | ||
109 | return ERR_PTR(-ENOMEM); | ||
110 | } | ||
111 | |||
112 | init.name = name; | ||
113 | init.ops = &mmp_clk_gate_ops; | ||
114 | init.flags = flags | CLK_IS_BASIC; | ||
115 | init.parent_names = (parent_name ? &parent_name : NULL); | ||
116 | init.num_parents = (parent_name ? 1 : 0); | ||
117 | |||
118 | /* struct clk_gate assignments */ | ||
119 | gate->reg = reg; | ||
120 | gate->mask = mask; | ||
121 | gate->val_enable = val_enable; | ||
122 | gate->val_disable = val_disable; | ||
123 | gate->flags = gate_flags; | ||
124 | gate->lock = lock; | ||
125 | gate->hw.init = &init; | ||
126 | |||
127 | clk = clk_register(dev, &gate->hw); | ||
128 | |||
129 | if (IS_ERR(clk)) | ||
130 | kfree(gate); | ||
131 | |||
132 | return clk; | ||
133 | } | ||
diff --git a/drivers/clk/mmp/clk-mix.c b/drivers/clk/mmp/clk-mix.c new file mode 100644 index 000000000000..b79742c47d53 --- /dev/null +++ b/drivers/clk/mmp/clk-mix.c | |||
@@ -0,0 +1,513 @@ | |||
1 | /* | ||
2 | * mmp mix(div and mux) clock operation source file | ||
3 | * | ||
4 | * Copyright (C) 2014 Marvell | ||
5 | * Chao Xie <chao.xie@marvell.com> | ||
6 | * | ||
7 | * This file is licensed under the terms of the GNU General Public | ||
8 | * License version 2. This program is licensed "as is" without any | ||
9 | * warranty of any kind, whether express or implied. | ||
10 | */ | ||
11 | |||
12 | #include <linux/clk-provider.h> | ||
13 | #include <linux/slab.h> | ||
14 | #include <linux/io.h> | ||
15 | #include <linux/err.h> | ||
16 | |||
17 | #include "clk.h" | ||
18 | |||
19 | /* | ||
20 | * The mix clock is a clock combined mux and div type clock. | ||
21 | * Because the div field and mux field need to be set at same | ||
22 | * time, we can not divide it into 2 types of clock | ||
23 | */ | ||
24 | |||
25 | #define to_clk_mix(hw) container_of(hw, struct mmp_clk_mix, hw) | ||
26 | |||
27 | static unsigned int _get_maxdiv(struct mmp_clk_mix *mix) | ||
28 | { | ||
29 | unsigned int div_mask = (1 << mix->reg_info.width_div) - 1; | ||
30 | unsigned int maxdiv = 0; | ||
31 | struct clk_div_table *clkt; | ||
32 | |||
33 | if (mix->div_flags & CLK_DIVIDER_ONE_BASED) | ||
34 | return div_mask; | ||
35 | if (mix->div_flags & CLK_DIVIDER_POWER_OF_TWO) | ||
36 | return 1 << div_mask; | ||
37 | if (mix->div_table) { | ||
38 | for (clkt = mix->div_table; clkt->div; clkt++) | ||
39 | if (clkt->div > maxdiv) | ||
40 | maxdiv = clkt->div; | ||
41 | return maxdiv; | ||
42 | } | ||
43 | return div_mask + 1; | ||
44 | } | ||
45 | |||
46 | static unsigned int _get_div(struct mmp_clk_mix *mix, unsigned int val) | ||
47 | { | ||
48 | struct clk_div_table *clkt; | ||
49 | |||
50 | if (mix->div_flags & CLK_DIVIDER_ONE_BASED) | ||
51 | return val; | ||
52 | if (mix->div_flags & CLK_DIVIDER_POWER_OF_TWO) | ||
53 | return 1 << val; | ||
54 | if (mix->div_table) { | ||
55 | for (clkt = mix->div_table; clkt->div; clkt++) | ||
56 | if (clkt->val == val) | ||
57 | return clkt->div; | ||
58 | if (clkt->div == 0) | ||
59 | return 0; | ||
60 | } | ||
61 | return val + 1; | ||
62 | } | ||
63 | |||
64 | static unsigned int _get_mux(struct mmp_clk_mix *mix, unsigned int val) | ||
65 | { | ||
66 | int num_parents = __clk_get_num_parents(mix->hw.clk); | ||
67 | int i; | ||
68 | |||
69 | if (mix->mux_flags & CLK_MUX_INDEX_BIT) | ||
70 | return ffs(val) - 1; | ||
71 | if (mix->mux_flags & CLK_MUX_INDEX_ONE) | ||
72 | return val - 1; | ||
73 | if (mix->mux_table) { | ||
74 | for (i = 0; i < num_parents; i++) | ||
75 | if (mix->mux_table[i] == val) | ||
76 | return i; | ||
77 | if (i == num_parents) | ||
78 | return 0; | ||
79 | } | ||
80 | |||
81 | return val; | ||
82 | } | ||
83 | static unsigned int _get_div_val(struct mmp_clk_mix *mix, unsigned int div) | ||
84 | { | ||
85 | struct clk_div_table *clkt; | ||
86 | |||
87 | if (mix->div_flags & CLK_DIVIDER_ONE_BASED) | ||
88 | return div; | ||
89 | if (mix->div_flags & CLK_DIVIDER_POWER_OF_TWO) | ||
90 | return __ffs(div); | ||
91 | if (mix->div_table) { | ||
92 | for (clkt = mix->div_table; clkt->div; clkt++) | ||
93 | if (clkt->div == div) | ||
94 | return clkt->val; | ||
95 | if (clkt->div == 0) | ||
96 | return 0; | ||
97 | } | ||
98 | |||
99 | return div - 1; | ||
100 | } | ||
101 | |||
102 | static unsigned int _get_mux_val(struct mmp_clk_mix *mix, unsigned int mux) | ||
103 | { | ||
104 | if (mix->mux_table) | ||
105 | return mix->mux_table[mux]; | ||
106 | |||
107 | return mux; | ||
108 | } | ||
109 | |||
110 | static void _filter_clk_table(struct mmp_clk_mix *mix, | ||
111 | struct mmp_clk_mix_clk_table *table, | ||
112 | unsigned int table_size) | ||
113 | { | ||
114 | int i; | ||
115 | struct mmp_clk_mix_clk_table *item; | ||
116 | struct clk *parent, *clk; | ||
117 | unsigned long parent_rate; | ||
118 | |||
119 | clk = mix->hw.clk; | ||
120 | |||
121 | for (i = 0; i < table_size; i++) { | ||
122 | item = &table[i]; | ||
123 | parent = clk_get_parent_by_index(clk, item->parent_index); | ||
124 | parent_rate = __clk_get_rate(parent); | ||
125 | if (parent_rate % item->rate) { | ||
126 | item->valid = 0; | ||
127 | } else { | ||
128 | item->divisor = parent_rate / item->rate; | ||
129 | item->valid = 1; | ||
130 | } | ||
131 | } | ||
132 | } | ||
133 | |||
134 | static int _set_rate(struct mmp_clk_mix *mix, u32 mux_val, u32 div_val, | ||
135 | unsigned int change_mux, unsigned int change_div) | ||
136 | { | ||
137 | struct mmp_clk_mix_reg_info *ri = &mix->reg_info; | ||
138 | u8 width, shift; | ||
139 | u32 mux_div, fc_req; | ||
140 | int ret, timeout = 50; | ||
141 | unsigned long flags = 0; | ||
142 | |||
143 | if (!change_mux && !change_div) | ||
144 | return -EINVAL; | ||
145 | |||
146 | if (mix->lock) | ||
147 | spin_lock_irqsave(mix->lock, flags); | ||
148 | |||
149 | if (mix->type == MMP_CLK_MIX_TYPE_V1 | ||
150 | || mix->type == MMP_CLK_MIX_TYPE_V2) | ||
151 | mux_div = readl(ri->reg_clk_ctrl); | ||
152 | else | ||
153 | mux_div = readl(ri->reg_clk_sel); | ||
154 | |||
155 | if (change_div) { | ||
156 | width = ri->width_div; | ||
157 | shift = ri->shift_div; | ||
158 | mux_div &= ~MMP_CLK_BITS_MASK(width, shift); | ||
159 | mux_div |= MMP_CLK_BITS_SET_VAL(div_val, width, shift); | ||
160 | } | ||
161 | |||
162 | if (change_mux) { | ||
163 | width = ri->width_mux; | ||
164 | shift = ri->shift_mux; | ||
165 | mux_div &= ~MMP_CLK_BITS_MASK(width, shift); | ||
166 | mux_div |= MMP_CLK_BITS_SET_VAL(mux_val, width, shift); | ||
167 | } | ||
168 | |||
169 | if (mix->type == MMP_CLK_MIX_TYPE_V1) { | ||
170 | writel(mux_div, ri->reg_clk_ctrl); | ||
171 | } else if (mix->type == MMP_CLK_MIX_TYPE_V2) { | ||
172 | mux_div |= (1 << ri->bit_fc); | ||
173 | writel(mux_div, ri->reg_clk_ctrl); | ||
174 | |||
175 | do { | ||
176 | fc_req = readl(ri->reg_clk_ctrl); | ||
177 | timeout--; | ||
178 | if (!(fc_req & (1 << ri->bit_fc))) | ||
179 | break; | ||
180 | } while (timeout); | ||
181 | |||
182 | if (timeout == 0) { | ||
183 | pr_err("%s:%s cannot do frequency change\n", | ||
184 | __func__, __clk_get_name(mix->hw.clk)); | ||
185 | ret = -EBUSY; | ||
186 | goto error; | ||
187 | } | ||
188 | } else { | ||
189 | fc_req = readl(ri->reg_clk_ctrl); | ||
190 | fc_req |= 1 << ri->bit_fc; | ||
191 | writel(fc_req, ri->reg_clk_ctrl); | ||
192 | writel(mux_div, ri->reg_clk_sel); | ||
193 | fc_req &= ~(1 << ri->bit_fc); | ||
194 | } | ||
195 | |||
196 | ret = 0; | ||
197 | error: | ||
198 | if (mix->lock) | ||
199 | spin_unlock_irqrestore(mix->lock, flags); | ||
200 | |||
201 | return ret; | ||
202 | } | ||
203 | |||
204 | static long mmp_clk_mix_determine_rate(struct clk_hw *hw, unsigned long rate, | ||
205 | unsigned long *best_parent_rate, | ||
206 | struct clk **best_parent_clk) | ||
207 | { | ||
208 | struct mmp_clk_mix *mix = to_clk_mix(hw); | ||
209 | struct mmp_clk_mix_clk_table *item; | ||
210 | struct clk *parent, *parent_best, *mix_clk; | ||
211 | unsigned long parent_rate, mix_rate, mix_rate_best, parent_rate_best; | ||
212 | unsigned long gap, gap_best; | ||
213 | u32 div_val_max; | ||
214 | unsigned int div; | ||
215 | int i, j; | ||
216 | |||
217 | mix_clk = hw->clk; | ||
218 | |||
219 | parent = NULL; | ||
220 | mix_rate_best = 0; | ||
221 | parent_rate_best = 0; | ||
222 | gap_best = rate; | ||
223 | parent_best = NULL; | ||
224 | |||
225 | if (mix->table) { | ||
226 | for (i = 0; i < mix->table_size; i++) { | ||
227 | item = &mix->table[i]; | ||
228 | if (item->valid == 0) | ||
229 | continue; | ||
230 | parent = clk_get_parent_by_index(mix_clk, | ||
231 | item->parent_index); | ||
232 | parent_rate = __clk_get_rate(parent); | ||
233 | mix_rate = parent_rate / item->divisor; | ||
234 | gap = abs(mix_rate - rate); | ||
235 | if (parent_best == NULL || gap < gap_best) { | ||
236 | parent_best = parent; | ||
237 | parent_rate_best = parent_rate; | ||
238 | mix_rate_best = mix_rate; | ||
239 | gap_best = gap; | ||
240 | if (gap_best == 0) | ||
241 | goto found; | ||
242 | } | ||
243 | } | ||
244 | } else { | ||
245 | for (i = 0; i < __clk_get_num_parents(mix_clk); i++) { | ||
246 | parent = clk_get_parent_by_index(mix_clk, i); | ||
247 | parent_rate = __clk_get_rate(parent); | ||
248 | div_val_max = _get_maxdiv(mix); | ||
249 | for (j = 0; j < div_val_max; j++) { | ||
250 | div = _get_div(mix, j); | ||
251 | mix_rate = parent_rate / div; | ||
252 | gap = abs(mix_rate - rate); | ||
253 | if (parent_best == NULL || gap < gap_best) { | ||
254 | parent_best = parent; | ||
255 | parent_rate_best = parent_rate; | ||
256 | mix_rate_best = mix_rate; | ||
257 | gap_best = gap; | ||
258 | if (gap_best == 0) | ||
259 | goto found; | ||
260 | } | ||
261 | } | ||
262 | } | ||
263 | } | ||
264 | |||
265 | found: | ||
266 | *best_parent_rate = parent_rate_best; | ||
267 | *best_parent_clk = parent_best; | ||
268 | |||
269 | return mix_rate_best; | ||
270 | } | ||
271 | |||
272 | static int mmp_clk_mix_set_rate_and_parent(struct clk_hw *hw, | ||
273 | unsigned long rate, | ||
274 | unsigned long parent_rate, | ||
275 | u8 index) | ||
276 | { | ||
277 | struct mmp_clk_mix *mix = to_clk_mix(hw); | ||
278 | unsigned int div; | ||
279 | u32 div_val, mux_val; | ||
280 | |||
281 | div = parent_rate / rate; | ||
282 | div_val = _get_div_val(mix, div); | ||
283 | mux_val = _get_mux_val(mix, index); | ||
284 | |||
285 | return _set_rate(mix, mux_val, div_val, 1, 1); | ||
286 | } | ||
287 | |||
288 | static u8 mmp_clk_mix_get_parent(struct clk_hw *hw) | ||
289 | { | ||
290 | struct mmp_clk_mix *mix = to_clk_mix(hw); | ||
291 | struct mmp_clk_mix_reg_info *ri = &mix->reg_info; | ||
292 | unsigned long flags = 0; | ||
293 | u32 mux_div = 0; | ||
294 | u8 width, shift; | ||
295 | u32 mux_val; | ||
296 | |||
297 | if (mix->lock) | ||
298 | spin_lock_irqsave(mix->lock, flags); | ||
299 | |||
300 | if (mix->type == MMP_CLK_MIX_TYPE_V1 | ||
301 | || mix->type == MMP_CLK_MIX_TYPE_V2) | ||
302 | mux_div = readl(ri->reg_clk_ctrl); | ||
303 | else | ||
304 | mux_div = readl(ri->reg_clk_sel); | ||
305 | |||
306 | if (mix->lock) | ||
307 | spin_unlock_irqrestore(mix->lock, flags); | ||
308 | |||
309 | width = mix->reg_info.width_mux; | ||
310 | shift = mix->reg_info.shift_mux; | ||
311 | |||
312 | mux_val = MMP_CLK_BITS_GET_VAL(mux_div, width, shift); | ||
313 | |||
314 | return _get_mux(mix, mux_val); | ||
315 | } | ||
316 | |||
317 | static unsigned long mmp_clk_mix_recalc_rate(struct clk_hw *hw, | ||
318 | unsigned long parent_rate) | ||
319 | { | ||
320 | struct mmp_clk_mix *mix = to_clk_mix(hw); | ||
321 | struct mmp_clk_mix_reg_info *ri = &mix->reg_info; | ||
322 | unsigned long flags = 0; | ||
323 | u32 mux_div = 0; | ||
324 | u8 width, shift; | ||
325 | unsigned int div; | ||
326 | |||
327 | if (mix->lock) | ||
328 | spin_lock_irqsave(mix->lock, flags); | ||
329 | |||
330 | if (mix->type == MMP_CLK_MIX_TYPE_V1 | ||
331 | || mix->type == MMP_CLK_MIX_TYPE_V2) | ||
332 | mux_div = readl(ri->reg_clk_ctrl); | ||
333 | else | ||
334 | mux_div = readl(ri->reg_clk_sel); | ||
335 | |||
336 | if (mix->lock) | ||
337 | spin_unlock_irqrestore(mix->lock, flags); | ||
338 | |||
339 | width = mix->reg_info.width_div; | ||
340 | shift = mix->reg_info.shift_div; | ||
341 | |||
342 | div = _get_div(mix, MMP_CLK_BITS_GET_VAL(mux_div, width, shift)); | ||
343 | |||
344 | return parent_rate / div; | ||
345 | } | ||
346 | |||
347 | static int mmp_clk_set_parent(struct clk_hw *hw, u8 index) | ||
348 | { | ||
349 | struct mmp_clk_mix *mix = to_clk_mix(hw); | ||
350 | struct mmp_clk_mix_clk_table *item; | ||
351 | int i; | ||
352 | u32 div_val, mux_val; | ||
353 | |||
354 | if (mix->table) { | ||
355 | for (i = 0; i < mix->table_size; i++) { | ||
356 | item = &mix->table[i]; | ||
357 | if (item->valid == 0) | ||
358 | continue; | ||
359 | if (item->parent_index == index) | ||
360 | break; | ||
361 | } | ||
362 | if (i < mix->table_size) { | ||
363 | div_val = _get_div_val(mix, item->divisor); | ||
364 | mux_val = _get_mux_val(mix, item->parent_index); | ||
365 | } else | ||
366 | return -EINVAL; | ||
367 | } else { | ||
368 | mux_val = _get_mux_val(mix, index); | ||
369 | div_val = 0; | ||
370 | } | ||
371 | |||
372 | return _set_rate(mix, mux_val, div_val, 1, div_val ? 1 : 0); | ||
373 | } | ||
374 | |||
375 | static int mmp_clk_set_rate(struct clk_hw *hw, unsigned long rate, | ||
376 | unsigned long best_parent_rate) | ||
377 | { | ||
378 | struct mmp_clk_mix *mix = to_clk_mix(hw); | ||
379 | struct mmp_clk_mix_clk_table *item; | ||
380 | unsigned long parent_rate; | ||
381 | unsigned int best_divisor; | ||
382 | struct clk *mix_clk, *parent; | ||
383 | int i; | ||
384 | |||
385 | best_divisor = best_parent_rate / rate; | ||
386 | |||
387 | mix_clk = hw->clk; | ||
388 | if (mix->table) { | ||
389 | for (i = 0; i < mix->table_size; i++) { | ||
390 | item = &mix->table[i]; | ||
391 | if (item->valid == 0) | ||
392 | continue; | ||
393 | parent = clk_get_parent_by_index(mix_clk, | ||
394 | item->parent_index); | ||
395 | parent_rate = __clk_get_rate(parent); | ||
396 | if (parent_rate == best_parent_rate | ||
397 | && item->divisor == best_divisor) | ||
398 | break; | ||
399 | } | ||
400 | if (i < mix->table_size) | ||
401 | return _set_rate(mix, | ||
402 | _get_mux_val(mix, item->parent_index), | ||
403 | _get_div_val(mix, item->divisor), | ||
404 | 1, 1); | ||
405 | else | ||
406 | return -EINVAL; | ||
407 | } else { | ||
408 | for (i = 0; i < __clk_get_num_parents(mix_clk); i++) { | ||
409 | parent = clk_get_parent_by_index(mix_clk, i); | ||
410 | parent_rate = __clk_get_rate(parent); | ||
411 | if (parent_rate == best_parent_rate) | ||
412 | break; | ||
413 | } | ||
414 | if (i < __clk_get_num_parents(mix_clk)) | ||
415 | return _set_rate(mix, _get_mux_val(mix, i), | ||
416 | _get_div_val(mix, best_divisor), 1, 1); | ||
417 | else | ||
418 | return -EINVAL; | ||
419 | } | ||
420 | } | ||
421 | |||
422 | static void mmp_clk_mix_init(struct clk_hw *hw) | ||
423 | { | ||
424 | struct mmp_clk_mix *mix = to_clk_mix(hw); | ||
425 | |||
426 | if (mix->table) | ||
427 | _filter_clk_table(mix, mix->table, mix->table_size); | ||
428 | } | ||
429 | |||
430 | const struct clk_ops mmp_clk_mix_ops = { | ||
431 | .determine_rate = mmp_clk_mix_determine_rate, | ||
432 | .set_rate_and_parent = mmp_clk_mix_set_rate_and_parent, | ||
433 | .set_rate = mmp_clk_set_rate, | ||
434 | .set_parent = mmp_clk_set_parent, | ||
435 | .get_parent = mmp_clk_mix_get_parent, | ||
436 | .recalc_rate = mmp_clk_mix_recalc_rate, | ||
437 | .init = mmp_clk_mix_init, | ||
438 | }; | ||
439 | |||
440 | struct clk *mmp_clk_register_mix(struct device *dev, | ||
441 | const char *name, | ||
442 | const char **parent_names, | ||
443 | u8 num_parents, | ||
444 | unsigned long flags, | ||
445 | struct mmp_clk_mix_config *config, | ||
446 | spinlock_t *lock) | ||
447 | { | ||
448 | struct mmp_clk_mix *mix; | ||
449 | struct clk *clk; | ||
450 | struct clk_init_data init; | ||
451 | size_t table_bytes; | ||
452 | |||
453 | mix = kzalloc(sizeof(*mix), GFP_KERNEL); | ||
454 | if (!mix) { | ||
455 | pr_err("%s:%s: could not allocate mmp mix clk\n", | ||
456 | __func__, name); | ||
457 | return ERR_PTR(-ENOMEM); | ||
458 | } | ||
459 | |||
460 | init.name = name; | ||
461 | init.flags = flags | CLK_GET_RATE_NOCACHE; | ||
462 | init.parent_names = parent_names; | ||
463 | init.num_parents = num_parents; | ||
464 | init.ops = &mmp_clk_mix_ops; | ||
465 | |||
466 | memcpy(&mix->reg_info, &config->reg_info, sizeof(config->reg_info)); | ||
467 | if (config->table) { | ||
468 | table_bytes = sizeof(*config->table) * config->table_size; | ||
469 | mix->table = kzalloc(table_bytes, GFP_KERNEL); | ||
470 | if (!mix->table) { | ||
471 | pr_err("%s:%s: could not allocate mmp mix table\n", | ||
472 | __func__, name); | ||
473 | kfree(mix); | ||
474 | return ERR_PTR(-ENOMEM); | ||
475 | } | ||
476 | memcpy(mix->table, config->table, table_bytes); | ||
477 | mix->table_size = config->table_size; | ||
478 | } | ||
479 | |||
480 | if (config->mux_table) { | ||
481 | table_bytes = sizeof(u32) * num_parents; | ||
482 | mix->mux_table = kzalloc(table_bytes, GFP_KERNEL); | ||
483 | if (!mix->mux_table) { | ||
484 | pr_err("%s:%s: could not allocate mmp mix mux-table\n", | ||
485 | __func__, name); | ||
486 | kfree(mix->table); | ||
487 | kfree(mix); | ||
488 | return ERR_PTR(-ENOMEM); | ||
489 | } | ||
490 | memcpy(mix->mux_table, config->mux_table, table_bytes); | ||
491 | } | ||
492 | |||
493 | mix->div_flags = config->div_flags; | ||
494 | mix->mux_flags = config->mux_flags; | ||
495 | mix->lock = lock; | ||
496 | mix->hw.init = &init; | ||
497 | |||
498 | if (config->reg_info.bit_fc >= 32) | ||
499 | mix->type = MMP_CLK_MIX_TYPE_V1; | ||
500 | else if (config->reg_info.reg_clk_sel) | ||
501 | mix->type = MMP_CLK_MIX_TYPE_V3; | ||
502 | else | ||
503 | mix->type = MMP_CLK_MIX_TYPE_V2; | ||
504 | clk = clk_register(dev, &mix->hw); | ||
505 | |||
506 | if (IS_ERR(clk)) { | ||
507 | kfree(mix->mux_table); | ||
508 | kfree(mix->table); | ||
509 | kfree(mix); | ||
510 | } | ||
511 | |||
512 | return clk; | ||
513 | } | ||
diff --git a/drivers/clk/mmp/clk-mmp2.c b/drivers/clk/mmp/clk-mmp2.c index b2721cae257a..5c90a4230fa3 100644 --- a/drivers/clk/mmp/clk-mmp2.c +++ b/drivers/clk/mmp/clk-mmp2.c | |||
@@ -54,7 +54,7 @@ | |||
54 | 54 | ||
55 | static DEFINE_SPINLOCK(clk_lock); | 55 | static DEFINE_SPINLOCK(clk_lock); |
56 | 56 | ||
57 | static struct clk_factor_masks uart_factor_masks = { | 57 | static struct mmp_clk_factor_masks uart_factor_masks = { |
58 | .factor = 2, | 58 | .factor = 2, |
59 | .num_mask = 0x1fff, | 59 | .num_mask = 0x1fff, |
60 | .den_mask = 0x1fff, | 60 | .den_mask = 0x1fff, |
@@ -62,7 +62,7 @@ static struct clk_factor_masks uart_factor_masks = { | |||
62 | .den_shift = 0, | 62 | .den_shift = 0, |
63 | }; | 63 | }; |
64 | 64 | ||
65 | static struct clk_factor_tbl uart_factor_tbl[] = { | 65 | static struct mmp_clk_factor_tbl uart_factor_tbl[] = { |
66 | {.num = 14634, .den = 2165}, /*14.745MHZ */ | 66 | {.num = 14634, .den = 2165}, /*14.745MHZ */ |
67 | {.num = 3521, .den = 689}, /*19.23MHZ */ | 67 | {.num = 3521, .den = 689}, /*19.23MHZ */ |
68 | {.num = 9679, .den = 5728}, /*58.9824MHZ */ | 68 | {.num = 9679, .den = 5728}, /*58.9824MHZ */ |
@@ -191,7 +191,7 @@ void __init mmp2_clk_init(void) | |||
191 | clk = mmp_clk_register_factor("uart_pll", "pll1_4", 0, | 191 | clk = mmp_clk_register_factor("uart_pll", "pll1_4", 0, |
192 | mpmu_base + MPMU_UART_PLL, | 192 | mpmu_base + MPMU_UART_PLL, |
193 | &uart_factor_masks, uart_factor_tbl, | 193 | &uart_factor_masks, uart_factor_tbl, |
194 | ARRAY_SIZE(uart_factor_tbl)); | 194 | ARRAY_SIZE(uart_factor_tbl), &clk_lock); |
195 | clk_set_rate(clk, 14745600); | 195 | clk_set_rate(clk, 14745600); |
196 | clk_register_clkdev(clk, "uart_pll", NULL); | 196 | clk_register_clkdev(clk, "uart_pll", NULL); |
197 | 197 | ||
diff --git a/drivers/clk/mmp/clk-of-mmp2.c b/drivers/clk/mmp/clk-of-mmp2.c new file mode 100644 index 000000000000..2cbc2b43ae52 --- /dev/null +++ b/drivers/clk/mmp/clk-of-mmp2.c | |||
@@ -0,0 +1,334 @@ | |||
1 | /* | ||
2 | * mmp2 clock framework source file | ||
3 | * | ||
4 | * Copyright (C) 2012 Marvell | ||
5 | * Chao Xie <xiechao.mail@gmail.com> | ||
6 | * | ||
7 | * This file is licensed under the terms of the GNU General Public | ||
8 | * License version 2. This program is licensed "as is" without any | ||
9 | * warranty of any kind, whether express or implied. | ||
10 | */ | ||
11 | |||
12 | #include <linux/module.h> | ||
13 | #include <linux/kernel.h> | ||
14 | #include <linux/spinlock.h> | ||
15 | #include <linux/io.h> | ||
16 | #include <linux/delay.h> | ||
17 | #include <linux/err.h> | ||
18 | #include <linux/of_address.h> | ||
19 | |||
20 | #include <dt-bindings/clock/marvell,mmp2.h> | ||
21 | |||
22 | #include "clk.h" | ||
23 | #include "reset.h" | ||
24 | |||
25 | #define APBC_RTC 0x0 | ||
26 | #define APBC_TWSI0 0x4 | ||
27 | #define APBC_TWSI1 0x8 | ||
28 | #define APBC_TWSI2 0xc | ||
29 | #define APBC_TWSI3 0x10 | ||
30 | #define APBC_TWSI4 0x7c | ||
31 | #define APBC_TWSI5 0x80 | ||
32 | #define APBC_KPC 0x18 | ||
33 | #define APBC_UART0 0x2c | ||
34 | #define APBC_UART1 0x30 | ||
35 | #define APBC_UART2 0x34 | ||
36 | #define APBC_UART3 0x88 | ||
37 | #define APBC_GPIO 0x38 | ||
38 | #define APBC_PWM0 0x3c | ||
39 | #define APBC_PWM1 0x40 | ||
40 | #define APBC_PWM2 0x44 | ||
41 | #define APBC_PWM3 0x48 | ||
42 | #define APBC_SSP0 0x50 | ||
43 | #define APBC_SSP1 0x54 | ||
44 | #define APBC_SSP2 0x58 | ||
45 | #define APBC_SSP3 0x5c | ||
46 | #define APMU_SDH0 0x54 | ||
47 | #define APMU_SDH1 0x58 | ||
48 | #define APMU_SDH2 0xe8 | ||
49 | #define APMU_SDH3 0xec | ||
50 | #define APMU_USB 0x5c | ||
51 | #define APMU_DISP0 0x4c | ||
52 | #define APMU_DISP1 0x110 | ||
53 | #define APMU_CCIC0 0x50 | ||
54 | #define APMU_CCIC1 0xf4 | ||
55 | #define MPMU_UART_PLL 0x14 | ||
56 | |||
57 | struct mmp2_clk_unit { | ||
58 | struct mmp_clk_unit unit; | ||
59 | void __iomem *mpmu_base; | ||
60 | void __iomem *apmu_base; | ||
61 | void __iomem *apbc_base; | ||
62 | }; | ||
63 | |||
64 | static struct mmp_param_fixed_rate_clk fixed_rate_clks[] = { | ||
65 | {MMP2_CLK_CLK32, "clk32", NULL, CLK_IS_ROOT, 32768}, | ||
66 | {MMP2_CLK_VCTCXO, "vctcxo", NULL, CLK_IS_ROOT, 26000000}, | ||
67 | {MMP2_CLK_PLL1, "pll1", NULL, CLK_IS_ROOT, 800000000}, | ||
68 | {MMP2_CLK_PLL2, "pll2", NULL, CLK_IS_ROOT, 960000000}, | ||
69 | {MMP2_CLK_USB_PLL, "usb_pll", NULL, CLK_IS_ROOT, 480000000}, | ||
70 | }; | ||
71 | |||
72 | static struct mmp_param_fixed_factor_clk fixed_factor_clks[] = { | ||
73 | {MMP2_CLK_PLL1_2, "pll1_2", "pll1", 1, 2, 0}, | ||
74 | {MMP2_CLK_PLL1_4, "pll1_4", "pll1_2", 1, 2, 0}, | ||
75 | {MMP2_CLK_PLL1_8, "pll1_8", "pll1_4", 1, 2, 0}, | ||
76 | {MMP2_CLK_PLL1_16, "pll1_16", "pll1_8", 1, 2, 0}, | ||
77 | {MMP2_CLK_PLL1_20, "pll1_20", "pll1_4", 1, 5, 0}, | ||
78 | {MMP2_CLK_PLL1_3, "pll1_3", "pll1", 1, 3, 0}, | ||
79 | {MMP2_CLK_PLL1_6, "pll1_6", "pll1_3", 1, 2, 0}, | ||
80 | {MMP2_CLK_PLL1_12, "pll1_12", "pll1_6", 1, 2, 0}, | ||
81 | {MMP2_CLK_PLL2_2, "pll2_2", "pll2", 1, 2, 0}, | ||
82 | {MMP2_CLK_PLL2_4, "pll2_4", "pll2_2", 1, 2, 0}, | ||
83 | {MMP2_CLK_PLL2_8, "pll2_8", "pll2_4", 1, 2, 0}, | ||
84 | {MMP2_CLK_PLL2_16, "pll2_16", "pll2_8", 1, 2, 0}, | ||
85 | {MMP2_CLK_PLL2_3, "pll2_3", "pll2", 1, 3, 0}, | ||
86 | {MMP2_CLK_PLL2_6, "pll2_6", "pll2_3", 1, 2, 0}, | ||
87 | {MMP2_CLK_PLL2_12, "pll2_12", "pll2_6", 1, 2, 0}, | ||
88 | {MMP2_CLK_VCTCXO_2, "vctcxo_2", "vctcxo", 1, 2, 0}, | ||
89 | {MMP2_CLK_VCTCXO_4, "vctcxo_4", "vctcxo_2", 1, 2, 0}, | ||
90 | }; | ||
91 | |||
92 | static struct mmp_clk_factor_masks uart_factor_masks = { | ||
93 | .factor = 2, | ||
94 | .num_mask = 0x1fff, | ||
95 | .den_mask = 0x1fff, | ||
96 | .num_shift = 16, | ||
97 | .den_shift = 0, | ||
98 | }; | ||
99 | |||
100 | static struct mmp_clk_factor_tbl uart_factor_tbl[] = { | ||
101 | {.num = 14634, .den = 2165}, /*14.745MHZ */ | ||
102 | {.num = 3521, .den = 689}, /*19.23MHZ */ | ||
103 | {.num = 9679, .den = 5728}, /*58.9824MHZ */ | ||
104 | {.num = 15850, .den = 9451}, /*59.429MHZ */ | ||
105 | }; | ||
106 | |||
107 | static void mmp2_pll_init(struct mmp2_clk_unit *pxa_unit) | ||
108 | { | ||
109 | struct clk *clk; | ||
110 | struct mmp_clk_unit *unit = &pxa_unit->unit; | ||
111 | |||
112 | mmp_register_fixed_rate_clks(unit, fixed_rate_clks, | ||
113 | ARRAY_SIZE(fixed_rate_clks)); | ||
114 | |||
115 | mmp_register_fixed_factor_clks(unit, fixed_factor_clks, | ||
116 | ARRAY_SIZE(fixed_factor_clks)); | ||
117 | |||
118 | clk = mmp_clk_register_factor("uart_pll", "pll1_4", | ||
119 | CLK_SET_RATE_PARENT, | ||
120 | pxa_unit->mpmu_base + MPMU_UART_PLL, | ||
121 | &uart_factor_masks, uart_factor_tbl, | ||
122 | ARRAY_SIZE(uart_factor_tbl), NULL); | ||
123 | mmp_clk_add(unit, MMP2_CLK_UART_PLL, clk); | ||
124 | } | ||
125 | |||
126 | static DEFINE_SPINLOCK(uart0_lock); | ||
127 | static DEFINE_SPINLOCK(uart1_lock); | ||
128 | static DEFINE_SPINLOCK(uart2_lock); | ||
129 | static const char *uart_parent_names[] = {"uart_pll", "vctcxo"}; | ||
130 | |||
131 | static DEFINE_SPINLOCK(ssp0_lock); | ||
132 | static DEFINE_SPINLOCK(ssp1_lock); | ||
133 | static DEFINE_SPINLOCK(ssp2_lock); | ||
134 | static DEFINE_SPINLOCK(ssp3_lock); | ||
135 | static const char *ssp_parent_names[] = {"vctcxo_4", "vctcxo_2", "vctcxo", "pll1_16"}; | ||
136 | |||
137 | static DEFINE_SPINLOCK(reset_lock); | ||
138 | |||
139 | static struct mmp_param_mux_clk apbc_mux_clks[] = { | ||
140 | {0, "uart0_mux", uart_parent_names, ARRAY_SIZE(uart_parent_names), CLK_SET_RATE_PARENT, APBC_UART0, 4, 3, 0, &uart0_lock}, | ||
141 | {0, "uart1_mux", uart_parent_names, ARRAY_SIZE(uart_parent_names), CLK_SET_RATE_PARENT, APBC_UART1, 4, 3, 0, &uart1_lock}, | ||
142 | {0, "uart2_mux", uart_parent_names, ARRAY_SIZE(uart_parent_names), CLK_SET_RATE_PARENT, APBC_UART2, 4, 3, 0, &uart2_lock}, | ||
143 | {0, "uart3_mux", uart_parent_names, ARRAY_SIZE(uart_parent_names), CLK_SET_RATE_PARENT, APBC_UART3, 4, 3, 0, &uart2_lock}, | ||
144 | {0, "ssp0_mux", ssp_parent_names, ARRAY_SIZE(ssp_parent_names), CLK_SET_RATE_PARENT, APBC_SSP0, 4, 3, 0, &ssp0_lock}, | ||
145 | {0, "ssp1_mux", ssp_parent_names, ARRAY_SIZE(ssp_parent_names), CLK_SET_RATE_PARENT, APBC_SSP1, 4, 3, 0, &ssp1_lock}, | ||
146 | {0, "ssp2_mux", ssp_parent_names, ARRAY_SIZE(ssp_parent_names), CLK_SET_RATE_PARENT, APBC_SSP2, 4, 3, 0, &ssp2_lock}, | ||
147 | {0, "ssp3_mux", ssp_parent_names, ARRAY_SIZE(ssp_parent_names), CLK_SET_RATE_PARENT, APBC_SSP3, 4, 3, 0, &ssp3_lock}, | ||
148 | }; | ||
149 | |||
150 | static struct mmp_param_gate_clk apbc_gate_clks[] = { | ||
151 | {MMP2_CLK_TWSI0, "twsi0_clk", "vctcxo", CLK_SET_RATE_PARENT, APBC_TWSI0, 0x7, 0x3, 0x0, 0, &reset_lock}, | ||
152 | {MMP2_CLK_TWSI1, "twsi1_clk", "vctcxo", CLK_SET_RATE_PARENT, APBC_TWSI1, 0x7, 0x3, 0x0, 0, &reset_lock}, | ||
153 | {MMP2_CLK_TWSI2, "twsi2_clk", "vctcxo", CLK_SET_RATE_PARENT, APBC_TWSI2, 0x7, 0x3, 0x0, 0, &reset_lock}, | ||
154 | {MMP2_CLK_TWSI3, "twsi3_clk", "vctcxo", CLK_SET_RATE_PARENT, APBC_TWSI3, 0x7, 0x3, 0x0, 0, &reset_lock}, | ||
155 | {MMP2_CLK_TWSI4, "twsi4_clk", "vctcxo", CLK_SET_RATE_PARENT, APBC_TWSI4, 0x7, 0x3, 0x0, 0, &reset_lock}, | ||
156 | {MMP2_CLK_TWSI5, "twsi5_clk", "vctcxo", CLK_SET_RATE_PARENT, APBC_TWSI5, 0x7, 0x3, 0x0, 0, &reset_lock}, | ||
157 | {MMP2_CLK_GPIO, "gpio_clk", "vctcxo", CLK_SET_RATE_PARENT, APBC_GPIO, 0x7, 0x3, 0x0, 0, &reset_lock}, | ||
158 | {MMP2_CLK_KPC, "kpc_clk", "clk32", CLK_SET_RATE_PARENT, APBC_KPC, 0x7, 0x3, 0x0, MMP_CLK_GATE_NEED_DELAY, &reset_lock}, | ||
159 | {MMP2_CLK_RTC, "rtc_clk", "clk32", CLK_SET_RATE_PARENT, APBC_RTC, 0x87, 0x83, 0x0, MMP_CLK_GATE_NEED_DELAY, &reset_lock}, | ||
160 | {MMP2_CLK_PWM0, "pwm0_clk", "pll1_48", CLK_SET_RATE_PARENT, APBC_PWM0, 0x7, 0x3, 0x0, 0, &reset_lock}, | ||
161 | {MMP2_CLK_PWM1, "pwm1_clk", "pll1_48", CLK_SET_RATE_PARENT, APBC_PWM1, 0x7, 0x3, 0x0, 0, &reset_lock}, | ||
162 | {MMP2_CLK_PWM2, "pwm2_clk", "pll1_48", CLK_SET_RATE_PARENT, APBC_PWM2, 0x7, 0x3, 0x0, 0, &reset_lock}, | ||
163 | {MMP2_CLK_PWM3, "pwm3_clk", "pll1_48", CLK_SET_RATE_PARENT, APBC_PWM3, 0x7, 0x3, 0x0, 0, &reset_lock}, | ||
164 | /* The gate clocks has mux parent. */ | ||
165 | {MMP2_CLK_UART0, "uart0_clk", "uart0_mux", CLK_SET_RATE_PARENT, APBC_UART0, 0x7, 0x3, 0x0, 0, &uart0_lock}, | ||
166 | {MMP2_CLK_UART1, "uart1_clk", "uart1_mux", CLK_SET_RATE_PARENT, APBC_UART1, 0x7, 0x3, 0x0, 0, &uart1_lock}, | ||
167 | {MMP2_CLK_UART2, "uart2_clk", "uart2_mux", CLK_SET_RATE_PARENT, APBC_UART2, 0x7, 0x3, 0x0, 0, &uart2_lock}, | ||
168 | {MMP2_CLK_UART3, "uart3_clk", "uart3_mux", CLK_SET_RATE_PARENT, APBC_UART3, 0x7, 0x3, 0x0, 0, &uart2_lock}, | ||
169 | {MMP2_CLK_SSP0, "ssp0_clk", "ssp0_mux", CLK_SET_RATE_PARENT, APBC_SSP0, 0x7, 0x3, 0x0, 0, &ssp0_lock}, | ||
170 | {MMP2_CLK_SSP1, "ssp1_clk", "ssp1_mux", CLK_SET_RATE_PARENT, APBC_SSP1, 0x7, 0x3, 0x0, 0, &ssp1_lock}, | ||
171 | {MMP2_CLK_SSP2, "ssp2_clk", "ssp2_mux", CLK_SET_RATE_PARENT, APBC_SSP2, 0x7, 0x3, 0x0, 0, &ssp2_lock}, | ||
172 | {MMP2_CLK_SSP3, "ssp3_clk", "ssp3_mux", CLK_SET_RATE_PARENT, APBC_SSP3, 0x7, 0x3, 0x0, 0, &ssp3_lock}, | ||
173 | }; | ||
174 | |||
175 | static void mmp2_apb_periph_clk_init(struct mmp2_clk_unit *pxa_unit) | ||
176 | { | ||
177 | struct mmp_clk_unit *unit = &pxa_unit->unit; | ||
178 | |||
179 | mmp_register_mux_clks(unit, apbc_mux_clks, pxa_unit->apbc_base, | ||
180 | ARRAY_SIZE(apbc_mux_clks)); | ||
181 | |||
182 | mmp_register_gate_clks(unit, apbc_gate_clks, pxa_unit->apbc_base, | ||
183 | ARRAY_SIZE(apbc_gate_clks)); | ||
184 | } | ||
185 | |||
186 | static DEFINE_SPINLOCK(sdh_lock); | ||
187 | static const char *sdh_parent_names[] = {"pll1_4", "pll2", "usb_pll", "pll1"}; | ||
188 | static struct mmp_clk_mix_config sdh_mix_config = { | ||
189 | .reg_info = DEFINE_MIX_REG_INFO(4, 10, 2, 8, 32), | ||
190 | }; | ||
191 | |||
192 | static DEFINE_SPINLOCK(usb_lock); | ||
193 | |||
194 | static DEFINE_SPINLOCK(disp0_lock); | ||
195 | static DEFINE_SPINLOCK(disp1_lock); | ||
196 | static const char *disp_parent_names[] = {"pll1", "pll1_16", "pll2", "vctcxo"}; | ||
197 | |||
198 | static DEFINE_SPINLOCK(ccic0_lock); | ||
199 | static DEFINE_SPINLOCK(ccic1_lock); | ||
200 | static const char *ccic_parent_names[] = {"pll1_2", "pll1_16", "vctcxo"}; | ||
201 | static struct mmp_clk_mix_config ccic0_mix_config = { | ||
202 | .reg_info = DEFINE_MIX_REG_INFO(4, 17, 2, 6, 32), | ||
203 | }; | ||
204 | static struct mmp_clk_mix_config ccic1_mix_config = { | ||
205 | .reg_info = DEFINE_MIX_REG_INFO(4, 16, 2, 6, 32), | ||
206 | }; | ||
207 | |||
208 | static struct mmp_param_mux_clk apmu_mux_clks[] = { | ||
209 | {MMP2_CLK_DISP0_MUX, "disp0_mux", disp_parent_names, ARRAY_SIZE(disp_parent_names), CLK_SET_RATE_PARENT, APMU_DISP0, 6, 2, 0, &disp0_lock}, | ||
210 | {MMP2_CLK_DISP1_MUX, "disp1_mux", disp_parent_names, ARRAY_SIZE(disp_parent_names), CLK_SET_RATE_PARENT, APMU_DISP1, 6, 2, 0, &disp1_lock}, | ||
211 | }; | ||
212 | |||
213 | static struct mmp_param_div_clk apmu_div_clks[] = { | ||
214 | {0, "disp0_div", "disp0_mux", CLK_SET_RATE_PARENT, APMU_DISP0, 8, 4, 0, &disp0_lock}, | ||
215 | {0, "disp0_sphy_div", "disp0_mux", CLK_SET_RATE_PARENT, APMU_DISP0, 15, 5, 0, &disp0_lock}, | ||
216 | {0, "disp1_div", "disp1_mux", CLK_SET_RATE_PARENT, APMU_DISP1, 8, 4, 0, &disp1_lock}, | ||
217 | {0, "ccic0_sphy_div", "ccic0_mix_clk", CLK_SET_RATE_PARENT, APMU_CCIC0, 10, 5, 0, &ccic0_lock}, | ||
218 | {0, "ccic1_sphy_div", "ccic1_mix_clk", CLK_SET_RATE_PARENT, APMU_CCIC1, 10, 5, 0, &ccic1_lock}, | ||
219 | }; | ||
220 | |||
221 | static struct mmp_param_gate_clk apmu_gate_clks[] = { | ||
222 | {MMP2_CLK_USB, "usb_clk", "usb_pll", 0, APMU_USB, 0x9, 0x9, 0x0, 0, &usb_lock}, | ||
223 | /* The gate clocks has mux parent. */ | ||
224 | {MMP2_CLK_SDH0, "sdh0_clk", "sdh_mix_clk", CLK_SET_RATE_PARENT, APMU_SDH0, 0x1b, 0x1b, 0x0, 0, &sdh_lock}, | ||
225 | {MMP2_CLK_SDH1, "sdh1_clk", "sdh_mix_clk", CLK_SET_RATE_PARENT, APMU_SDH1, 0x1b, 0x1b, 0x0, 0, &sdh_lock}, | ||
226 | {MMP2_CLK_SDH1, "sdh2_clk", "sdh_mix_clk", CLK_SET_RATE_PARENT, APMU_SDH2, 0x1b, 0x1b, 0x0, 0, &sdh_lock}, | ||
227 | {MMP2_CLK_SDH1, "sdh3_clk", "sdh_mix_clk", CLK_SET_RATE_PARENT, APMU_SDH3, 0x1b, 0x1b, 0x0, 0, &sdh_lock}, | ||
228 | {MMP2_CLK_DISP0, "disp0_clk", "disp0_div", CLK_SET_RATE_PARENT, APMU_DISP0, 0x1b, 0x1b, 0x0, 0, &disp0_lock}, | ||
229 | {MMP2_CLK_DISP0_SPHY, "disp0_sphy_clk", "disp0_sphy_div", CLK_SET_RATE_PARENT, APMU_DISP0, 0x1024, 0x1024, 0x0, 0, &disp0_lock}, | ||
230 | {MMP2_CLK_DISP1, "disp1_clk", "disp1_div", CLK_SET_RATE_PARENT, APMU_DISP1, 0x1b, 0x1b, 0x0, 0, &disp1_lock}, | ||
231 | {MMP2_CLK_CCIC_ARBITER, "ccic_arbiter", "vctcxo", CLK_SET_RATE_PARENT, APMU_CCIC0, 0x1800, 0x1800, 0x0, 0, &ccic0_lock}, | ||
232 | {MMP2_CLK_CCIC0, "ccic0_clk", "ccic0_mix_clk", CLK_SET_RATE_PARENT, APMU_CCIC0, 0x1b, 0x1b, 0x0, 0, &ccic0_lock}, | ||
233 | {MMP2_CLK_CCIC0_PHY, "ccic0_phy_clk", "ccic0_mix_clk", CLK_SET_RATE_PARENT, APMU_CCIC0, 0x24, 0x24, 0x0, 0, &ccic0_lock}, | ||
234 | {MMP2_CLK_CCIC0_SPHY, "ccic0_sphy_clk", "ccic0_sphy_div", CLK_SET_RATE_PARENT, APMU_CCIC0, 0x300, 0x300, 0x0, 0, &ccic0_lock}, | ||
235 | {MMP2_CLK_CCIC1, "ccic1_clk", "ccic1_mix_clk", CLK_SET_RATE_PARENT, APMU_CCIC1, 0x1b, 0x1b, 0x0, 0, &ccic1_lock}, | ||
236 | {MMP2_CLK_CCIC1_PHY, "ccic1_phy_clk", "ccic1_mix_clk", CLK_SET_RATE_PARENT, APMU_CCIC1, 0x24, 0x24, 0x0, 0, &ccic1_lock}, | ||
237 | {MMP2_CLK_CCIC1_SPHY, "ccic1_sphy_clk", "ccic1_sphy_div", CLK_SET_RATE_PARENT, APMU_CCIC1, 0x300, 0x300, 0x0, 0, &ccic1_lock}, | ||
238 | }; | ||
239 | |||
240 | static void mmp2_axi_periph_clk_init(struct mmp2_clk_unit *pxa_unit) | ||
241 | { | ||
242 | struct clk *clk; | ||
243 | struct mmp_clk_unit *unit = &pxa_unit->unit; | ||
244 | |||
245 | sdh_mix_config.reg_info.reg_clk_ctrl = pxa_unit->apmu_base + APMU_SDH0; | ||
246 | clk = mmp_clk_register_mix(NULL, "sdh_mix_clk", sdh_parent_names, | ||
247 | ARRAY_SIZE(sdh_parent_names), | ||
248 | CLK_SET_RATE_PARENT, | ||
249 | &sdh_mix_config, &sdh_lock); | ||
250 | |||
251 | ccic0_mix_config.reg_info.reg_clk_ctrl = pxa_unit->apmu_base + APMU_CCIC0; | ||
252 | clk = mmp_clk_register_mix(NULL, "ccic0_mix_clk", ccic_parent_names, | ||
253 | ARRAY_SIZE(ccic_parent_names), | ||
254 | CLK_SET_RATE_PARENT, | ||
255 | &ccic0_mix_config, &ccic0_lock); | ||
256 | mmp_clk_add(unit, MMP2_CLK_CCIC0_MIX, clk); | ||
257 | |||
258 | ccic1_mix_config.reg_info.reg_clk_ctrl = pxa_unit->apmu_base + APMU_CCIC1; | ||
259 | clk = mmp_clk_register_mix(NULL, "ccic1_mix_clk", ccic_parent_names, | ||
260 | ARRAY_SIZE(ccic_parent_names), | ||
261 | CLK_SET_RATE_PARENT, | ||
262 | &ccic1_mix_config, &ccic1_lock); | ||
263 | mmp_clk_add(unit, MMP2_CLK_CCIC1_MIX, clk); | ||
264 | |||
265 | mmp_register_mux_clks(unit, apmu_mux_clks, pxa_unit->apmu_base, | ||
266 | ARRAY_SIZE(apmu_mux_clks)); | ||
267 | |||
268 | mmp_register_div_clks(unit, apmu_div_clks, pxa_unit->apmu_base, | ||
269 | ARRAY_SIZE(apmu_div_clks)); | ||
270 | |||
271 | mmp_register_gate_clks(unit, apmu_gate_clks, pxa_unit->apmu_base, | ||
272 | ARRAY_SIZE(apmu_gate_clks)); | ||
273 | } | ||
274 | |||
275 | static void mmp2_clk_reset_init(struct device_node *np, | ||
276 | struct mmp2_clk_unit *pxa_unit) | ||
277 | { | ||
278 | struct mmp_clk_reset_cell *cells; | ||
279 | int i, nr_resets; | ||
280 | |||
281 | nr_resets = ARRAY_SIZE(apbc_gate_clks); | ||
282 | cells = kcalloc(nr_resets, sizeof(*cells), GFP_KERNEL); | ||
283 | if (!cells) | ||
284 | return; | ||
285 | |||
286 | for (i = 0; i < nr_resets; i++) { | ||
287 | cells[i].clk_id = apbc_gate_clks[i].id; | ||
288 | cells[i].reg = pxa_unit->apbc_base + apbc_gate_clks[i].offset; | ||
289 | cells[i].flags = 0; | ||
290 | cells[i].lock = apbc_gate_clks[i].lock; | ||
291 | cells[i].bits = 0x4; | ||
292 | } | ||
293 | |||
294 | mmp_clk_reset_register(np, cells, nr_resets); | ||
295 | } | ||
296 | |||
297 | static void __init mmp2_clk_init(struct device_node *np) | ||
298 | { | ||
299 | struct mmp2_clk_unit *pxa_unit; | ||
300 | |||
301 | pxa_unit = kzalloc(sizeof(*pxa_unit), GFP_KERNEL); | ||
302 | if (!pxa_unit) | ||
303 | return; | ||
304 | |||
305 | pxa_unit->mpmu_base = of_iomap(np, 0); | ||
306 | if (!pxa_unit->mpmu_base) { | ||
307 | pr_err("failed to map mpmu registers\n"); | ||
308 | return; | ||
309 | } | ||
310 | |||
311 | pxa_unit->apmu_base = of_iomap(np, 1); | ||
312 | if (!pxa_unit->mpmu_base) { | ||
313 | pr_err("failed to map apmu registers\n"); | ||
314 | return; | ||
315 | } | ||
316 | |||
317 | pxa_unit->apbc_base = of_iomap(np, 2); | ||
318 | if (!pxa_unit->apbc_base) { | ||
319 | pr_err("failed to map apbc registers\n"); | ||
320 | return; | ||
321 | } | ||
322 | |||
323 | mmp_clk_init(np, &pxa_unit->unit, MMP2_NR_CLKS); | ||
324 | |||
325 | mmp2_pll_init(pxa_unit); | ||
326 | |||
327 | mmp2_apb_periph_clk_init(pxa_unit); | ||
328 | |||
329 | mmp2_axi_periph_clk_init(pxa_unit); | ||
330 | |||
331 | mmp2_clk_reset_init(np, pxa_unit); | ||
332 | } | ||
333 | |||
334 | CLK_OF_DECLARE(mmp2_clk, "marvell,mmp2-clock", mmp2_clk_init); | ||
diff --git a/drivers/clk/mmp/clk-of-pxa168.c b/drivers/clk/mmp/clk-of-pxa168.c new file mode 100644 index 000000000000..5b1810dc4bd2 --- /dev/null +++ b/drivers/clk/mmp/clk-of-pxa168.c | |||
@@ -0,0 +1,279 @@ | |||
1 | /* | ||
2 | * pxa168 clock framework source file | ||
3 | * | ||
4 | * Copyright (C) 2012 Marvell | ||
5 | * Chao Xie <xiechao.mail@gmail.com> | ||
6 | * | ||
7 | * This file is licensed under the terms of the GNU General Public | ||
8 | * License version 2. This program is licensed "as is" without any | ||
9 | * warranty of any kind, whether express or implied. | ||
10 | */ | ||
11 | |||
12 | #include <linux/module.h> | ||
13 | #include <linux/kernel.h> | ||
14 | #include <linux/spinlock.h> | ||
15 | #include <linux/io.h> | ||
16 | #include <linux/delay.h> | ||
17 | #include <linux/err.h> | ||
18 | #include <linux/of_address.h> | ||
19 | |||
20 | #include <dt-bindings/clock/marvell,pxa168.h> | ||
21 | |||
22 | #include "clk.h" | ||
23 | #include "reset.h" | ||
24 | |||
25 | #define APBC_RTC 0x28 | ||
26 | #define APBC_TWSI0 0x2c | ||
27 | #define APBC_KPC 0x30 | ||
28 | #define APBC_UART0 0x0 | ||
29 | #define APBC_UART1 0x4 | ||
30 | #define APBC_GPIO 0x8 | ||
31 | #define APBC_PWM0 0xc | ||
32 | #define APBC_PWM1 0x10 | ||
33 | #define APBC_PWM2 0x14 | ||
34 | #define APBC_PWM3 0x18 | ||
35 | #define APBC_SSP0 0x81c | ||
36 | #define APBC_SSP1 0x820 | ||
37 | #define APBC_SSP2 0x84c | ||
38 | #define APBC_SSP3 0x858 | ||
39 | #define APBC_SSP4 0x85c | ||
40 | #define APBC_TWSI1 0x6c | ||
41 | #define APBC_UART2 0x70 | ||
42 | #define APMU_SDH0 0x54 | ||
43 | #define APMU_SDH1 0x58 | ||
44 | #define APMU_USB 0x5c | ||
45 | #define APMU_DISP0 0x4c | ||
46 | #define APMU_CCIC0 0x50 | ||
47 | #define APMU_DFC 0x60 | ||
48 | #define MPMU_UART_PLL 0x14 | ||
49 | |||
50 | struct pxa168_clk_unit { | ||
51 | struct mmp_clk_unit unit; | ||
52 | void __iomem *mpmu_base; | ||
53 | void __iomem *apmu_base; | ||
54 | void __iomem *apbc_base; | ||
55 | }; | ||
56 | |||
57 | static struct mmp_param_fixed_rate_clk fixed_rate_clks[] = { | ||
58 | {PXA168_CLK_CLK32, "clk32", NULL, CLK_IS_ROOT, 32768}, | ||
59 | {PXA168_CLK_VCTCXO, "vctcxo", NULL, CLK_IS_ROOT, 26000000}, | ||
60 | {PXA168_CLK_PLL1, "pll1", NULL, CLK_IS_ROOT, 624000000}, | ||
61 | }; | ||
62 | |||
63 | static struct mmp_param_fixed_factor_clk fixed_factor_clks[] = { | ||
64 | {PXA168_CLK_PLL1_2, "pll1_2", "pll1", 1, 2, 0}, | ||
65 | {PXA168_CLK_PLL1_4, "pll1_4", "pll1_2", 1, 2, 0}, | ||
66 | {PXA168_CLK_PLL1_8, "pll1_8", "pll1_4", 1, 2, 0}, | ||
67 | {PXA168_CLK_PLL1_16, "pll1_16", "pll1_8", 1, 2, 0}, | ||
68 | {PXA168_CLK_PLL1_6, "pll1_6", "pll1_2", 1, 3, 0}, | ||
69 | {PXA168_CLK_PLL1_12, "pll1_12", "pll1_6", 1, 2, 0}, | ||
70 | {PXA168_CLK_PLL1_24, "pll1_24", "pll1_12", 1, 2, 0}, | ||
71 | {PXA168_CLK_PLL1_48, "pll1_48", "pll1_24", 1, 2, 0}, | ||
72 | {PXA168_CLK_PLL1_96, "pll1_96", "pll1_48", 1, 2, 0}, | ||
73 | {PXA168_CLK_PLL1_13, "pll1_13", "pll1", 1, 13, 0}, | ||
74 | {PXA168_CLK_PLL1_13_1_5, "pll1_13_1_5", "pll1_13", 2, 3, 0}, | ||
75 | {PXA168_CLK_PLL1_2_1_5, "pll1_2_1_5", "pll1_2", 2, 3, 0}, | ||
76 | {PXA168_CLK_PLL1_3_16, "pll1_3_16", "pll1", 3, 16, 0}, | ||
77 | }; | ||
78 | |||
79 | static struct mmp_clk_factor_masks uart_factor_masks = { | ||
80 | .factor = 2, | ||
81 | .num_mask = 0x1fff, | ||
82 | .den_mask = 0x1fff, | ||
83 | .num_shift = 16, | ||
84 | .den_shift = 0, | ||
85 | }; | ||
86 | |||
87 | static struct mmp_clk_factor_tbl uart_factor_tbl[] = { | ||
88 | {.num = 8125, .den = 1536}, /*14.745MHZ */ | ||
89 | }; | ||
90 | |||
91 | static void pxa168_pll_init(struct pxa168_clk_unit *pxa_unit) | ||
92 | { | ||
93 | struct clk *clk; | ||
94 | struct mmp_clk_unit *unit = &pxa_unit->unit; | ||
95 | |||
96 | mmp_register_fixed_rate_clks(unit, fixed_rate_clks, | ||
97 | ARRAY_SIZE(fixed_rate_clks)); | ||
98 | |||
99 | mmp_register_fixed_factor_clks(unit, fixed_factor_clks, | ||
100 | ARRAY_SIZE(fixed_factor_clks)); | ||
101 | |||
102 | clk = mmp_clk_register_factor("uart_pll", "pll1_4", | ||
103 | CLK_SET_RATE_PARENT, | ||
104 | pxa_unit->mpmu_base + MPMU_UART_PLL, | ||
105 | &uart_factor_masks, uart_factor_tbl, | ||
106 | ARRAY_SIZE(uart_factor_tbl), NULL); | ||
107 | mmp_clk_add(unit, PXA168_CLK_UART_PLL, clk); | ||
108 | } | ||
109 | |||
110 | static DEFINE_SPINLOCK(uart0_lock); | ||
111 | static DEFINE_SPINLOCK(uart1_lock); | ||
112 | static DEFINE_SPINLOCK(uart2_lock); | ||
113 | static const char *uart_parent_names[] = {"pll1_3_16", "uart_pll"}; | ||
114 | |||
115 | static DEFINE_SPINLOCK(ssp0_lock); | ||
116 | static DEFINE_SPINLOCK(ssp1_lock); | ||
117 | static DEFINE_SPINLOCK(ssp2_lock); | ||
118 | static DEFINE_SPINLOCK(ssp3_lock); | ||
119 | static DEFINE_SPINLOCK(ssp4_lock); | ||
120 | static const char *ssp_parent_names[] = {"pll1_96", "pll1_48", "pll1_24", "pll1_12"}; | ||
121 | |||
122 | static DEFINE_SPINLOCK(reset_lock); | ||
123 | |||
124 | static struct mmp_param_mux_clk apbc_mux_clks[] = { | ||
125 | {0, "uart0_mux", uart_parent_names, ARRAY_SIZE(uart_parent_names), CLK_SET_RATE_PARENT, APBC_UART0, 4, 3, 0, &uart0_lock}, | ||
126 | {0, "uart1_mux", uart_parent_names, ARRAY_SIZE(uart_parent_names), CLK_SET_RATE_PARENT, APBC_UART1, 4, 3, 0, &uart1_lock}, | ||
127 | {0, "uart2_mux", uart_parent_names, ARRAY_SIZE(uart_parent_names), CLK_SET_RATE_PARENT, APBC_UART2, 4, 3, 0, &uart2_lock}, | ||
128 | {0, "ssp0_mux", ssp_parent_names, ARRAY_SIZE(ssp_parent_names), CLK_SET_RATE_PARENT, APBC_SSP0, 4, 3, 0, &ssp0_lock}, | ||
129 | {0, "ssp1_mux", ssp_parent_names, ARRAY_SIZE(ssp_parent_names), CLK_SET_RATE_PARENT, APBC_SSP1, 4, 3, 0, &ssp1_lock}, | ||
130 | {0, "ssp2_mux", ssp_parent_names, ARRAY_SIZE(ssp_parent_names), CLK_SET_RATE_PARENT, APBC_SSP2, 4, 3, 0, &ssp2_lock}, | ||
131 | {0, "ssp3_mux", ssp_parent_names, ARRAY_SIZE(ssp_parent_names), CLK_SET_RATE_PARENT, APBC_SSP3, 4, 3, 0, &ssp3_lock}, | ||
132 | {0, "ssp4_mux", ssp_parent_names, ARRAY_SIZE(ssp_parent_names), CLK_SET_RATE_PARENT, APBC_SSP4, 4, 3, 0, &ssp4_lock}, | ||
133 | }; | ||
134 | |||
135 | static struct mmp_param_gate_clk apbc_gate_clks[] = { | ||
136 | {PXA168_CLK_TWSI0, "twsi0_clk", "pll1_13_1_5", CLK_SET_RATE_PARENT, APBC_TWSI0, 0x3, 0x3, 0x0, 0, &reset_lock}, | ||
137 | {PXA168_CLK_TWSI1, "twsi1_clk", "pll1_13_1_5", CLK_SET_RATE_PARENT, APBC_TWSI1, 0x3, 0x3, 0x0, 0, &reset_lock}, | ||
138 | {PXA168_CLK_GPIO, "gpio_clk", "vctcxo", CLK_SET_RATE_PARENT, APBC_GPIO, 0x3, 0x3, 0x0, 0, &reset_lock}, | ||
139 | {PXA168_CLK_KPC, "kpc_clk", "clk32", CLK_SET_RATE_PARENT, APBC_KPC, 0x3, 0x3, 0x0, MMP_CLK_GATE_NEED_DELAY, NULL}, | ||
140 | {PXA168_CLK_RTC, "rtc_clk", "clk32", CLK_SET_RATE_PARENT, APBC_RTC, 0x83, 0x83, 0x0, MMP_CLK_GATE_NEED_DELAY, NULL}, | ||
141 | {PXA168_CLK_PWM0, "pwm0_clk", "pll1_48", CLK_SET_RATE_PARENT, APBC_PWM0, 0x3, 0x3, 0x0, 0, &reset_lock}, | ||
142 | {PXA168_CLK_PWM1, "pwm1_clk", "pll1_48", CLK_SET_RATE_PARENT, APBC_PWM1, 0x3, 0x3, 0x0, 0, &reset_lock}, | ||
143 | {PXA168_CLK_PWM2, "pwm2_clk", "pll1_48", CLK_SET_RATE_PARENT, APBC_PWM2, 0x3, 0x3, 0x0, 0, &reset_lock}, | ||
144 | {PXA168_CLK_PWM3, "pwm3_clk", "pll1_48", CLK_SET_RATE_PARENT, APBC_PWM3, 0x3, 0x3, 0x0, 0, &reset_lock}, | ||
145 | /* The gate clocks has mux parent. */ | ||
146 | {PXA168_CLK_UART0, "uart0_clk", "uart0_mux", CLK_SET_RATE_PARENT, APBC_UART0, 0x3, 0x3, 0x0, 0, &uart0_lock}, | ||
147 | {PXA168_CLK_UART1, "uart1_clk", "uart1_mux", CLK_SET_RATE_PARENT, APBC_UART1, 0x3, 0x3, 0x0, 0, &uart1_lock}, | ||
148 | {PXA168_CLK_UART2, "uart2_clk", "uart2_mux", CLK_SET_RATE_PARENT, APBC_UART2, 0x3, 0x3, 0x0, 0, &uart2_lock}, | ||
149 | {PXA168_CLK_SSP0, "ssp0_clk", "ssp0_mux", CLK_SET_RATE_PARENT, APBC_SSP0, 0x3, 0x3, 0x0, 0, &ssp0_lock}, | ||
150 | {PXA168_CLK_SSP1, "ssp1_clk", "ssp1_mux", CLK_SET_RATE_PARENT, APBC_SSP1, 0x3, 0x3, 0x0, 0, &ssp1_lock}, | ||
151 | {PXA168_CLK_SSP2, "ssp2_clk", "ssp2_mux", CLK_SET_RATE_PARENT, APBC_SSP2, 0x3, 0x3, 0x0, 0, &ssp2_lock}, | ||
152 | {PXA168_CLK_SSP3, "ssp3_clk", "ssp3_mux", CLK_SET_RATE_PARENT, APBC_SSP3, 0x3, 0x3, 0x0, 0, &ssp3_lock}, | ||
153 | {PXA168_CLK_SSP4, "ssp4_clk", "ssp4_mux", CLK_SET_RATE_PARENT, APBC_SSP4, 0x3, 0x3, 0x0, 0, &ssp4_lock}, | ||
154 | }; | ||
155 | |||
156 | static void pxa168_apb_periph_clk_init(struct pxa168_clk_unit *pxa_unit) | ||
157 | { | ||
158 | struct mmp_clk_unit *unit = &pxa_unit->unit; | ||
159 | |||
160 | mmp_register_mux_clks(unit, apbc_mux_clks, pxa_unit->apbc_base, | ||
161 | ARRAY_SIZE(apbc_mux_clks)); | ||
162 | |||
163 | mmp_register_gate_clks(unit, apbc_gate_clks, pxa_unit->apbc_base, | ||
164 | ARRAY_SIZE(apbc_gate_clks)); | ||
165 | |||
166 | } | ||
167 | |||
168 | static DEFINE_SPINLOCK(sdh0_lock); | ||
169 | static DEFINE_SPINLOCK(sdh1_lock); | ||
170 | static const char *sdh_parent_names[] = {"pll1_12", "pll1_13"}; | ||
171 | |||
172 | static DEFINE_SPINLOCK(usb_lock); | ||
173 | |||
174 | static DEFINE_SPINLOCK(disp0_lock); | ||
175 | static const char *disp_parent_names[] = {"pll1_2", "pll1_12"}; | ||
176 | |||
177 | static DEFINE_SPINLOCK(ccic0_lock); | ||
178 | static const char *ccic_parent_names[] = {"pll1_2", "pll1_12"}; | ||
179 | static const char *ccic_phy_parent_names[] = {"pll1_6", "pll1_12"}; | ||
180 | |||
181 | static struct mmp_param_mux_clk apmu_mux_clks[] = { | ||
182 | {0, "sdh0_mux", sdh_parent_names, ARRAY_SIZE(sdh_parent_names), CLK_SET_RATE_PARENT, APMU_SDH0, 6, 1, 0, &sdh0_lock}, | ||
183 | {0, "sdh1_mux", sdh_parent_names, ARRAY_SIZE(sdh_parent_names), CLK_SET_RATE_PARENT, APMU_SDH1, 6, 1, 0, &sdh1_lock}, | ||
184 | {0, "disp0_mux", disp_parent_names, ARRAY_SIZE(disp_parent_names), CLK_SET_RATE_PARENT, APMU_DISP0, 6, 1, 0, &disp0_lock}, | ||
185 | {0, "ccic0_mux", ccic_parent_names, ARRAY_SIZE(ccic_parent_names), CLK_SET_RATE_PARENT, APMU_CCIC0, 6, 1, 0, &ccic0_lock}, | ||
186 | {0, "ccic0_phy_mux", ccic_phy_parent_names, ARRAY_SIZE(ccic_phy_parent_names), CLK_SET_RATE_PARENT, APMU_CCIC0, 7, 1, 0, &ccic0_lock}, | ||
187 | }; | ||
188 | |||
189 | static struct mmp_param_div_clk apmu_div_clks[] = { | ||
190 | {0, "ccic0_sphy_div", "ccic0_mux", CLK_SET_RATE_PARENT, APMU_CCIC0, 10, 5, 0, &ccic0_lock}, | ||
191 | }; | ||
192 | |||
193 | static struct mmp_param_gate_clk apmu_gate_clks[] = { | ||
194 | {PXA168_CLK_DFC, "dfc_clk", "pll1_4", CLK_SET_RATE_PARENT, APMU_DFC, 0x19b, 0x19b, 0x0, 0, NULL}, | ||
195 | {PXA168_CLK_USB, "usb_clk", "usb_pll", 0, APMU_USB, 0x9, 0x9, 0x0, 0, &usb_lock}, | ||
196 | {PXA168_CLK_SPH, "sph_clk", "usb_pll", 0, APMU_USB, 0x12, 0x12, 0x0, 0, &usb_lock}, | ||
197 | /* The gate clocks has mux parent. */ | ||
198 | {PXA168_CLK_SDH0, "sdh0_clk", "sdh0_mux", CLK_SET_RATE_PARENT, APMU_SDH0, 0x1b, 0x1b, 0x0, 0, &sdh0_lock}, | ||
199 | {PXA168_CLK_SDH1, "sdh1_clk", "sdh1_mux", CLK_SET_RATE_PARENT, APMU_SDH1, 0x1b, 0x1b, 0x0, 0, &sdh1_lock}, | ||
200 | {PXA168_CLK_DISP0, "disp0_clk", "disp0_mux", CLK_SET_RATE_PARENT, APMU_DISP0, 0x1b, 0x1b, 0x0, 0, &disp0_lock}, | ||
201 | {PXA168_CLK_CCIC0, "ccic0_clk", "ccic0_mux", CLK_SET_RATE_PARENT, APMU_CCIC0, 0x1b, 0x1b, 0x0, 0, &ccic0_lock}, | ||
202 | {PXA168_CLK_CCIC0_PHY, "ccic0_phy_clk", "ccic0_phy_mux", CLK_SET_RATE_PARENT, APMU_CCIC0, 0x24, 0x24, 0x0, 0, &ccic0_lock}, | ||
203 | {PXA168_CLK_CCIC0_SPHY, "ccic0_sphy_clk", "ccic0_sphy_div", CLK_SET_RATE_PARENT, APMU_CCIC0, 0x300, 0x300, 0x0, 0, &ccic0_lock}, | ||
204 | }; | ||
205 | |||
206 | static void pxa168_axi_periph_clk_init(struct pxa168_clk_unit *pxa_unit) | ||
207 | { | ||
208 | struct mmp_clk_unit *unit = &pxa_unit->unit; | ||
209 | |||
210 | mmp_register_mux_clks(unit, apmu_mux_clks, pxa_unit->apmu_base, | ||
211 | ARRAY_SIZE(apmu_mux_clks)); | ||
212 | |||
213 | mmp_register_div_clks(unit, apmu_div_clks, pxa_unit->apmu_base, | ||
214 | ARRAY_SIZE(apmu_div_clks)); | ||
215 | |||
216 | mmp_register_gate_clks(unit, apmu_gate_clks, pxa_unit->apmu_base, | ||
217 | ARRAY_SIZE(apmu_gate_clks)); | ||
218 | } | ||
219 | |||
220 | static void pxa168_clk_reset_init(struct device_node *np, | ||
221 | struct pxa168_clk_unit *pxa_unit) | ||
222 | { | ||
223 | struct mmp_clk_reset_cell *cells; | ||
224 | int i, nr_resets; | ||
225 | |||
226 | nr_resets = ARRAY_SIZE(apbc_gate_clks); | ||
227 | cells = kcalloc(nr_resets, sizeof(*cells), GFP_KERNEL); | ||
228 | if (!cells) | ||
229 | return; | ||
230 | |||
231 | for (i = 0; i < nr_resets; i++) { | ||
232 | cells[i].clk_id = apbc_gate_clks[i].id; | ||
233 | cells[i].reg = pxa_unit->apbc_base + apbc_gate_clks[i].offset; | ||
234 | cells[i].flags = 0; | ||
235 | cells[i].lock = apbc_gate_clks[i].lock; | ||
236 | cells[i].bits = 0x4; | ||
237 | } | ||
238 | |||
239 | mmp_clk_reset_register(np, cells, nr_resets); | ||
240 | } | ||
241 | |||
242 | static void __init pxa168_clk_init(struct device_node *np) | ||
243 | { | ||
244 | struct pxa168_clk_unit *pxa_unit; | ||
245 | |||
246 | pxa_unit = kzalloc(sizeof(*pxa_unit), GFP_KERNEL); | ||
247 | if (!pxa_unit) | ||
248 | return; | ||
249 | |||
250 | pxa_unit->mpmu_base = of_iomap(np, 0); | ||
251 | if (!pxa_unit->mpmu_base) { | ||
252 | pr_err("failed to map mpmu registers\n"); | ||
253 | return; | ||
254 | } | ||
255 | |||
256 | pxa_unit->apmu_base = of_iomap(np, 1); | ||
257 | if (!pxa_unit->mpmu_base) { | ||
258 | pr_err("failed to map apmu registers\n"); | ||
259 | return; | ||
260 | } | ||
261 | |||
262 | pxa_unit->apbc_base = of_iomap(np, 2); | ||
263 | if (!pxa_unit->apbc_base) { | ||
264 | pr_err("failed to map apbc registers\n"); | ||
265 | return; | ||
266 | } | ||
267 | |||
268 | mmp_clk_init(np, &pxa_unit->unit, PXA168_NR_CLKS); | ||
269 | |||
270 | pxa168_pll_init(pxa_unit); | ||
271 | |||
272 | pxa168_apb_periph_clk_init(pxa_unit); | ||
273 | |||
274 | pxa168_axi_periph_clk_init(pxa_unit); | ||
275 | |||
276 | pxa168_clk_reset_init(np, pxa_unit); | ||
277 | } | ||
278 | |||
279 | CLK_OF_DECLARE(pxa168_clk, "marvell,pxa168-clock", pxa168_clk_init); | ||
diff --git a/drivers/clk/mmp/clk-of-pxa910.c b/drivers/clk/mmp/clk-of-pxa910.c new file mode 100644 index 000000000000..5e3c80dad336 --- /dev/null +++ b/drivers/clk/mmp/clk-of-pxa910.c | |||
@@ -0,0 +1,301 @@ | |||
1 | /* | ||
2 | * pxa910 clock framework source file | ||
3 | * | ||
4 | * Copyright (C) 2012 Marvell | ||
5 | * Chao Xie <xiechao.mail@gmail.com> | ||
6 | * | ||
7 | * This file is licensed under the terms of the GNU General Public | ||
8 | * License version 2. This program is licensed "as is" without any | ||
9 | * warranty of any kind, whether express or implied. | ||
10 | */ | ||
11 | |||
12 | #include <linux/module.h> | ||
13 | #include <linux/kernel.h> | ||
14 | #include <linux/spinlock.h> | ||
15 | #include <linux/io.h> | ||
16 | #include <linux/delay.h> | ||
17 | #include <linux/err.h> | ||
18 | #include <linux/of_address.h> | ||
19 | |||
20 | #include <dt-bindings/clock/marvell,pxa910.h> | ||
21 | |||
22 | #include "clk.h" | ||
23 | #include "reset.h" | ||
24 | |||
25 | #define APBC_RTC 0x28 | ||
26 | #define APBC_TWSI0 0x2c | ||
27 | #define APBC_KPC 0x18 | ||
28 | #define APBC_UART0 0x0 | ||
29 | #define APBC_UART1 0x4 | ||
30 | #define APBC_GPIO 0x8 | ||
31 | #define APBC_PWM0 0xc | ||
32 | #define APBC_PWM1 0x10 | ||
33 | #define APBC_PWM2 0x14 | ||
34 | #define APBC_PWM3 0x18 | ||
35 | #define APBC_SSP0 0x1c | ||
36 | #define APBC_SSP1 0x20 | ||
37 | #define APBC_SSP2 0x4c | ||
38 | #define APBCP_TWSI1 0x28 | ||
39 | #define APBCP_UART2 0x1c | ||
40 | #define APMU_SDH0 0x54 | ||
41 | #define APMU_SDH1 0x58 | ||
42 | #define APMU_USB 0x5c | ||
43 | #define APMU_DISP0 0x4c | ||
44 | #define APMU_CCIC0 0x50 | ||
45 | #define APMU_DFC 0x60 | ||
46 | #define MPMU_UART_PLL 0x14 | ||
47 | |||
48 | struct pxa910_clk_unit { | ||
49 | struct mmp_clk_unit unit; | ||
50 | void __iomem *mpmu_base; | ||
51 | void __iomem *apmu_base; | ||
52 | void __iomem *apbc_base; | ||
53 | void __iomem *apbcp_base; | ||
54 | }; | ||
55 | |||
56 | static struct mmp_param_fixed_rate_clk fixed_rate_clks[] = { | ||
57 | {PXA910_CLK_CLK32, "clk32", NULL, CLK_IS_ROOT, 32768}, | ||
58 | {PXA910_CLK_VCTCXO, "vctcxo", NULL, CLK_IS_ROOT, 26000000}, | ||
59 | {PXA910_CLK_PLL1, "pll1", NULL, CLK_IS_ROOT, 624000000}, | ||
60 | }; | ||
61 | |||
62 | static struct mmp_param_fixed_factor_clk fixed_factor_clks[] = { | ||
63 | {PXA910_CLK_PLL1_2, "pll1_2", "pll1", 1, 2, 0}, | ||
64 | {PXA910_CLK_PLL1_4, "pll1_4", "pll1_2", 1, 2, 0}, | ||
65 | {PXA910_CLK_PLL1_8, "pll1_8", "pll1_4", 1, 2, 0}, | ||
66 | {PXA910_CLK_PLL1_16, "pll1_16", "pll1_8", 1, 2, 0}, | ||
67 | {PXA910_CLK_PLL1_6, "pll1_6", "pll1_2", 1, 3, 0}, | ||
68 | {PXA910_CLK_PLL1_12, "pll1_12", "pll1_6", 1, 2, 0}, | ||
69 | {PXA910_CLK_PLL1_24, "pll1_24", "pll1_12", 1, 2, 0}, | ||
70 | {PXA910_CLK_PLL1_48, "pll1_48", "pll1_24", 1, 2, 0}, | ||
71 | {PXA910_CLK_PLL1_96, "pll1_96", "pll1_48", 1, 2, 0}, | ||
72 | {PXA910_CLK_PLL1_13, "pll1_13", "pll1", 1, 13, 0}, | ||
73 | {PXA910_CLK_PLL1_13_1_5, "pll1_13_1_5", "pll1_13", 2, 3, 0}, | ||
74 | {PXA910_CLK_PLL1_2_1_5, "pll1_2_1_5", "pll1_2", 2, 3, 0}, | ||
75 | {PXA910_CLK_PLL1_3_16, "pll1_3_16", "pll1", 3, 16, 0}, | ||
76 | }; | ||
77 | |||
78 | static struct mmp_clk_factor_masks uart_factor_masks = { | ||
79 | .factor = 2, | ||
80 | .num_mask = 0x1fff, | ||
81 | .den_mask = 0x1fff, | ||
82 | .num_shift = 16, | ||
83 | .den_shift = 0, | ||
84 | }; | ||
85 | |||
86 | static struct mmp_clk_factor_tbl uart_factor_tbl[] = { | ||
87 | {.num = 8125, .den = 1536}, /*14.745MHZ */ | ||
88 | }; | ||
89 | |||
90 | static void pxa910_pll_init(struct pxa910_clk_unit *pxa_unit) | ||
91 | { | ||
92 | struct clk *clk; | ||
93 | struct mmp_clk_unit *unit = &pxa_unit->unit; | ||
94 | |||
95 | mmp_register_fixed_rate_clks(unit, fixed_rate_clks, | ||
96 | ARRAY_SIZE(fixed_rate_clks)); | ||
97 | |||
98 | mmp_register_fixed_factor_clks(unit, fixed_factor_clks, | ||
99 | ARRAY_SIZE(fixed_factor_clks)); | ||
100 | |||
101 | clk = mmp_clk_register_factor("uart_pll", "pll1_4", | ||
102 | CLK_SET_RATE_PARENT, | ||
103 | pxa_unit->mpmu_base + MPMU_UART_PLL, | ||
104 | &uart_factor_masks, uart_factor_tbl, | ||
105 | ARRAY_SIZE(uart_factor_tbl), NULL); | ||
106 | mmp_clk_add(unit, PXA910_CLK_UART_PLL, clk); | ||
107 | } | ||
108 | |||
109 | static DEFINE_SPINLOCK(uart0_lock); | ||
110 | static DEFINE_SPINLOCK(uart1_lock); | ||
111 | static DEFINE_SPINLOCK(uart2_lock); | ||
112 | static const char *uart_parent_names[] = {"pll1_3_16", "uart_pll"}; | ||
113 | |||
114 | static DEFINE_SPINLOCK(ssp0_lock); | ||
115 | static DEFINE_SPINLOCK(ssp1_lock); | ||
116 | static const char *ssp_parent_names[] = {"pll1_96", "pll1_48", "pll1_24", "pll1_12"}; | ||
117 | |||
118 | static DEFINE_SPINLOCK(reset_lock); | ||
119 | |||
120 | static struct mmp_param_mux_clk apbc_mux_clks[] = { | ||
121 | {0, "uart0_mux", uart_parent_names, ARRAY_SIZE(uart_parent_names), CLK_SET_RATE_PARENT, APBC_UART0, 4, 3, 0, &uart0_lock}, | ||
122 | {0, "uart1_mux", uart_parent_names, ARRAY_SIZE(uart_parent_names), CLK_SET_RATE_PARENT, APBC_UART1, 4, 3, 0, &uart1_lock}, | ||
123 | {0, "ssp0_mux", ssp_parent_names, ARRAY_SIZE(ssp_parent_names), CLK_SET_RATE_PARENT, APBC_SSP0, 4, 3, 0, &ssp0_lock}, | ||
124 | {0, "ssp1_mux", ssp_parent_names, ARRAY_SIZE(ssp_parent_names), CLK_SET_RATE_PARENT, APBC_SSP1, 4, 3, 0, &ssp1_lock}, | ||
125 | }; | ||
126 | |||
127 | static struct mmp_param_mux_clk apbcp_mux_clks[] = { | ||
128 | {0, "uart2_mux", uart_parent_names, ARRAY_SIZE(uart_parent_names), CLK_SET_RATE_PARENT, APBCP_UART2, 4, 3, 0, &uart2_lock}, | ||
129 | }; | ||
130 | |||
131 | static struct mmp_param_gate_clk apbc_gate_clks[] = { | ||
132 | {PXA910_CLK_TWSI0, "twsi0_clk", "pll1_13_1_5", CLK_SET_RATE_PARENT, APBC_TWSI0, 0x3, 0x3, 0x0, 0, &reset_lock}, | ||
133 | {PXA910_CLK_GPIO, "gpio_clk", "vctcxo", CLK_SET_RATE_PARENT, APBC_GPIO, 0x3, 0x3, 0x0, 0, &reset_lock}, | ||
134 | {PXA910_CLK_KPC, "kpc_clk", "clk32", CLK_SET_RATE_PARENT, APBC_KPC, 0x3, 0x3, 0x0, MMP_CLK_GATE_NEED_DELAY, NULL}, | ||
135 | {PXA910_CLK_RTC, "rtc_clk", "clk32", CLK_SET_RATE_PARENT, APBC_RTC, 0x83, 0x83, 0x0, MMP_CLK_GATE_NEED_DELAY, NULL}, | ||
136 | {PXA910_CLK_PWM0, "pwm0_clk", "pll1_48", CLK_SET_RATE_PARENT, APBC_PWM0, 0x3, 0x3, 0x0, 0, &reset_lock}, | ||
137 | {PXA910_CLK_PWM1, "pwm1_clk", "pll1_48", CLK_SET_RATE_PARENT, APBC_PWM1, 0x3, 0x3, 0x0, 0, &reset_lock}, | ||
138 | {PXA910_CLK_PWM2, "pwm2_clk", "pll1_48", CLK_SET_RATE_PARENT, APBC_PWM2, 0x3, 0x3, 0x0, 0, &reset_lock}, | ||
139 | {PXA910_CLK_PWM3, "pwm3_clk", "pll1_48", CLK_SET_RATE_PARENT, APBC_PWM3, 0x3, 0x3, 0x0, 0, &reset_lock}, | ||
140 | /* The gate clocks has mux parent. */ | ||
141 | {PXA910_CLK_UART0, "uart0_clk", "uart0_mux", CLK_SET_RATE_PARENT, APBC_UART0, 0x3, 0x3, 0x0, 0, &uart0_lock}, | ||
142 | {PXA910_CLK_UART1, "uart1_clk", "uart1_mux", CLK_SET_RATE_PARENT, APBC_UART1, 0x3, 0x3, 0x0, 0, &uart1_lock}, | ||
143 | {PXA910_CLK_SSP0, "ssp0_clk", "ssp0_mux", CLK_SET_RATE_PARENT, APBC_SSP0, 0x3, 0x3, 0x0, 0, &ssp0_lock}, | ||
144 | {PXA910_CLK_SSP1, "ssp1_clk", "ssp1_mux", CLK_SET_RATE_PARENT, APBC_SSP1, 0x3, 0x3, 0x0, 0, &ssp1_lock}, | ||
145 | }; | ||
146 | |||
147 | static struct mmp_param_gate_clk apbcp_gate_clks[] = { | ||
148 | {PXA910_CLK_TWSI1, "twsi1_clk", "pll1_13_1_5", CLK_SET_RATE_PARENT, APBCP_TWSI1, 0x3, 0x3, 0x0, 0, &reset_lock}, | ||
149 | /* The gate clocks has mux parent. */ | ||
150 | {PXA910_CLK_UART2, "uart2_clk", "uart2_mux", CLK_SET_RATE_PARENT, APBCP_UART2, 0x3, 0x3, 0x0, 0, &uart2_lock}, | ||
151 | }; | ||
152 | |||
153 | static void pxa910_apb_periph_clk_init(struct pxa910_clk_unit *pxa_unit) | ||
154 | { | ||
155 | struct mmp_clk_unit *unit = &pxa_unit->unit; | ||
156 | |||
157 | mmp_register_mux_clks(unit, apbc_mux_clks, pxa_unit->apbc_base, | ||
158 | ARRAY_SIZE(apbc_mux_clks)); | ||
159 | |||
160 | mmp_register_mux_clks(unit, apbcp_mux_clks, pxa_unit->apbcp_base, | ||
161 | ARRAY_SIZE(apbcp_mux_clks)); | ||
162 | |||
163 | mmp_register_gate_clks(unit, apbc_gate_clks, pxa_unit->apbc_base, | ||
164 | ARRAY_SIZE(apbc_gate_clks)); | ||
165 | |||
166 | mmp_register_gate_clks(unit, apbcp_gate_clks, pxa_unit->apbcp_base, | ||
167 | ARRAY_SIZE(apbcp_gate_clks)); | ||
168 | } | ||
169 | |||
170 | static DEFINE_SPINLOCK(sdh0_lock); | ||
171 | static DEFINE_SPINLOCK(sdh1_lock); | ||
172 | static const char *sdh_parent_names[] = {"pll1_12", "pll1_13"}; | ||
173 | |||
174 | static DEFINE_SPINLOCK(usb_lock); | ||
175 | |||
176 | static DEFINE_SPINLOCK(disp0_lock); | ||
177 | static const char *disp_parent_names[] = {"pll1_2", "pll1_12"}; | ||
178 | |||
179 | static DEFINE_SPINLOCK(ccic0_lock); | ||
180 | static const char *ccic_parent_names[] = {"pll1_2", "pll1_12"}; | ||
181 | static const char *ccic_phy_parent_names[] = {"pll1_6", "pll1_12"}; | ||
182 | |||
183 | static struct mmp_param_mux_clk apmu_mux_clks[] = { | ||
184 | {0, "sdh0_mux", sdh_parent_names, ARRAY_SIZE(sdh_parent_names), CLK_SET_RATE_PARENT, APMU_SDH0, 6, 1, 0, &sdh0_lock}, | ||
185 | {0, "sdh1_mux", sdh_parent_names, ARRAY_SIZE(sdh_parent_names), CLK_SET_RATE_PARENT, APMU_SDH1, 6, 1, 0, &sdh1_lock}, | ||
186 | {0, "disp0_mux", disp_parent_names, ARRAY_SIZE(disp_parent_names), CLK_SET_RATE_PARENT, APMU_DISP0, 6, 1, 0, &disp0_lock}, | ||
187 | {0, "ccic0_mux", ccic_parent_names, ARRAY_SIZE(ccic_parent_names), CLK_SET_RATE_PARENT, APMU_CCIC0, 6, 1, 0, &ccic0_lock}, | ||
188 | {0, "ccic0_phy_mux", ccic_phy_parent_names, ARRAY_SIZE(ccic_phy_parent_names), CLK_SET_RATE_PARENT, APMU_CCIC0, 7, 1, 0, &ccic0_lock}, | ||
189 | }; | ||
190 | |||
191 | static struct mmp_param_div_clk apmu_div_clks[] = { | ||
192 | {0, "ccic0_sphy_div", "ccic0_mux", CLK_SET_RATE_PARENT, APMU_CCIC0, 10, 5, 0, &ccic0_lock}, | ||
193 | }; | ||
194 | |||
195 | static struct mmp_param_gate_clk apmu_gate_clks[] = { | ||
196 | {PXA910_CLK_DFC, "dfc_clk", "pll1_4", CLK_SET_RATE_PARENT, APMU_DFC, 0x19b, 0x19b, 0x0, 0, NULL}, | ||
197 | {PXA910_CLK_USB, "usb_clk", "usb_pll", 0, APMU_USB, 0x9, 0x9, 0x0, 0, &usb_lock}, | ||
198 | {PXA910_CLK_SPH, "sph_clk", "usb_pll", 0, APMU_USB, 0x12, 0x12, 0x0, 0, &usb_lock}, | ||
199 | /* The gate clocks has mux parent. */ | ||
200 | {PXA910_CLK_SDH0, "sdh0_clk", "sdh0_mux", CLK_SET_RATE_PARENT, APMU_SDH0, 0x1b, 0x1b, 0x0, 0, &sdh0_lock}, | ||
201 | {PXA910_CLK_SDH1, "sdh1_clk", "sdh1_mux", CLK_SET_RATE_PARENT, APMU_SDH1, 0x1b, 0x1b, 0x0, 0, &sdh1_lock}, | ||
202 | {PXA910_CLK_DISP0, "disp0_clk", "disp0_mux", CLK_SET_RATE_PARENT, APMU_DISP0, 0x1b, 0x1b, 0x0, 0, &disp0_lock}, | ||
203 | {PXA910_CLK_CCIC0, "ccic0_clk", "ccic0_mux", CLK_SET_RATE_PARENT, APMU_CCIC0, 0x1b, 0x1b, 0x0, 0, &ccic0_lock}, | ||
204 | {PXA910_CLK_CCIC0_PHY, "ccic0_phy_clk", "ccic0_phy_mux", CLK_SET_RATE_PARENT, APMU_CCIC0, 0x24, 0x24, 0x0, 0, &ccic0_lock}, | ||
205 | {PXA910_CLK_CCIC0_SPHY, "ccic0_sphy_clk", "ccic0_sphy_div", CLK_SET_RATE_PARENT, APMU_CCIC0, 0x300, 0x300, 0x0, 0, &ccic0_lock}, | ||
206 | }; | ||
207 | |||
208 | static void pxa910_axi_periph_clk_init(struct pxa910_clk_unit *pxa_unit) | ||
209 | { | ||
210 | struct mmp_clk_unit *unit = &pxa_unit->unit; | ||
211 | |||
212 | mmp_register_mux_clks(unit, apmu_mux_clks, pxa_unit->apmu_base, | ||
213 | ARRAY_SIZE(apmu_mux_clks)); | ||
214 | |||
215 | mmp_register_div_clks(unit, apmu_div_clks, pxa_unit->apmu_base, | ||
216 | ARRAY_SIZE(apmu_div_clks)); | ||
217 | |||
218 | mmp_register_gate_clks(unit, apmu_gate_clks, pxa_unit->apmu_base, | ||
219 | ARRAY_SIZE(apmu_gate_clks)); | ||
220 | } | ||
221 | |||
222 | static void pxa910_clk_reset_init(struct device_node *np, | ||
223 | struct pxa910_clk_unit *pxa_unit) | ||
224 | { | ||
225 | struct mmp_clk_reset_cell *cells; | ||
226 | int i, base, nr_resets_apbc, nr_resets_apbcp, nr_resets; | ||
227 | |||
228 | nr_resets_apbc = ARRAY_SIZE(apbc_gate_clks); | ||
229 | nr_resets_apbcp = ARRAY_SIZE(apbcp_gate_clks); | ||
230 | nr_resets = nr_resets_apbc + nr_resets_apbcp; | ||
231 | cells = kcalloc(nr_resets, sizeof(*cells), GFP_KERNEL); | ||
232 | if (!cells) | ||
233 | return; | ||
234 | |||
235 | base = 0; | ||
236 | for (i = 0; i < nr_resets_apbc; i++) { | ||
237 | cells[base + i].clk_id = apbc_gate_clks[i].id; | ||
238 | cells[base + i].reg = | ||
239 | pxa_unit->apbc_base + apbc_gate_clks[i].offset; | ||
240 | cells[base + i].flags = 0; | ||
241 | cells[base + i].lock = apbc_gate_clks[i].lock; | ||
242 | cells[base + i].bits = 0x4; | ||
243 | } | ||
244 | |||
245 | base = nr_resets_apbc; | ||
246 | for (i = 0; i < nr_resets_apbcp; i++) { | ||
247 | cells[base + i].clk_id = apbcp_gate_clks[i].id; | ||
248 | cells[base + i].reg = | ||
249 | pxa_unit->apbc_base + apbc_gate_clks[i].offset; | ||
250 | cells[base + i].flags = 0; | ||
251 | cells[base + i].lock = apbc_gate_clks[i].lock; | ||
252 | cells[base + i].bits = 0x4; | ||
253 | } | ||
254 | |||
255 | mmp_clk_reset_register(np, cells, nr_resets); | ||
256 | } | ||
257 | |||
258 | static void __init pxa910_clk_init(struct device_node *np) | ||
259 | { | ||
260 | struct pxa910_clk_unit *pxa_unit; | ||
261 | |||
262 | pxa_unit = kzalloc(sizeof(*pxa_unit), GFP_KERNEL); | ||
263 | if (!pxa_unit) | ||
264 | return; | ||
265 | |||
266 | pxa_unit->mpmu_base = of_iomap(np, 0); | ||
267 | if (!pxa_unit->mpmu_base) { | ||
268 | pr_err("failed to map mpmu registers\n"); | ||
269 | return; | ||
270 | } | ||
271 | |||
272 | pxa_unit->apmu_base = of_iomap(np, 1); | ||
273 | if (!pxa_unit->mpmu_base) { | ||
274 | pr_err("failed to map apmu registers\n"); | ||
275 | return; | ||
276 | } | ||
277 | |||
278 | pxa_unit->apbc_base = of_iomap(np, 2); | ||
279 | if (!pxa_unit->apbc_base) { | ||
280 | pr_err("failed to map apbc registers\n"); | ||
281 | return; | ||
282 | } | ||
283 | |||
284 | pxa_unit->apbcp_base = of_iomap(np, 3); | ||
285 | if (!pxa_unit->mpmu_base) { | ||
286 | pr_err("failed to map apbcp registers\n"); | ||
287 | return; | ||
288 | } | ||
289 | |||
290 | mmp_clk_init(np, &pxa_unit->unit, PXA910_NR_CLKS); | ||
291 | |||
292 | pxa910_pll_init(pxa_unit); | ||
293 | |||
294 | pxa910_apb_periph_clk_init(pxa_unit); | ||
295 | |||
296 | pxa910_axi_periph_clk_init(pxa_unit); | ||
297 | |||
298 | pxa910_clk_reset_init(np, pxa_unit); | ||
299 | } | ||
300 | |||
301 | CLK_OF_DECLARE(pxa910_clk, "marvell,pxa910-clock", pxa910_clk_init); | ||
diff --git a/drivers/clk/mmp/clk-pxa168.c b/drivers/clk/mmp/clk-pxa168.c index 014396b028a2..93e967c0f972 100644 --- a/drivers/clk/mmp/clk-pxa168.c +++ b/drivers/clk/mmp/clk-pxa168.c | |||
@@ -47,7 +47,7 @@ | |||
47 | 47 | ||
48 | static DEFINE_SPINLOCK(clk_lock); | 48 | static DEFINE_SPINLOCK(clk_lock); |
49 | 49 | ||
50 | static struct clk_factor_masks uart_factor_masks = { | 50 | static struct mmp_clk_factor_masks uart_factor_masks = { |
51 | .factor = 2, | 51 | .factor = 2, |
52 | .num_mask = 0x1fff, | 52 | .num_mask = 0x1fff, |
53 | .den_mask = 0x1fff, | 53 | .den_mask = 0x1fff, |
@@ -55,7 +55,7 @@ static struct clk_factor_masks uart_factor_masks = { | |||
55 | .den_shift = 0, | 55 | .den_shift = 0, |
56 | }; | 56 | }; |
57 | 57 | ||
58 | static struct clk_factor_tbl uart_factor_tbl[] = { | 58 | static struct mmp_clk_factor_tbl uart_factor_tbl[] = { |
59 | {.num = 8125, .den = 1536}, /*14.745MHZ */ | 59 | {.num = 8125, .den = 1536}, /*14.745MHZ */ |
60 | }; | 60 | }; |
61 | 61 | ||
@@ -158,7 +158,7 @@ void __init pxa168_clk_init(void) | |||
158 | uart_pll = mmp_clk_register_factor("uart_pll", "pll1_4", 0, | 158 | uart_pll = mmp_clk_register_factor("uart_pll", "pll1_4", 0, |
159 | mpmu_base + MPMU_UART_PLL, | 159 | mpmu_base + MPMU_UART_PLL, |
160 | &uart_factor_masks, uart_factor_tbl, | 160 | &uart_factor_masks, uart_factor_tbl, |
161 | ARRAY_SIZE(uart_factor_tbl)); | 161 | ARRAY_SIZE(uart_factor_tbl), &clk_lock); |
162 | clk_set_rate(uart_pll, 14745600); | 162 | clk_set_rate(uart_pll, 14745600); |
163 | clk_register_clkdev(uart_pll, "uart_pll", NULL); | 163 | clk_register_clkdev(uart_pll, "uart_pll", NULL); |
164 | 164 | ||
diff --git a/drivers/clk/mmp/clk-pxa910.c b/drivers/clk/mmp/clk-pxa910.c index 9efc6a47535d..993abcdb32cc 100644 --- a/drivers/clk/mmp/clk-pxa910.c +++ b/drivers/clk/mmp/clk-pxa910.c | |||
@@ -45,7 +45,7 @@ | |||
45 | 45 | ||
46 | static DEFINE_SPINLOCK(clk_lock); | 46 | static DEFINE_SPINLOCK(clk_lock); |
47 | 47 | ||
48 | static struct clk_factor_masks uart_factor_masks = { | 48 | static struct mmp_clk_factor_masks uart_factor_masks = { |
49 | .factor = 2, | 49 | .factor = 2, |
50 | .num_mask = 0x1fff, | 50 | .num_mask = 0x1fff, |
51 | .den_mask = 0x1fff, | 51 | .den_mask = 0x1fff, |
@@ -53,7 +53,7 @@ static struct clk_factor_masks uart_factor_masks = { | |||
53 | .den_shift = 0, | 53 | .den_shift = 0, |
54 | }; | 54 | }; |
55 | 55 | ||
56 | static struct clk_factor_tbl uart_factor_tbl[] = { | 56 | static struct mmp_clk_factor_tbl uart_factor_tbl[] = { |
57 | {.num = 8125, .den = 1536}, /*14.745MHZ */ | 57 | {.num = 8125, .den = 1536}, /*14.745MHZ */ |
58 | }; | 58 | }; |
59 | 59 | ||
@@ -163,7 +163,7 @@ void __init pxa910_clk_init(void) | |||
163 | uart_pll = mmp_clk_register_factor("uart_pll", "pll1_4", 0, | 163 | uart_pll = mmp_clk_register_factor("uart_pll", "pll1_4", 0, |
164 | mpmu_base + MPMU_UART_PLL, | 164 | mpmu_base + MPMU_UART_PLL, |
165 | &uart_factor_masks, uart_factor_tbl, | 165 | &uart_factor_masks, uart_factor_tbl, |
166 | ARRAY_SIZE(uart_factor_tbl)); | 166 | ARRAY_SIZE(uart_factor_tbl), &clk_lock); |
167 | clk_set_rate(uart_pll, 14745600); | 167 | clk_set_rate(uart_pll, 14745600); |
168 | clk_register_clkdev(uart_pll, "uart_pll", NULL); | 168 | clk_register_clkdev(uart_pll, "uart_pll", NULL); |
169 | 169 | ||
diff --git a/drivers/clk/mmp/clk.c b/drivers/clk/mmp/clk.c new file mode 100644 index 000000000000..cf038ef54c59 --- /dev/null +++ b/drivers/clk/mmp/clk.c | |||
@@ -0,0 +1,192 @@ | |||
1 | #include <linux/io.h> | ||
2 | #include <linux/clk.h> | ||
3 | #include <linux/clk-provider.h> | ||
4 | #include <linux/clkdev.h> | ||
5 | #include <linux/of.h> | ||
6 | #include <linux/of_address.h> | ||
7 | |||
8 | #include "clk.h" | ||
9 | |||
10 | void mmp_clk_init(struct device_node *np, struct mmp_clk_unit *unit, | ||
11 | int nr_clks) | ||
12 | { | ||
13 | static struct clk **clk_table; | ||
14 | |||
15 | clk_table = kcalloc(nr_clks, sizeof(struct clk *), GFP_KERNEL); | ||
16 | if (!clk_table) | ||
17 | return; | ||
18 | |||
19 | unit->clk_table = clk_table; | ||
20 | unit->nr_clks = nr_clks; | ||
21 | unit->clk_data.clks = clk_table; | ||
22 | unit->clk_data.clk_num = nr_clks; | ||
23 | of_clk_add_provider(np, of_clk_src_onecell_get, &unit->clk_data); | ||
24 | } | ||
25 | |||
26 | void mmp_register_fixed_rate_clks(struct mmp_clk_unit *unit, | ||
27 | struct mmp_param_fixed_rate_clk *clks, | ||
28 | int size) | ||
29 | { | ||
30 | int i; | ||
31 | struct clk *clk; | ||
32 | |||
33 | for (i = 0; i < size; i++) { | ||
34 | clk = clk_register_fixed_rate(NULL, clks[i].name, | ||
35 | clks[i].parent_name, | ||
36 | clks[i].flags, | ||
37 | clks[i].fixed_rate); | ||
38 | if (IS_ERR(clk)) { | ||
39 | pr_err("%s: failed to register clock %s\n", | ||
40 | __func__, clks[i].name); | ||
41 | continue; | ||
42 | } | ||
43 | if (clks[i].id) | ||
44 | unit->clk_table[clks[i].id] = clk; | ||
45 | } | ||
46 | } | ||
47 | |||
48 | void mmp_register_fixed_factor_clks(struct mmp_clk_unit *unit, | ||
49 | struct mmp_param_fixed_factor_clk *clks, | ||
50 | int size) | ||
51 | { | ||
52 | struct clk *clk; | ||
53 | int i; | ||
54 | |||
55 | for (i = 0; i < size; i++) { | ||
56 | clk = clk_register_fixed_factor(NULL, clks[i].name, | ||
57 | clks[i].parent_name, | ||
58 | clks[i].flags, clks[i].mult, | ||
59 | clks[i].div); | ||
60 | if (IS_ERR(clk)) { | ||
61 | pr_err("%s: failed to register clock %s\n", | ||
62 | __func__, clks[i].name); | ||
63 | continue; | ||
64 | } | ||
65 | if (clks[i].id) | ||
66 | unit->clk_table[clks[i].id] = clk; | ||
67 | } | ||
68 | } | ||
69 | |||
70 | void mmp_register_general_gate_clks(struct mmp_clk_unit *unit, | ||
71 | struct mmp_param_general_gate_clk *clks, | ||
72 | void __iomem *base, int size) | ||
73 | { | ||
74 | struct clk *clk; | ||
75 | int i; | ||
76 | |||
77 | for (i = 0; i < size; i++) { | ||
78 | clk = clk_register_gate(NULL, clks[i].name, | ||
79 | clks[i].parent_name, | ||
80 | clks[i].flags, | ||
81 | base + clks[i].offset, | ||
82 | clks[i].bit_idx, | ||
83 | clks[i].gate_flags, | ||
84 | clks[i].lock); | ||
85 | |||
86 | if (IS_ERR(clk)) { | ||
87 | pr_err("%s: failed to register clock %s\n", | ||
88 | __func__, clks[i].name); | ||
89 | continue; | ||
90 | } | ||
91 | if (clks[i].id) | ||
92 | unit->clk_table[clks[i].id] = clk; | ||
93 | } | ||
94 | } | ||
95 | |||
96 | void mmp_register_gate_clks(struct mmp_clk_unit *unit, | ||
97 | struct mmp_param_gate_clk *clks, | ||
98 | void __iomem *base, int size) | ||
99 | { | ||
100 | struct clk *clk; | ||
101 | int i; | ||
102 | |||
103 | for (i = 0; i < size; i++) { | ||
104 | clk = mmp_clk_register_gate(NULL, clks[i].name, | ||
105 | clks[i].parent_name, | ||
106 | clks[i].flags, | ||
107 | base + clks[i].offset, | ||
108 | clks[i].mask, | ||
109 | clks[i].val_enable, | ||
110 | clks[i].val_disable, | ||
111 | clks[i].gate_flags, | ||
112 | clks[i].lock); | ||
113 | |||
114 | if (IS_ERR(clk)) { | ||
115 | pr_err("%s: failed to register clock %s\n", | ||
116 | __func__, clks[i].name); | ||
117 | continue; | ||
118 | } | ||
119 | if (clks[i].id) | ||
120 | unit->clk_table[clks[i].id] = clk; | ||
121 | } | ||
122 | } | ||
123 | |||
124 | void mmp_register_mux_clks(struct mmp_clk_unit *unit, | ||
125 | struct mmp_param_mux_clk *clks, | ||
126 | void __iomem *base, int size) | ||
127 | { | ||
128 | struct clk *clk; | ||
129 | int i; | ||
130 | |||
131 | for (i = 0; i < size; i++) { | ||
132 | clk = clk_register_mux(NULL, clks[i].name, | ||
133 | clks[i].parent_name, | ||
134 | clks[i].num_parents, | ||
135 | clks[i].flags, | ||
136 | base + clks[i].offset, | ||
137 | clks[i].shift, | ||
138 | clks[i].width, | ||
139 | clks[i].mux_flags, | ||
140 | clks[i].lock); | ||
141 | |||
142 | if (IS_ERR(clk)) { | ||
143 | pr_err("%s: failed to register clock %s\n", | ||
144 | __func__, clks[i].name); | ||
145 | continue; | ||
146 | } | ||
147 | if (clks[i].id) | ||
148 | unit->clk_table[clks[i].id] = clk; | ||
149 | } | ||
150 | } | ||
151 | |||
152 | void mmp_register_div_clks(struct mmp_clk_unit *unit, | ||
153 | struct mmp_param_div_clk *clks, | ||
154 | void __iomem *base, int size) | ||
155 | { | ||
156 | struct clk *clk; | ||
157 | int i; | ||
158 | |||
159 | for (i = 0; i < size; i++) { | ||
160 | clk = clk_register_divider(NULL, clks[i].name, | ||
161 | clks[i].parent_name, | ||
162 | clks[i].flags, | ||
163 | base + clks[i].offset, | ||
164 | clks[i].shift, | ||
165 | clks[i].width, | ||
166 | clks[i].div_flags, | ||
167 | clks[i].lock); | ||
168 | |||
169 | if (IS_ERR(clk)) { | ||
170 | pr_err("%s: failed to register clock %s\n", | ||
171 | __func__, clks[i].name); | ||
172 | continue; | ||
173 | } | ||
174 | if (clks[i].id) | ||
175 | unit->clk_table[clks[i].id] = clk; | ||
176 | } | ||
177 | } | ||
178 | |||
179 | void mmp_clk_add(struct mmp_clk_unit *unit, unsigned int id, | ||
180 | struct clk *clk) | ||
181 | { | ||
182 | if (IS_ERR_OR_NULL(clk)) { | ||
183 | pr_err("CLK %d has invalid pointer %p\n", id, clk); | ||
184 | return; | ||
185 | } | ||
186 | if (id > unit->nr_clks) { | ||
187 | pr_err("CLK %d is invalid\n", id); | ||
188 | return; | ||
189 | } | ||
190 | |||
191 | unit->clk_table[id] = clk; | ||
192 | } | ||
diff --git a/drivers/clk/mmp/clk.h b/drivers/clk/mmp/clk.h index ab86dd4a416a..adf9b711b037 100644 --- a/drivers/clk/mmp/clk.h +++ b/drivers/clk/mmp/clk.h | |||
@@ -7,19 +7,123 @@ | |||
7 | #define APBC_NO_BUS_CTRL BIT(0) | 7 | #define APBC_NO_BUS_CTRL BIT(0) |
8 | #define APBC_POWER_CTRL BIT(1) | 8 | #define APBC_POWER_CTRL BIT(1) |
9 | 9 | ||
10 | struct clk_factor_masks { | 10 | |
11 | unsigned int factor; | 11 | /* Clock type "factor" */ |
12 | unsigned int num_mask; | 12 | struct mmp_clk_factor_masks { |
13 | unsigned int den_mask; | 13 | unsigned int factor; |
14 | unsigned int num_shift; | 14 | unsigned int num_mask; |
15 | unsigned int den_shift; | 15 | unsigned int den_mask; |
16 | unsigned int num_shift; | ||
17 | unsigned int den_shift; | ||
16 | }; | 18 | }; |
17 | 19 | ||
18 | struct clk_factor_tbl { | 20 | struct mmp_clk_factor_tbl { |
19 | unsigned int num; | 21 | unsigned int num; |
20 | unsigned int den; | 22 | unsigned int den; |
21 | }; | 23 | }; |
22 | 24 | ||
25 | struct mmp_clk_factor { | ||
26 | struct clk_hw hw; | ||
27 | void __iomem *base; | ||
28 | struct mmp_clk_factor_masks *masks; | ||
29 | struct mmp_clk_factor_tbl *ftbl; | ||
30 | unsigned int ftbl_cnt; | ||
31 | spinlock_t *lock; | ||
32 | }; | ||
33 | |||
34 | extern struct clk *mmp_clk_register_factor(const char *name, | ||
35 | const char *parent_name, unsigned long flags, | ||
36 | void __iomem *base, struct mmp_clk_factor_masks *masks, | ||
37 | struct mmp_clk_factor_tbl *ftbl, unsigned int ftbl_cnt, | ||
38 | spinlock_t *lock); | ||
39 | |||
40 | /* Clock type "mix" */ | ||
41 | #define MMP_CLK_BITS_MASK(width, shift) \ | ||
42 | (((1 << (width)) - 1) << (shift)) | ||
43 | #define MMP_CLK_BITS_GET_VAL(data, width, shift) \ | ||
44 | ((data & MMP_CLK_BITS_MASK(width, shift)) >> (shift)) | ||
45 | #define MMP_CLK_BITS_SET_VAL(val, width, shift) \ | ||
46 | (((val) << (shift)) & MMP_CLK_BITS_MASK(width, shift)) | ||
47 | |||
48 | enum { | ||
49 | MMP_CLK_MIX_TYPE_V1, | ||
50 | MMP_CLK_MIX_TYPE_V2, | ||
51 | MMP_CLK_MIX_TYPE_V3, | ||
52 | }; | ||
53 | |||
54 | /* The register layout */ | ||
55 | struct mmp_clk_mix_reg_info { | ||
56 | void __iomem *reg_clk_ctrl; | ||
57 | void __iomem *reg_clk_sel; | ||
58 | u8 width_div; | ||
59 | u8 shift_div; | ||
60 | u8 width_mux; | ||
61 | u8 shift_mux; | ||
62 | u8 bit_fc; | ||
63 | }; | ||
64 | |||
65 | /* The suggested clock table from user. */ | ||
66 | struct mmp_clk_mix_clk_table { | ||
67 | unsigned long rate; | ||
68 | u8 parent_index; | ||
69 | unsigned int divisor; | ||
70 | unsigned int valid; | ||
71 | }; | ||
72 | |||
73 | struct mmp_clk_mix_config { | ||
74 | struct mmp_clk_mix_reg_info reg_info; | ||
75 | struct mmp_clk_mix_clk_table *table; | ||
76 | unsigned int table_size; | ||
77 | u32 *mux_table; | ||
78 | struct clk_div_table *div_table; | ||
79 | u8 div_flags; | ||
80 | u8 mux_flags; | ||
81 | }; | ||
82 | |||
83 | struct mmp_clk_mix { | ||
84 | struct clk_hw hw; | ||
85 | struct mmp_clk_mix_reg_info reg_info; | ||
86 | struct mmp_clk_mix_clk_table *table; | ||
87 | u32 *mux_table; | ||
88 | struct clk_div_table *div_table; | ||
89 | unsigned int table_size; | ||
90 | u8 div_flags; | ||
91 | u8 mux_flags; | ||
92 | unsigned int type; | ||
93 | spinlock_t *lock; | ||
94 | }; | ||
95 | |||
96 | extern const struct clk_ops mmp_clk_mix_ops; | ||
97 | extern struct clk *mmp_clk_register_mix(struct device *dev, | ||
98 | const char *name, | ||
99 | const char **parent_names, | ||
100 | u8 num_parents, | ||
101 | unsigned long flags, | ||
102 | struct mmp_clk_mix_config *config, | ||
103 | spinlock_t *lock); | ||
104 | |||
105 | |||
106 | /* Clock type "gate". MMP private gate */ | ||
107 | #define MMP_CLK_GATE_NEED_DELAY BIT(0) | ||
108 | |||
109 | struct mmp_clk_gate { | ||
110 | struct clk_hw hw; | ||
111 | void __iomem *reg; | ||
112 | u32 mask; | ||
113 | u32 val_enable; | ||
114 | u32 val_disable; | ||
115 | unsigned int flags; | ||
116 | spinlock_t *lock; | ||
117 | }; | ||
118 | |||
119 | extern const struct clk_ops mmp_clk_gate_ops; | ||
120 | extern struct clk *mmp_clk_register_gate(struct device *dev, const char *name, | ||
121 | const char *parent_name, unsigned long flags, | ||
122 | void __iomem *reg, u32 mask, u32 val_enable, | ||
123 | u32 val_disable, unsigned int gate_flags, | ||
124 | spinlock_t *lock); | ||
125 | |||
126 | |||
23 | extern struct clk *mmp_clk_register_pll2(const char *name, | 127 | extern struct clk *mmp_clk_register_pll2(const char *name, |
24 | const char *parent_name, unsigned long flags); | 128 | const char *parent_name, unsigned long flags); |
25 | extern struct clk *mmp_clk_register_apbc(const char *name, | 129 | extern struct clk *mmp_clk_register_apbc(const char *name, |
@@ -28,8 +132,108 @@ extern struct clk *mmp_clk_register_apbc(const char *name, | |||
28 | extern struct clk *mmp_clk_register_apmu(const char *name, | 132 | extern struct clk *mmp_clk_register_apmu(const char *name, |
29 | const char *parent_name, void __iomem *base, u32 enable_mask, | 133 | const char *parent_name, void __iomem *base, u32 enable_mask, |
30 | spinlock_t *lock); | 134 | spinlock_t *lock); |
31 | extern struct clk *mmp_clk_register_factor(const char *name, | 135 | |
32 | const char *parent_name, unsigned long flags, | 136 | struct mmp_clk_unit { |
33 | void __iomem *base, struct clk_factor_masks *masks, | 137 | unsigned int nr_clks; |
34 | struct clk_factor_tbl *ftbl, unsigned int ftbl_cnt); | 138 | struct clk **clk_table; |
139 | struct clk_onecell_data clk_data; | ||
140 | }; | ||
141 | |||
142 | struct mmp_param_fixed_rate_clk { | ||
143 | unsigned int id; | ||
144 | char *name; | ||
145 | const char *parent_name; | ||
146 | unsigned long flags; | ||
147 | unsigned long fixed_rate; | ||
148 | }; | ||
149 | void mmp_register_fixed_rate_clks(struct mmp_clk_unit *unit, | ||
150 | struct mmp_param_fixed_rate_clk *clks, | ||
151 | int size); | ||
152 | |||
153 | struct mmp_param_fixed_factor_clk { | ||
154 | unsigned int id; | ||
155 | char *name; | ||
156 | const char *parent_name; | ||
157 | unsigned long mult; | ||
158 | unsigned long div; | ||
159 | unsigned long flags; | ||
160 | }; | ||
161 | void mmp_register_fixed_factor_clks(struct mmp_clk_unit *unit, | ||
162 | struct mmp_param_fixed_factor_clk *clks, | ||
163 | int size); | ||
164 | |||
165 | struct mmp_param_general_gate_clk { | ||
166 | unsigned int id; | ||
167 | const char *name; | ||
168 | const char *parent_name; | ||
169 | unsigned long flags; | ||
170 | unsigned long offset; | ||
171 | u8 bit_idx; | ||
172 | u8 gate_flags; | ||
173 | spinlock_t *lock; | ||
174 | }; | ||
175 | void mmp_register_general_gate_clks(struct mmp_clk_unit *unit, | ||
176 | struct mmp_param_general_gate_clk *clks, | ||
177 | void __iomem *base, int size); | ||
178 | |||
179 | struct mmp_param_gate_clk { | ||
180 | unsigned int id; | ||
181 | char *name; | ||
182 | const char *parent_name; | ||
183 | unsigned long flags; | ||
184 | unsigned long offset; | ||
185 | u32 mask; | ||
186 | u32 val_enable; | ||
187 | u32 val_disable; | ||
188 | unsigned int gate_flags; | ||
189 | spinlock_t *lock; | ||
190 | }; | ||
191 | void mmp_register_gate_clks(struct mmp_clk_unit *unit, | ||
192 | struct mmp_param_gate_clk *clks, | ||
193 | void __iomem *base, int size); | ||
194 | |||
195 | struct mmp_param_mux_clk { | ||
196 | unsigned int id; | ||
197 | char *name; | ||
198 | const char **parent_name; | ||
199 | u8 num_parents; | ||
200 | unsigned long flags; | ||
201 | unsigned long offset; | ||
202 | u8 shift; | ||
203 | u8 width; | ||
204 | u8 mux_flags; | ||
205 | spinlock_t *lock; | ||
206 | }; | ||
207 | void mmp_register_mux_clks(struct mmp_clk_unit *unit, | ||
208 | struct mmp_param_mux_clk *clks, | ||
209 | void __iomem *base, int size); | ||
210 | |||
211 | struct mmp_param_div_clk { | ||
212 | unsigned int id; | ||
213 | char *name; | ||
214 | const char *parent_name; | ||
215 | unsigned long flags; | ||
216 | unsigned long offset; | ||
217 | u8 shift; | ||
218 | u8 width; | ||
219 | u8 div_flags; | ||
220 | spinlock_t *lock; | ||
221 | }; | ||
222 | void mmp_register_div_clks(struct mmp_clk_unit *unit, | ||
223 | struct mmp_param_div_clk *clks, | ||
224 | void __iomem *base, int size); | ||
225 | |||
226 | #define DEFINE_MIX_REG_INFO(w_d, s_d, w_m, s_m, fc) \ | ||
227 | { \ | ||
228 | .width_div = (w_d), \ | ||
229 | .shift_div = (s_d), \ | ||
230 | .width_mux = (w_m), \ | ||
231 | .shift_mux = (s_m), \ | ||
232 | .bit_fc = (fc), \ | ||
233 | } | ||
234 | |||
235 | void mmp_clk_init(struct device_node *np, struct mmp_clk_unit *unit, | ||
236 | int nr_clks); | ||
237 | void mmp_clk_add(struct mmp_clk_unit *unit, unsigned int id, | ||
238 | struct clk *clk); | ||
35 | #endif | 239 | #endif |
diff --git a/drivers/clk/mmp/reset.c b/drivers/clk/mmp/reset.c new file mode 100644 index 000000000000..b54da1fe73f0 --- /dev/null +++ b/drivers/clk/mmp/reset.c | |||
@@ -0,0 +1,99 @@ | |||
1 | #include <linux/slab.h> | ||
2 | #include <linux/io.h> | ||
3 | #include <linux/of.h> | ||
4 | #include <linux/of_address.h> | ||
5 | #include <linux/reset-controller.h> | ||
6 | |||
7 | #include "reset.h" | ||
8 | |||
9 | #define rcdev_to_unit(rcdev) container_of(rcdev, struct mmp_clk_reset_unit, rcdev) | ||
10 | |||
11 | static int mmp_of_reset_xlate(struct reset_controller_dev *rcdev, | ||
12 | const struct of_phandle_args *reset_spec) | ||
13 | { | ||
14 | struct mmp_clk_reset_unit *unit = rcdev_to_unit(rcdev); | ||
15 | struct mmp_clk_reset_cell *cell; | ||
16 | int i; | ||
17 | |||
18 | if (WARN_ON(reset_spec->args_count != rcdev->of_reset_n_cells)) | ||
19 | return -EINVAL; | ||
20 | |||
21 | for (i = 0; i < rcdev->nr_resets; i++) { | ||
22 | cell = &unit->cells[i]; | ||
23 | if (cell->clk_id == reset_spec->args[0]) | ||
24 | break; | ||
25 | } | ||
26 | |||
27 | if (i == rcdev->nr_resets) | ||
28 | return -EINVAL; | ||
29 | |||
30 | return i; | ||
31 | } | ||
32 | |||
33 | static int mmp_clk_reset_assert(struct reset_controller_dev *rcdev, | ||
34 | unsigned long id) | ||
35 | { | ||
36 | struct mmp_clk_reset_unit *unit = rcdev_to_unit(rcdev); | ||
37 | struct mmp_clk_reset_cell *cell; | ||
38 | unsigned long flags = 0; | ||
39 | u32 val; | ||
40 | |||
41 | cell = &unit->cells[id]; | ||
42 | if (cell->lock) | ||
43 | spin_lock_irqsave(cell->lock, flags); | ||
44 | |||
45 | val = readl(cell->reg); | ||
46 | val |= cell->bits; | ||
47 | writel(val, cell->reg); | ||
48 | |||
49 | if (cell->lock) | ||
50 | spin_unlock_irqrestore(cell->lock, flags); | ||
51 | |||
52 | return 0; | ||
53 | } | ||
54 | |||
55 | static int mmp_clk_reset_deassert(struct reset_controller_dev *rcdev, | ||
56 | unsigned long id) | ||
57 | { | ||
58 | struct mmp_clk_reset_unit *unit = rcdev_to_unit(rcdev); | ||
59 | struct mmp_clk_reset_cell *cell; | ||
60 | unsigned long flags = 0; | ||
61 | u32 val; | ||
62 | |||
63 | cell = &unit->cells[id]; | ||
64 | if (cell->lock) | ||
65 | spin_lock_irqsave(cell->lock, flags); | ||
66 | |||
67 | val = readl(cell->reg); | ||
68 | val &= ~cell->bits; | ||
69 | writel(val, cell->reg); | ||
70 | |||
71 | if (cell->lock) | ||
72 | spin_unlock_irqrestore(cell->lock, flags); | ||
73 | |||
74 | return 0; | ||
75 | } | ||
76 | |||
77 | static struct reset_control_ops mmp_clk_reset_ops = { | ||
78 | .assert = mmp_clk_reset_assert, | ||
79 | .deassert = mmp_clk_reset_deassert, | ||
80 | }; | ||
81 | |||
82 | void mmp_clk_reset_register(struct device_node *np, | ||
83 | struct mmp_clk_reset_cell *cells, int nr_resets) | ||
84 | { | ||
85 | struct mmp_clk_reset_unit *unit; | ||
86 | |||
87 | unit = kzalloc(sizeof(*unit), GFP_KERNEL); | ||
88 | if (!unit) | ||
89 | return; | ||
90 | |||
91 | unit->cells = cells; | ||
92 | unit->rcdev.of_reset_n_cells = 1; | ||
93 | unit->rcdev.nr_resets = nr_resets; | ||
94 | unit->rcdev.ops = &mmp_clk_reset_ops; | ||
95 | unit->rcdev.of_node = np; | ||
96 | unit->rcdev.of_xlate = mmp_of_reset_xlate; | ||
97 | |||
98 | reset_controller_register(&unit->rcdev); | ||
99 | } | ||
diff --git a/drivers/clk/mmp/reset.h b/drivers/clk/mmp/reset.h new file mode 100644 index 000000000000..be8b1a7000f7 --- /dev/null +++ b/drivers/clk/mmp/reset.h | |||
@@ -0,0 +1,31 @@ | |||
1 | #ifndef __MACH_MMP_CLK_RESET_H | ||
2 | #define __MACH_MMP_CLK_RESET_H | ||
3 | |||
4 | #include <linux/reset-controller.h> | ||
5 | |||
6 | #define MMP_RESET_INVERT 1 | ||
7 | |||
8 | struct mmp_clk_reset_cell { | ||
9 | unsigned int clk_id; | ||
10 | void __iomem *reg; | ||
11 | u32 bits; | ||
12 | unsigned int flags; | ||
13 | spinlock_t *lock; | ||
14 | }; | ||
15 | |||
16 | struct mmp_clk_reset_unit { | ||
17 | struct reset_controller_dev rcdev; | ||
18 | struct mmp_clk_reset_cell *cells; | ||
19 | }; | ||
20 | |||
21 | #ifdef CONFIG_RESET_CONTROLLER | ||
22 | void mmp_clk_reset_register(struct device_node *np, | ||
23 | struct mmp_clk_reset_cell *cells, int nr_resets); | ||
24 | #else | ||
25 | static inline void mmp_clk_reset_register(struct device_node *np, | ||
26 | struct mmp_clk_reset_cell *cells, int nr_resets) | ||
27 | { | ||
28 | } | ||
29 | #endif | ||
30 | |||
31 | #endif | ||
diff --git a/drivers/clk/pxa/Makefile b/drivers/clk/pxa/Makefile index 4ff2abcd500b..38e915344605 100644 --- a/drivers/clk/pxa/Makefile +++ b/drivers/clk/pxa/Makefile | |||
@@ -1,2 +1,3 @@ | |||
1 | obj-y += clk-pxa.o | 1 | obj-y += clk-pxa.o |
2 | obj-$(CONFIG_PXA25x) += clk-pxa25x.o | ||
2 | obj-$(CONFIG_PXA27x) += clk-pxa27x.o | 3 | obj-$(CONFIG_PXA27x) += clk-pxa27x.o |
diff --git a/drivers/clk/pxa/clk-pxa.c b/drivers/clk/pxa/clk-pxa.c index ef3c05389c0a..4e834753ab09 100644 --- a/drivers/clk/pxa/clk-pxa.c +++ b/drivers/clk/pxa/clk-pxa.c | |||
@@ -26,12 +26,20 @@ static struct clk_onecell_data onecell_data = { | |||
26 | .clk_num = CLK_MAX, | 26 | .clk_num = CLK_MAX, |
27 | }; | 27 | }; |
28 | 28 | ||
29 | #define to_pxa_clk(_hw) container_of(_hw, struct pxa_clk_cken, hw) | 29 | struct pxa_clk { |
30 | struct clk_hw hw; | ||
31 | struct clk_fixed_factor lp; | ||
32 | struct clk_fixed_factor hp; | ||
33 | struct clk_gate gate; | ||
34 | bool (*is_in_low_power)(void); | ||
35 | }; | ||
36 | |||
37 | #define to_pxa_clk(_hw) container_of(_hw, struct pxa_clk, hw) | ||
30 | 38 | ||
31 | static unsigned long cken_recalc_rate(struct clk_hw *hw, | 39 | static unsigned long cken_recalc_rate(struct clk_hw *hw, |
32 | unsigned long parent_rate) | 40 | unsigned long parent_rate) |
33 | { | 41 | { |
34 | struct pxa_clk_cken *pclk = to_pxa_clk(hw); | 42 | struct pxa_clk *pclk = to_pxa_clk(hw); |
35 | struct clk_fixed_factor *fix; | 43 | struct clk_fixed_factor *fix; |
36 | 44 | ||
37 | if (!pclk->is_in_low_power || pclk->is_in_low_power()) | 45 | if (!pclk->is_in_low_power || pclk->is_in_low_power()) |
@@ -48,7 +56,7 @@ static struct clk_ops cken_rate_ops = { | |||
48 | 56 | ||
49 | static u8 cken_get_parent(struct clk_hw *hw) | 57 | static u8 cken_get_parent(struct clk_hw *hw) |
50 | { | 58 | { |
51 | struct pxa_clk_cken *pclk = to_pxa_clk(hw); | 59 | struct pxa_clk *pclk = to_pxa_clk(hw); |
52 | 60 | ||
53 | if (!pclk->is_in_low_power) | 61 | if (!pclk->is_in_low_power) |
54 | return 0; | 62 | return 0; |
@@ -69,29 +77,32 @@ void __init clkdev_pxa_register(int ckid, const char *con_id, | |||
69 | clk_register_clkdev(clk, con_id, dev_id); | 77 | clk_register_clkdev(clk, con_id, dev_id); |
70 | } | 78 | } |
71 | 79 | ||
72 | int __init clk_pxa_cken_init(struct pxa_clk_cken *clks, int nb_clks) | 80 | int __init clk_pxa_cken_init(const struct desc_clk_cken *clks, int nb_clks) |
73 | { | 81 | { |
74 | int i; | 82 | int i; |
75 | struct pxa_clk_cken *pclk; | 83 | struct pxa_clk *pxa_clk; |
76 | struct clk *clk; | 84 | struct clk *clk; |
77 | 85 | ||
78 | for (i = 0; i < nb_clks; i++) { | 86 | for (i = 0; i < nb_clks; i++) { |
79 | pclk = clks + i; | 87 | pxa_clk = kzalloc(sizeof(*pxa_clk), GFP_KERNEL); |
80 | pclk->gate.lock = &lock; | 88 | pxa_clk->is_in_low_power = clks[i].is_in_low_power; |
81 | clk = clk_register_composite(NULL, pclk->name, | 89 | pxa_clk->lp = clks[i].lp; |
82 | pclk->parent_names, 2, | 90 | pxa_clk->hp = clks[i].hp; |
83 | &pclk->hw, &cken_mux_ops, | 91 | pxa_clk->gate = clks[i].gate; |
84 | &pclk->hw, &cken_rate_ops, | 92 | pxa_clk->gate.lock = &lock; |
85 | &pclk->gate.hw, &clk_gate_ops, | 93 | clk = clk_register_composite(NULL, clks[i].name, |
86 | pclk->flags); | 94 | clks[i].parent_names, 2, |
87 | clkdev_pxa_register(pclk->ckid, pclk->con_id, pclk->dev_id, | 95 | &pxa_clk->hw, &cken_mux_ops, |
88 | clk); | 96 | &pxa_clk->hw, &cken_rate_ops, |
97 | &pxa_clk->gate.hw, &clk_gate_ops, | ||
98 | clks[i].flags); | ||
99 | clkdev_pxa_register(clks[i].ckid, clks[i].con_id, | ||
100 | clks[i].dev_id, clk); | ||
89 | } | 101 | } |
90 | return 0; | 102 | return 0; |
91 | } | 103 | } |
92 | 104 | ||
93 | static void __init pxa_dt_clocks_init(struct device_node *np) | 105 | void __init clk_pxa_dt_common_init(struct device_node *np) |
94 | { | 106 | { |
95 | of_clk_add_provider(np, of_clk_src_onecell_get, &onecell_data); | 107 | of_clk_add_provider(np, of_clk_src_onecell_get, &onecell_data); |
96 | } | 108 | } |
97 | CLK_OF_DECLARE(pxa_clks, "marvell,pxa-clocks", pxa_dt_clocks_init); | ||
diff --git a/drivers/clk/pxa/clk-pxa.h b/drivers/clk/pxa/clk-pxa.h index 5fe219d06b49..323965430111 100644 --- a/drivers/clk/pxa/clk-pxa.h +++ b/drivers/clk/pxa/clk-pxa.h | |||
@@ -25,7 +25,7 @@ | |||
25 | static struct clk_ops name ## _rate_ops = { \ | 25 | static struct clk_ops name ## _rate_ops = { \ |
26 | .recalc_rate = name ## _get_rate, \ | 26 | .recalc_rate = name ## _get_rate, \ |
27 | }; \ | 27 | }; \ |
28 | static struct clk *clk_register_ ## name(void) \ | 28 | static struct clk * __init clk_register_ ## name(void) \ |
29 | { \ | 29 | { \ |
30 | return clk_register_composite(NULL, clk_name, \ | 30 | return clk_register_composite(NULL, clk_name, \ |
31 | name ## _parents, \ | 31 | name ## _parents, \ |
@@ -40,7 +40,7 @@ | |||
40 | static struct clk_ops name ## _rate_ops = { \ | 40 | static struct clk_ops name ## _rate_ops = { \ |
41 | .recalc_rate = name ## _get_rate, \ | 41 | .recalc_rate = name ## _get_rate, \ |
42 | }; \ | 42 | }; \ |
43 | static struct clk *clk_register_ ## name(void) \ | 43 | static struct clk * __init clk_register_ ## name(void) \ |
44 | { \ | 44 | { \ |
45 | return clk_register_composite(NULL, clk_name, \ | 45 | return clk_register_composite(NULL, clk_name, \ |
46 | name ## _parents, \ | 46 | name ## _parents, \ |
@@ -66,7 +66,7 @@ | |||
66 | * | Clock | --- | / div_hp | | 66 | * | Clock | --- | / div_hp | |
67 | * +------------+ +-----------+ | 67 | * +------------+ +-----------+ |
68 | */ | 68 | */ |
69 | struct pxa_clk_cken { | 69 | struct desc_clk_cken { |
70 | struct clk_hw hw; | 70 | struct clk_hw hw; |
71 | int ckid; | 71 | int ckid; |
72 | const char *name; | 72 | const char *name; |
@@ -102,6 +102,7 @@ static int dummy_clk_set_parent(struct clk_hw *hw, u8 index) | |||
102 | 102 | ||
103 | extern void clkdev_pxa_register(int ckid, const char *con_id, | 103 | extern void clkdev_pxa_register(int ckid, const char *con_id, |
104 | const char *dev_id, struct clk *clk); | 104 | const char *dev_id, struct clk *clk); |
105 | extern int clk_pxa_cken_init(struct pxa_clk_cken *clks, int nb_clks); | 105 | extern int clk_pxa_cken_init(const struct desc_clk_cken *clks, int nb_clks); |
106 | void clk_pxa_dt_common_init(struct device_node *np); | ||
106 | 107 | ||
107 | #endif | 108 | #endif |
diff --git a/drivers/clk/pxa/clk-pxa25x.c b/drivers/clk/pxa/clk-pxa25x.c new file mode 100644 index 000000000000..6cd88d963a7f --- /dev/null +++ b/drivers/clk/pxa/clk-pxa25x.c | |||
@@ -0,0 +1,273 @@ | |||
1 | /* | ||
2 | * Marvell PXA25x family clocks | ||
3 | * | ||
4 | * Copyright (C) 2014 Robert Jarzmik | ||
5 | * | ||
6 | * Heavily inspired from former arch/arm/mach-pxa/pxa25x.c. | ||
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 | * For non-devicetree platforms. Once pxa is fully converted to devicetree, this | ||
13 | * should go away. | ||
14 | */ | ||
15 | #include <linux/clk-provider.h> | ||
16 | #include <linux/clk.h> | ||
17 | #include <linux/clkdev.h> | ||
18 | #include <linux/io.h> | ||
19 | #include <linux/of.h> | ||
20 | #include <mach/pxa25x.h> | ||
21 | #include <mach/pxa2xx-regs.h> | ||
22 | |||
23 | #include <dt-bindings/clock/pxa-clock.h> | ||
24 | #include "clk-pxa.h" | ||
25 | |||
26 | #define KHz 1000 | ||
27 | #define MHz (1000 * 1000) | ||
28 | |||
29 | enum { | ||
30 | PXA_CORE_RUN = 0, | ||
31 | PXA_CORE_TURBO, | ||
32 | }; | ||
33 | |||
34 | /* | ||
35 | * Various clock factors driven by the CCCR register. | ||
36 | */ | ||
37 | |||
38 | /* Crystal Frequency to Memory Frequency Multiplier (L) */ | ||
39 | static unsigned char L_clk_mult[32] = { 0, 27, 32, 36, 40, 45, 0, }; | ||
40 | |||
41 | /* Memory Frequency to Run Mode Frequency Multiplier (M) */ | ||
42 | static unsigned char M_clk_mult[4] = { 0, 1, 2, 4 }; | ||
43 | |||
44 | /* Run Mode Frequency to Turbo Mode Frequency Multiplier (N) */ | ||
45 | /* Note: we store the value N * 2 here. */ | ||
46 | static unsigned char N2_clk_mult[8] = { 0, 0, 2, 3, 4, 0, 6, 0 }; | ||
47 | |||
48 | static const char * const get_freq_khz[] = { | ||
49 | "core", "run", "cpll", "memory" | ||
50 | }; | ||
51 | |||
52 | /* | ||
53 | * Get the clock frequency as reflected by CCCR and the turbo flag. | ||
54 | * We assume these values have been applied via a fcs. | ||
55 | * If info is not 0 we also display the current settings. | ||
56 | */ | ||
57 | unsigned int pxa25x_get_clk_frequency_khz(int info) | ||
58 | { | ||
59 | struct clk *clk; | ||
60 | unsigned long clks[5]; | ||
61 | int i; | ||
62 | |||
63 | for (i = 0; i < ARRAY_SIZE(get_freq_khz); i++) { | ||
64 | clk = clk_get(NULL, get_freq_khz[i]); | ||
65 | if (IS_ERR(clk)) { | ||
66 | clks[i] = 0; | ||
67 | } else { | ||
68 | clks[i] = clk_get_rate(clk); | ||
69 | clk_put(clk); | ||
70 | } | ||
71 | } | ||
72 | |||
73 | if (info) { | ||
74 | pr_info("Run Mode clock: %ld.%02ldMHz\n", | ||
75 | clks[1] / 1000000, (clks[1] % 1000000) / 10000); | ||
76 | pr_info("Turbo Mode clock: %ld.%02ldMHz\n", | ||
77 | clks[2] / 1000000, (clks[2] % 1000000) / 10000); | ||
78 | pr_info("Memory clock: %ld.%02ldMHz\n", | ||
79 | clks[3] / 1000000, (clks[3] % 1000000) / 10000); | ||
80 | } | ||
81 | |||
82 | return (unsigned int)clks[0]; | ||
83 | } | ||
84 | |||
85 | static unsigned long clk_pxa25x_memory_get_rate(struct clk_hw *hw, | ||
86 | unsigned long parent_rate) | ||
87 | { | ||
88 | unsigned long cccr = CCCR; | ||
89 | unsigned int m = M_clk_mult[(cccr >> 5) & 0x03]; | ||
90 | |||
91 | return parent_rate / m; | ||
92 | } | ||
93 | PARENTS(clk_pxa25x_memory) = { "run" }; | ||
94 | RATE_RO_OPS(clk_pxa25x_memory, "memory"); | ||
95 | |||
96 | PARENTS(pxa25x_pbus95) = { "ppll_95_85mhz", "ppll_95_85mhz" }; | ||
97 | PARENTS(pxa25x_pbus147) = { "ppll_147_46mhz", "ppll_147_46mhz" }; | ||
98 | PARENTS(pxa25x_osc3) = { "osc_3_6864mhz", "osc_3_6864mhz" }; | ||
99 | |||
100 | #define PXA25X_CKEN(dev_id, con_id, parents, mult, div, \ | ||
101 | bit, is_lp, flags) \ | ||
102 | PXA_CKEN(dev_id, con_id, bit, parents, mult, div, mult, div, \ | ||
103 | is_lp, &CKEN, CKEN_ ## bit, flags) | ||
104 | #define PXA25X_PBUS95_CKEN(dev_id, con_id, bit, mult_hp, div_hp, delay) \ | ||
105 | PXA25X_CKEN(dev_id, con_id, pxa25x_pbus95_parents, mult_hp, \ | ||
106 | div_hp, bit, NULL, 0) | ||
107 | #define PXA25X_PBUS147_CKEN(dev_id, con_id, bit, mult_hp, div_hp, delay)\ | ||
108 | PXA25X_CKEN(dev_id, con_id, pxa25x_pbus147_parents, mult_hp, \ | ||
109 | div_hp, bit, NULL, 0) | ||
110 | #define PXA25X_OSC3_CKEN(dev_id, con_id, bit, mult_hp, div_hp, delay) \ | ||
111 | PXA25X_CKEN(dev_id, con_id, pxa25x_osc3_parents, mult_hp, \ | ||
112 | div_hp, bit, NULL, 0) | ||
113 | |||
114 | #define PXA25X_CKEN_1RATE(dev_id, con_id, bit, parents, delay) \ | ||
115 | PXA_CKEN_1RATE(dev_id, con_id, bit, parents, \ | ||
116 | &CKEN, CKEN_ ## bit, 0) | ||
117 | #define PXA25X_CKEN_1RATE_AO(dev_id, con_id, bit, parents, delay) \ | ||
118 | PXA_CKEN_1RATE(dev_id, con_id, bit, parents, \ | ||
119 | &CKEN, CKEN_ ## bit, CLK_IGNORE_UNUSED) | ||
120 | |||
121 | static struct desc_clk_cken pxa25x_clocks[] __initdata = { | ||
122 | PXA25X_PBUS95_CKEN("pxa2xx-mci.0", NULL, MMC, 1, 5, 0), | ||
123 | PXA25X_PBUS95_CKEN("pxa2xx-i2c.0", NULL, I2C, 1, 3, 0), | ||
124 | PXA25X_PBUS95_CKEN("pxa2xx-ir", "FICPCLK", FICP, 1, 2, 0), | ||
125 | PXA25X_PBUS95_CKEN("pxa25x-udc", NULL, USB, 1, 2, 5), | ||
126 | PXA25X_PBUS147_CKEN("pxa2xx-uart.0", NULL, FFUART, 1, 10, 1), | ||
127 | PXA25X_PBUS147_CKEN("pxa2xx-uart.1", NULL, BTUART, 1, 10, 1), | ||
128 | PXA25X_PBUS147_CKEN("pxa2xx-uart.2", NULL, STUART, 1, 10, 1), | ||
129 | PXA25X_PBUS147_CKEN("pxa2xx-uart.3", NULL, HWUART, 1, 10, 1), | ||
130 | PXA25X_PBUS147_CKEN("pxa2xx-i2s", NULL, I2S, 1, 10, 0), | ||
131 | PXA25X_PBUS147_CKEN(NULL, "AC97CLK", AC97, 1, 12, 0), | ||
132 | PXA25X_OSC3_CKEN("pxa25x-ssp.0", NULL, SSP, 1, 1, 0), | ||
133 | PXA25X_OSC3_CKEN("pxa25x-nssp.1", NULL, NSSP, 1, 1, 0), | ||
134 | PXA25X_OSC3_CKEN("pxa25x-nssp.2", NULL, ASSP, 1, 1, 0), | ||
135 | PXA25X_OSC3_CKEN("pxa25x-pwm.0", NULL, PWM0, 1, 1, 0), | ||
136 | PXA25X_OSC3_CKEN("pxa25x-pwm.1", NULL, PWM1, 1, 1, 0), | ||
137 | |||
138 | PXA25X_CKEN_1RATE("pxa2xx-fb", NULL, LCD, clk_pxa25x_memory_parents, 0), | ||
139 | PXA25X_CKEN_1RATE_AO("pxa2xx-pcmcia", NULL, MEMC, | ||
140 | clk_pxa25x_memory_parents, 0), | ||
141 | }; | ||
142 | |||
143 | static u8 clk_pxa25x_core_get_parent(struct clk_hw *hw) | ||
144 | { | ||
145 | unsigned long clkcfg; | ||
146 | unsigned int t; | ||
147 | |||
148 | asm("mrc\tp14, 0, %0, c6, c0, 0" : "=r" (clkcfg)); | ||
149 | t = clkcfg & (1 << 0); | ||
150 | if (t) | ||
151 | return PXA_CORE_TURBO; | ||
152 | return PXA_CORE_RUN; | ||
153 | } | ||
154 | |||
155 | static unsigned long clk_pxa25x_core_get_rate(struct clk_hw *hw, | ||
156 | unsigned long parent_rate) | ||
157 | { | ||
158 | return parent_rate; | ||
159 | } | ||
160 | PARENTS(clk_pxa25x_core) = { "run", "cpll" }; | ||
161 | MUX_RO_RATE_RO_OPS(clk_pxa25x_core, "core"); | ||
162 | |||
163 | static unsigned long clk_pxa25x_run_get_rate(struct clk_hw *hw, | ||
164 | unsigned long parent_rate) | ||
165 | { | ||
166 | unsigned long cccr = CCCR; | ||
167 | unsigned int n2 = N2_clk_mult[(cccr >> 7) & 0x07]; | ||
168 | |||
169 | return (parent_rate / n2) * 2; | ||
170 | } | ||
171 | PARENTS(clk_pxa25x_run) = { "cpll" }; | ||
172 | RATE_RO_OPS(clk_pxa25x_run, "run"); | ||
173 | |||
174 | static unsigned long clk_pxa25x_cpll_get_rate(struct clk_hw *hw, | ||
175 | unsigned long parent_rate) | ||
176 | { | ||
177 | unsigned long clkcfg, cccr = CCCR; | ||
178 | unsigned int l, m, n2, t; | ||
179 | |||
180 | asm("mrc\tp14, 0, %0, c6, c0, 0" : "=r" (clkcfg)); | ||
181 | t = clkcfg & (1 << 0); | ||
182 | l = L_clk_mult[(cccr >> 0) & 0x1f]; | ||
183 | m = M_clk_mult[(cccr >> 5) & 0x03]; | ||
184 | n2 = N2_clk_mult[(cccr >> 7) & 0x07]; | ||
185 | |||
186 | if (t) | ||
187 | return m * l * n2 * parent_rate / 2; | ||
188 | return m * l * parent_rate; | ||
189 | } | ||
190 | PARENTS(clk_pxa25x_cpll) = { "osc_3_6864mhz" }; | ||
191 | RATE_RO_OPS(clk_pxa25x_cpll, "cpll"); | ||
192 | |||
193 | static void __init pxa25x_register_core(void) | ||
194 | { | ||
195 | clk_register_clk_pxa25x_cpll(); | ||
196 | clk_register_clk_pxa25x_run(); | ||
197 | clkdev_pxa_register(CLK_CORE, "core", NULL, | ||
198 | clk_register_clk_pxa25x_core()); | ||
199 | } | ||
200 | |||
201 | static void __init pxa25x_register_plls(void) | ||
202 | { | ||
203 | clk_register_fixed_rate(NULL, "osc_3_6864mhz", NULL, | ||
204 | CLK_GET_RATE_NOCACHE | CLK_IS_ROOT, | ||
205 | 3686400); | ||
206 | clk_register_fixed_rate(NULL, "osc_32_768khz", NULL, | ||
207 | CLK_GET_RATE_NOCACHE | CLK_IS_ROOT, | ||
208 | 32768); | ||
209 | clk_register_fixed_rate(NULL, "clk_dummy", NULL, CLK_IS_ROOT, 0); | ||
210 | clk_register_fixed_factor(NULL, "ppll_95_85mhz", "osc_3_6864mhz", | ||
211 | 0, 26, 1); | ||
212 | clk_register_fixed_factor(NULL, "ppll_147_46mhz", "osc_3_6864mhz", | ||
213 | 0, 40, 1); | ||
214 | } | ||
215 | |||
216 | static void __init pxa25x_base_clocks_init(void) | ||
217 | { | ||
218 | pxa25x_register_plls(); | ||
219 | pxa25x_register_core(); | ||
220 | clk_register_clk_pxa25x_memory(); | ||
221 | } | ||
222 | |||
223 | #define DUMMY_CLK(_con_id, _dev_id, _parent) \ | ||
224 | { .con_id = _con_id, .dev_id = _dev_id, .parent = _parent } | ||
225 | struct dummy_clk { | ||
226 | const char *con_id; | ||
227 | const char *dev_id; | ||
228 | const char *parent; | ||
229 | }; | ||
230 | static struct dummy_clk dummy_clks[] __initdata = { | ||
231 | DUMMY_CLK(NULL, "pxa25x-gpio", "osc_32_768khz"), | ||
232 | DUMMY_CLK(NULL, "pxa26x-gpio", "osc_32_768khz"), | ||
233 | DUMMY_CLK("GPIO11_CLK", NULL, "osc_3_6864mhz"), | ||
234 | DUMMY_CLK("GPIO12_CLK", NULL, "osc_32_768khz"), | ||
235 | DUMMY_CLK(NULL, "sa1100-rtc", "osc_32_768khz"), | ||
236 | DUMMY_CLK("OSTIMER0", NULL, "osc_32_768khz"), | ||
237 | DUMMY_CLK("UARTCLK", "pxa2xx-ir", "STUART"), | ||
238 | }; | ||
239 | |||
240 | static void __init pxa25x_dummy_clocks_init(void) | ||
241 | { | ||
242 | struct clk *clk; | ||
243 | struct dummy_clk *d; | ||
244 | const char *name; | ||
245 | int i; | ||
246 | |||
247 | /* | ||
248 | * All pinctrl logic has been wiped out of the clock driver, especially | ||
249 | * for gpio11 and gpio12 outputs. Machine code should ensure proper pin | ||
250 | * control (ie. pxa2xx_mfp_config() invocation). | ||
251 | */ | ||
252 | for (i = 0; i < ARRAY_SIZE(dummy_clks); i++) { | ||
253 | d = &dummy_clks[i]; | ||
254 | name = d->dev_id ? d->dev_id : d->con_id; | ||
255 | clk = clk_register_fixed_factor(NULL, name, d->parent, 0, 1, 1); | ||
256 | clk_register_clkdev(clk, d->con_id, d->dev_id); | ||
257 | } | ||
258 | } | ||
259 | |||
260 | int __init pxa25x_clocks_init(void) | ||
261 | { | ||
262 | pxa25x_base_clocks_init(); | ||
263 | pxa25x_dummy_clocks_init(); | ||
264 | return clk_pxa_cken_init(pxa25x_clocks, ARRAY_SIZE(pxa25x_clocks)); | ||
265 | } | ||
266 | |||
267 | static void __init pxa25x_dt_clocks_init(struct device_node *np) | ||
268 | { | ||
269 | pxa25x_clocks_init(); | ||
270 | clk_pxa_dt_common_init(np); | ||
271 | } | ||
272 | CLK_OF_DECLARE(pxa25x_clks, "marvell,pxa250-core-clocks", | ||
273 | pxa25x_dt_clocks_init); | ||
diff --git a/drivers/clk/pxa/clk-pxa27x.c b/drivers/clk/pxa/clk-pxa27x.c index b345cc791e5d..bb8dfbc747ba 100644 --- a/drivers/clk/pxa/clk-pxa27x.c +++ b/drivers/clk/pxa/clk-pxa27x.c | |||
@@ -111,7 +111,7 @@ PARENTS(pxa27x_membus) = { "lcd_base", "lcd_base" }; | |||
111 | PXA_CKEN_1RATE(dev_id, con_id, bit, parents, \ | 111 | PXA_CKEN_1RATE(dev_id, con_id, bit, parents, \ |
112 | &CKEN, CKEN_ ## bit, CLK_IGNORE_UNUSED) | 112 | &CKEN, CKEN_ ## bit, CLK_IGNORE_UNUSED) |
113 | 113 | ||
114 | static struct pxa_clk_cken pxa27x_clocks[] = { | 114 | static struct desc_clk_cken pxa27x_clocks[] __initdata = { |
115 | PXA27X_PBUS_CKEN("pxa2xx-uart.0", NULL, FFUART, 2, 42, 1), | 115 | PXA27X_PBUS_CKEN("pxa2xx-uart.0", NULL, FFUART, 2, 42, 1), |
116 | PXA27X_PBUS_CKEN("pxa2xx-uart.1", NULL, BTUART, 2, 42, 1), | 116 | PXA27X_PBUS_CKEN("pxa2xx-uart.1", NULL, BTUART, 2, 42, 1), |
117 | PXA27X_PBUS_CKEN("pxa2xx-uart.2", NULL, STUART, 2, 42, 1), | 117 | PXA27X_PBUS_CKEN("pxa2xx-uart.2", NULL, STUART, 2, 42, 1), |
@@ -368,3 +368,10 @@ static int __init pxa27x_clocks_init(void) | |||
368 | return clk_pxa_cken_init(pxa27x_clocks, ARRAY_SIZE(pxa27x_clocks)); | 368 | return clk_pxa_cken_init(pxa27x_clocks, ARRAY_SIZE(pxa27x_clocks)); |
369 | } | 369 | } |
370 | postcore_initcall(pxa27x_clocks_init); | 370 | postcore_initcall(pxa27x_clocks_init); |
371 | |||
372 | static void __init pxa27x_dt_clocks_init(struct device_node *np) | ||
373 | { | ||
374 | pxa27x_clocks_init(); | ||
375 | clk_pxa_dt_common_init(np); | ||
376 | } | ||
377 | CLK_OF_DECLARE(pxa_clks, "marvell,pxa270-clocks", pxa27x_dt_clocks_init); | ||
diff --git a/drivers/clk/rockchip/clk-rk3188.c b/drivers/clk/rockchip/clk-rk3188.c index beed49c79126..f88eb7dacd97 100644 --- a/drivers/clk/rockchip/clk-rk3188.c +++ b/drivers/clk/rockchip/clk-rk3188.c | |||
@@ -257,9 +257,9 @@ static struct rockchip_clk_branch common_clk_branches[] __initdata = { | |||
257 | GATE(0, "hclk_vdpu", "aclk_vdpu", 0, | 257 | GATE(0, "hclk_vdpu", "aclk_vdpu", 0, |
258 | RK2928_CLKGATE_CON(3), 12, GFLAGS), | 258 | RK2928_CLKGATE_CON(3), 12, GFLAGS), |
259 | 259 | ||
260 | GATE(0, "gpll_ddr", "gpll", 0, | 260 | GATE(0, "gpll_ddr", "gpll", CLK_IGNORE_UNUSED, |
261 | RK2928_CLKGATE_CON(1), 7, GFLAGS), | 261 | RK2928_CLKGATE_CON(1), 7, GFLAGS), |
262 | COMPOSITE(0, "ddrphy", mux_ddrphy_p, 0, | 262 | COMPOSITE(0, "ddrphy", mux_ddrphy_p, CLK_IGNORE_UNUSED, |
263 | RK2928_CLKSEL_CON(26), 8, 1, MFLAGS, 0, 2, DFLAGS | CLK_DIVIDER_POWER_OF_TWO, | 263 | RK2928_CLKSEL_CON(26), 8, 1, MFLAGS, 0, 2, DFLAGS | CLK_DIVIDER_POWER_OF_TWO, |
264 | RK2928_CLKGATE_CON(0), 2, GFLAGS), | 264 | RK2928_CLKGATE_CON(0), 2, GFLAGS), |
265 | 265 | ||
@@ -270,10 +270,10 @@ static struct rockchip_clk_branch common_clk_branches[] __initdata = { | |||
270 | RK2928_CLKGATE_CON(0), 6, GFLAGS), | 270 | RK2928_CLKGATE_CON(0), 6, GFLAGS), |
271 | GATE(0, "pclk_cpu", "pclk_cpu_pre", 0, | 271 | GATE(0, "pclk_cpu", "pclk_cpu_pre", 0, |
272 | RK2928_CLKGATE_CON(0), 5, GFLAGS), | 272 | RK2928_CLKGATE_CON(0), 5, GFLAGS), |
273 | GATE(0, "hclk_cpu", "hclk_cpu_pre", 0, | 273 | GATE(0, "hclk_cpu", "hclk_cpu_pre", CLK_IGNORE_UNUSED, |
274 | RK2928_CLKGATE_CON(0), 4, GFLAGS), | 274 | RK2928_CLKGATE_CON(0), 4, GFLAGS), |
275 | 275 | ||
276 | COMPOSITE(0, "aclk_lcdc0_pre", mux_pll_src_cpll_gpll_p, 0, | 276 | COMPOSITE(0, "aclk_lcdc0_pre", mux_pll_src_cpll_gpll_p, CLK_IGNORE_UNUSED, |
277 | RK2928_CLKSEL_CON(31), 7, 1, MFLAGS, 0, 5, DFLAGS, | 277 | RK2928_CLKSEL_CON(31), 7, 1, MFLAGS, 0, 5, DFLAGS, |
278 | RK2928_CLKGATE_CON(3), 0, GFLAGS), | 278 | RK2928_CLKGATE_CON(3), 0, GFLAGS), |
279 | COMPOSITE(0, "aclk_lcdc1_pre", mux_pll_src_cpll_gpll_p, 0, | 279 | COMPOSITE(0, "aclk_lcdc1_pre", mux_pll_src_cpll_gpll_p, 0, |
@@ -304,9 +304,9 @@ static struct rockchip_clk_branch common_clk_branches[] __initdata = { | |||
304 | * the 480m are generated inside the usb block from these clocks, | 304 | * the 480m are generated inside the usb block from these clocks, |
305 | * but they are also a source for the hsicphy clock. | 305 | * but they are also a source for the hsicphy clock. |
306 | */ | 306 | */ |
307 | GATE(SCLK_OTGPHY0, "sclk_otgphy0", "usb480m", 0, | 307 | GATE(SCLK_OTGPHY0, "sclk_otgphy0", "usb480m", CLK_IGNORE_UNUSED, |
308 | RK2928_CLKGATE_CON(1), 5, GFLAGS), | 308 | RK2928_CLKGATE_CON(1), 5, GFLAGS), |
309 | GATE(SCLK_OTGPHY1, "sclk_otgphy1", "usb480m", 0, | 309 | GATE(SCLK_OTGPHY1, "sclk_otgphy1", "usb480m", CLK_IGNORE_UNUSED, |
310 | RK2928_CLKGATE_CON(1), 6, GFLAGS), | 310 | RK2928_CLKGATE_CON(1), 6, GFLAGS), |
311 | 311 | ||
312 | COMPOSITE(0, "mac_src", mux_mac_p, 0, | 312 | COMPOSITE(0, "mac_src", mux_mac_p, 0, |
@@ -320,9 +320,9 @@ static struct rockchip_clk_branch common_clk_branches[] __initdata = { | |||
320 | COMPOSITE(0, "hsadc_src", mux_pll_src_gpll_cpll_p, 0, | 320 | COMPOSITE(0, "hsadc_src", mux_pll_src_gpll_cpll_p, 0, |
321 | RK2928_CLKSEL_CON(22), 0, 1, MFLAGS, 8, 8, DFLAGS, | 321 | RK2928_CLKSEL_CON(22), 0, 1, MFLAGS, 8, 8, DFLAGS, |
322 | RK2928_CLKGATE_CON(2), 6, GFLAGS), | 322 | RK2928_CLKGATE_CON(2), 6, GFLAGS), |
323 | COMPOSITE_FRAC(0, "hsadc_frac", "hsadc_src", | 323 | COMPOSITE_FRAC(0, "hsadc_frac", "hsadc_src", 0, |
324 | RK2928_CLKSEL_CON(23), 0, | 324 | RK2928_CLKSEL_CON(23), 0, |
325 | RK2928_CLKGATE_CON(2), 7, 0, GFLAGS), | 325 | RK2928_CLKGATE_CON(2), 7, GFLAGS), |
326 | MUX(SCLK_HSADC, "sclk_hsadc", mux_sclk_hsadc_p, 0, | 326 | MUX(SCLK_HSADC, "sclk_hsadc", mux_sclk_hsadc_p, 0, |
327 | RK2928_CLKSEL_CON(22), 4, 2, MFLAGS), | 327 | RK2928_CLKSEL_CON(22), 4, 2, MFLAGS), |
328 | 328 | ||
@@ -399,8 +399,8 @@ static struct rockchip_clk_branch common_clk_branches[] __initdata = { | |||
399 | 399 | ||
400 | /* aclk_cpu gates */ | 400 | /* aclk_cpu gates */ |
401 | GATE(ACLK_DMA1, "aclk_dma1", "aclk_cpu", 0, RK2928_CLKGATE_CON(5), 0, GFLAGS), | 401 | GATE(ACLK_DMA1, "aclk_dma1", "aclk_cpu", 0, RK2928_CLKGATE_CON(5), 0, GFLAGS), |
402 | GATE(0, "aclk_intmem", "aclk_cpu", 0, RK2928_CLKGATE_CON(4), 12, GFLAGS), | 402 | GATE(0, "aclk_intmem", "aclk_cpu", CLK_IGNORE_UNUSED, RK2928_CLKGATE_CON(4), 12, GFLAGS), |
403 | GATE(0, "aclk_strc_sys", "aclk_cpu", 0, RK2928_CLKGATE_CON(4), 10, GFLAGS), | 403 | GATE(0, "aclk_strc_sys", "aclk_cpu", CLK_IGNORE_UNUSED, RK2928_CLKGATE_CON(4), 10, GFLAGS), |
404 | 404 | ||
405 | /* hclk_cpu gates */ | 405 | /* hclk_cpu gates */ |
406 | GATE(HCLK_ROM, "hclk_rom", "hclk_cpu", 0, RK2928_CLKGATE_CON(5), 6, GFLAGS), | 406 | GATE(HCLK_ROM, "hclk_rom", "hclk_cpu", 0, RK2928_CLKGATE_CON(5), 6, GFLAGS), |
@@ -416,8 +416,8 @@ static struct rockchip_clk_branch common_clk_branches[] __initdata = { | |||
416 | GATE(HCLK_RGA, "hclk_rga", "hclk_cpu", 0, RK2928_CLKGATE_CON(6), 10, GFLAGS), | 416 | GATE(HCLK_RGA, "hclk_rga", "hclk_cpu", 0, RK2928_CLKGATE_CON(6), 10, GFLAGS), |
417 | 417 | ||
418 | /* hclk_peri gates */ | 418 | /* hclk_peri gates */ |
419 | GATE(0, "hclk_peri_axi_matrix", "hclk_peri", 0, RK2928_CLKGATE_CON(4), 0, GFLAGS), | 419 | GATE(0, "hclk_peri_axi_matrix", "hclk_peri", CLK_IGNORE_UNUSED, RK2928_CLKGATE_CON(4), 0, GFLAGS), |
420 | GATE(0, "hclk_peri_ahb_arbi", "hclk_peri", 0, RK2928_CLKGATE_CON(4), 6, GFLAGS), | 420 | GATE(0, "hclk_peri_ahb_arbi", "hclk_peri", CLK_IGNORE_UNUSED, RK2928_CLKGATE_CON(4), 6, GFLAGS), |
421 | GATE(0, "hclk_emem_peri", "hclk_peri", 0, RK2928_CLKGATE_CON(4), 7, GFLAGS), | 421 | GATE(0, "hclk_emem_peri", "hclk_peri", 0, RK2928_CLKGATE_CON(4), 7, GFLAGS), |
422 | GATE(HCLK_EMAC, "hclk_emac", "hclk_peri", 0, RK2928_CLKGATE_CON(7), 0, GFLAGS), | 422 | GATE(HCLK_EMAC, "hclk_emac", "hclk_peri", 0, RK2928_CLKGATE_CON(7), 0, GFLAGS), |
423 | GATE(HCLK_NANDC0, "hclk_nandc0", "hclk_peri", 0, RK2928_CLKGATE_CON(5), 9, GFLAGS), | 423 | GATE(HCLK_NANDC0, "hclk_nandc0", "hclk_peri", 0, RK2928_CLKGATE_CON(5), 9, GFLAGS), |
@@ -457,18 +457,18 @@ static struct rockchip_clk_branch common_clk_branches[] __initdata = { | |||
457 | GATE(0, "pclk_ddrupctl", "pclk_cpu", 0, RK2928_CLKGATE_CON(5), 7, GFLAGS), | 457 | GATE(0, "pclk_ddrupctl", "pclk_cpu", 0, RK2928_CLKGATE_CON(5), 7, GFLAGS), |
458 | GATE(0, "pclk_ddrpubl", "pclk_cpu", 0, RK2928_CLKGATE_CON(9), 6, GFLAGS), | 458 | GATE(0, "pclk_ddrpubl", "pclk_cpu", 0, RK2928_CLKGATE_CON(9), 6, GFLAGS), |
459 | GATE(0, "pclk_dbg", "pclk_cpu", 0, RK2928_CLKGATE_CON(9), 1, GFLAGS), | 459 | GATE(0, "pclk_dbg", "pclk_cpu", 0, RK2928_CLKGATE_CON(9), 1, GFLAGS), |
460 | GATE(PCLK_GRF, "pclk_grf", "pclk_cpu", 0, RK2928_CLKGATE_CON(5), 4, GFLAGS), | 460 | GATE(PCLK_GRF, "pclk_grf", "pclk_cpu", CLK_IGNORE_UNUSED, RK2928_CLKGATE_CON(5), 4, GFLAGS), |
461 | GATE(PCLK_PMU, "pclk_pmu", "pclk_cpu", 0, RK2928_CLKGATE_CON(5), 5, GFLAGS), | 461 | GATE(PCLK_PMU, "pclk_pmu", "pclk_cpu", CLK_IGNORE_UNUSED, RK2928_CLKGATE_CON(5), 5, GFLAGS), |
462 | 462 | ||
463 | /* aclk_peri */ | 463 | /* aclk_peri */ |
464 | GATE(ACLK_DMA2, "aclk_dma2", "aclk_peri", 0, RK2928_CLKGATE_CON(5), 1, GFLAGS), | 464 | GATE(ACLK_DMA2, "aclk_dma2", "aclk_peri", 0, RK2928_CLKGATE_CON(5), 1, GFLAGS), |
465 | GATE(ACLK_SMC, "aclk_smc", "aclk_peri", 0, RK2928_CLKGATE_CON(5), 8, GFLAGS), | 465 | GATE(ACLK_SMC, "aclk_smc", "aclk_peri", 0, RK2928_CLKGATE_CON(5), 8, GFLAGS), |
466 | GATE(0, "aclk_peri_niu", "aclk_peri", 0, RK2928_CLKGATE_CON(4), 4, GFLAGS), | 466 | GATE(0, "aclk_peri_niu", "aclk_peri", CLK_IGNORE_UNUSED, RK2928_CLKGATE_CON(4), 4, GFLAGS), |
467 | GATE(0, "aclk_cpu_peri", "aclk_peri", 0, RK2928_CLKGATE_CON(4), 2, GFLAGS), | 467 | GATE(0, "aclk_cpu_peri", "aclk_peri", CLK_IGNORE_UNUSED, RK2928_CLKGATE_CON(4), 2, GFLAGS), |
468 | GATE(0, "aclk_peri_axi_matrix", "aclk_peri", 0, RK2928_CLKGATE_CON(4), 3, GFLAGS), | 468 | GATE(0, "aclk_peri_axi_matrix", "aclk_peri", CLK_IGNORE_UNUSED, RK2928_CLKGATE_CON(4), 3, GFLAGS), |
469 | 469 | ||
470 | /* pclk_peri gates */ | 470 | /* pclk_peri gates */ |
471 | GATE(0, "pclk_peri_axi_matrix", "pclk_peri", 0, RK2928_CLKGATE_CON(4), 1, GFLAGS), | 471 | GATE(0, "pclk_peri_axi_matrix", "pclk_peri", CLK_IGNORE_UNUSED, RK2928_CLKGATE_CON(4), 1, GFLAGS), |
472 | GATE(PCLK_PWM23, "pclk_pwm23", "pclk_peri", 0, RK2928_CLKGATE_CON(7), 11, GFLAGS), | 472 | GATE(PCLK_PWM23, "pclk_pwm23", "pclk_peri", 0, RK2928_CLKGATE_CON(7), 11, GFLAGS), |
473 | GATE(PCLK_WDT, "pclk_wdt", "pclk_peri", 0, RK2928_CLKGATE_CON(7), 15, GFLAGS), | 473 | GATE(PCLK_WDT, "pclk_wdt", "pclk_peri", 0, RK2928_CLKGATE_CON(7), 15, GFLAGS), |
474 | GATE(PCLK_SPI0, "pclk_spi0", "pclk_peri", 0, RK2928_CLKGATE_CON(7), 12, GFLAGS), | 474 | GATE(PCLK_SPI0, "pclk_spi0", "pclk_peri", 0, RK2928_CLKGATE_CON(7), 12, GFLAGS), |
@@ -511,7 +511,7 @@ static struct rockchip_clk_branch rk3066a_clk_branches[] __initdata = { | |||
511 | | CLK_DIVIDER_READ_ONLY, | 511 | | CLK_DIVIDER_READ_ONLY, |
512 | RK2928_CLKGATE_CON(4), 9, GFLAGS), | 512 | RK2928_CLKGATE_CON(4), 9, GFLAGS), |
513 | 513 | ||
514 | GATE(CORE_L2C, "core_l2c", "aclk_cpu", 0, | 514 | GATE(CORE_L2C, "core_l2c", "aclk_cpu", CLK_IGNORE_UNUSED, |
515 | RK2928_CLKGATE_CON(9), 4, GFLAGS), | 515 | RK2928_CLKGATE_CON(9), 4, GFLAGS), |
516 | 516 | ||
517 | COMPOSITE(0, "aclk_peri_pre", mux_pll_src_gpll_cpll_p, 0, | 517 | COMPOSITE(0, "aclk_peri_pre", mux_pll_src_gpll_cpll_p, 0, |
@@ -618,7 +618,7 @@ PNAME(mux_hsicphy_p) = { "sclk_otgphy0", "sclk_otgphy1", | |||
618 | "gpll", "cpll" }; | 618 | "gpll", "cpll" }; |
619 | 619 | ||
620 | static struct rockchip_clk_branch rk3188_clk_branches[] __initdata = { | 620 | static struct rockchip_clk_branch rk3188_clk_branches[] __initdata = { |
621 | COMPOSITE_NOMUX_DIVTBL(0, "aclk_core", "armclk", 0, | 621 | COMPOSITE_NOMUX_DIVTBL(0, "aclk_core", "armclk", CLK_IGNORE_UNUSED, |
622 | RK2928_CLKSEL_CON(1), 3, 3, DFLAGS | CLK_DIVIDER_READ_ONLY, | 622 | RK2928_CLKSEL_CON(1), 3, 3, DFLAGS | CLK_DIVIDER_READ_ONLY, |
623 | div_rk3188_aclk_core_t, RK2928_CLKGATE_CON(0), 7, GFLAGS), | 623 | div_rk3188_aclk_core_t, RK2928_CLKGATE_CON(0), 7, GFLAGS), |
624 | 624 | ||
@@ -633,7 +633,7 @@ static struct rockchip_clk_branch rk3188_clk_branches[] __initdata = { | |||
633 | RK2928_CLKSEL_CON(1), 14, 2, DFLAGS | CLK_DIVIDER_POWER_OF_TWO, | 633 | RK2928_CLKSEL_CON(1), 14, 2, DFLAGS | CLK_DIVIDER_POWER_OF_TWO, |
634 | RK2928_CLKGATE_CON(4), 9, GFLAGS), | 634 | RK2928_CLKGATE_CON(4), 9, GFLAGS), |
635 | 635 | ||
636 | GATE(CORE_L2C, "core_l2c", "armclk", 0, | 636 | GATE(CORE_L2C, "core_l2c", "armclk", CLK_IGNORE_UNUSED, |
637 | RK2928_CLKGATE_CON(9), 4, GFLAGS), | 637 | RK2928_CLKGATE_CON(9), 4, GFLAGS), |
638 | 638 | ||
639 | COMPOSITE(0, "aclk_peri_pre", mux_pll_src_cpll_gpll_p, 0, | 639 | COMPOSITE(0, "aclk_peri_pre", mux_pll_src_cpll_gpll_p, 0, |
diff --git a/drivers/clk/rockchip/clk-rk3288.c b/drivers/clk/rockchip/clk-rk3288.c index 23278291da44..174589c95e33 100644 --- a/drivers/clk/rockchip/clk-rk3288.c +++ b/drivers/clk/rockchip/clk-rk3288.c | |||
@@ -16,6 +16,7 @@ | |||
16 | #include <linux/clk-provider.h> | 16 | #include <linux/clk-provider.h> |
17 | #include <linux/of.h> | 17 | #include <linux/of.h> |
18 | #include <linux/of_address.h> | 18 | #include <linux/of_address.h> |
19 | #include <linux/syscore_ops.h> | ||
19 | #include <dt-bindings/clock/rk3288-cru.h> | 20 | #include <dt-bindings/clock/rk3288-cru.h> |
20 | #include "clk.h" | 21 | #include "clk.h" |
21 | 22 | ||
@@ -83,11 +84,13 @@ struct rockchip_pll_rate_table rk3288_pll_rates[] = { | |||
83 | RK3066_PLL_RATE( 742500000, 8, 495, 2), | 84 | RK3066_PLL_RATE( 742500000, 8, 495, 2), |
84 | RK3066_PLL_RATE( 696000000, 1, 58, 2), | 85 | RK3066_PLL_RATE( 696000000, 1, 58, 2), |
85 | RK3066_PLL_RATE( 600000000, 1, 50, 2), | 86 | RK3066_PLL_RATE( 600000000, 1, 50, 2), |
86 | RK3066_PLL_RATE( 594000000, 2, 198, 4), | 87 | RK3066_PLL_RATE_BWADJ(594000000, 1, 198, 8, 1), |
87 | RK3066_PLL_RATE( 552000000, 1, 46, 2), | 88 | RK3066_PLL_RATE( 552000000, 1, 46, 2), |
88 | RK3066_PLL_RATE( 504000000, 1, 84, 4), | 89 | RK3066_PLL_RATE( 504000000, 1, 84, 4), |
90 | RK3066_PLL_RATE( 500000000, 3, 125, 2), | ||
89 | RK3066_PLL_RATE( 456000000, 1, 76, 4), | 91 | RK3066_PLL_RATE( 456000000, 1, 76, 4), |
90 | RK3066_PLL_RATE( 408000000, 1, 68, 4), | 92 | RK3066_PLL_RATE( 408000000, 1, 68, 4), |
93 | RK3066_PLL_RATE( 400000000, 3, 100, 2), | ||
91 | RK3066_PLL_RATE( 384000000, 2, 128, 4), | 94 | RK3066_PLL_RATE( 384000000, 2, 128, 4), |
92 | RK3066_PLL_RATE( 360000000, 1, 60, 4), | 95 | RK3066_PLL_RATE( 360000000, 1, 60, 4), |
93 | RK3066_PLL_RATE( 312000000, 1, 52, 4), | 96 | RK3066_PLL_RATE( 312000000, 1, 52, 4), |
@@ -173,14 +176,14 @@ PNAME(mux_aclk_cpu_src_p) = { "cpll_aclk_cpu", "gpll_aclk_cpu" }; | |||
173 | PNAME(mux_pll_src_cpll_gpll_p) = { "cpll", "gpll" }; | 176 | PNAME(mux_pll_src_cpll_gpll_p) = { "cpll", "gpll" }; |
174 | PNAME(mux_pll_src_npll_cpll_gpll_p) = { "npll", "cpll", "gpll" }; | 177 | PNAME(mux_pll_src_npll_cpll_gpll_p) = { "npll", "cpll", "gpll" }; |
175 | PNAME(mux_pll_src_cpll_gpll_npll_p) = { "cpll", "gpll", "npll" }; | 178 | PNAME(mux_pll_src_cpll_gpll_npll_p) = { "cpll", "gpll", "npll" }; |
176 | PNAME(mux_pll_src_cpll_gpll_usb480m_p) = { "cpll", "gpll", "usb480m" }; | 179 | PNAME(mux_pll_src_cpll_gpll_usb480m_p) = { "cpll", "gpll", "usbphy480m_src" }; |
180 | PNAME(mux_pll_src_cpll_gll_usb_npll_p) = { "cpll", "gpll", "usbphy480m_src", "npll" }; | ||
177 | 181 | ||
178 | PNAME(mux_mmc_src_p) = { "cpll", "gpll", "xin24m", "xin24m" }; | 182 | PNAME(mux_mmc_src_p) = { "cpll", "gpll", "xin24m", "xin24m" }; |
179 | PNAME(mux_i2s_pre_p) = { "i2s_src", "i2s_frac", "ext_i2s", "xin12m" }; | 183 | PNAME(mux_i2s_pre_p) = { "i2s_src", "i2s_frac", "ext_i2s", "xin12m" }; |
180 | PNAME(mux_i2s_clkout_p) = { "i2s_pre", "xin12m" }; | 184 | PNAME(mux_i2s_clkout_p) = { "i2s_pre", "xin12m" }; |
181 | PNAME(mux_spdif_p) = { "spdif_pre", "spdif_frac", "xin12m" }; | 185 | PNAME(mux_spdif_p) = { "spdif_pre", "spdif_frac", "xin12m" }; |
182 | PNAME(mux_spdif_8ch_p) = { "spdif_8ch_pre", "spdif_8ch_frac", "xin12m" }; | 186 | PNAME(mux_spdif_8ch_p) = { "spdif_8ch_pre", "spdif_8ch_frac", "xin12m" }; |
183 | PNAME(mux_uart0_pll_p) = { "cpll", "gpll", "usbphy_480m_src", "npll" }; | ||
184 | PNAME(mux_uart0_p) = { "uart0_src", "uart0_frac", "xin24m" }; | 187 | PNAME(mux_uart0_p) = { "uart0_src", "uart0_frac", "xin24m" }; |
185 | PNAME(mux_uart1_p) = { "uart1_src", "uart1_frac", "xin24m" }; | 188 | PNAME(mux_uart1_p) = { "uart1_src", "uart1_frac", "xin24m" }; |
186 | PNAME(mux_uart2_p) = { "uart2_src", "uart2_frac", "xin24m" }; | 189 | PNAME(mux_uart2_p) = { "uart2_src", "uart2_frac", "xin24m" }; |
@@ -192,8 +195,8 @@ PNAME(mux_hsadcout_p) = { "hsadc_src", "ext_hsadc" }; | |||
192 | PNAME(mux_edp_24m_p) = { "ext_edp_24m", "xin24m" }; | 195 | PNAME(mux_edp_24m_p) = { "ext_edp_24m", "xin24m" }; |
193 | PNAME(mux_tspout_p) = { "cpll", "gpll", "npll", "xin27m" }; | 196 | PNAME(mux_tspout_p) = { "cpll", "gpll", "npll", "xin27m" }; |
194 | 197 | ||
195 | PNAME(mux_usbphy480m_p) = { "sclk_otgphy0", "sclk_otgphy1", | 198 | PNAME(mux_usbphy480m_p) = { "sclk_otgphy1", "sclk_otgphy2", |
196 | "sclk_otgphy2" }; | 199 | "sclk_otgphy0" }; |
197 | PNAME(mux_hsicphy480m_p) = { "cpll", "gpll", "usbphy480m_src" }; | 200 | PNAME(mux_hsicphy480m_p) = { "cpll", "gpll", "usbphy480m_src" }; |
198 | PNAME(mux_hsicphy12m_p) = { "hsicphy12m_xin12m", "hsicphy12m_usbphy" }; | 201 | PNAME(mux_hsicphy12m_p) = { "hsicphy12m_xin12m", "hsicphy12m_usbphy" }; |
199 | 202 | ||
@@ -226,67 +229,67 @@ static struct rockchip_clk_branch rk3288_clk_branches[] __initdata = { | |||
226 | * Clock-Architecture Diagram 1 | 229 | * Clock-Architecture Diagram 1 |
227 | */ | 230 | */ |
228 | 231 | ||
229 | GATE(0, "apll_core", "apll", 0, | 232 | GATE(0, "apll_core", "apll", CLK_IGNORE_UNUSED, |
230 | RK3288_CLKGATE_CON(0), 1, GFLAGS), | 233 | RK3288_CLKGATE_CON(0), 1, GFLAGS), |
231 | GATE(0, "gpll_core", "gpll", 0, | 234 | GATE(0, "gpll_core", "gpll", CLK_IGNORE_UNUSED, |
232 | RK3288_CLKGATE_CON(0), 2, GFLAGS), | 235 | RK3288_CLKGATE_CON(0), 2, GFLAGS), |
233 | 236 | ||
234 | COMPOSITE_NOMUX(0, "armcore0", "armclk", 0, | 237 | COMPOSITE_NOMUX(0, "armcore0", "armclk", CLK_IGNORE_UNUSED, |
235 | RK3288_CLKSEL_CON(36), 0, 3, DFLAGS | CLK_DIVIDER_READ_ONLY, | 238 | RK3288_CLKSEL_CON(36), 0, 3, DFLAGS | CLK_DIVIDER_READ_ONLY, |
236 | RK3288_CLKGATE_CON(12), 0, GFLAGS), | 239 | RK3288_CLKGATE_CON(12), 0, GFLAGS), |
237 | COMPOSITE_NOMUX(0, "armcore1", "armclk", 0, | 240 | COMPOSITE_NOMUX(0, "armcore1", "armclk", CLK_IGNORE_UNUSED, |
238 | RK3288_CLKSEL_CON(36), 4, 3, DFLAGS | CLK_DIVIDER_READ_ONLY, | 241 | RK3288_CLKSEL_CON(36), 4, 3, DFLAGS | CLK_DIVIDER_READ_ONLY, |
239 | RK3288_CLKGATE_CON(12), 1, GFLAGS), | 242 | RK3288_CLKGATE_CON(12), 1, GFLAGS), |
240 | COMPOSITE_NOMUX(0, "armcore2", "armclk", 0, | 243 | COMPOSITE_NOMUX(0, "armcore2", "armclk", CLK_IGNORE_UNUSED, |
241 | RK3288_CLKSEL_CON(36), 8, 3, DFLAGS | CLK_DIVIDER_READ_ONLY, | 244 | RK3288_CLKSEL_CON(36), 8, 3, DFLAGS | CLK_DIVIDER_READ_ONLY, |
242 | RK3288_CLKGATE_CON(12), 2, GFLAGS), | 245 | RK3288_CLKGATE_CON(12), 2, GFLAGS), |
243 | COMPOSITE_NOMUX(0, "armcore3", "armclk", 0, | 246 | COMPOSITE_NOMUX(0, "armcore3", "armclk", CLK_IGNORE_UNUSED, |
244 | RK3288_CLKSEL_CON(36), 12, 3, DFLAGS | CLK_DIVIDER_READ_ONLY, | 247 | RK3288_CLKSEL_CON(36), 12, 3, DFLAGS | CLK_DIVIDER_READ_ONLY, |
245 | RK3288_CLKGATE_CON(12), 3, GFLAGS), | 248 | RK3288_CLKGATE_CON(12), 3, GFLAGS), |
246 | COMPOSITE_NOMUX(0, "l2ram", "armclk", 0, | 249 | COMPOSITE_NOMUX(0, "l2ram", "armclk", CLK_IGNORE_UNUSED, |
247 | RK3288_CLKSEL_CON(37), 0, 3, DFLAGS | CLK_DIVIDER_READ_ONLY, | 250 | RK3288_CLKSEL_CON(37), 0, 3, DFLAGS | CLK_DIVIDER_READ_ONLY, |
248 | RK3288_CLKGATE_CON(12), 4, GFLAGS), | 251 | RK3288_CLKGATE_CON(12), 4, GFLAGS), |
249 | COMPOSITE_NOMUX(0, "aclk_core_m0", "armclk", 0, | 252 | COMPOSITE_NOMUX(0, "aclk_core_m0", "armclk", CLK_IGNORE_UNUSED, |
250 | RK3288_CLKSEL_CON(0), 0, 4, DFLAGS | CLK_DIVIDER_READ_ONLY, | 253 | RK3288_CLKSEL_CON(0), 0, 4, DFLAGS | CLK_DIVIDER_READ_ONLY, |
251 | RK3288_CLKGATE_CON(12), 5, GFLAGS), | 254 | RK3288_CLKGATE_CON(12), 5, GFLAGS), |
252 | COMPOSITE_NOMUX(0, "aclk_core_mp", "armclk", 0, | 255 | COMPOSITE_NOMUX(0, "aclk_core_mp", "armclk", CLK_IGNORE_UNUSED, |
253 | RK3288_CLKSEL_CON(0), 4, 4, DFLAGS | CLK_DIVIDER_READ_ONLY, | 256 | RK3288_CLKSEL_CON(0), 4, 4, DFLAGS | CLK_DIVIDER_READ_ONLY, |
254 | RK3288_CLKGATE_CON(12), 6, GFLAGS), | 257 | RK3288_CLKGATE_CON(12), 6, GFLAGS), |
255 | COMPOSITE_NOMUX(0, "atclk", "armclk", 0, | 258 | COMPOSITE_NOMUX(0, "atclk", "armclk", 0, |
256 | RK3288_CLKSEL_CON(37), 4, 5, DFLAGS | CLK_DIVIDER_READ_ONLY, | 259 | RK3288_CLKSEL_CON(37), 4, 5, DFLAGS | CLK_DIVIDER_READ_ONLY, |
257 | RK3288_CLKGATE_CON(12), 7, GFLAGS), | 260 | RK3288_CLKGATE_CON(12), 7, GFLAGS), |
258 | COMPOSITE_NOMUX(0, "pclk_dbg_pre", "armclk", 0, | 261 | COMPOSITE_NOMUX(0, "pclk_dbg_pre", "armclk", CLK_IGNORE_UNUSED, |
259 | RK3288_CLKSEL_CON(37), 9, 5, DFLAGS | CLK_DIVIDER_READ_ONLY, | 262 | RK3288_CLKSEL_CON(37), 9, 5, DFLAGS | CLK_DIVIDER_READ_ONLY, |
260 | RK3288_CLKGATE_CON(12), 8, GFLAGS), | 263 | RK3288_CLKGATE_CON(12), 8, GFLAGS), |
261 | GATE(0, "pclk_dbg", "pclk_dbg_pre", 0, | 264 | GATE(0, "pclk_dbg", "pclk_dbg_pre", 0, |
262 | RK3288_CLKGATE_CON(12), 9, GFLAGS), | 265 | RK3288_CLKGATE_CON(12), 9, GFLAGS), |
263 | GATE(0, "cs_dbg", "pclk_dbg_pre", 0, | 266 | GATE(0, "cs_dbg", "pclk_dbg_pre", CLK_IGNORE_UNUSED, |
264 | RK3288_CLKGATE_CON(12), 10, GFLAGS), | 267 | RK3288_CLKGATE_CON(12), 10, GFLAGS), |
265 | GATE(0, "pclk_core_niu", "pclk_dbg_pre", 0, | 268 | GATE(0, "pclk_core_niu", "pclk_dbg_pre", 0, |
266 | RK3288_CLKGATE_CON(12), 11, GFLAGS), | 269 | RK3288_CLKGATE_CON(12), 11, GFLAGS), |
267 | 270 | ||
268 | GATE(0, "dpll_ddr", "dpll", 0, | 271 | GATE(0, "dpll_ddr", "dpll", CLK_IGNORE_UNUSED, |
269 | RK3288_CLKGATE_CON(0), 8, GFLAGS), | 272 | RK3288_CLKGATE_CON(0), 8, GFLAGS), |
270 | GATE(0, "gpll_ddr", "gpll", 0, | 273 | GATE(0, "gpll_ddr", "gpll", 0, |
271 | RK3288_CLKGATE_CON(0), 9, GFLAGS), | 274 | RK3288_CLKGATE_CON(0), 9, GFLAGS), |
272 | COMPOSITE_NOGATE(0, "ddrphy", mux_ddrphy_p, 0, | 275 | COMPOSITE_NOGATE(0, "ddrphy", mux_ddrphy_p, CLK_IGNORE_UNUSED, |
273 | RK3288_CLKSEL_CON(26), 2, 1, MFLAGS, 0, 2, | 276 | RK3288_CLKSEL_CON(26), 2, 1, MFLAGS, 0, 2, |
274 | DFLAGS | CLK_DIVIDER_POWER_OF_TWO), | 277 | DFLAGS | CLK_DIVIDER_POWER_OF_TWO), |
275 | 278 | ||
276 | GATE(0, "gpll_aclk_cpu", "gpll", 0, | 279 | GATE(0, "gpll_aclk_cpu", "gpll", CLK_IGNORE_UNUSED, |
277 | RK3288_CLKGATE_CON(0), 10, GFLAGS), | 280 | RK3288_CLKGATE_CON(0), 10, GFLAGS), |
278 | GATE(0, "cpll_aclk_cpu", "cpll", 0, | 281 | GATE(0, "cpll_aclk_cpu", "cpll", CLK_IGNORE_UNUSED, |
279 | RK3288_CLKGATE_CON(0), 11, GFLAGS), | 282 | RK3288_CLKGATE_CON(0), 11, GFLAGS), |
280 | COMPOSITE_NOGATE(0, "aclk_cpu_src", mux_aclk_cpu_src_p, 0, | 283 | COMPOSITE_NOGATE(0, "aclk_cpu_src", mux_aclk_cpu_src_p, CLK_IGNORE_UNUSED, |
281 | RK3288_CLKSEL_CON(1), 15, 1, MFLAGS, 3, 5, DFLAGS), | 284 | RK3288_CLKSEL_CON(1), 15, 1, MFLAGS, 3, 5, DFLAGS), |
282 | DIV(0, "aclk_cpu_pre", "aclk_cpu_src", 0, | 285 | DIV(0, "aclk_cpu_pre", "aclk_cpu_src", CLK_SET_RATE_PARENT, |
283 | RK3288_CLKSEL_CON(1), 0, 3, DFLAGS), | 286 | RK3288_CLKSEL_CON(1), 0, 3, DFLAGS), |
284 | GATE(ACLK_CPU, "aclk_cpu", "aclk_cpu_pre", 0, | 287 | GATE(ACLK_CPU, "aclk_cpu", "aclk_cpu_pre", CLK_IGNORE_UNUSED, |
285 | RK3288_CLKGATE_CON(0), 3, GFLAGS), | 288 | RK3288_CLKGATE_CON(0), 3, GFLAGS), |
286 | COMPOSITE_NOMUX(PCLK_CPU, "pclk_cpu", "aclk_cpu_pre", 0, | 289 | COMPOSITE_NOMUX(PCLK_CPU, "pclk_cpu", "aclk_cpu_pre", CLK_IGNORE_UNUSED, |
287 | RK3288_CLKSEL_CON(1), 12, 3, DFLAGS, | 290 | RK3288_CLKSEL_CON(1), 12, 3, DFLAGS, |
288 | RK3288_CLKGATE_CON(0), 5, GFLAGS), | 291 | RK3288_CLKGATE_CON(0), 5, GFLAGS), |
289 | COMPOSITE_NOMUX_DIVTBL(HCLK_CPU, "hclk_cpu", "aclk_cpu_pre", 0, | 292 | COMPOSITE_NOMUX_DIVTBL(HCLK_CPU, "hclk_cpu", "aclk_cpu_pre", CLK_IGNORE_UNUSED, |
290 | RK3288_CLKSEL_CON(1), 8, 2, DFLAGS, div_hclk_cpu_t, | 293 | RK3288_CLKSEL_CON(1), 8, 2, DFLAGS, div_hclk_cpu_t, |
291 | RK3288_CLKGATE_CON(0), 4, GFLAGS), | 294 | RK3288_CLKGATE_CON(0), 4, GFLAGS), |
292 | GATE(0, "c2c_host", "aclk_cpu_src", 0, | 295 | GATE(0, "c2c_host", "aclk_cpu_src", 0, |
@@ -294,7 +297,7 @@ static struct rockchip_clk_branch rk3288_clk_branches[] __initdata = { | |||
294 | COMPOSITE_NOMUX(0, "crypto", "aclk_cpu_pre", 0, | 297 | COMPOSITE_NOMUX(0, "crypto", "aclk_cpu_pre", 0, |
295 | RK3288_CLKSEL_CON(26), 6, 2, DFLAGS, | 298 | RK3288_CLKSEL_CON(26), 6, 2, DFLAGS, |
296 | RK3288_CLKGATE_CON(5), 4, GFLAGS), | 299 | RK3288_CLKGATE_CON(5), 4, GFLAGS), |
297 | GATE(0, "aclk_bus_2pmu", "aclk_cpu_pre", 0, | 300 | GATE(0, "aclk_bus_2pmu", "aclk_cpu_pre", CLK_IGNORE_UNUSED, |
298 | RK3288_CLKGATE_CON(0), 7, GFLAGS), | 301 | RK3288_CLKGATE_CON(0), 7, GFLAGS), |
299 | 302 | ||
300 | COMPOSITE(0, "i2s_src", mux_pll_src_cpll_gpll_p, 0, | 303 | COMPOSITE(0, "i2s_src", mux_pll_src_cpll_gpll_p, 0, |
@@ -305,7 +308,7 @@ static struct rockchip_clk_branch rk3288_clk_branches[] __initdata = { | |||
305 | RK3288_CLKGATE_CON(4), 2, GFLAGS), | 308 | RK3288_CLKGATE_CON(4), 2, GFLAGS), |
306 | MUX(0, "i2s_pre", mux_i2s_pre_p, CLK_SET_RATE_PARENT, | 309 | MUX(0, "i2s_pre", mux_i2s_pre_p, CLK_SET_RATE_PARENT, |
307 | RK3288_CLKSEL_CON(4), 8, 2, MFLAGS), | 310 | RK3288_CLKSEL_CON(4), 8, 2, MFLAGS), |
308 | COMPOSITE_NODIV(0, "i2s0_clkout", mux_i2s_clkout_p, CLK_SET_RATE_PARENT, | 311 | COMPOSITE_NODIV(0, "i2s0_clkout", mux_i2s_clkout_p, 0, |
309 | RK3288_CLKSEL_CON(4), 12, 1, MFLAGS, | 312 | RK3288_CLKSEL_CON(4), 12, 1, MFLAGS, |
310 | RK3288_CLKGATE_CON(4), 0, GFLAGS), | 313 | RK3288_CLKGATE_CON(4), 0, GFLAGS), |
311 | GATE(SCLK_I2S0, "sclk_i2s0", "i2s_pre", CLK_SET_RATE_PARENT, | 314 | GATE(SCLK_I2S0, "sclk_i2s0", "i2s_pre", CLK_SET_RATE_PARENT, |
@@ -325,7 +328,7 @@ static struct rockchip_clk_branch rk3288_clk_branches[] __initdata = { | |||
325 | COMPOSITE_NOMUX(0, "spdif_8ch_pre", "spdif_src", 0, | 328 | COMPOSITE_NOMUX(0, "spdif_8ch_pre", "spdif_src", 0, |
326 | RK3288_CLKSEL_CON(40), 0, 7, DFLAGS, | 329 | RK3288_CLKSEL_CON(40), 0, 7, DFLAGS, |
327 | RK3288_CLKGATE_CON(4), 7, GFLAGS), | 330 | RK3288_CLKGATE_CON(4), 7, GFLAGS), |
328 | COMPOSITE_FRAC(0, "spdif_8ch_frac", "spdif_8ch_src", 0, | 331 | COMPOSITE_FRAC(0, "spdif_8ch_frac", "spdif_8ch_pre", 0, |
329 | RK3288_CLKSEL_CON(41), 0, | 332 | RK3288_CLKSEL_CON(41), 0, |
330 | RK3288_CLKGATE_CON(4), 8, GFLAGS), | 333 | RK3288_CLKGATE_CON(4), 8, GFLAGS), |
331 | COMPOSITE_NODIV(SCLK_SPDIF8CH, "sclk_spdif_8ch", mux_spdif_8ch_p, 0, | 334 | COMPOSITE_NODIV(SCLK_SPDIF8CH, "sclk_spdif_8ch", mux_spdif_8ch_p, 0, |
@@ -373,12 +376,12 @@ static struct rockchip_clk_branch rk3288_clk_branches[] __initdata = { | |||
373 | GATE(HCLK_VCODEC, "hclk_vcodec", "hclk_vcodec_pre", 0, | 376 | GATE(HCLK_VCODEC, "hclk_vcodec", "hclk_vcodec_pre", 0, |
374 | RK3288_CLKGATE_CON(9), 1, GFLAGS), | 377 | RK3288_CLKGATE_CON(9), 1, GFLAGS), |
375 | 378 | ||
376 | COMPOSITE(0, "aclk_vio0", mux_pll_src_cpll_gpll_usb480m_p, 0, | 379 | COMPOSITE(0, "aclk_vio0", mux_pll_src_cpll_gpll_usb480m_p, CLK_IGNORE_UNUSED, |
377 | RK3288_CLKSEL_CON(31), 6, 2, MFLAGS, 0, 5, DFLAGS, | 380 | RK3288_CLKSEL_CON(31), 6, 2, MFLAGS, 0, 5, DFLAGS, |
378 | RK3288_CLKGATE_CON(3), 0, GFLAGS), | 381 | RK3288_CLKGATE_CON(3), 0, GFLAGS), |
379 | DIV(0, "hclk_vio", "aclk_vio0", 0, | 382 | DIV(0, "hclk_vio", "aclk_vio0", 0, |
380 | RK3288_CLKSEL_CON(28), 8, 5, DFLAGS), | 383 | RK3288_CLKSEL_CON(28), 8, 5, DFLAGS), |
381 | COMPOSITE(0, "aclk_vio1", mux_pll_src_cpll_gpll_usb480m_p, 0, | 384 | COMPOSITE(0, "aclk_vio1", mux_pll_src_cpll_gpll_usb480m_p, CLK_IGNORE_UNUSED, |
382 | RK3288_CLKSEL_CON(31), 14, 2, MFLAGS, 8, 5, DFLAGS, | 385 | RK3288_CLKSEL_CON(31), 14, 2, MFLAGS, 8, 5, DFLAGS, |
383 | RK3288_CLKGATE_CON(3), 2, GFLAGS), | 386 | RK3288_CLKGATE_CON(3), 2, GFLAGS), |
384 | 387 | ||
@@ -436,24 +439,24 @@ static struct rockchip_clk_branch rk3288_clk_branches[] __initdata = { | |||
436 | 439 | ||
437 | DIV(0, "pclk_pd_alive", "gpll", 0, | 440 | DIV(0, "pclk_pd_alive", "gpll", 0, |
438 | RK3288_CLKSEL_CON(33), 8, 5, DFLAGS), | 441 | RK3288_CLKSEL_CON(33), 8, 5, DFLAGS), |
439 | COMPOSITE_NOMUX(0, "pclk_pd_pmu", "gpll", 0, | 442 | COMPOSITE_NOMUX(0, "pclk_pd_pmu", "gpll", CLK_IGNORE_UNUSED, |
440 | RK3288_CLKSEL_CON(33), 0, 5, DFLAGS, | 443 | RK3288_CLKSEL_CON(33), 0, 5, DFLAGS, |
441 | RK3288_CLKGATE_CON(5), 8, GFLAGS), | 444 | RK3288_CLKGATE_CON(5), 8, GFLAGS), |
442 | 445 | ||
443 | COMPOSITE(SCLK_GPU, "sclk_gpu", mux_pll_src_cpll_gpll_usb480m_p, 0, | 446 | COMPOSITE(SCLK_GPU, "sclk_gpu", mux_pll_src_cpll_gll_usb_npll_p, 0, |
444 | RK3288_CLKSEL_CON(34), 6, 2, MFLAGS, 0, 5, DFLAGS, | 447 | RK3288_CLKSEL_CON(34), 6, 2, MFLAGS, 0, 5, DFLAGS, |
445 | RK3288_CLKGATE_CON(5), 7, GFLAGS), | 448 | RK3288_CLKGATE_CON(5), 7, GFLAGS), |
446 | 449 | ||
447 | COMPOSITE(0, "aclk_peri_src", mux_pll_src_cpll_gpll_p, 0, | 450 | COMPOSITE(0, "aclk_peri_src", mux_pll_src_cpll_gpll_p, CLK_IGNORE_UNUSED, |
448 | RK3288_CLKSEL_CON(10), 15, 1, MFLAGS, 0, 5, DFLAGS, | 451 | RK3288_CLKSEL_CON(10), 15, 1, MFLAGS, 0, 5, DFLAGS, |
449 | RK3288_CLKGATE_CON(2), 0, GFLAGS), | 452 | RK3288_CLKGATE_CON(2), 0, GFLAGS), |
450 | COMPOSITE_NOMUX(PCLK_PERI, "pclk_peri", "aclk_peri_src", 0, | 453 | COMPOSITE_NOMUX(PCLK_PERI, "pclk_peri", "aclk_peri_src", 0, |
451 | RK3288_CLKSEL_CON(10), 12, 2, DFLAGS | CLK_DIVIDER_POWER_OF_TWO, | 454 | RK3288_CLKSEL_CON(10), 12, 2, DFLAGS | CLK_DIVIDER_POWER_OF_TWO, |
452 | RK3288_CLKGATE_CON(2), 3, GFLAGS), | 455 | RK3288_CLKGATE_CON(2), 3, GFLAGS), |
453 | COMPOSITE_NOMUX(HCLK_PERI, "hclk_peri", "aclk_peri_src", 0, | 456 | COMPOSITE_NOMUX(HCLK_PERI, "hclk_peri", "aclk_peri_src", CLK_IGNORE_UNUSED, |
454 | RK3288_CLKSEL_CON(10), 8, 2, DFLAGS | CLK_DIVIDER_POWER_OF_TWO, | 457 | RK3288_CLKSEL_CON(10), 8, 2, DFLAGS | CLK_DIVIDER_POWER_OF_TWO, |
455 | RK3288_CLKGATE_CON(2), 2, GFLAGS), | 458 | RK3288_CLKGATE_CON(2), 2, GFLAGS), |
456 | GATE(ACLK_PERI, "aclk_peri", "aclk_peri_src", 0, | 459 | GATE(ACLK_PERI, "aclk_peri", "aclk_peri_src", CLK_IGNORE_UNUSED, |
457 | RK3288_CLKGATE_CON(2), 1, GFLAGS), | 460 | RK3288_CLKGATE_CON(2), 1, GFLAGS), |
458 | 461 | ||
459 | /* | 462 | /* |
@@ -490,13 +493,13 @@ static struct rockchip_clk_branch rk3288_clk_branches[] __initdata = { | |||
490 | RK3288_CLKSEL_CON(35), 6, 2, MFLAGS, 0, 5, DFLAGS, | 493 | RK3288_CLKSEL_CON(35), 6, 2, MFLAGS, 0, 5, DFLAGS, |
491 | RK3288_CLKGATE_CON(4), 10, GFLAGS), | 494 | RK3288_CLKGATE_CON(4), 10, GFLAGS), |
492 | 495 | ||
493 | GATE(SCLK_OTGPHY0, "sclk_otgphy0", "usb480m", 0, | 496 | GATE(SCLK_OTGPHY0, "sclk_otgphy0", "usb480m", CLK_IGNORE_UNUSED, |
494 | RK3288_CLKGATE_CON(13), 4, GFLAGS), | 497 | RK3288_CLKGATE_CON(13), 4, GFLAGS), |
495 | GATE(SCLK_OTGPHY1, "sclk_otgphy1", "usb480m", 0, | 498 | GATE(SCLK_OTGPHY1, "sclk_otgphy1", "usb480m", CLK_IGNORE_UNUSED, |
496 | RK3288_CLKGATE_CON(13), 5, GFLAGS), | 499 | RK3288_CLKGATE_CON(13), 5, GFLAGS), |
497 | GATE(SCLK_OTGPHY2, "sclk_otgphy2", "usb480m", 0, | 500 | GATE(SCLK_OTGPHY2, "sclk_otgphy2", "usb480m", CLK_IGNORE_UNUSED, |
498 | RK3288_CLKGATE_CON(13), 6, GFLAGS), | 501 | RK3288_CLKGATE_CON(13), 6, GFLAGS), |
499 | GATE(SCLK_OTG_ADP, "sclk_otg_adp", "xin32k", 0, | 502 | GATE(SCLK_OTG_ADP, "sclk_otg_adp", "xin32k", CLK_IGNORE_UNUSED, |
500 | RK3288_CLKGATE_CON(13), 7, GFLAGS), | 503 | RK3288_CLKGATE_CON(13), 7, GFLAGS), |
501 | 504 | ||
502 | COMPOSITE_NOMUX(SCLK_TSADC, "sclk_tsadc", "xin32k", 0, | 505 | COMPOSITE_NOMUX(SCLK_TSADC, "sclk_tsadc", "xin32k", 0, |
@@ -517,7 +520,7 @@ static struct rockchip_clk_branch rk3288_clk_branches[] __initdata = { | |||
517 | RK3288_CLKSEL_CON(38), 15, 1, MFLAGS, 8, 5, DFLAGS, | 520 | RK3288_CLKSEL_CON(38), 15, 1, MFLAGS, 8, 5, DFLAGS, |
518 | RK3288_CLKGATE_CON(5), 6, GFLAGS), | 521 | RK3288_CLKGATE_CON(5), 6, GFLAGS), |
519 | 522 | ||
520 | COMPOSITE(0, "uart0_src", mux_uart0_pll_p, 0, | 523 | COMPOSITE(0, "uart0_src", mux_pll_src_cpll_gll_usb_npll_p, 0, |
521 | RK3288_CLKSEL_CON(13), 13, 2, MFLAGS, 0, 7, DFLAGS, | 524 | RK3288_CLKSEL_CON(13), 13, 2, MFLAGS, 0, 7, DFLAGS, |
522 | RK3288_CLKGATE_CON(1), 8, GFLAGS), | 525 | RK3288_CLKGATE_CON(1), 8, GFLAGS), |
523 | COMPOSITE_FRAC(0, "uart0_frac", "uart0_src", 0, | 526 | COMPOSITE_FRAC(0, "uart0_frac", "uart0_src", 0, |
@@ -585,7 +588,7 @@ static struct rockchip_clk_branch rk3288_clk_branches[] __initdata = { | |||
585 | 588 | ||
586 | COMPOSITE_NODIV(0, "usbphy480m_src", mux_usbphy480m_p, 0, | 589 | COMPOSITE_NODIV(0, "usbphy480m_src", mux_usbphy480m_p, 0, |
587 | RK3288_CLKSEL_CON(13), 11, 2, MFLAGS, | 590 | RK3288_CLKSEL_CON(13), 11, 2, MFLAGS, |
588 | RK3288_CLKGATE_CON(5), 15, GFLAGS), | 591 | RK3288_CLKGATE_CON(5), 14, GFLAGS), |
589 | COMPOSITE_NODIV(SCLK_HSICPHY480M, "sclk_hsicphy480m", mux_hsicphy480m_p, 0, | 592 | COMPOSITE_NODIV(SCLK_HSICPHY480M, "sclk_hsicphy480m", mux_hsicphy480m_p, 0, |
590 | RK3288_CLKSEL_CON(29), 0, 2, MFLAGS, | 593 | RK3288_CLKSEL_CON(29), 0, 2, MFLAGS, |
591 | RK3288_CLKGATE_CON(3), 6, GFLAGS), | 594 | RK3288_CLKGATE_CON(3), 6, GFLAGS), |
@@ -601,19 +604,19 @@ static struct rockchip_clk_branch rk3288_clk_branches[] __initdata = { | |||
601 | */ | 604 | */ |
602 | 605 | ||
603 | /* aclk_cpu gates */ | 606 | /* aclk_cpu gates */ |
604 | GATE(0, "sclk_intmem0", "aclk_cpu", 0, RK3288_CLKGATE_CON(10), 5, GFLAGS), | 607 | GATE(0, "sclk_intmem0", "aclk_cpu", CLK_IGNORE_UNUSED, RK3288_CLKGATE_CON(10), 5, GFLAGS), |
605 | GATE(0, "sclk_intmem1", "aclk_cpu", 0, RK3288_CLKGATE_CON(10), 6, GFLAGS), | 608 | GATE(0, "sclk_intmem1", "aclk_cpu", CLK_IGNORE_UNUSED, RK3288_CLKGATE_CON(10), 6, GFLAGS), |
606 | GATE(0, "sclk_intmem2", "aclk_cpu", 0, RK3288_CLKGATE_CON(10), 7, GFLAGS), | 609 | GATE(0, "sclk_intmem2", "aclk_cpu", CLK_IGNORE_UNUSED, RK3288_CLKGATE_CON(10), 7, GFLAGS), |
607 | GATE(ACLK_DMAC1, "aclk_dmac1", "aclk_cpu", 0, RK3288_CLKGATE_CON(10), 12, GFLAGS), | 610 | GATE(ACLK_DMAC1, "aclk_dmac1", "aclk_cpu", 0, RK3288_CLKGATE_CON(10), 12, GFLAGS), |
608 | GATE(0, "aclk_strc_sys", "aclk_cpu", 0, RK3288_CLKGATE_CON(10), 13, GFLAGS), | 611 | GATE(0, "aclk_strc_sys", "aclk_cpu", CLK_IGNORE_UNUSED, RK3288_CLKGATE_CON(10), 13, GFLAGS), |
609 | GATE(0, "aclk_intmem", "aclk_cpu", 0, RK3288_CLKGATE_CON(10), 4, GFLAGS), | 612 | GATE(0, "aclk_intmem", "aclk_cpu", CLK_IGNORE_UNUSED, RK3288_CLKGATE_CON(10), 4, GFLAGS), |
610 | GATE(ACLK_CRYPTO, "aclk_crypto", "aclk_cpu", 0, RK3288_CLKGATE_CON(11), 6, GFLAGS), | 613 | GATE(ACLK_CRYPTO, "aclk_crypto", "aclk_cpu", 0, RK3288_CLKGATE_CON(11), 6, GFLAGS), |
611 | GATE(0, "aclk_ccp", "aclk_cpu", 0, RK3288_CLKGATE_CON(11), 8, GFLAGS), | 614 | GATE(0, "aclk_ccp", "aclk_cpu", 0, RK3288_CLKGATE_CON(11), 8, GFLAGS), |
612 | 615 | ||
613 | /* hclk_cpu gates */ | 616 | /* hclk_cpu gates */ |
614 | GATE(HCLK_CRYPTO, "hclk_crypto", "hclk_cpu", 0, RK3288_CLKGATE_CON(11), 7, GFLAGS), | 617 | GATE(HCLK_CRYPTO, "hclk_crypto", "hclk_cpu", 0, RK3288_CLKGATE_CON(11), 7, GFLAGS), |
615 | GATE(HCLK_I2S0, "hclk_i2s0", "hclk_cpu", 0, RK3288_CLKGATE_CON(10), 8, GFLAGS), | 618 | GATE(HCLK_I2S0, "hclk_i2s0", "hclk_cpu", 0, RK3288_CLKGATE_CON(10), 8, GFLAGS), |
616 | GATE(HCLK_ROM, "hclk_rom", "hclk_cpu", 0, RK3288_CLKGATE_CON(10), 9, GFLAGS), | 619 | GATE(HCLK_ROM, "hclk_rom", "hclk_cpu", CLK_IGNORE_UNUSED, RK3288_CLKGATE_CON(10), 9, GFLAGS), |
617 | GATE(HCLK_SPDIF, "hclk_spdif", "hclk_cpu", 0, RK3288_CLKGATE_CON(10), 10, GFLAGS), | 620 | GATE(HCLK_SPDIF, "hclk_spdif", "hclk_cpu", 0, RK3288_CLKGATE_CON(10), 10, GFLAGS), |
618 | GATE(HCLK_SPDIF8CH, "hclk_spdif_8ch", "hclk_cpu", 0, RK3288_CLKGATE_CON(10), 11, GFLAGS), | 621 | GATE(HCLK_SPDIF8CH, "hclk_spdif_8ch", "hclk_cpu", 0, RK3288_CLKGATE_CON(10), 11, GFLAGS), |
619 | 622 | ||
@@ -630,34 +633,34 @@ static struct rockchip_clk_branch rk3288_clk_branches[] __initdata = { | |||
630 | GATE(PCLK_TZPC, "pclk_tzpc", "pclk_cpu", 0, RK3288_CLKGATE_CON(11), 3, GFLAGS), | 633 | GATE(PCLK_TZPC, "pclk_tzpc", "pclk_cpu", 0, RK3288_CLKGATE_CON(11), 3, GFLAGS), |
631 | GATE(PCLK_UART2, "pclk_uart2", "pclk_cpu", 0, RK3288_CLKGATE_CON(11), 9, GFLAGS), | 634 | GATE(PCLK_UART2, "pclk_uart2", "pclk_cpu", 0, RK3288_CLKGATE_CON(11), 9, GFLAGS), |
632 | GATE(0, "pclk_efuse_256", "pclk_cpu", 0, RK3288_CLKGATE_CON(11), 10, GFLAGS), | 635 | GATE(0, "pclk_efuse_256", "pclk_cpu", 0, RK3288_CLKGATE_CON(11), 10, GFLAGS), |
633 | GATE(PCLK_RKPWM, "pclk_rkpwm", "pclk_cpu", 0, RK3288_CLKGATE_CON(11), 11, GFLAGS), | 636 | GATE(PCLK_RKPWM, "pclk_rkpwm", "pclk_cpu", CLK_IGNORE_UNUSED, RK3288_CLKGATE_CON(11), 11, GFLAGS), |
634 | 637 | ||
635 | /* ddrctrl [DDR Controller PHY clock] gates */ | 638 | /* ddrctrl [DDR Controller PHY clock] gates */ |
636 | GATE(0, "nclk_ddrupctl0", "ddrphy", 0, RK3288_CLKGATE_CON(11), 4, GFLAGS), | 639 | GATE(0, "nclk_ddrupctl0", "ddrphy", CLK_IGNORE_UNUSED, RK3288_CLKGATE_CON(11), 4, GFLAGS), |
637 | GATE(0, "nclk_ddrupctl1", "ddrphy", 0, RK3288_CLKGATE_CON(11), 5, GFLAGS), | 640 | GATE(0, "nclk_ddrupctl1", "ddrphy", CLK_IGNORE_UNUSED, RK3288_CLKGATE_CON(11), 5, GFLAGS), |
638 | 641 | ||
639 | /* ddrphy gates */ | 642 | /* ddrphy gates */ |
640 | GATE(0, "sclk_ddrphy0", "ddrphy", 0, RK3288_CLKGATE_CON(4), 12, GFLAGS), | 643 | GATE(0, "sclk_ddrphy0", "ddrphy", CLK_IGNORE_UNUSED, RK3288_CLKGATE_CON(4), 12, GFLAGS), |
641 | GATE(0, "sclk_ddrphy1", "ddrphy", 0, RK3288_CLKGATE_CON(4), 13, GFLAGS), | 644 | GATE(0, "sclk_ddrphy1", "ddrphy", CLK_IGNORE_UNUSED, RK3288_CLKGATE_CON(4), 13, GFLAGS), |
642 | 645 | ||
643 | /* aclk_peri gates */ | 646 | /* aclk_peri gates */ |
644 | GATE(0, "aclk_peri_axi_matrix", "aclk_peri", 0, RK3288_CLKGATE_CON(6), 2, GFLAGS), | 647 | GATE(0, "aclk_peri_axi_matrix", "aclk_peri", CLK_IGNORE_UNUSED, RK3288_CLKGATE_CON(6), 2, GFLAGS), |
645 | GATE(ACLK_DMAC2, "aclk_dmac2", "aclk_peri", 0, RK3288_CLKGATE_CON(6), 3, GFLAGS), | 648 | GATE(ACLK_DMAC2, "aclk_dmac2", "aclk_peri", 0, RK3288_CLKGATE_CON(6), 3, GFLAGS), |
646 | GATE(0, "aclk_peri_niu", "aclk_peri", 0, RK3288_CLKGATE_CON(7), 11, GFLAGS), | 649 | GATE(0, "aclk_peri_niu", "aclk_peri", CLK_IGNORE_UNUSED, RK3288_CLKGATE_CON(7), 11, GFLAGS), |
647 | GATE(ACLK_MMU, "aclk_mmu", "aclk_peri", 0, RK3288_CLKGATE_CON(8), 12, GFLAGS), | 650 | GATE(ACLK_MMU, "aclk_mmu", "aclk_peri", CLK_IGNORE_UNUSED, RK3288_CLKGATE_CON(8), 12, GFLAGS), |
648 | GATE(ACLK_GMAC, "aclk_gmac", "aclk_peri", 0, RK3288_CLKGATE_CON(8), 0, GFLAGS), | 651 | GATE(ACLK_GMAC, "aclk_gmac", "aclk_peri", 0, RK3288_CLKGATE_CON(8), 0, GFLAGS), |
649 | GATE(HCLK_GPS, "hclk_gps", "aclk_peri", 0, RK3288_CLKGATE_CON(8), 2, GFLAGS), | 652 | GATE(HCLK_GPS, "hclk_gps", "aclk_peri", 0, RK3288_CLKGATE_CON(8), 2, GFLAGS), |
650 | 653 | ||
651 | /* hclk_peri gates */ | 654 | /* hclk_peri gates */ |
652 | GATE(0, "hclk_peri_matrix", "hclk_peri", 0, RK3288_CLKGATE_CON(6), 0, GFLAGS), | 655 | GATE(0, "hclk_peri_matrix", "hclk_peri", CLK_IGNORE_UNUSED, RK3288_CLKGATE_CON(6), 0, GFLAGS), |
653 | GATE(HCLK_OTG0, "hclk_otg0", "hclk_peri", 0, RK3288_CLKGATE_CON(7), 4, GFLAGS), | 656 | GATE(HCLK_OTG0, "hclk_otg0", "hclk_peri", CLK_IGNORE_UNUSED, RK3288_CLKGATE_CON(7), 4, GFLAGS), |
654 | GATE(HCLK_USBHOST0, "hclk_host0", "hclk_peri", 0, RK3288_CLKGATE_CON(7), 6, GFLAGS), | 657 | GATE(HCLK_USBHOST0, "hclk_host0", "hclk_peri", 0, RK3288_CLKGATE_CON(7), 6, GFLAGS), |
655 | GATE(HCLK_USBHOST1, "hclk_host1", "hclk_peri", 0, RK3288_CLKGATE_CON(7), 7, GFLAGS), | 658 | GATE(HCLK_USBHOST1, "hclk_host1", "hclk_peri", CLK_IGNORE_UNUSED, RK3288_CLKGATE_CON(7), 7, GFLAGS), |
656 | GATE(HCLK_HSIC, "hclk_hsic", "hclk_peri", 0, RK3288_CLKGATE_CON(7), 8, GFLAGS), | 659 | GATE(HCLK_HSIC, "hclk_hsic", "hclk_peri", 0, RK3288_CLKGATE_CON(7), 8, GFLAGS), |
657 | GATE(0, "hclk_usb_peri", "hclk_peri", 0, RK3288_CLKGATE_CON(7), 9, GFLAGS), | 660 | GATE(0, "hclk_usb_peri", "hclk_peri", CLK_IGNORE_UNUSED, RK3288_CLKGATE_CON(7), 9, GFLAGS), |
658 | GATE(0, "hclk_peri_ahb_arbi", "hclk_peri", 0, RK3288_CLKGATE_CON(7), 10, GFLAGS), | 661 | GATE(0, "hclk_peri_ahb_arbi", "hclk_peri", CLK_IGNORE_UNUSED, RK3288_CLKGATE_CON(7), 10, GFLAGS), |
659 | GATE(0, "hclk_emem", "hclk_peri", 0, RK3288_CLKGATE_CON(7), 12, GFLAGS), | 662 | GATE(0, "hclk_emem", "hclk_peri", CLK_IGNORE_UNUSED, RK3288_CLKGATE_CON(7), 12, GFLAGS), |
660 | GATE(0, "hclk_mem", "hclk_peri", 0, RK3288_CLKGATE_CON(7), 13, GFLAGS), | 663 | GATE(0, "hclk_mem", "hclk_peri", CLK_IGNORE_UNUSED, RK3288_CLKGATE_CON(7), 13, GFLAGS), |
661 | GATE(HCLK_NANDC0, "hclk_nandc0", "hclk_peri", 0, RK3288_CLKGATE_CON(7), 14, GFLAGS), | 664 | GATE(HCLK_NANDC0, "hclk_nandc0", "hclk_peri", 0, RK3288_CLKGATE_CON(7), 14, GFLAGS), |
662 | GATE(HCLK_NANDC1, "hclk_nandc1", "hclk_peri", 0, RK3288_CLKGATE_CON(7), 15, GFLAGS), | 665 | GATE(HCLK_NANDC1, "hclk_nandc1", "hclk_peri", 0, RK3288_CLKGATE_CON(7), 15, GFLAGS), |
663 | GATE(HCLK_TSP, "hclk_tsp", "hclk_peri", 0, RK3288_CLKGATE_CON(8), 8, GFLAGS), | 666 | GATE(HCLK_TSP, "hclk_tsp", "hclk_peri", 0, RK3288_CLKGATE_CON(8), 8, GFLAGS), |
@@ -669,7 +672,7 @@ static struct rockchip_clk_branch rk3288_clk_branches[] __initdata = { | |||
669 | GATE(0, "pmu_hclk_otg0", "hclk_peri", 0, RK3288_CLKGATE_CON(7), 5, GFLAGS), | 672 | GATE(0, "pmu_hclk_otg0", "hclk_peri", 0, RK3288_CLKGATE_CON(7), 5, GFLAGS), |
670 | 673 | ||
671 | /* pclk_peri gates */ | 674 | /* pclk_peri gates */ |
672 | GATE(0, "pclk_peri_matrix", "pclk_peri", 0, RK3288_CLKGATE_CON(6), 1, GFLAGS), | 675 | GATE(0, "pclk_peri_matrix", "pclk_peri", CLK_IGNORE_UNUSED, RK3288_CLKGATE_CON(6), 1, GFLAGS), |
673 | GATE(PCLK_SPI0, "pclk_spi0", "pclk_peri", 0, RK3288_CLKGATE_CON(6), 4, GFLAGS), | 676 | GATE(PCLK_SPI0, "pclk_spi0", "pclk_peri", 0, RK3288_CLKGATE_CON(6), 4, GFLAGS), |
674 | GATE(PCLK_SPI1, "pclk_spi1", "pclk_peri", 0, RK3288_CLKGATE_CON(6), 5, GFLAGS), | 677 | GATE(PCLK_SPI1, "pclk_spi1", "pclk_peri", 0, RK3288_CLKGATE_CON(6), 5, GFLAGS), |
675 | GATE(PCLK_SPI2, "pclk_spi2", "pclk_peri", 0, RK3288_CLKGATE_CON(6), 6, GFLAGS), | 678 | GATE(PCLK_SPI2, "pclk_spi2", "pclk_peri", 0, RK3288_CLKGATE_CON(6), 6, GFLAGS), |
@@ -705,48 +708,48 @@ static struct rockchip_clk_branch rk3288_clk_branches[] __initdata = { | |||
705 | GATE(PCLK_GPIO4, "pclk_gpio4", "pclk_pd_alive", 0, RK3288_CLKGATE_CON(14), 4, GFLAGS), | 708 | GATE(PCLK_GPIO4, "pclk_gpio4", "pclk_pd_alive", 0, RK3288_CLKGATE_CON(14), 4, GFLAGS), |
706 | GATE(PCLK_GPIO5, "pclk_gpio5", "pclk_pd_alive", 0, RK3288_CLKGATE_CON(14), 5, GFLAGS), | 709 | GATE(PCLK_GPIO5, "pclk_gpio5", "pclk_pd_alive", 0, RK3288_CLKGATE_CON(14), 5, GFLAGS), |
707 | GATE(PCLK_GPIO6, "pclk_gpio6", "pclk_pd_alive", 0, RK3288_CLKGATE_CON(14), 6, GFLAGS), | 710 | GATE(PCLK_GPIO6, "pclk_gpio6", "pclk_pd_alive", 0, RK3288_CLKGATE_CON(14), 6, GFLAGS), |
708 | GATE(PCLK_GRF, "pclk_grf", "pclk_pd_alive", 0, RK3288_CLKGATE_CON(14), 11, GFLAGS), | 711 | GATE(PCLK_GRF, "pclk_grf", "pclk_pd_alive", CLK_IGNORE_UNUSED, RK3288_CLKGATE_CON(14), 11, GFLAGS), |
709 | GATE(0, "pclk_alive_niu", "pclk_pd_alive", 0, RK3288_CLKGATE_CON(14), 12, GFLAGS), | 712 | GATE(0, "pclk_alive_niu", "pclk_pd_alive", CLK_IGNORE_UNUSED, RK3288_CLKGATE_CON(14), 12, GFLAGS), |
710 | 713 | ||
711 | /* pclk_pd_pmu gates */ | 714 | /* pclk_pd_pmu gates */ |
712 | GATE(PCLK_PMU, "pclk_pmu", "pclk_pd_pmu", 0, RK3288_CLKGATE_CON(17), 0, GFLAGS), | 715 | GATE(PCLK_PMU, "pclk_pmu", "pclk_pd_pmu", CLK_IGNORE_UNUSED, RK3288_CLKGATE_CON(17), 0, GFLAGS), |
713 | GATE(0, "pclk_intmem1", "pclk_pd_pmu", 0, RK3288_CLKGATE_CON(17), 1, GFLAGS), | 716 | GATE(0, "pclk_intmem1", "pclk_pd_pmu", CLK_IGNORE_UNUSED, RK3288_CLKGATE_CON(17), 1, GFLAGS), |
714 | GATE(0, "pclk_pmu_niu", "pclk_pd_pmu", 0, RK3288_CLKGATE_CON(17), 2, GFLAGS), | 717 | GATE(0, "pclk_pmu_niu", "pclk_pd_pmu", CLK_IGNORE_UNUSED, RK3288_CLKGATE_CON(17), 2, GFLAGS), |
715 | GATE(PCLK_SGRF, "pclk_sgrf", "pclk_pd_pmu", 0, RK3288_CLKGATE_CON(17), 3, GFLAGS), | 718 | GATE(PCLK_SGRF, "pclk_sgrf", "pclk_pd_pmu", CLK_IGNORE_UNUSED, RK3288_CLKGATE_CON(17), 3, GFLAGS), |
716 | GATE(PCLK_GPIO0, "pclk_gpio0", "pclk_pd_pmu", 0, RK3288_CLKGATE_CON(17), 4, GFLAGS), | 719 | GATE(PCLK_GPIO0, "pclk_gpio0", "pclk_pd_pmu", 0, RK3288_CLKGATE_CON(17), 4, GFLAGS), |
717 | 720 | ||
718 | /* hclk_vio gates */ | 721 | /* hclk_vio gates */ |
719 | GATE(HCLK_RGA, "hclk_rga", "hclk_vio", 0, RK3288_CLKGATE_CON(15), 1, GFLAGS), | 722 | GATE(HCLK_RGA, "hclk_rga", "hclk_vio", 0, RK3288_CLKGATE_CON(15), 1, GFLAGS), |
720 | GATE(HCLK_VOP0, "hclk_vop0", "hclk_vio", 0, RK3288_CLKGATE_CON(15), 6, GFLAGS), | 723 | GATE(HCLK_VOP0, "hclk_vop0", "hclk_vio", 0, RK3288_CLKGATE_CON(15), 6, GFLAGS), |
721 | GATE(HCLK_VOP1, "hclk_vop1", "hclk_vio", 0, RK3288_CLKGATE_CON(15), 8, GFLAGS), | 724 | GATE(HCLK_VOP1, "hclk_vop1", "hclk_vio", 0, RK3288_CLKGATE_CON(15), 8, GFLAGS), |
722 | GATE(HCLK_VIO_AHB_ARBI, "hclk_vio_ahb_arbi", "hclk_vio", 0, RK3288_CLKGATE_CON(15), 9, GFLAGS), | 725 | GATE(HCLK_VIO_AHB_ARBI, "hclk_vio_ahb_arbi", "hclk_vio", CLK_IGNORE_UNUSED, RK3288_CLKGATE_CON(15), 9, GFLAGS), |
723 | GATE(HCLK_VIO_NIU, "hclk_vio_niu", "hclk_vio", 0, RK3288_CLKGATE_CON(15), 10, GFLAGS), | 726 | GATE(HCLK_VIO_NIU, "hclk_vio_niu", "hclk_vio", CLK_IGNORE_UNUSED, RK3288_CLKGATE_CON(15), 10, GFLAGS), |
724 | GATE(HCLK_VIP, "hclk_vip", "hclk_vio", 0, RK3288_CLKGATE_CON(15), 15, GFLAGS), | 727 | GATE(HCLK_VIP, "hclk_vip", "hclk_vio", 0, RK3288_CLKGATE_CON(15), 15, GFLAGS), |
725 | GATE(HCLK_IEP, "hclk_iep", "hclk_vio", 0, RK3288_CLKGATE_CON(15), 3, GFLAGS), | 728 | GATE(HCLK_IEP, "hclk_iep", "hclk_vio", 0, RK3288_CLKGATE_CON(15), 3, GFLAGS), |
726 | GATE(HCLK_ISP, "hclk_isp", "hclk_vio", 0, RK3288_CLKGATE_CON(16), 1, GFLAGS), | 729 | GATE(HCLK_ISP, "hclk_isp", "hclk_vio", 0, RK3288_CLKGATE_CON(16), 1, GFLAGS), |
727 | GATE(HCLK_VIO2_H2P, "hclk_vio2_h2p", "hclk_vio", 0, RK3288_CLKGATE_CON(16), 10, GFLAGS), | 730 | GATE(HCLK_VIO2_H2P, "hclk_vio2_h2p", "hclk_vio", CLK_IGNORE_UNUSED, RK3288_CLKGATE_CON(16), 10, GFLAGS), |
728 | GATE(PCLK_MIPI_DSI0, "pclk_mipi_dsi0", "hclk_vio", 0, RK3288_CLKGATE_CON(16), 4, GFLAGS), | 731 | GATE(PCLK_MIPI_DSI0, "pclk_mipi_dsi0", "hclk_vio", 0, RK3288_CLKGATE_CON(16), 4, GFLAGS), |
729 | GATE(PCLK_MIPI_DSI1, "pclk_mipi_dsi1", "hclk_vio", 0, RK3288_CLKGATE_CON(16), 5, GFLAGS), | 732 | GATE(PCLK_MIPI_DSI1, "pclk_mipi_dsi1", "hclk_vio", 0, RK3288_CLKGATE_CON(16), 5, GFLAGS), |
730 | GATE(PCLK_MIPI_CSI, "pclk_mipi_csi", "hclk_vio", 0, RK3288_CLKGATE_CON(16), 6, GFLAGS), | 733 | GATE(PCLK_MIPI_CSI, "pclk_mipi_csi", "hclk_vio", 0, RK3288_CLKGATE_CON(16), 6, GFLAGS), |
731 | GATE(PCLK_LVDS_PHY, "pclk_lvds_phy", "hclk_vio", 0, RK3288_CLKGATE_CON(16), 7, GFLAGS), | 734 | GATE(PCLK_LVDS_PHY, "pclk_lvds_phy", "hclk_vio", 0, RK3288_CLKGATE_CON(16), 7, GFLAGS), |
732 | GATE(PCLK_EDP_CTRL, "pclk_edp_ctrl", "hclk_vio", 0, RK3288_CLKGATE_CON(16), 8, GFLAGS), | 735 | GATE(PCLK_EDP_CTRL, "pclk_edp_ctrl", "hclk_vio", CLK_IGNORE_UNUSED, RK3288_CLKGATE_CON(16), 8, GFLAGS), |
733 | GATE(PCLK_HDMI_CTRL, "pclk_hdmi_ctrl", "hclk_vio", 0, RK3288_CLKGATE_CON(16), 9, GFLAGS), | 736 | GATE(PCLK_HDMI_CTRL, "pclk_hdmi_ctrl", "hclk_vio", 0, RK3288_CLKGATE_CON(16), 9, GFLAGS), |
734 | GATE(PCLK_VIO2_H2P, "pclk_vio2_h2p", "hclk_vio", 0, RK3288_CLKGATE_CON(16), 11, GFLAGS), | 737 | GATE(PCLK_VIO2_H2P, "pclk_vio2_h2p", "hclk_vio", CLK_IGNORE_UNUSED, RK3288_CLKGATE_CON(16), 11, GFLAGS), |
735 | 738 | ||
736 | /* aclk_vio0 gates */ | 739 | /* aclk_vio0 gates */ |
737 | GATE(ACLK_VOP0, "aclk_vop0", "aclk_vio0", 0, RK3288_CLKGATE_CON(15), 5, GFLAGS), | 740 | GATE(ACLK_VOP0, "aclk_vop0", "aclk_vio0", 0, RK3288_CLKGATE_CON(15), 5, GFLAGS), |
738 | GATE(ACLK_IEP, "aclk_iep", "aclk_vio0", 0, RK3288_CLKGATE_CON(15), 2, GFLAGS), | 741 | GATE(ACLK_IEP, "aclk_iep", "aclk_vio0", 0, RK3288_CLKGATE_CON(15), 2, GFLAGS), |
739 | GATE(ACLK_VIO0_NIU, "aclk_vio0_niu", "aclk_vio0", 0, RK3288_CLKGATE_CON(15), 11, GFLAGS), | 742 | GATE(ACLK_VIO0_NIU, "aclk_vio0_niu", "aclk_vio0", CLK_IGNORE_UNUSED, RK3288_CLKGATE_CON(15), 11, GFLAGS), |
740 | GATE(ACLK_VIP, "aclk_vip", "aclk_vio0", 0, RK3288_CLKGATE_CON(15), 14, GFLAGS), | 743 | GATE(ACLK_VIP, "aclk_vip", "aclk_vio0", 0, RK3288_CLKGATE_CON(15), 14, GFLAGS), |
741 | 744 | ||
742 | /* aclk_vio1 gates */ | 745 | /* aclk_vio1 gates */ |
743 | GATE(ACLK_VOP1, "aclk_vop1", "aclk_vio1", 0, RK3288_CLKGATE_CON(15), 7, GFLAGS), | 746 | GATE(ACLK_VOP1, "aclk_vop1", "aclk_vio1", 0, RK3288_CLKGATE_CON(15), 7, GFLAGS), |
744 | GATE(ACLK_ISP, "aclk_isp", "aclk_vio1", 0, RK3288_CLKGATE_CON(16), 2, GFLAGS), | 747 | GATE(ACLK_ISP, "aclk_isp", "aclk_vio1", 0, RK3288_CLKGATE_CON(16), 2, GFLAGS), |
745 | GATE(ACLK_VIO1_NIU, "aclk_vio1_niu", "aclk_vio1", 0, RK3288_CLKGATE_CON(15), 12, GFLAGS), | 748 | GATE(ACLK_VIO1_NIU, "aclk_vio1_niu", "aclk_vio1", CLK_IGNORE_UNUSED, RK3288_CLKGATE_CON(15), 12, GFLAGS), |
746 | 749 | ||
747 | /* aclk_rga_pre gates */ | 750 | /* aclk_rga_pre gates */ |
748 | GATE(ACLK_RGA, "aclk_rga", "aclk_rga_pre", 0, RK3288_CLKGATE_CON(15), 0, GFLAGS), | 751 | GATE(ACLK_RGA, "aclk_rga", "aclk_rga_pre", 0, RK3288_CLKGATE_CON(15), 0, GFLAGS), |
749 | GATE(ACLK_RGA_NIU, "aclk_rga_niu", "aclk_rga_pre", 0, RK3288_CLKGATE_CON(15), 13, GFLAGS), | 752 | GATE(ACLK_RGA_NIU, "aclk_rga_niu", "aclk_rga_pre", CLK_IGNORE_UNUSED, RK3288_CLKGATE_CON(15), 13, GFLAGS), |
750 | 753 | ||
751 | /* | 754 | /* |
752 | * Other ungrouped clocks. | 755 | * Other ungrouped clocks. |
@@ -762,6 +765,64 @@ static const char *rk3288_critical_clocks[] __initconst = { | |||
762 | "hclk_peri", | 765 | "hclk_peri", |
763 | }; | 766 | }; |
764 | 767 | ||
768 | #ifdef CONFIG_PM_SLEEP | ||
769 | static void __iomem *rk3288_cru_base; | ||
770 | |||
771 | /* Some CRU registers will be reset in maskrom when the system | ||
772 | * wakes up from fastboot. | ||
773 | * So save them before suspend, restore them after resume. | ||
774 | */ | ||
775 | static const int rk3288_saved_cru_reg_ids[] = { | ||
776 | RK3288_MODE_CON, | ||
777 | RK3288_CLKSEL_CON(0), | ||
778 | RK3288_CLKSEL_CON(1), | ||
779 | RK3288_CLKSEL_CON(10), | ||
780 | RK3288_CLKSEL_CON(33), | ||
781 | RK3288_CLKSEL_CON(37), | ||
782 | }; | ||
783 | |||
784 | static u32 rk3288_saved_cru_regs[ARRAY_SIZE(rk3288_saved_cru_reg_ids)]; | ||
785 | |||
786 | static int rk3288_clk_suspend(void) | ||
787 | { | ||
788 | int i, reg_id; | ||
789 | |||
790 | for (i = 0; i < ARRAY_SIZE(rk3288_saved_cru_reg_ids); i++) { | ||
791 | reg_id = rk3288_saved_cru_reg_ids[i]; | ||
792 | |||
793 | rk3288_saved_cru_regs[i] = | ||
794 | readl_relaxed(rk3288_cru_base + reg_id); | ||
795 | } | ||
796 | return 0; | ||
797 | } | ||
798 | |||
799 | static void rk3288_clk_resume(void) | ||
800 | { | ||
801 | int i, reg_id; | ||
802 | |||
803 | for (i = ARRAY_SIZE(rk3288_saved_cru_reg_ids) - 1; i >= 0; i--) { | ||
804 | reg_id = rk3288_saved_cru_reg_ids[i]; | ||
805 | |||
806 | writel_relaxed(rk3288_saved_cru_regs[i] | 0xffff0000, | ||
807 | rk3288_cru_base + reg_id); | ||
808 | } | ||
809 | } | ||
810 | |||
811 | static struct syscore_ops rk3288_clk_syscore_ops = { | ||
812 | .suspend = rk3288_clk_suspend, | ||
813 | .resume = rk3288_clk_resume, | ||
814 | }; | ||
815 | |||
816 | static void rk3288_clk_sleep_init(void __iomem *reg_base) | ||
817 | { | ||
818 | rk3288_cru_base = reg_base; | ||
819 | register_syscore_ops(&rk3288_clk_syscore_ops); | ||
820 | } | ||
821 | |||
822 | #else /* CONFIG_PM_SLEEP */ | ||
823 | static void rk3288_clk_sleep_init(void __iomem *reg_base) {} | ||
824 | #endif | ||
825 | |||
765 | static void __init rk3288_clk_init(struct device_node *np) | 826 | static void __init rk3288_clk_init(struct device_node *np) |
766 | { | 827 | { |
767 | void __iomem *reg_base; | 828 | void __iomem *reg_base; |
@@ -810,5 +871,6 @@ static void __init rk3288_clk_init(struct device_node *np) | |||
810 | ROCKCHIP_SOFTRST_HIWORD_MASK); | 871 | ROCKCHIP_SOFTRST_HIWORD_MASK); |
811 | 872 | ||
812 | rockchip_register_restart_notifier(RK3288_GLB_SRST_FST); | 873 | rockchip_register_restart_notifier(RK3288_GLB_SRST_FST); |
874 | rk3288_clk_sleep_init(reg_base); | ||
813 | } | 875 | } |
814 | CLK_OF_DECLARE(rk3288_cru, "rockchip,rk3288-cru", rk3288_clk_init); | 876 | CLK_OF_DECLARE(rk3288_cru, "rockchip,rk3288-cru", rk3288_clk_init); |
diff --git a/drivers/clk/rockchip/clk.c b/drivers/clk/rockchip/clk.c index 1e68bff481b8..dec6f8d6dc13 100644 --- a/drivers/clk/rockchip/clk.c +++ b/drivers/clk/rockchip/clk.c | |||
@@ -246,9 +246,6 @@ void __init rockchip_clk_register_branches( | |||
246 | list->div_flags, &clk_lock); | 246 | list->div_flags, &clk_lock); |
247 | break; | 247 | break; |
248 | case branch_fraction_divider: | 248 | case branch_fraction_divider: |
249 | /* keep all gates untouched for now */ | ||
250 | flags |= CLK_IGNORE_UNUSED; | ||
251 | |||
252 | clk = rockchip_clk_register_frac_branch(list->name, | 249 | clk = rockchip_clk_register_frac_branch(list->name, |
253 | list->parent_names, list->num_parents, | 250 | list->parent_names, list->num_parents, |
254 | reg_base, list->muxdiv_offset, list->div_flags, | 251 | reg_base, list->muxdiv_offset, list->div_flags, |
@@ -258,18 +255,12 @@ void __init rockchip_clk_register_branches( | |||
258 | case branch_gate: | 255 | case branch_gate: |
259 | flags |= CLK_SET_RATE_PARENT; | 256 | flags |= CLK_SET_RATE_PARENT; |
260 | 257 | ||
261 | /* keep all gates untouched for now */ | ||
262 | flags |= CLK_IGNORE_UNUSED; | ||
263 | |||
264 | clk = clk_register_gate(NULL, list->name, | 258 | clk = clk_register_gate(NULL, list->name, |
265 | list->parent_names[0], flags, | 259 | list->parent_names[0], flags, |
266 | reg_base + list->gate_offset, | 260 | reg_base + list->gate_offset, |
267 | list->gate_shift, list->gate_flags, &clk_lock); | 261 | list->gate_shift, list->gate_flags, &clk_lock); |
268 | break; | 262 | break; |
269 | case branch_composite: | 263 | case branch_composite: |
270 | /* keep all gates untouched for now */ | ||
271 | flags |= CLK_IGNORE_UNUSED; | ||
272 | |||
273 | clk = rockchip_clk_register_branch(list->name, | 264 | clk = rockchip_clk_register_branch(list->name, |
274 | list->parent_names, list->num_parents, | 265 | list->parent_names, list->num_parents, |
275 | reg_base, list->muxdiv_offset, list->mux_shift, | 266 | reg_base, list->muxdiv_offset, list->mux_shift, |
diff --git a/drivers/clk/rockchip/clk.h b/drivers/clk/rockchip/clk.h index ca009ab0a33a..6baf6655b5c3 100644 --- a/drivers/clk/rockchip/clk.h +++ b/drivers/clk/rockchip/clk.h | |||
@@ -62,6 +62,15 @@ enum rockchip_pll_type { | |||
62 | .bwadj = (_nf >> 1), \ | 62 | .bwadj = (_nf >> 1), \ |
63 | } | 63 | } |
64 | 64 | ||
65 | #define RK3066_PLL_RATE_BWADJ(_rate, _nr, _nf, _no, _bw) \ | ||
66 | { \ | ||
67 | .rate = _rate##U, \ | ||
68 | .nr = _nr, \ | ||
69 | .nf = _nf, \ | ||
70 | .no = _no, \ | ||
71 | .bwadj = _bw, \ | ||
72 | } | ||
73 | |||
65 | struct rockchip_pll_rate_table { | 74 | struct rockchip_pll_rate_table { |
66 | unsigned long rate; | 75 | unsigned long rate; |
67 | unsigned int nr; | 76 | unsigned int nr; |
diff --git a/include/dt-bindings/clock/marvell,mmp2.h b/include/dt-bindings/clock/marvell,mmp2.h new file mode 100644 index 000000000000..591f7fba89e2 --- /dev/null +++ b/include/dt-bindings/clock/marvell,mmp2.h | |||
@@ -0,0 +1,74 @@ | |||
1 | #ifndef __DTS_MARVELL_MMP2_CLOCK_H | ||
2 | #define __DTS_MARVELL_MMP2_CLOCK_H | ||
3 | |||
4 | /* fixed clocks and plls */ | ||
5 | #define MMP2_CLK_CLK32 1 | ||
6 | #define MMP2_CLK_VCTCXO 2 | ||
7 | #define MMP2_CLK_PLL1 3 | ||
8 | #define MMP2_CLK_PLL1_2 8 | ||
9 | #define MMP2_CLK_PLL1_4 9 | ||
10 | #define MMP2_CLK_PLL1_8 10 | ||
11 | #define MMP2_CLK_PLL1_16 11 | ||
12 | #define MMP2_CLK_PLL1_3 12 | ||
13 | #define MMP2_CLK_PLL1_6 13 | ||
14 | #define MMP2_CLK_PLL1_12 14 | ||
15 | #define MMP2_CLK_PLL1_20 15 | ||
16 | #define MMP2_CLK_PLL2 16 | ||
17 | #define MMP2_CLK_PLL2_2 17 | ||
18 | #define MMP2_CLK_PLL2_4 18 | ||
19 | #define MMP2_CLK_PLL2_8 19 | ||
20 | #define MMP2_CLK_PLL2_16 20 | ||
21 | #define MMP2_CLK_PLL2_3 21 | ||
22 | #define MMP2_CLK_PLL2_6 22 | ||
23 | #define MMP2_CLK_PLL2_12 23 | ||
24 | #define MMP2_CLK_VCTCXO_2 24 | ||
25 | #define MMP2_CLK_VCTCXO_4 25 | ||
26 | #define MMP2_CLK_UART_PLL 26 | ||
27 | #define MMP2_CLK_USB_PLL 27 | ||
28 | |||
29 | /* apb periphrals */ | ||
30 | #define MMP2_CLK_TWSI0 60 | ||
31 | #define MMP2_CLK_TWSI1 61 | ||
32 | #define MMP2_CLK_TWSI2 62 | ||
33 | #define MMP2_CLK_TWSI3 63 | ||
34 | #define MMP2_CLK_TWSI4 64 | ||
35 | #define MMP2_CLK_TWSI5 65 | ||
36 | #define MMP2_CLK_GPIO 66 | ||
37 | #define MMP2_CLK_KPC 67 | ||
38 | #define MMP2_CLK_RTC 68 | ||
39 | #define MMP2_CLK_PWM0 69 | ||
40 | #define MMP2_CLK_PWM1 70 | ||
41 | #define MMP2_CLK_PWM2 71 | ||
42 | #define MMP2_CLK_PWM3 72 | ||
43 | #define MMP2_CLK_UART0 73 | ||
44 | #define MMP2_CLK_UART1 74 | ||
45 | #define MMP2_CLK_UART2 75 | ||
46 | #define MMP2_CLK_UART3 76 | ||
47 | #define MMP2_CLK_SSP0 77 | ||
48 | #define MMP2_CLK_SSP1 78 | ||
49 | #define MMP2_CLK_SSP2 79 | ||
50 | #define MMP2_CLK_SSP3 80 | ||
51 | |||
52 | /* axi periphrals */ | ||
53 | #define MMP2_CLK_SDH0 101 | ||
54 | #define MMP2_CLK_SDH1 102 | ||
55 | #define MMP2_CLK_SDH2 103 | ||
56 | #define MMP2_CLK_SDH3 104 | ||
57 | #define MMP2_CLK_USB 105 | ||
58 | #define MMP2_CLK_DISP0 106 | ||
59 | #define MMP2_CLK_DISP0_MUX 107 | ||
60 | #define MMP2_CLK_DISP0_SPHY 108 | ||
61 | #define MMP2_CLK_DISP1 109 | ||
62 | #define MMP2_CLK_DISP1_MUX 110 | ||
63 | #define MMP2_CLK_CCIC_ARBITER 111 | ||
64 | #define MMP2_CLK_CCIC0 112 | ||
65 | #define MMP2_CLK_CCIC0_MIX 113 | ||
66 | #define MMP2_CLK_CCIC0_PHY 114 | ||
67 | #define MMP2_CLK_CCIC0_SPHY 115 | ||
68 | #define MMP2_CLK_CCIC1 116 | ||
69 | #define MMP2_CLK_CCIC1_MIX 117 | ||
70 | #define MMP2_CLK_CCIC1_PHY 118 | ||
71 | #define MMP2_CLK_CCIC1_SPHY 119 | ||
72 | |||
73 | #define MMP2_NR_CLKS 200 | ||
74 | #endif | ||
diff --git a/include/dt-bindings/clock/marvell,pxa168.h b/include/dt-bindings/clock/marvell,pxa168.h new file mode 100644 index 000000000000..79630b9d74b8 --- /dev/null +++ b/include/dt-bindings/clock/marvell,pxa168.h | |||
@@ -0,0 +1,57 @@ | |||
1 | #ifndef __DTS_MARVELL_PXA168_CLOCK_H | ||
2 | #define __DTS_MARVELL_PXA168_CLOCK_H | ||
3 | |||
4 | /* fixed clocks and plls */ | ||
5 | #define PXA168_CLK_CLK32 1 | ||
6 | #define PXA168_CLK_VCTCXO 2 | ||
7 | #define PXA168_CLK_PLL1 3 | ||
8 | #define PXA168_CLK_PLL1_2 8 | ||
9 | #define PXA168_CLK_PLL1_4 9 | ||
10 | #define PXA168_CLK_PLL1_8 10 | ||
11 | #define PXA168_CLK_PLL1_16 11 | ||
12 | #define PXA168_CLK_PLL1_6 12 | ||
13 | #define PXA168_CLK_PLL1_12 13 | ||
14 | #define PXA168_CLK_PLL1_24 14 | ||
15 | #define PXA168_CLK_PLL1_48 15 | ||
16 | #define PXA168_CLK_PLL1_96 16 | ||
17 | #define PXA168_CLK_PLL1_13 17 | ||
18 | #define PXA168_CLK_PLL1_13_1_5 18 | ||
19 | #define PXA168_CLK_PLL1_2_1_5 19 | ||
20 | #define PXA168_CLK_PLL1_3_16 20 | ||
21 | #define PXA168_CLK_UART_PLL 27 | ||
22 | |||
23 | /* apb periphrals */ | ||
24 | #define PXA168_CLK_TWSI0 60 | ||
25 | #define PXA168_CLK_TWSI1 61 | ||
26 | #define PXA168_CLK_TWSI2 62 | ||
27 | #define PXA168_CLK_TWSI3 63 | ||
28 | #define PXA168_CLK_GPIO 64 | ||
29 | #define PXA168_CLK_KPC 65 | ||
30 | #define PXA168_CLK_RTC 66 | ||
31 | #define PXA168_CLK_PWM0 67 | ||
32 | #define PXA168_CLK_PWM1 68 | ||
33 | #define PXA168_CLK_PWM2 69 | ||
34 | #define PXA168_CLK_PWM3 70 | ||
35 | #define PXA168_CLK_UART0 71 | ||
36 | #define PXA168_CLK_UART1 72 | ||
37 | #define PXA168_CLK_UART2 73 | ||
38 | #define PXA168_CLK_SSP0 74 | ||
39 | #define PXA168_CLK_SSP1 75 | ||
40 | #define PXA168_CLK_SSP2 76 | ||
41 | #define PXA168_CLK_SSP3 77 | ||
42 | #define PXA168_CLK_SSP4 78 | ||
43 | |||
44 | /* axi periphrals */ | ||
45 | #define PXA168_CLK_DFC 100 | ||
46 | #define PXA168_CLK_SDH0 101 | ||
47 | #define PXA168_CLK_SDH1 102 | ||
48 | #define PXA168_CLK_SDH2 103 | ||
49 | #define PXA168_CLK_USB 104 | ||
50 | #define PXA168_CLK_SPH 105 | ||
51 | #define PXA168_CLK_DISP0 106 | ||
52 | #define PXA168_CLK_CCIC0 107 | ||
53 | #define PXA168_CLK_CCIC0_PHY 108 | ||
54 | #define PXA168_CLK_CCIC0_SPHY 109 | ||
55 | |||
56 | #define PXA168_NR_CLKS 200 | ||
57 | #endif | ||
diff --git a/include/dt-bindings/clock/marvell,pxa910.h b/include/dt-bindings/clock/marvell,pxa910.h new file mode 100644 index 000000000000..719cffb2bea2 --- /dev/null +++ b/include/dt-bindings/clock/marvell,pxa910.h | |||
@@ -0,0 +1,54 @@ | |||
1 | #ifndef __DTS_MARVELL_PXA910_CLOCK_H | ||
2 | #define __DTS_MARVELL_PXA910_CLOCK_H | ||
3 | |||
4 | /* fixed clocks and plls */ | ||
5 | #define PXA910_CLK_CLK32 1 | ||
6 | #define PXA910_CLK_VCTCXO 2 | ||
7 | #define PXA910_CLK_PLL1 3 | ||
8 | #define PXA910_CLK_PLL1_2 8 | ||
9 | #define PXA910_CLK_PLL1_4 9 | ||
10 | #define PXA910_CLK_PLL1_8 10 | ||
11 | #define PXA910_CLK_PLL1_16 11 | ||
12 | #define PXA910_CLK_PLL1_6 12 | ||
13 | #define PXA910_CLK_PLL1_12 13 | ||
14 | #define PXA910_CLK_PLL1_24 14 | ||
15 | #define PXA910_CLK_PLL1_48 15 | ||
16 | #define PXA910_CLK_PLL1_96 16 | ||
17 | #define PXA910_CLK_PLL1_13 17 | ||
18 | #define PXA910_CLK_PLL1_13_1_5 18 | ||
19 | #define PXA910_CLK_PLL1_2_1_5 19 | ||
20 | #define PXA910_CLK_PLL1_3_16 20 | ||
21 | #define PXA910_CLK_UART_PLL 27 | ||
22 | |||
23 | /* apb periphrals */ | ||
24 | #define PXA910_CLK_TWSI0 60 | ||
25 | #define PXA910_CLK_TWSI1 61 | ||
26 | #define PXA910_CLK_TWSI2 62 | ||
27 | #define PXA910_CLK_TWSI3 63 | ||
28 | #define PXA910_CLK_GPIO 64 | ||
29 | #define PXA910_CLK_KPC 65 | ||
30 | #define PXA910_CLK_RTC 66 | ||
31 | #define PXA910_CLK_PWM0 67 | ||
32 | #define PXA910_CLK_PWM1 68 | ||
33 | #define PXA910_CLK_PWM2 69 | ||
34 | #define PXA910_CLK_PWM3 70 | ||
35 | #define PXA910_CLK_UART0 71 | ||
36 | #define PXA910_CLK_UART1 72 | ||
37 | #define PXA910_CLK_UART2 73 | ||
38 | #define PXA910_CLK_SSP0 74 | ||
39 | #define PXA910_CLK_SSP1 75 | ||
40 | |||
41 | /* axi periphrals */ | ||
42 | #define PXA910_CLK_DFC 100 | ||
43 | #define PXA910_CLK_SDH0 101 | ||
44 | #define PXA910_CLK_SDH1 102 | ||
45 | #define PXA910_CLK_SDH2 103 | ||
46 | #define PXA910_CLK_USB 104 | ||
47 | #define PXA910_CLK_SPH 105 | ||
48 | #define PXA910_CLK_DISP0 106 | ||
49 | #define PXA910_CLK_CCIC0 107 | ||
50 | #define PXA910_CLK_CCIC0_PHY 108 | ||
51 | #define PXA910_CLK_CCIC0_SPHY 109 | ||
52 | |||
53 | #define PXA910_NR_CLKS 200 | ||
54 | #endif | ||