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

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'usb-5.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb

Pull USB / Thunderbolt updates from Greg KH:
"Here is the "big" set of USB and Thunderbolt driver changes for
5.18-rc1. For the most part it's been a quiet development cycle for
the USB core, but there are the usual "hot spots" of development
activity.

Included in here are:

- Thunderbolt driver updates:
- fixes for devices without displayport adapters
- lane bonding support and improvements
- other minor changes based on device testing

- dwc3 gadget driver changes.

It seems this driver will never be finished given that the IP core
is showing up in zillions of new devices and each implementation
decides to do something different with it...

- uvc gadget driver updates as more devices start to use and rely on
this hardware as well

- usb_maxpacket() api changes to remove an unneeded and unused
parameter.

- usb-serial driver device id updates and small cleanups

- typec cleanups and fixes based on device testing

- device tree updates for usb properties

- lots of other small fixes and driver updates.

All of these have been in linux-next for weeks with no reported
problems"

* tag 'usb-5.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (154 commits)
USB: new quirk for Dell Gen 2 devices
usb: dwc3: core: Add error log when core soft reset failed
usb: dwc3: gadget: Move null pinter check to proper place
usb: hub: Simplify error and success path in port_over_current_notify
usb: cdns3: allocate TX FIFO size according to composite EP number
usb: dwc3: Fix ep0 handling when getting reset while doing control transfer
usb: Probe EHCI, OHCI controllers asynchronously
usb: isp1760: Fix out-of-bounds array access
xhci: Don't defer primary roothub registration if there is only one roothub
USB: serial: option: add Quectel BG95 modem
USB: serial: pl2303: fix type detection for odd device
xhci: Allow host runtime PM as default for Intel Alder Lake N xHCI
xhci: Remove quirk for over 10 year old evaluation hardware
xhci: prevent U2 link power state if Intel tier policy prevented U1
xhci: use generic command timer for stop endpoint commands.
usb: host: xhci-plat: omit shared hcd if either root hub has no ports
usb: host: xhci-plat: prepare operation w/o shared hcd
usb: host: xhci-plat: create shared hcd after having added main hcd
xhci: prepare for operation w/o shared hcd
xhci: factor out parts of xhci_gen_setup()
...

+3681 -1487
+1
Documentation/ABI/testing/configfs-usb-gadget-uvc
··· 7 7 streaming_maxburst 0..15 (ss only) 8 8 streaming_maxpacket 1..1023 (fs), 1..3072 (hs/ss) 9 9 streaming_interval 1..16 10 + function_name string [32] 10 11 =================== ============================= 11 12 12 13 What: /config/usb-gadget/gadget/functions/uvc.name/control
+10
Documentation/ABI/testing/sysfs-bus-thunderbolt
··· 293 293 Description: This contains XDomain service specific settings as 294 294 bitmask. Format: %x 295 295 296 + What: /sys/bus/thunderbolt/devices/usb4_portX/connector 297 + Date: April 2022 298 + Contact: Heikki Krogerus <heikki.krogerus@linux.intel.com> 299 + Description: 300 + Symlink to the USB Type-C connector. This link is only 301 + created when USB Type-C Connector Class is enabled, 302 + and only if the system firmware is capable of 303 + describing the connection between a port and its 304 + connector. 305 + 296 306 What: /sys/bus/thunderbolt/devices/usb4_portX/link 297 307 Date: Sep 2021 298 308 KernelVersion: v5.14
+4 -3
Documentation/devicetree/bindings/usb/am33xx-usb.txt
··· 61 61 endpoint number (0 … 14 for endpoints 1 … 15 on instance 0 and 15 … 29 62 62 for endpoints 1 … 15 on instance 1). The second number is 0 for RX and 63 63 1 for TX transfers. 64 - - #dma-channels: should be set to 30 representing the 15 endpoints for 64 + - dma-channels: should be set to 30 representing the 15 endpoints for 65 65 each USB instance. 66 + - #dma-channels: deprecated 66 67 67 68 Example: 68 69 ~~~~~~~~ ··· 194 193 interrupts = <17>; 195 194 interrupt-names = "glue"; 196 195 #dma-cells = <2>; 197 - #dma-channels = <30>; 198 - #dma-requests = <256>; 196 + dma-channels = <30>; 197 + dma-requests = <256>; 199 198 }; 200 199 };
+3 -2
Documentation/devicetree/bindings/usb/da8xx-usb.txt
··· 36 36 - #dma-cells: should be set to 2. The first number represents the 37 37 channel number (0 … 3 for endpoints 1 … 4). 38 38 The second number is 0 for RX and 1 for TX transfers. 39 - - #dma-channels: should be set to 4 representing the 4 endpoints. 39 + - dma-channels: should be set to 4 representing the 4 endpoints. 40 + - #dma-channels: deprecated 40 41 41 42 Example: 42 43 usb_phy: usb-phy { ··· 75 74 reg-names = "controller", "scheduler", "queuemgr"; 76 75 interrupts = <58>; 77 76 #dma-cells = <2>; 78 - #dma-channels = <4>; 77 + dma-channels = <4>; 79 78 }; 80 79 81 80 };
+7
Documentation/devicetree/bindings/usb/dwc2.yaml
··· 17 17 oneOf: 18 18 - const: brcm,bcm2835-usb 19 19 - const: hisilicon,hi6220-usb 20 + - const: ingenic,jz4775-otg 21 + - const: ingenic,jz4780-otg 22 + - const: ingenic,x1000-otg 23 + - const: ingenic,x1600-otg 24 + - const: ingenic,x1700-otg 25 + - const: ingenic,x1830-otg 26 + - const: ingenic,x2000-otg 20 27 - items: 21 28 - const: rockchip,rk3066-usb 22 29 - const: snps,dwc2
+4
Documentation/devicetree/bindings/usb/dwc3-xilinx.yaml
··· 71 71 - usb2-phy 72 72 - usb3-phy 73 73 74 + reset-gpios: 75 + description: GPIO used for the reset ulpi-phy 76 + maxItems: 1 77 + 74 78 # Required child node: 75 79 76 80 patternProperties:
+72
Documentation/devicetree/bindings/usb/fcs,fsa4480.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/fcs,fsa4480.yaml#" 5 + $schema: "http://devicetree.org/meta-schemas/core.yaml#" 6 + 7 + title: ON Semiconductor Analog Audio Switch 8 + 9 + maintainers: 10 + - Bjorn Andersson <bjorn.andersson@linaro.org> 11 + 12 + properties: 13 + compatible: 14 + enum: 15 + - fcs,fsa4480 16 + 17 + reg: 18 + maxItems: 1 19 + 20 + interrupts: 21 + maxItems: 1 22 + 23 + vcc-supply: 24 + description: power supply (2.7V-5.5V) 25 + 26 + mode-switch: 27 + description: Flag the port as possible handle of altmode switching 28 + type: boolean 29 + 30 + orientation-switch: 31 + description: Flag the port as possible handler of orientation switching 32 + type: boolean 33 + 34 + port: 35 + $ref: /schemas/graph.yaml#/properties/port 36 + description: 37 + A port node to link the FSA4480 to a TypeC controller for the purpose of 38 + handling altmode muxing and orientation switching. 39 + 40 + required: 41 + - compatible 42 + - reg 43 + - port 44 + 45 + additionalProperties: false 46 + 47 + examples: 48 + - | 49 + #include <dt-bindings/interrupt-controller/irq.h> 50 + i2c13 { 51 + #address-cells = <1>; 52 + #size-cells = <0>; 53 + 54 + fsa4480@42 { 55 + compatible = "fcs,fsa4480"; 56 + reg = <0x42>; 57 + 58 + interrupts-extended = <&tlmm 2 IRQ_TYPE_LEVEL_LOW>; 59 + 60 + vcc-supply = <&vreg_bob>; 61 + 62 + mode-switch; 63 + orientation-switch; 64 + 65 + port { 66 + fsa4480_ept: endpoint { 67 + remote-endpoint = <&typec_controller>; 68 + }; 69 + }; 70 + }; 71 + }; 72 + ...
+1
Documentation/devicetree/bindings/usb/generic-ehci.yaml
··· 55 55 - brcm,bcm7420-ehci 56 56 - brcm,bcm7425-ehci 57 57 - brcm,bcm7435-ehci 58 + - hpe,gxp-ehci 58 59 - ibm,476gtr-ehci 59 60 - nxp,lpc1850-ehci 60 61 - qca,ar7100-ehci
+1
Documentation/devicetree/bindings/usb/generic-ohci.yaml
··· 42 42 - brcm,bcm7420-ohci 43 43 - brcm,bcm7425-ohci 44 44 - brcm,bcm7435-ohci 45 + - hpe,gxp-ohci 45 46 - ibm,476gtr-ohci 46 47 - ingenic,jz4740-ohci 47 48 - snps,hsdk-v1.0-ohci
+1
Documentation/devicetree/bindings/usb/mediatek,mtu3.yaml
··· 25 25 - mediatek,mt8173-mtu3 26 26 - mediatek,mt8183-mtu3 27 27 - mediatek,mt8192-mtu3 28 + - mediatek,mt8195-mtu3 28 29 - const: mediatek,mtu3 29 30 30 31 reg:
+205 -22
Documentation/devicetree/bindings/usb/qcom,dwc3.yaml
··· 16 16 - qcom,ipq4019-dwc3 17 17 - qcom,ipq6018-dwc3 18 18 - qcom,ipq8064-dwc3 19 + - qcom,ipq8074-dwc3 19 20 - qcom,msm8953-dwc3 21 + - qcom,msm8994-dwc3 20 22 - qcom,msm8996-dwc3 21 23 - qcom,msm8998-dwc3 24 + - qcom,qcs404-dwc3 22 25 - qcom,sc7180-dwc3 23 26 - qcom,sc7280-dwc3 24 27 - qcom,sdm660-dwc3 25 28 - qcom,sdm845-dwc3 26 29 - qcom,sdx55-dwc3 30 + - qcom,sdx65-dwc3 27 31 - qcom,sm4250-dwc3 28 32 - qcom,sm6115-dwc3 33 + - qcom,sm6125-dwc3 29 34 - qcom,sm6350-dwc3 30 35 - qcom,sm8150-dwc3 31 36 - qcom,sm8250-dwc3 ··· 55 50 maxItems: 1 56 51 57 52 clocks: 58 - description: 59 - A list of phandle and clock-specifier pairs for the clocks 60 - listed in clock-names. 61 - items: 62 - - description: System Config NOC clock. 63 - - description: Master/Core clock, has to be >= 125 MHz 64 - for SS operation and >= 60MHz for HS operation. 65 - - description: System bus AXI clock. 66 - - description: Mock utmi clock needed for ITP/SOF generation 67 - in host mode. Its frequency should be 19.2MHz. 68 - - description: Sleep clock, used for wakeup when 69 - USB3 core goes into low power mode (U3). 53 + description: | 54 + Several clocks are used, depending on the variant. Typical ones are:: 55 + - cfg_noc:: System Config NOC clock. 56 + - core:: Master/Core clock, has to be >= 125 MHz for SS operation and >= 57 + 60MHz for HS operation. 58 + - iface:: System bus AXI clock. 59 + - sleep:: Sleep clock, used for wakeup when USB3 core goes into low 60 + power mode (U3). 61 + - mock_utmi:: Mock utmi clock needed for ITP/SOF generation in host 62 + mode. Its frequency should be 19.2MHz. 63 + minItems: 1 64 + maxItems: 6 70 65 71 66 clock-names: 72 - items: 73 - - const: cfg_noc 74 - - const: core 75 - - const: iface 76 - - const: mock_utmi 77 - - const: sleep 67 + minItems: 1 68 + maxItems: 6 78 69 79 70 assigned-clocks: 80 71 items: ··· 133 132 - interrupts 134 133 - interrupt-names 135 134 135 + allOf: 136 + - if: 137 + properties: 138 + compatible: 139 + contains: 140 + enum: 141 + - qcom,ipq4019-dwc3 142 + then: 143 + properties: 144 + clocks: 145 + maxItems: 3 146 + clock-names: 147 + items: 148 + - const: core 149 + - const: sleep 150 + - const: mock_utmi 151 + 152 + - if: 153 + properties: 154 + compatible: 155 + contains: 156 + enum: 157 + - qcom,ipq8064-dwc3 158 + then: 159 + properties: 160 + clocks: 161 + items: 162 + - description: Master/Core clock, has to be >= 125 MHz 163 + for SS operation and >= 60MHz for HS operation. 164 + clock-names: 165 + items: 166 + - const: core 167 + 168 + - if: 169 + properties: 170 + compatible: 171 + contains: 172 + enum: 173 + - qcom,msm8953-dwc3 174 + - qcom,msm8996-dwc3 175 + - qcom,msm8998-dwc3 176 + - qcom,sc7180-dwc3 177 + - qcom,sc7280-dwc3 178 + - qcom,sdm845-dwc3 179 + - qcom,sdx55-dwc3 180 + - qcom,sm6350-dwc3 181 + then: 182 + properties: 183 + clocks: 184 + maxItems: 5 185 + clock-names: 186 + items: 187 + - const: cfg_noc 188 + - const: core 189 + - const: iface 190 + - const: sleep 191 + - const: mock_utmi 192 + 193 + - if: 194 + properties: 195 + compatible: 196 + contains: 197 + enum: 198 + - qcom,ipq6018-dwc3 199 + then: 200 + properties: 201 + clocks: 202 + minItems: 3 203 + maxItems: 4 204 + clock-names: 205 + oneOf: 206 + - items: 207 + - const: core 208 + - const: sleep 209 + - const: mock_utmi 210 + - items: 211 + - const: cfg_noc 212 + - const: core 213 + - const: sleep 214 + - const: mock_utmi 215 + 216 + - if: 217 + properties: 218 + compatible: 219 + contains: 220 + enum: 221 + - qcom,ipq8074-dwc3 222 + then: 223 + properties: 224 + clocks: 225 + maxItems: 4 226 + clock-names: 227 + items: 228 + - const: cfg_noc 229 + - const: core 230 + - const: sleep 231 + - const: mock_utmi 232 + 233 + - if: 234 + properties: 235 + compatible: 236 + contains: 237 + enum: 238 + - qcom,msm8994-dwc3 239 + - qcom,qcs404-dwc3 240 + then: 241 + properties: 242 + clocks: 243 + maxItems: 4 244 + clock-names: 245 + items: 246 + - const: core 247 + - const: iface 248 + - const: sleep 249 + - const: mock_utmi 250 + 251 + - if: 252 + properties: 253 + compatible: 254 + contains: 255 + enum: 256 + - qcom,sdm660-dwc3 257 + then: 258 + properties: 259 + clocks: 260 + minItems: 6 261 + clock-names: 262 + items: 263 + - const: cfg_noc 264 + - const: core 265 + - const: iface 266 + - const: sleep 267 + - const: mock_utmi 268 + - const: bus 269 + 270 + - if: 271 + properties: 272 + compatible: 273 + contains: 274 + enum: 275 + - qcom,sm6125-dwc3 276 + - qcom,sm8150-dwc3 277 + - qcom,sm8250-dwc3 278 + - qcom,sm8450-dwc3 279 + then: 280 + properties: 281 + clocks: 282 + minItems: 6 283 + clock-names: 284 + items: 285 + - const: cfg_noc 286 + - const: core 287 + - const: iface 288 + - const: sleep 289 + - const: mock_utmi 290 + - const: xo 291 + 292 + - if: 293 + properties: 294 + compatible: 295 + contains: 296 + enum: 297 + - qcom,sm8350-dwc3 298 + then: 299 + properties: 300 + clocks: 301 + minItems: 5 302 + maxItems: 6 303 + clock-names: 304 + minItems: 5 305 + items: 306 + - const: cfg_noc 307 + - const: core 308 + - const: iface 309 + - const: sleep 310 + - const: mock_utmi 311 + - const: xo 312 + 313 + 136 314 additionalProperties: false 137 315 138 316 examples: ··· 333 153 clocks = <&gcc GCC_CFG_NOC_USB3_PRIM_AXI_CLK>, 334 154 <&gcc GCC_USB30_PRIM_MASTER_CLK>, 335 155 <&gcc GCC_AGGRE_USB3_PRIM_AXI_CLK>, 336 - <&gcc GCC_USB30_PRIM_MOCK_UTMI_CLK>, 337 - <&gcc GCC_USB30_PRIM_SLEEP_CLK>; 338 - clock-names = "cfg_noc", "core", "iface", "mock_utmi", 339 - "sleep"; 156 + <&gcc GCC_USB30_PRIM_SLEEP_CLK>, 157 + <&gcc GCC_USB30_PRIM_MOCK_UTMI_CLK>; 158 + clock-names = "cfg_noc", 159 + "core", 160 + "iface", 161 + "sleep", 162 + "mock_utmi"; 340 163 341 164 assigned-clocks = <&gcc GCC_USB30_PRIM_MOCK_UTMI_CLK>, 342 165 <&gcc GCC_USB30_PRIM_MASTER_CLK>;
+4
Documentation/devicetree/bindings/usb/renesas,usbhs.yaml
··· 19 19 - items: 20 20 - enum: 21 21 - renesas,usbhs-r7s9210 # RZ/A2 22 + - renesas,usbhs-r9a07g043 # RZ/G2UL 22 23 - renesas,usbhs-r9a07g044 # RZ/G2{L,LC} 23 24 - renesas,usbhs-r9a07g054 # RZ/V2L 24 25 - const: renesas,rza2-usbhs ··· 119 118 compatible: 120 119 contains: 121 120 enum: 121 + - renesas,usbhs-r9a07g043 122 122 - renesas,usbhs-r9a07g044 123 123 - renesas,usbhs-r9a07g054 124 124 then: ··· 130 128 - description: U2P_INT_DMA[0] 131 129 - description: U2P_INT_DMA[1] 132 130 - description: U2P_INT_DMAERR 131 + required: 132 + - resets 133 133 else: 134 134 properties: 135 135 interrupts:
+2 -13
Documentation/devicetree/bindings/usb/samsung,exynos-usb2.yaml
··· 15 15 - samsung,exynos4210-ehci 16 16 - samsung,exynos4210-ohci 17 17 18 - '#address-cells': 19 - const: 1 20 - 21 18 clocks: 22 19 maxItems: 1 23 20 ··· 43 46 Only for controller in EHCI mode, if present, specifies the GPIO that 44 47 needs to be pulled up for the bus to be powered. 45 48 46 - '#size-cells': 47 - const: 0 48 - 49 - patternProperties: 50 - "^.*@[0-9a-f]{1,2}$": 51 - description: The hard wired USB devices 52 - type: object 53 - $ref: /usb/usb-device.yaml 54 - 55 49 required: 56 50 - compatible 57 51 - clocks ··· 53 65 - reg 54 66 55 67 allOf: 68 + - $ref: usb-hcd.yaml# 56 69 - if: 57 70 properties: 58 71 compatible: ··· 63 74 properties: 64 75 samsung,vbus-gpio: false 65 76 66 - additionalProperties: false 77 + unevaluatedProperties: false 67 78 68 79 examples: 69 80 - |
+103
Documentation/devicetree/bindings/usb/ti,am62-usb.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,am62-usb.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: TI's AM62 wrapper module for the Synopsys USBSS-DRD controller 8 + 9 + maintainers: 10 + - Aswath Govindraju <a-govindraju@ti.com> 11 + 12 + properties: 13 + compatible: 14 + const: ti,am62-usb 15 + 16 + reg: 17 + maxItems: 1 18 + 19 + ranges: true 20 + 21 + power-domains: 22 + description: 23 + PM domain provider node and an args specifier containing 24 + the USB ISO device id value. See, 25 + Documentation/devicetree/bindings/soc/ti/sci-pm-domain.yaml 26 + maxItems: 1 27 + 28 + clocks: 29 + description: Clock phandle to usb2_refclk 30 + maxItems: 1 31 + 32 + clock-names: 33 + items: 34 + - const: ref 35 + 36 + ti,vbus-divider: 37 + description: 38 + Should be present if USB VBUS line is connected to the 39 + VBUS pin of the SoC via a 1/3 voltage divider. 40 + type: boolean 41 + 42 + ti,syscon-phy-pll-refclk: 43 + $ref: /schemas/types.yaml#/definitions/phandle-array 44 + items: 45 + - items: 46 + - description: Phandle to the SYSCON entry 47 + - description: USB phy control register offset within SYSCON 48 + description: 49 + Specifier for conveying frequency of ref clock input, for the 50 + operation of USB2PHY. 51 + 52 + '#address-cells': 53 + const: 2 54 + 55 + '#size-cells': 56 + const: 2 57 + 58 + patternProperties: 59 + "^usb@[0-9a-f]+$": 60 + $ref: snps,dwc3.yaml# 61 + description: Required child node 62 + 63 + required: 64 + - compatible 65 + - reg 66 + - power-domains 67 + - clocks 68 + - clock-names 69 + - ti,syscon-phy-pll-refclk 70 + 71 + additionalProperties: false 72 + 73 + examples: 74 + - | 75 + #include <dt-bindings/soc/ti,sci_pm_domain.h> 76 + #include <dt-bindings/interrupt-controller/arm-gic.h> 77 + #include <dt-bindings/gpio/gpio.h> 78 + 79 + bus { 80 + #address-cells = <2>; 81 + #size-cells = <2>; 82 + 83 + usbss1: usb@f910000 { 84 + compatible = "ti,am62-usb"; 85 + reg = <0x00 0x0f910000 0x00 0x800>; 86 + clocks = <&k3_clks 162 3>; 87 + clock-names = "ref"; 88 + ti,syscon-phy-pll-refclk = <&wkup_conf 0x4018>; 89 + power-domains = <&k3_pds 179 TI_SCI_PD_EXCLUSIVE>; 90 + #address-cells = <2>; 91 + #size-cells = <2>; 92 + 93 + usb@31100000 { 94 + compatible = "snps,dwc3"; 95 + reg =<0x00 0x31100000 0x00 0x50000>; 96 + interrupts = <GIC_SPI 226 IRQ_TYPE_LEVEL_HIGH>, /* irq.0 */ 97 + <GIC_SPI 226 IRQ_TYPE_LEVEL_HIGH>; /* irq.0 */ 98 + interrupt-names = "host", "peripheral"; 99 + maximum-speed = "high-speed"; 100 + dr_mode = "otg"; 101 + }; 102 + }; 103 + };
+1
Documentation/usb/gadget-testing.rst
··· 787 787 streaming_maxpacket maximum packet size this endpoint is capable of 788 788 sending or receiving when this configuration is 789 789 selected 790 + function_name name of the interface 790 791 =================== ================================================ 791 792 792 793 There are also "control" and "streaming" subdirectories, each of which contain
+1 -1
arch/arm/boot/dts/qcom-ipq4019.dtsi
··· 646 646 clocks = <&gcc GCC_USB3_MASTER_CLK>, 647 647 <&gcc GCC_USB3_SLEEP_CLK>, 648 648 <&gcc GCC_USB3_MOCK_UTMI_CLK>; 649 - clock-names = "master", "sleep", "mock_utmi"; 649 + clock-names = "core", "sleep", "mock_utmi"; 650 650 ranges; 651 651 status = "disabled"; 652 652
+7 -4
arch/arm/boot/dts/qcom-sdx55.dtsi
··· 483 483 clocks = <&gcc GCC_USB30_SLV_AHB_CLK>, 484 484 <&gcc GCC_USB30_MASTER_CLK>, 485 485 <&gcc GCC_USB30_MSTR_AXI_CLK>, 486 - <&gcc GCC_USB30_MOCK_UTMI_CLK>, 487 - <&gcc GCC_USB30_SLEEP_CLK>; 488 - clock-names = "cfg_noc", "core", "iface", "mock_utmi", 489 - "sleep"; 486 + <&gcc GCC_USB30_SLEEP_CLK>, 487 + <&gcc GCC_USB30_MOCK_UTMI_CLK>; 488 + clock-names = "cfg_noc", 489 + "core", 490 + "iface", 491 + "sleep", 492 + "mock_utmi"; 490 493 491 494 assigned-clocks = <&gcc GCC_USB30_MOCK_UTMI_CLK>, 492 495 <&gcc GCC_USB30_MASTER_CLK>;
+9 -9
arch/arm64/boot/dts/qcom/apq8096-db820c.dts
··· 1052 1052 &usb2 { 1053 1053 status = "okay"; 1054 1054 extcon = <&usb2_id>; 1055 + }; 1055 1056 1056 - dwc3@7600000 { 1057 - extcon = <&usb2_id>; 1058 - dr_mode = "otg"; 1059 - maximum-speed = "high-speed"; 1060 - }; 1057 + &usb2_dwc3 { 1058 + extcon = <&usb2_id>; 1059 + dr_mode = "otg"; 1060 + maximum-speed = "high-speed"; 1061 1061 }; 1062 1062 1063 1063 &usb3 { 1064 1064 status = "okay"; 1065 1065 extcon = <&usb3_id>; 1066 + }; 1066 1067 1067 - dwc3@6a00000 { 1068 - extcon = <&usb3_id>; 1069 - dr_mode = "otg"; 1070 - }; 1068 + &usb3_dwc3 { 1069 + extcon = <&usb3_id>; 1070 + dr_mode = "otg"; 1071 1071 }; 1072 1072 1073 1073 &usb3phy {
+6 -6
arch/arm64/boot/dts/qcom/ipq6018.dtsi
··· 653 653 status = "disabled"; 654 654 }; 655 655 656 - usb2: usb2@7000000 { 656 + usb2: usb@70f8800 { 657 657 compatible = "qcom,ipq6018-dwc3", "qcom,dwc3"; 658 658 reg = <0x0 0x070F8800 0x0 0x400>; 659 659 #address-cells = <2>; ··· 662 662 clocks = <&gcc GCC_USB1_MASTER_CLK>, 663 663 <&gcc GCC_USB1_SLEEP_CLK>, 664 664 <&gcc GCC_USB1_MOCK_UTMI_CLK>; 665 - clock-names = "master", 665 + clock-names = "core", 666 666 "sleep", 667 667 "mock_utmi"; 668 668 ··· 730 730 status = "disabled"; 731 731 }; 732 732 733 - usb3: usb3@8A00000 { 733 + usb3: usb@8af8800 { 734 734 compatible = "qcom,ipq6018-dwc3", "qcom,dwc3"; 735 735 reg = <0x0 0x8AF8800 0x0 0x400>; 736 736 #address-cells = <2>; ··· 741 741 <&gcc GCC_USB0_MASTER_CLK>, 742 742 <&gcc GCC_USB0_SLEEP_CLK>, 743 743 <&gcc GCC_USB0_MOCK_UTMI_CLK>; 744 - clock-names = "sys_noc_axi", 745 - "master", 744 + clock-names = "cfg_noc", 745 + "core", 746 746 "sleep", 747 747 "mock_utmi"; 748 748 ··· 756 756 resets = <&gcc GCC_USB0_BCR>; 757 757 status = "disabled"; 758 758 759 - dwc_0: usb@8A00000 { 759 + dwc_0: usb@8a00000 { 760 760 compatible = "snps,dwc3"; 761 761 reg = <0x0 0x8A00000 0x0 0xcd00>; 762 762 interrupts = <GIC_SPI 140 IRQ_TYPE_LEVEL_HIGH>;
+8 -8
arch/arm64/boot/dts/qcom/ipq8074.dtsi
··· 553 553 }; 554 554 555 555 usb_0: usb@8af8800 { 556 - compatible = "qcom,dwc3"; 556 + compatible = "qcom,ipq8074-dwc3", "qcom,dwc3"; 557 557 reg = <0x08af8800 0x400>; 558 558 #address-cells = <1>; 559 559 #size-cells = <1>; ··· 563 563 <&gcc GCC_USB0_MASTER_CLK>, 564 564 <&gcc GCC_USB0_SLEEP_CLK>, 565 565 <&gcc GCC_USB0_MOCK_UTMI_CLK>; 566 - clock-names = "sys_noc_axi", 567 - "master", 566 + clock-names = "cfg_noc", 567 + "core", 568 568 "sleep", 569 569 "mock_utmi"; 570 570 ··· 578 578 resets = <&gcc GCC_USB0_BCR>; 579 579 status = "disabled"; 580 580 581 - dwc_0: dwc3@8a00000 { 581 + dwc_0: usb@8a00000 { 582 582 compatible = "snps,dwc3"; 583 583 reg = <0x8a00000 0xcd00>; 584 584 interrupts = <GIC_SPI 140 IRQ_TYPE_LEVEL_HIGH>; ··· 593 593 }; 594 594 595 595 usb_1: usb@8cf8800 { 596 - compatible = "qcom,dwc3"; 596 + compatible = "qcom,ipq8074-dwc3", "qcom,dwc3"; 597 597 reg = <0x08cf8800 0x400>; 598 598 #address-cells = <1>; 599 599 #size-cells = <1>; ··· 603 603 <&gcc GCC_USB1_MASTER_CLK>, 604 604 <&gcc GCC_USB1_SLEEP_CLK>, 605 605 <&gcc GCC_USB1_MOCK_UTMI_CLK>; 606 - clock-names = "sys_noc_axi", 607 - "master", 606 + clock-names = "cfg_noc", 607 + "core", 608 608 "sleep", 609 609 "mock_utmi"; 610 610 ··· 618 618 resets = <&gcc GCC_USB1_BCR>; 619 619 status = "disabled"; 620 620 621 - dwc_1: dwc3@8c00000 { 621 + dwc_1: usb@8c00000 { 622 622 compatible = "snps,dwc3"; 623 623 reg = <0x8c00000 0xcd00>; 624 624 interrupts = <GIC_SPI 99 IRQ_TYPE_LEVEL_HIGH>;
+7 -4
arch/arm64/boot/dts/qcom/msm8953.dtsi
··· 759 759 clocks = <&gcc GCC_USB_PHY_CFG_AHB_CLK>, 760 760 <&gcc GCC_USB30_MASTER_CLK>, 761 761 <&gcc GCC_PCNOC_USB3_AXI_CLK>, 762 - <&gcc GCC_USB30_MOCK_UTMI_CLK>, 763 - <&gcc GCC_USB30_SLEEP_CLK>; 764 - clock-names = "cfg_noc", "core", "iface", 765 - "mock_utmi", "sleep"; 762 + <&gcc GCC_USB30_SLEEP_CLK>, 763 + <&gcc GCC_USB30_MOCK_UTMI_CLK>; 764 + clock-names = "cfg_noc", 765 + "core", 766 + "iface", 767 + "sleep", 768 + "mock_utmi"; 766 769 767 770 assigned-clocks = <&gcc GCC_USB30_MOCK_UTMI_CLK>, 768 771 <&gcc GCC_USB30_MASTER_CLK>;
+5 -2
arch/arm64/boot/dts/qcom/msm8994.dtsi
··· 428 428 }; 429 429 430 430 usb3: usb@f92f8800 { 431 - compatible = "qcom,msm8996-dwc3", "qcom,dwc3"; 431 + compatible = "qcom,msm8994-dwc3", "qcom,dwc3"; 432 432 reg = <0xf92f8800 0x400>; 433 433 #address-cells = <1>; 434 434 #size-cells = <1>; ··· 438 438 <&gcc GCC_SYS_NOC_USB3_AXI_CLK>, 439 439 <&gcc GCC_USB30_SLEEP_CLK>, 440 440 <&gcc GCC_USB30_MOCK_UTMI_CLK>; 441 - clock-names = "core", "iface", "sleep", "mock_utmi", "ref", "xo"; 441 + clock-names = "core", 442 + "iface", 443 + "sleep", 444 + "mock_utmi"; 442 445 443 446 assigned-clocks = <&gcc GCC_USB30_MOCK_UTMI_CLK>, 444 447 <&gcc GCC_USB30_MASTER_CLK>;
+10 -10
arch/arm64/boot/dts/qcom/msm8996-xiaomi-common.dtsi
··· 308 308 extcon = <&typec>; 309 309 310 310 qcom,select-utmi-as-pipe-clk; 311 + }; 311 312 312 - dwc3@6a00000 { 313 - extcon = <&typec>; 313 + &usb3_dwc3 { 314 + extcon = <&typec>; 314 315 315 - /* usb3-phy is not used on this device */ 316 - phys = <&hsusb_phy1>; 317 - phy-names = "usb2-phy"; 316 + /* usb3-phy is not used on this device */ 317 + phys = <&hsusb_phy1>; 318 + phy-names = "usb2-phy"; 318 319 319 - maximum-speed = "high-speed"; 320 - snps,is-utmi-l1-suspend; 321 - snps,usb2-gadget-lpm-disable; 322 - snps,hird-threshold = /bits/ 8 <0>; 323 - }; 320 + maximum-speed = "high-speed"; 321 + snps,is-utmi-l1-suspend; 322 + snps,usb2-gadget-lpm-disable; 323 + snps,hird-threshold = /bits/ 8 <0>; 324 324 }; 325 325 326 326 &hsusb_phy1 {
+16 -7
arch/arm64/boot/dts/qcom/msm8996.dtsi
··· 2718 2718 interrupt-names = "hs_phy_irq", "ss_phy_irq"; 2719 2719 2720 2720 clocks = <&gcc GCC_SYS_NOC_USB3_AXI_CLK>, 2721 - <&gcc GCC_USB30_MASTER_CLK>, 2722 - <&gcc GCC_AGGRE2_USB3_AXI_CLK>, 2723 - <&gcc GCC_USB30_MOCK_UTMI_CLK>, 2724 - <&gcc GCC_USB30_SLEEP_CLK>, 2725 - <&gcc GCC_USB_PHY_CFG_AHB2PHY_CLK>; 2721 + <&gcc GCC_USB30_MASTER_CLK>, 2722 + <&gcc GCC_AGGRE2_USB3_AXI_CLK>, 2723 + <&gcc GCC_USB30_SLEEP_CLK>, 2724 + <&gcc GCC_USB30_MOCK_UTMI_CLK>; 2725 + clock-names = "cfg_noc", 2726 + "core", 2727 + "iface", 2728 + "sleep", 2729 + "mock_utmi"; 2726 2730 2727 2731 assigned-clocks = <&gcc GCC_USB30_MOCK_UTMI_CLK>, 2728 2732 <&gcc GCC_USB30_MASTER_CLK>; ··· 2735 2731 power-domains = <&gcc USB30_GDSC>; 2736 2732 status = "disabled"; 2737 2733 2738 - usb3_dwc3: dwc3@6a00000 { 2734 + usb3_dwc3: usb@6a00000 { 2739 2735 compatible = "snps,dwc3"; 2740 2736 reg = <0x06a00000 0xcc00>; 2741 2737 interrupts = <0 131 IRQ_TYPE_LEVEL_HIGH>; ··· 3054 3050 <&gcc GCC_USB20_MOCK_UTMI_CLK>, 3055 3051 <&gcc GCC_USB20_SLEEP_CLK>, 3056 3052 <&gcc GCC_USB_PHY_CFG_AHB2PHY_CLK>; 3053 + clock-names = "cfg_noc", 3054 + "core", 3055 + "iface", 3056 + "sleep", 3057 + "mock_utmi"; 3057 3058 3058 3059 assigned-clocks = <&gcc GCC_USB20_MOCK_UTMI_CLK>, 3059 3060 <&gcc GCC_USB20_MASTER_CLK>; ··· 3068 3059 qcom,select-utmi-as-pipe-clk; 3069 3060 status = "disabled"; 3070 3061 3071 - dwc3@7600000 { 3062 + usb2_dwc3: usb@7600000 { 3072 3063 compatible = "snps,dwc3"; 3073 3064 reg = <0x07600000 0xcc00>; 3074 3065 interrupts = <0 138 IRQ_TYPE_LEVEL_HIGH>;
+8 -5
arch/arm64/boot/dts/qcom/msm8998.dtsi
··· 2023 2023 clocks = <&gcc GCC_CFG_NOC_USB3_AXI_CLK>, 2024 2024 <&gcc GCC_USB30_MASTER_CLK>, 2025 2025 <&gcc GCC_AGGRE1_USB3_AXI_CLK>, 2026 - <&gcc GCC_USB30_MOCK_UTMI_CLK>, 2027 - <&gcc GCC_USB30_SLEEP_CLK>; 2028 - clock-names = "cfg_noc", "core", "iface", "mock_utmi", 2029 - "sleep"; 2026 + <&gcc GCC_USB30_SLEEP_CLK>, 2027 + <&gcc GCC_USB30_MOCK_UTMI_CLK>; 2028 + clock-names = "cfg_noc", 2029 + "core", 2030 + "iface", 2031 + "sleep", 2032 + "mock_utmi"; 2030 2033 2031 2034 assigned-clocks = <&gcc GCC_USB30_MOCK_UTMI_CLK>, 2032 2035 <&gcc GCC_USB30_MASTER_CLK>; ··· 2043 2040 2044 2041 resets = <&gcc GCC_USB_30_BCR>; 2045 2042 2046 - usb3_dwc3: dwc3@a800000 { 2043 + usb3_dwc3: usb@a800000 { 2047 2044 compatible = "snps,dwc3"; 2048 2045 reg = <0x0a800000 0xcd00>; 2049 2046 interrupts = <GIC_SPI 131 IRQ_TYPE_LEVEL_HIGH>;
+4 -3
arch/arm64/boot/dts/qcom/qcs404-evb.dtsi
··· 337 337 &usb3 { 338 338 status = "okay"; 339 339 340 - dwc3@7580000 { 341 - dr_mode = "host"; 342 - }; 340 + }; 341 + 342 + &usb3_dwc3 { 343 + dr_mode = "host"; 343 344 }; 344 345 345 346 &usb2_phy_prim {
+4 -4
arch/arm64/boot/dts/qcom/qcs404.dtsi
··· 529 529 }; 530 530 531 531 usb3: usb@7678800 { 532 - compatible = "qcom,dwc3"; 532 + compatible = "qcom,qcs404-dwc3", "qcom,dwc3"; 533 533 reg = <0x07678800 0x400>; 534 534 #address-cells = <1>; 535 535 #size-cells = <1>; ··· 544 544 assigned-clock-rates = <19200000>, <200000000>; 545 545 status = "disabled"; 546 546 547 - dwc3@7580000 { 547 + usb3_dwc3: usb@7580000 { 548 548 compatible = "snps,dwc3"; 549 549 reg = <0x07580000 0xcd00>; 550 550 interrupts = <GIC_SPI 26 IRQ_TYPE_LEVEL_HIGH>; ··· 558 558 }; 559 559 560 560 usb2: usb@79b8800 { 561 - compatible = "qcom,dwc3"; 561 + compatible = "qcom,qcs404-dwc3", "qcom,dwc3"; 562 562 reg = <0x079b8800 0x400>; 563 563 #address-cells = <1>; 564 564 #size-cells = <1>; ··· 573 573 assigned-clock-rates = <19200000>, <133333333>; 574 574 status = "disabled"; 575 575 576 - dwc3@78c0000 { 576 + usb@78c0000 { 577 577 compatible = "snps,dwc3"; 578 578 reg = <0x078c0000 0xcc00>; 579 579 interrupts = <GIC_SPI 44 IRQ_TYPE_LEVEL_HIGH>;
+8 -5
arch/arm64/boot/dts/qcom/sc7180.dtsi
··· 2755 2755 clocks = <&gcc GCC_CFG_NOC_USB3_PRIM_AXI_CLK>, 2756 2756 <&gcc GCC_USB30_PRIM_MASTER_CLK>, 2757 2757 <&gcc GCC_AGGRE_USB3_PRIM_AXI_CLK>, 2758 - <&gcc GCC_USB30_PRIM_MOCK_UTMI_CLK>, 2759 - <&gcc GCC_USB30_PRIM_SLEEP_CLK>; 2760 - clock-names = "cfg_noc", "core", "iface", "mock_utmi", 2761 - "sleep"; 2758 + <&gcc GCC_USB30_PRIM_SLEEP_CLK>, 2759 + <&gcc GCC_USB30_PRIM_MOCK_UTMI_CLK>; 2760 + clock-names = "cfg_noc", 2761 + "core", 2762 + "iface", 2763 + "sleep", 2764 + "mock_utmi"; 2762 2765 2763 2766 assigned-clocks = <&gcc GCC_USB30_PRIM_MOCK_UTMI_CLK>, 2764 2767 <&gcc GCC_USB30_PRIM_MASTER_CLK>; ··· 2782 2779 <&gem_noc MASTER_APPSS_PROC 0 &config_noc SLAVE_USB3 0>; 2783 2780 interconnect-names = "usb-ddr", "apps-usb"; 2784 2781 2785 - usb_1_dwc3: dwc3@a600000 { 2782 + usb_1_dwc3: usb@a600000 { 2786 2783 compatible = "snps,dwc3"; 2787 2784 reg = <0 0x0a600000 0 0xe000>; 2788 2785 interrupts = <GIC_SPI 133 IRQ_TYPE_LEVEL_HIGH>;
+56 -12
arch/arm64/boot/dts/qcom/sc7280.dtsi
··· 3069 3069 clocks = <&gcc GCC_CFG_NOC_USB3_SEC_AXI_CLK>, 3070 3070 <&gcc GCC_USB30_SEC_MASTER_CLK>, 3071 3071 <&gcc GCC_AGGRE_USB3_SEC_AXI_CLK>, 3072 - <&gcc GCC_USB30_SEC_MOCK_UTMI_CLK>, 3073 - <&gcc GCC_USB30_SEC_SLEEP_CLK>; 3074 - clock-names = "cfg_noc", "core", "iface","mock_utmi", 3075 - "sleep"; 3072 + <&gcc GCC_USB30_SEC_SLEEP_CLK>, 3073 + <&gcc GCC_USB30_SEC_MOCK_UTMI_CLK>; 3074 + clock-names = "cfg_noc", 3075 + "core", 3076 + "iface", 3077 + "sleep", 3078 + "mock_utmi"; 3076 3079 3077 3080 assigned-clocks = <&gcc GCC_USB30_SEC_MOCK_UTMI_CLK>, 3078 3081 <&gcc GCC_USB30_SEC_MASTER_CLK>; ··· 3105 3102 phys = <&usb_2_hsphy>; 3106 3103 phy-names = "usb2-phy"; 3107 3104 maximum-speed = "high-speed"; 3105 + usb-role-switch; 3106 + port { 3107 + usb2_role_switch: endpoint { 3108 + remote-endpoint = <&eud_ep>; 3109 + }; 3110 + }; 3108 3111 }; 3109 3112 }; 3110 3113 ··· 3203 3194 interrupts = <GIC_SPI 582 IRQ_TYPE_LEVEL_HIGH>; 3204 3195 }; 3205 3196 3197 + eud: eud@88e0000 { 3198 + compatible = "qcom,sc7280-eud","qcom,eud"; 3199 + reg = <0 0x88e0000 0 0x2000>, 3200 + <0 0x88e2000 0 0x1000>; 3201 + interrupts-extended = <&pdc 11 IRQ_TYPE_LEVEL_HIGH>; 3202 + ports { 3203 + port@0 { 3204 + eud_ep: endpoint { 3205 + remote-endpoint = <&usb2_role_switch>; 3206 + }; 3207 + }; 3208 + port@1 { 3209 + eud_con: endpoint { 3210 + remote-endpoint = <&con_eud>; 3211 + }; 3212 + }; 3213 + }; 3214 + }; 3215 + 3216 + eud_typec: connector { 3217 + compatible = "usb-c-connector"; 3218 + ports { 3219 + port@0 { 3220 + con_eud: endpoint { 3221 + remote-endpoint = <&eud_con>; 3222 + }; 3223 + }; 3224 + }; 3225 + }; 3226 + 3206 3227 nsp_noc: interconnect@a0c0000 { 3207 3228 reg = <0 0x0a0c0000 0 0x10000>; 3208 3229 compatible = "qcom,sc7280-nsp-noc"; ··· 3252 3213 clocks = <&gcc GCC_CFG_NOC_USB3_PRIM_AXI_CLK>, 3253 3214 <&gcc GCC_USB30_PRIM_MASTER_CLK>, 3254 3215 <&gcc GCC_AGGRE_USB3_PRIM_AXI_CLK>, 3255 - <&gcc GCC_USB30_PRIM_MOCK_UTMI_CLK>, 3256 - <&gcc GCC_USB30_PRIM_SLEEP_CLK>; 3257 - clock-names = "cfg_noc", "core", "iface", "mock_utmi", 3258 - "sleep"; 3216 + <&gcc GCC_USB30_PRIM_SLEEP_CLK>, 3217 + <&gcc GCC_USB30_PRIM_MOCK_UTMI_CLK>; 3218 + clock-names = "cfg_noc", 3219 + "core", 3220 + "iface", 3221 + "sleep", 3222 + "mock_utmi"; 3259 3223 3260 3224 assigned-clocks = <&gcc GCC_USB30_PRIM_MOCK_UTMI_CLK>, 3261 3225 <&gcc GCC_USB30_PRIM_MASTER_CLK>; 3262 3226 assigned-clock-rates = <19200000>, <200000000>; 3263 3227 3264 3228 interrupts-extended = <&intc GIC_SPI 131 IRQ_TYPE_LEVEL_HIGH>, 3265 - <&pdc 14 IRQ_TYPE_EDGE_BOTH>, 3229 + <&pdc 17 IRQ_TYPE_EDGE_BOTH>, 3266 3230 <&pdc 15 IRQ_TYPE_EDGE_BOTH>, 3267 - <&pdc 17 IRQ_TYPE_LEVEL_HIGH>; 3268 - interrupt-names = "hs_phy_irq", "dp_hs_phy_irq", 3269 - "dm_hs_phy_irq", "ss_phy_irq"; 3231 + <&pdc 14 IRQ_TYPE_LEVEL_HIGH>; 3232 + interrupt-names = "hs_phy_irq", 3233 + "ss_phy_irq", 3234 + "dm_hs_phy_irq", 3235 + "dp_hs_phy_irq"; 3270 3236 3271 3237 power-domains = <&gcc GCC_USB30_PRIM_GDSC>; 3272 3238
+8 -4
arch/arm64/boot/dts/qcom/sdm630.dtsi
··· 1215 1215 clocks = <&gcc GCC_CFG_NOC_USB3_AXI_CLK>, 1216 1216 <&gcc GCC_USB30_MASTER_CLK>, 1217 1217 <&gcc GCC_AGGRE2_USB3_AXI_CLK>, 1218 - <&rpmcc RPM_SMD_AGGR2_NOC_CLK>, 1218 + <&gcc GCC_USB30_SLEEP_CLK>, 1219 1219 <&gcc GCC_USB30_MOCK_UTMI_CLK>, 1220 - <&gcc GCC_USB30_SLEEP_CLK>; 1221 - clock-names = "cfg_noc", "core", "iface", "bus", 1222 - "mock_utmi", "sleep"; 1220 + <&rpmcc RPM_SMD_AGGR2_NOC_CLK>; 1221 + clock-names = "cfg_noc", 1222 + "core", 1223 + "iface", 1224 + "sleep", 1225 + "mock_utmi", 1226 + "bus"; 1223 1227 1224 1228 assigned-clocks = <&gcc GCC_USB30_MOCK_UTMI_CLK>, 1225 1229 <&gcc GCC_USB30_MASTER_CLK>,
+16 -10
arch/arm64/boot/dts/qcom/sdm845.dtsi
··· 3844 3844 clocks = <&gcc GCC_CFG_NOC_USB3_PRIM_AXI_CLK>, 3845 3845 <&gcc GCC_USB30_PRIM_MASTER_CLK>, 3846 3846 <&gcc GCC_AGGRE_USB3_PRIM_AXI_CLK>, 3847 - <&gcc GCC_USB30_PRIM_MOCK_UTMI_CLK>, 3848 - <&gcc GCC_USB30_PRIM_SLEEP_CLK>; 3849 - clock-names = "cfg_noc", "core", "iface", "mock_utmi", 3850 - "sleep"; 3847 + <&gcc GCC_USB30_PRIM_SLEEP_CLK>, 3848 + <&gcc GCC_USB30_PRIM_MOCK_UTMI_CLK>; 3849 + clock-names = "cfg_noc", 3850 + "core", 3851 + "iface", 3852 + "sleep", 3853 + "mock_utmi"; 3851 3854 3852 3855 assigned-clocks = <&gcc GCC_USB30_PRIM_MOCK_UTMI_CLK>, 3853 3856 <&gcc GCC_USB30_PRIM_MASTER_CLK>; ··· 3871 3868 <&gladiator_noc MASTER_APPSS_PROC 0 &config_noc SLAVE_USB3_0 0>; 3872 3869 interconnect-names = "usb-ddr", "apps-usb"; 3873 3870 3874 - usb_1_dwc3: dwc3@a600000 { 3871 + usb_1_dwc3: usb@a600000 { 3875 3872 compatible = "snps,dwc3"; 3876 3873 reg = <0 0x0a600000 0 0xcd00>; 3877 3874 interrupts = <GIC_SPI 133 IRQ_TYPE_LEVEL_HIGH>; ··· 3895 3892 clocks = <&gcc GCC_CFG_NOC_USB3_SEC_AXI_CLK>, 3896 3893 <&gcc GCC_USB30_SEC_MASTER_CLK>, 3897 3894 <&gcc GCC_AGGRE_USB3_SEC_AXI_CLK>, 3898 - <&gcc GCC_USB30_SEC_MOCK_UTMI_CLK>, 3899 - <&gcc GCC_USB30_SEC_SLEEP_CLK>; 3900 - clock-names = "cfg_noc", "core", "iface", "mock_utmi", 3901 - "sleep"; 3895 + <&gcc GCC_USB30_SEC_SLEEP_CLK>, 3896 + <&gcc GCC_USB30_SEC_MOCK_UTMI_CLK>; 3897 + clock-names = "cfg_noc", 3898 + "core", 3899 + "iface", 3900 + "sleep", 3901 + "mock_utmi"; 3902 3902 3903 3903 assigned-clocks = <&gcc GCC_USB30_SEC_MOCK_UTMI_CLK>, 3904 3904 <&gcc GCC_USB30_SEC_MASTER_CLK>; ··· 3922 3916 <&gladiator_noc MASTER_APPSS_PROC 0 &config_noc SLAVE_USB3_1 0>; 3923 3917 interconnect-names = "usb-ddr", "apps-usb"; 3924 3918 3925 - usb_2_dwc3: dwc3@a800000 { 3919 + usb_2_dwc3: usb@a800000 { 3926 3920 compatible = "snps,dwc3"; 3927 3921 reg = <0 0x0a800000 0 0xcd00>; 3928 3922 interrupts = <GIC_SPI 138 IRQ_TYPE_LEVEL_HIGH>;
+11 -5
arch/arm64/boot/dts/qcom/sm6125.dtsi
··· 481 481 }; 482 482 483 483 usb3: usb@4ef8800 { 484 - compatible = "qcom,msm8996-dwc3", "qcom,dwc3"; 484 + compatible = "qcom,sm6125-dwc3", "qcom,dwc3"; 485 485 reg = <0x04ef8800 0x400>; 486 486 #address-cells = <1>; 487 487 #size-cells = <1>; 488 488 ranges; 489 489 490 - clocks = <&gcc GCC_USB30_PRIM_MASTER_CLK>, 490 + clocks = <&gcc GCC_CFG_NOC_USB3_PRIM_AXI_CLK>, 491 + <&gcc GCC_USB30_PRIM_MASTER_CLK>, 491 492 <&gcc GCC_SYS_NOC_USB3_PRIM_AXI_CLK>, 492 - <&gcc GCC_CFG_NOC_USB3_PRIM_AXI_CLK>, 493 - <&gcc GCC_USB3_PRIM_CLKREF_CLK>, 494 493 <&gcc GCC_USB30_PRIM_SLEEP_CLK>, 495 - <&gcc GCC_USB30_PRIM_MOCK_UTMI_CLK>; 494 + <&gcc GCC_USB30_PRIM_MOCK_UTMI_CLK>, 495 + <&gcc GCC_USB3_PRIM_CLKREF_CLK>; 496 + clock-names = "cfg_noc", 497 + "core", 498 + "iface", 499 + "sleep", 500 + "mock_utmi", 501 + "xo"; 496 502 497 503 assigned-clocks = <&gcc GCC_USB30_PRIM_MOCK_UTMI_CLK>, 498 504 <&gcc GCC_USB30_PRIM_MASTER_CLK>;
+7 -4
arch/arm64/boot/dts/qcom/sm6350.dtsi
··· 1034 1034 clocks = <&gcc GCC_CFG_NOC_USB3_PRIM_AXI_CLK>, 1035 1035 <&gcc GCC_USB30_PRIM_MASTER_CLK>, 1036 1036 <&gcc GCC_AGGRE_USB3_PRIM_AXI_CLK>, 1037 - <&gcc GCC_USB30_PRIM_MOCK_UTMI_CLK>, 1038 - <&gcc GCC_USB30_PRIM_SLEEP_CLK>; 1039 - clock-names = "cfg_noc", "core", "iface", "mock_utmi", 1040 - "sleep"; 1037 + <&gcc GCC_USB30_PRIM_SLEEP_CLK>, 1038 + <&gcc GCC_USB30_PRIM_MOCK_UTMI_CLK>; 1039 + clock-names = "cfg_noc", 1040 + "core", 1041 + "iface", 1042 + "sleep", 1043 + "mock_utmi"; 1041 1044 1042 1045 interrupts-extended = <&intc GIC_SPI 130 IRQ_TYPE_LEVEL_HIGH>, 1043 1046 <&pdc 17 IRQ_TYPE_LEVEL_HIGH>,
+15 -7
arch/arm64/boot/dts/qcom/sm8150.dtsi
··· 3614 3614 clocks = <&gcc GCC_CFG_NOC_USB3_PRIM_AXI_CLK>, 3615 3615 <&gcc GCC_USB30_PRIM_MASTER_CLK>, 3616 3616 <&gcc GCC_AGGRE_USB3_PRIM_AXI_CLK>, 3617 - <&gcc GCC_USB30_PRIM_MOCK_UTMI_CLK>, 3618 3617 <&gcc GCC_USB30_PRIM_SLEEP_CLK>, 3618 + <&gcc GCC_USB30_PRIM_MOCK_UTMI_CLK>, 3619 3619 <&gcc GCC_USB3_SEC_CLKREF_CLK>; 3620 - clock-names = "cfg_noc", "core", "iface", "mock_utmi", 3621 - "sleep", "xo"; 3620 + clock-names = "cfg_noc", 3621 + "core", 3622 + "iface", 3623 + "sleep", 3624 + "mock_utmi", 3625 + "xo"; 3622 3626 3623 3627 assigned-clocks = <&gcc GCC_USB30_PRIM_MOCK_UTMI_CLK>, 3624 3628 <&gcc GCC_USB30_PRIM_MASTER_CLK>; ··· 3639 3635 3640 3636 resets = <&gcc GCC_USB30_PRIM_BCR>; 3641 3637 3642 - usb_1_dwc3: dwc3@a600000 { 3638 + usb_1_dwc3: usb@a600000 { 3643 3639 compatible = "snps,dwc3"; 3644 3640 reg = <0 0x0a600000 0 0xcd00>; 3645 3641 interrupts = <GIC_SPI 133 IRQ_TYPE_LEVEL_HIGH>; ··· 3663 3659 clocks = <&gcc GCC_CFG_NOC_USB3_SEC_AXI_CLK>, 3664 3660 <&gcc GCC_USB30_SEC_MASTER_CLK>, 3665 3661 <&gcc GCC_AGGRE_USB3_SEC_AXI_CLK>, 3666 - <&gcc GCC_USB30_SEC_MOCK_UTMI_CLK>, 3667 3662 <&gcc GCC_USB30_SEC_SLEEP_CLK>, 3663 + <&gcc GCC_USB30_SEC_MOCK_UTMI_CLK>, 3668 3664 <&gcc GCC_USB3_SEC_CLKREF_CLK>; 3669 - clock-names = "cfg_noc", "core", "iface", "mock_utmi", 3670 - "sleep", "xo"; 3665 + clock-names = "cfg_noc", 3666 + "core", 3667 + "iface", 3668 + "sleep", 3669 + "mock_utmi", 3670 + "xo"; 3671 3671 3672 3672 assigned-clocks = <&gcc GCC_USB30_SEC_MOCK_UTMI_CLK>, 3673 3673 <&gcc GCC_USB30_SEC_MASTER_CLK>;
+14 -6
arch/arm64/boot/dts/qcom/sm8250.dtsi
··· 2995 2995 clocks = <&gcc GCC_CFG_NOC_USB3_PRIM_AXI_CLK>, 2996 2996 <&gcc GCC_USB30_PRIM_MASTER_CLK>, 2997 2997 <&gcc GCC_AGGRE_USB3_PRIM_AXI_CLK>, 2998 - <&gcc GCC_USB30_PRIM_MOCK_UTMI_CLK>, 2999 2998 <&gcc GCC_USB30_PRIM_SLEEP_CLK>, 2999 + <&gcc GCC_USB30_PRIM_MOCK_UTMI_CLK>, 3000 3000 <&gcc GCC_USB3_SEC_CLKREF_EN>; 3001 - clock-names = "cfg_noc", "core", "iface", "mock_utmi", 3002 - "sleep", "xo"; 3001 + clock-names = "cfg_noc", 3002 + "core", 3003 + "iface", 3004 + "sleep", 3005 + "mock_utmi", 3006 + "xo"; 3003 3007 3004 3008 assigned-clocks = <&gcc GCC_USB30_PRIM_MOCK_UTMI_CLK>, 3005 3009 <&gcc GCC_USB30_PRIM_MASTER_CLK>; ··· 3050 3046 clocks = <&gcc GCC_CFG_NOC_USB3_SEC_AXI_CLK>, 3051 3047 <&gcc GCC_USB30_SEC_MASTER_CLK>, 3052 3048 <&gcc GCC_AGGRE_USB3_SEC_AXI_CLK>, 3053 - <&gcc GCC_USB30_SEC_MOCK_UTMI_CLK>, 3054 3049 <&gcc GCC_USB30_SEC_SLEEP_CLK>, 3050 + <&gcc GCC_USB30_SEC_MOCK_UTMI_CLK>, 3055 3051 <&gcc GCC_USB3_SEC_CLKREF_EN>; 3056 - clock-names = "cfg_noc", "core", "iface", "mock_utmi", 3057 - "sleep", "xo"; 3052 + clock-names = "cfg_noc", 3053 + "core", 3054 + "iface", 3055 + "sleep", 3056 + "mock_utmi", 3057 + "xo"; 3058 3058 3059 3059 assigned-clocks = <&gcc GCC_USB30_SEC_MOCK_UTMI_CLK>, 3060 3060 <&gcc GCC_USB30_SEC_MASTER_CLK>;
+14 -7
arch/arm64/boot/dts/qcom/sm8350.dtsi
··· 2449 2449 clocks = <&gcc GCC_CFG_NOC_USB3_PRIM_AXI_CLK>, 2450 2450 <&gcc GCC_USB30_PRIM_MASTER_CLK>, 2451 2451 <&gcc GCC_AGGRE_USB3_PRIM_AXI_CLK>, 2452 - <&gcc GCC_USB30_PRIM_MOCK_UTMI_CLK>, 2453 - <&gcc GCC_USB30_PRIM_SLEEP_CLK>; 2454 - clock-names = "cfg_noc", "core", "iface", "mock_utmi", 2455 - "sleep"; 2452 + <&gcc GCC_USB30_PRIM_SLEEP_CLK>, 2453 + <&gcc GCC_USB30_PRIM_MOCK_UTMI_CLK>; 2454 + clock-names = "cfg_noc", 2455 + "core", 2456 + "iface", 2457 + "sleep", 2458 + "mock_utmi"; 2456 2459 2457 2460 assigned-clocks = <&gcc GCC_USB30_PRIM_MOCK_UTMI_CLK>, 2458 2461 <&gcc GCC_USB30_PRIM_MASTER_CLK>; ··· 2495 2492 clocks = <&gcc GCC_CFG_NOC_USB3_SEC_AXI_CLK>, 2496 2493 <&gcc GCC_USB30_SEC_MASTER_CLK>, 2497 2494 <&gcc GCC_AGGRE_USB3_SEC_AXI_CLK>, 2498 - <&gcc GCC_USB30_SEC_MOCK_UTMI_CLK>, 2499 2495 <&gcc GCC_USB30_SEC_SLEEP_CLK>, 2496 + <&gcc GCC_USB30_SEC_MOCK_UTMI_CLK>, 2500 2497 <&gcc GCC_USB3_SEC_CLKREF_EN>; 2501 - clock-names = "cfg_noc", "core", "iface", "mock_utmi", 2502 - "sleep", "xo"; 2498 + clock-names = "cfg_noc", 2499 + "core", 2500 + "iface", 2501 + "sleep", 2502 + "mock_utmi", 2503 + "xo"; 2503 2504 2504 2505 assigned-clocks = <&gcc GCC_USB30_SEC_MOCK_UTMI_CLK>, 2505 2506 <&gcc GCC_USB30_SEC_MASTER_CLK>;
+13 -7
arch/arm64/boot/dts/qcom/sm8450.dtsi
··· 3107 3107 clocks = <&gcc GCC_CFG_NOC_USB3_PRIM_AXI_CLK>, 3108 3108 <&gcc GCC_USB30_PRIM_MASTER_CLK>, 3109 3109 <&gcc GCC_AGGRE_USB3_PRIM_AXI_CLK>, 3110 - <&gcc GCC_USB30_PRIM_MOCK_UTMI_CLK>, 3111 3110 <&gcc GCC_USB30_PRIM_SLEEP_CLK>, 3111 + <&gcc GCC_USB30_PRIM_MOCK_UTMI_CLK>, 3112 3112 <&gcc GCC_USB3_0_CLKREF_EN>; 3113 - clock-names = "cfg_noc", "core", "iface", "mock_utmi", 3114 - "sleep", "xo"; 3113 + clock-names = "cfg_noc", 3114 + "core", 3115 + "iface", 3116 + "sleep", 3117 + "mock_utmi", 3118 + "xo"; 3115 3119 3116 3120 assigned-clocks = <&gcc GCC_USB30_PRIM_MOCK_UTMI_CLK>, 3117 3121 <&gcc GCC_USB30_PRIM_MASTER_CLK>; 3118 3122 assigned-clock-rates = <19200000>, <200000000>; 3119 3123 3120 3124 interrupts-extended = <&intc GIC_SPI 130 IRQ_TYPE_LEVEL_HIGH>, 3121 - <&pdc 14 IRQ_TYPE_EDGE_BOTH>, 3125 + <&pdc 17 IRQ_TYPE_LEVEL_HIGH>, 3122 3126 <&pdc 15 IRQ_TYPE_EDGE_BOTH>, 3123 - <&pdc 17 IRQ_TYPE_LEVEL_HIGH>; 3124 - interrupt-names = "hs_phy_irq", "dp_hs_phy_irq", 3125 - "dm_hs_phy_irq", "ss_phy_irq"; 3127 + <&pdc 14 IRQ_TYPE_EDGE_BOTH>; 3128 + interrupt-names = "hs_phy_irq", 3129 + "ss_phy_irq", 3130 + "dm_hs_phy_irq", 3131 + "dp_hs_phy_irq"; 3126 3132 3127 3133 power-domains = <&gcc USB30_PRIM_GDSC>; 3128 3134
+1 -1
arch/mips/boot/dts/ingenic/jz4780.dtsi
··· 577 577 }; 578 578 579 579 otg: usb@13500000 { 580 - compatible = "ingenic,jz4780-otg", "snps,dwc2"; 580 + compatible = "ingenic,jz4780-otg"; 581 581 reg = <0x13500000 0x40000>; 582 582 583 583 interrupt-parent = <&intc>;
+1 -1
arch/mips/boot/dts/ingenic/x1000.dtsi
··· 398 398 }; 399 399 400 400 otg: usb@13500000 { 401 - compatible = "ingenic,x1000-otg", "snps,dwc2"; 401 + compatible = "ingenic,x1000-otg"; 402 402 reg = <0x13500000 0x40000>; 403 403 404 404 interrupt-parent = <&intc>;
+1 -1
arch/mips/boot/dts/ingenic/x1830.dtsi
··· 408 408 }; 409 409 410 410 otg: usb@13500000 { 411 - compatible = "ingenic,x1830-otg", "snps,dwc2"; 411 + compatible = "ingenic,x1830-otg"; 412 412 reg = <0x13500000 0x40000>; 413 413 414 414 interrupt-parent = <&intc>;
+80 -16
drivers/base/property.c
··· 1206 1206 } 1207 1207 EXPORT_SYMBOL_GPL(device_get_match_data); 1208 1208 1209 - static void * 1210 - fwnode_graph_devcon_match(struct fwnode_handle *fwnode, const char *con_id, 1211 - void *data, devcon_match_fn_t match) 1209 + static unsigned int fwnode_graph_devcon_matches(struct fwnode_handle *fwnode, 1210 + const char *con_id, void *data, 1211 + devcon_match_fn_t match, 1212 + void **matches, 1213 + unsigned int matches_len) 1212 1214 { 1213 1215 struct fwnode_handle *node; 1214 1216 struct fwnode_handle *ep; 1217 + unsigned int count = 0; 1215 1218 void *ret; 1216 1219 1217 1220 fwnode_graph_for_each_endpoint(fwnode, ep) { 1221 + if (matches && count >= matches_len) { 1222 + fwnode_handle_put(ep); 1223 + break; 1224 + } 1225 + 1218 1226 node = fwnode_graph_get_remote_port_parent(ep); 1219 1227 if (!fwnode_device_is_available(node)) { 1220 1228 fwnode_handle_put(node); ··· 1232 1224 ret = match(node, con_id, data); 1233 1225 fwnode_handle_put(node); 1234 1226 if (ret) { 1235 - fwnode_handle_put(ep); 1236 - return ret; 1227 + if (matches) 1228 + matches[count] = ret; 1229 + count++; 1237 1230 } 1238 1231 } 1239 - return NULL; 1232 + return count; 1240 1233 } 1241 1234 1242 - static void * 1243 - fwnode_devcon_match(struct fwnode_handle *fwnode, const char *con_id, 1244 - void *data, devcon_match_fn_t match) 1235 + static unsigned int fwnode_devcon_matches(struct fwnode_handle *fwnode, 1236 + const char *con_id, void *data, 1237 + devcon_match_fn_t match, 1238 + void **matches, 1239 + unsigned int matches_len) 1245 1240 { 1246 1241 struct fwnode_handle *node; 1242 + unsigned int count = 0; 1243 + unsigned int i; 1247 1244 void *ret; 1248 - int i; 1249 1245 1250 1246 for (i = 0; ; i++) { 1247 + if (matches && count >= matches_len) 1248 + break; 1249 + 1251 1250 node = fwnode_find_reference(fwnode, con_id, i); 1252 1251 if (IS_ERR(node)) 1253 1252 break; 1254 1253 1255 1254 ret = match(node, NULL, data); 1256 1255 fwnode_handle_put(node); 1257 - if (ret) 1258 - return ret; 1256 + if (ret) { 1257 + if (matches) 1258 + matches[count] = ret; 1259 + count++; 1260 + } 1259 1261 } 1260 1262 1261 - return NULL; 1263 + return count; 1262 1264 } 1263 1265 1264 1266 /** ··· 1286 1268 const char *con_id, void *data, 1287 1269 devcon_match_fn_t match) 1288 1270 { 1271 + unsigned int count; 1289 1272 void *ret; 1290 1273 1291 1274 if (!fwnode || !match) 1292 1275 return NULL; 1293 1276 1294 - ret = fwnode_graph_devcon_match(fwnode, con_id, data, match); 1295 - if (ret) 1277 + count = fwnode_graph_devcon_matches(fwnode, con_id, data, match, &ret, 1); 1278 + if (count) 1296 1279 return ret; 1297 1280 1298 - return fwnode_devcon_match(fwnode, con_id, data, match); 1281 + count = fwnode_devcon_matches(fwnode, con_id, data, match, &ret, 1); 1282 + return count ? ret : NULL; 1299 1283 } 1300 1284 EXPORT_SYMBOL_GPL(fwnode_connection_find_match); 1285 + 1286 + /** 1287 + * fwnode_connection_find_matches - Find connections from a device node 1288 + * @fwnode: Device node with the connection 1289 + * @con_id: Identifier for the connection 1290 + * @data: Data for the match function 1291 + * @match: Function to check and convert the connection description 1292 + * @matches: (Optional) array of pointers to fill with matches 1293 + * @matches_len: Length of @matches 1294 + * 1295 + * Find up to @matches_len connections with unique identifier @con_id between 1296 + * @fwnode and other device nodes. @match will be used to convert the 1297 + * connection description to data the caller is expecting to be returned 1298 + * through the @matches array. 1299 + * If @matches is NULL @matches_len is ignored and the total number of resolved 1300 + * matches is returned. 1301 + * 1302 + * Return: Number of matches resolved, or negative errno. 1303 + */ 1304 + int fwnode_connection_find_matches(struct fwnode_handle *fwnode, 1305 + const char *con_id, void *data, 1306 + devcon_match_fn_t match, 1307 + void **matches, unsigned int matches_len) 1308 + { 1309 + unsigned int count_graph; 1310 + unsigned int count_ref; 1311 + 1312 + if (!fwnode || !match) 1313 + return -EINVAL; 1314 + 1315 + count_graph = fwnode_graph_devcon_matches(fwnode, con_id, data, match, 1316 + matches, matches_len); 1317 + 1318 + if (matches) { 1319 + matches += count_graph; 1320 + matches_len -= count_graph; 1321 + } 1322 + 1323 + count_ref = fwnode_devcon_matches(fwnode, con_id, data, match, 1324 + matches, matches_len); 1325 + 1326 + return count_graph + count_ref; 1327 + } 1328 + EXPORT_SYMBOL_GPL(fwnode_connection_find_matches);
+1 -1
drivers/hid/usbhid/hid-core.c
··· 387 387 388 388 usbhid->urbctrl->pipe = usb_rcvctrlpipe(hid_to_usb_dev(hid), 0); 389 389 maxpacket = usb_maxpacket(hid_to_usb_dev(hid), 390 - usbhid->urbctrl->pipe, 0); 390 + usbhid->urbctrl->pipe); 391 391 len += (len == 0); /* Don't allow 0-length reports */ 392 392 len = round_up(len, maxpacket); 393 393 if (len > usbhid->bufsize)
+1 -1
drivers/hid/usbhid/usbkbd.c
··· 279 279 return -ENODEV; 280 280 281 281 pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress); 282 - maxp = usb_maxpacket(dev, pipe, usb_pipeout(pipe)); 282 + maxp = usb_maxpacket(dev, pipe); 283 283 284 284 kbd = kzalloc(sizeof(struct usb_kbd), GFP_KERNEL); 285 285 input_dev = input_allocate_device();
+1 -1
drivers/hid/usbhid/usbmouse.c
··· 123 123 return -ENODEV; 124 124 125 125 pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress); 126 - maxp = usb_maxpacket(dev, pipe, usb_pipeout(pipe)); 126 + maxp = usb_maxpacket(dev, pipe); 127 127 128 128 mouse = kzalloc(sizeof(struct usb_mouse), GFP_KERNEL); 129 129 input_dev = input_allocate_device();
+1 -1
drivers/input/misc/ati_remote2.c
··· 639 639 return -ENOMEM; 640 640 641 641 pipe = usb_rcvintpipe(udev, ar2->ep[i]->bEndpointAddress); 642 - maxp = usb_maxpacket(udev, pipe, usb_pipeout(pipe)); 642 + maxp = usb_maxpacket(udev, pipe); 643 643 maxp = maxp > 4 ? 4 : maxp; 644 644 645 645 usb_fill_int_urb(ar2->urb[i], udev, pipe, ar2->buf[i], maxp,
+1 -1
drivers/input/misc/cm109.c
··· 745 745 746 746 /* get a handle to the interrupt data pipe */ 747 747 pipe = usb_rcvintpipe(udev, endpoint->bEndpointAddress); 748 - ret = usb_maxpacket(udev, pipe, usb_pipeout(pipe)); 748 + ret = usb_maxpacket(udev, pipe); 749 749 if (ret != USB_PKT_LEN) 750 750 dev_err(&intf->dev, "invalid payload size %d, expected %d\n", 751 751 ret, USB_PKT_LEN);
+1 -1
drivers/input/misc/powermate.c
··· 374 374 375 375 /* get a handle to the interrupt data pipe */ 376 376 pipe = usb_rcvintpipe(udev, endpoint->bEndpointAddress); 377 - maxp = usb_maxpacket(udev, pipe, usb_pipeout(pipe)); 377 + maxp = usb_maxpacket(udev, pipe); 378 378 379 379 if (maxp < POWERMATE_PAYLOAD_SIZE_MIN || maxp > POWERMATE_PAYLOAD_SIZE_MAX) { 380 380 printk(KERN_WARNING "powermate: Expected payload of %d--%d bytes, found %d bytes!\n",
+1 -1
drivers/input/misc/yealink.c
··· 905 905 906 906 /* get a handle to the interrupt data pipe */ 907 907 pipe = usb_rcvintpipe(udev, endpoint->bEndpointAddress); 908 - ret = usb_maxpacket(udev, pipe, usb_pipeout(pipe)); 908 + ret = usb_maxpacket(udev, pipe); 909 909 if (ret != USB_PKT_LEN) 910 910 dev_err(&intf->dev, "invalid payload size %d, expected %zd\n", 911 911 ret, USB_PKT_LEN);
+1 -1
drivers/input/tablet/acecad.c
··· 130 130 return -ENODEV; 131 131 132 132 pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress); 133 - maxp = usb_maxpacket(dev, pipe, usb_pipeout(pipe)); 133 + maxp = usb_maxpacket(dev, pipe); 134 134 135 135 acecad = kzalloc(sizeof(struct usb_acecad), GFP_KERNEL); 136 136 input_dev = input_allocate_device();
+1 -1
drivers/input/tablet/pegasus_notetaker.c
··· 296 296 pegasus->intf = intf; 297 297 298 298 pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress); 299 - pegasus->data_len = usb_maxpacket(dev, pipe, usb_pipeout(pipe)); 299 + pegasus->data_len = usb_maxpacket(dev, pipe); 300 300 301 301 pegasus->data = usb_alloc_coherent(dev, pegasus->data_len, GFP_KERNEL, 302 302 &pegasus->data_dma);
+2 -2
drivers/media/rc/ati_remote.c
··· 773 773 774 774 /* Set up irq_urb */ 775 775 pipe = usb_rcvintpipe(udev, ati_remote->endpoint_in->bEndpointAddress); 776 - maxp = usb_maxpacket(udev, pipe, usb_pipeout(pipe)); 776 + maxp = usb_maxpacket(udev, pipe); 777 777 maxp = (maxp > DATA_BUFSIZE) ? DATA_BUFSIZE : maxp; 778 778 779 779 usb_fill_int_urb(ati_remote->irq_urb, udev, pipe, ati_remote->inbuf, ··· 784 784 785 785 /* Set up out_urb */ 786 786 pipe = usb_sndintpipe(udev, ati_remote->endpoint_out->bEndpointAddress); 787 - maxp = usb_maxpacket(udev, pipe, usb_pipeout(pipe)); 787 + maxp = usb_maxpacket(udev, pipe); 788 788 maxp = (maxp > DATA_BUFSIZE) ? DATA_BUFSIZE : maxp; 789 789 790 790 usb_fill_int_urb(ati_remote->out_urb, udev, pipe, ati_remote->outbuf,
+1 -1
drivers/media/rc/mceusb.c
··· 1728 1728 pipe = usb_rcvintpipe(dev, ep_in->bEndpointAddress); 1729 1729 else 1730 1730 pipe = usb_rcvbulkpipe(dev, ep_in->bEndpointAddress); 1731 - maxp = usb_maxpacket(dev, pipe, usb_pipeout(pipe)); 1731 + maxp = usb_maxpacket(dev, pipe); 1732 1732 1733 1733 ir = kzalloc(sizeof(struct mceusb_dev), GFP_KERNEL); 1734 1734 if (!ir)
+1 -1
drivers/media/rc/streamzap.c
··· 307 307 } 308 308 309 309 pipe = usb_rcvintpipe(usbdev, endpoint->bEndpointAddress); 310 - maxp = usb_maxpacket(usbdev, pipe, usb_pipeout(pipe)); 310 + maxp = usb_maxpacket(usbdev, pipe); 311 311 312 312 if (maxp == 0) { 313 313 dev_err(&intf->dev, "%s: endpoint Max Packet Size is 0!?!\n",
+1 -1
drivers/media/rc/xbox_remote.c
··· 171 171 172 172 /* Set up irq_urb */ 173 173 pipe = usb_rcvintpipe(udev, endpoint_in->bEndpointAddress); 174 - maxp = usb_maxpacket(udev, pipe, usb_pipeout(pipe)); 174 + maxp = usb_maxpacket(udev, pipe); 175 175 maxp = (maxp > DATA_BUFSIZE) ? DATA_BUFSIZE : maxp; 176 176 177 177 usb_fill_int_urb(xbox_remote->irq_urb, udev, pipe, xbox_remote->inbuf,
+1 -1
drivers/media/usb/tm6000/tm6000-dvb.c
··· 120 120 pipe = usb_rcvbulkpipe(dev->udev, dev->bulk_in.endp->desc.bEndpointAddress 121 121 & USB_ENDPOINT_NUMBER_MASK); 122 122 123 - size = usb_maxpacket(dev->udev, pipe, usb_pipeout(pipe)); 123 + size = usb_maxpacket(dev->udev, pipe); 124 124 size = size * 15; /* 512 x 8 or 12 or 15 */ 125 125 126 126 dvb->bulk_urb->transfer_buffer = kzalloc(size, GFP_KERNEL);
+1 -1
drivers/media/usb/tm6000/tm6000-input.c
··· 340 340 dev->int_in.endp->desc.bEndpointAddress 341 341 & USB_ENDPOINT_NUMBER_MASK); 342 342 343 - size = usb_maxpacket(dev->udev, pipe, usb_pipeout(pipe)); 343 + size = usb_maxpacket(dev->udev, pipe); 344 344 dprintk(1, "IR max size: %d\n", size); 345 345 346 346 ir->int_urb->transfer_buffer = kzalloc(size, GFP_ATOMIC);
+1 -1
drivers/media/usb/tm6000/tm6000-video.c
··· 570 570 dev->isoc_in.endp->desc.bEndpointAddress & 571 571 USB_ENDPOINT_NUMBER_MASK); 572 572 573 - size = usb_maxpacket(dev->udev, pipe, usb_pipeout(pipe)); 573 + size = usb_maxpacket(dev->udev, pipe); 574 574 575 575 if (size > dev->isoc_in.maxsize) 576 576 size = dev->isoc_in.maxsize;
+1 -1
drivers/misc/mei/hdcp/mei_hdcp.c
··· 784 784 { 785 785 struct device *base = data; 786 786 787 - if (strcmp(dev->driver->name, "i915") || 787 + if (!dev->driver || strcmp(dev->driver->name, "i915") || 788 788 subcomponent != I915_COMPONENT_HDCP) 789 789 return 0; 790 790
+1 -1
drivers/misc/mei/pxp/mei_pxp.c
··· 131 131 { 132 132 struct device *base = data; 133 133 134 - if (strcmp(dev->driver->name, "i915") || 134 + if (!dev->driver || strcmp(dev->driver->name, "i915") || 135 135 subcomponent != I915_COMPONENT_PXP) 136 136 return 0; 137 137
+2 -2
drivers/net/usb/cdc_ncm.c
··· 441 441 * .bind which is called before usbnet sets up dev->maxpacket 442 442 */ 443 443 if (val != le32_to_cpu(ctx->ncm_parm.dwNtbOutMaxSize) && 444 - val % usb_maxpacket(dev->udev, dev->out, 1) == 0) 444 + val % usb_maxpacket(dev->udev, dev->out) == 0) 445 445 val++; 446 446 447 447 /* we might need to flush any pending tx buffers if running */ ··· 465 465 usbnet_update_max_qlen(dev); 466 466 467 467 /* never pad more than 3 full USB packets per transfer */ 468 - ctx->min_tx_pkt = clamp_t(u16, ctx->tx_max - 3 * usb_maxpacket(dev->udev, dev->out, 1), 468 + ctx->min_tx_pkt = clamp_t(u16, ctx->tx_max - 3 * usb_maxpacket(dev->udev, dev->out), 469 469 CDC_NCM_MIN_TX_PKT, ctx->tx_max); 470 470 } 471 471
+2 -2
drivers/net/usb/lan78xx.c
··· 4421 4421 goto out4; 4422 4422 4423 4423 period = ep_intr->desc.bInterval; 4424 - maxp = usb_maxpacket(dev->udev, dev->pipe_intr, 0); 4424 + maxp = usb_maxpacket(dev->udev, dev->pipe_intr); 4425 4425 buf = kmalloc(maxp, GFP_KERNEL); 4426 4426 if (!buf) { 4427 4427 ret = -ENOMEM; ··· 4439 4439 dev->urb_intr->transfer_flags |= URB_FREE_BUFFER; 4440 4440 } 4441 4441 4442 - dev->maxpacket = usb_maxpacket(dev->udev, dev->pipe_out, 1); 4442 + dev->maxpacket = usb_maxpacket(dev->udev, dev->pipe_out); 4443 4443 4444 4444 /* Reject broken descriptors. */ 4445 4445 if (dev->maxpacket == 0) {
+1 -1
drivers/net/usb/rndis_host.c
··· 333 333 net->hard_header_len += sizeof (struct rndis_data_hdr); 334 334 dev->hard_mtu = net->mtu + net->hard_header_len; 335 335 336 - dev->maxpacket = usb_maxpacket(dev->udev, dev->out, 1); 336 + dev->maxpacket = usb_maxpacket(dev->udev, dev->out); 337 337 if (dev->maxpacket == 0) { 338 338 netif_dbg(dev, probe, dev->net, 339 339 "dev->maxpacket can't be 0\n");
+2 -2
drivers/net/usb/usbnet.c
··· 229 229 pipe = usb_rcvintpipe (dev->udev, 230 230 dev->status->desc.bEndpointAddress 231 231 & USB_ENDPOINT_NUMBER_MASK); 232 - maxp = usb_maxpacket (dev->udev, pipe, 0); 232 + maxp = usb_maxpacket(dev->udev, pipe); 233 233 234 234 /* avoid 1 msec chatter: min 8 msec poll rate */ 235 235 period = max ((int) dev->status->desc.bInterval, ··· 1789 1789 1790 1790 if (!dev->rx_urb_size) 1791 1791 dev->rx_urb_size = dev->hard_mtu; 1792 - dev->maxpacket = usb_maxpacket (dev->udev, dev->out, 1); 1792 + dev->maxpacket = usb_maxpacket(dev->udev, dev->out); 1793 1793 if (dev->maxpacket == 0) { 1794 1794 /* that is a broken device */ 1795 1795 status = -ENODEV;
+1 -1
drivers/net/wireless/mediatek/mt76/usb.c
··· 1068 1068 1069 1069 INIT_WORK(&usb->stat_work, mt76u_tx_status_data); 1070 1070 1071 - usb->data_len = usb_maxpacket(udev, usb_sndctrlpipe(udev, 0), 1); 1071 + usb->data_len = usb_maxpacket(udev, usb_sndctrlpipe(udev, 0)); 1072 1072 if (usb->data_len < 32) 1073 1073 usb->data_len = 32; 1074 1074
+2 -2
drivers/net/wireless/ralink/rt2x00/rt2x00usb.c
··· 586 586 587 587 if (queue->qid == QID_RX) { 588 588 pipe = usb_rcvbulkpipe(usb_dev, queue->usb_endpoint); 589 - queue->usb_maxpacket = usb_maxpacket(usb_dev, pipe, 0); 589 + queue->usb_maxpacket = usb_maxpacket(usb_dev, pipe); 590 590 } else { 591 591 pipe = usb_sndbulkpipe(usb_dev, queue->usb_endpoint); 592 - queue->usb_maxpacket = usb_maxpacket(usb_dev, pipe, 1); 592 + queue->usb_maxpacket = usb_maxpacket(usb_dev, pipe); 593 593 } 594 594 595 595 if (!queue->usb_maxpacket)
+7 -8
drivers/thunderbolt/ctl.c
··· 158 158 static struct tb_cfg_request * 159 159 tb_cfg_request_find(struct tb_ctl *ctl, struct ctl_pkg *pkg) 160 160 { 161 - struct tb_cfg_request *req; 162 - bool found = false; 161 + struct tb_cfg_request *req = NULL, *iter; 163 162 164 163 mutex_lock(&pkg->ctl->request_queue_lock); 165 - list_for_each_entry(req, &pkg->ctl->request_queue, list) { 166 - tb_cfg_request_get(req); 167 - if (req->match(req, pkg)) { 168 - found = true; 164 + list_for_each_entry(iter, &pkg->ctl->request_queue, list) { 165 + tb_cfg_request_get(iter); 166 + if (iter->match(iter, pkg)) { 167 + req = iter; 169 168 break; 170 169 } 171 - tb_cfg_request_put(req); 170 + tb_cfg_request_put(iter); 172 171 } 173 172 mutex_unlock(&pkg->ctl->request_queue_lock); 174 173 175 - return found ? req : NULL; 174 + return req; 176 175 } 177 176 178 177 /* utility functions */
+1 -1
drivers/thunderbolt/nhi.c
··· 1250 1250 1251 1251 nhi->pdev = pdev; 1252 1252 nhi->ops = (const struct tb_nhi_ops *)id->driver_data; 1253 - /* cannot fail - table is allocated bin pcim_iomap_regions */ 1253 + /* cannot fail - table is allocated in pcim_iomap_regions */ 1254 1254 nhi->iobase = pcim_iomap_table(pdev)[0]; 1255 1255 nhi->hop_count = ioread32(nhi->iobase + REG_HOP_COUNT) & 0x3ff; 1256 1256 dev_dbg(&pdev->dev, "total paths: %d\n", nhi->hop_count);
+6
drivers/thunderbolt/path.c
··· 166 166 return NULL; 167 167 } 168 168 169 + tb_dbg(path->tb, "discovering %s path starting from %llx:%u\n", 170 + path->name, tb_route(src->sw), src->port); 171 + 169 172 p = src; 170 173 h = src_hopid; 171 174 ··· 201 198 path->hops[i].out_port = out_port; 202 199 path->hops[i].next_hop_index = next_hop; 203 200 201 + tb_dump_hop(&path->hops[i], &hop); 202 + 204 203 h = next_hop; 205 204 p = out_port->remote; 206 205 } 207 206 207 + tb_dbg(path->tb, "path discovery complete\n"); 208 208 return path; 209 209 210 210 err:
+90 -19
drivers/thunderbolt/switch.c
··· 693 693 else 694 694 phy |= LANE_ADP_CS_1_LD; 695 695 696 - return tb_port_write(port, &phy, TB_CFG_PORT, 697 - port->cap_phy + LANE_ADP_CS_1, 1); 696 + 697 + ret = tb_port_write(port, &phy, TB_CFG_PORT, 698 + port->cap_phy + LANE_ADP_CS_1, 1); 699 + if (ret) 700 + return ret; 701 + 702 + tb_port_dbg(port, "lane %sabled\n", enable ? "en" : "dis"); 703 + return 0; 698 704 } 699 705 700 706 /** ··· 999 993 return !!(widths & width); 1000 994 } 1001 995 1002 - static int tb_port_set_link_width(struct tb_port *port, unsigned int width) 996 + /** 997 + * tb_port_set_link_width() - Set target link width of the lane adapter 998 + * @port: Lane adapter 999 + * @width: Target link width (%1 or %2) 1000 + * 1001 + * Sets the target link width of the lane adapter to @width. Does not 1002 + * enable/disable lane bonding. For that call tb_port_set_lane_bonding(). 1003 + * 1004 + * Return: %0 in case of success and negative errno in case of error 1005 + */ 1006 + int tb_port_set_link_width(struct tb_port *port, unsigned int width) 1003 1007 { 1004 1008 u32 val; 1005 1009 int ret; ··· 1036 1020 return -EINVAL; 1037 1021 } 1038 1022 1039 - val |= LANE_ADP_CS_1_LB; 1040 - 1041 1023 return tb_port_write(port, &val, TB_CFG_PORT, 1042 1024 port->cap_phy + LANE_ADP_CS_1, 1); 1025 + } 1026 + 1027 + /** 1028 + * tb_port_set_lane_bonding() - Enable/disable lane bonding 1029 + * @port: Lane adapter 1030 + * @bonding: enable/disable bonding 1031 + * 1032 + * Enables or disables lane bonding. This should be called after target 1033 + * link width has been set (tb_port_set_link_width()). Note in most 1034 + * cases one should use tb_port_lane_bonding_enable() instead to enable 1035 + * lane bonding. 1036 + * 1037 + * As a side effect sets @port->bonding accordingly (and does the same 1038 + * for lane 1 too). 1039 + * 1040 + * Return: %0 in case of success and negative errno in case of error 1041 + */ 1042 + int tb_port_set_lane_bonding(struct tb_port *port, bool bonding) 1043 + { 1044 + u32 val; 1045 + int ret; 1046 + 1047 + if (!port->cap_phy) 1048 + return -EINVAL; 1049 + 1050 + ret = tb_port_read(port, &val, TB_CFG_PORT, 1051 + port->cap_phy + LANE_ADP_CS_1, 1); 1052 + if (ret) 1053 + return ret; 1054 + 1055 + if (bonding) 1056 + val |= LANE_ADP_CS_1_LB; 1057 + else 1058 + val &= ~LANE_ADP_CS_1_LB; 1059 + 1060 + ret = tb_port_write(port, &val, TB_CFG_PORT, 1061 + port->cap_phy + LANE_ADP_CS_1, 1); 1062 + if (ret) 1063 + return ret; 1064 + 1065 + /* 1066 + * When lane 0 bonding is set it will affect lane 1 too so 1067 + * update both. 1068 + */ 1069 + port->bonded = bonding; 1070 + port->dual_link_port->bonded = bonding; 1071 + 1072 + return 0; 1043 1073 } 1044 1074 1045 1075 /** ··· 1112 1050 if (ret == 1) { 1113 1051 ret = tb_port_set_link_width(port, 2); 1114 1052 if (ret) 1115 - return ret; 1053 + goto err_lane0; 1116 1054 } 1117 1055 1118 1056 ret = tb_port_get_link_width(port->dual_link_port); 1119 1057 if (ret == 1) { 1120 1058 ret = tb_port_set_link_width(port->dual_link_port, 2); 1121 - if (ret) { 1122 - tb_port_set_link_width(port, 1); 1123 - return ret; 1124 - } 1059 + if (ret) 1060 + goto err_lane0; 1125 1061 } 1126 1062 1127 - port->bonded = true; 1128 - port->dual_link_port->bonded = true; 1063 + ret = tb_port_set_lane_bonding(port, true); 1064 + if (ret) 1065 + goto err_lane1; 1129 1066 1130 1067 return 0; 1068 + 1069 + err_lane1: 1070 + tb_port_set_link_width(port->dual_link_port, 1); 1071 + err_lane0: 1072 + tb_port_set_link_width(port, 1); 1073 + return ret; 1131 1074 } 1132 1075 1133 1076 /** ··· 1141 1074 * 1142 1075 * Disable bonding by setting the link width of the port and the 1143 1076 * other port in case of dual link port. 1144 - * 1145 1077 */ 1146 1078 void tb_port_lane_bonding_disable(struct tb_port *port) 1147 1079 { 1148 - port->dual_link_port->bonded = false; 1149 - port->bonded = false; 1150 - 1080 + tb_port_set_lane_bonding(port, false); 1151 1081 tb_port_set_link_width(port->dual_link_port, 1); 1152 1082 tb_port_set_link_width(port, 1); 1153 1083 } ··· 1168 1104 1169 1105 do { 1170 1106 ret = tb_port_get_link_width(port); 1171 - if (ret < 0) 1172 - return ret; 1173 - else if (ret == width) 1107 + if (ret < 0) { 1108 + /* 1109 + * Sometimes we get port locked error when 1110 + * polling the lanes so we can ignore it and 1111 + * retry. 1112 + */ 1113 + if (ret != -EACCES) 1114 + return ret; 1115 + } else if (ret == width) { 1174 1116 return 0; 1117 + } 1175 1118 1176 1119 usleep_range(1000, 2000); 1177 1120 } while (ktime_before(ktime_get(), timeout));
+17 -8
drivers/thunderbolt/tb.c
··· 169 169 170 170 static int tb_port_configure_xdomain(struct tb_port *port) 171 171 { 172 - /* 173 - * XDomain paths currently only support single lane so we must 174 - * disable the other lane according to USB4 spec. 175 - */ 176 - tb_port_disable(port->dual_link_port); 177 - 178 172 if (tb_switch_is_usb4(port->sw)) 179 173 return usb4_port_configure_xdomain(port); 180 174 return tb_lc_configure_xdomain(port); ··· 861 867 862 868 static void tb_tunnel_dp(struct tb *tb) 863 869 { 864 - int available_up, available_down, ret; 870 + int available_up, available_down, ret, link_nr; 865 871 struct tb_cm *tcm = tb_priv(tb); 866 872 struct tb_port *port, *in, *out; 867 873 struct tb_tunnel *tunnel; ··· 907 913 } 908 914 909 915 /* 916 + * This is only applicable to links that are not bonded (so 917 + * when Thunderbolt 1 hardware is involved somewhere in the 918 + * topology). For these try to share the DP bandwidth between 919 + * the two lanes. 920 + */ 921 + link_nr = 1; 922 + list_for_each_entry(tunnel, &tcm->tunnel_list, list) { 923 + if (tb_tunnel_is_dp(tunnel)) { 924 + link_nr = 0; 925 + break; 926 + } 927 + } 928 + 929 + /* 910 930 * DP stream needs the domain to be active so runtime resume 911 931 * both ends of the tunnel. 912 932 * ··· 951 943 tb_dbg(tb, "available bandwidth for new DP tunnel %u/%u Mb/s\n", 952 944 available_up, available_down); 953 945 954 - tunnel = tb_tunnel_alloc_dp(tb, in, out, available_up, available_down); 946 + tunnel = tb_tunnel_alloc_dp(tb, in, out, link_nr, available_up, 947 + available_down); 955 948 if (!tunnel) { 956 949 tb_port_dbg(out, "could not allocate DP tunnel\n"); 957 950 goto err_reclaim;
+4 -2
drivers/thunderbolt/tb.h
··· 674 674 #define __TB_PORT_PRINT(level, _port, fmt, arg...) \ 675 675 do { \ 676 676 const struct tb_port *__port = (_port); \ 677 - level(__port->sw->tb, "%llx:%x: " fmt, \ 677 + level(__port->sw->tb, "%llx:%u: " fmt, \ 678 678 tb_route(__port->sw), __port->port, ## arg); \ 679 679 } while (0) 680 680 #define tb_port_WARN(port, fmt, arg...) \ ··· 991 991 int tb_switch_xhci_connect(struct tb_switch *sw); 992 992 void tb_switch_xhci_disconnect(struct tb_switch *sw); 993 993 994 + int tb_port_state(struct tb_port *port); 994 995 int tb_wait_for_port(struct tb_port *port, bool wait_if_unplugged); 995 996 int tb_port_add_nfc_credits(struct tb_port *port, int credits); 996 997 int tb_port_clear_counter(struct tb_port *port, int counter); ··· 1024 1023 1025 1024 int tb_port_get_link_speed(struct tb_port *port); 1026 1025 int tb_port_get_link_width(struct tb_port *port); 1027 - int tb_port_state(struct tb_port *port); 1026 + int tb_port_set_link_width(struct tb_port *port, unsigned int width); 1027 + int tb_port_set_lane_bonding(struct tb_port *port, bool bonding); 1028 1028 int tb_port_lane_bonding_enable(struct tb_port *port); 1029 1029 void tb_port_lane_bonding_disable(struct tb_port *port); 1030 1030 int tb_port_wait_for_link_width(struct tb_port *port, int width,
+39
drivers/thunderbolt/tb_msgs.h
··· 527 527 PROPERTIES_CHANGED_RESPONSE, 528 528 ERROR_RESPONSE, 529 529 UUID_REQUEST = 12, 530 + LINK_STATE_STATUS_REQUEST = 15, 531 + LINK_STATE_STATUS_RESPONSE, 532 + LINK_STATE_CHANGE_REQUEST, 533 + LINK_STATE_CHANGE_RESPONSE, 530 534 }; 531 535 532 536 struct tb_xdp_header { ··· 542 538 struct tb_xdp_error_response { 543 539 struct tb_xdp_header hdr; 544 540 u32 error; 541 + }; 542 + 543 + struct tb_xdp_link_state_status { 544 + struct tb_xdp_header hdr; 545 + }; 546 + 547 + struct tb_xdp_link_state_status_response { 548 + union { 549 + struct tb_xdp_error_response err; 550 + struct { 551 + struct tb_xdp_header hdr; 552 + u32 status; 553 + u8 slw; 554 + u8 tlw; 555 + u8 sls; 556 + u8 tls; 557 + }; 558 + }; 559 + }; 560 + 561 + struct tb_xdp_link_state_change { 562 + struct tb_xdp_header hdr; 563 + u8 tlw; 564 + u8 tls; 565 + u16 reserved; 566 + }; 567 + 568 + struct tb_xdp_link_state_change_response { 569 + union { 570 + struct tb_xdp_error_response err; 571 + struct { 572 + struct tb_xdp_header hdr; 573 + u32 status; 574 + }; 575 + }; 545 576 }; 546 577 547 578 struct tb_xdp_uuid {
+5
drivers/thunderbolt/tb_regs.h
··· 311 311 312 312 /* Lane adapter registers */ 313 313 #define LANE_ADP_CS_0 0x00 314 + #define LANE_ADP_CS_0_SUPPORTED_SPEED_MASK GENMASK(19, 16) 315 + #define LANE_ADP_CS_0_SUPPORTED_SPEED_SHIFT 16 314 316 #define LANE_ADP_CS_0_SUPPORTED_WIDTH_MASK GENMASK(25, 20) 315 317 #define LANE_ADP_CS_0_SUPPORTED_WIDTH_SHIFT 20 318 + #define LANE_ADP_CS_0_SUPPORTED_WIDTH_DUAL 0x2 316 319 #define LANE_ADP_CS_0_CL0S_SUPPORT BIT(26) 317 320 #define LANE_ADP_CS_0_CL1_SUPPORT BIT(27) 318 321 #define LANE_ADP_CS_1 0x01 322 + #define LANE_ADP_CS_1_TARGET_SPEED_MASK GENMASK(3, 0) 323 + #define LANE_ADP_CS_1_TARGET_SPEED_GEN3 0xc 319 324 #define LANE_ADP_CS_1_TARGET_WIDTH_MASK GENMASK(9, 4) 320 325 #define LANE_ADP_CS_1_TARGET_WIDTH_SHIFT 4 321 326 #define LANE_ADP_CS_1_TARGET_WIDTH_SINGLE 0x1
+100 -8
drivers/thunderbolt/test.c
··· 341 341 return sw; 342 342 } 343 343 344 + static struct tb_switch *alloc_dev_without_dp(struct kunit *test, 345 + struct tb_switch *parent, 346 + u64 route, bool bonded) 347 + { 348 + struct tb_switch *sw; 349 + int i; 350 + 351 + sw = alloc_dev_default(test, parent, route, bonded); 352 + if (!sw) 353 + return NULL; 354 + /* 355 + * Device with: 356 + * 2x USB4 Adapters (adapters 1,2 and 3,4), 357 + * 1x PCIe Upstream (adapter 9), 358 + * 1x PCIe Downstream (adapter 10), 359 + * 1x USB3 Upstream (adapter 16), 360 + * 1x USB3 Downstream (adapter 17) 361 + */ 362 + for (i = 5; i <= 8; i++) 363 + sw->ports[i].disabled = true; 364 + 365 + for (i = 11; i <= 14; i++) 366 + sw->ports[i].disabled = true; 367 + 368 + sw->ports[13].cap_adap = 0; 369 + sw->ports[14].cap_adap = 0; 370 + 371 + for (i = 18; i <= 19; i++) 372 + sw->ports[i].disabled = true; 373 + 374 + sw->generation = 4; 375 + sw->credit_allocation = true; 376 + sw->max_usb3_credits = 109; 377 + sw->min_dp_aux_credits = 0; 378 + sw->min_dp_main_credits = 0; 379 + sw->max_pcie_credits = 30; 380 + sw->max_dma_credits = 1; 381 + 382 + return sw; 383 + } 384 + 344 385 static struct tb_switch *alloc_dev_usb4(struct kunit *test, 345 386 struct tb_switch *parent, 346 387 u64 route, bool bonded) ··· 1389 1348 in = &host->ports[5]; 1390 1349 out = &dev->ports[13]; 1391 1350 1392 - tunnel = tb_tunnel_alloc_dp(NULL, in, out, 0, 0); 1351 + tunnel = tb_tunnel_alloc_dp(NULL, in, out, 1, 0, 0); 1393 1352 KUNIT_ASSERT_NOT_NULL(test, tunnel); 1394 1353 KUNIT_EXPECT_EQ(test, tunnel->type, TB_TUNNEL_DP); 1395 1354 KUNIT_EXPECT_PTR_EQ(test, tunnel->src_port, in); ··· 1435 1394 in = &host->ports[5]; 1436 1395 out = &dev4->ports[14]; 1437 1396 1438 - tunnel = tb_tunnel_alloc_dp(NULL, in, out, 0, 0); 1397 + tunnel = tb_tunnel_alloc_dp(NULL, in, out, 1, 0, 0); 1439 1398 KUNIT_ASSERT_NOT_NULL(test, tunnel); 1440 1399 KUNIT_EXPECT_EQ(test, tunnel->type, TB_TUNNEL_DP); 1441 1400 KUNIT_EXPECT_PTR_EQ(test, tunnel->src_port, in); ··· 1485 1444 in = &dev2->ports[13]; 1486 1445 out = &dev5->ports[13]; 1487 1446 1488 - tunnel = tb_tunnel_alloc_dp(NULL, in, out, 0, 0); 1447 + tunnel = tb_tunnel_alloc_dp(NULL, in, out, 1, 0, 0); 1489 1448 KUNIT_ASSERT_NOT_NULL(test, tunnel); 1490 1449 KUNIT_EXPECT_EQ(test, tunnel->type, TB_TUNNEL_DP); 1491 1450 KUNIT_EXPECT_PTR_EQ(test, tunnel->src_port, in); ··· 1550 1509 in = &dev6->ports[13]; 1551 1510 out = &dev12->ports[13]; 1552 1511 1553 - tunnel = tb_tunnel_alloc_dp(NULL, in, out, 0, 0); 1512 + tunnel = tb_tunnel_alloc_dp(NULL, in, out, 1, 0, 0); 1554 1513 KUNIT_ASSERT_NOT_NULL(test, tunnel); 1555 1514 KUNIT_EXPECT_EQ(test, tunnel->type, TB_TUNNEL_DP); 1556 1515 KUNIT_EXPECT_PTR_EQ(test, tunnel->src_port, in); ··· 1668 1627 in = &dev2->ports[13]; 1669 1628 out = &dev5->ports[13]; 1670 1629 1671 - dp_tunnel = tb_tunnel_alloc_dp(NULL, in, out, 0, 0); 1630 + dp_tunnel = tb_tunnel_alloc_dp(NULL, in, out, 1, 0, 0); 1672 1631 KUNIT_ASSERT_NOT_NULL(test, dp_tunnel); 1673 1632 1674 1633 KUNIT_EXPECT_TRUE(test, tb_tunnel_port_on_path(dp_tunnel, in)); ··· 2037 1996 tb_tunnel_free(tunnel); 2038 1997 } 2039 1998 1999 + static void tb_test_credit_alloc_without_dp(struct kunit *test) 2000 + { 2001 + struct tb_switch *host, *dev; 2002 + struct tb_port *up, *down; 2003 + struct tb_tunnel *tunnel; 2004 + struct tb_path *path; 2005 + 2006 + host = alloc_host_usb4(test); 2007 + dev = alloc_dev_without_dp(test, host, 0x1, true); 2008 + 2009 + /* 2010 + * The device has no DP therefore baMinDPmain = baMinDPaux = 0 2011 + * 2012 + * Create PCIe path with buffers less than baMaxPCIe. 2013 + * 2014 + * For a device with buffers configurations: 2015 + * baMaxUSB3 = 109 2016 + * baMinDPaux = 0 2017 + * baMinDPmain = 0 2018 + * baMaxPCIe = 30 2019 + * baMaxHI = 1 2020 + * Remaining Buffers = Total - (CP + DP) = 120 - (2 + 0) = 118 2021 + * PCIe Credits = Max(6, Min(baMaxPCIe, Remaining Buffers - baMaxUSB3) 2022 + * = Max(6, Min(30, 9) = 9 2023 + */ 2024 + down = &host->ports[8]; 2025 + up = &dev->ports[9]; 2026 + tunnel = tb_tunnel_alloc_pci(NULL, up, down); 2027 + KUNIT_ASSERT_TRUE(test, tunnel != NULL); 2028 + KUNIT_ASSERT_EQ(test, tunnel->npaths, (size_t)2); 2029 + 2030 + /* PCIe downstream path */ 2031 + path = tunnel->paths[0]; 2032 + KUNIT_ASSERT_EQ(test, path->path_length, 2); 2033 + KUNIT_EXPECT_EQ(test, path->hops[0].nfc_credits, 0U); 2034 + KUNIT_EXPECT_EQ(test, path->hops[0].initial_credits, 7U); 2035 + KUNIT_EXPECT_EQ(test, path->hops[1].nfc_credits, 0U); 2036 + KUNIT_EXPECT_EQ(test, path->hops[1].initial_credits, 9U); 2037 + 2038 + /* PCIe upstream path */ 2039 + path = tunnel->paths[1]; 2040 + KUNIT_ASSERT_EQ(test, path->path_length, 2); 2041 + KUNIT_EXPECT_EQ(test, path->hops[0].nfc_credits, 0U); 2042 + KUNIT_EXPECT_EQ(test, path->hops[0].initial_credits, 7U); 2043 + KUNIT_EXPECT_EQ(test, path->hops[1].nfc_credits, 0U); 2044 + KUNIT_EXPECT_EQ(test, path->hops[1].initial_credits, 64U); 2045 + 2046 + tb_tunnel_free(tunnel); 2047 + } 2048 + 2040 2049 static void tb_test_credit_alloc_dp(struct kunit *test) 2041 2050 { 2042 2051 struct tb_switch *host, *dev; ··· 2100 2009 in = &host->ports[5]; 2101 2010 out = &dev->ports[14]; 2102 2011 2103 - tunnel = tb_tunnel_alloc_dp(NULL, in, out, 0, 0); 2012 + tunnel = tb_tunnel_alloc_dp(NULL, in, out, 1, 0, 0); 2104 2013 KUNIT_ASSERT_NOT_NULL(test, tunnel); 2105 2014 KUNIT_ASSERT_EQ(test, tunnel->npaths, (size_t)3); 2106 2015 ··· 2336 2245 2337 2246 in = &host->ports[5]; 2338 2247 out = &dev->ports[13]; 2339 - dp_tunnel1 = tb_tunnel_alloc_dp(NULL, in, out, 0, 0); 2248 + dp_tunnel1 = tb_tunnel_alloc_dp(NULL, in, out, 1, 0, 0); 2340 2249 KUNIT_ASSERT_NOT_NULL(test, dp_tunnel1); 2341 2250 KUNIT_ASSERT_EQ(test, dp_tunnel1->npaths, (size_t)3); 2342 2251 ··· 2373 2282 2374 2283 in = &host->ports[6]; 2375 2284 out = &dev->ports[14]; 2376 - dp_tunnel2 = tb_tunnel_alloc_dp(NULL, in, out, 0, 0); 2285 + dp_tunnel2 = tb_tunnel_alloc_dp(NULL, in, out, 1, 0, 0); 2377 2286 KUNIT_ASSERT_NOT_NULL(test, dp_tunnel2); 2378 2287 KUNIT_ASSERT_EQ(test, dp_tunnel2->npaths, (size_t)3); 2379 2288 ··· 2800 2709 KUNIT_CASE(tb_test_credit_alloc_legacy_not_bonded), 2801 2710 KUNIT_CASE(tb_test_credit_alloc_legacy_bonded), 2802 2711 KUNIT_CASE(tb_test_credit_alloc_pcie), 2712 + KUNIT_CASE(tb_test_credit_alloc_without_dp), 2803 2713 KUNIT_CASE(tb_test_credit_alloc_dp), 2804 2714 KUNIT_CASE(tb_test_credit_alloc_usb3), 2805 2715 KUNIT_CASE(tb_test_credit_alloc_dma),
+11 -7
drivers/thunderbolt/tunnel.c
··· 102 102 * Maximum number of DP streams possible through the 103 103 * lane adapter. 104 104 */ 105 - ndp = (credits - (usb3 + pcie + spare)) / 106 - (sw->min_dp_aux_credits + sw->min_dp_main_credits); 105 + if (sw->min_dp_aux_credits + sw->min_dp_main_credits) 106 + ndp = (credits - (usb3 + pcie + spare)) / 107 + (sw->min_dp_aux_credits + sw->min_dp_main_credits); 108 + else 109 + ndp = 0; 107 110 } else { 108 111 ndp = 0; 109 112 } ··· 861 858 * @tb: Pointer to the domain structure 862 859 * @in: DP in adapter port 863 860 * @out: DP out adapter port 861 + * @link_nr: Preferred lane adapter when the link is not bonded 864 862 * @max_up: Maximum available upstream bandwidth for the DP tunnel (%0 865 863 * if not limited) 866 864 * @max_down: Maximum available downstream bandwidth for the DP tunnel ··· 873 869 * Return: Returns a tb_tunnel on success or NULL on failure. 874 870 */ 875 871 struct tb_tunnel *tb_tunnel_alloc_dp(struct tb *tb, struct tb_port *in, 876 - struct tb_port *out, int max_up, 877 - int max_down) 872 + struct tb_port *out, int link_nr, 873 + int max_up, int max_down) 878 874 { 879 875 struct tb_tunnel *tunnel; 880 876 struct tb_path **paths; ··· 898 894 paths = tunnel->paths; 899 895 900 896 path = tb_path_alloc(tb, in, TB_DP_VIDEO_HOPID, out, TB_DP_VIDEO_HOPID, 901 - 1, "Video"); 897 + link_nr, "Video"); 902 898 if (!path) 903 899 goto err_free; 904 900 tb_dp_init_video_path(path); 905 901 paths[TB_DP_VIDEO_PATH_OUT] = path; 906 902 907 903 path = tb_path_alloc(tb, in, TB_DP_AUX_TX_HOPID, out, 908 - TB_DP_AUX_TX_HOPID, 1, "AUX TX"); 904 + TB_DP_AUX_TX_HOPID, link_nr, "AUX TX"); 909 905 if (!path) 910 906 goto err_free; 911 907 tb_dp_init_aux_path(path); 912 908 paths[TB_DP_AUX_PATH_OUT] = path; 913 909 914 910 path = tb_path_alloc(tb, out, TB_DP_AUX_RX_HOPID, in, 915 - TB_DP_AUX_RX_HOPID, 1, "AUX RX"); 911 + TB_DP_AUX_RX_HOPID, link_nr, "AUX RX"); 916 912 if (!path) 917 913 goto err_free; 918 914 tb_dp_init_aux_path(path);
+2 -2
drivers/thunderbolt/tunnel.h
··· 71 71 struct tb_tunnel *tb_tunnel_discover_dp(struct tb *tb, struct tb_port *in, 72 72 bool alloc_hopid); 73 73 struct tb_tunnel *tb_tunnel_alloc_dp(struct tb *tb, struct tb_port *in, 74 - struct tb_port *out, int max_up, 75 - int max_down); 74 + struct tb_port *out, int link_nr, 75 + int max_up, int max_down); 76 76 struct tb_tunnel *tb_tunnel_alloc_dma(struct tb *tb, struct tb_port *nhi, 77 77 struct tb_port *dst, int transmit_path, 78 78 int transmit_ring, int receive_path,
+38
drivers/thunderbolt/usb4_port.c
··· 7 7 */ 8 8 9 9 #include <linux/pm_runtime.h> 10 + #include <linux/component.h> 11 + #include <linux/property.h> 10 12 11 13 #include "tb.h" 14 + 15 + static int connector_bind(struct device *dev, struct device *connector, void *data) 16 + { 17 + int ret; 18 + 19 + ret = sysfs_create_link(&dev->kobj, &connector->kobj, "connector"); 20 + if (ret) 21 + return ret; 22 + 23 + ret = sysfs_create_link(&connector->kobj, &dev->kobj, dev_name(dev)); 24 + if (ret) 25 + sysfs_remove_link(&dev->kobj, "connector"); 26 + 27 + return ret; 28 + } 29 + 30 + static void connector_unbind(struct device *dev, struct device *connector, void *data) 31 + { 32 + sysfs_remove_link(&connector->kobj, dev_name(dev)); 33 + sysfs_remove_link(&dev->kobj, "connector"); 34 + } 35 + 36 + static const struct component_ops connector_ops = { 37 + .bind = connector_bind, 38 + .unbind = connector_unbind, 39 + }; 12 40 13 41 static ssize_t link_show(struct device *dev, struct device_attribute *attr, 14 42 char *buf) ··· 274 246 return ERR_PTR(ret); 275 247 } 276 248 249 + if (dev_fwnode(&usb4->dev)) { 250 + ret = component_add(&usb4->dev, &connector_ops); 251 + if (ret) { 252 + dev_err(&usb4->dev, "failed to add component\n"); 253 + device_unregister(&usb4->dev); 254 + } 255 + } 256 + 277 257 pm_runtime_no_callbacks(&usb4->dev); 278 258 pm_runtime_set_active(&usb4->dev); 279 259 pm_runtime_enable(&usb4->dev); ··· 301 265 */ 302 266 void usb4_port_device_remove(struct usb4_port *usb4) 303 267 { 268 + if (dev_fwnode(&usb4->dev)) 269 + component_del(&usb4->dev, &connector_ops); 304 270 device_unregister(&usb4->dev); 305 271 } 306 272
+541 -68
drivers/thunderbolt/xdomain.c
··· 19 19 20 20 #include "tb.h" 21 21 22 - #define XDOMAIN_DEFAULT_TIMEOUT 1000 /* ms */ 23 - #define XDOMAIN_UUID_RETRIES 10 24 - #define XDOMAIN_PROPERTIES_RETRIES 10 25 - #define XDOMAIN_PROPERTIES_CHANGED_RETRIES 10 26 - #define XDOMAIN_BONDING_WAIT 100 /* ms */ 22 + #define XDOMAIN_SHORT_TIMEOUT 100 /* ms */ 23 + #define XDOMAIN_DEFAULT_TIMEOUT 1000 /* ms */ 24 + #define XDOMAIN_BONDING_TIMEOUT 10000 /* ms */ 25 + #define XDOMAIN_RETRIES 10 27 26 #define XDOMAIN_DEFAULT_MAX_HOPID 15 27 + 28 + enum { 29 + XDOMAIN_STATE_INIT, 30 + XDOMAIN_STATE_UUID, 31 + XDOMAIN_STATE_LINK_STATUS, 32 + XDOMAIN_STATE_LINK_STATE_CHANGE, 33 + XDOMAIN_STATE_LINK_STATUS2, 34 + XDOMAIN_STATE_BONDING_UUID_LOW, 35 + XDOMAIN_STATE_BONDING_UUID_HIGH, 36 + XDOMAIN_STATE_PROPERTIES, 37 + XDOMAIN_STATE_ENUMERATED, 38 + XDOMAIN_STATE_ERROR, 39 + }; 40 + 41 + static const char * const state_names[] = { 42 + [XDOMAIN_STATE_INIT] = "INIT", 43 + [XDOMAIN_STATE_UUID] = "UUID", 44 + [XDOMAIN_STATE_LINK_STATUS] = "LINK_STATUS", 45 + [XDOMAIN_STATE_LINK_STATE_CHANGE] = "LINK_STATE_CHANGE", 46 + [XDOMAIN_STATE_LINK_STATUS2] = "LINK_STATUS2", 47 + [XDOMAIN_STATE_BONDING_UUID_LOW] = "BONDING_UUID_LOW", 48 + [XDOMAIN_STATE_BONDING_UUID_HIGH] = "BONDING_UUID_HIGH", 49 + [XDOMAIN_STATE_PROPERTIES] = "PROPERTIES", 50 + [XDOMAIN_STATE_ENUMERATED] = "ENUMERATED", 51 + [XDOMAIN_STATE_ERROR] = "ERROR", 52 + }; 28 53 29 54 struct xdomain_request_work { 30 55 struct work_struct work; ··· 260 235 } 261 236 262 237 static int tb_xdp_uuid_request(struct tb_ctl *ctl, u64 route, int retry, 263 - uuid_t *uuid) 238 + uuid_t *uuid, u64 *remote_route) 264 239 { 265 240 struct tb_xdp_uuid_response res; 266 241 struct tb_xdp_uuid req; ··· 283 258 return ret; 284 259 285 260 uuid_copy(uuid, &res.src_uuid); 261 + *remote_route = (u64)res.src_route_hi << 32 | res.src_route_lo; 262 + 286 263 return 0; 287 264 } 288 265 ··· 500 473 TB_CFG_PKG_XDOMAIN_RESP); 501 474 } 502 475 476 + static int tb_xdp_link_state_status_request(struct tb_ctl *ctl, u64 route, 477 + u8 sequence, u8 *slw, u8 *tlw, 478 + u8 *sls, u8 *tls) 479 + { 480 + struct tb_xdp_link_state_status_response res; 481 + struct tb_xdp_link_state_status req; 482 + int ret; 483 + 484 + memset(&req, 0, sizeof(req)); 485 + tb_xdp_fill_header(&req.hdr, route, sequence, LINK_STATE_STATUS_REQUEST, 486 + sizeof(req)); 487 + 488 + memset(&res, 0, sizeof(res)); 489 + ret = __tb_xdomain_request(ctl, &req, sizeof(req), TB_CFG_PKG_XDOMAIN_REQ, 490 + &res, sizeof(res), TB_CFG_PKG_XDOMAIN_RESP, 491 + XDOMAIN_DEFAULT_TIMEOUT); 492 + if (ret) 493 + return ret; 494 + 495 + ret = tb_xdp_handle_error(&res.err); 496 + if (ret) 497 + return ret; 498 + 499 + if (res.status != 0) 500 + return -EREMOTEIO; 501 + 502 + *slw = res.slw; 503 + *tlw = res.tlw; 504 + *sls = res.sls; 505 + *tls = res.tls; 506 + 507 + return 0; 508 + } 509 + 510 + static int tb_xdp_link_state_status_response(struct tb *tb, struct tb_ctl *ctl, 511 + struct tb_xdomain *xd, u8 sequence) 512 + { 513 + struct tb_switch *sw = tb_to_switch(xd->dev.parent); 514 + struct tb_xdp_link_state_status_response res; 515 + struct tb_port *port = tb_port_at(xd->route, sw); 516 + u32 val[2]; 517 + int ret; 518 + 519 + memset(&res, 0, sizeof(res)); 520 + tb_xdp_fill_header(&res.hdr, xd->route, sequence, 521 + LINK_STATE_STATUS_RESPONSE, sizeof(res)); 522 + 523 + ret = tb_port_read(port, val, TB_CFG_PORT, 524 + port->cap_phy + LANE_ADP_CS_0, ARRAY_SIZE(val)); 525 + if (ret) 526 + return ret; 527 + 528 + res.slw = (val[0] & LANE_ADP_CS_0_SUPPORTED_WIDTH_MASK) >> 529 + LANE_ADP_CS_0_SUPPORTED_WIDTH_SHIFT; 530 + res.sls = (val[0] & LANE_ADP_CS_0_SUPPORTED_SPEED_MASK) >> 531 + LANE_ADP_CS_0_SUPPORTED_SPEED_SHIFT; 532 + res.tls = val[1] & LANE_ADP_CS_1_TARGET_SPEED_MASK; 533 + res.tlw = (val[1] & LANE_ADP_CS_1_TARGET_WIDTH_MASK) >> 534 + LANE_ADP_CS_1_TARGET_WIDTH_SHIFT; 535 + 536 + return __tb_xdomain_response(ctl, &res, sizeof(res), 537 + TB_CFG_PKG_XDOMAIN_RESP); 538 + } 539 + 540 + static int tb_xdp_link_state_change_request(struct tb_ctl *ctl, u64 route, 541 + u8 sequence, u8 tlw, u8 tls) 542 + { 543 + struct tb_xdp_link_state_change_response res; 544 + struct tb_xdp_link_state_change req; 545 + int ret; 546 + 547 + memset(&req, 0, sizeof(req)); 548 + tb_xdp_fill_header(&req.hdr, route, sequence, LINK_STATE_CHANGE_REQUEST, 549 + sizeof(req)); 550 + req.tlw = tlw; 551 + req.tls = tls; 552 + 553 + memset(&res, 0, sizeof(res)); 554 + ret = __tb_xdomain_request(ctl, &req, sizeof(req), TB_CFG_PKG_XDOMAIN_REQ, 555 + &res, sizeof(res), TB_CFG_PKG_XDOMAIN_RESP, 556 + XDOMAIN_DEFAULT_TIMEOUT); 557 + if (ret) 558 + return ret; 559 + 560 + ret = tb_xdp_handle_error(&res.err); 561 + if (ret) 562 + return ret; 563 + 564 + return res.status != 0 ? -EREMOTEIO : 0; 565 + } 566 + 567 + static int tb_xdp_link_state_change_response(struct tb_ctl *ctl, u64 route, 568 + u8 sequence, u32 status) 569 + { 570 + struct tb_xdp_link_state_change_response res; 571 + 572 + memset(&res, 0, sizeof(res)); 573 + tb_xdp_fill_header(&res.hdr, route, sequence, LINK_STATE_CHANGE_RESPONSE, 574 + sizeof(res)); 575 + 576 + res.status = status; 577 + 578 + return __tb_xdomain_response(ctl, &res, sizeof(res), 579 + TB_CFG_PKG_XDOMAIN_RESP); 580 + } 581 + 503 582 /** 504 583 * tb_register_protocol_handler() - Register protocol handler 505 584 * @handler: Handler to register ··· 733 600 goto out; 734 601 } 735 602 736 - tb_dbg(tb, "%llx: received XDomain request %#x\n", route, pkg->type); 737 - 738 603 xd = tb_xdomain_find_by_route_locked(tb, route); 739 604 if (xd) 740 605 update_property_block(xd); 741 606 742 607 switch (pkg->type) { 743 608 case PROPERTIES_REQUEST: 609 + tb_dbg(tb, "%llx: received XDomain properties request\n", route); 744 610 if (xd) { 745 611 ret = tb_xdp_properties_response(tb, ctl, xd, sequence, 746 612 (const struct tb_xdp_properties *)pkg); ··· 747 615 break; 748 616 749 617 case PROPERTIES_CHANGED_REQUEST: 618 + tb_dbg(tb, "%llx: received XDomain properties changed request\n", 619 + route); 620 + 750 621 ret = tb_xdp_properties_changed_response(ctl, route, sequence); 751 622 752 623 /* ··· 757 622 * the xdomain related to this connection as well in 758 623 * case there is a change in services it offers. 759 624 */ 760 - if (xd && device_is_registered(&xd->dev)) { 761 - queue_delayed_work(tb->wq, &xd->get_properties_work, 762 - msecs_to_jiffies(50)); 763 - } 625 + if (xd && device_is_registered(&xd->dev)) 626 + queue_delayed_work(tb->wq, &xd->state_work, 627 + msecs_to_jiffies(XDOMAIN_SHORT_TIMEOUT)); 764 628 break; 765 629 766 630 case UUID_REQUEST_OLD: 767 631 case UUID_REQUEST: 632 + tb_dbg(tb, "%llx: received XDomain UUID request\n", route); 768 633 ret = tb_xdp_uuid_response(ctl, route, sequence, uuid); 769 634 break; 770 635 636 + case LINK_STATE_STATUS_REQUEST: 637 + tb_dbg(tb, "%llx: received XDomain link state status request\n", 638 + route); 639 + 640 + if (xd) { 641 + ret = tb_xdp_link_state_status_response(tb, ctl, xd, 642 + sequence); 643 + } else { 644 + tb_xdp_error_response(ctl, route, sequence, 645 + ERROR_NOT_READY); 646 + } 647 + break; 648 + 649 + case LINK_STATE_CHANGE_REQUEST: 650 + tb_dbg(tb, "%llx: received XDomain link state change request\n", 651 + route); 652 + 653 + if (xd && xd->state == XDOMAIN_STATE_BONDING_UUID_HIGH) { 654 + const struct tb_xdp_link_state_change *lsc = 655 + (const struct tb_xdp_link_state_change *)pkg; 656 + 657 + ret = tb_xdp_link_state_change_response(ctl, route, 658 + sequence, 0); 659 + xd->target_link_width = lsc->tlw; 660 + queue_delayed_work(tb->wq, &xd->state_work, 661 + msecs_to_jiffies(XDOMAIN_SHORT_TIMEOUT)); 662 + } else { 663 + tb_xdp_error_response(ctl, route, sequence, 664 + ERROR_NOT_READY); 665 + } 666 + break; 667 + 771 668 default: 669 + tb_dbg(tb, "%llx: unknown XDomain request %#x\n", route, pkg->type); 772 670 tb_xdp_error_response(ctl, route, sequence, 773 671 ERROR_NOT_SUPPORTED); 774 672 break; ··· 1168 1000 return 0; 1169 1001 } 1170 1002 1171 - static void tb_xdomain_get_uuid(struct work_struct *work) 1003 + static int tb_xdomain_get_uuid(struct tb_xdomain *xd) 1172 1004 { 1173 - struct tb_xdomain *xd = container_of(work, typeof(*xd), 1174 - get_uuid_work.work); 1175 1005 struct tb *tb = xd->tb; 1176 1006 uuid_t uuid; 1007 + u64 route; 1177 1008 int ret; 1178 1009 1179 1010 dev_dbg(&xd->dev, "requesting remote UUID\n"); 1180 1011 1181 - ret = tb_xdp_uuid_request(tb->ctl, xd->route, xd->uuid_retries, &uuid); 1012 + ret = tb_xdp_uuid_request(tb->ctl, xd->route, xd->state_retries, &uuid, 1013 + &route); 1182 1014 if (ret < 0) { 1183 - if (xd->uuid_retries-- > 0) { 1015 + if (xd->state_retries-- > 0) { 1184 1016 dev_dbg(&xd->dev, "failed to request UUID, retrying\n"); 1185 - queue_delayed_work(xd->tb->wq, &xd->get_uuid_work, 1186 - msecs_to_jiffies(100)); 1017 + return -EAGAIN; 1187 1018 } else { 1188 1019 dev_dbg(&xd->dev, "failed to read remote UUID\n"); 1189 1020 } 1190 - return; 1021 + return ret; 1191 1022 } 1192 1023 1193 1024 dev_dbg(&xd->dev, "got remote UUID %pUb\n", &uuid); 1194 1025 1195 - if (uuid_equal(&uuid, xd->local_uuid)) 1196 - dev_dbg(&xd->dev, "intra-domain loop detected\n"); 1026 + if (uuid_equal(&uuid, xd->local_uuid)) { 1027 + if (route == xd->route) 1028 + dev_dbg(&xd->dev, "loop back detected\n"); 1029 + else 1030 + dev_dbg(&xd->dev, "intra-domain loop detected\n"); 1031 + 1032 + /* Don't bond lanes automatically for loops */ 1033 + xd->bonding_possible = false; 1034 + } 1197 1035 1198 1036 /* 1199 1037 * If the UUID is different, there is another domain connected ··· 1209 1035 if (xd->remote_uuid && !uuid_equal(&uuid, xd->remote_uuid)) { 1210 1036 dev_dbg(&xd->dev, "remote UUID is different, unplugging\n"); 1211 1037 xd->is_unplugged = true; 1212 - return; 1038 + return -ENODEV; 1213 1039 } 1214 1040 1215 1041 /* First time fill in the missing UUID */ 1216 1042 if (!xd->remote_uuid) { 1217 1043 xd->remote_uuid = kmemdup(&uuid, sizeof(uuid_t), GFP_KERNEL); 1218 1044 if (!xd->remote_uuid) 1219 - return; 1045 + return -ENOMEM; 1220 1046 } 1221 1047 1222 - /* Now we can start the normal properties exchange */ 1223 - queue_delayed_work(xd->tb->wq, &xd->properties_changed_work, 1224 - msecs_to_jiffies(100)); 1225 - queue_delayed_work(xd->tb->wq, &xd->get_properties_work, 1226 - msecs_to_jiffies(1000)); 1048 + return 0; 1227 1049 } 1228 1050 1229 - static void tb_xdomain_get_properties(struct work_struct *work) 1051 + static int tb_xdomain_get_link_status(struct tb_xdomain *xd) 1230 1052 { 1231 - struct tb_xdomain *xd = container_of(work, typeof(*xd), 1232 - get_properties_work.work); 1053 + struct tb *tb = xd->tb; 1054 + u8 slw, tlw, sls, tls; 1055 + int ret; 1056 + 1057 + dev_dbg(&xd->dev, "sending link state status request to %pUb\n", 1058 + xd->remote_uuid); 1059 + 1060 + ret = tb_xdp_link_state_status_request(tb->ctl, xd->route, 1061 + xd->state_retries, &slw, &tlw, &sls, 1062 + &tls); 1063 + if (ret) { 1064 + if (ret != -EOPNOTSUPP && xd->state_retries-- > 0) { 1065 + dev_dbg(&xd->dev, 1066 + "failed to request remote link status, retrying\n"); 1067 + return -EAGAIN; 1068 + } 1069 + dev_dbg(&xd->dev, "failed to receive remote link status\n"); 1070 + return ret; 1071 + } 1072 + 1073 + dev_dbg(&xd->dev, "remote link supports width %#x speed %#x\n", slw, sls); 1074 + 1075 + if (slw < LANE_ADP_CS_0_SUPPORTED_WIDTH_DUAL) { 1076 + dev_dbg(&xd->dev, "remote adapter is single lane only\n"); 1077 + return -EOPNOTSUPP; 1078 + } 1079 + 1080 + return 0; 1081 + } 1082 + 1083 + static int tb_xdomain_link_state_change(struct tb_xdomain *xd, 1084 + unsigned int width) 1085 + { 1086 + struct tb_switch *sw = tb_to_switch(xd->dev.parent); 1087 + struct tb_port *port = tb_port_at(xd->route, sw); 1088 + struct tb *tb = xd->tb; 1089 + u8 tlw, tls; 1090 + u32 val; 1091 + int ret; 1092 + 1093 + if (width == 2) 1094 + tlw = LANE_ADP_CS_1_TARGET_WIDTH_DUAL; 1095 + else if (width == 1) 1096 + tlw = LANE_ADP_CS_1_TARGET_WIDTH_SINGLE; 1097 + else 1098 + return -EINVAL; 1099 + 1100 + /* Use the current target speed */ 1101 + ret = tb_port_read(port, &val, TB_CFG_PORT, port->cap_phy + LANE_ADP_CS_1, 1); 1102 + if (ret) 1103 + return ret; 1104 + tls = val & LANE_ADP_CS_1_TARGET_SPEED_MASK; 1105 + 1106 + dev_dbg(&xd->dev, "sending link state change request with width %#x speed %#x\n", 1107 + tlw, tls); 1108 + 1109 + ret = tb_xdp_link_state_change_request(tb->ctl, xd->route, 1110 + xd->state_retries, tlw, tls); 1111 + if (ret) { 1112 + if (ret != -EOPNOTSUPP && xd->state_retries-- > 0) { 1113 + dev_dbg(&xd->dev, 1114 + "failed to change remote link state, retrying\n"); 1115 + return -EAGAIN; 1116 + } 1117 + dev_err(&xd->dev, "failed request link state change, aborting\n"); 1118 + return ret; 1119 + } 1120 + 1121 + dev_dbg(&xd->dev, "received link state change response\n"); 1122 + return 0; 1123 + } 1124 + 1125 + static int tb_xdomain_bond_lanes_uuid_high(struct tb_xdomain *xd) 1126 + { 1127 + struct tb_port *port; 1128 + int ret, width; 1129 + 1130 + if (xd->target_link_width == LANE_ADP_CS_1_TARGET_WIDTH_SINGLE) { 1131 + width = 1; 1132 + } else if (xd->target_link_width == LANE_ADP_CS_1_TARGET_WIDTH_DUAL) { 1133 + width = 2; 1134 + } else { 1135 + if (xd->state_retries-- > 0) { 1136 + dev_dbg(&xd->dev, 1137 + "link state change request not received yet, retrying\n"); 1138 + return -EAGAIN; 1139 + } 1140 + dev_dbg(&xd->dev, "timeout waiting for link change request\n"); 1141 + return -ETIMEDOUT; 1142 + } 1143 + 1144 + port = tb_port_at(xd->route, tb_xdomain_parent(xd)); 1145 + 1146 + /* 1147 + * We can't use tb_xdomain_lane_bonding_enable() here because it 1148 + * is the other side that initiates lane bonding. So here we 1149 + * just set the width to both lane adapters and wait for the 1150 + * link to transition bonded. 1151 + */ 1152 + ret = tb_port_set_link_width(port->dual_link_port, width); 1153 + if (ret) { 1154 + tb_port_warn(port->dual_link_port, 1155 + "failed to set link width to %d\n", width); 1156 + return ret; 1157 + } 1158 + 1159 + ret = tb_port_set_link_width(port, width); 1160 + if (ret) { 1161 + tb_port_warn(port, "failed to set link width to %d\n", width); 1162 + return ret; 1163 + } 1164 + 1165 + ret = tb_port_wait_for_link_width(port, width, XDOMAIN_BONDING_TIMEOUT); 1166 + if (ret) { 1167 + dev_warn(&xd->dev, "error waiting for link width to become %d\n", 1168 + width); 1169 + return ret; 1170 + } 1171 + 1172 + port->bonded = width == 2; 1173 + port->dual_link_port->bonded = width == 2; 1174 + 1175 + tb_port_update_credits(port); 1176 + tb_xdomain_update_link_attributes(xd); 1177 + 1178 + dev_dbg(&xd->dev, "lane bonding %sabled\n", width == 2 ? "en" : "dis"); 1179 + return 0; 1180 + } 1181 + 1182 + static int tb_xdomain_get_properties(struct tb_xdomain *xd) 1183 + { 1233 1184 struct tb_property_dir *dir; 1234 1185 struct tb *tb = xd->tb; 1235 1186 bool update = false; ··· 1365 1066 dev_dbg(&xd->dev, "requesting remote properties\n"); 1366 1067 1367 1068 ret = tb_xdp_properties_request(tb->ctl, xd->route, xd->local_uuid, 1368 - xd->remote_uuid, xd->properties_retries, 1069 + xd->remote_uuid, xd->state_retries, 1369 1070 &block, &gen); 1370 1071 if (ret < 0) { 1371 - if (xd->properties_retries-- > 0) { 1072 + if (xd->state_retries-- > 0) { 1372 1073 dev_dbg(&xd->dev, 1373 1074 "failed to request remote properties, retrying\n"); 1374 - queue_delayed_work(xd->tb->wq, &xd->get_properties_work, 1375 - msecs_to_jiffies(1000)); 1075 + return -EAGAIN; 1376 1076 } else { 1377 1077 /* Give up now */ 1378 1078 dev_err(&xd->dev, 1379 1079 "failed read XDomain properties from %pUb\n", 1380 1080 xd->remote_uuid); 1381 1081 } 1382 - return; 1383 - } 1384 1082 1385 - xd->properties_retries = XDOMAIN_PROPERTIES_RETRIES; 1083 + return ret; 1084 + } 1386 1085 1387 1086 mutex_lock(&xd->lock); 1388 1087 1389 1088 /* Only accept newer generation properties */ 1390 - if (xd->remote_properties && gen <= xd->remote_property_block_gen) 1089 + if (xd->remote_properties && gen <= xd->remote_property_block_gen) { 1090 + ret = 0; 1391 1091 goto err_free_block; 1092 + } 1392 1093 1393 1094 dir = tb_property_parse_dir(block, ret); 1394 1095 if (!dir) { 1395 1096 dev_err(&xd->dev, "failed to parse XDomain properties\n"); 1097 + ret = -ENOMEM; 1396 1098 goto err_free_block; 1397 1099 } 1398 1100 ··· 1424 1124 * registered, we notify the userspace that it has changed. 1425 1125 */ 1426 1126 if (!update) { 1127 + struct tb_port *port; 1128 + 1129 + /* Now disable lane 1 if bonding was not enabled */ 1130 + port = tb_port_at(xd->route, tb_xdomain_parent(xd)); 1131 + if (!port->bonded) 1132 + tb_port_disable(port->dual_link_port); 1133 + 1427 1134 if (device_add(&xd->dev)) { 1428 1135 dev_err(&xd->dev, "failed to add XDomain device\n"); 1429 - return; 1136 + return -ENODEV; 1430 1137 } 1431 1138 dev_info(&xd->dev, "new host found, vendor=%#x device=%#x\n", 1432 1139 xd->vendor, xd->device); ··· 1445 1138 } 1446 1139 1447 1140 enumerate_services(xd); 1448 - return; 1141 + return 0; 1449 1142 1450 1143 err_free_dir: 1451 1144 tb_property_free_dir(dir); 1452 1145 err_free_block: 1453 1146 kfree(block); 1454 1147 mutex_unlock(&xd->lock); 1148 + 1149 + return ret; 1150 + } 1151 + 1152 + static void tb_xdomain_queue_uuid(struct tb_xdomain *xd) 1153 + { 1154 + xd->state = XDOMAIN_STATE_UUID; 1155 + xd->state_retries = XDOMAIN_RETRIES; 1156 + queue_delayed_work(xd->tb->wq, &xd->state_work, 1157 + msecs_to_jiffies(XDOMAIN_SHORT_TIMEOUT)); 1158 + } 1159 + 1160 + static void tb_xdomain_queue_link_status(struct tb_xdomain *xd) 1161 + { 1162 + xd->state = XDOMAIN_STATE_LINK_STATUS; 1163 + xd->state_retries = XDOMAIN_RETRIES; 1164 + queue_delayed_work(xd->tb->wq, &xd->state_work, 1165 + msecs_to_jiffies(XDOMAIN_DEFAULT_TIMEOUT)); 1166 + } 1167 + 1168 + static void tb_xdomain_queue_link_status2(struct tb_xdomain *xd) 1169 + { 1170 + xd->state = XDOMAIN_STATE_LINK_STATUS2; 1171 + xd->state_retries = XDOMAIN_RETRIES; 1172 + queue_delayed_work(xd->tb->wq, &xd->state_work, 1173 + msecs_to_jiffies(XDOMAIN_DEFAULT_TIMEOUT)); 1174 + } 1175 + 1176 + static void tb_xdomain_queue_bonding(struct tb_xdomain *xd) 1177 + { 1178 + if (memcmp(xd->local_uuid, xd->remote_uuid, UUID_SIZE) > 0) { 1179 + dev_dbg(&xd->dev, "we have higher UUID, other side bonds the lanes\n"); 1180 + xd->state = XDOMAIN_STATE_BONDING_UUID_HIGH; 1181 + } else { 1182 + dev_dbg(&xd->dev, "we have lower UUID, bonding lanes\n"); 1183 + xd->state = XDOMAIN_STATE_LINK_STATE_CHANGE; 1184 + } 1185 + 1186 + xd->state_retries = XDOMAIN_RETRIES; 1187 + queue_delayed_work(xd->tb->wq, &xd->state_work, 1188 + msecs_to_jiffies(XDOMAIN_DEFAULT_TIMEOUT)); 1189 + } 1190 + 1191 + static void tb_xdomain_queue_bonding_uuid_low(struct tb_xdomain *xd) 1192 + { 1193 + xd->state = XDOMAIN_STATE_BONDING_UUID_LOW; 1194 + xd->state_retries = XDOMAIN_RETRIES; 1195 + queue_delayed_work(xd->tb->wq, &xd->state_work, 1196 + msecs_to_jiffies(XDOMAIN_DEFAULT_TIMEOUT)); 1197 + } 1198 + 1199 + static void tb_xdomain_queue_properties(struct tb_xdomain *xd) 1200 + { 1201 + xd->state = XDOMAIN_STATE_PROPERTIES; 1202 + xd->state_retries = XDOMAIN_RETRIES; 1203 + queue_delayed_work(xd->tb->wq, &xd->state_work, 1204 + msecs_to_jiffies(XDOMAIN_DEFAULT_TIMEOUT)); 1205 + } 1206 + 1207 + static void tb_xdomain_queue_properties_changed(struct tb_xdomain *xd) 1208 + { 1209 + xd->properties_changed_retries = XDOMAIN_RETRIES; 1210 + queue_delayed_work(xd->tb->wq, &xd->properties_changed_work, 1211 + msecs_to_jiffies(XDOMAIN_SHORT_TIMEOUT)); 1212 + } 1213 + 1214 + static void tb_xdomain_state_work(struct work_struct *work) 1215 + { 1216 + struct tb_xdomain *xd = container_of(work, typeof(*xd), state_work.work); 1217 + int ret, state = xd->state; 1218 + 1219 + if (WARN_ON_ONCE(state < XDOMAIN_STATE_INIT || 1220 + state > XDOMAIN_STATE_ERROR)) 1221 + return; 1222 + 1223 + dev_dbg(&xd->dev, "running state %s\n", state_names[state]); 1224 + 1225 + switch (state) { 1226 + case XDOMAIN_STATE_INIT: 1227 + if (xd->needs_uuid) { 1228 + tb_xdomain_queue_uuid(xd); 1229 + } else { 1230 + tb_xdomain_queue_properties_changed(xd); 1231 + tb_xdomain_queue_properties(xd); 1232 + } 1233 + break; 1234 + 1235 + case XDOMAIN_STATE_UUID: 1236 + ret = tb_xdomain_get_uuid(xd); 1237 + if (ret) { 1238 + if (ret == -EAGAIN) 1239 + goto retry_state; 1240 + xd->state = XDOMAIN_STATE_ERROR; 1241 + } else { 1242 + tb_xdomain_queue_properties_changed(xd); 1243 + if (xd->bonding_possible) 1244 + tb_xdomain_queue_link_status(xd); 1245 + else 1246 + tb_xdomain_queue_properties(xd); 1247 + } 1248 + break; 1249 + 1250 + case XDOMAIN_STATE_LINK_STATUS: 1251 + ret = tb_xdomain_get_link_status(xd); 1252 + if (ret) { 1253 + if (ret == -EAGAIN) 1254 + goto retry_state; 1255 + 1256 + /* 1257 + * If any of the lane bonding states fail we skip 1258 + * bonding completely and try to continue from 1259 + * reading properties. 1260 + */ 1261 + tb_xdomain_queue_properties(xd); 1262 + } else { 1263 + tb_xdomain_queue_bonding(xd); 1264 + } 1265 + break; 1266 + 1267 + case XDOMAIN_STATE_LINK_STATE_CHANGE: 1268 + ret = tb_xdomain_link_state_change(xd, 2); 1269 + if (ret) { 1270 + if (ret == -EAGAIN) 1271 + goto retry_state; 1272 + tb_xdomain_queue_properties(xd); 1273 + } else { 1274 + tb_xdomain_queue_link_status2(xd); 1275 + } 1276 + break; 1277 + 1278 + case XDOMAIN_STATE_LINK_STATUS2: 1279 + ret = tb_xdomain_get_link_status(xd); 1280 + if (ret) { 1281 + if (ret == -EAGAIN) 1282 + goto retry_state; 1283 + tb_xdomain_queue_properties(xd); 1284 + } else { 1285 + tb_xdomain_queue_bonding_uuid_low(xd); 1286 + } 1287 + break; 1288 + 1289 + case XDOMAIN_STATE_BONDING_UUID_LOW: 1290 + tb_xdomain_lane_bonding_enable(xd); 1291 + tb_xdomain_queue_properties(xd); 1292 + break; 1293 + 1294 + case XDOMAIN_STATE_BONDING_UUID_HIGH: 1295 + if (tb_xdomain_bond_lanes_uuid_high(xd) == -EAGAIN) 1296 + goto retry_state; 1297 + tb_xdomain_queue_properties(xd); 1298 + break; 1299 + 1300 + case XDOMAIN_STATE_PROPERTIES: 1301 + ret = tb_xdomain_get_properties(xd); 1302 + if (ret) { 1303 + if (ret == -EAGAIN) 1304 + goto retry_state; 1305 + xd->state = XDOMAIN_STATE_ERROR; 1306 + } else { 1307 + xd->state = XDOMAIN_STATE_ENUMERATED; 1308 + } 1309 + break; 1310 + 1311 + case XDOMAIN_STATE_ENUMERATED: 1312 + tb_xdomain_queue_properties(xd); 1313 + break; 1314 + 1315 + case XDOMAIN_STATE_ERROR: 1316 + break; 1317 + 1318 + default: 1319 + dev_warn(&xd->dev, "unexpected state %d\n", state); 1320 + break; 1321 + } 1322 + 1323 + return; 1324 + 1325 + retry_state: 1326 + queue_delayed_work(xd->tb->wq, &xd->state_work, 1327 + msecs_to_jiffies(XDOMAIN_DEFAULT_TIMEOUT)); 1455 1328 } 1456 1329 1457 1330 static void tb_xdomain_properties_changed(struct work_struct *work) ··· 1650 1163 "failed to send properties changed notification, retrying\n"); 1651 1164 queue_delayed_work(xd->tb->wq, 1652 1165 &xd->properties_changed_work, 1653 - msecs_to_jiffies(1000)); 1166 + msecs_to_jiffies(XDOMAIN_DEFAULT_TIMEOUT)); 1654 1167 } 1655 1168 dev_err(&xd->dev, "failed to send properties changed notification\n"); 1656 1169 return; 1657 1170 } 1658 1171 1659 - xd->properties_changed_retries = XDOMAIN_PROPERTIES_CHANGED_RETRIES; 1172 + xd->properties_changed_retries = XDOMAIN_RETRIES; 1660 1173 } 1661 1174 1662 1175 static ssize_t device_show(struct device *dev, struct device_attribute *attr, ··· 1791 1304 1792 1305 static void start_handshake(struct tb_xdomain *xd) 1793 1306 { 1794 - xd->uuid_retries = XDOMAIN_UUID_RETRIES; 1795 - xd->properties_retries = XDOMAIN_PROPERTIES_RETRIES; 1796 - xd->properties_changed_retries = XDOMAIN_PROPERTIES_CHANGED_RETRIES; 1797 - 1798 - if (xd->needs_uuid) { 1799 - queue_delayed_work(xd->tb->wq, &xd->get_uuid_work, 1800 - msecs_to_jiffies(100)); 1801 - } else { 1802 - /* Start exchanging properties with the other host */ 1803 - queue_delayed_work(xd->tb->wq, &xd->properties_changed_work, 1804 - msecs_to_jiffies(100)); 1805 - queue_delayed_work(xd->tb->wq, &xd->get_properties_work, 1806 - msecs_to_jiffies(1000)); 1807 - } 1307 + xd->state = XDOMAIN_STATE_INIT; 1308 + queue_delayed_work(xd->tb->wq, &xd->state_work, 1309 + msecs_to_jiffies(XDOMAIN_SHORT_TIMEOUT)); 1808 1310 } 1809 1311 1810 1312 static void stop_handshake(struct tb_xdomain *xd) 1811 1313 { 1812 - xd->uuid_retries = 0; 1813 - xd->properties_retries = 0; 1814 - xd->properties_changed_retries = 0; 1815 - 1816 - cancel_delayed_work_sync(&xd->get_uuid_work); 1817 - cancel_delayed_work_sync(&xd->get_properties_work); 1818 1314 cancel_delayed_work_sync(&xd->properties_changed_work); 1315 + cancel_delayed_work_sync(&xd->state_work); 1316 + xd->properties_changed_retries = 0; 1317 + xd->state_retries = 0; 1819 1318 } 1820 1319 1821 1320 static int __maybe_unused tb_xdomain_suspend(struct device *dev) ··· 1862 1389 ida_init(&xd->in_hopids); 1863 1390 ida_init(&xd->out_hopids); 1864 1391 mutex_init(&xd->lock); 1865 - INIT_DELAYED_WORK(&xd->get_uuid_work, tb_xdomain_get_uuid); 1866 - INIT_DELAYED_WORK(&xd->get_properties_work, tb_xdomain_get_properties); 1392 + INIT_DELAYED_WORK(&xd->state_work, tb_xdomain_state_work); 1867 1393 INIT_DELAYED_WORK(&xd->properties_changed_work, 1868 1394 tb_xdomain_properties_changed); 1869 1395 ··· 1877 1405 goto err_free_local_uuid; 1878 1406 } else { 1879 1407 xd->needs_uuid = true; 1408 + xd->bonding_possible = !!down->dual_link_port; 1880 1409 } 1881 1410 1882 1411 device_initialize(&xd->dev); ··· 1996 1523 return ret; 1997 1524 } 1998 1525 1999 - ret = tb_port_wait_for_link_width(port, 2, 100); 1526 + ret = tb_port_wait_for_link_width(port, 2, XDOMAIN_BONDING_TIMEOUT); 2000 1527 if (ret) { 2001 - tb_port_warn(port, "timeout enabling lane bonding\n"); 1528 + tb_port_warn(port, "failed to enable lane bonding\n"); 2002 1529 return ret; 2003 1530 } 2004 1531
+1 -1
drivers/usb/atm/usbatm.c
··· 1091 1091 snd_buf_bytes - (snd_buf_bytes % instance->tx_channel.stride)); 1092 1092 1093 1093 /* rx buffer size must be a positive multiple of the endpoint maxpacket */ 1094 - maxpacket = usb_maxpacket(usb_dev, instance->rx_channel.endpoint, 0); 1094 + maxpacket = usb_maxpacket(usb_dev, instance->rx_channel.endpoint); 1095 1095 1096 1096 if ((maxpacket < 1) || (maxpacket > UDSL_MAX_BUF_SIZE)) { 1097 1097 dev_err(dev, "%s: invalid endpoint %02x!\n", __func__,
+2 -4
drivers/usb/c67x00/c67x00-drv.c
··· 189 189 c67x00_ll_release(c67x00); 190 190 191 191 res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); 192 - if (res) 193 - free_irq(res->start, c67x00); 192 + free_irq(res->start, c67x00); 194 193 195 194 iounmap(c67x00->hpi.base); 196 195 197 196 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 198 - if (res) 199 - release_mem_region(res->start, resource_size(res)); 197 + release_mem_region(res->start, resource_size(res)); 200 198 201 199 kfree(c67x00); 202 200
+2 -2
drivers/usb/c67x00/c67x00-sched.c
··· 655 655 usb_pipeout(urb->pipe)); 656 656 remaining = urb->transfer_buffer_length - urb->actual_length; 657 657 658 - maxps = usb_maxpacket(urb->dev, urb->pipe, usb_pipeout(urb->pipe)); 658 + maxps = usb_maxpacket(urb->dev, urb->pipe); 659 659 660 660 need_empty = (urb->transfer_flags & URB_ZERO_PACKET) && 661 661 usb_pipeout(urb->pipe) && !(remaining % maxps); ··· 866 866 if (unlikely(!act_bytes)) 867 867 return 1; /* This was an empty packet */ 868 868 869 - maxps = usb_maxpacket(td_udev(td), td->pipe, usb_pipeout(td->pipe)); 869 + maxps = usb_maxpacket(td_udev(td), td->pipe); 870 870 871 871 if (unlikely(act_bytes < maxps)) 872 872 return 1; /* Smaller then full packet */
+43 -4
drivers/usb/cdns3/cdns3-gadget.c
··· 2038 2038 u8 mult = 0; 2039 2039 int ret; 2040 2040 2041 - buffering = CDNS3_EP_BUF_SIZE - 1; 2041 + buffering = priv_dev->ep_buf_size - 1; 2042 2042 2043 2043 cdns3_configure_dmult(priv_dev, priv_ep); 2044 2044 ··· 2057 2057 break; 2058 2058 default: 2059 2059 ep_cfg = EP_CFG_EPTYPE(USB_ENDPOINT_XFER_ISOC); 2060 - mult = CDNS3_EP_ISO_HS_MULT - 1; 2060 + mult = priv_dev->ep_iso_burst - 1; 2061 2061 buffering = mult + 1; 2062 2062 } 2063 2063 ··· 2073 2073 mult = 0; 2074 2074 max_packet_size = 1024; 2075 2075 if (priv_ep->type == USB_ENDPOINT_XFER_ISOC) { 2076 - maxburst = CDNS3_EP_ISO_SS_BURST - 1; 2076 + maxburst = priv_dev->ep_iso_burst - 1; 2077 2077 buffering = (mult + 1) * 2078 2078 (maxburst + 1); 2079 2079 2080 2080 if (priv_ep->interval > 1) 2081 2081 buffering++; 2082 2082 } else { 2083 - maxburst = CDNS3_EP_BUF_SIZE - 1; 2083 + maxburst = priv_dev->ep_buf_size - 1; 2084 2084 } 2085 2085 break; 2086 2086 default: ··· 2094 2094 priv_ep->trb_burst_size = 64; 2095 2095 else 2096 2096 priv_ep->trb_burst_size = 16; 2097 + 2098 + mult = min_t(u8, mult, EP_CFG_MULT_MAX); 2099 + buffering = min_t(u8, buffering, EP_CFG_BUFFERING_MAX); 2100 + maxburst = min_t(u8, maxburst, EP_CFG_MAXBURST_MAX); 2097 2101 2098 2102 /* onchip buffer is only allocated before configuration */ 2099 2103 if (!priv_dev->hw_configured_flag) { ··· 2965 2961 return 0; 2966 2962 } 2967 2963 2964 + /** 2965 + * cdns3_gadget_check_config - ensure cdns3 can support the USB configuration 2966 + * @gadget: pointer to the USB gadget 2967 + * 2968 + * Used to record the maximum number of endpoints being used in a USB composite 2969 + * device. (across all configurations) This is to be used in the calculation 2970 + * of the TXFIFO sizes when resizing internal memory for individual endpoints. 2971 + * It will help ensured that the resizing logic reserves enough space for at 2972 + * least one max packet. 2973 + */ 2974 + static int cdns3_gadget_check_config(struct usb_gadget *gadget) 2975 + { 2976 + struct cdns3_device *priv_dev = gadget_to_cdns3_device(gadget); 2977 + struct usb_ep *ep; 2978 + int n_in = 0; 2979 + int total; 2980 + 2981 + list_for_each_entry(ep, &gadget->ep_list, ep_list) { 2982 + if (ep->claimed && (ep->address & USB_DIR_IN)) 2983 + n_in++; 2984 + } 2985 + 2986 + /* 2KB are reserved for EP0, 1KB for out*/ 2987 + total = 2 + n_in + 1; 2988 + 2989 + if (total > priv_dev->onchip_buffers) 2990 + return -ENOMEM; 2991 + 2992 + priv_dev->ep_buf_size = priv_dev->ep_iso_burst = 2993 + (priv_dev->onchip_buffers - 2) / (n_in + 1); 2994 + 2995 + return 0; 2996 + } 2997 + 2968 2998 static const struct usb_gadget_ops cdns3_gadget_ops = { 2969 2999 .get_frame = cdns3_gadget_get_frame, 2970 3000 .wakeup = cdns3_gadget_wakeup, ··· 3007 2969 .udc_start = cdns3_gadget_udc_start, 3008 2970 .udc_stop = cdns3_gadget_udc_stop, 3009 2971 .match_ep = cdns3_gadget_match_ep, 2972 + .check_config = cdns3_gadget_check_config, 3010 2973 }; 3011 2974 3012 2975 static void cdns3_free_all_eps(struct cdns3_device *priv_dev)
+6 -3
drivers/usb/cdns3/cdns3-gadget.h
··· 562 562 /* Max burst size (used only in SS mode). */ 563 563 #define EP_CFG_MAXBURST_MASK GENMASK(11, 8) 564 564 #define EP_CFG_MAXBURST(p) (((p) << 8) & EP_CFG_MAXBURST_MASK) 565 + #define EP_CFG_MAXBURST_MAX 15 565 566 /* ISO max burst. */ 566 567 #define EP_CFG_MULT_MASK GENMASK(15, 14) 567 568 #define EP_CFG_MULT(p) (((p) << 14) & EP_CFG_MULT_MASK) 569 + #define EP_CFG_MULT_MAX 2 568 570 /* ISO max burst. */ 569 571 #define EP_CFG_MAXPKTSIZE_MASK GENMASK(26, 16) 570 572 #define EP_CFG_MAXPKTSIZE(p) (((p) << 16) & EP_CFG_MAXPKTSIZE_MASK) 571 573 /* Max number of buffered packets. */ 572 574 #define EP_CFG_BUFFERING_MASK GENMASK(31, 27) 573 575 #define EP_CFG_BUFFERING(p) (((p) << 27) & EP_CFG_BUFFERING_MASK) 576 + #define EP_CFG_BUFFERING_MAX 15 574 577 575 578 /* EP_CMD - bitmasks */ 576 579 /* Endpoint reset. */ ··· 1097 1094 #define CDNS3_ENDPOINTS_MAX_COUNT 32 1098 1095 #define CDNS3_EP_ZLP_BUF_SIZE 1024 1099 1096 1100 - #define CDNS3_EP_BUF_SIZE 4 /* KB */ 1101 - #define CDNS3_EP_ISO_HS_MULT 3 1102 - #define CDNS3_EP_ISO_SS_BURST 3 1103 1097 #define CDNS3_MAX_NUM_DESCMISS_BUF 32 1104 1098 #define CDNS3_DESCMIS_BUF_SIZE 2048 /* Bytes */ 1105 1099 #define CDNS3_WA2_NUM_BUFFERS 128 ··· 1333 1333 /*in KB */ 1334 1334 u16 onchip_buffers; 1335 1335 u16 onchip_used_size; 1336 + 1337 + u16 ep_buf_size; 1338 + u16 ep_iso_burst; 1336 1339 }; 1337 1340 1338 1341 void cdns3_set_register_bit(void __iomem *ptr, u32 mask);
-47
drivers/usb/core/devices.c
··· 228 228 229 229 start = usb_dump_interface_descriptor(start, end, intfc, iface, setno); 230 230 for (i = 0; i < desc->desc.bNumEndpoints; i++) { 231 - if (start > end) 232 - return start; 233 231 start = usb_dump_endpoint_descriptor(speed, 234 232 start, end, &desc->endpoint[i].desc); 235 233 } ··· 300 302 intfc = config->intf_cache[i]; 301 303 interface = config->interface[i]; 302 304 for (j = 0; j < intfc->num_altsetting; j++) { 303 - if (start > end) 304 - return start; 305 305 start = usb_dump_interface(speed, 306 306 start, end, intfc, interface, j); 307 307 } ··· 365 369 { 366 370 int i; 367 371 368 - if (start > end) 369 - return start; 370 - 371 372 start = usb_dump_device_descriptor(start, end, &dev->descriptor); 372 - 373 - if (start > end) 374 - return start; 375 373 376 374 start = usb_dump_device_strings(start, end, dev); 377 375 378 376 for (i = 0; i < dev->descriptor.bNumConfigurations; i++) { 379 - if (start > end) 380 - return start; 381 377 start = usb_dump_config(dev->speed, 382 378 start, end, dev->config + i, 383 379 /* active ? */ ··· 377 389 } 378 390 return start; 379 391 } 380 - 381 - 382 - #ifdef PROC_EXTRA /* TBD: may want to add this code later */ 383 - 384 - static char *usb_dump_hub_descriptor(char *start, char *end, 385 - const struct usb_hub_descriptor *desc) 386 - { 387 - int leng = USB_DT_HUB_NONVAR_SIZE; 388 - unsigned char *ptr = (unsigned char *)desc; 389 - 390 - if (start > end) 391 - return start; 392 - start += sprintf(start, "Interface:"); 393 - while (leng && start <= end) { 394 - start += sprintf(start, " %02x", *ptr); 395 - ptr++; leng--; 396 - } 397 - *start++ = '\n'; 398 - return start; 399 - } 400 - 401 - static char *usb_dump_string(char *start, char *end, 402 - const struct usb_device *dev, char *id, int index) 403 - { 404 - if (start > end) 405 - return start; 406 - start += sprintf(start, "Interface:"); 407 - if (index <= dev->maxstring && dev->stringindex && 408 - dev->stringindex[index]) 409 - start += sprintf(start, "%s: %.100s ", id, 410 - dev->stringindex[index]); 411 - return start; 412 - } 413 - 414 - #endif /* PROC_EXTRA */ 415 392 416 393 /*****************************************************************/ 417 394
+13 -12
drivers/usb/core/driver.c
··· 1533 1533 { 1534 1534 int w; 1535 1535 1536 - /* Remote wakeup is needed only when we actually go to sleep. 1537 - * For things like FREEZE and QUIESCE, if the device is already 1538 - * autosuspended then its current wakeup setting is okay. 1536 + /* 1537 + * For FREEZE/QUIESCE, disable remote wakeups so no interrupts get 1538 + * generated. 1539 1539 */ 1540 1540 if (msg.event == PM_EVENT_FREEZE || msg.event == PM_EVENT_QUIESCE) { 1541 - if (udev->state != USB_STATE_SUSPENDED) 1542 - udev->do_remote_wakeup = 0; 1543 - return; 1541 + w = 0; 1542 + 1543 + } else { 1544 + /* 1545 + * Enable remote wakeup if it is allowed, even if no interface 1546 + * drivers actually want it. 1547 + */ 1548 + w = device_may_wakeup(&udev->dev); 1544 1549 } 1545 1550 1546 - /* Enable remote wakeup if it is allowed, even if no interface drivers 1547 - * actually want it. 1548 - */ 1549 - w = device_may_wakeup(&udev->dev); 1550 - 1551 - /* If the device is autosuspended with the wrong wakeup setting, 1551 + /* 1552 + * If the device is autosuspended with the wrong wakeup setting, 1552 1553 * autoresume now so the setting can be changed. 1553 1554 */ 1554 1555 if (udev->state == USB_STATE_SUSPENDED && w != udev->do_remote_wakeup)
+2 -3
drivers/usb/core/hcd-pci.c
··· 15 15 #ifdef CONFIG_PPC_PMAC 16 16 #include <asm/machdep.h> 17 17 #include <asm/pmac_feature.h> 18 - #include <asm/prom.h> 19 18 #endif 20 19 21 20 #include "usb.h" ··· 615 616 .suspend_noirq = hcd_pci_suspend_noirq, 616 617 .resume_noirq = hcd_pci_resume_noirq, 617 618 .resume = hcd_pci_resume, 618 - .freeze = check_root_hub_suspended, 619 + .freeze = hcd_pci_suspend, 619 620 .freeze_noirq = check_root_hub_suspended, 620 621 .thaw_noirq = NULL, 621 - .thaw = NULL, 622 + .thaw = hcd_pci_resume, 622 623 .poweroff = hcd_pci_suspend, 623 624 .poweroff_noirq = hcd_pci_suspend_noirq, 624 625 .restore_noirq = hcd_pci_resume_noirq,
+24 -7
drivers/usb/core/hcd.c
··· 2816 2816 { 2817 2817 int retval; 2818 2818 struct usb_device *rhdev; 2819 + struct usb_hcd *shared_hcd; 2819 2820 2820 2821 if (!hcd->skip_phy_initialization && usb_hcd_is_primary_hcd(hcd)) { 2821 2822 hcd->phy_roothub = usb_phy_roothub_alloc(hcd->self.sysdev); ··· 2977 2976 goto err_hcd_driver_start; 2978 2977 } 2979 2978 2980 - /* starting here, usbcore will pay attention to this root hub */ 2981 - retval = register_root_hub(hcd); 2982 - if (retval != 0) 2983 - goto err_register_root_hub; 2979 + /* starting here, usbcore will pay attention to the shared HCD roothub */ 2980 + shared_hcd = hcd->shared_hcd; 2981 + if (!usb_hcd_is_primary_hcd(hcd) && shared_hcd && HCD_DEFER_RH_REGISTER(shared_hcd)) { 2982 + retval = register_root_hub(shared_hcd); 2983 + if (retval != 0) 2984 + goto err_register_root_hub; 2984 2985 2985 - if (hcd->uses_new_polling && HCD_POLL_RH(hcd)) 2986 - usb_hcd_poll_rh_status(hcd); 2986 + if (shared_hcd->uses_new_polling && HCD_POLL_RH(shared_hcd)) 2987 + usb_hcd_poll_rh_status(shared_hcd); 2988 + } 2989 + 2990 + /* starting here, usbcore will pay attention to this root hub */ 2991 + if (!HCD_DEFER_RH_REGISTER(hcd)) { 2992 + retval = register_root_hub(hcd); 2993 + if (retval != 0) 2994 + goto err_register_root_hub; 2995 + 2996 + if (hcd->uses_new_polling && HCD_POLL_RH(hcd)) 2997 + usb_hcd_poll_rh_status(hcd); 2998 + } 2987 2999 2988 3000 return retval; 2989 3001 ··· 3034 3020 void usb_remove_hcd(struct usb_hcd *hcd) 3035 3021 { 3036 3022 struct usb_device *rhdev = hcd->self.root_hub; 3023 + bool rh_registered; 3037 3024 3038 3025 dev_info(hcd->self.controller, "remove, state %x\n", hcd->state); 3039 3026 ··· 3045 3030 3046 3031 dev_dbg(hcd->self.controller, "roothub graceful disconnect\n"); 3047 3032 spin_lock_irq (&hcd_root_hub_lock); 3033 + rh_registered = hcd->rh_registered; 3048 3034 hcd->rh_registered = 0; 3049 3035 spin_unlock_irq (&hcd_root_hub_lock); 3050 3036 ··· 3055 3039 cancel_work_sync(&hcd->died_work); 3056 3040 3057 3041 mutex_lock(&usb_bus_idr_lock); 3058 - usb_disconnect(&rhdev); /* Sets rhdev to NULL */ 3042 + if (rh_registered) 3043 + usb_disconnect(&rhdev); /* Sets rhdev to NULL */ 3059 3044 mutex_unlock(&usb_bus_idr_lock); 3060 3045 3061 3046 /*
+4 -6
drivers/usb/core/hub.c
··· 1635 1635 * maxpktsize is defined in hcd.c's fake endpoint descriptors 1636 1636 * to be big enough for at least USB_MAXCHILDREN ports. */ 1637 1637 pipe = usb_rcvintpipe(hdev, endpoint->bEndpointAddress); 1638 - maxp = usb_maxpacket(hdev, pipe, usb_pipeout(pipe)); 1638 + maxp = usb_maxpacket(hdev, pipe); 1639 1639 1640 1640 if (maxp > sizeof(*hub->buffer)) 1641 1641 maxp = sizeof(*hub->buffer); ··· 5511 5511 /* Handle notifying userspace about hub over-current events */ 5512 5512 static void port_over_current_notify(struct usb_port *port_dev) 5513 5513 { 5514 - char *envp[3]; 5514 + char *envp[3] = { NULL, NULL, NULL }; 5515 5515 struct device *hub_dev; 5516 5516 char *port_dev_path; 5517 5517 ··· 5528 5528 5529 5529 envp[0] = kasprintf(GFP_KERNEL, "OVER_CURRENT_PORT=%s", port_dev_path); 5530 5530 if (!envp[0]) 5531 - goto exit_path; 5531 + goto exit; 5532 5532 5533 5533 envp[1] = kasprintf(GFP_KERNEL, "OVER_CURRENT_COUNT=%u", 5534 5534 port_dev->over_current_count); 5535 5535 if (!envp[1]) 5536 5536 goto exit; 5537 5537 5538 - envp[2] = NULL; 5539 5538 kobject_uevent_env(&hub_dev->kobj, KOBJ_CHANGE, envp); 5540 5539 5541 - kfree(envp[1]); 5542 5540 exit: 5541 + kfree(envp[1]); 5543 5542 kfree(envp[0]); 5544 - exit_path: 5545 5543 kfree(port_dev_path); 5546 5544 } 5547 5545
+3
drivers/usb/core/quirks.c
··· 510 510 /* DJI CineSSD */ 511 511 { USB_DEVICE(0x2ca3, 0x0031), .driver_info = USB_QUIRK_NO_LPM }, 512 512 513 + /* DELL USB GEN2 */ 514 + { USB_DEVICE(0x413c, 0xb062), .driver_info = USB_QUIRK_NO_LPM | USB_QUIRK_RESET_RESUME }, 515 + 513 516 /* VCOM device */ 514 517 { USB_DEVICE(0x4296, 0x7570), .driver_info = USB_QUIRK_CONFIG_INTF_STRINGS }, 515 518
+5 -2
drivers/usb/core/usb-acpi.c
··· 205 205 struct usb_hub *hub; 206 206 207 207 if (!udev->parent) { 208 - /* root hub is only child (_ADR=0) under its parent, the HC */ 209 - adev = ACPI_COMPANION(udev->dev.parent); 208 + /* 209 + * root hub is only child (_ADR=0) under its parent, the HC. 210 + * sysdev pointer is the HC as seen from firmware. 211 + */ 212 + adev = ACPI_COMPANION(udev->bus->sysdev); 210 213 return acpi_find_child_device(adev, 0, false); 211 214 } 212 215
+9
drivers/usb/dwc2/core.c
··· 1153 1153 int dwc2_phy_init(struct dwc2_hsotg *hsotg, bool select_phy) 1154 1154 { 1155 1155 u32 usbcfg; 1156 + u32 otgctl; 1156 1157 int retval = 0; 1157 1158 1158 1159 if ((hsotg->params.speed == DWC2_SPEED_PARAM_FULL || ··· 1186 1185 usbcfg &= ~GUSBCFG_ULPI_FS_LS; 1187 1186 usbcfg &= ~GUSBCFG_ULPI_CLK_SUSP_M; 1188 1187 dwc2_writel(hsotg, usbcfg, GUSBCFG); 1188 + } 1189 + 1190 + if (!hsotg->params.activate_ingenic_overcurrent_detection) { 1191 + if (dwc2_is_host_mode(hsotg)) { 1192 + otgctl = readl(hsotg->regs + GOTGCTL); 1193 + otgctl |= GOTGCTL_VBVALOEN | GOTGCTL_VBVALOVAL; 1194 + writel(otgctl, hsotg->regs + GOTGCTL); 1195 + } 1189 1196 } 1190 1197 1191 1198 return retval;
+5
drivers/usb/dwc2/core.h
··· 426 426 * detection using GGPIO register. 427 427 * 0 - Deactivate the external level detection (default) 428 428 * 1 - Activate the external level detection 429 + * @activate_ingenic_overcurrent_detection: Activate Ingenic overcurrent 430 + * detection. 431 + * 0 - Deactivate the overcurrent detection 432 + * 1 - Activate the overcurrent detection (default) 429 433 * @g_dma: Enables gadget dma usage (default: autodetect). 430 434 * @g_dma_desc: Enables gadget descriptor DMA (default: autodetect). 431 435 * @g_rx_fifo_size: The periodic rx fifo size for the device, in ··· 498 494 u8 hird_threshold; 499 495 bool activate_stm_fs_transceiver; 500 496 bool activate_stm_id_vb_detection; 497 + bool activate_ingenic_overcurrent_detection; 501 498 bool ipg_isoc_en; 502 499 u16 max_packet_count; 503 500 u32 max_transfer_size;
-1
drivers/usb/dwc2/gadget.c
··· 4544 4544 4545 4545 WARN_ON(hsotg->driver); 4546 4546 4547 - driver->driver.bus = NULL; 4548 4547 hsotg->driver = driver; 4549 4548 hsotg->gadget.dev.of_node = hsotg->dev->of_node; 4550 4549 hsotg->gadget.speed = USB_SPEED_UNKNOWN;
+49 -1
drivers/usb/dwc2/params.c
··· 73 73 p->power_down = DWC2_POWER_DOWN_PARAM_NONE; 74 74 } 75 75 76 + static void dwc2_set_jz4775_params(struct dwc2_hsotg *hsotg) 77 + { 78 + struct dwc2_core_params *p = &hsotg->params; 79 + 80 + p->otg_caps.hnp_support = false; 81 + p->speed = DWC2_SPEED_PARAM_HIGH; 82 + p->phy_type = DWC2_PHY_TYPE_PARAM_UTMI; 83 + p->phy_utmi_width = 16; 84 + p->activate_ingenic_overcurrent_detection = 85 + !device_property_read_bool(hsotg->dev, "disable-over-current"); 86 + } 87 + 88 + static void dwc2_set_x1600_params(struct dwc2_hsotg *hsotg) 89 + { 90 + struct dwc2_core_params *p = &hsotg->params; 91 + 92 + p->otg_caps.hnp_support = false; 93 + p->speed = DWC2_SPEED_PARAM_HIGH; 94 + p->host_channels = 16; 95 + p->phy_type = DWC2_PHY_TYPE_PARAM_UTMI; 96 + p->phy_utmi_width = 16; 97 + p->activate_ingenic_overcurrent_detection = 98 + !device_property_read_bool(hsotg->dev, "disable-over-current"); 99 + } 100 + 101 + static void dwc2_set_x2000_params(struct dwc2_hsotg *hsotg) 102 + { 103 + struct dwc2_core_params *p = &hsotg->params; 104 + 105 + p->otg_caps.hnp_support = false; 106 + p->speed = DWC2_SPEED_PARAM_HIGH; 107 + p->host_rx_fifo_size = 1024; 108 + p->host_nperio_tx_fifo_size = 1024; 109 + p->host_perio_tx_fifo_size = 1024; 110 + p->host_channels = 16; 111 + p->phy_type = DWC2_PHY_TYPE_PARAM_UTMI; 112 + p->phy_utmi_width = 16; 113 + p->activate_ingenic_overcurrent_detection = 114 + !device_property_read_bool(hsotg->dev, "disable-over-current"); 115 + } 116 + 76 117 static void dwc2_set_s3c6400_params(struct dwc2_hsotg *hsotg) 77 118 { 78 119 struct dwc2_core_params *p = &hsotg->params; ··· 262 221 263 222 const struct of_device_id dwc2_of_match_table[] = { 264 223 { .compatible = "brcm,bcm2835-usb", .data = dwc2_set_bcm_params }, 265 - { .compatible = "hisilicon,hi6220-usb", .data = dwc2_set_his_params }, 224 + { .compatible = "hisilicon,hi6220-usb", .data = dwc2_set_his_params }, 225 + { .compatible = "ingenic,jz4775-otg", .data = dwc2_set_jz4775_params }, 226 + { .compatible = "ingenic,jz4780-otg", .data = dwc2_set_jz4775_params }, 227 + { .compatible = "ingenic,x1000-otg", .data = dwc2_set_jz4775_params }, 228 + { .compatible = "ingenic,x1600-otg", .data = dwc2_set_x1600_params }, 229 + { .compatible = "ingenic,x1700-otg", .data = dwc2_set_x1600_params }, 230 + { .compatible = "ingenic,x1830-otg", .data = dwc2_set_x1600_params }, 231 + { .compatible = "ingenic,x2000-otg", .data = dwc2_set_x2000_params }, 266 232 { .compatible = "rockchip,rk3066-usb", .data = dwc2_set_rk_params }, 267 233 { .compatible = "lantiq,arx100-usb", .data = dwc2_set_ltq_params }, 268 234 { .compatible = "lantiq,xrx200-usb", .data = dwc2_set_ltq_params },
+9
drivers/usb/dwc3/Kconfig
··· 159 159 This driver handles both ZynqMP and Versal SoC operations. 160 160 Say 'Y' or 'M' if you have one such device. 161 161 162 + config USB_DWC3_AM62 163 + tristate "Texas Instruments AM62 Platforms" 164 + depends on ARCH_K3 || COMPILE_TEST 165 + default USB_DWC3 166 + help 167 + Support TI's AM62 platforms with DesignWare Core USB3 IP. 168 + The Designware Core USB3 IP is progammed to operate in 169 + in USB 2.0 mode only. 170 + Say 'Y' or 'M' here if you have one such device 162 171 endif
+1
drivers/usb/dwc3/Makefile
··· 42 42 # and allyesconfig builds. 43 43 ## 44 44 45 + obj-$(CONFIG_USB_DWC3_AM62) += dwc3-am62.o 45 46 obj-$(CONFIG_USB_DWC3_OMAP) += dwc3-omap.o 46 47 obj-$(CONFIG_USB_DWC3_EXYNOS) += dwc3-exynos.o 47 48 obj-$(CONFIG_USB_DWC3_PCI) += dwc3-pci.o
+64 -17
drivers/usb/dwc3/core.c
··· 23 23 #include <linux/delay.h> 24 24 #include <linux/dma-mapping.h> 25 25 #include <linux/of.h> 26 + #include <linux/of_graph.h> 26 27 #include <linux/acpi.h> 27 28 #include <linux/pinctrl/consumer.h> 28 29 #include <linux/reset.h> ··· 86 85 * mode. If the controller supports DRD but the dr_mode is not 87 86 * specified or set to OTG, then set the mode to peripheral. 88 87 */ 89 - if (mode == USB_DR_MODE_OTG && 88 + if (mode == USB_DR_MODE_OTG && !dwc->edev && 90 89 (!IS_ENABLED(CONFIG_USB_ROLE_SWITCH) || 91 90 !device_property_read_bool(dwc->dev, "usb-role-switch")) && 92 91 !DWC3_VER_IS_PRIOR(DWC3, 330A)) ··· 298 297 udelay(1); 299 298 } while (--retries); 300 299 300 + dev_warn(dwc->dev, "DWC3 controller soft reset failed.\n"); 301 301 return -ETIMEDOUT; 302 302 303 303 done: ··· 344 342 * from the default, this will set clock period in DWC3_GUCTL 345 343 * register. 346 344 * @dwc: Pointer to our controller context structure 347 - * @ref_clk_per: reference clock period in ns 348 345 */ 349 346 static void dwc3_ref_clk_period(struct dwc3 *dwc) 350 347 { ··· 965 964 return; 966 965 967 966 vals = kcalloc(ntype, sizeof(u32), GFP_KERNEL); 968 - if (!vals) { 969 - dev_err(dev, "Error to get memory\n"); 967 + if (!vals) 970 968 return; 971 - } 972 969 973 970 /* Get INCR burst type, and parse it */ 974 971 ret = device_property_read_u32_array(dev, ··· 1267 1268 1268 1269 if (IS_ERR(dwc->usb2_phy)) { 1269 1270 ret = PTR_ERR(dwc->usb2_phy); 1270 - if (ret == -ENXIO || ret == -ENODEV) { 1271 + if (ret == -ENXIO || ret == -ENODEV) 1271 1272 dwc->usb2_phy = NULL; 1272 - } else { 1273 + else 1273 1274 return dev_err_probe(dev, ret, "no usb2 phy configured\n"); 1274 - } 1275 1275 } 1276 1276 1277 1277 if (IS_ERR(dwc->usb3_phy)) { 1278 1278 ret = PTR_ERR(dwc->usb3_phy); 1279 - if (ret == -ENXIO || ret == -ENODEV) { 1279 + if (ret == -ENXIO || ret == -ENODEV) 1280 1280 dwc->usb3_phy = NULL; 1281 - } else { 1281 + else 1282 1282 return dev_err_probe(dev, ret, "no usb3 phy configured\n"); 1283 - } 1284 1283 } 1285 1284 1286 1285 dwc->usb2_generic_phy = devm_phy_get(dev, "usb2-phy"); 1287 1286 if (IS_ERR(dwc->usb2_generic_phy)) { 1288 1287 ret = PTR_ERR(dwc->usb2_generic_phy); 1289 - if (ret == -ENOSYS || ret == -ENODEV) { 1288 + if (ret == -ENOSYS || ret == -ENODEV) 1290 1289 dwc->usb2_generic_phy = NULL; 1291 - } else { 1290 + else 1292 1291 return dev_err_probe(dev, ret, "no usb2 phy configured\n"); 1293 - } 1294 1292 } 1295 1293 1296 1294 dwc->usb3_generic_phy = devm_phy_get(dev, "usb3-phy"); 1297 1295 if (IS_ERR(dwc->usb3_generic_phy)) { 1298 1296 ret = PTR_ERR(dwc->usb3_generic_phy); 1299 - if (ret == -ENOSYS || ret == -ENODEV) { 1297 + if (ret == -ENOSYS || ret == -ENODEV) 1300 1298 dwc->usb3_generic_phy = NULL; 1301 - } else { 1299 + else 1302 1300 return dev_err_probe(dev, ret, "no usb3 phy configured\n"); 1303 - } 1304 1301 } 1305 1302 1306 1303 return 0; ··· 1628 1633 } 1629 1634 } 1630 1635 1636 + static struct extcon_dev *dwc3_get_extcon(struct dwc3 *dwc) 1637 + { 1638 + struct device *dev = dwc->dev; 1639 + struct device_node *np_phy; 1640 + struct extcon_dev *edev = NULL; 1641 + const char *name; 1642 + 1643 + if (device_property_read_bool(dev, "extcon")) 1644 + return extcon_get_edev_by_phandle(dev, 0); 1645 + 1646 + /* 1647 + * Device tree platforms should get extcon via phandle. 1648 + * On ACPI platforms, we get the name from a device property. 1649 + * This device property is for kernel internal use only and 1650 + * is expected to be set by the glue code. 1651 + */ 1652 + if (device_property_read_string(dev, "linux,extcon-name", &name) == 0) { 1653 + edev = extcon_get_extcon_dev(name); 1654 + if (!edev) 1655 + return ERR_PTR(-EPROBE_DEFER); 1656 + 1657 + return edev; 1658 + } 1659 + 1660 + /* 1661 + * Try to get an extcon device from the USB PHY controller's "port" 1662 + * node. Check if it has the "port" node first, to avoid printing the 1663 + * error message from underlying code, as it's a valid case: extcon 1664 + * device (and "port" node) may be missing in case of "usb-role-switch" 1665 + * or OTG mode. 1666 + */ 1667 + np_phy = of_parse_phandle(dev->of_node, "phys", 0); 1668 + if (of_graph_is_present(np_phy)) { 1669 + struct device_node *np_conn; 1670 + 1671 + np_conn = of_graph_get_remote_node(np_phy, -1, -1); 1672 + if (np_conn) 1673 + edev = extcon_find_edev_by_node(np_conn); 1674 + of_node_put(np_conn); 1675 + } 1676 + of_node_put(np_phy); 1677 + 1678 + return edev; 1679 + } 1680 + 1631 1681 static int dwc3_probe(struct platform_device *pdev) 1632 1682 { 1633 1683 struct device *dev = &pdev->dev; ··· 1806 1766 dev_err(dwc->dev, "failed to allocate event buffers\n"); 1807 1767 ret = -ENOMEM; 1808 1768 goto err2; 1769 + } 1770 + 1771 + dwc->edev = dwc3_get_extcon(dwc); 1772 + if (IS_ERR(dwc->edev)) { 1773 + ret = PTR_ERR(dwc->edev); 1774 + dev_err_probe(dwc->dev, ret, "failed to get extcon\n"); 1775 + goto err3; 1809 1776 } 1810 1777 1811 1778 ret = dwc3_get_dr_mode(dwc);
+2
drivers/usb/dwc3/core.h
··· 1046 1046 * @tx_thr_num_pkt_prd: periodic ESS transmit packet count 1047 1047 * @tx_max_burst_prd: max periodic ESS transmit burst size 1048 1048 * @tx_fifo_resize_max_num: max number of fifos allocated during txfifo resize 1049 + * @clear_stall_protocol: endpoint number that requires a delayed status phase 1049 1050 * @hsphy_interface: "utmi" or "ulpi" 1050 1051 * @connected: true when we're connected to a host, false otherwise 1051 1052 * @softconnect: true when gadget connect is called, false when disconnect runs ··· 1267 1266 u8 tx_thr_num_pkt_prd; 1268 1267 u8 tx_max_burst_prd; 1269 1268 u8 tx_fifo_resize_max_num; 1269 + u8 clear_stall_protocol; 1270 1270 1271 1271 const char *hsphy_interface; 1272 1272
-50
drivers/usb/dwc3/drd.c
··· 8 8 */ 9 9 10 10 #include <linux/extcon.h> 11 - #include <linux/of_graph.h> 12 11 #include <linux/of_platform.h> 13 12 #include <linux/platform_device.h> 14 13 #include <linux/property.h> ··· 438 439 return NOTIFY_DONE; 439 440 } 440 441 441 - static struct extcon_dev *dwc3_get_extcon(struct dwc3 *dwc) 442 - { 443 - struct device *dev = dwc->dev; 444 - struct device_node *np_phy; 445 - struct extcon_dev *edev = NULL; 446 - const char *name; 447 - 448 - if (device_property_read_bool(dev, "extcon")) 449 - return extcon_get_edev_by_phandle(dev, 0); 450 - 451 - /* 452 - * Device tree platforms should get extcon via phandle. 453 - * On ACPI platforms, we get the name from a device property. 454 - * This device property is for kernel internal use only and 455 - * is expected to be set by the glue code. 456 - */ 457 - if (device_property_read_string(dev, "linux,extcon-name", &name) == 0) { 458 - edev = extcon_get_extcon_dev(name); 459 - if (!edev) 460 - return ERR_PTR(-EPROBE_DEFER); 461 - 462 - return edev; 463 - } 464 - 465 - /* 466 - * Try to get an extcon device from the USB PHY controller's "port" 467 - * node. Check if it has the "port" node first, to avoid printing the 468 - * error message from underlying code, as it's a valid case: extcon 469 - * device (and "port" node) may be missing in case of "usb-role-switch" 470 - * or OTG mode. 471 - */ 472 - np_phy = of_parse_phandle(dev->of_node, "phys", 0); 473 - if (of_graph_is_present(np_phy)) { 474 - struct device_node *np_conn; 475 - 476 - np_conn = of_graph_get_remote_node(np_phy, -1, -1); 477 - if (np_conn) 478 - edev = extcon_find_edev_by_node(np_conn); 479 - of_node_put(np_conn); 480 - } 481 - of_node_put(np_phy); 482 - 483 - return edev; 484 - } 485 - 486 442 #if IS_ENABLED(CONFIG_USB_ROLE_SWITCH) 487 443 #define ROLE_SWITCH 1 488 444 static int dwc3_usb_role_switch_set(struct usb_role_switch *sw, ··· 541 587 if (ROLE_SWITCH && 542 588 device_property_read_bool(dwc->dev, "usb-role-switch")) 543 589 return dwc3_setup_role_switch(dwc); 544 - 545 - dwc->edev = dwc3_get_extcon(dwc); 546 - if (IS_ERR(dwc->edev)) 547 - return PTR_ERR(dwc->edev); 548 590 549 591 if (dwc->edev) { 550 592 dwc->edev_nb.notifier_call = dwc3_drd_notifier;
+332
drivers/usb/dwc3/dwc3-am62.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + /* 3 + * dwc3-am62.c - TI specific Glue layer for AM62 DWC3 USB Controller 4 + * 5 + * Copyright (C) 2022 Texas Instruments Incorporated - https://www.ti.com 6 + */ 7 + 8 + #include <linux/init.h> 9 + #include <linux/kernel.h> 10 + #include <linux/module.h> 11 + #include <linux/platform_device.h> 12 + #include <linux/mfd/syscon.h> 13 + #include <linux/of.h> 14 + #include <linux/of_device.h> 15 + #include <linux/pm_runtime.h> 16 + #include <linux/clk.h> 17 + #include <linux/regmap.h> 18 + #include <linux/pinctrl/consumer.h> 19 + 20 + /* USB WRAPPER register offsets */ 21 + #define USBSS_PID 0x0 22 + #define USBSS_OVERCURRENT_CTRL 0x4 23 + #define USBSS_PHY_CONFIG 0x8 24 + #define USBSS_PHY_TEST 0xc 25 + #define USBSS_CORE_STAT 0x14 26 + #define USBSS_HOST_VBUS_CTRL 0x18 27 + #define USBSS_MODE_CONTROL 0x1c 28 + #define USBSS_WAKEUP_CONFIG 0x30 29 + #define USBSS_WAKEUP_STAT 0x34 30 + #define USBSS_OVERRIDE_CONFIG 0x38 31 + #define USBSS_IRQ_MISC_STATUS_RAW 0x430 32 + #define USBSS_IRQ_MISC_STATUS 0x434 33 + #define USBSS_IRQ_MISC_ENABLE_SET 0x438 34 + #define USBSS_IRQ_MISC_ENABLE_CLR 0x43c 35 + #define USBSS_IRQ_MISC_EOI 0x440 36 + #define USBSS_INTR_TEST 0x490 37 + #define USBSS_VBUS_FILTER 0x614 38 + #define USBSS_VBUS_STAT 0x618 39 + #define USBSS_DEBUG_CFG 0x708 40 + #define USBSS_DEBUG_DATA 0x70c 41 + #define USBSS_HOST_HUB_CTRL 0x714 42 + 43 + /* PHY CONFIG register bits */ 44 + #define USBSS_PHY_VBUS_SEL_MASK GENMASK(2, 1) 45 + #define USBSS_PHY_VBUS_SEL_SHIFT 1 46 + #define USBSS_PHY_LANE_REVERSE BIT(0) 47 + 48 + /* MODE CONTROL register bits */ 49 + #define USBSS_MODE_VALID BIT(0) 50 + 51 + /* WAKEUP CONFIG register bits */ 52 + #define USBSS_WAKEUP_CFG_OVERCURRENT_EN BIT(3) 53 + #define USBSS_WAKEUP_CFG_LINESTATE_EN BIT(2) 54 + #define USBSS_WAKEUP_CFG_SESSVALID_EN BIT(1) 55 + #define USBSS_WAKEUP_CFG_VBUSVALID_EN BIT(0) 56 + 57 + /* WAKEUP STAT register bits */ 58 + #define USBSS_WAKEUP_STAT_OVERCURRENT BIT(4) 59 + #define USBSS_WAKEUP_STAT_LINESTATE BIT(3) 60 + #define USBSS_WAKEUP_STAT_SESSVALID BIT(2) 61 + #define USBSS_WAKEUP_STAT_VBUSVALID BIT(1) 62 + #define USBSS_WAKEUP_STAT_CLR BIT(0) 63 + 64 + /* IRQ_MISC_STATUS_RAW register bits */ 65 + #define USBSS_IRQ_MISC_RAW_VBUSVALID BIT(22) 66 + #define USBSS_IRQ_MISC_RAW_SESSVALID BIT(20) 67 + 68 + /* IRQ_MISC_STATUS register bits */ 69 + #define USBSS_IRQ_MISC_VBUSVALID BIT(22) 70 + #define USBSS_IRQ_MISC_SESSVALID BIT(20) 71 + 72 + /* IRQ_MISC_ENABLE_SET register bits */ 73 + #define USBSS_IRQ_MISC_ENABLE_SET_VBUSVALID BIT(22) 74 + #define USBSS_IRQ_MISC_ENABLE_SET_SESSVALID BIT(20) 75 + 76 + /* IRQ_MISC_ENABLE_CLR register bits */ 77 + #define USBSS_IRQ_MISC_ENABLE_CLR_VBUSVALID BIT(22) 78 + #define USBSS_IRQ_MISC_ENABLE_CLR_SESSVALID BIT(20) 79 + 80 + /* IRQ_MISC_EOI register bits */ 81 + #define USBSS_IRQ_MISC_EOI_VECTOR BIT(0) 82 + 83 + /* VBUS_STAT register bits */ 84 + #define USBSS_VBUS_STAT_SESSVALID BIT(2) 85 + #define USBSS_VBUS_STAT_VBUSVALID BIT(0) 86 + 87 + /* Mask for PHY PLL REFCLK */ 88 + #define PHY_PLL_REFCLK_MASK GENMASK(3, 0) 89 + 90 + #define DWC3_AM62_AUTOSUSPEND_DELAY 100 91 + 92 + struct dwc3_data { 93 + struct device *dev; 94 + void __iomem *usbss; 95 + struct clk *usb2_refclk; 96 + int rate_code; 97 + struct regmap *syscon; 98 + unsigned int offset; 99 + unsigned int vbus_divider; 100 + }; 101 + 102 + static const int dwc3_ti_rate_table[] = { /* in KHZ */ 103 + 9600, 104 + 10000, 105 + 12000, 106 + 19200, 107 + 20000, 108 + 24000, 109 + 25000, 110 + 26000, 111 + 38400, 112 + 40000, 113 + 58000, 114 + 50000, 115 + 52000, 116 + }; 117 + 118 + static inline u32 dwc3_ti_readl(struct dwc3_data *data, u32 offset) 119 + { 120 + return readl((data->usbss) + offset); 121 + } 122 + 123 + static inline void dwc3_ti_writel(struct dwc3_data *data, u32 offset, u32 value) 124 + { 125 + writel(value, (data->usbss) + offset); 126 + } 127 + 128 + static int phy_syscon_pll_refclk(struct dwc3_data *data) 129 + { 130 + struct device *dev = data->dev; 131 + struct device_node *node = dev->of_node; 132 + struct of_phandle_args args; 133 + struct regmap *syscon; 134 + int ret; 135 + 136 + syscon = syscon_regmap_lookup_by_phandle(node, "ti,syscon-phy-pll-refclk"); 137 + if (IS_ERR(syscon)) { 138 + dev_err(dev, "unable to get ti,syscon-phy-pll-refclk regmap\n"); 139 + return PTR_ERR(syscon); 140 + } 141 + 142 + data->syscon = syscon; 143 + 144 + ret = of_parse_phandle_with_fixed_args(node, "ti,syscon-phy-pll-refclk", 1, 145 + 0, &args); 146 + if (ret) 147 + return ret; 148 + 149 + data->offset = args.args[0]; 150 + 151 + ret = regmap_update_bits(data->syscon, data->offset, PHY_PLL_REFCLK_MASK, data->rate_code); 152 + if (ret) { 153 + dev_err(dev, "failed to set phy pll reference clock rate\n"); 154 + return ret; 155 + } 156 + 157 + return 0; 158 + } 159 + 160 + static int dwc3_ti_probe(struct platform_device *pdev) 161 + { 162 + struct device *dev = &pdev->dev; 163 + struct device_node *node = pdev->dev.of_node; 164 + struct dwc3_data *data; 165 + int i, ret; 166 + unsigned long rate; 167 + u32 reg; 168 + 169 + data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); 170 + if (!data) 171 + return -ENOMEM; 172 + 173 + data->dev = dev; 174 + platform_set_drvdata(pdev, data); 175 + 176 + data->usbss = devm_platform_ioremap_resource(pdev, 0); 177 + if (IS_ERR(data->usbss)) { 178 + dev_err(dev, "can't map IOMEM resource\n"); 179 + return PTR_ERR(data->usbss); 180 + } 181 + 182 + data->usb2_refclk = devm_clk_get(dev, "ref"); 183 + if (IS_ERR(data->usb2_refclk)) { 184 + dev_err(dev, "can't get usb2_refclk\n"); 185 + return PTR_ERR(data->usb2_refclk); 186 + } 187 + 188 + /* Calculate the rate code */ 189 + rate = clk_get_rate(data->usb2_refclk); 190 + rate /= 1000; // To KHz 191 + for (i = 0; i < ARRAY_SIZE(dwc3_ti_rate_table); i++) { 192 + if (dwc3_ti_rate_table[i] == rate) 193 + break; 194 + } 195 + 196 + if (i == ARRAY_SIZE(dwc3_ti_rate_table)) { 197 + dev_err(dev, "unsupported usb2_refclk rate: %lu KHz\n", rate); 198 + ret = -EINVAL; 199 + goto err_clk_disable; 200 + } 201 + 202 + data->rate_code = i; 203 + 204 + /* Read the syscon property and set the rate code */ 205 + ret = phy_syscon_pll_refclk(data); 206 + if (ret) 207 + goto err_clk_disable; 208 + 209 + /* VBUS divider select */ 210 + data->vbus_divider = device_property_read_bool(dev, "ti,vbus-divider"); 211 + reg = dwc3_ti_readl(data, USBSS_PHY_CONFIG); 212 + if (data->vbus_divider) 213 + reg |= 1 << USBSS_PHY_VBUS_SEL_SHIFT; 214 + 215 + dwc3_ti_writel(data, USBSS_PHY_CONFIG, reg); 216 + 217 + pm_runtime_set_active(dev); 218 + pm_runtime_enable(dev); 219 + /* 220 + * Don't ignore its dependencies with its children 221 + */ 222 + pm_suspend_ignore_children(dev, false); 223 + clk_prepare_enable(data->usb2_refclk); 224 + pm_runtime_get_noresume(dev); 225 + 226 + ret = of_platform_populate(node, NULL, NULL, dev); 227 + if (ret) { 228 + dev_err(dev, "failed to create dwc3 core: %d\n", ret); 229 + goto err_pm_disable; 230 + } 231 + 232 + /* Set mode valid bit to indicate role is valid */ 233 + reg = dwc3_ti_readl(data, USBSS_MODE_CONTROL); 234 + reg |= USBSS_MODE_VALID; 235 + dwc3_ti_writel(data, USBSS_MODE_CONTROL, reg); 236 + 237 + /* Setting up autosuspend */ 238 + pm_runtime_set_autosuspend_delay(dev, DWC3_AM62_AUTOSUSPEND_DELAY); 239 + pm_runtime_use_autosuspend(dev); 240 + pm_runtime_mark_last_busy(dev); 241 + pm_runtime_put_autosuspend(dev); 242 + return 0; 243 + 244 + err_pm_disable: 245 + clk_disable_unprepare(data->usb2_refclk); 246 + pm_runtime_disable(dev); 247 + pm_runtime_set_suspended(dev); 248 + err_clk_disable: 249 + clk_put(data->usb2_refclk); 250 + return ret; 251 + } 252 + 253 + static int dwc3_ti_remove_core(struct device *dev, void *c) 254 + { 255 + struct platform_device *pdev = to_platform_device(dev); 256 + 257 + platform_device_unregister(pdev); 258 + return 0; 259 + } 260 + 261 + static int dwc3_ti_remove(struct platform_device *pdev) 262 + { 263 + struct device *dev = &pdev->dev; 264 + struct dwc3_data *data = platform_get_drvdata(pdev); 265 + u32 reg; 266 + 267 + device_for_each_child(dev, NULL, dwc3_ti_remove_core); 268 + 269 + /* Clear mode valid bit */ 270 + reg = dwc3_ti_readl(data, USBSS_MODE_CONTROL); 271 + reg &= ~USBSS_MODE_VALID; 272 + dwc3_ti_writel(data, USBSS_MODE_CONTROL, reg); 273 + 274 + pm_runtime_put_sync(dev); 275 + clk_disable_unprepare(data->usb2_refclk); 276 + pm_runtime_disable(dev); 277 + pm_runtime_set_suspended(dev); 278 + 279 + clk_put(data->usb2_refclk); 280 + platform_set_drvdata(pdev, NULL); 281 + return 0; 282 + } 283 + 284 + #ifdef CONFIG_PM 285 + static int dwc3_ti_suspend_common(struct device *dev) 286 + { 287 + struct dwc3_data *data = dev_get_drvdata(dev); 288 + 289 + clk_disable_unprepare(data->usb2_refclk); 290 + 291 + return 0; 292 + } 293 + 294 + static int dwc3_ti_resume_common(struct device *dev) 295 + { 296 + struct dwc3_data *data = dev_get_drvdata(dev); 297 + 298 + clk_prepare_enable(data->usb2_refclk); 299 + 300 + return 0; 301 + } 302 + 303 + static UNIVERSAL_DEV_PM_OPS(dwc3_ti_pm_ops, dwc3_ti_suspend_common, 304 + dwc3_ti_resume_common, NULL); 305 + 306 + #define DEV_PM_OPS (&dwc3_ti_pm_ops) 307 + #else 308 + #define DEV_PM_OPS NULL 309 + #endif /* CONFIG_PM */ 310 + 311 + static const struct of_device_id dwc3_ti_of_match[] = { 312 + { .compatible = "ti,am62-usb"}, 313 + {}, 314 + }; 315 + MODULE_DEVICE_TABLE(of, dwc3_ti_of_match); 316 + 317 + static struct platform_driver dwc3_ti_driver = { 318 + .probe = dwc3_ti_probe, 319 + .remove = dwc3_ti_remove, 320 + .driver = { 321 + .name = "dwc3-am62", 322 + .pm = DEV_PM_OPS, 323 + .of_match_table = dwc3_ti_of_match, 324 + }, 325 + }; 326 + 327 + module_platform_driver(dwc3_ti_driver); 328 + 329 + MODULE_ALIAS("platform:dwc3-am62"); 330 + MODULE_AUTHOR("Aswath Govindraju <a-govindraju@ti.com>"); 331 + MODULE_LICENSE("GPL"); 332 + MODULE_DESCRIPTION("DesignWare USB3 TI Glue Layer");
+1 -1
drivers/usb/dwc3/dwc3-pci.c
··· 288 288 int ret; 289 289 290 290 ret = pm_runtime_get_sync(&dwc3->dev); 291 - if (ret) { 291 + if (ret < 0) { 292 292 pm_runtime_put_sync_autosuspend(&dwc3->dev); 293 293 return; 294 294 }
+17
drivers/usb/dwc3/dwc3-xilinx.c
··· 13 13 #include <linux/of.h> 14 14 #include <linux/platform_device.h> 15 15 #include <linux/dma-mapping.h> 16 + #include <linux/of_gpio.h> 16 17 #include <linux/of_platform.h> 17 18 #include <linux/pm_runtime.h> 18 19 #include <linux/reset.h> ··· 99 98 { 100 99 struct device *dev = priv_data->dev; 101 100 struct reset_control *crst, *hibrst, *apbrst; 101 + struct gpio_desc *reset_gpio; 102 102 struct phy *usb3_phy; 103 103 int ret = 0; 104 104 u32 reg; ··· 203 201 } 204 202 205 203 skip_usb3_phy: 204 + /* ulpi reset via gpio-modepin or gpio-framework driver */ 205 + reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW); 206 + if (IS_ERR(reset_gpio)) { 207 + return dev_err_probe(dev, PTR_ERR(reset_gpio), 208 + "Failed to request reset GPIO\n"); 209 + } 210 + 211 + if (reset_gpio) { 212 + /* Toggle ulpi to reset the phy. */ 213 + gpiod_set_value_cansleep(reset_gpio, 1); 214 + usleep_range(5000, 10000); 215 + gpiod_set_value_cansleep(reset_gpio, 0); 216 + usleep_range(5000, 10000); 217 + } 218 + 206 219 /* 207 220 * This routes the USB DMA traffic to go through FPD path instead 208 221 * of reaching DDR directly. This traffic routing is needed to
+10 -4
drivers/usb/dwc3/ep0.c
··· 218 218 return ret; 219 219 } 220 220 221 - static void dwc3_ep0_stall_and_restart(struct dwc3 *dwc) 221 + void dwc3_ep0_stall_and_restart(struct dwc3 *dwc) 222 222 { 223 223 struct dwc3_ep *dep; 224 224 ··· 813 813 int ret = -EINVAL; 814 814 u32 len; 815 815 816 - if (!dwc->gadget_driver) 816 + if (!dwc->gadget_driver || !dwc->connected) 817 817 goto out; 818 818 819 819 trace_dwc3_ctrl_req(ctrl); ··· 1080 1080 unsigned int direction = !dwc->ep0_expect_in; 1081 1081 1082 1082 dwc->delayed_status = false; 1083 + dwc->clear_stall_protocol = 0; 1083 1084 1084 1085 if (dwc->ep0state != EP0_STATUS_PHASE) 1085 1086 return; ··· 1088 1087 __dwc3_ep0_do_control_status(dwc, dwc->eps[direction]); 1089 1088 } 1090 1089 1091 - static void dwc3_ep0_end_control_data(struct dwc3 *dwc, struct dwc3_ep *dep) 1090 + void dwc3_ep0_end_control_data(struct dwc3 *dwc, struct dwc3_ep *dep) 1092 1091 { 1093 1092 struct dwc3_gadget_ep_cmd_params params; 1094 1093 u32 cmd; 1095 1094 int ret; 1096 1095 1097 - if (!dep->resource_index) 1096 + /* 1097 + * For status/DATA OUT stage, TRB will be queued on ep0 out 1098 + * endpoint for which resource index is zero. Hence allow 1099 + * queuing ENDXFER command for ep0 out endpoint. 1100 + */ 1101 + if (!dep->resource_index && dep->number) 1098 1102 return; 1099 1103 1100 1104 cmd = DWC3_DEPCMD_ENDTRANSFER;
+119 -71
drivers/usb/dwc3/gadget.c
··· 657 657 /** 658 658 * dwc3_gadget_calc_tx_fifo_size - calculates the txfifo size value 659 659 * @dwc: pointer to the DWC3 context 660 - * @nfifos: number of fifos to calculate for 661 660 * 662 661 * Calculates the size value based on the equation below: 663 662 * ··· 689 690 } 690 691 691 692 /** 692 - * dwc3_gadget_clear_tx_fifo_size - Clears txfifo allocation 693 + * dwc3_gadget_clear_tx_fifos - Clears txfifo allocation 693 694 * @dwc: pointer to the DWC3 context 694 695 * 695 696 * Iterates through all the endpoint registers and clears the previous txfifo ··· 782 783 num_fifos = 3; 783 784 784 785 if (dep->endpoint.maxburst > 6 && 785 - usb_endpoint_xfer_bulk(dep->endpoint.desc) && DWC3_IP_IS(DWC31)) 786 + (usb_endpoint_xfer_bulk(dep->endpoint.desc) || 787 + usb_endpoint_xfer_isoc(dep->endpoint.desc)) && DWC3_IP_IS(DWC31)) 786 788 num_fifos = dwc->tx_fifo_resize_max_num; 787 789 788 790 /* FIFO size for a single buffer */ ··· 882 882 reg |= DWC3_DALEPENA_EP(dep->number); 883 883 dwc3_writel(dwc->regs, DWC3_DALEPENA, reg); 884 884 885 + dep->trb_dequeue = 0; 886 + dep->trb_enqueue = 0; 887 + 885 888 if (usb_endpoint_xfer_control(desc)) 886 889 goto out; 887 890 888 891 /* Initialize the TRB ring */ 889 - dep->trb_dequeue = 0; 890 - dep->trb_enqueue = 0; 891 892 memset(dep->trb_pool, 0, 892 893 sizeof(struct dwc3_trb) * DWC3_TRB_NUM); 893 894 ··· 2002 2001 static void dwc3_gadget_ep_cleanup_cancelled_requests(struct dwc3_ep *dep) 2003 2002 { 2004 2003 struct dwc3_request *req; 2005 - struct dwc3_request *tmp; 2006 2004 struct dwc3 *dwc = dep->dwc; 2007 2005 2008 - list_for_each_entry_safe(req, tmp, &dep->cancelled_list, list) { 2006 + while (!list_empty(&dep->cancelled_list)) { 2007 + req = next_request(&dep->cancelled_list); 2009 2008 dwc3_gadget_ep_skip_trbs(dep, req); 2010 2009 switch (req->status) { 2011 2010 case DWC3_REQUEST_STATUS_DISCONNECTED: ··· 2022 2021 dwc3_gadget_giveback(dep, req, -ECONNRESET); 2023 2022 break; 2024 2023 } 2024 + /* 2025 + * The endpoint is disabled, let the dwc3_remove_requests() 2026 + * handle the cleanup. 2027 + */ 2028 + if (!dep->endpoint.desc) 2029 + break; 2025 2030 } 2026 2031 } 2027 2032 ··· 2062 2055 list_for_each_entry(r, &dep->started_list, list) { 2063 2056 if (r == req) { 2064 2057 struct dwc3_request *t; 2065 - 2066 - /* 2067 - * If a Setup packet is received but yet to DMA out, the controller will 2068 - * not process the End Transfer command of any endpoint. Polling of its 2069 - * DEPCMD.CmdAct may block setting up TRB for Setup packet, causing a 2070 - * timeout. Delay issuing the End Transfer command until the Setup TRB is 2071 - * prepared. 2072 - */ 2073 - if (dwc->ep0state != EP0_SETUP_PHASE && !dwc->delayed_status) 2074 - dep->flags |= DWC3_EP_DELAY_STOP; 2075 2058 2076 2059 /* wait until it is processed */ 2077 2060 dwc3_stop_active_transfer(dep, true, true); ··· 2149 2152 if (dep->flags & DWC3_EP_END_TRANSFER_PENDING || 2150 2153 (dep->flags & DWC3_EP_DELAY_STOP)) { 2151 2154 dep->flags |= DWC3_EP_PENDING_CLEAR_STALL; 2155 + if (protocol) 2156 + dwc->clear_stall_protocol = dep->number; 2157 + 2152 2158 return 0; 2153 2159 } 2154 2160 ··· 2498 2498 static void __dwc3_gadget_stop(struct dwc3 *dwc); 2499 2499 static int __dwc3_gadget_start(struct dwc3 *dwc); 2500 2500 2501 - static int dwc3_gadget_pullup(struct usb_gadget *g, int is_on) 2501 + static int dwc3_gadget_soft_disconnect(struct dwc3 *dwc) 2502 2502 { 2503 - struct dwc3 *dwc = gadget_to_dwc(g); 2504 - unsigned long flags; 2505 - int ret; 2503 + unsigned long flags; 2506 2504 2507 - is_on = !!is_on; 2508 - dwc->softconnect = is_on; 2505 + spin_lock_irqsave(&dwc->lock, flags); 2506 + dwc->connected = false; 2507 + 2509 2508 /* 2510 2509 * Per databook, when we want to stop the gadget, if a control transfer 2511 2510 * is still in process, complete it and get the core into setup phase. 2512 2511 */ 2513 - if (!is_on && dwc->ep0state != EP0_SETUP_PHASE) { 2512 + if (dwc->ep0state != EP0_SETUP_PHASE) { 2513 + int ret; 2514 + 2514 2515 reinit_completion(&dwc->ep0_in_setup); 2515 2516 2517 + spin_unlock_irqrestore(&dwc->lock, flags); 2516 2518 ret = wait_for_completion_timeout(&dwc->ep0_in_setup, 2517 2519 msecs_to_jiffies(DWC3_PULL_UP_TIMEOUT)); 2520 + spin_lock_irqsave(&dwc->lock, flags); 2518 2521 if (ret == 0) 2519 2522 dev_warn(dwc->dev, "timed out waiting for SETUP phase\n"); 2520 2523 } 2524 + 2525 + /* 2526 + * In the Synopsys DesignWare Cores USB3 Databook Rev. 3.30a 2527 + * Section 4.1.8 Table 4-7, it states that for a device-initiated 2528 + * disconnect, the SW needs to ensure that it sends "a DEPENDXFER 2529 + * command for any active transfers" before clearing the RunStop 2530 + * bit. 2531 + */ 2532 + dwc3_stop_active_transfers(dwc); 2533 + __dwc3_gadget_stop(dwc); 2534 + spin_unlock_irqrestore(&dwc->lock, flags); 2535 + 2536 + /* 2537 + * Note: if the GEVNTCOUNT indicates events in the event buffer, the 2538 + * driver needs to acknowledge them before the controller can halt. 2539 + * Simply let the interrupt handler acknowledges and handle the 2540 + * remaining event generated by the controller while polling for 2541 + * DSTS.DEVCTLHLT. 2542 + */ 2543 + return dwc3_gadget_run_stop(dwc, false, false); 2544 + } 2545 + 2546 + static int dwc3_gadget_pullup(struct usb_gadget *g, int is_on) 2547 + { 2548 + struct dwc3 *dwc = gadget_to_dwc(g); 2549 + int ret; 2550 + 2551 + is_on = !!is_on; 2552 + 2553 + if (dwc->pullups_connected == is_on) 2554 + return 0; 2555 + 2556 + dwc->softconnect = is_on; 2521 2557 2522 2558 /* 2523 2559 * Avoid issuing a runtime resume if the device is already in the ··· 2577 2541 return 0; 2578 2542 } 2579 2543 2580 - /* 2581 - * Synchronize and disable any further event handling while controller 2582 - * is being enabled/disabled. 2583 - */ 2584 - disable_irq(dwc->irq_gadget); 2585 - 2586 - spin_lock_irqsave(&dwc->lock, flags); 2587 - 2588 2544 if (!is_on) { 2589 - u32 count; 2590 - 2591 - dwc->connected = false; 2592 - /* 2593 - * In the Synopsis DesignWare Cores USB3 Databook Rev. 3.30a 2594 - * Section 4.1.8 Table 4-7, it states that for a device-initiated 2595 - * disconnect, the SW needs to ensure that it sends "a DEPENDXFER 2596 - * command for any active transfers" before clearing the RunStop 2597 - * bit. 2598 - */ 2599 - dwc3_stop_active_transfers(dwc); 2600 - __dwc3_gadget_stop(dwc); 2601 - 2602 - /* 2603 - * In the Synopsis DesignWare Cores USB3 Databook Rev. 3.30a 2604 - * Section 1.3.4, it mentions that for the DEVCTRLHLT bit, the 2605 - * "software needs to acknowledge the events that are generated 2606 - * (by writing to GEVNTCOUNTn) while it is waiting for this bit 2607 - * to be set to '1'." 2608 - */ 2609 - count = dwc3_readl(dwc->regs, DWC3_GEVNTCOUNT(0)); 2610 - count &= DWC3_GEVNTCOUNT_MASK; 2611 - if (count > 0) { 2612 - dwc3_writel(dwc->regs, DWC3_GEVNTCOUNT(0), count); 2613 - dwc->ev_buf->lpos = (dwc->ev_buf->lpos + count) % 2614 - dwc->ev_buf->length; 2615 - } 2545 + ret = dwc3_gadget_soft_disconnect(dwc); 2616 2546 } else { 2617 2547 /* 2618 2548 * In the Synopsys DWC_usb31 1.90a programming guide section ··· 2586 2584 * device-initiated disconnect requires a core soft reset 2587 2585 * (DCTL.CSftRst) before enabling the run/stop bit. 2588 2586 */ 2589 - spin_unlock_irqrestore(&dwc->lock, flags); 2590 2587 dwc3_core_soft_reset(dwc); 2591 - spin_lock_irqsave(&dwc->lock, flags); 2592 2588 2593 2589 dwc3_event_buffers_setup(dwc); 2594 2590 __dwc3_gadget_start(dwc); 2591 + ret = dwc3_gadget_run_stop(dwc, true, false); 2595 2592 } 2596 - 2597 - ret = dwc3_gadget_run_stop(dwc, is_on, false); 2598 - spin_unlock_irqrestore(&dwc->lock, flags); 2599 - enable_irq(dwc->irq_gadget); 2600 2593 2601 2594 pm_runtime_put(dwc->dev); 2602 2595 ··· 2742 2745 2743 2746 /* begin to receive SETUP packets */ 2744 2747 dwc->ep0state = EP0_SETUP_PHASE; 2748 + dwc->ep0_bounced = false; 2745 2749 dwc->link_state = DWC3_LINK_STATE_SS_DIS; 2746 2750 dwc->delayed_status = false; 2747 2751 dwc3_ep0_out_start(dwc); ··· 3331 3333 const struct dwc3_event_depevt *event, int status) 3332 3334 { 3333 3335 struct dwc3_request *req; 3334 - struct dwc3_request *tmp; 3335 3336 3336 - list_for_each_entry_safe(req, tmp, &dep->started_list, list) { 3337 + while (!list_empty(&dep->started_list)) { 3337 3338 int ret; 3338 3339 3340 + req = next_request(&dep->started_list); 3339 3341 ret = dwc3_gadget_ep_cleanup_completed_request(dep, event, 3340 3342 req, status); 3341 3343 if (ret) 3344 + break; 3345 + /* 3346 + * The endpoint is disabled, let the dwc3_remove_requests() 3347 + * handle the cleanup. 3348 + */ 3349 + if (!dep->endpoint.desc) 3342 3350 break; 3343 3351 } 3344 3352 } ··· 3384 3380 struct dwc3 *dwc = dep->dwc; 3385 3381 bool no_started_trb = true; 3386 3382 3387 - if (!dep->endpoint.desc) 3388 - return no_started_trb; 3389 - 3390 3383 dwc3_gadget_ep_cleanup_completed_requests(dep, event, status); 3391 3384 3392 3385 if (dep->flags & DWC3_EP_END_TRANSFER_PENDING) 3393 3386 goto out; 3387 + 3388 + if (!dep->endpoint.desc) 3389 + return no_started_trb; 3394 3390 3395 3391 if (usb_endpoint_xfer_isoc(dep->endpoint.desc) && 3396 3392 list_empty(&dep->started_list) && ··· 3516 3512 } 3517 3513 3518 3514 dep->flags &= ~(DWC3_EP_STALL | DWC3_EP_WEDGE); 3519 - if (dwc->delayed_status) 3515 + if (dwc->clear_stall_protocol == dep->number) 3520 3516 dwc3_ep0_send_delayed_status(dwc); 3521 3517 } 3522 3518 ··· 3677 3673 void dwc3_stop_active_transfer(struct dwc3_ep *dep, bool force, 3678 3674 bool interrupt) 3679 3675 { 3676 + struct dwc3 *dwc = dep->dwc; 3677 + 3678 + /* 3679 + * Only issue End Transfer command to the control endpoint of a started 3680 + * Data Phase. Typically we should only do so in error cases such as 3681 + * invalid/unexpected direction as described in the control transfer 3682 + * flow of the programming guide. 3683 + */ 3684 + if (dep->number <= 1 && dwc->ep0state != EP0_DATA_PHASE) 3685 + return; 3686 + 3680 3687 if (!(dep->flags & DWC3_EP_TRANSFER_STARTED) || 3681 3688 (dep->flags & DWC3_EP_DELAY_STOP) || 3682 3689 (dep->flags & DWC3_EP_END_TRANSFER_PENDING)) 3683 3690 return; 3691 + 3692 + /* 3693 + * If a Setup packet is received but yet to DMA out, the controller will 3694 + * not process the End Transfer command of any endpoint. Polling of its 3695 + * DEPCMD.CmdAct may block setting up TRB for Setup packet, causing a 3696 + * timeout. Delay issuing the End Transfer command until the Setup TRB is 3697 + * prepared. 3698 + */ 3699 + if (dwc->ep0state != EP0_SETUP_PHASE && !dwc->delayed_status) { 3700 + dep->flags |= DWC3_EP_DELAY_STOP; 3701 + return; 3702 + } 3684 3703 3685 3704 /* 3686 3705 * NOTICE: We are violating what the Databook says about the ··· 3822 3795 } 3823 3796 3824 3797 dwc3_reset_gadget(dwc); 3798 + 3799 + /* 3800 + * From SNPS databook section 8.1.2, the EP0 should be in setup 3801 + * phase. So ensure that EP0 is in setup phase by issuing a stall 3802 + * and restart if EP0 is not in setup phase. 3803 + */ 3804 + if (dwc->ep0state != EP0_SETUP_PHASE) { 3805 + unsigned int dir; 3806 + 3807 + dir = !!dwc->ep0_expect_in; 3808 + if (dwc->ep0state == EP0_DATA_PHASE) 3809 + dwc3_ep0_end_control_data(dwc, dwc->eps[dir]); 3810 + else 3811 + dwc3_ep0_end_control_data(dwc, dwc->eps[!dir]); 3812 + 3813 + dwc->eps[0]->trb_enqueue = 0; 3814 + dwc->eps[1]->trb_enqueue = 0; 3815 + 3816 + dwc3_ep0_stall_and_restart(dwc); 3817 + } 3818 + 3825 3819 /* 3826 3820 * In the Synopsis DesignWare Cores USB3 Databook Rev. 3.30a 3827 3821 * Section 4.1.2 Table 4-2, it states that during a USB reset, the SW
+2
drivers/usb/dwc3/gadget.h
··· 110 110 void dwc3_ep0_interrupt(struct dwc3 *dwc, 111 111 const struct dwc3_event_depevt *event); 112 112 void dwc3_ep0_out_start(struct dwc3 *dwc); 113 + void dwc3_ep0_end_control_data(struct dwc3 *dwc, struct dwc3_ep *dep); 114 + void dwc3_ep0_stall_and_restart(struct dwc3 *dwc); 113 115 int __dwc3_gadget_ep0_set_halt(struct usb_ep *ep, int value); 114 116 int dwc3_gadget_ep0_set_halt(struct usb_ep *ep, int value); 115 117 int dwc3_gadget_ep0_queue(struct usb_ep *ep, struct usb_request *request,
-2
drivers/usb/dwc3/host.c
··· 7 7 * Authors: Felipe Balbi <balbi@ti.com>, 8 8 */ 9 9 10 - #include <linux/acpi.h> 11 10 #include <linux/irq.h> 12 11 #include <linux/of.h> 13 12 #include <linux/platform_device.h> ··· 82 83 } 83 84 84 85 xhci->dev.parent = dwc->dev; 85 - ACPI_COMPANION_SET(&xhci->dev, ACPI_COMPANION(dwc->dev)); 86 86 87 87 dwc->xhci = xhci; 88 88
+1 -1
drivers/usb/gadget/composite.c
··· 2505 2505 gadget_driver->driver.name = driver->name; 2506 2506 gadget_driver->max_speed = driver->max_speed; 2507 2507 2508 - return usb_gadget_probe_driver(gadget_driver); 2508 + return usb_gadget_register_driver(gadget_driver); 2509 2509 } 2510 2510 EXPORT_SYMBOL_GPL(usb_composite_probe); 2511 2511
+1 -1
drivers/usb/gadget/configfs.c
··· 284 284 goto err; 285 285 } 286 286 gi->composite.gadget_driver.udc_name = name; 287 - ret = usb_gadget_probe_driver(&gi->composite.gadget_driver); 287 + ret = usb_gadget_register_driver(&gi->composite.gadget_driver); 288 288 if (ret) { 289 289 gi->composite.gadget_driver.udc_name = NULL; 290 290 goto err;
+10
drivers/usb/gadget/function/f_acm.c
··· 333 333 } 334 334 } 335 335 336 + static int acm_send_break(struct gserial *port, int duration); 337 + 336 338 static int acm_setup(struct usb_function *f, const struct usb_ctrlrequest *ctrl) 337 339 { 338 340 struct f_acm *acm = func_to_acm(f); ··· 391 389 * that bit, we should return to that no-flow state. 392 390 */ 393 391 acm->port_handshake_bits = w_value; 392 + break; 393 + 394 + case ((USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE) << 8) 395 + | USB_CDC_REQ_SEND_BREAK: 396 + if (w_index != acm->ctrl_id) 397 + goto invalid; 398 + 399 + acm_send_break(&acm->port, w_value); 394 400 break; 395 401 396 402 default:
+3 -2
drivers/usb/gadget/function/f_uvc.c
··· 24 24 #include <media/v4l2-dev.h> 25 25 #include <media/v4l2-event.h> 26 26 27 - #include "u_uvc.h" 28 27 #include "uvc.h" 29 28 #include "uvc_configfs.h" 30 29 #include "uvc_v4l2.h" ··· 43 44 #define UVC_STRING_STREAMING_IDX 1 44 45 45 46 static struct usb_string uvc_en_us_strings[] = { 46 - [UVC_STRING_CONTROL_IDX].s = "UVC Camera", 47 + /* [UVC_STRING_CONTROL_IDX].s = DYNAMIC, */ 47 48 [UVC_STRING_STREAMING_IDX].s = "Video Streaming", 48 49 { } 49 50 }; ··· 675 676 uvc_hs_streaming_ep.bEndpointAddress = uvc->video.ep->address; 676 677 uvc_ss_streaming_ep.bEndpointAddress = uvc->video.ep->address; 677 678 679 + uvc_en_us_strings[UVC_STRING_CONTROL_IDX].s = opts->function_name; 678 680 us = usb_gstrings_attach(cdev, uvc_function_strings, 679 681 ARRAY_SIZE(uvc_en_us_strings)); 680 682 if (IS_ERR(us)) { ··· 866 866 867 867 opts->streaming_interval = 1; 868 868 opts->streaming_maxpacket = 1024; 869 + snprintf(opts->function_name, sizeof(opts->function_name), "UVC Camera"); 869 870 870 871 ret = uvcg_attach_configfs(opts); 871 872 if (ret < 0) {
+2 -2
drivers/usb/gadget/function/u_audio.c
··· 1179 1179 if (c_chmask) { 1180 1180 struct uac_rtd_params *prm = &uac->c_prm; 1181 1181 1182 - spin_lock_init(&prm->lock); 1183 - uac->c_prm.uac = uac; 1182 + spin_lock_init(&prm->lock); 1183 + uac->c_prm.uac = uac; 1184 1184 prm->max_psize = g_audio->out_ep_maxpsize; 1185 1185 prm->srate = params->c_srates[0]; 1186 1186
+1
drivers/usb/gadget/function/u_uvc.h
··· 27 27 28 28 unsigned int control_interface; 29 29 unsigned int streaming_interface; 30 + char function_name[32]; 30 31 31 32 /* 32 33 * Control descriptors array pointers for full-/high-speed and
+1
drivers/usb/gadget/function/uvc.h
··· 80 80 struct uvc_video *video; 81 81 struct sg_table sgt; 82 82 u8 header[UVCG_REQUEST_HEADER_LEN]; 83 + struct uvc_buffer *last_buf; 83 84 }; 84 85 85 86 struct uvc_video {
+79 -110
drivers/usb/gadget/function/uvc_configfs.c
··· 10 10 * Author: Andrzej Pietrasiewicz <andrzejtp2010@gmail.com> 11 11 */ 12 12 13 - #include <linux/sort.h> 14 - 15 - #include "u_uvc.h" 16 13 #include "uvc_configfs.h" 14 + 15 + #include <linux/sort.h> 17 16 18 17 /* ----------------------------------------------------------------------------- 19 18 * Global Utility Structures and Macros 20 19 */ 21 - 22 - #define UVCG_STREAMING_CONTROL_SIZE 1 23 20 24 21 #define UVC_ATTR(prefix, cname, aname) \ 25 22 static struct configfs_attribute prefix##attr_##cname = { \ ··· 44 47 u32 ri = *(const u32 *)r; 45 48 46 49 return li < ri ? -1 : li == ri ? 0 : 1; 47 - } 48 - 49 - static inline struct f_uvc_opts *to_f_uvc_opts(struct config_item *item) 50 - { 51 - return container_of(to_config_group(item), struct f_uvc_opts, 52 - func_inst.group); 53 50 } 54 51 55 52 struct uvcg_config_group_type { ··· 115 124 * control/header/<NAME> 116 125 * control/header 117 126 */ 118 - 119 - DECLARE_UVC_HEADER_DESCRIPTOR(1); 120 - 121 - struct uvcg_control_header { 122 - struct config_item item; 123 - struct UVC_HEADER_DESCRIPTOR(1) desc; 124 - unsigned linked; 125 - }; 126 - 127 - static struct uvcg_control_header *to_uvcg_control_header(struct config_item *item) 128 - { 129 - return container_of(item, struct uvcg_control_header, item); 130 - } 131 127 132 128 #define UVCG_CTRL_HDR_ATTR(cname, aname, bits, limit) \ 133 129 static ssize_t uvcg_control_header_##cname##_show( \ ··· 747 769 "mjpeg", 748 770 }; 749 771 750 - enum uvcg_format_type { 751 - UVCG_UNCOMPRESSED = 0, 752 - UVCG_MJPEG, 753 - }; 754 - 755 - struct uvcg_format { 756 - struct config_group group; 757 - enum uvcg_format_type type; 758 - unsigned linked; 759 - unsigned num_frames; 760 - __u8 bmaControls[UVCG_STREAMING_CONTROL_SIZE]; 761 - }; 762 - 763 - static struct uvcg_format *to_uvcg_format(struct config_item *item) 764 - { 765 - return container_of(to_config_group(item), struct uvcg_format, group); 766 - } 767 - 768 772 static ssize_t uvcg_format_bma_controls_show(struct uvcg_format *f, char *page) 769 773 { 770 774 struct f_uvc_opts *opts; ··· 805 845 return ret; 806 846 } 807 847 808 - struct uvcg_format_ptr { 809 - struct uvcg_format *fmt; 810 - struct list_head entry; 811 - }; 812 - 813 848 /* ----------------------------------------------------------------------------- 814 849 * streaming/header/<NAME> 815 850 * streaming/header 816 851 */ 817 - 818 - struct uvcg_streaming_header { 819 - struct config_item item; 820 - struct uvc_input_header_descriptor desc; 821 - unsigned linked; 822 - struct list_head formats; 823 - unsigned num_fmt; 824 - }; 825 - 826 - static struct uvcg_streaming_header *to_uvcg_streaming_header(struct config_item *item) 827 - { 828 - return container_of(item, struct uvcg_streaming_header, item); 829 - } 830 852 831 853 static void uvcg_format_set_indices(struct config_group *fmt); 832 854 ··· 1000 1058 /* ----------------------------------------------------------------------------- 1001 1059 * streaming/<mode>/<format>/<NAME> 1002 1060 */ 1003 - 1004 - struct uvcg_frame { 1005 - struct config_item item; 1006 - enum uvcg_format_type fmt_type; 1007 - struct { 1008 - u8 b_length; 1009 - u8 b_descriptor_type; 1010 - u8 b_descriptor_subtype; 1011 - u8 b_frame_index; 1012 - u8 bm_capabilities; 1013 - u16 w_width; 1014 - u16 w_height; 1015 - u32 dw_min_bit_rate; 1016 - u32 dw_max_bit_rate; 1017 - u32 dw_max_video_frame_buffer_size; 1018 - u32 dw_default_frame_interval; 1019 - u8 b_frame_interval_type; 1020 - } __attribute__((packed)) frame; 1021 - u32 *dw_frame_interval; 1022 - }; 1023 - 1024 - static struct uvcg_frame *to_uvcg_frame(struct config_item *item) 1025 - { 1026 - return container_of(item, struct uvcg_frame, item); 1027 - } 1028 1061 1029 1062 #define UVCG_FRAME_ATTR(cname, aname, bits) \ 1030 1063 static ssize_t uvcg_frame_##cname##_show(struct config_item *item, char *page)\ ··· 1262 1345 struct uvcg_format *fmt; 1263 1346 struct f_uvc_opts *opts; 1264 1347 struct config_item *opts_item; 1348 + struct uvcg_frame_ptr *frame_ptr; 1265 1349 1266 1350 h = kzalloc(sizeof(*h), GFP_KERNEL); 1267 1351 if (!h) ··· 1293 1375 kfree(h); 1294 1376 return ERR_PTR(-EINVAL); 1295 1377 } 1378 + 1379 + frame_ptr = kzalloc(sizeof(*frame_ptr), GFP_KERNEL); 1380 + if (!frame_ptr) { 1381 + mutex_unlock(&opts->lock); 1382 + kfree(h); 1383 + return ERR_PTR(-ENOMEM); 1384 + } 1385 + 1386 + frame_ptr->frm = h; 1387 + list_add_tail(&frame_ptr->entry, &fmt->frames); 1296 1388 ++fmt->num_frames; 1297 1389 mutex_unlock(&opts->lock); 1298 1390 ··· 1316 1388 struct uvcg_format *fmt; 1317 1389 struct f_uvc_opts *opts; 1318 1390 struct config_item *opts_item; 1391 + struct uvcg_frame *target_frm = NULL; 1392 + struct uvcg_frame_ptr *frame_ptr, *tmp; 1319 1393 1320 1394 opts_item = group->cg_item.ci_parent->ci_parent->ci_parent; 1321 1395 opts = to_f_uvc_opts(opts_item); 1322 1396 1323 1397 mutex_lock(&opts->lock); 1398 + target_frm = container_of(item, struct uvcg_frame, item); 1324 1399 fmt = to_uvcg_format(&group->cg_item); 1325 - --fmt->num_frames; 1400 + 1401 + list_for_each_entry_safe(frame_ptr, tmp, &fmt->frames, entry) 1402 + if (frame_ptr->frm == target_frm) { 1403 + list_del(&frame_ptr->entry); 1404 + kfree(frame_ptr); 1405 + --fmt->num_frames; 1406 + break; 1407 + } 1326 1408 mutex_unlock(&opts->lock); 1327 1409 1328 1410 config_item_put(item); ··· 1357 1419 /* ----------------------------------------------------------------------------- 1358 1420 * streaming/uncompressed/<NAME> 1359 1421 */ 1360 - 1361 - struct uvcg_uncompressed { 1362 - struct uvcg_format fmt; 1363 - struct uvc_format_uncompressed desc; 1364 - }; 1365 - 1366 - static struct uvcg_uncompressed *to_uvcg_uncompressed(struct config_item *item) 1367 - { 1368 - return container_of( 1369 - container_of(to_config_group(item), struct uvcg_format, group), 1370 - struct uvcg_uncompressed, fmt); 1371 - } 1372 1422 1373 1423 static struct configfs_group_operations uvcg_uncompressed_group_ops = { 1374 1424 .make_item = uvcg_frame_make, ··· 1491 1565 if (ret) \ 1492 1566 goto end; \ 1493 1567 \ 1568 + /* index values in uvc are never 0 */ \ 1569 + if (!num) { \ 1570 + ret = -EINVAL; \ 1571 + goto end; \ 1572 + } \ 1573 + \ 1494 1574 u->desc.aname = num; \ 1495 1575 ret = len; \ 1496 1576 end: \ ··· 1577 1645 h->desc.bmInterfaceFlags = 0; 1578 1646 h->desc.bCopyProtect = 0; 1579 1647 1648 + INIT_LIST_HEAD(&h->fmt.frames); 1580 1649 h->fmt.type = UVCG_UNCOMPRESSED; 1581 1650 config_group_init_type_name(&h->fmt.group, name, 1582 1651 &uvcg_uncompressed_type); ··· 1601 1668 /* ----------------------------------------------------------------------------- 1602 1669 * streaming/mjpeg/<NAME> 1603 1670 */ 1604 - 1605 - struct uvcg_mjpeg { 1606 - struct uvcg_format fmt; 1607 - struct uvc_format_mjpeg desc; 1608 - }; 1609 - 1610 - static struct uvcg_mjpeg *to_uvcg_mjpeg(struct config_item *item) 1611 - { 1612 - return container_of( 1613 - container_of(to_config_group(item), struct uvcg_format, group), 1614 - struct uvcg_mjpeg, fmt); 1615 - } 1616 1671 1617 1672 static struct configfs_group_operations uvcg_mjpeg_group_ops = { 1618 1673 .make_item = uvcg_frame_make, ··· 1679 1758 if (ret) \ 1680 1759 goto end; \ 1681 1760 \ 1761 + /* index values in uvc are never 0 */ \ 1762 + if (!num) { \ 1763 + ret = -EINVAL; \ 1764 + goto end; \ 1765 + } \ 1766 + \ 1682 1767 u->desc.aname = num; \ 1683 1768 ret = len; \ 1684 1769 end: \ ··· 1758 1831 h->desc.bmInterfaceFlags = 0; 1759 1832 h->desc.bCopyProtect = 0; 1760 1833 1834 + INIT_LIST_HEAD(&h->fmt.frames); 1761 1835 h->fmt.type = UVCG_MJPEG; 1762 1836 config_group_init_type_name(&h->fmt.group, name, 1763 1837 &uvcg_mjpeg_type); ··· 2353 2425 2354 2426 #undef UVCG_OPTS_ATTR 2355 2427 2428 + #define UVCG_OPTS_STRING_ATTR(cname, aname) \ 2429 + static ssize_t f_uvc_opts_string_##cname##_show(struct config_item *item,\ 2430 + char *page) \ 2431 + { \ 2432 + struct f_uvc_opts *opts = to_f_uvc_opts(item); \ 2433 + int result; \ 2434 + \ 2435 + mutex_lock(&opts->lock); \ 2436 + result = snprintf(page, sizeof(opts->aname), "%s", opts->aname);\ 2437 + mutex_unlock(&opts->lock); \ 2438 + \ 2439 + return result; \ 2440 + } \ 2441 + \ 2442 + static ssize_t f_uvc_opts_string_##cname##_store(struct config_item *item,\ 2443 + const char *page, size_t len) \ 2444 + { \ 2445 + struct f_uvc_opts *opts = to_f_uvc_opts(item); \ 2446 + int ret = 0; \ 2447 + \ 2448 + mutex_lock(&opts->lock); \ 2449 + if (opts->refcnt) { \ 2450 + ret = -EBUSY; \ 2451 + goto end; \ 2452 + } \ 2453 + \ 2454 + ret = snprintf(opts->aname, min(sizeof(opts->aname), len), \ 2455 + "%s", page); \ 2456 + \ 2457 + end: \ 2458 + mutex_unlock(&opts->lock); \ 2459 + return ret; \ 2460 + } \ 2461 + \ 2462 + UVC_ATTR(f_uvc_opts_string_, cname, aname) 2463 + 2464 + UVCG_OPTS_STRING_ATTR(function_name, function_name); 2465 + 2466 + #undef UVCG_OPTS_STRING_ATTR 2467 + 2356 2468 static struct configfs_attribute *uvc_attrs[] = { 2357 2469 &f_uvc_opts_attr_streaming_interval, 2358 2470 &f_uvc_opts_attr_streaming_maxpacket, 2359 2471 &f_uvc_opts_attr_streaming_maxburst, 2472 + &f_uvc_opts_string_attr_function_name, 2360 2473 NULL, 2361 2474 }; 2362 2475
+119 -1
drivers/usb/gadget/function/uvc_configfs.h
··· 12 12 #ifndef UVC_CONFIGFS_H 13 13 #define UVC_CONFIGFS_H 14 14 15 - struct f_uvc_opts; 15 + #include <linux/configfs.h> 16 + 17 + #include "u_uvc.h" 18 + 19 + static inline struct f_uvc_opts *to_f_uvc_opts(struct config_item *item) 20 + { 21 + return container_of(to_config_group(item), struct f_uvc_opts, 22 + func_inst.group); 23 + } 24 + 25 + #define UVCG_STREAMING_CONTROL_SIZE 1 26 + 27 + DECLARE_UVC_HEADER_DESCRIPTOR(1); 28 + 29 + struct uvcg_control_header { 30 + struct config_item item; 31 + struct UVC_HEADER_DESCRIPTOR(1) desc; 32 + unsigned linked; 33 + }; 34 + 35 + static inline struct uvcg_control_header *to_uvcg_control_header(struct config_item *item) 36 + { 37 + return container_of(item, struct uvcg_control_header, item); 38 + } 39 + 40 + enum uvcg_format_type { 41 + UVCG_UNCOMPRESSED = 0, 42 + UVCG_MJPEG, 43 + }; 44 + 45 + struct uvcg_format { 46 + struct config_group group; 47 + enum uvcg_format_type type; 48 + unsigned linked; 49 + struct list_head frames; 50 + unsigned num_frames; 51 + __u8 bmaControls[UVCG_STREAMING_CONTROL_SIZE]; 52 + }; 53 + 54 + struct uvcg_format_ptr { 55 + struct uvcg_format *fmt; 56 + struct list_head entry; 57 + }; 58 + 59 + static inline struct uvcg_format *to_uvcg_format(struct config_item *item) 60 + { 61 + return container_of(to_config_group(item), struct uvcg_format, group); 62 + } 63 + 64 + struct uvcg_streaming_header { 65 + struct config_item item; 66 + struct uvc_input_header_descriptor desc; 67 + unsigned linked; 68 + struct list_head formats; 69 + unsigned num_fmt; 70 + }; 71 + 72 + static inline struct uvcg_streaming_header *to_uvcg_streaming_header(struct config_item *item) 73 + { 74 + return container_of(item, struct uvcg_streaming_header, item); 75 + } 76 + 77 + struct uvcg_frame_ptr { 78 + struct uvcg_frame *frm; 79 + struct list_head entry; 80 + }; 81 + 82 + struct uvcg_frame { 83 + struct config_item item; 84 + enum uvcg_format_type fmt_type; 85 + struct { 86 + u8 b_length; 87 + u8 b_descriptor_type; 88 + u8 b_descriptor_subtype; 89 + u8 b_frame_index; 90 + u8 bm_capabilities; 91 + u16 w_width; 92 + u16 w_height; 93 + u32 dw_min_bit_rate; 94 + u32 dw_max_bit_rate; 95 + u32 dw_max_video_frame_buffer_size; 96 + u32 dw_default_frame_interval; 97 + u8 b_frame_interval_type; 98 + } __attribute__((packed)) frame; 99 + u32 *dw_frame_interval; 100 + }; 101 + 102 + static inline struct uvcg_frame *to_uvcg_frame(struct config_item *item) 103 + { 104 + return container_of(item, struct uvcg_frame, item); 105 + } 106 + 107 + /* ----------------------------------------------------------------------------- 108 + * streaming/uncompressed/<NAME> 109 + */ 110 + 111 + struct uvcg_uncompressed { 112 + struct uvcg_format fmt; 113 + struct uvc_format_uncompressed desc; 114 + }; 115 + 116 + static inline struct uvcg_uncompressed *to_uvcg_uncompressed(struct config_item *item) 117 + { 118 + return container_of(to_uvcg_format(item), struct uvcg_uncompressed, fmt); 119 + } 120 + 121 + /* ----------------------------------------------------------------------------- 122 + * streaming/mjpeg/<NAME> 123 + */ 124 + 125 + struct uvcg_mjpeg { 126 + struct uvcg_format fmt; 127 + struct uvc_format_mjpeg desc; 128 + }; 129 + 130 + static inline struct uvcg_mjpeg *to_uvcg_mjpeg(struct config_item *item) 131 + { 132 + return container_of(to_uvcg_format(item), struct uvcg_mjpeg, fmt); 133 + } 16 134 17 135 int uvcg_attach_configfs(struct f_uvc_opts *opts); 18 136
+3 -27
drivers/usb/gadget/function/uvc_queue.c
··· 185 185 186 186 int uvcg_queue_buffer(struct uvc_video_queue *queue, struct v4l2_buffer *buf) 187 187 { 188 - unsigned long flags; 189 - int ret; 190 - 191 - ret = vb2_qbuf(&queue->queue, NULL, buf); 192 - if (ret < 0) 193 - return ret; 194 - 195 - spin_lock_irqsave(&queue->irqlock, flags); 196 - ret = (queue->flags & UVC_QUEUE_PAUSED) != 0; 197 - queue->flags &= ~UVC_QUEUE_PAUSED; 198 - spin_unlock_irqrestore(&queue->irqlock, flags); 199 - return ret; 188 + return vb2_qbuf(&queue->queue, NULL, buf); 200 189 } 201 190 202 191 /* ··· 317 328 } 318 329 319 330 /* called with &queue_irqlock held.. */ 320 - struct uvc_buffer *uvcg_queue_next_buffer(struct uvc_video_queue *queue, 331 + void uvcg_complete_buffer(struct uvc_video_queue *queue, 321 332 struct uvc_buffer *buf) 322 333 { 323 - struct uvc_buffer *nextbuf; 324 - 325 334 if ((queue->flags & UVC_QUEUE_DROP_INCOMPLETE) && 326 335 buf->length != buf->bytesused) { 327 336 buf->state = UVC_BUF_STATE_QUEUED; 328 337 vb2_set_plane_payload(&buf->buf.vb2_buf, 0, 0); 329 - return buf; 338 + return; 330 339 } 331 - 332 - list_del(&buf->queue); 333 - if (!list_empty(&queue->irqqueue)) 334 - nextbuf = list_first_entry(&queue->irqqueue, struct uvc_buffer, 335 - queue); 336 - else 337 - nextbuf = NULL; 338 340 339 341 buf->buf.field = V4L2_FIELD_NONE; 340 342 buf->buf.sequence = queue->sequence++; ··· 333 353 334 354 vb2_set_plane_payload(&buf->buf.vb2_buf, 0, buf->bytesused); 335 355 vb2_buffer_done(&buf->buf.vb2_buf, VB2_BUF_STATE_DONE); 336 - 337 - return nextbuf; 338 356 } 339 357 340 358 struct uvc_buffer *uvcg_queue_head(struct uvc_video_queue *queue) ··· 342 364 if (!list_empty(&queue->irqqueue)) 343 365 buf = list_first_entry(&queue->irqqueue, struct uvc_buffer, 344 366 queue); 345 - else 346 - queue->flags |= UVC_QUEUE_PAUSED; 347 367 348 368 return buf; 349 369 }
+1 -2
drivers/usb/gadget/function/uvc_queue.h
··· 43 43 44 44 #define UVC_QUEUE_DISCONNECTED (1 << 0) 45 45 #define UVC_QUEUE_DROP_INCOMPLETE (1 << 1) 46 - #define UVC_QUEUE_PAUSED (1 << 2) 47 46 48 47 struct uvc_video_queue { 49 48 struct vb2_queue queue; ··· 92 93 93 94 int uvcg_queue_enable(struct uvc_video_queue *queue, int enable); 94 95 95 - struct uvc_buffer *uvcg_queue_next_buffer(struct uvc_video_queue *queue, 96 + void uvcg_complete_buffer(struct uvc_video_queue *queue, 96 97 struct uvc_buffer *buf); 97 98 98 99 struct uvc_buffer *uvcg_queue_head(struct uvc_video_queue *queue);
+13 -4
drivers/usb/gadget/function/uvc_video.c
··· 112 112 if (buf->bytesused == video->queue.buf_used) { 113 113 video->queue.buf_used = 0; 114 114 buf->state = UVC_BUF_STATE_DONE; 115 - uvcg_queue_next_buffer(&video->queue, buf); 115 + list_del(&buf->queue); 116 + uvcg_complete_buffer(&video->queue, buf); 116 117 video->fid ^= UVC_STREAM_FID; 117 118 118 119 video->payload_size = 0; ··· 155 154 sg = sg_next(sg); 156 155 157 156 for_each_sg(sg, iter, ureq->sgt.nents - 1, i) { 158 - if (!len || !buf->sg) 157 + if (!len || !buf->sg || !sg_dma_len(buf->sg)) 159 158 break; 160 159 161 160 sg_left = sg_dma_len(buf->sg) - buf->offset; ··· 184 183 video->queue.buf_used = 0; 185 184 buf->state = UVC_BUF_STATE_DONE; 186 185 buf->offset = 0; 187 - uvcg_queue_next_buffer(&video->queue, buf); 186 + list_del(&buf->queue); 188 187 video->fid ^= UVC_STREAM_FID; 188 + ureq->last_buf = buf; 189 189 } 190 190 } 191 191 ··· 212 210 if (buf->bytesused == video->queue.buf_used) { 213 211 video->queue.buf_used = 0; 214 212 buf->state = UVC_BUF_STATE_DONE; 215 - uvcg_queue_next_buffer(&video->queue, buf); 213 + list_del(&buf->queue); 214 + uvcg_complete_buffer(&video->queue, buf); 216 215 video->fid ^= UVC_STREAM_FID; 217 216 } 218 217 } ··· 265 262 "VS request completed with status %d.\n", 266 263 req->status); 267 264 uvcg_queue_cancel(queue, 0); 265 + } 266 + 267 + if (ureq->last_buf) { 268 + uvcg_complete_buffer(&video->queue, ureq->last_buf); 269 + ureq->last_buf = NULL; 268 270 } 269 271 270 272 spin_lock_irqsave(&video->req_lock, flags); ··· 340 332 video->ureq[i].req->complete = uvc_video_complete; 341 333 video->ureq[i].req->context = &video->ureq[i]; 342 334 video->ureq[i].video = video; 335 + video->ureq[i].last_buf = NULL; 343 336 344 337 list_add_tail(&video->ureq[i].req->list, &video->req_free); 345 338 /* req_size/PAGE_SIZE + 1 for overruns and + 1 for header */
+1 -1
drivers/usb/gadget/legacy/dbgp.c
··· 422 422 423 423 static int __init dbgp_init(void) 424 424 { 425 - return usb_gadget_probe_driver(&dbgp_driver); 425 + return usb_gadget_register_driver(&dbgp_driver); 426 426 } 427 427 428 428 static void __exit dbgp_exit(void)
+1 -1
drivers/usb/gadget/legacy/inode.c
··· 1873 1873 else 1874 1874 gadgetfs_driver.max_speed = USB_SPEED_FULL; 1875 1875 1876 - value = usb_gadget_probe_driver(&gadgetfs_driver); 1876 + value = usb_gadget_register_driver(&gadgetfs_driver); 1877 1877 if (value != 0) { 1878 1878 spin_lock_irq(&dev->lock); 1879 1879 goto fail;
+2 -2
drivers/usb/gadget/legacy/raw_gadget.c
··· 512 512 dev->state = STATE_DEV_REGISTERING; 513 513 spin_unlock_irqrestore(&dev->lock, flags); 514 514 515 - ret = usb_gadget_probe_driver(&dev->driver); 515 + ret = usb_gadget_register_driver(&dev->driver); 516 516 517 517 spin_lock_irqsave(&dev->lock, flags); 518 518 if (ret) { 519 519 dev_err(dev->dev, 520 - "fail, usb_gadget_probe_driver returned %d\n", ret); 520 + "fail, usb_gadget_register_driver returned %d\n", ret); 521 521 dev->state = STATE_DEV_FAILED; 522 522 goto out_unlock; 523 523 }
+143 -146
drivers/usb/gadget/udc/core.c
··· 12 12 #include <linux/module.h> 13 13 #include <linux/device.h> 14 14 #include <linux/list.h> 15 + #include <linux/idr.h> 15 16 #include <linux/err.h> 16 17 #include <linux/dma-mapping.h> 17 18 #include <linux/sched/task_stack.h> ··· 23 22 #include <linux/usb.h> 24 23 25 24 #include "trace.h" 25 + 26 + static DEFINE_IDA(gadget_id_numbers); 27 + 28 + static struct bus_type gadget_bus_type; 26 29 27 30 /** 28 31 * struct usb_udc - describes one usb device controller ··· 52 47 53 48 static struct class *udc_class; 54 49 static LIST_HEAD(udc_list); 55 - static LIST_HEAD(gadget_driver_pending_list); 56 - static DEFINE_MUTEX(udc_lock); 57 50 58 - static int udc_bind_to_driver(struct usb_udc *udc, 59 - struct usb_gadget_driver *driver); 51 + /* Protects udc_list, udc->driver, driver->is_bound, and related calls */ 52 + static DEFINE_MUTEX(udc_lock); 60 53 61 54 /* ------------------------------------------------------------------------- */ 62 55 ··· 1241 1238 dev_vdbg(dev, "%s\n", __func__); 1242 1239 } 1243 1240 1244 - /* should be called with udc_lock held */ 1245 - static int check_pending_gadget_drivers(struct usb_udc *udc) 1246 - { 1247 - struct usb_gadget_driver *driver; 1248 - int ret = 0; 1249 - 1250 - list_for_each_entry(driver, &gadget_driver_pending_list, pending) 1251 - if (!driver->udc_name || strcmp(driver->udc_name, 1252 - dev_name(&udc->dev)) == 0) { 1253 - ret = udc_bind_to_driver(udc, driver); 1254 - if (ret != -EPROBE_DEFER) 1255 - list_del_init(&driver->pending); 1256 - break; 1257 - } 1258 - 1259 - return ret; 1260 - } 1261 - 1262 1241 /** 1263 1242 * usb_initialize_gadget - initialize a gadget and its embedded struct device 1264 1243 * @parent: the parent device to this udc. Usually the controller driver's 1265 1244 * device. 1266 1245 * @gadget: the gadget to be initialized. 1267 1246 * @release: a gadget release function. 1268 - * 1269 - * Returns zero on success, negative errno otherwise. 1270 - * Calls the gadget release function in the latter case. 1271 1247 */ 1272 1248 void usb_initialize_gadget(struct device *parent, struct usb_gadget *gadget, 1273 1249 void (*release)(struct device *dev)) 1274 1250 { 1275 - dev_set_name(&gadget->dev, "gadget"); 1276 1251 INIT_WORK(&gadget->work, usb_gadget_state_work); 1277 1252 gadget->dev.parent = parent; 1278 1253 ··· 1260 1279 gadget->dev.release = usb_udc_nop_release; 1261 1280 1262 1281 device_initialize(&gadget->dev); 1282 + gadget->dev.bus = &gadget_bus_type; 1263 1283 } 1264 1284 EXPORT_SYMBOL_GPL(usb_initialize_gadget); 1265 1285 ··· 1290 1308 if (ret) 1291 1309 goto err_put_udc; 1292 1310 1293 - ret = device_add(&gadget->dev); 1294 - if (ret) 1295 - goto err_put_udc; 1296 - 1297 1311 udc->gadget = gadget; 1298 1312 gadget->udc = udc; 1299 1313 ··· 1297 1319 1298 1320 mutex_lock(&udc_lock); 1299 1321 list_add_tail(&udc->list, &udc_list); 1322 + mutex_unlock(&udc_lock); 1300 1323 1301 1324 ret = device_add(&udc->dev); 1302 1325 if (ret) ··· 1306 1327 usb_gadget_set_state(gadget, USB_STATE_NOTATTACHED); 1307 1328 udc->vbus = true; 1308 1329 1309 - /* pick up one of pending gadget drivers */ 1310 - ret = check_pending_gadget_drivers(udc); 1311 - if (ret) 1330 + ret = ida_alloc(&gadget_id_numbers, GFP_KERNEL); 1331 + if (ret < 0) 1312 1332 goto err_del_udc; 1333 + gadget->id_number = ret; 1334 + dev_set_name(&gadget->dev, "gadget.%d", ret); 1313 1335 1314 - mutex_unlock(&udc_lock); 1336 + ret = device_add(&gadget->dev); 1337 + if (ret) 1338 + goto err_free_id; 1315 1339 1316 1340 return 0; 1341 + 1342 + err_free_id: 1343 + ida_free(&gadget_id_numbers, gadget->id_number); 1317 1344 1318 1345 err_del_udc: 1319 1346 flush_work(&gadget->work); 1320 1347 device_del(&udc->dev); 1321 1348 1322 1349 err_unlist_udc: 1350 + mutex_lock(&udc_lock); 1323 1351 list_del(&udc->list); 1324 1352 mutex_unlock(&udc_lock); 1325 - 1326 - device_del(&gadget->dev); 1327 1353 1328 1354 err_put_udc: 1329 1355 put_device(&udc->dev); ··· 1405 1421 } 1406 1422 EXPORT_SYMBOL_GPL(usb_add_gadget_udc); 1407 1423 1408 - static void usb_gadget_remove_driver(struct usb_udc *udc) 1409 - { 1410 - dev_dbg(&udc->dev, "unregistering UDC driver [%s]\n", 1411 - udc->driver->function); 1412 - 1413 - kobject_uevent(&udc->dev.kobj, KOBJ_CHANGE); 1414 - 1415 - usb_gadget_disconnect(udc->gadget); 1416 - usb_gadget_disable_async_callbacks(udc); 1417 - if (udc->gadget->irq) 1418 - synchronize_irq(udc->gadget->irq); 1419 - udc->driver->unbind(udc->gadget); 1420 - usb_gadget_udc_stop(udc); 1421 - 1422 - udc->driver = NULL; 1423 - udc->gadget->dev.driver = NULL; 1424 - } 1425 - 1426 1424 /** 1427 - * usb_del_gadget - deletes @udc from udc_list 1428 - * @gadget: the gadget to be removed. 1425 + * usb_del_gadget - deletes a gadget and unregisters its udc 1426 + * @gadget: the gadget to be deleted. 1429 1427 * 1430 - * This will call usb_gadget_unregister_driver() if 1431 - * the @udc is still busy. 1428 + * This will unbind @gadget, if it is bound. 1432 1429 * It will not do a final usb_put_gadget(). 1433 1430 */ 1434 1431 void usb_del_gadget(struct usb_gadget *gadget) ··· 1423 1458 1424 1459 mutex_lock(&udc_lock); 1425 1460 list_del(&udc->list); 1426 - 1427 - if (udc->driver) { 1428 - struct usb_gadget_driver *driver = udc->driver; 1429 - 1430 - usb_gadget_remove_driver(udc); 1431 - list_add(&driver->pending, &gadget_driver_pending_list); 1432 - } 1433 1461 mutex_unlock(&udc_lock); 1434 1462 1435 1463 kobject_uevent(&udc->dev.kobj, KOBJ_REMOVE); 1436 1464 flush_work(&gadget->work); 1437 - device_unregister(&udc->dev); 1438 1465 device_del(&gadget->dev); 1466 + ida_free(&gadget_id_numbers, gadget->id_number); 1467 + device_unregister(&udc->dev); 1439 1468 } 1440 1469 EXPORT_SYMBOL_GPL(usb_del_gadget); 1441 1470 1442 1471 /** 1443 - * usb_del_gadget_udc - deletes @udc from udc_list 1444 - * @gadget: the gadget to be removed. 1472 + * usb_del_gadget_udc - unregisters a gadget 1473 + * @gadget: the gadget to be unregistered. 1445 1474 * 1446 1475 * Calls usb_del_gadget() and does a final usb_put_gadget(). 1447 1476 */ ··· 1448 1489 1449 1490 /* ------------------------------------------------------------------------- */ 1450 1491 1451 - static int udc_bind_to_driver(struct usb_udc *udc, struct usb_gadget_driver *driver) 1492 + static int gadget_match_driver(struct device *dev, struct device_driver *drv) 1452 1493 { 1453 - int ret; 1494 + struct usb_gadget *gadget = dev_to_usb_gadget(dev); 1495 + struct usb_udc *udc = gadget->udc; 1496 + struct usb_gadget_driver *driver = container_of(drv, 1497 + struct usb_gadget_driver, driver); 1454 1498 1455 - dev_dbg(&udc->dev, "registering UDC driver [%s]\n", 1456 - driver->function); 1499 + /* If the driver specifies a udc_name, it must match the UDC's name */ 1500 + if (driver->udc_name && 1501 + strcmp(driver->udc_name, dev_name(&udc->dev)) != 0) 1502 + return 0; 1457 1503 1504 + /* If the driver is already bound to a gadget, it doesn't match */ 1505 + if (driver->is_bound) 1506 + return 0; 1507 + 1508 + /* Otherwise any gadget driver matches any UDC */ 1509 + return 1; 1510 + } 1511 + 1512 + static int gadget_bind_driver(struct device *dev) 1513 + { 1514 + struct usb_gadget *gadget = dev_to_usb_gadget(dev); 1515 + struct usb_udc *udc = gadget->udc; 1516 + struct usb_gadget_driver *driver = container_of(dev->driver, 1517 + struct usb_gadget_driver, driver); 1518 + int ret = 0; 1519 + 1520 + mutex_lock(&udc_lock); 1521 + if (driver->is_bound) { 1522 + mutex_unlock(&udc_lock); 1523 + return -ENXIO; /* Driver binds to only one gadget */ 1524 + } 1525 + driver->is_bound = true; 1458 1526 udc->driver = driver; 1459 - udc->gadget->dev.driver = &driver->driver; 1527 + mutex_unlock(&udc_lock); 1528 + 1529 + dev_dbg(&udc->dev, "binding gadget driver [%s]\n", driver->function); 1460 1530 1461 1531 usb_gadget_udc_set_speed(udc, driver->max_speed); 1462 1532 1533 + mutex_lock(&udc_lock); 1463 1534 ret = driver->bind(udc->gadget, driver); 1464 1535 if (ret) 1465 - goto err1; 1536 + goto err_bind; 1537 + 1466 1538 ret = usb_gadget_udc_start(udc); 1467 - if (ret) { 1468 - driver->unbind(udc->gadget); 1469 - goto err1; 1470 - } 1539 + if (ret) 1540 + goto err_start; 1471 1541 usb_gadget_enable_async_callbacks(udc); 1472 1542 usb_udc_connect_control(udc); 1543 + mutex_unlock(&udc_lock); 1473 1544 1474 1545 kobject_uevent(&udc->dev.kobj, KOBJ_CHANGE); 1475 1546 return 0; 1476 - err1: 1547 + 1548 + err_start: 1549 + driver->unbind(udc->gadget); 1550 + 1551 + err_bind: 1477 1552 if (ret != -EISNAM) 1478 1553 dev_err(&udc->dev, "failed to start %s: %d\n", 1479 - udc->driver->function, ret); 1554 + driver->function, ret); 1555 + 1480 1556 udc->driver = NULL; 1481 - udc->gadget->dev.driver = NULL; 1557 + driver->is_bound = false; 1558 + mutex_unlock(&udc_lock); 1559 + 1482 1560 return ret; 1483 1561 } 1484 1562 1485 - int usb_gadget_probe_driver(struct usb_gadget_driver *driver) 1563 + static void gadget_unbind_driver(struct device *dev) 1486 1564 { 1487 - struct usb_udc *udc = NULL, *iter; 1488 - int ret = -ENODEV; 1565 + struct usb_gadget *gadget = dev_to_usb_gadget(dev); 1566 + struct usb_udc *udc = gadget->udc; 1567 + struct usb_gadget_driver *driver = udc->driver; 1568 + 1569 + dev_dbg(&udc->dev, "unbinding gadget driver [%s]\n", driver->function); 1570 + 1571 + kobject_uevent(&udc->dev.kobj, KOBJ_CHANGE); 1572 + 1573 + mutex_lock(&udc_lock); 1574 + usb_gadget_disconnect(gadget); 1575 + usb_gadget_disable_async_callbacks(udc); 1576 + if (gadget->irq) 1577 + synchronize_irq(gadget->irq); 1578 + udc->driver->unbind(gadget); 1579 + usb_gadget_udc_stop(udc); 1580 + 1581 + driver->is_bound = false; 1582 + udc->driver = NULL; 1583 + mutex_unlock(&udc_lock); 1584 + } 1585 + 1586 + /* ------------------------------------------------------------------------- */ 1587 + 1588 + int usb_gadget_register_driver_owner(struct usb_gadget_driver *driver, 1589 + struct module *owner, const char *mod_name) 1590 + { 1591 + int ret; 1489 1592 1490 1593 if (!driver || !driver->bind || !driver->setup) 1491 1594 return -EINVAL; 1492 1595 1596 + driver->driver.bus = &gadget_bus_type; 1597 + driver->driver.owner = owner; 1598 + driver->driver.mod_name = mod_name; 1599 + ret = driver_register(&driver->driver); 1600 + if (ret) { 1601 + pr_warn("%s: driver registration failed: %d\n", 1602 + driver->function, ret); 1603 + return ret; 1604 + } 1605 + 1493 1606 mutex_lock(&udc_lock); 1494 - if (driver->udc_name) { 1495 - list_for_each_entry(iter, &udc_list, list) { 1496 - ret = strcmp(driver->udc_name, dev_name(&iter->dev)); 1497 - if (ret) 1498 - continue; 1499 - udc = iter; 1500 - break; 1501 - } 1502 - if (ret) 1503 - ret = -ENODEV; 1504 - else if (udc->driver) 1607 + if (!driver->is_bound) { 1608 + if (driver->match_existing_only) { 1609 + pr_warn("%s: couldn't find an available UDC or it's busy\n", 1610 + driver->function); 1505 1611 ret = -EBUSY; 1506 - else 1507 - goto found; 1508 - } else { 1509 - list_for_each_entry(iter, &udc_list, list) { 1510 - /* For now we take the first one */ 1511 - if (iter->driver) 1512 - continue; 1513 - udc = iter; 1514 - goto found; 1612 + } else { 1613 + pr_info("%s: couldn't find an available UDC\n", 1614 + driver->function); 1615 + ret = 0; 1515 1616 } 1516 1617 } 1517 - 1518 - if (!driver->match_existing_only) { 1519 - list_add_tail(&driver->pending, &gadget_driver_pending_list); 1520 - pr_info("couldn't find an available UDC - added [%s] to list of pending drivers\n", 1521 - driver->function); 1522 - ret = 0; 1523 - } 1524 - 1525 1618 mutex_unlock(&udc_lock); 1619 + 1526 1620 if (ret) 1527 - pr_warn("couldn't find an available UDC or it's busy: %d\n", ret); 1528 - return ret; 1529 - found: 1530 - ret = udc_bind_to_driver(udc, driver); 1531 - mutex_unlock(&udc_lock); 1621 + driver_unregister(&driver->driver); 1532 1622 return ret; 1533 1623 } 1534 - EXPORT_SYMBOL_GPL(usb_gadget_probe_driver); 1624 + EXPORT_SYMBOL_GPL(usb_gadget_register_driver_owner); 1535 1625 1536 1626 int usb_gadget_unregister_driver(struct usb_gadget_driver *driver) 1537 1627 { 1538 - struct usb_udc *udc = NULL; 1539 - int ret = -ENODEV; 1540 - 1541 1628 if (!driver || !driver->unbind) 1542 1629 return -EINVAL; 1543 1630 1544 - mutex_lock(&udc_lock); 1545 - list_for_each_entry(udc, &udc_list, list) { 1546 - if (udc->driver == driver) { 1547 - usb_gadget_remove_driver(udc); 1548 - usb_gadget_set_state(udc->gadget, 1549 - USB_STATE_NOTATTACHED); 1550 - 1551 - /* Maybe there is someone waiting for this UDC? */ 1552 - check_pending_gadget_drivers(udc); 1553 - /* 1554 - * For now we ignore bind errors as probably it's 1555 - * not a valid reason to fail other's gadget unbind 1556 - */ 1557 - ret = 0; 1558 - break; 1559 - } 1560 - } 1561 - 1562 - if (ret) { 1563 - list_del(&driver->pending); 1564 - ret = 0; 1565 - } 1566 - mutex_unlock(&udc_lock); 1567 - return ret; 1631 + driver_unregister(&driver->driver); 1632 + return 0; 1568 1633 } 1569 1634 EXPORT_SYMBOL_GPL(usb_gadget_unregister_driver); 1570 1635 ··· 1740 1757 return 0; 1741 1758 } 1742 1759 1760 + static struct bus_type gadget_bus_type = { 1761 + .name = "gadget", 1762 + .probe = gadget_bind_driver, 1763 + .remove = gadget_unbind_driver, 1764 + .match = gadget_match_driver, 1765 + }; 1766 + 1743 1767 static int __init usb_udc_init(void) 1744 1768 { 1769 + int rc; 1770 + 1745 1771 udc_class = class_create(THIS_MODULE, "udc"); 1746 1772 if (IS_ERR(udc_class)) { 1747 1773 pr_err("failed to create udc class --> %ld\n", ··· 1759 1767 } 1760 1768 1761 1769 udc_class->dev_uevent = usb_udc_uevent; 1762 - return 0; 1770 + 1771 + rc = bus_register(&gadget_bus_type); 1772 + if (rc) 1773 + class_destroy(udc_class); 1774 + return rc; 1763 1775 } 1764 1776 subsys_initcall(usb_udc_init); 1765 1777 1766 1778 static void __exit usb_udc_exit(void) 1767 1779 { 1780 + bus_unregister(&gadget_bus_type); 1768 1781 class_destroy(udc_class); 1769 1782 } 1770 1783 module_exit(usb_udc_exit);
+3 -3
drivers/usb/gadget/udc/net2272.c
··· 71 71 module_param(dma_ep, ushort, 0644); 72 72 73 73 /* 74 - * dma_mode: net2272 dma mode setting (see LOCCTL1 definiton): 74 + * dma_mode: net2272 dma mode setting (see LOCCTL1 definition): 75 75 * mode 0 == Slow DREQ mode 76 76 * mode 1 == Fast DREQ mode 77 77 * mode 2 == Burst mode ··· 97 97 /* 98 98 * enable_suspend: When enabled, the driver will respond to 99 99 * USB suspend requests by powering down the NET2272. Otherwise, 100 - * USB suspend requests will be ignored. This is acceptible for 100 + * USB suspend requests will be ignored. This is acceptable for 101 101 * self-powered devices. For bus powered devices set this to 1. 102 102 */ 103 103 static ushort enable_suspend = 0; ··· 288 288 | (1 << LOCAL_OUT_ZLP) 289 289 | (1 << BUFFER_FLUSH)); 290 290 291 - /* fifo size is handled seperately */ 291 + /* fifo size is handled separately */ 292 292 } 293 293 294 294 static int net2272_disable(struct usb_ep *_ep)
+3 -11
drivers/usb/gadget/udc/net2280.c
··· 932 932 static inline void 933 933 queue_dma(struct net2280_ep *ep, struct net2280_request *req, int valid) 934 934 { 935 - struct net2280_dma *end; 936 - dma_addr_t tmp; 937 - 938 935 /* swap new dummy for old, link; fill and maybe activate */ 939 - end = ep->dummy; 940 - ep->dummy = req->td; 941 - req->td = end; 936 + swap(ep->dummy, req->td); 937 + swap(ep->td_dma, req->td_dma); 942 938 943 - tmp = ep->td_dma; 944 - ep->td_dma = req->td_dma; 945 - req->td_dma = tmp; 946 - 947 - end->dmadesc = cpu_to_le32 (ep->td_dma); 939 + req->td->dmadesc = cpu_to_le32 (ep->td_dma); 948 940 949 941 fill_dma_desc(ep, req, valid); 950 942 }
+9 -7
drivers/usb/gadget/udc/omap_udc.c
··· 1470 1470 if (!udc->ep0_in) { 1471 1471 stat = 0; 1472 1472 /* read next OUT packet of request, maybe 1473 - * reactiviting the fifo; stall on errors. 1473 + * reactivating the fifo; stall on errors. 1474 1474 */ 1475 1475 stat = read_fifo(ep0, req); 1476 1476 if (!req || stat < 0) { ··· 2609 2609 if (udc->dc_clk) { 2610 2610 if (udc->clk_requested) 2611 2611 omap_udc_enable_clock(0); 2612 + clk_unprepare(udc->hhc_clk); 2613 + clk_unprepare(udc->dc_clk); 2612 2614 clk_put(udc->hhc_clk); 2613 2615 clk_put(udc->dc_clk); 2614 2616 } ··· 2775 2773 hhc_clk = clk_get(&pdev->dev, "usb_hhc_ck"); 2776 2774 BUG_ON(IS_ERR(dc_clk) || IS_ERR(hhc_clk)); 2777 2775 /* can't use omap_udc_enable_clock yet */ 2778 - clk_enable(dc_clk); 2779 - clk_enable(hhc_clk); 2776 + clk_prepare_enable(dc_clk); 2777 + clk_prepare_enable(hhc_clk); 2780 2778 udelay(100); 2781 2779 } 2782 2780 ··· 2785 2783 hhc_clk = clk_get(&pdev->dev, "l3_ocpi_ck"); 2786 2784 BUG_ON(IS_ERR(dc_clk) || IS_ERR(hhc_clk)); 2787 2785 /* can't use omap_udc_enable_clock yet */ 2788 - clk_enable(dc_clk); 2789 - clk_enable(hhc_clk); 2786 + clk_prepare_enable(dc_clk); 2787 + clk_prepare_enable(hhc_clk); 2790 2788 udelay(100); 2791 2789 } 2792 2790 ··· 2934 2932 usb_put_phy(xceiv); 2935 2933 2936 2934 if (cpu_is_omap16xx() || cpu_is_omap7xx()) { 2937 - clk_disable(hhc_clk); 2938 - clk_disable(dc_clk); 2935 + clk_disable_unprepare(hhc_clk); 2936 + clk_disable_unprepare(dc_clk); 2939 2937 clk_put(hhc_clk); 2940 2938 clk_put(dc_clk); 2941 2939 }
+1 -1
drivers/usb/gadget/udc/pxa27x_udc.h
··· 326 326 * @addr: usb endpoint number 327 327 * @config: configuration in which this endpoint is active 328 328 * @interface: interface in which this endpoint is active 329 - * @alternate: altsetting in which this endpoitn is active 329 + * @alternate: altsetting in which this endpoint is active 330 330 * @fifo_size: max packet size in the endpoint fifo 331 331 * @type: endpoint type (bulk, iso, int, ...) 332 332 * @udccsr_value: save register of UDCCSR0 for suspend/resume
+2 -2
drivers/usb/gadget/udc/s3c-hsudc.c
··· 126 126 /** 127 127 * struct s3c_hsudc - Driver's abstraction of the device controller. 128 128 * @gadget: Instance of usb_gadget which is referenced by gadget driver. 129 - * @driver: Reference to currenty active gadget driver. 129 + * @driver: Reference to currently active gadget driver. 130 130 * @dev: The device reference used by probe function. 131 131 * @lock: Lock to synchronize the usage of Endpoints (EP's are indexed). 132 132 * @regs: Remapped base address of controller's register space. ··· 633 633 } 634 634 635 635 /** s3c_hsudc_handle_ep0_intr - Handle endpoint 0 interrupt. 636 - * @hsudc: Device controller on which endpoint 0 interrupt has occured. 636 + * @hsudc: Device controller on which endpoint 0 interrupt has occurred. 637 637 * 638 638 * Handle endpoint 0 interrupt when it occurs. EP0 interrupt could occur 639 639 * when a stall handshake is sent to host or data is sent/received on
+2 -2
drivers/usb/gadget/udc/tegra-xudc.c
··· 1434 1434 return 0; 1435 1435 } 1436 1436 1437 - /* Halt DMA for this endpiont. */ 1437 + /* Halt DMA for this endpoint. */ 1438 1438 if (ep_ctx_read_state(ep->context) == EP_STATE_RUNNING) { 1439 1439 ep_pause(xudc, ep->index); 1440 1440 ep_wait_for_inactive(xudc, ep->index); ··· 3423 3423 } 3424 3424 3425 3425 /* 3426 - * Compliacne suite appears to be violating polling LFPS tBurst max 3426 + * Compliance suite appears to be violating polling LFPS tBurst max 3427 3427 * of 1.4us. Send 1.45us instead. 3428 3428 */ 3429 3429 val = xudc_readl(xudc, SSPX_CORE_CNT32);
+1 -1
drivers/usb/gadget/udc/udc-xilinx.c
··· 632 632 dev_dbg(udc->dev, "read %s, %d bytes%s req %p %d/%d\n", 633 633 ep->ep_usb.name, count, is_short ? "/S" : "", req, 634 634 req->usb_req.actual, req->usb_req.length); 635 - bufferspace -= count; 635 + 636 636 /* Completion */ 637 637 if ((req->usb_req.actual == req->usb_req.length) || is_short) { 638 638 if (udc->dma_enabled && req->usb_req.length)
-5
drivers/usb/host/ehci-omap.c
··· 61 61 __raw_writel(val, base + reg); 62 62 } 63 63 64 - static inline u32 ehci_read(void __iomem *base, u32 reg) 65 - { 66 - return __raw_readl(base + reg); 67 - } 68 - 69 64 /* configure so an HC device and id are always provided */ 70 65 /* always called with process context; sleeping is OK */ 71 66
+1
drivers/usb/host/ehci-platform.c
··· 518 518 .pm = pm_ptr(&ehci_platform_pm_ops), 519 519 .of_match_table = vt8500_ehci_ids, 520 520 .acpi_match_table = ACPI_PTR(ehci_acpi_match), 521 + .probe_type = PROBE_PREFER_ASYNCHRONOUS, 521 522 } 522 523 }; 523 524
+2 -2
drivers/usb/host/ehci-q.c
··· 645 645 token |= (1 /* "in" */ << 8); 646 646 /* else it's already initted to "out" pid (0 << 8) */ 647 647 648 - maxpacket = usb_maxpacket(urb->dev, urb->pipe, !is_input); 648 + maxpacket = usb_maxpacket(urb->dev, urb->pipe); 649 649 650 650 /* 651 651 * buffer gets wrapped in one or more qtds; ··· 1218 1218 1219 1219 token |= (1 /* "in" */ << 8); /*This is IN stage*/ 1220 1220 1221 - maxpacket = usb_maxpacket(urb->dev, urb->pipe, 0); 1221 + maxpacket = usb_maxpacket(urb->dev, urb->pipe); 1222 1222 1223 1223 qtd_fill(ehci, qtd, buf, len, token, maxpacket); 1224 1224
+8 -4
drivers/usb/host/ehci-xilinx-of.c
··· 32 32 * There are cases when the host controller fails to enable the port due to, 33 33 * for example, insufficient power that can be supplied to the device from 34 34 * the USB bus. In those cases, the messages printed here are not helpful. 35 + * 36 + * Return: Always return 0 35 37 */ 36 38 static int ehci_xilinx_port_handed_over(struct usb_hcd *hcd, int portnum) 37 39 { ··· 48 46 dev_warn(hcd->self.controller, 49 47 "Maybe your device is not a high speed device?\n"); 50 48 dev_warn(hcd->self.controller, 51 - "The USB host controller does not support full speed " 52 - "nor low speed devices\n"); 49 + "The USB host controller does not support full speed nor low speed devices\n"); 53 50 dev_warn(hcd->self.controller, 54 - "You can reconfigure the host controller to have " 55 - "full speed support\n"); 51 + "You can reconfigure the host controller to have full speed support\n"); 56 52 } 57 53 58 54 return 0; ··· 112 112 * host controller. Because the Xilinx USB host controller can be configured 113 113 * as HS only or HS/FS only, it checks the configuration in the device tree 114 114 * entry, and sets an appropriate value for hcd->has_tt. 115 + * 116 + * Return: zero on success, negative error code otherwise 115 117 */ 116 118 static int ehci_hcd_xilinx_of_probe(struct platform_device *op) 117 119 { ··· 198 196 * 199 197 * Remove the hcd structure, and release resources that has been requested 200 198 * during probe. 199 + * 200 + * Return: Always return 0 201 201 */ 202 202 static int ehci_hcd_xilinx_of_remove(struct platform_device *op) 203 203 {
+1 -2
drivers/usb/host/fhci-hcd.c
··· 408 408 size++; 409 409 else if ((urb->transfer_flags & URB_ZERO_PACKET) != 0 410 410 && (urb->transfer_buffer_length 411 - % usb_maxpacket(urb->dev, pipe, 412 - usb_pipeout(pipe))) != 0) 411 + % usb_maxpacket(urb->dev, pipe)) != 0) 413 412 size++; 414 413 break; 415 414 case PIPE_ISOCHRONOUS:
+1 -1
drivers/usb/host/fotg210-hcd.c
··· 2596 2596 token |= (1 /* "in" */ << 8); 2597 2597 /* else it's already initted to "out" pid (0 << 8) */ 2598 2598 2599 - maxpacket = usb_maxpacket(urb->dev, urb->pipe, !is_input); 2599 + maxpacket = usb_maxpacket(urb->dev, urb->pipe); 2600 2600 2601 2601 /* 2602 2602 * buffer gets wrapped in one or more qtds;
+6 -5
drivers/usb/host/isp116x-hcd.c
··· 726 726 INIT_LIST_HEAD(&ep->schedule); 727 727 ep->udev = udev; 728 728 ep->epnum = epnum; 729 - ep->maxpacket = usb_maxpacket(udev, urb->pipe, is_out); 729 + ep->maxpacket = usb_maxpacket(udev, urb->pipe); 730 730 usb_settoggle(udev, epnum, is_out, 0); 731 731 732 732 if (type == PIPE_CONTROL) { ··· 757 757 ep->load = usb_calc_bus_time(udev->speed, 758 758 !is_out, 759 759 (type == PIPE_ISOCHRONOUS), 760 - usb_maxpacket(udev, pipe, 761 - is_out)) / 760 + usb_maxpacket(udev, pipe)) / 762 761 1000; 763 762 } 764 763 hep->hcpriv = ep; ··· 1540 1541 1541 1542 iounmap(isp116x->data_reg); 1542 1543 res = platform_get_resource(pdev, IORESOURCE_MEM, 1); 1543 - release_mem_region(res->start, 2); 1544 + if (res) 1545 + release_mem_region(res->start, 2); 1544 1546 iounmap(isp116x->addr_reg); 1545 1547 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1546 - release_mem_region(res->start, 2); 1548 + if (res) 1549 + release_mem_region(res->start, 2); 1547 1550 1548 1551 usb_put_hcd(hcd); 1549 1552 return 0;
+3 -3
drivers/usb/host/isp1362-hcd.c
··· 1279 1279 ep->udev = usb_get_dev(udev); 1280 1280 ep->hep = hep; 1281 1281 ep->epnum = epnum; 1282 - ep->maxpacket = usb_maxpacket(udev, urb->pipe, is_out); 1282 + ep->maxpacket = usb_maxpacket(udev, urb->pipe); 1283 1283 ep->ptd_offset = -EINVAL; 1284 1284 ep->ptd_index = -EINVAL; 1285 1285 usb_settoggle(udev, epnum, is_out, 0); ··· 1299 1299 ep->interval = urb->interval; 1300 1300 ep->branch = PERIODIC_SIZE; 1301 1301 ep->load = usb_calc_bus_time(udev->speed, !is_out, 1302 - (type == PIPE_ISOCHRONOUS), 1303 - usb_maxpacket(udev, pipe, is_out)) / 1000; 1302 + type == PIPE_ISOCHRONOUS, 1303 + usb_maxpacket(udev, pipe)) / 1000; 1304 1304 break; 1305 1305 } 1306 1306 hep->hcpriv = ep;
+3 -3
drivers/usb/host/max3421-hcd.c
··· 546 546 return MAX3421_HXFR_BULK_OUT(epnum); 547 547 } 548 548 549 - max_packet = usb_maxpacket(urb->dev, urb->pipe, 1); 549 + max_packet = usb_maxpacket(urb->dev, urb->pipe); 550 550 551 551 if (max_packet > MAX3421_FIFO_SIZE) { 552 552 /* ··· 952 952 * USB 2.0 Section 5.3.2 Pipes: packets must be full size 953 953 * except for last one. 954 954 */ 955 - max_packet = usb_maxpacket(urb->dev, urb->pipe, 0); 955 + max_packet = usb_maxpacket(urb->dev, urb->pipe); 956 956 if (max_packet > MAX3421_FIFO_SIZE) { 957 957 /* 958 958 * We do not support isochronous transfers at this ··· 998 998 * max_packet as an indicator that the end of the 999 999 * packet has been reached). 1000 1000 */ 1001 - u32 max_packet = usb_maxpacket(urb->dev, urb->pipe, 1); 1001 + u32 max_packet = usb_maxpacket(urb->dev, urb->pipe); 1002 1002 1003 1003 if (max3421_hcd->curr_len == max_packet) 1004 1004 return 0;
+1 -2
drivers/usb/host/ohci-hcd.c
··· 181 181 size++; 182 182 else if ((urb->transfer_flags & URB_ZERO_PACKET) != 0 183 183 && (urb->transfer_buffer_length 184 - % usb_maxpacket (urb->dev, pipe, 185 - usb_pipeout (pipe))) == 0) 184 + % usb_maxpacket(urb->dev, pipe)) == 0) 186 185 size++; 187 186 break; 188 187 case PIPE_ISOCHRONOUS: /* number of packets from URB */
+16 -2
drivers/usb/host/ohci-omap.c
··· 259 259 goto err_put_hcd; 260 260 } 261 261 262 + retval = clk_prepare(priv->usb_host_ck); 263 + if (retval) 264 + goto err_put_host_ck; 265 + 262 266 if (!cpu_is_omap15xx()) 263 267 priv->usb_dc_ck = clk_get(&pdev->dev, "usb_dc_ck"); 264 268 else ··· 270 266 271 267 if (IS_ERR(priv->usb_dc_ck)) { 272 268 retval = PTR_ERR(priv->usb_dc_ck); 273 - goto err_put_host_ck; 269 + goto err_unprepare_host_ck; 274 270 } 271 + 272 + retval = clk_prepare(priv->usb_dc_ck); 273 + if (retval) 274 + goto err_put_dc_ck; 275 275 276 276 if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { 277 277 dev_dbg(&pdev->dev, "request_mem_region failed\n"); 278 278 retval = -EBUSY; 279 - goto err_put_dc_ck; 279 + goto err_unprepare_dc_ck; 280 280 } 281 281 282 282 hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); ··· 305 297 iounmap(hcd->regs); 306 298 err2: 307 299 release_mem_region(hcd->rsrc_start, hcd->rsrc_len); 300 + err_unprepare_dc_ck: 301 + clk_unprepare(priv->usb_dc_ck); 308 302 err_put_dc_ck: 309 303 clk_put(priv->usb_dc_ck); 304 + err_unprepare_host_ck: 305 + clk_unprepare(priv->usb_host_ck); 310 306 err_put_host_ck: 311 307 clk_put(priv->usb_host_ck); 312 308 err_put_hcd: ··· 345 333 } 346 334 iounmap(hcd->regs); 347 335 release_mem_region(hcd->rsrc_start, hcd->rsrc_len); 336 + clk_unprepare(priv->usb_dc_ck); 348 337 clk_put(priv->usb_dc_ck); 338 + clk_unprepare(priv->usb_host_ck); 349 339 clk_put(priv->usb_host_ck); 350 340 usb_put_hcd(hcd); 351 341 return 0;
+1
drivers/usb/host/ohci-platform.c
··· 334 334 .name = "ohci-platform", 335 335 .pm = &ohci_platform_pm_ops, 336 336 .of_match_table = ohci_platform_ids, 337 + .probe_type = PROBE_PREFER_ASYNCHRONOUS, 337 338 } 338 339 }; 339 340
-3
drivers/usb/host/ohci-ppc-of.c
··· 19 19 #include <linux/of_irq.h> 20 20 #include <linux/of_platform.h> 21 21 22 - #include <asm/prom.h> 23 - 24 - 25 22 static int 26 23 ohci_ppc_of_start(struct usb_hcd *hcd) 27 24 {
+7 -9
drivers/usb/host/oxu210hp-hcd.c
··· 1685 1685 token |= (1 /* "in" */ << 8); 1686 1686 /* else it's already initted to "out" pid (0 << 8) */ 1687 1687 1688 - maxpacket = usb_maxpacket(urb->dev, urb->pipe, !is_input); 1688 + maxpacket = usb_maxpacket(urb->dev, urb->pipe); 1689 1689 1690 1690 /* 1691 1691 * buffer gets wrapped in one or more qtds; ··· 1796 1796 1797 1797 is_input = usb_pipein(urb->pipe); 1798 1798 type = usb_pipetype(urb->pipe); 1799 - maxp = usb_maxpacket(urb->dev, urb->pipe, !is_input); 1799 + maxp = usb_maxpacket(urb->dev, urb->pipe); 1800 1800 1801 1801 /* Compute interrupt scheduling parameters just once, and save. 1802 1802 * - allowing for high bandwidth, how many nsec/uframe are used? ··· 3909 3909 } 3910 3910 } 3911 3911 3912 + spin_unlock_irq(&oxu->lock); 3912 3913 /* turn off now-idle HC */ 3913 3914 del_timer_sync(&oxu->watchdog); 3915 + spin_lock_irq(&oxu->lock); 3914 3916 ehci_halt(oxu); 3915 3917 hcd->state = HC_STATE_SUSPENDED; 3916 3918 ··· 4225 4223 /* 4226 4224 * Get the platform resources 4227 4225 */ 4228 - res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); 4229 - if (!res) { 4230 - dev_err(&pdev->dev, 4231 - "no IRQ! Check %s setup!\n", dev_name(&pdev->dev)); 4232 - return -ENODEV; 4233 - } 4234 - irq = res->start; 4226 + irq = platform_get_irq(pdev, 0); 4227 + if (irq < 0) 4228 + return irq; 4235 4229 dev_dbg(&pdev->dev, "IRQ resource %d\n", irq); 4236 4230 4237 4231 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+1 -2
drivers/usb/host/r8a66597-hcd.c
··· 1867 1867 td->pipe = hep->hcpriv; 1868 1868 td->urb = urb; 1869 1869 td->address = get_urb_to_r8a66597_addr(r8a66597, urb); 1870 - td->maxpacket = usb_maxpacket(urb->dev, urb->pipe, 1871 - !usb_pipein(urb->pipe)); 1870 + td->maxpacket = usb_maxpacket(urb->dev, urb->pipe); 1872 1871 if (usb_pipecontrol(urb->pipe)) 1873 1872 td->type = USB_PID_SETUP; 1874 1873 else if (usb_pipein(urb->pipe))
+3 -3
drivers/usb/host/sl811-hcd.c
··· 842 842 INIT_LIST_HEAD(&ep->schedule); 843 843 ep->udev = udev; 844 844 ep->epnum = epnum; 845 - ep->maxpacket = usb_maxpacket(udev, urb->pipe, is_out); 845 + ep->maxpacket = usb_maxpacket(udev, urb->pipe); 846 846 ep->defctrl = SL11H_HCTLMASK_ARM | SL11H_HCTLMASK_ENABLE; 847 847 usb_settoggle(udev, epnum, is_out, 0); 848 848 ··· 878 878 if (type == PIPE_ISOCHRONOUS) 879 879 ep->defctrl |= SL11H_HCTLMASK_ISOCH; 880 880 ep->load = usb_calc_bus_time(udev->speed, !is_out, 881 - (type == PIPE_ISOCHRONOUS), 882 - usb_maxpacket(udev, pipe, is_out)) 881 + type == PIPE_ISOCHRONOUS, 882 + usb_maxpacket(udev, pipe)) 883 883 / 1000; 884 884 break; 885 885 }
+2 -1
drivers/usb/host/xhci-hub.c
··· 707 707 u16 test_mode, u16 wIndex, unsigned long *flags) 708 708 __must_hold(&xhci->lock) 709 709 { 710 + struct usb_hcd *usb3_hcd = xhci_get_usb3_hcd(xhci); 710 711 int i, retval; 711 712 712 713 /* Disable all Device Slots */ ··· 728 727 xhci_dbg(xhci, "Disable all port (PP = 0)\n"); 729 728 /* Power off USB3 ports*/ 730 729 for (i = 0; i < xhci->usb3_rhub.num_ports; i++) 731 - xhci_set_port_power(xhci, xhci->shared_hcd, i, false, flags); 730 + xhci_set_port_power(xhci, usb3_hcd, i, false, flags); 732 731 /* Power off USB2 ports*/ 733 732 for (i = 0; i < xhci->usb2_rhub.num_ports; i++) 734 733 xhci_set_port_power(xhci, xhci->main_hcd, i, false, flags);
+8 -15
drivers/usb/host/xhci-mem.c
··· 782 782 783 783 /***************** Device context manipulation *************************/ 784 784 785 - static void xhci_init_endpoint_timer(struct xhci_hcd *xhci, 786 - struct xhci_virt_ep *ep) 787 - { 788 - timer_setup(&ep->stop_cmd_timer, xhci_stop_endpoint_command_watchdog, 789 - 0); 790 - ep->xhci = xhci; 791 - } 792 - 793 785 static void xhci_free_tt_info(struct xhci_hcd *xhci, 794 786 struct xhci_virt_device *virt_dev, 795 787 int slot_id) ··· 986 994 xhci_dbg(xhci, "Slot %d input ctx = 0x%llx (dma)\n", slot_id, 987 995 (unsigned long long)dev->in_ctx->dma); 988 996 989 - /* Initialize the cancellation list and watchdog timers for each ep */ 997 + /* Initialize the cancellation and bandwidth list for each ep */ 990 998 for (i = 0; i < 31; i++) { 991 999 dev->eps[i].ep_index = i; 992 1000 dev->eps[i].vdev = dev; 993 - xhci_init_endpoint_timer(xhci, &dev->eps[i]); 1001 + dev->eps[i].xhci = xhci; 994 1002 INIT_LIST_HEAD(&dev->eps[i].cancelled_td_list); 995 1003 INIT_LIST_HEAD(&dev->eps[i].bw_endpoint_list); 996 1004 } ··· 1064 1072 struct usb_hcd *hcd; 1065 1073 1066 1074 if (udev->speed >= USB_SPEED_SUPER) 1067 - hcd = xhci->shared_hcd; 1075 + hcd = xhci_get_usb3_hcd(xhci); 1068 1076 else 1069 1077 hcd = xhci->main_hcd; 1070 1078 ··· 2354 2362 xhci->usb2_rhub.num_ports = USB_MAXCHILDREN; 2355 2363 } 2356 2364 2357 - /* 2358 - * Note we could have all USB 3.0 ports, or all USB 2.0 ports. 2359 - * Not sure how the USB core will handle a hub with no ports... 2360 - */ 2365 + if (!xhci->usb2_rhub.num_ports) 2366 + xhci_info(xhci, "USB2 root hub has no ports\n"); 2367 + 2368 + if (!xhci->usb3_rhub.num_ports) 2369 + xhci_info(xhci, "USB3 root hub has no ports\n"); 2361 2370 2362 2371 xhci_create_rhub_port_array(xhci, &xhci->usb2_rhub, flags); 2363 2372 xhci_create_rhub_port_array(xhci, &xhci->usb3_rhub, flags);
+3 -2
drivers/usb/host/xhci-pci.c
··· 59 59 #define PCI_DEVICE_ID_INTEL_TIGER_LAKE_XHCI 0x9a13 60 60 #define PCI_DEVICE_ID_INTEL_MAPLE_RIDGE_XHCI 0x1138 61 61 #define PCI_DEVICE_ID_INTEL_ALDER_LAKE_XHCI 0x461e 62 + #define PCI_DEVICE_ID_INTEL_ALDER_LAKE_N_XHCI 0x464e 62 63 #define PCI_DEVICE_ID_INTEL_ALDER_LAKE_PCH_XHCI 0x51ed 63 64 64 65 #define PCI_DEVICE_ID_AMD_RENOIR_XHCI 0x1639 ··· 130 129 pdev->revision == 0x0) { 131 130 xhci->quirks |= XHCI_RESET_EP_QUIRK; 132 131 xhci_dbg_trace(xhci, trace_xhci_dbg_quirks, 133 - "QUIRK: Fresco Logic xHC needs configure" 134 - " endpoint cmd after reset endpoint"); 132 + "XHCI_RESET_EP_QUIRK for this evaluation HW is deprecated"); 135 133 } 136 134 if (pdev->device == PCI_DEVICE_ID_FRESCO_LOGIC_PDK && 137 135 pdev->revision == 0x4) { ··· 268 268 pdev->device == PCI_DEVICE_ID_INTEL_TIGER_LAKE_XHCI || 269 269 pdev->device == PCI_DEVICE_ID_INTEL_MAPLE_RIDGE_XHCI || 270 270 pdev->device == PCI_DEVICE_ID_INTEL_ALDER_LAKE_XHCI || 271 + pdev->device == PCI_DEVICE_ID_INTEL_ALDER_LAKE_N_XHCI || 271 272 pdev->device == PCI_DEVICE_ID_INTEL_ALDER_LAKE_PCH_XHCI)) 272 273 xhci->quirks |= XHCI_DEFAULT_PM_RUNTIME_ALLOW; 273 274
+28 -18
drivers/usb/host/xhci-plat.c
··· 180 180 struct device *sysdev, *tmpdev; 181 181 struct xhci_hcd *xhci; 182 182 struct resource *res; 183 - struct usb_hcd *hcd; 183 + struct usb_hcd *hcd, *usb3_hcd; 184 184 int ret; 185 185 int irq; 186 186 struct xhci_plat_priv *priv = NULL; ··· 245 245 246 246 xhci = hcd_to_xhci(hcd); 247 247 248 + xhci->allow_single_roothub = 1; 249 + 248 250 /* 249 251 * Not all platforms have clks so it is not an error if the 250 252 * clock do not exist. ··· 285 283 device_set_wakeup_capable(&pdev->dev, true); 286 284 287 285 xhci->main_hcd = hcd; 288 - xhci->shared_hcd = __usb_create_hcd(driver, sysdev, &pdev->dev, 289 - dev_name(&pdev->dev), hcd); 290 - if (!xhci->shared_hcd) { 291 - ret = -ENOMEM; 292 - goto disable_clk; 293 - } 294 286 295 287 /* imod_interval is the interrupt moderation value in nanoseconds. */ 296 288 xhci->imod_interval = 40000; ··· 309 313 if (IS_ERR(hcd->usb_phy)) { 310 314 ret = PTR_ERR(hcd->usb_phy); 311 315 if (ret == -EPROBE_DEFER) 312 - goto put_usb3_hcd; 316 + goto disable_clk; 313 317 hcd->usb_phy = NULL; 314 318 } else { 315 319 ret = usb_phy_init(hcd->usb_phy); 316 320 if (ret) 317 - goto put_usb3_hcd; 321 + goto disable_clk; 318 322 } 319 323 320 324 hcd->tpl_support = of_usb_host_tpl_support(sysdev->of_node); 321 - xhci->shared_hcd->tpl_support = hcd->tpl_support; 325 + 322 326 if (priv && (priv->quirks & XHCI_SKIP_PHY_INIT)) 323 327 hcd->skip_phy_initialization = 1; 324 328 ··· 329 333 if (ret) 330 334 goto disable_usb_phy; 331 335 332 - if (HCC_MAX_PSA(xhci->hcc_params) >= 4) 333 - xhci->shared_hcd->can_do_streams = 1; 336 + if (!xhci_has_one_roothub(xhci)) { 337 + xhci->shared_hcd = __usb_create_hcd(driver, sysdev, &pdev->dev, 338 + dev_name(&pdev->dev), hcd); 339 + if (!xhci->shared_hcd) { 340 + ret = -ENOMEM; 341 + goto dealloc_usb2_hcd; 342 + } 334 343 335 - ret = usb_add_hcd(xhci->shared_hcd, irq, IRQF_SHARED); 336 - if (ret) 337 - goto dealloc_usb2_hcd; 344 + xhci->shared_hcd->tpl_support = hcd->tpl_support; 345 + } 346 + 347 + usb3_hcd = xhci_get_usb3_hcd(xhci); 348 + if (usb3_hcd && HCC_MAX_PSA(xhci->hcc_params) >= 4) 349 + usb3_hcd->can_do_streams = 1; 350 + 351 + if (xhci->shared_hcd) { 352 + ret = usb_add_hcd(xhci->shared_hcd, irq, IRQF_SHARED); 353 + if (ret) 354 + goto put_usb3_hcd; 355 + } 338 356 339 357 device_enable_async_suspend(&pdev->dev); 340 358 pm_runtime_put_noidle(&pdev->dev); ··· 362 352 return 0; 363 353 364 354 355 + put_usb3_hcd: 356 + usb_put_hcd(xhci->shared_hcd); 357 + 365 358 dealloc_usb2_hcd: 366 359 usb_remove_hcd(hcd); 367 360 368 361 disable_usb_phy: 369 362 usb_phy_shutdown(hcd->usb_phy); 370 - 371 - put_usb3_hcd: 372 - usb_put_hcd(xhci->shared_hcd); 373 363 374 364 disable_clk: 375 365 clk_disable_unprepare(xhci->clk);
+39 -105
drivers/usb/host/xhci-ring.c
··· 740 740 } 741 741 } 742 742 743 - static void xhci_stop_watchdog_timer_in_irq(struct xhci_hcd *xhci, 744 - struct xhci_virt_ep *ep) 745 - { 746 - ep->ep_state &= ~EP_STOP_CMD_PENDING; 747 - /* Can't del_timer_sync in interrupt */ 748 - del_timer(&ep->stop_cmd_timer); 749 - } 750 - 751 743 /* 752 744 * Must be called with xhci->lock held in interrupt context, 753 745 * releases and re-acquires xhci->lock ··· 1114 1122 reset_type); 1115 1123 if (err) 1116 1124 break; 1117 - xhci_stop_watchdog_timer_in_irq(xhci, ep); 1125 + ep->ep_state &= ~EP_STOP_CMD_PENDING; 1118 1126 return; 1119 1127 case EP_STATE_RUNNING: 1120 1128 /* Race, HW handled stop ep cmd before ep was running */ 1121 1129 xhci_dbg(xhci, "Stop ep completion ctx error, ep is running\n"); 1122 1130 1123 1131 command = xhci_alloc_command(xhci, false, GFP_ATOMIC); 1124 - if (!command) 1125 - xhci_stop_watchdog_timer_in_irq(xhci, ep); 1126 - 1127 - mod_timer(&ep->stop_cmd_timer, 1128 - jiffies + XHCI_STOP_EP_CMD_TIMEOUT * HZ); 1132 + if (!command) { 1133 + ep->ep_state &= ~EP_STOP_CMD_PENDING; 1134 + return; 1135 + } 1129 1136 xhci_queue_stop_endpoint(xhci, command, slot_id, ep_index, 0); 1130 1137 xhci_ring_cmd_db(xhci); 1131 1138 ··· 1133 1142 break; 1134 1143 } 1135 1144 } 1145 + 1136 1146 /* will queue a set TR deq if stopped on a cancelled, uncleared TD */ 1137 1147 xhci_invalidate_cancelled_tds(ep); 1138 - xhci_stop_watchdog_timer_in_irq(xhci, ep); 1148 + ep->ep_state &= ~EP_STOP_CMD_PENDING; 1139 1149 1140 1150 /* Otherwise ring the doorbell(s) to restart queued transfers */ 1141 1151 xhci_giveback_invalidated_tds(ep); ··· 1238 1246 /* inform usb core hc died if PCI remove isn't already handling it */ 1239 1247 if (!(xhci->xhc_state & XHCI_STATE_REMOVING)) 1240 1248 usb_hc_died(xhci_to_hcd(xhci)); 1241 - } 1242 - 1243 - /* Watchdog timer function for when a stop endpoint command fails to complete. 1244 - * In this case, we assume the host controller is broken or dying or dead. The 1245 - * host may still be completing some other events, so we have to be careful to 1246 - * let the event ring handler and the URB dequeueing/enqueueing functions know 1247 - * through xhci->state. 1248 - * 1249 - * The timer may also fire if the host takes a very long time to respond to the 1250 - * command, and the stop endpoint command completion handler cannot delete the 1251 - * timer before the timer function is called. Another endpoint cancellation may 1252 - * sneak in before the timer function can grab the lock, and that may queue 1253 - * another stop endpoint command and add the timer back. So we cannot use a 1254 - * simple flag to say whether there is a pending stop endpoint command for a 1255 - * particular endpoint. 1256 - * 1257 - * Instead we use a combination of that flag and checking if a new timer is 1258 - * pending. 1259 - */ 1260 - void xhci_stop_endpoint_command_watchdog(struct timer_list *t) 1261 - { 1262 - struct xhci_virt_ep *ep = from_timer(ep, t, stop_cmd_timer); 1263 - struct xhci_hcd *xhci = ep->xhci; 1264 - unsigned long flags; 1265 - u32 usbsts; 1266 - char str[XHCI_MSG_MAX]; 1267 - 1268 - spin_lock_irqsave(&xhci->lock, flags); 1269 - 1270 - /* bail out if cmd completed but raced with stop ep watchdog timer.*/ 1271 - if (!(ep->ep_state & EP_STOP_CMD_PENDING) || 1272 - timer_pending(&ep->stop_cmd_timer)) { 1273 - spin_unlock_irqrestore(&xhci->lock, flags); 1274 - xhci_dbg(xhci, "Stop EP timer raced with cmd completion, exit"); 1275 - return; 1276 - } 1277 - usbsts = readl(&xhci->op_regs->status); 1278 - 1279 - xhci_warn(xhci, "xHCI host not responding to stop endpoint command.\n"); 1280 - xhci_warn(xhci, "USBSTS:%s\n", xhci_decode_usbsts(str, usbsts)); 1281 - 1282 - ep->ep_state &= ~EP_STOP_CMD_PENDING; 1283 - 1284 - xhci_halt(xhci); 1285 - 1286 - /* 1287 - * handle a stop endpoint cmd timeout as if host died (-ENODEV). 1288 - * In the future we could distinguish between -ENODEV and -ETIMEDOUT 1289 - * and try to recover a -ETIMEDOUT with a host controller reset 1290 - */ 1291 - xhci_hc_died(xhci); 1292 - 1293 - spin_unlock_irqrestore(&xhci->lock, flags); 1294 - xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb, 1295 - "xHCI host controller is dead."); 1296 1249 } 1297 1250 1298 1251 static void update_ring_for_set_deq_completion(struct xhci_hcd *xhci, ··· 1426 1489 /* Cleanup cancelled TDs as ep is stopped. May queue a Set TR Deq cmd */ 1427 1490 xhci_invalidate_cancelled_tds(ep); 1428 1491 1429 - if (xhci->quirks & XHCI_RESET_EP_QUIRK) 1430 - xhci_dbg(xhci, "Note: Removed workaround to queue config ep for this hw"); 1431 1492 /* Clear our internal halted state */ 1432 1493 ep->ep_state &= ~EP_HALTED; 1433 1494 ··· 1469 1534 struct xhci_input_control_ctx *ctrl_ctx; 1470 1535 struct xhci_ep_ctx *ep_ctx; 1471 1536 unsigned int ep_index; 1472 - unsigned int ep_state; 1473 - u32 add_flags, drop_flags; 1537 + u32 add_flags; 1474 1538 1475 1539 /* 1476 - * Configure endpoint commands can come from the USB core 1477 - * configuration or alt setting changes, or because the HW 1478 - * needed an extra configure endpoint command after a reset 1479 - * endpoint command or streams were being configured. 1480 - * If the command was for a halted endpoint, the xHCI driver 1481 - * is not waiting on the configure endpoint command. 1540 + * Configure endpoint commands can come from the USB core configuration 1541 + * or alt setting changes, or when streams were being configured. 1482 1542 */ 1543 + 1483 1544 virt_dev = xhci->devs[slot_id]; 1484 1545 if (!virt_dev) 1485 1546 return; ··· 1486 1555 } 1487 1556 1488 1557 add_flags = le32_to_cpu(ctrl_ctx->add_flags); 1489 - drop_flags = le32_to_cpu(ctrl_ctx->drop_flags); 1558 + 1490 1559 /* Input ctx add_flags are the endpoint index plus one */ 1491 1560 ep_index = xhci_last_valid_endpoint(add_flags) - 1; 1492 1561 1493 1562 ep_ctx = xhci_get_ep_ctx(xhci, virt_dev->out_ctx, ep_index); 1494 1563 trace_xhci_handle_cmd_config_ep(ep_ctx); 1495 1564 1496 - /* A usb_set_interface() call directly after clearing a halted 1497 - * condition may race on this quirky hardware. Not worth 1498 - * worrying about, since this is prototype hardware. Not sure 1499 - * if this will work for streams, but streams support was 1500 - * untested on this prototype. 1501 - */ 1502 - if (xhci->quirks & XHCI_RESET_EP_QUIRK && 1503 - ep_index != (unsigned int) -1 && 1504 - add_flags - SLOT_FLAG == drop_flags) { 1505 - ep_state = virt_dev->eps[ep_index].ep_state; 1506 - if (!(ep_state & EP_HALTED)) 1507 - return; 1508 - xhci_dbg_trace(xhci, trace_xhci_dbg_quirks, 1509 - "Completed config ep cmd - " 1510 - "last ep index = %d, state = %d", 1511 - ep_index, ep_state); 1512 - /* Clear internal halted state and restart ring(s) */ 1513 - virt_dev->eps[ep_index].ep_state &= ~EP_HALTED; 1514 - ring_doorbell_for_active_rings(xhci, slot_id, ep_index); 1515 - return; 1516 - } 1517 1565 return; 1518 1566 } 1519 1567 ··· 1560 1650 1561 1651 void xhci_handle_command_timeout(struct work_struct *work) 1562 1652 { 1563 - struct xhci_hcd *xhci; 1564 - unsigned long flags; 1565 - u64 hw_ring_state; 1653 + struct xhci_hcd *xhci; 1654 + unsigned long flags; 1655 + char str[XHCI_MSG_MAX]; 1656 + u64 hw_ring_state; 1657 + u32 cmd_field3; 1658 + u32 usbsts; 1566 1659 1567 1660 xhci = container_of(to_delayed_work(work), struct xhci_hcd, cmd_timer); 1568 1661 ··· 1579 1666 spin_unlock_irqrestore(&xhci->lock, flags); 1580 1667 return; 1581 1668 } 1669 + 1670 + cmd_field3 = le32_to_cpu(xhci->current_cmd->command_trb->generic.field[3]); 1671 + usbsts = readl(&xhci->op_regs->status); 1672 + xhci_dbg(xhci, "Command timeout, USBSTS:%s\n", xhci_decode_usbsts(str, usbsts)); 1673 + 1674 + /* Bail out and tear down xhci if a stop endpoint command failed */ 1675 + if (TRB_FIELD_TO_TYPE(cmd_field3) == TRB_STOP_RING) { 1676 + struct xhci_virt_ep *ep; 1677 + 1678 + xhci_warn(xhci, "xHCI host not responding to stop endpoint command\n"); 1679 + 1680 + ep = xhci_get_virt_ep(xhci, TRB_TO_SLOT_ID(cmd_field3), 1681 + TRB_TO_EP_INDEX(cmd_field3)); 1682 + if (ep) 1683 + ep->ep_state &= ~EP_STOP_CMD_PENDING; 1684 + 1685 + xhci_halt(xhci); 1686 + xhci_hc_died(xhci); 1687 + goto time_out_completed; 1688 + } 1689 + 1582 1690 /* mark this command to be cancelled */ 1583 1691 xhci->current_cmd->status = COMP_COMMAND_ABORTED; 1584 1692
+94 -81
drivers/usb/host/xhci.c
··· 486 486 487 487 xhci = from_timer(xhci, t, comp_mode_recovery_timer); 488 488 rhub = &xhci->usb3_rhub; 489 + hcd = rhub->hcd; 490 + 491 + if (!hcd) 492 + return; 489 493 490 494 for (i = 0; i < rhub->num_ports; i++) { 491 495 temp = readl(rhub->ports[i]->addr); ··· 503 499 i + 1); 504 500 xhci_dbg_trace(xhci, trace_xhci_dbg_quirks, 505 501 "Attempting compliance mode recovery"); 506 - hcd = xhci->shared_hcd; 507 502 508 503 if (hcd->state == HC_STATE_SUSPENDED) 509 504 usb_hcd_resume_root_hub(hcd); ··· 615 612 xhci_halt(xhci); 616 613 return -ENODEV; 617 614 } 618 - xhci->shared_hcd->state = HC_STATE_RUNNING; 619 615 xhci->cmd_ring_state = CMD_RING_STATE_RUNNING; 620 616 621 617 if (xhci->quirks & XHCI_NEC_HOST) 622 618 xhci_ring_cmd_db(xhci); 623 619 624 - xhci_dbg_trace(xhci, trace_xhci_dbg_init, 625 - "Finished xhci_run for USB3 roothub"); 626 620 return 0; 627 621 } 628 622 ··· 694 694 xhci_free_command(xhci, command); 695 695 } 696 696 xhci_dbg_trace(xhci, trace_xhci_dbg_init, 697 - "Finished xhci_run for USB2 roothub"); 697 + "Finished %s for main hcd", __func__); 698 698 699 699 xhci_create_dbc_dev(xhci); 700 700 701 701 xhci_debugfs_init(xhci); 702 + 703 + if (xhci_has_one_roothub(xhci)) 704 + return xhci_run_finished(xhci); 705 + 706 + set_bit(HCD_FLAG_DEFER_RH_REGISTER, &hcd->flags); 702 707 703 708 return 0; 704 709 } ··· 997 992 return 0; 998 993 999 994 if (hcd->state != HC_STATE_SUSPENDED || 1000 - xhci->shared_hcd->state != HC_STATE_SUSPENDED) 995 + (xhci->shared_hcd && xhci->shared_hcd->state != HC_STATE_SUSPENDED)) 1001 996 return -EINVAL; 1002 997 1003 998 /* Clear root port wake on bits if wakeup not allowed. */ ··· 1014 1009 __func__, hcd->self.busnum); 1015 1010 clear_bit(HCD_FLAG_POLL_RH, &hcd->flags); 1016 1011 del_timer_sync(&hcd->rh_timer); 1017 - clear_bit(HCD_FLAG_POLL_RH, &xhci->shared_hcd->flags); 1018 - del_timer_sync(&xhci->shared_hcd->rh_timer); 1012 + if (xhci->shared_hcd) { 1013 + clear_bit(HCD_FLAG_POLL_RH, &xhci->shared_hcd->flags); 1014 + del_timer_sync(&xhci->shared_hcd->rh_timer); 1015 + } 1019 1016 1020 1017 if (xhci->quirks & XHCI_SUSPEND_DELAY) 1021 1018 usleep_range(1000, 1500); 1022 1019 1023 1020 spin_lock_irq(&xhci->lock); 1024 1021 clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); 1025 - clear_bit(HCD_FLAG_HW_ACCESSIBLE, &xhci->shared_hcd->flags); 1022 + if (xhci->shared_hcd) 1023 + clear_bit(HCD_FLAG_HW_ACCESSIBLE, &xhci->shared_hcd->flags); 1026 1024 /* step 1: stop endpoint */ 1027 1025 /* skipped assuming that port suspend has done */ 1028 1026 ··· 1125 1117 msleep(100); 1126 1118 1127 1119 set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); 1128 - set_bit(HCD_FLAG_HW_ACCESSIBLE, &xhci->shared_hcd->flags); 1120 + if (xhci->shared_hcd) 1121 + set_bit(HCD_FLAG_HW_ACCESSIBLE, &xhci->shared_hcd->flags); 1129 1122 1130 1123 spin_lock_irq(&xhci->lock); 1131 1124 ··· 1186 1177 1187 1178 /* Let the USB core know _both_ roothubs lost power. */ 1188 1179 usb_root_hub_lost_power(xhci->main_hcd->self.root_hub); 1189 - usb_root_hub_lost_power(xhci->shared_hcd->self.root_hub); 1180 + if (xhci->shared_hcd) 1181 + usb_root_hub_lost_power(xhci->shared_hcd->self.root_hub); 1190 1182 1191 1183 xhci_dbg(xhci, "Stop HCD\n"); 1192 1184 xhci_halt(xhci); ··· 1227 1217 1228 1218 xhci_dbg(xhci, "Start the primary HCD\n"); 1229 1219 retval = xhci_run(hcd->primary_hcd); 1230 - if (!retval) { 1220 + if (!retval && secondary_hcd) { 1231 1221 xhci_dbg(xhci, "Start the secondary HCD\n"); 1232 1222 retval = xhci_run(secondary_hcd); 1233 1223 } 1234 1224 hcd->state = HC_STATE_SUSPENDED; 1235 - xhci->shared_hcd->state = HC_STATE_SUSPENDED; 1225 + if (xhci->shared_hcd) 1226 + xhci->shared_hcd->state = HC_STATE_SUSPENDED; 1236 1227 goto done; 1237 1228 } 1238 1229 ··· 1271 1260 } 1272 1261 1273 1262 if (pending_portevent) { 1274 - usb_hcd_resume_root_hub(xhci->shared_hcd); 1263 + if (xhci->shared_hcd) 1264 + usb_hcd_resume_root_hub(xhci->shared_hcd); 1275 1265 usb_hcd_resume_root_hub(hcd); 1276 1266 } 1277 1267 } ··· 1291 1279 /* Re-enable port polling. */ 1292 1280 xhci_dbg(xhci, "%s: starting usb%d port polling.\n", 1293 1281 __func__, hcd->self.busnum); 1294 - set_bit(HCD_FLAG_POLL_RH, &xhci->shared_hcd->flags); 1295 - usb_hcd_poll_rh_status(xhci->shared_hcd); 1282 + if (xhci->shared_hcd) { 1283 + set_bit(HCD_FLAG_POLL_RH, &xhci->shared_hcd->flags); 1284 + usb_hcd_poll_rh_status(xhci->shared_hcd); 1285 + } 1296 1286 set_bit(HCD_FLAG_POLL_RH, &hcd->flags); 1297 1287 usb_hcd_poll_rh_status(hcd); 1298 1288 ··· 1874 1860 goto done; 1875 1861 } 1876 1862 ep->ep_state |= EP_STOP_CMD_PENDING; 1877 - ep->stop_cmd_timer.expires = jiffies + 1878 - XHCI_STOP_EP_CMD_TIMEOUT * HZ; 1879 - add_timer(&ep->stop_cmd_timer); 1880 1863 xhci_queue_stop_endpoint(xhci, command, urb->dev->slot_id, 1881 1864 ep_index, 0); 1882 1865 xhci_ring_cmd_db(xhci); ··· 3983 3972 trace_xhci_free_dev(slot_ctx); 3984 3973 3985 3974 /* Stop any wayward timer functions (which may grab the lock) */ 3986 - for (i = 0; i < 31; i++) { 3975 + for (i = 0; i < 31; i++) 3987 3976 virt_dev->eps[i].ep_state &= ~EP_STOP_CMD_PENDING; 3988 - del_timer_sync(&virt_dev->eps[i].stop_cmd_timer); 3989 - } 3990 3977 virt_dev->udev = NULL; 3991 3978 xhci_disable_slot(xhci, udev->slot_id); 3992 3979 xhci_free_virt_device(xhci, udev->slot_id); ··· 4888 4879 struct usb_device *parent; 4889 4880 unsigned int num_hubs; 4890 4881 4891 - if (state == USB3_LPM_U2) 4892 - return 0; 4893 - 4894 4882 /* Don't enable U1 if the device is on a 2nd tier hub or lower. */ 4895 4883 for (parent = udev->parent, num_hubs = 0; parent->parent; 4896 4884 parent = parent->parent) ··· 4896 4890 if (num_hubs < 2) 4897 4891 return 0; 4898 4892 4899 - dev_dbg(&udev->dev, "Disabling U1 link state for device" 4893 + dev_dbg(&udev->dev, "Disabling U1/U2 link state for device" 4900 4894 " below second-tier hub.\n"); 4901 4895 dev_dbg(&udev->dev, "Plug device into first-tier hub " 4902 4896 "to decrease power consumption.\n"); ··· 4936 4930 state); 4937 4931 return timeout; 4938 4932 } 4939 - 4940 - if (xhci_check_tier_policy(xhci, udev, state) < 0) 4941 - return timeout; 4942 4933 4943 4934 /* Gather some information about the currently installed configuration 4944 4935 * and alternate interface settings. ··· 5041 5038 */ 5042 5039 if (!xhci || !(xhci->quirks & XHCI_LPM_SUPPORT) || 5043 5040 !xhci->devs[udev->slot_id]) 5041 + return USB3_LPM_DISABLED; 5042 + 5043 + if (xhci_check_tier_policy(xhci, udev, state) < 0) 5044 5044 return USB3_LPM_DISABLED; 5045 5045 5046 5046 hub_encoded_timeout = xhci_calculate_lpm_timeout(hcd, udev, state); ··· 5213 5207 return readl(&xhci->run_regs->microframe_index) >> 3; 5214 5208 } 5215 5209 5210 + static void xhci_hcd_init_usb2_data(struct xhci_hcd *xhci, struct usb_hcd *hcd) 5211 + { 5212 + xhci->usb2_rhub.hcd = hcd; 5213 + hcd->speed = HCD_USB2; 5214 + hcd->self.root_hub->speed = USB_SPEED_HIGH; 5215 + /* 5216 + * USB 2.0 roothub under xHCI has an integrated TT, 5217 + * (rate matching hub) as opposed to having an OHCI/UHCI 5218 + * companion controller. 5219 + */ 5220 + hcd->has_tt = 1; 5221 + } 5222 + 5223 + static void xhci_hcd_init_usb3_data(struct xhci_hcd *xhci, struct usb_hcd *hcd) 5224 + { 5225 + unsigned int minor_rev; 5226 + 5227 + /* 5228 + * Early xHCI 1.1 spec did not mention USB 3.1 capable hosts 5229 + * should return 0x31 for sbrn, or that the minor revision 5230 + * is a two digit BCD containig minor and sub-minor numbers. 5231 + * This was later clarified in xHCI 1.2. 5232 + * 5233 + * Some USB 3.1 capable hosts therefore have sbrn 0x30, and 5234 + * minor revision set to 0x1 instead of 0x10. 5235 + */ 5236 + if (xhci->usb3_rhub.min_rev == 0x1) 5237 + minor_rev = 1; 5238 + else 5239 + minor_rev = xhci->usb3_rhub.min_rev / 0x10; 5240 + 5241 + switch (minor_rev) { 5242 + case 2: 5243 + hcd->speed = HCD_USB32; 5244 + hcd->self.root_hub->speed = USB_SPEED_SUPER_PLUS; 5245 + hcd->self.root_hub->rx_lanes = 2; 5246 + hcd->self.root_hub->tx_lanes = 2; 5247 + hcd->self.root_hub->ssp_rate = USB_SSP_GEN_2x2; 5248 + break; 5249 + case 1: 5250 + hcd->speed = HCD_USB31; 5251 + hcd->self.root_hub->speed = USB_SPEED_SUPER_PLUS; 5252 + hcd->self.root_hub->ssp_rate = USB_SSP_GEN_2x1; 5253 + break; 5254 + } 5255 + xhci_info(xhci, "Host supports USB 3.%x %sSuperSpeed\n", 5256 + minor_rev, minor_rev ? "Enhanced " : ""); 5257 + 5258 + xhci->usb3_rhub.hcd = hcd; 5259 + } 5260 + 5216 5261 int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks) 5217 5262 { 5218 5263 struct xhci_hcd *xhci; ··· 5272 5215 * quirks 5273 5216 */ 5274 5217 struct device *dev = hcd->self.sysdev; 5275 - unsigned int minor_rev; 5276 5218 int retval; 5277 5219 5278 5220 /* Accept arbitrarily long scatter-gather lists */ ··· 5285 5229 5286 5230 xhci = hcd_to_xhci(hcd); 5287 5231 5288 - if (usb_hcd_is_primary_hcd(hcd)) { 5289 - xhci->main_hcd = hcd; 5290 - xhci->usb2_rhub.hcd = hcd; 5291 - /* Mark the first roothub as being USB 2.0. 5292 - * The xHCI driver will register the USB 3.0 roothub. 5293 - */ 5294 - hcd->speed = HCD_USB2; 5295 - hcd->self.root_hub->speed = USB_SPEED_HIGH; 5296 - /* 5297 - * USB 2.0 roothub under xHCI has an integrated TT, 5298 - * (rate matching hub) as opposed to having an OHCI/UHCI 5299 - * companion controller. 5300 - */ 5301 - hcd->has_tt = 1; 5302 - } else { 5303 - /* 5304 - * Early xHCI 1.1 spec did not mention USB 3.1 capable hosts 5305 - * should return 0x31 for sbrn, or that the minor revision 5306 - * is a two digit BCD containig minor and sub-minor numbers. 5307 - * This was later clarified in xHCI 1.2. 5308 - * 5309 - * Some USB 3.1 capable hosts therefore have sbrn 0x30, and 5310 - * minor revision set to 0x1 instead of 0x10. 5311 - */ 5312 - if (xhci->usb3_rhub.min_rev == 0x1) 5313 - minor_rev = 1; 5314 - else 5315 - minor_rev = xhci->usb3_rhub.min_rev / 0x10; 5316 - 5317 - switch (minor_rev) { 5318 - case 2: 5319 - hcd->speed = HCD_USB32; 5320 - hcd->self.root_hub->speed = USB_SPEED_SUPER_PLUS; 5321 - hcd->self.root_hub->rx_lanes = 2; 5322 - hcd->self.root_hub->tx_lanes = 2; 5323 - hcd->self.root_hub->ssp_rate = USB_SSP_GEN_2x2; 5324 - break; 5325 - case 1: 5326 - hcd->speed = HCD_USB31; 5327 - hcd->self.root_hub->speed = USB_SPEED_SUPER_PLUS; 5328 - hcd->self.root_hub->ssp_rate = USB_SSP_GEN_2x1; 5329 - break; 5330 - } 5331 - xhci_info(xhci, "Host supports USB 3.%x %sSuperSpeed\n", 5332 - minor_rev, 5333 - minor_rev ? "Enhanced " : ""); 5334 - 5335 - xhci->usb3_rhub.hcd = hcd; 5336 - /* xHCI private pointer was set in xhci_pci_probe for the second 5337 - * registered roothub. 5338 - */ 5232 + if (!usb_hcd_is_primary_hcd(hcd)) { 5233 + xhci_hcd_init_usb3_data(xhci, hcd); 5339 5234 return 0; 5340 5235 } 5341 5236 5342 5237 mutex_init(&xhci->mutex); 5238 + xhci->main_hcd = hcd; 5343 5239 xhci->cap_regs = hcd->regs; 5344 5240 xhci->op_regs = hcd->regs + 5345 5241 HC_LENGTH(readl(&xhci->cap_regs->hc_capbase)); ··· 5365 5357 if (retval) 5366 5358 return retval; 5367 5359 xhci_dbg(xhci, "Called HCD init\n"); 5360 + 5361 + if (xhci_hcd_is_usb3(hcd)) 5362 + xhci_hcd_init_usb3_data(xhci, hcd); 5363 + else 5364 + xhci_hcd_init_usb2_data(xhci, hcd); 5368 5365 5369 5366 xhci_info(xhci, "hcc params 0x%08x hci version 0x%x quirks 0x%016llx\n", 5370 5367 xhci->hcc_params, xhci->hci_version, xhci->quirks);
+27 -3
drivers/usb/host/xhci.h
··· 948 948 #define EP_CLEARING_TT (1 << 8) 949 949 /* ---- Related to URB cancellation ---- */ 950 950 struct list_head cancelled_td_list; 951 - /* Watchdog timer for stop endpoint command to cancel URBs */ 952 - struct timer_list stop_cmd_timer; 953 951 struct xhci_hcd *xhci; 954 952 /* Dequeue pointer and dequeue segment for a submitted Set TR Dequeue 955 953 * command. We'll need to update the ring's dequeue segment and dequeue ··· 1846 1848 #define XHCI_STATE_REMOVING (1 << 2) 1847 1849 unsigned long long quirks; 1848 1850 #define XHCI_LINK_TRB_QUIRK BIT_ULL(0) 1849 - #define XHCI_RESET_EP_QUIRK BIT_ULL(1) 1851 + #define XHCI_RESET_EP_QUIRK BIT_ULL(1) /* Deprecated */ 1850 1852 #define XHCI_NEC_HOST BIT_ULL(2) 1851 1853 #define XHCI_AMD_PLL_FIX BIT_ULL(3) 1852 1854 #define XHCI_SPURIOUS_SUCCESS BIT_ULL(4) ··· 1909 1911 unsigned hw_lpm_support:1; 1910 1912 /* Broken Suspend flag for SNPS Suspend resume issue */ 1911 1913 unsigned broken_suspend:1; 1914 + /* Indicates that omitting hcd is supported if root hub has no ports */ 1915 + unsigned allow_single_roothub:1; 1912 1916 /* cached usb2 extened protocol capabilites */ 1913 1917 u32 *ext_caps; 1914 1918 unsigned int num_ext_caps; ··· 1964 1964 static inline struct usb_hcd *xhci_to_hcd(struct xhci_hcd *xhci) 1965 1965 { 1966 1966 return xhci->main_hcd; 1967 + } 1968 + 1969 + static inline struct usb_hcd *xhci_get_usb3_hcd(struct xhci_hcd *xhci) 1970 + { 1971 + if (xhci->shared_hcd) 1972 + return xhci->shared_hcd; 1973 + 1974 + if (!xhci->usb2_rhub.num_ports) 1975 + return xhci->main_hcd; 1976 + 1977 + return NULL; 1978 + } 1979 + 1980 + static inline bool xhci_hcd_is_usb3(struct usb_hcd *hcd) 1981 + { 1982 + struct xhci_hcd *xhci = hcd_to_xhci(hcd); 1983 + 1984 + return hcd == xhci_get_usb3_hcd(xhci); 1985 + } 1986 + 1987 + static inline bool xhci_has_one_roothub(struct xhci_hcd *xhci) 1988 + { 1989 + return xhci->allow_single_roothub && 1990 + (!xhci->usb2_rhub.num_ports || !xhci->usb3_rhub.num_ports); 1967 1991 } 1968 1992 1969 1993 #define xhci_dbg(xhci, fmt, args...) \
+8
drivers/usb/isp1760/isp1760-core.c
··· 251 251 [HW_DM_PULLDOWN] = REG_FIELD(ISP176x_HC_OTG_CTRL, 2, 2), 252 252 [HW_DP_PULLDOWN] = REG_FIELD(ISP176x_HC_OTG_CTRL, 1, 1), 253 253 [HW_DP_PULLUP] = REG_FIELD(ISP176x_HC_OTG_CTRL, 0, 0), 254 + /* Make sure the array is sized properly during compilation */ 255 + [HC_FIELD_MAX] = {}, 254 256 }; 255 257 256 258 static const struct reg_field isp1763_hc_reg_fields[] = { ··· 323 321 [HW_DM_PULLDOWN_CLEAR] = REG_FIELD(ISP1763_HC_OTG_CTRL_CLEAR, 2, 2), 324 322 [HW_DP_PULLDOWN_CLEAR] = REG_FIELD(ISP1763_HC_OTG_CTRL_CLEAR, 1, 1), 325 323 [HW_DP_PULLUP_CLEAR] = REG_FIELD(ISP1763_HC_OTG_CTRL_CLEAR, 0, 0), 324 + /* Make sure the array is sized properly during compilation */ 325 + [HC_FIELD_MAX] = {}, 326 326 }; 327 327 328 328 static const struct regmap_range isp1763_hc_volatile_ranges[] = { ··· 409 405 [DC_CHIP_ID_HIGH] = REG_FIELD(ISP176x_DC_CHIPID, 16, 31), 410 406 [DC_CHIP_ID_LOW] = REG_FIELD(ISP176x_DC_CHIPID, 0, 15), 411 407 [DC_SCRATCH] = REG_FIELD(ISP176x_DC_SCRATCH, 0, 15), 408 + /* Make sure the array is sized properly during compilation */ 409 + [DC_FIELD_MAX] = {}, 412 410 }; 413 411 414 412 static const struct regmap_range isp1763_dc_volatile_ranges[] = { ··· 464 458 [DC_CHIP_ID_HIGH] = REG_FIELD(ISP1763_DC_CHIPID_HIGH, 0, 15), 465 459 [DC_CHIP_ID_LOW] = REG_FIELD(ISP1763_DC_CHIPID_LOW, 0, 15), 466 460 [DC_SCRATCH] = REG_FIELD(ISP1763_DC_SCRATCH, 0, 15), 461 + /* Make sure the array is sized properly during compilation */ 462 + [DC_FIELD_MAX] = {}, 467 463 }; 468 464 469 465 static const struct regmap_config isp1763_dc_regmap_conf = {
+2 -4
drivers/usb/isp1760/isp1760-hcd.c
··· 825 825 memset(ptd, 0, sizeof(*ptd)); 826 826 827 827 /* according to 3.6.2, max packet len can not be > 0x400 */ 828 - maxpacket = usb_maxpacket(qtd->urb->dev, qtd->urb->pipe, 829 - usb_pipeout(qtd->urb->pipe)); 828 + maxpacket = usb_maxpacket(qtd->urb->dev, qtd->urb->pipe); 830 829 multi = 1 + ((maxpacket >> 11) & 0x3); 831 830 maxpacket &= 0x7ff; 832 831 ··· 1807 1808 packet_type = IN_PID; 1808 1809 } 1809 1810 1810 - maxpacketsize = usb_maxpacket(urb->dev, urb->pipe, 1811 - usb_pipeout(urb->pipe)); 1811 + maxpacketsize = usb_maxpacket(urb->dev, urb->pipe); 1812 1812 1813 1813 /* 1814 1814 * buffer gets wrapped in one or more qtds;
+5 -10
drivers/usb/misc/ftdi-elan.c
··· 1449 1449 command->length = 0x8007; 1450 1450 command->address = (toggle_bits << 6) | (ep_number << 2) 1451 1451 | (address << 0); 1452 - command->width = usb_maxpacket(urb->dev, urb->pipe, 1453 - usb_pipeout(urb->pipe)); 1452 + command->width = usb_maxpacket(urb->dev, urb->pipe); 1454 1453 command->follows = 8; 1455 1454 command->value = 0; 1456 1455 command->buffer = urb->setup_packet; ··· 1513 1514 1); 1514 1515 command->address = (toggle_bits << 6) | (ep_number << 2) 1515 1516 | (address << 0); 1516 - command->width = usb_maxpacket(urb->dev, urb->pipe, 1517 - usb_pipeout(urb->pipe)); 1517 + command->width = usb_maxpacket(urb->dev, urb->pipe); 1518 1518 command->follows = 0; 1519 1519 command->value = 0; 1520 1520 command->buffer = NULL; ··· 1569 1571 command->length = 0x0000; 1570 1572 command->address = (toggle_bits << 6) | (ep_number << 2) 1571 1573 | (address << 0); 1572 - command->width = usb_maxpacket(urb->dev, urb->pipe, 1573 - usb_pipeout(urb->pipe)); 1574 + command->width = usb_maxpacket(urb->dev, urb->pipe); 1574 1575 command->follows = 0; 1575 1576 command->value = 0; 1576 1577 command->buffer = NULL; ··· 1631 1634 command->header = 0x81 | (ed << 5); 1632 1635 command->address = (toggle_bits << 6) | (ep_number << 2) 1633 1636 | (address << 0); 1634 - command->width = usb_maxpacket(urb->dev, urb->pipe, 1635 - usb_pipeout(urb->pipe)); 1637 + command->width = usb_maxpacket(urb->dev, urb->pipe); 1636 1638 command->follows = min_t(u32, 1024, 1637 1639 urb->transfer_buffer_length - 1638 1640 urb->actual_length); ··· 1711 1715 1); 1712 1716 command->address = (toggle_bits << 6) | (ep_number << 2) 1713 1717 | (address << 0); 1714 - command->width = usb_maxpacket(urb->dev, urb->pipe, 1715 - usb_pipeout(urb->pipe)); 1718 + command->width = usb_maxpacket(urb->dev, urb->pipe); 1716 1719 command->follows = 0; 1717 1720 command->value = 0; 1718 1721 command->buffer = NULL;
+1 -1
drivers/usb/misc/lvstest.c
··· 437 437 INIT_WORK(&lvs->rh_work, lvs_rh_work); 438 438 439 439 pipe = usb_rcvintpipe(hdev, endpoint->bEndpointAddress); 440 - maxp = usb_maxpacket(hdev, pipe, usb_pipeout(pipe)); 440 + maxp = usb_maxpacket(hdev, pipe); 441 441 usb_fill_int_urb(lvs->urb, hdev, pipe, &lvs->buffer[0], maxp, 442 442 lvs_rh_irq, lvs, endpoint->bInterval); 443 443
+10 -63
drivers/usb/musb/mediatek.c
··· 36 36 #define DMA_INTR_STATUS_MSK GENMASK(7, 0) 37 37 #define DMA_INTR_UNMASK_SET_MSK GENMASK(31, 24) 38 38 39 + #define MTK_MUSB_CLKS_NUM 3 40 + 39 41 struct mtk_glue { 40 42 struct device *dev; 41 43 struct musb *musb; ··· 46 44 struct phy *phy; 47 45 struct usb_phy *xceiv; 48 46 enum phy_mode phy_mode; 49 - struct clk *main; 50 - struct clk *mcu; 51 - struct clk *univpll; 47 + struct clk_bulk_data clks[MTK_MUSB_CLKS_NUM]; 52 48 enum usb_role role; 53 49 struct usb_role_switch *role_sw; 54 50 }; ··· 55 55 { 56 56 struct device *dev = glue->dev; 57 57 58 - glue->main = devm_clk_get(dev, "main"); 59 - if (IS_ERR(glue->main)) { 60 - dev_err(dev, "fail to get main clock\n"); 61 - return PTR_ERR(glue->main); 62 - } 58 + glue->clks[0].id = "main"; 59 + glue->clks[1].id = "mcu"; 60 + glue->clks[2].id = "univpll"; 63 61 64 - glue->mcu = devm_clk_get(dev, "mcu"); 65 - if (IS_ERR(glue->mcu)) { 66 - dev_err(dev, "fail to get mcu clock\n"); 67 - return PTR_ERR(glue->mcu); 68 - } 69 - 70 - glue->univpll = devm_clk_get(dev, "univpll"); 71 - if (IS_ERR(glue->univpll)) { 72 - dev_err(dev, "fail to get univpll clock\n"); 73 - return PTR_ERR(glue->univpll); 74 - } 75 - 76 - return 0; 77 - } 78 - 79 - static int mtk_musb_clks_enable(struct mtk_glue *glue) 80 - { 81 - int ret; 82 - 83 - ret = clk_prepare_enable(glue->main); 84 - if (ret) { 85 - dev_err(glue->dev, "failed to enable main clock\n"); 86 - goto err_main_clk; 87 - } 88 - 89 - ret = clk_prepare_enable(glue->mcu); 90 - if (ret) { 91 - dev_err(glue->dev, "failed to enable mcu clock\n"); 92 - goto err_mcu_clk; 93 - } 94 - 95 - ret = clk_prepare_enable(glue->univpll); 96 - if (ret) { 97 - dev_err(glue->dev, "failed to enable univpll clock\n"); 98 - goto err_univpll_clk; 99 - } 100 - 101 - return 0; 102 - 103 - err_univpll_clk: 104 - clk_disable_unprepare(glue->mcu); 105 - err_mcu_clk: 106 - clk_disable_unprepare(glue->main); 107 - err_main_clk: 108 - return ret; 109 - } 110 - 111 - static void mtk_musb_clks_disable(struct mtk_glue *glue) 112 - { 113 - clk_disable_unprepare(glue->univpll); 114 - clk_disable_unprepare(glue->mcu); 115 - clk_disable_unprepare(glue->main); 62 + return devm_clk_bulk_get(dev, MTK_MUSB_CLKS_NUM, glue->clks); 116 63 } 117 64 118 65 static int mtk_otg_switch_set(struct mtk_glue *glue, enum usb_role role) ··· 337 390 mtk_otg_switch_exit(glue); 338 391 phy_power_off(glue->phy); 339 392 phy_exit(glue->phy); 340 - mtk_musb_clks_disable(glue); 393 + clk_bulk_disable_unprepare(MTK_MUSB_CLKS_NUM, glue->clks); 341 394 342 395 pm_runtime_put_sync(dev); 343 396 pm_runtime_disable(dev); ··· 475 528 pm_runtime_enable(dev); 476 529 pm_runtime_get_sync(dev); 477 530 478 - ret = mtk_musb_clks_enable(glue); 531 + ret = clk_bulk_prepare_enable(MTK_MUSB_CLKS_NUM, glue->clks); 479 532 if (ret) 480 533 goto err_enable_clk; 481 534 ··· 498 551 return 0; 499 552 500 553 err_device_register: 501 - mtk_musb_clks_disable(glue); 554 + clk_bulk_disable_unprepare(MTK_MUSB_CLKS_NUM, glue->clks); 502 555 err_enable_clk: 503 556 pm_runtime_put_sync(dev); 504 557 pm_runtime_disable(dev);
+1
drivers/usb/musb/omap2430.c
··· 362 362 control_node = of_parse_phandle(np, "ctrl-module", 0); 363 363 if (control_node) { 364 364 control_pdev = of_find_device_by_node(control_node); 365 + of_node_put(control_node); 365 366 if (!control_pdev) { 366 367 dev_err(&pdev->dev, "Failed to get control device\n"); 367 368 ret = -EINVAL;
+1 -1
drivers/usb/serial/ftdi_sio.c
··· 1671 1671 if (priv->flags & ASYNC_LOW_LATENCY) 1672 1672 return sprintf(buf, "1\n"); 1673 1673 else 1674 - return sprintf(buf, "%i\n", priv->latency); 1674 + return sprintf(buf, "%u\n", priv->latency); 1675 1675 } 1676 1676 1677 1677 /* Write a new value of the latency timer, in units of milliseconds. */
+2
drivers/usb/serial/option.c
··· 1137 1137 { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EM12, 0xff, 0, 0) }, 1138 1138 { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, 0x0620, 0xff, 0xff, 0x30) }, /* EM160R-GL */ 1139 1139 { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, 0x0620, 0xff, 0, 0) }, 1140 + { USB_DEVICE_INTERFACE_CLASS(QUECTEL_VENDOR_ID, 0x0700, 0xff), /* BG95 */ 1141 + .driver_info = RSVD(3) | ZLP }, 1140 1142 { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_RM500Q, 0xff, 0xff, 0x30) }, 1141 1143 { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_RM500Q, 0xff, 0, 0) }, 1142 1144 { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_RM500Q, 0xff, 0xff, 0x10),
+3
drivers/usb/serial/pl2303.c
··· 421 421 bcdUSB = le16_to_cpu(desc->bcdUSB); 422 422 423 423 switch (bcdUSB) { 424 + case 0x101: 425 + /* USB 1.0.1? Let's assume they meant 1.1... */ 426 + fallthrough; 424 427 case 0x110: 425 428 switch (bcdDevice) { 426 429 case 0x300:
+2 -2
drivers/usb/storage/alauda.c
··· 1104 1104 1105 1105 us->extra = kzalloc(sizeof(struct alauda_info), GFP_NOIO); 1106 1106 if (!us->extra) 1107 - return USB_STOR_TRANSPORT_ERROR; 1107 + return -ENOMEM; 1108 1108 1109 1109 info = (struct alauda_info *) us->extra; 1110 1110 us->extra_destructor = alauda_info_destructor; ··· 1113 1113 altsetting->endpoint[0].desc.bEndpointAddress 1114 1114 & USB_ENDPOINT_NUMBER_MASK); 1115 1115 1116 - return USB_STOR_TRANSPORT_GOOD; 1116 + return 0; 1117 1117 } 1118 1118 1119 1119 static int alauda_transport(struct scsi_cmnd *srb, struct us_data *us)
+4 -4
drivers/usb/storage/isd200.c
··· 1449 1449 * Allocates (if necessary) and initializes the driver structure. 1450 1450 * 1451 1451 * RETURNS: 1452 - * ISD status code 1452 + * error status code 1453 1453 */ 1454 1454 static int isd200_init_info(struct us_data *us) 1455 1455 { ··· 1457 1457 1458 1458 info = kzalloc(sizeof(struct isd200_info), GFP_KERNEL); 1459 1459 if (!info) 1460 - return ISD200_ERROR; 1460 + return -ENOMEM; 1461 1461 1462 1462 info->id = kzalloc(ATA_ID_WORDS * 2, GFP_KERNEL); 1463 1463 info->RegsBuf = kmalloc(sizeof(info->ATARegs), GFP_KERNEL); ··· 1466 1466 if (!info->id || !info->RegsBuf || !info->srb.sense_buffer) { 1467 1467 isd200_free_info_ptrs(info); 1468 1468 kfree(info); 1469 - return ISD200_ERROR; 1469 + return -ENOMEM; 1470 1470 } 1471 1471 1472 1472 us->extra = info; 1473 1473 us->extra_destructor = isd200_free_info_ptrs; 1474 1474 1475 - return ISD200_GOOD; 1475 + return 0; 1476 1476 } 1477 1477 1478 1478 /**************************************************************************
+8 -7
drivers/usb/storage/karma.c
··· 174 174 175 175 static int rio_karma_init(struct us_data *us) 176 176 { 177 - int ret = 0; 178 177 struct karma_data *data = kzalloc(sizeof(struct karma_data), GFP_NOIO); 179 178 180 179 if (!data) 181 - goto out; 180 + return -ENOMEM; 182 181 183 182 data->recv = kmalloc(RIO_RECV_LEN, GFP_NOIO); 184 183 if (!data->recv) { 185 184 kfree(data); 186 - goto out; 185 + return -ENOMEM; 187 186 } 188 187 189 188 us->extra = data; 190 189 us->extra_destructor = rio_karma_destructor; 191 - ret = rio_karma_send_command(RIO_ENTER_STORAGE, us); 192 - data->in_storage = (ret == 0); 193 - out: 194 - return ret; 190 + if (rio_karma_send_command(RIO_ENTER_STORAGE, us)) 191 + return -EIO; 192 + 193 + data->in_storage = 1; 194 + 195 + return 0; 195 196 } 196 197 197 198 static struct scsi_host_template karma_host_template;
+1 -1
drivers/usb/storage/onetouch.c
··· 180 180 return -ENODEV; 181 181 182 182 pipe = usb_rcvintpipe(udev, endpoint->bEndpointAddress); 183 - maxp = usb_maxpacket(udev, pipe, usb_pipeout(pipe)); 183 + maxp = usb_maxpacket(udev, pipe); 184 184 maxp = min(maxp, ONETOUCH_PKT_LEN); 185 185 186 186 onetouch = kzalloc(sizeof(struct usb_onetouch), GFP_KERNEL);
+14 -14
drivers/usb/storage/shuttle_usbat.c
··· 1456 1456 1457 1457 us->extra = kzalloc(sizeof(struct usbat_info), GFP_NOIO); 1458 1458 if (!us->extra) 1459 - return 1; 1459 + return -ENOMEM; 1460 1460 1461 1461 info = (struct usbat_info *) (us->extra); 1462 1462 ··· 1465 1465 USBAT_UIO_OE1 | USBAT_UIO_OE0, 1466 1466 USBAT_UIO_EPAD | USBAT_UIO_1); 1467 1467 if (rc != USB_STOR_XFER_GOOD) 1468 - return USB_STOR_TRANSPORT_ERROR; 1468 + return -EIO; 1469 1469 1470 1470 usb_stor_dbg(us, "INIT 1\n"); 1471 1471 ··· 1473 1473 1474 1474 rc = usbat_read_user_io(us, status); 1475 1475 if (rc != USB_STOR_TRANSPORT_GOOD) 1476 - return rc; 1476 + return -EIO; 1477 1477 1478 1478 usb_stor_dbg(us, "INIT 2\n"); 1479 1479 1480 1480 rc = usbat_read_user_io(us, status); 1481 1481 if (rc != USB_STOR_XFER_GOOD) 1482 - return USB_STOR_TRANSPORT_ERROR; 1482 + return -EIO; 1483 1483 1484 1484 rc = usbat_read_user_io(us, status); 1485 1485 if (rc != USB_STOR_XFER_GOOD) 1486 - return USB_STOR_TRANSPORT_ERROR; 1486 + return -EIO; 1487 1487 1488 1488 usb_stor_dbg(us, "INIT 3\n"); 1489 1489 1490 1490 rc = usbat_select_and_test_registers(us); 1491 1491 if (rc != USB_STOR_TRANSPORT_GOOD) 1492 - return rc; 1492 + return -EIO; 1493 1493 1494 1494 usb_stor_dbg(us, "INIT 4\n"); 1495 1495 1496 1496 rc = usbat_read_user_io(us, status); 1497 1497 if (rc != USB_STOR_XFER_GOOD) 1498 - return USB_STOR_TRANSPORT_ERROR; 1498 + return -EIO; 1499 1499 1500 1500 usb_stor_dbg(us, "INIT 5\n"); 1501 1501 1502 1502 /* Enable peripheral control signals and card detect */ 1503 1503 rc = usbat_device_enable_cdt(us); 1504 1504 if (rc != USB_STOR_TRANSPORT_GOOD) 1505 - return rc; 1505 + return -EIO; 1506 1506 1507 1507 usb_stor_dbg(us, "INIT 6\n"); 1508 1508 1509 1509 rc = usbat_read_user_io(us, status); 1510 1510 if (rc != USB_STOR_XFER_GOOD) 1511 - return USB_STOR_TRANSPORT_ERROR; 1511 + return -EIO; 1512 1512 1513 1513 usb_stor_dbg(us, "INIT 7\n"); 1514 1514 ··· 1516 1516 1517 1517 rc = usbat_read_user_io(us, status); 1518 1518 if (rc != USB_STOR_XFER_GOOD) 1519 - return USB_STOR_TRANSPORT_ERROR; 1519 + return -EIO; 1520 1520 1521 1521 usb_stor_dbg(us, "INIT 8\n"); 1522 1522 1523 1523 rc = usbat_select_and_test_registers(us); 1524 1524 if (rc != USB_STOR_TRANSPORT_GOOD) 1525 - return rc; 1525 + return -EIO; 1526 1526 1527 1527 usb_stor_dbg(us, "INIT 9\n"); 1528 1528 1529 1529 /* At this point, we need to detect which device we are using */ 1530 1530 if (usbat_set_transport(us, info, devicetype)) 1531 - return USB_STOR_TRANSPORT_ERROR; 1531 + return -EIO; 1532 1532 1533 1533 usb_stor_dbg(us, "INIT 10\n"); 1534 1534 ··· 1539 1539 rc = usbat_set_shuttle_features(us, (USBAT_FEAT_ETEN | USBAT_FEAT_ET2 | USBAT_FEAT_ET1), 1540 1540 0x00, 0x88, 0x08, subcountH, subcountL); 1541 1541 if (rc != USB_STOR_XFER_GOOD) 1542 - return USB_STOR_TRANSPORT_ERROR; 1542 + return -EIO; 1543 1543 1544 1544 usb_stor_dbg(us, "INIT 11\n"); 1545 1545 1546 - return USB_STOR_TRANSPORT_GOOD; 1546 + return 0; 1547 1547 } 1548 1548 1549 1549 /*
+1 -1
drivers/usb/storage/transport.c
··· 363 363 usb_stor_dbg(us, "xfer %u bytes\n", length); 364 364 365 365 /* calculate the max packet size */ 366 - maxp = usb_maxpacket(us->pusb_dev, pipe, usb_pipeout(pipe)); 366 + maxp = usb_maxpacket(us->pusb_dev, pipe); 367 367 if (maxp > length) 368 368 maxp = length; 369 369
+1 -1
drivers/usb/typec/bus.c
··· 24 24 state.mode = conf; 25 25 state.data = data; 26 26 27 - return alt->mux->set(alt->mux, &state); 27 + return typec_mux_set(alt->mux, &state); 28 28 } 29 29 30 30 static int typec_altmode_set_state(struct typec_altmode *adev,
+205 -74
drivers/usb/typec/mux.c
··· 17 17 #include "class.h" 18 18 #include "mux.h" 19 19 20 + #define TYPEC_MUX_MAX_DEVS 3 21 + 22 + struct typec_switch { 23 + struct typec_switch_dev *sw_devs[TYPEC_MUX_MAX_DEVS]; 24 + unsigned int num_sw_devs; 25 + }; 26 + 20 27 static int switch_fwnode_match(struct device *dev, const void *fwnode) 21 28 { 22 - if (!is_typec_switch(dev)) 29 + if (!is_typec_switch_dev(dev)) 23 30 return 0; 24 31 25 32 return dev_fwnode(dev) == fwnode; ··· 56 49 dev = class_find_device(&typec_mux_class, NULL, fwnode, 57 50 switch_fwnode_match); 58 51 59 - return dev ? to_typec_switch(dev) : ERR_PTR(-EPROBE_DEFER); 52 + return dev ? to_typec_switch_dev(dev) : ERR_PTR(-EPROBE_DEFER); 60 53 } 61 54 62 55 /** ··· 70 63 */ 71 64 struct typec_switch *fwnode_typec_switch_get(struct fwnode_handle *fwnode) 72 65 { 66 + struct typec_switch_dev *sw_devs[TYPEC_MUX_MAX_DEVS]; 73 67 struct typec_switch *sw; 68 + int count; 69 + int err; 70 + int i; 74 71 75 - sw = fwnode_connection_find_match(fwnode, "orientation-switch", NULL, 76 - typec_switch_match); 77 - if (!IS_ERR_OR_NULL(sw)) 78 - WARN_ON(!try_module_get(sw->dev.parent->driver->owner)); 72 + sw = kzalloc(sizeof(*sw), GFP_KERNEL); 73 + if (!sw) 74 + return ERR_PTR(-ENOMEM); 75 + 76 + count = fwnode_connection_find_matches(fwnode, "orientation-switch", NULL, 77 + typec_switch_match, 78 + (void **)sw_devs, 79 + ARRAY_SIZE(sw_devs)); 80 + if (count <= 0) { 81 + kfree(sw); 82 + return NULL; 83 + } 84 + 85 + for (i = 0; i < count; i++) { 86 + if (IS_ERR(sw_devs[i])) { 87 + err = PTR_ERR(sw_devs[i]); 88 + goto put_sw_devs; 89 + } 90 + } 91 + 92 + for (i = 0; i < count; i++) { 93 + WARN_ON(!try_module_get(sw_devs[i]->dev.parent->driver->owner)); 94 + sw->sw_devs[i] = sw_devs[i]; 95 + } 96 + 97 + sw->num_sw_devs = count; 79 98 80 99 return sw; 100 + 101 + put_sw_devs: 102 + for (i = 0; i < count; i++) { 103 + if (!IS_ERR(sw_devs[i])) 104 + put_device(&sw_devs[i]->dev); 105 + } 106 + 107 + kfree(sw); 108 + 109 + return ERR_PTR(err); 81 110 } 82 111 EXPORT_SYMBOL_GPL(fwnode_typec_switch_get); 83 112 ··· 125 82 */ 126 83 void typec_switch_put(struct typec_switch *sw) 127 84 { 128 - if (!IS_ERR_OR_NULL(sw)) { 129 - module_put(sw->dev.parent->driver->owner); 130 - put_device(&sw->dev); 85 + struct typec_switch_dev *sw_dev; 86 + unsigned int i; 87 + 88 + if (IS_ERR_OR_NULL(sw)) 89 + return; 90 + 91 + for (i = 0; i < sw->num_sw_devs; i++) { 92 + sw_dev = sw->sw_devs[i]; 93 + 94 + module_put(sw_dev->dev.parent->driver->owner); 95 + put_device(&sw_dev->dev); 131 96 } 97 + kfree(sw); 132 98 } 133 99 EXPORT_SYMBOL_GPL(typec_switch_put); 134 100 135 101 static void typec_switch_release(struct device *dev) 136 102 { 137 - kfree(to_typec_switch(dev)); 103 + kfree(to_typec_switch_dev(dev)); 138 104 } 139 105 140 106 const struct device_type typec_switch_dev_type = { ··· 161 109 * connector to the USB controllers. USB Type-C plugs can be inserted 162 110 * right-side-up or upside-down. 163 111 */ 164 - struct typec_switch * 112 + struct typec_switch_dev * 165 113 typec_switch_register(struct device *parent, 166 114 const struct typec_switch_desc *desc) 167 115 { 168 - struct typec_switch *sw; 116 + struct typec_switch_dev *sw_dev; 169 117 int ret; 170 118 171 119 if (!desc || !desc->set) 172 120 return ERR_PTR(-EINVAL); 173 121 174 - sw = kzalloc(sizeof(*sw), GFP_KERNEL); 175 - if (!sw) 122 + sw_dev = kzalloc(sizeof(*sw_dev), GFP_KERNEL); 123 + if (!sw_dev) 176 124 return ERR_PTR(-ENOMEM); 177 125 178 - sw->set = desc->set; 126 + sw_dev->set = desc->set; 179 127 180 - device_initialize(&sw->dev); 181 - sw->dev.parent = parent; 182 - sw->dev.fwnode = desc->fwnode; 183 - sw->dev.class = &typec_mux_class; 184 - sw->dev.type = &typec_switch_dev_type; 185 - sw->dev.driver_data = desc->drvdata; 186 - dev_set_name(&sw->dev, "%s-switch", 187 - desc->name ? desc->name : dev_name(parent)); 188 - 189 - ret = device_add(&sw->dev); 128 + device_initialize(&sw_dev->dev); 129 + sw_dev->dev.parent = parent; 130 + sw_dev->dev.fwnode = desc->fwnode; 131 + sw_dev->dev.class = &typec_mux_class; 132 + sw_dev->dev.type = &typec_switch_dev_type; 133 + sw_dev->dev.driver_data = desc->drvdata; 134 + ret = dev_set_name(&sw_dev->dev, "%s-switch", desc->name ? desc->name : dev_name(parent)); 190 135 if (ret) { 191 - dev_err(parent, "failed to register switch (%d)\n", ret); 192 - put_device(&sw->dev); 136 + put_device(&sw_dev->dev); 193 137 return ERR_PTR(ret); 194 138 } 195 139 196 - return sw; 140 + ret = device_add(&sw_dev->dev); 141 + if (ret) { 142 + dev_err(parent, "failed to register switch (%d)\n", ret); 143 + put_device(&sw_dev->dev); 144 + return ERR_PTR(ret); 145 + } 146 + 147 + return sw_dev; 197 148 } 198 149 EXPORT_SYMBOL_GPL(typec_switch_register); 199 150 200 151 int typec_switch_set(struct typec_switch *sw, 201 152 enum typec_orientation orientation) 202 153 { 154 + struct typec_switch_dev *sw_dev; 155 + unsigned int i; 156 + int ret; 157 + 203 158 if (IS_ERR_OR_NULL(sw)) 204 159 return 0; 205 160 206 - return sw->set(sw, orientation); 161 + for (i = 0; i < sw->num_sw_devs; i++) { 162 + sw_dev = sw->sw_devs[i]; 163 + 164 + ret = sw_dev->set(sw_dev, orientation); 165 + if (ret) 166 + return ret; 167 + } 168 + 169 + return 0; 207 170 } 208 171 EXPORT_SYMBOL_GPL(typec_switch_set); 209 172 210 173 /** 211 174 * typec_switch_unregister - Unregister USB Type-C orientation switch 212 - * @sw: USB Type-C orientation switch 175 + * @sw_dev: USB Type-C orientation switch 213 176 * 214 177 * Unregister switch that was registered with typec_switch_register(). 215 178 */ 216 - void typec_switch_unregister(struct typec_switch *sw) 179 + void typec_switch_unregister(struct typec_switch_dev *sw_dev) 217 180 { 218 - if (!IS_ERR_OR_NULL(sw)) 219 - device_unregister(&sw->dev); 181 + if (!IS_ERR_OR_NULL(sw_dev)) 182 + device_unregister(&sw_dev->dev); 220 183 } 221 184 EXPORT_SYMBOL_GPL(typec_switch_unregister); 222 185 223 - void typec_switch_set_drvdata(struct typec_switch *sw, void *data) 186 + void typec_switch_set_drvdata(struct typec_switch_dev *sw_dev, void *data) 224 187 { 225 - dev_set_drvdata(&sw->dev, data); 188 + dev_set_drvdata(&sw_dev->dev, data); 226 189 } 227 190 EXPORT_SYMBOL_GPL(typec_switch_set_drvdata); 228 191 229 - void *typec_switch_get_drvdata(struct typec_switch *sw) 192 + void *typec_switch_get_drvdata(struct typec_switch_dev *sw_dev) 230 193 { 231 - return dev_get_drvdata(&sw->dev); 194 + return dev_get_drvdata(&sw_dev->dev); 232 195 } 233 196 EXPORT_SYMBOL_GPL(typec_switch_get_drvdata); 234 197 235 198 /* ------------------------------------------------------------------------- */ 236 199 200 + struct typec_mux { 201 + struct typec_mux_dev *mux_devs[TYPEC_MUX_MAX_DEVS]; 202 + unsigned int num_mux_devs; 203 + }; 204 + 237 205 static int mux_fwnode_match(struct device *dev, const void *fwnode) 238 206 { 239 - if (!is_typec_mux(dev)) 207 + if (!is_typec_mux_dev(dev)) 240 208 return 0; 241 209 242 210 return dev_fwnode(dev) == fwnode; ··· 318 246 dev = class_find_device(&typec_mux_class, NULL, fwnode, 319 247 mux_fwnode_match); 320 248 321 - return dev ? to_typec_mux(dev) : ERR_PTR(-EPROBE_DEFER); 249 + return dev ? to_typec_mux_dev(dev) : ERR_PTR(-EPROBE_DEFER); 322 250 } 323 251 324 252 /** ··· 334 262 struct typec_mux *fwnode_typec_mux_get(struct fwnode_handle *fwnode, 335 263 const struct typec_altmode_desc *desc) 336 264 { 265 + struct typec_mux_dev *mux_devs[TYPEC_MUX_MAX_DEVS]; 337 266 struct typec_mux *mux; 267 + int count; 268 + int err; 269 + int i; 338 270 339 - mux = fwnode_connection_find_match(fwnode, "mode-switch", (void *)desc, 340 - typec_mux_match); 341 - if (!IS_ERR_OR_NULL(mux)) 342 - WARN_ON(!try_module_get(mux->dev.parent->driver->owner)); 271 + mux = kzalloc(sizeof(*mux), GFP_KERNEL); 272 + if (!mux) 273 + return ERR_PTR(-ENOMEM); 274 + 275 + count = fwnode_connection_find_matches(fwnode, "mode-switch", 276 + (void *)desc, typec_mux_match, 277 + (void **)mux_devs, 278 + ARRAY_SIZE(mux_devs)); 279 + if (count <= 0) { 280 + kfree(mux); 281 + return NULL; 282 + } 283 + 284 + for (i = 0; i < count; i++) { 285 + if (IS_ERR(mux_devs[i])) { 286 + err = PTR_ERR(mux_devs[i]); 287 + goto put_mux_devs; 288 + } 289 + } 290 + 291 + for (i = 0; i < count; i++) { 292 + WARN_ON(!try_module_get(mux_devs[i]->dev.parent->driver->owner)); 293 + mux->mux_devs[i] = mux_devs[i]; 294 + } 295 + 296 + mux->num_mux_devs = count; 343 297 344 298 return mux; 299 + 300 + put_mux_devs: 301 + for (i = 0; i < count; i++) { 302 + if (!IS_ERR(mux_devs[i])) 303 + put_device(&mux_devs[i]->dev); 304 + } 305 + 306 + kfree(mux); 307 + 308 + return ERR_PTR(err); 345 309 } 346 310 EXPORT_SYMBOL_GPL(fwnode_typec_mux_get); 347 311 ··· 389 281 */ 390 282 void typec_mux_put(struct typec_mux *mux) 391 283 { 392 - if (!IS_ERR_OR_NULL(mux)) { 393 - module_put(mux->dev.parent->driver->owner); 394 - put_device(&mux->dev); 284 + struct typec_mux_dev *mux_dev; 285 + unsigned int i; 286 + 287 + if (IS_ERR_OR_NULL(mux)) 288 + return; 289 + 290 + for (i = 0; i < mux->num_mux_devs; i++) { 291 + mux_dev = mux->mux_devs[i]; 292 + module_put(mux_dev->dev.parent->driver->owner); 293 + put_device(&mux_dev->dev); 395 294 } 295 + kfree(mux); 396 296 } 397 297 EXPORT_SYMBOL_GPL(typec_mux_put); 398 298 399 299 int typec_mux_set(struct typec_mux *mux, struct typec_mux_state *state) 400 300 { 301 + struct typec_mux_dev *mux_dev; 302 + unsigned int i; 303 + int ret; 304 + 401 305 if (IS_ERR_OR_NULL(mux)) 402 306 return 0; 403 307 404 - return mux->set(mux, state); 308 + for (i = 0; i < mux->num_mux_devs; i++) { 309 + mux_dev = mux->mux_devs[i]; 310 + 311 + ret = mux_dev->set(mux_dev, state); 312 + if (ret) 313 + return ret; 314 + } 315 + 316 + return 0; 405 317 } 406 318 EXPORT_SYMBOL_GPL(typec_mux_set); 407 319 408 320 static void typec_mux_release(struct device *dev) 409 321 { 410 - kfree(to_typec_mux(dev)); 322 + kfree(to_typec_mux_dev(dev)); 411 323 } 412 324 413 325 const struct device_type typec_mux_dev_type = { ··· 445 317 * the pins on the connector need to be reconfigured. This function registers 446 318 * multiplexer switches routing the pins on the connector. 447 319 */ 448 - struct typec_mux * 320 + struct typec_mux_dev * 449 321 typec_mux_register(struct device *parent, const struct typec_mux_desc *desc) 450 322 { 451 - struct typec_mux *mux; 323 + struct typec_mux_dev *mux_dev; 452 324 int ret; 453 325 454 326 if (!desc || !desc->set) 455 327 return ERR_PTR(-EINVAL); 456 328 457 - mux = kzalloc(sizeof(*mux), GFP_KERNEL); 458 - if (!mux) 329 + mux_dev = kzalloc(sizeof(*mux_dev), GFP_KERNEL); 330 + if (!mux_dev) 459 331 return ERR_PTR(-ENOMEM); 460 332 461 - mux->set = desc->set; 333 + mux_dev->set = desc->set; 462 334 463 - device_initialize(&mux->dev); 464 - mux->dev.parent = parent; 465 - mux->dev.fwnode = desc->fwnode; 466 - mux->dev.class = &typec_mux_class; 467 - mux->dev.type = &typec_mux_dev_type; 468 - mux->dev.driver_data = desc->drvdata; 469 - dev_set_name(&mux->dev, "%s-mux", 470 - desc->name ? desc->name : dev_name(parent)); 471 - 472 - ret = device_add(&mux->dev); 335 + device_initialize(&mux_dev->dev); 336 + mux_dev->dev.parent = parent; 337 + mux_dev->dev.fwnode = desc->fwnode; 338 + mux_dev->dev.class = &typec_mux_class; 339 + mux_dev->dev.type = &typec_mux_dev_type; 340 + mux_dev->dev.driver_data = desc->drvdata; 341 + ret = dev_set_name(&mux_dev->dev, "%s-mux", desc->name ? desc->name : dev_name(parent)); 473 342 if (ret) { 474 - dev_err(parent, "failed to register mux (%d)\n", ret); 475 - put_device(&mux->dev); 343 + put_device(&mux_dev->dev); 476 344 return ERR_PTR(ret); 477 345 } 478 346 479 - return mux; 347 + ret = device_add(&mux_dev->dev); 348 + if (ret) { 349 + dev_err(parent, "failed to register mux (%d)\n", ret); 350 + put_device(&mux_dev->dev); 351 + return ERR_PTR(ret); 352 + } 353 + 354 + return mux_dev; 480 355 } 481 356 EXPORT_SYMBOL_GPL(typec_mux_register); 482 357 483 358 /** 484 359 * typec_mux_unregister - Unregister Multiplexer Switch 485 - * @mux: USB Type-C Connector Multiplexer/DeMultiplexer 360 + * @mux_dev: USB Type-C Connector Multiplexer/DeMultiplexer 486 361 * 487 362 * Unregister mux that was registered with typec_mux_register(). 488 363 */ 489 - void typec_mux_unregister(struct typec_mux *mux) 364 + void typec_mux_unregister(struct typec_mux_dev *mux_dev) 490 365 { 491 - if (!IS_ERR_OR_NULL(mux)) 492 - device_unregister(&mux->dev); 366 + if (!IS_ERR_OR_NULL(mux_dev)) 367 + device_unregister(&mux_dev->dev); 493 368 } 494 369 EXPORT_SYMBOL_GPL(typec_mux_unregister); 495 370 496 - void typec_mux_set_drvdata(struct typec_mux *mux, void *data) 371 + void typec_mux_set_drvdata(struct typec_mux_dev *mux_dev, void *data) 497 372 { 498 - dev_set_drvdata(&mux->dev, data); 373 + dev_set_drvdata(&mux_dev->dev, data); 499 374 } 500 375 EXPORT_SYMBOL_GPL(typec_mux_set_drvdata); 501 376 502 - void *typec_mux_get_drvdata(struct typec_mux *mux) 377 + void *typec_mux_get_drvdata(struct typec_mux_dev *mux_dev) 503 378 { 504 - return dev_get_drvdata(&mux->dev); 379 + return dev_get_drvdata(&mux_dev->dev); 505 380 } 506 381 EXPORT_SYMBOL_GPL(typec_mux_get_drvdata); 507 382
+6 -6
drivers/usb/typec/mux.h
··· 5 5 6 6 #include <linux/usb/typec_mux.h> 7 7 8 - struct typec_switch { 8 + struct typec_switch_dev { 9 9 struct device dev; 10 10 typec_switch_set_fn_t set; 11 11 }; 12 12 13 - struct typec_mux { 13 + struct typec_mux_dev { 14 14 struct device dev; 15 15 typec_mux_set_fn_t set; 16 16 }; 17 17 18 - #define to_typec_switch(_dev_) container_of(_dev_, struct typec_switch, dev) 19 - #define to_typec_mux(_dev_) container_of(_dev_, struct typec_mux, dev) 18 + #define to_typec_switch_dev(_dev_) container_of(_dev_, struct typec_switch_dev, dev) 19 + #define to_typec_mux_dev(_dev_) container_of(_dev_, struct typec_mux_dev, dev) 20 20 21 21 extern const struct device_type typec_switch_dev_type; 22 22 extern const struct device_type typec_mux_dev_type; 23 23 24 - #define is_typec_switch(dev) ((dev)->type == &typec_switch_dev_type) 25 - #define is_typec_mux(dev) ((dev)->type == &typec_mux_dev_type) 24 + #define is_typec_switch_dev(dev) ((dev)->type == &typec_switch_dev_type) 25 + #define is_typec_mux_dev(dev) ((dev)->type == &typec_mux_dev_type) 26 26 27 27 #endif /* __USB_TYPEC_MUX__ */
+10
drivers/usb/typec/mux/Kconfig
··· 2 2 3 3 menu "USB Type-C Multiplexer/DeMultiplexer Switch support" 4 4 5 + config TYPEC_MUX_FSA4480 6 + tristate "ON Semi FSA4480 Analog Audio Switch driver" 7 + depends on I2C 8 + select REGMAP_I2C 9 + help 10 + Driver for the ON Semiconductor FSA4480 Analog Audio Switch, which 11 + provides support for muxing analog audio and sideband signals on a 12 + common USB Type-C connector. 13 + If compiled as a module, the module will be named fsa4480. 14 + 5 15 config TYPEC_MUX_PI3USB30532 6 16 tristate "Pericom PI3USB30532 Type-C cross switch driver" 7 17 depends on I2C
+1
drivers/usb/typec/mux/Makefile
··· 1 1 # SPDX-License-Identifier: GPL-2.0 2 2 3 + obj-$(CONFIG_TYPEC_MUX_FSA4480) += fsa4480.o 3 4 obj-$(CONFIG_TYPEC_MUX_PI3USB30532) += pi3usb30532.o 4 5 obj-$(CONFIG_TYPEC_MUX_INTEL_PMC) += intel_pmc_mux.o
+218
drivers/usb/typec/mux/fsa4480.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + /* 3 + * Copyright (C) 2021-2022 Linaro Ltd. 4 + * Copyright (C) 2018-2020 The Linux Foundation 5 + */ 6 + 7 + #include <linux/bits.h> 8 + #include <linux/i2c.h> 9 + #include <linux/kernel.h> 10 + #include <linux/module.h> 11 + #include <linux/mutex.h> 12 + #include <linux/regmap.h> 13 + #include <linux/usb/typec_dp.h> 14 + #include <linux/usb/typec_mux.h> 15 + 16 + #define FSA4480_SWITCH_ENABLE 0x04 17 + #define FSA4480_SWITCH_SELECT 0x05 18 + #define FSA4480_SWITCH_STATUS1 0x07 19 + #define FSA4480_SLOW_L 0x08 20 + #define FSA4480_SLOW_R 0x09 21 + #define FSA4480_SLOW_MIC 0x0a 22 + #define FSA4480_SLOW_SENSE 0x0b 23 + #define FSA4480_SLOW_GND 0x0c 24 + #define FSA4480_DELAY_L_R 0x0d 25 + #define FSA4480_DELAY_L_MIC 0x0e 26 + #define FSA4480_DELAY_L_SENSE 0x0f 27 + #define FSA4480_DELAY_L_AGND 0x10 28 + #define FSA4480_RESET 0x1e 29 + #define FSA4480_MAX_REGISTER 0x1f 30 + 31 + #define FSA4480_ENABLE_DEVICE BIT(7) 32 + #define FSA4480_ENABLE_SBU GENMASK(6, 5) 33 + #define FSA4480_ENABLE_USB GENMASK(4, 3) 34 + 35 + #define FSA4480_SEL_SBU_REVERSE GENMASK(6, 5) 36 + #define FSA4480_SEL_USB GENMASK(4, 3) 37 + 38 + struct fsa4480 { 39 + struct i2c_client *client; 40 + 41 + /* used to serialize concurrent change requests */ 42 + struct mutex lock; 43 + 44 + struct typec_switch_dev *sw; 45 + struct typec_mux_dev *mux; 46 + 47 + struct regmap *regmap; 48 + 49 + u8 cur_enable; 50 + u8 cur_select; 51 + }; 52 + 53 + static const struct regmap_config fsa4480_regmap_config = { 54 + .reg_bits = 8, 55 + .val_bits = 8, 56 + .max_register = FSA4480_MAX_REGISTER, 57 + /* Accesses only done under fsa4480->lock */ 58 + .disable_locking = true, 59 + }; 60 + 61 + static int fsa4480_switch_set(struct typec_switch_dev *sw, 62 + enum typec_orientation orientation) 63 + { 64 + struct fsa4480 *fsa = typec_switch_get_drvdata(sw); 65 + u8 new_sel; 66 + 67 + mutex_lock(&fsa->lock); 68 + new_sel = FSA4480_SEL_USB; 69 + if (orientation == TYPEC_ORIENTATION_REVERSE) 70 + new_sel |= FSA4480_SEL_SBU_REVERSE; 71 + 72 + if (new_sel == fsa->cur_select) 73 + goto out_unlock; 74 + 75 + if (fsa->cur_enable & FSA4480_ENABLE_SBU) { 76 + /* Disable SBU output while re-configuring the switch */ 77 + regmap_write(fsa->regmap, FSA4480_SWITCH_ENABLE, 78 + fsa->cur_enable & ~FSA4480_ENABLE_SBU); 79 + 80 + /* 35us to allow the SBU switch to turn off */ 81 + usleep_range(35, 1000); 82 + } 83 + 84 + regmap_write(fsa->regmap, FSA4480_SWITCH_SELECT, new_sel); 85 + fsa->cur_select = new_sel; 86 + 87 + if (fsa->cur_enable & FSA4480_ENABLE_SBU) { 88 + regmap_write(fsa->regmap, FSA4480_SWITCH_ENABLE, fsa->cur_enable); 89 + 90 + /* 15us to allow the SBU switch to turn on again */ 91 + usleep_range(15, 1000); 92 + } 93 + 94 + out_unlock: 95 + mutex_unlock(&fsa->lock); 96 + 97 + return 0; 98 + } 99 + 100 + static int fsa4480_mux_set(struct typec_mux_dev *mux, struct typec_mux_state *state) 101 + { 102 + struct fsa4480 *fsa = typec_mux_get_drvdata(mux); 103 + u8 new_enable; 104 + 105 + mutex_lock(&fsa->lock); 106 + 107 + new_enable = FSA4480_ENABLE_DEVICE | FSA4480_ENABLE_USB; 108 + if (state->mode >= TYPEC_DP_STATE_A) 109 + new_enable |= FSA4480_ENABLE_SBU; 110 + 111 + if (new_enable == fsa->cur_enable) 112 + goto out_unlock; 113 + 114 + regmap_write(fsa->regmap, FSA4480_SWITCH_ENABLE, new_enable); 115 + fsa->cur_enable = new_enable; 116 + 117 + if (new_enable & FSA4480_ENABLE_SBU) { 118 + /* 15us to allow the SBU switch to turn off */ 119 + usleep_range(15, 1000); 120 + } 121 + 122 + out_unlock: 123 + mutex_unlock(&fsa->lock); 124 + 125 + return 0; 126 + } 127 + 128 + static int fsa4480_probe(struct i2c_client *client) 129 + { 130 + struct device *dev = &client->dev; 131 + struct typec_switch_desc sw_desc = { }; 132 + struct typec_mux_desc mux_desc = { }; 133 + struct fsa4480 *fsa; 134 + 135 + fsa = devm_kzalloc(dev, sizeof(*fsa), GFP_KERNEL); 136 + if (!fsa) 137 + return -ENOMEM; 138 + 139 + fsa->client = client; 140 + mutex_init(&fsa->lock); 141 + 142 + fsa->regmap = devm_regmap_init_i2c(client, &fsa4480_regmap_config); 143 + if (IS_ERR(fsa->regmap)) 144 + return dev_err_probe(dev, PTR_ERR(fsa->regmap), "failed to initialize regmap\n"); 145 + 146 + fsa->cur_enable = FSA4480_ENABLE_DEVICE | FSA4480_ENABLE_USB; 147 + fsa->cur_select = FSA4480_SEL_USB; 148 + 149 + /* set default settings */ 150 + regmap_write(fsa->regmap, FSA4480_SLOW_L, 0x00); 151 + regmap_write(fsa->regmap, FSA4480_SLOW_R, 0x00); 152 + regmap_write(fsa->regmap, FSA4480_SLOW_MIC, 0x00); 153 + regmap_write(fsa->regmap, FSA4480_SLOW_SENSE, 0x00); 154 + regmap_write(fsa->regmap, FSA4480_SLOW_GND, 0x00); 155 + regmap_write(fsa->regmap, FSA4480_DELAY_L_R, 0x00); 156 + regmap_write(fsa->regmap, FSA4480_DELAY_L_MIC, 0x00); 157 + regmap_write(fsa->regmap, FSA4480_DELAY_L_SENSE, 0x00); 158 + regmap_write(fsa->regmap, FSA4480_DELAY_L_AGND, 0x09); 159 + regmap_write(fsa->regmap, FSA4480_SWITCH_SELECT, fsa->cur_select); 160 + regmap_write(fsa->regmap, FSA4480_SWITCH_ENABLE, fsa->cur_enable); 161 + 162 + sw_desc.drvdata = fsa; 163 + sw_desc.fwnode = dev_fwnode(dev); 164 + sw_desc.set = fsa4480_switch_set; 165 + 166 + fsa->sw = typec_switch_register(dev, &sw_desc); 167 + if (IS_ERR(fsa->sw)) 168 + return dev_err_probe(dev, PTR_ERR(fsa->sw), "failed to register typec switch\n"); 169 + 170 + mux_desc.drvdata = fsa; 171 + mux_desc.fwnode = dev_fwnode(dev); 172 + mux_desc.set = fsa4480_mux_set; 173 + 174 + fsa->mux = typec_mux_register(dev, &mux_desc); 175 + if (IS_ERR(fsa->mux)) { 176 + typec_switch_unregister(fsa->sw); 177 + return dev_err_probe(dev, PTR_ERR(fsa->mux), "failed to register typec mux\n"); 178 + } 179 + 180 + i2c_set_clientdata(client, fsa); 181 + return 0; 182 + } 183 + 184 + static int fsa4480_remove(struct i2c_client *client) 185 + { 186 + struct fsa4480 *fsa = i2c_get_clientdata(client); 187 + 188 + typec_mux_unregister(fsa->mux); 189 + typec_switch_unregister(fsa->sw); 190 + 191 + return 0; 192 + } 193 + 194 + static const struct i2c_device_id fsa4480_table[] = { 195 + { "fsa4480" }, 196 + { } 197 + }; 198 + MODULE_DEVICE_TABLE(i2c, fsa4480_table); 199 + 200 + static const struct of_device_id fsa4480_of_table[] = { 201 + { .compatible = "fcs,fsa4480" }, 202 + { } 203 + }; 204 + MODULE_DEVICE_TABLE(of, fsa4480_of_table); 205 + 206 + static struct i2c_driver fsa4480_driver = { 207 + .driver = { 208 + .name = "fsa4480", 209 + .of_match_table = fsa4480_of_table, 210 + }, 211 + .probe_new = fsa4480_probe, 212 + .remove = fsa4480_remove, 213 + .id_table = fsa4480_table, 214 + }; 215 + module_i2c_driver(fsa4480_driver); 216 + 217 + MODULE_DESCRIPTION("ON Semiconductor FSA4480 driver"); 218 + MODULE_LICENSE("GPL v2");
+23 -6
drivers/usb/typec/mux/intel_pmc_mux.c
··· 121 121 int num; 122 122 u32 iom_status; 123 123 struct pmc_usb *pmc; 124 - struct typec_mux *typec_mux; 125 - struct typec_switch *typec_sw; 124 + struct typec_mux_dev *typec_mux; 125 + struct typec_switch_dev *typec_sw; 126 126 struct usb_role_switch *usb_sw; 127 127 128 128 enum typec_orientation orientation; ··· 173 173 return port->orientation - 1; 174 174 } 175 175 176 - static int pmc_usb_command(struct pmc_usb_port *port, u8 *msg, u32 len) 176 + static int pmc_usb_send_command(struct intel_scu_ipc_dev *ipc, u8 *msg, u32 len) 177 177 { 178 178 u8 response[4]; 179 179 u8 status_res; ··· 184 184 * Status can be checked from the response message if the 185 185 * function intel_scu_ipc_dev_command succeeds. 186 186 */ 187 - ret = intel_scu_ipc_dev_command(port->pmc->ipc, PMC_USBC_CMD, 0, msg, 187 + ret = intel_scu_ipc_dev_command(ipc, PMC_USBC_CMD, 0, msg, 188 188 len, response, sizeof(response)); 189 189 190 190 if (ret) ··· 201 201 } 202 202 203 203 return 0; 204 + } 205 + 206 + static int pmc_usb_command(struct pmc_usb_port *port, u8 *msg, u32 len) 207 + { 208 + int retry_count = 3; 209 + int ret; 210 + 211 + /* 212 + * If PMC is busy then retry the command once again 213 + */ 214 + while (retry_count--) { 215 + ret = pmc_usb_send_command(port->pmc->ipc, msg, len); 216 + if (ret != -EBUSY) 217 + break; 218 + } 219 + 220 + return ret; 204 221 } 205 222 206 223 static int ··· 433 416 } 434 417 435 418 static int 436 - pmc_usb_mux_set(struct typec_mux *mux, struct typec_mux_state *state) 419 + pmc_usb_mux_set(struct typec_mux_dev *mux, struct typec_mux_state *state) 437 420 { 438 421 struct pmc_usb_port *port = typec_mux_get_drvdata(mux); 439 422 ··· 469 452 return -EOPNOTSUPP; 470 453 } 471 454 472 - static int pmc_usb_set_orientation(struct typec_switch *sw, 455 + static int pmc_usb_set_orientation(struct typec_switch_dev *sw, 473 456 enum typec_orientation orientation) 474 457 { 475 458 struct pmc_usb_port *port = typec_switch_get_drvdata(sw);
+4 -4
drivers/usb/typec/mux/pi3usb30532.c
··· 23 23 struct pi3usb30532 { 24 24 struct i2c_client *client; 25 25 struct mutex lock; /* protects the cached conf register */ 26 - struct typec_switch *sw; 27 - struct typec_mux *mux; 26 + struct typec_switch_dev *sw; 27 + struct typec_mux_dev *mux; 28 28 u8 conf; 29 29 }; 30 30 ··· 45 45 return 0; 46 46 } 47 47 48 - static int pi3usb30532_sw_set(struct typec_switch *sw, 48 + static int pi3usb30532_sw_set(struct typec_switch_dev *sw, 49 49 enum typec_orientation orientation) 50 50 { 51 51 struct pi3usb30532 *pi = typec_switch_get_drvdata(sw); ··· 74 74 } 75 75 76 76 static int 77 - pi3usb30532_mux_set(struct typec_mux *mux, struct typec_mux_state *state) 77 + pi3usb30532_mux_set(struct typec_mux_dev *mux, struct typec_mux_state *state) 78 78 { 79 79 struct pi3usb30532 *pi = typec_mux_get_drvdata(mux); 80 80 u8 new_conf;
+12 -20
drivers/usb/typec/tipd/core.c
··· 93 93 struct power_supply *psy; 94 94 struct power_supply_desc psy_desc; 95 95 enum power_supply_usb_type usb_type; 96 + 97 + u16 pwr_status; 96 98 }; 97 99 98 100 static enum power_supply_property tps6598x_psy_props[] = { ··· 232 230 { 233 231 struct typec_partner_desc desc; 234 232 enum typec_pwr_opmode mode; 235 - u16 pwr_status; 236 233 int ret; 237 234 238 235 if (tps->partner) 239 236 return 0; 240 237 241 - ret = tps6598x_read16(tps, TPS_REG_POWER_STATUS, &pwr_status); 242 - if (ret < 0) 243 - return ret; 244 - 245 - mode = TPS_POWER_STATUS_PWROPMODE(pwr_status); 238 + mode = TPS_POWER_STATUS_PWROPMODE(tps->pwr_status); 246 239 247 240 desc.usb_pd = mode == TYPEC_PWR_MODE_PD; 248 241 desc.accessory = TYPEC_ACCESSORY_NONE; /* XXX: handle accessories */ ··· 452 455 dev_err(tps->dev, "failed to read power status: %d\n", ret); 453 456 return false; 454 457 } 458 + tps->pwr_status = pwr_status; 455 459 trace_tps6598x_power_status(pwr_status); 456 460 457 461 return true; ··· 599 601 static int tps6598x_psy_get_online(struct tps6598x *tps, 600 602 union power_supply_propval *val) 601 603 { 602 - int ret; 603 - u16 pwr_status; 604 - 605 - ret = tps6598x_read16(tps, TPS_REG_POWER_STATUS, &pwr_status); 606 - if (ret < 0) 607 - return ret; 608 - 609 - if (TPS_POWER_STATUS_CONNECTION(pwr_status) && 610 - TPS_POWER_STATUS_SOURCESINK(pwr_status)) { 604 + if (TPS_POWER_STATUS_CONNECTION(tps->pwr_status) && 605 + TPS_POWER_STATUS_SOURCESINK(tps->pwr_status)) { 611 606 val->intval = 1; 612 607 } else { 613 608 val->intval = 0; ··· 613 622 union power_supply_propval *val) 614 623 { 615 624 struct tps6598x *tps = power_supply_get_drvdata(psy); 616 - u16 pwr_status; 617 625 int ret = 0; 618 626 619 627 switch (psp) { 620 628 case POWER_SUPPLY_PROP_USB_TYPE: 621 - ret = tps6598x_read16(tps, TPS_REG_POWER_STATUS, &pwr_status); 622 - if (ret < 0) 623 - return ret; 624 - if (TPS_POWER_STATUS_PWROPMODE(pwr_status) == TYPEC_PWR_MODE_PD) 629 + if (TPS_POWER_STATUS_PWROPMODE(tps->pwr_status) == TYPEC_PWR_MODE_PD) 625 630 val->intval = POWER_SUPPLY_USB_TYPE_PD; 626 631 else 627 632 val->intval = POWER_SUPPLY_USB_TYPE_C; ··· 824 837 fwnode_handle_put(fwnode); 825 838 826 839 if (status & TPS_STATUS_PLUG_PRESENT) { 840 + ret = tps6598x_read16(tps, TPS_REG_POWER_STATUS, &tps->pwr_status); 841 + if (ret < 0) { 842 + dev_err(tps->dev, "failed to read power status: %d\n", ret); 843 + goto err_role_put; 844 + } 827 845 ret = tps6598x_connect(tps, status); 828 846 if (ret) 829 847 dev_err(&client->dev, "failed to register partner\n");
+49 -36
drivers/usb/typec/ucsi/ucsi.c
··· 1063 1063 con->num = index + 1; 1064 1064 con->ucsi = ucsi; 1065 1065 1066 + cap->fwnode = ucsi_find_fwnode(con); 1067 + con->usb_role_sw = fwnode_usb_role_switch_get(cap->fwnode); 1068 + if (IS_ERR(con->usb_role_sw)) { 1069 + dev_err(ucsi->dev, "con%d: failed to get usb role switch\n", 1070 + con->num); 1071 + return PTR_ERR(con->usb_role_sw); 1072 + } 1073 + 1066 1074 /* Delay other interactions with the con until registration is complete */ 1067 1075 mutex_lock(&con->lock); 1068 1076 ··· 1106 1098 if (con->cap.op_mode & UCSI_CONCAP_OPMODE_DEBUG_ACCESSORY) 1107 1099 *accessory = TYPEC_ACCESSORY_DEBUG; 1108 1100 1109 - cap->fwnode = ucsi_find_fwnode(con); 1110 1101 cap->driver_data = con; 1111 1102 cap->ops = &ucsi_ops; 1112 1103 ··· 1163 1156 ucsi_port_psy_changed(con); 1164 1157 } 1165 1158 1166 - con->usb_role_sw = fwnode_usb_role_switch_get(cap->fwnode); 1167 - if (IS_ERR(con->usb_role_sw)) { 1168 - dev_err(ucsi->dev, "con%d: failed to get usb role switch\n", 1169 - con->num); 1170 - con->usb_role_sw = NULL; 1171 - } 1172 - 1173 1159 /* Only notify USB controller if partner supports USB data */ 1174 1160 if (!(UCSI_CONSTAT_PARTNER_FLAGS(con->status.flags) & UCSI_CONSTAT_PARTNER_FLAG_USB)) 1175 1161 u_role = USB_ROLE_NONE; ··· 1196 1196 return ret; 1197 1197 } 1198 1198 1199 + static void ucsi_unregister_connectors(struct ucsi *ucsi) 1200 + { 1201 + struct ucsi_connector *con; 1202 + int i; 1203 + 1204 + if (!ucsi->connector) 1205 + return; 1206 + 1207 + for (i = 0; i < ucsi->cap.num_connectors; i++) { 1208 + con = &ucsi->connector[i]; 1209 + 1210 + if (!con->wq) 1211 + break; 1212 + 1213 + cancel_work_sync(&con->work); 1214 + ucsi_unregister_partner(con); 1215 + ucsi_unregister_altmodes(con, UCSI_RECIPIENT_CON); 1216 + ucsi_unregister_port_psy(con); 1217 + destroy_workqueue(con->wq); 1218 + typec_unregister_port(con->port); 1219 + } 1220 + 1221 + kfree(ucsi->connector); 1222 + ucsi->connector = NULL; 1223 + } 1224 + 1199 1225 /** 1200 1226 * ucsi_init - Initialize UCSI interface 1201 1227 * @ucsi: UCSI to be initialized ··· 1230 1204 */ 1231 1205 static int ucsi_init(struct ucsi *ucsi) 1232 1206 { 1233 - struct ucsi_connector *con; 1234 1207 u64 command; 1235 1208 int ret; 1236 1209 int i; ··· 1260 1235 } 1261 1236 1262 1237 /* Allocate the connectors. Released in ucsi_unregister() */ 1263 - ucsi->connector = kcalloc(ucsi->cap.num_connectors + 1, 1238 + ucsi->connector = kcalloc(ucsi->cap.num_connectors, 1264 1239 sizeof(*ucsi->connector), GFP_KERNEL); 1265 1240 if (!ucsi->connector) { 1266 1241 ret = -ENOMEM; ··· 1284 1259 return 0; 1285 1260 1286 1261 err_unregister: 1287 - for (con = ucsi->connector; con->port; con++) { 1288 - ucsi_unregister_partner(con); 1289 - ucsi_unregister_altmodes(con, UCSI_RECIPIENT_CON); 1290 - ucsi_unregister_port_psy(con); 1291 - if (con->wq) 1292 - destroy_workqueue(con->wq); 1293 - typec_unregister_port(con->port); 1294 - con->port = NULL; 1295 - } 1262 + ucsi_unregister_connectors(ucsi); 1296 1263 1297 1264 err_reset: 1298 1265 memset(&ucsi->cap, 0, sizeof(ucsi->cap)); ··· 1295 1278 1296 1279 static void ucsi_init_work(struct work_struct *work) 1297 1280 { 1298 - struct ucsi *ucsi = container_of(work, struct ucsi, work); 1281 + struct ucsi *ucsi = container_of(work, struct ucsi, work.work); 1299 1282 int ret; 1300 1283 1301 1284 ret = ucsi_init(ucsi); 1302 1285 if (ret) 1303 1286 dev_err(ucsi->dev, "PPM init failed (%d)\n", ret); 1287 + 1288 + if (ret == -EPROBE_DEFER) { 1289 + if (ucsi->work_count++ > UCSI_ROLE_SWITCH_WAIT_COUNT) 1290 + return; 1291 + 1292 + queue_delayed_work(system_long_wq, &ucsi->work, 1293 + UCSI_ROLE_SWITCH_INTERVAL); 1294 + } 1304 1295 } 1305 1296 1306 1297 /** ··· 1348 1323 if (!ucsi) 1349 1324 return ERR_PTR(-ENOMEM); 1350 1325 1351 - INIT_WORK(&ucsi->work, ucsi_init_work); 1326 + INIT_DELAYED_WORK(&ucsi->work, ucsi_init_work); 1352 1327 mutex_init(&ucsi->ppm_lock); 1353 1328 ucsi->dev = dev; 1354 1329 ucsi->ops = ops; ··· 1383 1358 if (!ucsi->version) 1384 1359 return -ENODEV; 1385 1360 1386 - queue_work(system_long_wq, &ucsi->work); 1361 + queue_delayed_work(system_long_wq, &ucsi->work, 0); 1387 1362 1388 1363 return 0; 1389 1364 } ··· 1398 1373 void ucsi_unregister(struct ucsi *ucsi) 1399 1374 { 1400 1375 u64 cmd = UCSI_SET_NOTIFICATION_ENABLE; 1401 - int i; 1402 1376 1403 1377 /* Make sure that we are not in the middle of driver initialization */ 1404 - cancel_work_sync(&ucsi->work); 1378 + cancel_delayed_work_sync(&ucsi->work); 1405 1379 1406 1380 /* Disable notifications */ 1407 1381 ucsi->ops->async_write(ucsi, UCSI_CONTROL, &cmd, sizeof(cmd)); 1408 1382 1409 - for (i = 0; i < ucsi->cap.num_connectors; i++) { 1410 - cancel_work_sync(&ucsi->connector[i].work); 1411 - ucsi_unregister_partner(&ucsi->connector[i]); 1412 - ucsi_unregister_altmodes(&ucsi->connector[i], 1413 - UCSI_RECIPIENT_CON); 1414 - ucsi_unregister_port_psy(&ucsi->connector[i]); 1415 - if (ucsi->connector[i].wq) 1416 - destroy_workqueue(ucsi->connector[i].wq); 1417 - typec_unregister_port(ucsi->connector[i].port); 1418 - } 1419 - 1420 - kfree(ucsi->connector); 1383 + ucsi_unregister_connectors(ucsi); 1421 1384 } 1422 1385 EXPORT_SYMBOL_GPL(ucsi_unregister); 1423 1386
+5 -1
drivers/usb/typec/ucsi/ucsi.h
··· 287 287 struct ucsi_capability cap; 288 288 struct ucsi_connector *connector; 289 289 290 - struct work_struct work; 290 + struct delayed_work work; 291 + int work_count; 292 + #define UCSI_ROLE_SWITCH_RETRY_PER_HZ 10 293 + #define UCSI_ROLE_SWITCH_INTERVAL (HZ / UCSI_ROLE_SWITCH_RETRY_PER_HZ) 294 + #define UCSI_ROLE_SWITCH_WAIT_COUNT (10 * UCSI_ROLE_SWITCH_RETRY_PER_HZ) 291 295 292 296 /* PPM Communication lock */ 293 297 struct mutex ppm_lock;
+1 -1
drivers/usb/usbip/stub_dev.c
··· 393 393 394 394 err_port: 395 395 dev_set_drvdata(&udev->dev, NULL); 396 - usb_put_dev(udev); 397 396 398 397 /* we already have busid_priv, just lock busid_lock */ 399 398 spin_lock(&busid_priv->busid_lock); ··· 407 408 put_busid_priv(busid_priv); 408 409 409 410 sdev_free: 411 + usb_put_dev(udev); 410 412 stub_device_free(sdev); 411 413 412 414 return rc;
+2
drivers/usb/usbip/stub_rx.c
··· 138 138 req = (struct usb_ctrlrequest *) urb->setup_packet; 139 139 config = le16_to_cpu(req->wValue); 140 140 141 + usb_lock_device(sdev->udev); 141 142 err = usb_set_configuration(sdev->udev, config); 143 + usb_unlock_device(sdev->udev); 142 144 if (err && err != -ENODEV) 143 145 dev_err(&sdev->udev->dev, "can't set config #%d, error %d\n", 144 146 config, err);
+5
include/linux/property.h
··· 451 451 return fwnode_connection_find_match(dev_fwnode(dev), con_id, data, match); 452 452 } 453 453 454 + int fwnode_connection_find_matches(struct fwnode_handle *fwnode, 455 + const char *con_id, void *data, 456 + devcon_match_fn_t match, 457 + void **matches, unsigned int matches_len); 458 + 454 459 /* -------------------------------------------------------------------------- */ 455 460 /* Software fwnode support - when HW description is incomplete or missing */ 456 461
+10 -9
include/linux/thunderbolt.h
··· 198 198 * @local_property_block_len: Length of the @local_property_block in dwords 199 199 * @remote_properties: Properties exported by the remote domain 200 200 * @remote_property_block_gen: Generation of @remote_properties 201 - * @get_uuid_work: Work used to retrieve @remote_uuid 202 - * @uuid_retries: Number of times left @remote_uuid is requested before 203 - * giving up 204 - * @get_properties_work: Work used to get remote domain properties 205 - * @properties_retries: Number of times left to read properties 201 + * @state: Next XDomain discovery state to run 202 + * @state_work: Work used to run the next state 203 + * @state_retries: Number of retries remain for the state 206 204 * @properties_changed_work: Work used to notify the remote domain that 207 205 * our properties have changed 208 206 * @properties_changed_retries: Number of times left to send properties 209 207 * changed notification 208 + * @bonding_possible: True if lane bonding is possible on local side 209 + * @target_link_width: Target link width from the remote host 210 210 * @link: Root switch link the remote domain is connected (ICM only) 211 211 * @depth: Depth in the chain the remote domain is connected (ICM only) 212 212 * ··· 244 244 u32 local_property_block_len; 245 245 struct tb_property_dir *remote_properties; 246 246 u32 remote_property_block_gen; 247 - struct delayed_work get_uuid_work; 248 - int uuid_retries; 249 - struct delayed_work get_properties_work; 250 - int properties_retries; 247 + int state; 248 + struct delayed_work state_work; 249 + int state_retries; 251 250 struct delayed_work properties_changed_work; 252 251 int properties_changed_retries; 252 + bool bonding_possible; 253 + u8 target_link_width; 253 254 u8 link; 254 255 u8 depth; 255 256 };
+2 -15
include/linux/usb.h
··· 1969 1969 return eps[usb_pipeendpoint(pipe)]; 1970 1970 } 1971 1971 1972 - /*-------------------------------------------------------------------------*/ 1973 - 1974 - static inline __u16 1975 - usb_maxpacket(struct usb_device *udev, int pipe, int is_out) 1972 + static inline u16 usb_maxpacket(struct usb_device *udev, int pipe) 1976 1973 { 1977 - struct usb_host_endpoint *ep; 1978 - unsigned epnum = usb_pipeendpoint(pipe); 1974 + struct usb_host_endpoint *ep = usb_pipe_endpoint(udev, pipe); 1979 1975 1980 - if (is_out) { 1981 - WARN_ON(usb_pipein(pipe)); 1982 - ep = udev->ep_out[epnum]; 1983 - } else { 1984 - WARN_ON(usb_pipeout(pipe)); 1985 - ep = udev->ep_in[epnum]; 1986 - } 1987 1976 if (!ep) 1988 1977 return 0; 1989 1978 1990 1979 /* NOTE: only 0x07ff bits are for packet size... */ 1991 1980 return usb_endpoint_maxp(&ep->desc); 1992 1981 } 1993 - 1994 - /* ----------------------------------------------------------------------- */ 1995 1982 1996 1983 /* translate USB error codes to codes user space understands */ 1997 1984 static inline int usb_translate_errors(int error_code)
+19 -9
include/linux/usb/gadget.h
··· 386 386 * @lpm_capable: If the gadget max_speed is FULL or HIGH, this flag 387 387 * indicates that it supports LPM as per the LPM ECN & errata. 388 388 * @irq: the interrupt number for device controller. 389 + * @id_number: a unique ID number for ensuring that gadget names are distinct 389 390 * 390 391 * Gadgets have a mostly-portable "gadget driver" implementing device 391 392 * functions, handling all usb configurations and interfaces. Gadget ··· 447 446 unsigned connected:1; 448 447 unsigned lpm_capable:1; 449 448 int irq; 449 + int id_number; 450 450 }; 451 451 #define work_to_gadget(w) (container_of((w), struct usb_gadget, work)) 452 452 ··· 666 664 * @driver: Driver model state for this driver. 667 665 * @udc_name: A name of UDC this driver should be bound to. If udc_name is NULL, 668 666 * this driver will be bound to any available UDC. 669 - * @pending: UDC core private data used for deferred probe of this driver. 670 - * @match_existing_only: If udc is not found, return an error and don't add this 671 - * gadget driver to list of pending driver 667 + * @match_existing_only: If udc is not found, return an error and fail 668 + * the driver registration 669 + * @is_bound: Allow a driver to be bound to only one gadget 672 670 * 673 671 * Devices are disabled till a gadget driver successfully bind()s, which 674 672 * means the driver will handle setup() requests needed to enumerate (and ··· 731 729 struct device_driver driver; 732 730 733 731 char *udc_name; 734 - struct list_head pending; 735 732 unsigned match_existing_only:1; 733 + bool is_bound:1; 736 734 }; 737 735 738 736 ··· 742 740 /* driver modules register and unregister, as usual. 743 741 * these calls must be made in a context that can sleep. 744 742 * 745 - * these will usually be implemented directly by the hardware-dependent 746 - * usb bus interface driver, which will only support a single driver. 743 + * A gadget driver can be bound to only one gadget at a time. 747 744 */ 748 745 749 746 /** 750 - * usb_gadget_probe_driver - probe a gadget driver 747 + * usb_gadget_register_driver_owner - register a gadget driver 751 748 * @driver: the driver being registered 749 + * @owner: the driver module 750 + * @mod_name: the driver module's build name 752 751 * Context: can sleep 753 752 * 754 753 * Call this in your gadget driver's module initialization function, 755 - * to tell the underlying usb controller driver about your driver. 754 + * to tell the underlying UDC controller driver about your driver. 756 755 * The @bind() function will be called to bind it to a gadget before this 757 756 * registration call returns. It's expected that the @bind() function will 758 757 * be in init sections. 758 + * 759 + * Use the macro defined below instead of calling this directly. 759 760 */ 760 - int usb_gadget_probe_driver(struct usb_gadget_driver *driver); 761 + int usb_gadget_register_driver_owner(struct usb_gadget_driver *driver, 762 + struct module *owner, const char *mod_name); 763 + 764 + /* use a define to avoid include chaining to get THIS_MODULE & friends */ 765 + #define usb_gadget_register_driver(driver) \ 766 + usb_gadget_register_driver_owner(driver, THIS_MODULE, KBUILD_MODNAME) 761 767 762 768 /** 763 769 * usb_gadget_unregister_driver - unregister a gadget driver
+2
include/linux/usb/hcd.h
··· 124 124 #define HCD_FLAG_RH_RUNNING 5 /* root hub is running? */ 125 125 #define HCD_FLAG_DEAD 6 /* controller has died? */ 126 126 #define HCD_FLAG_INTF_AUTHORIZED 7 /* authorize interfaces? */ 127 + #define HCD_FLAG_DEFER_RH_REGISTER 8 /* Defer roothub registration */ 127 128 128 129 /* The flags can be tested using these macros; they are likely to 129 130 * be slightly faster than test_bit(). ··· 135 134 #define HCD_WAKEUP_PENDING(hcd) ((hcd)->flags & (1U << HCD_FLAG_WAKEUP_PENDING)) 136 135 #define HCD_RH_RUNNING(hcd) ((hcd)->flags & (1U << HCD_FLAG_RH_RUNNING)) 137 136 #define HCD_DEAD(hcd) ((hcd)->flags & (1U << HCD_FLAG_DEAD)) 137 + #define HCD_DEFER_RH_REGISTER(hcd) ((hcd)->flags & (1U << HCD_FLAG_DEFER_RH_REGISTER)) 138 138 139 139 /* 140 140 * Specifies if interfaces are authorized by default
+12 -10
include/linux/usb/typec_mux.h
··· 8 8 9 9 struct device; 10 10 struct typec_mux; 11 + struct typec_mux_dev; 11 12 struct typec_switch; 13 + struct typec_switch_dev; 12 14 struct typec_altmode; 13 15 struct fwnode_handle; 14 16 15 - typedef int (*typec_switch_set_fn_t)(struct typec_switch *sw, 17 + typedef int (*typec_switch_set_fn_t)(struct typec_switch_dev *sw, 16 18 enum typec_orientation orientation); 17 19 18 20 struct typec_switch_desc { ··· 34 32 return fwnode_typec_switch_get(dev_fwnode(dev)); 35 33 } 36 34 37 - struct typec_switch * 35 + struct typec_switch_dev * 38 36 typec_switch_register(struct device *parent, 39 37 const struct typec_switch_desc *desc); 40 - void typec_switch_unregister(struct typec_switch *sw); 38 + void typec_switch_unregister(struct typec_switch_dev *sw); 41 39 42 - void typec_switch_set_drvdata(struct typec_switch *sw, void *data); 43 - void *typec_switch_get_drvdata(struct typec_switch *sw); 40 + void typec_switch_set_drvdata(struct typec_switch_dev *sw, void *data); 41 + void *typec_switch_get_drvdata(struct typec_switch_dev *sw); 44 42 45 43 struct typec_mux_state { 46 44 struct typec_altmode *alt; ··· 48 46 void *data; 49 47 }; 50 48 51 - typedef int (*typec_mux_set_fn_t)(struct typec_mux *mux, 49 + typedef int (*typec_mux_set_fn_t)(struct typec_mux_dev *mux, 52 50 struct typec_mux_state *state); 53 51 54 52 struct typec_mux_desc { ··· 69 67 return fwnode_typec_mux_get(dev_fwnode(dev), desc); 70 68 } 71 69 72 - struct typec_mux * 70 + struct typec_mux_dev * 73 71 typec_mux_register(struct device *parent, const struct typec_mux_desc *desc); 74 - void typec_mux_unregister(struct typec_mux *mux); 72 + void typec_mux_unregister(struct typec_mux_dev *mux); 75 73 76 - void typec_mux_set_drvdata(struct typec_mux *mux, void *data); 77 - void *typec_mux_get_drvdata(struct typec_mux *mux); 74 + void typec_mux_set_drvdata(struct typec_mux_dev *mux, void *data); 75 + void *typec_mux_get_drvdata(struct typec_mux_dev *mux); 78 76 79 77 #endif /* __USB_TYPEC_MUX */
+2 -2
sound/usb/line6/pcm.c
··· 552 552 553 553 line6pcm->max_packet_size_in = 554 554 usb_maxpacket(line6->usbdev, 555 - usb_rcvisocpipe(line6->usbdev, ep_read), 0); 555 + usb_rcvisocpipe(line6->usbdev, ep_read)); 556 556 line6pcm->max_packet_size_out = 557 557 usb_maxpacket(line6->usbdev, 558 - usb_sndisocpipe(line6->usbdev, ep_write), 1); 558 + usb_sndisocpipe(line6->usbdev, ep_write)); 559 559 if (!line6pcm->max_packet_size_in || !line6pcm->max_packet_size_out) { 560 560 dev_err(line6pcm->line6->ifcdev, 561 561 "cannot get proper max packet size\n");
+2 -2
sound/usb/midi.c
··· 1289 1289 pipe = usb_rcvintpipe(umidi->dev, ep_info->in_ep); 1290 1290 else 1291 1291 pipe = usb_rcvbulkpipe(umidi->dev, ep_info->in_ep); 1292 - length = usb_maxpacket(umidi->dev, pipe, 0); 1292 + length = usb_maxpacket(umidi->dev, pipe); 1293 1293 for (i = 0; i < INPUT_URBS; ++i) { 1294 1294 buffer = usb_alloc_coherent(umidi->dev, length, GFP_KERNEL, 1295 1295 &ep->urbs[i]->transfer_dma); ··· 1378 1378 pipe = usb_sndbulkpipe(umidi->dev, ep_info->out_ep); 1379 1379 switch (umidi->usb_id) { 1380 1380 default: 1381 - ep->max_transfer = usb_maxpacket(umidi->dev, pipe, 1); 1381 + ep->max_transfer = usb_maxpacket(umidi->dev, pipe); 1382 1382 break; 1383 1383 /* 1384 1384 * Various chips declare a packet size larger than 4 bytes, but
+3 -3
sound/usb/usx2y/usb_stream.c
··· 51 51 { 52 52 int u, p; 53 53 int maxpacket = use_packsize ? 54 - use_packsize : usb_maxpacket(dev, pipe, usb_pipeout(pipe)); 54 + use_packsize : usb_maxpacket(dev, pipe); 55 55 int transfer_length = maxpacket * sk->n_o_ps; 56 56 57 57 for (u = 0; u < USB_STREAM_NURBS; ··· 171 171 out_pipe = usb_sndisocpipe(dev, out_endpoint); 172 172 173 173 max_packsize = use_packsize ? 174 - use_packsize : usb_maxpacket(dev, in_pipe, 0); 174 + use_packsize : usb_maxpacket(dev, in_pipe); 175 175 176 176 /* 177 177 t_period = period_frames / sample_rate ··· 187 187 read_size += packets * USB_STREAM_URBDEPTH * 188 188 (max_packsize + sizeof(struct usb_stream_packet)); 189 189 190 - max_packsize = usb_maxpacket(dev, out_pipe, 1); 190 + max_packsize = usb_maxpacket(dev, out_pipe); 191 191 write_size = max_packsize * packets * USB_STREAM_URBDEPTH; 192 192 193 193 if (read_size >= 256*PAGE_SIZE || write_size >= 256*PAGE_SIZE) {
+1 -1
sound/usb/usx2y/usbusx2yaudio.c
··· 421 421 422 422 pipe = is_playback ? usb_sndisocpipe(dev, subs->endpoint) : 423 423 usb_rcvisocpipe(dev, subs->endpoint); 424 - subs->maxpacksize = usb_maxpacket(dev, pipe, is_playback); 424 + subs->maxpacksize = usb_maxpacket(dev, pipe); 425 425 if (!subs->maxpacksize) 426 426 return -EINVAL; 427 427
+1 -1
sound/usb/usx2y/usx2yhwdeppcm.c
··· 321 321 322 322 pipe = is_playback ? usb_sndisocpipe(dev, subs->endpoint) : 323 323 usb_rcvisocpipe(dev, subs->endpoint); 324 - subs->maxpacksize = usb_maxpacket(dev, pipe, is_playback); 324 + subs->maxpacksize = usb_maxpacket(dev, pipe); 325 325 if (!subs->maxpacksize) 326 326 return -EINVAL; 327 327
+1 -1
tools/usb/testusb.c
··· 482 482 } 483 483 if (not) 484 484 return 0; 485 - if (testdevs && testdevs->next == 0 && !device) 485 + if (testdevs && !testdevs->next && !device) 486 486 device = testdevs->name; 487 487 for (entry = testdevs; entry; entry = entry->next) { 488 488 int status;