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

Merge tag 'usb-for-v5.8' of git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb into usb-next

Felipe writes:

USB: changes for v5.8 merge window

Rather busy cycle. We have a total 99 non-merge commits going into v5.8
merge window. The majority of the changes are in dwc3 this around (31.7%
of all changes). It's composed mostly Thinh's recent updates to get dwc3
to behave correctly with stream transfers. We have also have Roger's for
Keystone platforms and Neil's updates for the meson glue layer.

Apart from those, we have the usual set of non-critical fixes, new
device IDs, spelling fixes all over the place.

Signed-off-by: Felipe Balbi <balbi@kernel.org>

* tag 'usb-for-v5.8' of git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb: (99 commits)
usb: dwc3: keystone: Turn on USB3 PHY before controller
dt-bindings: usb: ti,keystone-dwc3.yaml: Add USB3.0 PHY property
dt-bindings: usb: convert keystone-usb.txt to YAML
usb: dwc3: gadget: Check for prepared TRBs
usb: gadget: Fix issue with config_ep_by_speed function
usb: cdns3: ep0: delete the redundant status stage
usb: dwc2: Update Core Reset programming flow.
usb: gadget: fsl: Fix a wrong judgment in fsl_udc_probe()
usb: gadget: fix potential double-free in m66592_probe.
usb: cdns3: Fix runtime PM imbalance on error
usb: gadget: lpc32xx_udc: don't dereference ep pointer before null check
usb: dwc3: Increase timeout for CmdAct cleared by device controller
USB: dummy-hcd: use configurable endpoint naming scheme
usb: cdns3: gadget: assign interrupt number to USB gadget structure
usb: gadget: core: sync interrupt before unbind the udc
arm64: dts: qcom: sc7180: Add interconnect properties for USB
arm64: dts: qcom: sdm845: Add interconnect properties for USB
dt-bindings: usb: qcom,dwc3: Introduce interconnect properties for Qualcomm DWC3 driver
ARM: dts: at91: Remove the USB EP child node
dt-bindings: usb: atmel: Mark EP child node as deprecated
...

