diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2016-05-21 00:12:25 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-05-21 00:12:25 -0400 |
commit | 19e36ad292ab24980db64a5ff17973d3118a8fb9 (patch) | |
tree | 175715409a689814e5cd425a98f2d2d47f82addf | |
parent | e10abc629f38efd9b6936cf3612583cc846104d9 (diff) | |
parent | 60d5794fe5a50d02f4a0df84b45910a4dfa8b487 (diff) |
Merge tag 'usb-4.7-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb
Pull USB updates from Greg KH:
"Here's the big pull request for USB and PHY drivers for 4.7-rc1
Full details in the shortlog, but it's the normal major gadget driver
updates, phy updates, new usbip code, as well as a bit of lots of
other stuff.
All have been in linux-next with no reported issues"
* tag 'usb-4.7-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (164 commits)
USB: serial: ti_usb_3410_5052: add MOXA UPORT 11x0 support
USB: serial: fix minor-number allocation
USB: serial: quatech2: fix use-after-free in probe error path
USB: serial: mxuport: fix use-after-free in probe error path
USB: serial: keyspan: fix debug and error messages
USB: serial: keyspan: fix URB unlink
USB: serial: keyspan: fix use-after-free in probe error path
USB: serial: io_edgeport: fix memory leaks in probe error path
USB: serial: io_edgeport: fix memory leaks in attach error path
usb: Remove unnecessary space before operator ','.
usb: Remove unnecessary space before open square bracket.
USB: FHCI: avoid redundant condition
usb: host: xhci-rcar: Avoid long wait in xhci_reset()
usb/host/fotg210: remove dead code in create_sysfs_files
usb: wusbcore: Do not initialise statics to 0.
usb: wusbcore: Remove space before ',' and '(' .
USB: serial: cp210x: clean up CRTSCTS flag code
USB: serial: cp210x: get rid of magic numbers in CRTSCTS flag code
USB: serial: cp210x: fix hardware flow-control disable
USB: serial: option: add even more ZTE device ids
...
182 files changed, 7630 insertions, 2525 deletions
diff --git a/Documentation/ABI/testing/sysfs-platform-usbip-vudc b/Documentation/ABI/testing/sysfs-platform-usbip-vudc new file mode 100644 index 000000000000..81fcfb454913 --- /dev/null +++ b/Documentation/ABI/testing/sysfs-platform-usbip-vudc | |||
@@ -0,0 +1,35 @@ | |||
1 | What: /sys/devices/platform/usbip-vudc.%d/dev_desc | ||
2 | Date: April 2016 | ||
3 | KernelVersion: 4.6 | ||
4 | Contact: Krzysztof Opasiak <k.opasiak@samsung.com> | ||
5 | Description: | ||
6 | This file allows to read device descriptor of | ||
7 | gadget driver which is currently bound to this | ||
8 | controller. It is possible to read this file | ||
9 | only if gadget driver is bound, otherwise error | ||
10 | is returned. | ||
11 | |||
12 | What: /sys/devices/platform/usbip-vudc.%d/usbip_status | ||
13 | Date: April 2016 | ||
14 | KernelVersion: 4.6 | ||
15 | Contact: Krzysztof Opasiak <k.opasiak@samsung.com> | ||
16 | Description: | ||
17 | Current status of the device. | ||
18 | Allowed values: | ||
19 | 1 - Device is available and can be exported | ||
20 | 2 - Device is currently exported | ||
21 | 3 - Fatal error occurred during communication | ||
22 | with peer | ||
23 | |||
24 | What: /sys/devices/platform/usbip-vudc.%d/usbip_sockfd | ||
25 | Date: April 2016 | ||
26 | KernelVersion: 4.6 | ||
27 | Contact: Krzysztof Opasiak <k.opasiak@samsung.com> | ||
28 | Description: | ||
29 | This file allows to export usb device to | ||
30 | connection peer. It is done by writing to this | ||
31 | file socket fd (as a string for example "8") | ||
32 | associated with a connection to remote peer who | ||
33 | would like to use this device. It is possible to | ||
34 | close the connection by writing -1 instead of | ||
35 | socked fd. | ||
diff --git a/Documentation/devicetree/bindings/phy/bcm-ns-usb2-phy.txt b/Documentation/devicetree/bindings/phy/bcm-ns-usb2-phy.txt new file mode 100644 index 000000000000..a7aee9ea8926 --- /dev/null +++ b/Documentation/devicetree/bindings/phy/bcm-ns-usb2-phy.txt | |||
@@ -0,0 +1,21 @@ | |||
1 | Driver for Broadcom Northstar USB 2.0 PHY | ||
2 | |||
3 | Required properties: | ||
4 | - compatible: brcm,ns-usb2-phy | ||
5 | - reg: iomem address range of DMU (Device Management Unit) | ||
6 | - reg-names: "dmu", the only needed & supported reg right now | ||
7 | - clocks: USB PHY reference clock | ||
8 | - clock-names: "phy-ref-clk", the only needed & supported clock right now | ||
9 | |||
10 | To initialize USB 2.0 PHY driver needs to setup PLL correctly. To do this it | ||
11 | requires passing phandle to the USB PHY reference clock. | ||
12 | |||
13 | Example: | ||
14 | usb2-phy { | ||
15 | compatible = "brcm,ns-usb2-phy"; | ||
16 | reg = <0x1800c000 0x1000>; | ||
17 | reg-names = "dmu"; | ||
18 | #phy-cells = <0>; | ||
19 | clocks = <&genpll BCM_NSP_GENPLL_USB_PHY_REF_CLK>; | ||
20 | clock-names = "phy-ref-clk"; | ||
21 | }; | ||
diff --git a/Documentation/devicetree/bindings/phy/brcm,brcmstb-sata-phy.txt b/Documentation/devicetree/bindings/phy/brcm-sata-phy.txt index d87ab7c127b8..d0231209d846 100644 --- a/Documentation/devicetree/bindings/phy/brcm,brcmstb-sata-phy.txt +++ b/Documentation/devicetree/bindings/phy/brcm-sata-phy.txt | |||
@@ -1,14 +1,17 @@ | |||
1 | * Broadcom SATA3 PHY for STB | 1 | * Broadcom SATA3 PHY |
2 | 2 | ||
3 | Required properties: | 3 | Required properties: |
4 | - compatible: should be one or more of | 4 | - compatible: should be one or more of |
5 | "brcm,bcm7425-sata-phy" | 5 | "brcm,bcm7425-sata-phy" |
6 | "brcm,bcm7445-sata-phy" | 6 | "brcm,bcm7445-sata-phy" |
7 | "brcm,iproc-ns2-sata-phy" | ||
7 | "brcm,phy-sata3" | 8 | "brcm,phy-sata3" |
8 | - address-cells: should be 1 | 9 | - address-cells: should be 1 |
9 | - size-cells: should be 0 | 10 | - size-cells: should be 0 |
10 | - reg: register range for the PHY PCB interface | 11 | - reg: register ranges for the PHY PCB interface |
11 | - reg-names: should be "phy" | 12 | - reg-names: should be "phy" and "phy-ctrl" |
13 | The "phy-ctrl" registers are only required for | ||
14 | "brcm,iproc-ns2-sata-phy". | ||
12 | 15 | ||
13 | Sub-nodes: | 16 | Sub-nodes: |
14 | Each port's PHY should be represented as a sub-node. | 17 | Each port's PHY should be represented as a sub-node. |
@@ -16,12 +19,12 @@ Sub-nodes: | |||
16 | Sub-nodes required properties: | 19 | Sub-nodes required properties: |
17 | - reg: the PHY number | 20 | - reg: the PHY number |
18 | - phy-cells: generic PHY binding; must be 0 | 21 | - phy-cells: generic PHY binding; must be 0 |
19 | Optional: | ||
20 | - brcm,enable-ssc: use spread spectrum clocking (SSC) on this port | ||
21 | 22 | ||
23 | Sub-nodes optional properties: | ||
24 | - brcm,enable-ssc: use spread spectrum clocking (SSC) on this port | ||
25 | This property is not applicable for "brcm,iproc-ns2-sata-phy". | ||
22 | 26 | ||
23 | Example: | 27 | Example: |
24 | |||
25 | sata-phy@f0458100 { | 28 | sata-phy@f0458100 { |
26 | compatible = "brcm,bcm7445-sata-phy", "brcm,phy-sata3"; | 29 | compatible = "brcm,bcm7445-sata-phy", "brcm,phy-sata3"; |
27 | reg = <0xf0458100 0x1e00>, <0xf045804c 0x10>; | 30 | reg = <0xf0458100 0x1e00>, <0xf045804c 0x10>; |
diff --git a/Documentation/devicetree/bindings/phy/phy-mt65xx-usb.txt b/Documentation/devicetree/bindings/phy/phy-mt65xx-usb.txt index 00100cf3e037..33a2b1ee3f3e 100644 --- a/Documentation/devicetree/bindings/phy/phy-mt65xx-usb.txt +++ b/Documentation/devicetree/bindings/phy/phy-mt65xx-usb.txt | |||
@@ -4,7 +4,9 @@ mt65xx USB3.0 PHY binding | |||
4 | This binding describes a usb3.0 phy for mt65xx platforms of Medaitek SoC. | 4 | This binding describes a usb3.0 phy for mt65xx platforms of Medaitek SoC. |
5 | 5 | ||
6 | Required properties (controller (parent) node): | 6 | Required properties (controller (parent) node): |
7 | - compatible : should be "mediatek,mt8173-u3phy" | 7 | - compatible : should be one of |
8 | "mediatek,mt2701-u3phy" | ||
9 | "mediatek,mt8173-u3phy" | ||
8 | - reg : offset and length of register for phy, exclude port's | 10 | - reg : offset and length of register for phy, exclude port's |
9 | register. | 11 | register. |
10 | - clocks : a list of phandle + clock-specifier pairs, one for each | 12 | - clocks : a list of phandle + clock-specifier pairs, one for each |
diff --git a/Documentation/devicetree/bindings/phy/rcar-gen2-phy.txt b/Documentation/devicetree/bindings/phy/rcar-gen2-phy.txt index d564ba4f1cf6..91da947ae9b6 100644 --- a/Documentation/devicetree/bindings/phy/rcar-gen2-phy.txt +++ b/Documentation/devicetree/bindings/phy/rcar-gen2-phy.txt | |||
@@ -7,6 +7,12 @@ Required properties: | |||
7 | - compatible: "renesas,usb-phy-r8a7790" if the device is a part of R8A7790 SoC. | 7 | - compatible: "renesas,usb-phy-r8a7790" if the device is a part of R8A7790 SoC. |
8 | "renesas,usb-phy-r8a7791" if the device is a part of R8A7791 SoC. | 8 | "renesas,usb-phy-r8a7791" if the device is a part of R8A7791 SoC. |
9 | "renesas,usb-phy-r8a7794" if the device is a part of R8A7794 SoC. | 9 | "renesas,usb-phy-r8a7794" if the device is a part of R8A7794 SoC. |
10 | "renesas,rcar-gen2-usb-phy" for a generic R-Car Gen2 compatible device. | ||
11 | |||
12 | When compatible with the generic version, nodes must list the | ||
13 | SoC-specific version corresponding to the platform first | ||
14 | followed by the generic version. | ||
15 | |||
10 | - reg: offset and length of the register block. | 16 | - reg: offset and length of the register block. |
11 | - #address-cells: number of address cells for the USB channel subnodes, must | 17 | - #address-cells: number of address cells for the USB channel subnodes, must |
12 | be <1>. | 18 | be <1>. |
@@ -34,7 +40,7 @@ the USB channel; see the selector meanings below: | |||
34 | Example (Lager board): | 40 | Example (Lager board): |
35 | 41 | ||
36 | usb-phy@e6590100 { | 42 | usb-phy@e6590100 { |
37 | compatible = "renesas,usb-phy-r8a7790"; | 43 | compatible = "renesas,usb-phy-r8a7790", "renesas,rcar-gen2-usb-phy"; |
38 | reg = <0 0xe6590100 0 0x100>; | 44 | reg = <0 0xe6590100 0 0x100>; |
39 | #address-cells = <1>; | 45 | #address-cells = <1>; |
40 | #size-cells = <0>; | 46 | #size-cells = <0>; |
diff --git a/Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb2.txt b/Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb2.txt index eaf7e9b7ce6b..2281d6cdecb1 100644 --- a/Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb2.txt +++ b/Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb2.txt | |||
@@ -6,6 +6,12 @@ This file provides information on what the device node for the R-Car generation | |||
6 | Required properties: | 6 | Required properties: |
7 | - compatible: "renesas,usb2-phy-r8a7795" if the device is a part of an R8A7795 | 7 | - compatible: "renesas,usb2-phy-r8a7795" if the device is a part of an R8A7795 |
8 | SoC. | 8 | SoC. |
9 | "renesas,rcar-gen3-usb2-phy" for a generic R-Car Gen3 compatible device. | ||
10 | |||
11 | When compatible with the generic version, nodes must list the | ||
12 | SoC-specific version corresponding to the platform first | ||
13 | followed by the generic version. | ||
14 | |||
9 | - reg: offset and length of the partial USB 2.0 Host register block. | 15 | - reg: offset and length of the partial USB 2.0 Host register block. |
10 | - clocks: clock phandle and specifier pair(s). | 16 | - clocks: clock phandle and specifier pair(s). |
11 | - #phy-cells: see phy-bindings.txt in the same directory, must be <0>. | 17 | - #phy-cells: see phy-bindings.txt in the same directory, must be <0>. |
@@ -15,18 +21,20 @@ To use a USB channel where USB 2.0 Host and HSUSB (USB 2.0 Peripheral) are | |||
15 | combined, the device tree node should set interrupt properties to use the | 21 | combined, the device tree node should set interrupt properties to use the |
16 | channel as USB OTG: | 22 | channel as USB OTG: |
17 | - interrupts: interrupt specifier for the PHY. | 23 | - interrupts: interrupt specifier for the PHY. |
24 | - vbus-supply: Phandle to a regulator that provides power to the VBUS. This | ||
25 | regulator will be managed during the PHY power on/off sequence. | ||
18 | 26 | ||
19 | Example (R-Car H3): | 27 | Example (R-Car H3): |
20 | 28 | ||
21 | usb-phy@ee080200 { | 29 | usb-phy@ee080200 { |
22 | compatible = "renesas,usb2-phy-r8a7795"; | 30 | compatible = "renesas,usb2-phy-r8a7795", "renesas,rcar-gen3-usb2-phy"; |
23 | reg = <0 0xee080200 0 0x700>; | 31 | reg = <0 0xee080200 0 0x700>; |
24 | interrupts = <GIC_SPI 108 IRQ_TYPE_LEVEL_HIGH>; | 32 | interrupts = <GIC_SPI 108 IRQ_TYPE_LEVEL_HIGH>; |
25 | clocks = <&mstp7_clks R8A7795_CLK_EHCI0>; | 33 | clocks = <&mstp7_clks R8A7795_CLK_EHCI0>; |
26 | }; | 34 | }; |
27 | 35 | ||
28 | usb-phy@ee0a0200 { | 36 | usb-phy@ee0a0200 { |
29 | compatible = "renesas,usb2-phy-r8a7795"; | 37 | compatible = "renesas,usb2-phy-r8a7795", "renesas,rcar-gen3-usb2-phy"; |
30 | reg = <0 0xee0a0200 0 0x700>; | 38 | reg = <0 0xee0a0200 0 0x700>; |
31 | clocks = <&mstp7_clks R8A7795_CLK_EHCI0>; | 39 | clocks = <&mstp7_clks R8A7795_CLK_EHCI0>; |
32 | }; | 40 | }; |
diff --git a/Documentation/devicetree/bindings/phy/samsung-phy.txt b/Documentation/devicetree/bindings/phy/samsung-phy.txt index 0289d3b07853..9872ba8546bd 100644 --- a/Documentation/devicetree/bindings/phy/samsung-phy.txt +++ b/Documentation/devicetree/bindings/phy/samsung-phy.txt | |||
@@ -2,9 +2,20 @@ Samsung S5P/EXYNOS SoC series MIPI CSIS/DSIM DPHY | |||
2 | ------------------------------------------------- | 2 | ------------------------------------------------- |
3 | 3 | ||
4 | Required properties: | 4 | Required properties: |
5 | - compatible : should be "samsung,s5pv210-mipi-video-phy"; | 5 | - compatible : should be one of the listed compatibles: |
6 | - "samsung,s5pv210-mipi-video-phy" | ||
7 | - "samsung,exynos5420-mipi-video-phy" | ||
8 | - "samsung,exynos5433-mipi-video-phy" | ||
6 | - #phy-cells : from the generic phy bindings, must be 1; | 9 | - #phy-cells : from the generic phy bindings, must be 1; |
7 | - syscon - phandle to the PMU system controller; | 10 | |
11 | In case of s5pv210 and exynos5420 compatible PHYs: | ||
12 | - syscon - phandle to the PMU system controller | ||
13 | |||
14 | In case of exynos5433 compatible PHY: | ||
15 | - samsung,pmu-syscon - phandle to the PMU system controller | ||
16 | - samsung,disp-sysreg - phandle to the DISP system registers controller | ||
17 | - samsung,cam0-sysreg - phandle to the CAM0 system registers controller | ||
18 | - samsung,cam1-sysreg - phandle to the CAM1 system registers controller | ||
8 | 19 | ||
9 | For "samsung,s5pv210-mipi-video-phy" compatible PHYs the second cell in | 20 | For "samsung,s5pv210-mipi-video-phy" compatible PHYs the second cell in |
10 | the PHY specifier identifies the PHY and its meaning is as follows: | 21 | the PHY specifier identifies the PHY and its meaning is as follows: |
@@ -12,6 +23,9 @@ the PHY specifier identifies the PHY and its meaning is as follows: | |||
12 | 1 - MIPI DSIM 0, | 23 | 1 - MIPI DSIM 0, |
13 | 2 - MIPI CSIS 1, | 24 | 2 - MIPI CSIS 1, |
14 | 3 - MIPI DSIM 1. | 25 | 3 - MIPI DSIM 1. |
26 | "samsung,exynos5420-mipi-video-phy" and "samsung,exynos5433-mipi-video-phy" | ||
27 | supports additional fifth PHY: | ||
28 | 4 - MIPI CSIS 2. | ||
15 | 29 | ||
16 | Samsung EXYNOS SoC series Display Port PHY | 30 | Samsung EXYNOS SoC series Display Port PHY |
17 | ------------------------------------------------- | 31 | ------------------------------------------------- |
diff --git a/Documentation/devicetree/bindings/usb/dwc3.txt b/Documentation/devicetree/bindings/usb/dwc3.txt index fb2ad0acedbd..7d7ce089b003 100644 --- a/Documentation/devicetree/bindings/usb/dwc3.txt +++ b/Documentation/devicetree/bindings/usb/dwc3.txt | |||
@@ -14,7 +14,6 @@ Optional properties: | |||
14 | the second element is expected to be a handle to the USB3/SS PHY | 14 | the second element is expected to be a handle to the USB3/SS PHY |
15 | - phys: from the *Generic PHY* bindings | 15 | - phys: from the *Generic PHY* bindings |
16 | - phy-names: from the *Generic PHY* bindings | 16 | - phy-names: from the *Generic PHY* bindings |
17 | - tx-fifo-resize: determines if the FIFO *has* to be reallocated. | ||
18 | - snps,usb3_lpm_capable: determines if platform is USB3 LPM capable | 17 | - snps,usb3_lpm_capable: determines if platform is USB3 LPM capable |
19 | - snps,disable_scramble_quirk: true when SW should disable data scrambling. | 18 | - snps,disable_scramble_quirk: true when SW should disable data scrambling. |
20 | Only really useful for FPGA builds. | 19 | Only really useful for FPGA builds. |
@@ -38,6 +37,8 @@ Optional properties: | |||
38 | - snps,dis_u2_susphy_quirk: when set core will disable USB2 suspend phy. | 37 | - snps,dis_u2_susphy_quirk: when set core will disable USB2 suspend phy. |
39 | - snps,dis_enblslpm_quirk: when set clears the enblslpm in GUSB2PHYCFG, | 38 | - snps,dis_enblslpm_quirk: when set clears the enblslpm in GUSB2PHYCFG, |
40 | disabling the suspend signal to the PHY. | 39 | disabling the suspend signal to the PHY. |
40 | - snps,dis_rxdet_inp3_quirk: when set core will disable receiver detection | ||
41 | in PHY P3 power state. | ||
41 | - snps,is-utmi-l1-suspend: true when DWC3 asserts output signal | 42 | - snps,is-utmi-l1-suspend: true when DWC3 asserts output signal |
42 | utmi_l1_suspend_n, false when asserts utmi_sleep_n | 43 | utmi_l1_suspend_n, false when asserts utmi_sleep_n |
43 | - snps,hird-threshold: HIRD threshold | 44 | - snps,hird-threshold: HIRD threshold |
@@ -47,6 +48,8 @@ Optional properties: | |||
47 | register for post-silicon frame length adjustment when the | 48 | register for post-silicon frame length adjustment when the |
48 | fladj_30mhz_sdbnd signal is invalid or incorrect. | 49 | fladj_30mhz_sdbnd signal is invalid or incorrect. |
49 | 50 | ||
51 | - <DEPRECATED> tx-fifo-resize: determines if the FIFO *has* to be reallocated. | ||
52 | |||
50 | This is usually a subnode to DWC3 glue to which it is connected. | 53 | This is usually a subnode to DWC3 glue to which it is connected. |
51 | 54 | ||
52 | dwc3@4a030000 { | 55 | dwc3@4a030000 { |
@@ -54,5 +57,4 @@ dwc3@4a030000 { | |||
54 | reg = <0x4a030000 0xcfff>; | 57 | reg = <0x4a030000 0xcfff>; |
55 | interrupts = <0 92 4> | 58 | interrupts = <0 92 4> |
56 | usb-phy = <&usb2_phy>, <&usb3,phy>; | 59 | usb-phy = <&usb2_phy>, <&usb3,phy>; |
57 | tx-fifo-resize; | ||
58 | }; | 60 | }; |
diff --git a/Documentation/devicetree/bindings/usb/qcom,dwc3.txt b/Documentation/devicetree/bindings/usb/qcom,dwc3.txt index ca164e71dd50..39acb084bce9 100644 --- a/Documentation/devicetree/bindings/usb/qcom,dwc3.txt +++ b/Documentation/devicetree/bindings/usb/qcom,dwc3.txt | |||
@@ -59,7 +59,6 @@ Example device nodes: | |||
59 | interrupts = <0 205 0x4>; | 59 | interrupts = <0 205 0x4>; |
60 | phys = <&hs_phy>, <&ss_phy>; | 60 | phys = <&hs_phy>, <&ss_phy>; |
61 | phy-names = "usb2-phy", "usb3-phy"; | 61 | phy-names = "usb2-phy", "usb3-phy"; |
62 | tx-fifo-resize; | ||
63 | dr_mode = "host"; | 62 | dr_mode = "host"; |
64 | }; | 63 | }; |
65 | }; | 64 | }; |
diff --git a/Documentation/usb/chipidea.txt b/Documentation/usb/chipidea.txt index 678741b0f213..edf7cdfddc88 100644 --- a/Documentation/usb/chipidea.txt +++ b/Documentation/usb/chipidea.txt | |||
@@ -3,14 +3,17 @@ | |||
3 | To show how to demo OTG HNP and SRP functions via sys input files | 3 | To show how to demo OTG HNP and SRP functions via sys input files |
4 | with 2 Freescale i.MX6Q sabre SD boards. | 4 | with 2 Freescale i.MX6Q sabre SD boards. |
5 | 5 | ||
6 | 1.1 How to enable OTG FSM in menuconfig | 6 | 1.1 How to enable OTG FSM |
7 | --------------------------------------- | 7 | --------------------------------------- |
8 | Select CONFIG_USB_OTG_FSM, rebuild kernel Image and modules. | 8 | 1.1.1 Select CONFIG_USB_OTG_FSM in menuconfig, rebuild kernel |
9 | If you want to check some internal variables for otg fsm, | 9 | Image and modules. If you want to check some internal |
10 | mount debugfs, there are 2 files which can show otg fsm | 10 | variables for otg fsm, mount debugfs, there are 2 files |
11 | variables and some controller registers value: | 11 | which can show otg fsm variables and some controller registers value: |
12 | cat /sys/kernel/debug/ci_hdrc.0/otg | 12 | cat /sys/kernel/debug/ci_hdrc.0/otg |
13 | cat /sys/kernel/debug/ci_hdrc.0/registers | 13 | cat /sys/kernel/debug/ci_hdrc.0/registers |
14 | 1.1.2 Add below entries in your dts file for your controller node | ||
15 | otg-rev = <0x0200>; | ||
16 | adp-disable; | ||
14 | 17 | ||
15 | 1.2 Test operations | 18 | 1.2 Test operations |
16 | ------------------- | 19 | ------------------- |
diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index 27e5f6ee9a2a..b869b98835f4 100644 --- a/drivers/phy/Kconfig +++ b/drivers/phy/Kconfig | |||
@@ -15,6 +15,15 @@ config GENERIC_PHY | |||
15 | phy users can obtain reference to the PHY. All the users of this | 15 | phy users can obtain reference to the PHY. All the users of this |
16 | framework should select this config. | 16 | framework should select this config. |
17 | 17 | ||
18 | config PHY_BCM_NS_USB2 | ||
19 | tristate "Broadcom Northstar USB 2.0 PHY Driver" | ||
20 | depends on ARCH_BCM_IPROC || COMPILE_TEST | ||
21 | depends on HAS_IOMEM && OF | ||
22 | select GENERIC_PHY | ||
23 | help | ||
24 | Enable this to support Broadcom USB 2.0 PHY connected to the USB | ||
25 | controller on Northstar family. | ||
26 | |||
18 | config PHY_BERLIN_USB | 27 | config PHY_BERLIN_USB |
19 | tristate "Marvell Berlin USB PHY Driver" | 28 | tristate "Marvell Berlin USB PHY Driver" |
20 | depends on ARCH_BERLIN && RESET_CONTROLLER && HAS_IOMEM && OF | 29 | depends on ARCH_BERLIN && RESET_CONTROLLER && HAS_IOMEM && OF |
@@ -113,14 +122,15 @@ config PHY_MIPHY365X | |||
113 | 122 | ||
114 | config PHY_RCAR_GEN2 | 123 | config PHY_RCAR_GEN2 |
115 | tristate "Renesas R-Car generation 2 USB PHY driver" | 124 | tristate "Renesas R-Car generation 2 USB PHY driver" |
116 | depends on ARCH_SHMOBILE | 125 | depends on ARCH_RENESAS |
117 | depends on GENERIC_PHY | 126 | depends on GENERIC_PHY |
118 | help | 127 | help |
119 | Support for USB PHY found on Renesas R-Car generation 2 SoCs. | 128 | Support for USB PHY found on Renesas R-Car generation 2 SoCs. |
120 | 129 | ||
121 | config PHY_RCAR_GEN3_USB2 | 130 | config PHY_RCAR_GEN3_USB2 |
122 | tristate "Renesas R-Car generation 3 USB 2.0 PHY driver" | 131 | tristate "Renesas R-Car generation 3 USB 2.0 PHY driver" |
123 | depends on OF && ARCH_SHMOBILE | 132 | depends on ARCH_RENESAS |
133 | depends on EXTCON | ||
124 | select GENERIC_PHY | 134 | select GENERIC_PHY |
125 | help | 135 | help |
126 | Support for USB 2.0 PHY found on Renesas R-Car generation 3 SoCs. | 136 | Support for USB 2.0 PHY found on Renesas R-Car generation 3 SoCs. |
@@ -218,9 +228,8 @@ config PHY_MT65XX_USB3 | |||
218 | depends on ARCH_MEDIATEK && OF | 228 | depends on ARCH_MEDIATEK && OF |
219 | select GENERIC_PHY | 229 | select GENERIC_PHY |
220 | help | 230 | help |
221 | Say 'Y' here to add support for Mediatek USB3.0 PHY driver | 231 | Say 'Y' here to add support for Mediatek USB3.0 PHY driver, |
222 | for mt65xx SoCs. it supports two usb2.0 ports and | 232 | it supports multiple usb2.0 and usb3.0 ports. |
223 | one usb3.0 port. | ||
224 | 233 | ||
225 | config PHY_HI6220_USB | 234 | config PHY_HI6220_USB |
226 | tristate "hi6220 USB PHY support" | 235 | tristate "hi6220 USB PHY support" |
@@ -250,7 +259,8 @@ config PHY_SUN9I_USB | |||
250 | tristate "Allwinner sun9i SoC USB PHY driver" | 259 | tristate "Allwinner sun9i SoC USB PHY driver" |
251 | depends on ARCH_SUNXI && HAS_IOMEM && OF | 260 | depends on ARCH_SUNXI && HAS_IOMEM && OF |
252 | depends on RESET_CONTROLLER | 261 | depends on RESET_CONTROLLER |
253 | depends on USB_COMMON | 262 | depends on USB_SUPPORT |
263 | select USB_COMMON | ||
254 | select GENERIC_PHY | 264 | select GENERIC_PHY |
255 | help | 265 | help |
256 | Enable this to support the transceiver that is part of Allwinner | 266 | Enable this to support the transceiver that is part of Allwinner |
@@ -403,14 +413,15 @@ config PHY_TUSB1210 | |||
403 | help | 413 | help |
404 | Support for TI TUSB1210 USB ULPI PHY. | 414 | Support for TI TUSB1210 USB ULPI PHY. |
405 | 415 | ||
406 | config PHY_BRCMSTB_SATA | 416 | config PHY_BRCM_SATA |
407 | tristate "Broadcom STB SATA PHY driver" | 417 | tristate "Broadcom SATA PHY driver" |
408 | depends on ARCH_BRCMSTB || BMIPS_GENERIC | 418 | depends on ARCH_BRCMSTB || ARCH_BCM_IPROC || BMIPS_GENERIC || COMPILE_TEST |
409 | depends on OF | 419 | depends on OF |
410 | select GENERIC_PHY | 420 | select GENERIC_PHY |
421 | default ARCH_BCM_IPROC | ||
411 | help | 422 | help |
412 | Enable this to support the SATA3 PHY on 28nm or 40nm Broadcom STB SoCs. | 423 | Enable this to support the Broadcom SATA PHY. |
413 | Likely useful only with CONFIG_SATA_BRCMSTB enabled. | 424 | If unsure, say N. |
414 | 425 | ||
415 | config PHY_CYGNUS_PCIE | 426 | config PHY_CYGNUS_PCIE |
416 | tristate "Broadcom Cygnus PCIe PHY driver" | 427 | tristate "Broadcom Cygnus PCIe PHY driver" |
diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile index d4f06e69fd9a..9c3e73ccabc4 100644 --- a/drivers/phy/Makefile +++ b/drivers/phy/Makefile | |||
@@ -3,6 +3,7 @@ | |||
3 | # | 3 | # |
4 | 4 | ||
5 | obj-$(CONFIG_GENERIC_PHY) += phy-core.o | 5 | obj-$(CONFIG_GENERIC_PHY) += phy-core.o |
6 | obj-$(CONFIG_PHY_BCM_NS_USB2) += phy-bcm-ns-usb2.o | ||
6 | obj-$(CONFIG_PHY_BERLIN_USB) += phy-berlin-usb.o | 7 | obj-$(CONFIG_PHY_BERLIN_USB) += phy-berlin-usb.o |
7 | obj-$(CONFIG_PHY_BERLIN_SATA) += phy-berlin-sata.o | 8 | obj-$(CONFIG_PHY_BERLIN_SATA) += phy-berlin-sata.o |
8 | obj-$(CONFIG_PHY_DM816X_USB) += phy-dm816x-usb.o | 9 | obj-$(CONFIG_PHY_DM816X_USB) += phy-dm816x-usb.o |
@@ -49,7 +50,7 @@ obj-$(CONFIG_PHY_QCOM_UFS) += phy-qcom-ufs.o | |||
49 | obj-$(CONFIG_PHY_QCOM_UFS) += phy-qcom-ufs-qmp-20nm.o | 50 | obj-$(CONFIG_PHY_QCOM_UFS) += phy-qcom-ufs-qmp-20nm.o |
50 | obj-$(CONFIG_PHY_QCOM_UFS) += phy-qcom-ufs-qmp-14nm.o | 51 | obj-$(CONFIG_PHY_QCOM_UFS) += phy-qcom-ufs-qmp-14nm.o |
51 | obj-$(CONFIG_PHY_TUSB1210) += phy-tusb1210.o | 52 | obj-$(CONFIG_PHY_TUSB1210) += phy-tusb1210.o |
52 | obj-$(CONFIG_PHY_BRCMSTB_SATA) += phy-brcmstb-sata.o | 53 | obj-$(CONFIG_PHY_BRCM_SATA) += phy-brcm-sata.o |
53 | obj-$(CONFIG_PHY_PISTACHIO_USB) += phy-pistachio-usb.o | 54 | obj-$(CONFIG_PHY_PISTACHIO_USB) += phy-pistachio-usb.o |
54 | obj-$(CONFIG_PHY_CYGNUS_PCIE) += phy-bcm-cygnus-pcie.o | 55 | obj-$(CONFIG_PHY_CYGNUS_PCIE) += phy-bcm-cygnus-pcie.o |
55 | 56 | ||
diff --git a/drivers/phy/phy-bcm-ns-usb2.c b/drivers/phy/phy-bcm-ns-usb2.c new file mode 100644 index 000000000000..95ab6b2a0de5 --- /dev/null +++ b/drivers/phy/phy-bcm-ns-usb2.c | |||
@@ -0,0 +1,137 @@ | |||
1 | /* | ||
2 | * Broadcom Northstar USB 2.0 PHY Driver | ||
3 | * | ||
4 | * Copyright (C) 2016 Rafał Miłecki <zajec5@gmail.com> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License version 2 as | ||
8 | * published by the Free Software Foundation. | ||
9 | * | ||
10 | */ | ||
11 | |||
12 | #include <linux/bcma/bcma.h> | ||
13 | #include <linux/clk.h> | ||
14 | #include <linux/delay.h> | ||
15 | #include <linux/err.h> | ||
16 | #include <linux/module.h> | ||
17 | #include <linux/of_address.h> | ||
18 | #include <linux/of_platform.h> | ||
19 | #include <linux/phy/phy.h> | ||
20 | #include <linux/platform_device.h> | ||
21 | #include <linux/slab.h> | ||
22 | |||
23 | struct bcm_ns_usb2 { | ||
24 | struct device *dev; | ||
25 | struct clk *ref_clk; | ||
26 | struct phy *phy; | ||
27 | void __iomem *dmu; | ||
28 | }; | ||
29 | |||
30 | static int bcm_ns_usb2_phy_init(struct phy *phy) | ||
31 | { | ||
32 | struct bcm_ns_usb2 *usb2 = phy_get_drvdata(phy); | ||
33 | struct device *dev = usb2->dev; | ||
34 | void __iomem *dmu = usb2->dmu; | ||
35 | u32 ref_clk_rate, usb2ctl, usb_pll_ndiv, usb_pll_pdiv; | ||
36 | int err = 0; | ||
37 | |||
38 | err = clk_prepare_enable(usb2->ref_clk); | ||
39 | if (err < 0) { | ||
40 | dev_err(dev, "Failed to prepare ref clock: %d\n", err); | ||
41 | goto err_out; | ||
42 | } | ||
43 | |||
44 | ref_clk_rate = clk_get_rate(usb2->ref_clk); | ||
45 | if (!ref_clk_rate) { | ||
46 | dev_err(dev, "Failed to get ref clock rate\n"); | ||
47 | err = -EINVAL; | ||
48 | goto err_clk_off; | ||
49 | } | ||
50 | |||
51 | usb2ctl = readl(dmu + BCMA_DMU_CRU_USB2_CONTROL); | ||
52 | |||
53 | if (usb2ctl & BCMA_DMU_CRU_USB2_CONTROL_USB_PLL_PDIV_MASK) { | ||
54 | usb_pll_pdiv = usb2ctl; | ||
55 | usb_pll_pdiv &= BCMA_DMU_CRU_USB2_CONTROL_USB_PLL_PDIV_MASK; | ||
56 | usb_pll_pdiv >>= BCMA_DMU_CRU_USB2_CONTROL_USB_PLL_PDIV_SHIFT; | ||
57 | } else { | ||
58 | usb_pll_pdiv = 1 << 3; | ||
59 | } | ||
60 | |||
61 | /* Calculate ndiv based on a solid 1920 MHz that is for USB2 PHY */ | ||
62 | usb_pll_ndiv = (1920000000 * usb_pll_pdiv) / ref_clk_rate; | ||
63 | |||
64 | /* Unlock DMU PLL settings with some magic value */ | ||
65 | writel(0x0000ea68, dmu + BCMA_DMU_CRU_CLKSET_KEY); | ||
66 | |||
67 | /* Write USB 2.0 PLL control setting */ | ||
68 | usb2ctl &= ~BCMA_DMU_CRU_USB2_CONTROL_USB_PLL_NDIV_MASK; | ||
69 | usb2ctl |= usb_pll_ndiv << BCMA_DMU_CRU_USB2_CONTROL_USB_PLL_NDIV_SHIFT; | ||
70 | writel(usb2ctl, dmu + BCMA_DMU_CRU_USB2_CONTROL); | ||
71 | |||
72 | /* Lock DMU PLL settings */ | ||
73 | writel(0x00000000, dmu + BCMA_DMU_CRU_CLKSET_KEY); | ||
74 | |||
75 | err_clk_off: | ||
76 | clk_disable_unprepare(usb2->ref_clk); | ||
77 | err_out: | ||
78 | return err; | ||
79 | } | ||
80 | |||
81 | static const struct phy_ops ops = { | ||
82 | .init = bcm_ns_usb2_phy_init, | ||
83 | .owner = THIS_MODULE, | ||
84 | }; | ||
85 | |||
86 | static int bcm_ns_usb2_probe(struct platform_device *pdev) | ||
87 | { | ||
88 | struct device *dev = &pdev->dev; | ||
89 | struct bcm_ns_usb2 *usb2; | ||
90 | struct resource *res; | ||
91 | struct phy_provider *phy_provider; | ||
92 | |||
93 | usb2 = devm_kzalloc(&pdev->dev, sizeof(*usb2), GFP_KERNEL); | ||
94 | if (!usb2) | ||
95 | return -ENOMEM; | ||
96 | usb2->dev = dev; | ||
97 | |||
98 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dmu"); | ||
99 | usb2->dmu = devm_ioremap_resource(dev, res); | ||
100 | if (IS_ERR(usb2->dmu)) { | ||
101 | dev_err(dev, "Failed to map DMU regs\n"); | ||
102 | return PTR_ERR(usb2->dmu); | ||
103 | } | ||
104 | |||
105 | usb2->ref_clk = devm_clk_get(dev, "phy-ref-clk"); | ||
106 | if (IS_ERR(usb2->ref_clk)) { | ||
107 | dev_err(dev, "Clock not defined\n"); | ||
108 | return PTR_ERR(usb2->ref_clk); | ||
109 | } | ||
110 | |||
111 | usb2->phy = devm_phy_create(dev, NULL, &ops); | ||
112 | if (IS_ERR(dev)) | ||
113 | return PTR_ERR(dev); | ||
114 | |||
115 | phy_set_drvdata(usb2->phy, usb2); | ||
116 | platform_set_drvdata(pdev, usb2); | ||
117 | |||
118 | phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate); | ||
119 | return PTR_ERR_OR_ZERO(phy_provider); | ||
120 | } | ||
121 | |||
122 | static const struct of_device_id bcm_ns_usb2_id_table[] = { | ||
123 | { .compatible = "brcm,ns-usb2-phy", }, | ||
124 | {}, | ||
125 | }; | ||
126 | MODULE_DEVICE_TABLE(of, bcm_ns_usb2_id_table); | ||
127 | |||
128 | static struct platform_driver bcm_ns_usb2_driver = { | ||
129 | .probe = bcm_ns_usb2_probe, | ||
130 | .driver = { | ||
131 | .name = "bcm_ns_usb2", | ||
132 | .of_match_table = bcm_ns_usb2_id_table, | ||
133 | }, | ||
134 | }; | ||
135 | module_platform_driver(bcm_ns_usb2_driver); | ||
136 | |||
137 | MODULE_LICENSE("GPL v2"); | ||
diff --git a/drivers/phy/phy-brcm-sata.c b/drivers/phy/phy-brcm-sata.c new file mode 100644 index 000000000000..6c4c5cb791ca --- /dev/null +++ b/drivers/phy/phy-brcm-sata.c | |||
@@ -0,0 +1,412 @@ | |||
1 | /* | ||
2 | * Broadcom SATA3 AHCI Controller PHY Driver | ||
3 | * | ||
4 | * Copyright (C) 2016 Broadcom | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2, or (at your option) | ||
9 | * any later version. | ||
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 | |||
17 | #include <linux/delay.h> | ||
18 | #include <linux/device.h> | ||
19 | #include <linux/init.h> | ||
20 | #include <linux/interrupt.h> | ||
21 | #include <linux/io.h> | ||
22 | #include <linux/kernel.h> | ||
23 | #include <linux/module.h> | ||
24 | #include <linux/of.h> | ||
25 | #include <linux/phy/phy.h> | ||
26 | #include <linux/platform_device.h> | ||
27 | |||
28 | #define SATA_PCB_BANK_OFFSET 0x23c | ||
29 | #define SATA_PCB_REG_OFFSET(ofs) ((ofs) * 4) | ||
30 | |||
31 | #define MAX_PORTS 2 | ||
32 | |||
33 | /* Register offset between PHYs in PCB space */ | ||
34 | #define SATA_PCB_REG_28NM_SPACE_SIZE 0x1000 | ||
35 | |||
36 | /* The older SATA PHY registers duplicated per port registers within the map, | ||
37 | * rather than having a separate map per port. | ||
38 | */ | ||
39 | #define SATA_PCB_REG_40NM_SPACE_SIZE 0x10 | ||
40 | |||
41 | /* Register offset between PHYs in PHY control space */ | ||
42 | #define SATA_PHY_CTRL_REG_28NM_SPACE_SIZE 0x8 | ||
43 | |||
44 | enum brcm_sata_phy_version { | ||
45 | BRCM_SATA_PHY_STB_28NM, | ||
46 | BRCM_SATA_PHY_STB_40NM, | ||
47 | BRCM_SATA_PHY_IPROC_NS2, | ||
48 | }; | ||
49 | |||
50 | struct brcm_sata_port { | ||
51 | int portnum; | ||
52 | struct phy *phy; | ||
53 | struct brcm_sata_phy *phy_priv; | ||
54 | bool ssc_en; | ||
55 | }; | ||
56 | |||
57 | struct brcm_sata_phy { | ||
58 | struct device *dev; | ||
59 | void __iomem *phy_base; | ||
60 | void __iomem *ctrl_base; | ||
61 | enum brcm_sata_phy_version version; | ||
62 | |||
63 | struct brcm_sata_port phys[MAX_PORTS]; | ||
64 | }; | ||
65 | |||
66 | enum sata_phy_regs { | ||
67 | BLOCK0_REG_BANK = 0x000, | ||
68 | BLOCK0_XGXSSTATUS = 0x81, | ||
69 | BLOCK0_XGXSSTATUS_PLL_LOCK = BIT(12), | ||
70 | BLOCK0_SPARE = 0x8d, | ||
71 | BLOCK0_SPARE_OOB_CLK_SEL_MASK = 0x3, | ||
72 | BLOCK0_SPARE_OOB_CLK_SEL_REFBY2 = 0x1, | ||
73 | |||
74 | PLL_REG_BANK_0 = 0x050, | ||
75 | PLL_REG_BANK_0_PLLCONTROL_0 = 0x81, | ||
76 | |||
77 | PLL1_REG_BANK = 0x060, | ||
78 | PLL1_ACTRL2 = 0x82, | ||
79 | PLL1_ACTRL3 = 0x83, | ||
80 | PLL1_ACTRL4 = 0x84, | ||
81 | |||
82 | OOB_REG_BANK = 0x150, | ||
83 | OOB_CTRL1 = 0x80, | ||
84 | OOB_CTRL1_BURST_MAX_MASK = 0xf, | ||
85 | OOB_CTRL1_BURST_MAX_SHIFT = 12, | ||
86 | OOB_CTRL1_BURST_MIN_MASK = 0xf, | ||
87 | OOB_CTRL1_BURST_MIN_SHIFT = 8, | ||
88 | OOB_CTRL1_WAKE_IDLE_MAX_MASK = 0xf, | ||
89 | OOB_CTRL1_WAKE_IDLE_MAX_SHIFT = 4, | ||
90 | OOB_CTRL1_WAKE_IDLE_MIN_MASK = 0xf, | ||
91 | OOB_CTRL1_WAKE_IDLE_MIN_SHIFT = 0, | ||
92 | OOB_CTRL2 = 0x81, | ||
93 | OOB_CTRL2_SEL_ENA_SHIFT = 15, | ||
94 | OOB_CTRL2_SEL_ENA_RC_SHIFT = 14, | ||
95 | OOB_CTRL2_RESET_IDLE_MAX_MASK = 0x3f, | ||
96 | OOB_CTRL2_RESET_IDLE_MAX_SHIFT = 8, | ||
97 | OOB_CTRL2_BURST_CNT_MASK = 0x3, | ||
98 | OOB_CTRL2_BURST_CNT_SHIFT = 6, | ||
99 | OOB_CTRL2_RESET_IDLE_MIN_MASK = 0x3f, | ||
100 | OOB_CTRL2_RESET_IDLE_MIN_SHIFT = 0, | ||
101 | |||
102 | TXPMD_REG_BANK = 0x1a0, | ||
103 | TXPMD_CONTROL1 = 0x81, | ||
104 | TXPMD_CONTROL1_TX_SSC_EN_FRC = BIT(0), | ||
105 | TXPMD_CONTROL1_TX_SSC_EN_FRC_VAL = BIT(1), | ||
106 | TXPMD_TX_FREQ_CTRL_CONTROL1 = 0x82, | ||
107 | TXPMD_TX_FREQ_CTRL_CONTROL2 = 0x83, | ||
108 | TXPMD_TX_FREQ_CTRL_CONTROL2_FMIN_MASK = 0x3ff, | ||
109 | TXPMD_TX_FREQ_CTRL_CONTROL3 = 0x84, | ||
110 | TXPMD_TX_FREQ_CTRL_CONTROL3_FMAX_MASK = 0x3ff, | ||
111 | }; | ||
112 | |||
113 | enum sata_phy_ctrl_regs { | ||
114 | PHY_CTRL_1 = 0x0, | ||
115 | PHY_CTRL_1_RESET = BIT(0), | ||
116 | }; | ||
117 | |||
118 | static inline void __iomem *brcm_sata_pcb_base(struct brcm_sata_port *port) | ||
119 | { | ||
120 | struct brcm_sata_phy *priv = port->phy_priv; | ||
121 | u32 size = 0; | ||
122 | |||
123 | switch (priv->version) { | ||
124 | case BRCM_SATA_PHY_STB_28NM: | ||
125 | case BRCM_SATA_PHY_IPROC_NS2: | ||
126 | size = SATA_PCB_REG_28NM_SPACE_SIZE; | ||
127 | break; | ||
128 | case BRCM_SATA_PHY_STB_40NM: | ||
129 | size = SATA_PCB_REG_40NM_SPACE_SIZE; | ||
130 | break; | ||
131 | default: | ||
132 | dev_err(priv->dev, "invalid phy version\n"); | ||
133 | break; | ||
134 | }; | ||
135 | |||
136 | return priv->phy_base + (port->portnum * size); | ||
137 | } | ||
138 | |||
139 | static inline void __iomem *brcm_sata_ctrl_base(struct brcm_sata_port *port) | ||
140 | { | ||
141 | struct brcm_sata_phy *priv = port->phy_priv; | ||
142 | u32 size = 0; | ||
143 | |||
144 | switch (priv->version) { | ||
145 | case BRCM_SATA_PHY_IPROC_NS2: | ||
146 | size = SATA_PHY_CTRL_REG_28NM_SPACE_SIZE; | ||
147 | break; | ||
148 | default: | ||
149 | dev_err(priv->dev, "invalid phy version\n"); | ||
150 | break; | ||
151 | }; | ||
152 | |||
153 | return priv->ctrl_base + (port->portnum * size); | ||
154 | } | ||
155 | |||
156 | static void brcm_sata_phy_wr(void __iomem *pcb_base, u32 bank, | ||
157 | u32 ofs, u32 msk, u32 value) | ||
158 | { | ||
159 | u32 tmp; | ||
160 | |||
161 | writel(bank, pcb_base + SATA_PCB_BANK_OFFSET); | ||
162 | tmp = readl(pcb_base + SATA_PCB_REG_OFFSET(ofs)); | ||
163 | tmp = (tmp & msk) | value; | ||
164 | writel(tmp, pcb_base + SATA_PCB_REG_OFFSET(ofs)); | ||
165 | } | ||
166 | |||
167 | static u32 brcm_sata_phy_rd(void __iomem *pcb_base, u32 bank, u32 ofs) | ||
168 | { | ||
169 | writel(bank, pcb_base + SATA_PCB_BANK_OFFSET); | ||
170 | return readl(pcb_base + SATA_PCB_REG_OFFSET(ofs)); | ||
171 | } | ||
172 | |||
173 | /* These defaults were characterized by H/W group */ | ||
174 | #define STB_FMIN_VAL_DEFAULT 0x3df | ||
175 | #define STB_FMAX_VAL_DEFAULT 0x3df | ||
176 | #define STB_FMAX_VAL_SSC 0x83 | ||
177 | |||
178 | static int brcm_stb_sata_init(struct brcm_sata_port *port) | ||
179 | { | ||
180 | void __iomem *base = brcm_sata_pcb_base(port); | ||
181 | struct brcm_sata_phy *priv = port->phy_priv; | ||
182 | u32 tmp; | ||
183 | |||
184 | /* override the TX spread spectrum setting */ | ||
185 | tmp = TXPMD_CONTROL1_TX_SSC_EN_FRC_VAL | TXPMD_CONTROL1_TX_SSC_EN_FRC; | ||
186 | brcm_sata_phy_wr(base, TXPMD_REG_BANK, TXPMD_CONTROL1, ~tmp, tmp); | ||
187 | |||
188 | /* set fixed min freq */ | ||
189 | brcm_sata_phy_wr(base, TXPMD_REG_BANK, TXPMD_TX_FREQ_CTRL_CONTROL2, | ||
190 | ~TXPMD_TX_FREQ_CTRL_CONTROL2_FMIN_MASK, | ||
191 | STB_FMIN_VAL_DEFAULT); | ||
192 | |||
193 | /* set fixed max freq depending on SSC config */ | ||
194 | if (port->ssc_en) { | ||
195 | dev_info(priv->dev, "enabling SSC on port%d\n", port->portnum); | ||
196 | tmp = STB_FMAX_VAL_SSC; | ||
197 | } else { | ||
198 | tmp = STB_FMAX_VAL_DEFAULT; | ||
199 | } | ||
200 | |||
201 | brcm_sata_phy_wr(base, TXPMD_REG_BANK, TXPMD_TX_FREQ_CTRL_CONTROL3, | ||
202 | ~TXPMD_TX_FREQ_CTRL_CONTROL3_FMAX_MASK, tmp); | ||
203 | |||
204 | return 0; | ||
205 | } | ||
206 | |||
207 | /* NS2 SATA PLL1 defaults were characterized by H/W group */ | ||
208 | #define NS2_PLL1_ACTRL2_MAGIC 0x1df8 | ||
209 | #define NS2_PLL1_ACTRL3_MAGIC 0x2b00 | ||
210 | #define NS2_PLL1_ACTRL4_MAGIC 0x8824 | ||
211 | |||
212 | static int brcm_ns2_sata_init(struct brcm_sata_port *port) | ||
213 | { | ||
214 | int try; | ||
215 | unsigned int val; | ||
216 | void __iomem *base = brcm_sata_pcb_base(port); | ||
217 | void __iomem *ctrl_base = brcm_sata_ctrl_base(port); | ||
218 | struct device *dev = port->phy_priv->dev; | ||
219 | |||
220 | /* Configure OOB control */ | ||
221 | val = 0x0; | ||
222 | val |= (0xc << OOB_CTRL1_BURST_MAX_SHIFT); | ||
223 | val |= (0x4 << OOB_CTRL1_BURST_MIN_SHIFT); | ||
224 | val |= (0x9 << OOB_CTRL1_WAKE_IDLE_MAX_SHIFT); | ||
225 | val |= (0x3 << OOB_CTRL1_WAKE_IDLE_MIN_SHIFT); | ||
226 | brcm_sata_phy_wr(base, OOB_REG_BANK, OOB_CTRL1, 0x0, val); | ||
227 | val = 0x0; | ||
228 | val |= (0x1b << OOB_CTRL2_RESET_IDLE_MAX_SHIFT); | ||
229 | val |= (0x2 << OOB_CTRL2_BURST_CNT_SHIFT); | ||
230 | val |= (0x9 << OOB_CTRL2_RESET_IDLE_MIN_SHIFT); | ||
231 | brcm_sata_phy_wr(base, OOB_REG_BANK, OOB_CTRL2, 0x0, val); | ||
232 | |||
233 | /* Configure PHY PLL register bank 1 */ | ||
234 | val = NS2_PLL1_ACTRL2_MAGIC; | ||
235 | brcm_sata_phy_wr(base, PLL1_REG_BANK, PLL1_ACTRL2, 0x0, val); | ||
236 | val = NS2_PLL1_ACTRL3_MAGIC; | ||
237 | brcm_sata_phy_wr(base, PLL1_REG_BANK, PLL1_ACTRL3, 0x0, val); | ||
238 | val = NS2_PLL1_ACTRL4_MAGIC; | ||
239 | brcm_sata_phy_wr(base, PLL1_REG_BANK, PLL1_ACTRL4, 0x0, val); | ||
240 | |||
241 | /* Configure PHY BLOCK0 register bank */ | ||
242 | /* Set oob_clk_sel to refclk/2 */ | ||
243 | brcm_sata_phy_wr(base, BLOCK0_REG_BANK, BLOCK0_SPARE, | ||
244 | ~BLOCK0_SPARE_OOB_CLK_SEL_MASK, | ||
245 | BLOCK0_SPARE_OOB_CLK_SEL_REFBY2); | ||
246 | |||
247 | /* Strobe PHY reset using PHY control register */ | ||
248 | writel(PHY_CTRL_1_RESET, ctrl_base + PHY_CTRL_1); | ||
249 | mdelay(1); | ||
250 | writel(0x0, ctrl_base + PHY_CTRL_1); | ||
251 | mdelay(1); | ||
252 | |||
253 | /* Wait for PHY PLL lock by polling pll_lock bit */ | ||
254 | try = 50; | ||
255 | while (try) { | ||
256 | val = brcm_sata_phy_rd(base, BLOCK0_REG_BANK, | ||
257 | BLOCK0_XGXSSTATUS); | ||
258 | if (val & BLOCK0_XGXSSTATUS_PLL_LOCK) | ||
259 | break; | ||
260 | msleep(20); | ||
261 | try--; | ||
262 | } | ||
263 | if (!try) { | ||
264 | /* PLL did not lock; give up */ | ||
265 | dev_err(dev, "port%d PLL did not lock\n", port->portnum); | ||
266 | return -ETIMEDOUT; | ||
267 | } | ||
268 | |||
269 | dev_dbg(dev, "port%d initialized\n", port->portnum); | ||
270 | |||
271 | return 0; | ||
272 | } | ||
273 | |||
274 | static int brcm_sata_phy_init(struct phy *phy) | ||
275 | { | ||
276 | int rc; | ||
277 | struct brcm_sata_port *port = phy_get_drvdata(phy); | ||
278 | |||
279 | switch (port->phy_priv->version) { | ||
280 | case BRCM_SATA_PHY_STB_28NM: | ||
281 | case BRCM_SATA_PHY_STB_40NM: | ||
282 | rc = brcm_stb_sata_init(port); | ||
283 | break; | ||
284 | case BRCM_SATA_PHY_IPROC_NS2: | ||
285 | rc = brcm_ns2_sata_init(port); | ||
286 | break; | ||
287 | default: | ||
288 | rc = -ENODEV; | ||
289 | }; | ||
290 | |||
291 | return 0; | ||
292 | } | ||
293 | |||
294 | static const struct phy_ops phy_ops = { | ||
295 | .init = brcm_sata_phy_init, | ||
296 | .owner = THIS_MODULE, | ||
297 | }; | ||
298 | |||
299 | static const struct of_device_id brcm_sata_phy_of_match[] = { | ||
300 | { .compatible = "brcm,bcm7445-sata-phy", | ||
301 | .data = (void *)BRCM_SATA_PHY_STB_28NM }, | ||
302 | { .compatible = "brcm,bcm7425-sata-phy", | ||
303 | .data = (void *)BRCM_SATA_PHY_STB_40NM }, | ||
304 | { .compatible = "brcm,iproc-ns2-sata-phy", | ||
305 | .data = (void *)BRCM_SATA_PHY_IPROC_NS2 }, | ||
306 | {}, | ||
307 | }; | ||
308 | MODULE_DEVICE_TABLE(of, brcm_sata_phy_of_match); | ||
309 | |||
310 | static int brcm_sata_phy_probe(struct platform_device *pdev) | ||
311 | { | ||
312 | struct device *dev = &pdev->dev; | ||
313 | struct device_node *dn = dev->of_node, *child; | ||
314 | const struct of_device_id *of_id; | ||
315 | struct brcm_sata_phy *priv; | ||
316 | struct resource *res; | ||
317 | struct phy_provider *provider; | ||
318 | int ret, count = 0; | ||
319 | |||
320 | if (of_get_child_count(dn) == 0) | ||
321 | return -ENODEV; | ||
322 | |||
323 | priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); | ||
324 | if (!priv) | ||
325 | return -ENOMEM; | ||
326 | dev_set_drvdata(dev, priv); | ||
327 | priv->dev = dev; | ||
328 | |||
329 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "phy"); | ||
330 | priv->phy_base = devm_ioremap_resource(dev, res); | ||
331 | if (IS_ERR(priv->phy_base)) | ||
332 | return PTR_ERR(priv->phy_base); | ||
333 | |||
334 | of_id = of_match_node(brcm_sata_phy_of_match, dn); | ||
335 | if (of_id) | ||
336 | priv->version = (enum brcm_sata_phy_version)of_id->data; | ||
337 | else | ||
338 | priv->version = BRCM_SATA_PHY_STB_28NM; | ||
339 | |||
340 | if (priv->version == BRCM_SATA_PHY_IPROC_NS2) { | ||
341 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, | ||
342 | "phy-ctrl"); | ||
343 | priv->ctrl_base = devm_ioremap_resource(dev, res); | ||
344 | if (IS_ERR(priv->ctrl_base)) | ||
345 | return PTR_ERR(priv->ctrl_base); | ||
346 | } | ||
347 | |||
348 | for_each_available_child_of_node(dn, child) { | ||
349 | unsigned int id; | ||
350 | struct brcm_sata_port *port; | ||
351 | |||
352 | if (of_property_read_u32(child, "reg", &id)) { | ||
353 | dev_err(dev, "missing reg property in node %s\n", | ||
354 | child->name); | ||
355 | ret = -EINVAL; | ||
356 | goto put_child; | ||
357 | } | ||
358 | |||
359 | if (id >= MAX_PORTS) { | ||
360 | dev_err(dev, "invalid reg: %u\n", id); | ||
361 | ret = -EINVAL; | ||
362 | goto put_child; | ||
363 | } | ||
364 | if (priv->phys[id].phy) { | ||
365 | dev_err(dev, "already registered port %u\n", id); | ||
366 | ret = -EINVAL; | ||
367 | goto put_child; | ||
368 | } | ||
369 | |||
370 | port = &priv->phys[id]; | ||
371 | port->portnum = id; | ||
372 | port->phy_priv = priv; | ||
373 | port->phy = devm_phy_create(dev, child, &phy_ops); | ||
374 | port->ssc_en = of_property_read_bool(child, "brcm,enable-ssc"); | ||
375 | if (IS_ERR(port->phy)) { | ||
376 | dev_err(dev, "failed to create PHY\n"); | ||
377 | ret = PTR_ERR(port->phy); | ||
378 | goto put_child; | ||
379 | } | ||
380 | |||
381 | phy_set_drvdata(port->phy, port); | ||
382 | count++; | ||
383 | } | ||
384 | |||
385 | provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate); | ||
386 | if (IS_ERR(provider)) { | ||
387 | dev_err(dev, "could not register PHY provider\n"); | ||
388 | return PTR_ERR(provider); | ||
389 | } | ||
390 | |||
391 | dev_info(dev, "registered %d port(s)\n", count); | ||
392 | |||
393 | return 0; | ||
394 | put_child: | ||
395 | of_node_put(child); | ||
396 | return ret; | ||
397 | } | ||
398 | |||
399 | static struct platform_driver brcm_sata_phy_driver = { | ||
400 | .probe = brcm_sata_phy_probe, | ||
401 | .driver = { | ||
402 | .of_match_table = brcm_sata_phy_of_match, | ||
403 | .name = "brcm-sata-phy", | ||
404 | } | ||
405 | }; | ||
406 | module_platform_driver(brcm_sata_phy_driver); | ||
407 | |||
408 | MODULE_DESCRIPTION("Broadcom SATA PHY driver"); | ||
409 | MODULE_LICENSE("GPL"); | ||
410 | MODULE_AUTHOR("Marc Carino"); | ||
411 | MODULE_AUTHOR("Brian Norris"); | ||
412 | MODULE_ALIAS("platform:phy-brcm-sata"); | ||
diff --git a/drivers/phy/phy-brcmstb-sata.c b/drivers/phy/phy-brcmstb-sata.c deleted file mode 100644 index a23172ff40e3..000000000000 --- a/drivers/phy/phy-brcmstb-sata.c +++ /dev/null | |||
@@ -1,250 +0,0 @@ | |||
1 | /* | ||
2 | * Broadcom SATA3 AHCI Controller PHY Driver | ||
3 | * | ||
4 | * Copyright © 2009-2015 Broadcom Corporation | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2, or (at your option) | ||
9 | * any later version. | ||
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 | |||
17 | #include <linux/device.h> | ||
18 | #include <linux/init.h> | ||
19 | #include <linux/interrupt.h> | ||
20 | #include <linux/io.h> | ||
21 | #include <linux/kernel.h> | ||
22 | #include <linux/module.h> | ||
23 | #include <linux/of.h> | ||
24 | #include <linux/phy/phy.h> | ||
25 | #include <linux/platform_device.h> | ||
26 | |||
27 | #define SATA_MDIO_BANK_OFFSET 0x23c | ||
28 | #define SATA_MDIO_REG_OFFSET(ofs) ((ofs) * 4) | ||
29 | |||
30 | #define MAX_PORTS 2 | ||
31 | |||
32 | /* Register offset between PHYs in PCB space */ | ||
33 | #define SATA_MDIO_REG_28NM_SPACE_SIZE 0x1000 | ||
34 | |||
35 | /* The older SATA PHY registers duplicated per port registers within the map, | ||
36 | * rather than having a separate map per port. | ||
37 | */ | ||
38 | #define SATA_MDIO_REG_40NM_SPACE_SIZE 0x10 | ||
39 | |||
40 | enum brcm_sata_phy_version { | ||
41 | BRCM_SATA_PHY_28NM, | ||
42 | BRCM_SATA_PHY_40NM, | ||
43 | }; | ||
44 | |||
45 | struct brcm_sata_port { | ||
46 | int portnum; | ||
47 | struct phy *phy; | ||
48 | struct brcm_sata_phy *phy_priv; | ||
49 | bool ssc_en; | ||
50 | }; | ||
51 | |||
52 | struct brcm_sata_phy { | ||
53 | struct device *dev; | ||
54 | void __iomem *phy_base; | ||
55 | enum brcm_sata_phy_version version; | ||
56 | |||
57 | struct brcm_sata_port phys[MAX_PORTS]; | ||
58 | }; | ||
59 | |||
60 | enum sata_mdio_phy_regs { | ||
61 | PLL_REG_BANK_0 = 0x50, | ||
62 | PLL_REG_BANK_0_PLLCONTROL_0 = 0x81, | ||
63 | |||
64 | TXPMD_REG_BANK = 0x1a0, | ||
65 | TXPMD_CONTROL1 = 0x81, | ||
66 | TXPMD_CONTROL1_TX_SSC_EN_FRC = BIT(0), | ||
67 | TXPMD_CONTROL1_TX_SSC_EN_FRC_VAL = BIT(1), | ||
68 | TXPMD_TX_FREQ_CTRL_CONTROL1 = 0x82, | ||
69 | TXPMD_TX_FREQ_CTRL_CONTROL2 = 0x83, | ||
70 | TXPMD_TX_FREQ_CTRL_CONTROL2_FMIN_MASK = 0x3ff, | ||
71 | TXPMD_TX_FREQ_CTRL_CONTROL3 = 0x84, | ||
72 | TXPMD_TX_FREQ_CTRL_CONTROL3_FMAX_MASK = 0x3ff, | ||
73 | }; | ||
74 | |||
75 | static inline void __iomem *brcm_sata_phy_base(struct brcm_sata_port *port) | ||
76 | { | ||
77 | struct brcm_sata_phy *priv = port->phy_priv; | ||
78 | u32 offset = 0; | ||
79 | |||
80 | if (priv->version == BRCM_SATA_PHY_28NM) | ||
81 | offset = SATA_MDIO_REG_28NM_SPACE_SIZE; | ||
82 | else if (priv->version == BRCM_SATA_PHY_40NM) | ||
83 | offset = SATA_MDIO_REG_40NM_SPACE_SIZE; | ||
84 | else | ||
85 | dev_err(priv->dev, "invalid phy version\n"); | ||
86 | |||
87 | return priv->phy_base + (port->portnum * offset); | ||
88 | } | ||
89 | |||
90 | static void brcm_sata_mdio_wr(void __iomem *addr, u32 bank, u32 ofs, | ||
91 | u32 msk, u32 value) | ||
92 | { | ||
93 | u32 tmp; | ||
94 | |||
95 | writel(bank, addr + SATA_MDIO_BANK_OFFSET); | ||
96 | tmp = readl(addr + SATA_MDIO_REG_OFFSET(ofs)); | ||
97 | tmp = (tmp & msk) | value; | ||
98 | writel(tmp, addr + SATA_MDIO_REG_OFFSET(ofs)); | ||
99 | } | ||
100 | |||
101 | /* These defaults were characterized by H/W group */ | ||
102 | #define FMIN_VAL_DEFAULT 0x3df | ||
103 | #define FMAX_VAL_DEFAULT 0x3df | ||
104 | #define FMAX_VAL_SSC 0x83 | ||
105 | |||
106 | static void brcm_sata_cfg_ssc(struct brcm_sata_port *port) | ||
107 | { | ||
108 | void __iomem *base = brcm_sata_phy_base(port); | ||
109 | struct brcm_sata_phy *priv = port->phy_priv; | ||
110 | u32 tmp; | ||
111 | |||
112 | /* override the TX spread spectrum setting */ | ||
113 | tmp = TXPMD_CONTROL1_TX_SSC_EN_FRC_VAL | TXPMD_CONTROL1_TX_SSC_EN_FRC; | ||
114 | brcm_sata_mdio_wr(base, TXPMD_REG_BANK, TXPMD_CONTROL1, ~tmp, tmp); | ||
115 | |||
116 | /* set fixed min freq */ | ||
117 | brcm_sata_mdio_wr(base, TXPMD_REG_BANK, TXPMD_TX_FREQ_CTRL_CONTROL2, | ||
118 | ~TXPMD_TX_FREQ_CTRL_CONTROL2_FMIN_MASK, | ||
119 | FMIN_VAL_DEFAULT); | ||
120 | |||
121 | /* set fixed max freq depending on SSC config */ | ||
122 | if (port->ssc_en) { | ||
123 | dev_info(priv->dev, "enabling SSC on port %d\n", port->portnum); | ||
124 | tmp = FMAX_VAL_SSC; | ||
125 | } else { | ||
126 | tmp = FMAX_VAL_DEFAULT; | ||
127 | } | ||
128 | |||
129 | brcm_sata_mdio_wr(base, TXPMD_REG_BANK, TXPMD_TX_FREQ_CTRL_CONTROL3, | ||
130 | ~TXPMD_TX_FREQ_CTRL_CONTROL3_FMAX_MASK, tmp); | ||
131 | } | ||
132 | |||
133 | static int brcm_sata_phy_init(struct phy *phy) | ||
134 | { | ||
135 | struct brcm_sata_port *port = phy_get_drvdata(phy); | ||
136 | |||
137 | brcm_sata_cfg_ssc(port); | ||
138 | |||
139 | return 0; | ||
140 | } | ||
141 | |||
142 | static const struct phy_ops phy_ops = { | ||
143 | .init = brcm_sata_phy_init, | ||
144 | .owner = THIS_MODULE, | ||
145 | }; | ||
146 | |||
147 | static const struct of_device_id brcm_sata_phy_of_match[] = { | ||
148 | { .compatible = "brcm,bcm7445-sata-phy", | ||
149 | .data = (void *)BRCM_SATA_PHY_28NM }, | ||
150 | { .compatible = "brcm,bcm7425-sata-phy", | ||
151 | .data = (void *)BRCM_SATA_PHY_40NM }, | ||
152 | {}, | ||
153 | }; | ||
154 | MODULE_DEVICE_TABLE(of, brcm_sata_phy_of_match); | ||
155 | |||
156 | static int brcm_sata_phy_probe(struct platform_device *pdev) | ||
157 | { | ||
158 | struct device *dev = &pdev->dev; | ||
159 | struct device_node *dn = dev->of_node, *child; | ||
160 | const struct of_device_id *of_id; | ||
161 | struct brcm_sata_phy *priv; | ||
162 | struct resource *res; | ||
163 | struct phy_provider *provider; | ||
164 | int ret, count = 0; | ||
165 | |||
166 | if (of_get_child_count(dn) == 0) | ||
167 | return -ENODEV; | ||
168 | |||
169 | priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); | ||
170 | if (!priv) | ||
171 | return -ENOMEM; | ||
172 | dev_set_drvdata(dev, priv); | ||
173 | priv->dev = dev; | ||
174 | |||
175 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "phy"); | ||
176 | priv->phy_base = devm_ioremap_resource(dev, res); | ||
177 | if (IS_ERR(priv->phy_base)) | ||
178 | return PTR_ERR(priv->phy_base); | ||
179 | |||
180 | of_id = of_match_node(brcm_sata_phy_of_match, dn); | ||
181 | if (of_id) | ||
182 | priv->version = (enum brcm_sata_phy_version)of_id->data; | ||
183 | else | ||
184 | priv->version = BRCM_SATA_PHY_28NM; | ||
185 | |||
186 | for_each_available_child_of_node(dn, child) { | ||
187 | unsigned int id; | ||
188 | struct brcm_sata_port *port; | ||
189 | |||
190 | if (of_property_read_u32(child, "reg", &id)) { | ||
191 | dev_err(dev, "missing reg property in node %s\n", | ||
192 | child->name); | ||
193 | ret = -EINVAL; | ||
194 | goto put_child; | ||
195 | } | ||
196 | |||
197 | if (id >= MAX_PORTS) { | ||
198 | dev_err(dev, "invalid reg: %u\n", id); | ||
199 | ret = -EINVAL; | ||
200 | goto put_child; | ||
201 | } | ||
202 | if (priv->phys[id].phy) { | ||
203 | dev_err(dev, "already registered port %u\n", id); | ||
204 | ret = -EINVAL; | ||
205 | goto put_child; | ||
206 | } | ||
207 | |||
208 | port = &priv->phys[id]; | ||
209 | port->portnum = id; | ||
210 | port->phy_priv = priv; | ||
211 | port->phy = devm_phy_create(dev, child, &phy_ops); | ||
212 | port->ssc_en = of_property_read_bool(child, "brcm,enable-ssc"); | ||
213 | if (IS_ERR(port->phy)) { | ||
214 | dev_err(dev, "failed to create PHY\n"); | ||
215 | ret = PTR_ERR(port->phy); | ||
216 | goto put_child; | ||
217 | } | ||
218 | |||
219 | phy_set_drvdata(port->phy, port); | ||
220 | count++; | ||
221 | } | ||
222 | |||
223 | provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate); | ||
224 | if (IS_ERR(provider)) { | ||
225 | dev_err(dev, "could not register PHY provider\n"); | ||
226 | return PTR_ERR(provider); | ||
227 | } | ||
228 | |||
229 | dev_info(dev, "registered %d port(s)\n", count); | ||
230 | |||
231 | return 0; | ||
232 | put_child: | ||
233 | of_node_put(child); | ||
234 | return ret; | ||
235 | } | ||
236 | |||
237 | static struct platform_driver brcm_sata_phy_driver = { | ||
238 | .probe = brcm_sata_phy_probe, | ||
239 | .driver = { | ||
240 | .of_match_table = brcm_sata_phy_of_match, | ||
241 | .name = "brcmstb-sata-phy", | ||
242 | } | ||
243 | }; | ||
244 | module_platform_driver(brcm_sata_phy_driver); | ||
245 | |||
246 | MODULE_DESCRIPTION("Broadcom STB SATA PHY driver"); | ||
247 | MODULE_LICENSE("GPL"); | ||
248 | MODULE_AUTHOR("Marc Carino"); | ||
249 | MODULE_AUTHOR("Brian Norris"); | ||
250 | MODULE_ALIAS("platform:phy-brcmstb-sata"); | ||
diff --git a/drivers/phy/phy-exynos-mipi-video.c b/drivers/phy/phy-exynos-mipi-video.c index 2a54caba93b4..cc093ebfda94 100644 --- a/drivers/phy/phy-exynos-mipi-video.c +++ b/drivers/phy/phy-exynos-mipi-video.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Samsung S5P/EXYNOS SoC series MIPI CSIS/DSIM DPHY driver | 2 | * Samsung S5P/EXYNOS SoC series MIPI CSIS/DSIM DPHY driver |
3 | * | 3 | * |
4 | * Copyright (C) 2013 Samsung Electronics Co., Ltd. | 4 | * Copyright (C) 2013,2016 Samsung Electronics Co., Ltd. |
5 | * Author: Sylwester Nawrocki <s.nawrocki@samsung.com> | 5 | * Author: Sylwester Nawrocki <s.nawrocki@samsung.com> |
6 | * | 6 | * |
7 | * This program is free software; you can redistribute it and/or modify | 7 | * This program is free software; you can redistribute it and/or modify |
@@ -13,96 +13,276 @@ | |||
13 | #include <linux/io.h> | 13 | #include <linux/io.h> |
14 | #include <linux/kernel.h> | 14 | #include <linux/kernel.h> |
15 | #include <linux/mfd/syscon/exynos4-pmu.h> | 15 | #include <linux/mfd/syscon/exynos4-pmu.h> |
16 | #include <linux/mfd/syscon/exynos5-pmu.h> | ||
16 | #include <linux/module.h> | 17 | #include <linux/module.h> |
17 | #include <linux/of.h> | 18 | #include <linux/of.h> |
18 | #include <linux/of_address.h> | 19 | #include <linux/of_address.h> |
20 | #include <linux/of_device.h> | ||
19 | #include <linux/phy/phy.h> | 21 | #include <linux/phy/phy.h> |
20 | #include <linux/platform_device.h> | ||
21 | #include <linux/regmap.h> | 22 | #include <linux/regmap.h> |
22 | #include <linux/spinlock.h> | 23 | #include <linux/spinlock.h> |
23 | #include <linux/mfd/syscon.h> | 24 | #include <linux/mfd/syscon.h> |
24 | 25 | ||
25 | /* MIPI_PHYn_CONTROL reg. offset (for base address from ioremap): n = 0..1 */ | ||
26 | #define EXYNOS_MIPI_PHY_CONTROL(n) ((n) * 4) | ||
27 | |||
28 | enum exynos_mipi_phy_id { | 26 | enum exynos_mipi_phy_id { |
27 | EXYNOS_MIPI_PHY_ID_NONE = -1, | ||
29 | EXYNOS_MIPI_PHY_ID_CSIS0, | 28 | EXYNOS_MIPI_PHY_ID_CSIS0, |
30 | EXYNOS_MIPI_PHY_ID_DSIM0, | 29 | EXYNOS_MIPI_PHY_ID_DSIM0, |
31 | EXYNOS_MIPI_PHY_ID_CSIS1, | 30 | EXYNOS_MIPI_PHY_ID_CSIS1, |
32 | EXYNOS_MIPI_PHY_ID_DSIM1, | 31 | EXYNOS_MIPI_PHY_ID_DSIM1, |
32 | EXYNOS_MIPI_PHY_ID_CSIS2, | ||
33 | EXYNOS_MIPI_PHYS_NUM | 33 | EXYNOS_MIPI_PHYS_NUM |
34 | }; | 34 | }; |
35 | 35 | ||
36 | #define is_mipi_dsim_phy_id(id) \ | 36 | enum exynos_mipi_phy_regmap_id { |
37 | ((id) == EXYNOS_MIPI_PHY_ID_DSIM0 || (id) == EXYNOS_MIPI_PHY_ID_DSIM1) | 37 | EXYNOS_MIPI_REGMAP_PMU, |
38 | EXYNOS_MIPI_REGMAP_DISP, | ||
39 | EXYNOS_MIPI_REGMAP_CAM0, | ||
40 | EXYNOS_MIPI_REGMAP_CAM1, | ||
41 | EXYNOS_MIPI_REGMAPS_NUM | ||
42 | }; | ||
43 | |||
44 | struct mipi_phy_device_desc { | ||
45 | int num_phys; | ||
46 | int num_regmaps; | ||
47 | const char *regmap_names[EXYNOS_MIPI_REGMAPS_NUM]; | ||
48 | struct exynos_mipi_phy_desc { | ||
49 | enum exynos_mipi_phy_id coupled_phy_id; | ||
50 | u32 enable_val; | ||
51 | unsigned int enable_reg; | ||
52 | enum exynos_mipi_phy_regmap_id enable_map; | ||
53 | u32 resetn_val; | ||
54 | unsigned int resetn_reg; | ||
55 | enum exynos_mipi_phy_regmap_id resetn_map; | ||
56 | } phys[EXYNOS_MIPI_PHYS_NUM]; | ||
57 | }; | ||
58 | |||
59 | static const struct mipi_phy_device_desc s5pv210_mipi_phy = { | ||
60 | .num_regmaps = 1, | ||
61 | .regmap_names = {"syscon"}, | ||
62 | .num_phys = 4, | ||
63 | .phys = { | ||
64 | { | ||
65 | /* EXYNOS_MIPI_PHY_ID_CSIS0 */ | ||
66 | .coupled_phy_id = EXYNOS_MIPI_PHY_ID_DSIM0, | ||
67 | .enable_val = EXYNOS4_MIPI_PHY_ENABLE, | ||
68 | .enable_reg = EXYNOS4_MIPI_PHY_CONTROL(0), | ||
69 | .enable_map = EXYNOS_MIPI_REGMAP_PMU, | ||
70 | .resetn_val = EXYNOS4_MIPI_PHY_SRESETN, | ||
71 | .resetn_reg = EXYNOS4_MIPI_PHY_CONTROL(0), | ||
72 | .resetn_map = EXYNOS_MIPI_REGMAP_PMU, | ||
73 | }, { | ||
74 | /* EXYNOS_MIPI_PHY_ID_DSIM0 */ | ||
75 | .coupled_phy_id = EXYNOS_MIPI_PHY_ID_CSIS0, | ||
76 | .enable_val = EXYNOS4_MIPI_PHY_ENABLE, | ||
77 | .enable_reg = EXYNOS4_MIPI_PHY_CONTROL(0), | ||
78 | .enable_map = EXYNOS_MIPI_REGMAP_PMU, | ||
79 | .resetn_val = EXYNOS4_MIPI_PHY_MRESETN, | ||
80 | .resetn_reg = EXYNOS4_MIPI_PHY_CONTROL(0), | ||
81 | .resetn_map = EXYNOS_MIPI_REGMAP_PMU, | ||
82 | }, { | ||
83 | /* EXYNOS_MIPI_PHY_ID_CSIS1 */ | ||
84 | .coupled_phy_id = EXYNOS_MIPI_PHY_ID_DSIM1, | ||
85 | .enable_val = EXYNOS4_MIPI_PHY_ENABLE, | ||
86 | .enable_reg = EXYNOS4_MIPI_PHY_CONTROL(1), | ||
87 | .enable_map = EXYNOS_MIPI_REGMAP_PMU, | ||
88 | .resetn_val = EXYNOS4_MIPI_PHY_SRESETN, | ||
89 | .resetn_reg = EXYNOS4_MIPI_PHY_CONTROL(1), | ||
90 | .resetn_map = EXYNOS_MIPI_REGMAP_PMU, | ||
91 | }, { | ||
92 | /* EXYNOS_MIPI_PHY_ID_DSIM1 */ | ||
93 | .coupled_phy_id = EXYNOS_MIPI_PHY_ID_CSIS1, | ||
94 | .enable_val = EXYNOS4_MIPI_PHY_ENABLE, | ||
95 | .enable_reg = EXYNOS4_MIPI_PHY_CONTROL(1), | ||
96 | .enable_map = EXYNOS_MIPI_REGMAP_PMU, | ||
97 | .resetn_val = EXYNOS4_MIPI_PHY_MRESETN, | ||
98 | .resetn_reg = EXYNOS4_MIPI_PHY_CONTROL(1), | ||
99 | .resetn_map = EXYNOS_MIPI_REGMAP_PMU, | ||
100 | }, | ||
101 | }, | ||
102 | }; | ||
103 | |||
104 | static const struct mipi_phy_device_desc exynos5420_mipi_phy = { | ||
105 | .num_regmaps = 1, | ||
106 | .regmap_names = {"syscon"}, | ||
107 | .num_phys = 5, | ||
108 | .phys = { | ||
109 | { | ||
110 | /* EXYNOS_MIPI_PHY_ID_CSIS0 */ | ||
111 | .coupled_phy_id = EXYNOS_MIPI_PHY_ID_DSIM0, | ||
112 | .enable_val = EXYNOS5_PHY_ENABLE, | ||
113 | .enable_reg = EXYNOS5420_MIPI_PHY0_CONTROL, | ||
114 | .enable_map = EXYNOS_MIPI_REGMAP_PMU, | ||
115 | .resetn_val = EXYNOS5_MIPI_PHY_S_RESETN, | ||
116 | .resetn_reg = EXYNOS5420_MIPI_PHY0_CONTROL, | ||
117 | .resetn_map = EXYNOS_MIPI_REGMAP_PMU, | ||
118 | }, { | ||
119 | /* EXYNOS_MIPI_PHY_ID_DSIM0 */ | ||
120 | .coupled_phy_id = EXYNOS_MIPI_PHY_ID_CSIS0, | ||
121 | .enable_val = EXYNOS5_PHY_ENABLE, | ||
122 | .enable_reg = EXYNOS5420_MIPI_PHY0_CONTROL, | ||
123 | .enable_map = EXYNOS_MIPI_REGMAP_PMU, | ||
124 | .resetn_val = EXYNOS5_MIPI_PHY_M_RESETN, | ||
125 | .resetn_reg = EXYNOS5420_MIPI_PHY0_CONTROL, | ||
126 | .resetn_map = EXYNOS_MIPI_REGMAP_PMU, | ||
127 | }, { | ||
128 | /* EXYNOS_MIPI_PHY_ID_CSIS1 */ | ||
129 | .coupled_phy_id = EXYNOS_MIPI_PHY_ID_DSIM1, | ||
130 | .enable_val = EXYNOS5_PHY_ENABLE, | ||
131 | .enable_reg = EXYNOS5420_MIPI_PHY1_CONTROL, | ||
132 | .enable_map = EXYNOS_MIPI_REGMAP_PMU, | ||
133 | .resetn_val = EXYNOS5_MIPI_PHY_S_RESETN, | ||
134 | .resetn_reg = EXYNOS5420_MIPI_PHY1_CONTROL, | ||
135 | .resetn_map = EXYNOS_MIPI_REGMAP_PMU, | ||
136 | }, { | ||
137 | /* EXYNOS_MIPI_PHY_ID_DSIM1 */ | ||
138 | .coupled_phy_id = EXYNOS_MIPI_PHY_ID_CSIS1, | ||
139 | .enable_val = EXYNOS5_PHY_ENABLE, | ||
140 | .enable_reg = EXYNOS5420_MIPI_PHY1_CONTROL, | ||
141 | .enable_map = EXYNOS_MIPI_REGMAP_PMU, | ||
142 | .resetn_val = EXYNOS5_MIPI_PHY_M_RESETN, | ||
143 | .resetn_reg = EXYNOS5420_MIPI_PHY1_CONTROL, | ||
144 | .resetn_map = EXYNOS_MIPI_REGMAP_PMU, | ||
145 | }, { | ||
146 | /* EXYNOS_MIPI_PHY_ID_CSIS2 */ | ||
147 | .coupled_phy_id = EXYNOS_MIPI_PHY_ID_NONE, | ||
148 | .enable_val = EXYNOS5_PHY_ENABLE, | ||
149 | .enable_reg = EXYNOS5420_MIPI_PHY2_CONTROL, | ||
150 | .enable_map = EXYNOS_MIPI_REGMAP_PMU, | ||
151 | .resetn_val = EXYNOS5_MIPI_PHY_S_RESETN, | ||
152 | .resetn_reg = EXYNOS5420_MIPI_PHY2_CONTROL, | ||
153 | .resetn_map = EXYNOS_MIPI_REGMAP_PMU, | ||
154 | }, | ||
155 | }, | ||
156 | }; | ||
157 | |||
158 | #define EXYNOS5433_SYSREG_DISP_MIPI_PHY 0x100C | ||
159 | #define EXYNOS5433_SYSREG_CAM0_MIPI_DPHY_CON 0x1014 | ||
160 | #define EXYNOS5433_SYSREG_CAM1_MIPI_DPHY_CON 0x1020 | ||
161 | |||
162 | static const struct mipi_phy_device_desc exynos5433_mipi_phy = { | ||
163 | .num_regmaps = 4, | ||
164 | .regmap_names = { | ||
165 | "samsung,pmu-syscon", | ||
166 | "samsung,disp-sysreg", | ||
167 | "samsung,cam0-sysreg", | ||
168 | "samsung,cam1-sysreg" | ||
169 | }, | ||
170 | .num_phys = 5, | ||
171 | .phys = { | ||
172 | { | ||
173 | /* EXYNOS_MIPI_PHY_ID_CSIS0 */ | ||
174 | .coupled_phy_id = EXYNOS_MIPI_PHY_ID_DSIM0, | ||
175 | .enable_val = EXYNOS5_PHY_ENABLE, | ||
176 | .enable_reg = EXYNOS5433_MIPI_PHY0_CONTROL, | ||
177 | .enable_map = EXYNOS_MIPI_REGMAP_PMU, | ||
178 | .resetn_val = BIT(0), | ||
179 | .resetn_reg = EXYNOS5433_SYSREG_CAM0_MIPI_DPHY_CON, | ||
180 | .resetn_map = EXYNOS_MIPI_REGMAP_CAM0, | ||
181 | }, { | ||
182 | /* EXYNOS_MIPI_PHY_ID_DSIM0 */ | ||
183 | .coupled_phy_id = EXYNOS_MIPI_PHY_ID_CSIS0, | ||
184 | .enable_val = EXYNOS5_PHY_ENABLE, | ||
185 | .enable_reg = EXYNOS5433_MIPI_PHY0_CONTROL, | ||
186 | .enable_map = EXYNOS_MIPI_REGMAP_PMU, | ||
187 | .resetn_val = BIT(0), | ||
188 | .resetn_reg = EXYNOS5433_SYSREG_DISP_MIPI_PHY, | ||
189 | .resetn_map = EXYNOS_MIPI_REGMAP_DISP, | ||
190 | }, { | ||
191 | /* EXYNOS_MIPI_PHY_ID_CSIS1 */ | ||
192 | .coupled_phy_id = EXYNOS_MIPI_PHY_ID_NONE, | ||
193 | .enable_val = EXYNOS5_PHY_ENABLE, | ||
194 | .enable_reg = EXYNOS5433_MIPI_PHY1_CONTROL, | ||
195 | .enable_map = EXYNOS_MIPI_REGMAP_PMU, | ||
196 | .resetn_val = BIT(1), | ||
197 | .resetn_reg = EXYNOS5433_SYSREG_CAM0_MIPI_DPHY_CON, | ||
198 | .resetn_map = EXYNOS_MIPI_REGMAP_CAM0, | ||
199 | }, { | ||
200 | /* EXYNOS_MIPI_PHY_ID_DSIM1 */ | ||
201 | .coupled_phy_id = EXYNOS_MIPI_PHY_ID_NONE, | ||
202 | .enable_val = EXYNOS5_PHY_ENABLE, | ||
203 | .enable_reg = EXYNOS5433_MIPI_PHY1_CONTROL, | ||
204 | .enable_map = EXYNOS_MIPI_REGMAP_PMU, | ||
205 | .resetn_val = BIT(1), | ||
206 | .resetn_reg = EXYNOS5433_SYSREG_DISP_MIPI_PHY, | ||
207 | .resetn_map = EXYNOS_MIPI_REGMAP_DISP, | ||
208 | }, { | ||
209 | /* EXYNOS_MIPI_PHY_ID_CSIS2 */ | ||
210 | .coupled_phy_id = EXYNOS_MIPI_PHY_ID_NONE, | ||
211 | .enable_val = EXYNOS5_PHY_ENABLE, | ||
212 | .enable_reg = EXYNOS5433_MIPI_PHY2_CONTROL, | ||
213 | .enable_map = EXYNOS_MIPI_REGMAP_PMU, | ||
214 | .resetn_val = BIT(0), | ||
215 | .resetn_reg = EXYNOS5433_SYSREG_CAM1_MIPI_DPHY_CON, | ||
216 | .resetn_map = EXYNOS_MIPI_REGMAP_CAM1, | ||
217 | }, | ||
218 | }, | ||
219 | }; | ||
38 | 220 | ||
39 | struct exynos_mipi_video_phy { | 221 | struct exynos_mipi_video_phy { |
222 | struct regmap *regmaps[EXYNOS_MIPI_REGMAPS_NUM]; | ||
223 | int num_phys; | ||
40 | struct video_phy_desc { | 224 | struct video_phy_desc { |
41 | struct phy *phy; | 225 | struct phy *phy; |
42 | unsigned int index; | 226 | unsigned int index; |
227 | const struct exynos_mipi_phy_desc *data; | ||
43 | } phys[EXYNOS_MIPI_PHYS_NUM]; | 228 | } phys[EXYNOS_MIPI_PHYS_NUM]; |
44 | spinlock_t slock; | 229 | spinlock_t slock; |
45 | void __iomem *regs; | ||
46 | struct regmap *regmap; | ||
47 | }; | 230 | }; |
48 | 231 | ||
49 | static int __set_phy_state(struct exynos_mipi_video_phy *state, | 232 | static inline int __is_running(const struct exynos_mipi_phy_desc *data, |
50 | enum exynos_mipi_phy_id id, unsigned int on) | 233 | struct exynos_mipi_video_phy *state) |
51 | { | 234 | { |
52 | const unsigned int offset = EXYNOS4_MIPI_PHY_CONTROL(id / 2); | 235 | u32 val; |
53 | void __iomem *addr; | ||
54 | u32 val, reset; | ||
55 | 236 | ||
56 | if (is_mipi_dsim_phy_id(id)) | 237 | regmap_read(state->regmaps[data->resetn_map], data->resetn_reg, &val); |
57 | reset = EXYNOS4_MIPI_PHY_MRESETN; | 238 | return val & data->resetn_val; |
58 | else | 239 | } |
59 | reset = EXYNOS4_MIPI_PHY_SRESETN; | 240 | |
241 | static int __set_phy_state(const struct exynos_mipi_phy_desc *data, | ||
242 | struct exynos_mipi_video_phy *state, unsigned int on) | ||
243 | { | ||
244 | u32 val; | ||
60 | 245 | ||
61 | spin_lock(&state->slock); | 246 | spin_lock(&state->slock); |
62 | 247 | ||
63 | if (!IS_ERR(state->regmap)) { | 248 | /* disable in PMU sysreg */ |
64 | regmap_read(state->regmap, offset, &val); | 249 | if (!on && data->coupled_phy_id >= 0 && |
65 | if (on) | 250 | !__is_running(state->phys[data->coupled_phy_id].data, state)) { |
66 | val |= reset; | 251 | regmap_read(state->regmaps[data->enable_map], data->enable_reg, |
67 | else | 252 | &val); |
68 | val &= ~reset; | 253 | val &= ~data->enable_val; |
69 | regmap_write(state->regmap, offset, val); | 254 | regmap_write(state->regmaps[data->enable_map], data->enable_reg, |
70 | if (on) | 255 | val); |
71 | val |= EXYNOS4_MIPI_PHY_ENABLE; | 256 | } |
72 | else if (!(val & EXYNOS4_MIPI_PHY_RESET_MASK)) | 257 | |
73 | val &= ~EXYNOS4_MIPI_PHY_ENABLE; | 258 | /* PHY reset */ |
74 | regmap_write(state->regmap, offset, val); | 259 | regmap_read(state->regmaps[data->resetn_map], data->resetn_reg, &val); |
75 | } else { | 260 | val = on ? (val | data->resetn_val) : (val & ~data->resetn_val); |
76 | addr = state->regs + EXYNOS_MIPI_PHY_CONTROL(id / 2); | 261 | regmap_write(state->regmaps[data->resetn_map], data->resetn_reg, val); |
77 | 262 | ||
78 | val = readl(addr); | 263 | /* enable in PMU sysreg */ |
79 | if (on) | 264 | if (on) { |
80 | val |= reset; | 265 | regmap_read(state->regmaps[data->enable_map], data->enable_reg, |
81 | else | 266 | &val); |
82 | val &= ~reset; | 267 | val |= data->enable_val; |
83 | writel(val, addr); | 268 | regmap_write(state->regmaps[data->enable_map], data->enable_reg, |
84 | /* Clear ENABLE bit only if MRESETN, SRESETN bits are not set */ | 269 | val); |
85 | if (on) | ||
86 | val |= EXYNOS4_MIPI_PHY_ENABLE; | ||
87 | else if (!(val & EXYNOS4_MIPI_PHY_RESET_MASK)) | ||
88 | val &= ~EXYNOS4_MIPI_PHY_ENABLE; | ||
89 | |||
90 | writel(val, addr); | ||
91 | } | 270 | } |
92 | 271 | ||
93 | spin_unlock(&state->slock); | 272 | spin_unlock(&state->slock); |
273 | |||
94 | return 0; | 274 | return 0; |
95 | } | 275 | } |
96 | 276 | ||
97 | #define to_mipi_video_phy(desc) \ | 277 | #define to_mipi_video_phy(desc) \ |
98 | container_of((desc), struct exynos_mipi_video_phy, phys[(desc)->index]); | 278 | container_of((desc), struct exynos_mipi_video_phy, phys[(desc)->index]) |
99 | 279 | ||
100 | static int exynos_mipi_video_phy_power_on(struct phy *phy) | 280 | static int exynos_mipi_video_phy_power_on(struct phy *phy) |
101 | { | 281 | { |
102 | struct video_phy_desc *phy_desc = phy_get_drvdata(phy); | 282 | struct video_phy_desc *phy_desc = phy_get_drvdata(phy); |
103 | struct exynos_mipi_video_phy *state = to_mipi_video_phy(phy_desc); | 283 | struct exynos_mipi_video_phy *state = to_mipi_video_phy(phy_desc); |
104 | 284 | ||
105 | return __set_phy_state(state, phy_desc->index, 1); | 285 | return __set_phy_state(phy_desc->data, state, 1); |
106 | } | 286 | } |
107 | 287 | ||
108 | static int exynos_mipi_video_phy_power_off(struct phy *phy) | 288 | static int exynos_mipi_video_phy_power_off(struct phy *phy) |
@@ -110,7 +290,7 @@ static int exynos_mipi_video_phy_power_off(struct phy *phy) | |||
110 | struct video_phy_desc *phy_desc = phy_get_drvdata(phy); | 290 | struct video_phy_desc *phy_desc = phy_get_drvdata(phy); |
111 | struct exynos_mipi_video_phy *state = to_mipi_video_phy(phy_desc); | 291 | struct exynos_mipi_video_phy *state = to_mipi_video_phy(phy_desc); |
112 | 292 | ||
113 | return __set_phy_state(state, phy_desc->index, 0); | 293 | return __set_phy_state(phy_desc->data, state, 0); |
114 | } | 294 | } |
115 | 295 | ||
116 | static struct phy *exynos_mipi_video_phy_xlate(struct device *dev, | 296 | static struct phy *exynos_mipi_video_phy_xlate(struct device *dev, |
@@ -118,7 +298,7 @@ static struct phy *exynos_mipi_video_phy_xlate(struct device *dev, | |||
118 | { | 298 | { |
119 | struct exynos_mipi_video_phy *state = dev_get_drvdata(dev); | 299 | struct exynos_mipi_video_phy *state = dev_get_drvdata(dev); |
120 | 300 | ||
121 | if (WARN_ON(args->args[0] >= EXYNOS_MIPI_PHYS_NUM)) | 301 | if (WARN_ON(args->args[0] >= state->num_phys)) |
122 | return ERR_PTR(-ENODEV); | 302 | return ERR_PTR(-ENODEV); |
123 | 303 | ||
124 | return state->phys[args->args[0]].phy; | 304 | return state->phys[args->args[0]].phy; |
@@ -132,32 +312,33 @@ static const struct phy_ops exynos_mipi_video_phy_ops = { | |||
132 | 312 | ||
133 | static int exynos_mipi_video_phy_probe(struct platform_device *pdev) | 313 | static int exynos_mipi_video_phy_probe(struct platform_device *pdev) |
134 | { | 314 | { |
315 | const struct mipi_phy_device_desc *phy_dev; | ||
135 | struct exynos_mipi_video_phy *state; | 316 | struct exynos_mipi_video_phy *state; |
136 | struct device *dev = &pdev->dev; | 317 | struct device *dev = &pdev->dev; |
318 | struct device_node *np = dev->of_node; | ||
137 | struct phy_provider *phy_provider; | 319 | struct phy_provider *phy_provider; |
138 | unsigned int i; | 320 | unsigned int i; |
139 | 321 | ||
322 | phy_dev = of_device_get_match_data(dev); | ||
323 | if (!phy_dev) | ||
324 | return -ENODEV; | ||
325 | |||
140 | state = devm_kzalloc(dev, sizeof(*state), GFP_KERNEL); | 326 | state = devm_kzalloc(dev, sizeof(*state), GFP_KERNEL); |
141 | if (!state) | 327 | if (!state) |
142 | return -ENOMEM; | 328 | return -ENOMEM; |
143 | 329 | ||
144 | state->regmap = syscon_regmap_lookup_by_phandle(dev->of_node, "syscon"); | 330 | for (i = 0; i < phy_dev->num_regmaps; i++) { |
145 | if (IS_ERR(state->regmap)) { | 331 | state->regmaps[i] = syscon_regmap_lookup_by_phandle(np, |
146 | struct resource *res; | 332 | phy_dev->regmap_names[i]); |
147 | 333 | if (IS_ERR(state->regmaps[i])) | |
148 | dev_info(dev, "regmap lookup failed: %ld\n", | 334 | return PTR_ERR(state->regmaps[i]); |
149 | PTR_ERR(state->regmap)); | ||
150 | |||
151 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
152 | state->regs = devm_ioremap_resource(dev, res); | ||
153 | if (IS_ERR(state->regs)) | ||
154 | return PTR_ERR(state->regs); | ||
155 | } | 335 | } |
336 | state->num_phys = phy_dev->num_phys; | ||
337 | spin_lock_init(&state->slock); | ||
156 | 338 | ||
157 | dev_set_drvdata(dev, state); | 339 | dev_set_drvdata(dev, state); |
158 | spin_lock_init(&state->slock); | ||
159 | 340 | ||
160 | for (i = 0; i < EXYNOS_MIPI_PHYS_NUM; i++) { | 341 | for (i = 0; i < state->num_phys; i++) { |
161 | struct phy *phy = devm_phy_create(dev, NULL, | 342 | struct phy *phy = devm_phy_create(dev, NULL, |
162 | &exynos_mipi_video_phy_ops); | 343 | &exynos_mipi_video_phy_ops); |
163 | if (IS_ERR(phy)) { | 344 | if (IS_ERR(phy)) { |
@@ -167,6 +348,7 @@ static int exynos_mipi_video_phy_probe(struct platform_device *pdev) | |||
167 | 348 | ||
168 | state->phys[i].phy = phy; | 349 | state->phys[i].phy = phy; |
169 | state->phys[i].index = i; | 350 | state->phys[i].index = i; |
351 | state->phys[i].data = &phy_dev->phys[i]; | ||
170 | phy_set_drvdata(phy, &state->phys[i]); | 352 | phy_set_drvdata(phy, &state->phys[i]); |
171 | } | 353 | } |
172 | 354 | ||
@@ -177,8 +359,17 @@ static int exynos_mipi_video_phy_probe(struct platform_device *pdev) | |||
177 | } | 359 | } |
178 | 360 | ||
179 | static const struct of_device_id exynos_mipi_video_phy_of_match[] = { | 361 | static const struct of_device_id exynos_mipi_video_phy_of_match[] = { |
180 | { .compatible = "samsung,s5pv210-mipi-video-phy" }, | 362 | { |
181 | { }, | 363 | .compatible = "samsung,s5pv210-mipi-video-phy", |
364 | .data = &s5pv210_mipi_phy, | ||
365 | }, { | ||
366 | .compatible = "samsung,exynos5420-mipi-video-phy", | ||
367 | .data = &exynos5420_mipi_phy, | ||
368 | }, { | ||
369 | .compatible = "samsung,exynos5433-mipi-video-phy", | ||
370 | .data = &exynos5433_mipi_phy, | ||
371 | }, | ||
372 | { /* sentinel */ }, | ||
182 | }; | 373 | }; |
183 | MODULE_DEVICE_TABLE(of, exynos_mipi_video_phy_of_match); | 374 | MODULE_DEVICE_TABLE(of, exynos_mipi_video_phy_of_match); |
184 | 375 | ||
diff --git a/drivers/phy/phy-mt65xx-usb3.c b/drivers/phy/phy-mt65xx-usb3.c index c0e7b4b0cf5c..4d85e730ccab 100644 --- a/drivers/phy/phy-mt65xx-usb3.c +++ b/drivers/phy/phy-mt65xx-usb3.c | |||
@@ -134,6 +134,11 @@ | |||
134 | #define U3P_SR_COEF_DIVISOR 1000 | 134 | #define U3P_SR_COEF_DIVISOR 1000 |
135 | #define U3P_FM_DET_CYCLE_CNT 1024 | 135 | #define U3P_FM_DET_CYCLE_CNT 1024 |
136 | 136 | ||
137 | struct mt65xx_phy_pdata { | ||
138 | /* avoid RX sensitivity level degradation only for mt8173 */ | ||
139 | bool avoid_rx_sen_degradation; | ||
140 | }; | ||
141 | |||
137 | struct mt65xx_phy_instance { | 142 | struct mt65xx_phy_instance { |
138 | struct phy *phy; | 143 | struct phy *phy; |
139 | void __iomem *port_base; | 144 | void __iomem *port_base; |
@@ -145,6 +150,7 @@ struct mt65xx_u3phy { | |||
145 | struct device *dev; | 150 | struct device *dev; |
146 | void __iomem *sif_base; /* include sif2, but exclude port's */ | 151 | void __iomem *sif_base; /* include sif2, but exclude port's */ |
147 | struct clk *u3phya_ref; /* reference clock of usb3 anolog phy */ | 152 | struct clk *u3phya_ref; /* reference clock of usb3 anolog phy */ |
153 | const struct mt65xx_phy_pdata *pdata; | ||
148 | struct mt65xx_phy_instance **phys; | 154 | struct mt65xx_phy_instance **phys; |
149 | int nphys; | 155 | int nphys; |
150 | }; | 156 | }; |
@@ -241,22 +247,26 @@ static void phy_instance_init(struct mt65xx_u3phy *u3phy, | |||
241 | tmp = readl(port_base + U3P_U2PHYACR4); | 247 | tmp = readl(port_base + U3P_U2PHYACR4); |
242 | tmp &= ~P2C_U2_GPIO_CTR_MSK; | 248 | tmp &= ~P2C_U2_GPIO_CTR_MSK; |
243 | writel(tmp, port_base + U3P_U2PHYACR4); | 249 | writel(tmp, port_base + U3P_U2PHYACR4); |
250 | } | ||
244 | 251 | ||
245 | tmp = readl(port_base + U3P_USBPHYACR2); | 252 | if (u3phy->pdata->avoid_rx_sen_degradation) { |
246 | tmp |= PA2_RG_SIF_U2PLL_FORCE_EN; | 253 | if (!index) { |
247 | writel(tmp, port_base + U3P_USBPHYACR2); | 254 | tmp = readl(port_base + U3P_USBPHYACR2); |
248 | 255 | tmp |= PA2_RG_SIF_U2PLL_FORCE_EN; | |
249 | tmp = readl(port_base + U3D_U2PHYDCR0); | 256 | writel(tmp, port_base + U3P_USBPHYACR2); |
250 | tmp &= ~P2C_RG_SIF_U2PLL_FORCE_ON; | 257 | |
251 | writel(tmp, port_base + U3D_U2PHYDCR0); | 258 | tmp = readl(port_base + U3D_U2PHYDCR0); |
252 | } else { | 259 | tmp &= ~P2C_RG_SIF_U2PLL_FORCE_ON; |
253 | tmp = readl(port_base + U3D_U2PHYDCR0); | 260 | writel(tmp, port_base + U3D_U2PHYDCR0); |
254 | tmp |= P2C_RG_SIF_U2PLL_FORCE_ON; | 261 | } else { |
255 | writel(tmp, port_base + U3D_U2PHYDCR0); | 262 | tmp = readl(port_base + U3D_U2PHYDCR0); |
256 | 263 | tmp |= P2C_RG_SIF_U2PLL_FORCE_ON; | |
257 | tmp = readl(port_base + U3P_U2PHYDTM0); | 264 | writel(tmp, port_base + U3D_U2PHYDCR0); |
258 | tmp |= P2C_RG_SUSPENDM | P2C_FORCE_SUSPENDM; | 265 | |
259 | writel(tmp, port_base + U3P_U2PHYDTM0); | 266 | tmp = readl(port_base + U3P_U2PHYDTM0); |
267 | tmp |= P2C_RG_SUSPENDM | P2C_FORCE_SUSPENDM; | ||
268 | writel(tmp, port_base + U3P_U2PHYDTM0); | ||
269 | } | ||
260 | } | 270 | } |
261 | 271 | ||
262 | tmp = readl(port_base + U3P_USBPHYACR6); | 272 | tmp = readl(port_base + U3P_USBPHYACR6); |
@@ -318,7 +328,7 @@ static void phy_instance_power_on(struct mt65xx_u3phy *u3phy, | |||
318 | tmp |= XC3_RG_U3_XTAL_RX_PWD | XC3_RG_U3_FRC_XTAL_RX_PWD; | 328 | tmp |= XC3_RG_U3_XTAL_RX_PWD | XC3_RG_U3_FRC_XTAL_RX_PWD; |
319 | writel(tmp, u3phy->sif_base + U3P_XTALCTL3); | 329 | writel(tmp, u3phy->sif_base + U3P_XTALCTL3); |
320 | 330 | ||
321 | /* [mt8173]switch 100uA current to SSUSB */ | 331 | /* switch 100uA current to SSUSB */ |
322 | tmp = readl(port_base + U3P_USBPHYACR5); | 332 | tmp = readl(port_base + U3P_USBPHYACR5); |
323 | tmp |= PA5_RG_U2_HS_100U_U3_EN; | 333 | tmp |= PA5_RG_U2_HS_100U_U3_EN; |
324 | writel(tmp, port_base + U3P_USBPHYACR5); | 334 | writel(tmp, port_base + U3P_USBPHYACR5); |
@@ -335,7 +345,7 @@ static void phy_instance_power_on(struct mt65xx_u3phy *u3phy, | |||
335 | tmp |= PA5_RG_U2_HSTX_SRCTRL_VAL(4); | 345 | tmp |= PA5_RG_U2_HSTX_SRCTRL_VAL(4); |
336 | writel(tmp, port_base + U3P_USBPHYACR5); | 346 | writel(tmp, port_base + U3P_USBPHYACR5); |
337 | 347 | ||
338 | if (index) { | 348 | if (u3phy->pdata->avoid_rx_sen_degradation && index) { |
339 | tmp = readl(port_base + U3D_U2PHYDCR0); | 349 | tmp = readl(port_base + U3D_U2PHYDCR0); |
340 | tmp |= P2C_RG_SIF_U2PLL_FORCE_ON; | 350 | tmp |= P2C_RG_SIF_U2PLL_FORCE_ON; |
341 | writel(tmp, port_base + U3D_U2PHYDCR0); | 351 | writel(tmp, port_base + U3D_U2PHYDCR0); |
@@ -386,7 +396,9 @@ static void phy_instance_power_off(struct mt65xx_u3phy *u3phy, | |||
386 | tmp = readl(port_base + U3P_U3_PHYA_REG0); | 396 | tmp = readl(port_base + U3P_U3_PHYA_REG0); |
387 | tmp &= ~P3A_RG_U3_VUSB10_ON; | 397 | tmp &= ~P3A_RG_U3_VUSB10_ON; |
388 | writel(tmp, port_base + U3P_U3_PHYA_REG0); | 398 | writel(tmp, port_base + U3P_U3_PHYA_REG0); |
389 | } else { | 399 | } |
400 | |||
401 | if (u3phy->pdata->avoid_rx_sen_degradation && index) { | ||
390 | tmp = readl(port_base + U3D_U2PHYDCR0); | 402 | tmp = readl(port_base + U3D_U2PHYDCR0); |
391 | tmp &= ~P2C_RG_SIF_U2PLL_FORCE_ON; | 403 | tmp &= ~P2C_RG_SIF_U2PLL_FORCE_ON; |
392 | writel(tmp, port_base + U3D_U2PHYDCR0); | 404 | writel(tmp, port_base + U3D_U2PHYDCR0); |
@@ -402,7 +414,7 @@ static void phy_instance_exit(struct mt65xx_u3phy *u3phy, | |||
402 | u32 index = instance->index; | 414 | u32 index = instance->index; |
403 | u32 tmp; | 415 | u32 tmp; |
404 | 416 | ||
405 | if (index) { | 417 | if (u3phy->pdata->avoid_rx_sen_degradation && index) { |
406 | tmp = readl(port_base + U3D_U2PHYDCR0); | 418 | tmp = readl(port_base + U3D_U2PHYDCR0); |
407 | tmp &= ~P2C_RG_SIF_U2PLL_FORCE_ON; | 419 | tmp &= ~P2C_RG_SIF_U2PLL_FORCE_ON; |
408 | writel(tmp, port_base + U3D_U2PHYDCR0); | 420 | writel(tmp, port_base + U3D_U2PHYDCR0); |
@@ -502,8 +514,24 @@ static struct phy_ops mt65xx_u3phy_ops = { | |||
502 | .owner = THIS_MODULE, | 514 | .owner = THIS_MODULE, |
503 | }; | 515 | }; |
504 | 516 | ||
517 | static const struct mt65xx_phy_pdata mt2701_pdata = { | ||
518 | .avoid_rx_sen_degradation = false, | ||
519 | }; | ||
520 | |||
521 | static const struct mt65xx_phy_pdata mt8173_pdata = { | ||
522 | .avoid_rx_sen_degradation = true, | ||
523 | }; | ||
524 | |||
525 | static const struct of_device_id mt65xx_u3phy_id_table[] = { | ||
526 | { .compatible = "mediatek,mt2701-u3phy", .data = &mt2701_pdata }, | ||
527 | { .compatible = "mediatek,mt8173-u3phy", .data = &mt8173_pdata }, | ||
528 | { }, | ||
529 | }; | ||
530 | MODULE_DEVICE_TABLE(of, mt65xx_u3phy_id_table); | ||
531 | |||
505 | static int mt65xx_u3phy_probe(struct platform_device *pdev) | 532 | static int mt65xx_u3phy_probe(struct platform_device *pdev) |
506 | { | 533 | { |
534 | const struct of_device_id *match; | ||
507 | struct device *dev = &pdev->dev; | 535 | struct device *dev = &pdev->dev; |
508 | struct device_node *np = dev->of_node; | 536 | struct device_node *np = dev->of_node; |
509 | struct device_node *child_np; | 537 | struct device_node *child_np; |
@@ -513,10 +541,15 @@ static int mt65xx_u3phy_probe(struct platform_device *pdev) | |||
513 | struct resource res; | 541 | struct resource res; |
514 | int port, retval; | 542 | int port, retval; |
515 | 543 | ||
544 | match = of_match_node(mt65xx_u3phy_id_table, pdev->dev.of_node); | ||
545 | if (!match) | ||
546 | return -EINVAL; | ||
547 | |||
516 | u3phy = devm_kzalloc(dev, sizeof(*u3phy), GFP_KERNEL); | 548 | u3phy = devm_kzalloc(dev, sizeof(*u3phy), GFP_KERNEL); |
517 | if (!u3phy) | 549 | if (!u3phy) |
518 | return -ENOMEM; | 550 | return -ENOMEM; |
519 | 551 | ||
552 | u3phy->pdata = match->data; | ||
520 | u3phy->nphys = of_get_child_count(np); | 553 | u3phy->nphys = of_get_child_count(np); |
521 | u3phy->phys = devm_kcalloc(dev, u3phy->nphys, | 554 | u3phy->phys = devm_kcalloc(dev, u3phy->nphys, |
522 | sizeof(*u3phy->phys), GFP_KERNEL); | 555 | sizeof(*u3phy->phys), GFP_KERNEL); |
@@ -587,12 +620,6 @@ put_child: | |||
587 | return retval; | 620 | return retval; |
588 | } | 621 | } |
589 | 622 | ||
590 | static const struct of_device_id mt65xx_u3phy_id_table[] = { | ||
591 | { .compatible = "mediatek,mt8173-u3phy", }, | ||
592 | { }, | ||
593 | }; | ||
594 | MODULE_DEVICE_TABLE(of, mt65xx_u3phy_id_table); | ||
595 | |||
596 | static struct platform_driver mt65xx_u3phy_driver = { | 623 | static struct platform_driver mt65xx_u3phy_driver = { |
597 | .probe = mt65xx_u3phy_probe, | 624 | .probe = mt65xx_u3phy_probe, |
598 | .driver = { | 625 | .driver = { |
diff --git a/drivers/phy/phy-rcar-gen2.c b/drivers/phy/phy-rcar-gen2.c index c7a05996d5c1..97d4dd6ea924 100644 --- a/drivers/phy/phy-rcar-gen2.c +++ b/drivers/phy/phy-rcar-gen2.c | |||
@@ -195,6 +195,7 @@ static const struct of_device_id rcar_gen2_phy_match_table[] = { | |||
195 | { .compatible = "renesas,usb-phy-r8a7790" }, | 195 | { .compatible = "renesas,usb-phy-r8a7790" }, |
196 | { .compatible = "renesas,usb-phy-r8a7791" }, | 196 | { .compatible = "renesas,usb-phy-r8a7791" }, |
197 | { .compatible = "renesas,usb-phy-r8a7794" }, | 197 | { .compatible = "renesas,usb-phy-r8a7794" }, |
198 | { .compatible = "renesas,rcar-gen2-usb-phy" }, | ||
198 | { } | 199 | { } |
199 | }; | 200 | }; |
200 | MODULE_DEVICE_TABLE(of, rcar_gen2_phy_match_table); | 201 | MODULE_DEVICE_TABLE(of, rcar_gen2_phy_match_table); |
diff --git a/drivers/phy/phy-rcar-gen3-usb2.c b/drivers/phy/phy-rcar-gen3-usb2.c index bc4f7dd821aa..76bb88f0700a 100644 --- a/drivers/phy/phy-rcar-gen3-usb2.c +++ b/drivers/phy/phy-rcar-gen3-usb2.c | |||
@@ -12,6 +12,7 @@ | |||
12 | * published by the Free Software Foundation. | 12 | * published by the Free Software Foundation. |
13 | */ | 13 | */ |
14 | 14 | ||
15 | #include <linux/extcon.h> | ||
15 | #include <linux/interrupt.h> | 16 | #include <linux/interrupt.h> |
16 | #include <linux/io.h> | 17 | #include <linux/io.h> |
17 | #include <linux/module.h> | 18 | #include <linux/module.h> |
@@ -19,6 +20,7 @@ | |||
19 | #include <linux/of_address.h> | 20 | #include <linux/of_address.h> |
20 | #include <linux/phy/phy.h> | 21 | #include <linux/phy/phy.h> |
21 | #include <linux/platform_device.h> | 22 | #include <linux/platform_device.h> |
23 | #include <linux/regulator/consumer.h> | ||
22 | 24 | ||
23 | /******* USB2.0 Host registers (original offset is +0x200) *******/ | 25 | /******* USB2.0 Host registers (original offset is +0x200) *******/ |
24 | #define USB2_INT_ENABLE 0x000 | 26 | #define USB2_INT_ENABLE 0x000 |
@@ -74,20 +76,17 @@ | |||
74 | #define USB2_ADPCTRL_IDPULLUP BIT(5) /* 1 = ID sampling is enabled */ | 76 | #define USB2_ADPCTRL_IDPULLUP BIT(5) /* 1 = ID sampling is enabled */ |
75 | #define USB2_ADPCTRL_DRVVBUS BIT(4) | 77 | #define USB2_ADPCTRL_DRVVBUS BIT(4) |
76 | 78 | ||
77 | struct rcar_gen3_data { | ||
78 | void __iomem *base; | ||
79 | struct clk *clk; | ||
80 | }; | ||
81 | |||
82 | struct rcar_gen3_chan { | 79 | struct rcar_gen3_chan { |
83 | struct rcar_gen3_data usb2; | 80 | void __iomem *base; |
81 | struct extcon_dev *extcon; | ||
84 | struct phy *phy; | 82 | struct phy *phy; |
83 | struct regulator *vbus; | ||
85 | bool has_otg; | 84 | bool has_otg; |
86 | }; | 85 | }; |
87 | 86 | ||
88 | static void rcar_gen3_set_host_mode(struct rcar_gen3_chan *ch, int host) | 87 | static void rcar_gen3_set_host_mode(struct rcar_gen3_chan *ch, int host) |
89 | { | 88 | { |
90 | void __iomem *usb2_base = ch->usb2.base; | 89 | void __iomem *usb2_base = ch->base; |
91 | u32 val = readl(usb2_base + USB2_COMMCTRL); | 90 | u32 val = readl(usb2_base + USB2_COMMCTRL); |
92 | 91 | ||
93 | dev_vdbg(&ch->phy->dev, "%s: %08x, %d\n", __func__, val, host); | 92 | dev_vdbg(&ch->phy->dev, "%s: %08x, %d\n", __func__, val, host); |
@@ -100,7 +99,7 @@ static void rcar_gen3_set_host_mode(struct rcar_gen3_chan *ch, int host) | |||
100 | 99 | ||
101 | static void rcar_gen3_set_linectrl(struct rcar_gen3_chan *ch, int dp, int dm) | 100 | static void rcar_gen3_set_linectrl(struct rcar_gen3_chan *ch, int dp, int dm) |
102 | { | 101 | { |
103 | void __iomem *usb2_base = ch->usb2.base; | 102 | void __iomem *usb2_base = ch->base; |
104 | u32 val = readl(usb2_base + USB2_LINECTRL1); | 103 | u32 val = readl(usb2_base + USB2_LINECTRL1); |
105 | 104 | ||
106 | dev_vdbg(&ch->phy->dev, "%s: %08x, %d, %d\n", __func__, val, dp, dm); | 105 | dev_vdbg(&ch->phy->dev, "%s: %08x, %d, %d\n", __func__, val, dp, dm); |
@@ -114,7 +113,7 @@ static void rcar_gen3_set_linectrl(struct rcar_gen3_chan *ch, int dp, int dm) | |||
114 | 113 | ||
115 | static void rcar_gen3_enable_vbus_ctrl(struct rcar_gen3_chan *ch, int vbus) | 114 | static void rcar_gen3_enable_vbus_ctrl(struct rcar_gen3_chan *ch, int vbus) |
116 | { | 115 | { |
117 | void __iomem *usb2_base = ch->usb2.base; | 116 | void __iomem *usb2_base = ch->base; |
118 | u32 val = readl(usb2_base + USB2_ADPCTRL); | 117 | u32 val = readl(usb2_base + USB2_ADPCTRL); |
119 | 118 | ||
120 | dev_vdbg(&ch->phy->dev, "%s: %08x, %d\n", __func__, val, vbus); | 119 | dev_vdbg(&ch->phy->dev, "%s: %08x, %d\n", __func__, val, vbus); |
@@ -130,6 +129,9 @@ static void rcar_gen3_init_for_host(struct rcar_gen3_chan *ch) | |||
130 | rcar_gen3_set_linectrl(ch, 1, 1); | 129 | rcar_gen3_set_linectrl(ch, 1, 1); |
131 | rcar_gen3_set_host_mode(ch, 1); | 130 | rcar_gen3_set_host_mode(ch, 1); |
132 | rcar_gen3_enable_vbus_ctrl(ch, 1); | 131 | rcar_gen3_enable_vbus_ctrl(ch, 1); |
132 | |||
133 | extcon_set_cable_state_(ch->extcon, EXTCON_USB_HOST, true); | ||
134 | extcon_set_cable_state_(ch->extcon, EXTCON_USB, false); | ||
133 | } | 135 | } |
134 | 136 | ||
135 | static void rcar_gen3_init_for_peri(struct rcar_gen3_chan *ch) | 137 | static void rcar_gen3_init_for_peri(struct rcar_gen3_chan *ch) |
@@ -137,17 +139,20 @@ static void rcar_gen3_init_for_peri(struct rcar_gen3_chan *ch) | |||
137 | rcar_gen3_set_linectrl(ch, 0, 1); | 139 | rcar_gen3_set_linectrl(ch, 0, 1); |
138 | rcar_gen3_set_host_mode(ch, 0); | 140 | rcar_gen3_set_host_mode(ch, 0); |
139 | rcar_gen3_enable_vbus_ctrl(ch, 0); | 141 | rcar_gen3_enable_vbus_ctrl(ch, 0); |
142 | |||
143 | extcon_set_cable_state_(ch->extcon, EXTCON_USB_HOST, false); | ||
144 | extcon_set_cable_state_(ch->extcon, EXTCON_USB, true); | ||
140 | } | 145 | } |
141 | 146 | ||
142 | static bool rcar_gen3_check_vbus(struct rcar_gen3_chan *ch) | 147 | static bool rcar_gen3_check_vbus(struct rcar_gen3_chan *ch) |
143 | { | 148 | { |
144 | return !!(readl(ch->usb2.base + USB2_ADPCTRL) & | 149 | return !!(readl(ch->base + USB2_ADPCTRL) & |
145 | USB2_ADPCTRL_OTGSESSVLD); | 150 | USB2_ADPCTRL_OTGSESSVLD); |
146 | } | 151 | } |
147 | 152 | ||
148 | static bool rcar_gen3_check_id(struct rcar_gen3_chan *ch) | 153 | static bool rcar_gen3_check_id(struct rcar_gen3_chan *ch) |
149 | { | 154 | { |
150 | return !!(readl(ch->usb2.base + USB2_ADPCTRL) & USB2_ADPCTRL_IDDIG); | 155 | return !!(readl(ch->base + USB2_ADPCTRL) & USB2_ADPCTRL_IDDIG); |
151 | } | 156 | } |
152 | 157 | ||
153 | static void rcar_gen3_device_recognition(struct rcar_gen3_chan *ch) | 158 | static void rcar_gen3_device_recognition(struct rcar_gen3_chan *ch) |
@@ -166,7 +171,7 @@ static void rcar_gen3_device_recognition(struct rcar_gen3_chan *ch) | |||
166 | 171 | ||
167 | static void rcar_gen3_init_otg(struct rcar_gen3_chan *ch) | 172 | static void rcar_gen3_init_otg(struct rcar_gen3_chan *ch) |
168 | { | 173 | { |
169 | void __iomem *usb2_base = ch->usb2.base; | 174 | void __iomem *usb2_base = ch->base; |
170 | u32 val; | 175 | u32 val; |
171 | 176 | ||
172 | val = readl(usb2_base + USB2_VBCTRL); | 177 | val = readl(usb2_base + USB2_VBCTRL); |
@@ -187,7 +192,7 @@ static void rcar_gen3_init_otg(struct rcar_gen3_chan *ch) | |||
187 | static int rcar_gen3_phy_usb2_init(struct phy *p) | 192 | static int rcar_gen3_phy_usb2_init(struct phy *p) |
188 | { | 193 | { |
189 | struct rcar_gen3_chan *channel = phy_get_drvdata(p); | 194 | struct rcar_gen3_chan *channel = phy_get_drvdata(p); |
190 | void __iomem *usb2_base = channel->usb2.base; | 195 | void __iomem *usb2_base = channel->base; |
191 | 196 | ||
192 | /* Initialize USB2 part */ | 197 | /* Initialize USB2 part */ |
193 | writel(USB2_INT_ENABLE_INIT, usb2_base + USB2_INT_ENABLE); | 198 | writel(USB2_INT_ENABLE_INIT, usb2_base + USB2_INT_ENABLE); |
@@ -205,7 +210,7 @@ static int rcar_gen3_phy_usb2_exit(struct phy *p) | |||
205 | { | 210 | { |
206 | struct rcar_gen3_chan *channel = phy_get_drvdata(p); | 211 | struct rcar_gen3_chan *channel = phy_get_drvdata(p); |
207 | 212 | ||
208 | writel(0, channel->usb2.base + USB2_INT_ENABLE); | 213 | writel(0, channel->base + USB2_INT_ENABLE); |
209 | 214 | ||
210 | return 0; | 215 | return 0; |
211 | } | 216 | } |
@@ -213,8 +218,15 @@ static int rcar_gen3_phy_usb2_exit(struct phy *p) | |||
213 | static int rcar_gen3_phy_usb2_power_on(struct phy *p) | 218 | static int rcar_gen3_phy_usb2_power_on(struct phy *p) |
214 | { | 219 | { |
215 | struct rcar_gen3_chan *channel = phy_get_drvdata(p); | 220 | struct rcar_gen3_chan *channel = phy_get_drvdata(p); |
216 | void __iomem *usb2_base = channel->usb2.base; | 221 | void __iomem *usb2_base = channel->base; |
217 | u32 val; | 222 | u32 val; |
223 | int ret; | ||
224 | |||
225 | if (channel->vbus) { | ||
226 | ret = regulator_enable(channel->vbus); | ||
227 | if (ret) | ||
228 | return ret; | ||
229 | } | ||
218 | 230 | ||
219 | val = readl(usb2_base + USB2_USBCTR); | 231 | val = readl(usb2_base + USB2_USBCTR); |
220 | val |= USB2_USBCTR_PLL_RST; | 232 | val |= USB2_USBCTR_PLL_RST; |
@@ -225,17 +237,29 @@ static int rcar_gen3_phy_usb2_power_on(struct phy *p) | |||
225 | return 0; | 237 | return 0; |
226 | } | 238 | } |
227 | 239 | ||
240 | static int rcar_gen3_phy_usb2_power_off(struct phy *p) | ||
241 | { | ||
242 | struct rcar_gen3_chan *channel = phy_get_drvdata(p); | ||
243 | int ret = 0; | ||
244 | |||
245 | if (channel->vbus) | ||
246 | ret = regulator_disable(channel->vbus); | ||
247 | |||
248 | return ret; | ||
249 | } | ||
250 | |||
228 | static struct phy_ops rcar_gen3_phy_usb2_ops = { | 251 | static struct phy_ops rcar_gen3_phy_usb2_ops = { |
229 | .init = rcar_gen3_phy_usb2_init, | 252 | .init = rcar_gen3_phy_usb2_init, |
230 | .exit = rcar_gen3_phy_usb2_exit, | 253 | .exit = rcar_gen3_phy_usb2_exit, |
231 | .power_on = rcar_gen3_phy_usb2_power_on, | 254 | .power_on = rcar_gen3_phy_usb2_power_on, |
255 | .power_off = rcar_gen3_phy_usb2_power_off, | ||
232 | .owner = THIS_MODULE, | 256 | .owner = THIS_MODULE, |
233 | }; | 257 | }; |
234 | 258 | ||
235 | static irqreturn_t rcar_gen3_phy_usb2_irq(int irq, void *_ch) | 259 | static irqreturn_t rcar_gen3_phy_usb2_irq(int irq, void *_ch) |
236 | { | 260 | { |
237 | struct rcar_gen3_chan *ch = _ch; | 261 | struct rcar_gen3_chan *ch = _ch; |
238 | void __iomem *usb2_base = ch->usb2.base; | 262 | void __iomem *usb2_base = ch->base; |
239 | u32 status = readl(usb2_base + USB2_OBINTSTA); | 263 | u32 status = readl(usb2_base + USB2_OBINTSTA); |
240 | irqreturn_t ret = IRQ_NONE; | 264 | irqreturn_t ret = IRQ_NONE; |
241 | 265 | ||
@@ -251,10 +275,17 @@ static irqreturn_t rcar_gen3_phy_usb2_irq(int irq, void *_ch) | |||
251 | 275 | ||
252 | static const struct of_device_id rcar_gen3_phy_usb2_match_table[] = { | 276 | static const struct of_device_id rcar_gen3_phy_usb2_match_table[] = { |
253 | { .compatible = "renesas,usb2-phy-r8a7795" }, | 277 | { .compatible = "renesas,usb2-phy-r8a7795" }, |
278 | { .compatible = "renesas,rcar-gen3-usb2-phy" }, | ||
254 | { } | 279 | { } |
255 | }; | 280 | }; |
256 | MODULE_DEVICE_TABLE(of, rcar_gen3_phy_usb2_match_table); | 281 | MODULE_DEVICE_TABLE(of, rcar_gen3_phy_usb2_match_table); |
257 | 282 | ||
283 | static const unsigned int rcar_gen3_phy_cable[] = { | ||
284 | EXTCON_USB, | ||
285 | EXTCON_USB_HOST, | ||
286 | EXTCON_NONE, | ||
287 | }; | ||
288 | |||
258 | static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev) | 289 | static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev) |
259 | { | 290 | { |
260 | struct device *dev = &pdev->dev; | 291 | struct device *dev = &pdev->dev; |
@@ -273,18 +304,30 @@ static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev) | |||
273 | return -ENOMEM; | 304 | return -ENOMEM; |
274 | 305 | ||
275 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 306 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
276 | channel->usb2.base = devm_ioremap_resource(dev, res); | 307 | channel->base = devm_ioremap_resource(dev, res); |
277 | if (IS_ERR(channel->usb2.base)) | 308 | if (IS_ERR(channel->base)) |
278 | return PTR_ERR(channel->usb2.base); | 309 | return PTR_ERR(channel->base); |
279 | 310 | ||
280 | /* call request_irq for OTG */ | 311 | /* call request_irq for OTG */ |
281 | irq = platform_get_irq(pdev, 0); | 312 | irq = platform_get_irq(pdev, 0); |
282 | if (irq >= 0) { | 313 | if (irq >= 0) { |
314 | int ret; | ||
315 | |||
283 | irq = devm_request_irq(dev, irq, rcar_gen3_phy_usb2_irq, | 316 | irq = devm_request_irq(dev, irq, rcar_gen3_phy_usb2_irq, |
284 | IRQF_SHARED, dev_name(dev), channel); | 317 | IRQF_SHARED, dev_name(dev), channel); |
285 | if (irq < 0) | 318 | if (irq < 0) |
286 | dev_err(dev, "No irq handler (%d)\n", irq); | 319 | dev_err(dev, "No irq handler (%d)\n", irq); |
287 | channel->has_otg = true; | 320 | channel->has_otg = true; |
321 | channel->extcon = devm_extcon_dev_allocate(dev, | ||
322 | rcar_gen3_phy_cable); | ||
323 | if (IS_ERR(channel->extcon)) | ||
324 | return PTR_ERR(channel->extcon); | ||
325 | |||
326 | ret = devm_extcon_dev_register(dev, channel->extcon); | ||
327 | if (ret < 0) { | ||
328 | dev_err(dev, "Failed to register extcon\n"); | ||
329 | return ret; | ||
330 | } | ||
288 | } | 331 | } |
289 | 332 | ||
290 | /* devm_phy_create() will call pm_runtime_enable(dev); */ | 333 | /* devm_phy_create() will call pm_runtime_enable(dev); */ |
@@ -294,6 +337,13 @@ static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev) | |||
294 | return PTR_ERR(channel->phy); | 337 | return PTR_ERR(channel->phy); |
295 | } | 338 | } |
296 | 339 | ||
340 | channel->vbus = devm_regulator_get_optional(dev, "vbus"); | ||
341 | if (IS_ERR(channel->vbus)) { | ||
342 | if (PTR_ERR(channel->vbus) == -EPROBE_DEFER) | ||
343 | return PTR_ERR(channel->vbus); | ||
344 | channel->vbus = NULL; | ||
345 | } | ||
346 | |||
297 | phy_set_drvdata(channel->phy, channel); | 347 | phy_set_drvdata(channel->phy, channel); |
298 | 348 | ||
299 | provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate); | 349 | provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate); |
diff --git a/drivers/phy/phy-rockchip-usb.c b/drivers/phy/phy-rockchip-usb.c index f62d899063a3..d60b149cff0f 100644 --- a/drivers/phy/phy-rockchip-usb.c +++ b/drivers/phy/phy-rockchip-usb.c | |||
@@ -216,7 +216,7 @@ static int rockchip_usb_phy_init(struct rockchip_usb_phy_base *base, | |||
216 | init.parent_names = &clk_name; | 216 | init.parent_names = &clk_name; |
217 | init.num_parents = 1; | 217 | init.num_parents = 1; |
218 | } else { | 218 | } else { |
219 | init.flags = CLK_IS_ROOT; | 219 | init.flags = 0; |
220 | init.parent_names = NULL; | 220 | init.parent_names = NULL; |
221 | init.num_parents = 0; | 221 | init.num_parents = 0; |
222 | } | 222 | } |
diff --git a/drivers/usb/Kconfig b/drivers/usb/Kconfig index 8ed451dd651e..8689dcba5201 100644 --- a/drivers/usb/Kconfig +++ b/drivers/usb/Kconfig | |||
@@ -31,8 +31,6 @@ if USB_SUPPORT | |||
31 | 31 | ||
32 | config USB_COMMON | 32 | config USB_COMMON |
33 | tristate | 33 | tristate |
34 | default y | ||
35 | depends on USB || USB_GADGET | ||
36 | 34 | ||
37 | config USB_ARCH_HAS_HCD | 35 | config USB_ARCH_HAS_HCD |
38 | def_bool y | 36 | def_bool y |
@@ -41,6 +39,7 @@ config USB_ARCH_HAS_HCD | |||
41 | config USB | 39 | config USB |
42 | tristate "Support for Host-side USB" | 40 | tristate "Support for Host-side USB" |
43 | depends on USB_ARCH_HAS_HCD | 41 | depends on USB_ARCH_HAS_HCD |
42 | select USB_COMMON | ||
44 | select NLS # for UTF-8 strings | 43 | select NLS # for UTF-8 strings |
45 | ---help--- | 44 | ---help--- |
46 | Universal Serial Bus (USB) is a specification for a serial bus | 45 | Universal Serial Bus (USB) is a specification for a serial bus |
diff --git a/drivers/usb/atm/ueagle-atm.c b/drivers/usb/atm/ueagle-atm.c index a2ae88dbda78..4333dc576a12 100644 --- a/drivers/usb/atm/ueagle-atm.c +++ b/drivers/usb/atm/ueagle-atm.c | |||
@@ -173,10 +173,10 @@ struct uea_softc { | |||
173 | const struct firmware *dsp_firm; | 173 | const struct firmware *dsp_firm; |
174 | struct urb *urb_int; | 174 | struct urb *urb_int; |
175 | 175 | ||
176 | void (*dispatch_cmv) (struct uea_softc *, struct intr_pkt *); | 176 | void (*dispatch_cmv)(struct uea_softc *, struct intr_pkt *); |
177 | void (*schedule_load_page) (struct uea_softc *, struct intr_pkt *); | 177 | void (*schedule_load_page)(struct uea_softc *, struct intr_pkt *); |
178 | int (*stat) (struct uea_softc *); | 178 | int (*stat)(struct uea_softc *); |
179 | int (*send_cmvs) (struct uea_softc *); | 179 | int (*send_cmvs)(struct uea_softc *); |
180 | 180 | ||
181 | /* keep in sync with eaglectl */ | 181 | /* keep in sync with eaglectl */ |
182 | struct uea_stats { | 182 | struct uea_stats { |
@@ -2454,7 +2454,7 @@ UEA_ATTR(firmid, 0); | |||
2454 | 2454 | ||
2455 | /* Retrieve the device End System Identifier (MAC) */ | 2455 | /* Retrieve the device End System Identifier (MAC) */ |
2456 | 2456 | ||
2457 | static int uea_getesi(struct uea_softc *sc, u_char * esi) | 2457 | static int uea_getesi(struct uea_softc *sc, u_char *esi) |
2458 | { | 2458 | { |
2459 | unsigned char mac_str[2 * ETH_ALEN + 1]; | 2459 | unsigned char mac_str[2 * ETH_ALEN + 1]; |
2460 | int i; | 2460 | int i; |
diff --git a/drivers/usb/chipidea/ci_hdrc_imx.c b/drivers/usb/chipidea/ci_hdrc_imx.c index 9ce8c9f91674..dedc33e589f4 100644 --- a/drivers/usb/chipidea/ci_hdrc_imx.c +++ b/drivers/usb/chipidea/ci_hdrc_imx.c | |||
@@ -292,10 +292,6 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev) | |||
292 | if (pdata.flags & CI_HDRC_SUPPORTS_RUNTIME_PM) | 292 | if (pdata.flags & CI_HDRC_SUPPORTS_RUNTIME_PM) |
293 | data->supports_runtime_pm = true; | 293 | data->supports_runtime_pm = true; |
294 | 294 | ||
295 | ret = dma_coerce_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)); | ||
296 | if (ret) | ||
297 | goto err_clk; | ||
298 | |||
299 | ret = imx_usbmisc_init(data->usbmisc_data); | 295 | ret = imx_usbmisc_init(data->usbmisc_data); |
300 | if (ret) { | 296 | if (ret) { |
301 | dev_err(&pdev->dev, "usbmisc init failed, ret=%d\n", ret); | 297 | dev_err(&pdev->dev, "usbmisc init failed, ret=%d\n", ret); |
diff --git a/drivers/usb/common/usb-otg-fsm.c b/drivers/usb/common/usb-otg-fsm.c index 504708f59b93..9059b7dc185e 100644 --- a/drivers/usb/common/usb-otg-fsm.c +++ b/drivers/usb/common/usb-otg-fsm.c | |||
@@ -61,8 +61,6 @@ static int otg_set_protocol(struct otg_fsm *fsm, int protocol) | |||
61 | return 0; | 61 | return 0; |
62 | } | 62 | } |
63 | 63 | ||
64 | static int state_changed; | ||
65 | |||
66 | /* Called when leaving a state. Do state clean up jobs here */ | 64 | /* Called when leaving a state. Do state clean up jobs here */ |
67 | static void otg_leave_state(struct otg_fsm *fsm, enum usb_otg_state old_state) | 65 | static void otg_leave_state(struct otg_fsm *fsm, enum usb_otg_state old_state) |
68 | { | 66 | { |
@@ -208,7 +206,6 @@ static void otg_start_hnp_polling(struct otg_fsm *fsm) | |||
208 | /* Called when entering a state */ | 206 | /* Called when entering a state */ |
209 | static int otg_set_state(struct otg_fsm *fsm, enum usb_otg_state new_state) | 207 | static int otg_set_state(struct otg_fsm *fsm, enum usb_otg_state new_state) |
210 | { | 208 | { |
211 | state_changed = 1; | ||
212 | if (fsm->otg->state == new_state) | 209 | if (fsm->otg->state == new_state) |
213 | return 0; | 210 | return 0; |
214 | VDBG("Set state: %s\n", usb_otg_state_string(new_state)); | 211 | VDBG("Set state: %s\n", usb_otg_state_string(new_state)); |
@@ -324,6 +321,7 @@ static int otg_set_state(struct otg_fsm *fsm, enum usb_otg_state new_state) | |||
324 | } | 321 | } |
325 | 322 | ||
326 | fsm->otg->state = new_state; | 323 | fsm->otg->state = new_state; |
324 | fsm->state_changed = 1; | ||
327 | return 0; | 325 | return 0; |
328 | } | 326 | } |
329 | 327 | ||
@@ -335,7 +333,7 @@ int otg_statemachine(struct otg_fsm *fsm) | |||
335 | mutex_lock(&fsm->lock); | 333 | mutex_lock(&fsm->lock); |
336 | 334 | ||
337 | state = fsm->otg->state; | 335 | state = fsm->otg->state; |
338 | state_changed = 0; | 336 | fsm->state_changed = 0; |
339 | /* State machine state change judgement */ | 337 | /* State machine state change judgement */ |
340 | 338 | ||
341 | switch (state) { | 339 | switch (state) { |
@@ -448,7 +446,7 @@ int otg_statemachine(struct otg_fsm *fsm) | |||
448 | } | 446 | } |
449 | mutex_unlock(&fsm->lock); | 447 | mutex_unlock(&fsm->lock); |
450 | 448 | ||
451 | VDBG("quit statemachine, changed = %d\n", state_changed); | 449 | VDBG("quit statemachine, changed = %d\n", fsm->state_changed); |
452 | return state_changed; | 450 | return fsm->state_changed; |
453 | } | 451 | } |
454 | EXPORT_SYMBOL_GPL(otg_statemachine); | 452 | EXPORT_SYMBOL_GPL(otg_statemachine); |
diff --git a/drivers/usb/core/buffer.c b/drivers/usb/core/buffer.c index 2741566ee4f2..98e39f91723a 100644 --- a/drivers/usb/core/buffer.c +++ b/drivers/usb/core/buffer.c | |||
@@ -122,6 +122,9 @@ void *hcd_buffer_alloc( | |||
122 | struct usb_hcd *hcd = bus_to_hcd(bus); | 122 | struct usb_hcd *hcd = bus_to_hcd(bus); |
123 | int i; | 123 | int i; |
124 | 124 | ||
125 | if (size == 0) | ||
126 | return NULL; | ||
127 | |||
125 | /* some USB hosts just use PIO */ | 128 | /* some USB hosts just use PIO */ |
126 | if (!IS_ENABLED(CONFIG_HAS_DMA) || | 129 | if (!IS_ENABLED(CONFIG_HAS_DMA) || |
127 | (!bus->controller->dma_mask && | 130 | (!bus->controller->dma_mask && |
diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c index 52c4461dfccd..e9f5043a2167 100644 --- a/drivers/usb/core/devio.c +++ b/drivers/usb/core/devio.c | |||
@@ -216,7 +216,7 @@ static void usbdev_vm_close(struct vm_area_struct *vma) | |||
216 | dec_usb_memory_use_count(usbm, &usbm->vma_use_count); | 216 | dec_usb_memory_use_count(usbm, &usbm->vma_use_count); |
217 | } | 217 | } |
218 | 218 | ||
219 | struct vm_operations_struct usbdev_vm_ops = { | 219 | static struct vm_operations_struct usbdev_vm_ops = { |
220 | .open = usbdev_vm_open, | 220 | .open = usbdev_vm_open, |
221 | .close = usbdev_vm_close | 221 | .close = usbdev_vm_close |
222 | }; | 222 | }; |
@@ -1316,10 +1316,11 @@ static int proc_getdriver(struct usb_dev_state *ps, void __user *arg) | |||
1316 | 1316 | ||
1317 | static int proc_connectinfo(struct usb_dev_state *ps, void __user *arg) | 1317 | static int proc_connectinfo(struct usb_dev_state *ps, void __user *arg) |
1318 | { | 1318 | { |
1319 | struct usbdevfs_connectinfo ci = { | 1319 | struct usbdevfs_connectinfo ci; |
1320 | .devnum = ps->dev->devnum, | 1320 | |
1321 | .slow = ps->dev->speed == USB_SPEED_LOW | 1321 | memset(&ci, 0, sizeof(ci)); |
1322 | }; | 1322 | ci.devnum = ps->dev->devnum; |
1323 | ci.slow = ps->dev->speed == USB_SPEED_LOW; | ||
1323 | 1324 | ||
1324 | if (copy_to_user(arg, &ci, sizeof(ci))) | 1325 | if (copy_to_user(arg, &ci, sizeof(ci))) |
1325 | return -EFAULT; | 1326 | return -EFAULT; |
diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c index 2057d91d8336..dadd1e8dfe09 100644 --- a/drivers/usb/core/driver.c +++ b/drivers/usb/core/driver.c | |||
@@ -284,7 +284,7 @@ static int usb_probe_interface(struct device *dev) | |||
284 | struct usb_device *udev = interface_to_usbdev(intf); | 284 | struct usb_device *udev = interface_to_usbdev(intf); |
285 | const struct usb_device_id *id; | 285 | const struct usb_device_id *id; |
286 | int error = -ENODEV; | 286 | int error = -ENODEV; |
287 | int lpm_disable_error; | 287 | int lpm_disable_error = -ENODEV; |
288 | 288 | ||
289 | dev_dbg(dev, "%s\n", __func__); | 289 | dev_dbg(dev, "%s\n", __func__); |
290 | 290 | ||
@@ -336,12 +336,14 @@ static int usb_probe_interface(struct device *dev) | |||
336 | * setting during probe, that should also be fine. usb_set_interface() | 336 | * setting during probe, that should also be fine. usb_set_interface() |
337 | * will attempt to disable LPM, and fail if it can't disable it. | 337 | * will attempt to disable LPM, and fail if it can't disable it. |
338 | */ | 338 | */ |
339 | lpm_disable_error = usb_unlocked_disable_lpm(udev); | 339 | if (driver->disable_hub_initiated_lpm) { |
340 | if (lpm_disable_error && driver->disable_hub_initiated_lpm) { | 340 | lpm_disable_error = usb_unlocked_disable_lpm(udev); |
341 | dev_err(&intf->dev, "%s Failed to disable LPM for driver %s\n.", | 341 | if (lpm_disable_error) { |
342 | __func__, driver->name); | 342 | dev_err(&intf->dev, "%s Failed to disable LPM for driver %s\n.", |
343 | error = lpm_disable_error; | 343 | __func__, driver->name); |
344 | goto err; | 344 | error = lpm_disable_error; |
345 | goto err; | ||
346 | } | ||
345 | } | 347 | } |
346 | 348 | ||
347 | /* Carry out a deferred switch to altsetting 0 */ | 349 | /* Carry out a deferred switch to altsetting 0 */ |
@@ -391,7 +393,8 @@ static int usb_unbind_interface(struct device *dev) | |||
391 | struct usb_interface *intf = to_usb_interface(dev); | 393 | struct usb_interface *intf = to_usb_interface(dev); |
392 | struct usb_host_endpoint *ep, **eps = NULL; | 394 | struct usb_host_endpoint *ep, **eps = NULL; |
393 | struct usb_device *udev; | 395 | struct usb_device *udev; |
394 | int i, j, error, r, lpm_disable_error; | 396 | int i, j, error, r; |
397 | int lpm_disable_error = -ENODEV; | ||
395 | 398 | ||
396 | intf->condition = USB_INTERFACE_UNBINDING; | 399 | intf->condition = USB_INTERFACE_UNBINDING; |
397 | 400 | ||
@@ -399,12 +402,13 @@ static int usb_unbind_interface(struct device *dev) | |||
399 | udev = interface_to_usbdev(intf); | 402 | udev = interface_to_usbdev(intf); |
400 | error = usb_autoresume_device(udev); | 403 | error = usb_autoresume_device(udev); |
401 | 404 | ||
402 | /* Hub-initiated LPM policy may change, so attempt to disable LPM until | 405 | /* If hub-initiated LPM policy may change, attempt to disable LPM until |
403 | * the driver is unbound. If LPM isn't disabled, that's fine because it | 406 | * the driver is unbound. If LPM isn't disabled, that's fine because it |
404 | * wouldn't be enabled unless all the bound interfaces supported | 407 | * wouldn't be enabled unless all the bound interfaces supported |
405 | * hub-initiated LPM. | 408 | * hub-initiated LPM. |
406 | */ | 409 | */ |
407 | lpm_disable_error = usb_unlocked_disable_lpm(udev); | 410 | if (driver->disable_hub_initiated_lpm) |
411 | lpm_disable_error = usb_unlocked_disable_lpm(udev); | ||
408 | 412 | ||
409 | /* | 413 | /* |
410 | * Terminate all URBs for this interface unless the driver | 414 | * Terminate all URBs for this interface unless the driver |
@@ -505,7 +509,7 @@ int usb_driver_claim_interface(struct usb_driver *driver, | |||
505 | struct device *dev; | 509 | struct device *dev; |
506 | struct usb_device *udev; | 510 | struct usb_device *udev; |
507 | int retval = 0; | 511 | int retval = 0; |
508 | int lpm_disable_error; | 512 | int lpm_disable_error = -ENODEV; |
509 | 513 | ||
510 | if (!iface) | 514 | if (!iface) |
511 | return -ENODEV; | 515 | return -ENODEV; |
@@ -526,12 +530,14 @@ int usb_driver_claim_interface(struct usb_driver *driver, | |||
526 | 530 | ||
527 | iface->condition = USB_INTERFACE_BOUND; | 531 | iface->condition = USB_INTERFACE_BOUND; |
528 | 532 | ||
529 | /* Disable LPM until this driver is bound. */ | 533 | /* See the comment about disabling LPM in usb_probe_interface(). */ |
530 | lpm_disable_error = usb_unlocked_disable_lpm(udev); | 534 | if (driver->disable_hub_initiated_lpm) { |
531 | if (lpm_disable_error && driver->disable_hub_initiated_lpm) { | 535 | lpm_disable_error = usb_unlocked_disable_lpm(udev); |
532 | dev_err(&iface->dev, "%s Failed to disable LPM for driver %s\n.", | 536 | if (lpm_disable_error) { |
533 | __func__, driver->name); | 537 | dev_err(&iface->dev, "%s Failed to disable LPM for driver %s\n.", |
534 | return -ENOMEM; | 538 | __func__, driver->name); |
539 | return -ENOMEM; | ||
540 | } | ||
535 | } | 541 | } |
536 | 542 | ||
537 | /* Claimed interfaces are initially inactive (suspended) and | 543 | /* Claimed interfaces are initially inactive (suspended) and |
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c index 2ca2cef7f681..34b837ae1ed7 100644 --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c | |||
@@ -994,7 +994,7 @@ static void usb_bus_init (struct usb_bus *bus) | |||
994 | bus->bandwidth_allocated = 0; | 994 | bus->bandwidth_allocated = 0; |
995 | bus->bandwidth_int_reqs = 0; | 995 | bus->bandwidth_int_reqs = 0; |
996 | bus->bandwidth_isoc_reqs = 0; | 996 | bus->bandwidth_isoc_reqs = 0; |
997 | mutex_init(&bus->usb_address0_mutex); | 997 | mutex_init(&bus->devnum_next_mutex); |
998 | } | 998 | } |
999 | 999 | ||
1000 | /*-------------------------------------------------------------------------*/ | 1000 | /*-------------------------------------------------------------------------*/ |
@@ -1118,6 +1118,7 @@ static int register_root_hub(struct usb_hcd *hcd) | |||
1118 | /* Did the HC die before the root hub was registered? */ | 1118 | /* Did the HC die before the root hub was registered? */ |
1119 | if (HCD_DEAD(hcd)) | 1119 | if (HCD_DEAD(hcd)) |
1120 | usb_hc_died (hcd); /* This time clean up */ | 1120 | usb_hc_died (hcd); /* This time clean up */ |
1121 | usb_dev->dev.of_node = parent_dev->of_node; | ||
1121 | } | 1122 | } |
1122 | mutex_unlock(&usb_bus_idr_lock); | 1123 | mutex_unlock(&usb_bus_idr_lock); |
1123 | 1124 | ||
@@ -2521,6 +2522,14 @@ struct usb_hcd *usb_create_shared_hcd(const struct hc_driver *driver, | |||
2521 | return NULL; | 2522 | return NULL; |
2522 | } | 2523 | } |
2523 | if (primary_hcd == NULL) { | 2524 | if (primary_hcd == NULL) { |
2525 | hcd->address0_mutex = kmalloc(sizeof(*hcd->address0_mutex), | ||
2526 | GFP_KERNEL); | ||
2527 | if (!hcd->address0_mutex) { | ||
2528 | kfree(hcd); | ||
2529 | dev_dbg(dev, "hcd address0 mutex alloc failed\n"); | ||
2530 | return NULL; | ||
2531 | } | ||
2532 | mutex_init(hcd->address0_mutex); | ||
2524 | hcd->bandwidth_mutex = kmalloc(sizeof(*hcd->bandwidth_mutex), | 2533 | hcd->bandwidth_mutex = kmalloc(sizeof(*hcd->bandwidth_mutex), |
2525 | GFP_KERNEL); | 2534 | GFP_KERNEL); |
2526 | if (!hcd->bandwidth_mutex) { | 2535 | if (!hcd->bandwidth_mutex) { |
@@ -2532,6 +2541,7 @@ struct usb_hcd *usb_create_shared_hcd(const struct hc_driver *driver, | |||
2532 | dev_set_drvdata(dev, hcd); | 2541 | dev_set_drvdata(dev, hcd); |
2533 | } else { | 2542 | } else { |
2534 | mutex_lock(&usb_port_peer_mutex); | 2543 | mutex_lock(&usb_port_peer_mutex); |
2544 | hcd->address0_mutex = primary_hcd->address0_mutex; | ||
2535 | hcd->bandwidth_mutex = primary_hcd->bandwidth_mutex; | 2545 | hcd->bandwidth_mutex = primary_hcd->bandwidth_mutex; |
2536 | hcd->primary_hcd = primary_hcd; | 2546 | hcd->primary_hcd = primary_hcd; |
2537 | primary_hcd->primary_hcd = primary_hcd; | 2547 | primary_hcd->primary_hcd = primary_hcd; |
@@ -2598,8 +2608,10 @@ static void hcd_release(struct kref *kref) | |||
2598 | struct usb_hcd *hcd = container_of (kref, struct usb_hcd, kref); | 2608 | struct usb_hcd *hcd = container_of (kref, struct usb_hcd, kref); |
2599 | 2609 | ||
2600 | mutex_lock(&usb_port_peer_mutex); | 2610 | mutex_lock(&usb_port_peer_mutex); |
2601 | if (usb_hcd_is_primary_hcd(hcd)) | 2611 | if (usb_hcd_is_primary_hcd(hcd)) { |
2612 | kfree(hcd->address0_mutex); | ||
2602 | kfree(hcd->bandwidth_mutex); | 2613 | kfree(hcd->bandwidth_mutex); |
2614 | } | ||
2603 | if (hcd->shared_hcd) { | 2615 | if (hcd->shared_hcd) { |
2604 | struct usb_hcd *peer = hcd->shared_hcd; | 2616 | struct usb_hcd *peer = hcd->shared_hcd; |
2605 | 2617 | ||
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index 38cc4bae0a82..bee13517676f 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c | |||
@@ -104,6 +104,8 @@ static int usb_reset_and_verify_device(struct usb_device *udev); | |||
104 | 104 | ||
105 | static inline char *portspeed(struct usb_hub *hub, int portstatus) | 105 | static inline char *portspeed(struct usb_hub *hub, int portstatus) |
106 | { | 106 | { |
107 | if (hub_is_superspeedplus(hub->hdev)) | ||
108 | return "10.0 Gb/s"; | ||
107 | if (hub_is_superspeed(hub->hdev)) | 109 | if (hub_is_superspeed(hub->hdev)) |
108 | return "5.0 Gb/s"; | 110 | return "5.0 Gb/s"; |
109 | if (portstatus & USB_PORT_STAT_HIGH_SPEED) | 111 | if (portstatus & USB_PORT_STAT_HIGH_SPEED) |
@@ -2080,7 +2082,7 @@ static void choose_devnum(struct usb_device *udev) | |||
2080 | struct usb_bus *bus = udev->bus; | 2082 | struct usb_bus *bus = udev->bus; |
2081 | 2083 | ||
2082 | /* be safe when more hub events are proceed in parallel */ | 2084 | /* be safe when more hub events are proceed in parallel */ |
2083 | mutex_lock(&bus->usb_address0_mutex); | 2085 | mutex_lock(&bus->devnum_next_mutex); |
2084 | if (udev->wusb) { | 2086 | if (udev->wusb) { |
2085 | devnum = udev->portnum + 1; | 2087 | devnum = udev->portnum + 1; |
2086 | BUG_ON(test_bit(devnum, bus->devmap.devicemap)); | 2088 | BUG_ON(test_bit(devnum, bus->devmap.devicemap)); |
@@ -2098,7 +2100,7 @@ static void choose_devnum(struct usb_device *udev) | |||
2098 | set_bit(devnum, bus->devmap.devicemap); | 2100 | set_bit(devnum, bus->devmap.devicemap); |
2099 | udev->devnum = devnum; | 2101 | udev->devnum = devnum; |
2100 | } | 2102 | } |
2101 | mutex_unlock(&bus->usb_address0_mutex); | 2103 | mutex_unlock(&bus->devnum_next_mutex); |
2102 | } | 2104 | } |
2103 | 2105 | ||
2104 | static void release_devnum(struct usb_device *udev) | 2106 | static void release_devnum(struct usb_device *udev) |
@@ -4364,7 +4366,7 @@ hub_port_init(struct usb_hub *hub, struct usb_device *udev, int port1, | |||
4364 | if (oldspeed == USB_SPEED_LOW) | 4366 | if (oldspeed == USB_SPEED_LOW) |
4365 | delay = HUB_LONG_RESET_TIME; | 4367 | delay = HUB_LONG_RESET_TIME; |
4366 | 4368 | ||
4367 | mutex_lock(&hdev->bus->usb_address0_mutex); | 4369 | mutex_lock(hcd->address0_mutex); |
4368 | 4370 | ||
4369 | /* Reset the device; full speed may morph to high speed */ | 4371 | /* Reset the device; full speed may morph to high speed */ |
4370 | /* FIXME a USB 2.0 device may morph into SuperSpeed on reset. */ | 4372 | /* FIXME a USB 2.0 device may morph into SuperSpeed on reset. */ |
@@ -4650,7 +4652,7 @@ fail: | |||
4650 | hub_port_disable(hub, port1, 0); | 4652 | hub_port_disable(hub, port1, 0); |
4651 | update_devnum(udev, devnum); /* for disconnect processing */ | 4653 | update_devnum(udev, devnum); /* for disconnect processing */ |
4652 | } | 4654 | } |
4653 | mutex_unlock(&hdev->bus->usb_address0_mutex); | 4655 | mutex_unlock(hcd->address0_mutex); |
4654 | return retval; | 4656 | return retval; |
4655 | } | 4657 | } |
4656 | 4658 | ||
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c index 8e641b5893ed..ea681f157368 100644 --- a/drivers/usb/core/message.c +++ b/drivers/usb/core/message.c | |||
@@ -302,9 +302,10 @@ static void sg_complete(struct urb *urb) | |||
302 | */ | 302 | */ |
303 | spin_unlock(&io->lock); | 303 | spin_unlock(&io->lock); |
304 | for (i = 0, found = 0; i < io->entries; i++) { | 304 | for (i = 0, found = 0; i < io->entries; i++) { |
305 | if (!io->urbs[i] || !io->urbs[i]->dev) | 305 | if (!io->urbs[i]) |
306 | continue; | 306 | continue; |
307 | if (found) { | 307 | if (found) { |
308 | usb_block_urb(io->urbs[i]); | ||
308 | retval = usb_unlink_urb(io->urbs[i]); | 309 | retval = usb_unlink_urb(io->urbs[i]); |
309 | if (retval != -EINPROGRESS && | 310 | if (retval != -EINPROGRESS && |
310 | retval != -ENODEV && | 311 | retval != -ENODEV && |
@@ -515,12 +516,10 @@ void usb_sg_wait(struct usb_sg_request *io) | |||
515 | int retval; | 516 | int retval; |
516 | 517 | ||
517 | io->urbs[i]->dev = io->dev; | 518 | io->urbs[i]->dev = io->dev; |
518 | retval = usb_submit_urb(io->urbs[i], GFP_ATOMIC); | ||
519 | |||
520 | /* after we submit, let completions or cancellations fire; | ||
521 | * we handshake using io->status. | ||
522 | */ | ||
523 | spin_unlock_irq(&io->lock); | 519 | spin_unlock_irq(&io->lock); |
520 | |||
521 | retval = usb_submit_urb(io->urbs[i], GFP_NOIO); | ||
522 | |||
524 | switch (retval) { | 523 | switch (retval) { |
525 | /* maybe we retrying will recover */ | 524 | /* maybe we retrying will recover */ |
526 | case -ENXIO: /* hc didn't queue this one */ | 525 | case -ENXIO: /* hc didn't queue this one */ |
@@ -578,31 +577,28 @@ EXPORT_SYMBOL_GPL(usb_sg_wait); | |||
578 | void usb_sg_cancel(struct usb_sg_request *io) | 577 | void usb_sg_cancel(struct usb_sg_request *io) |
579 | { | 578 | { |
580 | unsigned long flags; | 579 | unsigned long flags; |
580 | int i, retval; | ||
581 | 581 | ||
582 | spin_lock_irqsave(&io->lock, flags); | 582 | spin_lock_irqsave(&io->lock, flags); |
583 | if (io->status) { | ||
584 | spin_unlock_irqrestore(&io->lock, flags); | ||
585 | return; | ||
586 | } | ||
587 | /* shut everything down */ | ||
588 | io->status = -ECONNRESET; | ||
589 | spin_unlock_irqrestore(&io->lock, flags); | ||
583 | 590 | ||
584 | /* shut everything down, if it didn't already */ | 591 | for (i = io->entries - 1; i >= 0; --i) { |
585 | if (!io->status) { | 592 | usb_block_urb(io->urbs[i]); |
586 | int i; | ||
587 | |||
588 | io->status = -ECONNRESET; | ||
589 | spin_unlock(&io->lock); | ||
590 | for (i = 0; i < io->entries; i++) { | ||
591 | int retval; | ||
592 | 593 | ||
593 | if (!io->urbs[i]->dev) | 594 | retval = usb_unlink_urb(io->urbs[i]); |
594 | continue; | 595 | if (retval != -EINPROGRESS |
595 | retval = usb_unlink_urb(io->urbs[i]); | 596 | && retval != -ENODEV |
596 | if (retval != -EINPROGRESS | 597 | && retval != -EBUSY |
597 | && retval != -ENODEV | 598 | && retval != -EIDRM) |
598 | && retval != -EBUSY | 599 | dev_warn(&io->dev->dev, "%s, unlink --> %d\n", |
599 | && retval != -EIDRM) | 600 | __func__, retval); |
600 | dev_warn(&io->dev->dev, "%s, unlink --> %d\n", | ||
601 | __func__, retval); | ||
602 | } | ||
603 | spin_lock(&io->lock); | ||
604 | } | 601 | } |
605 | spin_unlock_irqrestore(&io->lock, flags); | ||
606 | } | 602 | } |
607 | EXPORT_SYMBOL_GPL(usb_sg_cancel); | 603 | EXPORT_SYMBOL_GPL(usb_sg_cancel); |
608 | 604 | ||
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c index 479187c32571..5e80697ef952 100644 --- a/drivers/usb/core/usb.c +++ b/drivers/usb/core/usb.c | |||
@@ -466,7 +466,6 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent, | |||
466 | dev->route = 0; | 466 | dev->route = 0; |
467 | 467 | ||
468 | dev->dev.parent = bus->controller; | 468 | dev->dev.parent = bus->controller; |
469 | dev->dev.of_node = bus->controller->of_node; | ||
470 | dev_set_name(&dev->dev, "usb%d", bus->busnum); | 469 | dev_set_name(&dev->dev, "usb%d", bus->busnum); |
471 | root_hub = 1; | 470 | root_hub = 1; |
472 | } else { | 471 | } else { |
diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index 818f158232bb..4c5e3005e1dc 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c | |||
@@ -2425,6 +2425,9 @@ static irqreturn_t dwc2_hsotg_irq(int irq, void *pw) | |||
2425 | u32 gintsts; | 2425 | u32 gintsts; |
2426 | u32 gintmsk; | 2426 | u32 gintmsk; |
2427 | 2427 | ||
2428 | if (!dwc2_is_device_mode(hsotg)) | ||
2429 | return IRQ_NONE; | ||
2430 | |||
2428 | spin_lock(&hsotg->lock); | 2431 | spin_lock(&hsotg->lock); |
2429 | irq_retry: | 2432 | irq_retry: |
2430 | gintsts = dwc2_readl(hsotg->regs + GINTSTS); | 2433 | gintsts = dwc2_readl(hsotg->regs + GINTSTS); |
@@ -2631,7 +2634,10 @@ static int dwc2_hsotg_ep_enable(struct usb_ep *ep, | |||
2631 | desc->wMaxPacketSize, desc->bInterval); | 2634 | desc->wMaxPacketSize, desc->bInterval); |
2632 | 2635 | ||
2633 | /* not to be called for EP0 */ | 2636 | /* not to be called for EP0 */ |
2634 | WARN_ON(index == 0); | 2637 | if (index == 0) { |
2638 | dev_err(hsotg->dev, "%s: called for EP 0\n", __func__); | ||
2639 | return -EINVAL; | ||
2640 | } | ||
2635 | 2641 | ||
2636 | dir_in = (desc->bEndpointAddress & USB_ENDPOINT_DIR_MASK) ? 1 : 0; | 2642 | dir_in = (desc->bEndpointAddress & USB_ENDPOINT_DIR_MASK) ? 1 : 0; |
2637 | if (dir_in != hs_ep->dir_in) { | 2643 | if (dir_in != hs_ep->dir_in) { |
diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c index 1f6255131857..2df3d04d26f5 100644 --- a/drivers/usb/dwc2/hcd.c +++ b/drivers/usb/dwc2/hcd.c | |||
@@ -4703,6 +4703,7 @@ fail2: | |||
4703 | spin_unlock_irqrestore(&hsotg->lock, flags); | 4703 | spin_unlock_irqrestore(&hsotg->lock, flags); |
4704 | urb->hcpriv = NULL; | 4704 | urb->hcpriv = NULL; |
4705 | kfree(qtd); | 4705 | kfree(qtd); |
4706 | qtd = NULL; | ||
4706 | fail1: | 4707 | fail1: |
4707 | if (qh_allocated) { | 4708 | if (qh_allocated) { |
4708 | struct dwc2_qtd *qtd2, *qtd2_tmp; | 4709 | struct dwc2_qtd *qtd2, *qtd2_tmp; |
diff --git a/drivers/usb/dwc2/hcd.h b/drivers/usb/dwc2/hcd.h index 89fa26cb25f4..7758bfb644ff 100644 --- a/drivers/usb/dwc2/hcd.h +++ b/drivers/usb/dwc2/hcd.h | |||
@@ -552,6 +552,7 @@ static inline void dwc2_hcd_qtd_unlink_and_free(struct dwc2_hsotg *hsotg, | |||
552 | { | 552 | { |
553 | list_del(&qtd->qtd_list_entry); | 553 | list_del(&qtd->qtd_list_entry); |
554 | kfree(qtd); | 554 | kfree(qtd); |
555 | qtd = NULL; | ||
555 | } | 556 | } |
556 | 557 | ||
557 | /* Descriptor DMA support functions */ | 558 | /* Descriptor DMA support functions */ |
diff --git a/drivers/usb/dwc2/hcd_queue.c b/drivers/usb/dwc2/hcd_queue.c index 7f634fd771c7..b5c7793a2df2 100644 --- a/drivers/usb/dwc2/hcd_queue.c +++ b/drivers/usb/dwc2/hcd_queue.c | |||
@@ -1709,7 +1709,8 @@ void dwc2_hcd_qh_unlink(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh) | |||
1709 | 1709 | ||
1710 | dwc2_deschedule_periodic(hsotg, qh); | 1710 | dwc2_deschedule_periodic(hsotg, qh); |
1711 | hsotg->periodic_qh_count--; | 1711 | hsotg->periodic_qh_count--; |
1712 | if (!hsotg->periodic_qh_count) { | 1712 | if (!hsotg->periodic_qh_count && |
1713 | hsotg->core_params->dma_desc_enable <= 0) { | ||
1713 | intr_mask = dwc2_readl(hsotg->regs + GINTMSK); | 1714 | intr_mask = dwc2_readl(hsotg->regs + GINTMSK); |
1714 | intr_mask &= ~GINTSTS_SOF; | 1715 | intr_mask &= ~GINTSTS_SOF; |
1715 | dwc2_writel(intr_mask, hsotg->regs + GINTMSK); | 1716 | dwc2_writel(intr_mask, hsotg->regs + GINTMSK); |
diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c index 88629bed6614..fc6f5251de5d 100644 --- a/drivers/usb/dwc2/platform.c +++ b/drivers/usb/dwc2/platform.c | |||
@@ -562,7 +562,7 @@ static int dwc2_driver_probe(struct platform_device *dev) | |||
562 | 562 | ||
563 | retval = dwc2_get_dr_mode(hsotg); | 563 | retval = dwc2_get_dr_mode(hsotg); |
564 | if (retval) | 564 | if (retval) |
565 | return retval; | 565 | goto error; |
566 | 566 | ||
567 | /* | 567 | /* |
568 | * Reset before dwc2_get_hwparams() then it could get power-on real | 568 | * Reset before dwc2_get_hwparams() then it could get power-on real |
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 34277ced26bd..a590cd225bb7 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c | |||
@@ -60,6 +60,20 @@ void dwc3_set_mode(struct dwc3 *dwc, u32 mode) | |||
60 | dwc3_writel(dwc->regs, DWC3_GCTL, reg); | 60 | dwc3_writel(dwc->regs, DWC3_GCTL, reg); |
61 | } | 61 | } |
62 | 62 | ||
63 | u32 dwc3_core_fifo_space(struct dwc3_ep *dep, u8 type) | ||
64 | { | ||
65 | struct dwc3 *dwc = dep->dwc; | ||
66 | u32 reg; | ||
67 | |||
68 | dwc3_writel(dwc->regs, DWC3_GDBGFIFOSPACE, | ||
69 | DWC3_GDBGFIFOSPACE_NUM(dep->number) | | ||
70 | DWC3_GDBGFIFOSPACE_TYPE(type)); | ||
71 | |||
72 | reg = dwc3_readl(dwc->regs, DWC3_GDBGFIFOSPACE); | ||
73 | |||
74 | return DWC3_GDBGFIFOSPACE_SPACE_AVAILABLE(reg); | ||
75 | } | ||
76 | |||
63 | /** | 77 | /** |
64 | * dwc3_core_soft_reset - Issues core soft reset and PHY reset | 78 | * dwc3_core_soft_reset - Issues core soft reset and PHY reset |
65 | * @dwc: pointer to our context structure | 79 | * @dwc: pointer to our context structure |
@@ -203,13 +217,10 @@ static struct dwc3_event_buffer *dwc3_alloc_one_event_buffer(struct dwc3 *dwc, | |||
203 | static void dwc3_free_event_buffers(struct dwc3 *dwc) | 217 | static void dwc3_free_event_buffers(struct dwc3 *dwc) |
204 | { | 218 | { |
205 | struct dwc3_event_buffer *evt; | 219 | struct dwc3_event_buffer *evt; |
206 | int i; | ||
207 | 220 | ||
208 | for (i = 0; i < dwc->num_event_buffers; i++) { | 221 | evt = dwc->ev_buf; |
209 | evt = dwc->ev_buffs[i]; | 222 | if (evt) |
210 | if (evt) | 223 | dwc3_free_one_event_buffer(dwc, evt); |
211 | dwc3_free_one_event_buffer(dwc, evt); | ||
212 | } | ||
213 | } | 224 | } |
214 | 225 | ||
215 | /** | 226 | /** |
@@ -222,27 +233,14 @@ static void dwc3_free_event_buffers(struct dwc3 *dwc) | |||
222 | */ | 233 | */ |
223 | static int dwc3_alloc_event_buffers(struct dwc3 *dwc, unsigned length) | 234 | static int dwc3_alloc_event_buffers(struct dwc3 *dwc, unsigned length) |
224 | { | 235 | { |
225 | int num; | 236 | struct dwc3_event_buffer *evt; |
226 | int i; | ||
227 | |||
228 | num = DWC3_NUM_INT(dwc->hwparams.hwparams1); | ||
229 | dwc->num_event_buffers = num; | ||
230 | |||
231 | dwc->ev_buffs = devm_kzalloc(dwc->dev, sizeof(*dwc->ev_buffs) * num, | ||
232 | GFP_KERNEL); | ||
233 | if (!dwc->ev_buffs) | ||
234 | return -ENOMEM; | ||
235 | |||
236 | for (i = 0; i < num; i++) { | ||
237 | struct dwc3_event_buffer *evt; | ||
238 | 237 | ||
239 | evt = dwc3_alloc_one_event_buffer(dwc, length); | 238 | evt = dwc3_alloc_one_event_buffer(dwc, length); |
240 | if (IS_ERR(evt)) { | 239 | if (IS_ERR(evt)) { |
241 | dev_err(dwc->dev, "can't allocate event buffer\n"); | 240 | dev_err(dwc->dev, "can't allocate event buffer\n"); |
242 | return PTR_ERR(evt); | 241 | return PTR_ERR(evt); |
243 | } | ||
244 | dwc->ev_buffs[i] = evt; | ||
245 | } | 242 | } |
243 | dwc->ev_buf = evt; | ||
246 | 244 | ||
247 | return 0; | 245 | return 0; |
248 | } | 246 | } |
@@ -256,25 +254,22 @@ static int dwc3_alloc_event_buffers(struct dwc3 *dwc, unsigned length) | |||
256 | static int dwc3_event_buffers_setup(struct dwc3 *dwc) | 254 | static int dwc3_event_buffers_setup(struct dwc3 *dwc) |
257 | { | 255 | { |
258 | struct dwc3_event_buffer *evt; | 256 | struct dwc3_event_buffer *evt; |
259 | int n; | ||
260 | 257 | ||
261 | for (n = 0; n < dwc->num_event_buffers; n++) { | 258 | evt = dwc->ev_buf; |
262 | evt = dwc->ev_buffs[n]; | 259 | dwc3_trace(trace_dwc3_core, |
263 | dwc3_trace(trace_dwc3_core, | 260 | "Event buf %p dma %08llx length %d\n", |
264 | "Event buf %p dma %08llx length %d\n", | 261 | evt->buf, (unsigned long long) evt->dma, |
265 | evt->buf, (unsigned long long) evt->dma, | 262 | evt->length); |
266 | evt->length); | 263 | |
267 | 264 | evt->lpos = 0; | |
268 | evt->lpos = 0; | 265 | |
269 | 266 | dwc3_writel(dwc->regs, DWC3_GEVNTADRLO(0), | |
270 | dwc3_writel(dwc->regs, DWC3_GEVNTADRLO(n), | 267 | lower_32_bits(evt->dma)); |
271 | lower_32_bits(evt->dma)); | 268 | dwc3_writel(dwc->regs, DWC3_GEVNTADRHI(0), |
272 | dwc3_writel(dwc->regs, DWC3_GEVNTADRHI(n), | 269 | upper_32_bits(evt->dma)); |
273 | upper_32_bits(evt->dma)); | 270 | dwc3_writel(dwc->regs, DWC3_GEVNTSIZ(0), |
274 | dwc3_writel(dwc->regs, DWC3_GEVNTSIZ(n), | 271 | DWC3_GEVNTSIZ_SIZE(evt->length)); |
275 | DWC3_GEVNTSIZ_SIZE(evt->length)); | 272 | dwc3_writel(dwc->regs, DWC3_GEVNTCOUNT(0), 0); |
276 | dwc3_writel(dwc->regs, DWC3_GEVNTCOUNT(n), 0); | ||
277 | } | ||
278 | 273 | ||
279 | return 0; | 274 | return 0; |
280 | } | 275 | } |
@@ -282,19 +277,16 @@ static int dwc3_event_buffers_setup(struct dwc3 *dwc) | |||
282 | static void dwc3_event_buffers_cleanup(struct dwc3 *dwc) | 277 | static void dwc3_event_buffers_cleanup(struct dwc3 *dwc) |
283 | { | 278 | { |
284 | struct dwc3_event_buffer *evt; | 279 | struct dwc3_event_buffer *evt; |
285 | int n; | ||
286 | 280 | ||
287 | for (n = 0; n < dwc->num_event_buffers; n++) { | 281 | evt = dwc->ev_buf; |
288 | evt = dwc->ev_buffs[n]; | ||
289 | 282 | ||
290 | evt->lpos = 0; | 283 | evt->lpos = 0; |
291 | 284 | ||
292 | dwc3_writel(dwc->regs, DWC3_GEVNTADRLO(n), 0); | 285 | dwc3_writel(dwc->regs, DWC3_GEVNTADRLO(0), 0); |
293 | dwc3_writel(dwc->regs, DWC3_GEVNTADRHI(n), 0); | 286 | dwc3_writel(dwc->regs, DWC3_GEVNTADRHI(0), 0); |
294 | dwc3_writel(dwc->regs, DWC3_GEVNTSIZ(n), DWC3_GEVNTSIZ_INTMASK | 287 | dwc3_writel(dwc->regs, DWC3_GEVNTSIZ(0), DWC3_GEVNTSIZ_INTMASK |
295 | | DWC3_GEVNTSIZ_SIZE(0)); | 288 | | DWC3_GEVNTSIZ_SIZE(0)); |
296 | dwc3_writel(dwc->regs, DWC3_GEVNTCOUNT(n), 0); | 289 | dwc3_writel(dwc->regs, DWC3_GEVNTCOUNT(0), 0); |
297 | } | ||
298 | } | 290 | } |
299 | 291 | ||
300 | static int dwc3_alloc_scratch_buffers(struct dwc3 *dwc) | 292 | static int dwc3_alloc_scratch_buffers(struct dwc3 *dwc) |
@@ -434,6 +426,9 @@ static int dwc3_phy_setup(struct dwc3 *dwc) | |||
434 | if (dwc->u2ss_inp3_quirk) | 426 | if (dwc->u2ss_inp3_quirk) |
435 | reg |= DWC3_GUSB3PIPECTL_U2SSINP3OK; | 427 | reg |= DWC3_GUSB3PIPECTL_U2SSINP3OK; |
436 | 428 | ||
429 | if (dwc->dis_rxdet_inp3_quirk) | ||
430 | reg |= DWC3_GUSB3PIPECTL_DISRXDETINP3; | ||
431 | |||
437 | if (dwc->req_p1p2p3_quirk) | 432 | if (dwc->req_p1p2p3_quirk) |
438 | reg |= DWC3_GUSB3PIPECTL_REQP1P2P3; | 433 | reg |= DWC3_GUSB3PIPECTL_REQP1P2P3; |
439 | 434 | ||
@@ -882,9 +877,6 @@ static int dwc3_probe(struct platform_device *pdev) | |||
882 | dwc->usb3_lpm_capable = device_property_read_bool(dev, | 877 | dwc->usb3_lpm_capable = device_property_read_bool(dev, |
883 | "snps,usb3_lpm_capable"); | 878 | "snps,usb3_lpm_capable"); |
884 | 879 | ||
885 | dwc->needs_fifo_resize = device_property_read_bool(dev, | ||
886 | "tx-fifo-resize"); | ||
887 | |||
888 | dwc->disable_scramble_quirk = device_property_read_bool(dev, | 880 | dwc->disable_scramble_quirk = device_property_read_bool(dev, |
889 | "snps,disable_scramble_quirk"); | 881 | "snps,disable_scramble_quirk"); |
890 | dwc->u2exit_lfps_quirk = device_property_read_bool(dev, | 882 | dwc->u2exit_lfps_quirk = device_property_read_bool(dev, |
@@ -907,6 +899,8 @@ static int dwc3_probe(struct platform_device *pdev) | |||
907 | "snps,dis_u2_susphy_quirk"); | 899 | "snps,dis_u2_susphy_quirk"); |
908 | dwc->dis_enblslpm_quirk = device_property_read_bool(dev, | 900 | dwc->dis_enblslpm_quirk = device_property_read_bool(dev, |
909 | "snps,dis_enblslpm_quirk"); | 901 | "snps,dis_enblslpm_quirk"); |
902 | dwc->dis_rxdet_inp3_quirk = device_property_read_bool(dev, | ||
903 | "snps,dis_rxdet_inp3_quirk"); | ||
910 | 904 | ||
911 | dwc->tx_de_emphasis_quirk = device_property_read_bool(dev, | 905 | dwc->tx_de_emphasis_quirk = device_property_read_bool(dev, |
912 | "snps,tx_de_emphasis_quirk"); | 906 | "snps,tx_de_emphasis_quirk"); |
@@ -926,7 +920,6 @@ static int dwc3_probe(struct platform_device *pdev) | |||
926 | if (pdata->hird_threshold) | 920 | if (pdata->hird_threshold) |
927 | hird_threshold = pdata->hird_threshold; | 921 | hird_threshold = pdata->hird_threshold; |
928 | 922 | ||
929 | dwc->needs_fifo_resize = pdata->tx_fifo_resize; | ||
930 | dwc->usb3_lpm_capable = pdata->usb3_lpm_capable; | 923 | dwc->usb3_lpm_capable = pdata->usb3_lpm_capable; |
931 | dwc->dr_mode = pdata->dr_mode; | 924 | dwc->dr_mode = pdata->dr_mode; |
932 | 925 | ||
@@ -941,6 +934,7 @@ static int dwc3_probe(struct platform_device *pdev) | |||
941 | dwc->dis_u3_susphy_quirk = pdata->dis_u3_susphy_quirk; | 934 | dwc->dis_u3_susphy_quirk = pdata->dis_u3_susphy_quirk; |
942 | dwc->dis_u2_susphy_quirk = pdata->dis_u2_susphy_quirk; | 935 | dwc->dis_u2_susphy_quirk = pdata->dis_u2_susphy_quirk; |
943 | dwc->dis_enblslpm_quirk = pdata->dis_enblslpm_quirk; | 936 | dwc->dis_enblslpm_quirk = pdata->dis_enblslpm_quirk; |
937 | dwc->dis_rxdet_inp3_quirk = pdata->dis_rxdet_inp3_quirk; | ||
944 | 938 | ||
945 | dwc->tx_de_emphasis_quirk = pdata->tx_de_emphasis_quirk; | 939 | dwc->tx_de_emphasis_quirk = pdata->tx_de_emphasis_quirk; |
946 | if (pdata->tx_de_emphasis) | 940 | if (pdata->tx_de_emphasis) |
@@ -1050,19 +1044,11 @@ static int dwc3_probe(struct platform_device *pdev) | |||
1050 | if (ret) | 1044 | if (ret) |
1051 | goto err5; | 1045 | goto err5; |
1052 | 1046 | ||
1053 | ret = dwc3_debugfs_init(dwc); | 1047 | dwc3_debugfs_init(dwc); |
1054 | if (ret) { | ||
1055 | dev_err(dev, "failed to initialize debugfs\n"); | ||
1056 | goto err6; | ||
1057 | } | ||
1058 | |||
1059 | pm_runtime_allow(dev); | 1048 | pm_runtime_allow(dev); |
1060 | 1049 | ||
1061 | return 0; | 1050 | return 0; |
1062 | 1051 | ||
1063 | err6: | ||
1064 | dwc3_core_exit_mode(dwc); | ||
1065 | |||
1066 | err5: | 1052 | err5: |
1067 | dwc3_event_buffers_cleanup(dwc); | 1053 | dwc3_event_buffers_cleanup(dwc); |
1068 | 1054 | ||
diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h index 6254b2ff9080..7ddf9449a063 100644 --- a/drivers/usb/dwc3/core.h +++ b/drivers/usb/dwc3/core.h | |||
@@ -152,6 +152,24 @@ | |||
152 | 152 | ||
153 | /* Bit fields */ | 153 | /* Bit fields */ |
154 | 154 | ||
155 | /* Global Debug Queue/FIFO Space Available Register */ | ||
156 | #define DWC3_GDBGFIFOSPACE_NUM(n) ((n) & 0x1f) | ||
157 | #define DWC3_GDBGFIFOSPACE_TYPE(n) (((n) << 5) & 0x1e0) | ||
158 | #define DWC3_GDBGFIFOSPACE_SPACE_AVAILABLE(n) (((n) >> 16) & 0xffff) | ||
159 | |||
160 | #define DWC3_TXFIFOQ 1 | ||
161 | #define DWC3_RXFIFOQ 3 | ||
162 | #define DWC3_TXREQQ 5 | ||
163 | #define DWC3_RXREQQ 7 | ||
164 | #define DWC3_RXINFOQ 9 | ||
165 | #define DWC3_DESCFETCHQ 13 | ||
166 | #define DWC3_EVENTQ 15 | ||
167 | |||
168 | /* Global RX Threshold Configuration Register */ | ||
169 | #define DWC3_GRXTHRCFG_MAXRXBURSTSIZE(n) (((n) & 0x1f) << 19) | ||
170 | #define DWC3_GRXTHRCFG_RXPKTCNT(n) (((n) & 0xf) << 24) | ||
171 | #define DWC3_GRXTHRCFG_PKTCNTSEL (1 << 29) | ||
172 | |||
155 | /* Global Configuration Register */ | 173 | /* Global Configuration Register */ |
156 | #define DWC3_GCTL_PWRDNSCALE(n) ((n) << 19) | 174 | #define DWC3_GCTL_PWRDNSCALE(n) ((n) << 19) |
157 | #define DWC3_GCTL_U2RSTECN (1 << 16) | 175 | #define DWC3_GCTL_U2RSTECN (1 << 16) |
@@ -193,6 +211,7 @@ | |||
193 | /* Global USB3 PIPE Control Register */ | 211 | /* Global USB3 PIPE Control Register */ |
194 | #define DWC3_GUSB3PIPECTL_PHYSOFTRST (1 << 31) | 212 | #define DWC3_GUSB3PIPECTL_PHYSOFTRST (1 << 31) |
195 | #define DWC3_GUSB3PIPECTL_U2SSINP3OK (1 << 29) | 213 | #define DWC3_GUSB3PIPECTL_U2SSINP3OK (1 << 29) |
214 | #define DWC3_GUSB3PIPECTL_DISRXDETINP3 (1 << 28) | ||
196 | #define DWC3_GUSB3PIPECTL_REQP1P2P3 (1 << 24) | 215 | #define DWC3_GUSB3PIPECTL_REQP1P2P3 (1 << 24) |
197 | #define DWC3_GUSB3PIPECTL_DEP1P2P3(n) ((n) << 19) | 216 | #define DWC3_GUSB3PIPECTL_DEP1P2P3(n) ((n) << 19) |
198 | #define DWC3_GUSB3PIPECTL_DEP1P2P3_MASK DWC3_GUSB3PIPECTL_DEP1P2P3(7) | 217 | #define DWC3_GUSB3PIPECTL_DEP1P2P3_MASK DWC3_GUSB3PIPECTL_DEP1P2P3(7) |
@@ -257,6 +276,9 @@ | |||
257 | #define DWC3_DCFG_LOWSPEED (2 << 0) | 276 | #define DWC3_DCFG_LOWSPEED (2 << 0) |
258 | #define DWC3_DCFG_FULLSPEED1 (3 << 0) | 277 | #define DWC3_DCFG_FULLSPEED1 (3 << 0) |
259 | 278 | ||
279 | #define DWC3_DCFG_NUMP_SHIFT 17 | ||
280 | #define DWC3_DCFG_NUMP(n) (((n) >> DWC3_DCFG_NUMP_SHIFT) & 0x1f) | ||
281 | #define DWC3_DCFG_NUMP_MASK (0x1f << DWC3_DCFG_NUMP_SHIFT) | ||
260 | #define DWC3_DCFG_LPM_CAP (1 << 22) | 282 | #define DWC3_DCFG_LPM_CAP (1 << 22) |
261 | 283 | ||
262 | /* Device Control Register */ | 284 | /* Device Control Register */ |
@@ -438,18 +460,17 @@ struct dwc3_event_buffer { | |||
438 | #define DWC3_EP_DIRECTION_TX true | 460 | #define DWC3_EP_DIRECTION_TX true |
439 | #define DWC3_EP_DIRECTION_RX false | 461 | #define DWC3_EP_DIRECTION_RX false |
440 | 462 | ||
441 | #define DWC3_TRB_NUM 32 | 463 | #define DWC3_TRB_NUM 256 |
442 | #define DWC3_TRB_MASK (DWC3_TRB_NUM - 1) | ||
443 | 464 | ||
444 | /** | 465 | /** |
445 | * struct dwc3_ep - device side endpoint representation | 466 | * struct dwc3_ep - device side endpoint representation |
446 | * @endpoint: usb endpoint | 467 | * @endpoint: usb endpoint |
447 | * @request_list: list of requests for this endpoint | 468 | * @pending_list: list of pending requests for this endpoint |
448 | * @req_queued: list of requests on this ep which have TRBs setup | 469 | * @started_list: list of started requests on this endpoint |
449 | * @trb_pool: array of transaction buffers | 470 | * @trb_pool: array of transaction buffers |
450 | * @trb_pool_dma: dma address of @trb_pool | 471 | * @trb_pool_dma: dma address of @trb_pool |
451 | * @free_slot: next slot which is going to be used | 472 | * @trb_enqueue: enqueue 'pointer' into TRB array |
452 | * @busy_slot: first slot which is owned by HW | 473 | * @trb_dequeue: dequeue 'pointer' into TRB array |
453 | * @desc: usb_endpoint_descriptor pointer | 474 | * @desc: usb_endpoint_descriptor pointer |
454 | * @dwc: pointer to DWC controller | 475 | * @dwc: pointer to DWC controller |
455 | * @saved_state: ep state saved during hibernation | 476 | * @saved_state: ep state saved during hibernation |
@@ -464,13 +485,11 @@ struct dwc3_event_buffer { | |||
464 | */ | 485 | */ |
465 | struct dwc3_ep { | 486 | struct dwc3_ep { |
466 | struct usb_ep endpoint; | 487 | struct usb_ep endpoint; |
467 | struct list_head request_list; | 488 | struct list_head pending_list; |
468 | struct list_head req_queued; | 489 | struct list_head started_list; |
469 | 490 | ||
470 | struct dwc3_trb *trb_pool; | 491 | struct dwc3_trb *trb_pool; |
471 | dma_addr_t trb_pool_dma; | 492 | dma_addr_t trb_pool_dma; |
472 | u32 free_slot; | ||
473 | u32 busy_slot; | ||
474 | const struct usb_ss_ep_comp_descriptor *comp_desc; | 493 | const struct usb_ss_ep_comp_descriptor *comp_desc; |
475 | struct dwc3 *dwc; | 494 | struct dwc3 *dwc; |
476 | 495 | ||
@@ -486,6 +505,18 @@ struct dwc3_ep { | |||
486 | /* This last one is specific to EP0 */ | 505 | /* This last one is specific to EP0 */ |
487 | #define DWC3_EP0_DIR_IN (1 << 31) | 506 | #define DWC3_EP0_DIR_IN (1 << 31) |
488 | 507 | ||
508 | /* | ||
509 | * IMPORTANT: we *know* we have 256 TRBs in our @trb_pool, so we will | ||
510 | * use a u8 type here. If anybody decides to increase number of TRBs to | ||
511 | * anything larger than 256 - I can't see why people would want to do | ||
512 | * this though - then this type needs to be changed. | ||
513 | * | ||
514 | * By using u8 types we ensure that our % operator when incrementing | ||
515 | * enqueue and dequeue get optimized away by the compiler. | ||
516 | */ | ||
517 | u8 trb_enqueue; | ||
518 | u8 trb_dequeue; | ||
519 | |||
489 | u8 number; | 520 | u8 number; |
490 | u8 type; | 521 | u8 type; |
491 | u8 resource_index; | 522 | u8 resource_index; |
@@ -557,6 +588,7 @@ enum dwc3_link_state { | |||
557 | #define DWC3_TRB_CTRL_IOC (1 << 11) | 588 | #define DWC3_TRB_CTRL_IOC (1 << 11) |
558 | #define DWC3_TRB_CTRL_SID_SOFN(n) (((n) & 0xffff) << 14) | 589 | #define DWC3_TRB_CTRL_SID_SOFN(n) (((n) & 0xffff) << 14) |
559 | 590 | ||
591 | #define DWC3_TRBCTL_TYPE(n) ((n) & (0x3f << 4)) | ||
560 | #define DWC3_TRBCTL_NORMAL DWC3_TRB_CTRL_TRBCTL(1) | 592 | #define DWC3_TRBCTL_NORMAL DWC3_TRB_CTRL_TRBCTL(1) |
561 | #define DWC3_TRBCTL_CONTROL_SETUP DWC3_TRB_CTRL_TRBCTL(2) | 593 | #define DWC3_TRBCTL_CONTROL_SETUP DWC3_TRB_CTRL_TRBCTL(2) |
562 | #define DWC3_TRBCTL_CONTROL_STATUS2 DWC3_TRB_CTRL_TRBCTL(3) | 594 | #define DWC3_TRBCTL_CONTROL_STATUS2 DWC3_TRB_CTRL_TRBCTL(3) |
@@ -623,19 +655,32 @@ struct dwc3_hwparams { | |||
623 | /* HWPARAMS7 */ | 655 | /* HWPARAMS7 */ |
624 | #define DWC3_RAM1_DEPTH(n) ((n) & 0xffff) | 656 | #define DWC3_RAM1_DEPTH(n) ((n) & 0xffff) |
625 | 657 | ||
658 | /** | ||
659 | * struct dwc3_request - representation of a transfer request | ||
660 | * @request: struct usb_request to be transferred | ||
661 | * @list: a list_head used for request queueing | ||
662 | * @dep: struct dwc3_ep owning this request | ||
663 | * @first_trb_index: index to first trb used by this request | ||
664 | * @epnum: endpoint number to which this request refers | ||
665 | * @trb: pointer to struct dwc3_trb | ||
666 | * @trb_dma: DMA address of @trb | ||
667 | * @direction: IN or OUT direction flag | ||
668 | * @mapped: true when request has been dma-mapped | ||
669 | * @queued: true when request has been queued to HW | ||
670 | */ | ||
626 | struct dwc3_request { | 671 | struct dwc3_request { |
627 | struct usb_request request; | 672 | struct usb_request request; |
628 | struct list_head list; | 673 | struct list_head list; |
629 | struct dwc3_ep *dep; | 674 | struct dwc3_ep *dep; |
630 | u32 start_slot; | ||
631 | 675 | ||
676 | u8 first_trb_index; | ||
632 | u8 epnum; | 677 | u8 epnum; |
633 | struct dwc3_trb *trb; | 678 | struct dwc3_trb *trb; |
634 | dma_addr_t trb_dma; | 679 | dma_addr_t trb_dma; |
635 | 680 | ||
636 | unsigned direction:1; | 681 | unsigned direction:1; |
637 | unsigned mapped:1; | 682 | unsigned mapped:1; |
638 | unsigned queued:1; | 683 | unsigned started:1; |
639 | }; | 684 | }; |
640 | 685 | ||
641 | /* | 686 | /* |
@@ -667,7 +712,6 @@ struct dwc3_scratchpad_array { | |||
667 | * @regs: base address for our registers | 712 | * @regs: base address for our registers |
668 | * @regs_size: address space size | 713 | * @regs_size: address space size |
669 | * @nr_scratch: number of scratch buffers | 714 | * @nr_scratch: number of scratch buffers |
670 | * @num_event_buffers: calculated number of event buffers | ||
671 | * @u1u2: only used on revisions <1.83a for workaround | 715 | * @u1u2: only used on revisions <1.83a for workaround |
672 | * @maximum_speed: maximum speed requested (mainly for testing purposes) | 716 | * @maximum_speed: maximum speed requested (mainly for testing purposes) |
673 | * @revision: revision register contents | 717 | * @revision: revision register contents |
@@ -709,9 +753,7 @@ struct dwc3_scratchpad_array { | |||
709 | * 0 - utmi_sleep_n | 753 | * 0 - utmi_sleep_n |
710 | * 1 - utmi_l1_suspend_n | 754 | * 1 - utmi_l1_suspend_n |
711 | * @is_fpga: true when we are using the FPGA board | 755 | * @is_fpga: true when we are using the FPGA board |
712 | * @needs_fifo_resize: not all users might want fifo resizing, flag it | ||
713 | * @pullups_connected: true when Run/Stop bit is set | 756 | * @pullups_connected: true when Run/Stop bit is set |
714 | * @resize_fifos: tells us it's ok to reconfigure our TxFIFO sizes. | ||
715 | * @setup_packet_pending: true when there's a Setup Packet in FIFO. Workaround | 757 | * @setup_packet_pending: true when there's a Setup Packet in FIFO. Workaround |
716 | * @start_config_issued: true when StartConfig command has been issued | 758 | * @start_config_issued: true when StartConfig command has been issued |
717 | * @three_stage_setup: set if we perform a three phase setup | 759 | * @three_stage_setup: set if we perform a three phase setup |
@@ -756,7 +798,7 @@ struct dwc3 { | |||
756 | struct platform_device *xhci; | 798 | struct platform_device *xhci; |
757 | struct resource xhci_resources[DWC3_XHCI_RESOURCES_NUM]; | 799 | struct resource xhci_resources[DWC3_XHCI_RESOURCES_NUM]; |
758 | 800 | ||
759 | struct dwc3_event_buffer **ev_buffs; | 801 | struct dwc3_event_buffer *ev_buf; |
760 | struct dwc3_ep *eps[DWC3_ENDPOINTS_NUM]; | 802 | struct dwc3_ep *eps[DWC3_ENDPOINTS_NUM]; |
761 | 803 | ||
762 | struct usb_gadget gadget; | 804 | struct usb_gadget gadget; |
@@ -780,7 +822,6 @@ struct dwc3 { | |||
780 | u32 gctl; | 822 | u32 gctl; |
781 | 823 | ||
782 | u32 nr_scratch; | 824 | u32 nr_scratch; |
783 | u32 num_event_buffers; | ||
784 | u32 u1u2; | 825 | u32 u1u2; |
785 | u32 maximum_speed; | 826 | u32 maximum_speed; |
786 | 827 | ||
@@ -855,9 +896,7 @@ struct dwc3 { | |||
855 | unsigned has_lpm_erratum:1; | 896 | unsigned has_lpm_erratum:1; |
856 | unsigned is_utmi_l1_suspend:1; | 897 | unsigned is_utmi_l1_suspend:1; |
857 | unsigned is_fpga:1; | 898 | unsigned is_fpga:1; |
858 | unsigned needs_fifo_resize:1; | ||
859 | unsigned pullups_connected:1; | 899 | unsigned pullups_connected:1; |
860 | unsigned resize_fifos:1; | ||
861 | unsigned setup_packet_pending:1; | 900 | unsigned setup_packet_pending:1; |
862 | unsigned three_stage_setup:1; | 901 | unsigned three_stage_setup:1; |
863 | unsigned usb3_lpm_capable:1; | 902 | unsigned usb3_lpm_capable:1; |
@@ -873,6 +912,7 @@ struct dwc3 { | |||
873 | unsigned dis_u3_susphy_quirk:1; | 912 | unsigned dis_u3_susphy_quirk:1; |
874 | unsigned dis_u2_susphy_quirk:1; | 913 | unsigned dis_u2_susphy_quirk:1; |
875 | unsigned dis_enblslpm_quirk:1; | 914 | unsigned dis_enblslpm_quirk:1; |
915 | unsigned dis_rxdet_inp3_quirk:1; | ||
876 | 916 | ||
877 | unsigned tx_de_emphasis_quirk:1; | 917 | unsigned tx_de_emphasis_quirk:1; |
878 | unsigned tx_de_emphasis:2; | 918 | unsigned tx_de_emphasis:2; |
@@ -938,6 +978,10 @@ struct dwc3_event_depevt { | |||
938 | #define DEPEVT_STATUS_CONTROL_DATA 1 | 978 | #define DEPEVT_STATUS_CONTROL_DATA 1 |
939 | #define DEPEVT_STATUS_CONTROL_STATUS 2 | 979 | #define DEPEVT_STATUS_CONTROL_STATUS 2 |
940 | 980 | ||
981 | /* In response to Start Transfer */ | ||
982 | #define DEPEVT_TRANSFER_NO_RESOURCE 1 | ||
983 | #define DEPEVT_TRANSFER_BUS_EXPIRY 2 | ||
984 | |||
941 | u32 parameters:16; | 985 | u32 parameters:16; |
942 | } __packed; | 986 | } __packed; |
943 | 987 | ||
@@ -1025,7 +1069,7 @@ struct dwc3_gadget_ep_cmd_params { | |||
1025 | 1069 | ||
1026 | /* prototypes */ | 1070 | /* prototypes */ |
1027 | void dwc3_set_mode(struct dwc3 *dwc, u32 mode); | 1071 | void dwc3_set_mode(struct dwc3 *dwc, u32 mode); |
1028 | int dwc3_gadget_resize_tx_fifos(struct dwc3 *dwc); | 1072 | u32 dwc3_core_fifo_space(struct dwc3_ep *dep, u8 type); |
1029 | 1073 | ||
1030 | /* check whether we are on the DWC_usb31 core */ | 1074 | /* check whether we are on the DWC_usb31 core */ |
1031 | static inline bool dwc3_is_usb31(struct dwc3 *dwc) | 1075 | static inline bool dwc3_is_usb31(struct dwc3 *dwc) |
diff --git a/drivers/usb/dwc3/debug.h b/drivers/usb/dwc3/debug.h index 07fbc2d94fd4..71e318025964 100644 --- a/drivers/usb/dwc3/debug.h +++ b/drivers/usb/dwc3/debug.h | |||
@@ -217,11 +217,11 @@ static inline const char *dwc3_gadget_event_type_string(u8 event) | |||
217 | void dwc3_trace(void (*trace)(struct va_format *), const char *fmt, ...); | 217 | void dwc3_trace(void (*trace)(struct va_format *), const char *fmt, ...); |
218 | 218 | ||
219 | #ifdef CONFIG_DEBUG_FS | 219 | #ifdef CONFIG_DEBUG_FS |
220 | extern int dwc3_debugfs_init(struct dwc3 *); | 220 | extern void dwc3_debugfs_init(struct dwc3 *); |
221 | extern void dwc3_debugfs_exit(struct dwc3 *); | 221 | extern void dwc3_debugfs_exit(struct dwc3 *); |
222 | #else | 222 | #else |
223 | static inline int dwc3_debugfs_init(struct dwc3 *d) | 223 | static inline void dwc3_debugfs_init(struct dwc3 *d) |
224 | { return 0; } | 224 | { } |
225 | static inline void dwc3_debugfs_exit(struct dwc3 *d) | 225 | static inline void dwc3_debugfs_exit(struct dwc3 *d) |
226 | { } | 226 | { } |
227 | #endif | 227 | #endif |
diff --git a/drivers/usb/dwc3/debugfs.c b/drivers/usb/dwc3/debugfs.c index cebf9e38b60a..b1dd3c6d7ef7 100644 --- a/drivers/usb/dwc3/debugfs.c +++ b/drivers/usb/dwc3/debugfs.c | |||
@@ -618,24 +618,323 @@ static const struct file_operations dwc3_link_state_fops = { | |||
618 | .release = single_release, | 618 | .release = single_release, |
619 | }; | 619 | }; |
620 | 620 | ||
621 | int dwc3_debugfs_init(struct dwc3 *dwc) | 621 | struct dwc3_ep_file_map { |
622 | char name[25]; | ||
623 | int (*show)(struct seq_file *s, void *unused); | ||
624 | }; | ||
625 | |||
626 | static int dwc3_tx_fifo_queue_show(struct seq_file *s, void *unused) | ||
627 | { | ||
628 | struct dwc3_ep *dep = s->private; | ||
629 | struct dwc3 *dwc = dep->dwc; | ||
630 | unsigned long flags; | ||
631 | u32 val; | ||
632 | |||
633 | spin_lock_irqsave(&dwc->lock, flags); | ||
634 | val = dwc3_core_fifo_space(dep, DWC3_TXFIFOQ); | ||
635 | seq_printf(s, "%u\n", val); | ||
636 | spin_unlock_irqrestore(&dwc->lock, flags); | ||
637 | |||
638 | return 0; | ||
639 | } | ||
640 | |||
641 | static int dwc3_rx_fifo_queue_show(struct seq_file *s, void *unused) | ||
642 | { | ||
643 | struct dwc3_ep *dep = s->private; | ||
644 | struct dwc3 *dwc = dep->dwc; | ||
645 | unsigned long flags; | ||
646 | u32 val; | ||
647 | |||
648 | spin_lock_irqsave(&dwc->lock, flags); | ||
649 | val = dwc3_core_fifo_space(dep, DWC3_RXFIFOQ); | ||
650 | seq_printf(s, "%u\n", val); | ||
651 | spin_unlock_irqrestore(&dwc->lock, flags); | ||
652 | |||
653 | return 0; | ||
654 | } | ||
655 | |||
656 | static int dwc3_tx_request_queue_show(struct seq_file *s, void *unused) | ||
657 | { | ||
658 | struct dwc3_ep *dep = s->private; | ||
659 | struct dwc3 *dwc = dep->dwc; | ||
660 | unsigned long flags; | ||
661 | u32 val; | ||
662 | |||
663 | spin_lock_irqsave(&dwc->lock, flags); | ||
664 | val = dwc3_core_fifo_space(dep, DWC3_TXREQQ); | ||
665 | seq_printf(s, "%u\n", val); | ||
666 | spin_unlock_irqrestore(&dwc->lock, flags); | ||
667 | |||
668 | return 0; | ||
669 | } | ||
670 | |||
671 | static int dwc3_rx_request_queue_show(struct seq_file *s, void *unused) | ||
672 | { | ||
673 | struct dwc3_ep *dep = s->private; | ||
674 | struct dwc3 *dwc = dep->dwc; | ||
675 | unsigned long flags; | ||
676 | u32 val; | ||
677 | |||
678 | spin_lock_irqsave(&dwc->lock, flags); | ||
679 | val = dwc3_core_fifo_space(dep, DWC3_RXREQQ); | ||
680 | seq_printf(s, "%u\n", val); | ||
681 | spin_unlock_irqrestore(&dwc->lock, flags); | ||
682 | |||
683 | return 0; | ||
684 | } | ||
685 | |||
686 | static int dwc3_rx_info_queue_show(struct seq_file *s, void *unused) | ||
687 | { | ||
688 | struct dwc3_ep *dep = s->private; | ||
689 | struct dwc3 *dwc = dep->dwc; | ||
690 | unsigned long flags; | ||
691 | u32 val; | ||
692 | |||
693 | spin_lock_irqsave(&dwc->lock, flags); | ||
694 | val = dwc3_core_fifo_space(dep, DWC3_RXINFOQ); | ||
695 | seq_printf(s, "%u\n", val); | ||
696 | spin_unlock_irqrestore(&dwc->lock, flags); | ||
697 | |||
698 | return 0; | ||
699 | } | ||
700 | |||
701 | static int dwc3_descriptor_fetch_queue_show(struct seq_file *s, void *unused) | ||
702 | { | ||
703 | struct dwc3_ep *dep = s->private; | ||
704 | struct dwc3 *dwc = dep->dwc; | ||
705 | unsigned long flags; | ||
706 | u32 val; | ||
707 | |||
708 | spin_lock_irqsave(&dwc->lock, flags); | ||
709 | val = dwc3_core_fifo_space(dep, DWC3_DESCFETCHQ); | ||
710 | seq_printf(s, "%u\n", val); | ||
711 | spin_unlock_irqrestore(&dwc->lock, flags); | ||
712 | |||
713 | return 0; | ||
714 | } | ||
715 | |||
716 | static int dwc3_event_queue_show(struct seq_file *s, void *unused) | ||
717 | { | ||
718 | struct dwc3_ep *dep = s->private; | ||
719 | struct dwc3 *dwc = dep->dwc; | ||
720 | unsigned long flags; | ||
721 | u32 val; | ||
722 | |||
723 | spin_lock_irqsave(&dwc->lock, flags); | ||
724 | val = dwc3_core_fifo_space(dep, DWC3_EVENTQ); | ||
725 | seq_printf(s, "%u\n", val); | ||
726 | spin_unlock_irqrestore(&dwc->lock, flags); | ||
727 | |||
728 | return 0; | ||
729 | } | ||
730 | |||
731 | static int dwc3_ep_transfer_type_show(struct seq_file *s, void *unused) | ||
732 | { | ||
733 | struct dwc3_ep *dep = s->private; | ||
734 | struct dwc3 *dwc = dep->dwc; | ||
735 | unsigned long flags; | ||
736 | |||
737 | spin_lock_irqsave(&dwc->lock, flags); | ||
738 | if (!(dep->flags & DWC3_EP_ENABLED) || | ||
739 | !dep->endpoint.desc) { | ||
740 | seq_printf(s, "--\n"); | ||
741 | goto out; | ||
742 | } | ||
743 | |||
744 | switch (usb_endpoint_type(dep->endpoint.desc)) { | ||
745 | case USB_ENDPOINT_XFER_CONTROL: | ||
746 | seq_printf(s, "control\n"); | ||
747 | break; | ||
748 | case USB_ENDPOINT_XFER_ISOC: | ||
749 | seq_printf(s, "isochronous\n"); | ||
750 | break; | ||
751 | case USB_ENDPOINT_XFER_BULK: | ||
752 | seq_printf(s, "bulk\n"); | ||
753 | break; | ||
754 | case USB_ENDPOINT_XFER_INT: | ||
755 | seq_printf(s, "interrupt\n"); | ||
756 | break; | ||
757 | default: | ||
758 | seq_printf(s, "--\n"); | ||
759 | } | ||
760 | |||
761 | out: | ||
762 | spin_unlock_irqrestore(&dwc->lock, flags); | ||
763 | |||
764 | return 0; | ||
765 | } | ||
766 | |||
767 | static inline const char *dwc3_trb_type_string(struct dwc3_trb *trb) | ||
768 | { | ||
769 | switch (DWC3_TRBCTL_TYPE(trb->ctrl)) { | ||
770 | case DWC3_TRBCTL_NORMAL: | ||
771 | return "normal"; | ||
772 | case DWC3_TRBCTL_CONTROL_SETUP: | ||
773 | return "control-setup"; | ||
774 | case DWC3_TRBCTL_CONTROL_STATUS2: | ||
775 | return "control-status2"; | ||
776 | case DWC3_TRBCTL_CONTROL_STATUS3: | ||
777 | return "control-status3"; | ||
778 | case DWC3_TRBCTL_CONTROL_DATA: | ||
779 | return "control-data"; | ||
780 | case DWC3_TRBCTL_ISOCHRONOUS_FIRST: | ||
781 | return "isoc-first"; | ||
782 | case DWC3_TRBCTL_ISOCHRONOUS: | ||
783 | return "isoc"; | ||
784 | case DWC3_TRBCTL_LINK_TRB: | ||
785 | return "link"; | ||
786 | default: | ||
787 | return "UNKNOWN"; | ||
788 | } | ||
789 | } | ||
790 | |||
791 | static int dwc3_ep_trb_ring_show(struct seq_file *s, void *unused) | ||
792 | { | ||
793 | struct dwc3_ep *dep = s->private; | ||
794 | struct dwc3 *dwc = dep->dwc; | ||
795 | unsigned long flags; | ||
796 | int i; | ||
797 | |||
798 | spin_lock_irqsave(&dwc->lock, flags); | ||
799 | if (dep->number <= 1) { | ||
800 | seq_printf(s, "--\n"); | ||
801 | goto out; | ||
802 | } | ||
803 | |||
804 | seq_printf(s, "enqueue pointer %d\n", dep->trb_enqueue); | ||
805 | seq_printf(s, "dequeue pointer %d\n", dep->trb_dequeue); | ||
806 | seq_printf(s, "\n--------------------------------------------------\n\n"); | ||
807 | seq_printf(s, "buffer_addr,size,type,ioc,isp_imi,csp,chn,lst,hwo\n"); | ||
808 | |||
809 | for (i = 0; i < DWC3_TRB_NUM; i++) { | ||
810 | struct dwc3_trb *trb = &dep->trb_pool[i]; | ||
811 | |||
812 | seq_printf(s, "%08x%08x,%d,%s,%d,%d,%d,%d,%d,%d\n", | ||
813 | trb->bph, trb->bpl, trb->size, | ||
814 | dwc3_trb_type_string(trb), | ||
815 | !!(trb->ctrl & DWC3_TRB_CTRL_IOC), | ||
816 | !!(trb->ctrl & DWC3_TRB_CTRL_ISP_IMI), | ||
817 | !!(trb->ctrl & DWC3_TRB_CTRL_CSP), | ||
818 | !!(trb->ctrl & DWC3_TRB_CTRL_CHN), | ||
819 | !!(trb->ctrl & DWC3_TRB_CTRL_LST), | ||
820 | !!(trb->ctrl & DWC3_TRB_CTRL_HWO)); | ||
821 | } | ||
822 | |||
823 | out: | ||
824 | spin_unlock_irqrestore(&dwc->lock, flags); | ||
825 | |||
826 | return 0; | ||
827 | } | ||
828 | |||
829 | static struct dwc3_ep_file_map map[] = { | ||
830 | { "tx_fifo_queue", dwc3_tx_fifo_queue_show, }, | ||
831 | { "rx_fifo_queue", dwc3_rx_fifo_queue_show, }, | ||
832 | { "tx_request_queue", dwc3_tx_request_queue_show, }, | ||
833 | { "rx_request_queue", dwc3_rx_request_queue_show, }, | ||
834 | { "rx_info_queue", dwc3_rx_info_queue_show, }, | ||
835 | { "descriptor_fetch_queue", dwc3_descriptor_fetch_queue_show, }, | ||
836 | { "event_queue", dwc3_event_queue_show, }, | ||
837 | { "transfer_type", dwc3_ep_transfer_type_show, }, | ||
838 | { "trb_ring", dwc3_ep_trb_ring_show, }, | ||
839 | }; | ||
840 | |||
841 | static int dwc3_endpoint_open(struct inode *inode, struct file *file) | ||
842 | { | ||
843 | const char *file_name = file_dentry(file)->d_iname; | ||
844 | struct dwc3_ep_file_map *f_map; | ||
845 | int i; | ||
846 | |||
847 | for (i = 0; i < ARRAY_SIZE(map); i++) { | ||
848 | f_map = &map[i]; | ||
849 | |||
850 | if (strcmp(f_map->name, file_name) == 0) | ||
851 | break; | ||
852 | } | ||
853 | |||
854 | return single_open(file, f_map->show, inode->i_private); | ||
855 | } | ||
856 | |||
857 | static const struct file_operations dwc3_endpoint_fops = { | ||
858 | .open = dwc3_endpoint_open, | ||
859 | .read = seq_read, | ||
860 | .llseek = seq_lseek, | ||
861 | .release = single_release, | ||
862 | }; | ||
863 | |||
864 | static void dwc3_debugfs_create_endpoint_file(struct dwc3_ep *dep, | ||
865 | struct dentry *parent, int type) | ||
622 | { | 866 | { |
623 | struct dentry *root; | ||
624 | struct dentry *file; | 867 | struct dentry *file; |
625 | int ret; | 868 | struct dwc3_ep_file_map *ep_file = &map[type]; |
626 | 869 | ||
627 | root = debugfs_create_dir(dev_name(dwc->dev), NULL); | 870 | file = debugfs_create_file(ep_file->name, S_IRUGO, parent, dep, |
628 | if (!root) { | 871 | &dwc3_endpoint_fops); |
629 | ret = -ENOMEM; | 872 | } |
630 | goto err0; | 873 | |
874 | static void dwc3_debugfs_create_endpoint_files(struct dwc3_ep *dep, | ||
875 | struct dentry *parent) | ||
876 | { | ||
877 | int i; | ||
878 | |||
879 | for (i = 0; i < ARRAY_SIZE(map); i++) | ||
880 | dwc3_debugfs_create_endpoint_file(dep, parent, i); | ||
881 | } | ||
882 | |||
883 | static void dwc3_debugfs_create_endpoint_dir(struct dwc3_ep *dep, | ||
884 | struct dentry *parent) | ||
885 | { | ||
886 | struct dentry *dir; | ||
887 | |||
888 | dir = debugfs_create_dir(dep->name, parent); | ||
889 | if (IS_ERR_OR_NULL(dir)) | ||
890 | return; | ||
891 | |||
892 | dwc3_debugfs_create_endpoint_files(dep, dir); | ||
893 | } | ||
894 | |||
895 | static void dwc3_debugfs_create_endpoint_dirs(struct dwc3 *dwc, | ||
896 | struct dentry *parent) | ||
897 | { | ||
898 | int i; | ||
899 | |||
900 | for (i = 0; i < dwc->num_in_eps; i++) { | ||
901 | u8 epnum = (i << 1) | 1; | ||
902 | struct dwc3_ep *dep = dwc->eps[epnum]; | ||
903 | |||
904 | if (!dep) | ||
905 | continue; | ||
906 | |||
907 | dwc3_debugfs_create_endpoint_dir(dep, parent); | ||
908 | } | ||
909 | |||
910 | for (i = 0; i < dwc->num_out_eps; i++) { | ||
911 | u8 epnum = (i << 1); | ||
912 | struct dwc3_ep *dep = dwc->eps[epnum]; | ||
913 | |||
914 | if (!dep) | ||
915 | continue; | ||
916 | |||
917 | dwc3_debugfs_create_endpoint_dir(dep, parent); | ||
631 | } | 918 | } |
919 | } | ||
920 | |||
921 | void dwc3_debugfs_init(struct dwc3 *dwc) | ||
922 | { | ||
923 | struct dentry *root; | ||
924 | struct dentry *file; | ||
632 | 925 | ||
926 | root = debugfs_create_dir(dev_name(dwc->dev), NULL); | ||
927 | if (IS_ERR_OR_NULL(root)) { | ||
928 | if (!root) | ||
929 | dev_err(dwc->dev, "Can't create debugfs root\n"); | ||
930 | return; | ||
931 | } | ||
633 | dwc->root = root; | 932 | dwc->root = root; |
634 | 933 | ||
635 | dwc->regset = kzalloc(sizeof(*dwc->regset), GFP_KERNEL); | 934 | dwc->regset = kzalloc(sizeof(*dwc->regset), GFP_KERNEL); |
636 | if (!dwc->regset) { | 935 | if (!dwc->regset) { |
637 | ret = -ENOMEM; | 936 | debugfs_remove_recursive(root); |
638 | goto err1; | 937 | return; |
639 | } | 938 | } |
640 | 939 | ||
641 | dwc->regset->regs = dwc3_regs; | 940 | dwc->regset->regs = dwc3_regs; |
@@ -643,47 +942,30 @@ int dwc3_debugfs_init(struct dwc3 *dwc) | |||
643 | dwc->regset->base = dwc->regs; | 942 | dwc->regset->base = dwc->regs; |
644 | 943 | ||
645 | file = debugfs_create_regset32("regdump", S_IRUGO, root, dwc->regset); | 944 | file = debugfs_create_regset32("regdump", S_IRUGO, root, dwc->regset); |
646 | if (!file) { | 945 | if (!file) |
647 | ret = -ENOMEM; | 946 | dev_dbg(dwc->dev, "Can't create debugfs regdump\n"); |
648 | goto err2; | ||
649 | } | ||
650 | 947 | ||
651 | if (IS_ENABLED(CONFIG_USB_DWC3_DUAL_ROLE)) { | 948 | if (IS_ENABLED(CONFIG_USB_DWC3_DUAL_ROLE)) { |
652 | file = debugfs_create_file("mode", S_IRUGO | S_IWUSR, root, | 949 | file = debugfs_create_file("mode", S_IRUGO | S_IWUSR, root, |
653 | dwc, &dwc3_mode_fops); | 950 | dwc, &dwc3_mode_fops); |
654 | if (!file) { | 951 | if (!file) |
655 | ret = -ENOMEM; | 952 | dev_dbg(dwc->dev, "Can't create debugfs mode\n"); |
656 | goto err2; | ||
657 | } | ||
658 | } | 953 | } |
659 | 954 | ||
660 | if (IS_ENABLED(CONFIG_USB_DWC3_DUAL_ROLE) || | 955 | if (IS_ENABLED(CONFIG_USB_DWC3_DUAL_ROLE) || |
661 | IS_ENABLED(CONFIG_USB_DWC3_GADGET)) { | 956 | IS_ENABLED(CONFIG_USB_DWC3_GADGET)) { |
662 | file = debugfs_create_file("testmode", S_IRUGO | S_IWUSR, root, | 957 | file = debugfs_create_file("testmode", S_IRUGO | S_IWUSR, root, |
663 | dwc, &dwc3_testmode_fops); | 958 | dwc, &dwc3_testmode_fops); |
664 | if (!file) { | 959 | if (!file) |
665 | ret = -ENOMEM; | 960 | dev_dbg(dwc->dev, "Can't create debugfs testmode\n"); |
666 | goto err2; | ||
667 | } | ||
668 | |||
669 | file = debugfs_create_file("link_state", S_IRUGO | S_IWUSR, root, | ||
670 | dwc, &dwc3_link_state_fops); | ||
671 | if (!file) { | ||
672 | ret = -ENOMEM; | ||
673 | goto err2; | ||
674 | } | ||
675 | } | ||
676 | 961 | ||
677 | return 0; | 962 | file = debugfs_create_file("link_state", S_IRUGO | S_IWUSR, |
963 | root, dwc, &dwc3_link_state_fops); | ||
964 | if (!file) | ||
965 | dev_dbg(dwc->dev, "Can't create debugfs link_state\n"); | ||
678 | 966 | ||
679 | err2: | 967 | dwc3_debugfs_create_endpoint_dirs(dwc, root); |
680 | kfree(dwc->regset); | 968 | } |
681 | |||
682 | err1: | ||
683 | debugfs_remove_recursive(root); | ||
684 | |||
685 | err0: | ||
686 | return ret; | ||
687 | } | 969 | } |
688 | 970 | ||
689 | void dwc3_debugfs_exit(struct dwc3 *dwc) | 971 | void dwc3_debugfs_exit(struct dwc3 *dwc) |
diff --git a/drivers/usb/dwc3/dwc3-omap.c b/drivers/usb/dwc3/dwc3-omap.c index 55da2c7f727f..af264493bbae 100644 --- a/drivers/usb/dwc3/dwc3-omap.c +++ b/drivers/usb/dwc3/dwc3-omap.c | |||
@@ -126,8 +126,6 @@ struct dwc3_omap { | |||
126 | u32 debug_offset; | 126 | u32 debug_offset; |
127 | u32 irq0_offset; | 127 | u32 irq0_offset; |
128 | 128 | ||
129 | u32 dma_status:1; | ||
130 | |||
131 | struct extcon_dev *edev; | 129 | struct extcon_dev *edev; |
132 | struct notifier_block vbus_nb; | 130 | struct notifier_block vbus_nb; |
133 | struct notifier_block id_nb; | 131 | struct notifier_block id_nb; |
@@ -277,9 +275,6 @@ static irqreturn_t dwc3_omap_interrupt(int irq, void *_omap) | |||
277 | 275 | ||
278 | reg = dwc3_omap_read_irqmisc_status(omap); | 276 | reg = dwc3_omap_read_irqmisc_status(omap); |
279 | 277 | ||
280 | if (reg & USBOTGSS_IRQMISC_DMADISABLECLR) | ||
281 | omap->dma_status = false; | ||
282 | |||
283 | dwc3_omap_write_irqmisc_status(omap, reg); | 278 | dwc3_omap_write_irqmisc_status(omap, reg); |
284 | 279 | ||
285 | reg = dwc3_omap_read_irq0_status(omap); | 280 | reg = dwc3_omap_read_irq0_status(omap); |
@@ -331,8 +326,6 @@ static void dwc3_omap_disable_irqs(struct dwc3_omap *omap) | |||
331 | dwc3_omap_write_irqmisc_clr(omap, reg); | 326 | dwc3_omap_write_irqmisc_clr(omap, reg); |
332 | } | 327 | } |
333 | 328 | ||
334 | static u64 dwc3_omap_dma_mask = DMA_BIT_MASK(32); | ||
335 | |||
336 | static int dwc3_omap_id_notifier(struct notifier_block *nb, | 329 | static int dwc3_omap_id_notifier(struct notifier_block *nb, |
337 | unsigned long event, void *ptr) | 330 | unsigned long event, void *ptr) |
338 | { | 331 | { |
@@ -490,7 +483,6 @@ static int dwc3_omap_probe(struct platform_device *pdev) | |||
490 | omap->irq = irq; | 483 | omap->irq = irq; |
491 | omap->base = base; | 484 | omap->base = base; |
492 | omap->vbus_reg = vbus_reg; | 485 | omap->vbus_reg = vbus_reg; |
493 | dev->dma_mask = &dwc3_omap_dma_mask; | ||
494 | 486 | ||
495 | pm_runtime_enable(dev); | 487 | pm_runtime_enable(dev); |
496 | ret = pm_runtime_get_sync(dev); | 488 | ret = pm_runtime_get_sync(dev); |
@@ -504,7 +496,6 @@ static int dwc3_omap_probe(struct platform_device *pdev) | |||
504 | 496 | ||
505 | /* check the DMA Status */ | 497 | /* check the DMA Status */ |
506 | reg = dwc3_omap_readl(omap->base, USBOTGSS_SYSCONFIG); | 498 | reg = dwc3_omap_readl(omap->base, USBOTGSS_SYSCONFIG); |
507 | omap->dma_status = !!(reg & USBOTGSS_SYSCONFIG_DMADISABLE); | ||
508 | 499 | ||
509 | ret = devm_request_irq(dev, omap->irq, dwc3_omap_interrupt, 0, | 500 | ret = devm_request_irq(dev, omap->irq, dwc3_omap_interrupt, 0, |
510 | "dwc3-omap", omap); | 501 | "dwc3-omap", omap); |
diff --git a/drivers/usb/dwc3/dwc3-pci.c b/drivers/usb/dwc3/dwc3-pci.c index adc1e8a624cb..14196cd416b3 100644 --- a/drivers/usb/dwc3/dwc3-pci.c +++ b/drivers/usb/dwc3/dwc3-pci.c | |||
@@ -47,7 +47,7 @@ static const struct acpi_gpio_mapping acpi_dwc3_byt_gpios[] = { | |||
47 | { }, | 47 | { }, |
48 | }; | 48 | }; |
49 | 49 | ||
50 | static int dwc3_pci_quirks(struct pci_dev *pdev) | 50 | static int dwc3_pci_quirks(struct pci_dev *pdev, struct platform_device *dwc3) |
51 | { | 51 | { |
52 | if (pdev->vendor == PCI_VENDOR_ID_AMD && | 52 | if (pdev->vendor == PCI_VENDOR_ID_AMD && |
53 | pdev->device == PCI_DEVICE_ID_AMD_NL_USB) { | 53 | pdev->device == PCI_DEVICE_ID_AMD_NL_USB) { |
@@ -77,8 +77,7 @@ static int dwc3_pci_quirks(struct pci_dev *pdev) | |||
77 | pdata.dis_u3_susphy_quirk = true; | 77 | pdata.dis_u3_susphy_quirk = true; |
78 | pdata.dis_u2_susphy_quirk = true; | 78 | pdata.dis_u2_susphy_quirk = true; |
79 | 79 | ||
80 | return platform_device_add_data(pci_get_drvdata(pdev), &pdata, | 80 | return platform_device_add_data(dwc3, &pdata, sizeof(pdata)); |
81 | sizeof(pdata)); | ||
82 | } | 81 | } |
83 | 82 | ||
84 | if (pdev->vendor == PCI_VENDOR_ID_INTEL && | 83 | if (pdev->vendor == PCI_VENDOR_ID_INTEL && |
@@ -123,8 +122,7 @@ static int dwc3_pci_quirks(struct pci_dev *pdev) | |||
123 | pdata.has_lpm_erratum = true; | 122 | pdata.has_lpm_erratum = true; |
124 | pdata.dis_enblslpm_quirk = true; | 123 | pdata.dis_enblslpm_quirk = true; |
125 | 124 | ||
126 | return platform_device_add_data(pci_get_drvdata(pdev), &pdata, | 125 | return platform_device_add_data(dwc3, &pdata, sizeof(pdata)); |
127 | sizeof(pdata)); | ||
128 | } | 126 | } |
129 | 127 | ||
130 | return 0; | 128 | return 0; |
@@ -169,20 +167,20 @@ static int dwc3_pci_probe(struct pci_dev *pci, | |||
169 | return ret; | 167 | return ret; |
170 | } | 168 | } |
171 | 169 | ||
172 | pci_set_drvdata(pci, dwc3); | ||
173 | ret = dwc3_pci_quirks(pci); | ||
174 | if (ret) | ||
175 | goto err; | ||
176 | |||
177 | dwc3->dev.parent = dev; | 170 | dwc3->dev.parent = dev; |
178 | ACPI_COMPANION_SET(&dwc3->dev, ACPI_COMPANION(dev)); | 171 | ACPI_COMPANION_SET(&dwc3->dev, ACPI_COMPANION(dev)); |
179 | 172 | ||
173 | ret = dwc3_pci_quirks(pci, dwc3); | ||
174 | if (ret) | ||
175 | goto err; | ||
176 | |||
180 | ret = platform_device_add(dwc3); | 177 | ret = platform_device_add(dwc3); |
181 | if (ret) { | 178 | if (ret) { |
182 | dev_err(dev, "failed to register dwc3 device\n"); | 179 | dev_err(dev, "failed to register dwc3 device\n"); |
183 | goto err; | 180 | goto err; |
184 | } | 181 | } |
185 | 182 | ||
183 | pci_set_drvdata(pci, dwc3); | ||
186 | return 0; | 184 | return 0; |
187 | err: | 185 | err: |
188 | platform_device_put(dwc3); | 186 | platform_device_put(dwc3); |
diff --git a/drivers/usb/dwc3/ep0.c b/drivers/usb/dwc3/ep0.c index eca2e6d8e041..51b52a79dfec 100644 --- a/drivers/usb/dwc3/ep0.c +++ b/drivers/usb/dwc3/ep0.c | |||
@@ -70,10 +70,10 @@ static int dwc3_ep0_start_trans(struct dwc3 *dwc, u8 epnum, dma_addr_t buf_dma, | |||
70 | return 0; | 70 | return 0; |
71 | } | 71 | } |
72 | 72 | ||
73 | trb = &dwc->ep0_trb[dep->free_slot]; | 73 | trb = &dwc->ep0_trb[dep->trb_enqueue]; |
74 | 74 | ||
75 | if (chain) | 75 | if (chain) |
76 | dep->free_slot++; | 76 | dep->trb_enqueue++; |
77 | 77 | ||
78 | trb->bpl = lower_32_bits(buf_dma); | 78 | trb->bpl = lower_32_bits(buf_dma); |
79 | trb->bph = upper_32_bits(buf_dma); | 79 | trb->bph = upper_32_bits(buf_dma); |
@@ -124,7 +124,7 @@ static int __dwc3_gadget_ep0_queue(struct dwc3_ep *dep, | |||
124 | req->request.status = -EINPROGRESS; | 124 | req->request.status = -EINPROGRESS; |
125 | req->epnum = dep->number; | 125 | req->epnum = dep->number; |
126 | 126 | ||
127 | list_add_tail(&req->list, &dep->request_list); | 127 | list_add_tail(&req->list, &dep->pending_list); |
128 | 128 | ||
129 | /* | 129 | /* |
130 | * Gadget driver might not be quick enough to queue a request | 130 | * Gadget driver might not be quick enough to queue a request |
@@ -240,7 +240,7 @@ int dwc3_gadget_ep0_queue(struct usb_ep *ep, struct usb_request *request, | |||
240 | } | 240 | } |
241 | 241 | ||
242 | /* we share one TRB for ep0/1 */ | 242 | /* we share one TRB for ep0/1 */ |
243 | if (!list_empty(&dep->request_list)) { | 243 | if (!list_empty(&dep->pending_list)) { |
244 | ret = -EBUSY; | 244 | ret = -EBUSY; |
245 | goto out; | 245 | goto out; |
246 | } | 246 | } |
@@ -272,10 +272,10 @@ static void dwc3_ep0_stall_and_restart(struct dwc3 *dwc) | |||
272 | dep->flags = DWC3_EP_ENABLED; | 272 | dep->flags = DWC3_EP_ENABLED; |
273 | dwc->delayed_status = false; | 273 | dwc->delayed_status = false; |
274 | 274 | ||
275 | if (!list_empty(&dep->request_list)) { | 275 | if (!list_empty(&dep->pending_list)) { |
276 | struct dwc3_request *req; | 276 | struct dwc3_request *req; |
277 | 277 | ||
278 | req = next_request(&dep->request_list); | 278 | req = next_request(&dep->pending_list); |
279 | dwc3_gadget_giveback(dep, req, -ECONNRESET); | 279 | dwc3_gadget_giveback(dep, req, -ECONNRESET); |
280 | } | 280 | } |
281 | 281 | ||
@@ -463,8 +463,18 @@ static int dwc3_ep0_handle_feature(struct dwc3 *dwc, | |||
463 | if (!set) | 463 | if (!set) |
464 | return -EINVAL; | 464 | return -EINVAL; |
465 | 465 | ||
466 | dwc->test_mode_nr = wIndex >> 8; | 466 | switch (wIndex >> 8) { |
467 | dwc->test_mode = true; | 467 | case TEST_J: |
468 | case TEST_K: | ||
469 | case TEST_SE0_NAK: | ||
470 | case TEST_PACKET: | ||
471 | case TEST_FORCE_EN: | ||
472 | dwc->test_mode_nr = wIndex >> 8; | ||
473 | dwc->test_mode = true; | ||
474 | break; | ||
475 | default: | ||
476 | return -EINVAL; | ||
477 | } | ||
468 | break; | 478 | break; |
469 | default: | 479 | default: |
470 | return -EINVAL; | 480 | return -EINVAL; |
@@ -586,9 +596,6 @@ static int dwc3_ep0_set_config(struct dwc3 *dwc, struct usb_ctrlrequest *ctrl) | |||
586 | reg = dwc3_readl(dwc->regs, DWC3_DCTL); | 596 | reg = dwc3_readl(dwc->regs, DWC3_DCTL); |
587 | reg |= (DWC3_DCTL_ACCEPTU1ENA | DWC3_DCTL_ACCEPTU2ENA); | 597 | reg |= (DWC3_DCTL_ACCEPTU1ENA | DWC3_DCTL_ACCEPTU2ENA); |
588 | dwc3_writel(dwc->regs, DWC3_DCTL, reg); | 598 | dwc3_writel(dwc->regs, DWC3_DCTL, reg); |
589 | |||
590 | dwc->resize_fifos = true; | ||
591 | dwc3_trace(trace_dwc3_ep0, "resize FIFOs flag SET"); | ||
592 | } | 599 | } |
593 | break; | 600 | break; |
594 | 601 | ||
@@ -809,7 +816,7 @@ static void dwc3_ep0_complete_data(struct dwc3 *dwc, | |||
809 | 816 | ||
810 | trace_dwc3_complete_trb(ep0, trb); | 817 | trace_dwc3_complete_trb(ep0, trb); |
811 | 818 | ||
812 | r = next_request(&ep0->request_list); | 819 | r = next_request(&ep0->pending_list); |
813 | if (!r) | 820 | if (!r) |
814 | return; | 821 | return; |
815 | 822 | ||
@@ -848,7 +855,7 @@ static void dwc3_ep0_complete_data(struct dwc3 *dwc, | |||
848 | trb++; | 855 | trb++; |
849 | length = trb->size & DWC3_TRB_SIZE_MASK; | 856 | length = trb->size & DWC3_TRB_SIZE_MASK; |
850 | 857 | ||
851 | ep0->free_slot = 0; | 858 | ep0->trb_enqueue = 0; |
852 | } | 859 | } |
853 | 860 | ||
854 | transfer_size = roundup((ur->length - transfer_size), | 861 | transfer_size = roundup((ur->length - transfer_size), |
@@ -897,8 +904,8 @@ static void dwc3_ep0_complete_status(struct dwc3 *dwc, | |||
897 | 904 | ||
898 | trace_dwc3_complete_trb(dep, trb); | 905 | trace_dwc3_complete_trb(dep, trb); |
899 | 906 | ||
900 | if (!list_empty(&dep->request_list)) { | 907 | if (!list_empty(&dep->pending_list)) { |
901 | r = next_request(&dep->request_list); | 908 | r = next_request(&dep->pending_list); |
902 | 909 | ||
903 | dwc3_gadget_giveback(dep, r, 0); | 910 | dwc3_gadget_giveback(dep, r, 0); |
904 | } | 911 | } |
@@ -1027,12 +1034,6 @@ static int dwc3_ep0_start_control_status(struct dwc3_ep *dep) | |||
1027 | 1034 | ||
1028 | static void __dwc3_ep0_do_control_status(struct dwc3 *dwc, struct dwc3_ep *dep) | 1035 | static void __dwc3_ep0_do_control_status(struct dwc3 *dwc, struct dwc3_ep *dep) |
1029 | { | 1036 | { |
1030 | if (dwc->resize_fifos) { | ||
1031 | dwc3_trace(trace_dwc3_ep0, "Resizing FIFOs"); | ||
1032 | dwc3_gadget_resize_tx_fifos(dwc); | ||
1033 | dwc->resize_fifos = 0; | ||
1034 | } | ||
1035 | |||
1036 | WARN_ON(dwc3_ep0_start_control_status(dep)); | 1037 | WARN_ON(dwc3_ep0_start_control_status(dep)); |
1037 | } | 1038 | } |
1038 | 1039 | ||
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index 8e4a1b195e9b..9a7d0bd15dc3 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c | |||
@@ -145,90 +145,21 @@ int dwc3_gadget_set_link_state(struct dwc3 *dwc, enum dwc3_link_state state) | |||
145 | return -ETIMEDOUT; | 145 | return -ETIMEDOUT; |
146 | } | 146 | } |
147 | 147 | ||
148 | /** | 148 | static void dwc3_ep_inc_enq(struct dwc3_ep *dep) |
149 | * dwc3_gadget_resize_tx_fifos - reallocate fifo spaces for current use-case | ||
150 | * @dwc: pointer to our context structure | ||
151 | * | ||
152 | * This function will a best effort FIFO allocation in order | ||
153 | * to improve FIFO usage and throughput, while still allowing | ||
154 | * us to enable as many endpoints as possible. | ||
155 | * | ||
156 | * Keep in mind that this operation will be highly dependent | ||
157 | * on the configured size for RAM1 - which contains TxFifo -, | ||
158 | * the amount of endpoints enabled on coreConsultant tool, and | ||
159 | * the width of the Master Bus. | ||
160 | * | ||
161 | * In the ideal world, we would always be able to satisfy the | ||
162 | * following equation: | ||
163 | * | ||
164 | * ((512 + 2 * MDWIDTH-Bytes) + (Number of IN Endpoints - 1) * \ | ||
165 | * (3 * (1024 + MDWIDTH-Bytes) + MDWIDTH-Bytes)) / MDWIDTH-Bytes | ||
166 | * | ||
167 | * Unfortunately, due to many variables that's not always the case. | ||
168 | */ | ||
169 | int dwc3_gadget_resize_tx_fifos(struct dwc3 *dwc) | ||
170 | { | 149 | { |
171 | int last_fifo_depth = 0; | 150 | dep->trb_enqueue++; |
172 | int ram1_depth; | 151 | dep->trb_enqueue %= DWC3_TRB_NUM; |
173 | int fifo_size; | 152 | } |
174 | int mdwidth; | ||
175 | int num; | ||
176 | |||
177 | if (!dwc->needs_fifo_resize) | ||
178 | return 0; | ||
179 | |||
180 | ram1_depth = DWC3_RAM1_DEPTH(dwc->hwparams.hwparams7); | ||
181 | mdwidth = DWC3_MDWIDTH(dwc->hwparams.hwparams0); | ||
182 | |||
183 | /* MDWIDTH is represented in bits, we need it in bytes */ | ||
184 | mdwidth >>= 3; | ||
185 | |||
186 | /* | ||
187 | * FIXME For now we will only allocate 1 wMaxPacketSize space | ||
188 | * for each enabled endpoint, later patches will come to | ||
189 | * improve this algorithm so that we better use the internal | ||
190 | * FIFO space | ||
191 | */ | ||
192 | for (num = 0; num < dwc->num_in_eps; num++) { | ||
193 | /* bit0 indicates direction; 1 means IN ep */ | ||
194 | struct dwc3_ep *dep = dwc->eps[(num << 1) | 1]; | ||
195 | int mult = 1; | ||
196 | int tmp; | ||
197 | |||
198 | if (!(dep->flags & DWC3_EP_ENABLED)) | ||
199 | continue; | ||
200 | |||
201 | if (usb_endpoint_xfer_bulk(dep->endpoint.desc) | ||
202 | || usb_endpoint_xfer_isoc(dep->endpoint.desc)) | ||
203 | mult = 3; | ||
204 | |||
205 | /* | ||
206 | * REVISIT: the following assumes we will always have enough | ||
207 | * space available on the FIFO RAM for all possible use cases. | ||
208 | * Make sure that's true somehow and change FIFO allocation | ||
209 | * accordingly. | ||
210 | * | ||
211 | * If we have Bulk or Isochronous endpoints, we want | ||
212 | * them to be able to be very, very fast. So we're giving | ||
213 | * those endpoints a fifo_size which is enough for 3 full | ||
214 | * packets | ||
215 | */ | ||
216 | tmp = mult * (dep->endpoint.maxpacket + mdwidth); | ||
217 | tmp += mdwidth; | ||
218 | |||
219 | fifo_size = DIV_ROUND_UP(tmp, mdwidth); | ||
220 | |||
221 | fifo_size |= (last_fifo_depth << 16); | ||
222 | |||
223 | dwc3_trace(trace_dwc3_gadget, "%s: Fifo Addr %04x Size %d", | ||
224 | dep->name, last_fifo_depth, fifo_size & 0xffff); | ||
225 | |||
226 | dwc3_writel(dwc->regs, DWC3_GTXFIFOSIZ(num), fifo_size); | ||
227 | 153 | ||
228 | last_fifo_depth += (fifo_size & 0xffff); | 154 | static void dwc3_ep_inc_deq(struct dwc3_ep *dep) |
229 | } | 155 | { |
156 | dep->trb_dequeue++; | ||
157 | dep->trb_dequeue %= DWC3_TRB_NUM; | ||
158 | } | ||
230 | 159 | ||
231 | return 0; | 160 | static int dwc3_ep_is_last_trb(unsigned int index) |
161 | { | ||
162 | return index == DWC3_TRB_NUM - 1; | ||
232 | } | 163 | } |
233 | 164 | ||
234 | void dwc3_gadget_giveback(struct dwc3_ep *dep, struct dwc3_request *req, | 165 | void dwc3_gadget_giveback(struct dwc3_ep *dep, struct dwc3_request *req, |
@@ -237,21 +168,19 @@ void dwc3_gadget_giveback(struct dwc3_ep *dep, struct dwc3_request *req, | |||
237 | struct dwc3 *dwc = dep->dwc; | 168 | struct dwc3 *dwc = dep->dwc; |
238 | int i; | 169 | int i; |
239 | 170 | ||
240 | if (req->queued) { | 171 | if (req->started) { |
241 | i = 0; | 172 | i = 0; |
242 | do { | 173 | do { |
243 | dep->busy_slot++; | 174 | dwc3_ep_inc_deq(dep); |
244 | /* | 175 | /* |
245 | * Skip LINK TRB. We can't use req->trb and check for | 176 | * Skip LINK TRB. We can't use req->trb and check for |
246 | * DWC3_TRBCTL_LINK_TRB because it points the TRB we | 177 | * DWC3_TRBCTL_LINK_TRB because it points the TRB we |
247 | * just completed (not the LINK TRB). | 178 | * just completed (not the LINK TRB). |
248 | */ | 179 | */ |
249 | if (((dep->busy_slot & DWC3_TRB_MASK) == | 180 | if (dwc3_ep_is_last_trb(dep->trb_dequeue)) |
250 | DWC3_TRB_NUM- 1) && | 181 | dwc3_ep_inc_deq(dep); |
251 | usb_endpoint_xfer_isoc(dep->endpoint.desc)) | ||
252 | dep->busy_slot++; | ||
253 | } while(++i < req->request.num_mapped_sgs); | 182 | } while(++i < req->request.num_mapped_sgs); |
254 | req->queued = false; | 183 | req->started = false; |
255 | } | 184 | } |
256 | list_del(&req->list); | 185 | list_del(&req->list); |
257 | req->trb = NULL; | 186 | req->trb = NULL; |
@@ -307,6 +236,8 @@ int dwc3_send_gadget_generic_command(struct dwc3 *dwc, unsigned cmd, u32 param) | |||
307 | } while (1); | 236 | } while (1); |
308 | } | 237 | } |
309 | 238 | ||
239 | static int __dwc3_gadget_wakeup(struct dwc3 *dwc); | ||
240 | |||
310 | int dwc3_send_gadget_ep_cmd(struct dwc3 *dwc, unsigned ep, | 241 | int dwc3_send_gadget_ep_cmd(struct dwc3 *dwc, unsigned ep, |
311 | unsigned cmd, struct dwc3_gadget_ep_cmd_params *params) | 242 | unsigned cmd, struct dwc3_gadget_ep_cmd_params *params) |
312 | { | 243 | { |
@@ -314,8 +245,40 @@ int dwc3_send_gadget_ep_cmd(struct dwc3 *dwc, unsigned ep, | |||
314 | u32 timeout = 500; | 245 | u32 timeout = 500; |
315 | u32 reg; | 246 | u32 reg; |
316 | 247 | ||
248 | int susphy = false; | ||
249 | int ret = -EINVAL; | ||
250 | |||
317 | trace_dwc3_gadget_ep_cmd(dep, cmd, params); | 251 | trace_dwc3_gadget_ep_cmd(dep, cmd, params); |
318 | 252 | ||
253 | /* | ||
254 | * Synopsys Databook 2.60a states, on section 6.3.2.5.[1-8], that if | ||
255 | * we're issuing an endpoint command, we must check if | ||
256 | * GUSB2PHYCFG.SUSPHY bit is set. If it is, then we need to clear it. | ||
257 | * | ||
258 | * We will also set SUSPHY bit to what it was before returning as stated | ||
259 | * by the same section on Synopsys databook. | ||
260 | */ | ||
261 | reg = dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0)); | ||
262 | if (unlikely(reg & DWC3_GUSB2PHYCFG_SUSPHY)) { | ||
263 | susphy = true; | ||
264 | reg &= ~DWC3_GUSB2PHYCFG_SUSPHY; | ||
265 | dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg); | ||
266 | } | ||
267 | |||
268 | if (cmd == DWC3_DEPCMD_STARTTRANSFER) { | ||
269 | int needs_wakeup; | ||
270 | |||
271 | needs_wakeup = (dwc->link_state == DWC3_LINK_STATE_U1 || | ||
272 | dwc->link_state == DWC3_LINK_STATE_U2 || | ||
273 | dwc->link_state == DWC3_LINK_STATE_U3); | ||
274 | |||
275 | if (unlikely(needs_wakeup)) { | ||
276 | ret = __dwc3_gadget_wakeup(dwc); | ||
277 | dev_WARN_ONCE(dwc->dev, ret, "wakeup failed --> %d\n", | ||
278 | ret); | ||
279 | } | ||
280 | } | ||
281 | |||
319 | dwc3_writel(dwc->regs, DWC3_DEPCMDPAR0(ep), params->param0); | 282 | dwc3_writel(dwc->regs, DWC3_DEPCMDPAR0(ep), params->param0); |
320 | dwc3_writel(dwc->regs, DWC3_DEPCMDPAR1(ep), params->param1); | 283 | dwc3_writel(dwc->regs, DWC3_DEPCMDPAR1(ep), params->param1); |
321 | dwc3_writel(dwc->regs, DWC3_DEPCMDPAR2(ep), params->param2); | 284 | dwc3_writel(dwc->regs, DWC3_DEPCMDPAR2(ep), params->param2); |
@@ -324,12 +287,40 @@ int dwc3_send_gadget_ep_cmd(struct dwc3 *dwc, unsigned ep, | |||
324 | do { | 287 | do { |
325 | reg = dwc3_readl(dwc->regs, DWC3_DEPCMD(ep)); | 288 | reg = dwc3_readl(dwc->regs, DWC3_DEPCMD(ep)); |
326 | if (!(reg & DWC3_DEPCMD_CMDACT)) { | 289 | if (!(reg & DWC3_DEPCMD_CMDACT)) { |
290 | int cmd_status = DWC3_DEPCMD_STATUS(reg); | ||
291 | |||
327 | dwc3_trace(trace_dwc3_gadget, | 292 | dwc3_trace(trace_dwc3_gadget, |
328 | "Command Complete --> %d", | 293 | "Command Complete --> %d", |
329 | DWC3_DEPCMD_STATUS(reg)); | 294 | cmd_status); |
330 | if (DWC3_DEPCMD_STATUS(reg)) | 295 | |
331 | return -EINVAL; | 296 | switch (cmd_status) { |
332 | return 0; | 297 | case 0: |
298 | ret = 0; | ||
299 | break; | ||
300 | case DEPEVT_TRANSFER_NO_RESOURCE: | ||
301 | dwc3_trace(trace_dwc3_gadget, "%s: no resource available"); | ||
302 | ret = -EINVAL; | ||
303 | break; | ||
304 | case DEPEVT_TRANSFER_BUS_EXPIRY: | ||
305 | /* | ||
306 | * SW issues START TRANSFER command to | ||
307 | * isochronous ep with future frame interval. If | ||
308 | * future interval time has already passed when | ||
309 | * core receives the command, it will respond | ||
310 | * with an error status of 'Bus Expiry'. | ||
311 | * | ||
312 | * Instead of always returning -EINVAL, let's | ||
313 | * give a hint to the gadget driver that this is | ||
314 | * the case by returning -EAGAIN. | ||
315 | */ | ||
316 | dwc3_trace(trace_dwc3_gadget, "%s: bus expiry"); | ||
317 | ret = -EAGAIN; | ||
318 | break; | ||
319 | default: | ||
320 | dev_WARN(dwc->dev, "UNKNOWN cmd status\n"); | ||
321 | } | ||
322 | |||
323 | break; | ||
333 | } | 324 | } |
334 | 325 | ||
335 | /* | 326 | /* |
@@ -340,11 +331,20 @@ int dwc3_send_gadget_ep_cmd(struct dwc3 *dwc, unsigned ep, | |||
340 | if (!timeout) { | 331 | if (!timeout) { |
341 | dwc3_trace(trace_dwc3_gadget, | 332 | dwc3_trace(trace_dwc3_gadget, |
342 | "Command Timed Out"); | 333 | "Command Timed Out"); |
343 | return -ETIMEDOUT; | 334 | ret = -ETIMEDOUT; |
335 | break; | ||
344 | } | 336 | } |
345 | 337 | ||
346 | udelay(1); | 338 | udelay(1); |
347 | } while (1); | 339 | } while (1); |
340 | |||
341 | if (unlikely(susphy)) { | ||
342 | reg = dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0)); | ||
343 | reg |= DWC3_GUSB2PHYCFG_SUSPHY; | ||
344 | dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg); | ||
345 | } | ||
346 | |||
347 | return ret; | ||
348 | } | 348 | } |
349 | 349 | ||
350 | static dma_addr_t dwc3_trb_dma_offset(struct dwc3_ep *dep, | 350 | static dma_addr_t dwc3_trb_dma_offset(struct dwc3_ep *dep, |
@@ -464,9 +464,19 @@ static int dwc3_gadget_set_ep_config(struct dwc3 *dwc, struct dwc3_ep *dep, | |||
464 | 464 | ||
465 | /* Burst size is only needed in SuperSpeed mode */ | 465 | /* Burst size is only needed in SuperSpeed mode */ |
466 | if (dwc->gadget.speed >= USB_SPEED_SUPER) { | 466 | if (dwc->gadget.speed >= USB_SPEED_SUPER) { |
467 | u32 burst = dep->endpoint.maxburst - 1; | 467 | u32 burst = dep->endpoint.maxburst; |
468 | u32 nump; | ||
469 | u32 reg; | ||
470 | |||
471 | /* update NumP */ | ||
472 | reg = dwc3_readl(dwc->regs, DWC3_DCFG); | ||
473 | nump = DWC3_DCFG_NUMP(reg); | ||
474 | nump = max(nump, burst); | ||
475 | reg &= ~DWC3_DCFG_NUMP_MASK; | ||
476 | reg |= nump << DWC3_DCFG_NUMP_SHIFT; | ||
477 | dwc3_writel(dwc->regs, DWC3_DCFG, reg); | ||
468 | 478 | ||
469 | params.param0 |= DWC3_DEPCFG_BURST_SIZE(burst); | 479 | params.param0 |= DWC3_DEPCFG_BURST_SIZE(burst - 1); |
470 | } | 480 | } |
471 | 481 | ||
472 | if (ignore) | 482 | if (ignore) |
@@ -567,10 +577,10 @@ static int __dwc3_gadget_ep_enable(struct dwc3_ep *dep, | |||
567 | reg |= DWC3_DALEPENA_EP(dep->number); | 577 | reg |= DWC3_DALEPENA_EP(dep->number); |
568 | dwc3_writel(dwc->regs, DWC3_DALEPENA, reg); | 578 | dwc3_writel(dwc->regs, DWC3_DALEPENA, reg); |
569 | 579 | ||
570 | if (!usb_endpoint_xfer_isoc(desc)) | 580 | if (usb_endpoint_xfer_control(desc)) |
571 | goto out; | 581 | goto out; |
572 | 582 | ||
573 | /* Link TRB for ISOC. The HWO bit is never reset */ | 583 | /* Link TRB. The HWO bit is never reset */ |
574 | trb_st_hw = &dep->trb_pool[0]; | 584 | trb_st_hw = &dep->trb_pool[0]; |
575 | 585 | ||
576 | trb_link = &dep->trb_pool[DWC3_TRB_NUM - 1]; | 586 | trb_link = &dep->trb_pool[DWC3_TRB_NUM - 1]; |
@@ -608,19 +618,19 @@ static void dwc3_remove_requests(struct dwc3 *dwc, struct dwc3_ep *dep) | |||
608 | { | 618 | { |
609 | struct dwc3_request *req; | 619 | struct dwc3_request *req; |
610 | 620 | ||
611 | if (!list_empty(&dep->req_queued)) { | 621 | if (!list_empty(&dep->started_list)) { |
612 | dwc3_stop_active_transfer(dwc, dep->number, true); | 622 | dwc3_stop_active_transfer(dwc, dep->number, true); |
613 | 623 | ||
614 | /* - giveback all requests to gadget driver */ | 624 | /* - giveback all requests to gadget driver */ |
615 | while (!list_empty(&dep->req_queued)) { | 625 | while (!list_empty(&dep->started_list)) { |
616 | req = next_request(&dep->req_queued); | 626 | req = next_request(&dep->started_list); |
617 | 627 | ||
618 | dwc3_gadget_giveback(dep, req, -ESHUTDOWN); | 628 | dwc3_gadget_giveback(dep, req, -ESHUTDOWN); |
619 | } | 629 | } |
620 | } | 630 | } |
621 | 631 | ||
622 | while (!list_empty(&dep->request_list)) { | 632 | while (!list_empty(&dep->pending_list)) { |
623 | req = next_request(&dep->request_list); | 633 | req = next_request(&dep->pending_list); |
624 | 634 | ||
625 | dwc3_gadget_giveback(dep, req, -ESHUTDOWN); | 635 | dwc3_gadget_giveback(dep, req, -ESHUTDOWN); |
626 | } | 636 | } |
@@ -783,20 +793,19 @@ static void dwc3_prepare_one_trb(struct dwc3_ep *dep, | |||
783 | chain ? " chain" : ""); | 793 | chain ? " chain" : ""); |
784 | 794 | ||
785 | 795 | ||
786 | trb = &dep->trb_pool[dep->free_slot & DWC3_TRB_MASK]; | 796 | trb = &dep->trb_pool[dep->trb_enqueue]; |
787 | 797 | ||
788 | if (!req->trb) { | 798 | if (!req->trb) { |
789 | dwc3_gadget_move_request_queued(req); | 799 | dwc3_gadget_move_started_request(req); |
790 | req->trb = trb; | 800 | req->trb = trb; |
791 | req->trb_dma = dwc3_trb_dma_offset(dep, trb); | 801 | req->trb_dma = dwc3_trb_dma_offset(dep, trb); |
792 | req->start_slot = dep->free_slot & DWC3_TRB_MASK; | 802 | req->first_trb_index = dep->trb_enqueue; |
793 | } | 803 | } |
794 | 804 | ||
795 | dep->free_slot++; | 805 | dwc3_ep_inc_enq(dep); |
796 | /* Skip the LINK-TRB on ISOC */ | 806 | /* Skip the LINK-TRB */ |
797 | if (((dep->free_slot & DWC3_TRB_MASK) == DWC3_TRB_NUM - 1) && | 807 | if (dwc3_ep_is_last_trb(dep->trb_enqueue)) |
798 | usb_endpoint_xfer_isoc(dep->endpoint.desc)) | 808 | dwc3_ep_inc_enq(dep); |
799 | dep->free_slot++; | ||
800 | 809 | ||
801 | trb->size = DWC3_TRB_SIZE_LENGTH(length); | 810 | trb->size = DWC3_TRB_SIZE_LENGTH(length); |
802 | trb->bpl = lower_32_bits(dma); | 811 | trb->bpl = lower_32_bits(dma); |
@@ -812,6 +821,9 @@ static void dwc3_prepare_one_trb(struct dwc3_ep *dep, | |||
812 | trb->ctrl = DWC3_TRBCTL_ISOCHRONOUS_FIRST; | 821 | trb->ctrl = DWC3_TRBCTL_ISOCHRONOUS_FIRST; |
813 | else | 822 | else |
814 | trb->ctrl = DWC3_TRBCTL_ISOCHRONOUS; | 823 | trb->ctrl = DWC3_TRBCTL_ISOCHRONOUS; |
824 | |||
825 | /* always enable Interrupt on Missed ISOC */ | ||
826 | trb->ctrl |= DWC3_TRB_CTRL_ISP_IMI; | ||
815 | break; | 827 | break; |
816 | 828 | ||
817 | case USB_ENDPOINT_XFER_BULK: | 829 | case USB_ENDPOINT_XFER_BULK: |
@@ -826,15 +838,14 @@ static void dwc3_prepare_one_trb(struct dwc3_ep *dep, | |||
826 | BUG(); | 838 | BUG(); |
827 | } | 839 | } |
828 | 840 | ||
841 | /* always enable Continue on Short Packet */ | ||
842 | trb->ctrl |= DWC3_TRB_CTRL_CSP; | ||
843 | |||
829 | if (!req->request.no_interrupt && !chain) | 844 | if (!req->request.no_interrupt && !chain) |
830 | trb->ctrl |= DWC3_TRB_CTRL_IOC; | 845 | trb->ctrl |= DWC3_TRB_CTRL_IOC | DWC3_TRB_CTRL_ISP_IMI; |
831 | 846 | ||
832 | if (usb_endpoint_xfer_isoc(dep->endpoint.desc)) { | 847 | if (last) |
833 | trb->ctrl |= DWC3_TRB_CTRL_ISP_IMI; | ||
834 | trb->ctrl |= DWC3_TRB_CTRL_CSP; | ||
835 | } else if (last) { | ||
836 | trb->ctrl |= DWC3_TRB_CTRL_LST; | 848 | trb->ctrl |= DWC3_TRB_CTRL_LST; |
837 | } | ||
838 | 849 | ||
839 | if (chain) | 850 | if (chain) |
840 | trb->ctrl |= DWC3_TRB_CTRL_CHN; | 851 | trb->ctrl |= DWC3_TRB_CTRL_CHN; |
@@ -860,55 +871,29 @@ static void dwc3_prepare_trbs(struct dwc3_ep *dep, bool starting) | |||
860 | { | 871 | { |
861 | struct dwc3_request *req, *n; | 872 | struct dwc3_request *req, *n; |
862 | u32 trbs_left; | 873 | u32 trbs_left; |
863 | u32 max; | ||
864 | unsigned int last_one = 0; | 874 | unsigned int last_one = 0; |
865 | 875 | ||
866 | BUILD_BUG_ON_NOT_POWER_OF_2(DWC3_TRB_NUM); | 876 | BUILD_BUG_ON_NOT_POWER_OF_2(DWC3_TRB_NUM); |
867 | 877 | ||
868 | /* the first request must not be queued */ | 878 | trbs_left = dep->trb_dequeue - dep->trb_enqueue; |
869 | trbs_left = (dep->busy_slot - dep->free_slot) & DWC3_TRB_MASK; | ||
870 | |||
871 | /* Can't wrap around on a non-isoc EP since there's no link TRB */ | ||
872 | if (!usb_endpoint_xfer_isoc(dep->endpoint.desc)) { | ||
873 | max = DWC3_TRB_NUM - (dep->free_slot & DWC3_TRB_MASK); | ||
874 | if (trbs_left > max) | ||
875 | trbs_left = max; | ||
876 | } | ||
877 | 879 | ||
878 | /* | 880 | /* |
879 | * If busy & slot are equal than it is either full or empty. If we are | 881 | * If enqueue & dequeue are equal than it is either full or empty. If we |
880 | * starting to process requests then we are empty. Otherwise we are | 882 | * are starting to process requests then we are empty. Otherwise we are |
881 | * full and don't do anything | 883 | * full and don't do anything |
882 | */ | 884 | */ |
883 | if (!trbs_left) { | 885 | if (!trbs_left) { |
884 | if (!starting) | 886 | if (!starting) |
885 | return; | 887 | return; |
888 | |||
886 | trbs_left = DWC3_TRB_NUM; | 889 | trbs_left = DWC3_TRB_NUM; |
887 | /* | ||
888 | * In case we start from scratch, we queue the ISOC requests | ||
889 | * starting from slot 1. This is done because we use ring | ||
890 | * buffer and have no LST bit to stop us. Instead, we place | ||
891 | * IOC bit every TRB_NUM/4. We try to avoid having an interrupt | ||
892 | * after the first request so we start at slot 1 and have | ||
893 | * 7 requests proceed before we hit the first IOC. | ||
894 | * Other transfer types don't use the ring buffer and are | ||
895 | * processed from the first TRB until the last one. Since we | ||
896 | * don't wrap around we have to start at the beginning. | ||
897 | */ | ||
898 | if (usb_endpoint_xfer_isoc(dep->endpoint.desc)) { | ||
899 | dep->busy_slot = 1; | ||
900 | dep->free_slot = 1; | ||
901 | } else { | ||
902 | dep->busy_slot = 0; | ||
903 | dep->free_slot = 0; | ||
904 | } | ||
905 | } | 890 | } |
906 | 891 | ||
907 | /* The last TRB is a link TRB, not used for xfer */ | 892 | /* The last TRB is a link TRB, not used for xfer */ |
908 | if ((trbs_left <= 1) && usb_endpoint_xfer_isoc(dep->endpoint.desc)) | 893 | if (trbs_left <= 1) |
909 | return; | 894 | return; |
910 | 895 | ||
911 | list_for_each_entry_safe(req, n, &dep->request_list, list) { | 896 | list_for_each_entry_safe(req, n, &dep->pending_list, list) { |
912 | unsigned length; | 897 | unsigned length; |
913 | dma_addr_t dma; | 898 | dma_addr_t dma; |
914 | last_one = false; | 899 | last_one = false; |
@@ -927,7 +912,7 @@ static void dwc3_prepare_trbs(struct dwc3_ep *dep, bool starting) | |||
927 | 912 | ||
928 | if (i == (request->num_mapped_sgs - 1) || | 913 | if (i == (request->num_mapped_sgs - 1) || |
929 | sg_is_last(s)) { | 914 | sg_is_last(s)) { |
930 | if (list_empty(&dep->request_list)) | 915 | if (list_empty(&dep->pending_list)) |
931 | last_one = true; | 916 | last_one = true; |
932 | chain = false; | 917 | chain = false; |
933 | } | 918 | } |
@@ -957,7 +942,7 @@ static void dwc3_prepare_trbs(struct dwc3_ep *dep, bool starting) | |||
957 | last_one = 1; | 942 | last_one = 1; |
958 | 943 | ||
959 | /* Is this the last request? */ | 944 | /* Is this the last request? */ |
960 | if (list_is_last(&req->list, &dep->request_list)) | 945 | if (list_is_last(&req->list, &dep->pending_list)) |
961 | last_one = 1; | 946 | last_one = 1; |
962 | 947 | ||
963 | dwc3_prepare_one_trb(dep, req, dma, length, | 948 | dwc3_prepare_one_trb(dep, req, dma, length, |
@@ -988,18 +973,18 @@ static int __dwc3_gadget_kick_transfer(struct dwc3_ep *dep, u16 cmd_param, | |||
988 | * new requests as we try to set the IOC bit only on the last request. | 973 | * new requests as we try to set the IOC bit only on the last request. |
989 | */ | 974 | */ |
990 | if (start_new) { | 975 | if (start_new) { |
991 | if (list_empty(&dep->req_queued)) | 976 | if (list_empty(&dep->started_list)) |
992 | dwc3_prepare_trbs(dep, start_new); | 977 | dwc3_prepare_trbs(dep, start_new); |
993 | 978 | ||
994 | /* req points to the first request which will be sent */ | 979 | /* req points to the first request which will be sent */ |
995 | req = next_request(&dep->req_queued); | 980 | req = next_request(&dep->started_list); |
996 | } else { | 981 | } else { |
997 | dwc3_prepare_trbs(dep, start_new); | 982 | dwc3_prepare_trbs(dep, start_new); |
998 | 983 | ||
999 | /* | 984 | /* |
1000 | * req points to the first request where HWO changed from 0 to 1 | 985 | * req points to the first request where HWO changed from 0 to 1 |
1001 | */ | 986 | */ |
1002 | req = next_request(&dep->req_queued); | 987 | req = next_request(&dep->started_list); |
1003 | } | 988 | } |
1004 | if (!req) { | 989 | if (!req) { |
1005 | dep->flags |= DWC3_EP_PENDING_REQUEST; | 990 | dep->flags |= DWC3_EP_PENDING_REQUEST; |
@@ -1046,7 +1031,7 @@ static void __dwc3_gadget_start_isoc(struct dwc3 *dwc, | |||
1046 | { | 1031 | { |
1047 | u32 uf; | 1032 | u32 uf; |
1048 | 1033 | ||
1049 | if (list_empty(&dep->request_list)) { | 1034 | if (list_empty(&dep->pending_list)) { |
1050 | dwc3_trace(trace_dwc3_gadget, | 1035 | dwc3_trace(trace_dwc3_gadget, |
1051 | "ISOC ep %s run out for requests", | 1036 | "ISOC ep %s run out for requests", |
1052 | dep->name); | 1037 | dep->name); |
@@ -1114,7 +1099,7 @@ static int __dwc3_gadget_ep_queue(struct dwc3_ep *dep, struct dwc3_request *req) | |||
1114 | if (ret) | 1099 | if (ret) |
1115 | return ret; | 1100 | return ret; |
1116 | 1101 | ||
1117 | list_add_tail(&req->list, &dep->request_list); | 1102 | list_add_tail(&req->list, &dep->pending_list); |
1118 | 1103 | ||
1119 | /* | 1104 | /* |
1120 | * If there are no pending requests and the endpoint isn't already | 1105 | * If there are no pending requests and the endpoint isn't already |
@@ -1149,7 +1134,7 @@ static int __dwc3_gadget_ep_queue(struct dwc3_ep *dep, struct dwc3_request *req) | |||
1149 | * notion of current microframe. | 1134 | * notion of current microframe. |
1150 | */ | 1135 | */ |
1151 | if (usb_endpoint_xfer_isoc(dep->endpoint.desc)) { | 1136 | if (usb_endpoint_xfer_isoc(dep->endpoint.desc)) { |
1152 | if (list_empty(&dep->req_queued)) { | 1137 | if (list_empty(&dep->started_list)) { |
1153 | dwc3_stop_active_transfer(dwc, dep->number, true); | 1138 | dwc3_stop_active_transfer(dwc, dep->number, true); |
1154 | dep->flags = DWC3_EP_ENABLED; | 1139 | dep->flags = DWC3_EP_ENABLED; |
1155 | } | 1140 | } |
@@ -1267,13 +1252,13 @@ static int dwc3_gadget_ep_dequeue(struct usb_ep *ep, | |||
1267 | 1252 | ||
1268 | spin_lock_irqsave(&dwc->lock, flags); | 1253 | spin_lock_irqsave(&dwc->lock, flags); |
1269 | 1254 | ||
1270 | list_for_each_entry(r, &dep->request_list, list) { | 1255 | list_for_each_entry(r, &dep->pending_list, list) { |
1271 | if (r == req) | 1256 | if (r == req) |
1272 | break; | 1257 | break; |
1273 | } | 1258 | } |
1274 | 1259 | ||
1275 | if (r != req) { | 1260 | if (r != req) { |
1276 | list_for_each_entry(r, &dep->req_queued, list) { | 1261 | list_for_each_entry(r, &dep->started_list, list) { |
1277 | if (r == req) | 1262 | if (r == req) |
1278 | break; | 1263 | break; |
1279 | } | 1264 | } |
@@ -1313,10 +1298,10 @@ int __dwc3_gadget_ep_set_halt(struct dwc3_ep *dep, int value, int protocol) | |||
1313 | 1298 | ||
1314 | if (value) { | 1299 | if (value) { |
1315 | if (!protocol && ((dep->direction && dep->flags & DWC3_EP_BUSY) || | 1300 | if (!protocol && ((dep->direction && dep->flags & DWC3_EP_BUSY) || |
1316 | (!list_empty(&dep->req_queued) || | 1301 | (!list_empty(&dep->started_list) || |
1317 | !list_empty(&dep->request_list)))) { | 1302 | !list_empty(&dep->pending_list)))) { |
1318 | dwc3_trace(trace_dwc3_gadget, | 1303 | dwc3_trace(trace_dwc3_gadget, |
1319 | "%s: pending request, cannot halt\n", | 1304 | "%s: pending request, cannot halt", |
1320 | dep->name); | 1305 | dep->name); |
1321 | return -EAGAIN; | 1306 | return -EAGAIN; |
1322 | } | 1307 | } |
@@ -1417,22 +1402,16 @@ static int dwc3_gadget_get_frame(struct usb_gadget *g) | |||
1417 | return DWC3_DSTS_SOFFN(reg); | 1402 | return DWC3_DSTS_SOFFN(reg); |
1418 | } | 1403 | } |
1419 | 1404 | ||
1420 | static int dwc3_gadget_wakeup(struct usb_gadget *g) | 1405 | static int __dwc3_gadget_wakeup(struct dwc3 *dwc) |
1421 | { | 1406 | { |
1422 | struct dwc3 *dwc = gadget_to_dwc(g); | ||
1423 | |||
1424 | unsigned long timeout; | 1407 | unsigned long timeout; |
1425 | unsigned long flags; | ||
1426 | 1408 | ||
1409 | int ret; | ||
1427 | u32 reg; | 1410 | u32 reg; |
1428 | 1411 | ||
1429 | int ret = 0; | ||
1430 | |||
1431 | u8 link_state; | 1412 | u8 link_state; |
1432 | u8 speed; | 1413 | u8 speed; |
1433 | 1414 | ||
1434 | spin_lock_irqsave(&dwc->lock, flags); | ||
1435 | |||
1436 | /* | 1415 | /* |
1437 | * According to the Databook Remote wakeup request should | 1416 | * According to the Databook Remote wakeup request should |
1438 | * be issued only when the device is in early suspend state. | 1417 | * be issued only when the device is in early suspend state. |
@@ -1445,8 +1424,7 @@ static int dwc3_gadget_wakeup(struct usb_gadget *g) | |||
1445 | if ((speed == DWC3_DSTS_SUPERSPEED) || | 1424 | if ((speed == DWC3_DSTS_SUPERSPEED) || |
1446 | (speed == DWC3_DSTS_SUPERSPEED_PLUS)) { | 1425 | (speed == DWC3_DSTS_SUPERSPEED_PLUS)) { |
1447 | dwc3_trace(trace_dwc3_gadget, "no wakeup on SuperSpeed\n"); | 1426 | dwc3_trace(trace_dwc3_gadget, "no wakeup on SuperSpeed\n"); |
1448 | ret = -EINVAL; | 1427 | return -EINVAL; |
1449 | goto out; | ||
1450 | } | 1428 | } |
1451 | 1429 | ||
1452 | link_state = DWC3_DSTS_USBLNKST(reg); | 1430 | link_state = DWC3_DSTS_USBLNKST(reg); |
@@ -1459,14 +1437,13 @@ static int dwc3_gadget_wakeup(struct usb_gadget *g) | |||
1459 | dwc3_trace(trace_dwc3_gadget, | 1437 | dwc3_trace(trace_dwc3_gadget, |
1460 | "can't wakeup from '%s'\n", | 1438 | "can't wakeup from '%s'\n", |
1461 | dwc3_gadget_link_string(link_state)); | 1439 | dwc3_gadget_link_string(link_state)); |
1462 | ret = -EINVAL; | 1440 | return -EINVAL; |
1463 | goto out; | ||
1464 | } | 1441 | } |
1465 | 1442 | ||
1466 | ret = dwc3_gadget_set_link_state(dwc, DWC3_LINK_STATE_RECOV); | 1443 | ret = dwc3_gadget_set_link_state(dwc, DWC3_LINK_STATE_RECOV); |
1467 | if (ret < 0) { | 1444 | if (ret < 0) { |
1468 | dev_err(dwc->dev, "failed to put link in Recovery\n"); | 1445 | dev_err(dwc->dev, "failed to put link in Recovery\n"); |
1469 | goto out; | 1446 | return ret; |
1470 | } | 1447 | } |
1471 | 1448 | ||
1472 | /* Recent versions do this automatically */ | 1449 | /* Recent versions do this automatically */ |
@@ -1490,10 +1467,20 @@ static int dwc3_gadget_wakeup(struct usb_gadget *g) | |||
1490 | 1467 | ||
1491 | if (DWC3_DSTS_USBLNKST(reg) != DWC3_LINK_STATE_U0) { | 1468 | if (DWC3_DSTS_USBLNKST(reg) != DWC3_LINK_STATE_U0) { |
1492 | dev_err(dwc->dev, "failed to send remote wakeup\n"); | 1469 | dev_err(dwc->dev, "failed to send remote wakeup\n"); |
1493 | ret = -EINVAL; | 1470 | return -EINVAL; |
1494 | } | 1471 | } |
1495 | 1472 | ||
1496 | out: | 1473 | return 0; |
1474 | } | ||
1475 | |||
1476 | static int dwc3_gadget_wakeup(struct usb_gadget *g) | ||
1477 | { | ||
1478 | struct dwc3 *dwc = gadget_to_dwc(g); | ||
1479 | unsigned long flags; | ||
1480 | int ret; | ||
1481 | |||
1482 | spin_lock_irqsave(&dwc->lock, flags); | ||
1483 | ret = __dwc3_gadget_wakeup(dwc); | ||
1497 | spin_unlock_irqrestore(&dwc->lock, flags); | 1484 | spin_unlock_irqrestore(&dwc->lock, flags); |
1498 | 1485 | ||
1499 | return ret; | 1486 | return ret; |
@@ -1620,7 +1607,7 @@ static int dwc3_gadget_start(struct usb_gadget *g, | |||
1620 | 1607 | ||
1621 | irq = platform_get_irq(to_platform_device(dwc->dev), 0); | 1608 | irq = platform_get_irq(to_platform_device(dwc->dev), 0); |
1622 | ret = request_threaded_irq(irq, dwc3_interrupt, dwc3_thread_interrupt, | 1609 | ret = request_threaded_irq(irq, dwc3_interrupt, dwc3_thread_interrupt, |
1623 | IRQF_SHARED, "dwc3", dwc); | 1610 | IRQF_SHARED, "dwc3", dwc->ev_buf); |
1624 | if (ret) { | 1611 | if (ret) { |
1625 | dev_err(dwc->dev, "failed to request irq #%d --> %d\n", | 1612 | dev_err(dwc->dev, "failed to request irq #%d --> %d\n", |
1626 | irq, ret); | 1613 | irq, ret); |
@@ -1682,6 +1669,17 @@ static int dwc3_gadget_start(struct usb_gadget *g, | |||
1682 | } | 1669 | } |
1683 | dwc3_writel(dwc->regs, DWC3_DCFG, reg); | 1670 | dwc3_writel(dwc->regs, DWC3_DCFG, reg); |
1684 | 1671 | ||
1672 | /* | ||
1673 | * We are telling dwc3 that we want to use DCFG.NUMP as ACK TP's NUMP | ||
1674 | * field instead of letting dwc3 itself calculate that automatically. | ||
1675 | * | ||
1676 | * This way, we maximize the chances that we'll be able to get several | ||
1677 | * bursts of data without going through any sort of endpoint throttling. | ||
1678 | */ | ||
1679 | reg = dwc3_readl(dwc->regs, DWC3_GRXTHRCFG); | ||
1680 | reg &= ~DWC3_GRXTHRCFG_PKTCNTSEL; | ||
1681 | dwc3_writel(dwc->regs, DWC3_GRXTHRCFG, reg); | ||
1682 | |||
1685 | /* Start with SuperSpeed Default */ | 1683 | /* Start with SuperSpeed Default */ |
1686 | dwc3_gadget_ep0_desc.wMaxPacketSize = cpu_to_le16(512); | 1684 | dwc3_gadget_ep0_desc.wMaxPacketSize = cpu_to_le16(512); |
1687 | 1685 | ||
@@ -1720,7 +1718,7 @@ err2: | |||
1720 | err1: | 1718 | err1: |
1721 | spin_unlock_irqrestore(&dwc->lock, flags); | 1719 | spin_unlock_irqrestore(&dwc->lock, flags); |
1722 | 1720 | ||
1723 | free_irq(irq, dwc); | 1721 | free_irq(irq, dwc->ev_buf); |
1724 | 1722 | ||
1725 | err0: | 1723 | err0: |
1726 | return ret; | 1724 | return ret; |
@@ -1743,7 +1741,7 @@ static int dwc3_gadget_stop(struct usb_gadget *g) | |||
1743 | spin_unlock_irqrestore(&dwc->lock, flags); | 1741 | spin_unlock_irqrestore(&dwc->lock, flags); |
1744 | 1742 | ||
1745 | irq = platform_get_irq(to_platform_device(dwc->dev), 0); | 1743 | irq = platform_get_irq(to_platform_device(dwc->dev), 0); |
1746 | free_irq(irq, dwc); | 1744 | free_irq(irq, dwc->ev_buf); |
1747 | 1745 | ||
1748 | return 0; | 1746 | return 0; |
1749 | } | 1747 | } |
@@ -1815,8 +1813,8 @@ static int dwc3_gadget_init_hw_endpoints(struct dwc3 *dwc, | |||
1815 | dep->endpoint.caps.dir_in = !!direction; | 1813 | dep->endpoint.caps.dir_in = !!direction; |
1816 | dep->endpoint.caps.dir_out = !direction; | 1814 | dep->endpoint.caps.dir_out = !direction; |
1817 | 1815 | ||
1818 | INIT_LIST_HEAD(&dep->request_list); | 1816 | INIT_LIST_HEAD(&dep->pending_list); |
1819 | INIT_LIST_HEAD(&dep->req_queued); | 1817 | INIT_LIST_HEAD(&dep->started_list); |
1820 | } | 1818 | } |
1821 | 1819 | ||
1822 | return 0; | 1820 | return 0; |
@@ -1913,11 +1911,11 @@ static int __dwc3_cleanup_done_trbs(struct dwc3 *dwc, struct dwc3_ep *dep, | |||
1913 | * If there are still queued request | 1911 | * If there are still queued request |
1914 | * then wait, do not issue either END | 1912 | * then wait, do not issue either END |
1915 | * or UPDATE TRANSFER, just attach next | 1913 | * or UPDATE TRANSFER, just attach next |
1916 | * request in request_list during | 1914 | * request in pending_list during |
1917 | * giveback.If any future queued request | 1915 | * giveback.If any future queued request |
1918 | * is successfully transferred then we | 1916 | * is successfully transferred then we |
1919 | * will issue UPDATE TRANSFER for all | 1917 | * will issue UPDATE TRANSFER for all |
1920 | * request in the request_list. | 1918 | * request in the pending_list. |
1921 | */ | 1919 | */ |
1922 | dep->flags |= DWC3_EP_MISSED_ISOC; | 1920 | dep->flags |= DWC3_EP_MISSED_ISOC; |
1923 | } else { | 1921 | } else { |
@@ -1963,15 +1961,14 @@ static int dwc3_cleanup_done_reqs(struct dwc3 *dwc, struct dwc3_ep *dep, | |||
1963 | int ret; | 1961 | int ret; |
1964 | 1962 | ||
1965 | do { | 1963 | do { |
1966 | req = next_request(&dep->req_queued); | 1964 | req = next_request(&dep->started_list); |
1967 | if (WARN_ON_ONCE(!req)) | 1965 | if (WARN_ON_ONCE(!req)) |
1968 | return 1; | 1966 | return 1; |
1969 | 1967 | ||
1970 | i = 0; | 1968 | i = 0; |
1971 | do { | 1969 | do { |
1972 | slot = req->start_slot + i; | 1970 | slot = req->first_trb_index + i; |
1973 | if ((slot == DWC3_TRB_NUM - 1) && | 1971 | if (slot == DWC3_TRB_NUM - 1) |
1974 | usb_endpoint_xfer_isoc(dep->endpoint.desc)) | ||
1975 | slot++; | 1972 | slot++; |
1976 | slot %= DWC3_TRB_NUM; | 1973 | slot %= DWC3_TRB_NUM; |
1977 | trb = &dep->trb_pool[slot]; | 1974 | trb = &dep->trb_pool[slot]; |
@@ -1989,8 +1986,8 @@ static int dwc3_cleanup_done_reqs(struct dwc3 *dwc, struct dwc3_ep *dep, | |||
1989 | } while (1); | 1986 | } while (1); |
1990 | 1987 | ||
1991 | if (usb_endpoint_xfer_isoc(dep->endpoint.desc) && | 1988 | if (usb_endpoint_xfer_isoc(dep->endpoint.desc) && |
1992 | list_empty(&dep->req_queued)) { | 1989 | list_empty(&dep->started_list)) { |
1993 | if (list_empty(&dep->request_list)) { | 1990 | if (list_empty(&dep->pending_list)) { |
1994 | /* | 1991 | /* |
1995 | * If there is no entry in request list then do | 1992 | * If there is no entry in request list then do |
1996 | * not issue END TRANSFER now. Just set PENDING | 1993 | * not issue END TRANSFER now. Just set PENDING |
@@ -2039,7 +2036,7 @@ static void dwc3_endpoint_transfer_complete(struct dwc3 *dwc, | |||
2039 | if (!(dep->flags & DWC3_EP_ENABLED)) | 2036 | if (!(dep->flags & DWC3_EP_ENABLED)) |
2040 | continue; | 2037 | continue; |
2041 | 2038 | ||
2042 | if (!list_empty(&dep->req_queued)) | 2039 | if (!list_empty(&dep->started_list)) |
2043 | return; | 2040 | return; |
2044 | } | 2041 | } |
2045 | 2042 | ||
@@ -2686,14 +2683,13 @@ static void dwc3_process_event_entry(struct dwc3 *dwc, | |||
2686 | } | 2683 | } |
2687 | } | 2684 | } |
2688 | 2685 | ||
2689 | static irqreturn_t dwc3_process_event_buf(struct dwc3 *dwc, u32 buf) | 2686 | static irqreturn_t dwc3_process_event_buf(struct dwc3_event_buffer *evt) |
2690 | { | 2687 | { |
2691 | struct dwc3_event_buffer *evt; | 2688 | struct dwc3 *dwc = evt->dwc; |
2692 | irqreturn_t ret = IRQ_NONE; | 2689 | irqreturn_t ret = IRQ_NONE; |
2693 | int left; | 2690 | int left; |
2694 | u32 reg; | 2691 | u32 reg; |
2695 | 2692 | ||
2696 | evt = dwc->ev_buffs[buf]; | ||
2697 | left = evt->count; | 2693 | left = evt->count; |
2698 | 2694 | ||
2699 | if (!(evt->flags & DWC3_EVENT_PENDING)) | 2695 | if (!(evt->flags & DWC3_EVENT_PENDING)) |
@@ -2718,7 +2714,7 @@ static irqreturn_t dwc3_process_event_buf(struct dwc3 *dwc, u32 buf) | |||
2718 | evt->lpos = (evt->lpos + 4) % DWC3_EVENT_BUFFERS_SIZE; | 2714 | evt->lpos = (evt->lpos + 4) % DWC3_EVENT_BUFFERS_SIZE; |
2719 | left -= 4; | 2715 | left -= 4; |
2720 | 2716 | ||
2721 | dwc3_writel(dwc->regs, DWC3_GEVNTCOUNT(buf), 4); | 2717 | dwc3_writel(dwc->regs, DWC3_GEVNTCOUNT(0), 4); |
2722 | } | 2718 | } |
2723 | 2719 | ||
2724 | evt->count = 0; | 2720 | evt->count = 0; |
@@ -2726,39 +2722,34 @@ static irqreturn_t dwc3_process_event_buf(struct dwc3 *dwc, u32 buf) | |||
2726 | ret = IRQ_HANDLED; | 2722 | ret = IRQ_HANDLED; |
2727 | 2723 | ||
2728 | /* Unmask interrupt */ | 2724 | /* Unmask interrupt */ |
2729 | reg = dwc3_readl(dwc->regs, DWC3_GEVNTSIZ(buf)); | 2725 | reg = dwc3_readl(dwc->regs, DWC3_GEVNTSIZ(0)); |
2730 | reg &= ~DWC3_GEVNTSIZ_INTMASK; | 2726 | reg &= ~DWC3_GEVNTSIZ_INTMASK; |
2731 | dwc3_writel(dwc->regs, DWC3_GEVNTSIZ(buf), reg); | 2727 | dwc3_writel(dwc->regs, DWC3_GEVNTSIZ(0), reg); |
2732 | 2728 | ||
2733 | return ret; | 2729 | return ret; |
2734 | } | 2730 | } |
2735 | 2731 | ||
2736 | static irqreturn_t dwc3_thread_interrupt(int irq, void *_dwc) | 2732 | static irqreturn_t dwc3_thread_interrupt(int irq, void *_evt) |
2737 | { | 2733 | { |
2738 | struct dwc3 *dwc = _dwc; | 2734 | struct dwc3_event_buffer *evt = _evt; |
2735 | struct dwc3 *dwc = evt->dwc; | ||
2739 | unsigned long flags; | 2736 | unsigned long flags; |
2740 | irqreturn_t ret = IRQ_NONE; | 2737 | irqreturn_t ret = IRQ_NONE; |
2741 | int i; | ||
2742 | 2738 | ||
2743 | spin_lock_irqsave(&dwc->lock, flags); | 2739 | spin_lock_irqsave(&dwc->lock, flags); |
2744 | 2740 | ret = dwc3_process_event_buf(evt); | |
2745 | for (i = 0; i < dwc->num_event_buffers; i++) | ||
2746 | ret |= dwc3_process_event_buf(dwc, i); | ||
2747 | |||
2748 | spin_unlock_irqrestore(&dwc->lock, flags); | 2741 | spin_unlock_irqrestore(&dwc->lock, flags); |
2749 | 2742 | ||
2750 | return ret; | 2743 | return ret; |
2751 | } | 2744 | } |
2752 | 2745 | ||
2753 | static irqreturn_t dwc3_check_event_buf(struct dwc3 *dwc, u32 buf) | 2746 | static irqreturn_t dwc3_check_event_buf(struct dwc3_event_buffer *evt) |
2754 | { | 2747 | { |
2755 | struct dwc3_event_buffer *evt; | 2748 | struct dwc3 *dwc = evt->dwc; |
2756 | u32 count; | 2749 | u32 count; |
2757 | u32 reg; | 2750 | u32 reg; |
2758 | 2751 | ||
2759 | evt = dwc->ev_buffs[buf]; | 2752 | count = dwc3_readl(dwc->regs, DWC3_GEVNTCOUNT(0)); |
2760 | |||
2761 | count = dwc3_readl(dwc->regs, DWC3_GEVNTCOUNT(buf)); | ||
2762 | count &= DWC3_GEVNTCOUNT_MASK; | 2753 | count &= DWC3_GEVNTCOUNT_MASK; |
2763 | if (!count) | 2754 | if (!count) |
2764 | return IRQ_NONE; | 2755 | return IRQ_NONE; |
@@ -2767,28 +2758,18 @@ static irqreturn_t dwc3_check_event_buf(struct dwc3 *dwc, u32 buf) | |||
2767 | evt->flags |= DWC3_EVENT_PENDING; | 2758 | evt->flags |= DWC3_EVENT_PENDING; |
2768 | 2759 | ||
2769 | /* Mask interrupt */ | 2760 | /* Mask interrupt */ |
2770 | reg = dwc3_readl(dwc->regs, DWC3_GEVNTSIZ(buf)); | 2761 | reg = dwc3_readl(dwc->regs, DWC3_GEVNTSIZ(0)); |
2771 | reg |= DWC3_GEVNTSIZ_INTMASK; | 2762 | reg |= DWC3_GEVNTSIZ_INTMASK; |
2772 | dwc3_writel(dwc->regs, DWC3_GEVNTSIZ(buf), reg); | 2763 | dwc3_writel(dwc->regs, DWC3_GEVNTSIZ(0), reg); |
2773 | 2764 | ||
2774 | return IRQ_WAKE_THREAD; | 2765 | return IRQ_WAKE_THREAD; |
2775 | } | 2766 | } |
2776 | 2767 | ||
2777 | static irqreturn_t dwc3_interrupt(int irq, void *_dwc) | 2768 | static irqreturn_t dwc3_interrupt(int irq, void *_evt) |
2778 | { | 2769 | { |
2779 | struct dwc3 *dwc = _dwc; | 2770 | struct dwc3_event_buffer *evt = _evt; |
2780 | int i; | ||
2781 | irqreturn_t ret = IRQ_NONE; | ||
2782 | |||
2783 | for (i = 0; i < dwc->num_event_buffers; i++) { | ||
2784 | irqreturn_t status; | ||
2785 | 2771 | ||
2786 | status = dwc3_check_event_buf(dwc, i); | 2772 | return dwc3_check_event_buf(evt); |
2787 | if (status == IRQ_WAKE_THREAD) | ||
2788 | ret = status; | ||
2789 | } | ||
2790 | |||
2791 | return ret; | ||
2792 | } | 2773 | } |
2793 | 2774 | ||
2794 | /** | 2775 | /** |
diff --git a/drivers/usb/dwc3/gadget.h b/drivers/usb/dwc3/gadget.h index 18ae3eaa8b6f..f21c0fccbebd 100644 --- a/drivers/usb/dwc3/gadget.h +++ b/drivers/usb/dwc3/gadget.h | |||
@@ -68,12 +68,12 @@ static inline struct dwc3_request *next_request(struct list_head *list) | |||
68 | return list_first_entry(list, struct dwc3_request, list); | 68 | return list_first_entry(list, struct dwc3_request, list); |
69 | } | 69 | } |
70 | 70 | ||
71 | static inline void dwc3_gadget_move_request_queued(struct dwc3_request *req) | 71 | static inline void dwc3_gadget_move_started_request(struct dwc3_request *req) |
72 | { | 72 | { |
73 | struct dwc3_ep *dep = req->dep; | 73 | struct dwc3_ep *dep = req->dep; |
74 | 74 | ||
75 | req->queued = true; | 75 | req->started = true; |
76 | list_move_tail(&req->list, &dep->req_queued); | 76 | list_move_tail(&req->list, &dep->started_list); |
77 | } | 77 | } |
78 | 78 | ||
79 | void dwc3_gadget_giveback(struct dwc3_ep *dep, struct dwc3_request *req, | 79 | void dwc3_gadget_giveback(struct dwc3_ep *dep, struct dwc3_request *req, |
diff --git a/drivers/usb/dwc3/platform_data.h b/drivers/usb/dwc3/platform_data.h index 2bb4d3ad0e6b..8826cca5fc6f 100644 --- a/drivers/usb/dwc3/platform_data.h +++ b/drivers/usb/dwc3/platform_data.h | |||
@@ -23,7 +23,6 @@ | |||
23 | struct dwc3_platform_data { | 23 | struct dwc3_platform_data { |
24 | enum usb_device_speed maximum_speed; | 24 | enum usb_device_speed maximum_speed; |
25 | enum usb_dr_mode dr_mode; | 25 | enum usb_dr_mode dr_mode; |
26 | bool tx_fifo_resize; | ||
27 | bool usb3_lpm_capable; | 26 | bool usb3_lpm_capable; |
28 | 27 | ||
29 | unsigned is_utmi_l1_suspend:1; | 28 | unsigned is_utmi_l1_suspend:1; |
@@ -43,6 +42,7 @@ struct dwc3_platform_data { | |||
43 | unsigned dis_u3_susphy_quirk:1; | 42 | unsigned dis_u3_susphy_quirk:1; |
44 | unsigned dis_u2_susphy_quirk:1; | 43 | unsigned dis_u2_susphy_quirk:1; |
45 | unsigned dis_enblslpm_quirk:1; | 44 | unsigned dis_enblslpm_quirk:1; |
45 | unsigned dis_rxdet_inp3_quirk:1; | ||
46 | 46 | ||
47 | unsigned tx_de_emphasis_quirk:1; | 47 | unsigned tx_de_emphasis_quirk:1; |
48 | unsigned tx_de_emphasis:2; | 48 | unsigned tx_de_emphasis:2; |
diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig index af5d922a8f5d..2057add439f0 100644 --- a/drivers/usb/gadget/Kconfig +++ b/drivers/usb/gadget/Kconfig | |||
@@ -15,6 +15,7 @@ | |||
15 | 15 | ||
16 | menuconfig USB_GADGET | 16 | menuconfig USB_GADGET |
17 | tristate "USB Gadget Support" | 17 | tristate "USB Gadget Support" |
18 | select USB_COMMON | ||
18 | select NLS | 19 | select NLS |
19 | help | 20 | help |
20 | USB is a master/slave protocol, organized with one master | 21 | USB is a master/slave protocol, organized with one master |
diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c index 524e233d48de..d67de0d22a2b 100644 --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c | |||
@@ -66,20 +66,36 @@ function_descriptors(struct usb_function *f, | |||
66 | { | 66 | { |
67 | struct usb_descriptor_header **descriptors; | 67 | struct usb_descriptor_header **descriptors; |
68 | 68 | ||
69 | /* | ||
70 | * NOTE: we try to help gadget drivers which might not be setting | ||
71 | * max_speed appropriately. | ||
72 | */ | ||
73 | |||
69 | switch (speed) { | 74 | switch (speed) { |
70 | case USB_SPEED_SUPER_PLUS: | 75 | case USB_SPEED_SUPER_PLUS: |
71 | descriptors = f->ssp_descriptors; | 76 | descriptors = f->ssp_descriptors; |
72 | break; | 77 | if (descriptors) |
78 | break; | ||
79 | /* FALLTHROUGH */ | ||
73 | case USB_SPEED_SUPER: | 80 | case USB_SPEED_SUPER: |
74 | descriptors = f->ss_descriptors; | 81 | descriptors = f->ss_descriptors; |
75 | break; | 82 | if (descriptors) |
83 | break; | ||
84 | /* FALLTHROUGH */ | ||
76 | case USB_SPEED_HIGH: | 85 | case USB_SPEED_HIGH: |
77 | descriptors = f->hs_descriptors; | 86 | descriptors = f->hs_descriptors; |
78 | break; | 87 | if (descriptors) |
88 | break; | ||
89 | /* FALLTHROUGH */ | ||
79 | default: | 90 | default: |
80 | descriptors = f->fs_descriptors; | 91 | descriptors = f->fs_descriptors; |
81 | } | 92 | } |
82 | 93 | ||
94 | /* | ||
95 | * if we can't find any descriptors at all, then this gadget deserves to | ||
96 | * Oops with a NULL pointer dereference | ||
97 | */ | ||
98 | |||
83 | return descriptors; | 99 | return descriptors; |
84 | } | 100 | } |
85 | 101 | ||
diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c index 15b648cbc75c..73515d54e1cc 100644 --- a/drivers/usb/gadget/function/f_fs.c +++ b/drivers/usb/gadget/function/f_fs.c | |||
@@ -651,7 +651,7 @@ static void ffs_user_copy_worker(struct work_struct *work) | |||
651 | if (io_data->read && ret > 0) { | 651 | if (io_data->read && ret > 0) { |
652 | use_mm(io_data->mm); | 652 | use_mm(io_data->mm); |
653 | ret = copy_to_iter(io_data->buf, ret, &io_data->data); | 653 | ret = copy_to_iter(io_data->buf, ret, &io_data->data); |
654 | if (iov_iter_count(&io_data->data)) | 654 | if (ret != io_data->req->actual && iov_iter_count(&io_data->data)) |
655 | ret = -EFAULT; | 655 | ret = -EFAULT; |
656 | unuse_mm(io_data->mm); | 656 | unuse_mm(io_data->mm); |
657 | } | 657 | } |
diff --git a/drivers/usb/gadget/function/f_mass_storage.c b/drivers/usb/gadget/function/f_mass_storage.c index acf210f16328..5c6d4d7ca605 100644 --- a/drivers/usb/gadget/function/f_mass_storage.c +++ b/drivers/usb/gadget/function/f_mass_storage.c | |||
@@ -2977,25 +2977,6 @@ void fsg_common_set_inquiry_string(struct fsg_common *common, const char *vn, | |||
2977 | } | 2977 | } |
2978 | EXPORT_SYMBOL_GPL(fsg_common_set_inquiry_string); | 2978 | EXPORT_SYMBOL_GPL(fsg_common_set_inquiry_string); |
2979 | 2979 | ||
2980 | int fsg_common_run_thread(struct fsg_common *common) | ||
2981 | { | ||
2982 | common->state = FSG_STATE_IDLE; | ||
2983 | /* Tell the thread to start working */ | ||
2984 | common->thread_task = | ||
2985 | kthread_create(fsg_main_thread, common, "file-storage"); | ||
2986 | if (IS_ERR(common->thread_task)) { | ||
2987 | common->state = FSG_STATE_TERMINATED; | ||
2988 | return PTR_ERR(common->thread_task); | ||
2989 | } | ||
2990 | |||
2991 | DBG(common, "I/O thread pid: %d\n", task_pid_nr(common->thread_task)); | ||
2992 | |||
2993 | wake_up_process(common->thread_task); | ||
2994 | |||
2995 | return 0; | ||
2996 | } | ||
2997 | EXPORT_SYMBOL_GPL(fsg_common_run_thread); | ||
2998 | |||
2999 | static void fsg_common_release(struct kref *ref) | 2980 | static void fsg_common_release(struct kref *ref) |
3000 | { | 2981 | { |
3001 | struct fsg_common *common = container_of(ref, struct fsg_common, ref); | 2982 | struct fsg_common *common = container_of(ref, struct fsg_common, ref); |
@@ -3005,6 +2986,7 @@ static void fsg_common_release(struct kref *ref) | |||
3005 | if (common->state != FSG_STATE_TERMINATED) { | 2986 | if (common->state != FSG_STATE_TERMINATED) { |
3006 | raise_exception(common, FSG_STATE_EXIT); | 2987 | raise_exception(common, FSG_STATE_EXIT); |
3007 | wait_for_completion(&common->thread_notifier); | 2988 | wait_for_completion(&common->thread_notifier); |
2989 | common->thread_task = NULL; | ||
3008 | } | 2990 | } |
3009 | 2991 | ||
3010 | for (i = 0; i < ARRAY_SIZE(common->luns); ++i) { | 2992 | for (i = 0; i < ARRAY_SIZE(common->luns); ++i) { |
@@ -3050,9 +3032,21 @@ static int fsg_bind(struct usb_configuration *c, struct usb_function *f) | |||
3050 | if (ret) | 3032 | if (ret) |
3051 | return ret; | 3033 | return ret; |
3052 | fsg_common_set_inquiry_string(fsg->common, NULL, NULL); | 3034 | fsg_common_set_inquiry_string(fsg->common, NULL, NULL); |
3053 | ret = fsg_common_run_thread(fsg->common); | 3035 | } |
3054 | if (ret) | 3036 | |
3037 | if (!common->thread_task) { | ||
3038 | common->state = FSG_STATE_IDLE; | ||
3039 | common->thread_task = | ||
3040 | kthread_create(fsg_main_thread, common, "file-storage"); | ||
3041 | if (IS_ERR(common->thread_task)) { | ||
3042 | int ret = PTR_ERR(common->thread_task); | ||
3043 | common->thread_task = NULL; | ||
3044 | common->state = FSG_STATE_TERMINATED; | ||
3055 | return ret; | 3045 | return ret; |
3046 | } | ||
3047 | DBG(common, "I/O thread pid: %d\n", | ||
3048 | task_pid_nr(common->thread_task)); | ||
3049 | wake_up_process(common->thread_task); | ||
3056 | } | 3050 | } |
3057 | 3051 | ||
3058 | fsg->gadget = gadget; | 3052 | fsg->gadget = gadget; |
diff --git a/drivers/usb/gadget/function/f_mass_storage.h b/drivers/usb/gadget/function/f_mass_storage.h index 445df6775609..b6a9918eaefb 100644 --- a/drivers/usb/gadget/function/f_mass_storage.h +++ b/drivers/usb/gadget/function/f_mass_storage.h | |||
@@ -153,8 +153,6 @@ int fsg_common_create_luns(struct fsg_common *common, struct fsg_config *cfg); | |||
153 | void fsg_common_set_inquiry_string(struct fsg_common *common, const char *vn, | 153 | void fsg_common_set_inquiry_string(struct fsg_common *common, const char *vn, |
154 | const char *pn); | 154 | const char *pn); |
155 | 155 | ||
156 | int fsg_common_run_thread(struct fsg_common *common); | ||
157 | |||
158 | void fsg_config_from_params(struct fsg_config *cfg, | 156 | void fsg_config_from_params(struct fsg_config *cfg, |
159 | const struct fsg_module_parameters *params, | 157 | const struct fsg_module_parameters *params, |
160 | unsigned int fsg_num_buffers); | 158 | unsigned int fsg_num_buffers); |
diff --git a/drivers/usb/gadget/legacy/acm_ms.c b/drivers/usb/gadget/legacy/acm_ms.c index c16089efc322..c39de65a448b 100644 --- a/drivers/usb/gadget/legacy/acm_ms.c +++ b/drivers/usb/gadget/legacy/acm_ms.c | |||
@@ -133,10 +133,6 @@ static int acm_ms_do_config(struct usb_configuration *c) | |||
133 | if (status < 0) | 133 | if (status < 0) |
134 | goto put_msg; | 134 | goto put_msg; |
135 | 135 | ||
136 | status = fsg_common_run_thread(opts->common); | ||
137 | if (status) | ||
138 | goto remove_acm; | ||
139 | |||
140 | status = usb_add_function(c, f_msg); | 136 | status = usb_add_function(c, f_msg); |
141 | if (status) | 137 | if (status) |
142 | goto remove_acm; | 138 | goto remove_acm; |
diff --git a/drivers/usb/gadget/legacy/mass_storage.c b/drivers/usb/gadget/legacy/mass_storage.c index e61af53c7d2b..125974f32f50 100644 --- a/drivers/usb/gadget/legacy/mass_storage.c +++ b/drivers/usb/gadget/legacy/mass_storage.c | |||
@@ -132,10 +132,6 @@ static int msg_do_config(struct usb_configuration *c) | |||
132 | if (IS_ERR(f_msg)) | 132 | if (IS_ERR(f_msg)) |
133 | return PTR_ERR(f_msg); | 133 | return PTR_ERR(f_msg); |
134 | 134 | ||
135 | ret = fsg_common_run_thread(opts->common); | ||
136 | if (ret) | ||
137 | goto put_func; | ||
138 | |||
139 | ret = usb_add_function(c, f_msg); | 135 | ret = usb_add_function(c, f_msg); |
140 | if (ret) | 136 | if (ret) |
141 | goto put_func; | 137 | goto put_func; |
diff --git a/drivers/usb/gadget/legacy/multi.c b/drivers/usb/gadget/legacy/multi.c index 229d704a620b..a70a406580ea 100644 --- a/drivers/usb/gadget/legacy/multi.c +++ b/drivers/usb/gadget/legacy/multi.c | |||
@@ -137,7 +137,6 @@ static struct usb_function *f_msg_rndis; | |||
137 | 137 | ||
138 | static int rndis_do_config(struct usb_configuration *c) | 138 | static int rndis_do_config(struct usb_configuration *c) |
139 | { | 139 | { |
140 | struct fsg_opts *fsg_opts; | ||
141 | int ret; | 140 | int ret; |
142 | 141 | ||
143 | if (gadget_is_otg(c->cdev->gadget)) { | 142 | if (gadget_is_otg(c->cdev->gadget)) { |
@@ -169,11 +168,6 @@ static int rndis_do_config(struct usb_configuration *c) | |||
169 | goto err_fsg; | 168 | goto err_fsg; |
170 | } | 169 | } |
171 | 170 | ||
172 | fsg_opts = fsg_opts_from_func_inst(fi_msg); | ||
173 | ret = fsg_common_run_thread(fsg_opts->common); | ||
174 | if (ret) | ||
175 | goto err_run; | ||
176 | |||
177 | ret = usb_add_function(c, f_msg_rndis); | 171 | ret = usb_add_function(c, f_msg_rndis); |
178 | if (ret) | 172 | if (ret) |
179 | goto err_run; | 173 | goto err_run; |
@@ -225,7 +219,6 @@ static struct usb_function *f_msg_multi; | |||
225 | 219 | ||
226 | static int cdc_do_config(struct usb_configuration *c) | 220 | static int cdc_do_config(struct usb_configuration *c) |
227 | { | 221 | { |
228 | struct fsg_opts *fsg_opts; | ||
229 | int ret; | 222 | int ret; |
230 | 223 | ||
231 | if (gadget_is_otg(c->cdev->gadget)) { | 224 | if (gadget_is_otg(c->cdev->gadget)) { |
@@ -258,11 +251,6 @@ static int cdc_do_config(struct usb_configuration *c) | |||
258 | goto err_fsg; | 251 | goto err_fsg; |
259 | } | 252 | } |
260 | 253 | ||
261 | fsg_opts = fsg_opts_from_func_inst(fi_msg); | ||
262 | ret = fsg_common_run_thread(fsg_opts->common); | ||
263 | if (ret) | ||
264 | goto err_run; | ||
265 | |||
266 | ret = usb_add_function(c, f_msg_multi); | 254 | ret = usb_add_function(c, f_msg_multi); |
267 | if (ret) | 255 | if (ret) |
268 | goto err_run; | 256 | goto err_run; |
diff --git a/drivers/usb/gadget/legacy/nokia.c b/drivers/usb/gadget/legacy/nokia.c index 09975046c694..b1e535f4022e 100644 --- a/drivers/usb/gadget/legacy/nokia.c +++ b/drivers/usb/gadget/legacy/nokia.c | |||
@@ -152,7 +152,6 @@ static int nokia_bind_config(struct usb_configuration *c) | |||
152 | struct usb_function *f_ecm; | 152 | struct usb_function *f_ecm; |
153 | struct usb_function *f_obex2 = NULL; | 153 | struct usb_function *f_obex2 = NULL; |
154 | struct usb_function *f_msg; | 154 | struct usb_function *f_msg; |
155 | struct fsg_opts *fsg_opts; | ||
156 | int status = 0; | 155 | int status = 0; |
157 | int obex1_stat = -1; | 156 | int obex1_stat = -1; |
158 | int obex2_stat = -1; | 157 | int obex2_stat = -1; |
@@ -222,12 +221,6 @@ static int nokia_bind_config(struct usb_configuration *c) | |||
222 | goto err_ecm; | 221 | goto err_ecm; |
223 | } | 222 | } |
224 | 223 | ||
225 | fsg_opts = fsg_opts_from_func_inst(fi_msg); | ||
226 | |||
227 | status = fsg_common_run_thread(fsg_opts->common); | ||
228 | if (status) | ||
229 | goto err_msg; | ||
230 | |||
231 | status = usb_add_function(c, f_msg); | 224 | status = usb_add_function(c, f_msg); |
232 | if (status) | 225 | if (status) |
233 | goto err_msg; | 226 | goto err_msg; |
diff --git a/drivers/usb/gadget/udc/at91_udc.c b/drivers/usb/gadget/udc/at91_udc.c index d0d18947f58b..8bc78418d40e 100644 --- a/drivers/usb/gadget/udc/at91_udc.c +++ b/drivers/usb/gadget/udc/at91_udc.c | |||
@@ -1726,10 +1726,7 @@ static int at91sam9261_udc_init(struct at91_udc *udc) | |||
1726 | 1726 | ||
1727 | udc->matrix = syscon_regmap_lookup_by_phandle(udc->pdev->dev.of_node, | 1727 | udc->matrix = syscon_regmap_lookup_by_phandle(udc->pdev->dev.of_node, |
1728 | "atmel,matrix"); | 1728 | "atmel,matrix"); |
1729 | if (IS_ERR(udc->matrix)) | 1729 | return PTR_ERR_OR_ZERO(udc->matrix); |
1730 | return PTR_ERR(udc->matrix); | ||
1731 | |||
1732 | return 0; | ||
1733 | } | 1730 | } |
1734 | 1731 | ||
1735 | static void at91sam9261_udc_pullup(struct at91_udc *udc, int is_on) | 1732 | static void at91sam9261_udc_pullup(struct at91_udc *udc, int is_on) |
diff --git a/drivers/usb/gadget/udc/pch_udc.c b/drivers/usb/gadget/udc/pch_udc.c index 9571ef54b86b..ebc51ec5790a 100644 --- a/drivers/usb/gadget/udc/pch_udc.c +++ b/drivers/usb/gadget/udc/pch_udc.c | |||
@@ -325,11 +325,8 @@ struct pch_vbus_gpio_data { | |||
325 | * @pdev: reference to the PCI device | 325 | * @pdev: reference to the PCI device |
326 | * @ep: array of endpoints | 326 | * @ep: array of endpoints |
327 | * @lock: protects all state | 327 | * @lock: protects all state |
328 | * @active: enabled the PCI device | ||
329 | * @stall: stall requested | 328 | * @stall: stall requested |
330 | * @prot_stall: protcol stall requested | 329 | * @prot_stall: protcol stall requested |
331 | * @irq_registered: irq registered with system | ||
332 | * @mem_region: device memory mapped | ||
333 | * @registered: driver registered with system | 330 | * @registered: driver registered with system |
334 | * @suspended: driver in suspended state | 331 | * @suspended: driver in suspended state |
335 | * @connected: gadget driver associated | 332 | * @connected: gadget driver associated |
@@ -339,12 +336,8 @@ struct pch_vbus_gpio_data { | |||
339 | * @data_requests: DMA pool for data requests | 336 | * @data_requests: DMA pool for data requests |
340 | * @stp_requests: DMA pool for setup requests | 337 | * @stp_requests: DMA pool for setup requests |
341 | * @dma_addr: DMA pool for received | 338 | * @dma_addr: DMA pool for received |
342 | * @ep0out_buf: Buffer for DMA | ||
343 | * @setup_data: Received setup data | 339 | * @setup_data: Received setup data |
344 | * @phys_addr: of device memory | ||
345 | * @base_addr: for mapped device memory | 340 | * @base_addr: for mapped device memory |
346 | * @bar: Indicates which PCI BAR for USB regs | ||
347 | * @irq: IRQ line for the device | ||
348 | * @cfg_data: current cfg, intf, and alt in use | 341 | * @cfg_data: current cfg, intf, and alt in use |
349 | * @vbus_gpio: GPIO informaton for detecting VBUS | 342 | * @vbus_gpio: GPIO informaton for detecting VBUS |
350 | */ | 343 | */ |
@@ -354,11 +347,9 @@ struct pch_udc_dev { | |||
354 | struct pci_dev *pdev; | 347 | struct pci_dev *pdev; |
355 | struct pch_udc_ep ep[PCH_UDC_EP_NUM]; | 348 | struct pch_udc_ep ep[PCH_UDC_EP_NUM]; |
356 | spinlock_t lock; /* protects all state */ | 349 | spinlock_t lock; /* protects all state */ |
357 | unsigned active:1, | 350 | unsigned |
358 | stall:1, | 351 | stall:1, |
359 | prot_stall:1, | 352 | prot_stall:1, |
360 | irq_registered:1, | ||
361 | mem_region:1, | ||
362 | suspended:1, | 353 | suspended:1, |
363 | connected:1, | 354 | connected:1, |
364 | vbus_session:1, | 355 | vbus_session:1, |
@@ -367,12 +358,8 @@ struct pch_udc_dev { | |||
367 | struct pci_pool *data_requests; | 358 | struct pci_pool *data_requests; |
368 | struct pci_pool *stp_requests; | 359 | struct pci_pool *stp_requests; |
369 | dma_addr_t dma_addr; | 360 | dma_addr_t dma_addr; |
370 | void *ep0out_buf; | ||
371 | struct usb_ctrlrequest setup_data; | 361 | struct usb_ctrlrequest setup_data; |
372 | unsigned long phys_addr; | ||
373 | void __iomem *base_addr; | 362 | void __iomem *base_addr; |
374 | unsigned bar; | ||
375 | unsigned irq; | ||
376 | struct pch_udc_cfg_data cfg_data; | 363 | struct pch_udc_cfg_data cfg_data; |
377 | struct pch_vbus_gpio_data vbus_gpio; | 364 | struct pch_vbus_gpio_data vbus_gpio; |
378 | }; | 365 | }; |
@@ -380,8 +367,10 @@ struct pch_udc_dev { | |||
380 | 367 | ||
381 | #define PCH_UDC_PCI_BAR_QUARK_X1000 0 | 368 | #define PCH_UDC_PCI_BAR_QUARK_X1000 0 |
382 | #define PCH_UDC_PCI_BAR 1 | 369 | #define PCH_UDC_PCI_BAR 1 |
383 | #define PCI_DEVICE_ID_INTEL_EG20T_UDC 0x8808 | 370 | |
384 | #define PCI_DEVICE_ID_INTEL_QUARK_X1000_UDC 0x0939 | 371 | #define PCI_DEVICE_ID_INTEL_QUARK_X1000_UDC 0x0939 |
372 | #define PCI_DEVICE_ID_INTEL_EG20T_UDC 0x8808 | ||
373 | |||
385 | #define PCI_VENDOR_ID_ROHM 0x10DB | 374 | #define PCI_VENDOR_ID_ROHM 0x10DB |
386 | #define PCI_DEVICE_ID_ML7213_IOH_UDC 0x801D | 375 | #define PCI_DEVICE_ID_ML7213_IOH_UDC 0x801D |
387 | #define PCI_DEVICE_ID_ML7831_IOH_UDC 0x8808 | 376 | #define PCI_DEVICE_ID_ML7831_IOH_UDC 0x8808 |
@@ -1732,14 +1721,12 @@ static int pch_udc_pcd_ep_enable(struct usb_ep *usbep, | |||
1732 | static int pch_udc_pcd_ep_disable(struct usb_ep *usbep) | 1721 | static int pch_udc_pcd_ep_disable(struct usb_ep *usbep) |
1733 | { | 1722 | { |
1734 | struct pch_udc_ep *ep; | 1723 | struct pch_udc_ep *ep; |
1735 | struct pch_udc_dev *dev; | ||
1736 | unsigned long iflags; | 1724 | unsigned long iflags; |
1737 | 1725 | ||
1738 | if (!usbep) | 1726 | if (!usbep) |
1739 | return -EINVAL; | 1727 | return -EINVAL; |
1740 | 1728 | ||
1741 | ep = container_of(usbep, struct pch_udc_ep, ep); | 1729 | ep = container_of(usbep, struct pch_udc_ep, ep); |
1742 | dev = ep->dev; | ||
1743 | if ((usbep->name == ep0_string) || !ep->ep.desc) | 1730 | if ((usbep->name == ep0_string) || !ep->ep.desc) |
1744 | return -EINVAL; | 1731 | return -EINVAL; |
1745 | 1732 | ||
@@ -1770,12 +1757,10 @@ static struct usb_request *pch_udc_alloc_request(struct usb_ep *usbep, | |||
1770 | struct pch_udc_request *req; | 1757 | struct pch_udc_request *req; |
1771 | struct pch_udc_ep *ep; | 1758 | struct pch_udc_ep *ep; |
1772 | struct pch_udc_data_dma_desc *dma_desc; | 1759 | struct pch_udc_data_dma_desc *dma_desc; |
1773 | struct pch_udc_dev *dev; | ||
1774 | 1760 | ||
1775 | if (!usbep) | 1761 | if (!usbep) |
1776 | return NULL; | 1762 | return NULL; |
1777 | ep = container_of(usbep, struct pch_udc_ep, ep); | 1763 | ep = container_of(usbep, struct pch_udc_ep, ep); |
1778 | dev = ep->dev; | ||
1779 | req = kzalloc(sizeof *req, gfp); | 1764 | req = kzalloc(sizeof *req, gfp); |
1780 | if (!req) | 1765 | if (!req) |
1781 | return NULL; | 1766 | return NULL; |
@@ -1948,12 +1933,10 @@ static int pch_udc_pcd_dequeue(struct usb_ep *usbep, | |||
1948 | { | 1933 | { |
1949 | struct pch_udc_ep *ep; | 1934 | struct pch_udc_ep *ep; |
1950 | struct pch_udc_request *req; | 1935 | struct pch_udc_request *req; |
1951 | struct pch_udc_dev *dev; | ||
1952 | unsigned long flags; | 1936 | unsigned long flags; |
1953 | int ret = -EINVAL; | 1937 | int ret = -EINVAL; |
1954 | 1938 | ||
1955 | ep = container_of(usbep, struct pch_udc_ep, ep); | 1939 | ep = container_of(usbep, struct pch_udc_ep, ep); |
1956 | dev = ep->dev; | ||
1957 | if (!usbep || !usbreq || (!ep->ep.desc && ep->num)) | 1940 | if (!usbep || !usbreq || (!ep->ep.desc && ep->num)) |
1958 | return ret; | 1941 | return ret; |
1959 | req = container_of(usbreq, struct pch_udc_request, req); | 1942 | req = container_of(usbreq, struct pch_udc_request, req); |
@@ -1985,14 +1968,12 @@ static int pch_udc_pcd_dequeue(struct usb_ep *usbep, | |||
1985 | static int pch_udc_pcd_set_halt(struct usb_ep *usbep, int halt) | 1968 | static int pch_udc_pcd_set_halt(struct usb_ep *usbep, int halt) |
1986 | { | 1969 | { |
1987 | struct pch_udc_ep *ep; | 1970 | struct pch_udc_ep *ep; |
1988 | struct pch_udc_dev *dev; | ||
1989 | unsigned long iflags; | 1971 | unsigned long iflags; |
1990 | int ret; | 1972 | int ret; |
1991 | 1973 | ||
1992 | if (!usbep) | 1974 | if (!usbep) |
1993 | return -EINVAL; | 1975 | return -EINVAL; |
1994 | ep = container_of(usbep, struct pch_udc_ep, ep); | 1976 | ep = container_of(usbep, struct pch_udc_ep, ep); |
1995 | dev = ep->dev; | ||
1996 | if (!ep->ep.desc && !ep->num) | 1977 | if (!ep->ep.desc && !ep->num) |
1997 | return -EINVAL; | 1978 | return -EINVAL; |
1998 | if (!ep->dev->driver || (ep->dev->gadget.speed == USB_SPEED_UNKNOWN)) | 1979 | if (!ep->dev->driver || (ep->dev->gadget.speed == USB_SPEED_UNKNOWN)) |
@@ -2030,14 +2011,12 @@ static int pch_udc_pcd_set_halt(struct usb_ep *usbep, int halt) | |||
2030 | static int pch_udc_pcd_set_wedge(struct usb_ep *usbep) | 2011 | static int pch_udc_pcd_set_wedge(struct usb_ep *usbep) |
2031 | { | 2012 | { |
2032 | struct pch_udc_ep *ep; | 2013 | struct pch_udc_ep *ep; |
2033 | struct pch_udc_dev *dev; | ||
2034 | unsigned long iflags; | 2014 | unsigned long iflags; |
2035 | int ret; | 2015 | int ret; |
2036 | 2016 | ||
2037 | if (!usbep) | 2017 | if (!usbep) |
2038 | return -EINVAL; | 2018 | return -EINVAL; |
2039 | ep = container_of(usbep, struct pch_udc_ep, ep); | 2019 | ep = container_of(usbep, struct pch_udc_ep, ep); |
2040 | dev = ep->dev; | ||
2041 | if (!ep->ep.desc && !ep->num) | 2020 | if (!ep->ep.desc && !ep->num) |
2042 | return -EINVAL; | 2021 | return -EINVAL; |
2043 | if (!ep->dev->driver || (ep->dev->gadget.speed == USB_SPEED_UNKNOWN)) | 2022 | if (!ep->dev->driver || (ep->dev->gadget.speed == USB_SPEED_UNKNOWN)) |
@@ -2647,7 +2626,7 @@ static void pch_udc_svc_enum_interrupt(struct pch_udc_dev *dev) | |||
2647 | static void pch_udc_svc_intf_interrupt(struct pch_udc_dev *dev) | 2626 | static void pch_udc_svc_intf_interrupt(struct pch_udc_dev *dev) |
2648 | { | 2627 | { |
2649 | u32 reg, dev_stat = 0; | 2628 | u32 reg, dev_stat = 0; |
2650 | int i, ret; | 2629 | int i; |
2651 | 2630 | ||
2652 | dev_stat = pch_udc_read_device_status(dev); | 2631 | dev_stat = pch_udc_read_device_status(dev); |
2653 | dev->cfg_data.cur_intf = (dev_stat & UDC_DEVSTS_INTF_MASK) >> | 2632 | dev->cfg_data.cur_intf = (dev_stat & UDC_DEVSTS_INTF_MASK) >> |
@@ -2676,7 +2655,7 @@ static void pch_udc_svc_intf_interrupt(struct pch_udc_dev *dev) | |||
2676 | } | 2655 | } |
2677 | dev->stall = 0; | 2656 | dev->stall = 0; |
2678 | spin_lock(&dev->lock); | 2657 | spin_lock(&dev->lock); |
2679 | ret = dev->driver->setup(&dev->gadget, &dev->setup_data); | 2658 | dev->driver->setup(&dev->gadget, &dev->setup_data); |
2680 | spin_unlock(&dev->lock); | 2659 | spin_unlock(&dev->lock); |
2681 | } | 2660 | } |
2682 | 2661 | ||
@@ -2687,7 +2666,7 @@ static void pch_udc_svc_intf_interrupt(struct pch_udc_dev *dev) | |||
2687 | */ | 2666 | */ |
2688 | static void pch_udc_svc_cfg_interrupt(struct pch_udc_dev *dev) | 2667 | static void pch_udc_svc_cfg_interrupt(struct pch_udc_dev *dev) |
2689 | { | 2668 | { |
2690 | int i, ret; | 2669 | int i; |
2691 | u32 reg, dev_stat = 0; | 2670 | u32 reg, dev_stat = 0; |
2692 | 2671 | ||
2693 | dev_stat = pch_udc_read_device_status(dev); | 2672 | dev_stat = pch_udc_read_device_status(dev); |
@@ -2713,7 +2692,7 @@ static void pch_udc_svc_cfg_interrupt(struct pch_udc_dev *dev) | |||
2713 | 2692 | ||
2714 | /* call gadget zero with setup data received */ | 2693 | /* call gadget zero with setup data received */ |
2715 | spin_lock(&dev->lock); | 2694 | spin_lock(&dev->lock); |
2716 | ret = dev->driver->setup(&dev->gadget, &dev->setup_data); | 2695 | dev->driver->setup(&dev->gadget, &dev->setup_data); |
2717 | spin_unlock(&dev->lock); | 2696 | spin_unlock(&dev->lock); |
2718 | } | 2697 | } |
2719 | 2698 | ||
@@ -2856,17 +2835,6 @@ static void pch_udc_setup_ep0(struct pch_udc_dev *dev) | |||
2856 | } | 2835 | } |
2857 | 2836 | ||
2858 | /** | 2837 | /** |
2859 | * gadget_release() - Free the gadget driver private data | ||
2860 | * @pdev reference to struct pci_dev | ||
2861 | */ | ||
2862 | static void gadget_release(struct device *pdev) | ||
2863 | { | ||
2864 | struct pch_udc_dev *dev = dev_get_drvdata(pdev); | ||
2865 | |||
2866 | kfree(dev); | ||
2867 | } | ||
2868 | |||
2869 | /** | ||
2870 | * pch_udc_pcd_reinit() - This API initializes the endpoint structures | 2838 | * pch_udc_pcd_reinit() - This API initializes the endpoint structures |
2871 | * @dev: Reference to the driver structure | 2839 | * @dev: Reference to the driver structure |
2872 | */ | 2840 | */ |
@@ -2949,6 +2917,7 @@ static int init_dma_pools(struct pch_udc_dev *dev) | |||
2949 | { | 2917 | { |
2950 | struct pch_udc_stp_dma_desc *td_stp; | 2918 | struct pch_udc_stp_dma_desc *td_stp; |
2951 | struct pch_udc_data_dma_desc *td_data; | 2919 | struct pch_udc_data_dma_desc *td_data; |
2920 | void *ep0out_buf; | ||
2952 | 2921 | ||
2953 | /* DMA setup */ | 2922 | /* DMA setup */ |
2954 | dev->data_requests = pci_pool_create("data_requests", dev->pdev, | 2923 | dev->data_requests = pci_pool_create("data_requests", dev->pdev, |
@@ -2991,10 +2960,11 @@ static int init_dma_pools(struct pch_udc_dev *dev) | |||
2991 | dev->ep[UDC_EP0IN_IDX].td_data = NULL; | 2960 | dev->ep[UDC_EP0IN_IDX].td_data = NULL; |
2992 | dev->ep[UDC_EP0IN_IDX].td_data_phys = 0; | 2961 | dev->ep[UDC_EP0IN_IDX].td_data_phys = 0; |
2993 | 2962 | ||
2994 | dev->ep0out_buf = kzalloc(UDC_EP0OUT_BUFF_SIZE * 4, GFP_KERNEL); | 2963 | ep0out_buf = devm_kzalloc(&dev->pdev->dev, UDC_EP0OUT_BUFF_SIZE * 4, |
2995 | if (!dev->ep0out_buf) | 2964 | GFP_KERNEL); |
2965 | if (!ep0out_buf) | ||
2996 | return -ENOMEM; | 2966 | return -ENOMEM; |
2997 | dev->dma_addr = dma_map_single(&dev->pdev->dev, dev->ep0out_buf, | 2967 | dev->dma_addr = dma_map_single(&dev->pdev->dev, ep0out_buf, |
2998 | UDC_EP0OUT_BUFF_SIZE * 4, | 2968 | UDC_EP0OUT_BUFF_SIZE * 4, |
2999 | DMA_FROM_DEVICE); | 2969 | DMA_FROM_DEVICE); |
3000 | return 0; | 2970 | return 0; |
@@ -3078,129 +3048,80 @@ static void pch_udc_remove(struct pci_dev *pdev) | |||
3078 | if (dev->dma_addr) | 3048 | if (dev->dma_addr) |
3079 | dma_unmap_single(&dev->pdev->dev, dev->dma_addr, | 3049 | dma_unmap_single(&dev->pdev->dev, dev->dma_addr, |
3080 | UDC_EP0OUT_BUFF_SIZE * 4, DMA_FROM_DEVICE); | 3050 | UDC_EP0OUT_BUFF_SIZE * 4, DMA_FROM_DEVICE); |
3081 | kfree(dev->ep0out_buf); | ||
3082 | 3051 | ||
3083 | pch_vbus_gpio_free(dev); | 3052 | pch_vbus_gpio_free(dev); |
3084 | 3053 | ||
3085 | pch_udc_exit(dev); | 3054 | pch_udc_exit(dev); |
3086 | |||
3087 | if (dev->irq_registered) | ||
3088 | free_irq(pdev->irq, dev); | ||
3089 | if (dev->base_addr) | ||
3090 | iounmap(dev->base_addr); | ||
3091 | if (dev->mem_region) | ||
3092 | release_mem_region(dev->phys_addr, | ||
3093 | pci_resource_len(pdev, dev->bar)); | ||
3094 | if (dev->active) | ||
3095 | pci_disable_device(pdev); | ||
3096 | kfree(dev); | ||
3097 | } | 3055 | } |
3098 | 3056 | ||
3099 | #ifdef CONFIG_PM | 3057 | #ifdef CONFIG_PM_SLEEP |
3100 | static int pch_udc_suspend(struct pci_dev *pdev, pm_message_t state) | 3058 | static int pch_udc_suspend(struct device *d) |
3101 | { | 3059 | { |
3060 | struct pci_dev *pdev = to_pci_dev(d); | ||
3102 | struct pch_udc_dev *dev = pci_get_drvdata(pdev); | 3061 | struct pch_udc_dev *dev = pci_get_drvdata(pdev); |
3103 | 3062 | ||
3104 | pch_udc_disable_interrupts(dev, UDC_DEVINT_MSK); | 3063 | pch_udc_disable_interrupts(dev, UDC_DEVINT_MSK); |
3105 | pch_udc_disable_ep_interrupts(dev, UDC_EPINT_MSK_DISABLE_ALL); | 3064 | pch_udc_disable_ep_interrupts(dev, UDC_EPINT_MSK_DISABLE_ALL); |
3106 | 3065 | ||
3107 | pci_disable_device(pdev); | ||
3108 | pci_enable_wake(pdev, PCI_D3hot, 0); | ||
3109 | |||
3110 | if (pci_save_state(pdev)) { | ||
3111 | dev_err(&pdev->dev, | ||
3112 | "%s: could not save PCI config state\n", __func__); | ||
3113 | return -ENOMEM; | ||
3114 | } | ||
3115 | pci_set_power_state(pdev, pci_choose_state(pdev, state)); | ||
3116 | return 0; | 3066 | return 0; |
3117 | } | 3067 | } |
3118 | 3068 | ||
3119 | static int pch_udc_resume(struct pci_dev *pdev) | 3069 | static int pch_udc_resume(struct device *d) |
3120 | { | 3070 | { |
3121 | int ret; | ||
3122 | |||
3123 | pci_set_power_state(pdev, PCI_D0); | ||
3124 | pci_restore_state(pdev); | ||
3125 | ret = pci_enable_device(pdev); | ||
3126 | if (ret) { | ||
3127 | dev_err(&pdev->dev, "%s: pci_enable_device failed\n", __func__); | ||
3128 | return ret; | ||
3129 | } | ||
3130 | pci_enable_wake(pdev, PCI_D3hot, 0); | ||
3131 | return 0; | 3071 | return 0; |
3132 | } | 3072 | } |
3073 | |||
3074 | static SIMPLE_DEV_PM_OPS(pch_udc_pm, pch_udc_suspend, pch_udc_resume); | ||
3075 | #define PCH_UDC_PM_OPS (&pch_udc_pm) | ||
3133 | #else | 3076 | #else |
3134 | #define pch_udc_suspend NULL | 3077 | #define PCH_UDC_PM_OPS NULL |
3135 | #define pch_udc_resume NULL | 3078 | #endif /* CONFIG_PM_SLEEP */ |
3136 | #endif /* CONFIG_PM */ | ||
3137 | 3079 | ||
3138 | static int pch_udc_probe(struct pci_dev *pdev, | 3080 | static int pch_udc_probe(struct pci_dev *pdev, |
3139 | const struct pci_device_id *id) | 3081 | const struct pci_device_id *id) |
3140 | { | 3082 | { |
3141 | unsigned long resource; | 3083 | int bar; |
3142 | unsigned long len; | ||
3143 | int retval; | 3084 | int retval; |
3144 | struct pch_udc_dev *dev; | 3085 | struct pch_udc_dev *dev; |
3145 | 3086 | ||
3146 | /* init */ | 3087 | /* init */ |
3147 | dev = kzalloc(sizeof *dev, GFP_KERNEL); | 3088 | dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL); |
3148 | if (!dev) { | 3089 | if (!dev) |
3149 | pr_err("%s: no memory for device structure\n", __func__); | ||
3150 | return -ENOMEM; | 3090 | return -ENOMEM; |
3151 | } | 3091 | |
3152 | /* pci setup */ | 3092 | /* pci setup */ |
3153 | if (pci_enable_device(pdev) < 0) { | 3093 | retval = pcim_enable_device(pdev); |
3154 | kfree(dev); | 3094 | if (retval) |
3155 | pr_err("%s: pci_enable_device failed\n", __func__); | 3095 | return retval; |
3156 | return -ENODEV; | 3096 | |
3157 | } | ||
3158 | dev->active = 1; | ||
3159 | pci_set_drvdata(pdev, dev); | 3097 | pci_set_drvdata(pdev, dev); |
3160 | 3098 | ||
3161 | /* Determine BAR based on PCI ID */ | 3099 | /* Determine BAR based on PCI ID */ |
3162 | if (id->device == PCI_DEVICE_ID_INTEL_QUARK_X1000_UDC) | 3100 | if (id->device == PCI_DEVICE_ID_INTEL_QUARK_X1000_UDC) |
3163 | dev->bar = PCH_UDC_PCI_BAR_QUARK_X1000; | 3101 | bar = PCH_UDC_PCI_BAR_QUARK_X1000; |
3164 | else | 3102 | else |
3165 | dev->bar = PCH_UDC_PCI_BAR; | 3103 | bar = PCH_UDC_PCI_BAR; |
3166 | 3104 | ||
3167 | /* PCI resource allocation */ | 3105 | /* PCI resource allocation */ |
3168 | resource = pci_resource_start(pdev, dev->bar); | 3106 | retval = pcim_iomap_regions(pdev, 1 << bar, pci_name(pdev)); |
3169 | len = pci_resource_len(pdev, dev->bar); | 3107 | if (retval) |
3108 | return retval; | ||
3170 | 3109 | ||
3171 | if (!request_mem_region(resource, len, KBUILD_MODNAME)) { | 3110 | dev->base_addr = pcim_iomap_table(pdev)[bar]; |
3172 | dev_err(&pdev->dev, "%s: pci device used already\n", __func__); | ||
3173 | retval = -EBUSY; | ||
3174 | goto finished; | ||
3175 | } | ||
3176 | dev->phys_addr = resource; | ||
3177 | dev->mem_region = 1; | ||
3178 | 3111 | ||
3179 | dev->base_addr = ioremap_nocache(resource, len); | ||
3180 | if (!dev->base_addr) { | ||
3181 | pr_err("%s: device memory cannot be mapped\n", __func__); | ||
3182 | retval = -ENOMEM; | ||
3183 | goto finished; | ||
3184 | } | ||
3185 | if (!pdev->irq) { | ||
3186 | dev_err(&pdev->dev, "%s: irq not set\n", __func__); | ||
3187 | retval = -ENODEV; | ||
3188 | goto finished; | ||
3189 | } | ||
3190 | /* initialize the hardware */ | 3112 | /* initialize the hardware */ |
3191 | if (pch_udc_pcd_init(dev)) { | 3113 | if (pch_udc_pcd_init(dev)) |
3192 | retval = -ENODEV; | 3114 | return -ENODEV; |
3193 | goto finished; | 3115 | |
3194 | } | 3116 | pci_enable_msi(pdev); |
3195 | if (request_irq(pdev->irq, pch_udc_isr, IRQF_SHARED, KBUILD_MODNAME, | 3117 | |
3196 | dev)) { | 3118 | retval = devm_request_irq(&pdev->dev, pdev->irq, pch_udc_isr, |
3119 | IRQF_SHARED, KBUILD_MODNAME, dev); | ||
3120 | if (retval) { | ||
3197 | dev_err(&pdev->dev, "%s: request_irq(%d) fail\n", __func__, | 3121 | dev_err(&pdev->dev, "%s: request_irq(%d) fail\n", __func__, |
3198 | pdev->irq); | 3122 | pdev->irq); |
3199 | retval = -ENODEV; | ||
3200 | goto finished; | 3123 | goto finished; |
3201 | } | 3124 | } |
3202 | dev->irq = pdev->irq; | ||
3203 | dev->irq_registered = 1; | ||
3204 | 3125 | ||
3205 | pci_set_master(pdev); | 3126 | pci_set_master(pdev); |
3206 | pci_try_set_mwi(pdev); | 3127 | pci_try_set_mwi(pdev); |
@@ -3219,8 +3140,7 @@ static int pch_udc_probe(struct pci_dev *pdev, | |||
3219 | 3140 | ||
3220 | /* Put the device in disconnected state till a driver is bound */ | 3141 | /* Put the device in disconnected state till a driver is bound */ |
3221 | pch_udc_set_disconnect(dev); | 3142 | pch_udc_set_disconnect(dev); |
3222 | retval = usb_add_gadget_udc_release(&pdev->dev, &dev->gadget, | 3143 | retval = usb_add_gadget_udc(&pdev->dev, &dev->gadget); |
3223 | gadget_release); | ||
3224 | if (retval) | 3144 | if (retval) |
3225 | goto finished; | 3145 | goto finished; |
3226 | return 0; | 3146 | return 0; |
@@ -3262,9 +3182,10 @@ static struct pci_driver pch_udc_driver = { | |||
3262 | .id_table = pch_udc_pcidev_id, | 3182 | .id_table = pch_udc_pcidev_id, |
3263 | .probe = pch_udc_probe, | 3183 | .probe = pch_udc_probe, |
3264 | .remove = pch_udc_remove, | 3184 | .remove = pch_udc_remove, |
3265 | .suspend = pch_udc_suspend, | ||
3266 | .resume = pch_udc_resume, | ||
3267 | .shutdown = pch_udc_shutdown, | 3185 | .shutdown = pch_udc_shutdown, |
3186 | .driver = { | ||
3187 | .pm = PCH_UDC_PM_OPS, | ||
3188 | }, | ||
3268 | }; | 3189 | }; |
3269 | 3190 | ||
3270 | module_pci_driver(pch_udc_driver); | 3191 | module_pci_driver(pch_udc_driver); |
diff --git a/drivers/usb/gadget/udc/r8a66597-udc.c b/drivers/usb/gadget/udc/r8a66597-udc.c index baa0609a429d..8b300e6da7fc 100644 --- a/drivers/usb/gadget/udc/r8a66597-udc.c +++ b/drivers/usb/gadget/udc/r8a66597-udc.c | |||
@@ -296,7 +296,7 @@ static void r8a66597_change_curpipe(struct r8a66597 *r8a66597, u16 pipenum, | |||
296 | } while ((tmp & mask) != loop); | 296 | } while ((tmp & mask) != loop); |
297 | } | 297 | } |
298 | 298 | ||
299 | static inline void pipe_change(struct r8a66597 *r8a66597, u16 pipenum) | 299 | static void pipe_change(struct r8a66597 *r8a66597, u16 pipenum) |
300 | { | 300 | { |
301 | struct r8a66597_ep *ep = r8a66597->pipenum2ep[pipenum]; | 301 | struct r8a66597_ep *ep = r8a66597->pipenum2ep[pipenum]; |
302 | 302 | ||
diff --git a/drivers/usb/gadget/udc/udc-core.c b/drivers/usb/gadget/udc/udc-core.c index e4e70e11d0f6..6e8300d6a737 100644 --- a/drivers/usb/gadget/udc/udc-core.c +++ b/drivers/usb/gadget/udc/udc-core.c | |||
@@ -61,11 +61,9 @@ static int udc_bind_to_driver(struct usb_udc *udc, | |||
61 | 61 | ||
62 | #ifdef CONFIG_HAS_DMA | 62 | #ifdef CONFIG_HAS_DMA |
63 | 63 | ||
64 | int usb_gadget_map_request(struct usb_gadget *gadget, | 64 | int usb_gadget_map_request_by_dev(struct device *dev, |
65 | struct usb_request *req, int is_in) | 65 | struct usb_request *req, int is_in) |
66 | { | 66 | { |
67 | struct device *dev = gadget->dev.parent; | ||
68 | |||
69 | if (req->length == 0) | 67 | if (req->length == 0) |
70 | return 0; | 68 | return 0; |
71 | 69 | ||
@@ -75,7 +73,7 @@ int usb_gadget_map_request(struct usb_gadget *gadget, | |||
75 | mapped = dma_map_sg(dev, req->sg, req->num_sgs, | 73 | mapped = dma_map_sg(dev, req->sg, req->num_sgs, |
76 | is_in ? DMA_TO_DEVICE : DMA_FROM_DEVICE); | 74 | is_in ? DMA_TO_DEVICE : DMA_FROM_DEVICE); |
77 | if (mapped == 0) { | 75 | if (mapped == 0) { |
78 | dev_err(&gadget->dev, "failed to map SGs\n"); | 76 | dev_err(dev, "failed to map SGs\n"); |
79 | return -EFAULT; | 77 | return -EFAULT; |
80 | } | 78 | } |
81 | 79 | ||
@@ -92,24 +90,38 @@ int usb_gadget_map_request(struct usb_gadget *gadget, | |||
92 | 90 | ||
93 | return 0; | 91 | return 0; |
94 | } | 92 | } |
93 | EXPORT_SYMBOL_GPL(usb_gadget_map_request_by_dev); | ||
94 | |||
95 | int usb_gadget_map_request(struct usb_gadget *gadget, | ||
96 | struct usb_request *req, int is_in) | ||
97 | { | ||
98 | return usb_gadget_map_request_by_dev(gadget->dev.parent, req, is_in); | ||
99 | } | ||
95 | EXPORT_SYMBOL_GPL(usb_gadget_map_request); | 100 | EXPORT_SYMBOL_GPL(usb_gadget_map_request); |
96 | 101 | ||
97 | void usb_gadget_unmap_request(struct usb_gadget *gadget, | 102 | void usb_gadget_unmap_request_by_dev(struct device *dev, |
98 | struct usb_request *req, int is_in) | 103 | struct usb_request *req, int is_in) |
99 | { | 104 | { |
100 | if (req->length == 0) | 105 | if (req->length == 0) |
101 | return; | 106 | return; |
102 | 107 | ||
103 | if (req->num_mapped_sgs) { | 108 | if (req->num_mapped_sgs) { |
104 | dma_unmap_sg(gadget->dev.parent, req->sg, req->num_mapped_sgs, | 109 | dma_unmap_sg(dev, req->sg, req->num_mapped_sgs, |
105 | is_in ? DMA_TO_DEVICE : DMA_FROM_DEVICE); | 110 | is_in ? DMA_TO_DEVICE : DMA_FROM_DEVICE); |
106 | 111 | ||
107 | req->num_mapped_sgs = 0; | 112 | req->num_mapped_sgs = 0; |
108 | } else { | 113 | } else { |
109 | dma_unmap_single(gadget->dev.parent, req->dma, req->length, | 114 | dma_unmap_single(dev, req->dma, req->length, |
110 | is_in ? DMA_TO_DEVICE : DMA_FROM_DEVICE); | 115 | is_in ? DMA_TO_DEVICE : DMA_FROM_DEVICE); |
111 | } | 116 | } |
112 | } | 117 | } |
118 | EXPORT_SYMBOL_GPL(usb_gadget_unmap_request_by_dev); | ||
119 | |||
120 | void usb_gadget_unmap_request(struct usb_gadget *gadget, | ||
121 | struct usb_request *req, int is_in) | ||
122 | { | ||
123 | usb_gadget_unmap_request_by_dev(gadget->dev.parent, req, is_in); | ||
124 | } | ||
113 | EXPORT_SYMBOL_GPL(usb_gadget_unmap_request); | 125 | EXPORT_SYMBOL_GPL(usb_gadget_unmap_request); |
114 | 126 | ||
115 | #endif /* CONFIG_HAS_DMA */ | 127 | #endif /* CONFIG_HAS_DMA */ |
diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig index 6acac6201af0..d8f5674809e8 100644 --- a/drivers/usb/host/Kconfig +++ b/drivers/usb/host/Kconfig | |||
@@ -35,6 +35,7 @@ config USB_XHCI_PCI | |||
35 | 35 | ||
36 | config USB_XHCI_PLATFORM | 36 | config USB_XHCI_PLATFORM |
37 | tristate "Generic xHCI driver for a platform device" | 37 | tristate "Generic xHCI driver for a platform device" |
38 | select USB_XHCI_RCAR if ARCH_RENESAS | ||
38 | ---help--- | 39 | ---help--- |
39 | Adds an xHCI host driver for a generic platform device, which | 40 | Adds an xHCI host driver for a generic platform device, which |
40 | provides a memory space and an irq. | 41 | provides a memory space and an irq. |
@@ -63,7 +64,7 @@ config USB_XHCI_MVEBU | |||
63 | 64 | ||
64 | config USB_XHCI_RCAR | 65 | config USB_XHCI_RCAR |
65 | tristate "xHCI support for Renesas R-Car SoCs" | 66 | tristate "xHCI support for Renesas R-Car SoCs" |
66 | select USB_XHCI_PLATFORM | 67 | depends on USB_XHCI_PLATFORM |
67 | depends on ARCH_RENESAS || COMPILE_TEST | 68 | depends on ARCH_RENESAS || COMPILE_TEST |
68 | ---help--- | 69 | ---help--- |
69 | Say 'Y' to enable the support for the xHCI host controller | 70 | Say 'Y' to enable the support for the xHCI host controller |
diff --git a/drivers/usb/host/bcma-hcd.c b/drivers/usb/host/bcma-hcd.c index 963e2d0e8f92..172ef17911aa 100644 --- a/drivers/usb/host/bcma-hcd.c +++ b/drivers/usb/host/bcma-hcd.c | |||
@@ -352,10 +352,8 @@ static int bcma_hcd_probe(struct bcma_device *core) | |||
352 | usb_dev->core = core; | 352 | usb_dev->core = core; |
353 | 353 | ||
354 | if (core->dev.of_node) | 354 | if (core->dev.of_node) |
355 | usb_dev->gpio_desc = devm_get_gpiod_from_child(&core->dev, "vcc", | 355 | usb_dev->gpio_desc = devm_gpiod_get(&core->dev, "vcc", |
356 | &core->dev.of_node->fwnode); | 356 | GPIOD_OUT_HIGH); |
357 | if (!IS_ERR_OR_NULL(usb_dev->gpio_desc)) | ||
358 | gpiod_direction_output(usb_dev->gpio_desc, 1); | ||
359 | 357 | ||
360 | switch (core->id.id) { | 358 | switch (core->id.id) { |
361 | case BCMA_CORE_USB20_HOST: | 359 | case BCMA_CORE_USB20_HOST: |
diff --git a/drivers/usb/host/ehci-dbg.c b/drivers/usb/host/ehci-dbg.c index 79d12b2ba3c4..1a2614aae42c 100644 --- a/drivers/usb/host/ehci-dbg.c +++ b/drivers/usb/host/ehci-dbg.c | |||
@@ -52,13 +52,6 @@ static void dbg_hcs_params(struct ehci_hcd *ehci, char *label) | |||
52 | ehci_dbg(ehci, "%s portroute %s\n", label, buf); | 52 | ehci_dbg(ehci, "%s portroute %s\n", label, buf); |
53 | } | 53 | } |
54 | } | 54 | } |
55 | #else | ||
56 | |||
57 | static inline void dbg_hcs_params(struct ehci_hcd *ehci, char *label) {} | ||
58 | |||
59 | #endif | ||
60 | |||
61 | #ifdef CONFIG_DYNAMIC_DEBUG | ||
62 | 55 | ||
63 | /* | 56 | /* |
64 | * check the values in the HCCPARAMS register | 57 | * check the values in the HCCPARAMS register |
@@ -92,13 +85,6 @@ static void dbg_hcc_params(struct ehci_hcd *ehci, char *label) | |||
92 | " 32 periodic list" : ""); | 85 | " 32 periodic list" : ""); |
93 | } | 86 | } |
94 | } | 87 | } |
95 | #else | ||
96 | |||
97 | static inline void dbg_hcc_params(struct ehci_hcd *ehci, char *label) {} | ||
98 | |||
99 | #endif | ||
100 | |||
101 | #ifdef CONFIG_DYNAMIC_DEBUG | ||
102 | 88 | ||
103 | static void __maybe_unused | 89 | static void __maybe_unused |
104 | dbg_qtd(const char *label, struct ehci_hcd *ehci, struct ehci_qtd *qtd) | 90 | dbg_qtd(const char *label, struct ehci_hcd *ehci, struct ehci_qtd *qtd) |
@@ -281,37 +267,6 @@ dbg_port_buf(char *buf, unsigned len, const char *label, int port, u32 status) | |||
281 | (status & PORT_CONNECT) ? " CONNECT" : ""); | 267 | (status & PORT_CONNECT) ? " CONNECT" : ""); |
282 | } | 268 | } |
283 | 269 | ||
284 | #else | ||
285 | static inline void __maybe_unused | ||
286 | dbg_qh(char *label, struct ehci_hcd *ehci, struct ehci_qh *qh) | ||
287 | {} | ||
288 | |||
289 | static inline int __maybe_unused | ||
290 | dbg_status_buf(char *buf, unsigned len, const char *label, u32 status) | ||
291 | { | ||
292 | return 0; | ||
293 | } | ||
294 | |||
295 | static inline int __maybe_unused | ||
296 | dbg_command_buf(char *buf, unsigned len, const char *label, u32 command) | ||
297 | { | ||
298 | return 0; | ||
299 | } | ||
300 | |||
301 | static inline int __maybe_unused | ||
302 | dbg_intr_buf(char *buf, unsigned len, const char *label, u32 enable) | ||
303 | { | ||
304 | return 0; | ||
305 | } | ||
306 | |||
307 | static inline int __maybe_unused | ||
308 | dbg_port_buf(char *buf, unsigned len, const char *label, int port, u32 status) | ||
309 | { | ||
310 | return 0; | ||
311 | } | ||
312 | |||
313 | #endif /* CONFIG_DYNAMIC_DEBUG */ | ||
314 | |||
315 | static inline void | 270 | static inline void |
316 | dbg_status(struct ehci_hcd *ehci, const char *label, u32 status) | 271 | dbg_status(struct ehci_hcd *ehci, const char *label, u32 status) |
317 | { | 272 | { |
@@ -341,13 +296,6 @@ dbg_port(struct ehci_hcd *ehci, const char *label, int port, u32 status) | |||
341 | 296 | ||
342 | /*-------------------------------------------------------------------------*/ | 297 | /*-------------------------------------------------------------------------*/ |
343 | 298 | ||
344 | #ifndef CONFIG_DYNAMIC_DEBUG | ||
345 | |||
346 | static inline void create_debug_files(struct ehci_hcd *bus) { } | ||
347 | static inline void remove_debug_files(struct ehci_hcd *bus) { } | ||
348 | |||
349 | #else | ||
350 | |||
351 | /* troubleshooting help: expose state in debugfs */ | 299 | /* troubleshooting help: expose state in debugfs */ |
352 | 300 | ||
353 | static int debug_async_open(struct inode *, struct file *); | 301 | static int debug_async_open(struct inode *, struct file *); |
@@ -1120,4 +1068,38 @@ static inline void remove_debug_files(struct ehci_hcd *ehci) | |||
1120 | debugfs_remove_recursive(ehci->debug_dir); | 1068 | debugfs_remove_recursive(ehci->debug_dir); |
1121 | } | 1069 | } |
1122 | 1070 | ||
1071 | #else /* CONFIG_DYNAMIC_DEBUG */ | ||
1072 | |||
1073 | static inline void dbg_hcs_params(struct ehci_hcd *ehci, char *label) { } | ||
1074 | static inline void dbg_hcc_params(struct ehci_hcd *ehci, char *label) { } | ||
1075 | |||
1076 | static inline void __maybe_unused dbg_qh(const char *label, | ||
1077 | struct ehci_hcd *ehci, struct ehci_qh *qh) { } | ||
1078 | |||
1079 | static inline int __maybe_unused dbg_status_buf(const char *buf, | ||
1080 | unsigned int len, const char *label, u32 status) | ||
1081 | { return 0; } | ||
1082 | |||
1083 | static inline int __maybe_unused dbg_command_buf(const char *buf, | ||
1084 | unsigned int len, const char *label, u32 command) | ||
1085 | { return 0; } | ||
1086 | |||
1087 | static inline int __maybe_unused dbg_intr_buf(const char *buf, | ||
1088 | unsigned int len, const char *label, u32 enable) | ||
1089 | { return 0; } | ||
1090 | |||
1091 | static inline int __maybe_unused dbg_port_buf(char *buf, | ||
1092 | unsigned int len, const char *label, int port, u32 status) | ||
1093 | { return 0; } | ||
1094 | |||
1095 | static inline void dbg_status(struct ehci_hcd *ehci, const char *label, | ||
1096 | u32 status) { } | ||
1097 | static inline void dbg_cmd(struct ehci_hcd *ehci, const char *label, | ||
1098 | u32 command) { } | ||
1099 | static inline void dbg_port(struct ehci_hcd *ehci, const char *label, | ||
1100 | int port, u32 status) { } | ||
1101 | |||
1102 | static inline void create_debug_files(struct ehci_hcd *bus) { } | ||
1103 | static inline void remove_debug_files(struct ehci_hcd *bus) { } | ||
1104 | |||
1123 | #endif /* CONFIG_DYNAMIC_DEBUG */ | 1105 | #endif /* CONFIG_DYNAMIC_DEBUG */ |
diff --git a/drivers/usb/host/ehci-exynos.c b/drivers/usb/host/ehci-exynos.c index df538fd10aa4..42e5b66353ef 100644 --- a/drivers/usb/host/ehci-exynos.c +++ b/drivers/usb/host/ehci-exynos.c | |||
@@ -321,7 +321,7 @@ static struct platform_driver exynos_ehci_driver = { | |||
321 | .of_match_table = of_match_ptr(exynos_ehci_match), | 321 | .of_match_table = of_match_ptr(exynos_ehci_match), |
322 | } | 322 | } |
323 | }; | 323 | }; |
324 | static const struct ehci_driver_overrides exynos_overrides __initdata = { | 324 | static const struct ehci_driver_overrides exynos_overrides __initconst = { |
325 | .extra_priv_size = sizeof(struct exynos_ehci_hcd), | 325 | .extra_priv_size = sizeof(struct exynos_ehci_hcd), |
326 | }; | 326 | }; |
327 | 327 | ||
diff --git a/drivers/usb/host/ehci-msm.c b/drivers/usb/host/ehci-msm.c index 3e226ef6ca62..d3afc89d00f5 100644 --- a/drivers/usb/host/ehci-msm.c +++ b/drivers/usb/host/ehci-msm.c | |||
@@ -229,7 +229,7 @@ static struct platform_driver ehci_msm_driver = { | |||
229 | }, | 229 | }, |
230 | }; | 230 | }; |
231 | 231 | ||
232 | static const struct ehci_driver_overrides msm_overrides __initdata = { | 232 | static const struct ehci_driver_overrides msm_overrides __initconst = { |
233 | .reset = ehci_msm_reset, | 233 | .reset = ehci_msm_reset, |
234 | }; | 234 | }; |
235 | 235 | ||
diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c index a24720beb39d..94ea9fff13e6 100644 --- a/drivers/usb/host/ehci-omap.c +++ b/drivers/usb/host/ehci-omap.c | |||
@@ -86,7 +86,7 @@ static inline u32 ehci_read(void __iomem *base, u32 reg) | |||
86 | 86 | ||
87 | static struct hc_driver __read_mostly ehci_omap_hc_driver; | 87 | static struct hc_driver __read_mostly ehci_omap_hc_driver; |
88 | 88 | ||
89 | static const struct ehci_driver_overrides ehci_omap_overrides __initdata = { | 89 | static const struct ehci_driver_overrides ehci_omap_overrides __initconst = { |
90 | .extra_priv_size = sizeof(struct omap_hcd), | 90 | .extra_priv_size = sizeof(struct omap_hcd), |
91 | }; | 91 | }; |
92 | 92 | ||
diff --git a/drivers/usb/host/ehci-spear.c b/drivers/usb/host/ehci-spear.c index 3c4e5253955c..1f25c7985f5b 100644 --- a/drivers/usb/host/ehci-spear.c +++ b/drivers/usb/host/ehci-spear.c | |||
@@ -163,7 +163,7 @@ static struct platform_driver spear_ehci_hcd_driver = { | |||
163 | } | 163 | } |
164 | }; | 164 | }; |
165 | 165 | ||
166 | static const struct ehci_driver_overrides spear_overrides __initdata = { | 166 | static const struct ehci_driver_overrides spear_overrides __initconst = { |
167 | .extra_priv_size = sizeof(struct spear_ehci), | 167 | .extra_priv_size = sizeof(struct spear_ehci), |
168 | }; | 168 | }; |
169 | 169 | ||
diff --git a/drivers/usb/host/fhci-sched.c b/drivers/usb/host/fhci-sched.c index a9609a336efe..2f162faabbca 100644 --- a/drivers/usb/host/fhci-sched.c +++ b/drivers/usb/host/fhci-sched.c | |||
@@ -288,7 +288,7 @@ static int scan_ed_list(struct fhci_usb *usb, | |||
288 | list_for_each_entry(ed, list, node) { | 288 | list_for_each_entry(ed, list, node) { |
289 | td = ed->td_head; | 289 | td = ed->td_head; |
290 | 290 | ||
291 | if (!td || (td && td->status == USB_TD_INPROGRESS)) | 291 | if (!td || td->status == USB_TD_INPROGRESS) |
292 | continue; | 292 | continue; |
293 | 293 | ||
294 | if (ed->state != FHCI_ED_OPER) { | 294 | if (ed->state != FHCI_ED_OPER) { |
diff --git a/drivers/usb/host/fotg210-hcd.c b/drivers/usb/host/fotg210-hcd.c index 360a5e95abca..66efa9a67687 100644 --- a/drivers/usb/host/fotg210-hcd.c +++ b/drivers/usb/host/fotg210-hcd.c | |||
@@ -4795,14 +4795,8 @@ static DEVICE_ATTR(uframe_periodic_max, 0644, show_uframe_periodic_max, | |||
4795 | static inline int create_sysfs_files(struct fotg210_hcd *fotg210) | 4795 | static inline int create_sysfs_files(struct fotg210_hcd *fotg210) |
4796 | { | 4796 | { |
4797 | struct device *controller = fotg210_to_hcd(fotg210)->self.controller; | 4797 | struct device *controller = fotg210_to_hcd(fotg210)->self.controller; |
4798 | int i = 0; | ||
4799 | 4798 | ||
4800 | if (i) | 4799 | return device_create_file(controller, &dev_attr_uframe_periodic_max); |
4801 | goto out; | ||
4802 | |||
4803 | i = device_create_file(controller, &dev_attr_uframe_periodic_max); | ||
4804 | out: | ||
4805 | return i; | ||
4806 | } | 4800 | } |
4807 | 4801 | ||
4808 | static inline void remove_sysfs_files(struct fotg210_hcd *fotg210) | 4802 | static inline void remove_sysfs_files(struct fotg210_hcd *fotg210) |
diff --git a/drivers/usb/host/whci/hcd.c b/drivers/usb/host/whci/hcd.c index 43626c44683b..5b3603c360ab 100644 --- a/drivers/usb/host/whci/hcd.c +++ b/drivers/usb/host/whci/hcd.c | |||
@@ -257,14 +257,14 @@ static int whc_probe(struct umc_dev *umc) | |||
257 | 257 | ||
258 | ret = whc_init(whc); | 258 | ret = whc_init(whc); |
259 | if (ret) | 259 | if (ret) |
260 | goto error; | 260 | goto error_whc_init; |
261 | 261 | ||
262 | wusbhc->dev = dev; | 262 | wusbhc->dev = dev; |
263 | wusbhc->uwb_rc = uwb_rc_get_by_grandpa(umc->dev.parent); | 263 | wusbhc->uwb_rc = uwb_rc_get_by_grandpa(umc->dev.parent); |
264 | if (!wusbhc->uwb_rc) { | 264 | if (!wusbhc->uwb_rc) { |
265 | ret = -ENODEV; | 265 | ret = -ENODEV; |
266 | dev_err(dev, "cannot get radio controller\n"); | 266 | dev_err(dev, "cannot get radio controller\n"); |
267 | goto error; | 267 | goto error_uwb_rc; |
268 | } | 268 | } |
269 | 269 | ||
270 | if (whc->n_devices > USB_MAXCHILDREN) { | 270 | if (whc->n_devices > USB_MAXCHILDREN) { |
@@ -311,8 +311,9 @@ error_usb_add_hcd: | |||
311 | wusbhc_destroy(wusbhc); | 311 | wusbhc_destroy(wusbhc); |
312 | error_wusbhc_create: | 312 | error_wusbhc_create: |
313 | uwb_rc_put(wusbhc->uwb_rc); | 313 | uwb_rc_put(wusbhc->uwb_rc); |
314 | error: | 314 | error_uwb_rc: |
315 | whc_clean_up(whc); | 315 | whc_clean_up(whc); |
316 | error_whc_init: | ||
316 | usb_put_hcd(usb_hcd); | 317 | usb_put_hcd(usb_hcd); |
317 | return ret; | 318 | return ret; |
318 | } | 319 | } |
diff --git a/drivers/usb/host/whci/qset.c b/drivers/usb/host/whci/qset.c index 1a8e960d073b..c0e6812426b3 100644 --- a/drivers/usb/host/whci/qset.c +++ b/drivers/usb/host/whci/qset.c | |||
@@ -314,7 +314,7 @@ void qset_free_std(struct whc *whc, struct whc_std *std) | |||
314 | kfree(std->bounce_buf); | 314 | kfree(std->bounce_buf); |
315 | } | 315 | } |
316 | if (std->pl_virt) { | 316 | if (std->pl_virt) { |
317 | if (std->dma_addr) | 317 | if (!dma_mapping_error(whc->wusbhc.dev, std->dma_addr)) |
318 | dma_unmap_single(whc->wusbhc.dev, std->dma_addr, | 318 | dma_unmap_single(whc->wusbhc.dev, std->dma_addr, |
319 | std->num_pointers * sizeof(struct whc_page_list_entry), | 319 | std->num_pointers * sizeof(struct whc_page_list_entry), |
320 | DMA_TO_DEVICE); | 320 | DMA_TO_DEVICE); |
@@ -535,9 +535,11 @@ static int qset_add_urb_sg(struct whc *whc, struct whc_qset *qset, struct urb *u | |||
535 | list_for_each_entry(std, &qset->stds, list_node) { | 535 | list_for_each_entry(std, &qset->stds, list_node) { |
536 | if (std->ntds_remaining == -1) { | 536 | if (std->ntds_remaining == -1) { |
537 | pl_len = std->num_pointers * sizeof(struct whc_page_list_entry); | 537 | pl_len = std->num_pointers * sizeof(struct whc_page_list_entry); |
538 | std->ntds_remaining = ntds--; | ||
539 | std->dma_addr = dma_map_single(whc->wusbhc.dev, std->pl_virt, | 538 | std->dma_addr = dma_map_single(whc->wusbhc.dev, std->pl_virt, |
540 | pl_len, DMA_TO_DEVICE); | 539 | pl_len, DMA_TO_DEVICE); |
540 | if (dma_mapping_error(whc->wusbhc.dev, std->dma_addr)) | ||
541 | return -EFAULT; | ||
542 | std->ntds_remaining = ntds--; | ||
541 | } | 543 | } |
542 | } | 544 | } |
543 | return 0; | 545 | return 0; |
@@ -618,6 +620,8 @@ static int qset_add_urb_sg_linearize(struct whc *whc, struct whc_qset *qset, | |||
618 | 620 | ||
619 | std->dma_addr = dma_map_single(&whc->umc->dev, std->bounce_buf, std->len, | 621 | std->dma_addr = dma_map_single(&whc->umc->dev, std->bounce_buf, std->len, |
620 | is_out ? DMA_TO_DEVICE : DMA_FROM_DEVICE); | 622 | is_out ? DMA_TO_DEVICE : DMA_FROM_DEVICE); |
623 | if (dma_mapping_error(&whc->umc->dev, std->dma_addr)) | ||
624 | return -EFAULT; | ||
621 | 625 | ||
622 | if (qset_fill_page_list(whc, std, mem_flags) < 0) | 626 | if (qset_fill_page_list(whc, std, mem_flags) < 0) |
623 | return -ENOMEM; | 627 | return -ENOMEM; |
diff --git a/drivers/usb/host/xhci-mvebu.c b/drivers/usb/host/xhci-mvebu.c index 1eefc988192d..85908a3ecb8f 100644 --- a/drivers/usb/host/xhci-mvebu.c +++ b/drivers/usb/host/xhci-mvebu.c | |||
@@ -12,6 +12,9 @@ | |||
12 | #include <linux/of.h> | 12 | #include <linux/of.h> |
13 | #include <linux/platform_device.h> | 13 | #include <linux/platform_device.h> |
14 | 14 | ||
15 | #include <linux/usb.h> | ||
16 | #include <linux/usb/hcd.h> | ||
17 | |||
15 | #include "xhci-mvebu.h" | 18 | #include "xhci-mvebu.h" |
16 | 19 | ||
17 | #define USB3_MAX_WINDOWS 4 | 20 | #define USB3_MAX_WINDOWS 4 |
@@ -41,8 +44,10 @@ static void xhci_mvebu_mbus_config(void __iomem *base, | |||
41 | } | 44 | } |
42 | } | 45 | } |
43 | 46 | ||
44 | int xhci_mvebu_mbus_init_quirk(struct platform_device *pdev) | 47 | int xhci_mvebu_mbus_init_quirk(struct usb_hcd *hcd) |
45 | { | 48 | { |
49 | struct device *dev = hcd->self.controller; | ||
50 | struct platform_device *pdev = to_platform_device(dev); | ||
46 | struct resource *res; | 51 | struct resource *res; |
47 | void __iomem *base; | 52 | void __iomem *base; |
48 | const struct mbus_dram_target_info *dram; | 53 | const struct mbus_dram_target_info *dram; |
diff --git a/drivers/usb/host/xhci-mvebu.h b/drivers/usb/host/xhci-mvebu.h index 7ede92aa41f6..301fc984cae6 100644 --- a/drivers/usb/host/xhci-mvebu.h +++ b/drivers/usb/host/xhci-mvebu.h | |||
@@ -10,10 +10,13 @@ | |||
10 | 10 | ||
11 | #ifndef __LINUX_XHCI_MVEBU_H | 11 | #ifndef __LINUX_XHCI_MVEBU_H |
12 | #define __LINUX_XHCI_MVEBU_H | 12 | #define __LINUX_XHCI_MVEBU_H |
13 | |||
14 | struct usb_hcd; | ||
15 | |||
13 | #if IS_ENABLED(CONFIG_USB_XHCI_MVEBU) | 16 | #if IS_ENABLED(CONFIG_USB_XHCI_MVEBU) |
14 | int xhci_mvebu_mbus_init_quirk(struct platform_device *pdev); | 17 | int xhci_mvebu_mbus_init_quirk(struct usb_hcd *hcd); |
15 | #else | 18 | #else |
16 | static inline int xhci_mvebu_mbus_init_quirk(struct platform_device *pdev) | 19 | static inline int xhci_mvebu_mbus_init_quirk(struct usb_hcd *hcd) |
17 | { | 20 | { |
18 | return 0; | 21 | return 0; |
19 | } | 22 | } |
diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c index 474b5fa14900..676ea458148b 100644 --- a/drivers/usb/host/xhci-plat.c +++ b/drivers/usb/host/xhci-plat.c | |||
@@ -37,27 +37,32 @@ static const struct xhci_driver_overrides xhci_plat_overrides __initconst = { | |||
37 | .start = xhci_plat_start, | 37 | .start = xhci_plat_start, |
38 | }; | 38 | }; |
39 | 39 | ||
40 | static void xhci_plat_quirks(struct device *dev, struct xhci_hcd *xhci) | 40 | static void xhci_priv_plat_start(struct usb_hcd *hcd) |
41 | { | ||
42 | struct xhci_plat_priv *priv = hcd_to_xhci_priv(hcd); | ||
43 | |||
44 | if (priv->plat_start) | ||
45 | priv->plat_start(hcd); | ||
46 | } | ||
47 | |||
48 | static int xhci_priv_init_quirk(struct usb_hcd *hcd) | ||
41 | { | 49 | { |
42 | struct usb_hcd *hcd = xhci_to_hcd(xhci); | 50 | struct xhci_plat_priv *priv = hcd_to_xhci_priv(hcd); |
51 | |||
52 | if (!priv->init_quirk) | ||
53 | return 0; | ||
43 | 54 | ||
55 | return priv->init_quirk(hcd); | ||
56 | } | ||
57 | |||
58 | static void xhci_plat_quirks(struct device *dev, struct xhci_hcd *xhci) | ||
59 | { | ||
44 | /* | 60 | /* |
45 | * As of now platform drivers don't provide MSI support so we ensure | 61 | * As of now platform drivers don't provide MSI support so we ensure |
46 | * here that the generic code does not try to make a pci_dev from our | 62 | * here that the generic code does not try to make a pci_dev from our |
47 | * dev struct in order to setup MSI | 63 | * dev struct in order to setup MSI |
48 | */ | 64 | */ |
49 | xhci->quirks |= XHCI_PLAT; | 65 | xhci->quirks |= XHCI_PLAT; |
50 | |||
51 | /* | ||
52 | * On R-Car Gen2 and Gen3, the AC64 bit (bit 0) of HCCPARAMS1 is set | ||
53 | * to 1. However, these SoCs don't support 64-bit address memory | ||
54 | * pointers. So, this driver clears the AC64 bit of xhci->hcc_params | ||
55 | * to call dma_set_coherent_mask(dev, DMA_BIT_MASK(32)) in | ||
56 | * xhci_gen_setup(). | ||
57 | */ | ||
58 | if (xhci_plat_type_is(hcd, XHCI_PLAT_TYPE_RENESAS_RCAR_GEN2) || | ||
59 | xhci_plat_type_is(hcd, XHCI_PLAT_TYPE_RENESAS_RCAR_GEN3)) | ||
60 | xhci->quirks |= XHCI_NO_64BIT_SUPPORT; | ||
61 | } | 66 | } |
62 | 67 | ||
63 | /* called during probe() after chip reset completes */ | 68 | /* called during probe() after chip reset completes */ |
@@ -65,38 +70,35 @@ static int xhci_plat_setup(struct usb_hcd *hcd) | |||
65 | { | 70 | { |
66 | int ret; | 71 | int ret; |
67 | 72 | ||
68 | if (xhci_plat_type_is(hcd, XHCI_PLAT_TYPE_RENESAS_RCAR_GEN2) || | 73 | |
69 | xhci_plat_type_is(hcd, XHCI_PLAT_TYPE_RENESAS_RCAR_GEN3)) { | 74 | ret = xhci_priv_init_quirk(hcd); |
70 | ret = xhci_rcar_init_quirk(hcd); | 75 | if (ret) |
71 | if (ret) | 76 | return ret; |
72 | return ret; | ||
73 | } | ||
74 | 77 | ||
75 | return xhci_gen_setup(hcd, xhci_plat_quirks); | 78 | return xhci_gen_setup(hcd, xhci_plat_quirks); |
76 | } | 79 | } |
77 | 80 | ||
78 | static int xhci_plat_start(struct usb_hcd *hcd) | 81 | static int xhci_plat_start(struct usb_hcd *hcd) |
79 | { | 82 | { |
80 | if (xhci_plat_type_is(hcd, XHCI_PLAT_TYPE_RENESAS_RCAR_GEN2) || | 83 | xhci_priv_plat_start(hcd); |
81 | xhci_plat_type_is(hcd, XHCI_PLAT_TYPE_RENESAS_RCAR_GEN3)) | ||
82 | xhci_rcar_start(hcd); | ||
83 | |||
84 | return xhci_run(hcd); | 84 | return xhci_run(hcd); |
85 | } | 85 | } |
86 | 86 | ||
87 | #ifdef CONFIG_OF | 87 | #ifdef CONFIG_OF |
88 | static const struct xhci_plat_priv xhci_plat_marvell_armada = { | 88 | static const struct xhci_plat_priv xhci_plat_marvell_armada = { |
89 | .type = XHCI_PLAT_TYPE_MARVELL_ARMADA, | 89 | .init_quirk = xhci_mvebu_mbus_init_quirk, |
90 | }; | 90 | }; |
91 | 91 | ||
92 | static const struct xhci_plat_priv xhci_plat_renesas_rcar_gen2 = { | 92 | static const struct xhci_plat_priv xhci_plat_renesas_rcar_gen2 = { |
93 | .type = XHCI_PLAT_TYPE_RENESAS_RCAR_GEN2, | ||
94 | .firmware_name = XHCI_RCAR_FIRMWARE_NAME_V1, | 93 | .firmware_name = XHCI_RCAR_FIRMWARE_NAME_V1, |
94 | .init_quirk = xhci_rcar_init_quirk, | ||
95 | .plat_start = xhci_rcar_start, | ||
95 | }; | 96 | }; |
96 | 97 | ||
97 | static const struct xhci_plat_priv xhci_plat_renesas_rcar_gen3 = { | 98 | static const struct xhci_plat_priv xhci_plat_renesas_rcar_gen3 = { |
98 | .type = XHCI_PLAT_TYPE_RENESAS_RCAR_GEN3, | ||
99 | .firmware_name = XHCI_RCAR_FIRMWARE_NAME_V2, | 99 | .firmware_name = XHCI_RCAR_FIRMWARE_NAME_V2, |
100 | .init_quirk = xhci_rcar_init_quirk, | ||
101 | .plat_start = xhci_rcar_start, | ||
100 | }; | 102 | }; |
101 | 103 | ||
102 | static const struct of_device_id usb_xhci_of_match[] = { | 104 | static const struct of_device_id usb_xhci_of_match[] = { |
@@ -207,12 +209,6 @@ static int xhci_plat_probe(struct platform_device *pdev) | |||
207 | *priv = *priv_match; | 209 | *priv = *priv_match; |
208 | } | 210 | } |
209 | 211 | ||
210 | if (xhci_plat_type_is(hcd, XHCI_PLAT_TYPE_MARVELL_ARMADA)) { | ||
211 | ret = xhci_mvebu_mbus_init_quirk(pdev); | ||
212 | if (ret) | ||
213 | goto disable_clk; | ||
214 | } | ||
215 | |||
216 | device_wakeup_enable(hcd->self.controller); | 212 | device_wakeup_enable(hcd->self.controller); |
217 | 213 | ||
218 | xhci->clk = clk; | 214 | xhci->clk = clk; |
diff --git a/drivers/usb/host/xhci-plat.h b/drivers/usb/host/xhci-plat.h index 529c3c40f901..9af0cb48053f 100644 --- a/drivers/usb/host/xhci-plat.h +++ b/drivers/usb/host/xhci-plat.h | |||
@@ -13,27 +13,11 @@ | |||
13 | 13 | ||
14 | #include "xhci.h" /* for hcd_to_xhci() */ | 14 | #include "xhci.h" /* for hcd_to_xhci() */ |
15 | 15 | ||
16 | enum xhci_plat_type { | ||
17 | XHCI_PLAT_TYPE_MARVELL_ARMADA = 1, | ||
18 | XHCI_PLAT_TYPE_RENESAS_RCAR_GEN2, | ||
19 | XHCI_PLAT_TYPE_RENESAS_RCAR_GEN3, | ||
20 | }; | ||
21 | |||
22 | struct xhci_plat_priv { | 16 | struct xhci_plat_priv { |
23 | enum xhci_plat_type type; | ||
24 | const char *firmware_name; | 17 | const char *firmware_name; |
18 | void (*plat_start)(struct usb_hcd *); | ||
19 | int (*init_quirk)(struct usb_hcd *); | ||
25 | }; | 20 | }; |
26 | 21 | ||
27 | #define hcd_to_xhci_priv(h) ((struct xhci_plat_priv *)hcd_to_xhci(h)->priv) | 22 | #define hcd_to_xhci_priv(h) ((struct xhci_plat_priv *)hcd_to_xhci(h)->priv) |
28 | |||
29 | static inline bool xhci_plat_type_is(struct usb_hcd *hcd, | ||
30 | enum xhci_plat_type type) | ||
31 | { | ||
32 | struct xhci_plat_priv *priv = hcd_to_xhci_priv(hcd); | ||
33 | |||
34 | if (priv && priv->type == type) | ||
35 | return true; | ||
36 | else | ||
37 | return false; | ||
38 | } | ||
39 | #endif /* _XHCI_PLAT_H */ | 23 | #endif /* _XHCI_PLAT_H */ |
diff --git a/drivers/usb/host/xhci-rcar.c b/drivers/usb/host/xhci-rcar.c index 623100e9385e..0e4535e632ec 100644 --- a/drivers/usb/host/xhci-rcar.c +++ b/drivers/usb/host/xhci-rcar.c | |||
@@ -11,6 +11,7 @@ | |||
11 | #include <linux/firmware.h> | 11 | #include <linux/firmware.h> |
12 | #include <linux/module.h> | 12 | #include <linux/module.h> |
13 | #include <linux/platform_device.h> | 13 | #include <linux/platform_device.h> |
14 | #include <linux/of.h> | ||
14 | #include <linux/usb/phy.h> | 15 | #include <linux/usb/phy.h> |
15 | 16 | ||
16 | #include "xhci.h" | 17 | #include "xhci.h" |
@@ -76,6 +77,24 @@ static void xhci_rcar_start_gen2(struct usb_hcd *hcd) | |||
76 | writel(RCAR_USB3_TX_POL_VAL, hcd->regs + RCAR_USB3_TX_POL); | 77 | writel(RCAR_USB3_TX_POL_VAL, hcd->regs + RCAR_USB3_TX_POL); |
77 | } | 78 | } |
78 | 79 | ||
80 | static int xhci_rcar_is_gen2(struct device *dev) | ||
81 | { | ||
82 | struct device_node *node = dev->of_node; | ||
83 | |||
84 | return of_device_is_compatible(node, "renesas,xhci-r8a7790") || | ||
85 | of_device_is_compatible(node, "renesas,xhci-r8a7791") || | ||
86 | of_device_is_compatible(node, "renesas,xhci-r8a7793") || | ||
87 | of_device_is_compatible(node, "renensas,rcar-gen2-xhci"); | ||
88 | } | ||
89 | |||
90 | static int xhci_rcar_is_gen3(struct device *dev) | ||
91 | { | ||
92 | struct device_node *node = dev->of_node; | ||
93 | |||
94 | return of_device_is_compatible(node, "renesas,xhci-r8a7795") || | ||
95 | of_device_is_compatible(node, "renesas,rcar-gen3-xhci"); | ||
96 | } | ||
97 | |||
79 | void xhci_rcar_start(struct usb_hcd *hcd) | 98 | void xhci_rcar_start(struct usb_hcd *hcd) |
80 | { | 99 | { |
81 | u32 temp; | 100 | u32 temp; |
@@ -85,7 +104,7 @@ void xhci_rcar_start(struct usb_hcd *hcd) | |||
85 | temp = readl(hcd->regs + RCAR_USB3_INT_ENA); | 104 | temp = readl(hcd->regs + RCAR_USB3_INT_ENA); |
86 | temp |= RCAR_USB3_INT_ENA_VAL; | 105 | temp |= RCAR_USB3_INT_ENA_VAL; |
87 | writel(temp, hcd->regs + RCAR_USB3_INT_ENA); | 106 | writel(temp, hcd->regs + RCAR_USB3_INT_ENA); |
88 | if (xhci_plat_type_is(hcd, XHCI_PLAT_TYPE_RENESAS_RCAR_GEN2)) | 107 | if (xhci_rcar_is_gen2(hcd->self.controller)) |
89 | xhci_rcar_start_gen2(hcd); | 108 | xhci_rcar_start_gen2(hcd); |
90 | } | 109 | } |
91 | } | 110 | } |
@@ -156,9 +175,22 @@ static int xhci_rcar_download_firmware(struct usb_hcd *hcd) | |||
156 | /* This function needs to initialize a "phy" of usb before */ | 175 | /* This function needs to initialize a "phy" of usb before */ |
157 | int xhci_rcar_init_quirk(struct usb_hcd *hcd) | 176 | int xhci_rcar_init_quirk(struct usb_hcd *hcd) |
158 | { | 177 | { |
178 | struct xhci_hcd *xhci = hcd_to_xhci(hcd); | ||
179 | |||
159 | /* If hcd->regs is NULL, we don't just call the following function */ | 180 | /* If hcd->regs is NULL, we don't just call the following function */ |
160 | if (!hcd->regs) | 181 | if (!hcd->regs) |
161 | return 0; | 182 | return 0; |
162 | 183 | ||
184 | /* | ||
185 | * On R-Car Gen2 and Gen3, the AC64 bit (bit 0) of HCCPARAMS1 is set | ||
186 | * to 1. However, these SoCs don't support 64-bit address memory | ||
187 | * pointers. So, this driver clears the AC64 bit of xhci->hcc_params | ||
188 | * to call dma_set_coherent_mask(dev, DMA_BIT_MASK(32)) in | ||
189 | * xhci_gen_setup(). | ||
190 | */ | ||
191 | if (xhci_rcar_is_gen2(hcd->self.controller) || | ||
192 | xhci_rcar_is_gen3(hcd->self.controller)) | ||
193 | xhci->quirks |= XHCI_NO_64BIT_SUPPORT; | ||
194 | |||
163 | return xhci_rcar_download_firmware(hcd); | 195 | return xhci_rcar_download_firmware(hcd); |
164 | } | 196 | } |
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index 99b4ff42f7a0..52deae4b7eac 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c | |||
@@ -373,7 +373,11 @@ static void ring_doorbell_for_active_rings(struct xhci_hcd *xhci, | |||
373 | } | 373 | } |
374 | } | 374 | } |
375 | 375 | ||
376 | static struct xhci_ring *xhci_triad_to_transfer_ring(struct xhci_hcd *xhci, | 376 | /* Get the right ring for the given slot_id, ep_index and stream_id. |
377 | * If the endpoint supports streams, boundary check the URB's stream ID. | ||
378 | * If the endpoint doesn't support streams, return the singular endpoint ring. | ||
379 | */ | ||
380 | struct xhci_ring *xhci_triad_to_transfer_ring(struct xhci_hcd *xhci, | ||
377 | unsigned int slot_id, unsigned int ep_index, | 381 | unsigned int slot_id, unsigned int ep_index, |
378 | unsigned int stream_id) | 382 | unsigned int stream_id) |
379 | { | 383 | { |
@@ -405,17 +409,6 @@ static struct xhci_ring *xhci_triad_to_transfer_ring(struct xhci_hcd *xhci, | |||
405 | return NULL; | 409 | return NULL; |
406 | } | 410 | } |
407 | 411 | ||
408 | /* Get the right ring for the given URB. | ||
409 | * If the endpoint supports streams, boundary check the URB's stream ID. | ||
410 | * If the endpoint doesn't support streams, return the singular endpoint ring. | ||
411 | */ | ||
412 | static struct xhci_ring *xhci_urb_to_transfer_ring(struct xhci_hcd *xhci, | ||
413 | struct urb *urb) | ||
414 | { | ||
415 | return xhci_triad_to_transfer_ring(xhci, urb->dev->slot_id, | ||
416 | xhci_get_endpoint_index(&urb->ep->desc), urb->stream_id); | ||
417 | } | ||
418 | |||
419 | /* | 412 | /* |
420 | * Move the xHC's endpoint ring dequeue pointer past cur_td. | 413 | * Move the xHC's endpoint ring dequeue pointer past cur_td. |
421 | * Record the new state of the xHC's endpoint ring dequeue segment, | 414 | * Record the new state of the xHC's endpoint ring dequeue segment, |
@@ -1768,7 +1761,7 @@ static int xhci_requires_manual_halt_cleanup(struct xhci_hcd *xhci, | |||
1768 | if (trb_comp_code == COMP_TX_ERR || | 1761 | if (trb_comp_code == COMP_TX_ERR || |
1769 | trb_comp_code == COMP_BABBLE || | 1762 | trb_comp_code == COMP_BABBLE || |
1770 | trb_comp_code == COMP_SPLIT_ERR) | 1763 | trb_comp_code == COMP_SPLIT_ERR) |
1771 | /* The 0.96 spec says a babbling control endpoint | 1764 | /* The 0.95 spec says a babbling control endpoint |
1772 | * is not halted. The 0.96 spec says it is. Some HW | 1765 | * is not halted. The 0.96 spec says it is. Some HW |
1773 | * claims to be 0.95 compliant, but it halts the control | 1766 | * claims to be 0.95 compliant, but it halts the control |
1774 | * endpoint anyway. Check if a babble halted the | 1767 | * endpoint anyway. Check if a babble halted the |
@@ -2938,46 +2931,55 @@ static int prepare_transfer(struct xhci_hcd *xhci, | |||
2938 | return 0; | 2931 | return 0; |
2939 | } | 2932 | } |
2940 | 2933 | ||
2941 | static unsigned int count_sg_trbs_needed(struct xhci_hcd *xhci, struct urb *urb) | 2934 | static unsigned int count_trbs(u64 addr, u64 len) |
2935 | { | ||
2936 | unsigned int num_trbs; | ||
2937 | |||
2938 | num_trbs = DIV_ROUND_UP(len + (addr & (TRB_MAX_BUFF_SIZE - 1)), | ||
2939 | TRB_MAX_BUFF_SIZE); | ||
2940 | if (num_trbs == 0) | ||
2941 | num_trbs++; | ||
2942 | |||
2943 | return num_trbs; | ||
2944 | } | ||
2945 | |||
2946 | static inline unsigned int count_trbs_needed(struct urb *urb) | ||
2947 | { | ||
2948 | return count_trbs(urb->transfer_dma, urb->transfer_buffer_length); | ||
2949 | } | ||
2950 | |||
2951 | static unsigned int count_sg_trbs_needed(struct urb *urb) | ||
2942 | { | 2952 | { |
2943 | int num_sgs, num_trbs, running_total, temp, i; | ||
2944 | struct scatterlist *sg; | 2953 | struct scatterlist *sg; |
2954 | unsigned int i, len, full_len, num_trbs = 0; | ||
2945 | 2955 | ||
2946 | sg = NULL; | 2956 | full_len = urb->transfer_buffer_length; |
2947 | num_sgs = urb->num_mapped_sgs; | ||
2948 | temp = urb->transfer_buffer_length; | ||
2949 | 2957 | ||
2950 | num_trbs = 0; | 2958 | for_each_sg(urb->sg, sg, urb->num_mapped_sgs, i) { |
2951 | for_each_sg(urb->sg, sg, num_sgs, i) { | 2959 | len = sg_dma_len(sg); |
2952 | unsigned int len = sg_dma_len(sg); | 2960 | num_trbs += count_trbs(sg_dma_address(sg), len); |
2953 | 2961 | len = min_t(unsigned int, len, full_len); | |
2954 | /* Scatter gather list entries may cross 64KB boundaries */ | 2962 | full_len -= len; |
2955 | running_total = TRB_MAX_BUFF_SIZE - | 2963 | if (full_len == 0) |
2956 | (sg_dma_address(sg) & (TRB_MAX_BUFF_SIZE - 1)); | ||
2957 | running_total &= TRB_MAX_BUFF_SIZE - 1; | ||
2958 | if (running_total != 0) | ||
2959 | num_trbs++; | ||
2960 | |||
2961 | /* How many more 64KB chunks to transfer, how many more TRBs? */ | ||
2962 | while (running_total < sg_dma_len(sg) && running_total < temp) { | ||
2963 | num_trbs++; | ||
2964 | running_total += TRB_MAX_BUFF_SIZE; | ||
2965 | } | ||
2966 | len = min_t(int, len, temp); | ||
2967 | temp -= len; | ||
2968 | if (temp == 0) | ||
2969 | break; | 2964 | break; |
2970 | } | 2965 | } |
2966 | |||
2971 | return num_trbs; | 2967 | return num_trbs; |
2972 | } | 2968 | } |
2973 | 2969 | ||
2974 | static void check_trb_math(struct urb *urb, int num_trbs, int running_total) | 2970 | static unsigned int count_isoc_trbs_needed(struct urb *urb, int i) |
2975 | { | 2971 | { |
2976 | if (num_trbs != 0) | 2972 | u64 addr, len; |
2977 | dev_err(&urb->dev->dev, "%s - ep %#x - Miscalculated number of " | 2973 | |
2978 | "TRBs, %d left\n", __func__, | 2974 | addr = (u64) (urb->transfer_dma + urb->iso_frame_desc[i].offset); |
2979 | urb->ep->desc.bEndpointAddress, num_trbs); | 2975 | len = urb->iso_frame_desc[i].length; |
2980 | if (running_total != urb->transfer_buffer_length) | 2976 | |
2977 | return count_trbs(addr, len); | ||
2978 | } | ||
2979 | |||
2980 | static void check_trb_math(struct urb *urb, int running_total) | ||
2981 | { | ||
2982 | if (unlikely(running_total != urb->transfer_buffer_length)) | ||
2981 | dev_err(&urb->dev->dev, "%s - ep %#x - Miscalculated tx length, " | 2983 | dev_err(&urb->dev->dev, "%s - ep %#x - Miscalculated tx length, " |
2982 | "queued %#x (%d), asked for %#x (%d)\n", | 2984 | "queued %#x (%d), asked for %#x (%d)\n", |
2983 | __func__, | 2985 | __func__, |
@@ -3003,26 +3005,20 @@ static void giveback_first_trb(struct xhci_hcd *xhci, int slot_id, | |||
3003 | xhci_ring_ep_doorbell(xhci, slot_id, ep_index, stream_id); | 3005 | xhci_ring_ep_doorbell(xhci, slot_id, ep_index, stream_id); |
3004 | } | 3006 | } |
3005 | 3007 | ||
3006 | /* | 3008 | static void check_interval(struct xhci_hcd *xhci, struct urb *urb, |
3007 | * xHCI uses normal TRBs for both bulk and interrupt. When the interrupt | 3009 | struct xhci_ep_ctx *ep_ctx) |
3008 | * endpoint is to be serviced, the xHC will consume (at most) one TD. A TD | ||
3009 | * (comprised of sg list entries) can take several service intervals to | ||
3010 | * transmit. | ||
3011 | */ | ||
3012 | int xhci_queue_intr_tx(struct xhci_hcd *xhci, gfp_t mem_flags, | ||
3013 | struct urb *urb, int slot_id, unsigned int ep_index) | ||
3014 | { | 3010 | { |
3015 | struct xhci_ep_ctx *ep_ctx = xhci_get_ep_ctx(xhci, | ||
3016 | xhci->devs[slot_id]->out_ctx, ep_index); | ||
3017 | int xhci_interval; | 3011 | int xhci_interval; |
3018 | int ep_interval; | 3012 | int ep_interval; |
3019 | 3013 | ||
3020 | xhci_interval = EP_INTERVAL_TO_UFRAMES(le32_to_cpu(ep_ctx->ep_info)); | 3014 | xhci_interval = EP_INTERVAL_TO_UFRAMES(le32_to_cpu(ep_ctx->ep_info)); |
3021 | ep_interval = urb->interval; | 3015 | ep_interval = urb->interval; |
3016 | |||
3022 | /* Convert to microframes */ | 3017 | /* Convert to microframes */ |
3023 | if (urb->dev->speed == USB_SPEED_LOW || | 3018 | if (urb->dev->speed == USB_SPEED_LOW || |
3024 | urb->dev->speed == USB_SPEED_FULL) | 3019 | urb->dev->speed == USB_SPEED_FULL) |
3025 | ep_interval *= 8; | 3020 | ep_interval *= 8; |
3021 | |||
3026 | /* FIXME change this to a warning and a suggestion to use the new API | 3022 | /* FIXME change this to a warning and a suggestion to use the new API |
3027 | * to set the polling interval (once the API is added). | 3023 | * to set the polling interval (once the API is added). |
3028 | */ | 3024 | */ |
@@ -3037,6 +3033,22 @@ int xhci_queue_intr_tx(struct xhci_hcd *xhci, gfp_t mem_flags, | |||
3037 | urb->dev->speed == USB_SPEED_FULL) | 3033 | urb->dev->speed == USB_SPEED_FULL) |
3038 | urb->interval /= 8; | 3034 | urb->interval /= 8; |
3039 | } | 3035 | } |
3036 | } | ||
3037 | |||
3038 | /* | ||
3039 | * xHCI uses normal TRBs for both bulk and interrupt. When the interrupt | ||
3040 | * endpoint is to be serviced, the xHC will consume (at most) one TD. A TD | ||
3041 | * (comprised of sg list entries) can take several service intervals to | ||
3042 | * transmit. | ||
3043 | */ | ||
3044 | int xhci_queue_intr_tx(struct xhci_hcd *xhci, gfp_t mem_flags, | ||
3045 | struct urb *urb, int slot_id, unsigned int ep_index) | ||
3046 | { | ||
3047 | struct xhci_ep_ctx *ep_ctx; | ||
3048 | |||
3049 | ep_ctx = xhci_get_ep_ctx(xhci, xhci->devs[slot_id]->out_ctx, ep_index); | ||
3050 | check_interval(xhci, urb, ep_ctx); | ||
3051 | |||
3040 | return xhci_queue_bulk_tx(xhci, mem_flags, urb, slot_id, ep_index); | 3052 | return xhci_queue_bulk_tx(xhci, mem_flags, urb, slot_id, ep_index); |
3041 | } | 3053 | } |
3042 | 3054 | ||
@@ -3086,44 +3098,47 @@ static u32 xhci_td_remainder(struct xhci_hcd *xhci, int transferred, | |||
3086 | return (total_packet_count - ((transferred + trb_buff_len) / maxp)); | 3098 | return (total_packet_count - ((transferred + trb_buff_len) / maxp)); |
3087 | } | 3099 | } |
3088 | 3100 | ||
3089 | 3101 | /* This is very similar to what ehci-q.c qtd_fill() does */ | |
3090 | static int queue_bulk_sg_tx(struct xhci_hcd *xhci, gfp_t mem_flags, | 3102 | int xhci_queue_bulk_tx(struct xhci_hcd *xhci, gfp_t mem_flags, |
3091 | struct urb *urb, int slot_id, unsigned int ep_index) | 3103 | struct urb *urb, int slot_id, unsigned int ep_index) |
3092 | { | 3104 | { |
3093 | struct xhci_ring *ep_ring; | 3105 | struct xhci_ring *ep_ring; |
3094 | unsigned int num_trbs; | ||
3095 | struct urb_priv *urb_priv; | 3106 | struct urb_priv *urb_priv; |
3096 | struct xhci_td *td; | 3107 | struct xhci_td *td; |
3097 | struct scatterlist *sg; | 3108 | struct xhci_generic_trb *start_trb; |
3098 | int num_sgs; | 3109 | struct scatterlist *sg = NULL; |
3099 | int trb_buff_len, this_sg_len, running_total, ret; | 3110 | bool more_trbs_coming; |
3100 | unsigned int total_packet_count; | ||
3101 | bool zero_length_needed; | 3111 | bool zero_length_needed; |
3102 | bool first_trb; | 3112 | unsigned int num_trbs, last_trb_num, i; |
3103 | int last_trb_num; | 3113 | unsigned int start_cycle, num_sgs = 0; |
3114 | unsigned int running_total, block_len, trb_buff_len; | ||
3115 | unsigned int full_len; | ||
3116 | int ret; | ||
3117 | u32 field, length_field, remainder; | ||
3104 | u64 addr; | 3118 | u64 addr; |
3105 | bool more_trbs_coming; | ||
3106 | |||
3107 | struct xhci_generic_trb *start_trb; | ||
3108 | int start_cycle; | ||
3109 | 3119 | ||
3110 | ep_ring = xhci_urb_to_transfer_ring(xhci, urb); | 3120 | ep_ring = xhci_urb_to_transfer_ring(xhci, urb); |
3111 | if (!ep_ring) | 3121 | if (!ep_ring) |
3112 | return -EINVAL; | 3122 | return -EINVAL; |
3113 | 3123 | ||
3114 | num_trbs = count_sg_trbs_needed(xhci, urb); | 3124 | /* If we have scatter/gather list, we use it. */ |
3115 | num_sgs = urb->num_mapped_sgs; | 3125 | if (urb->num_sgs) { |
3116 | total_packet_count = DIV_ROUND_UP(urb->transfer_buffer_length, | 3126 | num_sgs = urb->num_mapped_sgs; |
3117 | usb_endpoint_maxp(&urb->ep->desc)); | 3127 | sg = urb->sg; |
3128 | num_trbs = count_sg_trbs_needed(urb); | ||
3129 | } else | ||
3130 | num_trbs = count_trbs_needed(urb); | ||
3118 | 3131 | ||
3119 | ret = prepare_transfer(xhci, xhci->devs[slot_id], | 3132 | ret = prepare_transfer(xhci, xhci->devs[slot_id], |
3120 | ep_index, urb->stream_id, | 3133 | ep_index, urb->stream_id, |
3121 | num_trbs, urb, 0, mem_flags); | 3134 | num_trbs, urb, 0, mem_flags); |
3122 | if (ret < 0) | 3135 | if (unlikely(ret < 0)) |
3123 | return ret; | 3136 | return ret; |
3124 | 3137 | ||
3125 | urb_priv = urb->hcpriv; | 3138 | urb_priv = urb->hcpriv; |
3126 | 3139 | ||
3140 | last_trb_num = num_trbs - 1; | ||
3141 | |||
3127 | /* Deal with URB_ZERO_PACKET - need one more td/trb */ | 3142 | /* Deal with URB_ZERO_PACKET - need one more td/trb */ |
3128 | zero_length_needed = urb->transfer_flags & URB_ZERO_PACKET && | 3143 | zero_length_needed = urb->transfer_flags & URB_ZERO_PACKET && |
3129 | urb_priv->length == 2; | 3144 | urb_priv->length == 2; |
@@ -3133,7 +3148,7 @@ static int queue_bulk_sg_tx(struct xhci_hcd *xhci, gfp_t mem_flags, | |||
3133 | ret = prepare_transfer(xhci, xhci->devs[slot_id], | 3148 | ret = prepare_transfer(xhci, xhci->devs[slot_id], |
3134 | ep_index, urb->stream_id, | 3149 | ep_index, urb->stream_id, |
3135 | 1, urb, 1, mem_flags); | 3150 | 1, urb, 1, mem_flags); |
3136 | if (ret < 0) | 3151 | if (unlikely(ret < 0)) |
3137 | return ret; | 3152 | return ret; |
3138 | } | 3153 | } |
3139 | 3154 | ||
@@ -3147,228 +3162,58 @@ static int queue_bulk_sg_tx(struct xhci_hcd *xhci, gfp_t mem_flags, | |||
3147 | start_trb = &ep_ring->enqueue->generic; | 3162 | start_trb = &ep_ring->enqueue->generic; |
3148 | start_cycle = ep_ring->cycle_state; | 3163 | start_cycle = ep_ring->cycle_state; |
3149 | 3164 | ||
3165 | full_len = urb->transfer_buffer_length; | ||
3150 | running_total = 0; | 3166 | running_total = 0; |
3151 | /* | 3167 | block_len = 0; |
3152 | * How much data is in the first TRB? | ||
3153 | * | ||
3154 | * There are three forces at work for TRB buffer pointers and lengths: | ||
3155 | * 1. We don't want to walk off the end of this sg-list entry buffer. | ||
3156 | * 2. The transfer length that the driver requested may be smaller than | ||
3157 | * the amount of memory allocated for this scatter-gather list. | ||
3158 | * 3. TRBs buffers can't cross 64KB boundaries. | ||
3159 | */ | ||
3160 | sg = urb->sg; | ||
3161 | addr = (u64) sg_dma_address(sg); | ||
3162 | this_sg_len = sg_dma_len(sg); | ||
3163 | trb_buff_len = TRB_MAX_BUFF_SIZE - (addr & (TRB_MAX_BUFF_SIZE - 1)); | ||
3164 | trb_buff_len = min_t(int, trb_buff_len, this_sg_len); | ||
3165 | if (trb_buff_len > urb->transfer_buffer_length) | ||
3166 | trb_buff_len = urb->transfer_buffer_length; | ||
3167 | |||
3168 | first_trb = true; | ||
3169 | last_trb_num = zero_length_needed ? 2 : 1; | ||
3170 | /* Queue the first TRB, even if it's zero-length */ | ||
3171 | do { | ||
3172 | u32 field = 0; | ||
3173 | u32 length_field = 0; | ||
3174 | u32 remainder = 0; | ||
3175 | 3168 | ||
3176 | /* Don't change the cycle bit of the first TRB until later */ | 3169 | /* Queue the TRBs, even if they are zero-length */ |
3177 | if (first_trb) { | 3170 | for (i = 0; i < num_trbs; i++) { |
3178 | first_trb = false; | 3171 | field = TRB_TYPE(TRB_NORMAL); |
3179 | if (start_cycle == 0) | ||
3180 | field |= 0x1; | ||
3181 | } else | ||
3182 | field |= ep_ring->cycle_state; | ||
3183 | 3172 | ||
3184 | /* Chain all the TRBs together; clear the chain bit in the last | 3173 | if (block_len == 0) { |
3185 | * TRB to indicate it's the last TRB in the chain. | 3174 | /* A new contiguous block. */ |
3186 | */ | 3175 | if (sg) { |
3187 | if (num_trbs > last_trb_num) { | 3176 | addr = (u64) sg_dma_address(sg); |
3188 | field |= TRB_CHAIN; | 3177 | block_len = sg_dma_len(sg); |
3189 | } else if (num_trbs == last_trb_num) { | 3178 | } else { |
3190 | td->last_trb = ep_ring->enqueue; | 3179 | addr = (u64) urb->transfer_dma; |
3191 | field |= TRB_IOC; | 3180 | block_len = full_len; |
3192 | } else if (zero_length_needed && num_trbs == 1) { | 3181 | } |
3193 | trb_buff_len = 0; | 3182 | /* TRB buffer should not cross 64KB boundaries */ |
3194 | urb_priv->td[1]->last_trb = ep_ring->enqueue; | 3183 | trb_buff_len = TRB_BUFF_LEN_UP_TO_BOUNDARY(addr); |
3195 | field |= TRB_IOC; | 3184 | trb_buff_len = min_t(unsigned int, |
3196 | } | 3185 | trb_buff_len, |
3197 | 3186 | block_len); | |
3198 | /* Only set interrupt on short packet for IN endpoints */ | ||
3199 | if (usb_urb_dir_in(urb)) | ||
3200 | field |= TRB_ISP; | ||
3201 | |||
3202 | if (TRB_MAX_BUFF_SIZE - | ||
3203 | (addr & (TRB_MAX_BUFF_SIZE - 1)) < trb_buff_len) { | ||
3204 | xhci_warn(xhci, "WARN: sg dma xfer crosses 64KB boundaries!\n"); | ||
3205 | xhci_dbg(xhci, "Next boundary at %#x, end dma = %#x\n", | ||
3206 | (unsigned int) (addr + TRB_MAX_BUFF_SIZE) & ~(TRB_MAX_BUFF_SIZE - 1), | ||
3207 | (unsigned int) addr + trb_buff_len); | ||
3208 | } | ||
3209 | |||
3210 | /* Set the TRB length, TD size, and interrupter fields. */ | ||
3211 | remainder = xhci_td_remainder(xhci, running_total, trb_buff_len, | ||
3212 | urb->transfer_buffer_length, | ||
3213 | urb, num_trbs - 1); | ||
3214 | |||
3215 | length_field = TRB_LEN(trb_buff_len) | | ||
3216 | TRB_TD_SIZE(remainder) | | ||
3217 | TRB_INTR_TARGET(0); | ||
3218 | |||
3219 | if (num_trbs > 1) | ||
3220 | more_trbs_coming = true; | ||
3221 | else | ||
3222 | more_trbs_coming = false; | ||
3223 | queue_trb(xhci, ep_ring, more_trbs_coming, | ||
3224 | lower_32_bits(addr), | ||
3225 | upper_32_bits(addr), | ||
3226 | length_field, | ||
3227 | field | TRB_TYPE(TRB_NORMAL)); | ||
3228 | --num_trbs; | ||
3229 | running_total += trb_buff_len; | ||
3230 | |||
3231 | /* Calculate length for next transfer -- | ||
3232 | * Are we done queueing all the TRBs for this sg entry? | ||
3233 | */ | ||
3234 | this_sg_len -= trb_buff_len; | ||
3235 | if (this_sg_len == 0) { | ||
3236 | --num_sgs; | ||
3237 | if (num_sgs == 0) | ||
3238 | break; | ||
3239 | sg = sg_next(sg); | ||
3240 | addr = (u64) sg_dma_address(sg); | ||
3241 | this_sg_len = sg_dma_len(sg); | ||
3242 | } else { | 3187 | } else { |
3243 | addr += trb_buff_len; | 3188 | /* Further through the contiguous block. */ |
3189 | trb_buff_len = block_len; | ||
3190 | if (trb_buff_len > TRB_MAX_BUFF_SIZE) | ||
3191 | trb_buff_len = TRB_MAX_BUFF_SIZE; | ||
3244 | } | 3192 | } |
3245 | 3193 | ||
3246 | trb_buff_len = TRB_MAX_BUFF_SIZE - | 3194 | if (running_total + trb_buff_len > full_len) |
3247 | (addr & (TRB_MAX_BUFF_SIZE - 1)); | 3195 | trb_buff_len = full_len - running_total; |
3248 | trb_buff_len = min_t(int, trb_buff_len, this_sg_len); | ||
3249 | if (running_total + trb_buff_len > urb->transfer_buffer_length) | ||
3250 | trb_buff_len = | ||
3251 | urb->transfer_buffer_length - running_total; | ||
3252 | } while (num_trbs > 0); | ||
3253 | |||
3254 | check_trb_math(urb, num_trbs, running_total); | ||
3255 | giveback_first_trb(xhci, slot_id, ep_index, urb->stream_id, | ||
3256 | start_cycle, start_trb); | ||
3257 | return 0; | ||
3258 | } | ||
3259 | |||
3260 | /* This is very similar to what ehci-q.c qtd_fill() does */ | ||
3261 | int xhci_queue_bulk_tx(struct xhci_hcd *xhci, gfp_t mem_flags, | ||
3262 | struct urb *urb, int slot_id, unsigned int ep_index) | ||
3263 | { | ||
3264 | struct xhci_ring *ep_ring; | ||
3265 | struct urb_priv *urb_priv; | ||
3266 | struct xhci_td *td; | ||
3267 | int num_trbs; | ||
3268 | struct xhci_generic_trb *start_trb; | ||
3269 | bool first_trb; | ||
3270 | int last_trb_num; | ||
3271 | bool more_trbs_coming; | ||
3272 | bool zero_length_needed; | ||
3273 | int start_cycle; | ||
3274 | u32 field, length_field; | ||
3275 | |||
3276 | int running_total, trb_buff_len, ret; | ||
3277 | unsigned int total_packet_count; | ||
3278 | u64 addr; | ||
3279 | |||
3280 | if (urb->num_sgs) | ||
3281 | return queue_bulk_sg_tx(xhci, mem_flags, urb, slot_id, ep_index); | ||
3282 | |||
3283 | ep_ring = xhci_urb_to_transfer_ring(xhci, urb); | ||
3284 | if (!ep_ring) | ||
3285 | return -EINVAL; | ||
3286 | |||
3287 | num_trbs = 0; | ||
3288 | /* How much data is (potentially) left before the 64KB boundary? */ | ||
3289 | running_total = TRB_MAX_BUFF_SIZE - | ||
3290 | (urb->transfer_dma & (TRB_MAX_BUFF_SIZE - 1)); | ||
3291 | running_total &= TRB_MAX_BUFF_SIZE - 1; | ||
3292 | |||
3293 | /* If there's some data on this 64KB chunk, or we have to send a | ||
3294 | * zero-length transfer, we need at least one TRB | ||
3295 | */ | ||
3296 | if (running_total != 0 || urb->transfer_buffer_length == 0) | ||
3297 | num_trbs++; | ||
3298 | /* How many more 64KB chunks to transfer, how many more TRBs? */ | ||
3299 | while (running_total < urb->transfer_buffer_length) { | ||
3300 | num_trbs++; | ||
3301 | running_total += TRB_MAX_BUFF_SIZE; | ||
3302 | } | ||
3303 | |||
3304 | ret = prepare_transfer(xhci, xhci->devs[slot_id], | ||
3305 | ep_index, urb->stream_id, | ||
3306 | num_trbs, urb, 0, mem_flags); | ||
3307 | if (ret < 0) | ||
3308 | return ret; | ||
3309 | |||
3310 | urb_priv = urb->hcpriv; | ||
3311 | |||
3312 | /* Deal with URB_ZERO_PACKET - need one more td/trb */ | ||
3313 | zero_length_needed = urb->transfer_flags & URB_ZERO_PACKET && | ||
3314 | urb_priv->length == 2; | ||
3315 | if (zero_length_needed) { | ||
3316 | num_trbs++; | ||
3317 | xhci_dbg(xhci, "Creating zero length td.\n"); | ||
3318 | ret = prepare_transfer(xhci, xhci->devs[slot_id], | ||
3319 | ep_index, urb->stream_id, | ||
3320 | 1, urb, 1, mem_flags); | ||
3321 | if (ret < 0) | ||
3322 | return ret; | ||
3323 | } | ||
3324 | |||
3325 | td = urb_priv->td[0]; | ||
3326 | |||
3327 | /* | ||
3328 | * Don't give the first TRB to the hardware (by toggling the cycle bit) | ||
3329 | * until we've finished creating all the other TRBs. The ring's cycle | ||
3330 | * state may change as we enqueue the other TRBs, so save it too. | ||
3331 | */ | ||
3332 | start_trb = &ep_ring->enqueue->generic; | ||
3333 | start_cycle = ep_ring->cycle_state; | ||
3334 | |||
3335 | running_total = 0; | ||
3336 | total_packet_count = DIV_ROUND_UP(urb->transfer_buffer_length, | ||
3337 | usb_endpoint_maxp(&urb->ep->desc)); | ||
3338 | /* How much data is in the first TRB? */ | ||
3339 | addr = (u64) urb->transfer_dma; | ||
3340 | trb_buff_len = TRB_MAX_BUFF_SIZE - | ||
3341 | (urb->transfer_dma & (TRB_MAX_BUFF_SIZE - 1)); | ||
3342 | if (trb_buff_len > urb->transfer_buffer_length) | ||
3343 | trb_buff_len = urb->transfer_buffer_length; | ||
3344 | |||
3345 | first_trb = true; | ||
3346 | last_trb_num = zero_length_needed ? 2 : 1; | ||
3347 | /* Queue the first TRB, even if it's zero-length */ | ||
3348 | do { | ||
3349 | u32 remainder = 0; | ||
3350 | field = 0; | ||
3351 | 3196 | ||
3352 | /* Don't change the cycle bit of the first TRB until later */ | 3197 | /* Don't change the cycle bit of the first TRB until later */ |
3353 | if (first_trb) { | 3198 | if (i == 0) { |
3354 | first_trb = false; | ||
3355 | if (start_cycle == 0) | 3199 | if (start_cycle == 0) |
3356 | field |= 0x1; | 3200 | field |= TRB_CYCLE; |
3357 | } else | 3201 | } else |
3358 | field |= ep_ring->cycle_state; | 3202 | field |= ep_ring->cycle_state; |
3359 | 3203 | ||
3360 | /* Chain all the TRBs together; clear the chain bit in the last | 3204 | /* Chain all the TRBs together; clear the chain bit in the last |
3361 | * TRB to indicate it's the last TRB in the chain. | 3205 | * TRB to indicate it's the last TRB in the chain. |
3362 | */ | 3206 | */ |
3363 | if (num_trbs > last_trb_num) { | 3207 | if (i < last_trb_num) { |
3364 | field |= TRB_CHAIN; | 3208 | field |= TRB_CHAIN; |
3365 | } else if (num_trbs == last_trb_num) { | 3209 | } else { |
3366 | td->last_trb = ep_ring->enqueue; | ||
3367 | field |= TRB_IOC; | ||
3368 | } else if (zero_length_needed && num_trbs == 1) { | ||
3369 | trb_buff_len = 0; | ||
3370 | urb_priv->td[1]->last_trb = ep_ring->enqueue; | ||
3371 | field |= TRB_IOC; | 3210 | field |= TRB_IOC; |
3211 | if (i == last_trb_num) | ||
3212 | td->last_trb = ep_ring->enqueue; | ||
3213 | else if (zero_length_needed) { | ||
3214 | trb_buff_len = 0; | ||
3215 | urb_priv->td[1]->last_trb = ep_ring->enqueue; | ||
3216 | } | ||
3372 | } | 3217 | } |
3373 | 3218 | ||
3374 | /* Only set interrupt on short packet for IN endpoints */ | 3219 | /* Only set interrupt on short packet for IN endpoints */ |
@@ -3376,15 +3221,15 @@ int xhci_queue_bulk_tx(struct xhci_hcd *xhci, gfp_t mem_flags, | |||
3376 | field |= TRB_ISP; | 3221 | field |= TRB_ISP; |
3377 | 3222 | ||
3378 | /* Set the TRB length, TD size, and interrupter fields. */ | 3223 | /* Set the TRB length, TD size, and interrupter fields. */ |
3379 | remainder = xhci_td_remainder(xhci, running_total, trb_buff_len, | 3224 | remainder = xhci_td_remainder(xhci, running_total, |
3380 | urb->transfer_buffer_length, | 3225 | trb_buff_len, full_len, |
3381 | urb, num_trbs - 1); | 3226 | urb, num_trbs - i - 1); |
3382 | 3227 | ||
3383 | length_field = TRB_LEN(trb_buff_len) | | 3228 | length_field = TRB_LEN(trb_buff_len) | |
3384 | TRB_TD_SIZE(remainder) | | 3229 | TRB_TD_SIZE(remainder) | |
3385 | TRB_INTR_TARGET(0); | 3230 | TRB_INTR_TARGET(0); |
3386 | 3231 | ||
3387 | if (num_trbs > 1) | 3232 | if (i < num_trbs - 1) |
3388 | more_trbs_coming = true; | 3233 | more_trbs_coming = true; |
3389 | else | 3234 | else |
3390 | more_trbs_coming = false; | 3235 | more_trbs_coming = false; |
@@ -3392,18 +3237,24 @@ int xhci_queue_bulk_tx(struct xhci_hcd *xhci, gfp_t mem_flags, | |||
3392 | lower_32_bits(addr), | 3237 | lower_32_bits(addr), |
3393 | upper_32_bits(addr), | 3238 | upper_32_bits(addr), |
3394 | length_field, | 3239 | length_field, |
3395 | field | TRB_TYPE(TRB_NORMAL)); | 3240 | field); |
3396 | --num_trbs; | ||
3397 | running_total += trb_buff_len; | ||
3398 | 3241 | ||
3399 | /* Calculate length for next transfer */ | 3242 | running_total += trb_buff_len; |
3400 | addr += trb_buff_len; | 3243 | addr += trb_buff_len; |
3401 | trb_buff_len = urb->transfer_buffer_length - running_total; | 3244 | block_len -= trb_buff_len; |
3402 | if (trb_buff_len > TRB_MAX_BUFF_SIZE) | 3245 | |
3403 | trb_buff_len = TRB_MAX_BUFF_SIZE; | 3246 | if (sg) { |
3404 | } while (num_trbs > 0); | 3247 | if (block_len == 0) { |
3248 | /* New sg entry */ | ||
3249 | --num_sgs; | ||
3250 | if (num_sgs == 0) | ||
3251 | break; | ||
3252 | sg = sg_next(sg); | ||
3253 | } | ||
3254 | } | ||
3255 | } | ||
3405 | 3256 | ||
3406 | check_trb_math(urb, num_trbs, running_total); | 3257 | check_trb_math(urb, running_total); |
3407 | giveback_first_trb(xhci, slot_id, ep_index, urb->stream_id, | 3258 | giveback_first_trb(xhci, slot_id, ep_index, urb->stream_id, |
3408 | start_cycle, start_trb); | 3259 | start_cycle, start_trb); |
3409 | return 0; | 3260 | return 0; |
@@ -3532,23 +3383,6 @@ int xhci_queue_ctrl_tx(struct xhci_hcd *xhci, gfp_t mem_flags, | |||
3532 | return 0; | 3383 | return 0; |
3533 | } | 3384 | } |
3534 | 3385 | ||
3535 | static int count_isoc_trbs_needed(struct xhci_hcd *xhci, | ||
3536 | struct urb *urb, int i) | ||
3537 | { | ||
3538 | int num_trbs = 0; | ||
3539 | u64 addr, td_len; | ||
3540 | |||
3541 | addr = (u64) (urb->transfer_dma + urb->iso_frame_desc[i].offset); | ||
3542 | td_len = urb->iso_frame_desc[i].length; | ||
3543 | |||
3544 | num_trbs = DIV_ROUND_UP(td_len + (addr & (TRB_MAX_BUFF_SIZE - 1)), | ||
3545 | TRB_MAX_BUFF_SIZE); | ||
3546 | if (num_trbs == 0) | ||
3547 | num_trbs++; | ||
3548 | |||
3549 | return num_trbs; | ||
3550 | } | ||
3551 | |||
3552 | /* | 3386 | /* |
3553 | * The transfer burst count field of the isochronous TRB defines the number of | 3387 | * The transfer burst count field of the isochronous TRB defines the number of |
3554 | * bursts that are required to move all packets in this TD. Only SuperSpeed | 3388 | * bursts that are required to move all packets in this TD. Only SuperSpeed |
@@ -3746,7 +3580,7 @@ static int xhci_queue_isoc_tx(struct xhci_hcd *xhci, gfp_t mem_flags, | |||
3746 | last_burst_pkt_count = xhci_get_last_burst_packet_count(xhci, | 3580 | last_burst_pkt_count = xhci_get_last_burst_packet_count(xhci, |
3747 | urb, total_pkt_count); | 3581 | urb, total_pkt_count); |
3748 | 3582 | ||
3749 | trbs_per_td = count_isoc_trbs_needed(xhci, urb, i); | 3583 | trbs_per_td = count_isoc_trbs_needed(urb, i); |
3750 | 3584 | ||
3751 | ret = prepare_transfer(xhci, xhci->devs[slot_id], ep_index, | 3585 | ret = prepare_transfer(xhci, xhci->devs[slot_id], ep_index, |
3752 | urb->stream_id, trbs_per_td, urb, i, mem_flags); | 3586 | urb->stream_id, trbs_per_td, urb, i, mem_flags); |
@@ -3807,8 +3641,7 @@ static int xhci_queue_isoc_tx(struct xhci_hcd *xhci, gfp_t mem_flags, | |||
3807 | field |= TRB_BEI; | 3641 | field |= TRB_BEI; |
3808 | } | 3642 | } |
3809 | /* Calculate TRB length */ | 3643 | /* Calculate TRB length */ |
3810 | trb_buff_len = TRB_MAX_BUFF_SIZE - | 3644 | trb_buff_len = TRB_BUFF_LEN_UP_TO_BOUNDARY(addr); |
3811 | (addr & ((1 << TRB_MAX_BUFF_SHIFT) - 1)); | ||
3812 | if (trb_buff_len > td_remain_len) | 3645 | if (trb_buff_len > td_remain_len) |
3813 | trb_buff_len = td_remain_len; | 3646 | trb_buff_len = td_remain_len; |
3814 | 3647 | ||
@@ -3897,8 +3730,6 @@ int xhci_queue_isoc_tx_prepare(struct xhci_hcd *xhci, gfp_t mem_flags, | |||
3897 | struct xhci_ring *ep_ring; | 3730 | struct xhci_ring *ep_ring; |
3898 | struct xhci_ep_ctx *ep_ctx; | 3731 | struct xhci_ep_ctx *ep_ctx; |
3899 | int start_frame; | 3732 | int start_frame; |
3900 | int xhci_interval; | ||
3901 | int ep_interval; | ||
3902 | int num_tds, num_trbs, i; | 3733 | int num_tds, num_trbs, i; |
3903 | int ret; | 3734 | int ret; |
3904 | struct xhci_virt_ep *xep; | 3735 | struct xhci_virt_ep *xep; |
@@ -3912,7 +3743,7 @@ int xhci_queue_isoc_tx_prepare(struct xhci_hcd *xhci, gfp_t mem_flags, | |||
3912 | num_trbs = 0; | 3743 | num_trbs = 0; |
3913 | num_tds = urb->number_of_packets; | 3744 | num_tds = urb->number_of_packets; |
3914 | for (i = 0; i < num_tds; i++) | 3745 | for (i = 0; i < num_tds; i++) |
3915 | num_trbs += count_isoc_trbs_needed(xhci, urb, i); | 3746 | num_trbs += count_isoc_trbs_needed(urb, i); |
3916 | 3747 | ||
3917 | /* Check the ring to guarantee there is enough room for the whole urb. | 3748 | /* Check the ring to guarantee there is enough room for the whole urb. |
3918 | * Do not insert any td of the urb to the ring if the check failed. | 3749 | * Do not insert any td of the urb to the ring if the check failed. |
@@ -3926,26 +3757,7 @@ int xhci_queue_isoc_tx_prepare(struct xhci_hcd *xhci, gfp_t mem_flags, | |||
3926 | * Check interval value. This should be done before we start to | 3757 | * Check interval value. This should be done before we start to |
3927 | * calculate the start frame value. | 3758 | * calculate the start frame value. |
3928 | */ | 3759 | */ |
3929 | xhci_interval = EP_INTERVAL_TO_UFRAMES(le32_to_cpu(ep_ctx->ep_info)); | 3760 | check_interval(xhci, urb, ep_ctx); |
3930 | ep_interval = urb->interval; | ||
3931 | /* Convert to microframes */ | ||
3932 | if (urb->dev->speed == USB_SPEED_LOW || | ||
3933 | urb->dev->speed == USB_SPEED_FULL) | ||
3934 | ep_interval *= 8; | ||
3935 | /* FIXME change this to a warning and a suggestion to use the new API | ||
3936 | * to set the polling interval (once the API is added). | ||
3937 | */ | ||
3938 | if (xhci_interval != ep_interval) { | ||
3939 | dev_dbg_ratelimited(&urb->dev->dev, | ||
3940 | "Driver uses different interval (%d microframe%s) than xHCI (%d microframe%s)\n", | ||
3941 | ep_interval, ep_interval == 1 ? "" : "s", | ||
3942 | xhci_interval, xhci_interval == 1 ? "" : "s"); | ||
3943 | urb->interval = xhci_interval; | ||
3944 | /* Convert back to frames for LS/FS devices */ | ||
3945 | if (urb->dev->speed == USB_SPEED_LOW || | ||
3946 | urb->dev->speed == USB_SPEED_FULL) | ||
3947 | urb->interval /= 8; | ||
3948 | } | ||
3949 | 3761 | ||
3950 | /* Calculate the start frame and put it in urb->start_frame. */ | 3762 | /* Calculate the start frame and put it in urb->start_frame. */ |
3951 | if (HCC_CFC(xhci->hcc_params) && !list_empty(&ep_ring->td_list)) { | 3763 | if (HCC_CFC(xhci->hcc_params) && !list_empty(&ep_ring->td_list)) { |
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 9e71c96ad74a..fa7e1ef36cd9 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c | |||
@@ -1459,47 +1459,6 @@ free_priv: | |||
1459 | return ret; | 1459 | return ret; |
1460 | } | 1460 | } |
1461 | 1461 | ||
1462 | /* Get the right ring for the given URB. | ||
1463 | * If the endpoint supports streams, boundary check the URB's stream ID. | ||
1464 | * If the endpoint doesn't support streams, return the singular endpoint ring. | ||
1465 | */ | ||
1466 | static struct xhci_ring *xhci_urb_to_transfer_ring(struct xhci_hcd *xhci, | ||
1467 | struct urb *urb) | ||
1468 | { | ||
1469 | unsigned int slot_id; | ||
1470 | unsigned int ep_index; | ||
1471 | unsigned int stream_id; | ||
1472 | struct xhci_virt_ep *ep; | ||
1473 | |||
1474 | slot_id = urb->dev->slot_id; | ||
1475 | ep_index = xhci_get_endpoint_index(&urb->ep->desc); | ||
1476 | stream_id = urb->stream_id; | ||
1477 | ep = &xhci->devs[slot_id]->eps[ep_index]; | ||
1478 | /* Common case: no streams */ | ||
1479 | if (!(ep->ep_state & EP_HAS_STREAMS)) | ||
1480 | return ep->ring; | ||
1481 | |||
1482 | if (stream_id == 0) { | ||
1483 | xhci_warn(xhci, | ||
1484 | "WARN: Slot ID %u, ep index %u has streams, " | ||
1485 | "but URB has no stream ID.\n", | ||
1486 | slot_id, ep_index); | ||
1487 | return NULL; | ||
1488 | } | ||
1489 | |||
1490 | if (stream_id < ep->stream_info->num_streams) | ||
1491 | return ep->stream_info->stream_rings[stream_id]; | ||
1492 | |||
1493 | xhci_warn(xhci, | ||
1494 | "WARN: Slot ID %u, ep index %u has " | ||
1495 | "stream IDs 1 to %u allocated, " | ||
1496 | "but stream ID %u is requested.\n", | ||
1497 | slot_id, ep_index, | ||
1498 | ep->stream_info->num_streams - 1, | ||
1499 | stream_id); | ||
1500 | return NULL; | ||
1501 | } | ||
1502 | |||
1503 | /* | 1462 | /* |
1504 | * Remove the URB's TD from the endpoint ring. This may cause the HC to stop | 1463 | * Remove the URB's TD from the endpoint ring. This may cause the HC to stop |
1505 | * USB transfers, potentially stopping in the middle of a TRB buffer. The HC | 1464 | * USB transfers, potentially stopping in the middle of a TRB buffer. The HC |
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index 6c629c97f8ad..b0b8d0f8791a 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h | |||
@@ -1338,6 +1338,9 @@ union xhci_trb { | |||
1338 | /* TRB buffer pointers can't cross 64KB boundaries */ | 1338 | /* TRB buffer pointers can't cross 64KB boundaries */ |
1339 | #define TRB_MAX_BUFF_SHIFT 16 | 1339 | #define TRB_MAX_BUFF_SHIFT 16 |
1340 | #define TRB_MAX_BUFF_SIZE (1 << TRB_MAX_BUFF_SHIFT) | 1340 | #define TRB_MAX_BUFF_SIZE (1 << TRB_MAX_BUFF_SHIFT) |
1341 | /* How much data is left before the 64KB boundary? */ | ||
1342 | #define TRB_BUFF_LEN_UP_TO_BOUNDARY(addr) (TRB_MAX_BUFF_SIZE - \ | ||
1343 | (addr & (TRB_MAX_BUFF_SIZE - 1))) | ||
1341 | 1344 | ||
1342 | struct xhci_segment { | 1345 | struct xhci_segment { |
1343 | union xhci_trb *trbs; | 1346 | union xhci_trb *trbs; |
@@ -1965,4 +1968,15 @@ struct xhci_input_control_ctx *xhci_get_input_control_ctx(struct xhci_container_ | |||
1965 | struct xhci_slot_ctx *xhci_get_slot_ctx(struct xhci_hcd *xhci, struct xhci_container_ctx *ctx); | 1968 | struct xhci_slot_ctx *xhci_get_slot_ctx(struct xhci_hcd *xhci, struct xhci_container_ctx *ctx); |
1966 | struct xhci_ep_ctx *xhci_get_ep_ctx(struct xhci_hcd *xhci, struct xhci_container_ctx *ctx, unsigned int ep_index); | 1969 | struct xhci_ep_ctx *xhci_get_ep_ctx(struct xhci_hcd *xhci, struct xhci_container_ctx *ctx, unsigned int ep_index); |
1967 | 1970 | ||
1971 | struct xhci_ring *xhci_triad_to_transfer_ring(struct xhci_hcd *xhci, | ||
1972 | unsigned int slot_id, unsigned int ep_index, | ||
1973 | unsigned int stream_id); | ||
1974 | static inline struct xhci_ring *xhci_urb_to_transfer_ring(struct xhci_hcd *xhci, | ||
1975 | struct urb *urb) | ||
1976 | { | ||
1977 | return xhci_triad_to_transfer_ring(xhci, urb->dev->slot_id, | ||
1978 | xhci_get_endpoint_index(&urb->ep->desc), | ||
1979 | urb->stream_id); | ||
1980 | } | ||
1981 | |||
1968 | #endif /* __LINUX_XHCI_HCD_H */ | 1982 | #endif /* __LINUX_XHCI_HCD_H */ |
diff --git a/drivers/usb/isp1760/isp1760-if.c b/drivers/usb/isp1760/isp1760-if.c index 264be4d21706..9535b2872183 100644 --- a/drivers/usb/isp1760/isp1760-if.c +++ b/drivers/usb/isp1760/isp1760-if.c | |||
@@ -163,7 +163,7 @@ static void isp1761_pci_shutdown(struct pci_dev *dev) | |||
163 | printk(KERN_ERR "ips1761_pci_shutdown\n"); | 163 | printk(KERN_ERR "ips1761_pci_shutdown\n"); |
164 | } | 164 | } |
165 | 165 | ||
166 | static const struct pci_device_id isp1760_plx [] = { | 166 | static const struct pci_device_id isp1760_plx[] = { |
167 | { | 167 | { |
168 | .class = PCI_CLASS_BRIDGE_OTHER << 8, | 168 | .class = PCI_CLASS_BRIDGE_OTHER << 8, |
169 | .class_mask = ~0, | 169 | .class_mask = ~0, |
diff --git a/drivers/usb/misc/Kconfig b/drivers/usb/misc/Kconfig index f7a7fc21be8a..e9e5ae521fa6 100644 --- a/drivers/usb/misc/Kconfig +++ b/drivers/usb/misc/Kconfig | |||
@@ -268,3 +268,29 @@ config USB_CHAOSKEY | |||
268 | 268 | ||
269 | To compile this driver as a module, choose M here: the | 269 | To compile this driver as a module, choose M here: the |
270 | module will be called chaoskey. | 270 | module will be called chaoskey. |
271 | |||
272 | config UCSI | ||
273 | tristate "USB Type-C Connector System Software Interface driver" | ||
274 | depends on ACPI | ||
275 | help | ||
276 | UCSI driver is meant to be used as a convenience tool for desktop and | ||
277 | server systems that are not equipped to handle USB in device mode. It | ||
278 | will always select USB host role for the USB Type-C ports on systems | ||
279 | that provide UCSI interface. | ||
280 | |||
281 | USB Type-C Connector System Software Interface (UCSI) is a | ||
282 | specification for an interface that allows the Operating System to | ||
283 | control the USB Type-C ports on a system. Things the need controlling | ||
284 | include the USB Data Role (host or device), and when USB Power | ||
285 | Delivery is supported, the Power Role (source or sink). With USB | ||
286 | Type-C connectors, when two dual role capable devices are attached | ||
287 | together, the data role is selected randomly. Therefore it is | ||
288 | important to give the OS a way to select the role. Otherwise the user | ||
289 | would have to unplug and replug in order in order to attempt to swap | ||
290 | the data and power roles. | ||
291 | |||
292 | The UCSI specification can be downloaded from: | ||
293 | http://www.intel.com/content/www/us/en/io/universal-serial-bus/usb-type-c-ucsi-spec.html | ||
294 | |||
295 | To compile the driver as a module, choose M here: the module will be | ||
296 | called ucsi. | ||
diff --git a/drivers/usb/misc/Makefile b/drivers/usb/misc/Makefile index 45fd4ac39d3e..2769cf6351b4 100644 --- a/drivers/usb/misc/Makefile +++ b/drivers/usb/misc/Makefile | |||
@@ -26,6 +26,7 @@ obj-$(CONFIG_USB_SEVSEG) += usbsevseg.o | |||
26 | obj-$(CONFIG_USB_YUREX) += yurex.o | 26 | obj-$(CONFIG_USB_YUREX) += yurex.o |
27 | obj-$(CONFIG_USB_HSIC_USB3503) += usb3503.o | 27 | obj-$(CONFIG_USB_HSIC_USB3503) += usb3503.o |
28 | obj-$(CONFIG_USB_CHAOSKEY) += chaoskey.o | 28 | obj-$(CONFIG_USB_CHAOSKEY) += chaoskey.o |
29 | obj-$(CONFIG_UCSI) += ucsi.o | ||
29 | 30 | ||
30 | obj-$(CONFIG_USB_SISUSBVGA) += sisusbvga/ | 31 | obj-$(CONFIG_USB_SISUSBVGA) += sisusbvga/ |
31 | obj-$(CONFIG_USB_LINK_LAYER_TEST) += lvstest.o | 32 | obj-$(CONFIG_USB_LINK_LAYER_TEST) += lvstest.o |
diff --git a/drivers/usb/misc/sisusbvga/sisusb.c b/drivers/usb/misc/sisusbvga/sisusb.c index a22de52cb083..15666ad7c772 100644 --- a/drivers/usb/misc/sisusbvga/sisusb.c +++ b/drivers/usb/misc/sisusbvga/sisusb.c | |||
@@ -2420,7 +2420,7 @@ static int sisusb_open(struct inode *inode, struct file *file) | |||
2420 | 2420 | ||
2421 | if (!sisusb->devinit) { | 2421 | if (!sisusb->devinit) { |
2422 | if (sisusb->sisusb_dev->speed == USB_SPEED_HIGH || | 2422 | if (sisusb->sisusb_dev->speed == USB_SPEED_HIGH || |
2423 | sisusb->sisusb_dev->speed == USB_SPEED_SUPER) { | 2423 | sisusb->sisusb_dev->speed >= USB_SPEED_SUPER) { |
2424 | if (sisusb_init_gfxdevice(sisusb, 0)) { | 2424 | if (sisusb_init_gfxdevice(sisusb, 0)) { |
2425 | mutex_unlock(&sisusb->lock); | 2425 | mutex_unlock(&sisusb->lock); |
2426 | dev_err(&sisusb->sisusb_dev->dev, | 2426 | dev_err(&sisusb->sisusb_dev->dev, |
@@ -3127,7 +3127,7 @@ static int sisusb_probe(struct usb_interface *intf, | |||
3127 | 3127 | ||
3128 | sisusb->present = 1; | 3128 | sisusb->present = 1; |
3129 | 3129 | ||
3130 | if (dev->speed == USB_SPEED_HIGH || dev->speed == USB_SPEED_SUPER) { | 3130 | if (dev->speed == USB_SPEED_HIGH || dev->speed >= USB_SPEED_SUPER) { |
3131 | int initscreen = 1; | 3131 | int initscreen = 1; |
3132 | #ifdef INCL_SISUSB_CON | 3132 | #ifdef INCL_SISUSB_CON |
3133 | if (sisusb_first_vc > 0 && sisusb_last_vc > 0 && | 3133 | if (sisusb_first_vc > 0 && sisusb_last_vc > 0 && |
diff --git a/drivers/usb/misc/ucsi.c b/drivers/usb/misc/ucsi.c new file mode 100644 index 000000000000..07397bddefa3 --- /dev/null +++ b/drivers/usb/misc/ucsi.c | |||
@@ -0,0 +1,478 @@ | |||
1 | /* | ||
2 | * USB Type-C Connector System Software Interface driver | ||
3 | * | ||
4 | * Copyright (C) 2016, Intel Corporation | ||
5 | * Author: Heikki Krogerus <heikki.krogerus@linux.intel.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 as | ||
9 | * published by the Free Software Foundation. | ||
10 | */ | ||
11 | |||
12 | #include <linux/platform_device.h> | ||
13 | #include <linux/module.h> | ||
14 | #include <linux/delay.h> | ||
15 | #include <linux/acpi.h> | ||
16 | |||
17 | #include "ucsi.h" | ||
18 | |||
19 | /* Double the time defined by MIN_TIME_TO_RESPOND_WITH_BUSY */ | ||
20 | #define UCSI_TIMEOUT_MS 20 | ||
21 | |||
22 | enum ucsi_status { | ||
23 | UCSI_IDLE = 0, | ||
24 | UCSI_BUSY, | ||
25 | UCSI_ERROR, | ||
26 | }; | ||
27 | |||
28 | struct ucsi_connector { | ||
29 | int num; | ||
30 | struct ucsi *ucsi; | ||
31 | struct work_struct work; | ||
32 | struct ucsi_connector_capability cap; | ||
33 | }; | ||
34 | |||
35 | struct ucsi { | ||
36 | struct device *dev; | ||
37 | struct ucsi_data __iomem *data; | ||
38 | |||
39 | enum ucsi_status status; | ||
40 | struct completion complete; | ||
41 | struct ucsi_capability cap; | ||
42 | struct ucsi_connector *connector; | ||
43 | |||
44 | /* device lock */ | ||
45 | spinlock_t dev_lock; | ||
46 | |||
47 | /* PPM Communication lock */ | ||
48 | struct mutex ppm_lock; | ||
49 | |||
50 | /* PPM communication flags */ | ||
51 | unsigned long flags; | ||
52 | #define EVENT_PENDING 0 | ||
53 | #define COMMAND_PENDING 1 | ||
54 | }; | ||
55 | |||
56 | static int ucsi_acpi_cmd(struct ucsi *ucsi, struct ucsi_control *ctrl) | ||
57 | { | ||
58 | uuid_le uuid = UUID_LE(0x6f8398c2, 0x7ca4, 0x11e4, | ||
59 | 0xad, 0x36, 0x63, 0x10, 0x42, 0xb5, 0x00, 0x8f); | ||
60 | union acpi_object *obj; | ||
61 | |||
62 | ucsi->data->ctrl.raw_cmd = ctrl->raw_cmd; | ||
63 | |||
64 | obj = acpi_evaluate_dsm(ACPI_HANDLE(ucsi->dev), uuid.b, 1, 1, NULL); | ||
65 | if (!obj) { | ||
66 | dev_err(ucsi->dev, "%s: failed to evaluate _DSM\n", __func__); | ||
67 | return -EIO; | ||
68 | } | ||
69 | |||
70 | ACPI_FREE(obj); | ||
71 | return 0; | ||
72 | } | ||
73 | |||
74 | static void ucsi_acpi_notify(acpi_handle handle, u32 event, void *data) | ||
75 | { | ||
76 | struct ucsi *ucsi = data; | ||
77 | struct ucsi_cci *cci; | ||
78 | |||
79 | spin_lock(&ucsi->dev_lock); | ||
80 | |||
81 | ucsi->status = UCSI_IDLE; | ||
82 | cci = &ucsi->data->cci; | ||
83 | |||
84 | /* | ||
85 | * REVISIT: This is not documented behavior, but all known PPMs ACK | ||
86 | * asynchronous events by sending notification with cleared CCI. | ||
87 | */ | ||
88 | if (!ucsi->data->raw_cci) { | ||
89 | if (test_bit(EVENT_PENDING, &ucsi->flags)) | ||
90 | complete(&ucsi->complete); | ||
91 | else | ||
92 | dev_WARN(ucsi->dev, "spurious notification\n"); | ||
93 | goto out_unlock; | ||
94 | } | ||
95 | |||
96 | if (test_bit(COMMAND_PENDING, &ucsi->flags)) { | ||
97 | if (cci->busy) { | ||
98 | ucsi->status = UCSI_BUSY; | ||
99 | complete(&ucsi->complete); | ||
100 | |||
101 | goto out_unlock; | ||
102 | } else if (cci->ack_complete || cci->cmd_complete) { | ||
103 | /* Error Indication is only valid with commands */ | ||
104 | if (cci->error && cci->cmd_complete) | ||
105 | ucsi->status = UCSI_ERROR; | ||
106 | |||
107 | ucsi->data->ctrl.raw_cmd = 0; | ||
108 | complete(&ucsi->complete); | ||
109 | } | ||
110 | } | ||
111 | |||
112 | if (cci->connector_change) { | ||
113 | struct ucsi_connector *con; | ||
114 | |||
115 | /* | ||
116 | * This is workaround for buggy PPMs that create asynchronous | ||
117 | * event notifications before OPM has enabled them. | ||
118 | */ | ||
119 | if (!ucsi->connector) | ||
120 | goto out_unlock; | ||
121 | |||
122 | con = ucsi->connector + (cci->connector_change - 1); | ||
123 | |||
124 | /* | ||
125 | * PPM will not clear the connector specific bit in Connector | ||
126 | * Change Indication field of CCI until the driver has ACK it, | ||
127 | * and the driver can not ACK it before it has been processed. | ||
128 | * The PPM will not generate new events before the first has | ||
129 | * been acknowledged, even if they are for an other connector. | ||
130 | * So only one event at a time. | ||
131 | */ | ||
132 | if (!test_and_set_bit(EVENT_PENDING, &ucsi->flags)) | ||
133 | schedule_work(&con->work); | ||
134 | } | ||
135 | out_unlock: | ||
136 | spin_unlock(&ucsi->dev_lock); | ||
137 | } | ||
138 | |||
139 | static int ucsi_ack(struct ucsi *ucsi, u8 cmd) | ||
140 | { | ||
141 | struct ucsi_control ctrl; | ||
142 | int ret; | ||
143 | |||
144 | ctrl.cmd.cmd = UCSI_ACK_CC_CI; | ||
145 | ctrl.cmd.length = 0; | ||
146 | ctrl.cmd.data = cmd; | ||
147 | ret = ucsi_acpi_cmd(ucsi, &ctrl); | ||
148 | if (ret) | ||
149 | return ret; | ||
150 | |||
151 | /* Waiting for ACK also with ACK CMD for now */ | ||
152 | ret = wait_for_completion_timeout(&ucsi->complete, | ||
153 | msecs_to_jiffies(UCSI_TIMEOUT_MS)); | ||
154 | if (!ret) | ||
155 | return -ETIMEDOUT; | ||
156 | return 0; | ||
157 | } | ||
158 | |||
159 | static int ucsi_run_cmd(struct ucsi *ucsi, struct ucsi_control *ctrl, | ||
160 | void *data, size_t size) | ||
161 | { | ||
162 | u16 err_value = 0; | ||
163 | int ret; | ||
164 | |||
165 | set_bit(COMMAND_PENDING, &ucsi->flags); | ||
166 | |||
167 | ret = ucsi_acpi_cmd(ucsi, ctrl); | ||
168 | if (ret) | ||
169 | goto err_clear_flag; | ||
170 | |||
171 | ret = wait_for_completion_timeout(&ucsi->complete, | ||
172 | msecs_to_jiffies(UCSI_TIMEOUT_MS)); | ||
173 | if (!ret) { | ||
174 | ret = -ETIMEDOUT; | ||
175 | goto err_clear_flag; | ||
176 | } | ||
177 | |||
178 | switch (ucsi->status) { | ||
179 | case UCSI_IDLE: | ||
180 | if (data) | ||
181 | memcpy(data, ucsi->data->message_in, size); | ||
182 | |||
183 | ret = ucsi_ack(ucsi, UCSI_ACK_CMD); | ||
184 | break; | ||
185 | case UCSI_BUSY: | ||
186 | /* The caller decides whether to cancel or not */ | ||
187 | ret = -EBUSY; | ||
188 | goto err_clear_flag; | ||
189 | case UCSI_ERROR: | ||
190 | ret = ucsi_ack(ucsi, UCSI_ACK_CMD); | ||
191 | if (ret) | ||
192 | goto err_clear_flag; | ||
193 | |||
194 | ctrl->cmd.cmd = UCSI_GET_ERROR_STATUS; | ||
195 | ctrl->cmd.length = 0; | ||
196 | ctrl->cmd.data = 0; | ||
197 | ret = ucsi_acpi_cmd(ucsi, ctrl); | ||
198 | if (ret) | ||
199 | goto err_clear_flag; | ||
200 | |||
201 | ret = wait_for_completion_timeout(&ucsi->complete, | ||
202 | msecs_to_jiffies(UCSI_TIMEOUT_MS)); | ||
203 | if (!ret) { | ||
204 | ret = -ETIMEDOUT; | ||
205 | goto err_clear_flag; | ||
206 | } | ||
207 | |||
208 | memcpy(&err_value, ucsi->data->message_in, sizeof(err_value)); | ||
209 | |||
210 | /* Something has really gone wrong */ | ||
211 | if (WARN_ON(ucsi->status == UCSI_ERROR)) { | ||
212 | ret = -ENODEV; | ||
213 | goto err_clear_flag; | ||
214 | } | ||
215 | |||
216 | ret = ucsi_ack(ucsi, UCSI_ACK_CMD); | ||
217 | if (ret) | ||
218 | goto err_clear_flag; | ||
219 | |||
220 | switch (err_value) { | ||
221 | case UCSI_ERROR_INCOMPATIBLE_PARTNER: | ||
222 | ret = -EOPNOTSUPP; | ||
223 | break; | ||
224 | case UCSI_ERROR_CC_COMMUNICATION_ERR: | ||
225 | ret = -ECOMM; | ||
226 | break; | ||
227 | case UCSI_ERROR_CONTRACT_NEGOTIATION_FAIL: | ||
228 | ret = -EIO; | ||
229 | break; | ||
230 | case UCSI_ERROR_DEAD_BATTERY: | ||
231 | dev_warn(ucsi->dev, "Dead battery condition!\n"); | ||
232 | ret = -EPERM; | ||
233 | break; | ||
234 | /* The following mean a bug in this driver */ | ||
235 | case UCSI_ERROR_INVALID_CON_NUM: | ||
236 | case UCSI_ERROR_UNREGONIZED_CMD: | ||
237 | case UCSI_ERROR_INVALID_CMD_ARGUMENT: | ||
238 | default: | ||
239 | dev_warn(ucsi->dev, | ||
240 | "%s: possible UCSI driver bug - error %hu\n", | ||
241 | __func__, err_value); | ||
242 | ret = -EINVAL; | ||
243 | break; | ||
244 | } | ||
245 | break; | ||
246 | } | ||
247 | ctrl->raw_cmd = 0; | ||
248 | err_clear_flag: | ||
249 | clear_bit(COMMAND_PENDING, &ucsi->flags); | ||
250 | return ret; | ||
251 | } | ||
252 | |||
253 | static void ucsi_connector_change(struct work_struct *work) | ||
254 | { | ||
255 | struct ucsi_connector *con = container_of(work, struct ucsi_connector, | ||
256 | work); | ||
257 | struct ucsi_connector_status constat; | ||
258 | struct ucsi *ucsi = con->ucsi; | ||
259 | struct ucsi_control ctrl; | ||
260 | int ret; | ||
261 | |||
262 | mutex_lock(&ucsi->ppm_lock); | ||
263 | |||
264 | ctrl.cmd.cmd = UCSI_GET_CONNECTOR_STATUS; | ||
265 | ctrl.cmd.length = 0; | ||
266 | ctrl.cmd.data = con->num; | ||
267 | ret = ucsi_run_cmd(con->ucsi, &ctrl, &constat, sizeof(constat)); | ||
268 | if (ret) { | ||
269 | dev_err(ucsi->dev, "%s: failed to read connector status (%d)\n", | ||
270 | __func__, ret); | ||
271 | goto out_ack_event; | ||
272 | } | ||
273 | |||
274 | /* Ignoring disconnections and Alternate Modes */ | ||
275 | if (!constat.connected || !(constat.change & | ||
276 | (UCSI_CONSTAT_PARTNER_CHANGE | UCSI_CONSTAT_CONNECT_CHANGE)) || | ||
277 | constat.partner_flags & UCSI_CONSTAT_PARTNER_FLAG_ALT_MODE) | ||
278 | goto out_ack_event; | ||
279 | |||
280 | /* If the partner got USB Host role, attempting swap */ | ||
281 | if (constat.partner_type & UCSI_CONSTAT_PARTNER_TYPE_DFP) { | ||
282 | ctrl.uor.cmd = UCSI_SET_UOR; | ||
283 | ctrl.uor.con_num = con->num; | ||
284 | ctrl.uor.role = UCSI_UOR_ROLE_DFP; | ||
285 | |||
286 | ret = ucsi_run_cmd(con->ucsi, &ctrl, NULL, 0); | ||
287 | if (ret) | ||
288 | dev_err(ucsi->dev, "%s: failed to swap role (%d)\n", | ||
289 | __func__, ret); | ||
290 | } | ||
291 | out_ack_event: | ||
292 | ucsi_ack(ucsi, UCSI_ACK_EVENT); | ||
293 | clear_bit(EVENT_PENDING, &ucsi->flags); | ||
294 | mutex_unlock(&ucsi->ppm_lock); | ||
295 | } | ||
296 | |||
297 | static int ucsi_reset_ppm(struct ucsi *ucsi) | ||
298 | { | ||
299 | int timeout = UCSI_TIMEOUT_MS; | ||
300 | struct ucsi_control ctrl; | ||
301 | int ret; | ||
302 | |||
303 | memset(&ctrl, 0, sizeof(ctrl)); | ||
304 | ctrl.cmd.cmd = UCSI_PPM_RESET; | ||
305 | ret = ucsi_acpi_cmd(ucsi, &ctrl); | ||
306 | if (ret) | ||
307 | return ret; | ||
308 | |||
309 | /* There is no quarantee the PPM will ever set the RESET_COMPLETE bit */ | ||
310 | while (!ucsi->data->cci.reset_complete && timeout--) | ||
311 | usleep_range(1000, 2000); | ||
312 | return 0; | ||
313 | } | ||
314 | |||
315 | static int ucsi_init(struct ucsi *ucsi) | ||
316 | { | ||
317 | struct ucsi_connector *con; | ||
318 | struct ucsi_control ctrl; | ||
319 | int ret; | ||
320 | int i; | ||
321 | |||
322 | init_completion(&ucsi->complete); | ||
323 | spin_lock_init(&ucsi->dev_lock); | ||
324 | mutex_init(&ucsi->ppm_lock); | ||
325 | |||
326 | /* Reset the PPM */ | ||
327 | ret = ucsi_reset_ppm(ucsi); | ||
328 | if (ret) | ||
329 | return ret; | ||
330 | |||
331 | /* | ||
332 | * REVISIT: Executing second reset to WA an issue seen on some of the | ||
333 | * Broxton based platforms, where the first reset puts the PPM into a | ||
334 | * state where it's unable to recognise some of the commands. | ||
335 | */ | ||
336 | ret = ucsi_reset_ppm(ucsi); | ||
337 | if (ret) | ||
338 | return ret; | ||
339 | |||
340 | mutex_lock(&ucsi->ppm_lock); | ||
341 | |||
342 | /* Enable basic notifications */ | ||
343 | ctrl.cmd.cmd = UCSI_SET_NOTIFICATION_ENABLE; | ||
344 | ctrl.cmd.length = 0; | ||
345 | ctrl.cmd.data = UCSI_ENABLE_NTFY_CMD_COMPLETE | UCSI_ENABLE_NTFY_ERROR; | ||
346 | ret = ucsi_run_cmd(ucsi, &ctrl, NULL, 0); | ||
347 | if (ret) | ||
348 | goto err_reset; | ||
349 | |||
350 | /* Get PPM capabilities */ | ||
351 | ctrl.cmd.cmd = UCSI_GET_CAPABILITY; | ||
352 | ret = ucsi_run_cmd(ucsi, &ctrl, &ucsi->cap, sizeof(ucsi->cap)); | ||
353 | if (ret) | ||
354 | goto err_reset; | ||
355 | |||
356 | if (!ucsi->cap.num_connectors) { | ||
357 | ret = -ENODEV; | ||
358 | goto err_reset; | ||
359 | } | ||
360 | |||
361 | ucsi->connector = devm_kcalloc(ucsi->dev, ucsi->cap.num_connectors, | ||
362 | sizeof(*ucsi->connector), GFP_KERNEL); | ||
363 | if (!ucsi->connector) { | ||
364 | ret = -ENOMEM; | ||
365 | goto err_reset; | ||
366 | } | ||
367 | |||
368 | for (i = 1, con = ucsi->connector; i < ucsi->cap.num_connectors + 1; | ||
369 | i++, con++) { | ||
370 | /* Get connector capability */ | ||
371 | ctrl.cmd.cmd = UCSI_GET_CONNECTOR_CAPABILITY; | ||
372 | ctrl.cmd.data = i; | ||
373 | ret = ucsi_run_cmd(ucsi, &ctrl, &con->cap, sizeof(con->cap)); | ||
374 | if (ret) | ||
375 | goto err_reset; | ||
376 | |||
377 | con->num = i; | ||
378 | con->ucsi = ucsi; | ||
379 | INIT_WORK(&con->work, ucsi_connector_change); | ||
380 | } | ||
381 | |||
382 | /* Enable all notifications */ | ||
383 | ctrl.cmd.cmd = UCSI_SET_NOTIFICATION_ENABLE; | ||
384 | ctrl.cmd.data = UCSI_ENABLE_NTFY_ALL; | ||
385 | ret = ucsi_run_cmd(ucsi, &ctrl, NULL, 0); | ||
386 | if (ret < 0) | ||
387 | goto err_reset; | ||
388 | |||
389 | mutex_unlock(&ucsi->ppm_lock); | ||
390 | return 0; | ||
391 | err_reset: | ||
392 | ucsi_reset_ppm(ucsi); | ||
393 | mutex_unlock(&ucsi->ppm_lock); | ||
394 | return ret; | ||
395 | } | ||
396 | |||
397 | static int ucsi_acpi_probe(struct platform_device *pdev) | ||
398 | { | ||
399 | struct resource *res; | ||
400 | acpi_status status; | ||
401 | struct ucsi *ucsi; | ||
402 | int ret; | ||
403 | |||
404 | ucsi = devm_kzalloc(&pdev->dev, sizeof(*ucsi), GFP_KERNEL); | ||
405 | if (!ucsi) | ||
406 | return -ENOMEM; | ||
407 | |||
408 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
409 | if (!res) { | ||
410 | dev_err(&pdev->dev, "missing memory resource\n"); | ||
411 | return -ENODEV; | ||
412 | } | ||
413 | |||
414 | /* | ||
415 | * NOTE: ACPI has claimed the memory region as it's also an Operation | ||
416 | * Region. It's not possible to request it in the driver. | ||
417 | */ | ||
418 | ucsi->data = devm_ioremap(&pdev->dev, res->start, resource_size(res)); | ||
419 | if (!ucsi->data) | ||
420 | return -ENOMEM; | ||
421 | |||
422 | ucsi->dev = &pdev->dev; | ||
423 | |||
424 | status = acpi_install_notify_handler(ACPI_HANDLE(&pdev->dev), | ||
425 | ACPI_ALL_NOTIFY, | ||
426 | ucsi_acpi_notify, ucsi); | ||
427 | if (ACPI_FAILURE(status)) | ||
428 | return -ENODEV; | ||
429 | |||
430 | ret = ucsi_init(ucsi); | ||
431 | if (ret) { | ||
432 | acpi_remove_notify_handler(ACPI_HANDLE(&pdev->dev), | ||
433 | ACPI_ALL_NOTIFY, | ||
434 | ucsi_acpi_notify); | ||
435 | return ret; | ||
436 | } | ||
437 | |||
438 | platform_set_drvdata(pdev, ucsi); | ||
439 | return 0; | ||
440 | } | ||
441 | |||
442 | static int ucsi_acpi_remove(struct platform_device *pdev) | ||
443 | { | ||
444 | struct ucsi *ucsi = platform_get_drvdata(pdev); | ||
445 | |||
446 | acpi_remove_notify_handler(ACPI_HANDLE(&pdev->dev), | ||
447 | ACPI_ALL_NOTIFY, ucsi_acpi_notify); | ||
448 | |||
449 | /* Make sure there are no events in the middle of being processed */ | ||
450 | if (wait_on_bit_timeout(&ucsi->flags, EVENT_PENDING, | ||
451 | TASK_UNINTERRUPTIBLE, | ||
452 | msecs_to_jiffies(UCSI_TIMEOUT_MS))) | ||
453 | dev_WARN(ucsi->dev, "%s: Events still pending\n", __func__); | ||
454 | |||
455 | ucsi_reset_ppm(ucsi); | ||
456 | return 0; | ||
457 | } | ||
458 | |||
459 | static const struct acpi_device_id ucsi_acpi_match[] = { | ||
460 | { "PNP0CA0", 0 }, | ||
461 | { }, | ||
462 | }; | ||
463 | MODULE_DEVICE_TABLE(acpi, ucsi_acpi_match); | ||
464 | |||
465 | static struct platform_driver ucsi_acpi_platform_driver = { | ||
466 | .driver = { | ||
467 | .name = "ucsi_acpi", | ||
468 | .acpi_match_table = ACPI_PTR(ucsi_acpi_match), | ||
469 | }, | ||
470 | .probe = ucsi_acpi_probe, | ||
471 | .remove = ucsi_acpi_remove, | ||
472 | }; | ||
473 | |||
474 | module_platform_driver(ucsi_acpi_platform_driver); | ||
475 | |||
476 | MODULE_AUTHOR("Heikki Krogerus <heikki.krogerus@linux.intel.com>"); | ||
477 | MODULE_LICENSE("GPL v2"); | ||
478 | MODULE_DESCRIPTION("USB Type-C System Software Interface (UCSI) driver"); | ||
diff --git a/drivers/usb/misc/ucsi.h b/drivers/usb/misc/ucsi.h new file mode 100644 index 000000000000..6dd11d1fe225 --- /dev/null +++ b/drivers/usb/misc/ucsi.h | |||
@@ -0,0 +1,215 @@ | |||
1 | |||
2 | #include <linux/types.h> | ||
3 | |||
4 | /* -------------------------------------------------------------------------- */ | ||
5 | |||
6 | /* Command Status and Connector Change Indication (CCI) data structure */ | ||
7 | struct ucsi_cci { | ||
8 | unsigned int RESERVED1:1; | ||
9 | unsigned int connector_change:7; | ||
10 | u8 data_length; | ||
11 | unsigned int RESERVED9:9; | ||
12 | unsigned int not_supported:1; | ||
13 | unsigned int cancel_complete:1; | ||
14 | unsigned int reset_complete:1; | ||
15 | unsigned int busy:1; | ||
16 | unsigned int ack_complete:1; | ||
17 | unsigned int error:1; | ||
18 | unsigned int cmd_complete:1; | ||
19 | } __packed; | ||
20 | |||
21 | /* Default fields in CONTROL data structure */ | ||
22 | struct ucsi_command { | ||
23 | u8 cmd; | ||
24 | u8 length; | ||
25 | u64 data:48; | ||
26 | } __packed; | ||
27 | |||
28 | /* Set USB Operation Mode Command structure */ | ||
29 | struct ucsi_uor_cmd { | ||
30 | u8 cmd; | ||
31 | u8 length; | ||
32 | u64 con_num:7; | ||
33 | u64 role:3; | ||
34 | #define UCSI_UOR_ROLE_DFP BIT(0) | ||
35 | #define UCSI_UOR_ROLE_UFP BIT(1) | ||
36 | #define UCSI_UOR_ROLE_DRP BIT(2) | ||
37 | u64 data:38; | ||
38 | } __packed; | ||
39 | |||
40 | struct ucsi_control { | ||
41 | union { | ||
42 | u64 raw_cmd; | ||
43 | struct ucsi_command cmd; | ||
44 | struct ucsi_uor_cmd uor; | ||
45 | }; | ||
46 | }; | ||
47 | |||
48 | struct ucsi_data { | ||
49 | u16 version; | ||
50 | u16 RESERVED; | ||
51 | union { | ||
52 | u32 raw_cci; | ||
53 | struct ucsi_cci cci; | ||
54 | }; | ||
55 | struct ucsi_control ctrl; | ||
56 | u32 message_in[4]; | ||
57 | u32 message_out[4]; | ||
58 | } __packed; | ||
59 | |||
60 | /* Commands */ | ||
61 | #define UCSI_PPM_RESET 0x01 | ||
62 | #define UCSI_CANCEL 0x02 | ||
63 | #define UCSI_CONNECTOR_RESET 0x03 | ||
64 | #define UCSI_ACK_CC_CI 0x04 | ||
65 | #define UCSI_SET_NOTIFICATION_ENABLE 0x05 | ||
66 | #define UCSI_GET_CAPABILITY 0x06 | ||
67 | #define UCSI_GET_CONNECTOR_CAPABILITY 0x07 | ||
68 | #define UCSI_SET_UOM 0x08 | ||
69 | #define UCSI_SET_UOR 0x09 | ||
70 | #define UCSI_SET_PDM 0x0A | ||
71 | #define UCSI_SET_PDR 0x0B | ||
72 | #define UCSI_GET_ALTERNATE_MODES 0x0C | ||
73 | #define UCSI_GET_CAM_SUPPORTED 0x0D | ||
74 | #define UCSI_GET_CURRENT_CAM 0x0E | ||
75 | #define UCSI_SET_NEW_CAM 0x0F | ||
76 | #define UCSI_GET_PDOS 0x10 | ||
77 | #define UCSI_GET_CABLE_PROPERTY 0x11 | ||
78 | #define UCSI_GET_CONNECTOR_STATUS 0x12 | ||
79 | #define UCSI_GET_ERROR_STATUS 0x13 | ||
80 | |||
81 | /* ACK_CC_CI commands */ | ||
82 | #define UCSI_ACK_EVENT 1 | ||
83 | #define UCSI_ACK_CMD 2 | ||
84 | |||
85 | /* Bits for SET_NOTIFICATION_ENABLE command */ | ||
86 | #define UCSI_ENABLE_NTFY_CMD_COMPLETE BIT(0) | ||
87 | #define UCSI_ENABLE_NTFY_EXT_PWR_SRC_CHANGE BIT(1) | ||
88 | #define UCSI_ENABLE_NTFY_PWR_OPMODE_CHANGE BIT(2) | ||
89 | #define UCSI_ENABLE_NTFY_CAP_CHANGE BIT(5) | ||
90 | #define UCSI_ENABLE_NTFY_PWR_LEVEL_CHANGE BIT(6) | ||
91 | #define UCSI_ENABLE_NTFY_PD_RESET_COMPLETE BIT(7) | ||
92 | #define UCSI_ENABLE_NTFY_CAM_CHANGE BIT(8) | ||
93 | #define UCSI_ENABLE_NTFY_BAT_STATUS_CHANGE BIT(9) | ||
94 | #define UCSI_ENABLE_NTFY_PARTNER_CHANGE BIT(11) | ||
95 | #define UCSI_ENABLE_NTFY_PWR_DIR_CHANGE BIT(12) | ||
96 | #define UCSI_ENABLE_NTFY_CONNECTOR_CHANGE BIT(14) | ||
97 | #define UCSI_ENABLE_NTFY_ERROR BIT(15) | ||
98 | #define UCSI_ENABLE_NTFY_ALL 0xdbe7 | ||
99 | |||
100 | /* Error information returned by PPM in response to GET_ERROR_STATUS command. */ | ||
101 | #define UCSI_ERROR_UNREGONIZED_CMD BIT(0) | ||
102 | #define UCSI_ERROR_INVALID_CON_NUM BIT(1) | ||
103 | #define UCSI_ERROR_INVALID_CMD_ARGUMENT BIT(2) | ||
104 | #define UCSI_ERROR_INCOMPATIBLE_PARTNER BIT(3) | ||
105 | #define UCSI_ERROR_CC_COMMUNICATION_ERR BIT(4) | ||
106 | #define UCSI_ERROR_DEAD_BATTERY BIT(5) | ||
107 | #define UCSI_ERROR_CONTRACT_NEGOTIATION_FAIL BIT(6) | ||
108 | |||
109 | /* Data structure filled by PPM in response to GET_CAPABILITY command. */ | ||
110 | struct ucsi_capability { | ||
111 | u32 attributes; | ||
112 | #define UCSI_CAP_ATTR_DISABLE_STATE BIT(0) | ||
113 | #define UCSI_CAP_ATTR_BATTERY_CHARGING BIT(1) | ||
114 | #define UCSI_CAP_ATTR_USB_PD BIT(2) | ||
115 | #define UCSI_CAP_ATTR_TYPEC_CURRENT BIT(6) | ||
116 | #define UCSI_CAP_ATTR_POWER_AC_SUPPLY BIT(8) | ||
117 | #define UCSI_CAP_ATTR_POWER_OTHER BIT(10) | ||
118 | #define UCSI_CAP_ATTR_POWER_VBUS BIT(14) | ||
119 | u8 num_connectors; | ||
120 | u32 features:24; | ||
121 | #define UCSI_CAP_SET_UOM BIT(0) | ||
122 | #define UCSI_CAP_SET_PDM BIT(1) | ||
123 | #define UCSI_CAP_ALT_MODE_DETAILS BIT(2) | ||
124 | #define UCSI_CAP_ALT_MODE_OVERRIDE BIT(3) | ||
125 | #define UCSI_CAP_PDO_DETAILS BIT(4) | ||
126 | #define UCSI_CAP_CABLE_DETAILS BIT(5) | ||
127 | #define UCSI_CAP_EXT_SUPPLY_NOTIFICATIONS BIT(6) | ||
128 | #define UCSI_CAP_PD_RESET BIT(7) | ||
129 | u8 num_alt_modes; | ||
130 | u8 RESERVED; | ||
131 | u16 bc_version; | ||
132 | u16 pd_version; | ||
133 | u16 typec_version; | ||
134 | } __packed; | ||
135 | |||
136 | /* Data structure filled by PPM in response to GET_CONNECTOR_CAPABILITY cmd. */ | ||
137 | struct ucsi_connector_capability { | ||
138 | u8 op_mode; | ||
139 | #define UCSI_CONCAP_OPMODE_DFP BIT(0) | ||
140 | #define UCSI_CONCAP_OPMODE_UFP BIT(1) | ||
141 | #define UCSI_CONCAP_OPMODE_DRP BIT(2) | ||
142 | #define UCSI_CONCAP_OPMODE_AUDIO_ACCESSORY BIT(3) | ||
143 | #define UCSI_CONCAP_OPMODE_DEBUG_ACCESSORY BIT(4) | ||
144 | #define UCSI_CONCAP_OPMODE_USB2 BIT(5) | ||
145 | #define UCSI_CONCAP_OPMODE_USB3 BIT(6) | ||
146 | #define UCSI_CONCAP_OPMODE_ALT_MODE BIT(7) | ||
147 | u8 provider:1; | ||
148 | u8 consumer:1; | ||
149 | } __packed; | ||
150 | |||
151 | /* Data structure filled by PPM in response to GET_CABLE_PROPERTY command. */ | ||
152 | struct ucsi_cable_property { | ||
153 | u16 speed_supported; | ||
154 | u8 current_capability; | ||
155 | u8 vbus_in_cable:1; | ||
156 | u8 active_cable:1; | ||
157 | u8 directionality:1; | ||
158 | u8 plug_type:2; | ||
159 | #define UCSI_CABLE_PROPERTY_PLUG_TYPE_A 0 | ||
160 | #define UCSI_CABLE_PROPERTY_PLUG_TYPE_B 1 | ||
161 | #define UCSI_CABLE_PROPERTY_PLUG_TYPE_C 2 | ||
162 | #define UCSI_CABLE_PROPERTY_PLUG_OTHER 3 | ||
163 | u8 mode_support:1; | ||
164 | u8 RESERVED_2:2; | ||
165 | u8 latency:4; | ||
166 | u8 RESERVED_4:4; | ||
167 | } __packed; | ||
168 | |||
169 | /* Data structure filled by PPM in response to GET_CONNECTOR_STATUS command. */ | ||
170 | struct ucsi_connector_status { | ||
171 | u16 change; | ||
172 | #define UCSI_CONSTAT_EXT_SUPPLY_CHANGE BIT(1) | ||
173 | #define UCSI_CONSTAT_POWER_OPMODE_CHANGE BIT(2) | ||
174 | #define UCSI_CONSTAT_PDOS_CHANGE BIT(5) | ||
175 | #define UCSI_CONSTAT_POWER_LEVEL_CHANGE BIT(6) | ||
176 | #define UCSI_CONSTAT_PD_RESET_COMPLETE BIT(7) | ||
177 | #define UCSI_CONSTAT_CAM_CHANGE BIT(8) | ||
178 | #define UCSI_CONSTAT_BC_CHANGE BIT(9) | ||
179 | #define UCSI_CONSTAT_PARTNER_CHANGE BIT(11) | ||
180 | #define UCSI_CONSTAT_POWER_DIR_CHANGE BIT(12) | ||
181 | #define UCSI_CONSTAT_CONNECT_CHANGE BIT(14) | ||
182 | #define UCSI_CONSTAT_ERROR BIT(15) | ||
183 | u16 pwr_op_mode:3; | ||
184 | #define UCSI_CONSTAT_PWR_OPMODE_NONE 0 | ||
185 | #define UCSI_CONSTAT_PWR_OPMODE_DEFAULT 1 | ||
186 | #define UCSI_CONSTAT_PWR_OPMODE_BC 2 | ||
187 | #define UCSI_CONSTAT_PWR_OPMODE_PD 3 | ||
188 | #define UCSI_CONSTAT_PWR_OPMODE_TYPEC1_3 4 | ||
189 | #define UCSI_CONSTAT_PWR_OPMODE_TYPEC3_0 5 | ||
190 | u16 connected:1; | ||
191 | u16 pwr_dir:1; | ||
192 | u16 partner_flags:8; | ||
193 | #define UCSI_CONSTAT_PARTNER_FLAG_USB BIT(0) | ||
194 | #define UCSI_CONSTAT_PARTNER_FLAG_ALT_MODE BIT(1) | ||
195 | u16 partner_type:3; | ||
196 | #define UCSI_CONSTAT_PARTNER_TYPE_DFP 1 | ||
197 | #define UCSI_CONSTAT_PARTNER_TYPE_UFP 2 | ||
198 | #define UCSI_CONSTAT_PARTNER_TYPE_CABLE_NO_UFP 3 /* Powered Cable */ | ||
199 | #define UCSI_CONSTAT_PARTNER_TYPE_CABLE_AND_UFP 4 /* Powered Cable */ | ||
200 | #define UCSI_CONSTAT_PARTNER_TYPE_DEBUG 5 | ||
201 | #define UCSI_CONSTAT_PARTNER_TYPE_AUDIO 6 | ||
202 | u32 request_data_obj; | ||
203 | u8 bc_status:2; | ||
204 | #define UCSI_CONSTAT_BC_NOT_CHARGING 0 | ||
205 | #define UCSI_CONSTAT_BC_NOMINAL_CHARGING 1 | ||
206 | #define UCSI_CONSTAT_BC_SLOW_CHARGING 2 | ||
207 | #define UCSI_CONSTAT_BC_TRICKLE_CHARGING 3 | ||
208 | u8 provider_cap_limit_reason:4; | ||
209 | #define UCSI_CONSTAT_CAP_PWR_LOWERED 0 | ||
210 | #define UCSI_CONSTAT_CAP_PWR_BUDGET_LIMIT 1 | ||
211 | u8 RESERVED:2; | ||
212 | } __packed; | ||
213 | |||
214 | /* -------------------------------------------------------------------------- */ | ||
215 | |||
diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c index 92fdb6e9faff..6b978f04b8d7 100644 --- a/drivers/usb/misc/usbtest.c +++ b/drivers/usb/misc/usbtest.c | |||
@@ -287,6 +287,9 @@ static struct urb *usbtest_alloc_urb( | |||
287 | if (usb_pipein(pipe)) | 287 | if (usb_pipein(pipe)) |
288 | urb->transfer_flags |= URB_SHORT_NOT_OK; | 288 | urb->transfer_flags |= URB_SHORT_NOT_OK; |
289 | 289 | ||
290 | if ((bytes + offset) == 0) | ||
291 | return urb; | ||
292 | |||
290 | if (urb->transfer_flags & URB_NO_TRANSFER_DMA_MAP) | 293 | if (urb->transfer_flags & URB_NO_TRANSFER_DMA_MAP) |
291 | urb->transfer_buffer = usb_alloc_coherent(udev, bytes + offset, | 294 | urb->transfer_buffer = usb_alloc_coherent(udev, bytes + offset, |
292 | GFP_KERNEL, &urb->transfer_dma); | 295 | GFP_KERNEL, &urb->transfer_dma); |
@@ -529,6 +532,7 @@ static struct scatterlist * | |||
529 | alloc_sglist(int nents, int max, int vary, struct usbtest_dev *dev, int pipe) | 532 | alloc_sglist(int nents, int max, int vary, struct usbtest_dev *dev, int pipe) |
530 | { | 533 | { |
531 | struct scatterlist *sg; | 534 | struct scatterlist *sg; |
535 | unsigned int n_size = 0; | ||
532 | unsigned i; | 536 | unsigned i; |
533 | unsigned size = max; | 537 | unsigned size = max; |
534 | unsigned maxpacket = | 538 | unsigned maxpacket = |
@@ -561,7 +565,8 @@ alloc_sglist(int nents, int max, int vary, struct usbtest_dev *dev, int pipe) | |||
561 | break; | 565 | break; |
562 | case 1: | 566 | case 1: |
563 | for (j = 0; j < size; j++) | 567 | for (j = 0; j < size; j++) |
564 | *buf++ = (u8) ((j % maxpacket) % 63); | 568 | *buf++ = (u8) (((j + n_size) % maxpacket) % 63); |
569 | n_size += size; | ||
565 | break; | 570 | break; |
566 | } | 571 | } |
567 | 572 | ||
diff --git a/drivers/usb/phy/phy-qcom-8x16-usb.c b/drivers/usb/phy/phy-qcom-8x16-usb.c index 3d7af85aecb9..d8593adb3621 100644 --- a/drivers/usb/phy/phy-qcom-8x16-usb.c +++ b/drivers/usb/phy/phy-qcom-8x16-usb.c | |||
@@ -240,10 +240,7 @@ static int phy_8x16_read_devicetree(struct phy_8x16 *qphy) | |||
240 | 240 | ||
241 | qphy->switch_gpio = devm_gpiod_get_optional(dev, "switch", | 241 | qphy->switch_gpio = devm_gpiod_get_optional(dev, "switch", |
242 | GPIOD_OUT_LOW); | 242 | GPIOD_OUT_LOW); |
243 | if (IS_ERR(qphy->switch_gpio)) | 243 | return PTR_ERR_OR_ZERO(qphy->switch_gpio); |
244 | return PTR_ERR(qphy->switch_gpio); | ||
245 | |||
246 | return 0; | ||
247 | } | 244 | } |
248 | 245 | ||
249 | static int phy_8x16_reboot_notify(struct notifier_block *this, | 246 | static int phy_8x16_reboot_notify(struct notifier_block *this, |
diff --git a/drivers/usb/phy/phy-twl6030-usb.c b/drivers/usb/phy/phy-twl6030-usb.c index 014dbbd72132..24e2b3cf1867 100644 --- a/drivers/usb/phy/phy-twl6030-usb.c +++ b/drivers/usb/phy/phy-twl6030-usb.c | |||
@@ -155,13 +155,13 @@ static int twl6030_start_srp(struct phy_companion *comparator) | |||
155 | static int twl6030_usb_ldo_init(struct twl6030_usb *twl) | 155 | static int twl6030_usb_ldo_init(struct twl6030_usb *twl) |
156 | { | 156 | { |
157 | /* Set to OTG_REV 1.3 and turn on the ID_WAKEUP_COMP */ | 157 | /* Set to OTG_REV 1.3 and turn on the ID_WAKEUP_COMP */ |
158 | twl6030_writeb(twl, TWL6030_MODULE_ID0 , 0x1, TWL6030_BACKUP_REG); | 158 | twl6030_writeb(twl, TWL6030_MODULE_ID0, 0x1, TWL6030_BACKUP_REG); |
159 | 159 | ||
160 | /* Program CFG_LDO_PD2 register and set VUSB bit */ | 160 | /* Program CFG_LDO_PD2 register and set VUSB bit */ |
161 | twl6030_writeb(twl, TWL6030_MODULE_ID0 , 0x1, TWL6030_CFG_LDO_PD2); | 161 | twl6030_writeb(twl, TWL6030_MODULE_ID0, 0x1, TWL6030_CFG_LDO_PD2); |
162 | 162 | ||
163 | /* Program MISC2 register and set bit VUSB_IN_VBAT */ | 163 | /* Program MISC2 register and set bit VUSB_IN_VBAT */ |
164 | twl6030_writeb(twl, TWL6030_MODULE_ID0 , 0x10, TWL6030_MISC2); | 164 | twl6030_writeb(twl, TWL6030_MODULE_ID0, 0x10, TWL6030_MISC2); |
165 | 165 | ||
166 | twl->usb3v3 = regulator_get(twl->dev, twl->regulator); | 166 | twl->usb3v3 = regulator_get(twl->dev, twl->regulator); |
167 | if (IS_ERR(twl->usb3v3)) | 167 | if (IS_ERR(twl->usb3v3)) |
@@ -301,10 +301,10 @@ static void otg_set_vbus_work(struct work_struct *data) | |||
301 | */ | 301 | */ |
302 | 302 | ||
303 | if (twl->vbus_enable) | 303 | if (twl->vbus_enable) |
304 | twl6030_writeb(twl, TWL_MODULE_MAIN_CHARGE , 0x40, | 304 | twl6030_writeb(twl, TWL_MODULE_MAIN_CHARGE, 0x40, |
305 | CHARGERUSB_CTRL1); | 305 | CHARGERUSB_CTRL1); |
306 | else | 306 | else |
307 | twl6030_writeb(twl, TWL_MODULE_MAIN_CHARGE , 0x00, | 307 | twl6030_writeb(twl, TWL_MODULE_MAIN_CHARGE, 0x00, |
308 | CHARGERUSB_CTRL1); | 308 | CHARGERUSB_CTRL1); |
309 | } | 309 | } |
310 | 310 | ||
diff --git a/drivers/usb/renesas_usbhs/fifo.c b/drivers/usb/renesas_usbhs/fifo.c index 000f9750149f..7be4e7d57ace 100644 --- a/drivers/usb/renesas_usbhs/fifo.c +++ b/drivers/usb/renesas_usbhs/fifo.c | |||
@@ -799,8 +799,10 @@ static int __usbhsf_dma_map_ctrl(struct usbhs_pkt *pkt, int map) | |||
799 | struct usbhs_pipe *pipe = pkt->pipe; | 799 | struct usbhs_pipe *pipe = pkt->pipe; |
800 | struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe); | 800 | struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe); |
801 | struct usbhs_pipe_info *info = usbhs_priv_to_pipeinfo(priv); | 801 | struct usbhs_pipe_info *info = usbhs_priv_to_pipeinfo(priv); |
802 | struct usbhs_fifo *fifo = usbhs_pipe_to_fifo(pipe); | ||
803 | struct dma_chan *chan = usbhsf_dma_chan_get(fifo, pkt); | ||
802 | 804 | ||
803 | return info->dma_map_ctrl(pkt, map); | 805 | return info->dma_map_ctrl(chan->device->dev, pkt, map); |
804 | } | 806 | } |
805 | 807 | ||
806 | static void usbhsf_dma_complete(void *arg); | 808 | static void usbhsf_dma_complete(void *arg); |
@@ -881,12 +883,12 @@ static int usbhsf_dma_prepare_push(struct usbhs_pkt *pkt, int *is_done) | |||
881 | if (!fifo) | 883 | if (!fifo) |
882 | goto usbhsf_pio_prepare_push; | 884 | goto usbhsf_pio_prepare_push; |
883 | 885 | ||
884 | if (usbhsf_dma_map(pkt) < 0) | ||
885 | goto usbhsf_pio_prepare_push; | ||
886 | |||
887 | ret = usbhsf_fifo_select(pipe, fifo, 0); | 886 | ret = usbhsf_fifo_select(pipe, fifo, 0); |
888 | if (ret < 0) | 887 | if (ret < 0) |
889 | goto usbhsf_pio_prepare_push_unmap; | 888 | goto usbhsf_pio_prepare_push; |
889 | |||
890 | if (usbhsf_dma_map(pkt) < 0) | ||
891 | goto usbhsf_pio_prepare_push_unselect; | ||
890 | 892 | ||
891 | pkt->trans = len; | 893 | pkt->trans = len; |
892 | 894 | ||
@@ -896,8 +898,8 @@ static int usbhsf_dma_prepare_push(struct usbhs_pkt *pkt, int *is_done) | |||
896 | 898 | ||
897 | return 0; | 899 | return 0; |
898 | 900 | ||
899 | usbhsf_pio_prepare_push_unmap: | 901 | usbhsf_pio_prepare_push_unselect: |
900 | usbhsf_dma_unmap(pkt); | 902 | usbhsf_fifo_unselect(pipe, fifo); |
901 | usbhsf_pio_prepare_push: | 903 | usbhsf_pio_prepare_push: |
902 | /* | 904 | /* |
903 | * change handler to PIO | 905 | * change handler to PIO |
diff --git a/drivers/usb/renesas_usbhs/mod_gadget.c b/drivers/usb/renesas_usbhs/mod_gadget.c index 53d104b56ef1..30345c2d01be 100644 --- a/drivers/usb/renesas_usbhs/mod_gadget.c +++ b/drivers/usb/renesas_usbhs/mod_gadget.c | |||
@@ -191,13 +191,12 @@ static void usbhsg_queue_push(struct usbhsg_uep *uep, | |||
191 | /* | 191 | /* |
192 | * dma map/unmap | 192 | * dma map/unmap |
193 | */ | 193 | */ |
194 | static int usbhsg_dma_map_ctrl(struct usbhs_pkt *pkt, int map) | 194 | static int usbhsg_dma_map_ctrl(struct device *dma_dev, struct usbhs_pkt *pkt, |
195 | int map) | ||
195 | { | 196 | { |
196 | struct usbhsg_request *ureq = usbhsg_pkt_to_ureq(pkt); | 197 | struct usbhsg_request *ureq = usbhsg_pkt_to_ureq(pkt); |
197 | struct usb_request *req = &ureq->req; | 198 | struct usb_request *req = &ureq->req; |
198 | struct usbhs_pipe *pipe = pkt->pipe; | 199 | struct usbhs_pipe *pipe = pkt->pipe; |
199 | struct usbhsg_uep *uep = usbhsg_pipe_to_uep(pipe); | ||
200 | struct usbhsg_gpriv *gpriv = usbhsg_uep_to_gpriv(uep); | ||
201 | enum dma_data_direction dir; | 200 | enum dma_data_direction dir; |
202 | int ret = 0; | 201 | int ret = 0; |
203 | 202 | ||
@@ -207,13 +206,13 @@ static int usbhsg_dma_map_ctrl(struct usbhs_pkt *pkt, int map) | |||
207 | /* it can not use scatter/gather */ | 206 | /* it can not use scatter/gather */ |
208 | WARN_ON(req->num_sgs); | 207 | WARN_ON(req->num_sgs); |
209 | 208 | ||
210 | ret = usb_gadget_map_request(&gpriv->gadget, req, dir); | 209 | ret = usb_gadget_map_request_by_dev(dma_dev, req, dir); |
211 | if (ret < 0) | 210 | if (ret < 0) |
212 | return ret; | 211 | return ret; |
213 | 212 | ||
214 | pkt->dma = req->dma; | 213 | pkt->dma = req->dma; |
215 | } else { | 214 | } else { |
216 | usb_gadget_unmap_request(&gpriv->gadget, req, dir); | 215 | usb_gadget_unmap_request_by_dev(dma_dev, req, dir); |
217 | } | 216 | } |
218 | 217 | ||
219 | return ret; | 218 | return ret; |
diff --git a/drivers/usb/renesas_usbhs/mod_host.c b/drivers/usb/renesas_usbhs/mod_host.c index 1a8e4c45c4c5..3bf0b72eb359 100644 --- a/drivers/usb/renesas_usbhs/mod_host.c +++ b/drivers/usb/renesas_usbhs/mod_host.c | |||
@@ -929,7 +929,8 @@ static int usbhsh_dcp_queue_push(struct usb_hcd *hcd, | |||
929 | /* | 929 | /* |
930 | * dma map functions | 930 | * dma map functions |
931 | */ | 931 | */ |
932 | static int usbhsh_dma_map_ctrl(struct usbhs_pkt *pkt, int map) | 932 | static int usbhsh_dma_map_ctrl(struct device *dma_dev, struct usbhs_pkt *pkt, |
933 | int map) | ||
933 | { | 934 | { |
934 | if (map) { | 935 | if (map) { |
935 | struct usbhsh_request *ureq = usbhsh_pkt_to_ureq(pkt); | 936 | struct usbhsh_request *ureq = usbhsh_pkt_to_ureq(pkt); |
diff --git a/drivers/usb/renesas_usbhs/pipe.c b/drivers/usb/renesas_usbhs/pipe.c index 78e9dba701c4..c238772b9e9e 100644 --- a/drivers/usb/renesas_usbhs/pipe.c +++ b/drivers/usb/renesas_usbhs/pipe.c | |||
@@ -391,9 +391,8 @@ void usbhs_pipe_set_trans_count_if_bulk(struct usbhs_pipe *pipe, int len) | |||
391 | /* | 391 | /* |
392 | * pipe setup | 392 | * pipe setup |
393 | */ | 393 | */ |
394 | static u16 usbhsp_setup_pipecfg(struct usbhs_pipe *pipe, | 394 | static int usbhsp_setup_pipecfg(struct usbhs_pipe *pipe, int is_host, |
395 | int is_host, | 395 | int dir_in, u16 *pipecfg) |
396 | int dir_in) | ||
397 | { | 396 | { |
398 | u16 type = 0; | 397 | u16 type = 0; |
399 | u16 bfre = 0; | 398 | u16 bfre = 0; |
@@ -451,14 +450,14 @@ static u16 usbhsp_setup_pipecfg(struct usbhs_pipe *pipe, | |||
451 | 450 | ||
452 | /* EPNUM */ | 451 | /* EPNUM */ |
453 | epnum = 0; /* see usbhs_pipe_config_update() */ | 452 | epnum = 0; /* see usbhs_pipe_config_update() */ |
454 | 453 | *pipecfg = type | | |
455 | return type | | 454 | bfre | |
456 | bfre | | 455 | dblb | |
457 | dblb | | 456 | cntmd | |
458 | cntmd | | 457 | dir | |
459 | dir | | 458 | shtnak | |
460 | shtnak | | 459 | epnum; |
461 | epnum; | 460 | return 0; |
462 | } | 461 | } |
463 | 462 | ||
464 | static u16 usbhsp_setup_pipebuff(struct usbhs_pipe *pipe) | 463 | static u16 usbhsp_setup_pipebuff(struct usbhs_pipe *pipe) |
@@ -655,7 +654,8 @@ static void usbhsp_put_pipe(struct usbhs_pipe *pipe) | |||
655 | } | 654 | } |
656 | 655 | ||
657 | void usbhs_pipe_init(struct usbhs_priv *priv, | 656 | void usbhs_pipe_init(struct usbhs_priv *priv, |
658 | int (*dma_map_ctrl)(struct usbhs_pkt *pkt, int map)) | 657 | int (*dma_map_ctrl)(struct device *dma_dev, |
658 | struct usbhs_pkt *pkt, int map)) | ||
659 | { | 659 | { |
660 | struct usbhs_pipe_info *info = usbhs_priv_to_pipeinfo(priv); | 660 | struct usbhs_pipe_info *info = usbhs_priv_to_pipeinfo(priv); |
661 | struct usbhs_pipe *pipe; | 661 | struct usbhs_pipe *pipe; |
@@ -702,7 +702,11 @@ struct usbhs_pipe *usbhs_pipe_malloc(struct usbhs_priv *priv, | |||
702 | return NULL; | 702 | return NULL; |
703 | } | 703 | } |
704 | 704 | ||
705 | pipecfg = usbhsp_setup_pipecfg(pipe, is_host, dir_in); | 705 | if (usbhsp_setup_pipecfg(pipe, is_host, dir_in, &pipecfg)) { |
706 | dev_err(dev, "can't setup pipe\n"); | ||
707 | return NULL; | ||
708 | } | ||
709 | |||
706 | pipebuf = usbhsp_setup_pipebuff(pipe); | 710 | pipebuf = usbhsp_setup_pipebuff(pipe); |
707 | 711 | ||
708 | usbhsp_pipe_select(pipe); | 712 | usbhsp_pipe_select(pipe); |
diff --git a/drivers/usb/renesas_usbhs/pipe.h b/drivers/usb/renesas_usbhs/pipe.h index 7835747f9803..95185fdb29b1 100644 --- a/drivers/usb/renesas_usbhs/pipe.h +++ b/drivers/usb/renesas_usbhs/pipe.h | |||
@@ -47,7 +47,8 @@ struct usbhs_pipe_info { | |||
47 | struct usbhs_pipe *pipe; | 47 | struct usbhs_pipe *pipe; |
48 | int size; /* array size of "pipe" */ | 48 | int size; /* array size of "pipe" */ |
49 | 49 | ||
50 | int (*dma_map_ctrl)(struct usbhs_pkt *pkt, int map); | 50 | int (*dma_map_ctrl)(struct device *dma_dev, struct usbhs_pkt *pkt, |
51 | int map); | ||
51 | }; | 52 | }; |
52 | 53 | ||
53 | /* | 54 | /* |
@@ -84,7 +85,8 @@ int usbhs_pipe_is_running(struct usbhs_pipe *pipe); | |||
84 | void usbhs_pipe_running(struct usbhs_pipe *pipe, int running); | 85 | void usbhs_pipe_running(struct usbhs_pipe *pipe, int running); |
85 | 86 | ||
86 | void usbhs_pipe_init(struct usbhs_priv *priv, | 87 | void usbhs_pipe_init(struct usbhs_priv *priv, |
87 | int (*dma_map_ctrl)(struct usbhs_pkt *pkt, int map)); | 88 | int (*dma_map_ctrl)(struct device *dma_dev, |
89 | struct usbhs_pkt *pkt, int map)); | ||
88 | int usbhs_pipe_get_maxpacket(struct usbhs_pipe *pipe); | 90 | int usbhs_pipe_get_maxpacket(struct usbhs_pipe *pipe); |
89 | void usbhs_pipe_clear(struct usbhs_pipe *pipe); | 91 | void usbhs_pipe_clear(struct usbhs_pipe *pipe); |
90 | int usbhs_pipe_is_accessible(struct usbhs_pipe *pipe); | 92 | int usbhs_pipe_is_accessible(struct usbhs_pipe *pipe); |
diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c index 7c9f25e9c422..96a70789b4c2 100644 --- a/drivers/usb/serial/cp210x.c +++ b/drivers/usb/serial/cp210x.c | |||
@@ -331,6 +331,42 @@ struct cp210x_comm_status { | |||
331 | */ | 331 | */ |
332 | #define PURGE_ALL 0x000f | 332 | #define PURGE_ALL 0x000f |
333 | 333 | ||
334 | /* CP210X_GET_FLOW/CP210X_SET_FLOW read/write these 0x10 bytes */ | ||
335 | struct cp210x_flow_ctl { | ||
336 | __le32 ulControlHandshake; | ||
337 | __le32 ulFlowReplace; | ||
338 | __le32 ulXonLimit; | ||
339 | __le32 ulXoffLimit; | ||
340 | } __packed; | ||
341 | |||
342 | /* cp210x_flow_ctl::ulControlHandshake */ | ||
343 | #define CP210X_SERIAL_DTR_MASK GENMASK(1, 0) | ||
344 | #define CP210X_SERIAL_DTR_SHIFT(_mode) (_mode) | ||
345 | #define CP210X_SERIAL_CTS_HANDSHAKE BIT(3) | ||
346 | #define CP210X_SERIAL_DSR_HANDSHAKE BIT(4) | ||
347 | #define CP210X_SERIAL_DCD_HANDSHAKE BIT(5) | ||
348 | #define CP210X_SERIAL_DSR_SENSITIVITY BIT(6) | ||
349 | |||
350 | /* values for cp210x_flow_ctl::ulControlHandshake::CP210X_SERIAL_DTR_MASK */ | ||
351 | #define CP210X_SERIAL_DTR_INACTIVE 0 | ||
352 | #define CP210X_SERIAL_DTR_ACTIVE 1 | ||
353 | #define CP210X_SERIAL_DTR_FLOW_CTL 2 | ||
354 | |||
355 | /* cp210x_flow_ctl::ulFlowReplace */ | ||
356 | #define CP210X_SERIAL_AUTO_TRANSMIT BIT(0) | ||
357 | #define CP210X_SERIAL_AUTO_RECEIVE BIT(1) | ||
358 | #define CP210X_SERIAL_ERROR_CHAR BIT(2) | ||
359 | #define CP210X_SERIAL_NULL_STRIPPING BIT(3) | ||
360 | #define CP210X_SERIAL_BREAK_CHAR BIT(4) | ||
361 | #define CP210X_SERIAL_RTS_MASK GENMASK(7, 6) | ||
362 | #define CP210X_SERIAL_RTS_SHIFT(_mode) (_mode << 6) | ||
363 | #define CP210X_SERIAL_XOFF_CONTINUE BIT(31) | ||
364 | |||
365 | /* values for cp210x_flow_ctl::ulFlowReplace::CP210X_SERIAL_RTS_MASK */ | ||
366 | #define CP210X_SERIAL_RTS_INACTIVE 0 | ||
367 | #define CP210X_SERIAL_RTS_ACTIVE 1 | ||
368 | #define CP210X_SERIAL_RTS_FLOW_CTL 2 | ||
369 | |||
334 | /* | 370 | /* |
335 | * Reads a variable-sized block of CP210X_ registers, identified by req. | 371 | * Reads a variable-sized block of CP210X_ registers, identified by req. |
336 | * Returns data into buf in native USB byte order. | 372 | * Returns data into buf in native USB byte order. |
@@ -698,9 +734,10 @@ static void cp210x_get_termios_port(struct usb_serial_port *port, | |||
698 | { | 734 | { |
699 | struct device *dev = &port->dev; | 735 | struct device *dev = &port->dev; |
700 | unsigned int cflag; | 736 | unsigned int cflag; |
701 | u8 modem_ctl[16]; | 737 | struct cp210x_flow_ctl flow_ctl; |
702 | u32 baud; | 738 | u32 baud; |
703 | u16 bits; | 739 | u16 bits; |
740 | u32 ctl_hs; | ||
704 | 741 | ||
705 | cp210x_read_u32_reg(port, CP210X_GET_BAUDRATE, &baud); | 742 | cp210x_read_u32_reg(port, CP210X_GET_BAUDRATE, &baud); |
706 | 743 | ||
@@ -796,9 +833,10 @@ static void cp210x_get_termios_port(struct usb_serial_port *port, | |||
796 | break; | 833 | break; |
797 | } | 834 | } |
798 | 835 | ||
799 | cp210x_read_reg_block(port, CP210X_GET_FLOW, modem_ctl, | 836 | cp210x_read_reg_block(port, CP210X_GET_FLOW, &flow_ctl, |
800 | sizeof(modem_ctl)); | 837 | sizeof(flow_ctl)); |
801 | if (modem_ctl[0] & 0x08) { | 838 | ctl_hs = le32_to_cpu(flow_ctl.ulControlHandshake); |
839 | if (ctl_hs & CP210X_SERIAL_CTS_HANDSHAKE) { | ||
802 | dev_dbg(dev, "%s - flow control = CRTSCTS\n", __func__); | 840 | dev_dbg(dev, "%s - flow control = CRTSCTS\n", __func__); |
803 | cflag |= CRTSCTS; | 841 | cflag |= CRTSCTS; |
804 | } else { | 842 | } else { |
@@ -867,7 +905,6 @@ static void cp210x_set_termios(struct tty_struct *tty, | |||
867 | struct device *dev = &port->dev; | 905 | struct device *dev = &port->dev; |
868 | unsigned int cflag, old_cflag; | 906 | unsigned int cflag, old_cflag; |
869 | u16 bits; | 907 | u16 bits; |
870 | u8 modem_ctl[16]; | ||
871 | 908 | ||
872 | cflag = tty->termios.c_cflag; | 909 | cflag = tty->termios.c_cflag; |
873 | old_cflag = old_termios->c_cflag; | 910 | old_cflag = old_termios->c_cflag; |
@@ -951,35 +988,44 @@ static void cp210x_set_termios(struct tty_struct *tty, | |||
951 | } | 988 | } |
952 | 989 | ||
953 | if ((cflag & CRTSCTS) != (old_cflag & CRTSCTS)) { | 990 | if ((cflag & CRTSCTS) != (old_cflag & CRTSCTS)) { |
954 | 991 | struct cp210x_flow_ctl flow_ctl; | |
955 | /* Only bytes 0, 4 and 7 out of first 8 have functional bits */ | 992 | u32 ctl_hs; |
956 | 993 | u32 flow_repl; | |
957 | cp210x_read_reg_block(port, CP210X_GET_FLOW, modem_ctl, | 994 | |
958 | sizeof(modem_ctl)); | 995 | cp210x_read_reg_block(port, CP210X_GET_FLOW, &flow_ctl, |
959 | dev_dbg(dev, "%s - read modem controls = %02x .. .. .. %02x .. .. %02x\n", | 996 | sizeof(flow_ctl)); |
960 | __func__, modem_ctl[0], modem_ctl[4], modem_ctl[7]); | 997 | ctl_hs = le32_to_cpu(flow_ctl.ulControlHandshake); |
961 | 998 | flow_repl = le32_to_cpu(flow_ctl.ulFlowReplace); | |
999 | dev_dbg(dev, "%s - read ulControlHandshake=0x%08x, ulFlowReplace=0x%08x\n", | ||
1000 | __func__, ctl_hs, flow_repl); | ||
1001 | |||
1002 | ctl_hs &= ~CP210X_SERIAL_DSR_HANDSHAKE; | ||
1003 | ctl_hs &= ~CP210X_SERIAL_DCD_HANDSHAKE; | ||
1004 | ctl_hs &= ~CP210X_SERIAL_DSR_SENSITIVITY; | ||
1005 | ctl_hs &= ~CP210X_SERIAL_DTR_MASK; | ||
1006 | ctl_hs |= CP210X_SERIAL_DTR_SHIFT(CP210X_SERIAL_DTR_ACTIVE); | ||
962 | if (cflag & CRTSCTS) { | 1007 | if (cflag & CRTSCTS) { |
963 | modem_ctl[0] &= ~0x7B; | 1008 | ctl_hs |= CP210X_SERIAL_CTS_HANDSHAKE; |
964 | modem_ctl[0] |= 0x09; | 1009 | |
965 | modem_ctl[4] = 0x80; | 1010 | flow_repl &= ~CP210X_SERIAL_RTS_MASK; |
966 | /* FIXME - why clear reserved bits just read? */ | 1011 | flow_repl |= CP210X_SERIAL_RTS_SHIFT( |
967 | modem_ctl[5] = 0; | 1012 | CP210X_SERIAL_RTS_FLOW_CTL); |
968 | modem_ctl[6] = 0; | ||
969 | modem_ctl[7] = 0; | ||
970 | dev_dbg(dev, "%s - flow control = CRTSCTS\n", __func__); | 1013 | dev_dbg(dev, "%s - flow control = CRTSCTS\n", __func__); |
971 | } else { | 1014 | } else { |
972 | modem_ctl[0] &= ~0x7B; | 1015 | ctl_hs &= ~CP210X_SERIAL_CTS_HANDSHAKE; |
973 | modem_ctl[0] |= 0x01; | 1016 | |
974 | /* FIXME - OR here instead of assignment looks wrong */ | 1017 | flow_repl &= ~CP210X_SERIAL_RTS_MASK; |
975 | modem_ctl[4] |= 0x40; | 1018 | flow_repl |= CP210X_SERIAL_RTS_SHIFT( |
1019 | CP210X_SERIAL_RTS_ACTIVE); | ||
976 | dev_dbg(dev, "%s - flow control = NONE\n", __func__); | 1020 | dev_dbg(dev, "%s - flow control = NONE\n", __func__); |
977 | } | 1021 | } |
978 | 1022 | ||
979 | dev_dbg(dev, "%s - write modem controls = %02x .. .. .. %02x .. .. %02x\n", | 1023 | dev_dbg(dev, "%s - write ulControlHandshake=0x%08x, ulFlowReplace=0x%08x\n", |
980 | __func__, modem_ctl[0], modem_ctl[4], modem_ctl[7]); | 1024 | __func__, ctl_hs, flow_repl); |
981 | cp210x_write_reg_block(port, CP210X_SET_FLOW, modem_ctl, | 1025 | flow_ctl.ulControlHandshake = cpu_to_le32(ctl_hs); |
982 | sizeof(modem_ctl)); | 1026 | flow_ctl.ulFlowReplace = cpu_to_le32(flow_repl); |
1027 | cp210x_write_reg_block(port, CP210X_SET_FLOW, &flow_ctl, | ||
1028 | sizeof(flow_ctl)); | ||
983 | } | 1029 | } |
984 | 1030 | ||
985 | } | 1031 | } |
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c index 3a814e802dee..00820809139a 100644 --- a/drivers/usb/serial/ftdi_sio.c +++ b/drivers/usb/serial/ftdi_sio.c | |||
@@ -93,27 +93,27 @@ static int ftdi_8u2232c_probe(struct usb_serial *serial); | |||
93 | static void ftdi_USB_UIRT_setup(struct ftdi_private *priv); | 93 | static void ftdi_USB_UIRT_setup(struct ftdi_private *priv); |
94 | static void ftdi_HE_TIRA1_setup(struct ftdi_private *priv); | 94 | static void ftdi_HE_TIRA1_setup(struct ftdi_private *priv); |
95 | 95 | ||
96 | static struct ftdi_sio_quirk ftdi_jtag_quirk = { | 96 | static const struct ftdi_sio_quirk ftdi_jtag_quirk = { |
97 | .probe = ftdi_jtag_probe, | 97 | .probe = ftdi_jtag_probe, |
98 | }; | 98 | }; |
99 | 99 | ||
100 | static struct ftdi_sio_quirk ftdi_NDI_device_quirk = { | 100 | static const struct ftdi_sio_quirk ftdi_NDI_device_quirk = { |
101 | .probe = ftdi_NDI_device_setup, | 101 | .probe = ftdi_NDI_device_setup, |
102 | }; | 102 | }; |
103 | 103 | ||
104 | static struct ftdi_sio_quirk ftdi_USB_UIRT_quirk = { | 104 | static const struct ftdi_sio_quirk ftdi_USB_UIRT_quirk = { |
105 | .port_probe = ftdi_USB_UIRT_setup, | 105 | .port_probe = ftdi_USB_UIRT_setup, |
106 | }; | 106 | }; |
107 | 107 | ||
108 | static struct ftdi_sio_quirk ftdi_HE_TIRA1_quirk = { | 108 | static const struct ftdi_sio_quirk ftdi_HE_TIRA1_quirk = { |
109 | .port_probe = ftdi_HE_TIRA1_setup, | 109 | .port_probe = ftdi_HE_TIRA1_setup, |
110 | }; | 110 | }; |
111 | 111 | ||
112 | static struct ftdi_sio_quirk ftdi_stmclite_quirk = { | 112 | static const struct ftdi_sio_quirk ftdi_stmclite_quirk = { |
113 | .probe = ftdi_stmclite_probe, | 113 | .probe = ftdi_stmclite_probe, |
114 | }; | 114 | }; |
115 | 115 | ||
116 | static struct ftdi_sio_quirk ftdi_8u2232c_quirk = { | 116 | static const struct ftdi_sio_quirk ftdi_8u2232c_quirk = { |
117 | .probe = ftdi_8u2232c_probe, | 117 | .probe = ftdi_8u2232c_probe, |
118 | }; | 118 | }; |
119 | 119 | ||
@@ -1775,7 +1775,7 @@ static void remove_sysfs_attrs(struct usb_serial_port *port) | |||
1775 | static int ftdi_sio_probe(struct usb_serial *serial, | 1775 | static int ftdi_sio_probe(struct usb_serial *serial, |
1776 | const struct usb_device_id *id) | 1776 | const struct usb_device_id *id) |
1777 | { | 1777 | { |
1778 | struct ftdi_sio_quirk *quirk = | 1778 | const struct ftdi_sio_quirk *quirk = |
1779 | (struct ftdi_sio_quirk *)id->driver_info; | 1779 | (struct ftdi_sio_quirk *)id->driver_info; |
1780 | 1780 | ||
1781 | if (quirk && quirk->probe) { | 1781 | if (quirk && quirk->probe) { |
@@ -1792,7 +1792,7 @@ static int ftdi_sio_probe(struct usb_serial *serial, | |||
1792 | static int ftdi_sio_port_probe(struct usb_serial_port *port) | 1792 | static int ftdi_sio_port_probe(struct usb_serial_port *port) |
1793 | { | 1793 | { |
1794 | struct ftdi_private *priv; | 1794 | struct ftdi_private *priv; |
1795 | struct ftdi_sio_quirk *quirk = usb_get_serial_data(port->serial); | 1795 | const struct ftdi_sio_quirk *quirk = usb_get_serial_data(port->serial); |
1796 | 1796 | ||
1797 | 1797 | ||
1798 | priv = kzalloc(sizeof(struct ftdi_private), GFP_KERNEL); | 1798 | priv = kzalloc(sizeof(struct ftdi_private), GFP_KERNEL); |
diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c index f3007ecdd1b4..11c05ce2f35f 100644 --- a/drivers/usb/serial/io_edgeport.c +++ b/drivers/usb/serial/io_edgeport.c | |||
@@ -2849,14 +2849,16 @@ static int edge_startup(struct usb_serial *serial) | |||
2849 | /* not set up yet, so do it now */ | 2849 | /* not set up yet, so do it now */ |
2850 | edge_serial->interrupt_read_urb = | 2850 | edge_serial->interrupt_read_urb = |
2851 | usb_alloc_urb(0, GFP_KERNEL); | 2851 | usb_alloc_urb(0, GFP_KERNEL); |
2852 | if (!edge_serial->interrupt_read_urb) | 2852 | if (!edge_serial->interrupt_read_urb) { |
2853 | return -ENOMEM; | 2853 | response = -ENOMEM; |
2854 | break; | ||
2855 | } | ||
2854 | 2856 | ||
2855 | edge_serial->interrupt_in_buffer = | 2857 | edge_serial->interrupt_in_buffer = |
2856 | kmalloc(buffer_size, GFP_KERNEL); | 2858 | kmalloc(buffer_size, GFP_KERNEL); |
2857 | if (!edge_serial->interrupt_in_buffer) { | 2859 | if (!edge_serial->interrupt_in_buffer) { |
2858 | usb_free_urb(edge_serial->interrupt_read_urb); | 2860 | response = -ENOMEM; |
2859 | return -ENOMEM; | 2861 | break; |
2860 | } | 2862 | } |
2861 | edge_serial->interrupt_in_endpoint = | 2863 | edge_serial->interrupt_in_endpoint = |
2862 | endpoint->bEndpointAddress; | 2864 | endpoint->bEndpointAddress; |
@@ -2884,14 +2886,16 @@ static int edge_startup(struct usb_serial *serial) | |||
2884 | /* not set up yet, so do it now */ | 2886 | /* not set up yet, so do it now */ |
2885 | edge_serial->read_urb = | 2887 | edge_serial->read_urb = |
2886 | usb_alloc_urb(0, GFP_KERNEL); | 2888 | usb_alloc_urb(0, GFP_KERNEL); |
2887 | if (!edge_serial->read_urb) | 2889 | if (!edge_serial->read_urb) { |
2888 | return -ENOMEM; | 2890 | response = -ENOMEM; |
2891 | break; | ||
2892 | } | ||
2889 | 2893 | ||
2890 | edge_serial->bulk_in_buffer = | 2894 | edge_serial->bulk_in_buffer = |
2891 | kmalloc(buffer_size, GFP_KERNEL); | 2895 | kmalloc(buffer_size, GFP_KERNEL); |
2892 | if (!edge_serial->bulk_in_buffer) { | 2896 | if (!edge_serial->bulk_in_buffer) { |
2893 | usb_free_urb(edge_serial->read_urb); | 2897 | response = -ENOMEM; |
2894 | return -ENOMEM; | 2898 | break; |
2895 | } | 2899 | } |
2896 | edge_serial->bulk_in_endpoint = | 2900 | edge_serial->bulk_in_endpoint = |
2897 | endpoint->bEndpointAddress; | 2901 | endpoint->bEndpointAddress; |
@@ -2917,9 +2921,22 @@ static int edge_startup(struct usb_serial *serial) | |||
2917 | } | 2921 | } |
2918 | } | 2922 | } |
2919 | 2923 | ||
2920 | if (!interrupt_in_found || !bulk_in_found || !bulk_out_found) { | 2924 | if (response || !interrupt_in_found || !bulk_in_found || |
2921 | dev_err(ddev, "Error - the proper endpoints were not found!\n"); | 2925 | !bulk_out_found) { |
2922 | return -ENODEV; | 2926 | if (!response) { |
2927 | dev_err(ddev, "expected endpoints not found\n"); | ||
2928 | response = -ENODEV; | ||
2929 | } | ||
2930 | |||
2931 | usb_free_urb(edge_serial->interrupt_read_urb); | ||
2932 | kfree(edge_serial->interrupt_in_buffer); | ||
2933 | |||
2934 | usb_free_urb(edge_serial->read_urb); | ||
2935 | kfree(edge_serial->bulk_in_buffer); | ||
2936 | |||
2937 | kfree(edge_serial); | ||
2938 | |||
2939 | return response; | ||
2923 | } | 2940 | } |
2924 | 2941 | ||
2925 | /* start interrupt read for this edgeport this interrupt will | 2942 | /* start interrupt read for this edgeport this interrupt will |
@@ -2942,16 +2959,9 @@ static void edge_disconnect(struct usb_serial *serial) | |||
2942 | { | 2959 | { |
2943 | struct edgeport_serial *edge_serial = usb_get_serial_data(serial); | 2960 | struct edgeport_serial *edge_serial = usb_get_serial_data(serial); |
2944 | 2961 | ||
2945 | /* stop reads and writes on all ports */ | ||
2946 | /* free up our endpoint stuff */ | ||
2947 | if (edge_serial->is_epic) { | 2962 | if (edge_serial->is_epic) { |
2948 | usb_kill_urb(edge_serial->interrupt_read_urb); | 2963 | usb_kill_urb(edge_serial->interrupt_read_urb); |
2949 | usb_free_urb(edge_serial->interrupt_read_urb); | ||
2950 | kfree(edge_serial->interrupt_in_buffer); | ||
2951 | |||
2952 | usb_kill_urb(edge_serial->read_urb); | 2964 | usb_kill_urb(edge_serial->read_urb); |
2953 | usb_free_urb(edge_serial->read_urb); | ||
2954 | kfree(edge_serial->bulk_in_buffer); | ||
2955 | } | 2965 | } |
2956 | } | 2966 | } |
2957 | 2967 | ||
@@ -2964,6 +2974,16 @@ static void edge_release(struct usb_serial *serial) | |||
2964 | { | 2974 | { |
2965 | struct edgeport_serial *edge_serial = usb_get_serial_data(serial); | 2975 | struct edgeport_serial *edge_serial = usb_get_serial_data(serial); |
2966 | 2976 | ||
2977 | if (edge_serial->is_epic) { | ||
2978 | usb_kill_urb(edge_serial->interrupt_read_urb); | ||
2979 | usb_free_urb(edge_serial->interrupt_read_urb); | ||
2980 | kfree(edge_serial->interrupt_in_buffer); | ||
2981 | |||
2982 | usb_kill_urb(edge_serial->read_urb); | ||
2983 | usb_free_urb(edge_serial->read_urb); | ||
2984 | kfree(edge_serial->bulk_in_buffer); | ||
2985 | } | ||
2986 | |||
2967 | kfree(edge_serial); | 2987 | kfree(edge_serial); |
2968 | } | 2988 | } |
2969 | 2989 | ||
diff --git a/drivers/usb/serial/keyspan.c b/drivers/usb/serial/keyspan.c index b6bd8e4a6486..1f9414bdd649 100644 --- a/drivers/usb/serial/keyspan.c +++ b/drivers/usb/serial/keyspan.c | |||
@@ -255,7 +255,7 @@ static int keyspan_write(struct tty_struct *tty, | |||
255 | return count; | 255 | return count; |
256 | } | 256 | } |
257 | 257 | ||
258 | dev_dbg(&port->dev, "%s - endpoint %d flip %d\n", | 258 | dev_dbg(&port->dev, "%s - endpoint %x flip %d\n", |
259 | __func__, usb_pipeendpoint(this_urb->pipe), flip); | 259 | __func__, usb_pipeendpoint(this_urb->pipe), flip); |
260 | 260 | ||
261 | if (this_urb->status == -EINPROGRESS) { | 261 | if (this_urb->status == -EINPROGRESS) { |
@@ -300,7 +300,7 @@ static void usa26_indat_callback(struct urb *urb) | |||
300 | endpoint = usb_pipeendpoint(urb->pipe); | 300 | endpoint = usb_pipeendpoint(urb->pipe); |
301 | 301 | ||
302 | if (status) { | 302 | if (status) { |
303 | dev_dbg(&urb->dev->dev, "%s - nonzero status: %x on endpoint %d.\n", | 303 | dev_dbg(&urb->dev->dev, "%s - nonzero status %d on endpoint %x\n", |
304 | __func__, status, endpoint); | 304 | __func__, status, endpoint); |
305 | return; | 305 | return; |
306 | } | 306 | } |
@@ -393,7 +393,8 @@ static void usa26_instat_callback(struct urb *urb) | |||
393 | serial = urb->context; | 393 | serial = urb->context; |
394 | 394 | ||
395 | if (status) { | 395 | if (status) { |
396 | dev_dbg(&urb->dev->dev, "%s - nonzero status: %x\n", __func__, status); | 396 | dev_dbg(&urb->dev->dev, "%s - nonzero status: %d\n", |
397 | __func__, status); | ||
397 | return; | 398 | return; |
398 | } | 399 | } |
399 | if (urb->actual_length != 9) { | 400 | if (urb->actual_length != 9) { |
@@ -452,7 +453,7 @@ static void usa28_indat_callback(struct urb *urb) | |||
452 | 453 | ||
453 | do { | 454 | do { |
454 | if (status) { | 455 | if (status) { |
455 | dev_dbg(&urb->dev->dev, "%s - nonzero status: %x on endpoint %d.\n", | 456 | dev_dbg(&urb->dev->dev, "%s - nonzero status %d on endpoint %x\n", |
456 | __func__, status, usb_pipeendpoint(urb->pipe)); | 457 | __func__, status, usb_pipeendpoint(urb->pipe)); |
457 | return; | 458 | return; |
458 | } | 459 | } |
@@ -511,7 +512,8 @@ static void usa28_instat_callback(struct urb *urb) | |||
511 | serial = urb->context; | 512 | serial = urb->context; |
512 | 513 | ||
513 | if (status) { | 514 | if (status) { |
514 | dev_dbg(&urb->dev->dev, "%s - nonzero status: %x\n", __func__, status); | 515 | dev_dbg(&urb->dev->dev, "%s - nonzero status: %d\n", |
516 | __func__, status); | ||
515 | return; | 517 | return; |
516 | } | 518 | } |
517 | 519 | ||
@@ -591,7 +593,8 @@ static void usa49_instat_callback(struct urb *urb) | |||
591 | serial = urb->context; | 593 | serial = urb->context; |
592 | 594 | ||
593 | if (status) { | 595 | if (status) { |
594 | dev_dbg(&urb->dev->dev, "%s - nonzero status: %x\n", __func__, status); | 596 | dev_dbg(&urb->dev->dev, "%s - nonzero status: %d\n", |
597 | __func__, status); | ||
595 | return; | 598 | return; |
596 | } | 599 | } |
597 | 600 | ||
@@ -646,7 +649,7 @@ static void usa49_indat_callback(struct urb *urb) | |||
646 | endpoint = usb_pipeendpoint(urb->pipe); | 649 | endpoint = usb_pipeendpoint(urb->pipe); |
647 | 650 | ||
648 | if (status) { | 651 | if (status) { |
649 | dev_dbg(&urb->dev->dev, "%s - nonzero status: %x on endpoint %d.\n", | 652 | dev_dbg(&urb->dev->dev, "%s - nonzero status %d on endpoint %x\n", |
650 | __func__, status, endpoint); | 653 | __func__, status, endpoint); |
651 | return; | 654 | return; |
652 | } | 655 | } |
@@ -698,7 +701,8 @@ static void usa49wg_indat_callback(struct urb *urb) | |||
698 | serial = urb->context; | 701 | serial = urb->context; |
699 | 702 | ||
700 | if (status) { | 703 | if (status) { |
701 | dev_dbg(&urb->dev->dev, "%s - nonzero status: %x\n", __func__, status); | 704 | dev_dbg(&urb->dev->dev, "%s - nonzero status: %d\n", |
705 | __func__, status); | ||
702 | return; | 706 | return; |
703 | } | 707 | } |
704 | 708 | ||
@@ -774,8 +778,8 @@ static void usa90_indat_callback(struct urb *urb) | |||
774 | endpoint = usb_pipeendpoint(urb->pipe); | 778 | endpoint = usb_pipeendpoint(urb->pipe); |
775 | 779 | ||
776 | if (status) { | 780 | if (status) { |
777 | dev_dbg(&urb->dev->dev, "%s - nonzero status: %x on endpoint %d.\n", | 781 | dev_dbg(&urb->dev->dev, "%s - nonzero status %d on endpoint %x\n", |
778 | __func__, status, endpoint); | 782 | __func__, status, endpoint); |
779 | return; | 783 | return; |
780 | } | 784 | } |
781 | 785 | ||
@@ -847,7 +851,8 @@ static void usa90_instat_callback(struct urb *urb) | |||
847 | serial = urb->context; | 851 | serial = urb->context; |
848 | 852 | ||
849 | if (status) { | 853 | if (status) { |
850 | dev_dbg(&urb->dev->dev, "%s - nonzero status: %x\n", __func__, status); | 854 | dev_dbg(&urb->dev->dev, "%s - nonzero status: %d\n", |
855 | __func__, status); | ||
851 | return; | 856 | return; |
852 | } | 857 | } |
853 | if (urb->actual_length < 14) { | 858 | if (urb->actual_length < 14) { |
@@ -912,7 +917,8 @@ static void usa67_instat_callback(struct urb *urb) | |||
912 | serial = urb->context; | 917 | serial = urb->context; |
913 | 918 | ||
914 | if (status) { | 919 | if (status) { |
915 | dev_dbg(&urb->dev->dev, "%s - nonzero status: %x\n", __func__, status); | 920 | dev_dbg(&urb->dev->dev, "%s - nonzero status: %d\n", |
921 | __func__, status); | ||
916 | return; | 922 | return; |
917 | } | 923 | } |
918 | 924 | ||
@@ -1082,12 +1088,6 @@ static int keyspan_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
1082 | return 0; | 1088 | return 0; |
1083 | } | 1089 | } |
1084 | 1090 | ||
1085 | static inline void stop_urb(struct urb *urb) | ||
1086 | { | ||
1087 | if (urb && urb->status == -EINPROGRESS) | ||
1088 | usb_kill_urb(urb); | ||
1089 | } | ||
1090 | |||
1091 | static void keyspan_dtr_rts(struct usb_serial_port *port, int on) | 1091 | static void keyspan_dtr_rts(struct usb_serial_port *port, int on) |
1092 | { | 1092 | { |
1093 | struct keyspan_port_private *p_priv = usb_get_serial_port_data(port); | 1093 | struct keyspan_port_private *p_priv = usb_get_serial_port_data(port); |
@@ -1114,10 +1114,10 @@ static void keyspan_close(struct usb_serial_port *port) | |||
1114 | p_priv->out_flip = 0; | 1114 | p_priv->out_flip = 0; |
1115 | p_priv->in_flip = 0; | 1115 | p_priv->in_flip = 0; |
1116 | 1116 | ||
1117 | stop_urb(p_priv->inack_urb); | 1117 | usb_kill_urb(p_priv->inack_urb); |
1118 | for (i = 0; i < 2; i++) { | 1118 | for (i = 0; i < 2; i++) { |
1119 | stop_urb(p_priv->in_urbs[i]); | 1119 | usb_kill_urb(p_priv->in_urbs[i]); |
1120 | stop_urb(p_priv->out_urbs[i]); | 1120 | usb_kill_urb(p_priv->out_urbs[i]); |
1121 | } | 1121 | } |
1122 | } | 1122 | } |
1123 | 1123 | ||
@@ -1221,8 +1221,8 @@ static struct usb_endpoint_descriptor const *find_ep(struct usb_serial const *se | |||
1221 | if (ep->bEndpointAddress == endpoint) | 1221 | if (ep->bEndpointAddress == endpoint) |
1222 | return ep; | 1222 | return ep; |
1223 | } | 1223 | } |
1224 | dev_warn(&serial->interface->dev, "found no endpoint descriptor for " | 1224 | dev_warn(&serial->interface->dev, "found no endpoint descriptor for endpoint %x\n", |
1225 | "endpoint %x\n", endpoint); | 1225 | endpoint); |
1226 | return NULL; | 1226 | return NULL; |
1227 | } | 1227 | } |
1228 | 1228 | ||
@@ -1237,7 +1237,8 @@ static struct urb *keyspan_setup_urb(struct usb_serial *serial, int endpoint, | |||
1237 | if (endpoint == -1) | 1237 | if (endpoint == -1) |
1238 | return NULL; /* endpoint not needed */ | 1238 | return NULL; /* endpoint not needed */ |
1239 | 1239 | ||
1240 | dev_dbg(&serial->interface->dev, "%s - alloc for endpoint %d.\n", __func__, endpoint); | 1240 | dev_dbg(&serial->interface->dev, "%s - alloc for endpoint %x\n", |
1241 | __func__, endpoint); | ||
1241 | urb = usb_alloc_urb(0, GFP_KERNEL); /* No ISO */ | 1242 | urb = usb_alloc_urb(0, GFP_KERNEL); /* No ISO */ |
1242 | if (!urb) | 1243 | if (!urb) |
1243 | return NULL; | 1244 | return NULL; |
@@ -1572,7 +1573,8 @@ static int keyspan_usa26_send_setup(struct usb_serial *serial, | |||
1572 | return -1; | 1573 | return -1; |
1573 | } | 1574 | } |
1574 | 1575 | ||
1575 | dev_dbg(&port->dev, "%s - endpoint %d\n", __func__, usb_pipeendpoint(this_urb->pipe)); | 1576 | dev_dbg(&port->dev, "%s - endpoint %x\n", |
1577 | __func__, usb_pipeendpoint(this_urb->pipe)); | ||
1576 | 1578 | ||
1577 | /* Save reset port val for resend. | 1579 | /* Save reset port val for resend. |
1578 | Don't overwrite resend for open/close condition. */ | 1580 | Don't overwrite resend for open/close condition. */ |
@@ -1838,7 +1840,7 @@ static int keyspan_usa49_send_setup(struct usb_serial *serial, | |||
1838 | return -1; | 1840 | return -1; |
1839 | } | 1841 | } |
1840 | 1842 | ||
1841 | dev_dbg(&port->dev, "%s - endpoint %d (%d)\n", | 1843 | dev_dbg(&port->dev, "%s - endpoint %x (%d)\n", |
1842 | __func__, usb_pipeendpoint(this_urb->pipe), device_port); | 1844 | __func__, usb_pipeendpoint(this_urb->pipe), device_port); |
1843 | 1845 | ||
1844 | /* Save reset port val for resend. | 1846 | /* Save reset port val for resend. |
@@ -2365,9 +2367,9 @@ static void keyspan_disconnect(struct usb_serial *serial) | |||
2365 | 2367 | ||
2366 | s_priv = usb_get_serial_data(serial); | 2368 | s_priv = usb_get_serial_data(serial); |
2367 | 2369 | ||
2368 | stop_urb(s_priv->instat_urb); | 2370 | usb_kill_urb(s_priv->instat_urb); |
2369 | stop_urb(s_priv->glocont_urb); | 2371 | usb_kill_urb(s_priv->glocont_urb); |
2370 | stop_urb(s_priv->indat_urb); | 2372 | usb_kill_urb(s_priv->indat_urb); |
2371 | } | 2373 | } |
2372 | 2374 | ||
2373 | static void keyspan_release(struct usb_serial *serial) | 2375 | static void keyspan_release(struct usb_serial *serial) |
@@ -2376,6 +2378,10 @@ static void keyspan_release(struct usb_serial *serial) | |||
2376 | 2378 | ||
2377 | s_priv = usb_get_serial_data(serial); | 2379 | s_priv = usb_get_serial_data(serial); |
2378 | 2380 | ||
2381 | /* Make sure to unlink the URBs submitted in attach. */ | ||
2382 | usb_kill_urb(s_priv->instat_urb); | ||
2383 | usb_kill_urb(s_priv->indat_urb); | ||
2384 | |||
2379 | usb_free_urb(s_priv->instat_urb); | 2385 | usb_free_urb(s_priv->instat_urb); |
2380 | usb_free_urb(s_priv->indat_urb); | 2386 | usb_free_urb(s_priv->indat_urb); |
2381 | usb_free_urb(s_priv->glocont_urb); | 2387 | usb_free_urb(s_priv->glocont_urb); |
@@ -2491,11 +2497,11 @@ static int keyspan_port_remove(struct usb_serial_port *port) | |||
2491 | 2497 | ||
2492 | p_priv = usb_get_serial_port_data(port); | 2498 | p_priv = usb_get_serial_port_data(port); |
2493 | 2499 | ||
2494 | stop_urb(p_priv->inack_urb); | 2500 | usb_kill_urb(p_priv->inack_urb); |
2495 | stop_urb(p_priv->outcont_urb); | 2501 | usb_kill_urb(p_priv->outcont_urb); |
2496 | for (i = 0; i < 2; i++) { | 2502 | for (i = 0; i < 2; i++) { |
2497 | stop_urb(p_priv->in_urbs[i]); | 2503 | usb_kill_urb(p_priv->in_urbs[i]); |
2498 | stop_urb(p_priv->out_urbs[i]); | 2504 | usb_kill_urb(p_priv->out_urbs[i]); |
2499 | } | 2505 | } |
2500 | 2506 | ||
2501 | usb_free_urb(p_priv->inack_urb); | 2507 | usb_free_urb(p_priv->inack_urb); |
diff --git a/drivers/usb/serial/mxuport.c b/drivers/usb/serial/mxuport.c index 3722d6c1ba77..c88215a0fa3d 100644 --- a/drivers/usb/serial/mxuport.c +++ b/drivers/usb/serial/mxuport.c | |||
@@ -1259,6 +1259,15 @@ static int mxuport_attach(struct usb_serial *serial) | |||
1259 | return 0; | 1259 | return 0; |
1260 | } | 1260 | } |
1261 | 1261 | ||
1262 | static void mxuport_release(struct usb_serial *serial) | ||
1263 | { | ||
1264 | struct usb_serial_port *port0 = serial->port[0]; | ||
1265 | struct usb_serial_port *port1 = serial->port[1]; | ||
1266 | |||
1267 | usb_serial_generic_close(port1); | ||
1268 | usb_serial_generic_close(port0); | ||
1269 | } | ||
1270 | |||
1262 | static int mxuport_open(struct tty_struct *tty, struct usb_serial_port *port) | 1271 | static int mxuport_open(struct tty_struct *tty, struct usb_serial_port *port) |
1263 | { | 1272 | { |
1264 | struct mxuport_port *mxport = usb_get_serial_port_data(port); | 1273 | struct mxuport_port *mxport = usb_get_serial_port_data(port); |
@@ -1361,6 +1370,7 @@ static struct usb_serial_driver mxuport_device = { | |||
1361 | .probe = mxuport_probe, | 1370 | .probe = mxuport_probe, |
1362 | .port_probe = mxuport_port_probe, | 1371 | .port_probe = mxuport_port_probe, |
1363 | .attach = mxuport_attach, | 1372 | .attach = mxuport_attach, |
1373 | .release = mxuport_release, | ||
1364 | .calc_num_ports = mxuport_calc_num_ports, | 1374 | .calc_num_ports = mxuport_calc_num_ports, |
1365 | .open = mxuport_open, | 1375 | .open = mxuport_open, |
1366 | .close = mxuport_close, | 1376 | .close = mxuport_close, |
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c index c6f497f16526..d96d423d00e6 100644 --- a/drivers/usb/serial/option.c +++ b/drivers/usb/serial/option.c | |||
@@ -375,18 +375,22 @@ static void option_instat_callback(struct urb *urb); | |||
375 | #define HAIER_PRODUCT_CE81B 0x10f8 | 375 | #define HAIER_PRODUCT_CE81B 0x10f8 |
376 | #define HAIER_PRODUCT_CE100 0x2009 | 376 | #define HAIER_PRODUCT_CE100 0x2009 |
377 | 377 | ||
378 | /* Cinterion (formerly Siemens) products */ | 378 | /* Gemalto's Cinterion products (formerly Siemens) */ |
379 | #define SIEMENS_VENDOR_ID 0x0681 | 379 | #define SIEMENS_VENDOR_ID 0x0681 |
380 | #define CINTERION_VENDOR_ID 0x1e2d | 380 | #define CINTERION_VENDOR_ID 0x1e2d |
381 | #define CINTERION_PRODUCT_HC25_MDMNET 0x0040 | ||
381 | #define CINTERION_PRODUCT_HC25_MDM 0x0047 | 382 | #define CINTERION_PRODUCT_HC25_MDM 0x0047 |
382 | #define CINTERION_PRODUCT_HC25_MDMNET 0x0040 | 383 | #define CINTERION_PRODUCT_HC28_MDMNET 0x004A /* same for HC28J */ |
383 | #define CINTERION_PRODUCT_HC28_MDM 0x004C | 384 | #define CINTERION_PRODUCT_HC28_MDM 0x004C |
384 | #define CINTERION_PRODUCT_HC28_MDMNET 0x004A /* same for HC28J */ | ||
385 | #define CINTERION_PRODUCT_EU3_E 0x0051 | 385 | #define CINTERION_PRODUCT_EU3_E 0x0051 |
386 | #define CINTERION_PRODUCT_EU3_P 0x0052 | 386 | #define CINTERION_PRODUCT_EU3_P 0x0052 |
387 | #define CINTERION_PRODUCT_PH8 0x0053 | 387 | #define CINTERION_PRODUCT_PH8 0x0053 |
388 | #define CINTERION_PRODUCT_AHXX 0x0055 | 388 | #define CINTERION_PRODUCT_AHXX 0x0055 |
389 | #define CINTERION_PRODUCT_PLXX 0x0060 | 389 | #define CINTERION_PRODUCT_PLXX 0x0060 |
390 | #define CINTERION_PRODUCT_PH8_2RMNET 0x0082 | ||
391 | #define CINTERION_PRODUCT_PH8_AUDIO 0x0083 | ||
392 | #define CINTERION_PRODUCT_AHXX_2RMNET 0x0084 | ||
393 | #define CINTERION_PRODUCT_AHXX_AUDIO 0x0085 | ||
390 | 394 | ||
391 | /* Olivetti products */ | 395 | /* Olivetti products */ |
392 | #define OLIVETTI_VENDOR_ID 0x0b3c | 396 | #define OLIVETTI_VENDOR_ID 0x0b3c |
@@ -633,6 +637,10 @@ static const struct option_blacklist_info telit_le922_blacklist_usbcfg3 = { | |||
633 | .reserved = BIT(1) | BIT(2) | BIT(3), | 637 | .reserved = BIT(1) | BIT(2) | BIT(3), |
634 | }; | 638 | }; |
635 | 639 | ||
640 | static const struct option_blacklist_info cinterion_rmnet2_blacklist = { | ||
641 | .reserved = BIT(4) | BIT(5), | ||
642 | }; | ||
643 | |||
636 | static const struct usb_device_id option_ids[] = { | 644 | static const struct usb_device_id option_ids[] = { |
637 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COLT) }, | 645 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COLT) }, |
638 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA) }, | 646 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA) }, |
@@ -1602,7 +1610,79 @@ static const struct usb_device_id option_ids[] = { | |||
1602 | .driver_info = (kernel_ulong_t)&net_intf3_blacklist }, | 1610 | .driver_info = (kernel_ulong_t)&net_intf3_blacklist }, |
1603 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0178, 0xff, 0xff, 0xff), | 1611 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0178, 0xff, 0xff, 0xff), |
1604 | .driver_info = (kernel_ulong_t)&net_intf3_blacklist }, | 1612 | .driver_info = (kernel_ulong_t)&net_intf3_blacklist }, |
1605 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffe9, 0xff, 0xff, 0xff) }, | 1613 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff42, 0xff, 0xff, 0xff) }, |
1614 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff43, 0xff, 0xff, 0xff) }, | ||
1615 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff44, 0xff, 0xff, 0xff) }, | ||
1616 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff45, 0xff, 0xff, 0xff) }, | ||
1617 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff46, 0xff, 0xff, 0xff) }, | ||
1618 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff47, 0xff, 0xff, 0xff) }, | ||
1619 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff48, 0xff, 0xff, 0xff) }, | ||
1620 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff49, 0xff, 0xff, 0xff) }, | ||
1621 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff4a, 0xff, 0xff, 0xff) }, | ||
1622 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff4b, 0xff, 0xff, 0xff) }, | ||
1623 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff4c, 0xff, 0xff, 0xff) }, | ||
1624 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff4d, 0xff, 0xff, 0xff) }, | ||
1625 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff4e, 0xff, 0xff, 0xff) }, | ||
1626 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff4f, 0xff, 0xff, 0xff) }, | ||
1627 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff50, 0xff, 0xff, 0xff) }, | ||
1628 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff51, 0xff, 0xff, 0xff) }, | ||
1629 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff52, 0xff, 0xff, 0xff) }, | ||
1630 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff53, 0xff, 0xff, 0xff) }, | ||
1631 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff54, 0xff, 0xff, 0xff) }, | ||
1632 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff55, 0xff, 0xff, 0xff) }, | ||
1633 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff56, 0xff, 0xff, 0xff) }, | ||
1634 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff57, 0xff, 0xff, 0xff) }, | ||
1635 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff58, 0xff, 0xff, 0xff) }, | ||
1636 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff59, 0xff, 0xff, 0xff) }, | ||
1637 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff5a, 0xff, 0xff, 0xff) }, | ||
1638 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff5b, 0xff, 0xff, 0xff) }, | ||
1639 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff5c, 0xff, 0xff, 0xff) }, | ||
1640 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff5d, 0xff, 0xff, 0xff) }, | ||
1641 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff5e, 0xff, 0xff, 0xff) }, | ||
1642 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff5f, 0xff, 0xff, 0xff) }, | ||
1643 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff60, 0xff, 0xff, 0xff) }, | ||
1644 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff61, 0xff, 0xff, 0xff) }, | ||
1645 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff62, 0xff, 0xff, 0xff) }, | ||
1646 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff63, 0xff, 0xff, 0xff) }, | ||
1647 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff64, 0xff, 0xff, 0xff) }, | ||
1648 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff65, 0xff, 0xff, 0xff) }, | ||
1649 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff66, 0xff, 0xff, 0xff) }, | ||
1650 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff67, 0xff, 0xff, 0xff) }, | ||
1651 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff68, 0xff, 0xff, 0xff) }, | ||
1652 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff69, 0xff, 0xff, 0xff) }, | ||
1653 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff6a, 0xff, 0xff, 0xff) }, | ||
1654 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff6b, 0xff, 0xff, 0xff) }, | ||
1655 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff6c, 0xff, 0xff, 0xff) }, | ||
1656 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff6d, 0xff, 0xff, 0xff) }, | ||
1657 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff6e, 0xff, 0xff, 0xff) }, | ||
1658 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff6f, 0xff, 0xff, 0xff) }, | ||
1659 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff70, 0xff, 0xff, 0xff) }, | ||
1660 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff71, 0xff, 0xff, 0xff) }, | ||
1661 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff72, 0xff, 0xff, 0xff) }, | ||
1662 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff73, 0xff, 0xff, 0xff) }, | ||
1663 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff74, 0xff, 0xff, 0xff) }, | ||
1664 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff75, 0xff, 0xff, 0xff) }, | ||
1665 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff76, 0xff, 0xff, 0xff) }, | ||
1666 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff77, 0xff, 0xff, 0xff) }, | ||
1667 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff78, 0xff, 0xff, 0xff) }, | ||
1668 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff79, 0xff, 0xff, 0xff) }, | ||
1669 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff7a, 0xff, 0xff, 0xff) }, | ||
1670 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff7b, 0xff, 0xff, 0xff) }, | ||
1671 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff7c, 0xff, 0xff, 0xff) }, | ||
1672 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff7d, 0xff, 0xff, 0xff) }, | ||
1673 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff7e, 0xff, 0xff, 0xff) }, | ||
1674 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff7f, 0xff, 0xff, 0xff) }, | ||
1675 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff80, 0xff, 0xff, 0xff) }, | ||
1676 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff81, 0xff, 0xff, 0xff) }, | ||
1677 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff82, 0xff, 0xff, 0xff) }, | ||
1678 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff83, 0xff, 0xff, 0xff) }, | ||
1679 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff84, 0xff, 0xff, 0xff) }, | ||
1680 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff85, 0xff, 0xff, 0xff) }, | ||
1681 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff86, 0xff, 0xff, 0xff) }, | ||
1682 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff87, 0xff, 0xff, 0xff) }, | ||
1683 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff88, 0xff, 0xff, 0xff) }, | ||
1684 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff89, 0xff, 0xff, 0xff) }, | ||
1685 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff8a, 0xff, 0xff, 0xff) }, | ||
1606 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff8b, 0xff, 0xff, 0xff) }, | 1686 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff8b, 0xff, 0xff, 0xff) }, |
1607 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff8c, 0xff, 0xff, 0xff) }, | 1687 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff8c, 0xff, 0xff, 0xff) }, |
1608 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff8d, 0xff, 0xff, 0xff) }, | 1688 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff8d, 0xff, 0xff, 0xff) }, |
@@ -1613,6 +1693,61 @@ static const struct usb_device_id option_ids[] = { | |||
1613 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff92, 0xff, 0xff, 0xff) }, | 1693 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff92, 0xff, 0xff, 0xff) }, |
1614 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff93, 0xff, 0xff, 0xff) }, | 1694 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff93, 0xff, 0xff, 0xff) }, |
1615 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff94, 0xff, 0xff, 0xff) }, | 1695 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff94, 0xff, 0xff, 0xff) }, |
1696 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff9f, 0xff, 0xff, 0xff) }, | ||
1697 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffa0, 0xff, 0xff, 0xff) }, | ||
1698 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffa1, 0xff, 0xff, 0xff) }, | ||
1699 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffa2, 0xff, 0xff, 0xff) }, | ||
1700 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffa3, 0xff, 0xff, 0xff) }, | ||
1701 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffa4, 0xff, 0xff, 0xff) }, | ||
1702 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffa5, 0xff, 0xff, 0xff) }, | ||
1703 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffa6, 0xff, 0xff, 0xff) }, | ||
1704 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffa7, 0xff, 0xff, 0xff) }, | ||
1705 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffa8, 0xff, 0xff, 0xff) }, | ||
1706 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffa9, 0xff, 0xff, 0xff) }, | ||
1707 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffaa, 0xff, 0xff, 0xff) }, | ||
1708 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffab, 0xff, 0xff, 0xff) }, | ||
1709 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffac, 0xff, 0xff, 0xff) }, | ||
1710 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffae, 0xff, 0xff, 0xff) }, | ||
1711 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffaf, 0xff, 0xff, 0xff) }, | ||
1712 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffb0, 0xff, 0xff, 0xff) }, | ||
1713 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffb1, 0xff, 0xff, 0xff) }, | ||
1714 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffb2, 0xff, 0xff, 0xff) }, | ||
1715 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffb3, 0xff, 0xff, 0xff) }, | ||
1716 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffb4, 0xff, 0xff, 0xff) }, | ||
1717 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffb5, 0xff, 0xff, 0xff) }, | ||
1718 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffb6, 0xff, 0xff, 0xff) }, | ||
1719 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffb7, 0xff, 0xff, 0xff) }, | ||
1720 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffb8, 0xff, 0xff, 0xff) }, | ||
1721 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffb9, 0xff, 0xff, 0xff) }, | ||
1722 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffba, 0xff, 0xff, 0xff) }, | ||
1723 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffbb, 0xff, 0xff, 0xff) }, | ||
1724 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffbc, 0xff, 0xff, 0xff) }, | ||
1725 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffbd, 0xff, 0xff, 0xff) }, | ||
1726 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffbe, 0xff, 0xff, 0xff) }, | ||
1727 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffbf, 0xff, 0xff, 0xff) }, | ||
1728 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffc0, 0xff, 0xff, 0xff) }, | ||
1729 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffc1, 0xff, 0xff, 0xff) }, | ||
1730 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffc2, 0xff, 0xff, 0xff) }, | ||
1731 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffc3, 0xff, 0xff, 0xff) }, | ||
1732 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffc4, 0xff, 0xff, 0xff) }, | ||
1733 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffc5, 0xff, 0xff, 0xff) }, | ||
1734 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffc6, 0xff, 0xff, 0xff) }, | ||
1735 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffc7, 0xff, 0xff, 0xff) }, | ||
1736 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffc8, 0xff, 0xff, 0xff) }, | ||
1737 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffc9, 0xff, 0xff, 0xff) }, | ||
1738 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffca, 0xff, 0xff, 0xff) }, | ||
1739 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffcb, 0xff, 0xff, 0xff) }, | ||
1740 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffcc, 0xff, 0xff, 0xff) }, | ||
1741 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffcd, 0xff, 0xff, 0xff) }, | ||
1742 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffce, 0xff, 0xff, 0xff) }, | ||
1743 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffcf, 0xff, 0xff, 0xff) }, | ||
1744 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffd0, 0xff, 0xff, 0xff) }, | ||
1745 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffd1, 0xff, 0xff, 0xff) }, | ||
1746 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffd2, 0xff, 0xff, 0xff) }, | ||
1747 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffd3, 0xff, 0xff, 0xff) }, | ||
1748 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffd4, 0xff, 0xff, 0xff) }, | ||
1749 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffd5, 0xff, 0xff, 0xff) }, | ||
1750 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffe9, 0xff, 0xff, 0xff) }, | ||
1616 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffec, 0xff, 0xff, 0xff) }, | 1751 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffec, 0xff, 0xff, 0xff) }, |
1617 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffee, 0xff, 0xff, 0xff) }, | 1752 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffee, 0xff, 0xff, 0xff) }, |
1618 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xfff6, 0xff, 0xff, 0xff) }, | 1753 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xfff6, 0xff, 0xff, 0xff) }, |
@@ -1712,7 +1847,13 @@ static const struct usb_device_id option_ids[] = { | |||
1712 | { USB_DEVICE_INTERFACE_CLASS(CINTERION_VENDOR_ID, CINTERION_PRODUCT_AHXX, 0xff) }, | 1847 | { USB_DEVICE_INTERFACE_CLASS(CINTERION_VENDOR_ID, CINTERION_PRODUCT_AHXX, 0xff) }, |
1713 | { USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_PLXX), | 1848 | { USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_PLXX), |
1714 | .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, | 1849 | .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, |
1715 | { USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_HC28_MDM) }, | 1850 | { USB_DEVICE_INTERFACE_CLASS(CINTERION_VENDOR_ID, CINTERION_PRODUCT_PH8_2RMNET, 0xff), |
1851 | .driver_info = (kernel_ulong_t)&cinterion_rmnet2_blacklist }, | ||
1852 | { USB_DEVICE_INTERFACE_CLASS(CINTERION_VENDOR_ID, CINTERION_PRODUCT_PH8_AUDIO, 0xff), | ||
1853 | .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, | ||
1854 | { USB_DEVICE_INTERFACE_CLASS(CINTERION_VENDOR_ID, CINTERION_PRODUCT_AHXX_2RMNET, 0xff) }, | ||
1855 | { USB_DEVICE_INTERFACE_CLASS(CINTERION_VENDOR_ID, CINTERION_PRODUCT_AHXX_AUDIO, 0xff) }, | ||
1856 | { USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_HC28_MDM) }, | ||
1716 | { USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_HC28_MDMNET) }, | 1857 | { USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_HC28_MDMNET) }, |
1717 | { USB_DEVICE(SIEMENS_VENDOR_ID, CINTERION_PRODUCT_HC25_MDM) }, | 1858 | { USB_DEVICE(SIEMENS_VENDOR_ID, CINTERION_PRODUCT_HC25_MDM) }, |
1718 | { USB_DEVICE(SIEMENS_VENDOR_ID, CINTERION_PRODUCT_HC25_MDMNET) }, | 1859 | { USB_DEVICE(SIEMENS_VENDOR_ID, CINTERION_PRODUCT_HC25_MDMNET) }, |
diff --git a/drivers/usb/serial/quatech2.c b/drivers/usb/serial/quatech2.c index 2df8ad5ede89..85acb50a7ee2 100644 --- a/drivers/usb/serial/quatech2.c +++ b/drivers/usb/serial/quatech2.c | |||
@@ -141,6 +141,7 @@ static void qt2_release(struct usb_serial *serial) | |||
141 | 141 | ||
142 | serial_priv = usb_get_serial_data(serial); | 142 | serial_priv = usb_get_serial_data(serial); |
143 | 143 | ||
144 | usb_kill_urb(serial_priv->read_urb); | ||
144 | usb_free_urb(serial_priv->read_urb); | 145 | usb_free_urb(serial_priv->read_urb); |
145 | kfree(serial_priv->read_buffer); | 146 | kfree(serial_priv->read_buffer); |
146 | kfree(serial_priv); | 147 | kfree(serial_priv); |
diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c index 2694df2f4559..e7dbbef2af2a 100644 --- a/drivers/usb/serial/ti_usb_3410_5052.c +++ b/drivers/usb/serial/ti_usb_3410_5052.c | |||
@@ -80,6 +80,7 @@ struct ti_device { | |||
80 | int td_open_port_count; | 80 | int td_open_port_count; |
81 | struct usb_serial *td_serial; | 81 | struct usb_serial *td_serial; |
82 | int td_is_3410; | 82 | int td_is_3410; |
83 | bool td_rs485_only; | ||
83 | int td_urb_error; | 84 | int td_urb_error; |
84 | }; | 85 | }; |
85 | 86 | ||
@@ -160,6 +161,11 @@ static const struct usb_device_id ti_id_table_3410[] = { | |||
160 | { USB_DEVICE(ABBOTT_VENDOR_ID, ABBOTT_STRIP_PORT_ID) }, | 161 | { USB_DEVICE(ABBOTT_VENDOR_ID, ABBOTT_STRIP_PORT_ID) }, |
161 | { USB_DEVICE(TI_VENDOR_ID, FRI2_PRODUCT_ID) }, | 162 | { USB_DEVICE(TI_VENDOR_ID, FRI2_PRODUCT_ID) }, |
162 | { USB_DEVICE(HONEYWELL_VENDOR_ID, HONEYWELL_HGI80_PRODUCT_ID) }, | 163 | { USB_DEVICE(HONEYWELL_VENDOR_ID, HONEYWELL_HGI80_PRODUCT_ID) }, |
164 | { USB_DEVICE(MXU1_VENDOR_ID, MXU1_1110_PRODUCT_ID) }, | ||
165 | { USB_DEVICE(MXU1_VENDOR_ID, MXU1_1130_PRODUCT_ID) }, | ||
166 | { USB_DEVICE(MXU1_VENDOR_ID, MXU1_1131_PRODUCT_ID) }, | ||
167 | { USB_DEVICE(MXU1_VENDOR_ID, MXU1_1150_PRODUCT_ID) }, | ||
168 | { USB_DEVICE(MXU1_VENDOR_ID, MXU1_1151_PRODUCT_ID) }, | ||
163 | { } /* terminator */ | 169 | { } /* terminator */ |
164 | }; | 170 | }; |
165 | 171 | ||
@@ -193,6 +199,11 @@ static const struct usb_device_id ti_id_table_combined[] = { | |||
193 | { USB_DEVICE(ABBOTT_VENDOR_ID, ABBOTT_STRIP_PORT_ID) }, | 199 | { USB_DEVICE(ABBOTT_VENDOR_ID, ABBOTT_STRIP_PORT_ID) }, |
194 | { USB_DEVICE(TI_VENDOR_ID, FRI2_PRODUCT_ID) }, | 200 | { USB_DEVICE(TI_VENDOR_ID, FRI2_PRODUCT_ID) }, |
195 | { USB_DEVICE(HONEYWELL_VENDOR_ID, HONEYWELL_HGI80_PRODUCT_ID) }, | 201 | { USB_DEVICE(HONEYWELL_VENDOR_ID, HONEYWELL_HGI80_PRODUCT_ID) }, |
202 | { USB_DEVICE(MXU1_VENDOR_ID, MXU1_1110_PRODUCT_ID) }, | ||
203 | { USB_DEVICE(MXU1_VENDOR_ID, MXU1_1130_PRODUCT_ID) }, | ||
204 | { USB_DEVICE(MXU1_VENDOR_ID, MXU1_1131_PRODUCT_ID) }, | ||
205 | { USB_DEVICE(MXU1_VENDOR_ID, MXU1_1150_PRODUCT_ID) }, | ||
206 | { USB_DEVICE(MXU1_VENDOR_ID, MXU1_1151_PRODUCT_ID) }, | ||
196 | { } /* terminator */ | 207 | { } /* terminator */ |
197 | }; | 208 | }; |
198 | 209 | ||
@@ -277,6 +288,11 @@ MODULE_FIRMWARE("mts_gsm.fw"); | |||
277 | MODULE_FIRMWARE("mts_edge.fw"); | 288 | MODULE_FIRMWARE("mts_edge.fw"); |
278 | MODULE_FIRMWARE("mts_mt9234mu.fw"); | 289 | MODULE_FIRMWARE("mts_mt9234mu.fw"); |
279 | MODULE_FIRMWARE("mts_mt9234zba.fw"); | 290 | MODULE_FIRMWARE("mts_mt9234zba.fw"); |
291 | MODULE_FIRMWARE("moxa/moxa-1110.fw"); | ||
292 | MODULE_FIRMWARE("moxa/moxa-1130.fw"); | ||
293 | MODULE_FIRMWARE("moxa/moxa-1131.fw"); | ||
294 | MODULE_FIRMWARE("moxa/moxa-1150.fw"); | ||
295 | MODULE_FIRMWARE("moxa/moxa-1151.fw"); | ||
280 | 296 | ||
281 | module_param(closing_wait, int, S_IRUGO | S_IWUSR); | 297 | module_param(closing_wait, int, S_IRUGO | S_IWUSR); |
282 | MODULE_PARM_DESC(closing_wait, | 298 | MODULE_PARM_DESC(closing_wait, |
@@ -292,6 +308,9 @@ static int ti_startup(struct usb_serial *serial) | |||
292 | { | 308 | { |
293 | struct ti_device *tdev; | 309 | struct ti_device *tdev; |
294 | struct usb_device *dev = serial->dev; | 310 | struct usb_device *dev = serial->dev; |
311 | struct usb_host_interface *cur_altsetting; | ||
312 | int num_endpoints; | ||
313 | u16 vid, pid; | ||
295 | int status; | 314 | int status; |
296 | 315 | ||
297 | dev_dbg(&dev->dev, | 316 | dev_dbg(&dev->dev, |
@@ -315,8 +334,22 @@ static int ti_startup(struct usb_serial *serial) | |||
315 | dev_dbg(&dev->dev, "%s - device type is %s\n", __func__, | 334 | dev_dbg(&dev->dev, "%s - device type is %s\n", __func__, |
316 | tdev->td_is_3410 ? "3410" : "5052"); | 335 | tdev->td_is_3410 ? "3410" : "5052"); |
317 | 336 | ||
318 | /* if we have only 1 configuration, download firmware */ | 337 | vid = le16_to_cpu(dev->descriptor.idVendor); |
319 | if (dev->descriptor.bNumConfigurations == 1) { | 338 | pid = le16_to_cpu(dev->descriptor.idProduct); |
339 | if (vid == MXU1_VENDOR_ID) { | ||
340 | switch (pid) { | ||
341 | case MXU1_1130_PRODUCT_ID: | ||
342 | case MXU1_1131_PRODUCT_ID: | ||
343 | tdev->td_rs485_only = true; | ||
344 | break; | ||
345 | } | ||
346 | } | ||
347 | |||
348 | cur_altsetting = serial->interface->cur_altsetting; | ||
349 | num_endpoints = cur_altsetting->desc.bNumEndpoints; | ||
350 | |||
351 | /* if we have only 1 configuration and 1 endpoint, download firmware */ | ||
352 | if (dev->descriptor.bNumConfigurations == 1 && num_endpoints == 1) { | ||
320 | status = ti_download_firmware(tdev); | 353 | status = ti_download_firmware(tdev); |
321 | 354 | ||
322 | if (status != 0) | 355 | if (status != 0) |
@@ -371,7 +404,11 @@ static int ti_port_probe(struct usb_serial_port *port) | |||
371 | port->port.closing_wait = msecs_to_jiffies(10 * closing_wait); | 404 | port->port.closing_wait = msecs_to_jiffies(10 * closing_wait); |
372 | tport->tp_port = port; | 405 | tport->tp_port = port; |
373 | tport->tp_tdev = usb_get_serial_data(port->serial); | 406 | tport->tp_tdev = usb_get_serial_data(port->serial); |
374 | tport->tp_uart_mode = 0; /* default is RS232 */ | 407 | |
408 | if (tport->tp_tdev->td_rs485_only) | ||
409 | tport->tp_uart_mode = TI_UART_485_RECEIVER_DISABLED; | ||
410 | else | ||
411 | tport->tp_uart_mode = TI_UART_232; | ||
375 | 412 | ||
376 | usb_set_serial_port_data(port, tport); | 413 | usb_set_serial_port_data(port, tport); |
377 | 414 | ||
@@ -1450,6 +1487,16 @@ static int ti_download_firmware(struct ti_device *tdev) | |||
1450 | const struct firmware *fw_p; | 1487 | const struct firmware *fw_p; |
1451 | char buf[32]; | 1488 | char buf[32]; |
1452 | 1489 | ||
1490 | if (le16_to_cpu(dev->descriptor.idVendor) == MXU1_VENDOR_ID) { | ||
1491 | snprintf(buf, | ||
1492 | sizeof(buf), | ||
1493 | "moxa/moxa-%04x.fw", | ||
1494 | le16_to_cpu(dev->descriptor.idProduct)); | ||
1495 | |||
1496 | status = request_firmware(&fw_p, buf, &dev->dev); | ||
1497 | goto check_firmware; | ||
1498 | } | ||
1499 | |||
1453 | /* try ID specific firmware first, then try generic firmware */ | 1500 | /* try ID specific firmware first, then try generic firmware */ |
1454 | sprintf(buf, "ti_usb-v%04x-p%04x.fw", | 1501 | sprintf(buf, "ti_usb-v%04x-p%04x.fw", |
1455 | le16_to_cpu(dev->descriptor.idVendor), | 1502 | le16_to_cpu(dev->descriptor.idVendor), |
@@ -1487,6 +1534,8 @@ static int ti_download_firmware(struct ti_device *tdev) | |||
1487 | } | 1534 | } |
1488 | status = request_firmware(&fw_p, buf, &dev->dev); | 1535 | status = request_firmware(&fw_p, buf, &dev->dev); |
1489 | } | 1536 | } |
1537 | |||
1538 | check_firmware: | ||
1490 | if (status) { | 1539 | if (status) { |
1491 | dev_err(&dev->dev, "%s - firmware not found\n", __func__); | 1540 | dev_err(&dev->dev, "%s - firmware not found\n", __func__); |
1492 | return -ENOENT; | 1541 | return -ENOENT; |
diff --git a/drivers/usb/serial/ti_usb_3410_5052.h b/drivers/usb/serial/ti_usb_3410_5052.h index 98f35c656c02..bbfd3a184600 100644 --- a/drivers/usb/serial/ti_usb_3410_5052.h +++ b/drivers/usb/serial/ti_usb_3410_5052.h | |||
@@ -60,6 +60,14 @@ | |||
60 | #define HONEYWELL_VENDOR_ID 0x10ac | 60 | #define HONEYWELL_VENDOR_ID 0x10ac |
61 | #define HONEYWELL_HGI80_PRODUCT_ID 0x0102 /* Honeywell HGI80 */ | 61 | #define HONEYWELL_HGI80_PRODUCT_ID 0x0102 /* Honeywell HGI80 */ |
62 | 62 | ||
63 | /* Moxa UPORT 11x0 vendor and product IDs */ | ||
64 | #define MXU1_VENDOR_ID 0x110a | ||
65 | #define MXU1_1110_PRODUCT_ID 0x1110 | ||
66 | #define MXU1_1130_PRODUCT_ID 0x1130 | ||
67 | #define MXU1_1131_PRODUCT_ID 0x1131 | ||
68 | #define MXU1_1150_PRODUCT_ID 0x1150 | ||
69 | #define MXU1_1151_PRODUCT_ID 0x1151 | ||
70 | |||
63 | /* Commands */ | 71 | /* Commands */ |
64 | #define TI_GET_VERSION 0x01 | 72 | #define TI_GET_VERSION 0x01 |
65 | #define TI_GET_PORT_STATUS 0x02 | 73 | #define TI_GET_PORT_STATUS 0x02 |
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c index 3f253aec0c16..b1b9bac44016 100644 --- a/drivers/usb/serial/usb-serial.c +++ b/drivers/usb/serial/usb-serial.c | |||
@@ -96,7 +96,8 @@ static int allocate_minors(struct usb_serial *serial, int num_ports) | |||
96 | mutex_lock(&table_lock); | 96 | mutex_lock(&table_lock); |
97 | for (i = 0; i < num_ports; ++i) { | 97 | for (i = 0; i < num_ports; ++i) { |
98 | port = serial->port[i]; | 98 | port = serial->port[i]; |
99 | minor = idr_alloc(&serial_minors, port, 0, 0, GFP_KERNEL); | 99 | minor = idr_alloc(&serial_minors, port, 0, |
100 | USB_SERIAL_TTY_MINORS, GFP_KERNEL); | ||
100 | if (minor < 0) | 101 | if (minor < 0) |
101 | goto error; | 102 | goto error; |
102 | port->minor = minor; | 103 | port->minor = minor; |
@@ -815,7 +816,7 @@ static int usb_serial_probe(struct usb_interface *interface, | |||
815 | } | 816 | } |
816 | } | 817 | } |
817 | 818 | ||
818 | #if defined(CONFIG_USB_SERIAL_PL2303) || defined(CONFIG_USB_SERIAL_PL2303_MODULE) | 819 | #if IS_ENABLED(CONFIG_USB_SERIAL_PL2303) |
819 | /* BEGIN HORRIBLE HACK FOR PL2303 */ | 820 | /* BEGIN HORRIBLE HACK FOR PL2303 */ |
820 | /* this is needed due to the looney way its endpoints are set up */ | 821 | /* this is needed due to the looney way its endpoints are set up */ |
821 | if (((le16_to_cpu(dev->descriptor.idVendor) == PL2303_VENDOR_ID) && | 822 | if (((le16_to_cpu(dev->descriptor.idVendor) == PL2303_VENDOR_ID) && |
diff --git a/drivers/usb/storage/alauda.c b/drivers/usb/storage/alauda.c index 171fa7d793bc..1d8b03c81030 100644 --- a/drivers/usb/storage/alauda.c +++ b/drivers/usb/storage/alauda.c | |||
@@ -829,8 +829,10 @@ static int alauda_write_lba(struct us_data *us, u16 lba, | |||
829 | 829 | ||
830 | pba = MEDIA_INFO(us).lba_to_pba[zone][lba_offset]; | 830 | pba = MEDIA_INFO(us).lba_to_pba[zone][lba_offset]; |
831 | if (pba == 1) { | 831 | if (pba == 1) { |
832 | /* Maybe it is impossible to write to PBA 1. | 832 | /* |
833 | Fake success, but don't do anything. */ | 833 | * Maybe it is impossible to write to PBA 1. |
834 | * Fake success, but don't do anything. | ||
835 | */ | ||
834 | printk(KERN_WARNING | 836 | printk(KERN_WARNING |
835 | "alauda_write_lba: avoid writing to pba 1\n"); | 837 | "alauda_write_lba: avoid writing to pba 1\n"); |
836 | return USB_STOR_TRANSPORT_GOOD; | 838 | return USB_STOR_TRANSPORT_GOOD; |
@@ -977,10 +979,12 @@ static int alauda_read_data(struct us_data *us, unsigned long address, | |||
977 | usb_stor_dbg(us, "Read %d zero pages (LBA %d) page %d\n", | 979 | usb_stor_dbg(us, "Read %d zero pages (LBA %d) page %d\n", |
978 | pages, lba, page); | 980 | pages, lba, page); |
979 | 981 | ||
980 | /* This is not really an error. It just means | 982 | /* |
981 | that the block has never been written. | 983 | * This is not really an error. It just means |
982 | Instead of returning USB_STOR_TRANSPORT_ERROR | 984 | * that the block has never been written. |
983 | it is better to return all zero data. */ | 985 | * Instead of returning USB_STOR_TRANSPORT_ERROR |
986 | * it is better to return all zero data. | ||
987 | */ | ||
984 | 988 | ||
985 | memset(buffer, 0, len); | 989 | memset(buffer, 0, len); |
986 | } else { | 990 | } else { |
@@ -1222,8 +1226,10 @@ static int alauda_transport(struct scsi_cmnd *srb, struct us_data *us) | |||
1222 | } | 1226 | } |
1223 | 1227 | ||
1224 | if (srb->cmnd[0] == ALLOW_MEDIUM_REMOVAL) { | 1228 | if (srb->cmnd[0] == ALLOW_MEDIUM_REMOVAL) { |
1225 | /* sure. whatever. not like we can stop the user from popping | 1229 | /* |
1226 | the media out of the device (no locking doors, etc) */ | 1230 | * sure. whatever. not like we can stop the user from popping |
1231 | * the media out of the device (no locking doors, etc) | ||
1232 | */ | ||
1227 | return USB_STOR_TRANSPORT_GOOD; | 1233 | return USB_STOR_TRANSPORT_GOOD; |
1228 | } | 1234 | } |
1229 | 1235 | ||
diff --git a/drivers/usb/storage/cypress_atacb.c b/drivers/usb/storage/cypress_atacb.c index c80d3dec9a34..5e4af44d7d9f 100644 --- a/drivers/usb/storage/cypress_atacb.c +++ b/drivers/usb/storage/cypress_atacb.c | |||
@@ -110,13 +110,17 @@ static void cypress_atacb_passthrough(struct scsi_cmnd *srb, struct us_data *us) | |||
110 | /* first build the ATACB command */ | 110 | /* first build the ATACB command */ |
111 | srb->cmd_len = 16; | 111 | srb->cmd_len = 16; |
112 | 112 | ||
113 | srb->cmnd[0] = 0x24; /* bVSCBSignature : vendor-specific command | 113 | srb->cmnd[0] = 0x24; /* |
114 | this value can change, but most(all ?) manufacturers | 114 | * bVSCBSignature : vendor-specific command |
115 | keep the cypress default : 0x24 */ | 115 | * this value can change, but most(all ?) manufacturers |
116 | * keep the cypress default : 0x24 | ||
117 | */ | ||
116 | srb->cmnd[1] = 0x24; /* bVSCBSubCommand : 0x24 for ATACB */ | 118 | srb->cmnd[1] = 0x24; /* bVSCBSubCommand : 0x24 for ATACB */ |
117 | 119 | ||
118 | srb->cmnd[3] = 0xff - 1; /* features, sector count, lba low, lba med | 120 | srb->cmnd[3] = 0xff - 1; /* |
119 | lba high, device, command are valid */ | 121 | * features, sector count, lba low, lba med |
122 | * lba high, device, command are valid | ||
123 | */ | ||
120 | srb->cmnd[4] = 1; /* TransferBlockCount : 512 */ | 124 | srb->cmnd[4] = 1; /* TransferBlockCount : 512 */ |
121 | 125 | ||
122 | if (save_cmnd[0] == ATA_16) { | 126 | if (save_cmnd[0] == ATA_16) { |
@@ -155,8 +159,7 @@ static void cypress_atacb_passthrough(struct scsi_cmnd *srb, struct us_data *us) | |||
155 | 159 | ||
156 | usb_stor_transparent_scsi_command(srb, us); | 160 | usb_stor_transparent_scsi_command(srb, us); |
157 | 161 | ||
158 | /* if the device doesn't support ATACB | 162 | /* if the device doesn't support ATACB */ |
159 | */ | ||
160 | if (srb->result == SAM_STAT_CHECK_CONDITION && | 163 | if (srb->result == SAM_STAT_CHECK_CONDITION && |
161 | memcmp(srb->sense_buffer, usb_stor_sense_invalidCDB, | 164 | memcmp(srb->sense_buffer, usb_stor_sense_invalidCDB, |
162 | sizeof(usb_stor_sense_invalidCDB)) == 0) { | 165 | sizeof(usb_stor_sense_invalidCDB)) == 0) { |
@@ -164,7 +167,8 @@ static void cypress_atacb_passthrough(struct scsi_cmnd *srb, struct us_data *us) | |||
164 | goto end; | 167 | goto end; |
165 | } | 168 | } |
166 | 169 | ||
167 | /* if ck_cond flags is set, and there wasn't critical error, | 170 | /* |
171 | * if ck_cond flags is set, and there wasn't critical error, | ||
168 | * build the special sense | 172 | * build the special sense |
169 | */ | 173 | */ |
170 | if ((srb->result != (DID_ERROR << 16) && | 174 | if ((srb->result != (DID_ERROR << 16) && |
@@ -176,11 +180,11 @@ static void cypress_atacb_passthrough(struct scsi_cmnd *srb, struct us_data *us) | |||
176 | unsigned char *desc = sb + 8; | 180 | unsigned char *desc = sb + 8; |
177 | int tmp_result; | 181 | int tmp_result; |
178 | 182 | ||
179 | /* build the command for | 183 | /* build the command for reading the ATA registers */ |
180 | * reading the ATA registers */ | ||
181 | scsi_eh_prep_cmnd(srb, &ses, NULL, 0, sizeof(regs)); | 184 | scsi_eh_prep_cmnd(srb, &ses, NULL, 0, sizeof(regs)); |
182 | 185 | ||
183 | /* we use the same command as before, but we set | 186 | /* |
187 | * we use the same command as before, but we set | ||
184 | * the read taskfile bit, for not executing atacb command, | 188 | * the read taskfile bit, for not executing atacb command, |
185 | * but reading register selected in srb->cmnd[4] | 189 | * but reading register selected in srb->cmnd[4] |
186 | */ | 190 | */ |
@@ -204,10 +208,11 @@ static void cypress_atacb_passthrough(struct scsi_cmnd *srb, struct us_data *us) | |||
204 | sb[2] = 0; /* ATA PASS THROUGH INFORMATION AVAILABLE */ | 208 | sb[2] = 0; /* ATA PASS THROUGH INFORMATION AVAILABLE */ |
205 | sb[3] = 0x1D; | 209 | sb[3] = 0x1D; |
206 | 210 | ||
207 | /* XXX we should generate sk, asc, ascq from status and error | 211 | /* |
212 | * XXX we should generate sk, asc, ascq from status and error | ||
208 | * regs | 213 | * regs |
209 | * (see 11.1 Error translation ATA device error to SCSI error | 214 | * (see 11.1 Error translation ATA device error to SCSI error |
210 | * map, and ata_to_sense_error from libata.) | 215 | * map, and ata_to_sense_error from libata.) |
211 | */ | 216 | */ |
212 | 217 | ||
213 | /* Sense data is current and format is descriptor. */ | 218 | /* Sense data is current and format is descriptor. */ |
@@ -258,7 +263,8 @@ static int cypress_probe(struct usb_interface *intf, | |||
258 | if (result) | 263 | if (result) |
259 | return result; | 264 | return result; |
260 | 265 | ||
261 | /* Among CY7C68300 chips, the A revision does not support Cypress ATACB | 266 | /* |
267 | * Among CY7C68300 chips, the A revision does not support Cypress ATACB | ||
262 | * Filter out this revision from EEPROM default descriptor values | 268 | * Filter out this revision from EEPROM default descriptor values |
263 | */ | 269 | */ |
264 | device = interface_to_usbdev(intf); | 270 | device = interface_to_usbdev(intf); |
diff --git a/drivers/usb/storage/datafab.c b/drivers/usb/storage/datafab.c index aa4f51944a4a..723197af6ec5 100644 --- a/drivers/usb/storage/datafab.c +++ b/drivers/usb/storage/datafab.c | |||
@@ -1,4 +1,5 @@ | |||
1 | /* Driver for Datafab USB Compact Flash reader | 1 | /* |
2 | * Driver for Datafab USB Compact Flash reader | ||
2 | * | 3 | * |
3 | * datafab driver v0.1: | 4 | * datafab driver v0.1: |
4 | * | 5 | * |
@@ -693,18 +694,23 @@ static int datafab_transport(struct scsi_cmnd *srb, struct us_data *us) | |||
693 | } | 694 | } |
694 | 695 | ||
695 | if (srb->cmnd[0] == ALLOW_MEDIUM_REMOVAL) { | 696 | if (srb->cmnd[0] == ALLOW_MEDIUM_REMOVAL) { |
696 | // sure. whatever. not like we can stop the user from | 697 | /* |
697 | // popping the media out of the device (no locking doors, etc) | 698 | * sure. whatever. not like we can stop the user from |
698 | // | 699 | * popping the media out of the device (no locking doors, etc) |
700 | */ | ||
699 | return USB_STOR_TRANSPORT_GOOD; | 701 | return USB_STOR_TRANSPORT_GOOD; |
700 | } | 702 | } |
701 | 703 | ||
702 | if (srb->cmnd[0] == START_STOP) { | 704 | if (srb->cmnd[0] == START_STOP) { |
703 | /* this is used by sd.c'check_scsidisk_media_change to detect | 705 | /* |
704 | media change */ | 706 | * this is used by sd.c'check_scsidisk_media_change to detect |
707 | * media change | ||
708 | */ | ||
705 | usb_stor_dbg(us, "START_STOP\n"); | 709 | usb_stor_dbg(us, "START_STOP\n"); |
706 | /* the first datafab_id_device after a media change returns | 710 | /* |
707 | an error (determined experimentally) */ | 711 | * the first datafab_id_device after a media change returns |
712 | * an error (determined experimentally) | ||
713 | */ | ||
708 | rc = datafab_id_device(us, info); | 714 | rc = datafab_id_device(us, info); |
709 | if (rc == USB_STOR_TRANSPORT_GOOD) { | 715 | if (rc == USB_STOR_TRANSPORT_GOOD) { |
710 | info->sense_key = NO_SENSE; | 716 | info->sense_key = NO_SENSE; |
diff --git a/drivers/usb/storage/debug.c b/drivers/usb/storage/debug.c index 5a12c03138f8..8d20804a59e6 100644 --- a/drivers/usb/storage/debug.c +++ b/drivers/usb/storage/debug.c | |||
@@ -1,4 +1,5 @@ | |||
1 | /* Driver for USB Mass Storage compliant devices | 1 | /* |
2 | * Driver for USB Mass Storage compliant devices | ||
2 | * Debugging Functions Source Code File | 3 | * Debugging Functions Source Code File |
3 | * | 4 | * |
4 | * Current development and maintenance by: | 5 | * Current development and maintenance by: |
diff --git a/drivers/usb/storage/debug.h b/drivers/usb/storage/debug.h index 6b365ce4e610..8ab73299b650 100644 --- a/drivers/usb/storage/debug.h +++ b/drivers/usb/storage/debug.h | |||
@@ -1,4 +1,5 @@ | |||
1 | /* Driver for USB Mass Storage compliant devices | 1 | /* |
2 | * Driver for USB Mass Storage compliant devices | ||
2 | * Debugging Functions Header File | 3 | * Debugging Functions Header File |
3 | * | 4 | * |
4 | * Current development and maintenance by: | 5 | * Current development and maintenance by: |
diff --git a/drivers/usb/storage/ene_ub6250.c b/drivers/usb/storage/ene_ub6250.c index d3a17c65a702..02bdaa912164 100644 --- a/drivers/usb/storage/ene_ub6250.c +++ b/drivers/usb/storage/ene_ub6250.c | |||
@@ -560,8 +560,10 @@ static int ene_send_scsi_cmd(struct us_data *us, u8 fDir, void *buf, int use_sg) | |||
560 | /* check bulk status */ | 560 | /* check bulk status */ |
561 | residue = le32_to_cpu(bcs->Residue); | 561 | residue = le32_to_cpu(bcs->Residue); |
562 | 562 | ||
563 | /* try to compute the actual residue, based on how much data | 563 | /* |
564 | * was really transferred and what the device tells us */ | 564 | * try to compute the actual residue, based on how much data |
565 | * was really transferred and what the device tells us | ||
566 | */ | ||
565 | if (residue && !(us->fflags & US_FL_IGNORE_RESIDUE)) { | 567 | if (residue && !(us->fflags & US_FL_IGNORE_RESIDUE)) { |
566 | residue = min(residue, transfer_length); | 568 | residue = min(residue, transfer_length); |
567 | if (us->srb != NULL) | 569 | if (us->srb != NULL) |
@@ -862,9 +864,6 @@ static int ms_read_readpage(struct us_data *us, u32 PhyBlockAddr, | |||
862 | u8 ExtBuf[4]; | 864 | u8 ExtBuf[4]; |
863 | u32 bn = PhyBlockAddr * 0x20 + PageNum; | 865 | u32 bn = PhyBlockAddr * 0x20 + PageNum; |
864 | 866 | ||
865 | /* printk(KERN_INFO "MS --- MS_ReaderReadPage, | ||
866 | PhyBlockAddr = %x, PageNum = %x\n", PhyBlockAddr, PageNum); */ | ||
867 | |||
868 | result = ene_load_bincode(us, MS_RW_PATTERN); | 867 | result = ene_load_bincode(us, MS_RW_PATTERN); |
869 | if (result != USB_STOR_XFER_GOOD) | 868 | if (result != USB_STOR_XFER_GOOD) |
870 | return USB_STOR_TRANSPORT_ERROR; | 869 | return USB_STOR_TRANSPORT_ERROR; |
@@ -1141,8 +1140,6 @@ static int ms_read_copyblock(struct us_data *us, u16 oldphy, u16 newphy, | |||
1141 | struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf; | 1140 | struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf; |
1142 | int result; | 1141 | int result; |
1143 | 1142 | ||
1144 | /* printk(KERN_INFO "MS_ReaderCopyBlock --- PhyBlockAddr = %x, | ||
1145 | PageNum = %x\n", PhyBlockAddr, PageNum); */ | ||
1146 | result = ene_load_bincode(us, MS_RW_PATTERN); | 1143 | result = ene_load_bincode(us, MS_RW_PATTERN); |
1147 | if (result != USB_STOR_XFER_GOOD) | 1144 | if (result != USB_STOR_XFER_GOOD) |
1148 | return USB_STOR_TRANSPORT_ERROR; | 1145 | return USB_STOR_TRANSPORT_ERROR; |
@@ -1176,8 +1173,6 @@ static int ms_read_eraseblock(struct us_data *us, u32 PhyBlockAddr) | |||
1176 | int result; | 1173 | int result; |
1177 | u32 bn = PhyBlockAddr; | 1174 | u32 bn = PhyBlockAddr; |
1178 | 1175 | ||
1179 | /* printk(KERN_INFO "MS --- ms_read_eraseblock, | ||
1180 | PhyBlockAddr = %x\n", PhyBlockAddr); */ | ||
1181 | result = ene_load_bincode(us, MS_RW_PATTERN); | 1176 | result = ene_load_bincode(us, MS_RW_PATTERN); |
1182 | if (result != USB_STOR_XFER_GOOD) | 1177 | if (result != USB_STOR_XFER_GOOD) |
1183 | return USB_STOR_TRANSPORT_ERROR; | 1178 | return USB_STOR_TRANSPORT_ERROR; |
@@ -1255,8 +1250,6 @@ static int ms_lib_overwrite_extra(struct us_data *us, u32 PhyBlockAddr, | |||
1255 | struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf; | 1250 | struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf; |
1256 | int result; | 1251 | int result; |
1257 | 1252 | ||
1258 | /* printk("MS --- MS_LibOverwriteExtra, | ||
1259 | PhyBlockAddr = %x, PageNum = %x\n", PhyBlockAddr, PageNum); */ | ||
1260 | result = ene_load_bincode(us, MS_RW_PATTERN); | 1253 | result = ene_load_bincode(us, MS_RW_PATTERN); |
1261 | if (result != USB_STOR_XFER_GOOD) | 1254 | if (result != USB_STOR_XFER_GOOD) |
1262 | return USB_STOR_TRANSPORT_ERROR; | 1255 | return USB_STOR_TRANSPORT_ERROR; |
@@ -1342,7 +1335,6 @@ static int ms_lib_read_extra(struct us_data *us, u32 PhyBlock, | |||
1342 | int result; | 1335 | int result; |
1343 | u8 ExtBuf[4]; | 1336 | u8 ExtBuf[4]; |
1344 | 1337 | ||
1345 | /* printk("MS_LibReadExtra --- PhyBlock = %x, PageNum = %x\n", PhyBlock, PageNum); */ | ||
1346 | memset(bcb, 0, sizeof(struct bulk_cb_wrap)); | 1338 | memset(bcb, 0, sizeof(struct bulk_cb_wrap)); |
1347 | bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN); | 1339 | bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN); |
1348 | bcb->DataTransferLength = 0x4; | 1340 | bcb->DataTransferLength = 0x4; |
@@ -1541,9 +1533,6 @@ static int ms_lib_read_extrablock(struct us_data *us, u32 PhyBlock, | |||
1541 | struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf; | 1533 | struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf; |
1542 | int result; | 1534 | int result; |
1543 | 1535 | ||
1544 | /* printk("MS_LibReadExtraBlock --- PhyBlock = %x, | ||
1545 | PageNum = %x, blen = %x\n", PhyBlock, PageNum, blen); */ | ||
1546 | |||
1547 | /* Read Extra Data */ | 1536 | /* Read Extra Data */ |
1548 | memset(bcb, 0, sizeof(struct bulk_cb_wrap)); | 1537 | memset(bcb, 0, sizeof(struct bulk_cb_wrap)); |
1549 | bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN); | 1538 | bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN); |
@@ -2390,8 +2379,10 @@ static int ene_ub6250_reset_resume(struct usb_interface *iface) | |||
2390 | /* Report the reset to the SCSI core */ | 2379 | /* Report the reset to the SCSI core */ |
2391 | usb_stor_reset_resume(iface); | 2380 | usb_stor_reset_resume(iface); |
2392 | 2381 | ||
2393 | /* FIXME: Notify the subdrivers that they need to reinitialize | 2382 | /* |
2394 | * the device */ | 2383 | * FIXME: Notify the subdrivers that they need to reinitialize |
2384 | * the device | ||
2385 | */ | ||
2395 | info->Power_IsResum = true; | 2386 | info->Power_IsResum = true; |
2396 | /*info->SD_Status.Ready = 0; */ | 2387 | /*info->SD_Status.Ready = 0; */ |
2397 | info->SD_Status = *(struct SD_STATUS *)&tmp; | 2388 | info->SD_Status = *(struct SD_STATUS *)&tmp; |
diff --git a/drivers/usb/storage/freecom.c b/drivers/usb/storage/freecom.c index 3f2b08966b9d..c0a5d954414b 100644 --- a/drivers/usb/storage/freecom.c +++ b/drivers/usb/storage/freecom.c | |||
@@ -1,4 +1,5 @@ | |||
1 | /* Driver for Freecom USB/IDE adaptor | 1 | /* |
2 | * Driver for Freecom USB/IDE adaptor | ||
2 | * | 3 | * |
3 | * Freecom v0.1: | 4 | * Freecom v0.1: |
4 | * | 5 | * |
@@ -84,25 +85,33 @@ struct freecom_status { | |||
84 | u8 Pad[60]; | 85 | u8 Pad[60]; |
85 | }; | 86 | }; |
86 | 87 | ||
87 | /* Freecom stuffs the interrupt status in the INDEX_STAT bit of the ide | 88 | /* |
88 | * register. */ | 89 | * Freecom stuffs the interrupt status in the INDEX_STAT bit of the ide |
90 | * register. | ||
91 | */ | ||
89 | #define FCM_INT_STATUS 0x02 /* INDEX_STAT */ | 92 | #define FCM_INT_STATUS 0x02 /* INDEX_STAT */ |
90 | #define FCM_STATUS_BUSY 0x80 | 93 | #define FCM_STATUS_BUSY 0x80 |
91 | 94 | ||
92 | /* These are the packet types. The low bit indicates that this command | 95 | /* |
93 | * should wait for an interrupt. */ | 96 | * These are the packet types. The low bit indicates that this command |
97 | * should wait for an interrupt. | ||
98 | */ | ||
94 | #define FCM_PACKET_ATAPI 0x21 | 99 | #define FCM_PACKET_ATAPI 0x21 |
95 | #define FCM_PACKET_STATUS 0x20 | 100 | #define FCM_PACKET_STATUS 0x20 |
96 | 101 | ||
97 | /* Receive data from the IDE interface. The ATAPI packet has already | 102 | /* |
98 | * waited, so the data should be immediately available. */ | 103 | * Receive data from the IDE interface. The ATAPI packet has already |
104 | * waited, so the data should be immediately available. | ||
105 | */ | ||
99 | #define FCM_PACKET_INPUT 0x81 | 106 | #define FCM_PACKET_INPUT 0x81 |
100 | 107 | ||
101 | /* Send data to the IDE interface. */ | 108 | /* Send data to the IDE interface. */ |
102 | #define FCM_PACKET_OUTPUT 0x01 | 109 | #define FCM_PACKET_OUTPUT 0x01 |
103 | 110 | ||
104 | /* Write a value to an ide register. Or the ide register to write after | 111 | /* |
105 | * munging the address a bit. */ | 112 | * Write a value to an ide register. Or the ide register to write after |
113 | * munging the address a bit. | ||
114 | */ | ||
106 | #define FCM_PACKET_IDE_WRITE 0x40 | 115 | #define FCM_PACKET_IDE_WRITE 0x40 |
107 | #define FCM_PACKET_IDE_READ 0xC0 | 116 | #define FCM_PACKET_IDE_READ 0xC0 |
108 | 117 | ||
@@ -251,16 +260,20 @@ static int freecom_transport(struct scsi_cmnd *srb, struct us_data *us) | |||
251 | result = usb_stor_bulk_transfer_buf (us, opipe, fcb, | 260 | result = usb_stor_bulk_transfer_buf (us, opipe, fcb, |
252 | FCM_PACKET_LENGTH, NULL); | 261 | FCM_PACKET_LENGTH, NULL); |
253 | 262 | ||
254 | /* The Freecom device will only fail if there is something wrong in | 263 | /* |
264 | * The Freecom device will only fail if there is something wrong in | ||
255 | * USB land. It returns the status in its own registers, which | 265 | * USB land. It returns the status in its own registers, which |
256 | * come back in the bulk pipe. */ | 266 | * come back in the bulk pipe. |
267 | */ | ||
257 | if (result != USB_STOR_XFER_GOOD) { | 268 | if (result != USB_STOR_XFER_GOOD) { |
258 | usb_stor_dbg(us, "freecom transport error\n"); | 269 | usb_stor_dbg(us, "freecom transport error\n"); |
259 | return USB_STOR_TRANSPORT_ERROR; | 270 | return USB_STOR_TRANSPORT_ERROR; |
260 | } | 271 | } |
261 | 272 | ||
262 | /* There are times we can optimize out this status read, but it | 273 | /* |
263 | * doesn't hurt us to always do it now. */ | 274 | * There are times we can optimize out this status read, but it |
275 | * doesn't hurt us to always do it now. | ||
276 | */ | ||
264 | result = usb_stor_bulk_transfer_buf (us, ipipe, fst, | 277 | result = usb_stor_bulk_transfer_buf (us, ipipe, fst, |
265 | FCM_STATUS_PACKET_LENGTH, &partial); | 278 | FCM_STATUS_PACKET_LENGTH, &partial); |
266 | usb_stor_dbg(us, "foo Status result %d %u\n", result, partial); | 279 | usb_stor_dbg(us, "foo Status result %d %u\n", result, partial); |
@@ -269,7 +282,8 @@ static int freecom_transport(struct scsi_cmnd *srb, struct us_data *us) | |||
269 | 282 | ||
270 | US_DEBUG(pdump(us, (void *)fst, partial)); | 283 | US_DEBUG(pdump(us, (void *)fst, partial)); |
271 | 284 | ||
272 | /* The firmware will time-out commands after 20 seconds. Some commands | 285 | /* |
286 | * The firmware will time-out commands after 20 seconds. Some commands | ||
273 | * can legitimately take longer than this, so we use a different | 287 | * can legitimately take longer than this, so we use a different |
274 | * command that only waits for the interrupt and then sends status, | 288 | * command that only waits for the interrupt and then sends status, |
275 | * without having to send a new ATAPI command to the device. | 289 | * without having to send a new ATAPI command to the device. |
@@ -291,7 +305,8 @@ static int freecom_transport(struct scsi_cmnd *srb, struct us_data *us) | |||
291 | result = usb_stor_bulk_transfer_buf (us, opipe, fcb, | 305 | result = usb_stor_bulk_transfer_buf (us, opipe, fcb, |
292 | FCM_PACKET_LENGTH, NULL); | 306 | FCM_PACKET_LENGTH, NULL); |
293 | 307 | ||
294 | /* The Freecom device will only fail if there is something | 308 | /* |
309 | * The Freecom device will only fail if there is something | ||
295 | * wrong in USB land. It returns the status in its own | 310 | * wrong in USB land. It returns the status in its own |
296 | * registers, which come back in the bulk pipe. | 311 | * registers, which come back in the bulk pipe. |
297 | */ | 312 | */ |
@@ -318,9 +333,11 @@ static int freecom_transport(struct scsi_cmnd *srb, struct us_data *us) | |||
318 | return USB_STOR_TRANSPORT_FAILED; | 333 | return USB_STOR_TRANSPORT_FAILED; |
319 | } | 334 | } |
320 | 335 | ||
321 | /* The device might not have as much data available as we | 336 | /* |
337 | * The device might not have as much data available as we | ||
322 | * requested. If you ask for more than the device has, this reads | 338 | * requested. If you ask for more than the device has, this reads |
323 | * and such will hang. */ | 339 | * and such will hang. |
340 | */ | ||
324 | usb_stor_dbg(us, "Device indicates that it has %d bytes available\n", | 341 | usb_stor_dbg(us, "Device indicates that it has %d bytes available\n", |
325 | le16_to_cpu(fst->Count)); | 342 | le16_to_cpu(fst->Count)); |
326 | usb_stor_dbg(us, "SCSI requested %d\n", scsi_bufflen(srb)); | 343 | usb_stor_dbg(us, "SCSI requested %d\n", scsi_bufflen(srb)); |
@@ -344,16 +361,20 @@ static int freecom_transport(struct scsi_cmnd *srb, struct us_data *us) | |||
344 | length); | 361 | length); |
345 | } | 362 | } |
346 | 363 | ||
347 | /* What we do now depends on what direction the data is supposed to | 364 | /* |
348 | * move in. */ | 365 | * What we do now depends on what direction the data is supposed to |
366 | * move in. | ||
367 | */ | ||
349 | 368 | ||
350 | switch (us->srb->sc_data_direction) { | 369 | switch (us->srb->sc_data_direction) { |
351 | case DMA_FROM_DEVICE: | 370 | case DMA_FROM_DEVICE: |
352 | /* catch bogus "read 0 length" case */ | 371 | /* catch bogus "read 0 length" case */ |
353 | if (!length) | 372 | if (!length) |
354 | break; | 373 | break; |
355 | /* Make sure that the status indicates that the device | 374 | /* |
356 | * wants data as well. */ | 375 | * Make sure that the status indicates that the device |
376 | * wants data as well. | ||
377 | */ | ||
357 | if ((fst->Status & DRQ_STAT) == 0 || (fst->Reason & 3) != 2) { | 378 | if ((fst->Status & DRQ_STAT) == 0 || (fst->Reason & 3) != 2) { |
358 | usb_stor_dbg(us, "SCSI wants data, drive doesn't have any\n"); | 379 | usb_stor_dbg(us, "SCSI wants data, drive doesn't have any\n"); |
359 | return USB_STOR_TRANSPORT_FAILED; | 380 | return USB_STOR_TRANSPORT_FAILED; |
@@ -384,8 +405,10 @@ static int freecom_transport(struct scsi_cmnd *srb, struct us_data *us) | |||
384 | /* catch bogus "write 0 length" case */ | 405 | /* catch bogus "write 0 length" case */ |
385 | if (!length) | 406 | if (!length) |
386 | break; | 407 | break; |
387 | /* Make sure the status indicates that the device wants to | 408 | /* |
388 | * send us data. */ | 409 | * Make sure the status indicates that the device wants to |
410 | * send us data. | ||
411 | */ | ||
389 | /* !!IMPLEMENT!! */ | 412 | /* !!IMPLEMENT!! */ |
390 | result = freecom_writedata (srb, us, ipipe, opipe, length); | 413 | result = freecom_writedata (srb, us, ipipe, opipe, length); |
391 | if (result != USB_STOR_TRANSPORT_GOOD) | 414 | if (result != USB_STOR_TRANSPORT_GOOD) |
@@ -431,7 +454,8 @@ static int init_freecom(struct us_data *us) | |||
431 | int result; | 454 | int result; |
432 | char *buffer = us->iobuf; | 455 | char *buffer = us->iobuf; |
433 | 456 | ||
434 | /* The DMA-mapped I/O buffer is 64 bytes long, just right for | 457 | /* |
458 | * The DMA-mapped I/O buffer is 64 bytes long, just right for | ||
435 | * all our packets. No need to allocate any extra buffer space. | 459 | * all our packets. No need to allocate any extra buffer space. |
436 | */ | 460 | */ |
437 | 461 | ||
@@ -440,7 +464,8 @@ static int init_freecom(struct us_data *us) | |||
440 | buffer[32] = '\0'; | 464 | buffer[32] = '\0'; |
441 | usb_stor_dbg(us, "String returned from FC init is: %s\n", buffer); | 465 | usb_stor_dbg(us, "String returned from FC init is: %s\n", buffer); |
442 | 466 | ||
443 | /* Special thanks to the people at Freecom for providing me with | 467 | /* |
468 | * Special thanks to the people at Freecom for providing me with | ||
444 | * this "magic sequence", which they use in their Windows and MacOS | 469 | * this "magic sequence", which they use in their Windows and MacOS |
445 | * drivers to make sure that all the attached perhiperals are | 470 | * drivers to make sure that all the attached perhiperals are |
446 | * properly reset. | 471 | * properly reset. |
diff --git a/drivers/usb/storage/initializers.c b/drivers/usb/storage/initializers.c index 31fa2e92065b..d9d8c17e05d1 100644 --- a/drivers/usb/storage/initializers.c +++ b/drivers/usb/storage/initializers.c | |||
@@ -1,4 +1,5 @@ | |||
1 | /* Special Initializers for certain USB Mass Storage devices | 1 | /* |
2 | * Special Initializers for certain USB Mass Storage devices | ||
2 | * | 3 | * |
3 | * Current development and maintenance by: | 4 | * Current development and maintenance by: |
4 | * (c) 1999, 2000 Matthew Dharm (mdharm-usb@one-eyed-alien.net) | 5 | * (c) 1999, 2000 Matthew Dharm (mdharm-usb@one-eyed-alien.net) |
@@ -42,8 +43,10 @@ | |||
42 | #include "debug.h" | 43 | #include "debug.h" |
43 | #include "transport.h" | 44 | #include "transport.h" |
44 | 45 | ||
45 | /* This places the Shuttle/SCM USB<->SCSI bridge devices in multi-target | 46 | /* |
46 | * mode */ | 47 | * This places the Shuttle/SCM USB<->SCSI bridge devices in multi-target |
48 | * mode | ||
49 | */ | ||
47 | int usb_stor_euscsi_init(struct us_data *us) | 50 | int usb_stor_euscsi_init(struct us_data *us) |
48 | { | 51 | { |
49 | int result; | 52 | int result; |
@@ -57,8 +60,10 @@ int usb_stor_euscsi_init(struct us_data *us) | |||
57 | return 0; | 60 | return 0; |
58 | } | 61 | } |
59 | 62 | ||
60 | /* This function is required to activate all four slots on the UCR-61S2B | 63 | /* |
61 | * flash reader */ | 64 | * This function is required to activate all four slots on the UCR-61S2B |
65 | * flash reader | ||
66 | */ | ||
62 | int usb_stor_ucr61s2b_init(struct us_data *us) | 67 | int usb_stor_ucr61s2b_init(struct us_data *us) |
63 | { | 68 | { |
64 | struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap*) us->iobuf; | 69 | struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap*) us->iobuf; |
diff --git a/drivers/usb/storage/initializers.h b/drivers/usb/storage/initializers.h index 529327fbb06b..039abf4d1cb7 100644 --- a/drivers/usb/storage/initializers.h +++ b/drivers/usb/storage/initializers.h | |||
@@ -1,4 +1,5 @@ | |||
1 | /* Header file for Special Initializers for certain USB Mass Storage devices | 1 | /* |
2 | * Header file for Special Initializers for certain USB Mass Storage devices | ||
2 | * | 3 | * |
3 | * Current development and maintenance by: | 4 | * Current development and maintenance by: |
4 | * (c) 1999, 2000 Matthew Dharm (mdharm-usb@one-eyed-alien.net) | 5 | * (c) 1999, 2000 Matthew Dharm (mdharm-usb@one-eyed-alien.net) |
@@ -38,12 +39,16 @@ | |||
38 | #include "usb.h" | 39 | #include "usb.h" |
39 | #include "transport.h" | 40 | #include "transport.h" |
40 | 41 | ||
41 | /* This places the Shuttle/SCM USB<->SCSI bridge devices in multi-target | 42 | /* |
42 | * mode */ | 43 | * This places the Shuttle/SCM USB<->SCSI bridge devices in multi-target |
44 | * mode | ||
45 | */ | ||
43 | int usb_stor_euscsi_init(struct us_data *us); | 46 | int usb_stor_euscsi_init(struct us_data *us); |
44 | 47 | ||
45 | /* This function is required to activate all four slots on the UCR-61S2B | 48 | /* |
46 | * flash reader */ | 49 | * This function is required to activate all four slots on the UCR-61S2B |
50 | * flash reader | ||
51 | */ | ||
47 | int usb_stor_ucr61s2b_init(struct us_data *us); | 52 | int usb_stor_ucr61s2b_init(struct us_data *us); |
48 | 53 | ||
49 | /* This places the HUAWEI E220 devices in multi-port mode */ | 54 | /* This places the HUAWEI E220 devices in multi-port mode */ |
diff --git a/drivers/usb/storage/isd200.c b/drivers/usb/storage/isd200.c index 39afd7045c43..fba4005dd737 100644 --- a/drivers/usb/storage/isd200.c +++ b/drivers/usb/storage/isd200.c | |||
@@ -1,4 +1,5 @@ | |||
1 | /* Transport & Protocol Driver for In-System Design, Inc. ISD200 ASIC | 1 | /* |
2 | * Transport & Protocol Driver for In-System Design, Inc. ISD200 ASIC | ||
2 | * | 3 | * |
3 | * Current development and maintenance: | 4 | * Current development and maintenance: |
4 | * (C) 2001-2002 Björn Stenberg (bjorn@haxx.se) | 5 | * (C) 2001-2002 Björn Stenberg (bjorn@haxx.se) |
@@ -628,7 +629,8 @@ static void isd200_invoke_transport( struct us_data *us, | |||
628 | srb->cmd_len = sizeof(ataCdb->generic); | 629 | srb->cmd_len = sizeof(ataCdb->generic); |
629 | transferStatus = usb_stor_Bulk_transport(srb, us); | 630 | transferStatus = usb_stor_Bulk_transport(srb, us); |
630 | 631 | ||
631 | /* if the command gets aborted by the higher layers, we need to | 632 | /* |
633 | * if the command gets aborted by the higher layers, we need to | ||
632 | * short-circuit all other processing | 634 | * short-circuit all other processing |
633 | */ | 635 | */ |
634 | if (test_bit(US_FLIDX_TIMED_OUT, &us->dflags)) { | 636 | if (test_bit(US_FLIDX_TIMED_OUT, &us->dflags)) { |
@@ -695,15 +697,18 @@ static void isd200_invoke_transport( struct us_data *us, | |||
695 | } | 697 | } |
696 | } | 698 | } |
697 | 699 | ||
698 | /* Regardless of auto-sense, if we _know_ we have an error | 700 | /* |
701 | * Regardless of auto-sense, if we _know_ we have an error | ||
699 | * condition, show that in the result code | 702 | * condition, show that in the result code |
700 | */ | 703 | */ |
701 | if (transferStatus == USB_STOR_TRANSPORT_FAILED) | 704 | if (transferStatus == USB_STOR_TRANSPORT_FAILED) |
702 | srb->result = SAM_STAT_CHECK_CONDITION; | 705 | srb->result = SAM_STAT_CHECK_CONDITION; |
703 | return; | 706 | return; |
704 | 707 | ||
705 | /* abort processing: the bulk-only transport requires a reset | 708 | /* |
706 | * following an abort */ | 709 | * abort processing: the bulk-only transport requires a reset |
710 | * following an abort | ||
711 | */ | ||
707 | Handle_Abort: | 712 | Handle_Abort: |
708 | srb->result = DID_ABORT << 16; | 713 | srb->result = DID_ABORT << 16; |
709 | 714 | ||
@@ -965,20 +970,22 @@ static int isd200_try_enum(struct us_data *us, unsigned char master_slave, | |||
965 | info->DeviceHead = master_slave; | 970 | info->DeviceHead = master_slave; |
966 | break; | 971 | break; |
967 | } | 972 | } |
968 | /* check Cylinder High/Low to | 973 | /* |
969 | determine if it is an ATAPI device | 974 | * check Cylinder High/Low to |
970 | */ | 975 | * determine if it is an ATAPI device |
976 | */ | ||
971 | else if (regs[ATA_REG_HCYL_OFFSET] == 0xEB && | 977 | else if (regs[ATA_REG_HCYL_OFFSET] == 0xEB && |
972 | regs[ATA_REG_LCYL_OFFSET] == 0x14) { | 978 | regs[ATA_REG_LCYL_OFFSET] == 0x14) { |
973 | /* It seems that the RICOH | 979 | /* |
974 | MP6200A CD/RW drive will | 980 | * It seems that the RICOH |
975 | report itself okay as a | 981 | * MP6200A CD/RW drive will |
976 | slave when it is really a | 982 | * report itself okay as a |
977 | master. So this check again | 983 | * slave when it is really a |
978 | as a master device just to | 984 | * master. So this check again |
979 | make sure it doesn't report | 985 | * as a master device just to |
980 | itself okay as a master also | 986 | * make sure it doesn't report |
981 | */ | 987 | * itself okay as a master also |
988 | */ | ||
982 | if ((master_slave & ATA_ADDRESS_DEVHEAD_SLAVE) && | 989 | if ((master_slave & ATA_ADDRESS_DEVHEAD_SLAVE) && |
983 | !recheckAsMaster) { | 990 | !recheckAsMaster) { |
984 | usb_stor_dbg(us, " Identified ATAPI device as slave. Rechecking again as master\n"); | 991 | usb_stor_dbg(us, " Identified ATAPI device as slave. Rechecking again as master\n"); |
@@ -1176,9 +1183,11 @@ static int isd200_get_inquiry_data( struct us_data *us ) | |||
1176 | if (id[ATA_ID_COMMAND_SET_2] & COMMANDSET_MEDIA_STATUS) { | 1183 | if (id[ATA_ID_COMMAND_SET_2] & COMMANDSET_MEDIA_STATUS) { |
1177 | usb_stor_dbg(us, " Device supports Media Status Notification\n"); | 1184 | usb_stor_dbg(us, " Device supports Media Status Notification\n"); |
1178 | 1185 | ||
1179 | /* Indicate that it is enabled, even though it is not | 1186 | /* |
1180 | * This allows the lock/unlock of the media to work | 1187 | * Indicate that it is enabled, even |
1181 | * correctly. | 1188 | * though it is not. |
1189 | * This allows the lock/unlock of the | ||
1190 | * media to work correctly. | ||
1182 | */ | 1191 | */ |
1183 | info->DeviceFlags |= DF_MEDIA_STATUS_ENABLED; | 1192 | info->DeviceFlags |= DF_MEDIA_STATUS_ENABLED; |
1184 | } | 1193 | } |
@@ -1197,7 +1206,7 @@ static int isd200_get_inquiry_data( struct us_data *us ) | |||
1197 | usb_stor_dbg(us, "Protocol changed to: %s\n", | 1206 | usb_stor_dbg(us, "Protocol changed to: %s\n", |
1198 | us->protocol_name); | 1207 | us->protocol_name); |
1199 | 1208 | ||
1200 | /* Free driver structure */ | 1209 | /* Free driver structure */ |
1201 | us->extra_destructor(info); | 1210 | us->extra_destructor(info); |
1202 | kfree(info); | 1211 | kfree(info); |
1203 | us->extra = NULL; | 1212 | us->extra = NULL; |
diff --git a/drivers/usb/storage/jumpshot.c b/drivers/usb/storage/jumpshot.c index ee613e258db0..011e5270690a 100644 --- a/drivers/usb/storage/jumpshot.c +++ b/drivers/usb/storage/jumpshot.c | |||
@@ -1,4 +1,5 @@ | |||
1 | /* Driver for Lexar "Jumpshot" Compact Flash reader | 1 | /* |
2 | * Driver for Lexar "Jumpshot" Compact Flash reader | ||
2 | * | 3 | * |
3 | * jumpshot driver v0.1: | 4 | * jumpshot driver v0.1: |
4 | * | 5 | * |
@@ -618,18 +619,23 @@ static int jumpshot_transport(struct scsi_cmnd *srb, struct us_data *us) | |||
618 | } | 619 | } |
619 | 620 | ||
620 | if (srb->cmnd[0] == ALLOW_MEDIUM_REMOVAL) { | 621 | if (srb->cmnd[0] == ALLOW_MEDIUM_REMOVAL) { |
621 | // sure. whatever. not like we can stop the user from popping | 622 | /* |
622 | // the media out of the device (no locking doors, etc) | 623 | * sure. whatever. not like we can stop the user from popping |
623 | // | 624 | * the media out of the device (no locking doors, etc) |
625 | */ | ||
624 | return USB_STOR_TRANSPORT_GOOD; | 626 | return USB_STOR_TRANSPORT_GOOD; |
625 | } | 627 | } |
626 | 628 | ||
627 | if (srb->cmnd[0] == START_STOP) { | 629 | if (srb->cmnd[0] == START_STOP) { |
628 | /* this is used by sd.c'check_scsidisk_media_change to detect | 630 | /* |
629 | media change */ | 631 | * this is used by sd.c'check_scsidisk_media_change to detect |
632 | * media change | ||
633 | */ | ||
630 | usb_stor_dbg(us, "START_STOP\n"); | 634 | usb_stor_dbg(us, "START_STOP\n"); |
631 | /* the first jumpshot_id_device after a media change returns | 635 | /* |
632 | an error (determined experimentally) */ | 636 | * the first jumpshot_id_device after a media change returns |
637 | * an error (determined experimentally) | ||
638 | */ | ||
633 | rc = jumpshot_id_device(us, info); | 639 | rc = jumpshot_id_device(us, info); |
634 | if (rc == USB_STOR_TRANSPORT_GOOD) { | 640 | if (rc == USB_STOR_TRANSPORT_GOOD) { |
635 | info->sense_key = NO_SENSE; | 641 | info->sense_key = NO_SENSE; |
diff --git a/drivers/usb/storage/karma.c b/drivers/usb/storage/karma.c index ae201e69475c..f9d407f0b508 100644 --- a/drivers/usb/storage/karma.c +++ b/drivers/usb/storage/karma.c | |||
@@ -1,4 +1,5 @@ | |||
1 | /* Driver for Rio Karma | 1 | /* |
2 | * Driver for Rio Karma | ||
2 | * | 3 | * |
3 | * (c) 2006 Bob Copeland <me@bobcopeland.com> | 4 | * (c) 2006 Bob Copeland <me@bobcopeland.com> |
4 | * (c) 2006 Keith Bennett <keith@mcs.st-and.ac.uk> | 5 | * (c) 2006 Keith Bennett <keith@mcs.st-and.ac.uk> |
diff --git a/drivers/usb/storage/option_ms.c b/drivers/usb/storage/option_ms.c index b2b35b1d7de8..57282f12317b 100644 --- a/drivers/usb/storage/option_ms.c +++ b/drivers/usb/storage/option_ms.c | |||
@@ -65,7 +65,8 @@ static int option_rezero(struct us_data *us) | |||
65 | goto out; | 65 | goto out; |
66 | } | 66 | } |
67 | 67 | ||
68 | /* Some of the devices need to be asked for a response, but we don't | 68 | /* |
69 | * Some of the devices need to be asked for a response, but we don't | ||
69 | * care what that response is. | 70 | * care what that response is. |
70 | */ | 71 | */ |
71 | usb_stor_bulk_transfer_buf(us, | 72 | usb_stor_bulk_transfer_buf(us, |
@@ -140,7 +141,8 @@ int option_ms_init(struct us_data *us) | |||
140 | 141 | ||
141 | usb_stor_dbg(us, "Option MS: %s\n", "option_ms_init called"); | 142 | usb_stor_dbg(us, "Option MS: %s\n", "option_ms_init called"); |
142 | 143 | ||
143 | /* Additional test for vendor information via INQUIRY, | 144 | /* |
145 | * Additional test for vendor information via INQUIRY, | ||
144 | * because some vendor/product IDs are ambiguous | 146 | * because some vendor/product IDs are ambiguous |
145 | */ | 147 | */ |
146 | result = option_inquiry(us); | 148 | result = option_inquiry(us); |
diff --git a/drivers/usb/storage/protocol.c b/drivers/usb/storage/protocol.c index 12e3c2fac642..74c38870a17e 100644 --- a/drivers/usb/storage/protocol.c +++ b/drivers/usb/storage/protocol.c | |||
@@ -1,4 +1,5 @@ | |||
1 | /* Driver for USB Mass Storage compliant devices | 1 | /* |
2 | * Driver for USB Mass Storage compliant devices | ||
2 | * | 3 | * |
3 | * Current development and maintenance by: | 4 | * Current development and maintenance by: |
4 | * (c) 1999-2002 Matthew Dharm (mdharm-usb@one-eyed-alien.net) | 5 | * (c) 1999-2002 Matthew Dharm (mdharm-usb@one-eyed-alien.net) |
@@ -75,7 +76,8 @@ void usb_stor_pad12_command(struct scsi_cmnd *srb, struct us_data *us) | |||
75 | 76 | ||
76 | void usb_stor_ufi_command(struct scsi_cmnd *srb, struct us_data *us) | 77 | void usb_stor_ufi_command(struct scsi_cmnd *srb, struct us_data *us) |
77 | { | 78 | { |
78 | /* fix some commands -- this is a form of mode translation | 79 | /* |
80 | * fix some commands -- this is a form of mode translation | ||
79 | * UFI devices only accept 12 byte long commands | 81 | * UFI devices only accept 12 byte long commands |
80 | * | 82 | * |
81 | * NOTE: This only works because a scsi_cmnd struct field contains | 83 | * NOTE: This only works because a scsi_cmnd struct field contains |
@@ -127,7 +129,8 @@ EXPORT_SYMBOL_GPL(usb_stor_transparent_scsi_command); | |||
127 | * Scatter-gather transfer buffer access routines | 129 | * Scatter-gather transfer buffer access routines |
128 | ***********************************************************************/ | 130 | ***********************************************************************/ |
129 | 131 | ||
130 | /* Copy a buffer of length buflen to/from the srb's transfer buffer. | 132 | /* |
133 | * Copy a buffer of length buflen to/from the srb's transfer buffer. | ||
131 | * Update the **sgptr and *offset variables so that the next copy will | 134 | * Update the **sgptr and *offset variables so that the next copy will |
132 | * pick up from where this one left off. | 135 | * pick up from where this one left off. |
133 | */ | 136 | */ |
@@ -175,7 +178,8 @@ unsigned int usb_stor_access_xfer_buf(unsigned char *buffer, | |||
175 | } | 178 | } |
176 | EXPORT_SYMBOL_GPL(usb_stor_access_xfer_buf); | 179 | EXPORT_SYMBOL_GPL(usb_stor_access_xfer_buf); |
177 | 180 | ||
178 | /* Store the contents of buffer into srb's transfer buffer and set the | 181 | /* |
182 | * Store the contents of buffer into srb's transfer buffer and set the | ||
179 | * SCSI residue. | 183 | * SCSI residue. |
180 | */ | 184 | */ |
181 | void usb_stor_set_xfer_buf(unsigned char *buffer, | 185 | void usb_stor_set_xfer_buf(unsigned char *buffer, |
diff --git a/drivers/usb/storage/protocol.h b/drivers/usb/storage/protocol.h index ffc3e2af0156..a55666880b7b 100644 --- a/drivers/usb/storage/protocol.h +++ b/drivers/usb/storage/protocol.h | |||
@@ -1,4 +1,5 @@ | |||
1 | /* Driver for USB Mass Storage compliant devices | 1 | /* |
2 | * Driver for USB Mass Storage compliant devices | ||
2 | * Protocol Functions Header File | 3 | * Protocol Functions Header File |
3 | * | 4 | * |
4 | * Current development and maintenance by: | 5 | * Current development and maintenance by: |
diff --git a/drivers/usb/storage/realtek_cr.c b/drivers/usb/storage/realtek_cr.c index 20433563a601..4176d1af9bf2 100644 --- a/drivers/usb/storage/realtek_cr.c +++ b/drivers/usb/storage/realtek_cr.c | |||
@@ -1,4 +1,5 @@ | |||
1 | /* Driver for Realtek RTS51xx USB card reader | 1 | /* |
2 | * Driver for Realtek RTS51xx USB card reader | ||
2 | * | 3 | * |
3 | * Copyright(c) 2009 Realtek Semiconductor Corp. All rights reserved. | 4 | * Copyright(c) 2009 Realtek Semiconductor Corp. All rights reserved. |
4 | * | 5 | * |
@@ -267,8 +268,10 @@ static int rts51x_bulk_transport(struct us_data *us, u8 lun, | |||
267 | if (bcs->Tag != us->tag) | 268 | if (bcs->Tag != us->tag) |
268 | return USB_STOR_TRANSPORT_ERROR; | 269 | return USB_STOR_TRANSPORT_ERROR; |
269 | 270 | ||
270 | /* try to compute the actual residue, based on how much data | 271 | /* |
271 | * was really transferred and what the device tells us */ | 272 | * try to compute the actual residue, based on how much data |
273 | * was really transferred and what the device tells us | ||
274 | */ | ||
272 | if (residue) | 275 | if (residue) |
273 | residue = residue < buf_len ? residue : buf_len; | 276 | residue = residue < buf_len ? residue : buf_len; |
274 | 277 | ||
@@ -286,7 +289,8 @@ static int rts51x_bulk_transport(struct us_data *us, u8 lun, | |||
286 | return USB_STOR_TRANSPORT_FAILED; | 289 | return USB_STOR_TRANSPORT_FAILED; |
287 | 290 | ||
288 | case US_BULK_STAT_PHASE: | 291 | case US_BULK_STAT_PHASE: |
289 | /* phase error -- note that a transport reset will be | 292 | /* |
293 | * phase error -- note that a transport reset will be | ||
290 | * invoked by the invoke_transport() function | 294 | * invoked by the invoke_transport() function |
291 | */ | 295 | */ |
292 | return USB_STOR_TRANSPORT_ERROR; | 296 | return USB_STOR_TRANSPORT_ERROR; |
diff --git a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c index ae85861051eb..33eb923df892 100644 --- a/drivers/usb/storage/scsiglue.c +++ b/drivers/usb/storage/scsiglue.c | |||
@@ -1,4 +1,5 @@ | |||
1 | /* Driver for USB Mass Storage compliant devices | 1 | /* |
2 | * Driver for USB Mass Storage compliant devices | ||
2 | * SCSI layer glue code | 3 | * SCSI layer glue code |
3 | * | 4 | * |
4 | * Current development and maintenance by: | 5 | * Current development and maintenance by: |
@@ -58,7 +59,8 @@ | |||
58 | #include "transport.h" | 59 | #include "transport.h" |
59 | #include "protocol.h" | 60 | #include "protocol.h" |
60 | 61 | ||
61 | /* Vendor IDs for companies that seem to include the READ CAPACITY bug | 62 | /* |
63 | * Vendor IDs for companies that seem to include the READ CAPACITY bug | ||
62 | * in all their devices | 64 | * in all their devices |
63 | */ | 65 | */ |
64 | #define VENDOR_ID_NOKIA 0x0421 | 66 | #define VENDOR_ID_NOKIA 0x0421 |
@@ -87,7 +89,8 @@ static int slave_alloc (struct scsi_device *sdev) | |||
87 | */ | 89 | */ |
88 | sdev->inquiry_len = 36; | 90 | sdev->inquiry_len = 36; |
89 | 91 | ||
90 | /* USB has unusual DMA-alignment requirements: Although the | 92 | /* |
93 | * USB has unusual DMA-alignment requirements: Although the | ||
91 | * starting address of each scatter-gather element doesn't matter, | 94 | * starting address of each scatter-gather element doesn't matter, |
92 | * the length of each element except the last must be divisible | 95 | * the length of each element except the last must be divisible |
93 | * by the Bulk maxpacket value. There's currently no way to | 96 | * by the Bulk maxpacket value. There's currently no way to |
@@ -115,7 +118,8 @@ static int slave_configure(struct scsi_device *sdev) | |||
115 | { | 118 | { |
116 | struct us_data *us = host_to_us(sdev->host); | 119 | struct us_data *us = host_to_us(sdev->host); |
117 | 120 | ||
118 | /* Many devices have trouble transferring more than 32KB at a time, | 121 | /* |
122 | * Many devices have trouble transferring more than 32KB at a time, | ||
119 | * while others have trouble with more than 64K. At this time we | 123 | * while others have trouble with more than 64K. At this time we |
120 | * are limiting both to 32K (64 sectores). | 124 | * are limiting both to 32K (64 sectores). |
121 | */ | 125 | */ |
@@ -128,14 +132,22 @@ static int slave_configure(struct scsi_device *sdev) | |||
128 | blk_queue_max_hw_sectors(sdev->request_queue, | 132 | blk_queue_max_hw_sectors(sdev->request_queue, |
129 | max_sectors); | 133 | max_sectors); |
130 | } else if (sdev->type == TYPE_TAPE) { | 134 | } else if (sdev->type == TYPE_TAPE) { |
131 | /* Tapes need much higher max_sector limits, so just | 135 | /* |
136 | * Tapes need much higher max_sector limits, so just | ||
132 | * raise it to the maximum possible (4 GB / 512) and | 137 | * raise it to the maximum possible (4 GB / 512) and |
133 | * let the queue segment size sort out the real limit. | 138 | * let the queue segment size sort out the real limit. |
134 | */ | 139 | */ |
135 | blk_queue_max_hw_sectors(sdev->request_queue, 0x7FFFFF); | 140 | blk_queue_max_hw_sectors(sdev->request_queue, 0x7FFFFF); |
141 | } else if (us->pusb_dev->speed >= USB_SPEED_SUPER) { | ||
142 | /* | ||
143 | * USB3 devices will be limited to 2048 sectors. This gives us | ||
144 | * better throughput on most devices. | ||
145 | */ | ||
146 | blk_queue_max_hw_sectors(sdev->request_queue, 2048); | ||
136 | } | 147 | } |
137 | 148 | ||
138 | /* Some USB host controllers can't do DMA; they have to use PIO. | 149 | /* |
150 | * Some USB host controllers can't do DMA; they have to use PIO. | ||
139 | * They indicate this by setting their dma_mask to NULL. For | 151 | * They indicate this by setting their dma_mask to NULL. For |
140 | * such controllers we need to make sure the block layer sets | 152 | * such controllers we need to make sure the block layer sets |
141 | * up bounce buffers in addressable memory. | 153 | * up bounce buffers in addressable memory. |
@@ -143,17 +155,21 @@ static int slave_configure(struct scsi_device *sdev) | |||
143 | if (!us->pusb_dev->bus->controller->dma_mask) | 155 | if (!us->pusb_dev->bus->controller->dma_mask) |
144 | blk_queue_bounce_limit(sdev->request_queue, BLK_BOUNCE_HIGH); | 156 | blk_queue_bounce_limit(sdev->request_queue, BLK_BOUNCE_HIGH); |
145 | 157 | ||
146 | /* We can't put these settings in slave_alloc() because that gets | 158 | /* |
159 | * We can't put these settings in slave_alloc() because that gets | ||
147 | * called before the device type is known. Consequently these | 160 | * called before the device type is known. Consequently these |
148 | * settings can't be overridden via the scsi devinfo mechanism. */ | 161 | * settings can't be overridden via the scsi devinfo mechanism. |
162 | */ | ||
149 | if (sdev->type == TYPE_DISK) { | 163 | if (sdev->type == TYPE_DISK) { |
150 | 164 | ||
151 | /* Some vendors seem to put the READ CAPACITY bug into | 165 | /* |
166 | * Some vendors seem to put the READ CAPACITY bug into | ||
152 | * all their devices -- primarily makers of cell phones | 167 | * all their devices -- primarily makers of cell phones |
153 | * and digital cameras. Since these devices always use | 168 | * and digital cameras. Since these devices always use |
154 | * flash media and can be expected to have an even number | 169 | * flash media and can be expected to have an even number |
155 | * of sectors, we will always enable the CAPACITY_HEURISTICS | 170 | * of sectors, we will always enable the CAPACITY_HEURISTICS |
156 | * flag unless told otherwise. */ | 171 | * flag unless told otherwise. |
172 | */ | ||
157 | switch (le16_to_cpu(us->pusb_dev->descriptor.idVendor)) { | 173 | switch (le16_to_cpu(us->pusb_dev->descriptor.idVendor)) { |
158 | case VENDOR_ID_NOKIA: | 174 | case VENDOR_ID_NOKIA: |
159 | case VENDOR_ID_NIKON: | 175 | case VENDOR_ID_NIKON: |
@@ -165,28 +181,36 @@ static int slave_configure(struct scsi_device *sdev) | |||
165 | break; | 181 | break; |
166 | } | 182 | } |
167 | 183 | ||
168 | /* Disk-type devices use MODE SENSE(6) if the protocol | 184 | /* |
185 | * Disk-type devices use MODE SENSE(6) if the protocol | ||
169 | * (SubClass) is Transparent SCSI, otherwise they use | 186 | * (SubClass) is Transparent SCSI, otherwise they use |
170 | * MODE SENSE(10). */ | 187 | * MODE SENSE(10). |
188 | */ | ||
171 | if (us->subclass != USB_SC_SCSI && us->subclass != USB_SC_CYP_ATACB) | 189 | if (us->subclass != USB_SC_SCSI && us->subclass != USB_SC_CYP_ATACB) |
172 | sdev->use_10_for_ms = 1; | 190 | sdev->use_10_for_ms = 1; |
173 | 191 | ||
174 | /* Many disks only accept MODE SENSE transfer lengths of | 192 | /* |
175 | * 192 bytes (that's what Windows uses). */ | 193 | *Many disks only accept MODE SENSE transfer lengths of |
194 | * 192 bytes (that's what Windows uses). | ||
195 | */ | ||
176 | sdev->use_192_bytes_for_3f = 1; | 196 | sdev->use_192_bytes_for_3f = 1; |
177 | 197 | ||
178 | /* Some devices don't like MODE SENSE with page=0x3f, | 198 | /* |
199 | * Some devices don't like MODE SENSE with page=0x3f, | ||
179 | * which is the command used for checking if a device | 200 | * which is the command used for checking if a device |
180 | * is write-protected. Now that we tell the sd driver | 201 | * is write-protected. Now that we tell the sd driver |
181 | * to do a 192-byte transfer with this command the | 202 | * to do a 192-byte transfer with this command the |
182 | * majority of devices work fine, but a few still can't | 203 | * majority of devices work fine, but a few still can't |
183 | * handle it. The sd driver will simply assume those | 204 | * handle it. The sd driver will simply assume those |
184 | * devices are write-enabled. */ | 205 | * devices are write-enabled. |
206 | */ | ||
185 | if (us->fflags & US_FL_NO_WP_DETECT) | 207 | if (us->fflags & US_FL_NO_WP_DETECT) |
186 | sdev->skip_ms_page_3f = 1; | 208 | sdev->skip_ms_page_3f = 1; |
187 | 209 | ||
188 | /* A number of devices have problems with MODE SENSE for | 210 | /* |
189 | * page x08, so we will skip it. */ | 211 | * A number of devices have problems with MODE SENSE for |
212 | * page x08, so we will skip it. | ||
213 | */ | ||
190 | sdev->skip_ms_page_8 = 1; | 214 | sdev->skip_ms_page_8 = 1; |
191 | 215 | ||
192 | /* Some devices don't handle VPD pages correctly */ | 216 | /* Some devices don't handle VPD pages correctly */ |
@@ -198,15 +222,19 @@ static int slave_configure(struct scsi_device *sdev) | |||
198 | /* Do not attempt to use WRITE SAME */ | 222 | /* Do not attempt to use WRITE SAME */ |
199 | sdev->no_write_same = 1; | 223 | sdev->no_write_same = 1; |
200 | 224 | ||
201 | /* Some disks return the total number of blocks in response | 225 | /* |
226 | * Some disks return the total number of blocks in response | ||
202 | * to READ CAPACITY rather than the highest block number. | 227 | * to READ CAPACITY rather than the highest block number. |
203 | * If this device makes that mistake, tell the sd driver. */ | 228 | * If this device makes that mistake, tell the sd driver. |
229 | */ | ||
204 | if (us->fflags & US_FL_FIX_CAPACITY) | 230 | if (us->fflags & US_FL_FIX_CAPACITY) |
205 | sdev->fix_capacity = 1; | 231 | sdev->fix_capacity = 1; |
206 | 232 | ||
207 | /* A few disks have two indistinguishable version, one of | 233 | /* |
234 | * A few disks have two indistinguishable version, one of | ||
208 | * which reports the correct capacity and the other does not. | 235 | * which reports the correct capacity and the other does not. |
209 | * The sd driver has to guess which is the case. */ | 236 | * The sd driver has to guess which is the case. |
237 | */ | ||
210 | if (us->fflags & US_FL_CAPACITY_HEURISTICS) | 238 | if (us->fflags & US_FL_CAPACITY_HEURISTICS) |
211 | sdev->guess_capacity = 1; | 239 | sdev->guess_capacity = 1; |
212 | 240 | ||
@@ -227,26 +255,34 @@ static int slave_configure(struct scsi_device *sdev) | |||
227 | if (sdev->scsi_level > SCSI_SPC_2) | 255 | if (sdev->scsi_level > SCSI_SPC_2) |
228 | us->fflags |= US_FL_SANE_SENSE; | 256 | us->fflags |= US_FL_SANE_SENSE; |
229 | 257 | ||
230 | /* USB-IDE bridges tend to report SK = 0x04 (Non-recoverable | 258 | /* |
259 | * USB-IDE bridges tend to report SK = 0x04 (Non-recoverable | ||
231 | * Hardware Error) when any low-level error occurs, | 260 | * Hardware Error) when any low-level error occurs, |
232 | * recoverable or not. Setting this flag tells the SCSI | 261 | * recoverable or not. Setting this flag tells the SCSI |
233 | * midlayer to retry such commands, which frequently will | 262 | * midlayer to retry such commands, which frequently will |
234 | * succeed and fix the error. The worst this can lead to | 263 | * succeed and fix the error. The worst this can lead to |
235 | * is an occasional series of retries that will all fail. */ | 264 | * is an occasional series of retries that will all fail. |
265 | */ | ||
236 | sdev->retry_hwerror = 1; | 266 | sdev->retry_hwerror = 1; |
237 | 267 | ||
238 | /* USB disks should allow restart. Some drives spin down | 268 | /* |
239 | * automatically, requiring a START-STOP UNIT command. */ | 269 | * USB disks should allow restart. Some drives spin down |
270 | * automatically, requiring a START-STOP UNIT command. | ||
271 | */ | ||
240 | sdev->allow_restart = 1; | 272 | sdev->allow_restart = 1; |
241 | 273 | ||
242 | /* Some USB cardreaders have trouble reading an sdcard's last | 274 | /* |
275 | * Some USB cardreaders have trouble reading an sdcard's last | ||
243 | * sector in a larger then 1 sector read, since the performance | 276 | * sector in a larger then 1 sector read, since the performance |
244 | * impact is negligible we set this flag for all USB disks */ | 277 | * impact is negligible we set this flag for all USB disks |
278 | */ | ||
245 | sdev->last_sector_bug = 1; | 279 | sdev->last_sector_bug = 1; |
246 | 280 | ||
247 | /* Enable last-sector hacks for single-target devices using | 281 | /* |
282 | * Enable last-sector hacks for single-target devices using | ||
248 | * the Bulk-only transport, unless we already know the | 283 | * the Bulk-only transport, unless we already know the |
249 | * capacity will be decremented or is correct. */ | 284 | * capacity will be decremented or is correct. |
285 | */ | ||
250 | if (!(us->fflags & (US_FL_FIX_CAPACITY | US_FL_CAPACITY_OK | | 286 | if (!(us->fflags & (US_FL_FIX_CAPACITY | US_FL_CAPACITY_OK | |
251 | US_FL_SCM_MULT_TARG)) && | 287 | US_FL_SCM_MULT_TARG)) && |
252 | us->protocol == USB_PR_BULK) | 288 | us->protocol == USB_PR_BULK) |
@@ -262,9 +298,11 @@ static int slave_configure(struct scsi_device *sdev) | |||
262 | 298 | ||
263 | } else { | 299 | } else { |
264 | 300 | ||
265 | /* Non-disk-type devices don't need to blacklist any pages | 301 | /* |
302 | * Non-disk-type devices don't need to blacklist any pages | ||
266 | * or to force 192-byte transfer lengths for MODE SENSE. | 303 | * or to force 192-byte transfer lengths for MODE SENSE. |
267 | * But they do need to use MODE SENSE(10). */ | 304 | * But they do need to use MODE SENSE(10). |
305 | */ | ||
268 | sdev->use_10_for_ms = 1; | 306 | sdev->use_10_for_ms = 1; |
269 | 307 | ||
270 | /* Some (fake) usb cdrom devices don't like READ_DISC_INFO */ | 308 | /* Some (fake) usb cdrom devices don't like READ_DISC_INFO */ |
@@ -272,7 +310,8 @@ static int slave_configure(struct scsi_device *sdev) | |||
272 | sdev->no_read_disc_info = 1; | 310 | sdev->no_read_disc_info = 1; |
273 | } | 311 | } |
274 | 312 | ||
275 | /* The CB and CBI transports have no way to pass LUN values | 313 | /* |
314 | * The CB and CBI transports have no way to pass LUN values | ||
276 | * other than the bits in the second byte of a CDB. But those | 315 | * other than the bits in the second byte of a CDB. But those |
277 | * bits don't get set to the LUN value if the device reports | 316 | * bits don't get set to the LUN value if the device reports |
278 | * scsi_level == 0 (UNKNOWN). Hence such devices must necessarily | 317 | * scsi_level == 0 (UNKNOWN). Hence such devices must necessarily |
@@ -282,13 +321,17 @@ static int slave_configure(struct scsi_device *sdev) | |||
282 | sdev->scsi_level == SCSI_UNKNOWN) | 321 | sdev->scsi_level == SCSI_UNKNOWN) |
283 | us->max_lun = 0; | 322 | us->max_lun = 0; |
284 | 323 | ||
285 | /* Some devices choke when they receive a PREVENT-ALLOW MEDIUM | 324 | /* |
286 | * REMOVAL command, so suppress those commands. */ | 325 | * Some devices choke when they receive a PREVENT-ALLOW MEDIUM |
326 | * REMOVAL command, so suppress those commands. | ||
327 | */ | ||
287 | if (us->fflags & US_FL_NOT_LOCKABLE) | 328 | if (us->fflags & US_FL_NOT_LOCKABLE) |
288 | sdev->lockable = 0; | 329 | sdev->lockable = 0; |
289 | 330 | ||
290 | /* this is to satisfy the compiler, tho I don't think the | 331 | /* |
291 | * return code is ever checked anywhere. */ | 332 | * this is to satisfy the compiler, tho I don't think the |
333 | * return code is ever checked anywhere. | ||
334 | */ | ||
292 | return 0; | 335 | return 0; |
293 | } | 336 | } |
294 | 337 | ||
@@ -362,8 +405,10 @@ static int command_abort(struct scsi_cmnd *srb) | |||
362 | 405 | ||
363 | usb_stor_dbg(us, "%s called\n", __func__); | 406 | usb_stor_dbg(us, "%s called\n", __func__); |
364 | 407 | ||
365 | /* us->srb together with the TIMED_OUT, RESETTING, and ABORTING | 408 | /* |
366 | * bits are protected by the host lock. */ | 409 | * us->srb together with the TIMED_OUT, RESETTING, and ABORTING |
410 | * bits are protected by the host lock. | ||
411 | */ | ||
367 | scsi_lock(us_to_host(us)); | 412 | scsi_lock(us_to_host(us)); |
368 | 413 | ||
369 | /* Is this command still active? */ | 414 | /* Is this command still active? */ |
@@ -373,11 +418,13 @@ static int command_abort(struct scsi_cmnd *srb) | |||
373 | return FAILED; | 418 | return FAILED; |
374 | } | 419 | } |
375 | 420 | ||
376 | /* Set the TIMED_OUT bit. Also set the ABORTING bit, but only if | 421 | /* |
422 | * Set the TIMED_OUT bit. Also set the ABORTING bit, but only if | ||
377 | * a device reset isn't already in progress (to avoid interfering | 423 | * a device reset isn't already in progress (to avoid interfering |
378 | * with the reset). Note that we must retain the host lock while | 424 | * with the reset). Note that we must retain the host lock while |
379 | * calling usb_stor_stop_transport(); otherwise it might interfere | 425 | * calling usb_stor_stop_transport(); otherwise it might interfere |
380 | * with an auto-reset that begins as soon as we release the lock. */ | 426 | * with an auto-reset that begins as soon as we release the lock. |
427 | */ | ||
381 | set_bit(US_FLIDX_TIMED_OUT, &us->dflags); | 428 | set_bit(US_FLIDX_TIMED_OUT, &us->dflags); |
382 | if (!test_bit(US_FLIDX_RESETTING, &us->dflags)) { | 429 | if (!test_bit(US_FLIDX_RESETTING, &us->dflags)) { |
383 | set_bit(US_FLIDX_ABORTING, &us->dflags); | 430 | set_bit(US_FLIDX_ABORTING, &us->dflags); |
@@ -390,8 +437,10 @@ static int command_abort(struct scsi_cmnd *srb) | |||
390 | return SUCCESS; | 437 | return SUCCESS; |
391 | } | 438 | } |
392 | 439 | ||
393 | /* This invokes the transport reset mechanism to reset the state of the | 440 | /* |
394 | * device */ | 441 | * This invokes the transport reset mechanism to reset the state of the |
442 | * device | ||
443 | */ | ||
395 | static int device_reset(struct scsi_cmnd *srb) | 444 | static int device_reset(struct scsi_cmnd *srb) |
396 | { | 445 | { |
397 | struct us_data *us = host_to_us(srb->device->host); | 446 | struct us_data *us = host_to_us(srb->device->host); |
@@ -419,9 +468,11 @@ static int bus_reset(struct scsi_cmnd *srb) | |||
419 | return result < 0 ? FAILED : SUCCESS; | 468 | return result < 0 ? FAILED : SUCCESS; |
420 | } | 469 | } |
421 | 470 | ||
422 | /* Report a driver-initiated device reset to the SCSI layer. | 471 | /* |
472 | * Report a driver-initiated device reset to the SCSI layer. | ||
423 | * Calling this for a SCSI-initiated reset is unnecessary but harmless. | 473 | * Calling this for a SCSI-initiated reset is unnecessary but harmless. |
424 | * The caller must own the SCSI host lock. */ | 474 | * The caller must own the SCSI host lock. |
475 | */ | ||
425 | void usb_stor_report_device_reset(struct us_data *us) | 476 | void usb_stor_report_device_reset(struct us_data *us) |
426 | { | 477 | { |
427 | int i; | 478 | int i; |
@@ -434,9 +485,11 @@ void usb_stor_report_device_reset(struct us_data *us) | |||
434 | } | 485 | } |
435 | } | 486 | } |
436 | 487 | ||
437 | /* Report a driver-initiated bus reset to the SCSI layer. | 488 | /* |
489 | * Report a driver-initiated bus reset to the SCSI layer. | ||
438 | * Calling this for a SCSI-initiated reset is unnecessary but harmless. | 490 | * Calling this for a SCSI-initiated reset is unnecessary but harmless. |
439 | * The caller must not own the SCSI host lock. */ | 491 | * The caller must not own the SCSI host lock. |
492 | */ | ||
440 | void usb_stor_report_bus_reset(struct us_data *us) | 493 | void usb_stor_report_bus_reset(struct us_data *us) |
441 | { | 494 | { |
442 | struct Scsi_Host *host = us_to_host(us); | 495 | struct Scsi_Host *host = us_to_host(us); |
@@ -565,10 +618,28 @@ static const struct scsi_host_template usb_stor_host_template = { | |||
565 | /* lots of sg segments can be handled */ | 618 | /* lots of sg segments can be handled */ |
566 | .sg_tablesize = SG_MAX_SEGMENTS, | 619 | .sg_tablesize = SG_MAX_SEGMENTS, |
567 | 620 | ||
568 | /* limit the total size of a transfer to 120 KB */ | 621 | |
622 | /* | ||
623 | * Limit the total size of a transfer to 120 KB. | ||
624 | * | ||
625 | * Some devices are known to choke with anything larger. It seems like | ||
626 | * the problem stems from the fact that original IDE controllers had | ||
627 | * only an 8-bit register to hold the number of sectors in one transfer | ||
628 | * and even those couldn't handle a full 256 sectors. | ||
629 | * | ||
630 | * Because we want to make sure we interoperate with as many devices as | ||
631 | * possible, we will maintain a 240 sector transfer size limit for USB | ||
632 | * Mass Storage devices. | ||
633 | * | ||
634 | * Tests show that other operating have similar limits with Microsoft | ||
635 | * Windows 7 limiting transfers to 128 sectors for both USB2 and USB3 | ||
636 | * and Apple Mac OS X 10.11 limiting transfers to 256 sectors for USB2 | ||
637 | * and 2048 for USB3 devices. | ||
638 | */ | ||
569 | .max_sectors = 240, | 639 | .max_sectors = 240, |
570 | 640 | ||
571 | /* merge commands... this seems to help performance, but | 641 | /* |
642 | * merge commands... this seems to help performance, but | ||
572 | * periodically someone should test to see which setting is more | 643 | * periodically someone should test to see which setting is more |
573 | * optimal. | 644 | * optimal. |
574 | */ | 645 | */ |
diff --git a/drivers/usb/storage/scsiglue.h b/drivers/usb/storage/scsiglue.h index 5494d87607fb..d0a331dd9bc5 100644 --- a/drivers/usb/storage/scsiglue.h +++ b/drivers/usb/storage/scsiglue.h | |||
@@ -1,4 +1,5 @@ | |||
1 | /* Driver for USB Mass Storage compliant devices | 1 | /* |
2 | * Driver for USB Mass Storage compliant devices | ||
2 | * SCSI Connecting Glue Header File | 3 | * SCSI Connecting Glue Header File |
3 | * | 4 | * |
4 | * Current development and maintenance by: | 5 | * Current development and maintenance by: |
diff --git a/drivers/usb/storage/sddr09.c b/drivers/usb/storage/sddr09.c index 79224fcf9b59..c5797fa2125e 100644 --- a/drivers/usb/storage/sddr09.c +++ b/drivers/usb/storage/sddr09.c | |||
@@ -1,4 +1,5 @@ | |||
1 | /* Driver for SanDisk SDDR-09 SmartMedia reader | 1 | /* |
2 | * Driver for SanDisk SDDR-09 SmartMedia reader | ||
2 | * | 3 | * |
3 | * (c) 2000, 2001 Robert Baruch (autophile@starband.net) | 4 | * (c) 2000, 2001 Robert Baruch (autophile@starband.net) |
4 | * (c) 2002 Andries Brouwer (aeb@cwi.nl) | 5 | * (c) 2002 Andries Brouwer (aeb@cwi.nl) |
@@ -799,10 +800,12 @@ sddr09_read_data(struct us_data *us, | |||
799 | usb_stor_dbg(us, "Read %d zero pages (LBA %d) page %d\n", | 800 | usb_stor_dbg(us, "Read %d zero pages (LBA %d) page %d\n", |
800 | pages, lba, page); | 801 | pages, lba, page); |
801 | 802 | ||
802 | /* This is not really an error. It just means | 803 | /* |
803 | that the block has never been written. | 804 | * This is not really an error. It just means |
804 | Instead of returning an error | 805 | * that the block has never been written. |
805 | it is better to return all zero data. */ | 806 | * Instead of returning an error |
807 | * it is better to return all zero data. | ||
808 | */ | ||
806 | 809 | ||
807 | memset(buffer, 0, len); | 810 | memset(buffer, 0, len); |
808 | 811 | ||
@@ -890,8 +893,10 @@ sddr09_write_lba(struct us_data *us, unsigned int lba, | |||
890 | } | 893 | } |
891 | 894 | ||
892 | if (pba == 1) { | 895 | if (pba == 1) { |
893 | /* Maybe it is impossible to write to PBA 1. | 896 | /* |
894 | Fake success, but don't do anything. */ | 897 | * Maybe it is impossible to write to PBA 1. |
898 | * Fake success, but don't do anything. | ||
899 | */ | ||
895 | printk(KERN_WARNING "sddr09: avoid writing to pba 1\n"); | 900 | printk(KERN_WARNING "sddr09: avoid writing to pba 1\n"); |
896 | return 0; | 901 | return 0; |
897 | } | 902 | } |
@@ -979,18 +984,22 @@ sddr09_write_data(struct us_data *us, | |||
979 | struct scatterlist *sg; | 984 | struct scatterlist *sg; |
980 | int result; | 985 | int result; |
981 | 986 | ||
982 | // Figure out the initial LBA and page | 987 | /* Figure out the initial LBA and page */ |
983 | lba = address >> info->blockshift; | 988 | lba = address >> info->blockshift; |
984 | page = (address & info->blockmask); | 989 | page = (address & info->blockmask); |
985 | maxlba = info->capacity >> (info->pageshift + info->blockshift); | 990 | maxlba = info->capacity >> (info->pageshift + info->blockshift); |
986 | if (lba >= maxlba) | 991 | if (lba >= maxlba) |
987 | return -EIO; | 992 | return -EIO; |
988 | 993 | ||
989 | // blockbuffer is used for reading in the old data, overwriting | 994 | /* |
990 | // with the new data, and performing ECC calculations | 995 | * blockbuffer is used for reading in the old data, overwriting |
996 | * with the new data, and performing ECC calculations | ||
997 | */ | ||
991 | 998 | ||
992 | /* TODO: instead of doing kmalloc/kfree for each write, | 999 | /* |
993 | add a bufferpointer to the info structure */ | 1000 | * TODO: instead of doing kmalloc/kfree for each write, |
1001 | * add a bufferpointer to the info structure | ||
1002 | */ | ||
994 | 1003 | ||
995 | pagelen = (1 << info->pageshift) + (1 << CONTROL_SHIFT); | 1004 | pagelen = (1 << info->pageshift) + (1 << CONTROL_SHIFT); |
996 | blocklen = (pagelen << info->blockshift); | 1005 | blocklen = (pagelen << info->blockshift); |
@@ -1000,9 +1009,11 @@ sddr09_write_data(struct us_data *us, | |||
1000 | return -ENOMEM; | 1009 | return -ENOMEM; |
1001 | } | 1010 | } |
1002 | 1011 | ||
1003 | // Since we don't write the user data directly to the device, | 1012 | /* |
1004 | // we have to create a bounce buffer and move the data a piece | 1013 | * Since we don't write the user data directly to the device, |
1005 | // at a time between the bounce buffer and the actual transfer buffer. | 1014 | * we have to create a bounce buffer and move the data a piece |
1015 | * at a time between the bounce buffer and the actual transfer buffer. | ||
1016 | */ | ||
1006 | 1017 | ||
1007 | len = min(sectors, (unsigned int) info->blocksize) * info->pagesize; | 1018 | len = min(sectors, (unsigned int) info->blocksize) * info->pagesize; |
1008 | buffer = kmalloc(len, GFP_NOIO); | 1019 | buffer = kmalloc(len, GFP_NOIO); |
@@ -1018,7 +1029,7 @@ sddr09_write_data(struct us_data *us, | |||
1018 | 1029 | ||
1019 | while (sectors > 0) { | 1030 | while (sectors > 0) { |
1020 | 1031 | ||
1021 | // Write as many sectors as possible in this block | 1032 | /* Write as many sectors as possible in this block */ |
1022 | 1033 | ||
1023 | pages = min(sectors, info->blocksize - page); | 1034 | pages = min(sectors, info->blocksize - page); |
1024 | len = (pages << info->pageshift); | 1035 | len = (pages << info->pageshift); |
@@ -1031,7 +1042,7 @@ sddr09_write_data(struct us_data *us, | |||
1031 | break; | 1042 | break; |
1032 | } | 1043 | } |
1033 | 1044 | ||
1034 | // Get the data from the transfer buffer | 1045 | /* Get the data from the transfer buffer */ |
1035 | usb_stor_access_xfer_buf(buffer, len, us->srb, | 1046 | usb_stor_access_xfer_buf(buffer, len, us->srb, |
1036 | &sg, &offset, FROM_XFER_BUF); | 1047 | &sg, &offset, FROM_XFER_BUF); |
1037 | 1048 | ||
@@ -1168,9 +1179,11 @@ sddr09_get_cardinfo(struct us_data *us, unsigned char flags) { | |||
1168 | /* Byte 1 is the device type */ | 1179 | /* Byte 1 is the device type */ |
1169 | cardinfo = nand_find_id(deviceID[1]); | 1180 | cardinfo = nand_find_id(deviceID[1]); |
1170 | if (cardinfo) { | 1181 | if (cardinfo) { |
1171 | /* MB or MiB? It is neither. A 16 MB card has | 1182 | /* |
1172 | 17301504 raw bytes, of which 16384000 are | 1183 | * MB or MiB? It is neither. A 16 MB card has |
1173 | usable for user data. */ | 1184 | * 17301504 raw bytes, of which 16384000 are |
1185 | * usable for user data. | ||
1186 | */ | ||
1174 | sprintf(blurbtxt + strlen(blurbtxt), | 1187 | sprintf(blurbtxt + strlen(blurbtxt), |
1175 | ", %d MB", 1<<(cardinfo->chipshift - 20)); | 1188 | ", %d MB", 1<<(cardinfo->chipshift - 20)); |
1176 | } else { | 1189 | } else { |
@@ -1211,14 +1224,18 @@ sddr09_read_map(struct us_data *us) { | |||
1211 | if (!info->capacity) | 1224 | if (!info->capacity) |
1212 | return -1; | 1225 | return -1; |
1213 | 1226 | ||
1214 | // size of a block is 1 << (blockshift + pageshift) bytes | 1227 | /* |
1215 | // divide into the total capacity to get the number of blocks | 1228 | * size of a block is 1 << (blockshift + pageshift) bytes |
1229 | * divide into the total capacity to get the number of blocks | ||
1230 | */ | ||
1216 | 1231 | ||
1217 | numblocks = info->capacity >> (info->blockshift + info->pageshift); | 1232 | numblocks = info->capacity >> (info->blockshift + info->pageshift); |
1218 | 1233 | ||
1219 | // read 64 bytes for every block (actually 1 << CONTROL_SHIFT) | 1234 | /* |
1220 | // but only use a 64 KB buffer | 1235 | * read 64 bytes for every block (actually 1 << CONTROL_SHIFT) |
1221 | // buffer size used must be a multiple of (1 << CONTROL_SHIFT) | 1236 | * but only use a 64 KB buffer |
1237 | * buffer size used must be a multiple of (1 << CONTROL_SHIFT) | ||
1238 | */ | ||
1222 | #define SDDR09_READ_MAP_BUFSZ 65536 | 1239 | #define SDDR09_READ_MAP_BUFSZ 65536 |
1223 | 1240 | ||
1224 | alloc_blocks = min(numblocks, SDDR09_READ_MAP_BUFSZ >> CONTROL_SHIFT); | 1241 | alloc_blocks = min(numblocks, SDDR09_READ_MAP_BUFSZ >> CONTROL_SHIFT); |
@@ -1575,8 +1592,10 @@ static int sddr09_transport(struct scsi_cmnd *srb, struct us_data *us) | |||
1575 | 1592 | ||
1576 | havefakesense = 1; | 1593 | havefakesense = 1; |
1577 | 1594 | ||
1578 | /* Dummy up a response for INQUIRY since SDDR09 doesn't | 1595 | /* |
1579 | respond to INQUIRY commands */ | 1596 | * Dummy up a response for INQUIRY since SDDR09 doesn't |
1597 | * respond to INQUIRY commands | ||
1598 | */ | ||
1580 | 1599 | ||
1581 | if (srb->cmnd[0] == INQUIRY) { | 1600 | if (srb->cmnd[0] == INQUIRY) { |
1582 | memcpy(ptr, inquiry_response, 8); | 1601 | memcpy(ptr, inquiry_response, 8); |
@@ -1628,8 +1647,10 @@ static int sddr09_transport(struct scsi_cmnd *srb, struct us_data *us) | |||
1628 | if (srb->cmnd[0] == MODE_SENSE_10) { | 1647 | if (srb->cmnd[0] == MODE_SENSE_10) { |
1629 | int modepage = (srb->cmnd[2] & 0x3F); | 1648 | int modepage = (srb->cmnd[2] & 0x3F); |
1630 | 1649 | ||
1631 | /* They ask for the Read/Write error recovery page, | 1650 | /* |
1632 | or for all pages. */ | 1651 | * They ask for the Read/Write error recovery page, |
1652 | * or for all pages. | ||
1653 | */ | ||
1633 | /* %% We should check DBD %% */ | 1654 | /* %% We should check DBD %% */ |
1634 | if (modepage == 0x01 || modepage == 0x3F) { | 1655 | if (modepage == 0x01 || modepage == 0x3F) { |
1635 | usb_stor_dbg(us, "Dummy up request for mode page 0x%x\n", | 1656 | usb_stor_dbg(us, "Dummy up request for mode page 0x%x\n", |
@@ -1682,7 +1703,8 @@ static int sddr09_transport(struct scsi_cmnd *srb, struct us_data *us) | |||
1682 | USB_STOR_TRANSPORT_ERROR); | 1703 | USB_STOR_TRANSPORT_ERROR); |
1683 | } | 1704 | } |
1684 | 1705 | ||
1685 | /* catch-all for all other commands, except | 1706 | /* |
1707 | * catch-all for all other commands, except | ||
1686 | * pass TEST_UNIT_READY and REQUEST_SENSE through | 1708 | * pass TEST_UNIT_READY and REQUEST_SENSE through |
1687 | */ | 1709 | */ |
1688 | if (srb->cmnd[0] != TEST_UNIT_READY && | 1710 | if (srb->cmnd[0] != TEST_UNIT_READY && |
diff --git a/drivers/usb/storage/sddr55.c b/drivers/usb/storage/sddr55.c index e5e0a25ecd96..147c50b3e00f 100644 --- a/drivers/usb/storage/sddr55.c +++ b/drivers/usb/storage/sddr55.c | |||
@@ -1,4 +1,5 @@ | |||
1 | /* Driver for SanDisk SDDR-55 SmartMedia reader | 1 | /* |
2 | * Driver for SanDisk SDDR-55 SmartMedia reader | ||
2 | * | 3 | * |
3 | * SDDR55 driver v0.1: | 4 | * SDDR55 driver v0.1: |
4 | * | 5 | * |
@@ -130,7 +131,8 @@ sddr55_bulk_transport(struct us_data *us, int direction, | |||
130 | return usb_stor_bulk_transfer_buf(us, pipe, data, len, NULL); | 131 | return usb_stor_bulk_transfer_buf(us, pipe, data, len, NULL); |
131 | } | 132 | } |
132 | 133 | ||
133 | /* check if card inserted, if there is, update read_only status | 134 | /* |
135 | * check if card inserted, if there is, update read_only status | ||
134 | * return non zero if no card | 136 | * return non zero if no card |
135 | */ | 137 | */ |
136 | 138 | ||
@@ -714,15 +716,18 @@ static int sddr55_read_map(struct us_data *us) { | |||
714 | if (max_lba > 1000) | 716 | if (max_lba > 1000) |
715 | max_lba = 1000; | 717 | max_lba = 1000; |
716 | 718 | ||
717 | // Each block is 64 bytes of control data, so block i is located in | 719 | /* |
718 | // scatterlist block i*64/128k = i*(2^6)*(2^-17) = i*(2^-11) | 720 | * Each block is 64 bytes of control data, so block i is located in |
721 | * scatterlist block i*64/128k = i*(2^6)*(2^-17) = i*(2^-11) | ||
722 | */ | ||
719 | 723 | ||
720 | for (i=0; i<numblocks; i++) { | 724 | for (i=0; i<numblocks; i++) { |
721 | int zone = i / 1024; | 725 | int zone = i / 1024; |
722 | 726 | ||
723 | lba = short_pack(buffer[i * 2], buffer[i * 2 + 1]); | 727 | lba = short_pack(buffer[i * 2], buffer[i * 2 + 1]); |
724 | 728 | ||
725 | /* Every 1024 physical blocks ("zone"), the LBA numbers | 729 | /* |
730 | * Every 1024 physical blocks ("zone"), the LBA numbers | ||
726 | * go back to zero, but are within a higher | 731 | * go back to zero, but are within a higher |
727 | * block of LBA's. Also, there is a maximum of | 732 | * block of LBA's. Also, there is a maximum of |
728 | * 1000 LBA's per zone. In other words, in PBA | 733 | * 1000 LBA's per zone. In other words, in PBA |
@@ -733,7 +738,8 @@ static int sddr55_read_map(struct us_data *us) { | |||
733 | * are 24 spare blocks to use when blocks do go bad. | 738 | * are 24 spare blocks to use when blocks do go bad. |
734 | */ | 739 | */ |
735 | 740 | ||
736 | /* SDDR55 returns 0xffff for a bad block, and 0x400 for the | 741 | /* |
742 | * SDDR55 returns 0xffff for a bad block, and 0x400 for the | ||
737 | * CIS block. (Is this true for cards 8MB or less??) | 743 | * CIS block. (Is this true for cards 8MB or less??) |
738 | * Record these in the physical to logical map | 744 | * Record these in the physical to logical map |
739 | */ | 745 | */ |
@@ -824,8 +830,10 @@ static int sddr55_transport(struct scsi_cmnd *srb, struct us_data *us) | |||
824 | 830 | ||
825 | memset (info->sense_data, 0, sizeof info->sense_data); | 831 | memset (info->sense_data, 0, sizeof info->sense_data); |
826 | 832 | ||
827 | /* Dummy up a response for INQUIRY since SDDR55 doesn't | 833 | /* |
828 | respond to INQUIRY commands */ | 834 | * Dummy up a response for INQUIRY since SDDR55 doesn't |
835 | * respond to INQUIRY commands | ||
836 | */ | ||
829 | 837 | ||
830 | if (srb->cmnd[0] == INQUIRY) { | 838 | if (srb->cmnd[0] == INQUIRY) { |
831 | memcpy(ptr, inquiry_response, 8); | 839 | memcpy(ptr, inquiry_response, 8); |
@@ -833,7 +841,8 @@ static int sddr55_transport(struct scsi_cmnd *srb, struct us_data *us) | |||
833 | return USB_STOR_TRANSPORT_GOOD; | 841 | return USB_STOR_TRANSPORT_GOOD; |
834 | } | 842 | } |
835 | 843 | ||
836 | /* only check card status if the map isn't allocated, ie no card seen yet | 844 | /* |
845 | * only check card status if the map isn't allocated, ie no card seen yet | ||
837 | * or if it's been over half a second since we last accessed it | 846 | * or if it's been over half a second since we last accessed it |
838 | */ | 847 | */ |
839 | if (info->lba_to_pba == NULL || time_after(jiffies, info->last_access + HZ/2)) { | 848 | if (info->lba_to_pba == NULL || time_after(jiffies, info->last_access + HZ/2)) { |
@@ -849,8 +858,10 @@ static int sddr55_transport(struct scsi_cmnd *srb, struct us_data *us) | |||
849 | } | 858 | } |
850 | } | 859 | } |
851 | 860 | ||
852 | /* if we detected a problem with the map when writing, | 861 | /* |
853 | don't allow any more access */ | 862 | * if we detected a problem with the map when writing, |
863 | * don't allow any more access | ||
864 | */ | ||
854 | if (info->fatal_error) { | 865 | if (info->fatal_error) { |
855 | 866 | ||
856 | set_sense_info (3, 0x31, 0); | 867 | set_sense_info (3, 0x31, 0); |
@@ -868,12 +879,16 @@ static int sddr55_transport(struct scsi_cmnd *srb, struct us_data *us) | |||
868 | 879 | ||
869 | info->capacity = capacity; | 880 | info->capacity = capacity; |
870 | 881 | ||
871 | /* figure out the maximum logical block number, allowing for | 882 | /* |
872 | * the fact that only 250 out of every 256 are used */ | 883 | * figure out the maximum logical block number, allowing for |
884 | * the fact that only 250 out of every 256 are used | ||
885 | */ | ||
873 | info->max_log_blks = ((info->capacity >> (info->pageshift + info->blockshift)) / 256) * 250; | 886 | info->max_log_blks = ((info->capacity >> (info->pageshift + info->blockshift)) / 256) * 250; |
874 | 887 | ||
875 | /* Last page in the card, adjust as we only use 250 out of | 888 | /* |
876 | * every 256 pages */ | 889 | * Last page in the card, adjust as we only use 250 out of |
890 | * every 256 pages | ||
891 | */ | ||
877 | capacity = (capacity / 256) * 250; | 892 | capacity = (capacity / 256) * 250; |
878 | 893 | ||
879 | capacity /= PAGESIZE; | 894 | capacity /= PAGESIZE; |
diff --git a/drivers/usb/storage/shuttle_usbat.c b/drivers/usb/storage/shuttle_usbat.c index a3ec86b913a1..3b0294e4df93 100644 --- a/drivers/usb/storage/shuttle_usbat.c +++ b/drivers/usb/storage/shuttle_usbat.c | |||
@@ -1,4 +1,5 @@ | |||
1 | /* Driver for SCM Microsystems (a.k.a. Shuttle) USB-ATAPI cable | 1 | /* |
2 | * Driver for SCM Microsystems (a.k.a. Shuttle) USB-ATAPI cable | ||
2 | * | 3 | * |
3 | * Current development and maintenance by: | 4 | * Current development and maintenance by: |
4 | * (c) 2000, 2001 Robert Baruch (autophile@starband.net) | 5 | * (c) 2000, 2001 Robert Baruch (autophile@starband.net) |
@@ -408,7 +409,8 @@ static int usbat_wait_not_busy(struct us_data *us, int minutes) | |||
408 | int result; | 409 | int result; |
409 | unsigned char *status = us->iobuf; | 410 | unsigned char *status = us->iobuf; |
410 | 411 | ||
411 | /* Synchronizing cache on a CDR could take a heck of a long time, | 412 | /* |
413 | * Synchronizing cache on a CDR could take a heck of a long time, | ||
412 | * but probably not more than 10 minutes or so. On the other hand, | 414 | * but probably not more than 10 minutes or so. On the other hand, |
413 | * doing a full blank on a CDRW at speed 1 will take about 75 | 415 | * doing a full blank on a CDRW at speed 1 will take about 75 |
414 | * minutes! | 416 | * minutes! |
@@ -1570,9 +1572,10 @@ static int usbat_hp8200e_transport(struct scsi_cmnd *srb, struct us_data *us) | |||
1570 | 1572 | ||
1571 | len = scsi_bufflen(srb); | 1573 | len = scsi_bufflen(srb); |
1572 | 1574 | ||
1573 | /* Send A0 (ATA PACKET COMMAND). | 1575 | /* |
1574 | Note: I guess we're never going to get any of the ATA | 1576 | * Send A0 (ATA PACKET COMMAND). |
1575 | commands... just ATA Packet Commands. | 1577 | * Note: I guess we're never going to get any of the ATA |
1578 | * commands... just ATA Packet Commands. | ||
1576 | */ | 1579 | */ |
1577 | 1580 | ||
1578 | registers[0] = USBAT_ATA_FEATURES; | 1581 | registers[0] = USBAT_ATA_FEATURES; |
@@ -1851,7 +1854,8 @@ static int usbat_probe(struct usb_interface *intf, | |||
1851 | if (result) | 1854 | if (result) |
1852 | return result; | 1855 | return result; |
1853 | 1856 | ||
1854 | /* The actual transport will be determined later by the | 1857 | /* |
1858 | * The actual transport will be determined later by the | ||
1855 | * initialization routine; this is just a placeholder. | 1859 | * initialization routine; this is just a placeholder. |
1856 | */ | 1860 | */ |
1857 | us->transport_name = "Shuttle USBAT"; | 1861 | us->transport_name = "Shuttle USBAT"; |
diff --git a/drivers/usb/storage/sierra_ms.c b/drivers/usb/storage/sierra_ms.c index 2ea657be14c8..9a51019ac7b2 100644 --- a/drivers/usb/storage/sierra_ms.c +++ b/drivers/usb/storage/sierra_ms.c | |||
@@ -177,7 +177,8 @@ int sierra_ms_init(struct us_data *us) | |||
177 | 177 | ||
178 | debug_swoc(&us->pusb_dev->dev, swocInfo); | 178 | debug_swoc(&us->pusb_dev->dev, swocInfo); |
179 | 179 | ||
180 | /* If there is not Linux software on the TRU-Install device | 180 | /* |
181 | * If there is not Linux software on the TRU-Install device | ||
181 | * then switch to modem mode | 182 | * then switch to modem mode |
182 | */ | 183 | */ |
183 | if (!containsFullLinuxPackage(swocInfo)) { | 184 | if (!containsFullLinuxPackage(swocInfo)) { |
diff --git a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c index 5e67f63b2e46..ffd086733421 100644 --- a/drivers/usb/storage/transport.c +++ b/drivers/usb/storage/transport.c | |||
@@ -1,4 +1,5 @@ | |||
1 | /* Driver for USB Mass Storage compliant devices | 1 | /* |
2 | * Driver for USB Mass Storage compliant devices | ||
2 | * | 3 | * |
3 | * Current development and maintenance by: | 4 | * Current development and maintenance by: |
4 | * (c) 1999-2002 Matthew Dharm (mdharm-usb@one-eyed-alien.net) | 5 | * (c) 1999-2002 Matthew Dharm (mdharm-usb@one-eyed-alien.net) |
@@ -109,7 +110,8 @@ | |||
109 | * called more than once or from being called during usb_submit_urb(). | 110 | * called more than once or from being called during usb_submit_urb(). |
110 | */ | 111 | */ |
111 | 112 | ||
112 | /* This is the completion handler which will wake us up when an URB | 113 | /* |
114 | * This is the completion handler which will wake us up when an URB | ||
113 | * completes. | 115 | * completes. |
114 | */ | 116 | */ |
115 | static void usb_stor_blocking_completion(struct urb *urb) | 117 | static void usb_stor_blocking_completion(struct urb *urb) |
@@ -119,7 +121,8 @@ static void usb_stor_blocking_completion(struct urb *urb) | |||
119 | complete(urb_done_ptr); | 121 | complete(urb_done_ptr); |
120 | } | 122 | } |
121 | 123 | ||
122 | /* This is the common part of the URB message submission code | 124 | /* |
125 | * This is the common part of the URB message submission code | ||
123 | * | 126 | * |
124 | * All URBs from the usb-storage driver involved in handling a queued scsi | 127 | * All URBs from the usb-storage driver involved in handling a queued scsi |
125 | * command _must_ pass through this function (or something like it) for the | 128 | * command _must_ pass through this function (or something like it) for the |
@@ -142,10 +145,12 @@ static int usb_stor_msg_common(struct us_data *us, int timeout) | |||
142 | us->current_urb->context = &urb_done; | 145 | us->current_urb->context = &urb_done; |
143 | us->current_urb->transfer_flags = 0; | 146 | us->current_urb->transfer_flags = 0; |
144 | 147 | ||
145 | /* we assume that if transfer_buffer isn't us->iobuf then it | 148 | /* |
149 | * we assume that if transfer_buffer isn't us->iobuf then it | ||
146 | * hasn't been mapped for DMA. Yes, this is clunky, but it's | 150 | * hasn't been mapped for DMA. Yes, this is clunky, but it's |
147 | * easier than always having the caller tell us whether the | 151 | * easier than always having the caller tell us whether the |
148 | * transfer buffer has already been mapped. */ | 152 | * transfer buffer has already been mapped. |
153 | */ | ||
149 | if (us->current_urb->transfer_buffer == us->iobuf) | 154 | if (us->current_urb->transfer_buffer == us->iobuf) |
150 | us->current_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; | 155 | us->current_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; |
151 | us->current_urb->transfer_dma = us->iobuf_dma; | 156 | us->current_urb->transfer_dma = us->iobuf_dma; |
@@ -157,8 +162,10 @@ static int usb_stor_msg_common(struct us_data *us, int timeout) | |||
157 | return status; | 162 | return status; |
158 | } | 163 | } |
159 | 164 | ||
160 | /* since the URB has been submitted successfully, it's now okay | 165 | /* |
161 | * to cancel it */ | 166 | * since the URB has been submitted successfully, it's now okay |
167 | * to cancel it | ||
168 | */ | ||
162 | set_bit(US_FLIDX_URB_ACTIVE, &us->dflags); | 169 | set_bit(US_FLIDX_URB_ACTIVE, &us->dflags); |
163 | 170 | ||
164 | /* did an abort occur during the submission? */ | 171 | /* did an abort occur during the submission? */ |
@@ -220,7 +227,8 @@ int usb_stor_control_msg(struct us_data *us, unsigned int pipe, | |||
220 | } | 227 | } |
221 | EXPORT_SYMBOL_GPL(usb_stor_control_msg); | 228 | EXPORT_SYMBOL_GPL(usb_stor_control_msg); |
222 | 229 | ||
223 | /* This is a version of usb_clear_halt() that allows early termination and | 230 | /* |
231 | * This is a version of usb_clear_halt() that allows early termination and | ||
224 | * doesn't read the status from the device -- this is because some devices | 232 | * doesn't read the status from the device -- this is because some devices |
225 | * crash their internal firmware when the status is requested after a halt. | 233 | * crash their internal firmware when the status is requested after a halt. |
226 | * | 234 | * |
@@ -280,8 +288,10 @@ static int interpret_urb_result(struct us_data *us, unsigned int pipe, | |||
280 | 288 | ||
281 | /* stalled */ | 289 | /* stalled */ |
282 | case -EPIPE: | 290 | case -EPIPE: |
283 | /* for control endpoints, (used by CB[I]) a stall indicates | 291 | /* |
284 | * a failed command */ | 292 | * for control endpoints, (used by CB[I]) a stall indicates |
293 | * a failed command | ||
294 | */ | ||
285 | if (usb_pipecontrol(pipe)) { | 295 | if (usb_pipecontrol(pipe)) { |
286 | usb_stor_dbg(us, "-- stall on control pipe\n"); | 296 | usb_stor_dbg(us, "-- stall on control pipe\n"); |
287 | return USB_STOR_XFER_STALLED; | 297 | return USB_STOR_XFER_STALLED; |
@@ -433,8 +443,10 @@ static int usb_stor_bulk_transfer_sglist(struct us_data *us, unsigned int pipe, | |||
433 | return USB_STOR_XFER_ERROR; | 443 | return USB_STOR_XFER_ERROR; |
434 | } | 444 | } |
435 | 445 | ||
436 | /* since the block has been initialized successfully, it's now | 446 | /* |
437 | * okay to cancel it */ | 447 | * since the block has been initialized successfully, it's now |
448 | * okay to cancel it | ||
449 | */ | ||
438 | set_bit(US_FLIDX_SG_ACTIVE, &us->dflags); | 450 | set_bit(US_FLIDX_SG_ACTIVE, &us->dflags); |
439 | 451 | ||
440 | /* did an abort occur during the submission? */ | 452 | /* did an abort occur during the submission? */ |
@@ -515,7 +527,8 @@ EXPORT_SYMBOL_GPL(usb_stor_bulk_transfer_sg); | |||
515 | * Transport routines | 527 | * Transport routines |
516 | ***********************************************************************/ | 528 | ***********************************************************************/ |
517 | 529 | ||
518 | /* There are so many devices that report the capacity incorrectly, | 530 | /* |
531 | * There are so many devices that report the capacity incorrectly, | ||
519 | * this routine was written to counteract some of the resulting | 532 | * this routine was written to counteract some of the resulting |
520 | * problems. | 533 | * problems. |
521 | */ | 534 | */ |
@@ -533,7 +546,8 @@ static void last_sector_hacks(struct us_data *us, struct scsi_cmnd *srb) | |||
533 | [12] = 0x14 /* Record Not Found */ | 546 | [12] = 0x14 /* Record Not Found */ |
534 | }; | 547 | }; |
535 | 548 | ||
536 | /* If last-sector problems can't occur, whether because the | 549 | /* |
550 | * If last-sector problems can't occur, whether because the | ||
537 | * capacity was already decremented or because the device is | 551 | * capacity was already decremented or because the device is |
538 | * known to report the correct capacity, then we don't need | 552 | * known to report the correct capacity, then we don't need |
539 | * to do anything. | 553 | * to do anything. |
@@ -559,13 +573,15 @@ static void last_sector_hacks(struct us_data *us, struct scsi_cmnd *srb) | |||
559 | 573 | ||
560 | if (srb->result == SAM_STAT_GOOD && scsi_get_resid(srb) == 0) { | 574 | if (srb->result == SAM_STAT_GOOD && scsi_get_resid(srb) == 0) { |
561 | 575 | ||
562 | /* The command succeeded. We know this device doesn't | 576 | /* |
577 | * The command succeeded. We know this device doesn't | ||
563 | * have the last-sector bug, so stop checking it. | 578 | * have the last-sector bug, so stop checking it. |
564 | */ | 579 | */ |
565 | us->use_last_sector_hacks = 0; | 580 | us->use_last_sector_hacks = 0; |
566 | 581 | ||
567 | } else { | 582 | } else { |
568 | /* The command failed. Allow up to 3 retries in case this | 583 | /* |
584 | * The command failed. Allow up to 3 retries in case this | ||
569 | * is some normal sort of failure. After that, assume the | 585 | * is some normal sort of failure. After that, assume the |
570 | * capacity is wrong and we're trying to access the sector | 586 | * capacity is wrong and we're trying to access the sector |
571 | * beyond the end. Replace the result code and sense data | 587 | * beyond the end. Replace the result code and sense data |
@@ -581,7 +597,8 @@ static void last_sector_hacks(struct us_data *us, struct scsi_cmnd *srb) | |||
581 | } | 597 | } |
582 | 598 | ||
583 | done: | 599 | done: |
584 | /* Don't reset the retry counter for TEST UNIT READY commands, | 600 | /* |
601 | * Don't reset the retry counter for TEST UNIT READY commands, | ||
585 | * because they get issued after device resets which might be | 602 | * because they get issued after device resets which might be |
586 | * caused by a failed last-sector access. | 603 | * caused by a failed last-sector access. |
587 | */ | 604 | */ |
@@ -589,7 +606,8 @@ static void last_sector_hacks(struct us_data *us, struct scsi_cmnd *srb) | |||
589 | us->last_sector_retries = 0; | 606 | us->last_sector_retries = 0; |
590 | } | 607 | } |
591 | 608 | ||
592 | /* Invoke the transport and basic error-handling/recovery methods | 609 | /* |
610 | * Invoke the transport and basic error-handling/recovery methods | ||
593 | * | 611 | * |
594 | * This is used by the protocol layers to actually send the message to | 612 | * This is used by the protocol layers to actually send the message to |
595 | * the device and receive the response. | 613 | * the device and receive the response. |
@@ -603,7 +621,8 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us) | |||
603 | scsi_set_resid(srb, 0); | 621 | scsi_set_resid(srb, 0); |
604 | result = us->transport(srb, us); | 622 | result = us->transport(srb, us); |
605 | 623 | ||
606 | /* if the command gets aborted by the higher layers, we need to | 624 | /* |
625 | * if the command gets aborted by the higher layers, we need to | ||
607 | * short-circuit all other processing | 626 | * short-circuit all other processing |
608 | */ | 627 | */ |
609 | if (test_bit(US_FLIDX_TIMED_OUT, &us->dflags)) { | 628 | if (test_bit(US_FLIDX_TIMED_OUT, &us->dflags)) { |
@@ -628,7 +647,8 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us) | |||
628 | 647 | ||
629 | srb->result = SAM_STAT_GOOD; | 648 | srb->result = SAM_STAT_GOOD; |
630 | 649 | ||
631 | /* Determine if we need to auto-sense | 650 | /* |
651 | * Determine if we need to auto-sense | ||
632 | * | 652 | * |
633 | * I normally don't use a flag like this, but it's almost impossible | 653 | * I normally don't use a flag like this, but it's almost impossible |
634 | * to understand what's going on here if I don't. | 654 | * to understand what's going on here if I don't. |
@@ -728,7 +748,8 @@ Retry_Sense: | |||
728 | goto Handle_Errors; | 748 | goto Handle_Errors; |
729 | } | 749 | } |
730 | 750 | ||
731 | /* Some devices claim to support larger sense but fail when | 751 | /* |
752 | * Some devices claim to support larger sense but fail when | ||
732 | * trying to request it. When a transport failure happens | 753 | * trying to request it. When a transport failure happens |
733 | * using US_FS_SANE_SENSE, we always retry with a standard | 754 | * using US_FS_SANE_SENSE, we always retry with a standard |
734 | * (small) sense request. This fixes some USB GSM modems | 755 | * (small) sense request. This fixes some USB GSM modems |
@@ -746,7 +767,8 @@ Retry_Sense: | |||
746 | if (temp_result != USB_STOR_TRANSPORT_GOOD) { | 767 | if (temp_result != USB_STOR_TRANSPORT_GOOD) { |
747 | usb_stor_dbg(us, "-- auto-sense failure\n"); | 768 | usb_stor_dbg(us, "-- auto-sense failure\n"); |
748 | 769 | ||
749 | /* we skip the reset if this happens to be a | 770 | /* |
771 | * we skip the reset if this happens to be a | ||
750 | * multi-target device, since failure of an | 772 | * multi-target device, since failure of an |
751 | * auto-sense is perfectly valid | 773 | * auto-sense is perfectly valid |
752 | */ | 774 | */ |
@@ -756,7 +778,8 @@ Retry_Sense: | |||
756 | return; | 778 | return; |
757 | } | 779 | } |
758 | 780 | ||
759 | /* If the sense data returned is larger than 18-bytes then we | 781 | /* |
782 | * If the sense data returned is larger than 18-bytes then we | ||
760 | * assume this device supports requesting more in the future. | 783 | * assume this device supports requesting more in the future. |
761 | * The response code must be 70h through 73h inclusive. | 784 | * The response code must be 70h through 73h inclusive. |
762 | */ | 785 | */ |
@@ -767,7 +790,8 @@ Retry_Sense: | |||
767 | usb_stor_dbg(us, "-- SANE_SENSE support enabled\n"); | 790 | usb_stor_dbg(us, "-- SANE_SENSE support enabled\n"); |
768 | us->fflags |= US_FL_SANE_SENSE; | 791 | us->fflags |= US_FL_SANE_SENSE; |
769 | 792 | ||
770 | /* Indicate to the user that we truncated their sense | 793 | /* |
794 | * Indicate to the user that we truncated their sense | ||
771 | * because we didn't know it supported larger sense. | 795 | * because we didn't know it supported larger sense. |
772 | */ | 796 | */ |
773 | usb_stor_dbg(us, "-- Sense data truncated to %i from %i\n", | 797 | usb_stor_dbg(us, "-- Sense data truncated to %i from %i\n", |
@@ -795,13 +819,15 @@ Retry_Sense: | |||
795 | SCSI_SENSE_BUFFERSIZE, 4); | 819 | SCSI_SENSE_BUFFERSIZE, 4); |
796 | fm_ili = (scdd ? scdd[3] : srb->sense_buffer[2]) & 0xA0; | 820 | fm_ili = (scdd ? scdd[3] : srb->sense_buffer[2]) & 0xA0; |
797 | 821 | ||
798 | /* We often get empty sense data. This could indicate that | 822 | /* |
823 | * We often get empty sense data. This could indicate that | ||
799 | * everything worked or that there was an unspecified | 824 | * everything worked or that there was an unspecified |
800 | * problem. We have to decide which. | 825 | * problem. We have to decide which. |
801 | */ | 826 | */ |
802 | if (sshdr.sense_key == 0 && sshdr.asc == 0 && sshdr.ascq == 0 && | 827 | if (sshdr.sense_key == 0 && sshdr.asc == 0 && sshdr.ascq == 0 && |
803 | fm_ili == 0) { | 828 | fm_ili == 0) { |
804 | /* If things are really okay, then let's show that. | 829 | /* |
830 | * If things are really okay, then let's show that. | ||
805 | * Zero out the sense buffer so the higher layers | 831 | * Zero out the sense buffer so the higher layers |
806 | * won't realize we did an unsolicited auto-sense. | 832 | * won't realize we did an unsolicited auto-sense. |
807 | */ | 833 | */ |
@@ -809,7 +835,8 @@ Retry_Sense: | |||
809 | srb->result = SAM_STAT_GOOD; | 835 | srb->result = SAM_STAT_GOOD; |
810 | srb->sense_buffer[0] = 0x0; | 836 | srb->sense_buffer[0] = 0x0; |
811 | 837 | ||
812 | /* If there was a problem, report an unspecified | 838 | /* |
839 | * If there was a problem, report an unspecified | ||
813 | * hardware error to prevent the higher layers from | 840 | * hardware error to prevent the higher layers from |
814 | * entering an infinite retry loop. | 841 | * entering an infinite retry loop. |
815 | */ | 842 | */ |
@@ -860,20 +887,26 @@ Retry_Sense: | |||
860 | last_sector_hacks(us, srb); | 887 | last_sector_hacks(us, srb); |
861 | return; | 888 | return; |
862 | 889 | ||
863 | /* Error and abort processing: try to resynchronize with the device | 890 | /* |
891 | * Error and abort processing: try to resynchronize with the device | ||
864 | * by issuing a port reset. If that fails, try a class-specific | 892 | * by issuing a port reset. If that fails, try a class-specific |
865 | * device reset. */ | 893 | * device reset. |
894 | */ | ||
866 | Handle_Errors: | 895 | Handle_Errors: |
867 | 896 | ||
868 | /* Set the RESETTING bit, and clear the ABORTING bit so that | 897 | /* |
869 | * the reset may proceed. */ | 898 | * Set the RESETTING bit, and clear the ABORTING bit so that |
899 | * the reset may proceed. | ||
900 | */ | ||
870 | scsi_lock(us_to_host(us)); | 901 | scsi_lock(us_to_host(us)); |
871 | set_bit(US_FLIDX_RESETTING, &us->dflags); | 902 | set_bit(US_FLIDX_RESETTING, &us->dflags); |
872 | clear_bit(US_FLIDX_ABORTING, &us->dflags); | 903 | clear_bit(US_FLIDX_ABORTING, &us->dflags); |
873 | scsi_unlock(us_to_host(us)); | 904 | scsi_unlock(us_to_host(us)); |
874 | 905 | ||
875 | /* We must release the device lock because the pre_reset routine | 906 | /* |
876 | * will want to acquire it. */ | 907 | * We must release the device lock because the pre_reset routine |
908 | * will want to acquire it. | ||
909 | */ | ||
877 | mutex_unlock(&us->dev_mutex); | 910 | mutex_unlock(&us->dev_mutex); |
878 | result = usb_stor_port_reset(us); | 911 | result = usb_stor_port_reset(us); |
879 | mutex_lock(&us->dev_mutex); | 912 | mutex_lock(&us->dev_mutex); |
@@ -891,10 +924,12 @@ Retry_Sense: | |||
891 | /* Stop the current URB transfer */ | 924 | /* Stop the current URB transfer */ |
892 | void usb_stor_stop_transport(struct us_data *us) | 925 | void usb_stor_stop_transport(struct us_data *us) |
893 | { | 926 | { |
894 | /* If the state machine is blocked waiting for an URB, | 927 | /* |
928 | * If the state machine is blocked waiting for an URB, | ||
895 | * let's wake it up. The test_and_clear_bit() call | 929 | * let's wake it up. The test_and_clear_bit() call |
896 | * guarantees that if a URB has just been submitted, | 930 | * guarantees that if a URB has just been submitted, |
897 | * it won't be cancelled more than once. */ | 931 | * it won't be cancelled more than once. |
932 | */ | ||
898 | if (test_and_clear_bit(US_FLIDX_URB_ACTIVE, &us->dflags)) { | 933 | if (test_and_clear_bit(US_FLIDX_URB_ACTIVE, &us->dflags)) { |
899 | usb_stor_dbg(us, "-- cancelling URB\n"); | 934 | usb_stor_dbg(us, "-- cancelling URB\n"); |
900 | usb_unlink_urb(us->current_urb); | 935 | usb_unlink_urb(us->current_urb); |
@@ -955,7 +990,8 @@ int usb_stor_CB_transport(struct scsi_cmnd *srb, struct us_data *us) | |||
955 | 990 | ||
956 | /* STATUS STAGE */ | 991 | /* STATUS STAGE */ |
957 | 992 | ||
958 | /* NOTE: CB does not have a status stage. Silly, I know. So | 993 | /* |
994 | * NOTE: CB does not have a status stage. Silly, I know. So | ||
959 | * we have to catch this at a higher level. | 995 | * we have to catch this at a higher level. |
960 | */ | 996 | */ |
961 | if (us->protocol != USB_PR_CBI) | 997 | if (us->protocol != USB_PR_CBI) |
@@ -967,7 +1003,8 @@ int usb_stor_CB_transport(struct scsi_cmnd *srb, struct us_data *us) | |||
967 | if (result != USB_STOR_XFER_GOOD) | 1003 | if (result != USB_STOR_XFER_GOOD) |
968 | return USB_STOR_TRANSPORT_ERROR; | 1004 | return USB_STOR_TRANSPORT_ERROR; |
969 | 1005 | ||
970 | /* UFI gives us ASC and ASCQ, like a request sense | 1006 | /* |
1007 | * UFI gives us ASC and ASCQ, like a request sense | ||
971 | * | 1008 | * |
972 | * REQUEST_SENSE and INQUIRY don't affect the sense data on UFI | 1009 | * REQUEST_SENSE and INQUIRY don't affect the sense data on UFI |
973 | * devices, so we ignore the information for those commands. Note | 1010 | * devices, so we ignore the information for those commands. Note |
@@ -983,7 +1020,8 @@ int usb_stor_CB_transport(struct scsi_cmnd *srb, struct us_data *us) | |||
983 | return USB_STOR_TRANSPORT_GOOD; | 1020 | return USB_STOR_TRANSPORT_GOOD; |
984 | } | 1021 | } |
985 | 1022 | ||
986 | /* If not UFI, we interpret the data as a result code | 1023 | /* |
1024 | * If not UFI, we interpret the data as a result code | ||
987 | * The first byte should always be a 0x0. | 1025 | * The first byte should always be a 0x0. |
988 | * | 1026 | * |
989 | * Some bogus devices don't follow that rule. They stuff the ASC | 1027 | * Some bogus devices don't follow that rule. They stuff the ASC |
@@ -1005,7 +1043,8 @@ int usb_stor_CB_transport(struct scsi_cmnd *srb, struct us_data *us) | |||
1005 | } | 1043 | } |
1006 | return USB_STOR_TRANSPORT_ERROR; | 1044 | return USB_STOR_TRANSPORT_ERROR; |
1007 | 1045 | ||
1008 | /* the CBI spec requires that the bulk pipe must be cleared | 1046 | /* |
1047 | * the CBI spec requires that the bulk pipe must be cleared | ||
1009 | * following any data-in/out command failure (section 2.4.3.1.3) | 1048 | * following any data-in/out command failure (section 2.4.3.1.3) |
1010 | */ | 1049 | */ |
1011 | Failed: | 1050 | Failed: |
@@ -1107,9 +1146,11 @@ int usb_stor_Bulk_transport(struct scsi_cmnd *srb, struct us_data *us) | |||
1107 | /* DATA STAGE */ | 1146 | /* DATA STAGE */ |
1108 | /* send/receive data payload, if there is any */ | 1147 | /* send/receive data payload, if there is any */ |
1109 | 1148 | ||
1110 | /* Some USB-IDE converter chips need a 100us delay between the | 1149 | /* |
1150 | * Some USB-IDE converter chips need a 100us delay between the | ||
1111 | * command phase and the data phase. Some devices need a little | 1151 | * command phase and the data phase. Some devices need a little |
1112 | * more than that, probably because of clock rate inaccuracies. */ | 1152 | * more than that, probably because of clock rate inaccuracies. |
1153 | */ | ||
1113 | if (unlikely(us->fflags & US_FL_GO_SLOW)) | 1154 | if (unlikely(us->fflags & US_FL_GO_SLOW)) |
1114 | usleep_range(125, 150); | 1155 | usleep_range(125, 150); |
1115 | 1156 | ||
@@ -1121,7 +1162,8 @@ int usb_stor_Bulk_transport(struct scsi_cmnd *srb, struct us_data *us) | |||
1121 | if (result == USB_STOR_XFER_ERROR) | 1162 | if (result == USB_STOR_XFER_ERROR) |
1122 | return USB_STOR_TRANSPORT_ERROR; | 1163 | return USB_STOR_TRANSPORT_ERROR; |
1123 | 1164 | ||
1124 | /* If the device tried to send back more data than the | 1165 | /* |
1166 | * If the device tried to send back more data than the | ||
1125 | * amount requested, the spec requires us to transfer | 1167 | * amount requested, the spec requires us to transfer |
1126 | * the CSW anyway. Since there's no point retrying the | 1168 | * the CSW anyway. Since there's no point retrying the |
1127 | * the command, we'll return fake sense data indicating | 1169 | * the command, we'll return fake sense data indicating |
@@ -1156,7 +1198,8 @@ int usb_stor_Bulk_transport(struct scsi_cmnd *srb, struct us_data *us) | |||
1156 | } | 1198 | } |
1157 | } | 1199 | } |
1158 | 1200 | ||
1159 | /* See flow chart on pg 15 of the Bulk Only Transport spec for | 1201 | /* |
1202 | * See flow chart on pg 15 of the Bulk Only Transport spec for | ||
1160 | * an explanation of how this code works. | 1203 | * an explanation of how this code works. |
1161 | */ | 1204 | */ |
1162 | 1205 | ||
@@ -1165,7 +1208,8 @@ int usb_stor_Bulk_transport(struct scsi_cmnd *srb, struct us_data *us) | |||
1165 | result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, | 1208 | result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, |
1166 | bcs, US_BULK_CS_WRAP_LEN, &cswlen); | 1209 | bcs, US_BULK_CS_WRAP_LEN, &cswlen); |
1167 | 1210 | ||
1168 | /* Some broken devices add unnecessary zero-length packets to the | 1211 | /* |
1212 | * Some broken devices add unnecessary zero-length packets to the | ||
1169 | * end of their data transfers. Such packets show up as 0-length | 1213 | * end of their data transfers. Such packets show up as 0-length |
1170 | * CSWs. If we encounter such a thing, try to read the CSW again. | 1214 | * CSWs. If we encounter such a thing, try to read the CSW again. |
1171 | */ | 1215 | */ |
@@ -1201,7 +1245,8 @@ int usb_stor_Bulk_transport(struct scsi_cmnd *srb, struct us_data *us) | |||
1201 | return USB_STOR_TRANSPORT_ERROR; | 1245 | return USB_STOR_TRANSPORT_ERROR; |
1202 | } | 1246 | } |
1203 | 1247 | ||
1204 | /* Some broken devices report odd signatures, so we do not check them | 1248 | /* |
1249 | * Some broken devices report odd signatures, so we do not check them | ||
1205 | * for validity against the spec. We store the first one we see, | 1250 | * for validity against the spec. We store the first one we see, |
1206 | * and check subsequent transfers for validity against this signature. | 1251 | * and check subsequent transfers for validity against this signature. |
1207 | */ | 1252 | */ |
@@ -1217,11 +1262,14 @@ int usb_stor_Bulk_transport(struct scsi_cmnd *srb, struct us_data *us) | |||
1217 | return USB_STOR_TRANSPORT_ERROR; | 1262 | return USB_STOR_TRANSPORT_ERROR; |
1218 | } | 1263 | } |
1219 | 1264 | ||
1220 | /* try to compute the actual residue, based on how much data | 1265 | /* |
1221 | * was really transferred and what the device tells us */ | 1266 | * try to compute the actual residue, based on how much data |
1267 | * was really transferred and what the device tells us | ||
1268 | */ | ||
1222 | if (residue && !(us->fflags & US_FL_IGNORE_RESIDUE)) { | 1269 | if (residue && !(us->fflags & US_FL_IGNORE_RESIDUE)) { |
1223 | 1270 | ||
1224 | /* Heuristically detect devices that generate bogus residues | 1271 | /* |
1272 | * Heuristically detect devices that generate bogus residues | ||
1225 | * by seeing what happens with INQUIRY and READ CAPACITY | 1273 | * by seeing what happens with INQUIRY and READ CAPACITY |
1226 | * commands. | 1274 | * commands. |
1227 | */ | 1275 | */ |
@@ -1259,7 +1307,8 @@ int usb_stor_Bulk_transport(struct scsi_cmnd *srb, struct us_data *us) | |||
1259 | return USB_STOR_TRANSPORT_FAILED; | 1307 | return USB_STOR_TRANSPORT_FAILED; |
1260 | 1308 | ||
1261 | case US_BULK_STAT_PHASE: | 1309 | case US_BULK_STAT_PHASE: |
1262 | /* phase error -- note that a transport reset will be | 1310 | /* |
1311 | * phase error -- note that a transport reset will be | ||
1263 | * invoked by the invoke_transport() function | 1312 | * invoked by the invoke_transport() function |
1264 | */ | 1313 | */ |
1265 | return USB_STOR_TRANSPORT_ERROR; | 1314 | return USB_STOR_TRANSPORT_ERROR; |
@@ -1274,7 +1323,8 @@ EXPORT_SYMBOL_GPL(usb_stor_Bulk_transport); | |||
1274 | * Reset routines | 1323 | * Reset routines |
1275 | ***********************************************************************/ | 1324 | ***********************************************************************/ |
1276 | 1325 | ||
1277 | /* This is the common part of the device reset code. | 1326 | /* |
1327 | * This is the common part of the device reset code. | ||
1278 | * | 1328 | * |
1279 | * It's handy that every transport mechanism uses the control endpoint for | 1329 | * It's handy that every transport mechanism uses the control endpoint for |
1280 | * resets. | 1330 | * resets. |
@@ -1302,8 +1352,10 @@ static int usb_stor_reset_common(struct us_data *us, | |||
1302 | return result; | 1352 | return result; |
1303 | } | 1353 | } |
1304 | 1354 | ||
1305 | /* Give the device some time to recover from the reset, | 1355 | /* |
1306 | * but don't delay disconnect processing. */ | 1356 | * Give the device some time to recover from the reset, |
1357 | * but don't delay disconnect processing. | ||
1358 | */ | ||
1307 | wait_event_interruptible_timeout(us->delay_wait, | 1359 | wait_event_interruptible_timeout(us->delay_wait, |
1308 | test_bit(US_FLIDX_DISCONNECTING, &us->dflags), | 1360 | test_bit(US_FLIDX_DISCONNECTING, &us->dflags), |
1309 | HZ*6); | 1361 | HZ*6); |
@@ -1328,8 +1380,7 @@ static int usb_stor_reset_common(struct us_data *us, | |||
1328 | return result; | 1380 | return result; |
1329 | } | 1381 | } |
1330 | 1382 | ||
1331 | /* This issues a CB[I] Reset to the device in question | 1383 | /* This issues a CB[I] Reset to the device in question */ |
1332 | */ | ||
1333 | #define CB_RESET_CMD_SIZE 12 | 1384 | #define CB_RESET_CMD_SIZE 12 |
1334 | 1385 | ||
1335 | int usb_stor_CB_reset(struct us_data *us) | 1386 | int usb_stor_CB_reset(struct us_data *us) |
@@ -1343,7 +1394,8 @@ int usb_stor_CB_reset(struct us_data *us) | |||
1343 | } | 1394 | } |
1344 | EXPORT_SYMBOL_GPL(usb_stor_CB_reset); | 1395 | EXPORT_SYMBOL_GPL(usb_stor_CB_reset); |
1345 | 1396 | ||
1346 | /* This issues a Bulk-only Reset to the device in question, including | 1397 | /* |
1398 | * This issues a Bulk-only Reset to the device in question, including | ||
1347 | * clearing the subsequent endpoint halts that may occur. | 1399 | * clearing the subsequent endpoint halts that may occur. |
1348 | */ | 1400 | */ |
1349 | int usb_stor_Bulk_reset(struct us_data *us) | 1401 | int usb_stor_Bulk_reset(struct us_data *us) |
@@ -1354,7 +1406,8 @@ int usb_stor_Bulk_reset(struct us_data *us) | |||
1354 | } | 1406 | } |
1355 | EXPORT_SYMBOL_GPL(usb_stor_Bulk_reset); | 1407 | EXPORT_SYMBOL_GPL(usb_stor_Bulk_reset); |
1356 | 1408 | ||
1357 | /* Issue a USB port reset to the device. The caller must not hold | 1409 | /* |
1410 | * Issue a USB port reset to the device. The caller must not hold | ||
1358 | * us->dev_mutex. | 1411 | * us->dev_mutex. |
1359 | */ | 1412 | */ |
1360 | int usb_stor_port_reset(struct us_data *us) | 1413 | int usb_stor_port_reset(struct us_data *us) |
diff --git a/drivers/usb/storage/transport.h b/drivers/usb/storage/transport.h index 9369d752d419..dae3ecd2e6cf 100644 --- a/drivers/usb/storage/transport.h +++ b/drivers/usb/storage/transport.h | |||
@@ -1,4 +1,5 @@ | |||
1 | /* Driver for USB Mass Storage compliant devices | 1 | /* |
2 | * Driver for USB Mass Storage compliant devices | ||
2 | * Transport Functions Header File | 3 | * Transport Functions Header File |
3 | * | 4 | * |
4 | * Current development and maintenance by: | 5 | * Current development and maintenance by: |
diff --git a/drivers/usb/storage/uas.c b/drivers/usb/storage/uas.c index 16bc679dc2fc..4d49fce406e1 100644 --- a/drivers/usb/storage/uas.c +++ b/drivers/usb/storage/uas.c | |||
@@ -799,7 +799,8 @@ static int uas_slave_alloc(struct scsi_device *sdev) | |||
799 | 799 | ||
800 | sdev->hostdata = devinfo; | 800 | sdev->hostdata = devinfo; |
801 | 801 | ||
802 | /* USB has unusual DMA-alignment requirements: Although the | 802 | /* |
803 | * USB has unusual DMA-alignment requirements: Although the | ||
803 | * starting address of each scatter-gather element doesn't matter, | 804 | * starting address of each scatter-gather element doesn't matter, |
804 | * the length of each element except the last must be divisible | 805 | * the length of each element except the last must be divisible |
805 | * by the Bulk maxpacket value. There's currently no way to | 806 | * by the Bulk maxpacket value. There's currently no way to |
diff --git a/drivers/usb/storage/unusual_alauda.h b/drivers/usb/storage/unusual_alauda.h index fa3e9edaa2cf..763bc03032a1 100644 --- a/drivers/usb/storage/unusual_alauda.h +++ b/drivers/usb/storage/unusual_alauda.h | |||
@@ -1,4 +1,5 @@ | |||
1 | /* Unusual Devices File for the Alauda-based card readers | 1 | /* |
2 | * Unusual Devices File for the Alauda-based card readers | ||
2 | * | 3 | * |
3 | * This program is free software; you can redistribute it and/or modify it | 4 | * This program is free software; you can redistribute it and/or modify it |
4 | * under the terms of the GNU General Public License as published by the | 5 | * under the terms of the GNU General Public License as published by the |
diff --git a/drivers/usb/storage/unusual_cypress.h b/drivers/usb/storage/unusual_cypress.h index 82e8ed0324e3..e9a2eb88869a 100644 --- a/drivers/usb/storage/unusual_cypress.h +++ b/drivers/usb/storage/unusual_cypress.h | |||
@@ -1,4 +1,5 @@ | |||
1 | /* Unusual Devices File for devices based on the Cypress USB/ATA bridge | 1 | /* |
2 | * Unusual Devices File for devices based on the Cypress USB/ATA bridge | ||
2 | * with support for ATACB | 3 | * with support for ATACB |
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or modify it |
diff --git a/drivers/usb/storage/unusual_datafab.h b/drivers/usb/storage/unusual_datafab.h index 582a603c78be..5049b6bbe5d5 100644 --- a/drivers/usb/storage/unusual_datafab.h +++ b/drivers/usb/storage/unusual_datafab.h | |||
@@ -1,4 +1,5 @@ | |||
1 | /* Unusual Devices File for the Datafab USB Compact Flash reader | 1 | /* |
2 | * Unusual Devices File for the Datafab USB Compact Flash reader | ||
2 | * | 3 | * |
3 | * This program is free software; you can redistribute it and/or modify it | 4 | * This program is free software; you can redistribute it and/or modify it |
4 | * under the terms of the GNU General Public License as published by the | 5 | * under the terms of the GNU General Public License as published by the |
@@ -79,7 +80,8 @@ UNUSUAL_DEV( 0x07c4, 0xa109, 0x0000, 0xffff, | |||
79 | USB_SC_SCSI, USB_PR_DATAFAB, NULL, | 80 | USB_SC_SCSI, USB_PR_DATAFAB, NULL, |
80 | 0), | 81 | 0), |
81 | 82 | ||
82 | /* Reported by Felix Moeller <felix@derklecks.de> | 83 | /* |
84 | * Reported by Felix Moeller <felix@derklecks.de> | ||
83 | * in Germany this is sold by Hama with the productnumber 46952 | 85 | * in Germany this is sold by Hama with the productnumber 46952 |
84 | * as "DualSlot CompactFlash(TM) & MStick Drive USB" | 86 | * as "DualSlot CompactFlash(TM) & MStick Drive USB" |
85 | */ | 87 | */ |
diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h index 7ffe4209067b..aa3539238848 100644 --- a/drivers/usb/storage/unusual_devs.h +++ b/drivers/usb/storage/unusual_devs.h | |||
@@ -1,4 +1,5 @@ | |||
1 | /* Driver for USB Mass Storage compliant devices | 1 | /* |
2 | * Driver for USB Mass Storage compliant devices | ||
2 | * Unusual Devices File | 3 | * Unusual Devices File |
3 | * | 4 | * |
4 | * Current development and maintenance by: | 5 | * Current development and maintenance by: |
@@ -25,13 +26,15 @@ | |||
25 | * 675 Mass Ave, Cambridge, MA 02139, USA. | 26 | * 675 Mass Ave, Cambridge, MA 02139, USA. |
26 | */ | 27 | */ |
27 | 28 | ||
28 | /* IMPORTANT NOTE: This file must be included in another file which does | 29 | /* |
30 | * IMPORTANT NOTE: This file must be included in another file which does | ||
29 | * the following thing for it to work: | 31 | * the following thing for it to work: |
30 | * The UNUSUAL_DEV, COMPLIANT_DEV, and USUAL_DEV macros must be defined | 32 | * The UNUSUAL_DEV, COMPLIANT_DEV, and USUAL_DEV macros must be defined |
31 | * before this file is included. | 33 | * before this file is included. |
32 | */ | 34 | */ |
33 | 35 | ||
34 | /* If you edit this file, please try to keep it sorted first by VendorID, | 36 | /* |
37 | * If you edit this file, please try to keep it sorted first by VendorID, | ||
35 | * then by ProductID. | 38 | * then by ProductID. |
36 | * | 39 | * |
37 | * If you want to add an entry for this file, be sure to include the | 40 | * If you want to add an entry for this file, be sure to include the |
@@ -47,13 +50,15 @@ | |||
47 | * <usb-storage@lists.one-eyed-alien.net> | 50 | * <usb-storage@lists.one-eyed-alien.net> |
48 | */ | 51 | */ |
49 | 52 | ||
50 | /* Note: If you add an entry only in order to set the CAPACITY_OK flag, | 53 | /* |
54 | * Note: If you add an entry only in order to set the CAPACITY_OK flag, | ||
51 | * use the COMPLIANT_DEV macro instead of UNUSUAL_DEV. This is | 55 | * use the COMPLIANT_DEV macro instead of UNUSUAL_DEV. This is |
52 | * because such entries mark devices which actually work correctly, | 56 | * because such entries mark devices which actually work correctly, |
53 | * as opposed to devices that do something strangely or wrongly. | 57 | * as opposed to devices that do something strangely or wrongly. |
54 | */ | 58 | */ |
55 | 59 | ||
56 | /* In-kernel mode switching is deprecated. Do not add new devices to | 60 | /* |
61 | * In-kernel mode switching is deprecated. Do not add new devices to | ||
57 | * this list for the sole purpose of switching them to a different | 62 | * this list for the sole purpose of switching them to a different |
58 | * mode. Existing userspace solutions are superior. | 63 | * mode. Existing userspace solutions are superior. |
59 | * | 64 | * |
@@ -66,8 +71,7 @@ | |||
66 | #define NO_SDDR09 | 71 | #define NO_SDDR09 |
67 | #endif | 72 | #endif |
68 | 73 | ||
69 | /* patch submitted by Vivian Bregier <Vivian.Bregier@imag.fr> | 74 | /* patch submitted by Vivian Bregier <Vivian.Bregier@imag.fr> */ |
70 | */ | ||
71 | UNUSUAL_DEV( 0x03eb, 0x2002, 0x0100, 0x0100, | 75 | UNUSUAL_DEV( 0x03eb, 0x2002, 0x0100, 0x0100, |
72 | "ATMEL", | 76 | "ATMEL", |
73 | "SND1 Storage", | 77 | "SND1 Storage", |
@@ -93,7 +97,8 @@ UNUSUAL_DEV( 0x03f0, 0x070c, 0x0000, 0x0000, | |||
93 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, | 97 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, |
94 | US_FL_SANE_SENSE ), | 98 | US_FL_SANE_SENSE ), |
95 | 99 | ||
96 | /* Reported by Grant Grundler <grundler@parisc-linux.org> | 100 | /* |
101 | * Reported by Grant Grundler <grundler@parisc-linux.org> | ||
97 | * HP r707 camera in "Disk" mode with 2.00.23 or 2.00.24 firmware. | 102 | * HP r707 camera in "Disk" mode with 2.00.23 or 2.00.24 firmware. |
98 | */ | 103 | */ |
99 | UNUSUAL_DEV( 0x03f0, 0x4002, 0x0001, 0x0001, | 104 | UNUSUAL_DEV( 0x03f0, 0x4002, 0x0001, 0x0001, |
@@ -107,7 +112,8 @@ UNUSUAL_DEV( 0x03f3, 0x0001, 0x0000, 0x9999, | |||
107 | USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_euscsi_init, | 112 | USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_euscsi_init, |
108 | US_FL_SCM_MULT_TARG ), | 113 | US_FL_SCM_MULT_TARG ), |
109 | 114 | ||
110 | /* Reported by Sebastian Kapfer <sebastian_kapfer@gmx.net> | 115 | /* |
116 | * Reported by Sebastian Kapfer <sebastian_kapfer@gmx.net> | ||
111 | * and Olaf Hering <olh@suse.de> (different bcd's, same vendor/product) | 117 | * and Olaf Hering <olh@suse.de> (different bcd's, same vendor/product) |
112 | * for USB floppies that need the SINGLE_LUN enforcement. | 118 | * for USB floppies that need the SINGLE_LUN enforcement. |
113 | */ | 119 | */ |
@@ -124,7 +130,8 @@ UNUSUAL_DEV( 0x040d, 0x6205, 0x0003, 0x0003, | |||
124 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, | 130 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, |
125 | US_FL_IGNORE_RESIDUE ), | 131 | US_FL_IGNORE_RESIDUE ), |
126 | 132 | ||
127 | /* Deduced by Jonathan Woithe <jwoithe@just42.net> | 133 | /* |
134 | * Deduced by Jonathan Woithe <jwoithe@just42.net> | ||
128 | * Entry needed for flags: US_FL_FIX_INQUIRY because initial inquiry message | 135 | * Entry needed for flags: US_FL_FIX_INQUIRY because initial inquiry message |
129 | * always fails and confuses drive. | 136 | * always fails and confuses drive. |
130 | */ | 137 | */ |
@@ -167,8 +174,10 @@ UNUSUAL_DEV( 0x0420, 0x0001, 0x0100, 0x0100, | |||
167 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, | 174 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, |
168 | US_FL_IGNORE_RESIDUE ), | 175 | US_FL_IGNORE_RESIDUE ), |
169 | 176 | ||
170 | /* Reported by Andrew Nayenko <relan@bk.ru> | 177 | /* |
171 | * Updated for new firmware by Phillip Potter <phillipinda@hotmail.com> */ | 178 | * Reported by Andrew Nayenko <relan@bk.ru> |
179 | * Updated for new firmware by Phillip Potter <phillipinda@hotmail.com> | ||
180 | */ | ||
172 | UNUSUAL_DEV( 0x0421, 0x0019, 0x0592, 0x0610, | 181 | UNUSUAL_DEV( 0x0421, 0x0019, 0x0592, 0x0610, |
173 | "Nokia", | 182 | "Nokia", |
174 | "Nokia 6288", | 183 | "Nokia 6288", |
@@ -196,16 +205,20 @@ UNUSUAL_DEV( 0x0421, 0x0434, 0x0100, 0x0100, | |||
196 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, | 205 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, |
197 | US_FL_FIX_CAPACITY | US_FL_IGNORE_RESIDUE ), | 206 | US_FL_FIX_CAPACITY | US_FL_IGNORE_RESIDUE ), |
198 | 207 | ||
199 | /* Reported by Sumedha Swamy <sumedhaswamy@gmail.com> and | 208 | /* |
200 | * Einar Th. Einarsson <einarthered@gmail.com> */ | 209 | * Reported by Sumedha Swamy <sumedhaswamy@gmail.com> and |
210 | * Einar Th. Einarsson <einarthered@gmail.com> | ||
211 | */ | ||
201 | UNUSUAL_DEV( 0x0421, 0x0444, 0x0100, 0x0100, | 212 | UNUSUAL_DEV( 0x0421, 0x0444, 0x0100, 0x0100, |
202 | "Nokia", | 213 | "Nokia", |
203 | "N91", | 214 | "N91", |
204 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, | 215 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, |
205 | US_FL_IGNORE_RESIDUE | US_FL_FIX_CAPACITY ), | 216 | US_FL_IGNORE_RESIDUE | US_FL_FIX_CAPACITY ), |
206 | 217 | ||
207 | /* Reported by Jiri Slaby <jirislaby@gmail.com> and | 218 | /* |
208 | * Rene C. Castberg <Rene@Castberg.org> */ | 219 | * Reported by Jiri Slaby <jirislaby@gmail.com> and |
220 | * Rene C. Castberg <Rene@Castberg.org> | ||
221 | */ | ||
209 | UNUSUAL_DEV( 0x0421, 0x0446, 0x0100, 0x0100, | 222 | UNUSUAL_DEV( 0x0421, 0x0446, 0x0100, 0x0100, |
210 | "Nokia", | 223 | "Nokia", |
211 | "N80", | 224 | "N80", |
@@ -269,8 +282,10 @@ UNUSUAL_DEV( 0x0436, 0x0005, 0x0100, 0x0100, | |||
269 | US_FL_SINGLE_LUN ), | 282 | US_FL_SINGLE_LUN ), |
270 | #endif | 283 | #endif |
271 | 284 | ||
272 | /* Patch submitted by Daniel Drake <dsd@gentoo.org> | 285 | /* |
273 | * Device reports nonsense bInterfaceProtocol 6 when connected over USB2 */ | 286 | * Patch submitted by Daniel Drake <dsd@gentoo.org> |
287 | * Device reports nonsense bInterfaceProtocol 6 when connected over USB2 | ||
288 | */ | ||
274 | UNUSUAL_DEV( 0x0451, 0x5416, 0x0100, 0x0100, | 289 | UNUSUAL_DEV( 0x0451, 0x5416, 0x0100, 0x0100, |
275 | "Neuros Audio", | 290 | "Neuros Audio", |
276 | "USB 2.0 HD 2.5", | 291 | "USB 2.0 HD 2.5", |
@@ -288,17 +303,18 @@ UNUSUAL_DEV( 0x0457, 0x0150, 0x0100, 0x0100, | |||
288 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, US_FL_NOT_LOCKABLE ), | 303 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, US_FL_NOT_LOCKABLE ), |
289 | 304 | ||
290 | /* | 305 | /* |
291 | * Bohdan Linda <bohdan.linda@gmail.com> | 306 | * Bohdan Linda <bohdan.linda@gmail.com> |
292 | * 1GB USB sticks MyFlash High Speed. I have restricted | 307 | * 1GB USB sticks MyFlash High Speed. I have restricted |
293 | * the revision to my model only | 308 | * the revision to my model only |
294 | */ | 309 | */ |
295 | UNUSUAL_DEV( 0x0457, 0x0151, 0x0100, 0x0100, | 310 | UNUSUAL_DEV( 0x0457, 0x0151, 0x0100, 0x0100, |
296 | "USB 2.0", | 311 | "USB 2.0", |
297 | "Flash Disk", | 312 | "Flash Disk", |
298 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, | 313 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, |
299 | US_FL_NOT_LOCKABLE ), | 314 | US_FL_NOT_LOCKABLE ), |
300 | 315 | ||
301 | /* Reported by Tamas Kerecsen <kerecsen@bigfoot.com> | 316 | /* |
317 | * Reported by Tamas Kerecsen <kerecsen@bigfoot.com> | ||
302 | * Obviously the PROM has not been customized by the VAR; | 318 | * Obviously the PROM has not been customized by the VAR; |
303 | * the Vendor and Product string descriptors are: | 319 | * the Vendor and Product string descriptors are: |
304 | * Generic Mass Storage (PROTOTYPE--Remember to change idVendor) | 320 | * Generic Mass Storage (PROTOTYPE--Remember to change idVendor) |
@@ -347,24 +363,30 @@ UNUSUAL_DEV( 0x0482, 0x0107, 0x0100, 0x0100, | |||
347 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, | 363 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, |
348 | US_FL_FIX_CAPACITY | US_FL_NOT_LOCKABLE), | 364 | US_FL_FIX_CAPACITY | US_FL_NOT_LOCKABLE), |
349 | 365 | ||
350 | /* Reported by Paul Stewart <stewart@wetlogic.net> | 366 | /* |
351 | * This entry is needed because the device reports Sub=ff */ | 367 | * Reported by Paul Stewart <stewart@wetlogic.net> |
368 | * This entry is needed because the device reports Sub=ff | ||
369 | */ | ||
352 | UNUSUAL_DEV( 0x04a4, 0x0004, 0x0001, 0x0001, | 370 | UNUSUAL_DEV( 0x04a4, 0x0004, 0x0001, 0x0001, |
353 | "Hitachi", | 371 | "Hitachi", |
354 | "DVD-CAM DZ-MV100A Camcorder", | 372 | "DVD-CAM DZ-MV100A Camcorder", |
355 | USB_SC_SCSI, USB_PR_CB, NULL, US_FL_SINGLE_LUN), | 373 | USB_SC_SCSI, USB_PR_CB, NULL, US_FL_SINGLE_LUN), |
356 | 374 | ||
357 | /* BENQ DC5330 | 375 | /* |
376 | * BENQ DC5330 | ||
358 | * Reported by Manuel Fombuena <mfombuena@ya.com> and | 377 | * Reported by Manuel Fombuena <mfombuena@ya.com> and |
359 | * Frank Copeland <fjc@thingy.apana.org.au> */ | 378 | * Frank Copeland <fjc@thingy.apana.org.au> |
379 | */ | ||
360 | UNUSUAL_DEV( 0x04a5, 0x3010, 0x0100, 0x0100, | 380 | UNUSUAL_DEV( 0x04a5, 0x3010, 0x0100, 0x0100, |
361 | "Tekom Technologies, Inc", | 381 | "Tekom Technologies, Inc", |
362 | "300_CAMERA", | 382 | "300_CAMERA", |
363 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, | 383 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, |
364 | US_FL_IGNORE_RESIDUE ), | 384 | US_FL_IGNORE_RESIDUE ), |
365 | 385 | ||
366 | /* Patch for Nikon coolpix 2000 | 386 | /* |
367 | * Submitted by Fabien Cosse <fabien.cosse@wanadoo.fr>*/ | 387 | * Patch for Nikon coolpix 2000 |
388 | * Submitted by Fabien Cosse <fabien.cosse@wanadoo.fr> | ||
389 | */ | ||
368 | UNUSUAL_DEV( 0x04b0, 0x0301, 0x0010, 0x0010, | 390 | UNUSUAL_DEV( 0x04b0, 0x0301, 0x0010, 0x0010, |
369 | "NIKON", | 391 | "NIKON", |
370 | "NIKON DSC E2000", | 392 | "NIKON DSC E2000", |
@@ -378,21 +400,26 @@ UNUSUAL_DEV( 0x04b3, 0x4001, 0x0110, 0x0110, | |||
378 | USB_SC_DEVICE, USB_PR_CB, NULL, | 400 | USB_SC_DEVICE, USB_PR_CB, NULL, |
379 | US_FL_MAX_SECTORS_MIN), | 401 | US_FL_MAX_SECTORS_MIN), |
380 | 402 | ||
381 | /* Reported by Simon Levitt <simon@whattf.com> | 403 | /* |
382 | * This entry needs Sub and Proto fields */ | 404 | * Reported by Simon Levitt <simon@whattf.com> |
405 | * This entry needs Sub and Proto fields | ||
406 | */ | ||
383 | UNUSUAL_DEV( 0x04b8, 0x0601, 0x0100, 0x0100, | 407 | UNUSUAL_DEV( 0x04b8, 0x0601, 0x0100, 0x0100, |
384 | "Epson", | 408 | "Epson", |
385 | "875DC Storage", | 409 | "875DC Storage", |
386 | USB_SC_SCSI, USB_PR_CB, NULL, US_FL_FIX_INQUIRY), | 410 | USB_SC_SCSI, USB_PR_CB, NULL, US_FL_FIX_INQUIRY), |
387 | 411 | ||
388 | /* Reported by Khalid Aziz <khalid@gonehiking.org> | 412 | /* |
389 | * This entry is needed because the device reports Sub=ff */ | 413 | * Reported by Khalid Aziz <khalid@gonehiking.org> |
414 | * This entry is needed because the device reports Sub=ff | ||
415 | */ | ||
390 | UNUSUAL_DEV( 0x04b8, 0x0602, 0x0110, 0x0110, | 416 | UNUSUAL_DEV( 0x04b8, 0x0602, 0x0110, 0x0110, |
391 | "Epson", | 417 | "Epson", |
392 | "785EPX Storage", | 418 | "785EPX Storage", |
393 | USB_SC_SCSI, USB_PR_BULK, NULL, US_FL_SINGLE_LUN), | 419 | USB_SC_SCSI, USB_PR_BULK, NULL, US_FL_SINGLE_LUN), |
394 | 420 | ||
395 | /* Not sure who reported this originally but | 421 | /* |
422 | * Not sure who reported this originally but | ||
396 | * Pavel Machek <pavel@ucw.cz> reported that the extra US_FL_SINGLE_LUN | 423 | * Pavel Machek <pavel@ucw.cz> reported that the extra US_FL_SINGLE_LUN |
397 | * flag be added */ | 424 | * flag be added */ |
398 | UNUSUAL_DEV( 0x04cb, 0x0100, 0x0000, 0x2210, | 425 | UNUSUAL_DEV( 0x04cb, 0x0100, 0x0000, 0x2210, |
@@ -400,7 +427,8 @@ UNUSUAL_DEV( 0x04cb, 0x0100, 0x0000, 0x2210, | |||
400 | "FinePix 1400Zoom", | 427 | "FinePix 1400Zoom", |
401 | USB_SC_UFI, USB_PR_DEVICE, NULL, US_FL_FIX_INQUIRY | US_FL_SINGLE_LUN), | 428 | USB_SC_UFI, USB_PR_DEVICE, NULL, US_FL_FIX_INQUIRY | US_FL_SINGLE_LUN), |
402 | 429 | ||
403 | /* Reported by Ondrej Zary <linux@rainbow-software.org> | 430 | /* |
431 | * Reported by Ondrej Zary <linux@rainbow-software.org> | ||
404 | * The device reports one sector more and breaks when that sector is accessed | 432 | * The device reports one sector more and breaks when that sector is accessed |
405 | */ | 433 | */ |
406 | UNUSUAL_DEV( 0x04ce, 0x0002, 0x026c, 0x026c, | 434 | UNUSUAL_DEV( 0x04ce, 0x0002, 0x026c, 0x026c, |
@@ -409,7 +437,8 @@ UNUSUAL_DEV( 0x04ce, 0x0002, 0x026c, 0x026c, | |||
409 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, | 437 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, |
410 | US_FL_FIX_CAPACITY), | 438 | US_FL_FIX_CAPACITY), |
411 | 439 | ||
412 | /* Reported by Kriston Fincher <kriston@airmail.net> | 440 | /* |
441 | * Reported by Kriston Fincher <kriston@airmail.net> | ||
413 | * Patch submitted by Sean Millichamp <sean@bruenor.org> | 442 | * Patch submitted by Sean Millichamp <sean@bruenor.org> |
414 | * This is to support the Panasonic PalmCam PV-SD4090 | 443 | * This is to support the Panasonic PalmCam PV-SD4090 |
415 | * This entry is needed because the device reports Sub=ff | 444 | * This entry is needed because the device reports Sub=ff |
@@ -419,8 +448,10 @@ UNUSUAL_DEV( 0x04da, 0x0901, 0x0100, 0x0200, | |||
419 | "LS-120 Camera", | 448 | "LS-120 Camera", |
420 | USB_SC_UFI, USB_PR_DEVICE, NULL, 0), | 449 | USB_SC_UFI, USB_PR_DEVICE, NULL, 0), |
421 | 450 | ||
422 | /* From Yukihiro Nakai, via zaitcev@yahoo.com. | 451 | /* |
423 | * This is needed for CB instead of CBI */ | 452 | * From Yukihiro Nakai, via zaitcev@yahoo.com. |
453 | * This is needed for CB instead of CBI | ||
454 | */ | ||
424 | UNUSUAL_DEV( 0x04da, 0x0d05, 0x0000, 0x0000, | 455 | UNUSUAL_DEV( 0x04da, 0x0d05, 0x0000, 0x0000, |
425 | "Sharp CE-CW05", | 456 | "Sharp CE-CW05", |
426 | "CD-R/RW Drive", | 457 | "CD-R/RW Drive", |
@@ -440,7 +471,8 @@ UNUSUAL_DEV( 0x04da, 0x2373, 0x0000, 0x9999, | |||
440 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, | 471 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, |
441 | US_FL_FIX_CAPACITY | US_FL_NOT_LOCKABLE ), | 472 | US_FL_FIX_CAPACITY | US_FL_NOT_LOCKABLE ), |
442 | 473 | ||
443 | /* Most of the following entries were developed with the help of | 474 | /* |
475 | * Most of the following entries were developed with the help of | ||
444 | * Shuttle/SCM directly. | 476 | * Shuttle/SCM directly. |
445 | */ | 477 | */ |
446 | UNUSUAL_DEV( 0x04e6, 0x0001, 0x0200, 0x0200, | 478 | UNUSUAL_DEV( 0x04e6, 0x0001, 0x0200, 0x0200, |
@@ -536,7 +568,8 @@ UNUSUAL_DEV( 0x04e8, 0x5136, 0x0000, 0x9999, | |||
536 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, | 568 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, |
537 | US_FL_MAX_SECTORS_64), | 569 | US_FL_MAX_SECTORS_64), |
538 | 570 | ||
539 | /* Entry and supporting patch by Theodore Kilgore <kilgota@auburn.edu>. | 571 | /* |
572 | * Entry and supporting patch by Theodore Kilgore <kilgota@auburn.edu>. | ||
540 | * Device uses standards-violating 32-byte Bulk Command Block Wrappers and | 573 | * Device uses standards-violating 32-byte Bulk Command Block Wrappers and |
541 | * reports itself as "Proprietary SCSI Bulk." Cf. device entry 0x084d:0x0011. | 574 | * reports itself as "Proprietary SCSI Bulk." Cf. device entry 0x084d:0x0011. |
542 | */ | 575 | */ |
@@ -553,7 +586,8 @@ UNUSUAL_DEV( 0x050d, 0x0115, 0x0133, 0x0133, | |||
553 | USB_SC_SCSI, USB_PR_BULK, usb_stor_euscsi_init, | 586 | USB_SC_SCSI, USB_PR_BULK, usb_stor_euscsi_init, |
554 | US_FL_SCM_MULT_TARG ), | 587 | US_FL_SCM_MULT_TARG ), |
555 | 588 | ||
556 | /* Iomega Clik! Drive | 589 | /* |
590 | * Iomega Clik! Drive | ||
557 | * Reported by David Chatenay <dchatenay@hotmail.com> | 591 | * Reported by David Chatenay <dchatenay@hotmail.com> |
558 | * The reason this is needed is not fully known. | 592 | * The reason this is needed is not fully known. |
559 | */ | 593 | */ |
@@ -570,7 +604,8 @@ COMPLIANT_DEV(0x0525, 0xa4a5, 0x0000, 0x9999, | |||
570 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, | 604 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, |
571 | US_FL_CAPACITY_OK ), | 605 | US_FL_CAPACITY_OK ), |
572 | 606 | ||
573 | /* Yakumo Mega Image 37 | 607 | /* |
608 | * Yakumo Mega Image 37 | ||
574 | * Submitted by Stephan Fuhrmann <atomenergie@t-online.de> */ | 609 | * Submitted by Stephan Fuhrmann <atomenergie@t-online.de> */ |
575 | UNUSUAL_DEV( 0x052b, 0x1801, 0x0100, 0x0100, | 610 | UNUSUAL_DEV( 0x052b, 0x1801, 0x0100, 0x0100, |
576 | "Tekom Technologies, Inc", | 611 | "Tekom Technologies, Inc", |
@@ -578,8 +613,10 @@ UNUSUAL_DEV( 0x052b, 0x1801, 0x0100, 0x0100, | |||
578 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, | 613 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, |
579 | US_FL_IGNORE_RESIDUE ), | 614 | US_FL_IGNORE_RESIDUE ), |
580 | 615 | ||
581 | /* Another Yakumo camera. | 616 | /* |
582 | * Reported by Michele Alzetta <michele.alzetta@aliceposta.it> */ | 617 | * Another Yakumo camera. |
618 | * Reported by Michele Alzetta <michele.alzetta@aliceposta.it> | ||
619 | */ | ||
583 | UNUSUAL_DEV( 0x052b, 0x1804, 0x0100, 0x0100, | 620 | UNUSUAL_DEV( 0x052b, 0x1804, 0x0100, 0x0100, |
584 | "Tekom Technologies, Inc", | 621 | "Tekom Technologies, Inc", |
585 | "300_CAMERA", | 622 | "300_CAMERA", |
@@ -593,16 +630,20 @@ UNUSUAL_DEV( 0x052b, 0x1807, 0x0100, 0x0100, | |||
593 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, | 630 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, |
594 | US_FL_IGNORE_RESIDUE ), | 631 | US_FL_IGNORE_RESIDUE ), |
595 | 632 | ||
596 | /* Yakumo Mega Image 47 | 633 | /* |
597 | * Reported by Bjoern Paetzel <kolrabi@kolrabi.de> */ | 634 | * Yakumo Mega Image 47 |
635 | * Reported by Bjoern Paetzel <kolrabi@kolrabi.de> | ||
636 | */ | ||
598 | UNUSUAL_DEV( 0x052b, 0x1905, 0x0100, 0x0100, | 637 | UNUSUAL_DEV( 0x052b, 0x1905, 0x0100, 0x0100, |
599 | "Tekom Technologies, Inc", | 638 | "Tekom Technologies, Inc", |
600 | "400_CAMERA", | 639 | "400_CAMERA", |
601 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, | 640 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, |
602 | US_FL_IGNORE_RESIDUE ), | 641 | US_FL_IGNORE_RESIDUE ), |
603 | 642 | ||
604 | /* Reported by Paul Ortyl <ortylp@3miasto.net> | 643 | /* |
605 | * Note that it's similar to the device above, only different prodID */ | 644 | * Reported by Paul Ortyl <ortylp@3miasto.net> |
645 | * Note that it's similar to the device above, only different prodID | ||
646 | */ | ||
606 | UNUSUAL_DEV( 0x052b, 0x1911, 0x0100, 0x0100, | 647 | UNUSUAL_DEV( 0x052b, 0x1911, 0x0100, 0x0100, |
607 | "Tekom Technologies, Inc", | 648 | "Tekom Technologies, Inc", |
608 | "400_CAMERA", | 649 | "400_CAMERA", |
@@ -615,8 +656,10 @@ UNUSUAL_DEV( 0x054c, 0x0010, 0x0106, 0x0450, | |||
615 | USB_SC_SCSI, USB_PR_DEVICE, NULL, | 656 | USB_SC_SCSI, USB_PR_DEVICE, NULL, |
616 | US_FL_SINGLE_LUN | US_FL_NOT_LOCKABLE | US_FL_NO_WP_DETECT ), | 657 | US_FL_SINGLE_LUN | US_FL_NOT_LOCKABLE | US_FL_NO_WP_DETECT ), |
617 | 658 | ||
618 | /* Submitted by Lars Jacob <jacob.lars@googlemail.com> | 659 | /* |
619 | * This entry is needed because the device reports Sub=ff */ | 660 | * Submitted by Lars Jacob <jacob.lars@googlemail.com> |
661 | * This entry is needed because the device reports Sub=ff | ||
662 | */ | ||
620 | UNUSUAL_DEV( 0x054c, 0x0010, 0x0500, 0x0610, | 663 | UNUSUAL_DEV( 0x054c, 0x0010, 0x0500, 0x0610, |
621 | "Sony", | 664 | "Sony", |
622 | "DSC-T1/T5/H5", | 665 | "DSC-T1/T5/H5", |
@@ -719,7 +762,8 @@ UNUSUAL_DEV( 0x057b, 0x0000, 0x0000, 0x0299, | |||
719 | USB_SC_DEVICE, USB_PR_CB, NULL, | 762 | USB_SC_DEVICE, USB_PR_CB, NULL, |
720 | US_FL_SINGLE_LUN), | 763 | US_FL_SINGLE_LUN), |
721 | 764 | ||
722 | /* Reported by Johann Cardon <johann.cardon@free.fr> | 765 | /* |
766 | * Reported by Johann Cardon <johann.cardon@free.fr> | ||
723 | * This entry is needed only because the device reports | 767 | * This entry is needed only because the device reports |
724 | * bInterfaceClass = 0xff (vendor-specific) | 768 | * bInterfaceClass = 0xff (vendor-specific) |
725 | */ | 769 | */ |
@@ -741,7 +785,8 @@ UNUSUAL_DEV( 0x0595, 0x4343, 0x0000, 0x2210, | |||
741 | "Digital Camera EX-20 DSC", | 785 | "Digital Camera EX-20 DSC", |
742 | USB_SC_8070, USB_PR_DEVICE, NULL, 0 ), | 786 | USB_SC_8070, USB_PR_DEVICE, NULL, 0 ), |
743 | 787 | ||
744 | /* Reported by Andre Welter <a.r.welter@gmx.de> | 788 | /* |
789 | * Reported by Andre Welter <a.r.welter@gmx.de> | ||
745 | * This antique device predates the release of the Bulk-only Transport | 790 | * This antique device predates the release of the Bulk-only Transport |
746 | * spec, and if it gets a Get-Max-LUN then it requires the host to do a | 791 | * spec, and if it gets a Get-Max-LUN then it requires the host to do a |
747 | * Clear-Halt on the bulk endpoints. The SINGLE_LUN flag will prevent | 792 | * Clear-Halt on the bulk endpoints. The SINGLE_LUN flag will prevent |
@@ -773,7 +818,8 @@ UNUSUAL_DEV( 0x059f, 0x0651, 0x0000, 0x0000, | |||
773 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, | 818 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, |
774 | US_FL_NO_WP_DETECT ), | 819 | US_FL_NO_WP_DETECT ), |
775 | 820 | ||
776 | /* Submitted by Joel Bourquard <numlock@freesurf.ch> | 821 | /* |
822 | * Submitted by Joel Bourquard <numlock@freesurf.ch> | ||
777 | * Some versions of this device need the SubClass and Protocol overrides | 823 | * Some versions of this device need the SubClass and Protocol overrides |
778 | * while others don't. | 824 | * while others don't. |
779 | */ | 825 | */ |
@@ -783,7 +829,8 @@ UNUSUAL_DEV( 0x05ab, 0x0060, 0x1104, 0x1110, | |||
783 | USB_SC_SCSI, USB_PR_BULK, NULL, | 829 | USB_SC_SCSI, USB_PR_BULK, NULL, |
784 | US_FL_NEED_OVERRIDE ), | 830 | US_FL_NEED_OVERRIDE ), |
785 | 831 | ||
786 | /* Submitted by Sven Anderson <sven-linux@anderson.de> | 832 | /* |
833 | * Submitted by Sven Anderson <sven-linux@anderson.de> | ||
787 | * There are at least four ProductIDs used for iPods, so I added 0x1202 and | 834 | * There are at least four ProductIDs used for iPods, so I added 0x1202 and |
788 | * 0x1204. They just need the US_FL_FIX_CAPACITY. As the bcdDevice appears | 835 | * 0x1204. They just need the US_FL_FIX_CAPACITY. As the bcdDevice appears |
789 | * to change with firmware updates, I changed the range to maximum for all | 836 | * to change with firmware updates, I changed the range to maximum for all |
@@ -824,7 +871,8 @@ UNUSUAL_DEV( 0x05ac, 0x120a, 0x0000, 0x9999, | |||
824 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, | 871 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, |
825 | US_FL_FIX_CAPACITY ), | 872 | US_FL_FIX_CAPACITY ), |
826 | 873 | ||
827 | /* Reported by Dan Williams <dcbw@redhat.com> | 874 | /* |
875 | * Reported by Dan Williams <dcbw@redhat.com> | ||
828 | * Option N.V. mobile broadband modems | 876 | * Option N.V. mobile broadband modems |
829 | * Ignore driver CD mode and force into modem mode by default. | 877 | * Ignore driver CD mode and force into modem mode by default. |
830 | */ | 878 | */ |
@@ -843,7 +891,8 @@ UNUSUAL_DEV( 0x05dc, 0xb002, 0x0000, 0x0113, | |||
843 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, | 891 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, |
844 | US_FL_FIX_INQUIRY ), | 892 | US_FL_FIX_INQUIRY ), |
845 | 893 | ||
846 | /* The following two entries are for a Genesys USB to IDE | 894 | /* |
895 | * The following two entries are for a Genesys USB to IDE | ||
847 | * converter chip, but it changes its ProductId depending | 896 | * converter chip, but it changes its ProductId depending |
848 | * on whether or not a disk or an optical device is enclosed | 897 | * on whether or not a disk or an optical device is enclosed |
849 | * They were originally reported by Alexander Oltu | 898 | * They were originally reported by Alexander Oltu |
@@ -873,8 +922,10 @@ UNUSUAL_DEV( 0x05e3, 0x0723, 0x9451, 0x9451, | |||
873 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, | 922 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, |
874 | US_FL_SANE_SENSE ), | 923 | US_FL_SANE_SENSE ), |
875 | 924 | ||
876 | /* Reported by Hanno Boeck <hanno@gmx.de> | 925 | /* |
877 | * Taken from the Lycoris Kernel */ | 926 | * Reported by Hanno Boeck <hanno@gmx.de> |
927 | * Taken from the Lycoris Kernel | ||
928 | */ | ||
878 | UNUSUAL_DEV( 0x0636, 0x0003, 0x0000, 0x9999, | 929 | UNUSUAL_DEV( 0x0636, 0x0003, 0x0000, 0x9999, |
879 | "Vivitar", | 930 | "Vivitar", |
880 | "Vivicam 35Xx", | 931 | "Vivicam 35Xx", |
@@ -908,8 +959,10 @@ UNUSUAL_DEV( 0x067b, 0x2317, 0x0001, 0x001, | |||
908 | US_FL_NOT_LOCKABLE ), | 959 | US_FL_NOT_LOCKABLE ), |
909 | 960 | ||
910 | /* Reported by Richard -=[]=- <micro_flyer@hotmail.com> */ | 961 | /* Reported by Richard -=[]=- <micro_flyer@hotmail.com> */ |
911 | /* Change to bcdDeviceMin (0x0100 to 0x0001) reported by | 962 | /* |
912 | * Thomas Bartosik <tbartdev@gmx-topmail.de> */ | 963 | * Change to bcdDeviceMin (0x0100 to 0x0001) reported by |
964 | * Thomas Bartosik <tbartdev@gmx-topmail.de> | ||
965 | */ | ||
913 | UNUSUAL_DEV( 0x067b, 0x2507, 0x0001, 0x0100, | 966 | UNUSUAL_DEV( 0x067b, 0x2507, 0x0001, 0x0100, |
914 | "Prolific Technology Inc.", | 967 | "Prolific Technology Inc.", |
915 | "Mass Storage Device", | 968 | "Mass Storage Device", |
@@ -961,7 +1014,8 @@ UNUSUAL_DEV( 0x071b, 0x3203, 0x0000, 0x0000, | |||
961 | US_FL_NO_WP_DETECT | US_FL_MAX_SECTORS_64 | | 1014 | US_FL_NO_WP_DETECT | US_FL_MAX_SECTORS_64 | |
962 | US_FL_NO_READ_CAPACITY_16), | 1015 | US_FL_NO_READ_CAPACITY_16), |
963 | 1016 | ||
964 | /* Reported by Jean-Baptiste Onofre <jb@nanthrax.net> | 1017 | /* |
1018 | * Reported by Jean-Baptiste Onofre <jb@nanthrax.net> | ||
965 | * Support the following product : | 1019 | * Support the following product : |
966 | * "Dane-Elec MediaTouch" | 1020 | * "Dane-Elec MediaTouch" |
967 | */ | 1021 | */ |
@@ -971,7 +1025,8 @@ UNUSUAL_DEV( 0x071b, 0x32bb, 0x0000, 0x0000, | |||
971 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, | 1025 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, |
972 | US_FL_NO_WP_DETECT | US_FL_MAX_SECTORS_64), | 1026 | US_FL_NO_WP_DETECT | US_FL_MAX_SECTORS_64), |
973 | 1027 | ||
974 | /* Reported by Massimiliano Ghilardi <massimiliano.ghilardi@gmail.com> | 1028 | /* |
1029 | * Reported by Massimiliano Ghilardi <massimiliano.ghilardi@gmail.com> | ||
975 | * This USB MP3/AVI player device fails and disconnects if more than 128 | 1030 | * This USB MP3/AVI player device fails and disconnects if more than 128 |
976 | * sectors (64kB) are read/written in a single command, and may be present | 1031 | * sectors (64kB) are read/written in a single command, and may be present |
977 | * at least in the following products: | 1032 | * at least in the following products: |
@@ -1040,7 +1095,8 @@ UNUSUAL_DEV( 0x07af, 0x0006, 0x0100, 0x0100, | |||
1040 | US_FL_SINGLE_LUN ), | 1095 | US_FL_SINGLE_LUN ), |
1041 | #endif | 1096 | #endif |
1042 | 1097 | ||
1043 | /* Datafab KECF-USB / Sagatek DCS-CF / Simpletech Flashlink UCF-100 | 1098 | /* |
1099 | * Datafab KECF-USB / Sagatek DCS-CF / Simpletech Flashlink UCF-100 | ||
1044 | * Only revision 1.13 tested (same for all of the above devices, | 1100 | * Only revision 1.13 tested (same for all of the above devices, |
1045 | * based on the Datafab DF-UG-07 chip). Needed for US_FL_FIX_INQUIRY. | 1101 | * based on the Datafab DF-UG-07 chip). Needed for US_FL_FIX_INQUIRY. |
1046 | * Submitted by Marek Michalkiewicz <marekm@amelek.gda.pl>. | 1102 | * Submitted by Marek Michalkiewicz <marekm@amelek.gda.pl>. |
@@ -1052,7 +1108,8 @@ UNUSUAL_DEV( 0x07c4, 0xa400, 0x0000, 0xffff, | |||
1052 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, | 1108 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, |
1053 | US_FL_FIX_INQUIRY | US_FL_FIX_CAPACITY ), | 1109 | US_FL_FIX_INQUIRY | US_FL_FIX_CAPACITY ), |
1054 | 1110 | ||
1055 | /* Reported by Rauch Wolke <rauchwolke@gmx.net> | 1111 | /* |
1112 | * Reported by Rauch Wolke <rauchwolke@gmx.net> | ||
1056 | * and augmented by binbin <binbinsh@gmail.com> (Bugzilla #12882) | 1113 | * and augmented by binbin <binbinsh@gmail.com> (Bugzilla #12882) |
1057 | */ | 1114 | */ |
1058 | UNUSUAL_DEV( 0x07c4, 0xa4a5, 0x0000, 0xffff, | 1115 | UNUSUAL_DEV( 0x07c4, 0xa4a5, 0x0000, 0xffff, |
@@ -1061,7 +1118,8 @@ UNUSUAL_DEV( 0x07c4, 0xa4a5, 0x0000, 0xffff, | |||
1061 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, | 1118 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, |
1062 | US_FL_IGNORE_RESIDUE | US_FL_MAX_SECTORS_64 ), | 1119 | US_FL_IGNORE_RESIDUE | US_FL_MAX_SECTORS_64 ), |
1063 | 1120 | ||
1064 | /* Casio QV 2x00/3x00/4000/8000 digital still cameras are not conformant | 1121 | /* |
1122 | * Casio QV 2x00/3x00/4000/8000 digital still cameras are not conformant | ||
1065 | * to the USB storage specification in two ways: | 1123 | * to the USB storage specification in two ways: |
1066 | * - They tell us they are using transport protocol CBI. In reality they | 1124 | * - They tell us they are using transport protocol CBI. In reality they |
1067 | * are using transport protocol CB. | 1125 | * are using transport protocol CB. |
@@ -1119,7 +1177,8 @@ UNUSUAL_DEV( 0x084b, 0xa001, 0x0000, 0x9999, | |||
1119 | USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_euscsi_init, | 1177 | USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_euscsi_init, |
1120 | US_FL_SCM_MULT_TARG ), | 1178 | US_FL_SCM_MULT_TARG ), |
1121 | 1179 | ||
1122 | /* Entry and supporting patch by Theodore Kilgore <kilgota@auburn.edu>. | 1180 | /* |
1181 | * Entry and supporting patch by Theodore Kilgore <kilgota@auburn.edu>. | ||
1123 | * Flag will support Bulk devices which use a standards-violating 32-byte | 1182 | * Flag will support Bulk devices which use a standards-violating 32-byte |
1124 | * Command Block Wrapper. Here, the "DC2MEGA" cameras (several brands) with | 1183 | * Command Block Wrapper. Here, the "DC2MEGA" cameras (several brands) with |
1125 | * Grandtech GT892x chip, which request "Proprietary SCSI Bulk" support. | 1184 | * Grandtech GT892x chip, which request "Proprietary SCSI Bulk" support. |
@@ -1131,7 +1190,8 @@ UNUSUAL_DEV( 0x084d, 0x0011, 0x0110, 0x0110, | |||
1131 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, | 1190 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, |
1132 | US_FL_BULK32), | 1191 | US_FL_BULK32), |
1133 | 1192 | ||
1134 | /* Reported by <ttkspam@free.fr> | 1193 | /* |
1194 | * Reported by <ttkspam@free.fr> | ||
1135 | * The device reports a vendor-specific device class, requiring an | 1195 | * The device reports a vendor-specific device class, requiring an |
1136 | * explicit vendor/product match. | 1196 | * explicit vendor/product match. |
1137 | */ | 1197 | */ |
@@ -1140,11 +1200,12 @@ UNUSUAL_DEV( 0x0851, 0x1542, 0x0002, 0x0002, | |||
1140 | "FW_Omega2", | 1200 | "FW_Omega2", |
1141 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, 0), | 1201 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, 0), |
1142 | 1202 | ||
1143 | /* Andrew Lunn <andrew@lunn.ch> | 1203 | /* |
1204 | * Andrew Lunn <andrew@lunn.ch> | ||
1144 | * PanDigital Digital Picture Frame. Does not like ALLOW_MEDIUM_REMOVAL | 1205 | * PanDigital Digital Picture Frame. Does not like ALLOW_MEDIUM_REMOVAL |
1145 | * on LUN 4. | 1206 | * on LUN 4. |
1146 | * Note: Vend:Prod clash with "Ltd Maxell WS30 Slim Digital Camera" | 1207 | * Note: Vend:Prod clash with "Ltd Maxell WS30 Slim Digital Camera" |
1147 | */ | 1208 | */ |
1148 | UNUSUAL_DEV( 0x0851, 0x1543, 0x0200, 0x0200, | 1209 | UNUSUAL_DEV( 0x0851, 0x1543, 0x0200, 0x0200, |
1149 | "PanDigital", | 1210 | "PanDigital", |
1150 | "Photo Frame", | 1211 | "Photo Frame", |
@@ -1170,7 +1231,8 @@ UNUSUAL_DEV( 0x08bd, 0x1100, 0x0000, 0x0000, | |||
1170 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, | 1231 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, |
1171 | US_FL_SINGLE_LUN), | 1232 | US_FL_SINGLE_LUN), |
1172 | 1233 | ||
1173 | /* Submitted by Dylan Taft <d13f00l@gmail.com> | 1234 | /* |
1235 | * Submitted by Dylan Taft <d13f00l@gmail.com> | ||
1174 | * US_FL_IGNORE_RESIDUE Needed | 1236 | * US_FL_IGNORE_RESIDUE Needed |
1175 | */ | 1237 | */ |
1176 | UNUSUAL_DEV( 0x08ca, 0x3103, 0x0100, 0x0100, | 1238 | UNUSUAL_DEV( 0x08ca, 0x3103, 0x0100, 0x0100, |
@@ -1179,7 +1241,8 @@ UNUSUAL_DEV( 0x08ca, 0x3103, 0x0100, 0x0100, | |||
1179 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, | 1241 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, |
1180 | US_FL_IGNORE_RESIDUE), | 1242 | US_FL_IGNORE_RESIDUE), |
1181 | 1243 | ||
1182 | /* Entry needed for flags. Moreover, all devices with this ID use | 1244 | /* |
1245 | * Entry needed for flags. Moreover, all devices with this ID use | ||
1183 | * bulk-only transport, but _some_ falsely report Control/Bulk instead. | 1246 | * bulk-only transport, but _some_ falsely report Control/Bulk instead. |
1184 | * One example is "Trumpion Digital Research MYMP3". | 1247 | * One example is "Trumpion Digital Research MYMP3". |
1185 | * Submitted by Bjoern Brill <brill(at)fs.math.uni-frankfurt.de> | 1248 | * Submitted by Bjoern Brill <brill(at)fs.math.uni-frankfurt.de> |
@@ -1190,7 +1253,8 @@ UNUSUAL_DEV( 0x090a, 0x1001, 0x0100, 0x0100, | |||
1190 | USB_SC_DEVICE, USB_PR_BULK, NULL, | 1253 | USB_SC_DEVICE, USB_PR_BULK, NULL, |
1191 | US_FL_NEED_OVERRIDE ), | 1254 | US_FL_NEED_OVERRIDE ), |
1192 | 1255 | ||
1193 | /* Reported by Filippo Bardelli <filibard@libero.it> | 1256 | /* |
1257 | * Reported by Filippo Bardelli <filibard@libero.it> | ||
1194 | * The device reports a subclass of RBC, which is wrong. | 1258 | * The device reports a subclass of RBC, which is wrong. |
1195 | */ | 1259 | */ |
1196 | UNUSUAL_DEV( 0x090a, 0x1050, 0x0100, 0x0100, | 1260 | UNUSUAL_DEV( 0x090a, 0x1050, 0x0100, 0x0100, |
@@ -1213,7 +1277,8 @@ UNUSUAL_DEV( 0x090c, 0x1132, 0x0000, 0xffff, | |||
1213 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, | 1277 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, |
1214 | US_FL_FIX_CAPACITY ), | 1278 | US_FL_FIX_CAPACITY ), |
1215 | 1279 | ||
1216 | /* Reported by Paul Hartman <paul.hartman+linux@gmail.com> | 1280 | /* |
1281 | * Reported by Paul Hartman <paul.hartman+linux@gmail.com> | ||
1217 | * This card reader returns "Illegal Request, Logical Block Address | 1282 | * This card reader returns "Illegal Request, Logical Block Address |
1218 | * Out of Range" for the first READ(10) after a new card is inserted. | 1283 | * Out of Range" for the first READ(10) after a new card is inserted. |
1219 | */ | 1284 | */ |
@@ -1223,7 +1288,8 @@ UNUSUAL_DEV( 0x090c, 0x6000, 0x0100, 0x0100, | |||
1223 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, | 1288 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, |
1224 | US_FL_INITIAL_READ10 ), | 1289 | US_FL_INITIAL_READ10 ), |
1225 | 1290 | ||
1226 | /* This Pentax still camera is not conformant | 1291 | /* |
1292 | * This Pentax still camera is not conformant | ||
1227 | * to the USB storage specification: - | 1293 | * to the USB storage specification: - |
1228 | * - It does not like the INQUIRY command. So we must handle this command | 1294 | * - It does not like the INQUIRY command. So we must handle this command |
1229 | * of the SCSI layer ourselves. | 1295 | * of the SCSI layer ourselves. |
@@ -1236,8 +1302,10 @@ UNUSUAL_DEV( 0x0a17, 0x0004, 0x1000, 0x1000, | |||
1236 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, | 1302 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, |
1237 | US_FL_FIX_INQUIRY ), | 1303 | US_FL_FIX_INQUIRY ), |
1238 | 1304 | ||
1239 | /* These are virtual windows driver CDs, which the zd1211rw driver | 1305 | /* |
1240 | * automatically converts into WLAN devices. */ | 1306 | * These are virtual windows driver CDs, which the zd1211rw driver |
1307 | * automatically converts into WLAN devices. | ||
1308 | */ | ||
1241 | UNUSUAL_DEV( 0x0ace, 0x2011, 0x0101, 0x0101, | 1309 | UNUSUAL_DEV( 0x0ace, 0x2011, 0x0101, 0x0101, |
1242 | "ZyXEL", | 1310 | "ZyXEL", |
1243 | "G-220F USB-WLAN Install", | 1311 | "G-220F USB-WLAN Install", |
@@ -1250,7 +1318,8 @@ UNUSUAL_DEV( 0x0ace, 0x20ff, 0x0101, 0x0101, | |||
1250 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, | 1318 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, |
1251 | US_FL_IGNORE_DEVICE ), | 1319 | US_FL_IGNORE_DEVICE ), |
1252 | 1320 | ||
1253 | /* Reported by Dan Williams <dcbw@redhat.com> | 1321 | /* |
1322 | * Reported by Dan Williams <dcbw@redhat.com> | ||
1254 | * Option N.V. mobile broadband modems | 1323 | * Option N.V. mobile broadband modems |
1255 | * Ignore driver CD mode and force into modem mode by default. | 1324 | * Ignore driver CD mode and force into modem mode by default. |
1256 | */ | 1325 | */ |
@@ -1262,20 +1331,24 @@ UNUSUAL_DEV( 0x0af0, 0x6971, 0x0000, 0x9999, | |||
1262 | USB_SC_DEVICE, USB_PR_DEVICE, option_ms_init, | 1331 | USB_SC_DEVICE, USB_PR_DEVICE, option_ms_init, |
1263 | 0), | 1332 | 0), |
1264 | 1333 | ||
1265 | /* Reported by F. Aben <f.aben@option.com> | 1334 | /* |
1335 | * Reported by F. Aben <f.aben@option.com> | ||
1266 | * This device (wrongly) has a vendor-specific device descriptor. | 1336 | * This device (wrongly) has a vendor-specific device descriptor. |
1267 | * The entry is needed so usb-storage can bind to it's mass-storage | 1337 | * The entry is needed so usb-storage can bind to it's mass-storage |
1268 | * interface as an interface driver */ | 1338 | * interface as an interface driver |
1339 | */ | ||
1269 | UNUSUAL_DEV( 0x0af0, 0x7401, 0x0000, 0x0000, | 1340 | UNUSUAL_DEV( 0x0af0, 0x7401, 0x0000, 0x0000, |
1270 | "Option", | 1341 | "Option", |
1271 | "GI 0401 SD-Card", | 1342 | "GI 0401 SD-Card", |
1272 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, | 1343 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, |
1273 | 0 ), | 1344 | 0 ), |
1274 | 1345 | ||
1275 | /* Reported by Jan Dumon <j.dumon@option.com> | 1346 | /* |
1347 | * Reported by Jan Dumon <j.dumon@option.com> | ||
1276 | * These devices (wrongly) have a vendor-specific device descriptor. | 1348 | * These devices (wrongly) have a vendor-specific device descriptor. |
1277 | * These entries are needed so usb-storage can bind to their mass-storage | 1349 | * These entries are needed so usb-storage can bind to their mass-storage |
1278 | * interface as an interface driver */ | 1350 | * interface as an interface driver |
1351 | */ | ||
1279 | UNUSUAL_DEV( 0x0af0, 0x7501, 0x0000, 0x0000, | 1352 | UNUSUAL_DEV( 0x0af0, 0x7501, 0x0000, 0x0000, |
1280 | "Option", | 1353 | "Option", |
1281 | "GI 0431 SD-Card", | 1354 | "GI 0431 SD-Card", |
@@ -1419,7 +1492,8 @@ UNUSUAL_DEV( 0x0dc4, 0x0073, 0x0000, 0x0000, | |||
1419 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, | 1492 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, |
1420 | US_FL_FIX_CAPACITY), | 1493 | US_FL_FIX_CAPACITY), |
1421 | 1494 | ||
1422 | /* Reported by Lubomir Blaha <tritol@trilogic.cz> | 1495 | /* |
1496 | * Reported by Lubomir Blaha <tritol@trilogic.cz> | ||
1423 | * I _REALLY_ don't know what 3rd, 4th number and all defines mean, but this | 1497 | * I _REALLY_ don't know what 3rd, 4th number and all defines mean, but this |
1424 | * works for me. Can anybody correct these values? (I able to test corrected | 1498 | * works for me. Can anybody correct these values? (I able to test corrected |
1425 | * version.) | 1499 | * version.) |
@@ -1430,8 +1504,10 @@ UNUSUAL_DEV( 0x0dd8, 0x1060, 0x0000, 0xffff, | |||
1430 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, | 1504 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, |
1431 | US_FL_FIX_INQUIRY ), | 1505 | US_FL_FIX_INQUIRY ), |
1432 | 1506 | ||
1433 | /* Reported by Edward Chapman (taken from linux-usb mailing list) | 1507 | /* |
1434 | Netac OnlyDisk Mini U2CV2 512MB USB 2.0 Flash Drive */ | 1508 | * Reported by Edward Chapman (taken from linux-usb mailing list) |
1509 | * Netac OnlyDisk Mini U2CV2 512MB USB 2.0 Flash Drive | ||
1510 | */ | ||
1435 | UNUSUAL_DEV( 0x0dd8, 0xd202, 0x0000, 0x9999, | 1511 | UNUSUAL_DEV( 0x0dd8, 0xd202, 0x0000, 0x9999, |
1436 | "Netac", | 1512 | "Netac", |
1437 | "USB Flash Disk", | 1513 | "USB Flash Disk", |
@@ -1439,8 +1515,10 @@ UNUSUAL_DEV( 0x0dd8, 0xd202, 0x0000, 0x9999, | |||
1439 | US_FL_IGNORE_RESIDUE ), | 1515 | US_FL_IGNORE_RESIDUE ), |
1440 | 1516 | ||
1441 | 1517 | ||
1442 | /* Patch by Stephan Walter <stephan.walter@epfl.ch> | 1518 | /* |
1443 | * I don't know why, but it works... */ | 1519 | * Patch by Stephan Walter <stephan.walter@epfl.ch> |
1520 | * I don't know why, but it works... | ||
1521 | */ | ||
1444 | UNUSUAL_DEV( 0x0dda, 0x0001, 0x0012, 0x0012, | 1522 | UNUSUAL_DEV( 0x0dda, 0x0001, 0x0012, 0x0012, |
1445 | "WINWARD", | 1523 | "WINWARD", |
1446 | "Music Disk", | 1524 | "Music Disk", |
@@ -1468,8 +1546,10 @@ UNUSUAL_DEV( 0x0ed1, 0x6660, 0x0100, 0x0300, | |||
1468 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, | 1546 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, |
1469 | US_FL_FIX_INQUIRY ), | 1547 | US_FL_FIX_INQUIRY ), |
1470 | 1548 | ||
1471 | /* Submitted by Daniel Drake <dsd@gentoo.org> | 1549 | /* |
1472 | * Reported by dayul on the Gentoo Forums */ | 1550 | * Submitted by Daniel Drake <dsd@gentoo.org> |
1551 | * Reported by dayul on the Gentoo Forums | ||
1552 | */ | ||
1473 | UNUSUAL_DEV( 0x0ea0, 0x2168, 0x0110, 0x0110, | 1553 | UNUSUAL_DEV( 0x0ea0, 0x2168, 0x0110, 0x0110, |
1474 | "Ours Technology", | 1554 | "Ours Technology", |
1475 | "Flash Disk", | 1555 | "Flash Disk", |
@@ -1483,15 +1563,18 @@ UNUSUAL_DEV( 0x0ea0, 0x6828, 0x0110, 0x0110, | |||
1483 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, | 1563 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, |
1484 | US_FL_IGNORE_RESIDUE ), | 1564 | US_FL_IGNORE_RESIDUE ), |
1485 | 1565 | ||
1486 | /* Reported by Benjamin Schiller <sbenni@gmx.de> | 1566 | /* |
1487 | * It is also sold by Easylite as DJ 20 */ | 1567 | * Reported by Benjamin Schiller <sbenni@gmx.de> |
1568 | * It is also sold by Easylite as DJ 20 | ||
1569 | */ | ||
1488 | UNUSUAL_DEV( 0x0ed1, 0x7636, 0x0103, 0x0103, | 1570 | UNUSUAL_DEV( 0x0ed1, 0x7636, 0x0103, 0x0103, |
1489 | "Typhoon", | 1571 | "Typhoon", |
1490 | "My DJ 1820", | 1572 | "My DJ 1820", |
1491 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, | 1573 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, |
1492 | US_FL_IGNORE_RESIDUE | US_FL_GO_SLOW | US_FL_MAX_SECTORS_64), | 1574 | US_FL_IGNORE_RESIDUE | US_FL_GO_SLOW | US_FL_MAX_SECTORS_64), |
1493 | 1575 | ||
1494 | /* Patch by Leonid Petrov mail at lpetrov.net | 1576 | /* |
1577 | * Patch by Leonid Petrov mail at lpetrov.net | ||
1495 | * Reported by Robert Spitzenpfeil <robert@spitzenpfeil.org> | 1578 | * Reported by Robert Spitzenpfeil <robert@spitzenpfeil.org> |
1496 | * http://www.qbik.ch/usb/devices/showdev.php?id=1705 | 1579 | * http://www.qbik.ch/usb/devices/showdev.php?id=1705 |
1497 | * Updated to 103 device by MJ Ray mjr at phonecoop.coop | 1580 | * Updated to 103 device by MJ Ray mjr at phonecoop.coop |
@@ -1502,7 +1585,8 @@ UNUSUAL_DEV( 0x0f19, 0x0103, 0x0100, 0x0100, | |||
1502 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, | 1585 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, |
1503 | US_FL_IGNORE_RESIDUE ), | 1586 | US_FL_IGNORE_RESIDUE ), |
1504 | 1587 | ||
1505 | /* David Kuehling <dvdkhlng@gmx.de>: | 1588 | /* |
1589 | * David Kuehling <dvdkhlng@gmx.de>: | ||
1506 | * for MP3-Player AVOX WSX-300ER (bought in Japan). Reports lots of SCSI | 1590 | * for MP3-Player AVOX WSX-300ER (bought in Japan). Reports lots of SCSI |
1507 | * errors when trying to write. | 1591 | * errors when trying to write. |
1508 | */ | 1592 | */ |
@@ -1540,8 +1624,10 @@ UNUSUAL_DEV( 0x0fce, 0xd0e1, 0x0000, 0x0000, | |||
1540 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, | 1624 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, |
1541 | US_FL_IGNORE_DEVICE), | 1625 | US_FL_IGNORE_DEVICE), |
1542 | 1626 | ||
1543 | /* Reported by Jan Mate <mate@fiit.stuba.sk> | 1627 | /* |
1544 | * and by Soeren Sonnenburg <kernel@nn7.de> */ | 1628 | * Reported by Jan Mate <mate@fiit.stuba.sk> |
1629 | * and by Soeren Sonnenburg <kernel@nn7.de> | ||
1630 | */ | ||
1545 | UNUSUAL_DEV( 0x0fce, 0xe030, 0x0000, 0x0000, | 1631 | UNUSUAL_DEV( 0x0fce, 0xe030, 0x0000, 0x0000, |
1546 | "Sony Ericsson", | 1632 | "Sony Ericsson", |
1547 | "P990i", | 1633 | "P990i", |
@@ -1562,7 +1648,8 @@ UNUSUAL_DEV( 0x0fce, 0xe092, 0x0000, 0x0000, | |||
1562 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, | 1648 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, |
1563 | US_FL_IGNORE_RESIDUE ), | 1649 | US_FL_IGNORE_RESIDUE ), |
1564 | 1650 | ||
1565 | /* Reported by Kevin Cernekee <kpc-usbdev@gelato.uiuc.edu> | 1651 | /* |
1652 | * Reported by Kevin Cernekee <kpc-usbdev@gelato.uiuc.edu> | ||
1566 | * Tested on hardware version 1.10. | 1653 | * Tested on hardware version 1.10. |
1567 | * Entry is needed only for the initializer function override. | 1654 | * Entry is needed only for the initializer function override. |
1568 | * Devices with bcd > 110 seem to not need it while those | 1655 | * Devices with bcd > 110 seem to not need it while those |
@@ -1586,7 +1673,8 @@ UNUSUAL_DEV(0x1058, 0x070a, 0x0000, 0x9999, | |||
1586 | "My Passport HDD", | 1673 | "My Passport HDD", |
1587 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, US_FL_WRITE_CACHE), | 1674 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, US_FL_WRITE_CACHE), |
1588 | 1675 | ||
1589 | /* Reported by Fabio Venturi <f.venturi@tdnet.it> | 1676 | /* |
1677 | * Reported by Fabio Venturi <f.venturi@tdnet.it> | ||
1590 | * The device reports a vendor-specific bDeviceClass. | 1678 | * The device reports a vendor-specific bDeviceClass. |
1591 | */ | 1679 | */ |
1592 | UNUSUAL_DEV( 0x10d6, 0x2200, 0x0100, 0x0100, | 1680 | UNUSUAL_DEV( 0x10d6, 0x2200, 0x0100, 0x0100, |
@@ -1595,7 +1683,8 @@ UNUSUAL_DEV( 0x10d6, 0x2200, 0x0100, 0x0100, | |||
1595 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, | 1683 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, |
1596 | 0), | 1684 | 0), |
1597 | 1685 | ||
1598 | /* Reported by Pascal Terjan <pterjan@mandriva.com> | 1686 | /* |
1687 | * Reported by Pascal Terjan <pterjan@mandriva.com> | ||
1599 | * Ignore driver CD mode and force into modem mode by default. | 1688 | * Ignore driver CD mode and force into modem mode by default. |
1600 | */ | 1689 | */ |
1601 | UNUSUAL_DEV( 0x1186, 0x3e04, 0x0000, 0x0000, | 1690 | UNUSUAL_DEV( 0x1186, 0x3e04, 0x0000, 0x0000, |
@@ -1603,7 +1692,8 @@ UNUSUAL_DEV( 0x1186, 0x3e04, 0x0000, 0x0000, | |||
1603 | "USB Mass Storage", | 1692 | "USB Mass Storage", |
1604 | USB_SC_DEVICE, USB_PR_DEVICE, option_ms_init, US_FL_IGNORE_DEVICE), | 1693 | USB_SC_DEVICE, USB_PR_DEVICE, option_ms_init, US_FL_IGNORE_DEVICE), |
1605 | 1694 | ||
1606 | /* Reported by Kevin Lloyd <linux@sierrawireless.com> | 1695 | /* |
1696 | * Reported by Kevin Lloyd <linux@sierrawireless.com> | ||
1607 | * Entry is needed for the initializer function override, | 1697 | * Entry is needed for the initializer function override, |
1608 | * which instructs the device to load as a modem | 1698 | * which instructs the device to load as a modem |
1609 | * device. | 1699 | * device. |
@@ -1614,7 +1704,8 @@ UNUSUAL_DEV( 0x1199, 0x0fff, 0x0000, 0x9999, | |||
1614 | USB_SC_DEVICE, USB_PR_DEVICE, sierra_ms_init, | 1704 | USB_SC_DEVICE, USB_PR_DEVICE, sierra_ms_init, |
1615 | 0), | 1705 | 0), |
1616 | 1706 | ||
1617 | /* Reported by Jaco Kroon <jaco@kroon.co.za> | 1707 | /* |
1708 | * Reported by Jaco Kroon <jaco@kroon.co.za> | ||
1618 | * The usb-storage module found on the Digitech GNX4 (and supposedly other | 1709 | * The usb-storage module found on the Digitech GNX4 (and supposedly other |
1619 | * devices) misbehaves and causes a bunch of invalid I/O errors. | 1710 | * devices) misbehaves and causes a bunch of invalid I/O errors. |
1620 | */ | 1711 | */ |
@@ -1624,7 +1715,8 @@ UNUSUAL_DEV( 0x1210, 0x0003, 0x0100, 0x0100, | |||
1624 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, | 1715 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, |
1625 | US_FL_IGNORE_RESIDUE ), | 1716 | US_FL_IGNORE_RESIDUE ), |
1626 | 1717 | ||
1627 | /* Reported by fangxiaozhi <huananhu@huawei.com> | 1718 | /* |
1719 | * Reported by fangxiaozhi <huananhu@huawei.com> | ||
1628 | * This brings the HUAWEI data card devices into multi-port mode | 1720 | * This brings the HUAWEI data card devices into multi-port mode |
1629 | */ | 1721 | */ |
1630 | UNUSUAL_DEV( 0x12d1, 0x1001, 0x0000, 0x0000, | 1722 | UNUSUAL_DEV( 0x12d1, 0x1001, 0x0000, 0x0000, |
@@ -1993,7 +2085,8 @@ UNUSUAL_DEV( 0x152d, 0x0567, 0x0114, 0x0116, | |||
1993 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, | 2085 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, |
1994 | US_FL_BROKEN_FUA ), | 2086 | US_FL_BROKEN_FUA ), |
1995 | 2087 | ||
1996 | /* Reported by Alexandre Oliva <oliva@lsd.ic.unicamp.br> | 2088 | /* |
2089 | * Reported by Alexandre Oliva <oliva@lsd.ic.unicamp.br> | ||
1997 | * JMicron responds to USN and several other SCSI ioctls with a | 2090 | * JMicron responds to USN and several other SCSI ioctls with a |
1998 | * residue that causes subsequent I/O requests to fail. */ | 2091 | * residue that causes subsequent I/O requests to fail. */ |
1999 | UNUSUAL_DEV( 0x152d, 0x2329, 0x0100, 0x0100, | 2092 | UNUSUAL_DEV( 0x152d, 0x2329, 0x0100, 0x0100, |
@@ -2009,7 +2102,8 @@ UNUSUAL_DEV( 0x152d, 0x2566, 0x0114, 0x0114, | |||
2009 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, | 2102 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, |
2010 | US_FL_BROKEN_FUA ), | 2103 | US_FL_BROKEN_FUA ), |
2011 | 2104 | ||
2012 | /* Entrega Technologies U1-SC25 (later Xircom PortGear PGSCSI) | 2105 | /* |
2106 | * Entrega Technologies U1-SC25 (later Xircom PortGear PGSCSI) | ||
2013 | * and Mac USB Dock USB-SCSI */ | 2107 | * and Mac USB Dock USB-SCSI */ |
2014 | UNUSUAL_DEV( 0x1645, 0x0007, 0x0100, 0x0133, | 2108 | UNUSUAL_DEV( 0x1645, 0x0007, 0x0100, 0x0133, |
2015 | "Entrega Technologies", | 2109 | "Entrega Technologies", |
@@ -2017,8 +2111,10 @@ UNUSUAL_DEV( 0x1645, 0x0007, 0x0100, 0x0133, | |||
2017 | USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_euscsi_init, | 2111 | USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_euscsi_init, |
2018 | US_FL_SCM_MULT_TARG ), | 2112 | US_FL_SCM_MULT_TARG ), |
2019 | 2113 | ||
2020 | /* Reported by Robert Schedel <r.schedel@yahoo.de> | 2114 | /* |
2021 | * Note: this is a 'super top' device like the above 14cd/6600 device */ | 2115 | * Reported by Robert Schedel <r.schedel@yahoo.de> |
2116 | * Note: this is a 'super top' device like the above 14cd/6600 device | ||
2117 | */ | ||
2022 | UNUSUAL_DEV( 0x1652, 0x6600, 0x0201, 0x0201, | 2118 | UNUSUAL_DEV( 0x1652, 0x6600, 0x0201, 0x0201, |
2023 | "Teac", | 2119 | "Teac", |
2024 | "HD-35PUK-B", | 2120 | "HD-35PUK-B", |
@@ -2045,10 +2141,12 @@ UNUSUAL_DEV( 0x1822, 0x0001, 0x0000, 0x9999, | |||
2045 | USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_euscsi_init, | 2141 | USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_euscsi_init, |
2046 | US_FL_SCM_MULT_TARG ), | 2142 | US_FL_SCM_MULT_TARG ), |
2047 | 2143 | ||
2048 | /* Reported by Hans de Goede <hdegoede@redhat.com> | 2144 | /* |
2145 | * Reported by Hans de Goede <hdegoede@redhat.com> | ||
2049 | * These Appotech controllers are found in Picture Frames, they provide a | 2146 | * These Appotech controllers are found in Picture Frames, they provide a |
2050 | * (buggy) emulation of a cdrom drive which contains the windows software | 2147 | * (buggy) emulation of a cdrom drive which contains the windows software |
2051 | * Uploading of pictures happens over the corresponding /dev/sg device. */ | 2148 | * Uploading of pictures happens over the corresponding /dev/sg device. |
2149 | */ | ||
2052 | UNUSUAL_DEV( 0x1908, 0x1315, 0x0000, 0x0000, | 2150 | UNUSUAL_DEV( 0x1908, 0x1315, 0x0000, 0x0000, |
2053 | "BUILDWIN", | 2151 | "BUILDWIN", |
2054 | "Photo Frame", | 2152 | "Photo Frame", |
@@ -2065,19 +2163,22 @@ UNUSUAL_DEV( 0x1908, 0x3335, 0x0200, 0x0200, | |||
2065 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, | 2163 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, |
2066 | US_FL_NO_READ_DISC_INFO ), | 2164 | US_FL_NO_READ_DISC_INFO ), |
2067 | 2165 | ||
2068 | /* Reported by Oliver Neukum <oneukum@suse.com> | 2166 | /* |
2167 | * Reported by Oliver Neukum <oneukum@suse.com> | ||
2069 | * This device morphes spontaneously into another device if the access | 2168 | * This device morphes spontaneously into another device if the access |
2070 | * pattern of Windows isn't followed. Thus writable media would be dirty | 2169 | * pattern of Windows isn't followed. Thus writable media would be dirty |
2071 | * if the initial instance is used. So the device is limited to its | 2170 | * if the initial instance is used. So the device is limited to its |
2072 | * virtual CD. | 2171 | * virtual CD. |
2073 | * And yes, the concept that BCD goes up to 9 is not heeded */ | 2172 | * And yes, the concept that BCD goes up to 9 is not heeded |
2173 | */ | ||
2074 | UNUSUAL_DEV( 0x19d2, 0x1225, 0x0000, 0xffff, | 2174 | UNUSUAL_DEV( 0x19d2, 0x1225, 0x0000, 0xffff, |
2075 | "ZTE,Incorporated", | 2175 | "ZTE,Incorporated", |
2076 | "ZTE WCDMA Technologies MSM", | 2176 | "ZTE WCDMA Technologies MSM", |
2077 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, | 2177 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, |
2078 | US_FL_SINGLE_LUN ), | 2178 | US_FL_SINGLE_LUN ), |
2079 | 2179 | ||
2080 | /* Reported by Sven Geggus <sven-usbst@geggus.net> | 2180 | /* |
2181 | * Reported by Sven Geggus <sven-usbst@geggus.net> | ||
2081 | * This encrypted pen drive returns bogus data for the initial READ(10). | 2182 | * This encrypted pen drive returns bogus data for the initial READ(10). |
2082 | */ | 2183 | */ |
2083 | UNUSUAL_DEV( 0x1b1c, 0x1ab5, 0x0200, 0x0200, | 2184 | UNUSUAL_DEV( 0x1b1c, 0x1ab5, 0x0200, 0x0200, |
@@ -2086,7 +2187,8 @@ UNUSUAL_DEV( 0x1b1c, 0x1ab5, 0x0200, 0x0200, | |||
2086 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, | 2187 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, |
2087 | US_FL_INITIAL_READ10 ), | 2188 | US_FL_INITIAL_READ10 ), |
2088 | 2189 | ||
2089 | /* Reported by Hans de Goede <hdegoede@redhat.com> | 2190 | /* |
2191 | * Reported by Hans de Goede <hdegoede@redhat.com> | ||
2090 | * These are mini projectors using USB for both power and video data transport | 2192 | * These are mini projectors using USB for both power and video data transport |
2091 | * The usb-storage interface is a virtual windows driver CD, which the gm12u320 | 2193 | * The usb-storage interface is a virtual windows driver CD, which the gm12u320 |
2092 | * driver automatically converts into framebuffer & kms dri device nodes. | 2194 | * driver automatically converts into framebuffer & kms dri device nodes. |
@@ -2097,9 +2199,11 @@ UNUSUAL_DEV( 0x1de1, 0xc102, 0x0000, 0xffff, | |||
2097 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, | 2199 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, |
2098 | US_FL_IGNORE_DEVICE ), | 2200 | US_FL_IGNORE_DEVICE ), |
2099 | 2201 | ||
2100 | /* Patch by Richard Schütz <r.schtz@t-online.de> | 2202 | /* |
2203 | * Patch by Richard Schütz <r.schtz@t-online.de> | ||
2101 | * This external hard drive enclosure uses a JMicron chip which | 2204 | * This external hard drive enclosure uses a JMicron chip which |
2102 | * needs the US_FL_IGNORE_RESIDUE flag to work properly. */ | 2205 | * needs the US_FL_IGNORE_RESIDUE flag to work properly. |
2206 | */ | ||
2103 | UNUSUAL_DEV( 0x1e68, 0x001b, 0x0000, 0x0000, | 2207 | UNUSUAL_DEV( 0x1e68, 0x001b, 0x0000, 0x0000, |
2104 | "TrekStor GmbH & Co. KG", | 2208 | "TrekStor GmbH & Co. KG", |
2105 | "DataStation maxi g.u", | 2209 | "DataStation maxi g.u", |
@@ -2126,7 +2230,8 @@ UNUSUAL_DEV( 0x2116, 0x0320, 0x0001, 0x0001, | |||
2126 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, | 2230 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, |
2127 | US_FL_FIX_CAPACITY), | 2231 | US_FL_FIX_CAPACITY), |
2128 | 2232 | ||
2129 | /* patch submitted by Davide Perini <perini.davide@dpsoftware.org> | 2233 | /* |
2234 | * patch submitted by Davide Perini <perini.davide@dpsoftware.org> | ||
2130 | * and Renato Perini <rperini@email.it> | 2235 | * and Renato Perini <rperini@email.it> |
2131 | */ | 2236 | */ |
2132 | UNUSUAL_DEV( 0x22b8, 0x3010, 0x0001, 0x0001, | 2237 | UNUSUAL_DEV( 0x22b8, 0x3010, 0x0001, 0x0001, |
@@ -2153,7 +2258,8 @@ UNUSUAL_DEV( 0x2735, 0x100b, 0x0000, 0x9999, | |||
2153 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, | 2258 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, |
2154 | US_FL_GO_SLOW ), | 2259 | US_FL_GO_SLOW ), |
2155 | 2260 | ||
2156 | /* Reported by Frederic Marchal <frederic.marchal@wowcompany.com> | 2261 | /* |
2262 | * Reported by Frederic Marchal <frederic.marchal@wowcompany.com> | ||
2157 | * Mio Moov 330 | 2263 | * Mio Moov 330 |
2158 | */ | 2264 | */ |
2159 | UNUSUAL_DEV( 0x3340, 0xffff, 0x0000, 0x0000, | 2265 | UNUSUAL_DEV( 0x3340, 0xffff, 0x0000, 0x0000, |
diff --git a/drivers/usb/storage/unusual_freecom.h b/drivers/usb/storage/unusual_freecom.h index 59a261155b98..1f5aab42ece2 100644 --- a/drivers/usb/storage/unusual_freecom.h +++ b/drivers/usb/storage/unusual_freecom.h | |||
@@ -1,4 +1,5 @@ | |||
1 | /* Unusual Devices File for the Freecom USB/IDE adaptor | 1 | /* |
2 | * Unusual Devices File for the Freecom USB/IDE adaptor | ||
2 | * | 3 | * |
3 | * This program is free software; you can redistribute it and/or modify it | 4 | * This program is free software; you can redistribute it and/or modify it |
4 | * under the terms of the GNU General Public License as published by the | 5 | * under the terms of the GNU General Public License as published by the |
diff --git a/drivers/usb/storage/unusual_isd200.h b/drivers/usb/storage/unusual_isd200.h index 14cca0c48302..9b6862ec3d4f 100644 --- a/drivers/usb/storage/unusual_isd200.h +++ b/drivers/usb/storage/unusual_isd200.h | |||
@@ -1,4 +1,5 @@ | |||
1 | /* Unusual Devices File for In-System Design, Inc. ISD200 ASIC | 1 | /* |
2 | * Unusual Devices File for In-System Design, Inc. ISD200 ASIC | ||
2 | * | 3 | * |
3 | * This program is free software; you can redistribute it and/or modify it | 4 | * This program is free software; you can redistribute it and/or modify it |
4 | * under the terms of the GNU General Public License as published by the | 5 | * under the terms of the GNU General Public License as published by the |
diff --git a/drivers/usb/storage/unusual_jumpshot.h b/drivers/usb/storage/unusual_jumpshot.h index 54be78b5d643..413e64fa6b95 100644 --- a/drivers/usb/storage/unusual_jumpshot.h +++ b/drivers/usb/storage/unusual_jumpshot.h | |||
@@ -1,4 +1,5 @@ | |||
1 | /* Unusual Devices File for the Lexar "Jumpshot" Compact Flash reader | 1 | /* |
2 | * Unusual Devices File for the Lexar "Jumpshot" Compact Flash reader | ||
2 | * | 3 | * |
3 | * This program is free software; you can redistribute it and/or modify it | 4 | * This program is free software; you can redistribute it and/or modify it |
4 | * under the terms of the GNU General Public License as published by the | 5 | * under the terms of the GNU General Public License as published by the |
diff --git a/drivers/usb/storage/unusual_karma.h b/drivers/usb/storage/unusual_karma.h index 6df03972a22c..e6fad3aeae20 100644 --- a/drivers/usb/storage/unusual_karma.h +++ b/drivers/usb/storage/unusual_karma.h | |||
@@ -1,4 +1,5 @@ | |||
1 | /* Unusual Devices File for the Rio Karma | 1 | /* |
2 | * Unusual Devices File for the Rio Karma | ||
2 | * | 3 | * |
3 | * This program is free software; you can redistribute it and/or modify it | 4 | * This program is free software; you can redistribute it and/or modify it |
4 | * under the terms of the GNU General Public License as published by the | 5 | * under the terms of the GNU General Public License as published by the |
diff --git a/drivers/usb/storage/unusual_onetouch.h b/drivers/usb/storage/unusual_onetouch.h index 0abb819c7405..425dc22f345a 100644 --- a/drivers/usb/storage/unusual_onetouch.h +++ b/drivers/usb/storage/unusual_onetouch.h | |||
@@ -1,4 +1,5 @@ | |||
1 | /* Unusual Devices File for the Maxtor OneTouch USB hard drive's button | 1 | /* |
2 | * Unusual Devices File for the Maxtor OneTouch USB hard drive's button | ||
2 | * | 3 | * |
3 | * This program is free software; you can redistribute it and/or modify it | 4 | * This program is free software; you can redistribute it and/or modify it |
4 | * under the terms of the GNU General Public License as published by the | 5 | * under the terms of the GNU General Public License as published by the |
@@ -18,7 +19,8 @@ | |||
18 | #if defined(CONFIG_USB_STORAGE_ONETOUCH) || \ | 19 | #if defined(CONFIG_USB_STORAGE_ONETOUCH) || \ |
19 | defined(CONFIG_USB_STORAGE_ONETOUCH_MODULE) | 20 | defined(CONFIG_USB_STORAGE_ONETOUCH_MODULE) |
20 | 21 | ||
21 | /* Submitted by: Nick Sillik <n.sillik@temple.edu> | 22 | /* |
23 | * Submitted by: Nick Sillik <n.sillik@temple.edu> | ||
22 | * Needed for OneTouch extension to usb-storage | 24 | * Needed for OneTouch extension to usb-storage |
23 | */ | 25 | */ |
24 | UNUSUAL_DEV( 0x0d49, 0x7000, 0x0000, 0x9999, | 26 | UNUSUAL_DEV( 0x0d49, 0x7000, 0x0000, 0x9999, |
diff --git a/drivers/usb/storage/unusual_realtek.h b/drivers/usb/storage/unusual_realtek.h index e41f50c95ed4..8fe624ad302a 100644 --- a/drivers/usb/storage/unusual_realtek.h +++ b/drivers/usb/storage/unusual_realtek.h | |||
@@ -1,4 +1,5 @@ | |||
1 | /* Driver for Realtek RTS51xx USB card reader | 1 | /* |
2 | * Driver for Realtek RTS51xx USB card reader | ||
2 | * | 3 | * |
3 | * Copyright(c) 2009 Realtek Semiconductor Corp. All rights reserved. | 4 | * Copyright(c) 2009 Realtek Semiconductor Corp. All rights reserved. |
4 | * | 5 | * |
diff --git a/drivers/usb/storage/unusual_sddr09.h b/drivers/usb/storage/unusual_sddr09.h index 59a7e37b6c11..d9d38ac4abf9 100644 --- a/drivers/usb/storage/unusual_sddr09.h +++ b/drivers/usb/storage/unusual_sddr09.h | |||
@@ -1,4 +1,5 @@ | |||
1 | /* Unusual Devices File for SanDisk SDDR-09 SmartMedia reader | 1 | /* |
2 | * Unusual Devices File for SanDisk SDDR-09 SmartMedia reader | ||
2 | * | 3 | * |
3 | * This program is free software; you can redistribute it and/or modify it | 4 | * This program is free software; you can redistribute it and/or modify it |
4 | * under the terms of the GNU General Public License as published by the | 5 | * under the terms of the GNU General Public License as published by the |
diff --git a/drivers/usb/storage/unusual_sddr55.h b/drivers/usb/storage/unusual_sddr55.h index fcb7e12c598f..ebb1d1c6c467 100644 --- a/drivers/usb/storage/unusual_sddr55.h +++ b/drivers/usb/storage/unusual_sddr55.h | |||
@@ -1,4 +1,5 @@ | |||
1 | /* Unusual Devices File for SanDisk SDDR-55 SmartMedia reader | 1 | /* |
2 | * Unusual Devices File for SanDisk SDDR-55 SmartMedia reader | ||
2 | * | 3 | * |
3 | * This program is free software; you can redistribute it and/or modify it | 4 | * This program is free software; you can redistribute it and/or modify it |
4 | * under the terms of the GNU General Public License as published by the | 5 | * under the terms of the GNU General Public License as published by the |
diff --git a/drivers/usb/storage/unusual_uas.h b/drivers/usb/storage/unusual_uas.h index 53341a77d89f..cbea9f329e71 100644 --- a/drivers/usb/storage/unusual_uas.h +++ b/drivers/usb/storage/unusual_uas.h | |||
@@ -1,4 +1,5 @@ | |||
1 | /* Driver for USB Attached SCSI devices - Unusual Devices File | 1 | /* |
2 | * Driver for USB Attached SCSI devices - Unusual Devices File | ||
2 | * | 3 | * |
3 | * (c) 2013 Hans de Goede <hdegoede@redhat.com> | 4 | * (c) 2013 Hans de Goede <hdegoede@redhat.com> |
4 | * | 5 | * |
diff --git a/drivers/usb/storage/unusual_usbat.h b/drivers/usb/storage/unusual_usbat.h index 38e79c4e6d6a..2044ad5ef5e4 100644 --- a/drivers/usb/storage/unusual_usbat.h +++ b/drivers/usb/storage/unusual_usbat.h | |||
@@ -1,4 +1,5 @@ | |||
1 | /* Unusual Devices File for SCM Microsystems (a.k.a. Shuttle) USB-ATAPI cable | 1 | /* |
2 | * Unusual Devices File for SCM Microsystems (a.k.a. Shuttle) USB-ATAPI cable | ||
2 | * | 3 | * |
3 | * This program is free software; you can redistribute it and/or modify it | 4 | * This program is free software; you can redistribute it and/or modify it |
4 | * under the terms of the GNU General Public License as published by the | 5 | * under the terms of the GNU General Public License as published by the |
diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c index 9de988a0f856..ef2d8cde6ef7 100644 --- a/drivers/usb/storage/usb.c +++ b/drivers/usb/storage/usb.c | |||
@@ -1,4 +1,5 @@ | |||
1 | /* Driver for USB Mass Storage compliant devices | 1 | /* |
2 | * Driver for USB Mass Storage compliant devices | ||
2 | * | 3 | * |
3 | * Current development and maintenance by: | 4 | * Current development and maintenance by: |
4 | * (c) 1999-2003 Matthew Dharm (mdharm-usb@one-eyed-alien.net) | 5 | * (c) 1999-2003 Matthew Dharm (mdharm-usb@one-eyed-alien.net) |
@@ -97,7 +98,8 @@ MODULE_PARM_DESC(quirks, "supplemental list of device IDs and their quirks"); | |||
97 | * with the entries in usb_storage_usb_ids[], defined in usual-tables.c. | 98 | * with the entries in usb_storage_usb_ids[], defined in usual-tables.c. |
98 | */ | 99 | */ |
99 | 100 | ||
100 | /* The vendor name should be kept at eight characters or less, and | 101 | /* |
102 | *The vendor name should be kept at eight characters or less, and | ||
101 | * the product name should be kept at 16 characters or less. If a device | 103 | * the product name should be kept at 16 characters or less. If a device |
102 | * has the US_FL_FIX_INQUIRY flag, then the vendor and product names | 104 | * has the US_FL_FIX_INQUIRY flag, then the vendor and product names |
103 | * normally generated by a device through the INQUIRY response will be | 105 | * normally generated by a device through the INQUIRY response will be |
@@ -191,8 +193,10 @@ int usb_stor_suspend(struct usb_interface *iface, pm_message_t message) | |||
191 | if (us->suspend_resume_hook) | 193 | if (us->suspend_resume_hook) |
192 | (us->suspend_resume_hook)(us, US_SUSPEND); | 194 | (us->suspend_resume_hook)(us, US_SUSPEND); |
193 | 195 | ||
194 | /* When runtime PM is working, we'll set a flag to indicate | 196 | /* |
195 | * whether we should autoresume when a SCSI request arrives. */ | 197 | * When runtime PM is working, we'll set a flag to indicate |
198 | * whether we should autoresume when a SCSI request arrives. | ||
199 | */ | ||
196 | 200 | ||
197 | mutex_unlock(&us->dev_mutex); | 201 | mutex_unlock(&us->dev_mutex); |
198 | return 0; | 202 | return 0; |
@@ -220,8 +224,10 @@ int usb_stor_reset_resume(struct usb_interface *iface) | |||
220 | /* Report the reset to the SCSI core */ | 224 | /* Report the reset to the SCSI core */ |
221 | usb_stor_report_bus_reset(us); | 225 | usb_stor_report_bus_reset(us); |
222 | 226 | ||
223 | /* FIXME: Notify the subdrivers that they need to reinitialize | 227 | /* |
224 | * the device */ | 228 | * FIXME: Notify the subdrivers that they need to reinitialize |
229 | * the device | ||
230 | */ | ||
225 | return 0; | 231 | return 0; |
226 | } | 232 | } |
227 | EXPORT_SYMBOL_GPL(usb_stor_reset_resume); | 233 | EXPORT_SYMBOL_GPL(usb_stor_reset_resume); |
@@ -250,8 +256,10 @@ int usb_stor_post_reset(struct usb_interface *iface) | |||
250 | /* Report the reset to the SCSI core */ | 256 | /* Report the reset to the SCSI core */ |
251 | usb_stor_report_bus_reset(us); | 257 | usb_stor_report_bus_reset(us); |
252 | 258 | ||
253 | /* FIXME: Notify the subdrivers that they need to reinitialize | 259 | /* |
254 | * the device */ | 260 | * FIXME: Notify the subdrivers that they need to reinitialize |
261 | * the device | ||
262 | */ | ||
255 | 263 | ||
256 | mutex_unlock(&us->dev_mutex); | 264 | mutex_unlock(&us->dev_mutex); |
257 | return 0; | 265 | return 0; |
@@ -274,15 +282,17 @@ void fill_inquiry_response(struct us_data *us, unsigned char *data, | |||
274 | return; | 282 | return; |
275 | 283 | ||
276 | memset(data+8, ' ', 28); | 284 | memset(data+8, ' ', 28); |
277 | if (data[0]&0x20) { /* USB device currently not connected. Return | 285 | if (data[0]&0x20) { /* |
278 | peripheral qualifier 001b ("...however, the | 286 | * USB device currently not connected. Return |
279 | physical device is not currently connected | 287 | * peripheral qualifier 001b ("...however, the |
280 | to this logical unit") and leave vendor and | 288 | * physical device is not currently connected |
281 | product identification empty. ("If the target | 289 | * to this logical unit") and leave vendor and |
282 | does store some of the INQUIRY data on the | 290 | * product identification empty. ("If the target |
283 | device, it may return zeros or ASCII spaces | 291 | * does store some of the INQUIRY data on the |
284 | (20h) in those fields until the data is | 292 | * device, it may return zeros or ASCII spaces |
285 | available from the device."). */ | 293 | * (20h) in those fields until the data is |
294 | * available from the device."). | ||
295 | */ | ||
286 | } else { | 296 | } else { |
287 | u16 bcdDevice = le16_to_cpu(us->pusb_dev->descriptor.bcdDevice); | 297 | u16 bcdDevice = le16_to_cpu(us->pusb_dev->descriptor.bcdDevice); |
288 | int n; | 298 | int n; |
@@ -336,7 +346,8 @@ static int usb_stor_control_thread(void * __us) | |||
336 | 346 | ||
337 | scsi_unlock(host); | 347 | scsi_unlock(host); |
338 | 348 | ||
339 | /* reject the command if the direction indicator | 349 | /* |
350 | * reject the command if the direction indicator | ||
340 | * is UNKNOWN | 351 | * is UNKNOWN |
341 | */ | 352 | */ |
342 | if (us->srb->sc_data_direction == DMA_BIDIRECTIONAL) { | 353 | if (us->srb->sc_data_direction == DMA_BIDIRECTIONAL) { |
@@ -344,7 +355,8 @@ static int usb_stor_control_thread(void * __us) | |||
344 | us->srb->result = DID_ERROR << 16; | 355 | us->srb->result = DID_ERROR << 16; |
345 | } | 356 | } |
346 | 357 | ||
347 | /* reject if target != 0 or if LUN is higher than | 358 | /* |
359 | * reject if target != 0 or if LUN is higher than | ||
348 | * the maximum known LUN | 360 | * the maximum known LUN |
349 | */ | 361 | */ |
350 | else if (us->srb->device->id && | 362 | else if (us->srb->device->id && |
@@ -362,8 +374,10 @@ static int usb_stor_control_thread(void * __us) | |||
362 | us->srb->result = DID_BAD_TARGET << 16; | 374 | us->srb->result = DID_BAD_TARGET << 16; |
363 | } | 375 | } |
364 | 376 | ||
365 | /* Handle those devices which need us to fake | 377 | /* |
366 | * their inquiry data */ | 378 | * Handle those devices which need us to fake |
379 | * their inquiry data | ||
380 | */ | ||
367 | else if ((us->srb->cmnd[0] == INQUIRY) && | 381 | else if ((us->srb->cmnd[0] == INQUIRY) && |
368 | (us->fflags & US_FL_FIX_INQUIRY)) { | 382 | (us->fflags & US_FL_FIX_INQUIRY)) { |
369 | unsigned char data_ptr[36] = { | 383 | unsigned char data_ptr[36] = { |
@@ -395,11 +409,13 @@ SkipForAbort: | |||
395 | usb_stor_dbg(us, "scsi command aborted\n"); | 409 | usb_stor_dbg(us, "scsi command aborted\n"); |
396 | } | 410 | } |
397 | 411 | ||
398 | /* If an abort request was received we need to signal that | 412 | /* |
413 | * If an abort request was received we need to signal that | ||
399 | * the abort has finished. The proper test for this is | 414 | * the abort has finished. The proper test for this is |
400 | * the TIMED_OUT flag, not srb->result == DID_ABORT, because | 415 | * the TIMED_OUT flag, not srb->result == DID_ABORT, because |
401 | * the timeout might have occurred after the command had | 416 | * the timeout might have occurred after the command had |
402 | * already completed with a different result code. */ | 417 | * already completed with a different result code. |
418 | */ | ||
403 | if (test_bit(US_FLIDX_TIMED_OUT, &us->dflags)) { | 419 | if (test_bit(US_FLIDX_TIMED_OUT, &us->dflags)) { |
404 | complete(&(us->notify)); | 420 | complete(&(us->notify)); |
405 | 421 | ||
@@ -610,7 +626,8 @@ static int get_device_info(struct us_data *us, const struct usb_device_id *id, | |||
610 | le16_to_cpu(dev->descriptor.idProduct), | 626 | le16_to_cpu(dev->descriptor.idProduct), |
611 | us->fflags); | 627 | us->fflags); |
612 | 628 | ||
613 | /* Log a message if a non-generic unusual_dev entry contains an | 629 | /* |
630 | * Log a message if a non-generic unusual_dev entry contains an | ||
614 | * unnecessary subclass or protocol override. This may stimulate | 631 | * unnecessary subclass or protocol override. This may stimulate |
615 | * reports from users that will help us remove unneeded entries | 632 | * reports from users that will help us remove unneeded entries |
616 | * from the unusual_devs.h table. | 633 | * from the unusual_devs.h table. |
@@ -782,8 +799,10 @@ static int usb_stor_acquire_resources(struct us_data *us) | |||
782 | return -ENOMEM; | 799 | return -ENOMEM; |
783 | } | 800 | } |
784 | 801 | ||
785 | /* Just before we start our control thread, initialize | 802 | /* |
786 | * the device if it needs initialization */ | 803 | * Just before we start our control thread, initialize |
804 | * the device if it needs initialization | ||
805 | */ | ||
787 | if (us->unusual_dev->initFunction) { | 806 | if (us->unusual_dev->initFunction) { |
788 | p = us->unusual_dev->initFunction(us); | 807 | p = us->unusual_dev->initFunction(us); |
789 | if (p) | 808 | if (p) |
@@ -805,7 +824,8 @@ static int usb_stor_acquire_resources(struct us_data *us) | |||
805 | /* Release all our dynamic resources */ | 824 | /* Release all our dynamic resources */ |
806 | static void usb_stor_release_resources(struct us_data *us) | 825 | static void usb_stor_release_resources(struct us_data *us) |
807 | { | 826 | { |
808 | /* Tell the control thread to exit. The SCSI host must | 827 | /* |
828 | * Tell the control thread to exit. The SCSI host must | ||
809 | * already have been removed and the DISCONNECTING flag set | 829 | * already have been removed and the DISCONNECTING flag set |
810 | * so that we won't accept any more commands. | 830 | * so that we won't accept any more commands. |
811 | */ | 831 | */ |
@@ -836,7 +856,8 @@ static void dissociate_dev(struct us_data *us) | |||
836 | usb_set_intfdata(us->pusb_intf, NULL); | 856 | usb_set_intfdata(us->pusb_intf, NULL); |
837 | } | 857 | } |
838 | 858 | ||
839 | /* First stage of disconnect processing: stop SCSI scanning, | 859 | /* |
860 | * First stage of disconnect processing: stop SCSI scanning, | ||
840 | * remove the host, and stop accepting new commands | 861 | * remove the host, and stop accepting new commands |
841 | */ | 862 | */ |
842 | static void quiesce_and_remove_host(struct us_data *us) | 863 | static void quiesce_and_remove_host(struct us_data *us) |
@@ -849,7 +870,8 @@ static void quiesce_and_remove_host(struct us_data *us) | |||
849 | wake_up(&us->delay_wait); | 870 | wake_up(&us->delay_wait); |
850 | } | 871 | } |
851 | 872 | ||
852 | /* Prevent SCSI scanning (if it hasn't started yet) | 873 | /* |
874 | * Prevent SCSI scanning (if it hasn't started yet) | ||
853 | * or wait for the SCSI-scanning routine to stop. | 875 | * or wait for the SCSI-scanning routine to stop. |
854 | */ | 876 | */ |
855 | cancel_delayed_work_sync(&us->scan_dwork); | 877 | cancel_delayed_work_sync(&us->scan_dwork); |
@@ -858,12 +880,14 @@ static void quiesce_and_remove_host(struct us_data *us) | |||
858 | if (test_bit(US_FLIDX_SCAN_PENDING, &us->dflags)) | 880 | if (test_bit(US_FLIDX_SCAN_PENDING, &us->dflags)) |
859 | usb_autopm_put_interface_no_suspend(us->pusb_intf); | 881 | usb_autopm_put_interface_no_suspend(us->pusb_intf); |
860 | 882 | ||
861 | /* Removing the host will perform an orderly shutdown: caches | 883 | /* |
884 | * Removing the host will perform an orderly shutdown: caches | ||
862 | * synchronized, disks spun down, etc. | 885 | * synchronized, disks spun down, etc. |
863 | */ | 886 | */ |
864 | scsi_remove_host(host); | 887 | scsi_remove_host(host); |
865 | 888 | ||
866 | /* Prevent any new commands from being accepted and cut short | 889 | /* |
890 | * Prevent any new commands from being accepted and cut short | ||
867 | * reset delays. | 891 | * reset delays. |
868 | */ | 892 | */ |
869 | scsi_lock(host); | 893 | scsi_lock(host); |
@@ -878,8 +902,10 @@ static void release_everything(struct us_data *us) | |||
878 | usb_stor_release_resources(us); | 902 | usb_stor_release_resources(us); |
879 | dissociate_dev(us); | 903 | dissociate_dev(us); |
880 | 904 | ||
881 | /* Drop our reference to the host; the SCSI core will free it | 905 | /* |
882 | * (and "us" along with it) when the refcount becomes 0. */ | 906 | * Drop our reference to the host; the SCSI core will free it |
907 | * (and "us" along with it) when the refcount becomes 0. | ||
908 | */ | ||
883 | scsi_host_put(us_to_host(us)); | 909 | scsi_host_put(us_to_host(us)); |
884 | } | 910 | } |
885 | 911 | ||
@@ -900,7 +926,8 @@ static void usb_stor_scan_dwork(struct work_struct *work) | |||
900 | us->max_lun = usb_stor_Bulk_max_lun(us); | 926 | us->max_lun = usb_stor_Bulk_max_lun(us); |
901 | /* | 927 | /* |
902 | * Allow proper scanning of devices that present more than 8 LUNs | 928 | * Allow proper scanning of devices that present more than 8 LUNs |
903 | * While not affecting other devices that may need the previous behavior | 929 | * While not affecting other devices that may need the previous |
930 | * behavior | ||
904 | */ | 931 | */ |
905 | if (us->max_lun >= 8) | 932 | if (us->max_lun >= 8) |
906 | us_to_host(us)->max_lun = us->max_lun+1; | 933 | us_to_host(us)->max_lun = us->max_lun+1; |
@@ -975,7 +1002,8 @@ int usb_stor_probe1(struct us_data **pus, | |||
975 | get_transport(us); | 1002 | get_transport(us); |
976 | get_protocol(us); | 1003 | get_protocol(us); |
977 | 1004 | ||
978 | /* Give the caller a chance to fill in specialized transport | 1005 | /* |
1006 | * Give the caller a chance to fill in specialized transport | ||
979 | * or protocol settings. | 1007 | * or protocol settings. |
980 | */ | 1008 | */ |
981 | return 0; | 1009 | return 0; |
diff --git a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h index da0ad3241728..8fae28b40bb4 100644 --- a/drivers/usb/storage/usb.h +++ b/drivers/usb/storage/usb.h | |||
@@ -1,4 +1,5 @@ | |||
1 | /* Driver for USB Mass Storage compliant devices | 1 | /* |
2 | * Driver for USB Mass Storage compliant devices | ||
2 | * Main Header File | 3 | * Main Header File |
3 | * | 4 | * |
4 | * Current development and maintenance by: | 5 | * Current development and maintenance by: |
@@ -100,7 +101,8 @@ typedef void (*pm_hook)(struct us_data *, int); /* power management hook */ | |||
100 | 101 | ||
101 | /* we allocate one of these for every device that we remember */ | 102 | /* we allocate one of these for every device that we remember */ |
102 | struct us_data { | 103 | struct us_data { |
103 | /* The device we're working with | 104 | /* |
105 | * The device we're working with | ||
104 | * It's important to note: | 106 | * It's important to note: |
105 | * (o) you must hold dev_mutex to change pusb_dev | 107 | * (o) you must hold dev_mutex to change pusb_dev |
106 | */ | 108 | */ |
@@ -125,7 +127,7 @@ struct us_data { | |||
125 | u8 max_lun; | 127 | u8 max_lun; |
126 | 128 | ||
127 | u8 ifnum; /* interface number */ | 129 | u8 ifnum; /* interface number */ |
128 | u8 ep_bInterval; /* interrupt interval */ | 130 | u8 ep_bInterval; /* interrupt interval */ |
129 | 131 | ||
130 | /* function pointers for this device */ | 132 | /* function pointers for this device */ |
131 | trans_cmnd transport; /* transport function */ | 133 | trans_cmnd transport; /* transport function */ |
@@ -175,8 +177,10 @@ static inline struct us_data *host_to_us(struct Scsi_Host *host) { | |||
175 | extern void fill_inquiry_response(struct us_data *us, | 177 | extern void fill_inquiry_response(struct us_data *us, |
176 | unsigned char *data, unsigned int data_len); | 178 | unsigned char *data, unsigned int data_len); |
177 | 179 | ||
178 | /* The scsi_lock() and scsi_unlock() macros protect the sm_state and the | 180 | /* |
179 | * single queue element srb for write access */ | 181 | * The scsi_lock() and scsi_unlock() macros protect the sm_state and the |
182 | * single queue element srb for write access | ||
183 | */ | ||
180 | #define scsi_unlock(host) spin_unlock_irq(host->host_lock) | 184 | #define scsi_unlock(host) spin_unlock_irq(host->host_lock) |
181 | #define scsi_lock(host) spin_lock_irq(host->host_lock) | 185 | #define scsi_lock(host) spin_lock_irq(host->host_lock) |
182 | 186 | ||
diff --git a/drivers/usb/storage/usual-tables.c b/drivers/usb/storage/usual-tables.c index 5ef8ce74aae4..499669bcf700 100644 --- a/drivers/usb/storage/usual-tables.c +++ b/drivers/usb/storage/usual-tables.c | |||
@@ -1,4 +1,5 @@ | |||
1 | /* Driver for USB Mass Storage devices | 1 | /* |
2 | * Driver for USB Mass Storage devices | ||
2 | * Usual Tables File for usb-storage and libusual | 3 | * Usual Tables File for usb-storage and libusual |
3 | * | 4 | * |
4 | * Copyright (C) 2009 Alan Stern (stern@rowland.harvard.edu) | 5 | * Copyright (C) 2009 Alan Stern (stern@rowland.harvard.edu) |
diff --git a/drivers/usb/usbip/Kconfig b/drivers/usb/usbip/Kconfig index bd99e9e47e50..17646b25343f 100644 --- a/drivers/usb/usbip/Kconfig +++ b/drivers/usb/usbip/Kconfig | |||
@@ -1,6 +1,6 @@ | |||
1 | config USBIP_CORE | 1 | config USBIP_CORE |
2 | tristate "USB/IP support" | 2 | tristate "USB/IP support" |
3 | depends on USB && NET | 3 | depends on USB_COMMON && NET |
4 | ---help--- | 4 | ---help--- |
5 | This enables pushing USB packets over IP to allow remote | 5 | This enables pushing USB packets over IP to allow remote |
6 | machines direct access to USB devices. It provides the | 6 | machines direct access to USB devices. It provides the |
@@ -16,7 +16,7 @@ config USBIP_CORE | |||
16 | 16 | ||
17 | config USBIP_VHCI_HCD | 17 | config USBIP_VHCI_HCD |
18 | tristate "VHCI hcd" | 18 | tristate "VHCI hcd" |
19 | depends on USBIP_CORE | 19 | depends on USBIP_CORE && USB |
20 | ---help--- | 20 | ---help--- |
21 | This enables the USB/IP virtual host controller driver, | 21 | This enables the USB/IP virtual host controller driver, |
22 | which is run on the remote machine. | 22 | which is run on the remote machine. |
@@ -26,7 +26,7 @@ config USBIP_VHCI_HCD | |||
26 | 26 | ||
27 | config USBIP_HOST | 27 | config USBIP_HOST |
28 | tristate "Host driver" | 28 | tristate "Host driver" |
29 | depends on USBIP_CORE | 29 | depends on USBIP_CORE && USB |
30 | ---help--- | 30 | ---help--- |
31 | This enables the USB/IP host driver, which is run on the | 31 | This enables the USB/IP host driver, which is run on the |
32 | machine that is sharing the USB devices. | 32 | machine that is sharing the USB devices. |
@@ -34,6 +34,17 @@ config USBIP_HOST | |||
34 | To compile this driver as a module, choose M here: the | 34 | To compile this driver as a module, choose M here: the |
35 | module will be called usbip-host. | 35 | module will be called usbip-host. |
36 | 36 | ||
37 | config USBIP_VUDC | ||
38 | tristate "VUDC driver" | ||
39 | depends on USBIP_CORE && USB_GADGET | ||
40 | ---help--- | ||
41 | This enables the USB/IP virtual USB device controller | ||
42 | driver, which is run on the host machine, allowing the | ||
43 | machine itself to act as a device. | ||
44 | |||
45 | To compile this driver as a module, choose M here: the | ||
46 | module will be called usbip-vudc. | ||
47 | |||
37 | config USBIP_DEBUG | 48 | config USBIP_DEBUG |
38 | bool "Debug messages for USB/IP" | 49 | bool "Debug messages for USB/IP" |
39 | depends on USBIP_CORE | 50 | depends on USBIP_CORE |
diff --git a/drivers/usb/usbip/Makefile b/drivers/usb/usbip/Makefile index 9ecd61545be1..d843a9e68852 100644 --- a/drivers/usb/usbip/Makefile +++ b/drivers/usb/usbip/Makefile | |||
@@ -8,3 +8,6 @@ vhci-hcd-y := vhci_sysfs.o vhci_tx.o vhci_rx.o vhci_hcd.o | |||
8 | 8 | ||
9 | obj-$(CONFIG_USBIP_HOST) += usbip-host.o | 9 | obj-$(CONFIG_USBIP_HOST) += usbip-host.o |
10 | usbip-host-y := stub_dev.o stub_main.o stub_rx.o stub_tx.o | 10 | usbip-host-y := stub_dev.o stub_main.o stub_rx.o stub_tx.o |
11 | |||
12 | obj-$(CONFIG_USBIP_VUDC) += usbip-vudc.o | ||
13 | usbip-vudc-y := vudc_dev.o vudc_sysfs.o vudc_tx.o vudc_rx.o vudc_transfer.o vudc_main.o | ||
diff --git a/drivers/usb/usbip/stub.h b/drivers/usb/usbip/stub.h index 266e2b0ce9a8..910f027773aa 100644 --- a/drivers/usb/usbip/stub.h +++ b/drivers/usb/usbip/stub.h | |||
@@ -33,7 +33,6 @@ | |||
33 | #define STUB_BUSID_ALLOC 3 | 33 | #define STUB_BUSID_ALLOC 3 |
34 | 34 | ||
35 | struct stub_device { | 35 | struct stub_device { |
36 | struct usb_interface *interface; | ||
37 | struct usb_device *udev; | 36 | struct usb_device *udev; |
38 | 37 | ||
39 | struct usbip_device ud; | 38 | struct usbip_device ud; |
diff --git a/drivers/usb/usbip/stub_dev.c b/drivers/usb/usbip/stub_dev.c index a3ec49bdc1e6..c653ce533430 100644 --- a/drivers/usb/usbip/stub_dev.c +++ b/drivers/usb/usbip/stub_dev.c | |||
@@ -219,7 +219,7 @@ static void stub_device_reset(struct usbip_device *ud) | |||
219 | 219 | ||
220 | dev_dbg(&udev->dev, "device reset"); | 220 | dev_dbg(&udev->dev, "device reset"); |
221 | 221 | ||
222 | ret = usb_lock_device_for_reset(udev, sdev->interface); | 222 | ret = usb_lock_device_for_reset(udev, NULL); |
223 | if (ret < 0) { | 223 | if (ret < 0) { |
224 | dev_err(&udev->dev, "lock for reset\n"); | 224 | dev_err(&udev->dev, "lock for reset\n"); |
225 | spin_lock_irq(&ud->lock); | 225 | spin_lock_irq(&ud->lock); |
@@ -252,7 +252,7 @@ static void stub_device_unusable(struct usbip_device *ud) | |||
252 | 252 | ||
253 | /** | 253 | /** |
254 | * stub_device_alloc - allocate a new stub_device struct | 254 | * stub_device_alloc - allocate a new stub_device struct |
255 | * @interface: usb_interface of a new device | 255 | * @udev: usb_device of a new device |
256 | * | 256 | * |
257 | * Allocates and initializes a new stub_device struct. | 257 | * Allocates and initializes a new stub_device struct. |
258 | */ | 258 | */ |
@@ -388,7 +388,6 @@ err_files: | |||
388 | err_port: | 388 | err_port: |
389 | dev_set_drvdata(&udev->dev, NULL); | 389 | dev_set_drvdata(&udev->dev, NULL); |
390 | usb_put_dev(udev); | 390 | usb_put_dev(udev); |
391 | kthread_stop_put(sdev->ud.eh); | ||
392 | 391 | ||
393 | busid_priv->sdev = NULL; | 392 | busid_priv->sdev = NULL; |
394 | stub_device_free(sdev); | 393 | stub_device_free(sdev); |
@@ -449,7 +448,7 @@ static void stub_disconnect(struct usb_device *udev) | |||
449 | } | 448 | } |
450 | 449 | ||
451 | /* If usb reset is called from event handler */ | 450 | /* If usb reset is called from event handler */ |
452 | if (busid_priv->sdev->ud.eh == current) | 451 | if (usbip_in_eh(current)) |
453 | return; | 452 | return; |
454 | 453 | ||
455 | /* shutdown the current connection */ | 454 | /* shutdown the current connection */ |
diff --git a/drivers/usb/usbip/stub_rx.c b/drivers/usb/usbip/stub_rx.c index 00e475c51a12..2df63e305722 100644 --- a/drivers/usb/usbip/stub_rx.c +++ b/drivers/usb/usbip/stub_rx.c | |||
@@ -165,12 +165,7 @@ static int tweak_reset_device_cmd(struct urb *urb) | |||
165 | 165 | ||
166 | dev_info(&urb->dev->dev, "usb_queue_reset_device\n"); | 166 | dev_info(&urb->dev->dev, "usb_queue_reset_device\n"); |
167 | 167 | ||
168 | /* | 168 | if (usb_lock_device_for_reset(sdev->udev, NULL) < 0) { |
169 | * With the implementation of pre_reset and post_reset the driver no | ||
170 | * longer unbinds. This allows the use of synchronous reset. | ||
171 | */ | ||
172 | |||
173 | if (usb_lock_device_for_reset(sdev->udev, sdev->interface) < 0) { | ||
174 | dev_err(&urb->dev->dev, "could not obtain lock to reset device\n"); | 169 | dev_err(&urb->dev->dev, "could not obtain lock to reset device\n"); |
175 | return 0; | 170 | return 0; |
176 | } | 171 | } |
@@ -321,7 +316,7 @@ static struct stub_priv *stub_priv_alloc(struct stub_device *sdev, | |||
321 | 316 | ||
322 | priv = kmem_cache_zalloc(stub_priv_cache, GFP_ATOMIC); | 317 | priv = kmem_cache_zalloc(stub_priv_cache, GFP_ATOMIC); |
323 | if (!priv) { | 318 | if (!priv) { |
324 | dev_err(&sdev->interface->dev, "alloc stub_priv\n"); | 319 | dev_err(&sdev->udev->dev, "alloc stub_priv\n"); |
325 | spin_unlock_irqrestore(&sdev->priv_lock, flags); | 320 | spin_unlock_irqrestore(&sdev->priv_lock, flags); |
326 | usbip_event_add(ud, SDEV_EVENT_ERROR_MALLOC); | 321 | usbip_event_add(ud, SDEV_EVENT_ERROR_MALLOC); |
327 | return NULL; | 322 | return NULL; |
@@ -352,7 +347,7 @@ static int get_pipe(struct stub_device *sdev, int epnum, int dir) | |||
352 | else | 347 | else |
353 | ep = udev->ep_out[epnum & 0x7f]; | 348 | ep = udev->ep_out[epnum & 0x7f]; |
354 | if (!ep) { | 349 | if (!ep) { |
355 | dev_err(&sdev->interface->dev, "no such endpoint?, %d\n", | 350 | dev_err(&sdev->udev->dev, "no such endpoint?, %d\n", |
356 | epnum); | 351 | epnum); |
357 | BUG(); | 352 | BUG(); |
358 | } | 353 | } |
@@ -387,7 +382,7 @@ static int get_pipe(struct stub_device *sdev, int epnum, int dir) | |||
387 | } | 382 | } |
388 | 383 | ||
389 | /* NOT REACHED */ | 384 | /* NOT REACHED */ |
390 | dev_err(&sdev->interface->dev, "get pipe, epnum %d\n", epnum); | 385 | dev_err(&sdev->udev->dev, "get pipe, epnum %d\n", epnum); |
391 | return 0; | 386 | return 0; |
392 | } | 387 | } |
393 | 388 | ||
@@ -466,7 +461,7 @@ static void stub_recv_cmd_submit(struct stub_device *sdev, | |||
466 | priv->urb = usb_alloc_urb(0, GFP_KERNEL); | 461 | priv->urb = usb_alloc_urb(0, GFP_KERNEL); |
467 | 462 | ||
468 | if (!priv->urb) { | 463 | if (!priv->urb) { |
469 | dev_err(&sdev->interface->dev, "malloc urb\n"); | 464 | dev_err(&udev->dev, "malloc urb\n"); |
470 | usbip_event_add(ud, SDEV_EVENT_ERROR_MALLOC); | 465 | usbip_event_add(ud, SDEV_EVENT_ERROR_MALLOC); |
471 | return; | 466 | return; |
472 | } | 467 | } |
@@ -486,7 +481,7 @@ static void stub_recv_cmd_submit(struct stub_device *sdev, | |||
486 | priv->urb->setup_packet = kmemdup(&pdu->u.cmd_submit.setup, 8, | 481 | priv->urb->setup_packet = kmemdup(&pdu->u.cmd_submit.setup, 8, |
487 | GFP_KERNEL); | 482 | GFP_KERNEL); |
488 | if (!priv->urb->setup_packet) { | 483 | if (!priv->urb->setup_packet) { |
489 | dev_err(&sdev->interface->dev, "allocate setup_packet\n"); | 484 | dev_err(&udev->dev, "allocate setup_packet\n"); |
490 | usbip_event_add(ud, SDEV_EVENT_ERROR_MALLOC); | 485 | usbip_event_add(ud, SDEV_EVENT_ERROR_MALLOC); |
491 | return; | 486 | return; |
492 | } | 487 | } |
@@ -517,7 +512,7 @@ static void stub_recv_cmd_submit(struct stub_device *sdev, | |||
517 | usbip_dbg_stub_rx("submit urb ok, seqnum %u\n", | 512 | usbip_dbg_stub_rx("submit urb ok, seqnum %u\n", |
518 | pdu->base.seqnum); | 513 | pdu->base.seqnum); |
519 | else { | 514 | else { |
520 | dev_err(&sdev->interface->dev, "submit_urb error, %d\n", ret); | 515 | dev_err(&udev->dev, "submit_urb error, %d\n", ret); |
521 | usbip_dump_header(pdu); | 516 | usbip_dump_header(pdu); |
522 | usbip_dump_urb(priv->urb); | 517 | usbip_dump_urb(priv->urb); |
523 | 518 | ||
diff --git a/drivers/usb/usbip/stub_tx.c b/drivers/usb/usbip/stub_tx.c index dbcabc9dbe0d..6b1e8c3f0e4b 100644 --- a/drivers/usb/usbip/stub_tx.c +++ b/drivers/usb/usbip/stub_tx.c | |||
@@ -97,7 +97,10 @@ void stub_complete(struct urb *urb) | |||
97 | 97 | ||
98 | /* link a urb to the queue of tx. */ | 98 | /* link a urb to the queue of tx. */ |
99 | spin_lock_irqsave(&sdev->priv_lock, flags); | 99 | spin_lock_irqsave(&sdev->priv_lock, flags); |
100 | if (priv->unlinking) { | 100 | if (sdev->ud.tcp_socket == NULL) { |
101 | usbip_dbg_stub_tx("ignore urb for closed connection %p", urb); | ||
102 | /* It will be freed in stub_device_cleanup_urbs(). */ | ||
103 | } else if (priv->unlinking) { | ||
101 | stub_enqueue_ret_unlink(sdev, priv->seqnum, urb->status); | 104 | stub_enqueue_ret_unlink(sdev, priv->seqnum, urb->status); |
102 | stub_free_priv_and_urb(priv); | 105 | stub_free_priv_and_urb(priv); |
103 | } else { | 106 | } else { |
@@ -229,7 +232,7 @@ static int stub_send_ret_submit(struct stub_device *sdev) | |||
229 | } | 232 | } |
230 | 233 | ||
231 | if (txsize != sizeof(pdu_header) + urb->actual_length) { | 234 | if (txsize != sizeof(pdu_header) + urb->actual_length) { |
232 | dev_err(&sdev->interface->dev, | 235 | dev_err(&sdev->udev->dev, |
233 | "actual length of urb %d does not match iso packet sizes %zu\n", | 236 | "actual length of urb %d does not match iso packet sizes %zu\n", |
234 | urb->actual_length, | 237 | urb->actual_length, |
235 | txsize-sizeof(pdu_header)); | 238 | txsize-sizeof(pdu_header)); |
@@ -261,7 +264,7 @@ static int stub_send_ret_submit(struct stub_device *sdev) | |||
261 | ret = kernel_sendmsg(sdev->ud.tcp_socket, &msg, | 264 | ret = kernel_sendmsg(sdev->ud.tcp_socket, &msg, |
262 | iov, iovnum, txsize); | 265 | iov, iovnum, txsize); |
263 | if (ret != txsize) { | 266 | if (ret != txsize) { |
264 | dev_err(&sdev->interface->dev, | 267 | dev_err(&sdev->udev->dev, |
265 | "sendmsg failed!, retval %d for %zd\n", | 268 | "sendmsg failed!, retval %d for %zd\n", |
266 | ret, txsize); | 269 | ret, txsize); |
267 | kfree(iov); | 270 | kfree(iov); |
@@ -336,7 +339,7 @@ static int stub_send_ret_unlink(struct stub_device *sdev) | |||
336 | ret = kernel_sendmsg(sdev->ud.tcp_socket, &msg, iov, | 339 | ret = kernel_sendmsg(sdev->ud.tcp_socket, &msg, iov, |
337 | 1, txsize); | 340 | 1, txsize); |
338 | if (ret != txsize) { | 341 | if (ret != txsize) { |
339 | dev_err(&sdev->interface->dev, | 342 | dev_err(&sdev->udev->dev, |
340 | "sendmsg failed!, retval %d for %zd\n", | 343 | "sendmsg failed!, retval %d for %zd\n", |
341 | ret, txsize); | 344 | ret, txsize); |
342 | usbip_event_add(&sdev->ud, SDEV_EVENT_ERROR_TCP); | 345 | usbip_event_add(&sdev->ud, SDEV_EVENT_ERROR_TCP); |
diff --git a/drivers/usb/usbip/usbip_common.c b/drivers/usb/usbip/usbip_common.c index e40da7759a0e..8b232290be6b 100644 --- a/drivers/usb/usbip/usbip_common.c +++ b/drivers/usb/usbip/usbip_common.c | |||
@@ -1,5 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2003-2008 Takahiro Hirofuchi | 2 | * Copyright (C) 2003-2008 Takahiro Hirofuchi |
3 | * Copyright (C) 2015-2016 Samsung Electronics | ||
4 | * Krzysztof Opasiak <k.opasiak@samsung.com> | ||
3 | * | 5 | * |
4 | * This is free software; you can redistribute it and/or modify | 6 | * This is free software; you can redistribute it and/or modify |
5 | * it under the terms of the GNU General Public License as published by | 7 | * it under the terms of the GNU General Public License as published by |
@@ -643,7 +645,7 @@ int usbip_recv_iso(struct usbip_device *ud, struct urb *urb) | |||
643 | ret); | 645 | ret); |
644 | kfree(buff); | 646 | kfree(buff); |
645 | 647 | ||
646 | if (ud->side == USBIP_STUB) | 648 | if (ud->side == USBIP_STUB || ud->side == USBIP_VUDC) |
647 | usbip_event_add(ud, SDEV_EVENT_ERROR_TCP); | 649 | usbip_event_add(ud, SDEV_EVENT_ERROR_TCP); |
648 | else | 650 | else |
649 | usbip_event_add(ud, VDEV_EVENT_ERROR_TCP); | 651 | usbip_event_add(ud, VDEV_EVENT_ERROR_TCP); |
@@ -665,7 +667,7 @@ int usbip_recv_iso(struct usbip_device *ud, struct urb *urb) | |||
665 | "total length of iso packets %d not equal to actual length of buffer %d\n", | 667 | "total length of iso packets %d not equal to actual length of buffer %d\n", |
666 | total_length, urb->actual_length); | 668 | total_length, urb->actual_length); |
667 | 669 | ||
668 | if (ud->side == USBIP_STUB) | 670 | if (ud->side == USBIP_STUB || ud->side == USBIP_VUDC) |
669 | usbip_event_add(ud, SDEV_EVENT_ERROR_TCP); | 671 | usbip_event_add(ud, SDEV_EVENT_ERROR_TCP); |
670 | else | 672 | else |
671 | usbip_event_add(ud, VDEV_EVENT_ERROR_TCP); | 673 | usbip_event_add(ud, VDEV_EVENT_ERROR_TCP); |
@@ -723,7 +725,7 @@ int usbip_recv_xbuff(struct usbip_device *ud, struct urb *urb) | |||
723 | int ret; | 725 | int ret; |
724 | int size; | 726 | int size; |
725 | 727 | ||
726 | if (ud->side == USBIP_STUB) { | 728 | if (ud->side == USBIP_STUB || ud->side == USBIP_VUDC) { |
727 | /* the direction of urb must be OUT. */ | 729 | /* the direction of urb must be OUT. */ |
728 | if (usb_pipein(urb->pipe)) | 730 | if (usb_pipein(urb->pipe)) |
729 | return 0; | 731 | return 0; |
@@ -755,7 +757,7 @@ int usbip_recv_xbuff(struct usbip_device *ud, struct urb *urb) | |||
755 | ret = usbip_recv(ud->tcp_socket, urb->transfer_buffer, size); | 757 | ret = usbip_recv(ud->tcp_socket, urb->transfer_buffer, size); |
756 | if (ret != size) { | 758 | if (ret != size) { |
757 | dev_err(&urb->dev->dev, "recv xbuf, %d\n", ret); | 759 | dev_err(&urb->dev->dev, "recv xbuf, %d\n", ret); |
758 | if (ud->side == USBIP_STUB) { | 760 | if (ud->side == USBIP_STUB || ud->side == USBIP_VUDC) { |
759 | usbip_event_add(ud, SDEV_EVENT_ERROR_TCP); | 761 | usbip_event_add(ud, SDEV_EVENT_ERROR_TCP); |
760 | } else { | 762 | } else { |
761 | usbip_event_add(ud, VDEV_EVENT_ERROR_TCP); | 763 | usbip_event_add(ud, VDEV_EVENT_ERROR_TCP); |
@@ -769,12 +771,19 @@ EXPORT_SYMBOL_GPL(usbip_recv_xbuff); | |||
769 | 771 | ||
770 | static int __init usbip_core_init(void) | 772 | static int __init usbip_core_init(void) |
771 | { | 773 | { |
774 | int ret; | ||
775 | |||
772 | pr_info(DRIVER_DESC " v" USBIP_VERSION "\n"); | 776 | pr_info(DRIVER_DESC " v" USBIP_VERSION "\n"); |
777 | ret = usbip_init_eh(); | ||
778 | if (ret) | ||
779 | return ret; | ||
780 | |||
773 | return 0; | 781 | return 0; |
774 | } | 782 | } |
775 | 783 | ||
776 | static void __exit usbip_core_exit(void) | 784 | static void __exit usbip_core_exit(void) |
777 | { | 785 | { |
786 | usbip_finish_eh(); | ||
778 | return; | 787 | return; |
779 | } | 788 | } |
780 | 789 | ||
diff --git a/drivers/usb/usbip/usbip_common.h b/drivers/usb/usbip/usbip_common.h index 86b08475c254..c7508cbce3ce 100644 --- a/drivers/usb/usbip/usbip_common.h +++ b/drivers/usb/usbip/usbip_common.h | |||
@@ -1,5 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2003-2008 Takahiro Hirofuchi | 2 | * Copyright (C) 2003-2008 Takahiro Hirofuchi |
3 | * Copyright (C) 2015-2016 Samsung Electronics | ||
4 | * Krzysztof Opasiak <k.opasiak@samsung.com> | ||
3 | * | 5 | * |
4 | * This is free software; you can redistribute it and/or modify | 6 | * This is free software; you can redistribute it and/or modify |
5 | * it under the terms of the GNU General Public License as published by | 7 | * it under the terms of the GNU General Public License as published by |
@@ -234,6 +236,7 @@ struct usbip_iso_packet_descriptor { | |||
234 | enum usbip_side { | 236 | enum usbip_side { |
235 | USBIP_VHCI, | 237 | USBIP_VHCI, |
236 | USBIP_STUB, | 238 | USBIP_STUB, |
239 | USBIP_VUDC, | ||
237 | }; | 240 | }; |
238 | 241 | ||
239 | /* event handler */ | 242 | /* event handler */ |
@@ -248,6 +251,13 @@ enum usbip_side { | |||
248 | #define SDEV_EVENT_ERROR_SUBMIT (USBIP_EH_SHUTDOWN | USBIP_EH_RESET) | 251 | #define SDEV_EVENT_ERROR_SUBMIT (USBIP_EH_SHUTDOWN | USBIP_EH_RESET) |
249 | #define SDEV_EVENT_ERROR_MALLOC (USBIP_EH_SHUTDOWN | USBIP_EH_UNUSABLE) | 252 | #define SDEV_EVENT_ERROR_MALLOC (USBIP_EH_SHUTDOWN | USBIP_EH_UNUSABLE) |
250 | 253 | ||
254 | #define VUDC_EVENT_REMOVED (USBIP_EH_SHUTDOWN | USBIP_EH_RESET | USBIP_EH_BYE) | ||
255 | #define VUDC_EVENT_DOWN (USBIP_EH_SHUTDOWN | USBIP_EH_RESET) | ||
256 | #define VUDC_EVENT_ERROR_TCP (USBIP_EH_SHUTDOWN | USBIP_EH_RESET) | ||
257 | /* catastrophic emulated usb error */ | ||
258 | #define VUDC_EVENT_ERROR_USB (USBIP_EH_SHUTDOWN | USBIP_EH_UNUSABLE) | ||
259 | #define VUDC_EVENT_ERROR_MALLOC (USBIP_EH_SHUTDOWN | USBIP_EH_UNUSABLE) | ||
260 | |||
251 | #define VDEV_EVENT_REMOVED (USBIP_EH_SHUTDOWN | USBIP_EH_BYE) | 261 | #define VDEV_EVENT_REMOVED (USBIP_EH_SHUTDOWN | USBIP_EH_BYE) |
252 | #define VDEV_EVENT_DOWN (USBIP_EH_SHUTDOWN | USBIP_EH_RESET) | 262 | #define VDEV_EVENT_DOWN (USBIP_EH_SHUTDOWN | USBIP_EH_RESET) |
253 | #define VDEV_EVENT_ERROR_TCP (USBIP_EH_SHUTDOWN | USBIP_EH_RESET) | 263 | #define VDEV_EVENT_ERROR_TCP (USBIP_EH_SHUTDOWN | USBIP_EH_RESET) |
@@ -267,7 +277,6 @@ struct usbip_device { | |||
267 | struct task_struct *tcp_tx; | 277 | struct task_struct *tcp_tx; |
268 | 278 | ||
269 | unsigned long event; | 279 | unsigned long event; |
270 | struct task_struct *eh; | ||
271 | wait_queue_head_t eh_waitq; | 280 | wait_queue_head_t eh_waitq; |
272 | 281 | ||
273 | struct eh_ops { | 282 | struct eh_ops { |
@@ -313,10 +322,13 @@ void usbip_pad_iso(struct usbip_device *ud, struct urb *urb); | |||
313 | int usbip_recv_xbuff(struct usbip_device *ud, struct urb *urb); | 322 | int usbip_recv_xbuff(struct usbip_device *ud, struct urb *urb); |
314 | 323 | ||
315 | /* usbip_event.c */ | 324 | /* usbip_event.c */ |
325 | int usbip_init_eh(void); | ||
326 | void usbip_finish_eh(void); | ||
316 | int usbip_start_eh(struct usbip_device *ud); | 327 | int usbip_start_eh(struct usbip_device *ud); |
317 | void usbip_stop_eh(struct usbip_device *ud); | 328 | void usbip_stop_eh(struct usbip_device *ud); |
318 | void usbip_event_add(struct usbip_device *ud, unsigned long event); | 329 | void usbip_event_add(struct usbip_device *ud, unsigned long event); |
319 | int usbip_event_happened(struct usbip_device *ud); | 330 | int usbip_event_happened(struct usbip_device *ud); |
331 | int usbip_in_eh(struct task_struct *task); | ||
320 | 332 | ||
321 | static inline int interface_to_busnum(struct usb_interface *interface) | 333 | static inline int interface_to_busnum(struct usb_interface *interface) |
322 | { | 334 | { |
diff --git a/drivers/usb/usbip/usbip_event.c b/drivers/usb/usbip/usbip_event.c index 2580a32bcdff..f1635662c299 100644 --- a/drivers/usb/usbip/usbip_event.c +++ b/drivers/usb/usbip/usbip_event.c | |||
@@ -1,5 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2003-2008 Takahiro Hirofuchi | 2 | * Copyright (C) 2003-2008 Takahiro Hirofuchi |
3 | * Copyright (C) 2015 Nobuo Iwata | ||
3 | * | 4 | * |
4 | * This is free software; you can redistribute it and/or modify | 5 | * This is free software; you can redistribute it and/or modify |
5 | * it under the terms of the GNU General Public License as published by | 6 | * it under the terms of the GNU General Public License as published by |
@@ -19,17 +20,68 @@ | |||
19 | 20 | ||
20 | #include <linux/kthread.h> | 21 | #include <linux/kthread.h> |
21 | #include <linux/export.h> | 22 | #include <linux/export.h> |
23 | #include <linux/slab.h> | ||
24 | #include <linux/workqueue.h> | ||
22 | 25 | ||
23 | #include "usbip_common.h" | 26 | #include "usbip_common.h" |
24 | 27 | ||
25 | static int event_handler(struct usbip_device *ud) | 28 | struct usbip_event { |
29 | struct list_head node; | ||
30 | struct usbip_device *ud; | ||
31 | }; | ||
32 | |||
33 | static DEFINE_SPINLOCK(event_lock); | ||
34 | static LIST_HEAD(event_list); | ||
35 | |||
36 | static void set_event(struct usbip_device *ud, unsigned long event) | ||
26 | { | 37 | { |
27 | usbip_dbg_eh("enter\n"); | 38 | unsigned long flags; |
28 | 39 | ||
29 | /* | 40 | spin_lock_irqsave(&ud->lock, flags); |
30 | * Events are handled by only this thread. | 41 | ud->event |= event; |
31 | */ | 42 | spin_unlock_irqrestore(&ud->lock, flags); |
32 | while (usbip_event_happened(ud)) { | 43 | } |
44 | |||
45 | static void unset_event(struct usbip_device *ud, unsigned long event) | ||
46 | { | ||
47 | unsigned long flags; | ||
48 | |||
49 | spin_lock_irqsave(&ud->lock, flags); | ||
50 | ud->event &= ~event; | ||
51 | spin_unlock_irqrestore(&ud->lock, flags); | ||
52 | } | ||
53 | |||
54 | static struct usbip_device *get_event(void) | ||
55 | { | ||
56 | struct usbip_event *ue = NULL; | ||
57 | struct usbip_device *ud = NULL; | ||
58 | unsigned long flags; | ||
59 | |||
60 | spin_lock_irqsave(&event_lock, flags); | ||
61 | if (!list_empty(&event_list)) { | ||
62 | ue = list_first_entry(&event_list, struct usbip_event, node); | ||
63 | list_del(&ue->node); | ||
64 | } | ||
65 | spin_unlock_irqrestore(&event_lock, flags); | ||
66 | |||
67 | if (ue) { | ||
68 | ud = ue->ud; | ||
69 | kfree(ue); | ||
70 | } | ||
71 | return ud; | ||
72 | } | ||
73 | |||
74 | static struct task_struct *worker_context; | ||
75 | |||
76 | static void event_handler(struct work_struct *work) | ||
77 | { | ||
78 | struct usbip_device *ud; | ||
79 | |||
80 | if (worker_context == NULL) { | ||
81 | worker_context = current; | ||
82 | } | ||
83 | |||
84 | while ((ud = get_event()) != NULL) { | ||
33 | usbip_dbg_eh("pending event %lx\n", ud->event); | 85 | usbip_dbg_eh("pending event %lx\n", ud->event); |
34 | 86 | ||
35 | /* | 87 | /* |
@@ -38,79 +90,102 @@ static int event_handler(struct usbip_device *ud) | |||
38 | */ | 90 | */ |
39 | if (ud->event & USBIP_EH_SHUTDOWN) { | 91 | if (ud->event & USBIP_EH_SHUTDOWN) { |
40 | ud->eh_ops.shutdown(ud); | 92 | ud->eh_ops.shutdown(ud); |
41 | ud->event &= ~USBIP_EH_SHUTDOWN; | 93 | unset_event(ud, USBIP_EH_SHUTDOWN); |
42 | } | 94 | } |
43 | 95 | ||
44 | /* Reset the device. */ | 96 | /* Reset the device. */ |
45 | if (ud->event & USBIP_EH_RESET) { | 97 | if (ud->event & USBIP_EH_RESET) { |
46 | ud->eh_ops.reset(ud); | 98 | ud->eh_ops.reset(ud); |
47 | ud->event &= ~USBIP_EH_RESET; | 99 | unset_event(ud, USBIP_EH_RESET); |
48 | } | 100 | } |
49 | 101 | ||
50 | /* Mark the device as unusable. */ | 102 | /* Mark the device as unusable. */ |
51 | if (ud->event & USBIP_EH_UNUSABLE) { | 103 | if (ud->event & USBIP_EH_UNUSABLE) { |
52 | ud->eh_ops.unusable(ud); | 104 | ud->eh_ops.unusable(ud); |
53 | ud->event &= ~USBIP_EH_UNUSABLE; | 105 | unset_event(ud, USBIP_EH_UNUSABLE); |
54 | } | 106 | } |
55 | 107 | ||
56 | /* Stop the error handler. */ | 108 | /* Stop the error handler. */ |
57 | if (ud->event & USBIP_EH_BYE) | 109 | if (ud->event & USBIP_EH_BYE) |
58 | return -1; | 110 | usbip_dbg_eh("removed %p\n", ud); |
111 | |||
112 | wake_up(&ud->eh_waitq); | ||
59 | } | 113 | } |
114 | } | ||
60 | 115 | ||
116 | int usbip_start_eh(struct usbip_device *ud) | ||
117 | { | ||
118 | init_waitqueue_head(&ud->eh_waitq); | ||
119 | ud->event = 0; | ||
61 | return 0; | 120 | return 0; |
62 | } | 121 | } |
122 | EXPORT_SYMBOL_GPL(usbip_start_eh); | ||
63 | 123 | ||
64 | static int event_handler_loop(void *data) | 124 | void usbip_stop_eh(struct usbip_device *ud) |
65 | { | 125 | { |
66 | struct usbip_device *ud = data; | 126 | unsigned long pending = ud->event & ~USBIP_EH_BYE; |
67 | 127 | ||
68 | while (!kthread_should_stop()) { | 128 | if (!(ud->event & USBIP_EH_BYE)) |
69 | wait_event_interruptible(ud->eh_waitq, | 129 | usbip_dbg_eh("usbip_eh stopping but not removed\n"); |
70 | usbip_event_happened(ud) || | ||
71 | kthread_should_stop()); | ||
72 | usbip_dbg_eh("wakeup\n"); | ||
73 | 130 | ||
74 | if (event_handler(ud) < 0) | 131 | if (pending) |
75 | break; | 132 | usbip_dbg_eh("usbip_eh waiting completion %lx\n", pending); |
76 | } | ||
77 | 133 | ||
78 | return 0; | 134 | wait_event_interruptible(ud->eh_waitq, !(ud->event & ~USBIP_EH_BYE)); |
135 | usbip_dbg_eh("usbip_eh has stopped\n"); | ||
79 | } | 136 | } |
137 | EXPORT_SYMBOL_GPL(usbip_stop_eh); | ||
80 | 138 | ||
81 | int usbip_start_eh(struct usbip_device *ud) | 139 | #define WORK_QUEUE_NAME "usbip_event" |
82 | { | ||
83 | init_waitqueue_head(&ud->eh_waitq); | ||
84 | ud->event = 0; | ||
85 | 140 | ||
86 | ud->eh = kthread_run(event_handler_loop, ud, "usbip_eh"); | 141 | static struct workqueue_struct *usbip_queue; |
87 | if (IS_ERR(ud->eh)) { | 142 | static DECLARE_WORK(usbip_work, event_handler); |
88 | pr_warn("Unable to start control thread\n"); | ||
89 | return PTR_ERR(ud->eh); | ||
90 | } | ||
91 | 143 | ||
144 | int usbip_init_eh(void) | ||
145 | { | ||
146 | usbip_queue = create_singlethread_workqueue(WORK_QUEUE_NAME); | ||
147 | if (usbip_queue == NULL) { | ||
148 | pr_err("failed to create usbip_event\n"); | ||
149 | return -ENOMEM; | ||
150 | } | ||
92 | return 0; | 151 | return 0; |
93 | } | 152 | } |
94 | EXPORT_SYMBOL_GPL(usbip_start_eh); | ||
95 | 153 | ||
96 | void usbip_stop_eh(struct usbip_device *ud) | 154 | void usbip_finish_eh(void) |
97 | { | 155 | { |
98 | if (ud->eh == current) | 156 | flush_workqueue(usbip_queue); |
99 | return; /* do not wait for myself */ | 157 | destroy_workqueue(usbip_queue); |
100 | 158 | usbip_queue = NULL; | |
101 | kthread_stop(ud->eh); | ||
102 | usbip_dbg_eh("usbip_eh has finished\n"); | ||
103 | } | 159 | } |
104 | EXPORT_SYMBOL_GPL(usbip_stop_eh); | ||
105 | 160 | ||
106 | void usbip_event_add(struct usbip_device *ud, unsigned long event) | 161 | void usbip_event_add(struct usbip_device *ud, unsigned long event) |
107 | { | 162 | { |
163 | struct usbip_event *ue; | ||
108 | unsigned long flags; | 164 | unsigned long flags; |
109 | 165 | ||
110 | spin_lock_irqsave(&ud->lock, flags); | 166 | if (ud->event & USBIP_EH_BYE) |
111 | ud->event |= event; | 167 | return; |
112 | wake_up(&ud->eh_waitq); | 168 | |
113 | spin_unlock_irqrestore(&ud->lock, flags); | 169 | set_event(ud, event); |
170 | |||
171 | spin_lock_irqsave(&event_lock, flags); | ||
172 | |||
173 | list_for_each_entry_reverse(ue, &event_list, node) { | ||
174 | if (ue->ud == ud) | ||
175 | goto out; | ||
176 | } | ||
177 | |||
178 | ue = kmalloc(sizeof(struct usbip_event), GFP_ATOMIC); | ||
179 | if (ue == NULL) | ||
180 | goto out; | ||
181 | |||
182 | ue->ud = ud; | ||
183 | |||
184 | list_add_tail(&ue->node, &event_list); | ||
185 | queue_work(usbip_queue, &usbip_work); | ||
186 | |||
187 | out: | ||
188 | spin_unlock_irqrestore(&event_lock, flags); | ||
114 | } | 189 | } |
115 | EXPORT_SYMBOL_GPL(usbip_event_add); | 190 | EXPORT_SYMBOL_GPL(usbip_event_add); |
116 | 191 | ||
@@ -127,3 +202,12 @@ int usbip_event_happened(struct usbip_device *ud) | |||
127 | return happened; | 202 | return happened; |
128 | } | 203 | } |
129 | EXPORT_SYMBOL_GPL(usbip_event_happened); | 204 | EXPORT_SYMBOL_GPL(usbip_event_happened); |
205 | |||
206 | int usbip_in_eh(struct task_struct *task) | ||
207 | { | ||
208 | if (task == worker_context) | ||
209 | return 1; | ||
210 | |||
211 | return 0; | ||
212 | } | ||
213 | EXPORT_SYMBOL_GPL(usbip_in_eh); | ||
diff --git a/drivers/usb/usbip/vudc.h b/drivers/usb/usbip/vudc.h new file mode 100644 index 000000000000..25e01b09c4c3 --- /dev/null +++ b/drivers/usb/usbip/vudc.h | |||
@@ -0,0 +1,190 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2015 Karol Kosik <karo9@interia.eu> | ||
3 | * Copyright (C) 2015-2016 Samsung Electronics | ||
4 | * Igor Kotrasinski <i.kotrasinsk@samsung.com> | ||
5 | * Krzysztof Opasiak <k.opasiak@samsung.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 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
19 | */ | ||
20 | |||
21 | #ifndef __USBIP_VUDC_H | ||
22 | #define __USBIP_VUDC_H | ||
23 | |||
24 | #include <linux/platform_device.h> | ||
25 | #include <linux/usb.h> | ||
26 | #include <linux/usb/gadget.h> | ||
27 | #include <linux/usb/ch9.h> | ||
28 | #include <linux/list.h> | ||
29 | #include <linux/timer.h> | ||
30 | #include <linux/time.h> | ||
31 | #include <linux/sysfs.h> | ||
32 | |||
33 | #include "usbip_common.h" | ||
34 | |||
35 | #define GADGET_NAME "usbip-vudc" | ||
36 | |||
37 | struct vep { | ||
38 | struct usb_ep ep; | ||
39 | unsigned type:2; /* type, as USB_ENDPOINT_XFER_* */ | ||
40 | char name[8]; /* space for ep name */ | ||
41 | |||
42 | const struct usb_endpoint_descriptor *desc; | ||
43 | struct usb_gadget *gadget; | ||
44 | struct list_head req_queue; /* Request queue */ | ||
45 | unsigned halted:1; | ||
46 | unsigned wedged:1; | ||
47 | unsigned already_seen:1; | ||
48 | unsigned setup_stage:1; | ||
49 | }; | ||
50 | |||
51 | struct vrequest { | ||
52 | struct usb_request req; | ||
53 | struct vudc *udc; | ||
54 | struct list_head req_entry; /* Request queue */ | ||
55 | }; | ||
56 | |||
57 | struct urbp { | ||
58 | struct urb *urb; | ||
59 | struct vep *ep; | ||
60 | struct list_head urb_entry; /* urb queue */ | ||
61 | unsigned long seqnum; | ||
62 | unsigned type:2; /* for tx, since ep type can change after */ | ||
63 | unsigned new:1; | ||
64 | }; | ||
65 | |||
66 | struct v_unlink { | ||
67 | unsigned long seqnum; | ||
68 | __u32 status; | ||
69 | }; | ||
70 | |||
71 | enum tx_type { | ||
72 | TX_UNLINK, | ||
73 | TX_SUBMIT, | ||
74 | }; | ||
75 | |||
76 | struct tx_item { | ||
77 | struct list_head tx_entry; | ||
78 | enum tx_type type; | ||
79 | union { | ||
80 | struct urbp *s; | ||
81 | struct v_unlink *u; | ||
82 | }; | ||
83 | }; | ||
84 | |||
85 | enum tr_state { | ||
86 | VUDC_TR_RUNNING, | ||
87 | VUDC_TR_IDLE, | ||
88 | VUDC_TR_STOPPED, | ||
89 | }; | ||
90 | |||
91 | struct transfer_timer { | ||
92 | struct timer_list timer; | ||
93 | enum tr_state state; | ||
94 | unsigned long frame_start; | ||
95 | int frame_limit; | ||
96 | }; | ||
97 | |||
98 | struct vudc { | ||
99 | struct usb_gadget gadget; | ||
100 | struct usb_gadget_driver *driver; | ||
101 | struct platform_device *pdev; | ||
102 | |||
103 | struct usb_device_descriptor dev_desc; | ||
104 | |||
105 | struct usbip_device ud; | ||
106 | struct transfer_timer tr_timer; | ||
107 | struct timeval start_time; | ||
108 | |||
109 | struct list_head urb_queue; | ||
110 | |||
111 | spinlock_t lock_tx; | ||
112 | struct list_head tx_queue; | ||
113 | wait_queue_head_t tx_waitq; | ||
114 | |||
115 | spinlock_t lock; | ||
116 | struct vep *ep; | ||
117 | int address; | ||
118 | u16 devstatus; | ||
119 | |||
120 | unsigned pullup:1; | ||
121 | unsigned connected:1; | ||
122 | unsigned desc_cached:1; | ||
123 | }; | ||
124 | |||
125 | struct vudc_device { | ||
126 | struct platform_device *pdev; | ||
127 | struct list_head dev_entry; | ||
128 | }; | ||
129 | |||
130 | extern const struct attribute_group vudc_attr_group; | ||
131 | |||
132 | /* visible everywhere */ | ||
133 | |||
134 | static inline struct vep *to_vep(struct usb_ep *_ep) | ||
135 | { | ||
136 | return container_of(_ep, struct vep, ep); | ||
137 | } | ||
138 | |||
139 | static inline struct vrequest *to_vrequest( | ||
140 | struct usb_request *_req) | ||
141 | { | ||
142 | return container_of(_req, struct vrequest, req); | ||
143 | } | ||
144 | |||
145 | static inline struct vudc *usb_gadget_to_vudc( | ||
146 | struct usb_gadget *_gadget) | ||
147 | { | ||
148 | return container_of(_gadget, struct vudc, gadget); | ||
149 | } | ||
150 | |||
151 | static inline struct vudc *ep_to_vudc(struct vep *ep) | ||
152 | { | ||
153 | return container_of(ep->gadget, struct vudc, gadget); | ||
154 | } | ||
155 | |||
156 | /* vudc_sysfs.c */ | ||
157 | |||
158 | int get_gadget_descs(struct vudc *udc); | ||
159 | |||
160 | /* vudc_tx.c */ | ||
161 | |||
162 | int v_tx_loop(void *data); | ||
163 | void v_enqueue_ret_unlink(struct vudc *udc, __u32 seqnum, __u32 status); | ||
164 | void v_enqueue_ret_submit(struct vudc *udc, struct urbp *urb_p); | ||
165 | |||
166 | /* vudc_rx.c */ | ||
167 | |||
168 | int v_rx_loop(void *data); | ||
169 | |||
170 | /* vudc_transfer.c */ | ||
171 | |||
172 | void v_init_timer(struct vudc *udc); | ||
173 | void v_start_timer(struct vudc *udc); | ||
174 | void v_kick_timer(struct vudc *udc, unsigned long time); | ||
175 | void v_stop_timer(struct vudc *udc); | ||
176 | |||
177 | /* vudc_dev.c */ | ||
178 | |||
179 | struct urbp *alloc_urbp(void); | ||
180 | void free_urbp_and_urb(struct urbp *urb_p); | ||
181 | |||
182 | struct vep *vudc_find_endpoint(struct vudc *udc, u8 address); | ||
183 | |||
184 | struct vudc_device *alloc_vudc_device(int devid); | ||
185 | void put_vudc_device(struct vudc_device *udc_dev); | ||
186 | |||
187 | int vudc_probe(struct platform_device *pdev); | ||
188 | int vudc_remove(struct platform_device *pdev); | ||
189 | |||
190 | #endif /* __USBIP_VUDC_H */ | ||
diff --git a/drivers/usb/usbip/vudc_dev.c b/drivers/usb/usbip/vudc_dev.c new file mode 100644 index 000000000000..8994a13819ab --- /dev/null +++ b/drivers/usb/usbip/vudc_dev.c | |||
@@ -0,0 +1,661 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2015 Karol Kosik <karo9@interia.eu> | ||
3 | * Copyright (C) 2015-2016 Samsung Electronics | ||
4 | * Igor Kotrasinski <i.kotrasinsk@samsung.com> | ||
5 | * Krzysztof Opasiak <k.opasiak@samsung.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 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
19 | */ | ||
20 | |||
21 | #include <linux/device.h> | ||
22 | #include <linux/kernel.h> | ||
23 | #include <linux/list.h> | ||
24 | #include <linux/platform_device.h> | ||
25 | #include <linux/usb.h> | ||
26 | #include <linux/usb/gadget.h> | ||
27 | #include <linux/usb/hcd.h> | ||
28 | #include <linux/kthread.h> | ||
29 | #include <linux/file.h> | ||
30 | #include <linux/byteorder/generic.h> | ||
31 | |||
32 | #include "usbip_common.h" | ||
33 | #include "vudc.h" | ||
34 | |||
35 | #define VIRTUAL_ENDPOINTS (1 /* ep0 */ + 15 /* in eps */ + 15 /* out eps */) | ||
36 | |||
37 | /* urb-related structures alloc / free */ | ||
38 | |||
39 | |||
40 | static void free_urb(struct urb *urb) | ||
41 | { | ||
42 | if (!urb) | ||
43 | return; | ||
44 | |||
45 | kfree(urb->setup_packet); | ||
46 | urb->setup_packet = NULL; | ||
47 | |||
48 | kfree(urb->transfer_buffer); | ||
49 | urb->transfer_buffer = NULL; | ||
50 | |||
51 | usb_free_urb(urb); | ||
52 | } | ||
53 | |||
54 | struct urbp *alloc_urbp(void) | ||
55 | { | ||
56 | struct urbp *urb_p; | ||
57 | |||
58 | urb_p = kzalloc(sizeof(*urb_p), GFP_KERNEL); | ||
59 | if (!urb_p) | ||
60 | return urb_p; | ||
61 | |||
62 | urb_p->urb = NULL; | ||
63 | urb_p->ep = NULL; | ||
64 | INIT_LIST_HEAD(&urb_p->urb_entry); | ||
65 | return urb_p; | ||
66 | } | ||
67 | |||
68 | static void free_urbp(struct urbp *urb_p) | ||
69 | { | ||
70 | kfree(urb_p); | ||
71 | } | ||
72 | |||
73 | void free_urbp_and_urb(struct urbp *urb_p) | ||
74 | { | ||
75 | if (!urb_p) | ||
76 | return; | ||
77 | free_urb(urb_p->urb); | ||
78 | free_urbp(urb_p); | ||
79 | } | ||
80 | |||
81 | |||
82 | /* utilities ; almost verbatim from dummy_hcd.c */ | ||
83 | |||
84 | /* called with spinlock held */ | ||
85 | static void nuke(struct vudc *udc, struct vep *ep) | ||
86 | { | ||
87 | struct vrequest *req; | ||
88 | |||
89 | while (!list_empty(&ep->req_queue)) { | ||
90 | req = list_first_entry(&ep->req_queue, struct vrequest, | ||
91 | req_entry); | ||
92 | list_del_init(&req->req_entry); | ||
93 | req->req.status = -ESHUTDOWN; | ||
94 | |||
95 | spin_unlock(&udc->lock); | ||
96 | usb_gadget_giveback_request(&ep->ep, &req->req); | ||
97 | spin_lock(&udc->lock); | ||
98 | } | ||
99 | } | ||
100 | |||
101 | /* caller must hold lock */ | ||
102 | static void stop_activity(struct vudc *udc) | ||
103 | { | ||
104 | int i; | ||
105 | struct urbp *urb_p, *tmp; | ||
106 | |||
107 | udc->address = 0; | ||
108 | |||
109 | for (i = 0; i < VIRTUAL_ENDPOINTS; i++) | ||
110 | nuke(udc, &udc->ep[i]); | ||
111 | |||
112 | list_for_each_entry_safe(urb_p, tmp, &udc->urb_queue, urb_entry) { | ||
113 | list_del(&urb_p->urb_entry); | ||
114 | free_urbp_and_urb(urb_p); | ||
115 | } | ||
116 | } | ||
117 | |||
118 | struct vep *vudc_find_endpoint(struct vudc *udc, u8 address) | ||
119 | { | ||
120 | int i; | ||
121 | |||
122 | if ((address & ~USB_DIR_IN) == 0) | ||
123 | return &udc->ep[0]; | ||
124 | |||
125 | for (i = 1; i < VIRTUAL_ENDPOINTS; i++) { | ||
126 | struct vep *ep = &udc->ep[i]; | ||
127 | |||
128 | if (!ep->desc) | ||
129 | continue; | ||
130 | if (ep->desc->bEndpointAddress == address) | ||
131 | return ep; | ||
132 | } | ||
133 | return NULL; | ||
134 | } | ||
135 | |||
136 | /* gadget ops */ | ||
137 | |||
138 | /* FIXME - this will probably misbehave when suspend/resume is added */ | ||
139 | static int vgadget_get_frame(struct usb_gadget *_gadget) | ||
140 | { | ||
141 | struct timeval now; | ||
142 | struct vudc *udc = usb_gadget_to_vudc(_gadget); | ||
143 | |||
144 | do_gettimeofday(&now); | ||
145 | return ((now.tv_sec - udc->start_time.tv_sec) * 1000 + | ||
146 | (now.tv_usec - udc->start_time.tv_usec) / 1000) | ||
147 | % 0x7FF; | ||
148 | } | ||
149 | |||
150 | static int vgadget_set_selfpowered(struct usb_gadget *_gadget, int value) | ||
151 | { | ||
152 | struct vudc *udc = usb_gadget_to_vudc(_gadget); | ||
153 | |||
154 | if (value) | ||
155 | udc->devstatus |= (1 << USB_DEVICE_SELF_POWERED); | ||
156 | else | ||
157 | udc->devstatus &= ~(1 << USB_DEVICE_SELF_POWERED); | ||
158 | return 0; | ||
159 | } | ||
160 | |||
161 | static int vgadget_pullup(struct usb_gadget *_gadget, int value) | ||
162 | { | ||
163 | struct vudc *udc = usb_gadget_to_vudc(_gadget); | ||
164 | unsigned long flags; | ||
165 | int ret; | ||
166 | |||
167 | |||
168 | spin_lock_irqsave(&udc->lock, flags); | ||
169 | value = !!value; | ||
170 | if (value == udc->pullup) | ||
171 | goto unlock; | ||
172 | |||
173 | udc->pullup = value; | ||
174 | if (value) { | ||
175 | udc->gadget.speed = min_t(u8, USB_SPEED_HIGH, | ||
176 | udc->driver->max_speed); | ||
177 | udc->ep[0].ep.maxpacket = 64; | ||
178 | /* | ||
179 | * This is the first place where we can ask our | ||
180 | * gadget driver for descriptors. | ||
181 | */ | ||
182 | ret = get_gadget_descs(udc); | ||
183 | if (ret) { | ||
184 | dev_err(&udc->gadget.dev, "Unable go get desc: %d", ret); | ||
185 | goto unlock; | ||
186 | } | ||
187 | |||
188 | spin_unlock_irqrestore(&udc->lock, flags); | ||
189 | usbip_start_eh(&udc->ud); | ||
190 | } else { | ||
191 | /* Invalidate descriptors */ | ||
192 | udc->desc_cached = 0; | ||
193 | |||
194 | spin_unlock_irqrestore(&udc->lock, flags); | ||
195 | usbip_event_add(&udc->ud, VUDC_EVENT_REMOVED); | ||
196 | usbip_stop_eh(&udc->ud); /* Wait for eh completion */ | ||
197 | } | ||
198 | |||
199 | return 0; | ||
200 | |||
201 | unlock: | ||
202 | spin_unlock_irqrestore(&udc->lock, flags); | ||
203 | return 0; | ||
204 | } | ||
205 | |||
206 | static int vgadget_udc_start(struct usb_gadget *g, | ||
207 | struct usb_gadget_driver *driver) | ||
208 | { | ||
209 | struct vudc *udc = usb_gadget_to_vudc(g); | ||
210 | unsigned long flags; | ||
211 | |||
212 | spin_lock_irqsave(&udc->lock, flags); | ||
213 | udc->driver = driver; | ||
214 | udc->pullup = udc->connected = udc->desc_cached = 0; | ||
215 | spin_unlock_irqrestore(&udc->lock, flags); | ||
216 | |||
217 | return 0; | ||
218 | } | ||
219 | |||
220 | static int vgadget_udc_stop(struct usb_gadget *g) | ||
221 | { | ||
222 | struct vudc *udc = usb_gadget_to_vudc(g); | ||
223 | unsigned long flags; | ||
224 | |||
225 | spin_lock_irqsave(&udc->lock, flags); | ||
226 | udc->driver = NULL; | ||
227 | spin_unlock_irqrestore(&udc->lock, flags); | ||
228 | return 0; | ||
229 | } | ||
230 | |||
231 | static const struct usb_gadget_ops vgadget_ops = { | ||
232 | .get_frame = vgadget_get_frame, | ||
233 | .set_selfpowered = vgadget_set_selfpowered, | ||
234 | .pullup = vgadget_pullup, | ||
235 | .udc_start = vgadget_udc_start, | ||
236 | .udc_stop = vgadget_udc_stop, | ||
237 | }; | ||
238 | |||
239 | |||
240 | /* endpoint ops */ | ||
241 | |||
242 | static int vep_enable(struct usb_ep *_ep, | ||
243 | const struct usb_endpoint_descriptor *desc) | ||
244 | { | ||
245 | struct vep *ep; | ||
246 | struct vudc *udc; | ||
247 | unsigned maxp; | ||
248 | unsigned long flags; | ||
249 | |||
250 | ep = to_vep(_ep); | ||
251 | udc = ep_to_vudc(ep); | ||
252 | |||
253 | if (!_ep || !desc || ep->desc || _ep->caps.type_control | ||
254 | || desc->bDescriptorType != USB_DT_ENDPOINT) | ||
255 | return -EINVAL; | ||
256 | |||
257 | if (!udc->driver) | ||
258 | return -ESHUTDOWN; | ||
259 | |||
260 | spin_lock_irqsave(&udc->lock, flags); | ||
261 | |||
262 | maxp = usb_endpoint_maxp(desc) & 0x7ff; | ||
263 | _ep->maxpacket = maxp; | ||
264 | ep->desc = desc; | ||
265 | ep->type = usb_endpoint_type(desc); | ||
266 | ep->halted = ep->wedged = 0; | ||
267 | |||
268 | spin_unlock_irqrestore(&udc->lock, flags); | ||
269 | |||
270 | return 0; | ||
271 | } | ||
272 | |||
273 | static int vep_disable(struct usb_ep *_ep) | ||
274 | { | ||
275 | struct vep *ep; | ||
276 | struct vudc *udc; | ||
277 | unsigned long flags; | ||
278 | |||
279 | ep = to_vep(_ep); | ||
280 | udc = ep_to_vudc(ep); | ||
281 | if (!_ep || !ep->desc || _ep->caps.type_control) | ||
282 | return -EINVAL; | ||
283 | |||
284 | spin_lock_irqsave(&udc->lock, flags); | ||
285 | ep->desc = NULL; | ||
286 | nuke(udc, ep); | ||
287 | spin_unlock_irqrestore(&udc->lock, flags); | ||
288 | |||
289 | return 0; | ||
290 | } | ||
291 | |||
292 | static struct usb_request *vep_alloc_request(struct usb_ep *_ep, | ||
293 | gfp_t mem_flags) | ||
294 | { | ||
295 | struct vep *ep; | ||
296 | struct vrequest *req; | ||
297 | |||
298 | if (!_ep) | ||
299 | return NULL; | ||
300 | ep = to_vep(_ep); | ||
301 | |||
302 | req = kzalloc(sizeof(*req), mem_flags); | ||
303 | if (!req) | ||
304 | return NULL; | ||
305 | |||
306 | INIT_LIST_HEAD(&req->req_entry); | ||
307 | |||
308 | return &req->req; | ||
309 | } | ||
310 | |||
311 | static void vep_free_request(struct usb_ep *_ep, struct usb_request *_req) | ||
312 | { | ||
313 | struct vrequest *req; | ||
314 | |||
315 | if (WARN_ON(!_ep || !_req)) | ||
316 | return; | ||
317 | |||
318 | req = to_vrequest(_req); | ||
319 | kfree(req); | ||
320 | } | ||
321 | |||
322 | static int vep_queue(struct usb_ep *_ep, struct usb_request *_req, | ||
323 | gfp_t mem_flags) | ||
324 | { | ||
325 | struct vep *ep; | ||
326 | struct vrequest *req; | ||
327 | struct vudc *udc; | ||
328 | unsigned long flags; | ||
329 | |||
330 | if (!_ep || !_req) | ||
331 | return -EINVAL; | ||
332 | |||
333 | ep = to_vep(_ep); | ||
334 | req = to_vrequest(_req); | ||
335 | udc = ep_to_vudc(ep); | ||
336 | |||
337 | spin_lock_irqsave(&udc->lock, flags); | ||
338 | _req->actual = 0; | ||
339 | _req->status = -EINPROGRESS; | ||
340 | |||
341 | list_add_tail(&req->req_entry, &ep->req_queue); | ||
342 | spin_unlock_irqrestore(&udc->lock, flags); | ||
343 | |||
344 | return 0; | ||
345 | } | ||
346 | |||
347 | static int vep_dequeue(struct usb_ep *_ep, struct usb_request *_req) | ||
348 | { | ||
349 | struct vep *ep; | ||
350 | struct vrequest *req; | ||
351 | struct vudc *udc; | ||
352 | struct vrequest *lst; | ||
353 | unsigned long flags; | ||
354 | int ret = -EINVAL; | ||
355 | |||
356 | if (!_ep || !_req) | ||
357 | return ret; | ||
358 | |||
359 | ep = to_vep(_ep); | ||
360 | req = to_vrequest(_req); | ||
361 | udc = req->udc; | ||
362 | |||
363 | if (!udc->driver) | ||
364 | return -ESHUTDOWN; | ||
365 | |||
366 | spin_lock_irqsave(&udc->lock, flags); | ||
367 | list_for_each_entry(lst, &ep->req_queue, req_entry) { | ||
368 | if (&lst->req == _req) { | ||
369 | list_del_init(&lst->req_entry); | ||
370 | _req->status = -ECONNRESET; | ||
371 | ret = 0; | ||
372 | break; | ||
373 | } | ||
374 | } | ||
375 | spin_unlock_irqrestore(&udc->lock, flags); | ||
376 | |||
377 | if (ret == 0) | ||
378 | usb_gadget_giveback_request(_ep, _req); | ||
379 | |||
380 | return ret; | ||
381 | } | ||
382 | |||
383 | static int | ||
384 | vep_set_halt_and_wedge(struct usb_ep *_ep, int value, int wedged) | ||
385 | { | ||
386 | struct vep *ep; | ||
387 | struct vudc *udc; | ||
388 | unsigned long flags; | ||
389 | int ret = 0; | ||
390 | |||
391 | ep = to_vep(_ep); | ||
392 | if (!_ep) | ||
393 | return -EINVAL; | ||
394 | |||
395 | udc = ep_to_vudc(ep); | ||
396 | if (!udc->driver) | ||
397 | return -ESHUTDOWN; | ||
398 | |||
399 | spin_lock_irqsave(&udc->lock, flags); | ||
400 | if (!value) | ||
401 | ep->halted = ep->wedged = 0; | ||
402 | else if (ep->desc && (ep->desc->bEndpointAddress & USB_DIR_IN) && | ||
403 | !list_empty(&ep->req_queue)) | ||
404 | ret = -EAGAIN; | ||
405 | else { | ||
406 | ep->halted = 1; | ||
407 | if (wedged) | ||
408 | ep->wedged = 1; | ||
409 | } | ||
410 | |||
411 | spin_unlock_irqrestore(&udc->lock, flags); | ||
412 | return ret; | ||
413 | } | ||
414 | |||
415 | static int | ||
416 | vep_set_halt(struct usb_ep *_ep, int value) | ||
417 | { | ||
418 | return vep_set_halt_and_wedge(_ep, value, 0); | ||
419 | } | ||
420 | |||
421 | static int vep_set_wedge(struct usb_ep *_ep) | ||
422 | { | ||
423 | return vep_set_halt_and_wedge(_ep, 1, 1); | ||
424 | } | ||
425 | |||
426 | static const struct usb_ep_ops vep_ops = { | ||
427 | .enable = vep_enable, | ||
428 | .disable = vep_disable, | ||
429 | |||
430 | .alloc_request = vep_alloc_request, | ||
431 | .free_request = vep_free_request, | ||
432 | |||
433 | .queue = vep_queue, | ||
434 | .dequeue = vep_dequeue, | ||
435 | |||
436 | .set_halt = vep_set_halt, | ||
437 | .set_wedge = vep_set_wedge, | ||
438 | }; | ||
439 | |||
440 | |||
441 | /* shutdown / reset / error handlers */ | ||
442 | |||
443 | static void vudc_shutdown(struct usbip_device *ud) | ||
444 | { | ||
445 | struct vudc *udc = container_of(ud, struct vudc, ud); | ||
446 | int call_disconnect = 0; | ||
447 | unsigned long flags; | ||
448 | |||
449 | dev_dbg(&udc->pdev->dev, "device shutdown"); | ||
450 | if (ud->tcp_socket) | ||
451 | kernel_sock_shutdown(ud->tcp_socket, SHUT_RDWR); | ||
452 | |||
453 | if (ud->tcp_tx) { | ||
454 | kthread_stop_put(ud->tcp_rx); | ||
455 | ud->tcp_rx = NULL; | ||
456 | } | ||
457 | if (ud->tcp_tx) { | ||
458 | kthread_stop_put(ud->tcp_tx); | ||
459 | ud->tcp_tx = NULL; | ||
460 | } | ||
461 | |||
462 | if (ud->tcp_socket) { | ||
463 | sockfd_put(ud->tcp_socket); | ||
464 | ud->tcp_socket = NULL; | ||
465 | } | ||
466 | |||
467 | spin_lock_irqsave(&udc->lock, flags); | ||
468 | stop_activity(udc); | ||
469 | if (udc->connected && udc->driver->disconnect) | ||
470 | call_disconnect = 1; | ||
471 | udc->connected = 0; | ||
472 | spin_unlock_irqrestore(&udc->lock, flags); | ||
473 | if (call_disconnect) | ||
474 | udc->driver->disconnect(&udc->gadget); | ||
475 | } | ||
476 | |||
477 | static void vudc_device_reset(struct usbip_device *ud) | ||
478 | { | ||
479 | struct vudc *udc = container_of(ud, struct vudc, ud); | ||
480 | unsigned long flags; | ||
481 | |||
482 | dev_dbg(&udc->pdev->dev, "device reset"); | ||
483 | spin_lock_irqsave(&udc->lock, flags); | ||
484 | stop_activity(udc); | ||
485 | spin_unlock_irqrestore(&udc->lock, flags); | ||
486 | if (udc->driver) | ||
487 | usb_gadget_udc_reset(&udc->gadget, udc->driver); | ||
488 | spin_lock_irqsave(&ud->lock, flags); | ||
489 | ud->status = SDEV_ST_AVAILABLE; | ||
490 | spin_unlock_irqrestore(&ud->lock, flags); | ||
491 | } | ||
492 | |||
493 | static void vudc_device_unusable(struct usbip_device *ud) | ||
494 | { | ||
495 | unsigned long flags; | ||
496 | |||
497 | spin_lock_irqsave(&ud->lock, flags); | ||
498 | ud->status = SDEV_ST_ERROR; | ||
499 | spin_unlock_irqrestore(&ud->lock, flags); | ||
500 | } | ||
501 | |||
502 | /* device setup / cleanup */ | ||
503 | |||
504 | struct vudc_device *alloc_vudc_device(int devid) | ||
505 | { | ||
506 | struct vudc_device *udc_dev = NULL; | ||
507 | |||
508 | udc_dev = kzalloc(sizeof(*udc_dev), GFP_KERNEL); | ||
509 | if (!udc_dev) | ||
510 | goto out; | ||
511 | |||
512 | INIT_LIST_HEAD(&udc_dev->dev_entry); | ||
513 | |||
514 | udc_dev->pdev = platform_device_alloc(GADGET_NAME, devid); | ||
515 | if (!udc_dev->pdev) { | ||
516 | kfree(udc_dev); | ||
517 | udc_dev = NULL; | ||
518 | } | ||
519 | |||
520 | out: | ||
521 | return udc_dev; | ||
522 | } | ||
523 | |||
524 | void put_vudc_device(struct vudc_device *udc_dev) | ||
525 | { | ||
526 | platform_device_put(udc_dev->pdev); | ||
527 | kfree(udc_dev); | ||
528 | } | ||
529 | |||
530 | static int init_vudc_hw(struct vudc *udc) | ||
531 | { | ||
532 | int i; | ||
533 | struct usbip_device *ud = &udc->ud; | ||
534 | struct vep *ep; | ||
535 | |||
536 | udc->ep = kcalloc(VIRTUAL_ENDPOINTS, sizeof(*udc->ep), GFP_KERNEL); | ||
537 | if (!udc->ep) | ||
538 | goto nomem_ep; | ||
539 | |||
540 | INIT_LIST_HEAD(&udc->gadget.ep_list); | ||
541 | |||
542 | /* create ep0 and 15 in, 15 out general purpose eps */ | ||
543 | for (i = 0; i < VIRTUAL_ENDPOINTS; ++i) { | ||
544 | int is_out = i % 2; | ||
545 | int num = (i + 1) / 2; | ||
546 | |||
547 | ep = &udc->ep[i]; | ||
548 | |||
549 | sprintf(ep->name, "ep%d%s", num, | ||
550 | i ? (is_out ? "out" : "in") : ""); | ||
551 | ep->ep.name = ep->name; | ||
552 | if (i == 0) { | ||
553 | ep->ep.caps.type_control = true; | ||
554 | ep->ep.caps.dir_out = true; | ||
555 | ep->ep.caps.dir_in = true; | ||
556 | } else { | ||
557 | ep->ep.caps.type_iso = true; | ||
558 | ep->ep.caps.type_int = true; | ||
559 | ep->ep.caps.type_bulk = true; | ||
560 | } | ||
561 | |||
562 | if (is_out) | ||
563 | ep->ep.caps.dir_out = true; | ||
564 | else | ||
565 | ep->ep.caps.dir_in = true; | ||
566 | |||
567 | ep->ep.ops = &vep_ops; | ||
568 | list_add_tail(&ep->ep.ep_list, &udc->gadget.ep_list); | ||
569 | ep->halted = ep->wedged = ep->already_seen = | ||
570 | ep->setup_stage = 0; | ||
571 | usb_ep_set_maxpacket_limit(&ep->ep, ~0); | ||
572 | ep->ep.max_streams = 16; | ||
573 | ep->gadget = &udc->gadget; | ||
574 | ep->desc = NULL; | ||
575 | INIT_LIST_HEAD(&ep->req_queue); | ||
576 | } | ||
577 | |||
578 | spin_lock_init(&udc->lock); | ||
579 | spin_lock_init(&udc->lock_tx); | ||
580 | INIT_LIST_HEAD(&udc->urb_queue); | ||
581 | INIT_LIST_HEAD(&udc->tx_queue); | ||
582 | init_waitqueue_head(&udc->tx_waitq); | ||
583 | |||
584 | spin_lock_init(&ud->lock); | ||
585 | ud->status = SDEV_ST_AVAILABLE; | ||
586 | ud->side = USBIP_VUDC; | ||
587 | |||
588 | ud->eh_ops.shutdown = vudc_shutdown; | ||
589 | ud->eh_ops.reset = vudc_device_reset; | ||
590 | ud->eh_ops.unusable = vudc_device_unusable; | ||
591 | |||
592 | udc->gadget.ep0 = &udc->ep[0].ep; | ||
593 | list_del_init(&udc->ep[0].ep.ep_list); | ||
594 | |||
595 | v_init_timer(udc); | ||
596 | return 0; | ||
597 | |||
598 | nomem_ep: | ||
599 | return -ENOMEM; | ||
600 | } | ||
601 | |||
602 | static void cleanup_vudc_hw(struct vudc *udc) | ||
603 | { | ||
604 | kfree(udc->ep); | ||
605 | } | ||
606 | |||
607 | /* platform driver ops */ | ||
608 | |||
609 | int vudc_probe(struct platform_device *pdev) | ||
610 | { | ||
611 | struct vudc *udc; | ||
612 | int ret = -ENOMEM; | ||
613 | |||
614 | udc = kzalloc(sizeof(*udc), GFP_KERNEL); | ||
615 | if (!udc) | ||
616 | goto out; | ||
617 | |||
618 | udc->gadget.name = GADGET_NAME; | ||
619 | udc->gadget.ops = &vgadget_ops; | ||
620 | udc->gadget.max_speed = USB_SPEED_HIGH; | ||
621 | udc->gadget.dev.parent = &pdev->dev; | ||
622 | udc->pdev = pdev; | ||
623 | |||
624 | ret = init_vudc_hw(udc); | ||
625 | if (ret) | ||
626 | goto err_init_vudc_hw; | ||
627 | |||
628 | ret = usb_add_gadget_udc(&pdev->dev, &udc->gadget); | ||
629 | if (ret < 0) | ||
630 | goto err_add_udc; | ||
631 | |||
632 | ret = sysfs_create_group(&pdev->dev.kobj, &vudc_attr_group); | ||
633 | if (ret) { | ||
634 | dev_err(&udc->pdev->dev, "create sysfs files\n"); | ||
635 | goto err_sysfs; | ||
636 | } | ||
637 | |||
638 | platform_set_drvdata(pdev, udc); | ||
639 | |||
640 | return ret; | ||
641 | |||
642 | err_sysfs: | ||
643 | usb_del_gadget_udc(&udc->gadget); | ||
644 | err_add_udc: | ||
645 | cleanup_vudc_hw(udc); | ||
646 | err_init_vudc_hw: | ||
647 | kfree(udc); | ||
648 | out: | ||
649 | return ret; | ||
650 | } | ||
651 | |||
652 | int vudc_remove(struct platform_device *pdev) | ||
653 | { | ||
654 | struct vudc *udc = platform_get_drvdata(pdev); | ||
655 | |||
656 | sysfs_remove_group(&pdev->dev.kobj, &vudc_attr_group); | ||
657 | usb_del_gadget_udc(&udc->gadget); | ||
658 | cleanup_vudc_hw(udc); | ||
659 | kfree(udc); | ||
660 | return 0; | ||
661 | } | ||
diff --git a/drivers/usb/usbip/vudc_main.c b/drivers/usb/usbip/vudc_main.c new file mode 100644 index 000000000000..9e655714e389 --- /dev/null +++ b/drivers/usb/usbip/vudc_main.c | |||
@@ -0,0 +1,113 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2015 Karol Kosik <karo9@interia.eu> | ||
3 | * Copyright (C) 2015-2016 Samsung Electronics | ||
4 | * Igor Kotrasinski <i.kotrasinsk@samsung.com> | ||
5 | * Krzysztof Opasiak <k.opasiak@samsung.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 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
19 | */ | ||
20 | |||
21 | #include <linux/device.h> | ||
22 | #include <linux/list.h> | ||
23 | #include <linux/module.h> | ||
24 | |||
25 | #include "vudc.h" | ||
26 | |||
27 | static unsigned int vudc_number = 1; | ||
28 | |||
29 | module_param_named(num, vudc_number, uint, S_IRUGO); | ||
30 | MODULE_PARM_DESC(num, "number of emulated controllers"); | ||
31 | |||
32 | static struct platform_driver vudc_driver = { | ||
33 | .probe = vudc_probe, | ||
34 | .remove = vudc_remove, | ||
35 | .driver = { | ||
36 | .name = GADGET_NAME, | ||
37 | }, | ||
38 | }; | ||
39 | |||
40 | static struct list_head vudc_devices = LIST_HEAD_INIT(vudc_devices); | ||
41 | |||
42 | static int __init init(void) | ||
43 | { | ||
44 | int retval = -ENOMEM; | ||
45 | int i; | ||
46 | struct vudc_device *udc_dev = NULL, *udc_dev2 = NULL; | ||
47 | |||
48 | if (usb_disabled()) | ||
49 | return -ENODEV; | ||
50 | |||
51 | if (vudc_number < 1) { | ||
52 | pr_err("Number of emulated UDC must be no less than 1"); | ||
53 | return -EINVAL; | ||
54 | } | ||
55 | |||
56 | retval = platform_driver_register(&vudc_driver); | ||
57 | if (retval < 0) | ||
58 | goto out; | ||
59 | |||
60 | for (i = 0; i < vudc_number; i++) { | ||
61 | udc_dev = alloc_vudc_device(i); | ||
62 | if (!udc_dev) { | ||
63 | retval = -ENOMEM; | ||
64 | goto cleanup; | ||
65 | } | ||
66 | |||
67 | retval = platform_device_add(udc_dev->pdev); | ||
68 | if (retval < 0) { | ||
69 | put_vudc_device(udc_dev); | ||
70 | goto cleanup; | ||
71 | } | ||
72 | |||
73 | list_add_tail(&udc_dev->dev_entry, &vudc_devices); | ||
74 | if (!platform_get_drvdata(udc_dev->pdev)) { | ||
75 | /* | ||
76 | * The udc was added successfully but its probe | ||
77 | * function failed for some reason. | ||
78 | */ | ||
79 | retval = -EINVAL; | ||
80 | goto cleanup; | ||
81 | } | ||
82 | } | ||
83 | goto out; | ||
84 | |||
85 | cleanup: | ||
86 | list_for_each_entry_safe(udc_dev, udc_dev2, &vudc_devices, dev_entry) { | ||
87 | list_del(&udc_dev->dev_entry); | ||
88 | platform_device_del(udc_dev->pdev); | ||
89 | put_vudc_device(udc_dev); | ||
90 | } | ||
91 | |||
92 | platform_driver_unregister(&vudc_driver); | ||
93 | out: | ||
94 | return retval; | ||
95 | } | ||
96 | module_init(init); | ||
97 | |||
98 | static void __exit cleanup(void) | ||
99 | { | ||
100 | struct vudc_device *udc_dev = NULL, *udc_dev2 = NULL; | ||
101 | |||
102 | list_for_each_entry_safe(udc_dev, udc_dev2, &vudc_devices, dev_entry) { | ||
103 | list_del(&udc_dev->dev_entry); | ||
104 | platform_device_unregister(udc_dev->pdev); | ||
105 | put_vudc_device(udc_dev); | ||
106 | } | ||
107 | platform_driver_unregister(&vudc_driver); | ||
108 | } | ||
109 | module_exit(cleanup); | ||
110 | |||
111 | MODULE_DESCRIPTION("USB over IP Device Controller"); | ||
112 | MODULE_AUTHOR("Krzysztof Opasiak, Karol Kosik, Igor Kotrasinski"); | ||
113 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/usb/usbip/vudc_rx.c b/drivers/usb/usbip/vudc_rx.c new file mode 100644 index 000000000000..344bd9473475 --- /dev/null +++ b/drivers/usb/usbip/vudc_rx.c | |||
@@ -0,0 +1,234 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2015 Karol Kosik <karo9@interia.eu> | ||
3 | * Copyright (C) 2015-2016 Samsung Electronics | ||
4 | * Igor Kotrasinski <i.kotrasinsk@samsung.com> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * 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 <net/sock.h> | ||
21 | #include <linux/list.h> | ||
22 | #include <linux/kthread.h> | ||
23 | |||
24 | #include "usbip_common.h" | ||
25 | #include "vudc.h" | ||
26 | |||
27 | static int alloc_urb_from_cmd(struct urb **urbp, | ||
28 | struct usbip_header *pdu, u8 type) | ||
29 | { | ||
30 | struct urb *urb; | ||
31 | |||
32 | if (type == USB_ENDPOINT_XFER_ISOC) | ||
33 | urb = usb_alloc_urb(pdu->u.cmd_submit.number_of_packets, | ||
34 | GFP_KERNEL); | ||
35 | else | ||
36 | urb = usb_alloc_urb(0, GFP_KERNEL); | ||
37 | |||
38 | if (!urb) | ||
39 | goto err; | ||
40 | |||
41 | usbip_pack_pdu(pdu, urb, USBIP_CMD_SUBMIT, 0); | ||
42 | |||
43 | if (urb->transfer_buffer_length > 0) { | ||
44 | urb->transfer_buffer = kzalloc(urb->transfer_buffer_length, | ||
45 | GFP_KERNEL); | ||
46 | if (!urb->transfer_buffer) | ||
47 | goto free_urb; | ||
48 | } | ||
49 | |||
50 | urb->setup_packet = kmemdup(&pdu->u.cmd_submit.setup, 8, | ||
51 | GFP_KERNEL); | ||
52 | if (!urb->setup_packet) | ||
53 | goto free_buffer; | ||
54 | |||
55 | /* | ||
56 | * FIXME - we only setup pipe enough for usbip functions | ||
57 | * to behave nicely | ||
58 | */ | ||
59 | urb->pipe |= pdu->base.direction == USBIP_DIR_IN ? | ||
60 | USB_DIR_IN : USB_DIR_OUT; | ||
61 | |||
62 | *urbp = urb; | ||
63 | return 0; | ||
64 | |||
65 | free_buffer: | ||
66 | kfree(urb->transfer_buffer); | ||
67 | urb->transfer_buffer = NULL; | ||
68 | free_urb: | ||
69 | usb_free_urb(urb); | ||
70 | err: | ||
71 | return -ENOMEM; | ||
72 | } | ||
73 | |||
74 | static int v_recv_cmd_unlink(struct vudc *udc, | ||
75 | struct usbip_header *pdu) | ||
76 | { | ||
77 | unsigned long flags; | ||
78 | struct urbp *urb_p; | ||
79 | |||
80 | spin_lock_irqsave(&udc->lock, flags); | ||
81 | list_for_each_entry(urb_p, &udc->urb_queue, urb_entry) { | ||
82 | if (urb_p->seqnum != pdu->u.cmd_unlink.seqnum) | ||
83 | continue; | ||
84 | urb_p->urb->unlinked = -ECONNRESET; | ||
85 | urb_p->seqnum = pdu->base.seqnum; | ||
86 | v_kick_timer(udc, jiffies); | ||
87 | spin_unlock_irqrestore(&udc->lock, flags); | ||
88 | return 0; | ||
89 | } | ||
90 | /* Not found, completed / not queued */ | ||
91 | spin_lock(&udc->lock_tx); | ||
92 | v_enqueue_ret_unlink(udc, pdu->base.seqnum, 0); | ||
93 | wake_up(&udc->tx_waitq); | ||
94 | spin_unlock(&udc->lock_tx); | ||
95 | spin_unlock_irqrestore(&udc->lock, flags); | ||
96 | |||
97 | return 0; | ||
98 | } | ||
99 | |||
100 | static int v_recv_cmd_submit(struct vudc *udc, | ||
101 | struct usbip_header *pdu) | ||
102 | { | ||
103 | int ret = 0; | ||
104 | struct urbp *urb_p; | ||
105 | u8 address; | ||
106 | unsigned long flags; | ||
107 | |||
108 | urb_p = alloc_urbp(); | ||
109 | if (!urb_p) { | ||
110 | usbip_event_add(&udc->ud, VUDC_EVENT_ERROR_MALLOC); | ||
111 | return -ENOMEM; | ||
112 | } | ||
113 | |||
114 | /* base.ep is pipeendpoint(pipe) */ | ||
115 | address = pdu->base.ep; | ||
116 | if (pdu->base.direction == USBIP_DIR_IN) | ||
117 | address |= USB_DIR_IN; | ||
118 | |||
119 | spin_lock_irq(&udc->lock); | ||
120 | urb_p->ep = vudc_find_endpoint(udc, address); | ||
121 | if (!urb_p->ep) { | ||
122 | /* we don't know the type, there may be isoc data! */ | ||
123 | dev_err(&udc->pdev->dev, "request to nonexistent endpoint"); | ||
124 | spin_unlock_irq(&udc->lock); | ||
125 | usbip_event_add(&udc->ud, VUDC_EVENT_ERROR_TCP); | ||
126 | ret = -EPIPE; | ||
127 | goto free_urbp; | ||
128 | } | ||
129 | urb_p->type = urb_p->ep->type; | ||
130 | spin_unlock_irq(&udc->lock); | ||
131 | |||
132 | urb_p->new = 1; | ||
133 | urb_p->seqnum = pdu->base.seqnum; | ||
134 | |||
135 | ret = alloc_urb_from_cmd(&urb_p->urb, pdu, urb_p->ep->type); | ||
136 | if (ret) { | ||
137 | usbip_event_add(&udc->ud, VUDC_EVENT_ERROR_MALLOC); | ||
138 | ret = -ENOMEM; | ||
139 | goto free_urbp; | ||
140 | } | ||
141 | |||
142 | urb_p->urb->status = -EINPROGRESS; | ||
143 | |||
144 | /* FIXME: more pipe setup to please usbip_common */ | ||
145 | urb_p->urb->pipe &= ~(11 << 30); | ||
146 | switch (urb_p->ep->type) { | ||
147 | case USB_ENDPOINT_XFER_BULK: | ||
148 | urb_p->urb->pipe |= (PIPE_BULK << 30); | ||
149 | break; | ||
150 | case USB_ENDPOINT_XFER_INT: | ||
151 | urb_p->urb->pipe |= (PIPE_INTERRUPT << 30); | ||
152 | break; | ||
153 | case USB_ENDPOINT_XFER_CONTROL: | ||
154 | urb_p->urb->pipe |= (PIPE_CONTROL << 30); | ||
155 | break; | ||
156 | case USB_ENDPOINT_XFER_ISOC: | ||
157 | urb_p->urb->pipe |= (PIPE_ISOCHRONOUS << 30); | ||
158 | break; | ||
159 | } | ||
160 | ret = usbip_recv_xbuff(&udc->ud, urb_p->urb); | ||
161 | if (ret < 0) | ||
162 | goto free_urbp; | ||
163 | |||
164 | ret = usbip_recv_iso(&udc->ud, urb_p->urb); | ||
165 | if (ret < 0) | ||
166 | goto free_urbp; | ||
167 | |||
168 | spin_lock_irqsave(&udc->lock, flags); | ||
169 | v_kick_timer(udc, jiffies); | ||
170 | list_add_tail(&urb_p->urb_entry, &udc->urb_queue); | ||
171 | spin_unlock_irqrestore(&udc->lock, flags); | ||
172 | |||
173 | return 0; | ||
174 | |||
175 | free_urbp: | ||
176 | free_urbp_and_urb(urb_p); | ||
177 | return ret; | ||
178 | } | ||
179 | |||
180 | static int v_rx_pdu(struct usbip_device *ud) | ||
181 | { | ||
182 | int ret; | ||
183 | struct usbip_header pdu; | ||
184 | struct vudc *udc = container_of(ud, struct vudc, ud); | ||
185 | |||
186 | memset(&pdu, 0, sizeof(pdu)); | ||
187 | ret = usbip_recv(ud->tcp_socket, &pdu, sizeof(pdu)); | ||
188 | if (ret != sizeof(pdu)) { | ||
189 | usbip_event_add(ud, VUDC_EVENT_ERROR_TCP); | ||
190 | if (ret >= 0) | ||
191 | return -EPIPE; | ||
192 | return ret; | ||
193 | } | ||
194 | usbip_header_correct_endian(&pdu, 0); | ||
195 | |||
196 | spin_lock_irq(&ud->lock); | ||
197 | ret = (ud->status == SDEV_ST_USED); | ||
198 | spin_unlock_irq(&ud->lock); | ||
199 | if (!ret) { | ||
200 | usbip_event_add(ud, VUDC_EVENT_ERROR_TCP); | ||
201 | return -EBUSY; | ||
202 | } | ||
203 | |||
204 | switch (pdu.base.command) { | ||
205 | case USBIP_CMD_UNLINK: | ||
206 | ret = v_recv_cmd_unlink(udc, &pdu); | ||
207 | break; | ||
208 | case USBIP_CMD_SUBMIT: | ||
209 | ret = v_recv_cmd_submit(udc, &pdu); | ||
210 | break; | ||
211 | default: | ||
212 | ret = -EPIPE; | ||
213 | pr_err("rx: unknown command"); | ||
214 | break; | ||
215 | } | ||
216 | return ret; | ||
217 | } | ||
218 | |||
219 | int v_rx_loop(void *data) | ||
220 | { | ||
221 | struct usbip_device *ud = data; | ||
222 | int ret = 0; | ||
223 | |||
224 | while (!kthread_should_stop()) { | ||
225 | if (usbip_event_happened(ud)) | ||
226 | break; | ||
227 | ret = v_rx_pdu(ud); | ||
228 | if (ret < 0) { | ||
229 | pr_warn("v_rx exit with error %d", ret); | ||
230 | break; | ||
231 | } | ||
232 | } | ||
233 | return ret; | ||
234 | } | ||
diff --git a/drivers/usb/usbip/vudc_sysfs.c b/drivers/usb/usbip/vudc_sysfs.c new file mode 100644 index 000000000000..99397fa1e3f0 --- /dev/null +++ b/drivers/usb/usbip/vudc_sysfs.c | |||
@@ -0,0 +1,229 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2015 Karol Kosik <karo9@interia.eu> | ||
3 | * Copyright (C) 2015-2016 Samsung Electronics | ||
4 | * Igor Kotrasinski <i.kotrasinsk@samsung.com> | ||
5 | * Krzysztof Opasiak <k.opasiak@samsung.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 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
19 | */ | ||
20 | |||
21 | #include <linux/device.h> | ||
22 | #include <linux/list.h> | ||
23 | #include <linux/usb/gadget.h> | ||
24 | #include <linux/usb/ch9.h> | ||
25 | #include <linux/sysfs.h> | ||
26 | #include <linux/kthread.h> | ||
27 | #include <linux/byteorder/generic.h> | ||
28 | |||
29 | #include "usbip_common.h" | ||
30 | #include "vudc.h" | ||
31 | |||
32 | #include <net/sock.h> | ||
33 | |||
34 | /* called with udc->lock held */ | ||
35 | int get_gadget_descs(struct vudc *udc) | ||
36 | { | ||
37 | struct vrequest *usb_req; | ||
38 | struct vep *ep0 = to_vep(udc->gadget.ep0); | ||
39 | struct usb_device_descriptor *ddesc = &udc->dev_desc; | ||
40 | struct usb_ctrlrequest req; | ||
41 | int ret; | ||
42 | |||
43 | if (!udc || !udc->driver || !udc->pullup) | ||
44 | return -EINVAL; | ||
45 | |||
46 | req.bRequestType = USB_DIR_IN | USB_TYPE_STANDARD | USB_RECIP_DEVICE; | ||
47 | req.bRequest = USB_REQ_GET_DESCRIPTOR; | ||
48 | req.wValue = cpu_to_le16(USB_DT_DEVICE << 8); | ||
49 | req.wIndex = cpu_to_le16(0); | ||
50 | req.wLength = cpu_to_le16(sizeof(*ddesc)); | ||
51 | |||
52 | spin_unlock(&udc->lock); | ||
53 | ret = udc->driver->setup(&(udc->gadget), &req); | ||
54 | spin_lock(&udc->lock); | ||
55 | if (ret < 0) | ||
56 | goto out; | ||
57 | |||
58 | /* assuming request queue is empty; request is now on top */ | ||
59 | usb_req = list_last_entry(&ep0->req_queue, struct vrequest, req_entry); | ||
60 | list_del(&usb_req->req_entry); | ||
61 | |||
62 | if (usb_req->req.length > sizeof(*ddesc)) { | ||
63 | ret = -EOVERFLOW; | ||
64 | goto giveback_req; | ||
65 | } | ||
66 | |||
67 | memcpy(ddesc, usb_req->req.buf, sizeof(*ddesc)); | ||
68 | udc->desc_cached = 1; | ||
69 | ret = 0; | ||
70 | giveback_req: | ||
71 | usb_req->req.status = 0; | ||
72 | usb_req->req.actual = usb_req->req.length; | ||
73 | usb_gadget_giveback_request(&(ep0->ep), &(usb_req->req)); | ||
74 | out: | ||
75 | return ret; | ||
76 | } | ||
77 | |||
78 | /* | ||
79 | * Exposes device descriptor from the gadget driver. | ||
80 | */ | ||
81 | static ssize_t dev_desc_read(struct file *file, struct kobject *kobj, | ||
82 | struct bin_attribute *attr, char *out, | ||
83 | loff_t off, size_t count) | ||
84 | { | ||
85 | struct device *dev = kobj_to_dev(kobj); | ||
86 | struct vudc *udc = (struct vudc *)dev_get_drvdata(dev); | ||
87 | char *desc_ptr = (char *) &udc->dev_desc; | ||
88 | unsigned long flags; | ||
89 | int ret; | ||
90 | |||
91 | spin_lock_irqsave(&udc->lock, flags); | ||
92 | if (!udc->desc_cached) { | ||
93 | ret = -ENODEV; | ||
94 | goto unlock; | ||
95 | } | ||
96 | |||
97 | memcpy(out, desc_ptr + off, count); | ||
98 | ret = count; | ||
99 | unlock: | ||
100 | spin_unlock_irqrestore(&udc->lock, flags); | ||
101 | return ret; | ||
102 | } | ||
103 | static BIN_ATTR_RO(dev_desc, sizeof(struct usb_device_descriptor)); | ||
104 | |||
105 | static ssize_t store_sockfd(struct device *dev, struct device_attribute *attr, | ||
106 | const char *in, size_t count) | ||
107 | { | ||
108 | struct vudc *udc = (struct vudc *) dev_get_drvdata(dev); | ||
109 | int rv; | ||
110 | int sockfd = 0; | ||
111 | int err; | ||
112 | struct socket *socket; | ||
113 | unsigned long flags; | ||
114 | int ret; | ||
115 | |||
116 | rv = kstrtoint(in, 0, &sockfd); | ||
117 | if (rv != 0) | ||
118 | return -EINVAL; | ||
119 | |||
120 | spin_lock_irqsave(&udc->lock, flags); | ||
121 | /* Don't export what we don't have */ | ||
122 | if (!udc || !udc->driver || !udc->pullup) { | ||
123 | dev_err(dev, "no device or gadget not bound"); | ||
124 | ret = -ENODEV; | ||
125 | goto unlock; | ||
126 | } | ||
127 | |||
128 | if (sockfd != -1) { | ||
129 | if (udc->connected) { | ||
130 | dev_err(dev, "Device already connected"); | ||
131 | ret = -EBUSY; | ||
132 | goto unlock; | ||
133 | } | ||
134 | |||
135 | spin_lock_irq(&udc->ud.lock); | ||
136 | |||
137 | if (udc->ud.status != SDEV_ST_AVAILABLE) { | ||
138 | ret = -EINVAL; | ||
139 | goto unlock_ud; | ||
140 | } | ||
141 | |||
142 | socket = sockfd_lookup(sockfd, &err); | ||
143 | if (!socket) { | ||
144 | dev_err(dev, "failed to lookup sock"); | ||
145 | ret = -EINVAL; | ||
146 | goto unlock_ud; | ||
147 | } | ||
148 | |||
149 | udc->ud.tcp_socket = socket; | ||
150 | |||
151 | spin_unlock_irq(&udc->ud.lock); | ||
152 | spin_unlock_irqrestore(&udc->lock, flags); | ||
153 | |||
154 | udc->ud.tcp_rx = kthread_get_run(&v_rx_loop, | ||
155 | &udc->ud, "vudc_rx"); | ||
156 | udc->ud.tcp_tx = kthread_get_run(&v_tx_loop, | ||
157 | &udc->ud, "vudc_tx"); | ||
158 | |||
159 | spin_lock_irqsave(&udc->lock, flags); | ||
160 | spin_lock_irq(&udc->ud.lock); | ||
161 | udc->ud.status = SDEV_ST_USED; | ||
162 | spin_unlock_irq(&udc->ud.lock); | ||
163 | |||
164 | do_gettimeofday(&udc->start_time); | ||
165 | v_start_timer(udc); | ||
166 | udc->connected = 1; | ||
167 | } else { | ||
168 | if (!udc->connected) { | ||
169 | dev_err(dev, "Device not connected"); | ||
170 | ret = -EINVAL; | ||
171 | goto unlock; | ||
172 | } | ||
173 | |||
174 | spin_lock_irq(&udc->ud.lock); | ||
175 | if (udc->ud.status != SDEV_ST_USED) { | ||
176 | ret = -EINVAL; | ||
177 | goto unlock_ud; | ||
178 | } | ||
179 | spin_unlock_irq(&udc->ud.lock); | ||
180 | |||
181 | usbip_event_add(&udc->ud, VUDC_EVENT_DOWN); | ||
182 | } | ||
183 | |||
184 | spin_unlock_irqrestore(&udc->lock, flags); | ||
185 | |||
186 | return count; | ||
187 | |||
188 | unlock_ud: | ||
189 | spin_unlock_irq(&udc->ud.lock); | ||
190 | unlock: | ||
191 | spin_unlock_irqrestore(&udc->lock, flags); | ||
192 | |||
193 | return ret; | ||
194 | } | ||
195 | static DEVICE_ATTR(usbip_sockfd, S_IWUSR, NULL, store_sockfd); | ||
196 | |||
197 | static ssize_t usbip_status_show(struct device *dev, | ||
198 | struct device_attribute *attr, char *out) | ||
199 | { | ||
200 | struct vudc *udc = (struct vudc *) dev_get_drvdata(dev); | ||
201 | int status; | ||
202 | |||
203 | if (!udc) { | ||
204 | dev_err(dev, "no device"); | ||
205 | return -ENODEV; | ||
206 | } | ||
207 | spin_lock_irq(&udc->ud.lock); | ||
208 | status = udc->ud.status; | ||
209 | spin_unlock_irq(&udc->ud.lock); | ||
210 | |||
211 | return snprintf(out, PAGE_SIZE, "%d\n", status); | ||
212 | } | ||
213 | static DEVICE_ATTR_RO(usbip_status); | ||
214 | |||
215 | static struct attribute *dev_attrs[] = { | ||
216 | &dev_attr_usbip_sockfd.attr, | ||
217 | &dev_attr_usbip_status.attr, | ||
218 | NULL, | ||
219 | }; | ||
220 | |||
221 | static struct bin_attribute *dev_bin_attrs[] = { | ||
222 | &bin_attr_dev_desc, | ||
223 | NULL, | ||
224 | }; | ||
225 | |||
226 | const struct attribute_group vudc_attr_group = { | ||
227 | .attrs = dev_attrs, | ||
228 | .bin_attrs = dev_bin_attrs, | ||
229 | }; | ||
diff --git a/drivers/usb/usbip/vudc_transfer.c b/drivers/usb/usbip/vudc_transfer.c new file mode 100644 index 000000000000..aba6bd478045 --- /dev/null +++ b/drivers/usb/usbip/vudc_transfer.c | |||
@@ -0,0 +1,506 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2015 Karol Kosik <karo9@interia.eu> | ||
3 | * Copyright (C) 2015-2016 Samsung Electronics | ||
4 | * Igor Kotrasinski <i.kotrasinsk@samsung.com> | ||
5 | * | ||
6 | * Based on dummy_hcd.c, which is: | ||
7 | * Copyright (C) 2003 David Brownell | ||
8 | * Copyright (C) 2003-2005 Alan Stern | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or modify | ||
11 | * it under the terms of the GNU General Public License as published by | ||
12 | * the Free Software Foundation; either version 2 of the License, or | ||
13 | * (at your option) any later version. | ||
14 | * | ||
15 | * This program is distributed in the hope that it will be useful, | ||
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
18 | * GNU General Public License for more details. | ||
19 | * | ||
20 | * You should have received a copy of the GNU General Public License | ||
21 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
22 | */ | ||
23 | |||
24 | #include <linux/usb.h> | ||
25 | #include <linux/timer.h> | ||
26 | #include <linux/usb/ch9.h> | ||
27 | |||
28 | #include "vudc.h" | ||
29 | |||
30 | #define DEV_REQUEST (USB_TYPE_STANDARD | USB_RECIP_DEVICE) | ||
31 | #define DEV_INREQUEST (DEV_REQUEST | USB_DIR_IN) | ||
32 | #define INTF_REQUEST (USB_TYPE_STANDARD | USB_RECIP_INTERFACE) | ||
33 | #define INTF_INREQUEST (INTF_REQUEST | USB_DIR_IN) | ||
34 | #define EP_REQUEST (USB_TYPE_STANDARD | USB_RECIP_ENDPOINT) | ||
35 | #define EP_INREQUEST (EP_REQUEST | USB_DIR_IN) | ||
36 | |||
37 | static int get_frame_limit(enum usb_device_speed speed) | ||
38 | { | ||
39 | switch (speed) { | ||
40 | case USB_SPEED_LOW: | ||
41 | return 8 /*bytes*/ * 12 /*packets*/; | ||
42 | case USB_SPEED_FULL: | ||
43 | return 64 /*bytes*/ * 19 /*packets*/; | ||
44 | case USB_SPEED_HIGH: | ||
45 | return 512 /*bytes*/ * 13 /*packets*/ * 8 /*uframes*/; | ||
46 | case USB_SPEED_SUPER: | ||
47 | /* Bus speed is 500000 bytes/ms, so use a little less */ | ||
48 | return 490000; | ||
49 | default: | ||
50 | /* error */ | ||
51 | return -1; | ||
52 | } | ||
53 | |||
54 | } | ||
55 | |||
56 | /* | ||
57 | * handle_control_request() - handles all control transfers | ||
58 | * @udc: pointer to vudc | ||
59 | * @urb: the urb request to handle | ||
60 | * @setup: pointer to the setup data for a USB device control | ||
61 | * request | ||
62 | * @status: pointer to request handling status | ||
63 | * | ||
64 | * Return 0 - if the request was handled | ||
65 | * 1 - if the request wasn't handles | ||
66 | * error code on error | ||
67 | * | ||
68 | * Adapted from drivers/usb/gadget/udc/dummy_hcd.c | ||
69 | */ | ||
70 | static int handle_control_request(struct vudc *udc, struct urb *urb, | ||
71 | struct usb_ctrlrequest *setup, | ||
72 | int *status) | ||
73 | { | ||
74 | struct vep *ep2; | ||
75 | int ret_val = 1; | ||
76 | unsigned w_index; | ||
77 | unsigned w_value; | ||
78 | |||
79 | w_index = le16_to_cpu(setup->wIndex); | ||
80 | w_value = le16_to_cpu(setup->wValue); | ||
81 | switch (setup->bRequest) { | ||
82 | case USB_REQ_SET_ADDRESS: | ||
83 | if (setup->bRequestType != DEV_REQUEST) | ||
84 | break; | ||
85 | udc->address = w_value; | ||
86 | ret_val = 0; | ||
87 | *status = 0; | ||
88 | break; | ||
89 | case USB_REQ_SET_FEATURE: | ||
90 | if (setup->bRequestType == DEV_REQUEST) { | ||
91 | ret_val = 0; | ||
92 | switch (w_value) { | ||
93 | case USB_DEVICE_REMOTE_WAKEUP: | ||
94 | break; | ||
95 | case USB_DEVICE_B_HNP_ENABLE: | ||
96 | udc->gadget.b_hnp_enable = 1; | ||
97 | break; | ||
98 | case USB_DEVICE_A_HNP_SUPPORT: | ||
99 | udc->gadget.a_hnp_support = 1; | ||
100 | break; | ||
101 | case USB_DEVICE_A_ALT_HNP_SUPPORT: | ||
102 | udc->gadget.a_alt_hnp_support = 1; | ||
103 | break; | ||
104 | default: | ||
105 | ret_val = -EOPNOTSUPP; | ||
106 | } | ||
107 | if (ret_val == 0) { | ||
108 | udc->devstatus |= (1 << w_value); | ||
109 | *status = 0; | ||
110 | } | ||
111 | } else if (setup->bRequestType == EP_REQUEST) { | ||
112 | /* endpoint halt */ | ||
113 | ep2 = vudc_find_endpoint(udc, w_index); | ||
114 | if (!ep2 || ep2->ep.name == udc->ep[0].ep.name) { | ||
115 | ret_val = -EOPNOTSUPP; | ||
116 | break; | ||
117 | } | ||
118 | ep2->halted = 1; | ||
119 | ret_val = 0; | ||
120 | *status = 0; | ||
121 | } | ||
122 | break; | ||
123 | case USB_REQ_CLEAR_FEATURE: | ||
124 | if (setup->bRequestType == DEV_REQUEST) { | ||
125 | ret_val = 0; | ||
126 | switch (w_value) { | ||
127 | case USB_DEVICE_REMOTE_WAKEUP: | ||
128 | w_value = USB_DEVICE_REMOTE_WAKEUP; | ||
129 | break; | ||
130 | |||
131 | case USB_DEVICE_U1_ENABLE: | ||
132 | case USB_DEVICE_U2_ENABLE: | ||
133 | case USB_DEVICE_LTM_ENABLE: | ||
134 | ret_val = -EOPNOTSUPP; | ||
135 | break; | ||
136 | default: | ||
137 | ret_val = -EOPNOTSUPP; | ||
138 | break; | ||
139 | } | ||
140 | if (ret_val == 0) { | ||
141 | udc->devstatus &= ~(1 << w_value); | ||
142 | *status = 0; | ||
143 | } | ||
144 | } else if (setup->bRequestType == EP_REQUEST) { | ||
145 | /* endpoint halt */ | ||
146 | ep2 = vudc_find_endpoint(udc, w_index); | ||
147 | if (!ep2) { | ||
148 | ret_val = -EOPNOTSUPP; | ||
149 | break; | ||
150 | } | ||
151 | if (!ep2->wedged) | ||
152 | ep2->halted = 0; | ||
153 | ret_val = 0; | ||
154 | *status = 0; | ||
155 | } | ||
156 | break; | ||
157 | case USB_REQ_GET_STATUS: | ||
158 | if (setup->bRequestType == DEV_INREQUEST | ||
159 | || setup->bRequestType == INTF_INREQUEST | ||
160 | || setup->bRequestType == EP_INREQUEST) { | ||
161 | char *buf; | ||
162 | /* | ||
163 | * device: remote wakeup, selfpowered | ||
164 | * interface: nothing | ||
165 | * endpoint: halt | ||
166 | */ | ||
167 | buf = (char *)urb->transfer_buffer; | ||
168 | if (urb->transfer_buffer_length > 0) { | ||
169 | if (setup->bRequestType == EP_INREQUEST) { | ||
170 | ep2 = vudc_find_endpoint(udc, w_index); | ||
171 | if (!ep2) { | ||
172 | ret_val = -EOPNOTSUPP; | ||
173 | break; | ||
174 | } | ||
175 | buf[0] = ep2->halted; | ||
176 | } else if (setup->bRequestType == | ||
177 | DEV_INREQUEST) { | ||
178 | buf[0] = (u8)udc->devstatus; | ||
179 | } else | ||
180 | buf[0] = 0; | ||
181 | } | ||
182 | if (urb->transfer_buffer_length > 1) | ||
183 | buf[1] = 0; | ||
184 | urb->actual_length = min_t(u32, 2, | ||
185 | urb->transfer_buffer_length); | ||
186 | ret_val = 0; | ||
187 | *status = 0; | ||
188 | } | ||
189 | break; | ||
190 | } | ||
191 | return ret_val; | ||
192 | } | ||
193 | |||
194 | /* Adapted from dummy_hcd.c ; caller must hold lock */ | ||
195 | static int transfer(struct vudc *udc, | ||
196 | struct urb *urb, struct vep *ep, int limit) | ||
197 | { | ||
198 | struct vrequest *req; | ||
199 | int sent = 0; | ||
200 | top: | ||
201 | /* if there's no request queued, the device is NAKing; return */ | ||
202 | list_for_each_entry(req, &ep->req_queue, req_entry) { | ||
203 | unsigned host_len, dev_len, len; | ||
204 | void *ubuf_pos, *rbuf_pos; | ||
205 | int is_short, to_host; | ||
206 | int rescan = 0; | ||
207 | |||
208 | /* | ||
209 | * 1..N packets of ep->ep.maxpacket each ... the last one | ||
210 | * may be short (including zero length). | ||
211 | * | ||
212 | * writer can send a zlp explicitly (length 0) or implicitly | ||
213 | * (length mod maxpacket zero, and 'zero' flag); they always | ||
214 | * terminate reads. | ||
215 | */ | ||
216 | host_len = urb->transfer_buffer_length - urb->actual_length; | ||
217 | dev_len = req->req.length - req->req.actual; | ||
218 | len = min(host_len, dev_len); | ||
219 | |||
220 | to_host = usb_pipein(urb->pipe); | ||
221 | if (unlikely(len == 0)) | ||
222 | is_short = 1; | ||
223 | else { | ||
224 | /* send multiple of maxpacket first, then remainder */ | ||
225 | if (len >= ep->ep.maxpacket) { | ||
226 | is_short = 0; | ||
227 | if (len % ep->ep.maxpacket > 0) | ||
228 | rescan = 1; | ||
229 | len -= len % ep->ep.maxpacket; | ||
230 | } else { | ||
231 | is_short = 1; | ||
232 | } | ||
233 | |||
234 | ubuf_pos = urb->transfer_buffer + urb->actual_length; | ||
235 | rbuf_pos = req->req.buf + req->req.actual; | ||
236 | |||
237 | if (urb->pipe & USB_DIR_IN) | ||
238 | memcpy(ubuf_pos, rbuf_pos, len); | ||
239 | else | ||
240 | memcpy(rbuf_pos, ubuf_pos, len); | ||
241 | |||
242 | urb->actual_length += len; | ||
243 | req->req.actual += len; | ||
244 | sent += len; | ||
245 | } | ||
246 | |||
247 | /* | ||
248 | * short packets terminate, maybe with overflow/underflow. | ||
249 | * it's only really an error to write too much. | ||
250 | * | ||
251 | * partially filling a buffer optionally blocks queue advances | ||
252 | * (so completion handlers can clean up the queue) but we don't | ||
253 | * need to emulate such data-in-flight. | ||
254 | */ | ||
255 | if (is_short) { | ||
256 | if (host_len == dev_len) { | ||
257 | req->req.status = 0; | ||
258 | urb->status = 0; | ||
259 | } else if (to_host) { | ||
260 | req->req.status = 0; | ||
261 | if (dev_len > host_len) | ||
262 | urb->status = -EOVERFLOW; | ||
263 | else | ||
264 | urb->status = 0; | ||
265 | } else { | ||
266 | urb->status = 0; | ||
267 | if (host_len > dev_len) | ||
268 | req->req.status = -EOVERFLOW; | ||
269 | else | ||
270 | req->req.status = 0; | ||
271 | } | ||
272 | |||
273 | /* many requests terminate without a short packet */ | ||
274 | /* also check if we need to send zlp */ | ||
275 | } else { | ||
276 | if (req->req.length == req->req.actual) { | ||
277 | if (req->req.zero && to_host) | ||
278 | rescan = 1; | ||
279 | else | ||
280 | req->req.status = 0; | ||
281 | } | ||
282 | if (urb->transfer_buffer_length == urb->actual_length) { | ||
283 | if (urb->transfer_flags & URB_ZERO_PACKET && | ||
284 | !to_host) | ||
285 | rescan = 1; | ||
286 | else | ||
287 | urb->status = 0; | ||
288 | } | ||
289 | } | ||
290 | |||
291 | /* device side completion --> continuable */ | ||
292 | if (req->req.status != -EINPROGRESS) { | ||
293 | |||
294 | list_del_init(&req->req_entry); | ||
295 | spin_unlock(&udc->lock); | ||
296 | usb_gadget_giveback_request(&ep->ep, &req->req); | ||
297 | spin_lock(&udc->lock); | ||
298 | |||
299 | /* requests might have been unlinked... */ | ||
300 | rescan = 1; | ||
301 | } | ||
302 | |||
303 | /* host side completion --> terminate */ | ||
304 | if (urb->status != -EINPROGRESS) | ||
305 | break; | ||
306 | |||
307 | /* rescan to continue with any other queued i/o */ | ||
308 | if (rescan) | ||
309 | goto top; | ||
310 | } | ||
311 | return sent; | ||
312 | } | ||
313 | |||
314 | static void v_timer(unsigned long _vudc) | ||
315 | { | ||
316 | struct vudc *udc = (struct vudc *) _vudc; | ||
317 | struct transfer_timer *timer = &udc->tr_timer; | ||
318 | struct urbp *urb_p, *tmp; | ||
319 | unsigned long flags; | ||
320 | struct usb_ep *_ep; | ||
321 | struct vep *ep; | ||
322 | int ret = 0; | ||
323 | int total, limit; | ||
324 | |||
325 | spin_lock_irqsave(&udc->lock, flags); | ||
326 | |||
327 | total = get_frame_limit(udc->gadget.speed); | ||
328 | if (total < 0) { /* unknown speed, or not set yet */ | ||
329 | timer->state = VUDC_TR_IDLE; | ||
330 | spin_unlock_irqrestore(&udc->lock, flags); | ||
331 | return; | ||
332 | } | ||
333 | /* is it next frame now? */ | ||
334 | if (time_after(jiffies, timer->frame_start + msecs_to_jiffies(1))) { | ||
335 | timer->frame_limit = total; | ||
336 | /* FIXME: how to make it accurate? */ | ||
337 | timer->frame_start = jiffies; | ||
338 | } else { | ||
339 | total = timer->frame_limit; | ||
340 | } | ||
341 | |||
342 | list_for_each_entry(_ep, &udc->gadget.ep_list, ep_list) { | ||
343 | ep = to_vep(_ep); | ||
344 | ep->already_seen = 0; | ||
345 | } | ||
346 | |||
347 | restart: | ||
348 | list_for_each_entry_safe(urb_p, tmp, &udc->urb_queue, urb_entry) { | ||
349 | struct urb *urb = urb_p->urb; | ||
350 | |||
351 | ep = urb_p->ep; | ||
352 | if (urb->unlinked) | ||
353 | goto return_urb; | ||
354 | if (timer->state != VUDC_TR_RUNNING) | ||
355 | continue; | ||
356 | |||
357 | if (!ep) { | ||
358 | urb->status = -EPROTO; | ||
359 | goto return_urb; | ||
360 | } | ||
361 | |||
362 | /* Used up bandwidth? */ | ||
363 | if (total <= 0 && ep->type == USB_ENDPOINT_XFER_BULK) | ||
364 | continue; | ||
365 | |||
366 | if (ep->already_seen) | ||
367 | continue; | ||
368 | ep->already_seen = 1; | ||
369 | if (ep == &udc->ep[0] && urb_p->new) { | ||
370 | ep->setup_stage = 1; | ||
371 | urb_p->new = 0; | ||
372 | } | ||
373 | if (ep->halted && !ep->setup_stage) { | ||
374 | urb->status = -EPIPE; | ||
375 | goto return_urb; | ||
376 | } | ||
377 | |||
378 | if (ep == &udc->ep[0] && ep->setup_stage) { | ||
379 | /* TODO - flush any stale requests */ | ||
380 | ep->setup_stage = 0; | ||
381 | ep->halted = 0; | ||
382 | |||
383 | ret = handle_control_request(udc, urb, | ||
384 | (struct usb_ctrlrequest *) urb->setup_packet, | ||
385 | (&urb->status)); | ||
386 | if (ret > 0) { | ||
387 | spin_unlock(&udc->lock); | ||
388 | ret = udc->driver->setup(&udc->gadget, | ||
389 | (struct usb_ctrlrequest *) | ||
390 | urb->setup_packet); | ||
391 | spin_lock(&udc->lock); | ||
392 | } | ||
393 | if (ret >= 0) { | ||
394 | /* no delays (max 64kb data stage) */ | ||
395 | limit = 64 * 1024; | ||
396 | goto treat_control_like_bulk; | ||
397 | } else { | ||
398 | urb->status = -EPIPE; | ||
399 | urb->actual_length = 0; | ||
400 | goto return_urb; | ||
401 | } | ||
402 | } | ||
403 | |||
404 | limit = total; | ||
405 | switch (ep->type) { | ||
406 | case USB_ENDPOINT_XFER_ISOC: | ||
407 | /* TODO: support */ | ||
408 | urb->status = -EXDEV; | ||
409 | break; | ||
410 | |||
411 | case USB_ENDPOINT_XFER_INT: | ||
412 | /* | ||
413 | * TODO: figure out bandwidth guarantees | ||
414 | * for now, give unlimited bandwidth | ||
415 | */ | ||
416 | limit += urb->transfer_buffer_length; | ||
417 | /* fallthrough */ | ||
418 | default: | ||
419 | treat_control_like_bulk: | ||
420 | total -= transfer(udc, urb, ep, limit); | ||
421 | } | ||
422 | if (urb->status == -EINPROGRESS) | ||
423 | continue; | ||
424 | |||
425 | return_urb: | ||
426 | if (ep) | ||
427 | ep->already_seen = ep->setup_stage = 0; | ||
428 | |||
429 | spin_lock(&udc->lock_tx); | ||
430 | list_del(&urb_p->urb_entry); | ||
431 | if (!urb->unlinked) { | ||
432 | v_enqueue_ret_submit(udc, urb_p); | ||
433 | } else { | ||
434 | v_enqueue_ret_unlink(udc, urb_p->seqnum, | ||
435 | urb->unlinked); | ||
436 | free_urbp_and_urb(urb_p); | ||
437 | } | ||
438 | wake_up(&udc->tx_waitq); | ||
439 | spin_unlock(&udc->lock_tx); | ||
440 | |||
441 | goto restart; | ||
442 | } | ||
443 | |||
444 | /* TODO - also wait on empty usb_request queues? */ | ||
445 | if (list_empty(&udc->urb_queue)) | ||
446 | timer->state = VUDC_TR_IDLE; | ||
447 | else | ||
448 | mod_timer(&timer->timer, | ||
449 | timer->frame_start + msecs_to_jiffies(1)); | ||
450 | |||
451 | spin_unlock_irqrestore(&udc->lock, flags); | ||
452 | } | ||
453 | |||
454 | /* All timer functions are run with udc->lock held */ | ||
455 | |||
456 | void v_init_timer(struct vudc *udc) | ||
457 | { | ||
458 | struct transfer_timer *t = &udc->tr_timer; | ||
459 | |||
460 | setup_timer(&t->timer, v_timer, (unsigned long) udc); | ||
461 | t->state = VUDC_TR_STOPPED; | ||
462 | } | ||
463 | |||
464 | void v_start_timer(struct vudc *udc) | ||
465 | { | ||
466 | struct transfer_timer *t = &udc->tr_timer; | ||
467 | |||
468 | dev_dbg(&udc->pdev->dev, "timer start"); | ||
469 | switch (t->state) { | ||
470 | case VUDC_TR_RUNNING: | ||
471 | return; | ||
472 | case VUDC_TR_IDLE: | ||
473 | return v_kick_timer(udc, jiffies); | ||
474 | case VUDC_TR_STOPPED: | ||
475 | t->state = VUDC_TR_IDLE; | ||
476 | t->frame_start = jiffies; | ||
477 | t->frame_limit = get_frame_limit(udc->gadget.speed); | ||
478 | return v_kick_timer(udc, jiffies); | ||
479 | } | ||
480 | } | ||
481 | |||
482 | void v_kick_timer(struct vudc *udc, unsigned long time) | ||
483 | { | ||
484 | struct transfer_timer *t = &udc->tr_timer; | ||
485 | |||
486 | dev_dbg(&udc->pdev->dev, "timer kick"); | ||
487 | switch (t->state) { | ||
488 | case VUDC_TR_RUNNING: | ||
489 | return; | ||
490 | case VUDC_TR_IDLE: | ||
491 | t->state = VUDC_TR_RUNNING; | ||
492 | /* fallthrough */ | ||
493 | case VUDC_TR_STOPPED: | ||
494 | /* we may want to kick timer to unqueue urbs */ | ||
495 | mod_timer(&t->timer, time); | ||
496 | } | ||
497 | } | ||
498 | |||
499 | void v_stop_timer(struct vudc *udc) | ||
500 | { | ||
501 | struct transfer_timer *t = &udc->tr_timer; | ||
502 | |||
503 | /* timer itself will take care of stopping */ | ||
504 | dev_dbg(&udc->pdev->dev, "timer stop"); | ||
505 | t->state = VUDC_TR_STOPPED; | ||
506 | } | ||
diff --git a/drivers/usb/usbip/vudc_tx.c b/drivers/usb/usbip/vudc_tx.c new file mode 100644 index 000000000000..234661782fa0 --- /dev/null +++ b/drivers/usb/usbip/vudc_tx.c | |||
@@ -0,0 +1,289 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2015 Karol Kosik <karo9@interia.eu> | ||
3 | * Copyright (C) 2015-2016 Samsung Electronics | ||
4 | * Igor Kotrasinski <i.kotrasinsk@samsung.com> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * 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 <net/sock.h> | ||
21 | #include <linux/list.h> | ||
22 | #include <linux/kthread.h> | ||
23 | |||
24 | #include "usbip_common.h" | ||
25 | #include "vudc.h" | ||
26 | |||
27 | static inline void setup_base_pdu(struct usbip_header_basic *base, | ||
28 | __u32 command, __u32 seqnum) | ||
29 | { | ||
30 | base->command = command; | ||
31 | base->seqnum = seqnum; | ||
32 | base->devid = 0; | ||
33 | base->ep = 0; | ||
34 | base->direction = 0; | ||
35 | } | ||
36 | |||
37 | static void setup_ret_submit_pdu(struct usbip_header *rpdu, struct urbp *urb_p) | ||
38 | { | ||
39 | setup_base_pdu(&rpdu->base, USBIP_RET_SUBMIT, urb_p->seqnum); | ||
40 | usbip_pack_pdu(rpdu, urb_p->urb, USBIP_RET_SUBMIT, 1); | ||
41 | } | ||
42 | |||
43 | static void setup_ret_unlink_pdu(struct usbip_header *rpdu, | ||
44 | struct v_unlink *unlink) | ||
45 | { | ||
46 | setup_base_pdu(&rpdu->base, USBIP_RET_UNLINK, unlink->seqnum); | ||
47 | rpdu->u.ret_unlink.status = unlink->status; | ||
48 | } | ||
49 | |||
50 | static int v_send_ret_unlink(struct vudc *udc, struct v_unlink *unlink) | ||
51 | { | ||
52 | struct msghdr msg; | ||
53 | struct kvec iov[1]; | ||
54 | size_t txsize; | ||
55 | |||
56 | int ret; | ||
57 | struct usbip_header pdu_header; | ||
58 | |||
59 | txsize = 0; | ||
60 | memset(&pdu_header, 0, sizeof(pdu_header)); | ||
61 | memset(&msg, 0, sizeof(msg)); | ||
62 | memset(&iov, 0, sizeof(iov)); | ||
63 | |||
64 | /* 1. setup usbip_header */ | ||
65 | setup_ret_unlink_pdu(&pdu_header, unlink); | ||
66 | usbip_header_correct_endian(&pdu_header, 1); | ||
67 | |||
68 | iov[0].iov_base = &pdu_header; | ||
69 | iov[0].iov_len = sizeof(pdu_header); | ||
70 | txsize += sizeof(pdu_header); | ||
71 | |||
72 | ret = kernel_sendmsg(udc->ud.tcp_socket, &msg, iov, | ||
73 | 1, txsize); | ||
74 | if (ret != txsize) { | ||
75 | usbip_event_add(&udc->ud, VUDC_EVENT_ERROR_TCP); | ||
76 | if (ret >= 0) | ||
77 | return -EPIPE; | ||
78 | return ret; | ||
79 | } | ||
80 | kfree(unlink); | ||
81 | |||
82 | return txsize; | ||
83 | } | ||
84 | |||
85 | static int v_send_ret_submit(struct vudc *udc, struct urbp *urb_p) | ||
86 | { | ||
87 | struct urb *urb = urb_p->urb; | ||
88 | struct usbip_header pdu_header; | ||
89 | struct usbip_iso_packet_descriptor *iso_buffer = NULL; | ||
90 | struct kvec *iov = NULL; | ||
91 | int iovnum = 0; | ||
92 | int ret = 0; | ||
93 | size_t txsize; | ||
94 | struct msghdr msg; | ||
95 | |||
96 | txsize = 0; | ||
97 | memset(&pdu_header, 0, sizeof(pdu_header)); | ||
98 | memset(&msg, 0, sizeof(msg)); | ||
99 | |||
100 | if (urb_p->type == USB_ENDPOINT_XFER_ISOC) | ||
101 | iovnum = 2 + urb->number_of_packets; | ||
102 | else | ||
103 | iovnum = 2; | ||
104 | |||
105 | iov = kcalloc(iovnum, sizeof(*iov), GFP_KERNEL); | ||
106 | if (!iov) { | ||
107 | usbip_event_add(&udc->ud, VUDC_EVENT_ERROR_MALLOC); | ||
108 | ret = -ENOMEM; | ||
109 | goto out; | ||
110 | } | ||
111 | iovnum = 0; | ||
112 | |||
113 | /* 1. setup usbip_header */ | ||
114 | setup_ret_submit_pdu(&pdu_header, urb_p); | ||
115 | usbip_dbg_stub_tx("setup txdata seqnum: %d urb: %p\n", | ||
116 | pdu_header.base.seqnum, urb); | ||
117 | usbip_header_correct_endian(&pdu_header, 1); | ||
118 | |||
119 | iov[iovnum].iov_base = &pdu_header; | ||
120 | iov[iovnum].iov_len = sizeof(pdu_header); | ||
121 | iovnum++; | ||
122 | txsize += sizeof(pdu_header); | ||
123 | |||
124 | /* 2. setup transfer buffer */ | ||
125 | if (urb_p->type != USB_ENDPOINT_XFER_ISOC && | ||
126 | usb_pipein(urb->pipe) && urb->actual_length > 0) { | ||
127 | iov[iovnum].iov_base = urb->transfer_buffer; | ||
128 | iov[iovnum].iov_len = urb->actual_length; | ||
129 | iovnum++; | ||
130 | txsize += urb->actual_length; | ||
131 | } else if (urb_p->type == USB_ENDPOINT_XFER_ISOC && | ||
132 | usb_pipein(urb->pipe)) { | ||
133 | /* FIXME - copypasted from stub_tx, refactor */ | ||
134 | int i; | ||
135 | |||
136 | for (i = 0; i < urb->number_of_packets; i++) { | ||
137 | iov[iovnum].iov_base = urb->transfer_buffer + | ||
138 | urb->iso_frame_desc[i].offset; | ||
139 | iov[iovnum].iov_len = | ||
140 | urb->iso_frame_desc[i].actual_length; | ||
141 | iovnum++; | ||
142 | txsize += urb->iso_frame_desc[i].actual_length; | ||
143 | } | ||
144 | |||
145 | if (txsize != sizeof(pdu_header) + urb->actual_length) { | ||
146 | usbip_event_add(&udc->ud, VUDC_EVENT_ERROR_TCP); | ||
147 | ret = -EPIPE; | ||
148 | goto out; | ||
149 | } | ||
150 | } | ||
151 | /* else - no buffer to send */ | ||
152 | |||
153 | /* 3. setup iso_packet_descriptor */ | ||
154 | if (urb_p->type == USB_ENDPOINT_XFER_ISOC) { | ||
155 | ssize_t len = 0; | ||
156 | |||
157 | iso_buffer = usbip_alloc_iso_desc_pdu(urb, &len); | ||
158 | if (!iso_buffer) { | ||
159 | usbip_event_add(&udc->ud, | ||
160 | VUDC_EVENT_ERROR_MALLOC); | ||
161 | ret = -ENOMEM; | ||
162 | goto out; | ||
163 | } | ||
164 | |||
165 | iov[iovnum].iov_base = iso_buffer; | ||
166 | iov[iovnum].iov_len = len; | ||
167 | txsize += len; | ||
168 | iovnum++; | ||
169 | } | ||
170 | |||
171 | ret = kernel_sendmsg(udc->ud.tcp_socket, &msg, | ||
172 | iov, iovnum, txsize); | ||
173 | if (ret != txsize) { | ||
174 | usbip_event_add(&udc->ud, VUDC_EVENT_ERROR_TCP); | ||
175 | if (ret >= 0) | ||
176 | ret = -EPIPE; | ||
177 | goto out; | ||
178 | } | ||
179 | |||
180 | out: | ||
181 | kfree(iov); | ||
182 | kfree(iso_buffer); | ||
183 | free_urbp_and_urb(urb_p); | ||
184 | if (ret < 0) | ||
185 | return ret; | ||
186 | return txsize; | ||
187 | } | ||
188 | |||
189 | static int v_send_ret(struct vudc *udc) | ||
190 | { | ||
191 | unsigned long flags; | ||
192 | struct tx_item *txi; | ||
193 | size_t total_size = 0; | ||
194 | int ret = 0; | ||
195 | |||
196 | spin_lock_irqsave(&udc->lock_tx, flags); | ||
197 | while (!list_empty(&udc->tx_queue)) { | ||
198 | txi = list_first_entry(&udc->tx_queue, struct tx_item, | ||
199 | tx_entry); | ||
200 | list_del(&txi->tx_entry); | ||
201 | spin_unlock_irqrestore(&udc->lock_tx, flags); | ||
202 | |||
203 | switch (txi->type) { | ||
204 | case TX_SUBMIT: | ||
205 | ret = v_send_ret_submit(udc, txi->s); | ||
206 | break; | ||
207 | case TX_UNLINK: | ||
208 | ret = v_send_ret_unlink(udc, txi->u); | ||
209 | break; | ||
210 | } | ||
211 | kfree(txi); | ||
212 | |||
213 | if (ret < 0) | ||
214 | return ret; | ||
215 | |||
216 | total_size += ret; | ||
217 | |||
218 | spin_lock_irqsave(&udc->lock_tx, flags); | ||
219 | } | ||
220 | |||
221 | spin_unlock_irqrestore(&udc->lock_tx, flags); | ||
222 | return total_size; | ||
223 | } | ||
224 | |||
225 | |||
226 | int v_tx_loop(void *data) | ||
227 | { | ||
228 | struct usbip_device *ud = (struct usbip_device *) data; | ||
229 | struct vudc *udc = container_of(ud, struct vudc, ud); | ||
230 | int ret; | ||
231 | |||
232 | while (!kthread_should_stop()) { | ||
233 | if (usbip_event_happened(&udc->ud)) | ||
234 | break; | ||
235 | ret = v_send_ret(udc); | ||
236 | if (ret < 0) { | ||
237 | pr_warn("v_tx exit with error %d", ret); | ||
238 | break; | ||
239 | } | ||
240 | wait_event_interruptible(udc->tx_waitq, | ||
241 | (!list_empty(&udc->tx_queue) || | ||
242 | kthread_should_stop())); | ||
243 | } | ||
244 | |||
245 | return 0; | ||
246 | } | ||
247 | |||
248 | /* called with spinlocks held */ | ||
249 | void v_enqueue_ret_unlink(struct vudc *udc, __u32 seqnum, __u32 status) | ||
250 | { | ||
251 | struct tx_item *txi; | ||
252 | struct v_unlink *unlink; | ||
253 | |||
254 | txi = kzalloc(sizeof(*txi), GFP_ATOMIC); | ||
255 | if (!txi) { | ||
256 | usbip_event_add(&udc->ud, VDEV_EVENT_ERROR_MALLOC); | ||
257 | return; | ||
258 | } | ||
259 | unlink = kzalloc(sizeof(*unlink), GFP_ATOMIC); | ||
260 | if (!unlink) { | ||
261 | kfree(txi); | ||
262 | usbip_event_add(&udc->ud, VDEV_EVENT_ERROR_MALLOC); | ||
263 | return; | ||
264 | } | ||
265 | |||
266 | unlink->seqnum = seqnum; | ||
267 | unlink->status = status; | ||
268 | txi->type = TX_UNLINK; | ||
269 | txi->u = unlink; | ||
270 | |||
271 | list_add_tail(&txi->tx_entry, &udc->tx_queue); | ||
272 | } | ||
273 | |||
274 | /* called with spinlocks held */ | ||
275 | void v_enqueue_ret_submit(struct vudc *udc, struct urbp *urb_p) | ||
276 | { | ||
277 | struct tx_item *txi; | ||
278 | |||
279 | txi = kzalloc(sizeof(*txi), GFP_ATOMIC); | ||
280 | if (!txi) { | ||
281 | usbip_event_add(&udc->ud, VDEV_EVENT_ERROR_MALLOC); | ||
282 | return; | ||
283 | } | ||
284 | |||
285 | txi->type = TX_SUBMIT; | ||
286 | txi->s = urb_p; | ||
287 | |||
288 | list_add_tail(&txi->tx_entry, &udc->tx_queue); | ||
289 | } | ||
diff --git a/drivers/usb/wusbcore/crypto.c b/drivers/usb/wusbcore/crypto.c index 8ed8e34c3492..33acd1599e99 100644 --- a/drivers/usb/wusbcore/crypto.c +++ b/drivers/usb/wusbcore/crypto.c | |||
@@ -54,7 +54,7 @@ | |||
54 | #include <linux/usb/wusb.h> | 54 | #include <linux/usb/wusb.h> |
55 | #include <linux/scatterlist.h> | 55 | #include <linux/scatterlist.h> |
56 | 56 | ||
57 | static int debug_crypto_verify = 0; | 57 | static int debug_crypto_verify; |
58 | 58 | ||
59 | module_param(debug_crypto_verify, int, 0); | 59 | module_param(debug_crypto_verify, int, 0); |
60 | MODULE_PARM_DESC(debug_crypto_verify, "verify the key generation algorithms"); | 60 | MODULE_PARM_DESC(debug_crypto_verify, "verify the key generation algorithms"); |
@@ -390,7 +390,7 @@ static int wusb_oob_mic_verify(void) | |||
390 | 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, | 390 | 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, |
391 | 0x2c, 0x2d, 0x2e, 0x2f }, | 391 | 0x2c, 0x2d, 0x2e, 0x2f }, |
392 | .MIC = { 0x75, 0x6a, 0x97, 0x51, 0x0c, 0x8c, | 392 | .MIC = { 0x75, 0x6a, 0x97, 0x51, 0x0c, 0x8c, |
393 | 0x14, 0x7b } , | 393 | 0x14, 0x7b }, |
394 | }; | 394 | }; |
395 | size_t hs_size; | 395 | size_t hs_size; |
396 | 396 | ||
@@ -480,7 +480,7 @@ static int wusb_key_derive_verify(void) | |||
480 | printk(KERN_ERR "E: keydvt in: key\n"); | 480 | printk(KERN_ERR "E: keydvt in: key\n"); |
481 | wusb_key_dump(stv_key_a1, sizeof(stv_key_a1)); | 481 | wusb_key_dump(stv_key_a1, sizeof(stv_key_a1)); |
482 | printk(KERN_ERR "E: keydvt in: nonce\n"); | 482 | printk(KERN_ERR "E: keydvt in: nonce\n"); |
483 | wusb_key_dump( &stv_keydvt_n_a1, sizeof(stv_keydvt_n_a1)); | 483 | wusb_key_dump(&stv_keydvt_n_a1, sizeof(stv_keydvt_n_a1)); |
484 | printk(KERN_ERR "E: keydvt in: hnonce & dnonce\n"); | 484 | printk(KERN_ERR "E: keydvt in: hnonce & dnonce\n"); |
485 | wusb_key_dump(&stv_keydvt_in_a1, sizeof(stv_keydvt_in_a1)); | 485 | wusb_key_dump(&stv_keydvt_in_a1, sizeof(stv_keydvt_in_a1)); |
486 | printk(KERN_ERR "E: keydvt out: KCK\n"); | 486 | printk(KERN_ERR "E: keydvt out: KCK\n"); |
diff --git a/drivers/usb/wusbcore/devconnect.c b/drivers/usb/wusbcore/devconnect.c index 3f4f5fbded55..bf9551735938 100644 --- a/drivers/usb/wusbcore/devconnect.c +++ b/drivers/usb/wusbcore/devconnect.c | |||
@@ -893,7 +893,6 @@ out: | |||
893 | error_nodev: | 893 | error_nodev: |
894 | return; | 894 | return; |
895 | 895 | ||
896 | wusb_dev_sysfs_rm(wusb_dev); | ||
897 | error_add_sysfs: | 896 | error_add_sysfs: |
898 | wusb_dev_bos_rm(wusb_dev); | 897 | wusb_dev_bos_rm(wusb_dev); |
899 | error_bos_add: | 898 | error_bos_add: |
diff --git a/include/linux/bcma/bcma.h b/include/linux/bcma/bcma.h index 0367c63f5960..e6b41f42602b 100644 --- a/include/linux/bcma/bcma.h +++ b/include/linux/bcma/bcma.h | |||
@@ -4,6 +4,7 @@ | |||
4 | #include <linux/pci.h> | 4 | #include <linux/pci.h> |
5 | #include <linux/mod_devicetable.h> | 5 | #include <linux/mod_devicetable.h> |
6 | 6 | ||
7 | #include <linux/bcma/bcma_driver_arm_c9.h> | ||
7 | #include <linux/bcma/bcma_driver_chipcommon.h> | 8 | #include <linux/bcma/bcma_driver_chipcommon.h> |
8 | #include <linux/bcma/bcma_driver_pci.h> | 9 | #include <linux/bcma/bcma_driver_pci.h> |
9 | #include <linux/bcma/bcma_driver_pcie2.h> | 10 | #include <linux/bcma/bcma_driver_pcie2.h> |
diff --git a/include/linux/bcma/bcma_driver_arm_c9.h b/include/linux/bcma/bcma_driver_arm_c9.h new file mode 100644 index 000000000000..93bd73d670d5 --- /dev/null +++ b/include/linux/bcma/bcma_driver_arm_c9.h | |||
@@ -0,0 +1,15 @@ | |||
1 | #ifndef LINUX_BCMA_DRIVER_ARM_C9_H_ | ||
2 | #define LINUX_BCMA_DRIVER_ARM_C9_H_ | ||
3 | |||
4 | /* DMU (Device Management Unit) */ | ||
5 | #define BCMA_DMU_CRU_USB2_CONTROL 0x0164 | ||
6 | #define BCMA_DMU_CRU_USB2_CONTROL_USB_PLL_NDIV_MASK 0x00000FFC | ||
7 | #define BCMA_DMU_CRU_USB2_CONTROL_USB_PLL_NDIV_SHIFT 2 | ||
8 | #define BCMA_DMU_CRU_USB2_CONTROL_USB_PLL_PDIV_MASK 0x00007000 | ||
9 | #define BCMA_DMU_CRU_USB2_CONTROL_USB_PLL_PDIV_SHIFT 12 | ||
10 | #define BCMA_DMU_CRU_CLKSET_KEY 0x0180 | ||
11 | #define BCMA_DMU_CRU_STRAPS_CTRL 0x02A0 | ||
12 | #define BCMA_DMU_CRU_STRAPS_CTRL_USB3 0x00000010 | ||
13 | #define BCMA_DMU_CRU_STRAPS_CTRL_4BYTE 0x00008000 | ||
14 | |||
15 | #endif /* LINUX_BCMA_DRIVER_ARM_C9_H_ */ | ||
diff --git a/include/linux/mfd/syscon/exynos5-pmu.h b/include/linux/mfd/syscon/exynos5-pmu.h index 9352adc95de6..76f30f940c70 100644 --- a/include/linux/mfd/syscon/exynos5-pmu.h +++ b/include/linux/mfd/syscon/exynos5-pmu.h | |||
@@ -38,6 +38,9 @@ | |||
38 | 38 | ||
39 | /* Exynos5433 specific register definitions */ | 39 | /* Exynos5433 specific register definitions */ |
40 | #define EXYNOS5433_USBHOST30_PHY_CONTROL (0x728) | 40 | #define EXYNOS5433_USBHOST30_PHY_CONTROL (0x728) |
41 | #define EXYNOS5433_MIPI_PHY0_CONTROL (0x710) | ||
42 | #define EXYNOS5433_MIPI_PHY1_CONTROL (0x714) | ||
43 | #define EXYNOS5433_MIPI_PHY2_CONTROL (0x718) | ||
41 | 44 | ||
42 | #define EXYNOS5_PHY_ENABLE BIT(0) | 45 | #define EXYNOS5_PHY_ENABLE BIT(0) |
43 | 46 | ||
diff --git a/include/linux/usb.h b/include/linux/usb.h index 6a9a0c28415d..eba1f10e8cfd 100644 --- a/include/linux/usb.h +++ b/include/linux/usb.h | |||
@@ -374,13 +374,12 @@ struct usb_bus { | |||
374 | 374 | ||
375 | int devnum_next; /* Next open device number in | 375 | int devnum_next; /* Next open device number in |
376 | * round-robin allocation */ | 376 | * round-robin allocation */ |
377 | struct mutex devnum_next_mutex; /* devnum_next mutex */ | ||
377 | 378 | ||
378 | struct usb_devmap devmap; /* device address allocation map */ | 379 | struct usb_devmap devmap; /* device address allocation map */ |
379 | struct usb_device *root_hub; /* Root hub */ | 380 | struct usb_device *root_hub; /* Root hub */ |
380 | struct usb_bus *hs_companion; /* Companion EHCI bus, if any */ | 381 | struct usb_bus *hs_companion; /* Companion EHCI bus, if any */ |
381 | 382 | ||
382 | struct mutex usb_address0_mutex; /* unaddressed device mutex */ | ||
383 | |||
384 | int bandwidth_allocated; /* on this bus: how much of the time | 383 | int bandwidth_allocated; /* on this bus: how much of the time |
385 | * reserved for periodic (intr/iso) | 384 | * reserved for periodic (intr/iso) |
386 | * requests is used, on average? | 385 | * requests is used, on average? |
@@ -720,7 +719,7 @@ extern void usb_enable_ltm(struct usb_device *udev); | |||
720 | 719 | ||
721 | static inline bool usb_device_supports_ltm(struct usb_device *udev) | 720 | static inline bool usb_device_supports_ltm(struct usb_device *udev) |
722 | { | 721 | { |
723 | if (udev->speed != USB_SPEED_SUPER || !udev->bos || !udev->bos->ss_cap) | 722 | if (udev->speed < USB_SPEED_SUPER || !udev->bos || !udev->bos->ss_cap) |
724 | return false; | 723 | return false; |
725 | return udev->bos->ss_cap->bmAttributes & USB_LTM_SUPPORT; | 724 | return udev->bos->ss_cap->bmAttributes & USB_LTM_SUPPORT; |
726 | } | 725 | } |
@@ -1069,7 +1068,7 @@ struct usbdrv_wrap { | |||
1069 | * for interfaces bound to this driver. | 1068 | * for interfaces bound to this driver. |
1070 | * @soft_unbind: if set to 1, the USB core will not kill URBs and disable | 1069 | * @soft_unbind: if set to 1, the USB core will not kill URBs and disable |
1071 | * endpoints before calling the driver's disconnect method. | 1070 | * endpoints before calling the driver's disconnect method. |
1072 | * @disable_hub_initiated_lpm: if set to 0, the USB core will not allow hubs | 1071 | * @disable_hub_initiated_lpm: if set to 1, the USB core will not allow hubs |
1073 | * to initiate lower power link state transitions when an idle timeout | 1072 | * to initiate lower power link state transitions when an idle timeout |
1074 | * occurs. Device-initiated USB 3.0 link PM will still be allowed. | 1073 | * occurs. Device-initiated USB 3.0 link PM will still be allowed. |
1075 | * | 1074 | * |
@@ -1569,7 +1568,7 @@ static inline void usb_fill_bulk_urb(struct urb *urb, | |||
1569 | * Initializes a interrupt urb with the proper information needed to submit | 1568 | * Initializes a interrupt urb with the proper information needed to submit |
1570 | * it to a device. | 1569 | * it to a device. |
1571 | * | 1570 | * |
1572 | * Note that High Speed and SuperSpeed interrupt endpoints use a logarithmic | 1571 | * Note that High Speed and SuperSpeed(+) interrupt endpoints use a logarithmic |
1573 | * encoding of the endpoint interval, and express polling intervals in | 1572 | * encoding of the endpoint interval, and express polling intervals in |
1574 | * microframes (eight per millisecond) rather than in frames (one per | 1573 | * microframes (eight per millisecond) rather than in frames (one per |
1575 | * millisecond). | 1574 | * millisecond). |
@@ -1595,7 +1594,7 @@ static inline void usb_fill_int_urb(struct urb *urb, | |||
1595 | urb->complete = complete_fn; | 1594 | urb->complete = complete_fn; |
1596 | urb->context = context; | 1595 | urb->context = context; |
1597 | 1596 | ||
1598 | if (dev->speed == USB_SPEED_HIGH || dev->speed == USB_SPEED_SUPER) { | 1597 | if (dev->speed == USB_SPEED_HIGH || dev->speed >= USB_SPEED_SUPER) { |
1599 | /* make sure interval is within allowed range */ | 1598 | /* make sure interval is within allowed range */ |
1600 | interval = clamp(interval, 1, 16); | 1599 | interval = clamp(interval, 1, 16); |
1601 | 1600 | ||
diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h index 5d4e151c49bf..457651bf45b0 100644 --- a/include/linux/usb/gadget.h +++ b/include/linux/usb/gadget.h | |||
@@ -1223,9 +1223,13 @@ int usb_otg_descriptor_init(struct usb_gadget *gadget, | |||
1223 | 1223 | ||
1224 | /* utility to simplify map/unmap of usb_requests to/from DMA */ | 1224 | /* utility to simplify map/unmap of usb_requests to/from DMA */ |
1225 | 1225 | ||
1226 | extern int usb_gadget_map_request_by_dev(struct device *dev, | ||
1227 | struct usb_request *req, int is_in); | ||
1226 | extern int usb_gadget_map_request(struct usb_gadget *gadget, | 1228 | extern int usb_gadget_map_request(struct usb_gadget *gadget, |
1227 | struct usb_request *req, int is_in); | 1229 | struct usb_request *req, int is_in); |
1228 | 1230 | ||
1231 | extern void usb_gadget_unmap_request_by_dev(struct device *dev, | ||
1232 | struct usb_request *req, int is_in); | ||
1229 | extern void usb_gadget_unmap_request(struct usb_gadget *gadget, | 1233 | extern void usb_gadget_unmap_request(struct usb_gadget *gadget, |
1230 | struct usb_request *req, int is_in); | 1234 | struct usb_request *req, int is_in); |
1231 | 1235 | ||
diff --git a/include/linux/usb/hcd.h b/include/linux/usb/hcd.h index b98f831dcda3..66fc13705ab7 100644 --- a/include/linux/usb/hcd.h +++ b/include/linux/usb/hcd.h | |||
@@ -181,6 +181,7 @@ struct usb_hcd { | |||
181 | * bandwidth_mutex should be dropped after a successful control message | 181 | * bandwidth_mutex should be dropped after a successful control message |
182 | * to the device, or resetting the bandwidth after a failed attempt. | 182 | * to the device, or resetting the bandwidth after a failed attempt. |
183 | */ | 183 | */ |
184 | struct mutex *address0_mutex; | ||
184 | struct mutex *bandwidth_mutex; | 185 | struct mutex *bandwidth_mutex; |
185 | struct usb_hcd *shared_hcd; | 186 | struct usb_hcd *shared_hcd; |
186 | struct usb_hcd *primary_hcd; | 187 | struct usb_hcd *primary_hcd; |
diff --git a/include/linux/usb/otg-fsm.h b/include/linux/usb/otg-fsm.h index 24198e16f849..7a0350535cb1 100644 --- a/include/linux/usb/otg-fsm.h +++ b/include/linux/usb/otg-fsm.h | |||
@@ -72,37 +72,113 @@ enum otg_fsm_timer { | |||
72 | NUM_OTG_FSM_TIMERS, | 72 | NUM_OTG_FSM_TIMERS, |
73 | }; | 73 | }; |
74 | 74 | ||
75 | /* OTG state machine according to the OTG spec */ | 75 | /** |
76 | * struct otg_fsm - OTG state machine according to the OTG spec | ||
77 | * | ||
78 | * OTG hardware Inputs | ||
79 | * | ||
80 | * Common inputs for A and B device | ||
81 | * @id: TRUE for B-device, FALSE for A-device. | ||
82 | * @adp_change: TRUE when current ADP measurement (n) value, compared to the | ||
83 | * ADP measurement taken at n-2, differs by more than CADP_THR | ||
84 | * @power_up: TRUE when the OTG device first powers up its USB system and | ||
85 | * ADP measurement taken if ADP capable | ||
86 | * | ||
87 | * A-Device state inputs | ||
88 | * @a_srp_det: TRUE if the A-device detects SRP | ||
89 | * @a_vbus_vld: TRUE when VBUS voltage is in regulation | ||
90 | * @b_conn: TRUE if the A-device detects connection from the B-device | ||
91 | * @a_bus_resume: TRUE when the B-device detects that the A-device is signaling | ||
92 | * a resume (K state) | ||
93 | * B-Device state inputs | ||
94 | * @a_bus_suspend: TRUE when the B-device detects that the A-device has put the | ||
95 | * bus into suspend | ||
96 | * @a_conn: TRUE if the B-device detects a connection from the A-device | ||
97 | * @b_se0_srp: TRUE when the line has been at SE0 for more than the minimum | ||
98 | * time before generating SRP | ||
99 | * @b_ssend_srp: TRUE when the VBUS has been below VOTG_SESS_VLD for more than | ||
100 | * the minimum time before generating SRP | ||
101 | * @b_sess_vld: TRUE when the B-device detects that the voltage on VBUS is | ||
102 | * above VOTG_SESS_VLD | ||
103 | * @test_device: TRUE when the B-device switches to B-Host and detects an OTG | ||
104 | * test device. This must be set by host/hub driver | ||
105 | * | ||
106 | * Application inputs (A-Device) | ||
107 | * @a_bus_drop: TRUE when A-device application needs to power down the bus | ||
108 | * @a_bus_req: TRUE when A-device application wants to use the bus. | ||
109 | * FALSE to suspend the bus | ||
110 | * | ||
111 | * Application inputs (B-Device) | ||
112 | * @b_bus_req: TRUE during the time that the Application running on the | ||
113 | * B-device wants to use the bus | ||
114 | * | ||
115 | * Auxilary inputs (OTG v1.3 only. Obsolete now.) | ||
116 | * @a_sess_vld: TRUE if the A-device detects that VBUS is above VA_SESS_VLD | ||
117 | * @b_bus_suspend: TRUE when the A-device detects that the B-device has put | ||
118 | * the bus into suspend | ||
119 | * @b_bus_resume: TRUE when the A-device detects that the B-device is signaling | ||
120 | * resume on the bus | ||
121 | * | ||
122 | * OTG Output status. Read only for users. Updated by OTG FSM helpers defined | ||
123 | * in this file | ||
124 | * | ||
125 | * Outputs for Both A and B device | ||
126 | * @drv_vbus: TRUE when A-device is driving VBUS | ||
127 | * @loc_conn: TRUE when the local device has signaled that it is connected | ||
128 | * to the bus | ||
129 | * @loc_sof: TRUE when the local device is generating activity on the bus | ||
130 | * @adp_prb: TRUE when the local device is in the process of doing | ||
131 | * ADP probing | ||
132 | * | ||
133 | * Outputs for B-device state | ||
134 | * @adp_sns: TRUE when the B-device is in the process of carrying out | ||
135 | * ADP sensing | ||
136 | * @data_pulse: TRUE when the B-device is performing data line pulsing | ||
137 | * | ||
138 | * Internal Variables | ||
139 | * | ||
140 | * a_set_b_hnp_en: TRUE when the A-device has successfully set the | ||
141 | * b_hnp_enable bit in the B-device. | ||
142 | * Unused as OTG fsm uses otg->host->b_hnp_enable instead | ||
143 | * b_srp_done: TRUE when the B-device has completed initiating SRP | ||
144 | * b_hnp_enable: TRUE when the B-device has accepted the | ||
145 | * SetFeature(b_hnp_enable) B-device. | ||
146 | * Unused as OTG fsm uses otg->gadget->b_hnp_enable instead | ||
147 | * a_clr_err: Asserted (by application ?) to clear a_vbus_err due to an | ||
148 | * overcurrent condition and causes the A-device to transition | ||
149 | * to a_wait_vfall | ||
150 | */ | ||
76 | struct otg_fsm { | 151 | struct otg_fsm { |
77 | /* Input */ | 152 | /* Input */ |
78 | int id; | 153 | int id; |
79 | int adp_change; | 154 | int adp_change; |
80 | int power_up; | 155 | int power_up; |
81 | int test_device; | ||
82 | int a_bus_drop; | ||
83 | int a_bus_req; | ||
84 | int a_srp_det; | 156 | int a_srp_det; |
85 | int a_vbus_vld; | 157 | int a_vbus_vld; |
86 | int b_conn; | 158 | int b_conn; |
87 | int a_bus_resume; | 159 | int a_bus_resume; |
88 | int a_bus_suspend; | 160 | int a_bus_suspend; |
89 | int a_conn; | 161 | int a_conn; |
90 | int b_bus_req; | ||
91 | int b_se0_srp; | 162 | int b_se0_srp; |
92 | int b_ssend_srp; | 163 | int b_ssend_srp; |
93 | int b_sess_vld; | 164 | int b_sess_vld; |
165 | int test_device; | ||
166 | int a_bus_drop; | ||
167 | int a_bus_req; | ||
168 | int b_bus_req; | ||
169 | |||
94 | /* Auxilary inputs */ | 170 | /* Auxilary inputs */ |
95 | int a_sess_vld; | 171 | int a_sess_vld; |
96 | int b_bus_resume; | 172 | int b_bus_resume; |
97 | int b_bus_suspend; | 173 | int b_bus_suspend; |
98 | 174 | ||
99 | /* Output */ | 175 | /* Output */ |
100 | int data_pulse; | ||
101 | int drv_vbus; | 176 | int drv_vbus; |
102 | int loc_conn; | 177 | int loc_conn; |
103 | int loc_sof; | 178 | int loc_sof; |
104 | int adp_prb; | 179 | int adp_prb; |
105 | int adp_sns; | 180 | int adp_sns; |
181 | int data_pulse; | ||
106 | 182 | ||
107 | /* Internal variables */ | 183 | /* Internal variables */ |
108 | int a_set_b_hnp_en; | 184 | int a_set_b_hnp_en; |
@@ -110,7 +186,7 @@ struct otg_fsm { | |||
110 | int b_hnp_enable; | 186 | int b_hnp_enable; |
111 | int a_clr_err; | 187 | int a_clr_err; |
112 | 188 | ||
113 | /* Informative variables */ | 189 | /* Informative variables. All unused as of now */ |
114 | int a_bus_drop_inf; | 190 | int a_bus_drop_inf; |
115 | int a_bus_req_inf; | 191 | int a_bus_req_inf; |
116 | int a_clr_err_inf; | 192 | int a_clr_err_inf; |
@@ -134,6 +210,7 @@ struct otg_fsm { | |||
134 | struct mutex lock; | 210 | struct mutex lock; |
135 | u8 *host_req_flag; | 211 | u8 *host_req_flag; |
136 | struct delayed_work hnp_polling_work; | 212 | struct delayed_work hnp_polling_work; |
213 | bool state_changed; | ||
137 | }; | 214 | }; |
138 | 215 | ||
139 | struct otg_fsm_ops { | 216 | struct otg_fsm_ops { |
diff --git a/include/uapi/linux/usb/ch9.h b/include/uapi/linux/usb/ch9.h index d5ce71607972..a8acc24765fe 100644 --- a/include/uapi/linux/usb/ch9.h +++ b/include/uapi/linux/usb/ch9.h | |||
@@ -105,6 +105,13 @@ | |||
105 | #define USB_REQ_LOOPBACK_DATA_READ 0x16 | 105 | #define USB_REQ_LOOPBACK_DATA_READ 0x16 |
106 | #define USB_REQ_SET_INTERFACE_DS 0x17 | 106 | #define USB_REQ_SET_INTERFACE_DS 0x17 |
107 | 107 | ||
108 | /* specific requests for USB Power Delivery */ | ||
109 | #define USB_REQ_GET_PARTNER_PDO 20 | ||
110 | #define USB_REQ_GET_BATTERY_STATUS 21 | ||
111 | #define USB_REQ_SET_PDO 22 | ||
112 | #define USB_REQ_GET_VDM 23 | ||
113 | #define USB_REQ_SEND_VDM 24 | ||
114 | |||
108 | /* The Link Power Management (LPM) ECN defines USB_REQ_TEST_AND_SET command, | 115 | /* The Link Power Management (LPM) ECN defines USB_REQ_TEST_AND_SET command, |
109 | * used by hubs to put ports into a new L1 suspend state, except that it | 116 | * used by hubs to put ports into a new L1 suspend state, except that it |
110 | * forgot to define its number ... | 117 | * forgot to define its number ... |
@@ -165,6 +172,22 @@ | |||
165 | #define USB_DEV_STAT_U2_ENABLED 3 /* transition into U2 state */ | 172 | #define USB_DEV_STAT_U2_ENABLED 3 /* transition into U2 state */ |
166 | #define USB_DEV_STAT_LTM_ENABLED 4 /* Latency tolerance messages */ | 173 | #define USB_DEV_STAT_LTM_ENABLED 4 /* Latency tolerance messages */ |
167 | 174 | ||
175 | /* | ||
176 | * Feature selectors from Table 9-8 USB Power Delivery spec | ||
177 | */ | ||
178 | #define USB_DEVICE_BATTERY_WAKE_MASK 40 | ||
179 | #define USB_DEVICE_OS_IS_PD_AWARE 41 | ||
180 | #define USB_DEVICE_POLICY_MODE 42 | ||
181 | #define USB_PORT_PR_SWAP 43 | ||
182 | #define USB_PORT_GOTO_MIN 44 | ||
183 | #define USB_PORT_RETURN_POWER 45 | ||
184 | #define USB_PORT_ACCEPT_PD_REQUEST 46 | ||
185 | #define USB_PORT_REJECT_PD_REQUEST 47 | ||
186 | #define USB_PORT_PORT_PD_RESET 48 | ||
187 | #define USB_PORT_C_PORT_PD_CHANGE 49 | ||
188 | #define USB_PORT_CABLE_PD_RESET 50 | ||
189 | #define USB_DEVICE_CHARGING_POLICY 54 | ||
190 | |||
168 | /** | 191 | /** |
169 | * struct usb_ctrlrequest - SETUP data for a USB device control request | 192 | * struct usb_ctrlrequest - SETUP data for a USB device control request |
170 | * @bRequestType: matches the USB bmRequestType field | 193 | * @bRequestType: matches the USB bmRequestType field |
@@ -914,6 +937,104 @@ struct usb_ssp_cap_descriptor { | |||
914 | } __attribute__((packed)); | 937 | } __attribute__((packed)); |
915 | 938 | ||
916 | /* | 939 | /* |
940 | * USB Power Delivery Capability Descriptor: | ||
941 | * Defines capabilities for PD | ||
942 | */ | ||
943 | /* Defines the various PD Capabilities of this device */ | ||
944 | #define USB_PD_POWER_DELIVERY_CAPABILITY 0x06 | ||
945 | /* Provides information on each battery supported by the device */ | ||
946 | #define USB_PD_BATTERY_INFO_CAPABILITY 0x07 | ||
947 | /* The Consumer characteristics of a Port on the device */ | ||
948 | #define USB_PD_PD_CONSUMER_PORT_CAPABILITY 0x08 | ||
949 | /* The provider characteristics of a Port on the device */ | ||
950 | #define USB_PD_PD_PROVIDER_PORT_CAPABILITY 0x09 | ||
951 | |||
952 | struct usb_pd_cap_descriptor { | ||
953 | __u8 bLength; | ||
954 | __u8 bDescriptorType; | ||
955 | __u8 bDevCapabilityType; /* set to USB_PD_POWER_DELIVERY_CAPABILITY */ | ||
956 | __u8 bReserved; | ||
957 | __le32 bmAttributes; | ||
958 | #define USB_PD_CAP_BATTERY_CHARGING (1 << 1) /* supports Battery Charging specification */ | ||
959 | #define USB_PD_CAP_USB_PD (1 << 2) /* supports USB Power Delivery specification */ | ||
960 | #define USB_PD_CAP_PROVIDER (1 << 3) /* can provide power */ | ||
961 | #define USB_PD_CAP_CONSUMER (1 << 4) /* can consume power */ | ||
962 | #define USB_PD_CAP_CHARGING_POLICY (1 << 5) /* supports CHARGING_POLICY feature */ | ||
963 | #define USB_PD_CAP_TYPE_C_CURRENT (1 << 6) /* supports power capabilities defined in the USB Type-C Specification */ | ||
964 | |||
965 | #define USB_PD_CAP_PWR_AC (1 << 8) | ||
966 | #define USB_PD_CAP_PWR_BAT (1 << 9) | ||
967 | #define USB_PD_CAP_PWR_USE_V_BUS (1 << 14) | ||
968 | |||
969 | __le16 bmProviderPorts; /* Bit zero refers to the UFP of the device */ | ||
970 | __le16 bmConsumerPorts; | ||
971 | __le16 bcdBCVersion; | ||
972 | __le16 bcdPDVersion; | ||
973 | __le16 bcdUSBTypeCVersion; | ||
974 | } __attribute__((packed)); | ||
975 | |||
976 | struct usb_pd_cap_battery_info_descriptor { | ||
977 | __u8 bLength; | ||
978 | __u8 bDescriptorType; | ||
979 | __u8 bDevCapabilityType; | ||
980 | /* Index of string descriptor shall contain the user friendly name for this battery */ | ||
981 | __u8 iBattery; | ||
982 | /* Index of string descriptor shall contain the Serial Number String for this battery */ | ||
983 | __u8 iSerial; | ||
984 | __u8 iManufacturer; | ||
985 | __u8 bBatteryId; /* uniquely identifies this battery in status Messages */ | ||
986 | __u8 bReserved; | ||
987 | /* | ||
988 | * Shall contain the Battery Charge value above which this | ||
989 | * battery is considered to be fully charged but not necessarily | ||
990 | * “topped off.” | ||
991 | */ | ||
992 | __le32 dwChargedThreshold; /* in mWh */ | ||
993 | /* | ||
994 | * Shall contain the minimum charge level of this battery such | ||
995 | * that above this threshold, a device can be assured of being | ||
996 | * able to power up successfully (see Battery Charging 1.2). | ||
997 | */ | ||
998 | __le32 dwWeakThreshold; /* in mWh */ | ||
999 | __le32 dwBatteryDesignCapacity; /* in mWh */ | ||
1000 | __le32 dwBatteryLastFullchargeCapacity; /* in mWh */ | ||
1001 | } __attribute__((packed)); | ||
1002 | |||
1003 | struct usb_pd_cap_consumer_port_descriptor { | ||
1004 | __u8 bLength; | ||
1005 | __u8 bDescriptorType; | ||
1006 | __u8 bDevCapabilityType; | ||
1007 | __u8 bReserved; | ||
1008 | __u8 bmCapabilities; | ||
1009 | /* port will oerate under: */ | ||
1010 | #define USB_PD_CAP_CONSUMER_BC (1 << 0) /* BC */ | ||
1011 | #define USB_PD_CAP_CONSUMER_PD (1 << 1) /* PD */ | ||
1012 | #define USB_PD_CAP_CONSUMER_TYPE_C (1 << 2) /* USB Type-C Current */ | ||
1013 | __le16 wMinVoltage; /* in 50mV units */ | ||
1014 | __le16 wMaxVoltage; /* in 50mV units */ | ||
1015 | __u16 wReserved; | ||
1016 | __le32 dwMaxOperatingPower; /* in 10 mW - operating at steady state */ | ||
1017 | __le32 dwMaxPeakPower; /* in 10mW units - operating at peak power */ | ||
1018 | __le32 dwMaxPeakPowerTime; /* in 100ms units - duration of peak */ | ||
1019 | #define USB_PD_CAP_CONSUMER_UNKNOWN_PEAK_POWER_TIME 0xffff | ||
1020 | } __attribute__((packed)); | ||
1021 | |||
1022 | struct usb_pd_cap_provider_port_descriptor { | ||
1023 | __u8 bLength; | ||
1024 | __u8 bDescriptorType; | ||
1025 | __u8 bDevCapabilityType; | ||
1026 | __u8 bReserved1; | ||
1027 | __u8 bmCapabilities; | ||
1028 | /* port will oerate under: */ | ||
1029 | #define USB_PD_CAP_PROVIDER_BC (1 << 0) /* BC */ | ||
1030 | #define USB_PD_CAP_PROVIDER_PD (1 << 1) /* PD */ | ||
1031 | #define USB_PD_CAP_PROVIDER_TYPE_C (1 << 2) /* USB Type-C Current */ | ||
1032 | __u8 bNumOfPDObjects; | ||
1033 | __u8 bReserved2; | ||
1034 | __le32 wPowerDataObject[]; | ||
1035 | } __attribute__((packed)); | ||
1036 | |||
1037 | /* | ||
917 | * Precision time measurement capability descriptor: advertised by devices and | 1038 | * Precision time measurement capability descriptor: advertised by devices and |
918 | * hubs that support PTM | 1039 | * hubs that support PTM |
919 | */ | 1040 | */ |
diff --git a/tools/usb/usbip/libsrc/Makefile.am b/tools/usb/usbip/libsrc/Makefile.am index 7c8f8a4d54e4..90daf95c0804 100644 --- a/tools/usb/usbip/libsrc/Makefile.am +++ b/tools/usb/usbip/libsrc/Makefile.am | |||
@@ -4,5 +4,7 @@ libusbip_la_LDFLAGS = -version-info @LIBUSBIP_VERSION@ | |||
4 | 4 | ||
5 | lib_LTLIBRARIES := libusbip.la | 5 | lib_LTLIBRARIES := libusbip.la |
6 | libusbip_la_SOURCES := names.c names.h usbip_host_driver.c usbip_host_driver.h \ | 6 | libusbip_la_SOURCES := names.c names.h usbip_host_driver.c usbip_host_driver.h \ |
7 | usbip_common.c usbip_common.h vhci_driver.c vhci_driver.h \ | 7 | usbip_device_driver.c usbip_device_driver.h \ |
8 | usbip_common.c usbip_common.h usbip_host_common.h \ | ||
9 | usbip_host_common.c vhci_driver.c vhci_driver.h \ | ||
8 | sysfs_utils.c sysfs_utils.h | 10 | sysfs_utils.c sysfs_utils.h |
diff --git a/tools/usb/usbip/libsrc/usbip_common.h b/tools/usb/usbip/libsrc/usbip_common.h index 15fe792e1e96..51ef5fe485dd 100644 --- a/tools/usb/usbip/libsrc/usbip_common.h +++ b/tools/usb/usbip/libsrc/usbip_common.h | |||
@@ -25,9 +25,12 @@ | |||
25 | #define VHCI_STATE_PATH "/var/run/vhci_hcd" | 25 | #define VHCI_STATE_PATH "/var/run/vhci_hcd" |
26 | #endif | 26 | #endif |
27 | 27 | ||
28 | #define VUDC_DEVICE_DESCR_FILE "dev_desc" | ||
29 | |||
28 | /* kernel module names */ | 30 | /* kernel module names */ |
29 | #define USBIP_CORE_MOD_NAME "usbip-core" | 31 | #define USBIP_CORE_MOD_NAME "usbip-core" |
30 | #define USBIP_HOST_DRV_NAME "usbip-host" | 32 | #define USBIP_HOST_DRV_NAME "usbip-host" |
33 | #define USBIP_DEVICE_DRV_NAME "usbip-vudc" | ||
31 | #define USBIP_VHCI_DRV_NAME "vhci_hcd" | 34 | #define USBIP_VHCI_DRV_NAME "vhci_hcd" |
32 | 35 | ||
33 | /* sysfs constants */ | 36 | /* sysfs constants */ |
diff --git a/tools/usb/usbip/libsrc/usbip_device_driver.c b/tools/usb/usbip/libsrc/usbip_device_driver.c new file mode 100644 index 000000000000..e059b7d1ec5b --- /dev/null +++ b/tools/usb/usbip/libsrc/usbip_device_driver.c | |||
@@ -0,0 +1,163 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2015 Karol Kosik <karo9@interia.eu> | ||
3 | * 2015 Samsung Electronics | ||
4 | * Author: Igor Kotrasinski <i.kotrasinsk@samsung.com> | ||
5 | * | ||
6 | * Based on tools/usb/usbip/libsrc/usbip_host_driver.c, which is: | ||
7 | * Copyright (C) 2011 matt mooney <mfm@muteddisk.com> | ||
8 | * 2005-2007 Takahiro Hirofuchi | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or modify | ||
11 | * it under the terms of the GNU General Public License as published by | ||
12 | * the Free Software Foundation; either version 2 of the License, or | ||
13 | * (at your option) any later version. | ||
14 | * | ||
15 | * This program is distributed in the hope that it will be useful, | ||
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
18 | * GNU General Public License for more details. | ||
19 | * | ||
20 | * You should have received a copy of the GNU General Public License | ||
21 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
22 | */ | ||
23 | |||
24 | #include <fcntl.h> | ||
25 | #include <string.h> | ||
26 | #include <linux/usb/ch9.h> | ||
27 | |||
28 | #include <unistd.h> | ||
29 | |||
30 | #include "usbip_host_common.h" | ||
31 | #include "usbip_device_driver.h" | ||
32 | |||
33 | #undef PROGNAME | ||
34 | #define PROGNAME "libusbip" | ||
35 | |||
36 | #define copy_descr_attr16(dev, descr, attr) \ | ||
37 | ((dev)->attr = le16toh((descr)->attr)) \ | ||
38 | |||
39 | #define copy_descr_attr(dev, descr, attr) \ | ||
40 | ((dev)->attr = (descr)->attr) \ | ||
41 | |||
42 | #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) | ||
43 | |||
44 | static struct { | ||
45 | enum usb_device_speed speed; | ||
46 | const char *name; | ||
47 | } speed_names[] = { | ||
48 | { | ||
49 | .speed = USB_SPEED_UNKNOWN, | ||
50 | .name = "UNKNOWN", | ||
51 | }, | ||
52 | { | ||
53 | .speed = USB_SPEED_LOW, | ||
54 | .name = "low-speed", | ||
55 | }, | ||
56 | { | ||
57 | .speed = USB_SPEED_FULL, | ||
58 | .name = "full-speed", | ||
59 | }, | ||
60 | { | ||
61 | .speed = USB_SPEED_HIGH, | ||
62 | .name = "high-speed", | ||
63 | }, | ||
64 | { | ||
65 | .speed = USB_SPEED_WIRELESS, | ||
66 | .name = "wireless", | ||
67 | }, | ||
68 | { | ||
69 | .speed = USB_SPEED_SUPER, | ||
70 | .name = "super-speed", | ||
71 | }, | ||
72 | }; | ||
73 | |||
74 | static | ||
75 | int read_usb_vudc_device(struct udev_device *sdev, struct usbip_usb_device *dev) | ||
76 | { | ||
77 | const char *path, *name; | ||
78 | char filepath[SYSFS_PATH_MAX]; | ||
79 | struct usb_device_descriptor descr; | ||
80 | unsigned i; | ||
81 | FILE *fd = NULL; | ||
82 | struct udev_device *plat; | ||
83 | const char *speed; | ||
84 | int ret = 0; | ||
85 | |||
86 | plat = udev_device_get_parent(sdev); | ||
87 | path = udev_device_get_syspath(plat); | ||
88 | snprintf(filepath, SYSFS_PATH_MAX, "%s/%s", | ||
89 | path, VUDC_DEVICE_DESCR_FILE); | ||
90 | fd = fopen(filepath, "r"); | ||
91 | if (!fd) | ||
92 | return -1; | ||
93 | ret = fread((char *) &descr, sizeof(descr), 1, fd); | ||
94 | if (ret < 0) | ||
95 | return -1; | ||
96 | fclose(fd); | ||
97 | |||
98 | copy_descr_attr(dev, &descr, bDeviceClass); | ||
99 | copy_descr_attr(dev, &descr, bDeviceSubClass); | ||
100 | copy_descr_attr(dev, &descr, bDeviceProtocol); | ||
101 | copy_descr_attr(dev, &descr, bNumConfigurations); | ||
102 | copy_descr_attr16(dev, &descr, idVendor); | ||
103 | copy_descr_attr16(dev, &descr, idProduct); | ||
104 | copy_descr_attr16(dev, &descr, bcdDevice); | ||
105 | |||
106 | strncpy(dev->path, path, SYSFS_PATH_MAX); | ||
107 | |||
108 | dev->speed = USB_SPEED_UNKNOWN; | ||
109 | speed = udev_device_get_sysattr_value(sdev, "current_speed"); | ||
110 | if (speed) { | ||
111 | for (i = 0; i < ARRAY_SIZE(speed_names); i++) { | ||
112 | if (!strcmp(speed_names[i].name, speed)) { | ||
113 | dev->speed = speed_names[i].speed; | ||
114 | break; | ||
115 | } | ||
116 | } | ||
117 | } | ||
118 | |||
119 | /* Only used for user output, little sense to output them in general */ | ||
120 | dev->bNumInterfaces = 0; | ||
121 | dev->bConfigurationValue = 0; | ||
122 | dev->busnum = 0; | ||
123 | |||
124 | name = udev_device_get_sysname(plat); | ||
125 | strncpy(dev->busid, name, SYSFS_BUS_ID_SIZE); | ||
126 | return 0; | ||
127 | } | ||
128 | |||
129 | static int is_my_device(struct udev_device *dev) | ||
130 | { | ||
131 | const char *driver; | ||
132 | |||
133 | driver = udev_device_get_property_value(dev, "USB_UDC_NAME"); | ||
134 | return driver != NULL && !strcmp(driver, USBIP_DEVICE_DRV_NAME); | ||
135 | } | ||
136 | |||
137 | static int usbip_device_driver_open(struct usbip_host_driver *hdriver) | ||
138 | { | ||
139 | int ret; | ||
140 | |||
141 | hdriver->ndevs = 0; | ||
142 | INIT_LIST_HEAD(&hdriver->edev_list); | ||
143 | |||
144 | ret = usbip_generic_driver_open(hdriver); | ||
145 | if (ret) | ||
146 | err("please load " USBIP_CORE_MOD_NAME ".ko and " | ||
147 | USBIP_DEVICE_DRV_NAME ".ko!"); | ||
148 | |||
149 | return ret; | ||
150 | } | ||
151 | |||
152 | struct usbip_host_driver device_driver = { | ||
153 | .edev_list = LIST_HEAD_INIT(device_driver.edev_list), | ||
154 | .udev_subsystem = "udc", | ||
155 | .ops = { | ||
156 | .open = usbip_device_driver_open, | ||
157 | .close = usbip_generic_driver_close, | ||
158 | .refresh_device_list = usbip_generic_refresh_device_list, | ||
159 | .get_device = usbip_generic_get_device, | ||
160 | .read_device = read_usb_vudc_device, | ||
161 | .is_my_device = is_my_device, | ||
162 | }, | ||
163 | }; | ||
diff --git a/tools/usb/usbip/libsrc/usbip_device_driver.h b/tools/usb/usbip/libsrc/usbip_device_driver.h new file mode 100644 index 000000000000..54cb658b37a3 --- /dev/null +++ b/tools/usb/usbip/libsrc/usbip_device_driver.h | |||
@@ -0,0 +1,34 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2015 Karol Kosik <karo9@interia.eu> | ||
3 | * 2015 Samsung Electronics | ||
4 | * Author: Igor Kotrasinski <i.kotrasinsk@samsung.com> | ||
5 | * | ||
6 | * Based on tools/usb/usbip/libsrc/usbip_host_driver.c, which is: | ||
7 | * Copyright (C) 2011 matt mooney <mfm@muteddisk.com> | ||
8 | * 2005-2007 Takahiro Hirofuchi | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or modify | ||
11 | * it under the terms of the GNU General Public License as published by | ||
12 | * the Free Software Foundation; either version 2 of the License, or | ||
13 | * (at your option) any later version. | ||
14 | * | ||
15 | * This program is distributed in the hope that it will be useful, | ||
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
18 | * GNU General Public License for more details. | ||
19 | * | ||
20 | * You should have received a copy of the GNU General Public License | ||
21 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
22 | */ | ||
23 | |||
24 | #ifndef __USBIP_DEVICE_DRIVER_H | ||
25 | #define __USBIP_DEVICE_DRIVER_H | ||
26 | |||
27 | #include <stdint.h> | ||
28 | #include "usbip_common.h" | ||
29 | #include "usbip_host_common.h" | ||
30 | #include "list.h" | ||
31 | |||
32 | extern struct usbip_host_driver device_driver; | ||
33 | |||
34 | #endif /* __USBIP_DEVICE_DRIVER_H */ | ||
diff --git a/tools/usb/usbip/libsrc/usbip_host_common.c b/tools/usb/usbip/libsrc/usbip_host_common.c new file mode 100644 index 000000000000..9d415228883d --- /dev/null +++ b/tools/usb/usbip/libsrc/usbip_host_common.c | |||
@@ -0,0 +1,273 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2015-2016 Samsung Electronics | ||
3 | * Igor Kotrasinski <i.kotrasinsk@samsung.com> | ||
4 | * Krzysztof Opasiak <k.opasiak@samsung.com> | ||
5 | * | ||
6 | * Refactored from usbip_host_driver.c, which is: | ||
7 | * Copyright (C) 2011 matt mooney <mfm@muteddisk.com> | ||
8 | * 2005-2007 Takahiro Hirofuchi | ||
9 | * | ||
10 | * This program is free software: you can redistribute it and/or modify | ||
11 | * it under the terms of the GNU General Public License as published by | ||
12 | * the Free Software Foundation, either version 2 of the License, or | ||
13 | * (at your option) any later version. | ||
14 | * | ||
15 | * This program is distributed in the hope that it will be useful, | ||
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
18 | * GNU General Public License for more details. | ||
19 | * | ||
20 | * You should have received a copy of the GNU General Public License | ||
21 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
22 | */ | ||
23 | |||
24 | #include <sys/types.h> | ||
25 | #include <sys/stat.h> | ||
26 | #include <fcntl.h> | ||
27 | |||
28 | #include <errno.h> | ||
29 | #include <unistd.h> | ||
30 | |||
31 | #include <libudev.h> | ||
32 | |||
33 | #include "usbip_common.h" | ||
34 | #include "usbip_host_common.h" | ||
35 | #include "list.h" | ||
36 | #include "sysfs_utils.h" | ||
37 | |||
38 | struct udev *udev_context; | ||
39 | |||
40 | static int32_t read_attr_usbip_status(struct usbip_usb_device *udev) | ||
41 | { | ||
42 | char status_attr_path[SYSFS_PATH_MAX]; | ||
43 | int fd; | ||
44 | int length; | ||
45 | char status; | ||
46 | int value = 0; | ||
47 | |||
48 | snprintf(status_attr_path, SYSFS_PATH_MAX, "%s/usbip_status", | ||
49 | udev->path); | ||
50 | |||
51 | fd = open(status_attr_path, O_RDONLY); | ||
52 | if (fd < 0) { | ||
53 | err("error opening attribute %s", status_attr_path); | ||
54 | return -1; | ||
55 | } | ||
56 | |||
57 | length = read(fd, &status, 1); | ||
58 | if (length < 0) { | ||
59 | err("error reading attribute %s", status_attr_path); | ||
60 | close(fd); | ||
61 | return -1; | ||
62 | } | ||
63 | |||
64 | value = atoi(&status); | ||
65 | |||
66 | return value; | ||
67 | } | ||
68 | |||
69 | static | ||
70 | struct usbip_exported_device *usbip_exported_device_new( | ||
71 | struct usbip_host_driver *hdriver, const char *sdevpath) | ||
72 | { | ||
73 | struct usbip_exported_device *edev = NULL; | ||
74 | struct usbip_exported_device *edev_old; | ||
75 | size_t size; | ||
76 | int i; | ||
77 | |||
78 | edev = calloc(1, sizeof(struct usbip_exported_device)); | ||
79 | |||
80 | edev->sudev = | ||
81 | udev_device_new_from_syspath(udev_context, sdevpath); | ||
82 | if (!edev->sudev) { | ||
83 | err("udev_device_new_from_syspath: %s", sdevpath); | ||
84 | goto err; | ||
85 | } | ||
86 | |||
87 | if (hdriver->ops.read_device(edev->sudev, &edev->udev) < 0) | ||
88 | goto err; | ||
89 | |||
90 | edev->status = read_attr_usbip_status(&edev->udev); | ||
91 | if (edev->status < 0) | ||
92 | goto err; | ||
93 | |||
94 | /* reallocate buffer to include usb interface data */ | ||
95 | size = sizeof(struct usbip_exported_device) + | ||
96 | edev->udev.bNumInterfaces * sizeof(struct usbip_usb_interface); | ||
97 | |||
98 | edev_old = edev; | ||
99 | edev = realloc(edev, size); | ||
100 | if (!edev) { | ||
101 | edev = edev_old; | ||
102 | dbg("realloc failed"); | ||
103 | goto err; | ||
104 | } | ||
105 | |||
106 | for (i = 0; i < edev->udev.bNumInterfaces; i++) { | ||
107 | /* vudc does not support reading interfaces */ | ||
108 | if (!hdriver->ops.read_interface) | ||
109 | break; | ||
110 | hdriver->ops.read_interface(&edev->udev, i, &edev->uinf[i]); | ||
111 | } | ||
112 | |||
113 | return edev; | ||
114 | err: | ||
115 | if (edev->sudev) | ||
116 | udev_device_unref(edev->sudev); | ||
117 | if (edev) | ||
118 | free(edev); | ||
119 | |||
120 | return NULL; | ||
121 | } | ||
122 | |||
123 | static int refresh_exported_devices(struct usbip_host_driver *hdriver) | ||
124 | { | ||
125 | struct usbip_exported_device *edev; | ||
126 | struct udev_enumerate *enumerate; | ||
127 | struct udev_list_entry *devices, *dev_list_entry; | ||
128 | struct udev_device *dev; | ||
129 | const char *path; | ||
130 | |||
131 | enumerate = udev_enumerate_new(udev_context); | ||
132 | udev_enumerate_add_match_subsystem(enumerate, hdriver->udev_subsystem); | ||
133 | udev_enumerate_scan_devices(enumerate); | ||
134 | |||
135 | devices = udev_enumerate_get_list_entry(enumerate); | ||
136 | |||
137 | udev_list_entry_foreach(dev_list_entry, devices) { | ||
138 | path = udev_list_entry_get_name(dev_list_entry); | ||
139 | dev = udev_device_new_from_syspath(udev_context, | ||
140 | path); | ||
141 | if (dev == NULL) | ||
142 | continue; | ||
143 | |||
144 | /* Check whether device uses usbip driver. */ | ||
145 | if (hdriver->ops.is_my_device(dev)) { | ||
146 | edev = usbip_exported_device_new(hdriver, path); | ||
147 | if (!edev) { | ||
148 | dbg("usbip_exported_device_new failed"); | ||
149 | continue; | ||
150 | } | ||
151 | |||
152 | list_add(&edev->node, &hdriver->edev_list); | ||
153 | hdriver->ndevs++; | ||
154 | } | ||
155 | } | ||
156 | |||
157 | return 0; | ||
158 | } | ||
159 | |||
160 | static void usbip_exported_device_destroy(struct list_head *devs) | ||
161 | { | ||
162 | struct list_head *i, *tmp; | ||
163 | struct usbip_exported_device *edev; | ||
164 | |||
165 | list_for_each_safe(i, tmp, devs) { | ||
166 | edev = list_entry(i, struct usbip_exported_device, node); | ||
167 | list_del(i); | ||
168 | free(edev); | ||
169 | } | ||
170 | } | ||
171 | |||
172 | int usbip_generic_driver_open(struct usbip_host_driver *hdriver) | ||
173 | { | ||
174 | int rc; | ||
175 | |||
176 | udev_context = udev_new(); | ||
177 | if (!udev_context) { | ||
178 | err("udev_new failed"); | ||
179 | return -1; | ||
180 | } | ||
181 | |||
182 | rc = refresh_exported_devices(hdriver); | ||
183 | if (rc < 0) | ||
184 | goto err; | ||
185 | return 0; | ||
186 | err: | ||
187 | udev_unref(udev_context); | ||
188 | return -1; | ||
189 | } | ||
190 | |||
191 | void usbip_generic_driver_close(struct usbip_host_driver *hdriver) | ||
192 | { | ||
193 | if (!hdriver) | ||
194 | return; | ||
195 | |||
196 | usbip_exported_device_destroy(&hdriver->edev_list); | ||
197 | |||
198 | udev_unref(udev_context); | ||
199 | } | ||
200 | |||
201 | int usbip_generic_refresh_device_list(struct usbip_host_driver *hdriver) | ||
202 | { | ||
203 | int rc; | ||
204 | |||
205 | usbip_exported_device_destroy(&hdriver->edev_list); | ||
206 | |||
207 | hdriver->ndevs = 0; | ||
208 | INIT_LIST_HEAD(&hdriver->edev_list); | ||
209 | |||
210 | rc = refresh_exported_devices(hdriver); | ||
211 | if (rc < 0) | ||
212 | return -1; | ||
213 | |||
214 | return 0; | ||
215 | } | ||
216 | |||
217 | int usbip_export_device(struct usbip_exported_device *edev, int sockfd) | ||
218 | { | ||
219 | char attr_name[] = "usbip_sockfd"; | ||
220 | char sockfd_attr_path[SYSFS_PATH_MAX]; | ||
221 | char sockfd_buff[30]; | ||
222 | int ret; | ||
223 | |||
224 | if (edev->status != SDEV_ST_AVAILABLE) { | ||
225 | dbg("device not available: %s", edev->udev.busid); | ||
226 | switch (edev->status) { | ||
227 | case SDEV_ST_ERROR: | ||
228 | dbg("status SDEV_ST_ERROR"); | ||
229 | break; | ||
230 | case SDEV_ST_USED: | ||
231 | dbg("status SDEV_ST_USED"); | ||
232 | break; | ||
233 | default: | ||
234 | dbg("status unknown: 0x%x", edev->status); | ||
235 | } | ||
236 | return -1; | ||
237 | } | ||
238 | |||
239 | /* only the first interface is true */ | ||
240 | snprintf(sockfd_attr_path, sizeof(sockfd_attr_path), "%s/%s", | ||
241 | edev->udev.path, attr_name); | ||
242 | |||
243 | snprintf(sockfd_buff, sizeof(sockfd_buff), "%d\n", sockfd); | ||
244 | |||
245 | ret = write_sysfs_attribute(sockfd_attr_path, sockfd_buff, | ||
246 | strlen(sockfd_buff)); | ||
247 | if (ret < 0) { | ||
248 | err("write_sysfs_attribute failed: sockfd %s to %s", | ||
249 | sockfd_buff, sockfd_attr_path); | ||
250 | return ret; | ||
251 | } | ||
252 | |||
253 | info("connect: %s", edev->udev.busid); | ||
254 | |||
255 | return ret; | ||
256 | } | ||
257 | |||
258 | struct usbip_exported_device *usbip_generic_get_device( | ||
259 | struct usbip_host_driver *hdriver, int num) | ||
260 | { | ||
261 | struct list_head *i; | ||
262 | struct usbip_exported_device *edev; | ||
263 | int cnt = 0; | ||
264 | |||
265 | list_for_each(i, &hdriver->edev_list) { | ||
266 | edev = list_entry(i, struct usbip_exported_device, node); | ||
267 | if (num == cnt) | ||
268 | return edev; | ||
269 | cnt++; | ||
270 | } | ||
271 | |||
272 | return NULL; | ||
273 | } | ||
diff --git a/tools/usb/usbip/libsrc/usbip_host_common.h b/tools/usb/usbip/libsrc/usbip_host_common.h new file mode 100644 index 000000000000..a64b8033fe64 --- /dev/null +++ b/tools/usb/usbip/libsrc/usbip_host_common.h | |||
@@ -0,0 +1,104 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2015-2016 Samsung Electronics | ||
3 | * Igor Kotrasinski <i.kotrasinsk@samsung.com> | ||
4 | * Krzysztof Opasiak <k.opasiak@samsung.com> | ||
5 | * | ||
6 | * Refactored from usbip_host_driver.c, which is: | ||
7 | * Copyright (C) 2011 matt mooney <mfm@muteddisk.com> | ||
8 | * 2005-2007 Takahiro Hirofuchi | ||
9 | * | ||
10 | * This program is free software: you can redistribute it and/or modify | ||
11 | * it under the terms of the GNU General Public License as published by | ||
12 | * the Free Software Foundation, either version 2 of the License, or | ||
13 | * (at your option) any later version. | ||
14 | * | ||
15 | * This program is distributed in the hope that it will be useful, | ||
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
18 | * GNU General Public License for more details. | ||
19 | * | ||
20 | * You should have received a copy of the GNU General Public License | ||
21 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
22 | */ | ||
23 | |||
24 | #ifndef __USBIP_HOST_COMMON_H | ||
25 | #define __USBIP_HOST_COMMON_H | ||
26 | |||
27 | #include <stdint.h> | ||
28 | #include <libudev.h> | ||
29 | #include <errno.h> | ||
30 | #include "list.h" | ||
31 | #include "usbip_common.h" | ||
32 | #include "sysfs_utils.h" | ||
33 | |||
34 | struct usbip_host_driver; | ||
35 | |||
36 | struct usbip_host_driver_ops { | ||
37 | int (*open)(struct usbip_host_driver *hdriver); | ||
38 | void (*close)(struct usbip_host_driver *hdriver); | ||
39 | int (*refresh_device_list)(struct usbip_host_driver *hdriver); | ||
40 | struct usbip_exported_device * (*get_device)( | ||
41 | struct usbip_host_driver *hdriver, int num); | ||
42 | |||
43 | int (*read_device)(struct udev_device *sdev, | ||
44 | struct usbip_usb_device *dev); | ||
45 | int (*read_interface)(struct usbip_usb_device *udev, int i, | ||
46 | struct usbip_usb_interface *uinf); | ||
47 | int (*is_my_device)(struct udev_device *udev); | ||
48 | }; | ||
49 | |||
50 | struct usbip_host_driver { | ||
51 | int ndevs; | ||
52 | /* list of exported device */ | ||
53 | struct list_head edev_list; | ||
54 | const char *udev_subsystem; | ||
55 | struct usbip_host_driver_ops ops; | ||
56 | }; | ||
57 | |||
58 | struct usbip_exported_device { | ||
59 | struct udev_device *sudev; | ||
60 | int32_t status; | ||
61 | struct usbip_usb_device udev; | ||
62 | struct list_head node; | ||
63 | struct usbip_usb_interface uinf[]; | ||
64 | }; | ||
65 | |||
66 | /* External API to access the driver */ | ||
67 | static inline int usbip_driver_open(struct usbip_host_driver *hdriver) | ||
68 | { | ||
69 | if (!hdriver->ops.open) | ||
70 | return -EOPNOTSUPP; | ||
71 | return hdriver->ops.open(hdriver); | ||
72 | } | ||
73 | |||
74 | static inline void usbip_driver_close(struct usbip_host_driver *hdriver) | ||
75 | { | ||
76 | if (!hdriver->ops.close) | ||
77 | return; | ||
78 | hdriver->ops.close(hdriver); | ||
79 | } | ||
80 | |||
81 | static inline int usbip_refresh_device_list(struct usbip_host_driver *hdriver) | ||
82 | { | ||
83 | if (!hdriver->ops.refresh_device_list) | ||
84 | return -EOPNOTSUPP; | ||
85 | return hdriver->ops.refresh_device_list(hdriver); | ||
86 | } | ||
87 | |||
88 | static inline struct usbip_exported_device * | ||
89 | usbip_get_device(struct usbip_host_driver *hdriver, int num) | ||
90 | { | ||
91 | if (!hdriver->ops.get_device) | ||
92 | return NULL; | ||
93 | return hdriver->ops.get_device(hdriver, num); | ||
94 | } | ||
95 | |||
96 | /* Helper functions for implementing driver backend */ | ||
97 | int usbip_generic_driver_open(struct usbip_host_driver *hdriver); | ||
98 | void usbip_generic_driver_close(struct usbip_host_driver *hdriver); | ||
99 | int usbip_generic_refresh_device_list(struct usbip_host_driver *hdriver); | ||
100 | int usbip_export_device(struct usbip_exported_device *edev, int sockfd); | ||
101 | struct usbip_exported_device *usbip_generic_get_device( | ||
102 | struct usbip_host_driver *hdriver, int num); | ||
103 | |||
104 | #endif /* __USBIP_HOST_COMMON_H */ | ||
diff --git a/tools/usb/usbip/libsrc/usbip_host_driver.c b/tools/usb/usbip/libsrc/usbip_host_driver.c index bef08d5c44e8..4de6edc54d35 100644 --- a/tools/usb/usbip/libsrc/usbip_host_driver.c +++ b/tools/usb/usbip/libsrc/usbip_host_driver.c | |||
@@ -1,6 +1,9 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2011 matt mooney <mfm@muteddisk.com> | 2 | * Copyright (C) 2011 matt mooney <mfm@muteddisk.com> |
3 | * 2005-2007 Takahiro Hirofuchi | 3 | * 2005-2007 Takahiro Hirofuchi |
4 | * Copyright (C) 2015-2016 Samsung Electronics | ||
5 | * Igor Kotrasinski <i.kotrasinsk@samsung.com> | ||
6 | * Krzysztof Opasiak <k.opasiak@samsung.com> | ||
4 | * | 7 | * |
5 | * This program is free software: you can redistribute it and/or modify | 8 | * This program is free software: you can redistribute it and/or modify |
6 | * it under the terms of the GNU General Public License as published by | 9 | * it under the terms of the GNU General Public License as published by |
@@ -16,265 +19,47 @@ | |||
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | */ | 20 | */ |
18 | 21 | ||
19 | #include <sys/types.h> | ||
20 | #include <sys/stat.h> | ||
21 | #include <fcntl.h> | ||
22 | |||
23 | #include <errno.h> | ||
24 | #include <unistd.h> | 22 | #include <unistd.h> |
25 | |||
26 | #include <libudev.h> | 23 | #include <libudev.h> |
27 | 24 | ||
28 | #include "usbip_common.h" | 25 | #include "usbip_host_common.h" |
29 | #include "usbip_host_driver.h" | 26 | #include "usbip_host_driver.h" |
30 | #include "list.h" | ||
31 | #include "sysfs_utils.h" | ||
32 | 27 | ||
33 | #undef PROGNAME | 28 | #undef PROGNAME |
34 | #define PROGNAME "libusbip" | 29 | #define PROGNAME "libusbip" |
35 | 30 | ||
36 | struct usbip_host_driver *host_driver; | 31 | static int is_my_device(struct udev_device *dev) |
37 | struct udev *udev_context; | ||
38 | |||
39 | static int32_t read_attr_usbip_status(struct usbip_usb_device *udev) | ||
40 | { | ||
41 | char status_attr_path[SYSFS_PATH_MAX]; | ||
42 | int fd; | ||
43 | int length; | ||
44 | char status; | ||
45 | int value = 0; | ||
46 | |||
47 | snprintf(status_attr_path, SYSFS_PATH_MAX, "%s/usbip_status", | ||
48 | udev->path); | ||
49 | |||
50 | fd = open(status_attr_path, O_RDONLY); | ||
51 | if (fd < 0) { | ||
52 | err("error opening attribute %s", status_attr_path); | ||
53 | return -1; | ||
54 | } | ||
55 | |||
56 | length = read(fd, &status, 1); | ||
57 | if (length < 0) { | ||
58 | err("error reading attribute %s", status_attr_path); | ||
59 | close(fd); | ||
60 | return -1; | ||
61 | } | ||
62 | |||
63 | value = atoi(&status); | ||
64 | |||
65 | return value; | ||
66 | } | ||
67 | |||
68 | static | ||
69 | struct usbip_exported_device *usbip_exported_device_new(const char *sdevpath) | ||
70 | { | ||
71 | struct usbip_exported_device *edev = NULL; | ||
72 | struct usbip_exported_device *edev_old; | ||
73 | size_t size; | ||
74 | int i; | ||
75 | |||
76 | edev = calloc(1, sizeof(struct usbip_exported_device)); | ||
77 | |||
78 | edev->sudev = udev_device_new_from_syspath(udev_context, sdevpath); | ||
79 | if (!edev->sudev) { | ||
80 | err("udev_device_new_from_syspath: %s", sdevpath); | ||
81 | goto err; | ||
82 | } | ||
83 | |||
84 | read_usb_device(edev->sudev, &edev->udev); | ||
85 | |||
86 | edev->status = read_attr_usbip_status(&edev->udev); | ||
87 | if (edev->status < 0) | ||
88 | goto err; | ||
89 | |||
90 | /* reallocate buffer to include usb interface data */ | ||
91 | size = sizeof(struct usbip_exported_device) + | ||
92 | edev->udev.bNumInterfaces * sizeof(struct usbip_usb_interface); | ||
93 | |||
94 | edev_old = edev; | ||
95 | edev = realloc(edev, size); | ||
96 | if (!edev) { | ||
97 | edev = edev_old; | ||
98 | dbg("realloc failed"); | ||
99 | goto err; | ||
100 | } | ||
101 | |||
102 | for (i = 0; i < edev->udev.bNumInterfaces; i++) | ||
103 | read_usb_interface(&edev->udev, i, &edev->uinf[i]); | ||
104 | |||
105 | return edev; | ||
106 | err: | ||
107 | if (edev->sudev) | ||
108 | udev_device_unref(edev->sudev); | ||
109 | if (edev) | ||
110 | free(edev); | ||
111 | |||
112 | return NULL; | ||
113 | } | ||
114 | |||
115 | static int refresh_exported_devices(void) | ||
116 | { | 32 | { |
117 | struct usbip_exported_device *edev; | ||
118 | struct udev_enumerate *enumerate; | ||
119 | struct udev_list_entry *devices, *dev_list_entry; | ||
120 | struct udev_device *dev; | ||
121 | const char *path; | ||
122 | const char *driver; | 33 | const char *driver; |
123 | 34 | ||
124 | enumerate = udev_enumerate_new(udev_context); | 35 | driver = udev_device_get_driver(dev); |
125 | udev_enumerate_add_match_subsystem(enumerate, "usb"); | 36 | return driver != NULL && !strcmp(driver, USBIP_HOST_DRV_NAME); |
126 | udev_enumerate_scan_devices(enumerate); | ||
127 | |||
128 | devices = udev_enumerate_get_list_entry(enumerate); | ||
129 | |||
130 | udev_list_entry_foreach(dev_list_entry, devices) { | ||
131 | path = udev_list_entry_get_name(dev_list_entry); | ||
132 | dev = udev_device_new_from_syspath(udev_context, path); | ||
133 | if (dev == NULL) | ||
134 | continue; | ||
135 | |||
136 | /* Check whether device uses usbip-host driver. */ | ||
137 | driver = udev_device_get_driver(dev); | ||
138 | if (driver != NULL && !strcmp(driver, USBIP_HOST_DRV_NAME)) { | ||
139 | edev = usbip_exported_device_new(path); | ||
140 | if (!edev) { | ||
141 | dbg("usbip_exported_device_new failed"); | ||
142 | continue; | ||
143 | } | ||
144 | |||
145 | list_add(&edev->node, &host_driver->edev_list); | ||
146 | host_driver->ndevs++; | ||
147 | } | ||
148 | } | ||
149 | |||
150 | return 0; | ||
151 | } | ||
152 | |||
153 | static void usbip_exported_device_destroy(void) | ||
154 | { | ||
155 | struct list_head *i, *tmp; | ||
156 | struct usbip_exported_device *edev; | ||
157 | |||
158 | list_for_each_safe(i, tmp, &host_driver->edev_list) { | ||
159 | edev = list_entry(i, struct usbip_exported_device, node); | ||
160 | list_del(i); | ||
161 | free(edev); | ||
162 | } | ||
163 | } | 37 | } |
164 | 38 | ||
165 | int usbip_host_driver_open(void) | 39 | static int usbip_host_driver_open(struct usbip_host_driver *hdriver) |
166 | { | 40 | { |
167 | int rc; | ||
168 | |||
169 | udev_context = udev_new(); | ||
170 | if (!udev_context) { | ||
171 | err("udev_new failed"); | ||
172 | return -1; | ||
173 | } | ||
174 | |||
175 | host_driver = calloc(1, sizeof(*host_driver)); | ||
176 | |||
177 | host_driver->ndevs = 0; | ||
178 | INIT_LIST_HEAD(&host_driver->edev_list); | ||
179 | |||
180 | rc = refresh_exported_devices(); | ||
181 | if (rc < 0) | ||
182 | goto err_free_host_driver; | ||
183 | |||
184 | return 0; | ||
185 | |||
186 | err_free_host_driver: | ||
187 | free(host_driver); | ||
188 | host_driver = NULL; | ||
189 | |||
190 | udev_unref(udev_context); | ||
191 | |||
192 | return -1; | ||
193 | } | ||
194 | |||
195 | void usbip_host_driver_close(void) | ||
196 | { | ||
197 | if (!host_driver) | ||
198 | return; | ||
199 | |||
200 | usbip_exported_device_destroy(); | ||
201 | |||
202 | free(host_driver); | ||
203 | host_driver = NULL; | ||
204 | |||
205 | udev_unref(udev_context); | ||
206 | } | ||
207 | |||
208 | int usbip_host_refresh_device_list(void) | ||
209 | { | ||
210 | int rc; | ||
211 | |||
212 | usbip_exported_device_destroy(); | ||
213 | |||
214 | host_driver->ndevs = 0; | ||
215 | INIT_LIST_HEAD(&host_driver->edev_list); | ||
216 | |||
217 | rc = refresh_exported_devices(); | ||
218 | if (rc < 0) | ||
219 | return -1; | ||
220 | |||
221 | return 0; | ||
222 | } | ||
223 | |||
224 | int usbip_host_export_device(struct usbip_exported_device *edev, int sockfd) | ||
225 | { | ||
226 | char attr_name[] = "usbip_sockfd"; | ||
227 | char sockfd_attr_path[SYSFS_PATH_MAX]; | ||
228 | char sockfd_buff[30]; | ||
229 | int ret; | 41 | int ret; |
230 | 42 | ||
231 | if (edev->status != SDEV_ST_AVAILABLE) { | 43 | hdriver->ndevs = 0; |
232 | dbg("device not available: %s", edev->udev.busid); | 44 | INIT_LIST_HEAD(&hdriver->edev_list); |
233 | switch (edev->status) { | ||
234 | case SDEV_ST_ERROR: | ||
235 | dbg("status SDEV_ST_ERROR"); | ||
236 | break; | ||
237 | case SDEV_ST_USED: | ||
238 | dbg("status SDEV_ST_USED"); | ||
239 | break; | ||
240 | default: | ||
241 | dbg("status unknown: 0x%x", edev->status); | ||
242 | } | ||
243 | return -1; | ||
244 | } | ||
245 | |||
246 | /* only the first interface is true */ | ||
247 | snprintf(sockfd_attr_path, sizeof(sockfd_attr_path), "%s/%s", | ||
248 | edev->udev.path, attr_name); | ||
249 | |||
250 | snprintf(sockfd_buff, sizeof(sockfd_buff), "%d\n", sockfd); | ||
251 | |||
252 | ret = write_sysfs_attribute(sockfd_attr_path, sockfd_buff, | ||
253 | strlen(sockfd_buff)); | ||
254 | if (ret < 0) { | ||
255 | err("write_sysfs_attribute failed: sockfd %s to %s", | ||
256 | sockfd_buff, sockfd_attr_path); | ||
257 | return ret; | ||
258 | } | ||
259 | |||
260 | info("connect: %s", edev->udev.busid); | ||
261 | 45 | ||
46 | ret = usbip_generic_driver_open(hdriver); | ||
47 | if (ret) | ||
48 | err("please load " USBIP_CORE_MOD_NAME ".ko and " | ||
49 | USBIP_HOST_DRV_NAME ".ko!"); | ||
262 | return ret; | 50 | return ret; |
263 | } | 51 | } |
264 | 52 | ||
265 | struct usbip_exported_device *usbip_host_get_device(int num) | 53 | struct usbip_host_driver host_driver = { |
266 | { | 54 | .edev_list = LIST_HEAD_INIT(host_driver.edev_list), |
267 | struct list_head *i; | 55 | .udev_subsystem = "usb", |
268 | struct usbip_exported_device *edev; | 56 | .ops = { |
269 | int cnt = 0; | 57 | .open = usbip_host_driver_open, |
270 | 58 | .close = usbip_generic_driver_close, | |
271 | list_for_each(i, &host_driver->edev_list) { | 59 | .refresh_device_list = usbip_generic_refresh_device_list, |
272 | edev = list_entry(i, struct usbip_exported_device, node); | 60 | .get_device = usbip_generic_get_device, |
273 | if (num == cnt) | 61 | .read_device = read_usb_device, |
274 | return edev; | 62 | .read_interface = read_usb_interface, |
275 | else | 63 | .is_my_device = is_my_device, |
276 | cnt++; | 64 | }, |
277 | } | 65 | }; |
278 | |||
279 | return NULL; | ||
280 | } | ||
diff --git a/tools/usb/usbip/libsrc/usbip_host_driver.h b/tools/usb/usbip/libsrc/usbip_host_driver.h index 2a31f855c616..77f07e72a7fe 100644 --- a/tools/usb/usbip/libsrc/usbip_host_driver.h +++ b/tools/usb/usbip/libsrc/usbip_host_driver.h | |||
@@ -1,6 +1,9 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2011 matt mooney <mfm@muteddisk.com> | 2 | * Copyright (C) 2011 matt mooney <mfm@muteddisk.com> |
3 | * 2005-2007 Takahiro Hirofuchi | 3 | * 2005-2007 Takahiro Hirofuchi |
4 | * Copyright (C) 2015-2016 Samsung Electronics | ||
5 | * Igor Kotrasinski <i.kotrasinsk@samsung.com> | ||
6 | * Krzysztof Opasiak <k.opasiak@samsung.com> | ||
4 | * | 7 | * |
5 | * This program is free software: you can redistribute it and/or modify | 8 | * This program is free software: you can redistribute it and/or modify |
6 | * it under the terms of the GNU General Public License as published by | 9 | * it under the terms of the GNU General Public License as published by |
@@ -22,28 +25,8 @@ | |||
22 | #include <stdint.h> | 25 | #include <stdint.h> |
23 | #include "usbip_common.h" | 26 | #include "usbip_common.h" |
24 | #include "list.h" | 27 | #include "list.h" |
28 | #include "usbip_host_common.h" | ||
25 | 29 | ||
26 | struct usbip_host_driver { | 30 | extern struct usbip_host_driver host_driver; |
27 | int ndevs; | ||
28 | /* list of exported device */ | ||
29 | struct list_head edev_list; | ||
30 | }; | ||
31 | |||
32 | struct usbip_exported_device { | ||
33 | struct udev_device *sudev; | ||
34 | int32_t status; | ||
35 | struct usbip_usb_device udev; | ||
36 | struct list_head node; | ||
37 | struct usbip_usb_interface uinf[]; | ||
38 | }; | ||
39 | |||
40 | extern struct usbip_host_driver *host_driver; | ||
41 | |||
42 | int usbip_host_driver_open(void); | ||
43 | void usbip_host_driver_close(void); | ||
44 | |||
45 | int usbip_host_refresh_device_list(void); | ||
46 | int usbip_host_export_device(struct usbip_exported_device *edev, int sockfd); | ||
47 | struct usbip_exported_device *usbip_host_get_device(int num); | ||
48 | 31 | ||
49 | #endif /* __USBIP_HOST_DRIVER_H */ | 32 | #endif /* __USBIP_HOST_DRIVER_H */ |
diff --git a/tools/usb/usbip/src/usbip_attach.c b/tools/usb/usbip/src/usbip_attach.c index d58a14dfc094..70a6b507fb62 100644 --- a/tools/usb/usbip/src/usbip_attach.c +++ b/tools/usb/usbip/src/usbip_attach.c | |||
@@ -1,6 +1,9 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2011 matt mooney <mfm@muteddisk.com> | 2 | * Copyright (C) 2011 matt mooney <mfm@muteddisk.com> |
3 | * 2005-2007 Takahiro Hirofuchi | 3 | * 2005-2007 Takahiro Hirofuchi |
4 | * Copyright (C) 2015-2016 Samsung Electronics | ||
5 | * Igor Kotrasinski <i.kotrasinsk@samsung.com> | ||
6 | * Krzysztof Opasiak <k.opasiak@samsung.com> | ||
4 | * | 7 | * |
5 | * This program is free software: you can redistribute it and/or modify | 8 | * This program is free software: you can redistribute it and/or modify |
6 | * it under the terms of the GNU General Public License as published by | 9 | * it under the terms of the GNU General Public License as published by |
@@ -36,7 +39,8 @@ | |||
36 | static const char usbip_attach_usage_string[] = | 39 | static const char usbip_attach_usage_string[] = |
37 | "usbip attach <args>\n" | 40 | "usbip attach <args>\n" |
38 | " -r, --remote=<host> The machine with exported USB devices\n" | 41 | " -r, --remote=<host> The machine with exported USB devices\n" |
39 | " -b, --busid=<busid> Busid of the device on <host>\n"; | 42 | " -b, --busid=<busid> Busid of the device on <host>\n" |
43 | " -d, --device=<devid> Id of the virtual UDC on <host>\n"; | ||
40 | 44 | ||
41 | void usbip_attach_usage(void) | 45 | void usbip_attach_usage(void) |
42 | { | 46 | { |
@@ -203,6 +207,7 @@ int usbip_attach(int argc, char *argv[]) | |||
203 | static const struct option opts[] = { | 207 | static const struct option opts[] = { |
204 | { "remote", required_argument, NULL, 'r' }, | 208 | { "remote", required_argument, NULL, 'r' }, |
205 | { "busid", required_argument, NULL, 'b' }, | 209 | { "busid", required_argument, NULL, 'b' }, |
210 | { "device", required_argument, NULL, 'd' }, | ||
206 | { NULL, 0, NULL, 0 } | 211 | { NULL, 0, NULL, 0 } |
207 | }; | 212 | }; |
208 | char *host = NULL; | 213 | char *host = NULL; |
@@ -211,7 +216,7 @@ int usbip_attach(int argc, char *argv[]) | |||
211 | int ret = -1; | 216 | int ret = -1; |
212 | 217 | ||
213 | for (;;) { | 218 | for (;;) { |
214 | opt = getopt_long(argc, argv, "r:b:", opts, NULL); | 219 | opt = getopt_long(argc, argv, "d:r:b:", opts, NULL); |
215 | 220 | ||
216 | if (opt == -1) | 221 | if (opt == -1) |
217 | break; | 222 | break; |
@@ -220,6 +225,7 @@ int usbip_attach(int argc, char *argv[]) | |||
220 | case 'r': | 225 | case 'r': |
221 | host = optarg; | 226 | host = optarg; |
222 | break; | 227 | break; |
228 | case 'd': | ||
223 | case 'b': | 229 | case 'b': |
224 | busid = optarg; | 230 | busid = optarg; |
225 | break; | 231 | break; |
diff --git a/tools/usb/usbip/src/usbip_list.c b/tools/usb/usbip/src/usbip_list.c index d5ce34a410e7..f1b38e866dd7 100644 --- a/tools/usb/usbip/src/usbip_list.c +++ b/tools/usb/usbip/src/usbip_list.c | |||
@@ -1,6 +1,9 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2011 matt mooney <mfm@muteddisk.com> | 2 | * Copyright (C) 2011 matt mooney <mfm@muteddisk.com> |
3 | * 2005-2007 Takahiro Hirofuchi | 3 | * 2005-2007 Takahiro Hirofuchi |
4 | * Copyright (C) 2015-2016 Samsung Electronics | ||
5 | * Igor Kotrasinski <i.kotrasinsk@samsung.com> | ||
6 | * Krzysztof Opasiak <k.opasiak@samsung.com> | ||
4 | * | 7 | * |
5 | * This program is free software: you can redistribute it and/or modify | 8 | * This program is free software: you can redistribute it and/or modify |
6 | * it under the terms of the GNU General Public License as published by | 9 | * it under the terms of the GNU General Public License as published by |
@@ -30,6 +33,10 @@ | |||
30 | #include <netdb.h> | 33 | #include <netdb.h> |
31 | #include <unistd.h> | 34 | #include <unistd.h> |
32 | 35 | ||
36 | #include <dirent.h> | ||
37 | |||
38 | #include <linux/usb/ch9.h> | ||
39 | |||
33 | #include "usbip_common.h" | 40 | #include "usbip_common.h" |
34 | #include "usbip_network.h" | 41 | #include "usbip_network.h" |
35 | #include "usbip.h" | 42 | #include "usbip.h" |
@@ -205,8 +212,10 @@ static int list_devices(bool parsable) | |||
205 | /* Get device information. */ | 212 | /* Get device information. */ |
206 | idVendor = udev_device_get_sysattr_value(dev, "idVendor"); | 213 | idVendor = udev_device_get_sysattr_value(dev, "idVendor"); |
207 | idProduct = udev_device_get_sysattr_value(dev, "idProduct"); | 214 | idProduct = udev_device_get_sysattr_value(dev, "idProduct"); |
208 | bConfValue = udev_device_get_sysattr_value(dev, "bConfigurationValue"); | 215 | bConfValue = udev_device_get_sysattr_value(dev, |
209 | bNumIntfs = udev_device_get_sysattr_value(dev, "bNumInterfaces"); | 216 | "bConfigurationValue"); |
217 | bNumIntfs = udev_device_get_sysattr_value(dev, | ||
218 | "bNumInterfaces"); | ||
210 | busid = udev_device_get_sysname(dev); | 219 | busid = udev_device_get_sysname(dev); |
211 | if (!idVendor || !idProduct || !bConfValue || !bNumIntfs) { | 220 | if (!idVendor || !idProduct || !bConfValue || !bNumIntfs) { |
212 | err("problem getting device attributes: %s", | 221 | err("problem getting device attributes: %s", |
@@ -237,12 +246,90 @@ err_out: | |||
237 | return ret; | 246 | return ret; |
238 | } | 247 | } |
239 | 248 | ||
249 | static int list_gadget_devices(bool parsable) | ||
250 | { | ||
251 | int ret = -1; | ||
252 | struct udev *udev; | ||
253 | struct udev_enumerate *enumerate; | ||
254 | struct udev_list_entry *devices, *dev_list_entry; | ||
255 | struct udev_device *dev; | ||
256 | const char *path; | ||
257 | const char *driver; | ||
258 | |||
259 | const struct usb_device_descriptor *d_desc; | ||
260 | const char *descriptors; | ||
261 | char product_name[128]; | ||
262 | |||
263 | uint16_t idVendor; | ||
264 | char idVendor_buf[8]; | ||
265 | uint16_t idProduct; | ||
266 | char idProduct_buf[8]; | ||
267 | const char *busid; | ||
268 | |||
269 | udev = udev_new(); | ||
270 | enumerate = udev_enumerate_new(udev); | ||
271 | |||
272 | udev_enumerate_add_match_subsystem(enumerate, "platform"); | ||
273 | |||
274 | udev_enumerate_scan_devices(enumerate); | ||
275 | devices = udev_enumerate_get_list_entry(enumerate); | ||
276 | |||
277 | udev_list_entry_foreach(dev_list_entry, devices) { | ||
278 | path = udev_list_entry_get_name(dev_list_entry); | ||
279 | dev = udev_device_new_from_syspath(udev, path); | ||
280 | |||
281 | driver = udev_device_get_driver(dev); | ||
282 | /* We only have mechanism to enumerate gadgets bound to vudc */ | ||
283 | if (driver == NULL || strcmp(driver, USBIP_DEVICE_DRV_NAME)) | ||
284 | continue; | ||
285 | |||
286 | /* Get device information. */ | ||
287 | descriptors = udev_device_get_sysattr_value(dev, | ||
288 | VUDC_DEVICE_DESCR_FILE); | ||
289 | |||
290 | if (!descriptors) { | ||
291 | err("problem getting device attributes: %s", | ||
292 | strerror(errno)); | ||
293 | goto err_out; | ||
294 | } | ||
295 | |||
296 | d_desc = (const struct usb_device_descriptor *) descriptors; | ||
297 | |||
298 | idVendor = le16toh(d_desc->idVendor); | ||
299 | sprintf(idVendor_buf, "0x%4x", idVendor); | ||
300 | idProduct = le16toh(d_desc->idProduct); | ||
301 | sprintf(idProduct_buf, "0x%4x", idVendor); | ||
302 | busid = udev_device_get_sysname(dev); | ||
303 | |||
304 | /* Get product name. */ | ||
305 | usbip_names_get_product(product_name, sizeof(product_name), | ||
306 | le16toh(idVendor), | ||
307 | le16toh(idProduct)); | ||
308 | |||
309 | /* Print information. */ | ||
310 | print_device(busid, idVendor_buf, idProduct_buf, parsable); | ||
311 | print_product_name(product_name, parsable); | ||
312 | |||
313 | printf("\n"); | ||
314 | |||
315 | udev_device_unref(dev); | ||
316 | } | ||
317 | ret = 0; | ||
318 | |||
319 | err_out: | ||
320 | udev_enumerate_unref(enumerate); | ||
321 | udev_unref(udev); | ||
322 | |||
323 | return ret; | ||
324 | } | ||
325 | |||
240 | int usbip_list(int argc, char *argv[]) | 326 | int usbip_list(int argc, char *argv[]) |
241 | { | 327 | { |
242 | static const struct option opts[] = { | 328 | static const struct option opts[] = { |
243 | { "parsable", no_argument, NULL, 'p' }, | 329 | { "parsable", no_argument, NULL, 'p' }, |
244 | { "remote", required_argument, NULL, 'r' }, | 330 | { "remote", required_argument, NULL, 'r' }, |
245 | { "local", no_argument, NULL, 'l' }, | 331 | { "local", no_argument, NULL, 'l' }, |
332 | { "device", no_argument, NULL, 'd' }, | ||
246 | { NULL, 0, NULL, 0 } | 333 | { NULL, 0, NULL, 0 } |
247 | }; | 334 | }; |
248 | 335 | ||
@@ -254,7 +341,7 @@ int usbip_list(int argc, char *argv[]) | |||
254 | err("failed to open %s", USBIDS_FILE); | 341 | err("failed to open %s", USBIDS_FILE); |
255 | 342 | ||
256 | for (;;) { | 343 | for (;;) { |
257 | opt = getopt_long(argc, argv, "pr:l", opts, NULL); | 344 | opt = getopt_long(argc, argv, "pr:ld", opts, NULL); |
258 | 345 | ||
259 | if (opt == -1) | 346 | if (opt == -1) |
260 | break; | 347 | break; |
@@ -269,6 +356,9 @@ int usbip_list(int argc, char *argv[]) | |||
269 | case 'l': | 356 | case 'l': |
270 | ret = list_devices(parsable); | 357 | ret = list_devices(parsable); |
271 | goto out; | 358 | goto out; |
359 | case 'd': | ||
360 | ret = list_gadget_devices(parsable); | ||
361 | goto out; | ||
272 | default: | 362 | default: |
273 | goto err_out; | 363 | goto err_out; |
274 | } | 364 | } |
diff --git a/tools/usb/usbip/src/usbip_port.c b/tools/usb/usbip/src/usbip_port.c index a2e884fd9226..7bd74fb3a9cd 100644 --- a/tools/usb/usbip/src/usbip_port.c +++ b/tools/usb/usbip/src/usbip_port.c | |||
@@ -22,10 +22,13 @@ static int list_imported_devices(void) | |||
22 | struct usbip_imported_device *idev; | 22 | struct usbip_imported_device *idev; |
23 | int ret; | 23 | int ret; |
24 | 24 | ||
25 | if (usbip_names_init(USBIDS_FILE)) | ||
26 | err("failed to open %s", USBIDS_FILE); | ||
27 | |||
25 | ret = usbip_vhci_driver_open(); | 28 | ret = usbip_vhci_driver_open(); |
26 | if (ret < 0) { | 29 | if (ret < 0) { |
27 | err("open vhci_driver"); | 30 | err("open vhci_driver"); |
28 | return -1; | 31 | goto err_names_free; |
29 | } | 32 | } |
30 | 33 | ||
31 | printf("Imported USB devices\n"); | 34 | printf("Imported USB devices\n"); |
@@ -35,13 +38,19 @@ static int list_imported_devices(void) | |||
35 | idev = &vhci_driver->idev[i]; | 38 | idev = &vhci_driver->idev[i]; |
36 | 39 | ||
37 | if (usbip_vhci_imported_device_dump(idev) < 0) | 40 | if (usbip_vhci_imported_device_dump(idev) < 0) |
38 | ret = -1; | 41 | goto err_driver_close; |
39 | } | 42 | } |
40 | 43 | ||
41 | usbip_vhci_driver_close(); | 44 | usbip_vhci_driver_close(); |
45 | usbip_names_free(); | ||
42 | 46 | ||
43 | return ret; | 47 | return ret; |
44 | 48 | ||
49 | err_driver_close: | ||
50 | usbip_vhci_driver_close(); | ||
51 | err_names_free: | ||
52 | usbip_names_free(); | ||
53 | return -1; | ||
45 | } | 54 | } |
46 | 55 | ||
47 | int usbip_port_show(__attribute__((unused)) int argc, | 56 | int usbip_port_show(__attribute__((unused)) int argc, |
diff --git a/tools/usb/usbip/src/usbipd.c b/tools/usb/usbip/src/usbipd.c index 2a7cd2b8d966..a0972dea9e6c 100644 --- a/tools/usb/usbip/src/usbipd.c +++ b/tools/usb/usbip/src/usbipd.c | |||
@@ -1,6 +1,9 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2011 matt mooney <mfm@muteddisk.com> | 2 | * Copyright (C) 2011 matt mooney <mfm@muteddisk.com> |
3 | * 2005-2007 Takahiro Hirofuchi | 3 | * 2005-2007 Takahiro Hirofuchi |
4 | * Copyright (C) 2015-2016 Samsung Electronics | ||
5 | * Igor Kotrasinski <i.kotrasinsk@samsung.com> | ||
6 | * Krzysztof Opasiak <k.opasiak@samsung.com> | ||
4 | * | 7 | * |
5 | * This program is free software: you can redistribute it and/or modify | 8 | * This program is free software: you can redistribute it and/or modify |
6 | * it under the terms of the GNU General Public License as published by | 9 | * it under the terms of the GNU General Public License as published by |
@@ -41,6 +44,8 @@ | |||
41 | #include <poll.h> | 44 | #include <poll.h> |
42 | 45 | ||
43 | #include "usbip_host_driver.h" | 46 | #include "usbip_host_driver.h" |
47 | #include "usbip_host_common.h" | ||
48 | #include "usbip_device_driver.h" | ||
44 | #include "usbip_common.h" | 49 | #include "usbip_common.h" |
45 | #include "usbip_network.h" | 50 | #include "usbip_network.h" |
46 | #include "list.h" | 51 | #include "list.h" |
@@ -64,6 +69,11 @@ static const char usbipd_help_string[] = | |||
64 | " -6, --ipv6\n" | 69 | " -6, --ipv6\n" |
65 | " Bind to IPv6. Default is both.\n" | 70 | " Bind to IPv6. Default is both.\n" |
66 | "\n" | 71 | "\n" |
72 | " -e, --device\n" | ||
73 | " Run in device mode.\n" | ||
74 | " Rather than drive an attached device, create\n" | ||
75 | " a virtual UDC to bind gadgets to.\n" | ||
76 | "\n" | ||
67 | " -D, --daemon\n" | 77 | " -D, --daemon\n" |
68 | " Run as a daemon process.\n" | 78 | " Run as a daemon process.\n" |
69 | "\n" | 79 | "\n" |
@@ -83,6 +93,8 @@ static const char usbipd_help_string[] = | |||
83 | " -v, --version\n" | 93 | " -v, --version\n" |
84 | " Show version.\n"; | 94 | " Show version.\n"; |
85 | 95 | ||
96 | static struct usbip_host_driver *driver; | ||
97 | |||
86 | static void usbipd_help(void) | 98 | static void usbipd_help(void) |
87 | { | 99 | { |
88 | printf("%s\n", usbipd_help_string); | 100 | printf("%s\n", usbipd_help_string); |
@@ -107,7 +119,7 @@ static int recv_request_import(int sockfd) | |||
107 | } | 119 | } |
108 | PACK_OP_IMPORT_REQUEST(0, &req); | 120 | PACK_OP_IMPORT_REQUEST(0, &req); |
109 | 121 | ||
110 | list_for_each(i, &host_driver->edev_list) { | 122 | list_for_each(i, &driver->edev_list) { |
111 | edev = list_entry(i, struct usbip_exported_device, node); | 123 | edev = list_entry(i, struct usbip_exported_device, node); |
112 | if (!strncmp(req.busid, edev->udev.busid, SYSFS_BUS_ID_SIZE)) { | 124 | if (!strncmp(req.busid, edev->udev.busid, SYSFS_BUS_ID_SIZE)) { |
113 | info("found requested device: %s", req.busid); | 125 | info("found requested device: %s", req.busid); |
@@ -121,7 +133,7 @@ static int recv_request_import(int sockfd) | |||
121 | usbip_net_set_nodelay(sockfd); | 133 | usbip_net_set_nodelay(sockfd); |
122 | 134 | ||
123 | /* export device needs a TCP/IP socket descriptor */ | 135 | /* export device needs a TCP/IP socket descriptor */ |
124 | rc = usbip_host_export_device(edev, sockfd); | 136 | rc = usbip_export_device(edev, sockfd); |
125 | if (rc < 0) | 137 | if (rc < 0) |
126 | error = 1; | 138 | error = 1; |
127 | } else { | 139 | } else { |
@@ -166,7 +178,7 @@ static int send_reply_devlist(int connfd) | |||
166 | 178 | ||
167 | reply.ndev = 0; | 179 | reply.ndev = 0; |
168 | /* number of exported devices */ | 180 | /* number of exported devices */ |
169 | list_for_each(j, &host_driver->edev_list) { | 181 | list_for_each(j, &driver->edev_list) { |
170 | reply.ndev += 1; | 182 | reply.ndev += 1; |
171 | } | 183 | } |
172 | info("exportable devices: %d", reply.ndev); | 184 | info("exportable devices: %d", reply.ndev); |
@@ -184,7 +196,7 @@ static int send_reply_devlist(int connfd) | |||
184 | return -1; | 196 | return -1; |
185 | } | 197 | } |
186 | 198 | ||
187 | list_for_each(j, &host_driver->edev_list) { | 199 | list_for_each(j, &driver->edev_list) { |
188 | edev = list_entry(j, struct usbip_exported_device, node); | 200 | edev = list_entry(j, struct usbip_exported_device, node); |
189 | dump_usb_device(&edev->udev); | 201 | dump_usb_device(&edev->udev); |
190 | memcpy(&pdu_udev, &edev->udev, sizeof(pdu_udev)); | 202 | memcpy(&pdu_udev, &edev->udev, sizeof(pdu_udev)); |
@@ -246,7 +258,7 @@ static int recv_pdu(int connfd) | |||
246 | return -1; | 258 | return -1; |
247 | } | 259 | } |
248 | 260 | ||
249 | ret = usbip_host_refresh_device_list(); | 261 | ret = usbip_refresh_device_list(driver); |
250 | if (ret < 0) { | 262 | if (ret < 0) { |
251 | dbg("could not refresh device list: %d", ret); | 263 | dbg("could not refresh device list: %d", ret); |
252 | return -1; | 264 | return -1; |
@@ -491,16 +503,13 @@ static int do_standalone_mode(int daemonize, int ipv4, int ipv6) | |||
491 | struct timespec timeout; | 503 | struct timespec timeout; |
492 | sigset_t sigmask; | 504 | sigset_t sigmask; |
493 | 505 | ||
494 | if (usbip_host_driver_open()) { | 506 | if (usbip_driver_open(driver)) |
495 | err("please load " USBIP_CORE_MOD_NAME ".ko and " | ||
496 | USBIP_HOST_DRV_NAME ".ko!"); | ||
497 | return -1; | 507 | return -1; |
498 | } | ||
499 | 508 | ||
500 | if (daemonize) { | 509 | if (daemonize) { |
501 | if (daemon(0, 0) < 0) { | 510 | if (daemon(0, 0) < 0) { |
502 | err("daemonizing failed: %s", strerror(errno)); | 511 | err("daemonizing failed: %s", strerror(errno)); |
503 | usbip_host_driver_close(); | 512 | usbip_driver_close(driver); |
504 | return -1; | 513 | return -1; |
505 | } | 514 | } |
506 | umask(0); | 515 | umask(0); |
@@ -525,7 +534,7 @@ static int do_standalone_mode(int daemonize, int ipv4, int ipv6) | |||
525 | 534 | ||
526 | ai_head = do_getaddrinfo(NULL, family); | 535 | ai_head = do_getaddrinfo(NULL, family); |
527 | if (!ai_head) { | 536 | if (!ai_head) { |
528 | usbip_host_driver_close(); | 537 | usbip_driver_close(driver); |
529 | return -1; | 538 | return -1; |
530 | } | 539 | } |
531 | nsockfd = listen_all_addrinfo(ai_head, sockfdlist, | 540 | nsockfd = listen_all_addrinfo(ai_head, sockfdlist, |
@@ -533,7 +542,7 @@ static int do_standalone_mode(int daemonize, int ipv4, int ipv6) | |||
533 | freeaddrinfo(ai_head); | 542 | freeaddrinfo(ai_head); |
534 | if (nsockfd <= 0) { | 543 | if (nsockfd <= 0) { |
535 | err("failed to open a listening socket"); | 544 | err("failed to open a listening socket"); |
536 | usbip_host_driver_close(); | 545 | usbip_driver_close(driver); |
537 | return -1; | 546 | return -1; |
538 | } | 547 | } |
539 | 548 | ||
@@ -574,7 +583,7 @@ static int do_standalone_mode(int daemonize, int ipv4, int ipv6) | |||
574 | 583 | ||
575 | info("shutting down " PROGNAME); | 584 | info("shutting down " PROGNAME); |
576 | free(fds); | 585 | free(fds); |
577 | usbip_host_driver_close(); | 586 | usbip_driver_close(driver); |
578 | 587 | ||
579 | return 0; | 588 | return 0; |
580 | } | 589 | } |
@@ -587,6 +596,7 @@ int main(int argc, char *argv[]) | |||
587 | { "daemon", no_argument, NULL, 'D' }, | 596 | { "daemon", no_argument, NULL, 'D' }, |
588 | { "daemon", no_argument, NULL, 'D' }, | 597 | { "daemon", no_argument, NULL, 'D' }, |
589 | { "debug", no_argument, NULL, 'd' }, | 598 | { "debug", no_argument, NULL, 'd' }, |
599 | { "device", no_argument, NULL, 'e' }, | ||
590 | { "pid", optional_argument, NULL, 'P' }, | 600 | { "pid", optional_argument, NULL, 'P' }, |
591 | { "tcp-port", required_argument, NULL, 't' }, | 601 | { "tcp-port", required_argument, NULL, 't' }, |
592 | { "help", no_argument, NULL, 'h' }, | 602 | { "help", no_argument, NULL, 'h' }, |
@@ -613,8 +623,9 @@ int main(int argc, char *argv[]) | |||
613 | err("not running as root?"); | 623 | err("not running as root?"); |
614 | 624 | ||
615 | cmd = cmd_standalone_mode; | 625 | cmd = cmd_standalone_mode; |
626 | driver = &host_driver; | ||
616 | for (;;) { | 627 | for (;;) { |
617 | opt = getopt_long(argc, argv, "46DdP::t:hv", longopts, NULL); | 628 | opt = getopt_long(argc, argv, "46DdeP::t:hv", longopts, NULL); |
618 | 629 | ||
619 | if (opt == -1) | 630 | if (opt == -1) |
620 | break; | 631 | break; |
@@ -644,6 +655,9 @@ int main(int argc, char *argv[]) | |||
644 | case 'v': | 655 | case 'v': |
645 | cmd = cmd_version; | 656 | cmd = cmd_version; |
646 | break; | 657 | break; |
658 | case 'e': | ||
659 | driver = &device_driver; | ||
660 | break; | ||
647 | case '?': | 661 | case '?': |
648 | usbipd_help(); | 662 | usbipd_help(); |
649 | default: | 663 | default: |