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-6.8-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 changes for 6.8-rc1.
Included in here are the following:

- Thunderbolt subsystem and driver updates for USB 4 hardware and
issues reported by real devices

- xhci driver updates

- dwc3 driver updates

- uvc_video gadget driver updates

- typec driver updates

- gadget string functions cleaned up

- other small changes

All of these have been in the linux-next tree for a while with no
reported issues"

* tag 'usb-6.8-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (169 commits)
usb: typec: tipd: fix use of device-specific init function
usb: typec: tipd: Separate reset for TPS6598x
usb: mon: Fix atomicity violation in mon_bin_vma_fault
usb: gadget: uvc: Remove nested locking
usb: gadget: uvc: Fix use are free during STREAMOFF
usb: typec: class: fix typec_altmode_put_partner to put plugs
dt-bindings: usb: dwc3: Limit num-hc-interrupters definition
dt-bindings: usb: xhci: Add num-hc-interrupters definition
xhci: add support to allocate several interrupters
USB: core: Use device_driver directly in struct usb_driver and usb_device_driver
arm64: dts: mediatek: mt8195: Add 'rx-fifo-depth' for cherry
usb: xhci-mtk: fix a short packet issue of gen1 isoc-in transfer
dt-bindings: usb: mtk-xhci: add a property for Gen1 isoc-in transfer issue
arm64: dts: qcom: msm8996: Remove PNoC clock from MSS
arm64: dts: qcom: msm8996: Remove AGGRE2 clock from SLPI
arm64: dts: qcom: msm8998: Remove AGGRE2 clock from SLPI
arm64: dts: qcom: msm8939: Drop RPM bus clocks
arm64: dts: qcom: sdm630: Drop RPM bus clocks
arm64: dts: qcom: qcs404: Drop RPM bus clocks
arm64: dts: qcom: msm8996: Drop RPM bus clocks
...

+3945 -1549
+3
Documentation/admin-guide/kernel-parameters.txt
··· 6933 6933 pause after every control message); 6934 6934 o = USB_QUIRK_HUB_SLOW_RESET (Hub needs extra 6935 6935 delay after resetting its port); 6936 + p = USB_QUIRK_SHORT_SET_ADDRESS_REQ_TIMEOUT 6937 + (Reduce timeout of the SET_ADDRESS 6938 + request from 5000 ms to 500 ms); 6936 6939 Example: quirks=0781:5580:bk,0a5c:5834:gij 6937 6940 6938 6941 usbhid.mousepoll=
+94 -30
Documentation/devicetree/bindings/connector/usb-connector.yaml
··· 66 66 Particularly, if use an output GPIO to control a VBUS regulator, should 67 67 model it as a regulator. See bindings/regulator/fixed-regulator.yaml 68 68 69 - # The following are optional properties for "usb-c-connector". 70 69 power-role: 71 70 description: Determines the power role that the Type C connector will 72 71 support. "dual" refers to Dual Role Port (DRP). ··· 118 119 119 120 # The following are optional properties for "usb-c-connector" with power 120 121 # delivery support. 121 - source-pdos: 122 - description: An array of u32 with each entry providing supported power 123 - source data object(PDO), the detailed bit definitions of PDO can be found 124 - in "Universal Serial Bus Power Delivery Specification" chapter 6.4.1.2 125 - Source_Capabilities Message, the order of each entry(PDO) should follow 126 - the PD spec chapter 6.4.1. Required for power source and power dual role. 127 - User can specify the source PDO array via PDO_FIXED/BATT/VAR/PPS_APDO() 128 - defined in dt-bindings/usb/pd.h. 129 - minItems: 1 130 - maxItems: 7 131 - $ref: /schemas/types.yaml#/definitions/uint32-array 132 - 133 - sink-pdos: 134 - description: An array of u32 with each entry providing supported power sink 135 - data object(PDO), the detailed bit definitions of PDO can be found in 136 - "Universal Serial Bus Power Delivery Specification" chapter 6.4.1.3 137 - Sink Capabilities Message, the order of each entry(PDO) should follow the 138 - PD spec chapter 6.4.1. Required for power sink and power dual role. User 139 - can specify the sink PDO array via PDO_FIXED/BATT/VAR/PPS_APDO() defined 140 - in dt-bindings/usb/pd.h. 141 - minItems: 1 142 - maxItems: 7 143 - $ref: /schemas/types.yaml#/definitions/uint32-array 144 - 145 122 sink-vdos: 146 123 description: An array of u32 with each entry, a Vendor Defined Message Object (VDO), 147 124 providing additional information corresponding to the product, the detailed bit ··· 141 166 maxItems: 6 142 167 $ref: /schemas/types.yaml#/definitions/uint32-array 143 168 144 - op-sink-microwatt: 145 - description: Sink required operating power in microwatt, if source can't 146 - offer the power, Capability Mismatch is set. Required for power sink and 147 - power dual role. 169 + accessory-mode-audio: 170 + type: boolean 171 + description: Whether the device supports Audio Adapter Accessory Mode. This 172 + is only necessary if there are no other means to discover supported 173 + alternative modes (e.g. through the UCSI firmware interface). 174 + 175 + accessory-mode-debug: 176 + type: boolean 177 + description: Whether the device supports Debug Accessory Mode. This 178 + is only necessary if there are no other means to discover supported 179 + alternative modes (e.g. through the UCSI firmware interface). 180 + 181 + altmodes: 182 + type: object 183 + description: List of Alternative Modes supported by the schematics on the 184 + particular device. This is only necessary if there are no other means to 185 + discover supported alternative modes (e.g. through the UCSI firmware 186 + interface). 187 + 188 + additionalProperties: false 189 + 190 + patternProperties: 191 + "^(displayport)$": 192 + type: object 193 + description: 194 + A single USB-C Alternative Mode as supported by the USB-C connector logic. 195 + 196 + additionalProperties: false 197 + 198 + properties: 199 + svid: 200 + $ref: /schemas/types.yaml#/definitions/uint16 201 + description: Unique value assigned by USB-IF to the Vendor / AltMode. 202 + enum: [ 0xff01 ] 203 + vdo: 204 + $ref: /schemas/types.yaml#/definitions/uint32 205 + description: VDO returned by Discover Modes USB PD command. 148 206 149 207 port: 150 208 $ref: /schemas/graph.yaml#/properties/port ··· 239 231 SNK_READY for non-pd link. 240 232 type: boolean 241 233 234 + capabilities: 235 + description: A child node to contain all the selectable USB Power Delivery capabilities. 236 + type: object 237 + 238 + patternProperties: 239 + "^caps-[0-9]+$": 240 + description: Child nodes under "capabilities" node. Each node contains a selectable USB 241 + Power Delivery capability. 242 + type: object 243 + $ref: "#/$defs/capabilities" 244 + unevaluatedProperties: false 245 + 246 + additionalProperties: false 247 + 242 248 dependencies: 243 249 sink-vdos-v1: [ sink-vdos ] 244 250 sink-vdos: [ sink-vdos-v1 ] ··· 260 238 required: 261 239 - compatible 262 240 241 + $defs: 242 + capabilities: 243 + type: object 244 + 245 + properties: 246 + source-pdos: 247 + description: An array of u32 with each entry providing supported power 248 + source data object(PDO), the detailed bit definitions of PDO can be found 249 + in "Universal Serial Bus Power Delivery Specification" chapter 6.4.1.2 250 + Source_Capabilities Message, the order of each entry(PDO) should follow 251 + the PD spec chapter 6.4.1. Required for power source and power dual role. 252 + User can specify the source PDO array via PDO_FIXED/BATT/VAR/PPS_APDO() 253 + defined in dt-bindings/usb/pd.h. 254 + minItems: 1 255 + maxItems: 7 256 + $ref: /schemas/types.yaml#/definitions/uint32-array 257 + 258 + sink-pdos: 259 + description: An array of u32 with each entry providing supported power sink 260 + data object(PDO), the detailed bit definitions of PDO can be found in 261 + "Universal Serial Bus Power Delivery Specification" chapter 6.4.1.3 262 + Sink Capabilities Message, the order of each entry(PDO) should follow the 263 + PD spec chapter 6.4.1. Required for power sink and power dual role. User 264 + can specify the sink PDO array via PDO_FIXED/BATT/VAR/PPS_APDO() defined 265 + in dt-bindings/usb/pd.h. 266 + minItems: 1 267 + maxItems: 7 268 + $ref: /schemas/types.yaml#/definitions/uint32-array 269 + 270 + op-sink-microwatt: 271 + description: Sink required operating power in microwatt, if source can't 272 + offer the power, Capability Mismatch is set. Required for power sink and 273 + power dual role. 274 + 263 275 allOf: 276 + - $ref: "#/$defs/capabilities" 264 277 - if: 265 278 properties: 266 279 compatible: ··· 324 267 - typec-power-opmode 325 268 - new-source-frs-typec-current 326 269 327 - additionalProperties: false 270 + unevaluatedProperties: false 328 271 329 272 examples: 330 273 # Micro-USB connector with HS lines routed via controller (MUIC). ··· 345 288 usb_con2: connector { 346 289 compatible = "usb-c-connector"; 347 290 label = "USB-C"; 291 + 292 + altmodes { 293 + displayport { 294 + svid = /bits/ 16 <0xff01>; 295 + vdo = <0x00001c46>; 296 + }; 297 + }; 348 298 349 299 ports { 350 300 #address-cells = <1>;
+22 -3
Documentation/devicetree/bindings/usb/generic-xhci.yaml
··· 9 9 maintainers: 10 10 - Mathias Nyman <mathias.nyman@intel.com> 11 11 12 - allOf: 13 - - $ref: usb-xhci.yaml# 14 - 15 12 properties: 16 13 compatible: 17 14 oneOf: ··· 22 25 - marvell,armada-380-xhci 23 26 - marvell,armada-8k-xhci 24 27 - const: generic-xhci 28 + - description: Broadcom SoCs with power domains 29 + items: 30 + - enum: 31 + - brcm,bcm2711-xhci 32 + - const: brcm,xhci-brcm-v2 25 33 - description: Broadcom STB SoCs with xHCI 26 34 enum: 27 35 - brcm,xhci-brcm-v2 ··· 51 49 - const: core 52 50 - const: reg 53 51 52 + power-domains: 53 + maxItems: 1 54 + 54 55 unevaluatedProperties: false 55 56 56 57 required: 57 58 - compatible 58 59 - reg 59 60 - interrupts 61 + 62 + allOf: 63 + - $ref: usb-xhci.yaml# 64 + - if: 65 + properties: 66 + compatible: 67 + contains: 68 + const: brcm,bcm2711-xhci 69 + then: 70 + required: 71 + - power-domains 72 + else: 73 + properties: 74 + power-domains: false 60 75 61 76 examples: 62 77 - |
+5
Documentation/devicetree/bindings/usb/genesys,gl850g.yaml
··· 29 29 description: 30 30 the regulator that provides 3.3V core power to the hub. 31 31 32 + peer-hub: 33 + $ref: /schemas/types.yaml#/definitions/phandle 34 + description: 35 + phandle to the peer hub on the controller. 36 + 32 37 required: 33 38 - compatible 34 39 - reg
+11
Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.yaml
··· 124 124 defined in the xHCI spec on MTK's controller. 125 125 default: 5000 126 126 127 + rx-fifo-depth: 128 + $ref: /schemas/types.yaml#/definitions/uint32 129 + description: 130 + It is a quirk used to work around Gen1 isoc-in endpoint transfer issue 131 + that still send out unexpected ACK after device finishes the burst 132 + transfer with a short packet and cause an exception, specially on a 4K 133 + camera device, it happens on controller before about IPM v1.6.0; 134 + the side-effect is that it may cause performance drop about 10%, 135 + including bulk transfer, prefer to use 3k here. The size is in bytes. 136 + enum: [1024, 2048, 3072, 4096] 137 + 127 138 # the following properties are only used for case 1 128 139 wakeup-source: 129 140 description: enable USB remote wakeup, see power/wakeup-source.txt
+1 -1
Documentation/devicetree/bindings/usb/nxp,ptn5110.yaml
··· 4 4 $id: http://devicetree.org/schemas/usb/nxp,ptn5110.yaml# 5 5 $schema: http://devicetree.org/meta-schemas/core.yaml# 6 6 7 - title: NXP PTN5110 Typec Port Cotroller 7 + title: NXP PTN5110 Type-C Port Controller 8 8 9 9 maintainers: 10 10 - Li Jun <jun.li@nxp.com>
+101 -116
Documentation/devicetree/bindings/usb/qcom,dwc3.yaml
··· 46 46 - qcom,sm8350-dwc3 47 47 - qcom,sm8450-dwc3 48 48 - qcom,sm8550-dwc3 49 + - qcom,sm8650-dwc3 50 + - qcom,x1e80100-dwc3 49 51 - const: qcom,dwc3 50 52 51 53 reg: ··· 99 97 - const: apps-usb 100 98 101 99 interrupts: 102 - minItems: 1 103 - maxItems: 4 100 + description: | 101 + Different types of interrupts are used based on HS PHY used on target: 102 + - pwr_event: Used for wakeup based on other power events. 103 + - hs_phY_irq: Apart from DP/DM/QUSB2 PHY interrupts, there is 104 + hs_phy_irq which is not triggered by default and its 105 + functionality is mutually exclusive to that of 106 + {dp/dm}_hs_phy_irq and qusb2_phy_irq. 107 + - qusb2_phy: SoCs with QUSB2 PHY do not have separate DP/DM IRQs and 108 + expose only a single IRQ whose behavior can be modified 109 + by the QUSB2PHY_INTR_CTRL register. The required DPSE/ 110 + DMSE configuration is done in QUSB2PHY_INTR_CTRL register 111 + of PHY address space. 112 + - {dp/dm}_hs_phy_irq: These IRQ's directly reflect changes on the DP/ 113 + DM pads of the SoC. These are used for wakeup 114 + only on SoCs with non-QUSB2 targets with 115 + exception of SDM670/SDM845/SM6350. 116 + - ss_phy_irq: Used for remote wakeup in Super Speed mode of operation. 117 + minItems: 2 118 + maxItems: 5 104 119 105 120 interrupt-names: 106 - minItems: 1 107 - maxItems: 4 121 + minItems: 2 122 + maxItems: 5 108 123 109 124 qcom,select-utmi-as-pipe-clk: 110 125 description: ··· 282 263 contains: 283 264 enum: 284 265 - qcom,sc8280xp-dwc3 266 + - qcom,x1e80100-dwc3 285 267 then: 286 268 properties: 287 269 clocks: ··· 308 288 then: 309 289 properties: 310 290 clocks: 311 - minItems: 5 312 - maxItems: 6 291 + minItems: 4 292 + maxItems: 5 313 293 clock-names: 314 294 oneOf: 315 295 - items: ··· 318 298 - const: iface 319 299 - const: sleep 320 300 - const: mock_utmi 321 - - const: bus 322 301 - items: 323 302 - const: cfg_noc 324 303 - const: core 325 304 - const: sleep 326 305 - const: mock_utmi 327 - - const: bus 328 306 329 307 - if: 330 308 properties: ··· 336 318 - qcom,sm8250-dwc3 337 319 - qcom,sm8450-dwc3 338 320 - qcom,sm8550-dwc3 321 + - qcom,sm8650-dwc3 339 322 then: 340 323 properties: 341 324 clocks: ··· 376 357 compatible: 377 358 contains: 378 359 enum: 379 - - qcom,ipq4019-dwc3 360 + - qcom,ipq5018-dwc3 380 361 - qcom,ipq6018-dwc3 381 - - qcom,ipq8064-dwc3 382 362 - qcom,ipq8074-dwc3 383 - - qcom,msm8994-dwc3 363 + - qcom,msm8953-dwc3 364 + - qcom,msm8998-dwc3 365 + then: 366 + properties: 367 + interrupts: 368 + minItems: 2 369 + maxItems: 3 370 + interrupt-names: 371 + items: 372 + - const: pwr_event 373 + - const: qusb2_phy 374 + - const: ss_phy_irq 375 + 376 + - if: 377 + properties: 378 + compatible: 379 + contains: 380 + enum: 381 + - qcom,msm8996-dwc3 384 382 - qcom,qcs404-dwc3 383 + - qcom,sdm660-dwc3 384 + - qcom,sm6115-dwc3 385 + - qcom,sm6125-dwc3 386 + then: 387 + properties: 388 + interrupts: 389 + minItems: 3 390 + maxItems: 4 391 + interrupt-names: 392 + items: 393 + - const: pwr_event 394 + - const: qusb2_phy 395 + - const: hs_phy_irq 396 + - const: ss_phy_irq 397 + 398 + - if: 399 + properties: 400 + compatible: 401 + contains: 402 + enum: 403 + - qcom,ipq5332-dwc3 404 + - qcom,x1e80100-dwc3 405 + then: 406 + properties: 407 + interrupts: 408 + maxItems: 4 409 + interrupt-names: 410 + items: 411 + - const: pwr_event 412 + - const: dp_hs_phy_irq 413 + - const: dm_hs_phy_irq 414 + - const: ss_phy_irq 415 + 416 + - if: 417 + properties: 418 + compatible: 419 + contains: 420 + enum: 421 + - qcom,ipq4019-dwc3 422 + - qcom,ipq8064-dwc3 423 + - qcom,msm8994-dwc3 424 + - qcom,sa8775p-dwc3 385 425 - qcom,sc7180-dwc3 426 + - qcom,sc7280-dwc3 427 + - qcom,sc8280xp-dwc3 386 428 - qcom,sdm670-dwc3 387 429 - qcom,sdm845-dwc3 388 430 - qcom,sdx55-dwc3 389 431 - qcom,sdx65-dwc3 390 432 - qcom,sdx75-dwc3 391 433 - qcom,sm4250-dwc3 392 - - qcom,sm6125-dwc3 393 434 - qcom,sm6350-dwc3 394 435 - qcom,sm8150-dwc3 395 436 - qcom,sm8250-dwc3 396 437 - qcom,sm8350-dwc3 397 438 - qcom,sm8450-dwc3 398 439 - qcom,sm8550-dwc3 440 + - qcom,sm8650-dwc3 399 441 then: 400 442 properties: 401 443 interrupts: 402 - items: 403 - - description: The interrupt that is asserted 404 - when a wakeup event is received on USB2 bus. 405 - - description: The interrupt that is asserted 406 - when a wakeup event is received on USB3 bus. 407 - - description: Wakeup event on DM line. 408 - - description: Wakeup event on DP line. 409 - interrupt-names: 410 - items: 411 - - const: hs_phy_irq 412 - - const: ss_phy_irq 413 - - const: dm_hs_phy_irq 414 - - const: dp_hs_phy_irq 415 - 416 - - if: 417 - properties: 418 - compatible: 419 - contains: 420 - enum: 421 - - qcom,msm8953-dwc3 422 - - qcom,msm8996-dwc3 423 - - qcom,msm8998-dwc3 424 - - qcom,sm6115-dwc3 425 - then: 426 - properties: 427 - interrupts: 428 - maxItems: 2 429 - interrupt-names: 430 - items: 431 - - const: hs_phy_irq 432 - - const: ss_phy_irq 433 - 434 - - if: 435 - properties: 436 - compatible: 437 - contains: 438 - enum: 439 - - qcom,ipq5018-dwc3 440 - - qcom,ipq5332-dwc3 441 - - qcom,sdm660-dwc3 442 - then: 443 - properties: 444 - interrupts: 445 - minItems: 1 446 - maxItems: 2 447 - interrupt-names: 448 - minItems: 1 449 - items: 450 - - const: hs_phy_irq 451 - - const: ss_phy_irq 452 - 453 - - if: 454 - properties: 455 - compatible: 456 - contains: 457 - enum: 458 - - qcom,sc7280-dwc3 459 - then: 460 - properties: 461 - interrupts: 462 - minItems: 3 463 - maxItems: 4 464 - interrupt-names: 465 - minItems: 3 466 - items: 467 - - const: hs_phy_irq 468 - - const: dp_hs_phy_irq 469 - - const: dm_hs_phy_irq 470 - - const: ss_phy_irq 471 - 472 - - if: 473 - properties: 474 - compatible: 475 - contains: 476 - enum: 477 - - qcom,sc8280xp-dwc3 478 - then: 479 - properties: 480 - interrupts: 481 - maxItems: 4 444 + minItems: 4 445 + maxItems: 5 482 446 interrupt-names: 483 447 items: 484 448 - const: pwr_event 485 - - const: dp_hs_phy_irq 486 - - const: dm_hs_phy_irq 487 - - const: ss_phy_irq 488 - 489 - - if: 490 - properties: 491 - compatible: 492 - contains: 493 - enum: 494 - - qcom,sa8775p-dwc3 495 - then: 496 - properties: 497 - interrupts: 498 - minItems: 3 499 - maxItems: 4 500 - interrupt-names: 501 - minItems: 3 502 - items: 503 - - const: pwr_event 449 + - const: hs_phy_irq 504 450 - const: dp_hs_phy_irq 505 451 - const: dm_hs_phy_irq 506 452 - const: ss_phy_irq ··· 503 519 <&gcc GCC_USB30_PRIM_MASTER_CLK>; 504 520 assigned-clock-rates = <19200000>, <150000000>; 505 521 506 - interrupts = <GIC_SPI 131 IRQ_TYPE_LEVEL_HIGH>, 507 - <GIC_SPI 486 IRQ_TYPE_LEVEL_HIGH>, 522 + interrupts = <GIC_SPI 130 IRQ_TYPE_LEVEL_HIGH>, 523 + <GIC_SPI 131 IRQ_TYPE_LEVEL_HIGH>, 524 + <GIC_SPI 489 IRQ_TYPE_EDGE_BOTH>, 508 525 <GIC_SPI 488 IRQ_TYPE_EDGE_BOTH>, 509 - <GIC_SPI 489 IRQ_TYPE_EDGE_BOTH>; 510 - interrupt-names = "hs_phy_irq", "ss_phy_irq", 511 - "dm_hs_phy_irq", "dp_hs_phy_irq"; 526 + <GIC_SPI 486 IRQ_TYPE_LEVEL_HIGH>; 527 + interrupt-names = "pwr_event", "hs_phy_irq", 528 + "dp_hs_phy_irq", "dm_hs_phy_irq", "ss_phy_irq"; 512 529 513 530 power-domains = <&gcc USB30_PRIM_GDSC>; 514 531
+102
Documentation/devicetree/bindings/usb/qcom,wcd939x-usbss.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/qcom,wcd939x-usbss.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Qualcomm WCD9380/WCD9385 USB SubSystem Altmode/Analog Audio Switch 8 + 9 + maintainers: 10 + - Neil Armstrong <neil.armstrong@linaro.org> 11 + 12 + description: 13 + Qualcomm WCD9390/WCD9395 is a standalone Hi-Fi audio codec IC with a 14 + functionally separate USB SubSystem for Altmode/Analog Audio Switch 15 + accessible over an I2C interface. 16 + The Audio Headphone and Microphone data path between the Codec and the 17 + USB-C Mux subsystems are external to the IC, thus requiring DT port-endpoint 18 + graph description to handle USB-C altmode & orientation switching for Audio 19 + Accessory Mode. 20 + 21 + properties: 22 + compatible: 23 + oneOf: 24 + - const: qcom,wcd9390-usbss 25 + - items: 26 + - const: qcom,wcd9395-usbss 27 + - const: qcom,wcd9390-usbss 28 + 29 + reg: 30 + maxItems: 1 31 + 32 + reset-gpios: 33 + maxItems: 1 34 + 35 + vdd-supply: 36 + description: USBSS VDD power supply 37 + 38 + mode-switch: 39 + description: Flag the port as possible handle of altmode switching 40 + type: boolean 41 + 42 + orientation-switch: 43 + description: Flag the port as possible handler of orientation switching 44 + type: boolean 45 + 46 + ports: 47 + $ref: /schemas/graph.yaml#/properties/ports 48 + properties: 49 + port@0: 50 + $ref: /schemas/graph.yaml#/properties/port 51 + description: 52 + A port node to link the WCD939x USB SubSystem to a TypeC controller for the 53 + purpose of handling altmode muxing and orientation switching. 54 + 55 + port@1: 56 + $ref: /schemas/graph.yaml#/properties/port 57 + description: 58 + A port node to link the WCD939x USB SubSystem to the Codec SubSystem for the 59 + purpose of handling USB-C Audio Accessory Mode muxing and orientation switching. 60 + 61 + required: 62 + - compatible 63 + - reg 64 + - ports 65 + 66 + additionalProperties: false 67 + 68 + examples: 69 + - | 70 + i2c { 71 + #address-cells = <1>; 72 + #size-cells = <0>; 73 + 74 + typec-mux@42 { 75 + compatible = "qcom,wcd9390-usbss"; 76 + reg = <0x42>; 77 + 78 + vdd-supply = <&vreg_bob>; 79 + 80 + mode-switch; 81 + orientation-switch; 82 + 83 + ports { 84 + #address-cells = <1>; 85 + #size-cells = <0>; 86 + 87 + port@0 { 88 + reg = <0>; 89 + wcd9390_usbss_sbu: endpoint { 90 + remote-endpoint = <&typec_sbu>; 91 + }; 92 + }; 93 + port@1 { 94 + reg = <1>; 95 + wcd9390_usbss_codec: endpoint { 96 + remote-endpoint = <&wcd9390_codec_usbss>; 97 + }; 98 + }; 99 + }; 100 + }; 101 + }; 102 + ...
+1 -1
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 + - renesas,usbhs-r9a07g043 # RZ/G2UL and RZ/Five 23 23 - renesas,usbhs-r9a07g044 # RZ/G2{L,LC} 24 24 - renesas,usbhs-r9a07g054 # RZ/V2L 25 25 - const: renesas,rza2-usbhs
+4
Documentation/devicetree/bindings/usb/snps,dwc3.yaml
··· 432 432 items: 433 433 enum: [1, 4, 8, 16, 32, 64, 128, 256] 434 434 435 + num-hc-interrupters: 436 + maximum: 8 437 + default: 1 438 + 435 439 port: 436 440 $ref: /schemas/graph.yaml#/properties/port 437 441 description:
+6
Documentation/devicetree/bindings/usb/ti,tps6598x.yaml
··· 38 38 - const: main 39 39 - const: patch-address 40 40 41 + reset-gpios: 42 + description: GPIO used for the HRESET pin. 43 + maxItems: 1 44 + 41 45 wakeup-source: true 42 46 43 47 interrupts: ··· 94 90 95 91 examples: 96 92 - | 93 + #include <dt-bindings/gpio/gpio.h> 97 94 #include <dt-bindings/interrupt-controller/irq.h> 98 95 i2c { 99 96 #address-cells = <1>; ··· 111 106 112 107 pinctrl-names = "default"; 113 108 pinctrl-0 = <&typec_pins>; 109 + reset-gpios = <&gpio1 6 GPIO_ACTIVE_HIGH>; 114 110 115 111 typec_con: connector { 116 112 compatible = "usb-c-connector";
+6
Documentation/devicetree/bindings/usb/usb-xhci.yaml
··· 29 29 description: Interrupt moderation interval 30 30 default: 5000 31 31 32 + num-hc-interrupters: 33 + description: Maximum number of interrupters to allocate 34 + $ref: /schemas/types.yaml#/definitions/uint16 35 + minimum: 1 36 + maximum: 1024 37 + 32 38 additionalProperties: true 33 39 34 40 examples:
+11 -9
Documentation/usb/gadget-testing.rst
··· 448 448 The function name to use when creating the function directory is "ncm". 449 449 The NCM function provides these attributes in its function directory: 450 450 451 - =============== ================================================== 452 - ifname network device interface name associated with this 453 - function instance 454 - qmult queue length multiplier for high and super speed 455 - host_addr MAC address of host's end of this 456 - Ethernet over USB link 457 - dev_addr MAC address of device's end of this 458 - Ethernet over USB link 459 - =============== ================================================== 451 + =============== ================================================== 452 + ifname network device interface name associated with this 453 + function instance 454 + qmult queue length multiplier for high and super speed 455 + host_addr MAC address of host's end of this 456 + Ethernet over USB link 457 + dev_addr MAC address of device's end of this 458 + Ethernet over USB link 459 + max_segment_size Segment size required for P2P connections. This 460 + will set MTU to (max_segment_size - 14 bytes) 461 + =============== ================================================== 460 462 461 463 and after creating the functions/ncm.<instance name> they contain default 462 464 values: qmult is 5, dev_addr and host_addr are randomly selected.
-3
Documentation/usb/raw-gadget.rst
··· 81 81 Potential future improvements 82 82 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 83 83 84 - - Report more events (suspend, resume, etc.) through 85 - ``USB_RAW_IOCTL_EVENT_FETCH``. 86 - 87 84 - Support ``O_NONBLOCK`` I/O. This would be another mode of operation, where 88 85 Raw Gadget would not wait until the completion of each USB request. 89 86
+5
arch/arm/boot/dts/broadcom/bcm2711-rpi.dtsi
··· 1 1 // SPDX-License-Identifier: GPL-2.0 2 2 #include "bcm2835-rpi.dtsi" 3 3 4 + #include <dt-bindings/power/raspberrypi-power.h> 4 5 #include <dt-bindings/reset/raspberrypi,firmware-reset.h> 5 6 6 7 / { ··· 76 75 77 76 &vchiq { 78 77 interrupts = <GIC_SPI 34 IRQ_TYPE_LEVEL_HIGH>; 78 + }; 79 + 80 + &xhci { 81 + power-domains = <&power RPI_POWER_DOMAIN_USB>; 79 82 };
+14
arch/arm/boot/dts/broadcom/bcm2711.dtsi
··· 604 604 }; 605 605 }; 606 606 607 + xhci: usb@7e9c0000 { 608 + compatible = "brcm,bcm2711-xhci", "brcm,xhci-brcm-v2"; 609 + reg = <0x0 0x7e9c0000 0x100000>; 610 + #address-cells = <1>; 611 + #size-cells = <0>; 612 + interrupts = <GIC_SPI 176 IRQ_TYPE_LEVEL_HIGH>; 613 + /* DWC2 and this IP block share the same USB PHY, 614 + * enabling both at the same time results in lockups. 615 + * So keep this node disabled and let the bootloader 616 + * decide which interface should be enabled. 617 + */ 618 + status = "disabled"; 619 + }; 620 + 607 621 v3d: gpu@7ec00000 { 608 622 compatible = "brcm,2711-v3d"; 609 623 reg = <0x0 0x7ec00000 0x4000>,
+2
arch/arm64/boot/dts/mediatek/mt8195-cherry.dtsi
··· 1294 1294 &xhci0 { 1295 1295 status = "okay"; 1296 1296 1297 + rx-fifo-depth = <3072>; 1297 1298 vusb33-supply = <&mt6359_vusb_ldo_reg>; 1298 1299 vbus-supply = <&usb_vbus>; 1299 1300 }; ··· 1302 1301 &xhci1 { 1303 1302 status = "okay"; 1304 1303 1304 + rx-fifo-depth = <3072>; 1305 1305 vusb33-supply = <&mt6359_vusb_ldo_reg>; 1306 1306 vbus-supply = <&usb_vbus>; 1307 1307 };
-9
arch/arm64/boot/dts/qcom/msm8916.dtsi
··· 540 540 compatible = "qcom,msm8916-bimc"; 541 541 reg = <0x00400000 0x62000>; 542 542 #interconnect-cells = <1>; 543 - clock-names = "bus", "bus_a"; 544 - clocks = <&rpmcc RPM_SMD_BIMC_CLK>, 545 - <&rpmcc RPM_SMD_BIMC_A_CLK>; 546 543 }; 547 544 548 545 tsens: thermal-sensor@4a9000 { ··· 572 575 compatible = "qcom,msm8916-pcnoc"; 573 576 reg = <0x00500000 0x11000>; 574 577 #interconnect-cells = <1>; 575 - clock-names = "bus", "bus_a"; 576 - clocks = <&rpmcc RPM_SMD_PCNOC_CLK>, 577 - <&rpmcc RPM_SMD_PCNOC_A_CLK>; 578 578 }; 579 579 580 580 snoc: interconnect@580000 { 581 581 compatible = "qcom,msm8916-snoc"; 582 582 reg = <0x00580000 0x14000>; 583 583 #interconnect-cells = <1>; 584 - clock-names = "bus", "bus_a"; 585 - clocks = <&rpmcc RPM_SMD_SNOC_CLK>, 586 - <&rpmcc RPM_SMD_SNOC_A_CLK>; 587 584 }; 588 585 589 586 stm: stm@802000 {
-12
arch/arm64/boot/dts/qcom/msm8939.dtsi
··· 602 602 bimc: interconnect@400000 { 603 603 compatible = "qcom,msm8939-bimc"; 604 604 reg = <0x00400000 0x62000>; 605 - clock-names = "bus", "bus_a"; 606 - clocks = <&rpmcc RPM_SMD_BIMC_CLK>, 607 - <&rpmcc RPM_SMD_BIMC_A_CLK>; 608 605 #interconnect-cells = <1>; 609 606 }; 610 607 ··· 645 648 pcnoc: interconnect@500000 { 646 649 compatible = "qcom,msm8939-pcnoc"; 647 650 reg = <0x00500000 0x11000>; 648 - clock-names = "bus", "bus_a"; 649 - clocks = <&rpmcc RPM_SMD_PCNOC_CLK>, 650 - <&rpmcc RPM_SMD_PCNOC_A_CLK>; 651 651 #interconnect-cells = <1>; 652 652 }; 653 653 654 654 snoc: interconnect@580000 { 655 655 compatible = "qcom,msm8939-snoc"; 656 656 reg = <0x00580000 0x14080>; 657 - clock-names = "bus", "bus_a"; 658 - clocks = <&rpmcc RPM_SMD_SNOC_CLK>, 659 - <&rpmcc RPM_SMD_SNOC_A_CLK>; 660 657 #interconnect-cells = <1>; 661 658 662 659 snoc_mm: interconnect-snoc { 663 660 compatible = "qcom,msm8939-snoc-mm"; 664 - clock-names = "bus", "bus_a"; 665 - clocks = <&rpmcc RPM_SMD_SYSMMNOC_CLK>, 666 - <&rpmcc RPM_SMD_SYSMMNOC_A_CLK>; 667 661 #interconnect-cells = <1>; 668 662 }; 669 663 };
+14 -29
arch/arm64/boot/dts/qcom/msm8996.dtsi
··· 838 838 compatible = "qcom,msm8996-bimc"; 839 839 reg = <0x00408000 0x5a000>; 840 840 #interconnect-cells = <1>; 841 - clock-names = "bus", "bus_a"; 842 - clocks = <&rpmcc RPM_SMD_BIMC_CLK>, 843 - <&rpmcc RPM_SMD_BIMC_A_CLK>; 844 841 }; 845 842 846 843 tsens0: thermal-sensor@4a9000 { ··· 888 891 compatible = "qcom,msm8996-cnoc"; 889 892 reg = <0x00500000 0x1000>; 890 893 #interconnect-cells = <1>; 891 - clock-names = "bus", "bus_a"; 892 - clocks = <&rpmcc RPM_SMD_CNOC_CLK>, 893 - <&rpmcc RPM_SMD_CNOC_A_CLK>; 894 894 }; 895 895 896 896 snoc: interconnect@524000 { 897 897 compatible = "qcom,msm8996-snoc"; 898 898 reg = <0x00524000 0x1c000>; 899 899 #interconnect-cells = <1>; 900 - clock-names = "bus", "bus_a"; 901 - clocks = <&rpmcc RPM_SMD_SNOC_CLK>, 902 - <&rpmcc RPM_SMD_SNOC_A_CLK>; 903 900 }; 904 901 905 902 a0noc: interconnect@543000 { ··· 913 922 compatible = "qcom,msm8996-a1noc"; 914 923 reg = <0x00562000 0x5000>; 915 924 #interconnect-cells = <1>; 916 - clock-names = "bus", "bus_a"; 917 - clocks = <&rpmcc RPM_SMD_AGGR1_NOC_CLK>, 918 - <&rpmcc RPM_SMD_AGGR1_NOC_A_CLK>; 919 925 }; 920 926 921 927 a2noc: interconnect@583000 { 922 928 compatible = "qcom,msm8996-a2noc"; 923 929 reg = <0x00583000 0x7000>; 924 930 #interconnect-cells = <1>; 925 - clock-names = "bus", "bus_a", "aggre2_ufs_axi", "ufs_axi"; 926 - clocks = <&rpmcc RPM_SMD_AGGR2_NOC_CLK>, 927 - <&rpmcc RPM_SMD_AGGR2_NOC_A_CLK>, 928 - <&gcc GCC_AGGRE2_UFS_AXI_CLK>, 931 + clock-names = "aggre2_ufs_axi", "ufs_axi"; 932 + clocks = <&gcc GCC_AGGRE2_UFS_AXI_CLK>, 929 933 <&gcc GCC_UFS_AXI_CLK>; 930 934 }; 931 935 ··· 928 942 compatible = "qcom,msm8996-mnoc"; 929 943 reg = <0x005a4000 0x1c000>; 930 944 #interconnect-cells = <1>; 931 - clock-names = "bus", "bus_a", "iface"; 932 - clocks = <&rpmcc RPM_SMD_MMAXI_CLK>, 933 - <&rpmcc RPM_SMD_MMAXI_A_CLK>, 934 - <&mmcc AHB_CLK_SRC>; 945 + clock-names = "iface"; 946 + clocks = <&mmcc AHB_CLK_SRC>; 935 947 }; 936 948 937 949 pnoc: interconnect@5c0000 { 938 950 compatible = "qcom,msm8996-pnoc"; 939 951 reg = <0x005c0000 0x3000>; 940 952 #interconnect-cells = <1>; 941 - clock-names = "bus", "bus_a"; 942 - clocks = <&rpmcc RPM_SMD_PCNOC_CLK>, 943 - <&rpmcc RPM_SMD_PCNOC_A_CLK>; 944 953 }; 945 954 946 955 tcsr_mutex: hwlock@740000 { ··· 2467 2486 "handover", 2468 2487 "stop-ack"; 2469 2488 2470 - clocks = <&xo_board>, 2471 - <&rpmcc RPM_SMD_AGGR2_NOC_CLK>; 2472 - clock-names = "xo", "aggre2"; 2489 + clocks = <&xo_board>; 2490 + clock-names = "xo"; 2473 2491 2474 2492 memory-region = <&slpi_mem>; 2475 2493 ··· 2513 2533 <&gcc GCC_MSS_GPLL0_DIV_CLK>, 2514 2534 <&gcc GCC_MSS_SNOC_AXI_CLK>, 2515 2535 <&gcc GCC_MSS_MNOC_BIMC_AXI_CLK>, 2516 - <&rpmcc RPM_SMD_PCNOC_CLK>, 2517 2536 <&rpmcc RPM_SMD_QDSS_CLK>; 2518 - clock-names = "iface", "bus", "mem", "xo", "gpll0_mss", 2519 - "snoc_axi", "mnoc_axi", "pnoc", "qdss"; 2537 + clock-names = "iface", 2538 + "bus", 2539 + "mem", 2540 + "xo", 2541 + "gpll0_mss", 2542 + "snoc_axi", 2543 + "mnoc_axi", 2544 + "qdss"; 2520 2545 2521 2546 resets = <&gcc GCC_MSS_RESTART>; 2522 2547 reset-names = "mss_restart";
+2 -3
arch/arm64/boot/dts/qcom/msm8998.dtsi
··· 1605 1605 1606 1606 px-supply = <&vreg_lvs2a_1p8>; 1607 1607 1608 - clocks = <&rpmcc RPM_SMD_XO_CLK_SRC>, 1609 - <&rpmcc RPM_SMD_AGGR2_NOC_CLK>; 1610 - clock-names = "xo", "aggre2"; 1608 + clocks = <&rpmcc RPM_SMD_XO_CLK_SRC>; 1609 + clock-names = "xo"; 1611 1610 1612 1611 memory-region = <&slpi_mem>; 1613 1612
-9
arch/arm64/boot/dts/qcom/qcs404.dtsi
··· 558 558 reg = <0x00400000 0x80000>; 559 559 compatible = "qcom,qcs404-bimc"; 560 560 #interconnect-cells = <1>; 561 - clock-names = "bus", "bus_a"; 562 - clocks = <&rpmcc RPM_SMD_BIMC_CLK>, 563 - <&rpmcc RPM_SMD_BIMC_A_CLK>; 564 561 }; 565 562 566 563 tsens: thermal-sensor@4a9000 { ··· 598 601 reg = <0x00500000 0x15080>; 599 602 compatible = "qcom,qcs404-pcnoc"; 600 603 #interconnect-cells = <1>; 601 - clock-names = "bus", "bus_a"; 602 - clocks = <&rpmcc RPM_SMD_PNOC_CLK>, 603 - <&rpmcc RPM_SMD_PNOC_A_CLK>; 604 604 }; 605 605 606 606 snoc: interconnect@580000 { 607 607 reg = <0x00580000 0x23080>; 608 608 compatible = "qcom,qcs404-snoc"; 609 609 #interconnect-cells = <1>; 610 - clock-names = "bus", "bus_a"; 611 - clocks = <&rpmcc RPM_SMD_SNOC_CLK>, 612 - <&rpmcc RPM_SMD_SNOC_A_CLK>; 613 610 }; 614 611 615 612 remoteproc_cdsp: remoteproc@b00000 {
+1 -1
arch/arm64/boot/dts/qcom/qrb5165-rb5.dts
··· 1454 1454 1455 1455 altmodes { 1456 1456 displayport { 1457 - svid = <0xff01>; 1457 + svid = /bits/ 16 <0xff01>; 1458 1458 vdo = <0x00001c46>; 1459 1459 }; 1460 1460 };
+12 -41
arch/arm64/boot/dts/qcom/sdm630.dtsi
··· 606 606 compatible = "qcom,sdm660-bimc"; 607 607 reg = <0x01008000 0x78000>; 608 608 #interconnect-cells = <1>; 609 - clock-names = "bus", "bus_a"; 610 - clocks = <&rpmcc RPM_SMD_BIMC_CLK>, 611 - <&rpmcc RPM_SMD_BIMC_A_CLK>; 612 609 }; 613 610 614 611 restart@10ac000 { ··· 617 620 compatible = "qcom,sdm660-cnoc"; 618 621 reg = <0x01500000 0x10000>; 619 622 #interconnect-cells = <1>; 620 - clock-names = "bus", "bus_a"; 621 - clocks = <&rpmcc RPM_SMD_CNOC_CLK>, 622 - <&rpmcc RPM_SMD_CNOC_A_CLK>; 623 623 }; 624 624 625 625 snoc: interconnect@1626000 { 626 626 compatible = "qcom,sdm660-snoc"; 627 627 reg = <0x01626000 0x7090>; 628 628 #interconnect-cells = <1>; 629 - clock-names = "bus", "bus_a"; 630 - clocks = <&rpmcc RPM_SMD_SNOC_CLK>, 631 - <&rpmcc RPM_SMD_SNOC_A_CLK>; 632 629 }; 633 630 634 631 anoc2_smmu: iommu@16c0000 { 635 632 compatible = "qcom,sdm630-smmu-v2", "qcom,smmu-v2"; 636 633 reg = <0x016c0000 0x40000>; 637 - 638 - assigned-clocks = <&rpmcc RPM_SMD_AGGR2_NOC_CLK>; 639 - assigned-clock-rates = <1000>; 640 - clocks = <&rpmcc RPM_SMD_AGGR2_NOC_CLK>; 641 - clock-names = "bus"; 642 634 #global-interrupts = <2>; 643 635 #iommu-cells = <1>; 644 636 ··· 672 686 compatible = "qcom,sdm660-a2noc"; 673 687 reg = <0x01704000 0xc100>; 674 688 #interconnect-cells = <1>; 675 - clock-names = "bus", 676 - "bus_a", 677 - "ipa", 689 + clock-names = "ipa", 678 690 "ufs_axi", 679 691 "aggre2_ufs_axi", 680 692 "aggre2_usb3_axi", 681 693 "cfg_noc_usb2_axi"; 682 - clocks = <&rpmcc RPM_SMD_AGGR2_NOC_CLK>, 683 - <&rpmcc RPM_SMD_AGGR2_NOC_A_CLK>, 684 - <&rpmcc RPM_SMD_IPA_CLK>, 694 + clocks = <&rpmcc RPM_SMD_IPA_CLK>, 685 695 <&gcc GCC_UFS_AXI_CLK>, 686 696 <&gcc GCC_AGGRE2_UFS_AXI_CLK>, 687 697 <&gcc GCC_AGGRE2_USB3_AXI_CLK>, ··· 688 706 compatible = "qcom,sdm660-mnoc"; 689 707 reg = <0x01745000 0xa010>; 690 708 #interconnect-cells = <1>; 691 - clock-names = "bus", "bus_a", "iface"; 692 - clocks = <&rpmcc RPM_SMD_MMSSNOC_AXI_CLK>, 693 - <&rpmcc RPM_SMD_MMSSNOC_AXI_CLK_A>, 694 - <&mmcc AHB_CLK_SRC>; 709 + clock-names = "iface"; 710 + clocks = <&mmcc AHB_CLK_SRC>; 695 711 }; 696 712 697 713 tsens: thermal-sensor@10ae000 { ··· 1166 1186 clocks = <&gcc GCC_GPU_CFG_AHB_CLK>, 1167 1187 <&gcc GCC_BIMC_GFX_CLK>, 1168 1188 <&gcc GCC_GPU_BIMC_GFX_CLK>; 1169 - clock-names = "iface", "mem", "mem_iface"; 1189 + clock-names = "iface", 1190 + "mem", 1191 + "mem_iface"; 1170 1192 #global-interrupts = <2>; 1171 1193 #iommu-cells = <1>; 1172 1194 ··· 1270 1288 <&gcc GCC_USB30_MASTER_CLK>, 1271 1289 <&gcc GCC_AGGRE2_USB3_AXI_CLK>, 1272 1290 <&gcc GCC_USB30_SLEEP_CLK>, 1273 - <&gcc GCC_USB30_MOCK_UTMI_CLK>, 1274 - <&rpmcc RPM_SMD_AGGR2_NOC_CLK>; 1291 + <&gcc GCC_USB30_MOCK_UTMI_CLK>; 1275 1292 clock-names = "cfg_noc", 1276 1293 "core", 1277 1294 "iface", 1278 1295 "sleep", 1279 - "mock_utmi", 1280 - "bus"; 1296 + "mock_utmi"; 1281 1297 1282 1298 assigned-clocks = <&gcc GCC_USB30_MOCK_UTMI_CLK>, 1283 - <&gcc GCC_USB30_MASTER_CLK>, 1284 - <&rpmcc RPM_SMD_AGGR2_NOC_CLK>; 1285 - assigned-clock-rates = <19200000>, <120000000>, 1286 - <19200000>; 1299 + <&gcc GCC_USB30_MASTER_CLK>; 1300 + assigned-clock-rates = <19200000>, <120000000>; 1287 1301 1288 1302 interrupts = <GIC_SPI 347 IRQ_TYPE_LEVEL_HIGH>, 1289 1303 <GIC_SPI 243 IRQ_TYPE_LEVEL_HIGH>; ··· 2182 2204 2183 2205 clocks = <&mmcc MNOC_AHB_CLK>, 2184 2206 <&mmcc BIMC_SMMU_AHB_CLK>, 2185 - <&rpmcc RPM_SMD_MMSSNOC_AXI_CLK>, 2186 2207 <&mmcc BIMC_SMMU_AXI_CLK>; 2187 2208 clock-names = "iface-mm", "iface-smmu", 2188 - "bus-mm", "bus-smmu"; 2209 + "bus-smmu"; 2189 2210 #global-interrupts = <2>; 2190 2211 #iommu-cells = <1>; 2191 2212 ··· 2301 2324 compatible = "qcom,sdm660-gnoc"; 2302 2325 reg = <0x17900000 0xe000>; 2303 2326 #interconnect-cells = <1>; 2304 - /* 2305 - * This one apparently features no clocks, 2306 - * so let's not mess with the driver needlessly 2307 - */ 2308 - clock-names = "bus", "bus_a"; 2309 - clocks = <&xo_board>, <&xo_board>; 2310 2327 }; 2311 2328 2312 2329 apcs_glb: mailbox@17911000 {
+2 -4
drivers/bluetooth/btusb.c
··· 4796 4796 .disable_hub_initiated_lpm = 1, 4797 4797 4798 4798 #ifdef CONFIG_DEV_COREDUMP 4799 - .drvwrap = { 4800 - .driver = { 4801 - .coredump = btusb_coredump, 4802 - }, 4799 + .driver = { 4800 + .coredump = btusb_coredump, 4803 4801 }, 4804 4802 #endif 4805 4803 };
+1 -1
drivers/net/can/usb/peak_usb/pcan_usb_core.c
··· 1143 1143 int err; 1144 1144 1145 1145 /* last chance do send any synchronous commands here */ 1146 - err = driver_for_each_device(&peak_usb_driver.drvwrap.driver, NULL, 1146 + err = driver_for_each_device(&peak_usb_driver.driver, NULL, 1147 1147 NULL, peak_usb_do_device_exit); 1148 1148 if (err) 1149 1149 pr_err("%s: failed to stop all can devices (err %d)\n",
+5 -11
drivers/net/usb/r8152.c
··· 10069 10069 .disable_hub_initiated_lpm = 1, 10070 10070 }; 10071 10071 10072 - static int rtl8152_cfgselector_probe(struct usb_device *udev) 10072 + static int rtl8152_cfgselector_choose_configuration(struct usb_device *udev) 10073 10073 { 10074 10074 struct usb_host_config *c; 10075 10075 int i, num_configs; ··· 10096 10096 if (i == num_configs) 10097 10097 return -ENODEV; 10098 10098 10099 - if (usb_set_configuration(udev, c->desc.bConfigurationValue)) { 10100 - dev_err(&udev->dev, "Failed to set configuration %d\n", 10101 - c->desc.bConfigurationValue); 10102 - return -ENODEV; 10103 - } 10104 - 10105 - return 0; 10099 + return c->desc.bConfigurationValue; 10106 10100 } 10107 10101 10108 10102 static struct usb_device_driver rtl8152_cfgselector_driver = { 10109 - .name = MODULENAME "-cfgselector", 10110 - .probe = rtl8152_cfgselector_probe, 10111 - .id_table = rtl8152_table, 10103 + .name = MODULENAME "-cfgselector", 10104 + .choose_configuration = rtl8152_cfgselector_choose_configuration, 10105 + .id_table = rtl8152_table, 10112 10106 .generic_subclass = 1, 10113 10107 .supports_autosuspend = 1, 10114 10108 };
+1 -1
drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c
··· 1581 1581 1582 1582 void brcmf_usb_exit(void) 1583 1583 { 1584 - struct device_driver *drv = &brcmf_usbdrvr.drvwrap.driver; 1584 + struct device_driver *drv = &brcmf_usbdrvr.driver; 1585 1585 int ret; 1586 1586 1587 1587 brcmf_dbg(USB, "Enter\n");
+1 -1
drivers/net/wireless/marvell/mwifiex/usb.c
··· 687 687 .suspend = mwifiex_usb_suspend, 688 688 .resume = mwifiex_usb_resume, 689 689 .soft_unbind = 1, 690 - .drvwrap.driver = { 690 + .driver = { 691 691 .coredump = mwifiex_usb_coredump, 692 692 }, 693 693 };
+1 -1
drivers/platform/x86/intel/chtwc_int33fe.c
··· 136 136 }; 137 137 138 138 static const struct property_entry dp_altmode_properties[] = { 139 - PROPERTY_ENTRY_U32("svid", 0xff01), 139 + PROPERTY_ENTRY_U16("svid", 0xff01), 140 140 PROPERTY_ENTRY_U32("vdo", 0x0c0086), 141 141 { } 142 142 };
+1 -1
drivers/thunderbolt/domain.c
··· 307 307 NULL, 308 308 }; 309 309 310 - struct bus_type tb_bus_type = { 310 + const struct bus_type tb_bus_type = { 311 311 .name = "thunderbolt", 312 312 .match = tb_service_match, 313 313 .probe = tb_service_probe,
+1 -1
drivers/thunderbolt/icm.c
··· 1020 1020 1021 1021 memset(&reply, 0, sizeof(reply)); 1022 1022 ret = icm_request(tb, &request, sizeof(request), &reply, sizeof(reply), 1023 - 1, 10, 2000); 1023 + 1, 10, 250); 1024 1024 if (ret) 1025 1025 return ret; 1026 1026
+4
drivers/thunderbolt/nhi.c
··· 1517 1517 .driver_data = (kernel_ulong_t)&icl_nhi_ops }, 1518 1518 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_MTL_P_NHI1), 1519 1519 .driver_data = (kernel_ulong_t)&icl_nhi_ops }, 1520 + { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_LNL_NHI0), 1521 + .driver_data = (kernel_ulong_t)&icl_nhi_ops }, 1522 + { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_LNL_NHI1), 1523 + .driver_data = (kernel_ulong_t)&icl_nhi_ops }, 1520 1524 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_BARLOW_RIDGE_HOST_80G_NHI) }, 1521 1525 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_BARLOW_RIDGE_HOST_40G_NHI) }, 1522 1526
+2
drivers/thunderbolt/nhi.h
··· 90 90 #define PCI_DEVICE_ID_INTEL_TGL_H_NHI1 0x9a21 91 91 #define PCI_DEVICE_ID_INTEL_RPL_NHI0 0xa73e 92 92 #define PCI_DEVICE_ID_INTEL_RPL_NHI1 0xa76d 93 + #define PCI_DEVICE_ID_INTEL_LNL_NHI0 0xa833 94 + #define PCI_DEVICE_ID_INTEL_LNL_NHI1 0xa834 93 95 94 96 #define PCI_CLASS_SERIAL_USB_USB4 0x0c0340 95 97
+15 -18
drivers/thunderbolt/switch.c
··· 941 941 } 942 942 } 943 943 944 - static const char *width_name(enum tb_link_width width) 945 - { 946 - switch (width) { 947 - case TB_LINK_WIDTH_SINGLE: 948 - return "symmetric, single lane"; 949 - case TB_LINK_WIDTH_DUAL: 950 - return "symmetric, dual lanes"; 951 - case TB_LINK_WIDTH_ASYM_TX: 952 - return "asymmetric, 3 transmitters, 1 receiver"; 953 - case TB_LINK_WIDTH_ASYM_RX: 954 - return "asymmetric, 3 receivers, 1 transmitter"; 955 - default: 956 - return "unknown"; 957 - } 958 - } 959 - 960 944 /** 961 945 * tb_port_get_link_width() - Get current link width 962 946 * @port: Port to check (USB4 or CIO) ··· 2753 2769 return; 2754 2770 2755 2771 tb_sw_dbg(sw, "current link speed %u.0 Gb/s\n", sw->link_speed); 2756 - tb_sw_dbg(sw, "current link width %s\n", width_name(sw->link_width)); 2772 + tb_sw_dbg(sw, "current link width %s\n", tb_width_name(sw->link_width)); 2757 2773 2758 2774 bonded = sw->link_width >= TB_LINK_WIDTH_DUAL; 2759 2775 ··· 2773 2789 if (down->dual_link_port) 2774 2790 down->dual_link_port->bonded = bonded; 2775 2791 tb_port_update_credits(down); 2792 + 2793 + if (tb_port_get_link_generation(up) < 4) 2794 + return; 2795 + 2796 + /* 2797 + * Set the Gen 4 preferred link width. This is what the router 2798 + * prefers when the link is brought up. If the router does not 2799 + * support asymmetric link configuration, this also will be set 2800 + * to TB_LINK_WIDTH_DUAL. 2801 + */ 2802 + sw->preferred_link_width = sw->link_width; 2803 + tb_sw_dbg(sw, "preferred link width %s\n", 2804 + tb_width_name(sw->preferred_link_width)); 2776 2805 } 2777 2806 2778 2807 /** ··· 3026 3029 3027 3030 tb_switch_update_link_attributes(sw); 3028 3031 3029 - tb_sw_dbg(sw, "link width set to %s\n", width_name(width)); 3032 + tb_sw_dbg(sw, "link width set to %s\n", tb_width_name(width)); 3030 3033 return ret; 3031 3034 } 3032 3035
+50 -24
drivers/thunderbolt/tb.c
··· 513 513 usb4_port_unconfigure_xdomain(port); 514 514 else 515 515 tb_lc_unconfigure_xdomain(port); 516 - 517 - tb_port_enable(port->dual_link_port); 518 516 } 519 517 520 518 static void tb_scan_xdomain(struct tb_port *port) ··· 1085 1087 struct tb_port *dst_port, int requested_up, 1086 1088 int requested_down) 1087 1089 { 1090 + bool clx = false, clx_disabled = false, downstream; 1088 1091 struct tb_switch *sw; 1089 - bool clx, downstream; 1090 1092 struct tb_port *up; 1091 1093 int ret = 0; 1092 1094 1093 1095 if (!asym_threshold) 1094 1096 return 0; 1095 1097 1096 - /* Disable CL states before doing any transitions */ 1097 1098 downstream = tb_port_path_direction_downstream(src_port, dst_port); 1098 1099 /* Pick up router deepest in the hierarchy */ 1099 1100 if (downstream) ··· 1100 1103 else 1101 1104 sw = src_port->sw; 1102 1105 1103 - clx = tb_disable_clx(sw); 1104 - 1105 1106 tb_for_each_upstream_port_on_path(src_port, dst_port, up) { 1107 + struct tb_port *down = tb_switch_downstream_port(up->sw); 1108 + enum tb_link_width width_up, width_down; 1106 1109 int consumed_up, consumed_down; 1107 - enum tb_link_width width; 1108 1110 1109 1111 ret = tb_consumed_dp_bandwidth(tb, src_port, dst_port, up, 1110 1112 &consumed_up, &consumed_down); ··· 1124 1128 if (consumed_down + requested_down < asym_threshold) 1125 1129 continue; 1126 1130 1127 - width = TB_LINK_WIDTH_ASYM_RX; 1131 + width_up = TB_LINK_WIDTH_ASYM_RX; 1132 + width_down = TB_LINK_WIDTH_ASYM_TX; 1128 1133 } else { 1129 1134 /* Upstream, the opposite of above */ 1130 1135 if (consumed_down + requested_down >= TB_ASYM_MIN) { ··· 1135 1138 if (consumed_up + requested_up < asym_threshold) 1136 1139 continue; 1137 1140 1138 - width = TB_LINK_WIDTH_ASYM_TX; 1141 + width_up = TB_LINK_WIDTH_ASYM_TX; 1142 + width_down = TB_LINK_WIDTH_ASYM_RX; 1139 1143 } 1140 1144 1141 - if (up->sw->link_width == width) 1145 + if (up->sw->link_width == width_up) 1142 1146 continue; 1143 1147 1144 - if (!tb_port_width_supported(up, width)) 1148 + if (!tb_port_width_supported(up, width_up) || 1149 + !tb_port_width_supported(down, width_down)) 1145 1150 continue; 1151 + 1152 + /* 1153 + * Disable CL states before doing any transitions. We 1154 + * delayed it until now that we know there is a real 1155 + * transition taking place. 1156 + */ 1157 + if (!clx_disabled) { 1158 + clx = tb_disable_clx(sw); 1159 + clx_disabled = true; 1160 + } 1146 1161 1147 1162 tb_sw_dbg(up->sw, "configuring asymmetric link\n"); 1148 1163 ··· 1162 1153 * Here requested + consumed > threshold so we need to 1163 1154 * transtion the link into asymmetric now. 1164 1155 */ 1165 - ret = tb_switch_set_link_width(up->sw, width); 1156 + ret = tb_switch_set_link_width(up->sw, width_up); 1166 1157 if (ret) { 1167 1158 tb_sw_warn(up->sw, "failed to set link width\n"); 1168 1159 break; ··· 1183 1174 * @dst_port: Destination adapter 1184 1175 * @requested_up: New lower bandwidth request upstream (Mb/s) 1185 1176 * @requested_down: New lower bandwidth request downstream (Mb/s) 1177 + * @keep_asym: Keep asymmetric link if preferred 1186 1178 * 1187 1179 * Goes over each link from @src_port to @dst_port and tries to 1188 1180 * transition the link to symmetric if the currently consumed bandwidth 1189 - * allows. 1181 + * allows and link asymmetric preference is ignored (if @keep_asym is %false). 1190 1182 */ 1191 1183 static int tb_configure_sym(struct tb *tb, struct tb_port *src_port, 1192 1184 struct tb_port *dst_port, int requested_up, 1193 - int requested_down) 1185 + int requested_down, bool keep_asym) 1194 1186 { 1187 + bool clx = false, clx_disabled = false, downstream; 1195 1188 struct tb_switch *sw; 1196 - bool clx, downstream; 1197 1189 struct tb_port *up; 1198 1190 int ret = 0; 1199 1191 1200 1192 if (!asym_threshold) 1201 1193 return 0; 1202 1194 1203 - /* Disable CL states before doing any transitions */ 1204 1195 downstream = tb_port_path_direction_downstream(src_port, dst_port); 1205 1196 /* Pick up router deepest in the hierarchy */ 1206 1197 if (downstream) 1207 1198 sw = dst_port->sw; 1208 1199 else 1209 1200 sw = src_port->sw; 1210 - 1211 - clx = tb_disable_clx(sw); 1212 1201 1213 1202 tb_for_each_upstream_port_on_path(src_port, dst_port, up) { 1214 1203 int consumed_up, consumed_down; ··· 1239 1232 1240 1233 if (up->sw->link_width == TB_LINK_WIDTH_DUAL) 1241 1234 continue; 1235 + 1236 + /* 1237 + * Here consumed < threshold so we can transition the 1238 + * link to symmetric. 1239 + * 1240 + * However, if the router prefers asymmetric link we 1241 + * honor that (unless @keep_asym is %false). 1242 + */ 1243 + if (keep_asym && 1244 + up->sw->preferred_link_width > TB_LINK_WIDTH_DUAL) { 1245 + tb_sw_dbg(up->sw, "keeping preferred asymmetric link\n"); 1246 + continue; 1247 + } 1248 + 1249 + /* Disable CL states before doing any transitions */ 1250 + if (!clx_disabled) { 1251 + clx = tb_disable_clx(sw); 1252 + clx_disabled = true; 1253 + } 1242 1254 1243 1255 tb_sw_dbg(up->sw, "configuring symmetric link\n"); 1244 1256 ··· 1306 1280 struct tb_port *host_port; 1307 1281 1308 1282 host_port = tb_port_at(tb_route(sw), tb->root_switch); 1309 - tb_configure_sym(tb, host_port, up, 0, 0); 1283 + tb_configure_sym(tb, host_port, up, 0, 0, false); 1310 1284 } 1311 1285 1312 1286 /* Set the link configured */ ··· 1491 1465 * If bandwidth on a link is < asym_threshold 1492 1466 * transition the link to symmetric. 1493 1467 */ 1494 - tb_configure_sym(tb, src_port, dst_port, 0, 0); 1468 + tb_configure_sym(tb, src_port, dst_port, 0, 0, true); 1495 1469 /* Now we can allow the domain to runtime suspend again */ 1496 1470 pm_runtime_mark_last_busy(&dst_port->sw->dev); 1497 1471 pm_runtime_put_autosuspend(&dst_port->sw->dev); ··· 1927 1901 return; 1928 1902 } 1929 1903 1930 - tb_port_dbg(port, "DP %s resource available\n", 1904 + tb_port_dbg(port, "DP %s resource available after hotplug\n", 1931 1905 tb_port_is_dpin(port) ? "IN" : "OUT"); 1932 1906 list_add_tail(&port->list, &tcm->dp_resources); 1933 1907 ··· 2313 2287 * If bandwidth on a link is < asym_threshold transition 2314 2288 * the link to symmetric. 2315 2289 */ 2316 - tb_configure_sym(tb, in, out, *requested_up, *requested_down); 2290 + tb_configure_sym(tb, in, out, *requested_up, *requested_down, true); 2317 2291 /* 2318 2292 * If requested bandwidth is less or equal than what is 2319 2293 * currently allocated to that tunnel we simply change ··· 2356 2330 ret = tb_configure_asym(tb, in, out, *requested_up, 2357 2331 *requested_down); 2358 2332 if (ret) { 2359 - tb_configure_sym(tb, in, out, 0, 0); 2333 + tb_configure_sym(tb, in, out, 0, 0, true); 2360 2334 return ret; 2361 2335 } 2362 2336 ··· 2364 2338 requested_down); 2365 2339 if (ret) { 2366 2340 tb_tunnel_warn(tunnel, "failed to allocate bandwidth\n"); 2367 - tb_configure_sym(tb, in, out, 0, 0); 2341 + tb_configure_sym(tb, in, out, 0, 0, true); 2368 2342 } 2369 2343 } else { 2370 2344 ret = -ENOBUFS;
+18
drivers/thunderbolt/tb.h
··· 125 125 * @device_name: Name of the device (or %NULL if not known) 126 126 * @link_speed: Speed of the link in Gb/s 127 127 * @link_width: Width of the upstream facing link 128 + * @preferred_link_width: Router preferred link width (only set for Gen 4 links) 128 129 * @link_usb4: Upstream link is USB4 129 130 * @generation: Switch Thunderbolt generation 130 131 * @cap_plug_events: Offset to the plug events capability (%0 if not found) ··· 179 178 const char *device_name; 180 179 unsigned int link_speed; 181 180 enum tb_link_width link_width; 181 + enum tb_link_width preferred_link_width; 182 182 bool link_usb4; 183 183 unsigned int generation; 184 184 int cap_plug_events; ··· 568 566 if (WARN_ON(port > sw->config.max_port_number)) 569 567 return NULL; 570 568 return &sw->ports[port]; 569 + } 570 + 571 + static inline const char *tb_width_name(enum tb_link_width width) 572 + { 573 + switch (width) { 574 + case TB_LINK_WIDTH_SINGLE: 575 + return "symmetric, single lane"; 576 + case TB_LINK_WIDTH_DUAL: 577 + return "symmetric, dual lanes"; 578 + case TB_LINK_WIDTH_ASYM_TX: 579 + return "asymmetric, 3 transmitters, 1 receiver"; 580 + case TB_LINK_WIDTH_ASYM_RX: 581 + return "asymmetric, 3 receivers, 1 transmitter"; 582 + default: 583 + return "unknown"; 584 + } 571 585 } 572 586 573 587 /**
+1 -1
drivers/thunderbolt/tmu.c
··· 894 894 895 895 ret = tb_switch_set_tmu_mode_params(sw, sw->tmu.mode_request); 896 896 if (ret) 897 - return ret; 897 + goto out; 898 898 899 899 /* Program the new mode and the downstream router lane adapter */ 900 900 switch (sw->tmu.mode_request) {
+32 -14
drivers/thunderbolt/tunnel.c
··· 173 173 int ret; 174 174 175 175 /* Only supported of both routers are at least USB4 v2 */ 176 - if (tb_port_get_link_generation(port) < 4) 176 + if ((usb4_switch_version(tunnel->src_port->sw) < 2) || 177 + (usb4_switch_version(tunnel->dst_port->sw) < 2)) 178 + return 0; 179 + 180 + if (enable && tb_port_get_link_generation(port) < 4) 177 181 return 0; 178 182 179 183 ret = usb4_pci_port_set_ext_encapsulation(tunnel->src_port, enable); 180 184 if (ret) 181 185 return ret; 182 186 187 + /* 188 + * Downstream router could be unplugged so disable of encapsulation 189 + * in upstream router is still possible. 190 + */ 183 191 ret = usb4_pci_port_set_ext_encapsulation(tunnel->dst_port, enable); 184 - if (ret) 185 - return ret; 192 + if (ret) { 193 + if (enable) 194 + return ret; 195 + if (ret != -ENODEV) 196 + return ret; 197 + } 186 198 187 199 tb_tunnel_dbg(tunnel, "extended encapsulation %s\n", 188 200 str_enabled_disabled(enable)); ··· 211 199 return res; 212 200 } 213 201 214 - res = tb_pci_port_enable(tunnel->src_port, activate); 202 + if (activate) 203 + res = tb_pci_port_enable(tunnel->dst_port, activate); 204 + else 205 + res = tb_pci_port_enable(tunnel->src_port, activate); 215 206 if (res) 216 207 return res; 217 208 218 - if (tb_port_is_pcie_up(tunnel->dst_port)) { 219 - res = tb_pci_port_enable(tunnel->dst_port, activate); 209 + 210 + if (activate) { 211 + res = tb_pci_port_enable(tunnel->src_port, activate); 220 212 if (res) 221 213 return res; 214 + } else { 215 + /* Downstream router could be unplugged */ 216 + tb_pci_port_enable(tunnel->dst_port, activate); 222 217 } 223 218 224 219 return activate ? 0 : tb_pci_set_ext_encapsulation(tunnel, activate); ··· 1086 1067 return 0; 1087 1068 } 1088 1069 1089 - static int tb_dp_read_dprx(struct tb_tunnel *tunnel, u32 *rate, u32 *lanes, 1090 - int timeout_msec) 1070 + static int tb_dp_wait_dprx(struct tb_tunnel *tunnel, int timeout_msec) 1091 1071 { 1092 1072 ktime_t timeout = ktime_add_ms(ktime_get(), timeout_msec); 1093 1073 struct tb_port *in = tunnel->src_port; ··· 1105 1087 return ret; 1106 1088 1107 1089 if (val & DP_COMMON_CAP_DPRX_DONE) { 1108 - *rate = tb_dp_cap_get_rate(val); 1109 - *lanes = tb_dp_cap_get_lanes(val); 1110 - 1111 1090 tb_tunnel_dbg(tunnel, "DPRX read done\n"); 1112 1091 return 0; 1113 1092 } 1114 1093 usleep_range(100, 150); 1115 1094 } while (ktime_before(ktime_get(), timeout)); 1116 1095 1096 + tb_tunnel_dbg(tunnel, "DPRX read timeout\n"); 1117 1097 return -ETIMEDOUT; 1118 1098 } 1119 1099 ··· 1126 1110 switch (cap) { 1127 1111 case DP_LOCAL_CAP: 1128 1112 case DP_REMOTE_CAP: 1113 + case DP_COMMON_CAP: 1129 1114 break; 1130 1115 1131 1116 default: ··· 1199 1182 * reduced one). Otherwise return the remote (possibly 1200 1183 * reduced) caps. 1201 1184 */ 1202 - ret = tb_dp_read_dprx(tunnel, &rate, &lanes, 150); 1185 + ret = tb_dp_wait_dprx(tunnel, 150); 1203 1186 if (ret) { 1204 1187 if (ret == -ETIMEDOUT) 1205 1188 ret = tb_dp_read_cap(tunnel, DP_REMOTE_CAP, ··· 1207 1190 if (ret) 1208 1191 return ret; 1209 1192 } 1193 + ret = tb_dp_read_cap(tunnel, DP_COMMON_CAP, &rate, &lanes); 1194 + if (ret) 1195 + return ret; 1210 1196 } else if (sw->generation >= 2) { 1211 1197 ret = tb_dp_read_cap(tunnel, DP_REMOTE_CAP, &rate, &lanes); 1212 1198 if (ret) ··· 1332 1312 tb_tunnel_dbg(tunnel, 1333 1313 "DP IN maximum supported bandwidth %u Mb/s x%u = %u Mb/s\n", 1334 1314 rate, lanes, tb_dp_bandwidth(rate, lanes)); 1335 - 1336 - out = tunnel->dst_port; 1337 1315 1338 1316 if (tb_port_read(out, &dp_cap, TB_CFG_PORT, 1339 1317 out->cap_adap + DP_LOCAL_CAP, 1))
+53 -1
drivers/thunderbolt/xdomain.c
··· 1462 1462 tb_port_disable(port->dual_link_port); 1463 1463 } 1464 1464 1465 + dev_dbg(&xd->dev, "current link speed %u.0 Gb/s\n", 1466 + xd->link_speed); 1467 + dev_dbg(&xd->dev, "current link width %s\n", 1468 + tb_width_name(xd->link_width)); 1469 + 1465 1470 if (device_add(&xd->dev)) { 1466 1471 dev_err(&xd->dev, "failed to add XDomain device\n"); 1467 1472 return -ENODEV; ··· 1900 1895 }; 1901 1896 EXPORT_SYMBOL_GPL(tb_xdomain_type); 1902 1897 1898 + static void tb_xdomain_link_init(struct tb_xdomain *xd, struct tb_port *down) 1899 + { 1900 + if (!down->dual_link_port) 1901 + return; 1902 + 1903 + /* 1904 + * Gen 4 links come up already as bonded so only update the port 1905 + * structures here. 1906 + */ 1907 + if (tb_port_get_link_generation(down) >= 4) { 1908 + down->bonded = true; 1909 + down->dual_link_port->bonded = true; 1910 + } else { 1911 + xd->bonding_possible = true; 1912 + } 1913 + } 1914 + 1915 + static void tb_xdomain_link_exit(struct tb_xdomain *xd) 1916 + { 1917 + struct tb_port *down = tb_xdomain_downstream_port(xd); 1918 + 1919 + if (!down->dual_link_port) 1920 + return; 1921 + 1922 + if (tb_port_get_link_generation(down) >= 4) { 1923 + down->bonded = false; 1924 + down->dual_link_port->bonded = false; 1925 + } else if (xd->link_width > TB_LINK_WIDTH_SINGLE) { 1926 + /* 1927 + * Just return port structures back to way they were and 1928 + * update credits. No need to update userspace because 1929 + * the XDomain is removed soon anyway. 1930 + */ 1931 + tb_port_lane_bonding_disable(down); 1932 + tb_port_update_credits(down); 1933 + } else if (down->dual_link_port) { 1934 + /* 1935 + * Re-enable the lane 1 adapter we disabled at the end 1936 + * of tb_xdomain_get_properties(). 1937 + */ 1938 + tb_port_enable(down->dual_link_port); 1939 + } 1940 + } 1941 + 1903 1942 /** 1904 1943 * tb_xdomain_alloc() - Allocate new XDomain object 1905 1944 * @tb: Domain where the XDomain belongs ··· 1994 1945 goto err_free_local_uuid; 1995 1946 } else { 1996 1947 xd->needs_uuid = true; 1997 - xd->bonding_possible = !!down->dual_link_port; 1948 + 1949 + tb_xdomain_link_init(xd, down); 1998 1950 } 1999 1951 2000 1952 device_initialize(&xd->dev); ··· 2063 2013 stop_handshake(xd); 2064 2014 2065 2015 device_for_each_child_reverse(&xd->dev, xd, unregister_service); 2016 + 2017 + tb_xdomain_link_exit(xd); 2066 2018 2067 2019 /* 2068 2020 * Undo runtime PM here explicitly because it is possible that
+3
drivers/tty/tty_io.c
··· 2493 2493 if (!retval) { 2494 2494 msleep_interruptible(duration); 2495 2495 retval = tty->ops->break_ctl(tty, 0); 2496 + } else if (retval == -EOPNOTSUPP) { 2497 + /* some drivers can tell only dynamically */ 2498 + retval = 0; 2496 2499 } 2497 2500 tty_write_unlock(tty); 2498 2501
+9 -10
drivers/usb/atm/ueagle-atm.c
··· 546 546 547 547 #define uea_wait(sc, cond, timeo) \ 548 548 ({ \ 549 - int _r = wait_event_interruptible_timeout(sc->sync_q, \ 549 + int _r = wait_event_freezable_timeout(sc->sync_q, \ 550 550 (cond) || kthread_should_stop(), timeo); \ 551 551 if (kthread_should_stop()) \ 552 552 _r = -ENODEV; \ ··· 1896 1896 ret = sc->stat(sc); 1897 1897 if (ret != -EAGAIN) 1898 1898 uea_wait(sc, 0, msecs_to_jiffies(1000)); 1899 - try_to_freeze(); 1900 1899 } 1901 1900 uea_leaves(INS_TO_USBDEV(sc)); 1902 1901 return ret; ··· 2251 2252 sc = dev_to_uea(dev); 2252 2253 if (!sc) 2253 2254 goto out; 2254 - ret = snprintf(buf, 10, "%08x\n", sc->stats.phy.state); 2255 + ret = sysfs_emit(buf, "%08x\n", sc->stats.phy.state); 2255 2256 out: 2256 2257 mutex_unlock(&uea_mutex); 2257 2258 return ret; ··· 2317 2318 2318 2319 switch (modem_state) { 2319 2320 case 0: 2320 - ret = sprintf(buf, "Modem is booting\n"); 2321 + ret = sysfs_emit(buf, "Modem is booting\n"); 2321 2322 break; 2322 2323 case 1: 2323 - ret = sprintf(buf, "Modem is initializing\n"); 2324 + ret = sysfs_emit(buf, "Modem is initializing\n"); 2324 2325 break; 2325 2326 case 2: 2326 - ret = sprintf(buf, "Modem is operational\n"); 2327 + ret = sysfs_emit(buf, "Modem is operational\n"); 2327 2328 break; 2328 2329 case 3: 2329 - ret = sprintf(buf, "Modem synchronization failed\n"); 2330 + ret = sysfs_emit(buf, "Modem synchronization failed\n"); 2330 2331 break; 2331 2332 default: 2332 - ret = sprintf(buf, "Modem state is unknown\n"); 2333 + ret = sysfs_emit(buf, "Modem state is unknown\n"); 2333 2334 break; 2334 2335 } 2335 2336 out: ··· 2363 2364 delin = "LOSS"; 2364 2365 } 2365 2366 2366 - ret = sprintf(buf, "%s\n", delin); 2367 + ret = sysfs_emit(buf, "%s\n", delin); 2367 2368 out: 2368 2369 mutex_unlock(&uea_mutex); 2369 2370 return ret; ··· 2383 2384 sc = dev_to_uea(dev); \ 2384 2385 if (!sc) \ 2385 2386 goto out; \ 2386 - ret = snprintf(buf, 10, "%08x\n", sc->stats.phy.name); \ 2387 + ret = sysfs_emit(buf, "%08x\n", sc->stats.phy.name); \ 2387 2388 if (reset) \ 2388 2389 sc->stats.phy.name = 0; \ 2389 2390 out: \
+111 -38
drivers/usb/cdns3/cdns3-gadget.c
··· 1119 1119 dma_addr_t trb_dma; 1120 1120 u32 togle_pcs = 1; 1121 1121 int sg_iter = 0; 1122 + int num_trb_req; 1123 + int trb_burst; 1122 1124 int num_trb; 1123 1125 int address; 1124 1126 u32 control; ··· 1128 1126 u16 total_tdl = 0; 1129 1127 struct scatterlist *s = NULL; 1130 1128 bool sg_supported = !!(request->num_mapped_sgs); 1129 + u32 ioc = request->no_interrupt ? 0 : TRB_IOC; 1131 1130 1131 + num_trb_req = sg_supported ? request->num_mapped_sgs : 1; 1132 + 1133 + /* ISO transfer require each SOF have a TD, each TD include some TRBs */ 1132 1134 if (priv_ep->type == USB_ENDPOINT_XFER_ISOC) 1133 - num_trb = priv_ep->interval; 1135 + num_trb = priv_ep->interval * num_trb_req; 1134 1136 else 1135 - num_trb = sg_supported ? request->num_mapped_sgs : 1; 1136 - 1137 - if (num_trb > priv_ep->free_trbs) { 1138 - priv_ep->flags |= EP_RING_FULL; 1139 - return -ENOBUFS; 1140 - } 1137 + num_trb = num_trb_req; 1141 1138 1142 1139 priv_req = to_cdns3_request(request); 1143 1140 address = priv_ep->endpoint.desc->bEndpointAddress; ··· 1185 1184 1186 1185 link_trb->control = cpu_to_le32(((priv_ep->pcs) ? TRB_CYCLE : 0) | 1187 1186 TRB_TYPE(TRB_LINK) | TRB_TOGGLE | ch_bit); 1187 + 1188 + if (priv_ep->type == USB_ENDPOINT_XFER_ISOC) { 1189 + /* 1190 + * ISO require LINK TRB must be first one of TD. 1191 + * Fill LINK TRBs for left trb space to simply software process logic. 1192 + */ 1193 + while (priv_ep->enqueue) { 1194 + *trb = *link_trb; 1195 + trace_cdns3_prepare_trb(priv_ep, trb); 1196 + 1197 + cdns3_ep_inc_enq(priv_ep); 1198 + trb = priv_ep->trb_pool + priv_ep->enqueue; 1199 + priv_req->trb = trb; 1200 + } 1201 + } 1202 + } 1203 + 1204 + if (num_trb > priv_ep->free_trbs) { 1205 + priv_ep->flags |= EP_RING_FULL; 1206 + return -ENOBUFS; 1188 1207 } 1189 1208 1190 1209 if (priv_dev->dev_ver <= DEV_VER_V2) 1191 1210 togle_pcs = cdns3_wa1_update_guard(priv_ep, trb); 1192 - 1193 - if (sg_supported) 1194 - s = request->sg; 1195 1211 1196 1212 /* set incorrect Cycle Bit for first trb*/ 1197 1213 control = priv_ep->pcs ? 0 : TRB_CYCLE; ··· 1227 1209 do { 1228 1210 u32 length; 1229 1211 1212 + if (!(sg_iter % num_trb_req) && sg_supported) 1213 + s = request->sg; 1214 + 1230 1215 /* fill TRB */ 1231 1216 control |= TRB_TYPE(TRB_NORMAL); 1232 1217 if (sg_supported) { ··· 1244 1223 total_tdl += DIV_ROUND_UP(length, 1245 1224 priv_ep->endpoint.maxpacket); 1246 1225 1247 - trb->length |= cpu_to_le32(TRB_BURST_LEN(priv_ep->trb_burst_size) | 1226 + trb_burst = priv_ep->trb_burst_size; 1227 + 1228 + /* 1229 + * Supposed DMA cross 4k bounder problem should be fixed at DEV_VER_V2, but still 1230 + * met problem when do ISO transfer if sg enabled. 1231 + * 1232 + * Data pattern likes below when sg enabled, package size is 1k and mult is 2 1233 + * [UVC Header(8B) ] [data(3k - 8)] ... 1234 + * 1235 + * The received data at offset 0xd000 will get 0xc000 data, len 0x70. Error happen 1236 + * as below pattern: 1237 + * 0xd000: wrong 1238 + * 0xe000: wrong 1239 + * 0xf000: correct 1240 + * 0x10000: wrong 1241 + * 0x11000: wrong 1242 + * 0x12000: correct 1243 + * ... 1244 + * 1245 + * But it is still unclear about why error have not happen below 0xd000, it should 1246 + * cross 4k bounder. But anyway, the below code can fix this problem. 1247 + * 1248 + * To avoid DMA cross 4k bounder at ISO transfer, reduce burst len according to 16. 1249 + */ 1250 + if (priv_ep->type == USB_ENDPOINT_XFER_ISOC && priv_dev->dev_ver <= DEV_VER_V2) 1251 + if (ALIGN_DOWN(trb->buffer, SZ_4K) != 1252 + ALIGN_DOWN(trb->buffer + length, SZ_4K)) 1253 + trb_burst = 16; 1254 + 1255 + trb->length |= cpu_to_le32(TRB_BURST_LEN(trb_burst) | 1248 1256 TRB_LEN(length)); 1249 1257 pcs = priv_ep->pcs ? TRB_CYCLE : 0; 1250 1258 ··· 1285 1235 control |= pcs; 1286 1236 1287 1237 if (priv_ep->type == USB_ENDPOINT_XFER_ISOC && !priv_ep->dir) { 1288 - control |= TRB_IOC | TRB_ISP; 1238 + control |= ioc | TRB_ISP; 1289 1239 } else { 1290 1240 /* for last element in TD or in SG list */ 1291 1241 if (sg_iter == (num_trb - 1) && sg_iter != 0) 1292 - control |= pcs | TRB_IOC | TRB_ISP; 1242 + control |= pcs | ioc | TRB_ISP; 1293 1243 } 1294 1244 1295 1245 if (sg_iter) ··· 1300 1250 if (sg_supported) { 1301 1251 trb->control |= cpu_to_le32(TRB_ISP); 1302 1252 /* Don't set chain bit for last TRB */ 1303 - if (sg_iter < num_trb - 1) 1253 + if ((sg_iter % num_trb_req) < num_trb_req - 1) 1304 1254 trb->control |= cpu_to_le32(TRB_CHAIN); 1305 1255 1306 1256 s = sg_next(s); ··· 1320 1270 priv_req->num_of_trb = num_trb; 1321 1271 1322 1272 if (sg_iter == 1) 1323 - trb->control |= cpu_to_le32(TRB_IOC | TRB_ISP); 1273 + trb->control |= cpu_to_le32(ioc | TRB_ISP); 1324 1274 1325 1275 if (priv_dev->dev_ver < DEV_VER_V2 && 1326 1276 (priv_ep->flags & EP_TDLCHK_EN)) { ··· 1558 1508 1559 1509 /* The TRB was changed as link TRB, and the request was handled at ep_dequeue */ 1560 1510 while (TRB_FIELD_TO_TYPE(le32_to_cpu(trb->control)) == TRB_LINK) { 1511 + 1512 + /* ISO ep_traddr may stop at LINK TRB */ 1513 + if (priv_ep->dequeue == cdns3_get_dma_pos(priv_dev, priv_ep) && 1514 + priv_ep->type == USB_ENDPOINT_XFER_ISOC) 1515 + break; 1516 + 1561 1517 trace_cdns3_complete_trb(priv_ep, trb); 1562 1518 cdns3_ep_inc_deq(priv_ep); 1563 1519 trb = priv_ep->trb_pool + priv_ep->dequeue; ··· 1596 1540 } 1597 1541 1598 1542 if (request_handled) { 1543 + /* TRBs are duplicated by priv_ep->interval time for ISO IN */ 1544 + if (priv_ep->type == USB_ENDPOINT_XFER_ISOC && priv_ep->dir) 1545 + request->actual /= priv_ep->interval; 1546 + 1599 1547 cdns3_gadget_giveback(priv_ep, priv_req, 0); 1600 1548 request_handled = false; 1601 1549 transfer_end = false; ··· 2095 2035 bool is_iso_ep = (priv_ep->type == USB_ENDPOINT_XFER_ISOC); 2096 2036 struct cdns3_device *priv_dev = priv_ep->cdns3_dev; 2097 2037 u32 bEndpointAddress = priv_ep->num | priv_ep->dir; 2098 - u32 max_packet_size = 0; 2099 - u8 maxburst = 0; 2038 + u32 max_packet_size = priv_ep->wMaxPacketSize; 2039 + u8 maxburst = priv_ep->bMaxBurst; 2100 2040 u32 ep_cfg = 0; 2101 2041 u8 buffering; 2102 - u8 mult = 0; 2103 2042 int ret; 2104 2043 2105 2044 buffering = priv_dev->ep_buf_size - 1; ··· 2120 2061 break; 2121 2062 default: 2122 2063 ep_cfg = EP_CFG_EPTYPE(USB_ENDPOINT_XFER_ISOC); 2123 - mult = priv_dev->ep_iso_burst - 1; 2124 - buffering = mult + 1; 2064 + buffering = (priv_ep->bMaxBurst + 1) * (priv_ep->mult + 1) - 1; 2125 2065 } 2126 2066 2127 2067 switch (priv_dev->gadget.speed) { ··· 2131 2073 max_packet_size = is_iso_ep ? 1024 : 512; 2132 2074 break; 2133 2075 case USB_SPEED_SUPER: 2134 - /* It's limitation that driver assumes in driver. */ 2135 - mult = 0; 2136 - max_packet_size = 1024; 2137 - if (priv_ep->type == USB_ENDPOINT_XFER_ISOC) { 2138 - maxburst = priv_dev->ep_iso_burst - 1; 2139 - buffering = (mult + 1) * 2140 - (maxburst + 1); 2141 - 2142 - if (priv_ep->interval > 1) 2143 - buffering++; 2144 - } else { 2076 + if (priv_ep->type != USB_ENDPOINT_XFER_ISOC) { 2077 + max_packet_size = 1024; 2145 2078 maxburst = priv_dev->ep_buf_size - 1; 2146 2079 } 2147 2080 break; ··· 2161 2112 if (priv_dev->dev_ver < DEV_VER_V2) 2162 2113 priv_ep->trb_burst_size = 16; 2163 2114 2164 - mult = min_t(u8, mult, EP_CFG_MULT_MAX); 2165 2115 buffering = min_t(u8, buffering, EP_CFG_BUFFERING_MAX); 2166 2116 maxburst = min_t(u8, maxburst, EP_CFG_MAXBURST_MAX); 2167 2117 ··· 2194 2146 } 2195 2147 2196 2148 ep_cfg |= EP_CFG_MAXPKTSIZE(max_packet_size) | 2197 - EP_CFG_MULT(mult) | 2149 + EP_CFG_MULT(priv_ep->mult) | /* must match EP setting */ 2198 2150 EP_CFG_BUFFERING(buffering) | 2199 2151 EP_CFG_MAXBURST(maxburst); 2200 2152 ··· 2284 2236 priv_ep->type = usb_endpoint_type(desc); 2285 2237 priv_ep->flags |= EP_CLAIMED; 2286 2238 priv_ep->interval = desc->bInterval ? BIT(desc->bInterval - 1) : 0; 2239 + priv_ep->wMaxPacketSize = usb_endpoint_maxp(desc); 2240 + priv_ep->mult = USB_EP_MAXP_MULT(priv_ep->wMaxPacketSize); 2241 + priv_ep->wMaxPacketSize &= USB_ENDPOINT_MAXP_MASK; 2242 + if (priv_ep->type == USB_ENDPOINT_XFER_ISOC && comp_desc) { 2243 + priv_ep->mult = USB_SS_MULT(comp_desc->bmAttributes) - 1; 2244 + priv_ep->bMaxBurst = comp_desc->bMaxBurst; 2245 + } 2287 2246 2288 2247 spin_unlock_irqrestore(&priv_dev->lock, flags); 2289 2248 return &priv_ep->endpoint; ··· 3074 3019 struct cdns3_endpoint *priv_ep; 3075 3020 struct usb_ep *ep; 3076 3021 int n_in = 0; 3022 + int iso = 0; 3023 + int out = 1; 3077 3024 int total; 3025 + int n; 3078 3026 3079 3027 list_for_each_entry(ep, &gadget->ep_list, ep_list) { 3080 3028 priv_ep = ep_to_cdns3_ep(ep); 3081 - if ((priv_ep->flags & EP_CLAIMED) && (ep->address & USB_DIR_IN)) 3082 - n_in++; 3029 + if (!(priv_ep->flags & EP_CLAIMED)) 3030 + continue; 3031 + 3032 + n = (priv_ep->mult + 1) * (priv_ep->bMaxBurst + 1); 3033 + if (ep->address & USB_DIR_IN) { 3034 + /* 3035 + * ISO transfer: DMA start move data when get ISO, only transfer 3036 + * data as min(TD size, iso). No benefit for allocate bigger 3037 + * internal memory than 'iso'. 3038 + */ 3039 + if (priv_ep->type == USB_ENDPOINT_XFER_ISOC) 3040 + iso += n; 3041 + else 3042 + n_in++; 3043 + } else { 3044 + if (priv_ep->type == USB_ENDPOINT_XFER_ISOC) 3045 + out = max_t(int, out, n); 3046 + } 3083 3047 } 3084 3048 3085 3049 /* 2KB are reserved for EP0, 1KB for out*/ 3086 - total = 2 + n_in + 1; 3050 + total = 2 + n_in + out + iso; 3087 3051 3088 3052 if (total > priv_dev->onchip_buffers) 3089 3053 return -ENOMEM; 3090 3054 3091 - priv_dev->ep_buf_size = priv_dev->ep_iso_burst = 3092 - (priv_dev->onchip_buffers - 2) / (n_in + 1); 3055 + priv_dev->ep_buf_size = (priv_dev->onchip_buffers - 2 - iso) / (n_in + out); 3093 3056 3094 3057 return 0; 3095 3058 }
+3
drivers/usb/cdns3/cdns3-gadget.h
··· 1168 1168 u8 dir; 1169 1169 u8 num; 1170 1170 u8 type; 1171 + u8 mult; 1172 + u8 bMaxBurst; 1173 + u16 wMaxPacketSize; 1171 1174 int interval; 1172 1175 1173 1176 int free_trbs;
+11 -5
drivers/usb/cdns3/cdns3-plat.c
··· 87 87 cdns->dev_irq = platform_get_irq_byname(pdev, "peripheral"); 88 88 89 89 if (cdns->dev_irq < 0) 90 - return cdns->dev_irq; 90 + return dev_err_probe(dev, cdns->dev_irq, 91 + "Failed to get peripheral IRQ\n"); 91 92 92 93 regs = devm_platform_ioremap_resource_byname(pdev, "dev"); 93 94 if (IS_ERR(regs)) 94 - return PTR_ERR(regs); 95 + return dev_err_probe(dev, PTR_ERR(regs), 96 + "Failed to get dev base\n"); 97 + 95 98 cdns->dev_regs = regs; 96 99 97 100 cdns->otg_irq = platform_get_irq_byname(pdev, "otg"); 98 101 if (cdns->otg_irq < 0) 99 - return cdns->otg_irq; 102 + return dev_err_probe(dev, cdns->otg_irq, 103 + "Failed to get otg IRQ\n"); 100 104 101 105 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "otg"); 102 106 if (!res) { ··· 123 119 124 120 cdns->usb2_phy = devm_phy_optional_get(dev, "cdns3,usb2-phy"); 125 121 if (IS_ERR(cdns->usb2_phy)) 126 - return PTR_ERR(cdns->usb2_phy); 122 + return dev_err_probe(dev, PTR_ERR(cdns->usb2_phy), 123 + "Failed to get cdn3,usb2-phy\n"); 127 124 128 125 ret = phy_init(cdns->usb2_phy); 129 126 if (ret) ··· 132 127 133 128 cdns->usb3_phy = devm_phy_optional_get(dev, "cdns3,usb3-phy"); 134 129 if (IS_ERR(cdns->usb3_phy)) 135 - return PTR_ERR(cdns->usb3_phy); 130 + return dev_err_probe(dev, PTR_ERR(cdns->usb3_phy), 131 + "Failed to get cdn3,usb3-phy\n"); 136 132 137 133 ret = phy_init(cdns->usb3_phy); 138 134 if (ret)
+1 -1
drivers/usb/cdns3/cdns3-starfive.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 2 - /** 2 + /* 3 3 * cdns3-starfive.c - StarFive specific Glue layer for Cadence USB Controller 4 4 * 5 5 * Copyright (C) 2023 StarFive Technology Co., Ltd.
+177 -177
drivers/usb/cdns3/cdnsp-debug.h
··· 187 187 188 188 switch (type) { 189 189 case TRB_LINK: 190 - ret = snprintf(str, size, 191 - "LINK %08x%08x intr %ld type '%s' flags %c:%c:%c:%c", 192 - field1, field0, GET_INTR_TARGET(field2), 193 - cdnsp_trb_type_string(type), 194 - field3 & TRB_IOC ? 'I' : 'i', 195 - field3 & TRB_CHAIN ? 'C' : 'c', 196 - field3 & TRB_TC ? 'T' : 't', 197 - field3 & TRB_CYCLE ? 'C' : 'c'); 190 + ret = scnprintf(str, size, 191 + "LINK %08x%08x intr %ld type '%s' flags %c:%c:%c:%c", 192 + field1, field0, GET_INTR_TARGET(field2), 193 + cdnsp_trb_type_string(type), 194 + field3 & TRB_IOC ? 'I' : 'i', 195 + field3 & TRB_CHAIN ? 'C' : 'c', 196 + field3 & TRB_TC ? 'T' : 't', 197 + field3 & TRB_CYCLE ? 'C' : 'c'); 198 198 break; 199 199 case TRB_TRANSFER: 200 200 case TRB_COMPLETION: 201 201 case TRB_PORT_STATUS: 202 202 case TRB_HC_EVENT: 203 - ret = snprintf(str, size, 204 - "ep%d%s(%d) type '%s' TRB %08x%08x status '%s'" 205 - " len %ld slot %ld flags %c:%c", 206 - ep_num, ep_id % 2 ? "out" : "in", 207 - TRB_TO_EP_INDEX(field3), 208 - cdnsp_trb_type_string(type), field1, field0, 209 - cdnsp_trb_comp_code_string(GET_COMP_CODE(field2)), 210 - EVENT_TRB_LEN(field2), TRB_TO_SLOT_ID(field3), 211 - field3 & EVENT_DATA ? 'E' : 'e', 212 - field3 & TRB_CYCLE ? 'C' : 'c'); 203 + ret = scnprintf(str, size, 204 + "ep%d%s(%d) type '%s' TRB %08x%08x status '%s'" 205 + " len %ld slot %ld flags %c:%c", 206 + ep_num, ep_id % 2 ? "out" : "in", 207 + TRB_TO_EP_INDEX(field3), 208 + cdnsp_trb_type_string(type), field1, field0, 209 + cdnsp_trb_comp_code_string(GET_COMP_CODE(field2)), 210 + EVENT_TRB_LEN(field2), TRB_TO_SLOT_ID(field3), 211 + field3 & EVENT_DATA ? 'E' : 'e', 212 + field3 & TRB_CYCLE ? 'C' : 'c'); 213 213 break; 214 214 case TRB_MFINDEX_WRAP: 215 - ret = snprintf(str, size, "%s: flags %c", 216 - cdnsp_trb_type_string(type), 217 - field3 & TRB_CYCLE ? 'C' : 'c'); 215 + ret = scnprintf(str, size, "%s: flags %c", 216 + cdnsp_trb_type_string(type), 217 + field3 & TRB_CYCLE ? 'C' : 'c'); 218 218 break; 219 219 case TRB_SETUP: 220 - ret = snprintf(str, size, 221 - "type '%s' bRequestType %02x bRequest %02x " 222 - "wValue %02x%02x wIndex %02x%02x wLength %d " 223 - "length %ld TD size %ld intr %ld Setup ID %ld " 224 - "flags %c:%c:%c", 225 - cdnsp_trb_type_string(type), 226 - field0 & 0xff, 227 - (field0 & 0xff00) >> 8, 228 - (field0 & 0xff000000) >> 24, 229 - (field0 & 0xff0000) >> 16, 230 - (field1 & 0xff00) >> 8, 231 - field1 & 0xff, 232 - (field1 & 0xff000000) >> 16 | 233 - (field1 & 0xff0000) >> 16, 234 - TRB_LEN(field2), GET_TD_SIZE(field2), 235 - GET_INTR_TARGET(field2), 236 - TRB_SETUPID_TO_TYPE(field3), 237 - field3 & TRB_IDT ? 'D' : 'd', 238 - field3 & TRB_IOC ? 'I' : 'i', 239 - field3 & TRB_CYCLE ? 'C' : 'c'); 220 + ret = scnprintf(str, size, 221 + "type '%s' bRequestType %02x bRequest %02x " 222 + "wValue %02x%02x wIndex %02x%02x wLength %d " 223 + "length %ld TD size %ld intr %ld Setup ID %ld " 224 + "flags %c:%c:%c", 225 + cdnsp_trb_type_string(type), 226 + field0 & 0xff, 227 + (field0 & 0xff00) >> 8, 228 + (field0 & 0xff000000) >> 24, 229 + (field0 & 0xff0000) >> 16, 230 + (field1 & 0xff00) >> 8, 231 + field1 & 0xff, 232 + (field1 & 0xff000000) >> 16 | 233 + (field1 & 0xff0000) >> 16, 234 + TRB_LEN(field2), GET_TD_SIZE(field2), 235 + GET_INTR_TARGET(field2), 236 + TRB_SETUPID_TO_TYPE(field3), 237 + field3 & TRB_IDT ? 'D' : 'd', 238 + field3 & TRB_IOC ? 'I' : 'i', 239 + field3 & TRB_CYCLE ? 'C' : 'c'); 240 240 break; 241 241 case TRB_DATA: 242 - ret = snprintf(str, size, 243 - "type '%s' Buffer %08x%08x length %ld TD size %ld " 244 - "intr %ld flags %c:%c:%c:%c:%c:%c:%c", 245 - cdnsp_trb_type_string(type), 246 - field1, field0, TRB_LEN(field2), 247 - GET_TD_SIZE(field2), 248 - GET_INTR_TARGET(field2), 249 - field3 & TRB_IDT ? 'D' : 'i', 250 - field3 & TRB_IOC ? 'I' : 'i', 251 - field3 & TRB_CHAIN ? 'C' : 'c', 252 - field3 & TRB_NO_SNOOP ? 'S' : 's', 253 - field3 & TRB_ISP ? 'I' : 'i', 254 - field3 & TRB_ENT ? 'E' : 'e', 255 - field3 & TRB_CYCLE ? 'C' : 'c'); 242 + ret = scnprintf(str, size, 243 + "type '%s' Buffer %08x%08x length %ld TD size %ld " 244 + "intr %ld flags %c:%c:%c:%c:%c:%c:%c", 245 + cdnsp_trb_type_string(type), 246 + field1, field0, TRB_LEN(field2), 247 + GET_TD_SIZE(field2), 248 + GET_INTR_TARGET(field2), 249 + field3 & TRB_IDT ? 'D' : 'i', 250 + field3 & TRB_IOC ? 'I' : 'i', 251 + field3 & TRB_CHAIN ? 'C' : 'c', 252 + field3 & TRB_NO_SNOOP ? 'S' : 's', 253 + field3 & TRB_ISP ? 'I' : 'i', 254 + field3 & TRB_ENT ? 'E' : 'e', 255 + field3 & TRB_CYCLE ? 'C' : 'c'); 256 256 break; 257 257 case TRB_STATUS: 258 - ret = snprintf(str, size, 259 - "Buffer %08x%08x length %ld TD size %ld intr" 260 - "%ld type '%s' flags %c:%c:%c:%c", 261 - field1, field0, TRB_LEN(field2), 262 - GET_TD_SIZE(field2), 263 - GET_INTR_TARGET(field2), 264 - cdnsp_trb_type_string(type), 265 - field3 & TRB_IOC ? 'I' : 'i', 266 - field3 & TRB_CHAIN ? 'C' : 'c', 267 - field3 & TRB_ENT ? 'E' : 'e', 268 - field3 & TRB_CYCLE ? 'C' : 'c'); 258 + ret = scnprintf(str, size, 259 + "Buffer %08x%08x length %ld TD size %ld intr" 260 + "%ld type '%s' flags %c:%c:%c:%c", 261 + field1, field0, TRB_LEN(field2), 262 + GET_TD_SIZE(field2), 263 + GET_INTR_TARGET(field2), 264 + cdnsp_trb_type_string(type), 265 + field3 & TRB_IOC ? 'I' : 'i', 266 + field3 & TRB_CHAIN ? 'C' : 'c', 267 + field3 & TRB_ENT ? 'E' : 'e', 268 + field3 & TRB_CYCLE ? 'C' : 'c'); 269 269 break; 270 270 case TRB_NORMAL: 271 271 case TRB_ISOC: 272 272 case TRB_EVENT_DATA: 273 273 case TRB_TR_NOOP: 274 - ret = snprintf(str, size, 275 - "type '%s' Buffer %08x%08x length %ld " 276 - "TD size %ld intr %ld " 277 - "flags %c:%c:%c:%c:%c:%c:%c:%c:%c", 278 - cdnsp_trb_type_string(type), 279 - field1, field0, TRB_LEN(field2), 280 - GET_TD_SIZE(field2), 281 - GET_INTR_TARGET(field2), 282 - field3 & TRB_BEI ? 'B' : 'b', 283 - field3 & TRB_IDT ? 'T' : 't', 284 - field3 & TRB_IOC ? 'I' : 'i', 285 - field3 & TRB_CHAIN ? 'C' : 'c', 286 - field3 & TRB_NO_SNOOP ? 'S' : 's', 287 - field3 & TRB_ISP ? 'I' : 'i', 288 - field3 & TRB_ENT ? 'E' : 'e', 289 - field3 & TRB_CYCLE ? 'C' : 'c', 290 - !(field3 & TRB_EVENT_INVALIDATE) ? 'V' : 'v'); 274 + ret = scnprintf(str, size, 275 + "type '%s' Buffer %08x%08x length %ld " 276 + "TD size %ld intr %ld " 277 + "flags %c:%c:%c:%c:%c:%c:%c:%c:%c", 278 + cdnsp_trb_type_string(type), 279 + field1, field0, TRB_LEN(field2), 280 + GET_TD_SIZE(field2), 281 + GET_INTR_TARGET(field2), 282 + field3 & TRB_BEI ? 'B' : 'b', 283 + field3 & TRB_IDT ? 'T' : 't', 284 + field3 & TRB_IOC ? 'I' : 'i', 285 + field3 & TRB_CHAIN ? 'C' : 'c', 286 + field3 & TRB_NO_SNOOP ? 'S' : 's', 287 + field3 & TRB_ISP ? 'I' : 'i', 288 + field3 & TRB_ENT ? 'E' : 'e', 289 + field3 & TRB_CYCLE ? 'C' : 'c', 290 + !(field3 & TRB_EVENT_INVALIDATE) ? 'V' : 'v'); 291 291 break; 292 292 case TRB_CMD_NOOP: 293 293 case TRB_ENABLE_SLOT: 294 - ret = snprintf(str, size, "%s: flags %c", 295 - cdnsp_trb_type_string(type), 296 - field3 & TRB_CYCLE ? 'C' : 'c'); 294 + ret = scnprintf(str, size, "%s: flags %c", 295 + cdnsp_trb_type_string(type), 296 + field3 & TRB_CYCLE ? 'C' : 'c'); 297 297 break; 298 298 case TRB_DISABLE_SLOT: 299 - ret = snprintf(str, size, "%s: slot %ld flags %c", 300 - cdnsp_trb_type_string(type), 301 - TRB_TO_SLOT_ID(field3), 302 - field3 & TRB_CYCLE ? 'C' : 'c'); 299 + ret = scnprintf(str, size, "%s: slot %ld flags %c", 300 + cdnsp_trb_type_string(type), 301 + TRB_TO_SLOT_ID(field3), 302 + field3 & TRB_CYCLE ? 'C' : 'c'); 303 303 break; 304 304 case TRB_ADDR_DEV: 305 - ret = snprintf(str, size, 306 - "%s: ctx %08x%08x slot %ld flags %c:%c", 307 - cdnsp_trb_type_string(type), field1, field0, 308 - TRB_TO_SLOT_ID(field3), 309 - field3 & TRB_BSR ? 'B' : 'b', 310 - field3 & TRB_CYCLE ? 'C' : 'c'); 305 + ret = scnprintf(str, size, 306 + "%s: ctx %08x%08x slot %ld flags %c:%c", 307 + cdnsp_trb_type_string(type), field1, field0, 308 + TRB_TO_SLOT_ID(field3), 309 + field3 & TRB_BSR ? 'B' : 'b', 310 + field3 & TRB_CYCLE ? 'C' : 'c'); 311 311 break; 312 312 case TRB_CONFIG_EP: 313 - ret = snprintf(str, size, 314 - "%s: ctx %08x%08x slot %ld flags %c:%c", 315 - cdnsp_trb_type_string(type), field1, field0, 316 - TRB_TO_SLOT_ID(field3), 317 - field3 & TRB_DC ? 'D' : 'd', 318 - field3 & TRB_CYCLE ? 'C' : 'c'); 313 + ret = scnprintf(str, size, 314 + "%s: ctx %08x%08x slot %ld flags %c:%c", 315 + cdnsp_trb_type_string(type), field1, field0, 316 + TRB_TO_SLOT_ID(field3), 317 + field3 & TRB_DC ? 'D' : 'd', 318 + field3 & TRB_CYCLE ? 'C' : 'c'); 319 319 break; 320 320 case TRB_EVAL_CONTEXT: 321 - ret = snprintf(str, size, 322 - "%s: ctx %08x%08x slot %ld flags %c", 323 - cdnsp_trb_type_string(type), field1, field0, 324 - TRB_TO_SLOT_ID(field3), 325 - field3 & TRB_CYCLE ? 'C' : 'c'); 321 + ret = scnprintf(str, size, 322 + "%s: ctx %08x%08x slot %ld flags %c", 323 + cdnsp_trb_type_string(type), field1, field0, 324 + TRB_TO_SLOT_ID(field3), 325 + field3 & TRB_CYCLE ? 'C' : 'c'); 326 326 break; 327 327 case TRB_RESET_EP: 328 328 case TRB_HALT_ENDPOINT: 329 - ret = snprintf(str, size, 330 - "%s: ep%d%s(%d) ctx %08x%08x slot %ld flags %c", 331 - cdnsp_trb_type_string(type), 332 - ep_num, ep_id % 2 ? "out" : "in", 333 - TRB_TO_EP_INDEX(field3), field1, field0, 334 - TRB_TO_SLOT_ID(field3), 335 - field3 & TRB_CYCLE ? 'C' : 'c'); 329 + ret = scnprintf(str, size, 330 + "%s: ep%d%s(%d) ctx %08x%08x slot %ld flags %c", 331 + cdnsp_trb_type_string(type), 332 + ep_num, ep_id % 2 ? "out" : "in", 333 + TRB_TO_EP_INDEX(field3), field1, field0, 334 + TRB_TO_SLOT_ID(field3), 335 + field3 & TRB_CYCLE ? 'C' : 'c'); 336 336 break; 337 337 case TRB_STOP_RING: 338 - ret = snprintf(str, size, 339 - "%s: ep%d%s(%d) slot %ld sp %d flags %c", 340 - cdnsp_trb_type_string(type), 341 - ep_num, ep_id % 2 ? "out" : "in", 342 - TRB_TO_EP_INDEX(field3), 343 - TRB_TO_SLOT_ID(field3), 344 - TRB_TO_SUSPEND_PORT(field3), 345 - field3 & TRB_CYCLE ? 'C' : 'c'); 338 + ret = scnprintf(str, size, 339 + "%s: ep%d%s(%d) slot %ld sp %d flags %c", 340 + cdnsp_trb_type_string(type), 341 + ep_num, ep_id % 2 ? "out" : "in", 342 + TRB_TO_EP_INDEX(field3), 343 + TRB_TO_SLOT_ID(field3), 344 + TRB_TO_SUSPEND_PORT(field3), 345 + field3 & TRB_CYCLE ? 'C' : 'c'); 346 346 break; 347 347 case TRB_SET_DEQ: 348 - ret = snprintf(str, size, 349 - "%s: ep%d%s(%d) deq %08x%08x stream %ld slot %ld flags %c", 350 - cdnsp_trb_type_string(type), 351 - ep_num, ep_id % 2 ? "out" : "in", 352 - TRB_TO_EP_INDEX(field3), field1, field0, 353 - TRB_TO_STREAM_ID(field2), 354 - TRB_TO_SLOT_ID(field3), 355 - field3 & TRB_CYCLE ? 'C' : 'c'); 348 + ret = scnprintf(str, size, 349 + "%s: ep%d%s(%d) deq %08x%08x stream %ld slot %ld flags %c", 350 + cdnsp_trb_type_string(type), 351 + ep_num, ep_id % 2 ? "out" : "in", 352 + TRB_TO_EP_INDEX(field3), field1, field0, 353 + TRB_TO_STREAM_ID(field2), 354 + TRB_TO_SLOT_ID(field3), 355 + field3 & TRB_CYCLE ? 'C' : 'c'); 356 356 break; 357 357 case TRB_RESET_DEV: 358 - ret = snprintf(str, size, "%s: slot %ld flags %c", 359 - cdnsp_trb_type_string(type), 360 - TRB_TO_SLOT_ID(field3), 361 - field3 & TRB_CYCLE ? 'C' : 'c'); 358 + ret = scnprintf(str, size, "%s: slot %ld flags %c", 359 + cdnsp_trb_type_string(type), 360 + TRB_TO_SLOT_ID(field3), 361 + field3 & TRB_CYCLE ? 'C' : 'c'); 362 362 break; 363 363 case TRB_ENDPOINT_NRDY: 364 364 temp = TRB_TO_HOST_STREAM(field2); 365 365 366 - ret = snprintf(str, size, 367 - "%s: ep%d%s(%d) H_SID %x%s%s D_SID %lx flags %c:%c", 368 - cdnsp_trb_type_string(type), 369 - ep_num, ep_id % 2 ? "out" : "in", 370 - TRB_TO_EP_INDEX(field3), temp, 371 - temp == STREAM_PRIME_ACK ? "(PRIME)" : "", 372 - temp == STREAM_REJECTED ? "(REJECTED)" : "", 373 - TRB_TO_DEV_STREAM(field0), 374 - field3 & TRB_STAT ? 'S' : 's', 375 - field3 & TRB_CYCLE ? 'C' : 'c'); 366 + ret = scnprintf(str, size, 367 + "%s: ep%d%s(%d) H_SID %x%s%s D_SID %lx flags %c:%c", 368 + cdnsp_trb_type_string(type), 369 + ep_num, ep_id % 2 ? "out" : "in", 370 + TRB_TO_EP_INDEX(field3), temp, 371 + temp == STREAM_PRIME_ACK ? "(PRIME)" : "", 372 + temp == STREAM_REJECTED ? "(REJECTED)" : "", 373 + TRB_TO_DEV_STREAM(field0), 374 + field3 & TRB_STAT ? 'S' : 's', 375 + field3 & TRB_CYCLE ? 'C' : 'c'); 376 376 break; 377 377 default: 378 - ret = snprintf(str, size, 379 - "type '%s' -> raw %08x %08x %08x %08x", 380 - cdnsp_trb_type_string(type), 381 - field0, field1, field2, field3); 378 + ret = scnprintf(str, size, 379 + "type '%s' -> raw %08x %08x %08x %08x", 380 + cdnsp_trb_type_string(type), 381 + field0, field1, field2, field3); 382 382 } 383 383 384 - if (ret >= size) 385 - pr_info("CDNSP: buffer overflowed.\n"); 384 + if (ret == size - 1) 385 + pr_info("CDNSP: buffer may be truncated.\n"); 386 386 387 387 return str; 388 388 } ··· 465 465 { 466 466 int ret; 467 467 468 - ret = snprintf(str, size, "%s %s %s Link:%s PortSpeed:%d ", 469 - portsc & PORT_POWER ? "Powered" : "Powered-off", 470 - portsc & PORT_CONNECT ? "Connected" : "Not-connected", 471 - portsc & PORT_PED ? "Enabled" : "Disabled", 472 - cdnsp_portsc_link_state_string(portsc), 473 - DEV_PORT_SPEED(portsc)); 468 + ret = scnprintf(str, size, "%s %s %s Link:%s PortSpeed:%d ", 469 + portsc & PORT_POWER ? "Powered" : "Powered-off", 470 + portsc & PORT_CONNECT ? "Connected" : "Not-connected", 471 + portsc & PORT_PED ? "Enabled" : "Disabled", 472 + cdnsp_portsc_link_state_string(portsc), 473 + DEV_PORT_SPEED(portsc)); 474 474 475 475 if (portsc & PORT_RESET) 476 - ret += snprintf(str + ret, size - ret, "In-Reset "); 476 + ret += scnprintf(str + ret, size - ret, "In-Reset "); 477 477 478 - ret += snprintf(str + ret, size - ret, "Change: "); 478 + ret += scnprintf(str + ret, size - ret, "Change: "); 479 479 if (portsc & PORT_CSC) 480 - ret += snprintf(str + ret, size - ret, "CSC "); 480 + ret += scnprintf(str + ret, size - ret, "CSC "); 481 481 if (portsc & PORT_WRC) 482 - ret += snprintf(str + ret, size - ret, "WRC "); 482 + ret += scnprintf(str + ret, size - ret, "WRC "); 483 483 if (portsc & PORT_RC) 484 - ret += snprintf(str + ret, size - ret, "PRC "); 484 + ret += scnprintf(str + ret, size - ret, "PRC "); 485 485 if (portsc & PORT_PLC) 486 - ret += snprintf(str + ret, size - ret, "PLC "); 486 + ret += scnprintf(str + ret, size - ret, "PLC "); 487 487 if (portsc & PORT_CEC) 488 - ret += snprintf(str + ret, size - ret, "CEC "); 489 - ret += snprintf(str + ret, size - ret, "Wake: "); 488 + ret += scnprintf(str + ret, size - ret, "CEC "); 489 + ret += scnprintf(str + ret, size - ret, "Wake: "); 490 490 if (portsc & PORT_WKCONN_E) 491 - ret += snprintf(str + ret, size - ret, "WCE "); 491 + ret += scnprintf(str + ret, size - ret, "WCE "); 492 492 if (portsc & PORT_WKDISC_E) 493 - ret += snprintf(str + ret, size - ret, "WDE "); 493 + ret += scnprintf(str + ret, size - ret, "WDE "); 494 494 495 495 return str; 496 496 } ··· 562 562 563 563 avg = EP_AVG_TRB_LENGTH(tx_info); 564 564 565 - ret = snprintf(str, size, "State %s mult %d max P. Streams %d %s", 566 - cdnsp_ep_state_string(ep_state), mult, 567 - max_pstr, lsa ? "LSA " : ""); 565 + ret = scnprintf(str, size, "State %s mult %d max P. Streams %d %s", 566 + cdnsp_ep_state_string(ep_state), mult, 567 + max_pstr, lsa ? "LSA " : ""); 568 568 569 - ret += snprintf(str + ret, size - ret, 570 - "interval %d us max ESIT payload %d CErr %d ", 571 - (1 << interval) * 125, esit, cerr); 569 + ret += scnprintf(str + ret, size - ret, 570 + "interval %d us max ESIT payload %d CErr %d ", 571 + (1 << interval) * 125, esit, cerr); 572 572 573 - ret += snprintf(str + ret, size - ret, 574 - "Type %s %sburst %d maxp %d deq %016llx ", 575 - cdnsp_ep_type_string(ep_type), hid ? "HID" : "", 576 - burst, maxp, deq); 573 + ret += scnprintf(str + ret, size - ret, 574 + "Type %s %sburst %d maxp %d deq %016llx ", 575 + cdnsp_ep_type_string(ep_type), hid ? "HID" : "", 576 + burst, maxp, deq); 577 577 578 - ret += snprintf(str + ret, size - ret, "avg trb len %d", avg); 578 + ret += scnprintf(str + ret, size - ret, "avg trb len %d", avg); 579 579 580 580 return str; 581 581 }
+16 -1
drivers/usb/chipidea/ci_hdrc_imx.c
··· 96 96 struct usb_phy *phy; 97 97 struct platform_device *ci_pdev; 98 98 struct clk *clk; 99 + struct clk *clk_wakeup; 99 100 struct imx_usbmisc_data *usbmisc_data; 100 101 bool supports_runtime_pm; 101 102 bool override_phy_control; ··· 200 199 201 200 data->clk_ipg = devm_clk_get(dev, "ipg"); 202 201 if (IS_ERR(data->clk_ipg)) { 203 - /* If the platform only needs one clocks */ 202 + /* If the platform only needs one primary clock */ 204 203 data->clk = devm_clk_get(dev, NULL); 205 204 if (IS_ERR(data->clk)) { 206 205 ret = PTR_ERR(data->clk); ··· 209 208 PTR_ERR(data->clk), PTR_ERR(data->clk_ipg)); 210 209 return ret; 211 210 } 211 + /* Get wakeup clock. Not all of the platforms need to 212 + * handle this clock. So make it optional. 213 + */ 214 + data->clk_wakeup = devm_clk_get_optional(dev, "usb_wakeup_clk"); 215 + if (IS_ERR(data->clk_wakeup)) 216 + ret = dev_err_probe(dev, PTR_ERR(data->clk_wakeup), 217 + "Failed to get wakeup clk\n"); 212 218 return ret; 213 219 } 214 220 ··· 431 423 if (ret) 432 424 goto disable_hsic_regulator; 433 425 426 + ret = clk_prepare_enable(data->clk_wakeup); 427 + if (ret) 428 + goto err_wakeup_clk; 429 + 434 430 data->phy = devm_usb_get_phy_by_phandle(dev, "fsl,usbphy", 0); 435 431 if (IS_ERR(data->phy)) { 436 432 ret = PTR_ERR(data->phy); ··· 516 504 disable_device: 517 505 ci_hdrc_remove_device(data->ci_pdev); 518 506 err_clk: 507 + clk_disable_unprepare(data->clk_wakeup); 508 + err_wakeup_clk: 519 509 imx_disable_unprepare_clks(dev); 520 510 disable_hsic_regulator: 521 511 if (data->hsic_pad_regulator) ··· 544 530 usb_phy_shutdown(data->phy); 545 531 if (data->ci_pdev) { 546 532 imx_disable_unprepare_clks(&pdev->dev); 533 + clk_disable_unprepare(data->clk_wakeup); 547 534 if (data->plat_data->flags & CI_HDRC_PMQOS) 548 535 cpu_latency_qos_remove_request(&data->pm_qos_req); 549 536 if (data->hsic_pad_regulator)
+10 -3
drivers/usb/chipidea/core.c
··· 523 523 u32 otgsc = 0; 524 524 525 525 if (ci->in_lpm) { 526 + /* 527 + * If we already have a wakeup irq pending there, 528 + * let's just return to wait resume finished firstly. 529 + */ 530 + if (ci->wakeup_int) 531 + return IRQ_HANDLED; 532 + 526 533 disable_irq_nosync(irq); 527 534 ci->wakeup_int = true; 528 535 pm_runtime_get(ci->dev); ··· 869 862 if (ret) 870 863 return ERR_PTR(ret); 871 864 872 - id = ida_simple_get(&ci_ida, 0, 0, GFP_KERNEL); 865 + id = ida_alloc(&ci_ida, GFP_KERNEL); 873 866 if (id < 0) 874 867 return ERR_PTR(id); 875 868 ··· 899 892 err: 900 893 platform_device_put(pdev); 901 894 put_id: 902 - ida_simple_remove(&ci_ida, id); 895 + ida_free(&ci_ida, id); 903 896 return ERR_PTR(ret); 904 897 } 905 898 EXPORT_SYMBOL_GPL(ci_hdrc_add_device); ··· 908 901 { 909 902 int id = pdev->id; 910 903 platform_device_unregister(pdev); 911 - ida_simple_remove(&ci_ida, id); 904 + ida_free(&ci_ida, id); 912 905 } 913 906 EXPORT_SYMBOL_GPL(ci_hdrc_remove_device); 914 907
+2 -1
drivers/usb/chipidea/udc.c
··· 688 688 if ((TD_STATUS_ACTIVE & tmptoken) != 0) { 689 689 int n = hw_ep_bit(hwep->num, hwep->dir); 690 690 691 - if (ci->rev == CI_REVISION_24) 691 + if (ci->rev == CI_REVISION_24 || 692 + ci->rev == CI_REVISION_22) 692 693 if (!hw_read(ci, OP_ENDPTSTAT, BIT(n))) 693 694 reprime_dtd(ci, hwep, node); 694 695 hwreq->req.status = -EALREADY;
+3
drivers/usb/class/cdc-acm.c
··· 916 916 struct acm *acm = tty->driver_data; 917 917 int retval; 918 918 919 + if (!(acm->ctrl_caps & USB_CDC_CAP_BRK)) 920 + return -EOPNOTSUPP; 921 + 919 922 retval = acm_send_break(acm, state ? 0xffff : 0); 920 923 if (retval < 0) 921 924 dev_dbg(&acm->control->dev,
+35 -29
drivers/usb/core/driver.c
··· 189 189 goto exit; 190 190 191 191 if (usb_drv->probe != NULL) { 192 - error = driver_create_file(&usb_drv->drvwrap.driver, 192 + error = driver_create_file(&usb_drv->driver, 193 193 &driver_attr_new_id); 194 194 if (error == 0) { 195 - error = driver_create_file(&usb_drv->drvwrap.driver, 195 + error = driver_create_file(&usb_drv->driver, 196 196 &driver_attr_remove_id); 197 197 if (error) 198 - driver_remove_file(&usb_drv->drvwrap.driver, 198 + driver_remove_file(&usb_drv->driver, 199 199 &driver_attr_new_id); 200 200 } 201 201 } ··· 209 209 return; 210 210 211 211 if (usb_drv->probe != NULL) { 212 - driver_remove_file(&usb_drv->drvwrap.driver, 212 + driver_remove_file(&usb_drv->driver, 213 213 &driver_attr_remove_id); 214 - driver_remove_file(&usb_drv->drvwrap.driver, 214 + driver_remove_file(&usb_drv->driver, 215 215 &driver_attr_new_id); 216 216 } 217 217 } ··· 290 290 * specialised device drivers prior to setting the 291 291 * use_generic_driver bit. 292 292 */ 293 - error = udriver->probe(udev); 293 + if (udriver->probe) 294 + error = udriver->probe(udev); 295 + else if (!udriver->generic_subclass) 296 + error = -EINVAL; 294 297 if (error == -ENODEV && udriver != &usb_generic_driver && 295 298 (udriver->id_table || udriver->match)) { 296 299 udev->use_generic_driver = 1; ··· 552 549 if (!iface->authorized) 553 550 return -ENODEV; 554 551 555 - dev->driver = &driver->drvwrap.driver; 552 + dev->driver = &driver->driver; 556 553 usb_set_intfdata(iface, data); 557 554 iface->needs_binding = 0; 558 555 ··· 615 612 struct device *dev = &iface->dev; 616 613 617 614 /* this should never happen, don't release something that's not ours */ 618 - if (!dev->driver || dev->driver != &driver->drvwrap.driver) 615 + if (!dev->driver || dev->driver != &driver->driver) 619 616 return; 620 617 621 618 /* don't release from within disconnect() */ ··· 950 947 int ret; 951 948 952 949 /* Don't reprobe if current driver isn't usb_generic_driver */ 953 - if (dev->driver != &usb_generic_driver.drvwrap.driver) 950 + if (dev->driver != &usb_generic_driver.driver) 954 951 return 0; 955 952 956 953 udev = to_usb_device(dev); ··· 962 959 dev_err(dev, "Failed to reprobe device (error %d)\n", ret); 963 960 964 961 return 0; 962 + } 963 + 964 + bool is_usb_device_driver(const struct device_driver *drv) 965 + { 966 + return drv->probe == usb_probe_device; 965 967 } 966 968 967 969 /** ··· 988 980 if (usb_disabled()) 989 981 return -ENODEV; 990 982 991 - new_udriver->drvwrap.for_devices = 1; 992 - new_udriver->drvwrap.driver.name = new_udriver->name; 993 - new_udriver->drvwrap.driver.bus = &usb_bus_type; 994 - new_udriver->drvwrap.driver.probe = usb_probe_device; 995 - new_udriver->drvwrap.driver.remove = usb_unbind_device; 996 - new_udriver->drvwrap.driver.owner = owner; 997 - new_udriver->drvwrap.driver.dev_groups = new_udriver->dev_groups; 983 + new_udriver->driver.name = new_udriver->name; 984 + new_udriver->driver.bus = &usb_bus_type; 985 + new_udriver->driver.probe = usb_probe_device; 986 + new_udriver->driver.remove = usb_unbind_device; 987 + new_udriver->driver.owner = owner; 988 + new_udriver->driver.dev_groups = new_udriver->dev_groups; 998 989 999 - retval = driver_register(&new_udriver->drvwrap.driver); 990 + retval = driver_register(&new_udriver->driver); 1000 991 1001 992 if (!retval) { 1002 993 pr_info("%s: registered new device driver %s\n", ··· 1027 1020 pr_info("%s: deregistering device driver %s\n", 1028 1021 usbcore_name, udriver->name); 1029 1022 1030 - driver_unregister(&udriver->drvwrap.driver); 1023 + driver_unregister(&udriver->driver); 1031 1024 } 1032 1025 EXPORT_SYMBOL_GPL(usb_deregister_device_driver); 1033 1026 ··· 1055 1048 if (usb_disabled()) 1056 1049 return -ENODEV; 1057 1050 1058 - new_driver->drvwrap.for_devices = 0; 1059 - new_driver->drvwrap.driver.name = new_driver->name; 1060 - new_driver->drvwrap.driver.bus = &usb_bus_type; 1061 - new_driver->drvwrap.driver.probe = usb_probe_interface; 1062 - new_driver->drvwrap.driver.remove = usb_unbind_interface; 1063 - new_driver->drvwrap.driver.owner = owner; 1064 - new_driver->drvwrap.driver.mod_name = mod_name; 1065 - new_driver->drvwrap.driver.dev_groups = new_driver->dev_groups; 1051 + new_driver->driver.name = new_driver->name; 1052 + new_driver->driver.bus = &usb_bus_type; 1053 + new_driver->driver.probe = usb_probe_interface; 1054 + new_driver->driver.remove = usb_unbind_interface; 1055 + new_driver->driver.owner = owner; 1056 + new_driver->driver.mod_name = mod_name; 1057 + new_driver->driver.dev_groups = new_driver->dev_groups; 1066 1058 spin_lock_init(&new_driver->dynids.lock); 1067 1059 INIT_LIST_HEAD(&new_driver->dynids.list); 1068 1060 1069 - retval = driver_register(&new_driver->drvwrap.driver); 1061 + retval = driver_register(&new_driver->driver); 1070 1062 if (retval) 1071 1063 goto out; 1072 1064 ··· 1080 1074 return retval; 1081 1075 1082 1076 out_newid: 1083 - driver_unregister(&new_driver->drvwrap.driver); 1077 + driver_unregister(&new_driver->driver); 1084 1078 1085 1079 pr_err("%s: error %d registering interface driver %s\n", 1086 1080 usbcore_name, retval, new_driver->name); ··· 1105 1099 usbcore_name, driver->name); 1106 1100 1107 1101 usb_remove_newid_files(driver); 1108 - driver_unregister(&driver->drvwrap.driver); 1102 + driver_unregister(&driver->driver); 1109 1103 usb_free_dynids(driver); 1110 1104 } 1111 1105 EXPORT_SYMBOL_GPL(usb_deregister);
+16
drivers/usb/core/generic.c
··· 59 59 int num_configs; 60 60 int insufficient_power = 0; 61 61 struct usb_host_config *c, *best; 62 + struct usb_device_driver *udriver; 63 + 64 + /* 65 + * If a USB device (not an interface) doesn't have a driver then the 66 + * kernel has no business trying to select or install a configuration 67 + * for it. 68 + */ 69 + if (!udev->dev.driver) 70 + return -1; 71 + udriver = to_usb_device_driver(udev->dev.driver); 62 72 63 73 if (usb_device_is_owned(udev)) 64 74 return 0; 75 + 76 + if (udriver->choose_configuration) { 77 + i = udriver->choose_configuration(udev); 78 + if (i >= 0) 79 + return i; 80 + } 65 81 66 82 best = NULL; 67 83 c = udev->config;
+44 -4
drivers/usb/core/hub.c
··· 47 47 #define USB_VENDOR_TEXAS_INSTRUMENTS 0x0451 48 48 #define USB_PRODUCT_TUSB8041_USB3 0x8140 49 49 #define USB_PRODUCT_TUSB8041_USB2 0x8142 50 - #define HUB_QUIRK_CHECK_PORT_AUTOSUSPEND 0x01 51 - #define HUB_QUIRK_DISABLE_AUTOSUSPEND 0x02 50 + #define USB_VENDOR_MICROCHIP 0x0424 51 + #define USB_PRODUCT_USB4913 0x4913 52 + #define USB_PRODUCT_USB4914 0x4914 53 + #define USB_PRODUCT_USB4915 0x4915 54 + #define HUB_QUIRK_CHECK_PORT_AUTOSUSPEND BIT(0) 55 + #define HUB_QUIRK_DISABLE_AUTOSUSPEND BIT(1) 56 + #define HUB_QUIRK_REDUCE_FRAME_INTR_BINTERVAL BIT(2) 52 57 53 58 #define USB_TP_TRANSMISSION_DELAY 40 /* ns */ 54 59 #define USB_TP_TRANSMISSION_DELAY_MAX 65535 /* ns */ 55 60 #define USB_PING_RESPONSE_TIME 400 /* ns */ 61 + #define USB_REDUCE_FRAME_INTR_BINTERVAL 9 62 + 63 + /* 64 + * The SET_ADDRESS request timeout will be 500 ms when 65 + * USB_QUIRK_SHORT_SET_ADDRESS_REQ_TIMEOUT quirk flag is set. 66 + */ 67 + #define USB_SHORT_SET_ADDRESS_REQ_TIMEOUT 500 /* ms */ 56 68 57 69 /* Protect struct usb_device->state and ->children members 58 70 * Note: Both are also protected by ->dev.sem, except that ->state can ··· 1914 1902 if (id->driver_info & HUB_QUIRK_DISABLE_AUTOSUSPEND) { 1915 1903 hub->quirk_disable_autosuspend = 1; 1916 1904 usb_autopm_get_interface_no_resume(intf); 1905 + } 1906 + 1907 + if ((id->driver_info & HUB_QUIRK_REDUCE_FRAME_INTR_BINTERVAL) && 1908 + desc->endpoint[0].desc.bInterval > USB_REDUCE_FRAME_INTR_BINTERVAL) { 1909 + desc->endpoint[0].desc.bInterval = 1910 + USB_REDUCE_FRAME_INTR_BINTERVAL; 1911 + /* Tell the HCD about the interrupt ep's new bInterval */ 1912 + usb_set_interface(hdev, 0, 0); 1917 1913 } 1918 1914 1919 1915 if (hub_configure(hub, &desc->endpoint[0].desc) >= 0) { ··· 4646 4626 static int hub_set_address(struct usb_device *udev, int devnum) 4647 4627 { 4648 4628 int retval; 4629 + unsigned int timeout_ms = USB_CTRL_SET_TIMEOUT; 4649 4630 struct usb_hcd *hcd = bus_to_hcd(udev->bus); 4631 + struct usb_hub *hub = usb_hub_to_struct_hub(udev->parent); 4632 + 4633 + if (hub->hdev->quirks & USB_QUIRK_SHORT_SET_ADDRESS_REQ_TIMEOUT) 4634 + timeout_ms = USB_SHORT_SET_ADDRESS_REQ_TIMEOUT; 4650 4635 4651 4636 /* 4652 4637 * The host controller will choose the device address, ··· 4664 4639 if (udev->state != USB_STATE_DEFAULT) 4665 4640 return -EINVAL; 4666 4641 if (hcd->driver->address_device) 4667 - retval = hcd->driver->address_device(hcd, udev); 4642 + retval = hcd->driver->address_device(hcd, udev, timeout_ms); 4668 4643 else 4669 4644 retval = usb_control_msg(udev, usb_sndaddr0pipe(), 4670 4645 USB_REQ_SET_ADDRESS, 0, devnum, 0, 4671 - NULL, 0, USB_CTRL_SET_TIMEOUT); 4646 + NULL, 0, timeout_ms); 4672 4647 if (retval == 0) { 4673 4648 update_devnum(udev, devnum); 4674 4649 /* Device now using proper address. */ ··· 5920 5895 .idVendor = USB_VENDOR_TEXAS_INSTRUMENTS, 5921 5896 .idProduct = USB_PRODUCT_TUSB8041_USB3, 5922 5897 .driver_info = HUB_QUIRK_DISABLE_AUTOSUSPEND}, 5898 + { .match_flags = USB_DEVICE_ID_MATCH_VENDOR 5899 + | USB_DEVICE_ID_MATCH_PRODUCT, 5900 + .idVendor = USB_VENDOR_MICROCHIP, 5901 + .idProduct = USB_PRODUCT_USB4913, 5902 + .driver_info = HUB_QUIRK_REDUCE_FRAME_INTR_BINTERVAL}, 5903 + { .match_flags = USB_DEVICE_ID_MATCH_VENDOR 5904 + | USB_DEVICE_ID_MATCH_PRODUCT, 5905 + .idVendor = USB_VENDOR_MICROCHIP, 5906 + .idProduct = USB_PRODUCT_USB4914, 5907 + .driver_info = HUB_QUIRK_REDUCE_FRAME_INTR_BINTERVAL}, 5908 + { .match_flags = USB_DEVICE_ID_MATCH_VENDOR 5909 + | USB_DEVICE_ID_MATCH_PRODUCT, 5910 + .idVendor = USB_VENDOR_MICROCHIP, 5911 + .idProduct = USB_PRODUCT_USB4915, 5912 + .driver_info = HUB_QUIRK_REDUCE_FRAME_INTR_BINTERVAL}, 5923 5913 { .match_flags = USB_DEVICE_ID_MATCH_DEV_CLASS, 5924 5914 .bDeviceClass = USB_CLASS_HUB}, 5925 5915 { .match_flags = USB_DEVICE_ID_MATCH_INT_CLASS,
+7
drivers/usb/core/quirks.c
··· 138 138 case 'o': 139 139 flags |= USB_QUIRK_HUB_SLOW_RESET; 140 140 break; 141 + case 'p': 142 + flags |= USB_QUIRK_SHORT_SET_ADDRESS_REQ_TIMEOUT; 143 + break; 141 144 /* Ignore unrecognized flag characters */ 142 145 } 143 146 } ··· 529 526 { USB_DEVICE(0x2386, 0x3119), .driver_info = USB_QUIRK_NO_LPM }, 530 527 531 528 { USB_DEVICE(0x2386, 0x350e), .driver_info = USB_QUIRK_NO_LPM }, 529 + 530 + /* APTIV AUTOMOTIVE HUB */ 531 + { USB_DEVICE(0x2c48, 0x0132), .driver_info = 532 + USB_QUIRK_SHORT_SET_ADDRESS_REQ_TIMEOUT }, 532 533 533 534 /* DJI CineSSD */ 534 535 { USB_DEVICE(0x2ca3, 0x0031), .driver_info = USB_QUIRK_NO_LPM },
+1 -1
drivers/usb/core/usb.c
··· 431 431 struct device *dev; 432 432 433 433 argb.minor = minor; 434 - argb.drv = &drv->drvwrap.driver; 434 + argb.drv = &drv->driver; 435 435 436 436 dev = bus_find_device(&usb_bus_type, NULL, &argb, __find_interface); 437 437
+1 -7
drivers/usb/core/usb.h
··· 175 175 return (udev->parent == NULL); 176 176 } 177 177 178 - /* Do the same for device drivers and interface drivers. */ 179 - 180 - static inline int is_usb_device_driver(struct device_driver *drv) 181 - { 182 - return container_of(drv, struct usbdrv_wrap, driver)-> 183 - for_devices; 184 - } 178 + extern bool is_usb_device_driver(const struct device_driver *drv); 185 179 186 180 /* for labeling diagnostics */ 187 181 extern const char *usbcore_name;
+1
drivers/usb/dwc2/params.c
··· 130 130 p->lpm_clock_gating = false; 131 131 p->besl = false; 132 132 p->hird_threshold_en = false; 133 + p->no_clock_gating = true; 133 134 } 134 135 135 136 static void dwc2_set_ltq_params(struct dwc2_hsotg *hsotg)
+20 -42
drivers/usb/dwc3/core.c
··· 277 277 /* 278 278 * We're resetting only the device side because, if we're in host mode, 279 279 * XHCI driver will reset the host block. If dwc3 was configured for 280 - * host-only mode or current role is host, then we can return early. 280 + * host-only mode, then we can return early. 281 281 */ 282 282 if (dwc->current_dr_role == DWC3_GCTL_PRTCAP_HOST) 283 283 return 0; 284 - 285 - /* 286 - * If the dr_mode is host and the dwc->current_dr_role is not the 287 - * corresponding DWC3_GCTL_PRTCAP_HOST, then the dwc3_core_init_mode 288 - * isn't executed yet. Ensure the phy is ready before the controller 289 - * updates the GCTL.PRTCAPDIR or other settings by soft-resetting 290 - * the phy. 291 - * 292 - * Note: GUSB3PIPECTL[n] and GUSB2PHYCFG[n] are port settings where n 293 - * is port index. If this is a multiport host, then we need to reset 294 - * all active ports. 295 - */ 296 - if (dwc->dr_mode == USB_DR_MODE_HOST) { 297 - u32 usb3_port; 298 - u32 usb2_port; 299 - 300 - usb3_port = dwc3_readl(dwc->regs, DWC3_GUSB3PIPECTL(0)); 301 - usb3_port |= DWC3_GUSB3PIPECTL_PHYSOFTRST; 302 - dwc3_writel(dwc->regs, DWC3_GUSB3PIPECTL(0), usb3_port); 303 - 304 - usb2_port = dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0)); 305 - usb2_port |= DWC3_GUSB2PHYCFG_PHYSOFTRST; 306 - dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), usb2_port); 307 - 308 - /* Small delay for phy reset assertion */ 309 - usleep_range(1000, 2000); 310 - 311 - usb3_port &= ~DWC3_GUSB3PIPECTL_PHYSOFTRST; 312 - dwc3_writel(dwc->regs, DWC3_GUSB3PIPECTL(0), usb3_port); 313 - 314 - usb2_port &= ~DWC3_GUSB2PHYCFG_PHYSOFTRST; 315 - dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), usb2_port); 316 - 317 - /* Wait for clock synchronization */ 318 - msleep(50); 319 - return 0; 320 - } 321 284 322 285 reg = dwc3_readl(dwc->regs, DWC3_DCTL); 323 286 reg |= DWC3_DCTL_CSFTRST; ··· 1330 1367 1331 1368 dwc3_config_threshold(dwc); 1332 1369 1370 + /* 1371 + * Modify this for all supported Super Speed ports when 1372 + * multiport support is added. 1373 + */ 1374 + if (hw_mode != DWC3_GHWPARAMS0_MODE_GADGET && 1375 + (DWC3_IP_IS(DWC31)) && 1376 + dwc->maximum_speed == USB_SPEED_SUPER) { 1377 + reg = dwc3_readl(dwc->regs, DWC3_LLUCTL); 1378 + reg |= DWC3_LLUCTL_FORCE_GEN1; 1379 + dwc3_writel(dwc->regs, DWC3_LLUCTL, reg); 1380 + } 1381 + 1333 1382 return 0; 1334 1383 1335 1384 err_power_off_phy: ··· 2315 2340 2316 2341 pinctrl_pm_select_default_state(dev); 2317 2342 2318 - ret = dwc3_resume_common(dwc, PMSG_RESUME); 2319 - if (ret) 2320 - return ret; 2321 - 2322 2343 pm_runtime_disable(dev); 2323 2344 pm_runtime_set_active(dev); 2345 + 2346 + ret = dwc3_resume_common(dwc, PMSG_RESUME); 2347 + if (ret) { 2348 + pm_runtime_set_suspended(dev); 2349 + return ret; 2350 + } 2351 + 2324 2352 pm_runtime_enable(dev); 2325 2353 2326 2354 return 0;
+6
drivers/usb/dwc3/core.h
··· 172 172 #define DWC3_OEVTEN 0xcc0C 173 173 #define DWC3_OSTS 0xcc10 174 174 175 + #define DWC3_LLUCTL 0xd024 176 + 175 177 /* Bit fields */ 176 178 177 179 /* Global SoC Bus Configuration INCRx Register 0 */ ··· 376 374 /* Global HWPARAMS4 Register */ 377 375 #define DWC3_GHWPARAMS4_HIBER_SCRATCHBUFS(n) (((n) & (0x0f << 13)) >> 13) 378 376 #define DWC3_MAX_HIBER_SCRATCHBUFS 15 377 + #define DWC3_EXT_BUFF_CONTROL BIT(21) 379 378 380 379 /* Global HWPARAMS6 Register */ 381 380 #define DWC3_GHWPARAMS6_BCSUPPORT BIT(14) ··· 659 656 #define DWC3_OSTS_BSESVLD BIT(2) 660 657 #define DWC3_OSTS_VBUSVLD BIT(1) 661 658 #define DWC3_OSTS_CONIDSTS BIT(0) 659 + 660 + /* Force Gen1 speed on Gen2 link */ 661 + #define DWC3_LLUCTL_FORCE_GEN1 BIT(10) 662 662 663 663 /* Structures */ 664 664
+3 -1
drivers/usb/dwc3/dwc3-imx8mp.c
··· 363 363 } 364 364 365 365 ret = clk_prepare_enable(dwc3_imx->hsio_clk); 366 - if (ret) 366 + if (ret) { 367 + clk_disable_unprepare(dwc3_imx->suspend_clk); 367 368 return ret; 369 + } 368 370 369 371 ret = dwc3_imx8mp_resume(dwc3_imx, PMSG_RESUME); 370 372
+11 -11
drivers/usb/dwc3/dwc3-qcom.c
··· 57 57 u32 qscratch_base_offset; 58 58 u32 qscratch_base_size; 59 59 u32 dwc3_core_base_size; 60 - int hs_phy_irq_index; 60 + int qusb2_phy_irq_index; 61 61 int dp_hs_phy_irq_index; 62 62 int dm_hs_phy_irq_index; 63 63 int ss_phy_irq_index; ··· 73 73 int num_clocks; 74 74 struct reset_control *resets; 75 75 76 - int hs_phy_irq; 76 + int qusb2_phy_irq; 77 77 int dp_hs_phy_irq; 78 78 int dm_hs_phy_irq; 79 79 int ss_phy_irq; ··· 372 372 373 373 static void dwc3_qcom_disable_interrupts(struct dwc3_qcom *qcom) 374 374 { 375 - dwc3_qcom_disable_wakeup_irq(qcom->hs_phy_irq); 375 + dwc3_qcom_disable_wakeup_irq(qcom->qusb2_phy_irq); 376 376 377 377 if (qcom->usb2_speed == USB_SPEED_LOW) { 378 378 dwc3_qcom_disable_wakeup_irq(qcom->dm_hs_phy_irq); ··· 389 389 390 390 static void dwc3_qcom_enable_interrupts(struct dwc3_qcom *qcom) 391 391 { 392 - dwc3_qcom_enable_wakeup_irq(qcom->hs_phy_irq, 0); 392 + dwc3_qcom_enable_wakeup_irq(qcom->qusb2_phy_irq, 0); 393 393 394 394 /* 395 395 * Configure DP/DM line interrupts based on the USB2 device attached to ··· 542 542 int irq; 543 543 int ret; 544 544 545 - irq = dwc3_qcom_get_irq(pdev, "hs_phy_irq", 546 - pdata ? pdata->hs_phy_irq_index : -1); 545 + irq = dwc3_qcom_get_irq(pdev, "qusb2_phy", 546 + pdata ? pdata->qusb2_phy_irq_index : -1); 547 547 if (irq > 0) { 548 548 /* Keep wakeup interrupts disabled until suspend */ 549 549 ret = devm_request_threaded_irq(qcom->dev, irq, NULL, 550 550 qcom_dwc3_resume_irq, 551 551 IRQF_ONESHOT | IRQF_NO_AUTOEN, 552 - "qcom_dwc3 HS", qcom); 552 + "qcom_dwc3 QUSB2", qcom); 553 553 if (ret) { 554 - dev_err(qcom->dev, "hs_phy_irq failed: %d\n", ret); 554 + dev_err(qcom->dev, "qusb2_phy_irq failed: %d\n", ret); 555 555 return ret; 556 556 } 557 - qcom->hs_phy_irq = irq; 557 + qcom->qusb2_phy_irq = irq; 558 558 } 559 559 560 560 irq = dwc3_qcom_get_irq(pdev, "dp_hs_phy_irq", ··· 1058 1058 .qscratch_base_offset = SDM845_QSCRATCH_BASE_OFFSET, 1059 1059 .qscratch_base_size = SDM845_QSCRATCH_SIZE, 1060 1060 .dwc3_core_base_size = SDM845_DWC3_CORE_SIZE, 1061 - .hs_phy_irq_index = 1, 1061 + .qusb2_phy_irq_index = 1, 1062 1062 .dp_hs_phy_irq_index = 4, 1063 1063 .dm_hs_phy_irq_index = 3, 1064 1064 .ss_phy_irq_index = 2 ··· 1068 1068 .qscratch_base_offset = SDM845_QSCRATCH_BASE_OFFSET, 1069 1069 .qscratch_base_size = SDM845_QSCRATCH_SIZE, 1070 1070 .dwc3_core_base_size = SDM845_DWC3_CORE_SIZE, 1071 - .hs_phy_irq_index = 1, 1071 + .qusb2_phy_irq_index = 1, 1072 1072 .dp_hs_phy_irq_index = 4, 1073 1073 .dm_hs_phy_irq_index = 3, 1074 1074 .ss_phy_irq_index = 2,
+8 -5
drivers/usb/dwc3/dwc3-xilinx.c
··· 293 293 goto err_clk_put; 294 294 295 295 pm_runtime_set_active(dev); 296 - pm_runtime_enable(dev); 297 - pm_suspend_ignore_children(dev, false); 298 - pm_runtime_get_sync(dev); 296 + ret = devm_pm_runtime_enable(dev); 297 + if (ret < 0) 298 + goto err_pm_set_suspended; 299 299 300 - return 0; 300 + pm_suspend_ignore_children(dev, false); 301 + return pm_runtime_resume_and_get(dev); 302 + 303 + err_pm_set_suspended: 304 + pm_runtime_set_suspended(dev); 301 305 302 306 err_clk_put: 303 307 clk_bulk_disable_unprepare(priv_data->num_clocks, priv_data->clks); ··· 319 315 clk_bulk_disable_unprepare(priv_data->num_clocks, priv_data->clks); 320 316 priv_data->num_clocks = 0; 321 317 322 - pm_runtime_disable(dev); 323 318 pm_runtime_put_noidle(dev); 324 319 pm_runtime_set_suspended(dev); 325 320 }
+4 -1
drivers/usb/dwc3/ep0.c
··· 238 238 struct dwc3_request *req; 239 239 240 240 req = next_request(&dep->pending_list); 241 - dwc3_gadget_giveback(dep, req, -ECONNRESET); 241 + if (!dwc->connected) 242 + dwc3_gadget_giveback(dep, req, -ESHUTDOWN); 243 + else 244 + dwc3_gadget_giveback(dep, req, -ECONNRESET); 242 245 } 243 246 244 247 dwc->eps[0]->trb_enqueue = 0;
+24 -1
drivers/usb/dwc3/gadget.c
··· 673 673 params.param1 |= DWC3_DEPCFG_BINTERVAL_M1(bInterval_m1); 674 674 } 675 675 676 + if (dep->endpoint.fifo_mode) { 677 + if (!(dwc->hwparams.hwparams4 & DWC3_EXT_BUFF_CONTROL)) 678 + return -EINVAL; 679 + params.param1 |= DWC3_DEPCFG_EBC_HWO_NOWB | DWC3_DEPCFG_USE_EBC; 680 + } 681 + 676 682 return dwc3_send_gadget_ep_cmd(dep, DWC3_DEPCMD_SETEPCONFIG, &params); 677 683 } 678 684 ··· 2109 2103 2110 2104 list_for_each_entry(r, &dep->pending_list, list) { 2111 2105 if (r == req) { 2112 - dwc3_gadget_giveback(dep, req, -ECONNRESET); 2106 + /* 2107 + * Explicitly check for EP0/1 as dequeue for those 2108 + * EPs need to be handled differently. Control EP 2109 + * only deals with one USB req, and giveback will 2110 + * occur during dwc3_ep0_stall_and_restart(). EP0 2111 + * requests are never added to started_list. 2112 + */ 2113 + if (dep->number > 1) 2114 + dwc3_gadget_giveback(dep, req, -ECONNRESET); 2115 + else 2116 + dwc3_ep0_reset_state(dwc); 2113 2117 goto out; 2114 2118 } 2115 2119 } ··· 3989 3973 usb_gadget_set_state(dwc->gadget, USB_STATE_NOTATTACHED); 3990 3974 3991 3975 dwc3_ep0_reset_state(dwc); 3976 + 3977 + /* 3978 + * Request PM idle to address condition where usage count is 3979 + * already decremented to zero, but waiting for the disconnect 3980 + * interrupt to set dwc->connected to FALSE. 3981 + */ 3982 + pm_request_idle(dwc->dev); 3992 3983 } 3993 3984 3994 3985 static void dwc3_gadget_reset_interrupt(struct dwc3 *dwc)
+2
drivers/usb/dwc3/gadget.h
··· 26 26 #define DWC3_DEPCFG_XFER_NOT_READY_EN BIT(10) 27 27 #define DWC3_DEPCFG_FIFO_ERROR_EN BIT(11) 28 28 #define DWC3_DEPCFG_STREAM_EVENT_EN BIT(13) 29 + #define DWC3_DEPCFG_EBC_HWO_NOWB BIT(14) 30 + #define DWC3_DEPCFG_USE_EBC BIT(15) 29 31 #define DWC3_DEPCFG_BINTERVAL_M1(n) (((n) & 0xff) << 16) 30 32 #define DWC3_DEPCFG_STREAM_CAPABLE BIT(24) 31 33 #define DWC3_DEPCFG_EP_NUMBER(n) (((n) & 0x1f) << 25)
+4 -8
drivers/usb/fotg210/fotg210-hcd.c
··· 404 404 else if (td->hw_alt_next != list_end) 405 405 mark = '/'; 406 406 } 407 - temp = snprintf(next, size, 408 - "\n\t%p%c%s len=%d %08x urb %p", 409 - td, mark, ({ char *tmp; 407 + temp = scnprintf(next, size, 408 + "\n\t%p%c%s len=%d %08x urb %p", 409 + td, mark, ({ char *tmp; 410 410 switch ((scratch>>8)&0x03) { 411 411 case 0: 412 412 tmp = "out"; ··· 424 424 (scratch >> 16) & 0x7fff, 425 425 scratch, 426 426 td->urb); 427 - if (size < temp) 428 - temp = size; 429 427 size -= temp; 430 428 next += temp; 431 429 } 432 430 433 - temp = snprintf(next, size, "\n"); 434 - if (size < temp) 435 - temp = size; 431 + temp = scnprintf(next, size, "\n"); 436 432 437 433 size -= temp; 438 434 next += temp;
+3 -3
drivers/usb/fotg210/fotg210-udc.c
··· 1094 1094 1095 1095 /** 1096 1096 * fotg210_vbus_session - Called by external transceiver to enable/disable udc 1097 - * @_gadget: usb gadget 1097 + * @g: usb gadget 1098 1098 * @is_active: 0 if should disable UDC VBUS, 1 if should enable 1099 1099 * 1100 - * Returns 0 1100 + * Returns: %0 1101 1101 */ 1102 1102 static int fotg210_vbus_session(struct usb_gadget *g, int is_active) 1103 1103 { ··· 1122 1122 * 1123 1123 * Called by the USB Phy when a cable connect or disconnect is sensed. 1124 1124 * 1125 - * Returns NOTIFY_OK or NOTIFY_DONE 1125 + * Returns: NOTIFY_OK or NOTIFY_DONE 1126 1126 */ 1127 1127 static int fotg210_phy_event(struct notifier_block *nb, unsigned long action, 1128 1128 void *data)
+8 -5
drivers/usb/gadget/configfs.c
··· 606 606 char *instance_name; 607 607 int ret; 608 608 609 - ret = snprintf(buf, MAX_NAME_LEN, "%s", name); 610 - if (ret >= MAX_NAME_LEN) 609 + if (strlen(name) >= MAX_NAME_LEN) 611 610 return ERR_PTR(-ENAMETOOLONG); 611 + 612 + scnprintf(buf, MAX_NAME_LEN, "%s", name); 612 613 613 614 func_name = buf; 614 615 instance_name = strchr(func_name, '.'); ··· 702 701 int ret; 703 702 704 703 gi = container_of(group, struct gadget_info, configs_group); 705 - ret = snprintf(buf, MAX_NAME_LEN, "%s", name); 706 - if (ret >= MAX_NAME_LEN) 704 + 705 + if (strlen(name) >= MAX_NAME_LEN) 707 706 return ERR_PTR(-ENAMETOOLONG); 707 + 708 + scnprintf(buf, MAX_NAME_LEN, "%s", name); 708 709 709 710 num_str = strchr(buf, '.'); 710 711 if (!num_str) { ··· 815 812 struct gadget_string *string = to_gadget_string(item); 816 813 int ret; 817 814 818 - ret = snprintf(page, sizeof(string->string), "%s\n", string->string); 815 + ret = sysfs_emit(page, "%s\n", string->string); 819 816 return ret; 820 817 } 821 818
+2 -3
drivers/usb/gadget/function/f_fs.c
··· 2931 2931 2932 2932 t = &func->function.os_desc_table[desc->bFirstInterfaceNumber]; 2933 2933 t->if_id = func->interfaces_nums[desc->bFirstInterfaceNumber]; 2934 - memcpy(t->os_desc->ext_compat_id, &desc->CompatibleID, 2935 - ARRAY_SIZE(desc->CompatibleID) + 2936 - ARRAY_SIZE(desc->SubCompatibleID)); 2934 + memcpy(t->os_desc->ext_compat_id, &desc->IDs, 2935 + sizeof_field(struct usb_ext_compat_desc, IDs)); 2937 2936 length = sizeof(*desc); 2938 2937 } 2939 2938 break;
+2 -2
drivers/usb/gadget/function/f_midi.c
··· 1177 1177 static ssize_t f_midi_opts_id_show(struct config_item *item, char *page) 1178 1178 { 1179 1179 struct f_midi_opts *opts = to_f_midi_opts(item); 1180 - int result; 1180 + ssize_t result; 1181 1181 1182 1182 mutex_lock(&opts->lock); 1183 1183 if (opts->id) { 1184 - result = strlcpy(page, opts->id, PAGE_SIZE); 1184 + result = strscpy(page, opts->id, PAGE_SIZE); 1185 1185 } else { 1186 1186 page[0] = 0; 1187 1187 result = 0;
+66 -3
drivers/usb/gadget/function/f_ncm.c
··· 103 103 /* Delay for the transmit to wait before sending an unfilled NTB frame. */ 104 104 #define TX_TIMEOUT_NSECS 300000 105 105 106 + /* 107 + * Although max mtu as dictated by u_ether is 15412 bytes, setting 108 + * max_segment_sizeto 15426 would not be efficient. If user chooses segment 109 + * size to be (>= 8192), then we can't aggregate more than one buffer in each 110 + * NTB (assuming each packet coming from network layer is >= 8192 bytes) as ep 111 + * maxpacket limit is 16384. So let max_segment_size be limited to 8000 to allow 112 + * at least 2 packets to be aggregated reducing wastage of NTB buffer space 113 + */ 114 + #define MAX_DATAGRAM_SIZE 8000 115 + 106 116 #define FORMATS_SUPPORTED (USB_CDC_NCM_NTB16_SUPPORTED | \ 107 117 USB_CDC_NCM_NTB32_SUPPORTED) 108 118 ··· 189 179 /* this descriptor actually adds value, surprise! */ 190 180 /* .iMACAddress = DYNAMIC */ 191 181 .bmEthernetStatistics = cpu_to_le32(0), /* no statistics */ 192 - .wMaxSegmentSize = cpu_to_le16(ETH_FRAME_LEN), 193 182 .wNumberMCFilters = cpu_to_le16(0), 194 183 .bNumberPowerFilters = 0, 195 184 }; ··· 1175 1166 struct sk_buff *skb2; 1176 1167 int ret = -EINVAL; 1177 1168 unsigned ntb_max = le32_to_cpu(ntb_parameters.dwNtbOutMaxSize); 1178 - unsigned frame_max = le16_to_cpu(ecm_desc.wMaxSegmentSize); 1169 + unsigned frame_max; 1179 1170 const struct ndp_parser_opts *opts = ncm->parser_opts; 1180 1171 unsigned crc_len = ncm->is_crc ? sizeof(uint32_t) : 0; 1181 1172 int dgram_counter; 1182 1173 int to_process = skb->len; 1174 + struct f_ncm_opts *ncm_opts; 1175 + 1176 + ncm_opts = container_of(port->func.fi, struct f_ncm_opts, func_inst); 1177 + frame_max = ncm_opts->max_segment_size; 1183 1178 1184 1179 parse_ntb: 1185 1180 tmp = (__le16 *)ntb_ptr; ··· 1443 1430 1444 1431 mutex_lock(&ncm_opts->lock); 1445 1432 gether_set_gadget(ncm_opts->net, cdev->gadget); 1446 - if (!ncm_opts->bound) 1433 + if (!ncm_opts->bound) { 1434 + ncm_opts->net->mtu = (ncm_opts->max_segment_size - ETH_HLEN); 1447 1435 status = gether_register_netdev(ncm_opts->net); 1436 + } 1448 1437 mutex_unlock(&ncm_opts->lock); 1449 1438 1450 1439 if (status) ··· 1488 1473 ncm_data_nop_intf.bInterfaceNumber = status; 1489 1474 ncm_data_intf.bInterfaceNumber = status; 1490 1475 ncm_union_desc.bSlaveInterface0 = status; 1476 + 1477 + ecm_desc.wMaxSegmentSize = ncm_opts->max_segment_size; 1491 1478 1492 1479 status = -ENODEV; 1493 1480 ··· 1593 1576 /* f_ncm_opts_ifname */ 1594 1577 USB_ETHERNET_CONFIGFS_ITEM_ATTR_IFNAME(ncm); 1595 1578 1579 + static ssize_t ncm_opts_max_segment_size_show(struct config_item *item, 1580 + char *page) 1581 + { 1582 + struct f_ncm_opts *opts = to_f_ncm_opts(item); 1583 + u16 segment_size; 1584 + 1585 + mutex_lock(&opts->lock); 1586 + segment_size = opts->max_segment_size; 1587 + mutex_unlock(&opts->lock); 1588 + 1589 + return sysfs_emit(page, "%u\n", segment_size); 1590 + } 1591 + 1592 + static ssize_t ncm_opts_max_segment_size_store(struct config_item *item, 1593 + const char *page, size_t len) 1594 + { 1595 + struct f_ncm_opts *opts = to_f_ncm_opts(item); 1596 + u16 segment_size; 1597 + int ret; 1598 + 1599 + mutex_lock(&opts->lock); 1600 + if (opts->refcnt) { 1601 + ret = -EBUSY; 1602 + goto out; 1603 + } 1604 + 1605 + ret = kstrtou16(page, 0, &segment_size); 1606 + if (ret) 1607 + goto out; 1608 + 1609 + if (segment_size > MAX_DATAGRAM_SIZE) { 1610 + ret = -EINVAL; 1611 + goto out; 1612 + } 1613 + 1614 + opts->max_segment_size = segment_size; 1615 + ret = len; 1616 + out: 1617 + mutex_unlock(&opts->lock); 1618 + return ret; 1619 + } 1620 + 1621 + CONFIGFS_ATTR(ncm_opts_, max_segment_size); 1622 + 1596 1623 static struct configfs_attribute *ncm_attrs[] = { 1597 1624 &ncm_opts_attr_dev_addr, 1598 1625 &ncm_opts_attr_host_addr, 1599 1626 &ncm_opts_attr_qmult, 1600 1627 &ncm_opts_attr_ifname, 1628 + &ncm_opts_attr_max_segment_size, 1601 1629 NULL, 1602 1630 }; 1603 1631 ··· 1685 1623 kfree(opts); 1686 1624 return ERR_CAST(net); 1687 1625 } 1626 + opts->max_segment_size = cpu_to_le16(ETH_FRAME_LEN); 1688 1627 INIT_LIST_HEAD(&opts->ncm_os_desc.ext_prop); 1689 1628 1690 1629 descs[0] = &opts->ncm_os_desc;
+2 -2
drivers/usb/gadget/function/f_tcm.c
··· 1504 1504 ret = -ENODEV; 1505 1505 goto out; 1506 1506 } 1507 - ret = snprintf(page, PAGE_SIZE, "%s\n", 1508 - tv_nexus->tvn_se_sess->se_node_acl->initiatorname); 1507 + ret = sysfs_emit(page, "%s\n", 1508 + tv_nexus->tvn_se_sess->se_node_acl->initiatorname); 1509 1509 out: 1510 1510 mutex_unlock(&tpg->tpg_mutex); 1511 1511 return ret;
+78 -5
drivers/usb/gadget/function/f_uac1.c
··· 292 292 NULL, 293 293 }; 294 294 295 + /* Standard ISO OUT Endpoint Descriptor */ 296 + static struct usb_endpoint_descriptor ss_as_out_ep_desc = { 297 + .bLength = USB_DT_ENDPOINT_AUDIO_SIZE, 298 + .bDescriptorType = USB_DT_ENDPOINT, 299 + .bEndpointAddress = USB_DIR_OUT, 300 + .bmAttributes = USB_ENDPOINT_SYNC_ADAPTIVE 301 + | USB_ENDPOINT_XFER_ISOC, 302 + .wMaxPacketSize = cpu_to_le16(UAC1_OUT_EP_MAX_PACKET_SIZE), 303 + .bInterval = 4, 304 + }; 305 + 306 + static struct usb_ss_ep_comp_descriptor ss_as_out_ep_desc_comp = { 307 + .bLength = sizeof(ss_as_out_ep_desc_comp), 308 + .bDescriptorType = USB_DT_SS_ENDPOINT_COMP, 309 + .bMaxBurst = 0, 310 + .bmAttributes = 0, 311 + /* wBytesPerInterval = DYNAMIC */ 312 + }; 313 + 314 + /* Standard ISO OUT Endpoint Descriptor */ 315 + static struct usb_endpoint_descriptor ss_as_in_ep_desc = { 316 + .bLength = USB_DT_ENDPOINT_AUDIO_SIZE, 317 + .bDescriptorType = USB_DT_ENDPOINT, 318 + .bEndpointAddress = USB_DIR_IN, 319 + .bmAttributes = USB_ENDPOINT_SYNC_ASYNC 320 + | USB_ENDPOINT_XFER_ISOC, 321 + .wMaxPacketSize = cpu_to_le16(UAC1_OUT_EP_MAX_PACKET_SIZE), 322 + .bInterval = 4, 323 + }; 324 + 325 + static struct usb_ss_ep_comp_descriptor ss_as_in_ep_desc_comp = { 326 + .bLength = sizeof(ss_as_in_ep_desc_comp), 327 + .bDescriptorType = USB_DT_SS_ENDPOINT_COMP, 328 + .bMaxBurst = 0, 329 + .bmAttributes = 0, 330 + /* wBytesPerInterval = DYNAMIC */ 331 + }; 332 + 333 + static struct usb_descriptor_header *f_audio_ss_desc[] = { 334 + (struct usb_descriptor_header *)&ac_interface_desc, 335 + (struct usb_descriptor_header *)&ac_header_desc, 336 + 337 + (struct usb_descriptor_header *)&usb_out_it_desc, 338 + (struct usb_descriptor_header *)&io_out_ot_desc, 339 + (struct usb_descriptor_header *)&io_in_it_desc, 340 + (struct usb_descriptor_header *)&usb_in_ot_desc, 341 + 342 + (struct usb_descriptor_header *)&as_out_interface_alt_0_desc, 343 + (struct usb_descriptor_header *)&as_out_interface_alt_1_desc, 344 + (struct usb_descriptor_header *)&as_out_header_desc, 345 + 346 + (struct usb_descriptor_header *)&as_out_type_i_desc, 347 + 348 + //(struct usb_descriptor_header *)&as_out_ep_desc, 349 + (struct usb_descriptor_header *)&ss_as_out_ep_desc, 350 + (struct usb_descriptor_header *)&ss_as_out_ep_desc_comp, 351 + (struct usb_descriptor_header *)&as_iso_out_desc, 352 + 353 + (struct usb_descriptor_header *)&as_in_interface_alt_0_desc, 354 + (struct usb_descriptor_header *)&as_in_interface_alt_1_desc, 355 + (struct usb_descriptor_header *)&as_in_header_desc, 356 + 357 + (struct usb_descriptor_header *)&as_in_type_i_desc, 358 + 359 + //(struct usb_descriptor_header *)&as_in_ep_desc, 360 + (struct usb_descriptor_header *)&ss_as_in_ep_desc, 361 + (struct usb_descriptor_header *)&ss_as_in_ep_desc_comp, 362 + (struct usb_descriptor_header *)&as_iso_in_desc, 363 + NULL, 364 + }; 365 + 295 366 enum { 296 367 STR_AC_IF, 297 368 STR_USB_OUT_IT, ··· 1423 1352 ep = usb_ep_autoconfig(cdev->gadget, &as_out_ep_desc); 1424 1353 if (!ep) 1425 1354 goto err_free_fu; 1355 + ss_as_out_ep_desc.bEndpointAddress = as_out_ep_desc.bEndpointAddress; 1426 1356 audio->out_ep = ep; 1427 1357 audio->out_ep->desc = &as_out_ep_desc; 1428 1358 } ··· 1432 1360 ep = usb_ep_autoconfig(cdev->gadget, &as_in_ep_desc); 1433 1361 if (!ep) 1434 1362 goto err_free_fu; 1363 + ss_as_in_ep_desc.bEndpointAddress = as_in_ep_desc.bEndpointAddress; 1435 1364 audio->in_ep = ep; 1436 1365 audio->in_ep->desc = &as_in_ep_desc; 1437 1366 } ··· 1440 1367 setup_descriptor(audio_opts); 1441 1368 1442 1369 /* copy descriptors, and track endpoint copies */ 1443 - status = usb_assign_descriptors(f, f_audio_desc, f_audio_desc, NULL, 1444 - NULL); 1370 + status = usb_assign_descriptors(f, f_audio_desc, f_audio_desc, f_audio_ss_desc, 1371 + f_audio_ss_desc); 1445 1372 if (status) 1446 1373 goto err_free_fu; 1447 1374 ··· 1634 1561 int result; \ 1635 1562 \ 1636 1563 mutex_lock(&opts->lock); \ 1637 - result = snprintf(page, sizeof(opts->name), "%s", opts->name); \ 1564 + result = scnprintf(page, sizeof(opts->name), "%s", opts->name); \ 1638 1565 mutex_unlock(&opts->lock); \ 1639 1566 \ 1640 1567 return result; \ ··· 1652 1579 goto end; \ 1653 1580 } \ 1654 1581 \ 1655 - ret = snprintf(opts->name, min(sizeof(opts->name), len), \ 1582 + ret = scnprintf(opts->name, min(sizeof(opts->name), len), \ 1656 1583 "%s", page); \ 1657 1584 \ 1658 1585 end: \ ··· 1758 1685 1759 1686 opts->req_number = UAC1_DEF_REQ_NUM; 1760 1687 1761 - snprintf(opts->function_name, sizeof(opts->function_name), "AC Interface"); 1688 + scnprintf(opts->function_name, sizeof(opts->function_name), "AC Interface"); 1762 1689 1763 1690 return &opts->func_inst; 1764 1691 }
+3 -3
drivers/usb/gadget/function/f_uac2.c
··· 2045 2045 int result; \ 2046 2046 \ 2047 2047 mutex_lock(&opts->lock); \ 2048 - result = snprintf(page, sizeof(opts->name), "%s", opts->name); \ 2048 + result = scnprintf(page, sizeof(opts->name), "%s", opts->name); \ 2049 2049 mutex_unlock(&opts->lock); \ 2050 2050 \ 2051 2051 return result; \ ··· 2063 2063 goto end; \ 2064 2064 } \ 2065 2065 \ 2066 - ret = snprintf(opts->name, min(sizeof(opts->name), len), \ 2066 + ret = scnprintf(opts->name, min(sizeof(opts->name), len), \ 2067 2067 "%s", page); \ 2068 2068 \ 2069 2069 end: \ ··· 2187 2187 opts->req_number = UAC2_DEF_REQ_NUM; 2188 2188 opts->fb_max = FBACK_FAST_MAX; 2189 2189 2190 - snprintf(opts->function_name, sizeof(opts->function_name), "Source/Sink"); 2190 + scnprintf(opts->function_name, sizeof(opts->function_name), "Source/Sink"); 2191 2191 2192 2192 opts->p_terminal_type = UAC2_DEF_P_TERM_TYPE; 2193 2193 opts->c_terminal_type = UAC2_DEF_C_TERM_TYPE;
+44 -24
drivers/usb/gadget/function/f_uvc.c
··· 263 263 return 0; 264 264 } 265 265 266 - void uvc_function_setup_continue(struct uvc_device *uvc) 266 + void uvc_function_setup_continue(struct uvc_device *uvc, int disable_ep) 267 267 { 268 268 struct usb_composite_dev *cdev = uvc->func.config->cdev; 269 + 270 + if (disable_ep && uvc->video.ep) 271 + usb_ep_disable(uvc->video.ep); 269 272 270 273 usb_composite_setup_continue(cdev); 271 274 } ··· 340 337 if (uvc->state != UVC_STATE_STREAMING) 341 338 return 0; 342 339 343 - if (uvc->video.ep) 344 - usb_ep_disable(uvc->video.ep); 345 - 346 340 memset(&v4l2_event, 0, sizeof(v4l2_event)); 347 341 v4l2_event.type = UVC_EVENT_STREAMOFF; 348 342 v4l2_event_queue(&uvc->vdev, &v4l2_event); 349 343 350 - uvc->state = UVC_STATE_CONNECTED; 351 - return 0; 344 + return USB_GADGET_DELAYED_STATUS; 352 345 353 346 case 1: 354 347 if (uvc->state != UVC_STATE_CONNECTED) ··· 721 722 } 722 723 uvc->enable_interrupt_ep = opts->enable_interrupt_ep; 723 724 724 - ep = usb_ep_autoconfig(cdev->gadget, &uvc_fs_streaming_ep); 725 + /* 726 + * gadget_is_{super|dual}speed() API check UDC controller capitblity. It should pass down 727 + * highest speed endpoint descriptor to UDC controller. So UDC controller driver can reserve 728 + * enough resource at check_config(), especially mult and maxburst. So UDC driver (such as 729 + * cdns3) can know need at least (mult + 1) * (maxburst + 1) * wMaxPacketSize internal 730 + * memory for this uvc functions. This is the only straightforward method to resolve the UDC 731 + * resource allocation issue in the current gadget framework. 732 + */ 733 + if (gadget_is_superspeed(c->cdev->gadget)) 734 + ep = usb_ep_autoconfig_ss(cdev->gadget, &uvc_ss_streaming_ep, 735 + &uvc_ss_streaming_comp); 736 + else if (gadget_is_dualspeed(cdev->gadget)) 737 + ep = usb_ep_autoconfig(cdev->gadget, &uvc_hs_streaming_ep); 738 + else 739 + ep = usb_ep_autoconfig(cdev->gadget, &uvc_fs_streaming_ep); 740 + 725 741 if (!ep) { 726 742 uvcg_info(f, "Unable to allocate streaming EP\n"); 727 743 goto error; 728 744 } 729 745 uvc->video.ep = ep; 730 746 747 + uvc_fs_streaming_ep.bEndpointAddress = uvc->video.ep->address; 731 748 uvc_hs_streaming_ep.bEndpointAddress = uvc->video.ep->address; 732 749 uvc_ss_streaming_ep.bEndpointAddress = uvc->video.ep->address; 733 750 ··· 975 960 struct uvc_device *uvc = to_uvc(f); 976 961 struct f_uvc_opts *opts = container_of(f->fi, struct f_uvc_opts, 977 962 func_inst); 978 - config_item_put(&uvc->header->item); 963 + if (!opts->header) 964 + config_item_put(&uvc->header->item); 979 965 --opts->refcnt; 980 966 kfree(uvc); 981 967 } ··· 1068 1052 uvc->desc.hs_streaming = opts->hs_streaming; 1069 1053 uvc->desc.ss_streaming = opts->ss_streaming; 1070 1054 1071 - streaming = config_group_find_item(&opts->func_inst.group, "streaming"); 1072 - if (!streaming) 1073 - goto err_config; 1055 + if (opts->header) { 1056 + uvc->header = opts->header; 1057 + } else { 1058 + streaming = config_group_find_item(&opts->func_inst.group, "streaming"); 1059 + if (!streaming) 1060 + goto err_config; 1074 1061 1075 - header = config_group_find_item(to_config_group(streaming), "header"); 1076 - config_item_put(streaming); 1077 - if (!header) 1078 - goto err_config; 1062 + header = config_group_find_item(to_config_group(streaming), "header"); 1063 + config_item_put(streaming); 1064 + if (!header) 1065 + goto err_config; 1079 1066 1080 - h = config_group_find_item(to_config_group(header), "h"); 1081 - config_item_put(header); 1082 - if (!h) 1083 - goto err_config; 1067 + h = config_group_find_item(to_config_group(header), "h"); 1068 + config_item_put(header); 1069 + if (!h) 1070 + goto err_config; 1084 1071 1085 - uvc->header = to_uvcg_streaming_header(h); 1086 - if (!uvc->header->linked) { 1087 - mutex_unlock(&opts->lock); 1088 - kfree(uvc); 1089 - return ERR_PTR(-EBUSY); 1072 + uvc->header = to_uvcg_streaming_header(h); 1073 + if (!uvc->header->linked) { 1074 + mutex_unlock(&opts->lock); 1075 + kfree(uvc); 1076 + return ERR_PTR(-EBUSY); 1077 + } 1090 1078 } 1091 1079 1092 1080 uvc->desc.extension_units = &opts->extension_units;
+1 -1
drivers/usb/gadget/function/f_uvc.h
··· 11 11 12 12 struct uvc_device; 13 13 14 - void uvc_function_setup_continue(struct uvc_device *uvc); 14 + void uvc_function_setup_continue(struct uvc_device *uvc, int disable_ep); 15 15 16 16 void uvc_function_connect(struct uvc_device *uvc); 17 17
+2
drivers/usb/gadget/function/u_ether.c
··· 1163 1163 if (netif_running(dev->net)) 1164 1164 eth_start(dev, GFP_ATOMIC); 1165 1165 1166 + netif_device_attach(dev->net); 1167 + 1166 1168 /* on error, disable any endpoints */ 1167 1169 } else { 1168 1170 (void) usb_ep_disable(link->out_ep);
+2
drivers/usb/gadget/function/u_ncm.h
··· 31 31 */ 32 32 struct mutex lock; 33 33 int refcnt; 34 + 35 + u16 max_segment_size; 34 36 }; 35 37 36 38 #endif /* U_NCM_H */
+6
drivers/usb/gadget/function/u_uvc.h
··· 98 98 */ 99 99 struct mutex lock; 100 100 int refcnt; 101 + 102 + /* 103 + * Only for legacy gadget. Shall be NULL for configfs-composed gadgets, 104 + * which is guaranteed by alloc_inst implementation of f_uvc doing kzalloc. 105 + */ 106 + struct uvcg_streaming_header *header; 101 107 }; 102 108 103 109 #endif /* U_UVC_H */
+12 -2
drivers/usb/gadget/function/uvc.h
··· 81 81 struct sg_table sgt; 82 82 u8 header[UVCG_REQUEST_HEADER_LEN]; 83 83 struct uvc_buffer *last_buf; 84 + struct list_head list; 84 85 }; 85 86 86 87 struct uvc_video { ··· 102 101 unsigned int uvc_num_requests; 103 102 104 103 /* Requests */ 104 + bool is_enabled; /* tracks whether video stream is enabled */ 105 105 unsigned int req_size; 106 - struct uvc_request *ureq; 106 + struct list_head ureqs; /* all uvc_requests allocated by uvc_video */ 107 + 108 + /* USB requests that the video pump thread can encode into */ 107 109 struct list_head req_free; 110 + 111 + /* 112 + * USB requests video pump thread has already encoded into. These are 113 + * ready to be queued to the endpoint. 114 + */ 115 + struct list_head req_ready; 108 116 spinlock_t req_lock; 109 117 110 118 unsigned int req_int_count; ··· 187 177 * Functions 188 178 */ 189 179 190 - extern void uvc_function_setup_continue(struct uvc_device *uvc); 180 + extern void uvc_function_setup_continue(struct uvc_device *uvc, int disable_ep); 191 181 extern void uvc_function_connect(struct uvc_device *uvc); 192 182 extern void uvc_function_disconnect(struct uvc_device *uvc); 193 183
+1 -1
drivers/usb/gadget/function/uvc_configfs.c
··· 3414 3414 int result; \ 3415 3415 \ 3416 3416 mutex_lock(&opts->lock); \ 3417 - result = snprintf(page, sizeof(opts->aname), "%s", opts->aname);\ 3417 + result = scnprintf(page, sizeof(opts->aname), "%s", opts->aname);\ 3418 3418 mutex_unlock(&opts->lock); \ 3419 3419 \ 3420 3420 return result; \
+11 -5
drivers/usb/gadget/function/uvc_v4l2.c
··· 443 443 return -EINVAL; 444 444 445 445 /* Enable UVC video. */ 446 - ret = uvcg_video_enable(video, 1); 446 + ret = uvcg_video_enable(video); 447 447 if (ret < 0) 448 448 return ret; 449 449 ··· 451 451 * Complete the alternate setting selection setup phase now that 452 452 * userspace is ready to provide video frames. 453 453 */ 454 - uvc_function_setup_continue(uvc); 454 + uvc_function_setup_continue(uvc, 0); 455 455 uvc->state = UVC_STATE_STREAMING; 456 456 457 457 return 0; ··· 463 463 struct video_device *vdev = video_devdata(file); 464 464 struct uvc_device *uvc = video_get_drvdata(vdev); 465 465 struct uvc_video *video = &uvc->video; 466 + int ret = 0; 466 467 467 468 if (type != video->queue.queue.type) 468 469 return -EINVAL; 469 470 470 - return uvcg_video_enable(video, 0); 471 + ret = uvcg_video_disable(video); 472 + if (ret < 0) 473 + return ret; 474 + 475 + uvc->state = UVC_STATE_CONNECTED; 476 + uvc_function_setup_continue(uvc, 1); 477 + return 0; 471 478 } 472 479 473 480 static int ··· 507 500 static void uvc_v4l2_disable(struct uvc_device *uvc) 508 501 { 509 502 uvc_function_disconnect(uvc); 510 - uvcg_video_enable(&uvc->video, 0); 503 + uvcg_video_disable(&uvc->video); 511 504 uvcg_free_buffers(&uvc->video.queue); 512 505 uvc->func_connected = false; 513 506 wake_up_interruptible(&uvc->func_connected_queue); ··· 654 647 .get_unmapped_area = uvcg_v4l2_get_unmapped_area, 655 648 #endif 656 649 }; 657 -
+341 -108
drivers/usb/gadget/function/uvc_video.c
··· 227 227 * Request handling 228 228 */ 229 229 230 + /* 231 + * Callers must take care to hold req_lock when this function may be called 232 + * from multiple threads. For example, when frames are streaming to the host. 233 + */ 234 + static void 235 + uvc_video_free_request(struct uvc_request *ureq, struct usb_ep *ep) 236 + { 237 + sg_free_table(&ureq->sgt); 238 + if (ureq->req && ep) { 239 + usb_ep_free_request(ep, ureq->req); 240 + ureq->req = NULL; 241 + } 242 + 243 + kfree(ureq->req_buffer); 244 + ureq->req_buffer = NULL; 245 + 246 + if (!list_empty(&ureq->list)) 247 + list_del_init(&ureq->list); 248 + 249 + kfree(ureq); 250 + } 251 + 230 252 static int uvcg_video_ep_queue(struct uvc_video *video, struct usb_request *req) 231 253 { 232 254 int ret; ··· 269 247 return ret; 270 248 } 271 249 250 + /* This function must be called with video->req_lock held. */ 251 + static int uvcg_video_usb_req_queue(struct uvc_video *video, 252 + struct usb_request *req, bool queue_to_ep) 253 + { 254 + bool is_bulk = video->max_payload_size; 255 + struct list_head *list = NULL; 256 + 257 + if (!video->is_enabled) 258 + return -ENODEV; 259 + 260 + if (queue_to_ep) { 261 + struct uvc_request *ureq = req->context; 262 + /* 263 + * With USB3 handling more requests at a higher speed, we can't 264 + * afford to generate an interrupt for every request. Decide to 265 + * interrupt: 266 + * 267 + * - When no more requests are available in the free queue, as 268 + * this may be our last chance to refill the endpoint's 269 + * request queue. 270 + * 271 + * - When this is request is the last request for the video 272 + * buffer, as we want to start sending the next video buffer 273 + * ASAP in case it doesn't get started already in the next 274 + * iteration of this loop. 275 + * 276 + * - Four times over the length of the requests queue (as 277 + * indicated by video->uvc_num_requests), as a trade-off 278 + * between latency and interrupt load. 279 + */ 280 + if (list_empty(&video->req_free) || ureq->last_buf || 281 + !(video->req_int_count % 282 + DIV_ROUND_UP(video->uvc_num_requests, 4))) { 283 + video->req_int_count = 0; 284 + req->no_interrupt = 0; 285 + } else { 286 + req->no_interrupt = 1; 287 + } 288 + video->req_int_count++; 289 + return uvcg_video_ep_queue(video, req); 290 + } 291 + /* 292 + * If we're not queuing to the ep, for isoc we're queuing 293 + * to the req_ready list, otherwise req_free. 294 + */ 295 + list = is_bulk ? &video->req_free : &video->req_ready; 296 + list_add_tail(&req->list, list); 297 + return 0; 298 + } 299 + 300 + /* 301 + * Must only be called from uvcg_video_enable - since after that we only want to 302 + * queue requests to the endpoint from the uvc_video_complete complete handler. 303 + * This function is needed in order to 'kick start' the flow of requests from 304 + * gadget driver to the usb controller. 305 + */ 306 + static void uvc_video_ep_queue_initial_requests(struct uvc_video *video) 307 + { 308 + struct usb_request *req = NULL; 309 + unsigned long flags = 0; 310 + unsigned int count = 0; 311 + int ret = 0; 312 + 313 + /* 314 + * We only queue half of the free list since we still want to have 315 + * some free usb_requests in the free list for the video_pump async_wq 316 + * thread to encode uvc buffers into. Otherwise we could get into a 317 + * situation where the free list does not have any usb requests to 318 + * encode into - we always end up queueing 0 length requests to the 319 + * end point. 320 + */ 321 + unsigned int half_list_size = video->uvc_num_requests / 2; 322 + 323 + spin_lock_irqsave(&video->req_lock, flags); 324 + /* 325 + * Take these requests off the free list and queue them all to the 326 + * endpoint. Since we queue 0 length requests with the req_lock held, 327 + * there isn't any 'data' race involved here with the complete handler. 328 + */ 329 + while (count < half_list_size) { 330 + req = list_first_entry(&video->req_free, struct usb_request, 331 + list); 332 + list_del(&req->list); 333 + req->length = 0; 334 + ret = uvcg_video_ep_queue(video, req); 335 + if (ret < 0) { 336 + uvcg_queue_cancel(&video->queue, 0); 337 + break; 338 + } 339 + count++; 340 + } 341 + spin_unlock_irqrestore(&video->req_lock, flags); 342 + } 343 + 272 344 static void 273 345 uvc_video_complete(struct usb_ep *ep, struct usb_request *req) 274 346 { 275 347 struct uvc_request *ureq = req->context; 276 348 struct uvc_video *video = ureq->video; 277 349 struct uvc_video_queue *queue = &video->queue; 278 - struct uvc_device *uvc = video->uvc; 350 + struct uvc_buffer *last_buf; 279 351 unsigned long flags; 352 + bool is_bulk = video->max_payload_size; 353 + int ret = 0; 354 + 355 + spin_lock_irqsave(&video->req_lock, flags); 356 + if (!video->is_enabled) { 357 + /* 358 + * When is_enabled is false, uvcg_video_disable() ensures 359 + * that in-flight uvc_buffers are returned, so we can 360 + * safely call free_request without worrying about 361 + * last_buf. 362 + */ 363 + uvc_video_free_request(ureq, ep); 364 + spin_unlock_irqrestore(&video->req_lock, flags); 365 + return; 366 + } 367 + 368 + last_buf = ureq->last_buf; 369 + ureq->last_buf = NULL; 370 + spin_unlock_irqrestore(&video->req_lock, flags); 280 371 281 372 switch (req->status) { 282 373 case 0: ··· 412 277 uvcg_queue_cancel(queue, 0); 413 278 } 414 279 415 - if (ureq->last_buf) { 416 - uvcg_complete_buffer(&video->queue, ureq->last_buf); 417 - ureq->last_buf = NULL; 280 + if (last_buf) { 281 + spin_lock_irqsave(&queue->irqlock, flags); 282 + uvcg_complete_buffer(queue, last_buf); 283 + spin_unlock_irqrestore(&queue->irqlock, flags); 418 284 } 419 285 420 286 spin_lock_irqsave(&video->req_lock, flags); 421 - list_add_tail(&req->list, &video->req_free); 422 - spin_unlock_irqrestore(&video->req_lock, flags); 287 + /* 288 + * Video stream might have been disabled while we were 289 + * processing the current usb_request. So make sure 290 + * we're still streaming before queueing the usb_request 291 + * back to req_free 292 + */ 293 + if (video->is_enabled) { 294 + /* 295 + * Here we check whether any request is available in the ready 296 + * list. If it is, queue it to the ep and add the current 297 + * usb_request to the req_free list - for video_pump to fill in. 298 + * Otherwise, just use the current usb_request to queue a 0 299 + * length request to the ep. Since we always add to the req_free 300 + * list if we dequeue from the ready list, there will never 301 + * be a situation where the req_free list is completely out of 302 + * requests and cannot recover. 303 + */ 304 + struct usb_request *to_queue = req; 423 305 424 - if (uvc->state == UVC_STATE_STREAMING) 425 - queue_work(video->async_wq, &video->pump); 306 + to_queue->length = 0; 307 + if (!list_empty(&video->req_ready)) { 308 + to_queue = list_first_entry(&video->req_ready, 309 + struct usb_request, list); 310 + list_del(&to_queue->list); 311 + list_add_tail(&req->list, &video->req_free); 312 + /* 313 + * Queue work to the wq as well since it is possible that a 314 + * buffer may not have been completely encoded with the set of 315 + * in-flight usb requests for whih the complete callbacks are 316 + * firing. 317 + * In that case, if we do not queue work to the worker thread, 318 + * the buffer will never be marked as complete - and therefore 319 + * not be returned to userpsace. As a result, 320 + * dequeue -> queue -> dequeue flow of uvc buffers will not 321 + * happen. 322 + */ 323 + queue_work(video->async_wq, &video->pump); 324 + } 325 + /* 326 + * Queue to the endpoint. The actual queueing to ep will 327 + * only happen on one thread - the async_wq for bulk endpoints 328 + * and this thread for isoc endpoints. 329 + */ 330 + ret = uvcg_video_usb_req_queue(video, to_queue, !is_bulk); 331 + if (ret < 0) { 332 + /* 333 + * Endpoint error, but the stream is still enabled. 334 + * Put request back in req_free for it to be cleaned 335 + * up later. 336 + */ 337 + list_add_tail(&to_queue->list, &video->req_free); 338 + } 339 + } else { 340 + uvc_video_free_request(ureq, ep); 341 + ret = 0; 342 + } 343 + spin_unlock_irqrestore(&video->req_lock, flags); 344 + if (ret < 0) 345 + uvcg_queue_cancel(queue, 0); 426 346 } 427 347 428 348 static int 429 349 uvc_video_free_requests(struct uvc_video *video) 430 350 { 431 - unsigned int i; 351 + struct uvc_request *ureq, *temp; 432 352 433 - if (video->ureq) { 434 - for (i = 0; i < video->uvc_num_requests; ++i) { 435 - sg_free_table(&video->ureq[i].sgt); 353 + list_for_each_entry_safe(ureq, temp, &video->ureqs, list) 354 + uvc_video_free_request(ureq, video->ep); 436 355 437 - if (video->ureq[i].req) { 438 - usb_ep_free_request(video->ep, video->ureq[i].req); 439 - video->ureq[i].req = NULL; 440 - } 441 - 442 - if (video->ureq[i].req_buffer) { 443 - kfree(video->ureq[i].req_buffer); 444 - video->ureq[i].req_buffer = NULL; 445 - } 446 - } 447 - 448 - kfree(video->ureq); 449 - video->ureq = NULL; 450 - } 451 - 356 + INIT_LIST_HEAD(&video->ureqs); 452 357 INIT_LIST_HEAD(&video->req_free); 358 + INIT_LIST_HEAD(&video->req_ready); 453 359 video->req_size = 0; 454 360 return 0; 455 361 } ··· 498 322 static int 499 323 uvc_video_alloc_requests(struct uvc_video *video) 500 324 { 325 + struct uvc_request *ureq; 501 326 unsigned int req_size; 502 327 unsigned int i; 503 328 int ret = -ENOMEM; ··· 509 332 * max_t(unsigned int, video->ep->maxburst, 1) 510 333 * (video->ep->mult); 511 334 512 - video->ureq = kcalloc(video->uvc_num_requests, sizeof(struct uvc_request), GFP_KERNEL); 513 - if (video->ureq == NULL) 514 - return -ENOMEM; 515 - 516 - for (i = 0; i < video->uvc_num_requests; ++i) { 517 - video->ureq[i].req_buffer = kmalloc(req_size, GFP_KERNEL); 518 - if (video->ureq[i].req_buffer == NULL) 335 + for (i = 0; i < video->uvc_num_requests; i++) { 336 + ureq = kzalloc(sizeof(struct uvc_request), GFP_KERNEL); 337 + if (ureq == NULL) 519 338 goto error; 520 339 521 - video->ureq[i].req = usb_ep_alloc_request(video->ep, GFP_KERNEL); 522 - if (video->ureq[i].req == NULL) 340 + INIT_LIST_HEAD(&ureq->list); 341 + 342 + list_add_tail(&ureq->list, &video->ureqs); 343 + 344 + ureq->req_buffer = kmalloc(req_size, GFP_KERNEL); 345 + if (ureq->req_buffer == NULL) 523 346 goto error; 524 347 525 - video->ureq[i].req->buf = video->ureq[i].req_buffer; 526 - video->ureq[i].req->length = 0; 527 - video->ureq[i].req->complete = uvc_video_complete; 528 - video->ureq[i].req->context = &video->ureq[i]; 529 - video->ureq[i].video = video; 530 - video->ureq[i].last_buf = NULL; 348 + ureq->req = usb_ep_alloc_request(video->ep, GFP_KERNEL); 349 + if (ureq->req == NULL) 350 + goto error; 531 351 532 - list_add_tail(&video->ureq[i].req->list, &video->req_free); 352 + ureq->req->buf = ureq->req_buffer; 353 + ureq->req->length = 0; 354 + ureq->req->complete = uvc_video_complete; 355 + ureq->req->context = ureq; 356 + ureq->video = video; 357 + ureq->last_buf = NULL; 358 + 359 + list_add_tail(&ureq->req->list, &video->req_free); 533 360 /* req_size/PAGE_SIZE + 1 for overruns and + 1 for header */ 534 - sg_alloc_table(&video->ureq[i].sgt, 361 + sg_alloc_table(&ureq->sgt, 535 362 DIV_ROUND_UP(req_size - UVCG_REQUEST_HEADER_LEN, 536 363 PAGE_SIZE) + 2, GFP_KERNEL); 537 364 } ··· 568 387 struct usb_request *req = NULL; 569 388 struct uvc_buffer *buf; 570 389 unsigned long flags; 571 - bool buf_done; 572 - int ret; 390 + int ret = 0; 573 391 574 - while (video->ep->enabled) { 392 + while (true) { 393 + if (!video->ep->enabled) 394 + return; 395 + 575 396 /* 576 - * Retrieve the first available USB request, protected by the 577 - * request lock. 397 + * Check is_enabled and retrieve the first available USB 398 + * request, protected by the request lock. 578 399 */ 579 400 spin_lock_irqsave(&video->req_lock, flags); 580 - if (list_empty(&video->req_free)) { 401 + if (!video->is_enabled || list_empty(&video->req_free)) { 581 402 spin_unlock_irqrestore(&video->req_lock, flags); 582 403 return; 583 404 } ··· 597 414 598 415 if (buf != NULL) { 599 416 video->encode(req, video, buf); 600 - buf_done = buf->state == UVC_BUF_STATE_DONE; 601 - } else if (!(queue->flags & UVC_QUEUE_DISCONNECTED) && !is_bulk) { 602 - /* 603 - * No video buffer available; the queue is still connected and 604 - * we're transferring over ISOC. Queue a 0 length request to 605 - * prevent missed ISOC transfers. 606 - */ 607 - req->length = 0; 608 - buf_done = false; 609 417 } else { 610 418 /* 611 419 * Either the queue has been disconnected or no video buffer ··· 607 433 break; 608 434 } 609 435 610 - /* 611 - * With USB3 handling more requests at a higher speed, we can't 612 - * afford to generate an interrupt for every request. Decide to 613 - * interrupt: 614 - * 615 - * - When no more requests are available in the free queue, as 616 - * this may be our last chance to refill the endpoint's 617 - * request queue. 618 - * 619 - * - When this is request is the last request for the video 620 - * buffer, as we want to start sending the next video buffer 621 - * ASAP in case it doesn't get started already in the next 622 - * iteration of this loop. 623 - * 624 - * - Four times over the length of the requests queue (as 625 - * indicated by video->uvc_num_requests), as a trade-off 626 - * between latency and interrupt load. 627 - */ 628 - if (list_empty(&video->req_free) || buf_done || 629 - !(video->req_int_count % 630 - DIV_ROUND_UP(video->uvc_num_requests, 4))) { 631 - video->req_int_count = 0; 632 - req->no_interrupt = 0; 633 - } else { 634 - req->no_interrupt = 1; 635 - } 636 - 637 - /* Queue the USB request */ 638 - ret = uvcg_video_ep_queue(video, req); 639 436 spin_unlock_irqrestore(&queue->irqlock, flags); 437 + 438 + spin_lock_irqsave(&video->req_lock, flags); 439 + /* For bulk end points we queue from the worker thread 440 + * since we would preferably not want to wait on requests 441 + * to be ready, in the uvcg_video_complete() handler. 442 + * For isoc endpoints we add the request to the ready list 443 + * and only queue it to the endpoint from the complete handler. 444 + */ 445 + ret = uvcg_video_usb_req_queue(video, req, is_bulk); 446 + spin_unlock_irqrestore(&video->req_lock, flags); 640 447 641 448 if (ret < 0) { 642 449 uvcg_queue_cancel(queue, 0); 643 450 break; 644 451 } 645 452 646 - /* Endpoint now owns the request */ 453 + /* The request is owned by the endpoint / ready list. */ 647 454 req = NULL; 648 - video->req_int_count++; 649 455 } 650 456 651 457 if (!req) 652 458 return; 653 459 654 460 spin_lock_irqsave(&video->req_lock, flags); 655 - list_add_tail(&req->list, &video->req_free); 461 + if (video->is_enabled) 462 + list_add_tail(&req->list, &video->req_free); 463 + else 464 + uvc_video_free_request(req->context, video->ep); 656 465 spin_unlock_irqrestore(&video->req_lock, flags); 657 - return; 658 466 } 659 467 660 468 /* 661 - * Enable or disable the video stream. 469 + * Disable the video stream 662 470 */ 663 - int uvcg_video_enable(struct uvc_video *video, int enable) 471 + int 472 + uvcg_video_disable(struct uvc_video *video) 664 473 { 665 - unsigned int i; 474 + unsigned long flags; 475 + struct list_head inflight_bufs; 476 + struct usb_request *req, *temp; 477 + struct uvc_buffer *buf, *btemp; 478 + struct uvc_request *ureq, *utemp; 479 + 480 + if (video->ep == NULL) { 481 + uvcg_info(&video->uvc->func, 482 + "Video disable failed, device is uninitialized.\n"); 483 + return -ENODEV; 484 + } 485 + 486 + INIT_LIST_HEAD(&inflight_bufs); 487 + spin_lock_irqsave(&video->req_lock, flags); 488 + video->is_enabled = false; 489 + 490 + /* 491 + * Remove any in-flight buffers from the uvc_requests 492 + * because we want to return them before cancelling the 493 + * queue. This ensures that we aren't stuck waiting for 494 + * all complete callbacks to come through before disabling 495 + * vb2 queue. 496 + */ 497 + list_for_each_entry(ureq, &video->ureqs, list) { 498 + if (ureq->last_buf) { 499 + list_add_tail(&ureq->last_buf->queue, &inflight_bufs); 500 + ureq->last_buf = NULL; 501 + } 502 + } 503 + spin_unlock_irqrestore(&video->req_lock, flags); 504 + 505 + cancel_work_sync(&video->pump); 506 + uvcg_queue_cancel(&video->queue, 0); 507 + 508 + spin_lock_irqsave(&video->req_lock, flags); 509 + /* 510 + * Remove all uvc_requests from ureqs with list_del_init 511 + * This lets uvc_video_free_request correctly identify 512 + * if the uvc_request is attached to a list or not when freeing 513 + * memory. 514 + */ 515 + list_for_each_entry_safe(ureq, utemp, &video->ureqs, list) 516 + list_del_init(&ureq->list); 517 + 518 + list_for_each_entry_safe(req, temp, &video->req_free, list) { 519 + list_del(&req->list); 520 + uvc_video_free_request(req->context, video->ep); 521 + } 522 + 523 + list_for_each_entry_safe(req, temp, &video->req_ready, list) { 524 + list_del(&req->list); 525 + uvc_video_free_request(req->context, video->ep); 526 + } 527 + 528 + INIT_LIST_HEAD(&video->ureqs); 529 + INIT_LIST_HEAD(&video->req_free); 530 + INIT_LIST_HEAD(&video->req_ready); 531 + video->req_size = 0; 532 + spin_unlock_irqrestore(&video->req_lock, flags); 533 + 534 + /* 535 + * Return all the video buffers before disabling the queue. 536 + */ 537 + spin_lock_irqsave(&video->queue.irqlock, flags); 538 + list_for_each_entry_safe(buf, btemp, &inflight_bufs, queue) { 539 + list_del(&buf->queue); 540 + uvcg_complete_buffer(&video->queue, buf); 541 + } 542 + spin_unlock_irqrestore(&video->queue.irqlock, flags); 543 + 544 + uvcg_queue_enable(&video->queue, 0); 545 + return 0; 546 + } 547 + 548 + /* 549 + * Enable the video stream. 550 + */ 551 + int uvcg_video_enable(struct uvc_video *video) 552 + { 666 553 int ret; 667 554 668 555 if (video->ep == NULL) { ··· 732 497 return -ENODEV; 733 498 } 734 499 735 - if (!enable) { 736 - cancel_work_sync(&video->pump); 737 - uvcg_queue_cancel(&video->queue, 0); 738 - 739 - for (i = 0; i < video->uvc_num_requests; ++i) 740 - if (video->ureq && video->ureq[i].req) 741 - usb_ep_dequeue(video->ep, video->ureq[i].req); 742 - 743 - uvc_video_free_requests(video); 744 - uvcg_queue_enable(&video->queue, 0); 745 - return 0; 746 - } 500 + /* 501 + * Safe to access request related fields without req_lock because 502 + * this is the only thread currently active, and no other 503 + * request handling thread will become active until this function 504 + * returns. 505 + */ 506 + video->is_enabled = true; 747 507 748 508 if ((ret = uvcg_queue_enable(&video->queue, 1)) < 0) 749 509 return ret; ··· 755 525 756 526 video->req_int_count = 0; 757 527 758 - queue_work(video->async_wq, &video->pump); 528 + uvc_video_ep_queue_initial_requests(video); 759 529 760 530 return ret; 761 531 } ··· 765 535 */ 766 536 int uvcg_video_init(struct uvc_video *video, struct uvc_device *uvc) 767 537 { 538 + video->is_enabled = false; 539 + INIT_LIST_HEAD(&video->ureqs); 768 540 INIT_LIST_HEAD(&video->req_free); 541 + INIT_LIST_HEAD(&video->req_ready); 769 542 spin_lock_init(&video->req_lock); 770 543 INIT_WORK(&video->pump, uvcg_video_pump); 771 544
+2 -1
drivers/usb/gadget/function/uvc_video.h
··· 14 14 15 15 struct uvc_video; 16 16 17 - int uvcg_video_enable(struct uvc_video *video, int enable); 17 + int uvcg_video_enable(struct uvc_video *video); 18 + int uvcg_video_disable(struct uvc_video *video); 18 19 19 20 int uvcg_video_init(struct uvc_video *video, struct uvc_device *uvc); 20 21
+253 -80
drivers/usb/gadget/legacy/webcam.c
··· 12 12 #include <linux/usb/video.h> 13 13 14 14 #include "u_uvc.h" 15 + #include "uvc_configfs.h" 15 16 16 17 USB_GADGET_COMPOSITE_OPTIONS(); 17 18 ··· 84 83 .iSerialNumber = 0, /* dynamic */ 85 84 .bNumConfigurations = 0, /* dynamic */ 86 85 }; 87 - 88 - DECLARE_UVC_HEADER_DESCRIPTOR(1); 89 86 90 87 static const struct UVC_HEADER_DESCRIPTOR(1) uvc_control_header = { 91 88 .bLength = UVC_DT_HEADER_SIZE(1), ··· 157 158 .bmaControls[1][0] = 4, 158 159 }; 159 160 160 - static const struct uvc_format_uncompressed uvc_format_yuv = { 161 - .bLength = UVC_DT_FORMAT_UNCOMPRESSED_SIZE, 162 - .bDescriptorType = USB_DT_CS_INTERFACE, 163 - .bDescriptorSubType = UVC_VS_FORMAT_UNCOMPRESSED, 164 - .bFormatIndex = 1, 165 - .bNumFrameDescriptors = 2, 166 - .guidFormat = 167 - { 'Y', 'U', 'Y', '2', 0x00, 0x00, 0x10, 0x00, 168 - 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}, 169 - .bBitsPerPixel = 16, 170 - .bDefaultFrameIndex = 1, 171 - .bAspectRatioX = 0, 172 - .bAspectRatioY = 0, 173 - .bmInterlaceFlags = 0, 174 - .bCopyProtect = 0, 161 + static const struct uvcg_color_matching uvcg_color_matching = { 162 + .desc = { 163 + .bLength = UVC_DT_COLOR_MATCHING_SIZE, 164 + .bDescriptorType = USB_DT_CS_INTERFACE, 165 + .bDescriptorSubType = UVC_VS_COLORFORMAT, 166 + .bColorPrimaries = 1, 167 + .bTransferCharacteristics = 1, 168 + .bMatrixCoefficients = 4, 169 + }, 170 + }; 171 + 172 + static struct uvcg_uncompressed uvcg_format_yuv = { 173 + .fmt = { 174 + .type = UVCG_UNCOMPRESSED, 175 + /* add to .frames and fill .num_frames at runtime */ 176 + .color_matching = (struct uvcg_color_matching *)&uvcg_color_matching, 177 + }, 178 + .desc = { 179 + .bLength = UVC_DT_FORMAT_UNCOMPRESSED_SIZE, 180 + .bDescriptorType = USB_DT_CS_INTERFACE, 181 + .bDescriptorSubType = UVC_VS_FORMAT_UNCOMPRESSED, 182 + .bFormatIndex = 1, 183 + .bNumFrameDescriptors = 2, 184 + .guidFormat = { 185 + 'Y', 'U', 'Y', '2', 0x00, 0x00, 0x10, 0x00, 186 + 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71 187 + }, 188 + .bBitsPerPixel = 16, 189 + .bDefaultFrameIndex = 1, 190 + .bAspectRatioX = 0, 191 + .bAspectRatioY = 0, 192 + .bmInterlaceFlags = 0, 193 + .bCopyProtect = 0, 194 + }, 195 + }; 196 + 197 + static struct uvcg_format_ptr uvcg_format_ptr_yuv = { 198 + .fmt = &uvcg_format_yuv.fmt, 175 199 }; 176 200 177 201 DECLARE_UVC_FRAME_UNCOMPRESSED(1); 178 202 DECLARE_UVC_FRAME_UNCOMPRESSED(3); 203 + 204 + #define UVCG_WIDTH_360P 640 205 + #define UVCG_HEIGHT_360P 360 206 + #define UVCG_MIN_BITRATE_360P 18432000 207 + #define UVCG_MAX_BITRATE_360P 55296000 208 + #define UVCG_MAX_VIDEO_FB_SZ_360P 460800 209 + #define UVCG_FRM_INTERV_0_360P 666666 210 + #define UVCG_FRM_INTERV_1_360P 1000000 211 + #define UVCG_FRM_INTERV_2_360P 5000000 212 + #define UVCG_DEFAULT_FRM_INTERV_360P UVCG_FRM_INTERV_0_360P 179 213 180 214 static const struct UVC_FRAME_UNCOMPRESSED(3) uvc_frame_yuv_360p = { 181 215 .bLength = UVC_DT_FRAME_UNCOMPRESSED_SIZE(3), ··· 216 184 .bDescriptorSubType = UVC_VS_FRAME_UNCOMPRESSED, 217 185 .bFrameIndex = 1, 218 186 .bmCapabilities = 0, 219 - .wWidth = cpu_to_le16(640), 220 - .wHeight = cpu_to_le16(360), 221 - .dwMinBitRate = cpu_to_le32(18432000), 222 - .dwMaxBitRate = cpu_to_le32(55296000), 223 - .dwMaxVideoFrameBufferSize = cpu_to_le32(460800), 224 - .dwDefaultFrameInterval = cpu_to_le32(666666), 187 + .wWidth = cpu_to_le16(UVCG_WIDTH_360P), 188 + .wHeight = cpu_to_le16(UVCG_HEIGHT_360P), 189 + .dwMinBitRate = cpu_to_le32(UVCG_MIN_BITRATE_360P), 190 + .dwMaxBitRate = cpu_to_le32(UVCG_MAX_BITRATE_360P), 191 + .dwMaxVideoFrameBufferSize = cpu_to_le32(UVCG_MAX_VIDEO_FB_SZ_360P), 192 + .dwDefaultFrameInterval = cpu_to_le32(UVCG_DEFAULT_FRM_INTERV_360P), 225 193 .bFrameIntervalType = 3, 226 - .dwFrameInterval[0] = cpu_to_le32(666666), 227 - .dwFrameInterval[1] = cpu_to_le32(1000000), 228 - .dwFrameInterval[2] = cpu_to_le32(5000000), 194 + .dwFrameInterval[0] = cpu_to_le32(UVCG_FRM_INTERV_0_360P), 195 + .dwFrameInterval[1] = cpu_to_le32(UVCG_FRM_INTERV_1_360P), 196 + .dwFrameInterval[2] = cpu_to_le32(UVCG_FRM_INTERV_2_360P), 229 197 }; 198 + 199 + static u32 uvcg_frame_yuv_360p_dw_frame_interval[] = { 200 + [0] = UVCG_FRM_INTERV_0_360P, 201 + [1] = UVCG_FRM_INTERV_1_360P, 202 + [2] = UVCG_FRM_INTERV_2_360P, 203 + }; 204 + 205 + static const struct uvcg_frame uvcg_frame_yuv_360p = { 206 + .fmt_type = UVCG_UNCOMPRESSED, 207 + .frame = { 208 + .b_length = UVC_DT_FRAME_UNCOMPRESSED_SIZE(3), 209 + .b_descriptor_type = USB_DT_CS_INTERFACE, 210 + .b_descriptor_subtype = UVC_VS_FRAME_UNCOMPRESSED, 211 + .b_frame_index = 1, 212 + .bm_capabilities = 0, 213 + .w_width = UVCG_WIDTH_360P, 214 + .w_height = UVCG_HEIGHT_360P, 215 + .dw_min_bit_rate = UVCG_MIN_BITRATE_360P, 216 + .dw_max_bit_rate = UVCG_MAX_BITRATE_360P, 217 + .dw_max_video_frame_buffer_size = UVCG_MAX_VIDEO_FB_SZ_360P, 218 + .dw_default_frame_interval = UVCG_DEFAULT_FRM_INTERV_360P, 219 + .b_frame_interval_type = 3, 220 + }, 221 + .dw_frame_interval = uvcg_frame_yuv_360p_dw_frame_interval, 222 + }; 223 + 224 + static struct uvcg_frame_ptr uvcg_frame_ptr_yuv_360p = { 225 + .frm = (struct uvcg_frame *)&uvcg_frame_yuv_360p, 226 + }; 227 + #define UVCG_WIDTH_720P 1280 228 + #define UVCG_HEIGHT_720P 720 229 + #define UVCG_MIN_BITRATE_720P 29491200 230 + #define UVCG_MAX_BITRATE_720P 29491200 231 + #define UVCG_MAX_VIDEO_FB_SZ_720P 1843200 232 + #define UVCG_FRM_INTERV_0_720P 5000000 233 + #define UVCG_DEFAULT_FRM_INTERV_720P UVCG_FRM_INTERV_0_720P 230 234 231 235 static const struct UVC_FRAME_UNCOMPRESSED(1) uvc_frame_yuv_720p = { 232 236 .bLength = UVC_DT_FRAME_UNCOMPRESSED_SIZE(1), ··· 270 202 .bDescriptorSubType = UVC_VS_FRAME_UNCOMPRESSED, 271 203 .bFrameIndex = 2, 272 204 .bmCapabilities = 0, 273 - .wWidth = cpu_to_le16(1280), 274 - .wHeight = cpu_to_le16(720), 275 - .dwMinBitRate = cpu_to_le32(29491200), 276 - .dwMaxBitRate = cpu_to_le32(29491200), 277 - .dwMaxVideoFrameBufferSize = cpu_to_le32(1843200), 278 - .dwDefaultFrameInterval = cpu_to_le32(5000000), 205 + .wWidth = cpu_to_le16(UVCG_WIDTH_720P), 206 + .wHeight = cpu_to_le16(UVCG_HEIGHT_720P), 207 + .dwMinBitRate = cpu_to_le32(UVCG_MIN_BITRATE_720P), 208 + .dwMaxBitRate = cpu_to_le32(UVCG_MAX_BITRATE_720P), 209 + .dwMaxVideoFrameBufferSize = cpu_to_le32(UVCG_MAX_VIDEO_FB_SZ_720P), 210 + .dwDefaultFrameInterval = cpu_to_le32(UVCG_DEFAULT_FRM_INTERV_720P), 279 211 .bFrameIntervalType = 1, 280 - .dwFrameInterval[0] = cpu_to_le32(5000000), 212 + .dwFrameInterval[0] = cpu_to_le32(UVCG_FRM_INTERV_0_720P), 281 213 }; 282 214 283 - static const struct uvc_format_mjpeg uvc_format_mjpg = { 284 - .bLength = UVC_DT_FORMAT_MJPEG_SIZE, 285 - .bDescriptorType = USB_DT_CS_INTERFACE, 286 - .bDescriptorSubType = UVC_VS_FORMAT_MJPEG, 287 - .bFormatIndex = 2, 288 - .bNumFrameDescriptors = 2, 289 - .bmFlags = 0, 290 - .bDefaultFrameIndex = 1, 291 - .bAspectRatioX = 0, 292 - .bAspectRatioY = 0, 293 - .bmInterlaceFlags = 0, 294 - .bCopyProtect = 0, 215 + static u32 uvcg_frame_yuv_720p_dw_frame_interval[] = { 216 + [0] = UVCG_FRM_INTERV_0_720P, 217 + }; 218 + 219 + static const struct uvcg_frame uvcg_frame_yuv_720p = { 220 + .fmt_type = UVCG_UNCOMPRESSED, 221 + .frame = { 222 + .b_length = UVC_DT_FRAME_UNCOMPRESSED_SIZE(1), 223 + .b_descriptor_type = USB_DT_CS_INTERFACE, 224 + .b_descriptor_subtype = UVC_VS_FRAME_UNCOMPRESSED, 225 + .b_frame_index = 2, 226 + .bm_capabilities = 0, 227 + .w_width = UVCG_WIDTH_720P, 228 + .w_height = UVCG_HEIGHT_720P, 229 + .dw_min_bit_rate = UVCG_MIN_BITRATE_720P, 230 + .dw_max_bit_rate = UVCG_MAX_BITRATE_720P, 231 + .dw_max_video_frame_buffer_size = UVCG_MAX_VIDEO_FB_SZ_720P, 232 + .dw_default_frame_interval = UVCG_DEFAULT_FRM_INTERV_720P, 233 + .b_frame_interval_type = 1, 234 + }, 235 + .dw_frame_interval = uvcg_frame_yuv_720p_dw_frame_interval, 236 + }; 237 + 238 + static struct uvcg_frame_ptr uvcg_frame_ptr_yuv_720p = { 239 + .frm = (struct uvcg_frame *)&uvcg_frame_yuv_720p, 240 + }; 241 + 242 + static struct uvcg_mjpeg uvcg_format_mjpeg = { 243 + .fmt = { 244 + .type = UVCG_MJPEG, 245 + /* add to .frames and fill .num_frames at runtime */ 246 + .color_matching = (struct uvcg_color_matching *)&uvcg_color_matching, 247 + }, 248 + .desc = { 249 + .bLength = UVC_DT_FORMAT_MJPEG_SIZE, 250 + .bDescriptorType = USB_DT_CS_INTERFACE, 251 + .bDescriptorSubType = UVC_VS_FORMAT_MJPEG, 252 + .bFormatIndex = 2, 253 + .bNumFrameDescriptors = 2, 254 + .bmFlags = 0, 255 + .bDefaultFrameIndex = 1, 256 + .bAspectRatioX = 0, 257 + .bAspectRatioY = 0, 258 + .bmInterlaceFlags = 0, 259 + .bCopyProtect = 0, 260 + }, 261 + }; 262 + 263 + static struct uvcg_format_ptr uvcg_format_ptr_mjpeg = { 264 + .fmt = &uvcg_format_mjpeg.fmt, 295 265 }; 296 266 297 267 DECLARE_UVC_FRAME_MJPEG(1); ··· 341 235 .bDescriptorSubType = UVC_VS_FRAME_MJPEG, 342 236 .bFrameIndex = 1, 343 237 .bmCapabilities = 0, 344 - .wWidth = cpu_to_le16(640), 345 - .wHeight = cpu_to_le16(360), 346 - .dwMinBitRate = cpu_to_le32(18432000), 347 - .dwMaxBitRate = cpu_to_le32(55296000), 348 - .dwMaxVideoFrameBufferSize = cpu_to_le32(460800), 349 - .dwDefaultFrameInterval = cpu_to_le32(666666), 238 + .wWidth = cpu_to_le16(UVCG_WIDTH_360P), 239 + .wHeight = cpu_to_le16(UVCG_HEIGHT_360P), 240 + .dwMinBitRate = cpu_to_le32(UVCG_MIN_BITRATE_360P), 241 + .dwMaxBitRate = cpu_to_le32(UVCG_MAX_BITRATE_360P), 242 + .dwMaxVideoFrameBufferSize = cpu_to_le32(UVCG_MAX_VIDEO_FB_SZ_360P), 243 + .dwDefaultFrameInterval = cpu_to_le32(UVCG_DEFAULT_FRM_INTERV_360P), 350 244 .bFrameIntervalType = 3, 351 - .dwFrameInterval[0] = cpu_to_le32(666666), 352 - .dwFrameInterval[1] = cpu_to_le32(1000000), 353 - .dwFrameInterval[2] = cpu_to_le32(5000000), 245 + .dwFrameInterval[0] = cpu_to_le32(UVCG_FRM_INTERV_0_360P), 246 + .dwFrameInterval[1] = cpu_to_le32(UVCG_FRM_INTERV_1_360P), 247 + .dwFrameInterval[2] = cpu_to_le32(UVCG_FRM_INTERV_2_360P), 248 + }; 249 + 250 + static u32 uvcg_frame_mjpeg_360p_dw_frame_interval[] = { 251 + [0] = UVCG_FRM_INTERV_0_360P, 252 + [1] = UVCG_FRM_INTERV_1_360P, 253 + [2] = UVCG_FRM_INTERV_2_360P, 254 + }; 255 + 256 + static const struct uvcg_frame uvcg_frame_mjpeg_360p = { 257 + .fmt_type = UVCG_MJPEG, 258 + .frame = { 259 + .b_length = UVC_DT_FRAME_MJPEG_SIZE(3), 260 + .b_descriptor_type = USB_DT_CS_INTERFACE, 261 + .b_descriptor_subtype = UVC_VS_FRAME_MJPEG, 262 + .b_frame_index = 1, 263 + .bm_capabilities = 0, 264 + .w_width = UVCG_WIDTH_360P, 265 + .w_height = UVCG_HEIGHT_360P, 266 + .dw_min_bit_rate = UVCG_MIN_BITRATE_360P, 267 + .dw_max_bit_rate = UVCG_MAX_BITRATE_360P, 268 + .dw_max_video_frame_buffer_size = UVCG_MAX_VIDEO_FB_SZ_360P, 269 + .dw_default_frame_interval = UVCG_DEFAULT_FRM_INTERV_360P, 270 + .b_frame_interval_type = 3, 271 + }, 272 + .dw_frame_interval = uvcg_frame_mjpeg_360p_dw_frame_interval, 273 + }; 274 + 275 + static struct uvcg_frame_ptr uvcg_frame_ptr_mjpeg_360p = { 276 + .frm = (struct uvcg_frame *)&uvcg_frame_mjpeg_360p, 354 277 }; 355 278 356 279 static const struct UVC_FRAME_MJPEG(1) uvc_frame_mjpg_720p = { ··· 388 253 .bDescriptorSubType = UVC_VS_FRAME_MJPEG, 389 254 .bFrameIndex = 2, 390 255 .bmCapabilities = 0, 391 - .wWidth = cpu_to_le16(1280), 392 - .wHeight = cpu_to_le16(720), 393 - .dwMinBitRate = cpu_to_le32(29491200), 394 - .dwMaxBitRate = cpu_to_le32(29491200), 395 - .dwMaxVideoFrameBufferSize = cpu_to_le32(1843200), 396 - .dwDefaultFrameInterval = cpu_to_le32(5000000), 256 + .wWidth = cpu_to_le16(UVCG_WIDTH_720P), 257 + .wHeight = cpu_to_le16(UVCG_HEIGHT_720P), 258 + .dwMinBitRate = cpu_to_le32(UVCG_MIN_BITRATE_720P), 259 + .dwMaxBitRate = cpu_to_le32(UVCG_MAX_BITRATE_720P), 260 + .dwMaxVideoFrameBufferSize = cpu_to_le32(UVCG_MAX_VIDEO_FB_SZ_720P), 261 + .dwDefaultFrameInterval = cpu_to_le32(UVCG_DEFAULT_FRM_INTERV_720P), 397 262 .bFrameIntervalType = 1, 398 - .dwFrameInterval[0] = cpu_to_le32(5000000), 263 + .dwFrameInterval[0] = cpu_to_le32(UVCG_FRM_INTERV_0_720P), 399 264 }; 400 265 401 - static const struct uvc_color_matching_descriptor uvc_color_matching = { 402 - .bLength = UVC_DT_COLOR_MATCHING_SIZE, 403 - .bDescriptorType = USB_DT_CS_INTERFACE, 404 - .bDescriptorSubType = UVC_VS_COLORFORMAT, 405 - .bColorPrimaries = 1, 406 - .bTransferCharacteristics = 1, 407 - .bMatrixCoefficients = 4, 266 + static u32 uvcg_frame_mjpeg_720p_dw_frame_interval[] = { 267 + [0] = UVCG_FRM_INTERV_0_720P, 268 + }; 269 + 270 + static const struct uvcg_frame uvcg_frame_mjpeg_720p = { 271 + .fmt_type = UVCG_MJPEG, 272 + .frame = { 273 + .b_length = UVC_DT_FRAME_MJPEG_SIZE(1), 274 + .b_descriptor_type = USB_DT_CS_INTERFACE, 275 + .b_descriptor_subtype = UVC_VS_FRAME_MJPEG, 276 + .b_frame_index = 2, 277 + .bm_capabilities = 0, 278 + .w_width = UVCG_WIDTH_720P, 279 + .w_height = UVCG_HEIGHT_720P, 280 + .dw_min_bit_rate = UVCG_MIN_BITRATE_720P, 281 + .dw_max_bit_rate = UVCG_MAX_BITRATE_720P, 282 + .dw_max_video_frame_buffer_size = UVCG_MAX_VIDEO_FB_SZ_720P, 283 + .dw_default_frame_interval = UVCG_DEFAULT_FRM_INTERV_720P, 284 + .b_frame_interval_type = 1, 285 + }, 286 + .dw_frame_interval = uvcg_frame_mjpeg_720p_dw_frame_interval, 287 + }; 288 + 289 + static struct uvcg_frame_ptr uvcg_frame_ptr_mjpeg_720p = { 290 + .frm = (struct uvcg_frame *)&uvcg_frame_mjpeg_720p, 291 + }; 292 + 293 + static struct uvcg_streaming_header uvcg_streaming_header = { 408 294 }; 409 295 410 296 static const struct uvc_descriptor_header * const uvc_fs_control_cls[] = { ··· 446 290 447 291 static const struct uvc_descriptor_header * const uvc_fs_streaming_cls[] = { 448 292 (const struct uvc_descriptor_header *) &uvc_input_header, 449 - (const struct uvc_descriptor_header *) &uvc_format_yuv, 293 + (const struct uvc_descriptor_header *) &uvcg_format_yuv.desc, 450 294 (const struct uvc_descriptor_header *) &uvc_frame_yuv_360p, 451 295 (const struct uvc_descriptor_header *) &uvc_frame_yuv_720p, 452 - (const struct uvc_descriptor_header *) &uvc_color_matching, 453 - (const struct uvc_descriptor_header *) &uvc_format_mjpg, 296 + (const struct uvc_descriptor_header *) &uvcg_color_matching.desc, 297 + (const struct uvc_descriptor_header *) &uvcg_format_mjpeg.desc, 454 298 (const struct uvc_descriptor_header *) &uvc_frame_mjpg_360p, 455 299 (const struct uvc_descriptor_header *) &uvc_frame_mjpg_720p, 456 - (const struct uvc_descriptor_header *) &uvc_color_matching, 300 + (const struct uvc_descriptor_header *) &uvcg_color_matching.desc, 457 301 NULL, 458 302 }; 459 303 460 304 static const struct uvc_descriptor_header * const uvc_hs_streaming_cls[] = { 461 305 (const struct uvc_descriptor_header *) &uvc_input_header, 462 - (const struct uvc_descriptor_header *) &uvc_format_yuv, 306 + (const struct uvc_descriptor_header *) &uvcg_format_yuv.desc, 463 307 (const struct uvc_descriptor_header *) &uvc_frame_yuv_360p, 464 308 (const struct uvc_descriptor_header *) &uvc_frame_yuv_720p, 465 - (const struct uvc_descriptor_header *) &uvc_color_matching, 466 - (const struct uvc_descriptor_header *) &uvc_format_mjpg, 309 + (const struct uvc_descriptor_header *) &uvcg_color_matching.desc, 310 + (const struct uvc_descriptor_header *) &uvcg_format_mjpeg.desc, 467 311 (const struct uvc_descriptor_header *) &uvc_frame_mjpg_360p, 468 312 (const struct uvc_descriptor_header *) &uvc_frame_mjpg_720p, 469 - (const struct uvc_descriptor_header *) &uvc_color_matching, 313 + (const struct uvc_descriptor_header *) &uvcg_color_matching.desc, 470 314 NULL, 471 315 }; 472 316 473 317 static const struct uvc_descriptor_header * const uvc_ss_streaming_cls[] = { 474 318 (const struct uvc_descriptor_header *) &uvc_input_header, 475 - (const struct uvc_descriptor_header *) &uvc_format_yuv, 319 + (const struct uvc_descriptor_header *) &uvcg_format_yuv.desc, 476 320 (const struct uvc_descriptor_header *) &uvc_frame_yuv_360p, 477 321 (const struct uvc_descriptor_header *) &uvc_frame_yuv_720p, 478 - (const struct uvc_descriptor_header *) &uvc_color_matching, 479 - (const struct uvc_descriptor_header *) &uvc_format_mjpg, 322 + (const struct uvc_descriptor_header *) &uvcg_color_matching.desc, 323 + (const struct uvc_descriptor_header *) &uvcg_format_mjpeg.desc, 480 324 (const struct uvc_descriptor_header *) &uvc_frame_mjpg_360p, 481 325 (const struct uvc_descriptor_header *) &uvc_frame_mjpg_720p, 482 - (const struct uvc_descriptor_header *) &uvc_color_matching, 326 + (const struct uvc_descriptor_header *) &uvcg_color_matching.desc, 483 327 NULL, 484 328 }; 485 329 ··· 542 386 uvc_opts->fs_streaming = uvc_fs_streaming_cls; 543 387 uvc_opts->hs_streaming = uvc_hs_streaming_cls; 544 388 uvc_opts->ss_streaming = uvc_ss_streaming_cls; 389 + 390 + INIT_LIST_HEAD(&uvcg_format_yuv.fmt.frames); 391 + list_add_tail(&uvcg_frame_ptr_yuv_360p.entry, &uvcg_format_yuv.fmt.frames); 392 + list_add_tail(&uvcg_frame_ptr_yuv_720p.entry, &uvcg_format_yuv.fmt.frames); 393 + uvcg_format_yuv.fmt.num_frames = 2; 394 + 395 + INIT_LIST_HEAD(&uvcg_format_mjpeg.fmt.frames); 396 + list_add_tail(&uvcg_frame_ptr_mjpeg_360p.entry, &uvcg_format_mjpeg.fmt.frames); 397 + list_add_tail(&uvcg_frame_ptr_mjpeg_720p.entry, &uvcg_format_mjpeg.fmt.frames); 398 + uvcg_format_mjpeg.fmt.num_frames = 2; 399 + 400 + INIT_LIST_HEAD(&uvcg_streaming_header.formats); 401 + list_add_tail(&uvcg_format_ptr_yuv.entry, &uvcg_streaming_header.formats); 402 + list_add_tail(&uvcg_format_ptr_mjpeg.entry, &uvcg_streaming_header.formats); 403 + uvcg_streaming_header.num_fmt = 2; 404 + 405 + uvc_opts->header = &uvcg_streaming_header; 545 406 546 407 /* Allocate string descriptor numbers ... note that string contents 547 408 * can be overridden by the composite_dev glue.
+7 -6
drivers/usb/gadget/udc/at91_udc.c
··· 1924 1924 return retval; 1925 1925 } 1926 1926 1927 - static int at91udc_remove(struct platform_device *pdev) 1927 + static void at91udc_remove(struct platform_device *pdev) 1928 1928 { 1929 1929 struct at91_udc *udc = platform_get_drvdata(pdev); 1930 1930 unsigned long flags; ··· 1932 1932 DBG("remove\n"); 1933 1933 1934 1934 usb_del_gadget_udc(&udc->gadget); 1935 - if (udc->driver) 1936 - return -EBUSY; 1935 + if (udc->driver) { 1936 + dev_err(&pdev->dev, 1937 + "Driver still in use but removing anyhow\n"); 1938 + return; 1939 + } 1937 1940 1938 1941 spin_lock_irqsave(&udc->lock, flags); 1939 1942 pullup(udc, 0); ··· 1946 1943 remove_debug_file(udc); 1947 1944 clk_unprepare(udc->fclk); 1948 1945 clk_unprepare(udc->iclk); 1949 - 1950 - return 0; 1951 1946 } 1952 1947 1953 1948 #ifdef CONFIG_PM ··· 2002 2001 2003 2002 static struct platform_driver at91_udc_driver = { 2004 2003 .probe = at91udc_probe, 2005 - .remove = at91udc_remove, 2004 + .remove_new = at91udc_remove, 2006 2005 .shutdown = at91udc_shutdown, 2007 2006 .suspend = at91udc_suspend, 2008 2007 .resume = at91udc_resume,
+1 -2
drivers/usb/gadget/udc/atmel_usba_udc.c
··· 94 94 95 95 inode_lock(file_inode(file)); 96 96 list_for_each_entry_safe(req, tmp_req, queue, queue) { 97 - len = snprintf(tmpbuf, sizeof(tmpbuf), 97 + len = scnprintf(tmpbuf, sizeof(tmpbuf), 98 98 "%8p %08x %c%c%c %5d %c%c%c\n", 99 99 req->req.buf, req->req.length, 100 100 req->req.no_interrupt ? 'i' : 'I', ··· 104 104 req->submitted ? 'F' : 'f', 105 105 req->using_dma ? 'D' : 'd', 106 106 req->last_transaction ? 'L' : 'l'); 107 - len = min(len, sizeof(tmpbuf)); 108 107 if (len > nbytes) 109 108 break; 110 109
+69 -69
drivers/usb/gadget/udc/cdns2/cdns2-debug.h
··· 16 16 { 17 17 int ret; 18 18 19 - ret = snprintf(str, size, "usbirq: 0x%02x - ", usb_irq); 19 + ret = scnprintf(str, size, "usbirq: 0x%02x - ", usb_irq); 20 20 21 21 if (usb_irq & USBIRQ_SOF) 22 - ret += snprintf(str + ret, size - ret, "SOF "); 22 + ret += scnprintf(str + ret, size - ret, "SOF "); 23 23 if (usb_irq & USBIRQ_SUTOK) 24 - ret += snprintf(str + ret, size - ret, "SUTOK "); 24 + ret += scnprintf(str + ret, size - ret, "SUTOK "); 25 25 if (usb_irq & USBIRQ_SUDAV) 26 - ret += snprintf(str + ret, size - ret, "SETUP "); 26 + ret += scnprintf(str + ret, size - ret, "SETUP "); 27 27 if (usb_irq & USBIRQ_SUSPEND) 28 - ret += snprintf(str + ret, size - ret, "Suspend "); 28 + ret += scnprintf(str + ret, size - ret, "Suspend "); 29 29 if (usb_irq & USBIRQ_URESET) 30 - ret += snprintf(str + ret, size - ret, "Reset "); 30 + ret += scnprintf(str + ret, size - ret, "Reset "); 31 31 if (usb_irq & USBIRQ_HSPEED) 32 - ret += snprintf(str + ret, size - ret, "HS "); 32 + ret += scnprintf(str + ret, size - ret, "HS "); 33 33 if (usb_irq & USBIRQ_LPM) 34 - ret += snprintf(str + ret, size - ret, "LPM "); 34 + ret += scnprintf(str + ret, size - ret, "LPM "); 35 35 36 - ret += snprintf(str + ret, size - ret, ", EXT: 0x%02x - ", ext_irq); 36 + ret += scnprintf(str + ret, size - ret, ", EXT: 0x%02x - ", ext_irq); 37 37 38 38 if (ext_irq & EXTIRQ_WAKEUP) 39 - ret += snprintf(str + ret, size - ret, "Wakeup "); 39 + ret += scnprintf(str + ret, size - ret, "Wakeup "); 40 40 if (ext_irq & EXTIRQ_VBUSFAULT_FALL) 41 - ret += snprintf(str + ret, size - ret, "VBUS_FALL "); 41 + ret += scnprintf(str + ret, size - ret, "VBUS_FALL "); 42 42 if (ext_irq & EXTIRQ_VBUSFAULT_RISE) 43 - ret += snprintf(str + ret, size - ret, "VBUS_RISE "); 43 + ret += scnprintf(str + ret, size - ret, "VBUS_RISE "); 44 44 45 - if (ret >= size) 46 - pr_info("CDNS2: buffer overflowed.\n"); 45 + if (ret == size - 1) 46 + pr_info("CDNS2: buffer may be truncated.\n"); 47 47 48 48 return str; 49 49 } ··· 54 54 { 55 55 int ret; 56 56 57 - ret = snprintf(str, size, "ISTS: %08x, %s: %08x ", 58 - ep_ists, ep_name, ep_sts); 57 + ret = scnprintf(str, size, "ISTS: %08x, %s: %08x ", 58 + ep_ists, ep_name, ep_sts); 59 59 60 60 if (ep_sts & DMA_EP_STS_IOC) 61 - ret += snprintf(str + ret, size - ret, "IOC "); 61 + ret += scnprintf(str + ret, size - ret, "IOC "); 62 62 if (ep_sts & DMA_EP_STS_ISP) 63 - ret += snprintf(str + ret, size - ret, "ISP "); 63 + ret += scnprintf(str + ret, size - ret, "ISP "); 64 64 if (ep_sts & DMA_EP_STS_DESCMIS) 65 - ret += snprintf(str + ret, size - ret, "DESCMIS "); 65 + ret += scnprintf(str + ret, size - ret, "DESCMIS "); 66 66 if (ep_sts & DMA_EP_STS_TRBERR) 67 - ret += snprintf(str + ret, size - ret, "TRBERR "); 67 + ret += scnprintf(str + ret, size - ret, "TRBERR "); 68 68 if (ep_sts & DMA_EP_STS_OUTSMM) 69 - ret += snprintf(str + ret, size - ret, "OUTSMM "); 69 + ret += scnprintf(str + ret, size - ret, "OUTSMM "); 70 70 if (ep_sts & DMA_EP_STS_ISOERR) 71 - ret += snprintf(str + ret, size - ret, "ISOERR "); 71 + ret += scnprintf(str + ret, size - ret, "ISOERR "); 72 72 if (ep_sts & DMA_EP_STS_DBUSY) 73 - ret += snprintf(str + ret, size - ret, "DBUSY "); 73 + ret += scnprintf(str + ret, size - ret, "DBUSY "); 74 74 if (DMA_EP_STS_CCS(ep_sts)) 75 - ret += snprintf(str + ret, size - ret, "CCS "); 75 + ret += scnprintf(str + ret, size - ret, "CCS "); 76 76 77 - if (ret >= size) 78 - pr_info("CDNS2: buffer overflowed.\n"); 77 + if (ret == size - 1) 78 + pr_info("CDNS2: buffer may be truncated.\n"); 79 79 80 80 return str; 81 81 } ··· 105 105 int ret; 106 106 int i; 107 107 108 - ret = snprintf(str, size, "\n\t\tTR for %s:", pep->name); 108 + ret = scnprintf(str, size, "\n\t\tTR for %s:", pep->name); 109 109 110 110 trb = &trbs[ring->dequeue]; 111 111 dma = cdns2_trb_virt_to_dma(pep, trb); 112 - ret += snprintf(str + ret, size - ret, 113 - "\n\t\tRing deq index: %d, trb: V=%p, P=0x%pad\n", 114 - ring->dequeue, trb, &dma); 112 + ret += scnprintf(str + ret, size - ret, 113 + "\n\t\tRing deq index: %d, trb: V=%p, P=0x%pad\n", 114 + ring->dequeue, trb, &dma); 115 115 116 116 trb = &trbs[ring->enqueue]; 117 117 dma = cdns2_trb_virt_to_dma(pep, trb); 118 - ret += snprintf(str + ret, size - ret, 119 - "\t\tRing enq index: %d, trb: V=%p, P=0x%pad\n", 120 - ring->enqueue, trb, &dma); 118 + ret += scnprintf(str + ret, size - ret, 119 + "\t\tRing enq index: %d, trb: V=%p, P=0x%pad\n", 120 + ring->enqueue, trb, &dma); 121 121 122 - ret += snprintf(str + ret, size - ret, 123 - "\t\tfree trbs: %d, CCS=%d, PCS=%d\n", 124 - ring->free_trbs, ring->ccs, ring->pcs); 122 + ret += scnprintf(str + ret, size - ret, 123 + "\t\tfree trbs: %d, CCS=%d, PCS=%d\n", 124 + ring->free_trbs, ring->ccs, ring->pcs); 125 125 126 126 if (TRBS_PER_SEGMENT > 40) { 127 - ret += snprintf(str + ret, size - ret, 128 - "\t\tTransfer ring %d too big\n", TRBS_PER_SEGMENT); 127 + ret += scnprintf(str + ret, size - ret, 128 + "\t\tTransfer ring %d too big\n", TRBS_PER_SEGMENT); 129 129 return str; 130 130 } 131 131 132 132 dma = ring->dma; 133 133 for (i = 0; i < TRBS_PER_SEGMENT; ++i) { 134 134 trb = &trbs[i]; 135 - ret += snprintf(str + ret, size - ret, 136 - "\t\t@%pad %08x %08x %08x\n", &dma, 137 - le32_to_cpu(trb->buffer), 138 - le32_to_cpu(trb->length), 139 - le32_to_cpu(trb->control)); 135 + ret += scnprintf(str + ret, size - ret, 136 + "\t\t@%pad %08x %08x %08x\n", &dma, 137 + le32_to_cpu(trb->buffer), 138 + le32_to_cpu(trb->length), 139 + le32_to_cpu(trb->control)); 140 140 dma += sizeof(*trb); 141 141 } 142 142 143 - if (ret >= size) 144 - pr_info("CDNS2: buffer overflowed.\n"); 143 + if (ret == size - 1) 144 + pr_info("CDNS2: buffer may be truncated.\n"); 145 145 146 146 return str; 147 147 } ··· 166 166 167 167 switch (type) { 168 168 case TRB_LINK: 169 - ret = snprintf(str, size, 170 - "LINK %08x type '%s' flags %c:%c:%c%c:%c", 171 - buffer, cdns2_trb_type_string(type), 172 - flags & TRB_CYCLE ? 'C' : 'c', 173 - flags & TRB_TOGGLE ? 'T' : 't', 174 - flags & TRB_CHAIN ? 'C' : 'c', 175 - flags & TRB_CHAIN ? 'H' : 'h', 176 - flags & TRB_IOC ? 'I' : 'i'); 169 + ret = scnprintf(str, size, 170 + "LINK %08x type '%s' flags %c:%c:%c%c:%c", 171 + buffer, cdns2_trb_type_string(type), 172 + flags & TRB_CYCLE ? 'C' : 'c', 173 + flags & TRB_TOGGLE ? 'T' : 't', 174 + flags & TRB_CHAIN ? 'C' : 'c', 175 + flags & TRB_CHAIN ? 'H' : 'h', 176 + flags & TRB_IOC ? 'I' : 'i'); 177 177 break; 178 178 case TRB_NORMAL: 179 - ret = snprintf(str, size, 180 - "type: '%s', Buffer: %08x, length: %ld, burst len: %ld, " 181 - "flags %c:%c:%c%c:%c", 182 - cdns2_trb_type_string(type), 183 - buffer, TRB_LEN(length), 184 - TRB_FIELD_TO_BURST(length), 185 - flags & TRB_CYCLE ? 'C' : 'c', 186 - flags & TRB_ISP ? 'I' : 'i', 187 - flags & TRB_CHAIN ? 'C' : 'c', 188 - flags & TRB_CHAIN ? 'H' : 'h', 189 - flags & TRB_IOC ? 'I' : 'i'); 179 + ret = scnprintf(str, size, 180 + "type: '%s', Buffer: %08x, length: %ld, burst len: %ld, " 181 + "flags %c:%c:%c%c:%c", 182 + cdns2_trb_type_string(type), 183 + buffer, TRB_LEN(length), 184 + TRB_FIELD_TO_BURST(length), 185 + flags & TRB_CYCLE ? 'C' : 'c', 186 + flags & TRB_ISP ? 'I' : 'i', 187 + flags & TRB_CHAIN ? 'C' : 'c', 188 + flags & TRB_CHAIN ? 'H' : 'h', 189 + flags & TRB_IOC ? 'I' : 'i'); 190 190 break; 191 191 default: 192 - ret = snprintf(str, size, "type '%s' -> raw %08x %08x %08x", 193 - cdns2_trb_type_string(type), 194 - buffer, length, flags); 192 + ret = scnprintf(str, size, "type '%s' -> raw %08x %08x %08x", 193 + cdns2_trb_type_string(type), 194 + buffer, length, flags); 195 195 } 196 196 197 - if (ret >= size) 198 - pr_info("CDNS2: buffer overflowed.\n"); 197 + if (ret == size - 1) 198 + pr_info("CDNS2: buffer may be truncated.\n"); 199 199 200 200 return str; 201 201 }
+8 -7
drivers/usb/gadget/udc/fsl_udc_core.c
··· 1360 1360 udc->ep0_dir = USB_DIR_IN; 1361 1361 /* Borrow the per device status_req */ 1362 1362 req = udc->status_req; 1363 - /* Fill in the reqest structure */ 1363 + /* Fill in the request structure */ 1364 1364 *((u16 *) req->req.buf) = cpu_to_le16(tmp); 1365 1365 1366 1366 req->ep = ep; ··· 2532 2532 /* Driver removal function 2533 2533 * Free resources and finish pending transactions 2534 2534 */ 2535 - static int fsl_udc_remove(struct platform_device *pdev) 2535 + static void fsl_udc_remove(struct platform_device *pdev) 2536 2536 { 2537 2537 struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 2538 2538 struct fsl_usb2_platform_data *pdata = dev_get_platdata(&pdev->dev); 2539 2539 2540 2540 DECLARE_COMPLETION_ONSTACK(done); 2541 2541 2542 - if (!udc_controller) 2543 - return -ENODEV; 2542 + if (!udc_controller) { 2543 + dev_err(&pdev->dev, 2544 + "Driver still in use but removing anyhow\n"); 2545 + return; 2546 + } 2544 2547 2545 2548 udc_controller->done = &done; 2546 2549 usb_del_gadget_udc(&udc_controller->gadget); ··· 2571 2568 */ 2572 2569 if (pdata->exit) 2573 2570 pdata->exit(pdev); 2574 - 2575 - return 0; 2576 2571 } 2577 2572 2578 2573 /*----------------------------------------------------------------- ··· 2668 2667 MODULE_DEVICE_TABLE(platform, fsl_udc_devtype); 2669 2668 static struct platform_driver udc_driver = { 2670 2669 .probe = fsl_udc_probe, 2671 - .remove = fsl_udc_remove, 2670 + .remove_new = fsl_udc_remove, 2672 2671 .id_table = fsl_udc_devtype, 2673 2672 /* these suspend and resume are not usb suspend and resume */ 2674 2673 .suspend = fsl_udc_suspend,
+7 -6
drivers/usb/gadget/udc/gr_udc.c
··· 2089 2089 ep->tailbuf, ep->tailbuf_paddr); 2090 2090 } 2091 2091 2092 - static int gr_remove(struct platform_device *pdev) 2092 + static void gr_remove(struct platform_device *pdev) 2093 2093 { 2094 2094 struct gr_udc *dev = platform_get_drvdata(pdev); 2095 2095 int i; 2096 2096 2097 2097 if (dev->added) 2098 2098 usb_del_gadget_udc(&dev->gadget); /* Shuts everything down */ 2099 - if (dev->driver) 2100 - return -EBUSY; 2099 + if (dev->driver) { 2100 + dev_err(&pdev->dev, 2101 + "Driver still in use but removing anyhow\n"); 2102 + return; 2103 + } 2101 2104 2102 2105 gr_dfs_delete(dev); 2103 2106 dma_pool_destroy(dev->desc_pool); ··· 2113 2110 gr_ep_remove(dev, i, 0); 2114 2111 for (i = 0; i < dev->nepi; i++) 2115 2112 gr_ep_remove(dev, i, 1); 2116 - 2117 - return 0; 2118 2113 } 2119 2114 static int gr_request_irq(struct gr_udc *dev, int irq) 2120 2115 { ··· 2249 2248 .of_match_table = gr_match, 2250 2249 }, 2251 2250 .probe = gr_probe, 2252 - .remove = gr_remove, 2251 + .remove_new = gr_remove, 2253 2252 }; 2254 2253 module_platform_driver(gr_driver); 2255 2254
+7 -6
drivers/usb/gadget/udc/lpc32xx_udc.c
··· 3174 3174 return retval; 3175 3175 } 3176 3176 3177 - static int lpc32xx_udc_remove(struct platform_device *pdev) 3177 + static void lpc32xx_udc_remove(struct platform_device *pdev) 3178 3178 { 3179 3179 struct lpc32xx_udc *udc = platform_get_drvdata(pdev); 3180 3180 3181 3181 usb_del_gadget_udc(&udc->gadget); 3182 - if (udc->driver) 3183 - return -EBUSY; 3182 + if (udc->driver) { 3183 + dev_err(&pdev->dev, 3184 + "Driver still in use but removing anyhow\n"); 3185 + return; 3186 + } 3184 3187 3185 3188 udc_clk_set(udc, 1); 3186 3189 udc_disable(udc); ··· 3197 3194 udc->udca_v_base, udc->udca_p_base); 3198 3195 3199 3196 clk_disable_unprepare(udc->usb_slv_clk); 3200 - 3201 - return 0; 3202 3197 } 3203 3198 3204 3199 #ifdef CONFIG_PM ··· 3256 3255 3257 3256 static struct platform_driver lpc32xx_udc_driver = { 3258 3257 .probe = lpc32xx_udc_probe, 3259 - .remove = lpc32xx_udc_remove, 3258 + .remove_new = lpc32xx_udc_remove, 3260 3259 .shutdown = lpc32xx_udc_shutdown, 3261 3260 .suspend = lpc32xx_udc_suspend, 3262 3261 .resume = lpc32xx_udc_resume,
+1 -1
drivers/usb/gadget/udc/mv_udc_core.c
··· 1451 1451 1452 1452 req = udc->status_req; 1453 1453 1454 - /* fill in the reqest structure */ 1454 + /* fill in the request structure */ 1455 1455 if (empty == false) { 1456 1456 *((u16 *) req->req.buf) = cpu_to_le16(status); 1457 1457 req->req.length = 2;
+7 -5
drivers/usb/gadget/udc/pxa25x_udc.c
··· 2397 2397 pullup_off(); 2398 2398 } 2399 2399 2400 - static int pxa25x_udc_remove(struct platform_device *pdev) 2400 + static void pxa25x_udc_remove(struct platform_device *pdev) 2401 2401 { 2402 2402 struct pxa25x_udc *dev = platform_get_drvdata(pdev); 2403 2403 2404 - if (dev->driver) 2405 - return -EBUSY; 2404 + if (dev->driver) { 2405 + dev_err(&pdev->dev, 2406 + "Driver still in use but removing anyhow\n"); 2407 + return; 2408 + } 2406 2409 2407 2410 usb_del_gadget_udc(&dev->gadget); 2408 2411 dev->pullup = 0; ··· 2417 2414 dev->transceiver = NULL; 2418 2415 2419 2416 the_controller = NULL; 2420 - return 0; 2421 2417 } 2422 2418 2423 2419 /*-------------------------------------------------------------------------*/ ··· 2474 2472 static struct platform_driver udc_driver = { 2475 2473 .shutdown = pxa25x_udc_shutdown, 2476 2474 .probe = pxa25x_udc_probe, 2477 - .remove = pxa25x_udc_remove, 2475 + .remove_new = pxa25x_udc_remove, 2478 2476 .suspend = pxa25x_udc_suspend, 2479 2477 .resume = pxa25x_udc_resume, 2480 2478 .driver = {
+9 -9
drivers/usb/host/max3421-hcd.c
··· 1158 1158 end = dp + sizeof(ubuf); 1159 1159 *dp = '\0'; 1160 1160 list_for_each_entry(urb, &ep->urb_list, urb_list) { 1161 - ret = snprintf(dp, end - dp, " %p(%d.%s %d/%d)", urb, 1162 - usb_pipetype(urb->pipe), 1163 - usb_urb_dir_in(urb) ? "IN" : "OUT", 1164 - urb->actual_length, 1165 - urb->transfer_buffer_length); 1166 - if (ret < 0 || ret >= end - dp) 1161 + ret = scnprintf(dp, end - dp, " %p(%d.%s %d/%d)", urb, 1162 + usb_pipetype(urb->pipe), 1163 + usb_urb_dir_in(urb) ? "IN" : "OUT", 1164 + urb->actual_length, 1165 + urb->transfer_buffer_length); 1166 + if (ret == end - dp - 1) 1167 1167 break; /* error or buffer full */ 1168 1168 dp += ret; 1169 1169 } ··· 1255 1255 end = sbuf + sizeof(sbuf); 1256 1256 *dp = '\0'; 1257 1257 for (i = 0; i < 16; ++i) { 1258 - int ret = snprintf(dp, end - dp, " %lu", 1259 - max3421_hcd->err_stat[i]); 1260 - if (ret < 0 || ret >= end - dp) 1258 + int ret = scnprintf(dp, end - dp, " %lu", 1259 + max3421_hcd->err_stat[i]); 1260 + if (ret == end - dp - 1) 1261 1261 break; /* error or buffer full */ 1262 1262 dp += ret; 1263 1263 }
+69 -63
drivers/usb/host/xhci-dbgcap.c
··· 6 6 * 7 7 * Author: Lu Baolu <baolu.lu@linux.intel.com> 8 8 */ 9 + #include <linux/bug.h> 10 + #include <linux/device.h> 9 11 #include <linux/dma-mapping.h> 10 - #include <linux/slab.h> 12 + #include <linux/errno.h> 13 + #include <linux/kstrtox.h> 14 + #include <linux/list.h> 11 15 #include <linux/nls.h> 16 + #include <linux/pm_runtime.h> 17 + #include <linux/slab.h> 18 + #include <linux/spinlock.h> 19 + #include <linux/string.h> 20 + #include <linux/sysfs.h> 21 + #include <linux/types.h> 22 + #include <linux/workqueue.h> 23 + 24 + #include <linux/io-64-nonatomic-lo-hi.h> 25 + 26 + #include <asm/byteorder.h> 12 27 13 28 #include "xhci.h" 14 29 #include "xhci-trace.h" ··· 43 28 if (!ring) 44 29 return; 45 30 46 - if (ring->first_seg && ring->first_seg->trbs) { 31 + if (ring->first_seg) { 47 32 dma_free_coherent(dev, TRB_SEGMENT_SIZE, 48 33 ring->first_seg->trbs, 49 34 ring->first_seg->dma); ··· 389 374 390 375 static void xhci_dbc_eps_exit(struct xhci_dbc *dbc) 391 376 { 392 - memset(dbc->eps, 0, sizeof(struct dbc_ep) * ARRAY_SIZE(dbc->eps)); 377 + memset(dbc->eps, 0, sizeof_field(struct xhci_dbc, eps)); 393 378 } 394 379 395 380 static int dbc_erst_alloc(struct device *dev, struct xhci_ring *evt_ring, 396 381 struct xhci_erst *erst, gfp_t flags) 397 382 { 398 - erst->entries = dma_alloc_coherent(dev, sizeof(struct xhci_erst_entry), 383 + erst->entries = dma_alloc_coherent(dev, sizeof(*erst->entries), 399 384 &erst->erst_dma_addr, flags); 400 385 if (!erst->entries) 401 386 return -ENOMEM; ··· 409 394 410 395 static void dbc_erst_free(struct device *dev, struct xhci_erst *erst) 411 396 { 412 - if (erst->entries) 413 - dma_free_coherent(dev, sizeof(struct xhci_erst_entry), 414 - erst->entries, erst->erst_dma_addr); 397 + dma_free_coherent(dev, sizeof(*erst->entries), erst->entries, 398 + erst->erst_dma_addr); 415 399 erst->entries = NULL; 416 400 } 417 401 ··· 509 495 goto ctx_fail; 510 496 511 497 /* Allocate the string table: */ 512 - dbc->string_size = sizeof(struct dbc_str_descs); 498 + dbc->string_size = sizeof(*dbc->string); 513 499 dbc->string = dma_alloc_coherent(dev, dbc->string_size, 514 500 &dbc->string_dma, flags); 515 501 if (!dbc->string) ··· 557 543 558 544 xhci_dbc_eps_exit(dbc); 559 545 560 - if (dbc->string) { 561 - dma_free_coherent(dbc->dev, dbc->string_size, 562 - dbc->string, dbc->string_dma); 563 - dbc->string = NULL; 564 - } 546 + dma_free_coherent(dbc->dev, dbc->string_size, dbc->string, dbc->string_dma); 547 + dbc->string = NULL; 565 548 566 549 dbc_free_ctx(dbc->dev, dbc->ctx); 567 550 dbc->ctx = NULL; ··· 608 597 static int xhci_do_dbc_stop(struct xhci_dbc *dbc) 609 598 { 610 599 if (dbc->state == DS_DISABLED) 611 - return -1; 600 + return -EINVAL; 612 601 613 602 writel(0, &dbc->regs->control); 614 603 dbc->state = DS_DISABLED; ··· 661 650 spin_lock_irqsave(&dbc->lock, flags); 662 651 ret = xhci_do_dbc_stop(dbc); 663 652 spin_unlock_irqrestore(&dbc->lock, flags); 653 + if (ret) 654 + return; 664 655 665 - if (!ret) { 666 - xhci_dbc_mem_cleanup(dbc); 667 - pm_runtime_put_sync(dbc->dev); /* note, was self.controller */ 668 - } 656 + xhci_dbc_mem_cleanup(dbc); 657 + pm_runtime_put_sync(dbc->dev); /* note, was self.controller */ 669 658 } 670 659 671 660 static void ··· 925 914 mod_delayed_work(system_wq, &dbc->event_work, 1); 926 915 } 927 916 917 + static const char * const dbc_state_strings[DS_MAX] = { 918 + [DS_DISABLED] = "disabled", 919 + [DS_INITIALIZED] = "initialized", 920 + [DS_ENABLED] = "enabled", 921 + [DS_CONNECTED] = "connected", 922 + [DS_CONFIGURED] = "configured", 923 + [DS_STALLED] = "stalled", 924 + }; 925 + 928 926 static ssize_t dbc_show(struct device *dev, 929 927 struct device_attribute *attr, 930 928 char *buf) 931 929 { 932 - const char *p; 933 930 struct xhci_dbc *dbc; 934 931 struct xhci_hcd *xhci; 935 932 936 933 xhci = hcd_to_xhci(dev_get_drvdata(dev)); 937 934 dbc = xhci->dbc; 938 935 939 - switch (dbc->state) { 940 - case DS_DISABLED: 941 - p = "disabled"; 942 - break; 943 - case DS_INITIALIZED: 944 - p = "initialized"; 945 - break; 946 - case DS_ENABLED: 947 - p = "enabled"; 948 - break; 949 - case DS_CONNECTED: 950 - p = "connected"; 951 - break; 952 - case DS_CONFIGURED: 953 - p = "configured"; 954 - break; 955 - case DS_STALLED: 956 - p = "stalled"; 957 - break; 958 - default: 959 - p = "unknown"; 960 - } 936 + if (dbc->state >= ARRAY_SIZE(dbc_state_strings)) 937 + return sysfs_emit(buf, "unknown\n"); 961 938 962 - return sprintf(buf, "%s\n", p); 939 + return sysfs_emit(buf, "%s\n", dbc_state_strings[dbc->state]); 963 940 } 964 941 965 942 static ssize_t dbc_store(struct device *dev, ··· 960 961 xhci = hcd_to_xhci(dev_get_drvdata(dev)); 961 962 dbc = xhci->dbc; 962 963 963 - if (!strncmp(buf, "enable", 6)) 964 + if (sysfs_streq(buf, "enable")) 964 965 xhci_dbc_start(dbc); 965 - else if (!strncmp(buf, "disable", 7)) 966 + else if (sysfs_streq(buf, "disable")) 966 967 xhci_dbc_stop(dbc); 967 968 else 968 969 return -EINVAL; ··· 980 981 xhci = hcd_to_xhci(dev_get_drvdata(dev)); 981 982 dbc = xhci->dbc; 982 983 983 - return sprintf(buf, "%04x\n", dbc->idVendor); 984 + return sysfs_emit(buf, "%04x\n", dbc->idVendor); 984 985 } 985 986 986 987 static ssize_t dbc_idVendor_store(struct device *dev, ··· 992 993 void __iomem *ptr; 993 994 u16 value; 994 995 u32 dev_info; 996 + int ret; 995 997 996 - if (kstrtou16(buf, 0, &value)) 997 - return -EINVAL; 998 + ret = kstrtou16(buf, 0, &value); 999 + if (ret) 1000 + return ret; 998 1001 999 1002 xhci = hcd_to_xhci(dev_get_drvdata(dev)); 1000 1003 dbc = xhci->dbc; ··· 1022 1021 xhci = hcd_to_xhci(dev_get_drvdata(dev)); 1023 1022 dbc = xhci->dbc; 1024 1023 1025 - return sprintf(buf, "%04x\n", dbc->idProduct); 1024 + return sysfs_emit(buf, "%04x\n", dbc->idProduct); 1026 1025 } 1027 1026 1028 1027 static ssize_t dbc_idProduct_store(struct device *dev, ··· 1034 1033 void __iomem *ptr; 1035 1034 u32 dev_info; 1036 1035 u16 value; 1036 + int ret; 1037 1037 1038 - if (kstrtou16(buf, 0, &value)) 1039 - return -EINVAL; 1038 + ret = kstrtou16(buf, 0, &value); 1039 + if (ret) 1040 + return ret; 1040 1041 1041 1042 xhci = hcd_to_xhci(dev_get_drvdata(dev)); 1042 1043 dbc = xhci->dbc; ··· 1063 1060 xhci = hcd_to_xhci(dev_get_drvdata(dev)); 1064 1061 dbc = xhci->dbc; 1065 1062 1066 - return sprintf(buf, "%04x\n", dbc->bcdDevice); 1063 + return sysfs_emit(buf, "%04x\n", dbc->bcdDevice); 1067 1064 } 1068 1065 1069 1066 static ssize_t dbc_bcdDevice_store(struct device *dev, ··· 1075 1072 void __iomem *ptr; 1076 1073 u32 dev_info; 1077 1074 u16 value; 1075 + int ret; 1078 1076 1079 - if (kstrtou16(buf, 0, &value)) 1080 - return -EINVAL; 1077 + ret = kstrtou16(buf, 0, &value); 1078 + if (ret) 1079 + return ret; 1081 1080 1082 1081 xhci = hcd_to_xhci(dev_get_drvdata(dev)); 1083 1082 dbc = xhci->dbc; ··· 1105 1100 xhci = hcd_to_xhci(dev_get_drvdata(dev)); 1106 1101 dbc = xhci->dbc; 1107 1102 1108 - return sprintf(buf, "%02x\n", dbc->bInterfaceProtocol); 1103 + return sysfs_emit(buf, "%02x\n", dbc->bInterfaceProtocol); 1109 1104 } 1110 1105 1111 1106 static ssize_t dbc_bInterfaceProtocol_store(struct device *dev, ··· 1119 1114 u8 value; 1120 1115 int ret; 1121 1116 1122 - /* bInterfaceProtocol is 8 bit, but xhci only supports values 0 and 1 */ 1117 + /* bInterfaceProtocol is 8 bit, but... */ 1123 1118 ret = kstrtou8(buf, 0, &value); 1124 - if (ret || value > 1) 1119 + if (ret) 1120 + return ret; 1121 + 1122 + /* ...xhci only supports values 0 and 1 */ 1123 + if (value > 1) 1125 1124 return -EINVAL; 1126 1125 1127 1126 xhci = hcd_to_xhci(dev_get_drvdata(dev)); ··· 1148 1139 static DEVICE_ATTR_RW(dbc_bcdDevice); 1149 1140 static DEVICE_ATTR_RW(dbc_bInterfaceProtocol); 1150 1141 1151 - static struct attribute *dbc_dev_attributes[] = { 1142 + static struct attribute *dbc_dev_attrs[] = { 1152 1143 &dev_attr_dbc.attr, 1153 1144 &dev_attr_dbc_idVendor.attr, 1154 1145 &dev_attr_dbc_idProduct.attr, ··· 1156 1147 &dev_attr_dbc_bInterfaceProtocol.attr, 1157 1148 NULL 1158 1149 }; 1159 - 1160 - static const struct attribute_group dbc_dev_attrib_grp = { 1161 - .attrs = dbc_dev_attributes, 1162 - }; 1150 + ATTRIBUTE_GROUPS(dbc_dev); 1163 1151 1164 1152 struct xhci_dbc * 1165 1153 xhci_alloc_dbc(struct device *dev, void __iomem *base, const struct dbc_driver *driver) ··· 1182 1176 INIT_DELAYED_WORK(&dbc->event_work, xhci_dbc_handle_events); 1183 1177 spin_lock_init(&dbc->lock); 1184 1178 1185 - ret = sysfs_create_group(&dev->kobj, &dbc_dev_attrib_grp); 1179 + ret = sysfs_create_groups(&dev->kobj, dbc_dev_groups); 1186 1180 if (ret) 1187 1181 goto err; 1188 1182 ··· 1201 1195 xhci_dbc_stop(dbc); 1202 1196 1203 1197 /* remove sysfs files */ 1204 - sysfs_remove_group(&dbc->dev->kobj, &dbc_dev_attrib_grp); 1198 + sysfs_remove_groups(&dbc->dev->kobj, dbc_dev_groups); 1205 1199 1206 1200 kfree(dbc); 1207 1201 }
+1
drivers/usb/host/xhci-dbgcap.h
··· 82 82 DS_CONNECTED, 83 83 DS_CONFIGURED, 84 84 DS_STALLED, 85 + DS_MAX 85 86 }; 86 87 87 88 struct dbc_ep {
+1 -1
drivers/usb/host/xhci-debugfs.c
··· 693 693 "command-ring", 694 694 xhci->debugfs_root); 695 695 696 - xhci_debugfs_create_ring_dir(xhci, &xhci->interrupter->event_ring, 696 + xhci_debugfs_create_ring_dir(xhci, &xhci->interrupters[0]->event_ring, 697 697 "event-ring", 698 698 xhci->debugfs_root); 699 699
+99 -11
drivers/usb/host/xhci-mem.c
··· 323 323 */ 324 324 ring->num_trbs_free = ring->num_segs * (TRBS_PER_SEGMENT - 1) - 1; 325 325 } 326 + EXPORT_SYMBOL_GPL(xhci_initialize_ring_info); 326 327 327 328 /* Allocate segments and link them for a ring */ 328 329 static int xhci_alloc_segments_for_ring(struct xhci_hcd *xhci, ··· 1740 1739 } 1741 1740 1742 1741 command->status = 0; 1742 + /* set default timeout to 5000 ms */ 1743 + command->timeout_ms = XHCI_CMD_DEFAULT_TIMEOUT; 1743 1744 INIT_LIST_HEAD(&command->cmd_list); 1744 1745 return command; 1745 1746 } ··· 1856 1853 kfree(ir); 1857 1854 } 1858 1855 1856 + void xhci_remove_secondary_interrupter(struct usb_hcd *hcd, struct xhci_interrupter *ir) 1857 + { 1858 + struct xhci_hcd *xhci = hcd_to_xhci(hcd); 1859 + unsigned int intr_num; 1860 + 1861 + /* interrupter 0 is primary interrupter, don't touch it */ 1862 + if (!ir || !ir->intr_num || ir->intr_num >= xhci->max_interrupters) 1863 + xhci_dbg(xhci, "Invalid secondary interrupter, can't remove\n"); 1864 + 1865 + /* fixme, should we check xhci->interrupter[intr_num] == ir */ 1866 + /* fixme locking */ 1867 + 1868 + spin_lock_irq(&xhci->lock); 1869 + 1870 + intr_num = ir->intr_num; 1871 + 1872 + xhci_remove_interrupter(xhci, ir); 1873 + xhci->interrupters[intr_num] = NULL; 1874 + 1875 + spin_unlock_irq(&xhci->lock); 1876 + 1877 + xhci_free_interrupter(xhci, ir); 1878 + } 1879 + EXPORT_SYMBOL_GPL(xhci_remove_secondary_interrupter); 1880 + 1859 1881 void xhci_mem_cleanup(struct xhci_hcd *xhci) 1860 1882 { 1861 1883 struct device *dev = xhci_to_hcd(xhci)->self.sysdev; ··· 1888 1860 1889 1861 cancel_delayed_work_sync(&xhci->cmd_timer); 1890 1862 1891 - xhci_remove_interrupter(xhci, xhci->interrupter); 1892 - xhci_free_interrupter(xhci, xhci->interrupter); 1893 - xhci->interrupter = NULL; 1894 - xhci_dbg_trace(xhci, trace_xhci_dbg_init, "Freed primary event ring"); 1863 + for (i = 0; i < xhci->max_interrupters; i++) { 1864 + if (xhci->interrupters[i]) { 1865 + xhci_remove_interrupter(xhci, xhci->interrupters[i]); 1866 + xhci_free_interrupter(xhci, xhci->interrupters[i]); 1867 + xhci->interrupters[i] = NULL; 1868 + } 1869 + } 1870 + xhci_dbg_trace(xhci, trace_xhci_dbg_init, "Freed interrupters"); 1895 1871 1896 1872 if (xhci->cmd_ring) 1897 1873 xhci_ring_free(xhci, xhci->cmd_ring); ··· 1965 1933 for (i = 0; i < xhci->num_port_caps; i++) 1966 1934 kfree(xhci->port_caps[i].psi); 1967 1935 kfree(xhci->port_caps); 1936 + kfree(xhci->interrupters); 1968 1937 xhci->num_port_caps = 0; 1969 1938 1970 1939 xhci->usb2_rhub.ports = NULL; ··· 1974 1941 xhci->rh_bw = NULL; 1975 1942 xhci->ext_caps = NULL; 1976 1943 xhci->port_caps = NULL; 1944 + xhci->interrupters = NULL; 1977 1945 1978 1946 xhci->page_size = 0; 1979 1947 xhci->page_shift = 0; ··· 2280 2246 } 2281 2247 2282 2248 static struct xhci_interrupter * 2283 - xhci_alloc_interrupter(struct xhci_hcd *xhci, gfp_t flags) 2249 + xhci_alloc_interrupter(struct xhci_hcd *xhci, int segs, gfp_t flags) 2284 2250 { 2285 2251 struct device *dev = xhci_to_hcd(xhci)->self.sysdev; 2286 2252 struct xhci_interrupter *ir; 2287 - unsigned int num_segs; 2253 + unsigned int num_segs = segs; 2288 2254 int ret; 2289 2255 2290 2256 ir = kzalloc_node(sizeof(*ir), flags, dev_to_node(dev)); 2291 2257 if (!ir) 2292 2258 return NULL; 2293 2259 2294 - num_segs = min_t(unsigned int, 1 << HCS_ERST_MAX(xhci->hcs_params2), 2260 + /* number of ring segments should be greater than 0 */ 2261 + if (segs <= 0) 2262 + num_segs = min_t(unsigned int, 1 << HCS_ERST_MAX(xhci->hcs_params2), 2295 2263 ERST_MAX_SEGS); 2296 2264 2297 2265 ir->event_ring = xhci_ring_alloc(xhci, num_segs, 1, TYPE_EVENT, 0, ··· 2328 2292 return -EINVAL; 2329 2293 } 2330 2294 2295 + if (xhci->interrupters[intr_num]) { 2296 + xhci_warn(xhci, "Interrupter %d\n already set up", intr_num); 2297 + return -EINVAL; 2298 + } 2299 + 2300 + xhci->interrupters[intr_num] = ir; 2301 + ir->intr_num = intr_num; 2331 2302 ir->ir_set = &xhci->run_regs->ir_set[intr_num]; 2332 2303 2333 2304 /* set ERST count with the number of entries in the segment table */ ··· 2354 2311 return 0; 2355 2312 } 2356 2313 2314 + struct xhci_interrupter * 2315 + xhci_create_secondary_interrupter(struct usb_hcd *hcd, int num_seg) 2316 + { 2317 + struct xhci_hcd *xhci = hcd_to_xhci(hcd); 2318 + struct xhci_interrupter *ir; 2319 + unsigned int i; 2320 + int err = -ENOSPC; 2321 + 2322 + if (!xhci->interrupters || xhci->max_interrupters <= 1) 2323 + return NULL; 2324 + 2325 + ir = xhci_alloc_interrupter(xhci, num_seg, GFP_KERNEL); 2326 + if (!ir) 2327 + return NULL; 2328 + 2329 + spin_lock_irq(&xhci->lock); 2330 + 2331 + /* Find available secondary interrupter, interrupter 0 is reserved for primary */ 2332 + for (i = 1; i < xhci->max_interrupters; i++) { 2333 + if (xhci->interrupters[i] == NULL) { 2334 + err = xhci_add_interrupter(xhci, ir, i); 2335 + break; 2336 + } 2337 + } 2338 + 2339 + spin_unlock_irq(&xhci->lock); 2340 + 2341 + if (err) { 2342 + xhci_warn(xhci, "Failed to add secondary interrupter, max interrupters %d\n", 2343 + xhci->max_interrupters); 2344 + xhci_free_interrupter(xhci, ir); 2345 + return NULL; 2346 + } 2347 + 2348 + xhci_dbg(xhci, "Add secondary interrupter %d, max interrupters %d\n", 2349 + i, xhci->max_interrupters); 2350 + 2351 + return ir; 2352 + } 2353 + EXPORT_SYMBOL_GPL(xhci_create_secondary_interrupter); 2354 + 2357 2355 int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags) 2358 2356 { 2359 - dma_addr_t dma; 2357 + struct xhci_interrupter *ir; 2360 2358 struct device *dev = xhci_to_hcd(xhci)->self.sysdev; 2359 + dma_addr_t dma; 2361 2360 unsigned int val, val2; 2362 2361 u64 val_64; 2363 2362 u32 page_size, temp; ··· 2523 2438 /* Allocate and set up primary interrupter 0 with an event ring. */ 2524 2439 xhci_dbg_trace(xhci, trace_xhci_dbg_init, 2525 2440 "Allocating primary event ring"); 2526 - xhci->interrupter = xhci_alloc_interrupter(xhci, flags); 2527 - if (!xhci->interrupter) 2441 + xhci->interrupters = kcalloc_node(xhci->max_interrupters, sizeof(*xhci->interrupters), 2442 + flags, dev_to_node(dev)); 2443 + 2444 + ir = xhci_alloc_interrupter(xhci, 0, flags); 2445 + if (!ir) 2528 2446 goto fail; 2529 2447 2530 - if (xhci_add_interrupter(xhci, xhci->interrupter, 0)) 2448 + if (xhci_add_interrupter(xhci, ir, 0)) 2531 2449 goto fail; 2532 2450 2533 2451 xhci->isoc_bei_interval = AVOID_BEI_INTERVAL_MAX;
+38 -2
drivers/usb/host/xhci-mtk.c
··· 7 7 * Chunfeng Yun <chunfeng.yun@mediatek.com> 8 8 */ 9 9 10 + #include <linux/bitfield.h> 10 11 #include <linux/dma-mapping.h> 11 12 #include <linux/iopoll.h> 12 13 #include <linux/kernel.h> ··· 74 73 #define FRMCNT_LEV1_RANG (0x12b << 8) 75 74 #define FRMCNT_LEV1_RANG_MASK GENMASK(19, 8) 76 75 76 + #define HSCH_CFG1 0x960 77 + #define SCH3_RXFIFO_DEPTH_MASK GENMASK(21, 20) 78 + 77 79 #define SS_GEN2_EOF_CFG 0x990 78 80 #define SSG2EOF_OFFSET 0x3c 79 81 ··· 117 113 #define PERI_SSUSB_SPM_CTRL 0x0 118 114 #define SSC_IP_SLEEP_EN BIT(4) 119 115 #define SSC_SPM_INT_EN BIT(1) 116 + 117 + #define SCH_FIFO_TO_KB(x) ((x) >> 10) 120 118 121 119 enum ssusb_uwk_vers { 122 120 SSUSB_UWK_V1 = 1, ··· 169 163 value &= ~XSEOF_OFFSET_MASK; 170 164 value |= SSG2EOF_OFFSET; 171 165 writel(value, hcd->regs + SS_GEN2_EOF_CFG); 166 + } 167 + 168 + /* 169 + * workaround: usb3.2 gen1 isoc rx hw issue 170 + * host send out unexpected ACK afer device fininsh a burst transfer with 171 + * a short packet. 172 + */ 173 + static void xhci_mtk_rxfifo_depth_set(struct xhci_hcd_mtk *mtk) 174 + { 175 + struct usb_hcd *hcd = mtk->hcd; 176 + u32 value; 177 + 178 + if (!mtk->rxfifo_depth) 179 + return; 180 + 181 + value = readl(hcd->regs + HSCH_CFG1); 182 + value &= ~SCH3_RXFIFO_DEPTH_MASK; 183 + value |= FIELD_PREP(SCH3_RXFIFO_DEPTH_MASK, 184 + SCH_FIFO_TO_KB(mtk->rxfifo_depth) - 1); 185 + writel(value, hcd->regs + HSCH_CFG1); 186 + } 187 + 188 + static void xhci_mtk_init_quirk(struct xhci_hcd_mtk *mtk) 189 + { 190 + /* workaround only for mt8195 */ 191 + xhci_mtk_set_frame_interval(mtk); 192 + 193 + /* workaround for SoCs using SSUSB about before IPM v1.6.0 */ 194 + xhci_mtk_rxfifo_depth_set(mtk); 172 195 } 173 196 174 197 static int xhci_mtk_host_enable(struct xhci_hcd_mtk *mtk) ··· 483 448 if (ret) 484 449 return ret; 485 450 486 - /* workaround only for mt8195 */ 487 - xhci_mtk_set_frame_interval(mtk); 451 + xhci_mtk_init_quirk(mtk); 488 452 } 489 453 490 454 ret = xhci_gen_setup(hcd, xhci_mtk_quirks); ··· 560 526 &mtk->u3p_dis_msk); 561 527 of_property_read_u32(node, "mediatek,u2p-dis-msk", 562 528 &mtk->u2p_dis_msk); 529 + 530 + of_property_read_u32(node, "rx-fifo-depth", &mtk->rxfifo_depth); 563 531 564 532 ret = usb_wakeup_of_property_parse(mtk, node); 565 533 if (ret) {
+2
drivers/usb/host/xhci-mtk.h
··· 171 171 struct regmap *uwk; 172 172 u32 uwk_reg_base; 173 173 u32 uwk_vers; 174 + /* quirk */ 175 + u32 rxfifo_depth; 174 176 }; 175 177 176 178 static inline struct xhci_hcd_mtk *hcd_to_mtk(struct usb_hcd *hcd)
+39 -101
drivers/usb/host/xhci-pci.c
··· 95 95 96 96 if (hcd->msix_enabled) { 97 97 struct pci_dev *pdev = to_pci_dev(hcd->self.controller); 98 - int i; 99 98 100 - for (i = 0; i < xhci->msix_count; i++) 101 - synchronize_irq(pci_irq_vector(pdev, i)); 99 + /* for now, the driver only supports one primary interrupter */ 100 + synchronize_irq(pci_irq_vector(pdev, 0)); 102 101 } 103 102 } 104 103 ··· 111 112 if (hcd->irq > 0) 112 113 return; 113 114 114 - if (hcd->msix_enabled) { 115 - int i; 116 - 117 - for (i = 0; i < xhci->msix_count; i++) 118 - free_irq(pci_irq_vector(pdev, i), xhci_to_hcd(xhci)); 119 - } else { 120 - free_irq(pci_irq_vector(pdev, 0), xhci_to_hcd(xhci)); 121 - } 122 - 115 + free_irq(pci_irq_vector(pdev, 0), xhci_to_hcd(xhci)); 123 116 pci_free_irq_vectors(pdev); 124 117 hcd->msix_enabled = 0; 125 118 } 126 119 127 - /* 128 - * Set up MSI 129 - */ 130 - static int xhci_setup_msi(struct xhci_hcd *xhci) 131 - { 132 - int ret; 133 - /* 134 - * TODO:Check with MSI Soc for sysdev 135 - */ 136 - struct pci_dev *pdev = to_pci_dev(xhci_to_hcd(xhci)->self.controller); 137 - 138 - ret = pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_MSI); 139 - if (ret < 0) { 140 - xhci_dbg_trace(xhci, trace_xhci_dbg_init, 141 - "failed to allocate MSI entry"); 142 - return ret; 143 - } 144 - 145 - ret = request_irq(pdev->irq, xhci_msi_irq, 146 - 0, "xhci_hcd", xhci_to_hcd(xhci)); 147 - if (ret) { 148 - xhci_dbg_trace(xhci, trace_xhci_dbg_init, 149 - "disable MSI interrupt"); 150 - pci_free_irq_vectors(pdev); 151 - } 152 - 153 - return ret; 154 - } 155 - 156 - /* 157 - * Set up MSI-X 158 - */ 159 - static int xhci_setup_msix(struct xhci_hcd *xhci) 160 - { 161 - int i, ret; 162 - struct usb_hcd *hcd = xhci_to_hcd(xhci); 163 - struct pci_dev *pdev = to_pci_dev(hcd->self.controller); 164 - 165 - /* 166 - * calculate number of msi-x vectors supported. 167 - * - HCS_MAX_INTRS: the max number of interrupts the host can handle, 168 - * with max number of interrupters based on the xhci HCSPARAMS1. 169 - * - num_online_cpus: maximum msi-x vectors per CPUs core. 170 - * Add additional 1 vector to ensure always available interrupt. 171 - */ 172 - xhci->msix_count = min(num_online_cpus() + 1, 173 - HCS_MAX_INTRS(xhci->hcs_params1)); 174 - 175 - ret = pci_alloc_irq_vectors(pdev, xhci->msix_count, xhci->msix_count, 176 - PCI_IRQ_MSIX); 177 - if (ret < 0) { 178 - xhci_dbg_trace(xhci, trace_xhci_dbg_init, 179 - "Failed to enable MSI-X"); 180 - return ret; 181 - } 182 - 183 - for (i = 0; i < xhci->msix_count; i++) { 184 - ret = request_irq(pci_irq_vector(pdev, i), xhci_msi_irq, 0, 185 - "xhci_hcd", xhci_to_hcd(xhci)); 186 - if (ret) 187 - goto disable_msix; 188 - } 189 - 190 - hcd->msix_enabled = 1; 191 - return ret; 192 - 193 - disable_msix: 194 - xhci_dbg_trace(xhci, trace_xhci_dbg_init, "disable MSI-X interrupt"); 195 - while (--i >= 0) 196 - free_irq(pci_irq_vector(pdev, i), xhci_to_hcd(xhci)); 197 - pci_free_irq_vectors(pdev); 198 - return ret; 199 - } 200 - 120 + /* Try enabling MSI-X with MSI and legacy IRQ as fallback */ 201 121 static int xhci_try_enable_msi(struct usb_hcd *hcd) 202 122 { 123 + struct pci_dev *pdev = to_pci_dev(hcd->self.controller); 203 124 struct xhci_hcd *xhci = hcd_to_xhci(hcd); 204 - struct pci_dev *pdev; 205 125 int ret; 206 126 207 - pdev = to_pci_dev(xhci_to_hcd(xhci)->self.controller); 208 127 /* 209 128 * Some Fresco Logic host controllers advertise MSI, but fail to 210 129 * generate interrupts. Don't even try to enable MSI. ··· 135 218 free_irq(hcd->irq, hcd); 136 219 hcd->irq = 0; 137 220 138 - ret = xhci_setup_msix(xhci); 139 - if (ret) 140 - /* fall back to msi*/ 141 - ret = xhci_setup_msi(xhci); 221 + /* 222 + * calculate number of MSI-X vectors supported. 223 + * - HCS_MAX_INTRS: the max number of interrupts the host can handle, 224 + * with max number of interrupters based on the xhci HCSPARAMS1. 225 + * - num_online_cpus: maximum MSI-X vectors per CPUs core. 226 + * Add additional 1 vector to ensure always available interrupt. 227 + */ 228 + xhci->nvecs = min(num_online_cpus() + 1, 229 + HCS_MAX_INTRS(xhci->hcs_params1)); 142 230 143 - if (!ret) { 144 - hcd->msi_enabled = 1; 145 - return 0; 231 + /* TODO: Check with MSI Soc for sysdev */ 232 + xhci->nvecs = pci_alloc_irq_vectors(pdev, 1, xhci->nvecs, 233 + PCI_IRQ_MSIX | PCI_IRQ_MSI); 234 + if (xhci->nvecs < 0) { 235 + xhci_dbg_trace(xhci, trace_xhci_dbg_init, 236 + "failed to allocate IRQ vectors"); 237 + goto legacy_irq; 146 238 } 147 239 240 + ret = request_irq(pci_irq_vector(pdev, 0), xhci_msi_irq, 0, "xhci_hcd", 241 + xhci_to_hcd(xhci)); 242 + if (ret) 243 + goto free_irq_vectors; 244 + 245 + hcd->msi_enabled = 1; 246 + hcd->msix_enabled = pdev->msix_enabled; 247 + return 0; 248 + 249 + free_irq_vectors: 250 + xhci_dbg_trace(xhci, trace_xhci_dbg_init, "disable %s interrupt", 251 + pdev->msix_enabled ? "MSI-X" : "MSI"); 252 + pci_free_irq_vectors(pdev); 253 + 254 + legacy_irq: 148 255 if (!pdev->irq) { 149 256 xhci_err(xhci, "No msi-x/msi found and no IRQ in BIOS\n"); 150 257 return -EINVAL; 151 258 } 152 259 153 - legacy_irq: 154 260 if (!strlen(hcd->irq_descr)) 155 261 snprintf(hcd->irq_descr, sizeof(hcd->irq_descr), "%s:usb%d", 156 262 hcd->driver->description, hcd->self.busnum); 157 263 158 - /* fall back to legacy interrupt*/ 159 - ret = request_irq(pdev->irq, &usb_hcd_irq, IRQF_SHARED, 160 - hcd->irq_descr, hcd); 264 + /* fall back to legacy interrupt */ 265 + ret = request_irq(pdev->irq, &usb_hcd_irq, IRQF_SHARED, hcd->irq_descr, hcd); 161 266 if (ret) { 162 - xhci_err(xhci, "request interrupt %d failed\n", 163 - pdev->irq); 267 + xhci_err(xhci, "request interrupt %d failed\n", pdev->irq); 164 268 return ret; 165 269 } 166 270 hcd->irq = pdev->irq;
+22 -4
drivers/usb/host/xhci-plat.c
··· 131 131 .compatible = "brcm,xhci-brcm-v2", 132 132 .data = &xhci_plat_brcm, 133 133 }, { 134 + .compatible = "brcm,bcm2711-xhci", 135 + .data = &xhci_plat_brcm, 136 + }, { 134 137 .compatible = "brcm,bcm7445-xhci", 135 138 .data = &xhci_plat_brcm, 136 139 }, ··· 436 433 } 437 434 EXPORT_SYMBOL_GPL(xhci_plat_remove); 438 435 439 - static int __maybe_unused xhci_plat_suspend(struct device *dev) 436 + static int xhci_plat_suspend(struct device *dev) 440 437 { 441 438 struct usb_hcd *hcd = dev_get_drvdata(dev); 442 439 struct xhci_hcd *xhci = hcd_to_xhci(hcd); ··· 464 461 return 0; 465 462 } 466 463 467 - static int __maybe_unused xhci_plat_resume(struct device *dev) 464 + static int xhci_plat_resume_common(struct device *dev, struct pm_message pmsg) 468 465 { 469 466 struct usb_hcd *hcd = dev_get_drvdata(dev); 470 467 struct xhci_hcd *xhci = hcd_to_xhci(hcd); ··· 486 483 if (ret) 487 484 goto disable_clks; 488 485 489 - ret = xhci_resume(xhci, PMSG_RESUME); 486 + ret = xhci_resume(xhci, pmsg); 490 487 if (ret) 491 488 goto disable_clks; 492 489 ··· 503 500 } 504 501 505 502 return ret; 503 + } 504 + 505 + static int xhci_plat_resume(struct device *dev) 506 + { 507 + return xhci_plat_resume_common(dev, PMSG_RESUME); 508 + } 509 + 510 + static int xhci_plat_restore(struct device *dev) 511 + { 512 + return xhci_plat_resume_common(dev, PMSG_RESTORE); 506 513 } 507 514 508 515 static int __maybe_unused xhci_plat_runtime_suspend(struct device *dev) ··· 537 524 } 538 525 539 526 const struct dev_pm_ops xhci_plat_pm_ops = { 540 - SET_SYSTEM_SLEEP_PM_OPS(xhci_plat_suspend, xhci_plat_resume) 527 + .suspend = pm_sleep_ptr(xhci_plat_suspend), 528 + .resume = pm_sleep_ptr(xhci_plat_resume), 529 + .freeze = pm_sleep_ptr(xhci_plat_suspend), 530 + .thaw = pm_sleep_ptr(xhci_plat_resume), 531 + .poweroff = pm_sleep_ptr(xhci_plat_suspend), 532 + .restore = pm_sleep_ptr(xhci_plat_restore), 541 533 542 534 SET_RUNTIME_PM_OPS(xhci_plat_runtime_suspend, 543 535 xhci_plat_runtime_resume,
+7 -6
drivers/usb/host/xhci-ring.c
··· 366 366 readl(&xhci->dba->doorbell[0]); 367 367 } 368 368 369 - static bool xhci_mod_cmd_timer(struct xhci_hcd *xhci, unsigned long delay) 369 + static bool xhci_mod_cmd_timer(struct xhci_hcd *xhci) 370 370 { 371 - return mod_delayed_work(system_wq, &xhci->cmd_timer, delay); 371 + return mod_delayed_work(system_wq, &xhci->cmd_timer, 372 + msecs_to_jiffies(xhci->current_cmd->timeout_ms)); 372 373 } 373 374 374 375 static struct xhci_command *xhci_next_queued_cmd(struct xhci_hcd *xhci) ··· 413 412 if ((xhci->cmd_ring->dequeue != xhci->cmd_ring->enqueue) && 414 413 !(xhci->xhc_state & XHCI_STATE_DYING)) { 415 414 xhci->current_cmd = cur_cmd; 416 - xhci_mod_cmd_timer(xhci, XHCI_CMD_DEFAULT_TIMEOUT); 415 + xhci_mod_cmd_timer(xhci); 417 416 xhci_ring_cmd_db(xhci); 418 417 } 419 418 } ··· 1788 1787 if (!list_is_singular(&xhci->cmd_list)) { 1789 1788 xhci->current_cmd = list_first_entry(&cmd->cmd_list, 1790 1789 struct xhci_command, cmd_list); 1791 - xhci_mod_cmd_timer(xhci, XHCI_CMD_DEFAULT_TIMEOUT); 1790 + xhci_mod_cmd_timer(xhci); 1792 1791 } else if (xhci->current_cmd == cmd) { 1793 1792 xhci->current_cmd = NULL; 1794 1793 } ··· 3061 3060 writel(status, &xhci->op_regs->status); 3062 3061 3063 3062 /* This is the handler of the primary interrupter */ 3064 - ir = xhci->interrupter; 3063 + ir = xhci->interrupters[0]; 3065 3064 if (!hcd->msi_enabled) { 3066 3065 u32 irq_pending; 3067 3066 irq_pending = readl(&ir->ir_set->irq_pending); ··· 4288 4287 /* if there are no other commands queued we start the timeout timer */ 4289 4288 if (list_empty(&xhci->cmd_list)) { 4290 4289 xhci->current_cmd = cmd; 4291 - xhci_mod_cmd_timer(xhci, XHCI_CMD_DEFAULT_TIMEOUT); 4290 + xhci_mod_cmd_timer(xhci); 4292 4291 } 4293 4292 4294 4293 list_add_tail(&cmd->cmd_list, &xhci->cmd_list);
+124 -89
drivers/usb/host/xhci.c
··· 480 480 481 481 static int xhci_run_finished(struct xhci_hcd *xhci) 482 482 { 483 - struct xhci_interrupter *ir = xhci->interrupter; 483 + struct xhci_interrupter *ir = xhci->interrupters[0]; 484 484 unsigned long flags; 485 485 u32 temp; 486 486 ··· 532 532 u64 temp_64; 533 533 int ret; 534 534 struct xhci_hcd *xhci = hcd_to_xhci(hcd); 535 - struct xhci_interrupter *ir = xhci->interrupter; 535 + struct xhci_interrupter *ir = xhci->interrupters[0]; 536 536 /* Start the xHCI host controller running only after the USB 2.0 roothub 537 537 * is setup. 538 538 */ ··· 596 596 { 597 597 u32 temp; 598 598 struct xhci_hcd *xhci = hcd_to_xhci(hcd); 599 - struct xhci_interrupter *ir = xhci->interrupter; 599 + struct xhci_interrupter *ir = xhci->interrupters[0]; 600 600 601 601 mutex_lock(&xhci->mutex); 602 602 ··· 692 692 #ifdef CONFIG_PM 693 693 static void xhci_save_registers(struct xhci_hcd *xhci) 694 694 { 695 - struct xhci_interrupter *ir = xhci->interrupter; 695 + struct xhci_interrupter *ir; 696 + unsigned int i; 696 697 697 698 xhci->s3.command = readl(&xhci->op_regs->command); 698 699 xhci->s3.dev_nt = readl(&xhci->op_regs->dev_notification); 699 700 xhci->s3.dcbaa_ptr = xhci_read_64(xhci, &xhci->op_regs->dcbaa_ptr); 700 701 xhci->s3.config_reg = readl(&xhci->op_regs->config_reg); 701 702 702 - if (!ir) 703 - return; 703 + /* save both primary and all secondary interrupters */ 704 + /* fixme, shold we lock to prevent race with remove secondary interrupter? */ 705 + for (i = 0; i < xhci->max_interrupters; i++) { 706 + ir = xhci->interrupters[i]; 707 + if (!ir) 708 + continue; 704 709 705 - ir->s3_erst_size = readl(&ir->ir_set->erst_size); 706 - ir->s3_erst_base = xhci_read_64(xhci, &ir->ir_set->erst_base); 707 - ir->s3_erst_dequeue = xhci_read_64(xhci, &ir->ir_set->erst_dequeue); 708 - ir->s3_irq_pending = readl(&ir->ir_set->irq_pending); 709 - ir->s3_irq_control = readl(&ir->ir_set->irq_control); 710 + ir->s3_erst_size = readl(&ir->ir_set->erst_size); 711 + ir->s3_erst_base = xhci_read_64(xhci, &ir->ir_set->erst_base); 712 + ir->s3_erst_dequeue = xhci_read_64(xhci, &ir->ir_set->erst_dequeue); 713 + ir->s3_irq_pending = readl(&ir->ir_set->irq_pending); 714 + ir->s3_irq_control = readl(&ir->ir_set->irq_control); 715 + } 710 716 } 711 717 712 718 static void xhci_restore_registers(struct xhci_hcd *xhci) 713 719 { 714 - struct xhci_interrupter *ir = xhci->interrupter; 720 + struct xhci_interrupter *ir; 721 + unsigned int i; 715 722 716 723 writel(xhci->s3.command, &xhci->op_regs->command); 717 724 writel(xhci->s3.dev_nt, &xhci->op_regs->dev_notification); 718 725 xhci_write_64(xhci, xhci->s3.dcbaa_ptr, &xhci->op_regs->dcbaa_ptr); 719 726 writel(xhci->s3.config_reg, &xhci->op_regs->config_reg); 720 - writel(ir->s3_erst_size, &ir->ir_set->erst_size); 721 - xhci_write_64(xhci, ir->s3_erst_base, &ir->ir_set->erst_base); 722 - xhci_write_64(xhci, ir->s3_erst_dequeue, &ir->ir_set->erst_dequeue); 723 - writel(ir->s3_irq_pending, &ir->ir_set->irq_pending); 724 - writel(ir->s3_irq_control, &ir->ir_set->irq_control); 727 + 728 + /* FIXME should we lock to protect against freeing of interrupters */ 729 + for (i = 0; i < xhci->max_interrupters; i++) { 730 + ir = xhci->interrupters[i]; 731 + if (!ir) 732 + continue; 733 + 734 + writel(ir->s3_erst_size, &ir->ir_set->erst_size); 735 + xhci_write_64(xhci, ir->s3_erst_base, &ir->ir_set->erst_base); 736 + xhci_write_64(xhci, ir->s3_erst_dequeue, &ir->ir_set->erst_dequeue); 737 + writel(ir->s3_irq_pending, &ir->ir_set->irq_pending); 738 + writel(ir->s3_irq_control, &ir->ir_set->irq_control); 739 + } 725 740 } 726 741 727 742 static void xhci_set_cmd_ring_deq(struct xhci_hcd *xhci) ··· 1099 1084 xhci_dbg(xhci, "// Disabling event ring interrupts\n"); 1100 1085 temp = readl(&xhci->op_regs->status); 1101 1086 writel((temp & ~0x1fff) | STS_EINT, &xhci->op_regs->status); 1102 - xhci_disable_interrupter(xhci->interrupter); 1087 + xhci_disable_interrupter(xhci->interrupters[0]); 1103 1088 1104 1089 xhci_dbg(xhci, "cleaning up memory\n"); 1105 1090 xhci_mem_cleanup(xhci); ··· 1453 1438 * descriptor. If the usb_device's max packet size changes after that point, 1454 1439 * we need to issue an evaluate context command and wait on it. 1455 1440 */ 1456 - static int xhci_check_maxpacket(struct xhci_hcd *xhci, unsigned int slot_id, 1457 - unsigned int ep_index, struct urb *urb, gfp_t mem_flags) 1441 + static int xhci_check_ep0_maxpacket(struct xhci_hcd *xhci, struct xhci_virt_device *vdev) 1458 1442 { 1459 - struct xhci_container_ctx *out_ctx; 1460 1443 struct xhci_input_control_ctx *ctrl_ctx; 1461 1444 struct xhci_ep_ctx *ep_ctx; 1462 1445 struct xhci_command *command; ··· 1462 1449 int hw_max_packet_size; 1463 1450 int ret = 0; 1464 1451 1465 - out_ctx = xhci->devs[slot_id]->out_ctx; 1466 - ep_ctx = xhci_get_ep_ctx(xhci, out_ctx, ep_index); 1452 + ep_ctx = xhci_get_ep_ctx(xhci, vdev->out_ctx, 0); 1467 1453 hw_max_packet_size = MAX_PACKET_DECODED(le32_to_cpu(ep_ctx->ep_info2)); 1468 - max_packet_size = usb_endpoint_maxp(&urb->dev->ep0.desc); 1469 - if (hw_max_packet_size != max_packet_size) { 1454 + max_packet_size = usb_endpoint_maxp(&vdev->udev->ep0.desc); 1455 + 1456 + if (hw_max_packet_size == max_packet_size) 1457 + return 0; 1458 + 1459 + switch (max_packet_size) { 1460 + case 8: case 16: case 32: case 64: case 9: 1470 1461 xhci_dbg_trace(xhci, trace_xhci_dbg_context_change, 1471 1462 "Max Packet Size for ep 0 changed."); 1472 1463 xhci_dbg_trace(xhci, trace_xhci_dbg_context_change, ··· 1482 1465 xhci_dbg_trace(xhci, trace_xhci_dbg_context_change, 1483 1466 "Issuing evaluate context command."); 1484 1467 1485 - /* Set up the input context flags for the command */ 1486 - /* FIXME: This won't work if a non-default control endpoint 1487 - * changes max packet sizes. 1488 - */ 1489 - 1490 - command = xhci_alloc_command(xhci, true, mem_flags); 1468 + command = xhci_alloc_command(xhci, true, GFP_KERNEL); 1491 1469 if (!command) 1492 1470 return -ENOMEM; 1493 1471 1494 - command->in_ctx = xhci->devs[slot_id]->in_ctx; 1472 + command->in_ctx = vdev->in_ctx; 1495 1473 ctrl_ctx = xhci_get_input_control_ctx(command->in_ctx); 1496 1474 if (!ctrl_ctx) { 1497 1475 xhci_warn(xhci, "%s: Could not get input context, bad type.\n", 1498 1476 __func__); 1499 1477 ret = -ENOMEM; 1500 - goto command_cleanup; 1478 + break; 1501 1479 } 1502 1480 /* Set up the modified control endpoint 0 */ 1503 - xhci_endpoint_copy(xhci, xhci->devs[slot_id]->in_ctx, 1504 - xhci->devs[slot_id]->out_ctx, ep_index); 1481 + xhci_endpoint_copy(xhci, vdev->in_ctx, vdev->out_ctx, 0); 1505 1482 1506 - ep_ctx = xhci_get_ep_ctx(xhci, command->in_ctx, ep_index); 1483 + ep_ctx = xhci_get_ep_ctx(xhci, command->in_ctx, 0); 1507 1484 ep_ctx->ep_info &= cpu_to_le32(~EP_STATE_MASK);/* must clear */ 1508 1485 ep_ctx->ep_info2 &= cpu_to_le32(~MAX_PACKET_MASK); 1509 1486 ep_ctx->ep_info2 |= cpu_to_le32(MAX_PACKET(max_packet_size)); ··· 1505 1494 ctrl_ctx->add_flags = cpu_to_le32(EP0_FLAG); 1506 1495 ctrl_ctx->drop_flags = 0; 1507 1496 1508 - ret = xhci_configure_endpoint(xhci, urb->dev, command, 1509 - true, false); 1510 - 1511 - /* Clean up the input context for later use by bandwidth 1512 - * functions. 1513 - */ 1497 + ret = xhci_configure_endpoint(xhci, vdev->udev, command, 1498 + true, false); 1499 + /* Clean up the input context for later use by bandwidth functions */ 1514 1500 ctrl_ctx->add_flags = cpu_to_le32(SLOT_FLAG); 1515 - command_cleanup: 1516 - kfree(command->completion); 1517 - kfree(command); 1501 + break; 1502 + default: 1503 + dev_dbg(&vdev->udev->dev, "incorrect max packet size %d for ep0\n", 1504 + max_packet_size); 1505 + return -EINVAL; 1518 1506 } 1507 + 1508 + kfree(command->completion); 1509 + kfree(command); 1510 + 1519 1511 return ret; 1520 1512 } 1521 1513 ··· 1536 1522 struct urb_priv *urb_priv; 1537 1523 int num_tds; 1538 1524 1539 - if (!urb) 1540 - return -EINVAL; 1541 - ret = xhci_check_args(hcd, urb->dev, urb->ep, 1542 - true, true, __func__); 1543 - if (ret <= 0) 1544 - return ret ? ret : -EINVAL; 1545 - 1546 - slot_id = urb->dev->slot_id; 1547 1525 ep_index = xhci_get_endpoint_index(&urb->ep->desc); 1548 - ep_state = &xhci->devs[slot_id]->eps[ep_index].ep_state; 1549 - 1550 - if (!HCD_HW_ACCESSIBLE(hcd)) 1551 - return -ESHUTDOWN; 1552 - 1553 - if (xhci->devs[slot_id]->flags & VDEV_PORT_ERROR) { 1554 - xhci_dbg(xhci, "Can't queue urb, port error, link inactive\n"); 1555 - return -ENODEV; 1556 - } 1557 1526 1558 1527 if (usb_endpoint_xfer_isoc(&urb->ep->desc)) 1559 1528 num_tds = urb->number_of_packets; ··· 1558 1561 1559 1562 trace_xhci_urb_enqueue(urb); 1560 1563 1561 - if (usb_endpoint_xfer_control(&urb->ep->desc)) { 1562 - /* Check to see if the max packet size for the default control 1563 - * endpoint changed during FS device enumeration 1564 - */ 1565 - if (urb->dev->speed == USB_SPEED_FULL) { 1566 - ret = xhci_check_maxpacket(xhci, slot_id, 1567 - ep_index, urb, mem_flags); 1568 - if (ret < 0) { 1569 - xhci_urb_free_priv(urb_priv); 1570 - urb->hcpriv = NULL; 1571 - return ret; 1572 - } 1573 - } 1564 + spin_lock_irqsave(&xhci->lock, flags); 1565 + 1566 + ret = xhci_check_args(hcd, urb->dev, urb->ep, 1567 + true, true, __func__); 1568 + if (ret <= 0) { 1569 + ret = ret ? ret : -EINVAL; 1570 + goto free_priv; 1574 1571 } 1575 1572 1576 - spin_lock_irqsave(&xhci->lock, flags); 1573 + slot_id = urb->dev->slot_id; 1574 + 1575 + if (!HCD_HW_ACCESSIBLE(hcd)) { 1576 + ret = -ESHUTDOWN; 1577 + goto free_priv; 1578 + } 1579 + 1580 + if (xhci->devs[slot_id]->flags & VDEV_PORT_ERROR) { 1581 + xhci_dbg(xhci, "Can't queue urb, port error, link inactive\n"); 1582 + ret = -ENODEV; 1583 + goto free_priv; 1584 + } 1577 1585 1578 1586 if (xhci->xhc_state & XHCI_STATE_DYING) { 1579 1587 xhci_dbg(xhci, "Ep 0x%x: URB %p submitted for non-responsive xHCI host.\n", ··· 1586 1584 ret = -ESHUTDOWN; 1587 1585 goto free_priv; 1588 1586 } 1587 + 1588 + ep_state = &xhci->devs[slot_id]->eps[ep_index].ep_state; 1589 + 1589 1590 if (*ep_state & (EP_GETTING_STREAMS | EP_GETTING_NO_STREAMS)) { 1590 1591 xhci_warn(xhci, "WARN: Can't enqueue URB, ep in streams transition state %x\n", 1591 1592 *ep_state); ··· 3092 3087 * of an endpoint that isn't in the halted state this function will issue a 3093 3088 * configure endpoint command with the Drop and Add bits set for the target 3094 3089 * endpoint. Refer to the additional note in xhci spcification section 4.6.8. 3090 + * 3091 + * vdev may be lost due to xHC restore error and re-initialization during S3/S4 3092 + * resume. A new vdev will be allocated later by xhci_discover_or_reset_device() 3095 3093 */ 3096 3094 3097 3095 static void xhci_endpoint_reset(struct usb_hcd *hcd, ··· 3112 3104 int err; 3113 3105 3114 3106 xhci = hcd_to_xhci(hcd); 3107 + ep_index = xhci_get_endpoint_index(&host_ep->desc); 3108 + 3109 + /* 3110 + * Usb core assumes a max packet value for ep0 on FS devices until the 3111 + * real value is read from the descriptor. Core resets Ep0 if values 3112 + * mismatch. Reconfigure the xhci ep0 endpoint context here in that case 3113 + */ 3114 + if (usb_endpoint_xfer_control(&host_ep->desc) && ep_index == 0) { 3115 + 3116 + udev = container_of(host_ep, struct usb_device, ep0); 3117 + if (udev->speed != USB_SPEED_FULL || !udev->slot_id) 3118 + return; 3119 + 3120 + vdev = xhci->devs[udev->slot_id]; 3121 + if (!vdev || vdev->udev != udev) 3122 + return; 3123 + 3124 + xhci_check_ep0_maxpacket(xhci, vdev); 3125 + 3126 + /* Nothing else should be done here for ep0 during ep reset */ 3127 + return; 3128 + } 3129 + 3115 3130 if (!host_ep->hcpriv) 3116 3131 return; 3117 3132 udev = (struct usb_device *) host_ep->hcpriv; 3118 3133 vdev = xhci->devs[udev->slot_id]; 3119 3134 3120 - /* 3121 - * vdev may be lost due to xHC restore error and re-initialization 3122 - * during S3/S4 resume. A new vdev will be allocated later by 3123 - * xhci_discover_or_reset_device() 3124 - */ 3125 3135 if (!udev->slot_id || !vdev) 3126 3136 return; 3127 - ep_index = xhci_get_endpoint_index(&host_ep->desc); 3137 + 3128 3138 ep = &vdev->eps[ep_index]; 3129 3139 3130 3140 /* Bail out if toggle is already being cleared by a endpoint reset */ ··· 4055 4029 return 0; 4056 4030 } 4057 4031 4058 - /* 4059 - * Issue an Address Device command and optionally send a corresponding 4060 - * SetAddress request to the device. 4032 + /** 4033 + * xhci_setup_device - issues an Address Device command to assign a unique 4034 + * USB bus address. 4035 + * @hcd: USB host controller data structure. 4036 + * @udev: USB dev structure representing the connected device. 4037 + * @setup: Enum specifying setup mode: address only or with context. 4038 + * @timeout_ms: Max wait time (ms) for the command operation to complete. 4039 + * 4040 + * Return: 0 if successful; otherwise, negative error code. 4061 4041 */ 4062 4042 static int xhci_setup_device(struct usb_hcd *hcd, struct usb_device *udev, 4063 - enum xhci_setup_dev setup) 4043 + enum xhci_setup_dev setup, unsigned int timeout_ms) 4064 4044 { 4065 4045 const char *act = setup == SETUP_CONTEXT_ONLY ? "context" : "address"; 4066 4046 unsigned long flags; ··· 4123 4091 } 4124 4092 4125 4093 command->in_ctx = virt_dev->in_ctx; 4094 + command->timeout_ms = timeout_ms; 4126 4095 4127 4096 slot_ctx = xhci_get_slot_ctx(xhci, virt_dev->in_ctx); 4128 4097 ctrl_ctx = xhci_get_input_control_ctx(virt_dev->in_ctx); ··· 4250 4217 return ret; 4251 4218 } 4252 4219 4253 - static int xhci_address_device(struct usb_hcd *hcd, struct usb_device *udev) 4220 + static int xhci_address_device(struct usb_hcd *hcd, struct usb_device *udev, 4221 + unsigned int timeout_ms) 4254 4222 { 4255 - return xhci_setup_device(hcd, udev, SETUP_CONTEXT_ADDRESS); 4223 + return xhci_setup_device(hcd, udev, SETUP_CONTEXT_ADDRESS, timeout_ms); 4256 4224 } 4257 4225 4258 4226 static int xhci_enable_device(struct usb_hcd *hcd, struct usb_device *udev) 4259 4227 { 4260 - return xhci_setup_device(hcd, udev, SETUP_CONTEXT_ONLY); 4228 + return xhci_setup_device(hcd, udev, SETUP_CONTEXT_ONLY, 4229 + XHCI_CMD_DEFAULT_TIMEOUT); 4261 4230 } 4262 4231 4263 4232 /*
+14 -5
drivers/usb/host/xhci.h
··· 791 791 struct completion *completion; 792 792 union xhci_trb *command_trb; 793 793 struct list_head cmd_list; 794 + /* xHCI command response timeout in milliseconds */ 795 + unsigned int timeout_ms; 794 796 }; 795 797 796 798 /* drop context bitmasks */ ··· 1552 1550 unsigned int num_trbs; 1553 1551 }; 1554 1552 1555 - /* xHCI command default timeout value */ 1556 - #define XHCI_CMD_DEFAULT_TIMEOUT (5 * HZ) 1553 + /* 1554 + * xHCI command default timeout value in milliseconds. 1555 + * USB 3.2 spec, section 9.2.6.1 1556 + */ 1557 + #define XHCI_CMD_DEFAULT_TIMEOUT 5000 1557 1558 1558 1559 /* command descriptor */ 1559 1560 struct xhci_cd { ··· 1765 1760 int page_size; 1766 1761 /* Valid values are 12 to 20, inclusive */ 1767 1762 int page_shift; 1768 - /* msi-x vectors */ 1769 - int msix_count; 1763 + /* MSI-X/MSI vectors */ 1764 + int nvecs; 1770 1765 /* optional clocks */ 1771 1766 struct clk *clk; 1772 1767 struct clk *reg_clk; ··· 1774 1769 struct reset_control *reset; 1775 1770 /* data structures */ 1776 1771 struct xhci_device_context_array *dcbaa; 1777 - struct xhci_interrupter *interrupter; 1772 + struct xhci_interrupter **interrupters; 1778 1773 struct xhci_ring *cmd_ring; 1779 1774 unsigned int cmd_ring_state; 1780 1775 #define CMD_RING_STATE_RUNNING (1 << 0) ··· 2085 2080 int type, gfp_t flags); 2086 2081 void xhci_free_container_ctx(struct xhci_hcd *xhci, 2087 2082 struct xhci_container_ctx *ctx); 2083 + struct xhci_interrupter * 2084 + xhci_create_secondary_interrupter(struct usb_hcd *hcd, int num_seg); 2085 + void xhci_remove_secondary_interrupter(struct usb_hcd 2086 + *hcd, struct xhci_interrupter *ir); 2088 2087 2089 2088 /* xHCI host controller glue */ 2090 2089 typedef void (*xhci_get_quirks_t)(struct device *, struct xhci_hcd *);
-1
drivers/usb/misc/iowarrior.c
··· 501 501 dev->minor, cmd, arg); 502 502 503 503 retval = 0; 504 - io_res = 0; 505 504 switch (cmd) { 506 505 case IOW_WRITE: 507 506 if (dev->product_id == USB_DEVICE_ID_CODEMERCS_IOW24 ||
+21 -5
drivers/usb/misc/onboard_usb_hub.c
··· 5 5 * Copyright (c) 2022, Google LLC 6 6 */ 7 7 8 + #include <linux/clk.h> 8 9 #include <linux/device.h> 9 10 #include <linux/export.h> 11 + #include <linux/err.h> 10 12 #include <linux/gpio/consumer.h> 11 13 #include <linux/init.h> 12 14 #include <linux/kernel.h> ··· 62 60 bool going_away; 63 61 struct list_head udev_list; 64 62 struct mutex lock; 63 + struct clk *clk; 65 64 }; 66 65 67 66 static int onboard_hub_power_on(struct onboard_hub *hub) 68 67 { 69 68 int err; 70 69 70 + err = clk_prepare_enable(hub->clk); 71 + if (err) { 72 + dev_err(hub->dev, "failed to enable clock: %pe\n", ERR_PTR(err)); 73 + return err; 74 + } 75 + 71 76 err = regulator_bulk_enable(hub->pdata->num_supplies, hub->supplies); 72 77 if (err) { 73 - dev_err(hub->dev, "failed to enable supplies: %d\n", err); 78 + dev_err(hub->dev, "failed to enable supplies: %pe\n", ERR_PTR(err)); 74 79 return err; 75 80 } 76 81 ··· 97 88 98 89 err = regulator_bulk_disable(hub->pdata->num_supplies, hub->supplies); 99 90 if (err) { 100 - dev_err(hub->dev, "failed to disable supplies: %d\n", err); 91 + dev_err(hub->dev, "failed to disable supplies: %pe\n", ERR_PTR(err)); 101 92 return err; 102 93 } 94 + 95 + clk_disable_unprepare(hub->clk); 103 96 104 97 hub->is_powered_on = false; 105 98 ··· 244 233 { 245 234 int err; 246 235 247 - err = driver_attach(&onboard_hub_usbdev_driver.drvwrap.driver); 236 + err = driver_attach(&onboard_hub_usbdev_driver.driver); 248 237 if (err) 249 - pr_err("Failed to attach USB driver: %d\n", err); 238 + pr_err("Failed to attach USB driver: %pe\n", ERR_PTR(err)); 250 239 } 251 240 252 241 static int onboard_hub_probe(struct platform_device *pdev) ··· 273 262 274 263 err = devm_regulator_bulk_get(dev, hub->pdata->num_supplies, hub->supplies); 275 264 if (err) { 276 - dev_err(dev, "Failed to get regulator supplies: %d\n", err); 265 + dev_err(dev, "Failed to get regulator supplies: %pe\n", ERR_PTR(err)); 277 266 return err; 278 267 } 268 + 269 + hub->clk = devm_clk_get_optional(dev, NULL); 270 + if (IS_ERR(hub->clk)) 271 + return dev_err_probe(dev, PTR_ERR(hub->clk), "failed to get clock\n"); 279 272 280 273 hub->reset_gpio = devm_gpiod_get_optional(dev, "reset", 281 274 GPIOD_OUT_HIGH); ··· 441 426 static const struct usb_device_id onboard_hub_id_table[] = { 442 427 { USB_DEVICE(VENDOR_ID_CYPRESS, 0x6504) }, /* CYUSB33{0,1,2}x/CYUSB230x 3.0 */ 443 428 { USB_DEVICE(VENDOR_ID_CYPRESS, 0x6506) }, /* CYUSB33{0,1,2}x/CYUSB230x 2.0 */ 429 + { USB_DEVICE(VENDOR_ID_CYPRESS, 0x6570) }, /* CY7C6563x 2.0 */ 444 430 { USB_DEVICE(VENDOR_ID_GENESYS, 0x0608) }, /* Genesys Logic GL850G USB 2.0 */ 445 431 { USB_DEVICE(VENDOR_ID_GENESYS, 0x0610) }, /* Genesys Logic GL852G USB 2.0 */ 446 432 { USB_DEVICE(VENDOR_ID_GENESYS, 0x0620) }, /* Genesys Logic GL3523 USB 3.1 */
+6
drivers/usb/misc/onboard_usb_hub.h
··· 36 36 .num_supplies = 2, 37 37 }; 38 38 39 + static const struct onboard_hub_pdata cypress_hx2vl_data = { 40 + .reset_us = 1, 41 + .num_supplies = 1, 42 + }; 43 + 39 44 static const struct onboard_hub_pdata genesys_gl850g_data = { 40 45 .reset_us = 3, 41 46 .num_supplies = 1, ··· 66 61 { .compatible = "usb451,8142", .data = &ti_tusb8041_data, }, 67 62 { .compatible = "usb4b4,6504", .data = &cypress_hx3_data, }, 68 63 { .compatible = "usb4b4,6506", .data = &cypress_hx3_data, }, 64 + { .compatible = "usb4b4,6570", .data = &cypress_hx2vl_data, }, 69 65 { .compatible = "usb5e3,608", .data = &genesys_gl850g_data, }, 70 66 { .compatible = "usb5e3,610", .data = &genesys_gl852g_data, }, 71 67 { .compatible = "usb5e3,620", .data = &genesys_gl852g_data, },
+3
drivers/usb/misc/qcom_eud.c
··· 205 205 return PTR_ERR(chip->mode_mgr); 206 206 207 207 chip->irq = platform_get_irq(pdev, 0); 208 + if (chip->irq < 0) 209 + return chip->irq; 210 + 208 211 ret = devm_request_threaded_irq(&pdev->dev, chip->irq, handle_eud_irq, 209 212 handle_eud_irq_thread, IRQF_ONESHOT, NULL, chip); 210 213 if (ret)
+9 -5
drivers/usb/misc/yurex.c
··· 34 34 #define YUREX_BUF_SIZE 8 35 35 #define YUREX_WRITE_TIMEOUT (HZ*2) 36 36 37 + #define MAX_S64_STRLEN 20 /* {-}922337203685477580{7,8} */ 38 + 37 39 /* table of devices that work with this driver */ 38 40 static struct usb_device_id yurex_table[] = { 39 41 { USB_DEVICE(YUREX_VENDOR_ID, YUREX_PRODUCT_ID) }, ··· 403 401 { 404 402 struct usb_yurex *dev; 405 403 int len = 0; 406 - char in_buffer[20]; 404 + char in_buffer[MAX_S64_STRLEN]; 407 405 unsigned long flags; 408 406 409 407 dev = file->private_data; ··· 414 412 return -ENODEV; 415 413 } 416 414 415 + if (WARN_ON_ONCE(dev->bbu > S64_MAX || dev->bbu < S64_MIN)) { 416 + mutex_unlock(&dev->io_mutex); 417 + return -EIO; 418 + } 419 + 417 420 spin_lock_irqsave(&dev->lock, flags); 418 - len = snprintf(in_buffer, 20, "%lld\n", dev->bbu); 421 + scnprintf(in_buffer, MAX_S64_STRLEN, "%lld\n", dev->bbu); 419 422 spin_unlock_irqrestore(&dev->lock, flags); 420 423 mutex_unlock(&dev->io_mutex); 421 - 422 - if (WARN_ON_ONCE(len >= sizeof(in_buffer))) 423 - return -EIO; 424 424 425 425 return simple_read_from_buffer(buffer, count, ppos, in_buffer, len); 426 426 }
+6 -1
drivers/usb/mon/mon_bin.c
··· 1250 1250 struct mon_reader_bin *rp = vmf->vma->vm_private_data; 1251 1251 unsigned long offset, chunk_idx; 1252 1252 struct page *pageptr; 1253 + unsigned long flags; 1253 1254 1255 + spin_lock_irqsave(&rp->b_lock, flags); 1254 1256 offset = vmf->pgoff << PAGE_SHIFT; 1255 - if (offset >= rp->b_size) 1257 + if (offset >= rp->b_size) { 1258 + spin_unlock_irqrestore(&rp->b_lock, flags); 1256 1259 return VM_FAULT_SIGBUS; 1260 + } 1257 1261 chunk_idx = offset / CHUNK_SIZE; 1258 1262 pageptr = rp->b_vec[chunk_idx].pg; 1259 1263 get_page(pageptr); 1260 1264 vmf->page = pageptr; 1265 + spin_unlock_irqrestore(&rp->b_lock, flags); 1261 1266 return 0; 1262 1267 } 1263 1268
+3 -3
drivers/usb/mon/mon_stat.c
··· 35 35 36 36 mbus = inode->i_private; 37 37 38 - sp->slen = snprintf(sp->str, STAT_BUF_SIZE, 39 - "nreaders %d events %u text_lost %u\n", 40 - mbus->nreaders, mbus->cnt_events, mbus->cnt_text_lost); 38 + sp->slen = scnprintf(sp->str, STAT_BUF_SIZE, 39 + "nreaders %d events %u text_lost %u\n", 40 + mbus->nreaders, mbus->cnt_events, mbus->cnt_text_lost); 41 41 42 42 file->private_data = sp; 43 43 return 0;
+5 -23
drivers/usb/mon/mon_text.c
··· 352 352 rp->r.rnf_error = mon_text_error; 353 353 rp->r.rnf_complete = mon_text_complete; 354 354 355 - snprintf(rp->slab_name, SLAB_NAME_SZ, "mon_text_%p", rp); 355 + scnprintf(rp->slab_name, SLAB_NAME_SZ, "mon_text_%p", rp); 356 356 rp->e_slab = kmem_cache_create(rp->slab_name, 357 357 sizeof(struct mon_event_text), sizeof(long), 0, 358 358 mon_text_ctor); ··· 700 700 701 701 int mon_text_add(struct mon_bus *mbus, const struct usb_bus *ubus) 702 702 { 703 - enum { NAMESZ = 10 }; 703 + enum { NAMESZ = 12 }; 704 704 char name[NAMESZ]; 705 705 int busnum = ubus? ubus->busnum: 0; 706 - int rc; 707 706 708 707 if (mon_dir == NULL) 709 708 return 0; 710 709 711 710 if (ubus != NULL) { 712 - rc = snprintf(name, NAMESZ, "%dt", busnum); 713 - if (rc <= 0 || rc >= NAMESZ) 714 - goto err_print_t; 711 + scnprintf(name, NAMESZ, "%dt", busnum); 715 712 mbus->dent_t = debugfs_create_file(name, 0600, mon_dir, mbus, 716 713 &mon_fops_text_t); 717 714 } 718 715 719 - rc = snprintf(name, NAMESZ, "%du", busnum); 720 - if (rc <= 0 || rc >= NAMESZ) 721 - goto err_print_u; 716 + scnprintf(name, NAMESZ, "%du", busnum); 722 717 mbus->dent_u = debugfs_create_file(name, 0600, mon_dir, mbus, 723 718 &mon_fops_text_u); 724 719 725 - rc = snprintf(name, NAMESZ, "%ds", busnum); 726 - if (rc <= 0 || rc >= NAMESZ) 727 - goto err_print_s; 720 + scnprintf(name, NAMESZ, "%ds", busnum); 728 721 mbus->dent_s = debugfs_create_file(name, 0600, mon_dir, mbus, 729 722 &mon_fops_stat); 730 723 731 724 return 1; 732 - 733 - err_print_s: 734 - debugfs_remove(mbus->dent_u); 735 - mbus->dent_u = NULL; 736 - err_print_u: 737 - if (ubus != NULL) { 738 - debugfs_remove(mbus->dent_t); 739 - mbus->dent_t = NULL; 740 - } 741 - err_print_t: 742 - return 0; 743 725 } 744 726 745 727 void mon_text_del(struct mon_bus *mbus)
+10 -4
drivers/usb/phy/phy-generic.c
··· 46 46 static int nop_set_suspend(struct usb_phy *x, int suspend) 47 47 { 48 48 struct usb_phy_generic *nop = dev_get_drvdata(x->dev); 49 + int ret = 0; 49 50 50 - if (!IS_ERR(nop->clk)) { 51 - if (suspend) 51 + if (suspend) { 52 + if (!IS_ERR(nop->clk)) 52 53 clk_disable_unprepare(nop->clk); 53 - else 54 + if (!IS_ERR(nop->vcc) && !device_may_wakeup(x->dev)) 55 + ret = regulator_disable(nop->vcc); 56 + } else { 57 + if (!IS_ERR(nop->vcc) && !device_may_wakeup(x->dev)) 58 + ret = regulator_enable(nop->vcc); 59 + if (!IS_ERR(nop->clk)) 54 60 clk_prepare_enable(nop->clk); 55 61 } 56 62 57 - return 0; 63 + return ret; 58 64 } 59 65 60 66 static void nop_reset(struct usb_phy_generic *nop)
+1 -2
drivers/usb/phy/phy-mxs-usb.c
··· 388 388 389 389 static bool mxs_phy_is_otg_host(struct mxs_phy *mxs_phy) 390 390 { 391 - return IS_ENABLED(CONFIG_USB_OTG) && 392 - mxs_phy->phy.last_event == USB_EVENT_ID; 391 + return mxs_phy->phy.last_event == USB_EVENT_ID; 393 392 } 394 393 395 394 static void mxs_phy_disconnect_line(struct mxs_phy *mxs_phy, bool on)
+4 -4
drivers/usb/phy/phy-twl6030-usb.c
··· 179 179 180 180 switch (twl->linkstat) { 181 181 case MUSB_VBUS_VALID: 182 - ret = snprintf(buf, PAGE_SIZE, "vbus\n"); 182 + ret = sysfs_emit(buf, "vbus\n"); 183 183 break; 184 184 case MUSB_ID_GROUND: 185 - ret = snprintf(buf, PAGE_SIZE, "id\n"); 185 + ret = sysfs_emit(buf, "id\n"); 186 186 break; 187 187 case MUSB_VBUS_OFF: 188 - ret = snprintf(buf, PAGE_SIZE, "none\n"); 188 + ret = sysfs_emit(buf, "none\n"); 189 189 break; 190 190 default: 191 - ret = snprintf(buf, PAGE_SIZE, "UNKNOWN\n"); 191 + ret = sysfs_emit(buf, "UNKNOWN\n"); 192 192 } 193 193 spin_unlock_irqrestore(&twl->lock, flags); 194 194
+1 -1
drivers/usb/serial/bus.c
··· 113 113 if (retval >= 0 && usb_drv->usb_driver != NULL) 114 114 retval = usb_store_new_id(&usb_drv->usb_driver->dynids, 115 115 usb_drv->usb_driver->id_table, 116 - &usb_drv->usb_driver->drvwrap.driver, 116 + &usb_drv->usb_driver->driver, 117 117 buf, count); 118 118 return retval; 119 119 }
+1 -1
drivers/usb/serial/usb-serial.c
··· 1521 1521 1522 1522 /* Now set udriver's id_table and look for matches */ 1523 1523 udriver->id_table = id_table; 1524 - rc = driver_attach(&udriver->drvwrap.driver); 1524 + rc = driver_attach(&udriver->driver); 1525 1525 return 0; 1526 1526 1527 1527 err_deregister_drivers:
+8 -8
drivers/usb/storage/sierra_ms.c
··· 98 98 struct usb_device *udev = interface_to_usbdev(intf); 99 99 int result; 100 100 if (swi_tru_install == TRU_FORCE_MS) { 101 - result = snprintf(buf, PAGE_SIZE, "Forced Mass Storage\n"); 101 + result = sysfs_emit(buf, "Forced Mass Storage\n"); 102 102 } else { 103 103 swocInfo = kmalloc(sizeof(struct swoc_info), GFP_KERNEL); 104 104 if (!swocInfo) { 105 - snprintf(buf, PAGE_SIZE, "Error\n"); 105 + sysfs_emit(buf, "Error\n"); 106 106 return -ENOMEM; 107 107 } 108 108 result = sierra_get_swoc_info(udev, swocInfo); 109 109 if (result < 0) { 110 110 dev_dbg(dev, "SWIMS: failed SWoC query\n"); 111 111 kfree(swocInfo); 112 - snprintf(buf, PAGE_SIZE, "Error\n"); 112 + sysfs_emit(buf, "Error\n"); 113 113 return -EIO; 114 114 } 115 115 debug_swoc(dev, swocInfo); 116 - result = snprintf(buf, PAGE_SIZE, 117 - "REV=%02d SKU=%04X VER=%04X\n", 118 - swocInfo->rev, 119 - swocInfo->LinuxSKU, 120 - swocInfo->LinuxVer); 116 + result = sysfs_emit(buf, 117 + "REV=%02d SKU=%04X VER=%04X\n", 118 + swocInfo->rev, 119 + swocInfo->LinuxSKU, 120 + swocInfo->LinuxVer); 121 121 kfree(swocInfo); 122 122 } 123 123 return result;
+1 -1
drivers/usb/storage/uas.c
··· 1246 1246 .suspend = uas_suspend, 1247 1247 .resume = uas_resume, 1248 1248 .reset_resume = uas_reset_resume, 1249 - .drvwrap.driver.shutdown = uas_shutdown, 1249 + .driver.shutdown = uas_shutdown, 1250 1250 .id_table = uas_usb_ids, 1251 1251 }; 1252 1252
+10 -7
drivers/usb/typec/class.c
··· 263 263 { 264 264 struct altmode *partner = altmode->partner; 265 265 struct typec_altmode *adev; 266 + struct typec_altmode *partner_adev; 266 267 267 268 if (!partner) 268 269 return; 269 270 270 271 adev = &altmode->adev; 272 + partner_adev = &partner->adev; 271 273 272 274 if (is_typec_plug(adev->dev.parent)) { 273 275 struct typec_plug *plug = to_typec_plug(adev->dev.parent); ··· 278 276 } else { 279 277 partner->partner = NULL; 280 278 } 281 - put_device(&adev->dev); 279 + put_device(&partner_adev->dev); 282 280 } 283 281 284 282 /** ··· 478 476 else 479 477 ids = &to_typec_port(dev)->mode_ids; 480 478 481 - return ida_simple_get(ids, 0, 0, GFP_KERNEL); 479 + return ida_alloc(ids, GFP_KERNEL); 482 480 } 483 481 484 482 static void altmode_id_remove(struct device *dev, int id) ··· 492 490 else 493 491 ids = &to_typec_port(dev)->mode_ids; 494 492 495 - ida_simple_remove(ids, id); 493 + ida_free(ids, id); 496 494 } 497 495 498 496 static void typec_altmode_release(struct device *dev) ··· 1800 1798 { 1801 1799 struct typec_port *port = to_typec_port(dev); 1802 1800 1803 - ida_simple_remove(&typec_index_ida, port->id); 1801 + ida_free(&typec_index_ida, port->id); 1804 1802 ida_destroy(&port->mode_ids); 1805 1803 typec_switch_put(port->sw); 1806 1804 typec_mux_put(port->mux); ··· 2233 2231 struct typec_altmode_desc desc; 2234 2232 struct typec_altmode *alt; 2235 2233 size_t index = 0; 2236 - u32 svid, vdo; 2234 + u16 svid; 2235 + u32 vdo; 2237 2236 int ret; 2238 2237 2239 2238 altmodes_node = device_get_named_child_node(&port->dev, "altmodes"); ··· 2242 2239 return; /* No altmodes specified */ 2243 2240 2244 2241 fwnode_for_each_child_node(altmodes_node, child) { 2245 - ret = fwnode_property_read_u32(child, "svid", &svid); 2242 + ret = fwnode_property_read_u16(child, "svid", &svid); 2246 2243 if (ret) { 2247 2244 dev_err(&port->dev, "Error reading svid for altmode %s\n", 2248 2245 fwnode_get_name(child)); ··· 2300 2297 if (!port) 2301 2298 return ERR_PTR(-ENOMEM); 2302 2299 2303 - id = ida_simple_get(&typec_index_ida, 0, 0, GFP_KERNEL); 2300 + id = ida_alloc(&typec_index_ida, GFP_KERNEL); 2304 2301 if (id < 0) { 2305 2302 kfree(port); 2306 2303 return ERR_PTR(id);
+10
drivers/usb/typec/mux/Kconfig
··· 56 56 Say Y or M if your system has a NXP PTN36502 Type-C redriver chip 57 57 found on some devices with a Type-C port. 58 58 59 + config TYPEC_MUX_WCD939X_USBSS 60 + tristate "Qualcomm WCD939x USBSS Analog Audio Switch driver" 61 + depends on I2C 62 + select REGMAP_I2C 63 + help 64 + Driver for the Qualcomm WCD939x Audio Codec USBSS domain which 65 + provides support for muxing analog audio and sideband signals on a 66 + common USB Type-C connector. 67 + If compiled as a module, the module will be named wcd939x-usbss. 68 + 59 69 endmenu
+1
drivers/usb/typec/mux/Makefile
··· 6 6 obj-$(CONFIG_TYPEC_MUX_INTEL_PMC) += intel_pmc_mux.o 7 7 obj-$(CONFIG_TYPEC_MUX_NB7VPQ904M) += nb7vpq904m.o 8 8 obj-$(CONFIG_TYPEC_MUX_PTN36502) += ptn36502.o 9 + obj-$(CONFIG_TYPEC_MUX_WCD939X_USBSS) += wcd939x-usbss.o
+779
drivers/usb/typec/mux/wcd939x-usbss.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-only 2 + /* 3 + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. 4 + * Copyright (C) 2023 Linaro Ltd. 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/bitfield.h> 14 + #include <linux/gpio/consumer.h> 15 + #include <linux/usb/typec_dp.h> 16 + #include <linux/usb/typec_mux.h> 17 + 18 + #define WCD_USBSS_PMP_OUT1 0x2 19 + 20 + #define WCD_USBSS_DP_DN_MISC1 0x20 21 + 22 + #define WCD_USBSS_DP_DN_MISC1_DP_PCOMP_2X_DYN_BST_ON_EN BIT(3) 23 + #define WCD_USBSS_DP_DN_MISC1_DN_PCOMP_2X_DYN_BST_ON_EN BIT(0) 24 + 25 + #define WCD_USBSS_MG1_EN 0x24 26 + 27 + #define WCD_USBSS_MG1_EN_CT_SNS_EN BIT(1) 28 + 29 + #define WCD_USBSS_MG1_BIAS 0x25 30 + 31 + #define WCD_USBSS_MG1_BIAS_PCOMP_DYN_BST_EN BIT(3) 32 + 33 + #define WCD_USBSS_MG1_MISC 0x27 34 + 35 + #define WCD_USBSS_MG1_MISC_PCOMP_2X_DYN_BST_ON_EN BIT(5) 36 + 37 + #define WCD_USBSS_MG2_EN 0x28 38 + 39 + #define WCD_USBSS_MG2_EN_CT_SNS_EN BIT(1) 40 + 41 + #define WCD_USBSS_MG2_BIAS 0x29 42 + 43 + #define WCD_USBSS_MG2_BIAS_PCOMP_DYN_BST_EN BIT(3) 44 + 45 + #define WCD_USBSS_MG2_MISC 0x30 46 + 47 + #define WCD_USBSS_MG2_MISC_PCOMP_2X_DYN_BST_ON_EN BIT(5) 48 + 49 + #define WCD_USBSS_DISP_AUXP_THRESH 0x80 50 + 51 + #define WCD_USBSS_DISP_AUXP_THRESH_DISP_AUXP_OVPON_CM GENMASK(7, 5) 52 + 53 + #define WCD_USBSS_DISP_AUXP_CTL 0x81 54 + 55 + #define WCD_USBSS_DISP_AUXP_CTL_LK_CANCEL_TRK_COEFF GENMASK(2, 0) 56 + 57 + #define WCD_USBSS_CPLDO_CTL2 0xa1 58 + 59 + #define WCD_USBSS_SWITCH_SETTINGS_ENABLE 0x403 60 + 61 + #define WCD_USBSS_SWITCH_SETTINGS_ENABLE_DEVICE_ENABLE BIT(7) 62 + #define WCD_USBSS_SWITCH_SETTINGS_ENABLE_DP_AUXP_TO_MGX_SWITCHES BIT(6) 63 + #define WCD_USBSS_SWITCH_SETTINGS_ENABLE_DP_AUXM_TO_MGX_SWITCHES BIT(5) 64 + #define WCD_USBSS_SWITCH_SETTINGS_ENABLE_DNL_SWITCHES BIT(4) 65 + #define WCD_USBSS_SWITCH_SETTINGS_ENABLE_DPR_SWITCHES BIT(3) 66 + #define WCD_USBSS_SWITCH_SETTINGS_ENABLE_SENSE_SWITCHES BIT(2) 67 + #define WCD_USBSS_SWITCH_SETTINGS_ENABLE_MIC_SWITCHES BIT(1) 68 + #define WCD_USBSS_SWITCH_SETTINGS_ENABLE_AGND_SWITCHES BIT(0) 69 + 70 + #define WCD_USBSS_SWITCH_SELECT0 0x404 71 + 72 + #define WCD_USBSS_SWITCH_SELECT0_DP_AUXP_SWITCHES BIT(7) /* 1-> MG2 */ 73 + #define WCD_USBSS_SWITCH_SELECT0_DP_AUXM_SWITCHES BIT(6) /* 1-> MG2 */ 74 + #define WCD_USBSS_SWITCH_SELECT0_DNL_SWITCHES GENMASK(5, 4) 75 + #define WCD_USBSS_SWITCH_SELECT0_DPR_SWITCHES GENMASK(3, 2) 76 + #define WCD_USBSS_SWITCH_SELECT0_SENSE_SWITCHES BIT(1) /* 1-> SBU2 */ 77 + #define WCD_USBSS_SWITCH_SELECT0_MIC_SWITCHES BIT(0) /* 1-> MG2 */ 78 + 79 + #define WCD_USBSS_SWITCH_SELECT0_DNL_SWITCH_L 0 80 + #define WCD_USBSS_SWITCH_SELECT0_DNL_SWITCH_DN 1 81 + #define WCD_USBSS_SWITCH_SELECT0_DNL_SWITCH_DN2 2 82 + 83 + #define WCD_USBSS_SWITCH_SELECT0_DPR_SWITCH_R 0 84 + #define WCD_USBSS_SWITCH_SELECT0_DPR_SWITCH_DP 1 85 + #define WCD_USBSS_SWITCH_SELECT0_DPR_SWITCH_DR2 2 86 + 87 + #define WCD_USBSS_SWITCH_SELECT1 0x405 88 + 89 + #define WCD_USBSS_SWITCH_SELECT1_AGND_SWITCHES BIT(0) /* 1-> MG2 */ 90 + 91 + #define WCD_USBSS_DELAY_R_SW 0x40d 92 + #define WCD_USBSS_DELAY_MIC_SW 0x40e 93 + #define WCD_USBSS_DELAY_SENSE_SW 0x40f 94 + #define WCD_USBSS_DELAY_GND_SW 0x410 95 + #define WCD_USBSS_DELAY_L_SW 0x411 96 + 97 + #define WCD_USBSS_FUNCTION_ENABLE 0x413 98 + 99 + #define WCD_USBSS_FUNCTION_ENABLE_SOURCE_SELECT GENMASK(1, 0) 100 + 101 + #define WCD_USBSS_FUNCTION_ENABLE_SOURCE_SELECT_MANUAL 1 102 + #define WCD_USBSS_FUNCTION_ENABLE_SOURCE_SELECT_AUDIO_FSM 2 103 + 104 + #define WCD_USBSS_EQUALIZER1 0x415 105 + 106 + #define WCD_USBSS_EQUALIZER1_EQ_EN BIT(7) 107 + #define WCD_USBSS_EQUALIZER1_BW_SETTINGS GENMASK(6, 3) 108 + 109 + #define WCD_USBSS_USB_SS_CNTL 0x419 110 + 111 + #define WCD_USBSS_USB_SS_CNTL_STANDBY_STATE BIT(4) 112 + #define WCD_USBSS_USB_SS_CNTL_RCO_EN BIT(3) 113 + #define WCD_USBSS_USB_SS_CNTL_USB_SS_MODE GENMASK(2, 0) 114 + 115 + #define WCD_USBSS_USB_SS_CNTL_USB_SS_MODE_AATC 2 116 + #define WCD_USBSS_USB_SS_CNTL_USB_SS_MODE_USB 5 117 + 118 + #define WCD_USBSS_AUDIO_FSM_START 0x433 119 + 120 + #define WCD_USBSS_AUDIO_FSM_START_AUDIO_FSM_AUDIO_TRIG BIT(0) 121 + 122 + #define WCD_USBSS_RATIO_SPKR_REXT_L_LSB 0x461 123 + #define WCD_USBSS_RATIO_SPKR_REXT_L_MSB 0x462 124 + #define WCD_USBSS_RATIO_SPKR_REXT_R_LSB 0x463 125 + #define WCD_USBSS_RATIO_SPKR_REXT_R_MSB 0x464 126 + #define WCD_USBSS_AUD_COEF_L_K0_0 0x475 127 + #define WCD_USBSS_AUD_COEF_L_K0_1 0x476 128 + #define WCD_USBSS_AUD_COEF_L_K0_2 0x477 129 + #define WCD_USBSS_AUD_COEF_L_K1_0 0x478 130 + #define WCD_USBSS_AUD_COEF_L_K1_1 0x479 131 + #define WCD_USBSS_AUD_COEF_L_K2_0 0x47a 132 + #define WCD_USBSS_AUD_COEF_L_K2_1 0x47b 133 + #define WCD_USBSS_AUD_COEF_L_K3_0 0x47c 134 + #define WCD_USBSS_AUD_COEF_L_K3_1 0x47d 135 + #define WCD_USBSS_AUD_COEF_L_K4_0 0x47e 136 + #define WCD_USBSS_AUD_COEF_L_K4_1 0x47f 137 + #define WCD_USBSS_AUD_COEF_L_K5_0 0x480 138 + #define WCD_USBSS_AUD_COEF_L_K5_1 0x481 139 + #define WCD_USBSS_AUD_COEF_R_K0_0 0x482 140 + #define WCD_USBSS_AUD_COEF_R_K0_1 0x483 141 + #define WCD_USBSS_AUD_COEF_R_K0_2 0x484 142 + #define WCD_USBSS_AUD_COEF_R_K1_0 0x485 143 + #define WCD_USBSS_AUD_COEF_R_K1_1 0x486 144 + #define WCD_USBSS_AUD_COEF_R_K2_0 0x487 145 + #define WCD_USBSS_AUD_COEF_R_K2_1 0x488 146 + #define WCD_USBSS_AUD_COEF_R_K3_0 0x489 147 + #define WCD_USBSS_AUD_COEF_R_K3_1 0x48a 148 + #define WCD_USBSS_AUD_COEF_R_K4_0 0x48b 149 + #define WCD_USBSS_AUD_COEF_R_K4_1 0x48c 150 + #define WCD_USBSS_AUD_COEF_R_K5_0 0x48d 151 + #define WCD_USBSS_AUD_COEF_R_K5_1 0x48e 152 + #define WCD_USBSS_GND_COEF_L_K0_0 0x48f 153 + #define WCD_USBSS_GND_COEF_L_K0_1 0x490 154 + #define WCD_USBSS_GND_COEF_L_K0_2 0x491 155 + #define WCD_USBSS_GND_COEF_L_K1_0 0x492 156 + #define WCD_USBSS_GND_COEF_L_K1_1 0x493 157 + #define WCD_USBSS_GND_COEF_L_K2_0 0x494 158 + #define WCD_USBSS_GND_COEF_L_K2_1 0x495 159 + #define WCD_USBSS_GND_COEF_L_K3_0 0x496 160 + #define WCD_USBSS_GND_COEF_L_K3_1 0x497 161 + #define WCD_USBSS_GND_COEF_L_K4_0 0x498 162 + #define WCD_USBSS_GND_COEF_L_K4_1 0x499 163 + #define WCD_USBSS_GND_COEF_L_K5_0 0x49a 164 + #define WCD_USBSS_GND_COEF_L_K5_1 0x49b 165 + #define WCD_USBSS_GND_COEF_R_K0_0 0x49c 166 + #define WCD_USBSS_GND_COEF_R_K0_1 0x49d 167 + #define WCD_USBSS_GND_COEF_R_K0_2 0x49e 168 + #define WCD_USBSS_GND_COEF_R_K1_0 0x49f 169 + #define WCD_USBSS_GND_COEF_R_K1_1 0x4a0 170 + #define WCD_USBSS_GND_COEF_R_K2_0 0x4a1 171 + #define WCD_USBSS_GND_COEF_R_K2_1 0x4a2 172 + #define WCD_USBSS_GND_COEF_R_K3_0 0x4a3 173 + #define WCD_USBSS_GND_COEF_R_K3_1 0x4a4 174 + #define WCD_USBSS_GND_COEF_R_K4_0 0x4a5 175 + #define WCD_USBSS_GND_COEF_R_K4_1 0x4a6 176 + #define WCD_USBSS_GND_COEF_R_K5_0 0x4a7 177 + #define WCD_USBSS_GND_COEF_R_K5_1 0x4a8 178 + 179 + #define WCD_USBSS_MAX_REGISTER 0x4c1 180 + 181 + struct wcd939x_usbss { 182 + struct i2c_client *client; 183 + struct gpio_desc *reset_gpio; 184 + struct regulator *vdd_supply; 185 + 186 + /* used to serialize concurrent change requests */ 187 + struct mutex lock; 188 + 189 + struct typec_switch_dev *sw; 190 + struct typec_mux_dev *mux; 191 + 192 + struct regmap *regmap; 193 + 194 + struct typec_mux *codec; 195 + struct typec_switch *codec_switch; 196 + 197 + enum typec_orientation orientation; 198 + unsigned long mode; 199 + unsigned int svid; 200 + }; 201 + 202 + static const struct regmap_range_cfg wcd939x_usbss_ranges[] = { 203 + { 204 + .range_min = 0, 205 + .range_max = WCD_USBSS_MAX_REGISTER, 206 + .selector_reg = 0x0, 207 + .selector_mask = 0xff, 208 + .selector_shift = 0, 209 + .window_start = 0, 210 + .window_len = 0x100, 211 + }, 212 + }; 213 + 214 + static const struct regmap_config wcd939x_usbss_regmap_config = { 215 + .reg_bits = 8, 216 + .val_bits = 8, 217 + .max_register = WCD_USBSS_MAX_REGISTER, 218 + .ranges = wcd939x_usbss_ranges, 219 + .num_ranges = ARRAY_SIZE(wcd939x_usbss_ranges), 220 + }; 221 + 222 + /* Linearlizer coefficients for 32ohm load */ 223 + static const struct { 224 + unsigned int offset; 225 + unsigned int mask; 226 + unsigned int value; 227 + } wcd939x_usbss_coeff_init[] = { 228 + { WCD_USBSS_AUD_COEF_L_K5_0, GENMASK(7, 0), 0x39 }, 229 + { WCD_USBSS_AUD_COEF_R_K5_0, GENMASK(7, 0), 0x39 }, 230 + { WCD_USBSS_GND_COEF_L_K2_0, GENMASK(7, 0), 0xe8 }, 231 + { WCD_USBSS_GND_COEF_L_K4_0, GENMASK(7, 0), 0x73 }, 232 + { WCD_USBSS_GND_COEF_R_K2_0, GENMASK(7, 0), 0xe8 }, 233 + { WCD_USBSS_GND_COEF_R_K4_0, GENMASK(7, 0), 0x73 }, 234 + { WCD_USBSS_RATIO_SPKR_REXT_L_LSB, GENMASK(7, 0), 0x00 }, 235 + { WCD_USBSS_RATIO_SPKR_REXT_L_MSB, GENMASK(6, 0), 0x04 }, 236 + { WCD_USBSS_RATIO_SPKR_REXT_R_LSB, GENMASK(7, 0), 0x00 }, 237 + { WCD_USBSS_RATIO_SPKR_REXT_R_MSB, GENMASK(6, 0), 0x04 }, 238 + }; 239 + 240 + static int wcd939x_usbss_set(struct wcd939x_usbss *usbss) 241 + { 242 + bool reverse = (usbss->orientation == TYPEC_ORIENTATION_REVERSE); 243 + bool enable_audio = false; 244 + bool enable_usb = false; 245 + bool enable_dp = false; 246 + int ret; 247 + 248 + /* USB Mode */ 249 + if (usbss->mode < TYPEC_STATE_MODAL || 250 + (!usbss->svid && (usbss->mode == TYPEC_MODE_USB2 || 251 + usbss->mode == TYPEC_MODE_USB3))) { 252 + enable_usb = true; 253 + } else if (usbss->svid) { 254 + switch (usbss->mode) { 255 + /* DP Only */ 256 + case TYPEC_DP_STATE_C: 257 + case TYPEC_DP_STATE_E: 258 + enable_dp = true; 259 + break; 260 + 261 + /* DP + USB */ 262 + case TYPEC_DP_STATE_D: 263 + case TYPEC_DP_STATE_F: 264 + enable_usb = true; 265 + enable_dp = true; 266 + break; 267 + 268 + default: 269 + return -EOPNOTSUPP; 270 + } 271 + } else if (usbss->mode == TYPEC_MODE_AUDIO) { 272 + enable_audio = true; 273 + } else { 274 + return -EOPNOTSUPP; 275 + } 276 + 277 + /* Disable all switches */ 278 + ret = regmap_clear_bits(usbss->regmap, WCD_USBSS_SWITCH_SETTINGS_ENABLE, 279 + WCD_USBSS_SWITCH_SETTINGS_ENABLE_DP_AUXP_TO_MGX_SWITCHES | 280 + WCD_USBSS_SWITCH_SETTINGS_ENABLE_DP_AUXM_TO_MGX_SWITCHES | 281 + WCD_USBSS_SWITCH_SETTINGS_ENABLE_DPR_SWITCHES | 282 + WCD_USBSS_SWITCH_SETTINGS_ENABLE_DNL_SWITCHES | 283 + WCD_USBSS_SWITCH_SETTINGS_ENABLE_SENSE_SWITCHES | 284 + WCD_USBSS_SWITCH_SETTINGS_ENABLE_MIC_SWITCHES | 285 + WCD_USBSS_SWITCH_SETTINGS_ENABLE_AGND_SWITCHES); 286 + if (ret) 287 + return ret; 288 + 289 + /* Clear switches */ 290 + ret = regmap_clear_bits(usbss->regmap, WCD_USBSS_SWITCH_SELECT0, 291 + WCD_USBSS_SWITCH_SELECT0_DP_AUXP_SWITCHES | 292 + WCD_USBSS_SWITCH_SELECT0_DP_AUXM_SWITCHES | 293 + WCD_USBSS_SWITCH_SELECT0_DPR_SWITCHES | 294 + WCD_USBSS_SWITCH_SELECT0_DNL_SWITCHES | 295 + WCD_USBSS_SWITCH_SELECT0_SENSE_SWITCHES | 296 + WCD_USBSS_SWITCH_SELECT0_MIC_SWITCHES); 297 + if (ret) 298 + return ret; 299 + 300 + ret = regmap_clear_bits(usbss->regmap, WCD_USBSS_SWITCH_SELECT1, 301 + WCD_USBSS_SWITCH_SELECT1_AGND_SWITCHES); 302 + if (ret) 303 + return ret; 304 + 305 + /* Enable OVP_MG1_BIAS PCOMP_DYN_BST_EN */ 306 + ret = regmap_set_bits(usbss->regmap, WCD_USBSS_MG1_BIAS, 307 + WCD_USBSS_MG1_BIAS_PCOMP_DYN_BST_EN); 308 + if (ret) 309 + return ret; 310 + 311 + /* Enable OVP_MG2_BIAS PCOMP_DYN_BST_EN */ 312 + ret = regmap_set_bits(usbss->regmap, WCD_USBSS_MG2_BIAS, 313 + WCD_USBSS_MG2_BIAS_PCOMP_DYN_BST_EN); 314 + if (ret) 315 + return ret; 316 + 317 + /* Disable Equalizer in safe mode */ 318 + ret = regmap_clear_bits(usbss->regmap, WCD_USBSS_EQUALIZER1, 319 + WCD_USBSS_EQUALIZER1_EQ_EN); 320 + if (ret) 321 + return ret; 322 + 323 + /* Start FSM with all disabled, force write */ 324 + ret = regmap_write_bits(usbss->regmap, WCD_USBSS_AUDIO_FSM_START, 325 + WCD_USBSS_AUDIO_FSM_START_AUDIO_FSM_AUDIO_TRIG, 326 + WCD_USBSS_AUDIO_FSM_START_AUDIO_FSM_AUDIO_TRIG); 327 + 328 + /* 35us to allow the SBU switch to turn off */ 329 + usleep_range(35, 1000); 330 + 331 + /* Setup Audio Accessory mux/switch */ 332 + if (enable_audio) { 333 + int i; 334 + 335 + /* 336 + * AATC switch configuration: 337 + * "Normal": 338 + * - R: DNR 339 + * - L: DNL 340 + * - Sense: GSBU2 341 + * - Mic: MG1 342 + * - AGND: MG2 343 + * "Swapped": 344 + * - R: DNR 345 + * - L: DNL 346 + * - Sense: GSBU1 347 + * - Mic: MG2 348 + * - AGND: MG1 349 + * Swapped information is given by the codec MBHC logic 350 + */ 351 + 352 + /* Set AATC mode */ 353 + ret = regmap_update_bits(usbss->regmap, WCD_USBSS_USB_SS_CNTL, 354 + WCD_USBSS_USB_SS_CNTL_USB_SS_MODE, 355 + FIELD_PREP(WCD_USBSS_USB_SS_CNTL_USB_SS_MODE, 356 + WCD_USBSS_USB_SS_CNTL_USB_SS_MODE_AATC)); 357 + if (ret) 358 + return ret; 359 + 360 + /* Select L for DNL_SWITCHES and R for DPR_SWITCHES */ 361 + ret = regmap_update_bits(usbss->regmap, WCD_USBSS_SWITCH_SELECT0, 362 + WCD_USBSS_SWITCH_SELECT0_DPR_SWITCHES | 363 + WCD_USBSS_SWITCH_SELECT0_DNL_SWITCHES, 364 + FIELD_PREP(WCD_USBSS_SWITCH_SELECT0_DNL_SWITCHES, 365 + WCD_USBSS_SWITCH_SELECT0_DNL_SWITCH_L) | 366 + FIELD_PREP(WCD_USBSS_SWITCH_SELECT0_DPR_SWITCHES, 367 + WCD_USBSS_SWITCH_SELECT0_DPR_SWITCH_R)); 368 + if (ret) 369 + return ret; 370 + 371 + if (reverse) 372 + /* Select MG2 for MIC, SBU1 for Sense */ 373 + ret = regmap_update_bits(usbss->regmap, WCD_USBSS_SWITCH_SELECT0, 374 + WCD_USBSS_SWITCH_SELECT0_MIC_SWITCHES, 375 + WCD_USBSS_SWITCH_SELECT0_MIC_SWITCHES); 376 + else 377 + /* Select MG1 for MIC, SBU2 for Sense */ 378 + ret = regmap_update_bits(usbss->regmap, WCD_USBSS_SWITCH_SELECT0, 379 + WCD_USBSS_SWITCH_SELECT0_SENSE_SWITCHES, 380 + WCD_USBSS_SWITCH_SELECT0_SENSE_SWITCHES); 381 + if (ret) 382 + return ret; 383 + 384 + if (reverse) 385 + /* Disable OVP_MG1_BIAS PCOMP_DYN_BST_EN */ 386 + ret = regmap_clear_bits(usbss->regmap, WCD_USBSS_MG1_BIAS, 387 + WCD_USBSS_MG1_BIAS_PCOMP_DYN_BST_EN); 388 + else 389 + /* Disable OVP_MG2_BIAS PCOMP_DYN_BST_EN */ 390 + ret = regmap_clear_bits(usbss->regmap, WCD_USBSS_MG2_BIAS, 391 + WCD_USBSS_MG2_BIAS_PCOMP_DYN_BST_EN); 392 + if (ret) 393 + return ret; 394 + 395 + /* Enable SENSE, MIC switches */ 396 + ret = regmap_set_bits(usbss->regmap, WCD_USBSS_SWITCH_SETTINGS_ENABLE, 397 + WCD_USBSS_SWITCH_SETTINGS_ENABLE_SENSE_SWITCHES | 398 + WCD_USBSS_SWITCH_SETTINGS_ENABLE_MIC_SWITCHES); 399 + if (ret) 400 + return ret; 401 + 402 + if (reverse) 403 + /* Select MG1 for AGND_SWITCHES */ 404 + ret = regmap_clear_bits(usbss->regmap, WCD_USBSS_SWITCH_SELECT1, 405 + WCD_USBSS_SWITCH_SELECT1_AGND_SWITCHES); 406 + else 407 + /* Select MG2 for AGND_SWITCHES */ 408 + ret = regmap_set_bits(usbss->regmap, WCD_USBSS_SWITCH_SELECT1, 409 + WCD_USBSS_SWITCH_SELECT1_AGND_SWITCHES); 410 + if (ret) 411 + return ret; 412 + 413 + /* Enable AGND switches */ 414 + ret = regmap_set_bits(usbss->regmap, WCD_USBSS_SWITCH_SETTINGS_ENABLE, 415 + WCD_USBSS_SWITCH_SETTINGS_ENABLE_AGND_SWITCHES); 416 + if (ret) 417 + return ret; 418 + 419 + /* Enable DPR, DNL switches */ 420 + ret = regmap_set_bits(usbss->regmap, WCD_USBSS_SWITCH_SETTINGS_ENABLE, 421 + WCD_USBSS_SWITCH_SETTINGS_ENABLE_DNL_SWITCHES | 422 + WCD_USBSS_SWITCH_SETTINGS_ENABLE_DPR_SWITCHES); 423 + if (ret) 424 + return ret; 425 + 426 + /* Setup FSM delays */ 427 + ret = regmap_write(usbss->regmap, WCD_USBSS_DELAY_L_SW, 0x02); 428 + if (ret) 429 + return ret; 430 + 431 + ret = regmap_write(usbss->regmap, WCD_USBSS_DELAY_R_SW, 0x02); 432 + if (ret) 433 + return ret; 434 + 435 + ret = regmap_write(usbss->regmap, WCD_USBSS_DELAY_MIC_SW, 0x01); 436 + if (ret) 437 + return ret; 438 + 439 + /* Start FSM, force write */ 440 + ret = regmap_write_bits(usbss->regmap, WCD_USBSS_AUDIO_FSM_START, 441 + WCD_USBSS_AUDIO_FSM_START_AUDIO_FSM_AUDIO_TRIG, 442 + WCD_USBSS_AUDIO_FSM_START_AUDIO_FSM_AUDIO_TRIG); 443 + if (ret) 444 + return ret; 445 + 446 + /* Default Linearlizer coefficients */ 447 + for (i = 0; i < ARRAY_SIZE(wcd939x_usbss_coeff_init); ++i) 448 + regmap_update_bits(usbss->regmap, 449 + wcd939x_usbss_coeff_init[i].offset, 450 + wcd939x_usbss_coeff_init[i].mask, 451 + wcd939x_usbss_coeff_init[i].value); 452 + 453 + return 0; 454 + } 455 + 456 + ret = regmap_update_bits(usbss->regmap, WCD_USBSS_USB_SS_CNTL, 457 + WCD_USBSS_USB_SS_CNTL_USB_SS_MODE, 458 + FIELD_PREP(WCD_USBSS_USB_SS_CNTL_USB_SS_MODE, 459 + WCD_USBSS_USB_SS_CNTL_USB_SS_MODE_USB)); 460 + if (ret) 461 + return ret; 462 + 463 + /* Enable USB muxes */ 464 + if (enable_usb) { 465 + /* Do not enable Equalizer in safe mode */ 466 + if (usbss->mode != TYPEC_STATE_SAFE) { 467 + ret = regmap_set_bits(usbss->regmap, WCD_USBSS_EQUALIZER1, 468 + WCD_USBSS_EQUALIZER1_EQ_EN); 469 + if (ret) 470 + return ret; 471 + } 472 + 473 + /* Select DN for DNL_SWITCHES and DP for DPR_SWITCHES */ 474 + ret = regmap_update_bits(usbss->regmap, WCD_USBSS_SWITCH_SELECT0, 475 + WCD_USBSS_SWITCH_SELECT0_DPR_SWITCHES | 476 + WCD_USBSS_SWITCH_SELECT0_DNL_SWITCHES, 477 + FIELD_PREP(WCD_USBSS_SWITCH_SELECT0_DNL_SWITCHES, 478 + WCD_USBSS_SWITCH_SELECT0_DNL_SWITCH_DN) | 479 + FIELD_PREP(WCD_USBSS_SWITCH_SELECT0_DPR_SWITCHES, 480 + WCD_USBSS_SWITCH_SELECT0_DPR_SWITCH_DP)); 481 + if (ret) 482 + return ret; 483 + 484 + /* Enable DNL_SWITCHES and DPR_SWITCHES */ 485 + ret = regmap_set_bits(usbss->regmap, WCD_USBSS_SWITCH_SETTINGS_ENABLE, 486 + WCD_USBSS_SWITCH_SETTINGS_ENABLE_DPR_SWITCHES | 487 + WCD_USBSS_SWITCH_SETTINGS_ENABLE_DNL_SWITCHES); 488 + if (ret) 489 + return ret; 490 + } 491 + 492 + /* Enable DP AUX muxes */ 493 + if (enable_dp) { 494 + /* Update Leakage Canceller Coefficient for AUXP pins */ 495 + ret = regmap_update_bits(usbss->regmap, WCD_USBSS_DISP_AUXP_CTL, 496 + WCD_USBSS_DISP_AUXP_CTL_LK_CANCEL_TRK_COEFF, 497 + FIELD_PREP(WCD_USBSS_DISP_AUXP_CTL_LK_CANCEL_TRK_COEFF, 498 + 5)); 499 + if (ret) 500 + return ret; 501 + 502 + ret = regmap_set_bits(usbss->regmap, WCD_USBSS_DISP_AUXP_THRESH, 503 + WCD_USBSS_DISP_AUXP_THRESH_DISP_AUXP_OVPON_CM); 504 + if (ret) 505 + return ret; 506 + 507 + if (reverse) 508 + /* Select MG2 for AUXP and MG1 for AUXM */ 509 + ret = regmap_update_bits(usbss->regmap, WCD_USBSS_SWITCH_SELECT0, 510 + WCD_USBSS_SWITCH_SELECT0_DP_AUXP_SWITCHES | 511 + WCD_USBSS_SWITCH_SELECT0_DP_AUXM_SWITCHES, 512 + WCD_USBSS_SWITCH_SELECT0_DP_AUXP_SWITCHES); 513 + else 514 + /* Select MG1 for AUXP and MG2 for AUXM */ 515 + ret = regmap_update_bits(usbss->regmap, WCD_USBSS_SWITCH_SELECT0, 516 + WCD_USBSS_SWITCH_SELECT0_DP_AUXP_SWITCHES | 517 + WCD_USBSS_SWITCH_SELECT0_DP_AUXM_SWITCHES, 518 + WCD_USBSS_SWITCH_SELECT0_DP_AUXM_SWITCHES); 519 + if (ret) 520 + return ret; 521 + 522 + /* Enable DP_AUXP_TO_MGX and DP_AUXM_TO_MGX switches */ 523 + ret = regmap_set_bits(usbss->regmap, WCD_USBSS_SWITCH_SETTINGS_ENABLE, 524 + WCD_USBSS_SWITCH_SETTINGS_ENABLE_DP_AUXP_TO_MGX_SWITCHES | 525 + WCD_USBSS_SWITCH_SETTINGS_ENABLE_DP_AUXM_TO_MGX_SWITCHES); 526 + 527 + /* 15us to allow the SBU switch to turn on again */ 528 + usleep_range(15, 1000); 529 + } 530 + 531 + return 0; 532 + } 533 + 534 + static int wcd939x_usbss_switch_set(struct typec_switch_dev *sw, 535 + enum typec_orientation orientation) 536 + { 537 + struct wcd939x_usbss *usbss = typec_switch_get_drvdata(sw); 538 + int ret = 0; 539 + 540 + mutex_lock(&usbss->lock); 541 + 542 + if (usbss->orientation != orientation) { 543 + usbss->orientation = orientation; 544 + 545 + ret = wcd939x_usbss_set(usbss); 546 + } 547 + 548 + mutex_unlock(&usbss->lock); 549 + 550 + if (ret) 551 + return ret; 552 + 553 + /* Report orientation to codec after switch has been done */ 554 + return typec_switch_set(usbss->codec_switch, orientation); 555 + } 556 + 557 + static int wcd939x_usbss_mux_set(struct typec_mux_dev *mux, 558 + struct typec_mux_state *state) 559 + { 560 + struct wcd939x_usbss *usbss = typec_mux_get_drvdata(mux); 561 + int ret = 0; 562 + 563 + mutex_lock(&usbss->lock); 564 + 565 + if (usbss->mode != state->mode) { 566 + usbss->mode = state->mode; 567 + 568 + if (state->alt) 569 + usbss->svid = state->alt->svid; 570 + else 571 + usbss->svid = 0; // No SVID 572 + 573 + ret = wcd939x_usbss_set(usbss); 574 + } 575 + 576 + mutex_unlock(&usbss->lock); 577 + 578 + if (ret) 579 + return ret; 580 + 581 + /* Report event to codec after switch has been done */ 582 + return typec_mux_set(usbss->codec, state); 583 + } 584 + 585 + static int wcd939x_usbss_probe(struct i2c_client *client) 586 + { 587 + struct device *dev = &client->dev; 588 + struct typec_switch_desc sw_desc = { }; 589 + struct typec_mux_desc mux_desc = { }; 590 + struct wcd939x_usbss *usbss; 591 + int ret; 592 + 593 + usbss = devm_kzalloc(dev, sizeof(*usbss), GFP_KERNEL); 594 + if (!usbss) 595 + return -ENOMEM; 596 + 597 + usbss->client = client; 598 + mutex_init(&usbss->lock); 599 + 600 + usbss->regmap = devm_regmap_init_i2c(client, &wcd939x_usbss_regmap_config); 601 + if (IS_ERR(usbss->regmap)) 602 + return dev_err_probe(dev, PTR_ERR(usbss->regmap), "failed to initialize regmap\n"); 603 + 604 + usbss->reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW); 605 + if (IS_ERR(usbss->reset_gpio)) 606 + return dev_err_probe(dev, PTR_ERR(usbss->reset_gpio), 607 + "unable to acquire reset gpio\n"); 608 + 609 + usbss->vdd_supply = devm_regulator_get_optional(dev, "vdd"); 610 + if (IS_ERR(usbss->vdd_supply)) 611 + return PTR_ERR(usbss->vdd_supply); 612 + 613 + /* Get Codec's MUX & Switch devices */ 614 + usbss->codec = fwnode_typec_mux_get(dev->fwnode); 615 + if (IS_ERR(usbss->codec)) 616 + return dev_err_probe(dev, PTR_ERR(usbss->codec), 617 + "failed to acquire codec mode-switch\n"); 618 + 619 + usbss->codec_switch = fwnode_typec_switch_get(dev->fwnode); 620 + if (IS_ERR(usbss->codec_switch)) { 621 + ret = dev_err_probe(dev, PTR_ERR(usbss->codec_switch), 622 + "failed to acquire codec orientation-switch\n"); 623 + goto err_mux_put; 624 + } 625 + 626 + usbss->mode = TYPEC_STATE_SAFE; 627 + usbss->orientation = TYPEC_ORIENTATION_NONE; 628 + 629 + gpiod_set_value(usbss->reset_gpio, 1); 630 + 631 + ret = regulator_enable(usbss->vdd_supply); 632 + if (ret) { 633 + dev_err(dev, "Failed to enable vdd: %d\n", ret); 634 + goto err_mux_switch; 635 + } 636 + 637 + msleep(20); 638 + 639 + gpiod_set_value(usbss->reset_gpio, 0); 640 + 641 + msleep(20); 642 + 643 + /* Disable standby */ 644 + ret = regmap_clear_bits(usbss->regmap, WCD_USBSS_USB_SS_CNTL, 645 + WCD_USBSS_USB_SS_CNTL_STANDBY_STATE); 646 + if (ret) 647 + goto err_regulator_disable; 648 + 649 + /* Set manual mode by default */ 650 + ret = regmap_update_bits(usbss->regmap, WCD_USBSS_FUNCTION_ENABLE, 651 + WCD_USBSS_FUNCTION_ENABLE_SOURCE_SELECT, 652 + FIELD_PREP(WCD_USBSS_FUNCTION_ENABLE_SOURCE_SELECT, 653 + WCD_USBSS_FUNCTION_ENABLE_SOURCE_SELECT_MANUAL)); 654 + if (ret) 655 + goto err_regulator_disable; 656 + 657 + /* Enable dynamic boosting for DP and DN */ 658 + ret = regmap_set_bits(usbss->regmap, WCD_USBSS_DP_DN_MISC1, 659 + WCD_USBSS_DP_DN_MISC1_DP_PCOMP_2X_DYN_BST_ON_EN | 660 + WCD_USBSS_DP_DN_MISC1_DN_PCOMP_2X_DYN_BST_ON_EN); 661 + if (ret) 662 + goto err_regulator_disable; 663 + 664 + /* Enable dynamic boosting for MG1 OVP */ 665 + ret = regmap_set_bits(usbss->regmap, WCD_USBSS_MG1_MISC, 666 + WCD_USBSS_MG1_MISC_PCOMP_2X_DYN_BST_ON_EN); 667 + if (ret) 668 + goto err_regulator_disable; 669 + 670 + /* Enable dynamic boosting for MG2 OVP */ 671 + ret = regmap_set_bits(usbss->regmap, WCD_USBSS_MG2_MISC, 672 + WCD_USBSS_MG2_MISC_PCOMP_2X_DYN_BST_ON_EN); 673 + if (ret) 674 + goto err_regulator_disable; 675 + 676 + /* Write 0xFF to WCD_USBSS_CPLDO_CTL2 */ 677 + ret = regmap_set_bits(usbss->regmap, WCD_USBSS_CPLDO_CTL2, 0xff); 678 + if (ret) 679 + goto err_regulator_disable; 680 + 681 + /* Set RCO_EN: WCD_USBSS_USB_SS_CNTL Bit<3> --> 0x0 --> 0x1 */ 682 + ret = regmap_clear_bits(usbss->regmap, WCD_USBSS_USB_SS_CNTL, 683 + WCD_USBSS_USB_SS_CNTL_RCO_EN); 684 + if (ret) 685 + goto err_regulator_disable; 686 + 687 + ret = regmap_set_bits(usbss->regmap, WCD_USBSS_USB_SS_CNTL, 688 + WCD_USBSS_USB_SS_CNTL_RCO_EN); 689 + if (ret) 690 + goto err_regulator_disable; 691 + 692 + /* Disable all switches but enable the mux */ 693 + ret = regmap_write(usbss->regmap, WCD_USBSS_SWITCH_SETTINGS_ENABLE, 694 + WCD_USBSS_SWITCH_SETTINGS_ENABLE_DEVICE_ENABLE); 695 + if (ret) 696 + goto err_regulator_disable; 697 + 698 + /* Setup in SAFE mode */ 699 + ret = wcd939x_usbss_set(usbss); 700 + if (ret) 701 + goto err_regulator_disable; 702 + 703 + sw_desc.drvdata = usbss; 704 + sw_desc.fwnode = dev_fwnode(dev); 705 + sw_desc.set = wcd939x_usbss_switch_set; 706 + 707 + usbss->sw = typec_switch_register(dev, &sw_desc); 708 + if (IS_ERR(usbss->sw)) { 709 + ret = dev_err_probe(dev, PTR_ERR(usbss->sw), "failed to register typec switch\n"); 710 + goto err_regulator_disable; 711 + } 712 + 713 + mux_desc.drvdata = usbss; 714 + mux_desc.fwnode = dev_fwnode(dev); 715 + mux_desc.set = wcd939x_usbss_mux_set; 716 + 717 + usbss->mux = typec_mux_register(dev, &mux_desc); 718 + if (IS_ERR(usbss->mux)) { 719 + ret = dev_err_probe(dev, PTR_ERR(usbss->mux), "failed to register typec mux\n"); 720 + goto err_switch_unregister; 721 + } 722 + 723 + i2c_set_clientdata(client, usbss); 724 + 725 + return 0; 726 + 727 + err_switch_unregister: 728 + typec_switch_unregister(usbss->sw); 729 + 730 + err_regulator_disable: 731 + regulator_disable(usbss->vdd_supply); 732 + 733 + err_mux_switch: 734 + typec_switch_put(usbss->codec_switch); 735 + 736 + err_mux_put: 737 + typec_mux_put(usbss->codec); 738 + 739 + return ret; 740 + } 741 + 742 + static void wcd939x_usbss_remove(struct i2c_client *client) 743 + { 744 + struct wcd939x_usbss *usbss = i2c_get_clientdata(client); 745 + 746 + typec_mux_unregister(usbss->mux); 747 + typec_switch_unregister(usbss->sw); 748 + 749 + regulator_disable(usbss->vdd_supply); 750 + 751 + typec_switch_put(usbss->codec_switch); 752 + typec_mux_put(usbss->codec); 753 + } 754 + 755 + static const struct i2c_device_id wcd939x_usbss_table[] = { 756 + { "wcd9390-usbss" }, 757 + { } 758 + }; 759 + MODULE_DEVICE_TABLE(i2c, wcd939x_usbss_table); 760 + 761 + static const struct of_device_id wcd939x_usbss_of_table[] = { 762 + { .compatible = "qcom,wcd9390-usbss" }, 763 + { } 764 + }; 765 + MODULE_DEVICE_TABLE(of, wcd939x_usbss_of_table); 766 + 767 + static struct i2c_driver wcd939x_usbss_driver = { 768 + .driver = { 769 + .name = "wcd939x-usbss", 770 + .of_match_table = wcd939x_usbss_of_table, 771 + }, 772 + .probe = wcd939x_usbss_probe, 773 + .remove = wcd939x_usbss_remove, 774 + .id_table = wcd939x_usbss_table, 775 + }; 776 + module_i2c_driver(wcd939x_usbss_driver); 777 + 778 + MODULE_DESCRIPTION("Qualcomm WCD939x USBSS driver"); 779 + MODULE_LICENSE("GPL");
+3 -3
drivers/usb/typec/pd.c
··· 468 468 /** 469 469 * usb_power_delivery_register_capabilities - Register a set of capabilities. 470 470 * @pd: The USB PD instance that the capabilities belong to. 471 - * @desc: Description of the Capablities Message. 471 + * @desc: Description of the Capabilities Message. 472 472 * 473 473 * This function registers a Capabilities Message described in @desc. The 474 474 * capabilities will have their own sub-directory under @pd in sysfs. ··· 571 571 { 572 572 struct usb_power_delivery *pd = to_usb_power_delivery(dev); 573 573 574 - ida_simple_remove(&pd_ida, pd->id); 574 + ida_free(&pd_ida, pd->id); 575 575 kfree(pd); 576 576 } 577 577 ··· 616 616 if (!pd) 617 617 return ERR_PTR(-ENOMEM); 618 618 619 - ret = ida_simple_get(&pd_ida, 0, 0, GFP_KERNEL); 619 + ret = ida_alloc(&pd_ida, GFP_KERNEL); 620 620 if (ret < 0) { 621 621 kfree(pd); 622 622 return ERR_PTR(ret);
+19 -1
drivers/usb/typec/tcpm/tcpci_maxim_core.c
··· 92 92 return; 93 93 } 94 94 95 + /* Vconn Over Current Protection */ 96 + ret = max_tcpci_write8(chip, TCPC_FAULT_STATUS_MASK, TCPC_FAULT_STATUS_MASK_VCONN_OC); 97 + if (ret < 0) 98 + return; 99 + 95 100 alert_mask = TCPC_ALERT_TX_SUCCESS | TCPC_ALERT_TX_DISCARDED | TCPC_ALERT_TX_FAILED | 96 101 TCPC_ALERT_RX_HARD_RST | TCPC_ALERT_RX_STATUS | TCPC_ALERT_CC_STATUS | 97 102 TCPC_ALERT_VBUS_DISCNCT | TCPC_ALERT_RX_BUF_OVF | TCPC_ALERT_POWER_STATUS | 98 103 /* Enable Extended alert for detecting Fast Role Swap Signal */ 99 - TCPC_ALERT_EXTND | TCPC_ALERT_EXTENDED_STATUS; 104 + TCPC_ALERT_EXTND | TCPC_ALERT_EXTENDED_STATUS | TCPC_ALERT_FAULT; 100 105 101 106 ret = max_tcpci_write16(chip, TCPC_ALERT_MASK, alert_mask); 102 107 if (ret < 0) { ··· 298 293 dev_err(chip->dev, "ALERT clear failed\n"); 299 294 return ret; 300 295 } 296 + } 297 + 298 + if (status & TCPC_ALERT_FAULT) { 299 + ret = max_tcpci_read8(chip, TCPC_FAULT_STATUS, &reg_status); 300 + if (ret < 0) 301 + return ret; 302 + 303 + ret = max_tcpci_write8(chip, TCPC_FAULT_STATUS, reg_status); 304 + if (ret < 0) 305 + return ret; 306 + 307 + if (reg_status & TCPC_FAULT_STATUS_VCONN_OC) 308 + tcpm_port_error_recovery(chip->port); 301 309 } 302 310 303 311 if (status & TCPC_ALERT_EXTND) {
+325 -92
drivers/usb/typec/tcpm/tcpm.c
··· 251 251 #define TCPM_FRS_EVENT BIT(3) 252 252 #define TCPM_SOURCING_VBUS BIT(4) 253 253 #define TCPM_PORT_CLEAN BIT(5) 254 + #define TCPM_PORT_ERROR BIT(6) 254 255 255 256 #define LOG_BUFFER_ENTRIES 1024 256 257 #define LOG_BUFFER_ENTRY_SIZE 128 ··· 295 294 u32 req_op_curr; 296 295 bool supported; 297 296 bool active; 297 + }; 298 + 299 + struct pd_data { 300 + struct usb_power_delivery *pd; 301 + struct usb_power_delivery_capabilities *source_cap; 302 + struct usb_power_delivery_capabilities_desc source_desc; 303 + struct usb_power_delivery_capabilities *sink_cap; 304 + struct usb_power_delivery_capabilities_desc sink_desc; 305 + unsigned int operating_snk_mw; 298 306 }; 299 307 300 308 struct tcpm_port { ··· 407 397 unsigned int rx_msgid; 408 398 409 399 /* USB PD objects */ 410 - struct usb_power_delivery *pd; 400 + struct usb_power_delivery **pds; 401 + struct pd_data **pd_list; 411 402 struct usb_power_delivery_capabilities *port_source_caps; 412 403 struct usb_power_delivery_capabilities *port_sink_caps; 413 404 struct usb_power_delivery *partner_pd; 414 405 struct usb_power_delivery_capabilities *partner_source_caps; 415 406 struct usb_power_delivery_capabilities *partner_sink_caps; 407 + struct usb_power_delivery *selected_pd; 416 408 417 409 /* Partner capabilities/requests */ 418 410 u32 sink_request; ··· 424 412 unsigned int nr_sink_caps; 425 413 426 414 /* Local capabilities */ 415 + unsigned int pd_count; 427 416 u32 src_pdo[PDO_MAX_OBJECTS]; 428 417 unsigned int nr_src_pdo; 429 418 u32 snk_pdo[PDO_MAX_OBJECTS]; ··· 2860 2847 PD_MSG_CTRL_NOT_SUPP, 2861 2848 NONE_AMS); 2862 2849 } else { 2863 - if (port->send_discover) { 2850 + if (port->send_discover && port->negotiated_rev < PD_REV30) { 2864 2851 tcpm_queue_message(port, PD_MSG_CTRL_WAIT); 2865 2852 break; 2866 2853 } ··· 2876 2863 PD_MSG_CTRL_NOT_SUPP, 2877 2864 NONE_AMS); 2878 2865 } else { 2879 - if (port->send_discover) { 2866 + if (port->send_discover && port->negotiated_rev < PD_REV30) { 2880 2867 tcpm_queue_message(port, PD_MSG_CTRL_WAIT); 2881 2868 break; 2882 2869 } ··· 2885 2872 } 2886 2873 break; 2887 2874 case PD_CTRL_VCONN_SWAP: 2888 - if (port->send_discover) { 2875 + if (port->send_discover && port->negotiated_rev < PD_REV30) { 2889 2876 tcpm_queue_message(port, PD_MSG_CTRL_WAIT); 2890 2877 break; 2891 2878 } ··· 4414 4401 tcpm_set_current_limit(port, tcpm_get_current_limit(port), 5000); 4415 4402 tcpm_swap_complete(port, 0); 4416 4403 tcpm_typec_connect(port); 4417 - mod_enable_frs_delayed_work(port, 0); 4404 + if (port->pd_capable && port->source_caps[0] & PDO_FIXED_DUAL_ROLE) 4405 + mod_enable_frs_delayed_work(port, 0); 4418 4406 tcpm_pps_complete(port, port->pps_status); 4419 4407 4420 4408 if (port->ams != NONE_AMS) ··· 5501 5487 tcpm_set_state(port, tcpm_default_state(port), 0); 5502 5488 } 5503 5489 } 5490 + if (events & TCPM_PORT_ERROR) { 5491 + tcpm_log(port, "port triggering error recovery"); 5492 + tcpm_set_state(port, ERROR_RECOVERY, 0); 5493 + } 5504 5494 5505 5495 spin_lock(&port->pd_event_lock); 5506 5496 } ··· 5571 5553 return port->port_type == TYPEC_PORT_DRP && port->state == TOGGLING; 5572 5554 } 5573 5555 EXPORT_SYMBOL_GPL(tcpm_port_is_toggling); 5556 + 5557 + void tcpm_port_error_recovery(struct tcpm_port *port) 5558 + { 5559 + spin_lock(&port->pd_event_lock); 5560 + port->pd_events |= TCPM_PORT_ERROR; 5561 + spin_unlock(&port->pd_event_lock); 5562 + kthread_queue_work(port->wq, &port->event_work); 5563 + } 5564 + EXPORT_SYMBOL_GPL(tcpm_port_error_recovery); 5574 5565 5575 5566 static void tcpm_enable_frs_work(struct kthread_work *work) 5576 5567 { ··· 6072 6045 return 0; 6073 6046 } 6074 6047 6048 + static struct pd_data *tcpm_find_pd_data(struct tcpm_port *port, struct usb_power_delivery *pd) 6049 + { 6050 + int i; 6051 + 6052 + for (i = 0; port->pd_list[i]; i++) { 6053 + if (port->pd_list[i]->pd == pd) 6054 + return port->pd_list[i]; 6055 + } 6056 + 6057 + return ERR_PTR(-ENODATA); 6058 + } 6059 + 6060 + static struct usb_power_delivery **tcpm_pd_get(struct typec_port *p) 6061 + { 6062 + struct tcpm_port *port = typec_get_drvdata(p); 6063 + 6064 + return port->pds; 6065 + } 6066 + 6067 + static int tcpm_pd_set(struct typec_port *p, struct usb_power_delivery *pd) 6068 + { 6069 + struct tcpm_port *port = typec_get_drvdata(p); 6070 + struct pd_data *data; 6071 + int i, ret = 0; 6072 + 6073 + mutex_lock(&port->lock); 6074 + 6075 + if (port->selected_pd == pd) 6076 + goto unlock; 6077 + 6078 + data = tcpm_find_pd_data(port, pd); 6079 + if (IS_ERR(data)) { 6080 + ret = PTR_ERR(data); 6081 + goto unlock; 6082 + } 6083 + 6084 + if (data->sink_desc.pdo[0]) { 6085 + for (i = 0; i < PDO_MAX_OBJECTS && data->sink_desc.pdo[i]; i++) 6086 + port->snk_pdo[i] = data->sink_desc.pdo[i]; 6087 + port->nr_snk_pdo = i + 1; 6088 + port->operating_snk_mw = data->operating_snk_mw; 6089 + } 6090 + 6091 + if (data->source_desc.pdo[0]) { 6092 + for (i = 0; i < PDO_MAX_OBJECTS && data->source_desc.pdo[i]; i++) 6093 + port->snk_pdo[i] = data->source_desc.pdo[i]; 6094 + port->nr_src_pdo = i + 1; 6095 + } 6096 + 6097 + switch (port->state) { 6098 + case SRC_UNATTACHED: 6099 + case SRC_ATTACH_WAIT: 6100 + case SRC_TRYWAIT: 6101 + tcpm_set_cc(port, tcpm_rp_cc(port)); 6102 + break; 6103 + case SRC_SEND_CAPABILITIES: 6104 + case SRC_SEND_CAPABILITIES_TIMEOUT: 6105 + case SRC_NEGOTIATE_CAPABILITIES: 6106 + case SRC_READY: 6107 + case SRC_WAIT_NEW_CAPABILITIES: 6108 + port->caps_count = 0; 6109 + port->upcoming_state = SRC_SEND_CAPABILITIES; 6110 + ret = tcpm_ams_start(port, POWER_NEGOTIATION); 6111 + if (ret == -EAGAIN) { 6112 + port->upcoming_state = INVALID_STATE; 6113 + goto unlock; 6114 + } 6115 + break; 6116 + case SNK_NEGOTIATE_CAPABILITIES: 6117 + case SNK_NEGOTIATE_PPS_CAPABILITIES: 6118 + case SNK_READY: 6119 + case SNK_TRANSITION_SINK: 6120 + case SNK_TRANSITION_SINK_VBUS: 6121 + if (port->pps_data.active) 6122 + port->upcoming_state = SNK_NEGOTIATE_PPS_CAPABILITIES; 6123 + else if (port->pd_capable) 6124 + port->upcoming_state = SNK_NEGOTIATE_CAPABILITIES; 6125 + else 6126 + break; 6127 + 6128 + port->update_sink_caps = true; 6129 + 6130 + ret = tcpm_ams_start(port, POWER_NEGOTIATION); 6131 + if (ret == -EAGAIN) { 6132 + port->upcoming_state = INVALID_STATE; 6133 + goto unlock; 6134 + } 6135 + break; 6136 + default: 6137 + break; 6138 + } 6139 + 6140 + port->port_source_caps = data->source_cap; 6141 + port->port_sink_caps = data->sink_cap; 6142 + port->selected_pd = pd; 6143 + unlock: 6144 + mutex_unlock(&port->lock); 6145 + return ret; 6146 + } 6147 + 6075 6148 static const struct typec_operations tcpm_ops = { 6076 6149 .try_role = tcpm_try_role, 6077 6150 .dr_set = tcpm_dr_set, 6078 6151 .pr_set = tcpm_pr_set, 6079 6152 .vconn_set = tcpm_vconn_set, 6080 - .port_type_set = tcpm_port_type_set 6153 + .port_type_set = tcpm_port_type_set, 6154 + .pd_get = tcpm_pd_get, 6155 + .pd_set = tcpm_pd_set 6081 6156 }; 6082 6157 6083 6158 void tcpm_tcpc_reset(struct tcpm_port *port) ··· 6193 6064 6194 6065 static void tcpm_port_unregister_pd(struct tcpm_port *port) 6195 6066 { 6196 - usb_power_delivery_unregister_capabilities(port->port_sink_caps); 6067 + int i; 6068 + 6197 6069 port->port_sink_caps = NULL; 6198 - usb_power_delivery_unregister_capabilities(port->port_source_caps); 6199 6070 port->port_source_caps = NULL; 6200 - usb_power_delivery_unregister(port->pd); 6201 - port->pd = NULL; 6071 + for (i = 0; i < port->pd_count; i++) { 6072 + usb_power_delivery_unregister_capabilities(port->pd_list[i]->sink_cap); 6073 + kfree(port->pd_list[i]->sink_cap); 6074 + usb_power_delivery_unregister_capabilities(port->pd_list[i]->source_cap); 6075 + kfree(port->pd_list[i]->source_cap); 6076 + devm_kfree(port->dev, port->pd_list[i]); 6077 + port->pd_list[i] = NULL; 6078 + usb_power_delivery_unregister(port->pds[i]); 6079 + port->pds[i] = NULL; 6080 + } 6202 6081 } 6203 6082 6204 6083 static int tcpm_port_register_pd(struct tcpm_port *port) 6205 6084 { 6206 6085 struct usb_power_delivery_desc desc = { port->typec_caps.pd_revision }; 6207 - struct usb_power_delivery_capabilities_desc caps = { }; 6208 6086 struct usb_power_delivery_capabilities *cap; 6209 - int ret; 6087 + int ret, i; 6210 6088 6211 6089 if (!port->nr_src_pdo && !port->nr_snk_pdo) 6212 6090 return 0; 6213 6091 6214 - port->pd = usb_power_delivery_register(port->dev, &desc); 6215 - if (IS_ERR(port->pd)) { 6216 - ret = PTR_ERR(port->pd); 6217 - goto err_unregister; 6218 - } 6219 - 6220 - if (port->nr_src_pdo) { 6221 - memcpy_and_pad(caps.pdo, sizeof(caps.pdo), port->src_pdo, 6222 - port->nr_src_pdo * sizeof(u32), 0); 6223 - caps.role = TYPEC_SOURCE; 6224 - 6225 - cap = usb_power_delivery_register_capabilities(port->pd, &caps); 6226 - if (IS_ERR(cap)) { 6227 - ret = PTR_ERR(cap); 6092 + for (i = 0; i < port->pd_count; i++) { 6093 + port->pds[i] = usb_power_delivery_register(port->dev, &desc); 6094 + if (IS_ERR(port->pds[i])) { 6095 + ret = PTR_ERR(port->pds[i]); 6228 6096 goto err_unregister; 6229 6097 } 6098 + port->pd_list[i]->pd = port->pds[i]; 6230 6099 6231 - port->port_source_caps = cap; 6232 - } 6233 - 6234 - if (port->nr_snk_pdo) { 6235 - memcpy_and_pad(caps.pdo, sizeof(caps.pdo), port->snk_pdo, 6236 - port->nr_snk_pdo * sizeof(u32), 0); 6237 - caps.role = TYPEC_SINK; 6238 - 6239 - cap = usb_power_delivery_register_capabilities(port->pd, &caps); 6240 - if (IS_ERR(cap)) { 6241 - ret = PTR_ERR(cap); 6242 - goto err_unregister; 6100 + if (port->pd_list[i]->source_desc.pdo[0]) { 6101 + cap = usb_power_delivery_register_capabilities(port->pds[i], 6102 + &port->pd_list[i]->source_desc); 6103 + if (IS_ERR(cap)) { 6104 + ret = PTR_ERR(cap); 6105 + goto err_unregister; 6106 + } 6107 + port->pd_list[i]->source_cap = cap; 6243 6108 } 6244 6109 6245 - port->port_sink_caps = cap; 6110 + if (port->pd_list[i]->sink_desc.pdo[0]) { 6111 + cap = usb_power_delivery_register_capabilities(port->pds[i], 6112 + &port->pd_list[i]->sink_desc); 6113 + if (IS_ERR(cap)) { 6114 + ret = PTR_ERR(cap); 6115 + goto err_unregister; 6116 + } 6117 + port->pd_list[i]->sink_cap = cap; 6118 + } 6246 6119 } 6247 6120 6121 + port->port_source_caps = port->pd_list[0]->source_cap; 6122 + port->port_sink_caps = port->pd_list[0]->sink_cap; 6123 + port->selected_pd = port->pds[0]; 6248 6124 return 0; 6249 6125 6250 6126 err_unregister: ··· 6258 6124 return ret; 6259 6125 } 6260 6126 6261 - static int tcpm_fw_get_caps(struct tcpm_port *port, 6262 - struct fwnode_handle *fwnode) 6127 + static int tcpm_fw_get_caps(struct tcpm_port *port, struct fwnode_handle *fwnode) 6263 6128 { 6129 + struct fwnode_handle *capabilities, *child, *caps = NULL; 6130 + unsigned int nr_src_pdo, nr_snk_pdo; 6264 6131 const char *opmode_str; 6265 - int ret; 6266 - u32 mw, frs_current; 6132 + u32 *src_pdo, *snk_pdo; 6133 + u32 uw, frs_current; 6134 + int ret = 0, i; 6135 + int mode; 6267 6136 6268 6137 if (!fwnode) 6269 6138 return -EINVAL; ··· 6284 6147 if (ret < 0) 6285 6148 return ret; 6286 6149 6150 + mode = 0; 6151 + 6152 + if (fwnode_property_read_bool(fwnode, "accessory-mode-audio")) 6153 + port->typec_caps.accessory[mode++] = TYPEC_ACCESSORY_AUDIO; 6154 + 6155 + if (fwnode_property_read_bool(fwnode, "accessory-mode-debug")) 6156 + port->typec_caps.accessory[mode++] = TYPEC_ACCESSORY_DEBUG; 6157 + 6287 6158 port->port_type = port->typec_caps.type; 6288 6159 port->pd_supported = !fwnode_property_read_bool(fwnode, "pd-disable"); 6289 - 6290 6160 port->slow_charger_loop = fwnode_property_read_bool(fwnode, "slow-charger-loop"); 6291 - if (port->port_type == TYPEC_PORT_SNK) 6292 - goto sink; 6161 + port->self_powered = fwnode_property_read_bool(fwnode, "self-powered"); 6293 6162 6294 - /* Get Source PDOs for the PD port or Source Rp value for the non-PD port */ 6295 - if (port->pd_supported) { 6296 - ret = fwnode_property_count_u32(fwnode, "source-pdos"); 6297 - if (ret == 0) 6298 - return -EINVAL; 6299 - else if (ret < 0) 6300 - return ret; 6301 - 6302 - port->nr_src_pdo = min(ret, PDO_MAX_OBJECTS); 6303 - ret = fwnode_property_read_u32_array(fwnode, "source-pdos", 6304 - port->src_pdo, port->nr_src_pdo); 6305 - if (ret) 6306 - return ret; 6307 - ret = tcpm_validate_caps(port, port->src_pdo, port->nr_src_pdo); 6308 - if (ret) 6309 - return ret; 6310 - } else { 6163 + if (!port->pd_supported) { 6311 6164 ret = fwnode_property_read_string(fwnode, "typec-power-opmode", &opmode_str); 6312 6165 if (ret) 6313 6166 return ret; ··· 6305 6178 if (ret < 0) 6306 6179 return ret; 6307 6180 port->src_rp = tcpm_pwr_opmode_to_rp(ret); 6181 + return 0; 6308 6182 } 6309 6183 6310 - if (port->port_type == TYPEC_PORT_SRC) 6311 - return 0; 6312 - 6313 - sink: 6314 - port->self_powered = fwnode_property_read_bool(fwnode, "self-powered"); 6315 - 6316 - if (!port->pd_supported) 6317 - return 0; 6318 - 6319 - /* Get sink pdos */ 6320 - ret = fwnode_property_count_u32(fwnode, "sink-pdos"); 6321 - if (ret <= 0) 6322 - return -EINVAL; 6323 - 6324 - port->nr_snk_pdo = min(ret, PDO_MAX_OBJECTS); 6325 - ret = fwnode_property_read_u32_array(fwnode, "sink-pdos", 6326 - port->snk_pdo, port->nr_snk_pdo); 6327 - if ((ret < 0) || tcpm_validate_caps(port, port->snk_pdo, 6328 - port->nr_snk_pdo)) 6329 - return -EINVAL; 6330 - 6331 - if (fwnode_property_read_u32(fwnode, "op-sink-microwatt", &mw) < 0) 6332 - return -EINVAL; 6333 - port->operating_snk_mw = mw / 1000; 6184 + /* The following code are applicable to pd-capable ports, i.e. pd_supported is true. */ 6334 6185 6335 6186 /* FRS can only be supported by DRP ports */ 6336 6187 if (port->port_type == TYPEC_PORT_DRP) { 6337 6188 ret = fwnode_property_read_u32(fwnode, "new-source-frs-typec-current", 6338 6189 &frs_current); 6339 - if (ret >= 0 && frs_current <= FRS_5V_3A) 6190 + if (!ret && frs_current <= FRS_5V_3A) 6340 6191 port->new_source_frs_current = frs_current; 6192 + 6193 + if (ret) 6194 + ret = 0; 6341 6195 } 6196 + 6197 + /* For the backward compatibility, "capabilities" node is optional. */ 6198 + capabilities = fwnode_get_named_child_node(fwnode, "capabilities"); 6199 + if (!capabilities) { 6200 + port->pd_count = 1; 6201 + } else { 6202 + fwnode_for_each_child_node(capabilities, child) 6203 + port->pd_count++; 6204 + 6205 + if (!port->pd_count) { 6206 + ret = -ENODATA; 6207 + goto put_capabilities; 6208 + } 6209 + } 6210 + 6211 + port->pds = devm_kcalloc(port->dev, port->pd_count, sizeof(struct usb_power_delivery *), 6212 + GFP_KERNEL); 6213 + if (!port->pds) { 6214 + ret = -ENOMEM; 6215 + goto put_capabilities; 6216 + } 6217 + 6218 + port->pd_list = devm_kcalloc(port->dev, port->pd_count, sizeof(struct pd_data *), 6219 + GFP_KERNEL); 6220 + if (!port->pd_list) { 6221 + ret = -ENOMEM; 6222 + goto put_capabilities; 6223 + } 6224 + 6225 + for (i = 0; i < port->pd_count; i++) { 6226 + port->pd_list[i] = devm_kzalloc(port->dev, sizeof(struct pd_data), GFP_KERNEL); 6227 + if (!port->pd_list[i]) { 6228 + ret = -ENOMEM; 6229 + goto put_capabilities; 6230 + } 6231 + 6232 + src_pdo = port->pd_list[i]->source_desc.pdo; 6233 + port->pd_list[i]->source_desc.role = TYPEC_SOURCE; 6234 + snk_pdo = port->pd_list[i]->sink_desc.pdo; 6235 + port->pd_list[i]->sink_desc.role = TYPEC_SINK; 6236 + 6237 + /* If "capabilities" is NULL, fall back to single pd cap population. */ 6238 + if (!capabilities) 6239 + caps = fwnode; 6240 + else 6241 + caps = fwnode_get_next_child_node(capabilities, caps); 6242 + 6243 + if (port->port_type != TYPEC_PORT_SNK) { 6244 + ret = fwnode_property_count_u32(caps, "source-pdos"); 6245 + if (ret == 0) { 6246 + ret = -EINVAL; 6247 + goto put_caps; 6248 + } 6249 + if (ret < 0) 6250 + goto put_caps; 6251 + 6252 + nr_src_pdo = min(ret, PDO_MAX_OBJECTS); 6253 + ret = fwnode_property_read_u32_array(caps, "source-pdos", src_pdo, 6254 + nr_src_pdo); 6255 + if (ret) 6256 + goto put_caps; 6257 + 6258 + ret = tcpm_validate_caps(port, src_pdo, nr_src_pdo); 6259 + if (ret) 6260 + goto put_caps; 6261 + 6262 + if (i == 0) { 6263 + port->nr_src_pdo = nr_src_pdo; 6264 + memcpy_and_pad(port->src_pdo, sizeof(u32) * PDO_MAX_OBJECTS, 6265 + port->pd_list[0]->source_desc.pdo, 6266 + sizeof(u32) * nr_src_pdo, 6267 + 0); 6268 + } 6269 + } 6270 + 6271 + if (port->port_type != TYPEC_PORT_SRC) { 6272 + ret = fwnode_property_count_u32(caps, "sink-pdos"); 6273 + if (ret == 0) { 6274 + ret = -EINVAL; 6275 + goto put_caps; 6276 + } 6277 + 6278 + if (ret < 0) 6279 + goto put_caps; 6280 + 6281 + nr_snk_pdo = min(ret, PDO_MAX_OBJECTS); 6282 + ret = fwnode_property_read_u32_array(caps, "sink-pdos", snk_pdo, 6283 + nr_snk_pdo); 6284 + if (ret) 6285 + goto put_caps; 6286 + 6287 + ret = tcpm_validate_caps(port, snk_pdo, nr_snk_pdo); 6288 + if (ret) 6289 + goto put_caps; 6290 + 6291 + if (fwnode_property_read_u32(caps, "op-sink-microwatt", &uw) < 0) { 6292 + ret = -EINVAL; 6293 + goto put_caps; 6294 + } 6295 + 6296 + port->pd_list[i]->operating_snk_mw = uw / 1000; 6297 + 6298 + if (i == 0) { 6299 + port->nr_snk_pdo = nr_snk_pdo; 6300 + memcpy_and_pad(port->snk_pdo, sizeof(u32) * PDO_MAX_OBJECTS, 6301 + port->pd_list[0]->sink_desc.pdo, 6302 + sizeof(u32) * nr_snk_pdo, 6303 + 0); 6304 + port->operating_snk_mw = port->pd_list[0]->operating_snk_mw; 6305 + } 6306 + } 6307 + } 6308 + 6309 + put_caps: 6310 + if (caps != fwnode) 6311 + fwnode_handle_put(caps); 6312 + put_capabilities: 6313 + fwnode_handle_put(capabilities); 6314 + return ret; 6315 + } 6316 + 6317 + static int tcpm_fw_get_snk_vdos(struct tcpm_port *port, struct fwnode_handle *fwnode) 6318 + { 6319 + int ret; 6342 6320 6343 6321 /* sink-vdos is optional */ 6344 6322 ret = fwnode_property_count_u32(fwnode, "sink-vdos"); 6345 6323 if (ret < 0) 6346 - ret = 0; 6324 + return 0; 6347 6325 6348 6326 port->nr_snk_vdo = min(ret, VDO_MAX_OBJECTS); 6349 6327 if (port->nr_snk_vdo) { ··· 6816 6584 err = tcpm_fw_get_caps(port, tcpc->fwnode); 6817 6585 if (err < 0) 6818 6586 goto out_destroy_wq; 6587 + err = tcpm_fw_get_snk_vdos(port, tcpc->fwnode); 6588 + if (err < 0) 6589 + goto out_destroy_wq; 6819 6590 6820 6591 port->try_role = port->typec_caps.prefer_role; 6821 6592 6822 - port->typec_caps.fwnode = tcpc->fwnode; 6823 6593 port->typec_caps.revision = 0x0120; /* Type-C spec release 1.2 */ 6824 6594 port->typec_caps.pd_revision = 0x0300; /* USB-PD spec release 3.0 */ 6825 6595 port->typec_caps.svdm_version = SVDM_VER_2_0; ··· 6830 6596 port->typec_caps.orientation_aware = 1; 6831 6597 6832 6598 port->partner_desc.identity = &port->partner_ident; 6833 - port->port_type = port->typec_caps.type; 6834 6599 6835 6600 port->role_sw = usb_role_switch_get(port->dev); 6836 6601 if (!port->role_sw) ··· 6848 6615 if (err) 6849 6616 goto out_role_sw_put; 6850 6617 6851 - port->typec_caps.pd = port->pd; 6618 + port->typec_caps.pd = port->pds[0]; 6852 6619 6853 6620 port->typec_port = typec_register_port(port->dev, &port->typec_caps); 6854 6621 if (IS_ERR(port->typec_port)) {
+155 -22
drivers/usb/typec/tipd/core.c
··· 8 8 9 9 #include <linux/i2c.h> 10 10 #include <linux/acpi.h> 11 + #include <linux/gpio/consumer.h> 11 12 #include <linux/module.h> 12 13 #include <linux/of.h> 13 14 #include <linux/power_supply.h> ··· 65 64 #define TPS_PBMC_RC 0 /* Return code */ 66 65 #define TPS_PBMC_DPCS 2 /* device patch complete status */ 67 66 67 + /* reset de-assertion to ready for operation */ 68 + #define TPS_SETUP_MS 1000 69 + 68 70 enum { 69 71 TPS_PORTINFO_SINK, 70 72 TPS_PORTINFO_SINK_ACCESSORY, ··· 115 111 void (*trace_power_status)(u16 status); 116 112 void (*trace_status)(u32 status); 117 113 int (*apply_patch)(struct tps6598x *tps); 114 + int (*init)(struct tps6598x *tps); 115 + int (*reset)(struct tps6598x *tps); 118 116 }; 119 117 120 118 struct tps6598x { ··· 125 119 struct mutex lock; /* device lock */ 126 120 u8 i2c_protocol:1; 127 121 122 + struct gpio_desc *reset; 128 123 struct typec_port *port; 129 124 struct typec_partner *partner; 130 125 struct usb_pd_identity partner_identity; ··· 330 323 } 331 324 332 325 static int tps6598x_exec_cmd_tmo(struct tps6598x *tps, const char *cmd, 333 - size_t in_len, u8 *in_data, 326 + size_t in_len, const u8 *in_data, 334 327 size_t out_len, u8 *out_data, 335 328 u32 cmd_timeout_ms, u32 res_delay_ms) 336 329 { ··· 396 389 } 397 390 398 391 static int tps6598x_exec_cmd(struct tps6598x *tps, const char *cmd, 399 - size_t in_len, u8 *in_data, 392 + size_t in_len, const u8 *in_data, 400 393 size_t out_len, u8 *out_data) 401 394 { 402 395 return tps6598x_exec_cmd_tmo(tps, cmd, in_len, in_data, ··· 873 866 return 0; 874 867 } 875 868 869 + static int tps_request_firmware(struct tps6598x *tps, const struct firmware **fw) 870 + { 871 + const char *firmware_name; 872 + int ret; 873 + 874 + ret = device_property_read_string(tps->dev, "firmware-name", 875 + &firmware_name); 876 + if (ret) 877 + return ret; 878 + 879 + ret = request_firmware(fw, firmware_name, tps->dev); 880 + if (ret) { 881 + dev_err(tps->dev, "failed to retrieve \"%s\"\n", firmware_name); 882 + return ret; 883 + } 884 + 885 + if ((*fw)->size == 0) { 886 + release_firmware(*fw); 887 + ret = -EINVAL; 888 + } 889 + 890 + return ret; 891 + } 892 + 876 893 static int 877 894 tps25750_write_firmware(struct tps6598x *tps, 878 895 u8 bpms_addr, const u8 *data, size_t len) ··· 985 954 if (ret) 986 955 return ret; 987 956 988 - ret = request_firmware(&fw, firmware_name, tps->dev); 989 - if (ret) { 990 - dev_err(tps->dev, "failed to retrieve \"%s\"\n", firmware_name); 957 + ret = tps_request_firmware(tps, &fw); 958 + if (ret) 991 959 return ret; 992 - } 993 - 994 - if (fw->size == 0) { 995 - ret = -EINVAL; 996 - goto release_fw; 997 - } 998 960 999 961 ret = of_property_match_string(np, "reg-names", "patch-address"); 1000 962 if (ret < 0) { ··· 1125 1101 return 0; 1126 1102 }; 1127 1103 1104 + static int tps6598x_apply_patch(struct tps6598x *tps) 1105 + { 1106 + u8 in = TPS_PTCS_CONTENT_DEV | TPS_PTCS_CONTENT_APP; 1107 + u8 out[TPS_MAX_LEN] = {0}; 1108 + size_t in_len = sizeof(in); 1109 + size_t copied_bytes = 0; 1110 + size_t bytes_left; 1111 + const struct firmware *fw; 1112 + const char *firmware_name; 1113 + int ret; 1114 + 1115 + ret = device_property_read_string(tps->dev, "firmware-name", 1116 + &firmware_name); 1117 + if (ret) 1118 + return ret; 1119 + 1120 + ret = tps_request_firmware(tps, &fw); 1121 + if (ret) 1122 + return ret; 1123 + 1124 + ret = tps6598x_exec_cmd(tps, "PTCs", in_len, &in, 1125 + TPS_PTCS_OUT_BYTES, out); 1126 + if (ret || out[TPS_PTCS_STATUS] == TPS_PTCS_STATUS_FAIL) { 1127 + if (!ret) 1128 + ret = -EBUSY; 1129 + dev_err(tps->dev, "Update start failed (%d)\n", ret); 1130 + goto release_fw; 1131 + } 1132 + 1133 + bytes_left = fw->size; 1134 + while (bytes_left) { 1135 + if (bytes_left < TPS_MAX_LEN) 1136 + in_len = bytes_left; 1137 + else 1138 + in_len = TPS_MAX_LEN; 1139 + ret = tps6598x_exec_cmd(tps, "PTCd", in_len, 1140 + fw->data + copied_bytes, 1141 + TPS_PTCD_OUT_BYTES, out); 1142 + if (ret || out[TPS_PTCD_TRANSFER_STATUS] || 1143 + out[TPS_PTCD_LOADING_STATE] == TPS_PTCD_LOAD_ERR) { 1144 + if (!ret) 1145 + ret = -EBUSY; 1146 + dev_err(tps->dev, "Patch download failed (%d)\n", ret); 1147 + goto release_fw; 1148 + } 1149 + copied_bytes += in_len; 1150 + bytes_left -= in_len; 1151 + } 1152 + 1153 + ret = tps6598x_exec_cmd(tps, "PTCc", 0, NULL, TPS_PTCC_OUT_BYTES, out); 1154 + if (ret || out[TPS_PTCC_DEV] || out[TPS_PTCC_APP]) { 1155 + if (!ret) 1156 + ret = -EBUSY; 1157 + dev_err(tps->dev, "Update completion failed (%d)\n", ret); 1158 + goto release_fw; 1159 + } 1160 + msleep(TPS_SETUP_MS); 1161 + dev_info(tps->dev, "Firmware update succeeded\n"); 1162 + 1163 + release_fw: 1164 + release_firmware(fw); 1165 + 1166 + return ret; 1167 + }; 1168 + 1169 + static int cd321x_init(struct tps6598x *tps) 1170 + { 1171 + return 0; 1172 + } 1173 + 1128 1174 static int tps25750_init(struct tps6598x *tps) 1129 1175 { 1130 1176 int ret; ··· 1210 1116 "%s: failed to enable sleep mode: %d\n", 1211 1117 __func__, ret); 1212 1118 1119 + return 0; 1120 + } 1121 + 1122 + static int tps6598x_init(struct tps6598x *tps) 1123 + { 1124 + return tps->data->apply_patch(tps); 1125 + } 1126 + 1127 + static int cd321x_reset(struct tps6598x *tps) 1128 + { 1129 + return 0; 1130 + } 1131 + 1132 + static int tps25750_reset(struct tps6598x *tps) 1133 + { 1134 + return tps6598x_exec_cmd_tmo(tps, "GAID", 0, NULL, 0, NULL, 2000, 0); 1135 + } 1136 + 1137 + static int tps6598x_reset(struct tps6598x *tps) 1138 + { 1213 1139 return 0; 1214 1140 } 1215 1141 ··· 1296 1182 u32 vid; 1297 1183 int ret; 1298 1184 u64 mask1; 1299 - bool is_tps25750; 1300 1185 1301 1186 tps = devm_kzalloc(&client->dev, sizeof(*tps), GFP_KERNEL); 1302 1187 if (!tps) ··· 1304 1191 mutex_init(&tps->lock); 1305 1192 tps->dev = &client->dev; 1306 1193 1194 + tps->reset = devm_gpiod_get_optional(tps->dev, "reset", GPIOD_OUT_LOW); 1195 + if (IS_ERR(tps->reset)) 1196 + return dev_err_probe(tps->dev, PTR_ERR(tps->reset), 1197 + "failed to get reset GPIO\n"); 1198 + if (tps->reset) 1199 + msleep(TPS_SETUP_MS); 1200 + 1307 1201 tps->regmap = devm_regmap_init_i2c(client, &tps6598x_regmap_config); 1308 1202 if (IS_ERR(tps->regmap)) 1309 1203 return PTR_ERR(tps->regmap); 1310 1204 1311 - is_tps25750 = device_is_compatible(tps->dev, "ti,tps25750"); 1312 - if (!is_tps25750) { 1205 + if (!device_is_compatible(tps->dev, "ti,tps25750")) { 1313 1206 ret = tps6598x_read32(tps, TPS_REG_VID, &vid); 1314 1207 if (ret < 0 || !vid) 1315 1208 return -ENODEV; ··· 1358 1239 if (ret < 0) 1359 1240 return ret; 1360 1241 1361 - if (is_tps25750 && ret == TPS_MODE_PTCH) { 1362 - ret = tps25750_init(tps); 1242 + if (ret == TPS_MODE_PTCH) { 1243 + ret = tps->data->init(tps); 1363 1244 if (ret) 1364 1245 return ret; 1365 1246 } ··· 1447 1328 tps6598x_write64(tps, TPS_REG_INT_MASK1, 0); 1448 1329 err_reset_controller: 1449 1330 /* Reset PD controller to remove any applied patch */ 1450 - if (is_tps25750) 1451 - tps6598x_exec_cmd_tmo(tps, "GAID", 0, NULL, 0, NULL, 2000, 0); 1331 + tps->data->reset(tps); 1332 + 1452 1333 return ret; 1453 1334 } 1454 1335 ··· 1465 1346 usb_role_switch_put(tps->role_sw); 1466 1347 1467 1348 /* Reset PD controller to remove any applied patch */ 1468 - if (device_is_compatible(tps->dev, "ti,tps25750")) 1469 - tps6598x_exec_cmd_tmo(tps, "GAID", 0, NULL, 0, NULL, 2000, 0); 1349 + tps->data->reset(tps); 1350 + 1351 + if (tps->reset) 1352 + gpiod_set_value_cansleep(tps->reset, 1); 1470 1353 } 1471 1354 1472 1355 static int __maybe_unused tps6598x_suspend(struct device *dev) ··· 1479 1358 if (tps->wakeup) { 1480 1359 disable_irq(client->irq); 1481 1360 enable_irq_wake(client->irq); 1361 + } else if (tps->reset) { 1362 + gpiod_set_value_cansleep(tps->reset, 1); 1482 1363 } 1483 1364 1484 1365 if (!client->irq) ··· 1499 1376 if (ret < 0) 1500 1377 return ret; 1501 1378 1502 - if (device_is_compatible(tps->dev, "ti,tps25750") && ret == TPS_MODE_PTCH) { 1503 - ret = tps25750_init(tps); 1379 + if (ret == TPS_MODE_PTCH) { 1380 + ret = tps->data->init(tps); 1504 1381 if (ret) 1505 1382 return ret; 1506 1383 } ··· 1508 1385 if (tps->wakeup) { 1509 1386 disable_irq_wake(client->irq); 1510 1387 enable_irq(client->irq); 1388 + } else if (tps->reset) { 1389 + gpiod_set_value_cansleep(tps->reset, 0); 1390 + msleep(TPS_SETUP_MS); 1511 1391 } 1512 1392 1513 1393 if (!client->irq) ··· 1529 1403 .register_port = tps6598x_register_port, 1530 1404 .trace_power_status = trace_tps6598x_power_status, 1531 1405 .trace_status = trace_tps6598x_status, 1406 + .init = cd321x_init, 1407 + .reset = cd321x_reset, 1532 1408 }; 1533 1409 1534 1410 static const struct tipd_data tps6598x_data = { ··· 1538 1410 .register_port = tps6598x_register_port, 1539 1411 .trace_power_status = trace_tps6598x_power_status, 1540 1412 .trace_status = trace_tps6598x_status, 1413 + .apply_patch = tps6598x_apply_patch, 1414 + .init = tps6598x_init, 1415 + .reset = tps6598x_reset, 1541 1416 }; 1542 1417 1543 1418 static const struct tipd_data tps25750_data = { ··· 1549 1418 .trace_power_status = trace_tps25750_power_status, 1550 1419 .trace_status = trace_tps25750_status, 1551 1420 .apply_patch = tps25750_apply_patch, 1421 + .init = tps25750_init, 1422 + .reset = tps25750_reset, 1552 1423 }; 1553 1424 1554 1425 static const struct of_device_id tps6598x_of_match[] = {
+18
drivers/usb/typec/tipd/tps6598x.h
··· 235 235 /* SLEEP CONF REG */ 236 236 #define TPS_SLEEP_CONF_SLEEP_MODE_ALLOWED BIT(0) 237 237 238 + /* Start Patch Download Sequence */ 239 + #define TPS_PTCS_CONTENT_APP BIT(0) 240 + #define TPS_PTCS_CONTENT_DEV BIT(1) 241 + #define TPS_PTCS_OUT_BYTES 4 242 + #define TPS_PTCS_STATUS 1 243 + 244 + #define TPS_PTCS_STATUS_FAIL 0x80 245 + /* Patch Download */ 246 + #define TPS_PTCD_OUT_BYTES 10 247 + #define TPS_PTCD_TRANSFER_STATUS 1 248 + #define TPS_PTCD_LOADING_STATE 2 249 + 250 + #define TPS_PTCD_LOAD_ERR 0x09 251 + /* Patch Download Complete */ 252 + #define TPS_PTCC_OUT_BYTES 4 253 + #define TPS_PTCC_DEV 2 254 + #define TPS_PTCC_APP 3 255 + 238 256 #endif /* __TPS6598X_H__ */
+4 -4
drivers/usb/usbip/stub_main.c
··· 377 377 goto err_usb_register; 378 378 } 379 379 380 - ret = driver_create_file(&stub_driver.drvwrap.driver, 380 + ret = driver_create_file(&stub_driver.driver, 381 381 &driver_attr_match_busid); 382 382 if (ret) { 383 383 pr_err("driver_create_file failed\n"); 384 384 goto err_create_file; 385 385 } 386 386 387 - ret = driver_create_file(&stub_driver.drvwrap.driver, 387 + ret = driver_create_file(&stub_driver.driver, 388 388 &driver_attr_rebind); 389 389 if (ret) { 390 390 pr_err("driver_create_file failed\n"); ··· 402 402 403 403 static void __exit usbip_host_exit(void) 404 404 { 405 - driver_remove_file(&stub_driver.drvwrap.driver, 405 + driver_remove_file(&stub_driver.driver, 406 406 &driver_attr_match_busid); 407 407 408 - driver_remove_file(&stub_driver.drvwrap.driver, 408 + driver_remove_file(&stub_driver.driver, 409 409 &driver_attr_rebind); 410 410 411 411 /*
+1 -1
drivers/usb/usbip/vudc.h
··· 173 173 void put_vudc_device(struct vudc_device *udc_dev); 174 174 175 175 int vudc_probe(struct platform_device *pdev); 176 - int vudc_remove(struct platform_device *pdev); 176 + void vudc_remove(struct platform_device *pdev); 177 177 178 178 #endif /* __USBIP_VUDC_H */
+1 -2
drivers/usb/usbip/vudc_dev.c
··· 628 628 return ret; 629 629 } 630 630 631 - int vudc_remove(struct platform_device *pdev) 631 + void vudc_remove(struct platform_device *pdev) 632 632 { 633 633 struct vudc *udc = platform_get_drvdata(pdev); 634 634 635 635 usb_del_gadget_udc(&udc->gadget); 636 636 cleanup_vudc_hw(udc); 637 637 kfree(udc); 638 - return 0; 639 638 }
+1 -1
drivers/usb/usbip/vudc_main.c
··· 19 19 20 20 static struct platform_driver vudc_driver = { 21 21 .probe = vudc_probe, 22 - .remove = vudc_remove, 22 + .remove_new = vudc_remove, 23 23 .driver = { 24 24 .name = GADGET_NAME, 25 25 .dev_groups = vudc_groups,
+1 -1
include/linux/thunderbolt.h
··· 86 86 unsigned long privdata[]; 87 87 }; 88 88 89 - extern struct bus_type tb_bus_type; 89 + extern const struct bus_type tb_bus_type; 90 90 extern struct device_type tb_service_type; 91 91 extern struct device_type tb_xdomain_type; 92 92
+13 -18
include/linux/usb.h
··· 632 632 * @reset_resume: needs reset instead of resume 633 633 * @port_is_suspended: the upstream port is suspended (L2 or U3) 634 634 * @slot_id: Slot ID assigned by xHCI 635 - * @removable: Device can be physically removed from this port 636 635 * @l1_params: best effor service latency for USB2 L1 LPM state, and L1 timeout. 637 636 * @u1_params: exit latencies for USB3 U1 LPM state, and hub-initiated timeout. 638 637 * @u2_params: exit latencies for USB3 U2 LPM state, and hub-initiated timeout. ··· 1144 1145 extern ssize_t usb_show_dynids(struct usb_dynids *dynids, char *buf); 1145 1146 1146 1147 /** 1147 - * struct usbdrv_wrap - wrapper for driver-model structure 1148 - * @driver: The driver-model core driver structure. 1149 - * @for_devices: Non-zero for device drivers, 0 for interface drivers. 1150 - */ 1151 - struct usbdrv_wrap { 1152 - struct device_driver driver; 1153 - int for_devices; 1154 - }; 1155 - 1156 - /** 1157 1148 * struct usb_driver - identifies USB interface driver to usbcore 1158 1149 * @name: The driver name should be unique among USB drivers, 1159 1150 * and should normally be the same as the module name. ··· 1183 1194 * is bound to the driver. 1184 1195 * @dynids: used internally to hold the list of dynamically added device 1185 1196 * ids for this driver. 1186 - * @drvwrap: Driver-model core structure wrapper. 1197 + * @driver: The driver-model core driver structure. 1187 1198 * @no_dynamic_id: if set to 1, the USB core will not allow dynamic ids to be 1188 1199 * added to this driver by preventing the sysfs file from being created. 1189 1200 * @supports_autosuspend: if set to 0, the USB core will not allow autosuspend ··· 1231 1242 const struct attribute_group **dev_groups; 1232 1243 1233 1244 struct usb_dynids dynids; 1234 - struct usbdrv_wrap drvwrap; 1245 + struct device_driver driver; 1235 1246 unsigned int no_dynamic_id:1; 1236 1247 unsigned int supports_autosuspend:1; 1237 1248 unsigned int disable_hub_initiated_lpm:1; 1238 1249 unsigned int soft_unbind:1; 1239 1250 }; 1240 - #define to_usb_driver(d) container_of(d, struct usb_driver, drvwrap.driver) 1251 + #define to_usb_driver(d) container_of(d, struct usb_driver, driver) 1241 1252 1242 1253 /** 1243 1254 * struct usb_device_driver - identifies USB device driver to usbcore ··· 1253 1264 * module is being unloaded. 1254 1265 * @suspend: Called when the device is going to be suspended by the system. 1255 1266 * @resume: Called when the device is being resumed by the system. 1267 + * @choose_configuration: If non-NULL, called instead of the default 1268 + * usb_choose_configuration(). If this returns an error then we'll go 1269 + * on to call the normal usb_choose_configuration(). 1256 1270 * @dev_groups: Attributes attached to the device that will be created once it 1257 1271 * is bound to the driver. 1258 - * @drvwrap: Driver-model core structure wrapper. 1272 + * @driver: The driver-model core driver structure. 1259 1273 * @id_table: used with @match() to select better matching driver at 1260 1274 * probe() time. 1261 1275 * @supports_autosuspend: if set to 0, the USB core will not allow autosuspend ··· 1267 1275 * resume and suspend functions will be called in addition to the driver's 1268 1276 * own, so this part of the setup does not need to be replicated. 1269 1277 * 1270 - * USB drivers must provide all the fields listed above except drvwrap, 1278 + * USB drivers must provide all the fields listed above except driver, 1271 1279 * match, and id_table. 1272 1280 */ 1273 1281 struct usb_device_driver { ··· 1279 1287 1280 1288 int (*suspend) (struct usb_device *udev, pm_message_t message); 1281 1289 int (*resume) (struct usb_device *udev, pm_message_t message); 1290 + 1291 + int (*choose_configuration) (struct usb_device *udev); 1292 + 1282 1293 const struct attribute_group **dev_groups; 1283 - struct usbdrv_wrap drvwrap; 1294 + struct device_driver driver; 1284 1295 const struct usb_device_id *id_table; 1285 1296 unsigned int supports_autosuspend:1; 1286 1297 unsigned int generic_subclass:1; 1287 1298 }; 1288 1299 #define to_usb_device_driver(d) container_of(d, struct usb_device_driver, \ 1289 - drvwrap.driver) 1300 + driver) 1290 1301 1291 1302 /** 1292 1303 * struct usb_class_driver - identifies a USB driver that wants to use the USB major number
+1
include/linux/usb/gadget.h
··· 236 236 unsigned max_streams:16; 237 237 unsigned mult:2; 238 238 unsigned maxburst:5; 239 + unsigned fifo_mode:1; 239 240 u8 address; 240 241 const struct usb_endpoint_descriptor *desc; 241 242 const struct usb_ss_ep_comp_descriptor *comp_desc;
+3 -2
include/linux/usb/hcd.h
··· 372 372 * or bandwidth constraints. 373 373 */ 374 374 void (*reset_bandwidth)(struct usb_hcd *, struct usb_device *); 375 - /* Returns the hardware-chosen device address */ 376 - int (*address_device)(struct usb_hcd *, struct usb_device *udev); 375 + /* Set the hardware-chosen device address */ 376 + int (*address_device)(struct usb_hcd *, struct usb_device *udev, 377 + unsigned int timeout_ms); 377 378 /* prepares the hardware to send commands to the device */ 378 379 int (*enable_device)(struct usb_hcd *, struct usb_device *udev); 379 380 /* Notifies the HCD after a hub descriptor is fetched.
+3
include/linux/usb/quirks.h
··· 72 72 /* device has endpoints that should be ignored */ 73 73 #define USB_QUIRK_ENDPOINT_IGNORE BIT(15) 74 74 75 + /* short SET_ADDRESS request timeout */ 76 + #define USB_QUIRK_SHORT_SET_ADDRESS_REQ_TIMEOUT BIT(16) 77 + 75 78 #endif /* __LINUX_USB_QUIRKS_H */
+4 -1
include/linux/usb/tcpci.h
··· 36 36 37 37 #define TCPC_ALERT_MASK 0x12 38 38 #define TCPC_POWER_STATUS_MASK 0x14 39 - #define TCPC_FAULT_STATUS_MASK 0x15 39 + 40 + #define TCPC_FAULT_STATUS_MASK 0x15 41 + #define TCPC_FAULT_STATUS_MASK_VCONN_OC BIT(1) 40 42 41 43 #define TCPC_EXTENDED_STATUS_MASK 0x16 42 44 #define TCPC_EXTENDED_STATUS_MASK_VSAFE0V BIT(0) ··· 106 104 107 105 #define TCPC_FAULT_STATUS 0x1f 108 106 #define TCPC_FAULT_STATUS_ALL_REG_RST_TO_DEFAULT BIT(7) 107 + #define TCPC_FAULT_STATUS_VCONN_OC BIT(1) 109 108 110 109 #define TCPC_ALERT_EXTENDED 0x21 111 110
+1
include/linux/usb/tcpm.h
··· 173 173 void tcpm_tcpc_reset(struct tcpm_port *port); 174 174 void tcpm_port_clean(struct tcpm_port *port); 175 175 bool tcpm_port_is_toggling(struct tcpm_port *port); 176 + void tcpm_port_error_recovery(struct tcpm_port *port); 176 177 177 178 #endif /* __LINUX_USB_TCPM_H */
+4 -2
include/uapi/linux/usb/functionfs.h
··· 73 73 struct usb_ext_compat_desc { 74 74 __u8 bFirstInterfaceNumber; 75 75 __u8 Reserved1; 76 - __u8 CompatibleID[8]; 77 - __u8 SubCompatibleID[8]; 76 + __struct_group(/* no tag */, IDs, /* no attrs */, 77 + __u8 CompatibleID[8]; 78 + __u8 SubCompatibleID[8]; 79 + ); 78 80 __u8 Reserved2[6]; 79 81 }; 80 82