+2107 -1700
-31
Documentation/devicetree/bindings/phy/meson-gxl-usb3-phy.txt
··· 1 - * Amlogic Meson GXL and GXM USB3 PHY and OTG detection binding 2 - 3 - Required properties: 4 - - compatible: Should be "amlogic,meson-gxl-usb3-phy" 5 - - #phys-cells: must be 0 (see phy-bindings.txt in this directory) 6 - - reg: The base address and length of the registers 7 - - interrupts: the interrupt specifier for the OTG detection 8 - - clocks: phandles to the clocks for 9 - - the USB3 PHY 10 - - and peripheral mode/OTG detection 11 - - clock-names: must contain "phy" and "peripheral" 12 - - resets: phandle to the reset lines for: 13 - - the USB3 PHY and 14 - - peripheral mode/OTG detection 15 - - reset-names: must contain "phy" and "peripheral" 16 - 17 - Optional properties: 18 - - phy-supply: see phy-bindings.txt in this directory 19 - 20 - 21 - Example: 22 - usb3_phy0: phy@78080 { 23 - compatible = "amlogic,meson-gxl-usb3-phy"; 24 - #phy-cells = <0>; 25 - reg = <0x0 0x78080 0x0 0x20>; 26 - interrupts = <GIC_SPI 16 IRQ_TYPE_LEVEL_HIGH>; 27 - clocks = <&clkc CLKID_USB_OTG>, <&clkc_AO CLKID_AO_CEC_32K>; 28 - clock-names = "phy", "peripheral"; 29 - resets = <&reset RESET_USB_OTG>, <&reset RESET_USB_OTG>; 30 - reset-names = "phy", "peripheral"; 31 - };
-42
Documentation/devicetree/bindings/usb/amlogic,dwc3.txt
··· 1 - Amlogic Meson GX DWC3 USB SoC controller 2 - 3 - Required properties: 4 - - compatible: depending on the SoC this should contain one of: 5 - * amlogic,meson-axg-dwc3 6 - * amlogic,meson-gxl-dwc3 7 - - clocks: a handle for the "USB general" clock 8 - - clock-names: must be "usb_general" 9 - - resets: a handle for the shared "USB OTG" reset line 10 - - reset-names: must be "usb_otg" 11 - 12 - Required child node: 13 - A child node must exist to represent the core DWC3 IP block. The name of 14 - the node is not important. The content of the node is defined in dwc3.txt. 15 - 16 - PHY documentation is provided in the following places: 17 - - Documentation/devicetree/bindings/phy/meson-gxl-usb2-phy.txt 18 - - Documentation/devicetree/bindings/phy/meson-gxl-usb3-phy.txt 19 - 20 - Example device nodes: 21 - usb0: usb@ff500000 { 22 - compatible = "amlogic,meson-axg-dwc3"; 23 - #address-cells = <2>; 24 - #size-cells = <2>; 25 - ranges; 26 - 27 - clocks = <&clkc CLKID_USB>; 28 - clock-names = "usb_general"; 29 - resets = <&reset RESET_USB_OTG>; 30 - reset-names = "usb_otg"; 31 - 32 - dwc3: dwc3@ff500000 { 33 - compatible = "snps,dwc3"; 34 - reg = <0x0 0xff500000 0x0 0x100000>; 35 - interrupts = <GIC_SPI 30 IRQ_TYPE_LEVEL_HIGH>; 36 - dr_mode = "host"; 37 - maximum-speed = "high-speed"; 38 - snps,dis_u2_susphy_quirk; 39 - phys = <&usb3_phy>, <&usb2_phy0>; 40 - phy-names = "usb2-phy", "usb3-phy"; 41 - }; 42 - };
+69 -4
Documentation/devicetree/bindings/usb/amlogic,meson-g12a-usb-ctrl.yaml
··· 25 25 The Amlogic A1 embeds a DWC3 USB IP Core configured for USB2 in 26 26 host-only mode. 27 27 28 + The Amlogic GXL & GXM SoCs doesn't embed an USB3 PHY. 29 + 28 30 properties: 29 31 compatible: 30 32 enum: 33 + - amlogic,meson-gxl-usb-ctrl 34 + - amlogic,meson-gxm-usb-ctrl 31 35 - amlogic,meson-g12a-usb-ctrl 32 36 - amlogic,meson-a1-usb-ctrl 33 37 ··· 45 41 46 42 clocks: 47 43 minItems: 1 44 + maxItems: 3 45 + 46 + clock-names: 47 + minItems: 1 48 + maxItems: 3 48 49 49 50 resets: 50 51 minItems: 1 ··· 61 52 maxItems: 1 62 53 63 54 phy-names: 64 - items: 65 - - const: usb2-phy0 # USB2 PHY0 if USBHOST_A port is used 66 - - const: usb2-phy1 # USB2 PHY1 if USBOTG_B port is used 67 - - const: usb3-phy0 # USB3 PHY if USB3_0 is used 55 + minItems: 1 56 + maxItems: 3 68 57 69 58 phys: 70 59 minItems: 1 ··· 100 93 properties: 101 94 compatible: 102 95 enum: 96 + - amlogic,meson-g12a-usb-ctrl 97 + 98 + then: 99 + properties: 100 + phy-names: 101 + items: 102 + - const: usb2-phy0 # USB2 PHY0 if USBHOST_A port is used 103 + - const: usb2-phy1 # USB2 PHY1 if USBOTG_B port is used 104 + - const: usb3-phy0 # USB3 PHY if USB3_0 is used 105 + - if: 106 + properties: 107 + compatible: 108 + enum: 109 + - amlogic,meson-gxl-usb-ctrl 110 + 111 + then: 112 + properties: 113 + clocks: 114 + minItems: 2 115 + clock-names: 116 + items: 117 + - const: usb_ctrl 118 + - const: ddr 119 + phy-names: 120 + items: 121 + - const: usb2-phy0 # USB2 PHY0 if USBHOST_A port is used 122 + - const: usb2-phy1 # USB2 PHY1 if USBOTG_B port is used 123 + required: 124 + - clock-names 125 + - if: 126 + properties: 127 + compatible: 128 + enum: 129 + - amlogic,meson-gxm-usb-ctrl 130 + 131 + then: 132 + properties: 133 + clocks: 134 + minItems: 2 135 + clock-names: 136 + items: 137 + - const: usb_ctrl 138 + - const: ddr 139 + phy-names: 140 + items: 141 + - const: usb2-phy0 # USB2 PHY0 if USBHOST_A port is used 142 + - const: usb2-phy1 # USB2 PHY1 if USBOTG_B port is used 143 + - const: usb2-phy2 # USB2 PHY2 if USBOTG_C port is used 144 + 145 + required: 146 + - clock-names 147 + - if: 148 + properties: 149 + compatible: 150 + enum: 103 151 - amlogic,meson-a1-usb-ctrl 104 152 105 153 then: 106 154 properties: 155 + phy-names: 156 + items: 157 + - const: usb2-phy1 # USB2 PHY1 if USBOTG_B port is used 107 158 clocks: 108 159 minItems: 3 109 160 clock-names:
+68
Documentation/devicetree/bindings/usb/aspeed,usb-vhub.yaml
··· 52 52 minimum: 1 53 53 maximum: 21 54 54 55 + vhub-vendor-id: 56 + description: vhub Vendor ID 57 + allOf: 58 + - $ref: /schemas/types.yaml#/definitions/uint32 59 + - maximum: 65535 60 + 61 + vhub-product-id: 62 + description: vhub Product ID 63 + allOf: 64 + - $ref: /schemas/types.yaml#/definitions/uint32 65 + - maximum: 65535 66 + 67 + vhub-device-revision: 68 + description: vhub Device Revision in binary-coded decimal 69 + allOf: 70 + - $ref: /schemas/types.yaml#/definitions/uint32 71 + - maximum: 65535 72 + 73 + vhub-strings: 74 + type: object 75 + 76 + properties: 77 + '#address-cells': 78 + const: 1 79 + 80 + '#size-cells': 81 + const: 0 82 + 83 + patternProperties: 84 + '^string@[0-9a-f]+$': 85 + type: object 86 + description: string descriptors of the specific language 87 + 88 + properties: 89 + reg: 90 + maxItems: 1 91 + description: 16-bit Language Identifier defined by USB-IF 92 + 93 + manufacturer: 94 + description: vhub manufacturer 95 + allOf: 96 + - $ref: /schemas/types.yaml#/definitions/string 97 + 98 + product: 99 + description: vhub product name 100 + allOf: 101 + - $ref: /schemas/types.yaml#/definitions/string 102 + 103 + serial-number: 104 + description: vhub device serial number 105 + allOf: 106 + - $ref: /schemas/types.yaml#/definitions/string 107 + 55 108 required: 56 109 - compatible 57 110 - reg ··· 127 74 aspeed,vhub-generic-endpoints = <15>; 128 75 pinctrl-names = "default"; 129 76 pinctrl-0 = <&pinctrl_usb2ad_default>; 77 + 78 + vhub-vendor-id = <0x1d6b>; 79 + vhub-product-id = <0x0107>; 80 + vhub-device-revision = <0x0100>; 81 + vhub-strings { 82 + #address-cells = <1>; 83 + #size-cells = <0>; 84 + 85 + string@0409 { 86 + reg = <0x0409>; 87 + manufacturer = "ASPEED"; 88 + product = "USB Virtual Hub"; 89 + serial-number = "0000"; 90 + }; 91 + }; 130 92 };
+3 -53
Documentation/devicetree/bindings/usb/atmel-usb.txt
··· 88 88 - clock-names: Should contain two strings 89 89 "pclk" for the peripheral clock 90 90 "hclk" for the host clock 91 + 92 + Deprecated property: 91 93 - ep childnode: To specify the number of endpoints and their properties. 92 94 93 95 Optional properties: 94 96 - atmel,vbus-gpio: If present, specifies a gpio that allows to detect whether 95 97 vbus is present (USB is connected). 96 98 97 - Required child node properties: 99 + Deprecated child node properties: 98 100 - name: Name of the endpoint. 99 101 - reg: Num of the endpoint. 100 102 - atmel,fifo-size: Size of the fifo. ··· 114 112 clocks = <&utmi>, <&udphs_clk>; 115 113 clock-names = "hclk", "pclk"; 116 114 atmel,vbus-gpio = <&pioB 19 0>; 117 - 118 - ep@0 { 119 - reg = <0>; 120 - atmel,fifo-size = <64>; 121 - atmel,nb-banks = <1>; 122 - }; 123 - 124 - ep@1 { 125 - reg = <1>; 126 - atmel,fifo-size = <1024>; 127 - atmel,nb-banks = <2>; 128 - atmel,can-dma; 129 - atmel,can-isoc; 130 - }; 131 - 132 - ep@2 { 133 - reg = <2>; 134 - atmel,fifo-size = <1024>; 135 - atmel,nb-banks = <2>; 136 - atmel,can-dma; 137 - atmel,can-isoc; 138 - }; 139 - 140 - ep@3 { 141 - reg = <3>; 142 - atmel,fifo-size = <1024>; 143 - atmel,nb-banks = <3>; 144 - atmel,can-dma; 145 - }; 146 - 147 - ep@4 { 148 - reg = <4>; 149 - atmel,fifo-size = <1024>; 150 - atmel,nb-banks = <3>; 151 - atmel,can-dma; 152 - }; 153 - 154 - ep@5 { 155 - reg = <5>; 156 - atmel,fifo-size = <1024>; 157 - atmel,nb-banks = <3>; 158 - atmel,can-dma; 159 - atmel,can-isoc; 160 - }; 161 - 162 - ep@6 { 163 - reg = <6>; 164 - atmel,fifo-size = <1024>; 165 - atmel,nb-banks = <3>; 166 - atmel,can-dma; 167 - atmel,can-isoc; 168 - }; 169 115 };
-2
Documentation/devicetree/bindings/usb/dwc3.txt
··· 15 15 Exception for clocks: 16 16 clocks are optional if the parent node (i.e. glue-layer) is compatible to 17 17 one of the following: 18 - "amlogic,meson-axg-dwc3" 19 - "amlogic,meson-gxl-dwc3" 20 18 "cavium,octeon-7130-usb-uctl" 21 19 "qcom,dwc3" 22 20 "samsung,exynos5250-dwusb3"
-56
Documentation/devicetree/bindings/usb/keystone-usb.txt
··· 1 - TI Keystone Soc USB Controller 2 - 3 - DWC3 GLUE 4 - 5 - Required properties: 6 - - compatible: should be 7 - "ti,keystone-dwc3" for Keystone 2 SoCs 8 - "ti,am654-dwc3" for AM654 SoC 9 - - #address-cells, #size-cells : should be '1' if the device has sub-nodes 10 - with 'reg' property. 11 - - reg : Address and length of the register set for the USB subsystem on 12 - the SOC. 13 - - interrupts : The irq number of this device that is used to interrupt the 14 - MPU. 15 - - ranges: allows valid 1:1 translation between child's address space and 16 - parent's address space. 17 - 18 - SoC-specific Required Properties: 19 - The following are mandatory properties for Keystone 2 66AK2HK, 66AK2L and 66AK2E 20 - SoCs only: 21 - 22 - - clocks: Clock ID for USB functional clock. 23 - - clock-names: Must be "usb". 24 - 25 - 26 - The following are mandatory properties for 66AK2G and AM654: 27 - 28 - - power-domains: Should contain a phandle to a PM domain provider node 29 - and an args specifier containing the USB device id 30 - value. This property is as per the binding, 31 - Documentation/devicetree/bindings/soc/ti/sci-pm-domain.txt 32 - 33 - Sub-nodes: 34 - The dwc3 core should be added as subnode to Keystone DWC3 glue. 35 - - dwc3 : 36 - The binding details of dwc3 can be found in: 37 - Documentation/devicetree/bindings/usb/dwc3.txt 38 - 39 - Example: 40 - usb: usb@2680000 { 41 - compatible = "ti,keystone-dwc3"; 42 - #address-cells = <1>; 43 - #size-cells = <1>; 44 - reg = <0x2680000 0x10000>; 45 - clocks = <&clkusb>; 46 - clock-names = "usb"; 47 - interrupts = <GIC_SPI 393 IRQ_TYPE_EDGE_RISING>; 48 - ranges; 49 - 50 - dwc3@2690000 { 51 - compatible = "synopsys,dwc3"; 52 - reg = <0x2690000 0x70000>; 53 - interrupts = <GIC_SPI 393 IRQ_TYPE_EDGE_RISING>; 54 - usb-phy = <&usb_phy>, <&usb_phy>; 55 - }; 56 - };
+2
Documentation/devicetree/bindings/usb/nvidia,tegra-xudc.yaml
··· 21 21 - enum: 22 22 - nvidia,tegra210-xudc # For Tegra210 23 23 - nvidia,tegra186-xudc # For Tegra186 24 + - nvidia,tegra194-xudc # For Tegra194 24 25 25 26 reg: 26 27 minItems: 2 ··· 145 144 contains: 146 145 enum: 147 146 - nvidia,tegra186-xudc 147 + - nvidia,tegra194-xudc 148 148 then: 149 149 properties: 150 150 reg:
-104
Documentation/devicetree/bindings/usb/qcom,dwc3.txt
··· 1 - Qualcomm SuperSpeed DWC3 USB SoC controller 2 - 3 - Required properties: 4 - - compatible: Compatible list, contains 5 - "qcom,dwc3" 6 - "qcom,msm8996-dwc3" for msm8996 SOC. 7 - "qcom,msm8998-dwc3" for msm8998 SOC. 8 - "qcom,sdm845-dwc3" for sdm845 SOC. 9 - - reg: Offset and length of register set for QSCRATCH wrapper 10 - - power-domains: specifies a phandle to PM domain provider node 11 - - clocks: A list of phandle + clock-specifier pairs for the 12 - clocks listed in clock-names 13 - - clock-names: Should contain the following: 14 - "core" Master/Core clock, have to be >= 125 MHz for SS 15 - operation and >= 60MHz for HS operation 16 - "mock_utmi" Mock utmi clock needed for ITP/SOF generation in 17 - host mode. Its frequency should be 19.2MHz. 18 - "sleep" Sleep clock, used for wakeup when USB3 core goes 19 - into low power mode (U3). 20 - 21 - Optional clocks: 22 - "iface" System bus AXI clock. 23 - Not present on "qcom,msm8996-dwc3" compatible. 24 - "cfg_noc" System Config NOC clock. 25 - Not present on "qcom,msm8996-dwc3" compatible. 26 - - assigned-clocks: Should be: 27 - MOCK_UTMI_CLK 28 - MASTER_CLK 29 - - assigned-clock-rates: Should be: 30 - 19.2Mhz (192000000) for MOCK_UTMI_CLK 31 - >=125Mhz (125000000) for MASTER_CLK in SS mode 32 - >=60Mhz (60000000) for MASTER_CLK in HS mode 33 - 34 - Optional properties: 35 - - resets: Phandle to reset control that resets core and wrapper. 36 - - interrupts: specifies interrupts from controller wrapper used 37 - to wakeup from low power/susepnd state. Must contain 38 - one or more entry for interrupt-names property 39 - - interrupt-names: Must include the following entries: 40 - - "hs_phy_irq": The interrupt that is asserted when a 41 - wakeup event is received on USB2 bus 42 - - "ss_phy_irq": The interrupt that is asserted when a 43 - wakeup event is received on USB3 bus 44 - - "dm_hs_phy_irq" and "dp_hs_phy_irq": Separate 45 - interrupts for any wakeup event on DM and DP lines 46 - - qcom,select-utmi-as-pipe-clk: if present, disable USB3 pipe_clk requirement. 47 - Used when dwc3 operates without SSPHY and only 48 - HS/FS/LS modes are supported. 49 - 50 - Required child node: 51 - A child node must exist to represent the core DWC3 IP block. The name of 52 - the node is not important. The content of the node is defined in dwc3.txt. 53 - 54 - Phy documentation is provided in the following places: 55 - Documentation/devicetree/bindings/phy/qcom-qmp-phy.txt - USB3 QMP PHY 56 - Documentation/devicetree/bindings/phy/qcom,qusb2-phy.yaml - USB2 QUSB2 PHY 57 - 58 - Example device nodes: 59 - 60 - hs_phy: phy@100f8800 { 61 - compatible = "qcom,qusb2-v2-phy"; 62 - ... 63 - }; 64 - 65 - ss_phy: phy@100f8830 { 66 - compatible = "qcom,qmp-v3-usb3-phy"; 67 - ... 68 - }; 69 - 70 - usb3_0: usb30@a6f8800 { 71 - compatible = "qcom,dwc3"; 72 - reg = <0xa6f8800 0x400>; 73 - #address-cells = <1>; 74 - #size-cells = <1>; 75 - ranges; 76 - 77 - interrupts = <0 131 0>, <0 486 0>, <0 488 0>, <0 489 0>; 78 - interrupt-names = "hs_phy_irq", "ss_phy_irq", 79 - "dm_hs_phy_irq", "dp_hs_phy_irq"; 80 - 81 - clocks = <&gcc GCC_USB30_PRIM_MASTER_CLK>, 82 - <&gcc GCC_USB30_PRIM_MOCK_UTMI_CLK>, 83 - <&gcc GCC_USB30_PRIM_SLEEP_CLK>; 84 - clock-names = "core", "mock_utmi", "sleep"; 85 - 86 - assigned-clocks = <&gcc GCC_USB30_PRIM_MOCK_UTMI_CLK>, 87 - <&gcc GCC_USB30_PRIM_MASTER_CLK>; 88 - assigned-clock-rates = <19200000>, <133000000>; 89 - 90 - resets = <&gcc GCC_USB30_PRIM_BCR>; 91 - reset-names = "core_reset"; 92 - power-domains = <&gcc USB30_PRIM_GDSC>; 93 - qcom,select-utmi-as-pipe-clk; 94 - 95 - dwc3@10000000 { 96 - compatible = "snps,dwc3"; 97 - reg = <0x10000000 0xcd00>; 98 - interrupts = <0 205 0x4>; 99 - phys = <&hs_phy>, <&ss_phy>; 100 - phy-names = "usb2-phy", "usb3-phy"; 101 - dr_mode = "host"; 102 - }; 103 - }; 104 -
+167
Documentation/devicetree/bindings/usb/qcom,dwc3.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) 2 + 3 + %YAML 1.2 4 + --- 5 + $id: http://devicetree.org/schemas/usb/qcom,dwc3.yaml# 6 + $schema: http://devicetree.org/meta-schemas/core.yaml# 7 + 8 + title: Qualcomm SuperSpeed DWC3 USB SoC controller 9 + 10 + maintainers: 11 + - Manu Gautam <mgautam@codeaurora.org> 12 + 13 + properties: 14 + compatible: 15 + items: 16 + - enum: 17 + - qcom,msm8996-dwc3 18 + - qcom,msm8998-dwc3 19 + - qcom,sc7180-dwc3 20 + - qcom,sdm845-dwc3 21 + - const: qcom,dwc3 22 + 23 + reg: 24 + description: Offset and length of register set for QSCRATCH wrapper 25 + maxItems: 1 26 + 27 + "#address-cells": 28 + enum: [ 1, 2 ] 29 + 30 + "#size-cells": 31 + enum: [ 1, 2 ] 32 + 33 + power-domains: 34 + description: specifies a phandle to PM domain provider node 35 + maxItems: 1 36 + 37 + clocks: 38 + description: 39 + A list of phandle and clock-specifier pairs for the clocks 40 + listed in clock-names. 41 + items: 42 + - description: System Config NOC clock. 43 + - description: Master/Core clock, has to be >= 125 MHz 44 + for SS operation and >= 60MHz for HS operation. 45 + - description: System bus AXI clock. 46 + - description: Mock utmi clock needed for ITP/SOF generation 47 + in host mode. Its frequency should be 19.2MHz. 48 + - description: Sleep clock, used for wakeup when 49 + USB3 core goes into low power mode (U3). 50 + 51 + clock-names: 52 + items: 53 + - const: cfg_noc 54 + - const: core 55 + - const: iface 56 + - const: mock_utmi 57 + - const: sleep 58 + 59 + assigned-clocks: 60 + items: 61 + - description: Phandle and clock specifier of MOCK_UTMI_CLK. 62 + - description: Phandle and clock specifoer of MASTER_CLK. 63 + 64 + assigned-clock-rates: 65 + maxItems: 2 66 + items: 67 + - description: Must be 19.2MHz (19200000). 68 + - description: Must be >= 60 MHz in HS mode, >= 125 MHz in SS mode. 69 + 70 + resets: 71 + maxItems: 1 72 + 73 + interconnects: 74 + maxItems: 2 75 + 76 + interconnect-names: 77 + items: 78 + - const: usb-ddr 79 + - const: apps-usb 80 + 81 + interrupts: 82 + items: 83 + - description: The interrupt that is asserted 84 + when a wakeup event is received on USB2 bus. 85 + - description: The interrupt that is asserted 86 + when a wakeup event is received on USB3 bus. 87 + - description: Wakeup event on DM line. 88 + - description: Wakeup event on DP line. 89 + 90 + interrupt-names: 91 + items: 92 + - const: hs_phy_irq 93 + - const: ss_phy_irq 94 + - const: dm_hs_phy_irq 95 + - const: dp_hs_phy_irq 96 + 97 + qcom,select-utmi-as-pipe-clk: 98 + description: 99 + If present, disable USB3 pipe_clk requirement. 100 + Used when dwc3 operates without SSPHY and only 101 + HS/FS/LS modes are supported. 102 + type: boolean 103 + 104 + # Required child node: 105 + 106 + patternProperties: 107 + "^dwc3@[0-9a-f]+$": 108 + type: object 109 + description: 110 + A child node must exist to represent the core DWC3 IP block 111 + The content of the node is defined in dwc3.txt. 112 + 113 + required: 114 + - compatible 115 + - reg 116 + - "#address-cells" 117 + - "#size-cells" 118 + - power-domains 119 + - clocks 120 + - clock-names 121 + 122 + examples: 123 + - | 124 + #include <dt-bindings/clock/qcom,gcc-sdm845.h> 125 + #include <dt-bindings/interrupt-controller/arm-gic.h> 126 + #include <dt-bindings/interrupt-controller/irq.h> 127 + usb@a6f8800 { 128 + compatible = "qcom,sdm845-dwc3", "qcom,dwc3"; 129 + reg = <0 0x0a6f8800 0 0x400>; 130 + 131 + #address-cells = <2>; 132 + #size-cells = <2>; 133 + 134 + clocks = <&gcc GCC_CFG_NOC_USB3_PRIM_AXI_CLK>, 135 + <&gcc GCC_USB30_PRIM_MASTER_CLK>, 136 + <&gcc GCC_AGGRE_USB3_PRIM_AXI_CLK>, 137 + <&gcc GCC_USB30_PRIM_MOCK_UTMI_CLK>, 138 + <&gcc GCC_USB30_PRIM_SLEEP_CLK>; 139 + clock-names = "cfg_noc", "core", "iface", "mock_utmi", 140 + "sleep"; 141 + 142 + assigned-clocks = <&gcc GCC_USB30_PRIM_MOCK_UTMI_CLK>, 143 + <&gcc GCC_USB30_PRIM_MASTER_CLK>; 144 + assigned-clock-rates = <19200000>, <150000000>; 145 + 146 + interrupts = <GIC_SPI 131 IRQ_TYPE_LEVEL_HIGH>, 147 + <GIC_SPI 486 IRQ_TYPE_LEVEL_HIGH>, 148 + <GIC_SPI 488 IRQ_TYPE_LEVEL_HIGH>, 149 + <GIC_SPI 489 IRQ_TYPE_LEVEL_HIGH>; 150 + interrupt-names = "hs_phy_irq", "ss_phy_irq", 151 + "dm_hs_phy_irq", "dp_hs_phy_irq"; 152 + 153 + power-domains = <&gcc USB30_PRIM_GDSC>; 154 + 155 + resets = <&gcc GCC_USB30_PRIM_BCR>; 156 + 157 + dwc3@a600000 { 158 + compatible = "snps,dwc3"; 159 + reg = <0 0x0a600000 0 0xcd00>; 160 + interrupts = <GIC_SPI 133 IRQ_TYPE_LEVEL_HIGH>; 161 + iommus = <&apps_smmu 0x740 0>; 162 + snps,dis_u2_susphy_quirk; 163 + snps,dis_enblslpm_quirk; 164 + phys = <&usb_1_hsphy>, <&usb_1_ssphy>; 165 + phy-names = "usb2-phy", "usb3-phy"; 166 + }; 167 + };
+77
Documentation/devicetree/bindings/usb/ti,keystone-dwc3.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/usb/ti,keystone-dwc3.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: TI Keystone Soc USB Controller 8 + 9 + maintainers: 10 + - Roger Quadros <rogerq@ti.com> 11 + 12 + properties: 13 + compatible: 14 + oneOf: 15 + - const: "ti,keystone-dwc3" 16 + - const: "ti,am654-dwc3" 17 + 18 + reg: 19 + maxItems: 1 20 + description: Address and length of the register set for the USB subsystem on 21 + the SOC. 22 + 23 + interrupts: 24 + maxItems: 1 25 + description: The irq number of this device that is used to interrupt the MPU. 26 + 27 + 28 + clocks: 29 + description: Clock ID for USB functional clock. 30 + 31 + power-domains: 32 + description: Should contain a phandle to a PM domain provider node 33 + and an args specifier containing the USB device id 34 + value. This property is as per the binding, 35 + Documentation/devicetree/bindings/soc/ti/sci-pm-domain.txt 36 + 37 + phys: 38 + description: 39 + PHY specifier for the USB3.0 PHY. Some SoCs need the USB3.0 PHY 40 + to be turned on before the controller. 41 + Documentation/devicetree/bindings/phy/phy-bindings.txt 42 + 43 + phy-names: 44 + items: 45 + - const: "usb3-phy" 46 + 47 + dwc3: 48 + description: This is the node representing the DWC3 controller instance 49 + Documentation/devicetree/bindings/usb/dwc3.txt 50 + 51 + required: 52 + - compatible 53 + - reg 54 + - interrupts 55 + - clocks 56 + 57 + examples: 58 + - | 59 + #include <dt-bindings/interrupt-controller/arm-gic.h> 60 + 61 + usb: usb@2680000 { 62 + compatible = "ti,keystone-dwc3"; 63 + #address-cells = <1>; 64 + #size-cells = <1>; 65 + reg = <0x2680000 0x10000>; 66 + clocks = <&clkusb>; 67 + clock-names = "usb"; 68 + interrupts = <GIC_SPI 393 IRQ_TYPE_EDGE_RISING>; 69 + ranges; 70 + 71 + dwc3@2690000 { 72 + compatible = "synopsys,dwc3"; 73 + reg = <0x2690000 0x70000>; 74 + interrupts = <GIC_SPI 393 IRQ_TYPE_EDGE_RISING>; 75 + usb-phy = <&usb_phy>, <&usb_phy>; 76 + }; 77 + };
-54
arch/arm/boot/dts/at91sam9g45.dtsi
··· 1195 1195 }; 1196 1196 1197 1197 usb2: gadget@fff78000 { 1198 - #address-cells = <1>; 1199 - #size-cells = <0>; 1200 1198 compatible = "atmel,at91sam9g45-udc"; 1201 1199 reg = <0x00600000 0x80000 1202 1200 0xfff78000 0x400>; ··· 1202 1204 clocks = <&udphs_clk>, <&utmi>; 1203 1205 clock-names = "pclk", "hclk"; 1204 1206 status = "disabled"; 1205 - 1206 - ep@0 { 1207 - reg = <0>; 1208 - atmel,fifo-size = <64>; 1209 - atmel,nb-banks = <1>; 1210 - }; 1211 - 1212 - ep@1 { 1213 - reg = <1>; 1214 - atmel,fifo-size = <1024>; 1215 - atmel,nb-banks = <2>; 1216 - atmel,can-dma; 1217 - atmel,can-isoc; 1218 - }; 1219 - 1220 - ep@2 { 1221 - reg = <2>; 1222 - atmel,fifo-size = <1024>; 1223 - atmel,nb-banks = <2>; 1224 - atmel,can-dma; 1225 - atmel,can-isoc; 1226 - }; 1227 - 1228 - ep@3 { 1229 - reg = <3>; 1230 - atmel,fifo-size = <1024>; 1231 - atmel,nb-banks = <3>; 1232 - atmel,can-dma; 1233 - }; 1234 - 1235 - ep@4 { 1236 - reg = <4>; 1237 - atmel,fifo-size = <1024>; 1238 - atmel,nb-banks = <3>; 1239 - atmel,can-dma; 1240 - }; 1241 - 1242 - ep@5 { 1243 - reg = <5>; 1244 - atmel,fifo-size = <1024>; 1245 - atmel,nb-banks = <3>; 1246 - atmel,can-dma; 1247 - atmel,can-isoc; 1248 - }; 1249 - 1250 - ep@6 { 1251 - reg = <6>; 1252 - atmel,fifo-size = <1024>; 1253 - atmel,nb-banks = <3>; 1254 - atmel,can-dma; 1255 - atmel,can-isoc; 1256 - }; 1257 1207 }; 1258 1208 1259 1209 clk32k: sckc@fffffd50 {
-54
arch/arm/boot/dts/at91sam9rl.dtsi
··· 299 299 }; 300 300 301 301 usb0: gadget@fffd4000 { 302 - #address-cells = <1>; 303 - #size-cells = <0>; 304 302 compatible = "atmel,at91sam9rl-udc"; 305 303 reg = <0x00600000 0x100000>, 306 304 <0xfffd4000 0x4000>; ··· 306 308 clocks = <&pmc PMC_TYPE_PERIPHERAL 22>, <&pmc PMC_TYPE_CORE PMC_UTMI>; 307 309 clock-names = "pclk", "hclk"; 308 310 status = "disabled"; 309 - 310 - ep@0 { 311 - reg = <0>; 312 - atmel,fifo-size = <64>; 313 - atmel,nb-banks = <1>; 314 - }; 315 - 316 - ep@1 { 317 - reg = <1>; 318 - atmel,fifo-size = <1024>; 319 - atmel,nb-banks = <2>; 320 - atmel,can-dma; 321 - atmel,can-isoc; 322 - }; 323 - 324 - ep@2 { 325 - reg = <2>; 326 - atmel,fifo-size = <1024>; 327 - atmel,nb-banks = <2>; 328 - atmel,can-dma; 329 - atmel,can-isoc; 330 - }; 331 - 332 - ep@3 { 333 - reg = <3>; 334 - atmel,fifo-size = <1024>; 335 - atmel,nb-banks = <3>; 336 - atmel,can-dma; 337 - }; 338 - 339 - ep@4 { 340 - reg = <4>; 341 - atmel,fifo-size = <1024>; 342 - atmel,nb-banks = <3>; 343 - atmel,can-dma; 344 - }; 345 - 346 - ep@5 { 347 - reg = <5>; 348 - atmel,fifo-size = <1024>; 349 - atmel,nb-banks = <3>; 350 - atmel,can-dma; 351 - atmel,can-isoc; 352 - }; 353 - 354 - ep@6 { 355 - reg = <6>; 356 - atmel,fifo-size = <1024>; 357 - atmel,nb-banks = <3>; 358 - atmel,can-dma; 359 - atmel,can-isoc; 360 - }; 361 311 }; 362 312 363 313 dma0: dma-controller@ffffe600 {
-54
arch/arm/boot/dts/at91sam9x5.dtsi
··· 867 867 }; 868 868 869 869 usb2: gadget@f803c000 { 870 - #address-cells = <1>; 871 - #size-cells = <0>; 872 870 compatible = "atmel,at91sam9g45-udc"; 873 871 reg = <0x00500000 0x80000 874 872 0xf803c000 0x400>; ··· 874 876 clocks = <&pmc PMC_TYPE_CORE PMC_UTMI>, <&pmc PMC_TYPE_PERIPHERAL 23>; 875 877 clock-names = "hclk", "pclk"; 876 878 status = "disabled"; 877 - 878 - ep@0 { 879 - reg = <0>; 880 - atmel,fifo-size = <64>; 881 - atmel,nb-banks = <1>; 882 - }; 883 - 884 - ep@1 { 885 - reg = <1>; 886 - atmel,fifo-size = <1024>; 887 - atmel,nb-banks = <2>; 888 - atmel,can-dma; 889 - atmel,can-isoc; 890 - }; 891 - 892 - ep@2 { 893 - reg = <2>; 894 - atmel,fifo-size = <1024>; 895 - atmel,nb-banks = <2>; 896 - atmel,can-dma; 897 - atmel,can-isoc; 898 - }; 899 - 900 - ep@3 { 901 - reg = <3>; 902 - atmel,fifo-size = <1024>; 903 - atmel,nb-banks = <3>; 904 - atmel,can-dma; 905 - }; 906 - 907 - ep@4 { 908 - reg = <4>; 909 - atmel,fifo-size = <1024>; 910 - atmel,nb-banks = <3>; 911 - atmel,can-dma; 912 - }; 913 - 914 - ep@5 { 915 - reg = <5>; 916 - atmel,fifo-size = <1024>; 917 - atmel,nb-banks = <3>; 918 - atmel,can-dma; 919 - atmel,can-isoc; 920 - }; 921 - 922 - ep@6 { 923 - reg = <6>; 924 - atmel,fifo-size = <1024>; 925 - atmel,nb-banks = <3>; 926 - atmel,can-dma; 927 - atmel,can-isoc; 928 - }; 929 879 }; 930 880 931 881 watchdog: watchdog@fffffe40 {
-120
arch/arm/boot/dts/sama5d2.dtsi
··· 113 113 }; 114 114 115 115 usb0: gadget@300000 { 116 - #address-cells = <1>; 117 - #size-cells = <0>; 118 116 compatible = "atmel,sama5d3-udc"; 119 117 reg = <0x00300000 0x100000 120 118 0xfc02c000 0x400>; ··· 120 122 clocks = <&pmc PMC_TYPE_PERIPHERAL 42>, <&pmc PMC_TYPE_CORE PMC_UTMI>; 121 123 clock-names = "pclk", "hclk"; 122 124 status = "disabled"; 123 - 124 - ep@0 { 125 - reg = <0>; 126 - atmel,fifo-size = <64>; 127 - atmel,nb-banks = <1>; 128 - }; 129 - 130 - ep@1 { 131 - reg = <1>; 132 - atmel,fifo-size = <1024>; 133 - atmel,nb-banks = <3>; 134 - atmel,can-dma; 135 - atmel,can-isoc; 136 - }; 137 - 138 - ep@2 { 139 - reg = <2>; 140 - atmel,fifo-size = <1024>; 141 - atmel,nb-banks = <3>; 142 - atmel,can-dma; 143 - atmel,can-isoc; 144 - }; 145 - 146 - ep@3 { 147 - reg = <3>; 148 - atmel,fifo-size = <1024>; 149 - atmel,nb-banks = <2>; 150 - atmel,can-dma; 151 - atmel,can-isoc; 152 - }; 153 - 154 - ep@4 { 155 - reg = <4>; 156 - atmel,fifo-size = <1024>; 157 - atmel,nb-banks = <2>; 158 - atmel,can-dma; 159 - atmel,can-isoc; 160 - }; 161 - 162 - ep@5 { 163 - reg = <5>; 164 - atmel,fifo-size = <1024>; 165 - atmel,nb-banks = <2>; 166 - atmel,can-dma; 167 - atmel,can-isoc; 168 - }; 169 - 170 - ep@6 { 171 - reg = <6>; 172 - atmel,fifo-size = <1024>; 173 - atmel,nb-banks = <2>; 174 - atmel,can-dma; 175 - atmel,can-isoc; 176 - }; 177 - 178 - ep@7 { 179 - reg = <7>; 180 - atmel,fifo-size = <1024>; 181 - atmel,nb-banks = <2>; 182 - atmel,can-dma; 183 - atmel,can-isoc; 184 - }; 185 - 186 - ep@8 { 187 - reg = <8>; 188 - atmel,fifo-size = <1024>; 189 - atmel,nb-banks = <2>; 190 - atmel,can-isoc; 191 - }; 192 - 193 - ep@9 { 194 - reg = <9>; 195 - atmel,fifo-size = <1024>; 196 - atmel,nb-banks = <2>; 197 - atmel,can-isoc; 198 - }; 199 - 200 - ep@10 { 201 - reg = <10>; 202 - atmel,fifo-size = <1024>; 203 - atmel,nb-banks = <2>; 204 - atmel,can-isoc; 205 - }; 206 - 207 - ep@11 { 208 - reg = <11>; 209 - atmel,fifo-size = <1024>; 210 - atmel,nb-banks = <2>; 211 - atmel,can-isoc; 212 - }; 213 - 214 - ep@12 { 215 - reg = <12>; 216 - atmel,fifo-size = <1024>; 217 - atmel,nb-banks = <2>; 218 - atmel,can-isoc; 219 - }; 220 - 221 - ep@13 { 222 - reg = <13>; 223 - atmel,fifo-size = <1024>; 224 - atmel,nb-banks = <2>; 225 - atmel,can-isoc; 226 - }; 227 - 228 - ep@14 { 229 - reg = <14>; 230 - atmel,fifo-size = <1024>; 231 - atmel,nb-banks = <2>; 232 - atmel,can-isoc; 233 - }; 234 - 235 - ep@15 { 236 - reg = <15>; 237 - atmel,fifo-size = <1024>; 238 - atmel,nb-banks = <2>; 239 - atmel,can-isoc; 240 - }; 241 125 }; 242 126 243 127 usb1: ohci@400000 {
-107
arch/arm/boot/dts/sama5d3.dtsi
··· 1420 1420 }; 1421 1421 1422 1422 usb0: gadget@500000 { 1423 - #address-cells = <1>; 1424 - #size-cells = <0>; 1425 1423 compatible = "atmel,sama5d3-udc"; 1426 1424 reg = <0x00500000 0x100000 1427 1425 0xf8030000 0x4000>; ··· 1427 1429 clocks = <&udphs_clk>, <&utmi>; 1428 1430 clock-names = "pclk", "hclk"; 1429 1431 status = "disabled"; 1430 - 1431 - ep@0 { 1432 - reg = <0>; 1433 - atmel,fifo-size = <64>; 1434 - atmel,nb-banks = <1>; 1435 - }; 1436 - 1437 - ep@1 { 1438 - reg = <1>; 1439 - atmel,fifo-size = <1024>; 1440 - atmel,nb-banks = <3>; 1441 - atmel,can-dma; 1442 - atmel,can-isoc; 1443 - }; 1444 - 1445 - ep@2 { 1446 - reg = <2>; 1447 - atmel,fifo-size = <1024>; 1448 - atmel,nb-banks = <3>; 1449 - atmel,can-dma; 1450 - atmel,can-isoc; 1451 - }; 1452 - 1453 - ep@3 { 1454 - reg = <3>; 1455 - atmel,fifo-size = <1024>; 1456 - atmel,nb-banks = <2>; 1457 - atmel,can-dma; 1458 - }; 1459 - 1460 - ep@4 { 1461 - reg = <4>; 1462 - atmel,fifo-size = <1024>; 1463 - atmel,nb-banks = <2>; 1464 - atmel,can-dma; 1465 - }; 1466 - 1467 - ep@5 { 1468 - reg = <5>; 1469 - atmel,fifo-size = <1024>; 1470 - atmel,nb-banks = <2>; 1471 - atmel,can-dma; 1472 - }; 1473 - 1474 - ep@6 { 1475 - reg = <6>; 1476 - atmel,fifo-size = <1024>; 1477 - atmel,nb-banks = <2>; 1478 - atmel,can-dma; 1479 - }; 1480 - 1481 - ep@7 { 1482 - reg = <7>; 1483 - atmel,fifo-size = <1024>; 1484 - atmel,nb-banks = <2>; 1485 - atmel,can-dma; 1486 - }; 1487 - 1488 - ep@8 { 1489 - reg = <8>; 1490 - atmel,fifo-size = <1024>; 1491 - atmel,nb-banks = <2>; 1492 - }; 1493 - 1494 - ep@9 { 1495 - reg = <9>; 1496 - atmel,fifo-size = <1024>; 1497 - atmel,nb-banks = <2>; 1498 - }; 1499 - 1500 - ep@10 { 1501 - reg = <10>; 1502 - atmel,fifo-size = <1024>; 1503 - atmel,nb-banks = <2>; 1504 - }; 1505 - 1506 - ep@11 { 1507 - reg = <11>; 1508 - atmel,fifo-size = <1024>; 1509 - atmel,nb-banks = <2>; 1510 - }; 1511 - 1512 - ep@12 { 1513 - reg = <12>; 1514 - atmel,fifo-size = <1024>; 1515 - atmel,nb-banks = <2>; 1516 - }; 1517 - 1518 - ep@13 { 1519 - reg = <13>; 1520 - atmel,fifo-size = <1024>; 1521 - atmel,nb-banks = <2>; 1522 - }; 1523 - 1524 - ep@14 { 1525 - reg = <14>; 1526 - atmel,fifo-size = <1024>; 1527 - atmel,nb-banks = <2>; 1528 - }; 1529 - 1530 - ep@15 { 1531 - reg = <15>; 1532 - atmel,fifo-size = <1024>; 1533 - atmel,nb-banks = <2>; 1534 - }; 1535 1432 }; 1536 1433 1537 1434 usb1: ohci@600000 {
-120
arch/arm/boot/dts/sama5d4.dtsi
··· 96 96 }; 97 97 98 98 usb0: gadget@400000 { 99 - #address-cells = <1>; 100 - #size-cells = <0>; 101 99 compatible = "atmel,sama5d3-udc"; 102 100 reg = <0x00400000 0x100000 103 101 0xfc02c000 0x4000>; ··· 103 105 clocks = <&pmc PMC_TYPE_PERIPHERAL 47>, <&pmc PMC_TYPE_CORE PMC_UTMI>; 104 106 clock-names = "pclk", "hclk"; 105 107 status = "disabled"; 106 - 107 - ep@0 { 108 - reg = <0>; 109 - atmel,fifo-size = <64>; 110 - atmel,nb-banks = <1>; 111 - }; 112 - 113 - ep@1 { 114 - reg = <1>; 115 - atmel,fifo-size = <1024>; 116 - atmel,nb-banks = <3>; 117 - atmel,can-dma; 118 - atmel,can-isoc; 119 - }; 120 - 121 - ep@2 { 122 - reg = <2>; 123 - atmel,fifo-size = <1024>; 124 - atmel,nb-banks = <3>; 125 - atmel,can-dma; 126 - atmel,can-isoc; 127 - }; 128 - 129 - ep@3 { 130 - reg = <3>; 131 - atmel,fifo-size = <1024>; 132 - atmel,nb-banks = <2>; 133 - atmel,can-dma; 134 - atmel,can-isoc; 135 - }; 136 - 137 - ep@4 { 138 - reg = <4>; 139 - atmel,fifo-size = <1024>; 140 - atmel,nb-banks = <2>; 141 - atmel,can-dma; 142 - atmel,can-isoc; 143 - }; 144 - 145 - ep@5 { 146 - reg = <5>; 147 - atmel,fifo-size = <1024>; 148 - atmel,nb-banks = <2>; 149 - atmel,can-dma; 150 - atmel,can-isoc; 151 - }; 152 - 153 - ep@6 { 154 - reg = <6>; 155 - atmel,fifo-size = <1024>; 156 - atmel,nb-banks = <2>; 157 - atmel,can-dma; 158 - atmel,can-isoc; 159 - }; 160 - 161 - ep@7 { 162 - reg = <7>; 163 - atmel,fifo-size = <1024>; 164 - atmel,nb-banks = <2>; 165 - atmel,can-dma; 166 - atmel,can-isoc; 167 - }; 168 - 169 - ep@8 { 170 - reg = <8>; 171 - atmel,fifo-size = <1024>; 172 - atmel,nb-banks = <2>; 173 - atmel,can-isoc; 174 - }; 175 - 176 - ep@9 { 177 - reg = <9>; 178 - atmel,fifo-size = <1024>; 179 - atmel,nb-banks = <2>; 180 - atmel,can-isoc; 181 - }; 182 - 183 - ep@10 { 184 - reg = <10>; 185 - atmel,fifo-size = <1024>; 186 - atmel,nb-banks = <2>; 187 - atmel,can-isoc; 188 - }; 189 - 190 - ep@11 { 191 - reg = <11>; 192 - atmel,fifo-size = <1024>; 193 - atmel,nb-banks = <2>; 194 - atmel,can-isoc; 195 - }; 196 - 197 - ep@12 { 198 - reg = <12>; 199 - atmel,fifo-size = <1024>; 200 - atmel,nb-banks = <2>; 201 - atmel,can-isoc; 202 - }; 203 - 204 - ep@13 { 205 - reg = <13>; 206 - atmel,fifo-size = <1024>; 207 - atmel,nb-banks = <2>; 208 - atmel,can-isoc; 209 - }; 210 - 211 - ep@14 { 212 - reg = <14>; 213 - atmel,fifo-size = <1024>; 214 - atmel,nb-banks = <2>; 215 - atmel,can-isoc; 216 - }; 217 - 218 - ep@15 { 219 - reg = <15>; 220 - atmel,fifo-size = <1024>; 221 - atmel,nb-banks = <2>; 222 - atmel,can-isoc; 223 - }; 224 108 }; 225 109 226 110 usb1: ohci@500000 {
+2 -1
arch/arm64/boot/dts/amlogic/meson-gx-libretech-pc.dtsi
··· 360 360 status = "okay"; 361 361 }; 362 362 363 - &usb0 { 363 + &usb { 364 364 status = "okay"; 365 + dr_mode = "host"; 365 366 }; 366 367 367 368 &usb2_phy0 {
+2 -1
arch/arm64/boot/dts/amlogic/meson-gx-p23x-q20x.dtsi
··· 223 223 pinctrl-names = "default"; 224 224 }; 225 225 226 - &usb0 { 226 + &usb { 227 227 status = "okay"; 228 + dr_mode = "otg"; 228 229 };
+2 -1
arch/arm64/boot/dts/amlogic/meson-gxl-s805x-libretech-ac.dts
··· 243 243 pinctrl-names = "default"; 244 244 }; 245 245 246 - &usb0 { 246 + &usb { 247 247 status = "okay"; 248 + dr_mode = "host"; 248 249 };
+2 -1
arch/arm64/boot/dts/amlogic/meson-gxl-s805x-p241.dts
··· 216 216 pinctrl-names = "default"; 217 217 }; 218 218 219 - &usb0 { 219 + &usb { 220 220 status = "okay"; 221 + dr_mode = "host"; 221 222 };
+4
arch/arm64/boot/dts/amlogic/meson-gxl-s905d-phicomm-n1.dts
··· 29 29 &cvbs_vdac_port { 30 30 status = "disabled"; 31 31 }; 32 + 33 + &usb { 34 + dr_mode = "host"; 35 + };
+4
arch/arm64/boot/dts/amlogic/meson-gxl-s905w-p281.dts
··· 20 20 reg = <0x0 0x0 0x0 0x40000000>; 21 21 }; 22 22 }; 23 + 24 + &usb { 25 + dr_mode = "host"; 26 + };
+4
arch/arm64/boot/dts/amlogic/meson-gxl-s905w-tx3-mini.dts
··· 24 24 &ir { 25 25 linux,rc-map-name = "rc-tanix-tx3mini"; 26 26 }; 27 + 28 + &usb { 29 + dr_mode = "host"; 30 + };
+4
arch/arm64/boot/dts/amlogic/meson-gxl-s905x-khadas-vim.dts
··· 207 207 pinctrl-0 = <&uart_ao_b_pins>; 208 208 pinctrl-names = "default"; 209 209 }; 210 + 211 + &usb { 212 + dr_mode = "peripheral"; 213 + };
+2 -1
arch/arm64/boot/dts/amlogic/meson-gxl-s905x-libretech-cc.dts
··· 272 272 pinctrl-names = "default"; 273 273 }; 274 274 275 - &usb0 { 275 + &usb { 276 276 status = "okay"; 277 + dr_mode = "host"; 277 278 }; 278 279 279 280 &usb2_phy0 {
+2 -1
arch/arm64/boot/dts/amlogic/meson-gxl-s905x-nexbox-a95x.dts
··· 218 218 pinctrl-names = "default"; 219 219 }; 220 220 221 - &usb0 { 221 + &usb { 222 222 status = "okay"; 223 + dr_mode = "host"; 223 224 };
+2 -1
arch/arm64/boot/dts/amlogic/meson-gxl-s905x-p212.dtsi
··· 195 195 pinctrl-names = "default"; 196 196 }; 197 197 198 - &usb0 { 198 + &usb { 199 199 status = "okay"; 200 + dr_mode = "host"; 200 201 }; 201 202 202 203 &usb2_phy0 {
+25 -20
arch/arm64/boot/dts/amlogic/meson-gxl.dtsi
··· 14 14 compatible = "amlogic,meson-gxl"; 15 15 16 16 soc { 17 - usb0: usb@c9000000 { 18 - status = "disabled"; 19 - compatible = "amlogic,meson-gxl-dwc3"; 17 + usb: usb@d0078080 { 18 + compatible = "amlogic,meson-gxl-usb-ctrl"; 19 + reg = <0x0 0xd0078080 0x0 0x20>; 20 + interrupts = <GIC_SPI 16 IRQ_TYPE_LEVEL_HIGH>; 20 21 #address-cells = <2>; 21 22 #size-cells = <2>; 22 23 ranges; 23 24 24 - clocks = <&clkc CLKID_USB>; 25 - clock-names = "usb_general"; 25 + clocks = <&clkc CLKID_USB>, <&clkc CLKID_USB1_DDR_BRIDGE>; 26 + clock-names = "usb_ctrl", "ddr"; 26 27 resets = <&reset RESET_USB_OTG>; 27 - reset-names = "usb_otg"; 28 28 29 - dwc3: dwc3@c9000000 { 29 + dr_mode = "otg"; 30 + 31 + phys = <&usb2_phy0>, <&usb2_phy1>; 32 + phy-names = "usb2-phy0", "usb2-phy1"; 33 + 34 + dwc2: usb@c9100000 { 35 + compatible = "amlogic,meson-g12a-usb", "snps,dwc2"; 36 + reg = <0x0 0xc9100000 0x0 0x40000>; 37 + interrupts = <GIC_SPI 31 IRQ_TYPE_LEVEL_HIGH>; 38 + clocks = <&clkc CLKID_USB1>; 39 + clock-names = "otg"; 40 + phys = <&usb2_phy1>; 41 + dr_mode = "peripheral"; 42 + g-rx-fifo-size = <192>; 43 + g-np-tx-fifo-size = <128>; 44 + g-tx-fifo-size = <128 128 16 16 16>; 45 + }; 46 + 47 + dwc3: usb@c9000000 { 30 48 compatible = "snps,dwc3"; 31 49 reg = <0x0 0xc9000000 0x0 0x100000>; 32 50 interrupts = <GIC_SPI 30 IRQ_TYPE_LEVEL_HIGH>; 33 51 dr_mode = "host"; 34 52 maximum-speed = "high-speed"; 35 53 snps,dis_u2_susphy_quirk; 36 - phys = <&usb3_phy>, <&usb2_phy0>, <&usb2_phy1>; 37 54 }; 38 55 }; 39 56 ··· 86 69 clock-names = "phy"; 87 70 resets = <&reset RESET_USB_OTG>; 88 71 reset-names = "phy"; 89 - status = "okay"; 90 - }; 91 - 92 - usb3_phy: phy@78080 { 93 - compatible = "amlogic,meson-gxl-usb3-phy"; 94 - #phy-cells = <0>; 95 - reg = <0x0 0x78080 0x0 0x20>; 96 - interrupts = <GIC_SPI 16 IRQ_TYPE_LEVEL_HIGH>; 97 - clocks = <&clkc CLKID_USB>, <&clkc_AO CLKID_AO_CEC_32K>; 98 - clock-names = "phy", "peripheral"; 99 - resets = <&reset RESET_USB_OTG>, <&reset RESET_USB_OTG>; 100 - reset-names = "phy", "peripheral"; 101 72 status = "okay"; 102 73 }; 103 74 };
+2 -1
arch/arm64/boot/dts/amlogic/meson-gxm-khadas-vim2.dts
··· 380 380 vref-supply = <&vddio_ao18>; 381 381 }; 382 382 383 - &usb0 { 383 + &usb { 384 384 status = "okay"; 385 + dr_mode = "peripheral"; 385 386 };
+2 -1
arch/arm64/boot/dts/amlogic/meson-gxm-nexbox-a1.dts
··· 179 179 pinctrl-names = "default"; 180 180 }; 181 181 182 - &usb0 { 182 + &usb { 183 183 status = "okay"; 184 + dr_mode = "host"; 184 185 };
+4
arch/arm64/boot/dts/amlogic/meson-gxm-vega-s96.dts
··· 39 39 &ir { 40 40 linux,rc-map-name = "rc-vega-s9x"; 41 41 }; 42 + 43 + &usb { 44 + dr_mode = "host"; 45 + };
+5 -2
arch/arm64/boot/dts/amlogic/meson-gxm.dtsi
··· 169 169 compatible = "amlogic,meson-gxm-dw-hdmi", "amlogic,meson-gx-dw-hdmi"; 170 170 }; 171 171 172 - &dwc3 { 173 - phys = <&usb3_phy>, <&usb2_phy0>, <&usb2_phy1>, <&usb2_phy2>; 172 + &usb { 173 + compatible = "amlogic,meson-gxm-usb-ctrl"; 174 + 175 + phy-names = "usb2-phy0", "usb2-phy1", "usb2-phy2"; 176 + phys = <&usb2_phy0>, <&usb2_phy1>, <&usb2_phy2>; 174 177 }; 175 178 176 179 &vdec {
+4
arch/arm64/boot/dts/qcom/sc7180.dtsi
··· 1447 1447 1448 1448 resets = <&gcc GCC_USB30_PRIM_BCR>; 1449 1449 1450 + interconnects = <&aggre2_noc MASTER_USB3 &mc_virt SLAVE_EBI1>, 1451 + <&gem_noc MASTER_APPSS_PROC &config_noc SLAVE_USB3>; 1452 + interconnect-names = "usb-ddr", "apps-usb"; 1453 + 1450 1454 usb_1_dwc3: dwc3@a600000 { 1451 1455 compatible = "snps,dwc3"; 1452 1456 reg = <0 0x0a600000 0 0xe000>;
+8
arch/arm64/boot/dts/qcom/sdm845.dtsi
··· 3097 3097 3098 3098 resets = <&gcc GCC_USB30_PRIM_BCR>; 3099 3099 3100 + interconnects = <&aggre2_noc MASTER_USB3_0 &mem_noc SLAVE_EBI1>, 3101 + <&gladiator_noc MASTER_APPSS_PROC &config_noc SLAVE_USB3_0>; 3102 + interconnect-names = "usb-ddr", "apps-usb"; 3103 + 3100 3104 usb_1_dwc3: dwc3@a600000 { 3101 3105 compatible = "snps,dwc3"; 3102 3106 reg = <0 0x0a600000 0 0xcd00>; ··· 3144 3140 power-domains = <&gcc USB30_SEC_GDSC>; 3145 3141 3146 3142 resets = <&gcc GCC_USB30_SEC_BCR>; 3143 + 3144 + interconnects = <&aggre2_noc MASTER_USB3_1 &mem_noc SLAVE_EBI1>, 3145 + <&gladiator_noc MASTER_APPSS_PROC &config_noc SLAVE_USB3_1>; 3146 + interconnect-names = "usb-ddr", "apps-usb"; 3147 3147 3148 3148 usb_2_dwc3: dwc3@a800000 { 3149 3149 compatible = "snps,dwc3";
-12
drivers/phy/amlogic/Kconfig
··· 27 27 GXL and GXM SoCs. 28 28 If unsure, say N. 29 29 30 - config PHY_MESON_GXL_USB3 31 - tristate "Meson GXL and GXM USB3 PHY drivers" 32 - default ARCH_MESON 33 - depends on OF && (ARCH_MESON || COMPILE_TEST) 34 - depends on USB_SUPPORT 35 - select GENERIC_PHY 36 - select REGMAP_MMIO 37 - help 38 - Enable this to support the Meson USB3 PHY and OTG detection 39 - IP block found in Meson GXL and GXM SoCs. 40 - If unsure, say N. 41 - 42 30 config PHY_MESON_G12A_USB2 43 31 tristate "Meson G12A USB2 PHY driver" 44 32 default ARCH_MESON
-1
drivers/phy/amlogic/Makefile
··· 2 2 obj-$(CONFIG_PHY_MESON8B_USB2) += phy-meson8b-usb2.o 3 3 obj-$(CONFIG_PHY_MESON_GXL_USB2) += phy-meson-gxl-usb2.o 4 4 obj-$(CONFIG_PHY_MESON_G12A_USB2) += phy-meson-g12a-usb2.o 5 - obj-$(CONFIG_PHY_MESON_GXL_USB3) += phy-meson-gxl-usb3.o 6 5 obj-$(CONFIG_PHY_MESON_G12A_USB3_PCIE) += phy-meson-g12a-usb3-pcie.o 7 6 obj-$(CONFIG_PHY_MESON_AXG_PCIE) += phy-meson-axg-pcie.o 8 7 obj-$(CONFIG_PHY_MESON_AXG_MIPI_PCIE_ANALOG) += phy-meson-axg-mipi-pcie-analog.o
-283
drivers/phy/amlogic/phy-meson-gxl-usb3.c
··· 1 - // SPDX-License-Identifier: GPL-2.0 2 - /* 3 - * Meson GXL USB3 PHY and OTG mode detection driver 4 - * 5 - * Copyright (C) 2018 Martin Blumenstingl <martin.blumenstingl@googlemail.com> 6 - */ 7 - 8 - #include <linux/bitfield.h> 9 - #include <linux/bitops.h> 10 - #include <linux/clk.h> 11 - #include <linux/module.h> 12 - #include <linux/of_device.h> 13 - #include <linux/phy/phy.h> 14 - #include <linux/regmap.h> 15 - #include <linux/reset.h> 16 - #include <linux/platform_device.h> 17 - 18 - #define USB_R0 0x00 19 - #define USB_R0_P30_FSEL_MASK GENMASK(5, 0) 20 - #define USB_R0_P30_PHY_RESET BIT(6) 21 - #define USB_R0_P30_TEST_POWERDOWN_HSP BIT(7) 22 - #define USB_R0_P30_TEST_POWERDOWN_SSP BIT(8) 23 - #define USB_R0_P30_ACJT_LEVEL_MASK GENMASK(13, 9) 24 - #define USB_R0_P30_TX_BOOST_LEVEL_MASK GENMASK(16, 14) 25 - #define USB_R0_P30_LANE0_TX2RX_LOOPBACK BIT(17) 26 - #define USB_R0_P30_LANE0_EXT_PCLK_REQ BIT(18) 27 - #define USB_R0_P30_PCS_RX_LOS_MASK_VAL_MASK GENMASK(28, 19) 28 - #define USB_R0_U2D_SS_SCALEDOWN_MODE_MASK GENMASK(30, 29) 29 - #define USB_R0_U2D_ACT BIT(31) 30 - 31 - #define USB_R1 0x04 32 - #define USB_R1_U3H_BIGENDIAN_GS BIT(0) 33 - #define USB_R1_U3H_PME_ENABLE BIT(1) 34 - #define USB_R1_U3H_HUB_PORT_OVERCURRENT_MASK GENMASK(6, 2) 35 - #define USB_R1_U3H_HUB_PORT_PERM_ATTACH_MASK GENMASK(11, 7) 36 - #define USB_R1_U3H_HOST_U2_PORT_DISABLE_MASK GENMASK(15, 12) 37 - #define USB_R1_U3H_HOST_U3_PORT_DISABLE BIT(16) 38 - #define USB_R1_U3H_HOST_PORT_POWER_CONTROL_PRESENT BIT(17) 39 - #define USB_R1_U3H_HOST_MSI_ENABLE BIT(18) 40 - #define USB_R1_U3H_FLADJ_30MHZ_REG_MASK GENMASK(24, 19) 41 - #define USB_R1_P30_PCS_TX_SWING_FULL_MASK GENMASK(31, 25) 42 - 43 - #define USB_R2 0x08 44 - #define USB_R2_P30_CR_DATA_IN_MASK GENMASK(15, 0) 45 - #define USB_R2_P30_CR_READ BIT(16) 46 - #define USB_R2_P30_CR_WRITE BIT(17) 47 - #define USB_R2_P30_CR_CAP_ADDR BIT(18) 48 - #define USB_R2_P30_CR_CAP_DATA BIT(19) 49 - #define USB_R2_P30_PCS_TX_DEEMPH_3P5DB_MASK GENMASK(25, 20) 50 - #define USB_R2_P30_PCS_TX_DEEMPH_6DB_MASK GENMASK(31, 26) 51 - 52 - #define USB_R3 0x0c 53 - #define USB_R3_P30_SSC_ENABLE BIT(0) 54 - #define USB_R3_P30_SSC_RANGE_MASK GENMASK(3, 1) 55 - #define USB_R3_P30_SSC_REF_CLK_SEL_MASK GENMASK(12, 4) 56 - #define USB_R3_P30_REF_SSP_EN BIT(13) 57 - #define USB_R3_P30_LOS_BIAS_MASK GENMASK(18, 16) 58 - #define USB_R3_P30_LOS_LEVEL_MASK GENMASK(23, 19) 59 - #define USB_R3_P30_MPLL_MULTIPLIER_MASK GENMASK(30, 24) 60 - 61 - #define USB_R4 0x10 62 - #define USB_R4_P21_PORT_RESET_0 BIT(0) 63 - #define USB_R4_P21_SLEEP_M0 BIT(1) 64 - #define USB_R4_MEM_PD_MASK GENMASK(3, 2) 65 - #define USB_R4_P21_ONLY BIT(4) 66 - 67 - #define USB_R5 0x14 68 - #define USB_R5_ID_DIG_SYNC BIT(0) 69 - #define USB_R5_ID_DIG_REG BIT(1) 70 - #define USB_R5_ID_DIG_CFG_MASK GENMASK(3, 2) 71 - #define USB_R5_ID_DIG_EN_0 BIT(4) 72 - #define USB_R5_ID_DIG_EN_1 BIT(5) 73 - #define USB_R5_ID_DIG_CURR BIT(6) 74 - #define USB_R5_ID_DIG_IRQ BIT(7) 75 - #define USB_R5_ID_DIG_TH_MASK GENMASK(15, 8) 76 - #define USB_R5_ID_DIG_CNT_MASK GENMASK(23, 16) 77 - 78 - /* read-only register */ 79 - #define USB_R6 0x18 80 - #define USB_R6_P30_CR_DATA_OUT_MASK GENMASK(15, 0) 81 - #define USB_R6_P30_CR_ACK BIT(16) 82 - 83 - struct phy_meson_gxl_usb3_priv { 84 - struct regmap *regmap; 85 - enum phy_mode mode; 86 - struct clk *clk_phy; 87 - struct clk *clk_peripheral; 88 - struct reset_control *reset; 89 - }; 90 - 91 - static const struct regmap_config phy_meson_gxl_usb3_regmap_conf = { 92 - .reg_bits = 8, 93 - .val_bits = 32, 94 - .reg_stride = 4, 95 - .max_register = USB_R6, 96 - }; 97 - 98 - static int phy_meson_gxl_usb3_power_on(struct phy *phy) 99 - { 100 - struct phy_meson_gxl_usb3_priv *priv = phy_get_drvdata(phy); 101 - 102 - regmap_update_bits(priv->regmap, USB_R5, USB_R5_ID_DIG_EN_0, 103 - USB_R5_ID_DIG_EN_0); 104 - regmap_update_bits(priv->regmap, USB_R5, USB_R5_ID_DIG_EN_1, 105 - USB_R5_ID_DIG_EN_1); 106 - regmap_update_bits(priv->regmap, USB_R5, USB_R5_ID_DIG_TH_MASK, 107 - FIELD_PREP(USB_R5_ID_DIG_TH_MASK, 0xff)); 108 - 109 - return 0; 110 - } 111 - 112 - static int phy_meson_gxl_usb3_power_off(struct phy *phy) 113 - { 114 - struct phy_meson_gxl_usb3_priv *priv = phy_get_drvdata(phy); 115 - 116 - regmap_update_bits(priv->regmap, USB_R5, USB_R5_ID_DIG_EN_0, 0); 117 - regmap_update_bits(priv->regmap, USB_R5, USB_R5_ID_DIG_EN_1, 0); 118 - 119 - return 0; 120 - } 121 - 122 - static int phy_meson_gxl_usb3_set_mode(struct phy *phy, 123 - enum phy_mode mode, int submode) 124 - { 125 - struct phy_meson_gxl_usb3_priv *priv = phy_get_drvdata(phy); 126 - 127 - switch (mode) { 128 - case PHY_MODE_USB_HOST: 129 - regmap_update_bits(priv->regmap, USB_R0, USB_R0_U2D_ACT, 0); 130 - regmap_update_bits(priv->regmap, USB_R4, USB_R4_P21_SLEEP_M0, 131 - 0); 132 - break; 133 - 134 - case PHY_MODE_USB_DEVICE: 135 - regmap_update_bits(priv->regmap, USB_R0, USB_R0_U2D_ACT, 136 - USB_R0_U2D_ACT); 137 - regmap_update_bits(priv->regmap, USB_R4, USB_R4_P21_SLEEP_M0, 138 - USB_R4_P21_SLEEP_M0); 139 - break; 140 - 141 - default: 142 - dev_err(&phy->dev, "unsupported PHY mode %d\n", mode); 143 - return -EINVAL; 144 - } 145 - 146 - priv->mode = mode; 147 - 148 - return 0; 149 - } 150 - 151 - static int phy_meson_gxl_usb3_init(struct phy *phy) 152 - { 153 - struct phy_meson_gxl_usb3_priv *priv = phy_get_drvdata(phy); 154 - int ret; 155 - 156 - ret = reset_control_reset(priv->reset); 157 - if (ret) 158 - goto err; 159 - 160 - ret = clk_prepare_enable(priv->clk_phy); 161 - if (ret) 162 - goto err; 163 - 164 - ret = clk_prepare_enable(priv->clk_peripheral); 165 - if (ret) 166 - goto err_disable_clk_phy; 167 - 168 - ret = phy_meson_gxl_usb3_set_mode(phy, priv->mode, 0); 169 - if (ret) 170 - goto err_disable_clk_peripheral; 171 - 172 - regmap_update_bits(priv->regmap, USB_R1, 173 - USB_R1_U3H_FLADJ_30MHZ_REG_MASK, 174 - FIELD_PREP(USB_R1_U3H_FLADJ_30MHZ_REG_MASK, 0x20)); 175 - 176 - return 0; 177 - 178 - err_disable_clk_peripheral: 179 - clk_disable_unprepare(priv->clk_peripheral); 180 - err_disable_clk_phy: 181 - clk_disable_unprepare(priv->clk_phy); 182 - err: 183 - return ret; 184 - } 185 - 186 - static int phy_meson_gxl_usb3_exit(struct phy *phy) 187 - { 188 - struct phy_meson_gxl_usb3_priv *priv = phy_get_drvdata(phy); 189 - 190 - clk_disable_unprepare(priv->clk_peripheral); 191 - clk_disable_unprepare(priv->clk_phy); 192 - 193 - return 0; 194 - } 195 - 196 - static const struct phy_ops phy_meson_gxl_usb3_ops = { 197 - .power_on = phy_meson_gxl_usb3_power_on, 198 - .power_off = phy_meson_gxl_usb3_power_off, 199 - .set_mode = phy_meson_gxl_usb3_set_mode, 200 - .init = phy_meson_gxl_usb3_init, 201 - .exit = phy_meson_gxl_usb3_exit, 202 - .owner = THIS_MODULE, 203 - }; 204 - 205 - static int phy_meson_gxl_usb3_probe(struct platform_device *pdev) 206 - { 207 - struct device *dev = &pdev->dev; 208 - struct device_node *np = dev->of_node; 209 - struct phy_meson_gxl_usb3_priv *priv; 210 - struct resource *res; 211 - struct phy *phy; 212 - struct phy_provider *phy_provider; 213 - void __iomem *base; 214 - int ret; 215 - 216 - priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); 217 - if (!priv) 218 - return -ENOMEM; 219 - 220 - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 221 - base = devm_ioremap_resource(dev, res); 222 - if (IS_ERR(base)) 223 - return PTR_ERR(base); 224 - 225 - priv->regmap = devm_regmap_init_mmio(dev, base, 226 - &phy_meson_gxl_usb3_regmap_conf); 227 - if (IS_ERR(priv->regmap)) 228 - return PTR_ERR(priv->regmap); 229 - 230 - priv->clk_phy = devm_clk_get(dev, "phy"); 231 - if (IS_ERR(priv->clk_phy)) 232 - return PTR_ERR(priv->clk_phy); 233 - 234 - priv->clk_peripheral = devm_clk_get(dev, "peripheral"); 235 - if (IS_ERR(priv->clk_peripheral)) 236 - return PTR_ERR(priv->clk_peripheral); 237 - 238 - priv->reset = devm_reset_control_array_get_shared(dev); 239 - if (IS_ERR(priv->reset)) 240 - return PTR_ERR(priv->reset); 241 - 242 - /* 243 - * default to host mode as hardware defaults and/or boot-loader 244 - * behavior can result in this PHY starting up in device mode. this 245 - * default and the initialization in phy_meson_gxl_usb3_init ensure 246 - * that we reproducibly start in a known mode on all devices. 247 - */ 248 - priv->mode = PHY_MODE_USB_HOST; 249 - 250 - phy = devm_phy_create(dev, np, &phy_meson_gxl_usb3_ops); 251 - if (IS_ERR(phy)) { 252 - ret = PTR_ERR(phy); 253 - if (ret != -EPROBE_DEFER) 254 - dev_err(dev, "failed to create PHY\n"); 255 - 256 - return ret; 257 - } 258 - 259 - phy_set_drvdata(phy, priv); 260 - 261 - phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate); 262 - 263 - return PTR_ERR_OR_ZERO(phy_provider); 264 - } 265 - 266 - static const struct of_device_id phy_meson_gxl_usb3_of_match[] = { 267 - { .compatible = "amlogic,meson-gxl-usb3-phy", }, 268 - { }, 269 - }; 270 - MODULE_DEVICE_TABLE(of, phy_meson_gxl_usb3_of_match); 271 - 272 - static struct platform_driver phy_meson_gxl_usb3_driver = { 273 - .probe = phy_meson_gxl_usb3_probe, 274 - .driver = { 275 - .name = "phy-meson-gxl-usb3", 276 - .of_match_table = phy_meson_gxl_usb3_of_match, 277 - }, 278 - }; 279 - module_platform_driver(phy_meson_gxl_usb3_driver); 280 - 281 - MODULE_AUTHOR("Martin Blumenstingl <martin.blumenstingl@googlemail.com>"); 282 - MODULE_DESCRIPTION("Meson GXL USB3 PHY and OTG detection driver"); 283 - MODULE_LICENSE("GPL v2");
+1 -2
drivers/usb/cdns3/cdns3-ti.c
··· 138 138 error = pm_runtime_get_sync(dev); 139 139 if (error < 0) { 140 140 dev_err(dev, "pm_runtime_get_sync failed: %d\n", error); 141 - goto err_get; 141 + goto err; 142 142 } 143 143 144 144 /* assert RESET */ ··· 185 185 186 186 err: 187 187 pm_runtime_put_sync(data->dev); 188 - err_get: 189 188 pm_runtime_disable(data->dev); 190 189 191 190 return error;
-7
drivers/usb/cdns3/ep0.c
··· 332 332 case TEST_K: 333 333 case TEST_SE0_NAK: 334 334 case TEST_PACKET: 335 - cdns3_ep0_complete_setup(priv_dev, 0, 1); 336 - /** 337 - * Little delay to give the controller some time 338 - * for sending status stage. 339 - * This time should be less then 3ms. 340 - */ 341 - mdelay(1); 342 335 cdns3_set_register_bit(&priv_dev->regs->usb_cmd, 343 336 USB_CMD_STMODE | 344 337 USB_STS_TMODE_SEL(tmode - 1));
+7 -6
drivers/usb/cdns3/gadget.c
··· 512 512 } 513 513 514 514 static struct usb_request *cdns3_wa2_gadget_giveback(struct cdns3_device *priv_dev, 515 - struct cdns3_endpoint *priv_ep, 516 - struct cdns3_request *priv_req) 515 + struct cdns3_endpoint *priv_ep, 516 + struct cdns3_request *priv_req) 517 517 { 518 518 if (priv_ep->flags & EP_QUIRK_EXTRA_BUF_EN && 519 519 priv_req->flags & REQUEST_INTERNAL) { ··· 552 552 } 553 553 554 554 static int cdns3_wa2_gadget_ep_queue(struct cdns3_device *priv_dev, 555 - struct cdns3_endpoint *priv_ep, 556 - struct cdns3_request *priv_req) 555 + struct cdns3_endpoint *priv_ep, 556 + struct cdns3_request *priv_req) 557 557 { 558 558 int deferred = 0; 559 559 ··· 1905 1905 } 1906 1906 1907 1907 static void cdns3_stream_ep_reconfig(struct cdns3_device *priv_dev, 1908 - struct cdns3_endpoint *priv_ep) 1908 + struct cdns3_endpoint *priv_ep) 1909 1909 { 1910 1910 if (!priv_ep->use_streams || priv_dev->gadget.speed < USB_SPEED_SUPER) 1911 1911 return; ··· 1926 1926 } 1927 1927 1928 1928 static void cdns3_configure_dmult(struct cdns3_device *priv_dev, 1929 - struct cdns3_endpoint *priv_ep) 1929 + struct cdns3_endpoint *priv_ep) 1930 1930 { 1931 1931 struct cdns3_usb_regs __iomem *regs = priv_dev->regs; 1932 1932 ··· 3069 3069 priv_dev->gadget.name = "usb-ss-gadget"; 3070 3070 priv_dev->gadget.sg_supported = 1; 3071 3071 priv_dev->gadget.quirk_avoids_skb_reserve = 1; 3072 + priv_dev->gadget.irq = cdns->dev_irq; 3072 3073 3073 3074 spin_lock_init(&priv_dev->lock); 3074 3075 INIT_WORK(&priv_dev->pending_status_wq,
+19 -4
drivers/usb/dwc2/core.c
··· 524 524 greset |= GRSTCTL_CSFTRST; 525 525 dwc2_writel(hsotg, greset, GRSTCTL); 526 526 527 - if (dwc2_hsotg_wait_bit_clear(hsotg, GRSTCTL, GRSTCTL_CSFTRST, 10000)) { 528 - dev_warn(hsotg->dev, "%s: HANG! Soft Reset timeout GRSTCTL GRSTCTL_CSFTRST\n", 529 - __func__); 530 - return -EBUSY; 527 + if ((hsotg->hw_params.snpsid & DWC2_CORE_REV_MASK) < 528 + (DWC2_CORE_REV_4_20a & DWC2_CORE_REV_MASK)) { 529 + if (dwc2_hsotg_wait_bit_clear(hsotg, GRSTCTL, 530 + GRSTCTL_CSFTRST, 10000)) { 531 + dev_warn(hsotg->dev, "%s: HANG! Soft Reset timeout GRSTCTL_CSFTRST\n", 532 + __func__); 533 + return -EBUSY; 534 + } 535 + } else { 536 + if (dwc2_hsotg_wait_bit_set(hsotg, GRSTCTL, 537 + GRSTCTL_CSFTRST_DONE, 10000)) { 538 + dev_warn(hsotg->dev, "%s: HANG! Soft Reset timeout GRSTCTL_CSFTRST_DONE\n", 539 + __func__); 540 + return -EBUSY; 541 + } 542 + greset = dwc2_readl(hsotg, GRSTCTL); 543 + greset &= ~GRSTCTL_CSFTRST; 544 + greset |= GRSTCTL_CSFTRST_DONE; 545 + dwc2_writel(hsotg, greset, GRSTCTL); 531 546 } 532 547 533 548 /* Wait for AHB master IDLE state */
+4
drivers/usb/dwc2/core.h
··· 1103 1103 #define DWC2_CORE_REV_3_00a 0x4f54300a 1104 1104 #define DWC2_CORE_REV_3_10a 0x4f54310a 1105 1105 #define DWC2_CORE_REV_4_00a 0x4f54400a 1106 + #define DWC2_CORE_REV_4_20a 0x4f54420a 1106 1107 #define DWC2_FS_IOT_REV_1_00a 0x5531100a 1107 1108 #define DWC2_HS_IOT_REV_1_00a 0x5532100a 1109 + #define DWC2_CORE_REV_MASK 0x0000ffff 1108 1110 1109 1111 /* DWC OTG HW Core ID */ 1110 1112 #define DWC2_OTG_ID 0x4f540000 ··· 1310 1308 void dwc2_force_dr_mode(struct dwc2_hsotg *hsotg); 1311 1309 1312 1310 bool dwc2_is_controller_alive(struct dwc2_hsotg *hsotg); 1311 + 1312 + int dwc2_check_core_version(struct dwc2_hsotg *hsotg); 1313 1313 1314 1314 /* 1315 1315 * Common core Functions.
+5 -2
drivers/usb/dwc2/core_intr.c
··· 416 416 if (ret && (ret != -ENOTSUPP)) 417 417 dev_err(hsotg->dev, "exit power_down failed\n"); 418 418 419 + /* Change to L0 state */ 420 + hsotg->lx_state = DWC2_L0; 419 421 call_gadget(hsotg, resume); 422 + } else { 423 + /* Change to L0 state */ 424 + hsotg->lx_state = DWC2_L0; 420 425 } 421 - /* Change to L0 state */ 422 - hsotg->lx_state = DWC2_L0; 423 426 } else { 424 427 if (hsotg->params.power_down) 425 428 return;
+1
drivers/usb/dwc2/hw.h
··· 126 126 #define GRSTCTL HSOTG_REG(0x010) 127 127 #define GRSTCTL_AHBIDLE BIT(31) 128 128 #define GRSTCTL_DMAREQ BIT(30) 129 + #define GRSTCTL_CSFTRST_DONE BIT(29) 129 130 #define GRSTCTL_TXFNUM_MASK (0x1f << 6) 130 131 #define GRSTCTL_TXFNUM_SHIFT 6 131 132 #define GRSTCTL_TXFNUM_LIMIT 0x1f
-19
drivers/usb/dwc2/params.c
··· 782 782 u32 hwcfg1, hwcfg2, hwcfg3, hwcfg4; 783 783 u32 grxfsiz; 784 784 785 - /* 786 - * Attempt to ensure this device is really a DWC_otg Controller. 787 - * Read and verify the GSNPSID register contents. The value should be 788 - * 0x45f4xxxx, 0x5531xxxx or 0x5532xxxx 789 - */ 790 - 791 - hw->snpsid = dwc2_readl(hsotg, GSNPSID); 792 - if ((hw->snpsid & GSNPSID_ID_MASK) != DWC2_OTG_ID && 793 - (hw->snpsid & GSNPSID_ID_MASK) != DWC2_FS_IOT_ID && 794 - (hw->snpsid & GSNPSID_ID_MASK) != DWC2_HS_IOT_ID) { 795 - dev_err(hsotg->dev, "Bad value for GSNPSID: 0x%08x\n", 796 - hw->snpsid); 797 - return -ENODEV; 798 - } 799 - 800 - dev_dbg(hsotg->dev, "Core Release: %1x.%1x%1x%1x (snpsid=%x)\n", 801 - hw->snpsid >> 12 & 0xf, hw->snpsid >> 8 & 0xf, 802 - hw->snpsid >> 4 & 0xf, hw->snpsid & 0xf, hw->snpsid); 803 - 804 785 hwcfg1 = dwc2_readl(hsotg, GHWCFG1); 805 786 hwcfg2 = dwc2_readl(hsotg, GHWCFG2); 806 787 hwcfg3 = dwc2_readl(hsotg, GHWCFG3);
+39
drivers/usb/dwc2/platform.c
··· 363 363 } 364 364 365 365 /** 366 + * Check core version 367 + * 368 + * @hsotg: Programming view of the DWC_otg controller 369 + * 370 + */ 371 + int dwc2_check_core_version(struct dwc2_hsotg *hsotg) 372 + { 373 + struct dwc2_hw_params *hw = &hsotg->hw_params; 374 + 375 + /* 376 + * Attempt to ensure this device is really a DWC_otg Controller. 377 + * Read and verify the GSNPSID register contents. The value should be 378 + * 0x45f4xxxx, 0x5531xxxx or 0x5532xxxx 379 + */ 380 + 381 + hw->snpsid = dwc2_readl(hsotg, GSNPSID); 382 + if ((hw->snpsid & GSNPSID_ID_MASK) != DWC2_OTG_ID && 383 + (hw->snpsid & GSNPSID_ID_MASK) != DWC2_FS_IOT_ID && 384 + (hw->snpsid & GSNPSID_ID_MASK) != DWC2_HS_IOT_ID) { 385 + dev_err(hsotg->dev, "Bad value for GSNPSID: 0x%08x\n", 386 + hw->snpsid); 387 + return -ENODEV; 388 + } 389 + 390 + dev_dbg(hsotg->dev, "Core Release: %1x.%1x%1x%1x (snpsid=%x)\n", 391 + hw->snpsid >> 12 & 0xf, hw->snpsid >> 8 & 0xf, 392 + hw->snpsid >> 4 & 0xf, hw->snpsid & 0xf, hw->snpsid); 393 + return 0; 394 + } 395 + 396 + /** 366 397 * dwc2_driver_probe() - Called when the DWC_otg core is bound to the DWC_otg 367 398 * driver 368 399 * ··· 474 443 hsotg->need_phy_for_wake = 475 444 of_property_read_bool(dev->dev.of_node, 476 445 "snps,need-phy-for-wake"); 446 + 447 + /* 448 + * Before performing any core related operations 449 + * check core version. 450 + */ 451 + retval = dwc2_check_core_version(hsotg); 452 + if (retval) 453 + goto error; 477 454 478 455 /* 479 456 * Reset before dwc2_get_hwparams() then it could get power-on real
+32 -30
drivers/usb/dwc3/core.c
··· 85 85 * specified or set to OTG, then set the mode to peripheral. 86 86 */ 87 87 if (mode == USB_DR_MODE_OTG && 88 - dwc->revision >= DWC3_REVISION_330A) 88 + (!IS_ENABLED(CONFIG_USB_ROLE_SWITCH) || 89 + !device_property_read_bool(dwc->dev, "usb-role-switch")) && 90 + !DWC3_VER_IS_PRIOR(DWC3, 330A)) 89 91 mode = USB_DR_MODE_PERIPHERAL; 90 92 } 91 93 ··· 123 121 if (dwc->dr_mode != USB_DR_MODE_OTG) 124 122 return; 125 123 124 + pm_runtime_get_sync(dwc->dev); 125 + 126 126 if (dwc->current_dr_role == DWC3_GCTL_PRTCAP_OTG) 127 127 dwc3_otg_update(dwc, 0); 128 128 129 129 if (!dwc->desired_dr_role) 130 - return; 130 + goto out; 131 131 132 132 if (dwc->desired_dr_role == dwc->current_dr_role) 133 - return; 133 + goto out; 134 134 135 135 if (dwc->desired_dr_role == DWC3_GCTL_PRTCAP_OTG && dwc->edev) 136 - return; 136 + goto out; 137 137 138 138 switch (dwc->current_dr_role) { 139 139 case DWC3_GCTL_PRTCAP_HOST: ··· 194 190 break; 195 191 } 196 192 193 + out: 194 + pm_runtime_mark_last_busy(dwc->dev); 195 + pm_runtime_put_autosuspend(dwc->dev); 197 196 } 198 197 199 198 void dwc3_set_mode(struct dwc3 *dwc, u32 mode) ··· 264 257 * take a little more than 50ms. Set the polling rate at 20ms 265 258 * for 10 times instead. 266 259 */ 267 - if (dwc3_is_usb31(dwc) && dwc->revision >= DWC3_USB31_REVISION_190A) 260 + if (DWC3_VER_IS_WITHIN(DWC31, 190A, ANY) || DWC3_IP_IS(DWC32)) 268 261 retries = 10; 269 262 270 263 do { ··· 272 265 if (!(reg & DWC3_DCTL_CSFTRST)) 273 266 goto done; 274 267 275 - if (dwc3_is_usb31(dwc) && 276 - dwc->revision >= DWC3_USB31_REVISION_190A) 268 + if (DWC3_VER_IS_WITHIN(DWC31, 190A, ANY) || DWC3_IP_IS(DWC32)) 277 269 msleep(20); 278 270 else 279 271 udelay(1); ··· 289 283 * is cleared, we must wait at least 50ms before accessing the PHY 290 284 * domain (synchronization delay). 291 285 */ 292 - if (dwc3_is_usb31(dwc) && dwc->revision <= DWC3_USB31_REVISION_180A) 286 + if (DWC3_VER_IS_WITHIN(DWC31, ANY, 180A)) 293 287 msleep(50); 294 288 295 289 return 0; ··· 304 298 u32 reg; 305 299 u32 dft; 306 300 307 - if (dwc->revision < DWC3_REVISION_250A) 301 + if (DWC3_VER_IS_PRIOR(DWC3, 250A)) 308 302 return; 309 303 310 304 if (dwc->fladj == 0) ··· 585 579 * will be '0' when the core is reset. Application needs to set it 586 580 * to '1' after the core initialization is completed. 587 581 */ 588 - if (dwc->revision > DWC3_REVISION_194A) 582 + if (!DWC3_VER_IS_WITHIN(DWC3, ANY, 194A)) 589 583 reg |= DWC3_GUSB3PIPECTL_SUSPHY; 590 584 591 585 /* ··· 676 670 * be '0' when the core is reset. Application needs to set it to 677 671 * '1' after the core initialization is completed. 678 672 */ 679 - if (dwc->revision > DWC3_REVISION_194A) 673 + if (!DWC3_VER_IS_WITHIN(DWC3, ANY, 194A)) 680 674 reg |= DWC3_GUSB2PHYCFG_SUSPHY; 681 675 682 676 /* ··· 725 719 u32 reg; 726 720 727 721 reg = dwc3_readl(dwc->regs, DWC3_GSNPSID); 722 + dwc->ip = DWC3_GSNPS_ID(reg); 728 723 729 724 /* This should read as U3 followed by revision number */ 730 - if ((reg & DWC3_GSNPSID_MASK) == 0x55330000) { 731 - /* Detected DWC_usb3 IP */ 725 + if (DWC3_IP_IS(DWC3)) { 732 726 dwc->revision = reg; 733 - } else if ((reg & DWC3_GSNPSID_MASK) == 0x33310000) { 734 - /* Detected DWC_usb31 IP */ 727 + } else if (DWC3_IP_IS(DWC31) || DWC3_IP_IS(DWC32)) { 735 728 dwc->revision = dwc3_readl(dwc->regs, DWC3_VER_NUMBER); 736 - dwc->revision |= DWC3_REVISION_IS_DWC31; 737 729 dwc->version_type = dwc3_readl(dwc->regs, DWC3_VER_TYPE); 738 730 } else { 739 731 return false; ··· 764 760 */ 765 761 if ((dwc->dr_mode == USB_DR_MODE_HOST || 766 762 dwc->dr_mode == USB_DR_MODE_OTG) && 767 - (dwc->revision >= DWC3_REVISION_210A && 768 - dwc->revision <= DWC3_REVISION_250A)) 763 + DWC3_VER_IS_WITHIN(DWC3, 210A, 250A)) 769 764 reg |= DWC3_GCTL_DSBLCLKGTNG | DWC3_GCTL_SOFITPSYNC; 770 765 else 771 766 reg &= ~DWC3_GCTL_DSBLCLKGTNG; ··· 807 804 * and falls back to high-speed mode which causes 808 805 * the device to enter a Connect/Disconnect loop 809 806 */ 810 - if (dwc->revision < DWC3_REVISION_190A) 807 + if (DWC3_VER_IS_PRIOR(DWC3, 190A)) 811 808 reg |= DWC3_GCTL_U2RSTECN; 812 809 813 810 dwc3_writel(dwc->regs, DWC3_GCTL, reg); ··· 960 957 goto err0a; 961 958 962 959 if (hw_mode == DWC3_GHWPARAMS0_MODE_DRD && 963 - dwc->revision > DWC3_REVISION_194A) { 960 + !DWC3_VER_IS_WITHIN(DWC3, ANY, 194A)) { 964 961 if (!dwc->dis_u3_susphy_quirk) { 965 962 reg = dwc3_readl(dwc->regs, DWC3_GUSB3PIPECTL(0)); 966 963 reg |= DWC3_GUSB3PIPECTL_SUSPHY; ··· 1007 1004 * the DWC_usb3 controller. It is NOT available in the 1008 1005 * DWC_usb31 controller. 1009 1006 */ 1010 - if (!dwc3_is_usb31(dwc) && dwc->revision >= DWC3_REVISION_310A) { 1007 + if (DWC3_VER_IS_WITHIN(DWC3, 310A, ANY)) { 1011 1008 reg = dwc3_readl(dwc->regs, DWC3_GUCTL2); 1012 1009 reg |= DWC3_GUCTL2_RST_ACTBITLATER; 1013 1010 dwc3_writel(dwc->regs, DWC3_GUCTL2, reg); 1014 1011 } 1015 1012 1016 - if (dwc->revision >= DWC3_REVISION_250A) { 1013 + if (!DWC3_VER_IS_PRIOR(DWC3, 250A)) { 1017 1014 reg = dwc3_readl(dwc->regs, DWC3_GUCTL1); 1018 1015 1019 1016 /* 1020 1017 * Enable hardware control of sending remote wakeup 1021 1018 * in HS when the device is in the L1 state. 1022 1019 */ 1023 - if (dwc->revision >= DWC3_REVISION_290A) 1020 + if (!DWC3_VER_IS_PRIOR(DWC3, 290A)) 1024 1021 reg |= DWC3_GUCTL1_DEV_L1_EXIT_BY_HW; 1025 1022 1026 1023 if (dwc->dis_tx_ipgap_linecheck_quirk) ··· 1052 1049 * Must config both number of packets and max burst settings to enable 1053 1050 * RX and/or TX threshold. 1054 1051 */ 1055 - if (dwc3_is_usb31(dwc) && dwc->dr_mode == USB_DR_MODE_HOST) { 1052 + if (!DWC3_IP_IS(DWC3) && dwc->dr_mode == USB_DR_MODE_HOST) { 1056 1053 u8 rx_thr_num = dwc->rx_thr_num_pkt_prd; 1057 1054 u8 rx_maxburst = dwc->rx_max_burst_prd; 1058 1055 u8 tx_thr_num = dwc->tx_thr_num_pkt_prd; ··· 1374 1371 /* check whether the core supports IMOD */ 1375 1372 bool dwc3_has_imod(struct dwc3 *dwc) 1376 1373 { 1377 - return ((dwc3_is_usb3(dwc) && 1378 - dwc->revision >= DWC3_REVISION_300A) || 1379 - (dwc3_is_usb31(dwc) && 1380 - dwc->revision >= DWC3_USB31_REVISION_120A)); 1374 + return DWC3_VER_IS_WITHIN(DWC3, 300A, ANY) || 1375 + DWC3_VER_IS_WITHIN(DWC31, 120A, ANY) || 1376 + DWC3_IP_IS(DWC32); 1381 1377 } 1382 1378 1383 1379 static void dwc3_check_params(struct dwc3 *dwc) ··· 1397 1395 * affected version. 1398 1396 */ 1399 1397 if (!dwc->imod_interval && 1400 - (dwc->revision == DWC3_REVISION_300A)) 1398 + DWC3_VER_IS(DWC3, 300A)) 1401 1399 dwc->imod_interval = 1; 1402 1400 1403 1401 /* Check the maximum_speed parameter */ ··· 1419 1417 /* 1420 1418 * default to superspeed plus if we are capable. 1421 1419 */ 1422 - if (dwc3_is_usb31(dwc) && 1420 + if ((DWC3_IP_IS(DWC31) || DWC3_IP_IS(DWC32)) && 1423 1421 (DWC3_GHWPARAMS3_SSPHY_IFC(dwc->hwparams.hwparams3) == 1424 1422 DWC3_GHWPARAMS3_SSPHY_IFC_GEN2)) 1425 1423 dwc->maximum_speed = USB_SPEED_SUPER_PLUS;
+53 -30
drivers/usb/dwc3/core.h
··· 1 - // SPDX-License-Identifier: GPL-2.0 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 2 /* 3 3 * core.h - DesignWare USB3 DRD Core Header 4 4 * ··· 69 69 #define DWC3_GEVNTCOUNT_EHB BIT(31) 70 70 #define DWC3_GSNPSID_MASK 0xffff0000 71 71 #define DWC3_GSNPSREV_MASK 0xffff 72 + #define DWC3_GSNPS_ID(p) (((p) & DWC3_GSNPSID_MASK) >> 16) 72 73 73 74 /* DWC3 registers memory space boundries */ 74 75 #define DWC3_XHCI_REGS_START 0x0 ··· 366 365 #define DWC3_GHWPARAMS6_SRPSUPPORT BIT(10) 367 366 #define DWC3_GHWPARAMS6_EN_FPGA BIT(7) 368 367 368 + /* DWC_usb32 only */ 369 + #define DWC3_GHWPARAMS6_MDWIDTH(n) ((n) & (0x3 << 8)) 370 + 369 371 /* Global HWPARAMS7 Register */ 370 372 #define DWC3_GHWPARAMS7_RAM1_DEPTH(n) ((n) & 0xffff) 371 373 #define DWC3_GHWPARAMS7_RAM2_DEPTH(n) (((n) >> 16) & 0xffff) ··· 495 491 #define DWC3_DGCMD_SELECTED_FIFO_FLUSH 0x09 496 492 #define DWC3_DGCMD_ALL_FIFO_FLUSH 0x0a 497 493 #define DWC3_DGCMD_SET_ENDPOINT_NRDY 0x0c 494 + #define DWC3_DGCMD_SET_ENDPOINT_PRIME 0x0d 498 495 #define DWC3_DGCMD_RUN_SOC_BUS_LOOPBACK 0x10 499 496 500 497 #define DWC3_DGCMD_STATUS(n) (((n) >> 12) & 0x0F) ··· 702 697 #define DWC3_EP_END_TRANSFER_PENDING BIT(4) 703 698 #define DWC3_EP_PENDING_REQUEST BIT(5) 704 699 #define DWC3_EP_DELAY_START BIT(6) 700 + #define DWC3_EP_WAIT_TRANSFER_COMPLETE BIT(7) 701 + #define DWC3_EP_IGNORE_NEXT_NOSTREAM BIT(8) 702 + #define DWC3_EP_FORCE_RESTART_STREAM BIT(9) 703 + #define DWC3_EP_FIRST_STREAM_PRIMED BIT(10) 705 704 706 705 /* This last one is specific to EP0 */ 707 706 #define DWC3_EP0_DIR_IN BIT(31) ··· 958 949 * @nr_scratch: number of scratch buffers 959 950 * @u1u2: only used on revisions <1.83a for workaround 960 951 * @maximum_speed: maximum speed requested (mainly for testing purposes) 961 - * @revision: revision register contents 952 + * @ip: controller's ID 953 + * @revision: controller's version of an IP 962 954 * @version_type: VERSIONTYPE register contents, a sub release of a revision 963 955 * @dr_mode: requested mode of operation 964 956 * @current_dr_role: current role of operation when in dual-role mode ··· 1120 1110 u32 u1u2; 1121 1111 u32 maximum_speed; 1122 1112 1123 - /* 1124 - * All 3.1 IP version constants are greater than the 3.0 IP 1125 - * version constants. This works for most version checks in 1126 - * dwc3. However, in the future, this may not apply as 1127 - * features may be developed on newer versions of the 3.0 IP 1128 - * that are not in the 3.1 IP. 1129 - */ 1113 + u32 ip; 1114 + 1115 + #define DWC3_IP 0x5533 1116 + #define DWC31_IP 0x3331 1117 + #define DWC32_IP 0x3332 1118 + 1130 1119 u32 revision; 1131 1120 1121 + #define DWC3_REVISION_ANY 0x0 1132 1122 #define DWC3_REVISION_173A 0x5533173a 1133 1123 #define DWC3_REVISION_175A 0x5533175a 1134 1124 #define DWC3_REVISION_180A 0x5533180a ··· 1153 1143 #define DWC3_REVISION_310A 0x5533310a 1154 1144 #define DWC3_REVISION_330A 0x5533330a 1155 1145 1156 - /* 1157 - * NOTICE: we're using bit 31 as a "is usb 3.1" flag. This is really 1158 - * just so dwc31 revisions are always larger than dwc3. 1159 - */ 1160 - #define DWC3_REVISION_IS_DWC31 0x80000000 1161 - #define DWC3_USB31_REVISION_110A (0x3131302a | DWC3_REVISION_IS_DWC31) 1162 - #define DWC3_USB31_REVISION_120A (0x3132302a | DWC3_REVISION_IS_DWC31) 1163 - #define DWC3_USB31_REVISION_160A (0x3136302a | DWC3_REVISION_IS_DWC31) 1164 - #define DWC3_USB31_REVISION_170A (0x3137302a | DWC3_REVISION_IS_DWC31) 1165 - #define DWC3_USB31_REVISION_180A (0x3138302a | DWC3_REVISION_IS_DWC31) 1166 - #define DWC3_USB31_REVISION_190A (0x3139302a | DWC3_REVISION_IS_DWC31) 1146 + #define DWC31_REVISION_ANY 0x0 1147 + #define DWC31_REVISION_110A 0x3131302a 1148 + #define DWC31_REVISION_120A 0x3132302a 1149 + #define DWC31_REVISION_160A 0x3136302a 1150 + #define DWC31_REVISION_170A 0x3137302a 1151 + #define DWC31_REVISION_180A 0x3138302a 1152 + #define DWC31_REVISION_190A 0x3139302a 1153 + 1154 + #define DWC32_REVISION_ANY 0x0 1155 + #define DWC32_REVISION_100A 0x3130302a 1167 1156 1168 1157 u32 version_type; 1169 1158 1159 + #define DWC31_VERSIONTYPE_ANY 0x0 1170 1160 #define DWC31_VERSIONTYPE_EA01 0x65613031 1171 1161 #define DWC31_VERSIONTYPE_EA02 0x65613032 1172 1162 #define DWC31_VERSIONTYPE_EA03 0x65613033 ··· 1308 1298 #define DEPEVT_STREAMEVT_FOUND 1 1309 1299 #define DEPEVT_STREAMEVT_NOTFOUND 2 1310 1300 1301 + /* Stream event parameter */ 1302 + #define DEPEVT_STREAM_PRIME 0xfffe 1303 + #define DEPEVT_STREAM_NOSTREAM 0x0 1304 + 1311 1305 /* Control-only Status */ 1312 1306 #define DEPEVT_STATUS_CONTROL_DATA 1 1313 1307 #define DEPEVT_STATUS_CONTROL_STATUS 2 ··· 1414 1400 void dwc3_set_mode(struct dwc3 *dwc, u32 mode); 1415 1401 u32 dwc3_core_fifo_space(struct dwc3_ep *dep, u8 type); 1416 1402 1417 - /* check whether we are on the DWC_usb3 core */ 1418 - static inline bool dwc3_is_usb3(struct dwc3 *dwc) 1419 - { 1420 - return !(dwc->revision & DWC3_REVISION_IS_DWC31); 1421 - } 1403 + #define DWC3_IP_IS(_ip) \ 1404 + (dwc->ip == _ip##_IP) 1422 1405 1423 - /* check whether we are on the DWC_usb31 core */ 1424 - static inline bool dwc3_is_usb31(struct dwc3 *dwc) 1425 - { 1426 - return !!(dwc->revision & DWC3_REVISION_IS_DWC31); 1427 - } 1406 + #define DWC3_VER_IS(_ip, _ver) \ 1407 + (DWC3_IP_IS(_ip) && dwc->revision == _ip##_REVISION_##_ver) 1408 + 1409 + #define DWC3_VER_IS_PRIOR(_ip, _ver) \ 1410 + (DWC3_IP_IS(_ip) && dwc->revision < _ip##_REVISION_##_ver) 1411 + 1412 + #define DWC3_VER_IS_WITHIN(_ip, _from, _to) \ 1413 + (DWC3_IP_IS(_ip) && \ 1414 + dwc->revision >= _ip##_REVISION_##_from && \ 1415 + (!(_ip##_REVISION_##_to) || \ 1416 + dwc->revision <= _ip##_REVISION_##_to)) 1417 + 1418 + #define DWC3_VER_TYPE_IS_WITHIN(_ip, _ver, _from, _to) \ 1419 + (DWC3_VER_IS(_ip, _ver) && \ 1420 + dwc->version_type >= _ip##_VERSIONTYPE_##_from && \ 1421 + (!(_ip##_VERSIONTYPE_##_to) || \ 1422 + dwc->version_type <= _ip##_VERSIONTYPE_##_to)) 1428 1423 1429 1424 bool dwc3_has_imod(struct dwc3 *dwc); 1430 1425
+3 -1
drivers/usb/dwc3/debug.h
··· 1 - // SPDX-License-Identifier: GPL-2.0 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 2 /** 3 3 * debug.h - DesignWare USB3 DRD Controller Debug Header 4 4 * ··· 68 68 return "All FIFO Flush"; 69 69 case DWC3_DGCMD_SET_ENDPOINT_NRDY: 70 70 return "Set Endpoint NRDY"; 71 + case DWC3_DGCMD_SET_ENDPOINT_PRIME: 72 + return "Set Endpoint Prime"; 71 73 case DWC3_DGCMD_RUN_SOC_BUS_LOOPBACK: 72 74 return "Run SoC Bus Loopback Test"; 73 75 default:
+12 -2
drivers/usb/dwc3/debugfs.c
··· 635 635 struct dwc3_ep *dep = s->private; 636 636 struct dwc3 *dwc = dep->dwc; 637 637 unsigned long flags; 638 + int mdwidth; 638 639 u32 val; 639 640 640 641 spin_lock_irqsave(&dwc->lock, flags); 641 642 val = dwc3_core_fifo_space(dep, DWC3_TXFIFO); 642 643 643 644 /* Convert to bytes */ 644 - val *= DWC3_MDWIDTH(dwc->hwparams.hwparams0); 645 + mdwidth = DWC3_MDWIDTH(dwc->hwparams.hwparams0); 646 + if (DWC3_IP_IS(DWC32)) 647 + mdwidth += DWC3_GHWPARAMS6_MDWIDTH(dwc->hwparams.hwparams6); 648 + 649 + val *= mdwidth; 645 650 val >>= 3; 646 651 seq_printf(s, "%u\n", val); 647 652 spin_unlock_irqrestore(&dwc->lock, flags); ··· 659 654 struct dwc3_ep *dep = s->private; 660 655 struct dwc3 *dwc = dep->dwc; 661 656 unsigned long flags; 657 + int mdwidth; 662 658 u32 val; 663 659 664 660 spin_lock_irqsave(&dwc->lock, flags); 665 661 val = dwc3_core_fifo_space(dep, DWC3_RXFIFO); 666 662 667 663 /* Convert to bytes */ 668 - val *= DWC3_MDWIDTH(dwc->hwparams.hwparams0); 664 + mdwidth = DWC3_MDWIDTH(dwc->hwparams.hwparams0); 665 + if (DWC3_IP_IS(DWC32)) 666 + mdwidth += DWC3_GHWPARAMS6_MDWIDTH(dwc->hwparams.hwparams6); 667 + 668 + val *= mdwidth; 669 669 val >>= 3; 670 670 seq_printf(s, "%u\n", val); 671 671 spin_unlock_irqrestore(&dwc->lock, flags);
+3 -3
drivers/usb/dwc3/drd.c
··· 56 56 spin_lock(&dwc->lock); 57 57 if (dwc->otg_restart_host) { 58 58 dwc3_otg_host_init(dwc); 59 - dwc->otg_restart_host = 0; 59 + dwc->otg_restart_host = false; 60 60 } 61 61 62 62 spin_unlock(&dwc->lock); ··· 82 82 83 83 if (dwc->current_otg_role == DWC3_OTG_ROLE_HOST && 84 84 !(reg & DWC3_OEVT_DEVICEMODE)) 85 - dwc->otg_restart_host = 1; 85 + dwc->otg_restart_host = true; 86 86 dwc3_writel(dwc->regs, DWC3_OEVT, reg); 87 87 ret = IRQ_WAKE_THREAD; 88 88 } ··· 653 653 break; 654 654 } 655 655 656 - if (!dwc->edev) 656 + if (dwc->otg_irq) 657 657 free_irq(dwc->otg_irq, dwc); 658 658 }
+40 -1
drivers/usb/dwc3/dwc3-keystone.c
··· 14 14 #include <linux/dma-mapping.h> 15 15 #include <linux/io.h> 16 16 #include <linux/of_platform.h> 17 + #include <linux/phy/phy.h> 17 18 #include <linux/pm_runtime.h> 18 19 19 20 /* USBSS register offsets */ ··· 35 34 struct dwc3_keystone { 36 35 struct device *dev; 37 36 void __iomem *usbss; 37 + struct phy *usb3_phy; 38 38 }; 39 39 40 40 static inline u32 kdwc3_readl(void __iomem *base, u32 offset) ··· 97 95 if (IS_ERR(kdwc->usbss)) 98 96 return PTR_ERR(kdwc->usbss); 99 97 100 - pm_runtime_enable(kdwc->dev); 98 + /* PSC dependency on AM65 needs SERDES0 to be powered before USB0 */ 99 + kdwc->usb3_phy = devm_phy_optional_get(dev, "usb3-phy"); 100 + if (IS_ERR(kdwc->usb3_phy)) { 101 + error = PTR_ERR(kdwc->usb3_phy); 102 + if (error != -EPROBE_DEFER) 103 + dev_err(dev, "couldn't get usb3 phy: %d\n", error); 101 104 105 + return error; 106 + } 107 + 108 + phy_pm_runtime_get_sync(kdwc->usb3_phy); 109 + 110 + error = phy_reset(kdwc->usb3_phy); 111 + if (error < 0) { 112 + dev_err(dev, "usb3 phy reset failed: %d\n", error); 113 + return error; 114 + } 115 + 116 + error = phy_init(kdwc->usb3_phy); 117 + if (error < 0) { 118 + dev_err(dev, "usb3 phy init failed: %d\n", error); 119 + return error; 120 + } 121 + 122 + error = phy_power_on(kdwc->usb3_phy); 123 + if (error < 0) { 124 + dev_err(dev, "usb3 phy power on failed: %d\n", error); 125 + phy_exit(kdwc->usb3_phy); 126 + return error; 127 + } 128 + 129 + pm_runtime_enable(kdwc->dev); 102 130 error = pm_runtime_get_sync(kdwc->dev); 103 131 if (error < 0) { 104 132 dev_err(kdwc->dev, "pm_runtime_get_sync failed, error %d\n", ··· 170 138 err_irq: 171 139 pm_runtime_put_sync(kdwc->dev); 172 140 pm_runtime_disable(kdwc->dev); 141 + phy_power_off(kdwc->usb3_phy); 142 + phy_exit(kdwc->usb3_phy); 143 + phy_pm_runtime_put_sync(kdwc->usb3_phy); 173 144 174 145 return error; 175 146 } ··· 197 162 device_for_each_child(&pdev->dev, NULL, kdwc3_remove_core); 198 163 pm_runtime_put_sync(kdwc->dev); 199 164 pm_runtime_disable(kdwc->dev); 165 + 166 + phy_power_off(kdwc->usb3_phy); 167 + phy_exit(kdwc->usb3_phy); 168 + phy_pm_runtime_put_sync(kdwc->usb3_phy); 200 169 201 170 platform_set_drvdata(pdev, NULL); 202 171
+338 -82
drivers/usb/dwc3/dwc3-meson-g12a.c
··· 30 30 #include <linux/usb/role.h> 31 31 #include <linux/regulator/consumer.h> 32 32 33 - /* USB2 Ports Control Registers */ 33 + /* USB2 Ports Control Registers, offsets are per-port */ 34 34 35 35 #define U2P_REG_SIZE 0x20 36 36 ··· 50 50 51 51 /* USB Glue Control Registers */ 52 52 53 - #define USB_R0 0x80 53 + #define G12A_GLUE_OFFSET 0x80 54 + 55 + #define USB_R0 0x00 54 56 #define USB_R0_P30_LANE0_TX2RX_LOOPBACK BIT(17) 55 57 #define USB_R0_P30_LANE0_EXT_PCLK_REQ BIT(18) 56 58 #define USB_R0_P30_PCS_RX_LOS_MASK_VAL_MASK GENMASK(28, 19) 57 59 #define USB_R0_U2D_SS_SCALEDOWN_MODE_MASK GENMASK(30, 29) 58 60 #define USB_R0_U2D_ACT BIT(31) 59 61 60 - #define USB_R1 0x84 62 + #define USB_R1 0x04 61 63 #define USB_R1_U3H_BIGENDIAN_GS BIT(0) 62 64 #define USB_R1_U3H_PME_ENABLE BIT(1) 63 65 #define USB_R1_U3H_HUB_PORT_OVERCURRENT_MASK GENMASK(4, 2) ··· 71 69 #define USB_R1_U3H_FLADJ_30MHZ_REG_MASK GENMASK(24, 19) 72 70 #define USB_R1_P30_PCS_TX_SWING_FULL_MASK GENMASK(31, 25) 73 71 74 - #define USB_R2 0x88 72 + #define USB_R2 0x08 75 73 #define USB_R2_P30_PCS_TX_DEEMPH_3P5DB_MASK GENMASK(25, 20) 76 74 #define USB_R2_P30_PCS_TX_DEEMPH_6DB_MASK GENMASK(31, 26) 77 75 78 - #define USB_R3 0x8c 76 + #define USB_R3 0x0c 79 77 #define USB_R3_P30_SSC_ENABLE BIT(0) 80 78 #define USB_R3_P30_SSC_RANGE_MASK GENMASK(3, 1) 81 79 #define USB_R3_P30_SSC_REF_CLK_SEL_MASK GENMASK(12, 4) 82 80 #define USB_R3_P30_REF_SSP_EN BIT(13) 83 81 84 - #define USB_R4 0x90 82 + #define USB_R4 0x10 85 83 #define USB_R4_P21_PORT_RESET_0 BIT(0) 86 84 #define USB_R4_P21_SLEEP_M0 BIT(1) 87 85 #define USB_R4_MEM_PD_MASK GENMASK(3, 2) 88 86 #define USB_R4_P21_ONLY BIT(4) 89 87 90 - #define USB_R5 0x94 88 + #define USB_R5 0x14 91 89 #define USB_R5_ID_DIG_SYNC BIT(0) 92 90 #define USB_R5_ID_DIG_REG BIT(1) 93 91 #define USB_R5_ID_DIG_CFG_MASK GENMASK(3, 2) ··· 98 96 #define USB_R5_ID_DIG_TH_MASK GENMASK(15, 8) 99 97 #define USB_R5_ID_DIG_CNT_MASK GENMASK(23, 16) 100 98 101 - enum { 102 - USB2_HOST_PHY = 0, 103 - USB2_OTG_PHY, 104 - USB3_HOST_PHY, 105 - PHY_COUNT, 106 - }; 99 + #define PHY_COUNT 3 100 + #define USB2_OTG_PHY 1 107 101 108 - static const char *phy_names[PHY_COUNT] = { 109 - "usb2-phy0", "usb2-phy1", "usb3-phy0", 102 + static struct clk_bulk_data meson_gxl_clocks[] = { 103 + { .id = "usb_ctrl" }, 104 + { .id = "ddr" }, 110 105 }; 111 106 112 107 static struct clk_bulk_data meson_g12a_clocks[] = { ··· 116 117 { .id = "xtal_usb_ctrl" }, 117 118 }; 118 119 120 + static const char *meson_gxm_phy_names[] = { 121 + "usb2-phy0", "usb2-phy1", "usb2-phy2", 122 + }; 123 + 124 + static const char *meson_g12a_phy_names[] = { 125 + "usb2-phy0", "usb2-phy1", "usb3-phy0", 126 + }; 127 + 128 + /* 129 + * Amlogic A1 has a single physical PHY, in slot 1, but still has the 130 + * two U2 PHY controls register blocks like G12A. 131 + * Handling the first PHY on slot 1 would need a large amount of code 132 + * changes, and the current management is generic enough to handle it 133 + * correctly when only the "usb2-phy1" phy is specified on-par with the 134 + * DT bindings. 135 + */ 136 + static const char *meson_a1_phy_names[] = { 137 + "usb2-phy0", "usb2-phy1" 138 + }; 139 + 140 + struct dwc3_meson_g12a; 141 + 119 142 struct dwc3_meson_g12a_drvdata { 120 143 bool otg_switch_supported; 144 + bool otg_phy_host_port_disable; 121 145 struct clk_bulk_data *clks; 122 146 int num_clks; 147 + const char **phy_names; 148 + int num_phys; 149 + int (*setup_regmaps)(struct dwc3_meson_g12a *priv, void __iomem *base); 150 + int (*usb2_init_phy)(struct dwc3_meson_g12a *priv, int i, 151 + enum phy_mode mode); 152 + int (*set_phy_mode)(struct dwc3_meson_g12a *priv, int i, 153 + enum phy_mode mode); 154 + int (*usb_init)(struct dwc3_meson_g12a *priv); 155 + int (*usb_post_init)(struct dwc3_meson_g12a *priv); 156 + }; 157 + 158 + static int dwc3_meson_gxl_setup_regmaps(struct dwc3_meson_g12a *priv, 159 + void __iomem *base); 160 + static int dwc3_meson_g12a_setup_regmaps(struct dwc3_meson_g12a *priv, 161 + void __iomem *base); 162 + 163 + static int dwc3_meson_g12a_usb2_init_phy(struct dwc3_meson_g12a *priv, int i, 164 + enum phy_mode mode); 165 + static int dwc3_meson_gxl_usb2_init_phy(struct dwc3_meson_g12a *priv, int i, 166 + enum phy_mode mode); 167 + 168 + static int dwc3_meson_g12a_set_phy_mode(struct dwc3_meson_g12a *priv, 169 + int i, enum phy_mode mode); 170 + static int dwc3_meson_gxl_set_phy_mode(struct dwc3_meson_g12a *priv, 171 + int i, enum phy_mode mode); 172 + 173 + static int dwc3_meson_g12a_usb_init(struct dwc3_meson_g12a *priv); 174 + static int dwc3_meson_gxl_usb_init(struct dwc3_meson_g12a *priv); 175 + 176 + static int dwc3_meson_gxl_usb_post_init(struct dwc3_meson_g12a *priv); 177 + 178 + /* 179 + * For GXL and GXM SoCs: 180 + * USB Phy muxing between the DWC2 Device controller and the DWC3 Host 181 + * controller is buggy when switching from Device to Host when USB port 182 + * is unpopulated, it causes the DWC3 to hard crash. 183 + * When populated (including OTG switching with ID pin), the switch works 184 + * like a charm like on the G12A platforms. 185 + * In order to still switch from Host to Device on an USB Type-A port, 186 + * an U2_PORT_DISABLE bit has been added to disconnect the DWC3 Host 187 + * controller from the port, but when used the DWC3 controller must be 188 + * reset to recover usage of the port. 189 + */ 190 + 191 + static struct dwc3_meson_g12a_drvdata gxl_drvdata = { 192 + .otg_switch_supported = true, 193 + .otg_phy_host_port_disable = true, 194 + .clks = meson_gxl_clocks, 195 + .num_clks = ARRAY_SIZE(meson_g12a_clocks), 196 + .phy_names = meson_a1_phy_names, 197 + .num_phys = ARRAY_SIZE(meson_a1_phy_names), 198 + .setup_regmaps = dwc3_meson_gxl_setup_regmaps, 199 + .usb2_init_phy = dwc3_meson_gxl_usb2_init_phy, 200 + .set_phy_mode = dwc3_meson_gxl_set_phy_mode, 201 + .usb_init = dwc3_meson_gxl_usb_init, 202 + .usb_post_init = dwc3_meson_gxl_usb_post_init, 203 + }; 204 + 205 + static struct dwc3_meson_g12a_drvdata gxm_drvdata = { 206 + .otg_switch_supported = true, 207 + .otg_phy_host_port_disable = true, 208 + .clks = meson_gxl_clocks, 209 + .num_clks = ARRAY_SIZE(meson_g12a_clocks), 210 + .phy_names = meson_gxm_phy_names, 211 + .num_phys = ARRAY_SIZE(meson_gxm_phy_names), 212 + .setup_regmaps = dwc3_meson_gxl_setup_regmaps, 213 + .usb2_init_phy = dwc3_meson_gxl_usb2_init_phy, 214 + .set_phy_mode = dwc3_meson_gxl_set_phy_mode, 215 + .usb_init = dwc3_meson_gxl_usb_init, 216 + .usb_post_init = dwc3_meson_gxl_usb_post_init, 123 217 }; 124 218 125 219 static struct dwc3_meson_g12a_drvdata g12a_drvdata = { 126 220 .otg_switch_supported = true, 127 221 .clks = meson_g12a_clocks, 128 222 .num_clks = ARRAY_SIZE(meson_g12a_clocks), 223 + .phy_names = meson_g12a_phy_names, 224 + .num_phys = ARRAY_SIZE(meson_g12a_phy_names), 225 + .setup_regmaps = dwc3_meson_g12a_setup_regmaps, 226 + .usb2_init_phy = dwc3_meson_g12a_usb2_init_phy, 227 + .set_phy_mode = dwc3_meson_g12a_set_phy_mode, 228 + .usb_init = dwc3_meson_g12a_usb_init, 129 229 }; 130 230 131 231 static struct dwc3_meson_g12a_drvdata a1_drvdata = { 132 232 .otg_switch_supported = false, 133 233 .clks = meson_a1_clocks, 134 234 .num_clks = ARRAY_SIZE(meson_a1_clocks), 235 + .phy_names = meson_a1_phy_names, 236 + .num_phys = ARRAY_SIZE(meson_a1_phy_names), 237 + .setup_regmaps = dwc3_meson_g12a_setup_regmaps, 238 + .usb2_init_phy = dwc3_meson_g12a_usb2_init_phy, 239 + .set_phy_mode = dwc3_meson_g12a_set_phy_mode, 240 + .usb_init = dwc3_meson_g12a_usb_init, 135 241 }; 136 242 137 243 struct dwc3_meson_g12a { 138 244 struct device *dev; 139 - struct regmap *regmap; 245 + struct regmap *u2p_regmap[PHY_COUNT]; 246 + struct regmap *usb_glue_regmap; 140 247 struct reset_control *reset; 141 248 struct phy *phys[PHY_COUNT]; 142 249 enum usb_dr_mode otg_mode; ··· 255 150 const struct dwc3_meson_g12a_drvdata *drvdata; 256 151 }; 257 152 258 - static void dwc3_meson_g12a_usb2_set_mode(struct dwc3_meson_g12a *priv, 259 - int i, enum phy_mode mode) 153 + static int dwc3_meson_gxl_set_phy_mode(struct dwc3_meson_g12a *priv, 154 + int i, enum phy_mode mode) 155 + { 156 + return phy_set_mode(priv->phys[i], mode); 157 + } 158 + 159 + static int dwc3_meson_gxl_usb2_init_phy(struct dwc3_meson_g12a *priv, int i, 160 + enum phy_mode mode) 161 + { 162 + /* On GXL PHY must be started in device mode for DWC2 init */ 163 + return priv->drvdata->set_phy_mode(priv, i, 164 + (i == USB2_OTG_PHY) ? PHY_MODE_USB_DEVICE 165 + : PHY_MODE_USB_HOST); 166 + } 167 + 168 + static int dwc3_meson_g12a_set_phy_mode(struct dwc3_meson_g12a *priv, 169 + int i, enum phy_mode mode) 260 170 { 261 171 if (mode == PHY_MODE_USB_HOST) 262 - regmap_update_bits(priv->regmap, U2P_R0 + (U2P_REG_SIZE * i), 172 + regmap_update_bits(priv->u2p_regmap[i], U2P_R0, 263 173 U2P_R0_HOST_DEVICE, 264 174 U2P_R0_HOST_DEVICE); 265 175 else 266 - regmap_update_bits(priv->regmap, U2P_R0 + (U2P_REG_SIZE * i), 176 + regmap_update_bits(priv->u2p_regmap[i], U2P_R0, 267 177 U2P_R0_HOST_DEVICE, 0); 178 + 179 + return 0; 268 180 } 269 181 270 - static int dwc3_meson_g12a_usb2_init(struct dwc3_meson_g12a *priv) 182 + static int dwc3_meson_g12a_usb2_init_phy(struct dwc3_meson_g12a *priv, int i, 183 + enum phy_mode mode) 271 184 { 272 - int i; 185 + int ret; 273 186 274 - if (priv->otg_mode == USB_DR_MODE_PERIPHERAL) 275 - priv->otg_phy_mode = PHY_MODE_USB_DEVICE; 276 - else 277 - priv->otg_phy_mode = PHY_MODE_USB_HOST; 187 + regmap_update_bits(priv->u2p_regmap[i], U2P_R0, 188 + U2P_R0_POWER_ON_RESET, 189 + U2P_R0_POWER_ON_RESET); 278 190 279 - for (i = 0 ; i < USB3_HOST_PHY ; ++i) { 191 + if (priv->drvdata->otg_switch_supported && i == USB2_OTG_PHY) { 192 + regmap_update_bits(priv->u2p_regmap[i], U2P_R0, 193 + U2P_R0_ID_PULLUP | U2P_R0_DRV_VBUS, 194 + U2P_R0_ID_PULLUP | U2P_R0_DRV_VBUS); 195 + 196 + ret = priv->drvdata->set_phy_mode(priv, i, mode); 197 + } else 198 + ret = priv->drvdata->set_phy_mode(priv, i, 199 + PHY_MODE_USB_HOST); 200 + 201 + if (ret) 202 + return ret; 203 + 204 + regmap_update_bits(priv->u2p_regmap[i], U2P_R0, 205 + U2P_R0_POWER_ON_RESET, 0); 206 + 207 + return 0; 208 + } 209 + 210 + static int dwc3_meson_g12a_usb2_init(struct dwc3_meson_g12a *priv, 211 + enum phy_mode mode) 212 + { 213 + int i, ret; 214 + 215 + for (i = 0; i < priv->drvdata->num_phys; ++i) { 280 216 if (!priv->phys[i]) 281 217 continue; 282 218 283 - regmap_update_bits(priv->regmap, U2P_R0 + (U2P_REG_SIZE * i), 284 - U2P_R0_POWER_ON_RESET, 285 - U2P_R0_POWER_ON_RESET); 219 + if (!strstr(priv->drvdata->phy_names[i], "usb2")) 220 + continue; 286 221 287 - if (priv->drvdata->otg_switch_supported && i == USB2_OTG_PHY) { 288 - regmap_update_bits(priv->regmap, 289 - U2P_R0 + (U2P_REG_SIZE * i), 290 - U2P_R0_ID_PULLUP | U2P_R0_DRV_VBUS, 291 - U2P_R0_ID_PULLUP | U2P_R0_DRV_VBUS); 292 - 293 - dwc3_meson_g12a_usb2_set_mode(priv, i, 294 - priv->otg_phy_mode); 295 - } else 296 - dwc3_meson_g12a_usb2_set_mode(priv, i, 297 - PHY_MODE_USB_HOST); 298 - 299 - regmap_update_bits(priv->regmap, U2P_R0 + (U2P_REG_SIZE * i), 300 - U2P_R0_POWER_ON_RESET, 0); 222 + ret = priv->drvdata->usb2_init_phy(priv, i, mode); 223 + if (ret) 224 + return ret; 301 225 } 302 226 303 227 return 0; ··· 334 200 335 201 static void dwc3_meson_g12a_usb3_init(struct dwc3_meson_g12a *priv) 336 202 { 337 - regmap_update_bits(priv->regmap, USB_R3, 203 + regmap_update_bits(priv->usb_glue_regmap, USB_R3, 338 204 USB_R3_P30_SSC_RANGE_MASK | 339 205 USB_R3_P30_REF_SSP_EN, 340 206 USB_R3_P30_SSC_ENABLE | ··· 342 208 USB_R3_P30_REF_SSP_EN); 343 209 udelay(2); 344 210 345 - regmap_update_bits(priv->regmap, USB_R2, 211 + regmap_update_bits(priv->usb_glue_regmap, USB_R2, 346 212 USB_R2_P30_PCS_TX_DEEMPH_3P5DB_MASK, 347 213 FIELD_PREP(USB_R2_P30_PCS_TX_DEEMPH_3P5DB_MASK, 0x15)); 348 214 349 - regmap_update_bits(priv->regmap, USB_R2, 215 + regmap_update_bits(priv->usb_glue_regmap, USB_R2, 350 216 USB_R2_P30_PCS_TX_DEEMPH_6DB_MASK, 351 217 FIELD_PREP(USB_R2_P30_PCS_TX_DEEMPH_6DB_MASK, 0x20)); 352 218 353 219 udelay(2); 354 220 355 - regmap_update_bits(priv->regmap, USB_R1, 221 + regmap_update_bits(priv->usb_glue_regmap, USB_R1, 356 222 USB_R1_U3H_HOST_PORT_POWER_CONTROL_PRESENT, 357 223 USB_R1_U3H_HOST_PORT_POWER_CONTROL_PRESENT); 358 224 359 - regmap_update_bits(priv->regmap, USB_R1, 225 + regmap_update_bits(priv->usb_glue_regmap, USB_R1, 360 226 USB_R1_P30_PCS_TX_SWING_FULL_MASK, 361 227 FIELD_PREP(USB_R1_P30_PCS_TX_SWING_FULL_MASK, 127)); 362 228 } 363 229 364 - static void dwc3_meson_g12a_usb_otg_apply_mode(struct dwc3_meson_g12a *priv) 230 + static void dwc3_meson_g12a_usb_otg_apply_mode(struct dwc3_meson_g12a *priv, 231 + enum phy_mode mode) 365 232 { 366 - if (priv->otg_phy_mode == PHY_MODE_USB_DEVICE) { 367 - regmap_update_bits(priv->regmap, USB_R0, 233 + if (mode == PHY_MODE_USB_DEVICE) { 234 + if (priv->otg_mode != USB_DR_MODE_OTG && 235 + priv->drvdata->otg_phy_host_port_disable) 236 + /* Isolate the OTG PHY port from the Host Controller */ 237 + regmap_update_bits(priv->usb_glue_regmap, USB_R1, 238 + USB_R1_U3H_HOST_U2_PORT_DISABLE_MASK, 239 + FIELD_PREP(USB_R1_U3H_HOST_U2_PORT_DISABLE_MASK, 240 + BIT(USB2_OTG_PHY))); 241 + 242 + regmap_update_bits(priv->usb_glue_regmap, USB_R0, 368 243 USB_R0_U2D_ACT, USB_R0_U2D_ACT); 369 - regmap_update_bits(priv->regmap, USB_R0, 244 + regmap_update_bits(priv->usb_glue_regmap, USB_R0, 370 245 USB_R0_U2D_SS_SCALEDOWN_MODE_MASK, 0); 371 - regmap_update_bits(priv->regmap, USB_R4, 246 + regmap_update_bits(priv->usb_glue_regmap, USB_R4, 372 247 USB_R4_P21_SLEEP_M0, USB_R4_P21_SLEEP_M0); 373 248 } else { 374 - regmap_update_bits(priv->regmap, USB_R0, 249 + if (priv->otg_mode != USB_DR_MODE_OTG && 250 + priv->drvdata->otg_phy_host_port_disable) { 251 + regmap_update_bits(priv->usb_glue_regmap, USB_R1, 252 + USB_R1_U3H_HOST_U2_PORT_DISABLE_MASK, 0); 253 + msleep(500); 254 + } 255 + regmap_update_bits(priv->usb_glue_regmap, USB_R0, 375 256 USB_R0_U2D_ACT, 0); 376 - regmap_update_bits(priv->regmap, USB_R4, 257 + regmap_update_bits(priv->usb_glue_regmap, USB_R4, 377 258 USB_R4_P21_SLEEP_M0, 0); 378 259 } 379 260 } 380 261 381 - static int dwc3_meson_g12a_usb_init(struct dwc3_meson_g12a *priv) 262 + static int dwc3_meson_g12a_usb_init_glue(struct dwc3_meson_g12a *priv, 263 + enum phy_mode mode) 382 264 { 383 265 int ret; 384 266 385 - ret = dwc3_meson_g12a_usb2_init(priv); 267 + ret = dwc3_meson_g12a_usb2_init(priv, mode); 386 268 if (ret) 387 269 return ret; 388 270 389 - regmap_update_bits(priv->regmap, USB_R1, 271 + regmap_update_bits(priv->usb_glue_regmap, USB_R1, 390 272 USB_R1_U3H_FLADJ_30MHZ_REG_MASK, 391 273 FIELD_PREP(USB_R1_U3H_FLADJ_30MHZ_REG_MASK, 0x20)); 392 274 393 - regmap_update_bits(priv->regmap, USB_R5, 275 + regmap_update_bits(priv->usb_glue_regmap, USB_R5, 394 276 USB_R5_ID_DIG_EN_0, 395 277 USB_R5_ID_DIG_EN_0); 396 - regmap_update_bits(priv->regmap, USB_R5, 278 + regmap_update_bits(priv->usb_glue_regmap, USB_R5, 397 279 USB_R5_ID_DIG_EN_1, 398 280 USB_R5_ID_DIG_EN_1); 399 - regmap_update_bits(priv->regmap, USB_R5, 281 + regmap_update_bits(priv->usb_glue_regmap, USB_R5, 400 282 USB_R5_ID_DIG_TH_MASK, 401 283 FIELD_PREP(USB_R5_ID_DIG_TH_MASK, 0xff)); 402 284 ··· 420 270 if (priv->usb3_ports) 421 271 dwc3_meson_g12a_usb3_init(priv); 422 272 423 - dwc3_meson_g12a_usb_otg_apply_mode(priv); 273 + dwc3_meson_g12a_usb_otg_apply_mode(priv, mode); 424 274 425 275 return 0; 426 276 } 427 277 428 - static const struct regmap_config phy_meson_g12a_usb3_regmap_conf = { 278 + static const struct regmap_config phy_meson_g12a_usb_glue_regmap_conf = { 279 + .name = "usb-glue", 429 280 .reg_bits = 8, 430 281 .val_bits = 32, 431 282 .reg_stride = 4, ··· 435 284 436 285 static int dwc3_meson_g12a_get_phys(struct dwc3_meson_g12a *priv) 437 286 { 287 + const char *phy_name; 438 288 int i; 439 289 440 - for (i = 0 ; i < PHY_COUNT ; ++i) { 441 - priv->phys[i] = devm_phy_optional_get(priv->dev, phy_names[i]); 290 + for (i = 0 ; i < priv->drvdata->num_phys ; ++i) { 291 + phy_name = priv->drvdata->phy_names[i]; 292 + priv->phys[i] = devm_phy_optional_get(priv->dev, phy_name); 442 293 if (!priv->phys[i]) 443 294 continue; 444 295 445 296 if (IS_ERR(priv->phys[i])) 446 297 return PTR_ERR(priv->phys[i]); 447 298 448 - if (i == USB3_HOST_PHY) 299 + if (strstr(phy_name, "usb3")) 449 300 priv->usb3_ports++; 450 301 else 451 302 priv->usb2_ports++; ··· 463 310 { 464 311 u32 reg; 465 312 466 - regmap_read(priv->regmap, USB_R5, &reg); 313 + regmap_read(priv->usb_glue_regmap, USB_R5, &reg); 467 314 468 315 if (reg & (USB_R5_ID_DIG_SYNC | USB_R5_ID_DIG_REG)) 469 316 return PHY_MODE_USB_DEVICE; ··· 495 342 496 343 priv->otg_phy_mode = mode; 497 344 498 - dwc3_meson_g12a_usb2_set_mode(priv, USB2_OTG_PHY, mode); 345 + ret = priv->drvdata->set_phy_mode(priv, USB2_OTG_PHY, mode); 346 + if (ret) 347 + return ret; 499 348 500 - dwc3_meson_g12a_usb_otg_apply_mode(priv); 349 + dwc3_meson_g12a_usb_otg_apply_mode(priv, mode); 501 350 502 351 return 0; 503 352 } ··· 518 363 519 364 if (mode == priv->otg_phy_mode) 520 365 return 0; 366 + 367 + if (priv->drvdata->otg_phy_host_port_disable) 368 + dev_warn_once(priv->dev, "Manual OTG switch is broken on this "\ 369 + "SoC, when manual switching from "\ 370 + "Host to device, DWC3 controller "\ 371 + "will need to be resetted in order "\ 372 + "to recover usage of the Host port"); 521 373 522 374 return dwc3_meson_g12a_otg_mode_set(priv, mode); 523 375 } ··· 548 386 dev_warn(priv->dev, "Failed to switch OTG mode\n"); 549 387 } 550 388 551 - regmap_update_bits(priv->regmap, USB_R5, USB_R5_ID_DIG_IRQ, 0); 389 + regmap_update_bits(priv->usb_glue_regmap, USB_R5, 390 + USB_R5_ID_DIG_IRQ, 0); 552 391 553 392 return IRQ_HANDLED; 554 393 } ··· 584 421 585 422 if (priv->otg_mode == USB_DR_MODE_OTG) { 586 423 /* Ack irq before registering */ 587 - regmap_update_bits(priv->regmap, USB_R5, 424 + regmap_update_bits(priv->usb_glue_regmap, USB_R5, 588 425 USB_R5_ID_DIG_IRQ, 0); 589 426 590 427 irq = platform_get_irq(pdev, 0); ··· 620 457 return 0; 621 458 } 622 459 460 + static int dwc3_meson_gxl_setup_regmaps(struct dwc3_meson_g12a *priv, 461 + void __iomem *base) 462 + { 463 + /* GXL controls the PHY mode in the PHY registers unlike G12A */ 464 + priv->usb_glue_regmap = devm_regmap_init_mmio(priv->dev, base, 465 + &phy_meson_g12a_usb_glue_regmap_conf); 466 + if (IS_ERR(priv->usb_glue_regmap)) 467 + return PTR_ERR(priv->usb_glue_regmap); 468 + 469 + return 0; 470 + } 471 + 472 + static int dwc3_meson_g12a_setup_regmaps(struct dwc3_meson_g12a *priv, 473 + void __iomem *base) 474 + { 475 + int i; 476 + 477 + priv->usb_glue_regmap = devm_regmap_init_mmio(priv->dev, 478 + base + G12A_GLUE_OFFSET, 479 + &phy_meson_g12a_usb_glue_regmap_conf); 480 + if (IS_ERR(priv->usb_glue_regmap)) 481 + return PTR_ERR(priv->usb_glue_regmap); 482 + 483 + /* Create a regmap for each USB2 PHY control register set */ 484 + for (i = 0; i < priv->usb2_ports; i++) { 485 + struct regmap_config u2p_regmap_config = { 486 + .reg_bits = 8, 487 + .val_bits = 32, 488 + .reg_stride = 4, 489 + .max_register = U2P_R1, 490 + }; 491 + 492 + u2p_regmap_config.name = devm_kasprintf(priv->dev, GFP_KERNEL, 493 + "u2p-%d", i); 494 + if (!u2p_regmap_config.name) 495 + return -ENOMEM; 496 + 497 + priv->u2p_regmap[i] = devm_regmap_init_mmio(priv->dev, 498 + base + (i * U2P_REG_SIZE), 499 + &u2p_regmap_config); 500 + if (IS_ERR(priv->u2p_regmap[i])) 501 + return PTR_ERR(priv->u2p_regmap[i]); 502 + } 503 + 504 + return 0; 505 + } 506 + 507 + static int dwc3_meson_g12a_usb_init(struct dwc3_meson_g12a *priv) 508 + { 509 + return dwc3_meson_g12a_usb_init_glue(priv, priv->otg_phy_mode); 510 + } 511 + 512 + static int dwc3_meson_gxl_usb_init(struct dwc3_meson_g12a *priv) 513 + { 514 + return dwc3_meson_g12a_usb_init_glue(priv, PHY_MODE_USB_DEVICE); 515 + } 516 + 517 + static int dwc3_meson_gxl_usb_post_init(struct dwc3_meson_g12a *priv) 518 + { 519 + int ret; 520 + 521 + ret = priv->drvdata->set_phy_mode(priv, USB2_OTG_PHY, 522 + priv->otg_phy_mode); 523 + if (ret) 524 + return ret; 525 + 526 + dwc3_meson_g12a_usb_otg_apply_mode(priv, priv->otg_phy_mode); 527 + 528 + return 0; 529 + } 530 + 623 531 static int dwc3_meson_g12a_probe(struct platform_device *pdev) 624 532 { 625 533 struct dwc3_meson_g12a *priv; ··· 707 473 if (IS_ERR(base)) 708 474 return PTR_ERR(base); 709 475 710 - priv->regmap = devm_regmap_init_mmio(dev, base, 711 - &phy_meson_g12a_usb3_regmap_conf); 712 - if (IS_ERR(priv->regmap)) 713 - return PTR_ERR(priv->regmap); 476 + priv->drvdata = of_device_get_match_data(&pdev->dev); 477 + 478 + priv->dev = dev; 479 + ret = priv->drvdata->setup_regmaps(priv, base); 480 + if (ret) 481 + return ret; 714 482 715 483 priv->vbus = devm_regulator_get_optional(dev, "vbus"); 716 484 if (IS_ERR(priv->vbus)) { ··· 720 484 return PTR_ERR(priv->vbus); 721 485 priv->vbus = NULL; 722 486 } 723 - 724 - priv->drvdata = of_device_get_match_data(&pdev->dev); 725 487 726 488 ret = devm_clk_bulk_get(dev, 727 489 priv->drvdata->num_clks, ··· 733 499 return ret; 734 500 735 501 platform_set_drvdata(pdev, priv); 736 - priv->dev = dev; 737 502 738 - priv->reset = devm_reset_control_get(dev, NULL); 503 + priv->reset = devm_reset_control_get_shared(dev, NULL); 739 504 if (IS_ERR(priv->reset)) { 740 505 ret = PTR_ERR(priv->reset); 741 506 dev_err(dev, "failed to get device reset, err=%d\n", ret); ··· 758 525 /* Get dr_mode */ 759 526 priv->otg_mode = usb_get_dr_mode(dev); 760 527 761 - dwc3_meson_g12a_usb_init(priv); 528 + if (priv->otg_mode == USB_DR_MODE_PERIPHERAL) 529 + priv->otg_phy_mode = PHY_MODE_USB_DEVICE; 530 + else 531 + priv->otg_phy_mode = PHY_MODE_USB_HOST; 532 + 533 + ret = priv->drvdata->usb_init(priv); 534 + if (ret) 535 + goto err_disable_clks; 762 536 763 537 /* Init PHYs */ 764 538 for (i = 0 ; i < PHY_COUNT ; ++i) { ··· 779 539 ret = phy_power_on(priv->phys[i]); 780 540 if (ret) 781 541 goto err_phys_exit; 542 + } 543 + 544 + if (priv->drvdata->usb_post_init) { 545 + ret = priv->drvdata->usb_post_init(priv); 546 + if (ret) 547 + goto err_phys_power; 782 548 } 783 549 784 550 ret = of_platform_populate(np, NULL, NULL, dev); ··· 888 642 889 643 reset_control_deassert(priv->reset); 890 644 891 - dwc3_meson_g12a_usb_init(priv); 645 + ret = priv->drvdata->usb_init(priv); 646 + if (ret) 647 + return ret; 892 648 893 649 /* Init PHYs */ 894 650 for (i = 0 ; i < PHY_COUNT ; ++i) { ··· 922 674 }; 923 675 924 676 static const struct of_device_id dwc3_meson_g12a_match[] = { 677 + { 678 + .compatible = "amlogic,meson-gxl-usb-ctrl", 679 + .data = &gxl_drvdata, 680 + }, 681 + { 682 + .compatible = "amlogic,meson-gxm-usb-ctrl", 683 + .data = &gxm_drvdata, 684 + }, 925 685 { 926 686 .compatible = "amlogic,meson-g12a-usb-ctrl", 927 687 .data = &g12a_drvdata,
+6 -24
drivers/usb/dwc3/dwc3-of-simple.c
··· 27 27 struct clk_bulk_data *clks; 28 28 int num_clocks; 29 29 struct reset_control *resets; 30 - bool pulse_resets; 31 30 bool need_reset; 32 31 }; 33 32 ··· 37 38 struct device_node *np = dev->of_node; 38 39 39 40 int ret; 40 - bool shared_resets = false; 41 41 42 42 simple = devm_kzalloc(dev, sizeof(*simple), GFP_KERNEL); 43 43 if (!simple) ··· 52 54 if (of_device_is_compatible(np, "rockchip,rk3399-dwc3")) 53 55 simple->need_reset = true; 54 56 55 - if (of_device_is_compatible(np, "amlogic,meson-axg-dwc3") || 56 - of_device_is_compatible(np, "amlogic,meson-gxl-dwc3")) { 57 - shared_resets = true; 58 - simple->pulse_resets = true; 59 - } 60 - 61 - simple->resets = of_reset_control_array_get(np, shared_resets, true, 57 + simple->resets = of_reset_control_array_get(np, false, true, 62 58 true); 63 59 if (IS_ERR(simple->resets)) { 64 60 ret = PTR_ERR(simple->resets); ··· 60 68 return ret; 61 69 } 62 70 63 - if (simple->pulse_resets) { 64 - ret = reset_control_reset(simple->resets); 65 - if (ret) 66 - goto err_resetc_put; 67 - } else { 68 - ret = reset_control_deassert(simple->resets); 69 - if (ret) 70 - goto err_resetc_put; 71 - } 71 + ret = reset_control_deassert(simple->resets); 72 + if (ret) 73 + goto err_resetc_put; 72 74 73 75 ret = clk_bulk_get_all(simple->dev, &simple->clks); 74 76 if (ret < 0) ··· 88 102 clk_bulk_put_all(simple->num_clocks, simple->clks); 89 103 90 104 err_resetc_assert: 91 - if (!simple->pulse_resets) 92 - reset_control_assert(simple->resets); 105 + reset_control_assert(simple->resets); 93 106 94 107 err_resetc_put: 95 108 reset_control_put(simple->resets); ··· 103 118 clk_bulk_put_all(simple->num_clocks, simple->clks); 104 119 simple->num_clocks = 0; 105 120 106 - if (!simple->pulse_resets) 107 - reset_control_assert(simple->resets); 121 + reset_control_assert(simple->resets); 108 122 109 123 reset_control_put(simple->resets); 110 124 ··· 175 191 { .compatible = "xlnx,zynqmp-dwc3" }, 176 192 { .compatible = "cavium,octeon-7130-usb-uctl" }, 177 193 { .compatible = "sprd,sc9860-dwc3" }, 178 - { .compatible = "amlogic,meson-axg-dwc3" }, 179 - { .compatible = "amlogic,meson-gxl-dwc3" }, 180 194 { .compatible = "allwinner,sun50i-h6-dwc3" }, 181 195 { /* Sentinel */ } 182 196 };
+364 -109
drivers/usb/dwc3/gadget.c
··· 95 95 * Wait until device controller is ready. Only applies to 1.94a and 96 96 * later RTL. 97 97 */ 98 - if (dwc->revision >= DWC3_REVISION_194A) { 98 + if (!DWC3_VER_IS_PRIOR(DWC3, 194A)) { 99 99 while (--retries) { 100 100 reg = dwc3_readl(dwc->regs, DWC3_DSTS); 101 101 if (reg & DWC3_DSTS_DCNRD) ··· 122 122 * The following code is racy when called from dwc3_gadget_wakeup, 123 123 * and is not needed, at least on newer versions 124 124 */ 125 - if (dwc->revision >= DWC3_REVISION_194A) 125 + if (!DWC3_VER_IS_PRIOR(DWC3, 194A)) 126 126 return 0; 127 127 128 128 /* wait for a change in DSTS */ ··· 273 273 { 274 274 const struct usb_endpoint_descriptor *desc = dep->endpoint.desc; 275 275 struct dwc3 *dwc = dep->dwc; 276 - u32 timeout = 1000; 276 + u32 timeout = 5000; 277 277 u32 saved_config = 0; 278 278 u32 reg; 279 279 ··· 356 356 ret = 0; 357 357 break; 358 358 case DEPEVT_TRANSFER_NO_RESOURCE: 359 + dev_WARN(dwc->dev, "No resource for %s\n", 360 + dep->name); 359 361 ret = -EINVAL; 360 362 break; 361 363 case DEPEVT_TRANSFER_BUS_EXPIRY: ··· 389 387 390 388 trace_dwc3_gadget_ep_cmd(dep, cmd, params, cmd_status); 391 389 392 - if (ret == 0 && DWC3_DEPCMD_CMD(cmd) == DWC3_DEPCMD_STARTTRANSFER) { 393 - dep->flags |= DWC3_EP_TRANSFER_STARTED; 394 - dwc3_gadget_ep_get_transfer_index(dep); 390 + if (DWC3_DEPCMD_CMD(cmd) == DWC3_DEPCMD_STARTTRANSFER) { 391 + if (ret == 0) 392 + dep->flags |= DWC3_EP_TRANSFER_STARTED; 393 + 394 + if (ret != -ETIMEDOUT) 395 + dwc3_gadget_ep_get_transfer_index(dep); 395 396 } 396 397 397 398 if (saved_config) { ··· 420 415 * IN transfers due to a mishandled error condition. Synopsys 421 416 * STAR 9000614252. 422 417 */ 423 - if (dep->direction && (dwc->revision >= DWC3_REVISION_260A) && 418 + if (dep->direction && 419 + !DWC3_VER_IS_PRIOR(DWC3, 260A) && 424 420 (dwc->gadget.speed >= USB_SPEED_SUPER)) 425 421 cmd |= DWC3_DEPCMD_CLEARPENDIN; 426 422 ··· 579 573 580 574 if (usb_ss_max_streams(comp_desc) && usb_endpoint_xfer_bulk(desc)) { 581 575 params.param1 |= DWC3_DEPCFG_STREAM_CAPABLE 576 + | DWC3_DEPCFG_XFER_COMPLETE_EN 582 577 | DWC3_DEPCFG_STREAM_EVENT_EN; 583 578 dep->stream_capable = true; 584 579 } ··· 609 602 610 603 return dwc3_send_gadget_ep_cmd(dep, DWC3_DEPCMD_SETEPCONFIG, &params); 611 604 } 605 + 606 + static void dwc3_stop_active_transfer(struct dwc3_ep *dep, bool force, 607 + bool interrupt); 612 608 613 609 /** 614 610 * __dwc3_gadget_ep_enable - initializes a hw endpoint ··· 673 663 * Issue StartTransfer here with no-op TRB so we can always rely on No 674 664 * Response Update Transfer command. 675 665 */ 676 - if ((usb_endpoint_xfer_bulk(desc) && !dep->stream_capable) || 666 + if (usb_endpoint_xfer_bulk(desc) || 677 667 usb_endpoint_xfer_int(desc)) { 678 668 struct dwc3_gadget_ep_cmd_params params; 679 669 struct dwc3_trb *trb; ··· 692 682 ret = dwc3_send_gadget_ep_cmd(dep, cmd, &params); 693 683 if (ret < 0) 694 684 return ret; 685 + 686 + if (dep->stream_capable) { 687 + /* 688 + * For streams, at start, there maybe a race where the 689 + * host primes the endpoint before the function driver 690 + * queues a request to initiate a stream. In that case, 691 + * the controller will not see the prime to generate the 692 + * ERDY and start stream. To workaround this, issue a 693 + * no-op TRB as normal, but end it immediately. As a 694 + * result, when the function driver queues the request, 695 + * the next START_TRANSFER command will cause the 696 + * controller to generate an ERDY to initiate the 697 + * stream. 698 + */ 699 + dwc3_stop_active_transfer(dep, true, true); 700 + 701 + /* 702 + * All stream eps will reinitiate stream on NoStream 703 + * rejection until we can determine that the host can 704 + * prime after the first transfer. 705 + */ 706 + dep->flags |= DWC3_EP_FORCE_RESTART_STREAM; 707 + } 695 708 } 696 709 697 710 out: ··· 723 690 return 0; 724 691 } 725 692 726 - static void dwc3_stop_active_transfer(struct dwc3_ep *dep, bool force, 727 - bool interrupt); 728 693 static void dwc3_remove_requests(struct dwc3 *dwc, struct dwc3_ep *dep) 729 694 { 730 695 struct dwc3_request *req; ··· 943 912 944 913 static void __dwc3_prepare_one_trb(struct dwc3_ep *dep, struct dwc3_trb *trb, 945 914 dma_addr_t dma, unsigned length, unsigned chain, unsigned node, 946 - unsigned stream_id, unsigned short_not_ok, unsigned no_interrupt) 915 + unsigned stream_id, unsigned short_not_ok, 916 + unsigned no_interrupt, unsigned is_last) 947 917 { 948 918 struct dwc3 *dwc = dep->dwc; 949 919 struct usb_gadget *gadget = &dwc->gadget; ··· 1037 1005 1038 1006 if (chain) 1039 1007 trb->ctrl |= DWC3_TRB_CTRL_CHN; 1008 + else if (dep->stream_capable && is_last) 1009 + trb->ctrl |= DWC3_TRB_CTRL_LST; 1040 1010 1041 1011 if (usb_endpoint_xfer_bulk(dep->endpoint.desc) && dep->stream_capable) 1042 1012 trb->ctrl |= DWC3_TRB_CTRL_SID_SOFN(stream_id); ··· 1066 1032 unsigned stream_id = req->request.stream_id; 1067 1033 unsigned short_not_ok = req->request.short_not_ok; 1068 1034 unsigned no_interrupt = req->request.no_interrupt; 1035 + unsigned is_last = req->request.is_last; 1069 1036 1070 1037 if (req->request.num_sgs > 0) { 1071 1038 length = sg_dma_len(req->start_sg); ··· 1087 1052 req->num_trbs++; 1088 1053 1089 1054 __dwc3_prepare_one_trb(dep, trb, dma, length, chain, node, 1090 - stream_id, short_not_ok, no_interrupt); 1055 + stream_id, short_not_ok, no_interrupt, is_last); 1091 1056 } 1092 1057 1093 1058 static void dwc3_prepare_one_trb_sg(struct dwc3_ep *dep, ··· 1132 1097 maxp - rem, false, 1, 1133 1098 req->request.stream_id, 1134 1099 req->request.short_not_ok, 1135 - req->request.no_interrupt); 1100 + req->request.no_interrupt, 1101 + req->request.is_last); 1136 1102 } else { 1137 1103 dwc3_prepare_one_trb(dep, req, chain, i); 1138 1104 } ··· 1177 1141 __dwc3_prepare_one_trb(dep, trb, dwc->bounce_addr, maxp - rem, 1178 1142 false, 1, req->request.stream_id, 1179 1143 req->request.short_not_ok, 1180 - req->request.no_interrupt); 1144 + req->request.no_interrupt, 1145 + req->request.is_last); 1181 1146 } else if (req->request.zero && req->request.length && 1182 1147 (IS_ALIGNED(req->request.length, maxp))) { 1183 1148 struct dwc3 *dwc = dep->dwc; ··· 1195 1158 __dwc3_prepare_one_trb(dep, trb, dwc->bounce_addr, 0, 1196 1159 false, 1, req->request.stream_id, 1197 1160 req->request.short_not_ok, 1198 - req->request.no_interrupt); 1161 + req->request.no_interrupt, 1162 + req->request.is_last); 1199 1163 } else { 1200 1164 dwc3_prepare_one_trb(dep, req, false, 0); 1201 1165 } ··· 1232 1194 1233 1195 if (!dwc3_calc_trbs_left(dep)) 1234 1196 return; 1197 + 1198 + /* 1199 + * Don't prepare beyond a transfer. In DWC_usb32, its transfer 1200 + * burst capability may try to read and use TRBs beyond the 1201 + * active transfer instead of stopping. 1202 + */ 1203 + if (dep->stream_capable && req->request.is_last) 1204 + return; 1235 1205 } 1236 1206 1237 1207 list_for_each_entry_safe(req, n, &dep->pending_list, list) { ··· 1263 1217 1264 1218 if (!dwc3_calc_trbs_left(dep)) 1265 1219 return; 1220 + 1221 + /* 1222 + * Don't prepare beyond a transfer. In DWC_usb32, its transfer 1223 + * burst capability may try to read and use TRBs beyond the 1224 + * active transfer instead of stopping. 1225 + */ 1226 + if (dep->stream_capable && req->request.is_last) 1227 + return; 1266 1228 } 1267 1229 } 1230 + 1231 + static void dwc3_gadget_ep_cleanup_cancelled_requests(struct dwc3_ep *dep); 1268 1232 1269 1233 static int __dwc3_gadget_kick_transfer(struct dwc3_ep *dep) 1270 1234 { ··· 1315 1259 1316 1260 ret = dwc3_send_gadget_ep_cmd(dep, cmd, &params); 1317 1261 if (ret < 0) { 1318 - /* 1319 - * FIXME we need to iterate over the list of requests 1320 - * here and stop, unmap, free and del each of the linked 1321 - * requests instead of what we do now. 1322 - */ 1323 - if (req->trb) 1324 - memset(req->trb, 0, sizeof(struct dwc3_trb)); 1325 - dwc3_gadget_del_and_unmap_request(dep, req, ret); 1262 + struct dwc3_request *tmp; 1263 + 1264 + if (ret == -EAGAIN) 1265 + return ret; 1266 + 1267 + dwc3_stop_active_transfer(dep, true, true); 1268 + 1269 + list_for_each_entry_safe(req, tmp, &dep->started_list, list) 1270 + dwc3_gadget_move_cancelled_request(req); 1271 + 1272 + /* If ep isn't started, then there's no end transfer pending */ 1273 + if (!(dep->flags & DWC3_EP_END_TRANSFER_PENDING)) 1274 + dwc3_gadget_ep_cleanup_cancelled_requests(dep); 1275 + 1326 1276 return ret; 1327 1277 } 1278 + 1279 + if (dep->stream_capable && req->request.is_last) 1280 + dep->flags |= DWC3_EP_WAIT_TRANSFER_COMPLETE; 1328 1281 1329 1282 return 0; 1330 1283 } ··· 1467 1402 int ret; 1468 1403 int i; 1469 1404 1470 - if (list_empty(&dep->pending_list)) { 1405 + if (list_empty(&dep->pending_list) && 1406 + list_empty(&dep->started_list)) { 1471 1407 dep->flags |= DWC3_EP_PENDING_REQUEST; 1472 1408 return -EAGAIN; 1473 1409 } 1474 1410 1475 - if (!dwc->dis_start_transfer_quirk && dwc3_is_usb31(dwc) && 1476 - (dwc->revision <= DWC3_USB31_REVISION_160A || 1477 - (dwc->revision == DWC3_USB31_REVISION_170A && 1478 - dwc->version_type >= DWC31_VERSIONTYPE_EA01 && 1479 - dwc->version_type <= DWC31_VERSIONTYPE_EA06))) { 1480 - 1411 + if (!dwc->dis_start_transfer_quirk && 1412 + (DWC3_VER_IS_PRIOR(DWC31, 170A) || 1413 + DWC3_VER_TYPE_IS_WITHIN(DWC31, 170A, EA01, EA06))) { 1481 1414 if (dwc->gadget.speed <= USB_SPEED_HIGH && dep->direction) 1482 1415 return dwc3_gadget_start_isoc_quirk(dep); 1483 1416 } ··· 1486 1423 ret = __dwc3_gadget_kick_transfer(dep); 1487 1424 if (ret != -EAGAIN) 1488 1425 break; 1426 + } 1427 + 1428 + /* 1429 + * After a number of unsuccessful start attempts due to bus-expiry 1430 + * status, issue END_TRANSFER command and retry on the next XferNotReady 1431 + * event. 1432 + */ 1433 + if (ret == -EAGAIN) { 1434 + struct dwc3_gadget_ep_cmd_params params; 1435 + u32 cmd; 1436 + 1437 + cmd = DWC3_DEPCMD_ENDTRANSFER | 1438 + DWC3_DEPCMD_CMDIOC | 1439 + DWC3_DEPCMD_PARAM(dep->resource_index); 1440 + 1441 + dep->resource_index = 0; 1442 + memset(&params, 0, sizeof(params)); 1443 + 1444 + ret = dwc3_send_gadget_ep_cmd(dep, cmd, &params); 1445 + if (!ret) 1446 + dep->flags |= DWC3_EP_END_TRANSFER_PENDING; 1489 1447 } 1490 1448 1491 1449 return ret; ··· 1540 1456 1541 1457 list_add_tail(&req->list, &dep->pending_list); 1542 1458 req->status = DWC3_REQUEST_STATUS_QUEUED; 1459 + 1460 + if (dep->flags & DWC3_EP_WAIT_TRANSFER_COMPLETE) 1461 + return 0; 1543 1462 1544 1463 /* Start the transfer only after the END_TRANSFER is completed */ 1545 1464 if (dep->flags & DWC3_EP_END_TRANSFER_PENDING) { ··· 1595 1508 { 1596 1509 int i; 1597 1510 1511 + /* If req->trb is not set, then the request has not started */ 1512 + if (!req->trb) 1513 + return; 1514 + 1598 1515 /* 1599 1516 * If request was already started, this means we had to 1600 1517 * stop the transfer. With that we also need to ignore ··· 1647 1556 1648 1557 spin_lock_irqsave(&dwc->lock, flags); 1649 1558 1650 - list_for_each_entry(r, &dep->pending_list, list) { 1559 + list_for_each_entry(r, &dep->cancelled_list, list) { 1651 1560 if (r == req) 1652 - break; 1561 + goto out; 1653 1562 } 1654 1563 1655 - if (r != req) { 1656 - list_for_each_entry(r, &dep->started_list, list) { 1657 - if (r == req) 1658 - break; 1659 - } 1564 + list_for_each_entry(r, &dep->pending_list, list) { 1660 1565 if (r == req) { 1566 + dwc3_gadget_giveback(dep, req, -ECONNRESET); 1567 + goto out; 1568 + } 1569 + } 1570 + 1571 + list_for_each_entry(r, &dep->started_list, list) { 1572 + if (r == req) { 1573 + struct dwc3_request *t; 1574 + 1661 1575 /* wait until it is processed */ 1662 1576 dwc3_stop_active_transfer(dep, true, true); 1663 1577 1664 - if (!r->trb) 1665 - goto out0; 1578 + /* 1579 + * Remove any started request if the transfer is 1580 + * cancelled. 1581 + */ 1582 + list_for_each_entry_safe(r, t, &dep->started_list, list) 1583 + dwc3_gadget_move_cancelled_request(r); 1666 1584 1667 - dwc3_gadget_move_cancelled_request(req); 1668 - if (dep->flags & DWC3_EP_TRANSFER_STARTED) 1669 - goto out0; 1670 - else 1671 - goto out1; 1585 + goto out; 1672 1586 } 1673 - dev_err(dwc->dev, "request %pK was not queued to %s\n", 1674 - request, ep->name); 1675 - ret = -EINVAL; 1676 - goto out0; 1677 1587 } 1678 1588 1679 - out1: 1680 - dwc3_gadget_giveback(dep, req, -ECONNRESET); 1681 - 1682 - out0: 1589 + dev_err(dwc->dev, "request %pK was not queued to %s\n", 1590 + request, ep->name); 1591 + ret = -EINVAL; 1592 + out: 1683 1593 spin_unlock_irqrestore(&dwc->lock, flags); 1684 1594 1685 1595 return ret; ··· 1690 1598 { 1691 1599 struct dwc3_gadget_ep_cmd_params params; 1692 1600 struct dwc3 *dwc = dep->dwc; 1601 + struct dwc3_request *req; 1602 + struct dwc3_request *tmp; 1693 1603 int ret; 1694 1604 1695 1605 if (usb_endpoint_xfer_isoc(dep->endpoint.desc)) { ··· 1728 1634 else 1729 1635 dep->flags |= DWC3_EP_STALL; 1730 1636 } else { 1637 + /* 1638 + * Don't issue CLEAR_STALL command to control endpoints. The 1639 + * controller automatically clears the STALL when it receives 1640 + * the SETUP token. 1641 + */ 1642 + if (dep->number <= 1) { 1643 + dep->flags &= ~(DWC3_EP_STALL | DWC3_EP_WEDGE); 1644 + return 0; 1645 + } 1731 1646 1732 1647 ret = dwc3_send_clear_stall_ep_cmd(dep); 1733 - if (ret) 1648 + if (ret) { 1734 1649 dev_err(dwc->dev, "failed to clear STALL on %s\n", 1735 1650 dep->name); 1736 - else 1737 - dep->flags &= ~(DWC3_EP_STALL | DWC3_EP_WEDGE); 1651 + return ret; 1652 + } 1653 + 1654 + dep->flags &= ~(DWC3_EP_STALL | DWC3_EP_WEDGE); 1655 + 1656 + dwc3_stop_active_transfer(dep, true, true); 1657 + 1658 + list_for_each_entry_safe(req, tmp, &dep->started_list, list) 1659 + dwc3_gadget_move_cancelled_request(req); 1660 + 1661 + list_for_each_entry_safe(req, tmp, &dep->pending_list, list) 1662 + dwc3_gadget_move_cancelled_request(req); 1663 + 1664 + if (!(dep->flags & DWC3_EP_END_TRANSFER_PENDING)) { 1665 + dep->flags &= ~DWC3_EP_DELAY_START; 1666 + dwc3_gadget_ep_cleanup_cancelled_requests(dep); 1667 + } 1738 1668 } 1739 1669 1740 1670 return ret; ··· 1874 1756 } 1875 1757 1876 1758 /* Recent versions do this automatically */ 1877 - if (dwc->revision < DWC3_REVISION_194A) { 1759 + if (DWC3_VER_IS_PRIOR(DWC3, 194A)) { 1878 1760 /* write zeroes to Link Change Request */ 1879 1761 reg = dwc3_readl(dwc->regs, DWC3_DCTL); 1880 1762 reg &= ~DWC3_DCTL_ULSTCHNGREQ_MASK; ··· 1936 1818 1937 1819 reg = dwc3_readl(dwc->regs, DWC3_DCTL); 1938 1820 if (is_on) { 1939 - if (dwc->revision <= DWC3_REVISION_187A) { 1821 + if (DWC3_VER_IS_WITHIN(DWC3, ANY, 187A)) { 1940 1822 reg &= ~DWC3_DCTL_TRGTULST_MASK; 1941 1823 reg |= DWC3_DCTL_TRGTULST_RX_DET; 1942 1824 } 1943 1825 1944 - if (dwc->revision >= DWC3_REVISION_194A) 1826 + if (!DWC3_VER_IS_PRIOR(DWC3, 194A)) 1945 1827 reg &= ~DWC3_DCTL_KEEP_CONNECT; 1946 1828 reg |= DWC3_DCTL_RUN_STOP; 1947 1829 ··· 2015 1897 DWC3_DEVTEN_USBRSTEN | 2016 1898 DWC3_DEVTEN_DISCONNEVTEN); 2017 1899 2018 - if (dwc->revision < DWC3_REVISION_250A) 1900 + if (DWC3_VER_IS_PRIOR(DWC3, 250A)) 2019 1901 reg |= DWC3_DEVTEN_ULSTCNGEN; 2020 1902 2021 1903 dwc3_writel(dwc->regs, DWC3_DEVTEN, reg); ··· 2060 1942 2061 1943 ram2_depth = DWC3_GHWPARAMS7_RAM2_DEPTH(dwc->hwparams.hwparams7); 2062 1944 mdwidth = DWC3_GHWPARAMS0_MDWIDTH(dwc->hwparams.hwparams0); 1945 + if (DWC3_IP_IS(DWC32)) 1946 + mdwidth += DWC3_GHWPARAMS6_MDWIDTH(dwc->hwparams.hwparams6); 2063 1947 2064 1948 nump = ((ram2_depth * mdwidth / 8) - 24 - 16) / 1024; 2065 1949 nump = min_t(u32, nump, 16); ··· 2098 1978 * bursts of data without going through any sort of endpoint throttling. 2099 1979 */ 2100 1980 reg = dwc3_readl(dwc->regs, DWC3_GRXTHRCFG); 2101 - if (dwc3_is_usb31(dwc)) 2102 - reg &= ~DWC31_GRXTHRCFG_PKTCNTSEL; 2103 - else 1981 + if (DWC3_IP_IS(DWC3)) 2104 1982 reg &= ~DWC3_GRXTHRCFG_PKTCNTSEL; 1983 + else 1984 + reg &= ~DWC31_GRXTHRCFG_PKTCNTSEL; 2105 1985 2106 1986 dwc3_writel(dwc->regs, DWC3_GRXTHRCFG, reg); 2107 1987 ··· 2274 2154 * STAR#9000525659: Clock Domain Crossing on DCTL in 2275 2155 * USB 2.0 Mode 2276 2156 */ 2277 - if (dwc->revision < DWC3_REVISION_220A && 2157 + if (DWC3_VER_IS_PRIOR(DWC3, 220A) && 2278 2158 !dwc->dis_metastability_quirk) { 2279 2159 reg |= DWC3_DCFG_SUPERSPEED; 2280 2160 } else { ··· 2292 2172 reg |= DWC3_DCFG_SUPERSPEED; 2293 2173 break; 2294 2174 case USB_SPEED_SUPER_PLUS: 2295 - if (dwc3_is_usb31(dwc)) 2296 - reg |= DWC3_DCFG_SUPERSPEED_PLUS; 2297 - else 2175 + if (DWC3_IP_IS(DWC3)) 2298 2176 reg |= DWC3_DCFG_SUPERSPEED; 2177 + else 2178 + reg |= DWC3_DCFG_SUPERSPEED_PLUS; 2299 2179 break; 2300 2180 default: 2301 2181 dev_err(dwc->dev, "invalid speed (%d)\n", speed); 2302 2182 2303 - if (dwc->revision & DWC3_REVISION_IS_DWC31) 2304 - reg |= DWC3_DCFG_SUPERSPEED_PLUS; 2305 - else 2183 + if (DWC3_IP_IS(DWC3)) 2306 2184 reg |= DWC3_DCFG_SUPERSPEED; 2185 + else 2186 + reg |= DWC3_DCFG_SUPERSPEED_PLUS; 2307 2187 } 2308 2188 } 2309 2189 dwc3_writel(dwc->regs, DWC3_DCFG, reg); ··· 2346 2226 int size; 2347 2227 2348 2228 mdwidth = DWC3_MDWIDTH(dwc->hwparams.hwparams0); 2229 + if (DWC3_IP_IS(DWC32)) 2230 + mdwidth += DWC3_GHWPARAMS6_MDWIDTH(dwc->hwparams.hwparams6); 2231 + 2349 2232 /* MDWIDTH is represented in bits, we need it in bytes */ 2350 2233 mdwidth /= 8; 2351 2234 2352 2235 size = dwc3_readl(dwc->regs, DWC3_GTXFIFOSIZ(dep->number >> 1)); 2353 - if (dwc3_is_usb31(dwc)) 2354 - size = DWC31_GTXFIFOSIZ_TXFDEP(size); 2355 - else 2236 + if (DWC3_IP_IS(DWC3)) 2356 2237 size = DWC3_GTXFIFOSIZ_TXFDEP(size); 2238 + else 2239 + size = DWC31_GTXFIFOSIZ_TXFDEP(size); 2357 2240 2358 2241 /* FIFO Depth is in MDWDITH bytes. Multiply */ 2359 2242 size *= mdwidth; ··· 2393 2270 int size; 2394 2271 2395 2272 mdwidth = DWC3_MDWIDTH(dwc->hwparams.hwparams0); 2273 + if (DWC3_IP_IS(DWC32)) 2274 + mdwidth += DWC3_GHWPARAMS6_MDWIDTH(dwc->hwparams.hwparams6); 2396 2275 2397 2276 /* MDWIDTH is represented in bits, convert to bytes */ 2398 2277 mdwidth /= 8; 2399 2278 2400 2279 /* All OUT endpoints share a single RxFIFO space */ 2401 2280 size = dwc3_readl(dwc->regs, DWC3_GRXFIFOSIZ(0)); 2402 - if (dwc3_is_usb31(dwc)) 2403 - size = DWC31_GRXFIFOSIZ_RXFDEP(size); 2404 - else 2281 + if (DWC3_IP_IS(DWC3)) 2405 2282 size = DWC3_GRXFIFOSIZ_RXFDEP(size); 2283 + else 2284 + size = DWC31_GRXFIFOSIZ_RXFDEP(size); 2406 2285 2407 2286 /* FIFO depth is in MDWDITH bytes */ 2408 2287 size *= mdwidth; ··· 2656 2531 2657 2532 req->request.actual = req->request.length - req->remaining; 2658 2533 2659 - if (!dwc3_gadget_ep_request_completed(req)) { 2660 - __dwc3_gadget_kick_transfer(dep); 2534 + if (!dwc3_gadget_ep_request_completed(req)) 2661 2535 goto out; 2662 - } 2663 2536 2664 2537 dwc3_gadget_giveback(dep, req, status); 2665 2538 ··· 2681 2558 } 2682 2559 } 2683 2560 2561 + static bool dwc3_gadget_ep_should_continue(struct dwc3_ep *dep) 2562 + { 2563 + struct dwc3_request *req; 2564 + 2565 + if (!list_empty(&dep->pending_list)) 2566 + return true; 2567 + 2568 + /* 2569 + * We only need to check the first entry of the started list. We can 2570 + * assume the completed requests are removed from the started list. 2571 + */ 2572 + req = next_request(&dep->started_list); 2573 + if (!req) 2574 + return false; 2575 + 2576 + return !dwc3_gadget_ep_request_completed(req); 2577 + } 2578 + 2684 2579 static void dwc3_gadget_endpoint_frame_from_event(struct dwc3_ep *dep, 2685 2580 const struct dwc3_event_depevt *event) 2686 2581 { 2687 2582 dep->frame_number = event->parameters; 2688 2583 } 2689 2584 2690 - static void dwc3_gadget_endpoint_transfer_in_progress(struct dwc3_ep *dep, 2691 - const struct dwc3_event_depevt *event) 2585 + static bool dwc3_gadget_endpoint_trbs_complete(struct dwc3_ep *dep, 2586 + const struct dwc3_event_depevt *event, int status) 2692 2587 { 2693 2588 struct dwc3 *dwc = dep->dwc; 2694 - unsigned status = 0; 2695 - bool stop = false; 2696 - 2697 - dwc3_gadget_endpoint_frame_from_event(dep, event); 2698 - 2699 - if (event->status & DEPEVT_STATUS_BUSERR) 2700 - status = -ECONNRESET; 2701 - 2702 - if (event->status & DEPEVT_STATUS_MISSED_ISOC) { 2703 - status = -EXDEV; 2704 - 2705 - if (list_empty(&dep->started_list)) 2706 - stop = true; 2707 - } 2589 + bool no_started_trb = true; 2708 2590 2709 2591 dwc3_gadget_ep_cleanup_completed_requests(dep, event, status); 2710 2592 2711 - if (stop) 2712 - dwc3_stop_active_transfer(dep, true, true); 2593 + if (dep->flags & DWC3_EP_END_TRANSFER_PENDING) 2594 + goto out; 2713 2595 2596 + if (status == -EXDEV && list_empty(&dep->started_list)) 2597 + dwc3_stop_active_transfer(dep, true, true); 2598 + else if (dwc3_gadget_ep_should_continue(dep)) 2599 + if (__dwc3_gadget_kick_transfer(dep) == 0) 2600 + no_started_trb = false; 2601 + 2602 + out: 2714 2603 /* 2715 2604 * WORKAROUND: This is the 2nd half of U1/U2 -> U0 workaround. 2716 2605 * See dwc3_gadget_linksts_change_interrupt() for 1st half. 2717 2606 */ 2718 - if (dwc->revision < DWC3_REVISION_183A) { 2607 + if (DWC3_VER_IS_PRIOR(DWC3, 183A)) { 2719 2608 u32 reg; 2720 2609 int i; 2721 2610 ··· 2738 2603 continue; 2739 2604 2740 2605 if (!list_empty(&dep->started_list)) 2741 - return; 2606 + return no_started_trb; 2742 2607 } 2743 2608 2744 2609 reg = dwc3_readl(dwc->regs, DWC3_DCTL); ··· 2747 2612 2748 2613 dwc->u1u2 = 0; 2749 2614 } 2615 + 2616 + return no_started_trb; 2617 + } 2618 + 2619 + static void dwc3_gadget_endpoint_transfer_in_progress(struct dwc3_ep *dep, 2620 + const struct dwc3_event_depevt *event) 2621 + { 2622 + int status = 0; 2623 + 2624 + if (usb_endpoint_xfer_isoc(dep->endpoint.desc)) 2625 + dwc3_gadget_endpoint_frame_from_event(dep, event); 2626 + 2627 + if (event->status & DEPEVT_STATUS_BUSERR) 2628 + status = -ECONNRESET; 2629 + 2630 + if (event->status & DEPEVT_STATUS_MISSED_ISOC) 2631 + status = -EXDEV; 2632 + 2633 + dwc3_gadget_endpoint_trbs_complete(dep, event, status); 2634 + } 2635 + 2636 + static void dwc3_gadget_endpoint_transfer_complete(struct dwc3_ep *dep, 2637 + const struct dwc3_event_depevt *event) 2638 + { 2639 + int status = 0; 2640 + 2641 + dep->flags &= ~DWC3_EP_TRANSFER_STARTED; 2642 + 2643 + if (event->status & DEPEVT_STATUS_BUSERR) 2644 + status = -ECONNRESET; 2645 + 2646 + if (dwc3_gadget_endpoint_trbs_complete(dep, event, status)) 2647 + dep->flags &= ~DWC3_EP_WAIT_TRANSFER_COMPLETE; 2750 2648 } 2751 2649 2752 2650 static void dwc3_gadget_endpoint_transfer_not_ready(struct dwc3_ep *dep, 2753 2651 const struct dwc3_event_depevt *event) 2754 2652 { 2755 2653 dwc3_gadget_endpoint_frame_from_event(dep, event); 2654 + 2655 + /* 2656 + * The XferNotReady event is generated only once before the endpoint 2657 + * starts. It will be generated again when END_TRANSFER command is 2658 + * issued. For some controller versions, the XferNotReady event may be 2659 + * generated while the END_TRANSFER command is still in process. Ignore 2660 + * it and wait for the next XferNotReady event after the command is 2661 + * completed. 2662 + */ 2663 + if (dep->flags & DWC3_EP_END_TRANSFER_PENDING) 2664 + return; 2665 + 2756 2666 (void) __dwc3_gadget_start_isoc(dep); 2667 + } 2668 + 2669 + static void dwc3_gadget_endpoint_stream_event(struct dwc3_ep *dep, 2670 + const struct dwc3_event_depevt *event) 2671 + { 2672 + struct dwc3 *dwc = dep->dwc; 2673 + 2674 + if (event->status == DEPEVT_STREAMEVT_FOUND) { 2675 + dep->flags |= DWC3_EP_FIRST_STREAM_PRIMED; 2676 + goto out; 2677 + } 2678 + 2679 + /* Note: NoStream rejection event param value is 0 and not 0xFFFF */ 2680 + switch (event->parameters) { 2681 + case DEPEVT_STREAM_PRIME: 2682 + /* 2683 + * If the host can properly transition the endpoint state from 2684 + * idle to prime after a NoStream rejection, there's no need to 2685 + * force restarting the endpoint to reinitiate the stream. To 2686 + * simplify the check, assume the host follows the USB spec if 2687 + * it primed the endpoint more than once. 2688 + */ 2689 + if (dep->flags & DWC3_EP_FORCE_RESTART_STREAM) { 2690 + if (dep->flags & DWC3_EP_FIRST_STREAM_PRIMED) 2691 + dep->flags &= ~DWC3_EP_FORCE_RESTART_STREAM; 2692 + else 2693 + dep->flags |= DWC3_EP_FIRST_STREAM_PRIMED; 2694 + } 2695 + 2696 + break; 2697 + case DEPEVT_STREAM_NOSTREAM: 2698 + if ((dep->flags & DWC3_EP_IGNORE_NEXT_NOSTREAM) || 2699 + !(dep->flags & DWC3_EP_FORCE_RESTART_STREAM) || 2700 + !(dep->flags & DWC3_EP_WAIT_TRANSFER_COMPLETE)) 2701 + break; 2702 + 2703 + /* 2704 + * If the host rejects a stream due to no active stream, by the 2705 + * USB and xHCI spec, the endpoint will be put back to idle 2706 + * state. When the host is ready (buffer added/updated), it will 2707 + * prime the endpoint to inform the usb device controller. This 2708 + * triggers the device controller to issue ERDY to restart the 2709 + * stream. However, some hosts don't follow this and keep the 2710 + * endpoint in the idle state. No prime will come despite host 2711 + * streams are updated, and the device controller will not be 2712 + * triggered to generate ERDY to move the next stream data. To 2713 + * workaround this and maintain compatibility with various 2714 + * hosts, force to reinitate the stream until the host is ready 2715 + * instead of waiting for the host to prime the endpoint. 2716 + */ 2717 + if (DWC3_VER_IS_WITHIN(DWC32, 100A, ANY)) { 2718 + unsigned int cmd = DWC3_DGCMD_SET_ENDPOINT_PRIME; 2719 + 2720 + dwc3_send_gadget_generic_command(dwc, cmd, dep->number); 2721 + } else { 2722 + dep->flags |= DWC3_EP_DELAY_START; 2723 + dwc3_stop_active_transfer(dep, true, true); 2724 + return; 2725 + } 2726 + break; 2727 + } 2728 + 2729 + out: 2730 + dep->flags &= ~DWC3_EP_IGNORE_NEXT_NOSTREAM; 2757 2731 } 2758 2732 2759 2733 static void dwc3_endpoint_interrupt(struct dwc3 *dwc, ··· 2909 2665 dep->flags &= ~DWC3_EP_DELAY_START; 2910 2666 } 2911 2667 break; 2912 - case DWC3_DEPEVT_STREAMEVT: 2913 2668 case DWC3_DEPEVT_XFERCOMPLETE: 2669 + dwc3_gadget_endpoint_transfer_complete(dep, event); 2670 + break; 2671 + case DWC3_DEPEVT_STREAMEVT: 2672 + dwc3_gadget_endpoint_stream_event(dep, event); 2673 + break; 2914 2674 case DWC3_DEPEVT_RXTXFIFOEVT: 2915 2675 break; 2916 2676 } ··· 3006 2758 WARN_ON_ONCE(ret); 3007 2759 dep->resource_index = 0; 3008 2760 2761 + /* 2762 + * The END_TRANSFER command will cause the controller to generate a 2763 + * NoStream Event, and it's not due to the host DP NoStream rejection. 2764 + * Ignore the next NoStream event. 2765 + */ 2766 + if (dep->stream_capable) 2767 + dep->flags |= DWC3_EP_IGNORE_NEXT_NOSTREAM; 2768 + 3009 2769 if (!interrupt) 3010 2770 dep->flags &= ~DWC3_EP_TRANSFER_STARTED; 3011 2771 else ··· 3094 2838 * STAR#9000466709: RTL: Device : Disconnect event not 3095 2839 * generated if setup packet pending in FIFO 3096 2840 */ 3097 - if (dwc->revision < DWC3_REVISION_188A) { 2841 + if (DWC3_VER_IS_PRIOR(DWC3, 188A)) { 3098 2842 if (dwc->setup_packet_pending) 3099 2843 dwc3_gadget_disconnect_interrupt(dwc); 3100 2844 } ··· 3153 2897 * STAR#9000483510: RTL: SS : USB3 reset event may 3154 2898 * not be generated always when the link enters poll 3155 2899 */ 3156 - if (dwc->revision < DWC3_REVISION_190A) 2900 + if (DWC3_VER_IS_PRIOR(DWC3, 190A)) 3157 2901 dwc3_gadget_reset_interrupt(dwc); 3158 2902 3159 2903 dwc3_gadget_ep0_desc.wMaxPacketSize = cpu_to_le16(512); ··· 3181 2925 3182 2926 /* Enable USB2 LPM Capability */ 3183 2927 3184 - if ((dwc->revision > DWC3_REVISION_194A) && 2928 + if (!DWC3_VER_IS_WITHIN(DWC3, ANY, 194A) && 3185 2929 (speed != DWC3_DSTS_SUPERSPEED) && 3186 2930 (speed != DWC3_DSTS_SUPERSPEED_PLUS)) { 3187 2931 reg = dwc3_readl(dwc->regs, DWC3_DCFG); ··· 3200 2944 * BESL value in the LPM token is less than or equal to LPM 3201 2945 * NYET threshold. 3202 2946 */ 3203 - WARN_ONCE(dwc->revision < DWC3_REVISION_240A 3204 - && dwc->has_lpm_erratum, 2947 + WARN_ONCE(DWC3_VER_IS_PRIOR(DWC3, 240A) && dwc->has_lpm_erratum, 3205 2948 "LPM Erratum not available on dwc3 revisions < 2.40a\n"); 3206 2949 3207 - if (dwc->has_lpm_erratum && dwc->revision >= DWC3_REVISION_240A) 2950 + if (dwc->has_lpm_erratum && !DWC3_VER_IS_PRIOR(DWC3, 240A)) 3208 2951 reg |= DWC3_DCTL_NYET_THRES(dwc->lpm_nyet_threshold); 3209 2952 3210 2953 dwc3_gadget_dctl_write_safe(dwc, reg); ··· 3274 3019 * operational mode 3275 3020 */ 3276 3021 pwropt = DWC3_GHWPARAMS1_EN_PWROPT(dwc->hwparams.hwparams1); 3277 - if ((dwc->revision < DWC3_REVISION_250A) && 3022 + if (DWC3_VER_IS_PRIOR(DWC3, 250A) && 3278 3023 (pwropt != DWC3_GHWPARAMS1_EN_PWROPT_HIB)) { 3279 3024 if ((dwc->link_state == DWC3_LINK_STATE_U3) && 3280 3025 (next == DWC3_LINK_STATE_RESUME)) { ··· 3300 3045 * STAR#9000446952: RTL: Device SS : if U1/U2 ->U0 takes >128us 3301 3046 * core send LGO_Ux entering U0 3302 3047 */ 3303 - if (dwc->revision < DWC3_REVISION_183A) { 3048 + if (DWC3_VER_IS_PRIOR(DWC3, 183A)) { 3304 3049 if (next == DWC3_LINK_STATE_U0) { 3305 3050 u32 u1u2; 3306 3051 u32 reg; ··· 3411 3156 break; 3412 3157 case DWC3_DEVICE_EVENT_EOPF: 3413 3158 /* It changed to be suspend event for version 2.30a and above */ 3414 - if (dwc->revision >= DWC3_REVISION_230A) { 3159 + if (!DWC3_VER_IS_PRIOR(DWC3, 230A)) { 3415 3160 /* 3416 3161 * Ignore suspend event until the gadget enters into 3417 3162 * USB_STATE_CONFIGURED state. ··· 3656 3401 * is less than super speed because we don't have means, yet, to tell 3657 3402 * composite.c that we are USB 2.0 + LPM ECN. 3658 3403 */ 3659 - if (dwc->revision < DWC3_REVISION_220A && 3404 + if (DWC3_VER_IS_PRIOR(DWC3, 220A) && 3660 3405 !dwc->dis_metastability_quirk) 3661 3406 dev_info(dwc->dev, "changing max_speed on rev %08x\n", 3662 3407 dwc->revision);
+1 -1
drivers/usb/dwc3/gadget.h
··· 1 - // SPDX-License-Identifier: GPL-2.0 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 2 /* 3 3 * gadget.h - DesignWare USB3 DRD Gadget Header 4 4 *
+1 -1
drivers/usb/dwc3/host.c
··· 104 104 * 105 105 * This following flag tells XHCI to do just that. 106 106 */ 107 - if (dwc->revision <= DWC3_REVISION_300A) 107 + if (DWC3_VER_IS_WITHIN(DWC3, ANY, 300A)) 108 108 props[prop_idx++] = PROPERTY_ENTRY_BOOL("quirk-broken-port-ped"); 109 109 110 110 if (prop_idx) {
+1 -1
drivers/usb/dwc3/io.h
··· 1 - // SPDX-License-Identifier: GPL-2.0 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 2 /** 3 3 * io.h - DesignWare USB3 DRD IO Header 4 4 *
+1 -1
drivers/usb/dwc3/trace.h
··· 1 - // SPDX-License-Identifier: GPL-2.0 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 2 /** 3 3 * trace.h - DesignWare USB3 DRD Controller Trace Support 4 4 *
+61 -17
drivers/usb/gadget/composite.c
··· 96 96 } 97 97 98 98 /** 99 - * next_ep_desc() - advance to the next EP descriptor 99 + * next_desc() - advance to the next desc_type descriptor 100 100 * @t: currect pointer within descriptor array 101 + * @desc_type: descriptor type 101 102 * 102 - * Return: next EP descriptor or NULL 103 + * Return: next desc_type descriptor or NULL 103 104 * 104 - * Iterate over @t until either EP descriptor found or 105 + * Iterate over @t until either desc_type descriptor found or 105 106 * NULL (that indicates end of list) encountered 106 107 */ 107 108 static struct usb_descriptor_header** 108 - next_ep_desc(struct usb_descriptor_header **t) 109 + next_desc(struct usb_descriptor_header **t, u8 desc_type) 109 110 { 110 111 for (; *t; t++) { 111 - if ((*t)->bDescriptorType == USB_DT_ENDPOINT) 112 + if ((*t)->bDescriptorType == desc_type) 112 113 return t; 113 114 } 114 115 return NULL; 115 116 } 116 117 117 118 /* 118 - * for_each_ep_desc()- iterate over endpoint descriptors in the 119 - * descriptors list 120 - * @start: pointer within descriptor array. 121 - * @ep_desc: endpoint descriptor to use as the loop cursor 119 + * for_each_desc() - iterate over desc_type descriptors in the 120 + * descriptors list 121 + * @start: pointer within descriptor array. 122 + * @iter_desc: desc_type descriptor to use as the loop cursor 123 + * @desc_type: wanted descriptr type 122 124 */ 123 - #define for_each_ep_desc(start, ep_desc) \ 124 - for (ep_desc = next_ep_desc(start); \ 125 - ep_desc; ep_desc = next_ep_desc(ep_desc+1)) 125 + #define for_each_desc(start, iter_desc, desc_type) \ 126 + for (iter_desc = next_desc(start, desc_type); \ 127 + iter_desc; iter_desc = next_desc(iter_desc + 1, desc_type)) 126 128 127 129 /** 128 - * config_ep_by_speed() - configures the given endpoint 130 + * config_ep_by_speed_and_alt() - configures the given endpoint 129 131 * according to gadget speed. 130 132 * @g: pointer to the gadget 131 133 * @f: usb function 132 134 * @_ep: the endpoint to configure 135 + * @alt: alternate setting number 133 136 * 134 137 * Return: error code, 0 on success 135 138 * ··· 145 142 * Note: the supplied function should hold all the descriptors 146 143 * for supported speeds 147 144 */ 148 - int config_ep_by_speed(struct usb_gadget *g, 149 - struct usb_function *f, 150 - struct usb_ep *_ep) 145 + int config_ep_by_speed_and_alt(struct usb_gadget *g, 146 + struct usb_function *f, 147 + struct usb_ep *_ep, 148 + u8 alt) 151 149 { 152 150 struct usb_endpoint_descriptor *chosen_desc = NULL; 151 + struct usb_interface_descriptor *int_desc = NULL; 153 152 struct usb_descriptor_header **speed_desc = NULL; 154 153 155 154 struct usb_ss_ep_comp_descriptor *comp_desc = NULL; ··· 187 182 default: 188 183 speed_desc = f->fs_descriptors; 189 184 } 185 + 186 + /* find correct alternate setting descriptor */ 187 + for_each_desc(speed_desc, d_spd, USB_DT_INTERFACE) { 188 + int_desc = (struct usb_interface_descriptor *)*d_spd; 189 + 190 + if (int_desc->bAlternateSetting == alt) { 191 + speed_desc = d_spd; 192 + goto intf_found; 193 + } 194 + } 195 + return -EIO; 196 + 197 + intf_found: 190 198 /* find descriptors */ 191 - for_each_ep_desc(speed_desc, d_spd) { 199 + for_each_desc(speed_desc, d_spd, USB_DT_ENDPOINT) { 192 200 chosen_desc = (struct usb_endpoint_descriptor *)*d_spd; 193 201 if (chosen_desc->bEndpointAddress == _ep->address) 194 202 goto ep_found; ··· 254 236 } 255 237 } 256 238 return 0; 239 + } 240 + EXPORT_SYMBOL_GPL(config_ep_by_speed_and_alt); 241 + 242 + /** 243 + * config_ep_by_speed() - configures the given endpoint 244 + * according to gadget speed. 245 + * @g: pointer to the gadget 246 + * @f: usb function 247 + * @_ep: the endpoint to configure 248 + * 249 + * Return: error code, 0 on success 250 + * 251 + * This function chooses the right descriptors for a given 252 + * endpoint according to gadget speed and saves it in the 253 + * endpoint desc field. If the endpoint already has a descriptor 254 + * assigned to it - overwrites it with currently corresponding 255 + * descriptor. The endpoint maxpacket field is updated according 256 + * to the chosen descriptor. 257 + * Note: the supplied function should hold all the descriptors 258 + * for supported speeds 259 + */ 260 + int config_ep_by_speed(struct usb_gadget *g, 261 + struct usb_function *f, 262 + struct usb_ep *_ep) 263 + { 264 + return config_ep_by_speed_and_alt(g, f, _ep, 0); 257 265 } 258 266 EXPORT_SYMBOL_GPL(config_ep_by_speed); 259 267
+1 -13
drivers/usb/gadget/configfs.c
··· 13 13 int check_user_usb_string(const char *name, 14 14 struct usb_gadget_strings *stringtab_dev) 15 15 { 16 - unsigned primary_lang; 17 - unsigned sub_lang; 18 16 u16 num; 19 17 int ret; 20 18 ··· 20 22 if (ret) 21 23 return ret; 22 24 23 - primary_lang = num & 0x3ff; 24 - sub_lang = num >> 10; 25 - 26 - /* simple sanity check for valid langid */ 27 - switch (primary_lang) { 28 - case 0: 29 - case 0x62 ... 0xfe: 30 - case 0x100 ... 0x3ff: 31 - return -EINVAL; 32 - } 33 - if (!sub_lang) 25 + if (!usb_validate_langid(num)) 34 26 return -EINVAL; 35 27 36 28 stringtab_dev->language = num;
+16
drivers/usb/gadget/function/f_acm.c
··· 723 723 kfree(acm); 724 724 } 725 725 726 + static void acm_resume(struct usb_function *f) 727 + { 728 + struct f_acm *acm = func_to_acm(f); 729 + 730 + gserial_resume(&acm->port); 731 + } 732 + 733 + static void acm_suspend(struct usb_function *f) 734 + { 735 + struct f_acm *acm = func_to_acm(f); 736 + 737 + gserial_suspend(&acm->port); 738 + } 739 + 726 740 static struct usb_function *acm_alloc_func(struct usb_function_instance *fi) 727 741 { 728 742 struct f_serial_opts *opts; ··· 764 750 acm->port_num = opts->port_num; 765 751 acm->port.func.unbind = acm_unbind; 766 752 acm->port.func.free_func = acm_free_func; 753 + acm->port.func.resume = acm_resume; 754 + acm->port.func.suspend = acm_suspend; 767 755 768 756 return &acm->port.func; 769 757 }
-2
drivers/usb/gadget/function/f_eem.c
··· 291 291 goto fail; 292 292 eem->port.out_ep = ep; 293 293 294 - status = -ENOMEM; 295 - 296 294 /* support all relevant hardware speeds... we expect that when 297 295 * hardware is dual speed, all bulk-capable endpoints work at 298 296 * both speeds
+1 -1
drivers/usb/gadget/function/f_fs.c
··· 2508 2508 os_descs_count = get_unaligned_le32(data); 2509 2509 data += 4; 2510 2510 len -= 4; 2511 - }; 2511 + } 2512 2512 2513 2513 /* Read descriptors */ 2514 2514 raw_descs = data;
+16
drivers/usb/gadget/function/f_serial.c
··· 348 348 usb_free_all_descriptors(f); 349 349 } 350 350 351 + static void gser_resume(struct usb_function *f) 352 + { 353 + struct f_gser *gser = func_to_gser(f); 354 + 355 + gserial_resume(&gser->port); 356 + } 357 + 358 + static void gser_suspend(struct usb_function *f) 359 + { 360 + struct f_gser *gser = func_to_gser(f); 361 + 362 + gserial_suspend(&gser->port); 363 + } 364 + 351 365 static struct usb_function *gser_alloc(struct usb_function_instance *fi) 352 366 { 353 367 struct f_gser *gser; ··· 383 369 gser->port.func.set_alt = gser_set_alt; 384 370 gser->port.func.disable = gser_disable; 385 371 gser->port.func.free_func = gser_free; 372 + gser->port.func.resume = gser_resume; 373 + gser->port.func.suspend = gser_suspend; 386 374 387 375 return &gser->port.func; 388 376 }
+3
drivers/usb/gadget/function/f_tcm.c
··· 531 531 stream->req_in->sg = se_cmd->t_data_sg; 532 532 } 533 533 534 + stream->req_in->is_last = 1; 534 535 stream->req_in->complete = uasp_status_data_cmpl; 535 536 stream->req_in->length = se_cmd->data_length; 536 537 stream->req_in->context = cmd; ··· 555 554 */ 556 555 iu->len = cpu_to_be16(se_cmd->scsi_sense_length); 557 556 iu->status = se_cmd->scsi_status; 557 + stream->req_status->is_last = 1; 558 558 stream->req_status->context = cmd; 559 559 stream->req_status->length = se_cmd->scsi_sense_length + 16; 560 560 stream->req_status->buf = iu; ··· 993 991 req->sg = se_cmd->t_data_sg; 994 992 } 995 993 994 + req->is_last = 1; 996 995 req->complete = usbg_data_write_cmpl; 997 996 req->length = se_cmd->data_length; 998 997 req->context = cmd;
+1 -1
drivers/usb/gadget/function/f_uvc.h
··· 1 - // SPDX-License-Identifier: GPL-2.0+ 1 + /* SPDX-License-Identifier: GPL-2.0+ */ 2 2 /* 3 3 * f_uvc.h -- USB Video Class Gadget driver 4 4 *
+1 -1
drivers/usb/gadget/function/rndis.h
··· 1 - // SPDX-License-Identifier: GPL-2.0 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 2 /* 3 3 * RNDIS Definitions for Remote NDIS 4 4 *
+1 -1
drivers/usb/gadget/function/u_audio.h
··· 1 - // SPDX-License-Identifier: GPL-2.0+ 1 + /* SPDX-License-Identifier: GPL-2.0+ */ 2 2 /* 3 3 * u_audio.h -- interface to USB gadget "ALSA sound card" utilities 4 4 *
+1 -1
drivers/usb/gadget/function/u_ecm.h
··· 1 - // SPDX-License-Identifier: GPL-2.0 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 2 /* 3 3 * u_ecm.h 4 4 *
+1 -1
drivers/usb/gadget/function/u_eem.h
··· 1 - // SPDX-License-Identifier: GPL-2.0 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 2 /* 3 3 * u_eem.h 4 4 *
+1 -1
drivers/usb/gadget/function/u_ether.h
··· 1 - // SPDX-License-Identifier: GPL-2.0+ 1 + /* SPDX-License-Identifier: GPL-2.0+ */ 2 2 /* 3 3 * u_ether.h -- interface to USB gadget "ethernet link" utilities 4 4 *
+1 -1
drivers/usb/gadget/function/u_ether_configfs.h
··· 1 - // SPDX-License-Identifier: GPL-2.0 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 2 /* 3 3 * u_ether_configfs.h 4 4 *
+1 -1
drivers/usb/gadget/function/u_fs.h
··· 1 - // SPDX-License-Identifier: GPL-2.0 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 2 /* 3 3 * u_fs.h 4 4 *
+1 -1
drivers/usb/gadget/function/u_gether.h
··· 1 - // SPDX-License-Identifier: GPL-2.0 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 2 /* 3 3 * u_gether.h 4 4 *
+1 -1
drivers/usb/gadget/function/u_hid.h
··· 1 - // SPDX-License-Identifier: GPL-2.0 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 2 /* 3 3 * u_hid.h 4 4 *
+1 -1
drivers/usb/gadget/function/u_midi.h
··· 1 - // SPDX-License-Identifier: GPL-2.0 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 2 /* 3 3 * u_midi.h 4 4 *
+1 -1
drivers/usb/gadget/function/u_ncm.h
··· 1 - // SPDX-License-Identifier: GPL-2.0 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 2 /* 3 3 * u_ncm.h 4 4 *
+1 -1
drivers/usb/gadget/function/u_phonet.h
··· 1 - // SPDX-License-Identifier: GPL-2.0+ 1 + /* SPDX-License-Identifier: GPL-2.0+ */ 2 2 /* 3 3 * u_phonet.h - interface to Phonet 4 4 *
+1 -1
drivers/usb/gadget/function/u_printer.h
··· 1 - // SPDX-License-Identifier: GPL-2.0 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 2 /* 3 3 * u_printer.h 4 4 *
+1 -1
drivers/usb/gadget/function/u_rndis.h
··· 1 - // SPDX-License-Identifier: GPL-2.0 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 2 /* 3 3 * u_rndis.h 4 4 *
+47 -6
drivers/usb/gadget/function/u_serial.c
··· 120 120 wait_queue_head_t drain_wait; /* wait while writes drain */ 121 121 bool write_busy; 122 122 wait_queue_head_t close_wait; 123 + bool suspended; /* port suspended */ 124 + bool start_delayed; /* delay start when suspended */ 123 125 124 126 /* REVISIT this state ... */ 125 127 struct usb_cdc_line_coding port_line_coding; /* 8-N-1 etc */ ··· 632 630 633 631 /* if connected, start the I/O stream */ 634 632 if (port->port_usb) { 635 - struct gserial *gser = port->port_usb; 633 + /* if port is suspended, wait resume to start I/0 stream */ 634 + if (!port->suspended) { 635 + struct gserial *gser = port->port_usb; 636 636 637 - pr_debug("gs_open: start ttyGS%d\n", port->port_num); 638 - gs_start_io(port); 637 + pr_debug("gs_open: start ttyGS%d\n", port->port_num); 638 + gs_start_io(port); 639 639 640 - if (gser->connect) 641 - gser->connect(gser); 640 + if (gser->connect) 641 + gser->connect(gser); 642 + } else { 643 + pr_debug("delay start of ttyGS%d\n", port->port_num); 644 + port->start_delayed = true; 645 + } 642 646 } 643 647 644 648 pr_debug("gs_open: ttyGS%d (%p,%p)\n", port->port_num, tty, file); ··· 688 680 pr_debug("gs_close: ttyGS%d (%p,%p) ...\n", port->port_num, tty, file); 689 681 690 682 gser = port->port_usb; 691 - if (gser && gser->disconnect) 683 + if (gser && !port->suspended && gser->disconnect) 692 684 gser->disconnect(gser); 693 685 694 686 /* wait for circular write buffer to drain, disconnect, or at ··· 716 708 else 717 709 kfifo_reset(&port->port_write_buf); 718 710 711 + port->start_delayed = false; 719 712 port->port.count = 0; 720 713 port->port.tty = NULL; 721 714 ··· 1411 1402 spin_unlock_irqrestore(&port->port_lock, flags); 1412 1403 } 1413 1404 EXPORT_SYMBOL_GPL(gserial_disconnect); 1405 + 1406 + void gserial_suspend(struct gserial *gser) 1407 + { 1408 + struct gs_port *port = gser->ioport; 1409 + unsigned long flags; 1410 + 1411 + spin_lock_irqsave(&port->port_lock, flags); 1412 + port->suspended = true; 1413 + spin_unlock_irqrestore(&port->port_lock, flags); 1414 + } 1415 + EXPORT_SYMBOL_GPL(gserial_suspend); 1416 + 1417 + void gserial_resume(struct gserial *gser) 1418 + { 1419 + struct gs_port *port = gser->ioport; 1420 + unsigned long flags; 1421 + 1422 + spin_lock_irqsave(&port->port_lock, flags); 1423 + port->suspended = false; 1424 + if (!port->start_delayed) { 1425 + spin_unlock_irqrestore(&port->port_lock, flags); 1426 + return; 1427 + } 1428 + 1429 + pr_debug("delayed start ttyGS%d\n", port->port_num); 1430 + gs_start_io(port); 1431 + if (gser->connect) 1432 + gser->connect(gser); 1433 + port->start_delayed = false; 1434 + spin_unlock_irqrestore(&port->port_lock, flags); 1435 + } 1436 + EXPORT_SYMBOL_GPL(gserial_resume); 1414 1437 1415 1438 static int userial_init(void) 1416 1439 {
+3 -1
drivers/usb/gadget/function/u_serial.h
··· 1 - // SPDX-License-Identifier: GPL-2.0+ 1 + /* SPDX-License-Identifier: GPL-2.0+ */ 2 2 /* 3 3 * u_serial.h - interface to USB gadget "serial port"/TTY utilities 4 4 * ··· 68 68 /* connect/disconnect is handled by individual functions */ 69 69 int gserial_connect(struct gserial *, u8 port_num); 70 70 void gserial_disconnect(struct gserial *); 71 + void gserial_suspend(struct gserial *p); 72 + void gserial_resume(struct gserial *p); 71 73 72 74 /* functions are bound to configurations by a config or gadget driver */ 73 75 int gser_bind_config(struct usb_configuration *c, u8 port_num);
+1 -1
drivers/usb/gadget/function/u_tcm.h
··· 1 - // SPDX-License-Identifier: GPL-2.0 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 2 /* 3 3 * u_tcm.h 4 4 *
+1 -1
drivers/usb/gadget/function/u_uac1.h
··· 1 - // SPDX-License-Identifier: GPL-2.0 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 2 /* 3 3 * u_uac1.h - Utility definitions for UAC1 function 4 4 *
+1 -1
drivers/usb/gadget/function/u_uac1_legacy.h
··· 1 - // SPDX-License-Identifier: GPL-2.0+ 1 + /* SPDX-License-Identifier: GPL-2.0+ */ 2 2 /* 3 3 * u_uac1.h -- interface to USB gadget "ALSA AUDIO" utilities 4 4 *
+1 -1
drivers/usb/gadget/function/u_uac2.h
··· 1 - // SPDX-License-Identifier: GPL-2.0 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 2 /* 3 3 * u_uac2.h 4 4 *
+1 -1
drivers/usb/gadget/function/u_uvc.h
··· 1 - // SPDX-License-Identifier: GPL-2.0 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 2 /* 3 3 * u_uvc.h 4 4 *
+3 -1
drivers/usb/gadget/function/uvc.h
··· 1 - // SPDX-License-Identifier: GPL-2.0+ 1 + /* SPDX-License-Identifier: GPL-2.0+ */ 2 2 /* 3 3 * uvc_gadget.h -- USB Video Class Gadget driver 4 4 * ··· 76 76 struct uvc_video { 77 77 struct uvc_device *uvc; 78 78 struct usb_ep *ep; 79 + 80 + struct work_struct pump; 79 81 80 82 /* Frame parameters */ 81 83 u8 bpp;
+1 -1
drivers/usb/gadget/function/uvc_configfs.h
··· 1 - // SPDX-License-Identifier: GPL-2.0 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 2 /* 3 3 * uvc_configfs.h 4 4 *
+3 -1
drivers/usb/gadget/function/uvc_v4l2.c
··· 169 169 if (ret < 0) 170 170 return ret; 171 171 172 - return uvcg_video_pump(video); 172 + schedule_work(&video->pump); 173 + 174 + return ret; 173 175 } 174 176 175 177 static int
+1 -1
drivers/usb/gadget/function/uvc_v4l2.h
··· 1 - // SPDX-License-Identifier: GPL-2.0 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 2 /* 3 3 * uvc_v4l2.h -- USB Video Class Gadget driver 4 4 *
+14 -62
drivers/usb/gadget/function/uvc_video.c
··· 142 142 return ret; 143 143 } 144 144 145 - /* 146 - * I somehow feel that synchronisation won't be easy to achieve here. We have 147 - * three events that control USB requests submission: 148 - * 149 - * - USB request completion: the completion handler will resubmit the request 150 - * if a video buffer is available. 151 - * 152 - * - USB interface setting selection: in response to a SET_INTERFACE request, 153 - * the handler will start streaming if a video buffer is available and if 154 - * video is not currently streaming. 155 - * 156 - * - V4L2 buffer queueing: the driver will start streaming if video is not 157 - * currently streaming. 158 - * 159 - * Race conditions between those 3 events might lead to deadlocks or other 160 - * nasty side effects. 161 - * 162 - * The "video currently streaming" condition can't be detected by the irqqueue 163 - * being empty, as a request can still be in flight. A separate "queue paused" 164 - * flag is thus needed. 165 - * 166 - * The paused flag will be set when we try to retrieve the irqqueue head if the 167 - * queue is empty, and cleared when we queue a buffer. 168 - * 169 - * The USB request completion handler will get the buffer at the irqqueue head 170 - * under protection of the queue spinlock. If the queue is empty, the streaming 171 - * paused flag will be set. Right after releasing the spinlock a userspace 172 - * application can queue a buffer. The flag will then cleared, and the ioctl 173 - * handler will restart the video stream. 174 - */ 175 145 static void 176 146 uvc_video_complete(struct usb_ep *ep, struct usb_request *req) 177 147 { 178 148 struct uvc_video *video = req->context; 179 149 struct uvc_video_queue *queue = &video->queue; 180 - struct uvc_buffer *buf; 181 150 unsigned long flags; 182 - int ret; 183 151 184 152 switch (req->status) { 185 153 case 0: ··· 156 188 case -ESHUTDOWN: /* disconnect from host. */ 157 189 uvcg_dbg(&video->uvc->func, "VS request cancelled.\n"); 158 190 uvcg_queue_cancel(queue, 1); 159 - goto requeue; 191 + break; 160 192 161 193 default: 162 194 uvcg_info(&video->uvc->func, 163 195 "VS request completed with status %d.\n", 164 196 req->status); 165 197 uvcg_queue_cancel(queue, 0); 166 - goto requeue; 167 198 } 168 199 169 - spin_lock_irqsave(&video->queue.irqlock, flags); 170 - buf = uvcg_queue_head(&video->queue); 171 - if (buf == NULL) { 172 - spin_unlock_irqrestore(&video->queue.irqlock, flags); 173 - goto requeue; 174 - } 175 - 176 - video->encode(req, video, buf); 177 - 178 - ret = uvcg_video_ep_queue(video, req); 179 - spin_unlock_irqrestore(&video->queue.irqlock, flags); 180 - 181 - if (ret < 0) { 182 - uvcg_queue_cancel(queue, 0); 183 - goto requeue; 184 - } 185 - 186 - return; 187 - 188 - requeue: 189 200 spin_lock_irqsave(&video->req_lock, flags); 190 201 list_add_tail(&req->list, &video->req_free); 191 202 spin_unlock_irqrestore(&video->req_lock, flags); 203 + 204 + schedule_work(&video->pump); 192 205 } 193 206 194 207 static int ··· 243 294 * This function fills the available USB requests (listed in req_free) with 244 295 * video data from the queued buffers. 245 296 */ 246 - int uvcg_video_pump(struct uvc_video *video) 297 + static void uvcg_video_pump(struct work_struct *work) 247 298 { 299 + struct uvc_video *video = container_of(work, struct uvc_video, pump); 248 300 struct uvc_video_queue *queue = &video->queue; 249 301 struct usb_request *req; 250 302 struct uvc_buffer *buf; 251 303 unsigned long flags; 252 304 int ret; 253 - 254 - /* FIXME TODO Race between uvcg_video_pump and requests completion 255 - * handler ??? 256 - */ 257 305 258 306 while (1) { 259 307 /* Retrieve the first available USB request, protected by the ··· 259 313 spin_lock_irqsave(&video->req_lock, flags); 260 314 if (list_empty(&video->req_free)) { 261 315 spin_unlock_irqrestore(&video->req_lock, flags); 262 - return 0; 316 + return; 263 317 } 264 318 req = list_first_entry(&video->req_free, struct usb_request, 265 319 list); ··· 291 345 spin_lock_irqsave(&video->req_lock, flags); 292 346 list_add_tail(&req->list, &video->req_free); 293 347 spin_unlock_irqrestore(&video->req_lock, flags); 294 - return 0; 348 + return; 295 349 } 296 350 297 351 /* ··· 309 363 } 310 364 311 365 if (!enable) { 366 + cancel_work_sync(&video->pump); 367 + uvcg_queue_cancel(&video->queue, 0); 368 + 312 369 for (i = 0; i < UVC_NUM_REQUESTS; ++i) 313 370 if (video->req[i]) 314 371 usb_ep_dequeue(video->ep, video->req[i]); ··· 333 384 } else 334 385 video->encode = uvc_video_encode_isoc; 335 386 336 - return uvcg_video_pump(video); 387 + schedule_work(&video->pump); 388 + 389 + return ret; 337 390 } 338 391 339 392 /* ··· 345 394 { 346 395 INIT_LIST_HEAD(&video->req_free); 347 396 spin_lock_init(&video->req_lock); 397 + INIT_WORK(&video->pump, uvcg_video_pump); 348 398 349 399 video->uvc = uvc; 350 400 video->fcc = V4L2_PIX_FMT_YUYV;
+1 -3
drivers/usb/gadget/function/uvc_video.h
··· 1 - // SPDX-License-Identifier: GPL-2.0 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 2 /* 3 3 * uvc_video.h -- USB Video Class Gadget driver 4 4 * ··· 13 13 #define __UVC_VIDEO_H__ 14 14 15 15 struct uvc_video; 16 - 17 - int uvcg_video_pump(struct uvc_video *video); 18 16 19 17 int uvcg_video_enable(struct uvc_video *video, int enable); 20 18
+2 -12
drivers/usb/gadget/legacy/mass_storage.c
··· 229 229 .unbind = msg_unbind, 230 230 }; 231 231 232 + module_usb_composite_driver(msg_driver); 233 + 232 234 MODULE_DESCRIPTION(DRIVER_DESC); 233 235 MODULE_AUTHOR("Michal Nazarewicz"); 234 236 MODULE_LICENSE("GPL"); 235 - 236 - static int __init msg_init(void) 237 - { 238 - return usb_composite_probe(&msg_driver); 239 - } 240 - module_init(msg_init); 241 - 242 - static void __exit msg_cleanup(void) 243 - { 244 - usb_composite_unregister(&msg_driver); 245 - } 246 - module_exit(msg_cleanup);
+12 -4
drivers/usb/gadget/udc/aspeed-vhub/core.c
··· 134 134 } 135 135 136 136 /* Handle device interrupts */ 137 - for (i = 0; i < vhub->max_ports; i++) { 138 - u32 dev_mask = VHUB_IRQ_DEVICE1 << i; 137 + if (istat & vhub->port_irq_mask) { 138 + unsigned long bitmap = istat; 139 + int offset = VHUB_IRQ_DEV1_BIT; 140 + int size = VHUB_IRQ_DEV1_BIT + vhub->max_ports; 139 141 140 - if (istat & dev_mask) 142 + for_each_set_bit_from(offset, &bitmap, size) { 143 + i = offset - VHUB_IRQ_DEV1_BIT; 141 144 ast_vhub_dev_irq(&vhub->ports[i].dev); 145 + } 142 146 } 143 147 144 148 /* Handle top-level vHub EP0 interrupts */ ··· 336 332 337 333 spin_lock_init(&vhub->lock); 338 334 vhub->pdev = pdev; 335 + vhub->port_irq_mask = GENMASK(VHUB_IRQ_DEV1_BIT + vhub->max_ports - 1, 336 + VHUB_IRQ_DEV1_BIT); 339 337 340 338 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 341 339 vhub->regs = devm_ioremap_resource(&pdev->dev, res); ··· 408 402 goto err; 409 403 410 404 /* Init hub emulation */ 411 - ast_vhub_init_hub(vhub); 405 + rc = ast_vhub_init_hub(vhub); 406 + if (rc) 407 + goto err; 412 408 413 409 /* Initialize HW */ 414 410 ast_vhub_init_hw(vhub);
+211 -25
drivers/usb/gadget/udc/aspeed-vhub/hub.c
··· 50 50 #define KERNEL_VER bin2bcd(((LINUX_VERSION_CODE >> 8) & 0x0ff)) 51 51 52 52 enum { 53 + AST_VHUB_STR_INDEX_MAX = 4, 53 54 AST_VHUB_STR_MANUF = 3, 54 55 AST_VHUB_STR_PRODUCT = 2, 55 56 AST_VHUB_STR_SERIAL = 1, ··· 72 71 .iSerialNumber = AST_VHUB_STR_SERIAL, 73 72 .bNumConfigurations = 1, 74 73 }; 75 - 76 - /* Patches to the above when forcing USB1 mode */ 77 - static void ast_vhub_patch_dev_desc_usb1(struct usb_device_descriptor *desc) 78 - { 79 - desc->bcdUSB = cpu_to_le16(0x0100); 80 - desc->bDeviceProtocol = 0; 81 - } 82 74 83 75 /* 84 76 * Configuration descriptor: same comments as above ··· 296 302 if (len > dsize) 297 303 len = dsize; 298 304 299 - /* Patch it if forcing USB1 */ 300 - if (desc_type == USB_DT_DEVICE && ep->vhub->force_usb1) 301 - ast_vhub_patch_dev_desc_usb1(ep->buf); 302 - 303 305 /* Shoot it from the EP buffer */ 304 306 return ast_vhub_reply(ep, NULL, len); 307 + } 308 + 309 + static struct usb_gadget_strings* 310 + ast_vhub_str_of_container(struct usb_gadget_string_container *container) 311 + { 312 + return (struct usb_gadget_strings *)container->stash; 313 + } 314 + 315 + static int ast_vhub_collect_languages(struct ast_vhub *vhub, void *buf, 316 + size_t size) 317 + { 318 + int rc, hdr_len, nlangs, max_langs; 319 + struct usb_gadget_strings *lang_str; 320 + struct usb_gadget_string_container *container; 321 + struct usb_string_descriptor *sdesc = buf; 322 + 323 + nlangs = 0; 324 + hdr_len = sizeof(struct usb_descriptor_header); 325 + max_langs = (size - hdr_len) / sizeof(sdesc->wData[0]); 326 + list_for_each_entry(container, &vhub->vhub_str_desc, list) { 327 + if (nlangs >= max_langs) 328 + break; 329 + 330 + lang_str = ast_vhub_str_of_container(container); 331 + sdesc->wData[nlangs++] = cpu_to_le16(lang_str->language); 332 + } 333 + 334 + rc = hdr_len + nlangs * sizeof(sdesc->wData[0]); 335 + sdesc->bLength = rc; 336 + sdesc->bDescriptorType = USB_DT_STRING; 337 + 338 + return rc; 339 + } 340 + 341 + static struct usb_gadget_strings *ast_vhub_lookup_string(struct ast_vhub *vhub, 342 + u16 lang_id) 343 + { 344 + struct usb_gadget_strings *lang_str; 345 + struct usb_gadget_string_container *container; 346 + 347 + list_for_each_entry(container, &vhub->vhub_str_desc, list) { 348 + lang_str = ast_vhub_str_of_container(container); 349 + if (lang_str->language == lang_id) 350 + return lang_str; 351 + } 352 + 353 + return NULL; 305 354 } 306 355 307 356 static int ast_vhub_rep_string(struct ast_vhub_ep *ep, 308 357 u8 string_id, u16 lang_id, 309 358 u16 len) 310 359 { 311 - int rc = usb_gadget_get_string(&ep->vhub->vhub_str_desc, 312 - string_id, ep->buf); 360 + int rc; 361 + u8 buf[256]; 362 + struct ast_vhub *vhub = ep->vhub; 363 + struct usb_gadget_strings *lang_str; 313 364 314 - /* 315 - * This should never happen unless we put too big strings in 316 - * the array above 317 - */ 318 - BUG_ON(rc >= AST_VHUB_EP0_MAX_PACKET); 365 + if (string_id == 0) { 366 + rc = ast_vhub_collect_languages(vhub, buf, sizeof(buf)); 367 + } else { 368 + lang_str = ast_vhub_lookup_string(vhub, lang_id); 369 + if (!lang_str) 370 + return std_req_stall; 319 371 320 - if (rc < 0) 372 + rc = usb_gadget_get_string(lang_str, string_id, buf); 373 + } 374 + 375 + if (rc < 0 || rc >= AST_VHUB_EP0_MAX_PACKET) 321 376 return std_req_stall; 322 377 323 378 /* Shoot it from the EP buffer */ 379 + memcpy(ep->buf, buf, rc); 324 380 return ast_vhub_reply(ep, NULL, min_t(u16, rc, len)); 325 381 } 326 382 ··· 876 832 writel(0, vhub->regs + AST_VHUB_EP1_STS_CHG); 877 833 } 878 834 879 - static void ast_vhub_init_desc(struct ast_vhub *vhub) 835 + static void ast_vhub_of_parse_dev_desc(struct ast_vhub *vhub, 836 + const struct device_node *vhub_np) 880 837 { 838 + u16 id; 839 + u32 data; 840 + 841 + if (!of_property_read_u32(vhub_np, "vhub-vendor-id", &data)) { 842 + id = (u16)data; 843 + vhub->vhub_dev_desc.idVendor = cpu_to_le16(id); 844 + } 845 + if (!of_property_read_u32(vhub_np, "vhub-product-id", &data)) { 846 + id = (u16)data; 847 + vhub->vhub_dev_desc.idProduct = cpu_to_le16(id); 848 + } 849 + if (!of_property_read_u32(vhub_np, "vhub-device-revision", &data)) { 850 + id = (u16)data; 851 + vhub->vhub_dev_desc.bcdDevice = cpu_to_le16(id); 852 + } 853 + } 854 + 855 + static void ast_vhub_fixup_usb1_dev_desc(struct ast_vhub *vhub) 856 + { 857 + vhub->vhub_dev_desc.bcdUSB = cpu_to_le16(0x0100); 858 + vhub->vhub_dev_desc.bDeviceProtocol = 0; 859 + } 860 + 861 + static struct usb_gadget_string_container* 862 + ast_vhub_str_container_alloc(struct ast_vhub *vhub) 863 + { 864 + unsigned int size; 865 + struct usb_string *str_array; 866 + struct usb_gadget_strings *lang_str; 867 + struct usb_gadget_string_container *container; 868 + 869 + size = sizeof(*container); 870 + size += sizeof(struct usb_gadget_strings); 871 + size += sizeof(struct usb_string) * AST_VHUB_STR_INDEX_MAX; 872 + container = devm_kzalloc(&vhub->pdev->dev, size, GFP_KERNEL); 873 + if (!container) 874 + return ERR_PTR(-ENOMEM); 875 + 876 + lang_str = ast_vhub_str_of_container(container); 877 + str_array = (struct usb_string *)(lang_str + 1); 878 + lang_str->strings = str_array; 879 + return container; 880 + } 881 + 882 + static void ast_vhub_str_deep_copy(struct usb_gadget_strings *dest, 883 + const struct usb_gadget_strings *src) 884 + { 885 + struct usb_string *src_array = src->strings; 886 + struct usb_string *dest_array = dest->strings; 887 + 888 + dest->language = src->language; 889 + if (src_array && dest_array) { 890 + do { 891 + *dest_array = *src_array; 892 + dest_array++; 893 + src_array++; 894 + } while (src_array->s); 895 + } 896 + } 897 + 898 + static int ast_vhub_str_alloc_add(struct ast_vhub *vhub, 899 + const struct usb_gadget_strings *src_str) 900 + { 901 + struct usb_gadget_strings *dest_str; 902 + struct usb_gadget_string_container *container; 903 + 904 + container = ast_vhub_str_container_alloc(vhub); 905 + if (IS_ERR(container)) 906 + return PTR_ERR(container); 907 + 908 + dest_str = ast_vhub_str_of_container(container); 909 + ast_vhub_str_deep_copy(dest_str, src_str); 910 + list_add_tail(&container->list, &vhub->vhub_str_desc); 911 + 912 + return 0; 913 + } 914 + 915 + static const struct { 916 + const char *name; 917 + u8 id; 918 + } str_id_map[] = { 919 + {"manufacturer", AST_VHUB_STR_MANUF}, 920 + {"product", AST_VHUB_STR_PRODUCT}, 921 + {"serial-number", AST_VHUB_STR_SERIAL}, 922 + {}, 923 + }; 924 + 925 + static int ast_vhub_of_parse_str_desc(struct ast_vhub *vhub, 926 + const struct device_node *desc_np) 927 + { 928 + u32 langid; 929 + int ret = 0; 930 + int i, offset; 931 + const char *str; 932 + struct device_node *child; 933 + struct usb_string str_array[AST_VHUB_STR_INDEX_MAX]; 934 + struct usb_gadget_strings lang_str = { 935 + .strings = (struct usb_string *)str_array, 936 + }; 937 + 938 + for_each_child_of_node(desc_np, child) { 939 + if (of_property_read_u32(child, "reg", &langid)) 940 + continue; /* no language identifier specified */ 941 + 942 + if (!usb_validate_langid(langid)) 943 + continue; /* invalid language identifier */ 944 + 945 + lang_str.language = langid; 946 + for (i = offset = 0; str_id_map[i].name; i++) { 947 + str = of_get_property(child, str_id_map[i].name, NULL); 948 + if (str) { 949 + str_array[offset].s = str; 950 + str_array[offset].id = str_id_map[i].id; 951 + offset++; 952 + } 953 + } 954 + str_array[offset].id = 0; 955 + str_array[offset].s = NULL; 956 + 957 + ret = ast_vhub_str_alloc_add(vhub, &lang_str); 958 + if (ret) 959 + break; 960 + } 961 + 962 + return ret; 963 + } 964 + 965 + static int ast_vhub_init_desc(struct ast_vhub *vhub) 966 + { 967 + int ret; 968 + struct device_node *desc_np; 969 + const struct device_node *vhub_np = vhub->pdev->dev.of_node; 970 + 881 971 /* Initialize vhub Device Descriptor. */ 882 972 memcpy(&vhub->vhub_dev_desc, &ast_vhub_dev_desc, 883 973 sizeof(vhub->vhub_dev_desc)); 974 + ast_vhub_of_parse_dev_desc(vhub, vhub_np); 975 + if (vhub->force_usb1) 976 + ast_vhub_fixup_usb1_dev_desc(vhub); 884 977 885 978 /* Initialize vhub Configuration Descriptor. */ 886 979 memcpy(&vhub->vhub_conf_desc, &ast_vhub_conf_desc, ··· 1029 848 vhub->vhub_hub_desc.bNbrPorts = vhub->max_ports; 1030 849 1031 850 /* Initialize vhub String Descriptors. */ 1032 - memcpy(&vhub->vhub_str_desc, &ast_vhub_strings, 1033 - sizeof(vhub->vhub_str_desc)); 851 + INIT_LIST_HEAD(&vhub->vhub_str_desc); 852 + desc_np = of_get_child_by_name(vhub_np, "vhub-strings"); 853 + if (desc_np) 854 + ret = ast_vhub_of_parse_str_desc(vhub, desc_np); 855 + else 856 + ret = ast_vhub_str_alloc_add(vhub, &ast_vhub_strings); 857 + 858 + return ret; 1034 859 } 1035 860 1036 - void ast_vhub_init_hub(struct ast_vhub *vhub) 861 + int ast_vhub_init_hub(struct ast_vhub *vhub) 1037 862 { 1038 863 vhub->speed = USB_SPEED_UNKNOWN; 1039 864 INIT_WORK(&vhub->wake_work, ast_vhub_wake_work); 1040 865 1041 - ast_vhub_init_desc(vhub); 866 + return ast_vhub_init_desc(vhub); 1042 867 } 1043 -
+5 -7
drivers/usb/gadget/udc/aspeed-vhub/vhub.h
··· 51 51 #define VHUB_CTRL_UPSTREAM_CONNECT (1 << 0) 52 52 53 53 /* IER & ISR */ 54 + #define VHUB_IRQ_DEV1_BIT 9 54 55 #define VHUB_IRQ_USB_CMD_DEADLOCK (1 << 18) 55 56 #define VHUB_IRQ_EP_POOL_NAK (1 << 17) 56 57 #define VHUB_IRQ_EP_POOL_ACK_STALL (1 << 16) 57 - #define VHUB_IRQ_DEVICE5 (1 << 13) 58 - #define VHUB_IRQ_DEVICE4 (1 << 12) 59 - #define VHUB_IRQ_DEVICE3 (1 << 11) 60 - #define VHUB_IRQ_DEVICE2 (1 << 10) 61 - #define VHUB_IRQ_DEVICE1 (1 << 9) 58 + #define VHUB_IRQ_DEVICE1 (1 << (VHUB_IRQ_DEV1_BIT)) 62 59 #define VHUB_IRQ_BUS_RESUME (1 << 8) 63 60 #define VHUB_IRQ_BUS_SUSPEND (1 << 7) 64 61 #define VHUB_IRQ_BUS_RESET (1 << 6) ··· 399 402 /* Per-port info */ 400 403 struct ast_vhub_port *ports; 401 404 u32 max_ports; 405 + u32 port_irq_mask; 402 406 403 407 /* Generic EP data structures */ 404 408 struct ast_vhub_ep *epns; ··· 421 423 struct usb_device_descriptor vhub_dev_desc; 422 424 struct ast_vhub_full_cdesc vhub_conf_desc; 423 425 struct usb_hub_descriptor vhub_hub_desc; 424 - struct usb_gadget_strings vhub_str_desc; 426 + struct list_head vhub_str_desc; 425 427 }; 426 428 427 429 /* Standard request handlers result codes */ ··· 531 533 __VA_ARGS__) 532 534 533 535 /* hub.c */ 534 - void ast_vhub_init_hub(struct ast_vhub *vhub); 536 + int ast_vhub_init_hub(struct ast_vhub *vhub); 535 537 enum std_req_rc ast_vhub_std_hub_request(struct ast_vhub_ep *ep, 536 538 struct usb_ctrlrequest *crq); 537 539 enum std_req_rc ast_vhub_class_hub_request(struct ast_vhub_ep *ep,
+72 -40
drivers/usb/gadget/udc/atmel_usba_udc.c
··· 2043 2043 .pulse_bias = at91sam9g45_pulse_bias, 2044 2044 }; 2045 2045 2046 + static const struct usba_ep_config ep_config_sam9[] __initconst = { 2047 + { .nr_banks = 1 }, /* ep 0 */ 2048 + { .nr_banks = 2, .can_dma = 1, .can_isoc = 1 }, /* ep 1 */ 2049 + { .nr_banks = 2, .can_dma = 1, .can_isoc = 1 }, /* ep 2 */ 2050 + { .nr_banks = 3, .can_dma = 1 }, /* ep 3 */ 2051 + { .nr_banks = 3, .can_dma = 1 }, /* ep 4 */ 2052 + { .nr_banks = 3, .can_dma = 1, .can_isoc = 1 }, /* ep 5 */ 2053 + { .nr_banks = 3, .can_dma = 1, .can_isoc = 1 }, /* ep 6 */ 2054 + }; 2055 + 2056 + static const struct usba_ep_config ep_config_sama5[] __initconst = { 2057 + { .nr_banks = 1 }, /* ep 0 */ 2058 + { .nr_banks = 3, .can_dma = 1, .can_isoc = 1 }, /* ep 1 */ 2059 + { .nr_banks = 3, .can_dma = 1, .can_isoc = 1 }, /* ep 2 */ 2060 + { .nr_banks = 2, .can_dma = 1, .can_isoc = 1 }, /* ep 3 */ 2061 + { .nr_banks = 2, .can_dma = 1, .can_isoc = 1 }, /* ep 4 */ 2062 + { .nr_banks = 2, .can_dma = 1, .can_isoc = 1 }, /* ep 5 */ 2063 + { .nr_banks = 2, .can_dma = 1, .can_isoc = 1 }, /* ep 6 */ 2064 + { .nr_banks = 2, .can_dma = 1, .can_isoc = 1 }, /* ep 7 */ 2065 + { .nr_banks = 2, .can_isoc = 1 }, /* ep 8 */ 2066 + { .nr_banks = 2, .can_isoc = 1 }, /* ep 9 */ 2067 + { .nr_banks = 2, .can_isoc = 1 }, /* ep 10 */ 2068 + { .nr_banks = 2, .can_isoc = 1 }, /* ep 11 */ 2069 + { .nr_banks = 2, .can_isoc = 1 }, /* ep 12 */ 2070 + { .nr_banks = 2, .can_isoc = 1 }, /* ep 13 */ 2071 + { .nr_banks = 2, .can_isoc = 1 }, /* ep 14 */ 2072 + { .nr_banks = 2, .can_isoc = 1 }, /* ep 15 */ 2073 + }; 2074 + 2075 + static const struct usba_udc_config udc_at91sam9rl_cfg = { 2076 + .errata = &at91sam9rl_errata, 2077 + .config = ep_config_sam9, 2078 + .num_ep = ARRAY_SIZE(ep_config_sam9), 2079 + }; 2080 + 2081 + static const struct usba_udc_config udc_at91sam9g45_cfg = { 2082 + .errata = &at91sam9g45_errata, 2083 + .config = ep_config_sam9, 2084 + .num_ep = ARRAY_SIZE(ep_config_sam9), 2085 + }; 2086 + 2087 + static const struct usba_udc_config udc_sama5d3_cfg = { 2088 + .config = ep_config_sama5, 2089 + .num_ep = ARRAY_SIZE(ep_config_sama5), 2090 + }; 2091 + 2046 2092 static const struct of_device_id atmel_udc_dt_ids[] = { 2047 - { .compatible = "atmel,at91sam9rl-udc", .data = &at91sam9rl_errata }, 2048 - { .compatible = "atmel,at91sam9g45-udc", .data = &at91sam9g45_errata }, 2049 - { .compatible = "atmel,sama5d3-udc" }, 2093 + { .compatible = "atmel,at91sam9rl-udc", .data = &udc_at91sam9rl_cfg }, 2094 + { .compatible = "atmel,at91sam9g45-udc", .data = &udc_at91sam9g45_cfg }, 2095 + { .compatible = "atmel,sama5d3-udc", .data = &udc_sama5d3_cfg }, 2050 2096 { /* sentinel */ } 2051 2097 }; 2052 2098 ··· 2101 2055 static struct usba_ep * atmel_udc_of_init(struct platform_device *pdev, 2102 2056 struct usba_udc *udc) 2103 2057 { 2104 - u32 val; 2105 2058 struct device_node *np = pdev->dev.of_node; 2106 2059 const struct of_device_id *match; 2107 2060 struct device_node *pp; 2108 2061 int i, ret; 2109 2062 struct usba_ep *eps, *ep; 2063 + const struct usba_udc_config *udc_config; 2110 2064 2111 2065 match = of_match_node(atmel_udc_dt_ids, np); 2112 2066 if (!match) 2113 2067 return ERR_PTR(-EINVAL); 2114 2068 2115 - udc->errata = match->data; 2069 + udc_config = match->data; 2070 + udc->errata = udc_config->errata; 2116 2071 udc->pmc = syscon_regmap_lookup_by_compatible("atmel,at91sam9g45-pmc"); 2117 2072 if (IS_ERR(udc->pmc)) 2118 2073 udc->pmc = syscon_regmap_lookup_by_compatible("atmel,at91sam9rl-pmc"); ··· 2129 2082 2130 2083 if (fifo_mode == 0) { 2131 2084 pp = NULL; 2132 - while ((pp = of_get_next_child(np, pp))) 2133 - udc->num_ep++; 2085 + udc->num_ep = udc_config->num_ep; 2134 2086 udc->configured_ep = 1; 2135 2087 } else { 2136 2088 udc->num_ep = usba_config_fifo_table(udc); ··· 2146 2100 2147 2101 pp = NULL; 2148 2102 i = 0; 2149 - while ((pp = of_get_next_child(np, pp)) && i < udc->num_ep) { 2103 + while (i < udc->num_ep) { 2104 + const struct usba_ep_config *ep_cfg = &udc_config->config[i]; 2105 + 2150 2106 ep = &eps[i]; 2151 2107 2152 - ret = of_property_read_u32(pp, "reg", &val); 2153 - if (ret) { 2154 - dev_err(&pdev->dev, "of_probe: reg error(%d)\n", ret); 2155 - goto err; 2156 - } 2157 - ep->index = fifo_mode ? udc->fifo_cfg[i].hw_ep_num : val; 2108 + ep->index = fifo_mode ? udc->fifo_cfg[i].hw_ep_num : i; 2158 2109 2159 - ret = of_property_read_u32(pp, "atmel,fifo-size", &val); 2160 - if (ret) { 2161 - dev_err(&pdev->dev, "of_probe: fifo-size error(%d)\n", ret); 2162 - goto err; 2163 - } 2110 + /* Only the first EP is 64 bytes */ 2111 + if (ep->index == 0) 2112 + ep->fifo_size = 64; 2113 + else 2114 + ep->fifo_size = 1024; 2115 + 2164 2116 if (fifo_mode) { 2165 - if (val < udc->fifo_cfg[i].fifo_size) { 2117 + if (ep->fifo_size < udc->fifo_cfg[i].fifo_size) 2166 2118 dev_warn(&pdev->dev, 2167 - "Using max fifo-size value from DT\n"); 2168 - ep->fifo_size = val; 2169 - } else { 2119 + "Using default max fifo-size value\n"); 2120 + else 2170 2121 ep->fifo_size = udc->fifo_cfg[i].fifo_size; 2171 - } 2172 - } else { 2173 - ep->fifo_size = val; 2174 2122 } 2175 2123 2176 - ret = of_property_read_u32(pp, "atmel,nb-banks", &val); 2177 - if (ret) { 2178 - dev_err(&pdev->dev, "of_probe: nb-banks error(%d)\n", ret); 2179 - goto err; 2180 - } 2124 + ep->nr_banks = ep_cfg->nr_banks; 2181 2125 if (fifo_mode) { 2182 - if (val < udc->fifo_cfg[i].nr_banks) { 2126 + if (ep->nr_banks < udc->fifo_cfg[i].nr_banks) 2183 2127 dev_warn(&pdev->dev, 2184 - "Using max nb-banks value from DT\n"); 2185 - ep->nr_banks = val; 2186 - } else { 2128 + "Using default max nb-banks value\n"); 2129 + else 2187 2130 ep->nr_banks = udc->fifo_cfg[i].nr_banks; 2188 - } 2189 - } else { 2190 - ep->nr_banks = val; 2191 2131 } 2192 2132 2193 - ep->can_dma = of_property_read_bool(pp, "atmel,can-dma"); 2194 - ep->can_isoc = of_property_read_bool(pp, "atmel,can-isoc"); 2133 + ep->can_dma = ep_cfg->can_dma; 2134 + ep->can_isoc = ep_cfg->can_isoc; 2195 2135 2196 2136 sprintf(ep->name, "ep%d", ep->index); 2197 2137 ep->ep.name = ep->name;
+12
drivers/usb/gadget/udc/atmel_usba_udc.h
··· 290 290 #endif 291 291 }; 292 292 293 + struct usba_ep_config { 294 + u8 nr_banks; 295 + unsigned int can_dma:1; 296 + unsigned int can_isoc:1; 297 + }; 298 + 293 299 struct usba_request { 294 300 struct usb_request req; 295 301 struct list_head queue; ··· 311 305 struct usba_udc_errata { 312 306 void (*toggle_bias)(struct usba_udc *udc, int is_on); 313 307 void (*pulse_bias)(struct usba_udc *udc); 308 + }; 309 + 310 + struct usba_udc_config { 311 + const struct usba_udc_errata *errata; 312 + const struct usba_ep_config *config; 313 + const int num_ep; 314 314 }; 315 315 316 316 struct usba_udc {
+2
drivers/usb/gadget/udc/core.c
··· 1297 1297 kobject_uevent(&udc->dev.kobj, KOBJ_CHANGE); 1298 1298 1299 1299 usb_gadget_disconnect(udc->gadget); 1300 + if (udc->gadget->irq) 1301 + synchronize_irq(udc->gadget->irq); 1300 1302 udc->driver->unbind(udc->gadget); 1301 1303 usb_gadget_udc_stop(udc); 1302 1304
+14 -13
drivers/usb/gadget/udc/dummy_hcd.c
··· 187 187 USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_IN)), 188 188 189 189 /* and now some generic EPs so we have enough in multi config */ 190 - EP_INFO("ep3out", 190 + EP_INFO("ep-aout", 191 191 USB_EP_CAPS(TYPE_BULK_OR_INT, USB_EP_CAPS_DIR_OUT)), 192 - EP_INFO("ep4in", 192 + EP_INFO("ep-bin", 193 193 USB_EP_CAPS(TYPE_BULK_OR_INT, USB_EP_CAPS_DIR_IN)), 194 - EP_INFO("ep5out", 194 + EP_INFO("ep-cout", 195 195 USB_EP_CAPS(TYPE_BULK_OR_INT, USB_EP_CAPS_DIR_OUT)), 196 - EP_INFO("ep6out", 196 + EP_INFO("ep-dout", 197 197 USB_EP_CAPS(TYPE_BULK_OR_INT, USB_EP_CAPS_DIR_OUT)), 198 - EP_INFO("ep7in", 198 + EP_INFO("ep-ein", 199 199 USB_EP_CAPS(TYPE_BULK_OR_INT, USB_EP_CAPS_DIR_IN)), 200 - EP_INFO("ep8out", 200 + EP_INFO("ep-fout", 201 201 USB_EP_CAPS(TYPE_BULK_OR_INT, USB_EP_CAPS_DIR_OUT)), 202 - EP_INFO("ep9in", 202 + EP_INFO("ep-gin", 203 203 USB_EP_CAPS(TYPE_BULK_OR_INT, USB_EP_CAPS_DIR_IN)), 204 - EP_INFO("ep10out", 204 + EP_INFO("ep-hout", 205 205 USB_EP_CAPS(TYPE_BULK_OR_INT, USB_EP_CAPS_DIR_OUT)), 206 - EP_INFO("ep11out", 206 + EP_INFO("ep-iout", 207 207 USB_EP_CAPS(TYPE_BULK_OR_INT, USB_EP_CAPS_DIR_OUT)), 208 - EP_INFO("ep12in", 208 + EP_INFO("ep-jin", 209 209 USB_EP_CAPS(TYPE_BULK_OR_INT, USB_EP_CAPS_DIR_IN)), 210 - EP_INFO("ep13out", 210 + EP_INFO("ep-kout", 211 211 USB_EP_CAPS(TYPE_BULK_OR_INT, USB_EP_CAPS_DIR_OUT)), 212 - EP_INFO("ep14in", 212 + EP_INFO("ep-lin", 213 213 USB_EP_CAPS(TYPE_BULK_OR_INT, USB_EP_CAPS_DIR_IN)), 214 - EP_INFO("ep15out", 214 + EP_INFO("ep-mout", 215 215 USB_EP_CAPS(TYPE_BULK_OR_INT, USB_EP_CAPS_DIR_OUT)), 216 216 217 217 #undef EP_INFO ··· 427 427 428 428 /* caller must hold lock */ 429 429 static void set_link_state(struct dummy_hcd *dum_hcd) 430 + __must_hold(&dum->lock) 430 431 { 431 432 struct dummy *dum = dum_hcd->dum; 432 433 unsigned int power_bit;
+2 -2
drivers/usb/gadget/udc/fsl_udc_core.c
··· 2440 2440 udc_controller->max_ep = (dccparams & DCCPARAMS_DEN_MASK) * 2; 2441 2441 2442 2442 udc_controller->irq = platform_get_irq(pdev, 0); 2443 - if (!udc_controller->irq) { 2444 - ret = -ENODEV; 2443 + if (udc_controller->irq <= 0) { 2444 + ret = udc_controller->irq ? : -ENODEV; 2445 2445 goto err_iounmap; 2446 2446 } 2447 2447
+6 -5
drivers/usb/gadget/udc/lpc32xx_udc.c
··· 1614 1614 const struct usb_endpoint_descriptor *desc) 1615 1615 { 1616 1616 struct lpc32xx_ep *ep = container_of(_ep, struct lpc32xx_ep, ep); 1617 - struct lpc32xx_udc *udc = ep->udc; 1617 + struct lpc32xx_udc *udc; 1618 1618 u16 maxpacket; 1619 1619 u32 tmp; 1620 1620 unsigned long flags; 1621 1621 1622 1622 /* Verify EP data */ 1623 1623 if ((!_ep) || (!ep) || (!desc) || 1624 - (desc->bDescriptorType != USB_DT_ENDPOINT)) { 1625 - dev_dbg(udc->dev, "bad ep or descriptor\n"); 1624 + (desc->bDescriptorType != USB_DT_ENDPOINT)) 1626 1625 return -EINVAL; 1627 - } 1626 + 1627 + udc = ep->udc; 1628 1628 maxpacket = usb_endpoint_maxp(desc); 1629 1629 if ((maxpacket == 0) || (maxpacket > ep->maxpacket)) { 1630 1630 dev_dbg(udc->dev, "bad ep descriptor's packet size\n"); ··· 1872 1872 static int lpc32xx_ep_set_halt(struct usb_ep *_ep, int value) 1873 1873 { 1874 1874 struct lpc32xx_ep *ep = container_of(_ep, struct lpc32xx_ep, ep); 1875 - struct lpc32xx_udc *udc = ep->udc; 1875 + struct lpc32xx_udc *udc; 1876 1876 unsigned long flags; 1877 1877 1878 1878 if ((!ep) || (ep->hwep_num <= 1)) ··· 1882 1882 if (ep->is_in) 1883 1883 return -EAGAIN; 1884 1884 1885 + udc = ep->udc; 1885 1886 spin_lock_irqsave(&udc->lock, flags); 1886 1887 1887 1888 if (value == 1) {
+1 -1
drivers/usb/gadget/udc/m66592-udc.c
··· 1667 1667 1668 1668 err_add_udc: 1669 1669 m66592_free_request(&m66592->ep[0].ep, m66592->ep0_req); 1670 - 1670 + m66592->ep0_req = NULL; 1671 1671 clean_up3: 1672 1672 if (m66592->pdata->on_chip) { 1673 1673 clk_disable(m66592->clk);
+1 -1
drivers/usb/gadget/udc/max3420_udc.c
··· 901 901 } 902 902 903 903 set_current_state(TASK_RUNNING); 904 - dev_info(udc->dev, "SPI thread exiting"); 904 + dev_info(udc->dev, "SPI thread exiting\n"); 905 905 return 0; 906 906 } 907 907
+1 -1
drivers/usb/gadget/udc/mv_u3d_core.c
··· 1548 1548 delegate = true; 1549 1549 1550 1550 /* delegate USB standard requests to the gadget driver */ 1551 - if (delegate == true) { 1551 + if (delegate) { 1552 1552 /* USB requests handled by gadget */ 1553 1553 if (setup->wLength) { 1554 1554 /* DATA phase from gadget, STATUS phase from u3d */
+1 -1
drivers/usb/gadget/udc/net2272.c
··· 54 54 * 55 55 * If use_dma is disabled, pio will be used instead. 56 56 */ 57 - static bool use_dma = 0; 57 + static bool use_dma = false; 58 58 module_param(use_dma, bool, 0644); 59 59 60 60 /*
+1 -1
drivers/usb/gadget/udc/omap_udc.c
··· 2576 2576 case USB_ENDPOINT_XFER_INT: 2577 2577 ep->ep.caps.type_int = true; 2578 2578 break; 2579 - }; 2579 + } 2580 2580 2581 2581 if (addr & USB_DIR_IN) 2582 2582 ep->ep.caps.dir_in = true;
-4
drivers/usb/gadget/udc/s3c2410_udc.c
··· 251 251 static void s3c2410_udc_nuke(struct s3c2410_udc *udc, 252 252 struct s3c2410_ep *ep, int status) 253 253 { 254 - /* Sanity check */ 255 - if (&ep->queue == NULL) 256 - return; 257 - 258 254 while (!list_empty(&ep->queue)) { 259 255 struct s3c2410_request *req; 260 256 req = list_entry(ep->queue.next, struct s3c2410_request,
+140
drivers/usb/gadget/udc/tegra-xudc.c
··· 158 158 #define SSPX_CORE_CNT32_POLL_TBURST_MAX_MASK GENMASK(7, 0) 159 159 #define SSPX_CORE_CNT32_POLL_TBURST_MAX(x) ((x) & \ 160 160 SSPX_CORE_CNT32_POLL_TBURST_MAX_MASK) 161 + #define SSPX_CORE_CNT56 0x6fc 162 + #define SSPX_CORE_CNT56_SCD_BIT0_TRPT_MAX_MASK GENMASK(19, 0) 163 + #define SSPX_CORE_CNT56_SCD_BIT0_TRPT_MAX(x) ((x) & \ 164 + SSPX_CORE_CNT56_SCD_BIT0_TRPT_MAX_MASK) 165 + #define SSPX_CORE_CNT57 0x700 166 + #define SSPX_CORE_CNT57_SCD_BIT1_TRPT_MAX_MASK GENMASK(19, 0) 167 + #define SSPX_CORE_CNT57_SCD_BIT1_TRPT_MAX(x) ((x) & \ 168 + SSPX_CORE_CNT57_SCD_BIT1_TRPT_MAX_MASK) 169 + #define SSPX_CORE_CNT65 0x720 170 + #define SSPX_CORE_CNT65_TX_SCD_END_TRPT_MID_MASK GENMASK(19, 0) 171 + #define SSPX_CORE_CNT65_TX_SCD_END_TRPT_MID(x) ((x) & \ 172 + SSPX_CORE_CNT65_TX_SCD_END_TRPT_MID_MASK) 173 + #define SSPX_CORE_CNT66 0x724 174 + #define SSPX_CORE_CNT66_TX_SCD_BIT0_TRPT_MID_MASK GENMASK(19, 0) 175 + #define SSPX_CORE_CNT66_TX_SCD_BIT0_TRPT_MID(x) ((x) & \ 176 + SSPX_CORE_CNT66_TX_SCD_BIT0_TRPT_MID_MASK) 177 + #define SSPX_CORE_CNT67 0x728 178 + #define SSPX_CORE_CNT67_TX_SCD_BIT1_TRPT_MID_MASK GENMASK(19, 0) 179 + #define SSPX_CORE_CNT67_TX_SCD_BIT1_TRPT_MID(x) ((x) & \ 180 + SSPX_CORE_CNT67_TX_SCD_BIT1_TRPT_MID_MASK) 181 + #define SSPX_CORE_CNT72 0x73c 182 + #define SSPX_CORE_CNT72_SCD_LFPS_TIMEOUT_MASK GENMASK(19, 0) 183 + #define SSPX_CORE_CNT72_SCD_LFPS_TIMEOUT(x) ((x) & \ 184 + SSPX_CORE_CNT72_SCD_LFPS_TIMEOUT_MASK) 161 185 #define SSPX_CORE_PADCTL4 0x750 162 186 #define SSPX_CORE_PADCTL4_RXDAT_VLD_TIMEOUT_U3_MASK GENMASK(19, 0) 163 187 #define SSPX_CORE_PADCTL4_RXDAT_VLD_TIMEOUT_U3(x) ((x) & \ ··· 516 492 bool powergated; 517 493 518 494 struct usb_phy **usbphy; 495 + struct usb_phy *curr_usbphy; 519 496 struct notifier_block vbus_nb; 520 497 521 498 struct completion disconnect_complete; ··· 555 530 bool invalid_seq_num; 556 531 bool pls_quirk; 557 532 bool port_reset_quirk; 533 + bool port_speed_quirk; 558 534 bool has_ipfs; 559 535 }; 560 536 ··· 625 599 trb->control); 626 600 } 627 601 602 + static void tegra_xudc_limit_port_speed(struct tegra_xudc *xudc) 603 + { 604 + u32 val; 605 + 606 + /* limit port speed to gen 1 */ 607 + val = xudc_readl(xudc, SSPX_CORE_CNT56); 608 + val &= ~(SSPX_CORE_CNT56_SCD_BIT0_TRPT_MAX_MASK); 609 + val |= SSPX_CORE_CNT56_SCD_BIT0_TRPT_MAX(0x260); 610 + xudc_writel(xudc, val, SSPX_CORE_CNT56); 611 + 612 + val = xudc_readl(xudc, SSPX_CORE_CNT57); 613 + val &= ~(SSPX_CORE_CNT57_SCD_BIT1_TRPT_MAX_MASK); 614 + val |= SSPX_CORE_CNT57_SCD_BIT1_TRPT_MAX(0x6D6); 615 + xudc_writel(xudc, val, SSPX_CORE_CNT57); 616 + 617 + val = xudc_readl(xudc, SSPX_CORE_CNT65); 618 + val &= ~(SSPX_CORE_CNT65_TX_SCD_END_TRPT_MID_MASK); 619 + val |= SSPX_CORE_CNT65_TX_SCD_END_TRPT_MID(0x4B0); 620 + xudc_writel(xudc, val, SSPX_CORE_CNT66); 621 + 622 + val = xudc_readl(xudc, SSPX_CORE_CNT66); 623 + val &= ~(SSPX_CORE_CNT66_TX_SCD_BIT0_TRPT_MID_MASK); 624 + val |= SSPX_CORE_CNT66_TX_SCD_BIT0_TRPT_MID(0x4B0); 625 + xudc_writel(xudc, val, SSPX_CORE_CNT66); 626 + 627 + val = xudc_readl(xudc, SSPX_CORE_CNT67); 628 + val &= ~(SSPX_CORE_CNT67_TX_SCD_BIT1_TRPT_MID_MASK); 629 + val |= SSPX_CORE_CNT67_TX_SCD_BIT1_TRPT_MID(0x4B0); 630 + xudc_writel(xudc, val, SSPX_CORE_CNT67); 631 + 632 + val = xudc_readl(xudc, SSPX_CORE_CNT72); 633 + val &= ~(SSPX_CORE_CNT72_SCD_LFPS_TIMEOUT_MASK); 634 + val |= SSPX_CORE_CNT72_SCD_LFPS_TIMEOUT(0x10); 635 + xudc_writel(xudc, val, SSPX_CORE_CNT72); 636 + } 637 + 638 + static void tegra_xudc_restore_port_speed(struct tegra_xudc *xudc) 639 + { 640 + u32 val; 641 + 642 + /* restore port speed to gen2 */ 643 + val = xudc_readl(xudc, SSPX_CORE_CNT56); 644 + val &= ~(SSPX_CORE_CNT56_SCD_BIT0_TRPT_MAX_MASK); 645 + val |= SSPX_CORE_CNT56_SCD_BIT0_TRPT_MAX(0x438); 646 + xudc_writel(xudc, val, SSPX_CORE_CNT56); 647 + 648 + val = xudc_readl(xudc, SSPX_CORE_CNT57); 649 + val &= ~(SSPX_CORE_CNT57_SCD_BIT1_TRPT_MAX_MASK); 650 + val |= SSPX_CORE_CNT57_SCD_BIT1_TRPT_MAX(0x528); 651 + xudc_writel(xudc, val, SSPX_CORE_CNT57); 652 + 653 + val = xudc_readl(xudc, SSPX_CORE_CNT65); 654 + val &= ~(SSPX_CORE_CNT65_TX_SCD_END_TRPT_MID_MASK); 655 + val |= SSPX_CORE_CNT65_TX_SCD_END_TRPT_MID(0xE10); 656 + xudc_writel(xudc, val, SSPX_CORE_CNT66); 657 + 658 + val = xudc_readl(xudc, SSPX_CORE_CNT66); 659 + val &= ~(SSPX_CORE_CNT66_TX_SCD_BIT0_TRPT_MID_MASK); 660 + val |= SSPX_CORE_CNT66_TX_SCD_BIT0_TRPT_MID(0x348); 661 + xudc_writel(xudc, val, SSPX_CORE_CNT66); 662 + 663 + val = xudc_readl(xudc, SSPX_CORE_CNT67); 664 + val &= ~(SSPX_CORE_CNT67_TX_SCD_BIT1_TRPT_MID_MASK); 665 + val |= SSPX_CORE_CNT67_TX_SCD_BIT1_TRPT_MID(0x5a0); 666 + xudc_writel(xudc, val, SSPX_CORE_CNT67); 667 + 668 + val = xudc_readl(xudc, SSPX_CORE_CNT72); 669 + val &= ~(SSPX_CORE_CNT72_SCD_LFPS_TIMEOUT_MASK); 670 + val |= SSPX_CORE_CNT72_SCD_LFPS_TIMEOUT(0x1c21); 671 + xudc_writel(xudc, val, SSPX_CORE_CNT72); 672 + } 673 + 628 674 static void tegra_xudc_device_mode_on(struct tegra_xudc *xudc) 629 675 { 630 676 int err; ··· 728 630 connected = !!(xudc_readl(xudc, PORTSC) & PORTSC_CCS); 729 631 730 632 reinit_completion(&xudc->disconnect_complete); 633 + 634 + if (xudc->soc->port_speed_quirk) 635 + tegra_xudc_restore_port_speed(xudc); 731 636 732 637 phy_set_mode_ext(xudc->curr_utmi_phy, PHY_MODE_USB_OTG, USB_ROLE_NONE); 733 638 ··· 820 719 if (!xudc->suspended && phy_index != -1) { 821 720 xudc->curr_utmi_phy = xudc->utmi_phy[phy_index]; 822 721 xudc->curr_usb3_phy = xudc->usb3_phy[phy_index]; 722 + xudc->curr_usbphy = usbphy; 823 723 schedule_work(&xudc->usb_role_sw_work); 824 724 } 825 725 ··· 2144 2042 return 0; 2145 2043 } 2146 2044 2045 + static int tegra_xudc_gadget_vbus_draw(struct usb_gadget *gadget, 2046 + unsigned int m_a) 2047 + { 2048 + int ret = 0; 2049 + struct tegra_xudc *xudc = to_xudc(gadget); 2050 + 2051 + dev_dbg(xudc->dev, "%s: %u mA\n", __func__, m_a); 2052 + 2053 + if (xudc->curr_usbphy->chg_type == SDP_TYPE) 2054 + ret = usb_phy_set_power(xudc->curr_usbphy, m_a); 2055 + 2056 + return ret; 2057 + } 2058 + 2147 2059 static int tegra_xudc_set_selfpowered(struct usb_gadget *gadget, int is_on) 2148 2060 { 2149 2061 struct tegra_xudc *xudc = to_xudc(gadget); ··· 2174 2058 .pullup = tegra_xudc_gadget_pullup, 2175 2059 .udc_start = tegra_xudc_gadget_start, 2176 2060 .udc_stop = tegra_xudc_gadget_stop, 2061 + .vbus_draw = tegra_xudc_gadget_vbus_draw, 2177 2062 .set_selfpowered = tegra_xudc_set_selfpowered, 2178 2063 }; 2179 2064 ··· 3391 3274 xudc_writel(xudc, val, BLCG); 3392 3275 } 3393 3276 3277 + if (xudc->soc->port_speed_quirk) 3278 + tegra_xudc_limit_port_speed(xudc); 3279 + 3394 3280 /* Set a reasonable U3 exit timer value. */ 3395 3281 val = xudc_readl(xudc, SSPX_CORE_PADCTL4); 3396 3282 val &= ~(SSPX_CORE_PADCTL4_RXDAT_VLD_TIMEOUT_U3_MASK); ··· 3626 3506 .invalid_seq_num = true, 3627 3507 .pls_quirk = true, 3628 3508 .port_reset_quirk = true, 3509 + .port_speed_quirk = false, 3629 3510 .has_ipfs = true, 3630 3511 }; 3631 3512 ··· 3640 3519 .invalid_seq_num = false, 3641 3520 .pls_quirk = false, 3642 3521 .port_reset_quirk = false, 3522 + .port_speed_quirk = false, 3523 + .has_ipfs = false, 3524 + }; 3525 + 3526 + static struct tegra_xudc_soc tegra194_xudc_soc_data = { 3527 + .clock_names = tegra186_xudc_clock_names, 3528 + .num_clks = ARRAY_SIZE(tegra186_xudc_clock_names), 3529 + .num_phys = 4, 3530 + .u1_enable = true, 3531 + .u2_enable = true, 3532 + .lpm_enable = true, 3533 + .invalid_seq_num = false, 3534 + .pls_quirk = false, 3535 + .port_reset_quirk = false, 3536 + .port_speed_quirk = true, 3643 3537 .has_ipfs = false, 3644 3538 }; 3645 3539 ··· 3666 3530 { 3667 3531 .compatible = "nvidia,tegra186-xudc", 3668 3532 .data = &tegra186_xudc_soc_data 3533 + }, 3534 + { 3535 + .compatible = "nvidia,tegra194-xudc", 3536 + .data = &tegra194_xudc_soc_data 3669 3537 }, 3670 3538 { } 3671 3539 };
+1
drivers/usb/gadget/udc/udc-xilinx.c
··· 1732 1732 * Process setup packet and delegate to gadget layer. 1733 1733 */ 1734 1734 static void xudc_handle_setup(struct xusb_udc *udc) 1735 + __must_hold(&udc->lock) 1735 1736 { 1736 1737 struct xusb_ep *ep0 = &udc->ep[0]; 1737 1738 struct usb_ctrlrequest setup;
+24
drivers/usb/gadget/usbstring.c
··· 65 65 return buf [0]; 66 66 } 67 67 EXPORT_SYMBOL_GPL(usb_gadget_get_string); 68 + 69 + /** 70 + * usb_validate_langid - validate usb language identifiers 71 + * @lang: usb language identifier 72 + * 73 + * Returns true for valid language identifier, otherwise false. 74 + */ 75 + bool usb_validate_langid(u16 langid) 76 + { 77 + u16 primary_lang = langid & 0x3ff; /* bit [9:0] */ 78 + u16 sub_lang = langid >> 10; /* bit [15:10] */ 79 + 80 + switch (primary_lang) { 81 + case 0: 82 + case 0x62 ... 0xfe: 83 + case 0x100 ... 0x3ff: 84 + return false; 85 + } 86 + if (!sub_lang) 87 + return false; 88 + 89 + return true; 90 + } 91 + EXPORT_SYMBOL_GPL(usb_validate_langid);
+3
include/linux/usb/composite.h
··· 249 249 250 250 int usb_interface_id(struct usb_configuration *, struct usb_function *); 251 251 252 + int config_ep_by_speed_and_alt(struct usb_gadget *g, struct usb_function *f, 253 + struct usb_ep *_ep, u8 alt); 254 + 252 255 int config_ep_by_speed(struct usb_gadget *g, struct usb_function *f, 253 256 struct usb_ep *_ep); 254 257
+8
include/linux/usb/gadget.h
··· 42 42 * @num_mapped_sgs: number of SG entries mapped to DMA (internal) 43 43 * @length: Length of that data 44 44 * @stream_id: The stream id, when USB3.0 bulk streams are being used 45 + * @is_last: Indicates if this is the last request of a stream_id before 46 + * switching to a different stream (required for DWC3 controllers). 45 47 * @no_interrupt: If true, hints that no completion irq is needed. 46 48 * Helpful sometimes with deep request queues that are handled 47 49 * directly by DMA controllers. ··· 106 104 unsigned num_mapped_sgs; 107 105 108 106 unsigned stream_id:16; 107 + unsigned is_last:1; 109 108 unsigned no_interrupt:1; 110 109 unsigned zero:1; 111 110 unsigned short_not_ok:1; ··· 376 373 * @connected: True if gadget is connected. 377 374 * @lpm_capable: If the gadget max_speed is FULL or HIGH, this flag 378 375 * indicates that it supports LPM as per the LPM ECN & errata. 376 + * @irq: the interrupt number for device controller. 379 377 * 380 378 * Gadgets have a mostly-portable "gadget driver" implementing device 381 379 * functions, handling all usb configurations and interfaces. Gadget ··· 431 427 unsigned deactivated:1; 432 428 unsigned connected:1; 433 429 unsigned lpm_capable:1; 430 + int irq; 434 431 }; 435 432 #define work_to_gadget(w) (container_of((w), struct usb_gadget, work)) 436 433 ··· 777 772 778 773 /* put descriptor for string with that id into buf (buflen >= 256) */ 779 774 int usb_gadget_get_string(const struct usb_gadget_strings *table, int id, u8 *buf); 775 + 776 + /* check if the given language identifier is valid */ 777 + bool usb_validate_langid(u16 langid); 780 778 781 779 /*-------------------------------------------------------------------------*/ 782 780