aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/devicetree/bindings/clock/renesas,sh73a0-cpg-clocks.txt35
-rw-r--r--Documentation/devicetree/bindings/mfd/atmel-matrix.txt24
-rw-r--r--Documentation/devicetree/bindings/mfd/atmel-smc.txt19
-rw-r--r--Documentation/devicetree/bindings/usb/atmel-usb.txt10
-rw-r--r--arch/arm/boot/dts/sh73a0-kzm9g-reference.dts4
-rw-r--r--arch/arm/boot/dts/sh73a0.dtsi358
-rw-r--r--arch/arm/mach-exynos/common.h4
-rw-r--r--arch/arm/mach-exynos/exynos.c4
-rw-r--r--arch/arm/mach-exynos/platsmp.c2
-rw-r--r--arch/arm/mach-exynos/pm.c133
-rw-r--r--arch/arm/mach-exynos/suspend.c4
-rw-r--r--arch/arm/mach-shmobile/setup-sh73a0.c5
-rw-r--r--drivers/clk/shmobile/Makefile1
-rw-r--r--drivers/clk/shmobile/clk-sh73a0.c218
-rw-r--r--drivers/cpuidle/Kconfig.arm1
-rw-r--r--drivers/cpuidle/cpuidle-exynos.c76
-rw-r--r--drivers/of/platform.c1
-rw-r--r--drivers/pcmcia/Kconfig1
-rw-r--r--drivers/soc/ti/Makefile3
-rw-r--r--drivers/soc/ti/knav_qmss_acc.c2
-rw-r--r--drivers/soc/ti/knav_qmss_queue.c9
-rw-r--r--drivers/usb/gadget/udc/Kconfig1
-rw-r--r--drivers/usb/gadget/udc/at91_udc.c525
-rw-r--r--drivers/usb/gadget/udc/at91_udc.h9
-rw-r--r--include/dt-bindings/clock/sh73a0-clock.h79
-rw-r--r--include/linux/mfd/syscon/atmel-matrix.h117
-rw-r--r--include/linux/mfd/syscon/atmel-smc.h173
-rw-r--r--include/linux/platform_data/cpuidle-exynos.h20
28 files changed, 1570 insertions, 268 deletions
diff --git a/Documentation/devicetree/bindings/clock/renesas,sh73a0-cpg-clocks.txt b/Documentation/devicetree/bindings/clock/renesas,sh73a0-cpg-clocks.txt
new file mode 100644
index 000000000000..a8978ec94831
--- /dev/null
+++ b/Documentation/devicetree/bindings/clock/renesas,sh73a0-cpg-clocks.txt
@@ -0,0 +1,35 @@
1These bindings should be considered EXPERIMENTAL for now.
2
3* Renesas SH73A0 Clock Pulse Generator (CPG)
4
5The CPG generates core clocks for the SH73A0 SoC. It includes four PLLs
6and several fixed ratio dividers.
7
8Required Properties:
9
10 - compatible: Must be "renesas,sh73a0-cpg-clocks"
11
12 - reg: Base address and length of the memory resource used by the CPG
13
14 - clocks: Reference to the parent clocks ("extal1" and "extal2")
15
16 - #clock-cells: Must be 1
17
18 - clock-output-names: The names of the clocks. Supported clocks are "main",
19 "pll0", "pll1", "pll2", "pll3", "dsi0phy", "dsi1phy", "zg", "m3", "b",
20 "m1", "m2", "z", "zx", and "hp".
21
22
23Example
24-------
25
26 cpg_clocks: cpg_clocks@e6150000 {
27 compatible = "renesas,sh73a0-cpg-clocks";
28 reg = <0 0xe6150000 0 0x10000>;
29 clocks = <&extal1_clk>, <&extal2_clk>;
30 #clock-cells = <1>;
31 clock-output-names = "main", "pll0", "pll1", "pll2",
32 "pll3", "dsi0phy", "dsi1phy",
33 "zg", "m3", "b", "m1", "m2",
34 "z", "zx", "hp";
35 };
diff --git a/Documentation/devicetree/bindings/mfd/atmel-matrix.txt b/Documentation/devicetree/bindings/mfd/atmel-matrix.txt
new file mode 100644
index 000000000000..e3ef50ca02a5
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/atmel-matrix.txt
@@ -0,0 +1,24 @@
1* Device tree bindings for Atmel Bus Matrix
2
3The Bus Matrix registers are used to configure Atmel SoCs internal bus
4behavior (master/slave priorities, undefined burst length type, ...)
5
6Required properties:
7- compatible: Should be one of the following
8 "atmel,at91sam9260-matrix", "syscon"
9 "atmel,at91sam9261-matrix", "syscon"
10 "atmel,at91sam9263-matrix", "syscon"
11 "atmel,at91sam9rl-matrix", "syscon"
12 "atmel,at91sam9g45-matrix", "syscon"
13 "atmel,at91sam9n12-matrix", "syscon"
14 "atmel,at91sam9x5-matrix", "syscon"
15 "atmel,sama5d3-matrix", "syscon"
16- reg: Contains offset/length value of the Bus Matrix
17 memory region.
18
19Example:
20
21matrix: matrix@ffffec00 {
22 compatible = "atmel,sama5d3-matrix", "syscon";
23 reg = <0xffffec00 0x200>;
24};
diff --git a/Documentation/devicetree/bindings/mfd/atmel-smc.txt b/Documentation/devicetree/bindings/mfd/atmel-smc.txt
new file mode 100644
index 000000000000..26eeed373934
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/atmel-smc.txt
@@ -0,0 +1,19 @@
1* Device tree bindings for Atmel SMC (Static Memory Controller)
2
3The SMC registers are used to configure Atmel EBI (External Bus Interface)
4to interface with standard memory devices (NAND, NOR, SRAM or specialized
5devices like FPGAs).
6
7Required properties:
8- compatible: Should be one of the following
9 "atmel,at91sam9260-smc", "syscon"
10 "atmel,sama5d3-smc", "syscon"
11- reg: Contains offset/length value of the SMC memory
12 region.
13
14Example:
15
16smc: smc@ffffc000 {
17 compatible = "atmel,sama5d3-smc", "syscon";
18 reg = <0xffffc000 0x1000>;
19};
diff --git a/Documentation/devicetree/bindings/usb/atmel-usb.txt b/Documentation/devicetree/bindings/usb/atmel-usb.txt
index 38fee0f66c12..e180d56c75db 100644
--- a/Documentation/devicetree/bindings/usb/atmel-usb.txt
+++ b/Documentation/devicetree/bindings/usb/atmel-usb.txt
@@ -33,9 +33,17 @@ usb1: ehci@00800000 {
33AT91 USB device controller 33AT91 USB device controller
34 34
35Required properties: 35Required properties:
36 - compatible: Should be "atmel,at91rm9200-udc" 36 - compatible: Should be one of the following
37 "atmel,at91rm9200-udc"
38 "atmel,at91sam9260-udc"
39 "atmel,at91sam9261-udc"
40 "atmel,at91sam9263-udc"
37 - reg: Address and length of the register set for the device 41 - reg: Address and length of the register set for the device
38 - interrupts: Should contain macb interrupt 42 - interrupts: Should contain macb interrupt
43 - clocks: Should reference the peripheral and the AHB clocks
44 - clock-names: Should contains two strings
45 "pclk" for the peripheral clock
46 "hclk" for the AHB clock
39 47
40Optional properties: 48Optional properties:
41 - atmel,vbus-gpio: If present, specifies a gpio that needs to be 49 - atmel,vbus-gpio: If present, specifies a gpio that needs to be
diff --git a/arch/arm/boot/dts/sh73a0-kzm9g-reference.dts b/arch/arm/boot/dts/sh73a0-kzm9g-reference.dts
index 863dc4c7d7f6..6d32c87632d4 100644
--- a/arch/arm/boot/dts/sh73a0-kzm9g-reference.dts
+++ b/arch/arm/boot/dts/sh73a0-kzm9g-reference.dts
@@ -182,6 +182,10 @@
182 status = "okay"; 182 status = "okay";
183}; 183};
184 184
185&extal2_clk {
186 clock-frequency = <48000000>;
187};
188
185&i2c0 { 189&i2c0 {
186 status = "okay"; 190 status = "okay";
187 as3711@40 { 191 as3711@40 {
diff --git a/arch/arm/boot/dts/sh73a0.dtsi b/arch/arm/boot/dts/sh73a0.dtsi
index 37c8a761aeab..2dfd5b44255d 100644
--- a/arch/arm/boot/dts/sh73a0.dtsi
+++ b/arch/arm/boot/dts/sh73a0.dtsi
@@ -10,6 +10,7 @@
10 10
11/include/ "skeleton.dtsi" 11/include/ "skeleton.dtsi"
12 12
13#include <dt-bindings/clock/sh73a0-clock.h>
13#include <dt-bindings/interrupt-controller/irq.h> 14#include <dt-bindings/interrupt-controller/irq.h>
14 15
15/ { 16/ {
@@ -71,6 +72,8 @@
71 72
72 renesas,channels-mask = <0x3f>; 73 renesas,channels-mask = <0x3f>;
73 74
75 clocks = <&mstp3_clks SH73A0_CLK_CMT1>;
76 clock-names = "fck";
74 status = "disabled"; 77 status = "disabled";
75 }; 78 };
76 79
@@ -160,6 +163,7 @@
160 0 168 IRQ_TYPE_LEVEL_HIGH 163 0 168 IRQ_TYPE_LEVEL_HIGH
161 0 169 IRQ_TYPE_LEVEL_HIGH 164 0 169 IRQ_TYPE_LEVEL_HIGH
162 0 170 IRQ_TYPE_LEVEL_HIGH>; 165 0 170 IRQ_TYPE_LEVEL_HIGH>;
166 clocks = <&mstp1_clks SH73A0_CLK_IIC0>;
163 status = "disabled"; 167 status = "disabled";
164 }; 168 };
165 169
@@ -172,6 +176,7 @@
172 0 52 IRQ_TYPE_LEVEL_HIGH 176 0 52 IRQ_TYPE_LEVEL_HIGH
173 0 53 IRQ_TYPE_LEVEL_HIGH 177 0 53 IRQ_TYPE_LEVEL_HIGH
174 0 54 IRQ_TYPE_LEVEL_HIGH>; 178 0 54 IRQ_TYPE_LEVEL_HIGH>;
179 clocks = <&mstp3_clks SH73A0_CLK_IIC1>;
175 status = "disabled"; 180 status = "disabled";
176 }; 181 };
177 182
@@ -184,6 +189,7 @@
184 0 172 IRQ_TYPE_LEVEL_HIGH 189 0 172 IRQ_TYPE_LEVEL_HIGH
185 0 173 IRQ_TYPE_LEVEL_HIGH 190 0 173 IRQ_TYPE_LEVEL_HIGH
186 0 174 IRQ_TYPE_LEVEL_HIGH>; 191 0 174 IRQ_TYPE_LEVEL_HIGH>;
192 clocks = <&mstp0_clks SH73A0_CLK_IIC2>;
187 status = "disabled"; 193 status = "disabled";
188 }; 194 };
189 195
@@ -196,6 +202,7 @@
196 0 184 IRQ_TYPE_LEVEL_HIGH 202 0 184 IRQ_TYPE_LEVEL_HIGH
197 0 185 IRQ_TYPE_LEVEL_HIGH 203 0 185 IRQ_TYPE_LEVEL_HIGH
198 0 186 IRQ_TYPE_LEVEL_HIGH>; 204 0 186 IRQ_TYPE_LEVEL_HIGH>;
205 clocks = <&mstp4_clks SH73A0_CLK_IIC3>;
199 status = "disabled"; 206 status = "disabled";
200 }; 207 };
201 208
@@ -208,6 +215,7 @@
208 0 188 IRQ_TYPE_LEVEL_HIGH 215 0 188 IRQ_TYPE_LEVEL_HIGH
209 0 189 IRQ_TYPE_LEVEL_HIGH 216 0 189 IRQ_TYPE_LEVEL_HIGH
210 0 190 IRQ_TYPE_LEVEL_HIGH>; 217 0 190 IRQ_TYPE_LEVEL_HIGH>;
218 clocks = <&mstp4_clks SH73A0_CLK_IIC4>;
211 status = "disabled"; 219 status = "disabled";
212 }; 220 };
213 221
@@ -216,6 +224,7 @@
216 reg = <0xe6bd0000 0x100>; 224 reg = <0xe6bd0000 0x100>;
217 interrupts = <0 140 IRQ_TYPE_LEVEL_HIGH 225 interrupts = <0 140 IRQ_TYPE_LEVEL_HIGH
218 0 141 IRQ_TYPE_LEVEL_HIGH>; 226 0 141 IRQ_TYPE_LEVEL_HIGH>;
227 clocks = <&mstp3_clks SH73A0_CLK_MMCIF0>;
219 reg-io-width = <4>; 228 reg-io-width = <4>;
220 status = "disabled"; 229 status = "disabled";
221 }; 230 };
@@ -226,6 +235,7 @@
226 interrupts = <0 83 IRQ_TYPE_LEVEL_HIGH 235 interrupts = <0 83 IRQ_TYPE_LEVEL_HIGH
227 0 84 IRQ_TYPE_LEVEL_HIGH 236 0 84 IRQ_TYPE_LEVEL_HIGH
228 0 85 IRQ_TYPE_LEVEL_HIGH>; 237 0 85 IRQ_TYPE_LEVEL_HIGH>;
238 clocks = <&mstp3_clks SH73A0_CLK_SDHI0>;
229 cap-sd-highspeed; 239 cap-sd-highspeed;
230 status = "disabled"; 240 status = "disabled";
231 }; 241 };
@@ -236,6 +246,7 @@
236 reg = <0xee120000 0x100>; 246 reg = <0xee120000 0x100>;
237 interrupts = <0 88 IRQ_TYPE_LEVEL_HIGH 247 interrupts = <0 88 IRQ_TYPE_LEVEL_HIGH
238 0 89 IRQ_TYPE_LEVEL_HIGH>; 248 0 89 IRQ_TYPE_LEVEL_HIGH>;
249 clocks = <&mstp3_clks SH73A0_CLK_SDHI1>;
239 toshiba,mmc-wrprotect-disable; 250 toshiba,mmc-wrprotect-disable;
240 cap-sd-highspeed; 251 cap-sd-highspeed;
241 status = "disabled"; 252 status = "disabled";
@@ -246,6 +257,7 @@
246 reg = <0xee140000 0x100>; 257 reg = <0xee140000 0x100>;
247 interrupts = <0 104 IRQ_TYPE_LEVEL_HIGH 258 interrupts = <0 104 IRQ_TYPE_LEVEL_HIGH
248 0 105 IRQ_TYPE_LEVEL_HIGH>; 259 0 105 IRQ_TYPE_LEVEL_HIGH>;
260 clocks = <&mstp3_clks SH73A0_CLK_SDHI2>;
249 toshiba,mmc-wrprotect-disable; 261 toshiba,mmc-wrprotect-disable;
250 cap-sd-highspeed; 262 cap-sd-highspeed;
251 status = "disabled"; 263 status = "disabled";
@@ -255,6 +267,8 @@
255 compatible = "renesas,scifa-sh73a0", "renesas,scifa"; 267 compatible = "renesas,scifa-sh73a0", "renesas,scifa";
256 reg = <0xe6c40000 0x100>; 268 reg = <0xe6c40000 0x100>;
257 interrupts = <0 72 IRQ_TYPE_LEVEL_HIGH>; 269 interrupts = <0 72 IRQ_TYPE_LEVEL_HIGH>;
270 clocks = <&mstp2_clks SH73A0_CLK_SCIFA0>;
271 clock-names = "sci_ick";
258 status = "disabled"; 272 status = "disabled";
259 }; 273 };
260 274
@@ -262,6 +276,8 @@
262 compatible = "renesas,scifa-sh73a0", "renesas,scifa"; 276 compatible = "renesas,scifa-sh73a0", "renesas,scifa";
263 reg = <0xe6c50000 0x100>; 277 reg = <0xe6c50000 0x100>;
264 interrupts = <0 73 IRQ_TYPE_LEVEL_HIGH>; 278 interrupts = <0 73 IRQ_TYPE_LEVEL_HIGH>;
279 clocks = <&mstp2_clks SH73A0_CLK_SCIFA1>;
280 clock-names = "sci_ick";
265 status = "disabled"; 281 status = "disabled";
266 }; 282 };
267 283
@@ -269,6 +285,8 @@
269 compatible = "renesas,scifa-sh73a0", "renesas,scifa"; 285 compatible = "renesas,scifa-sh73a0", "renesas,scifa";
270 reg = <0xe6c60000 0x100>; 286 reg = <0xe6c60000 0x100>;
271 interrupts = <0 74 IRQ_TYPE_LEVEL_HIGH>; 287 interrupts = <0 74 IRQ_TYPE_LEVEL_HIGH>;
288 clocks = <&mstp2_clks SH73A0_CLK_SCIFA2>;
289 clock-names = "sci_ick";
272 status = "disabled"; 290 status = "disabled";
273 }; 291 };
274 292
@@ -276,6 +294,8 @@
276 compatible = "renesas,scifa-sh73a0", "renesas,scifa"; 294 compatible = "renesas,scifa-sh73a0", "renesas,scifa";
277 reg = <0xe6c70000 0x100>; 295 reg = <0xe6c70000 0x100>;
278 interrupts = <0 75 IRQ_TYPE_LEVEL_HIGH>; 296 interrupts = <0 75 IRQ_TYPE_LEVEL_HIGH>;
297 clocks = <&mstp2_clks SH73A0_CLK_SCIFA3>;
298 clock-names = "sci_ick";
279 status = "disabled"; 299 status = "disabled";
280 }; 300 };
281 301
@@ -283,6 +303,8 @@
283 compatible = "renesas,scifa-sh73a0", "renesas,scifa"; 303 compatible = "renesas,scifa-sh73a0", "renesas,scifa";
284 reg = <0xe6c80000 0x100>; 304 reg = <0xe6c80000 0x100>;
285 interrupts = <0 78 IRQ_TYPE_LEVEL_HIGH>; 305 interrupts = <0 78 IRQ_TYPE_LEVEL_HIGH>;
306 clocks = <&mstp2_clks SH73A0_CLK_SCIFA4>;
307 clock-names = "sci_ick";
286 status = "disabled"; 308 status = "disabled";
287 }; 309 };
288 310
@@ -290,6 +312,8 @@
290 compatible = "renesas,scifa-sh73a0", "renesas,scifa"; 312 compatible = "renesas,scifa-sh73a0", "renesas,scifa";
291 reg = <0xe6cb0000 0x100>; 313 reg = <0xe6cb0000 0x100>;
292 interrupts = <0 79 IRQ_TYPE_LEVEL_HIGH>; 314 interrupts = <0 79 IRQ_TYPE_LEVEL_HIGH>;
315 clocks = <&mstp2_clks SH73A0_CLK_SCIFA5>;
316 clock-names = "sci_ick";
293 status = "disabled"; 317 status = "disabled";
294 }; 318 };
295 319
@@ -297,6 +321,8 @@
297 compatible = "renesas,scifa-sh73a0", "renesas,scifa"; 321 compatible = "renesas,scifa-sh73a0", "renesas,scifa";
298 reg = <0xe6cc0000 0x100>; 322 reg = <0xe6cc0000 0x100>;
299 interrupts = <0 156 IRQ_TYPE_LEVEL_HIGH>; 323 interrupts = <0 156 IRQ_TYPE_LEVEL_HIGH>;
324 clocks = <&mstp3_clks SH73A0_CLK_SCIFA6>;
325 clock-names = "sci_ick";
300 status = "disabled"; 326 status = "disabled";
301 }; 327 };
302 328
@@ -304,6 +330,8 @@
304 compatible = "renesas,scifa-sh73a0", "renesas,scifa"; 330 compatible = "renesas,scifa-sh73a0", "renesas,scifa";
305 reg = <0xe6cd0000 0x100>; 331 reg = <0xe6cd0000 0x100>;
306 interrupts = <0 143 IRQ_TYPE_LEVEL_HIGH>; 332 interrupts = <0 143 IRQ_TYPE_LEVEL_HIGH>;
333 clocks = <&mstp2_clks SH73A0_CLK_SCIFA7>;
334 clock-names = "sci_ick";
307 status = "disabled"; 335 status = "disabled";
308 }; 336 };
309 337
@@ -311,6 +339,8 @@
311 compatible = "renesas,scifb-sh73a0", "renesas,scifb"; 339 compatible = "renesas,scifb-sh73a0", "renesas,scifb";
312 reg = <0xe6c30000 0x100>; 340 reg = <0xe6c30000 0x100>;
313 interrupts = <0 80 IRQ_TYPE_LEVEL_HIGH>; 341 interrupts = <0 80 IRQ_TYPE_LEVEL_HIGH>;
342 clocks = <&mstp2_clks SH73A0_CLK_SCIFB>;
343 clock-names = "sci_ick";
314 status = "disabled"; 344 status = "disabled";
315 }; 345 };
316 346
@@ -338,4 +368,332 @@
338 interrupts = <0 146 0x4>; 368 interrupts = <0 146 0x4>;
339 status = "disabled"; 369 status = "disabled";
340 }; 370 };
371
372 clocks {
373 #address-cells = <1>;
374 #size-cells = <1>;
375 ranges;
376
377 /* External root clocks */
378 extalr_clk: extalr_clk {
379 compatible = "fixed-clock";
380 #clock-cells = <0>;
381 clock-frequency = <32768>;
382 clock-output-names = "extalr";
383 };
384 extal1_clk: extal1_clk {
385 compatible = "fixed-clock";
386 #clock-cells = <0>;
387 clock-frequency = <26000000>;
388 clock-output-names = "extal1";
389 };
390 extal2_clk: extal2_clk {
391 compatible = "fixed-clock";
392 #clock-cells = <0>;
393 clock-output-names = "extal2";
394 };
395 extcki_clk: extcki_clk {
396 compatible = "fixed-clock";
397 #clock-cells = <0>;
398 clock-output-names = "extcki";
399 };
400 fsiack_clk: fsiack_clk {
401 compatible = "fixed-clock";
402 #clock-cells = <0>;
403 clock-frequency = <0>;
404 clock-output-names = "fsiack";
405 };
406 fsibck_clk: fsibck_clk {
407 compatible = "fixed-clock";
408 #clock-cells = <0>;
409 clock-frequency = <0>;
410 clock-output-names = "fsibck";
411 };
412
413 /* Special CPG clocks */
414 cpg_clocks: cpg_clocks@e6150000 {
415 compatible = "renesas,sh73a0-cpg-clocks";
416 reg = <0xe6150000 0x10000>;
417 clocks = <&extal1_clk>, <&extal2_clk>;
418 #clock-cells = <1>;
419 clock-output-names = "main", "pll0", "pll1", "pll2",
420 "pll3", "dsi0phy", "dsi1phy",
421 "zg", "m3", "b", "m1", "m2",
422 "z", "zx", "hp";
423 };
424
425 /* Variable factor clocks (DIV6) */
426 vclk1_clk: vclk1_clk@e6150008 {
427 compatible = "renesas,sh73a0-div6-clock", "renesas,cpg-div6-clock";
428 reg = <0xe6150008 4>;
429 clocks = <&pll1_div2_clk>;
430 #clock-cells = <0>;
431 clock-output-names = "vclk1";
432 };
433 vclk2_clk: vclk2_clk@e615000c {
434 compatible = "renesas,sh73a0-div6-clock", "renesas,cpg-div6-clock";
435 reg = <0xe615000c 4>;
436 clocks = <&pll1_div2_clk>;
437 #clock-cells = <0>;
438 clock-output-names = "vclk2";
439 };
440 vclk3_clk: vclk3_clk@e615001c {
441 compatible = "renesas,sh73a0-div6-clock", "renesas,cpg-div6-clock";
442 reg = <0xe615001c 4>;
443 clocks = <&pll1_div2_clk>;
444 #clock-cells = <0>;
445 clock-output-names = "vclk3";
446 };
447 zb_clk: zb_clk@e6150010 {
448 compatible = "renesas,sh73a0-div6-clock", "renesas,cpg-div6-clock";
449 reg = <0xe6150010 4>;
450 clocks = <&pll1_div2_clk>;
451 #clock-cells = <0>;
452 clock-output-names = "zb";
453 };
454 flctl_clk: flctl_clk@e6150014 {
455 compatible = "renesas,sh73a0-div6-clock", "renesas,cpg-div6-clock";
456 reg = <0xe6150014 4>;
457 clocks = <&pll1_div2_clk>;
458 #clock-cells = <0>;
459 clock-output-names = "flctlck";
460 };
461 sdhi0_clk: sdhi0_clk@e6150074 {
462 compatible = "renesas,sh73a0-div6-clock", "renesas,cpg-div6-clock";
463 reg = <0xe6150074 4>;
464 clocks = <&pll1_div2_clk>;
465 #clock-cells = <0>;
466 clock-output-names = "sdhi0ck";
467 };
468 sdhi1_clk: sdhi1_clk@e6150078 {
469 compatible = "renesas,sh73a0-div6-clock", "renesas,cpg-div6-clock";
470 reg = <0xe6150078 4>;
471 clocks = <&pll1_div2_clk>;
472 #clock-cells = <0>;
473 clock-output-names = "sdhi1ck";
474 };
475 sdhi2_clk: sdhi2_clk@e615007c {
476 compatible = "renesas,sh73a0-div6-clock", "renesas,cpg-div6-clock";
477 reg = <0xe615007c 4>;
478 clocks = <&pll1_div2_clk>;
479 #clock-cells = <0>;
480 clock-output-names = "sdhi2ck";
481 };
482 fsia_clk: fsia_clk@e6150018 {
483 compatible = "renesas,sh73a0-div6-clock", "renesas,cpg-div6-clock";
484 reg = <0xe6150018 4>;
485 clocks = <&pll1_div2_clk>;
486 #clock-cells = <0>;
487 clock-output-names = "fsia";
488 };
489 fsib_clk: fsib_clk@e6150090 {
490 compatible = "renesas,sh73a0-div6-clock", "renesas,cpg-div6-clock";
491 reg = <0xe6150090 4>;
492 clocks = <&pll1_div2_clk>;
493 #clock-cells = <0>;
494 clock-output-names = "fsib";
495 };
496 sub_clk: sub_clk@e6150080 {
497 compatible = "renesas,sh73a0-div6-clock", "renesas,cpg-div6-clock";
498 reg = <0xe6150080 4>;
499 clocks = <&extal2_clk>;
500 #clock-cells = <0>;
501 clock-output-names = "sub";
502 };
503 spua_clk: spua_clk@e6150084 {
504 compatible = "renesas,sh73a0-div6-clock", "renesas,cpg-div6-clock";
505 reg = <0xe6150084 4>;
506 clocks = <&pll1_div2_clk>;
507 #clock-cells = <0>;
508 clock-output-names = "spua";
509 };
510 spuv_clk: spuv_clk@e6150094 {
511 compatible = "renesas,sh73a0-div6-clock", "renesas,cpg-div6-clock";
512 reg = <0xe6150094 4>;
513 clocks = <&pll1_div2_clk>;
514 #clock-cells = <0>;
515 clock-output-names = "spuv";
516 };
517 msu_clk: msu_clk@e6150088 {
518 compatible = "renesas,sh73a0-div6-clock", "renesas,cpg-div6-clock";
519 reg = <0xe6150088 4>;
520 clocks = <&pll1_div2_clk>;
521 #clock-cells = <0>;
522 clock-output-names = "msu";
523 };
524 hsi_clk: hsi_clk@e615008c {
525 compatible = "renesas,sh73a0-div6-clock", "renesas,cpg-div6-clock";
526 reg = <0xe615008c 4>;
527 clocks = <&pll1_div2_clk>;
528 #clock-cells = <0>;
529 clock-output-names = "hsi";
530 };
531 mfg1_clk: mfg1_clk@e6150098 {
532 compatible = "renesas,sh73a0-div6-clock", "renesas,cpg-div6-clock";
533 reg = <0xe6150098 4>;
534 clocks = <&pll1_div2_clk>;
535 #clock-cells = <0>;
536 clock-output-names = "mfg1";
537 };
538 mfg2_clk: mfg2_clk@e615009c {
539 compatible = "renesas,sh73a0-div6-clock", "renesas,cpg-div6-clock";
540 reg = <0xe615009c 4>;
541 clocks = <&pll1_div2_clk>;
542 #clock-cells = <0>;
543 clock-output-names = "mfg2";
544 };
545 dsit_clk: dsit_clk@e6150060 {
546 compatible = "renesas,sh73a0-div6-clock", "renesas,cpg-div6-clock";
547 reg = <0xe6150060 4>;
548 clocks = <&pll1_div2_clk>;
549 #clock-cells = <0>;
550 clock-output-names = "dsit";
551 };
552 dsi0p_clk: dsi0p_clk@e6150064 {
553 compatible = "renesas,sh73a0-div6-clock", "renesas,cpg-div6-clock";
554 reg = <0xe6150064 4>;
555 clocks = <&pll1_div2_clk>;
556 #clock-cells = <0>;
557 clock-output-names = "dsi0pck";
558 };
559
560 /* Fixed factor clocks */
561 main_div2_clk: main_div2_clk {
562 compatible = "fixed-factor-clock";
563 clocks = <&cpg_clocks SH73A0_CLK_MAIN>;
564 #clock-cells = <0>;
565 clock-div = <2>;
566 clock-mult = <1>;
567 clock-output-names = "main_div2";
568 };
569 pll1_div2_clk: pll1_div2_clk {
570 compatible = "fixed-factor-clock";
571 clocks = <&cpg_clocks SH73A0_CLK_PLL1>;
572 #clock-cells = <0>;
573 clock-div = <2>;
574 clock-mult = <1>;
575 clock-output-names = "pll1_div2";
576 };
577 pll1_div7_clk: pll1_div7_clk {
578 compatible = "fixed-factor-clock";
579 clocks = <&cpg_clocks SH73A0_CLK_PLL1>;
580 #clock-cells = <0>;
581 clock-div = <7>;
582 clock-mult = <1>;
583 clock-output-names = "pll1_div7";
584 };
585 pll1_div13_clk: pll1_div13_clk {
586 compatible = "fixed-factor-clock";
587 clocks = <&cpg_clocks SH73A0_CLK_PLL1>;
588 #clock-cells = <0>;
589 clock-div = <13>;
590 clock-mult = <1>;
591 clock-output-names = "pll1_div13";
592 };
593 twd_clk: twd_clk {
594 compatible = "fixed-factor-clock";
595 clocks = <&cpg_clocks SH73A0_CLK_Z>;
596 #clock-cells = <0>;
597 clock-div = <4>;
598 clock-mult = <1>;
599 clock-output-names = "twd";
600 };
601
602 /* Gate clocks */
603 mstp0_clks: mstp0_clks@e6150130 {
604 compatible = "renesas,sh73a0-mstp-clocks", "renesas,cpg-mstp-clocks";
605 reg = <0xe6150130 4>, <0xe6150030 4>;
606 clocks = <&cpg_clocks SH73A0_CLK_HP>;
607 #clock-cells = <1>;
608 clock-indices = <
609 SH73A0_CLK_IIC2
610 >;
611 clock-output-names =
612 "iic2";
613 };
614 mstp1_clks: mstp1_clks@e6150134 {
615 compatible = "renesas,sh73a0-mstp-clocks", "renesas,cpg-mstp-clocks";
616 reg = <0xe6150134 4>, <0xe6150038 4>;
617 clocks = <&cpg_clocks SH73A0_CLK_B>,
618 <&cpg_clocks SH73A0_CLK_B>,
619 <&cpg_clocks SH73A0_CLK_B>,
620 <&cpg_clocks SH73A0_CLK_B>,
621 <&sub_clk>, <&cpg_clocks SH73A0_CLK_B>,
622 <&cpg_clocks SH73A0_CLK_HP>,
623 <&cpg_clocks SH73A0_CLK_ZG>,
624 <&cpg_clocks SH73A0_CLK_B>;
625 #clock-cells = <1>;
626 clock-indices = <
627 SH73A0_CLK_CEU1 SH73A0_CLK_CSI2_RX1
628 SH73A0_CLK_CEU0 SH73A0_CLK_CSI2_RX0
629 SH73A0_CLK_TMU0 SH73A0_CLK_DSITX0
630 SH73A0_CLK_IIC0 SH73A0_CLK_SGX
631 SH73A0_CLK_LCDC0
632 >;
633 clock-output-names =
634 "ceu1", "csi2_rx1", "ceu0", "csi2_rx0",
635 "tmu0", "dsitx0", "iic0", "sgx", "lcdc0";
636 };
637 mstp2_clks: mstp2_clks@e6150138 {
638 compatible = "renesas,sh73a0-mstp-clocks", "renesas,cpg-mstp-clocks";
639 reg = <0xe6150138 4>, <0xe6150040 4>;
640 clocks = <&sub_clk>, <&cpg_clocks SH73A0_CLK_HP>,
641 <&cpg_clocks SH73A0_CLK_HP>, <&sub_clk>,
642 <&sub_clk>, <&sub_clk>, <&sub_clk>, <&sub_clk>,
643 <&sub_clk>, <&sub_clk>;
644 #clock-cells = <1>;
645 clock-indices = <
646 SH73A0_CLK_SCIFA7 SH73A0_CLK_SY_DMAC
647 SH73A0_CLK_MP_DMAC SH73A0_CLK_SCIFA5
648 SH73A0_CLK_SCIFB SH73A0_CLK_SCIFA0
649 SH73A0_CLK_SCIFA1 SH73A0_CLK_SCIFA2
650 SH73A0_CLK_SCIFA3 SH73A0_CLK_SCIFA4
651 >;
652 clock-output-names =
653 "scifa7", "sy_dmac", "mp_dmac", "scifa5",
654 "scifb", "scifa0", "scifa1", "scifa2",
655 "scifa3", "scifa4";
656 };
657 mstp3_clks: mstp3_clks@e615013c {
658 compatible = "renesas,sh73a0-mstp-clocks", "renesas,cpg-mstp-clocks";
659 reg = <0xe615013c 4>, <0xe6150048 4>;
660 clocks = <&sub_clk>, <&extalr_clk>,
661 <&cpg_clocks SH73A0_CLK_HP>, <&sub_clk>,
662 <&cpg_clocks SH73A0_CLK_HP>,
663 <&cpg_clocks SH73A0_CLK_HP>, <&flctl_clk>,
664 <&sdhi0_clk>, <&sdhi1_clk>,
665 <&cpg_clocks SH73A0_CLK_HP>, <&sdhi2_clk>,
666 <&main_div2_clk>, <&main_div2_clk>,
667 <&main_div2_clk>, <&main_div2_clk>,
668 <&main_div2_clk>;
669 #clock-cells = <1>;
670 clock-indices = <
671 SH73A0_CLK_SCIFA6 SH73A0_CLK_CMT1
672 SH73A0_CLK_FSI SH73A0_CLK_IRDA
673 SH73A0_CLK_IIC1 SH73A0_CLK_USB SH73A0_CLK_FLCTL
674 SH73A0_CLK_SDHI0 SH73A0_CLK_SDHI1
675 SH73A0_CLK_MMCIF0 SH73A0_CLK_SDHI2
676 SH73A0_CLK_TPU0 SH73A0_CLK_TPU1
677 SH73A0_CLK_TPU2 SH73A0_CLK_TPU3
678 SH73A0_CLK_TPU4
679 >;
680 clock-output-names =
681 "scifa6", "cmt1", "fsi", "irda", "iic1",
682 "usb", "flctl", "sdhi0", "sdhi1", "mmcif0", "sdhi2",
683 "tpu0", "tpu1", "tpu2", "tpu3", "tpu4";
684 };
685 mstp4_clks: mstp4_clks@e6150140 {
686 compatible = "renesas,sh73a0-mstp-clocks", "renesas,cpg-mstp-clocks";
687 reg = <0xe6150140 4>, <0xe615004c 4>;
688 clocks = <&cpg_clocks SH73A0_CLK_HP>,
689 <&cpg_clocks SH73A0_CLK_HP>, <&extalr_clk>;
690 #clock-cells = <1>;
691 clock-indices = <
692 SH73A0_CLK_IIC3 SH73A0_CLK_IIC4
693 SH73A0_CLK_KEYSC
694 >;
695 clock-output-names =
696 "iic3", "iic4", "keysc";
697 };
698 };
341}; 699};
diff --git a/arch/arm/mach-exynos/common.h b/arch/arm/mach-exynos/common.h
index 865f878063cc..f70eca7ee705 100644
--- a/arch/arm/mach-exynos/common.h
+++ b/arch/arm/mach-exynos/common.h
@@ -13,6 +13,7 @@
13#define __ARCH_ARM_MACH_EXYNOS_COMMON_H 13#define __ARCH_ARM_MACH_EXYNOS_COMMON_H
14 14
15#include <linux/of.h> 15#include <linux/of.h>
16#include <linux/platform_data/cpuidle-exynos.h>
16 17
17#define EXYNOS3250_SOC_ID 0xE3472000 18#define EXYNOS3250_SOC_ID 0xE3472000
18#define EXYNOS3_SOC_MASK 0xFFFFF000 19#define EXYNOS3_SOC_MASK 0xFFFFF000
@@ -150,8 +151,11 @@ extern void exynos_pm_central_suspend(void);
150extern int exynos_pm_central_resume(void); 151extern int exynos_pm_central_resume(void);
151extern void exynos_enter_aftr(void); 152extern void exynos_enter_aftr(void);
152 153
154extern struct cpuidle_exynos_data cpuidle_coupled_exynos_data;
155
153extern void s5p_init_cpu(void __iomem *cpuid_addr); 156extern void s5p_init_cpu(void __iomem *cpuid_addr);
154extern unsigned int samsung_rev(void); 157extern unsigned int samsung_rev(void);
158extern void __iomem *cpu_boot_reg_base(void);
155 159
156static inline void pmu_raw_writel(u32 val, u32 offset) 160static inline void pmu_raw_writel(u32 val, u32 offset)
157{ 161{
diff --git a/arch/arm/mach-exynos/exynos.c b/arch/arm/mach-exynos/exynos.c
index 78eca99b98d1..2013f73797ed 100644
--- a/arch/arm/mach-exynos/exynos.c
+++ b/arch/arm/mach-exynos/exynos.c
@@ -211,6 +211,10 @@ static void __init exynos_dt_machine_init(void)
211 if (!IS_ENABLED(CONFIG_SMP)) 211 if (!IS_ENABLED(CONFIG_SMP))
212 exynos_sysram_init(); 212 exynos_sysram_init();
213 213
214#ifdef CONFIG_ARM_EXYNOS_CPUIDLE
215 if (of_machine_is_compatible("samsung,exynos4210"))
216 exynos_cpuidle.dev.platform_data = &cpuidle_coupled_exynos_data;
217#endif
214 if (of_machine_is_compatible("samsung,exynos4210") || 218 if (of_machine_is_compatible("samsung,exynos4210") ||
215 of_machine_is_compatible("samsung,exynos4212") || 219 of_machine_is_compatible("samsung,exynos4212") ||
216 (of_machine_is_compatible("samsung,exynos4412") && 220 (of_machine_is_compatible("samsung,exynos4412") &&
diff --git a/arch/arm/mach-exynos/platsmp.c b/arch/arm/mach-exynos/platsmp.c
index 7a1ebfeeeeb8..3f32c47a6d74 100644
--- a/arch/arm/mach-exynos/platsmp.c
+++ b/arch/arm/mach-exynos/platsmp.c
@@ -194,7 +194,7 @@ int exynos_cluster_power_state(int cluster)
194 S5P_CORE_LOCAL_PWR_EN); 194 S5P_CORE_LOCAL_PWR_EN);
195} 195}
196 196
197static inline void __iomem *cpu_boot_reg_base(void) 197void __iomem *cpu_boot_reg_base(void)
198{ 198{
199 if (soc_is_exynos4210() && samsung_rev() == EXYNOS4210_REV_1_1) 199 if (soc_is_exynos4210() && samsung_rev() == EXYNOS4210_REV_1_1)
200 return pmu_base_addr + S5P_INFORM5; 200 return pmu_base_addr + S5P_INFORM5;
diff --git a/arch/arm/mach-exynos/pm.c b/arch/arm/mach-exynos/pm.c
index dfc8594e5b1f..e6209dadc00d 100644
--- a/arch/arm/mach-exynos/pm.c
+++ b/arch/arm/mach-exynos/pm.c
@@ -98,10 +98,6 @@ void exynos_pm_central_suspend(void)
98 tmp = pmu_raw_readl(S5P_CENTRAL_SEQ_CONFIGURATION); 98 tmp = pmu_raw_readl(S5P_CENTRAL_SEQ_CONFIGURATION);
99 tmp &= ~S5P_CENTRAL_LOWPWR_CFG; 99 tmp &= ~S5P_CENTRAL_LOWPWR_CFG;
100 pmu_raw_writel(tmp, S5P_CENTRAL_SEQ_CONFIGURATION); 100 pmu_raw_writel(tmp, S5P_CENTRAL_SEQ_CONFIGURATION);
101
102 /* Setting SEQ_OPTION register */
103 pmu_raw_writel(S5P_USE_STANDBY_WFI0 | S5P_USE_STANDBY_WFE0,
104 S5P_CENTRAL_SEQ_OPTION);
105} 101}
106 102
107int exynos_pm_central_resume(void) 103int exynos_pm_central_resume(void)
@@ -165,6 +161,13 @@ void exynos_enter_aftr(void)
165 161
166 exynos_pm_central_suspend(); 162 exynos_pm_central_suspend();
167 163
164 if (of_machine_is_compatible("samsung,exynos4212") ||
165 of_machine_is_compatible("samsung,exynos4412")) {
166 /* Setting SEQ_OPTION register */
167 pmu_raw_writel(S5P_USE_STANDBY_WFI0 | S5P_USE_STANDBY_WFE0,
168 S5P_CENTRAL_SEQ_OPTION);
169 }
170
168 cpu_suspend(0, exynos_aftr_finisher); 171 cpu_suspend(0, exynos_aftr_finisher);
169 172
170 if (read_cpuid_part() == ARM_CPU_PART_CORTEX_A9) { 173 if (read_cpuid_part() == ARM_CPU_PART_CORTEX_A9) {
@@ -177,3 +180,125 @@ void exynos_enter_aftr(void)
177 180
178 cpu_pm_exit(); 181 cpu_pm_exit();
179} 182}
183
184static atomic_t cpu1_wakeup = ATOMIC_INIT(0);
185
186static int exynos_cpu0_enter_aftr(void)
187{
188 int ret = -1;
189
190 /*
191 * If the other cpu is powered on, we have to power it off, because
192 * the AFTR state won't work otherwise
193 */
194 if (cpu_online(1)) {
195 /*
196 * We reach a sync point with the coupled idle state, we know
197 * the other cpu will power down itself or will abort the
198 * sequence, let's wait for one of these to happen
199 */
200 while (exynos_cpu_power_state(1)) {
201 /*
202 * The other cpu may skip idle and boot back
203 * up again
204 */
205 if (atomic_read(&cpu1_wakeup))
206 goto abort;
207
208 /*
209 * The other cpu may bounce through idle and
210 * boot back up again, getting stuck in the
211 * boot rom code
212 */
213 if (__raw_readl(cpu_boot_reg_base()) == 0)
214 goto abort;
215
216 cpu_relax();
217 }
218 }
219
220 exynos_enter_aftr();
221 ret = 0;
222
223abort:
224 if (cpu_online(1)) {
225 /*
226 * Set the boot vector to something non-zero
227 */
228 __raw_writel(virt_to_phys(exynos_cpu_resume),
229 cpu_boot_reg_base());
230 dsb();
231
232 /*
233 * Turn on cpu1 and wait for it to be on
234 */
235 exynos_cpu_power_up(1);
236 while (exynos_cpu_power_state(1) != S5P_CORE_LOCAL_PWR_EN)
237 cpu_relax();
238
239 while (!atomic_read(&cpu1_wakeup)) {
240 /*
241 * Poke cpu1 out of the boot rom
242 */
243 __raw_writel(virt_to_phys(exynos_cpu_resume),
244 cpu_boot_reg_base());
245
246 arch_send_wakeup_ipi_mask(cpumask_of(1));
247 }
248 }
249
250 return ret;
251}
252
253static int exynos_wfi_finisher(unsigned long flags)
254{
255 cpu_do_idle();
256
257 return -1;
258}
259
260static int exynos_cpu1_powerdown(void)
261{
262 int ret = -1;
263
264 /*
265 * Idle sequence for cpu1
266 */
267 if (cpu_pm_enter())
268 goto cpu1_aborted;
269
270 /*
271 * Turn off cpu 1
272 */
273 exynos_cpu_power_down(1);
274
275 ret = cpu_suspend(0, exynos_wfi_finisher);
276
277 cpu_pm_exit();
278
279cpu1_aborted:
280 dsb();
281 /*
282 * Notify cpu 0 that cpu 1 is awake
283 */
284 atomic_set(&cpu1_wakeup, 1);
285
286 return ret;
287}
288
289static void exynos_pre_enter_aftr(void)
290{
291 __raw_writel(virt_to_phys(exynos_cpu_resume), cpu_boot_reg_base());
292}
293
294static void exynos_post_enter_aftr(void)
295{
296 atomic_set(&cpu1_wakeup, 0);
297}
298
299struct cpuidle_exynos_data cpuidle_coupled_exynos_data = {
300 .cpu0_enter_aftr = exynos_cpu0_enter_aftr,
301 .cpu1_powerdown = exynos_cpu1_powerdown,
302 .pre_enter_aftr = exynos_pre_enter_aftr,
303 .post_enter_aftr = exynos_post_enter_aftr,
304};
diff --git a/arch/arm/mach-exynos/suspend.c b/arch/arm/mach-exynos/suspend.c
index 82e6b6fba23f..666ec3e5b03f 100644
--- a/arch/arm/mach-exynos/suspend.c
+++ b/arch/arm/mach-exynos/suspend.c
@@ -319,6 +319,10 @@ static int exynos_pm_suspend(void)
319{ 319{
320 exynos_pm_central_suspend(); 320 exynos_pm_central_suspend();
321 321
322 /* Setting SEQ_OPTION register */
323 pmu_raw_writel(S5P_USE_STANDBY_WFI0 | S5P_USE_STANDBY_WFE0,
324 S5P_CENTRAL_SEQ_OPTION);
325
322 if (read_cpuid_part() == ARM_CPU_PART_CORTEX_A9) 326 if (read_cpuid_part() == ARM_CPU_PART_CORTEX_A9)
323 exynos_cpu_save_register(); 327 exynos_cpu_save_register();
324 328
diff --git a/arch/arm/mach-shmobile/setup-sh73a0.c b/arch/arm/mach-shmobile/setup-sh73a0.c
index a8593d1241be..faea74a2151b 100644
--- a/arch/arm/mach-shmobile/setup-sh73a0.c
+++ b/arch/arm/mach-shmobile/setup-sh73a0.c
@@ -766,7 +766,9 @@ void __init __weak sh73a0_register_twd(void) { }
766void __init sh73a0_earlytimer_init(void) 766void __init sh73a0_earlytimer_init(void)
767{ 767{
768 shmobile_init_delay(); 768 shmobile_init_delay();
769#ifndef CONFIG_COMMON_CLK
769 sh73a0_clock_init(); 770 sh73a0_clock_init();
771#endif
770 shmobile_earlytimer_init(); 772 shmobile_earlytimer_init();
771 sh73a0_register_twd(); 773 sh73a0_register_twd();
772} 774}
@@ -785,8 +787,9 @@ void __init sh73a0_add_early_devices(void)
785void __init sh73a0_add_standard_devices_dt(void) 787void __init sh73a0_add_standard_devices_dt(void)
786{ 788{
787 /* clocks are setup late during boot in the case of DT */ 789 /* clocks are setup late during boot in the case of DT */
790#ifndef CONFIG_COMMON_CLK
788 sh73a0_clock_init(); 791 sh73a0_clock_init();
789 792#endif
790 of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL); 793 of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
791} 794}
792 795
diff --git a/drivers/clk/shmobile/Makefile b/drivers/clk/shmobile/Makefile
index 960bf22d42ae..f83980f2b956 100644
--- a/drivers/clk/shmobile/Makefile
+++ b/drivers/clk/shmobile/Makefile
@@ -5,5 +5,6 @@ obj-$(CONFIG_ARCH_R8A7779) += clk-r8a7779.o
5obj-$(CONFIG_ARCH_R8A7790) += clk-rcar-gen2.o 5obj-$(CONFIG_ARCH_R8A7790) += clk-rcar-gen2.o
6obj-$(CONFIG_ARCH_R8A7791) += clk-rcar-gen2.o 6obj-$(CONFIG_ARCH_R8A7791) += clk-rcar-gen2.o
7obj-$(CONFIG_ARCH_R8A7794) += clk-rcar-gen2.o 7obj-$(CONFIG_ARCH_R8A7794) += clk-rcar-gen2.o
8obj-$(CONFIG_ARCH_SH73A0) += clk-sh73a0.o
8obj-$(CONFIG_ARCH_SHMOBILE_MULTI) += clk-div6.o 9obj-$(CONFIG_ARCH_SHMOBILE_MULTI) += clk-div6.o
9obj-$(CONFIG_ARCH_SHMOBILE_MULTI) += clk-mstp.o 10obj-$(CONFIG_ARCH_SHMOBILE_MULTI) += clk-mstp.o
diff --git a/drivers/clk/shmobile/clk-sh73a0.c b/drivers/clk/shmobile/clk-sh73a0.c
new file mode 100644
index 000000000000..cd529cfe412f
--- /dev/null
+++ b/drivers/clk/shmobile/clk-sh73a0.c
@@ -0,0 +1,218 @@
1/*
2 * sh73a0 Core CPG Clocks
3 *
4 * Copyright (C) 2014 Ulrich Hecht
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 */
10
11#include <linux/clk-provider.h>
12#include <linux/clkdev.h>
13#include <linux/clk/shmobile.h>
14#include <linux/init.h>
15#include <linux/kernel.h>
16#include <linux/of.h>
17#include <linux/of_address.h>
18#include <linux/spinlock.h>
19
20struct sh73a0_cpg {
21 struct clk_onecell_data data;
22 spinlock_t lock;
23 void __iomem *reg;
24};
25
26#define CPG_FRQCRA 0x00
27#define CPG_FRQCRB 0x04
28#define CPG_SD0CKCR 0x74
29#define CPG_SD1CKCR 0x78
30#define CPG_SD2CKCR 0x7c
31#define CPG_PLLECR 0xd0
32#define CPG_PLL0CR 0xd8
33#define CPG_PLL1CR 0x28
34#define CPG_PLL2CR 0x2c
35#define CPG_PLL3CR 0xdc
36#define CPG_CKSCR 0xc0
37#define CPG_DSI0PHYCR 0x6c
38#define CPG_DSI1PHYCR 0x70
39
40#define CLK_ENABLE_ON_INIT BIT(0)
41
42struct div4_clk {
43 const char *name;
44 const char *parent;
45 unsigned int reg;
46 unsigned int shift;
47};
48
49static struct div4_clk div4_clks[] = {
50 { "zg", "pll0", CPG_FRQCRA, 16 },
51 { "m3", "pll1", CPG_FRQCRA, 12 },
52 { "b", "pll1", CPG_FRQCRA, 8 },
53 { "m1", "pll1", CPG_FRQCRA, 4 },
54 { "m2", "pll1", CPG_FRQCRA, 0 },
55 { "zx", "pll1", CPG_FRQCRB, 12 },
56 { "hp", "pll1", CPG_FRQCRB, 4 },
57 { NULL, NULL, 0, 0 },
58};
59
60static const struct clk_div_table div4_div_table[] = {
61 { 0, 2 }, { 1, 3 }, { 2, 4 }, { 3, 6 }, { 4, 8 }, { 5, 12 },
62 { 6, 16 }, { 7, 18 }, { 8, 24 }, { 10, 36 }, { 11, 48 },
63 { 12, 7 }, { 0, 0 }
64};
65
66static const struct clk_div_table z_div_table[] = {
67 /* ZSEL == 0 */
68 { 0, 1 }, { 1, 1 }, { 2, 1 }, { 3, 1 }, { 4, 1 }, { 5, 1 },
69 { 6, 1 }, { 7, 1 }, { 8, 1 }, { 9, 1 }, { 10, 1 }, { 11, 1 },
70 { 12, 1 }, { 13, 1 }, { 14, 1 }, { 15, 1 },
71 /* ZSEL == 1 */
72 { 16, 2 }, { 17, 3 }, { 18, 4 }, { 19, 6 }, { 20, 8 }, { 21, 12 },
73 { 22, 16 }, { 24, 24 }, { 27, 48 }, { 0, 0 }
74};
75
76static struct clk * __init
77sh73a0_cpg_register_clock(struct device_node *np, struct sh73a0_cpg *cpg,
78 const char *name)
79{
80 const struct clk_div_table *table = NULL;
81 unsigned int shift, reg, width;
82 const char *parent_name;
83 unsigned int mult = 1;
84 unsigned int div = 1;
85
86 if (!strcmp(name, "main")) {
87 /* extal1, extal1_div2, extal2, extal2_div2 */
88 u32 parent_idx = (clk_readl(cpg->reg + CPG_CKSCR) >> 28) & 3;
89
90 parent_name = of_clk_get_parent_name(np, parent_idx >> 1);
91 div = (parent_idx & 1) + 1;
92 } else if (!strncmp(name, "pll", 3)) {
93 void __iomem *enable_reg = cpg->reg;
94 u32 enable_bit = name[3] - '0';
95
96 parent_name = "main";
97 switch (enable_bit) {
98 case 0:
99 enable_reg += CPG_PLL0CR;
100 break;
101 case 1:
102 enable_reg += CPG_PLL1CR;
103 break;
104 case 2:
105 enable_reg += CPG_PLL2CR;
106 break;
107 case 3:
108 enable_reg += CPG_PLL3CR;
109 break;
110 default:
111 return ERR_PTR(-EINVAL);
112 }
113 if (clk_readl(cpg->reg + CPG_PLLECR) & BIT(enable_bit)) {
114 mult = ((clk_readl(enable_reg) >> 24) & 0x3f) + 1;
115 /* handle CFG bit for PLL1 and PLL2 */
116 if (enable_bit == 1 || enable_bit == 2)
117 if (clk_readl(enable_reg) & BIT(20))
118 mult *= 2;
119 }
120 } else if (!strcmp(name, "dsi0phy") || !strcmp(name, "dsi1phy")) {
121 u32 phy_no = name[3] - '0';
122 void __iomem *dsi_reg = cpg->reg +
123 (phy_no ? CPG_DSI1PHYCR : CPG_DSI0PHYCR);
124
125 parent_name = phy_no ? "dsi1pck" : "dsi0pck";
126 mult = __raw_readl(dsi_reg);
127 if (!(mult & 0x8000))
128 mult = 1;
129 else
130 mult = (mult & 0x3f) + 1;
131 } else if (!strcmp(name, "z")) {
132 parent_name = "pll0";
133 table = z_div_table;
134 reg = CPG_FRQCRB;
135 shift = 24;
136 width = 5;
137 } else {
138 struct div4_clk *c;
139
140 for (c = div4_clks; c->name; c++) {
141 if (!strcmp(name, c->name)) {
142 parent_name = c->parent;
143 table = div4_div_table;
144 reg = c->reg;
145 shift = c->shift;
146 width = 4;
147 break;
148 }
149 }
150 if (!c->name)
151 return ERR_PTR(-EINVAL);
152 }
153
154 if (!table) {
155 return clk_register_fixed_factor(NULL, name, parent_name, 0,
156 mult, div);
157 } else {
158 return clk_register_divider_table(NULL, name, parent_name, 0,
159 cpg->reg + reg, shift, width, 0,
160 table, &cpg->lock);
161 }
162}
163
164static void __init sh73a0_cpg_clocks_init(struct device_node *np)
165{
166 struct sh73a0_cpg *cpg;
167 struct clk **clks;
168 unsigned int i;
169 int num_clks;
170
171 num_clks = of_property_count_strings(np, "clock-output-names");
172 if (num_clks < 0) {
173 pr_err("%s: failed to count clocks\n", __func__);
174 return;
175 }
176
177 cpg = kzalloc(sizeof(*cpg), GFP_KERNEL);
178 clks = kcalloc(num_clks, sizeof(*clks), GFP_KERNEL);
179 if (cpg == NULL || clks == NULL) {
180 /* We're leaking memory on purpose, there's no point in cleaning
181 * up as the system won't boot anyway.
182 */
183 return;
184 }
185
186 spin_lock_init(&cpg->lock);
187
188 cpg->data.clks = clks;
189 cpg->data.clk_num = num_clks;
190
191 cpg->reg = of_iomap(np, 0);
192 if (WARN_ON(cpg->reg == NULL))
193 return;
194
195 /* Set SDHI clocks to a known state */
196 clk_writel(0x108, cpg->reg + CPG_SD0CKCR);
197 clk_writel(0x108, cpg->reg + CPG_SD1CKCR);
198 clk_writel(0x108, cpg->reg + CPG_SD2CKCR);
199
200 for (i = 0; i < num_clks; ++i) {
201 const char *name;
202 struct clk *clk;
203
204 of_property_read_string_index(np, "clock-output-names", i,
205 &name);
206
207 clk = sh73a0_cpg_register_clock(np, cpg, name);
208 if (IS_ERR(clk))
209 pr_err("%s: failed to register %s %s clock (%ld)\n",
210 __func__, np->name, name, PTR_ERR(clk));
211 else
212 cpg->data.clks[i] = clk;
213 }
214
215 of_clk_add_provider(np, of_clk_src_onecell_get, &cpg->data);
216}
217CLK_OF_DECLARE(sh73a0_cpg_clks, "renesas,sh73a0-cpg-clocks",
218 sh73a0_cpg_clocks_init);
diff --git a/drivers/cpuidle/Kconfig.arm b/drivers/cpuidle/Kconfig.arm
index 8c16ab20fb15..8e07c9419153 100644
--- a/drivers/cpuidle/Kconfig.arm
+++ b/drivers/cpuidle/Kconfig.arm
@@ -55,6 +55,7 @@ config ARM_AT91_CPUIDLE
55config ARM_EXYNOS_CPUIDLE 55config ARM_EXYNOS_CPUIDLE
56 bool "Cpu Idle Driver for the Exynos processors" 56 bool "Cpu Idle Driver for the Exynos processors"
57 depends on ARCH_EXYNOS 57 depends on ARCH_EXYNOS
58 select ARCH_NEEDS_CPU_IDLE_COUPLED if SMP
58 help 59 help
59 Select this to enable cpuidle for Exynos processors 60 Select this to enable cpuidle for Exynos processors
60 61
diff --git a/drivers/cpuidle/cpuidle-exynos.c b/drivers/cpuidle/cpuidle-exynos.c
index 4003a3160865..26f5f29fdb03 100644
--- a/drivers/cpuidle/cpuidle-exynos.c
+++ b/drivers/cpuidle/cpuidle-exynos.c
@@ -1,8 +1,11 @@
1/* linux/arch/arm/mach-exynos/cpuidle.c 1/*
2 * 2 * Copyright (c) 2011-2014 Samsung Electronics Co., Ltd.
3 * Copyright (c) 2011 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com 3 * http://www.samsung.com
5 * 4 *
5 * Coupled cpuidle support based on the work of:
6 * Colin Cross <ccross@android.com>
7 * Daniel Lezcano <daniel.lezcano@linaro.org>
8 *
6 * This program is free software; you can redistribute it and/or modify 9 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as 10 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation. 11 * published by the Free Software Foundation.
@@ -13,13 +16,49 @@
13#include <linux/export.h> 16#include <linux/export.h>
14#include <linux/module.h> 17#include <linux/module.h>
15#include <linux/platform_device.h> 18#include <linux/platform_device.h>
19#include <linux/of.h>
20#include <linux/platform_data/cpuidle-exynos.h>
16 21
17#include <asm/proc-fns.h> 22#include <asm/proc-fns.h>
18#include <asm/suspend.h> 23#include <asm/suspend.h>
19#include <asm/cpuidle.h> 24#include <asm/cpuidle.h>
20 25
26static atomic_t exynos_idle_barrier;
27
28static struct cpuidle_exynos_data *exynos_cpuidle_pdata;
21static void (*exynos_enter_aftr)(void); 29static void (*exynos_enter_aftr)(void);
22 30
31static int exynos_enter_coupled_lowpower(struct cpuidle_device *dev,
32 struct cpuidle_driver *drv,
33 int index)
34{
35 int ret;
36
37 exynos_cpuidle_pdata->pre_enter_aftr();
38
39 /*
40 * Waiting all cpus to reach this point at the same moment
41 */
42 cpuidle_coupled_parallel_barrier(dev, &exynos_idle_barrier);
43
44 /*
45 * Both cpus will reach this point at the same time
46 */
47 ret = dev->cpu ? exynos_cpuidle_pdata->cpu1_powerdown()
48 : exynos_cpuidle_pdata->cpu0_enter_aftr();
49 if (ret)
50 index = ret;
51
52 /*
53 * Waiting all cpus to finish the power sequence before going further
54 */
55 cpuidle_coupled_parallel_barrier(dev, &exynos_idle_barrier);
56
57 exynos_cpuidle_pdata->post_enter_aftr();
58
59 return index;
60}
61
23static int exynos_enter_lowpower(struct cpuidle_device *dev, 62static int exynos_enter_lowpower(struct cpuidle_device *dev,
24 struct cpuidle_driver *drv, 63 struct cpuidle_driver *drv,
25 int index) 64 int index)
@@ -55,13 +94,40 @@ static struct cpuidle_driver exynos_idle_driver = {
55 .safe_state_index = 0, 94 .safe_state_index = 0,
56}; 95};
57 96
97static struct cpuidle_driver exynos_coupled_idle_driver = {
98 .name = "exynos_coupled_idle",
99 .owner = THIS_MODULE,
100 .states = {
101 [0] = ARM_CPUIDLE_WFI_STATE,
102 [1] = {
103 .enter = exynos_enter_coupled_lowpower,
104 .exit_latency = 5000,
105 .target_residency = 10000,
106 .flags = CPUIDLE_FLAG_COUPLED |
107 CPUIDLE_FLAG_TIMER_STOP,
108 .name = "C1",
109 .desc = "ARM power down",
110 },
111 },
112 .state_count = 2,
113 .safe_state_index = 0,
114};
115
58static int exynos_cpuidle_probe(struct platform_device *pdev) 116static int exynos_cpuidle_probe(struct platform_device *pdev)
59{ 117{
60 int ret; 118 int ret;
61 119
62 exynos_enter_aftr = (void *)(pdev->dev.platform_data); 120 if (of_machine_is_compatible("samsung,exynos4210")) {
121 exynos_cpuidle_pdata = pdev->dev.platform_data;
122
123 ret = cpuidle_register(&exynos_coupled_idle_driver,
124 cpu_possible_mask);
125 } else {
126 exynos_enter_aftr = (void *)(pdev->dev.platform_data);
127
128 ret = cpuidle_register(&exynos_idle_driver, NULL);
129 }
63 130
64 ret = cpuidle_register(&exynos_idle_driver, NULL);
65 if (ret) { 131 if (ret) {
66 dev_err(&pdev->dev, "failed to register cpuidle driver\n"); 132 dev_err(&pdev->dev, "failed to register cpuidle driver\n");
67 return ret; 133 return ret;
diff --git a/drivers/of/platform.c b/drivers/of/platform.c
index b0d50d70a8a1..b189733a1539 100644
--- a/drivers/of/platform.c
+++ b/drivers/of/platform.c
@@ -526,6 +526,7 @@ static int of_platform_device_destroy(struct device *dev, void *data)
526 amba_device_unregister(to_amba_device(dev)); 526 amba_device_unregister(to_amba_device(dev));
527#endif 527#endif
528 528
529 of_dma_deconfigure(dev);
529 of_node_clear_flag(dev->of_node, OF_POPULATED); 530 of_node_clear_flag(dev->of_node, OF_POPULATED);
530 of_node_clear_flag(dev->of_node, OF_POPULATED_BUS); 531 of_node_clear_flag(dev->of_node, OF_POPULATED_BUS);
531 return 0; 532 return 0;
diff --git a/drivers/pcmcia/Kconfig b/drivers/pcmcia/Kconfig
index 8843a678f200..3bb49252a098 100644
--- a/drivers/pcmcia/Kconfig
+++ b/drivers/pcmcia/Kconfig
@@ -279,6 +279,7 @@ config BFIN_CFPCMCIA
279config AT91_CF 279config AT91_CF
280 tristate "AT91 CompactFlash Controller" 280 tristate "AT91 CompactFlash Controller"
281 depends on PCMCIA && ARCH_AT91 281 depends on PCMCIA && ARCH_AT91
282 depends on !ARCH_MULTIPLATFORM
282 help 283 help
283 Say Y here to support the CompactFlash controller on AT91 chips. 284 Say Y here to support the CompactFlash controller on AT91 chips.
284 Or choose M to compile the driver as a module named "at91_cf". 285 Or choose M to compile the driver as a module named "at91_cf".
diff --git a/drivers/soc/ti/Makefile b/drivers/soc/ti/Makefile
index 6bed611e1934..135bdad7a6de 100644
--- a/drivers/soc/ti/Makefile
+++ b/drivers/soc/ti/Makefile
@@ -1,5 +1,6 @@
1# 1#
2# TI Keystone SOC drivers 2# TI Keystone SOC drivers
3# 3#
4obj-$(CONFIG_KEYSTONE_NAVIGATOR_QMSS) += knav_qmss_queue.o knav_qmss_acc.o 4obj-$(CONFIG_KEYSTONE_NAVIGATOR_QMSS) += knav_qmss.o
5knav_qmss-y := knav_qmss_queue.o knav_qmss_acc.o
5obj-$(CONFIG_KEYSTONE_NAVIGATOR_DMA) += knav_dma.o 6obj-$(CONFIG_KEYSTONE_NAVIGATOR_DMA) += knav_dma.o
diff --git a/drivers/soc/ti/knav_qmss_acc.c b/drivers/soc/ti/knav_qmss_acc.c
index 6fbfde6e748f..ef6f69db0bd0 100644
--- a/drivers/soc/ti/knav_qmss_acc.c
+++ b/drivers/soc/ti/knav_qmss_acc.c
@@ -209,7 +209,7 @@ static irqreturn_t knav_acc_int_handler(int irq, void *_instdata)
209 return IRQ_HANDLED; 209 return IRQ_HANDLED;
210} 210}
211 211
212int knav_range_setup_acc_irq(struct knav_range_info *range, 212static int knav_range_setup_acc_irq(struct knav_range_info *range,
213 int queue, bool enabled) 213 int queue, bool enabled)
214{ 214{
215 struct knav_device *kdev = range->kdev; 215 struct knav_device *kdev = range->kdev;
diff --git a/drivers/soc/ti/knav_qmss_queue.c b/drivers/soc/ti/knav_qmss_queue.c
index 8e6a95d91d33..6d8646db52cc 100644
--- a/drivers/soc/ti/knav_qmss_queue.c
+++ b/drivers/soc/ti/knav_qmss_queue.c
@@ -626,6 +626,7 @@ int knav_queue_push(void *qhandle, dma_addr_t dma,
626 atomic_inc(&qh->stats.pushes); 626 atomic_inc(&qh->stats.pushes);
627 return 0; 627 return 0;
628} 628}
629EXPORT_SYMBOL_GPL(knav_queue_push);
629 630
630/** 631/**
631 * knav_queue_pop() - pop data (or descriptor) from the head of a queue 632 * knav_queue_pop() - pop data (or descriptor) from the head of a queue
@@ -663,6 +664,7 @@ dma_addr_t knav_queue_pop(void *qhandle, unsigned *size)
663 atomic_inc(&qh->stats.pops); 664 atomic_inc(&qh->stats.pops);
664 return dma; 665 return dma;
665} 666}
667EXPORT_SYMBOL_GPL(knav_queue_pop);
666 668
667/* carve out descriptors and push into queue */ 669/* carve out descriptors and push into queue */
668static void kdesc_fill_pool(struct knav_pool *pool) 670static void kdesc_fill_pool(struct knav_pool *pool)
@@ -717,12 +719,14 @@ dma_addr_t knav_pool_desc_virt_to_dma(void *ph, void *virt)
717 struct knav_pool *pool = ph; 719 struct knav_pool *pool = ph;
718 return pool->region->dma_start + (virt - pool->region->virt_start); 720 return pool->region->dma_start + (virt - pool->region->virt_start);
719} 721}
722EXPORT_SYMBOL_GPL(knav_pool_desc_virt_to_dma);
720 723
721void *knav_pool_desc_dma_to_virt(void *ph, dma_addr_t dma) 724void *knav_pool_desc_dma_to_virt(void *ph, dma_addr_t dma)
722{ 725{
723 struct knav_pool *pool = ph; 726 struct knav_pool *pool = ph;
724 return pool->region->virt_start + (dma - pool->region->dma_start); 727 return pool->region->virt_start + (dma - pool->region->dma_start);
725} 728}
729EXPORT_SYMBOL_GPL(knav_pool_desc_dma_to_virt);
726 730
727/** 731/**
728 * knav_pool_create() - Create a pool of descriptors 732 * knav_pool_create() - Create a pool of descriptors
@@ -878,6 +882,7 @@ void *knav_pool_desc_get(void *ph)
878 data = knav_pool_desc_dma_to_virt(pool, dma); 882 data = knav_pool_desc_dma_to_virt(pool, dma);
879 return data; 883 return data;
880} 884}
885EXPORT_SYMBOL_GPL(knav_pool_desc_get);
881 886
882/** 887/**
883 * knav_pool_desc_put() - return a descriptor to the pool 888 * knav_pool_desc_put() - return a descriptor to the pool
@@ -890,6 +895,7 @@ void knav_pool_desc_put(void *ph, void *desc)
890 dma = knav_pool_desc_virt_to_dma(pool, desc); 895 dma = knav_pool_desc_virt_to_dma(pool, desc);
891 knav_queue_push(pool->queue, dma, pool->region->desc_size, 0); 896 knav_queue_push(pool->queue, dma, pool->region->desc_size, 0);
892} 897}
898EXPORT_SYMBOL_GPL(knav_pool_desc_put);
893 899
894/** 900/**
895 * knav_pool_desc_map() - Map descriptor for DMA transfer 901 * knav_pool_desc_map() - Map descriptor for DMA transfer
@@ -916,6 +922,7 @@ int knav_pool_desc_map(void *ph, void *desc, unsigned size,
916 922
917 return 0; 923 return 0;
918} 924}
925EXPORT_SYMBOL_GPL(knav_pool_desc_map);
919 926
920/** 927/**
921 * knav_pool_desc_unmap() - Unmap descriptor after DMA transfer 928 * knav_pool_desc_unmap() - Unmap descriptor after DMA transfer
@@ -938,6 +945,7 @@ void *knav_pool_desc_unmap(void *ph, dma_addr_t dma, unsigned dma_sz)
938 prefetch(desc); 945 prefetch(desc);
939 return desc; 946 return desc;
940} 947}
948EXPORT_SYMBOL_GPL(knav_pool_desc_unmap);
941 949
942/** 950/**
943 * knav_pool_count() - Get the number of descriptors in pool. 951 * knav_pool_count() - Get the number of descriptors in pool.
@@ -949,6 +957,7 @@ int knav_pool_count(void *ph)
949 struct knav_pool *pool = ph; 957 struct knav_pool *pool = ph;
950 return knav_queue_get_count(pool->queue); 958 return knav_queue_get_count(pool->queue);
951} 959}
960EXPORT_SYMBOL_GPL(knav_pool_count);
952 961
953static void knav_queue_setup_region(struct knav_device *kdev, 962static void knav_queue_setup_region(struct knav_device *kdev,
954 struct knav_region *region) 963 struct knav_region *region)
diff --git a/drivers/usb/gadget/udc/Kconfig b/drivers/usb/gadget/udc/Kconfig
index b8e213eb36cc..366e551aeff0 100644
--- a/drivers/usb/gadget/udc/Kconfig
+++ b/drivers/usb/gadget/udc/Kconfig
@@ -32,6 +32,7 @@ menu "USB Peripheral Controller"
32config USB_AT91 32config USB_AT91
33 tristate "Atmel AT91 USB Device Port" 33 tristate "Atmel AT91 USB Device Port"
34 depends on ARCH_AT91 34 depends on ARCH_AT91
35 depends on OF || COMPILE_TEST
35 help 36 help
36 Many Atmel AT91 processors (such as the AT91RM2000) have a 37 Many Atmel AT91 processors (such as the AT91RM2000) have a
37 full speed USB Device Port with support for five configurable 38 full speed USB Device Port with support for five configurable
diff --git a/drivers/usb/gadget/udc/at91_udc.c b/drivers/usb/gadget/udc/at91_udc.c
index c0ec5f71f16f..2fbedca3c2b4 100644
--- a/drivers/usb/gadget/udc/at91_udc.c
+++ b/drivers/usb/gadget/udc/at91_udc.c
@@ -31,16 +31,9 @@
31#include <linux/of.h> 31#include <linux/of.h>
32#include <linux/of_gpio.h> 32#include <linux/of_gpio.h>
33#include <linux/platform_data/atmel.h> 33#include <linux/platform_data/atmel.h>
34 34#include <linux/regmap.h>
35#include <asm/byteorder.h> 35#include <linux/mfd/syscon.h>
36#include <mach/hardware.h> 36#include <linux/mfd/syscon/atmel-matrix.h>
37#include <asm/io.h>
38#include <asm/irq.h>
39#include <asm/gpio.h>
40
41#include <mach/cpu.h>
42#include <mach/at91sam9261_matrix.h>
43#include <mach/at91_matrix.h>
44 37
45#include "at91_udc.h" 38#include "at91_udc.h"
46 39
@@ -66,7 +59,15 @@
66#define DRIVER_VERSION "3 May 2006" 59#define DRIVER_VERSION "3 May 2006"
67 60
68static const char driver_name [] = "at91_udc"; 61static const char driver_name [] = "at91_udc";
69static const char ep0name[] = "ep0"; 62static const char * const ep_names[] = {
63 "ep0",
64 "ep1",
65 "ep2",
66 "ep3-int",
67 "ep4",
68 "ep5",
69};
70#define ep0name ep_names[0]
70 71
71#define VBUS_POLL_TIMEOUT msecs_to_jiffies(1000) 72#define VBUS_POLL_TIMEOUT msecs_to_jiffies(1000)
72 73
@@ -895,8 +896,6 @@ static void clk_on(struct at91_udc *udc)
895 return; 896 return;
896 udc->clocked = 1; 897 udc->clocked = 1;
897 898
898 if (IS_ENABLED(CONFIG_COMMON_CLK))
899 clk_enable(udc->uclk);
900 clk_enable(udc->iclk); 899 clk_enable(udc->iclk);
901 clk_enable(udc->fclk); 900 clk_enable(udc->fclk);
902} 901}
@@ -909,8 +908,6 @@ static void clk_off(struct at91_udc *udc)
909 udc->gadget.speed = USB_SPEED_UNKNOWN; 908 udc->gadget.speed = USB_SPEED_UNKNOWN;
910 clk_disable(udc->fclk); 909 clk_disable(udc->fclk);
911 clk_disable(udc->iclk); 910 clk_disable(udc->iclk);
912 if (IS_ENABLED(CONFIG_COMMON_CLK))
913 clk_disable(udc->uclk);
914} 911}
915 912
916/* 913/*
@@ -919,8 +916,6 @@ static void clk_off(struct at91_udc *udc)
919 */ 916 */
920static void pullup(struct at91_udc *udc, int is_on) 917static void pullup(struct at91_udc *udc, int is_on)
921{ 918{
922 int active = !udc->board.pullup_active_low;
923
924 if (!udc->enabled || !udc->vbus) 919 if (!udc->enabled || !udc->vbus)
925 is_on = 0; 920 is_on = 0;
926 DBG("%sactive\n", is_on ? "" : "in"); 921 DBG("%sactive\n", is_on ? "" : "in");
@@ -929,40 +924,15 @@ static void pullup(struct at91_udc *udc, int is_on)
929 clk_on(udc); 924 clk_on(udc);
930 at91_udp_write(udc, AT91_UDP_ICR, AT91_UDP_RXRSM); 925 at91_udp_write(udc, AT91_UDP_ICR, AT91_UDP_RXRSM);
931 at91_udp_write(udc, AT91_UDP_TXVC, 0); 926 at91_udp_write(udc, AT91_UDP_TXVC, 0);
932 if (cpu_is_at91rm9200())
933 gpio_set_value(udc->board.pullup_pin, active);
934 else if (cpu_is_at91sam9260() || cpu_is_at91sam9263() || cpu_is_at91sam9g20()) {
935 u32 txvc = at91_udp_read(udc, AT91_UDP_TXVC);
936
937 txvc |= AT91_UDP_TXVC_PUON;
938 at91_udp_write(udc, AT91_UDP_TXVC, txvc);
939 } else if (cpu_is_at91sam9261() || cpu_is_at91sam9g10()) {
940 u32 usbpucr;
941
942 usbpucr = at91_matrix_read(AT91_MATRIX_USBPUCR);
943 usbpucr |= AT91_MATRIX_USBPUCR_PUON;
944 at91_matrix_write(AT91_MATRIX_USBPUCR, usbpucr);
945 }
946 } else { 927 } else {
947 stop_activity(udc); 928 stop_activity(udc);
948 at91_udp_write(udc, AT91_UDP_IDR, AT91_UDP_RXRSM); 929 at91_udp_write(udc, AT91_UDP_IDR, AT91_UDP_RXRSM);
949 at91_udp_write(udc, AT91_UDP_TXVC, AT91_UDP_TXVC_TXVDIS); 930 at91_udp_write(udc, AT91_UDP_TXVC, AT91_UDP_TXVC_TXVDIS);
950 if (cpu_is_at91rm9200())
951 gpio_set_value(udc->board.pullup_pin, !active);
952 else if (cpu_is_at91sam9260() || cpu_is_at91sam9263() || cpu_is_at91sam9g20()) {
953 u32 txvc = at91_udp_read(udc, AT91_UDP_TXVC);
954
955 txvc &= ~AT91_UDP_TXVC_PUON;
956 at91_udp_write(udc, AT91_UDP_TXVC, txvc);
957 } else if (cpu_is_at91sam9261() || cpu_is_at91sam9g10()) {
958 u32 usbpucr;
959
960 usbpucr = at91_matrix_read(AT91_MATRIX_USBPUCR);
961 usbpucr &= ~AT91_MATRIX_USBPUCR_PUON;
962 at91_matrix_write(AT91_MATRIX_USBPUCR, usbpucr);
963 }
964 clk_off(udc); 931 clk_off(udc);
965 } 932 }
933
934 if (udc->caps && udc->caps->pullup)
935 udc->caps->pullup(udc, is_on);
966} 936}
967 937
968/* vbus is here! turn everything on that's ready */ 938/* vbus is here! turn everything on that's ready */
@@ -1535,74 +1505,6 @@ static irqreturn_t at91_udc_irq (int irq, void *_udc)
1535 1505
1536/*-------------------------------------------------------------------------*/ 1506/*-------------------------------------------------------------------------*/
1537 1507
1538static struct at91_udc controller = {
1539 .gadget = {
1540 .ops = &at91_udc_ops,
1541 .ep0 = &controller.ep[0].ep,
1542 .name = driver_name,
1543 },
1544 .ep[0] = {
1545 .ep = {
1546 .name = ep0name,
1547 .ops = &at91_ep_ops,
1548 },
1549 .udc = &controller,
1550 .maxpacket = 8,
1551 .int_mask = 1 << 0,
1552 },
1553 .ep[1] = {
1554 .ep = {
1555 .name = "ep1",
1556 .ops = &at91_ep_ops,
1557 },
1558 .udc = &controller,
1559 .is_pingpong = 1,
1560 .maxpacket = 64,
1561 .int_mask = 1 << 1,
1562 },
1563 .ep[2] = {
1564 .ep = {
1565 .name = "ep2",
1566 .ops = &at91_ep_ops,
1567 },
1568 .udc = &controller,
1569 .is_pingpong = 1,
1570 .maxpacket = 64,
1571 .int_mask = 1 << 2,
1572 },
1573 .ep[3] = {
1574 .ep = {
1575 /* could actually do bulk too */
1576 .name = "ep3-int",
1577 .ops = &at91_ep_ops,
1578 },
1579 .udc = &controller,
1580 .maxpacket = 8,
1581 .int_mask = 1 << 3,
1582 },
1583 .ep[4] = {
1584 .ep = {
1585 .name = "ep4",
1586 .ops = &at91_ep_ops,
1587 },
1588 .udc = &controller,
1589 .is_pingpong = 1,
1590 .maxpacket = 256,
1591 .int_mask = 1 << 4,
1592 },
1593 .ep[5] = {
1594 .ep = {
1595 .name = "ep5",
1596 .ops = &at91_ep_ops,
1597 },
1598 .udc = &controller,
1599 .is_pingpong = 1,
1600 .maxpacket = 256,
1601 .int_mask = 1 << 5,
1602 },
1603 /* ep6 and ep7 are also reserved (custom silicon might use them) */
1604};
1605
1606static void at91_vbus_update(struct at91_udc *udc, unsigned value) 1508static void at91_vbus_update(struct at91_udc *udc, unsigned value)
1607{ 1509{
1608 value ^= udc->board.vbus_active_low; 1510 value ^= udc->board.vbus_active_low;
@@ -1687,12 +1589,202 @@ static void at91udc_shutdown(struct platform_device *dev)
1687 spin_unlock_irqrestore(&udc->lock, flags); 1589 spin_unlock_irqrestore(&udc->lock, flags);
1688} 1590}
1689 1591
1690static void at91udc_of_init(struct at91_udc *udc, 1592static int at91rm9200_udc_init(struct at91_udc *udc)
1691 struct device_node *np) 1593{
1594 struct at91_ep *ep;
1595 int ret;
1596 int i;
1597
1598 for (i = 0; i < NUM_ENDPOINTS; i++) {
1599 ep = &udc->ep[i];
1600
1601 switch (i) {
1602 case 0:
1603 case 3:
1604 ep->maxpacket = 8;
1605 break;
1606 case 1 ... 2:
1607 ep->maxpacket = 64;
1608 break;
1609 case 4 ... 5:
1610 ep->maxpacket = 256;
1611 break;
1612 }
1613 }
1614
1615 if (!gpio_is_valid(udc->board.pullup_pin)) {
1616 DBG("no D+ pullup?\n");
1617 return -ENODEV;
1618 }
1619
1620 ret = devm_gpio_request(&udc->pdev->dev, udc->board.pullup_pin,
1621 "udc_pullup");
1622 if (ret) {
1623 DBG("D+ pullup is busy\n");
1624 return ret;
1625 }
1626
1627 gpio_direction_output(udc->board.pullup_pin,
1628 udc->board.pullup_active_low);
1629
1630 return 0;
1631}
1632
1633static void at91rm9200_udc_pullup(struct at91_udc *udc, int is_on)
1634{
1635 int active = !udc->board.pullup_active_low;
1636
1637 if (is_on)
1638 gpio_set_value(udc->board.pullup_pin, active);
1639 else
1640 gpio_set_value(udc->board.pullup_pin, !active);
1641}
1642
1643static const struct at91_udc_caps at91rm9200_udc_caps = {
1644 .init = at91rm9200_udc_init,
1645 .pullup = at91rm9200_udc_pullup,
1646};
1647
1648static int at91sam9260_udc_init(struct at91_udc *udc)
1649{
1650 struct at91_ep *ep;
1651 int i;
1652
1653 for (i = 0; i < NUM_ENDPOINTS; i++) {
1654 ep = &udc->ep[i];
1655
1656 switch (i) {
1657 case 0 ... 3:
1658 ep->maxpacket = 64;
1659 break;
1660 case 4 ... 5:
1661 ep->maxpacket = 512;
1662 break;
1663 }
1664 }
1665
1666 return 0;
1667}
1668
1669static void at91sam9260_udc_pullup(struct at91_udc *udc, int is_on)
1670{
1671 u32 txvc = at91_udp_read(udc, AT91_UDP_TXVC);
1672
1673 if (is_on)
1674 txvc |= AT91_UDP_TXVC_PUON;
1675 else
1676 txvc &= ~AT91_UDP_TXVC_PUON;
1677
1678 at91_udp_write(udc, AT91_UDP_TXVC, txvc);
1679}
1680
1681static const struct at91_udc_caps at91sam9260_udc_caps = {
1682 .init = at91sam9260_udc_init,
1683 .pullup = at91sam9260_udc_pullup,
1684};
1685
1686static int at91sam9261_udc_init(struct at91_udc *udc)
1687{
1688 struct at91_ep *ep;
1689 int i;
1690
1691 for (i = 0; i < NUM_ENDPOINTS; i++) {
1692 ep = &udc->ep[i];
1693
1694 switch (i) {
1695 case 0:
1696 ep->maxpacket = 8;
1697 break;
1698 case 1 ... 3:
1699 ep->maxpacket = 64;
1700 break;
1701 case 4 ... 5:
1702 ep->maxpacket = 256;
1703 break;
1704 }
1705 }
1706
1707 udc->matrix = syscon_regmap_lookup_by_phandle(udc->pdev->dev.of_node,
1708 "atmel,matrix");
1709 if (IS_ERR(udc->matrix))
1710 return PTR_ERR(udc->matrix);
1711
1712 return 0;
1713}
1714
1715static void at91sam9261_udc_pullup(struct at91_udc *udc, int is_on)
1716{
1717 u32 usbpucr = 0;
1718
1719 if (is_on)
1720 usbpucr = AT91_MATRIX_USBPUCR_PUON;
1721
1722 regmap_update_bits(udc->matrix, AT91SAM9261_MATRIX_USBPUCR,
1723 AT91_MATRIX_USBPUCR_PUON, usbpucr);
1724}
1725
1726static const struct at91_udc_caps at91sam9261_udc_caps = {
1727 .init = at91sam9261_udc_init,
1728 .pullup = at91sam9261_udc_pullup,
1729};
1730
1731static int at91sam9263_udc_init(struct at91_udc *udc)
1732{
1733 struct at91_ep *ep;
1734 int i;
1735
1736 for (i = 0; i < NUM_ENDPOINTS; i++) {
1737 ep = &udc->ep[i];
1738
1739 switch (i) {
1740 case 0:
1741 case 1:
1742 case 2:
1743 case 3:
1744 ep->maxpacket = 64;
1745 break;
1746 case 4:
1747 case 5:
1748 ep->maxpacket = 256;
1749 break;
1750 }
1751 }
1752
1753 return 0;
1754}
1755
1756static const struct at91_udc_caps at91sam9263_udc_caps = {
1757 .init = at91sam9263_udc_init,
1758 .pullup = at91sam9260_udc_pullup,
1759};
1760
1761static const struct of_device_id at91_udc_dt_ids[] = {
1762 {
1763 .compatible = "atmel,at91rm9200-udc",
1764 .data = &at91rm9200_udc_caps,
1765 },
1766 {
1767 .compatible = "atmel,at91sam9260-udc",
1768 .data = &at91sam9260_udc_caps,
1769 },
1770 {
1771 .compatible = "atmel,at91sam9261-udc",
1772 .data = &at91sam9261_udc_caps,
1773 },
1774 {
1775 .compatible = "atmel,at91sam9263-udc",
1776 .data = &at91sam9263_udc_caps,
1777 },
1778 { /* sentinel */ }
1779};
1780MODULE_DEVICE_TABLE(of, at91_udc_dt_ids);
1781
1782static void at91udc_of_init(struct at91_udc *udc, struct device_node *np)
1692{ 1783{
1693 struct at91_udc_data *board = &udc->board; 1784 struct at91_udc_data *board = &udc->board;
1694 u32 val; 1785 const struct of_device_id *match;
1695 enum of_gpio_flags flags; 1786 enum of_gpio_flags flags;
1787 u32 val;
1696 1788
1697 if (of_property_read_u32(np, "atmel,vbus-polled", &val) == 0) 1789 if (of_property_read_u32(np, "atmel,vbus-polled", &val) == 0)
1698 board->vbus_polled = 1; 1790 board->vbus_polled = 1;
@@ -1705,6 +1797,10 @@ static void at91udc_of_init(struct at91_udc *udc,
1705 &flags); 1797 &flags);
1706 1798
1707 board->pullup_active_low = (flags & OF_GPIO_ACTIVE_LOW) ? 1 : 0; 1799 board->pullup_active_low = (flags & OF_GPIO_ACTIVE_LOW) ? 1 : 0;
1800
1801 match = of_match_node(at91_udc_dt_ids, np);
1802 if (match)
1803 udc->caps = match->data;
1708} 1804}
1709 1805
1710static int at91udc_probe(struct platform_device *pdev) 1806static int at91udc_probe(struct platform_device *pdev)
@@ -1713,97 +1809,67 @@ static int at91udc_probe(struct platform_device *pdev)
1713 struct at91_udc *udc; 1809 struct at91_udc *udc;
1714 int retval; 1810 int retval;
1715 struct resource *res; 1811 struct resource *res;
1812 struct at91_ep *ep;
1813 int i;
1716 1814
1717 if (!dev_get_platdata(dev) && !pdev->dev.of_node) { 1815 udc = devm_kzalloc(dev, sizeof(*udc), GFP_KERNEL);
1718 /* small (so we copy it) but critical! */ 1816 if (!udc)
1719 DBG("missing platform_data\n"); 1817 return -ENOMEM;
1720 return -ENODEV;
1721 }
1722
1723 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1724 if (!res)
1725 return -ENXIO;
1726
1727 if (!request_mem_region(res->start, resource_size(res), driver_name)) {
1728 DBG("someone's using UDC memory\n");
1729 return -EBUSY;
1730 }
1731 1818
1732 /* init software state */ 1819 /* init software state */
1733 udc = &controller;
1734 udc->gadget.dev.parent = dev; 1820 udc->gadget.dev.parent = dev;
1735 if (IS_ENABLED(CONFIG_OF) && pdev->dev.of_node) 1821 at91udc_of_init(udc, pdev->dev.of_node);
1736 at91udc_of_init(udc, pdev->dev.of_node);
1737 else
1738 memcpy(&udc->board, dev_get_platdata(dev),
1739 sizeof(struct at91_udc_data));
1740 udc->pdev = pdev; 1822 udc->pdev = pdev;
1741 udc->enabled = 0; 1823 udc->enabled = 0;
1742 spin_lock_init(&udc->lock); 1824 spin_lock_init(&udc->lock);
1743 1825
1744 /* rm9200 needs manual D+ pullup; off by default */ 1826 udc->gadget.ops = &at91_udc_ops;
1745 if (cpu_is_at91rm9200()) { 1827 udc->gadget.ep0 = &udc->ep[0].ep;
1746 if (!gpio_is_valid(udc->board.pullup_pin)) { 1828 udc->gadget.name = driver_name;
1747 DBG("no D+ pullup?\n"); 1829 udc->gadget.dev.init_name = "gadget";
1748 retval = -ENODEV;
1749 goto fail0;
1750 }
1751 retval = gpio_request(udc->board.pullup_pin, "udc_pullup");
1752 if (retval) {
1753 DBG("D+ pullup is busy\n");
1754 goto fail0;
1755 }
1756 gpio_direction_output(udc->board.pullup_pin,
1757 udc->board.pullup_active_low);
1758 }
1759 1830
1760 /* newer chips have more FIFO memory than rm9200 */ 1831 for (i = 0; i < NUM_ENDPOINTS; i++) {
1761 if (cpu_is_at91sam9260() || cpu_is_at91sam9g20()) { 1832 ep = &udc->ep[i];
1762 udc->ep[0].maxpacket = 64; 1833 ep->ep.name = ep_names[i];
1763 udc->ep[3].maxpacket = 64; 1834 ep->ep.ops = &at91_ep_ops;
1764 udc->ep[4].maxpacket = 512; 1835 ep->udc = udc;
1765 udc->ep[5].maxpacket = 512; 1836 ep->int_mask = BIT(i);
1766 } else if (cpu_is_at91sam9261() || cpu_is_at91sam9g10()) { 1837 if (i != 0 && i != 3)
1767 udc->ep[3].maxpacket = 64; 1838 ep->is_pingpong = 1;
1768 } else if (cpu_is_at91sam9263()) {
1769 udc->ep[0].maxpacket = 64;
1770 udc->ep[3].maxpacket = 64;
1771 } 1839 }
1772 1840
1773 udc->udp_baseaddr = ioremap(res->start, resource_size(res)); 1841 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1774 if (!udc->udp_baseaddr) { 1842 udc->udp_baseaddr = devm_ioremap_resource(dev, res);
1775 retval = -ENOMEM; 1843 if (IS_ERR(udc->udp_baseaddr))
1776 goto fail0a; 1844 return PTR_ERR(udc->udp_baseaddr);
1845
1846 if (udc->caps && udc->caps->init) {
1847 retval = udc->caps->init(udc);
1848 if (retval)
1849 return retval;
1777 } 1850 }
1778 1851
1779 udc_reinit(udc); 1852 udc_reinit(udc);
1780 1853
1781 /* get interface and function clocks */ 1854 /* get interface and function clocks */
1782 udc->iclk = clk_get(dev, "udc_clk"); 1855 udc->iclk = devm_clk_get(dev, "pclk");
1783 udc->fclk = clk_get(dev, "udpck"); 1856 if (IS_ERR(udc->iclk))
1784 if (IS_ENABLED(CONFIG_COMMON_CLK)) 1857 return PTR_ERR(udc->iclk);
1785 udc->uclk = clk_get(dev, "usb_clk"); 1858
1786 if (IS_ERR(udc->iclk) || IS_ERR(udc->fclk) || 1859 udc->fclk = devm_clk_get(dev, "hclk");
1787 (IS_ENABLED(CONFIG_COMMON_CLK) && IS_ERR(udc->uclk))) { 1860 if (IS_ERR(udc->fclk))
1788 DBG("clocks missing\n"); 1861 return PTR_ERR(udc->fclk);
1789 retval = -ENODEV;
1790 goto fail1;
1791 }
1792 1862
1793 /* don't do anything until we have both gadget driver and VBUS */ 1863 /* don't do anything until we have both gadget driver and VBUS */
1794 if (IS_ENABLED(CONFIG_COMMON_CLK)) { 1864 clk_set_rate(udc->fclk, 48000000);
1795 clk_set_rate(udc->uclk, 48000000);
1796 retval = clk_prepare(udc->uclk);
1797 if (retval)
1798 goto fail1;
1799 }
1800 retval = clk_prepare(udc->fclk); 1865 retval = clk_prepare(udc->fclk);
1801 if (retval) 1866 if (retval)
1802 goto fail1a; 1867 return retval;
1803 1868
1804 retval = clk_prepare_enable(udc->iclk); 1869 retval = clk_prepare_enable(udc->iclk);
1805 if (retval) 1870 if (retval)
1806 goto fail1b; 1871 goto err_unprepare_fclk;
1872
1807 at91_udp_write(udc, AT91_UDP_TXVC, AT91_UDP_TXVC_TXVDIS); 1873 at91_udp_write(udc, AT91_UDP_TXVC, AT91_UDP_TXVC_TXVDIS);
1808 at91_udp_write(udc, AT91_UDP_IDR, 0xffffffff); 1874 at91_udp_write(udc, AT91_UDP_IDR, 0xffffffff);
1809 /* Clear all pending interrupts - UDP may be used by bootloader. */ 1875 /* Clear all pending interrupts - UDP may be used by bootloader. */
@@ -1812,18 +1878,21 @@ static int at91udc_probe(struct platform_device *pdev)
1812 1878
1813 /* request UDC and maybe VBUS irqs */ 1879 /* request UDC and maybe VBUS irqs */
1814 udc->udp_irq = platform_get_irq(pdev, 0); 1880 udc->udp_irq = platform_get_irq(pdev, 0);
1815 retval = request_irq(udc->udp_irq, at91_udc_irq, 1881 retval = devm_request_irq(dev, udc->udp_irq, at91_udc_irq, 0,
1816 0, driver_name, udc); 1882 driver_name, udc);
1817 if (retval < 0) { 1883 if (retval) {
1818 DBG("request irq %d failed\n", udc->udp_irq); 1884 DBG("request irq %d failed\n", udc->udp_irq);
1819 goto fail1c; 1885 goto err_unprepare_iclk;
1820 } 1886 }
1887
1821 if (gpio_is_valid(udc->board.vbus_pin)) { 1888 if (gpio_is_valid(udc->board.vbus_pin)) {
1822 retval = gpio_request(udc->board.vbus_pin, "udc_vbus"); 1889 retval = devm_gpio_request(dev, udc->board.vbus_pin,
1823 if (retval < 0) { 1890 "udc_vbus");
1891 if (retval) {
1824 DBG("request vbus pin failed\n"); 1892 DBG("request vbus pin failed\n");
1825 goto fail2; 1893 goto err_unprepare_iclk;
1826 } 1894 }
1895
1827 gpio_direction_input(udc->board.vbus_pin); 1896 gpio_direction_input(udc->board.vbus_pin);
1828 1897
1829 /* 1898 /*
@@ -1840,12 +1909,13 @@ static int at91udc_probe(struct platform_device *pdev)
1840 mod_timer(&udc->vbus_timer, 1909 mod_timer(&udc->vbus_timer,
1841 jiffies + VBUS_POLL_TIMEOUT); 1910 jiffies + VBUS_POLL_TIMEOUT);
1842 } else { 1911 } else {
1843 if (request_irq(gpio_to_irq(udc->board.vbus_pin), 1912 retval = devm_request_irq(dev,
1844 at91_vbus_irq, 0, driver_name, udc)) { 1913 gpio_to_irq(udc->board.vbus_pin),
1914 at91_vbus_irq, 0, driver_name, udc);
1915 if (retval) {
1845 DBG("request vbus irq %d failed\n", 1916 DBG("request vbus irq %d failed\n",
1846 udc->board.vbus_pin); 1917 udc->board.vbus_pin);
1847 retval = -EBUSY; 1918 goto err_unprepare_iclk;
1848 goto fail3;
1849 } 1919 }
1850 } 1920 }
1851 } else { 1921 } else {
@@ -1854,49 +1924,27 @@ static int at91udc_probe(struct platform_device *pdev)
1854 } 1924 }
1855 retval = usb_add_gadget_udc(dev, &udc->gadget); 1925 retval = usb_add_gadget_udc(dev, &udc->gadget);
1856 if (retval) 1926 if (retval)
1857 goto fail4; 1927 goto err_unprepare_iclk;
1858 dev_set_drvdata(dev, udc); 1928 dev_set_drvdata(dev, udc);
1859 device_init_wakeup(dev, 1); 1929 device_init_wakeup(dev, 1);
1860 create_debug_file(udc); 1930 create_debug_file(udc);
1861 1931
1862 INFO("%s version %s\n", driver_name, DRIVER_VERSION); 1932 INFO("%s version %s\n", driver_name, DRIVER_VERSION);
1863 return 0; 1933 return 0;
1864fail4: 1934
1865 if (gpio_is_valid(udc->board.vbus_pin) && !udc->board.vbus_polled) 1935err_unprepare_iclk:
1866 free_irq(gpio_to_irq(udc->board.vbus_pin), udc);
1867fail3:
1868 if (gpio_is_valid(udc->board.vbus_pin))
1869 gpio_free(udc->board.vbus_pin);
1870fail2:
1871 free_irq(udc->udp_irq, udc);
1872fail1c:
1873 clk_unprepare(udc->iclk); 1936 clk_unprepare(udc->iclk);
1874fail1b: 1937err_unprepare_fclk:
1875 clk_unprepare(udc->fclk); 1938 clk_unprepare(udc->fclk);
1876fail1a: 1939
1877 if (IS_ENABLED(CONFIG_COMMON_CLK))
1878 clk_unprepare(udc->uclk);
1879fail1:
1880 if (IS_ENABLED(CONFIG_COMMON_CLK) && !IS_ERR(udc->uclk))
1881 clk_put(udc->uclk);
1882 if (!IS_ERR(udc->fclk))
1883 clk_put(udc->fclk);
1884 if (!IS_ERR(udc->iclk))
1885 clk_put(udc->iclk);
1886 iounmap(udc->udp_baseaddr);
1887fail0a:
1888 if (cpu_is_at91rm9200())
1889 gpio_free(udc->board.pullup_pin);
1890fail0:
1891 release_mem_region(res->start, resource_size(res));
1892 DBG("%s probe failed, %d\n", driver_name, retval); 1940 DBG("%s probe failed, %d\n", driver_name, retval);
1941
1893 return retval; 1942 return retval;
1894} 1943}
1895 1944
1896static int __exit at91udc_remove(struct platform_device *pdev) 1945static int __exit at91udc_remove(struct platform_device *pdev)
1897{ 1946{
1898 struct at91_udc *udc = platform_get_drvdata(pdev); 1947 struct at91_udc *udc = platform_get_drvdata(pdev);
1899 struct resource *res;
1900 unsigned long flags; 1948 unsigned long flags;
1901 1949
1902 DBG("remove\n"); 1950 DBG("remove\n");
@@ -1911,29 +1959,9 @@ static int __exit at91udc_remove(struct platform_device *pdev)
1911 1959
1912 device_init_wakeup(&pdev->dev, 0); 1960 device_init_wakeup(&pdev->dev, 0);
1913 remove_debug_file(udc); 1961 remove_debug_file(udc);
1914 if (gpio_is_valid(udc->board.vbus_pin)) {
1915 free_irq(gpio_to_irq(udc->board.vbus_pin), udc);
1916 gpio_free(udc->board.vbus_pin);
1917 }
1918 free_irq(udc->udp_irq, udc);
1919 iounmap(udc->udp_baseaddr);
1920
1921 if (cpu_is_at91rm9200())
1922 gpio_free(udc->board.pullup_pin);
1923
1924 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1925 release_mem_region(res->start, resource_size(res));
1926
1927 if (IS_ENABLED(CONFIG_COMMON_CLK))
1928 clk_unprepare(udc->uclk);
1929 clk_unprepare(udc->fclk); 1962 clk_unprepare(udc->fclk);
1930 clk_unprepare(udc->iclk); 1963 clk_unprepare(udc->iclk);
1931 1964
1932 clk_put(udc->iclk);
1933 clk_put(udc->fclk);
1934 if (IS_ENABLED(CONFIG_COMMON_CLK))
1935 clk_put(udc->uclk);
1936
1937 return 0; 1965 return 0;
1938} 1966}
1939 1967
@@ -1989,15 +2017,6 @@ static int at91udc_resume(struct platform_device *pdev)
1989#define at91udc_resume NULL 2017#define at91udc_resume NULL
1990#endif 2018#endif
1991 2019
1992#if defined(CONFIG_OF)
1993static const struct of_device_id at91_udc_dt_ids[] = {
1994 { .compatible = "atmel,at91rm9200-udc" },
1995 { /* sentinel */ }
1996};
1997
1998MODULE_DEVICE_TABLE(of, at91_udc_dt_ids);
1999#endif
2000
2001static struct platform_driver at91_udc_driver = { 2020static struct platform_driver at91_udc_driver = {
2002 .remove = __exit_p(at91udc_remove), 2021 .remove = __exit_p(at91udc_remove),
2003 .shutdown = at91udc_shutdown, 2022 .shutdown = at91udc_shutdown,
@@ -2005,7 +2024,7 @@ static struct platform_driver at91_udc_driver = {
2005 .resume = at91udc_resume, 2024 .resume = at91udc_resume,
2006 .driver = { 2025 .driver = {
2007 .name = (char *) driver_name, 2026 .name = (char *) driver_name,
2008 .of_match_table = of_match_ptr(at91_udc_dt_ids), 2027 .of_match_table = at91_udc_dt_ids,
2009 }, 2028 },
2010}; 2029};
2011 2030
diff --git a/drivers/usb/gadget/udc/at91_udc.h b/drivers/usb/gadget/udc/at91_udc.h
index 467dcfb74a51..2679c8b217cc 100644
--- a/drivers/usb/gadget/udc/at91_udc.h
+++ b/drivers/usb/gadget/udc/at91_udc.h
@@ -107,6 +107,11 @@ struct at91_ep {
107 unsigned fifo_bank:1; 107 unsigned fifo_bank:1;
108}; 108};
109 109
110struct at91_udc_caps {
111 int (*init)(struct at91_udc *udc);
112 void (*pullup)(struct at91_udc *udc, int is_on);
113};
114
110/* 115/*
111 * driver is non-SMP, and just blocks IRQs whenever it needs 116 * driver is non-SMP, and just blocks IRQs whenever it needs
112 * access protection for chip registers or driver state 117 * access protection for chip registers or driver state
@@ -115,6 +120,7 @@ struct at91_udc {
115 struct usb_gadget gadget; 120 struct usb_gadget gadget;
116 struct at91_ep ep[NUM_ENDPOINTS]; 121 struct at91_ep ep[NUM_ENDPOINTS];
117 struct usb_gadget_driver *driver; 122 struct usb_gadget_driver *driver;
123 const struct at91_udc_caps *caps;
118 unsigned vbus:1; 124 unsigned vbus:1;
119 unsigned enabled:1; 125 unsigned enabled:1;
120 unsigned clocked:1; 126 unsigned clocked:1;
@@ -125,7 +131,7 @@ struct at91_udc {
125 unsigned active_suspend:1; 131 unsigned active_suspend:1;
126 u8 addr; 132 u8 addr;
127 struct at91_udc_data board; 133 struct at91_udc_data board;
128 struct clk *iclk, *fclk, *uclk; 134 struct clk *iclk, *fclk;
129 struct platform_device *pdev; 135 struct platform_device *pdev;
130 struct proc_dir_entry *pde; 136 struct proc_dir_entry *pde;
131 void __iomem *udp_baseaddr; 137 void __iomem *udp_baseaddr;
@@ -133,6 +139,7 @@ struct at91_udc {
133 spinlock_t lock; 139 spinlock_t lock;
134 struct timer_list vbus_timer; 140 struct timer_list vbus_timer;
135 struct work_struct vbus_timer_work; 141 struct work_struct vbus_timer_work;
142 struct regmap *matrix;
136}; 143};
137 144
138static inline struct at91_udc *to_udc(struct usb_gadget *g) 145static inline struct at91_udc *to_udc(struct usb_gadget *g)
diff --git a/include/dt-bindings/clock/sh73a0-clock.h b/include/dt-bindings/clock/sh73a0-clock.h
new file mode 100644
index 000000000000..1dd3eb2b7d90
--- /dev/null
+++ b/include/dt-bindings/clock/sh73a0-clock.h
@@ -0,0 +1,79 @@
1/*
2 * Copyright 2014 Ulrich Hecht
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 */
9
10#ifndef __DT_BINDINGS_CLOCK_SH73A0_H__
11#define __DT_BINDINGS_CLOCK_SH73A0_H__
12
13/* CPG */
14#define SH73A0_CLK_MAIN 0
15#define SH73A0_CLK_PLL0 1
16#define SH73A0_CLK_PLL1 2
17#define SH73A0_CLK_PLL2 3
18#define SH73A0_CLK_PLL3 4
19#define SH73A0_CLK_DSI0PHY 5
20#define SH73A0_CLK_DSI1PHY 6
21#define SH73A0_CLK_ZG 7
22#define SH73A0_CLK_M3 8
23#define SH73A0_CLK_B 9
24#define SH73A0_CLK_M1 10
25#define SH73A0_CLK_M2 11
26#define SH73A0_CLK_Z 12
27#define SH73A0_CLK_ZX 13
28#define SH73A0_CLK_HP 14
29
30/* MSTP0 */
31#define SH73A0_CLK_IIC2 1
32
33/* MSTP1 */
34#define SH73A0_CLK_CEU1 29
35#define SH73A0_CLK_CSI2_RX1 28
36#define SH73A0_CLK_CEU0 27
37#define SH73A0_CLK_CSI2_RX0 26
38#define SH73A0_CLK_TMU0 25
39#define SH73A0_CLK_DSITX0 18
40#define SH73A0_CLK_IIC0 16
41#define SH73A0_CLK_SGX 12
42#define SH73A0_CLK_LCDC0 0
43
44/* MSTP2 */
45#define SH73A0_CLK_SCIFA7 19
46#define SH73A0_CLK_SY_DMAC 18
47#define SH73A0_CLK_MP_DMAC 17
48#define SH73A0_CLK_SCIFA5 7
49#define SH73A0_CLK_SCIFB 6
50#define SH73A0_CLK_SCIFA0 4
51#define SH73A0_CLK_SCIFA1 3
52#define SH73A0_CLK_SCIFA2 2
53#define SH73A0_CLK_SCIFA3 1
54#define SH73A0_CLK_SCIFA4 0
55
56/* MSTP3 */
57#define SH73A0_CLK_SCIFA6 31
58#define SH73A0_CLK_CMT1 29
59#define SH73A0_CLK_FSI 28
60#define SH73A0_CLK_IRDA 25
61#define SH73A0_CLK_IIC1 23
62#define SH73A0_CLK_USB 22
63#define SH73A0_CLK_FLCTL 15
64#define SH73A0_CLK_SDHI0 14
65#define SH73A0_CLK_SDHI1 13
66#define SH73A0_CLK_MMCIF0 12
67#define SH73A0_CLK_SDHI2 11
68#define SH73A0_CLK_TPU0 4
69#define SH73A0_CLK_TPU1 3
70#define SH73A0_CLK_TPU2 2
71#define SH73A0_CLK_TPU3 1
72#define SH73A0_CLK_TPU4 0
73
74/* MSTP4 */
75#define SH73A0_CLK_IIC3 11
76#define SH73A0_CLK_IIC4 10
77#define SH73A0_CLK_KEYSC 3
78
79#endif
diff --git a/include/linux/mfd/syscon/atmel-matrix.h b/include/linux/mfd/syscon/atmel-matrix.h
new file mode 100644
index 000000000000..8293c3e2a82a
--- /dev/null
+++ b/include/linux/mfd/syscon/atmel-matrix.h
@@ -0,0 +1,117 @@
1/*
2 * Copyright (C) 2014 Atmel Corporation.
3 *
4 * Memory Controllers (MATRIX, EBI) - System peripherals registers.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 */
11
12#ifndef _LINUX_MFD_SYSCON_ATMEL_MATRIX_H
13#define _LINUX_MFD_SYSCON_ATMEL_MATRIX_H
14
15#define AT91SAM9260_MATRIX_MCFG 0x00
16#define AT91SAM9260_MATRIX_SCFG 0x40
17#define AT91SAM9260_MATRIX_PRS 0x80
18#define AT91SAM9260_MATRIX_MRCR 0x100
19#define AT91SAM9260_MATRIX_EBICSA 0x11c
20
21#define AT91SAM9261_MATRIX_MRCR 0x0
22#define AT91SAM9261_MATRIX_SCFG 0x4
23#define AT91SAM9261_MATRIX_TCR 0x24
24#define AT91SAM9261_MATRIX_EBICSA 0x30
25#define AT91SAM9261_MATRIX_USBPUCR 0x34
26
27#define AT91SAM9263_MATRIX_MCFG 0x00
28#define AT91SAM9263_MATRIX_SCFG 0x40
29#define AT91SAM9263_MATRIX_PRS 0x80
30#define AT91SAM9263_MATRIX_MRCR 0x100
31#define AT91SAM9263_MATRIX_TCR 0x114
32#define AT91SAM9263_MATRIX_EBI0CSA 0x120
33#define AT91SAM9263_MATRIX_EBI1CSA 0x124
34
35#define AT91SAM9RL_MATRIX_MCFG 0x00
36#define AT91SAM9RL_MATRIX_SCFG 0x40
37#define AT91SAM9RL_MATRIX_PRS 0x80
38#define AT91SAM9RL_MATRIX_MRCR 0x100
39#define AT91SAM9RL_MATRIX_TCR 0x114
40#define AT91SAM9RL_MATRIX_EBICSA 0x120
41
42#define AT91SAM9G45_MATRIX_MCFG 0x00
43#define AT91SAM9G45_MATRIX_SCFG 0x40
44#define AT91SAM9G45_MATRIX_PRS 0x80
45#define AT91SAM9G45_MATRIX_MRCR 0x100
46#define AT91SAM9G45_MATRIX_TCR 0x110
47#define AT91SAM9G45_MATRIX_DDRMPR 0x118
48#define AT91SAM9G45_MATRIX_EBICSA 0x128
49
50#define AT91SAM9N12_MATRIX_MCFG 0x00
51#define AT91SAM9N12_MATRIX_SCFG 0x40
52#define AT91SAM9N12_MATRIX_PRS 0x80
53#define AT91SAM9N12_MATRIX_MRCR 0x100
54#define AT91SAM9N12_MATRIX_EBICSA 0x118
55
56#define AT91SAM9X5_MATRIX_MCFG 0x00
57#define AT91SAM9X5_MATRIX_SCFG 0x40
58#define AT91SAM9X5_MATRIX_PRS 0x80
59#define AT91SAM9X5_MATRIX_MRCR 0x100
60#define AT91SAM9X5_MATRIX_EBICSA 0x120
61
62#define SAMA5D3_MATRIX_MCFG 0x00
63#define SAMA5D3_MATRIX_SCFG 0x40
64#define SAMA5D3_MATRIX_PRS 0x80
65#define SAMA5D3_MATRIX_MRCR 0x100
66
67#define AT91_MATRIX_MCFG(o, x) ((o) + ((x) * 0x4))
68#define AT91_MATRIX_ULBT GENMASK(2, 0)
69#define AT91_MATRIX_ULBT_INFINITE (0 << 0)
70#define AT91_MATRIX_ULBT_SINGLE (1 << 0)
71#define AT91_MATRIX_ULBT_FOUR (2 << 0)
72#define AT91_MATRIX_ULBT_EIGHT (3 << 0)
73#define AT91_MATRIX_ULBT_SIXTEEN (4 << 0)
74
75#define AT91_MATRIX_SCFG(o, x) ((o) + ((x) * 0x4))
76#define AT91_MATRIX_SLOT_CYCLE GENMASK(7, 0)
77#define AT91_MATRIX_DEFMSTR_TYPE GENMASK(17, 16)
78#define AT91_MATRIX_DEFMSTR_TYPE_NONE (0 << 16)
79#define AT91_MATRIX_DEFMSTR_TYPE_LAST (1 << 16)
80#define AT91_MATRIX_DEFMSTR_TYPE_FIXED (2 << 16)
81#define AT91_MATRIX_FIXED_DEFMSTR GENMASK(20, 18)
82#define AT91_MATRIX_ARBT GENMASK(25, 24)
83#define AT91_MATRIX_ARBT_ROUND_ROBIN (0 << 24)
84#define AT91_MATRIX_ARBT_FIXED_PRIORITY (1 << 24)
85
86#define AT91_MATRIX_ITCM_SIZE GENMASK(3, 0)
87#define AT91_MATRIX_ITCM_0 (0 << 0)
88#define AT91_MATRIX_ITCM_16 (5 << 0)
89#define AT91_MATRIX_ITCM_32 (6 << 0)
90#define AT91_MATRIX_ITCM_64 (7 << 0)
91#define AT91_MATRIX_DTCM_SIZE GENMASK(7, 4)
92#define AT91_MATRIX_DTCM_0 (0 << 4)
93#define AT91_MATRIX_DTCM_16 (5 << 4)
94#define AT91_MATRIX_DTCM_32 (6 << 4)
95#define AT91_MATRIX_DTCM_64 (7 << 4)
96
97#define AT91_MATRIX_PRAS(o, x) ((o) + ((x) * 0x8))
98#define AT91_MATRIX_PRBS(o, x) ((o) + ((x) * 0x8) + 0x4)
99#define AT91_MATRIX_MPR(x) GENMASK(((x) * 0x4) + 1, ((x) * 0x4))
100
101#define AT91_MATRIX_RCB(x) BIT(x)
102
103#define AT91_MATRIX_CSA(cs, val) (val << (cs))
104#define AT91_MATRIX_DBPUC BIT(8)
105#define AT91_MATRIX_DBPDC BIT(9)
106#define AT91_MATRIX_VDDIOMSEL BIT(16)
107#define AT91_MATRIX_VDDIOMSEL_1_8V (0 << 16)
108#define AT91_MATRIX_VDDIOMSEL_3_3V (1 << 16)
109#define AT91_MATRIX_EBI_IOSR BIT(17)
110#define AT91_MATRIX_DDR_IOSR BIT(18)
111#define AT91_MATRIX_NFD0_SELECT BIT(24)
112#define AT91_MATRIX_DDR_MP_EN BIT(25)
113#define AT91_MATRIX_EBI_NUM_CS 8
114
115#define AT91_MATRIX_USBPUCR_PUON BIT(30)
116
117#endif /* _LINUX_MFD_SYSCON_ATMEL_MATRIX_H */
diff --git a/include/linux/mfd/syscon/atmel-smc.h b/include/linux/mfd/syscon/atmel-smc.h
new file mode 100644
index 000000000000..be6ebe64eebe
--- /dev/null
+++ b/include/linux/mfd/syscon/atmel-smc.h
@@ -0,0 +1,173 @@
1/*
2 * Atmel SMC (Static Memory Controller) register offsets and bit definitions.
3 *
4 * Copyright (C) 2014 Atmel
5 * Copyright (C) 2014 Free Electrons
6 *
7 * Author: Boris Brezillon <boris.brezillon@free-electrons.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 */
13
14#ifndef _LINUX_MFD_SYSCON_ATMEL_SMC_H_
15#define _LINUX_MFD_SYSCON_ATMEL_SMC_H_
16
17#include <linux/kernel.h>
18#include <linux/regmap.h>
19
20#define AT91SAM9_SMC_GENERIC 0x00
21#define AT91SAM9_SMC_GENERIC_BLK_SZ 0x10
22
23#define SAMA5_SMC_GENERIC 0x600
24#define SAMA5_SMC_GENERIC_BLK_SZ 0x14
25
26#define AT91SAM9_SMC_SETUP(o) ((o) + 0x00)
27#define AT91SAM9_SMC_NWESETUP(x) (x)
28#define AT91SAM9_SMC_NCS_WRSETUP(x) ((x) << 8)
29#define AT91SAM9_SMC_NRDSETUP(x) ((x) << 16)
30#define AT91SAM9_SMC_NCS_NRDSETUP(x) ((x) << 24)
31
32#define AT91SAM9_SMC_PULSE(o) ((o) + 0x04)
33#define AT91SAM9_SMC_NWEPULSE(x) (x)
34#define AT91SAM9_SMC_NCS_WRPULSE(x) ((x) << 8)
35#define AT91SAM9_SMC_NRDPULSE(x) ((x) << 16)
36#define AT91SAM9_SMC_NCS_NRDPULSE(x) ((x) << 24)
37
38#define AT91SAM9_SMC_CYCLE(o) ((o) + 0x08)
39#define AT91SAM9_SMC_NWECYCLE(x) (x)
40#define AT91SAM9_SMC_NRDCYCLE(x) ((x) << 16)
41
42#define AT91SAM9_SMC_MODE(o) ((o) + 0x0c)
43#define SAMA5_SMC_MODE(o) ((o) + 0x10)
44#define AT91_SMC_READMODE BIT(0)
45#define AT91_SMC_READMODE_NCS (0 << 0)
46#define AT91_SMC_READMODE_NRD (1 << 0)
47#define AT91_SMC_WRITEMODE BIT(1)
48#define AT91_SMC_WRITEMODE_NCS (0 << 1)
49#define AT91_SMC_WRITEMODE_NWE (1 << 1)
50#define AT91_SMC_EXNWMODE GENMASK(5, 4)
51#define AT91_SMC_EXNWMODE_DISABLE (0 << 4)
52#define AT91_SMC_EXNWMODE_FROZEN (2 << 4)
53#define AT91_SMC_EXNWMODE_READY (3 << 4)
54#define AT91_SMC_BAT BIT(8)
55#define AT91_SMC_BAT_SELECT (0 << 8)
56#define AT91_SMC_BAT_WRITE (1 << 8)
57#define AT91_SMC_DBW GENMASK(13, 12)
58#define AT91_SMC_DBW_8 (0 << 12)
59#define AT91_SMC_DBW_16 (1 << 12)
60#define AT91_SMC_DBW_32 (2 << 12)
61#define AT91_SMC_TDF GENMASK(19, 16)
62#define AT91_SMC_TDF_(x) ((((x) - 1) << 16) & AT91_SMC_TDF)
63#define AT91_SMC_TDF_MAX 16
64#define AT91_SMC_TDFMODE_OPTIMIZED BIT(20)
65#define AT91_SMC_PMEN BIT(24)
66#define AT91_SMC_PS GENMASK(29, 28)
67#define AT91_SMC_PS_4 (0 << 28)
68#define AT91_SMC_PS_8 (1 << 28)
69#define AT91_SMC_PS_16 (2 << 28)
70#define AT91_SMC_PS_32 (3 << 28)
71
72
73/*
74 * This function converts a setup timing expressed in nanoseconds into an
75 * encoded value that can be written in the SMC_SETUP register.
76 *
77 * The following formula is described in atmel datasheets (section
78 * "SMC Setup Register"):
79 *
80 * setup length = (128* SETUP[5] + SETUP[4:0])
81 *
82 * where setup length is the timing expressed in cycles.
83 */
84static inline u32 at91sam9_smc_setup_ns_to_cycles(unsigned int clk_rate,
85 u32 timing_ns)
86{
87 u32 clk_period = DIV_ROUND_UP(NSEC_PER_SEC, clk_rate);
88 u32 coded_cycles = 0;
89 u32 cycles;
90
91 cycles = DIV_ROUND_UP(timing_ns, clk_period);
92 if (cycles / 32) {
93 coded_cycles |= 1 << 5;
94 if (cycles < 128)
95 cycles = 0;
96 }
97
98 coded_cycles |= cycles % 32;
99
100 return coded_cycles;
101}
102
103/*
104 * This function converts a pulse timing expressed in nanoseconds into an
105 * encoded value that can be written in the SMC_PULSE register.
106 *
107 * The following formula is described in atmel datasheets (section
108 * "SMC Pulse Register"):
109 *
110 * pulse length = (256* PULSE[6] + PULSE[5:0])
111 *
112 * where pulse length is the timing expressed in cycles.
113 */
114static inline u32 at91sam9_smc_pulse_ns_to_cycles(unsigned int clk_rate,
115 u32 timing_ns)
116{
117 u32 clk_period = DIV_ROUND_UP(NSEC_PER_SEC, clk_rate);
118 u32 coded_cycles = 0;
119 u32 cycles;
120
121 cycles = DIV_ROUND_UP(timing_ns, clk_period);
122 if (cycles / 64) {
123 coded_cycles |= 1 << 6;
124 if (cycles < 256)
125 cycles = 0;
126 }
127
128 coded_cycles |= cycles % 64;
129
130 return coded_cycles;
131}
132
133/*
134 * This function converts a cycle timing expressed in nanoseconds into an
135 * encoded value that can be written in the SMC_CYCLE register.
136 *
137 * The following formula is described in atmel datasheets (section
138 * "SMC Cycle Register"):
139 *
140 * cycle length = (CYCLE[8:7]*256 + CYCLE[6:0])
141 *
142 * where cycle length is the timing expressed in cycles.
143 */
144static inline u32 at91sam9_smc_cycle_ns_to_cycles(unsigned int clk_rate,
145 u32 timing_ns)
146{
147 u32 clk_period = DIV_ROUND_UP(NSEC_PER_SEC, clk_rate);
148 u32 coded_cycles = 0;
149 u32 cycles;
150
151 cycles = DIV_ROUND_UP(timing_ns, clk_period);
152 if (cycles / 128) {
153 coded_cycles = cycles / 256;
154 cycles %= 256;
155 if (cycles >= 128) {
156 coded_cycles++;
157 cycles = 0;
158 }
159
160 if (coded_cycles > 0x3) {
161 coded_cycles = 0x3;
162 cycles = 0x7f;
163 }
164
165 coded_cycles <<= 7;
166 }
167
168 coded_cycles |= cycles % 128;
169
170 return coded_cycles;
171}
172
173#endif /* _LINUX_MFD_SYSCON_ATMEL_SMC_H_ */
diff --git a/include/linux/platform_data/cpuidle-exynos.h b/include/linux/platform_data/cpuidle-exynos.h
new file mode 100644
index 000000000000..bfa40e4c5d5f
--- /dev/null
+++ b/include/linux/platform_data/cpuidle-exynos.h
@@ -0,0 +1,20 @@
1/*
2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
3 * http://www.samsung.com
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8*/
9
10#ifndef __CPUIDLE_EXYNOS_H
11#define __CPUIDLE_EXYNOS_H
12
13struct cpuidle_exynos_data {
14 int (*cpu0_enter_aftr)(void);
15 int (*cpu1_powerdown)(void);
16 void (*pre_enter_aftr)(void);
17 void (*post_enter_aftr)(void);
18};
19
20#endif