diff options
123 files changed, 3607 insertions, 3509 deletions
diff --git a/Documentation/devicetree/bindings/usb/dwc3.txt b/Documentation/devicetree/bindings/usb/dwc3.txt index 7a95c651ceb3..e807635f9e1c 100644 --- a/Documentation/devicetree/bindings/usb/dwc3.txt +++ b/Documentation/devicetree/bindings/usb/dwc3.txt | |||
@@ -3,10 +3,12 @@ synopsys DWC3 CORE | |||
3 | DWC3- USB3 CONTROLLER | 3 | DWC3- USB3 CONTROLLER |
4 | 4 | ||
5 | Required properties: | 5 | Required properties: |
6 | - compatible: must be "synopsys,dwc3" | 6 | - compatible: must be "snps,dwc3" |
7 | - reg : Address and length of the register set for the device | 7 | - reg : Address and length of the register set for the device |
8 | - interrupts: Interrupts used by the dwc3 controller. | 8 | - interrupts: Interrupts used by the dwc3 controller. |
9 | - usb-phy : array of phandle for the PHY device | 9 | - usb-phy : array of phandle for the PHY device. The first element |
10 | in the array is expected to be a handle to the USB2/HS PHY and | ||
11 | the second element is expected to be a handle to the USB3/SS PHY | ||
10 | 12 | ||
11 | Optional properties: | 13 | Optional properties: |
12 | - tx-fifo-resize: determines if the FIFO *has* to be reallocated. | 14 | - tx-fifo-resize: determines if the FIFO *has* to be reallocated. |
@@ -14,7 +16,7 @@ Optional properties: | |||
14 | This is usually a subnode to DWC3 glue to which it is connected. | 16 | This is usually a subnode to DWC3 glue to which it is connected. |
15 | 17 | ||
16 | dwc3@4a030000 { | 18 | dwc3@4a030000 { |
17 | compatible = "synopsys,dwc3"; | 19 | compatible = "snps,dwc3"; |
18 | reg = <0x4a030000 0xcfff>; | 20 | reg = <0x4a030000 0xcfff>; |
19 | interrupts = <0 92 4> | 21 | interrupts = <0 92 4> |
20 | usb-phy = <&usb2_phy>, <&usb3,phy>; | 22 | usb-phy = <&usb2_phy>, <&usb3,phy>; |
diff --git a/Documentation/devicetree/bindings/usb/generic.txt b/Documentation/devicetree/bindings/usb/generic.txt new file mode 100644 index 000000000000..477d5bb5e51c --- /dev/null +++ b/Documentation/devicetree/bindings/usb/generic.txt | |||
@@ -0,0 +1,24 @@ | |||
1 | Generic USB Properties | ||
2 | |||
3 | Optional properties: | ||
4 | - maximum-speed: tells USB controllers we want to work up to a certain | ||
5 | speed. Valid arguments are "super-speed", "high-speed", | ||
6 | "full-speed" and "low-speed". In case this isn't passed | ||
7 | via DT, USB controllers should default to their maximum | ||
8 | HW capability. | ||
9 | - dr_mode: tells Dual-Role USB controllers that we want to work on a | ||
10 | particular mode. Valid arguments are "host", | ||
11 | "peripheral" and "otg". In case this attribute isn't | ||
12 | passed via DT, USB DRD controllers should default to | ||
13 | OTG. | ||
14 | |||
15 | This is an attribute to a USB controller such as: | ||
16 | |||
17 | dwc3@4a030000 { | ||
18 | compatible = "synopsys,dwc3"; | ||
19 | reg = <0x4a030000 0xcfff>; | ||
20 | interrupts = <0 92 4> | ||
21 | usb-phy = <&usb2_phy>, <&usb3,phy>; | ||
22 | maximum-speed = "super-speed"; | ||
23 | dr_mode = "otg"; | ||
24 | }; | ||
diff --git a/Documentation/devicetree/bindings/usb/nvidia,tegra20-usb-phy.txt b/Documentation/devicetree/bindings/usb/nvidia,tegra20-usb-phy.txt index c4c9e9e664aa..ba797d3e6326 100644 --- a/Documentation/devicetree/bindings/usb/nvidia,tegra20-usb-phy.txt +++ b/Documentation/devicetree/bindings/usb/nvidia,tegra20-usb-phy.txt | |||
@@ -3,7 +3,7 @@ Tegra SOC USB PHY | |||
3 | The device node for Tegra SOC USB PHY: | 3 | The device node for Tegra SOC USB PHY: |
4 | 4 | ||
5 | Required properties : | 5 | Required properties : |
6 | - compatible : Should be "nvidia,tegra20-usb-phy". | 6 | - compatible : Should be "nvidia,tegra<chip>-usb-phy". |
7 | - reg : Defines the following set of registers, in the order listed: | 7 | - reg : Defines the following set of registers, in the order listed: |
8 | - The PHY's own register set. | 8 | - The PHY's own register set. |
9 | Always present. | 9 | Always present. |
@@ -24,17 +24,26 @@ Required properties : | |||
24 | Required properties for phy_type == ulpi: | 24 | Required properties for phy_type == ulpi: |
25 | - nvidia,phy-reset-gpio : The GPIO used to reset the PHY. | 25 | - nvidia,phy-reset-gpio : The GPIO used to reset the PHY. |
26 | 26 | ||
27 | Required PHY timing params for utmi phy: | 27 | Required PHY timing params for utmi phy, for all chips: |
28 | - nvidia,hssync-start-delay : Number of 480 Mhz clock cycles to wait before | 28 | - nvidia,hssync-start-delay : Number of 480 Mhz clock cycles to wait before |
29 | start of sync launches RxActive | 29 | start of sync launches RxActive |
30 | - nvidia,elastic-limit : Variable FIFO Depth of elastic input store | 30 | - nvidia,elastic-limit : Variable FIFO Depth of elastic input store |
31 | - nvidia,idle-wait-delay : Number of 480 Mhz clock cycles of idle to wait | 31 | - nvidia,idle-wait-delay : Number of 480 Mhz clock cycles of idle to wait |
32 | before declare IDLE. | 32 | before declare IDLE. |
33 | - nvidia,term-range-adj : Range adjusment on terminations | 33 | - nvidia,term-range-adj : Range adjusment on terminations |
34 | - nvidia,xcvr-setup : HS driver output control | 34 | - Either one of the following for HS driver output control: |
35 | - nvidia,xcvr-setup : integer, uses the provided value. | ||
36 | - nvidia,xcvr-setup-use-fuses : boolean, indicates that the value is read | ||
37 | from the on-chip fuses | ||
38 | If both are provided, nvidia,xcvr-setup-use-fuses takes precedence. | ||
35 | - nvidia,xcvr-lsfslew : LS falling slew rate control. | 39 | - nvidia,xcvr-lsfslew : LS falling slew rate control. |
36 | - nvidia,xcvr-lsrslew : LS rising slew rate control. | 40 | - nvidia,xcvr-lsrslew : LS rising slew rate control. |
37 | 41 | ||
42 | Required PHY timing params for utmi phy, only on Tegra30 and above: | ||
43 | - nvidia,xcvr-hsslew : HS slew rate control. | ||
44 | - nvidia,hssquelch-level : HS squelch detector level. | ||
45 | - nvidia,hsdiscon-level : HS disconnect detector level. | ||
46 | |||
38 | Optional properties: | 47 | Optional properties: |
39 | - nvidia,has-legacy-mode : boolean indicates whether this controller can | 48 | - nvidia,has-legacy-mode : boolean indicates whether this controller can |
40 | operate in legacy mode (as APX 2500 / 2600). In legacy mode some | 49 | operate in legacy mode (as APX 2500 / 2600). In legacy mode some |
@@ -48,5 +57,5 @@ Optional properties: | |||
48 | peripheral means it is device controller | 57 | peripheral means it is device controller |
49 | otg means it can operate as either ("on the go") | 58 | otg means it can operate as either ("on the go") |
50 | 59 | ||
51 | Required properties for dr_mode == otg: | 60 | VBUS control (required for dr_mode == otg, optional for dr_mode == host): |
52 | - vbus-supply: regulator for VBUS | 61 | - vbus-supply: regulator for VBUS |
diff --git a/Documentation/devicetree/bindings/usb/samsung-hsotg.txt b/Documentation/devicetree/bindings/usb/samsung-hsotg.txt new file mode 100644 index 000000000000..b83d428a265e --- /dev/null +++ b/Documentation/devicetree/bindings/usb/samsung-hsotg.txt | |||
@@ -0,0 +1,40 @@ | |||
1 | Samsung High Speed USB OTG controller | ||
2 | ----------------------------- | ||
3 | |||
4 | The Samsung HSOTG IP can be found on Samsung SoCs, from S3C6400 onwards. | ||
5 | It gives functionality of OTG-compliant USB 2.0 host and device with | ||
6 | support for USB 2.0 high-speed (480Mbps) and full-speed (12 Mbps) | ||
7 | operation. | ||
8 | |||
9 | Currently only device mode is supported. | ||
10 | |||
11 | Binding details | ||
12 | ----- | ||
13 | |||
14 | Required properties: | ||
15 | - compatible: "samsung,s3c6400-hsotg" should be used for all currently | ||
16 | supported SoC, | ||
17 | - interrupt-parent: phandle for the interrupt controller to which the | ||
18 | interrupt signal of the HSOTG block is routed, | ||
19 | - interrupts: specifier of interrupt signal of interrupt controller, | ||
20 | according to bindings of interrupt controller, | ||
21 | - clocks: contains an array of clock specifiers: | ||
22 | - first entry: OTG clock | ||
23 | - clock-names: contains array of clock names: | ||
24 | - first entry: must be "otg" | ||
25 | - vusb_d-supply: phandle to voltage regulator of digital section, | ||
26 | - vusb_a-supply: phandle to voltage regulator of analog section. | ||
27 | |||
28 | Example | ||
29 | ----- | ||
30 | |||
31 | hsotg@12480000 { | ||
32 | compatible = "samsung,s3c6400-hsotg"; | ||
33 | reg = <0x12480000 0x20000>; | ||
34 | interrupts = <0 71 0>; | ||
35 | clocks = <&clock 305>; | ||
36 | clock-names = "otg"; | ||
37 | vusb_d-supply = <&vusb_reg>; | ||
38 | vusb_a-supply = <&vusbdac_reg>; | ||
39 | }; | ||
40 | |||
diff --git a/arch/arm/boot/dts/am335x-bone.dts b/arch/arm/boot/dts/am335x-bone.dts index 444b4ede0d60..a8907b57c75c 100644 --- a/arch/arm/boot/dts/am335x-bone.dts +++ b/arch/arm/boot/dts/am335x-bone.dts | |||
@@ -120,6 +120,22 @@ | |||
120 | status = "okay"; | 120 | status = "okay"; |
121 | }; | 121 | }; |
122 | 122 | ||
123 | musb: usb@47400000 { | ||
124 | status = "okay"; | ||
125 | |||
126 | control@44e10000 { | ||
127 | status = "okay"; | ||
128 | }; | ||
129 | |||
130 | phy@47401300 { | ||
131 | status = "okay"; | ||
132 | }; | ||
133 | |||
134 | usb@47401000 { | ||
135 | status = "okay"; | ||
136 | }; | ||
137 | }; | ||
138 | |||
123 | i2c0: i2c@44e0b000 { | 139 | i2c0: i2c@44e0b000 { |
124 | pinctrl-names = "default"; | 140 | pinctrl-names = "default"; |
125 | pinctrl-0 = <&i2c0_pins>; | 141 | pinctrl-0 = <&i2c0_pins>; |
diff --git a/arch/arm/boot/dts/am335x-evm.dts b/arch/arm/boot/dts/am335x-evm.dts index 3aee1a43782d..c26c16cace3c 100644 --- a/arch/arm/boot/dts/am335x-evm.dts +++ b/arch/arm/boot/dts/am335x-evm.dts | |||
@@ -171,6 +171,34 @@ | |||
171 | }; | 171 | }; |
172 | }; | 172 | }; |
173 | 173 | ||
174 | musb: usb@47400000 { | ||
175 | status = "okay"; | ||
176 | |||
177 | control@44e10000 { | ||
178 | status = "okay"; | ||
179 | }; | ||
180 | |||
181 | phy@47401300 { | ||
182 | status = "okay"; | ||
183 | }; | ||
184 | |||
185 | phy@47401b00 { | ||
186 | status = "okay"; | ||
187 | }; | ||
188 | |||
189 | usb@47401000 { | ||
190 | status = "okay"; | ||
191 | }; | ||
192 | |||
193 | usb@47401800 { | ||
194 | status = "okay"; | ||
195 | }; | ||
196 | |||
197 | dma@07402000 { | ||
198 | status = "okay"; | ||
199 | }; | ||
200 | }; | ||
201 | |||
174 | i2c1: i2c@4802a000 { | 202 | i2c1: i2c@4802a000 { |
175 | pinctrl-names = "default"; | 203 | pinctrl-names = "default"; |
176 | pinctrl-0 = <&i2c1_pins>; | 204 | pinctrl-0 = <&i2c1_pins>; |
diff --git a/arch/arm/boot/dts/am335x-evmsk.dts b/arch/arm/boot/dts/am335x-evmsk.dts index 0c8ad173d2b0..e92446c6846e 100644 --- a/arch/arm/boot/dts/am335x-evmsk.dts +++ b/arch/arm/boot/dts/am335x-evmsk.dts | |||
@@ -207,6 +207,22 @@ | |||
207 | }; | 207 | }; |
208 | }; | 208 | }; |
209 | 209 | ||
210 | musb: usb@47400000 { | ||
211 | status = "okay"; | ||
212 | |||
213 | control@44e10000 { | ||
214 | status = "okay"; | ||
215 | }; | ||
216 | |||
217 | phy@47401300 { | ||
218 | status = "okay"; | ||
219 | }; | ||
220 | |||
221 | usb@47401000 { | ||
222 | status = "okay"; | ||
223 | }; | ||
224 | }; | ||
225 | |||
210 | epwmss2: epwmss@48304000 { | 226 | epwmss2: epwmss@48304000 { |
211 | status = "okay"; | 227 | status = "okay"; |
212 | 228 | ||
diff --git a/arch/arm/boot/dts/am33xx.dtsi b/arch/arm/boot/dts/am33xx.dtsi index 38b446ba1ce1..24d63095ab83 100644 --- a/arch/arm/boot/dts/am33xx.dtsi +++ b/arch/arm/boot/dts/am33xx.dtsi | |||
@@ -26,6 +26,10 @@ | |||
26 | serial5 = &uart5; | 26 | serial5 = &uart5; |
27 | d_can0 = &dcan0; | 27 | d_can0 = &dcan0; |
28 | d_can1 = &dcan1; | 28 | d_can1 = &dcan1; |
29 | usb0 = &usb0; | ||
30 | usb1 = &usb1; | ||
31 | phy0 = &usb0_phy; | ||
32 | phy1 = &usb1_phy; | ||
29 | }; | 33 | }; |
30 | 34 | ||
31 | cpus { | 35 | cpus { |
@@ -333,21 +337,147 @@ | |||
333 | status = "disabled"; | 337 | status = "disabled"; |
334 | }; | 338 | }; |
335 | 339 | ||
336 | usb@47400000 { | 340 | usb: usb@47400000 { |
337 | compatible = "ti,musb-am33xx"; | 341 | compatible = "ti,am33xx-usb"; |
338 | reg = <0x47400000 0x1000 /* usbss */ | 342 | reg = <0x47400000 0x1000>; |
339 | 0x47401000 0x800 /* musb instance 0 */ | 343 | ranges; |
340 | 0x47401800 0x800>; /* musb instance 1 */ | 344 | #address-cells = <1>; |
341 | interrupts = <17 /* usbss */ | 345 | #size-cells = <1>; |
342 | 18 /* musb instance 0 */ | ||
343 | 19>; /* musb instance 1 */ | ||
344 | multipoint = <1>; | ||
345 | num-eps = <16>; | ||
346 | ram-bits = <12>; | ||
347 | port0-mode = <3>; | ||
348 | port1-mode = <3>; | ||
349 | power = <250>; | ||
350 | ti,hwmods = "usb_otg_hs"; | 346 | ti,hwmods = "usb_otg_hs"; |
347 | status = "disabled"; | ||
348 | |||
349 | ctrl_mod: control@44e10000 { | ||
350 | compatible = "ti,am335x-usb-ctrl-module"; | ||
351 | reg = <0x44e10620 0x10 | ||
352 | 0x44e10648 0x4>; | ||
353 | reg-names = "phy_ctrl", "wakeup"; | ||
354 | status = "disabled"; | ||
355 | }; | ||
356 | |||
357 | usb0_phy: phy@47401300 { | ||
358 | compatible = "ti,am335x-usb-phy"; | ||
359 | reg = <0x47401300 0x100>; | ||
360 | reg-names = "phy"; | ||
361 | status = "disabled"; | ||
362 | ti,ctrl_mod = <&ctrl_mod>; | ||
363 | }; | ||
364 | |||
365 | usb0: usb@47401000 { | ||
366 | compatible = "ti,musb-am33xx"; | ||
367 | ranges; | ||
368 | #address-cells = <1>; | ||
369 | #size-cells = <1>; | ||
370 | reg = <0x47401000 0x200>; | ||
371 | reg-names = "control"; | ||
372 | status = "disabled"; | ||
373 | |||
374 | musb0: usb@47401400 { | ||
375 | compatible = "mg,musbmhdrc"; | ||
376 | reg = <0x47401400 0x400>; | ||
377 | reg-names = "mc"; | ||
378 | interrupts = <18>; | ||
379 | interrupt-names = "mc"; | ||
380 | multipoint = <1>; | ||
381 | num-eps = <16>; | ||
382 | ram-bits = <12>; | ||
383 | port-mode = <3>; | ||
384 | power = <250>; | ||
385 | phys = <&usb0_phy>; | ||
386 | |||
387 | dmas = <&cppi41dma 0 0 &cppi41dma 1 0 | ||
388 | &cppi41dma 2 0 &cppi41dma 3 0 | ||
389 | &cppi41dma 4 0 &cppi41dma 5 0 | ||
390 | &cppi41dma 6 0 &cppi41dma 7 0 | ||
391 | &cppi41dma 8 0 &cppi41dma 9 0 | ||
392 | &cppi41dma 10 0 &cppi41dma 11 0 | ||
393 | &cppi41dma 12 0 &cppi41dma 13 0 | ||
394 | &cppi41dma 14 0 &cppi41dma 0 1 | ||
395 | &cppi41dma 1 1 &cppi41dma 2 1 | ||
396 | &cppi41dma 3 1 &cppi41dma 4 1 | ||
397 | &cppi41dma 5 1 &cppi41dma 6 1 | ||
398 | &cppi41dma 7 1 &cppi41dma 8 1 | ||
399 | &cppi41dma 9 1 &cppi41dma 10 1 | ||
400 | &cppi41dma 11 1 &cppi41dma 12 1 | ||
401 | &cppi41dma 13 1 &cppi41dma 14 1>; | ||
402 | dma-names = | ||
403 | "rx1", "rx2", "rx3", "rx4", "rx5", "rx6", "rx7", | ||
404 | "rx8", "rx9", "rx10", "rx11", "rx12", "rx13", | ||
405 | "rx14", "rx15", | ||
406 | "tx1", "tx2", "tx3", "tx4", "tx5", "tx6", "tx7", | ||
407 | "tx8", "tx9", "tx10", "tx11", "tx12", "tx13", | ||
408 | "tx14", "tx15"; | ||
409 | }; | ||
410 | }; | ||
411 | |||
412 | usb1_phy: phy@47401b00 { | ||
413 | compatible = "ti,am335x-usb-phy"; | ||
414 | reg = <0x47401b00 0x100>; | ||
415 | reg-names = "phy"; | ||
416 | status = "disabled"; | ||
417 | ti,ctrl_mod = <&ctrl_mod>; | ||
418 | }; | ||
419 | |||
420 | usb1: usb@47401800 { | ||
421 | compatible = "ti,musb-am33xx"; | ||
422 | ranges; | ||
423 | #address-cells = <1>; | ||
424 | #size-cells = <1>; | ||
425 | reg = <0x47401800 0x200>; | ||
426 | reg-names = "control"; | ||
427 | status = "disabled"; | ||
428 | |||
429 | musb1: usb@47401c00 { | ||
430 | compatible = "mg,musbmhdrc"; | ||
431 | reg = <0x47401c00 0x400>; | ||
432 | reg-names = "mc"; | ||
433 | interrupts = <19>; | ||
434 | interrupt-names = "mc"; | ||
435 | multipoint = <1>; | ||
436 | num-eps = <16>; | ||
437 | ram-bits = <12>; | ||
438 | port-mode = <3>; | ||
439 | power = <250>; | ||
440 | phys = <&usb1_phy>; | ||
441 | |||
442 | dmas = <&cppi41dma 15 0 &cppi41dma 16 0 | ||
443 | &cppi41dma 17 0 &cppi41dma 18 0 | ||
444 | &cppi41dma 19 0 &cppi41dma 20 0 | ||
445 | &cppi41dma 21 0 &cppi41dma 22 0 | ||
446 | &cppi41dma 23 0 &cppi41dma 24 0 | ||
447 | &cppi41dma 25 0 &cppi41dma 26 0 | ||
448 | &cppi41dma 27 0 &cppi41dma 28 0 | ||
449 | &cppi41dma 29 0 &cppi41dma 15 1 | ||
450 | &cppi41dma 16 1 &cppi41dma 17 1 | ||
451 | &cppi41dma 18 1 &cppi41dma 19 1 | ||
452 | &cppi41dma 20 1 &cppi41dma 21 1 | ||
453 | &cppi41dma 22 1 &cppi41dma 23 1 | ||
454 | &cppi41dma 24 1 &cppi41dma 25 1 | ||
455 | &cppi41dma 26 1 &cppi41dma 27 1 | ||
456 | &cppi41dma 28 1 &cppi41dma 29 1>; | ||
457 | dma-names = | ||
458 | "rx1", "rx2", "rx3", "rx4", "rx5", "rx6", "rx7", | ||
459 | "rx8", "rx9", "rx10", "rx11", "rx12", "rx13", | ||
460 | "rx14", "rx15", | ||
461 | "tx1", "tx2", "tx3", "tx4", "tx5", "tx6", "tx7", | ||
462 | "tx8", "tx9", "tx10", "tx11", "tx12", "tx13", | ||
463 | "tx14", "tx15"; | ||
464 | }; | ||
465 | }; | ||
466 | |||
467 | cppi41dma: dma@07402000 { | ||
468 | compatible = "ti,am3359-cppi41"; | ||
469 | reg = <0x47400000 0x1000 | ||
470 | 0x47402000 0x1000 | ||
471 | 0x47403000 0x1000 | ||
472 | 0x47404000 0x4000>; | ||
473 | reg-names = "glue controller scheduler queuemgr"; | ||
474 | interrupts = <17>; | ||
475 | interrupt-names = "glue"; | ||
476 | #dma-cells = <2>; | ||
477 | #dma-channels = <30>; | ||
478 | #dma-requests = <256>; | ||
479 | status = "disabled"; | ||
480 | }; | ||
351 | }; | 481 | }; |
352 | 482 | ||
353 | epwmss0: epwmss@48300000 { | 483 | epwmss0: epwmss@48300000 { |
diff --git a/arch/arm/boot/dts/omap5.dtsi b/arch/arm/boot/dts/omap5.dtsi index e643620417a9..07be2cd7b318 100644 --- a/arch/arm/boot/dts/omap5.dtsi +++ b/arch/arm/boot/dts/omap5.dtsi | |||
@@ -644,7 +644,7 @@ | |||
644 | utmi-mode = <2>; | 644 | utmi-mode = <2>; |
645 | ranges; | 645 | ranges; |
646 | dwc3@4a030000 { | 646 | dwc3@4a030000 { |
647 | compatible = "synopsys,dwc3"; | 647 | compatible = "snps,dwc3"; |
648 | reg = <0x4a030000 0x1000>; | 648 | reg = <0x4a030000 0x1000>; |
649 | interrupts = <GIC_SPI 92 IRQ_TYPE_LEVEL_HIGH>; | 649 | interrupts = <GIC_SPI 92 IRQ_TYPE_LEVEL_HIGH>; |
650 | usb-phy = <&usb2_phy>, <&usb3_phy>; | 650 | usb-phy = <&usb2_phy>, <&usb3_phy>; |
diff --git a/arch/arm/boot/dts/tegra20-seaboard.dts b/arch/arm/boot/dts/tegra20-seaboard.dts index 365760b33a26..52526c9a1329 100644 --- a/arch/arm/boot/dts/tegra20-seaboard.dts +++ b/arch/arm/boot/dts/tegra20-seaboard.dts | |||
@@ -566,7 +566,6 @@ | |||
566 | 566 | ||
567 | usb@c5000000 { | 567 | usb@c5000000 { |
568 | status = "okay"; | 568 | status = "okay"; |
569 | nvidia,vbus-gpio = <&gpio TEGRA_GPIO(D, 0) GPIO_ACTIVE_HIGH>; | ||
570 | dr_mode = "otg"; | 569 | dr_mode = "otg"; |
571 | }; | 570 | }; |
572 | 571 | ||
diff --git a/arch/arm/boot/dts/tegra20-trimslice.dts b/arch/arm/boot/dts/tegra20-trimslice.dts index ed4b901b0227..3e57b87cc75f 100644 --- a/arch/arm/boot/dts/tegra20-trimslice.dts +++ b/arch/arm/boot/dts/tegra20-trimslice.dts | |||
@@ -312,7 +312,6 @@ | |||
312 | 312 | ||
313 | usb@c5000000 { | 313 | usb@c5000000 { |
314 | status = "okay"; | 314 | status = "okay"; |
315 | nvidia,vbus-gpio = <&gpio TEGRA_GPIO(V, 2) GPIO_ACTIVE_HIGH>; | ||
316 | }; | 315 | }; |
317 | 316 | ||
318 | usb-phy@c5000000 { | 317 | usb-phy@c5000000 { |
diff --git a/arch/arm/boot/dts/tegra20-whistler.dts b/arch/arm/boot/dts/tegra20-whistler.dts index ab67c94db280..a6b1b5bdf288 100644 --- a/arch/arm/boot/dts/tegra20-whistler.dts +++ b/arch/arm/boot/dts/tegra20-whistler.dts | |||
@@ -509,7 +509,6 @@ | |||
509 | 509 | ||
510 | usb@c5000000 { | 510 | usb@c5000000 { |
511 | status = "okay"; | 511 | status = "okay"; |
512 | nvidia,vbus-gpio = <&tca6416 0 GPIO_ACTIVE_HIGH>; | ||
513 | }; | 512 | }; |
514 | 513 | ||
515 | usb-phy@c5000000 { | 514 | usb-phy@c5000000 { |
@@ -519,7 +518,6 @@ | |||
519 | 518 | ||
520 | usb@c5008000 { | 519 | usb@c5008000 { |
521 | status = "okay"; | 520 | status = "okay"; |
522 | nvidia,vbus-gpio = <&tca6416 1 GPIO_ACTIVE_HIGH>; | ||
523 | }; | 521 | }; |
524 | 522 | ||
525 | usb-phy@c5008000 { | 523 | usb-phy@c5008000 { |
diff --git a/arch/arm/boot/dts/tegra20.dtsi b/arch/arm/boot/dts/tegra20.dtsi index 9653fd8288d2..e4570834512e 100644 --- a/arch/arm/boot/dts/tegra20.dtsi +++ b/arch/arm/boot/dts/tegra20.dtsi | |||
@@ -477,13 +477,13 @@ | |||
477 | <&tegra_car TEGRA20_CLK_USBD>; | 477 | <&tegra_car TEGRA20_CLK_USBD>; |
478 | clock-names = "reg", "pll_u", "timer", "utmi-pads"; | 478 | clock-names = "reg", "pll_u", "timer", "utmi-pads"; |
479 | nvidia,has-legacy-mode; | 479 | nvidia,has-legacy-mode; |
480 | hssync_start_delay = <9>; | 480 | nvidia,hssync-start-delay = <9>; |
481 | idle_wait_delay = <17>; | 481 | nvidia,idle-wait-delay = <17>; |
482 | elastic_limit = <16>; | 482 | nvidia,elastic-limit = <16>; |
483 | term_range_adj = <6>; | 483 | nvidia,term-range-adj = <6>; |
484 | xcvr_setup = <9>; | 484 | nvidia,xcvr-setup = <9>; |
485 | xcvr_lsfslew = <1>; | 485 | nvidia,xcvr-lsfslew = <1>; |
486 | xcvr_lsrslew = <1>; | 486 | nvidia,xcvr-lsrslew = <1>; |
487 | status = "disabled"; | 487 | status = "disabled"; |
488 | }; | 488 | }; |
489 | 489 | ||
@@ -527,13 +527,13 @@ | |||
527 | <&tegra_car TEGRA20_CLK_CLK_M>, | 527 | <&tegra_car TEGRA20_CLK_CLK_M>, |
528 | <&tegra_car TEGRA20_CLK_USBD>; | 528 | <&tegra_car TEGRA20_CLK_USBD>; |
529 | clock-names = "reg", "pll_u", "timer", "utmi-pads"; | 529 | clock-names = "reg", "pll_u", "timer", "utmi-pads"; |
530 | hssync_start_delay = <9>; | 530 | nvidia,hssync-start-delay = <9>; |
531 | idle_wait_delay = <17>; | 531 | nvidia,idle-wait-delay = <17>; |
532 | elastic_limit = <16>; | 532 | nvidia,elastic-limit = <16>; |
533 | term_range_adj = <6>; | 533 | nvidia,term-range-adj = <6>; |
534 | xcvr_setup = <9>; | 534 | nvidia,xcvr-setup = <9>; |
535 | xcvr_lsfslew = <2>; | 535 | nvidia,xcvr-lsfslew = <2>; |
536 | xcvr_lsrslew = <2>; | 536 | nvidia,xcvr-lsrslew = <2>; |
537 | status = "disabled"; | 537 | status = "disabled"; |
538 | }; | 538 | }; |
539 | 539 | ||
diff --git a/arch/arm/mach-omap2/board-omap3beagle.c b/arch/arm/mach-omap2/board-omap3beagle.c index 04c116555412..1c6ae5f5bae7 100644 --- a/arch/arm/mach-omap2/board-omap3beagle.c +++ b/arch/arm/mach-omap2/board-omap3beagle.c | |||
@@ -33,7 +33,7 @@ | |||
33 | #include <linux/mtd/nand.h> | 33 | #include <linux/mtd/nand.h> |
34 | #include <linux/mmc/host.h> | 34 | #include <linux/mmc/host.h> |
35 | #include <linux/usb/phy.h> | 35 | #include <linux/usb/phy.h> |
36 | #include <linux/usb/nop-usb-xceiv.h> | 36 | #include <linux/usb/usb_phy_gen_xceiv.h> |
37 | 37 | ||
38 | #include <linux/regulator/machine.h> | 38 | #include <linux/regulator/machine.h> |
39 | #include <linux/i2c/twl.h> | 39 | #include <linux/i2c/twl.h> |
@@ -279,7 +279,7 @@ static struct regulator_consumer_supply beagle_vsim_supply[] = { | |||
279 | static struct gpio_led gpio_leds[]; | 279 | static struct gpio_led gpio_leds[]; |
280 | 280 | ||
281 | /* PHY's VCC regulator might be added later, so flag that we need it */ | 281 | /* PHY's VCC regulator might be added later, so flag that we need it */ |
282 | static struct nop_usb_xceiv_platform_data hsusb2_phy_data = { | 282 | static struct usb_phy_gen_xceiv_platform_data hsusb2_phy_data = { |
283 | .needs_vcc = true, | 283 | .needs_vcc = true, |
284 | }; | 284 | }; |
285 | 285 | ||
diff --git a/arch/arm/mach-omap2/board-omap3evm.c b/arch/arm/mach-omap2/board-omap3evm.c index 8c026269baca..52bdddd41e0e 100644 --- a/arch/arm/mach-omap2/board-omap3evm.c +++ b/arch/arm/mach-omap2/board-omap3evm.c | |||
@@ -33,7 +33,7 @@ | |||
33 | #include <linux/i2c/twl.h> | 33 | #include <linux/i2c/twl.h> |
34 | #include <linux/usb/otg.h> | 34 | #include <linux/usb/otg.h> |
35 | #include <linux/usb/musb.h> | 35 | #include <linux/usb/musb.h> |
36 | #include <linux/usb/nop-usb-xceiv.h> | 36 | #include <linux/usb/usb_phy_gen_xceiv.h> |
37 | #include <linux/smsc911x.h> | 37 | #include <linux/smsc911x.h> |
38 | 38 | ||
39 | #include <linux/wl12xx.h> | 39 | #include <linux/wl12xx.h> |
@@ -468,7 +468,7 @@ struct wl12xx_platform_data omap3evm_wlan_data __initdata = { | |||
468 | static struct regulator_consumer_supply omap3evm_vaux2_supplies[] = { | 468 | static struct regulator_consumer_supply omap3evm_vaux2_supplies[] = { |
469 | REGULATOR_SUPPLY("VDD_CSIPHY1", "omap3isp"), /* OMAP ISP */ | 469 | REGULATOR_SUPPLY("VDD_CSIPHY1", "omap3isp"), /* OMAP ISP */ |
470 | REGULATOR_SUPPLY("VDD_CSIPHY2", "omap3isp"), /* OMAP ISP */ | 470 | REGULATOR_SUPPLY("VDD_CSIPHY2", "omap3isp"), /* OMAP ISP */ |
471 | REGULATOR_SUPPLY("vcc", "nop_usb_xceiv.2"), /* hsusb port 2 */ | 471 | REGULATOR_SUPPLY("vcc", "usb_phy_gen_xceiv.2"), /* hsusb port 2 */ |
472 | REGULATOR_SUPPLY("vaux2", NULL), | 472 | REGULATOR_SUPPLY("vaux2", NULL), |
473 | }; | 473 | }; |
474 | 474 | ||
diff --git a/arch/arm/mach-omap2/board-omap3pandora.c b/arch/arm/mach-omap2/board-omap3pandora.c index b1547a0edfcd..d2b455e70486 100644 --- a/arch/arm/mach-omap2/board-omap3pandora.c +++ b/arch/arm/mach-omap2/board-omap3pandora.c | |||
@@ -352,7 +352,7 @@ static struct regulator_consumer_supply pandora_vcc_lcd_supply[] = { | |||
352 | }; | 352 | }; |
353 | 353 | ||
354 | static struct regulator_consumer_supply pandora_usb_phy_supply[] = { | 354 | static struct regulator_consumer_supply pandora_usb_phy_supply[] = { |
355 | REGULATOR_SUPPLY("vcc", "nop_usb_xceiv.2"), /* hsusb port 2 */ | 355 | REGULATOR_SUPPLY("vcc", "usb_phy_gen_xceiv.2"), /* hsusb port 2 */ |
356 | }; | 356 | }; |
357 | 357 | ||
358 | /* ads7846 on SPI and 2 nub controllers on I2C */ | 358 | /* ads7846 on SPI and 2 nub controllers on I2C */ |
diff --git a/arch/arm/mach-omap2/usb-host.c b/arch/arm/mach-omap2/usb-host.c index 2eb19d4d0aa1..e83a6a4b184a 100644 --- a/arch/arm/mach-omap2/usb-host.c +++ b/arch/arm/mach-omap2/usb-host.c | |||
@@ -28,7 +28,7 @@ | |||
28 | #include <linux/io.h> | 28 | #include <linux/io.h> |
29 | #include <linux/gpio.h> | 29 | #include <linux/gpio.h> |
30 | #include <linux/usb/phy.h> | 30 | #include <linux/usb/phy.h> |
31 | #include <linux/usb/nop-usb-xceiv.h> | 31 | #include <linux/usb/usb_phy_gen_xceiv.h> |
32 | 32 | ||
33 | #include "soc.h" | 33 | #include "soc.h" |
34 | #include "omap_device.h" | 34 | #include "omap_device.h" |
@@ -349,7 +349,7 @@ static struct fixed_voltage_config hsusb_reg_config = { | |||
349 | /* .init_data filled later */ | 349 | /* .init_data filled later */ |
350 | }; | 350 | }; |
351 | 351 | ||
352 | static const char *nop_name = "nop_usb_xceiv"; /* NOP PHY driver */ | 352 | static const char *nop_name = "usb_phy_gen_xceiv"; /* NOP PHY driver */ |
353 | static const char *reg_name = "reg-fixed-voltage"; /* Regulator driver */ | 353 | static const char *reg_name = "reg-fixed-voltage"; /* Regulator driver */ |
354 | 354 | ||
355 | /** | 355 | /** |
@@ -460,9 +460,9 @@ int usbhs_init_phys(struct usbhs_phy_data *phy, int num_phys) | |||
460 | pdevinfo.name = nop_name; | 460 | pdevinfo.name = nop_name; |
461 | pdevinfo.id = phy->port; | 461 | pdevinfo.id = phy->port; |
462 | pdevinfo.data = phy->platform_data; | 462 | pdevinfo.data = phy->platform_data; |
463 | pdevinfo.size_data = sizeof(struct nop_usb_xceiv_platform_data); | 463 | pdevinfo.size_data = |
464 | 464 | sizeof(struct usb_phy_gen_xceiv_platform_data); | |
465 | scnprintf(phy_id, MAX_STR, "nop_usb_xceiv.%d", | 465 | scnprintf(phy_id, MAX_STR, "usb_phy_gen_xceiv.%d", |
466 | phy->port); | 466 | phy->port); |
467 | pdev = platform_device_register_full(&pdevinfo); | 467 | pdev = platform_device_register_full(&pdevinfo); |
468 | if (IS_ERR(pdev)) { | 468 | if (IS_ERR(pdev)) { |
diff --git a/arch/arm/mach-tegra/tegra.c b/arch/arm/mach-tegra/tegra.c index 0d1e4128d460..fc97cfd52769 100644 --- a/arch/arm/mach-tegra/tegra.c +++ b/arch/arm/mach-tegra/tegra.c | |||
@@ -29,7 +29,6 @@ | |||
29 | #include <linux/of_fdt.h> | 29 | #include <linux/of_fdt.h> |
30 | #include <linux/of_platform.h> | 30 | #include <linux/of_platform.h> |
31 | #include <linux/pda_power.h> | 31 | #include <linux/pda_power.h> |
32 | #include <linux/platform_data/tegra_usb.h> | ||
33 | #include <linux/io.h> | 32 | #include <linux/io.h> |
34 | #include <linux/slab.h> | 33 | #include <linux/slab.h> |
35 | #include <linux/sys_soc.h> | 34 | #include <linux/sys_soc.h> |
@@ -46,40 +45,6 @@ | |||
46 | #include "fuse.h" | 45 | #include "fuse.h" |
47 | #include "iomap.h" | 46 | #include "iomap.h" |
48 | 47 | ||
49 | static struct tegra_ehci_platform_data tegra_ehci1_pdata = { | ||
50 | .operating_mode = TEGRA_USB_OTG, | ||
51 | .power_down_on_bus_suspend = 1, | ||
52 | .vbus_gpio = -1, | ||
53 | }; | ||
54 | |||
55 | static struct tegra_ulpi_config tegra_ehci2_ulpi_phy_config = { | ||
56 | .reset_gpio = -1, | ||
57 | .clk = "cdev2", | ||
58 | }; | ||
59 | |||
60 | static struct tegra_ehci_platform_data tegra_ehci2_pdata = { | ||
61 | .phy_config = &tegra_ehci2_ulpi_phy_config, | ||
62 | .operating_mode = TEGRA_USB_HOST, | ||
63 | .power_down_on_bus_suspend = 1, | ||
64 | .vbus_gpio = -1, | ||
65 | }; | ||
66 | |||
67 | static struct tegra_ehci_platform_data tegra_ehci3_pdata = { | ||
68 | .operating_mode = TEGRA_USB_HOST, | ||
69 | .power_down_on_bus_suspend = 1, | ||
70 | .vbus_gpio = -1, | ||
71 | }; | ||
72 | |||
73 | static struct of_dev_auxdata tegra20_auxdata_lookup[] __initdata = { | ||
74 | OF_DEV_AUXDATA("nvidia,tegra20-ehci", 0xC5000000, "tegra-ehci.0", | ||
75 | &tegra_ehci1_pdata), | ||
76 | OF_DEV_AUXDATA("nvidia,tegra20-ehci", 0xC5004000, "tegra-ehci.1", | ||
77 | &tegra_ehci2_pdata), | ||
78 | OF_DEV_AUXDATA("nvidia,tegra20-ehci", 0xC5008000, "tegra-ehci.2", | ||
79 | &tegra_ehci3_pdata), | ||
80 | {} | ||
81 | }; | ||
82 | |||
83 | static void __init tegra_dt_init(void) | 48 | static void __init tegra_dt_init(void) |
84 | { | 49 | { |
85 | struct soc_device_attribute *soc_dev_attr; | 50 | struct soc_device_attribute *soc_dev_attr; |
@@ -112,8 +77,7 @@ static void __init tegra_dt_init(void) | |||
112 | * devices | 77 | * devices |
113 | */ | 78 | */ |
114 | out: | 79 | out: |
115 | of_platform_populate(NULL, of_default_bus_match_table, | 80 | of_platform_populate(NULL, of_default_bus_match_table, NULL, parent); |
116 | tegra20_auxdata_lookup, parent); | ||
117 | } | 81 | } |
118 | 82 | ||
119 | static void __init trimslice_init(void) | 83 | static void __init trimslice_init(void) |
diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig index 6825957c97fb..77bc480117b7 100644 --- a/drivers/dma/Kconfig +++ b/drivers/dma/Kconfig | |||
@@ -287,6 +287,14 @@ config DMA_OMAP | |||
287 | select DMA_ENGINE | 287 | select DMA_ENGINE |
288 | select DMA_VIRTUAL_CHANNELS | 288 | select DMA_VIRTUAL_CHANNELS |
289 | 289 | ||
290 | config TI_CPPI41 | ||
291 | tristate "AM33xx CPPI41 DMA support" | ||
292 | depends on ARCH_OMAP | ||
293 | select DMA_ENGINE | ||
294 | help | ||
295 | The Communications Port Programming Interface (CPPI) 4.1 DMA engine | ||
296 | is currently used by the USB driver on AM335x platforms. | ||
297 | |||
290 | config MMP_PDMA | 298 | config MMP_PDMA |
291 | bool "MMP PDMA support" | 299 | bool "MMP PDMA support" |
292 | depends on (ARCH_MMP || ARCH_PXA) | 300 | depends on (ARCH_MMP || ARCH_PXA) |
diff --git a/drivers/dma/Makefile b/drivers/dma/Makefile index 5e0f2ef85614..6d62ec30c4bc 100644 --- a/drivers/dma/Makefile +++ b/drivers/dma/Makefile | |||
@@ -39,3 +39,4 @@ obj-$(CONFIG_MMP_TDMA) += mmp_tdma.o | |||
39 | obj-$(CONFIG_DMA_OMAP) += omap-dma.o | 39 | obj-$(CONFIG_DMA_OMAP) += omap-dma.o |
40 | obj-$(CONFIG_MMP_PDMA) += mmp_pdma.o | 40 | obj-$(CONFIG_MMP_PDMA) += mmp_pdma.o |
41 | obj-$(CONFIG_DMA_JZ4740) += dma-jz4740.o | 41 | obj-$(CONFIG_DMA_JZ4740) += dma-jz4740.o |
42 | obj-$(CONFIG_TI_CPPI41) += cppi41.o | ||
diff --git a/drivers/dma/cppi41.c b/drivers/dma/cppi41.c new file mode 100644 index 000000000000..5dcebca37760 --- /dev/null +++ b/drivers/dma/cppi41.c | |||
@@ -0,0 +1,1048 @@ | |||
1 | #include <linux/dmaengine.h> | ||
2 | #include <linux/dma-mapping.h> | ||
3 | #include <linux/platform_device.h> | ||
4 | #include <linux/module.h> | ||
5 | #include <linux/of.h> | ||
6 | #include <linux/slab.h> | ||
7 | #include <linux/of_dma.h> | ||
8 | #include <linux/of_irq.h> | ||
9 | #include <linux/dmapool.h> | ||
10 | #include <linux/interrupt.h> | ||
11 | #include <linux/of_address.h> | ||
12 | #include "dmaengine.h" | ||
13 | |||
14 | #define DESC_TYPE 27 | ||
15 | #define DESC_TYPE_HOST 0x10 | ||
16 | #define DESC_TYPE_TEARD 0x13 | ||
17 | |||
18 | #define TD_DESC_IS_RX (1 << 16) | ||
19 | #define TD_DESC_DMA_NUM 10 | ||
20 | |||
21 | #define DESC_LENGTH_BITS_NUM 21 | ||
22 | |||
23 | #define DESC_TYPE_USB (5 << 26) | ||
24 | #define DESC_PD_COMPLETE (1 << 31) | ||
25 | |||
26 | /* DMA engine */ | ||
27 | #define DMA_TDFDQ 4 | ||
28 | #define DMA_TXGCR(x) (0x800 + (x) * 0x20) | ||
29 | #define DMA_RXGCR(x) (0x808 + (x) * 0x20) | ||
30 | #define RXHPCRA0 4 | ||
31 | |||
32 | #define GCR_CHAN_ENABLE (1 << 31) | ||
33 | #define GCR_TEARDOWN (1 << 30) | ||
34 | #define GCR_STARV_RETRY (1 << 24) | ||
35 | #define GCR_DESC_TYPE_HOST (1 << 14) | ||
36 | |||
37 | /* DMA scheduler */ | ||
38 | #define DMA_SCHED_CTRL 0 | ||
39 | #define DMA_SCHED_CTRL_EN (1 << 31) | ||
40 | #define DMA_SCHED_WORD(x) ((x) * 4 + 0x800) | ||
41 | |||
42 | #define SCHED_ENTRY0_CHAN(x) ((x) << 0) | ||
43 | #define SCHED_ENTRY0_IS_RX (1 << 7) | ||
44 | |||
45 | #define SCHED_ENTRY1_CHAN(x) ((x) << 8) | ||
46 | #define SCHED_ENTRY1_IS_RX (1 << 15) | ||
47 | |||
48 | #define SCHED_ENTRY2_CHAN(x) ((x) << 16) | ||
49 | #define SCHED_ENTRY2_IS_RX (1 << 23) | ||
50 | |||
51 | #define SCHED_ENTRY3_CHAN(x) ((x) << 24) | ||
52 | #define SCHED_ENTRY3_IS_RX (1 << 31) | ||
53 | |||
54 | /* Queue manager */ | ||
55 | /* 4 KiB of memory for descriptors, 2 for each endpoint */ | ||
56 | #define ALLOC_DECS_NUM 128 | ||
57 | #define DESCS_AREAS 1 | ||
58 | #define TOTAL_DESCS_NUM (ALLOC_DECS_NUM * DESCS_AREAS) | ||
59 | #define QMGR_SCRATCH_SIZE (TOTAL_DESCS_NUM * 4) | ||
60 | |||
61 | #define QMGR_LRAM0_BASE 0x80 | ||
62 | #define QMGR_LRAM_SIZE 0x84 | ||
63 | #define QMGR_LRAM1_BASE 0x88 | ||
64 | #define QMGR_MEMBASE(x) (0x1000 + (x) * 0x10) | ||
65 | #define QMGR_MEMCTRL(x) (0x1004 + (x) * 0x10) | ||
66 | #define QMGR_MEMCTRL_IDX_SH 16 | ||
67 | #define QMGR_MEMCTRL_DESC_SH 8 | ||
68 | |||
69 | #define QMGR_NUM_PEND 5 | ||
70 | #define QMGR_PEND(x) (0x90 + (x) * 4) | ||
71 | |||
72 | #define QMGR_PENDING_SLOT_Q(x) (x / 32) | ||
73 | #define QMGR_PENDING_BIT_Q(x) (x % 32) | ||
74 | |||
75 | #define QMGR_QUEUE_A(n) (0x2000 + (n) * 0x10) | ||
76 | #define QMGR_QUEUE_B(n) (0x2004 + (n) * 0x10) | ||
77 | #define QMGR_QUEUE_C(n) (0x2008 + (n) * 0x10) | ||
78 | #define QMGR_QUEUE_D(n) (0x200c + (n) * 0x10) | ||
79 | |||
80 | /* Glue layer specific */ | ||
81 | /* USBSS / USB AM335x */ | ||
82 | #define USBSS_IRQ_STATUS 0x28 | ||
83 | #define USBSS_IRQ_ENABLER 0x2c | ||
84 | #define USBSS_IRQ_CLEARR 0x30 | ||
85 | |||
86 | #define USBSS_IRQ_PD_COMP (1 << 2) | ||
87 | |||
88 | struct cppi41_channel { | ||
89 | struct dma_chan chan; | ||
90 | struct dma_async_tx_descriptor txd; | ||
91 | struct cppi41_dd *cdd; | ||
92 | struct cppi41_desc *desc; | ||
93 | dma_addr_t desc_phys; | ||
94 | void __iomem *gcr_reg; | ||
95 | int is_tx; | ||
96 | u32 residue; | ||
97 | |||
98 | unsigned int q_num; | ||
99 | unsigned int q_comp_num; | ||
100 | unsigned int port_num; | ||
101 | |||
102 | unsigned td_retry; | ||
103 | unsigned td_queued:1; | ||
104 | unsigned td_seen:1; | ||
105 | unsigned td_desc_seen:1; | ||
106 | }; | ||
107 | |||
108 | struct cppi41_desc { | ||
109 | u32 pd0; | ||
110 | u32 pd1; | ||
111 | u32 pd2; | ||
112 | u32 pd3; | ||
113 | u32 pd4; | ||
114 | u32 pd5; | ||
115 | u32 pd6; | ||
116 | u32 pd7; | ||
117 | } __aligned(32); | ||
118 | |||
119 | struct chan_queues { | ||
120 | u16 submit; | ||
121 | u16 complete; | ||
122 | }; | ||
123 | |||
124 | struct cppi41_dd { | ||
125 | struct dma_device ddev; | ||
126 | |||
127 | void *qmgr_scratch; | ||
128 | dma_addr_t scratch_phys; | ||
129 | |||
130 | struct cppi41_desc *cd; | ||
131 | dma_addr_t descs_phys; | ||
132 | u32 first_td_desc; | ||
133 | struct cppi41_channel *chan_busy[ALLOC_DECS_NUM]; | ||
134 | |||
135 | void __iomem *usbss_mem; | ||
136 | void __iomem *ctrl_mem; | ||
137 | void __iomem *sched_mem; | ||
138 | void __iomem *qmgr_mem; | ||
139 | unsigned int irq; | ||
140 | const struct chan_queues *queues_rx; | ||
141 | const struct chan_queues *queues_tx; | ||
142 | struct chan_queues td_queue; | ||
143 | }; | ||
144 | |||
145 | #define FIST_COMPLETION_QUEUE 93 | ||
146 | static struct chan_queues usb_queues_tx[] = { | ||
147 | /* USB0 ENDP 1 */ | ||
148 | [ 0] = { .submit = 32, .complete = 93}, | ||
149 | [ 1] = { .submit = 34, .complete = 94}, | ||
150 | [ 2] = { .submit = 36, .complete = 95}, | ||
151 | [ 3] = { .submit = 38, .complete = 96}, | ||
152 | [ 4] = { .submit = 40, .complete = 97}, | ||
153 | [ 5] = { .submit = 42, .complete = 98}, | ||
154 | [ 6] = { .submit = 44, .complete = 99}, | ||
155 | [ 7] = { .submit = 46, .complete = 100}, | ||
156 | [ 8] = { .submit = 48, .complete = 101}, | ||
157 | [ 9] = { .submit = 50, .complete = 102}, | ||
158 | [10] = { .submit = 52, .complete = 103}, | ||
159 | [11] = { .submit = 54, .complete = 104}, | ||
160 | [12] = { .submit = 56, .complete = 105}, | ||
161 | [13] = { .submit = 58, .complete = 106}, | ||
162 | [14] = { .submit = 60, .complete = 107}, | ||
163 | |||
164 | /* USB1 ENDP1 */ | ||
165 | [15] = { .submit = 62, .complete = 125}, | ||
166 | [16] = { .submit = 64, .complete = 126}, | ||
167 | [17] = { .submit = 66, .complete = 127}, | ||
168 | [18] = { .submit = 68, .complete = 128}, | ||
169 | [19] = { .submit = 70, .complete = 129}, | ||
170 | [20] = { .submit = 72, .complete = 130}, | ||
171 | [21] = { .submit = 74, .complete = 131}, | ||
172 | [22] = { .submit = 76, .complete = 132}, | ||
173 | [23] = { .submit = 78, .complete = 133}, | ||
174 | [24] = { .submit = 80, .complete = 134}, | ||
175 | [25] = { .submit = 82, .complete = 135}, | ||
176 | [26] = { .submit = 84, .complete = 136}, | ||
177 | [27] = { .submit = 86, .complete = 137}, | ||
178 | [28] = { .submit = 88, .complete = 138}, | ||
179 | [29] = { .submit = 90, .complete = 139}, | ||
180 | }; | ||
181 | |||
182 | static const struct chan_queues usb_queues_rx[] = { | ||
183 | /* USB0 ENDP 1 */ | ||
184 | [ 0] = { .submit = 1, .complete = 109}, | ||
185 | [ 1] = { .submit = 2, .complete = 110}, | ||
186 | [ 2] = { .submit = 3, .complete = 111}, | ||
187 | [ 3] = { .submit = 4, .complete = 112}, | ||
188 | [ 4] = { .submit = 5, .complete = 113}, | ||
189 | [ 5] = { .submit = 6, .complete = 114}, | ||
190 | [ 6] = { .submit = 7, .complete = 115}, | ||
191 | [ 7] = { .submit = 8, .complete = 116}, | ||
192 | [ 8] = { .submit = 9, .complete = 117}, | ||
193 | [ 9] = { .submit = 10, .complete = 118}, | ||
194 | [10] = { .submit = 11, .complete = 119}, | ||
195 | [11] = { .submit = 12, .complete = 120}, | ||
196 | [12] = { .submit = 13, .complete = 121}, | ||
197 | [13] = { .submit = 14, .complete = 122}, | ||
198 | [14] = { .submit = 15, .complete = 123}, | ||
199 | |||
200 | /* USB1 ENDP 1 */ | ||
201 | [15] = { .submit = 16, .complete = 141}, | ||
202 | [16] = { .submit = 17, .complete = 142}, | ||
203 | [17] = { .submit = 18, .complete = 143}, | ||
204 | [18] = { .submit = 19, .complete = 144}, | ||
205 | [19] = { .submit = 20, .complete = 145}, | ||
206 | [20] = { .submit = 21, .complete = 146}, | ||
207 | [21] = { .submit = 22, .complete = 147}, | ||
208 | [22] = { .submit = 23, .complete = 148}, | ||
209 | [23] = { .submit = 24, .complete = 149}, | ||
210 | [24] = { .submit = 25, .complete = 150}, | ||
211 | [25] = { .submit = 26, .complete = 151}, | ||
212 | [26] = { .submit = 27, .complete = 152}, | ||
213 | [27] = { .submit = 28, .complete = 153}, | ||
214 | [28] = { .submit = 29, .complete = 154}, | ||
215 | [29] = { .submit = 30, .complete = 155}, | ||
216 | }; | ||
217 | |||
218 | struct cppi_glue_infos { | ||
219 | irqreturn_t (*isr)(int irq, void *data); | ||
220 | const struct chan_queues *queues_rx; | ||
221 | const struct chan_queues *queues_tx; | ||
222 | struct chan_queues td_queue; | ||
223 | }; | ||
224 | |||
225 | static struct cppi41_channel *to_cpp41_chan(struct dma_chan *c) | ||
226 | { | ||
227 | return container_of(c, struct cppi41_channel, chan); | ||
228 | } | ||
229 | |||
230 | static struct cppi41_channel *desc_to_chan(struct cppi41_dd *cdd, u32 desc) | ||
231 | { | ||
232 | struct cppi41_channel *c; | ||
233 | u32 descs_size; | ||
234 | u32 desc_num; | ||
235 | |||
236 | descs_size = sizeof(struct cppi41_desc) * ALLOC_DECS_NUM; | ||
237 | |||
238 | if (!((desc >= cdd->descs_phys) && | ||
239 | (desc < (cdd->descs_phys + descs_size)))) { | ||
240 | return NULL; | ||
241 | } | ||
242 | |||
243 | desc_num = (desc - cdd->descs_phys) / sizeof(struct cppi41_desc); | ||
244 | BUG_ON(desc_num > ALLOC_DECS_NUM); | ||
245 | c = cdd->chan_busy[desc_num]; | ||
246 | cdd->chan_busy[desc_num] = NULL; | ||
247 | return c; | ||
248 | } | ||
249 | |||
250 | static void cppi_writel(u32 val, void *__iomem *mem) | ||
251 | { | ||
252 | __raw_writel(val, mem); | ||
253 | } | ||
254 | |||
255 | static u32 cppi_readl(void *__iomem *mem) | ||
256 | { | ||
257 | return __raw_readl(mem); | ||
258 | } | ||
259 | |||
260 | static u32 pd_trans_len(u32 val) | ||
261 | { | ||
262 | return val & ((1 << (DESC_LENGTH_BITS_NUM + 1)) - 1); | ||
263 | } | ||
264 | |||
265 | static irqreturn_t cppi41_irq(int irq, void *data) | ||
266 | { | ||
267 | struct cppi41_dd *cdd = data; | ||
268 | struct cppi41_channel *c; | ||
269 | u32 status; | ||
270 | int i; | ||
271 | |||
272 | status = cppi_readl(cdd->usbss_mem + USBSS_IRQ_STATUS); | ||
273 | if (!(status & USBSS_IRQ_PD_COMP)) | ||
274 | return IRQ_NONE; | ||
275 | cppi_writel(status, cdd->usbss_mem + USBSS_IRQ_STATUS); | ||
276 | |||
277 | for (i = QMGR_PENDING_SLOT_Q(FIST_COMPLETION_QUEUE); i < QMGR_NUM_PEND; | ||
278 | i++) { | ||
279 | u32 val; | ||
280 | u32 q_num; | ||
281 | |||
282 | val = cppi_readl(cdd->qmgr_mem + QMGR_PEND(i)); | ||
283 | if (i == QMGR_PENDING_SLOT_Q(FIST_COMPLETION_QUEUE) && val) { | ||
284 | u32 mask; | ||
285 | /* set corresponding bit for completetion Q 93 */ | ||
286 | mask = 1 << QMGR_PENDING_BIT_Q(FIST_COMPLETION_QUEUE); | ||
287 | /* not set all bits for queues less than Q 93 */ | ||
288 | mask--; | ||
289 | /* now invert and keep only Q 93+ set */ | ||
290 | val &= ~mask; | ||
291 | } | ||
292 | |||
293 | if (val) | ||
294 | __iormb(); | ||
295 | |||
296 | while (val) { | ||
297 | u32 desc; | ||
298 | |||
299 | q_num = __fls(val); | ||
300 | val &= ~(1 << q_num); | ||
301 | q_num += 32 * i; | ||
302 | desc = cppi_readl(cdd->qmgr_mem + QMGR_QUEUE_D(q_num)); | ||
303 | desc &= ~0x1f; | ||
304 | c = desc_to_chan(cdd, desc); | ||
305 | if (WARN_ON(!c)) { | ||
306 | pr_err("%s() q %d desc %08x\n", __func__, | ||
307 | q_num, desc); | ||
308 | continue; | ||
309 | } | ||
310 | c->residue = pd_trans_len(c->desc->pd6) - | ||
311 | pd_trans_len(c->desc->pd0); | ||
312 | |||
313 | dma_cookie_complete(&c->txd); | ||
314 | c->txd.callback(c->txd.callback_param); | ||
315 | } | ||
316 | } | ||
317 | return IRQ_HANDLED; | ||
318 | } | ||
319 | |||
320 | static dma_cookie_t cppi41_tx_submit(struct dma_async_tx_descriptor *tx) | ||
321 | { | ||
322 | dma_cookie_t cookie; | ||
323 | |||
324 | cookie = dma_cookie_assign(tx); | ||
325 | |||
326 | return cookie; | ||
327 | } | ||
328 | |||
329 | static int cppi41_dma_alloc_chan_resources(struct dma_chan *chan) | ||
330 | { | ||
331 | struct cppi41_channel *c = to_cpp41_chan(chan); | ||
332 | |||
333 | dma_cookie_init(chan); | ||
334 | dma_async_tx_descriptor_init(&c->txd, chan); | ||
335 | c->txd.tx_submit = cppi41_tx_submit; | ||
336 | |||
337 | if (!c->is_tx) | ||
338 | cppi_writel(c->q_num, c->gcr_reg + RXHPCRA0); | ||
339 | |||
340 | return 0; | ||
341 | } | ||
342 | |||
343 | static void cppi41_dma_free_chan_resources(struct dma_chan *chan) | ||
344 | { | ||
345 | } | ||
346 | |||
347 | static enum dma_status cppi41_dma_tx_status(struct dma_chan *chan, | ||
348 | dma_cookie_t cookie, struct dma_tx_state *txstate) | ||
349 | { | ||
350 | struct cppi41_channel *c = to_cpp41_chan(chan); | ||
351 | enum dma_status ret; | ||
352 | |||
353 | /* lock */ | ||
354 | ret = dma_cookie_status(chan, cookie, txstate); | ||
355 | if (txstate && ret == DMA_SUCCESS) | ||
356 | txstate->residue = c->residue; | ||
357 | /* unlock */ | ||
358 | |||
359 | return ret; | ||
360 | } | ||
361 | |||
362 | static void push_desc_queue(struct cppi41_channel *c) | ||
363 | { | ||
364 | struct cppi41_dd *cdd = c->cdd; | ||
365 | u32 desc_num; | ||
366 | u32 desc_phys; | ||
367 | u32 reg; | ||
368 | |||
369 | desc_phys = lower_32_bits(c->desc_phys); | ||
370 | desc_num = (desc_phys - cdd->descs_phys) / sizeof(struct cppi41_desc); | ||
371 | WARN_ON(cdd->chan_busy[desc_num]); | ||
372 | cdd->chan_busy[desc_num] = c; | ||
373 | |||
374 | reg = (sizeof(struct cppi41_desc) - 24) / 4; | ||
375 | reg |= desc_phys; | ||
376 | cppi_writel(reg, cdd->qmgr_mem + QMGR_QUEUE_D(c->q_num)); | ||
377 | } | ||
378 | |||
379 | static void cppi41_dma_issue_pending(struct dma_chan *chan) | ||
380 | { | ||
381 | struct cppi41_channel *c = to_cpp41_chan(chan); | ||
382 | u32 reg; | ||
383 | |||
384 | c->residue = 0; | ||
385 | |||
386 | reg = GCR_CHAN_ENABLE; | ||
387 | if (!c->is_tx) { | ||
388 | reg |= GCR_STARV_RETRY; | ||
389 | reg |= GCR_DESC_TYPE_HOST; | ||
390 | reg |= c->q_comp_num; | ||
391 | } | ||
392 | |||
393 | cppi_writel(reg, c->gcr_reg); | ||
394 | |||
395 | /* | ||
396 | * We don't use writel() but __raw_writel() so we have to make sure | ||
397 | * that the DMA descriptor in coherent memory made to the main memory | ||
398 | * before starting the dma engine. | ||
399 | */ | ||
400 | __iowmb(); | ||
401 | push_desc_queue(c); | ||
402 | } | ||
403 | |||
404 | static u32 get_host_pd0(u32 length) | ||
405 | { | ||
406 | u32 reg; | ||
407 | |||
408 | reg = DESC_TYPE_HOST << DESC_TYPE; | ||
409 | reg |= length; | ||
410 | |||
411 | return reg; | ||
412 | } | ||
413 | |||
414 | static u32 get_host_pd1(struct cppi41_channel *c) | ||
415 | { | ||
416 | u32 reg; | ||
417 | |||
418 | reg = 0; | ||
419 | |||
420 | return reg; | ||
421 | } | ||
422 | |||
423 | static u32 get_host_pd2(struct cppi41_channel *c) | ||
424 | { | ||
425 | u32 reg; | ||
426 | |||
427 | reg = DESC_TYPE_USB; | ||
428 | reg |= c->q_comp_num; | ||
429 | |||
430 | return reg; | ||
431 | } | ||
432 | |||
433 | static u32 get_host_pd3(u32 length) | ||
434 | { | ||
435 | u32 reg; | ||
436 | |||
437 | /* PD3 = packet size */ | ||
438 | reg = length; | ||
439 | |||
440 | return reg; | ||
441 | } | ||
442 | |||
443 | static u32 get_host_pd6(u32 length) | ||
444 | { | ||
445 | u32 reg; | ||
446 | |||
447 | /* PD6 buffer size */ | ||
448 | reg = DESC_PD_COMPLETE; | ||
449 | reg |= length; | ||
450 | |||
451 | return reg; | ||
452 | } | ||
453 | |||
454 | static u32 get_host_pd4_or_7(u32 addr) | ||
455 | { | ||
456 | u32 reg; | ||
457 | |||
458 | reg = addr; | ||
459 | |||
460 | return reg; | ||
461 | } | ||
462 | |||
463 | static u32 get_host_pd5(void) | ||
464 | { | ||
465 | u32 reg; | ||
466 | |||
467 | reg = 0; | ||
468 | |||
469 | return reg; | ||
470 | } | ||
471 | |||
472 | static struct dma_async_tx_descriptor *cppi41_dma_prep_slave_sg( | ||
473 | struct dma_chan *chan, struct scatterlist *sgl, unsigned sg_len, | ||
474 | enum dma_transfer_direction dir, unsigned long tx_flags, void *context) | ||
475 | { | ||
476 | struct cppi41_channel *c = to_cpp41_chan(chan); | ||
477 | struct cppi41_desc *d; | ||
478 | struct scatterlist *sg; | ||
479 | unsigned int i; | ||
480 | unsigned int num; | ||
481 | |||
482 | num = 0; | ||
483 | d = c->desc; | ||
484 | for_each_sg(sgl, sg, sg_len, i) { | ||
485 | u32 addr; | ||
486 | u32 len; | ||
487 | |||
488 | /* We need to use more than one desc once musb supports sg */ | ||
489 | BUG_ON(num > 0); | ||
490 | addr = lower_32_bits(sg_dma_address(sg)); | ||
491 | len = sg_dma_len(sg); | ||
492 | |||
493 | d->pd0 = get_host_pd0(len); | ||
494 | d->pd1 = get_host_pd1(c); | ||
495 | d->pd2 = get_host_pd2(c); | ||
496 | d->pd3 = get_host_pd3(len); | ||
497 | d->pd4 = get_host_pd4_or_7(addr); | ||
498 | d->pd5 = get_host_pd5(); | ||
499 | d->pd6 = get_host_pd6(len); | ||
500 | d->pd7 = get_host_pd4_or_7(addr); | ||
501 | |||
502 | d++; | ||
503 | } | ||
504 | |||
505 | return &c->txd; | ||
506 | } | ||
507 | |||
508 | static int cpp41_cfg_chan(struct cppi41_channel *c, | ||
509 | struct dma_slave_config *cfg) | ||
510 | { | ||
511 | return 0; | ||
512 | } | ||
513 | |||
514 | static void cppi41_compute_td_desc(struct cppi41_desc *d) | ||
515 | { | ||
516 | d->pd0 = DESC_TYPE_TEARD << DESC_TYPE; | ||
517 | } | ||
518 | |||
519 | static u32 cppi41_pop_desc(struct cppi41_dd *cdd, unsigned queue_num) | ||
520 | { | ||
521 | u32 desc; | ||
522 | |||
523 | desc = cppi_readl(cdd->qmgr_mem + QMGR_QUEUE_D(queue_num)); | ||
524 | desc &= ~0x1f; | ||
525 | return desc; | ||
526 | } | ||
527 | |||
528 | static int cppi41_tear_down_chan(struct cppi41_channel *c) | ||
529 | { | ||
530 | struct cppi41_dd *cdd = c->cdd; | ||
531 | struct cppi41_desc *td; | ||
532 | u32 reg; | ||
533 | u32 desc_phys; | ||
534 | u32 td_desc_phys; | ||
535 | |||
536 | td = cdd->cd; | ||
537 | td += cdd->first_td_desc; | ||
538 | |||
539 | td_desc_phys = cdd->descs_phys; | ||
540 | td_desc_phys += cdd->first_td_desc * sizeof(struct cppi41_desc); | ||
541 | |||
542 | if (!c->td_queued) { | ||
543 | cppi41_compute_td_desc(td); | ||
544 | __iowmb(); | ||
545 | |||
546 | reg = (sizeof(struct cppi41_desc) - 24) / 4; | ||
547 | reg |= td_desc_phys; | ||
548 | cppi_writel(reg, cdd->qmgr_mem + | ||
549 | QMGR_QUEUE_D(cdd->td_queue.submit)); | ||
550 | |||
551 | reg = GCR_CHAN_ENABLE; | ||
552 | if (!c->is_tx) { | ||
553 | reg |= GCR_STARV_RETRY; | ||
554 | reg |= GCR_DESC_TYPE_HOST; | ||
555 | reg |= c->q_comp_num; | ||
556 | } | ||
557 | reg |= GCR_TEARDOWN; | ||
558 | cppi_writel(reg, c->gcr_reg); | ||
559 | c->td_queued = 1; | ||
560 | c->td_retry = 100; | ||
561 | } | ||
562 | |||
563 | if (!c->td_seen) { | ||
564 | unsigned td_comp_queue; | ||
565 | |||
566 | if (c->is_tx) | ||
567 | td_comp_queue = cdd->td_queue.complete; | ||
568 | else | ||
569 | td_comp_queue = c->q_comp_num; | ||
570 | |||
571 | desc_phys = cppi41_pop_desc(cdd, td_comp_queue); | ||
572 | if (desc_phys) { | ||
573 | __iormb(); | ||
574 | |||
575 | if (desc_phys == td_desc_phys) { | ||
576 | u32 pd0; | ||
577 | pd0 = td->pd0; | ||
578 | WARN_ON((pd0 >> DESC_TYPE) != DESC_TYPE_TEARD); | ||
579 | WARN_ON(!c->is_tx && !(pd0 & TD_DESC_IS_RX)); | ||
580 | WARN_ON((pd0 & 0x1f) != c->port_num); | ||
581 | } else { | ||
582 | __WARN(); | ||
583 | } | ||
584 | c->td_seen = 1; | ||
585 | } | ||
586 | } | ||
587 | if (!c->td_desc_seen) { | ||
588 | desc_phys = cppi41_pop_desc(cdd, c->q_comp_num); | ||
589 | if (desc_phys) { | ||
590 | __iormb(); | ||
591 | WARN_ON(c->desc_phys != desc_phys); | ||
592 | c->td_desc_seen = 1; | ||
593 | } | ||
594 | } | ||
595 | c->td_retry--; | ||
596 | /* | ||
597 | * If the TX descriptor / channel is in use, the caller needs to poke | ||
598 | * his TD bit multiple times. After that he hardware releases the | ||
599 | * transfer descriptor followed by TD descriptor. Waiting seems not to | ||
600 | * cause any difference. | ||
601 | * RX seems to be thrown out right away. However once the TearDown | ||
602 | * descriptor gets through we are done. If we have seens the transfer | ||
603 | * descriptor before the TD we fetch it from enqueue, it has to be | ||
604 | * there waiting for us. | ||
605 | */ | ||
606 | if (!c->td_seen && c->td_retry) | ||
607 | return -EAGAIN; | ||
608 | |||
609 | WARN_ON(!c->td_retry); | ||
610 | if (!c->td_desc_seen) { | ||
611 | desc_phys = cppi_readl(cdd->qmgr_mem + QMGR_QUEUE_D(c->q_num)); | ||
612 | WARN_ON(!desc_phys); | ||
613 | } | ||
614 | |||
615 | c->td_queued = 0; | ||
616 | c->td_seen = 0; | ||
617 | c->td_desc_seen = 0; | ||
618 | cppi_writel(0, c->gcr_reg); | ||
619 | return 0; | ||
620 | } | ||
621 | |||
622 | static int cppi41_stop_chan(struct dma_chan *chan) | ||
623 | { | ||
624 | struct cppi41_channel *c = to_cpp41_chan(chan); | ||
625 | struct cppi41_dd *cdd = c->cdd; | ||
626 | u32 desc_num; | ||
627 | u32 desc_phys; | ||
628 | int ret; | ||
629 | |||
630 | ret = cppi41_tear_down_chan(c); | ||
631 | if (ret) | ||
632 | return ret; | ||
633 | |||
634 | desc_phys = lower_32_bits(c->desc_phys); | ||
635 | desc_num = (desc_phys - cdd->descs_phys) / sizeof(struct cppi41_desc); | ||
636 | WARN_ON(!cdd->chan_busy[desc_num]); | ||
637 | cdd->chan_busy[desc_num] = NULL; | ||
638 | |||
639 | return 0; | ||
640 | } | ||
641 | |||
642 | static int cppi41_dma_control(struct dma_chan *chan, enum dma_ctrl_cmd cmd, | ||
643 | unsigned long arg) | ||
644 | { | ||
645 | struct cppi41_channel *c = to_cpp41_chan(chan); | ||
646 | int ret; | ||
647 | |||
648 | switch (cmd) { | ||
649 | case DMA_SLAVE_CONFIG: | ||
650 | ret = cpp41_cfg_chan(c, (struct dma_slave_config *) arg); | ||
651 | break; | ||
652 | |||
653 | case DMA_TERMINATE_ALL: | ||
654 | ret = cppi41_stop_chan(chan); | ||
655 | break; | ||
656 | |||
657 | default: | ||
658 | ret = -ENXIO; | ||
659 | break; | ||
660 | } | ||
661 | return ret; | ||
662 | } | ||
663 | |||
664 | static void cleanup_chans(struct cppi41_dd *cdd) | ||
665 | { | ||
666 | while (!list_empty(&cdd->ddev.channels)) { | ||
667 | struct cppi41_channel *cchan; | ||
668 | |||
669 | cchan = list_first_entry(&cdd->ddev.channels, | ||
670 | struct cppi41_channel, chan.device_node); | ||
671 | list_del(&cchan->chan.device_node); | ||
672 | kfree(cchan); | ||
673 | } | ||
674 | } | ||
675 | |||
676 | static int cppi41_add_chans(struct platform_device *pdev, struct cppi41_dd *cdd) | ||
677 | { | ||
678 | struct cppi41_channel *cchan; | ||
679 | int i; | ||
680 | int ret; | ||
681 | u32 n_chans; | ||
682 | |||
683 | ret = of_property_read_u32(pdev->dev.of_node, "#dma-channels", | ||
684 | &n_chans); | ||
685 | if (ret) | ||
686 | return ret; | ||
687 | /* | ||
688 | * The channels can only be used as TX or as RX. So we add twice | ||
689 | * that much dma channels because USB can only do RX or TX. | ||
690 | */ | ||
691 | n_chans *= 2; | ||
692 | |||
693 | for (i = 0; i < n_chans; i++) { | ||
694 | cchan = kzalloc(sizeof(*cchan), GFP_KERNEL); | ||
695 | if (!cchan) | ||
696 | goto err; | ||
697 | |||
698 | cchan->cdd = cdd; | ||
699 | if (i & 1) { | ||
700 | cchan->gcr_reg = cdd->ctrl_mem + DMA_TXGCR(i >> 1); | ||
701 | cchan->is_tx = 1; | ||
702 | } else { | ||
703 | cchan->gcr_reg = cdd->ctrl_mem + DMA_RXGCR(i >> 1); | ||
704 | cchan->is_tx = 0; | ||
705 | } | ||
706 | cchan->port_num = i >> 1; | ||
707 | cchan->desc = &cdd->cd[i]; | ||
708 | cchan->desc_phys = cdd->descs_phys; | ||
709 | cchan->desc_phys += i * sizeof(struct cppi41_desc); | ||
710 | cchan->chan.device = &cdd->ddev; | ||
711 | list_add_tail(&cchan->chan.device_node, &cdd->ddev.channels); | ||
712 | } | ||
713 | cdd->first_td_desc = n_chans; | ||
714 | |||
715 | return 0; | ||
716 | err: | ||
717 | cleanup_chans(cdd); | ||
718 | return -ENOMEM; | ||
719 | } | ||
720 | |||
721 | static void purge_descs(struct platform_device *pdev, struct cppi41_dd *cdd) | ||
722 | { | ||
723 | unsigned int mem_decs; | ||
724 | int i; | ||
725 | |||
726 | mem_decs = ALLOC_DECS_NUM * sizeof(struct cppi41_desc); | ||
727 | |||
728 | for (i = 0; i < DESCS_AREAS; i++) { | ||
729 | |||
730 | cppi_writel(0, cdd->qmgr_mem + QMGR_MEMBASE(i)); | ||
731 | cppi_writel(0, cdd->qmgr_mem + QMGR_MEMCTRL(i)); | ||
732 | |||
733 | dma_free_coherent(&pdev->dev, mem_decs, cdd->cd, | ||
734 | cdd->descs_phys); | ||
735 | } | ||
736 | } | ||
737 | |||
738 | static void disable_sched(struct cppi41_dd *cdd) | ||
739 | { | ||
740 | cppi_writel(0, cdd->sched_mem + DMA_SCHED_CTRL); | ||
741 | } | ||
742 | |||
743 | static void deinit_cpii41(struct platform_device *pdev, struct cppi41_dd *cdd) | ||
744 | { | ||
745 | disable_sched(cdd); | ||
746 | |||
747 | purge_descs(pdev, cdd); | ||
748 | |||
749 | cppi_writel(0, cdd->qmgr_mem + QMGR_LRAM0_BASE); | ||
750 | cppi_writel(0, cdd->qmgr_mem + QMGR_LRAM0_BASE); | ||
751 | dma_free_coherent(&pdev->dev, QMGR_SCRATCH_SIZE, cdd->qmgr_scratch, | ||
752 | cdd->scratch_phys); | ||
753 | } | ||
754 | |||
755 | static int init_descs(struct platform_device *pdev, struct cppi41_dd *cdd) | ||
756 | { | ||
757 | unsigned int desc_size; | ||
758 | unsigned int mem_decs; | ||
759 | int i; | ||
760 | u32 reg; | ||
761 | u32 idx; | ||
762 | |||
763 | BUILD_BUG_ON(sizeof(struct cppi41_desc) & | ||
764 | (sizeof(struct cppi41_desc) - 1)); | ||
765 | BUILD_BUG_ON(sizeof(struct cppi41_desc) < 32); | ||
766 | BUILD_BUG_ON(ALLOC_DECS_NUM < 32); | ||
767 | |||
768 | desc_size = sizeof(struct cppi41_desc); | ||
769 | mem_decs = ALLOC_DECS_NUM * desc_size; | ||
770 | |||
771 | idx = 0; | ||
772 | for (i = 0; i < DESCS_AREAS; i++) { | ||
773 | |||
774 | reg = idx << QMGR_MEMCTRL_IDX_SH; | ||
775 | reg |= (ilog2(desc_size) - 5) << QMGR_MEMCTRL_DESC_SH; | ||
776 | reg |= ilog2(ALLOC_DECS_NUM) - 5; | ||
777 | |||
778 | BUILD_BUG_ON(DESCS_AREAS != 1); | ||
779 | cdd->cd = dma_alloc_coherent(&pdev->dev, mem_decs, | ||
780 | &cdd->descs_phys, GFP_KERNEL); | ||
781 | if (!cdd->cd) | ||
782 | return -ENOMEM; | ||
783 | |||
784 | cppi_writel(cdd->descs_phys, cdd->qmgr_mem + QMGR_MEMBASE(i)); | ||
785 | cppi_writel(reg, cdd->qmgr_mem + QMGR_MEMCTRL(i)); | ||
786 | |||
787 | idx += ALLOC_DECS_NUM; | ||
788 | } | ||
789 | return 0; | ||
790 | } | ||
791 | |||
792 | static void init_sched(struct cppi41_dd *cdd) | ||
793 | { | ||
794 | unsigned ch; | ||
795 | unsigned word; | ||
796 | u32 reg; | ||
797 | |||
798 | word = 0; | ||
799 | cppi_writel(0, cdd->sched_mem + DMA_SCHED_CTRL); | ||
800 | for (ch = 0; ch < 15 * 2; ch += 2) { | ||
801 | |||
802 | reg = SCHED_ENTRY0_CHAN(ch); | ||
803 | reg |= SCHED_ENTRY1_CHAN(ch) | SCHED_ENTRY1_IS_RX; | ||
804 | |||
805 | reg |= SCHED_ENTRY2_CHAN(ch + 1); | ||
806 | reg |= SCHED_ENTRY3_CHAN(ch + 1) | SCHED_ENTRY3_IS_RX; | ||
807 | cppi_writel(reg, cdd->sched_mem + DMA_SCHED_WORD(word)); | ||
808 | word++; | ||
809 | } | ||
810 | reg = 15 * 2 * 2 - 1; | ||
811 | reg |= DMA_SCHED_CTRL_EN; | ||
812 | cppi_writel(reg, cdd->sched_mem + DMA_SCHED_CTRL); | ||
813 | } | ||
814 | |||
815 | static int init_cppi41(struct platform_device *pdev, struct cppi41_dd *cdd) | ||
816 | { | ||
817 | int ret; | ||
818 | |||
819 | BUILD_BUG_ON(QMGR_SCRATCH_SIZE > ((1 << 14) - 1)); | ||
820 | cdd->qmgr_scratch = dma_alloc_coherent(&pdev->dev, QMGR_SCRATCH_SIZE, | ||
821 | &cdd->scratch_phys, GFP_KERNEL); | ||
822 | if (!cdd->qmgr_scratch) | ||
823 | return -ENOMEM; | ||
824 | |||
825 | cppi_writel(cdd->scratch_phys, cdd->qmgr_mem + QMGR_LRAM0_BASE); | ||
826 | cppi_writel(QMGR_SCRATCH_SIZE, cdd->qmgr_mem + QMGR_LRAM_SIZE); | ||
827 | cppi_writel(0, cdd->qmgr_mem + QMGR_LRAM1_BASE); | ||
828 | |||
829 | ret = init_descs(pdev, cdd); | ||
830 | if (ret) | ||
831 | goto err_td; | ||
832 | |||
833 | cppi_writel(cdd->td_queue.submit, cdd->ctrl_mem + DMA_TDFDQ); | ||
834 | init_sched(cdd); | ||
835 | return 0; | ||
836 | err_td: | ||
837 | deinit_cpii41(pdev, cdd); | ||
838 | return ret; | ||
839 | } | ||
840 | |||
841 | static struct platform_driver cpp41_dma_driver; | ||
842 | /* | ||
843 | * The param format is: | ||
844 | * X Y | ||
845 | * X: Port | ||
846 | * Y: 0 = RX else TX | ||
847 | */ | ||
848 | #define INFO_PORT 0 | ||
849 | #define INFO_IS_TX 1 | ||
850 | |||
851 | static bool cpp41_dma_filter_fn(struct dma_chan *chan, void *param) | ||
852 | { | ||
853 | struct cppi41_channel *cchan; | ||
854 | struct cppi41_dd *cdd; | ||
855 | const struct chan_queues *queues; | ||
856 | u32 *num = param; | ||
857 | |||
858 | if (chan->device->dev->driver != &cpp41_dma_driver.driver) | ||
859 | return false; | ||
860 | |||
861 | cchan = to_cpp41_chan(chan); | ||
862 | |||
863 | if (cchan->port_num != num[INFO_PORT]) | ||
864 | return false; | ||
865 | |||
866 | if (cchan->is_tx && !num[INFO_IS_TX]) | ||
867 | return false; | ||
868 | cdd = cchan->cdd; | ||
869 | if (cchan->is_tx) | ||
870 | queues = cdd->queues_tx; | ||
871 | else | ||
872 | queues = cdd->queues_rx; | ||
873 | |||
874 | BUILD_BUG_ON(ARRAY_SIZE(usb_queues_rx) != ARRAY_SIZE(usb_queues_tx)); | ||
875 | if (WARN_ON(cchan->port_num > ARRAY_SIZE(usb_queues_rx))) | ||
876 | return false; | ||
877 | |||
878 | cchan->q_num = queues[cchan->port_num].submit; | ||
879 | cchan->q_comp_num = queues[cchan->port_num].complete; | ||
880 | return true; | ||
881 | } | ||
882 | |||
883 | static struct of_dma_filter_info cpp41_dma_info = { | ||
884 | .filter_fn = cpp41_dma_filter_fn, | ||
885 | }; | ||
886 | |||
887 | static struct dma_chan *cppi41_dma_xlate(struct of_phandle_args *dma_spec, | ||
888 | struct of_dma *ofdma) | ||
889 | { | ||
890 | int count = dma_spec->args_count; | ||
891 | struct of_dma_filter_info *info = ofdma->of_dma_data; | ||
892 | |||
893 | if (!info || !info->filter_fn) | ||
894 | return NULL; | ||
895 | |||
896 | if (count != 2) | ||
897 | return NULL; | ||
898 | |||
899 | return dma_request_channel(info->dma_cap, info->filter_fn, | ||
900 | &dma_spec->args[0]); | ||
901 | } | ||
902 | |||
903 | static const struct cppi_glue_infos usb_infos = { | ||
904 | .isr = cppi41_irq, | ||
905 | .queues_rx = usb_queues_rx, | ||
906 | .queues_tx = usb_queues_tx, | ||
907 | .td_queue = { .submit = 31, .complete = 0 }, | ||
908 | }; | ||
909 | |||
910 | static const struct of_device_id cppi41_dma_ids[] = { | ||
911 | { .compatible = "ti,am3359-cppi41", .data = &usb_infos}, | ||
912 | {}, | ||
913 | }; | ||
914 | MODULE_DEVICE_TABLE(of, cppi41_dma_ids); | ||
915 | |||
916 | static const struct cppi_glue_infos *get_glue_info(struct platform_device *pdev) | ||
917 | { | ||
918 | const struct of_device_id *of_id; | ||
919 | |||
920 | of_id = of_match_node(cppi41_dma_ids, pdev->dev.of_node); | ||
921 | if (!of_id) | ||
922 | return NULL; | ||
923 | return of_id->data; | ||
924 | } | ||
925 | |||
926 | static int cppi41_dma_probe(struct platform_device *pdev) | ||
927 | { | ||
928 | struct cppi41_dd *cdd; | ||
929 | const struct cppi_glue_infos *glue_info; | ||
930 | int irq; | ||
931 | int ret; | ||
932 | |||
933 | glue_info = get_glue_info(pdev); | ||
934 | if (!glue_info) | ||
935 | return -EINVAL; | ||
936 | |||
937 | cdd = kzalloc(sizeof(*cdd), GFP_KERNEL); | ||
938 | if (!cdd) | ||
939 | return -ENOMEM; | ||
940 | |||
941 | dma_cap_set(DMA_SLAVE, cdd->ddev.cap_mask); | ||
942 | cdd->ddev.device_alloc_chan_resources = cppi41_dma_alloc_chan_resources; | ||
943 | cdd->ddev.device_free_chan_resources = cppi41_dma_free_chan_resources; | ||
944 | cdd->ddev.device_tx_status = cppi41_dma_tx_status; | ||
945 | cdd->ddev.device_issue_pending = cppi41_dma_issue_pending; | ||
946 | cdd->ddev.device_prep_slave_sg = cppi41_dma_prep_slave_sg; | ||
947 | cdd->ddev.device_control = cppi41_dma_control; | ||
948 | cdd->ddev.dev = &pdev->dev; | ||
949 | INIT_LIST_HEAD(&cdd->ddev.channels); | ||
950 | cpp41_dma_info.dma_cap = cdd->ddev.cap_mask; | ||
951 | |||
952 | cdd->usbss_mem = of_iomap(pdev->dev.of_node, 0); | ||
953 | cdd->ctrl_mem = of_iomap(pdev->dev.of_node, 1); | ||
954 | cdd->sched_mem = of_iomap(pdev->dev.of_node, 2); | ||
955 | cdd->qmgr_mem = of_iomap(pdev->dev.of_node, 3); | ||
956 | |||
957 | if (!cdd->usbss_mem || !cdd->ctrl_mem || !cdd->sched_mem || | ||
958 | !cdd->qmgr_mem) { | ||
959 | ret = -ENXIO; | ||
960 | goto err_remap; | ||
961 | } | ||
962 | |||
963 | cdd->queues_rx = glue_info->queues_rx; | ||
964 | cdd->queues_tx = glue_info->queues_tx; | ||
965 | cdd->td_queue = glue_info->td_queue; | ||
966 | |||
967 | ret = init_cppi41(pdev, cdd); | ||
968 | if (ret) | ||
969 | goto err_init_cppi; | ||
970 | |||
971 | ret = cppi41_add_chans(pdev, cdd); | ||
972 | if (ret) | ||
973 | goto err_chans; | ||
974 | |||
975 | irq = irq_of_parse_and_map(pdev->dev.of_node, 0); | ||
976 | if (!irq) | ||
977 | goto err_irq; | ||
978 | |||
979 | cppi_writel(USBSS_IRQ_PD_COMP, cdd->usbss_mem + USBSS_IRQ_ENABLER); | ||
980 | |||
981 | ret = request_irq(irq, glue_info->isr, IRQF_SHARED, | ||
982 | dev_name(&pdev->dev), cdd); | ||
983 | if (ret) | ||
984 | goto err_irq; | ||
985 | cdd->irq = irq; | ||
986 | |||
987 | ret = dma_async_device_register(&cdd->ddev); | ||
988 | if (ret) | ||
989 | goto err_dma_reg; | ||
990 | |||
991 | ret = of_dma_controller_register(pdev->dev.of_node, | ||
992 | cppi41_dma_xlate, &cpp41_dma_info); | ||
993 | if (ret) | ||
994 | goto err_of; | ||
995 | |||
996 | platform_set_drvdata(pdev, cdd); | ||
997 | return 0; | ||
998 | err_of: | ||
999 | dma_async_device_unregister(&cdd->ddev); | ||
1000 | err_dma_reg: | ||
1001 | free_irq(irq, cdd); | ||
1002 | err_irq: | ||
1003 | cppi_writel(0, cdd->usbss_mem + USBSS_IRQ_CLEARR); | ||
1004 | cleanup_chans(cdd); | ||
1005 | err_chans: | ||
1006 | deinit_cpii41(pdev, cdd); | ||
1007 | err_init_cppi: | ||
1008 | iounmap(cdd->usbss_mem); | ||
1009 | iounmap(cdd->ctrl_mem); | ||
1010 | iounmap(cdd->sched_mem); | ||
1011 | iounmap(cdd->qmgr_mem); | ||
1012 | err_remap: | ||
1013 | kfree(cdd); | ||
1014 | return ret; | ||
1015 | } | ||
1016 | |||
1017 | static int cppi41_dma_remove(struct platform_device *pdev) | ||
1018 | { | ||
1019 | struct cppi41_dd *cdd = platform_get_drvdata(pdev); | ||
1020 | |||
1021 | of_dma_controller_free(pdev->dev.of_node); | ||
1022 | dma_async_device_unregister(&cdd->ddev); | ||
1023 | |||
1024 | cppi_writel(0, cdd->usbss_mem + USBSS_IRQ_CLEARR); | ||
1025 | free_irq(cdd->irq, cdd); | ||
1026 | cleanup_chans(cdd); | ||
1027 | deinit_cpii41(pdev, cdd); | ||
1028 | iounmap(cdd->usbss_mem); | ||
1029 | iounmap(cdd->ctrl_mem); | ||
1030 | iounmap(cdd->sched_mem); | ||
1031 | iounmap(cdd->qmgr_mem); | ||
1032 | kfree(cdd); | ||
1033 | return 0; | ||
1034 | } | ||
1035 | |||
1036 | static struct platform_driver cpp41_dma_driver = { | ||
1037 | .probe = cppi41_dma_probe, | ||
1038 | .remove = cppi41_dma_remove, | ||
1039 | .driver = { | ||
1040 | .name = "cppi41-dma-engine", | ||
1041 | .owner = THIS_MODULE, | ||
1042 | .of_match_table = of_match_ptr(cppi41_dma_ids), | ||
1043 | }, | ||
1044 | }; | ||
1045 | |||
1046 | module_platform_driver(cpp41_dma_driver); | ||
1047 | MODULE_LICENSE("GPL"); | ||
1048 | MODULE_AUTHOR("Sebastian Andrzej Siewior <bigeasy@linutronix.de>"); | ||
diff --git a/drivers/usb/Makefile b/drivers/usb/Makefile index 5460abf045de..70d7c5b92c3c 100644 --- a/drivers/usb/Makefile +++ b/drivers/usb/Makefile | |||
@@ -46,7 +46,7 @@ obj-$(CONFIG_USB_MICROTEK) += image/ | |||
46 | obj-$(CONFIG_USB_SERIAL) += serial/ | 46 | obj-$(CONFIG_USB_SERIAL) += serial/ |
47 | 47 | ||
48 | obj-$(CONFIG_USB) += misc/ | 48 | obj-$(CONFIG_USB) += misc/ |
49 | obj-$(CONFIG_USB_PHY) += phy/ | 49 | obj-$(CONFIG_USB_SUPPORT) += phy/ |
50 | obj-$(CONFIG_EARLY_PRINTK_DBGP) += early/ | 50 | obj-$(CONFIG_EARLY_PRINTK_DBGP) += early/ |
51 | 51 | ||
52 | obj-$(CONFIG_USB_ATM) += atm/ | 52 | obj-$(CONFIG_USB_ATM) += atm/ |
diff --git a/drivers/usb/chipidea/host.c b/drivers/usb/chipidea/host.c index 40d0fda4f66c..9b3aaf132bc3 100644 --- a/drivers/usb/chipidea/host.c +++ b/drivers/usb/chipidea/host.c | |||
@@ -63,6 +63,7 @@ static int host_start(struct ci_hdrc *ci) | |||
63 | ehci = hcd_to_ehci(hcd); | 63 | ehci = hcd_to_ehci(hcd); |
64 | ehci->caps = ci->hw_bank.cap; | 64 | ehci->caps = ci->hw_bank.cap; |
65 | ehci->has_hostpc = ci->hw_bank.lpm; | 65 | ehci->has_hostpc = ci->hw_bank.lpm; |
66 | ehci->has_tdi_phy_lpm = ci->hw_bank.lpm; | ||
66 | 67 | ||
67 | ret = usb_add_hcd(hcd, 0, 0); | 68 | ret = usb_add_hcd(hcd, 0, 0); |
68 | if (ret) | 69 | if (ret) |
diff --git a/drivers/usb/dwc3/Kconfig b/drivers/usb/dwc3/Kconfig index 2378958ea63e..3e225d5846f6 100644 --- a/drivers/usb/dwc3/Kconfig +++ b/drivers/usb/dwc3/Kconfig | |||
@@ -40,6 +40,38 @@ config USB_DWC3_DUAL_ROLE | |||
40 | 40 | ||
41 | endchoice | 41 | endchoice |
42 | 42 | ||
43 | comment "Platform Glue Driver Support" | ||
44 | |||
45 | config USB_DWC3_OMAP | ||
46 | tristate "Texas Instruments OMAP5 and similar Platforms" | ||
47 | depends on EXTCON | ||
48 | default USB_DWC3 | ||
49 | help | ||
50 | Some platforms from Texas Instruments like OMAP5, DRA7xxx and | ||
51 | AM437x use this IP for USB2/3 functionality. | ||
52 | |||
53 | Say 'Y' or 'M' here if you have one such device | ||
54 | |||
55 | config USB_DWC3_EXYNOS | ||
56 | tristate "Samsung Exynos Platform" | ||
57 | default USB_DWC3 | ||
58 | help | ||
59 | Recent Exynos5 SoCs ship with one DesignWare Core USB3 IP inside, | ||
60 | say 'Y' or 'M' if you have one such device. | ||
61 | |||
62 | config USB_DWC3_PCI | ||
63 | tristate "PCIe-based Platforms" | ||
64 | depends on PCI | ||
65 | default USB_DWC3 | ||
66 | help | ||
67 | If you're using the DesignWare Core IP with a PCIe, please say | ||
68 | 'Y' or 'M' here. | ||
69 | |||
70 | One such PCIe-based platform is Synopsys' PCIe HAPS model of | ||
71 | this IP. | ||
72 | |||
73 | comment "Debugging features" | ||
74 | |||
43 | config USB_DWC3_DEBUG | 75 | config USB_DWC3_DEBUG |
44 | bool "Enable Debugging Messages" | 76 | bool "Enable Debugging Messages" |
45 | help | 77 | help |
diff --git a/drivers/usb/dwc3/Makefile b/drivers/usb/dwc3/Makefile index 0c7ac92582be..dd1760145c46 100644 --- a/drivers/usb/dwc3/Makefile +++ b/drivers/usb/dwc3/Makefile | |||
@@ -27,15 +27,8 @@ endif | |||
27 | # the entire driver (with all its glue layers) on several architectures | 27 | # the entire driver (with all its glue layers) on several architectures |
28 | # and make sure it compiles fine. This will also help with allmodconfig | 28 | # and make sure it compiles fine. This will also help with allmodconfig |
29 | # and allyesconfig builds. | 29 | # and allyesconfig builds. |
30 | # | ||
31 | # The only exception is the PCI glue layer, but that's only because | ||
32 | # PCI doesn't provide nops if CONFIG_PCI isn't enabled. | ||
33 | ## | 30 | ## |
34 | 31 | ||
35 | obj-$(CONFIG_USB_DWC3) += dwc3-omap.o | 32 | obj-$(CONFIG_USB_DWC3_OMAP) += dwc3-omap.o |
36 | obj-$(CONFIG_USB_DWC3) += dwc3-exynos.o | 33 | obj-$(CONFIG_USB_DWC3_EXYNOS) += dwc3-exynos.o |
37 | 34 | obj-$(CONFIG_USB_DWC3_PCI) += dwc3-pci.o | |
38 | ifneq ($(CONFIG_PCI),) | ||
39 | obj-$(CONFIG_USB_DWC3) += dwc3-pci.o | ||
40 | endif | ||
41 | |||
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 358375e0b291..3ff6f0ad01df 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c | |||
@@ -6,34 +6,17 @@ | |||
6 | * Authors: Felipe Balbi <balbi@ti.com>, | 6 | * Authors: Felipe Balbi <balbi@ti.com>, |
7 | * Sebastian Andrzej Siewior <bigeasy@linutronix.de> | 7 | * Sebastian Andrzej Siewior <bigeasy@linutronix.de> |
8 | * | 8 | * |
9 | * Redistribution and use in source and binary forms, with or without | 9 | * This program is free software: you can redistribute it and/or modify |
10 | * modification, are permitted provided that the following conditions | 10 | * it under the terms of the GNU General Public License version 2 of |
11 | * are met: | 11 | * the License as published by the Free Software Foundation. |
12 | * 1. Redistributions of source code must retain the above copyright | ||
13 | * notice, this list of conditions, and the following disclaimer, | ||
14 | * without modification. | ||
15 | * 2. Redistributions in binary form must reproduce the above copyright | ||
16 | * notice, this list of conditions and the following disclaimer in the | ||
17 | * documentation and/or other materials provided with the distribution. | ||
18 | * 3. The names of the above-listed copyright holders may not be used | ||
19 | * to endorse or promote products derived from this software without | ||
20 | * specific prior written permission. | ||
21 | * | 12 | * |
22 | * ALTERNATIVELY, this software may be distributed under the terms of the | 13 | * This program is distributed in the hope that it will be useful, |
23 | * GNU General Public License ("GPL") version 2, as published by the Free | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
24 | * Software Foundation. | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | * GNU General Public License for more details. | ||
25 | * | 17 | * |
26 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS | 18 | * You should have received a copy of the GNU General Public License |
27 | * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | 19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
28 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
29 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | ||
30 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
31 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
32 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
33 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
34 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
35 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
36 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
37 | */ | 20 | */ |
38 | 21 | ||
39 | #include <linux/module.h> | 22 | #include <linux/module.h> |
@@ -53,17 +36,16 @@ | |||
53 | #include <linux/usb/otg.h> | 36 | #include <linux/usb/otg.h> |
54 | #include <linux/usb/ch9.h> | 37 | #include <linux/usb/ch9.h> |
55 | #include <linux/usb/gadget.h> | 38 | #include <linux/usb/gadget.h> |
39 | #include <linux/usb/of.h> | ||
40 | #include <linux/usb/otg.h> | ||
56 | 41 | ||
42 | #include "platform_data.h" | ||
57 | #include "core.h" | 43 | #include "core.h" |
58 | #include "gadget.h" | 44 | #include "gadget.h" |
59 | #include "io.h" | 45 | #include "io.h" |
60 | 46 | ||
61 | #include "debug.h" | 47 | #include "debug.h" |
62 | 48 | ||
63 | static char *maximum_speed = "super"; | ||
64 | module_param(maximum_speed, charp, 0); | ||
65 | MODULE_PARM_DESC(maximum_speed, "Maximum supported speed."); | ||
66 | |||
67 | /* -------------------------------------------------------------------------- */ | 49 | /* -------------------------------------------------------------------------- */ |
68 | 50 | ||
69 | void dwc3_set_mode(struct dwc3 *dwc, u32 mode) | 51 | void dwc3_set_mode(struct dwc3 *dwc, u32 mode) |
@@ -236,7 +218,7 @@ static int dwc3_event_buffers_setup(struct dwc3 *dwc) | |||
236 | dwc3_writel(dwc->regs, DWC3_GEVNTADRHI(n), | 218 | dwc3_writel(dwc->regs, DWC3_GEVNTADRHI(n), |
237 | upper_32_bits(evt->dma)); | 219 | upper_32_bits(evt->dma)); |
238 | dwc3_writel(dwc->regs, DWC3_GEVNTSIZ(n), | 220 | dwc3_writel(dwc->regs, DWC3_GEVNTSIZ(n), |
239 | evt->length & 0xffff); | 221 | DWC3_GEVNTSIZ_SIZE(evt->length)); |
240 | dwc3_writel(dwc->regs, DWC3_GEVNTCOUNT(n), 0); | 222 | dwc3_writel(dwc->regs, DWC3_GEVNTCOUNT(n), 0); |
241 | } | 223 | } |
242 | 224 | ||
@@ -255,7 +237,8 @@ static void dwc3_event_buffers_cleanup(struct dwc3 *dwc) | |||
255 | 237 | ||
256 | dwc3_writel(dwc->regs, DWC3_GEVNTADRLO(n), 0); | 238 | dwc3_writel(dwc->regs, DWC3_GEVNTADRLO(n), 0); |
257 | dwc3_writel(dwc->regs, DWC3_GEVNTADRHI(n), 0); | 239 | dwc3_writel(dwc->regs, DWC3_GEVNTADRHI(n), 0); |
258 | dwc3_writel(dwc->regs, DWC3_GEVNTSIZ(n), 0); | 240 | dwc3_writel(dwc->regs, DWC3_GEVNTSIZ(n), DWC3_GEVNTSIZ_INTMASK |
241 | | DWC3_GEVNTSIZ_SIZE(0)); | ||
259 | dwc3_writel(dwc->regs, DWC3_GEVNTCOUNT(n), 0); | 242 | dwc3_writel(dwc->regs, DWC3_GEVNTCOUNT(n), 0); |
260 | } | 243 | } |
261 | } | 244 | } |
@@ -367,18 +350,17 @@ static void dwc3_core_exit(struct dwc3 *dwc) | |||
367 | 350 | ||
368 | static int dwc3_probe(struct platform_device *pdev) | 351 | static int dwc3_probe(struct platform_device *pdev) |
369 | { | 352 | { |
370 | struct device_node *node = pdev->dev.of_node; | 353 | struct device *dev = &pdev->dev; |
354 | struct dwc3_platform_data *pdata = dev_get_platdata(dev); | ||
355 | struct device_node *node = dev->of_node; | ||
371 | struct resource *res; | 356 | struct resource *res; |
372 | struct dwc3 *dwc; | 357 | struct dwc3 *dwc; |
373 | struct device *dev = &pdev->dev; | ||
374 | 358 | ||
375 | int ret = -ENOMEM; | 359 | int ret = -ENOMEM; |
376 | 360 | ||
377 | void __iomem *regs; | 361 | void __iomem *regs; |
378 | void *mem; | 362 | void *mem; |
379 | 363 | ||
380 | u8 mode; | ||
381 | |||
382 | mem = devm_kzalloc(dev, sizeof(*dwc) + DWC3_ALIGN_MASK, GFP_KERNEL); | 364 | mem = devm_kzalloc(dev, sizeof(*dwc) + DWC3_ALIGN_MASK, GFP_KERNEL); |
383 | if (!mem) { | 365 | if (!mem) { |
384 | dev_err(dev, "not enough memory\n"); | 366 | dev_err(dev, "not enough memory\n"); |
@@ -402,38 +384,29 @@ static int dwc3_probe(struct platform_device *pdev) | |||
402 | dev_err(dev, "missing memory resource\n"); | 384 | dev_err(dev, "missing memory resource\n"); |
403 | return -ENODEV; | 385 | return -ENODEV; |
404 | } | 386 | } |
405 | dwc->xhci_resources[0].start = res->start; | ||
406 | dwc->xhci_resources[0].end = dwc->xhci_resources[0].start + | ||
407 | DWC3_XHCI_REGS_END; | ||
408 | dwc->xhci_resources[0].flags = res->flags; | ||
409 | dwc->xhci_resources[0].name = res->name; | ||
410 | |||
411 | /* | ||
412 | * Request memory region but exclude xHCI regs, | ||
413 | * since it will be requested by the xhci-plat driver. | ||
414 | */ | ||
415 | res = devm_request_mem_region(dev, res->start + DWC3_GLOBALS_REGS_START, | ||
416 | resource_size(res) - DWC3_GLOBALS_REGS_START, | ||
417 | dev_name(dev)); | ||
418 | if (!res) { | ||
419 | dev_err(dev, "can't request mem region\n"); | ||
420 | return -ENOMEM; | ||
421 | } | ||
422 | |||
423 | regs = devm_ioremap_nocache(dev, res->start, resource_size(res)); | ||
424 | if (!regs) { | ||
425 | dev_err(dev, "ioremap failed\n"); | ||
426 | return -ENOMEM; | ||
427 | } | ||
428 | 387 | ||
429 | if (node) { | 388 | if (node) { |
389 | dwc->maximum_speed = of_usb_get_maximum_speed(node); | ||
390 | |||
430 | dwc->usb2_phy = devm_usb_get_phy_by_phandle(dev, "usb-phy", 0); | 391 | dwc->usb2_phy = devm_usb_get_phy_by_phandle(dev, "usb-phy", 0); |
431 | dwc->usb3_phy = devm_usb_get_phy_by_phandle(dev, "usb-phy", 1); | 392 | dwc->usb3_phy = devm_usb_get_phy_by_phandle(dev, "usb-phy", 1); |
393 | |||
394 | dwc->needs_fifo_resize = of_property_read_bool(node, "tx-fifo-resize"); | ||
395 | dwc->dr_mode = of_usb_get_dr_mode(node); | ||
432 | } else { | 396 | } else { |
397 | dwc->maximum_speed = pdata->maximum_speed; | ||
398 | |||
433 | dwc->usb2_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2); | 399 | dwc->usb2_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2); |
434 | dwc->usb3_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB3); | 400 | dwc->usb3_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB3); |
401 | |||
402 | dwc->needs_fifo_resize = pdata->tx_fifo_resize; | ||
403 | dwc->dr_mode = pdata->dr_mode; | ||
435 | } | 404 | } |
436 | 405 | ||
406 | /* default to superspeed if no maximum_speed passed */ | ||
407 | if (dwc->maximum_speed == USB_SPEED_UNKNOWN) | ||
408 | dwc->maximum_speed = USB_SPEED_SUPER; | ||
409 | |||
437 | if (IS_ERR(dwc->usb2_phy)) { | 410 | if (IS_ERR(dwc->usb2_phy)) { |
438 | ret = PTR_ERR(dwc->usb2_phy); | 411 | ret = PTR_ERR(dwc->usb2_phy); |
439 | 412 | ||
@@ -464,6 +437,22 @@ static int dwc3_probe(struct platform_device *pdev) | |||
464 | return -EPROBE_DEFER; | 437 | return -EPROBE_DEFER; |
465 | } | 438 | } |
466 | 439 | ||
440 | dwc->xhci_resources[0].start = res->start; | ||
441 | dwc->xhci_resources[0].end = dwc->xhci_resources[0].start + | ||
442 | DWC3_XHCI_REGS_END; | ||
443 | dwc->xhci_resources[0].flags = res->flags; | ||
444 | dwc->xhci_resources[0].name = res->name; | ||
445 | |||
446 | res->start += DWC3_GLOBALS_REGS_START; | ||
447 | |||
448 | /* | ||
449 | * Request memory region but exclude xHCI regs, | ||
450 | * since it will be requested by the xhci-plat driver. | ||
451 | */ | ||
452 | regs = devm_ioremap_resource(dev, res); | ||
453 | if (IS_ERR(regs)) | ||
454 | return PTR_ERR(regs); | ||
455 | |||
467 | usb_phy_set_suspend(dwc->usb2_phy, 0); | 456 | usb_phy_set_suspend(dwc->usb2_phy, 0); |
468 | usb_phy_set_suspend(dwc->usb3_phy, 0); | 457 | usb_phy_set_suspend(dwc->usb3_phy, 0); |
469 | 458 | ||
@@ -478,19 +467,6 @@ static int dwc3_probe(struct platform_device *pdev) | |||
478 | dev->dma_parms = dev->parent->dma_parms; | 467 | dev->dma_parms = dev->parent->dma_parms; |
479 | dma_set_coherent_mask(dev, dev->parent->coherent_dma_mask); | 468 | dma_set_coherent_mask(dev, dev->parent->coherent_dma_mask); |
480 | 469 | ||
481 | if (!strncmp("super", maximum_speed, 5)) | ||
482 | dwc->maximum_speed = DWC3_DCFG_SUPERSPEED; | ||
483 | else if (!strncmp("high", maximum_speed, 4)) | ||
484 | dwc->maximum_speed = DWC3_DCFG_HIGHSPEED; | ||
485 | else if (!strncmp("full", maximum_speed, 4)) | ||
486 | dwc->maximum_speed = DWC3_DCFG_FULLSPEED1; | ||
487 | else if (!strncmp("low", maximum_speed, 3)) | ||
488 | dwc->maximum_speed = DWC3_DCFG_LOWSPEED; | ||
489 | else | ||
490 | dwc->maximum_speed = DWC3_DCFG_SUPERSPEED; | ||
491 | |||
492 | dwc->needs_fifo_resize = of_property_read_bool(node, "tx-fifo-resize"); | ||
493 | |||
494 | pm_runtime_enable(dev); | 470 | pm_runtime_enable(dev); |
495 | pm_runtime_get_sync(dev); | 471 | pm_runtime_get_sync(dev); |
496 | pm_runtime_forbid(dev); | 472 | pm_runtime_forbid(dev); |
@@ -517,14 +493,15 @@ static int dwc3_probe(struct platform_device *pdev) | |||
517 | } | 493 | } |
518 | 494 | ||
519 | if (IS_ENABLED(CONFIG_USB_DWC3_HOST)) | 495 | if (IS_ENABLED(CONFIG_USB_DWC3_HOST)) |
520 | mode = DWC3_MODE_HOST; | 496 | dwc->dr_mode = USB_DR_MODE_HOST; |
521 | else if (IS_ENABLED(CONFIG_USB_DWC3_GADGET)) | 497 | else if (IS_ENABLED(CONFIG_USB_DWC3_GADGET)) |
522 | mode = DWC3_MODE_DEVICE; | 498 | dwc->dr_mode = USB_DR_MODE_PERIPHERAL; |
523 | else | 499 | |
524 | mode = DWC3_MODE_DRD; | 500 | if (dwc->dr_mode == USB_DR_MODE_UNKNOWN) |
501 | dwc->dr_mode = USB_DR_MODE_OTG; | ||
525 | 502 | ||
526 | switch (mode) { | 503 | switch (dwc->dr_mode) { |
527 | case DWC3_MODE_DEVICE: | 504 | case USB_DR_MODE_PERIPHERAL: |
528 | dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_DEVICE); | 505 | dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_DEVICE); |
529 | ret = dwc3_gadget_init(dwc); | 506 | ret = dwc3_gadget_init(dwc); |
530 | if (ret) { | 507 | if (ret) { |
@@ -532,7 +509,7 @@ static int dwc3_probe(struct platform_device *pdev) | |||
532 | goto err2; | 509 | goto err2; |
533 | } | 510 | } |
534 | break; | 511 | break; |
535 | case DWC3_MODE_HOST: | 512 | case USB_DR_MODE_HOST: |
536 | dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_HOST); | 513 | dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_HOST); |
537 | ret = dwc3_host_init(dwc); | 514 | ret = dwc3_host_init(dwc); |
538 | if (ret) { | 515 | if (ret) { |
@@ -540,7 +517,7 @@ static int dwc3_probe(struct platform_device *pdev) | |||
540 | goto err2; | 517 | goto err2; |
541 | } | 518 | } |
542 | break; | 519 | break; |
543 | case DWC3_MODE_DRD: | 520 | case USB_DR_MODE_OTG: |
544 | dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_OTG); | 521 | dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_OTG); |
545 | ret = dwc3_host_init(dwc); | 522 | ret = dwc3_host_init(dwc); |
546 | if (ret) { | 523 | if (ret) { |
@@ -555,10 +532,9 @@ static int dwc3_probe(struct platform_device *pdev) | |||
555 | } | 532 | } |
556 | break; | 533 | break; |
557 | default: | 534 | default: |
558 | dev_err(dev, "Unsupported mode of operation %d\n", mode); | 535 | dev_err(dev, "Unsupported mode of operation %d\n", dwc->dr_mode); |
559 | goto err2; | 536 | goto err2; |
560 | } | 537 | } |
561 | dwc->mode = mode; | ||
562 | 538 | ||
563 | ret = dwc3_debugfs_init(dwc); | 539 | ret = dwc3_debugfs_init(dwc); |
564 | if (ret) { | 540 | if (ret) { |
@@ -571,14 +547,14 @@ static int dwc3_probe(struct platform_device *pdev) | |||
571 | return 0; | 547 | return 0; |
572 | 548 | ||
573 | err3: | 549 | err3: |
574 | switch (mode) { | 550 | switch (dwc->dr_mode) { |
575 | case DWC3_MODE_DEVICE: | 551 | case USB_DR_MODE_PERIPHERAL: |
576 | dwc3_gadget_exit(dwc); | 552 | dwc3_gadget_exit(dwc); |
577 | break; | 553 | break; |
578 | case DWC3_MODE_HOST: | 554 | case USB_DR_MODE_HOST: |
579 | dwc3_host_exit(dwc); | 555 | dwc3_host_exit(dwc); |
580 | break; | 556 | break; |
581 | case DWC3_MODE_DRD: | 557 | case USB_DR_MODE_OTG: |
582 | dwc3_host_exit(dwc); | 558 | dwc3_host_exit(dwc); |
583 | dwc3_gadget_exit(dwc); | 559 | dwc3_gadget_exit(dwc); |
584 | break; | 560 | break; |
@@ -611,14 +587,14 @@ static int dwc3_remove(struct platform_device *pdev) | |||
611 | 587 | ||
612 | dwc3_debugfs_exit(dwc); | 588 | dwc3_debugfs_exit(dwc); |
613 | 589 | ||
614 | switch (dwc->mode) { | 590 | switch (dwc->dr_mode) { |
615 | case DWC3_MODE_DEVICE: | 591 | case USB_DR_MODE_PERIPHERAL: |
616 | dwc3_gadget_exit(dwc); | 592 | dwc3_gadget_exit(dwc); |
617 | break; | 593 | break; |
618 | case DWC3_MODE_HOST: | 594 | case USB_DR_MODE_HOST: |
619 | dwc3_host_exit(dwc); | 595 | dwc3_host_exit(dwc); |
620 | break; | 596 | break; |
621 | case DWC3_MODE_DRD: | 597 | case USB_DR_MODE_OTG: |
622 | dwc3_host_exit(dwc); | 598 | dwc3_host_exit(dwc); |
623 | dwc3_gadget_exit(dwc); | 599 | dwc3_gadget_exit(dwc); |
624 | break; | 600 | break; |
@@ -642,12 +618,12 @@ static int dwc3_prepare(struct device *dev) | |||
642 | 618 | ||
643 | spin_lock_irqsave(&dwc->lock, flags); | 619 | spin_lock_irqsave(&dwc->lock, flags); |
644 | 620 | ||
645 | switch (dwc->mode) { | 621 | switch (dwc->dr_mode) { |
646 | case DWC3_MODE_DEVICE: | 622 | case USB_DR_MODE_PERIPHERAL: |
647 | case DWC3_MODE_DRD: | 623 | case USB_DR_MODE_OTG: |
648 | dwc3_gadget_prepare(dwc); | 624 | dwc3_gadget_prepare(dwc); |
649 | /* FALLTHROUGH */ | 625 | /* FALLTHROUGH */ |
650 | case DWC3_MODE_HOST: | 626 | case USB_DR_MODE_HOST: |
651 | default: | 627 | default: |
652 | dwc3_event_buffers_cleanup(dwc); | 628 | dwc3_event_buffers_cleanup(dwc); |
653 | break; | 629 | break; |
@@ -665,12 +641,12 @@ static void dwc3_complete(struct device *dev) | |||
665 | 641 | ||
666 | spin_lock_irqsave(&dwc->lock, flags); | 642 | spin_lock_irqsave(&dwc->lock, flags); |
667 | 643 | ||
668 | switch (dwc->mode) { | 644 | switch (dwc->dr_mode) { |
669 | case DWC3_MODE_DEVICE: | 645 | case USB_DR_MODE_PERIPHERAL: |
670 | case DWC3_MODE_DRD: | 646 | case USB_DR_MODE_OTG: |
671 | dwc3_gadget_complete(dwc); | 647 | dwc3_gadget_complete(dwc); |
672 | /* FALLTHROUGH */ | 648 | /* FALLTHROUGH */ |
673 | case DWC3_MODE_HOST: | 649 | case USB_DR_MODE_HOST: |
674 | default: | 650 | default: |
675 | dwc3_event_buffers_setup(dwc); | 651 | dwc3_event_buffers_setup(dwc); |
676 | break; | 652 | break; |
@@ -686,12 +662,12 @@ static int dwc3_suspend(struct device *dev) | |||
686 | 662 | ||
687 | spin_lock_irqsave(&dwc->lock, flags); | 663 | spin_lock_irqsave(&dwc->lock, flags); |
688 | 664 | ||
689 | switch (dwc->mode) { | 665 | switch (dwc->dr_mode) { |
690 | case DWC3_MODE_DEVICE: | 666 | case USB_DR_MODE_PERIPHERAL: |
691 | case DWC3_MODE_DRD: | 667 | case USB_DR_MODE_OTG: |
692 | dwc3_gadget_suspend(dwc); | 668 | dwc3_gadget_suspend(dwc); |
693 | /* FALLTHROUGH */ | 669 | /* FALLTHROUGH */ |
694 | case DWC3_MODE_HOST: | 670 | case USB_DR_MODE_HOST: |
695 | default: | 671 | default: |
696 | /* do nothing */ | 672 | /* do nothing */ |
697 | break; | 673 | break; |
@@ -719,12 +695,12 @@ static int dwc3_resume(struct device *dev) | |||
719 | 695 | ||
720 | dwc3_writel(dwc->regs, DWC3_GCTL, dwc->gctl); | 696 | dwc3_writel(dwc->regs, DWC3_GCTL, dwc->gctl); |
721 | 697 | ||
722 | switch (dwc->mode) { | 698 | switch (dwc->dr_mode) { |
723 | case DWC3_MODE_DEVICE: | 699 | case USB_DR_MODE_PERIPHERAL: |
724 | case DWC3_MODE_DRD: | 700 | case USB_DR_MODE_OTG: |
725 | dwc3_gadget_resume(dwc); | 701 | dwc3_gadget_resume(dwc); |
726 | /* FALLTHROUGH */ | 702 | /* FALLTHROUGH */ |
727 | case DWC3_MODE_HOST: | 703 | case USB_DR_MODE_HOST: |
728 | default: | 704 | default: |
729 | /* do nothing */ | 705 | /* do nothing */ |
730 | break; | 706 | break; |
@@ -754,6 +730,9 @@ static const struct dev_pm_ops dwc3_dev_pm_ops = { | |||
754 | #ifdef CONFIG_OF | 730 | #ifdef CONFIG_OF |
755 | static const struct of_device_id of_dwc3_match[] = { | 731 | static const struct of_device_id of_dwc3_match[] = { |
756 | { | 732 | { |
733 | .compatible = "snps,dwc3" | ||
734 | }, | ||
735 | { | ||
757 | .compatible = "synopsys,dwc3" | 736 | .compatible = "synopsys,dwc3" |
758 | }, | 737 | }, |
759 | { }, | 738 | { }, |
@@ -775,5 +754,5 @@ module_platform_driver(dwc3_driver); | |||
775 | 754 | ||
776 | MODULE_ALIAS("platform:dwc3"); | 755 | MODULE_ALIAS("platform:dwc3"); |
777 | MODULE_AUTHOR("Felipe Balbi <balbi@ti.com>"); | 756 | MODULE_AUTHOR("Felipe Balbi <balbi@ti.com>"); |
778 | MODULE_LICENSE("Dual BSD/GPL"); | 757 | MODULE_LICENSE("GPL v2"); |
779 | MODULE_DESCRIPTION("DesignWare USB3 DRD Controller Driver"); | 758 | MODULE_DESCRIPTION("DesignWare USB3 DRD Controller Driver"); |
diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h index 27dad993b007..f8af8d44af85 100644 --- a/drivers/usb/dwc3/core.h +++ b/drivers/usb/dwc3/core.h | |||
@@ -6,34 +6,14 @@ | |||
6 | * Authors: Felipe Balbi <balbi@ti.com>, | 6 | * Authors: Felipe Balbi <balbi@ti.com>, |
7 | * Sebastian Andrzej Siewior <bigeasy@linutronix.de> | 7 | * Sebastian Andrzej Siewior <bigeasy@linutronix.de> |
8 | * | 8 | * |
9 | * Redistribution and use in source and binary forms, with or without | 9 | * This program is free software: you can redistribute it and/or modify |
10 | * modification, are permitted provided that the following conditions | 10 | * it under the terms of the GNU General Public License version 2 of |
11 | * are met: | 11 | * the License as published by the Free Software Foundation. |
12 | * 1. Redistributions of source code must retain the above copyright | ||
13 | * notice, this list of conditions, and the following disclaimer, | ||
14 | * without modification. | ||
15 | * 2. Redistributions in binary form must reproduce the above copyright | ||
16 | * notice, this list of conditions and the following disclaimer in the | ||
17 | * documentation and/or other materials provided with the distribution. | ||
18 | * 3. The names of the above-listed copyright holders may not be used | ||
19 | * to endorse or promote products derived from this software without | ||
20 | * specific prior written permission. | ||
21 | * | 12 | * |
22 | * ALTERNATIVELY, this software may be distributed under the terms of the | 13 | * This program is distributed in the hope that it will be useful, |
23 | * GNU General Public License ("GPL") version 2, as published by the Free | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
24 | * Software Foundation. | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
25 | * | 16 | * GNU General Public License for more details. |
26 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS | ||
27 | * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
28 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
29 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | ||
30 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
31 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
32 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
33 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
34 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
35 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
36 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
37 | */ | 17 | */ |
38 | 18 | ||
39 | #ifndef __DRIVERS_USB_DWC3_CORE_H | 19 | #ifndef __DRIVERS_USB_DWC3_CORE_H |
@@ -49,6 +29,7 @@ | |||
49 | 29 | ||
50 | #include <linux/usb/ch9.h> | 30 | #include <linux/usb/ch9.h> |
51 | #include <linux/usb/gadget.h> | 31 | #include <linux/usb/gadget.h> |
32 | #include <linux/usb/otg.h> | ||
52 | 33 | ||
53 | /* Global constants */ | 34 | /* Global constants */ |
54 | #define DWC3_EP0_BOUNCE_SIZE 512 | 35 | #define DWC3_EP0_BOUNCE_SIZE 512 |
@@ -194,6 +175,10 @@ | |||
194 | #define DWC3_GTXFIFOSIZ_TXFDEF(n) ((n) & 0xffff) | 175 | #define DWC3_GTXFIFOSIZ_TXFDEF(n) ((n) & 0xffff) |
195 | #define DWC3_GTXFIFOSIZ_TXFSTADDR(n) ((n) & 0xffff0000) | 176 | #define DWC3_GTXFIFOSIZ_TXFSTADDR(n) ((n) & 0xffff0000) |
196 | 177 | ||
178 | /* Global Event Size Registers */ | ||
179 | #define DWC3_GEVNTSIZ_INTMASK (1 << 31) | ||
180 | #define DWC3_GEVNTSIZ_SIZE(n) ((n) & 0xffff) | ||
181 | |||
197 | /* Global HWPARAMS1 Register */ | 182 | /* Global HWPARAMS1 Register */ |
198 | #define DWC3_GHWPARAMS1_EN_PWROPT(n) (((n) & (3 << 24)) >> 24) | 183 | #define DWC3_GHWPARAMS1_EN_PWROPT(n) (((n) & (3 << 24)) >> 24) |
199 | #define DWC3_GHWPARAMS1_EN_PWROPT_NO 0 | 184 | #define DWC3_GHWPARAMS1_EN_PWROPT_NO 0 |
@@ -207,7 +192,6 @@ | |||
207 | #define DWC3_MAX_HIBER_SCRATCHBUFS 15 | 192 | #define DWC3_MAX_HIBER_SCRATCHBUFS 15 |
208 | 193 | ||
209 | /* Device Configuration Register */ | 194 | /* Device Configuration Register */ |
210 | #define DWC3_DCFG_LPM_CAP (1 << 22) | ||
211 | #define DWC3_DCFG_DEVADDR(addr) ((addr) << 3) | 195 | #define DWC3_DCFG_DEVADDR(addr) ((addr) << 3) |
212 | #define DWC3_DCFG_DEVADDR_MASK DWC3_DCFG_DEVADDR(0x7f) | 196 | #define DWC3_DCFG_DEVADDR_MASK DWC3_DCFG_DEVADDR(0x7f) |
213 | 197 | ||
@@ -367,7 +351,6 @@ struct dwc3_trb; | |||
367 | 351 | ||
368 | /** | 352 | /** |
369 | * struct dwc3_event_buffer - Software event buffer representation | 353 | * struct dwc3_event_buffer - Software event buffer representation |
370 | * @list: a list of event buffers | ||
371 | * @buf: _THE_ buffer | 354 | * @buf: _THE_ buffer |
372 | * @length: size of this buffer | 355 | * @length: size of this buffer |
373 | * @lpos: event offset | 356 | * @lpos: event offset |
@@ -415,7 +398,7 @@ struct dwc3_event_buffer { | |||
415 | * @number: endpoint number (1 - 15) | 398 | * @number: endpoint number (1 - 15) |
416 | * @type: set to bmAttributes & USB_ENDPOINT_XFERTYPE_MASK | 399 | * @type: set to bmAttributes & USB_ENDPOINT_XFERTYPE_MASK |
417 | * @resource_index: Resource transfer index | 400 | * @resource_index: Resource transfer index |
418 | * @interval: the intervall on which the ISOC transfer is started | 401 | * @interval: the interval on which the ISOC transfer is started |
419 | * @name: a human readable name e.g. ep1out-bulk | 402 | * @name: a human readable name e.g. ep1out-bulk |
420 | * @direction: true for TX, false for RX | 403 | * @direction: true for TX, false for RX |
421 | * @stream_capable: true when streams are enabled | 404 | * @stream_capable: true when streams are enabled |
@@ -566,11 +549,6 @@ struct dwc3_hwparams { | |||
566 | /* HWPARAMS0 */ | 549 | /* HWPARAMS0 */ |
567 | #define DWC3_MODE(n) ((n) & 0x7) | 550 | #define DWC3_MODE(n) ((n) & 0x7) |
568 | 551 | ||
569 | #define DWC3_MODE_DEVICE 0 | ||
570 | #define DWC3_MODE_HOST 1 | ||
571 | #define DWC3_MODE_DRD 2 | ||
572 | #define DWC3_MODE_HUB 3 | ||
573 | |||
574 | #define DWC3_MDWIDTH(n) (((n) & 0xff00) >> 8) | 552 | #define DWC3_MDWIDTH(n) (((n) & 0xff00) >> 8) |
575 | 553 | ||
576 | /* HWPARAMS1 */ | 554 | /* HWPARAMS1 */ |
@@ -632,7 +610,7 @@ struct dwc3_scratchpad_array { | |||
632 | * @u1u2: only used on revisions <1.83a for workaround | 610 | * @u1u2: only used on revisions <1.83a for workaround |
633 | * @maximum_speed: maximum speed requested (mainly for testing purposes) | 611 | * @maximum_speed: maximum speed requested (mainly for testing purposes) |
634 | * @revision: revision register contents | 612 | * @revision: revision register contents |
635 | * @mode: mode of operation | 613 | * @dr_mode: requested mode of operation |
636 | * @usb2_phy: pointer to USB2 PHY | 614 | * @usb2_phy: pointer to USB2 PHY |
637 | * @usb3_phy: pointer to USB3 PHY | 615 | * @usb3_phy: pointer to USB3 PHY |
638 | * @dcfg: saved contents of DCFG register | 616 | * @dcfg: saved contents of DCFG register |
@@ -690,6 +668,8 @@ struct dwc3 { | |||
690 | void __iomem *regs; | 668 | void __iomem *regs; |
691 | size_t regs_size; | 669 | size_t regs_size; |
692 | 670 | ||
671 | enum usb_dr_mode dr_mode; | ||
672 | |||
693 | /* used for suspend/resume */ | 673 | /* used for suspend/resume */ |
694 | u32 dcfg; | 674 | u32 dcfg; |
695 | u32 gctl; | 675 | u32 gctl; |
@@ -698,7 +678,6 @@ struct dwc3 { | |||
698 | u32 u1u2; | 678 | u32 u1u2; |
699 | u32 maximum_speed; | 679 | u32 maximum_speed; |
700 | u32 revision; | 680 | u32 revision; |
701 | u32 mode; | ||
702 | 681 | ||
703 | #define DWC3_REVISION_173A 0x5533173a | 682 | #define DWC3_REVISION_173A 0x5533173a |
704 | #define DWC3_REVISION_175A 0x5533175a | 683 | #define DWC3_REVISION_175A 0x5533175a |
diff --git a/drivers/usb/dwc3/debug.h b/drivers/usb/dwc3/debug.h index 5894ee8222af..fceb39dc4bba 100644 --- a/drivers/usb/dwc3/debug.h +++ b/drivers/usb/dwc3/debug.h | |||
@@ -6,34 +6,14 @@ | |||
6 | * Authors: Felipe Balbi <balbi@ti.com>, | 6 | * Authors: Felipe Balbi <balbi@ti.com>, |
7 | * Sebastian Andrzej Siewior <bigeasy@linutronix.de> | 7 | * Sebastian Andrzej Siewior <bigeasy@linutronix.de> |
8 | * | 8 | * |
9 | * Redistribution and use in source and binary forms, with or without | 9 | * This program is free software: you can redistribute it and/or modify |
10 | * modification, are permitted provided that the following conditions | 10 | * it under the terms of the GNU General Public License version 2 of |
11 | * are met: | 11 | * the License as published by the Free Software Foundation. |
12 | * 1. Redistributions of source code must retain the above copyright | ||
13 | * notice, this list of conditions, and the following disclaimer, | ||
14 | * without modification. | ||
15 | * 2. Redistributions in binary form must reproduce the above copyright | ||
16 | * notice, this list of conditions and the following disclaimer in the | ||
17 | * documentation and/or other materials provided with the distribution. | ||
18 | * 3. The names of the above-listed copyright holders may not be used | ||
19 | * to endorse or promote products derived from this software without | ||
20 | * specific prior written permission. | ||
21 | * | 12 | * |
22 | * ALTERNATIVELY, this software may be distributed under the terms of the | 13 | * This program is distributed in the hope that it will be useful, |
23 | * GNU General Public License ("GPL") version 2, as published by the Free | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
24 | * Software Foundation. | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
25 | * | 16 | * GNU General Public License for more details. |
26 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS | ||
27 | * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
28 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
29 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | ||
30 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
31 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
32 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
33 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
34 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
35 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
36 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
37 | */ | 17 | */ |
38 | 18 | ||
39 | #include "core.h" | 19 | #include "core.h" |
diff --git a/drivers/usb/dwc3/debugfs.c b/drivers/usb/dwc3/debugfs.c index 9e9f122162f2..9ac37fe1b6a7 100644 --- a/drivers/usb/dwc3/debugfs.c +++ b/drivers/usb/dwc3/debugfs.c | |||
@@ -6,34 +6,14 @@ | |||
6 | * Authors: Felipe Balbi <balbi@ti.com>, | 6 | * Authors: Felipe Balbi <balbi@ti.com>, |
7 | * Sebastian Andrzej Siewior <bigeasy@linutronix.de> | 7 | * Sebastian Andrzej Siewior <bigeasy@linutronix.de> |
8 | * | 8 | * |
9 | * Redistribution and use in source and binary forms, with or without | 9 | * This program is free software: you can redistribute it and/or modify |
10 | * modification, are permitted provided that the following conditions | 10 | * it under the terms of the GNU General Public License version 2 of |
11 | * are met: | 11 | * the License as published by the Free Software Foundation. |
12 | * 1. Redistributions of source code must retain the above copyright | ||
13 | * notice, this list of conditions, and the following disclaimer, | ||
14 | * without modification. | ||
15 | * 2. Redistributions in binary form must reproduce the above copyright | ||
16 | * notice, this list of conditions and the following disclaimer in the | ||
17 | * documentation and/or other materials provided with the distribution. | ||
18 | * 3. The names of the above-listed copyright holders may not be used | ||
19 | * to endorse or promote products derived from this software without | ||
20 | * specific prior written permission. | ||
21 | * | 12 | * |
22 | * ALTERNATIVELY, this software may be distributed under the terms of the | 13 | * This program is distributed in the hope that it will be useful, |
23 | * GNU General Public License ("GPL") version 2, as published by the Free | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
24 | * Software Foundation. | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
25 | * | 16 | * GNU General Public License for more details. |
26 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS | ||
27 | * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
28 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
29 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | ||
30 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
31 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
32 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
33 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
34 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
35 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
36 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
37 | */ | 17 | */ |
38 | 18 | ||
39 | #include <linux/kernel.h> | 19 | #include <linux/kernel.h> |
diff --git a/drivers/usb/dwc3/dwc3-exynos.c b/drivers/usb/dwc3/dwc3-exynos.c index 8ce9d7fd6cfc..2f2e88a3a11a 100644 --- a/drivers/usb/dwc3/dwc3-exynos.c +++ b/drivers/usb/dwc3/dwc3-exynos.c | |||
@@ -6,10 +6,14 @@ | |||
6 | * | 6 | * |
7 | * Author: Anton Tikhomirov <av.tikhomirov@samsung.com> | 7 | * Author: Anton Tikhomirov <av.tikhomirov@samsung.com> |
8 | * | 8 | * |
9 | * 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 |
10 | * it under the terms of the GNU General Public License as published by | 10 | * it under the terms of the GNU General Public License version 2 of |
11 | * the Free Software Foundation; either version 2 of the License, or | 11 | * the License as published by the Free Software Foundation. |
12 | * (at your option) any later version. | 12 | * |
13 | * This program is distributed in the hope that it will be useful, | ||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | * GNU General Public License for more details. | ||
13 | */ | 17 | */ |
14 | 18 | ||
15 | #include <linux/module.h> | 19 | #include <linux/module.h> |
@@ -20,7 +24,7 @@ | |||
20 | #include <linux/dma-mapping.h> | 24 | #include <linux/dma-mapping.h> |
21 | #include <linux/clk.h> | 25 | #include <linux/clk.h> |
22 | #include <linux/usb/otg.h> | 26 | #include <linux/usb/otg.h> |
23 | #include <linux/usb/nop-usb-xceiv.h> | 27 | #include <linux/usb/usb_phy_gen_xceiv.h> |
24 | #include <linux/of.h> | 28 | #include <linux/of.h> |
25 | #include <linux/of_platform.h> | 29 | #include <linux/of_platform.h> |
26 | 30 | ||
@@ -34,13 +38,13 @@ struct dwc3_exynos { | |||
34 | 38 | ||
35 | static int dwc3_exynos_register_phys(struct dwc3_exynos *exynos) | 39 | static int dwc3_exynos_register_phys(struct dwc3_exynos *exynos) |
36 | { | 40 | { |
37 | struct nop_usb_xceiv_platform_data pdata; | 41 | struct usb_phy_gen_xceiv_platform_data pdata; |
38 | struct platform_device *pdev; | 42 | struct platform_device *pdev; |
39 | int ret; | 43 | int ret; |
40 | 44 | ||
41 | memset(&pdata, 0x00, sizeof(pdata)); | 45 | memset(&pdata, 0x00, sizeof(pdata)); |
42 | 46 | ||
43 | pdev = platform_device_alloc("nop_usb_xceiv", PLATFORM_DEVID_AUTO); | 47 | pdev = platform_device_alloc("usb_phy_gen_xceiv", PLATFORM_DEVID_AUTO); |
44 | if (!pdev) | 48 | if (!pdev) |
45 | return -ENOMEM; | 49 | return -ENOMEM; |
46 | 50 | ||
@@ -51,7 +55,7 @@ static int dwc3_exynos_register_phys(struct dwc3_exynos *exynos) | |||
51 | if (ret) | 55 | if (ret) |
52 | goto err1; | 56 | goto err1; |
53 | 57 | ||
54 | pdev = platform_device_alloc("nop_usb_xceiv", PLATFORM_DEVID_AUTO); | 58 | pdev = platform_device_alloc("usb_phy_gen_xceiv", PLATFORM_DEVID_AUTO); |
55 | if (!pdev) { | 59 | if (!pdev) { |
56 | ret = -ENOMEM; | 60 | ret = -ENOMEM; |
57 | goto err1; | 61 | goto err1; |
@@ -228,5 +232,5 @@ module_platform_driver(dwc3_exynos_driver); | |||
228 | 232 | ||
229 | MODULE_ALIAS("platform:exynos-dwc3"); | 233 | MODULE_ALIAS("platform:exynos-dwc3"); |
230 | MODULE_AUTHOR("Anton Tikhomirov <av.tikhomirov@samsung.com>"); | 234 | MODULE_AUTHOR("Anton Tikhomirov <av.tikhomirov@samsung.com>"); |
231 | MODULE_LICENSE("GPL"); | 235 | MODULE_LICENSE("GPL v2"); |
232 | MODULE_DESCRIPTION("DesignWare USB3 EXYNOS Glue Layer"); | 236 | MODULE_DESCRIPTION("DesignWare USB3 EXYNOS Glue Layer"); |
diff --git a/drivers/usb/dwc3/dwc3-omap.c b/drivers/usb/dwc3/dwc3-omap.c index 077f110bd746..ecd99451ee90 100644 --- a/drivers/usb/dwc3/dwc3-omap.c +++ b/drivers/usb/dwc3/dwc3-omap.c | |||
@@ -6,34 +6,14 @@ | |||
6 | * Authors: Felipe Balbi <balbi@ti.com>, | 6 | * Authors: Felipe Balbi <balbi@ti.com>, |
7 | * Sebastian Andrzej Siewior <bigeasy@linutronix.de> | 7 | * Sebastian Andrzej Siewior <bigeasy@linutronix.de> |
8 | * | 8 | * |
9 | * Redistribution and use in source and binary forms, with or without | 9 | * This program is free software: you can redistribute it and/or modify |
10 | * modification, are permitted provided that the following conditions | 10 | * it under the terms of the GNU General Public License version 2 of |
11 | * are met: | 11 | * the License as published by the Free Software Foundation. |
12 | * 1. Redistributions of source code must retain the above copyright | ||
13 | * notice, this list of conditions, and the following disclaimer, | ||
14 | * without modification. | ||
15 | * 2. Redistributions in binary form must reproduce the above copyright | ||
16 | * notice, this list of conditions and the following disclaimer in the | ||
17 | * documentation and/or other materials provided with the distribution. | ||
18 | * 3. The names of the above-listed copyright holders may not be used | ||
19 | * to endorse or promote products derived from this software without | ||
20 | * specific prior written permission. | ||
21 | * | 12 | * |
22 | * ALTERNATIVELY, this software may be distributed under the terms of the | 13 | * This program is distributed in the hope that it will be useful, |
23 | * GNU General Public License ("GPL") version 2, as published by the Free | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
24 | * Software Foundation. | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
25 | * | 16 | * GNU General Public License for more details. |
26 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS | ||
27 | * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
28 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
29 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | ||
30 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
31 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
32 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
33 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
34 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
35 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
36 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
37 | */ | 17 | */ |
38 | 18 | ||
39 | #include <linux/module.h> | 19 | #include <linux/module.h> |
@@ -409,11 +389,9 @@ static int dwc3_omap_probe(struct platform_device *pdev) | |||
409 | return -EINVAL; | 389 | return -EINVAL; |
410 | } | 390 | } |
411 | 391 | ||
412 | base = devm_ioremap_nocache(dev, res->start, resource_size(res)); | 392 | base = devm_ioremap_resource(dev, res); |
413 | if (!base) { | 393 | if (IS_ERR(base)) |
414 | dev_err(dev, "ioremap failed\n"); | 394 | return PTR_ERR(base); |
415 | return -ENOMEM; | ||
416 | } | ||
417 | 395 | ||
418 | spin_lock_init(&omap->lock); | 396 | spin_lock_init(&omap->lock); |
419 | 397 | ||
@@ -610,5 +588,5 @@ module_platform_driver(dwc3_omap_driver); | |||
610 | 588 | ||
611 | MODULE_ALIAS("platform:omap-dwc3"); | 589 | MODULE_ALIAS("platform:omap-dwc3"); |
612 | MODULE_AUTHOR("Felipe Balbi <balbi@ti.com>"); | 590 | MODULE_AUTHOR("Felipe Balbi <balbi@ti.com>"); |
613 | MODULE_LICENSE("Dual BSD/GPL"); | 591 | MODULE_LICENSE("GPL v2"); |
614 | MODULE_DESCRIPTION("DesignWare USB3 OMAP Glue Layer"); | 592 | MODULE_DESCRIPTION("DesignWare USB3 OMAP Glue Layer"); |
diff --git a/drivers/usb/dwc3/dwc3-pci.c b/drivers/usb/dwc3/dwc3-pci.c index ed07ec04a962..9b138129e856 100644 --- a/drivers/usb/dwc3/dwc3-pci.c +++ b/drivers/usb/dwc3/dwc3-pci.c | |||
@@ -6,34 +6,14 @@ | |||
6 | * Authors: Felipe Balbi <balbi@ti.com>, | 6 | * Authors: Felipe Balbi <balbi@ti.com>, |
7 | * Sebastian Andrzej Siewior <bigeasy@linutronix.de> | 7 | * Sebastian Andrzej Siewior <bigeasy@linutronix.de> |
8 | * | 8 | * |
9 | * Redistribution and use in source and binary forms, with or without | 9 | * This program is free software: you can redistribute it and/or modify |
10 | * modification, are permitted provided that the following conditions | 10 | * it under the terms of the GNU General Public License version 2 of |
11 | * are met: | 11 | * the License as published by the Free Software Foundation. |
12 | * 1. Redistributions of source code must retain the above copyright | ||
13 | * notice, this list of conditions, and the following disclaimer, | ||
14 | * without modification. | ||
15 | * 2. Redistributions in binary form must reproduce the above copyright | ||
16 | * notice, this list of conditions and the following disclaimer in the | ||
17 | * documentation and/or other materials provided with the distribution. | ||
18 | * 3. The names of the above-listed copyright holders may not be used | ||
19 | * to endorse or promote products derived from this software without | ||
20 | * specific prior written permission. | ||
21 | * | 12 | * |
22 | * ALTERNATIVELY, this software may be distributed under the terms of the | 13 | * This program is distributed in the hope that it will be useful, |
23 | * GNU General Public License ("GPL") version 2, as published by the Free | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
24 | * Software Foundation. | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
25 | * | 16 | * GNU General Public License for more details. |
26 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS | ||
27 | * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
28 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
29 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | ||
30 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
31 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
32 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
33 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
34 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
35 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
36 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
37 | */ | 17 | */ |
38 | 18 | ||
39 | #include <linux/kernel.h> | 19 | #include <linux/kernel.h> |
@@ -43,7 +23,7 @@ | |||
43 | #include <linux/platform_device.h> | 23 | #include <linux/platform_device.h> |
44 | 24 | ||
45 | #include <linux/usb/otg.h> | 25 | #include <linux/usb/otg.h> |
46 | #include <linux/usb/nop-usb-xceiv.h> | 26 | #include <linux/usb/usb_phy_gen_xceiv.h> |
47 | 27 | ||
48 | /* FIXME define these in <linux/pci_ids.h> */ | 28 | /* FIXME define these in <linux/pci_ids.h> */ |
49 | #define PCI_VENDOR_ID_SYNOPSYS 0x16c3 | 29 | #define PCI_VENDOR_ID_SYNOPSYS 0x16c3 |
@@ -58,13 +38,13 @@ struct dwc3_pci { | |||
58 | 38 | ||
59 | static int dwc3_pci_register_phys(struct dwc3_pci *glue) | 39 | static int dwc3_pci_register_phys(struct dwc3_pci *glue) |
60 | { | 40 | { |
61 | struct nop_usb_xceiv_platform_data pdata; | 41 | struct usb_phy_gen_xceiv_platform_data pdata; |
62 | struct platform_device *pdev; | 42 | struct platform_device *pdev; |
63 | int ret; | 43 | int ret; |
64 | 44 | ||
65 | memset(&pdata, 0x00, sizeof(pdata)); | 45 | memset(&pdata, 0x00, sizeof(pdata)); |
66 | 46 | ||
67 | pdev = platform_device_alloc("nop_usb_xceiv", 0); | 47 | pdev = platform_device_alloc("usb_phy_gen_xceiv", 0); |
68 | if (!pdev) | 48 | if (!pdev) |
69 | return -ENOMEM; | 49 | return -ENOMEM; |
70 | 50 | ||
@@ -75,7 +55,7 @@ static int dwc3_pci_register_phys(struct dwc3_pci *glue) | |||
75 | if (ret) | 55 | if (ret) |
76 | goto err1; | 56 | goto err1; |
77 | 57 | ||
78 | pdev = platform_device_alloc("nop_usb_xceiv", 1); | 58 | pdev = platform_device_alloc("usb_phy_gen_xceiv", 1); |
79 | if (!pdev) { | 59 | if (!pdev) { |
80 | ret = -ENOMEM; | 60 | ret = -ENOMEM; |
81 | goto err1; | 61 | goto err1; |
@@ -211,7 +191,7 @@ static DEFINE_PCI_DEVICE_TABLE(dwc3_pci_id_table) = { | |||
211 | }; | 191 | }; |
212 | MODULE_DEVICE_TABLE(pci, dwc3_pci_id_table); | 192 | MODULE_DEVICE_TABLE(pci, dwc3_pci_id_table); |
213 | 193 | ||
214 | #ifdef CONFIG_PM | 194 | #ifdef CONFIG_PM_SLEEP |
215 | static int dwc3_pci_suspend(struct device *dev) | 195 | static int dwc3_pci_suspend(struct device *dev) |
216 | { | 196 | { |
217 | struct pci_dev *pci = to_pci_dev(dev); | 197 | struct pci_dev *pci = to_pci_dev(dev); |
@@ -236,28 +216,24 @@ static int dwc3_pci_resume(struct device *dev) | |||
236 | 216 | ||
237 | return 0; | 217 | return 0; |
238 | } | 218 | } |
219 | #endif /* CONFIG_PM_SLEEP */ | ||
239 | 220 | ||
240 | static const struct dev_pm_ops dwc3_pci_dev_pm_ops = { | 221 | static const struct dev_pm_ops dwc3_pci_dev_pm_ops = { |
241 | SET_SYSTEM_SLEEP_PM_OPS(dwc3_pci_suspend, dwc3_pci_resume) | 222 | SET_SYSTEM_SLEEP_PM_OPS(dwc3_pci_suspend, dwc3_pci_resume) |
242 | }; | 223 | }; |
243 | 224 | ||
244 | #define DEV_PM_OPS (&dwc3_pci_dev_pm_ops) | ||
245 | #else | ||
246 | #define DEV_PM_OPS NULL | ||
247 | #endif /* CONFIG_PM */ | ||
248 | |||
249 | static struct pci_driver dwc3_pci_driver = { | 225 | static struct pci_driver dwc3_pci_driver = { |
250 | .name = "dwc3-pci", | 226 | .name = "dwc3-pci", |
251 | .id_table = dwc3_pci_id_table, | 227 | .id_table = dwc3_pci_id_table, |
252 | .probe = dwc3_pci_probe, | 228 | .probe = dwc3_pci_probe, |
253 | .remove = dwc3_pci_remove, | 229 | .remove = dwc3_pci_remove, |
254 | .driver = { | 230 | .driver = { |
255 | .pm = DEV_PM_OPS, | 231 | .pm = &dwc3_pci_dev_pm_ops, |
256 | }, | 232 | }, |
257 | }; | 233 | }; |
258 | 234 | ||
259 | MODULE_AUTHOR("Felipe Balbi <balbi@ti.com>"); | 235 | MODULE_AUTHOR("Felipe Balbi <balbi@ti.com>"); |
260 | MODULE_LICENSE("Dual BSD/GPL"); | 236 | MODULE_LICENSE("GPL v2"); |
261 | MODULE_DESCRIPTION("DesignWare USB3 PCI Glue Layer"); | 237 | MODULE_DESCRIPTION("DesignWare USB3 PCI Glue Layer"); |
262 | 238 | ||
263 | module_pci_driver(dwc3_pci_driver); | 239 | module_pci_driver(dwc3_pci_driver); |
diff --git a/drivers/usb/dwc3/ep0.c b/drivers/usb/dwc3/ep0.c index 5acbb948b704..7fa93f4bc507 100644 --- a/drivers/usb/dwc3/ep0.c +++ b/drivers/usb/dwc3/ep0.c | |||
@@ -6,34 +6,14 @@ | |||
6 | * Authors: Felipe Balbi <balbi@ti.com>, | 6 | * Authors: Felipe Balbi <balbi@ti.com>, |
7 | * Sebastian Andrzej Siewior <bigeasy@linutronix.de> | 7 | * Sebastian Andrzej Siewior <bigeasy@linutronix.de> |
8 | * | 8 | * |
9 | * Redistribution and use in source and binary forms, with or without | 9 | * This program is free software: you can redistribute it and/or modify |
10 | * modification, are permitted provided that the following conditions | 10 | * it under the terms of the GNU General Public License version 2 of |
11 | * are met: | 11 | * the License as published by the Free Software Foundation. |
12 | * 1. Redistributions of source code must retain the above copyright | ||
13 | * notice, this list of conditions, and the following disclaimer, | ||
14 | * without modification. | ||
15 | * 2. Redistributions in binary form must reproduce the above copyright | ||
16 | * notice, this list of conditions and the following disclaimer in the | ||
17 | * documentation and/or other materials provided with the distribution. | ||
18 | * 3. The names of the above-listed copyright holders may not be used | ||
19 | * to endorse or promote products derived from this software without | ||
20 | * specific prior written permission. | ||
21 | * | 12 | * |
22 | * ALTERNATIVELY, this software may be distributed under the terms of the | 13 | * This program is distributed in the hope that it will be useful, |
23 | * GNU General Public License ("GPL") version 2, as published by the Free | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
24 | * Software Foundation. | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
25 | * | 16 | * GNU General Public License for more details. |
26 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS | ||
27 | * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
28 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
29 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | ||
30 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
31 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
32 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
33 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
34 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
35 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
36 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
37 | */ | 17 | */ |
38 | 18 | ||
39 | #include <linux/kernel.h> | 19 | #include <linux/kernel.h> |
@@ -168,6 +148,7 @@ static int __dwc3_gadget_ep0_queue(struct dwc3_ep *dep, | |||
168 | 148 | ||
169 | direction = !dwc->ep0_expect_in; | 149 | direction = !dwc->ep0_expect_in; |
170 | dwc->delayed_status = false; | 150 | dwc->delayed_status = false; |
151 | usb_gadget_set_state(&dwc->gadget, USB_STATE_CONFIGURED); | ||
171 | 152 | ||
172 | if (dwc->ep0state == EP0_STATUS_PHASE) | 153 | if (dwc->ep0state == EP0_STATUS_PHASE) |
173 | __dwc3_ep0_do_control_status(dwc, dwc->eps[direction]); | 154 | __dwc3_ep0_do_control_status(dwc, dwc->eps[direction]); |
@@ -553,8 +534,16 @@ static int dwc3_ep0_set_config(struct dwc3 *dwc, struct usb_ctrlrequest *ctrl) | |||
553 | ret = dwc3_ep0_delegate_req(dwc, ctrl); | 534 | ret = dwc3_ep0_delegate_req(dwc, ctrl); |
554 | /* if the cfg matches and the cfg is non zero */ | 535 | /* if the cfg matches and the cfg is non zero */ |
555 | if (cfg && (!ret || (ret == USB_GADGET_DELAYED_STATUS))) { | 536 | if (cfg && (!ret || (ret == USB_GADGET_DELAYED_STATUS))) { |
556 | usb_gadget_set_state(&dwc->gadget, | 537 | |
557 | USB_STATE_CONFIGURED); | 538 | /* |
539 | * only change state if set_config has already | ||
540 | * been processed. If gadget driver returns | ||
541 | * USB_GADGET_DELAYED_STATUS, we will wait | ||
542 | * to change the state on the next usb_ep_queue() | ||
543 | */ | ||
544 | if (ret == 0) | ||
545 | usb_gadget_set_state(&dwc->gadget, | ||
546 | USB_STATE_CONFIGURED); | ||
558 | 547 | ||
559 | /* | 548 | /* |
560 | * Enable transition to U1/U2 state when | 549 | * Enable transition to U1/U2 state when |
@@ -571,7 +560,7 @@ static int dwc3_ep0_set_config(struct dwc3 *dwc, struct usb_ctrlrequest *ctrl) | |||
571 | 560 | ||
572 | case USB_STATE_CONFIGURED: | 561 | case USB_STATE_CONFIGURED: |
573 | ret = dwc3_ep0_delegate_req(dwc, ctrl); | 562 | ret = dwc3_ep0_delegate_req(dwc, ctrl); |
574 | if (!cfg) | 563 | if (!cfg && !ret) |
575 | usb_gadget_set_state(&dwc->gadget, | 564 | usb_gadget_set_state(&dwc->gadget, |
576 | USB_STATE_ADDRESS); | 565 | USB_STATE_ADDRESS); |
577 | break; | 566 | break; |
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index f77083fedc68..f168eaebdef8 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c | |||
@@ -6,34 +6,14 @@ | |||
6 | * Authors: Felipe Balbi <balbi@ti.com>, | 6 | * Authors: Felipe Balbi <balbi@ti.com>, |
7 | * Sebastian Andrzej Siewior <bigeasy@linutronix.de> | 7 | * Sebastian Andrzej Siewior <bigeasy@linutronix.de> |
8 | * | 8 | * |
9 | * Redistribution and use in source and binary forms, with or without | 9 | * This program is free software: you can redistribute it and/or modify |
10 | * modification, are permitted provided that the following conditions | 10 | * it under the terms of the GNU General Public License version 2 of |
11 | * are met: | 11 | * the License as published by the Free Software Foundation. |
12 | * 1. Redistributions of source code must retain the above copyright | ||
13 | * notice, this list of conditions, and the following disclaimer, | ||
14 | * without modification. | ||
15 | * 2. Redistributions in binary form must reproduce the above copyright | ||
16 | * notice, this list of conditions and the following disclaimer in the | ||
17 | * documentation and/or other materials provided with the distribution. | ||
18 | * 3. The names of the above-listed copyright holders may not be used | ||
19 | * to endorse or promote products derived from this software without | ||
20 | * specific prior written permission. | ||
21 | * | 12 | * |
22 | * ALTERNATIVELY, this software may be distributed under the terms of the | 13 | * This program is distributed in the hope that it will be useful, |
23 | * GNU General Public License ("GPL") version 2, as published by the Free | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
24 | * Software Foundation. | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
25 | * | 16 | * GNU General Public License for more details. |
26 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS | ||
27 | * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
28 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
29 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | ||
30 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
31 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
32 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
33 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
34 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
35 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
36 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
37 | */ | 17 | */ |
38 | 18 | ||
39 | #include <linux/kernel.h> | 19 | #include <linux/kernel.h> |
@@ -520,6 +500,8 @@ static int __dwc3_gadget_ep_enable(struct dwc3_ep *dep, | |||
520 | u32 reg; | 500 | u32 reg; |
521 | int ret = -ENOMEM; | 501 | int ret = -ENOMEM; |
522 | 502 | ||
503 | dev_vdbg(dwc->dev, "Enabling %s\n", dep->name); | ||
504 | |||
523 | if (!(dep->flags & DWC3_EP_ENABLED)) { | 505 | if (!(dep->flags & DWC3_EP_ENABLED)) { |
524 | ret = dwc3_gadget_start_config(dwc, dep); | 506 | ret = dwc3_gadget_start_config(dwc, dep); |
525 | if (ret) | 507 | if (ret) |
@@ -676,8 +658,6 @@ static int dwc3_gadget_ep_enable(struct usb_ep *ep, | |||
676 | dev_err(dwc->dev, "invalid endpoint transfer type\n"); | 658 | dev_err(dwc->dev, "invalid endpoint transfer type\n"); |
677 | } | 659 | } |
678 | 660 | ||
679 | dev_vdbg(dwc->dev, "Enabling %s\n", dep->name); | ||
680 | |||
681 | spin_lock_irqsave(&dwc->lock, flags); | 661 | spin_lock_irqsave(&dwc->lock, flags); |
682 | ret = __dwc3_gadget_ep_enable(dep, desc, ep->comp_desc, false); | 662 | ret = __dwc3_gadget_ep_enable(dep, desc, ep->comp_desc, false); |
683 | spin_unlock_irqrestore(&dwc->lock, flags); | 663 | spin_unlock_irqrestore(&dwc->lock, flags); |
@@ -1508,6 +1488,15 @@ static int dwc3_gadget_start(struct usb_gadget *g, | |||
1508 | int irq; | 1488 | int irq; |
1509 | u32 reg; | 1489 | u32 reg; |
1510 | 1490 | ||
1491 | irq = platform_get_irq(to_platform_device(dwc->dev), 0); | ||
1492 | ret = request_threaded_irq(irq, dwc3_interrupt, dwc3_thread_interrupt, | ||
1493 | IRQF_SHARED, "dwc3", dwc); | ||
1494 | if (ret) { | ||
1495 | dev_err(dwc->dev, "failed to request irq #%d --> %d\n", | ||
1496 | irq, ret); | ||
1497 | goto err0; | ||
1498 | } | ||
1499 | |||
1511 | spin_lock_irqsave(&dwc->lock, flags); | 1500 | spin_lock_irqsave(&dwc->lock, flags); |
1512 | 1501 | ||
1513 | if (dwc->gadget_driver) { | 1502 | if (dwc->gadget_driver) { |
@@ -1515,7 +1504,7 @@ static int dwc3_gadget_start(struct usb_gadget *g, | |||
1515 | dwc->gadget.name, | 1504 | dwc->gadget.name, |
1516 | dwc->gadget_driver->driver.name); | 1505 | dwc->gadget_driver->driver.name); |
1517 | ret = -EBUSY; | 1506 | ret = -EBUSY; |
1518 | goto err0; | 1507 | goto err1; |
1519 | } | 1508 | } |
1520 | 1509 | ||
1521 | dwc->gadget_driver = driver; | 1510 | dwc->gadget_driver = driver; |
@@ -1536,10 +1525,25 @@ static int dwc3_gadget_start(struct usb_gadget *g, | |||
1536 | * STAR#9000525659: Clock Domain Crossing on DCTL in | 1525 | * STAR#9000525659: Clock Domain Crossing on DCTL in |
1537 | * USB 2.0 Mode | 1526 | * USB 2.0 Mode |
1538 | */ | 1527 | */ |
1539 | if (dwc->revision < DWC3_REVISION_220A) | 1528 | if (dwc->revision < DWC3_REVISION_220A) { |
1540 | reg |= DWC3_DCFG_SUPERSPEED; | 1529 | reg |= DWC3_DCFG_SUPERSPEED; |
1541 | else | 1530 | } else { |
1542 | reg |= dwc->maximum_speed; | 1531 | switch (dwc->maximum_speed) { |
1532 | case USB_SPEED_LOW: | ||
1533 | reg |= DWC3_DSTS_LOWSPEED; | ||
1534 | break; | ||
1535 | case USB_SPEED_FULL: | ||
1536 | reg |= DWC3_DSTS_FULLSPEED1; | ||
1537 | break; | ||
1538 | case USB_SPEED_HIGH: | ||
1539 | reg |= DWC3_DSTS_HIGHSPEED; | ||
1540 | break; | ||
1541 | case USB_SPEED_SUPER: /* FALLTHROUGH */ | ||
1542 | case USB_SPEED_UNKNOWN: /* FALTHROUGH */ | ||
1543 | default: | ||
1544 | reg |= DWC3_DSTS_SUPERSPEED; | ||
1545 | } | ||
1546 | } | ||
1543 | dwc3_writel(dwc->regs, DWC3_DCFG, reg); | 1547 | dwc3_writel(dwc->regs, DWC3_DCFG, reg); |
1544 | 1548 | ||
1545 | dwc->start_config_issued = false; | 1549 | dwc->start_config_issued = false; |
@@ -1551,42 +1555,38 @@ static int dwc3_gadget_start(struct usb_gadget *g, | |||
1551 | ret = __dwc3_gadget_ep_enable(dep, &dwc3_gadget_ep0_desc, NULL, false); | 1555 | ret = __dwc3_gadget_ep_enable(dep, &dwc3_gadget_ep0_desc, NULL, false); |
1552 | if (ret) { | 1556 | if (ret) { |
1553 | dev_err(dwc->dev, "failed to enable %s\n", dep->name); | 1557 | dev_err(dwc->dev, "failed to enable %s\n", dep->name); |
1554 | goto err0; | 1558 | goto err2; |
1555 | } | 1559 | } |
1556 | 1560 | ||
1557 | dep = dwc->eps[1]; | 1561 | dep = dwc->eps[1]; |
1558 | ret = __dwc3_gadget_ep_enable(dep, &dwc3_gadget_ep0_desc, NULL, false); | 1562 | ret = __dwc3_gadget_ep_enable(dep, &dwc3_gadget_ep0_desc, NULL, false); |
1559 | if (ret) { | 1563 | if (ret) { |
1560 | dev_err(dwc->dev, "failed to enable %s\n", dep->name); | 1564 | dev_err(dwc->dev, "failed to enable %s\n", dep->name); |
1561 | goto err1; | 1565 | goto err3; |
1562 | } | 1566 | } |
1563 | 1567 | ||
1564 | /* begin to receive SETUP packets */ | 1568 | /* begin to receive SETUP packets */ |
1565 | dwc->ep0state = EP0_SETUP_PHASE; | 1569 | dwc->ep0state = EP0_SETUP_PHASE; |
1566 | dwc3_ep0_out_start(dwc); | 1570 | dwc3_ep0_out_start(dwc); |
1567 | 1571 | ||
1568 | irq = platform_get_irq(to_platform_device(dwc->dev), 0); | ||
1569 | ret = request_threaded_irq(irq, dwc3_interrupt, dwc3_thread_interrupt, | ||
1570 | IRQF_SHARED | IRQF_ONESHOT, "dwc3", dwc); | ||
1571 | if (ret) { | ||
1572 | dev_err(dwc->dev, "failed to request irq #%d --> %d\n", | ||
1573 | irq, ret); | ||
1574 | goto err1; | ||
1575 | } | ||
1576 | |||
1577 | dwc3_gadget_enable_irq(dwc); | 1572 | dwc3_gadget_enable_irq(dwc); |
1578 | 1573 | ||
1579 | spin_unlock_irqrestore(&dwc->lock, flags); | 1574 | spin_unlock_irqrestore(&dwc->lock, flags); |
1580 | 1575 | ||
1581 | return 0; | 1576 | return 0; |
1582 | 1577 | ||
1583 | err1: | 1578 | err3: |
1584 | __dwc3_gadget_ep_disable(dwc->eps[0]); | 1579 | __dwc3_gadget_ep_disable(dwc->eps[0]); |
1585 | 1580 | ||
1586 | err0: | 1581 | err2: |
1587 | dwc->gadget_driver = NULL; | 1582 | dwc->gadget_driver = NULL; |
1583 | |||
1584 | err1: | ||
1588 | spin_unlock_irqrestore(&dwc->lock, flags); | 1585 | spin_unlock_irqrestore(&dwc->lock, flags); |
1589 | 1586 | ||
1587 | free_irq(irq, dwc); | ||
1588 | |||
1589 | err0: | ||
1590 | return ret; | 1590 | return ret; |
1591 | } | 1591 | } |
1592 | 1592 | ||
@@ -1600,9 +1600,6 @@ static int dwc3_gadget_stop(struct usb_gadget *g, | |||
1600 | spin_lock_irqsave(&dwc->lock, flags); | 1600 | spin_lock_irqsave(&dwc->lock, flags); |
1601 | 1601 | ||
1602 | dwc3_gadget_disable_irq(dwc); | 1602 | dwc3_gadget_disable_irq(dwc); |
1603 | irq = platform_get_irq(to_platform_device(dwc->dev), 0); | ||
1604 | free_irq(irq, dwc); | ||
1605 | |||
1606 | __dwc3_gadget_ep_disable(dwc->eps[0]); | 1603 | __dwc3_gadget_ep_disable(dwc->eps[0]); |
1607 | __dwc3_gadget_ep_disable(dwc->eps[1]); | 1604 | __dwc3_gadget_ep_disable(dwc->eps[1]); |
1608 | 1605 | ||
@@ -1610,6 +1607,9 @@ static int dwc3_gadget_stop(struct usb_gadget *g, | |||
1610 | 1607 | ||
1611 | spin_unlock_irqrestore(&dwc->lock, flags); | 1608 | spin_unlock_irqrestore(&dwc->lock, flags); |
1612 | 1609 | ||
1610 | irq = platform_get_irq(to_platform_device(dwc->dev), 0); | ||
1611 | free_irq(irq, dwc); | ||
1612 | |||
1613 | return 0; | 1613 | return 0; |
1614 | } | 1614 | } |
1615 | 1615 | ||
@@ -1642,13 +1642,15 @@ static int dwc3_gadget_init_hw_endpoints(struct dwc3 *dwc, | |||
1642 | 1642 | ||
1643 | dep->dwc = dwc; | 1643 | dep->dwc = dwc; |
1644 | dep->number = epnum; | 1644 | dep->number = epnum; |
1645 | dep->direction = !!direction; | ||
1645 | dwc->eps[epnum] = dep; | 1646 | dwc->eps[epnum] = dep; |
1646 | 1647 | ||
1647 | snprintf(dep->name, sizeof(dep->name), "ep%d%s", epnum >> 1, | 1648 | snprintf(dep->name, sizeof(dep->name), "ep%d%s", epnum >> 1, |
1648 | (epnum & 1) ? "in" : "out"); | 1649 | (epnum & 1) ? "in" : "out"); |
1649 | 1650 | ||
1650 | dep->endpoint.name = dep->name; | 1651 | dep->endpoint.name = dep->name; |
1651 | dep->direction = (epnum & 1); | 1652 | |
1653 | dev_vdbg(dwc->dev, "initializing %s\n", dep->name); | ||
1652 | 1654 | ||
1653 | if (epnum == 0 || epnum == 1) { | 1655 | if (epnum == 0 || epnum == 1) { |
1654 | dep->endpoint.maxpacket = 512; | 1656 | dep->endpoint.maxpacket = 512; |
@@ -2105,34 +2107,6 @@ static void dwc3_gadget_disconnect_interrupt(struct dwc3 *dwc) | |||
2105 | dwc->setup_packet_pending = false; | 2107 | dwc->setup_packet_pending = false; |
2106 | } | 2108 | } |
2107 | 2109 | ||
2108 | static void dwc3_gadget_usb3_phy_suspend(struct dwc3 *dwc, int suspend) | ||
2109 | { | ||
2110 | u32 reg; | ||
2111 | |||
2112 | reg = dwc3_readl(dwc->regs, DWC3_GUSB3PIPECTL(0)); | ||
2113 | |||
2114 | if (suspend) | ||
2115 | reg |= DWC3_GUSB3PIPECTL_SUSPHY; | ||
2116 | else | ||
2117 | reg &= ~DWC3_GUSB3PIPECTL_SUSPHY; | ||
2118 | |||
2119 | dwc3_writel(dwc->regs, DWC3_GUSB3PIPECTL(0), reg); | ||
2120 | } | ||
2121 | |||
2122 | static void dwc3_gadget_usb2_phy_suspend(struct dwc3 *dwc, int suspend) | ||
2123 | { | ||
2124 | u32 reg; | ||
2125 | |||
2126 | reg = dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0)); | ||
2127 | |||
2128 | if (suspend) | ||
2129 | reg |= DWC3_GUSB2PHYCFG_SUSPHY; | ||
2130 | else | ||
2131 | reg &= ~DWC3_GUSB2PHYCFG_SUSPHY; | ||
2132 | |||
2133 | dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg); | ||
2134 | } | ||
2135 | |||
2136 | static void dwc3_gadget_reset_interrupt(struct dwc3 *dwc) | 2110 | static void dwc3_gadget_reset_interrupt(struct dwc3 *dwc) |
2137 | { | 2111 | { |
2138 | u32 reg; | 2112 | u32 reg; |
@@ -2173,13 +2147,6 @@ static void dwc3_gadget_reset_interrupt(struct dwc3 *dwc) | |||
2173 | /* after reset -> Default State */ | 2147 | /* after reset -> Default State */ |
2174 | usb_gadget_set_state(&dwc->gadget, USB_STATE_DEFAULT); | 2148 | usb_gadget_set_state(&dwc->gadget, USB_STATE_DEFAULT); |
2175 | 2149 | ||
2176 | /* Recent versions support automatic phy suspend and don't need this */ | ||
2177 | if (dwc->revision < DWC3_REVISION_194A) { | ||
2178 | /* Resume PHYs */ | ||
2179 | dwc3_gadget_usb2_phy_suspend(dwc, false); | ||
2180 | dwc3_gadget_usb3_phy_suspend(dwc, false); | ||
2181 | } | ||
2182 | |||
2183 | if (dwc->gadget.speed != USB_SPEED_UNKNOWN) | 2150 | if (dwc->gadget.speed != USB_SPEED_UNKNOWN) |
2184 | dwc3_disconnect_gadget(dwc); | 2151 | dwc3_disconnect_gadget(dwc); |
2185 | 2152 | ||
@@ -2223,20 +2190,6 @@ static void dwc3_update_ram_clk_sel(struct dwc3 *dwc, u32 speed) | |||
2223 | dwc3_writel(dwc->regs, DWC3_GCTL, reg); | 2190 | dwc3_writel(dwc->regs, DWC3_GCTL, reg); |
2224 | } | 2191 | } |
2225 | 2192 | ||
2226 | static void dwc3_gadget_phy_suspend(struct dwc3 *dwc, u8 speed) | ||
2227 | { | ||
2228 | switch (speed) { | ||
2229 | case USB_SPEED_SUPER: | ||
2230 | dwc3_gadget_usb2_phy_suspend(dwc, true); | ||
2231 | break; | ||
2232 | case USB_SPEED_HIGH: | ||
2233 | case USB_SPEED_FULL: | ||
2234 | case USB_SPEED_LOW: | ||
2235 | dwc3_gadget_usb3_phy_suspend(dwc, true); | ||
2236 | break; | ||
2237 | } | ||
2238 | } | ||
2239 | |||
2240 | static void dwc3_gadget_conndone_interrupt(struct dwc3 *dwc) | 2193 | static void dwc3_gadget_conndone_interrupt(struct dwc3 *dwc) |
2241 | { | 2194 | { |
2242 | struct dwc3_ep *dep; | 2195 | struct dwc3_ep *dep; |
@@ -2312,12 +2265,6 @@ static void dwc3_gadget_conndone_interrupt(struct dwc3 *dwc) | |||
2312 | dwc3_writel(dwc->regs, DWC3_DCTL, reg); | 2265 | dwc3_writel(dwc->regs, DWC3_DCTL, reg); |
2313 | } | 2266 | } |
2314 | 2267 | ||
2315 | /* Recent versions support automatic phy suspend and don't need this */ | ||
2316 | if (dwc->revision < DWC3_REVISION_194A) { | ||
2317 | /* Suspend unneeded PHY */ | ||
2318 | dwc3_gadget_phy_suspend(dwc, dwc->gadget.speed); | ||
2319 | } | ||
2320 | |||
2321 | dep = dwc->eps[0]; | 2268 | dep = dwc->eps[0]; |
2322 | ret = __dwc3_gadget_ep_enable(dep, &dwc3_gadget_ep0_desc, NULL, true); | 2269 | ret = __dwc3_gadget_ep_enable(dep, &dwc3_gadget_ep0_desc, NULL, true); |
2323 | if (ret) { | 2270 | if (ret) { |
@@ -2495,61 +2442,75 @@ static void dwc3_process_event_entry(struct dwc3 *dwc, | |||
2495 | } | 2442 | } |
2496 | } | 2443 | } |
2497 | 2444 | ||
2498 | static irqreturn_t dwc3_thread_interrupt(int irq, void *_dwc) | 2445 | static irqreturn_t dwc3_process_event_buf(struct dwc3 *dwc, u32 buf) |
2499 | { | 2446 | { |
2500 | struct dwc3 *dwc = _dwc; | 2447 | struct dwc3_event_buffer *evt; |
2501 | unsigned long flags; | ||
2502 | irqreturn_t ret = IRQ_NONE; | 2448 | irqreturn_t ret = IRQ_NONE; |
2503 | int i; | 2449 | int left; |
2450 | u32 reg; | ||
2504 | 2451 | ||
2505 | spin_lock_irqsave(&dwc->lock, flags); | 2452 | evt = dwc->ev_buffs[buf]; |
2453 | left = evt->count; | ||
2506 | 2454 | ||
2507 | for (i = 0; i < dwc->num_event_buffers; i++) { | 2455 | if (!(evt->flags & DWC3_EVENT_PENDING)) |
2508 | struct dwc3_event_buffer *evt; | 2456 | return IRQ_NONE; |
2509 | int left; | ||
2510 | 2457 | ||
2511 | evt = dwc->ev_buffs[i]; | 2458 | while (left > 0) { |
2512 | left = evt->count; | 2459 | union dwc3_event event; |
2513 | 2460 | ||
2514 | if (!(evt->flags & DWC3_EVENT_PENDING)) | 2461 | event.raw = *(u32 *) (evt->buf + evt->lpos); |
2515 | continue; | ||
2516 | 2462 | ||
2517 | while (left > 0) { | 2463 | dwc3_process_event_entry(dwc, &event); |
2518 | union dwc3_event event; | ||
2519 | 2464 | ||
2520 | event.raw = *(u32 *) (evt->buf + evt->lpos); | 2465 | /* |
2466 | * FIXME we wrap around correctly to the next entry as | ||
2467 | * almost all entries are 4 bytes in size. There is one | ||
2468 | * entry which has 12 bytes which is a regular entry | ||
2469 | * followed by 8 bytes data. ATM I don't know how | ||
2470 | * things are organized if we get next to the a | ||
2471 | * boundary so I worry about that once we try to handle | ||
2472 | * that. | ||
2473 | */ | ||
2474 | evt->lpos = (evt->lpos + 4) % DWC3_EVENT_BUFFERS_SIZE; | ||
2475 | left -= 4; | ||
2521 | 2476 | ||
2522 | dwc3_process_event_entry(dwc, &event); | 2477 | dwc3_writel(dwc->regs, DWC3_GEVNTCOUNT(buf), 4); |
2478 | } | ||
2523 | 2479 | ||
2524 | /* | 2480 | evt->count = 0; |
2525 | * FIXME we wrap around correctly to the next entry as | 2481 | evt->flags &= ~DWC3_EVENT_PENDING; |
2526 | * almost all entries are 4 bytes in size. There is one | 2482 | ret = IRQ_HANDLED; |
2527 | * entry which has 12 bytes which is a regular entry | ||
2528 | * followed by 8 bytes data. ATM I don't know how | ||
2529 | * things are organized if we get next to the a | ||
2530 | * boundary so I worry about that once we try to handle | ||
2531 | * that. | ||
2532 | */ | ||
2533 | evt->lpos = (evt->lpos + 4) % DWC3_EVENT_BUFFERS_SIZE; | ||
2534 | left -= 4; | ||
2535 | 2483 | ||
2536 | dwc3_writel(dwc->regs, DWC3_GEVNTCOUNT(i), 4); | 2484 | /* Unmask interrupt */ |
2537 | } | 2485 | reg = dwc3_readl(dwc->regs, DWC3_GEVNTSIZ(buf)); |
2486 | reg &= ~DWC3_GEVNTSIZ_INTMASK; | ||
2487 | dwc3_writel(dwc->regs, DWC3_GEVNTSIZ(buf), reg); | ||
2538 | 2488 | ||
2539 | evt->count = 0; | 2489 | return ret; |
2540 | evt->flags &= ~DWC3_EVENT_PENDING; | 2490 | } |
2541 | ret = IRQ_HANDLED; | 2491 | |
2542 | } | 2492 | static irqreturn_t dwc3_thread_interrupt(int irq, void *_dwc) |
2493 | { | ||
2494 | struct dwc3 *dwc = _dwc; | ||
2495 | unsigned long flags; | ||
2496 | irqreturn_t ret = IRQ_NONE; | ||
2497 | int i; | ||
2498 | |||
2499 | spin_lock_irqsave(&dwc->lock, flags); | ||
2500 | |||
2501 | for (i = 0; i < dwc->num_event_buffers; i++) | ||
2502 | ret |= dwc3_process_event_buf(dwc, i); | ||
2543 | 2503 | ||
2544 | spin_unlock_irqrestore(&dwc->lock, flags); | 2504 | spin_unlock_irqrestore(&dwc->lock, flags); |
2545 | 2505 | ||
2546 | return ret; | 2506 | return ret; |
2547 | } | 2507 | } |
2548 | 2508 | ||
2549 | static irqreturn_t dwc3_process_event_buf(struct dwc3 *dwc, u32 buf) | 2509 | static irqreturn_t dwc3_check_event_buf(struct dwc3 *dwc, u32 buf) |
2550 | { | 2510 | { |
2551 | struct dwc3_event_buffer *evt; | 2511 | struct dwc3_event_buffer *evt; |
2552 | u32 count; | 2512 | u32 count; |
2513 | u32 reg; | ||
2553 | 2514 | ||
2554 | evt = dwc->ev_buffs[buf]; | 2515 | evt = dwc->ev_buffs[buf]; |
2555 | 2516 | ||
@@ -2561,6 +2522,11 @@ static irqreturn_t dwc3_process_event_buf(struct dwc3 *dwc, u32 buf) | |||
2561 | evt->count = count; | 2522 | evt->count = count; |
2562 | evt->flags |= DWC3_EVENT_PENDING; | 2523 | evt->flags |= DWC3_EVENT_PENDING; |
2563 | 2524 | ||
2525 | /* Mask interrupt */ | ||
2526 | reg = dwc3_readl(dwc->regs, DWC3_GEVNTSIZ(buf)); | ||
2527 | reg |= DWC3_GEVNTSIZ_INTMASK; | ||
2528 | dwc3_writel(dwc->regs, DWC3_GEVNTSIZ(buf), reg); | ||
2529 | |||
2564 | return IRQ_WAKE_THREAD; | 2530 | return IRQ_WAKE_THREAD; |
2565 | } | 2531 | } |
2566 | 2532 | ||
@@ -2575,7 +2541,7 @@ static irqreturn_t dwc3_interrupt(int irq, void *_dwc) | |||
2575 | for (i = 0; i < dwc->num_event_buffers; i++) { | 2541 | for (i = 0; i < dwc->num_event_buffers; i++) { |
2576 | irqreturn_t status; | 2542 | irqreturn_t status; |
2577 | 2543 | ||
2578 | status = dwc3_process_event_buf(dwc, i); | 2544 | status = dwc3_check_event_buf(dwc, i); |
2579 | if (status == IRQ_WAKE_THREAD) | 2545 | if (status == IRQ_WAKE_THREAD) |
2580 | ret = status; | 2546 | ret = status; |
2581 | } | 2547 | } |
@@ -2593,7 +2559,6 @@ static irqreturn_t dwc3_interrupt(int irq, void *_dwc) | |||
2593 | */ | 2559 | */ |
2594 | int dwc3_gadget_init(struct dwc3 *dwc) | 2560 | int dwc3_gadget_init(struct dwc3 *dwc) |
2595 | { | 2561 | { |
2596 | u32 reg; | ||
2597 | int ret; | 2562 | int ret; |
2598 | 2563 | ||
2599 | dwc->ctrl_req = dma_alloc_coherent(dwc->dev, sizeof(*dwc->ctrl_req), | 2564 | dwc->ctrl_req = dma_alloc_coherent(dwc->dev, sizeof(*dwc->ctrl_req), |
@@ -2643,16 +2608,6 @@ int dwc3_gadget_init(struct dwc3 *dwc) | |||
2643 | if (ret) | 2608 | if (ret) |
2644 | goto err4; | 2609 | goto err4; |
2645 | 2610 | ||
2646 | reg = dwc3_readl(dwc->regs, DWC3_DCFG); | ||
2647 | reg |= DWC3_DCFG_LPM_CAP; | ||
2648 | dwc3_writel(dwc->regs, DWC3_DCFG, reg); | ||
2649 | |||
2650 | /* Enable USB2 LPM and automatic phy suspend only on recent versions */ | ||
2651 | if (dwc->revision >= DWC3_REVISION_194A) { | ||
2652 | dwc3_gadget_usb2_phy_suspend(dwc, false); | ||
2653 | dwc3_gadget_usb3_phy_suspend(dwc, false); | ||
2654 | } | ||
2655 | |||
2656 | ret = usb_add_gadget_udc(dwc->dev, &dwc->gadget); | 2611 | ret = usb_add_gadget_udc(dwc->dev, &dwc->gadget); |
2657 | if (ret) { | 2612 | if (ret) { |
2658 | dev_err(dwc->dev, "failed to register udc\n"); | 2613 | dev_err(dwc->dev, "failed to register udc\n"); |
diff --git a/drivers/usb/dwc3/gadget.h b/drivers/usb/dwc3/gadget.h index 99e6d7248820..febe1aa7b714 100644 --- a/drivers/usb/dwc3/gadget.h +++ b/drivers/usb/dwc3/gadget.h | |||
@@ -6,34 +6,14 @@ | |||
6 | * Authors: Felipe Balbi <balbi@ti.com>, | 6 | * Authors: Felipe Balbi <balbi@ti.com>, |
7 | * Sebastian Andrzej Siewior <bigeasy@linutronix.de> | 7 | * Sebastian Andrzej Siewior <bigeasy@linutronix.de> |
8 | * | 8 | * |
9 | * Redistribution and use in source and binary forms, with or without | 9 | * This program is free software: you can redistribute it and/or modify |
10 | * modification, are permitted provided that the following conditions | 10 | * it under the terms of the GNU General Public License version 2 of |
11 | * are met: | 11 | * the License as published by the Free Software Foundation. |
12 | * 1. Redistributions of source code must retain the above copyright | ||
13 | * notice, this list of conditions, and the following disclaimer, | ||
14 | * without modification. | ||
15 | * 2. Redistributions in binary form must reproduce the above copyright | ||
16 | * notice, this list of conditions and the following disclaimer in the | ||
17 | * documentation and/or other materials provided with the distribution. | ||
18 | * 3. The names of the above-listed copyright holders may not be used | ||
19 | * to endorse or promote products derived from this software without | ||
20 | * specific prior written permission. | ||
21 | * | 12 | * |
22 | * ALTERNATIVELY, this software may be distributed under the terms of the | 13 | * This program is distributed in the hope that it will be useful, |
23 | * GNU General Public License ("GPL") version 2, as published by the Free | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
24 | * Software Foundation. | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
25 | * | 16 | * GNU General Public License for more details. |
26 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS | ||
27 | * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
28 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
29 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | ||
30 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
31 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
32 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
33 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
34 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
35 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
36 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
37 | */ | 17 | */ |
38 | 18 | ||
39 | #ifndef __DRIVERS_USB_DWC3_GADGET_H | 19 | #ifndef __DRIVERS_USB_DWC3_GADGET_H |
diff --git a/drivers/usb/dwc3/host.c b/drivers/usb/dwc3/host.c index 0fa1846eda4c..32db328cc769 100644 --- a/drivers/usb/dwc3/host.c +++ b/drivers/usb/dwc3/host.c | |||
@@ -5,34 +5,14 @@ | |||
5 | * | 5 | * |
6 | * Authors: Felipe Balbi <balbi@ti.com>, | 6 | * Authors: Felipe Balbi <balbi@ti.com>, |
7 | * | 7 | * |
8 | * Redistribution and use in source and binary forms, with or without | 8 | * This program is free software: you can redistribute it and/or modify |
9 | * modification, are permitted provided that the following conditions | 9 | * it under the terms of the GNU General Public License version 2 of |
10 | * are met: | 10 | * the License as published by the Free Software Foundation. |
11 | * 1. Redistributions of source code must retain the above copyright | ||
12 | * notice, this list of conditions, and the following disclaimer, | ||
13 | * without modification. | ||
14 | * 2. Redistributions in binary form must reproduce the above copyright | ||
15 | * notice, this list of conditions and the following disclaimer in the | ||
16 | * documentation and/or other materials provided with the distribution. | ||
17 | * 3. The names of the above-listed copyright holders may not be used | ||
18 | * to endorse or promote products derived from this software without | ||
19 | * specific prior written permission. | ||
20 | * | 11 | * |
21 | * ALTERNATIVELY, this software may be distributed under the terms of the | 12 | * This program is distributed in the hope that it will be useful, |
22 | * GNU General Public License ("GPL") version 2, as published by the Free | 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
23 | * Software Foundation. | 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
24 | * | 15 | * GNU General Public License for more details. |
25 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS | ||
26 | * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
27 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
28 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | ||
29 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
30 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
31 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
32 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
33 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
34 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
35 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
36 | */ | 16 | */ |
37 | 17 | ||
38 | #include <linux/platform_device.h> | 18 | #include <linux/platform_device.h> |
diff --git a/drivers/usb/dwc3/io.h b/drivers/usb/dwc3/io.h index a50f76b9d19b..d94441c14d8c 100644 --- a/drivers/usb/dwc3/io.h +++ b/drivers/usb/dwc3/io.h | |||
@@ -6,34 +6,14 @@ | |||
6 | * Authors: Felipe Balbi <balbi@ti.com>, | 6 | * Authors: Felipe Balbi <balbi@ti.com>, |
7 | * Sebastian Andrzej Siewior <bigeasy@linutronix.de> | 7 | * Sebastian Andrzej Siewior <bigeasy@linutronix.de> |
8 | * | 8 | * |
9 | * Redistribution and use in source and binary forms, with or without | 9 | * This program is free software: you can redistribute it and/or modify |
10 | * modification, are permitted provided that the following conditions | 10 | * it under the terms of the GNU General Public License version 2 of |
11 | * are met: | 11 | * the License as published by the Free Software Foundation. |
12 | * 1. Redistributions of source code must retain the above copyright | ||
13 | * notice, this list of conditions, and the following disclaimer, | ||
14 | * without modification. | ||
15 | * 2. Redistributions in binary form must reproduce the above copyright | ||
16 | * notice, this list of conditions and the following disclaimer in the | ||
17 | * documentation and/or other materials provided with the distribution. | ||
18 | * 3. The names of the above-listed copyright holders may not be used | ||
19 | * to endorse or promote products derived from this software without | ||
20 | * specific prior written permission. | ||
21 | * | 12 | * |
22 | * ALTERNATIVELY, this software may be distributed under the terms of the | 13 | * This program is distributed in the hope that it will be useful, |
23 | * GNU General Public License ("GPL") version 2, as published by the Free | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
24 | * Software Foundation. | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
25 | * | 16 | * GNU General Public License for more details. |
26 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS | ||
27 | * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
28 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
29 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | ||
30 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
31 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
32 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
33 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
34 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
35 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
36 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
37 | */ | 17 | */ |
38 | 18 | ||
39 | #ifndef __DRIVERS_USB_DWC3_IO_H | 19 | #ifndef __DRIVERS_USB_DWC3_IO_H |
diff --git a/drivers/usb/dwc3/platform_data.h b/drivers/usb/dwc3/platform_data.h new file mode 100644 index 000000000000..7db34f00b89a --- /dev/null +++ b/drivers/usb/dwc3/platform_data.h | |||
@@ -0,0 +1,27 @@ | |||
1 | /** | ||
2 | * platform_data.h - USB DWC3 Platform Data Support | ||
3 | * | ||
4 | * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com | ||
5 | * Author: Felipe Balbi <balbi@ti.com> | ||
6 | * | ||
7 | * This program is free software: you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License version 2 of | ||
9 | * the License as published by the Free Software Foundation. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
18 | */ | ||
19 | |||
20 | #include <linux/usb/ch9.h> | ||
21 | #include <linux/usb/otg.h> | ||
22 | |||
23 | struct dwc3_platform_data { | ||
24 | enum usb_device_speed maximum_speed; | ||
25 | enum usb_dr_mode dr_mode; | ||
26 | bool tx_fifo_resize; | ||
27 | }; | ||
diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig index 8e9368330b10..1e3f52574367 100644 --- a/drivers/usb/gadget/Kconfig +++ b/drivers/usb/gadget/Kconfig | |||
@@ -144,7 +144,6 @@ config USB_AT91 | |||
144 | config USB_LPC32XX | 144 | config USB_LPC32XX |
145 | tristate "LPC32XX USB Peripheral Controller" | 145 | tristate "LPC32XX USB Peripheral Controller" |
146 | depends on ARCH_LPC32XX | 146 | depends on ARCH_LPC32XX |
147 | depends on USB_PHY | ||
148 | select USB_ISP1301 | 147 | select USB_ISP1301 |
149 | help | 148 | help |
150 | This option selects the USB device controller in the LPC32xx SoC. | 149 | This option selects the USB device controller in the LPC32xx SoC. |
@@ -206,7 +205,6 @@ config USB_FOTG210_UDC | |||
206 | config USB_OMAP | 205 | config USB_OMAP |
207 | tristate "OMAP USB Device Controller" | 206 | tristate "OMAP USB Device Controller" |
208 | depends on ARCH_OMAP1 | 207 | depends on ARCH_OMAP1 |
209 | depends on USB_PHY | ||
210 | select ISP1301_OMAP if MACH_OMAP_H2 || MACH_OMAP_H3 || MACH_OMAP_H4_OTG | 208 | select ISP1301_OMAP if MACH_OMAP_H2 || MACH_OMAP_H3 || MACH_OMAP_H4_OTG |
211 | help | 209 | help |
212 | Many Texas Instruments OMAP processors have flexible full | 210 | Many Texas Instruments OMAP processors have flexible full |
@@ -287,21 +285,6 @@ config USB_S3C_HSOTG | |||
287 | The Samsung S3C64XX USB2.0 high-speed gadget controller | 285 | The Samsung S3C64XX USB2.0 high-speed gadget controller |
288 | integrated into the S3C64XX series SoC. | 286 | integrated into the S3C64XX series SoC. |
289 | 287 | ||
290 | config USB_IMX | ||
291 | tristate "Freescale i.MX1 USB Peripheral Controller" | ||
292 | depends on ARCH_MXC | ||
293 | depends on BROKEN | ||
294 | help | ||
295 | Freescale's i.MX1 includes an integrated full speed | ||
296 | USB 1.1 device controller. | ||
297 | |||
298 | It has Six fixed-function endpoints, as well as endpoint | ||
299 | zero (for control transfers). | ||
300 | |||
301 | Say "y" to link the driver statically, or "m" to build a | ||
302 | dynamically linked module called "imx_udc" and force all | ||
303 | gadget drivers to also be dynamically linked. | ||
304 | |||
305 | config USB_S3C2410 | 288 | config USB_S3C2410 |
306 | tristate "S3C2410 USB Device Controller" | 289 | tristate "S3C2410 USB Device Controller" |
307 | depends on ARCH_S3C24XX | 290 | depends on ARCH_S3C24XX |
diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile index bad08e66f369..386db9daf1d9 100644 --- a/drivers/usb/gadget/Makefile +++ b/drivers/usb/gadget/Makefile | |||
@@ -13,7 +13,6 @@ obj-$(CONFIG_USB_NET2280) += net2280.o | |||
13 | obj-$(CONFIG_USB_AMD5536UDC) += amd5536udc.o | 13 | obj-$(CONFIG_USB_AMD5536UDC) += amd5536udc.o |
14 | obj-$(CONFIG_USB_PXA25X) += pxa25x_udc.o | 14 | obj-$(CONFIG_USB_PXA25X) += pxa25x_udc.o |
15 | obj-$(CONFIG_USB_PXA27X) += pxa27x_udc.o | 15 | obj-$(CONFIG_USB_PXA27X) += pxa27x_udc.o |
16 | obj-$(CONFIG_USB_IMX) += imx_udc.o | ||
17 | obj-$(CONFIG_USB_GOKU) += goku_udc.o | 16 | obj-$(CONFIG_USB_GOKU) += goku_udc.o |
18 | obj-$(CONFIG_USB_OMAP) += omap_udc.o | 17 | obj-$(CONFIG_USB_OMAP) += omap_udc.o |
19 | obj-$(CONFIG_USB_S3C2410) += s3c2410_udc.o | 18 | obj-$(CONFIG_USB_S3C2410) += s3c2410_udc.o |
diff --git a/drivers/usb/gadget/amd5536udc.c b/drivers/usb/gadget/amd5536udc.c index f52dcfe8f545..a9a4346c83aa 100644 --- a/drivers/usb/gadget/amd5536udc.c +++ b/drivers/usb/gadget/amd5536udc.c | |||
@@ -1122,7 +1122,7 @@ udc_queue(struct usb_ep *usbep, struct usb_request *usbreq, gfp_t gfp) | |||
1122 | goto finished; | 1122 | goto finished; |
1123 | } | 1123 | } |
1124 | if (ep->dma) { | 1124 | if (ep->dma) { |
1125 | retval = prep_dma(ep, req, gfp); | 1125 | retval = prep_dma(ep, req, GFP_ATOMIC); |
1126 | if (retval != 0) | 1126 | if (retval != 0) |
1127 | goto finished; | 1127 | goto finished; |
1128 | /* write desc pointer to enable DMA */ | 1128 | /* write desc pointer to enable DMA */ |
@@ -1190,7 +1190,7 @@ udc_queue(struct usb_ep *usbep, struct usb_request *usbreq, gfp_t gfp) | |||
1190 | * for PPB modes, because of chain creation reasons | 1190 | * for PPB modes, because of chain creation reasons |
1191 | */ | 1191 | */ |
1192 | if (ep->in) { | 1192 | if (ep->in) { |
1193 | retval = prep_dma(ep, req, gfp); | 1193 | retval = prep_dma(ep, req, GFP_ATOMIC); |
1194 | if (retval != 0) | 1194 | if (retval != 0) |
1195 | goto finished; | 1195 | goto finished; |
1196 | } | 1196 | } |
diff --git a/drivers/usb/gadget/at91_udc.c b/drivers/usb/gadget/at91_udc.c index d9a6add0c852..4cc4fd6d1473 100644 --- a/drivers/usb/gadget/at91_udc.c +++ b/drivers/usb/gadget/at91_udc.c | |||
@@ -870,6 +870,11 @@ static void clk_on(struct at91_udc *udc) | |||
870 | if (udc->clocked) | 870 | if (udc->clocked) |
871 | return; | 871 | return; |
872 | udc->clocked = 1; | 872 | udc->clocked = 1; |
873 | |||
874 | if (IS_ENABLED(CONFIG_COMMON_CLK)) { | ||
875 | clk_set_rate(udc->uclk, 48000000); | ||
876 | clk_prepare_enable(udc->uclk); | ||
877 | } | ||
873 | clk_prepare_enable(udc->iclk); | 878 | clk_prepare_enable(udc->iclk); |
874 | clk_prepare_enable(udc->fclk); | 879 | clk_prepare_enable(udc->fclk); |
875 | } | 880 | } |
@@ -882,6 +887,8 @@ static void clk_off(struct at91_udc *udc) | |||
882 | udc->gadget.speed = USB_SPEED_UNKNOWN; | 887 | udc->gadget.speed = USB_SPEED_UNKNOWN; |
883 | clk_disable_unprepare(udc->fclk); | 888 | clk_disable_unprepare(udc->fclk); |
884 | clk_disable_unprepare(udc->iclk); | 889 | clk_disable_unprepare(udc->iclk); |
890 | if (IS_ENABLED(CONFIG_COMMON_CLK)) | ||
891 | clk_disable_unprepare(udc->uclk); | ||
885 | } | 892 | } |
886 | 893 | ||
887 | /* | 894 | /* |
@@ -1697,7 +1704,7 @@ static int at91udc_probe(struct platform_device *pdev) | |||
1697 | int retval; | 1704 | int retval; |
1698 | struct resource *res; | 1705 | struct resource *res; |
1699 | 1706 | ||
1700 | if (!dev->platform_data && !pdev->dev.of_node) { | 1707 | if (!dev_get_platdata(dev) && !pdev->dev.of_node) { |
1701 | /* small (so we copy it) but critical! */ | 1708 | /* small (so we copy it) but critical! */ |
1702 | DBG("missing platform_data\n"); | 1709 | DBG("missing platform_data\n"); |
1703 | return -ENODEV; | 1710 | return -ENODEV; |
@@ -1728,7 +1735,7 @@ static int at91udc_probe(struct platform_device *pdev) | |||
1728 | if (IS_ENABLED(CONFIG_OF) && pdev->dev.of_node) | 1735 | if (IS_ENABLED(CONFIG_OF) && pdev->dev.of_node) |
1729 | at91udc_of_init(udc, pdev->dev.of_node); | 1736 | at91udc_of_init(udc, pdev->dev.of_node); |
1730 | else | 1737 | else |
1731 | memcpy(&udc->board, dev->platform_data, | 1738 | memcpy(&udc->board, dev_get_platdata(dev), |
1732 | sizeof(struct at91_udc_data)); | 1739 | sizeof(struct at91_udc_data)); |
1733 | udc->pdev = pdev; | 1740 | udc->pdev = pdev; |
1734 | udc->enabled = 0; | 1741 | udc->enabled = 0; |
@@ -1774,10 +1781,12 @@ static int at91udc_probe(struct platform_device *pdev) | |||
1774 | /* get interface and function clocks */ | 1781 | /* get interface and function clocks */ |
1775 | udc->iclk = clk_get(dev, "udc_clk"); | 1782 | udc->iclk = clk_get(dev, "udc_clk"); |
1776 | udc->fclk = clk_get(dev, "udpck"); | 1783 | udc->fclk = clk_get(dev, "udpck"); |
1777 | if (IS_ERR(udc->iclk) || IS_ERR(udc->fclk)) { | 1784 | if (IS_ENABLED(CONFIG_COMMON_CLK)) |
1785 | udc->uclk = clk_get(dev, "usb_clk"); | ||
1786 | if (IS_ERR(udc->iclk) || IS_ERR(udc->fclk) || | ||
1787 | (IS_ENABLED(CONFIG_COMMON_CLK) && IS_ERR(udc->uclk))) { | ||
1778 | DBG("clocks missing\n"); | 1788 | DBG("clocks missing\n"); |
1779 | retval = -ENODEV; | 1789 | retval = -ENODEV; |
1780 | /* NOTE: we "know" here that refcounts on these are NOPs */ | ||
1781 | goto fail1; | 1790 | goto fail1; |
1782 | } | 1791 | } |
1783 | 1792 | ||
@@ -1851,6 +1860,12 @@ fail3: | |||
1851 | fail2: | 1860 | fail2: |
1852 | free_irq(udc->udp_irq, udc); | 1861 | free_irq(udc->udp_irq, udc); |
1853 | fail1: | 1862 | fail1: |
1863 | if (IS_ENABLED(CONFIG_COMMON_CLK) && !IS_ERR(udc->uclk)) | ||
1864 | clk_put(udc->uclk); | ||
1865 | if (!IS_ERR(udc->fclk)) | ||
1866 | clk_put(udc->fclk); | ||
1867 | if (!IS_ERR(udc->iclk)) | ||
1868 | clk_put(udc->iclk); | ||
1854 | iounmap(udc->udp_baseaddr); | 1869 | iounmap(udc->udp_baseaddr); |
1855 | fail0a: | 1870 | fail0a: |
1856 | if (cpu_is_at91rm9200()) | 1871 | if (cpu_is_at91rm9200()) |
@@ -1894,6 +1909,8 @@ static int __exit at91udc_remove(struct platform_device *pdev) | |||
1894 | 1909 | ||
1895 | clk_put(udc->iclk); | 1910 | clk_put(udc->iclk); |
1896 | clk_put(udc->fclk); | 1911 | clk_put(udc->fclk); |
1912 | if (IS_ENABLED(CONFIG_COMMON_CLK)) | ||
1913 | clk_put(udc->uclk); | ||
1897 | 1914 | ||
1898 | return 0; | 1915 | return 0; |
1899 | } | 1916 | } |
diff --git a/drivers/usb/gadget/at91_udc.h b/drivers/usb/gadget/at91_udc.h index e647d1c2ada4..017524663381 100644 --- a/drivers/usb/gadget/at91_udc.h +++ b/drivers/usb/gadget/at91_udc.h | |||
@@ -126,7 +126,7 @@ struct at91_udc { | |||
126 | unsigned active_suspend:1; | 126 | unsigned active_suspend:1; |
127 | u8 addr; | 127 | u8 addr; |
128 | struct at91_udc_data board; | 128 | struct at91_udc_data board; |
129 | struct clk *iclk, *fclk; | 129 | struct clk *iclk, *fclk, *uclk; |
130 | struct platform_device *pdev; | 130 | struct platform_device *pdev; |
131 | struct proc_dir_entry *pde; | 131 | struct proc_dir_entry *pde; |
132 | void __iomem *udp_baseaddr; | 132 | void __iomem *udp_baseaddr; |
diff --git a/drivers/usb/gadget/atmel_usba_udc.c b/drivers/usb/gadget/atmel_usba_udc.c index 1d9722203ca6..40d23384b716 100644 --- a/drivers/usb/gadget/atmel_usba_udc.c +++ b/drivers/usb/gadget/atmel_usba_udc.c | |||
@@ -1772,6 +1772,7 @@ out: | |||
1772 | static int atmel_usba_start(struct usb_gadget *gadget, | 1772 | static int atmel_usba_start(struct usb_gadget *gadget, |
1773 | struct usb_gadget_driver *driver) | 1773 | struct usb_gadget_driver *driver) |
1774 | { | 1774 | { |
1775 | int ret = 0; | ||
1775 | struct usba_udc *udc = container_of(gadget, struct usba_udc, gadget); | 1776 | struct usba_udc *udc = container_of(gadget, struct usba_udc, gadget); |
1776 | unsigned long flags; | 1777 | unsigned long flags; |
1777 | 1778 | ||
@@ -1781,8 +1782,14 @@ static int atmel_usba_start(struct usb_gadget *gadget, | |||
1781 | udc->driver = driver; | 1782 | udc->driver = driver; |
1782 | spin_unlock_irqrestore(&udc->lock, flags); | 1783 | spin_unlock_irqrestore(&udc->lock, flags); |
1783 | 1784 | ||
1784 | clk_enable(udc->pclk); | 1785 | ret = clk_prepare_enable(udc->pclk); |
1785 | clk_enable(udc->hclk); | 1786 | if (ret) |
1787 | goto out; | ||
1788 | ret = clk_prepare_enable(udc->hclk); | ||
1789 | if (ret) { | ||
1790 | clk_disable_unprepare(udc->pclk); | ||
1791 | goto out; | ||
1792 | } | ||
1786 | 1793 | ||
1787 | DBG(DBG_GADGET, "registered driver `%s'\n", driver->driver.name); | 1794 | DBG(DBG_GADGET, "registered driver `%s'\n", driver->driver.name); |
1788 | 1795 | ||
@@ -1797,9 +1804,11 @@ static int atmel_usba_start(struct usb_gadget *gadget, | |||
1797 | usba_writel(udc, CTRL, USBA_ENABLE_MASK); | 1804 | usba_writel(udc, CTRL, USBA_ENABLE_MASK); |
1798 | usba_writel(udc, INT_ENB, USBA_END_OF_RESET); | 1805 | usba_writel(udc, INT_ENB, USBA_END_OF_RESET); |
1799 | } | 1806 | } |
1807 | |||
1808 | out: | ||
1800 | spin_unlock_irqrestore(&udc->lock, flags); | 1809 | spin_unlock_irqrestore(&udc->lock, flags); |
1801 | 1810 | ||
1802 | return 0; | 1811 | return ret; |
1803 | } | 1812 | } |
1804 | 1813 | ||
1805 | static int atmel_usba_stop(struct usb_gadget *gadget, | 1814 | static int atmel_usba_stop(struct usb_gadget *gadget, |
@@ -1822,8 +1831,8 @@ static int atmel_usba_stop(struct usb_gadget *gadget, | |||
1822 | 1831 | ||
1823 | udc->driver = NULL; | 1832 | udc->driver = NULL; |
1824 | 1833 | ||
1825 | clk_disable(udc->hclk); | 1834 | clk_disable_unprepare(udc->hclk); |
1826 | clk_disable(udc->pclk); | 1835 | clk_disable_unprepare(udc->pclk); |
1827 | 1836 | ||
1828 | DBG(DBG_GADGET, "unregistered driver `%s'\n", driver->driver.name); | 1837 | DBG(DBG_GADGET, "unregistered driver `%s'\n", driver->driver.name); |
1829 | 1838 | ||
@@ -1922,7 +1931,7 @@ static struct usba_ep * atmel_udc_of_init(struct platform_device *pdev, | |||
1922 | static struct usba_ep * usba_udc_pdata(struct platform_device *pdev, | 1931 | static struct usba_ep * usba_udc_pdata(struct platform_device *pdev, |
1923 | struct usba_udc *udc) | 1932 | struct usba_udc *udc) |
1924 | { | 1933 | { |
1925 | struct usba_platform_data *pdata = pdev->dev.platform_data; | 1934 | struct usba_platform_data *pdata = dev_get_platdata(&pdev->dev); |
1926 | struct usba_ep *eps; | 1935 | struct usba_ep *eps; |
1927 | int i; | 1936 | int i; |
1928 | 1937 | ||
@@ -2022,10 +2031,14 @@ static int __init usba_udc_probe(struct platform_device *pdev) | |||
2022 | platform_set_drvdata(pdev, udc); | 2031 | platform_set_drvdata(pdev, udc); |
2023 | 2032 | ||
2024 | /* Make sure we start from a clean slate */ | 2033 | /* Make sure we start from a clean slate */ |
2025 | clk_enable(pclk); | 2034 | ret = clk_prepare_enable(pclk); |
2035 | if (ret) { | ||
2036 | dev_err(&pdev->dev, "Unable to enable pclk, aborting.\n"); | ||
2037 | goto err_clk_enable; | ||
2038 | } | ||
2026 | toggle_bias(0); | 2039 | toggle_bias(0); |
2027 | usba_writel(udc, CTRL, USBA_DISABLE_MASK); | 2040 | usba_writel(udc, CTRL, USBA_DISABLE_MASK); |
2028 | clk_disable(pclk); | 2041 | clk_disable_unprepare(pclk); |
2029 | 2042 | ||
2030 | if (pdev->dev.of_node) | 2043 | if (pdev->dev.of_node) |
2031 | udc->usba_ep = atmel_udc_of_init(pdev, udc); | 2044 | udc->usba_ep = atmel_udc_of_init(pdev, udc); |
@@ -2081,6 +2094,7 @@ err_add_udc: | |||
2081 | free_irq(irq, udc); | 2094 | free_irq(irq, udc); |
2082 | err_request_irq: | 2095 | err_request_irq: |
2083 | err_alloc_ep: | 2096 | err_alloc_ep: |
2097 | err_clk_enable: | ||
2084 | iounmap(udc->fifo); | 2098 | iounmap(udc->fifo); |
2085 | err_map_fifo: | 2099 | err_map_fifo: |
2086 | iounmap(udc->regs); | 2100 | iounmap(udc->regs); |
diff --git a/drivers/usb/gadget/bcm63xx_udc.c b/drivers/usb/gadget/bcm63xx_udc.c index fd24cb4540a4..c58fcf1ebe41 100644 --- a/drivers/usb/gadget/bcm63xx_udc.c +++ b/drivers/usb/gadget/bcm63xx_udc.c | |||
@@ -2313,7 +2313,7 @@ static void bcm63xx_udc_cleanup_debugfs(struct bcm63xx_udc *udc) | |||
2313 | static int bcm63xx_udc_probe(struct platform_device *pdev) | 2313 | static int bcm63xx_udc_probe(struct platform_device *pdev) |
2314 | { | 2314 | { |
2315 | struct device *dev = &pdev->dev; | 2315 | struct device *dev = &pdev->dev; |
2316 | struct bcm63xx_usbd_platform_data *pd = dev->platform_data; | 2316 | struct bcm63xx_usbd_platform_data *pd = dev_get_platdata(dev); |
2317 | struct bcm63xx_udc *udc; | 2317 | struct bcm63xx_udc *udc; |
2318 | struct resource *res; | 2318 | struct resource *res; |
2319 | int rc = -ENOMEM, i, irq; | 2319 | int rc = -ENOMEM, i, irq; |
diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c index 56f1fd1cba25..4d4e96a5d2e9 100644 --- a/drivers/usb/gadget/f_mass_storage.c +++ b/drivers/usb/gadget/f_mass_storage.c | |||
@@ -3043,12 +3043,12 @@ fsg_config_from_params(struct fsg_config *cfg, | |||
3043 | lun->filename = | 3043 | lun->filename = |
3044 | params->file_count > i && params->file[i][0] | 3044 | params->file_count > i && params->file[i][0] |
3045 | ? params->file[i] | 3045 | ? params->file[i] |
3046 | : 0; | 3046 | : NULL; |
3047 | } | 3047 | } |
3048 | 3048 | ||
3049 | /* Let MSF use defaults */ | 3049 | /* Let MSF use defaults */ |
3050 | cfg->vendor_name = 0; | 3050 | cfg->vendor_name = NULL; |
3051 | cfg->product_name = 0; | 3051 | cfg->product_name = NULL; |
3052 | 3052 | ||
3053 | cfg->ops = NULL; | 3053 | cfg->ops = NULL; |
3054 | cfg->private_data = NULL; | 3054 | cfg->private_data = NULL; |
diff --git a/drivers/usb/gadget/f_uac1.c b/drivers/usb/gadget/f_uac1.c index fa8ea4ea00c1..2b4c82d84bfc 100644 --- a/drivers/usb/gadget/f_uac1.c +++ b/drivers/usb/gadget/f_uac1.c | |||
@@ -695,7 +695,7 @@ static int generic_get_cmd(struct usb_audio_control *con, u8 cmd) | |||
695 | } | 695 | } |
696 | 696 | ||
697 | /* Todo: add more control selecotor dynamically */ | 697 | /* Todo: add more control selecotor dynamically */ |
698 | int __init control_selector_init(struct f_audio *audio) | 698 | static int __init control_selector_init(struct f_audio *audio) |
699 | { | 699 | { |
700 | INIT_LIST_HEAD(&audio->cs); | 700 | INIT_LIST_HEAD(&audio->cs); |
701 | list_add(&feature_unit.list, &audio->cs); | 701 | list_add(&feature_unit.list, &audio->cs); |
@@ -719,7 +719,7 @@ int __init control_selector_init(struct f_audio *audio) | |||
719 | * | 719 | * |
720 | * Returns zero on success, else negative errno. | 720 | * Returns zero on success, else negative errno. |
721 | */ | 721 | */ |
722 | int __init audio_bind_config(struct usb_configuration *c) | 722 | static int __init audio_bind_config(struct usb_configuration *c) |
723 | { | 723 | { |
724 | struct f_audio *audio; | 724 | struct f_audio *audio; |
725 | int status; | 725 | int status; |
diff --git a/drivers/usb/gadget/fsl_mxc_udc.c b/drivers/usb/gadget/fsl_mxc_udc.c index d3bd7b095ba3..9b140fc4d3bc 100644 --- a/drivers/usb/gadget/fsl_mxc_udc.c +++ b/drivers/usb/gadget/fsl_mxc_udc.c | |||
@@ -33,7 +33,7 @@ int fsl_udc_clk_init(struct platform_device *pdev) | |||
33 | unsigned long freq; | 33 | unsigned long freq; |
34 | int ret; | 34 | int ret; |
35 | 35 | ||
36 | pdata = pdev->dev.platform_data; | 36 | pdata = dev_get_platdata(&pdev->dev); |
37 | 37 | ||
38 | mxc_ipg_clk = devm_clk_get(&pdev->dev, "ipg"); | 38 | mxc_ipg_clk = devm_clk_get(&pdev->dev, "ipg"); |
39 | if (IS_ERR(mxc_ipg_clk)) { | 39 | if (IS_ERR(mxc_ipg_clk)) { |
@@ -80,7 +80,7 @@ eclkrate: | |||
80 | 80 | ||
81 | int fsl_udc_clk_finalize(struct platform_device *pdev) | 81 | int fsl_udc_clk_finalize(struct platform_device *pdev) |
82 | { | 82 | { |
83 | struct fsl_usb2_platform_data *pdata = pdev->dev.platform_data; | 83 | struct fsl_usb2_platform_data *pdata = dev_get_platdata(&pdev->dev); |
84 | int ret = 0; | 84 | int ret = 0; |
85 | 85 | ||
86 | /* workaround ENGcm09152 for i.MX35 */ | 86 | /* workaround ENGcm09152 for i.MX35 */ |
diff --git a/drivers/usb/gadget/fsl_udc_core.c b/drivers/usb/gadget/fsl_udc_core.c index a766a4ca1cb7..36ac7cfba91d 100644 --- a/drivers/usb/gadget/fsl_udc_core.c +++ b/drivers/usb/gadget/fsl_udc_core.c | |||
@@ -2248,7 +2248,7 @@ static int __init struct_udc_setup(struct fsl_udc *udc, | |||
2248 | struct fsl_usb2_platform_data *pdata; | 2248 | struct fsl_usb2_platform_data *pdata; |
2249 | size_t size; | 2249 | size_t size; |
2250 | 2250 | ||
2251 | pdata = pdev->dev.platform_data; | 2251 | pdata = dev_get_platdata(&pdev->dev); |
2252 | udc->phy_mode = pdata->phy_mode; | 2252 | udc->phy_mode = pdata->phy_mode; |
2253 | 2253 | ||
2254 | udc->eps = kzalloc(sizeof(struct fsl_ep) * udc->max_ep, GFP_KERNEL); | 2254 | udc->eps = kzalloc(sizeof(struct fsl_ep) * udc->max_ep, GFP_KERNEL); |
@@ -2343,7 +2343,7 @@ static int __init fsl_udc_probe(struct platform_device *pdev) | |||
2343 | return -ENOMEM; | 2343 | return -ENOMEM; |
2344 | } | 2344 | } |
2345 | 2345 | ||
2346 | pdata = pdev->dev.platform_data; | 2346 | pdata = dev_get_platdata(&pdev->dev); |
2347 | udc_controller->pdata = pdata; | 2347 | udc_controller->pdata = pdata; |
2348 | spin_lock_init(&udc_controller->lock); | 2348 | spin_lock_init(&udc_controller->lock); |
2349 | udc_controller->stopped = 1; | 2349 | udc_controller->stopped = 1; |
@@ -2524,7 +2524,7 @@ err_kfree: | |||
2524 | static int __exit fsl_udc_remove(struct platform_device *pdev) | 2524 | static int __exit fsl_udc_remove(struct platform_device *pdev) |
2525 | { | 2525 | { |
2526 | struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 2526 | struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
2527 | struct fsl_usb2_platform_data *pdata = pdev->dev.platform_data; | 2527 | struct fsl_usb2_platform_data *pdata = dev_get_platdata(&pdev->dev); |
2528 | 2528 | ||
2529 | DECLARE_COMPLETION(done); | 2529 | DECLARE_COMPLETION(done); |
2530 | 2530 | ||
diff --git a/drivers/usb/gadget/fusb300_udc.c b/drivers/usb/gadget/fusb300_udc.c index c83f3e165325..f1dd6daabe21 100644 --- a/drivers/usb/gadget/fusb300_udc.c +++ b/drivers/usb/gadget/fusb300_udc.c | |||
@@ -557,7 +557,7 @@ static void fusb300_set_cxdone(struct fusb300 *fusb300) | |||
557 | } | 557 | } |
558 | 558 | ||
559 | /* read data from cx fifo */ | 559 | /* read data from cx fifo */ |
560 | void fusb300_rdcxf(struct fusb300 *fusb300, | 560 | static void fusb300_rdcxf(struct fusb300 *fusb300, |
561 | u8 *buffer, u32 length) | 561 | u8 *buffer, u32 length) |
562 | { | 562 | { |
563 | int i = 0; | 563 | int i = 0; |
diff --git a/drivers/usb/gadget/goku_udc.c b/drivers/usb/gadget/goku_udc.c index 52dd6cc6c0aa..c64deb9e3d62 100644 --- a/drivers/usb/gadget/goku_udc.c +++ b/drivers/usb/gadget/goku_udc.c | |||
@@ -772,7 +772,7 @@ goku_queue(struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags) | |||
772 | 772 | ||
773 | } /* else pio or dma irq handler advances the queue. */ | 773 | } /* else pio or dma irq handler advances the queue. */ |
774 | 774 | ||
775 | if (likely(req != 0)) | 775 | if (likely(req != NULL)) |
776 | list_add_tail(&req->queue, &ep->queue); | 776 | list_add_tail(&req->queue, &ep->queue); |
777 | 777 | ||
778 | if (likely(!list_empty(&ep->queue)) | 778 | if (likely(!list_empty(&ep->queue)) |
diff --git a/drivers/usb/gadget/hid.c b/drivers/usb/gadget/hid.c index c36260ea8bf2..778613eb37af 100644 --- a/drivers/usb/gadget/hid.c +++ b/drivers/usb/gadget/hid.c | |||
@@ -185,7 +185,7 @@ static int __exit hid_unbind(struct usb_composite_dev *cdev) | |||
185 | 185 | ||
186 | static int __init hidg_plat_driver_probe(struct platform_device *pdev) | 186 | static int __init hidg_plat_driver_probe(struct platform_device *pdev) |
187 | { | 187 | { |
188 | struct hidg_func_descriptor *func = pdev->dev.platform_data; | 188 | struct hidg_func_descriptor *func = dev_get_platdata(&pdev->dev); |
189 | struct hidg_func_node *entry; | 189 | struct hidg_func_node *entry; |
190 | 190 | ||
191 | if (!func) { | 191 | if (!func) { |
diff --git a/drivers/usb/gadget/imx_udc.c b/drivers/usb/gadget/imx_udc.c deleted file mode 100644 index 9b2d24e4c95f..000000000000 --- a/drivers/usb/gadget/imx_udc.c +++ /dev/null | |||
@@ -1,1544 +0,0 @@ | |||
1 | /* | ||
2 | * driver/usb/gadget/imx_udc.c | ||
3 | * | ||
4 | * Copyright (C) 2005 Mike Lee <eemike@gmail.com> | ||
5 | * Copyright (C) 2008 Darius Augulis <augulis.darius@gmail.com> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License as published by | ||
9 | * the Free Software Foundation; either version 2 of the License, or | ||
10 | * (at your option) any later version. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | * GNU General Public License for more details. | ||
16 | */ | ||
17 | |||
18 | #include <linux/init.h> | ||
19 | #include <linux/kernel.h> | ||
20 | #include <linux/platform_device.h> | ||
21 | #include <linux/module.h> | ||
22 | #include <linux/errno.h> | ||
23 | #include <linux/list.h> | ||
24 | #include <linux/interrupt.h> | ||
25 | #include <linux/io.h> | ||
26 | #include <linux/irq.h> | ||
27 | #include <linux/device.h> | ||
28 | #include <linux/dma-mapping.h> | ||
29 | #include <linux/clk.h> | ||
30 | #include <linux/delay.h> | ||
31 | #include <linux/timer.h> | ||
32 | #include <linux/slab.h> | ||
33 | #include <linux/prefetch.h> | ||
34 | |||
35 | #include <linux/usb/ch9.h> | ||
36 | #include <linux/usb/gadget.h> | ||
37 | |||
38 | #include <linux/platform_data/usb-imx_udc.h> | ||
39 | #include <mach/hardware.h> | ||
40 | |||
41 | #include "imx_udc.h" | ||
42 | |||
43 | static const char driver_name[] = "imx_udc"; | ||
44 | static const char ep0name[] = "ep0"; | ||
45 | |||
46 | void ep0_chg_stat(const char *label, struct imx_udc_struct *imx_usb, | ||
47 | enum ep0_state stat); | ||
48 | |||
49 | /******************************************************************************* | ||
50 | * IMX UDC hardware related functions | ||
51 | ******************************************************************************* | ||
52 | */ | ||
53 | |||
54 | void imx_udc_enable(struct imx_udc_struct *imx_usb) | ||
55 | { | ||
56 | int temp = __raw_readl(imx_usb->base + USB_CTRL); | ||
57 | __raw_writel(temp | CTRL_FE_ENA | CTRL_AFE_ENA, | ||
58 | imx_usb->base + USB_CTRL); | ||
59 | imx_usb->gadget.speed = USB_SPEED_FULL; | ||
60 | } | ||
61 | |||
62 | void imx_udc_disable(struct imx_udc_struct *imx_usb) | ||
63 | { | ||
64 | int temp = __raw_readl(imx_usb->base + USB_CTRL); | ||
65 | |||
66 | __raw_writel(temp & ~(CTRL_FE_ENA | CTRL_AFE_ENA), | ||
67 | imx_usb->base + USB_CTRL); | ||
68 | |||
69 | ep0_chg_stat(__func__, imx_usb, EP0_IDLE); | ||
70 | imx_usb->gadget.speed = USB_SPEED_UNKNOWN; | ||
71 | } | ||
72 | |||
73 | void imx_udc_reset(struct imx_udc_struct *imx_usb) | ||
74 | { | ||
75 | int temp = __raw_readl(imx_usb->base + USB_ENAB); | ||
76 | |||
77 | /* set RST bit */ | ||
78 | __raw_writel(temp | ENAB_RST, imx_usb->base + USB_ENAB); | ||
79 | |||
80 | /* wait RST bit to clear */ | ||
81 | do {} while (__raw_readl(imx_usb->base + USB_ENAB) & ENAB_RST); | ||
82 | |||
83 | /* wait CFG bit to assert */ | ||
84 | do {} while (!(__raw_readl(imx_usb->base + USB_DADR) & DADR_CFG)); | ||
85 | |||
86 | /* udc module is now ready */ | ||
87 | } | ||
88 | |||
89 | void imx_udc_config(struct imx_udc_struct *imx_usb) | ||
90 | { | ||
91 | u8 ep_conf[5]; | ||
92 | u8 i, j, cfg; | ||
93 | struct imx_ep_struct *imx_ep; | ||
94 | |||
95 | /* wait CFG bit to assert */ | ||
96 | do {} while (!(__raw_readl(imx_usb->base + USB_DADR) & DADR_CFG)); | ||
97 | |||
98 | /* Download the endpoint buffer for endpoint 0. */ | ||
99 | for (j = 0; j < 5; j++) { | ||
100 | i = (j == 2 ? imx_usb->imx_ep[0].fifosize : 0x00); | ||
101 | __raw_writeb(i, imx_usb->base + USB_DDAT); | ||
102 | do {} while (__raw_readl(imx_usb->base + USB_DADR) & DADR_BSY); | ||
103 | } | ||
104 | |||
105 | /* Download the endpoint buffers for endpoints 1-5. | ||
106 | * We specify two configurations, one interface | ||
107 | */ | ||
108 | for (cfg = 1; cfg < 3; cfg++) { | ||
109 | for (i = 1; i < IMX_USB_NB_EP; i++) { | ||
110 | imx_ep = &imx_usb->imx_ep[i]; | ||
111 | /* EP no | Config no */ | ||
112 | ep_conf[0] = (i << 4) | (cfg << 2); | ||
113 | /* Type | Direction */ | ||
114 | ep_conf[1] = (imx_ep->bmAttributes << 3) | | ||
115 | (EP_DIR(imx_ep) << 2); | ||
116 | /* Max packet size */ | ||
117 | ep_conf[2] = imx_ep->fifosize; | ||
118 | /* TRXTYP */ | ||
119 | ep_conf[3] = 0xC0; | ||
120 | /* FIFO no */ | ||
121 | ep_conf[4] = i; | ||
122 | |||
123 | D_INI(imx_usb->dev, | ||
124 | "<%s> ep%d_conf[%d]:" | ||
125 | "[%02x-%02x-%02x-%02x-%02x]\n", | ||
126 | __func__, i, cfg, | ||
127 | ep_conf[0], ep_conf[1], ep_conf[2], | ||
128 | ep_conf[3], ep_conf[4]); | ||
129 | |||
130 | for (j = 0; j < 5; j++) { | ||
131 | __raw_writeb(ep_conf[j], | ||
132 | imx_usb->base + USB_DDAT); | ||
133 | do {} while (__raw_readl(imx_usb->base | ||
134 | + USB_DADR) | ||
135 | & DADR_BSY); | ||
136 | } | ||
137 | } | ||
138 | } | ||
139 | |||
140 | /* wait CFG bit to clear */ | ||
141 | do {} while (__raw_readl(imx_usb->base + USB_DADR) & DADR_CFG); | ||
142 | } | ||
143 | |||
144 | void imx_udc_init_irq(struct imx_udc_struct *imx_usb) | ||
145 | { | ||
146 | int i; | ||
147 | |||
148 | /* Mask and clear all irqs */ | ||
149 | __raw_writel(0xFFFFFFFF, imx_usb->base + USB_MASK); | ||
150 | __raw_writel(0xFFFFFFFF, imx_usb->base + USB_INTR); | ||
151 | for (i = 0; i < IMX_USB_NB_EP; i++) { | ||
152 | __raw_writel(0x1FF, imx_usb->base + USB_EP_MASK(i)); | ||
153 | __raw_writel(0x1FF, imx_usb->base + USB_EP_INTR(i)); | ||
154 | } | ||
155 | |||
156 | /* Enable USB irqs */ | ||
157 | __raw_writel(INTR_MSOF | INTR_FRAME_MATCH, imx_usb->base + USB_MASK); | ||
158 | |||
159 | /* Enable EP0 irqs */ | ||
160 | __raw_writel(0x1FF & ~(EPINTR_DEVREQ | EPINTR_MDEVREQ | EPINTR_EOT | ||
161 | | EPINTR_EOF | EPINTR_FIFO_EMPTY | EPINTR_FIFO_FULL), | ||
162 | imx_usb->base + USB_EP_MASK(0)); | ||
163 | } | ||
164 | |||
165 | void imx_udc_init_ep(struct imx_udc_struct *imx_usb) | ||
166 | { | ||
167 | int i, max, temp; | ||
168 | struct imx_ep_struct *imx_ep; | ||
169 | for (i = 0; i < IMX_USB_NB_EP; i++) { | ||
170 | imx_ep = &imx_usb->imx_ep[i]; | ||
171 | switch (imx_ep->fifosize) { | ||
172 | case 8: | ||
173 | max = 0; | ||
174 | break; | ||
175 | case 16: | ||
176 | max = 1; | ||
177 | break; | ||
178 | case 32: | ||
179 | max = 2; | ||
180 | break; | ||
181 | case 64: | ||
182 | max = 3; | ||
183 | break; | ||
184 | default: | ||
185 | max = 1; | ||
186 | break; | ||
187 | } | ||
188 | temp = (EP_DIR(imx_ep) << 7) | (max << 5) | ||
189 | | (imx_ep->bmAttributes << 3); | ||
190 | __raw_writel(temp, imx_usb->base + USB_EP_STAT(i)); | ||
191 | __raw_writel(temp | EPSTAT_FLUSH, | ||
192 | imx_usb->base + USB_EP_STAT(i)); | ||
193 | D_INI(imx_usb->dev, "<%s> ep%d_stat %08x\n", __func__, i, | ||
194 | __raw_readl(imx_usb->base + USB_EP_STAT(i))); | ||
195 | } | ||
196 | } | ||
197 | |||
198 | void imx_udc_init_fifo(struct imx_udc_struct *imx_usb) | ||
199 | { | ||
200 | int i, temp; | ||
201 | struct imx_ep_struct *imx_ep; | ||
202 | for (i = 0; i < IMX_USB_NB_EP; i++) { | ||
203 | imx_ep = &imx_usb->imx_ep[i]; | ||
204 | |||
205 | /* Fifo control */ | ||
206 | temp = EP_DIR(imx_ep) ? 0x0B000000 : 0x0F000000; | ||
207 | __raw_writel(temp, imx_usb->base + USB_EP_FCTRL(i)); | ||
208 | D_INI(imx_usb->dev, "<%s> ep%d_fctrl %08x\n", __func__, i, | ||
209 | __raw_readl(imx_usb->base + USB_EP_FCTRL(i))); | ||
210 | |||
211 | /* Fifo alarm */ | ||
212 | temp = (i ? imx_ep->fifosize / 2 : 0); | ||
213 | __raw_writel(temp, imx_usb->base + USB_EP_FALRM(i)); | ||
214 | D_INI(imx_usb->dev, "<%s> ep%d_falrm %08x\n", __func__, i, | ||
215 | __raw_readl(imx_usb->base + USB_EP_FALRM(i))); | ||
216 | } | ||
217 | } | ||
218 | |||
219 | static void imx_udc_init(struct imx_udc_struct *imx_usb) | ||
220 | { | ||
221 | /* Reset UDC */ | ||
222 | imx_udc_reset(imx_usb); | ||
223 | |||
224 | /* Download config to enpoint buffer */ | ||
225 | imx_udc_config(imx_usb); | ||
226 | |||
227 | /* Setup interrups */ | ||
228 | imx_udc_init_irq(imx_usb); | ||
229 | |||
230 | /* Setup endpoints */ | ||
231 | imx_udc_init_ep(imx_usb); | ||
232 | |||
233 | /* Setup fifos */ | ||
234 | imx_udc_init_fifo(imx_usb); | ||
235 | } | ||
236 | |||
237 | void imx_ep_irq_enable(struct imx_ep_struct *imx_ep) | ||
238 | { | ||
239 | |||
240 | int i = EP_NO(imx_ep); | ||
241 | |||
242 | __raw_writel(0x1FF, imx_ep->imx_usb->base + USB_EP_MASK(i)); | ||
243 | __raw_writel(0x1FF, imx_ep->imx_usb->base + USB_EP_INTR(i)); | ||
244 | __raw_writel(0x1FF & ~(EPINTR_EOT | EPINTR_EOF), | ||
245 | imx_ep->imx_usb->base + USB_EP_MASK(i)); | ||
246 | } | ||
247 | |||
248 | void imx_ep_irq_disable(struct imx_ep_struct *imx_ep) | ||
249 | { | ||
250 | |||
251 | int i = EP_NO(imx_ep); | ||
252 | |||
253 | __raw_writel(0x1FF, imx_ep->imx_usb->base + USB_EP_MASK(i)); | ||
254 | __raw_writel(0x1FF, imx_ep->imx_usb->base + USB_EP_INTR(i)); | ||
255 | } | ||
256 | |||
257 | int imx_ep_empty(struct imx_ep_struct *imx_ep) | ||
258 | { | ||
259 | struct imx_udc_struct *imx_usb = imx_ep->imx_usb; | ||
260 | |||
261 | return __raw_readl(imx_usb->base + USB_EP_FSTAT(EP_NO(imx_ep))) | ||
262 | & FSTAT_EMPTY; | ||
263 | } | ||
264 | |||
265 | unsigned imx_fifo_bcount(struct imx_ep_struct *imx_ep) | ||
266 | { | ||
267 | struct imx_udc_struct *imx_usb = imx_ep->imx_usb; | ||
268 | |||
269 | return (__raw_readl(imx_usb->base + USB_EP_STAT(EP_NO(imx_ep))) | ||
270 | & EPSTAT_BCOUNT) >> 16; | ||
271 | } | ||
272 | |||
273 | void imx_flush(struct imx_ep_struct *imx_ep) | ||
274 | { | ||
275 | struct imx_udc_struct *imx_usb = imx_ep->imx_usb; | ||
276 | |||
277 | int temp = __raw_readl(imx_usb->base + USB_EP_STAT(EP_NO(imx_ep))); | ||
278 | __raw_writel(temp | EPSTAT_FLUSH, | ||
279 | imx_usb->base + USB_EP_STAT(EP_NO(imx_ep))); | ||
280 | } | ||
281 | |||
282 | void imx_ep_stall(struct imx_ep_struct *imx_ep) | ||
283 | { | ||
284 | struct imx_udc_struct *imx_usb = imx_ep->imx_usb; | ||
285 | int temp, i; | ||
286 | |||
287 | D_ERR(imx_usb->dev, | ||
288 | "<%s> Forced stall on %s\n", __func__, imx_ep->ep.name); | ||
289 | |||
290 | imx_flush(imx_ep); | ||
291 | |||
292 | /* Special care for ep0 */ | ||
293 | if (!EP_NO(imx_ep)) { | ||
294 | temp = __raw_readl(imx_usb->base + USB_CTRL); | ||
295 | __raw_writel(temp | CTRL_CMDOVER | CTRL_CMDERROR, | ||
296 | imx_usb->base + USB_CTRL); | ||
297 | do { } while (__raw_readl(imx_usb->base + USB_CTRL) | ||
298 | & CTRL_CMDOVER); | ||
299 | temp = __raw_readl(imx_usb->base + USB_CTRL); | ||
300 | __raw_writel(temp & ~CTRL_CMDERROR, imx_usb->base + USB_CTRL); | ||
301 | } | ||
302 | else { | ||
303 | temp = __raw_readl(imx_usb->base + USB_EP_STAT(EP_NO(imx_ep))); | ||
304 | __raw_writel(temp | EPSTAT_STALL, | ||
305 | imx_usb->base + USB_EP_STAT(EP_NO(imx_ep))); | ||
306 | |||
307 | for (i = 0; i < 100; i ++) { | ||
308 | temp = __raw_readl(imx_usb->base | ||
309 | + USB_EP_STAT(EP_NO(imx_ep))); | ||
310 | if (!(temp & EPSTAT_STALL)) | ||
311 | break; | ||
312 | udelay(20); | ||
313 | } | ||
314 | if (i == 100) | ||
315 | D_ERR(imx_usb->dev, "<%s> Non finished stall on %s\n", | ||
316 | __func__, imx_ep->ep.name); | ||
317 | } | ||
318 | } | ||
319 | |||
320 | static int imx_udc_get_frame(struct usb_gadget *_gadget) | ||
321 | { | ||
322 | struct imx_udc_struct *imx_usb = container_of(_gadget, | ||
323 | struct imx_udc_struct, gadget); | ||
324 | |||
325 | return __raw_readl(imx_usb->base + USB_FRAME) & 0x7FF; | ||
326 | } | ||
327 | |||
328 | static int imx_udc_wakeup(struct usb_gadget *_gadget) | ||
329 | { | ||
330 | return 0; | ||
331 | } | ||
332 | |||
333 | /******************************************************************************* | ||
334 | * USB request control functions | ||
335 | ******************************************************************************* | ||
336 | */ | ||
337 | |||
338 | static void ep_add_request(struct imx_ep_struct *imx_ep, | ||
339 | struct imx_request *req) | ||
340 | { | ||
341 | if (unlikely(!req)) | ||
342 | return; | ||
343 | |||
344 | req->in_use = 1; | ||
345 | list_add_tail(&req->queue, &imx_ep->queue); | ||
346 | } | ||
347 | |||
348 | static void ep_del_request(struct imx_ep_struct *imx_ep, | ||
349 | struct imx_request *req) | ||
350 | { | ||
351 | if (unlikely(!req)) | ||
352 | return; | ||
353 | |||
354 | list_del_init(&req->queue); | ||
355 | req->in_use = 0; | ||
356 | } | ||
357 | |||
358 | static void done(struct imx_ep_struct *imx_ep, | ||
359 | struct imx_request *req, int status) | ||
360 | { | ||
361 | ep_del_request(imx_ep, req); | ||
362 | |||
363 | if (likely(req->req.status == -EINPROGRESS)) | ||
364 | req->req.status = status; | ||
365 | else | ||
366 | status = req->req.status; | ||
367 | |||
368 | if (status && status != -ESHUTDOWN) | ||
369 | D_ERR(imx_ep->imx_usb->dev, | ||
370 | "<%s> complete %s req %p stat %d len %u/%u\n", __func__, | ||
371 | imx_ep->ep.name, &req->req, status, | ||
372 | req->req.actual, req->req.length); | ||
373 | |||
374 | req->req.complete(&imx_ep->ep, &req->req); | ||
375 | } | ||
376 | |||
377 | static void nuke(struct imx_ep_struct *imx_ep, int status) | ||
378 | { | ||
379 | struct imx_request *req; | ||
380 | |||
381 | while (!list_empty(&imx_ep->queue)) { | ||
382 | req = list_entry(imx_ep->queue.next, struct imx_request, queue); | ||
383 | done(imx_ep, req, status); | ||
384 | } | ||
385 | } | ||
386 | |||
387 | /******************************************************************************* | ||
388 | * Data tansfer over USB functions | ||
389 | ******************************************************************************* | ||
390 | */ | ||
391 | static int read_packet(struct imx_ep_struct *imx_ep, struct imx_request *req) | ||
392 | { | ||
393 | u8 *buf; | ||
394 | int bytes_ep, bufferspace, count, i; | ||
395 | |||
396 | bytes_ep = imx_fifo_bcount(imx_ep); | ||
397 | bufferspace = req->req.length - req->req.actual; | ||
398 | |||
399 | buf = req->req.buf + req->req.actual; | ||
400 | prefetchw(buf); | ||
401 | |||
402 | if (unlikely(imx_ep_empty(imx_ep))) | ||
403 | count = 0; /* zlp */ | ||
404 | else | ||
405 | count = min(bytes_ep, bufferspace); | ||
406 | |||
407 | for (i = count; i > 0; i--) | ||
408 | *buf++ = __raw_readb(imx_ep->imx_usb->base | ||
409 | + USB_EP_FDAT0(EP_NO(imx_ep))); | ||
410 | req->req.actual += count; | ||
411 | |||
412 | return count; | ||
413 | } | ||
414 | |||
415 | static int write_packet(struct imx_ep_struct *imx_ep, struct imx_request *req) | ||
416 | { | ||
417 | u8 *buf; | ||
418 | int length, count, temp; | ||
419 | |||
420 | if (unlikely(__raw_readl(imx_ep->imx_usb->base + | ||
421 | USB_EP_STAT(EP_NO(imx_ep))) & EPSTAT_ZLPS)) { | ||
422 | D_TRX(imx_ep->imx_usb->dev, "<%s> zlp still queued in EP %s\n", | ||
423 | __func__, imx_ep->ep.name); | ||
424 | return -1; | ||
425 | } | ||
426 | |||
427 | buf = req->req.buf + req->req.actual; | ||
428 | prefetch(buf); | ||
429 | |||
430 | length = min(req->req.length - req->req.actual, (u32)imx_ep->fifosize); | ||
431 | |||
432 | if (imx_fifo_bcount(imx_ep) + length > imx_ep->fifosize) { | ||
433 | D_TRX(imx_ep->imx_usb->dev, "<%s> packet overfill %s fifo\n", | ||
434 | __func__, imx_ep->ep.name); | ||
435 | return -1; | ||
436 | } | ||
437 | |||
438 | req->req.actual += length; | ||
439 | count = length; | ||
440 | |||
441 | if (!count && req->req.zero) { /* zlp */ | ||
442 | temp = __raw_readl(imx_ep->imx_usb->base | ||
443 | + USB_EP_STAT(EP_NO(imx_ep))); | ||
444 | __raw_writel(temp | EPSTAT_ZLPS, imx_ep->imx_usb->base | ||
445 | + USB_EP_STAT(EP_NO(imx_ep))); | ||
446 | D_TRX(imx_ep->imx_usb->dev, "<%s> zero packet\n", __func__); | ||
447 | return 0; | ||
448 | } | ||
449 | |||
450 | while (count--) { | ||
451 | if (count == 0) { /* last byte */ | ||
452 | temp = __raw_readl(imx_ep->imx_usb->base | ||
453 | + USB_EP_FCTRL(EP_NO(imx_ep))); | ||
454 | __raw_writel(temp | FCTRL_WFR, imx_ep->imx_usb->base | ||
455 | + USB_EP_FCTRL(EP_NO(imx_ep))); | ||
456 | } | ||
457 | __raw_writeb(*buf++, | ||
458 | imx_ep->imx_usb->base + USB_EP_FDAT0(EP_NO(imx_ep))); | ||
459 | } | ||
460 | |||
461 | return length; | ||
462 | } | ||
463 | |||
464 | static int read_fifo(struct imx_ep_struct *imx_ep, struct imx_request *req) | ||
465 | { | ||
466 | int bytes = 0, | ||
467 | count, | ||
468 | completed = 0; | ||
469 | |||
470 | while (__raw_readl(imx_ep->imx_usb->base + USB_EP_FSTAT(EP_NO(imx_ep))) | ||
471 | & FSTAT_FR) { | ||
472 | count = read_packet(imx_ep, req); | ||
473 | bytes += count; | ||
474 | |||
475 | completed = (count != imx_ep->fifosize); | ||
476 | if (completed || req->req.actual == req->req.length) { | ||
477 | completed = 1; | ||
478 | break; | ||
479 | } | ||
480 | } | ||
481 | |||
482 | if (completed || !req->req.length) { | ||
483 | done(imx_ep, req, 0); | ||
484 | D_REQ(imx_ep->imx_usb->dev, "<%s> %s req<%p> %s\n", | ||
485 | __func__, imx_ep->ep.name, req, | ||
486 | completed ? "completed" : "not completed"); | ||
487 | if (!EP_NO(imx_ep)) | ||
488 | ep0_chg_stat(__func__, imx_ep->imx_usb, EP0_IDLE); | ||
489 | } | ||
490 | |||
491 | D_TRX(imx_ep->imx_usb->dev, "<%s> bytes read: %d\n", __func__, bytes); | ||
492 | |||
493 | return completed; | ||
494 | } | ||
495 | |||
496 | static int write_fifo(struct imx_ep_struct *imx_ep, struct imx_request *req) | ||
497 | { | ||
498 | int bytes = 0, | ||
499 | count, | ||
500 | completed = 0; | ||
501 | |||
502 | while (!completed) { | ||
503 | count = write_packet(imx_ep, req); | ||
504 | if (count < 0) | ||
505 | break; /* busy */ | ||
506 | bytes += count; | ||
507 | |||
508 | /* last packet "must be" short (or a zlp) */ | ||
509 | completed = (count != imx_ep->fifosize); | ||
510 | |||
511 | if (unlikely(completed)) { | ||
512 | done(imx_ep, req, 0); | ||
513 | D_REQ(imx_ep->imx_usb->dev, "<%s> %s req<%p> %s\n", | ||
514 | __func__, imx_ep->ep.name, req, | ||
515 | completed ? "completed" : "not completed"); | ||
516 | if (!EP_NO(imx_ep)) | ||
517 | ep0_chg_stat(__func__, | ||
518 | imx_ep->imx_usb, EP0_IDLE); | ||
519 | } | ||
520 | } | ||
521 | |||
522 | D_TRX(imx_ep->imx_usb->dev, "<%s> bytes sent: %d\n", __func__, bytes); | ||
523 | |||
524 | return completed; | ||
525 | } | ||
526 | |||
527 | /******************************************************************************* | ||
528 | * Endpoint handlers | ||
529 | ******************************************************************************* | ||
530 | */ | ||
531 | static int handle_ep(struct imx_ep_struct *imx_ep) | ||
532 | { | ||
533 | struct imx_request *req; | ||
534 | int completed = 0; | ||
535 | |||
536 | do { | ||
537 | if (!list_empty(&imx_ep->queue)) | ||
538 | req = list_entry(imx_ep->queue.next, | ||
539 | struct imx_request, queue); | ||
540 | else { | ||
541 | D_REQ(imx_ep->imx_usb->dev, "<%s> no request on %s\n", | ||
542 | __func__, imx_ep->ep.name); | ||
543 | return 0; | ||
544 | } | ||
545 | |||
546 | if (EP_DIR(imx_ep)) /* to host */ | ||
547 | completed = write_fifo(imx_ep, req); | ||
548 | else /* to device */ | ||
549 | completed = read_fifo(imx_ep, req); | ||
550 | |||
551 | dump_ep_stat(__func__, imx_ep); | ||
552 | |||
553 | } while (completed); | ||
554 | |||
555 | return 0; | ||
556 | } | ||
557 | |||
558 | static int handle_ep0(struct imx_ep_struct *imx_ep) | ||
559 | { | ||
560 | struct imx_request *req = NULL; | ||
561 | int ret = 0; | ||
562 | |||
563 | if (!list_empty(&imx_ep->queue)) { | ||
564 | req = list_entry(imx_ep->queue.next, struct imx_request, queue); | ||
565 | |||
566 | switch (imx_ep->imx_usb->ep0state) { | ||
567 | |||
568 | case EP0_IN_DATA_PHASE: /* GET_DESCRIPTOR */ | ||
569 | write_fifo(imx_ep, req); | ||
570 | break; | ||
571 | case EP0_OUT_DATA_PHASE: /* SET_DESCRIPTOR */ | ||
572 | read_fifo(imx_ep, req); | ||
573 | break; | ||
574 | default: | ||
575 | D_EP0(imx_ep->imx_usb->dev, | ||
576 | "<%s> ep0 i/o, odd state %d\n", | ||
577 | __func__, imx_ep->imx_usb->ep0state); | ||
578 | ep_del_request(imx_ep, req); | ||
579 | ret = -EL2HLT; | ||
580 | break; | ||
581 | } | ||
582 | } | ||
583 | |||
584 | else | ||
585 | D_ERR(imx_ep->imx_usb->dev, "<%s> no request on %s\n", | ||
586 | __func__, imx_ep->ep.name); | ||
587 | |||
588 | return ret; | ||
589 | } | ||
590 | |||
591 | static void handle_ep0_devreq(struct imx_udc_struct *imx_usb) | ||
592 | { | ||
593 | struct imx_ep_struct *imx_ep = &imx_usb->imx_ep[0]; | ||
594 | union { | ||
595 | struct usb_ctrlrequest r; | ||
596 | u8 raw[8]; | ||
597 | u32 word[2]; | ||
598 | } u; | ||
599 | int temp, i; | ||
600 | |||
601 | nuke(imx_ep, -EPROTO); | ||
602 | |||
603 | /* read SETUP packet */ | ||
604 | for (i = 0; i < 2; i++) { | ||
605 | if (imx_ep_empty(imx_ep)) { | ||
606 | D_ERR(imx_usb->dev, | ||
607 | "<%s> no setup packet received\n", __func__); | ||
608 | goto stall; | ||
609 | } | ||
610 | u.word[i] = __raw_readl(imx_usb->base | ||
611 | + USB_EP_FDAT(EP_NO(imx_ep))); | ||
612 | } | ||
613 | |||
614 | temp = imx_ep_empty(imx_ep); | ||
615 | while (!imx_ep_empty(imx_ep)) { | ||
616 | i = __raw_readl(imx_usb->base + USB_EP_FDAT(EP_NO(imx_ep))); | ||
617 | D_ERR(imx_usb->dev, | ||
618 | "<%s> wrong to have extra bytes for setup : 0x%08x\n", | ||
619 | __func__, i); | ||
620 | } | ||
621 | if (!temp) | ||
622 | goto stall; | ||
623 | |||
624 | le16_to_cpus(&u.r.wValue); | ||
625 | le16_to_cpus(&u.r.wIndex); | ||
626 | le16_to_cpus(&u.r.wLength); | ||
627 | |||
628 | D_REQ(imx_usb->dev, "<%s> SETUP %02x.%02x v%04x i%04x l%04x\n", | ||
629 | __func__, u.r.bRequestType, u.r.bRequest, | ||
630 | u.r.wValue, u.r.wIndex, u.r.wLength); | ||
631 | |||
632 | if (imx_usb->set_config) { | ||
633 | /* NACK the host by using CMDOVER */ | ||
634 | temp = __raw_readl(imx_usb->base + USB_CTRL); | ||
635 | __raw_writel(temp | CTRL_CMDOVER, imx_usb->base + USB_CTRL); | ||
636 | |||
637 | D_ERR(imx_usb->dev, | ||
638 | "<%s> set config req is pending, NACK the host\n", | ||
639 | __func__); | ||
640 | return; | ||
641 | } | ||
642 | |||
643 | if (u.r.bRequestType & USB_DIR_IN) | ||
644 | ep0_chg_stat(__func__, imx_usb, EP0_IN_DATA_PHASE); | ||
645 | else | ||
646 | ep0_chg_stat(__func__, imx_usb, EP0_OUT_DATA_PHASE); | ||
647 | |||
648 | i = imx_usb->driver->setup(&imx_usb->gadget, &u.r); | ||
649 | if (i < 0) { | ||
650 | D_ERR(imx_usb->dev, "<%s> device setup error %d\n", | ||
651 | __func__, i); | ||
652 | goto stall; | ||
653 | } | ||
654 | |||
655 | return; | ||
656 | stall: | ||
657 | D_ERR(imx_usb->dev, "<%s> protocol STALL\n", __func__); | ||
658 | imx_ep_stall(imx_ep); | ||
659 | ep0_chg_stat(__func__, imx_usb, EP0_STALL); | ||
660 | return; | ||
661 | } | ||
662 | |||
663 | /******************************************************************************* | ||
664 | * USB gadget callback functions | ||
665 | ******************************************************************************* | ||
666 | */ | ||
667 | |||
668 | static int imx_ep_enable(struct usb_ep *usb_ep, | ||
669 | const struct usb_endpoint_descriptor *desc) | ||
670 | { | ||
671 | struct imx_ep_struct *imx_ep = container_of(usb_ep, | ||
672 | struct imx_ep_struct, ep); | ||
673 | struct imx_udc_struct *imx_usb = imx_ep->imx_usb; | ||
674 | unsigned long flags; | ||
675 | |||
676 | if (!usb_ep | ||
677 | || !desc | ||
678 | || !EP_NO(imx_ep) | ||
679 | || desc->bDescriptorType != USB_DT_ENDPOINT | ||
680 | || imx_ep->bEndpointAddress != desc->bEndpointAddress) { | ||
681 | D_ERR(imx_usb->dev, | ||
682 | "<%s> bad ep or descriptor\n", __func__); | ||
683 | return -EINVAL; | ||
684 | } | ||
685 | |||
686 | if (imx_ep->bmAttributes != desc->bmAttributes) { | ||
687 | D_ERR(imx_usb->dev, | ||
688 | "<%s> %s type mismatch\n", __func__, usb_ep->name); | ||
689 | return -EINVAL; | ||
690 | } | ||
691 | |||
692 | if (imx_ep->fifosize < usb_endpoint_maxp(desc)) { | ||
693 | D_ERR(imx_usb->dev, | ||
694 | "<%s> bad %s maxpacket\n", __func__, usb_ep->name); | ||
695 | return -ERANGE; | ||
696 | } | ||
697 | |||
698 | if (!imx_usb->driver || imx_usb->gadget.speed == USB_SPEED_UNKNOWN) { | ||
699 | D_ERR(imx_usb->dev, "<%s> bogus device state\n", __func__); | ||
700 | return -ESHUTDOWN; | ||
701 | } | ||
702 | |||
703 | local_irq_save(flags); | ||
704 | |||
705 | imx_ep->stopped = 0; | ||
706 | imx_flush(imx_ep); | ||
707 | imx_ep_irq_enable(imx_ep); | ||
708 | |||
709 | local_irq_restore(flags); | ||
710 | |||
711 | D_EPX(imx_usb->dev, "<%s> ENABLED %s\n", __func__, usb_ep->name); | ||
712 | return 0; | ||
713 | } | ||
714 | |||
715 | static int imx_ep_disable(struct usb_ep *usb_ep) | ||
716 | { | ||
717 | struct imx_ep_struct *imx_ep = container_of(usb_ep, | ||
718 | struct imx_ep_struct, ep); | ||
719 | unsigned long flags; | ||
720 | |||
721 | if (!usb_ep || !EP_NO(imx_ep) || !list_empty(&imx_ep->queue)) { | ||
722 | D_ERR(imx_ep->imx_usb->dev, "<%s> %s can not be disabled\n", | ||
723 | __func__, usb_ep ? imx_ep->ep.name : NULL); | ||
724 | return -EINVAL; | ||
725 | } | ||
726 | |||
727 | local_irq_save(flags); | ||
728 | |||
729 | imx_ep->stopped = 1; | ||
730 | nuke(imx_ep, -ESHUTDOWN); | ||
731 | imx_flush(imx_ep); | ||
732 | imx_ep_irq_disable(imx_ep); | ||
733 | |||
734 | local_irq_restore(flags); | ||
735 | |||
736 | D_EPX(imx_ep->imx_usb->dev, | ||
737 | "<%s> DISABLED %s\n", __func__, usb_ep->name); | ||
738 | return 0; | ||
739 | } | ||
740 | |||
741 | static struct usb_request *imx_ep_alloc_request | ||
742 | (struct usb_ep *usb_ep, gfp_t gfp_flags) | ||
743 | { | ||
744 | struct imx_request *req; | ||
745 | |||
746 | if (!usb_ep) | ||
747 | return NULL; | ||
748 | |||
749 | req = kzalloc(sizeof *req, gfp_flags); | ||
750 | if (!req) | ||
751 | return NULL; | ||
752 | |||
753 | INIT_LIST_HEAD(&req->queue); | ||
754 | req->in_use = 0; | ||
755 | |||
756 | return &req->req; | ||
757 | } | ||
758 | |||
759 | static void imx_ep_free_request | ||
760 | (struct usb_ep *usb_ep, struct usb_request *usb_req) | ||
761 | { | ||
762 | struct imx_request *req; | ||
763 | |||
764 | req = container_of(usb_req, struct imx_request, req); | ||
765 | WARN_ON(!list_empty(&req->queue)); | ||
766 | kfree(req); | ||
767 | } | ||
768 | |||
769 | static int imx_ep_queue | ||
770 | (struct usb_ep *usb_ep, struct usb_request *usb_req, gfp_t gfp_flags) | ||
771 | { | ||
772 | struct imx_ep_struct *imx_ep; | ||
773 | struct imx_udc_struct *imx_usb; | ||
774 | struct imx_request *req; | ||
775 | unsigned long flags; | ||
776 | int ret = 0; | ||
777 | |||
778 | imx_ep = container_of(usb_ep, struct imx_ep_struct, ep); | ||
779 | imx_usb = imx_ep->imx_usb; | ||
780 | req = container_of(usb_req, struct imx_request, req); | ||
781 | |||
782 | /* | ||
783 | Special care on IMX udc. | ||
784 | Ignore enqueue when after set configuration from the | ||
785 | host. This assume all gadget drivers reply set | ||
786 | configuration with the next ep0 req enqueue. | ||
787 | */ | ||
788 | if (imx_usb->set_config && !EP_NO(imx_ep)) { | ||
789 | imx_usb->set_config = 0; | ||
790 | D_ERR(imx_usb->dev, | ||
791 | "<%s> gadget reply set config\n", __func__); | ||
792 | return 0; | ||
793 | } | ||
794 | |||
795 | if (unlikely(!usb_req || !req || !usb_req->complete || !usb_req->buf)) { | ||
796 | D_ERR(imx_usb->dev, "<%s> bad params\n", __func__); | ||
797 | return -EINVAL; | ||
798 | } | ||
799 | |||
800 | if (unlikely(!usb_ep || !imx_ep)) { | ||
801 | D_ERR(imx_usb->dev, "<%s> bad ep\n", __func__); | ||
802 | return -EINVAL; | ||
803 | } | ||
804 | |||
805 | if (!imx_usb->driver || imx_usb->gadget.speed == USB_SPEED_UNKNOWN) { | ||
806 | D_ERR(imx_usb->dev, "<%s> bogus device state\n", __func__); | ||
807 | return -ESHUTDOWN; | ||
808 | } | ||
809 | |||
810 | /* Debug */ | ||
811 | D_REQ(imx_usb->dev, "<%s> ep%d %s request for [%d] bytes\n", | ||
812 | __func__, EP_NO(imx_ep), | ||
813 | ((!EP_NO(imx_ep) && imx_ep->imx_usb->ep0state | ||
814 | == EP0_IN_DATA_PHASE) | ||
815 | || (EP_NO(imx_ep) && EP_DIR(imx_ep))) | ||
816 | ? "IN" : "OUT", usb_req->length); | ||
817 | dump_req(__func__, imx_ep, usb_req); | ||
818 | |||
819 | if (imx_ep->stopped) { | ||
820 | usb_req->status = -ESHUTDOWN; | ||
821 | return -ESHUTDOWN; | ||
822 | } | ||
823 | |||
824 | if (req->in_use) { | ||
825 | D_ERR(imx_usb->dev, | ||
826 | "<%s> refusing to queue req %p (already queued)\n", | ||
827 | __func__, req); | ||
828 | return 0; | ||
829 | } | ||
830 | |||
831 | local_irq_save(flags); | ||
832 | |||
833 | usb_req->status = -EINPROGRESS; | ||
834 | usb_req->actual = 0; | ||
835 | |||
836 | ep_add_request(imx_ep, req); | ||
837 | |||
838 | if (!EP_NO(imx_ep)) | ||
839 | ret = handle_ep0(imx_ep); | ||
840 | else | ||
841 | ret = handle_ep(imx_ep); | ||
842 | |||
843 | local_irq_restore(flags); | ||
844 | return ret; | ||
845 | } | ||
846 | |||
847 | static int imx_ep_dequeue(struct usb_ep *usb_ep, struct usb_request *usb_req) | ||
848 | { | ||
849 | |||
850 | struct imx_ep_struct *imx_ep = container_of | ||
851 | (usb_ep, struct imx_ep_struct, ep); | ||
852 | struct imx_request *req; | ||
853 | unsigned long flags; | ||
854 | |||
855 | if (unlikely(!usb_ep || !EP_NO(imx_ep))) { | ||
856 | D_ERR(imx_ep->imx_usb->dev, "<%s> bad ep\n", __func__); | ||
857 | return -EINVAL; | ||
858 | } | ||
859 | |||
860 | local_irq_save(flags); | ||
861 | |||
862 | /* make sure it's actually queued on this endpoint */ | ||
863 | list_for_each_entry(req, &imx_ep->queue, queue) { | ||
864 | if (&req->req == usb_req) | ||
865 | break; | ||
866 | } | ||
867 | if (&req->req != usb_req) { | ||
868 | local_irq_restore(flags); | ||
869 | return -EINVAL; | ||
870 | } | ||
871 | |||
872 | done(imx_ep, req, -ECONNRESET); | ||
873 | |||
874 | local_irq_restore(flags); | ||
875 | return 0; | ||
876 | } | ||
877 | |||
878 | static int imx_ep_set_halt(struct usb_ep *usb_ep, int value) | ||
879 | { | ||
880 | struct imx_ep_struct *imx_ep = container_of | ||
881 | (usb_ep, struct imx_ep_struct, ep); | ||
882 | unsigned long flags; | ||
883 | |||
884 | if (unlikely(!usb_ep || !EP_NO(imx_ep))) { | ||
885 | D_ERR(imx_ep->imx_usb->dev, "<%s> bad ep\n", __func__); | ||
886 | return -EINVAL; | ||
887 | } | ||
888 | |||
889 | local_irq_save(flags); | ||
890 | |||
891 | if ((imx_ep->bEndpointAddress & USB_DIR_IN) | ||
892 | && !list_empty(&imx_ep->queue)) { | ||
893 | local_irq_restore(flags); | ||
894 | return -EAGAIN; | ||
895 | } | ||
896 | |||
897 | imx_ep_stall(imx_ep); | ||
898 | |||
899 | local_irq_restore(flags); | ||
900 | |||
901 | D_EPX(imx_ep->imx_usb->dev, "<%s> %s halt\n", __func__, usb_ep->name); | ||
902 | return 0; | ||
903 | } | ||
904 | |||
905 | static int imx_ep_fifo_status(struct usb_ep *usb_ep) | ||
906 | { | ||
907 | struct imx_ep_struct *imx_ep = container_of | ||
908 | (usb_ep, struct imx_ep_struct, ep); | ||
909 | |||
910 | if (!usb_ep) { | ||
911 | D_ERR(imx_ep->imx_usb->dev, "<%s> bad ep\n", __func__); | ||
912 | return -ENODEV; | ||
913 | } | ||
914 | |||
915 | if (imx_ep->imx_usb->gadget.speed == USB_SPEED_UNKNOWN) | ||
916 | return 0; | ||
917 | else | ||
918 | return imx_fifo_bcount(imx_ep); | ||
919 | } | ||
920 | |||
921 | static void imx_ep_fifo_flush(struct usb_ep *usb_ep) | ||
922 | { | ||
923 | struct imx_ep_struct *imx_ep = container_of | ||
924 | (usb_ep, struct imx_ep_struct, ep); | ||
925 | unsigned long flags; | ||
926 | |||
927 | local_irq_save(flags); | ||
928 | |||
929 | if (!usb_ep || !EP_NO(imx_ep) || !list_empty(&imx_ep->queue)) { | ||
930 | D_ERR(imx_ep->imx_usb->dev, "<%s> bad ep\n", __func__); | ||
931 | local_irq_restore(flags); | ||
932 | return; | ||
933 | } | ||
934 | |||
935 | /* toggle and halt bits stay unchanged */ | ||
936 | imx_flush(imx_ep); | ||
937 | |||
938 | local_irq_restore(flags); | ||
939 | } | ||
940 | |||
941 | static struct usb_ep_ops imx_ep_ops = { | ||
942 | .enable = imx_ep_enable, | ||
943 | .disable = imx_ep_disable, | ||
944 | |||
945 | .alloc_request = imx_ep_alloc_request, | ||
946 | .free_request = imx_ep_free_request, | ||
947 | |||
948 | .queue = imx_ep_queue, | ||
949 | .dequeue = imx_ep_dequeue, | ||
950 | |||
951 | .set_halt = imx_ep_set_halt, | ||
952 | .fifo_status = imx_ep_fifo_status, | ||
953 | .fifo_flush = imx_ep_fifo_flush, | ||
954 | }; | ||
955 | |||
956 | /******************************************************************************* | ||
957 | * USB endpoint control functions | ||
958 | ******************************************************************************* | ||
959 | */ | ||
960 | |||
961 | void ep0_chg_stat(const char *label, | ||
962 | struct imx_udc_struct *imx_usb, enum ep0_state stat) | ||
963 | { | ||
964 | D_EP0(imx_usb->dev, "<%s> from %15s to %15s\n", | ||
965 | label, state_name[imx_usb->ep0state], state_name[stat]); | ||
966 | |||
967 | if (imx_usb->ep0state == stat) | ||
968 | return; | ||
969 | |||
970 | imx_usb->ep0state = stat; | ||
971 | } | ||
972 | |||
973 | static void usb_init_data(struct imx_udc_struct *imx_usb) | ||
974 | { | ||
975 | struct imx_ep_struct *imx_ep; | ||
976 | u8 i; | ||
977 | |||
978 | /* device/ep0 records init */ | ||
979 | INIT_LIST_HEAD(&imx_usb->gadget.ep_list); | ||
980 | INIT_LIST_HEAD(&imx_usb->gadget.ep0->ep_list); | ||
981 | ep0_chg_stat(__func__, imx_usb, EP0_IDLE); | ||
982 | |||
983 | /* basic endpoint records init */ | ||
984 | for (i = 0; i < IMX_USB_NB_EP; i++) { | ||
985 | imx_ep = &imx_usb->imx_ep[i]; | ||
986 | |||
987 | if (i) { | ||
988 | list_add_tail(&imx_ep->ep.ep_list, | ||
989 | &imx_usb->gadget.ep_list); | ||
990 | imx_ep->stopped = 1; | ||
991 | } else | ||
992 | imx_ep->stopped = 0; | ||
993 | |||
994 | INIT_LIST_HEAD(&imx_ep->queue); | ||
995 | } | ||
996 | } | ||
997 | |||
998 | static void udc_stop_activity(struct imx_udc_struct *imx_usb, | ||
999 | struct usb_gadget_driver *driver) | ||
1000 | { | ||
1001 | struct imx_ep_struct *imx_ep; | ||
1002 | int i; | ||
1003 | |||
1004 | if (imx_usb->gadget.speed == USB_SPEED_UNKNOWN) | ||
1005 | driver = NULL; | ||
1006 | |||
1007 | /* prevent new request submissions, kill any outstanding requests */ | ||
1008 | for (i = 1; i < IMX_USB_NB_EP; i++) { | ||
1009 | imx_ep = &imx_usb->imx_ep[i]; | ||
1010 | imx_flush(imx_ep); | ||
1011 | imx_ep->stopped = 1; | ||
1012 | imx_ep_irq_disable(imx_ep); | ||
1013 | nuke(imx_ep, -ESHUTDOWN); | ||
1014 | } | ||
1015 | |||
1016 | imx_usb->cfg = 0; | ||
1017 | imx_usb->intf = 0; | ||
1018 | imx_usb->alt = 0; | ||
1019 | |||
1020 | if (driver) | ||
1021 | driver->disconnect(&imx_usb->gadget); | ||
1022 | } | ||
1023 | |||
1024 | /******************************************************************************* | ||
1025 | * Interrupt handlers | ||
1026 | ******************************************************************************* | ||
1027 | */ | ||
1028 | |||
1029 | /* | ||
1030 | * Called when timer expires. | ||
1031 | * Timer is started when CFG_CHG is received. | ||
1032 | */ | ||
1033 | static void handle_config(unsigned long data) | ||
1034 | { | ||
1035 | struct imx_udc_struct *imx_usb = (void *)data; | ||
1036 | struct usb_ctrlrequest u; | ||
1037 | int temp, cfg, intf, alt; | ||
1038 | |||
1039 | local_irq_disable(); | ||
1040 | |||
1041 | temp = __raw_readl(imx_usb->base + USB_STAT); | ||
1042 | cfg = (temp & STAT_CFG) >> 5; | ||
1043 | intf = (temp & STAT_INTF) >> 3; | ||
1044 | alt = temp & STAT_ALTSET; | ||
1045 | |||
1046 | D_REQ(imx_usb->dev, | ||
1047 | "<%s> orig config C=%d, I=%d, A=%d / " | ||
1048 | "req config C=%d, I=%d, A=%d\n", | ||
1049 | __func__, imx_usb->cfg, imx_usb->intf, imx_usb->alt, | ||
1050 | cfg, intf, alt); | ||
1051 | |||
1052 | if (cfg == 1 || cfg == 2) { | ||
1053 | |||
1054 | if (imx_usb->cfg != cfg) { | ||
1055 | u.bRequest = USB_REQ_SET_CONFIGURATION; | ||
1056 | u.bRequestType = USB_DIR_OUT | | ||
1057 | USB_TYPE_STANDARD | | ||
1058 | USB_RECIP_DEVICE; | ||
1059 | u.wValue = cfg; | ||
1060 | u.wIndex = 0; | ||
1061 | u.wLength = 0; | ||
1062 | imx_usb->cfg = cfg; | ||
1063 | imx_usb->driver->setup(&imx_usb->gadget, &u); | ||
1064 | |||
1065 | } | ||
1066 | if (imx_usb->intf != intf || imx_usb->alt != alt) { | ||
1067 | u.bRequest = USB_REQ_SET_INTERFACE; | ||
1068 | u.bRequestType = USB_DIR_OUT | | ||
1069 | USB_TYPE_STANDARD | | ||
1070 | USB_RECIP_INTERFACE; | ||
1071 | u.wValue = alt; | ||
1072 | u.wIndex = intf; | ||
1073 | u.wLength = 0; | ||
1074 | imx_usb->intf = intf; | ||
1075 | imx_usb->alt = alt; | ||
1076 | imx_usb->driver->setup(&imx_usb->gadget, &u); | ||
1077 | } | ||
1078 | } | ||
1079 | |||
1080 | imx_usb->set_config = 0; | ||
1081 | |||
1082 | local_irq_enable(); | ||
1083 | } | ||
1084 | |||
1085 | static irqreturn_t imx_udc_irq(int irq, void *dev) | ||
1086 | { | ||
1087 | struct imx_udc_struct *imx_usb = dev; | ||
1088 | int intr = __raw_readl(imx_usb->base + USB_INTR); | ||
1089 | int temp; | ||
1090 | |||
1091 | if (intr & (INTR_WAKEUP | INTR_SUSPEND | INTR_RESUME | INTR_RESET_START | ||
1092 | | INTR_RESET_STOP | INTR_CFG_CHG)) { | ||
1093 | dump_intr(__func__, intr, imx_usb->dev); | ||
1094 | dump_usb_stat(__func__, imx_usb); | ||
1095 | } | ||
1096 | |||
1097 | if (!imx_usb->driver) | ||
1098 | goto end_irq; | ||
1099 | |||
1100 | if (intr & INTR_SOF) { | ||
1101 | /* Copy from Freescale BSP. | ||
1102 | We must enable SOF intr and set CMDOVER. | ||
1103 | Datasheet don't specifiy this action, but it | ||
1104 | is done in Freescale BSP, so just copy it. | ||
1105 | */ | ||
1106 | if (imx_usb->ep0state == EP0_IDLE) { | ||
1107 | temp = __raw_readl(imx_usb->base + USB_CTRL); | ||
1108 | __raw_writel(temp | CTRL_CMDOVER, | ||
1109 | imx_usb->base + USB_CTRL); | ||
1110 | } | ||
1111 | } | ||
1112 | |||
1113 | if (intr & INTR_CFG_CHG) { | ||
1114 | /* A workaround of serious IMX UDC bug. | ||
1115 | Handling of CFG_CHG should be delayed for some time, because | ||
1116 | IMX does not NACK the host when CFG_CHG interrupt is pending. | ||
1117 | There is no time to handle current CFG_CHG | ||
1118 | if next CFG_CHG or SETUP packed is send immediately. | ||
1119 | We have to clear CFG_CHG, start the timer and | ||
1120 | NACK the host by setting CTRL_CMDOVER | ||
1121 | if it sends any SETUP packet. | ||
1122 | When timer expires, handler is called to handle configuration | ||
1123 | changes. While CFG_CHG is not handled (set_config=1), | ||
1124 | we must NACK the host to every SETUP packed. | ||
1125 | This delay prevents from going out of sync with host. | ||
1126 | */ | ||
1127 | __raw_writel(INTR_CFG_CHG, imx_usb->base + USB_INTR); | ||
1128 | imx_usb->set_config = 1; | ||
1129 | mod_timer(&imx_usb->timer, jiffies + 5); | ||
1130 | goto end_irq; | ||
1131 | } | ||
1132 | |||
1133 | if (intr & INTR_WAKEUP) { | ||
1134 | if (imx_usb->gadget.speed == USB_SPEED_UNKNOWN | ||
1135 | && imx_usb->driver && imx_usb->driver->resume) | ||
1136 | imx_usb->driver->resume(&imx_usb->gadget); | ||
1137 | imx_usb->set_config = 0; | ||
1138 | del_timer(&imx_usb->timer); | ||
1139 | imx_usb->gadget.speed = USB_SPEED_FULL; | ||
1140 | } | ||
1141 | |||
1142 | if (intr & INTR_SUSPEND) { | ||
1143 | if (imx_usb->gadget.speed != USB_SPEED_UNKNOWN | ||
1144 | && imx_usb->driver && imx_usb->driver->suspend) | ||
1145 | imx_usb->driver->suspend(&imx_usb->gadget); | ||
1146 | imx_usb->set_config = 0; | ||
1147 | del_timer(&imx_usb->timer); | ||
1148 | imx_usb->gadget.speed = USB_SPEED_UNKNOWN; | ||
1149 | } | ||
1150 | |||
1151 | if (intr & INTR_RESET_START) { | ||
1152 | __raw_writel(intr, imx_usb->base + USB_INTR); | ||
1153 | udc_stop_activity(imx_usb, imx_usb->driver); | ||
1154 | imx_usb->set_config = 0; | ||
1155 | del_timer(&imx_usb->timer); | ||
1156 | imx_usb->gadget.speed = USB_SPEED_UNKNOWN; | ||
1157 | } | ||
1158 | |||
1159 | if (intr & INTR_RESET_STOP) | ||
1160 | imx_usb->gadget.speed = USB_SPEED_FULL; | ||
1161 | |||
1162 | end_irq: | ||
1163 | __raw_writel(intr, imx_usb->base + USB_INTR); | ||
1164 | return IRQ_HANDLED; | ||
1165 | } | ||
1166 | |||
1167 | static irqreturn_t imx_udc_ctrl_irq(int irq, void *dev) | ||
1168 | { | ||
1169 | struct imx_udc_struct *imx_usb = dev; | ||
1170 | struct imx_ep_struct *imx_ep = &imx_usb->imx_ep[0]; | ||
1171 | int intr = __raw_readl(imx_usb->base + USB_EP_INTR(0)); | ||
1172 | |||
1173 | dump_ep_intr(__func__, 0, intr, imx_usb->dev); | ||
1174 | |||
1175 | if (!imx_usb->driver) { | ||
1176 | __raw_writel(intr, imx_usb->base + USB_EP_INTR(0)); | ||
1177 | return IRQ_HANDLED; | ||
1178 | } | ||
1179 | |||
1180 | /* DEVREQ has highest priority */ | ||
1181 | if (intr & (EPINTR_DEVREQ | EPINTR_MDEVREQ)) | ||
1182 | handle_ep0_devreq(imx_usb); | ||
1183 | /* Seem i.MX is missing EOF interrupt sometimes. | ||
1184 | * Therefore we don't monitor EOF. | ||
1185 | * We call handle_ep0() only if a request is queued for ep0. | ||
1186 | */ | ||
1187 | else if (!list_empty(&imx_ep->queue)) | ||
1188 | handle_ep0(imx_ep); | ||
1189 | |||
1190 | __raw_writel(intr, imx_usb->base + USB_EP_INTR(0)); | ||
1191 | |||
1192 | return IRQ_HANDLED; | ||
1193 | } | ||
1194 | |||
1195 | #ifndef MX1_INT_USBD0 | ||
1196 | #define MX1_INT_USBD0 MX1_USBD_INT0 | ||
1197 | #endif | ||
1198 | |||
1199 | static irqreturn_t imx_udc_bulk_irq(int irq, void *dev) | ||
1200 | { | ||
1201 | struct imx_udc_struct *imx_usb = dev; | ||
1202 | struct imx_ep_struct *imx_ep = &imx_usb->imx_ep[irq - MX1_INT_USBD0]; | ||
1203 | int intr = __raw_readl(imx_usb->base + USB_EP_INTR(EP_NO(imx_ep))); | ||
1204 | |||
1205 | dump_ep_intr(__func__, irq - MX1_INT_USBD0, intr, imx_usb->dev); | ||
1206 | |||
1207 | if (!imx_usb->driver) { | ||
1208 | __raw_writel(intr, imx_usb->base + USB_EP_INTR(EP_NO(imx_ep))); | ||
1209 | return IRQ_HANDLED; | ||
1210 | } | ||
1211 | |||
1212 | handle_ep(imx_ep); | ||
1213 | |||
1214 | __raw_writel(intr, imx_usb->base + USB_EP_INTR(EP_NO(imx_ep))); | ||
1215 | |||
1216 | return IRQ_HANDLED; | ||
1217 | } | ||
1218 | |||
1219 | irq_handler_t intr_handler(int i) | ||
1220 | { | ||
1221 | switch (i) { | ||
1222 | case 0: | ||
1223 | return imx_udc_ctrl_irq; | ||
1224 | case 1: | ||
1225 | case 2: | ||
1226 | case 3: | ||
1227 | case 4: | ||
1228 | case 5: | ||
1229 | return imx_udc_bulk_irq; | ||
1230 | default: | ||
1231 | return imx_udc_irq; | ||
1232 | } | ||
1233 | } | ||
1234 | |||
1235 | /******************************************************************************* | ||
1236 | * Static defined IMX UDC structure | ||
1237 | ******************************************************************************* | ||
1238 | */ | ||
1239 | |||
1240 | static int imx_udc_start(struct usb_gadget *gadget, | ||
1241 | struct usb_gadget_driver *driver); | ||
1242 | static int imx_udc_stop(struct usb_gadget *gadget, | ||
1243 | struct usb_gadget_driver *driver); | ||
1244 | static const struct usb_gadget_ops imx_udc_ops = { | ||
1245 | .get_frame = imx_udc_get_frame, | ||
1246 | .wakeup = imx_udc_wakeup, | ||
1247 | .udc_start = imx_udc_start, | ||
1248 | .udc_stop = imx_udc_stop, | ||
1249 | }; | ||
1250 | |||
1251 | static struct imx_udc_struct controller = { | ||
1252 | .gadget = { | ||
1253 | .ops = &imx_udc_ops, | ||
1254 | .ep0 = &controller.imx_ep[0].ep, | ||
1255 | .name = driver_name, | ||
1256 | .dev = { | ||
1257 | .init_name = "gadget", | ||
1258 | }, | ||
1259 | }, | ||
1260 | |||
1261 | .imx_ep[0] = { | ||
1262 | .ep = { | ||
1263 | .name = ep0name, | ||
1264 | .ops = &imx_ep_ops, | ||
1265 | .maxpacket = 32, | ||
1266 | }, | ||
1267 | .imx_usb = &controller, | ||
1268 | .fifosize = 32, | ||
1269 | .bEndpointAddress = 0, | ||
1270 | .bmAttributes = USB_ENDPOINT_XFER_CONTROL, | ||
1271 | }, | ||
1272 | .imx_ep[1] = { | ||
1273 | .ep = { | ||
1274 | .name = "ep1in-bulk", | ||
1275 | .ops = &imx_ep_ops, | ||
1276 | .maxpacket = 64, | ||
1277 | }, | ||
1278 | .imx_usb = &controller, | ||
1279 | .fifosize = 64, | ||
1280 | .bEndpointAddress = USB_DIR_IN | 1, | ||
1281 | .bmAttributes = USB_ENDPOINT_XFER_BULK, | ||
1282 | }, | ||
1283 | .imx_ep[2] = { | ||
1284 | .ep = { | ||
1285 | .name = "ep2out-bulk", | ||
1286 | .ops = &imx_ep_ops, | ||
1287 | .maxpacket = 64, | ||
1288 | }, | ||
1289 | .imx_usb = &controller, | ||
1290 | .fifosize = 64, | ||
1291 | .bEndpointAddress = USB_DIR_OUT | 2, | ||
1292 | .bmAttributes = USB_ENDPOINT_XFER_BULK, | ||
1293 | }, | ||
1294 | .imx_ep[3] = { | ||
1295 | .ep = { | ||
1296 | .name = "ep3out-bulk", | ||
1297 | .ops = &imx_ep_ops, | ||
1298 | .maxpacket = 32, | ||
1299 | }, | ||
1300 | .imx_usb = &controller, | ||
1301 | .fifosize = 32, | ||
1302 | .bEndpointAddress = USB_DIR_OUT | 3, | ||
1303 | .bmAttributes = USB_ENDPOINT_XFER_BULK, | ||
1304 | }, | ||
1305 | .imx_ep[4] = { | ||
1306 | .ep = { | ||
1307 | .name = "ep4in-int", | ||
1308 | .ops = &imx_ep_ops, | ||
1309 | .maxpacket = 32, | ||
1310 | }, | ||
1311 | .imx_usb = &controller, | ||
1312 | .fifosize = 32, | ||
1313 | .bEndpointAddress = USB_DIR_IN | 4, | ||
1314 | .bmAttributes = USB_ENDPOINT_XFER_INT, | ||
1315 | }, | ||
1316 | .imx_ep[5] = { | ||
1317 | .ep = { | ||
1318 | .name = "ep5out-int", | ||
1319 | .ops = &imx_ep_ops, | ||
1320 | .maxpacket = 32, | ||
1321 | }, | ||
1322 | .imx_usb = &controller, | ||
1323 | .fifosize = 32, | ||
1324 | .bEndpointAddress = USB_DIR_OUT | 5, | ||
1325 | .bmAttributes = USB_ENDPOINT_XFER_INT, | ||
1326 | }, | ||
1327 | }; | ||
1328 | |||
1329 | /******************************************************************************* | ||
1330 | * USB gadget driver functions | ||
1331 | ******************************************************************************* | ||
1332 | */ | ||
1333 | static int imx_udc_start(struct usb_gadget *gadget, | ||
1334 | struct usb_gadget_driver *driver) | ||
1335 | { | ||
1336 | struct imx_udc_struct *imx_usb; | ||
1337 | |||
1338 | imx_usb = container_of(gadget, struct imx_udc_struct, gadget); | ||
1339 | /* first hook up the driver ... */ | ||
1340 | imx_usb->driver = driver; | ||
1341 | |||
1342 | D_INI(imx_usb->dev, "<%s> registered gadget driver '%s'\n", | ||
1343 | __func__, driver->driver.name); | ||
1344 | |||
1345 | imx_udc_enable(imx_usb); | ||
1346 | |||
1347 | return 0; | ||
1348 | } | ||
1349 | |||
1350 | static int imx_udc_stop(struct usb_gadget *gadget, | ||
1351 | struct usb_gadget_driver *driver) | ||
1352 | { | ||
1353 | struct imx_udc_struct *imx_usb = container_of(gadget, | ||
1354 | struct imx_udc_struct, gadget); | ||
1355 | |||
1356 | udc_stop_activity(imx_usb, driver); | ||
1357 | imx_udc_disable(imx_usb); | ||
1358 | del_timer(&imx_usb->timer); | ||
1359 | |||
1360 | imx_usb->driver = NULL; | ||
1361 | |||
1362 | D_INI(imx_usb->dev, "<%s> unregistered gadget driver '%s'\n", | ||
1363 | __func__, driver->driver.name); | ||
1364 | |||
1365 | return 0; | ||
1366 | } | ||
1367 | |||
1368 | /******************************************************************************* | ||
1369 | * Module functions | ||
1370 | ******************************************************************************* | ||
1371 | */ | ||
1372 | |||
1373 | static int __init imx_udc_probe(struct platform_device *pdev) | ||
1374 | { | ||
1375 | struct imx_udc_struct *imx_usb = &controller; | ||
1376 | struct resource *res; | ||
1377 | struct imxusb_platform_data *pdata; | ||
1378 | struct clk *clk; | ||
1379 | void __iomem *base; | ||
1380 | int ret = 0; | ||
1381 | int i; | ||
1382 | resource_size_t res_size; | ||
1383 | |||
1384 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
1385 | if (!res) { | ||
1386 | dev_err(&pdev->dev, "can't get device resources\n"); | ||
1387 | return -ENODEV; | ||
1388 | } | ||
1389 | |||
1390 | pdata = pdev->dev.platform_data; | ||
1391 | if (!pdata) { | ||
1392 | dev_err(&pdev->dev, "driver needs platform data\n"); | ||
1393 | return -ENODEV; | ||
1394 | } | ||
1395 | |||
1396 | res_size = resource_size(res); | ||
1397 | if (!request_mem_region(res->start, res_size, res->name)) { | ||
1398 | dev_err(&pdev->dev, "can't allocate %d bytes at %d address\n", | ||
1399 | res_size, res->start); | ||
1400 | return -ENOMEM; | ||
1401 | } | ||
1402 | |||
1403 | if (pdata->init) { | ||
1404 | ret = pdata->init(&pdev->dev); | ||
1405 | if (ret) | ||
1406 | goto fail0; | ||
1407 | } | ||
1408 | |||
1409 | base = ioremap(res->start, res_size); | ||
1410 | if (!base) { | ||
1411 | dev_err(&pdev->dev, "ioremap failed\n"); | ||
1412 | ret = -EIO; | ||
1413 | goto fail1; | ||
1414 | } | ||
1415 | |||
1416 | clk = clk_get(NULL, "usbd_clk"); | ||
1417 | if (IS_ERR(clk)) { | ||
1418 | ret = PTR_ERR(clk); | ||
1419 | dev_err(&pdev->dev, "can't get USB clock\n"); | ||
1420 | goto fail2; | ||
1421 | } | ||
1422 | clk_prepare_enable(clk); | ||
1423 | |||
1424 | if (clk_get_rate(clk) != 48000000) { | ||
1425 | D_INI(&pdev->dev, | ||
1426 | "Bad USB clock (%d Hz), changing to 48000000 Hz\n", | ||
1427 | (int)clk_get_rate(clk)); | ||
1428 | if (clk_set_rate(clk, 48000000)) { | ||
1429 | dev_err(&pdev->dev, | ||
1430 | "Unable to set correct USB clock (48MHz)\n"); | ||
1431 | ret = -EIO; | ||
1432 | goto fail3; | ||
1433 | } | ||
1434 | } | ||
1435 | |||
1436 | for (i = 0; i < IMX_USB_NB_EP + 1; i++) { | ||
1437 | imx_usb->usbd_int[i] = platform_get_irq(pdev, i); | ||
1438 | if (imx_usb->usbd_int[i] < 0) { | ||
1439 | dev_err(&pdev->dev, "can't get irq number\n"); | ||
1440 | ret = -ENODEV; | ||
1441 | goto fail3; | ||
1442 | } | ||
1443 | } | ||
1444 | |||
1445 | for (i = 0; i < IMX_USB_NB_EP + 1; i++) { | ||
1446 | ret = request_irq(imx_usb->usbd_int[i], intr_handler(i), | ||
1447 | 0, driver_name, imx_usb); | ||
1448 | if (ret) { | ||
1449 | dev_err(&pdev->dev, "can't get irq %i, err %d\n", | ||
1450 | imx_usb->usbd_int[i], ret); | ||
1451 | for (--i; i >= 0; i--) | ||
1452 | free_irq(imx_usb->usbd_int[i], imx_usb); | ||
1453 | goto fail3; | ||
1454 | } | ||
1455 | } | ||
1456 | |||
1457 | imx_usb->res = res; | ||
1458 | imx_usb->base = base; | ||
1459 | imx_usb->clk = clk; | ||
1460 | imx_usb->dev = &pdev->dev; | ||
1461 | |||
1462 | platform_set_drvdata(pdev, imx_usb); | ||
1463 | |||
1464 | usb_init_data(imx_usb); | ||
1465 | imx_udc_init(imx_usb); | ||
1466 | |||
1467 | init_timer(&imx_usb->timer); | ||
1468 | imx_usb->timer.function = handle_config; | ||
1469 | imx_usb->timer.data = (unsigned long)imx_usb; | ||
1470 | |||
1471 | ret = usb_add_gadget_udc(&pdev->dev, &imx_usb->gadget); | ||
1472 | if (ret) | ||
1473 | goto fail4; | ||
1474 | |||
1475 | return 0; | ||
1476 | fail4: | ||
1477 | for (i = 0; i < IMX_USB_NB_EP + 1; i++) | ||
1478 | free_irq(imx_usb->usbd_int[i], imx_usb); | ||
1479 | fail3: | ||
1480 | clk_put(clk); | ||
1481 | clk_disable_unprepare(clk); | ||
1482 | fail2: | ||
1483 | iounmap(base); | ||
1484 | fail1: | ||
1485 | if (pdata->exit) | ||
1486 | pdata->exit(&pdev->dev); | ||
1487 | fail0: | ||
1488 | release_mem_region(res->start, res_size); | ||
1489 | return ret; | ||
1490 | } | ||
1491 | |||
1492 | static int __exit imx_udc_remove(struct platform_device *pdev) | ||
1493 | { | ||
1494 | struct imx_udc_struct *imx_usb = platform_get_drvdata(pdev); | ||
1495 | struct imxusb_platform_data *pdata = pdev->dev.platform_data; | ||
1496 | int i; | ||
1497 | |||
1498 | usb_del_gadget_udc(&imx_usb->gadget); | ||
1499 | imx_udc_disable(imx_usb); | ||
1500 | del_timer(&imx_usb->timer); | ||
1501 | |||
1502 | for (i = 0; i < IMX_USB_NB_EP + 1; i++) | ||
1503 | free_irq(imx_usb->usbd_int[i], imx_usb); | ||
1504 | |||
1505 | clk_put(imx_usb->clk); | ||
1506 | clk_disable_unprepare(imx_usb->clk); | ||
1507 | iounmap(imx_usb->base); | ||
1508 | |||
1509 | release_mem_region(imx_usb->res->start, resource_size(imx_usb->res)); | ||
1510 | |||
1511 | if (pdata->exit) | ||
1512 | pdata->exit(&pdev->dev); | ||
1513 | |||
1514 | return 0; | ||
1515 | } | ||
1516 | |||
1517 | /*----------------------------------------------------------------------------*/ | ||
1518 | |||
1519 | #ifdef CONFIG_PM | ||
1520 | #define imx_udc_suspend NULL | ||
1521 | #define imx_udc_resume NULL | ||
1522 | #else | ||
1523 | #define imx_udc_suspend NULL | ||
1524 | #define imx_udc_resume NULL | ||
1525 | #endif | ||
1526 | |||
1527 | /*----------------------------------------------------------------------------*/ | ||
1528 | |||
1529 | static struct platform_driver udc_driver = { | ||
1530 | .driver = { | ||
1531 | .name = driver_name, | ||
1532 | .owner = THIS_MODULE, | ||
1533 | }, | ||
1534 | .remove = __exit_p(imx_udc_remove), | ||
1535 | .suspend = imx_udc_suspend, | ||
1536 | .resume = imx_udc_resume, | ||
1537 | }; | ||
1538 | |||
1539 | module_platform_driver_probe(udc_driver, imx_udc_probe); | ||
1540 | |||
1541 | MODULE_DESCRIPTION("IMX USB Device Controller driver"); | ||
1542 | MODULE_AUTHOR("Darius Augulis <augulis.darius@gmail.com>"); | ||
1543 | MODULE_LICENSE("GPL"); | ||
1544 | MODULE_ALIAS("platform:imx_udc"); | ||
diff --git a/drivers/usb/gadget/imx_udc.h b/drivers/usb/gadget/imx_udc.h deleted file mode 100644 index d118fb777840..000000000000 --- a/drivers/usb/gadget/imx_udc.h +++ /dev/null | |||
@@ -1,351 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2005 Mike Lee(eemike@gmail.com) | ||
3 | * | ||
4 | * This udc driver is now under testing and code is based on pxa2xx_udc.h | ||
5 | * Please use it with your own risk! | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License as published by | ||
9 | * the Free Software Foundation; either version 2 of the License, or | ||
10 | * (at your option) any later version. | ||
11 | */ | ||
12 | |||
13 | #ifndef __LINUX_USB_GADGET_IMX_H | ||
14 | #define __LINUX_USB_GADGET_IMX_H | ||
15 | |||
16 | #include <linux/types.h> | ||
17 | |||
18 | /* Helper macros */ | ||
19 | #define EP_NO(ep) ((ep->bEndpointAddress) & ~USB_DIR_IN) /* IN:1, OUT:0 */ | ||
20 | #define EP_DIR(ep) ((ep->bEndpointAddress) & USB_DIR_IN ? 1 : 0) | ||
21 | #define IMX_USB_NB_EP 6 | ||
22 | |||
23 | /* Driver structures */ | ||
24 | struct imx_request { | ||
25 | struct usb_request req; | ||
26 | struct list_head queue; | ||
27 | unsigned int in_use; | ||
28 | }; | ||
29 | |||
30 | enum ep0_state { | ||
31 | EP0_IDLE, | ||
32 | EP0_IN_DATA_PHASE, | ||
33 | EP0_OUT_DATA_PHASE, | ||
34 | EP0_CONFIG, | ||
35 | EP0_STALL, | ||
36 | }; | ||
37 | |||
38 | struct imx_ep_struct { | ||
39 | struct usb_ep ep; | ||
40 | struct imx_udc_struct *imx_usb; | ||
41 | struct list_head queue; | ||
42 | unsigned char stopped; | ||
43 | unsigned char fifosize; | ||
44 | unsigned char bEndpointAddress; | ||
45 | unsigned char bmAttributes; | ||
46 | }; | ||
47 | |||
48 | struct imx_udc_struct { | ||
49 | struct usb_gadget gadget; | ||
50 | struct usb_gadget_driver *driver; | ||
51 | struct device *dev; | ||
52 | struct imx_ep_struct imx_ep[IMX_USB_NB_EP]; | ||
53 | struct clk *clk; | ||
54 | struct timer_list timer; | ||
55 | enum ep0_state ep0state; | ||
56 | struct resource *res; | ||
57 | void __iomem *base; | ||
58 | unsigned char set_config; | ||
59 | int cfg, | ||
60 | intf, | ||
61 | alt, | ||
62 | usbd_int[7]; | ||
63 | }; | ||
64 | |||
65 | /* USB registers */ | ||
66 | #define USB_FRAME (0x00) /* USB frame */ | ||
67 | #define USB_SPEC (0x04) /* USB Spec */ | ||
68 | #define USB_STAT (0x08) /* USB Status */ | ||
69 | #define USB_CTRL (0x0C) /* USB Control */ | ||
70 | #define USB_DADR (0x10) /* USB Desc RAM addr */ | ||
71 | #define USB_DDAT (0x14) /* USB Desc RAM/EP buffer data */ | ||
72 | #define USB_INTR (0x18) /* USB interrupt */ | ||
73 | #define USB_MASK (0x1C) /* USB Mask */ | ||
74 | #define USB_ENAB (0x24) /* USB Enable */ | ||
75 | #define USB_EP_STAT(x) (0x30 + (x*0x30)) /* USB status/control */ | ||
76 | #define USB_EP_INTR(x) (0x34 + (x*0x30)) /* USB interrupt */ | ||
77 | #define USB_EP_MASK(x) (0x38 + (x*0x30)) /* USB mask */ | ||
78 | #define USB_EP_FDAT(x) (0x3C + (x*0x30)) /* USB FIFO data */ | ||
79 | #define USB_EP_FDAT0(x) (0x3C + (x*0x30)) /* USB FIFO data */ | ||
80 | #define USB_EP_FDAT1(x) (0x3D + (x*0x30)) /* USB FIFO data */ | ||
81 | #define USB_EP_FDAT2(x) (0x3E + (x*0x30)) /* USB FIFO data */ | ||
82 | #define USB_EP_FDAT3(x) (0x3F + (x*0x30)) /* USB FIFO data */ | ||
83 | #define USB_EP_FSTAT(x) (0x40 + (x*0x30)) /* USB FIFO status */ | ||
84 | #define USB_EP_FCTRL(x) (0x44 + (x*0x30)) /* USB FIFO control */ | ||
85 | #define USB_EP_LRFP(x) (0x48 + (x*0x30)) /* USB last rd f. pointer */ | ||
86 | #define USB_EP_LWFP(x) (0x4C + (x*0x30)) /* USB last wr f. pointer */ | ||
87 | #define USB_EP_FALRM(x) (0x50 + (x*0x30)) /* USB FIFO alarm */ | ||
88 | #define USB_EP_FRDP(x) (0x54 + (x*0x30)) /* USB FIFO read pointer */ | ||
89 | #define USB_EP_FWRP(x) (0x58 + (x*0x30)) /* USB FIFO write pointer */ | ||
90 | /* USB Control Register Bit Fields.*/ | ||
91 | #define CTRL_CMDOVER (1<<6) /* UDC status */ | ||
92 | #define CTRL_CMDERROR (1<<5) /* UDC status */ | ||
93 | #define CTRL_FE_ENA (1<<3) /* Enable Font End logic */ | ||
94 | #define CTRL_UDC_RST (1<<2) /* UDC reset */ | ||
95 | #define CTRL_AFE_ENA (1<<1) /* Analog Font end enable */ | ||
96 | #define CTRL_RESUME (1<<0) /* UDC resume */ | ||
97 | /* USB Status Register Bit Fields.*/ | ||
98 | #define STAT_RST (1<<8) | ||
99 | #define STAT_SUSP (1<<7) | ||
100 | #define STAT_CFG (3<<5) | ||
101 | #define STAT_INTF (3<<3) | ||
102 | #define STAT_ALTSET (7<<0) | ||
103 | /* USB Interrupt Status/Mask Registers Bit fields */ | ||
104 | #define INTR_WAKEUP (1<<31) /* Wake up Interrupt */ | ||
105 | #define INTR_MSOF (1<<7) /* Missed Start of Frame */ | ||
106 | #define INTR_SOF (1<<6) /* Start of Frame */ | ||
107 | #define INTR_RESET_STOP (1<<5) /* Reset Signaling stop */ | ||
108 | #define INTR_RESET_START (1<<4) /* Reset Signaling start */ | ||
109 | #define INTR_RESUME (1<<3) /* Suspend to resume */ | ||
110 | #define INTR_SUSPEND (1<<2) /* Active to suspend */ | ||
111 | #define INTR_FRAME_MATCH (1<<1) /* Frame matched */ | ||
112 | #define INTR_CFG_CHG (1<<0) /* Configuration change occurred */ | ||
113 | /* USB Enable Register Bit Fields.*/ | ||
114 | #define ENAB_RST (1<<31) /* Reset USB modules */ | ||
115 | #define ENAB_ENAB (1<<30) /* Enable USB modules*/ | ||
116 | #define ENAB_SUSPEND (1<<29) /* Suspend USB modules */ | ||
117 | #define ENAB_ENDIAN (1<<28) /* Endian of USB modules */ | ||
118 | #define ENAB_PWRMD (1<<0) /* Power mode of USB modules */ | ||
119 | /* USB Descriptor Ram Address Register bit fields */ | ||
120 | #define DADR_CFG (1<<31) /* Configuration */ | ||
121 | #define DADR_BSY (1<<30) /* Busy status */ | ||
122 | #define DADR_DADR (0x1FF) /* Descriptor Ram Address */ | ||
123 | /* USB Descriptor RAM/Endpoint Buffer Data Register bit fields */ | ||
124 | #define DDAT_DDAT (0xFF) /* Descriptor Endpoint Buffer */ | ||
125 | /* USB Endpoint Status Register bit fields */ | ||
126 | #define EPSTAT_BCOUNT (0x7F<<16) /* Endpoint FIFO byte count */ | ||
127 | #define EPSTAT_SIP (1<<8) /* Endpoint setup in progress */ | ||
128 | #define EPSTAT_DIR (1<<7) /* Endpoint transfer direction */ | ||
129 | #define EPSTAT_MAX (3<<5) /* Endpoint Max packet size */ | ||
130 | #define EPSTAT_TYP (3<<3) /* Endpoint type */ | ||
131 | #define EPSTAT_ZLPS (1<<2) /* Send zero length packet */ | ||
132 | #define EPSTAT_FLUSH (1<<1) /* Endpoint FIFO Flush */ | ||
133 | #define EPSTAT_STALL (1<<0) /* Force stall */ | ||
134 | /* USB Endpoint FIFO Status Register bit fields */ | ||
135 | #define FSTAT_FRAME_STAT (0xF<<24) /* Frame status bit [0-3] */ | ||
136 | #define FSTAT_ERR (1<<22) /* FIFO error */ | ||
137 | #define FSTAT_UF (1<<21) /* FIFO underflow */ | ||
138 | #define FSTAT_OF (1<<20) /* FIFO overflow */ | ||
139 | #define FSTAT_FR (1<<19) /* FIFO frame ready */ | ||
140 | #define FSTAT_FULL (1<<18) /* FIFO full */ | ||
141 | #define FSTAT_ALRM (1<<17) /* FIFO alarm */ | ||
142 | #define FSTAT_EMPTY (1<<16) /* FIFO empty */ | ||
143 | /* USB Endpoint FIFO Control Register bit fields */ | ||
144 | #define FCTRL_WFR (1<<29) /* Write frame end */ | ||
145 | /* USB Endpoint Interrupt Status Regsiter bit fields */ | ||
146 | #define EPINTR_FIFO_FULL (1<<8) /* fifo full */ | ||
147 | #define EPINTR_FIFO_EMPTY (1<<7) /* fifo empty */ | ||
148 | #define EPINTR_FIFO_ERROR (1<<6) /* fifo error */ | ||
149 | #define EPINTR_FIFO_HIGH (1<<5) /* fifo high */ | ||
150 | #define EPINTR_FIFO_LOW (1<<4) /* fifo low */ | ||
151 | #define EPINTR_MDEVREQ (1<<3) /* multi Device request */ | ||
152 | #define EPINTR_EOT (1<<2) /* fifo end of transfer */ | ||
153 | #define EPINTR_DEVREQ (1<<1) /* Device request */ | ||
154 | #define EPINTR_EOF (1<<0) /* fifo end of frame */ | ||
155 | |||
156 | /* Debug macros */ | ||
157 | #ifdef DEBUG | ||
158 | |||
159 | /* #define DEBUG_REQ */ | ||
160 | /* #define DEBUG_TRX */ | ||
161 | /* #define DEBUG_INIT */ | ||
162 | /* #define DEBUG_EP0 */ | ||
163 | /* #define DEBUG_EPX */ | ||
164 | /* #define DEBUG_IRQ */ | ||
165 | /* #define DEBUG_EPIRQ */ | ||
166 | /* #define DEBUG_DUMP */ | ||
167 | /* #define DEBUG_ERR */ | ||
168 | |||
169 | #ifdef DEBUG_REQ | ||
170 | #define D_REQ(dev, args...) dev_dbg(dev, ## args) | ||
171 | #else | ||
172 | #define D_REQ(dev, args...) do {} while (0) | ||
173 | #endif /* DEBUG_REQ */ | ||
174 | |||
175 | #ifdef DEBUG_TRX | ||
176 | #define D_TRX(dev, args...) dev_dbg(dev, ## args) | ||
177 | #else | ||
178 | #define D_TRX(dev, args...) do {} while (0) | ||
179 | #endif /* DEBUG_TRX */ | ||
180 | |||
181 | #ifdef DEBUG_INIT | ||
182 | #define D_INI(dev, args...) dev_dbg(dev, ## args) | ||
183 | #else | ||
184 | #define D_INI(dev, args...) do {} while (0) | ||
185 | #endif /* DEBUG_INIT */ | ||
186 | |||
187 | #ifdef DEBUG_EP0 | ||
188 | static const char *state_name[] = { | ||
189 | "EP0_IDLE", | ||
190 | "EP0_IN_DATA_PHASE", | ||
191 | "EP0_OUT_DATA_PHASE", | ||
192 | "EP0_CONFIG", | ||
193 | "EP0_STALL" | ||
194 | }; | ||
195 | #define D_EP0(dev, args...) dev_dbg(dev, ## args) | ||
196 | #else | ||
197 | #define D_EP0(dev, args...) do {} while (0) | ||
198 | #endif /* DEBUG_EP0 */ | ||
199 | |||
200 | #ifdef DEBUG_EPX | ||
201 | #define D_EPX(dev, args...) dev_dbg(dev, ## args) | ||
202 | #else | ||
203 | #define D_EPX(dev, args...) do {} while (0) | ||
204 | #endif /* DEBUG_EP0 */ | ||
205 | |||
206 | #ifdef DEBUG_IRQ | ||
207 | static void dump_intr(const char *label, int irqreg, struct device *dev) | ||
208 | { | ||
209 | dev_dbg(dev, "<%s> USB_INTR=[%s%s%s%s%s%s%s%s%s]\n", label, | ||
210 | (irqreg & INTR_WAKEUP) ? " wake" : "", | ||
211 | (irqreg & INTR_MSOF) ? " msof" : "", | ||
212 | (irqreg & INTR_SOF) ? " sof" : "", | ||
213 | (irqreg & INTR_RESUME) ? " resume" : "", | ||
214 | (irqreg & INTR_SUSPEND) ? " suspend" : "", | ||
215 | (irqreg & INTR_RESET_STOP) ? " noreset" : "", | ||
216 | (irqreg & INTR_RESET_START) ? " reset" : "", | ||
217 | (irqreg & INTR_FRAME_MATCH) ? " fmatch" : "", | ||
218 | (irqreg & INTR_CFG_CHG) ? " config" : ""); | ||
219 | } | ||
220 | #else | ||
221 | #define dump_intr(x, y, z) do {} while (0) | ||
222 | #endif /* DEBUG_IRQ */ | ||
223 | |||
224 | #ifdef DEBUG_EPIRQ | ||
225 | static void dump_ep_intr(const char *label, int nr, int irqreg, | ||
226 | struct device *dev) | ||
227 | { | ||
228 | dev_dbg(dev, "<%s> EP%d_INTR=[%s%s%s%s%s%s%s%s%s]\n", label, nr, | ||
229 | (irqreg & EPINTR_FIFO_FULL) ? " full" : "", | ||
230 | (irqreg & EPINTR_FIFO_EMPTY) ? " fempty" : "", | ||
231 | (irqreg & EPINTR_FIFO_ERROR) ? " ferr" : "", | ||
232 | (irqreg & EPINTR_FIFO_HIGH) ? " fhigh" : "", | ||
233 | (irqreg & EPINTR_FIFO_LOW) ? " flow" : "", | ||
234 | (irqreg & EPINTR_MDEVREQ) ? " mreq" : "", | ||
235 | (irqreg & EPINTR_EOF) ? " eof" : "", | ||
236 | (irqreg & EPINTR_DEVREQ) ? " devreq" : "", | ||
237 | (irqreg & EPINTR_EOT) ? " eot" : ""); | ||
238 | } | ||
239 | #else | ||
240 | #define dump_ep_intr(x, y, z, i) do {} while (0) | ||
241 | #endif /* DEBUG_IRQ */ | ||
242 | |||
243 | #ifdef DEBUG_DUMP | ||
244 | static void dump_usb_stat(const char *label, | ||
245 | struct imx_udc_struct *imx_usb) | ||
246 | { | ||
247 | int temp = __raw_readl(imx_usb->base + USB_STAT); | ||
248 | |||
249 | dev_dbg(imx_usb->dev, | ||
250 | "<%s> USB_STAT=[%s%s CFG=%d, INTF=%d, ALTR=%d]\n", label, | ||
251 | (temp & STAT_RST) ? " reset" : "", | ||
252 | (temp & STAT_SUSP) ? " suspend" : "", | ||
253 | (temp & STAT_CFG) >> 5, | ||
254 | (temp & STAT_INTF) >> 3, | ||
255 | (temp & STAT_ALTSET)); | ||
256 | } | ||
257 | |||
258 | static void dump_ep_stat(const char *label, | ||
259 | struct imx_ep_struct *imx_ep) | ||
260 | { | ||
261 | int temp = __raw_readl(imx_ep->imx_usb->base | ||
262 | + USB_EP_INTR(EP_NO(imx_ep))); | ||
263 | |||
264 | dev_dbg(imx_ep->imx_usb->dev, | ||
265 | "<%s> EP%d_INTR=[%s%s%s%s%s%s%s%s%s]\n", | ||
266 | label, EP_NO(imx_ep), | ||
267 | (temp & EPINTR_FIFO_FULL) ? " full" : "", | ||
268 | (temp & EPINTR_FIFO_EMPTY) ? " fempty" : "", | ||
269 | (temp & EPINTR_FIFO_ERROR) ? " ferr" : "", | ||
270 | (temp & EPINTR_FIFO_HIGH) ? " fhigh" : "", | ||
271 | (temp & EPINTR_FIFO_LOW) ? " flow" : "", | ||
272 | (temp & EPINTR_MDEVREQ) ? " mreq" : "", | ||
273 | (temp & EPINTR_EOF) ? " eof" : "", | ||
274 | (temp & EPINTR_DEVREQ) ? " devreq" : "", | ||
275 | (temp & EPINTR_EOT) ? " eot" : ""); | ||
276 | |||
277 | temp = __raw_readl(imx_ep->imx_usb->base | ||
278 | + USB_EP_STAT(EP_NO(imx_ep))); | ||
279 | |||
280 | dev_dbg(imx_ep->imx_usb->dev, | ||
281 | "<%s> EP%d_STAT=[%s%s bcount=%d]\n", | ||
282 | label, EP_NO(imx_ep), | ||
283 | (temp & EPSTAT_SIP) ? " sip" : "", | ||
284 | (temp & EPSTAT_STALL) ? " stall" : "", | ||
285 | (temp & EPSTAT_BCOUNT) >> 16); | ||
286 | |||
287 | temp = __raw_readl(imx_ep->imx_usb->base | ||
288 | + USB_EP_FSTAT(EP_NO(imx_ep))); | ||
289 | |||
290 | dev_dbg(imx_ep->imx_usb->dev, | ||
291 | "<%s> EP%d_FSTAT=[%s%s%s%s%s%s%s]\n", | ||
292 | label, EP_NO(imx_ep), | ||
293 | (temp & FSTAT_ERR) ? " ferr" : "", | ||
294 | (temp & FSTAT_UF) ? " funder" : "", | ||
295 | (temp & FSTAT_OF) ? " fover" : "", | ||
296 | (temp & FSTAT_FR) ? " fready" : "", | ||
297 | (temp & FSTAT_FULL) ? " ffull" : "", | ||
298 | (temp & FSTAT_ALRM) ? " falarm" : "", | ||
299 | (temp & FSTAT_EMPTY) ? " fempty" : ""); | ||
300 | } | ||
301 | |||
302 | static void dump_req(const char *label, struct imx_ep_struct *imx_ep, | ||
303 | struct usb_request *req) | ||
304 | { | ||
305 | int i; | ||
306 | |||
307 | if (!req || !req->buf) { | ||
308 | dev_dbg(imx_ep->imx_usb->dev, | ||
309 | "<%s> req or req buf is free\n", label); | ||
310 | return; | ||
311 | } | ||
312 | |||
313 | if ((!EP_NO(imx_ep) && imx_ep->imx_usb->ep0state | ||
314 | == EP0_IN_DATA_PHASE) | ||
315 | || (EP_NO(imx_ep) && EP_DIR(imx_ep))) { | ||
316 | |||
317 | dev_dbg(imx_ep->imx_usb->dev, | ||
318 | "<%s> request dump <", label); | ||
319 | for (i = 0; i < req->length; i++) | ||
320 | printk("%02x-", *((u8 *)req->buf + i)); | ||
321 | printk(">\n"); | ||
322 | } | ||
323 | } | ||
324 | |||
325 | #else | ||
326 | #define dump_ep_stat(x, y) do {} while (0) | ||
327 | #define dump_usb_stat(x, y) do {} while (0) | ||
328 | #define dump_req(x, y, z) do {} while (0) | ||
329 | #endif /* DEBUG_DUMP */ | ||
330 | |||
331 | #ifdef DEBUG_ERR | ||
332 | #define D_ERR(dev, args...) dev_dbg(dev, ## args) | ||
333 | #else | ||
334 | #define D_ERR(dev, args...) do {} while (0) | ||
335 | #endif | ||
336 | |||
337 | #else | ||
338 | #define D_REQ(dev, args...) do {} while (0) | ||
339 | #define D_TRX(dev, args...) do {} while (0) | ||
340 | #define D_INI(dev, args...) do {} while (0) | ||
341 | #define D_EP0(dev, args...) do {} while (0) | ||
342 | #define D_EPX(dev, args...) do {} while (0) | ||
343 | #define dump_ep_intr(x, y, z, i) do {} while (0) | ||
344 | #define dump_intr(x, y, z) do {} while (0) | ||
345 | #define dump_ep_stat(x, y) do {} while (0) | ||
346 | #define dump_usb_stat(x, y) do {} while (0) | ||
347 | #define dump_req(x, y, z) do {} while (0) | ||
348 | #define D_ERR(dev, args...) do {} while (0) | ||
349 | #endif /* DEBUG */ | ||
350 | |||
351 | #endif /* __LINUX_USB_GADGET_IMX_H */ | ||
diff --git a/drivers/usb/gadget/m66592-udc.c b/drivers/usb/gadget/m66592-udc.c index 46ba9838c3a0..d5f050d30edf 100644 --- a/drivers/usb/gadget/m66592-udc.c +++ b/drivers/usb/gadget/m66592-udc.c | |||
@@ -1584,7 +1584,7 @@ static int __init m66592_probe(struct platform_device *pdev) | |||
1584 | goto clean_up; | 1584 | goto clean_up; |
1585 | } | 1585 | } |
1586 | 1586 | ||
1587 | if (pdev->dev.platform_data == NULL) { | 1587 | if (dev_get_platdata(&pdev->dev) == NULL) { |
1588 | dev_err(&pdev->dev, "no platform data\n"); | 1588 | dev_err(&pdev->dev, "no platform data\n"); |
1589 | ret = -ENODEV; | 1589 | ret = -ENODEV; |
1590 | goto clean_up; | 1590 | goto clean_up; |
@@ -1598,7 +1598,7 @@ static int __init m66592_probe(struct platform_device *pdev) | |||
1598 | goto clean_up; | 1598 | goto clean_up; |
1599 | } | 1599 | } |
1600 | 1600 | ||
1601 | m66592->pdata = pdev->dev.platform_data; | 1601 | m66592->pdata = dev_get_platdata(&pdev->dev); |
1602 | m66592->irq_trigger = ires->flags & IRQF_TRIGGER_MASK; | 1602 | m66592->irq_trigger = ires->flags & IRQF_TRIGGER_MASK; |
1603 | 1603 | ||
1604 | spin_lock_init(&m66592->lock); | 1604 | spin_lock_init(&m66592->lock); |
diff --git a/drivers/usb/gadget/mv_u3d_core.c b/drivers/usb/gadget/mv_u3d_core.c index ec6a2d290398..bbb6e98c4384 100644 --- a/drivers/usb/gadget/mv_u3d_core.c +++ b/drivers/usb/gadget/mv_u3d_core.c | |||
@@ -1109,7 +1109,7 @@ static int mv_u3d_controller_reset(struct mv_u3d *u3d) | |||
1109 | 1109 | ||
1110 | static int mv_u3d_enable(struct mv_u3d *u3d) | 1110 | static int mv_u3d_enable(struct mv_u3d *u3d) |
1111 | { | 1111 | { |
1112 | struct mv_usb_platform_data *pdata = u3d->dev->platform_data; | 1112 | struct mv_usb_platform_data *pdata = dev_get_platdata(u3d->dev); |
1113 | int retval; | 1113 | int retval; |
1114 | 1114 | ||
1115 | if (u3d->active) | 1115 | if (u3d->active) |
@@ -1138,7 +1138,7 @@ static int mv_u3d_enable(struct mv_u3d *u3d) | |||
1138 | 1138 | ||
1139 | static void mv_u3d_disable(struct mv_u3d *u3d) | 1139 | static void mv_u3d_disable(struct mv_u3d *u3d) |
1140 | { | 1140 | { |
1141 | struct mv_usb_platform_data *pdata = u3d->dev->platform_data; | 1141 | struct mv_usb_platform_data *pdata = dev_get_platdata(u3d->dev); |
1142 | if (u3d->clock_gating && u3d->active) { | 1142 | if (u3d->clock_gating && u3d->active) { |
1143 | dev_dbg(u3d->dev, "disable u3d\n"); | 1143 | dev_dbg(u3d->dev, "disable u3d\n"); |
1144 | if (pdata->phy_deinit) | 1144 | if (pdata->phy_deinit) |
@@ -1246,7 +1246,7 @@ static int mv_u3d_start(struct usb_gadget *g, | |||
1246 | struct usb_gadget_driver *driver) | 1246 | struct usb_gadget_driver *driver) |
1247 | { | 1247 | { |
1248 | struct mv_u3d *u3d = container_of(g, struct mv_u3d, gadget); | 1248 | struct mv_u3d *u3d = container_of(g, struct mv_u3d, gadget); |
1249 | struct mv_usb_platform_data *pdata = u3d->dev->platform_data; | 1249 | struct mv_usb_platform_data *pdata = dev_get_platdata(u3d->dev); |
1250 | unsigned long flags; | 1250 | unsigned long flags; |
1251 | 1251 | ||
1252 | if (u3d->driver) | 1252 | if (u3d->driver) |
@@ -1277,7 +1277,7 @@ static int mv_u3d_stop(struct usb_gadget *g, | |||
1277 | struct usb_gadget_driver *driver) | 1277 | struct usb_gadget_driver *driver) |
1278 | { | 1278 | { |
1279 | struct mv_u3d *u3d = container_of(g, struct mv_u3d, gadget); | 1279 | struct mv_u3d *u3d = container_of(g, struct mv_u3d, gadget); |
1280 | struct mv_usb_platform_data *pdata = u3d->dev->platform_data; | 1280 | struct mv_usb_platform_data *pdata = dev_get_platdata(u3d->dev); |
1281 | unsigned long flags; | 1281 | unsigned long flags; |
1282 | 1282 | ||
1283 | u3d->vbus_valid_detect = 0; | 1283 | u3d->vbus_valid_detect = 0; |
@@ -1794,12 +1794,12 @@ static int mv_u3d_remove(struct platform_device *dev) | |||
1794 | static int mv_u3d_probe(struct platform_device *dev) | 1794 | static int mv_u3d_probe(struct platform_device *dev) |
1795 | { | 1795 | { |
1796 | struct mv_u3d *u3d = NULL; | 1796 | struct mv_u3d *u3d = NULL; |
1797 | struct mv_usb_platform_data *pdata = dev->dev.platform_data; | 1797 | struct mv_usb_platform_data *pdata = dev_get_platdata(&dev->dev); |
1798 | int retval = 0; | 1798 | int retval = 0; |
1799 | struct resource *r; | 1799 | struct resource *r; |
1800 | size_t size; | 1800 | size_t size; |
1801 | 1801 | ||
1802 | if (!dev->dev.platform_data) { | 1802 | if (!dev_get_platdata(&dev->dev)) { |
1803 | dev_err(&dev->dev, "missing platform_data\n"); | 1803 | dev_err(&dev->dev, "missing platform_data\n"); |
1804 | retval = -ENODEV; | 1804 | retval = -ENODEV; |
1805 | goto err_pdata; | 1805 | goto err_pdata; |
diff --git a/drivers/usb/gadget/mv_udc_core.c b/drivers/usb/gadget/mv_udc_core.c index c2a57023e467..104cdbea635a 100644 --- a/drivers/usb/gadget/mv_udc_core.c +++ b/drivers/usb/gadget/mv_udc_core.c | |||
@@ -2100,7 +2100,7 @@ static int mv_udc_remove(struct platform_device *pdev) | |||
2100 | 2100 | ||
2101 | static int mv_udc_probe(struct platform_device *pdev) | 2101 | static int mv_udc_probe(struct platform_device *pdev) |
2102 | { | 2102 | { |
2103 | struct mv_usb_platform_data *pdata = pdev->dev.platform_data; | 2103 | struct mv_usb_platform_data *pdata = dev_get_platdata(&pdev->dev); |
2104 | struct mv_udc *udc; | 2104 | struct mv_udc *udc; |
2105 | int retval = 0; | 2105 | int retval = 0; |
2106 | struct resource *r; | 2106 | struct resource *r; |
@@ -2118,7 +2118,7 @@ static int mv_udc_probe(struct platform_device *pdev) | |||
2118 | } | 2118 | } |
2119 | 2119 | ||
2120 | udc->done = &release_done; | 2120 | udc->done = &release_done; |
2121 | udc->pdata = pdev->dev.platform_data; | 2121 | udc->pdata = dev_get_platdata(&pdev->dev); |
2122 | spin_lock_init(&udc->lock); | 2122 | spin_lock_init(&udc->lock); |
2123 | 2123 | ||
2124 | udc->dev = pdev; | 2124 | udc->dev = pdev; |
diff --git a/drivers/usb/gadget/omap_udc.c b/drivers/usb/gadget/omap_udc.c index b8ed74a823cb..83957cc225d9 100644 --- a/drivers/usb/gadget/omap_udc.c +++ b/drivers/usb/gadget/omap_udc.c | |||
@@ -2734,7 +2734,7 @@ static int omap_udc_probe(struct platform_device *pdev) | |||
2734 | int hmc; | 2734 | int hmc; |
2735 | struct usb_phy *xceiv = NULL; | 2735 | struct usb_phy *xceiv = NULL; |
2736 | const char *type = NULL; | 2736 | const char *type = NULL; |
2737 | struct omap_usb_config *config = pdev->dev.platform_data; | 2737 | struct omap_usb_config *config = dev_get_platdata(&pdev->dev); |
2738 | struct clk *dc_clk = NULL; | 2738 | struct clk *dc_clk = NULL; |
2739 | struct clk *hhc_clk = NULL; | 2739 | struct clk *hhc_clk = NULL; |
2740 | 2740 | ||
diff --git a/drivers/usb/gadget/pxa25x_udc.c b/drivers/usb/gadget/pxa25x_udc.c index 95c531d5aa4f..cc9207473dbc 100644 --- a/drivers/usb/gadget/pxa25x_udc.c +++ b/drivers/usb/gadget/pxa25x_udc.c | |||
@@ -2117,7 +2117,7 @@ static int __init pxa25x_udc_probe(struct platform_device *pdev) | |||
2117 | 2117 | ||
2118 | /* other non-static parts of init */ | 2118 | /* other non-static parts of init */ |
2119 | dev->dev = &pdev->dev; | 2119 | dev->dev = &pdev->dev; |
2120 | dev->mach = pdev->dev.platform_data; | 2120 | dev->mach = dev_get_platdata(&pdev->dev); |
2121 | 2121 | ||
2122 | dev->transceiver = usb_get_phy(USB_PHY_TYPE_USB2); | 2122 | dev->transceiver = usb_get_phy(USB_PHY_TYPE_USB2); |
2123 | 2123 | ||
diff --git a/drivers/usb/gadget/pxa27x_udc.c b/drivers/usb/gadget/pxa27x_udc.c index 41cea9566ac8..3c97da7760da 100644 --- a/drivers/usb/gadget/pxa27x_udc.c +++ b/drivers/usb/gadget/pxa27x_udc.c | |||
@@ -2422,7 +2422,7 @@ static int pxa_udc_probe(struct platform_device *pdev) | |||
2422 | return udc->irq; | 2422 | return udc->irq; |
2423 | 2423 | ||
2424 | udc->dev = &pdev->dev; | 2424 | udc->dev = &pdev->dev; |
2425 | udc->mach = pdev->dev.platform_data; | 2425 | udc->mach = dev_get_platdata(&pdev->dev); |
2426 | udc->transceiver = usb_get_phy(USB_PHY_TYPE_USB2); | 2426 | udc->transceiver = usb_get_phy(USB_PHY_TYPE_USB2); |
2427 | 2427 | ||
2428 | gpio = udc->mach->gpio_pullup; | 2428 | gpio = udc->mach->gpio_pullup; |
diff --git a/drivers/usb/gadget/r8a66597-udc.c b/drivers/usb/gadget/r8a66597-udc.c index c6af649f3240..68be48d33404 100644 --- a/drivers/usb/gadget/r8a66597-udc.c +++ b/drivers/usb/gadget/r8a66597-udc.c | |||
@@ -1910,7 +1910,7 @@ static int __init r8a66597_probe(struct platform_device *pdev) | |||
1910 | 1910 | ||
1911 | spin_lock_init(&r8a66597->lock); | 1911 | spin_lock_init(&r8a66597->lock); |
1912 | platform_set_drvdata(pdev, r8a66597); | 1912 | platform_set_drvdata(pdev, r8a66597); |
1913 | r8a66597->pdata = pdev->dev.platform_data; | 1913 | r8a66597->pdata = dev_get_platdata(&pdev->dev); |
1914 | r8a66597->irq_sense_low = irq_trigger == IRQF_TRIGGER_LOW; | 1914 | r8a66597->irq_sense_low = irq_trigger == IRQF_TRIGGER_LOW; |
1915 | 1915 | ||
1916 | r8a66597->gadget.ops = &r8a66597_gadget_ops; | 1916 | r8a66597->gadget.ops = &r8a66597_gadget_ops; |
diff --git a/drivers/usb/gadget/rndis.c b/drivers/usb/gadget/rndis.c index 3e3ea7203030..9575085ded81 100644 --- a/drivers/usb/gadget/rndis.c +++ b/drivers/usb/gadget/rndis.c | |||
@@ -1142,7 +1142,7 @@ static struct proc_dir_entry *rndis_connect_state [RNDIS_MAX_CONFIGS]; | |||
1142 | #endif /* CONFIG_USB_GADGET_DEBUG_FILES */ | 1142 | #endif /* CONFIG_USB_GADGET_DEBUG_FILES */ |
1143 | 1143 | ||
1144 | 1144 | ||
1145 | int rndis_init(void) | 1145 | static int rndis_init(void) |
1146 | { | 1146 | { |
1147 | u8 i; | 1147 | u8 i; |
1148 | 1148 | ||
@@ -1176,7 +1176,7 @@ int rndis_init(void) | |||
1176 | } | 1176 | } |
1177 | module_init(rndis_init); | 1177 | module_init(rndis_init); |
1178 | 1178 | ||
1179 | void rndis_exit(void) | 1179 | static void rndis_exit(void) |
1180 | { | 1180 | { |
1181 | #ifdef CONFIG_USB_GADGET_DEBUG_FILES | 1181 | #ifdef CONFIG_USB_GADGET_DEBUG_FILES |
1182 | u8 i; | 1182 | u8 i; |
diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c index af22f24046b2..d69b36a99dbc 100644 --- a/drivers/usb/gadget/s3c-hsotg.c +++ b/drivers/usb/gadget/s3c-hsotg.c | |||
@@ -29,6 +29,7 @@ | |||
29 | #include <linux/slab.h> | 29 | #include <linux/slab.h> |
30 | #include <linux/clk.h> | 30 | #include <linux/clk.h> |
31 | #include <linux/regulator/consumer.h> | 31 | #include <linux/regulator/consumer.h> |
32 | #include <linux/of_platform.h> | ||
32 | 33 | ||
33 | #include <linux/usb/ch9.h> | 34 | #include <linux/usb/ch9.h> |
34 | #include <linux/usb/gadget.h> | 35 | #include <linux/usb/gadget.h> |
@@ -3450,7 +3451,7 @@ static void s3c_hsotg_delete_debug(struct s3c_hsotg *hsotg) | |||
3450 | 3451 | ||
3451 | static int s3c_hsotg_probe(struct platform_device *pdev) | 3452 | static int s3c_hsotg_probe(struct platform_device *pdev) |
3452 | { | 3453 | { |
3453 | struct s3c_hsotg_plat *plat = pdev->dev.platform_data; | 3454 | struct s3c_hsotg_plat *plat = dev_get_platdata(&pdev->dev); |
3454 | struct usb_phy *phy; | 3455 | struct usb_phy *phy; |
3455 | struct device *dev = &pdev->dev; | 3456 | struct device *dev = &pdev->dev; |
3456 | struct s3c_hsotg_ep *eps; | 3457 | struct s3c_hsotg_ep *eps; |
@@ -3469,7 +3470,7 @@ static int s3c_hsotg_probe(struct platform_device *pdev) | |||
3469 | phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2); | 3470 | phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2); |
3470 | if (IS_ERR(phy)) { | 3471 | if (IS_ERR(phy)) { |
3471 | /* Fallback for pdata */ | 3472 | /* Fallback for pdata */ |
3472 | plat = pdev->dev.platform_data; | 3473 | plat = dev_get_platdata(&pdev->dev); |
3473 | if (!plat) { | 3474 | if (!plat) { |
3474 | dev_err(&pdev->dev, "no platform data or transceiver defined\n"); | 3475 | dev_err(&pdev->dev, "no platform data or transceiver defined\n"); |
3475 | return -EPROBE_DEFER; | 3476 | return -EPROBE_DEFER; |
@@ -3648,10 +3649,19 @@ static int s3c_hsotg_remove(struct platform_device *pdev) | |||
3648 | #define s3c_hsotg_resume NULL | 3649 | #define s3c_hsotg_resume NULL |
3649 | #endif | 3650 | #endif |
3650 | 3651 | ||
3652 | #ifdef CONFIG_OF | ||
3653 | static const struct of_device_id s3c_hsotg_of_ids[] = { | ||
3654 | { .compatible = "samsung,s3c6400-hsotg", }, | ||
3655 | { /* sentinel */ } | ||
3656 | }; | ||
3657 | MODULE_DEVICE_TABLE(of, s3c_hsotg_of_ids); | ||
3658 | #endif | ||
3659 | |||
3651 | static struct platform_driver s3c_hsotg_driver = { | 3660 | static struct platform_driver s3c_hsotg_driver = { |
3652 | .driver = { | 3661 | .driver = { |
3653 | .name = "s3c-hsotg", | 3662 | .name = "s3c-hsotg", |
3654 | .owner = THIS_MODULE, | 3663 | .owner = THIS_MODULE, |
3664 | .of_match_table = of_match_ptr(s3c_hsotg_of_ids), | ||
3655 | }, | 3665 | }, |
3656 | .probe = s3c_hsotg_probe, | 3666 | .probe = s3c_hsotg_probe, |
3657 | .remove = s3c_hsotg_remove, | 3667 | .remove = s3c_hsotg_remove, |
diff --git a/drivers/usb/gadget/s3c-hsudc.c b/drivers/usb/gadget/s3c-hsudc.c index b1f0771fbd3d..1a1a41498db2 100644 --- a/drivers/usb/gadget/s3c-hsudc.c +++ b/drivers/usb/gadget/s3c-hsudc.c | |||
@@ -1262,7 +1262,7 @@ static int s3c_hsudc_probe(struct platform_device *pdev) | |||
1262 | struct device *dev = &pdev->dev; | 1262 | struct device *dev = &pdev->dev; |
1263 | struct resource *res; | 1263 | struct resource *res; |
1264 | struct s3c_hsudc *hsudc; | 1264 | struct s3c_hsudc *hsudc; |
1265 | struct s3c24xx_hsudc_platdata *pd = pdev->dev.platform_data; | 1265 | struct s3c24xx_hsudc_platdata *pd = dev_get_platdata(&pdev->dev); |
1266 | int ret, i; | 1266 | int ret, i; |
1267 | 1267 | ||
1268 | hsudc = devm_kzalloc(&pdev->dev, sizeof(struct s3c_hsudc) + | 1268 | hsudc = devm_kzalloc(&pdev->dev, sizeof(struct s3c_hsudc) + |
@@ -1275,7 +1275,7 @@ static int s3c_hsudc_probe(struct platform_device *pdev) | |||
1275 | 1275 | ||
1276 | platform_set_drvdata(pdev, dev); | 1276 | platform_set_drvdata(pdev, dev); |
1277 | hsudc->dev = dev; | 1277 | hsudc->dev = dev; |
1278 | hsudc->pd = pdev->dev.platform_data; | 1278 | hsudc->pd = dev_get_platdata(&pdev->dev); |
1279 | 1279 | ||
1280 | hsudc->transceiver = usb_get_phy(USB_PHY_TYPE_USB2); | 1280 | hsudc->transceiver = usb_get_phy(USB_PHY_TYPE_USB2); |
1281 | 1281 | ||
diff --git a/drivers/usb/gadget/s3c2410_udc.c b/drivers/usb/gadget/s3c2410_udc.c index 09c4f70c93c4..c72d810e6b36 100644 --- a/drivers/usb/gadget/s3c2410_udc.c +++ b/drivers/usb/gadget/s3c2410_udc.c | |||
@@ -1809,7 +1809,7 @@ static int s3c2410_udc_probe(struct platform_device *pdev) | |||
1809 | } | 1809 | } |
1810 | 1810 | ||
1811 | spin_lock_init(&udc->lock); | 1811 | spin_lock_init(&udc->lock); |
1812 | udc_info = pdev->dev.platform_data; | 1812 | udc_info = dev_get_platdata(&pdev->dev); |
1813 | 1813 | ||
1814 | rsrc_start = S3C2410_PA_USBDEV; | 1814 | rsrc_start = S3C2410_PA_USBDEV; |
1815 | rsrc_len = S3C24XX_SZ_USBDEV; | 1815 | rsrc_len = S3C24XX_SZ_USBDEV; |
diff --git a/drivers/usb/gadget/u_uac1.c b/drivers/usb/gadget/u_uac1.c index c7d460f43390..7a55fea43430 100644 --- a/drivers/usb/gadget/u_uac1.c +++ b/drivers/usb/gadget/u_uac1.c | |||
@@ -191,7 +191,7 @@ try_again: | |||
191 | frames = bytes_to_frames(runtime, count); | 191 | frames = bytes_to_frames(runtime, count); |
192 | old_fs = get_fs(); | 192 | old_fs = get_fs(); |
193 | set_fs(KERNEL_DS); | 193 | set_fs(KERNEL_DS); |
194 | result = snd_pcm_lib_write(snd->substream, buf, frames); | 194 | result = snd_pcm_lib_write(snd->substream, (void __user *)buf, frames); |
195 | if (result != frames) { | 195 | if (result != frames) { |
196 | ERROR(card, "Playback error: %d\n", (int)result); | 196 | ERROR(card, "Playback error: %d\n", (int)result); |
197 | set_fs(old_fs); | 197 | set_fs(old_fs); |
diff --git a/drivers/usb/gadget/udc-core.c b/drivers/usb/gadget/udc-core.c index 13e25f80fc20..546bfda3059a 100644 --- a/drivers/usb/gadget/udc-core.c +++ b/drivers/usb/gadget/udc-core.c | |||
@@ -23,6 +23,7 @@ | |||
23 | #include <linux/list.h> | 23 | #include <linux/list.h> |
24 | #include <linux/err.h> | 24 | #include <linux/err.h> |
25 | #include <linux/dma-mapping.h> | 25 | #include <linux/dma-mapping.h> |
26 | #include <linux/workqueue.h> | ||
26 | 27 | ||
27 | #include <linux/usb/ch9.h> | 28 | #include <linux/usb/ch9.h> |
28 | #include <linux/usb/gadget.h> | 29 | #include <linux/usb/gadget.h> |
@@ -105,11 +106,18 @@ EXPORT_SYMBOL_GPL(usb_gadget_unmap_request); | |||
105 | 106 | ||
106 | /* ------------------------------------------------------------------------- */ | 107 | /* ------------------------------------------------------------------------- */ |
107 | 108 | ||
109 | static void usb_gadget_state_work(struct work_struct *work) | ||
110 | { | ||
111 | struct usb_gadget *gadget = work_to_gadget(work); | ||
112 | |||
113 | sysfs_notify(&gadget->dev.kobj, NULL, "state"); | ||
114 | } | ||
115 | |||
108 | void usb_gadget_set_state(struct usb_gadget *gadget, | 116 | void usb_gadget_set_state(struct usb_gadget *gadget, |
109 | enum usb_device_state state) | 117 | enum usb_device_state state) |
110 | { | 118 | { |
111 | gadget->state = state; | 119 | gadget->state = state; |
112 | sysfs_notify(&gadget->dev.kobj, NULL, "state"); | 120 | schedule_work(&gadget->work); |
113 | } | 121 | } |
114 | EXPORT_SYMBOL_GPL(usb_gadget_set_state); | 122 | EXPORT_SYMBOL_GPL(usb_gadget_set_state); |
115 | 123 | ||
@@ -196,6 +204,7 @@ int usb_add_gadget_udc_release(struct device *parent, struct usb_gadget *gadget, | |||
196 | goto err1; | 204 | goto err1; |
197 | 205 | ||
198 | dev_set_name(&gadget->dev, "gadget"); | 206 | dev_set_name(&gadget->dev, "gadget"); |
207 | INIT_WORK(&gadget->work, usb_gadget_state_work); | ||
199 | gadget->dev.parent = parent; | 208 | gadget->dev.parent = parent; |
200 | 209 | ||
201 | #ifdef CONFIG_HAS_DMA | 210 | #ifdef CONFIG_HAS_DMA |
@@ -315,6 +324,7 @@ found: | |||
315 | usb_gadget_remove_driver(udc); | 324 | usb_gadget_remove_driver(udc); |
316 | 325 | ||
317 | kobject_uevent(&udc->dev.kobj, KOBJ_REMOVE); | 326 | kobject_uevent(&udc->dev.kobj, KOBJ_REMOVE); |
327 | flush_work(&gadget->work); | ||
318 | device_unregister(&udc->dev); | 328 | device_unregister(&udc->dev); |
319 | device_unregister(&gadget->dev); | 329 | device_unregister(&gadget->dev); |
320 | } | 330 | } |
diff --git a/drivers/usb/gadget/uvc_queue.c b/drivers/usb/gadget/uvc_queue.c index e6170478ea9f..0bb5d50075de 100644 --- a/drivers/usb/gadget/uvc_queue.c +++ b/drivers/usb/gadget/uvc_queue.c | |||
@@ -193,12 +193,16 @@ static int uvc_queue_buffer(struct uvc_video_queue *queue, | |||
193 | 193 | ||
194 | mutex_lock(&queue->mutex); | 194 | mutex_lock(&queue->mutex); |
195 | ret = vb2_qbuf(&queue->queue, buf); | 195 | ret = vb2_qbuf(&queue->queue, buf); |
196 | if (ret < 0) | ||
197 | goto done; | ||
198 | |||
196 | spin_lock_irqsave(&queue->irqlock, flags); | 199 | spin_lock_irqsave(&queue->irqlock, flags); |
197 | ret = (queue->flags & UVC_QUEUE_PAUSED) != 0; | 200 | ret = (queue->flags & UVC_QUEUE_PAUSED) != 0; |
198 | queue->flags &= ~UVC_QUEUE_PAUSED; | 201 | queue->flags &= ~UVC_QUEUE_PAUSED; |
199 | spin_unlock_irqrestore(&queue->irqlock, flags); | 202 | spin_unlock_irqrestore(&queue->irqlock, flags); |
200 | mutex_unlock(&queue->mutex); | ||
201 | 203 | ||
204 | done: | ||
205 | mutex_unlock(&queue->mutex); | ||
202 | return ret; | 206 | return ret; |
203 | } | 207 | } |
204 | 208 | ||
diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig index 0947aac857a2..e3ea970fe424 100644 --- a/drivers/usb/host/Kconfig +++ b/drivers/usb/host/Kconfig | |||
@@ -142,13 +142,11 @@ config USB_EHCI_MXC | |||
142 | config USB_EHCI_HCD_OMAP | 142 | config USB_EHCI_HCD_OMAP |
143 | tristate "EHCI support for OMAP3 and later chips" | 143 | tristate "EHCI support for OMAP3 and later chips" |
144 | depends on ARCH_OMAP | 144 | depends on ARCH_OMAP |
145 | select NOP_USB_XCEIV | ||
145 | default y | 146 | default y |
146 | ---help--- | 147 | ---help--- |
147 | Enables support for the on-chip EHCI controller on | 148 | Enables support for the on-chip EHCI controller on |
148 | OMAP3 and later chips. | 149 | OMAP3 and later chips. |
149 | If your system uses a PHY on the USB port, you will need to | ||
150 | enable USB_PHY and the appropriate PHY driver as well. Most | ||
151 | boards need the NOP_USB_XCEIV PHY driver. | ||
152 | 150 | ||
153 | config USB_EHCI_HCD_ORION | 151 | config USB_EHCI_HCD_ORION |
154 | tristate "Support for Marvell EBU on-chip EHCI USB controller" | 152 | tristate "Support for Marvell EBU on-chip EHCI USB controller" |
@@ -180,7 +178,6 @@ config USB_EHCI_HCD_AT91 | |||
180 | config USB_EHCI_MSM | 178 | config USB_EHCI_MSM |
181 | tristate "Support for Qualcomm QSD/MSM on-chip EHCI USB controller" | 179 | tristate "Support for Qualcomm QSD/MSM on-chip EHCI USB controller" |
182 | depends on ARCH_MSM | 180 | depends on ARCH_MSM |
183 | depends on USB_PHY | ||
184 | select USB_EHCI_ROOT_HUB_TT | 181 | select USB_EHCI_ROOT_HUB_TT |
185 | select USB_MSM_OTG | 182 | select USB_MSM_OTG |
186 | ---help--- | 183 | ---help--- |
diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c index d0d4cc151e71..f8b215fa0d93 100644 --- a/drivers/usb/host/ehci-hub.c +++ b/drivers/usb/host/ehci-hub.c | |||
@@ -183,7 +183,7 @@ static void ehci_adjust_port_wakeup_flags(struct ehci_hcd *ehci, | |||
183 | spin_lock_irq(&ehci->lock); | 183 | spin_lock_irq(&ehci->lock); |
184 | 184 | ||
185 | /* clear phy low-power mode before changing wakeup flags */ | 185 | /* clear phy low-power mode before changing wakeup flags */ |
186 | if (ehci->has_hostpc) { | 186 | if (ehci->has_tdi_phy_lpm) { |
187 | port = HCS_N_PORTS(ehci->hcs_params); | 187 | port = HCS_N_PORTS(ehci->hcs_params); |
188 | while (port--) { | 188 | while (port--) { |
189 | u32 __iomem *hostpc_reg = &ehci->regs->hostpc[port]; | 189 | u32 __iomem *hostpc_reg = &ehci->regs->hostpc[port]; |
@@ -217,7 +217,7 @@ static void ehci_adjust_port_wakeup_flags(struct ehci_hcd *ehci, | |||
217 | } | 217 | } |
218 | 218 | ||
219 | /* enter phy low-power mode again */ | 219 | /* enter phy low-power mode again */ |
220 | if (ehci->has_hostpc) { | 220 | if (ehci->has_tdi_phy_lpm) { |
221 | port = HCS_N_PORTS(ehci->hcs_params); | 221 | port = HCS_N_PORTS(ehci->hcs_params); |
222 | while (port--) { | 222 | while (port--) { |
223 | u32 __iomem *hostpc_reg = &ehci->regs->hostpc[port]; | 223 | u32 __iomem *hostpc_reg = &ehci->regs->hostpc[port]; |
@@ -309,7 +309,7 @@ static int ehci_bus_suspend (struct usb_hcd *hcd) | |||
309 | } | 309 | } |
310 | } | 310 | } |
311 | 311 | ||
312 | if (changed && ehci->has_hostpc) { | 312 | if (changed && ehci->has_tdi_phy_lpm) { |
313 | spin_unlock_irq(&ehci->lock); | 313 | spin_unlock_irq(&ehci->lock); |
314 | msleep(5); /* 5 ms for HCD to enter low-power mode */ | 314 | msleep(5); /* 5 ms for HCD to enter low-power mode */ |
315 | spin_lock_irq(&ehci->lock); | 315 | spin_lock_irq(&ehci->lock); |
@@ -436,7 +436,7 @@ static int ehci_bus_resume (struct usb_hcd *hcd) | |||
436 | goto shutdown; | 436 | goto shutdown; |
437 | 437 | ||
438 | /* clear phy low-power mode before resume */ | 438 | /* clear phy low-power mode before resume */ |
439 | if (ehci->bus_suspended && ehci->has_hostpc) { | 439 | if (ehci->bus_suspended && ehci->has_tdi_phy_lpm) { |
440 | i = HCS_N_PORTS(ehci->hcs_params); | 440 | i = HCS_N_PORTS(ehci->hcs_params); |
441 | while (i--) { | 441 | while (i--) { |
442 | if (test_bit(i, &ehci->bus_suspended)) { | 442 | if (test_bit(i, &ehci->bus_suspended)) { |
@@ -925,7 +925,7 @@ static int ehci_hub_control ( | |||
925 | goto error; | 925 | goto error; |
926 | 926 | ||
927 | /* clear phy low-power mode before resume */ | 927 | /* clear phy low-power mode before resume */ |
928 | if (ehci->has_hostpc) { | 928 | if (ehci->has_tdi_phy_lpm) { |
929 | temp1 = ehci_readl(ehci, hostpc_reg); | 929 | temp1 = ehci_readl(ehci, hostpc_reg); |
930 | ehci_writel(ehci, temp1 & ~HOSTPC_PHCD, | 930 | ehci_writel(ehci, temp1 & ~HOSTPC_PHCD, |
931 | hostpc_reg); | 931 | hostpc_reg); |
@@ -1162,12 +1162,12 @@ static int ehci_hub_control ( | |||
1162 | 1162 | ||
1163 | /* After above check the port must be connected. | 1163 | /* After above check the port must be connected. |
1164 | * Set appropriate bit thus could put phy into low power | 1164 | * Set appropriate bit thus could put phy into low power |
1165 | * mode if we have hostpc feature | 1165 | * mode if we have tdi_phy_lpm feature |
1166 | */ | 1166 | */ |
1167 | temp &= ~PORT_WKCONN_E; | 1167 | temp &= ~PORT_WKCONN_E; |
1168 | temp |= PORT_WKDISC_E | PORT_WKOC_E; | 1168 | temp |= PORT_WKDISC_E | PORT_WKOC_E; |
1169 | ehci_writel(ehci, temp | PORT_SUSPEND, status_reg); | 1169 | ehci_writel(ehci, temp | PORT_SUSPEND, status_reg); |
1170 | if (ehci->has_hostpc) { | 1170 | if (ehci->has_tdi_phy_lpm) { |
1171 | spin_unlock_irqrestore(&ehci->lock, flags); | 1171 | spin_unlock_irqrestore(&ehci->lock, flags); |
1172 | msleep(5);/* 5ms for HCD enter low pwr mode */ | 1172 | msleep(5);/* 5ms for HCD enter low pwr mode */ |
1173 | spin_lock_irqsave(&ehci->lock, flags); | 1173 | spin_lock_irqsave(&ehci->lock, flags); |
diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c index 5cd33cf783da..78fa76da3324 100644 --- a/drivers/usb/host/ehci-tegra.c +++ b/drivers/usb/host/ehci-tegra.c | |||
@@ -25,9 +25,9 @@ | |||
25 | #include <linux/irq.h> | 25 | #include <linux/irq.h> |
26 | #include <linux/module.h> | 26 | #include <linux/module.h> |
27 | #include <linux/of.h> | 27 | #include <linux/of.h> |
28 | #include <linux/of_device.h> | ||
28 | #include <linux/of_gpio.h> | 29 | #include <linux/of_gpio.h> |
29 | #include <linux/platform_device.h> | 30 | #include <linux/platform_device.h> |
30 | #include <linux/platform_data/tegra_usb.h> | ||
31 | #include <linux/pm_runtime.h> | 31 | #include <linux/pm_runtime.h> |
32 | #include <linux/slab.h> | 32 | #include <linux/slab.h> |
33 | #include <linux/usb/ehci_def.h> | 33 | #include <linux/usb/ehci_def.h> |
@@ -51,6 +51,10 @@ | |||
51 | 51 | ||
52 | static struct hc_driver __read_mostly tegra_ehci_hc_driver; | 52 | static struct hc_driver __read_mostly tegra_ehci_hc_driver; |
53 | 53 | ||
54 | struct tegra_ehci_soc_config { | ||
55 | bool has_hostpc; | ||
56 | }; | ||
57 | |||
54 | static int (*orig_hub_control)(struct usb_hcd *hcd, | 58 | static int (*orig_hub_control)(struct usb_hcd *hcd, |
55 | u16 typeReq, u16 wValue, u16 wIndex, | 59 | u16 typeReq, u16 wValue, u16 wIndex, |
56 | char *buf, u16 wLength); | 60 | char *buf, u16 wLength); |
@@ -58,7 +62,6 @@ static int (*orig_hub_control)(struct usb_hcd *hcd, | |||
58 | struct tegra_ehci_hcd { | 62 | struct tegra_ehci_hcd { |
59 | struct tegra_usb_phy *phy; | 63 | struct tegra_usb_phy *phy; |
60 | struct clk *clk; | 64 | struct clk *clk; |
61 | struct usb_phy *transceiver; | ||
62 | int port_resuming; | 65 | int port_resuming; |
63 | bool needs_double_reset; | 66 | bool needs_double_reset; |
64 | enum tegra_usb_phy_port_speed port_speed; | 67 | enum tegra_usb_phy_port_speed port_speed; |
@@ -322,50 +325,38 @@ static void tegra_ehci_unmap_urb_for_dma(struct usb_hcd *hcd, struct urb *urb) | |||
322 | free_dma_aligned_buffer(urb); | 325 | free_dma_aligned_buffer(urb); |
323 | } | 326 | } |
324 | 327 | ||
325 | static int setup_vbus_gpio(struct platform_device *pdev, | 328 | static const struct tegra_ehci_soc_config tegra30_soc_config = { |
326 | struct tegra_ehci_platform_data *pdata) | 329 | .has_hostpc = true, |
327 | { | 330 | }; |
328 | int err = 0; | ||
329 | int gpio; | ||
330 | |||
331 | gpio = pdata->vbus_gpio; | ||
332 | if (!gpio_is_valid(gpio)) | ||
333 | gpio = of_get_named_gpio(pdev->dev.of_node, | ||
334 | "nvidia,vbus-gpio", 0); | ||
335 | if (!gpio_is_valid(gpio)) | ||
336 | return 0; | ||
337 | 331 | ||
338 | err = gpio_request(gpio, "vbus_gpio"); | 332 | static const struct tegra_ehci_soc_config tegra20_soc_config = { |
339 | if (err) { | 333 | .has_hostpc = false, |
340 | dev_err(&pdev->dev, "can't request vbus gpio %d", gpio); | 334 | }; |
341 | return err; | ||
342 | } | ||
343 | err = gpio_direction_output(gpio, 1); | ||
344 | if (err) { | ||
345 | dev_err(&pdev->dev, "can't enable vbus\n"); | ||
346 | return err; | ||
347 | } | ||
348 | 335 | ||
349 | return err; | 336 | static struct of_device_id tegra_ehci_of_match[] = { |
350 | } | 337 | { .compatible = "nvidia,tegra30-ehci", .data = &tegra30_soc_config }, |
338 | { .compatible = "nvidia,tegra20-ehci", .data = &tegra20_soc_config }, | ||
339 | { }, | ||
340 | }; | ||
351 | 341 | ||
352 | static int tegra_ehci_probe(struct platform_device *pdev) | 342 | static int tegra_ehci_probe(struct platform_device *pdev) |
353 | { | 343 | { |
344 | const struct of_device_id *match; | ||
345 | const struct tegra_ehci_soc_config *soc_config; | ||
354 | struct resource *res; | 346 | struct resource *res; |
355 | struct usb_hcd *hcd; | 347 | struct usb_hcd *hcd; |
356 | struct ehci_hcd *ehci; | 348 | struct ehci_hcd *ehci; |
357 | struct tegra_ehci_hcd *tegra; | 349 | struct tegra_ehci_hcd *tegra; |
358 | struct tegra_ehci_platform_data *pdata; | ||
359 | int err = 0; | 350 | int err = 0; |
360 | int irq; | 351 | int irq; |
361 | struct device_node *np_phy; | ||
362 | struct usb_phy *u_phy; | 352 | struct usb_phy *u_phy; |
363 | 353 | ||
364 | pdata = dev_get_platdata(&pdev->dev); | 354 | match = of_match_device(tegra_ehci_of_match, &pdev->dev); |
365 | if (!pdata) { | 355 | if (!match) { |
366 | dev_err(&pdev->dev, "Platform data missing\n"); | 356 | dev_err(&pdev->dev, "Error: No device match found\n"); |
367 | return -EINVAL; | 357 | return -ENODEV; |
368 | } | 358 | } |
359 | soc_config = match->data; | ||
369 | 360 | ||
370 | /* Right now device-tree probed devices don't get dma_mask set. | 361 | /* Right now device-tree probed devices don't get dma_mask set. |
371 | * Since shared usb code relies on it, set it here for now. | 362 | * Since shared usb code relies on it, set it here for now. |
@@ -376,14 +367,11 @@ static int tegra_ehci_probe(struct platform_device *pdev) | |||
376 | if (!pdev->dev.coherent_dma_mask) | 367 | if (!pdev->dev.coherent_dma_mask) |
377 | pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32); | 368 | pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32); |
378 | 369 | ||
379 | setup_vbus_gpio(pdev, pdata); | ||
380 | |||
381 | hcd = usb_create_hcd(&tegra_ehci_hc_driver, &pdev->dev, | 370 | hcd = usb_create_hcd(&tegra_ehci_hc_driver, &pdev->dev, |
382 | dev_name(&pdev->dev)); | 371 | dev_name(&pdev->dev)); |
383 | if (!hcd) { | 372 | if (!hcd) { |
384 | dev_err(&pdev->dev, "Unable to create HCD\n"); | 373 | dev_err(&pdev->dev, "Unable to create HCD\n"); |
385 | err = -ENOMEM; | 374 | return -ENOMEM; |
386 | goto cleanup_vbus_gpio; | ||
387 | } | 375 | } |
388 | platform_set_drvdata(pdev, hcd); | 376 | platform_set_drvdata(pdev, hcd); |
389 | ehci = hcd_to_ehci(hcd); | 377 | ehci = hcd_to_ehci(hcd); |
@@ -406,13 +394,7 @@ static int tegra_ehci_probe(struct platform_device *pdev) | |||
406 | udelay(1); | 394 | udelay(1); |
407 | tegra_periph_reset_deassert(tegra->clk); | 395 | tegra_periph_reset_deassert(tegra->clk); |
408 | 396 | ||
409 | np_phy = of_parse_phandle(pdev->dev.of_node, "nvidia,phy", 0); | 397 | u_phy = devm_usb_get_phy_by_phandle(&pdev->dev, "nvidia,phy", 0); |
410 | if (!np_phy) { | ||
411 | err = -ENODEV; | ||
412 | goto cleanup_clk_en; | ||
413 | } | ||
414 | |||
415 | u_phy = tegra_usb_get_phy(np_phy); | ||
416 | if (IS_ERR(u_phy)) { | 398 | if (IS_ERR(u_phy)) { |
417 | err = PTR_ERR(u_phy); | 399 | err = PTR_ERR(u_phy); |
418 | goto cleanup_clk_en; | 400 | goto cleanup_clk_en; |
@@ -437,6 +419,7 @@ static int tegra_ehci_probe(struct platform_device *pdev) | |||
437 | goto cleanup_clk_en; | 419 | goto cleanup_clk_en; |
438 | } | 420 | } |
439 | ehci->caps = hcd->regs + 0x100; | 421 | ehci->caps = hcd->regs + 0x100; |
422 | ehci->has_hostpc = soc_config->has_hostpc; | ||
440 | 423 | ||
441 | err = usb_phy_init(hcd->phy); | 424 | err = usb_phy_init(hcd->phy); |
442 | if (err) { | 425 | if (err) { |
@@ -466,26 +449,18 @@ static int tegra_ehci_probe(struct platform_device *pdev) | |||
466 | goto cleanup_phy; | 449 | goto cleanup_phy; |
467 | } | 450 | } |
468 | 451 | ||
469 | if (pdata->operating_mode == TEGRA_USB_OTG) { | 452 | otg_set_host(u_phy->otg, &hcd->self); |
470 | tegra->transceiver = | ||
471 | devm_usb_get_phy(&pdev->dev, USB_PHY_TYPE_USB2); | ||
472 | if (!IS_ERR(tegra->transceiver)) | ||
473 | otg_set_host(tegra->transceiver->otg, &hcd->self); | ||
474 | } else { | ||
475 | tegra->transceiver = ERR_PTR(-ENODEV); | ||
476 | } | ||
477 | 453 | ||
478 | err = usb_add_hcd(hcd, irq, IRQF_SHARED); | 454 | err = usb_add_hcd(hcd, irq, IRQF_SHARED); |
479 | if (err) { | 455 | if (err) { |
480 | dev_err(&pdev->dev, "Failed to add USB HCD\n"); | 456 | dev_err(&pdev->dev, "Failed to add USB HCD\n"); |
481 | goto cleanup_transceiver; | 457 | goto cleanup_otg_set_host; |
482 | } | 458 | } |
483 | 459 | ||
484 | return err; | 460 | return err; |
485 | 461 | ||
486 | cleanup_transceiver: | 462 | cleanup_otg_set_host: |
487 | if (!IS_ERR(tegra->transceiver)) | 463 | otg_set_host(u_phy->otg, NULL); |
488 | otg_set_host(tegra->transceiver->otg, NULL); | ||
489 | cleanup_phy: | 464 | cleanup_phy: |
490 | usb_phy_shutdown(hcd->phy); | 465 | usb_phy_shutdown(hcd->phy); |
491 | cleanup_clk_en: | 466 | cleanup_clk_en: |
@@ -494,8 +469,6 @@ cleanup_clk_get: | |||
494 | clk_put(tegra->clk); | 469 | clk_put(tegra->clk); |
495 | cleanup_hcd_create: | 470 | cleanup_hcd_create: |
496 | usb_put_hcd(hcd); | 471 | usb_put_hcd(hcd); |
497 | cleanup_vbus_gpio: | ||
498 | /* FIXME: Undo setup_vbus_gpio() here */ | ||
499 | return err; | 472 | return err; |
500 | } | 473 | } |
501 | 474 | ||
@@ -505,8 +478,7 @@ static int tegra_ehci_remove(struct platform_device *pdev) | |||
505 | struct tegra_ehci_hcd *tegra = | 478 | struct tegra_ehci_hcd *tegra = |
506 | (struct tegra_ehci_hcd *)hcd_to_ehci(hcd)->priv; | 479 | (struct tegra_ehci_hcd *)hcd_to_ehci(hcd)->priv; |
507 | 480 | ||
508 | if (!IS_ERR(tegra->transceiver)) | 481 | otg_set_host(hcd->phy->otg, NULL); |
509 | otg_set_host(tegra->transceiver->otg, NULL); | ||
510 | 482 | ||
511 | usb_phy_shutdown(hcd->phy); | 483 | usb_phy_shutdown(hcd->phy); |
512 | usb_remove_hcd(hcd); | 484 | usb_remove_hcd(hcd); |
@@ -525,11 +497,6 @@ static void tegra_ehci_hcd_shutdown(struct platform_device *pdev) | |||
525 | hcd->driver->shutdown(hcd); | 497 | hcd->driver->shutdown(hcd); |
526 | } | 498 | } |
527 | 499 | ||
528 | static struct of_device_id tegra_ehci_of_match[] = { | ||
529 | { .compatible = "nvidia,tegra20-ehci", }, | ||
530 | { }, | ||
531 | }; | ||
532 | |||
533 | static struct platform_driver tegra_ehci_driver = { | 500 | static struct platform_driver tegra_ehci_driver = { |
534 | .probe = tegra_ehci_probe, | 501 | .probe = tegra_ehci_probe, |
535 | .remove = tegra_ehci_remove, | 502 | .remove = tegra_ehci_remove, |
diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h index 947752015d5d..2822e79e1fbc 100644 --- a/drivers/usb/host/ehci.h +++ b/drivers/usb/host/ehci.h | |||
@@ -213,6 +213,7 @@ struct ehci_hcd { /* one per controller */ | |||
213 | #define OHCI_HCCTRL_LEN 0x4 | 213 | #define OHCI_HCCTRL_LEN 0x4 |
214 | __hc32 *ohci_hcctrl_reg; | 214 | __hc32 *ohci_hcctrl_reg; |
215 | unsigned has_hostpc:1; | 215 | unsigned has_hostpc:1; |
216 | unsigned has_tdi_phy_lpm:1; | ||
216 | unsigned has_ppcd:1; /* support per-port change bits */ | 217 | unsigned has_ppcd:1; /* support per-port change bits */ |
217 | u8 sbrn; /* packed release number */ | 218 | u8 sbrn; /* packed release number */ |
218 | 219 | ||
diff --git a/drivers/usb/musb/Kconfig b/drivers/usb/musb/Kconfig index 797e3fd45510..c64ee09a7c0e 100644 --- a/drivers/usb/musb/Kconfig +++ b/drivers/usb/musb/Kconfig | |||
@@ -83,6 +83,8 @@ config USB_MUSB_AM35X | |||
83 | 83 | ||
84 | config USB_MUSB_DSPS | 84 | config USB_MUSB_DSPS |
85 | tristate "TI DSPS platforms" | 85 | tristate "TI DSPS platforms" |
86 | select USB_MUSB_AM335X_CHILD | ||
87 | depends on OF_IRQ | ||
86 | 88 | ||
87 | config USB_MUSB_BLACKFIN | 89 | config USB_MUSB_BLACKFIN |
88 | tristate "Blackfin" | 90 | tristate "Blackfin" |
@@ -93,6 +95,9 @@ config USB_MUSB_UX500 | |||
93 | 95 | ||
94 | endchoice | 96 | endchoice |
95 | 97 | ||
98 | config USB_MUSB_AM335X_CHILD | ||
99 | tristate | ||
100 | |||
96 | choice | 101 | choice |
97 | prompt 'MUSB DMA mode' | 102 | prompt 'MUSB DMA mode' |
98 | default MUSB_PIO_ONLY if ARCH_MULTIPLATFORM | 103 | default MUSB_PIO_ONLY if ARCH_MULTIPLATFORM |
@@ -125,6 +130,10 @@ config USB_TI_CPPI_DMA | |||
125 | help | 130 | help |
126 | Enable DMA transfers when TI CPPI DMA is available. | 131 | Enable DMA transfers when TI CPPI DMA is available. |
127 | 132 | ||
133 | config USB_TI_CPPI41_DMA | ||
134 | bool 'TI CPPI 4.1 (AM335x)' | ||
135 | depends on ARCH_OMAP | ||
136 | |||
128 | config USB_TUSB_OMAP_DMA | 137 | config USB_TUSB_OMAP_DMA |
129 | bool 'TUSB 6010' | 138 | bool 'TUSB 6010' |
130 | depends on USB_MUSB_TUSB6010 | 139 | depends on USB_MUSB_TUSB6010 |
diff --git a/drivers/usb/musb/Makefile b/drivers/usb/musb/Makefile index 2b82ed7c85ca..c5ea5c6dc169 100644 --- a/drivers/usb/musb/Makefile +++ b/drivers/usb/musb/Makefile | |||
@@ -20,6 +20,9 @@ obj-$(CONFIG_USB_MUSB_DA8XX) += da8xx.o | |||
20 | obj-$(CONFIG_USB_MUSB_BLACKFIN) += blackfin.o | 20 | obj-$(CONFIG_USB_MUSB_BLACKFIN) += blackfin.o |
21 | obj-$(CONFIG_USB_MUSB_UX500) += ux500.o | 21 | obj-$(CONFIG_USB_MUSB_UX500) += ux500.o |
22 | 22 | ||
23 | |||
24 | obj-$(CONFIG_USB_MUSB_AM335X_CHILD) += musb_am335x.o | ||
25 | |||
23 | # the kconfig must guarantee that only one of the | 26 | # the kconfig must guarantee that only one of the |
24 | # possible I/O schemes will be enabled at a time ... | 27 | # possible I/O schemes will be enabled at a time ... |
25 | # PIO only, or DMA (several potential schemes). | 28 | # PIO only, or DMA (several potential schemes). |
@@ -29,3 +32,4 @@ musb_hdrc-$(CONFIG_USB_INVENTRA_DMA) += musbhsdma.o | |||
29 | musb_hdrc-$(CONFIG_USB_TI_CPPI_DMA) += cppi_dma.o | 32 | musb_hdrc-$(CONFIG_USB_TI_CPPI_DMA) += cppi_dma.o |
30 | musb_hdrc-$(CONFIG_USB_TUSB_OMAP_DMA) += tusb6010_omap.o | 33 | musb_hdrc-$(CONFIG_USB_TUSB_OMAP_DMA) += tusb6010_omap.o |
31 | musb_hdrc-$(CONFIG_USB_UX500_DMA) += ux500_dma.o | 34 | musb_hdrc-$(CONFIG_USB_UX500_DMA) += ux500_dma.o |
35 | musb_hdrc-$(CONFIG_USB_TI_CPPI41_DMA) += musb_cppi41.o | ||
diff --git a/drivers/usb/musb/am35x.c b/drivers/usb/musb/am35x.c index 2231850c0625..5c310c664218 100644 --- a/drivers/usb/musb/am35x.c +++ b/drivers/usb/musb/am35x.c | |||
@@ -33,7 +33,7 @@ | |||
33 | #include <linux/io.h> | 33 | #include <linux/io.h> |
34 | #include <linux/platform_device.h> | 34 | #include <linux/platform_device.h> |
35 | #include <linux/dma-mapping.h> | 35 | #include <linux/dma-mapping.h> |
36 | #include <linux/usb/nop-usb-xceiv.h> | 36 | #include <linux/usb/usb_phy_gen_xceiv.h> |
37 | #include <linux/platform_data/usb-omap.h> | 37 | #include <linux/platform_data/usb-omap.h> |
38 | 38 | ||
39 | #include "musb_core.h" | 39 | #include "musb_core.h" |
@@ -218,7 +218,7 @@ static irqreturn_t am35x_musb_interrupt(int irq, void *hci) | |||
218 | struct musb *musb = hci; | 218 | struct musb *musb = hci; |
219 | void __iomem *reg_base = musb->ctrl_base; | 219 | void __iomem *reg_base = musb->ctrl_base; |
220 | struct device *dev = musb->controller; | 220 | struct device *dev = musb->controller; |
221 | struct musb_hdrc_platform_data *plat = dev->platform_data; | 221 | struct musb_hdrc_platform_data *plat = dev_get_platdata(dev); |
222 | struct omap_musb_board_data *data = plat->board_data; | 222 | struct omap_musb_board_data *data = plat->board_data; |
223 | struct usb_otg *otg = musb->xceiv->otg; | 223 | struct usb_otg *otg = musb->xceiv->otg; |
224 | unsigned long flags; | 224 | unsigned long flags; |
@@ -335,7 +335,7 @@ eoi: | |||
335 | static int am35x_musb_set_mode(struct musb *musb, u8 musb_mode) | 335 | static int am35x_musb_set_mode(struct musb *musb, u8 musb_mode) |
336 | { | 336 | { |
337 | struct device *dev = musb->controller; | 337 | struct device *dev = musb->controller; |
338 | struct musb_hdrc_platform_data *plat = dev->platform_data; | 338 | struct musb_hdrc_platform_data *plat = dev_get_platdata(dev); |
339 | struct omap_musb_board_data *data = plat->board_data; | 339 | struct omap_musb_board_data *data = plat->board_data; |
340 | int retval = 0; | 340 | int retval = 0; |
341 | 341 | ||
@@ -350,7 +350,7 @@ static int am35x_musb_set_mode(struct musb *musb, u8 musb_mode) | |||
350 | static int am35x_musb_init(struct musb *musb) | 350 | static int am35x_musb_init(struct musb *musb) |
351 | { | 351 | { |
352 | struct device *dev = musb->controller; | 352 | struct device *dev = musb->controller; |
353 | struct musb_hdrc_platform_data *plat = dev->platform_data; | 353 | struct musb_hdrc_platform_data *plat = dev_get_platdata(dev); |
354 | struct omap_musb_board_data *data = plat->board_data; | 354 | struct omap_musb_board_data *data = plat->board_data; |
355 | void __iomem *reg_base = musb->ctrl_base; | 355 | void __iomem *reg_base = musb->ctrl_base; |
356 | u32 rev; | 356 | u32 rev; |
@@ -394,7 +394,7 @@ static int am35x_musb_init(struct musb *musb) | |||
394 | static int am35x_musb_exit(struct musb *musb) | 394 | static int am35x_musb_exit(struct musb *musb) |
395 | { | 395 | { |
396 | struct device *dev = musb->controller; | 396 | struct device *dev = musb->controller; |
397 | struct musb_hdrc_platform_data *plat = dev->platform_data; | 397 | struct musb_hdrc_platform_data *plat = dev_get_platdata(dev); |
398 | struct omap_musb_board_data *data = plat->board_data; | 398 | struct omap_musb_board_data *data = plat->board_data; |
399 | 399 | ||
400 | del_timer_sync(&otg_workaround); | 400 | del_timer_sync(&otg_workaround); |
@@ -456,7 +456,7 @@ static u64 am35x_dmamask = DMA_BIT_MASK(32); | |||
456 | 456 | ||
457 | static int am35x_probe(struct platform_device *pdev) | 457 | static int am35x_probe(struct platform_device *pdev) |
458 | { | 458 | { |
459 | struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data; | 459 | struct musb_hdrc_platform_data *pdata = dev_get_platdata(&pdev->dev); |
460 | struct platform_device *musb; | 460 | struct platform_device *musb; |
461 | struct am35x_glue *glue; | 461 | struct am35x_glue *glue; |
462 | 462 | ||
@@ -577,7 +577,7 @@ static int am35x_remove(struct platform_device *pdev) | |||
577 | static int am35x_suspend(struct device *dev) | 577 | static int am35x_suspend(struct device *dev) |
578 | { | 578 | { |
579 | struct am35x_glue *glue = dev_get_drvdata(dev); | 579 | struct am35x_glue *glue = dev_get_drvdata(dev); |
580 | struct musb_hdrc_platform_data *plat = dev->platform_data; | 580 | struct musb_hdrc_platform_data *plat = dev_get_platdata(dev); |
581 | struct omap_musb_board_data *data = plat->board_data; | 581 | struct omap_musb_board_data *data = plat->board_data; |
582 | 582 | ||
583 | /* Shutdown the on-chip PHY and its PLL. */ | 583 | /* Shutdown the on-chip PHY and its PLL. */ |
@@ -593,7 +593,7 @@ static int am35x_suspend(struct device *dev) | |||
593 | static int am35x_resume(struct device *dev) | 593 | static int am35x_resume(struct device *dev) |
594 | { | 594 | { |
595 | struct am35x_glue *glue = dev_get_drvdata(dev); | 595 | struct am35x_glue *glue = dev_get_drvdata(dev); |
596 | struct musb_hdrc_platform_data *plat = dev->platform_data; | 596 | struct musb_hdrc_platform_data *plat = dev_get_platdata(dev); |
597 | struct omap_musb_board_data *data = plat->board_data; | 597 | struct omap_musb_board_data *data = plat->board_data; |
598 | int ret; | 598 | int ret; |
599 | 599 | ||
diff --git a/drivers/usb/musb/blackfin.c b/drivers/usb/musb/blackfin.c index 6ba8439bd5a6..72e2056b6082 100644 --- a/drivers/usb/musb/blackfin.c +++ b/drivers/usb/musb/blackfin.c | |||
@@ -19,7 +19,7 @@ | |||
19 | #include <linux/platform_device.h> | 19 | #include <linux/platform_device.h> |
20 | #include <linux/dma-mapping.h> | 20 | #include <linux/dma-mapping.h> |
21 | #include <linux/prefetch.h> | 21 | #include <linux/prefetch.h> |
22 | #include <linux/usb/nop-usb-xceiv.h> | 22 | #include <linux/usb/usb_phy_gen_xceiv.h> |
23 | 23 | ||
24 | #include <asm/cacheflush.h> | 24 | #include <asm/cacheflush.h> |
25 | 25 | ||
@@ -451,7 +451,7 @@ static u64 bfin_dmamask = DMA_BIT_MASK(32); | |||
451 | static int bfin_probe(struct platform_device *pdev) | 451 | static int bfin_probe(struct platform_device *pdev) |
452 | { | 452 | { |
453 | struct resource musb_resources[2]; | 453 | struct resource musb_resources[2]; |
454 | struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data; | 454 | struct musb_hdrc_platform_data *pdata = dev_get_platdata(&pdev->dev); |
455 | struct platform_device *musb; | 455 | struct platform_device *musb; |
456 | struct bfin_glue *glue; | 456 | struct bfin_glue *glue; |
457 | 457 | ||
diff --git a/drivers/usb/musb/cppi_dma.c b/drivers/usb/musb/cppi_dma.c index 9db211ee15b5..904fb85d85a6 100644 --- a/drivers/usb/musb/cppi_dma.c +++ b/drivers/usb/musb/cppi_dma.c | |||
@@ -150,14 +150,11 @@ static void cppi_pool_free(struct cppi_channel *c) | |||
150 | c->last_processed = NULL; | 150 | c->last_processed = NULL; |
151 | } | 151 | } |
152 | 152 | ||
153 | static int cppi_controller_start(struct dma_controller *c) | 153 | static void cppi_controller_start(struct cppi *controller) |
154 | { | 154 | { |
155 | struct cppi *controller; | ||
156 | void __iomem *tibase; | 155 | void __iomem *tibase; |
157 | int i; | 156 | int i; |
158 | 157 | ||
159 | controller = container_of(c, struct cppi, controller); | ||
160 | |||
161 | /* do whatever is necessary to start controller */ | 158 | /* do whatever is necessary to start controller */ |
162 | for (i = 0; i < ARRAY_SIZE(controller->tx); i++) { | 159 | for (i = 0; i < ARRAY_SIZE(controller->tx); i++) { |
163 | controller->tx[i].transmit = true; | 160 | controller->tx[i].transmit = true; |
@@ -212,8 +209,6 @@ static int cppi_controller_start(struct dma_controller *c) | |||
212 | /* disable RNDIS mode, also host rx RNDIS autorequest */ | 209 | /* disable RNDIS mode, also host rx RNDIS autorequest */ |
213 | musb_writel(tibase, DAVINCI_RNDIS_REG, 0); | 210 | musb_writel(tibase, DAVINCI_RNDIS_REG, 0); |
214 | musb_writel(tibase, DAVINCI_AUTOREQ_REG, 0); | 211 | musb_writel(tibase, DAVINCI_AUTOREQ_REG, 0); |
215 | |||
216 | return 0; | ||
217 | } | 212 | } |
218 | 213 | ||
219 | /* | 214 | /* |
@@ -222,14 +217,12 @@ static int cppi_controller_start(struct dma_controller *c) | |||
222 | * De-Init the DMA controller as necessary. | 217 | * De-Init the DMA controller as necessary. |
223 | */ | 218 | */ |
224 | 219 | ||
225 | static int cppi_controller_stop(struct dma_controller *c) | 220 | static void cppi_controller_stop(struct cppi *controller) |
226 | { | 221 | { |
227 | struct cppi *controller; | ||
228 | void __iomem *tibase; | 222 | void __iomem *tibase; |
229 | int i; | 223 | int i; |
230 | struct musb *musb; | 224 | struct musb *musb; |
231 | 225 | ||
232 | controller = container_of(c, struct cppi, controller); | ||
233 | musb = controller->musb; | 226 | musb = controller->musb; |
234 | 227 | ||
235 | tibase = controller->tibase; | 228 | tibase = controller->tibase; |
@@ -255,8 +248,6 @@ static int cppi_controller_stop(struct dma_controller *c) | |||
255 | /*disable tx/rx cppi */ | 248 | /*disable tx/rx cppi */ |
256 | musb_writel(tibase, DAVINCI_TXCPPI_CTRL_REG, DAVINCI_DMA_CTRL_DISABLE); | 249 | musb_writel(tibase, DAVINCI_TXCPPI_CTRL_REG, DAVINCI_DMA_CTRL_DISABLE); |
257 | musb_writel(tibase, DAVINCI_RXCPPI_CTRL_REG, DAVINCI_DMA_CTRL_DISABLE); | 250 | musb_writel(tibase, DAVINCI_RXCPPI_CTRL_REG, DAVINCI_DMA_CTRL_DISABLE); |
258 | |||
259 | return 0; | ||
260 | } | 251 | } |
261 | 252 | ||
262 | /* While dma channel is allocated, we only want the core irqs active | 253 | /* While dma channel is allocated, we only want the core irqs active |
@@ -1321,8 +1312,6 @@ struct dma_controller *dma_controller_create(struct musb *musb, void __iomem *mr | |||
1321 | controller->tibase = mregs - DAVINCI_BASE_OFFSET; | 1312 | controller->tibase = mregs - DAVINCI_BASE_OFFSET; |
1322 | 1313 | ||
1323 | controller->musb = musb; | 1314 | controller->musb = musb; |
1324 | controller->controller.start = cppi_controller_start; | ||
1325 | controller->controller.stop = cppi_controller_stop; | ||
1326 | controller->controller.channel_alloc = cppi_channel_allocate; | 1315 | controller->controller.channel_alloc = cppi_channel_allocate; |
1327 | controller->controller.channel_release = cppi_channel_release; | 1316 | controller->controller.channel_release = cppi_channel_release; |
1328 | controller->controller.channel_program = cppi_channel_program; | 1317 | controller->controller.channel_program = cppi_channel_program; |
@@ -1351,6 +1340,7 @@ struct dma_controller *dma_controller_create(struct musb *musb, void __iomem *mr | |||
1351 | controller->irq = irq; | 1340 | controller->irq = irq; |
1352 | } | 1341 | } |
1353 | 1342 | ||
1343 | cppi_controller_start(controller); | ||
1354 | return &controller->controller; | 1344 | return &controller->controller; |
1355 | } | 1345 | } |
1356 | 1346 | ||
@@ -1363,6 +1353,8 @@ void dma_controller_destroy(struct dma_controller *c) | |||
1363 | 1353 | ||
1364 | cppi = container_of(c, struct cppi, controller); | 1354 | cppi = container_of(c, struct cppi, controller); |
1365 | 1355 | ||
1356 | cppi_controller_stop(cppi); | ||
1357 | |||
1366 | if (cppi->irq) | 1358 | if (cppi->irq) |
1367 | free_irq(cppi->irq, cppi->musb); | 1359 | free_irq(cppi->irq, cppi->musb); |
1368 | 1360 | ||
diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c index 0da6f648a9fe..d9ddf4122f37 100644 --- a/drivers/usb/musb/da8xx.c +++ b/drivers/usb/musb/da8xx.c | |||
@@ -33,7 +33,7 @@ | |||
33 | #include <linux/io.h> | 33 | #include <linux/io.h> |
34 | #include <linux/platform_device.h> | 34 | #include <linux/platform_device.h> |
35 | #include <linux/dma-mapping.h> | 35 | #include <linux/dma-mapping.h> |
36 | #include <linux/usb/nop-usb-xceiv.h> | 36 | #include <linux/usb/usb_phy_gen_xceiv.h> |
37 | 37 | ||
38 | #include <mach/da8xx.h> | 38 | #include <mach/da8xx.h> |
39 | #include <linux/platform_data/usb-davinci.h> | 39 | #include <linux/platform_data/usb-davinci.h> |
@@ -477,7 +477,7 @@ static u64 da8xx_dmamask = DMA_BIT_MASK(32); | |||
477 | static int da8xx_probe(struct platform_device *pdev) | 477 | static int da8xx_probe(struct platform_device *pdev) |
478 | { | 478 | { |
479 | struct resource musb_resources[2]; | 479 | struct resource musb_resources[2]; |
480 | struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data; | 480 | struct musb_hdrc_platform_data *pdata = dev_get_platdata(&pdev->dev); |
481 | struct platform_device *musb; | 481 | struct platform_device *musb; |
482 | struct da8xx_glue *glue; | 482 | struct da8xx_glue *glue; |
483 | 483 | ||
diff --git a/drivers/usb/musb/davinci.c b/drivers/usb/musb/davinci.c index f8aeaf2e2cd1..ed0834e2b72e 100644 --- a/drivers/usb/musb/davinci.c +++ b/drivers/usb/musb/davinci.c | |||
@@ -33,7 +33,7 @@ | |||
33 | #include <linux/gpio.h> | 33 | #include <linux/gpio.h> |
34 | #include <linux/platform_device.h> | 34 | #include <linux/platform_device.h> |
35 | #include <linux/dma-mapping.h> | 35 | #include <linux/dma-mapping.h> |
36 | #include <linux/usb/nop-usb-xceiv.h> | 36 | #include <linux/usb/usb_phy_gen_xceiv.h> |
37 | 37 | ||
38 | #include <mach/cputype.h> | 38 | #include <mach/cputype.h> |
39 | #include <mach/hardware.h> | 39 | #include <mach/hardware.h> |
@@ -510,7 +510,7 @@ static u64 davinci_dmamask = DMA_BIT_MASK(32); | |||
510 | static int davinci_probe(struct platform_device *pdev) | 510 | static int davinci_probe(struct platform_device *pdev) |
511 | { | 511 | { |
512 | struct resource musb_resources[2]; | 512 | struct resource musb_resources[2]; |
513 | struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data; | 513 | struct musb_hdrc_platform_data *pdata = dev_get_platdata(&pdev->dev); |
514 | struct platform_device *musb; | 514 | struct platform_device *musb; |
515 | struct davinci_glue *glue; | 515 | struct davinci_glue *glue; |
516 | struct clk *clk; | 516 | struct clk *clk; |
diff --git a/drivers/usb/musb/musb_am335x.c b/drivers/usb/musb/musb_am335x.c new file mode 100644 index 000000000000..41ac5b5b57ce --- /dev/null +++ b/drivers/usb/musb/musb_am335x.c | |||
@@ -0,0 +1,55 @@ | |||
1 | #include <linux/init.h> | ||
2 | #include <linux/platform_device.h> | ||
3 | #include <linux/pm_runtime.h> | ||
4 | #include <linux/module.h> | ||
5 | #include <linux/of_platform.h> | ||
6 | |||
7 | static int am335x_child_probe(struct platform_device *pdev) | ||
8 | { | ||
9 | int ret; | ||
10 | |||
11 | pm_runtime_enable(&pdev->dev); | ||
12 | |||
13 | ret = of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev); | ||
14 | if (ret) | ||
15 | goto err; | ||
16 | |||
17 | return 0; | ||
18 | err: | ||
19 | pm_runtime_disable(&pdev->dev); | ||
20 | return ret; | ||
21 | } | ||
22 | |||
23 | static int of_remove_populated_child(struct device *dev, void *d) | ||
24 | { | ||
25 | struct platform_device *pdev = to_platform_device(dev); | ||
26 | |||
27 | of_device_unregister(pdev); | ||
28 | return 0; | ||
29 | } | ||
30 | |||
31 | static int am335x_child_remove(struct platform_device *pdev) | ||
32 | { | ||
33 | device_for_each_child(&pdev->dev, NULL, of_remove_populated_child); | ||
34 | pm_runtime_disable(&pdev->dev); | ||
35 | return 0; | ||
36 | } | ||
37 | |||
38 | static const struct of_device_id am335x_child_of_match[] = { | ||
39 | { .compatible = "ti,am33xx-usb" }, | ||
40 | { }, | ||
41 | }; | ||
42 | MODULE_DEVICE_TABLE(of, am335x_child_of_match); | ||
43 | |||
44 | static struct platform_driver am335x_child_driver = { | ||
45 | .probe = am335x_child_probe, | ||
46 | .remove = am335x_child_remove, | ||
47 | .driver = { | ||
48 | .name = "am335x-usb-childs", | ||
49 | .of_match_table = of_match_ptr(am335x_child_of_match), | ||
50 | }, | ||
51 | }; | ||
52 | |||
53 | module_platform_driver(am335x_child_driver); | ||
54 | MODULE_DESCRIPTION("AM33xx child devices"); | ||
55 | MODULE_LICENSE("GPL v2"); | ||
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c index 9e59710efee7..18e877ffe7b7 100644 --- a/drivers/usb/musb/musb_core.c +++ b/drivers/usb/musb/musb_core.c | |||
@@ -1763,12 +1763,8 @@ static void musb_free(struct musb *musb) | |||
1763 | disable_irq_wake(musb->nIrq); | 1763 | disable_irq_wake(musb->nIrq); |
1764 | free_irq(musb->nIrq, musb); | 1764 | free_irq(musb->nIrq, musb); |
1765 | } | 1765 | } |
1766 | if (is_dma_capable() && musb->dma_controller) { | 1766 | if (musb->dma_controller) |
1767 | struct dma_controller *c = musb->dma_controller; | 1767 | dma_controller_destroy(musb->dma_controller); |
1768 | |||
1769 | (void) c->stop(c); | ||
1770 | dma_controller_destroy(c); | ||
1771 | } | ||
1772 | 1768 | ||
1773 | musb_host_free(musb); | 1769 | musb_host_free(musb); |
1774 | } | 1770 | } |
@@ -1786,7 +1782,7 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl) | |||
1786 | { | 1782 | { |
1787 | int status; | 1783 | int status; |
1788 | struct musb *musb; | 1784 | struct musb *musb; |
1789 | struct musb_hdrc_platform_data *plat = dev->platform_data; | 1785 | struct musb_hdrc_platform_data *plat = dev_get_platdata(dev); |
1790 | 1786 | ||
1791 | /* The driver might handle more features than the board; OK. | 1787 | /* The driver might handle more features than the board; OK. |
1792 | * Fail when the board needs a feature that's not enabled. | 1788 | * Fail when the board needs a feature that's not enabled. |
@@ -1843,19 +1839,8 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl) | |||
1843 | 1839 | ||
1844 | pm_runtime_get_sync(musb->controller); | 1840 | pm_runtime_get_sync(musb->controller); |
1845 | 1841 | ||
1846 | #ifndef CONFIG_MUSB_PIO_ONLY | 1842 | if (use_dma && dev->dma_mask) |
1847 | if (use_dma && dev->dma_mask) { | 1843 | musb->dma_controller = dma_controller_create(musb, musb->mregs); |
1848 | struct dma_controller *c; | ||
1849 | |||
1850 | c = dma_controller_create(musb, musb->mregs); | ||
1851 | musb->dma_controller = c; | ||
1852 | if (c) | ||
1853 | (void) c->start(c); | ||
1854 | } | ||
1855 | #endif | ||
1856 | /* ideally this would be abstracted in platform setup */ | ||
1857 | if (!is_dma_capable() || !musb->dma_controller) | ||
1858 | dev->dma_mask = NULL; | ||
1859 | 1844 | ||
1860 | /* be sure interrupts are disabled before connecting ISR */ | 1845 | /* be sure interrupts are disabled before connecting ISR */ |
1861 | musb_platform_disable(musb); | 1846 | musb_platform_disable(musb); |
@@ -1943,6 +1928,8 @@ fail4: | |||
1943 | musb_gadget_cleanup(musb); | 1928 | musb_gadget_cleanup(musb); |
1944 | 1929 | ||
1945 | fail3: | 1930 | fail3: |
1931 | if (musb->dma_controller) | ||
1932 | dma_controller_destroy(musb->dma_controller); | ||
1946 | pm_runtime_put_sync(musb->controller); | 1933 | pm_runtime_put_sync(musb->controller); |
1947 | 1934 | ||
1948 | fail2: | 1935 | fail2: |
@@ -2001,9 +1988,6 @@ static int musb_remove(struct platform_device *pdev) | |||
2001 | 1988 | ||
2002 | musb_free(musb); | 1989 | musb_free(musb); |
2003 | device_init_wakeup(dev, 0); | 1990 | device_init_wakeup(dev, 0); |
2004 | #ifndef CONFIG_MUSB_PIO_ONLY | ||
2005 | dma_set_mask(dev, *dev->parent->dma_mask); | ||
2006 | #endif | ||
2007 | return 0; | 1991 | return 0; |
2008 | } | 1992 | } |
2009 | 1993 | ||
diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h index 7d341c387eab..65f3917b4fc5 100644 --- a/drivers/usb/musb/musb_core.h +++ b/drivers/usb/musb/musb_core.h | |||
@@ -83,11 +83,6 @@ enum { | |||
83 | MUSB_PORT_MODE_DUAL_ROLE, | 83 | MUSB_PORT_MODE_DUAL_ROLE, |
84 | }; | 84 | }; |
85 | 85 | ||
86 | #ifdef CONFIG_PROC_FS | ||
87 | #include <linux/fs.h> | ||
88 | #define MUSB_CONFIG_PROC_FS | ||
89 | #endif | ||
90 | |||
91 | /****************************** CONSTANTS ********************************/ | 86 | /****************************** CONSTANTS ********************************/ |
92 | 87 | ||
93 | #ifndef MUSB_C_NUM_EPS | 88 | #ifndef MUSB_C_NUM_EPS |
@@ -425,9 +420,6 @@ struct musb { | |||
425 | 420 | ||
426 | struct musb_hdrc_config *config; | 421 | struct musb_hdrc_config *config; |
427 | 422 | ||
428 | #ifdef MUSB_CONFIG_PROC_FS | ||
429 | struct proc_dir_entry *proc_entry; | ||
430 | #endif | ||
431 | int xceiv_old_state; | 423 | int xceiv_old_state; |
432 | #ifdef CONFIG_DEBUG_FS | 424 | #ifdef CONFIG_DEBUG_FS |
433 | struct dentry *debugfs_root; | 425 | struct dentry *debugfs_root; |
diff --git a/drivers/usb/musb/musb_cppi41.c b/drivers/usb/musb/musb_cppi41.c new file mode 100644 index 000000000000..e64701d15401 --- /dev/null +++ b/drivers/usb/musb/musb_cppi41.c | |||
@@ -0,0 +1,555 @@ | |||
1 | #include <linux/device.h> | ||
2 | #include <linux/dma-mapping.h> | ||
3 | #include <linux/dmaengine.h> | ||
4 | #include <linux/sizes.h> | ||
5 | #include <linux/platform_device.h> | ||
6 | #include <linux/of.h> | ||
7 | |||
8 | #include "musb_core.h" | ||
9 | |||
10 | #define RNDIS_REG(x) (0x80 + ((x - 1) * 4)) | ||
11 | |||
12 | #define EP_MODE_AUTOREG_NONE 0 | ||
13 | #define EP_MODE_AUTOREG_ALL_NEOP 1 | ||
14 | #define EP_MODE_AUTOREG_ALWAYS 3 | ||
15 | |||
16 | #define EP_MODE_DMA_TRANSPARENT 0 | ||
17 | #define EP_MODE_DMA_RNDIS 1 | ||
18 | #define EP_MODE_DMA_GEN_RNDIS 3 | ||
19 | |||
20 | #define USB_CTRL_TX_MODE 0x70 | ||
21 | #define USB_CTRL_RX_MODE 0x74 | ||
22 | #define USB_CTRL_AUTOREQ 0xd0 | ||
23 | #define USB_TDOWN 0xd8 | ||
24 | |||
25 | struct cppi41_dma_channel { | ||
26 | struct dma_channel channel; | ||
27 | struct cppi41_dma_controller *controller; | ||
28 | struct musb_hw_ep *hw_ep; | ||
29 | struct dma_chan *dc; | ||
30 | dma_cookie_t cookie; | ||
31 | u8 port_num; | ||
32 | u8 is_tx; | ||
33 | u8 is_allocated; | ||
34 | u8 usb_toggle; | ||
35 | |||
36 | dma_addr_t buf_addr; | ||
37 | u32 total_len; | ||
38 | u32 prog_len; | ||
39 | u32 transferred; | ||
40 | u32 packet_sz; | ||
41 | }; | ||
42 | |||
43 | #define MUSB_DMA_NUM_CHANNELS 15 | ||
44 | |||
45 | struct cppi41_dma_controller { | ||
46 | struct dma_controller controller; | ||
47 | struct cppi41_dma_channel rx_channel[MUSB_DMA_NUM_CHANNELS]; | ||
48 | struct cppi41_dma_channel tx_channel[MUSB_DMA_NUM_CHANNELS]; | ||
49 | struct musb *musb; | ||
50 | u32 rx_mode; | ||
51 | u32 tx_mode; | ||
52 | u32 auto_req; | ||
53 | }; | ||
54 | |||
55 | static void save_rx_toggle(struct cppi41_dma_channel *cppi41_channel) | ||
56 | { | ||
57 | u16 csr; | ||
58 | u8 toggle; | ||
59 | |||
60 | if (cppi41_channel->is_tx) | ||
61 | return; | ||
62 | if (!is_host_active(cppi41_channel->controller->musb)) | ||
63 | return; | ||
64 | |||
65 | csr = musb_readw(cppi41_channel->hw_ep->regs, MUSB_RXCSR); | ||
66 | toggle = csr & MUSB_RXCSR_H_DATATOGGLE ? 1 : 0; | ||
67 | |||
68 | cppi41_channel->usb_toggle = toggle; | ||
69 | } | ||
70 | |||
71 | static void update_rx_toggle(struct cppi41_dma_channel *cppi41_channel) | ||
72 | { | ||
73 | u16 csr; | ||
74 | u8 toggle; | ||
75 | |||
76 | if (cppi41_channel->is_tx) | ||
77 | return; | ||
78 | if (!is_host_active(cppi41_channel->controller->musb)) | ||
79 | return; | ||
80 | |||
81 | csr = musb_readw(cppi41_channel->hw_ep->regs, MUSB_RXCSR); | ||
82 | toggle = csr & MUSB_RXCSR_H_DATATOGGLE ? 1 : 0; | ||
83 | |||
84 | /* | ||
85 | * AM335x Advisory 1.0.13: Due to internal synchronisation error the | ||
86 | * data toggle may reset from DATA1 to DATA0 during receiving data from | ||
87 | * more than one endpoint. | ||
88 | */ | ||
89 | if (!toggle && toggle == cppi41_channel->usb_toggle) { | ||
90 | csr |= MUSB_RXCSR_H_DATATOGGLE | MUSB_RXCSR_H_WR_DATATOGGLE; | ||
91 | musb_writew(cppi41_channel->hw_ep->regs, MUSB_RXCSR, csr); | ||
92 | dev_dbg(cppi41_channel->controller->musb->controller, | ||
93 | "Restoring DATA1 toggle.\n"); | ||
94 | } | ||
95 | |||
96 | cppi41_channel->usb_toggle = toggle; | ||
97 | } | ||
98 | |||
99 | static void cppi41_dma_callback(void *private_data) | ||
100 | { | ||
101 | struct dma_channel *channel = private_data; | ||
102 | struct cppi41_dma_channel *cppi41_channel = channel->private_data; | ||
103 | struct musb_hw_ep *hw_ep = cppi41_channel->hw_ep; | ||
104 | struct musb *musb = hw_ep->musb; | ||
105 | unsigned long flags; | ||
106 | struct dma_tx_state txstate; | ||
107 | u32 transferred; | ||
108 | |||
109 | spin_lock_irqsave(&musb->lock, flags); | ||
110 | |||
111 | dmaengine_tx_status(cppi41_channel->dc, cppi41_channel->cookie, | ||
112 | &txstate); | ||
113 | transferred = cppi41_channel->prog_len - txstate.residue; | ||
114 | cppi41_channel->transferred += transferred; | ||
115 | |||
116 | dev_dbg(musb->controller, "DMA transfer done on hw_ep=%d bytes=%d/%d\n", | ||
117 | hw_ep->epnum, cppi41_channel->transferred, | ||
118 | cppi41_channel->total_len); | ||
119 | |||
120 | update_rx_toggle(cppi41_channel); | ||
121 | |||
122 | if (cppi41_channel->transferred == cppi41_channel->total_len || | ||
123 | transferred < cppi41_channel->packet_sz) { | ||
124 | |||
125 | /* done, complete */ | ||
126 | cppi41_channel->channel.actual_len = | ||
127 | cppi41_channel->transferred; | ||
128 | cppi41_channel->channel.status = MUSB_DMA_STATUS_FREE; | ||
129 | musb_dma_completion(musb, hw_ep->epnum, cppi41_channel->is_tx); | ||
130 | } else { | ||
131 | /* next iteration, reload */ | ||
132 | struct dma_chan *dc = cppi41_channel->dc; | ||
133 | struct dma_async_tx_descriptor *dma_desc; | ||
134 | enum dma_transfer_direction direction; | ||
135 | u16 csr; | ||
136 | u32 remain_bytes; | ||
137 | void __iomem *epio = cppi41_channel->hw_ep->regs; | ||
138 | |||
139 | cppi41_channel->buf_addr += cppi41_channel->packet_sz; | ||
140 | |||
141 | remain_bytes = cppi41_channel->total_len; | ||
142 | remain_bytes -= cppi41_channel->transferred; | ||
143 | remain_bytes = min(remain_bytes, cppi41_channel->packet_sz); | ||
144 | cppi41_channel->prog_len = remain_bytes; | ||
145 | |||
146 | direction = cppi41_channel->is_tx ? DMA_MEM_TO_DEV | ||
147 | : DMA_DEV_TO_MEM; | ||
148 | dma_desc = dmaengine_prep_slave_single(dc, | ||
149 | cppi41_channel->buf_addr, | ||
150 | remain_bytes, | ||
151 | direction, | ||
152 | DMA_PREP_INTERRUPT | DMA_CTRL_ACK); | ||
153 | if (WARN_ON(!dma_desc)) | ||
154 | return; | ||
155 | |||
156 | dma_desc->callback = cppi41_dma_callback; | ||
157 | dma_desc->callback_param = channel; | ||
158 | cppi41_channel->cookie = dma_desc->tx_submit(dma_desc); | ||
159 | dma_async_issue_pending(dc); | ||
160 | |||
161 | if (!cppi41_channel->is_tx) { | ||
162 | csr = musb_readw(epio, MUSB_RXCSR); | ||
163 | csr |= MUSB_RXCSR_H_REQPKT; | ||
164 | musb_writew(epio, MUSB_RXCSR, csr); | ||
165 | } | ||
166 | } | ||
167 | spin_unlock_irqrestore(&musb->lock, flags); | ||
168 | } | ||
169 | |||
170 | static u32 update_ep_mode(unsigned ep, unsigned mode, u32 old) | ||
171 | { | ||
172 | unsigned shift; | ||
173 | |||
174 | shift = (ep - 1) * 2; | ||
175 | old &= ~(3 << shift); | ||
176 | old |= mode << shift; | ||
177 | return old; | ||
178 | } | ||
179 | |||
180 | static void cppi41_set_dma_mode(struct cppi41_dma_channel *cppi41_channel, | ||
181 | unsigned mode) | ||
182 | { | ||
183 | struct cppi41_dma_controller *controller = cppi41_channel->controller; | ||
184 | u32 port; | ||
185 | u32 new_mode; | ||
186 | u32 old_mode; | ||
187 | |||
188 | if (cppi41_channel->is_tx) | ||
189 | old_mode = controller->tx_mode; | ||
190 | else | ||
191 | old_mode = controller->rx_mode; | ||
192 | port = cppi41_channel->port_num; | ||
193 | new_mode = update_ep_mode(port, mode, old_mode); | ||
194 | |||
195 | if (new_mode == old_mode) | ||
196 | return; | ||
197 | if (cppi41_channel->is_tx) { | ||
198 | controller->tx_mode = new_mode; | ||
199 | musb_writel(controller->musb->ctrl_base, USB_CTRL_TX_MODE, | ||
200 | new_mode); | ||
201 | } else { | ||
202 | controller->rx_mode = new_mode; | ||
203 | musb_writel(controller->musb->ctrl_base, USB_CTRL_RX_MODE, | ||
204 | new_mode); | ||
205 | } | ||
206 | } | ||
207 | |||
208 | static void cppi41_set_autoreq_mode(struct cppi41_dma_channel *cppi41_channel, | ||
209 | unsigned mode) | ||
210 | { | ||
211 | struct cppi41_dma_controller *controller = cppi41_channel->controller; | ||
212 | u32 port; | ||
213 | u32 new_mode; | ||
214 | u32 old_mode; | ||
215 | |||
216 | old_mode = controller->auto_req; | ||
217 | port = cppi41_channel->port_num; | ||
218 | new_mode = update_ep_mode(port, mode, old_mode); | ||
219 | |||
220 | if (new_mode == old_mode) | ||
221 | return; | ||
222 | controller->auto_req = new_mode; | ||
223 | musb_writel(controller->musb->ctrl_base, USB_CTRL_AUTOREQ, new_mode); | ||
224 | } | ||
225 | |||
226 | static bool cppi41_configure_channel(struct dma_channel *channel, | ||
227 | u16 packet_sz, u8 mode, | ||
228 | dma_addr_t dma_addr, u32 len) | ||
229 | { | ||
230 | struct cppi41_dma_channel *cppi41_channel = channel->private_data; | ||
231 | struct dma_chan *dc = cppi41_channel->dc; | ||
232 | struct dma_async_tx_descriptor *dma_desc; | ||
233 | enum dma_transfer_direction direction; | ||
234 | struct musb *musb = cppi41_channel->controller->musb; | ||
235 | unsigned use_gen_rndis = 0; | ||
236 | |||
237 | dev_dbg(musb->controller, | ||
238 | "configure ep%d/%x packet_sz=%d, mode=%d, dma_addr=0x%llx, len=%d is_tx=%d\n", | ||
239 | cppi41_channel->port_num, RNDIS_REG(cppi41_channel->port_num), | ||
240 | packet_sz, mode, (unsigned long long) dma_addr, | ||
241 | len, cppi41_channel->is_tx); | ||
242 | |||
243 | cppi41_channel->buf_addr = dma_addr; | ||
244 | cppi41_channel->total_len = len; | ||
245 | cppi41_channel->transferred = 0; | ||
246 | cppi41_channel->packet_sz = packet_sz; | ||
247 | |||
248 | /* | ||
249 | * Due to AM335x' Advisory 1.0.13 we are not allowed to transfer more | ||
250 | * than max packet size at a time. | ||
251 | */ | ||
252 | if (cppi41_channel->is_tx) | ||
253 | use_gen_rndis = 1; | ||
254 | |||
255 | if (use_gen_rndis) { | ||
256 | /* RNDIS mode */ | ||
257 | if (len > packet_sz) { | ||
258 | musb_writel(musb->ctrl_base, | ||
259 | RNDIS_REG(cppi41_channel->port_num), len); | ||
260 | /* gen rndis */ | ||
261 | cppi41_set_dma_mode(cppi41_channel, | ||
262 | EP_MODE_DMA_GEN_RNDIS); | ||
263 | |||
264 | /* auto req */ | ||
265 | cppi41_set_autoreq_mode(cppi41_channel, | ||
266 | EP_MODE_AUTOREG_ALL_NEOP); | ||
267 | } else { | ||
268 | musb_writel(musb->ctrl_base, | ||
269 | RNDIS_REG(cppi41_channel->port_num), 0); | ||
270 | cppi41_set_dma_mode(cppi41_channel, | ||
271 | EP_MODE_DMA_TRANSPARENT); | ||
272 | cppi41_set_autoreq_mode(cppi41_channel, | ||
273 | EP_MODE_AUTOREG_NONE); | ||
274 | } | ||
275 | } else { | ||
276 | /* fallback mode */ | ||
277 | cppi41_set_dma_mode(cppi41_channel, EP_MODE_DMA_TRANSPARENT); | ||
278 | cppi41_set_autoreq_mode(cppi41_channel, EP_MODE_AUTOREG_NONE); | ||
279 | len = min_t(u32, packet_sz, len); | ||
280 | } | ||
281 | cppi41_channel->prog_len = len; | ||
282 | direction = cppi41_channel->is_tx ? DMA_MEM_TO_DEV : DMA_DEV_TO_MEM; | ||
283 | dma_desc = dmaengine_prep_slave_single(dc, dma_addr, len, direction, | ||
284 | DMA_PREP_INTERRUPT | DMA_CTRL_ACK); | ||
285 | if (!dma_desc) | ||
286 | return false; | ||
287 | |||
288 | dma_desc->callback = cppi41_dma_callback; | ||
289 | dma_desc->callback_param = channel; | ||
290 | cppi41_channel->cookie = dma_desc->tx_submit(dma_desc); | ||
291 | |||
292 | save_rx_toggle(cppi41_channel); | ||
293 | dma_async_issue_pending(dc); | ||
294 | return true; | ||
295 | } | ||
296 | |||
297 | static struct dma_channel *cppi41_dma_channel_allocate(struct dma_controller *c, | ||
298 | struct musb_hw_ep *hw_ep, u8 is_tx) | ||
299 | { | ||
300 | struct cppi41_dma_controller *controller = container_of(c, | ||
301 | struct cppi41_dma_controller, controller); | ||
302 | struct cppi41_dma_channel *cppi41_channel = NULL; | ||
303 | u8 ch_num = hw_ep->epnum - 1; | ||
304 | |||
305 | if (ch_num >= MUSB_DMA_NUM_CHANNELS) | ||
306 | return NULL; | ||
307 | |||
308 | if (is_tx) | ||
309 | cppi41_channel = &controller->tx_channel[ch_num]; | ||
310 | else | ||
311 | cppi41_channel = &controller->rx_channel[ch_num]; | ||
312 | |||
313 | if (!cppi41_channel->dc) | ||
314 | return NULL; | ||
315 | |||
316 | if (cppi41_channel->is_allocated) | ||
317 | return NULL; | ||
318 | |||
319 | cppi41_channel->hw_ep = hw_ep; | ||
320 | cppi41_channel->is_allocated = 1; | ||
321 | |||
322 | return &cppi41_channel->channel; | ||
323 | } | ||
324 | |||
325 | static void cppi41_dma_channel_release(struct dma_channel *channel) | ||
326 | { | ||
327 | struct cppi41_dma_channel *cppi41_channel = channel->private_data; | ||
328 | |||
329 | if (cppi41_channel->is_allocated) { | ||
330 | cppi41_channel->is_allocated = 0; | ||
331 | channel->status = MUSB_DMA_STATUS_FREE; | ||
332 | channel->actual_len = 0; | ||
333 | } | ||
334 | } | ||
335 | |||
336 | static int cppi41_dma_channel_program(struct dma_channel *channel, | ||
337 | u16 packet_sz, u8 mode, | ||
338 | dma_addr_t dma_addr, u32 len) | ||
339 | { | ||
340 | int ret; | ||
341 | |||
342 | BUG_ON(channel->status == MUSB_DMA_STATUS_UNKNOWN || | ||
343 | channel->status == MUSB_DMA_STATUS_BUSY); | ||
344 | |||
345 | channel->status = MUSB_DMA_STATUS_BUSY; | ||
346 | channel->actual_len = 0; | ||
347 | ret = cppi41_configure_channel(channel, packet_sz, mode, dma_addr, len); | ||
348 | if (!ret) | ||
349 | channel->status = MUSB_DMA_STATUS_FREE; | ||
350 | |||
351 | return ret; | ||
352 | } | ||
353 | |||
354 | static int cppi41_is_compatible(struct dma_channel *channel, u16 maxpacket, | ||
355 | void *buf, u32 length) | ||
356 | { | ||
357 | struct cppi41_dma_channel *cppi41_channel = channel->private_data; | ||
358 | struct cppi41_dma_controller *controller = cppi41_channel->controller; | ||
359 | struct musb *musb = controller->musb; | ||
360 | |||
361 | if (is_host_active(musb)) { | ||
362 | WARN_ON(1); | ||
363 | return 1; | ||
364 | } | ||
365 | if (cppi41_channel->is_tx) | ||
366 | return 1; | ||
367 | /* AM335x Advisory 1.0.13. No workaround for device RX mode */ | ||
368 | return 0; | ||
369 | } | ||
370 | |||
371 | static int cppi41_dma_channel_abort(struct dma_channel *channel) | ||
372 | { | ||
373 | struct cppi41_dma_channel *cppi41_channel = channel->private_data; | ||
374 | struct cppi41_dma_controller *controller = cppi41_channel->controller; | ||
375 | struct musb *musb = controller->musb; | ||
376 | void __iomem *epio = cppi41_channel->hw_ep->regs; | ||
377 | int tdbit; | ||
378 | int ret; | ||
379 | unsigned is_tx; | ||
380 | u16 csr; | ||
381 | |||
382 | is_tx = cppi41_channel->is_tx; | ||
383 | dev_dbg(musb->controller, "abort channel=%d, is_tx=%d\n", | ||
384 | cppi41_channel->port_num, is_tx); | ||
385 | |||
386 | if (cppi41_channel->channel.status == MUSB_DMA_STATUS_FREE) | ||
387 | return 0; | ||
388 | |||
389 | if (is_tx) { | ||
390 | csr = musb_readw(epio, MUSB_TXCSR); | ||
391 | csr &= ~MUSB_TXCSR_DMAENAB; | ||
392 | musb_writew(epio, MUSB_TXCSR, csr); | ||
393 | } else { | ||
394 | csr = musb_readw(epio, MUSB_RXCSR); | ||
395 | csr &= ~(MUSB_RXCSR_H_REQPKT | MUSB_RXCSR_DMAENAB); | ||
396 | musb_writew(epio, MUSB_RXCSR, csr); | ||
397 | |||
398 | csr = musb_readw(epio, MUSB_RXCSR); | ||
399 | if (csr & MUSB_RXCSR_RXPKTRDY) { | ||
400 | csr |= MUSB_RXCSR_FLUSHFIFO; | ||
401 | musb_writew(epio, MUSB_RXCSR, csr); | ||
402 | musb_writew(epio, MUSB_RXCSR, csr); | ||
403 | } | ||
404 | } | ||
405 | |||
406 | tdbit = 1 << cppi41_channel->port_num; | ||
407 | if (is_tx) | ||
408 | tdbit <<= 16; | ||
409 | |||
410 | do { | ||
411 | musb_writel(musb->ctrl_base, USB_TDOWN, tdbit); | ||
412 | ret = dmaengine_terminate_all(cppi41_channel->dc); | ||
413 | } while (ret == -EAGAIN); | ||
414 | |||
415 | musb_writel(musb->ctrl_base, USB_TDOWN, tdbit); | ||
416 | |||
417 | if (is_tx) { | ||
418 | csr = musb_readw(epio, MUSB_TXCSR); | ||
419 | if (csr & MUSB_TXCSR_TXPKTRDY) { | ||
420 | csr |= MUSB_TXCSR_FLUSHFIFO; | ||
421 | musb_writew(epio, MUSB_TXCSR, csr); | ||
422 | } | ||
423 | } | ||
424 | |||
425 | cppi41_channel->channel.status = MUSB_DMA_STATUS_FREE; | ||
426 | return 0; | ||
427 | } | ||
428 | |||
429 | static void cppi41_release_all_dma_chans(struct cppi41_dma_controller *ctrl) | ||
430 | { | ||
431 | struct dma_chan *dc; | ||
432 | int i; | ||
433 | |||
434 | for (i = 0; i < MUSB_DMA_NUM_CHANNELS; i++) { | ||
435 | dc = ctrl->tx_channel[i].dc; | ||
436 | if (dc) | ||
437 | dma_release_channel(dc); | ||
438 | dc = ctrl->rx_channel[i].dc; | ||
439 | if (dc) | ||
440 | dma_release_channel(dc); | ||
441 | } | ||
442 | } | ||
443 | |||
444 | static void cppi41_dma_controller_stop(struct cppi41_dma_controller *controller) | ||
445 | { | ||
446 | cppi41_release_all_dma_chans(controller); | ||
447 | } | ||
448 | |||
449 | static int cppi41_dma_controller_start(struct cppi41_dma_controller *controller) | ||
450 | { | ||
451 | struct musb *musb = controller->musb; | ||
452 | struct device *dev = musb->controller; | ||
453 | struct device_node *np = dev->of_node; | ||
454 | struct cppi41_dma_channel *cppi41_channel; | ||
455 | int count; | ||
456 | int i; | ||
457 | int ret; | ||
458 | |||
459 | count = of_property_count_strings(np, "dma-names"); | ||
460 | if (count < 0) | ||
461 | return count; | ||
462 | |||
463 | for (i = 0; i < count; i++) { | ||
464 | struct dma_chan *dc; | ||
465 | struct dma_channel *musb_dma; | ||
466 | const char *str; | ||
467 | unsigned is_tx; | ||
468 | unsigned int port; | ||
469 | |||
470 | ret = of_property_read_string_index(np, "dma-names", i, &str); | ||
471 | if (ret) | ||
472 | goto err; | ||
473 | if (!strncmp(str, "tx", 2)) | ||
474 | is_tx = 1; | ||
475 | else if (!strncmp(str, "rx", 2)) | ||
476 | is_tx = 0; | ||
477 | else { | ||
478 | dev_err(dev, "Wrong dmatype %s\n", str); | ||
479 | goto err; | ||
480 | } | ||
481 | ret = kstrtouint(str + 2, 0, &port); | ||
482 | if (ret) | ||
483 | goto err; | ||
484 | |||
485 | if (port > MUSB_DMA_NUM_CHANNELS || !port) | ||
486 | goto err; | ||
487 | if (is_tx) | ||
488 | cppi41_channel = &controller->tx_channel[port - 1]; | ||
489 | else | ||
490 | cppi41_channel = &controller->rx_channel[port - 1]; | ||
491 | |||
492 | cppi41_channel->controller = controller; | ||
493 | cppi41_channel->port_num = port; | ||
494 | cppi41_channel->is_tx = is_tx; | ||
495 | |||
496 | musb_dma = &cppi41_channel->channel; | ||
497 | musb_dma->private_data = cppi41_channel; | ||
498 | musb_dma->status = MUSB_DMA_STATUS_FREE; | ||
499 | musb_dma->max_len = SZ_4M; | ||
500 | |||
501 | dc = dma_request_slave_channel(dev, str); | ||
502 | if (!dc) { | ||
503 | dev_err(dev, "Falied to request %s.\n", str); | ||
504 | goto err; | ||
505 | } | ||
506 | cppi41_channel->dc = dc; | ||
507 | } | ||
508 | return 0; | ||
509 | err: | ||
510 | cppi41_release_all_dma_chans(controller); | ||
511 | return -EINVAL; | ||
512 | } | ||
513 | |||
514 | void dma_controller_destroy(struct dma_controller *c) | ||
515 | { | ||
516 | struct cppi41_dma_controller *controller = container_of(c, | ||
517 | struct cppi41_dma_controller, controller); | ||
518 | |||
519 | cppi41_dma_controller_stop(controller); | ||
520 | kfree(controller); | ||
521 | } | ||
522 | |||
523 | struct dma_controller *dma_controller_create(struct musb *musb, | ||
524 | void __iomem *base) | ||
525 | { | ||
526 | struct cppi41_dma_controller *controller; | ||
527 | int ret; | ||
528 | |||
529 | if (!musb->controller->of_node) { | ||
530 | dev_err(musb->controller, "Need DT for the DMA engine.\n"); | ||
531 | return NULL; | ||
532 | } | ||
533 | |||
534 | controller = kzalloc(sizeof(*controller), GFP_KERNEL); | ||
535 | if (!controller) | ||
536 | goto kzalloc_fail; | ||
537 | |||
538 | controller->musb = musb; | ||
539 | |||
540 | controller->controller.channel_alloc = cppi41_dma_channel_allocate; | ||
541 | controller->controller.channel_release = cppi41_dma_channel_release; | ||
542 | controller->controller.channel_program = cppi41_dma_channel_program; | ||
543 | controller->controller.channel_abort = cppi41_dma_channel_abort; | ||
544 | controller->controller.is_compatible = cppi41_is_compatible; | ||
545 | |||
546 | ret = cppi41_dma_controller_start(controller); | ||
547 | if (ret) | ||
548 | goto plat_get_fail; | ||
549 | return &controller->controller; | ||
550 | |||
551 | plat_get_fail: | ||
552 | kfree(controller); | ||
553 | kzalloc_fail: | ||
554 | return NULL; | ||
555 | } | ||
diff --git a/drivers/usb/musb/musb_dma.h b/drivers/usb/musb/musb_dma.h index 1b6b827b769f..1345a4ff041a 100644 --- a/drivers/usb/musb/musb_dma.h +++ b/drivers/usb/musb/musb_dma.h | |||
@@ -62,13 +62,13 @@ struct musb_hw_ep; | |||
62 | 62 | ||
63 | #define DMA_ADDR_INVALID (~(dma_addr_t)0) | 63 | #define DMA_ADDR_INVALID (~(dma_addr_t)0) |
64 | 64 | ||
65 | #ifndef CONFIG_MUSB_PIO_ONLY | 65 | #ifdef CONFIG_MUSB_PIO_ONLY |
66 | #define is_dma_capable() (1) | ||
67 | #else | ||
68 | #define is_dma_capable() (0) | 66 | #define is_dma_capable() (0) |
67 | #else | ||
68 | #define is_dma_capable() (1) | ||
69 | #endif | 69 | #endif |
70 | 70 | ||
71 | #ifdef CONFIG_USB_TI_CPPI_DMA | 71 | #if defined(CONFIG_USB_TI_CPPI_DMA) || defined(CONFIG_USB_TI_CPPI41_DMA) |
72 | #define is_cppi_enabled() 1 | 72 | #define is_cppi_enabled() 1 |
73 | #else | 73 | #else |
74 | #define is_cppi_enabled() 0 | 74 | #define is_cppi_enabled() 0 |
@@ -159,8 +159,6 @@ dma_channel_status(struct dma_channel *c) | |||
159 | * Controllers manage dma channels. | 159 | * Controllers manage dma channels. |
160 | */ | 160 | */ |
161 | struct dma_controller { | 161 | struct dma_controller { |
162 | int (*start)(struct dma_controller *); | ||
163 | int (*stop)(struct dma_controller *); | ||
164 | struct dma_channel *(*channel_alloc)(struct dma_controller *, | 162 | struct dma_channel *(*channel_alloc)(struct dma_controller *, |
165 | struct musb_hw_ep *, u8 is_tx); | 163 | struct musb_hw_ep *, u8 is_tx); |
166 | void (*channel_release)(struct dma_channel *); | 164 | void (*channel_release)(struct dma_channel *); |
@@ -177,9 +175,20 @@ struct dma_controller { | |||
177 | /* called after channel_program(), may indicate a fault */ | 175 | /* called after channel_program(), may indicate a fault */ |
178 | extern void musb_dma_completion(struct musb *musb, u8 epnum, u8 transmit); | 176 | extern void musb_dma_completion(struct musb *musb, u8 epnum, u8 transmit); |
179 | 177 | ||
178 | #ifdef CONFIG_MUSB_PIO_ONLY | ||
179 | static inline struct dma_controller *dma_controller_create(struct musb *m, | ||
180 | void __iomem *io) | ||
181 | { | ||
182 | return NULL; | ||
183 | } | ||
184 | |||
185 | static inline void dma_controller_destroy(struct dma_controller *d) { } | ||
186 | |||
187 | #else | ||
180 | 188 | ||
181 | extern struct dma_controller *dma_controller_create(struct musb *, void __iomem *); | 189 | extern struct dma_controller *dma_controller_create(struct musb *, void __iomem *); |
182 | 190 | ||
183 | extern void dma_controller_destroy(struct dma_controller *); | 191 | extern void dma_controller_destroy(struct dma_controller *); |
192 | #endif | ||
184 | 193 | ||
185 | #endif /* __MUSB_DMA_H__ */ | 194 | #endif /* __MUSB_DMA_H__ */ |
diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c index 5233804d66b1..4ffbaace7913 100644 --- a/drivers/usb/musb/musb_dsps.c +++ b/drivers/usb/musb/musb_dsps.c | |||
@@ -36,19 +36,18 @@ | |||
36 | #include <linux/dma-mapping.h> | 36 | #include <linux/dma-mapping.h> |
37 | #include <linux/pm_runtime.h> | 37 | #include <linux/pm_runtime.h> |
38 | #include <linux/module.h> | 38 | #include <linux/module.h> |
39 | #include <linux/usb/nop-usb-xceiv.h> | 39 | #include <linux/usb/usb_phy_gen_xceiv.h> |
40 | #include <linux/platform_data/usb-omap.h> | 40 | #include <linux/platform_data/usb-omap.h> |
41 | #include <linux/sizes.h> | 41 | #include <linux/sizes.h> |
42 | 42 | ||
43 | #include <linux/of.h> | 43 | #include <linux/of.h> |
44 | #include <linux/of_device.h> | 44 | #include <linux/of_device.h> |
45 | #include <linux/of_address.h> | 45 | #include <linux/of_address.h> |
46 | #include <linux/of_irq.h> | ||
46 | 47 | ||
47 | #include "musb_core.h" | 48 | #include "musb_core.h" |
48 | 49 | ||
49 | #ifdef CONFIG_OF | ||
50 | static const struct of_device_id musb_dsps_of_match[]; | 50 | static const struct of_device_id musb_dsps_of_match[]; |
51 | #endif | ||
52 | 51 | ||
53 | /** | 52 | /** |
54 | * avoid using musb_readx()/musb_writex() as glue layer should not be | 53 | * avoid using musb_readx()/musb_writex() as glue layer should not be |
@@ -75,7 +74,6 @@ struct dsps_musb_wrapper { | |||
75 | u16 revision; | 74 | u16 revision; |
76 | u16 control; | 75 | u16 control; |
77 | u16 status; | 76 | u16 status; |
78 | u16 eoi; | ||
79 | u16 epintr_set; | 77 | u16 epintr_set; |
80 | u16 epintr_clear; | 78 | u16 epintr_clear; |
81 | u16 epintr_status; | 79 | u16 epintr_status; |
@@ -108,10 +106,7 @@ struct dsps_musb_wrapper { | |||
108 | /* bit positions for mode */ | 106 | /* bit positions for mode */ |
109 | unsigned iddig:5; | 107 | unsigned iddig:5; |
110 | /* miscellaneous stuff */ | 108 | /* miscellaneous stuff */ |
111 | u32 musb_core_offset; | ||
112 | u8 poll_seconds; | 109 | u8 poll_seconds; |
113 | /* number of musb instances */ | ||
114 | u8 instances; | ||
115 | }; | 110 | }; |
116 | 111 | ||
117 | /** | 112 | /** |
@@ -119,53 +114,12 @@ struct dsps_musb_wrapper { | |||
119 | */ | 114 | */ |
120 | struct dsps_glue { | 115 | struct dsps_glue { |
121 | struct device *dev; | 116 | struct device *dev; |
122 | struct platform_device *musb[2]; /* child musb pdev */ | 117 | struct platform_device *musb; /* child musb pdev */ |
123 | const struct dsps_musb_wrapper *wrp; /* wrapper register offsets */ | 118 | const struct dsps_musb_wrapper *wrp; /* wrapper register offsets */ |
124 | struct timer_list timer[2]; /* otg_workaround timer */ | 119 | struct timer_list timer; /* otg_workaround timer */ |
125 | unsigned long last_timer[2]; /* last timer data for each instance */ | 120 | unsigned long last_timer; /* last timer data for each instance */ |
126 | u32 __iomem *usb_ctrl[2]; | ||
127 | }; | 121 | }; |
128 | 122 | ||
129 | #define DSPS_AM33XX_CONTROL_MODULE_PHYS_0 0x44e10620 | ||
130 | #define DSPS_AM33XX_CONTROL_MODULE_PHYS_1 0x44e10628 | ||
131 | |||
132 | static const resource_size_t dsps_control_module_phys[] = { | ||
133 | DSPS_AM33XX_CONTROL_MODULE_PHYS_0, | ||
134 | DSPS_AM33XX_CONTROL_MODULE_PHYS_1, | ||
135 | }; | ||
136 | |||
137 | #define USBPHY_CM_PWRDN (1 << 0) | ||
138 | #define USBPHY_OTG_PWRDN (1 << 1) | ||
139 | #define USBPHY_OTGVDET_EN (1 << 19) | ||
140 | #define USBPHY_OTGSESSEND_EN (1 << 20) | ||
141 | |||
142 | /** | ||
143 | * musb_dsps_phy_control - phy on/off | ||
144 | * @glue: struct dsps_glue * | ||
145 | * @id: musb instance | ||
146 | * @on: flag for phy to be switched on or off | ||
147 | * | ||
148 | * This is to enable the PHY using usb_ctrl register in system control | ||
149 | * module space. | ||
150 | * | ||
151 | * XXX: This function will be removed once we have a seperate driver for | ||
152 | * control module | ||
153 | */ | ||
154 | static void musb_dsps_phy_control(struct dsps_glue *glue, u8 id, u8 on) | ||
155 | { | ||
156 | u32 usbphycfg; | ||
157 | |||
158 | usbphycfg = readl(glue->usb_ctrl[id]); | ||
159 | |||
160 | if (on) { | ||
161 | usbphycfg &= ~(USBPHY_CM_PWRDN | USBPHY_OTG_PWRDN); | ||
162 | usbphycfg |= USBPHY_OTGVDET_EN | USBPHY_OTGSESSEND_EN; | ||
163 | } else { | ||
164 | usbphycfg |= USBPHY_CM_PWRDN | USBPHY_OTG_PWRDN; | ||
165 | } | ||
166 | |||
167 | writel(usbphycfg, glue->usb_ctrl[id]); | ||
168 | } | ||
169 | /** | 123 | /** |
170 | * dsps_musb_enable - enable interrupts | 124 | * dsps_musb_enable - enable interrupts |
171 | */ | 125 | */ |
@@ -205,7 +159,6 @@ static void dsps_musb_disable(struct musb *musb) | |||
205 | dsps_writel(reg_base, wrp->epintr_clear, | 159 | dsps_writel(reg_base, wrp->epintr_clear, |
206 | wrp->txep_bitmap | wrp->rxep_bitmap); | 160 | wrp->txep_bitmap | wrp->rxep_bitmap); |
207 | dsps_writeb(musb->mregs, MUSB_DEVCTL, 0); | 161 | dsps_writeb(musb->mregs, MUSB_DEVCTL, 0); |
208 | dsps_writel(reg_base, wrp->eoi, 0); | ||
209 | } | 162 | } |
210 | 163 | ||
211 | static void otg_timer(unsigned long _musb) | 164 | static void otg_timer(unsigned long _musb) |
@@ -213,7 +166,6 @@ static void otg_timer(unsigned long _musb) | |||
213 | struct musb *musb = (void *)_musb; | 166 | struct musb *musb = (void *)_musb; |
214 | void __iomem *mregs = musb->mregs; | 167 | void __iomem *mregs = musb->mregs; |
215 | struct device *dev = musb->controller; | 168 | struct device *dev = musb->controller; |
216 | struct platform_device *pdev = to_platform_device(dev); | ||
217 | struct dsps_glue *glue = dev_get_drvdata(dev->parent); | 169 | struct dsps_glue *glue = dev_get_drvdata(dev->parent); |
218 | const struct dsps_musb_wrapper *wrp = glue->wrp; | 170 | const struct dsps_musb_wrapper *wrp = glue->wrp; |
219 | u8 devctl; | 171 | u8 devctl; |
@@ -250,7 +202,7 @@ static void otg_timer(unsigned long _musb) | |||
250 | case OTG_STATE_B_IDLE: | 202 | case OTG_STATE_B_IDLE: |
251 | devctl = dsps_readb(mregs, MUSB_DEVCTL); | 203 | devctl = dsps_readb(mregs, MUSB_DEVCTL); |
252 | if (devctl & MUSB_DEVCTL_BDEVICE) | 204 | if (devctl & MUSB_DEVCTL_BDEVICE) |
253 | mod_timer(&glue->timer[pdev->id], | 205 | mod_timer(&glue->timer, |
254 | jiffies + wrp->poll_seconds * HZ); | 206 | jiffies + wrp->poll_seconds * HZ); |
255 | else | 207 | else |
256 | musb->xceiv->state = OTG_STATE_A_IDLE; | 208 | musb->xceiv->state = OTG_STATE_A_IDLE; |
@@ -264,7 +216,6 @@ static void otg_timer(unsigned long _musb) | |||
264 | static void dsps_musb_try_idle(struct musb *musb, unsigned long timeout) | 216 | static void dsps_musb_try_idle(struct musb *musb, unsigned long timeout) |
265 | { | 217 | { |
266 | struct device *dev = musb->controller; | 218 | struct device *dev = musb->controller; |
267 | struct platform_device *pdev = to_platform_device(dev); | ||
268 | struct dsps_glue *glue = dev_get_drvdata(dev->parent); | 219 | struct dsps_glue *glue = dev_get_drvdata(dev->parent); |
269 | 220 | ||
270 | if (timeout == 0) | 221 | if (timeout == 0) |
@@ -275,23 +226,23 @@ static void dsps_musb_try_idle(struct musb *musb, unsigned long timeout) | |||
275 | musb->xceiv->state == OTG_STATE_A_WAIT_BCON)) { | 226 | musb->xceiv->state == OTG_STATE_A_WAIT_BCON)) { |
276 | dev_dbg(musb->controller, "%s active, deleting timer\n", | 227 | dev_dbg(musb->controller, "%s active, deleting timer\n", |
277 | usb_otg_state_string(musb->xceiv->state)); | 228 | usb_otg_state_string(musb->xceiv->state)); |
278 | del_timer(&glue->timer[pdev->id]); | 229 | del_timer(&glue->timer); |
279 | glue->last_timer[pdev->id] = jiffies; | 230 | glue->last_timer = jiffies; |
280 | return; | 231 | return; |
281 | } | 232 | } |
282 | 233 | ||
283 | if (time_after(glue->last_timer[pdev->id], timeout) && | 234 | if (time_after(glue->last_timer, timeout) && |
284 | timer_pending(&glue->timer[pdev->id])) { | 235 | timer_pending(&glue->timer)) { |
285 | dev_dbg(musb->controller, | 236 | dev_dbg(musb->controller, |
286 | "Longer idle timer already pending, ignoring...\n"); | 237 | "Longer idle timer already pending, ignoring...\n"); |
287 | return; | 238 | return; |
288 | } | 239 | } |
289 | glue->last_timer[pdev->id] = timeout; | 240 | glue->last_timer = timeout; |
290 | 241 | ||
291 | dev_dbg(musb->controller, "%s inactive, starting idle timer for %u ms\n", | 242 | dev_dbg(musb->controller, "%s inactive, starting idle timer for %u ms\n", |
292 | usb_otg_state_string(musb->xceiv->state), | 243 | usb_otg_state_string(musb->xceiv->state), |
293 | jiffies_to_msecs(timeout - jiffies)); | 244 | jiffies_to_msecs(timeout - jiffies)); |
294 | mod_timer(&glue->timer[pdev->id], timeout); | 245 | mod_timer(&glue->timer, timeout); |
295 | } | 246 | } |
296 | 247 | ||
297 | static irqreturn_t dsps_interrupt(int irq, void *hci) | 248 | static irqreturn_t dsps_interrupt(int irq, void *hci) |
@@ -299,7 +250,6 @@ static irqreturn_t dsps_interrupt(int irq, void *hci) | |||
299 | struct musb *musb = hci; | 250 | struct musb *musb = hci; |
300 | void __iomem *reg_base = musb->ctrl_base; | 251 | void __iomem *reg_base = musb->ctrl_base; |
301 | struct device *dev = musb->controller; | 252 | struct device *dev = musb->controller; |
302 | struct platform_device *pdev = to_platform_device(dev); | ||
303 | struct dsps_glue *glue = dev_get_drvdata(dev->parent); | 253 | struct dsps_glue *glue = dev_get_drvdata(dev->parent); |
304 | const struct dsps_musb_wrapper *wrp = glue->wrp; | 254 | const struct dsps_musb_wrapper *wrp = glue->wrp; |
305 | unsigned long flags; | 255 | unsigned long flags; |
@@ -319,7 +269,7 @@ static irqreturn_t dsps_interrupt(int irq, void *hci) | |||
319 | /* Get usb core interrupts */ | 269 | /* Get usb core interrupts */ |
320 | usbintr = dsps_readl(reg_base, wrp->coreintr_status); | 270 | usbintr = dsps_readl(reg_base, wrp->coreintr_status); |
321 | if (!usbintr && !epintr) | 271 | if (!usbintr && !epintr) |
322 | goto eoi; | 272 | goto out; |
323 | 273 | ||
324 | musb->int_usb = (usbintr & wrp->usb_bitmap) >> wrp->usb_shift; | 274 | musb->int_usb = (usbintr & wrp->usb_bitmap) >> wrp->usb_shift; |
325 | if (usbintr) | 275 | if (usbintr) |
@@ -359,7 +309,7 @@ static irqreturn_t dsps_interrupt(int irq, void *hci) | |||
359 | */ | 309 | */ |
360 | musb->int_usb &= ~MUSB_INTR_VBUSERROR; | 310 | musb->int_usb &= ~MUSB_INTR_VBUSERROR; |
361 | musb->xceiv->state = OTG_STATE_A_WAIT_VFALL; | 311 | musb->xceiv->state = OTG_STATE_A_WAIT_VFALL; |
362 | mod_timer(&glue->timer[pdev->id], | 312 | mod_timer(&glue->timer, |
363 | jiffies + wrp->poll_seconds * HZ); | 313 | jiffies + wrp->poll_seconds * HZ); |
364 | WARNING("VBUS error workaround (delay coming)\n"); | 314 | WARNING("VBUS error workaround (delay coming)\n"); |
365 | } else if (drvvbus) { | 315 | } else if (drvvbus) { |
@@ -367,7 +317,7 @@ static irqreturn_t dsps_interrupt(int irq, void *hci) | |||
367 | MUSB_HST_MODE(musb); | 317 | MUSB_HST_MODE(musb); |
368 | musb->xceiv->otg->default_a = 1; | 318 | musb->xceiv->otg->default_a = 1; |
369 | musb->xceiv->state = OTG_STATE_A_WAIT_VRISE; | 319 | musb->xceiv->state = OTG_STATE_A_WAIT_VRISE; |
370 | del_timer(&glue->timer[pdev->id]); | 320 | del_timer(&glue->timer); |
371 | } else { | 321 | } else { |
372 | musb->is_active = 0; | 322 | musb->is_active = 0; |
373 | MUSB_DEV_MODE(musb); | 323 | MUSB_DEV_MODE(musb); |
@@ -387,16 +337,10 @@ static irqreturn_t dsps_interrupt(int irq, void *hci) | |||
387 | if (musb->int_tx || musb->int_rx || musb->int_usb) | 337 | if (musb->int_tx || musb->int_rx || musb->int_usb) |
388 | ret |= musb_interrupt(musb); | 338 | ret |= musb_interrupt(musb); |
389 | 339 | ||
390 | eoi: | ||
391 | /* EOI needs to be written for the IRQ to be re-asserted. */ | ||
392 | if (ret == IRQ_HANDLED || epintr || usbintr) | ||
393 | dsps_writel(reg_base, wrp->eoi, 1); | ||
394 | |||
395 | /* Poll for ID change */ | 340 | /* Poll for ID change */ |
396 | if (musb->xceiv->state == OTG_STATE_B_IDLE) | 341 | if (musb->xceiv->state == OTG_STATE_B_IDLE) |
397 | mod_timer(&glue->timer[pdev->id], | 342 | mod_timer(&glue->timer, jiffies + wrp->poll_seconds * HZ); |
398 | jiffies + wrp->poll_seconds * HZ); | 343 | out: |
399 | |||
400 | spin_unlock_irqrestore(&musb->lock, flags); | 344 | spin_unlock_irqrestore(&musb->lock, flags); |
401 | 345 | ||
402 | return ret; | 346 | return ret; |
@@ -405,37 +349,38 @@ static irqreturn_t dsps_interrupt(int irq, void *hci) | |||
405 | static int dsps_musb_init(struct musb *musb) | 349 | static int dsps_musb_init(struct musb *musb) |
406 | { | 350 | { |
407 | struct device *dev = musb->controller; | 351 | struct device *dev = musb->controller; |
408 | struct platform_device *pdev = to_platform_device(dev); | ||
409 | struct dsps_glue *glue = dev_get_drvdata(dev->parent); | 352 | struct dsps_glue *glue = dev_get_drvdata(dev->parent); |
353 | struct platform_device *parent = to_platform_device(dev->parent); | ||
410 | const struct dsps_musb_wrapper *wrp = glue->wrp; | 354 | const struct dsps_musb_wrapper *wrp = glue->wrp; |
411 | void __iomem *reg_base = musb->ctrl_base; | 355 | void __iomem *reg_base; |
356 | struct resource *r; | ||
412 | u32 rev, val; | 357 | u32 rev, val; |
413 | int status; | ||
414 | 358 | ||
415 | /* mentor core register starts at offset of 0x400 from musb base */ | 359 | r = platform_get_resource_byname(parent, IORESOURCE_MEM, "control"); |
416 | musb->mregs += wrp->musb_core_offset; | 360 | if (!r) |
361 | return -EINVAL; | ||
362 | |||
363 | reg_base = devm_ioremap_resource(dev, r); | ||
364 | if (!musb->ctrl_base) | ||
365 | return -EINVAL; | ||
366 | musb->ctrl_base = reg_base; | ||
417 | 367 | ||
418 | /* NOP driver needs change if supporting dual instance */ | 368 | /* NOP driver needs change if supporting dual instance */ |
419 | usb_nop_xceiv_register(); | 369 | musb->xceiv = devm_usb_get_phy_by_phandle(dev, "phys", 0); |
420 | musb->xceiv = usb_get_phy(USB_PHY_TYPE_USB2); | 370 | if (IS_ERR(musb->xceiv)) |
421 | if (IS_ERR_OR_NULL(musb->xceiv)) | 371 | return PTR_ERR(musb->xceiv); |
422 | return -EPROBE_DEFER; | ||
423 | 372 | ||
424 | /* Returns zero if e.g. not clocked */ | 373 | /* Returns zero if e.g. not clocked */ |
425 | rev = dsps_readl(reg_base, wrp->revision); | 374 | rev = dsps_readl(reg_base, wrp->revision); |
426 | if (!rev) { | 375 | if (!rev) |
427 | status = -ENODEV; | 376 | return -ENODEV; |
428 | goto err0; | ||
429 | } | ||
430 | 377 | ||
431 | setup_timer(&glue->timer[pdev->id], otg_timer, (unsigned long) musb); | 378 | usb_phy_init(musb->xceiv); |
379 | setup_timer(&glue->timer, otg_timer, (unsigned long) musb); | ||
432 | 380 | ||
433 | /* Reset the musb */ | 381 | /* Reset the musb */ |
434 | dsps_writel(reg_base, wrp->control, (1 << wrp->reset)); | 382 | dsps_writel(reg_base, wrp->control, (1 << wrp->reset)); |
435 | 383 | ||
436 | /* Start the on-chip PHY and its PLL. */ | ||
437 | musb_dsps_phy_control(glue, pdev->id, 1); | ||
438 | |||
439 | musb->isr = dsps_interrupt; | 384 | musb->isr = dsps_interrupt; |
440 | 385 | ||
441 | /* reset the otgdisable bit, needed for host mode to work */ | 386 | /* reset the otgdisable bit, needed for host mode to work */ |
@@ -443,31 +388,17 @@ static int dsps_musb_init(struct musb *musb) | |||
443 | val &= ~(1 << wrp->otg_disable); | 388 | val &= ~(1 << wrp->otg_disable); |
444 | dsps_writel(musb->ctrl_base, wrp->phy_utmi, val); | 389 | dsps_writel(musb->ctrl_base, wrp->phy_utmi, val); |
445 | 390 | ||
446 | /* clear level interrupt */ | ||
447 | dsps_writel(reg_base, wrp->eoi, 0); | ||
448 | |||
449 | return 0; | 391 | return 0; |
450 | err0: | ||
451 | usb_put_phy(musb->xceiv); | ||
452 | usb_nop_xceiv_unregister(); | ||
453 | return status; | ||
454 | } | 392 | } |
455 | 393 | ||
456 | static int dsps_musb_exit(struct musb *musb) | 394 | static int dsps_musb_exit(struct musb *musb) |
457 | { | 395 | { |
458 | struct device *dev = musb->controller; | 396 | struct device *dev = musb->controller; |
459 | struct platform_device *pdev = to_platform_device(dev); | ||
460 | struct dsps_glue *glue = dev_get_drvdata(dev->parent); | 397 | struct dsps_glue *glue = dev_get_drvdata(dev->parent); |
461 | 398 | ||
462 | del_timer_sync(&glue->timer[pdev->id]); | 399 | del_timer_sync(&glue->timer); |
463 | |||
464 | /* Shutdown the on-chip PHY and its PLL. */ | ||
465 | musb_dsps_phy_control(glue, pdev->id, 0); | ||
466 | |||
467 | /* NOP driver needs change if supporting dual instance */ | ||
468 | usb_put_phy(musb->xceiv); | ||
469 | usb_nop_xceiv_unregister(); | ||
470 | 400 | ||
401 | usb_phy_shutdown(musb->xceiv); | ||
471 | return 0; | 402 | return 0; |
472 | } | 403 | } |
473 | 404 | ||
@@ -483,116 +414,98 @@ static struct musb_platform_ops dsps_ops = { | |||
483 | 414 | ||
484 | static u64 musb_dmamask = DMA_BIT_MASK(32); | 415 | static u64 musb_dmamask = DMA_BIT_MASK(32); |
485 | 416 | ||
486 | static int dsps_create_musb_pdev(struct dsps_glue *glue, u8 id) | 417 | static int get_int_prop(struct device_node *dn, const char *s) |
487 | { | 418 | { |
488 | struct device *dev = glue->dev; | 419 | int ret; |
489 | struct platform_device *pdev = to_platform_device(dev); | 420 | u32 val; |
490 | struct musb_hdrc_platform_data *pdata = dev->platform_data; | 421 | |
491 | struct device_node *np = pdev->dev.of_node; | 422 | ret = of_property_read_u32(dn, s, &val); |
492 | struct musb_hdrc_config *config; | 423 | if (ret) |
493 | struct platform_device *musb; | 424 | return 0; |
494 | struct resource *res; | 425 | return val; |
426 | } | ||
427 | |||
428 | static int dsps_create_musb_pdev(struct dsps_glue *glue, | ||
429 | struct platform_device *parent) | ||
430 | { | ||
431 | struct musb_hdrc_platform_data pdata; | ||
495 | struct resource resources[2]; | 432 | struct resource resources[2]; |
496 | char res_name[11]; | 433 | struct device *dev = &parent->dev; |
434 | struct musb_hdrc_config *config; | ||
435 | struct platform_device *musb; | ||
436 | struct device_node *dn = parent->dev.of_node; | ||
437 | struct device_node *child_node; | ||
497 | int ret; | 438 | int ret; |
498 | 439 | ||
499 | resources[0].start = dsps_control_module_phys[id]; | 440 | child_node = of_get_child_by_name(dn, "usb"); |
500 | resources[0].end = resources[0].start + SZ_4 - 1; | 441 | if (!child_node) |
501 | resources[0].flags = IORESOURCE_MEM; | 442 | return -EINVAL; |
502 | 443 | ||
503 | glue->usb_ctrl[id] = devm_ioremap_resource(&pdev->dev, resources); | 444 | memset(resources, 0, sizeof(resources)); |
504 | if (IS_ERR(glue->usb_ctrl[id])) { | 445 | ret = of_address_to_resource(child_node, 0, &resources[0]); |
505 | ret = PTR_ERR(glue->usb_ctrl[id]); | 446 | if (ret) { |
506 | goto err0; | 447 | dev_err(dev, "failed to get memory.\n"); |
448 | return ret; | ||
507 | } | 449 | } |
508 | 450 | ||
509 | /* first resource is for usbss, so start index from 1 */ | 451 | ret = of_irq_to_resource(child_node, 0, &resources[1]); |
510 | res = platform_get_resource(pdev, IORESOURCE_MEM, id + 1); | 452 | if (ret == 0) { |
511 | if (!res) { | 453 | dev_err(dev, "failed to get irq.\n"); |
512 | dev_err(dev, "failed to get memory for instance %d\n", id); | 454 | ret = -EINVAL; |
513 | ret = -ENODEV; | 455 | return ret; |
514 | goto err0; | ||
515 | } | ||
516 | res->parent = NULL; | ||
517 | resources[0] = *res; | ||
518 | |||
519 | /* first resource is for usbss, so start index from 1 */ | ||
520 | res = platform_get_resource(pdev, IORESOURCE_IRQ, id + 1); | ||
521 | if (!res) { | ||
522 | dev_err(dev, "failed to get irq for instance %d\n", id); | ||
523 | ret = -ENODEV; | ||
524 | goto err0; | ||
525 | } | 456 | } |
526 | res->parent = NULL; | ||
527 | resources[1] = *res; | ||
528 | resources[1].name = "mc"; | ||
529 | 457 | ||
530 | /* allocate the child platform device */ | 458 | /* allocate the child platform device */ |
531 | musb = platform_device_alloc("musb-hdrc", PLATFORM_DEVID_AUTO); | 459 | musb = platform_device_alloc("musb-hdrc", PLATFORM_DEVID_AUTO); |
532 | if (!musb) { | 460 | if (!musb) { |
533 | dev_err(dev, "failed to allocate musb device\n"); | 461 | dev_err(dev, "failed to allocate musb device\n"); |
534 | ret = -ENOMEM; | 462 | return -ENOMEM; |
535 | goto err0; | ||
536 | } | 463 | } |
537 | 464 | ||
538 | musb->dev.parent = dev; | 465 | musb->dev.parent = dev; |
539 | musb->dev.dma_mask = &musb_dmamask; | 466 | musb->dev.dma_mask = &musb_dmamask; |
540 | musb->dev.coherent_dma_mask = musb_dmamask; | 467 | musb->dev.coherent_dma_mask = musb_dmamask; |
468 | musb->dev.of_node = of_node_get(child_node); | ||
541 | 469 | ||
542 | glue->musb[id] = musb; | 470 | glue->musb = musb; |
543 | 471 | ||
544 | ret = platform_device_add_resources(musb, resources, 2); | 472 | ret = platform_device_add_resources(musb, resources, |
473 | ARRAY_SIZE(resources)); | ||
545 | if (ret) { | 474 | if (ret) { |
546 | dev_err(dev, "failed to add resources\n"); | 475 | dev_err(dev, "failed to add resources\n"); |
547 | goto err2; | 476 | goto err; |
548 | } | 477 | } |
549 | 478 | ||
550 | if (np) { | 479 | config = devm_kzalloc(&parent->dev, sizeof(*config), GFP_KERNEL); |
551 | pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); | 480 | if (!config) { |
552 | if (!pdata) { | 481 | dev_err(dev, "failed to allocate musb hdrc config\n"); |
553 | dev_err(&pdev->dev, | 482 | ret = -ENOMEM; |
554 | "failed to allocate musb platform data\n"); | 483 | goto err; |
555 | ret = -ENOMEM; | ||
556 | goto err2; | ||
557 | } | ||
558 | |||
559 | config = devm_kzalloc(&pdev->dev, sizeof(*config), GFP_KERNEL); | ||
560 | if (!config) { | ||
561 | dev_err(&pdev->dev, | ||
562 | "failed to allocate musb hdrc config\n"); | ||
563 | ret = -ENOMEM; | ||
564 | goto err2; | ||
565 | } | ||
566 | |||
567 | of_property_read_u32(np, "num-eps", (u32 *)&config->num_eps); | ||
568 | of_property_read_u32(np, "ram-bits", (u32 *)&config->ram_bits); | ||
569 | snprintf(res_name, sizeof(res_name), "port%d-mode", id); | ||
570 | of_property_read_u32(np, res_name, (u32 *)&pdata->mode); | ||
571 | of_property_read_u32(np, "power", (u32 *)&pdata->power); | ||
572 | config->multipoint = of_property_read_bool(np, "multipoint"); | ||
573 | |||
574 | pdata->config = config; | ||
575 | } | 484 | } |
485 | pdata.config = config; | ||
486 | pdata.platform_ops = &dsps_ops; | ||
576 | 487 | ||
577 | pdata->platform_ops = &dsps_ops; | 488 | config->num_eps = get_int_prop(child_node, "num-eps"); |
489 | config->ram_bits = get_int_prop(child_node, "ram-bits"); | ||
490 | pdata.mode = get_int_prop(child_node, "port-mode"); | ||
491 | pdata.power = get_int_prop(child_node, "power"); | ||
492 | config->multipoint = of_property_read_bool(child_node, "multipoint"); | ||
578 | 493 | ||
579 | ret = platform_device_add_data(musb, pdata, sizeof(*pdata)); | 494 | ret = platform_device_add_data(musb, &pdata, sizeof(pdata)); |
580 | if (ret) { | 495 | if (ret) { |
581 | dev_err(dev, "failed to add platform_data\n"); | 496 | dev_err(dev, "failed to add platform_data\n"); |
582 | goto err2; | 497 | goto err; |
583 | } | 498 | } |
584 | 499 | ||
585 | ret = platform_device_add(musb); | 500 | ret = platform_device_add(musb); |
586 | if (ret) { | 501 | if (ret) { |
587 | dev_err(dev, "failed to register musb device\n"); | 502 | dev_err(dev, "failed to register musb device\n"); |
588 | goto err2; | 503 | goto err; |
589 | } | 504 | } |
590 | |||
591 | return 0; | 505 | return 0; |
592 | 506 | ||
593 | err2: | 507 | err: |
594 | platform_device_put(musb); | 508 | platform_device_put(musb); |
595 | err0: | ||
596 | return ret; | 509 | return ret; |
597 | } | 510 | } |
598 | 511 | ||
@@ -601,14 +514,12 @@ static int dsps_probe(struct platform_device *pdev) | |||
601 | const struct of_device_id *match; | 514 | const struct of_device_id *match; |
602 | const struct dsps_musb_wrapper *wrp; | 515 | const struct dsps_musb_wrapper *wrp; |
603 | struct dsps_glue *glue; | 516 | struct dsps_glue *glue; |
604 | struct resource *iomem; | 517 | int ret; |
605 | int ret, i; | ||
606 | 518 | ||
607 | match = of_match_node(musb_dsps_of_match, pdev->dev.of_node); | 519 | match = of_match_node(musb_dsps_of_match, pdev->dev.of_node); |
608 | if (!match) { | 520 | if (!match) { |
609 | dev_err(&pdev->dev, "fail to get matching of_match struct\n"); | 521 | dev_err(&pdev->dev, "fail to get matching of_match struct\n"); |
610 | ret = -EINVAL; | 522 | return -EINVAL; |
611 | goto err0; | ||
612 | } | 523 | } |
613 | wrp = match->data; | 524 | wrp = match->data; |
614 | 525 | ||
@@ -616,29 +527,13 @@ static int dsps_probe(struct platform_device *pdev) | |||
616 | glue = kzalloc(sizeof(*glue), GFP_KERNEL); | 527 | glue = kzalloc(sizeof(*glue), GFP_KERNEL); |
617 | if (!glue) { | 528 | if (!glue) { |
618 | dev_err(&pdev->dev, "unable to allocate glue memory\n"); | 529 | dev_err(&pdev->dev, "unable to allocate glue memory\n"); |
619 | ret = -ENOMEM; | 530 | return -ENOMEM; |
620 | goto err0; | ||
621 | } | ||
622 | |||
623 | /* get memory resource */ | ||
624 | iomem = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
625 | if (!iomem) { | ||
626 | dev_err(&pdev->dev, "failed to get usbss mem resourse\n"); | ||
627 | ret = -ENODEV; | ||
628 | goto err1; | ||
629 | } | 531 | } |
630 | 532 | ||
631 | glue->dev = &pdev->dev; | 533 | glue->dev = &pdev->dev; |
534 | glue->wrp = wrp; | ||
632 | 535 | ||
633 | glue->wrp = kmemdup(wrp, sizeof(*wrp), GFP_KERNEL); | ||
634 | if (!glue->wrp) { | ||
635 | dev_err(&pdev->dev, "failed to duplicate wrapper struct memory\n"); | ||
636 | ret = -ENOMEM; | ||
637 | goto err1; | ||
638 | } | ||
639 | platform_set_drvdata(pdev, glue); | 536 | platform_set_drvdata(pdev, glue); |
640 | |||
641 | /* enable the usbss clocks */ | ||
642 | pm_runtime_enable(&pdev->dev); | 537 | pm_runtime_enable(&pdev->dev); |
643 | 538 | ||
644 | ret = pm_runtime_get_sync(&pdev->dev); | 539 | ret = pm_runtime_get_sync(&pdev->dev); |
@@ -647,17 +542,9 @@ static int dsps_probe(struct platform_device *pdev) | |||
647 | goto err2; | 542 | goto err2; |
648 | } | 543 | } |
649 | 544 | ||
650 | /* create the child platform device for all instances of musb */ | 545 | ret = dsps_create_musb_pdev(glue, pdev); |
651 | for (i = 0; i < wrp->instances ; i++) { | 546 | if (ret) |
652 | ret = dsps_create_musb_pdev(glue, i); | 547 | goto err3; |
653 | if (ret != 0) { | ||
654 | dev_err(&pdev->dev, "failed to create child pdev\n"); | ||
655 | /* release resources of previously created instances */ | ||
656 | for (i--; i >= 0 ; i--) | ||
657 | platform_device_unregister(glue->musb[i]); | ||
658 | goto err3; | ||
659 | } | ||
660 | } | ||
661 | 548 | ||
662 | return 0; | 549 | return 0; |
663 | 550 | ||
@@ -665,65 +552,27 @@ err3: | |||
665 | pm_runtime_put(&pdev->dev); | 552 | pm_runtime_put(&pdev->dev); |
666 | err2: | 553 | err2: |
667 | pm_runtime_disable(&pdev->dev); | 554 | pm_runtime_disable(&pdev->dev); |
668 | kfree(glue->wrp); | ||
669 | err1: | ||
670 | kfree(glue); | 555 | kfree(glue); |
671 | err0: | ||
672 | return ret; | 556 | return ret; |
673 | } | 557 | } |
558 | |||
674 | static int dsps_remove(struct platform_device *pdev) | 559 | static int dsps_remove(struct platform_device *pdev) |
675 | { | 560 | { |
676 | struct dsps_glue *glue = platform_get_drvdata(pdev); | 561 | struct dsps_glue *glue = platform_get_drvdata(pdev); |
677 | const struct dsps_musb_wrapper *wrp = glue->wrp; | ||
678 | int i; | ||
679 | 562 | ||
680 | /* delete the child platform device */ | 563 | platform_device_unregister(glue->musb); |
681 | for (i = 0; i < wrp->instances ; i++) | ||
682 | platform_device_unregister(glue->musb[i]); | ||
683 | 564 | ||
684 | /* disable usbss clocks */ | 565 | /* disable usbss clocks */ |
685 | pm_runtime_put(&pdev->dev); | 566 | pm_runtime_put(&pdev->dev); |
686 | pm_runtime_disable(&pdev->dev); | 567 | pm_runtime_disable(&pdev->dev); |
687 | kfree(glue->wrp); | ||
688 | kfree(glue); | 568 | kfree(glue); |
689 | return 0; | 569 | return 0; |
690 | } | 570 | } |
691 | 571 | ||
692 | #ifdef CONFIG_PM_SLEEP | 572 | static const struct dsps_musb_wrapper am33xx_driver_data = { |
693 | static int dsps_suspend(struct device *dev) | ||
694 | { | ||
695 | struct platform_device *pdev = to_platform_device(dev->parent); | ||
696 | struct dsps_glue *glue = platform_get_drvdata(pdev); | ||
697 | const struct dsps_musb_wrapper *wrp = glue->wrp; | ||
698 | int i; | ||
699 | |||
700 | for (i = 0; i < wrp->instances; i++) | ||
701 | musb_dsps_phy_control(glue, i, 0); | ||
702 | |||
703 | return 0; | ||
704 | } | ||
705 | |||
706 | static int dsps_resume(struct device *dev) | ||
707 | { | ||
708 | struct platform_device *pdev = to_platform_device(dev->parent); | ||
709 | struct dsps_glue *glue = platform_get_drvdata(pdev); | ||
710 | const struct dsps_musb_wrapper *wrp = glue->wrp; | ||
711 | int i; | ||
712 | |||
713 | for (i = 0; i < wrp->instances; i++) | ||
714 | musb_dsps_phy_control(glue, i, 1); | ||
715 | |||
716 | return 0; | ||
717 | } | ||
718 | #endif | ||
719 | |||
720 | static SIMPLE_DEV_PM_OPS(dsps_pm_ops, dsps_suspend, dsps_resume); | ||
721 | |||
722 | static const struct dsps_musb_wrapper ti81xx_driver_data = { | ||
723 | .revision = 0x00, | 573 | .revision = 0x00, |
724 | .control = 0x14, | 574 | .control = 0x14, |
725 | .status = 0x18, | 575 | .status = 0x18, |
726 | .eoi = 0x24, | ||
727 | .epintr_set = 0x38, | 576 | .epintr_set = 0x38, |
728 | .epintr_clear = 0x40, | 577 | .epintr_clear = 0x40, |
729 | .epintr_status = 0x30, | 578 | .epintr_status = 0x30, |
@@ -745,38 +594,23 @@ static const struct dsps_musb_wrapper ti81xx_driver_data = { | |||
745 | .rxep_shift = 16, | 594 | .rxep_shift = 16, |
746 | .rxep_mask = 0xfffe, | 595 | .rxep_mask = 0xfffe, |
747 | .rxep_bitmap = (0xfffe << 16), | 596 | .rxep_bitmap = (0xfffe << 16), |
748 | .musb_core_offset = 0x400, | ||
749 | .poll_seconds = 2, | 597 | .poll_seconds = 2, |
750 | .instances = 1, | ||
751 | }; | ||
752 | |||
753 | static const struct platform_device_id musb_dsps_id_table[] = { | ||
754 | { | ||
755 | .name = "musb-ti81xx", | ||
756 | .driver_data = (kernel_ulong_t) &ti81xx_driver_data, | ||
757 | }, | ||
758 | { }, /* Terminating Entry */ | ||
759 | }; | 598 | }; |
760 | MODULE_DEVICE_TABLE(platform, musb_dsps_id_table); | ||
761 | 599 | ||
762 | #ifdef CONFIG_OF | ||
763 | static const struct of_device_id musb_dsps_of_match[] = { | 600 | static const struct of_device_id musb_dsps_of_match[] = { |
764 | { .compatible = "ti,musb-am33xx", | 601 | { .compatible = "ti,musb-am33xx", |
765 | .data = (void *) &ti81xx_driver_data, }, | 602 | .data = (void *) &am33xx_driver_data, }, |
766 | { }, | 603 | { }, |
767 | }; | 604 | }; |
768 | MODULE_DEVICE_TABLE(of, musb_dsps_of_match); | 605 | MODULE_DEVICE_TABLE(of, musb_dsps_of_match); |
769 | #endif | ||
770 | 606 | ||
771 | static struct platform_driver dsps_usbss_driver = { | 607 | static struct platform_driver dsps_usbss_driver = { |
772 | .probe = dsps_probe, | 608 | .probe = dsps_probe, |
773 | .remove = dsps_remove, | 609 | .remove = dsps_remove, |
774 | .driver = { | 610 | .driver = { |
775 | .name = "musb-dsps", | 611 | .name = "musb-dsps", |
776 | .pm = &dsps_pm_ops, | ||
777 | .of_match_table = of_match_ptr(musb_dsps_of_match), | 612 | .of_match_table = of_match_ptr(musb_dsps_of_match), |
778 | }, | 613 | }, |
779 | .id_table = musb_dsps_id_table, | ||
780 | }; | 614 | }; |
781 | 615 | ||
782 | MODULE_DESCRIPTION("TI DSPS MUSB Glue Layer"); | 616 | MODULE_DESCRIPTION("TI DSPS MUSB Glue Layer"); |
@@ -784,14 +618,4 @@ MODULE_AUTHOR("Ravi B <ravibabu@ti.com>"); | |||
784 | MODULE_AUTHOR("Ajay Kumar Gupta <ajay.gupta@ti.com>"); | 618 | MODULE_AUTHOR("Ajay Kumar Gupta <ajay.gupta@ti.com>"); |
785 | MODULE_LICENSE("GPL v2"); | 619 | MODULE_LICENSE("GPL v2"); |
786 | 620 | ||
787 | static int __init dsps_init(void) | 621 | module_platform_driver(dsps_usbss_driver); |
788 | { | ||
789 | return platform_driver_register(&dsps_usbss_driver); | ||
790 | } | ||
791 | subsys_initcall(dsps_init); | ||
792 | |||
793 | static void __exit dsps_exit(void) | ||
794 | { | ||
795 | platform_driver_unregister(&dsps_usbss_driver); | ||
796 | } | ||
797 | module_exit(dsps_exit); | ||
diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c index 0414bc19d009..4376f51f5ef1 100644 --- a/drivers/usb/musb/musb_gadget.c +++ b/drivers/usb/musb/musb_gadget.c | |||
@@ -357,47 +357,49 @@ static void txstate(struct musb *musb, struct musb_request *req) | |||
357 | } | 357 | } |
358 | } | 358 | } |
359 | 359 | ||
360 | #elif defined(CONFIG_USB_TI_CPPI_DMA) | ||
361 | /* program endpoint CSR first, then setup DMA */ | ||
362 | csr &= ~(MUSB_TXCSR_P_UNDERRUN | MUSB_TXCSR_TXPKTRDY); | ||
363 | csr |= MUSB_TXCSR_DMAENAB | MUSB_TXCSR_DMAMODE | | ||
364 | MUSB_TXCSR_MODE; | ||
365 | musb_writew(epio, MUSB_TXCSR, | ||
366 | (MUSB_TXCSR_P_WZC_BITS & ~MUSB_TXCSR_P_UNDERRUN) | ||
367 | | csr); | ||
368 | |||
369 | /* ensure writebuffer is empty */ | ||
370 | csr = musb_readw(epio, MUSB_TXCSR); | ||
371 | |||
372 | /* NOTE host side sets DMAENAB later than this; both are | ||
373 | * OK since the transfer dma glue (between CPPI and Mentor | ||
374 | * fifos) just tells CPPI it could start. Data only moves | ||
375 | * to the USB TX fifo when both fifos are ready. | ||
376 | */ | ||
377 | |||
378 | /* "mode" is irrelevant here; handle terminating ZLPs like | ||
379 | * PIO does, since the hardware RNDIS mode seems unreliable | ||
380 | * except for the last-packet-is-already-short case. | ||
381 | */ | ||
382 | use_dma = use_dma && c->channel_program( | ||
383 | musb_ep->dma, musb_ep->packet_sz, | ||
384 | 0, | ||
385 | request->dma + request->actual, | ||
386 | request_size); | ||
387 | if (!use_dma) { | ||
388 | c->channel_release(musb_ep->dma); | ||
389 | musb_ep->dma = NULL; | ||
390 | csr &= ~MUSB_TXCSR_DMAENAB; | ||
391 | musb_writew(epio, MUSB_TXCSR, csr); | ||
392 | /* invariant: prequest->buf is non-null */ | ||
393 | } | ||
394 | #elif defined(CONFIG_USB_TUSB_OMAP_DMA) | ||
395 | use_dma = use_dma && c->channel_program( | ||
396 | musb_ep->dma, musb_ep->packet_sz, | ||
397 | request->zero, | ||
398 | request->dma + request->actual, | ||
399 | request_size); | ||
400 | #endif | 360 | #endif |
361 | if (is_cppi_enabled()) { | ||
362 | /* program endpoint CSR first, then setup DMA */ | ||
363 | csr &= ~(MUSB_TXCSR_P_UNDERRUN | MUSB_TXCSR_TXPKTRDY); | ||
364 | csr |= MUSB_TXCSR_DMAENAB | MUSB_TXCSR_DMAMODE | | ||
365 | MUSB_TXCSR_MODE; | ||
366 | musb_writew(epio, MUSB_TXCSR, (MUSB_TXCSR_P_WZC_BITS & | ||
367 | ~MUSB_TXCSR_P_UNDERRUN) | csr); | ||
368 | |||
369 | /* ensure writebuffer is empty */ | ||
370 | csr = musb_readw(epio, MUSB_TXCSR); | ||
371 | |||
372 | /* | ||
373 | * NOTE host side sets DMAENAB later than this; both are | ||
374 | * OK since the transfer dma glue (between CPPI and | ||
375 | * Mentor fifos) just tells CPPI it could start. Data | ||
376 | * only moves to the USB TX fifo when both fifos are | ||
377 | * ready. | ||
378 | */ | ||
379 | /* | ||
380 | * "mode" is irrelevant here; handle terminating ZLPs | ||
381 | * like PIO does, since the hardware RNDIS mode seems | ||
382 | * unreliable except for the | ||
383 | * last-packet-is-already-short case. | ||
384 | */ | ||
385 | use_dma = use_dma && c->channel_program( | ||
386 | musb_ep->dma, musb_ep->packet_sz, | ||
387 | 0, | ||
388 | request->dma + request->actual, | ||
389 | request_size); | ||
390 | if (!use_dma) { | ||
391 | c->channel_release(musb_ep->dma); | ||
392 | musb_ep->dma = NULL; | ||
393 | csr &= ~MUSB_TXCSR_DMAENAB; | ||
394 | musb_writew(epio, MUSB_TXCSR, csr); | ||
395 | /* invariant: prequest->buf is non-null */ | ||
396 | } | ||
397 | } else if (tusb_dma_omap()) | ||
398 | use_dma = use_dma && c->channel_program( | ||
399 | musb_ep->dma, musb_ep->packet_sz, | ||
400 | request->zero, | ||
401 | request->dma + request->actual, | ||
402 | request_size); | ||
401 | } | 403 | } |
402 | #endif | 404 | #endif |
403 | 405 | ||
@@ -1266,7 +1268,8 @@ static int musb_gadget_queue(struct usb_ep *ep, struct usb_request *req, | |||
1266 | dev_dbg(musb->controller, "req %p queued to %s while ep %s\n", | 1268 | dev_dbg(musb->controller, "req %p queued to %s while ep %s\n", |
1267 | req, ep->name, "disabled"); | 1269 | req, ep->name, "disabled"); |
1268 | status = -ESHUTDOWN; | 1270 | status = -ESHUTDOWN; |
1269 | goto cleanup; | 1271 | unmap_dma_buffer(request, musb); |
1272 | goto unlock; | ||
1270 | } | 1273 | } |
1271 | 1274 | ||
1272 | /* add request to the list */ | 1275 | /* add request to the list */ |
@@ -1276,7 +1279,7 @@ static int musb_gadget_queue(struct usb_ep *ep, struct usb_request *req, | |||
1276 | if (!musb_ep->busy && &request->list == musb_ep->req_list.next) | 1279 | if (!musb_ep->busy && &request->list == musb_ep->req_list.next) |
1277 | musb_ep_restart(musb, request); | 1280 | musb_ep_restart(musb, request); |
1278 | 1281 | ||
1279 | cleanup: | 1282 | unlock: |
1280 | spin_unlock_irqrestore(&musb->lock, lockflags); | 1283 | spin_unlock_irqrestore(&musb->lock, lockflags); |
1281 | return status; | 1284 | return status; |
1282 | } | 1285 | } |
diff --git a/drivers/usb/musb/musbhsdma.c b/drivers/usb/musb/musbhsdma.c index 3d1fd52a15a9..e8e9f9aab203 100644 --- a/drivers/usb/musb/musbhsdma.c +++ b/drivers/usb/musb/musbhsdma.c | |||
@@ -37,18 +37,10 @@ | |||
37 | #include "musb_core.h" | 37 | #include "musb_core.h" |
38 | #include "musbhsdma.h" | 38 | #include "musbhsdma.h" |
39 | 39 | ||
40 | static int dma_controller_start(struct dma_controller *c) | ||
41 | { | ||
42 | /* nothing to do */ | ||
43 | return 0; | ||
44 | } | ||
45 | |||
46 | static void dma_channel_release(struct dma_channel *channel); | 40 | static void dma_channel_release(struct dma_channel *channel); |
47 | 41 | ||
48 | static int dma_controller_stop(struct dma_controller *c) | 42 | static void dma_controller_stop(struct musb_dma_controller *controller) |
49 | { | 43 | { |
50 | struct musb_dma_controller *controller = container_of(c, | ||
51 | struct musb_dma_controller, controller); | ||
52 | struct musb *musb = controller->private_data; | 44 | struct musb *musb = controller->private_data; |
53 | struct dma_channel *channel; | 45 | struct dma_channel *channel; |
54 | u8 bit; | 46 | u8 bit; |
@@ -67,8 +59,6 @@ static int dma_controller_stop(struct dma_controller *c) | |||
67 | } | 59 | } |
68 | } | 60 | } |
69 | } | 61 | } |
70 | |||
71 | return 0; | ||
72 | } | 62 | } |
73 | 63 | ||
74 | static struct dma_channel *dma_channel_allocate(struct dma_controller *c, | 64 | static struct dma_channel *dma_channel_allocate(struct dma_controller *c, |
@@ -371,8 +361,7 @@ void dma_controller_destroy(struct dma_controller *c) | |||
371 | struct musb_dma_controller *controller = container_of(c, | 361 | struct musb_dma_controller *controller = container_of(c, |
372 | struct musb_dma_controller, controller); | 362 | struct musb_dma_controller, controller); |
373 | 363 | ||
374 | if (!controller) | 364 | dma_controller_stop(controller); |
375 | return; | ||
376 | 365 | ||
377 | if (controller->irq) | 366 | if (controller->irq) |
378 | free_irq(controller->irq, c); | 367 | free_irq(controller->irq, c); |
@@ -400,8 +389,6 @@ struct dma_controller *dma_controller_create(struct musb *musb, void __iomem *ba | |||
400 | controller->private_data = musb; | 389 | controller->private_data = musb; |
401 | controller->base = base; | 390 | controller->base = base; |
402 | 391 | ||
403 | controller->controller.start = dma_controller_start; | ||
404 | controller->controller.stop = dma_controller_stop; | ||
405 | controller->controller.channel_alloc = dma_channel_allocate; | 392 | controller->controller.channel_alloc = dma_channel_allocate; |
406 | controller->controller.channel_release = dma_channel_release; | 393 | controller->controller.channel_release = dma_channel_release; |
407 | controller->controller.channel_program = dma_channel_program; | 394 | controller->controller.channel_program = dma_channel_program; |
diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c index f44e8b5e00c9..59d2245db1c8 100644 --- a/drivers/usb/musb/omap2430.c +++ b/drivers/usb/musb/omap2430.c | |||
@@ -255,7 +255,7 @@ static void omap_musb_set_mailbox(struct omap2430_glue *glue) | |||
255 | { | 255 | { |
256 | struct musb *musb = glue_to_musb(glue); | 256 | struct musb *musb = glue_to_musb(glue); |
257 | struct device *dev = musb->controller; | 257 | struct device *dev = musb->controller; |
258 | struct musb_hdrc_platform_data *pdata = dev->platform_data; | 258 | struct musb_hdrc_platform_data *pdata = dev_get_platdata(dev); |
259 | struct omap_musb_board_data *data = pdata->board_data; | 259 | struct omap_musb_board_data *data = pdata->board_data; |
260 | struct usb_otg *otg = musb->xceiv->otg; | 260 | struct usb_otg *otg = musb->xceiv->otg; |
261 | 261 | ||
@@ -341,7 +341,7 @@ static int omap2430_musb_init(struct musb *musb) | |||
341 | int status = 0; | 341 | int status = 0; |
342 | struct device *dev = musb->controller; | 342 | struct device *dev = musb->controller; |
343 | struct omap2430_glue *glue = dev_get_drvdata(dev->parent); | 343 | struct omap2430_glue *glue = dev_get_drvdata(dev->parent); |
344 | struct musb_hdrc_platform_data *plat = dev->platform_data; | 344 | struct musb_hdrc_platform_data *plat = dev_get_platdata(dev); |
345 | struct omap_musb_board_data *data = plat->board_data; | 345 | struct omap_musb_board_data *data = plat->board_data; |
346 | 346 | ||
347 | /* We require some kind of external transceiver, hooked | 347 | /* We require some kind of external transceiver, hooked |
@@ -412,7 +412,7 @@ static void omap2430_musb_enable(struct musb *musb) | |||
412 | unsigned long timeout = jiffies + msecs_to_jiffies(1000); | 412 | unsigned long timeout = jiffies + msecs_to_jiffies(1000); |
413 | struct device *dev = musb->controller; | 413 | struct device *dev = musb->controller; |
414 | struct omap2430_glue *glue = dev_get_drvdata(dev->parent); | 414 | struct omap2430_glue *glue = dev_get_drvdata(dev->parent); |
415 | struct musb_hdrc_platform_data *pdata = dev->platform_data; | 415 | struct musb_hdrc_platform_data *pdata = dev_get_platdata(dev); |
416 | struct omap_musb_board_data *data = pdata->board_data; | 416 | struct omap_musb_board_data *data = pdata->board_data; |
417 | 417 | ||
418 | switch (glue->status) { | 418 | switch (glue->status) { |
@@ -482,7 +482,7 @@ static u64 omap2430_dmamask = DMA_BIT_MASK(32); | |||
482 | static int omap2430_probe(struct platform_device *pdev) | 482 | static int omap2430_probe(struct platform_device *pdev) |
483 | { | 483 | { |
484 | struct resource musb_resources[3]; | 484 | struct resource musb_resources[3]; |
485 | struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data; | 485 | struct musb_hdrc_platform_data *pdata = dev_get_platdata(&pdev->dev); |
486 | struct omap_musb_board_data *data; | 486 | struct omap_musb_board_data *data; |
487 | struct platform_device *musb; | 487 | struct platform_device *musb; |
488 | struct omap2430_glue *glue; | 488 | struct omap2430_glue *glue; |
diff --git a/drivers/usb/musb/tusb6010.c b/drivers/usb/musb/tusb6010.c index 6f8a9ca96ae7..b3b3ed723882 100644 --- a/drivers/usb/musb/tusb6010.c +++ b/drivers/usb/musb/tusb6010.c | |||
@@ -25,7 +25,7 @@ | |||
25 | #include <linux/io.h> | 25 | #include <linux/io.h> |
26 | #include <linux/platform_device.h> | 26 | #include <linux/platform_device.h> |
27 | #include <linux/dma-mapping.h> | 27 | #include <linux/dma-mapping.h> |
28 | #include <linux/usb/nop-usb-xceiv.h> | 28 | #include <linux/usb/usb_phy_gen_xceiv.h> |
29 | 29 | ||
30 | #include "musb_core.h" | 30 | #include "musb_core.h" |
31 | 31 | ||
@@ -1157,7 +1157,7 @@ static u64 tusb_dmamask = DMA_BIT_MASK(32); | |||
1157 | static int tusb_probe(struct platform_device *pdev) | 1157 | static int tusb_probe(struct platform_device *pdev) |
1158 | { | 1158 | { |
1159 | struct resource musb_resources[3]; | 1159 | struct resource musb_resources[3]; |
1160 | struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data; | 1160 | struct musb_hdrc_platform_data *pdata = dev_get_platdata(&pdev->dev); |
1161 | struct platform_device *musb; | 1161 | struct platform_device *musb; |
1162 | struct tusb6010_glue *glue; | 1162 | struct tusb6010_glue *glue; |
1163 | 1163 | ||
diff --git a/drivers/usb/musb/tusb6010_omap.c b/drivers/usb/musb/tusb6010_omap.c index 98df17c984a8..b8794eb81e9c 100644 --- a/drivers/usb/musb/tusb6010_omap.c +++ b/drivers/usb/musb/tusb6010_omap.c | |||
@@ -66,28 +66,6 @@ struct tusb_omap_dma { | |||
66 | unsigned multichannel:1; | 66 | unsigned multichannel:1; |
67 | }; | 67 | }; |
68 | 68 | ||
69 | static int tusb_omap_dma_start(struct dma_controller *c) | ||
70 | { | ||
71 | struct tusb_omap_dma *tusb_dma; | ||
72 | |||
73 | tusb_dma = container_of(c, struct tusb_omap_dma, controller); | ||
74 | |||
75 | /* dev_dbg(musb->controller, "ep%i ch: %i\n", chdat->epnum, chdat->ch); */ | ||
76 | |||
77 | return 0; | ||
78 | } | ||
79 | |||
80 | static int tusb_omap_dma_stop(struct dma_controller *c) | ||
81 | { | ||
82 | struct tusb_omap_dma *tusb_dma; | ||
83 | |||
84 | tusb_dma = container_of(c, struct tusb_omap_dma, controller); | ||
85 | |||
86 | /* dev_dbg(musb->controller, "ep%i ch: %i\n", chdat->epnum, chdat->ch); */ | ||
87 | |||
88 | return 0; | ||
89 | } | ||
90 | |||
91 | /* | 69 | /* |
92 | * Allocate dmareq0 to the current channel unless it's already taken | 70 | * Allocate dmareq0 to the current channel unless it's already taken |
93 | */ | 71 | */ |
@@ -695,8 +673,6 @@ struct dma_controller *dma_controller_create(struct musb *musb, void __iomem *ba | |||
695 | tusb_dma->dmareq = -1; | 673 | tusb_dma->dmareq = -1; |
696 | tusb_dma->sync_dev = -1; | 674 | tusb_dma->sync_dev = -1; |
697 | 675 | ||
698 | tusb_dma->controller.start = tusb_omap_dma_start; | ||
699 | tusb_dma->controller.stop = tusb_omap_dma_stop; | ||
700 | tusb_dma->controller.channel_alloc = tusb_omap_dma_allocate; | 676 | tusb_dma->controller.channel_alloc = tusb_omap_dma_allocate; |
701 | tusb_dma->controller.channel_release = tusb_omap_dma_release; | 677 | tusb_dma->controller.channel_release = tusb_omap_dma_release; |
702 | tusb_dma->controller.channel_program = tusb_omap_dma_program; | 678 | tusb_dma->controller.channel_program = tusb_omap_dma_program; |
diff --git a/drivers/usb/musb/ux500.c b/drivers/usb/musb/ux500.c index fce71b605936..59256b12f746 100644 --- a/drivers/usb/musb/ux500.c +++ b/drivers/usb/musb/ux500.c | |||
@@ -227,7 +227,7 @@ ux500_of_probe(struct platform_device *pdev, struct device_node *np) | |||
227 | static int ux500_probe(struct platform_device *pdev) | 227 | static int ux500_probe(struct platform_device *pdev) |
228 | { | 228 | { |
229 | struct resource musb_resources[2]; | 229 | struct resource musb_resources[2]; |
230 | struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data; | 230 | struct musb_hdrc_platform_data *pdata = dev_get_platdata(&pdev->dev); |
231 | struct device_node *np = pdev->dev.of_node; | 231 | struct device_node *np = pdev->dev.of_node; |
232 | struct platform_device *musb; | 232 | struct platform_device *musb; |
233 | struct ux500_glue *glue; | 233 | struct ux500_glue *glue; |
diff --git a/drivers/usb/musb/ux500_dma.c b/drivers/usb/musb/ux500_dma.c index bfb7a65d83cc..e51dd9b88e71 100644 --- a/drivers/usb/musb/ux500_dma.c +++ b/drivers/usb/musb/ux500_dma.c | |||
@@ -254,10 +254,8 @@ static int ux500_dma_channel_abort(struct dma_channel *channel) | |||
254 | return 0; | 254 | return 0; |
255 | } | 255 | } |
256 | 256 | ||
257 | static int ux500_dma_controller_stop(struct dma_controller *c) | 257 | static void ux500_dma_controller_stop(struct ux500_dma_controller *controller) |
258 | { | 258 | { |
259 | struct ux500_dma_controller *controller = container_of(c, | ||
260 | struct ux500_dma_controller, controller); | ||
261 | struct ux500_dma_channel *ux500_channel; | 259 | struct ux500_dma_channel *ux500_channel; |
262 | struct dma_channel *channel; | 260 | struct dma_channel *channel; |
263 | u8 ch_num; | 261 | u8 ch_num; |
@@ -281,18 +279,14 @@ static int ux500_dma_controller_stop(struct dma_controller *c) | |||
281 | if (ux500_channel->dma_chan) | 279 | if (ux500_channel->dma_chan) |
282 | dma_release_channel(ux500_channel->dma_chan); | 280 | dma_release_channel(ux500_channel->dma_chan); |
283 | } | 281 | } |
284 | |||
285 | return 0; | ||
286 | } | 282 | } |
287 | 283 | ||
288 | static int ux500_dma_controller_start(struct dma_controller *c) | 284 | static int ux500_dma_controller_start(struct ux500_dma_controller *controller) |
289 | { | 285 | { |
290 | struct ux500_dma_controller *controller = container_of(c, | ||
291 | struct ux500_dma_controller, controller); | ||
292 | struct ux500_dma_channel *ux500_channel = NULL; | 286 | struct ux500_dma_channel *ux500_channel = NULL; |
293 | struct musb *musb = controller->private_data; | 287 | struct musb *musb = controller->private_data; |
294 | struct device *dev = musb->controller; | 288 | struct device *dev = musb->controller; |
295 | struct musb_hdrc_platform_data *plat = dev->platform_data; | 289 | struct musb_hdrc_platform_data *plat = dev_get_platdata(dev); |
296 | struct ux500_musb_board_data *data; | 290 | struct ux500_musb_board_data *data; |
297 | struct dma_channel *dma_channel = NULL; | 291 | struct dma_channel *dma_channel = NULL; |
298 | char **chan_names; | 292 | char **chan_names; |
@@ -347,7 +341,7 @@ static int ux500_dma_controller_start(struct dma_controller *c) | |||
347 | dir, ch_num); | 341 | dir, ch_num); |
348 | 342 | ||
349 | /* Release already allocated channels */ | 343 | /* Release already allocated channels */ |
350 | ux500_dma_controller_stop(c); | 344 | ux500_dma_controller_stop(controller); |
351 | 345 | ||
352 | return -EBUSY; | 346 | return -EBUSY; |
353 | } | 347 | } |
@@ -369,6 +363,7 @@ void dma_controller_destroy(struct dma_controller *c) | |||
369 | struct ux500_dma_controller *controller = container_of(c, | 363 | struct ux500_dma_controller *controller = container_of(c, |
370 | struct ux500_dma_controller, controller); | 364 | struct ux500_dma_controller, controller); |
371 | 365 | ||
366 | ux500_dma_controller_stop(controller); | ||
372 | kfree(controller); | 367 | kfree(controller); |
373 | } | 368 | } |
374 | 369 | ||
@@ -378,6 +373,7 @@ struct dma_controller *dma_controller_create(struct musb *musb, | |||
378 | struct ux500_dma_controller *controller; | 373 | struct ux500_dma_controller *controller; |
379 | struct platform_device *pdev = to_platform_device(musb->controller); | 374 | struct platform_device *pdev = to_platform_device(musb->controller); |
380 | struct resource *iomem; | 375 | struct resource *iomem; |
376 | int ret; | ||
381 | 377 | ||
382 | controller = kzalloc(sizeof(*controller), GFP_KERNEL); | 378 | controller = kzalloc(sizeof(*controller), GFP_KERNEL); |
383 | if (!controller) | 379 | if (!controller) |
@@ -394,14 +390,15 @@ struct dma_controller *dma_controller_create(struct musb *musb, | |||
394 | 390 | ||
395 | controller->phy_base = (dma_addr_t) iomem->start; | 391 | controller->phy_base = (dma_addr_t) iomem->start; |
396 | 392 | ||
397 | controller->controller.start = ux500_dma_controller_start; | ||
398 | controller->controller.stop = ux500_dma_controller_stop; | ||
399 | controller->controller.channel_alloc = ux500_dma_channel_allocate; | 393 | controller->controller.channel_alloc = ux500_dma_channel_allocate; |
400 | controller->controller.channel_release = ux500_dma_channel_release; | 394 | controller->controller.channel_release = ux500_dma_channel_release; |
401 | controller->controller.channel_program = ux500_dma_channel_program; | 395 | controller->controller.channel_program = ux500_dma_channel_program; |
402 | controller->controller.channel_abort = ux500_dma_channel_abort; | 396 | controller->controller.channel_abort = ux500_dma_channel_abort; |
403 | controller->controller.is_compatible = ux500_dma_is_compatible; | 397 | controller->controller.is_compatible = ux500_dma_is_compatible; |
404 | 398 | ||
399 | ret = ux500_dma_controller_start(controller); | ||
400 | if (ret) | ||
401 | goto plat_get_fail; | ||
405 | return &controller->controller; | 402 | return &controller->controller; |
406 | 403 | ||
407 | plat_get_fail: | 404 | plat_get_fail: |
diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig index b57514ba486a..d5589f9c60a9 100644 --- a/drivers/usb/phy/Kconfig +++ b/drivers/usb/phy/Kconfig | |||
@@ -1,22 +1,10 @@ | |||
1 | # | 1 | # |
2 | # Physical Layer USB driver configuration | 2 | # Physical Layer USB driver configuration |
3 | # | 3 | # |
4 | menuconfig USB_PHY | 4 | menu "USB Physical Layer drivers" |
5 | bool "USB Physical Layer drivers" | ||
6 | help | ||
7 | Most USB controllers have the physical layer signalling part | ||
8 | (commonly called a PHY) built in. However, dual-role devices | ||
9 | (a.k.a. USB on-the-go) which support being USB master or slave | ||
10 | with the same connector often use an external PHY. | ||
11 | |||
12 | The drivers in this submenu add support for such PHY devices. | ||
13 | They are not needed for standard master-only (or the vast | ||
14 | majority of slave-only) USB interfaces. | ||
15 | 5 | ||
16 | If you're not sure if this applies to you, it probably doesn't; | 6 | config USB_PHY |
17 | say N here. | 7 | def_bool n |
18 | |||
19 | if USB_PHY | ||
20 | 8 | ||
21 | # | 9 | # |
22 | # USB Transceiver Drivers | 10 | # USB Transceiver Drivers |
@@ -24,6 +12,7 @@ if USB_PHY | |||
24 | config AB8500_USB | 12 | config AB8500_USB |
25 | tristate "AB8500 USB Transceiver Driver" | 13 | tristate "AB8500 USB Transceiver Driver" |
26 | depends on AB8500_CORE | 14 | depends on AB8500_CORE |
15 | select USB_PHY | ||
27 | help | 16 | help |
28 | Enable this to support the USB OTG transceiver in AB8500 chip. | 17 | Enable this to support the USB OTG transceiver in AB8500 chip. |
29 | This transceiver supports high and full speed devices plus, | 18 | This transceiver supports high and full speed devices plus, |
@@ -33,12 +22,14 @@ config FSL_USB2_OTG | |||
33 | bool "Freescale USB OTG Transceiver Driver" | 22 | bool "Freescale USB OTG Transceiver Driver" |
34 | depends on USB_EHCI_FSL && USB_FSL_USB2 && PM_RUNTIME | 23 | depends on USB_EHCI_FSL && USB_FSL_USB2 && PM_RUNTIME |
35 | select USB_OTG | 24 | select USB_OTG |
25 | select USB_PHY | ||
36 | help | 26 | help |
37 | Enable this to support Freescale USB OTG transceiver. | 27 | Enable this to support Freescale USB OTG transceiver. |
38 | 28 | ||
39 | config ISP1301_OMAP | 29 | config ISP1301_OMAP |
40 | tristate "Philips ISP1301 with OMAP OTG" | 30 | tristate "Philips ISP1301 with OMAP OTG" |
41 | depends on I2C && ARCH_OMAP_OTG | 31 | depends on I2C && ARCH_OMAP_OTG |
32 | select USB_PHY | ||
42 | help | 33 | help |
43 | If you say yes here you get support for the Philips ISP1301 | 34 | If you say yes here you get support for the Philips ISP1301 |
44 | USB-On-The-Go transceiver working with the OMAP OTG controller. | 35 | USB-On-The-Go transceiver working with the OMAP OTG controller. |
@@ -52,12 +43,14 @@ config ISP1301_OMAP | |||
52 | config MV_U3D_PHY | 43 | config MV_U3D_PHY |
53 | bool "Marvell USB 3.0 PHY controller Driver" | 44 | bool "Marvell USB 3.0 PHY controller Driver" |
54 | depends on CPU_MMP3 | 45 | depends on CPU_MMP3 |
46 | select USB_PHY | ||
55 | help | 47 | help |
56 | Enable this to support Marvell USB 3.0 phy controller for Marvell | 48 | Enable this to support Marvell USB 3.0 phy controller for Marvell |
57 | SoC. | 49 | SoC. |
58 | 50 | ||
59 | config NOP_USB_XCEIV | 51 | config NOP_USB_XCEIV |
60 | tristate "NOP USB Transceiver Driver" | 52 | tristate "NOP USB Transceiver Driver" |
53 | select USB_PHY | ||
61 | help | 54 | help |
62 | This driver is to be used by all the usb transceiver which are either | 55 | This driver is to be used by all the usb transceiver which are either |
63 | built-in with usb ip or which are autonomous and doesn't require any | 56 | built-in with usb ip or which are autonomous and doesn't require any |
@@ -77,6 +70,7 @@ config OMAP_USB2 | |||
77 | tristate "OMAP USB2 PHY Driver" | 70 | tristate "OMAP USB2 PHY Driver" |
78 | depends on ARCH_OMAP2PLUS | 71 | depends on ARCH_OMAP2PLUS |
79 | select OMAP_CONTROL_USB | 72 | select OMAP_CONTROL_USB |
73 | select USB_PHY | ||
80 | help | 74 | help |
81 | Enable this to support the transceiver that is part of SOC. This | 75 | Enable this to support the transceiver that is part of SOC. This |
82 | driver takes care of all the PHY functionality apart from comparator. | 76 | driver takes care of all the PHY functionality apart from comparator. |
@@ -87,12 +81,25 @@ config OMAP_USB3 | |||
87 | tristate "OMAP USB3 PHY Driver" | 81 | tristate "OMAP USB3 PHY Driver" |
88 | depends on ARCH_OMAP2PLUS || COMPILE_TEST | 82 | depends on ARCH_OMAP2PLUS || COMPILE_TEST |
89 | select OMAP_CONTROL_USB | 83 | select OMAP_CONTROL_USB |
84 | select USB_PHY | ||
90 | help | 85 | help |
91 | Enable this to support the USB3 PHY that is part of SOC. This | 86 | Enable this to support the USB3 PHY that is part of SOC. This |
92 | driver takes care of all the PHY functionality apart from comparator. | 87 | driver takes care of all the PHY functionality apart from comparator. |
93 | This driver interacts with the "OMAP Control USB Driver" to power | 88 | This driver interacts with the "OMAP Control USB Driver" to power |
94 | on/off the PHY. | 89 | on/off the PHY. |
95 | 90 | ||
91 | config AM335X_CONTROL_USB | ||
92 | tristate | ||
93 | |||
94 | config AM335X_PHY_USB | ||
95 | tristate "AM335x USB PHY Driver" | ||
96 | select USB_PHY | ||
97 | select AM335X_CONTROL_USB | ||
98 | select NOP_USB_XCEIV | ||
99 | help | ||
100 | This driver provides PHY support for that phy which part for the | ||
101 | AM335x SoC. | ||
102 | |||
96 | config SAMSUNG_USBPHY | 103 | config SAMSUNG_USBPHY |
97 | tristate | 104 | tristate |
98 | help | 105 | help |
@@ -103,6 +110,7 @@ config SAMSUNG_USBPHY | |||
103 | config SAMSUNG_USB2PHY | 110 | config SAMSUNG_USB2PHY |
104 | tristate "Samsung USB 2.0 PHY controller Driver" | 111 | tristate "Samsung USB 2.0 PHY controller Driver" |
105 | select SAMSUNG_USBPHY | 112 | select SAMSUNG_USBPHY |
113 | select USB_PHY | ||
106 | help | 114 | help |
107 | Enable this to support Samsung USB 2.0 (High Speed) PHY controller | 115 | Enable this to support Samsung USB 2.0 (High Speed) PHY controller |
108 | driver for Samsung SoCs. | 116 | driver for Samsung SoCs. |
@@ -110,6 +118,7 @@ config SAMSUNG_USB2PHY | |||
110 | config SAMSUNG_USB3PHY | 118 | config SAMSUNG_USB3PHY |
111 | tristate "Samsung USB 3.0 PHY controller Driver" | 119 | tristate "Samsung USB 3.0 PHY controller Driver" |
112 | select SAMSUNG_USBPHY | 120 | select SAMSUNG_USBPHY |
121 | select USB_PHY | ||
113 | help | 122 | help |
114 | Enable this to support Samsung USB 3.0 (Super Speed) phy controller | 123 | Enable this to support Samsung USB 3.0 (Super Speed) phy controller |
115 | for samsung SoCs. | 124 | for samsung SoCs. |
@@ -117,6 +126,7 @@ config SAMSUNG_USB3PHY | |||
117 | config TWL4030_USB | 126 | config TWL4030_USB |
118 | tristate "TWL4030 USB Transceiver Driver" | 127 | tristate "TWL4030 USB Transceiver Driver" |
119 | depends on TWL4030_CORE && REGULATOR_TWL4030 && USB_MUSB_OMAP2PLUS | 128 | depends on TWL4030_CORE && REGULATOR_TWL4030 && USB_MUSB_OMAP2PLUS |
129 | select USB_PHY | ||
120 | help | 130 | help |
121 | Enable this to support the USB OTG transceiver on TWL4030 | 131 | Enable this to support the USB OTG transceiver on TWL4030 |
122 | family chips (including the TWL5030 and TPS659x0 devices). | 132 | family chips (including the TWL5030 and TPS659x0 devices). |
@@ -137,6 +147,7 @@ config TWL6030_USB | |||
137 | config USB_GPIO_VBUS | 147 | config USB_GPIO_VBUS |
138 | tristate "GPIO based peripheral-only VBUS sensing 'transceiver'" | 148 | tristate "GPIO based peripheral-only VBUS sensing 'transceiver'" |
139 | depends on GPIOLIB | 149 | depends on GPIOLIB |
150 | select USB_PHY | ||
140 | help | 151 | help |
141 | Provides simple GPIO VBUS sensing for controllers with an | 152 | Provides simple GPIO VBUS sensing for controllers with an |
142 | internal transceiver via the usb_phy interface, and | 153 | internal transceiver via the usb_phy interface, and |
@@ -147,6 +158,7 @@ config USB_ISP1301 | |||
147 | tristate "NXP ISP1301 USB transceiver support" | 158 | tristate "NXP ISP1301 USB transceiver support" |
148 | depends on USB || USB_GADGET | 159 | depends on USB || USB_GADGET |
149 | depends on I2C | 160 | depends on I2C |
161 | select USB_PHY | ||
150 | help | 162 | help |
151 | Say Y here to add support for the NXP ISP1301 USB transceiver driver. | 163 | Say Y here to add support for the NXP ISP1301 USB transceiver driver. |
152 | This chip is typically used as USB transceiver for USB host, gadget | 164 | This chip is typically used as USB transceiver for USB host, gadget |
@@ -158,6 +170,7 @@ config USB_ISP1301 | |||
158 | config USB_MSM_OTG | 170 | config USB_MSM_OTG |
159 | tristate "OTG support for Qualcomm on-chip USB controller" | 171 | tristate "OTG support for Qualcomm on-chip USB controller" |
160 | depends on (USB || USB_GADGET) && ARCH_MSM | 172 | depends on (USB || USB_GADGET) && ARCH_MSM |
173 | select USB_PHY | ||
161 | help | 174 | help |
162 | Enable this to support the USB OTG transceiver on MSM chips. It | 175 | Enable this to support the USB OTG transceiver on MSM chips. It |
163 | handles PHY initialization, clock management, and workarounds | 176 | handles PHY initialization, clock management, and workarounds |
@@ -171,6 +184,7 @@ config USB_MV_OTG | |||
171 | tristate "Marvell USB OTG support" | 184 | tristate "Marvell USB OTG support" |
172 | depends on USB_EHCI_MV && USB_MV_UDC && PM_RUNTIME | 185 | depends on USB_EHCI_MV && USB_MV_UDC && PM_RUNTIME |
173 | select USB_OTG | 186 | select USB_OTG |
187 | select USB_PHY | ||
174 | help | 188 | help |
175 | Say Y here if you want to build Marvell USB OTG transciever | 189 | Say Y here if you want to build Marvell USB OTG transciever |
176 | driver in kernel (including PXA and MMP series). This driver | 190 | driver in kernel (including PXA and MMP series). This driver |
@@ -182,6 +196,7 @@ config USB_MXS_PHY | |||
182 | tristate "Freescale MXS USB PHY support" | 196 | tristate "Freescale MXS USB PHY support" |
183 | depends on ARCH_MXC || ARCH_MXS | 197 | depends on ARCH_MXC || ARCH_MXS |
184 | select STMP_DEVICE | 198 | select STMP_DEVICE |
199 | select USB_PHY | ||
185 | help | 200 | help |
186 | Enable this to support the Freescale MXS USB PHY. | 201 | Enable this to support the Freescale MXS USB PHY. |
187 | 202 | ||
@@ -190,6 +205,7 @@ config USB_MXS_PHY | |||
190 | config USB_RCAR_PHY | 205 | config USB_RCAR_PHY |
191 | tristate "Renesas R-Car USB PHY support" | 206 | tristate "Renesas R-Car USB PHY support" |
192 | depends on USB || USB_GADGET | 207 | depends on USB || USB_GADGET |
208 | select USB_PHY | ||
193 | help | 209 | help |
194 | Say Y here to add support for the Renesas R-Car USB common PHY driver. | 210 | Say Y here to add support for the Renesas R-Car USB common PHY driver. |
195 | This chip is typically used as USB PHY for USB host, gadget. | 211 | This chip is typically used as USB PHY for USB host, gadget. |
@@ -212,4 +228,4 @@ config USB_ULPI_VIEWPORT | |||
212 | Provides read/write operations to the ULPI phy register set for | 228 | Provides read/write operations to the ULPI phy register set for |
213 | controllers with a viewport register (e.g. Chipidea/ARC controllers). | 229 | controllers with a viewport register (e.g. Chipidea/ARC controllers). |
214 | 230 | ||
215 | endif # USB_PHY | 231 | endmenu |
diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile index 98730ca1d5d3..2135e85f46ed 100644 --- a/drivers/usb/phy/Makefile +++ b/drivers/usb/phy/Makefile | |||
@@ -11,8 +11,10 @@ phy-fsl-usb2-objs := phy-fsl-usb.o phy-fsm-usb.o | |||
11 | obj-$(CONFIG_FSL_USB2_OTG) += phy-fsl-usb2.o | 11 | obj-$(CONFIG_FSL_USB2_OTG) += phy-fsl-usb2.o |
12 | obj-$(CONFIG_ISP1301_OMAP) += phy-isp1301-omap.o | 12 | obj-$(CONFIG_ISP1301_OMAP) += phy-isp1301-omap.o |
13 | obj-$(CONFIG_MV_U3D_PHY) += phy-mv-u3d-usb.o | 13 | obj-$(CONFIG_MV_U3D_PHY) += phy-mv-u3d-usb.o |
14 | obj-$(CONFIG_NOP_USB_XCEIV) += phy-nop.o | 14 | obj-$(CONFIG_NOP_USB_XCEIV) += phy-generic.o |
15 | obj-$(CONFIG_OMAP_CONTROL_USB) += phy-omap-control.o | 15 | obj-$(CONFIG_OMAP_CONTROL_USB) += phy-omap-control.o |
16 | obj-$(CONFIG_AM335X_CONTROL_USB) += phy-am335x-control.o | ||
17 | obj-$(CONFIG_AM335X_PHY_USB) += phy-am335x.o | ||
16 | obj-$(CONFIG_OMAP_USB2) += phy-omap-usb2.o | 18 | obj-$(CONFIG_OMAP_USB2) += phy-omap-usb2.o |
17 | obj-$(CONFIG_OMAP_USB3) += phy-omap-usb3.o | 19 | obj-$(CONFIG_OMAP_USB3) += phy-omap-usb3.o |
18 | obj-$(CONFIG_SAMSUNG_USBPHY) += phy-samsung-usb.o | 20 | obj-$(CONFIG_SAMSUNG_USBPHY) += phy-samsung-usb.o |
diff --git a/drivers/usb/phy/am35x-phy-control.h b/drivers/usb/phy/am35x-phy-control.h new file mode 100644 index 000000000000..b96594d1962c --- /dev/null +++ b/drivers/usb/phy/am35x-phy-control.h | |||
@@ -0,0 +1,21 @@ | |||
1 | #ifndef _AM335x_PHY_CONTROL_H_ | ||
2 | #define _AM335x_PHY_CONTROL_H_ | ||
3 | |||
4 | struct phy_control { | ||
5 | void (*phy_power)(struct phy_control *phy_ctrl, u32 id, bool on); | ||
6 | void (*phy_wkup)(struct phy_control *phy_ctrl, u32 id, bool on); | ||
7 | }; | ||
8 | |||
9 | static inline void phy_ctrl_power(struct phy_control *phy_ctrl, u32 id, bool on) | ||
10 | { | ||
11 | phy_ctrl->phy_power(phy_ctrl, id, on); | ||
12 | } | ||
13 | |||
14 | static inline void phy_ctrl_wkup(struct phy_control *phy_ctrl, u32 id, bool on) | ||
15 | { | ||
16 | phy_ctrl->phy_wkup(phy_ctrl, id, on); | ||
17 | } | ||
18 | |||
19 | struct phy_control *am335x_get_phy_control(struct device *dev); | ||
20 | |||
21 | #endif | ||
diff --git a/drivers/usb/phy/phy-am335x-control.c b/drivers/usb/phy/phy-am335x-control.c new file mode 100644 index 000000000000..759754521426 --- /dev/null +++ b/drivers/usb/phy/phy-am335x-control.c | |||
@@ -0,0 +1,137 @@ | |||
1 | #include <linux/module.h> | ||
2 | #include <linux/platform_device.h> | ||
3 | #include <linux/err.h> | ||
4 | #include <linux/of.h> | ||
5 | #include <linux/io.h> | ||
6 | |||
7 | struct phy_control { | ||
8 | void (*phy_power)(struct phy_control *phy_ctrl, u32 id, bool on); | ||
9 | void (*phy_wkup)(struct phy_control *phy_ctrl, u32 id, bool on); | ||
10 | }; | ||
11 | |||
12 | struct am335x_control_usb { | ||
13 | struct device *dev; | ||
14 | void __iomem *phy_reg; | ||
15 | void __iomem *wkup; | ||
16 | spinlock_t lock; | ||
17 | struct phy_control phy_ctrl; | ||
18 | }; | ||
19 | |||
20 | #define AM335X_USB0_CTRL 0x0 | ||
21 | #define AM335X_USB1_CTRL 0x8 | ||
22 | #define AM335x_USB_WKUP 0x0 | ||
23 | |||
24 | #define USBPHY_CM_PWRDN (1 << 0) | ||
25 | #define USBPHY_OTG_PWRDN (1 << 1) | ||
26 | #define USBPHY_OTGVDET_EN (1 << 19) | ||
27 | #define USBPHY_OTGSESSEND_EN (1 << 20) | ||
28 | |||
29 | static void am335x_phy_power(struct phy_control *phy_ctrl, u32 id, bool on) | ||
30 | { | ||
31 | struct am335x_control_usb *usb_ctrl; | ||
32 | u32 val; | ||
33 | u32 reg; | ||
34 | |||
35 | usb_ctrl = container_of(phy_ctrl, struct am335x_control_usb, phy_ctrl); | ||
36 | |||
37 | switch (id) { | ||
38 | case 0: | ||
39 | reg = AM335X_USB0_CTRL; | ||
40 | break; | ||
41 | case 1: | ||
42 | reg = AM335X_USB1_CTRL; | ||
43 | break; | ||
44 | default: | ||
45 | __WARN(); | ||
46 | return; | ||
47 | } | ||
48 | |||
49 | val = readl(usb_ctrl->phy_reg + reg); | ||
50 | if (on) { | ||
51 | val &= ~(USBPHY_CM_PWRDN | USBPHY_OTG_PWRDN); | ||
52 | val |= USBPHY_OTGVDET_EN | USBPHY_OTGSESSEND_EN; | ||
53 | } else { | ||
54 | val |= USBPHY_CM_PWRDN | USBPHY_OTG_PWRDN; | ||
55 | } | ||
56 | |||
57 | writel(val, usb_ctrl->phy_reg + reg); | ||
58 | } | ||
59 | |||
60 | static const struct phy_control ctrl_am335x = { | ||
61 | .phy_power = am335x_phy_power, | ||
62 | }; | ||
63 | |||
64 | static const struct of_device_id omap_control_usb_id_table[] = { | ||
65 | { .compatible = "ti,am335x-usb-ctrl-module", .data = &ctrl_am335x }, | ||
66 | {} | ||
67 | }; | ||
68 | MODULE_DEVICE_TABLE(of, omap_control_usb_id_table); | ||
69 | |||
70 | static struct platform_driver am335x_control_driver; | ||
71 | static int match(struct device *dev, void *data) | ||
72 | { | ||
73 | struct device_node *node = (struct device_node *)data; | ||
74 | return dev->of_node == node && | ||
75 | dev->driver == &am335x_control_driver.driver; | ||
76 | } | ||
77 | |||
78 | struct phy_control *am335x_get_phy_control(struct device *dev) | ||
79 | { | ||
80 | struct device_node *node; | ||
81 | struct am335x_control_usb *ctrl_usb; | ||
82 | |||
83 | node = of_parse_phandle(dev->of_node, "ti,ctrl_mod", 0); | ||
84 | if (!node) | ||
85 | return NULL; | ||
86 | |||
87 | dev = bus_find_device(&platform_bus_type, NULL, node, match); | ||
88 | ctrl_usb = dev_get_drvdata(dev); | ||
89 | if (!ctrl_usb) | ||
90 | return NULL; | ||
91 | return &ctrl_usb->phy_ctrl; | ||
92 | } | ||
93 | EXPORT_SYMBOL_GPL(am335x_get_phy_control); | ||
94 | |||
95 | static int am335x_control_usb_probe(struct platform_device *pdev) | ||
96 | { | ||
97 | struct resource *res; | ||
98 | struct am335x_control_usb *ctrl_usb; | ||
99 | const struct of_device_id *of_id; | ||
100 | const struct phy_control *phy_ctrl; | ||
101 | |||
102 | of_id = of_match_node(omap_control_usb_id_table, pdev->dev.of_node); | ||
103 | if (!of_id) | ||
104 | return -EINVAL; | ||
105 | |||
106 | phy_ctrl = of_id->data; | ||
107 | |||
108 | ctrl_usb = devm_kzalloc(&pdev->dev, sizeof(*ctrl_usb), GFP_KERNEL); | ||
109 | if (!ctrl_usb) { | ||
110 | dev_err(&pdev->dev, "unable to alloc memory for control usb\n"); | ||
111 | return -ENOMEM; | ||
112 | } | ||
113 | |||
114 | ctrl_usb->dev = &pdev->dev; | ||
115 | |||
116 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "phy_ctrl"); | ||
117 | ctrl_usb->phy_reg = devm_ioremap_resource(&pdev->dev, res); | ||
118 | if (IS_ERR(ctrl_usb->phy_reg)) | ||
119 | return PTR_ERR(ctrl_usb->phy_reg); | ||
120 | spin_lock_init(&ctrl_usb->lock); | ||
121 | ctrl_usb->phy_ctrl = *phy_ctrl; | ||
122 | |||
123 | dev_set_drvdata(ctrl_usb->dev, ctrl_usb); | ||
124 | return 0; | ||
125 | } | ||
126 | |||
127 | static struct platform_driver am335x_control_driver = { | ||
128 | .probe = am335x_control_usb_probe, | ||
129 | .driver = { | ||
130 | .name = "am335x-control-usb", | ||
131 | .owner = THIS_MODULE, | ||
132 | .of_match_table = of_match_ptr(omap_control_usb_id_table), | ||
133 | }, | ||
134 | }; | ||
135 | |||
136 | module_platform_driver(am335x_control_driver); | ||
137 | MODULE_LICENSE("GPL v2"); | ||
diff --git a/drivers/usb/phy/phy-am335x.c b/drivers/usb/phy/phy-am335x.c new file mode 100644 index 000000000000..c4d614d1f173 --- /dev/null +++ b/drivers/usb/phy/phy-am335x.c | |||
@@ -0,0 +1,99 @@ | |||
1 | #include <linux/module.h> | ||
2 | #include <linux/platform_device.h> | ||
3 | #include <linux/dma-mapping.h> | ||
4 | #include <linux/usb/otg.h> | ||
5 | #include <linux/usb/usb_phy_gen_xceiv.h> | ||
6 | #include <linux/slab.h> | ||
7 | #include <linux/clk.h> | ||
8 | #include <linux/regulator/consumer.h> | ||
9 | #include <linux/of.h> | ||
10 | #include <linux/of_address.h> | ||
11 | |||
12 | #include "am35x-phy-control.h" | ||
13 | #include "phy-generic.h" | ||
14 | |||
15 | struct am335x_phy { | ||
16 | struct usb_phy_gen_xceiv usb_phy_gen; | ||
17 | struct phy_control *phy_ctrl; | ||
18 | int id; | ||
19 | }; | ||
20 | |||
21 | static int am335x_init(struct usb_phy *phy) | ||
22 | { | ||
23 | struct am335x_phy *am_phy = dev_get_drvdata(phy->dev); | ||
24 | |||
25 | phy_ctrl_power(am_phy->phy_ctrl, am_phy->id, true); | ||
26 | return 0; | ||
27 | } | ||
28 | |||
29 | static void am335x_shutdown(struct usb_phy *phy) | ||
30 | { | ||
31 | struct am335x_phy *am_phy = dev_get_drvdata(phy->dev); | ||
32 | |||
33 | phy_ctrl_power(am_phy->phy_ctrl, am_phy->id, false); | ||
34 | } | ||
35 | |||
36 | static int am335x_phy_probe(struct platform_device *pdev) | ||
37 | { | ||
38 | struct am335x_phy *am_phy; | ||
39 | struct device *dev = &pdev->dev; | ||
40 | int ret; | ||
41 | |||
42 | am_phy = devm_kzalloc(dev, sizeof(*am_phy), GFP_KERNEL); | ||
43 | if (!am_phy) | ||
44 | return -ENOMEM; | ||
45 | |||
46 | am_phy->phy_ctrl = am335x_get_phy_control(dev); | ||
47 | if (!am_phy->phy_ctrl) | ||
48 | return -EPROBE_DEFER; | ||
49 | am_phy->id = of_alias_get_id(pdev->dev.of_node, "phy"); | ||
50 | if (am_phy->id < 0) { | ||
51 | dev_err(&pdev->dev, "Missing PHY id: %d\n", am_phy->id); | ||
52 | return am_phy->id; | ||
53 | } | ||
54 | |||
55 | ret = usb_phy_gen_create_phy(dev, &am_phy->usb_phy_gen, | ||
56 | USB_PHY_TYPE_USB2, 0, false, false); | ||
57 | if (ret) | ||
58 | return ret; | ||
59 | |||
60 | ret = usb_add_phy_dev(&am_phy->usb_phy_gen.phy); | ||
61 | if (ret) | ||
62 | goto err_add; | ||
63 | am_phy->usb_phy_gen.phy.init = am335x_init; | ||
64 | am_phy->usb_phy_gen.phy.shutdown = am335x_shutdown; | ||
65 | |||
66 | platform_set_drvdata(pdev, am_phy); | ||
67 | return 0; | ||
68 | |||
69 | err_add: | ||
70 | usb_phy_gen_cleanup_phy(&am_phy->usb_phy_gen); | ||
71 | return ret; | ||
72 | } | ||
73 | |||
74 | static int am335x_phy_remove(struct platform_device *pdev) | ||
75 | { | ||
76 | struct am335x_phy *am_phy = platform_get_drvdata(pdev); | ||
77 | |||
78 | usb_remove_phy(&am_phy->usb_phy_gen.phy); | ||
79 | return 0; | ||
80 | } | ||
81 | |||
82 | static const struct of_device_id am335x_phy_ids[] = { | ||
83 | { .compatible = "ti,am335x-usb-phy" }, | ||
84 | { } | ||
85 | }; | ||
86 | MODULE_DEVICE_TABLE(of, am335x_phy_ids); | ||
87 | |||
88 | static struct platform_driver am335x_phy_driver = { | ||
89 | .probe = am335x_phy_probe, | ||
90 | .remove = am335x_phy_remove, | ||
91 | .driver = { | ||
92 | .name = "am335x-phy-driver", | ||
93 | .owner = THIS_MODULE, | ||
94 | .of_match_table = of_match_ptr(am335x_phy_ids), | ||
95 | }, | ||
96 | }; | ||
97 | |||
98 | module_platform_driver(am335x_phy_driver); | ||
99 | MODULE_LICENSE("GPL v2"); | ||
diff --git a/drivers/usb/phy/phy-fsl-usb.c b/drivers/usb/phy/phy-fsl-usb.c index 181bfb10a57a..fa7c9f9628b5 100644 --- a/drivers/usb/phy/phy-fsl-usb.c +++ b/drivers/usb/phy/phy-fsl-usb.c | |||
@@ -834,7 +834,7 @@ int usb_otg_start(struct platform_device *pdev) | |||
834 | int status; | 834 | int status; |
835 | struct resource *res; | 835 | struct resource *res; |
836 | u32 temp; | 836 | u32 temp; |
837 | struct fsl_usb2_platform_data *pdata = pdev->dev.platform_data; | 837 | struct fsl_usb2_platform_data *pdata = dev_get_platdata(&pdev->dev); |
838 | 838 | ||
839 | p_otg = container_of(otg_trans, struct fsl_otg, phy); | 839 | p_otg = container_of(otg_trans, struct fsl_otg, phy); |
840 | fsm = &p_otg->fsm; | 840 | fsm = &p_otg->fsm; |
@@ -1105,7 +1105,7 @@ static int fsl_otg_probe(struct platform_device *pdev) | |||
1105 | { | 1105 | { |
1106 | int ret; | 1106 | int ret; |
1107 | 1107 | ||
1108 | if (!pdev->dev.platform_data) | 1108 | if (!dev_get_platdata(&pdev->dev)) |
1109 | return -ENODEV; | 1109 | return -ENODEV; |
1110 | 1110 | ||
1111 | /* configure the OTG */ | 1111 | /* configure the OTG */ |
@@ -1137,7 +1137,7 @@ static int fsl_otg_probe(struct platform_device *pdev) | |||
1137 | 1137 | ||
1138 | static int fsl_otg_remove(struct platform_device *pdev) | 1138 | static int fsl_otg_remove(struct platform_device *pdev) |
1139 | { | 1139 | { |
1140 | struct fsl_usb2_platform_data *pdata = pdev->dev.platform_data; | 1140 | struct fsl_usb2_platform_data *pdata = dev_get_platdata(&pdev->dev); |
1141 | 1141 | ||
1142 | usb_remove_phy(&fsl_otg_dev->phy); | 1142 | usb_remove_phy(&fsl_otg_dev->phy); |
1143 | free_irq(fsl_otg_dev->irq, fsl_otg_dev); | 1143 | free_irq(fsl_otg_dev->irq, fsl_otg_dev); |
diff --git a/drivers/usb/phy/phy-nop.c b/drivers/usb/phy/phy-generic.c index 55445e5d72e5..efe59f3f7fda 100644 --- a/drivers/usb/phy/phy-nop.c +++ b/drivers/usb/phy/phy-generic.c | |||
@@ -30,19 +30,13 @@ | |||
30 | #include <linux/platform_device.h> | 30 | #include <linux/platform_device.h> |
31 | #include <linux/dma-mapping.h> | 31 | #include <linux/dma-mapping.h> |
32 | #include <linux/usb/otg.h> | 32 | #include <linux/usb/otg.h> |
33 | #include <linux/usb/nop-usb-xceiv.h> | 33 | #include <linux/usb/usb_phy_gen_xceiv.h> |
34 | #include <linux/slab.h> | 34 | #include <linux/slab.h> |
35 | #include <linux/clk.h> | 35 | #include <linux/clk.h> |
36 | #include <linux/regulator/consumer.h> | 36 | #include <linux/regulator/consumer.h> |
37 | #include <linux/of.h> | 37 | #include <linux/of.h> |
38 | 38 | ||
39 | struct nop_usb_xceiv { | 39 | #include "phy-generic.h" |
40 | struct usb_phy phy; | ||
41 | struct device *dev; | ||
42 | struct clk *clk; | ||
43 | struct regulator *vcc; | ||
44 | struct regulator *reset; | ||
45 | }; | ||
46 | 40 | ||
47 | static struct platform_device *pd; | 41 | static struct platform_device *pd; |
48 | 42 | ||
@@ -50,9 +44,9 @@ void usb_nop_xceiv_register(void) | |||
50 | { | 44 | { |
51 | if (pd) | 45 | if (pd) |
52 | return; | 46 | return; |
53 | pd = platform_device_register_simple("nop_usb_xceiv", -1, NULL, 0); | 47 | pd = platform_device_register_simple("usb_phy_gen_xceiv", -1, NULL, 0); |
54 | if (!pd) { | 48 | if (!pd) { |
55 | printk(KERN_ERR "Unable to register usb nop transceiver\n"); | 49 | pr_err("Unable to register generic usb transceiver\n"); |
56 | return; | 50 | return; |
57 | } | 51 | } |
58 | } | 52 | } |
@@ -70,9 +64,9 @@ static int nop_set_suspend(struct usb_phy *x, int suspend) | |||
70 | return 0; | 64 | return 0; |
71 | } | 65 | } |
72 | 66 | ||
73 | static int nop_init(struct usb_phy *phy) | 67 | int usb_gen_phy_init(struct usb_phy *phy) |
74 | { | 68 | { |
75 | struct nop_usb_xceiv *nop = dev_get_drvdata(phy->dev); | 69 | struct usb_phy_gen_xceiv *nop = dev_get_drvdata(phy->dev); |
76 | 70 | ||
77 | if (!IS_ERR(nop->vcc)) { | 71 | if (!IS_ERR(nop->vcc)) { |
78 | if (regulator_enable(nop->vcc)) | 72 | if (regulator_enable(nop->vcc)) |
@@ -90,10 +84,11 @@ static int nop_init(struct usb_phy *phy) | |||
90 | 84 | ||
91 | return 0; | 85 | return 0; |
92 | } | 86 | } |
87 | EXPORT_SYMBOL_GPL(usb_gen_phy_init); | ||
93 | 88 | ||
94 | static void nop_shutdown(struct usb_phy *phy) | 89 | void usb_gen_phy_shutdown(struct usb_phy *phy) |
95 | { | 90 | { |
96 | struct nop_usb_xceiv *nop = dev_get_drvdata(phy->dev); | 91 | struct usb_phy_gen_xceiv *nop = dev_get_drvdata(phy->dev); |
97 | 92 | ||
98 | if (!IS_ERR(nop->reset)) { | 93 | if (!IS_ERR(nop->reset)) { |
99 | /* Assert RESET */ | 94 | /* Assert RESET */ |
@@ -109,6 +104,7 @@ static void nop_shutdown(struct usb_phy *phy) | |||
109 | dev_err(phy->dev, "Failed to disable power\n"); | 104 | dev_err(phy->dev, "Failed to disable power\n"); |
110 | } | 105 | } |
111 | } | 106 | } |
107 | EXPORT_SYMBOL_GPL(usb_gen_phy_shutdown); | ||
112 | 108 | ||
113 | static int nop_set_peripheral(struct usb_otg *otg, struct usb_gadget *gadget) | 109 | static int nop_set_peripheral(struct usb_otg *otg, struct usb_gadget *gadget) |
114 | { | 110 | { |
@@ -139,52 +135,27 @@ static int nop_set_host(struct usb_otg *otg, struct usb_bus *host) | |||
139 | return 0; | 135 | return 0; |
140 | } | 136 | } |
141 | 137 | ||
142 | static int nop_usb_xceiv_probe(struct platform_device *pdev) | 138 | int usb_phy_gen_create_phy(struct device *dev, struct usb_phy_gen_xceiv *nop, |
139 | enum usb_phy_type type, u32 clk_rate, bool needs_vcc, | ||
140 | bool needs_reset) | ||
143 | { | 141 | { |
144 | struct device *dev = &pdev->dev; | ||
145 | struct nop_usb_xceiv_platform_data *pdata = pdev->dev.platform_data; | ||
146 | struct nop_usb_xceiv *nop; | ||
147 | enum usb_phy_type type = USB_PHY_TYPE_USB2; | ||
148 | int err; | 142 | int err; |
149 | u32 clk_rate = 0; | ||
150 | bool needs_vcc = false; | ||
151 | bool needs_reset = false; | ||
152 | |||
153 | nop = devm_kzalloc(&pdev->dev, sizeof(*nop), GFP_KERNEL); | ||
154 | if (!nop) | ||
155 | return -ENOMEM; | ||
156 | 143 | ||
157 | nop->phy.otg = devm_kzalloc(&pdev->dev, sizeof(*nop->phy.otg), | 144 | nop->phy.otg = devm_kzalloc(dev, sizeof(*nop->phy.otg), |
158 | GFP_KERNEL); | 145 | GFP_KERNEL); |
159 | if (!nop->phy.otg) | 146 | if (!nop->phy.otg) |
160 | return -ENOMEM; | 147 | return -ENOMEM; |
161 | 148 | ||
162 | if (dev->of_node) { | 149 | nop->clk = devm_clk_get(dev, "main_clk"); |
163 | struct device_node *node = dev->of_node; | ||
164 | |||
165 | if (of_property_read_u32(node, "clock-frequency", &clk_rate)) | ||
166 | clk_rate = 0; | ||
167 | |||
168 | needs_vcc = of_property_read_bool(node, "vcc-supply"); | ||
169 | needs_reset = of_property_read_bool(node, "reset-supply"); | ||
170 | |||
171 | } else if (pdata) { | ||
172 | type = pdata->type; | ||
173 | clk_rate = pdata->clk_rate; | ||
174 | needs_vcc = pdata->needs_vcc; | ||
175 | needs_reset = pdata->needs_reset; | ||
176 | } | ||
177 | |||
178 | nop->clk = devm_clk_get(&pdev->dev, "main_clk"); | ||
179 | if (IS_ERR(nop->clk)) { | 150 | if (IS_ERR(nop->clk)) { |
180 | dev_dbg(&pdev->dev, "Can't get phy clock: %ld\n", | 151 | dev_dbg(dev, "Can't get phy clock: %ld\n", |
181 | PTR_ERR(nop->clk)); | 152 | PTR_ERR(nop->clk)); |
182 | } | 153 | } |
183 | 154 | ||
184 | if (!IS_ERR(nop->clk) && clk_rate) { | 155 | if (!IS_ERR(nop->clk) && clk_rate) { |
185 | err = clk_set_rate(nop->clk, clk_rate); | 156 | err = clk_set_rate(nop->clk, clk_rate); |
186 | if (err) { | 157 | if (err) { |
187 | dev_err(&pdev->dev, "Error setting clock rate\n"); | 158 | dev_err(dev, "Error setting clock rate\n"); |
188 | return err; | 159 | return err; |
189 | } | 160 | } |
190 | } | 161 | } |
@@ -192,33 +163,31 @@ static int nop_usb_xceiv_probe(struct platform_device *pdev) | |||
192 | if (!IS_ERR(nop->clk)) { | 163 | if (!IS_ERR(nop->clk)) { |
193 | err = clk_prepare(nop->clk); | 164 | err = clk_prepare(nop->clk); |
194 | if (err) { | 165 | if (err) { |
195 | dev_err(&pdev->dev, "Error preparing clock\n"); | 166 | dev_err(dev, "Error preparing clock\n"); |
196 | return err; | 167 | return err; |
197 | } | 168 | } |
198 | } | 169 | } |
199 | 170 | ||
200 | nop->vcc = devm_regulator_get(&pdev->dev, "vcc"); | 171 | nop->vcc = devm_regulator_get(dev, "vcc"); |
201 | if (IS_ERR(nop->vcc)) { | 172 | if (IS_ERR(nop->vcc)) { |
202 | dev_dbg(&pdev->dev, "Error getting vcc regulator: %ld\n", | 173 | dev_dbg(dev, "Error getting vcc regulator: %ld\n", |
203 | PTR_ERR(nop->vcc)); | 174 | PTR_ERR(nop->vcc)); |
204 | if (needs_vcc) | 175 | if (needs_vcc) |
205 | return -EPROBE_DEFER; | 176 | return -EPROBE_DEFER; |
206 | } | 177 | } |
207 | 178 | ||
208 | nop->reset = devm_regulator_get(&pdev->dev, "reset"); | 179 | nop->reset = devm_regulator_get(dev, "reset"); |
209 | if (IS_ERR(nop->reset)) { | 180 | if (IS_ERR(nop->reset)) { |
210 | dev_dbg(&pdev->dev, "Error getting reset regulator: %ld\n", | 181 | dev_dbg(dev, "Error getting reset regulator: %ld\n", |
211 | PTR_ERR(nop->reset)); | 182 | PTR_ERR(nop->reset)); |
212 | if (needs_reset) | 183 | if (needs_reset) |
213 | return -EPROBE_DEFER; | 184 | return -EPROBE_DEFER; |
214 | } | 185 | } |
215 | 186 | ||
216 | nop->dev = &pdev->dev; | 187 | nop->dev = dev; |
217 | nop->phy.dev = nop->dev; | 188 | nop->phy.dev = nop->dev; |
218 | nop->phy.label = "nop-xceiv"; | 189 | nop->phy.label = "nop-xceiv"; |
219 | nop->phy.set_suspend = nop_set_suspend; | 190 | nop->phy.set_suspend = nop_set_suspend; |
220 | nop->phy.init = nop_init; | ||
221 | nop->phy.shutdown = nop_shutdown; | ||
222 | nop->phy.state = OTG_STATE_UNDEFINED; | 191 | nop->phy.state = OTG_STATE_UNDEFINED; |
223 | nop->phy.type = type; | 192 | nop->phy.type = type; |
224 | 193 | ||
@@ -226,6 +195,59 @@ static int nop_usb_xceiv_probe(struct platform_device *pdev) | |||
226 | nop->phy.otg->set_host = nop_set_host; | 195 | nop->phy.otg->set_host = nop_set_host; |
227 | nop->phy.otg->set_peripheral = nop_set_peripheral; | 196 | nop->phy.otg->set_peripheral = nop_set_peripheral; |
228 | 197 | ||
198 | ATOMIC_INIT_NOTIFIER_HEAD(&nop->phy.notifier); | ||
199 | return 0; | ||
200 | } | ||
201 | EXPORT_SYMBOL_GPL(usb_phy_gen_create_phy); | ||
202 | |||
203 | void usb_phy_gen_cleanup_phy(struct usb_phy_gen_xceiv *nop) | ||
204 | { | ||
205 | if (!IS_ERR(nop->clk)) | ||
206 | clk_unprepare(nop->clk); | ||
207 | } | ||
208 | EXPORT_SYMBOL_GPL(usb_phy_gen_cleanup_phy); | ||
209 | |||
210 | static int usb_phy_gen_xceiv_probe(struct platform_device *pdev) | ||
211 | { | ||
212 | struct device *dev = &pdev->dev; | ||
213 | struct usb_phy_gen_xceiv_platform_data *pdata = | ||
214 | dev_get_platdata(&pdev->dev); | ||
215 | struct usb_phy_gen_xceiv *nop; | ||
216 | enum usb_phy_type type = USB_PHY_TYPE_USB2; | ||
217 | int err; | ||
218 | u32 clk_rate = 0; | ||
219 | bool needs_vcc = false; | ||
220 | bool needs_reset = false; | ||
221 | |||
222 | if (dev->of_node) { | ||
223 | struct device_node *node = dev->of_node; | ||
224 | |||
225 | if (of_property_read_u32(node, "clock-frequency", &clk_rate)) | ||
226 | clk_rate = 0; | ||
227 | |||
228 | needs_vcc = of_property_read_bool(node, "vcc-supply"); | ||
229 | needs_reset = of_property_read_bool(node, "reset-supply"); | ||
230 | |||
231 | } else if (pdata) { | ||
232 | type = pdata->type; | ||
233 | clk_rate = pdata->clk_rate; | ||
234 | needs_vcc = pdata->needs_vcc; | ||
235 | needs_reset = pdata->needs_reset; | ||
236 | } | ||
237 | |||
238 | nop = devm_kzalloc(dev, sizeof(*nop), GFP_KERNEL); | ||
239 | if (!nop) | ||
240 | return -ENOMEM; | ||
241 | |||
242 | |||
243 | err = usb_phy_gen_create_phy(dev, nop, type, clk_rate, needs_vcc, | ||
244 | needs_reset); | ||
245 | if (err) | ||
246 | return err; | ||
247 | |||
248 | nop->phy.init = usb_gen_phy_init; | ||
249 | nop->phy.shutdown = usb_gen_phy_shutdown; | ||
250 | |||
229 | err = usb_add_phy_dev(&nop->phy); | 251 | err = usb_add_phy_dev(&nop->phy); |
230 | if (err) { | 252 | if (err) { |
231 | dev_err(&pdev->dev, "can't register transceiver, err: %d\n", | 253 | dev_err(&pdev->dev, "can't register transceiver, err: %d\n", |
@@ -235,23 +257,18 @@ static int nop_usb_xceiv_probe(struct platform_device *pdev) | |||
235 | 257 | ||
236 | platform_set_drvdata(pdev, nop); | 258 | platform_set_drvdata(pdev, nop); |
237 | 259 | ||
238 | ATOMIC_INIT_NOTIFIER_HEAD(&nop->phy.notifier); | ||
239 | |||
240 | return 0; | 260 | return 0; |
241 | 261 | ||
242 | err_add: | 262 | err_add: |
243 | if (!IS_ERR(nop->clk)) | 263 | usb_phy_gen_cleanup_phy(nop); |
244 | clk_unprepare(nop->clk); | ||
245 | return err; | 264 | return err; |
246 | } | 265 | } |
247 | 266 | ||
248 | static int nop_usb_xceiv_remove(struct platform_device *pdev) | 267 | static int usb_phy_gen_xceiv_remove(struct platform_device *pdev) |
249 | { | 268 | { |
250 | struct nop_usb_xceiv *nop = platform_get_drvdata(pdev); | 269 | struct usb_phy_gen_xceiv *nop = platform_get_drvdata(pdev); |
251 | |||
252 | if (!IS_ERR(nop->clk)) | ||
253 | clk_unprepare(nop->clk); | ||
254 | 270 | ||
271 | usb_phy_gen_cleanup_phy(nop); | ||
255 | usb_remove_phy(&nop->phy); | 272 | usb_remove_phy(&nop->phy); |
256 | 273 | ||
257 | return 0; | 274 | return 0; |
@@ -264,29 +281,29 @@ static const struct of_device_id nop_xceiv_dt_ids[] = { | |||
264 | 281 | ||
265 | MODULE_DEVICE_TABLE(of, nop_xceiv_dt_ids); | 282 | MODULE_DEVICE_TABLE(of, nop_xceiv_dt_ids); |
266 | 283 | ||
267 | static struct platform_driver nop_usb_xceiv_driver = { | 284 | static struct platform_driver usb_phy_gen_xceiv_driver = { |
268 | .probe = nop_usb_xceiv_probe, | 285 | .probe = usb_phy_gen_xceiv_probe, |
269 | .remove = nop_usb_xceiv_remove, | 286 | .remove = usb_phy_gen_xceiv_remove, |
270 | .driver = { | 287 | .driver = { |
271 | .name = "nop_usb_xceiv", | 288 | .name = "usb_phy_gen_xceiv", |
272 | .owner = THIS_MODULE, | 289 | .owner = THIS_MODULE, |
273 | .of_match_table = nop_xceiv_dt_ids, | 290 | .of_match_table = nop_xceiv_dt_ids, |
274 | }, | 291 | }, |
275 | }; | 292 | }; |
276 | 293 | ||
277 | static int __init nop_usb_xceiv_init(void) | 294 | static int __init usb_phy_gen_xceiv_init(void) |
278 | { | 295 | { |
279 | return platform_driver_register(&nop_usb_xceiv_driver); | 296 | return platform_driver_register(&usb_phy_gen_xceiv_driver); |
280 | } | 297 | } |
281 | subsys_initcall(nop_usb_xceiv_init); | 298 | subsys_initcall(usb_phy_gen_xceiv_init); |
282 | 299 | ||
283 | static void __exit nop_usb_xceiv_exit(void) | 300 | static void __exit usb_phy_gen_xceiv_exit(void) |
284 | { | 301 | { |
285 | platform_driver_unregister(&nop_usb_xceiv_driver); | 302 | platform_driver_unregister(&usb_phy_gen_xceiv_driver); |
286 | } | 303 | } |
287 | module_exit(nop_usb_xceiv_exit); | 304 | module_exit(usb_phy_gen_xceiv_exit); |
288 | 305 | ||
289 | MODULE_ALIAS("platform:nop_usb_xceiv"); | 306 | MODULE_ALIAS("platform:usb_phy_gen_xceiv"); |
290 | MODULE_AUTHOR("Texas Instruments Inc"); | 307 | MODULE_AUTHOR("Texas Instruments Inc"); |
291 | MODULE_DESCRIPTION("NOP USB Transceiver driver"); | 308 | MODULE_DESCRIPTION("NOP USB Transceiver driver"); |
292 | MODULE_LICENSE("GPL"); | 309 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/usb/phy/phy-generic.h b/drivers/usb/phy/phy-generic.h new file mode 100644 index 000000000000..61687d5a965b --- /dev/null +++ b/drivers/usb/phy/phy-generic.h | |||
@@ -0,0 +1,20 @@ | |||
1 | #ifndef _PHY_GENERIC_H_ | ||
2 | #define _PHY_GENERIC_H_ | ||
3 | |||
4 | struct usb_phy_gen_xceiv { | ||
5 | struct usb_phy phy; | ||
6 | struct device *dev; | ||
7 | struct clk *clk; | ||
8 | struct regulator *vcc; | ||
9 | struct regulator *reset; | ||
10 | }; | ||
11 | |||
12 | int usb_gen_phy_init(struct usb_phy *phy); | ||
13 | void usb_gen_phy_shutdown(struct usb_phy *phy); | ||
14 | |||
15 | int usb_phy_gen_create_phy(struct device *dev, struct usb_phy_gen_xceiv *nop, | ||
16 | enum usb_phy_type type, u32 clk_rate, bool needs_vcc, | ||
17 | bool needs_reset); | ||
18 | void usb_phy_gen_cleanup_phy(struct usb_phy_gen_xceiv *nop); | ||
19 | |||
20 | #endif | ||
diff --git a/drivers/usb/phy/phy-gpio-vbus-usb.c b/drivers/usb/phy/phy-gpio-vbus-usb.c index 8443335c2ea0..b2f29c9aebbf 100644 --- a/drivers/usb/phy/phy-gpio-vbus-usb.c +++ b/drivers/usb/phy/phy-gpio-vbus-usb.c | |||
@@ -101,7 +101,7 @@ static void gpio_vbus_work(struct work_struct *work) | |||
101 | { | 101 | { |
102 | struct gpio_vbus_data *gpio_vbus = | 102 | struct gpio_vbus_data *gpio_vbus = |
103 | container_of(work, struct gpio_vbus_data, work.work); | 103 | container_of(work, struct gpio_vbus_data, work.work); |
104 | struct gpio_vbus_mach_info *pdata = gpio_vbus->dev->platform_data; | 104 | struct gpio_vbus_mach_info *pdata = dev_get_platdata(gpio_vbus->dev); |
105 | int gpio, status, vbus; | 105 | int gpio, status, vbus; |
106 | 106 | ||
107 | if (!gpio_vbus->phy.otg->gadget) | 107 | if (!gpio_vbus->phy.otg->gadget) |
@@ -155,7 +155,7 @@ static void gpio_vbus_work(struct work_struct *work) | |||
155 | static irqreturn_t gpio_vbus_irq(int irq, void *data) | 155 | static irqreturn_t gpio_vbus_irq(int irq, void *data) |
156 | { | 156 | { |
157 | struct platform_device *pdev = data; | 157 | struct platform_device *pdev = data; |
158 | struct gpio_vbus_mach_info *pdata = pdev->dev.platform_data; | 158 | struct gpio_vbus_mach_info *pdata = dev_get_platdata(&pdev->dev); |
159 | struct gpio_vbus_data *gpio_vbus = platform_get_drvdata(pdev); | 159 | struct gpio_vbus_data *gpio_vbus = platform_get_drvdata(pdev); |
160 | struct usb_otg *otg = gpio_vbus->phy.otg; | 160 | struct usb_otg *otg = gpio_vbus->phy.otg; |
161 | 161 | ||
@@ -182,7 +182,7 @@ static int gpio_vbus_set_peripheral(struct usb_otg *otg, | |||
182 | 182 | ||
183 | gpio_vbus = container_of(otg->phy, struct gpio_vbus_data, phy); | 183 | gpio_vbus = container_of(otg->phy, struct gpio_vbus_data, phy); |
184 | pdev = to_platform_device(gpio_vbus->dev); | 184 | pdev = to_platform_device(gpio_vbus->dev); |
185 | pdata = gpio_vbus->dev->platform_data; | 185 | pdata = dev_get_platdata(gpio_vbus->dev); |
186 | gpio = pdata->gpio_pullup; | 186 | gpio = pdata->gpio_pullup; |
187 | 187 | ||
188 | if (!gadget) { | 188 | if (!gadget) { |
@@ -243,7 +243,7 @@ static int gpio_vbus_set_suspend(struct usb_phy *phy, int suspend) | |||
243 | 243 | ||
244 | static int __init gpio_vbus_probe(struct platform_device *pdev) | 244 | static int __init gpio_vbus_probe(struct platform_device *pdev) |
245 | { | 245 | { |
246 | struct gpio_vbus_mach_info *pdata = pdev->dev.platform_data; | 246 | struct gpio_vbus_mach_info *pdata = dev_get_platdata(&pdev->dev); |
247 | struct gpio_vbus_data *gpio_vbus; | 247 | struct gpio_vbus_data *gpio_vbus; |
248 | struct resource *res; | 248 | struct resource *res; |
249 | int err, gpio, irq; | 249 | int err, gpio, irq; |
@@ -352,7 +352,7 @@ err_gpio: | |||
352 | static int __exit gpio_vbus_remove(struct platform_device *pdev) | 352 | static int __exit gpio_vbus_remove(struct platform_device *pdev) |
353 | { | 353 | { |
354 | struct gpio_vbus_data *gpio_vbus = platform_get_drvdata(pdev); | 354 | struct gpio_vbus_data *gpio_vbus = platform_get_drvdata(pdev); |
355 | struct gpio_vbus_mach_info *pdata = pdev->dev.platform_data; | 355 | struct gpio_vbus_mach_info *pdata = dev_get_platdata(&pdev->dev); |
356 | int gpio = pdata->gpio_vbus; | 356 | int gpio = pdata->gpio_vbus; |
357 | 357 | ||
358 | device_init_wakeup(&pdev->dev, 0); | 358 | device_init_wakeup(&pdev->dev, 0); |
diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c index d08f33435e96..e9d4cd960ecd 100644 --- a/drivers/usb/phy/phy-msm-usb.c +++ b/drivers/usb/phy/phy-msm-usb.c | |||
@@ -1419,7 +1419,7 @@ static int __init msm_otg_probe(struct platform_device *pdev) | |||
1419 | struct usb_phy *phy; | 1419 | struct usb_phy *phy; |
1420 | 1420 | ||
1421 | dev_info(&pdev->dev, "msm_otg probe\n"); | 1421 | dev_info(&pdev->dev, "msm_otg probe\n"); |
1422 | if (!pdev->dev.platform_data) { | 1422 | if (!dev_get_platdata(&pdev->dev)) { |
1423 | dev_err(&pdev->dev, "No platform data given. Bailing out\n"); | 1423 | dev_err(&pdev->dev, "No platform data given. Bailing out\n"); |
1424 | return -ENODEV; | 1424 | return -ENODEV; |
1425 | } | 1425 | } |
@@ -1436,7 +1436,7 @@ static int __init msm_otg_probe(struct platform_device *pdev) | |||
1436 | return -ENOMEM; | 1436 | return -ENOMEM; |
1437 | } | 1437 | } |
1438 | 1438 | ||
1439 | motg->pdata = pdev->dev.platform_data; | 1439 | motg->pdata = dev_get_platdata(&pdev->dev); |
1440 | phy = &motg->phy; | 1440 | phy = &motg->phy; |
1441 | phy->dev = &pdev->dev; | 1441 | phy->dev = &pdev->dev; |
1442 | 1442 | ||
diff --git a/drivers/usb/phy/phy-mv-u3d-usb.c b/drivers/usb/phy/phy-mv-u3d-usb.c index 1568ea63e338..d317903022bf 100644 --- a/drivers/usb/phy/phy-mv-u3d-usb.c +++ b/drivers/usb/phy/phy-mv-u3d-usb.c | |||
@@ -82,7 +82,7 @@ static void mv_u3d_phy_write(void __iomem *base, u32 reg, u32 value) | |||
82 | writel_relaxed(value, data); | 82 | writel_relaxed(value, data); |
83 | } | 83 | } |
84 | 84 | ||
85 | void mv_u3d_phy_shutdown(struct usb_phy *phy) | 85 | static void mv_u3d_phy_shutdown(struct usb_phy *phy) |
86 | { | 86 | { |
87 | struct mv_u3d_phy *mv_u3d_phy; | 87 | struct mv_u3d_phy *mv_u3d_phy; |
88 | void __iomem *base; | 88 | void __iomem *base; |
@@ -271,7 +271,7 @@ static int mv_u3d_phy_probe(struct platform_device *pdev) | |||
271 | void __iomem *phy_base; | 271 | void __iomem *phy_base; |
272 | int ret; | 272 | int ret; |
273 | 273 | ||
274 | pdata = pdev->dev.platform_data; | 274 | pdata = dev_get_platdata(&pdev->dev); |
275 | if (!pdata) { | 275 | if (!pdata) { |
276 | dev_err(&pdev->dev, "%s: no platform data defined\n", __func__); | 276 | dev_err(&pdev->dev, "%s: no platform data defined\n", __func__); |
277 | return -EINVAL; | 277 | return -EINVAL; |
diff --git a/drivers/usb/phy/phy-mv-usb.c b/drivers/usb/phy/phy-mv-usb.c index 4a6b03c73876..98f6ac6a78ea 100644 --- a/drivers/usb/phy/phy-mv-usb.c +++ b/drivers/usb/phy/phy-mv-usb.c | |||
@@ -653,7 +653,7 @@ static struct attribute_group inputs_attr_group = { | |||
653 | .attrs = inputs_attrs, | 653 | .attrs = inputs_attrs, |
654 | }; | 654 | }; |
655 | 655 | ||
656 | int mv_otg_remove(struct platform_device *pdev) | 656 | static int mv_otg_remove(struct platform_device *pdev) |
657 | { | 657 | { |
658 | struct mv_otg *mvotg = platform_get_drvdata(pdev); | 658 | struct mv_otg *mvotg = platform_get_drvdata(pdev); |
659 | 659 | ||
@@ -673,7 +673,7 @@ int mv_otg_remove(struct platform_device *pdev) | |||
673 | 673 | ||
674 | static int mv_otg_probe(struct platform_device *pdev) | 674 | static int mv_otg_probe(struct platform_device *pdev) |
675 | { | 675 | { |
676 | struct mv_usb_platform_data *pdata = pdev->dev.platform_data; | 676 | struct mv_usb_platform_data *pdata = dev_get_platdata(&pdev->dev); |
677 | struct mv_otg *mvotg; | 677 | struct mv_otg *mvotg; |
678 | struct usb_otg *otg; | 678 | struct usb_otg *otg; |
679 | struct resource *r; | 679 | struct resource *r; |
@@ -893,7 +893,7 @@ static int mv_otg_resume(struct platform_device *pdev) | |||
893 | 893 | ||
894 | static struct platform_driver mv_otg_driver = { | 894 | static struct platform_driver mv_otg_driver = { |
895 | .probe = mv_otg_probe, | 895 | .probe = mv_otg_probe, |
896 | .remove = __exit_p(mv_otg_remove), | 896 | .remove = mv_otg_remove, |
897 | .driver = { | 897 | .driver = { |
898 | .owner = THIS_MODULE, | 898 | .owner = THIS_MODULE, |
899 | .name = driver_name, | 899 | .name = driver_name, |
diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-usb.c index bd601c537c8d..fdd33b44dbd3 100644 --- a/drivers/usb/phy/phy-mxs-usb.c +++ b/drivers/usb/phy/phy-mxs-usb.c | |||
@@ -41,11 +41,14 @@ struct mxs_phy { | |||
41 | 41 | ||
42 | #define to_mxs_phy(p) container_of((p), struct mxs_phy, phy) | 42 | #define to_mxs_phy(p) container_of((p), struct mxs_phy, phy) |
43 | 43 | ||
44 | static void mxs_phy_hw_init(struct mxs_phy *mxs_phy) | 44 | static int mxs_phy_hw_init(struct mxs_phy *mxs_phy) |
45 | { | 45 | { |
46 | int ret; | ||
46 | void __iomem *base = mxs_phy->phy.io_priv; | 47 | void __iomem *base = mxs_phy->phy.io_priv; |
47 | 48 | ||
48 | stmp_reset_block(base + HW_USBPHY_CTRL); | 49 | ret = stmp_reset_block(base + HW_USBPHY_CTRL); |
50 | if (ret) | ||
51 | return ret; | ||
49 | 52 | ||
50 | /* Power up the PHY */ | 53 | /* Power up the PHY */ |
51 | writel(0, base + HW_USBPHY_PWD); | 54 | writel(0, base + HW_USBPHY_PWD); |
@@ -54,6 +57,8 @@ static void mxs_phy_hw_init(struct mxs_phy *mxs_phy) | |||
54 | writel(BM_USBPHY_CTRL_ENUTMILEVEL2 | | 57 | writel(BM_USBPHY_CTRL_ENUTMILEVEL2 | |
55 | BM_USBPHY_CTRL_ENUTMILEVEL3, | 58 | BM_USBPHY_CTRL_ENUTMILEVEL3, |
56 | base + HW_USBPHY_CTRL_SET); | 59 | base + HW_USBPHY_CTRL_SET); |
60 | |||
61 | return 0; | ||
57 | } | 62 | } |
58 | 63 | ||
59 | static int mxs_phy_init(struct usb_phy *phy) | 64 | static int mxs_phy_init(struct usb_phy *phy) |
@@ -61,9 +66,7 @@ static int mxs_phy_init(struct usb_phy *phy) | |||
61 | struct mxs_phy *mxs_phy = to_mxs_phy(phy); | 66 | struct mxs_phy *mxs_phy = to_mxs_phy(phy); |
62 | 67 | ||
63 | clk_prepare_enable(mxs_phy->clk); | 68 | clk_prepare_enable(mxs_phy->clk); |
64 | mxs_phy_hw_init(mxs_phy); | 69 | return mxs_phy_hw_init(mxs_phy); |
65 | |||
66 | return 0; | ||
67 | } | 70 | } |
68 | 71 | ||
69 | static void mxs_phy_shutdown(struct usb_phy *phy) | 72 | static void mxs_phy_shutdown(struct usb_phy *phy) |
diff --git a/drivers/usb/phy/phy-omap-control.c b/drivers/usb/phy/phy-omap-control.c index 1419ceda9759..a4dda8e12562 100644 --- a/drivers/usb/phy/phy-omap-control.c +++ b/drivers/usb/phy/phy-omap-control.c | |||
@@ -197,7 +197,8 @@ static int omap_control_usb_probe(struct platform_device *pdev) | |||
197 | { | 197 | { |
198 | struct resource *res; | 198 | struct resource *res; |
199 | struct device_node *np = pdev->dev.of_node; | 199 | struct device_node *np = pdev->dev.of_node; |
200 | struct omap_control_usb_platform_data *pdata = pdev->dev.platform_data; | 200 | struct omap_control_usb_platform_data *pdata = |
201 | dev_get_platdata(&pdev->dev); | ||
201 | 202 | ||
202 | control_usb = devm_kzalloc(&pdev->dev, sizeof(*control_usb), | 203 | control_usb = devm_kzalloc(&pdev->dev, sizeof(*control_usb), |
203 | GFP_KERNEL); | 204 | GFP_KERNEL); |
diff --git a/drivers/usb/phy/phy-omap-usb3.c b/drivers/usb/phy/phy-omap-usb3.c index a2fb30bbb971..fc15694d3031 100644 --- a/drivers/usb/phy/phy-omap-usb3.c +++ b/drivers/usb/phy/phy-omap-usb3.c | |||
@@ -27,7 +27,6 @@ | |||
27 | #include <linux/delay.h> | 27 | #include <linux/delay.h> |
28 | #include <linux/usb/omap_control_usb.h> | 28 | #include <linux/usb/omap_control_usb.h> |
29 | 29 | ||
30 | #define NUM_SYS_CLKS 6 | ||
31 | #define PLL_STATUS 0x00000004 | 30 | #define PLL_STATUS 0x00000004 |
32 | #define PLL_GO 0x00000008 | 31 | #define PLL_GO 0x00000008 |
33 | #define PLL_CONFIGURATION1 0x0000000C | 32 | #define PLL_CONFIGURATION1 0x0000000C |
@@ -57,26 +56,32 @@ | |||
57 | */ | 56 | */ |
58 | # define PLL_IDLE_TIME 100; | 57 | # define PLL_IDLE_TIME 100; |
59 | 58 | ||
60 | enum sys_clk_rate { | 59 | struct usb_dpll_map { |
61 | CLK_RATE_UNDEFINED = -1, | 60 | unsigned long rate; |
62 | CLK_RATE_12MHZ, | 61 | struct usb_dpll_params params; |
63 | CLK_RATE_16MHZ, | ||
64 | CLK_RATE_19MHZ, | ||
65 | CLK_RATE_20MHZ, | ||
66 | CLK_RATE_26MHZ, | ||
67 | CLK_RATE_38MHZ | ||
68 | }; | 62 | }; |
69 | 63 | ||
70 | static struct usb_dpll_params omap_usb3_dpll_params[NUM_SYS_CLKS] = { | 64 | static struct usb_dpll_map dpll_map[] = { |
71 | {1250, 5, 4, 20, 0}, /* 12 MHz */ | 65 | {12000000, {1250, 5, 4, 20, 0} }, /* 12 MHz */ |
72 | {3125, 20, 4, 20, 0}, /* 16.8 MHz */ | 66 | {16800000, {3125, 20, 4, 20, 0} }, /* 16.8 MHz */ |
73 | {1172, 8, 4, 20, 65537}, /* 19.2 MHz */ | 67 | {19200000, {1172, 8, 4, 20, 65537} }, /* 19.2 MHz */ |
74 | {1000, 7, 4, 10, 0}, /* 20 MHz */ | 68 | {20000000, {1000, 7, 4, 10, 0} }, /* 20 MHz */ |
75 | {1250, 12, 4, 20, 0}, /* 26 MHz */ | 69 | {26000000, {1250, 12, 4, 20, 0} }, /* 26 MHz */ |
76 | {3125, 47, 4, 20, 92843}, /* 38.4 MHz */ | 70 | {38400000, {3125, 47, 4, 20, 92843} }, /* 38.4 MHz */ |
77 | |||
78 | }; | 71 | }; |
79 | 72 | ||
73 | static struct usb_dpll_params *omap_usb3_get_dpll_params(unsigned long rate) | ||
74 | { | ||
75 | int i; | ||
76 | |||
77 | for (i = 0; i < ARRAY_SIZE(dpll_map); i++) { | ||
78 | if (rate == dpll_map[i].rate) | ||
79 | return &dpll_map[i].params; | ||
80 | } | ||
81 | |||
82 | return 0; | ||
83 | } | ||
84 | |||
80 | static int omap_usb3_suspend(struct usb_phy *x, int suspend) | 85 | static int omap_usb3_suspend(struct usb_phy *x, int suspend) |
81 | { | 86 | { |
82 | struct omap_usb *phy = phy_to_omapusb(x); | 87 | struct omap_usb *phy = phy_to_omapusb(x); |
@@ -116,26 +121,6 @@ static int omap_usb3_suspend(struct usb_phy *x, int suspend) | |||
116 | return 0; | 121 | return 0; |
117 | } | 122 | } |
118 | 123 | ||
119 | static inline enum sys_clk_rate __get_sys_clk_index(unsigned long rate) | ||
120 | { | ||
121 | switch (rate) { | ||
122 | case 12000000: | ||
123 | return CLK_RATE_12MHZ; | ||
124 | case 16800000: | ||
125 | return CLK_RATE_16MHZ; | ||
126 | case 19200000: | ||
127 | return CLK_RATE_19MHZ; | ||
128 | case 20000000: | ||
129 | return CLK_RATE_20MHZ; | ||
130 | case 26000000: | ||
131 | return CLK_RATE_26MHZ; | ||
132 | case 38400000: | ||
133 | return CLK_RATE_38MHZ; | ||
134 | default: | ||
135 | return CLK_RATE_UNDEFINED; | ||
136 | } | ||
137 | } | ||
138 | |||
139 | static void omap_usb_dpll_relock(struct omap_usb *phy) | 124 | static void omap_usb_dpll_relock(struct omap_usb *phy) |
140 | { | 125 | { |
141 | u32 val; | 126 | u32 val; |
@@ -155,39 +140,39 @@ static int omap_usb_dpll_lock(struct omap_usb *phy) | |||
155 | { | 140 | { |
156 | u32 val; | 141 | u32 val; |
157 | unsigned long rate; | 142 | unsigned long rate; |
158 | enum sys_clk_rate clk_index; | 143 | struct usb_dpll_params *dpll_params; |
159 | |||
160 | rate = clk_get_rate(phy->sys_clk); | ||
161 | clk_index = __get_sys_clk_index(rate); | ||
162 | 144 | ||
163 | if (clk_index == CLK_RATE_UNDEFINED) { | 145 | rate = clk_get_rate(phy->sys_clk); |
164 | pr_err("dpll cannot be locked for sys clk freq:%luHz\n", rate); | 146 | dpll_params = omap_usb3_get_dpll_params(rate); |
147 | if (!dpll_params) { | ||
148 | dev_err(phy->dev, | ||
149 | "No DPLL configuration for %lu Hz SYS CLK\n", rate); | ||
165 | return -EINVAL; | 150 | return -EINVAL; |
166 | } | 151 | } |
167 | 152 | ||
168 | val = omap_usb_readl(phy->pll_ctrl_base, PLL_CONFIGURATION1); | 153 | val = omap_usb_readl(phy->pll_ctrl_base, PLL_CONFIGURATION1); |
169 | val &= ~PLL_REGN_MASK; | 154 | val &= ~PLL_REGN_MASK; |
170 | val |= omap_usb3_dpll_params[clk_index].n << PLL_REGN_SHIFT; | 155 | val |= dpll_params->n << PLL_REGN_SHIFT; |
171 | omap_usb_writel(phy->pll_ctrl_base, PLL_CONFIGURATION1, val); | 156 | omap_usb_writel(phy->pll_ctrl_base, PLL_CONFIGURATION1, val); |
172 | 157 | ||
173 | val = omap_usb_readl(phy->pll_ctrl_base, PLL_CONFIGURATION2); | 158 | val = omap_usb_readl(phy->pll_ctrl_base, PLL_CONFIGURATION2); |
174 | val &= ~PLL_SELFREQDCO_MASK; | 159 | val &= ~PLL_SELFREQDCO_MASK; |
175 | val |= omap_usb3_dpll_params[clk_index].freq << PLL_SELFREQDCO_SHIFT; | 160 | val |= dpll_params->freq << PLL_SELFREQDCO_SHIFT; |
176 | omap_usb_writel(phy->pll_ctrl_base, PLL_CONFIGURATION2, val); | 161 | omap_usb_writel(phy->pll_ctrl_base, PLL_CONFIGURATION2, val); |
177 | 162 | ||
178 | val = omap_usb_readl(phy->pll_ctrl_base, PLL_CONFIGURATION1); | 163 | val = omap_usb_readl(phy->pll_ctrl_base, PLL_CONFIGURATION1); |
179 | val &= ~PLL_REGM_MASK; | 164 | val &= ~PLL_REGM_MASK; |
180 | val |= omap_usb3_dpll_params[clk_index].m << PLL_REGM_SHIFT; | 165 | val |= dpll_params->m << PLL_REGM_SHIFT; |
181 | omap_usb_writel(phy->pll_ctrl_base, PLL_CONFIGURATION1, val); | 166 | omap_usb_writel(phy->pll_ctrl_base, PLL_CONFIGURATION1, val); |
182 | 167 | ||
183 | val = omap_usb_readl(phy->pll_ctrl_base, PLL_CONFIGURATION4); | 168 | val = omap_usb_readl(phy->pll_ctrl_base, PLL_CONFIGURATION4); |
184 | val &= ~PLL_REGM_F_MASK; | 169 | val &= ~PLL_REGM_F_MASK; |
185 | val |= omap_usb3_dpll_params[clk_index].mf << PLL_REGM_F_SHIFT; | 170 | val |= dpll_params->mf << PLL_REGM_F_SHIFT; |
186 | omap_usb_writel(phy->pll_ctrl_base, PLL_CONFIGURATION4, val); | 171 | omap_usb_writel(phy->pll_ctrl_base, PLL_CONFIGURATION4, val); |
187 | 172 | ||
188 | val = omap_usb_readl(phy->pll_ctrl_base, PLL_CONFIGURATION3); | 173 | val = omap_usb_readl(phy->pll_ctrl_base, PLL_CONFIGURATION3); |
189 | val &= ~PLL_SD_MASK; | 174 | val &= ~PLL_SD_MASK; |
190 | val |= omap_usb3_dpll_params[clk_index].sd << PLL_SD_SHIFT; | 175 | val |= dpll_params->sd << PLL_SD_SHIFT; |
191 | omap_usb_writel(phy->pll_ctrl_base, PLL_CONFIGURATION3, val); | 176 | omap_usb_writel(phy->pll_ctrl_base, PLL_CONFIGURATION3, val); |
192 | 177 | ||
193 | omap_usb_dpll_relock(phy); | 178 | omap_usb_dpll_relock(phy); |
@@ -198,8 +183,12 @@ static int omap_usb_dpll_lock(struct omap_usb *phy) | |||
198 | static int omap_usb3_init(struct usb_phy *x) | 183 | static int omap_usb3_init(struct usb_phy *x) |
199 | { | 184 | { |
200 | struct omap_usb *phy = phy_to_omapusb(x); | 185 | struct omap_usb *phy = phy_to_omapusb(x); |
186 | int ret; | ||
187 | |||
188 | ret = omap_usb_dpll_lock(phy); | ||
189 | if (ret) | ||
190 | return ret; | ||
201 | 191 | ||
202 | omap_usb_dpll_lock(phy); | ||
203 | omap_control_usb3_phy_power(phy->control_dev, 1); | 192 | omap_control_usb3_phy_power(phy->control_dev, 1); |
204 | 193 | ||
205 | return 0; | 194 | return 0; |
diff --git a/drivers/usb/phy/phy-rcar-usb.c b/drivers/usb/phy/phy-rcar-usb.c index ae909408958d..33265a5b2cdf 100644 --- a/drivers/usb/phy/phy-rcar-usb.c +++ b/drivers/usb/phy/phy-rcar-usb.c | |||
@@ -83,7 +83,7 @@ static int rcar_usb_phy_init(struct usb_phy *phy) | |||
83 | { | 83 | { |
84 | struct rcar_usb_phy_priv *priv = usb_phy_to_priv(phy); | 84 | struct rcar_usb_phy_priv *priv = usb_phy_to_priv(phy); |
85 | struct device *dev = phy->dev; | 85 | struct device *dev = phy->dev; |
86 | struct rcar_phy_platform_data *pdata = dev->platform_data; | 86 | struct rcar_phy_platform_data *pdata = dev_get_platdata(dev); |
87 | void __iomem *reg0 = priv->reg0; | 87 | void __iomem *reg0 = priv->reg0; |
88 | void __iomem *reg1 = priv->reg1; | 88 | void __iomem *reg1 = priv->reg1; |
89 | static const u8 ovcn_act[] = { OVC0_ACT, OVC1_ACT, OVC2_ACT }; | 89 | static const u8 ovcn_act[] = { OVC0_ACT, OVC1_ACT, OVC2_ACT }; |
@@ -184,17 +184,12 @@ static int rcar_usb_phy_probe(struct platform_device *pdev) | |||
184 | void __iomem *reg0, *reg1 = NULL; | 184 | void __iomem *reg0, *reg1 = NULL; |
185 | int ret; | 185 | int ret; |
186 | 186 | ||
187 | if (!pdev->dev.platform_data) { | 187 | if (!dev_get_platdata(&pdev->dev)) { |
188 | dev_err(dev, "No platform data\n"); | 188 | dev_err(dev, "No platform data\n"); |
189 | return -EINVAL; | 189 | return -EINVAL; |
190 | } | 190 | } |
191 | 191 | ||
192 | res0 = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 192 | res0 = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
193 | if (!res0) { | ||
194 | dev_err(dev, "Not enough platform resources\n"); | ||
195 | return -EINVAL; | ||
196 | } | ||
197 | |||
198 | reg0 = devm_ioremap_resource(dev, res0); | 193 | reg0 = devm_ioremap_resource(dev, res0); |
199 | if (IS_ERR(reg0)) | 194 | if (IS_ERR(reg0)) |
200 | return PTR_ERR(reg0); | 195 | return PTR_ERR(reg0); |
diff --git a/drivers/usb/phy/phy-samsung-usb2.c b/drivers/usb/phy/phy-samsung-usb2.c index 758b86d0fcb3..ff70e4b19b97 100644 --- a/drivers/usb/phy/phy-samsung-usb2.c +++ b/drivers/usb/phy/phy-samsung-usb2.c | |||
@@ -359,7 +359,7 @@ static int samsung_usb2phy_probe(struct platform_device *pdev) | |||
359 | { | 359 | { |
360 | struct samsung_usbphy *sphy; | 360 | struct samsung_usbphy *sphy; |
361 | struct usb_otg *otg; | 361 | struct usb_otg *otg; |
362 | struct samsung_usbphy_data *pdata = pdev->dev.platform_data; | 362 | struct samsung_usbphy_data *pdata = dev_get_platdata(&pdev->dev); |
363 | const struct samsung_usbphy_drvdata *drv_data; | 363 | const struct samsung_usbphy_drvdata *drv_data; |
364 | struct device *dev = &pdev->dev; | 364 | struct device *dev = &pdev->dev; |
365 | struct resource *phy_mem; | 365 | struct resource *phy_mem; |
diff --git a/drivers/usb/phy/phy-samsung-usb3.c b/drivers/usb/phy/phy-samsung-usb3.c index 300e0cf5e31f..c6eb22213de6 100644 --- a/drivers/usb/phy/phy-samsung-usb3.c +++ b/drivers/usb/phy/phy-samsung-usb3.c | |||
@@ -231,7 +231,7 @@ static void samsung_usb3phy_shutdown(struct usb_phy *phy) | |||
231 | static int samsung_usb3phy_probe(struct platform_device *pdev) | 231 | static int samsung_usb3phy_probe(struct platform_device *pdev) |
232 | { | 232 | { |
233 | struct samsung_usbphy *sphy; | 233 | struct samsung_usbphy *sphy; |
234 | struct samsung_usbphy_data *pdata = pdev->dev.platform_data; | 234 | struct samsung_usbphy_data *pdata = dev_get_platdata(&pdev->dev); |
235 | struct device *dev = &pdev->dev; | 235 | struct device *dev = &pdev->dev; |
236 | struct resource *phy_mem; | 236 | struct resource *phy_mem; |
237 | void __iomem *phy_base; | 237 | void __iomem *phy_base; |
diff --git a/drivers/usb/phy/phy-tegra-usb.c b/drivers/usb/phy/phy-tegra-usb.c index cec0855ed248..3bfb3d1957c1 100644 --- a/drivers/usb/phy/phy-tegra-usb.c +++ b/drivers/usb/phy/phy-tegra-usb.c | |||
@@ -28,20 +28,28 @@ | |||
28 | #include <linux/io.h> | 28 | #include <linux/io.h> |
29 | #include <linux/gpio.h> | 29 | #include <linux/gpio.h> |
30 | #include <linux/of.h> | 30 | #include <linux/of.h> |
31 | #include <linux/of_device.h> | ||
31 | #include <linux/of_gpio.h> | 32 | #include <linux/of_gpio.h> |
32 | #include <linux/usb/otg.h> | 33 | #include <linux/usb/otg.h> |
33 | #include <linux/usb/ulpi.h> | 34 | #include <linux/usb/ulpi.h> |
35 | #include <linux/usb/of.h> | ||
34 | #include <asm/mach-types.h> | 36 | #include <asm/mach-types.h> |
35 | #include <linux/usb/ehci_def.h> | 37 | #include <linux/usb/ehci_def.h> |
36 | #include <linux/usb/tegra_usb_phy.h> | 38 | #include <linux/usb/tegra_usb_phy.h> |
39 | #include <linux/regulator/consumer.h> | ||
37 | 40 | ||
38 | #define ULPI_VIEWPORT 0x170 | 41 | #define ULPI_VIEWPORT 0x170 |
39 | 42 | ||
40 | /* PORTSC registers */ | 43 | /* PORTSC PTS/PHCD bits, Tegra20 only */ |
41 | #define TEGRA_USB_PORTSC1 0x184 | 44 | #define TEGRA_USB_PORTSC1 0x184 |
42 | #define TEGRA_USB_PORTSC1_PTS(x) (((x) & 0x3) << 30) | 45 | #define TEGRA_USB_PORTSC1_PTS(x) (((x) & 0x3) << 30) |
43 | #define TEGRA_USB_PORTSC1_PHCD (1 << 23) | 46 | #define TEGRA_USB_PORTSC1_PHCD (1 << 23) |
44 | 47 | ||
48 | /* HOSTPC1 PTS/PHCD bits, Tegra30 and above */ | ||
49 | #define TEGRA_USB_HOSTPC1_DEVLC 0x1b4 | ||
50 | #define TEGRA_USB_HOSTPC1_DEVLC_PTS(x) (((x) & 0x7) << 29) | ||
51 | #define TEGRA_USB_HOSTPC1_DEVLC_PHCD (1 << 22) | ||
52 | |||
45 | /* Bits of PORTSC1, which will get cleared by writing 1 into them */ | 53 | /* Bits of PORTSC1, which will get cleared by writing 1 into them */ |
46 | #define TEGRA_PORTSC1_RWC_BITS (PORT_CSC | PORT_PEC | PORT_OCC) | 54 | #define TEGRA_PORTSC1_RWC_BITS (PORT_CSC | PORT_PEC | PORT_OCC) |
47 | 55 | ||
@@ -84,16 +92,22 @@ | |||
84 | 92 | ||
85 | #define UTMIP_XCVR_CFG0 0x808 | 93 | #define UTMIP_XCVR_CFG0 0x808 |
86 | #define UTMIP_XCVR_SETUP(x) (((x) & 0xf) << 0) | 94 | #define UTMIP_XCVR_SETUP(x) (((x) & 0xf) << 0) |
95 | #define UTMIP_XCVR_SETUP_MSB(x) ((((x) & 0x70) >> 4) << 22) | ||
87 | #define UTMIP_XCVR_LSRSLEW(x) (((x) & 0x3) << 8) | 96 | #define UTMIP_XCVR_LSRSLEW(x) (((x) & 0x3) << 8) |
88 | #define UTMIP_XCVR_LSFSLEW(x) (((x) & 0x3) << 10) | 97 | #define UTMIP_XCVR_LSFSLEW(x) (((x) & 0x3) << 10) |
89 | #define UTMIP_FORCE_PD_POWERDOWN (1 << 14) | 98 | #define UTMIP_FORCE_PD_POWERDOWN (1 << 14) |
90 | #define UTMIP_FORCE_PD2_POWERDOWN (1 << 16) | 99 | #define UTMIP_FORCE_PD2_POWERDOWN (1 << 16) |
91 | #define UTMIP_FORCE_PDZI_POWERDOWN (1 << 18) | 100 | #define UTMIP_FORCE_PDZI_POWERDOWN (1 << 18) |
92 | #define UTMIP_XCVR_HSSLEW_MSB(x) (((x) & 0x7f) << 25) | 101 | #define UTMIP_XCVR_LSBIAS_SEL (1 << 21) |
102 | #define UTMIP_XCVR_HSSLEW(x) (((x) & 0x3) << 4) | ||
103 | #define UTMIP_XCVR_HSSLEW_MSB(x) ((((x) & 0x1fc) >> 2) << 25) | ||
93 | 104 | ||
94 | #define UTMIP_BIAS_CFG0 0x80c | 105 | #define UTMIP_BIAS_CFG0 0x80c |
95 | #define UTMIP_OTGPD (1 << 11) | 106 | #define UTMIP_OTGPD (1 << 11) |
96 | #define UTMIP_BIASPD (1 << 10) | 107 | #define UTMIP_BIASPD (1 << 10) |
108 | #define UTMIP_HSSQUELCH_LEVEL(x) (((x) & 0x3) << 0) | ||
109 | #define UTMIP_HSDISCON_LEVEL(x) (((x) & 0x3) << 2) | ||
110 | #define UTMIP_HSDISCON_LEVEL_MSB(x) ((((x) & 0x4) >> 2) << 24) | ||
97 | 111 | ||
98 | #define UTMIP_HSRX_CFG0 0x810 | 112 | #define UTMIP_HSRX_CFG0 0x810 |
99 | #define UTMIP_ELASTIC_LIMIT(x) (((x) & 0x1f) << 10) | 113 | #define UTMIP_ELASTIC_LIMIT(x) (((x) & 0x1f) << 10) |
@@ -137,6 +151,12 @@ | |||
137 | #define UTMIP_BIAS_CFG1 0x83c | 151 | #define UTMIP_BIAS_CFG1 0x83c |
138 | #define UTMIP_BIAS_PDTRK_COUNT(x) (((x) & 0x1f) << 3) | 152 | #define UTMIP_BIAS_PDTRK_COUNT(x) (((x) & 0x1f) << 3) |
139 | 153 | ||
154 | /* For Tegra30 and above only, the address is different in Tegra20 */ | ||
155 | #define USB_USBMODE 0x1f8 | ||
156 | #define USB_USBMODE_MASK (3 << 0) | ||
157 | #define USB_USBMODE_HOST (3 << 0) | ||
158 | #define USB_USBMODE_DEVICE (2 << 0) | ||
159 | |||
140 | static DEFINE_SPINLOCK(utmip_pad_lock); | 160 | static DEFINE_SPINLOCK(utmip_pad_lock); |
141 | static int utmip_pad_count; | 161 | static int utmip_pad_count; |
142 | 162 | ||
@@ -184,36 +204,22 @@ static const struct tegra_xtal_freq tegra_freq_table[] = { | |||
184 | }, | 204 | }, |
185 | }; | 205 | }; |
186 | 206 | ||
187 | static struct tegra_utmip_config utmip_default[] = { | ||
188 | [0] = { | ||
189 | .hssync_start_delay = 9, | ||
190 | .idle_wait_delay = 17, | ||
191 | .elastic_limit = 16, | ||
192 | .term_range_adj = 6, | ||
193 | .xcvr_setup = 9, | ||
194 | .xcvr_lsfslew = 1, | ||
195 | .xcvr_lsrslew = 1, | ||
196 | }, | ||
197 | [2] = { | ||
198 | .hssync_start_delay = 9, | ||
199 | .idle_wait_delay = 17, | ||
200 | .elastic_limit = 16, | ||
201 | .term_range_adj = 6, | ||
202 | .xcvr_setup = 9, | ||
203 | .xcvr_lsfslew = 2, | ||
204 | .xcvr_lsrslew = 2, | ||
205 | }, | ||
206 | }; | ||
207 | |||
208 | static void set_pts(struct tegra_usb_phy *phy, u8 pts_val) | 207 | static void set_pts(struct tegra_usb_phy *phy, u8 pts_val) |
209 | { | 208 | { |
210 | void __iomem *base = phy->regs; | 209 | void __iomem *base = phy->regs; |
211 | unsigned long val; | 210 | unsigned long val; |
212 | 211 | ||
213 | val = readl(base + TEGRA_USB_PORTSC1) & ~TEGRA_PORTSC1_RWC_BITS; | 212 | if (phy->soc_config->has_hostpc) { |
214 | val &= ~TEGRA_USB_PORTSC1_PTS(3); | 213 | val = readl(base + TEGRA_USB_HOSTPC1_DEVLC); |
215 | val |= TEGRA_USB_PORTSC1_PTS(pts_val & 3); | 214 | val &= ~TEGRA_USB_HOSTPC1_DEVLC_PTS(~0); |
216 | writel(val, base + TEGRA_USB_PORTSC1); | 215 | val |= TEGRA_USB_HOSTPC1_DEVLC_PTS(pts_val); |
216 | writel(val, base + TEGRA_USB_HOSTPC1_DEVLC); | ||
217 | } else { | ||
218 | val = readl(base + TEGRA_USB_PORTSC1) & ~TEGRA_PORTSC1_RWC_BITS; | ||
219 | val &= ~TEGRA_USB_PORTSC1_PTS(~0); | ||
220 | val |= TEGRA_USB_PORTSC1_PTS(pts_val); | ||
221 | writel(val, base + TEGRA_USB_PORTSC1); | ||
222 | } | ||
217 | } | 223 | } |
218 | 224 | ||
219 | static void set_phcd(struct tegra_usb_phy *phy, bool enable) | 225 | static void set_phcd(struct tegra_usb_phy *phy, bool enable) |
@@ -221,17 +227,26 @@ static void set_phcd(struct tegra_usb_phy *phy, bool enable) | |||
221 | void __iomem *base = phy->regs; | 227 | void __iomem *base = phy->regs; |
222 | unsigned long val; | 228 | unsigned long val; |
223 | 229 | ||
224 | val = readl(base + TEGRA_USB_PORTSC1) & ~TEGRA_PORTSC1_RWC_BITS; | 230 | if (phy->soc_config->has_hostpc) { |
225 | if (enable) | 231 | val = readl(base + TEGRA_USB_HOSTPC1_DEVLC); |
226 | val |= TEGRA_USB_PORTSC1_PHCD; | 232 | if (enable) |
227 | else | 233 | val |= TEGRA_USB_HOSTPC1_DEVLC_PHCD; |
228 | val &= ~TEGRA_USB_PORTSC1_PHCD; | 234 | else |
229 | writel(val, base + TEGRA_USB_PORTSC1); | 235 | val &= ~TEGRA_USB_HOSTPC1_DEVLC_PHCD; |
236 | writel(val, base + TEGRA_USB_HOSTPC1_DEVLC); | ||
237 | } else { | ||
238 | val = readl(base + TEGRA_USB_PORTSC1) & ~PORT_RWC_BITS; | ||
239 | if (enable) | ||
240 | val |= TEGRA_USB_PORTSC1_PHCD; | ||
241 | else | ||
242 | val &= ~TEGRA_USB_PORTSC1_PHCD; | ||
243 | writel(val, base + TEGRA_USB_PORTSC1); | ||
244 | } | ||
230 | } | 245 | } |
231 | 246 | ||
232 | static int utmip_pad_open(struct tegra_usb_phy *phy) | 247 | static int utmip_pad_open(struct tegra_usb_phy *phy) |
233 | { | 248 | { |
234 | phy->pad_clk = devm_clk_get(phy->dev, "utmi-pads"); | 249 | phy->pad_clk = devm_clk_get(phy->u_phy.dev, "utmi-pads"); |
235 | if (IS_ERR(phy->pad_clk)) { | 250 | if (IS_ERR(phy->pad_clk)) { |
236 | pr_err("%s: can't get utmip pad clock\n", __func__); | 251 | pr_err("%s: can't get utmip pad clock\n", __func__); |
237 | return PTR_ERR(phy->pad_clk); | 252 | return PTR_ERR(phy->pad_clk); |
@@ -244,6 +259,7 @@ static void utmip_pad_power_on(struct tegra_usb_phy *phy) | |||
244 | { | 259 | { |
245 | unsigned long val, flags; | 260 | unsigned long val, flags; |
246 | void __iomem *base = phy->pad_regs; | 261 | void __iomem *base = phy->pad_regs; |
262 | struct tegra_utmip_config *config = phy->config; | ||
247 | 263 | ||
248 | clk_prepare_enable(phy->pad_clk); | 264 | clk_prepare_enable(phy->pad_clk); |
249 | 265 | ||
@@ -252,6 +268,16 @@ static void utmip_pad_power_on(struct tegra_usb_phy *phy) | |||
252 | if (utmip_pad_count++ == 0) { | 268 | if (utmip_pad_count++ == 0) { |
253 | val = readl(base + UTMIP_BIAS_CFG0); | 269 | val = readl(base + UTMIP_BIAS_CFG0); |
254 | val &= ~(UTMIP_OTGPD | UTMIP_BIASPD); | 270 | val &= ~(UTMIP_OTGPD | UTMIP_BIASPD); |
271 | |||
272 | if (phy->soc_config->requires_extra_tuning_parameters) { | ||
273 | val &= ~(UTMIP_HSSQUELCH_LEVEL(~0) | | ||
274 | UTMIP_HSDISCON_LEVEL(~0) | | ||
275 | UTMIP_HSDISCON_LEVEL_MSB(~0)); | ||
276 | |||
277 | val |= UTMIP_HSSQUELCH_LEVEL(config->hssquelch_level); | ||
278 | val |= UTMIP_HSDISCON_LEVEL(config->hsdiscon_level); | ||
279 | val |= UTMIP_HSDISCON_LEVEL_MSB(config->hsdiscon_level); | ||
280 | } | ||
255 | writel(val, base + UTMIP_BIAS_CFG0); | 281 | writel(val, base + UTMIP_BIAS_CFG0); |
256 | } | 282 | } |
257 | 283 | ||
@@ -361,7 +387,7 @@ static int utmi_phy_power_on(struct tegra_usb_phy *phy) | |||
361 | } | 387 | } |
362 | 388 | ||
363 | val = readl(base + UTMIP_TX_CFG0); | 389 | val = readl(base + UTMIP_TX_CFG0); |
364 | val &= ~UTMIP_FS_PREABMLE_J; | 390 | val |= UTMIP_FS_PREABMLE_J; |
365 | writel(val, base + UTMIP_TX_CFG0); | 391 | writel(val, base + UTMIP_TX_CFG0); |
366 | 392 | ||
367 | val = readl(base + UTMIP_HSRX_CFG0); | 393 | val = readl(base + UTMIP_HSRX_CFG0); |
@@ -384,34 +410,56 @@ static int utmi_phy_power_on(struct tegra_usb_phy *phy) | |||
384 | val &= ~UTMIP_SUSPEND_EXIT_ON_EDGE; | 410 | val &= ~UTMIP_SUSPEND_EXIT_ON_EDGE; |
385 | writel(val, base + UTMIP_MISC_CFG0); | 411 | writel(val, base + UTMIP_MISC_CFG0); |
386 | 412 | ||
387 | val = readl(base + UTMIP_MISC_CFG1); | 413 | if (!phy->soc_config->utmi_pll_config_in_car_module) { |
388 | val &= ~(UTMIP_PLL_ACTIVE_DLY_COUNT(~0) | UTMIP_PLLU_STABLE_COUNT(~0)); | 414 | val = readl(base + UTMIP_MISC_CFG1); |
389 | val |= UTMIP_PLL_ACTIVE_DLY_COUNT(phy->freq->active_delay) | | 415 | val &= ~(UTMIP_PLL_ACTIVE_DLY_COUNT(~0) | |
390 | UTMIP_PLLU_STABLE_COUNT(phy->freq->stable_count); | 416 | UTMIP_PLLU_STABLE_COUNT(~0)); |
391 | writel(val, base + UTMIP_MISC_CFG1); | 417 | val |= UTMIP_PLL_ACTIVE_DLY_COUNT(phy->freq->active_delay) | |
392 | 418 | UTMIP_PLLU_STABLE_COUNT(phy->freq->stable_count); | |
393 | val = readl(base + UTMIP_PLL_CFG1); | 419 | writel(val, base + UTMIP_MISC_CFG1); |
394 | val &= ~(UTMIP_XTAL_FREQ_COUNT(~0) | UTMIP_PLLU_ENABLE_DLY_COUNT(~0)); | 420 | |
395 | val |= UTMIP_XTAL_FREQ_COUNT(phy->freq->xtal_freq_count) | | 421 | val = readl(base + UTMIP_PLL_CFG1); |
396 | UTMIP_PLLU_ENABLE_DLY_COUNT(phy->freq->enable_delay); | 422 | val &= ~(UTMIP_XTAL_FREQ_COUNT(~0) | |
397 | writel(val, base + UTMIP_PLL_CFG1); | 423 | UTMIP_PLLU_ENABLE_DLY_COUNT(~0)); |
424 | val |= UTMIP_XTAL_FREQ_COUNT(phy->freq->xtal_freq_count) | | ||
425 | UTMIP_PLLU_ENABLE_DLY_COUNT(phy->freq->enable_delay); | ||
426 | writel(val, base + UTMIP_PLL_CFG1); | ||
427 | } | ||
398 | 428 | ||
399 | if (phy->mode == TEGRA_USB_PHY_MODE_DEVICE) { | 429 | if (phy->mode == USB_DR_MODE_PERIPHERAL) { |
400 | val = readl(base + USB_SUSP_CTRL); | 430 | val = readl(base + USB_SUSP_CTRL); |
401 | val &= ~(USB_WAKE_ON_CNNT_EN_DEV | USB_WAKE_ON_DISCON_EN_DEV); | 431 | val &= ~(USB_WAKE_ON_CNNT_EN_DEV | USB_WAKE_ON_DISCON_EN_DEV); |
402 | writel(val, base + USB_SUSP_CTRL); | 432 | writel(val, base + USB_SUSP_CTRL); |
433 | |||
434 | val = readl(base + UTMIP_BAT_CHRG_CFG0); | ||
435 | val &= ~UTMIP_PD_CHRG; | ||
436 | writel(val, base + UTMIP_BAT_CHRG_CFG0); | ||
437 | } else { | ||
438 | val = readl(base + UTMIP_BAT_CHRG_CFG0); | ||
439 | val |= UTMIP_PD_CHRG; | ||
440 | writel(val, base + UTMIP_BAT_CHRG_CFG0); | ||
403 | } | 441 | } |
404 | 442 | ||
405 | utmip_pad_power_on(phy); | 443 | utmip_pad_power_on(phy); |
406 | 444 | ||
407 | val = readl(base + UTMIP_XCVR_CFG0); | 445 | val = readl(base + UTMIP_XCVR_CFG0); |
408 | val &= ~(UTMIP_FORCE_PD_POWERDOWN | UTMIP_FORCE_PD2_POWERDOWN | | 446 | val &= ~(UTMIP_FORCE_PD_POWERDOWN | UTMIP_FORCE_PD2_POWERDOWN | |
409 | UTMIP_FORCE_PDZI_POWERDOWN | UTMIP_XCVR_SETUP(~0) | | 447 | UTMIP_FORCE_PDZI_POWERDOWN | UTMIP_XCVR_LSBIAS_SEL | |
410 | UTMIP_XCVR_LSFSLEW(~0) | UTMIP_XCVR_LSRSLEW(~0) | | 448 | UTMIP_XCVR_SETUP(~0) | UTMIP_XCVR_SETUP_MSB(~0) | |
411 | UTMIP_XCVR_HSSLEW_MSB(~0)); | 449 | UTMIP_XCVR_LSFSLEW(~0) | UTMIP_XCVR_LSRSLEW(~0)); |
412 | val |= UTMIP_XCVR_SETUP(config->xcvr_setup); | 450 | |
451 | if (!config->xcvr_setup_use_fuses) { | ||
452 | val |= UTMIP_XCVR_SETUP(config->xcvr_setup); | ||
453 | val |= UTMIP_XCVR_SETUP_MSB(config->xcvr_setup); | ||
454 | } | ||
413 | val |= UTMIP_XCVR_LSFSLEW(config->xcvr_lsfslew); | 455 | val |= UTMIP_XCVR_LSFSLEW(config->xcvr_lsfslew); |
414 | val |= UTMIP_XCVR_LSRSLEW(config->xcvr_lsrslew); | 456 | val |= UTMIP_XCVR_LSRSLEW(config->xcvr_lsrslew); |
457 | |||
458 | if (phy->soc_config->requires_extra_tuning_parameters) { | ||
459 | val &= ~(UTMIP_XCVR_HSSLEW(~0) | UTMIP_XCVR_HSSLEW_MSB(~0)); | ||
460 | val |= UTMIP_XCVR_HSSLEW(config->xcvr_hsslew); | ||
461 | val |= UTMIP_XCVR_HSSLEW_MSB(config->xcvr_hsslew); | ||
462 | } | ||
415 | writel(val, base + UTMIP_XCVR_CFG0); | 463 | writel(val, base + UTMIP_XCVR_CFG0); |
416 | 464 | ||
417 | val = readl(base + UTMIP_XCVR_CFG1); | 465 | val = readl(base + UTMIP_XCVR_CFG1); |
@@ -420,23 +468,19 @@ static int utmi_phy_power_on(struct tegra_usb_phy *phy) | |||
420 | val |= UTMIP_XCVR_TERM_RANGE_ADJ(config->term_range_adj); | 468 | val |= UTMIP_XCVR_TERM_RANGE_ADJ(config->term_range_adj); |
421 | writel(val, base + UTMIP_XCVR_CFG1); | 469 | writel(val, base + UTMIP_XCVR_CFG1); |
422 | 470 | ||
423 | val = readl(base + UTMIP_BAT_CHRG_CFG0); | ||
424 | val &= ~UTMIP_PD_CHRG; | ||
425 | writel(val, base + UTMIP_BAT_CHRG_CFG0); | ||
426 | |||
427 | val = readl(base + UTMIP_BIAS_CFG1); | 471 | val = readl(base + UTMIP_BIAS_CFG1); |
428 | val &= ~UTMIP_BIAS_PDTRK_COUNT(~0); | 472 | val &= ~UTMIP_BIAS_PDTRK_COUNT(~0); |
429 | val |= UTMIP_BIAS_PDTRK_COUNT(0x5); | 473 | val |= UTMIP_BIAS_PDTRK_COUNT(0x5); |
430 | writel(val, base + UTMIP_BIAS_CFG1); | 474 | writel(val, base + UTMIP_BIAS_CFG1); |
431 | 475 | ||
432 | if (phy->is_legacy_phy) { | 476 | val = readl(base + UTMIP_SPARE_CFG0); |
433 | val = readl(base + UTMIP_SPARE_CFG0); | 477 | if (config->xcvr_setup_use_fuses) |
434 | if (phy->mode == TEGRA_USB_PHY_MODE_DEVICE) | 478 | val |= FUSE_SETUP_SEL; |
435 | val &= ~FUSE_SETUP_SEL; | 479 | else |
436 | else | 480 | val &= ~FUSE_SETUP_SEL; |
437 | val |= FUSE_SETUP_SEL; | 481 | writel(val, base + UTMIP_SPARE_CFG0); |
438 | writel(val, base + UTMIP_SPARE_CFG0); | 482 | |
439 | } else { | 483 | if (!phy->is_legacy_phy) { |
440 | val = readl(base + USB_SUSP_CTRL); | 484 | val = readl(base + USB_SUSP_CTRL); |
441 | val |= UTMIP_PHY_ENABLE; | 485 | val |= UTMIP_PHY_ENABLE; |
442 | writel(val, base + USB_SUSP_CTRL); | 486 | writel(val, base + USB_SUSP_CTRL); |
@@ -459,6 +503,16 @@ static int utmi_phy_power_on(struct tegra_usb_phy *phy) | |||
459 | 503 | ||
460 | utmi_phy_clk_enable(phy); | 504 | utmi_phy_clk_enable(phy); |
461 | 505 | ||
506 | if (phy->soc_config->requires_usbmode_setup) { | ||
507 | val = readl(base + USB_USBMODE); | ||
508 | val &= ~USB_USBMODE_MASK; | ||
509 | if (phy->mode == USB_DR_MODE_HOST) | ||
510 | val |= USB_USBMODE_HOST; | ||
511 | else | ||
512 | val |= USB_USBMODE_DEVICE; | ||
513 | writel(val, base + USB_USBMODE); | ||
514 | } | ||
515 | |||
462 | if (!phy->is_legacy_phy) | 516 | if (!phy->is_legacy_phy) |
463 | set_pts(phy, 0); | 517 | set_pts(phy, 0); |
464 | 518 | ||
@@ -472,7 +526,7 @@ static int utmi_phy_power_off(struct tegra_usb_phy *phy) | |||
472 | 526 | ||
473 | utmi_phy_clk_disable(phy); | 527 | utmi_phy_clk_disable(phy); |
474 | 528 | ||
475 | if (phy->mode == TEGRA_USB_PHY_MODE_DEVICE) { | 529 | if (phy->mode == USB_DR_MODE_PERIPHERAL) { |
476 | val = readl(base + USB_SUSP_CTRL); | 530 | val = readl(base + USB_SUSP_CTRL); |
477 | val &= ~USB_WAKEUP_DEBOUNCE_COUNT(~0); | 531 | val &= ~USB_WAKEUP_DEBOUNCE_COUNT(~0); |
478 | val |= USB_WAKE_ON_CNNT_EN_DEV | USB_WAKEUP_DEBOUNCE_COUNT(5); | 532 | val |= USB_WAKE_ON_CNNT_EN_DEV | USB_WAKEUP_DEBOUNCE_COUNT(5); |
@@ -560,13 +614,15 @@ static int ulpi_phy_power_on(struct tegra_usb_phy *phy) | |||
560 | 614 | ||
561 | ret = gpio_direction_output(phy->reset_gpio, 0); | 615 | ret = gpio_direction_output(phy->reset_gpio, 0); |
562 | if (ret < 0) { | 616 | if (ret < 0) { |
563 | dev_err(phy->dev, "gpio %d not set to 0\n", phy->reset_gpio); | 617 | dev_err(phy->u_phy.dev, "gpio %d not set to 0\n", |
618 | phy->reset_gpio); | ||
564 | return ret; | 619 | return ret; |
565 | } | 620 | } |
566 | msleep(5); | 621 | msleep(5); |
567 | ret = gpio_direction_output(phy->reset_gpio, 1); | 622 | ret = gpio_direction_output(phy->reset_gpio, 1); |
568 | if (ret < 0) { | 623 | if (ret < 0) { |
569 | dev_err(phy->dev, "gpio %d not set to 1\n", phy->reset_gpio); | 624 | dev_err(phy->u_phy.dev, "gpio %d not set to 1\n", |
625 | phy->reset_gpio); | ||
570 | return ret; | 626 | return ret; |
571 | } | 627 | } |
572 | 628 | ||
@@ -634,6 +690,9 @@ static void tegra_usb_phy_close(struct usb_phy *x) | |||
634 | { | 690 | { |
635 | struct tegra_usb_phy *phy = container_of(x, struct tegra_usb_phy, u_phy); | 691 | struct tegra_usb_phy *phy = container_of(x, struct tegra_usb_phy, u_phy); |
636 | 692 | ||
693 | if (!IS_ERR(phy->vbus)) | ||
694 | regulator_disable(phy->vbus); | ||
695 | |||
637 | clk_disable_unprepare(phy->pll_u); | 696 | clk_disable_unprepare(phy->pll_u); |
638 | } | 697 | } |
639 | 698 | ||
@@ -666,29 +725,30 @@ static int ulpi_open(struct tegra_usb_phy *phy) | |||
666 | { | 725 | { |
667 | int err; | 726 | int err; |
668 | 727 | ||
669 | phy->clk = devm_clk_get(phy->dev, "ulpi-link"); | 728 | phy->clk = devm_clk_get(phy->u_phy.dev, "ulpi-link"); |
670 | if (IS_ERR(phy->clk)) { | 729 | if (IS_ERR(phy->clk)) { |
671 | pr_err("%s: can't get ulpi clock\n", __func__); | 730 | pr_err("%s: can't get ulpi clock\n", __func__); |
672 | return PTR_ERR(phy->clk); | 731 | return PTR_ERR(phy->clk); |
673 | } | 732 | } |
674 | 733 | ||
675 | err = devm_gpio_request(phy->dev, phy->reset_gpio, "ulpi_phy_reset_b"); | 734 | err = devm_gpio_request(phy->u_phy.dev, phy->reset_gpio, |
735 | "ulpi_phy_reset_b"); | ||
676 | if (err < 0) { | 736 | if (err < 0) { |
677 | dev_err(phy->dev, "request failed for gpio: %d\n", | 737 | dev_err(phy->u_phy.dev, "request failed for gpio: %d\n", |
678 | phy->reset_gpio); | 738 | phy->reset_gpio); |
679 | return err; | 739 | return err; |
680 | } | 740 | } |
681 | 741 | ||
682 | err = gpio_direction_output(phy->reset_gpio, 0); | 742 | err = gpio_direction_output(phy->reset_gpio, 0); |
683 | if (err < 0) { | 743 | if (err < 0) { |
684 | dev_err(phy->dev, "gpio %d direction not set to output\n", | 744 | dev_err(phy->u_phy.dev, "gpio %d direction not set to output\n", |
685 | phy->reset_gpio); | 745 | phy->reset_gpio); |
686 | return err; | 746 | return err; |
687 | } | 747 | } |
688 | 748 | ||
689 | phy->ulpi = otg_ulpi_create(&ulpi_viewport_access_ops, 0); | 749 | phy->ulpi = otg_ulpi_create(&ulpi_viewport_access_ops, 0); |
690 | if (!phy->ulpi) { | 750 | if (!phy->ulpi) { |
691 | dev_err(phy->dev, "otg_ulpi_create returned NULL\n"); | 751 | dev_err(phy->u_phy.dev, "otg_ulpi_create returned NULL\n"); |
692 | err = -ENOMEM; | 752 | err = -ENOMEM; |
693 | return err; | 753 | return err; |
694 | } | 754 | } |
@@ -703,14 +763,7 @@ static int tegra_usb_phy_init(struct tegra_usb_phy *phy) | |||
703 | int i; | 763 | int i; |
704 | int err; | 764 | int err; |
705 | 765 | ||
706 | if (!phy->is_ulpi_phy) { | 766 | phy->pll_u = devm_clk_get(phy->u_phy.dev, "pll_u"); |
707 | if (phy->is_legacy_phy) | ||
708 | phy->config = &utmip_default[0]; | ||
709 | else | ||
710 | phy->config = &utmip_default[2]; | ||
711 | } | ||
712 | |||
713 | phy->pll_u = devm_clk_get(phy->dev, "pll_u"); | ||
714 | if (IS_ERR(phy->pll_u)) { | 767 | if (IS_ERR(phy->pll_u)) { |
715 | pr_err("Can't get pll_u clock\n"); | 768 | pr_err("Can't get pll_u clock\n"); |
716 | return PTR_ERR(phy->pll_u); | 769 | return PTR_ERR(phy->pll_u); |
@@ -733,6 +786,16 @@ static int tegra_usb_phy_init(struct tegra_usb_phy *phy) | |||
733 | goto fail; | 786 | goto fail; |
734 | } | 787 | } |
735 | 788 | ||
789 | if (!IS_ERR(phy->vbus)) { | ||
790 | err = regulator_enable(phy->vbus); | ||
791 | if (err) { | ||
792 | dev_err(phy->u_phy.dev, | ||
793 | "failed to enable usb vbus regulator: %d\n", | ||
794 | err); | ||
795 | goto fail; | ||
796 | } | ||
797 | } | ||
798 | |||
736 | if (phy->is_ulpi_phy) | 799 | if (phy->is_ulpi_phy) |
737 | err = ulpi_open(phy); | 800 | err = ulpi_open(phy); |
738 | else | 801 | else |
@@ -784,11 +847,138 @@ void tegra_ehci_phy_restore_end(struct usb_phy *x) | |||
784 | } | 847 | } |
785 | EXPORT_SYMBOL_GPL(tegra_ehci_phy_restore_end); | 848 | EXPORT_SYMBOL_GPL(tegra_ehci_phy_restore_end); |
786 | 849 | ||
850 | static int read_utmi_param(struct platform_device *pdev, const char *param, | ||
851 | u8 *dest) | ||
852 | { | ||
853 | u32 value; | ||
854 | int err = of_property_read_u32(pdev->dev.of_node, param, &value); | ||
855 | *dest = (u8)value; | ||
856 | if (err < 0) | ||
857 | dev_err(&pdev->dev, "Failed to read USB UTMI parameter %s: %d\n", | ||
858 | param, err); | ||
859 | return err; | ||
860 | } | ||
861 | |||
862 | static int utmi_phy_probe(struct tegra_usb_phy *tegra_phy, | ||
863 | struct platform_device *pdev) | ||
864 | { | ||
865 | struct resource *res; | ||
866 | int err; | ||
867 | struct tegra_utmip_config *config; | ||
868 | |||
869 | tegra_phy->is_ulpi_phy = false; | ||
870 | |||
871 | res = platform_get_resource(pdev, IORESOURCE_MEM, 1); | ||
872 | if (!res) { | ||
873 | dev_err(&pdev->dev, "Failed to get UTMI Pad regs\n"); | ||
874 | return -ENXIO; | ||
875 | } | ||
876 | |||
877 | tegra_phy->pad_regs = devm_ioremap(&pdev->dev, res->start, | ||
878 | resource_size(res)); | ||
879 | if (!tegra_phy->regs) { | ||
880 | dev_err(&pdev->dev, "Failed to remap UTMI Pad regs\n"); | ||
881 | return -ENOMEM; | ||
882 | } | ||
883 | |||
884 | tegra_phy->config = devm_kzalloc(&pdev->dev, | ||
885 | sizeof(*tegra_phy->config), GFP_KERNEL); | ||
886 | if (!tegra_phy->config) { | ||
887 | dev_err(&pdev->dev, | ||
888 | "unable to allocate memory for USB UTMIP config\n"); | ||
889 | return -ENOMEM; | ||
890 | } | ||
891 | |||
892 | config = tegra_phy->config; | ||
893 | |||
894 | err = read_utmi_param(pdev, "nvidia,hssync-start-delay", | ||
895 | &config->hssync_start_delay); | ||
896 | if (err < 0) | ||
897 | return err; | ||
898 | |||
899 | err = read_utmi_param(pdev, "nvidia,elastic-limit", | ||
900 | &config->elastic_limit); | ||
901 | if (err < 0) | ||
902 | return err; | ||
903 | |||
904 | err = read_utmi_param(pdev, "nvidia,idle-wait-delay", | ||
905 | &config->idle_wait_delay); | ||
906 | if (err < 0) | ||
907 | return err; | ||
908 | |||
909 | err = read_utmi_param(pdev, "nvidia,term-range-adj", | ||
910 | &config->term_range_adj); | ||
911 | if (err < 0) | ||
912 | return err; | ||
913 | |||
914 | err = read_utmi_param(pdev, "nvidia,xcvr-lsfslew", | ||
915 | &config->xcvr_lsfslew); | ||
916 | if (err < 0) | ||
917 | return err; | ||
918 | |||
919 | err = read_utmi_param(pdev, "nvidia,xcvr-lsrslew", | ||
920 | &config->xcvr_lsrslew); | ||
921 | if (err < 0) | ||
922 | return err; | ||
923 | |||
924 | if (tegra_phy->soc_config->requires_extra_tuning_parameters) { | ||
925 | err = read_utmi_param(pdev, "nvidia,xcvr-hsslew", | ||
926 | &config->xcvr_hsslew); | ||
927 | if (err < 0) | ||
928 | return err; | ||
929 | |||
930 | err = read_utmi_param(pdev, "nvidia,hssquelch-level", | ||
931 | &config->hssquelch_level); | ||
932 | if (err < 0) | ||
933 | return err; | ||
934 | |||
935 | err = read_utmi_param(pdev, "nvidia,hsdiscon-level", | ||
936 | &config->hsdiscon_level); | ||
937 | if (err < 0) | ||
938 | return err; | ||
939 | } | ||
940 | |||
941 | config->xcvr_setup_use_fuses = of_property_read_bool( | ||
942 | pdev->dev.of_node, "nvidia,xcvr-setup-use-fuses"); | ||
943 | |||
944 | if (!config->xcvr_setup_use_fuses) { | ||
945 | err = read_utmi_param(pdev, "nvidia,xcvr-setup", | ||
946 | &config->xcvr_setup); | ||
947 | if (err < 0) | ||
948 | return err; | ||
949 | } | ||
950 | |||
951 | return 0; | ||
952 | } | ||
953 | |||
954 | static const struct tegra_phy_soc_config tegra20_soc_config = { | ||
955 | .utmi_pll_config_in_car_module = false, | ||
956 | .has_hostpc = false, | ||
957 | .requires_usbmode_setup = false, | ||
958 | .requires_extra_tuning_parameters = false, | ||
959 | }; | ||
960 | |||
961 | static const struct tegra_phy_soc_config tegra30_soc_config = { | ||
962 | .utmi_pll_config_in_car_module = true, | ||
963 | .has_hostpc = true, | ||
964 | .requires_usbmode_setup = true, | ||
965 | .requires_extra_tuning_parameters = true, | ||
966 | }; | ||
967 | |||
968 | static struct of_device_id tegra_usb_phy_id_table[] = { | ||
969 | { .compatible = "nvidia,tegra30-usb-phy", .data = &tegra30_soc_config }, | ||
970 | { .compatible = "nvidia,tegra20-usb-phy", .data = &tegra20_soc_config }, | ||
971 | { }, | ||
972 | }; | ||
973 | MODULE_DEVICE_TABLE(of, tegra_usb_phy_id_table); | ||
974 | |||
787 | static int tegra_usb_phy_probe(struct platform_device *pdev) | 975 | static int tegra_usb_phy_probe(struct platform_device *pdev) |
788 | { | 976 | { |
977 | const struct of_device_id *match; | ||
789 | struct resource *res; | 978 | struct resource *res; |
790 | struct tegra_usb_phy *tegra_phy = NULL; | 979 | struct tegra_usb_phy *tegra_phy = NULL; |
791 | struct device_node *np = pdev->dev.of_node; | 980 | struct device_node *np = pdev->dev.of_node; |
981 | enum usb_phy_interface phy_type; | ||
792 | int err; | 982 | int err; |
793 | 983 | ||
794 | tegra_phy = devm_kzalloc(&pdev->dev, sizeof(*tegra_phy), GFP_KERNEL); | 984 | tegra_phy = devm_kzalloc(&pdev->dev, sizeof(*tegra_phy), GFP_KERNEL); |
@@ -797,6 +987,13 @@ static int tegra_usb_phy_probe(struct platform_device *pdev) | |||
797 | return -ENOMEM; | 987 | return -ENOMEM; |
798 | } | 988 | } |
799 | 989 | ||
990 | match = of_match_device(tegra_usb_phy_id_table, &pdev->dev); | ||
991 | if (!match) { | ||
992 | dev_err(&pdev->dev, "Error: No device match found\n"); | ||
993 | return -ENODEV; | ||
994 | } | ||
995 | tegra_phy->soc_config = match->data; | ||
996 | |||
800 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 997 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
801 | if (!res) { | 998 | if (!res) { |
802 | dev_err(&pdev->dev, "Failed to get I/O memory\n"); | 999 | dev_err(&pdev->dev, "Failed to get I/O memory\n"); |
@@ -813,23 +1010,15 @@ static int tegra_usb_phy_probe(struct platform_device *pdev) | |||
813 | tegra_phy->is_legacy_phy = | 1010 | tegra_phy->is_legacy_phy = |
814 | of_property_read_bool(np, "nvidia,has-legacy-mode"); | 1011 | of_property_read_bool(np, "nvidia,has-legacy-mode"); |
815 | 1012 | ||
816 | err = of_property_match_string(np, "phy_type", "ulpi"); | 1013 | phy_type = of_usb_get_phy_mode(np); |
817 | if (err < 0) { | 1014 | switch (phy_type) { |
818 | tegra_phy->is_ulpi_phy = false; | 1015 | case USBPHY_INTERFACE_MODE_UTMI: |
819 | 1016 | err = utmi_phy_probe(tegra_phy, pdev); | |
820 | res = platform_get_resource(pdev, IORESOURCE_MEM, 1); | 1017 | if (err < 0) |
821 | if (!res) { | 1018 | return err; |
822 | dev_err(&pdev->dev, "Failed to get UTMI Pad regs\n"); | 1019 | break; |
823 | return -ENXIO; | ||
824 | } | ||
825 | 1020 | ||
826 | tegra_phy->pad_regs = devm_ioremap(&pdev->dev, res->start, | 1021 | case USBPHY_INTERFACE_MODE_ULPI: |
827 | resource_size(res)); | ||
828 | if (!tegra_phy->regs) { | ||
829 | dev_err(&pdev->dev, "Failed to remap UTMI Pad regs\n"); | ||
830 | return -ENOMEM; | ||
831 | } | ||
832 | } else { | ||
833 | tegra_phy->is_ulpi_phy = true; | 1022 | tegra_phy->is_ulpi_phy = true; |
834 | 1023 | ||
835 | tegra_phy->reset_gpio = | 1024 | tegra_phy->reset_gpio = |
@@ -839,19 +1028,35 @@ static int tegra_usb_phy_probe(struct platform_device *pdev) | |||
839 | tegra_phy->reset_gpio); | 1028 | tegra_phy->reset_gpio); |
840 | return tegra_phy->reset_gpio; | 1029 | return tegra_phy->reset_gpio; |
841 | } | 1030 | } |
1031 | tegra_phy->config = NULL; | ||
1032 | break; | ||
1033 | |||
1034 | default: | ||
1035 | dev_err(&pdev->dev, "phy_type is invalid or unsupported\n"); | ||
1036 | return -EINVAL; | ||
842 | } | 1037 | } |
843 | 1038 | ||
844 | err = of_property_match_string(np, "dr_mode", "otg"); | 1039 | if (of_find_property(np, "dr_mode", NULL)) |
845 | if (err < 0) { | 1040 | tegra_phy->mode = of_usb_get_dr_mode(np); |
846 | err = of_property_match_string(np, "dr_mode", "peripheral"); | 1041 | else |
847 | if (err < 0) | 1042 | tegra_phy->mode = USB_DR_MODE_HOST; |
848 | tegra_phy->mode = TEGRA_USB_PHY_MODE_HOST; | ||
849 | else | ||
850 | tegra_phy->mode = TEGRA_USB_PHY_MODE_DEVICE; | ||
851 | } else | ||
852 | tegra_phy->mode = TEGRA_USB_PHY_MODE_OTG; | ||
853 | 1043 | ||
854 | tegra_phy->dev = &pdev->dev; | 1044 | if (tegra_phy->mode == USB_DR_MODE_UNKNOWN) { |
1045 | dev_err(&pdev->dev, "dr_mode is invalid\n"); | ||
1046 | return -EINVAL; | ||
1047 | } | ||
1048 | |||
1049 | /* On some boards, the VBUS regulator doesn't need to be controlled */ | ||
1050 | if (of_find_property(np, "vbus-supply", NULL)) { | ||
1051 | tegra_phy->vbus = devm_regulator_get(&pdev->dev, "vbus"); | ||
1052 | if (IS_ERR(tegra_phy->vbus)) | ||
1053 | return PTR_ERR(tegra_phy->vbus); | ||
1054 | } else { | ||
1055 | dev_notice(&pdev->dev, "no vbus regulator"); | ||
1056 | tegra_phy->vbus = ERR_PTR(-ENODEV); | ||
1057 | } | ||
1058 | |||
1059 | tegra_phy->u_phy.dev = &pdev->dev; | ||
855 | err = tegra_usb_phy_init(tegra_phy); | 1060 | err = tegra_usb_phy_init(tegra_phy); |
856 | if (err < 0) | 1061 | if (err < 0) |
857 | return err; | 1062 | return err; |
@@ -860,17 +1065,28 @@ static int tegra_usb_phy_probe(struct platform_device *pdev) | |||
860 | tegra_phy->u_phy.set_suspend = tegra_usb_phy_suspend; | 1065 | tegra_phy->u_phy.set_suspend = tegra_usb_phy_suspend; |
861 | 1066 | ||
862 | dev_set_drvdata(&pdev->dev, tegra_phy); | 1067 | dev_set_drvdata(&pdev->dev, tegra_phy); |
1068 | |||
1069 | err = usb_add_phy_dev(&tegra_phy->u_phy); | ||
1070 | if (err < 0) { | ||
1071 | tegra_usb_phy_close(&tegra_phy->u_phy); | ||
1072 | return err; | ||
1073 | } | ||
1074 | |||
863 | return 0; | 1075 | return 0; |
864 | } | 1076 | } |
865 | 1077 | ||
866 | static struct of_device_id tegra_usb_phy_id_table[] = { | 1078 | static int tegra_usb_phy_remove(struct platform_device *pdev) |
867 | { .compatible = "nvidia,tegra20-usb-phy", }, | 1079 | { |
868 | { }, | 1080 | struct tegra_usb_phy *tegra_phy = platform_get_drvdata(pdev); |
869 | }; | 1081 | |
870 | MODULE_DEVICE_TABLE(of, tegra_usb_phy_id_table); | 1082 | usb_remove_phy(&tegra_phy->u_phy); |
1083 | |||
1084 | return 0; | ||
1085 | } | ||
871 | 1086 | ||
872 | static struct platform_driver tegra_usb_phy_driver = { | 1087 | static struct platform_driver tegra_usb_phy_driver = { |
873 | .probe = tegra_usb_phy_probe, | 1088 | .probe = tegra_usb_phy_probe, |
1089 | .remove = tegra_usb_phy_remove, | ||
874 | .driver = { | 1090 | .driver = { |
875 | .name = "tegra-phy", | 1091 | .name = "tegra-phy", |
876 | .owner = THIS_MODULE, | 1092 | .owner = THIS_MODULE, |
@@ -879,29 +1095,5 @@ static struct platform_driver tegra_usb_phy_driver = { | |||
879 | }; | 1095 | }; |
880 | module_platform_driver(tegra_usb_phy_driver); | 1096 | module_platform_driver(tegra_usb_phy_driver); |
881 | 1097 | ||
882 | static int tegra_usb_phy_match(struct device *dev, void *data) | ||
883 | { | ||
884 | struct tegra_usb_phy *tegra_phy = dev_get_drvdata(dev); | ||
885 | struct device_node *dn = data; | ||
886 | |||
887 | return (tegra_phy->dev->of_node == dn) ? 1 : 0; | ||
888 | } | ||
889 | |||
890 | struct usb_phy *tegra_usb_get_phy(struct device_node *dn) | ||
891 | { | ||
892 | struct device *dev; | ||
893 | struct tegra_usb_phy *tegra_phy; | ||
894 | |||
895 | dev = driver_find_device(&tegra_usb_phy_driver.driver, NULL, dn, | ||
896 | tegra_usb_phy_match); | ||
897 | if (!dev) | ||
898 | return ERR_PTR(-EPROBE_DEFER); | ||
899 | |||
900 | tegra_phy = dev_get_drvdata(dev); | ||
901 | |||
902 | return &tegra_phy->u_phy; | ||
903 | } | ||
904 | EXPORT_SYMBOL_GPL(tegra_usb_get_phy); | ||
905 | |||
906 | MODULE_DESCRIPTION("Tegra USB PHY driver"); | 1098 | MODULE_DESCRIPTION("Tegra USB PHY driver"); |
907 | MODULE_LICENSE("GPL v2"); | 1099 | MODULE_LICENSE("GPL v2"); |
diff --git a/drivers/usb/phy/phy-twl4030-usb.c b/drivers/usb/phy/phy-twl4030-usb.c index 8f78d2d40722..90730c8762b8 100644 --- a/drivers/usb/phy/phy-twl4030-usb.c +++ b/drivers/usb/phy/phy-twl4030-usb.c | |||
@@ -648,7 +648,7 @@ static int twl4030_set_host(struct usb_otg *otg, struct usb_bus *host) | |||
648 | 648 | ||
649 | static int twl4030_usb_probe(struct platform_device *pdev) | 649 | static int twl4030_usb_probe(struct platform_device *pdev) |
650 | { | 650 | { |
651 | struct twl4030_usb_data *pdata = pdev->dev.platform_data; | 651 | struct twl4030_usb_data *pdata = dev_get_platdata(&pdev->dev); |
652 | struct twl4030_usb *twl; | 652 | struct twl4030_usb *twl; |
653 | int status, err; | 653 | int status, err; |
654 | struct usb_otg *otg; | 654 | struct usb_otg *otg; |
diff --git a/drivers/usb/phy/phy-twl6030-usb.c b/drivers/usb/phy/phy-twl6030-usb.c index 1753bd367e0a..16dbc9382678 100644 --- a/drivers/usb/phy/phy-twl6030-usb.c +++ b/drivers/usb/phy/phy-twl6030-usb.c | |||
@@ -324,7 +324,7 @@ static int twl6030_usb_probe(struct platform_device *pdev) | |||
324 | int status, err; | 324 | int status, err; |
325 | struct device_node *np = pdev->dev.of_node; | 325 | struct device_node *np = pdev->dev.of_node; |
326 | struct device *dev = &pdev->dev; | 326 | struct device *dev = &pdev->dev; |
327 | struct twl4030_usb_data *pdata = dev->platform_data; | 327 | struct twl4030_usb_data *pdata = dev_get_platdata(dev); |
328 | 328 | ||
329 | twl = devm_kzalloc(dev, sizeof *twl, GFP_KERNEL); | 329 | twl = devm_kzalloc(dev, sizeof *twl, GFP_KERNEL); |
330 | if (!twl) | 330 | if (!twl) |
diff --git a/drivers/usb/renesas_usbhs/mod_gadget.c b/drivers/usb/renesas_usbhs/mod_gadget.c index 805940c37353..3385aeb5a364 100644 --- a/drivers/usb/renesas_usbhs/mod_gadget.c +++ b/drivers/usb/renesas_usbhs/mod_gadget.c | |||
@@ -77,9 +77,9 @@ struct usbhsg_recip_handle { | |||
77 | struct usbhsg_gpriv, mod) | 77 | struct usbhsg_gpriv, mod) |
78 | 78 | ||
79 | #define __usbhsg_for_each_uep(start, pos, g, i) \ | 79 | #define __usbhsg_for_each_uep(start, pos, g, i) \ |
80 | for (i = start, pos = (g)->uep + i; \ | 80 | for ((i) = start; \ |
81 | i < (g)->uep_size; \ | 81 | ((i) < (g)->uep_size) && ((pos) = (g)->uep + (i)); \ |
82 | i++, pos = (g)->uep + i) | 82 | (i)++) |
83 | 83 | ||
84 | #define usbhsg_for_each_uep(pos, gpriv, i) \ | 84 | #define usbhsg_for_each_uep(pos, gpriv, i) \ |
85 | __usbhsg_for_each_uep(1, pos, gpriv, i) | 85 | __usbhsg_for_each_uep(1, pos, gpriv, i) |
diff --git a/drivers/usb/renesas_usbhs/mod_host.c b/drivers/usb/renesas_usbhs/mod_host.c index b86815421c8d..e40f565004d0 100644 --- a/drivers/usb/renesas_usbhs/mod_host.c +++ b/drivers/usb/renesas_usbhs/mod_host.c | |||
@@ -111,9 +111,9 @@ static const char usbhsh_hcd_name[] = "renesas_usbhs host"; | |||
111 | container_of(usbhs_mod_get(priv, USBHS_HOST), struct usbhsh_hpriv, mod) | 111 | container_of(usbhs_mod_get(priv, USBHS_HOST), struct usbhsh_hpriv, mod) |
112 | 112 | ||
113 | #define __usbhsh_for_each_udev(start, pos, h, i) \ | 113 | #define __usbhsh_for_each_udev(start, pos, h, i) \ |
114 | for (i = start, pos = (h)->udev + i; \ | 114 | for ((i) = start; \ |
115 | i < USBHSH_DEVICE_MAX; \ | 115 | ((i) < USBHSH_DEVICE_MAX) && ((pos) = (h)->udev + (i)); \ |
116 | i++, pos = (h)->udev + i) | 116 | (i)++) |
117 | 117 | ||
118 | #define usbhsh_for_each_udev(pos, hpriv, i) \ | 118 | #define usbhsh_for_each_udev(pos, hpriv, i) \ |
119 | __usbhsh_for_each_udev(1, pos, hpriv, i) | 119 | __usbhsh_for_each_udev(1, pos, hpriv, i) |
diff --git a/drivers/usb/renesas_usbhs/pipe.h b/drivers/usb/renesas_usbhs/pipe.h index b476fde955bf..3e5349879838 100644 --- a/drivers/usb/renesas_usbhs/pipe.h +++ b/drivers/usb/renesas_usbhs/pipe.h | |||
@@ -54,9 +54,9 @@ struct usbhs_pipe_info { | |||
54 | * pipe list | 54 | * pipe list |
55 | */ | 55 | */ |
56 | #define __usbhs_for_each_pipe(start, pos, info, i) \ | 56 | #define __usbhs_for_each_pipe(start, pos, info, i) \ |
57 | for (i = start, pos = (info)->pipe + i; \ | 57 | for ((i) = start; \ |
58 | i < (info)->size; \ | 58 | ((i) < (info)->size) && ((pos) = (info)->pipe + (i)); \ |
59 | i++, pos = (info)->pipe + i) | 59 | (i)++) |
60 | 60 | ||
61 | #define usbhs_for_each_pipe(pos, priv, i) \ | 61 | #define usbhs_for_each_pipe(pos, priv, i) \ |
62 | __usbhs_for_each_pipe(1, pos, &((priv)->pipe_info), i) | 62 | __usbhs_for_each_pipe(1, pos, &((priv)->pipe_info), i) |
diff --git a/drivers/usb/usb-common.c b/drivers/usb/usb-common.c index 675384dabfe9..d771870a819e 100644 --- a/drivers/usb/usb-common.c +++ b/drivers/usb/usb-common.c | |||
@@ -43,20 +43,20 @@ const char *usb_otg_state_string(enum usb_otg_state state) | |||
43 | } | 43 | } |
44 | EXPORT_SYMBOL_GPL(usb_otg_state_string); | 44 | EXPORT_SYMBOL_GPL(usb_otg_state_string); |
45 | 45 | ||
46 | static const char *const speed_names[] = { | ||
47 | [USB_SPEED_UNKNOWN] = "UNKNOWN", | ||
48 | [USB_SPEED_LOW] = "low-speed", | ||
49 | [USB_SPEED_FULL] = "full-speed", | ||
50 | [USB_SPEED_HIGH] = "high-speed", | ||
51 | [USB_SPEED_WIRELESS] = "wireless", | ||
52 | [USB_SPEED_SUPER] = "super-speed", | ||
53 | }; | ||
54 | |||
46 | const char *usb_speed_string(enum usb_device_speed speed) | 55 | const char *usb_speed_string(enum usb_device_speed speed) |
47 | { | 56 | { |
48 | static const char *const names[] = { | 57 | if (speed < 0 || speed >= ARRAY_SIZE(speed_names)) |
49 | [USB_SPEED_UNKNOWN] = "UNKNOWN", | ||
50 | [USB_SPEED_LOW] = "low-speed", | ||
51 | [USB_SPEED_FULL] = "full-speed", | ||
52 | [USB_SPEED_HIGH] = "high-speed", | ||
53 | [USB_SPEED_WIRELESS] = "wireless", | ||
54 | [USB_SPEED_SUPER] = "super-speed", | ||
55 | }; | ||
56 | |||
57 | if (speed < 0 || speed >= ARRAY_SIZE(names)) | ||
58 | speed = USB_SPEED_UNKNOWN; | 58 | speed = USB_SPEED_UNKNOWN; |
59 | return names[speed]; | 59 | return speed_names[speed]; |
60 | } | 60 | } |
61 | EXPORT_SYMBOL_GPL(usb_speed_string); | 61 | EXPORT_SYMBOL_GPL(usb_speed_string); |
62 | 62 | ||
@@ -112,6 +112,33 @@ enum usb_dr_mode of_usb_get_dr_mode(struct device_node *np) | |||
112 | return USB_DR_MODE_UNKNOWN; | 112 | return USB_DR_MODE_UNKNOWN; |
113 | } | 113 | } |
114 | EXPORT_SYMBOL_GPL(of_usb_get_dr_mode); | 114 | EXPORT_SYMBOL_GPL(of_usb_get_dr_mode); |
115 | |||
116 | /** | ||
117 | * of_usb_get_maximum_speed - Get maximum requested speed for a given USB | ||
118 | * controller. | ||
119 | * @np: Pointer to the given device_node | ||
120 | * | ||
121 | * The function gets the maximum speed string from property "maximum-speed", | ||
122 | * and returns the corresponding enum usb_device_speed. | ||
123 | */ | ||
124 | enum usb_device_speed of_usb_get_maximum_speed(struct device_node *np) | ||
125 | { | ||
126 | const char *maximum_speed; | ||
127 | int err; | ||
128 | int i; | ||
129 | |||
130 | err = of_property_read_string(np, "maximum-speed", &maximum_speed); | ||
131 | if (err < 0) | ||
132 | return USB_SPEED_UNKNOWN; | ||
133 | |||
134 | for (i = 0; i < ARRAY_SIZE(speed_names); i++) | ||
135 | if (strcmp(maximum_speed, speed_names[i]) == 0) | ||
136 | return i; | ||
137 | |||
138 | return USB_SPEED_UNKNOWN; | ||
139 | } | ||
140 | EXPORT_SYMBOL_GPL(of_usb_get_maximum_speed); | ||
141 | |||
115 | #endif | 142 | #endif |
116 | 143 | ||
117 | MODULE_LICENSE("GPL"); | 144 | MODULE_LICENSE("GPL"); |
diff --git a/include/linux/platform_data/tegra_usb.h b/include/linux/platform_data/tegra_usb.h deleted file mode 100644 index 66c673fef408..000000000000 --- a/include/linux/platform_data/tegra_usb.h +++ /dev/null | |||
@@ -1,32 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2010 Google, Inc. | ||
3 | * | ||
4 | * This software is licensed under the terms of the GNU General Public | ||
5 | * License version 2, as published by the Free Software Foundation, and | ||
6 | * may be copied, distributed, and modified under those terms. | ||
7 | * | ||
8 | * This program is distributed in the hope that it will be useful, | ||
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
11 | * GNU General Public License for more details. | ||
12 | * | ||
13 | */ | ||
14 | |||
15 | #ifndef _TEGRA_USB_H_ | ||
16 | #define _TEGRA_USB_H_ | ||
17 | |||
18 | enum tegra_usb_operating_modes { | ||
19 | TEGRA_USB_DEVICE, | ||
20 | TEGRA_USB_HOST, | ||
21 | TEGRA_USB_OTG, | ||
22 | }; | ||
23 | |||
24 | struct tegra_ehci_platform_data { | ||
25 | enum tegra_usb_operating_modes operating_mode; | ||
26 | /* power down the phy on bus suspend */ | ||
27 | int power_down_on_bus_suspend; | ||
28 | void *phy_config; | ||
29 | int vbus_gpio; | ||
30 | }; | ||
31 | |||
32 | #endif /* _TEGRA_USB_H_ */ | ||
diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h index f1b0dca60f12..942ef5e053bf 100644 --- a/include/linux/usb/gadget.h +++ b/include/linux/usb/gadget.h | |||
@@ -22,6 +22,7 @@ | |||
22 | #include <linux/slab.h> | 22 | #include <linux/slab.h> |
23 | #include <linux/scatterlist.h> | 23 | #include <linux/scatterlist.h> |
24 | #include <linux/types.h> | 24 | #include <linux/types.h> |
25 | #include <linux/workqueue.h> | ||
25 | #include <linux/usb/ch9.h> | 26 | #include <linux/usb/ch9.h> |
26 | 27 | ||
27 | struct usb_ep; | 28 | struct usb_ep; |
@@ -475,6 +476,7 @@ struct usb_gadget_ops { | |||
475 | 476 | ||
476 | /** | 477 | /** |
477 | * struct usb_gadget - represents a usb slave device | 478 | * struct usb_gadget - represents a usb slave device |
479 | * @work: (internal use) Workqueue to be used for sysfs_notify() | ||
478 | * @ops: Function pointers used to access hardware-specific operations. | 480 | * @ops: Function pointers used to access hardware-specific operations. |
479 | * @ep0: Endpoint zero, used when reading or writing responses to | 481 | * @ep0: Endpoint zero, used when reading or writing responses to |
480 | * driver setup() requests | 482 | * driver setup() requests |
@@ -520,6 +522,7 @@ struct usb_gadget_ops { | |||
520 | * device is acting as a B-Peripheral (so is_a_peripheral is false). | 522 | * device is acting as a B-Peripheral (so is_a_peripheral is false). |
521 | */ | 523 | */ |
522 | struct usb_gadget { | 524 | struct usb_gadget { |
525 | struct work_struct work; | ||
523 | /* readonly to gadget driver */ | 526 | /* readonly to gadget driver */ |
524 | const struct usb_gadget_ops *ops; | 527 | const struct usb_gadget_ops *ops; |
525 | struct usb_ep *ep0; | 528 | struct usb_ep *ep0; |
@@ -538,6 +541,7 @@ struct usb_gadget { | |||
538 | unsigned out_epnum; | 541 | unsigned out_epnum; |
539 | unsigned in_epnum; | 542 | unsigned in_epnum; |
540 | }; | 543 | }; |
544 | #define work_to_gadget(w) (container_of((w), struct usb_gadget, work)) | ||
541 | 545 | ||
542 | static inline void set_gadget_data(struct usb_gadget *gadget, void *data) | 546 | static inline void set_gadget_data(struct usb_gadget *gadget, void *data) |
543 | { dev_set_drvdata(&gadget->dev, data); } | 547 | { dev_set_drvdata(&gadget->dev, data); } |
diff --git a/include/linux/usb/of.h b/include/linux/usb/of.h index a0ef405368b8..8c38aa26b3bb 100644 --- a/include/linux/usb/of.h +++ b/include/linux/usb/of.h | |||
@@ -7,19 +7,27 @@ | |||
7 | #ifndef __LINUX_USB_OF_H | 7 | #ifndef __LINUX_USB_OF_H |
8 | #define __LINUX_USB_OF_H | 8 | #define __LINUX_USB_OF_H |
9 | 9 | ||
10 | #include <linux/usb/ch9.h> | ||
10 | #include <linux/usb/otg.h> | 11 | #include <linux/usb/otg.h> |
11 | #include <linux/usb/phy.h> | 12 | #include <linux/usb/phy.h> |
12 | 13 | ||
13 | #if IS_ENABLED(CONFIG_OF) | 14 | #if IS_ENABLED(CONFIG_OF) |
14 | enum usb_dr_mode of_usb_get_dr_mode(struct device_node *np); | 15 | enum usb_dr_mode of_usb_get_dr_mode(struct device_node *np); |
16 | enum usb_device_speed of_usb_get_maximum_speed(struct device_node *np); | ||
15 | #else | 17 | #else |
16 | static inline enum usb_dr_mode of_usb_get_dr_mode(struct device_node *np) | 18 | static inline enum usb_dr_mode of_usb_get_dr_mode(struct device_node *np) |
17 | { | 19 | { |
18 | return USB_DR_MODE_UNKNOWN; | 20 | return USB_DR_MODE_UNKNOWN; |
19 | } | 21 | } |
22 | |||
23 | static inline enum usb_device_speed | ||
24 | of_usb_get_maximum_speed(struct device_node *np) | ||
25 | { | ||
26 | return USB_SPEED_UNKNOWN; | ||
27 | } | ||
20 | #endif | 28 | #endif |
21 | 29 | ||
22 | #if IS_ENABLED(CONFIG_OF) && IS_ENABLED(CONFIG_USB_PHY) | 30 | #if IS_ENABLED(CONFIG_OF) && IS_ENABLED(CONFIG_USB_SUPPORT) |
23 | enum usb_phy_interface of_usb_get_phy_mode(struct device_node *np); | 31 | enum usb_phy_interface of_usb_get_phy_mode(struct device_node *np); |
24 | #else | 32 | #else |
25 | static inline enum usb_phy_interface of_usb_get_phy_mode(struct device_node *np) | 33 | static inline enum usb_phy_interface of_usb_get_phy_mode(struct device_node *np) |
diff --git a/include/linux/usb/phy.h b/include/linux/usb/phy.h index 44036808bf0f..6c0b1c513db7 100644 --- a/include/linux/usb/phy.h +++ b/include/linux/usb/phy.h | |||
@@ -142,7 +142,7 @@ extern void usb_remove_phy(struct usb_phy *); | |||
142 | /* helpers for direct access thru low-level io interface */ | 142 | /* helpers for direct access thru low-level io interface */ |
143 | static inline int usb_phy_io_read(struct usb_phy *x, u32 reg) | 143 | static inline int usb_phy_io_read(struct usb_phy *x, u32 reg) |
144 | { | 144 | { |
145 | if (x->io_ops && x->io_ops->read) | 145 | if (x && x->io_ops && x->io_ops->read) |
146 | return x->io_ops->read(x, reg); | 146 | return x->io_ops->read(x, reg); |
147 | 147 | ||
148 | return -EINVAL; | 148 | return -EINVAL; |
@@ -150,7 +150,7 @@ static inline int usb_phy_io_read(struct usb_phy *x, u32 reg) | |||
150 | 150 | ||
151 | static inline int usb_phy_io_write(struct usb_phy *x, u32 val, u32 reg) | 151 | static inline int usb_phy_io_write(struct usb_phy *x, u32 val, u32 reg) |
152 | { | 152 | { |
153 | if (x->io_ops && x->io_ops->write) | 153 | if (x && x->io_ops && x->io_ops->write) |
154 | return x->io_ops->write(x, val, reg); | 154 | return x->io_ops->write(x, val, reg); |
155 | 155 | ||
156 | return -EINVAL; | 156 | return -EINVAL; |
@@ -159,7 +159,7 @@ static inline int usb_phy_io_write(struct usb_phy *x, u32 val, u32 reg) | |||
159 | static inline int | 159 | static inline int |
160 | usb_phy_init(struct usb_phy *x) | 160 | usb_phy_init(struct usb_phy *x) |
161 | { | 161 | { |
162 | if (x->init) | 162 | if (x && x->init) |
163 | return x->init(x); | 163 | return x->init(x); |
164 | 164 | ||
165 | return 0; | 165 | return 0; |
@@ -168,14 +168,14 @@ usb_phy_init(struct usb_phy *x) | |||
168 | static inline void | 168 | static inline void |
169 | usb_phy_shutdown(struct usb_phy *x) | 169 | usb_phy_shutdown(struct usb_phy *x) |
170 | { | 170 | { |
171 | if (x->shutdown) | 171 | if (x && x->shutdown) |
172 | x->shutdown(x); | 172 | x->shutdown(x); |
173 | } | 173 | } |
174 | 174 | ||
175 | static inline int | 175 | static inline int |
176 | usb_phy_vbus_on(struct usb_phy *x) | 176 | usb_phy_vbus_on(struct usb_phy *x) |
177 | { | 177 | { |
178 | if (!x->set_vbus) | 178 | if (!x || !x->set_vbus) |
179 | return 0; | 179 | return 0; |
180 | 180 | ||
181 | return x->set_vbus(x, true); | 181 | return x->set_vbus(x, true); |
@@ -184,7 +184,7 @@ usb_phy_vbus_on(struct usb_phy *x) | |||
184 | static inline int | 184 | static inline int |
185 | usb_phy_vbus_off(struct usb_phy *x) | 185 | usb_phy_vbus_off(struct usb_phy *x) |
186 | { | 186 | { |
187 | if (!x->set_vbus) | 187 | if (!x || !x->set_vbus) |
188 | return 0; | 188 | return 0; |
189 | 189 | ||
190 | return x->set_vbus(x, false); | 190 | return x->set_vbus(x, false); |
@@ -258,7 +258,7 @@ usb_phy_set_power(struct usb_phy *x, unsigned mA) | |||
258 | static inline int | 258 | static inline int |
259 | usb_phy_set_suspend(struct usb_phy *x, int suspend) | 259 | usb_phy_set_suspend(struct usb_phy *x, int suspend) |
260 | { | 260 | { |
261 | if (x->set_suspend != NULL) | 261 | if (x && x->set_suspend != NULL) |
262 | return x->set_suspend(x, suspend); | 262 | return x->set_suspend(x, suspend); |
263 | else | 263 | else |
264 | return 0; | 264 | return 0; |
@@ -267,7 +267,7 @@ usb_phy_set_suspend(struct usb_phy *x, int suspend) | |||
267 | static inline int | 267 | static inline int |
268 | usb_phy_notify_connect(struct usb_phy *x, enum usb_device_speed speed) | 268 | usb_phy_notify_connect(struct usb_phy *x, enum usb_device_speed speed) |
269 | { | 269 | { |
270 | if (x->notify_connect) | 270 | if (x && x->notify_connect) |
271 | return x->notify_connect(x, speed); | 271 | return x->notify_connect(x, speed); |
272 | else | 272 | else |
273 | return 0; | 273 | return 0; |
@@ -276,7 +276,7 @@ usb_phy_notify_connect(struct usb_phy *x, enum usb_device_speed speed) | |||
276 | static inline int | 276 | static inline int |
277 | usb_phy_notify_disconnect(struct usb_phy *x, enum usb_device_speed speed) | 277 | usb_phy_notify_disconnect(struct usb_phy *x, enum usb_device_speed speed) |
278 | { | 278 | { |
279 | if (x->notify_disconnect) | 279 | if (x && x->notify_disconnect) |
280 | return x->notify_disconnect(x, speed); | 280 | return x->notify_disconnect(x, speed); |
281 | else | 281 | else |
282 | return 0; | 282 | return 0; |
diff --git a/include/linux/usb/tegra_usb_phy.h b/include/linux/usb/tegra_usb_phy.h index d2ca919a5b73..1de16c324ec8 100644 --- a/include/linux/usb/tegra_usb_phy.h +++ b/include/linux/usb/tegra_usb_phy.h | |||
@@ -18,19 +18,36 @@ | |||
18 | #include <linux/clk.h> | 18 | #include <linux/clk.h> |
19 | #include <linux/usb/otg.h> | 19 | #include <linux/usb/otg.h> |
20 | 20 | ||
21 | /* | ||
22 | * utmi_pll_config_in_car_module: true if the UTMI PLL configuration registers | ||
23 | * should be set up by clk-tegra, false if by the PHY code | ||
24 | * has_hostpc: true if the USB controller has the HOSTPC extension, which | ||
25 | * changes the location of the PHCD and PTS fields | ||
26 | * requires_usbmode_setup: true if the USBMODE register needs to be set to | ||
27 | * enter host mode | ||
28 | * requires_extra_tuning_parameters: true if xcvr_hsslew, hssquelch_level | ||
29 | * and hsdiscon_level should be set for adequate signal quality | ||
30 | */ | ||
31 | |||
32 | struct tegra_phy_soc_config { | ||
33 | bool utmi_pll_config_in_car_module; | ||
34 | bool has_hostpc; | ||
35 | bool requires_usbmode_setup; | ||
36 | bool requires_extra_tuning_parameters; | ||
37 | }; | ||
38 | |||
21 | struct tegra_utmip_config { | 39 | struct tegra_utmip_config { |
22 | u8 hssync_start_delay; | 40 | u8 hssync_start_delay; |
23 | u8 elastic_limit; | 41 | u8 elastic_limit; |
24 | u8 idle_wait_delay; | 42 | u8 idle_wait_delay; |
25 | u8 term_range_adj; | 43 | u8 term_range_adj; |
44 | bool xcvr_setup_use_fuses; | ||
26 | u8 xcvr_setup; | 45 | u8 xcvr_setup; |
27 | u8 xcvr_lsfslew; | 46 | u8 xcvr_lsfslew; |
28 | u8 xcvr_lsrslew; | 47 | u8 xcvr_lsrslew; |
29 | }; | 48 | u8 xcvr_hsslew; |
30 | 49 | u8 hssquelch_level; | |
31 | struct tegra_ulpi_config { | 50 | u8 hsdiscon_level; |
32 | int reset_gpio; | ||
33 | const char *clk; | ||
34 | }; | 51 | }; |
35 | 52 | ||
36 | enum tegra_usb_phy_port_speed { | 53 | enum tegra_usb_phy_port_speed { |
@@ -39,12 +56,6 @@ enum tegra_usb_phy_port_speed { | |||
39 | TEGRA_USB_PHY_PORT_SPEED_HIGH, | 56 | TEGRA_USB_PHY_PORT_SPEED_HIGH, |
40 | }; | 57 | }; |
41 | 58 | ||
42 | enum tegra_usb_phy_mode { | ||
43 | TEGRA_USB_PHY_MODE_DEVICE, | ||
44 | TEGRA_USB_PHY_MODE_HOST, | ||
45 | TEGRA_USB_PHY_MODE_OTG, | ||
46 | }; | ||
47 | |||
48 | struct tegra_xtal_freq; | 59 | struct tegra_xtal_freq; |
49 | 60 | ||
50 | struct tegra_usb_phy { | 61 | struct tegra_usb_phy { |
@@ -55,18 +66,17 @@ struct tegra_usb_phy { | |||
55 | struct clk *clk; | 66 | struct clk *clk; |
56 | struct clk *pll_u; | 67 | struct clk *pll_u; |
57 | struct clk *pad_clk; | 68 | struct clk *pad_clk; |
58 | enum tegra_usb_phy_mode mode; | 69 | struct regulator *vbus; |
70 | enum usb_dr_mode mode; | ||
59 | void *config; | 71 | void *config; |
72 | const struct tegra_phy_soc_config *soc_config; | ||
60 | struct usb_phy *ulpi; | 73 | struct usb_phy *ulpi; |
61 | struct usb_phy u_phy; | 74 | struct usb_phy u_phy; |
62 | struct device *dev; | ||
63 | bool is_legacy_phy; | 75 | bool is_legacy_phy; |
64 | bool is_ulpi_phy; | 76 | bool is_ulpi_phy; |
65 | int reset_gpio; | 77 | int reset_gpio; |
66 | }; | 78 | }; |
67 | 79 | ||
68 | struct usb_phy *tegra_usb_get_phy(struct device_node *dn); | ||
69 | |||
70 | void tegra_usb_phy_preresume(struct usb_phy *phy); | 80 | void tegra_usb_phy_preresume(struct usb_phy *phy); |
71 | 81 | ||
72 | void tegra_usb_phy_postresume(struct usb_phy *phy); | 82 | void tegra_usb_phy_postresume(struct usb_phy *phy); |
diff --git a/include/linux/usb/nop-usb-xceiv.h b/include/linux/usb/usb_phy_gen_xceiv.h index 148d35171aac..f9a7e7bc925b 100644 --- a/include/linux/usb/nop-usb-xceiv.h +++ b/include/linux/usb/usb_phy_gen_xceiv.h | |||
@@ -3,7 +3,7 @@ | |||
3 | 3 | ||
4 | #include <linux/usb/otg.h> | 4 | #include <linux/usb/otg.h> |
5 | 5 | ||
6 | struct nop_usb_xceiv_platform_data { | 6 | struct usb_phy_gen_xceiv_platform_data { |
7 | enum usb_phy_type type; | 7 | enum usb_phy_type type; |
8 | unsigned long clk_rate; | 8 | unsigned long clk_rate; |
9 | 9 | ||
@@ -12,7 +12,7 @@ struct nop_usb_xceiv_platform_data { | |||
12 | unsigned int needs_reset:1; | 12 | unsigned int needs_reset:1; |
13 | }; | 13 | }; |
14 | 14 | ||
15 | #if defined(CONFIG_NOP_USB_XCEIV) || (defined(CONFIG_NOP_USB_XCEIV_MODULE) && defined(MODULE)) | 15 | #if IS_ENABLED(CONFIG_NOP_USB_XCEIV) |
16 | /* sometimes transceivers are accessed only through e.g. ULPI */ | 16 | /* sometimes transceivers are accessed only through e.g. ULPI */ |
17 | extern void usb_nop_xceiv_register(void); | 17 | extern void usb_nop_xceiv_register(void); |
18 | extern void usb_nop_xceiv_unregister(void); | 18 | extern void usb_nop_xceiv_unregister(void); |