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

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

Pull USB / Thunderbolt updates from Greg KH:
"Here is the large set of USB and Thunderbolt changes for 6.4-rc1.

The "biggest" thing in here is the removal of two obsolete drivers,
u132-hcd and ftdi-elan, making this a net-removal of code overall.

Other than the driver removals, included in here are:

- Thunderbolt updates for new hardware and features

- xhci driver updates and fixes

- dwc3 driver updates and fixes

- gadget core and driver updates and features added

- mtu3 driver updates

- dwc2 driver fixes and updates

- usb-serial driver updates

- typec driver updates and fixes

- platform remove callback changes

- dts updates and conversions

- other small changes

All have been in linux-next for a while with no reported problems"

* tag 'usb-6.4-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (177 commits)
usb: dwc3: gadget: Refactor EP0 forced stall/restart into a separate API
usb: dwc3: gadget: Execute gadget stop after halting the controller
media: radio-shark: Add endpoint checks
USB: sisusbvga: Add endpoint checks
USB: core: Add routines for endpoint checks in old drivers
usb: dwc3: gadget: Stall and restart EP0 if host is unresponsive
dt-bindings: usb: snps,dwc3: Add 'snps,parkmode-disable-hs-quirk' quirk
usb: dwc3: core: add support for disabling High-speed park mode
dt-bindings: usb: ci-hdrc-usb2: allow multiple PHYs
usb: mtu3: add optional clock xhci_ck and frmcnt_ck
dt-bindings: usb: mtu3: add two optional clocks
usb: mtu3: expose role-switch control to userspace
usb: mtu3: unlock @mtu->lock just before giving back request
usb: mtu3: fix kernel panic at qmu transfer done irq handler
usb: mtu3: use boolean return value
usb: mtu3: give back request when rx error happens
usb: chipidea: fix missing goto in `ci_hdrc_probe`
usb: gadget: udc: core: Prevent redundant calls to pullup
usb: gadget: udc: core: Invoke usb_gadget_connect only when started
usb: typec: ucsi: don't print PPM init deferred errors
...

+3334 -7869
+2 -2
Documentation/ABI/testing/configfs-usb-gadget-uvc
··· 76 76 KernelVersion: 4.0 77 77 Description: Default camera terminal descriptors 78 78 79 - All attributes read only: 79 + All attributes read only except bmControls, which is read/write: 80 80 81 81 ======================== ==================================== 82 82 bmControls bitmap specifying which controls are ··· 101 101 KernelVersion: 4.0 102 102 Description: Default processing unit descriptors 103 103 104 - All attributes read only: 104 + All attributes read only except bmControls, which is read/write: 105 105 106 106 =============== ======================================== 107 107 iProcessing index of string descriptor
+52
Documentation/ABI/testing/sysfs-bus-pci-drivers-xhci_hcd
··· 23 23 Reading this attribute gives the state of the DbC. It 24 24 can be one of the following states: disabled, enabled, 25 25 initialized, connected, configured and stalled. 26 + 27 + What: /sys/bus/pci/drivers/xhci_hcd/.../dbc_idVendor 28 + Date: March 2023 29 + Contact: Mathias Nyman <mathias.nyman@linux.intel.com> 30 + Description: 31 + This dbc_idVendor attribute lets us change the idVendor field 32 + presented in the USB device descriptor by this xhci debug 33 + device. 34 + Value can only be changed while debug capability (DbC) is in 35 + disabled state to prevent USB device descriptor change while 36 + connected to a USB host. 37 + The default value is 0x1d6b (Linux Foundation). 38 + It can be any 16-bit integer. 39 + 40 + What: /sys/bus/pci/drivers/xhci_hcd/.../dbc_idProduct 41 + Date: March 2023 42 + Contact: Mathias Nyman <mathias.nyman@linux.intel.com> 43 + Description: 44 + This dbc_idProduct attribute lets us change the idProduct field 45 + presented in the USB device descriptor by this xhci debug 46 + device. 47 + Value can only be changed while debug capability (DbC) is in 48 + disabled state to prevent USB device descriptor change while 49 + connected to a USB host. 50 + The default value is 0x0010. It can be any 16-bit integer. 51 + 52 + What: /sys/bus/pci/drivers/xhci_hcd/.../dbc_bcdDevice 53 + Date: March 2023 54 + Contact: Mathias Nyman <mathias.nyman@linux.intel.com> 55 + Description: 56 + This dbc_bcdDevice attribute lets us change the bcdDevice field 57 + presented in the USB device descriptor by this xhci debug 58 + device. 59 + Value can only be changed while debug capability (DbC) is in 60 + disabled state to prevent USB device descriptor change while 61 + connected to a USB host. 62 + The default value is 0x0010. (device rev 0.10) 63 + It can be any 16-bit integer. 64 + 65 + What: /sys/bus/pci/drivers/xhci_hcd/.../dbc_bInterfaceProtocol 66 + Date: March 2023 67 + Contact: Mathias Nyman <mathias.nyman@linux.intel.com> 68 + Description: 69 + This attribute lets us change the bInterfaceProtocol field 70 + presented in the USB Interface descriptor by the xhci debug 71 + device. 72 + Value can only be changed while debug capability (DbC) is in 73 + disabled state to prevent USB descriptor change while 74 + connected to a USB host. 75 + The default value is 1 (GNU Remote Debug command). 76 + Other permissible value is 0 which is for vendor defined debug 77 + target.
+2 -2
Documentation/devicetree/bindings/usb/amlogic,meson-g12a-usb-ctrl.yaml
··· 2 2 # Copyright 2019 BayLibre, SAS 3 3 %YAML 1.2 4 4 --- 5 - $id: "http://devicetree.org/schemas/usb/amlogic,meson-g12a-usb-ctrl.yaml#" 6 - $schema: "http://devicetree.org/meta-schemas/core.yaml#" 5 + $id: http://devicetree.org/schemas/usb/amlogic,meson-g12a-usb-ctrl.yaml# 6 + $schema: http://devicetree.org/meta-schemas/core.yaml# 7 7 8 8 title: Amlogic Meson G12A DWC3 USB SoC Controller Glue 9 9
+1 -1
Documentation/devicetree/bindings/usb/brcm,bcm7445-ehci.yaml
··· 7 7 title: Broadcom STB USB EHCI Controller 8 8 9 9 allOf: 10 - - $ref: "usb-hcd.yaml" 10 + - $ref: usb-hcd.yaml 11 11 12 12 maintainers: 13 13 - Al Cooper <alcooperx@gmail.com>
-159
Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt
··· 1 - * USB2 ChipIdea USB controller for ci13xxx 2 - 3 - Required properties: 4 - - compatible: should be one of: 5 - "fsl,imx23-usb" 6 - "fsl,imx27-usb" 7 - "fsl,imx28-usb" 8 - "fsl,imx6q-usb" 9 - "fsl,imx6sl-usb" 10 - "fsl,imx6sx-usb" 11 - "fsl,imx6ul-usb" 12 - "fsl,imx7d-usb" 13 - "fsl,imx7ulp-usb" 14 - "fsl,imx8mm-usb" 15 - "lsi,zevio-usb" 16 - "qcom,ci-hdrc" 17 - "chipidea,usb2" 18 - "xlnx,zynq-usb-2.20a" 19 - "nvidia,tegra20-udc" 20 - "nvidia,tegra30-udc" 21 - "nvidia,tegra114-udc" 22 - "nvidia,tegra124-udc" 23 - - reg: base address and length of the registers 24 - - interrupts: interrupt for the USB controller 25 - 26 - Recommended properies: 27 - - phy_type: the type of the phy connected to the core. Should be one 28 - of "utmi", "utmi_wide", "ulpi", "serial" or "hsic". Without this 29 - property the PORTSC register won't be touched. 30 - - dr_mode: One of "host", "peripheral" or "otg". Defaults to "otg" 31 - 32 - Deprecated properties: 33 - - usb-phy: phandle for the PHY device. Use "phys" instead. 34 - - fsl,usbphy: phandle of usb phy that connects to the port. Use "phys" instead. 35 - 36 - Optional properties: 37 - - clocks: reference to the USB clock 38 - - phys: reference to the USB PHY 39 - - phy-names: should be "usb-phy" 40 - - vbus-supply: reference to the VBUS regulator 41 - - maximum-speed: limit the maximum connection speed to "full-speed". 42 - - tpl-support: TPL (Targeted Peripheral List) feature for targeted hosts 43 - - itc-setting: interrupt threshold control register control, the setting 44 - should be aligned with ITC bits at register USBCMD. 45 - - ahb-burst-config: it is vendor dependent, the required value should be 46 - aligned with AHBBRST at SBUSCFG, the range is from 0x0 to 0x7. This 47 - property is used to change AHB burst configuration, check the chipidea 48 - spec for meaning of each value. If this property is not existed, it 49 - will use the reset value. 50 - - tx-burst-size-dword: it is vendor dependent, the tx burst size in dword 51 - (4 bytes), This register represents the maximum length of a the burst 52 - in 32-bit words while moving data from system memory to the USB 53 - bus, the value of this property will only take effect if property 54 - "ahb-burst-config" is set to 0, if this property is missing the reset 55 - default of the hardware implementation will be used. 56 - - rx-burst-size-dword: it is vendor dependent, the rx burst size in dword 57 - (4 bytes), This register represents the maximum length of a the burst 58 - in 32-bit words while moving data from the USB bus to system memory, 59 - the value of this property will only take effect if property 60 - "ahb-burst-config" is set to 0, if this property is missing the reset 61 - default of the hardware implementation will be used. 62 - - extcon: phandles to external connector devices. First phandle should point to 63 - external connector, which provide "USB" cable events, the second should point 64 - to external connector device, which provide "USB-HOST" cable events. If one 65 - of the external connector devices is not required, empty <0> phandle should 66 - be specified. 67 - - phy-clkgate-delay-us: the delay time (us) between putting the PHY into 68 - low power mode and gating the PHY clock. 69 - - non-zero-ttctrl-ttha: after setting this property, the value of register 70 - ttctrl.ttha will be 0x7f; if not, the value will be 0x0, this is the default 71 - value. It needs to be very carefully for setting this property, it is 72 - recommended that consult with your IC engineer before setting this value. 73 - On the most of chipidea platforms, the "usage_tt" flag at RTL is 0, so this 74 - property only affects siTD. 75 - If this property is not set, the max packet size is 1023 bytes, and if 76 - the total of packet size for pervious transactions are more than 256 bytes, 77 - it can't accept any transactions within this frame. The use case is single 78 - transaction, but higher frame rate. 79 - If this property is set, the max packet size is 188 bytes, it can handle 80 - more transactions than above case, it can accept transactions until it 81 - considers the left room size within frame is less than 188 bytes, software 82 - needs to make sure it does not send more than 90% 83 - maximum_periodic_data_per_frame. The use case is multiple transactions, but 84 - less frame rate. 85 - - mux-controls: The mux control for toggling host/device output of this 86 - controller. It's expected that a mux state of 0 indicates device mode and a 87 - mux state of 1 indicates host mode. 88 - - mux-control-names: Shall be "usb_switch" if mux-controls is specified. 89 - - pinctrl-names: Names for optional pin modes in "default", "host", "device". 90 - In case of HSIC-mode, "idle" and "active" pin modes are mandatory. In this 91 - case, the "idle" state needs to pull down the data and strobe pin 92 - and the "active" state needs to pull up the strobe pin. 93 - - pinctrl-n: alternate pin modes 94 - 95 - i.mx specific properties 96 - - fsl,usbmisc: phandler of non-core register device, with one 97 - argument that indicate usb controller index 98 - - disable-over-current: disable over current detect 99 - - over-current-active-low: over current signal polarity is active low. 100 - - over-current-active-high: over current signal polarity is active high. 101 - It's recommended to specify the over current polarity. 102 - - power-active-high: power signal polarity is active high 103 - - external-vbus-divider: enables off-chip resistor divider for Vbus 104 - - samsung,picophy-pre-emp-curr-control: HS Transmitter Pre-Emphasis Current 105 - Control. This signal controls the amount of current sourced to the 106 - USB_OTG*_DP and USB_OTG*_DN pins after a J-to-K or K-to-J transition. 107 - The range is from 0x0 to 0x3, the default value is 0x1. 108 - Details can refer to TXPREEMPAMPTUNE0 bits of USBNC_n_PHY_CFG1. 109 - - samsung,picophy-dc-vol-level-adjust: HS DC Voltage Level Adjustment. 110 - Adjust the high-speed transmitter DC level voltage. 111 - The range is from 0x0 to 0xf, the default value is 0x3. 112 - Details can refer to TXVREFTUNE0 bits of USBNC_n_PHY_CFG1. 113 - 114 - Example: 115 - 116 - usb@f7ed0000 { 117 - compatible = "chipidea,usb2"; 118 - reg = <0xf7ed0000 0x10000>; 119 - interrupts = <GIC_SPI 11 IRQ_TYPE_LEVEL_HIGH>; 120 - clocks = <&chip CLKID_USB0>; 121 - phys = <&usb_phy0>; 122 - phy-names = "usb-phy"; 123 - vbus-supply = <&reg_usb0_vbus>; 124 - itc-setting = <0x4>; /* 4 micro-frames */ 125 - /* Incremental burst of unspecified length */ 126 - ahb-burst-config = <0x0>; 127 - tx-burst-size-dword = <0x10>; /* 64 bytes */ 128 - rx-burst-size-dword = <0x10>; 129 - extcon = <0>, <&usb_id>; 130 - phy-clkgate-delay-us = <400>; 131 - mux-controls = <&usb_switch>; 132 - mux-control-names = "usb_switch"; 133 - }; 134 - 135 - Example for HSIC: 136 - 137 - usb@2184400 { 138 - compatible = "fsl,imx6q-usb", "fsl,imx27-usb"; 139 - reg = <0x02184400 0x200>; 140 - interrupts = <0 41 IRQ_TYPE_LEVEL_HIGH>; 141 - clocks = <&clks IMX6QDL_CLK_USBOH3>; 142 - fsl,usbphy = <&usbphynop1>; 143 - fsl,usbmisc = <&usbmisc 2>; 144 - phy_type = "hsic"; 145 - dr_mode = "host"; 146 - ahb-burst-config = <0x0>; 147 - tx-burst-size-dword = <0x10>; 148 - rx-burst-size-dword = <0x10>; 149 - pinctrl-names = "idle", "active"; 150 - pinctrl-0 = <&pinctrl_usbh2_idle>; 151 - pinctrl-1 = <&pinctrl_usbh2_active>; 152 - #address-cells = <1>; 153 - #size-cells = <0>; 154 - 155 - usbnet: ethernet@1 { 156 - compatible = "usb424,9730"; 157 - reg = <1>; 158 - }; 159 - };
+448
Documentation/devicetree/bindings/usb/ci-hdrc-usb2.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/ci-hdrc-usb2.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: USB2 ChipIdea USB controller 8 + 9 + maintainers: 10 + - Xu Yang <xu.yang_2@nxp.com> 11 + - Peng Fan <peng.fan@nxp.com> 12 + 13 + properties: 14 + compatible: 15 + oneOf: 16 + - enum: 17 + - chipidea,usb2 18 + - lsi,zevio-usb 19 + - nvidia,tegra20-ehci 20 + - nvidia,tegra20-udc 21 + - nvidia,tegra30-ehci 22 + - nvidia,tegra30-udc 23 + - nvidia,tegra114-udc 24 + - nvidia,tegra124-udc 25 + - qcom,ci-hdrc 26 + - items: 27 + - enum: 28 + - nvidia,tegra114-ehci 29 + - nvidia,tegra124-ehci 30 + - nvidia,tegra210-ehci 31 + - const: nvidia,tegra30-ehci 32 + - items: 33 + - enum: 34 + - fsl,imx23-usb 35 + - fsl,imx25-usb 36 + - fsl,imx28-usb 37 + - fsl,imx50-usb 38 + - fsl,imx51-usb 39 + - fsl,imx53-usb 40 + - fsl,imx6q-usb 41 + - fsl,imx6sl-usb 42 + - fsl,imx6sx-usb 43 + - fsl,imx6ul-usb 44 + - fsl,imx7d-usb 45 + - fsl,vf610-usb 46 + - const: fsl,imx27-usb 47 + - items: 48 + - const: fsl,imx8dxl-usb 49 + - const: fsl,imx7ulp-usb 50 + - const: fsl,imx6ul-usb 51 + - items: 52 + - enum: 53 + - fsl,imx8mm-usb 54 + - fsl,imx8mn-usb 55 + - const: fsl,imx7d-usb 56 + - const: fsl,imx27-usb 57 + - items: 58 + - enum: 59 + - fsl,imx6sll-usb 60 + - fsl,imx7ulp-usb 61 + - const: fsl,imx6ul-usb 62 + - const: fsl,imx27-usb 63 + - items: 64 + - const: xlnx,zynq-usb-2.20a 65 + - const: chipidea,usb2 66 + 67 + reg: 68 + minItems: 1 69 + maxItems: 2 70 + 71 + interrupts: 72 + minItems: 1 73 + maxItems: 2 74 + 75 + clocks: 76 + minItems: 1 77 + maxItems: 2 78 + 79 + clock-names: 80 + minItems: 1 81 + maxItems: 2 82 + 83 + dr_mode: true 84 + 85 + power-domains: 86 + maxItems: 1 87 + 88 + resets: 89 + maxItems: 1 90 + 91 + reset-names: 92 + maxItems: 1 93 + 94 + "#reset-cells": 95 + const: 1 96 + 97 + phy_type: true 98 + 99 + itc-setting: 100 + description: 101 + interrupt threshold control register control, the setting should be 102 + aligned with ITC bits at register USBCMD. 103 + $ref: /schemas/types.yaml#/definitions/uint32 104 + 105 + ahb-burst-config: 106 + description: 107 + it is vendor dependent, the required value should be aligned with 108 + AHBBRST at SBUSCFG, the range is from 0x0 to 0x7. This property is 109 + used to change AHB burst configuration, check the chipidea spec for 110 + meaning of each value. If this property is not existed, it will use 111 + the reset value. 112 + $ref: /schemas/types.yaml#/definitions/uint32 113 + minimum: 0x0 114 + maximum: 0x7 115 + 116 + tx-burst-size-dword: 117 + description: 118 + it is vendor dependent, the tx burst size in dword (4 bytes), This 119 + register represents the maximum length of a the burst in 32-bit 120 + words while moving data from system memory to the USB bus, the value 121 + of this property will only take effect if property "ahb-burst-config" 122 + is set to 0, if this property is missing the reset default of the 123 + hardware implementation will be used. 124 + $ref: /schemas/types.yaml#/definitions/uint32 125 + minimum: 0x0 126 + maximum: 0x20 127 + 128 + rx-burst-size-dword: 129 + description: 130 + it is vendor dependent, the rx burst size in dword (4 bytes), This 131 + register represents the maximum length of a the burst in 32-bit words 132 + while moving data from the USB bus to system memory, the value of 133 + this property will only take effect if property "ahb-burst-config" 134 + is set to 0, if this property is missing the reset default of the 135 + hardware implementation will be used. 136 + $ref: /schemas/types.yaml#/definitions/uint32 137 + minimum: 0x0 138 + maximum: 0x20 139 + 140 + extcon: 141 + description: 142 + Phandles to external connector devices. First phandle should point 143 + to external connector, which provide "USB" cable events, the second 144 + should point to external connector device, which provide "USB-HOST" 145 + cable events. If one of the external connector devices is not 146 + required, empty <0> phandle should be specified. 147 + $ref: /schemas/types.yaml#/definitions/phandle-array 148 + minItems: 1 149 + items: 150 + - description: vbus extcon 151 + - description: id extcon 152 + 153 + phy-clkgate-delay-us: 154 + description: 155 + The delay time (us) between putting the PHY into low power mode and 156 + gating the PHY clock. 157 + 158 + non-zero-ttctrl-ttha: 159 + description: 160 + After setting this property, the value of register ttctrl.ttha 161 + will be 0x7f; if not, the value will be 0x0, this is the default 162 + value. It needs to be very carefully for setting this property, it 163 + is recommended that consult with your IC engineer before setting 164 + this value. On the most of chipidea platforms, the "usage_tt" flag 165 + at RTL is 0, so this property only affects siTD. 166 + 167 + If this property is not set, the max packet size is 1023 bytes, and 168 + if the total of packet size for pervious transactions are more than 169 + 256 bytes, it can't accept any transactions within this frame. The 170 + use case is single transaction, but higher frame rate. 171 + 172 + If this property is set, the max packet size is 188 bytes, it can 173 + handle more transactions than above case, it can accept transactions 174 + until it considers the left room size within frame is less than 188 175 + bytes, software needs to make sure it does not send more than 90% 176 + maximum_periodic_data_per_frame. The use case is multiple 177 + transactions, but less frame rate. 178 + type: boolean 179 + 180 + mux-controls: 181 + description: 182 + The mux control for toggling host/device output of this controller. 183 + It's expected that a mux state of 0 indicates device mode and a mux 184 + state of 1 indicates host mode. 185 + maxItems: 1 186 + 187 + mux-control-names: 188 + const: usb_switch 189 + 190 + operating-points-v2: 191 + description: A phandle to the OPP table containing the performance states. 192 + $ref: /schemas/types.yaml#/definitions/phandle 193 + 194 + pinctrl-names: 195 + description: 196 + Names for optional pin modes in "default", "host", "device". 197 + In case of HSIC-mode, "idle" and "active" pin modes are mandatory. 198 + In this case, the "idle" state needs to pull down the data and 199 + strobe pin and the "active" state needs to pull up the strobe pin. 200 + oneOf: 201 + - items: 202 + - const: idle 203 + - const: active 204 + - items: 205 + - const: default 206 + - enum: 207 + - host 208 + - device 209 + - items: 210 + - const: default 211 + 212 + pinctrl-0: 213 + maxItems: 1 214 + 215 + pinctrl-1: 216 + maxItems: 1 217 + 218 + phys: 219 + maxItems: 1 220 + 221 + phy-names: 222 + const: usb-phy 223 + 224 + phy-select: 225 + description: 226 + Phandler of TCSR node with two argument that indicate register 227 + offset, and phy index 228 + $ref: /schemas/types.yaml#/definitions/phandle-array 229 + items: 230 + - description: phandle to TCSR node 231 + - description: register offset 232 + - description: phy index 233 + 234 + vbus-supply: 235 + description: reference to the VBUS regulator. 236 + 237 + fsl,usbmisc: 238 + description: 239 + Phandler of non-core register device, with one argument that 240 + indicate usb controller index 241 + $ref: /schemas/types.yaml#/definitions/phandle-array 242 + items: 243 + - items: 244 + - description: phandle to usbmisc node 245 + - description: index of usb controller 246 + 247 + fsl,anatop: 248 + description: phandle for the anatop node. 249 + $ref: /schemas/types.yaml#/definitions/phandle 250 + 251 + disable-over-current: 252 + type: boolean 253 + description: disable over current detect 254 + 255 + over-current-active-low: 256 + type: boolean 257 + description: over current signal polarity is active low 258 + 259 + over-current-active-high: 260 + type: boolean 261 + description: 262 + Over current signal polarity is active high. It's recommended to 263 + specify the over current polarity. 264 + 265 + power-active-high: 266 + type: boolean 267 + description: power signal polarity is active high 268 + 269 + external-vbus-divider: 270 + type: boolean 271 + description: enables off-chip resistor divider for Vbus 272 + 273 + samsung,picophy-pre-emp-curr-control: 274 + description: 275 + HS Transmitter Pre-Emphasis Current Control. This signal controls 276 + the amount of current sourced to the USB_OTG*_DP and USB_OTG*_DN 277 + pins after a J-to-K or K-to-J transition. The range is from 0x0 to 278 + 0x3, the default value is 0x1. Details can refer to TXPREEMPAMPTUNE0 279 + bits of USBNC_n_PHY_CFG1. 280 + $ref: /schemas/types.yaml#/definitions/uint32 281 + minimum: 0x0 282 + maximum: 0x3 283 + 284 + samsung,picophy-dc-vol-level-adjust: 285 + description: 286 + HS DC Voltage Level Adjustment. Adjust the high-speed transmitter DC 287 + level voltage. The range is from 0x0 to 0xf, the default value is 288 + 0x3. Details can refer to TXVREFTUNE0 bits of USBNC_n_PHY_CFG1. 289 + $ref: /schemas/types.yaml#/definitions/uint32 290 + minimum: 0x0 291 + maximum: 0xf 292 + 293 + usb-phy: 294 + description: phandle for the PHY device. Use "phys" instead. 295 + $ref: /schemas/types.yaml#/definitions/phandle 296 + deprecated: true 297 + 298 + fsl,usbphy: 299 + description: phandle of usb phy that connects to the port. Use "phys" instead. 300 + $ref: /schemas/types.yaml#/definitions/phandle 301 + deprecated: true 302 + 303 + nvidia,phy: 304 + description: phandle of usb phy that connects to the port. Use "phys" instead. 305 + $ref: /schemas/types.yaml#/definitions/phandle 306 + deprecated: true 307 + 308 + nvidia,needs-double-reset: 309 + description: Indicates double reset or not. 310 + type: boolean 311 + deprecated: true 312 + 313 + port: 314 + description: 315 + Any connector to the data bus of this controller should be modelled 316 + using the OF graph bindings specified, if the "usb-role-switch" 317 + property is used. 318 + $ref: /schemas/graph.yaml#/properties/port 319 + 320 + reset-gpios: 321 + maxItems: 1 322 + 323 + ulpi: 324 + type: object 325 + additionalProperties: false 326 + patternProperties: 327 + "^phy(-[0-9])?$": 328 + description: The phy child node for Qcom chips. 329 + type: object 330 + $ref: /schemas/phy/qcom,usb-hs-phy.yaml 331 + 332 + dependencies: 333 + port: [ usb-role-switch ] 334 + mux-controls: [ mux-control-names ] 335 + 336 + required: 337 + - compatible 338 + - reg 339 + - interrupts 340 + 341 + allOf: 342 + - $ref: usb-hcd.yaml# 343 + - $ref: usb-drd.yaml# 344 + - if: 345 + properties: 346 + phy_type: 347 + const: hsic 348 + required: 349 + - phy_type 350 + then: 351 + properties: 352 + pinctrl-names: 353 + items: 354 + - const: idle 355 + - const: active 356 + else: 357 + properties: 358 + pinctrl-names: 359 + minItems: 1 360 + maxItems: 2 361 + oneOf: 362 + - items: 363 + - const: default 364 + - enum: 365 + - host 366 + - device 367 + - items: 368 + - const: default 369 + - if: 370 + properties: 371 + compatible: 372 + contains: 373 + enum: 374 + - chipidea,usb2 375 + - lsi,zevio-usb 376 + - nvidia,tegra20-udc 377 + - nvidia,tegra30-udc 378 + - nvidia,tegra114-udc 379 + - nvidia,tegra124-udc 380 + - qcom,ci-hdrc 381 + - xlnx,zynq-usb-2.20a 382 + then: 383 + properties: 384 + fsl,usbmisc: false 385 + disable-over-current: false 386 + over-current-active-low: false 387 + over-current-active-high: false 388 + power-active-high: false 389 + external-vbus-divider: false 390 + samsung,picophy-pre-emp-curr-control: false 391 + samsung,picophy-dc-vol-level-adjust: false 392 + 393 + unevaluatedProperties: false 394 + 395 + examples: 396 + - | 397 + #include <dt-bindings/interrupt-controller/arm-gic.h> 398 + #include <dt-bindings/clock/berlin2.h> 399 + 400 + usb@f7ed0000 { 401 + compatible = "chipidea,usb2"; 402 + reg = <0xf7ed0000 0x10000>; 403 + interrupts = <GIC_SPI 11 IRQ_TYPE_LEVEL_HIGH>; 404 + clocks = <&chip CLKID_USB0>; 405 + phys = <&usb_phy0>; 406 + phy-names = "usb-phy"; 407 + vbus-supply = <&reg_usb0_vbus>; 408 + itc-setting = <0x4>; /* 4 micro-frames */ 409 + /* Incremental burst of unspecified length */ 410 + ahb-burst-config = <0x0>; 411 + tx-burst-size-dword = <0x10>; /* 64 bytes */ 412 + rx-burst-size-dword = <0x10>; 413 + extcon = <0>, <&usb_id>; 414 + phy-clkgate-delay-us = <400>; 415 + mux-controls = <&usb_switch>; 416 + mux-control-names = "usb_switch"; 417 + }; 418 + 419 + # Example for HSIC: 420 + - | 421 + #include <dt-bindings/interrupt-controller/arm-gic.h> 422 + #include <dt-bindings/clock/imx6qdl-clock.h> 423 + 424 + usb@2184400 { 425 + compatible = "fsl,imx6q-usb", "fsl,imx27-usb"; 426 + reg = <0x02184400 0x200>; 427 + interrupts = <0 41 IRQ_TYPE_LEVEL_HIGH>; 428 + clocks = <&clks IMX6QDL_CLK_USBOH3>; 429 + fsl,usbphy = <&usbphynop1>; 430 + fsl,usbmisc = <&usbmisc 2>; 431 + phy_type = "hsic"; 432 + dr_mode = "host"; 433 + ahb-burst-config = <0x0>; 434 + tx-burst-size-dword = <0x10>; 435 + rx-burst-size-dword = <0x10>; 436 + pinctrl-names = "idle", "active"; 437 + pinctrl-0 = <&pinctrl_usbh2_idle>; 438 + pinctrl-1 = <&pinctrl_usbh2_active>; 439 + #address-cells = <1>; 440 + #size-cells = <0>; 441 + 442 + ethernet@1 { 443 + compatible = "usb424,9730"; 444 + reg = <1>; 445 + }; 446 + }; 447 + 448 + ...
+4 -1
Documentation/devicetree/bindings/usb/dwc2.yaml
··· 75 75 maxItems: 1 76 76 77 77 clocks: 78 - maxItems: 1 78 + minItems: 1 79 + maxItems: 2 79 80 80 81 clock-names: 81 82 items: 82 83 - const: otg 84 + - const: utmi 85 + minItems: 1 83 86 84 87 disable-over-current: 85 88 type: boolean
+2 -2
Documentation/devicetree/bindings/usb/fcs,fsa4480.yaml
··· 1 1 # SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause 2 2 %YAML 1.2 3 3 --- 4 - $id: "http://devicetree.org/schemas/usb/fcs,fsa4480.yaml#" 5 - $schema: "http://devicetree.org/meta-schemas/core.yaml#" 4 + $id: http://devicetree.org/schemas/usb/fcs,fsa4480.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 6 7 7 title: ON Semiconductor Analog Audio Switch 8 8
+48
Documentation/devicetree/bindings/usb/fsl,imx8mq-dwc3.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/usb/fsl,imx8mq-dwc3.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: NXP iMX8MQ Soc USB Controller 8 + 9 + maintainers: 10 + - Li Jun <jun.li@nxp.com> 11 + - Peng Fan <peng.fan@nxp.com> 12 + 13 + select: 14 + properties: 15 + compatible: 16 + contains: 17 + enum: 18 + - fsl,imx8mq-dwc3 19 + required: 20 + - compatible 21 + 22 + properties: 23 + compatible: 24 + items: 25 + - const: fsl,imx8mq-dwc3 26 + - const: snps,dwc3 27 + 28 + allOf: 29 + - $ref: snps,dwc3.yaml# 30 + 31 + unevaluatedProperties: false 32 + 33 + examples: 34 + - | 35 + #include <dt-bindings/clock/imx8mq-clock.h> 36 + #include <dt-bindings/interrupt-controller/arm-gic.h> 37 + 38 + usb_dwc3_1: usb@38200000 { 39 + compatible = "fsl,imx8mq-dwc3", "snps,dwc3"; 40 + reg = <0x38200000 0x10000>; 41 + clocks = <&clk IMX8MQ_CLK_USB2_CTRL_ROOT>, 42 + <&clk IMX8MQ_CLK_USB_CORE_REF>, 43 + <&clk IMX8MQ_CLK_32K>; 44 + clock-names = "bus_early", "ref", "suspend"; 45 + interrupts = <GIC_SPI 41 IRQ_TYPE_LEVEL_HIGH>; 46 + phys = <&usb3_phy1>, <&usb3_phy1>; 47 + phy-names = "usb2-phy", "usb3-phy"; 48 + };
+68
Documentation/devicetree/bindings/usb/fsl,usbmisc.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/fsl,usbmisc.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Freescale i.MX wrapper module for Chipidea USB2 controller 8 + 9 + maintainers: 10 + - Xu Yang <xu.yang_2@nxp.com> 11 + - Peng Fan <peng.fan@nxp.com> 12 + 13 + properties: 14 + compatible: 15 + oneOf: 16 + - enum: 17 + - fsl,imx25-usbmisc 18 + - fsl,imx27-usbmisc 19 + - fsl,imx35-usbmisc 20 + - fsl,imx51-usbmisc 21 + - fsl,imx53-usbmisc 22 + - fsl,imx6q-usbmisc 23 + - fsl,vf610-usbmisc 24 + - items: 25 + - enum: 26 + - fsl,imx6ul-usbmisc 27 + - fsl,imx6sl-usbmisc 28 + - fsl,imx6sx-usbmisc 29 + - fsl,imx7d-usbmisc 30 + - const: fsl,imx6q-usbmisc 31 + - items: 32 + - enum: 33 + - fsl,imx7ulp-usbmisc 34 + - fsl,imx8mm-usbmisc 35 + - fsl,imx8mn-usbmisc 36 + - const: fsl,imx7d-usbmisc 37 + - const: fsl,imx6q-usbmisc 38 + - items: 39 + - const: fsl,imx6sll-usbmisc 40 + - const: fsl,imx6ul-usbmisc 41 + - const: fsl,imx6q-usbmisc 42 + 43 + clocks: 44 + maxItems: 1 45 + 46 + reg: 47 + maxItems: 1 48 + 49 + '#index-cells': 50 + const: 1 51 + description: Cells used to describe usb controller index. 52 + deprecated: true 53 + 54 + required: 55 + - compatible 56 + - reg 57 + 58 + additionalProperties: false 59 + 60 + examples: 61 + - | 62 + usbmisc@2184800 { 63 + compatible = "fsl,imx6q-usbmisc"; 64 + reg = <0x02184800 0x200>; 65 + #index-cells = <1>; 66 + }; 67 + 68 + ...
+1 -1
Documentation/devicetree/bindings/usb/generic-ehci.yaml
··· 10 10 - Greg Kroah-Hartman <gregkh@linuxfoundation.org> 11 11 12 12 allOf: 13 - - $ref: "usb-hcd.yaml" 13 + - $ref: usb-hcd.yaml 14 14 - if: 15 15 properties: 16 16 compatible:
+1 -1
Documentation/devicetree/bindings/usb/generic-ohci.yaml
··· 148 148 properties: 149 149 transceiver: false 150 150 151 - additionalProperties: false 151 + unevaluatedProperties: false 152 152 153 153 examples: 154 154 - |
+1 -1
Documentation/devicetree/bindings/usb/generic-xhci.yaml
··· 10 10 - Mathias Nyman <mathias.nyman@intel.com> 11 11 12 12 allOf: 13 - - $ref: "usb-xhci.yaml#" 13 + - $ref: usb-xhci.yaml# 14 14 15 15 properties: 16 16 compatible:
+2 -2
Documentation/devicetree/bindings/usb/gpio-sbu-mux.yaml
··· 1 1 # SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause 2 2 %YAML 1.2 3 3 --- 4 - $id: "http://devicetree.org/schemas/usb/gpio-sbu-mux.yaml#" 5 - $schema: "http://devicetree.org/meta-schemas/core.yaml#" 4 + $id: http://devicetree.org/schemas/usb/gpio-sbu-mux.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 6 7 7 title: GPIO-based SBU mux 8 8
+2 -2
Documentation/devicetree/bindings/usb/maxim,max33359.yaml
··· 1 1 # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) 2 2 %YAML 1.2 3 3 --- 4 - $id: "http://devicetree.org/schemas/usb/maxim,max33359.yaml#" 5 - $schema: "http://devicetree.org/meta-schemas/core.yaml#" 4 + $id: http://devicetree.org/schemas/usb/maxim,max33359.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 6 7 7 title: Maxim TCPCI Type-C PD controller 8 8
+2 -2
Documentation/devicetree/bindings/usb/mediatek,mt6360-tcpc.yaml
··· 1 1 # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) 2 2 %YAML 1.2 3 3 --- 4 - $id: "http://devicetree.org/schemas/usb/mediatek,mt6360-tcpc.yaml#" 5 - $schema: "http://devicetree.org/meta-schemas/core.yaml#" 4 + $id: http://devicetree.org/schemas/usb/mediatek,mt6360-tcpc.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 6 7 7 title: Mediatek MT6360 Type-C Port Switch and Power Delivery controller 8 8
+2 -2
Documentation/devicetree/bindings/usb/mediatek,mt6370-tcpc.yaml
··· 1 1 # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) 2 2 %YAML 1.2 3 3 --- 4 - $id: "http://devicetree.org/schemas/usb/mediatek,mt6370-tcpc.yaml#" 5 - $schema: "http://devicetree.org/meta-schemas/core.yaml#" 4 + $id: http://devicetree.org/schemas/usb/mediatek,mt6370-tcpc.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 6 7 7 title: MediatTek MT6370 Type-C Port Switch and Power Delivery controller 8 8
+3 -9
Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.yaml
··· 11 11 - Chunfeng Yun <chunfeng.yun@mediatek.com> 12 12 13 13 allOf: 14 - - $ref: "usb-xhci.yaml" 14 + - $ref: usb-xhci.yaml 15 15 16 16 description: | 17 17 There are two scenarios: ··· 77 77 - description: Mcu bus clock for register access 78 78 - description: DMA bus clock for data transfer 79 79 - description: controller clock 80 + - description: frame count clock 80 81 81 82 clock-names: 82 83 minItems: 1 ··· 87 86 - const: mcu_ck 88 87 - const: dma_ck 89 88 - const: xhci_ck 90 - 91 - assigned-clocks: 92 - minItems: 1 93 - maxItems: 5 94 - 95 - assigned-clock-parents: 96 - minItems: 1 97 - maxItems: 5 89 + - const: frmcnt_ck 98 90 99 91 phys: 100 92 description:
+8 -4
Documentation/devicetree/bindings/usb/mediatek,mtu3.yaml
··· 11 11 - Chunfeng Yun <chunfeng.yun@mediatek.com> 12 12 13 13 allOf: 14 - - $ref: "usb-drd.yaml" 14 + - $ref: usb-drd.yaml 15 15 16 16 description: | 17 17 The DRD controller has a glue layer IPPC (IP Port Control), and its host is ··· 66 66 - description: Reference clock used by low power mode etc 67 67 - description: Mcu bus clock for register access 68 68 - description: DMA bus clock for data transfer 69 + - description: DRD controller clock 70 + - description: Frame count clock 69 71 70 72 clock-names: 71 73 minItems: 1 ··· 76 74 - const: ref_ck 77 75 - const: mcu_ck 78 76 - const: dma_ck 77 + - const: xhci_ck 78 + - const: frmcnt_ck 79 79 80 80 phys: 81 81 description: ··· 208 204 example if the host mode is enabled. 209 205 210 206 dependencies: 211 - connector: [ 'usb-role-switch' ] 212 - port: [ 'usb-role-switch' ] 213 - role-switch-default-mode: [ 'usb-role-switch' ] 207 + connector: [ usb-role-switch ] 208 + port: [ usb-role-switch ] 209 + role-switch-default-mode: [ usb-role-switch ] 214 210 wakeup-source: [ 'mediatek,syscon-wakeup' ] 215 211 216 212 required:
+2 -2
Documentation/devicetree/bindings/usb/mediatek,musb.yaml
··· 68 68 type: object 69 69 70 70 dependencies: 71 - usb-role-switch: [ 'connector' ] 72 - connector: [ 'usb-role-switch' ] 71 + usb-role-switch: [ connector ] 72 + connector: [ usb-role-switch ] 73 73 74 74 required: 75 75 - compatible
+2 -2
Documentation/devicetree/bindings/usb/nvidia,tegra-xudc.yaml
··· 1 1 # SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) 2 2 %YAML 1.2 3 3 --- 4 - $id: "http://devicetree.org/schemas/usb/nvidia,tegra-xudc.yaml#" 5 - $schema: "http://devicetree.org/meta-schemas/core.yaml#" 4 + $id: http://devicetree.org/schemas/usb/nvidia,tegra-xudc.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 6 7 7 title: NVIDIA Tegra XUSB device mode controller (XUDC) 8 8
+72
Documentation/devicetree/bindings/usb/nxp,ptn5110.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/usb/nxp,ptn5110.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: NXP PTN5110 Typec Port Cotroller 8 + 9 + maintainers: 10 + - Li Jun <jun.li@nxp.com> 11 + 12 + properties: 13 + compatible: 14 + const: nxp,ptn5110 15 + 16 + reg: 17 + maxItems: 1 18 + 19 + interrupts: 20 + maxItems: 1 21 + 22 + connector: 23 + type: object 24 + $ref: /schemas/connector/usb-connector.yaml# 25 + unevaluatedProperties: false 26 + 27 + required: 28 + - compatible 29 + - reg 30 + - interrupts 31 + - connector 32 + 33 + additionalProperties: false 34 + 35 + examples: 36 + - | 37 + #include <dt-bindings/interrupt-controller/arm-gic.h> 38 + #include <dt-bindings/usb/pd.h> 39 + i2c { 40 + #address-cells = <1>; 41 + #size-cells = <0>; 42 + 43 + tcpci@50 { 44 + compatible = "nxp,ptn5110"; 45 + reg = <0x50>; 46 + interrupt-parent = <&gpio3>; 47 + interrupts = <3 IRQ_TYPE_LEVEL_LOW>; 48 + 49 + usb_con: connector { 50 + compatible = "usb-c-connector"; 51 + label = "USB-C"; 52 + data-role = "dual"; 53 + power-role = "dual"; 54 + try-power-role = "sink"; 55 + source-pdos = <PDO_FIXED(5000, 2000, PDO_FIXED_USB_COMM)>; 56 + sink-pdos = <PDO_FIXED(5000, 2000, PDO_FIXED_USB_COMM) PDO_VAR(5000, 12000, 2000)>; 57 + op-sink-microwatt = <10000000>; 58 + 59 + ports { 60 + #address-cells = <1>; 61 + #size-cells = <0>; 62 + 63 + port@0 { 64 + reg = <0>; 65 + typec1_dr_sw: endpoint { 66 + remote-endpoint = <&usb1_drd_sw>; 67 + }; 68 + }; 69 + }; 70 + }; 71 + }; 72 + };
+2
Documentation/devicetree/bindings/usb/qcom,dwc3.yaml
··· 21 21 - qcom,msm8994-dwc3 22 22 - qcom,msm8996-dwc3 23 23 - qcom,msm8998-dwc3 24 + - qcom,qcm2290-dwc3 24 25 - qcom,qcs404-dwc3 25 26 - qcom,sc7180-dwc3 26 27 - qcom,sc7280-dwc3 ··· 302 301 compatible: 303 302 contains: 304 303 enum: 304 + - qcom,qcm2290-dwc3 305 305 - qcom,sm6115-dwc3 306 306 - qcom,sm6125-dwc3 307 307 - qcom,sm8150-dwc3
+1 -1
Documentation/devicetree/bindings/usb/realtek,rts5411.yaml
··· 26 26 phandle to the regulator that provides power to the hub. 27 27 28 28 peer-hub: 29 - $ref: '/schemas/types.yaml#/definitions/phandle' 29 + $ref: /schemas/types.yaml#/definitions/phandle 30 30 description: 31 31 phandle to the peer hub on the controller. 32 32
+2 -2
Documentation/devicetree/bindings/usb/richtek,rt1711h.yaml
··· 1 1 # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) 2 2 %YAML 1.2 3 3 --- 4 - $id: "http://devicetree.org/schemas/usb/richtek,rt1711h.yaml#" 5 - $schema: "http://devicetree.org/meta-schemas/core.yaml#" 4 + $id: http://devicetree.org/schemas/usb/richtek,rt1711h.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 6 7 7 title: Richtek RT1711H Type-C Port Switch and Power Delivery controller 8 8
+2 -2
Documentation/devicetree/bindings/usb/richtek,rt1719.yaml
··· 1 1 # SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause 2 2 %YAML 1.2 3 3 --- 4 - $id: "http://devicetree.org/schemas/usb/richtek,rt1719.yaml#" 5 - $schema: "http://devicetree.org/meta-schemas/core.yaml#" 4 + $id: http://devicetree.org/schemas/usb/richtek,rt1719.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 6 7 7 title: Richtek RT1719 sink-only Type-C PD controller 8 8
+52 -2
Documentation/devicetree/bindings/usb/smsc,usb3503.yaml
··· 14 14 enum: 15 15 - smsc,usb3503 16 16 - smsc,usb3503a 17 + - smsc,usb3803 17 18 18 19 reg: 19 20 maxItems: 1 ··· 34 33 description: > 35 34 GPIO for reset 36 35 36 + bypass-gpios: 37 + maxItems: 1 38 + description: > 39 + GPIO for bypass. 40 + Control signal to select between HUB MODE and BYPASS MODE. 41 + 37 42 disabled-ports: 38 43 $ref: /schemas/types.yaml#/definitions/uint32-array 39 44 minItems: 1 ··· 53 46 54 47 initial-mode: 55 48 $ref: /schemas/types.yaml#/definitions/uint32 56 - enum: [1, 2] 57 49 description: > 58 - Specifies initial mode. 1 for Hub mode, 2 for standby mode. 50 + Specifies initial mode. 1 for Hub mode, 2 for standby mode and 3 for bypass mode. 51 + In bypass mode the downstream port 3 is connected to the upstream port with low 52 + switch resistance R_on. 59 53 60 54 clocks: 61 55 maxItems: 1 ··· 79 71 required: 80 72 - compatible 81 73 74 + allOf: 75 + - if: 76 + not: 77 + properties: 78 + compatible: 79 + enum: 80 + - smsc,usb3803 81 + then: 82 + properties: 83 + bypass-gpios: false 84 + 85 + - if: 86 + required: 87 + - bypass-gpios 88 + then: 89 + properties: 90 + initial-mode: 91 + enum: [1, 2, 3] 92 + else: 93 + properties: 94 + initial-mode: 95 + enum: [1, 2] 96 + 82 97 additionalProperties: false 83 98 84 99 examples: ··· 118 87 intn-gpios = <&gpx3 4 1>; 119 88 reset-gpios = <&gpx3 5 1>; 120 89 initial-mode = <1>; 90 + clocks = <&clks 80>; 91 + clock-names = "refclk"; 92 + }; 93 + }; 94 + 95 + - | 96 + i2c { 97 + #address-cells = <1>; 98 + #size-cells = <0>; 99 + 100 + usb-hub@8 { 101 + compatible = "smsc,usb3803"; 102 + reg = <0x08>; 103 + connect-gpios = <&gpx3 0 1>; 104 + disabled-ports = <2 3>; 105 + intn-gpios = <&gpx3 4 1>; 106 + reset-gpios = <&gpx3 5 1>; 107 + bypass-gpios = <&gpx3 6 1>; 108 + initial-mode = <3>; 121 109 clocks = <&clks 80>; 122 110 clock-names = "refclk"; 123 111 };
+33
Documentation/devicetree/bindings/usb/snps,dwc3.yaml
··· 70 70 71 71 dma-coherent: true 72 72 73 + extcon: 74 + maxItems: 1 75 + deprecated: true 76 + 73 77 iommus: 74 78 maxItems: 1 75 79 ··· 236 232 When set, all SuperSpeed bus instances in park mode are disabled. 237 233 type: boolean 238 234 235 + snps,parkmode-disable-hs-quirk: 236 + description: 237 + When set, all HighSpeed bus instances in park mode are disabled. 238 + type: boolean 239 + 239 240 snps,dis_metastability_quirk: 240 241 description: 241 242 When set, disable metastability workaround. CAUTION! Use only if you are ··· 263 254 Fix the issue of HS terminations CRC error on resume by enabling this 264 255 quirk. When set, all the termsel, xcvrsel, opmode becomes 0 during end 265 256 of resume. This option is to support certain legacy ULPI PHYs. 257 + type: boolean 258 + 259 + snps,ulpi-ext-vbus-drv: 260 + description: 261 + Some ULPI USB PHY does not support internal VBUS supply, and driving 262 + the CPEN pin, requires the configuration of the ulpi DRVVBUSEXTERNAL 263 + bit. When set, the xhci host will configure the USB2 PHY drives VBUS 264 + with an external supply. 266 265 type: boolean 267 266 268 267 snps,is-utmi-l1-suspend: ··· 381 364 description: 382 365 This port is used with the 'usb-role-switch' property to connect the 383 366 dwc3 to type C connector. 367 + 368 + ports: 369 + $ref: /schemas/graph.yaml#/properties/ports 370 + description: 371 + Those ports should be used with any connector to the data bus of this 372 + controller using the OF graph bindings specified if the "usb-role-switch" 373 + property is used. 374 + 375 + properties: 376 + port@0: 377 + $ref: /schemas/graph.yaml#/properties/port 378 + description: High Speed (HS) data bus. 379 + 380 + port@1: 381 + $ref: /schemas/graph.yaml#/properties/port 382 + description: Super Speed (SS) data bus. 384 383 385 384 wakeup-source: 386 385 $ref: /schemas/types.yaml#/definitions/flag
+2 -2
Documentation/devicetree/bindings/usb/st,stusb160x.yaml
··· 1 1 # SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause 2 2 %YAML 1.2 3 3 --- 4 - $id: "http://devicetree.org/schemas/usb/st,stusb160x.yaml#" 5 - $schema: "http://devicetree.org/meta-schemas/core.yaml#" 4 + $id: http://devicetree.org/schemas/usb/st,stusb160x.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 6 7 7 title: STMicroelectronics STUSB160x Type-C controller 8 8
+2 -8
Documentation/devicetree/bindings/usb/ti,j721e-usb.yaml
··· 1 1 # SPDX-License-Identifier: GPL-2.0 2 2 %YAML 1.2 3 3 --- 4 - $id: "http://devicetree.org/schemas/usb/ti,j721e-usb.yaml#" 5 - $schema: "http://devicetree.org/meta-schemas/core.yaml#" 4 + $id: http://devicetree.org/schemas/usb/ti,j721e-usb.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 6 7 7 title: TI wrapper module for the Cadence USBSS-DRD controller 8 8 ··· 52 52 Should be present if USB VBUS line is connected to the 53 53 VBUS pin of the SoC via a 1/3 voltage divider. 54 54 type: boolean 55 - 56 - assigned-clocks: 57 - maxItems: 1 58 - 59 - assigned-clock-parents: 60 - maxItems: 1 61 55 62 56 '#address-cells': 63 57 const: 2
-8
Documentation/devicetree/bindings/usb/ti,keystone-dwc3.yaml
··· 34 34 minItems: 1 35 35 maxItems: 2 36 36 37 - assigned-clocks: 38 - minItems: 1 39 - maxItems: 2 40 - 41 - assigned-clock-parents: 42 - minItems: 1 43 - maxItems: 2 44 - 45 37 power-domains: 46 38 maxItems: 1 47 39 description: Should contain a phandle to a PM domain provider node
+2 -4
Documentation/devicetree/bindings/usb/ti,tps6598x.yaml
··· 1 1 # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) 2 2 %YAML 1.2 3 3 --- 4 - $id: "http://devicetree.org/schemas/usb/ti,tps6598x.yaml#" 5 - $schema: "http://devicetree.org/meta-schemas/core.yaml#" 4 + $id: http://devicetree.org/schemas/usb/ti,tps6598x.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 6 7 7 title: Texas Instruments 6598x Type-C Port Switch and Power Delivery controller 8 8 ··· 35 35 required: 36 36 - compatible 37 37 - reg 38 - - interrupts 39 - - interrupt-names 40 38 41 39 additionalProperties: true 42 40
-49
Documentation/devicetree/bindings/usb/typec-tcpci.txt
··· 1 - TCPCI(Typec port cotroller interface) binding 2 - --------------------------------------------- 3 - 4 - Required properties: 5 - - compatible: should be set one of following: 6 - - "nxp,ptn5110" for NXP USB PD TCPC PHY IC ptn5110. 7 - 8 - - reg: the i2c slave address of typec port controller device. 9 - - interrupt-parent: the phandle to the interrupt controller which provides 10 - the interrupt. 11 - - interrupts: interrupt specification for tcpci alert. 12 - 13 - Required sub-node: 14 - - connector: The "usb-c-connector" attached to the tcpci chip, the bindings 15 - of connector node are specified in 16 - Documentation/devicetree/bindings/connector/usb-connector.yaml 17 - 18 - Example: 19 - 20 - ptn5110@50 { 21 - compatible = "nxp,ptn5110"; 22 - reg = <0x50>; 23 - interrupt-parent = <&gpio3>; 24 - interrupts = <3 IRQ_TYPE_LEVEL_LOW>; 25 - 26 - usb_con: connector { 27 - compatible = "usb-c-connector"; 28 - label = "USB-C"; 29 - data-role = "dual"; 30 - power-role = "dual"; 31 - try-power-role = "sink"; 32 - source-pdos = <PDO_FIXED(5000, 2000, PDO_FIXED_USB_COMM)>; 33 - sink-pdos = <PDO_FIXED(5000, 2000, PDO_FIXED_USB_COMM) 34 - PDO_VAR(5000, 12000, 2000)>; 35 - op-sink-microwatt = <10000000>; 36 - 37 - ports { 38 - #address-cells = <1>; 39 - #size-cells = <0>; 40 - 41 - port@1 { 42 - reg = <1>; 43 - usb_con_ss: endpoint { 44 - remote-endpoint = <&usb3_data_ss>; 45 - }; 46 - }; 47 - }; 48 - }; 49 - };
-1
Documentation/devicetree/bindings/usb/usb-device.yaml
··· 76 76 maxItems: 1 77 77 78 78 required: 79 - - compatible 80 79 - reg 81 80 82 81 additionalProperties: true
+3
Documentation/devicetree/bindings/usb/usb-nop-xceiv.yaml
··· 27 27 vcc-supply: 28 28 description: phandle to the regulator that provides power to the PHY. 29 29 30 + power-domains: 31 + maxItems: 1 32 + 30 33 reset-gpios: 31 34 maxItems: 1 32 35
+1 -1
Documentation/devicetree/bindings/usb/usb-xhci.yaml
··· 10 10 - Mathias Nyman <mathias.nyman@intel.com> 11 11 12 12 allOf: 13 - - $ref: "usb-hcd.yaml#" 13 + - $ref: usb-hcd.yaml# 14 14 15 15 properties: 16 16 usb2-lpm-disable:
-19
Documentation/devicetree/bindings/usb/usbmisc-imx.txt
··· 1 - * Freescale i.MX non-core registers 2 - 3 - Required properties: 4 - - #index-cells: Cells used to describe usb controller index. Should be <1> 5 - - compatible: Should be one of below: 6 - "fsl,imx6q-usbmisc" for imx6q 7 - "fsl,vf610-usbmisc" for Vybrid vf610 8 - "fsl,imx6sx-usbmisc" for imx6sx 9 - "fsl,imx7d-usbmisc" for imx7d 10 - "fsl,imx7ulp-usbmisc" for imx7ulp 11 - "fsl,imx8mm-usbmisc" for imx8mm 12 - - reg: Should contain registers location and length 13 - 14 - Examples: 15 - usbmisc@2184800 { 16 - #index-cells = <1>; 17 - compatible = "fsl,imx6q-usbmisc"; 18 - reg = <0x02184800 0x200>; 19 - };
+28
Documentation/usb/gadget_uvc.rst
··· 275 275 276 276 bNrInPins and baSourceID function in the same way. 277 277 278 + Configuring Supported Controls for Camera Terminal and Processing Unit 279 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 280 + 281 + The Camera Terminal and Processing Units in the UVC chain also have bmControls 282 + attributes which function similarly to the same field in an Extension Unit. 283 + Unlike XUs however, the meaning of the bitflag for these units is defined in 284 + the UVC specification; you should consult the "Camera Terminal Descriptor" and 285 + "Processing Unit Descriptor" sections for an enumeration of the flags. 286 + 287 + .. code-block:: bash 288 + 289 + # Set the Processing Unit's bmControls, flagging Brightness, Contrast 290 + # and Hue as available controls: 291 + echo 0x05 > $FUNCTION/control/processing/default/bmControls 292 + 293 + # Set the Camera Terminal's bmControls, flagging Focus Absolute and 294 + # Focus Relative as available controls: 295 + echo 0x60 > $FUNCTION/control/terminal/camera/default/bmControls 296 + 297 + If you do not set these fields then by default the Auto-Exposure Mode control 298 + for the Camera Terminal and the Brightness control for the Processing Unit will 299 + be flagged as available; if they are not supported you should set the field to 300 + 0x00. 301 + 302 + Note that the size of the bmControls field for a Camera Terminal or Processing 303 + Unit is fixed by the UVC specification, and so the bControlSize attribute is 304 + read-only here. 305 + 278 306 Custom Strings Support 279 307 ~~~~~~~~~~~~~~~~~~~~~~ 280 308
+3 -2
arch/arm/boot/dts/imx7ulp.dtsi
··· 189 189 }; 190 190 191 191 usbotg1: usb@40330000 { 192 - compatible = "fsl,imx7ulp-usb", "fsl,imx6ul-usb"; 192 + compatible = "fsl,imx7ulp-usb", "fsl,imx6ul-usb", "fsl,imx27-usb"; 193 193 reg = <0x40330000 0x200>; 194 194 interrupts = <GIC_SPI 40 IRQ_TYPE_LEVEL_HIGH>; 195 195 clocks = <&pcc2 IMX7ULP_CLK_USB0>; ··· 202 202 }; 203 203 204 204 usbmisc1: usbmisc@40330200 { 205 - compatible = "fsl,imx7ulp-usbmisc", "fsl,imx7d-usbmisc"; 205 + compatible = "fsl,imx7ulp-usbmisc", "fsl,imx7d-usbmisc", 206 + "fsl,imx6q-usbmisc"; 206 207 #index-cells = <1>; 207 208 reg = <0x40330200 0x200>; 208 209 };
+2 -2
arch/arm/boot/dts/stm32mp151.dtsi
··· 1130 1130 usbotg_hs: usb-otg@49000000 { 1131 1131 compatible = "st,stm32mp15-hsotg", "snps,dwc2"; 1132 1132 reg = <0x49000000 0x10000>; 1133 - clocks = <&rcc USBO_K>; 1134 - clock-names = "otg"; 1133 + clocks = <&rcc USBO_K>, <&usbphyc>; 1134 + clock-names = "otg", "utmi"; 1135 1135 resets = <&rcc USBO_R>; 1136 1136 reset-names = "dwc2"; 1137 1137 interrupts = <GIC_SPI 98 IRQ_TYPE_LEVEL_HIGH>;
+2 -2
arch/arm64/boot/dts/freescale/imx8-ss-conn.dtsi
··· 35 35 }; 36 36 37 37 usbotg1: usb@5b0d0000 { 38 - compatible = "fsl,imx7ulp-usb"; 38 + compatible = "fsl,imx7ulp-usb", "fsl,imx6ul-usb", "fsl,imx27-usb"; 39 39 reg = <0x5b0d0000 0x200>; 40 40 interrupt-parent = <&gic>; 41 41 interrupts = <GIC_SPI 267 IRQ_TYPE_LEVEL_HIGH>; ··· 51 51 52 52 usbmisc1: usbmisc@5b0d0200 { 53 53 #index-cells = <1>; 54 - compatible = "fsl,imx7ulp-usbmisc", "fsl,imx6q-usbmisc"; 54 + compatible = "fsl,imx7ulp-usbmisc", "fsl,imx7d-usbmisc", "fsl,imx6q-usbmisc"; 55 55 reg = <0x5b0d0200 0x200>; 56 56 }; 57 57
+2 -3
arch/arm64/boot/dts/freescale/imx8dxl-ss-conn.dtsi
··· 34 34 }; 35 35 36 36 usbotg2: usb@5b0e0000 { 37 - compatible = "fsl,imx8dxl-usb", "fsl,imx7ulp-usb"; 37 + compatible = "fsl,imx8dxl-usb", "fsl,imx7ulp-usb", "fsl,imx6ul-usb"; 38 38 reg = <0x5b0e0000 0x200>; 39 39 interrupt-parent = <&gic>; 40 40 interrupts = <GIC_SPI 166 IRQ_TYPE_LEVEL_HIGH>; ··· 49 49 ahb-burst-config = <0x0>; 50 50 tx-burst-size-dword = <0x10>; 51 51 rx-burst-size-dword = <0x10>; 52 - #stream-id-cells = <1>; 53 52 power-domains = <&pd IMX_SC_R_USB_1>; 54 53 status = "disabled"; 55 54 ··· 62 63 63 64 usbmisc2: usbmisc@5b0e0200 { 64 65 #index-cells = <1>; 65 - compatible = "fsl,imx7ulp-usbmisc"; 66 + compatible = "fsl,imx7ulp-usbmisc", "fsl,imx7d-usbmisc", "fsl,imx6q-usbmisc"; 66 67 reg = <0x5b0e0200 0x200>; 67 68 }; 68 69
+6 -4
arch/arm64/boot/dts/freescale/imx8mm.dtsi
··· 1253 1253 }; 1254 1254 1255 1255 usbotg1: usb@32e40000 { 1256 - compatible = "fsl,imx8mm-usb", "fsl,imx7d-usb"; 1256 + compatible = "fsl,imx8mm-usb", "fsl,imx7d-usb", "fsl,imx27-usb"; 1257 1257 reg = <0x32e40000 0x200>; 1258 1258 interrupts = <GIC_SPI 40 IRQ_TYPE_LEVEL_HIGH>; 1259 1259 clocks = <&clk IMX8MM_CLK_USB1_CTRL_ROOT>; ··· 1267 1267 }; 1268 1268 1269 1269 usbmisc1: usbmisc@32e40200 { 1270 - compatible = "fsl,imx8mm-usbmisc", "fsl,imx7d-usbmisc"; 1270 + compatible = "fsl,imx8mm-usbmisc", "fsl,imx7d-usbmisc", 1271 + "fsl,imx6q-usbmisc"; 1271 1272 #index-cells = <1>; 1272 1273 reg = <0x32e40200 0x200>; 1273 1274 }; 1274 1275 1275 1276 usbotg2: usb@32e50000 { 1276 - compatible = "fsl,imx8mm-usb", "fsl,imx7d-usb"; 1277 + compatible = "fsl,imx8mm-usb", "fsl,imx7d-usb", "fsl,imx27-usb"; 1277 1278 reg = <0x32e50000 0x200>; 1278 1279 interrupts = <GIC_SPI 41 IRQ_TYPE_LEVEL_HIGH>; 1279 1280 clocks = <&clk IMX8MM_CLK_USB1_CTRL_ROOT>; ··· 1288 1287 }; 1289 1288 1290 1289 usbmisc2: usbmisc@32e50200 { 1291 - compatible = "fsl,imx8mm-usbmisc", "fsl,imx7d-usbmisc"; 1290 + compatible = "fsl,imx8mm-usbmisc", "fsl,imx7d-usbmisc", 1291 + "fsl,imx6q-usbmisc"; 1292 1292 #index-cells = <1>; 1293 1293 reg = <0x32e50200 0x200>; 1294 1294 };
+3 -2
arch/arm64/boot/dts/freescale/imx8mn.dtsi
··· 1146 1146 }; 1147 1147 1148 1148 usbotg1: usb@32e40000 { 1149 - compatible = "fsl,imx8mn-usb", "fsl,imx7d-usb"; 1149 + compatible = "fsl,imx8mn-usb", "fsl,imx7d-usb", "fsl,imx27-usb"; 1150 1150 reg = <0x32e40000 0x200>; 1151 1151 interrupts = <GIC_SPI 40 IRQ_TYPE_LEVEL_HIGH>; 1152 1152 clocks = <&clk IMX8MN_CLK_USB1_CTRL_ROOT>; ··· 1160 1160 }; 1161 1161 1162 1162 usbmisc1: usbmisc@32e40200 { 1163 - compatible = "fsl,imx8mn-usbmisc", "fsl,imx7d-usbmisc"; 1163 + compatible = "fsl,imx8mn-usbmisc", "fsl,imx7d-usbmisc", 1164 + "fsl,imx6q-usbmisc"; 1164 1165 #index-cells = <1>; 1165 1166 reg = <0x32e40200 0x200>; 1166 1167 };
-2
arch/arm64/boot/dts/freescale/imx8mq.dtsi
··· 1453 1453 phys = <&usb3_phy0>, <&usb3_phy0>; 1454 1454 phy-names = "usb2-phy", "usb3-phy"; 1455 1455 power-domains = <&pgc_otg1>; 1456 - usb3-resume-missing-cas; 1457 1456 status = "disabled"; 1458 1457 }; 1459 1458 ··· 1484 1485 phys = <&usb3_phy1>, <&usb3_phy1>; 1485 1486 phy-names = "usb2-phy", "usb3-phy"; 1486 1487 power-domains = <&pgc_otg2>; 1487 - usb3-resume-missing-cas; 1488 1488 status = "disabled"; 1489 1489 }; 1490 1490
-2
arch/mips/configs/mtx1_defconfig
··· 497 497 CONFIG_USB_OHCI_HCD=m 498 498 CONFIG_USB_OHCI_HCD_PLATFORM=m 499 499 CONFIG_USB_UHCI_HCD=m 500 - CONFIG_USB_U132_HCD=m 501 500 CONFIG_USB_SL811_HCD=m 502 501 CONFIG_USB_SL811_CS=m 503 502 CONFIG_USB_ACM=m ··· 553 554 CONFIG_USB_CYPRESS_CY7C63=m 554 555 CONFIG_USB_CYTHERM=m 555 556 CONFIG_USB_IDMOUSE=m 556 - CONFIG_USB_FTDI_ELAN=m 557 557 CONFIG_USB_APPLEDISPLAY=m 558 558 CONFIG_USB_SISUSBVGA=m 559 559 CONFIG_USB_LD=m
-2
arch/powerpc/configs/ppc6xx_defconfig
··· 845 845 CONFIG_USB_OHCI_HCD_PPC_OF_BE=y 846 846 CONFIG_USB_OHCI_HCD_PPC_OF_LE=y 847 847 CONFIG_USB_UHCI_HCD=m 848 - CONFIG_USB_U132_HCD=m 849 848 CONFIG_USB_SL811_HCD=m 850 849 CONFIG_USB_ACM=m 851 850 CONFIG_USB_PRINTER=m ··· 907 908 CONFIG_USB_LEGOTOWER=m 908 909 CONFIG_USB_LCD=m 909 910 CONFIG_USB_IDMOUSE=m 910 - CONFIG_USB_FTDI_ELAN=m 911 911 CONFIG_USB_APPLEDISPLAY=m 912 912 CONFIG_USB_SISUSBVGA=m 913 913 CONFIG_USB_LD=m
+10
drivers/media/radio/radio-shark.c
··· 316 316 { 317 317 struct shark_device *shark; 318 318 int retval = -ENOMEM; 319 + static const u8 ep_addresses[] = { 320 + SHARK_IN_EP | USB_DIR_IN, 321 + SHARK_OUT_EP | USB_DIR_OUT, 322 + 0}; 323 + 324 + /* Are the expected endpoints present? */ 325 + if (!usb_check_int_endpoints(intf, ep_addresses)) { 326 + dev_err(&intf->dev, "Invalid radioSHARK device\n"); 327 + return -EINVAL; 328 + } 319 329 320 330 shark = kzalloc(sizeof(struct shark_device), GFP_KERNEL); 321 331 if (!shark)
+10
drivers/media/radio/radio-shark2.c
··· 282 282 { 283 283 struct shark_device *shark; 284 284 int retval = -ENOMEM; 285 + static const u8 ep_addresses[] = { 286 + SHARK_IN_EP | USB_DIR_IN, 287 + SHARK_OUT_EP | USB_DIR_OUT, 288 + 0}; 289 + 290 + /* Are the expected endpoints present? */ 291 + if (!usb_check_int_endpoints(intf, ep_addresses)) { 292 + dev_err(&intf->dev, "Invalid radioSHARK2 device\n"); 293 + return -EINVAL; 294 + } 285 295 286 296 shark = kzalloc(sizeof(struct shark_device), GFP_KERNEL); 287 297 if (!shark)
+1 -1
drivers/thunderbolt/acpi.c
··· 341 341 */ 342 342 if (tb_is_switch(dev)) 343 343 return tb_acpi_switch_find_companion(tb_to_switch(dev)); 344 - else if (tb_is_usb4_port_device(dev)) 344 + if (tb_is_usb4_port_device(dev)) 345 345 return acpi_find_child_by_adr(ACPI_COMPANION(dev->parent), 346 346 tb_to_usb4_port_device(dev)->port->port); 347 347 return NULL;
+1 -1
drivers/thunderbolt/ctl.c
··· 1033 1033 1034 1034 if (res->tb_error == TB_CFG_ERROR_LOCK) 1035 1035 return -EACCES; 1036 - else if (res->tb_error == TB_CFG_ERROR_PORT_NOT_CONNECTED) 1036 + if (res->tb_error == TB_CFG_ERROR_PORT_NOT_CONNECTED) 1037 1037 return -ENOTCONN; 1038 1038 1039 1039 return -EIO;
+118 -108
drivers/thunderbolt/eeprom.c
··· 416 416 if (pos + 1 == drom_size || pos + entry->len > drom_size 417 417 || !entry->len) { 418 418 tb_sw_warn(sw, "DROM buffer overrun\n"); 419 - return -EILSEQ; 419 + return -EIO; 420 420 } 421 421 422 422 switch (entry->type) { ··· 471 471 472 472 static int tb_drom_copy_nvm(struct tb_switch *sw, u16 *size) 473 473 { 474 - u32 drom_offset; 474 + u16 drom_offset; 475 475 int ret; 476 476 477 477 if (!sw->dma_port) 478 478 return -ENODEV; 479 479 480 - ret = tb_sw_read(sw, &drom_offset, TB_CFG_SWITCH, 481 - sw->cap_plug_events + 12, 1); 480 + ret = tb_eeprom_get_drom_offset(sw, &drom_offset); 482 481 if (ret) 483 482 return ret; 484 483 ··· 512 513 return ret; 513 514 } 514 515 515 - static int usb4_copy_host_drom(struct tb_switch *sw, u16 *size) 516 + static int usb4_copy_drom(struct tb_switch *sw, u16 *size) 516 517 { 517 518 int ret; 518 519 ··· 535 536 return ret; 536 537 } 537 538 538 - static int tb_drom_read_n(struct tb_switch *sw, u16 offset, u8 *val, 539 - size_t count) 539 + static int tb_drom_bit_bang(struct tb_switch *sw, u16 *size) 540 540 { 541 - if (tb_switch_is_usb4(sw)) 542 - return usb4_switch_drom_read(sw, offset, val, count); 543 - return tb_eeprom_read_n(sw, offset, val, count); 541 + int ret; 542 + 543 + ret = tb_eeprom_read_n(sw, 14, (u8 *)size, 2); 544 + if (ret) 545 + return ret; 546 + 547 + *size &= 0x3ff; 548 + *size += TB_DROM_DATA_START; 549 + 550 + tb_sw_dbg(sw, "reading DROM (length: %#x)\n", *size); 551 + if (*size < sizeof(struct tb_drom_header)) { 552 + tb_sw_warn(sw, "DROM too small, aborting\n"); 553 + return -EIO; 554 + } 555 + 556 + sw->drom = kzalloc(*size, GFP_KERNEL); 557 + if (!sw->drom) 558 + return -ENOMEM; 559 + 560 + ret = tb_eeprom_read_n(sw, 0, sw->drom, *size); 561 + if (ret) 562 + goto err; 563 + 564 + return 0; 565 + 566 + err: 567 + kfree(sw->drom); 568 + sw->drom = NULL; 569 + return ret; 544 570 } 545 571 546 - static int tb_drom_parse(struct tb_switch *sw) 572 + static int tb_drom_parse_v1(struct tb_switch *sw) 547 573 { 548 574 const struct tb_drom_header *header = 549 575 (const struct tb_drom_header *)sw->drom; ··· 579 555 tb_sw_warn(sw, 580 556 "DROM UID CRC8 mismatch (expected: %#x, got: %#x)\n", 581 557 header->uid_crc8, crc); 582 - return -EILSEQ; 558 + return -EIO; 583 559 } 584 560 if (!sw->uid) 585 561 sw->uid = header->uid; ··· 613 589 return tb_drom_parse_entries(sw, USB4_DROM_HEADER_SIZE); 614 590 } 615 591 592 + static int tb_drom_parse(struct tb_switch *sw, u16 size) 593 + { 594 + const struct tb_drom_header *header = (const void *)sw->drom; 595 + int ret; 596 + 597 + if (header->data_len + TB_DROM_DATA_START != size) { 598 + tb_sw_warn(sw, "DROM size mismatch\n"); 599 + ret = -EIO; 600 + goto err; 601 + } 602 + 603 + tb_sw_dbg(sw, "DROM version: %d\n", header->device_rom_revision); 604 + 605 + switch (header->device_rom_revision) { 606 + case 3: 607 + ret = usb4_drom_parse(sw); 608 + break; 609 + default: 610 + tb_sw_warn(sw, "DROM device_rom_revision %#x unknown\n", 611 + header->device_rom_revision); 612 + fallthrough; 613 + case 1: 614 + ret = tb_drom_parse_v1(sw); 615 + break; 616 + } 617 + 618 + if (ret) { 619 + tb_sw_warn(sw, "parsing DROM failed\n"); 620 + goto err; 621 + } 622 + 623 + return 0; 624 + 625 + err: 626 + kfree(sw->drom); 627 + sw->drom = NULL; 628 + 629 + return ret; 630 + } 631 + 632 + static int tb_drom_host_read(struct tb_switch *sw) 633 + { 634 + u16 size; 635 + 636 + if (tb_switch_is_usb4(sw)) { 637 + usb4_switch_read_uid(sw, &sw->uid); 638 + if (!usb4_copy_drom(sw, &size)) 639 + return tb_drom_parse(sw, size); 640 + } else { 641 + if (!tb_drom_copy_efi(sw, &size)) 642 + return tb_drom_parse(sw, size); 643 + 644 + if (!tb_drom_copy_nvm(sw, &size)) 645 + return tb_drom_parse(sw, size); 646 + 647 + tb_drom_read_uid_only(sw, &sw->uid); 648 + } 649 + 650 + return 0; 651 + } 652 + 653 + static int tb_drom_device_read(struct tb_switch *sw) 654 + { 655 + u16 size; 656 + int ret; 657 + 658 + if (tb_switch_is_usb4(sw)) { 659 + usb4_switch_read_uid(sw, &sw->uid); 660 + ret = usb4_copy_drom(sw, &size); 661 + } else { 662 + ret = tb_drom_bit_bang(sw, &size); 663 + } 664 + 665 + if (ret) 666 + return ret; 667 + 668 + return tb_drom_parse(sw, size); 669 + } 670 + 616 671 /** 617 672 * tb_drom_read() - Copy DROM to sw->drom and parse it 618 673 * @sw: Router whose DROM to read and parse ··· 704 601 */ 705 602 int tb_drom_read(struct tb_switch *sw) 706 603 { 707 - u16 size; 708 - struct tb_drom_header *header; 709 - int res, retries = 1; 710 - 711 604 if (sw->drom) 712 605 return 0; 713 606 714 - if (tb_route(sw) == 0) { 715 - /* 716 - * Apple's NHI EFI driver supplies a DROM for the root switch 717 - * in a device property. Use it if available. 718 - */ 719 - if (tb_drom_copy_efi(sw, &size) == 0) 720 - goto parse; 721 - 722 - /* Non-Apple hardware has the DROM as part of NVM */ 723 - if (tb_drom_copy_nvm(sw, &size) == 0) 724 - goto parse; 725 - 726 - /* 727 - * USB4 hosts may support reading DROM through router 728 - * operations. 729 - */ 730 - if (tb_switch_is_usb4(sw)) { 731 - usb4_switch_read_uid(sw, &sw->uid); 732 - if (!usb4_copy_host_drom(sw, &size)) 733 - goto parse; 734 - } else { 735 - /* 736 - * The root switch contains only a dummy drom 737 - * (header only, no entries). Hardcode the 738 - * configuration here. 739 - */ 740 - tb_drom_read_uid_only(sw, &sw->uid); 741 - } 742 - 743 - return 0; 744 - } 745 - 746 - res = tb_drom_read_n(sw, 14, (u8 *) &size, 2); 747 - if (res) 748 - return res; 749 - size &= 0x3ff; 750 - size += TB_DROM_DATA_START; 751 - tb_sw_dbg(sw, "reading drom (length: %#x)\n", size); 752 - if (size < sizeof(*header)) { 753 - tb_sw_warn(sw, "drom too small, aborting\n"); 754 - return -EIO; 755 - } 756 - 757 - sw->drom = kzalloc(size, GFP_KERNEL); 758 - if (!sw->drom) 759 - return -ENOMEM; 760 - read: 761 - res = tb_drom_read_n(sw, 0, sw->drom, size); 762 - if (res) 763 - goto err; 764 - 765 - parse: 766 - header = (void *) sw->drom; 767 - 768 - if (header->data_len + TB_DROM_DATA_START != size) { 769 - tb_sw_warn(sw, "drom size mismatch\n"); 770 - if (retries--) { 771 - msleep(100); 772 - goto read; 773 - } 774 - goto err; 775 - } 776 - 777 - tb_sw_dbg(sw, "DROM version: %d\n", header->device_rom_revision); 778 - 779 - switch (header->device_rom_revision) { 780 - case 3: 781 - res = usb4_drom_parse(sw); 782 - break; 783 - default: 784 - tb_sw_warn(sw, "DROM device_rom_revision %#x unknown\n", 785 - header->device_rom_revision); 786 - fallthrough; 787 - case 1: 788 - res = tb_drom_parse(sw); 789 - break; 790 - } 791 - 792 - /* If the DROM parsing fails, wait a moment and retry once */ 793 - if (res == -EILSEQ && retries--) { 794 - tb_sw_warn(sw, "parsing DROM failed\n"); 795 - msleep(100); 796 - goto read; 797 - } 798 - 799 - if (!res) 800 - return 0; 801 - 802 - err: 803 - kfree(sw->drom); 804 - sw->drom = NULL; 805 - return -EIO; 607 + if (!tb_route(sw)) 608 + return tb_drom_host_read(sw); 609 + return tb_drom_device_read(sw); 806 610 }
+2 -1
drivers/thunderbolt/nhi.c
··· 526 526 ring->hop); 527 527 ret = -EBUSY; 528 528 goto err_unlock; 529 - } else if (!ring->is_tx && nhi->rx_rings[ring->hop]) { 529 + } 530 + if (!ring->is_tx && nhi->rx_rings[ring->hop]) { 530 531 dev_warn(&nhi->pdev->dev, "RX hop %d already allocated\n", 531 532 ring->hop); 532 533 ret = -EBUSY;
+2 -2
drivers/thunderbolt/switch.c
··· 271 271 } 272 272 sw->nvm->authenticating = true; 273 273 return usb4_switch_nvm_authenticate(sw); 274 - } else if (auth_only) { 275 - return -EOPNOTSUPP; 276 274 } 275 + if (auth_only) 276 + return -EOPNOTSUPP; 277 277 278 278 sw->nvm->authenticating = true; 279 279 if (!tb_route(sw)) {
+26 -26
drivers/thunderbolt/usb4.c
··· 9 9 10 10 #include <linux/delay.h> 11 11 #include <linux/ktime.h> 12 + #include <linux/units.h> 12 13 13 14 #include "sb_regs.h" 14 15 #include "tb.h" ··· 852 851 */ 853 852 if (ret == -EOPNOTSUPP) 854 853 return true; 855 - else if (ret) 854 + if (ret) 856 855 return false; 857 856 858 857 return !status; ··· 878 877 &status); 879 878 if (ret == -EOPNOTSUPP) 880 879 return 0; 881 - else if (ret) 880 + if (ret) 882 881 return ret; 883 882 884 883 return status ? -EBUSY : 0; ··· 901 900 &status); 902 901 if (ret == -EOPNOTSUPP) 903 902 return 0; 904 - else if (ret) 903 + if (ret) 905 904 return ret; 906 905 907 906 return status ? -EIO : 0; ··· 1303 1302 return 0; 1304 1303 } 1305 1304 1305 + static int usb4_port_sb_opcode_err_to_errno(u32 val) 1306 + { 1307 + switch (val) { 1308 + case 0: 1309 + return 0; 1310 + case USB4_SB_OPCODE_ERR: 1311 + return -EAGAIN; 1312 + case USB4_SB_OPCODE_ONS: 1313 + return -EOPNOTSUPP; 1314 + default: 1315 + return -EIO; 1316 + } 1317 + } 1318 + 1306 1319 static int usb4_port_sb_op(struct tb_port *port, enum usb4_sb_target target, 1307 1320 u8 index, enum usb4_sb_opcode opcode, int timeout_msec) 1308 1321 { ··· 1339 1324 if (ret) 1340 1325 return ret; 1341 1326 1342 - switch (val) { 1343 - case 0: 1344 - return 0; 1345 - 1346 - case USB4_SB_OPCODE_ERR: 1347 - return -EAGAIN; 1348 - 1349 - case USB4_SB_OPCODE_ONS: 1350 - return -EOPNOTSUPP; 1351 - 1352 - default: 1353 - if (val != opcode) 1354 - return -EIO; 1355 - break; 1356 - } 1327 + if (val != opcode) 1328 + return usb4_port_sb_opcode_err_to_errno(val); 1357 1329 } while (ktime_before(ktime_get(), timeout)); 1358 1330 1359 1331 return -ETIMEDOUT; ··· 1815 1813 if (ret) 1816 1814 return ret; 1817 1815 1818 - switch (val) { 1816 + ret = usb4_port_sb_opcode_err_to_errno(val); 1817 + switch (ret) { 1819 1818 case 0: 1820 1819 *status = 0; 1821 1820 return 0; 1822 1821 1823 - case USB4_SB_OPCODE_ERR: 1822 + case -EAGAIN: 1824 1823 ret = usb4_port_retimer_read(port, index, USB4_SB_METADATA, 1825 1824 &metadata, sizeof(metadata)); 1826 1825 if (ret) ··· 1830 1827 *status = metadata & USB4_SB_METADATA_NVM_AUTH_WRITE_MASK; 1831 1828 return 0; 1832 1829 1833 - case USB4_SB_OPCODE_ONS: 1834 - return -EOPNOTSUPP; 1835 - 1836 1830 default: 1837 - return -EIO; 1831 + return ret; 1838 1832 } 1839 1833 } 1840 1834 ··· 1995 1995 unsigned long uframes; 1996 1996 1997 1997 uframes = bw * 512UL << scale; 1998 - return DIV_ROUND_CLOSEST(uframes * 8000, 1000 * 1000); 1998 + return DIV_ROUND_CLOSEST(uframes * 8000, MEGA); 1999 1999 } 2000 2000 2001 2001 static u32 mbps_to_usb3_bw(unsigned int mbps, u8 scale) ··· 2003 2003 unsigned long uframes; 2004 2004 2005 2005 /* 1 uframe is 1/8 ms (125 us) -> 1 / 8000 s */ 2006 - uframes = ((unsigned long)mbps * 1000 * 1000) / 8000; 2006 + uframes = ((unsigned long)mbps * MEGA) / 8000; 2007 2007 return DIV_ROUND_UP(uframes, 512UL << scale); 2008 2008 } 2009 2009
+10 -14
drivers/thunderbolt/xdomain.c
··· 1178 1178 if (xd->state_retries-- > 0) { 1179 1179 dev_dbg(&xd->dev, "failed to request UUID, retrying\n"); 1180 1180 return -EAGAIN; 1181 - } else { 1182 - dev_dbg(&xd->dev, "failed to read remote UUID\n"); 1183 1181 } 1182 + dev_dbg(&xd->dev, "failed to read remote UUID\n"); 1184 1183 return ret; 1185 1184 } 1186 1185 ··· 1366 1367 dev_dbg(&xd->dev, 1367 1368 "failed to request remote properties, retrying\n"); 1368 1369 return -EAGAIN; 1369 - } else { 1370 - /* Give up now */ 1371 - dev_err(&xd->dev, 1372 - "failed read XDomain properties from %pUb\n", 1373 - xd->remote_uuid); 1374 1370 } 1371 + /* Give up now */ 1372 + dev_err(&xd->dev, "failed read XDomain properties from %pUb\n", 1373 + xd->remote_uuid); 1375 1374 1376 1375 return ret; 1377 1376 } ··· 2176 2179 if (xd->remote_uuid && 2177 2180 uuid_equal(xd->remote_uuid, lookup->uuid)) 2178 2181 return xd; 2179 - } else if (lookup->link && 2180 - lookup->link == xd->link && 2181 - lookup->depth == xd->depth) { 2182 - return xd; 2183 - } else if (lookup->route && 2184 - lookup->route == xd->route) { 2185 - return xd; 2182 + } else { 2183 + if (lookup->link && lookup->link == xd->link && 2184 + lookup->depth == xd->depth) 2185 + return xd; 2186 + if (lookup->route && lookup->route == xd->route) 2187 + return xd; 2186 2188 } 2187 2189 } else if (tb_port_has_remote(port)) { 2188 2190 xd = switch_find_xdomain(port->remote->sw, lookup);
-29
drivers/usb/Kconfig
··· 133 133 134 134 if USB 135 135 136 - config USB_USS720 137 - tristate "USS720 parport driver" 138 - depends on PARPORT 139 - select PARPORT_NOT_PC 140 - help 141 - This driver is for USB parallel port adapters that use the Lucent 142 - Technologies USS-720 chip. These cables are plugged into your USB 143 - port and provide USB compatibility to peripherals designed with 144 - parallel port interfaces. 145 - 146 - The chip has two modes: automatic mode and manual mode. In automatic 147 - mode, it looks to the computer like a standard USB printer. Only 148 - printers may be connected to the USS-720 in this mode. The generic 149 - USB printer driver ("USB Printer support", above) may be used in 150 - that mode, and you can say N here if you want to use the chip only 151 - in this mode. 152 - 153 - Manual mode is not limited to printers, any parallel port 154 - device should work. This driver utilizes manual mode. 155 - Note however that some operations are three orders of magnitude 156 - slower than on a PCI/ISA Parallel Port, so timing critical 157 - applications might not work. 158 - 159 - Say Y here if you own an USS-720 USB->Parport cable and intend to 160 - connect anything other than a printer to it. 161 - 162 - To compile this driver as a module, choose M here: the 163 - module will be called uss720. 164 - 165 136 source "drivers/usb/serial/Kconfig" 166 137 167 138 source "drivers/usb/misc/Kconfig"
-1
drivers/usb/Makefile
··· 31 31 obj-$(CONFIG_USB_XHCI_HCD) += host/ 32 32 obj-$(CONFIG_USB_SL811_HCD) += host/ 33 33 obj-$(CONFIG_USB_ISP1362_HCD) += host/ 34 - obj-$(CONFIG_USB_U132_HCD) += host/ 35 34 obj-$(CONFIG_USB_R8A66597_HCD) += host/ 36 35 obj-$(CONFIG_USB_FSL_USB2) += host/ 37 36 obj-$(CONFIG_USB_FOTG210_HCD) += host/
+2 -6
drivers/usb/cdns3/cdns3-debug.h
··· 107 107 * Prints out all TRBs in the endpoint ring, even those after the Link TRB. 108 108 *. 109 109 */ 110 - static inline char *cdns3_dbg_ring(struct cdns3_endpoint *priv_ep, 111 - struct cdns3_trb *ring, char *str) 110 + static inline char *cdns3_dbg_ring(struct cdns3_endpoint *priv_ep, char *str) 112 111 { 113 112 dma_addr_t addr = priv_ep->trb_pool_dma; 114 113 struct cdns3_trb *trb; ··· 135 136 "\t\tfree trbs: %d, CCS=%d, PCS=%d\n", 136 137 priv_ep->free_trbs, priv_ep->ccs, priv_ep->pcs); 137 138 138 - if (trb_per_sector > TRBS_PER_SEGMENT) 139 - trb_per_sector = TRBS_PER_SEGMENT; 140 - 141 139 if (trb_per_sector > TRBS_PER_SEGMENT) { 142 140 sprintf(str + ret, "\t\tTransfer ring %d too big\n", 143 141 trb_per_sector); ··· 142 146 } 143 147 144 148 for (i = 0; i < trb_per_sector; ++i) { 145 - trb = &ring[i]; 149 + trb = &priv_ep->trb_pool[i]; 146 150 ret += sprintf(str + ret, 147 151 "\t\t@%pad %08x %08x %08x\n", &addr, 148 152 le32_to_cpu(trb->buffer),
+9 -19
drivers/usb/cdns3/cdns3-trace.h
··· 100 100 TP_STRUCT__entry( 101 101 __field(enum usb_device_speed, speed) 102 102 __field(u32, usb_ists) 103 - __dynamic_array(char, str, CDNS3_MSG_MAX) 104 103 ), 105 104 TP_fast_assign( 106 105 __entry->speed = cdns3_get_speed(priv_dev); 107 106 __entry->usb_ists = usb_ists; 108 107 ), 109 - TP_printk("%s", cdns3_decode_usb_irq(__get_str(str), __entry->speed, 108 + TP_printk("%s", cdns3_decode_usb_irq(__get_buf(CDNS3_MSG_MAX), __entry->speed, 110 109 __entry->usb_ists)) 111 110 ); 112 111 ··· 123 124 __field(u32, ep_traddr) 124 125 __field(u32, ep_last_sid) 125 126 __field(u32, use_streams) 126 - __dynamic_array(char, str, CDNS3_MSG_MAX) 127 127 ), 128 128 TP_fast_assign( 129 129 __assign_str(ep_name, priv_ep->name); ··· 132 134 __entry->use_streams = priv_ep->use_streams; 133 135 ), 134 136 TP_printk("%s, ep_traddr: %08x ep_last_sid: %08x use_streams: %d", 135 - cdns3_decode_epx_irq(__get_str(str), 137 + cdns3_decode_epx_irq(__get_buf(CDNS3_MSG_MAX), 136 138 __get_str(ep_name), 137 139 __entry->ep_sts), 138 140 __entry->ep_traddr, ··· 151 153 TP_STRUCT__entry( 152 154 __field(int, ep_dir) 153 155 __field(u32, ep_sts) 154 - __dynamic_array(char, str, CDNS3_MSG_MAX) 155 156 ), 156 157 TP_fast_assign( 157 158 __entry->ep_dir = priv_dev->selected_ep; 158 159 __entry->ep_sts = ep_sts; 159 160 ), 160 - TP_printk("%s", cdns3_decode_ep0_irq(__get_str(str), 161 + TP_printk("%s", cdns3_decode_ep0_irq(__get_buf(CDNS3_MSG_MAX), 161 162 __entry->ep_dir, 162 163 __entry->ep_sts)) 163 164 ); ··· 175 178 __field(u16, wValue) 176 179 __field(u16, wIndex) 177 180 __field(u16, wLength) 178 - __dynamic_array(char, str, CDNS3_MSG_MAX) 179 181 ), 180 182 TP_fast_assign( 181 183 __entry->bRequestType = ctrl->bRequestType; ··· 183 187 __entry->wIndex = le16_to_cpu(ctrl->wIndex); 184 188 __entry->wLength = le16_to_cpu(ctrl->wLength); 185 189 ), 186 - TP_printk("%s", usb_decode_ctrl(__get_str(str), CDNS3_MSG_MAX, 190 + TP_printk("%s", usb_decode_ctrl(__get_buf(CDNS3_MSG_MAX), CDNS3_MSG_MAX, 187 191 __entry->bRequestType, 188 192 __entry->bRequest, __entry->wValue, 189 193 __entry->wIndex, __entry->wLength) ··· 434 438 TP_PROTO(struct cdns3_endpoint *priv_ep), 435 439 TP_ARGS(priv_ep), 436 440 TP_STRUCT__entry( 437 - __dynamic_array(u8, ring, TRB_RING_SIZE) 438 - __dynamic_array(u8, priv_ep, sizeof(struct cdns3_endpoint)) 439 441 __dynamic_array(char, buffer, 440 - (TRBS_PER_SEGMENT * 65) + CDNS3_MSG_MAX) 442 + GET_TRBS_PER_SEGMENT(priv_ep->type) > TRBS_PER_SEGMENT ? 443 + CDNS3_MSG_MAX : 444 + (GET_TRBS_PER_SEGMENT(priv_ep->type) * 65) + CDNS3_MSG_MAX) 441 445 ), 442 446 TP_fast_assign( 443 - memcpy(__get_dynamic_array(priv_ep), priv_ep, 444 - sizeof(struct cdns3_endpoint)); 445 - memcpy(__get_dynamic_array(ring), priv_ep->trb_pool, 446 - TRB_RING_SIZE); 447 + cdns3_dbg_ring(priv_ep, __get_str(buffer)); 447 448 ), 448 449 449 - TP_printk("%s", 450 - cdns3_dbg_ring((struct cdns3_endpoint *)__get_str(priv_ep), 451 - (struct cdns3_trb *)__get_str(ring), 452 - __get_str(buffer))) 450 + TP_printk("%s", __get_str(buffer)) 453 451 ); 454 452 455 453 DEFINE_EVENT(cdns3_log_ring, cdns3_ring,
+4 -8
drivers/usb/cdns3/cdnsp-trace.h
··· 271 271 __field(u16, wValue) 272 272 __field(u16, wIndex) 273 273 __field(u16, wLength) 274 - __dynamic_array(char, str, CDNSP_MSG_MAX) 275 274 ), 276 275 TP_fast_assign( 277 276 __entry->bRequestType = ctrl->bRequestType; ··· 279 280 __entry->wIndex = le16_to_cpu(ctrl->wIndex); 280 281 __entry->wLength = le16_to_cpu(ctrl->wLength); 281 282 ), 282 - TP_printk("%s", usb_decode_ctrl(__get_str(str), CDNSP_MSG_MAX, 283 + TP_printk("%s", usb_decode_ctrl(__get_buf(CDNSP_MSG_MAX), CDNSP_MSG_MAX, 283 284 __entry->bRequestType, 284 285 __entry->bRequest, __entry->wValue, 285 286 __entry->wIndex, __entry->wLength) ··· 344 345 __field(u32, field3) 345 346 __field(union cdnsp_trb *, trb) 346 347 __field(dma_addr_t, trb_dma) 347 - __dynamic_array(char, str, CDNSP_MSG_MAX) 348 348 ), 349 349 TP_fast_assign( 350 350 __entry->type = ring->type; ··· 357 359 358 360 ), 359 361 TP_printk("%s: %s trb: %p(%pad)", cdnsp_ring_type_string(__entry->type), 360 - cdnsp_decode_trb(__get_str(str), CDNSP_MSG_MAX, 362 + cdnsp_decode_trb(__get_buf(CDNSP_MSG_MAX), CDNSP_MSG_MAX, 361 363 __entry->field0, __entry->field1, 362 364 __entry->field2, __entry->field3), 363 365 __entry->trb, &__entry->trb_dma ··· 542 544 __field(u32, info2) 543 545 __field(u64, deq) 544 546 __field(u32, tx_info) 545 - __dynamic_array(char, str, CDNSP_MSG_MAX) 546 547 ), 547 548 TP_fast_assign( 548 549 __entry->info = le32_to_cpu(ctx->ep_info); ··· 549 552 __entry->deq = le64_to_cpu(ctx->deq); 550 553 __entry->tx_info = le32_to_cpu(ctx->tx_info); 551 554 ), 552 - TP_printk("%s", cdnsp_decode_ep_context(__get_str(str), CDNSP_MSG_MAX, 555 + TP_printk("%s", cdnsp_decode_ep_context(__get_buf(CDNSP_MSG_MAX), CDNSP_MSG_MAX, 553 556 __entry->info, __entry->info2, 554 557 __entry->deq, __entry->tx_info) 555 558 ) ··· 774 777 TP_STRUCT__entry( 775 778 __field(u32, portnum) 776 779 __field(u32, portsc) 777 - __dynamic_array(char, str, CDNSP_MSG_MAX) 778 780 ), 779 781 TP_fast_assign( 780 782 __entry->portnum = portnum; ··· 781 785 ), 782 786 TP_printk("port-%d: %s", 783 787 __entry->portnum, 784 - cdnsp_decode_portsc(__get_str(str), CDNSP_MSG_MAX, 788 + cdnsp_decode_portsc(__get_buf(CDNSP_MSG_MAX), CDNSP_MSG_MAX, 785 789 __entry->portsc) 786 790 ) 787 791 );
+1 -1
drivers/usb/chipidea/Makefile
··· 14 14 obj-$(CONFIG_USB_CHIPIDEA_GENERIC) += ci_hdrc_usb2.o 15 15 obj-$(CONFIG_USB_CHIPIDEA_MSM) += ci_hdrc_msm.o 16 16 obj-$(CONFIG_USB_CHIPIDEA_PCI) += ci_hdrc_pci.o 17 - obj-$(CONFIG_USB_CHIPIDEA_IMX) += ci_hdrc_imx.o usbmisc_imx.o 17 + obj-$(CONFIG_USB_CHIPIDEA_IMX) += usbmisc_imx.o ci_hdrc_imx.o 18 18 obj-$(CONFIG_USB_CHIPIDEA_TEGRA) += ci_hdrc_tegra.o
+3 -3
drivers/usb/chipidea/ci_hdrc_imx.c
··· 152 152 * Check the various over current related properties. If over current 153 153 * detection is disabled we're not interested in the polarity. 154 154 */ 155 - if (of_find_property(np, "disable-over-current", NULL)) { 155 + if (of_property_read_bool(np, "disable-over-current")) { 156 156 data->disable_oc = 1; 157 - } else if (of_find_property(np, "over-current-active-high", NULL)) { 157 + } else if (of_property_read_bool(np, "over-current-active-high")) { 158 158 data->oc_pol_active_low = 0; 159 159 data->oc_pol_configured = 1; 160 - } else if (of_find_property(np, "over-current-active-low", NULL)) { 160 + } else if (of_property_read_bool(np, "over-current-active-low")) { 161 161 data->oc_pol_active_low = 1; 162 162 data->oc_pol_configured = 1; 163 163 } else {
+2 -2
drivers/usb/chipidea/core.c
··· 753 753 return ret; 754 754 } 755 755 756 - if (of_find_property(dev->of_node, "non-zero-ttctrl-ttha", NULL)) 756 + if (of_property_read_bool(dev->of_node, "non-zero-ttctrl-ttha")) 757 757 platdata->flags |= CI_HDRC_SET_NON_ZERO_TTHA; 758 758 759 759 ext_id = ERR_PTR(-ENODEV); ··· 1108 1108 ret = ci_usb_phy_init(ci); 1109 1109 if (ret) { 1110 1110 dev_err(dev, "unable to init phy: %d\n", ret); 1111 - return ret; 1111 + goto ulpi_exit; 1112 1112 } 1113 1113 1114 1114 ci->hw_bank.phys = res->start;
-55
drivers/usb/chipidea/debug.c
··· 247 247 } 248 248 DEFINE_SHOW_ATTRIBUTE(ci_otg); 249 249 250 - static int ci_role_show(struct seq_file *s, void *data) 251 - { 252 - struct ci_hdrc *ci = s->private; 253 - 254 - if (ci->role != CI_ROLE_END) 255 - seq_printf(s, "%s\n", ci_role(ci)->name); 256 - 257 - return 0; 258 - } 259 - 260 - static ssize_t ci_role_write(struct file *file, const char __user *ubuf, 261 - size_t count, loff_t *ppos) 262 - { 263 - struct seq_file *s = file->private_data; 264 - struct ci_hdrc *ci = s->private; 265 - enum ci_role role; 266 - char buf[8]; 267 - int ret; 268 - 269 - if (copy_from_user(buf, ubuf, min_t(size_t, sizeof(buf) - 1, count))) 270 - return -EFAULT; 271 - 272 - for (role = CI_ROLE_HOST; role < CI_ROLE_END; role++) 273 - if (ci->roles[role] && 274 - !strncmp(buf, ci->roles[role]->name, 275 - strlen(ci->roles[role]->name))) 276 - break; 277 - 278 - if (role == CI_ROLE_END || role == ci->role) 279 - return -EINVAL; 280 - 281 - pm_runtime_get_sync(ci->dev); 282 - disable_irq(ci->irq); 283 - ci_role_stop(ci); 284 - ret = ci_role_start(ci, role); 285 - enable_irq(ci->irq); 286 - pm_runtime_put_sync(ci->dev); 287 - 288 - return ret ? ret : count; 289 - } 290 - 291 - static int ci_role_open(struct inode *inode, struct file *file) 292 - { 293 - return single_open(file, ci_role_show, inode->i_private); 294 - } 295 - 296 - static const struct file_operations ci_role_fops = { 297 - .open = ci_role_open, 298 - .write = ci_role_write, 299 - .read = seq_read, 300 - .llseek = seq_lseek, 301 - .release = single_release, 302 - }; 303 - 304 250 static int ci_registers_show(struct seq_file *s, void *unused) 305 251 { 306 252 struct ci_hdrc *ci = s->private; ··· 300 354 if (ci_otg_is_fsm_mode(ci)) 301 355 debugfs_create_file("otg", S_IRUGO, dir, ci, &ci_otg_fops); 302 356 303 - debugfs_create_file("role", S_IRUGO | S_IWUSR, dir, ci, &ci_role_fops); 304 357 debugfs_create_file("registers", S_IRUGO, dir, ci, &ci_registers_fops); 305 358 } 306 359
+4 -8
drivers/usb/core/usb-acpi.c
··· 81 81 return -ENODEV; 82 82 } 83 83 84 - obj = acpi_evaluate_dsm(port_handle, &guid, 0, 85 - USB_DSM_DISABLE_U1_U2_FOR_PORT, NULL); 86 - 87 - if (!obj) 88 - return -ENODEV; 89 - 90 - if (obj->type != ACPI_TYPE_INTEGER) { 84 + obj = acpi_evaluate_dsm_typed(port_handle, &guid, 0, 85 + USB_DSM_DISABLE_U1_U2_FOR_PORT, NULL, 86 + ACPI_TYPE_INTEGER); 87 + if (!obj) { 91 88 dev_dbg(&hdev->dev, "evaluate port-%d _DSM failed\n", port1); 92 - ACPI_FREE(obj); 93 89 return -EINVAL; 94 90 } 95 91
+76
drivers/usb/core/usb.c
··· 207 207 EXPORT_SYMBOL_GPL(usb_find_common_endpoints_reverse); 208 208 209 209 /** 210 + * usb_find_endpoint() - Given an endpoint address, search for the endpoint's 211 + * usb_host_endpoint structure in an interface's current altsetting. 212 + * @intf: the interface whose current altsetting should be searched 213 + * @ep_addr: the endpoint address (number and direction) to find 214 + * 215 + * Search the altsetting's list of endpoints for one with the specified address. 216 + * 217 + * Return: Pointer to the usb_host_endpoint if found, %NULL otherwise. 218 + */ 219 + static const struct usb_host_endpoint *usb_find_endpoint( 220 + const struct usb_interface *intf, unsigned int ep_addr) 221 + { 222 + int n; 223 + const struct usb_host_endpoint *ep; 224 + 225 + n = intf->cur_altsetting->desc.bNumEndpoints; 226 + ep = intf->cur_altsetting->endpoint; 227 + for (; n > 0; (--n, ++ep)) { 228 + if (ep->desc.bEndpointAddress == ep_addr) 229 + return ep; 230 + } 231 + return NULL; 232 + } 233 + 234 + /** 235 + * usb_check_bulk_endpoints - Check whether an interface's current altsetting 236 + * contains a set of bulk endpoints with the given addresses. 237 + * @intf: the interface whose current altsetting should be searched 238 + * @ep_addrs: 0-terminated array of the endpoint addresses (number and 239 + * direction) to look for 240 + * 241 + * Search for endpoints with the specified addresses and check their types. 242 + * 243 + * Return: %true if all the endpoints are found and are bulk, %false otherwise. 244 + */ 245 + bool usb_check_bulk_endpoints( 246 + const struct usb_interface *intf, const u8 *ep_addrs) 247 + { 248 + const struct usb_host_endpoint *ep; 249 + 250 + for (; *ep_addrs; ++ep_addrs) { 251 + ep = usb_find_endpoint(intf, *ep_addrs); 252 + if (!ep || !usb_endpoint_xfer_bulk(&ep->desc)) 253 + return false; 254 + } 255 + return true; 256 + } 257 + EXPORT_SYMBOL_GPL(usb_check_bulk_endpoints); 258 + 259 + /** 260 + * usb_check_int_endpoints - Check whether an interface's current altsetting 261 + * contains a set of interrupt endpoints with the given addresses. 262 + * @intf: the interface whose current altsetting should be searched 263 + * @ep_addrs: 0-terminated array of the endpoint addresses (number and 264 + * direction) to look for 265 + * 266 + * Search for endpoints with the specified addresses and check their types. 267 + * 268 + * Return: %true if all the endpoints are found and are interrupt, 269 + * %false otherwise. 270 + */ 271 + bool usb_check_int_endpoints( 272 + const struct usb_interface *intf, const u8 *ep_addrs) 273 + { 274 + const struct usb_host_endpoint *ep; 275 + 276 + for (; *ep_addrs; ++ep_addrs) { 277 + ep = usb_find_endpoint(intf, *ep_addrs); 278 + if (!ep || !usb_endpoint_xfer_int(&ep->desc)) 279 + return false; 280 + } 281 + return true; 282 + } 283 + EXPORT_SYMBOL_GPL(usb_check_int_endpoints); 284 + 285 + /** 210 286 * usb_find_alt_setting() - Given a configuration, find the alternate setting 211 287 * for the given interface. 212 288 * @config: the configuration to search (not necessarily the current config).
+2
drivers/usb/dwc2/core.h
··· 1003 1003 * @ctrl_out_desc: EP0 OUT data phase desc chain pointer 1004 1004 * @irq: Interrupt request line number 1005 1005 * @clk: Pointer to otg clock 1006 + * @utmi_clk: Pointer to utmi_clk clock 1006 1007 * @reset: Pointer to dwc2 reset controller 1007 1008 * @reset_ecc: Pointer to dwc2 optional reset controller in Stratix10. 1008 1009 * @regset: A pointer to a struct debugfs_regset32, which contains ··· 1066 1065 void *priv; 1067 1066 int irq; 1068 1067 struct clk *clk; 1068 + struct clk *utmi_clk; 1069 1069 struct reset_control *reset; 1070 1070 struct reset_control *reset_ecc; 1071 1071
+1 -1
drivers/usb/dwc2/hcd_queue.c
··· 1078 1078 earliest_frame = dwc2_frame_num_inc(frame_number, 1); 1079 1079 next_active_frame = earliest_frame; 1080 1080 1081 - /* Get the "no microframe schduler" out of the way... */ 1081 + /* Get the "no microframe scheduler" out of the way... */ 1082 1082 if (!hsotg->params.uframe_sched) { 1083 1083 if (qh->do_split) 1084 1084 /* Splits are active at microframe 0 minus 1 */
+1 -2
drivers/usb/dwc2/params.c
··· 508 508 of_usb_update_otg_caps(hsotg->dev->of_node, &p->otg_caps); 509 509 } 510 510 511 - if (of_find_property(hsotg->dev->of_node, "disable-over-current", NULL)) 512 - p->oc_disable = true; 511 + p->oc_disable = of_property_read_bool(hsotg->dev->of_node, "disable-over-current"); 513 512 } 514 513 515 514 static void dwc2_check_param_otg_cap(struct dwc2_hsotg *hsotg)
+35 -2
drivers/usb/dwc2/platform.c
··· 101 101 if (ret) 102 102 return ret; 103 103 104 + if (hsotg->utmi_clk) { 105 + ret = clk_prepare_enable(hsotg->utmi_clk); 106 + if (ret) 107 + goto err_dis_reg; 108 + } 109 + 104 110 if (hsotg->clk) { 105 111 ret = clk_prepare_enable(hsotg->clk); 106 112 if (ret) 107 - return ret; 113 + goto err_dis_utmi_clk; 108 114 } 109 115 110 116 if (hsotg->uphy) { ··· 119 113 ret = hsotg->plat->phy_init(pdev, hsotg->plat->phy_type); 120 114 } else { 121 115 ret = phy_init(hsotg->phy); 122 - if (ret == 0) 116 + if (ret == 0) { 123 117 ret = phy_power_on(hsotg->phy); 118 + if (ret) 119 + phy_exit(hsotg->phy); 120 + } 124 121 } 122 + 123 + if (ret) 124 + goto err_dis_clk; 125 + 126 + return 0; 127 + 128 + err_dis_clk: 129 + if (hsotg->clk) 130 + clk_disable_unprepare(hsotg->clk); 131 + 132 + err_dis_utmi_clk: 133 + if (hsotg->utmi_clk) 134 + clk_disable_unprepare(hsotg->utmi_clk); 135 + 136 + err_dis_reg: 137 + regulator_bulk_disable(ARRAY_SIZE(hsotg->supplies), hsotg->supplies); 125 138 126 139 return ret; 127 140 } ··· 180 155 181 156 if (hsotg->clk) 182 157 clk_disable_unprepare(hsotg->clk); 158 + 159 + if (hsotg->utmi_clk) 160 + clk_disable_unprepare(hsotg->utmi_clk); 183 161 184 162 return regulator_bulk_disable(ARRAY_SIZE(hsotg->supplies), hsotg->supplies); 185 163 } ··· 259 231 hsotg->clk = devm_clk_get_optional(hsotg->dev, "otg"); 260 232 if (IS_ERR(hsotg->clk)) 261 233 return dev_err_probe(hsotg->dev, PTR_ERR(hsotg->clk), "cannot get otg clock\n"); 234 + 235 + hsotg->utmi_clk = devm_clk_get_optional(hsotg->dev, "utmi"); 236 + if (IS_ERR(hsotg->utmi_clk)) 237 + return dev_err_probe(hsotg->dev, PTR_ERR(hsotg->utmi_clk), 238 + "cannot get utmi clock\n"); 262 239 263 240 /* Regulators */ 264 241 for (i = 0; i < ARRAY_SIZE(hsotg->supplies); i++)
+194 -251
drivers/usb/dwc3/core.c
··· 534 534 dwc3_writel(dwc->regs, DWC3_GEVNTCOUNT(0), 0); 535 535 } 536 536 537 - static int dwc3_alloc_scratch_buffers(struct dwc3 *dwc) 538 - { 539 - if (!dwc->has_hibernation) 540 - return 0; 541 - 542 - if (!dwc->nr_scratch) 543 - return 0; 544 - 545 - dwc->scratchbuf = kmalloc_array(dwc->nr_scratch, 546 - DWC3_SCRATCHBUF_SIZE, GFP_KERNEL); 547 - if (!dwc->scratchbuf) 548 - return -ENOMEM; 549 - 550 - return 0; 551 - } 552 - 553 - static int dwc3_setup_scratch_buffers(struct dwc3 *dwc) 554 - { 555 - dma_addr_t scratch_addr; 556 - u32 param; 557 - int ret; 558 - 559 - if (!dwc->has_hibernation) 560 - return 0; 561 - 562 - if (!dwc->nr_scratch) 563 - return 0; 564 - 565 - /* should never fall here */ 566 - if (!WARN_ON(dwc->scratchbuf)) 567 - return 0; 568 - 569 - scratch_addr = dma_map_single(dwc->sysdev, dwc->scratchbuf, 570 - dwc->nr_scratch * DWC3_SCRATCHBUF_SIZE, 571 - DMA_BIDIRECTIONAL); 572 - if (dma_mapping_error(dwc->sysdev, scratch_addr)) { 573 - dev_err(dwc->sysdev, "failed to map scratch buffer\n"); 574 - ret = -EFAULT; 575 - goto err0; 576 - } 577 - 578 - dwc->scratch_addr = scratch_addr; 579 - 580 - param = lower_32_bits(scratch_addr); 581 - 582 - ret = dwc3_send_gadget_generic_command(dwc, 583 - DWC3_DGCMD_SET_SCRATCHPAD_ADDR_LO, param); 584 - if (ret < 0) 585 - goto err1; 586 - 587 - param = upper_32_bits(scratch_addr); 588 - 589 - ret = dwc3_send_gadget_generic_command(dwc, 590 - DWC3_DGCMD_SET_SCRATCHPAD_ADDR_HI, param); 591 - if (ret < 0) 592 - goto err1; 593 - 594 - return 0; 595 - 596 - err1: 597 - dma_unmap_single(dwc->sysdev, dwc->scratch_addr, dwc->nr_scratch * 598 - DWC3_SCRATCHBUF_SIZE, DMA_BIDIRECTIONAL); 599 - 600 - err0: 601 - return ret; 602 - } 603 - 604 - static void dwc3_free_scratch_buffers(struct dwc3 *dwc) 605 - { 606 - if (!dwc->has_hibernation) 607 - return; 608 - 609 - if (!dwc->nr_scratch) 610 - return; 611 - 612 - /* should never fall here */ 613 - if (!WARN_ON(dwc->scratchbuf)) 614 - return; 615 - 616 - dma_unmap_single(dwc->sysdev, dwc->scratch_addr, dwc->nr_scratch * 617 - DWC3_SCRATCHBUF_SIZE, DMA_BIDIRECTIONAL); 618 - kfree(dwc->scratchbuf); 619 - } 620 - 621 537 static void dwc3_core_num_eps(struct dwc3 *dwc) 622 538 { 623 539 struct dwc3_hwparams *parms = &dwc->hwparams; ··· 716 800 if (dwc->dis_u2_freeclk_exists_quirk || dwc->gfladj_refclk_lpm_sel) 717 801 reg &= ~DWC3_GUSB2PHYCFG_U2_FREECLK_EXISTS; 718 802 803 + /* 804 + * Some ULPI USB PHY does not support internal VBUS supply, to drive 805 + * the CPEN pin requires the configuration of the ULPI DRVVBUSEXTERNAL 806 + * bit of OTG_CTRL register. Controller configures the USB2 PHY 807 + * ULPIEXTVBUSDRV bit[17] of the GUSB2PHYCFG register to drive vBus 808 + * with an external supply. 809 + */ 810 + if (dwc->ulpi_ext_vbus_drv) 811 + reg |= DWC3_GUSB2PHYCFG_ULPIEXTVBUSDRV; 812 + 719 813 dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg); 720 814 721 815 return 0; 816 + } 817 + 818 + static int dwc3_phy_init(struct dwc3 *dwc) 819 + { 820 + int ret; 821 + 822 + usb_phy_init(dwc->usb2_phy); 823 + usb_phy_init(dwc->usb3_phy); 824 + 825 + ret = phy_init(dwc->usb2_generic_phy); 826 + if (ret < 0) 827 + goto err_shutdown_usb3_phy; 828 + 829 + ret = phy_init(dwc->usb3_generic_phy); 830 + if (ret < 0) 831 + goto err_exit_usb2_phy; 832 + 833 + return 0; 834 + 835 + err_exit_usb2_phy: 836 + phy_exit(dwc->usb2_generic_phy); 837 + err_shutdown_usb3_phy: 838 + usb_phy_shutdown(dwc->usb3_phy); 839 + usb_phy_shutdown(dwc->usb2_phy); 840 + 841 + return ret; 842 + } 843 + 844 + static void dwc3_phy_exit(struct dwc3 *dwc) 845 + { 846 + phy_exit(dwc->usb3_generic_phy); 847 + phy_exit(dwc->usb2_generic_phy); 848 + 849 + usb_phy_shutdown(dwc->usb3_phy); 850 + usb_phy_shutdown(dwc->usb2_phy); 851 + } 852 + 853 + static int dwc3_phy_power_on(struct dwc3 *dwc) 854 + { 855 + int ret; 856 + 857 + usb_phy_set_suspend(dwc->usb2_phy, 0); 858 + usb_phy_set_suspend(dwc->usb3_phy, 0); 859 + 860 + ret = phy_power_on(dwc->usb2_generic_phy); 861 + if (ret < 0) 862 + goto err_suspend_usb3_phy; 863 + 864 + ret = phy_power_on(dwc->usb3_generic_phy); 865 + if (ret < 0) 866 + goto err_power_off_usb2_phy; 867 + 868 + return 0; 869 + 870 + err_power_off_usb2_phy: 871 + phy_power_off(dwc->usb2_generic_phy); 872 + err_suspend_usb3_phy: 873 + usb_phy_set_suspend(dwc->usb3_phy, 1); 874 + usb_phy_set_suspend(dwc->usb2_phy, 1); 875 + 876 + return ret; 877 + } 878 + 879 + static void dwc3_phy_power_off(struct dwc3 *dwc) 880 + { 881 + phy_power_off(dwc->usb3_generic_phy); 882 + phy_power_off(dwc->usb2_generic_phy); 883 + 884 + usb_phy_set_suspend(dwc->usb3_phy, 1); 885 + usb_phy_set_suspend(dwc->usb2_phy, 1); 722 886 } 723 887 724 888 static int dwc3_clk_enable(struct dwc3 *dwc) ··· 836 840 static void dwc3_core_exit(struct dwc3 *dwc) 837 841 { 838 842 dwc3_event_buffers_cleanup(dwc); 839 - 840 - usb_phy_set_suspend(dwc->usb2_phy, 1); 841 - usb_phy_set_suspend(dwc->usb3_phy, 1); 842 - phy_power_off(dwc->usb2_generic_phy); 843 - phy_power_off(dwc->usb3_generic_phy); 844 - 845 - usb_phy_shutdown(dwc->usb2_phy); 846 - usb_phy_shutdown(dwc->usb3_phy); 847 - phy_exit(dwc->usb2_generic_phy); 848 - phy_exit(dwc->usb3_generic_phy); 849 - 843 + dwc3_phy_power_off(dwc); 844 + dwc3_phy_exit(dwc); 850 845 dwc3_clk_disable(dwc); 851 846 reset_control_assert(dwc->reset); 852 847 } ··· 864 877 865 878 static void dwc3_core_setup_global_control(struct dwc3 *dwc) 866 879 { 867 - u32 hwparams4 = dwc->hwparams.hwparams4; 868 880 u32 reg; 869 881 870 882 reg = dwc3_readl(dwc->regs, DWC3_GCTL); ··· 891 905 reg &= ~DWC3_GCTL_DSBLCLKGTNG; 892 906 break; 893 907 case DWC3_GHWPARAMS1_EN_PWROPT_HIB: 894 - /* enable hibernation here */ 895 - dwc->nr_scratch = DWC3_GHWPARAMS4_HIBER_SCRATCHBUFS(hwparams4); 896 - 897 908 /* 898 909 * REVISIT Enabling this bit so that host-mode hibernation 899 910 * will work. Device-mode hibernation is not yet implemented. ··· 1079 1096 1080 1097 ret = dwc3_phy_setup(dwc); 1081 1098 if (ret) 1082 - goto err0; 1099 + return ret; 1083 1100 1084 1101 if (!dwc->ulpi_ready) { 1085 1102 ret = dwc3_core_ulpi_init(dwc); ··· 1088 1105 dwc3_core_soft_reset(dwc); 1089 1106 ret = -EPROBE_DEFER; 1090 1107 } 1091 - goto err0; 1108 + return ret; 1092 1109 } 1093 1110 dwc->ulpi_ready = true; 1094 1111 } ··· 1096 1113 if (!dwc->phys_ready) { 1097 1114 ret = dwc3_core_get_phy(dwc); 1098 1115 if (ret) 1099 - goto err0a; 1116 + goto err_exit_ulpi; 1100 1117 dwc->phys_ready = true; 1101 1118 } 1102 1119 1103 - usb_phy_init(dwc->usb2_phy); 1104 - usb_phy_init(dwc->usb3_phy); 1105 - ret = phy_init(dwc->usb2_generic_phy); 1106 - if (ret < 0) 1107 - goto err0a; 1108 - 1109 - ret = phy_init(dwc->usb3_generic_phy); 1110 - if (ret < 0) { 1111 - phy_exit(dwc->usb2_generic_phy); 1112 - goto err0a; 1113 - } 1120 + ret = dwc3_phy_init(dwc); 1121 + if (ret) 1122 + goto err_exit_ulpi; 1114 1123 1115 1124 ret = dwc3_core_soft_reset(dwc); 1116 1125 if (ret) 1117 - goto err1; 1126 + goto err_exit_phy; 1118 1127 1119 1128 if (hw_mode == DWC3_GHWPARAMS0_MODE_DRD && 1120 1129 !DWC3_VER_IS_WITHIN(DWC3, ANY, 194A)) { ··· 1126 1151 dwc3_core_setup_global_control(dwc); 1127 1152 dwc3_core_num_eps(dwc); 1128 1153 1129 - ret = dwc3_setup_scratch_buffers(dwc); 1130 - if (ret) 1131 - goto err1; 1132 - 1133 1154 /* Set power down scale of suspend_clk */ 1134 1155 dwc3_set_power_down_clk_scale(dwc); 1135 1156 ··· 1137 1166 1138 1167 dwc3_set_incr_burst_type(dwc); 1139 1168 1140 - usb_phy_set_suspend(dwc->usb2_phy, 0); 1141 - usb_phy_set_suspend(dwc->usb3_phy, 0); 1142 - ret = phy_power_on(dwc->usb2_generic_phy); 1143 - if (ret < 0) 1144 - goto err2; 1145 - 1146 - ret = phy_power_on(dwc->usb3_generic_phy); 1147 - if (ret < 0) 1148 - goto err3; 1169 + dwc3_phy_power_on(dwc); 1170 + if (ret) 1171 + goto err_exit_phy; 1149 1172 1150 1173 ret = dwc3_event_buffers_setup(dwc); 1151 1174 if (ret) { 1152 1175 dev_err(dwc->dev, "failed to setup event buffers\n"); 1153 - goto err4; 1176 + goto err_power_off_phy; 1154 1177 } 1155 1178 1156 1179 /* ··· 1197 1232 1198 1233 if (dwc->parkmode_disable_ss_quirk) 1199 1234 reg |= DWC3_GUCTL1_PARKMODE_DISABLE_SS; 1235 + 1236 + if (dwc->parkmode_disable_hs_quirk) 1237 + reg |= DWC3_GUCTL1_PARKMODE_DISABLE_HS; 1200 1238 1201 1239 if (DWC3_VER_IS_WITHIN(DWC3, 290A, ANY) && 1202 1240 (dwc->maximum_speed == USB_SPEED_HIGH || ··· 1264 1296 1265 1297 return 0; 1266 1298 1267 - err4: 1268 - phy_power_off(dwc->usb3_generic_phy); 1269 - 1270 - err3: 1271 - phy_power_off(dwc->usb2_generic_phy); 1272 - 1273 - err2: 1274 - usb_phy_set_suspend(dwc->usb2_phy, 1); 1275 - usb_phy_set_suspend(dwc->usb3_phy, 1); 1276 - 1277 - err1: 1278 - usb_phy_shutdown(dwc->usb2_phy); 1279 - usb_phy_shutdown(dwc->usb3_phy); 1280 - phy_exit(dwc->usb2_generic_phy); 1281 - phy_exit(dwc->usb3_generic_phy); 1282 - 1283 - err0a: 1299 + err_power_off_phy: 1300 + dwc3_phy_power_off(dwc); 1301 + err_exit_phy: 1302 + dwc3_phy_exit(dwc); 1303 + err_exit_ulpi: 1284 1304 dwc3_ulpi_exit(dwc); 1285 1305 1286 - err0: 1287 1306 return ret; 1288 1307 } 1289 1308 ··· 1508 1553 "snps,dis-tx-ipgap-linecheck-quirk"); 1509 1554 dwc->resume_hs_terminations = device_property_read_bool(dev, 1510 1555 "snps,resume-hs-terminations"); 1556 + dwc->ulpi_ext_vbus_drv = device_property_read_bool(dev, 1557 + "snps,ulpi-ext-vbus-drv"); 1511 1558 dwc->parkmode_disable_ss_quirk = device_property_read_bool(dev, 1512 1559 "snps,parkmode-disable-ss-quirk"); 1560 + dwc->parkmode_disable_hs_quirk = device_property_read_bool(dev, 1561 + "snps,parkmode-disable-hs-quirk"); 1513 1562 dwc->gfladj_refclk_lpm_sel = device_property_read_bool(dev, 1514 1563 "snps,gfladj-refclk-lpm-sel-quirk"); 1515 1564 ··· 1709 1750 return edev; 1710 1751 } 1711 1752 1753 + static int dwc3_get_clocks(struct dwc3 *dwc) 1754 + { 1755 + struct device *dev = dwc->dev; 1756 + 1757 + if (!dev->of_node) 1758 + return 0; 1759 + 1760 + /* 1761 + * Clocks are optional, but new DT platforms should support all clocks 1762 + * as required by the DT-binding. 1763 + * Some devices have different clock names in legacy device trees, 1764 + * check for them to retain backwards compatibility. 1765 + */ 1766 + dwc->bus_clk = devm_clk_get_optional(dev, "bus_early"); 1767 + if (IS_ERR(dwc->bus_clk)) { 1768 + return dev_err_probe(dev, PTR_ERR(dwc->bus_clk), 1769 + "could not get bus clock\n"); 1770 + } 1771 + 1772 + if (dwc->bus_clk == NULL) { 1773 + dwc->bus_clk = devm_clk_get_optional(dev, "bus_clk"); 1774 + if (IS_ERR(dwc->bus_clk)) { 1775 + return dev_err_probe(dev, PTR_ERR(dwc->bus_clk), 1776 + "could not get bus clock\n"); 1777 + } 1778 + } 1779 + 1780 + dwc->ref_clk = devm_clk_get_optional(dev, "ref"); 1781 + if (IS_ERR(dwc->ref_clk)) { 1782 + return dev_err_probe(dev, PTR_ERR(dwc->ref_clk), 1783 + "could not get ref clock\n"); 1784 + } 1785 + 1786 + if (dwc->ref_clk == NULL) { 1787 + dwc->ref_clk = devm_clk_get_optional(dev, "ref_clk"); 1788 + if (IS_ERR(dwc->ref_clk)) { 1789 + return dev_err_probe(dev, PTR_ERR(dwc->ref_clk), 1790 + "could not get ref clock\n"); 1791 + } 1792 + } 1793 + 1794 + dwc->susp_clk = devm_clk_get_optional(dev, "suspend"); 1795 + if (IS_ERR(dwc->susp_clk)) { 1796 + return dev_err_probe(dev, PTR_ERR(dwc->susp_clk), 1797 + "could not get suspend clock\n"); 1798 + } 1799 + 1800 + if (dwc->susp_clk == NULL) { 1801 + dwc->susp_clk = devm_clk_get_optional(dev, "suspend_clk"); 1802 + if (IS_ERR(dwc->susp_clk)) { 1803 + return dev_err_probe(dev, PTR_ERR(dwc->susp_clk), 1804 + "could not get suspend clock\n"); 1805 + } 1806 + } 1807 + 1808 + return 0; 1809 + } 1810 + 1712 1811 static int dwc3_probe(struct platform_device *pdev) 1713 1812 { 1714 1813 struct device *dev = &pdev->dev; 1715 1814 struct resource *res, dwc_res; 1716 - struct dwc3 *dwc; 1717 - 1718 - int ret; 1719 - 1720 1815 void __iomem *regs; 1816 + struct dwc3 *dwc; 1817 + int ret; 1721 1818 1722 1819 dwc = devm_kzalloc(dev, sizeof(*dwc), GFP_KERNEL); 1723 1820 if (!dwc) ··· 1812 1797 dwc->reset = devm_reset_control_array_get_optional_shared(dev); 1813 1798 if (IS_ERR(dwc->reset)) { 1814 1799 ret = PTR_ERR(dwc->reset); 1815 - goto put_usb_psy; 1800 + goto err_put_psy; 1816 1801 } 1817 1802 1818 - if (dev->of_node) { 1819 - /* 1820 - * Clocks are optional, but new DT platforms should support all 1821 - * clocks as required by the DT-binding. 1822 - * Some devices have different clock names in legacy device trees, 1823 - * check for them to retain backwards compatibility. 1824 - */ 1825 - dwc->bus_clk = devm_clk_get_optional(dev, "bus_early"); 1826 - if (IS_ERR(dwc->bus_clk)) { 1827 - ret = dev_err_probe(dev, PTR_ERR(dwc->bus_clk), 1828 - "could not get bus clock\n"); 1829 - goto put_usb_psy; 1830 - } 1831 - 1832 - if (dwc->bus_clk == NULL) { 1833 - dwc->bus_clk = devm_clk_get_optional(dev, "bus_clk"); 1834 - if (IS_ERR(dwc->bus_clk)) { 1835 - ret = dev_err_probe(dev, PTR_ERR(dwc->bus_clk), 1836 - "could not get bus clock\n"); 1837 - goto put_usb_psy; 1838 - } 1839 - } 1840 - 1841 - dwc->ref_clk = devm_clk_get_optional(dev, "ref"); 1842 - if (IS_ERR(dwc->ref_clk)) { 1843 - ret = dev_err_probe(dev, PTR_ERR(dwc->ref_clk), 1844 - "could not get ref clock\n"); 1845 - goto put_usb_psy; 1846 - } 1847 - 1848 - if (dwc->ref_clk == NULL) { 1849 - dwc->ref_clk = devm_clk_get_optional(dev, "ref_clk"); 1850 - if (IS_ERR(dwc->ref_clk)) { 1851 - ret = dev_err_probe(dev, PTR_ERR(dwc->ref_clk), 1852 - "could not get ref clock\n"); 1853 - goto put_usb_psy; 1854 - } 1855 - } 1856 - 1857 - dwc->susp_clk = devm_clk_get_optional(dev, "suspend"); 1858 - if (IS_ERR(dwc->susp_clk)) { 1859 - ret = dev_err_probe(dev, PTR_ERR(dwc->susp_clk), 1860 - "could not get suspend clock\n"); 1861 - goto put_usb_psy; 1862 - } 1863 - 1864 - if (dwc->susp_clk == NULL) { 1865 - dwc->susp_clk = devm_clk_get_optional(dev, "suspend_clk"); 1866 - if (IS_ERR(dwc->susp_clk)) { 1867 - ret = dev_err_probe(dev, PTR_ERR(dwc->susp_clk), 1868 - "could not get suspend clock\n"); 1869 - goto put_usb_psy; 1870 - } 1871 - } 1872 - } 1803 + ret = dwc3_get_clocks(dwc); 1804 + if (ret) 1805 + goto err_put_psy; 1873 1806 1874 1807 ret = reset_control_deassert(dwc->reset); 1875 1808 if (ret) 1876 - goto put_usb_psy; 1809 + goto err_put_psy; 1877 1810 1878 1811 ret = dwc3_clk_enable(dwc); 1879 1812 if (ret) 1880 - goto assert_reset; 1813 + goto err_assert_reset; 1881 1814 1882 1815 if (!dwc3_core_is_valid(dwc)) { 1883 1816 dev_err(dwc->dev, "this is not a DesignWare USB3 DRD Core\n"); 1884 1817 ret = -ENODEV; 1885 - goto disable_clks; 1818 + goto err_disable_clks; 1886 1819 } 1887 1820 1888 1821 platform_set_drvdata(pdev, dwc); ··· 1840 1877 DWC3_GHWPARAMS0_AWIDTH(dwc->hwparams.hwparams0) == 64) { 1841 1878 ret = dma_set_mask_and_coherent(dwc->sysdev, DMA_BIT_MASK(64)); 1842 1879 if (ret) 1843 - goto disable_clks; 1880 + goto err_disable_clks; 1844 1881 } 1845 1882 1846 1883 spin_lock_init(&dwc->lock); 1847 1884 mutex_init(&dwc->mutex); 1848 1885 1886 + pm_runtime_get_noresume(dev); 1849 1887 pm_runtime_set_active(dev); 1850 1888 pm_runtime_use_autosuspend(dev); 1851 1889 pm_runtime_set_autosuspend_delay(dev, DWC3_DEFAULT_AUTOSUSPEND_DELAY); 1852 1890 pm_runtime_enable(dev); 1853 - ret = pm_runtime_get_sync(dev); 1854 - if (ret < 0) 1855 - goto err1; 1856 1891 1857 1892 pm_runtime_forbid(dev); 1858 1893 ··· 1858 1897 if (ret) { 1859 1898 dev_err(dwc->dev, "failed to allocate event buffers\n"); 1860 1899 ret = -ENOMEM; 1861 - goto err2; 1900 + goto err_allow_rpm; 1862 1901 } 1863 1902 1864 1903 dwc->edev = dwc3_get_extcon(dwc); 1865 1904 if (IS_ERR(dwc->edev)) { 1866 1905 ret = dev_err_probe(dwc->dev, PTR_ERR(dwc->edev), "failed to get extcon\n"); 1867 - goto err3; 1906 + goto err_free_event_buffers; 1868 1907 } 1869 1908 1870 1909 ret = dwc3_get_dr_mode(dwc); 1871 1910 if (ret) 1872 - goto err3; 1873 - 1874 - ret = dwc3_alloc_scratch_buffers(dwc); 1875 - if (ret) 1876 - goto err3; 1911 + goto err_free_event_buffers; 1877 1912 1878 1913 ret = dwc3_core_init(dwc); 1879 1914 if (ret) { 1880 1915 dev_err_probe(dev, ret, "failed to initialize core\n"); 1881 - goto err4; 1916 + goto err_free_event_buffers; 1882 1917 } 1883 1918 1884 1919 dwc3_check_params(dwc); ··· 1882 1925 1883 1926 ret = dwc3_core_init_mode(dwc); 1884 1927 if (ret) 1885 - goto err5; 1928 + goto err_exit_debugfs; 1886 1929 1887 1930 pm_runtime_put(dev); 1888 1931 1889 1932 return 0; 1890 1933 1891 - err5: 1934 + err_exit_debugfs: 1892 1935 dwc3_debugfs_exit(dwc); 1893 1936 dwc3_event_buffers_cleanup(dwc); 1894 - 1895 - usb_phy_set_suspend(dwc->usb2_phy, 1); 1896 - usb_phy_set_suspend(dwc->usb3_phy, 1); 1897 - phy_power_off(dwc->usb2_generic_phy); 1898 - phy_power_off(dwc->usb3_generic_phy); 1899 - 1900 - usb_phy_shutdown(dwc->usb2_phy); 1901 - usb_phy_shutdown(dwc->usb3_phy); 1902 - phy_exit(dwc->usb2_generic_phy); 1903 - phy_exit(dwc->usb3_generic_phy); 1904 - 1937 + dwc3_phy_power_off(dwc); 1938 + dwc3_phy_exit(dwc); 1905 1939 dwc3_ulpi_exit(dwc); 1906 - 1907 - err4: 1908 - dwc3_free_scratch_buffers(dwc); 1909 - 1910 - err3: 1940 + err_free_event_buffers: 1911 1941 dwc3_free_event_buffers(dwc); 1912 - 1913 - err2: 1914 - pm_runtime_allow(&pdev->dev); 1915 - 1916 - err1: 1917 - pm_runtime_put_sync(&pdev->dev); 1918 - pm_runtime_disable(&pdev->dev); 1919 - 1920 - disable_clks: 1942 + err_allow_rpm: 1943 + pm_runtime_allow(dev); 1944 + pm_runtime_disable(dev); 1945 + pm_runtime_dont_use_autosuspend(dev); 1946 + pm_runtime_set_suspended(dev); 1947 + pm_runtime_put_noidle(dev); 1948 + err_disable_clks: 1921 1949 dwc3_clk_disable(dwc); 1922 - assert_reset: 1950 + err_assert_reset: 1923 1951 reset_control_assert(dwc->reset); 1924 - put_usb_psy: 1952 + err_put_psy: 1925 1953 if (dwc->usb_psy) 1926 1954 power_supply_put(dwc->usb_psy); 1927 1955 ··· 1925 1983 dwc3_core_exit(dwc); 1926 1984 dwc3_ulpi_exit(dwc); 1927 1985 1986 + pm_runtime_allow(&pdev->dev); 1928 1987 pm_runtime_disable(&pdev->dev); 1988 + pm_runtime_dont_use_autosuspend(&pdev->dev); 1929 1989 pm_runtime_put_noidle(&pdev->dev); 1930 1990 pm_runtime_set_suspended(&pdev->dev); 1931 1991 1932 1992 dwc3_free_event_buffers(dwc); 1933 - dwc3_free_scratch_buffers(dwc); 1934 1993 1935 1994 if (dwc->usb_psy) 1936 1995 power_supply_put(dwc->usb_psy);
+13 -8
drivers/usb/dwc3/core.h
··· 263 263 #define DWC3_GUCTL1_DEV_FORCE_20_CLK_FOR_30_CLK BIT(26) 264 264 #define DWC3_GUCTL1_DEV_L1_EXIT_BY_HW BIT(24) 265 265 #define DWC3_GUCTL1_PARKMODE_DISABLE_SS BIT(17) 266 + #define DWC3_GUCTL1_PARKMODE_DISABLE_HS BIT(16) 266 267 #define DWC3_GUCTL1_RESUME_OPMODE_HS_HOST BIT(10) 267 268 268 269 /* Global Status Register */ ··· 281 280 /* Global USB2 PHY Configuration Register */ 282 281 #define DWC3_GUSB2PHYCFG_PHYSOFTRST BIT(31) 283 282 #define DWC3_GUSB2PHYCFG_U2_FREECLK_EXISTS BIT(30) 283 + #define DWC3_GUSB2PHYCFG_ULPIEXTVBUSDRV BIT(17) 284 284 #define DWC3_GUSB2PHYCFG_SUSPHY BIT(6) 285 285 #define DWC3_GUSB2PHYCFG_ULPI_UTMI BIT(4) 286 286 #define DWC3_GUSB2PHYCFG_ENBLSLPM BIT(8) ··· 528 526 #define DWC3_DGCMD_SET_ENDPOINT_NRDY 0x0c 529 527 #define DWC3_DGCMD_SET_ENDPOINT_PRIME 0x0d 530 528 #define DWC3_DGCMD_RUN_SOC_BUS_LOOPBACK 0x10 529 + #define DWC3_DGCMD_DEV_NOTIFICATION 0x07 531 530 532 531 #define DWC3_DGCMD_STATUS(n) (((n) >> 12) & 0x0F) 533 532 #define DWC3_DGCMD_CMDACT BIT(10) ··· 541 538 #define DWC3_DGCMDPAR_TX_FIFO BIT(5) 542 539 #define DWC3_DGCMDPAR_LOOPBACK_DIS (0 << 0) 543 540 #define DWC3_DGCMDPAR_LOOPBACK_ENA BIT(0) 541 + #define DWC3_DGCMDPAR_DN_FUNC_WAKE BIT(0) 542 + #define DWC3_DGCMDPAR_INTF_SEL(n) ((n) << 4) 544 543 545 544 /* Device Endpoint Command Register */ 546 545 #define DWC3_DEPCMD_PARAM_SHIFT 16 ··· 974 969 * @drd_work: workqueue used for role swapping 975 970 * @ep0_trb: trb which is used for the ctrl_req 976 971 * @bounce: address of bounce buffer 977 - * @scratchbuf: address of scratch buffer 978 972 * @setup_buf: used while precessing STD USB requests 979 973 * @ep0_trb_addr: dma address of @ep0_trb 980 974 * @bounce_addr: dma address of @bounce 981 975 * @ep0_usb_req: dummy req used while handling STD USB requests 982 - * @scratch_addr: dma address of scratchbuf 983 976 * @ep0_in_setup: one control transfer is completed and enter setup phase 984 977 * @lock: for synchronizing 985 978 * @mutex: for mode switching ··· 1002 999 * @current_otg_role: current role of operation while using the OTG block 1003 1000 * @desired_otg_role: desired role of operation while using the OTG block 1004 1001 * @otg_restart_host: flag that OTG controller needs to restart host 1005 - * @nr_scratch: number of scratch buffers 1006 1002 * @u1u2: only used on revisions <1.83a for workaround 1007 1003 * @maximum_speed: maximum speed requested (mainly for testing purposes) 1008 1004 * @max_ssp_rate: SuperSpeed Plus maximum signaling rate and lane count ··· 1058 1056 * @delayed_status: true when gadget driver asks for delayed status 1059 1057 * @ep0_bounced: true when we used bounce buffer 1060 1058 * @ep0_expect_in: true when we expect a DATA IN transfer 1061 - * @has_hibernation: true when dwc3 was configured with Hibernation 1062 1059 * @sysdev_is_parent: true when dwc3 device has a parent driver 1063 1060 * @has_lpm_erratum: true when core was configured with LPM Erratum. Note that 1064 1061 * there's now way for software to detect this in runtime. ··· 1101 1100 * check during HS transmit. 1102 1101 * @resume_hs_terminations: Set if we enable quirk for fixing improper crc 1103 1102 * generation after resume from suspend. 1103 + * @ulpi_ext_vbus_drv: Set to confiure the upli chip to drives CPEN pin 1104 + * VBUS with an external supply. 1104 1105 * @parkmode_disable_ss_quirk: set if we need to disable all SuperSpeed 1106 + * instances in park mode. 1107 + * @parkmode_disable_hs_quirk: set if we need to disable all HishSpeed 1105 1108 * instances in park mode. 1106 1109 * @tx_de_emphasis_quirk: set if we enable Tx de-emphasis quirk 1107 1110 * @tx_de_emphasis: Tx de-emphasis value ··· 1115 1110 * 3 - Reserved 1116 1111 * @dis_metastability_quirk: set to disable metastability quirk. 1117 1112 * @dis_split_quirk: set to disable split boundary. 1113 + * @wakeup_configured: set if the device is configured for remote wakeup. 1118 1114 * @imod_interval: set the interrupt moderation interval in 250ns 1119 1115 * increments or 0 to disable. 1120 1116 * @max_cfg_eps: current max number of IN eps used across all USB configs. ··· 1129 1123 struct work_struct drd_work; 1130 1124 struct dwc3_trb *ep0_trb; 1131 1125 void *bounce; 1132 - void *scratchbuf; 1133 1126 u8 *setup_buf; 1134 1127 dma_addr_t ep0_trb_addr; 1135 1128 dma_addr_t bounce_addr; 1136 - dma_addr_t scratch_addr; 1137 1129 struct dwc3_request ep0_usb_req; 1138 1130 struct completion ep0_in_setup; 1139 1131 ··· 1191 1187 u32 current_otg_role; 1192 1188 u32 desired_otg_role; 1193 1189 bool otg_restart_host; 1194 - u32 nr_scratch; 1195 1190 u32 u1u2; 1196 1191 u32 maximum_speed; 1197 1192 u32 gadget_max_speed; ··· 1287 1284 unsigned delayed_status:1; 1288 1285 unsigned ep0_bounced:1; 1289 1286 unsigned ep0_expect_in:1; 1290 - unsigned has_hibernation:1; 1291 1287 unsigned sysdev_is_parent:1; 1292 1288 unsigned has_lpm_erratum:1; 1293 1289 unsigned is_utmi_l1_suspend:1; ··· 1319 1317 unsigned dis_del_phy_power_chg_quirk:1; 1320 1318 unsigned dis_tx_ipgap_linecheck_quirk:1; 1321 1319 unsigned resume_hs_terminations:1; 1320 + unsigned ulpi_ext_vbus_drv:1; 1322 1321 unsigned parkmode_disable_ss_quirk:1; 1322 + unsigned parkmode_disable_hs_quirk:1; 1323 1323 unsigned gfladj_refclk_lpm_sel:1; 1324 1324 1325 1325 unsigned tx_de_emphasis_quirk:1; ··· 1331 1327 1332 1328 unsigned dis_split_quirk:1; 1333 1329 unsigned async_callbacks:1; 1330 + unsigned wakeup_configured:1; 1334 1331 1335 1332 u16 imod_interval; 1336 1333
+2
drivers/usb/dwc3/debug.h
··· 72 72 return "Set Endpoint Prime"; 73 73 case DWC3_DGCMD_RUN_SOC_BUS_LOOPBACK: 74 74 return "Run SoC Bus Loopback Test"; 75 + case DWC3_DGCMD_DEV_NOTIFICATION: 76 + return "Device Notification"; 75 77 default: 76 78 return "UNKNOWN"; 77 79 }
+5
drivers/usb/dwc3/debugfs.c
··· 88 88 dump_register(GPRTBIMAP_HS1), 89 89 dump_register(GPRTBIMAP_FS0), 90 90 dump_register(GPRTBIMAP_FS1), 91 + dump_register(GUCTL2), 92 + dump_register(VER_NUMBER), 93 + dump_register(VER_TYPE), 91 94 92 95 dump_register(GUSB2PHYCFG(0)), 93 96 dump_register(GUSB2PHYCFG(1)), ··· 232 229 dump_register(GEVNTCOUNT(0)), 233 230 234 231 dump_register(GHWPARAMS8), 232 + dump_register(GUCTL3), 233 + dump_register(GFLADJ), 235 234 dump_register(DCFG), 236 235 dump_register(DCTL), 237 236 dump_register(DEVTEN),
+51 -1
drivers/usb/dwc3/dwc3-am62.c
··· 11 11 #include <linux/platform_device.h> 12 12 #include <linux/mfd/syscon.h> 13 13 #include <linux/of.h> 14 - #include <linux/of_device.h> 14 + #include <linux/of_platform.h> 15 15 #include <linux/pm_runtime.h> 16 16 #include <linux/clk.h> 17 17 #include <linux/regmap.h> 18 18 #include <linux/pinctrl/consumer.h> 19 + 20 + #include "core.h" 19 21 20 22 /* USB WRAPPER register offsets */ 21 23 #define USBSS_PID 0x0 ··· 47 45 #define USBSS_PHY_VBUS_SEL_SHIFT 1 48 46 #define USBSS_PHY_LANE_REVERSE BIT(0) 49 47 48 + /* CORE STAT register bits */ 49 + #define USBSS_CORE_OPERATIONAL_MODE_MASK GENMASK(13, 12) 50 + #define USBSS_CORE_OPERATIONAL_MODE_SHIFT 12 51 + 50 52 /* MODE CONTROL register bits */ 51 53 #define USBSS_MODE_VALID BIT(0) 52 54 ··· 59 53 #define USBSS_WAKEUP_CFG_LINESTATE_EN BIT(2) 60 54 #define USBSS_WAKEUP_CFG_SESSVALID_EN BIT(1) 61 55 #define USBSS_WAKEUP_CFG_VBUSVALID_EN BIT(0) 56 + 57 + #define USBSS_WAKEUP_CFG_ALL (USBSS_WAKEUP_CFG_VBUSVALID_EN | \ 58 + USBSS_WAKEUP_CFG_SESSVALID_EN | \ 59 + USBSS_WAKEUP_CFG_LINESTATE_EN | \ 60 + USBSS_WAKEUP_CFG_OVERCURRENT_EN) 61 + 62 + #define USBSS_WAKEUP_CFG_NONE 0 62 63 63 64 /* WAKEUP STAT register bits */ 64 65 #define USBSS_WAKEUP_STAT_OVERCURRENT BIT(4) ··· 110 97 struct regmap *syscon; 111 98 unsigned int offset; 112 99 unsigned int vbus_divider; 100 + u32 wakeup_stat; 113 101 }; 114 102 115 103 static const int dwc3_ti_rate_table[] = { /* in KHZ */ ··· 247 233 reg |= USBSS_MODE_VALID; 248 234 dwc3_ti_writel(data, USBSS_MODE_CONTROL, reg); 249 235 236 + /* Device has capability to wakeup system from sleep */ 237 + device_set_wakeup_capable(dev, true); 238 + ret = device_wakeup_enable(dev); 239 + if (ret) 240 + dev_err(dev, "couldn't enable device as a wakeup source: %d\n", ret); 241 + 250 242 /* Setting up autosuspend */ 251 243 pm_runtime_set_autosuspend_delay(dev, DWC3_AM62_AUTOSUSPEND_DELAY); 252 244 pm_runtime_use_autosuspend(dev); ··· 301 281 static int dwc3_ti_suspend_common(struct device *dev) 302 282 { 303 283 struct dwc3_data *data = dev_get_drvdata(dev); 284 + u32 reg, current_prtcap_dir; 285 + 286 + if (device_may_wakeup(dev)) { 287 + reg = dwc3_ti_readl(data, USBSS_CORE_STAT); 288 + current_prtcap_dir = (reg & USBSS_CORE_OPERATIONAL_MODE_MASK) 289 + >> USBSS_CORE_OPERATIONAL_MODE_SHIFT; 290 + /* Set wakeup config enable bits */ 291 + reg = dwc3_ti_readl(data, USBSS_WAKEUP_CONFIG); 292 + if (current_prtcap_dir == DWC3_GCTL_PRTCAP_HOST) { 293 + reg = USBSS_WAKEUP_CFG_LINESTATE_EN | USBSS_WAKEUP_CFG_OVERCURRENT_EN; 294 + } else { 295 + reg = USBSS_WAKEUP_CFG_VBUSVALID_EN | USBSS_WAKEUP_CFG_SESSVALID_EN; 296 + /* 297 + * Enable LINESTATE wake up only if connected to bus 298 + * and in U2/L3 state else it causes spurious wake-up. 299 + */ 300 + } 301 + dwc3_ti_writel(data, USBSS_WAKEUP_CONFIG, reg); 302 + /* clear wakeup status so we know what caused the wake up */ 303 + dwc3_ti_writel(data, USBSS_WAKEUP_STAT, USBSS_WAKEUP_STAT_CLR); 304 + } 304 305 305 306 clk_disable_unprepare(data->usb2_refclk); 306 307 ··· 331 290 static int dwc3_ti_resume_common(struct device *dev) 332 291 { 333 292 struct dwc3_data *data = dev_get_drvdata(dev); 293 + u32 reg; 334 294 335 295 clk_prepare_enable(data->usb2_refclk); 296 + 297 + if (device_may_wakeup(dev)) { 298 + /* Clear wakeup config enable bits */ 299 + dwc3_ti_writel(data, USBSS_WAKEUP_CONFIG, USBSS_WAKEUP_CFG_NONE); 300 + } 301 + 302 + reg = dwc3_ti_readl(data, USBSS_WAKEUP_STAT); 303 + data->wakeup_stat = reg; 336 304 337 305 return 0; 338 306 }
+34 -100
drivers/usb/dwc3/dwc3-pci.c
··· 388 388 } 389 389 390 390 static const struct pci_device_id dwc3_pci_id_table[] = { 391 - { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_BSW), 392 - (kernel_ulong_t) &dwc3_pci_intel_swnode, }, 391 + { PCI_DEVICE_DATA(INTEL, BSW, &dwc3_pci_intel_swnode) }, 392 + { PCI_DEVICE_DATA(INTEL, BYT, &dwc3_pci_intel_byt_swnode) }, 393 + { PCI_DEVICE_DATA(INTEL, MRFLD, &dwc3_pci_intel_mrfld_swnode) }, 394 + { PCI_DEVICE_DATA(INTEL, CMLLP, &dwc3_pci_intel_swnode) }, 395 + { PCI_DEVICE_DATA(INTEL, CMLH, &dwc3_pci_intel_swnode) }, 396 + { PCI_DEVICE_DATA(INTEL, SPTLP, &dwc3_pci_intel_swnode) }, 397 + { PCI_DEVICE_DATA(INTEL, SPTH, &dwc3_pci_intel_swnode) }, 398 + { PCI_DEVICE_DATA(INTEL, BXT, &dwc3_pci_intel_swnode) }, 399 + { PCI_DEVICE_DATA(INTEL, BXT_M, &dwc3_pci_intel_swnode) }, 400 + { PCI_DEVICE_DATA(INTEL, APL, &dwc3_pci_intel_swnode) }, 401 + { PCI_DEVICE_DATA(INTEL, KBP, &dwc3_pci_intel_swnode) }, 402 + { PCI_DEVICE_DATA(INTEL, GLK, &dwc3_pci_intel_swnode) }, 403 + { PCI_DEVICE_DATA(INTEL, CNPLP, &dwc3_pci_intel_swnode) }, 404 + { PCI_DEVICE_DATA(INTEL, CNPH, &dwc3_pci_intel_swnode) }, 405 + { PCI_DEVICE_DATA(INTEL, CNPV, &dwc3_pci_intel_swnode) }, 406 + { PCI_DEVICE_DATA(INTEL, ICLLP, &dwc3_pci_intel_swnode) }, 407 + { PCI_DEVICE_DATA(INTEL, EHL, &dwc3_pci_intel_swnode) }, 408 + { PCI_DEVICE_DATA(INTEL, TGPLP, &dwc3_pci_intel_swnode) }, 409 + { PCI_DEVICE_DATA(INTEL, TGPH, &dwc3_pci_intel_swnode) }, 410 + { PCI_DEVICE_DATA(INTEL, JSP, &dwc3_pci_intel_swnode) }, 411 + { PCI_DEVICE_DATA(INTEL, ADL, &dwc3_pci_intel_swnode) }, 412 + { PCI_DEVICE_DATA(INTEL, ADL_PCH, &dwc3_pci_intel_swnode) }, 413 + { PCI_DEVICE_DATA(INTEL, ADLN, &dwc3_pci_intel_swnode) }, 414 + { PCI_DEVICE_DATA(INTEL, ADLN_PCH, &dwc3_pci_intel_swnode) }, 415 + { PCI_DEVICE_DATA(INTEL, ADLS, &dwc3_pci_intel_swnode) }, 416 + { PCI_DEVICE_DATA(INTEL, RPL, &dwc3_pci_intel_swnode) }, 417 + { PCI_DEVICE_DATA(INTEL, RPLS, &dwc3_pci_intel_swnode) }, 418 + { PCI_DEVICE_DATA(INTEL, MTLM, &dwc3_pci_intel_swnode) }, 419 + { PCI_DEVICE_DATA(INTEL, MTLP, &dwc3_pci_intel_swnode) }, 420 + { PCI_DEVICE_DATA(INTEL, MTL, &dwc3_pci_intel_swnode) }, 421 + { PCI_DEVICE_DATA(INTEL, MTLS, &dwc3_pci_intel_swnode) }, 422 + { PCI_DEVICE_DATA(INTEL, TGL, &dwc3_pci_intel_swnode) }, 393 423 394 - { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_BYT), 395 - (kernel_ulong_t) &dwc3_pci_intel_byt_swnode, }, 396 - 397 - { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_MRFLD), 398 - (kernel_ulong_t) &dwc3_pci_intel_mrfld_swnode, }, 399 - 400 - { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_CMLLP), 401 - (kernel_ulong_t) &dwc3_pci_intel_swnode, }, 402 - 403 - { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_CMLH), 404 - (kernel_ulong_t) &dwc3_pci_intel_swnode, }, 405 - 406 - { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_SPTLP), 407 - (kernel_ulong_t) &dwc3_pci_intel_swnode, }, 408 - 409 - { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_SPTH), 410 - (kernel_ulong_t) &dwc3_pci_intel_swnode, }, 411 - 412 - { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_BXT), 413 - (kernel_ulong_t) &dwc3_pci_intel_swnode, }, 414 - 415 - { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_BXT_M), 416 - (kernel_ulong_t) &dwc3_pci_intel_swnode, }, 417 - 418 - { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_APL), 419 - (kernel_ulong_t) &dwc3_pci_intel_swnode, }, 420 - 421 - { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_KBP), 422 - (kernel_ulong_t) &dwc3_pci_intel_swnode, }, 423 - 424 - { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_GLK), 425 - (kernel_ulong_t) &dwc3_pci_intel_swnode, }, 426 - 427 - { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_CNPLP), 428 - (kernel_ulong_t) &dwc3_pci_intel_swnode, }, 429 - 430 - { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_CNPH), 431 - (kernel_ulong_t) &dwc3_pci_intel_swnode, }, 432 - 433 - { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_CNPV), 434 - (kernel_ulong_t) &dwc3_pci_intel_swnode, }, 435 - 436 - { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_ICLLP), 437 - (kernel_ulong_t) &dwc3_pci_intel_swnode, }, 438 - 439 - { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_EHL), 440 - (kernel_ulong_t) &dwc3_pci_intel_swnode, }, 441 - 442 - { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_TGPLP), 443 - (kernel_ulong_t) &dwc3_pci_intel_swnode, }, 444 - 445 - { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_TGPH), 446 - (kernel_ulong_t) &dwc3_pci_intel_swnode, }, 447 - 448 - { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_JSP), 449 - (kernel_ulong_t) &dwc3_pci_intel_swnode, }, 450 - 451 - { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_ADL), 452 - (kernel_ulong_t) &dwc3_pci_intel_swnode, }, 453 - 454 - { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_ADL_PCH), 455 - (kernel_ulong_t) &dwc3_pci_intel_swnode, }, 456 - 457 - { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_ADLN), 458 - (kernel_ulong_t) &dwc3_pci_intel_swnode, }, 459 - 460 - { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_ADLN_PCH), 461 - (kernel_ulong_t) &dwc3_pci_intel_swnode, }, 462 - 463 - { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_ADLS), 464 - (kernel_ulong_t) &dwc3_pci_intel_swnode, }, 465 - 466 - { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_RPL), 467 - (kernel_ulong_t) &dwc3_pci_intel_swnode, }, 468 - 469 - { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_RPLS), 470 - (kernel_ulong_t) &dwc3_pci_intel_swnode, }, 471 - 472 - { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_MTLM), 473 - (kernel_ulong_t) &dwc3_pci_intel_swnode, }, 474 - 475 - { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_MTLP), 476 - (kernel_ulong_t) &dwc3_pci_intel_swnode, }, 477 - 478 - { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_MTLS), 479 - (kernel_ulong_t) &dwc3_pci_intel_swnode, }, 480 - 481 - { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_MTL), 482 - (kernel_ulong_t) &dwc3_pci_intel_swnode, }, 483 - 484 - { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_TGL), 485 - (kernel_ulong_t) &dwc3_pci_intel_swnode, }, 486 - 487 - { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_NL_USB), 488 - (kernel_ulong_t) &dwc3_pci_amd_swnode, }, 489 - 490 - { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_MR), 491 - (kernel_ulong_t)&dwc3_pci_amd_mr_swnode, }, 424 + { PCI_DEVICE_DATA(AMD, NL_USB, &dwc3_pci_amd_swnode) }, 425 + { PCI_DEVICE_DATA(AMD, MR, &dwc3_pci_amd_mr_swnode) }, 492 426 493 427 { } /* Terminating Entry */ 494 428 };
+11 -8
drivers/usb/dwc3/ep0.c
··· 30 30 static void __dwc3_ep0_do_control_status(struct dwc3 *dwc, struct dwc3_ep *dep); 31 31 static void __dwc3_ep0_do_control_data(struct dwc3 *dwc, 32 32 struct dwc3_ep *dep, struct dwc3_request *req); 33 + static int dwc3_ep0_delegate_req(struct dwc3 *dwc, 34 + struct usb_ctrlrequest *ctrl); 33 35 34 36 static void dwc3_ep0_prepare_one_trb(struct dwc3_ep *dep, 35 37 dma_addr_t buf_dma, u32 len, u32 type, bool chain) ··· 358 356 usb_status |= 1 << USB_DEV_STAT_U1_ENABLED; 359 357 if (reg & DWC3_DCTL_INITU2ENA) 360 358 usb_status |= 1 << USB_DEV_STAT_U2_ENABLED; 359 + } else { 360 + usb_status |= dwc->gadget->wakeup_armed << 361 + USB_DEVICE_REMOTE_WAKEUP; 361 362 } 362 363 363 364 break; ··· 370 365 * Function Remote Wake Capable D0 371 366 * Function Remote Wakeup D1 372 367 */ 373 - break; 368 + return dwc3_ep0_delegate_req(dwc, ctrl); 374 369 375 370 case USB_RECIP_ENDPOINT: 376 371 dep = dwc3_wIndex_to_dep(dwc, ctrl->wIndex); ··· 481 476 482 477 switch (wValue) { 483 478 case USB_DEVICE_REMOTE_WAKEUP: 479 + if (dwc->wakeup_configured) 480 + dwc->gadget->wakeup_armed = set; 481 + else 482 + ret = -EINVAL; 484 483 break; 485 484 /* 486 485 * 9.4.1 says only for SS, in AddressState only for ··· 519 510 520 511 switch (wValue) { 521 512 case USB_INTRF_FUNC_SUSPEND: 522 - /* 523 - * REVISIT: Ideally we would enable some low power mode here, 524 - * however it's unclear what we should be doing here. 525 - * 526 - * For now, we're not doing anything, just making sure we return 527 - * 0 so USB Command Verifier tests pass without any errors. 528 - */ 513 + ret = dwc3_ep0_delegate_req(dwc, ctrl); 529 514 break; 530 515 default: 531 516 ret = -EINVAL;
+177 -102
drivers/usb/dwc3/gadget.c
··· 139 139 return -ETIMEDOUT; 140 140 } 141 141 142 + static void dwc3_ep0_reset_state(struct dwc3 *dwc) 143 + { 144 + unsigned int dir; 145 + 146 + if (dwc->ep0state != EP0_SETUP_PHASE) { 147 + dir = !!dwc->ep0_expect_in; 148 + if (dwc->ep0state == EP0_DATA_PHASE) 149 + dwc3_ep0_end_control_data(dwc, dwc->eps[dir]); 150 + else 151 + dwc3_ep0_end_control_data(dwc, dwc->eps[!dir]); 152 + 153 + dwc->eps[0]->trb_enqueue = 0; 154 + dwc->eps[1]->trb_enqueue = 0; 155 + 156 + dwc3_ep0_stall_and_restart(dwc); 157 + } 158 + } 159 + 142 160 /** 143 161 * dwc3_ep_inc_trb - increment a trb index. 144 162 * @index: Pointer to the TRB index to increment. ··· 276 258 return ret; 277 259 } 278 260 279 - static int __dwc3_gadget_wakeup(struct dwc3 *dwc); 261 + static int __dwc3_gadget_wakeup(struct dwc3 *dwc, bool async); 280 262 281 263 /** 282 264 * dwc3_send_gadget_ep_cmd - issue an endpoint command ··· 343 325 344 326 fallthrough; 345 327 case DWC3_LINK_STATE_U3: 346 - ret = __dwc3_gadget_wakeup(dwc); 328 + ret = __dwc3_gadget_wakeup(dwc, false); 347 329 dev_WARN_ONCE(dwc->dev, ret, "wakeup failed --> %d\n", 348 330 ret); 349 331 break; ··· 2291 2273 2292 2274 /* -------------------------------------------------------------------------- */ 2293 2275 2276 + static void dwc3_gadget_enable_linksts_evts(struct dwc3 *dwc, bool set) 2277 + { 2278 + u32 reg; 2279 + 2280 + if (DWC3_VER_IS_PRIOR(DWC3, 250A)) 2281 + return; 2282 + 2283 + reg = dwc3_readl(dwc->regs, DWC3_DEVTEN); 2284 + if (set) 2285 + reg |= DWC3_DEVTEN_ULSTCNGEN; 2286 + else 2287 + reg &= ~DWC3_DEVTEN_ULSTCNGEN; 2288 + 2289 + dwc3_writel(dwc->regs, DWC3_DEVTEN, reg); 2290 + } 2291 + 2294 2292 static int dwc3_gadget_get_frame(struct usb_gadget *g) 2295 2293 { 2296 2294 struct dwc3 *dwc = gadget_to_dwc(g); ··· 2314 2280 return __dwc3_gadget_get_frame(dwc); 2315 2281 } 2316 2282 2317 - static int __dwc3_gadget_wakeup(struct dwc3 *dwc) 2283 + static int __dwc3_gadget_wakeup(struct dwc3 *dwc, bool async) 2318 2284 { 2319 2285 int retries; 2320 2286 ··· 2345 2311 return -EINVAL; 2346 2312 } 2347 2313 2314 + if (async) 2315 + dwc3_gadget_enable_linksts_evts(dwc, true); 2316 + 2348 2317 ret = dwc3_gadget_set_link_state(dwc, DWC3_LINK_STATE_RECOV); 2349 2318 if (ret < 0) { 2350 2319 dev_err(dwc->dev, "failed to put link in Recovery\n"); 2320 + dwc3_gadget_enable_linksts_evts(dwc, false); 2351 2321 return ret; 2352 2322 } 2353 2323 ··· 2362 2324 reg &= ~DWC3_DCTL_ULSTCHNGREQ_MASK; 2363 2325 dwc3_writel(dwc->regs, DWC3_DCTL, reg); 2364 2326 } 2327 + 2328 + /* 2329 + * Since link status change events are enabled we will receive 2330 + * an U0 event when wakeup is successful. So bail out. 2331 + */ 2332 + if (async) 2333 + return 0; 2365 2334 2366 2335 /* poll until Link State changes to ON */ 2367 2336 retries = 20000; ··· 2395 2350 unsigned long flags; 2396 2351 int ret; 2397 2352 2353 + if (!dwc->wakeup_configured) { 2354 + dev_err(dwc->dev, "remote wakeup not configured\n"); 2355 + return -EINVAL; 2356 + } 2357 + 2398 2358 spin_lock_irqsave(&dwc->lock, flags); 2399 - ret = __dwc3_gadget_wakeup(dwc); 2359 + if (!dwc->gadget->wakeup_armed) { 2360 + dev_err(dwc->dev, "not armed for remote wakeup\n"); 2361 + spin_unlock_irqrestore(&dwc->lock, flags); 2362 + return -EINVAL; 2363 + } 2364 + ret = __dwc3_gadget_wakeup(dwc, true); 2365 + 2400 2366 spin_unlock_irqrestore(&dwc->lock, flags); 2401 2367 2402 2368 return ret; 2369 + } 2370 + 2371 + static void dwc3_resume_gadget(struct dwc3 *dwc); 2372 + 2373 + static int dwc3_gadget_func_wakeup(struct usb_gadget *g, int intf_id) 2374 + { 2375 + struct dwc3 *dwc = gadget_to_dwc(g); 2376 + unsigned long flags; 2377 + int ret; 2378 + int link_state; 2379 + 2380 + if (!dwc->wakeup_configured) { 2381 + dev_err(dwc->dev, "remote wakeup not configured\n"); 2382 + return -EINVAL; 2383 + } 2384 + 2385 + spin_lock_irqsave(&dwc->lock, flags); 2386 + /* 2387 + * If the link is in U3, signal for remote wakeup and wait for the 2388 + * link to transition to U0 before sending device notification. 2389 + */ 2390 + link_state = dwc3_gadget_get_link_state(dwc); 2391 + if (link_state == DWC3_LINK_STATE_U3) { 2392 + ret = __dwc3_gadget_wakeup(dwc, false); 2393 + if (ret) { 2394 + spin_unlock_irqrestore(&dwc->lock, flags); 2395 + return -EINVAL; 2396 + } 2397 + dwc3_resume_gadget(dwc); 2398 + dwc->link_state = DWC3_LINK_STATE_U0; 2399 + } 2400 + 2401 + ret = dwc3_send_gadget_generic_command(dwc, DWC3_DGCMD_DEV_NOTIFICATION, 2402 + DWC3_DGCMDPAR_DN_FUNC_WAKE | 2403 + DWC3_DGCMDPAR_INTF_SEL(intf_id)); 2404 + if (ret) 2405 + dev_err(dwc->dev, "function remote wakeup failed, ret:%d\n", ret); 2406 + 2407 + spin_unlock_irqrestore(&dwc->lock, flags); 2408 + 2409 + return ret; 2410 + } 2411 + 2412 + static int dwc3_gadget_set_remote_wakeup(struct usb_gadget *g, int set) 2413 + { 2414 + struct dwc3 *dwc = gadget_to_dwc(g); 2415 + unsigned long flags; 2416 + 2417 + spin_lock_irqsave(&dwc->lock, flags); 2418 + dwc->wakeup_configured = !!set; 2419 + spin_unlock_irqrestore(&dwc->lock, flags); 2420 + 2421 + return 0; 2403 2422 } 2404 2423 2405 2424 static int dwc3_gadget_set_selfpowered(struct usb_gadget *g, ··· 2587 2478 dwc3_writel(dwc->regs, DWC3_DCFG, reg); 2588 2479 } 2589 2480 2590 - static int dwc3_gadget_run_stop(struct dwc3 *dwc, int is_on, int suspend) 2481 + static int dwc3_gadget_run_stop(struct dwc3 *dwc, int is_on) 2591 2482 { 2592 2483 u32 reg; 2593 2484 u32 timeout = 2000; ··· 2606 2497 reg &= ~DWC3_DCTL_KEEP_CONNECT; 2607 2498 reg |= DWC3_DCTL_RUN_STOP; 2608 2499 2609 - if (dwc->has_hibernation) 2610 - reg |= DWC3_DCTL_KEEP_CONNECT; 2611 - 2612 2500 __dwc3_gadget_set_speed(dwc); 2613 2501 dwc->pullups_connected = true; 2614 2502 } else { 2615 2503 reg &= ~DWC3_DCTL_RUN_STOP; 2616 - 2617 - if (dwc->has_hibernation && !suspend) 2618 - reg &= ~DWC3_DCTL_KEEP_CONNECT; 2619 2504 2620 2505 dwc->pullups_connected = false; 2621 2506 } ··· 2635 2532 static int dwc3_gadget_soft_disconnect(struct dwc3 *dwc) 2636 2533 { 2637 2534 unsigned long flags; 2535 + int ret; 2638 2536 2639 2537 spin_lock_irqsave(&dwc->lock, flags); 2640 2538 dwc->connected = false; 2641 2539 2642 2540 /* 2643 - * Per databook, when we want to stop the gadget, if a control transfer 2644 - * is still in process, complete it and get the core into setup phase. 2541 + * Attempt to end pending SETUP status phase, and not wait for the 2542 + * function to do so. 2645 2543 */ 2646 - if (dwc->ep0state != EP0_SETUP_PHASE) { 2647 - int ret; 2648 - 2649 - if (dwc->delayed_status) 2650 - dwc3_ep0_send_delayed_status(dwc); 2651 - 2652 - reinit_completion(&dwc->ep0_in_setup); 2653 - 2654 - spin_unlock_irqrestore(&dwc->lock, flags); 2655 - ret = wait_for_completion_timeout(&dwc->ep0_in_setup, 2656 - msecs_to_jiffies(DWC3_PULL_UP_TIMEOUT)); 2657 - spin_lock_irqsave(&dwc->lock, flags); 2658 - if (ret == 0) 2659 - dev_warn(dwc->dev, "timed out waiting for SETUP phase\n"); 2660 - } 2544 + if (dwc->delayed_status) 2545 + dwc3_ep0_send_delayed_status(dwc); 2661 2546 2662 2547 /* 2663 2548 * In the Synopsys DesignWare Cores USB3 Databook Rev. 3.30a ··· 2655 2564 * bit. 2656 2565 */ 2657 2566 dwc3_stop_active_transfers(dwc); 2658 - __dwc3_gadget_stop(dwc); 2659 2567 spin_unlock_irqrestore(&dwc->lock, flags); 2568 + 2569 + /* 2570 + * Per databook, when we want to stop the gadget, if a control transfer 2571 + * is still in process, complete it and get the core into setup phase. 2572 + * In case the host is unresponsive to a SETUP transaction, forcefully 2573 + * stall the transfer, and move back to the SETUP phase, so that any 2574 + * pending endxfers can be executed. 2575 + */ 2576 + if (dwc->ep0state != EP0_SETUP_PHASE) { 2577 + reinit_completion(&dwc->ep0_in_setup); 2578 + 2579 + ret = wait_for_completion_timeout(&dwc->ep0_in_setup, 2580 + msecs_to_jiffies(DWC3_PULL_UP_TIMEOUT)); 2581 + if (ret == 0) { 2582 + dev_warn(dwc->dev, "wait for SETUP phase timed out\n"); 2583 + spin_lock_irqsave(&dwc->lock, flags); 2584 + dwc3_ep0_reset_state(dwc); 2585 + spin_unlock_irqrestore(&dwc->lock, flags); 2586 + } 2587 + } 2660 2588 2661 2589 /* 2662 2590 * Note: if the GEVNTCOUNT indicates events in the event buffer, the ··· 2684 2574 * remaining event generated by the controller while polling for 2685 2575 * DSTS.DEVCTLHLT. 2686 2576 */ 2687 - return dwc3_gadget_run_stop(dwc, false, false); 2577 + ret = dwc3_gadget_run_stop(dwc, false); 2578 + 2579 + /* 2580 + * Stop the gadget after controller is halted, so that if needed, the 2581 + * events to update EP0 state can still occur while the run/stop 2582 + * routine polls for the halted state. DEVTEN is cleared as part of 2583 + * gadget stop. 2584 + */ 2585 + spin_lock_irqsave(&dwc->lock, flags); 2586 + __dwc3_gadget_stop(dwc); 2587 + spin_unlock_irqrestore(&dwc->lock, flags); 2588 + 2589 + return ret; 2688 2590 } 2689 2591 2690 2592 static int dwc3_gadget_pullup(struct usb_gadget *g, int is_on) ··· 2750 2628 2751 2629 dwc3_event_buffers_setup(dwc); 2752 2630 __dwc3_gadget_start(dwc); 2753 - ret = dwc3_gadget_run_stop(dwc, true, false); 2631 + ret = dwc3_gadget_run_stop(dwc, true); 2754 2632 } 2755 2633 2756 2634 pm_runtime_put(dwc->dev); ··· 3104 2982 static const struct usb_gadget_ops dwc3_gadget_ops = { 3105 2983 .get_frame = dwc3_gadget_get_frame, 3106 2984 .wakeup = dwc3_gadget_wakeup, 2985 + .func_wakeup = dwc3_gadget_func_wakeup, 2986 + .set_remote_wakeup = dwc3_gadget_set_remote_wakeup, 3107 2987 .set_selfpowered = dwc3_gadget_set_selfpowered, 3108 2988 .pullup = dwc3_gadget_pullup, 3109 2989 .udc_start = dwc3_gadget_start, ··· 3951 3827 3952 3828 dwc->gadget->speed = USB_SPEED_UNKNOWN; 3953 3829 dwc->setup_packet_pending = false; 3830 + dwc->gadget->wakeup_armed = false; 3831 + dwc3_gadget_enable_linksts_evts(dwc, false); 3954 3832 usb_gadget_set_state(dwc->gadget, USB_STATE_NOTATTACHED); 3955 3833 3956 - if (dwc->ep0state != EP0_SETUP_PHASE) { 3957 - unsigned int dir; 3958 - 3959 - dir = !!dwc->ep0_expect_in; 3960 - if (dwc->ep0state == EP0_DATA_PHASE) 3961 - dwc3_ep0_end_control_data(dwc, dwc->eps[dir]); 3962 - else 3963 - dwc3_ep0_end_control_data(dwc, dwc->eps[!dir]); 3964 - dwc3_ep0_stall_and_restart(dwc); 3965 - } 3834 + dwc3_ep0_reset_state(dwc); 3966 3835 } 3967 3836 3968 3837 static void dwc3_gadget_reset_interrupt(struct dwc3 *dwc) ··· 4009 3892 * phase. So ensure that EP0 is in setup phase by issuing a stall 4010 3893 * and restart if EP0 is not in setup phase. 4011 3894 */ 4012 - if (dwc->ep0state != EP0_SETUP_PHASE) { 4013 - unsigned int dir; 4014 - 4015 - dir = !!dwc->ep0_expect_in; 4016 - if (dwc->ep0state == EP0_DATA_PHASE) 4017 - dwc3_ep0_end_control_data(dwc, dwc->eps[dir]); 4018 - else 4019 - dwc3_ep0_end_control_data(dwc, dwc->eps[!dir]); 4020 - 4021 - dwc->eps[0]->trb_enqueue = 0; 4022 - dwc->eps[1]->trb_enqueue = 0; 4023 - 4024 - dwc3_ep0_stall_and_restart(dwc); 4025 - } 3895 + dwc3_ep0_reset_state(dwc); 4026 3896 4027 3897 /* 4028 3898 * In the Synopsis DesignWare Cores USB3 Databook Rev. 3.30a ··· 4024 3920 reg &= ~DWC3_DCTL_TSTCTRL_MASK; 4025 3921 dwc3_gadget_dctl_write_safe(dwc, reg); 4026 3922 dwc->test_mode = false; 3923 + dwc->gadget->wakeup_armed = false; 3924 + dwc3_gadget_enable_linksts_evts(dwc, false); 4027 3925 dwc3_clear_stall_all_ep(dwc); 4028 3926 4029 3927 /* Reset device address to zero */ ··· 4178 4072 */ 4179 4073 } 4180 4074 4181 - static void dwc3_gadget_wakeup_interrupt(struct dwc3 *dwc) 4075 + static void dwc3_gadget_wakeup_interrupt(struct dwc3 *dwc, unsigned int evtinfo) 4182 4076 { 4183 4077 /* 4184 4078 * TODO take core out of low power mode when that's ··· 4190 4084 dwc->gadget_driver->resume(dwc->gadget); 4191 4085 spin_lock(&dwc->lock); 4192 4086 } 4087 + 4088 + dwc->link_state = evtinfo & DWC3_LINK_STATE_MASK; 4193 4089 } 4194 4090 4195 4091 static void dwc3_gadget_linksts_change_interrupt(struct dwc3 *dwc, ··· 4273 4165 } 4274 4166 4275 4167 switch (next) { 4168 + case DWC3_LINK_STATE_U0: 4169 + if (dwc->gadget->wakeup_armed) { 4170 + dwc3_gadget_enable_linksts_evts(dwc, false); 4171 + dwc3_resume_gadget(dwc); 4172 + } 4173 + break; 4276 4174 case DWC3_LINK_STATE_U1: 4277 4175 if (dwc->speed == USB_SPEED_SUPER) 4278 4176 dwc3_suspend_gadget(dwc); ··· 4309 4195 dwc->link_state = next; 4310 4196 } 4311 4197 4312 - static void dwc3_gadget_hibernation_interrupt(struct dwc3 *dwc, 4313 - unsigned int evtinfo) 4314 - { 4315 - unsigned int is_ss = evtinfo & BIT(4); 4316 - 4317 - /* 4318 - * WORKAROUND: DWC3 revision 2.20a with hibernation support 4319 - * have a known issue which can cause USB CV TD.9.23 to fail 4320 - * randomly. 4321 - * 4322 - * Because of this issue, core could generate bogus hibernation 4323 - * events which SW needs to ignore. 4324 - * 4325 - * Refers to: 4326 - * 4327 - * STAR#9000546576: Device Mode Hibernation: Issue in USB 2.0 4328 - * Device Fallback from SuperSpeed 4329 - */ 4330 - if (is_ss ^ (dwc->speed == USB_SPEED_SUPER)) 4331 - return; 4332 - 4333 - /* enter hibernation here */ 4334 - } 4335 - 4336 4198 static void dwc3_gadget_interrupt(struct dwc3 *dwc, 4337 4199 const struct dwc3_event_devt *event) 4338 4200 { ··· 4323 4233 dwc3_gadget_conndone_interrupt(dwc); 4324 4234 break; 4325 4235 case DWC3_DEVICE_EVENT_WAKEUP: 4326 - dwc3_gadget_wakeup_interrupt(dwc); 4236 + dwc3_gadget_wakeup_interrupt(dwc, event->event_info); 4327 4237 break; 4328 4238 case DWC3_DEVICE_EVENT_HIBER_REQ: 4329 - if (dev_WARN_ONCE(dwc->dev, !dwc->has_hibernation, 4330 - "unexpected hibernation event\n")) 4331 - break; 4332 - 4333 - dwc3_gadget_hibernation_interrupt(dwc, event->event_info); 4239 + dev_WARN_ONCE(dwc->dev, true, "unexpected hibernation event\n"); 4334 4240 break; 4335 4241 case DWC3_DEVICE_EVENT_LINK_STATUS_CHANGE: 4336 4242 dwc3_gadget_linksts_change_interrupt(dwc, event->event_info); 4337 4243 break; 4338 4244 case DWC3_DEVICE_EVENT_SUSPEND: 4339 4245 /* It changed to be suspend event for version 2.30a and above */ 4340 - if (!DWC3_VER_IS_PRIOR(DWC3, 230A)) { 4341 - /* 4342 - * Ignore suspend event until the gadget enters into 4343 - * USB_STATE_CONFIGURED state. 4344 - */ 4345 - if (dwc->gadget->state >= USB_STATE_CONFIGURED) 4346 - dwc3_gadget_suspend_interrupt(dwc, 4347 - event->event_info); 4348 - } 4246 + if (!DWC3_VER_IS_PRIOR(DWC3, 230A)) 4247 + dwc3_gadget_suspend_interrupt(dwc, event->event_info); 4349 4248 break; 4350 4249 case DWC3_DEVICE_EVENT_SOF: 4351 4250 case DWC3_DEVICE_EVENT_ERRATIC_ERROR: ··· 4496 4417 goto out; 4497 4418 4498 4419 irq = platform_get_irq(dwc3_pdev, 0); 4499 - if (irq > 0) 4500 - goto out; 4501 - 4502 - if (!irq) 4503 - irq = -EINVAL; 4504 4420 4505 4421 out: 4506 4422 return irq; ··· 4567 4493 dwc->gadget->sg_supported = true; 4568 4494 dwc->gadget->name = "dwc3-gadget"; 4569 4495 dwc->gadget->lpm_capable = !dwc->usb2_gadget_lpm_disable; 4496 + dwc->gadget->wakeup_capable = true; 4570 4497 4571 4498 /* 4572 4499 * FIXME We might be setting max_speed to <SUPER, however versions ··· 4659 4584 if (!dwc->gadget_driver) 4660 4585 return 0; 4661 4586 4662 - dwc3_gadget_run_stop(dwc, false, false); 4587 + dwc3_gadget_run_stop(dwc, false); 4663 4588 4664 4589 spin_lock_irqsave(&dwc->lock, flags); 4665 4590 dwc3_disconnect_gadget(dwc); ··· 4680 4605 if (ret < 0) 4681 4606 goto err0; 4682 4607 4683 - ret = dwc3_gadget_run_stop(dwc, true, false); 4608 + ret = dwc3_gadget_run_stop(dwc, true); 4684 4609 if (ret < 0) 4685 4610 goto err1; 4686 4611
+1 -6
drivers/usb/dwc3/host.c
··· 52 52 goto out; 53 53 54 54 irq = platform_get_irq(dwc3_pdev, 0); 55 - if (irq > 0) { 55 + if (irq > 0) 56 56 dwc3_host_fill_xhci_irq_res(dwc, irq, NULL); 57 - goto out; 58 - } 59 - 60 - if (!irq) 61 - irq = -EINVAL; 62 57 63 58 out: 64 59 return irq;
+2 -4
drivers/usb/dwc3/trace.h
··· 54 54 TP_STRUCT__entry( 55 55 __field(u32, event) 56 56 __field(u32, ep0state) 57 - __dynamic_array(char, str, DWC3_MSG_MAX) 58 57 ), 59 58 TP_fast_assign( 60 59 __entry->event = event; 61 60 __entry->ep0state = dwc->ep0state; 62 61 ), 63 62 TP_printk("event (%08x): %s", __entry->event, 64 - dwc3_decode_event(__get_str(str), DWC3_MSG_MAX, 63 + dwc3_decode_event(__get_buf(DWC3_MSG_MAX), DWC3_MSG_MAX, 65 64 __entry->event, __entry->ep0state)) 66 65 ); 67 66 ··· 78 79 __field(__u16, wValue) 79 80 __field(__u16, wIndex) 80 81 __field(__u16, wLength) 81 - __dynamic_array(char, str, DWC3_MSG_MAX) 82 82 ), 83 83 TP_fast_assign( 84 84 __entry->bRequestType = ctrl->bRequestType; ··· 86 88 __entry->wIndex = le16_to_cpu(ctrl->wIndex); 87 89 __entry->wLength = le16_to_cpu(ctrl->wLength); 88 90 ), 89 - TP_printk("%s", usb_decode_ctrl(__get_str(str), DWC3_MSG_MAX, 91 + TP_printk("%s", usb_decode_ctrl(__get_buf(DWC3_MSG_MAX), DWC3_MSG_MAX, 90 92 __entry->bRequestType, 91 93 __entry->bRequest, __entry->wValue, 92 94 __entry->wIndex, __entry->wLength)
+122 -5
drivers/usb/gadget/composite.c
··· 492 492 } 493 493 EXPORT_SYMBOL_GPL(usb_interface_id); 494 494 495 + /** 496 + * usb_func_wakeup - sends function wake notification to the host. 497 + * @func: function that sends the remote wakeup notification. 498 + * 499 + * Applicable to devices operating at enhanced superspeed when usb 500 + * functions are put in function suspend state and armed for function 501 + * remote wakeup. On completion, function wake notification is sent. If 502 + * the device is in low power state it tries to bring the device to active 503 + * state before sending the wake notification. Since it is a synchronous 504 + * call, caller must take care of not calling it in interrupt context. 505 + * For devices operating at lower speeds returns negative errno. 506 + * 507 + * Returns zero on success, else negative errno. 508 + */ 509 + int usb_func_wakeup(struct usb_function *func) 510 + { 511 + struct usb_gadget *gadget = func->config->cdev->gadget; 512 + int id; 513 + 514 + if (!gadget->ops->func_wakeup) 515 + return -EOPNOTSUPP; 516 + 517 + if (!func->func_wakeup_armed) { 518 + ERROR(func->config->cdev, "not armed for func remote wakeup\n"); 519 + return -EINVAL; 520 + } 521 + 522 + for (id = 0; id < MAX_CONFIG_INTERFACES; id++) 523 + if (func->config->interface[id] == func) 524 + break; 525 + 526 + if (id == MAX_CONFIG_INTERFACES) { 527 + ERROR(func->config->cdev, "Invalid function\n"); 528 + return -EINVAL; 529 + } 530 + 531 + return gadget->ops->func_wakeup(gadget, id); 532 + } 533 + EXPORT_SYMBOL_GPL(usb_func_wakeup); 534 + 495 535 static u8 encode_bMaxPower(enum usb_device_speed speed, 496 536 struct usb_configuration *c) 497 537 { ··· 551 511 * by 8 the integral division will effectively cap to 896mA. 552 512 */ 553 513 return min(val, 900U) / 8; 514 + } 515 + 516 + void check_remote_wakeup_config(struct usb_gadget *g, 517 + struct usb_configuration *c) 518 + { 519 + if (USB_CONFIG_ATT_WAKEUP & c->bmAttributes) { 520 + /* Reset the rw bit if gadget is not capable of it */ 521 + if (!g->wakeup_capable && g->ops->set_remote_wakeup) { 522 + WARN(c->cdev, "Clearing wakeup bit for config c.%d\n", 523 + c->bConfigurationValue); 524 + c->bmAttributes &= ~USB_CONFIG_ATT_WAKEUP; 525 + } 526 + } 554 527 } 555 528 556 529 static int config_buf(struct usb_configuration *config, ··· 941 888 if (f->disable) 942 889 f->disable(f); 943 890 891 + /* Section 9.1.1.6, disable remote wakeup when device is reset */ 892 + f->func_wakeup_armed = false; 893 + 944 894 bitmap_zero(f->endpoints, 32); 945 895 } 946 896 cdev->config = NULL; ··· 1050 994 power = min(power, 500U); 1051 995 else 1052 996 power = min(power, 900U); 997 + 998 + if (USB_CONFIG_ATT_WAKEUP & c->bmAttributes) 999 + usb_gadget_set_remote_wakeup(gadget, 1); 1000 + else 1001 + usb_gadget_set_remote_wakeup(gadget, 0); 1053 1002 done: 1054 1003 if (power <= USB_SELF_POWER_VBUS_MAX_DRAW) 1055 1004 usb_gadget_set_selfpowered(gadget); ··· 2009 1948 f = cdev->config->interface[intf]; 2010 1949 if (!f) 2011 1950 break; 2012 - status = f->get_status ? f->get_status(f) : 0; 2013 - if (status < 0) 2014 - break; 1951 + 1952 + if (f->get_status) { 1953 + status = f->get_status(f); 1954 + if (status < 0) 1955 + break; 1956 + } else { 1957 + /* Set D0 and D1 bits based on func wakeup capability */ 1958 + if (f->config->bmAttributes & USB_CONFIG_ATT_WAKEUP) { 1959 + status |= USB_INTRF_STAT_FUNC_RW_CAP; 1960 + if (f->func_wakeup_armed) 1961 + status |= USB_INTRF_STAT_FUNC_RW; 1962 + } 1963 + } 1964 + 2015 1965 put_unaligned_le16(status & 0x0000ffff, req->buf); 2016 1966 break; 2017 1967 /* ··· 2044 1972 if (!f) 2045 1973 break; 2046 1974 value = 0; 2047 - if (f->func_suspend) 1975 + if (f->func_suspend) { 2048 1976 value = f->func_suspend(f, w_index >> 8); 1977 + /* SetFeature(FUNCTION_SUSPEND) */ 1978 + } else if (ctrl->bRequest == USB_REQ_SET_FEATURE) { 1979 + if (!(f->config->bmAttributes & 1980 + USB_CONFIG_ATT_WAKEUP) && 1981 + (w_index & USB_INTRF_FUNC_SUSPEND_RW)) 1982 + break; 1983 + 1984 + f->func_wakeup_armed = !!(w_index & 1985 + USB_INTRF_FUNC_SUSPEND_RW); 1986 + 1987 + if (w_index & USB_INTRF_FUNC_SUSPEND_LP) { 1988 + if (f->suspend && !f->func_suspended) { 1989 + f->suspend(f); 1990 + f->func_suspended = true; 1991 + } 1992 + /* 1993 + * Handle cases where host sends function resume 1994 + * through SetFeature(FUNCTION_SUSPEND) but low power 1995 + * bit reset 1996 + */ 1997 + } else { 1998 + if (f->resume && f->func_suspended) { 1999 + f->resume(f); 2000 + f->func_suspended = false; 2001 + } 2002 + } 2003 + /* ClearFeature(FUNCTION_SUSPEND) */ 2004 + } else if (ctrl->bRequest == USB_REQ_CLEAR_FEATURE) { 2005 + f->func_wakeup_armed = false; 2006 + 2007 + if (f->resume && f->func_suspended) { 2008 + f->resume(f); 2009 + f->func_suspended = false; 2010 + } 2011 + } 2012 + 2049 2013 if (value < 0) { 2050 2014 ERROR(cdev, 2051 2015 "func_suspend() returned error %d\n", ··· 2623 2515 cdev->driver->resume(cdev); 2624 2516 if (cdev->config) { 2625 2517 list_for_each_entry(f, &cdev->config->functions, list) { 2626 - if (f->resume) 2518 + /* 2519 + * Check for func_suspended flag to see if the function is 2520 + * in USB3 FUNCTION_SUSPEND state. In this case resume is 2521 + * done via FUNCTION_SUSPEND feature selector. 2522 + */ 2523 + if (f->resume && !f->func_suspended) 2627 2524 f->resume(f); 2628 2525 } 2629 2526 ··· 2642 2529 if (maxpower > USB_SELF_POWER_VBUS_MAX_DRAW) 2643 2530 usb_gadget_clear_selfpowered(gadget); 2644 2531 2532 + usb_gadget_vbus_draw(gadget, maxpower); 2533 + } else { 2534 + maxpower = CONFIG_USB_GADGET_VBUS_DRAW; 2535 + maxpower = min(maxpower, 100U); 2645 2536 usb_gadget_vbus_draw(gadget, maxpower); 2646 2537 } 2647 2538
+3
drivers/usb/gadget/configfs.c
··· 1761 1761 if (gadget_is_otg(gadget)) 1762 1762 c->descriptors = otg_desc; 1763 1763 1764 + /* Properly configure the bmAttributes wakeup bit */ 1765 + check_remote_wakeup_config(gadget, c); 1766 + 1764 1767 cfg = container_of(c, struct config_usb_cfg, c); 1765 1768 if (!list_empty(&cfg->string_list)) { 1766 1769 i = 0;
+22
drivers/usb/gadget/function/f_ecm.c
··· 885 885 return &opts->func_inst; 886 886 } 887 887 888 + static void ecm_suspend(struct usb_function *f) 889 + { 890 + struct f_ecm *ecm = func_to_ecm(f); 891 + struct usb_composite_dev *cdev = ecm->port.func.config->cdev; 892 + 893 + DBG(cdev, "ECM Suspend\n"); 894 + 895 + gether_suspend(&ecm->port); 896 + } 897 + 898 + static void ecm_resume(struct usb_function *f) 899 + { 900 + struct f_ecm *ecm = func_to_ecm(f); 901 + struct usb_composite_dev *cdev = ecm->port.func.config->cdev; 902 + 903 + DBG(cdev, "ECM Resume\n"); 904 + 905 + gether_resume(&ecm->port); 906 + } 907 + 888 908 static void ecm_free(struct usb_function *f) 889 909 { 890 910 struct f_ecm *ecm; ··· 972 952 ecm->port.func.setup = ecm_setup; 973 953 ecm->port.func.disable = ecm_disable; 974 954 ecm->port.func.free_func = ecm_free; 955 + ecm->port.func.suspend = ecm_suspend; 956 + ecm->port.func.resume = ecm_resume; 975 957 976 958 return &ecm->port.func; 977 959 }
+5 -96
drivers/usb/gadget/function/f_fs.c
··· 335 335 ssize_t ret; 336 336 char *data; 337 337 338 - ENTER(); 339 - 340 338 /* Fast check if setup was canceled */ 341 339 if (ffs_setup_state_clear_cancelled(ffs) == FFS_SETUP_CANCELLED) 342 340 return -EIDRM; ··· 510 512 size_t n; 511 513 int ret; 512 514 513 - ENTER(); 514 - 515 515 /* Fast check if setup was canceled */ 516 516 if (ffs_setup_state_clear_cancelled(ffs) == FFS_SETUP_CANCELLED) 517 517 return -EIDRM; ··· 608 612 { 609 613 struct ffs_data *ffs = inode->i_private; 610 614 611 - ENTER(); 612 - 613 615 if (ffs->state == FFS_CLOSING) 614 616 return -EBUSY; 615 617 ··· 621 627 { 622 628 struct ffs_data *ffs = file->private_data; 623 629 624 - ENTER(); 625 - 626 630 ffs_data_closed(ffs); 627 631 628 632 return 0; ··· 631 639 struct ffs_data *ffs = file->private_data; 632 640 struct usb_gadget *gadget = ffs->gadget; 633 641 long ret; 634 - 635 - ENTER(); 636 642 637 643 if (code == FUNCTIONFS_INTERFACE_REVMAP) { 638 644 struct ffs_function *func = ffs->func; ··· 705 715 { 706 716 struct ffs_io_data *io_data = req->context; 707 717 708 - ENTER(); 709 718 if (req->status) 710 719 io_data->status = req->status; 711 720 else ··· 844 855 { 845 856 struct ffs_io_data *io_data = req->context; 846 857 struct ffs_data *ffs = io_data->ffs; 847 - 848 - ENTER(); 849 858 850 859 io_data->status = req->status ? req->status : req->actual; 851 860 usb_ep_free_request(_ep, req); ··· 1148 1161 { 1149 1162 struct ffs_epfile *epfile = inode->i_private; 1150 1163 1151 - ENTER(); 1152 - 1153 1164 if (WARN_ON(epfile->ffs->state != FFS_ACTIVE)) 1154 1165 return -ENODEV; 1155 1166 ··· 1163 1178 struct ffs_epfile *epfile = kiocb->ki_filp->private_data; 1164 1179 unsigned long flags; 1165 1180 int value; 1166 - 1167 - ENTER(); 1168 1181 1169 1182 spin_lock_irqsave(&epfile->ffs->eps_lock, flags); 1170 1183 ··· 1180 1197 { 1181 1198 struct ffs_io_data io_data, *p = &io_data; 1182 1199 ssize_t res; 1183 - 1184 - ENTER(); 1185 1200 1186 1201 if (!is_sync_kiocb(kiocb)) { 1187 1202 p = kzalloc(sizeof(io_data), GFP_KERNEL); ··· 1215 1234 { 1216 1235 struct ffs_io_data io_data, *p = &io_data; 1217 1236 ssize_t res; 1218 - 1219 - ENTER(); 1220 1237 1221 1238 if (!is_sync_kiocb(kiocb)) { 1222 1239 p = kzalloc(sizeof(io_data), GFP_KERNEL); ··· 1263 1284 { 1264 1285 struct ffs_epfile *epfile = inode->i_private; 1265 1286 1266 - ENTER(); 1267 - 1268 1287 __ffs_epfile_read_buffer_free(epfile); 1269 1288 ffs_data_closed(epfile->ffs); 1270 1289 ··· 1275 1298 struct ffs_epfile *epfile = file->private_data; 1276 1299 struct ffs_ep *ep; 1277 1300 int ret; 1278 - 1279 - ENTER(); 1280 1301 1281 1302 if (WARN_ON(epfile->ffs->state != FFS_ACTIVE)) 1282 1303 return -ENODEV; ··· 1374 1399 { 1375 1400 struct inode *inode; 1376 1401 1377 - ENTER(); 1378 - 1379 1402 inode = new_inode(sb); 1380 1403 1381 1404 if (inode) { ··· 1404 1431 struct ffs_data *ffs = sb->s_fs_info; 1405 1432 struct dentry *dentry; 1406 1433 struct inode *inode; 1407 - 1408 - ENTER(); 1409 1434 1410 1435 dentry = d_alloc_name(sb->s_root, name); 1411 1436 if (!dentry) ··· 1438 1467 struct ffs_sb_fill_data *data = fc->fs_private; 1439 1468 struct inode *inode; 1440 1469 struct ffs_data *ffs = data->ffs_data; 1441 - 1442 - ENTER(); 1443 1470 1444 1471 ffs->sb = sb; 1445 1472 data->ffs_data = NULL; ··· 1490 1521 struct fs_parse_result result; 1491 1522 int opt; 1492 1523 1493 - ENTER(); 1494 - 1495 1524 opt = fs_parse(fc, ffs_fs_fs_parameters, param, &result); 1496 1525 if (opt < 0) 1497 1526 return opt; ··· 1538 1571 struct ffs_sb_fill_data *ctx = fc->fs_private; 1539 1572 struct ffs_data *ffs; 1540 1573 int ret; 1541 - 1542 - ENTER(); 1543 1574 1544 1575 if (!fc->source) 1545 1576 return invalf(fc, "No source specified"); ··· 1605 1640 static void 1606 1641 ffs_fs_kill_sb(struct super_block *sb) 1607 1642 { 1608 - ENTER(); 1609 - 1610 1643 kill_litter_super(sb); 1611 1644 if (sb->s_fs_info) 1612 1645 ffs_data_closed(sb->s_fs_info); ··· 1626 1663 { 1627 1664 int ret; 1628 1665 1629 - ENTER(); 1630 - 1631 1666 ret = register_filesystem(&ffs_fs_type); 1632 1667 if (!ret) 1633 1668 pr_info("file system registered\n"); ··· 1637 1676 1638 1677 static void functionfs_cleanup(void) 1639 1678 { 1640 - ENTER(); 1641 - 1642 1679 pr_info("unloading\n"); 1643 1680 unregister_filesystem(&ffs_fs_type); 1644 1681 } ··· 1649 1690 1650 1691 static void ffs_data_get(struct ffs_data *ffs) 1651 1692 { 1652 - ENTER(); 1653 - 1654 1693 refcount_inc(&ffs->ref); 1655 1694 } 1656 1695 1657 1696 static void ffs_data_opened(struct ffs_data *ffs) 1658 1697 { 1659 - ENTER(); 1660 - 1661 1698 refcount_inc(&ffs->ref); 1662 1699 if (atomic_add_return(1, &ffs->opened) == 1 && 1663 1700 ffs->state == FFS_DEACTIVATED) { ··· 1664 1709 1665 1710 static void ffs_data_put(struct ffs_data *ffs) 1666 1711 { 1667 - ENTER(); 1668 - 1669 1712 if (refcount_dec_and_test(&ffs->ref)) { 1670 1713 pr_info("%s(): freeing\n", __func__); 1671 1714 ffs_data_clear(ffs); ··· 1681 1728 { 1682 1729 struct ffs_epfile *epfiles; 1683 1730 unsigned long flags; 1684 - 1685 - ENTER(); 1686 1731 1687 1732 if (atomic_dec_and_test(&ffs->opened)) { 1688 1733 if (ffs->no_disconnect) { ··· 1716 1765 if (!ffs) 1717 1766 return NULL; 1718 1767 1719 - ENTER(); 1720 - 1721 1768 ffs->io_completion_wq = alloc_ordered_workqueue("%s", 0, dev_name); 1722 1769 if (!ffs->io_completion_wq) { 1723 1770 kfree(ffs); ··· 1741 1792 { 1742 1793 struct ffs_epfile *epfiles; 1743 1794 unsigned long flags; 1744 - 1745 - ENTER(); 1746 1795 1747 1796 ffs_closed(ffs); 1748 1797 ··· 1773 1826 1774 1827 static void ffs_data_reset(struct ffs_data *ffs) 1775 1828 { 1776 - ENTER(); 1777 - 1778 1829 ffs_data_clear(ffs); 1779 1830 1780 1831 ffs->raw_descs_data = NULL; ··· 1806 1861 struct usb_gadget_strings **lang; 1807 1862 int first_id; 1808 1863 1809 - ENTER(); 1810 - 1811 1864 if (WARN_ON(ffs->state != FFS_ACTIVE 1812 1865 || test_and_set_bit(FFS_FL_BOUND, &ffs->flags))) 1813 1866 return -EBADFD; ··· 1837 1894 1838 1895 static void functionfs_unbind(struct ffs_data *ffs) 1839 1896 { 1840 - ENTER(); 1841 - 1842 1897 if (!WARN_ON(!ffs->gadget)) { 1843 1898 /* dequeue before freeing ep0req */ 1844 1899 usb_ep_dequeue(ffs->gadget->ep0, ffs->ep0req); ··· 1854 1913 { 1855 1914 struct ffs_epfile *epfile, *epfiles; 1856 1915 unsigned i, count; 1857 - 1858 - ENTER(); 1859 1916 1860 1917 count = ffs->eps_count; 1861 1918 epfiles = kcalloc(count, sizeof(*epfiles), GFP_KERNEL); ··· 1884 1945 static void ffs_epfiles_destroy(struct ffs_epfile *epfiles, unsigned count) 1885 1946 { 1886 1947 struct ffs_epfile *epfile = epfiles; 1887 - 1888 - ENTER(); 1889 1948 1890 1949 for (; count; --count, ++epfile) { 1891 1950 BUG_ON(mutex_is_locked(&epfile->mutex)); ··· 2000 2063 struct usb_descriptor_header *_ds = (void *)data; 2001 2064 u8 length; 2002 2065 int ret; 2003 - 2004 - ENTER(); 2005 2066 2006 2067 /* At least two bytes are required: length and type */ 2007 2068 if (len < 2) { ··· 2139 2204 unsigned long num = 0; 2140 2205 int current_class = -1; 2141 2206 2142 - ENTER(); 2143 - 2144 2207 for (;;) { 2145 2208 int ret; 2146 2209 ··· 2175 2242 { 2176 2243 struct ffs_desc_helper *helper = priv; 2177 2244 struct usb_endpoint_descriptor *d; 2178 - 2179 - ENTER(); 2180 2245 2181 2246 switch (type) { 2182 2247 case FFS_DESCRIPTOR: ··· 2223 2292 u16 bcd_version = le16_to_cpu(desc->bcdVersion); 2224 2293 u16 w_index = le16_to_cpu(desc->wIndex); 2225 2294 2226 - if (bcd_version != 1) { 2227 - pr_vdebug("unsupported os descriptors version: %d", 2295 + if (bcd_version == 0x1) { 2296 + pr_warn("bcdVersion must be 0x0100, stored in Little Endian order. " 2297 + "Userspace driver should be fixed, accepting 0x0001 for compatibility.\n"); 2298 + } else if (bcd_version != 0x100) { 2299 + pr_vdebug("unsupported os descriptors version: 0x%x\n", 2228 2300 bcd_version); 2229 2301 return -EINVAL; 2230 2302 } ··· 2260 2326 int ret; 2261 2327 const unsigned _len = len; 2262 2328 2263 - ENTER(); 2264 - 2265 2329 /* loop over all ext compat/ext prop descriptors */ 2266 2330 while (feature_count--) { 2267 2331 ret = entity(type, h, data, len, priv); ··· 2280 2348 { 2281 2349 const unsigned _len = len; 2282 2350 unsigned long num = 0; 2283 - 2284 - ENTER(); 2285 2351 2286 2352 for (num = 0; num < count; ++num) { 2287 2353 int ret; ··· 2342 2412 { 2343 2413 struct ffs_data *ffs = priv; 2344 2414 u8 length; 2345 - 2346 - ENTER(); 2347 2415 2348 2416 switch (type) { 2349 2417 case FFS_OS_DESC_EXT_COMPAT: { ··· 2417 2489 unsigned os_descs_count = 0, counts[3], flags; 2418 2490 int ret = -EINVAL, i; 2419 2491 struct ffs_desc_helper helper; 2420 - 2421 - ENTER(); 2422 2492 2423 2493 if (get_unaligned_le32(data + 4) != len) 2424 2494 goto error; ··· 2547 2621 struct usb_gadget_strings **stringtabs, *t; 2548 2622 const char *data = _data; 2549 2623 struct usb_string *s; 2550 - 2551 - ENTER(); 2552 2624 2553 2625 if (len < 16 || 2554 2626 get_unaligned_le32(data) != FUNCTIONFS_STRINGS_MAGIC || ··· 3006 3082 struct ffs_data *ffs_data; 3007 3083 int ret; 3008 3084 3009 - ENTER(); 3010 - 3011 3085 /* 3012 3086 * Legacy gadget triggers binding in functionfs_ready_callback, 3013 3087 * which already uses locking; taking the same lock here would ··· 3081 3159 ffs->ms_os_descs_ext_prop_data_len); 3082 3160 vla_item_with_sz(d, char, raw_descs, ffs->raw_descs_length); 3083 3161 char *vlabuf; 3084 - 3085 - ENTER(); 3086 3162 3087 3163 /* Has descriptors only for speeds gadget does not support */ 3088 3164 if (!(full | high | super)) ··· 3285 3365 unsigned long flags; 3286 3366 int ret; 3287 3367 3288 - ENTER(); 3289 - 3290 3368 pr_vdebug("creq->bRequestType = %02x\n", creq->bRequestType); 3291 3369 pr_vdebug("creq->bRequest = %02x\n", creq->bRequest); 3292 3370 pr_vdebug("creq->wValue = %04x\n", le16_to_cpu(creq->wValue)); ··· 3359 3441 3360 3442 static void ffs_func_suspend(struct usb_function *f) 3361 3443 { 3362 - ENTER(); 3363 3444 ffs_event_add(ffs_func_from_usb(f)->ffs, FUNCTIONFS_SUSPEND); 3364 3445 } 3365 3446 3366 3447 static void ffs_func_resume(struct usb_function *f) 3367 3448 { 3368 - ENTER(); 3369 3449 ffs_event_add(ffs_func_from_usb(f)->ffs, FUNCTIONFS_RESUME); 3370 3450 } 3371 3451 ··· 3527 3611 unsigned count = ffs->eps_count; 3528 3612 unsigned long flags; 3529 3613 3530 - ENTER(); 3531 3614 if (ffs->func == func) { 3532 3615 ffs_func_eps_disable(func); 3533 3616 ffs->func = NULL; ··· 3565 3650 static struct usb_function *ffs_alloc(struct usb_function_instance *fi) 3566 3651 { 3567 3652 struct ffs_function *func; 3568 - 3569 - ENTER(); 3570 3653 3571 3654 func = kzalloc(sizeof(*func), GFP_KERNEL); 3572 3655 if (!func) ··· 3666 3753 int ret = 0; 3667 3754 struct ffs_dev *ffs_dev; 3668 3755 3669 - ENTER(); 3670 3756 ffs_dev_lock(); 3671 3757 3672 3758 ffs_dev = _ffs_find_dev(dev_name); ··· 3688 3776 3689 3777 static void ffs_release_dev(struct ffs_dev *ffs_dev) 3690 3778 { 3691 - ENTER(); 3692 3779 ffs_dev_lock(); 3693 3780 3694 3781 if (ffs_dev && ffs_dev->mounted) { ··· 3709 3798 struct ffs_dev *ffs_obj; 3710 3799 int ret = 0; 3711 3800 3712 - ENTER(); 3713 3801 ffs_dev_lock(); 3714 3802 3715 3803 ffs_obj = ffs->private_data; ··· 3741 3831 struct f_fs_opts *opts; 3742 3832 struct config_item *ci; 3743 3833 3744 - ENTER(); 3745 3834 ffs_dev_lock(); 3746 3835 3747 3836 ffs_obj = ffs->private_data;
+63
drivers/usb/gadget/function/u_ether.c
··· 437 437 return cdc_filter & USB_CDC_PACKET_TYPE_PROMISCUOUS; 438 438 } 439 439 440 + static int ether_wakeup_host(struct gether *port) 441 + { 442 + int ret; 443 + struct usb_function *func = &port->func; 444 + struct usb_gadget *gadget = func->config->cdev->gadget; 445 + 446 + if (func->func_suspended) 447 + ret = usb_func_wakeup(func); 448 + else 449 + ret = usb_gadget_wakeup(gadget); 450 + 451 + return ret; 452 + } 453 + 440 454 static netdev_tx_t eth_start_xmit(struct sk_buff *skb, 441 455 struct net_device *net) 442 456 { ··· 470 456 in = NULL; 471 457 cdc_filter = 0; 472 458 } 459 + 460 + if (dev->port_usb && dev->port_usb->is_suspend) { 461 + DBG(dev, "Port suspended. Triggering wakeup\n"); 462 + netif_stop_queue(net); 463 + spin_unlock_irqrestore(&dev->lock, flags); 464 + ether_wakeup_host(dev->port_usb); 465 + return NETDEV_TX_BUSY; 466 + } 467 + 473 468 spin_unlock_irqrestore(&dev->lock, flags); 474 469 475 470 if (!in) { ··· 1037 1014 } 1038 1015 EXPORT_SYMBOL_GPL(gether_set_ifname); 1039 1016 1017 + void gether_suspend(struct gether *link) 1018 + { 1019 + struct eth_dev *dev = link->ioport; 1020 + unsigned long flags; 1021 + 1022 + if (!dev) 1023 + return; 1024 + 1025 + if (atomic_read(&dev->tx_qlen)) { 1026 + /* 1027 + * There is a transfer in progress. So we trigger a remote 1028 + * wakeup to inform the host. 1029 + */ 1030 + ether_wakeup_host(dev->port_usb); 1031 + return; 1032 + } 1033 + spin_lock_irqsave(&dev->lock, flags); 1034 + link->is_suspend = true; 1035 + spin_unlock_irqrestore(&dev->lock, flags); 1036 + } 1037 + EXPORT_SYMBOL_GPL(gether_suspend); 1038 + 1039 + void gether_resume(struct gether *link) 1040 + { 1041 + struct eth_dev *dev = link->ioport; 1042 + unsigned long flags; 1043 + 1044 + if (!dev) 1045 + return; 1046 + 1047 + if (netif_queue_stopped(dev->net)) 1048 + netif_start_queue(dev->net); 1049 + 1050 + spin_lock_irqsave(&dev->lock, flags); 1051 + link->is_suspend = false; 1052 + spin_unlock_irqrestore(&dev->lock, flags); 1053 + } 1054 + EXPORT_SYMBOL_GPL(gether_resume); 1055 + 1040 1056 /* 1041 1057 * gether_cleanup - remove Ethernet-over-USB device 1042 1058 * Context: may sleep ··· 1238 1176 1239 1177 spin_lock(&dev->lock); 1240 1178 dev->port_usb = NULL; 1179 + link->is_suspend = false; 1241 1180 spin_unlock(&dev->lock); 1242 1181 } 1243 1182 EXPORT_SYMBOL_GPL(gether_disconnect);
+4
drivers/usb/gadget/function/u_ether.h
··· 79 79 /* called on network open/close */ 80 80 void (*open)(struct gether *); 81 81 void (*close)(struct gether *); 82 + bool is_suspend; 82 83 }; 83 84 84 85 #define DEFAULT_FILTER (USB_CDC_PACKET_TYPE_BROADCAST \ ··· 258 257 int gether_set_ifname(struct net_device *net, const char *name, int len); 259 258 260 259 void gether_cleanup(struct eth_dev *dev); 260 + 261 + void gether_suspend(struct gether *link); 262 + void gether_resume(struct gether *link); 261 263 262 264 /* connect/disconnect is handled by individual functions */ 263 265 struct net_device *gether_connect(struct gether *);
-2
drivers/usb/gadget/function/u_fs.h
··· 32 32 # define ffs_dump_mem(prefix, ptr, len) do { } while (0) 33 33 #endif /* VERBOSE_DEBUG */ 34 34 35 - #define ENTER() pr_vdebug("%s()\n", __func__) 36 - 37 35 struct f_fs_opts; 38 36 39 37 struct ffs_dev {
+119 -2
drivers/usb/gadget/function/uvc_configfs.c
··· 334 334 335 335 #undef UVCG_DEFAULT_PROCESSING_ATTR 336 336 337 + static ssize_t uvcg_default_processing_bm_controls_store( 338 + struct config_item *item, const char *page, size_t len) 339 + { 340 + struct config_group *group = to_config_group(item); 341 + struct mutex *su_mutex = &group->cg_subsys->su_mutex; 342 + struct uvc_processing_unit_descriptor *pd; 343 + struct config_item *opts_item; 344 + struct f_uvc_opts *opts; 345 + u8 *bm_controls, *tmp; 346 + unsigned int i; 347 + int ret, n = 0; 348 + 349 + mutex_lock(su_mutex); 350 + 351 + opts_item = group->cg_item.ci_parent->ci_parent->ci_parent; 352 + opts = to_f_uvc_opts(opts_item); 353 + pd = &opts->uvc_processing; 354 + 355 + mutex_lock(&opts->lock); 356 + if (opts->refcnt) { 357 + ret = -EBUSY; 358 + goto unlock; 359 + } 360 + 361 + ret = __uvcg_iter_item_entries(page, len, __uvcg_count_item_entries, &n, 362 + sizeof(u8)); 363 + if (ret) 364 + goto unlock; 365 + 366 + if (n > pd->bControlSize) { 367 + ret = -EINVAL; 368 + goto unlock; 369 + } 370 + 371 + tmp = bm_controls = kcalloc(n, sizeof(u8), GFP_KERNEL); 372 + if (!bm_controls) { 373 + ret = -ENOMEM; 374 + goto unlock; 375 + } 376 + 377 + ret = __uvcg_iter_item_entries(page, len, __uvcg_fill_item_entries, &tmp, 378 + sizeof(u8)); 379 + if (ret) 380 + goto free_mem; 381 + 382 + for (i = 0; i < n; i++) 383 + pd->bmControls[i] = bm_controls[i]; 384 + 385 + ret = len; 386 + 387 + free_mem: 388 + kfree(bm_controls); 389 + unlock: 390 + mutex_unlock(&opts->lock); 391 + mutex_unlock(su_mutex); 392 + return ret; 393 + } 394 + 337 395 static ssize_t uvcg_default_processing_bm_controls_show( 338 396 struct config_item *item, char *page) 339 397 { ··· 421 363 return result; 422 364 } 423 365 424 - UVC_ATTR_RO(uvcg_default_processing_, bm_controls, bmControls); 366 + UVC_ATTR(uvcg_default_processing_, bm_controls, bmControls); 425 367 426 368 static struct configfs_attribute *uvcg_default_processing_attrs[] = { 427 369 &uvcg_default_processing_attr_b_unit_id, ··· 503 445 504 446 #undef UVCG_DEFAULT_CAMERA_ATTR 505 447 448 + static ssize_t uvcg_default_camera_bm_controls_store( 449 + struct config_item *item, const char *page, size_t len) 450 + { 451 + struct config_group *group = to_config_group(item); 452 + struct mutex *su_mutex = &group->cg_subsys->su_mutex; 453 + struct uvc_camera_terminal_descriptor *cd; 454 + struct config_item *opts_item; 455 + struct f_uvc_opts *opts; 456 + u8 *bm_controls, *tmp; 457 + unsigned int i; 458 + int ret, n = 0; 459 + 460 + mutex_lock(su_mutex); 461 + 462 + opts_item = group->cg_item.ci_parent->ci_parent->ci_parent-> 463 + ci_parent; 464 + opts = to_f_uvc_opts(opts_item); 465 + cd = &opts->uvc_camera_terminal; 466 + 467 + mutex_lock(&opts->lock); 468 + if (opts->refcnt) { 469 + ret = -EBUSY; 470 + goto unlock; 471 + } 472 + 473 + ret = __uvcg_iter_item_entries(page, len, __uvcg_count_item_entries, &n, 474 + sizeof(u8)); 475 + if (ret) 476 + goto unlock; 477 + 478 + if (n > cd->bControlSize) { 479 + ret = -EINVAL; 480 + goto unlock; 481 + } 482 + 483 + tmp = bm_controls = kcalloc(n, sizeof(u8), GFP_KERNEL); 484 + if (!bm_controls) { 485 + ret = -ENOMEM; 486 + goto unlock; 487 + } 488 + 489 + ret = __uvcg_iter_item_entries(page, len, __uvcg_fill_item_entries, &tmp, 490 + sizeof(u8)); 491 + if (ret) 492 + goto free_mem; 493 + 494 + for (i = 0; i < n; i++) 495 + cd->bmControls[i] = bm_controls[i]; 496 + 497 + ret = len; 498 + 499 + free_mem: 500 + kfree(bm_controls); 501 + unlock: 502 + mutex_unlock(&opts->lock); 503 + mutex_unlock(su_mutex); 504 + return ret; 505 + } 506 + 506 507 static ssize_t uvcg_default_camera_bm_controls_show( 507 508 struct config_item *item, char *page) 508 509 { ··· 591 474 return result; 592 475 } 593 476 594 - UVC_ATTR_RO(uvcg_default_camera_, bm_controls, bmControls); 477 + UVC_ATTR(uvcg_default_camera_, bm_controls, bmControls); 595 478 596 479 static struct configfs_attribute *uvcg_default_camera_attrs[] = { 597 480 &uvcg_default_camera_attr_b_terminal_id,
-9
drivers/usb/gadget/legacy/g_ffs.c
··· 180 180 int i; 181 181 int ret = 0; 182 182 183 - ENTER(); 184 - 185 183 if (func_num < 2) { 186 184 gfs_single_func = true; 187 185 func_num = 1; ··· 239 241 static void __exit gfs_exit(void) 240 242 { 241 243 int i; 242 - 243 - ENTER(); 244 244 245 245 if (gfs_registered) 246 246 usb_composite_unregister(&gfs_driver); ··· 311 315 struct net_device *net; 312 316 #endif 313 317 int ret, i; 314 - 315 - ENTER(); 316 318 317 319 if (missing_funcs) 318 320 return -ENODEV; ··· 438 444 static int gfs_unbind(struct usb_composite_dev *cdev) 439 445 { 440 446 int i; 441 - 442 - ENTER(); 443 - 444 447 445 448 #ifdef CONFIG_USB_FUNCTIONFS_RNDIS 446 449 usb_put_function(f_rndis);
-1
drivers/usb/gadget/udc/aspeed-vhub/core.c
··· 21 21 #include <linux/clk.h> 22 22 #include <linux/usb/gadget.h> 23 23 #include <linux/of.h> 24 - #include <linux/of_gpio.h> 25 24 #include <linux/regmap.h> 26 25 #include <linux/dma-mapping.h> 27 26
-1
drivers/usb/gadget/udc/aspeed-vhub/dev.c
··· 21 21 #include <linux/clk.h> 22 22 #include <linux/usb/gadget.h> 23 23 #include <linux/of.h> 24 - #include <linux/of_gpio.h> 25 24 #include <linux/regmap.h> 26 25 #include <linux/dma-mapping.h> 27 26 #include <linux/usb.h>
-1
drivers/usb/gadget/udc/aspeed-vhub/ep0.c
··· 21 21 #include <linux/clk.h> 22 22 #include <linux/usb/gadget.h> 23 23 #include <linux/of.h> 24 - #include <linux/of_gpio.h> 25 24 #include <linux/regmap.h> 26 25 #include <linux/dma-mapping.h> 27 26
-1
drivers/usb/gadget/udc/aspeed-vhub/epn.c
··· 21 21 #include <linux/clk.h> 22 22 #include <linux/usb/gadget.h> 23 23 #include <linux/of.h> 24 - #include <linux/of_gpio.h> 25 24 #include <linux/regmap.h> 26 25 #include <linux/dma-mapping.h> 27 26
-1
drivers/usb/gadget/udc/aspeed-vhub/hub.c
··· 21 21 #include <linux/clk.h> 22 22 #include <linux/usb/gadget.h> 23 23 #include <linux/of.h> 24 - #include <linux/of_gpio.h> 25 24 #include <linux/regmap.h> 26 25 #include <linux/dma-mapping.h> 27 26 #include <linux/bcd.h>
+134 -44
drivers/usb/gadget/udc/core.c
··· 37 37 * @vbus: for udcs who care about vbus status, this value is real vbus status; 38 38 * for udcs who do not care about vbus status, this value is always true 39 39 * @started: the UDC's started state. True if the UDC had started. 40 + * @connect_lock: protects udc->vbus, udc->started, gadget->connect, gadget->deactivate related 41 + * functions. usb_gadget_connect_locked, usb_gadget_disconnect_locked, 42 + * usb_udc_connect_control_locked, usb_gadget_udc_start_locked, usb_gadget_udc_stop_locked are 43 + * called with this lock held. 40 44 * 41 45 * This represents the internal data structure which is used by the UDC-class 42 46 * to hold information about udc driver and gadget together. ··· 52 48 struct list_head list; 53 49 bool vbus; 54 50 bool started; 51 + struct mutex connect_lock; 55 52 }; 56 53 57 54 static struct class *udc_class; ··· 519 514 EXPORT_SYMBOL_GPL(usb_gadget_wakeup); 520 515 521 516 /** 517 + * usb_gadget_set_remote_wakeup - configures the device remote wakeup feature. 518 + * @gadget:the device being configured for remote wakeup 519 + * @set:value to be configured. 520 + * 521 + * set to one to enable remote wakeup feature and zero to disable it. 522 + * 523 + * returns zero on success, else negative errno. 524 + */ 525 + int usb_gadget_set_remote_wakeup(struct usb_gadget *gadget, int set) 526 + { 527 + int ret = 0; 528 + 529 + if (!gadget->ops->set_remote_wakeup) { 530 + ret = -EOPNOTSUPP; 531 + goto out; 532 + } 533 + 534 + ret = gadget->ops->set_remote_wakeup(gadget, set); 535 + 536 + out: 537 + trace_usb_gadget_set_remote_wakeup(gadget, ret); 538 + 539 + return ret; 540 + } 541 + EXPORT_SYMBOL_GPL(usb_gadget_set_remote_wakeup); 542 + 543 + /** 522 544 * usb_gadget_set_selfpowered - sets the device selfpowered feature. 523 545 * @gadget:the device being declared as self-powered 524 546 * ··· 692 660 } 693 661 EXPORT_SYMBOL_GPL(usb_gadget_vbus_disconnect); 694 662 695 - /** 696 - * usb_gadget_connect - software-controlled connect to USB host 697 - * @gadget:the peripheral being connected 698 - * 699 - * Enables the D+ (or potentially D-) pullup. The host will start 700 - * enumerating this gadget when the pullup is active and a VBUS session 701 - * is active (the link is powered). 702 - * 703 - * Returns zero on success, else negative errno. 704 - */ 705 - int usb_gadget_connect(struct usb_gadget *gadget) 663 + /* Internal version of usb_gadget_connect needs to be called with connect_lock held. */ 664 + static int usb_gadget_connect_locked(struct usb_gadget *gadget) 665 + __must_hold(&gadget->udc->connect_lock) 706 666 { 707 667 int ret = 0; 708 668 ··· 703 679 goto out; 704 680 } 705 681 706 - if (gadget->deactivated) { 682 + if (gadget->connected) 683 + goto out; 684 + 685 + if (gadget->deactivated || !gadget->udc->started) { 707 686 /* 708 687 * If gadget is deactivated we only save new state. 709 688 * Gadget will be connected automatically after activation. 689 + * 690 + * udc first needs to be started before gadget can be pulled up. 710 691 */ 711 692 gadget->connected = true; 712 693 goto out; ··· 726 697 727 698 return ret; 728 699 } 729 - EXPORT_SYMBOL_GPL(usb_gadget_connect); 730 700 731 701 /** 732 - * usb_gadget_disconnect - software-controlled disconnect from USB host 733 - * @gadget:the peripheral being disconnected 702 + * usb_gadget_connect - software-controlled connect to USB host 703 + * @gadget:the peripheral being connected 734 704 * 735 - * Disables the D+ (or potentially D-) pullup, which the host may see 736 - * as a disconnect (when a VBUS session is active). Not all systems 737 - * support software pullup controls. 738 - * 739 - * Following a successful disconnect, invoke the ->disconnect() callback 740 - * for the current gadget driver so that UDC drivers don't need to. 705 + * Enables the D+ (or potentially D-) pullup. The host will start 706 + * enumerating this gadget when the pullup is active and a VBUS session 707 + * is active (the link is powered). 741 708 * 742 709 * Returns zero on success, else negative errno. 743 710 */ 744 - int usb_gadget_disconnect(struct usb_gadget *gadget) 711 + int usb_gadget_connect(struct usb_gadget *gadget) 712 + { 713 + int ret; 714 + 715 + mutex_lock(&gadget->udc->connect_lock); 716 + ret = usb_gadget_connect_locked(gadget); 717 + mutex_unlock(&gadget->udc->connect_lock); 718 + 719 + return ret; 720 + } 721 + EXPORT_SYMBOL_GPL(usb_gadget_connect); 722 + 723 + /* Internal version of usb_gadget_disconnect needs to be called with connect_lock held. */ 724 + static int usb_gadget_disconnect_locked(struct usb_gadget *gadget) 725 + __must_hold(&gadget->udc->connect_lock) 745 726 { 746 727 int ret = 0; 747 728 ··· 763 724 if (!gadget->connected) 764 725 goto out; 765 726 766 - if (gadget->deactivated) { 727 + if (gadget->deactivated || !gadget->udc->started) { 767 728 /* 768 729 * If gadget is deactivated we only save new state. 769 730 * Gadget will stay disconnected after activation. 731 + * 732 + * udc should have been started before gadget being pulled down. 770 733 */ 771 734 gadget->connected = false; 772 735 goto out; ··· 785 744 786 745 out: 787 746 trace_usb_gadget_disconnect(gadget, ret); 747 + 748 + return ret; 749 + } 750 + 751 + /** 752 + * usb_gadget_disconnect - software-controlled disconnect from USB host 753 + * @gadget:the peripheral being disconnected 754 + * 755 + * Disables the D+ (or potentially D-) pullup, which the host may see 756 + * as a disconnect (when a VBUS session is active). Not all systems 757 + * support software pullup controls. 758 + * 759 + * Following a successful disconnect, invoke the ->disconnect() callback 760 + * for the current gadget driver so that UDC drivers don't need to. 761 + * 762 + * Returns zero on success, else negative errno. 763 + */ 764 + int usb_gadget_disconnect(struct usb_gadget *gadget) 765 + { 766 + int ret; 767 + 768 + mutex_lock(&gadget->udc->connect_lock); 769 + ret = usb_gadget_disconnect_locked(gadget); 770 + mutex_unlock(&gadget->udc->connect_lock); 788 771 789 772 return ret; 790 773 } ··· 832 767 if (gadget->deactivated) 833 768 goto out; 834 769 770 + mutex_lock(&gadget->udc->connect_lock); 835 771 if (gadget->connected) { 836 - ret = usb_gadget_disconnect(gadget); 772 + ret = usb_gadget_disconnect_locked(gadget); 837 773 if (ret) 838 - goto out; 774 + goto unlock; 839 775 840 776 /* 841 777 * If gadget was being connected before deactivation, we want ··· 846 780 } 847 781 gadget->deactivated = true; 848 782 783 + unlock: 784 + mutex_unlock(&gadget->udc->connect_lock); 849 785 out: 850 786 trace_usb_gadget_deactivate(gadget, ret); 851 787 ··· 871 803 if (!gadget->deactivated) 872 804 goto out; 873 805 806 + mutex_lock(&gadget->udc->connect_lock); 874 807 gadget->deactivated = false; 875 808 876 809 /* ··· 879 810 * while it was being deactivated, we call usb_gadget_connect(). 880 811 */ 881 812 if (gadget->connected) 882 - ret = usb_gadget_connect(gadget); 813 + ret = usb_gadget_connect_locked(gadget); 814 + mutex_unlock(&gadget->udc->connect_lock); 883 815 884 816 out: 885 817 trace_usb_gadget_activate(gadget, ret); ··· 1121 1051 1122 1052 /* ------------------------------------------------------------------------- */ 1123 1053 1124 - static void usb_udc_connect_control(struct usb_udc *udc) 1054 + /* Acquire connect_lock before calling this function. */ 1055 + static void usb_udc_connect_control_locked(struct usb_udc *udc) __must_hold(&udc->connect_lock) 1125 1056 { 1126 - if (udc->vbus) 1127 - usb_gadget_connect(udc->gadget); 1057 + if (udc->vbus && udc->started) 1058 + usb_gadget_connect_locked(udc->gadget); 1128 1059 else 1129 - usb_gadget_disconnect(udc->gadget); 1060 + usb_gadget_disconnect_locked(udc->gadget); 1130 1061 } 1131 1062 1132 1063 /** ··· 1143 1072 { 1144 1073 struct usb_udc *udc = gadget->udc; 1145 1074 1075 + mutex_lock(&udc->connect_lock); 1146 1076 if (udc) { 1147 1077 udc->vbus = status; 1148 - usb_udc_connect_control(udc); 1078 + usb_udc_connect_control_locked(udc); 1149 1079 } 1080 + mutex_unlock(&udc->connect_lock); 1150 1081 } 1151 1082 EXPORT_SYMBOL_GPL(usb_udc_vbus_handler); 1152 1083 ··· 1170 1097 EXPORT_SYMBOL_GPL(usb_gadget_udc_reset); 1171 1098 1172 1099 /** 1173 - * usb_gadget_udc_start - tells usb device controller to start up 1100 + * usb_gadget_udc_start_locked - tells usb device controller to start up 1174 1101 * @udc: The UDC to be started 1175 1102 * 1176 1103 * This call is issued by the UDC Class driver when it's about ··· 1181 1108 * necessary to have it powered on. 1182 1109 * 1183 1110 * Returns zero on success, else negative errno. 1111 + * 1112 + * Caller should acquire connect_lock before invoking this function. 1184 1113 */ 1185 - static inline int usb_gadget_udc_start(struct usb_udc *udc) 1114 + static inline int usb_gadget_udc_start_locked(struct usb_udc *udc) 1115 + __must_hold(&udc->connect_lock) 1186 1116 { 1187 1117 int ret; 1188 1118 ··· 1202 1126 } 1203 1127 1204 1128 /** 1205 - * usb_gadget_udc_stop - tells usb device controller we don't need it anymore 1129 + * usb_gadget_udc_stop_locked - tells usb device controller we don't need it anymore 1206 1130 * @udc: The UDC to be stopped 1207 1131 * 1208 1132 * This call is issued by the UDC Class driver after calling ··· 1211 1135 * The details are implementation specific, but it can go as 1212 1136 * far as powering off UDC completely and disable its data 1213 1137 * line pullups. 1138 + * 1139 + * Caller should acquire connect lock before invoking this function. 1214 1140 */ 1215 - static inline void usb_gadget_udc_stop(struct usb_udc *udc) 1141 + static inline void usb_gadget_udc_stop_locked(struct usb_udc *udc) 1142 + __must_hold(&udc->connect_lock) 1216 1143 { 1217 1144 if (!udc->started) { 1218 1145 dev_err(&udc->dev, "UDC had already stopped\n"); ··· 1374 1295 1375 1296 udc->gadget = gadget; 1376 1297 gadget->udc = udc; 1298 + mutex_init(&udc->connect_lock); 1377 1299 1378 1300 udc->started = false; 1379 1301 ··· 1576 1496 if (ret) 1577 1497 goto err_bind; 1578 1498 1579 - ret = usb_gadget_udc_start(udc); 1580 - if (ret) 1499 + mutex_lock(&udc->connect_lock); 1500 + ret = usb_gadget_udc_start_locked(udc); 1501 + if (ret) { 1502 + mutex_unlock(&udc->connect_lock); 1581 1503 goto err_start; 1504 + } 1582 1505 usb_gadget_enable_async_callbacks(udc); 1583 - usb_udc_connect_control(udc); 1506 + usb_udc_connect_control_locked(udc); 1507 + mutex_unlock(&udc->connect_lock); 1584 1508 1585 1509 kobject_uevent(&udc->dev.kobj, KOBJ_CHANGE); 1586 1510 return 0; ··· 1615 1531 1616 1532 kobject_uevent(&udc->dev.kobj, KOBJ_CHANGE); 1617 1533 1618 - usb_gadget_disconnect(gadget); 1534 + mutex_lock(&udc->connect_lock); 1535 + usb_gadget_disconnect_locked(gadget); 1619 1536 usb_gadget_disable_async_callbacks(udc); 1620 1537 if (gadget->irq) 1621 1538 synchronize_irq(gadget->irq); 1622 1539 udc->driver->unbind(gadget); 1623 - usb_gadget_udc_stop(udc); 1540 + usb_gadget_udc_stop_locked(udc); 1541 + mutex_unlock(&udc->connect_lock); 1624 1542 1625 1543 mutex_lock(&udc_lock); 1626 1544 driver->is_bound = false; ··· 1708 1622 } 1709 1623 1710 1624 if (sysfs_streq(buf, "connect")) { 1711 - usb_gadget_udc_start(udc); 1712 - usb_gadget_connect(udc->gadget); 1625 + mutex_lock(&udc->connect_lock); 1626 + usb_gadget_udc_start_locked(udc); 1627 + usb_gadget_connect_locked(udc->gadget); 1628 + mutex_unlock(&udc->connect_lock); 1713 1629 } else if (sysfs_streq(buf, "disconnect")) { 1714 - usb_gadget_disconnect(udc->gadget); 1715 - usb_gadget_udc_stop(udc); 1630 + mutex_lock(&udc->connect_lock); 1631 + usb_gadget_disconnect_locked(udc->gadget); 1632 + usb_gadget_udc_stop_locked(udc); 1633 + mutex_unlock(&udc->connect_lock); 1716 1634 } else { 1717 1635 dev_err(dev, "unsupported command '%s'\n", buf); 1718 1636 ret = -EINVAL;
+1 -1
drivers/usb/gadget/udc/max3420_udc.c
··· 1319 1319 static struct spi_driver max3420_driver = { 1320 1320 .driver = { 1321 1321 .name = "max3420-udc", 1322 - .of_match_table = of_match_ptr(max3420_udc_of_match), 1322 + .of_match_table = max3420_udc_of_match, 1323 1323 }, 1324 1324 .probe = max3420_probe, 1325 1325 .remove = max3420_remove,
+5 -1
drivers/usb/gadget/udc/mv_udc_core.c
··· 2229 2229 INIT_LIST_HEAD(&udc->status_req->queue); 2230 2230 2231 2231 /* allocate a small amount of memory to get valid address */ 2232 - udc->status_req->req.buf = kzalloc(8, GFP_KERNEL); 2232 + udc->status_req->req.buf = devm_kzalloc(&pdev->dev, 8, GFP_KERNEL); 2233 + if (!udc->status_req->req.buf) { 2234 + retval = -ENOMEM; 2235 + goto err_destroy_dma; 2236 + } 2233 2237 udc->status_req->req.dma = DMA_ADDR_INVALID; 2234 2238 2235 2239 udc->resume_state = USB_STATE_NOTATTACHED;
+3 -23
drivers/usb/gadget/udc/renesas_usb3.c
··· 22 22 #include <linux/sizes.h> 23 23 #include <linux/slab.h> 24 24 #include <linux/string.h> 25 - #include <linux/sys_soc.h> 26 25 #include <linux/uaccess.h> 27 26 #include <linux/usb/ch9.h> 28 27 #include <linux/usb/gadget.h> ··· 2660 2661 debugfs_remove_recursive(usb3->dentry); 2661 2662 device_remove_file(&pdev->dev, &dev_attr_role); 2662 2663 2664 + cancel_work_sync(&usb3->role_work); 2663 2665 usb_role_switch_unregister(usb3->role_sw); 2664 2666 2665 2667 usb_del_gadget_udc(&usb3->gadget); ··· 2781 2781 } 2782 2782 } 2783 2783 2784 - static const struct renesas_usb3_priv renesas_usb3_priv_r8a7795_es1 = { 2785 - .ramsize_per_ramif = SZ_16K, 2786 - .num_ramif = 2, 2787 - .ramsize_per_pipe = SZ_4K, 2788 - .workaround_for_vbus = true, 2789 - }; 2790 - 2791 2784 static const struct renesas_usb3_priv renesas_usb3_priv_gen3 = { 2792 2785 .ramsize_per_ramif = SZ_16K, 2793 2786 .num_ramif = 4, ··· 2822 2829 }; 2823 2830 MODULE_DEVICE_TABLE(of, usb3_of_match); 2824 2831 2825 - static const struct soc_device_attribute renesas_usb3_quirks_match[] = { 2826 - { 2827 - .soc_id = "r8a7795", .revision = "ES1.*", 2828 - .data = &renesas_usb3_priv_r8a7795_es1, 2829 - }, 2830 - { /* sentinel */ } 2831 - }; 2832 - 2833 2832 static const unsigned int renesas_usb3_cable[] = { 2834 2833 EXTCON_USB, 2835 2834 EXTCON_USB_HOST, ··· 2839 2854 struct renesas_usb3 *usb3; 2840 2855 int irq, ret; 2841 2856 const struct renesas_usb3_priv *priv; 2842 - const struct soc_device_attribute *attr; 2843 2857 2844 - attr = soc_device_match(renesas_usb3_quirks_match); 2845 - if (attr) 2846 - priv = attr->data; 2847 - else 2848 - priv = of_device_get_match_data(&pdev->dev); 2858 + priv = of_device_get_match_data(&pdev->dev); 2849 2859 2850 2860 irq = platform_get_irq(pdev, 0); 2851 2861 if (irq < 0) ··· 3019 3039 .driver = { 3020 3040 .name = udc_name, 3021 3041 .pm = &renesas_usb3_pm_ops, 3022 - .of_match_table = of_match_ptr(usb3_of_match), 3042 + .of_match_table = usb3_of_match, 3023 3043 }, 3024 3044 }; 3025 3045 module_platform_driver(renesas_usb3_driver);
-11
drivers/usb/gadget/udc/renesas_usbf.c
··· 545 545 usbf_ep_dma_reg_writel(ep, offset, tmp); 546 546 } 547 547 548 - static inline void usbf_ep_dma_reg_clrset(struct usbf_ep *ep, uint offset, 549 - u32 clr, u32 set) 550 - { 551 - u32 tmp; 552 - 553 - tmp = usbf_ep_dma_reg_readl(ep, offset); 554 - tmp &= ~clr; 555 - tmp |= set; 556 - usbf_ep_dma_reg_writel(ep, offset, tmp); 557 - } 558 - 559 548 static void usbf_ep0_send_null(struct usbf_ep *ep0, bool is_data1) 560 549 { 561 550 u32 set;
+2 -2
drivers/usb/gadget/udc/rzv2m_usb3drd.c
··· 6 6 */ 7 7 8 8 #include <linux/io.h> 9 - #include <linux/of_device.h> 9 + #include <linux/of_platform.h> 10 10 #include <linux/platform_device.h> 11 11 #include <linux/pm_runtime.h> 12 12 #include <linux/reset.h> ··· 126 126 static struct platform_driver rzv2m_usb3drd_driver = { 127 127 .driver = { 128 128 .name = "rzv2m-usb3drd", 129 - .of_match_table = of_match_ptr(rzv2m_usb3drd_of_match), 129 + .of_match_table = rzv2m_usb3drd_of_match, 130 130 }, 131 131 .probe = rzv2m_usb3drd_probe, 132 132 .remove = rzv2m_usb3drd_remove,
+1 -1
drivers/usb/gadget/udc/snps_udc_plat.c
··· 158 158 } 159 159 160 160 /* Register for extcon if supported */ 161 - if (of_get_property(dev->of_node, "extcon", NULL)) { 161 + if (of_property_present(dev->of_node, "extcon")) { 162 162 udc->edev = extcon_get_edev_by_phandle(dev, 0); 163 163 if (IS_ERR(udc->edev)) { 164 164 if (PTR_ERR(udc->edev) == -EPROBE_DEFER)
+3 -4
drivers/usb/gadget/udc/tegra-xudc.c
··· 2162 2162 static int tegra_xudc_gadget_vbus_draw(struct usb_gadget *gadget, 2163 2163 unsigned int m_a) 2164 2164 { 2165 - int ret = 0; 2166 2165 struct tegra_xudc *xudc = to_xudc(gadget); 2167 2166 2168 2167 dev_dbg(xudc->dev, "%s: %u mA\n", __func__, m_a); 2169 2168 2170 - if (xudc->curr_usbphy->chg_type == SDP_TYPE) 2171 - ret = usb_phy_set_power(xudc->curr_usbphy, m_a); 2169 + if (xudc->curr_usbphy && xudc->curr_usbphy->chg_type == SDP_TYPE) 2170 + return usb_phy_set_power(xudc->curr_usbphy, m_a); 2172 2171 2173 - return ret; 2172 + return 0; 2174 2173 } 2175 2174 2176 2175 static int tegra_xudc_set_selfpowered(struct usb_gadget *gadget, int is_on)
+5
drivers/usb/gadget/udc/trace.h
··· 91 91 TP_ARGS(g, ret) 92 92 ); 93 93 94 + DEFINE_EVENT(udc_log_gadget, usb_gadget_set_remote_wakeup, 95 + TP_PROTO(struct usb_gadget *g, int ret), 96 + TP_ARGS(g, ret) 97 + ); 98 + 94 99 DEFINE_EVENT(udc_log_gadget, usb_gadget_set_selfpowered, 95 100 TP_PROTO(struct usb_gadget *g, int ret), 96 101 TP_ARGS(g, ret)
-27
drivers/usb/host/Kconfig
··· 622 622 Say "y" to see some FHCI debug information and statistics 623 623 through debugfs. 624 624 625 - config USB_U132_HCD 626 - tristate "Elan U132 Adapter Host Controller" 627 - depends on USB_FTDI_ELAN 628 - help 629 - The U132 adapter is a USB to CardBus adapter specifically designed 630 - for PC cards that contain an OHCI host controller. Typical PC cards 631 - are the Orange Mobile 3G Option GlobeTrotter Fusion card. The U132 632 - adapter will *NOT* work with PC cards that do not contain an OHCI 633 - controller. 634 - 635 - For those PC cards that contain multiple OHCI controllers only the 636 - first one is used. 637 - 638 - The driver consists of two modules, the "ftdi-elan" module is a 639 - USB client driver that interfaces to the FTDI chip within ELAN's 640 - USB-to-PCMCIA adapter, and this "u132-hcd" module is a USB host 641 - controller driver that talks to the OHCI controller within the 642 - CardBus cards that are inserted in the U132 adapter. 643 - 644 - This driver has been tested with a CardBus OHCI USB adapter, and 645 - worked with a USB PEN Drive inserted into the first USB port of 646 - the PCCARD. A rather pointless thing to do, but useful for testing. 647 - 648 - It is safe to say M here. 649 - 650 - See also <http://www.elandigitalsystems.com/support/ufaq/u132linux.php> 651 - 652 625 config USB_SL811_HCD 653 626 tristate "SL811HS HCD support" 654 627 depends on HAS_IOMEM
-1
drivers/usb/host/Makefile
··· 76 76 obj-$(CONFIG_USB_XHCI_TEGRA) += xhci-tegra.o 77 77 obj-$(CONFIG_USB_SL811_HCD) += sl811-hcd.o 78 78 obj-$(CONFIG_USB_SL811_CS) += sl811_cs.o 79 - obj-$(CONFIG_USB_U132_HCD) += u132-hcd.o 80 79 obj-$(CONFIG_USB_R8A66597_HCD) += r8a66597-hcd.o 81 80 obj-$(CONFIG_USB_FSL_USB2) += fsl-mph-dr-of.o 82 81 obj-$(CONFIG_USB_EHCI_FSL) += fsl-mph-dr-of.o
+3 -3
drivers/usb/host/ehci-ppc-of.c
··· 151 151 of_node_put(np); 152 152 } 153 153 154 - if (of_get_property(dn, "big-endian", NULL)) { 154 + if (of_property_read_bool(dn, "big-endian")) { 155 155 ehci->big_endian_mmio = 1; 156 156 ehci->big_endian_desc = 1; 157 157 } 158 - if (of_get_property(dn, "big-endian-regs", NULL)) 158 + if (of_property_read_bool(dn, "big-endian-regs")) 159 159 ehci->big_endian_mmio = 1; 160 - if (of_get_property(dn, "big-endian-desc", NULL)) 160 + if (of_property_read_bool(dn, "big-endian-desc")) 161 161 ehci->big_endian_desc = 1; 162 162 163 163 ehci->caps = hcd->regs;
+4 -7
drivers/usb/host/fsl-mph-dr-of.c
··· 200 200 dev_data = get_dr_mode_data(np); 201 201 202 202 if (of_device_is_compatible(np, "fsl-usb2-mph")) { 203 - if (of_get_property(np, "port0", NULL)) 203 + if (of_property_present(np, "port0")) 204 204 pdata->port_enables |= FSL_USB2_PORT0_ENABLED; 205 205 206 - if (of_get_property(np, "port1", NULL)) 206 + if (of_property_present(np, "port1")) 207 207 pdata->port_enables |= FSL_USB2_PORT1_ENABLED; 208 208 209 209 pdata->operating_mode = FSL_USB2_MPH_HOST; 210 210 } else { 211 - if (of_get_property(np, "fsl,invert-drvvbus", NULL)) 212 - pdata->invert_drvvbus = 1; 213 - 214 - if (of_get_property(np, "fsl,invert-pwr-fault", NULL)) 215 - pdata->invert_pwr_fault = 1; 211 + pdata->invert_drvvbus = of_property_read_bool(np, "fsl,invert-drvvbus"); 212 + pdata->invert_pwr_fault = of_property_read_bool(np, "fsl,invert-pwr-fault"); 216 213 217 214 /* setup mode selected in the device tree */ 218 215 pdata->operating_mode = dev_data->op_mode;
+1 -1
drivers/usb/host/max3421-hcd.c
··· 1951 1951 .remove = max3421_remove, 1952 1952 .driver = { 1953 1953 .name = "max3421-hcd", 1954 - .of_match_table = of_match_ptr(max3421_of_match_table), 1954 + .of_match_table = max3421_of_match_table, 1955 1955 }, 1956 1956 }; 1957 1957
+1 -1
drivers/usb/host/oxu210hp-hcd.c
··· 169 169 #define FLAG_CF (1<<0) /* true: we'll support "high speed" */ 170 170 171 171 /* PORTSC: offset 0x44 */ 172 - u32 port_status[0]; /* up to N_PORTS */ 172 + u32 port_status[]; /* up to N_PORTS */ 173 173 /* 31:23 reserved */ 174 174 #define PORT_WKOC_E (1<<22) /* wake on overcurrent (enable) */ 175 175 #define PORT_WKDISC_E (1<<21) /* wake on disconnect (enable) */
+1 -3
drivers/usb/host/pci-quirks.c
··· 207 207 static void usb_amd_find_chipset_info(void) 208 208 { 209 209 unsigned long flags; 210 - struct amd_chipset_info info; 211 - info.need_pll_quirk = false; 210 + struct amd_chipset_info info = { }; 212 211 213 212 spin_lock_irqsave(&amd_lock, flags); 214 213 ··· 217 218 spin_unlock_irqrestore(&amd_lock, flags); 218 219 return; 219 220 } 220 - memset(&info, 0, sizeof(info)); 221 221 spin_unlock_irqrestore(&amd_lock, flags); 222 222 223 223 if (!amd_chipset_sb_type_init(&info)) {
-3219
drivers/usb/host/u132-hcd.c
··· 1 - // SPDX-License-Identifier: GPL-2.0 2 - /* 3 - * Host Controller Driver for the Elan Digital Systems U132 adapter 4 - * 5 - * Copyright(C) 2006 Elan Digital Systems Limited 6 - * http://www.elandigitalsystems.com 7 - * 8 - * Author and Maintainer - Tony Olech - Elan Digital Systems 9 - * tony.olech@elandigitalsystems.com 10 - * 11 - * This driver was written by Tony Olech(tony.olech@elandigitalsystems.com) 12 - * based on various USB host drivers in the 2.6.15 linux kernel 13 - * with constant reference to the 3rd Edition of Linux Device Drivers 14 - * published by O'Reilly 15 - * 16 - * The U132 adapter is a USB to CardBus adapter specifically designed 17 - * for PC cards that contain an OHCI host controller. Typical PC cards 18 - * are the Orange Mobile 3G Option GlobeTrotter Fusion card. 19 - * 20 - * The U132 adapter will *NOT *work with PC cards that do not contain 21 - * an OHCI controller. A simple way to test whether a PC card has an 22 - * OHCI controller as an interface is to insert the PC card directly 23 - * into a laptop(or desktop) with a CardBus slot and if "lspci" shows 24 - * a new USB controller and "lsusb -v" shows a new OHCI Host Controller 25 - * then there is a good chance that the U132 adapter will support the 26 - * PC card.(you also need the specific client driver for the PC card) 27 - * 28 - * Please inform the Author and Maintainer about any PC cards that 29 - * contain OHCI Host Controller and work when directly connected to 30 - * an embedded CardBus slot but do not work when they are connected 31 - * via an ELAN U132 adapter. 32 - * 33 - */ 34 - #include <linux/kernel.h> 35 - #include <linux/module.h> 36 - #include <linux/moduleparam.h> 37 - #include <linux/delay.h> 38 - #include <linux/ioport.h> 39 - #include <linux/pci_ids.h> 40 - #include <linux/sched.h> 41 - #include <linux/slab.h> 42 - #include <linux/errno.h> 43 - #include <linux/init.h> 44 - #include <linux/timer.h> 45 - #include <linux/list.h> 46 - #include <linux/interrupt.h> 47 - #include <linux/usb.h> 48 - #include <linux/usb/hcd.h> 49 - #include <linux/workqueue.h> 50 - #include <linux/platform_device.h> 51 - #include <linux/mutex.h> 52 - #include <asm/io.h> 53 - #include <asm/irq.h> 54 - #include <asm/byteorder.h> 55 - 56 - /* FIXME ohci.h is ONLY for internal use by the OHCI driver. 57 - * If you're going to try stuff like this, you need to split 58 - * out shareable stuff (register declarations?) into its own 59 - * file, maybe name <linux/usb/ohci.h> 60 - */ 61 - 62 - #include "ohci.h" 63 - #define OHCI_CONTROL_INIT OHCI_CTRL_CBSR 64 - #define OHCI_INTR_INIT (OHCI_INTR_MIE | OHCI_INTR_UE | OHCI_INTR_RD | \ 65 - OHCI_INTR_WDH) 66 - MODULE_AUTHOR("Tony Olech - Elan Digital Systems Limited"); 67 - MODULE_DESCRIPTION("U132 USB Host Controller Driver"); 68 - MODULE_LICENSE("GPL"); 69 - #define INT_MODULE_PARM(n, v) static int n = v;module_param(n, int, 0444) 70 - INT_MODULE_PARM(testing, 0); 71 - /* Some boards misreport power switching/overcurrent*/ 72 - static bool distrust_firmware = true; 73 - module_param(distrust_firmware, bool, 0); 74 - MODULE_PARM_DESC(distrust_firmware, "true to distrust firmware power/overcurrent" 75 - "t setup"); 76 - static DECLARE_WAIT_QUEUE_HEAD(u132_hcd_wait); 77 - /* 78 - * u132_module_lock exists to protect access to global variables 79 - * 80 - */ 81 - static DEFINE_MUTEX(u132_module_lock); 82 - static int u132_exiting; 83 - static int u132_instances; 84 - /* 85 - * end of the global variables protected by u132_module_lock 86 - */ 87 - static struct workqueue_struct *workqueue; 88 - #define MAX_U132_PORTS 7 89 - #define MAX_U132_ADDRS 128 90 - #define MAX_U132_UDEVS 4 91 - #define MAX_U132_ENDPS 100 92 - #define MAX_U132_RINGS 4 93 - static const char *cc_to_text[16] = { 94 - "No Error ", 95 - "CRC Error ", 96 - "Bit Stuff ", 97 - "Data Togg ", 98 - "Stall ", 99 - "DevNotResp ", 100 - "PIDCheck ", 101 - "UnExpPID ", 102 - "DataOver ", 103 - "DataUnder ", 104 - "(for hw) ", 105 - "(for hw) ", 106 - "BufferOver ", 107 - "BuffUnder ", 108 - "(for HCD) ", 109 - "(for HCD) " 110 - }; 111 - struct u132_port { 112 - struct u132 *u132; 113 - int reset; 114 - int enable; 115 - int power; 116 - int Status; 117 - }; 118 - struct u132_addr { 119 - u8 address; 120 - }; 121 - struct u132_udev { 122 - struct kref kref; 123 - struct usb_device *usb_device; 124 - u8 enumeration; 125 - u8 udev_number; 126 - u8 usb_addr; 127 - u8 portnumber; 128 - u8 endp_number_in[16]; 129 - u8 endp_number_out[16]; 130 - }; 131 - #define ENDP_QUEUE_SHIFT 3 132 - #define ENDP_QUEUE_SIZE (1<<ENDP_QUEUE_SHIFT) 133 - #define ENDP_QUEUE_MASK (ENDP_QUEUE_SIZE-1) 134 - struct u132_urbq { 135 - struct list_head urb_more; 136 - struct urb *urb; 137 - }; 138 - struct u132_spin { 139 - spinlock_t slock; 140 - }; 141 - struct u132_endp { 142 - struct kref kref; 143 - u8 udev_number; 144 - u8 endp_number; 145 - u8 usb_addr; 146 - u8 usb_endp; 147 - struct u132 *u132; 148 - struct list_head endp_ring; 149 - struct u132_ring *ring; 150 - unsigned toggle_bits:2; 151 - unsigned active:1; 152 - unsigned delayed:1; 153 - unsigned input:1; 154 - unsigned output:1; 155 - unsigned pipetype:2; 156 - unsigned dequeueing:1; 157 - unsigned edset_flush:1; 158 - unsigned spare_bits:14; 159 - unsigned long jiffies; 160 - struct usb_host_endpoint *hep; 161 - struct u132_spin queue_lock; 162 - u16 queue_size; 163 - u16 queue_last; 164 - u16 queue_next; 165 - struct urb *urb_list[ENDP_QUEUE_SIZE]; 166 - struct list_head urb_more; 167 - struct delayed_work scheduler; 168 - }; 169 - struct u132_ring { 170 - unsigned in_use:1; 171 - unsigned length:7; 172 - u8 number; 173 - struct u132 *u132; 174 - struct u132_endp *curr_endp; 175 - struct delayed_work scheduler; 176 - }; 177 - struct u132 { 178 - struct kref kref; 179 - struct mutex sw_lock; 180 - struct mutex scheduler_lock; 181 - struct u132_platform_data *board; 182 - struct platform_device *platform_dev; 183 - struct u132_ring ring[MAX_U132_RINGS]; 184 - int sequence_num; 185 - int going; 186 - int power; 187 - int reset; 188 - int num_ports; 189 - u32 hc_control; 190 - u32 hc_fminterval; 191 - u32 hc_roothub_status; 192 - u32 hc_roothub_a; 193 - u32 hc_roothub_portstatus[MAX_ROOT_PORTS]; 194 - int flags; 195 - unsigned long next_statechange; 196 - struct delayed_work monitor; 197 - int num_endpoints; 198 - struct u132_addr addr[MAX_U132_ADDRS]; 199 - struct u132_udev udev[MAX_U132_UDEVS]; 200 - struct u132_port port[MAX_U132_PORTS]; 201 - struct u132_endp *endp[MAX_U132_ENDPS]; 202 - }; 203 - 204 - /* 205 - * these cannot be inlines because we need the structure offset!! 206 - * Does anyone have a better way????? 207 - */ 208 - #define ftdi_read_pcimem(pdev, member, data) usb_ftdi_elan_read_pcimem(pdev, \ 209 - offsetof(struct ohci_regs, member), 0, data); 210 - #define ftdi_write_pcimem(pdev, member, data) usb_ftdi_elan_write_pcimem(pdev, \ 211 - offsetof(struct ohci_regs, member), 0, data) 212 - #define u132_read_pcimem(u132, member, data) \ 213 - usb_ftdi_elan_read_pcimem(u132->platform_dev, offsetof(struct \ 214 - ohci_regs, member), 0, data) 215 - #define u132_write_pcimem(u132, member, data) \ 216 - usb_ftdi_elan_write_pcimem(u132->platform_dev, offsetof(struct \ 217 - ohci_regs, member), 0, data) 218 - static inline struct u132 *udev_to_u132(struct u132_udev *udev) 219 - { 220 - u8 udev_number = udev->udev_number; 221 - return container_of(udev, struct u132, udev[udev_number]); 222 - } 223 - 224 - static inline struct u132 *hcd_to_u132(struct usb_hcd *hcd) 225 - { 226 - return (struct u132 *)(hcd->hcd_priv); 227 - } 228 - 229 - static inline struct usb_hcd *u132_to_hcd(struct u132 *u132) 230 - { 231 - return container_of((void *)u132, struct usb_hcd, hcd_priv); 232 - } 233 - 234 - static inline void u132_disable(struct u132 *u132) 235 - { 236 - u132_to_hcd(u132)->state = HC_STATE_HALT; 237 - } 238 - 239 - 240 - #define kref_to_u132(d) container_of(d, struct u132, kref) 241 - #define kref_to_u132_endp(d) container_of(d, struct u132_endp, kref) 242 - #define kref_to_u132_udev(d) container_of(d, struct u132_udev, kref) 243 - #include "../misc/usb_u132.h" 244 - static const char hcd_name[] = "u132_hcd"; 245 - #define PORT_C_MASK ((USB_PORT_STAT_C_CONNECTION | USB_PORT_STAT_C_ENABLE | \ 246 - USB_PORT_STAT_C_SUSPEND | USB_PORT_STAT_C_OVERCURRENT | \ 247 - USB_PORT_STAT_C_RESET) << 16) 248 - static void u132_hcd_delete(struct kref *kref) 249 - { 250 - struct u132 *u132 = kref_to_u132(kref); 251 - struct platform_device *pdev = u132->platform_dev; 252 - struct usb_hcd *hcd = u132_to_hcd(u132); 253 - u132->going += 1; 254 - mutex_lock(&u132_module_lock); 255 - u132_instances -= 1; 256 - mutex_unlock(&u132_module_lock); 257 - dev_warn(&u132->platform_dev->dev, "FREEING the hcd=%p and thus the u13" 258 - "2=%p going=%d pdev=%p\n", hcd, u132, u132->going, pdev); 259 - usb_put_hcd(hcd); 260 - } 261 - 262 - static inline void u132_u132_put_kref(struct u132 *u132) 263 - { 264 - kref_put(&u132->kref, u132_hcd_delete); 265 - } 266 - 267 - static inline void u132_u132_init_kref(struct u132 *u132) 268 - { 269 - kref_init(&u132->kref); 270 - } 271 - 272 - static void u132_udev_delete(struct kref *kref) 273 - { 274 - struct u132_udev *udev = kref_to_u132_udev(kref); 275 - udev->udev_number = 0; 276 - udev->usb_device = NULL; 277 - udev->usb_addr = 0; 278 - udev->enumeration = 0; 279 - } 280 - 281 - static inline void u132_udev_put_kref(struct u132 *u132, struct u132_udev *udev) 282 - { 283 - kref_put(&udev->kref, u132_udev_delete); 284 - } 285 - 286 - static inline void u132_udev_get_kref(struct u132 *u132, struct u132_udev *udev) 287 - { 288 - kref_get(&udev->kref); 289 - } 290 - 291 - static inline void u132_udev_init_kref(struct u132 *u132, 292 - struct u132_udev *udev) 293 - { 294 - kref_init(&udev->kref); 295 - } 296 - 297 - static inline void u132_ring_put_kref(struct u132 *u132, struct u132_ring *ring) 298 - { 299 - kref_put(&u132->kref, u132_hcd_delete); 300 - } 301 - 302 - static void u132_ring_requeue_work(struct u132 *u132, struct u132_ring *ring, 303 - unsigned int delta) 304 - { 305 - if (delta > 0) { 306 - if (queue_delayed_work(workqueue, &ring->scheduler, delta)) 307 - return; 308 - } else if (queue_delayed_work(workqueue, &ring->scheduler, 0)) 309 - return; 310 - kref_put(&u132->kref, u132_hcd_delete); 311 - } 312 - 313 - static void u132_ring_queue_work(struct u132 *u132, struct u132_ring *ring, 314 - unsigned int delta) 315 - { 316 - kref_get(&u132->kref); 317 - u132_ring_requeue_work(u132, ring, delta); 318 - } 319 - 320 - static void u132_ring_cancel_work(struct u132 *u132, struct u132_ring *ring) 321 - { 322 - if (cancel_delayed_work(&ring->scheduler)) 323 - kref_put(&u132->kref, u132_hcd_delete); 324 - } 325 - 326 - static void u132_endp_delete(struct kref *kref) 327 - { 328 - struct u132_endp *endp = kref_to_u132_endp(kref); 329 - struct u132 *u132 = endp->u132; 330 - u8 usb_addr = endp->usb_addr; 331 - u8 usb_endp = endp->usb_endp; 332 - u8 address = u132->addr[usb_addr].address; 333 - struct u132_udev *udev = &u132->udev[address]; 334 - u8 endp_number = endp->endp_number; 335 - struct usb_host_endpoint *hep = endp->hep; 336 - struct u132_ring *ring = endp->ring; 337 - struct list_head *head = &endp->endp_ring; 338 - ring->length -= 1; 339 - if (endp == ring->curr_endp) { 340 - if (list_empty(head)) { 341 - ring->curr_endp = NULL; 342 - list_del(head); 343 - } else { 344 - struct u132_endp *next_endp = list_entry(head->next, 345 - struct u132_endp, endp_ring); 346 - ring->curr_endp = next_endp; 347 - list_del(head); 348 - } 349 - } else 350 - list_del(head); 351 - if (endp->input) { 352 - udev->endp_number_in[usb_endp] = 0; 353 - u132_udev_put_kref(u132, udev); 354 - } 355 - if (endp->output) { 356 - udev->endp_number_out[usb_endp] = 0; 357 - u132_udev_put_kref(u132, udev); 358 - } 359 - u132->endp[endp_number - 1] = NULL; 360 - hep->hcpriv = NULL; 361 - kfree(endp); 362 - u132_u132_put_kref(u132); 363 - } 364 - 365 - static inline void u132_endp_put_kref(struct u132 *u132, struct u132_endp *endp) 366 - { 367 - kref_put(&endp->kref, u132_endp_delete); 368 - } 369 - 370 - static inline void u132_endp_get_kref(struct u132 *u132, struct u132_endp *endp) 371 - { 372 - kref_get(&endp->kref); 373 - } 374 - 375 - static inline void u132_endp_init_kref(struct u132 *u132, 376 - struct u132_endp *endp) 377 - { 378 - kref_init(&endp->kref); 379 - kref_get(&u132->kref); 380 - } 381 - 382 - static void u132_endp_queue_work(struct u132 *u132, struct u132_endp *endp, 383 - unsigned int delta) 384 - { 385 - if (queue_delayed_work(workqueue, &endp->scheduler, delta)) 386 - kref_get(&endp->kref); 387 - } 388 - 389 - static void u132_endp_cancel_work(struct u132 *u132, struct u132_endp *endp) 390 - { 391 - if (cancel_delayed_work(&endp->scheduler)) 392 - kref_put(&endp->kref, u132_endp_delete); 393 - } 394 - 395 - static inline void u132_monitor_put_kref(struct u132 *u132) 396 - { 397 - kref_put(&u132->kref, u132_hcd_delete); 398 - } 399 - 400 - static void u132_monitor_queue_work(struct u132 *u132, unsigned int delta) 401 - { 402 - if (queue_delayed_work(workqueue, &u132->monitor, delta)) 403 - kref_get(&u132->kref); 404 - } 405 - 406 - static void u132_monitor_requeue_work(struct u132 *u132, unsigned int delta) 407 - { 408 - if (!queue_delayed_work(workqueue, &u132->monitor, delta)) 409 - kref_put(&u132->kref, u132_hcd_delete); 410 - } 411 - 412 - static void u132_monitor_cancel_work(struct u132 *u132) 413 - { 414 - if (cancel_delayed_work(&u132->monitor)) 415 - kref_put(&u132->kref, u132_hcd_delete); 416 - } 417 - 418 - static int read_roothub_info(struct u132 *u132) 419 - { 420 - u32 revision; 421 - int retval; 422 - retval = u132_read_pcimem(u132, revision, &revision); 423 - if (retval) { 424 - dev_err(&u132->platform_dev->dev, "error %d accessing device co" 425 - "ntrol\n", retval); 426 - return retval; 427 - } else if ((revision & 0xFF) == 0x10) { 428 - } else if ((revision & 0xFF) == 0x11) { 429 - } else { 430 - dev_err(&u132->platform_dev->dev, "device revision is not valid" 431 - " %08X\n", revision); 432 - return -ENODEV; 433 - } 434 - retval = u132_read_pcimem(u132, control, &u132->hc_control); 435 - if (retval) { 436 - dev_err(&u132->platform_dev->dev, "error %d accessing device co" 437 - "ntrol\n", retval); 438 - return retval; 439 - } 440 - retval = u132_read_pcimem(u132, roothub.status, 441 - &u132->hc_roothub_status); 442 - if (retval) { 443 - dev_err(&u132->platform_dev->dev, "error %d accessing device re" 444 - "g roothub.status\n", retval); 445 - return retval; 446 - } 447 - retval = u132_read_pcimem(u132, roothub.a, &u132->hc_roothub_a); 448 - if (retval) { 449 - dev_err(&u132->platform_dev->dev, "error %d accessing device re" 450 - "g roothub.a\n", retval); 451 - return retval; 452 - } 453 - { 454 - int I = u132->num_ports; 455 - int i = 0; 456 - while (I-- > 0) { 457 - retval = u132_read_pcimem(u132, roothub.portstatus[i], 458 - &u132->hc_roothub_portstatus[i]); 459 - if (retval) { 460 - dev_err(&u132->platform_dev->dev, "error %d acc" 461 - "essing device roothub.portstatus[%d]\n" 462 - , retval, i); 463 - return retval; 464 - } else 465 - i += 1; 466 - } 467 - } 468 - return 0; 469 - } 470 - 471 - static void u132_hcd_monitor_work(struct work_struct *work) 472 - { 473 - struct u132 *u132 = container_of(work, struct u132, monitor.work); 474 - if (u132->going > 1) { 475 - dev_err(&u132->platform_dev->dev, "device has been removed %d\n" 476 - , u132->going); 477 - u132_monitor_put_kref(u132); 478 - return; 479 - } else if (u132->going > 0) { 480 - dev_err(&u132->platform_dev->dev, "device is being removed\n"); 481 - u132_monitor_put_kref(u132); 482 - return; 483 - } else { 484 - int retval; 485 - mutex_lock(&u132->sw_lock); 486 - retval = read_roothub_info(u132); 487 - if (retval) { 488 - struct usb_hcd *hcd = u132_to_hcd(u132); 489 - u132_disable(u132); 490 - u132->going = 1; 491 - mutex_unlock(&u132->sw_lock); 492 - usb_hc_died(hcd); 493 - ftdi_elan_gone_away(u132->platform_dev); 494 - u132_monitor_put_kref(u132); 495 - return; 496 - } else { 497 - u132_monitor_requeue_work(u132, 500); 498 - mutex_unlock(&u132->sw_lock); 499 - return; 500 - } 501 - } 502 - } 503 - 504 - static void u132_hcd_giveback_urb(struct u132 *u132, struct u132_endp *endp, 505 - struct urb *urb, int status) 506 - { 507 - struct u132_ring *ring; 508 - unsigned long irqs; 509 - struct usb_hcd *hcd = u132_to_hcd(u132); 510 - urb->error_count = 0; 511 - spin_lock_irqsave(&endp->queue_lock.slock, irqs); 512 - usb_hcd_unlink_urb_from_ep(hcd, urb); 513 - endp->queue_next += 1; 514 - if (ENDP_QUEUE_SIZE > --endp->queue_size) { 515 - endp->active = 0; 516 - spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); 517 - } else { 518 - struct list_head *next = endp->urb_more.next; 519 - struct u132_urbq *urbq = list_entry(next, struct u132_urbq, 520 - urb_more); 521 - list_del(next); 522 - endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] = 523 - urbq->urb; 524 - endp->active = 0; 525 - spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); 526 - kfree(urbq); 527 - } 528 - mutex_lock(&u132->scheduler_lock); 529 - ring = endp->ring; 530 - ring->in_use = 0; 531 - u132_ring_cancel_work(u132, ring); 532 - u132_ring_queue_work(u132, ring, 0); 533 - mutex_unlock(&u132->scheduler_lock); 534 - u132_endp_put_kref(u132, endp); 535 - usb_hcd_giveback_urb(hcd, urb, status); 536 - } 537 - 538 - static void u132_hcd_forget_urb(struct u132 *u132, struct u132_endp *endp, 539 - struct urb *urb, int status) 540 - { 541 - u132_endp_put_kref(u132, endp); 542 - } 543 - 544 - static void u132_hcd_abandon_urb(struct u132 *u132, struct u132_endp *endp, 545 - struct urb *urb, int status) 546 - { 547 - unsigned long irqs; 548 - struct usb_hcd *hcd = u132_to_hcd(u132); 549 - urb->error_count = 0; 550 - spin_lock_irqsave(&endp->queue_lock.slock, irqs); 551 - usb_hcd_unlink_urb_from_ep(hcd, urb); 552 - endp->queue_next += 1; 553 - if (ENDP_QUEUE_SIZE > --endp->queue_size) { 554 - endp->active = 0; 555 - spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); 556 - } else { 557 - struct list_head *next = endp->urb_more.next; 558 - struct u132_urbq *urbq = list_entry(next, struct u132_urbq, 559 - urb_more); 560 - list_del(next); 561 - endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] = 562 - urbq->urb; 563 - endp->active = 0; 564 - spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); 565 - kfree(urbq); 566 - } 567 - usb_hcd_giveback_urb(hcd, urb, status); 568 - } 569 - 570 - static inline int edset_input(struct u132 *u132, struct u132_ring *ring, 571 - struct u132_endp *endp, struct urb *urb, u8 address, u8 toggle_bits, 572 - void (*callback) (void *endp, struct urb *urb, u8 *buf, int len, 573 - int toggle_bits, int error_count, int condition_code, int repeat_number, 574 - int halted, int skipped, int actual, int non_null)) 575 - { 576 - return usb_ftdi_elan_edset_input(u132->platform_dev, ring->number, endp, 577 - urb, address, endp->usb_endp, toggle_bits, callback); 578 - } 579 - 580 - static inline int edset_setup(struct u132 *u132, struct u132_ring *ring, 581 - struct u132_endp *endp, struct urb *urb, u8 address, u8 toggle_bits, 582 - void (*callback) (void *endp, struct urb *urb, u8 *buf, int len, 583 - int toggle_bits, int error_count, int condition_code, int repeat_number, 584 - int halted, int skipped, int actual, int non_null)) 585 - { 586 - return usb_ftdi_elan_edset_setup(u132->platform_dev, ring->number, endp, 587 - urb, address, endp->usb_endp, toggle_bits, callback); 588 - } 589 - 590 - static inline int edset_single(struct u132 *u132, struct u132_ring *ring, 591 - struct u132_endp *endp, struct urb *urb, u8 address, u8 toggle_bits, 592 - void (*callback) (void *endp, struct urb *urb, u8 *buf, int len, 593 - int toggle_bits, int error_count, int condition_code, int repeat_number, 594 - int halted, int skipped, int actual, int non_null)) 595 - { 596 - return usb_ftdi_elan_edset_single(u132->platform_dev, ring->number, 597 - endp, urb, address, endp->usb_endp, toggle_bits, callback); 598 - } 599 - 600 - static inline int edset_output(struct u132 *u132, struct u132_ring *ring, 601 - struct u132_endp *endp, struct urb *urb, u8 address, u8 toggle_bits, 602 - void (*callback) (void *endp, struct urb *urb, u8 *buf, int len, 603 - int toggle_bits, int error_count, int condition_code, int repeat_number, 604 - int halted, int skipped, int actual, int non_null)) 605 - { 606 - return usb_ftdi_elan_edset_output(u132->platform_dev, ring->number, 607 - endp, urb, address, endp->usb_endp, toggle_bits, callback); 608 - } 609 - 610 - 611 - /* 612 - * must not LOCK sw_lock 613 - * 614 - */ 615 - static void u132_hcd_interrupt_recv(void *data, struct urb *urb, u8 *buf, 616 - int len, int toggle_bits, int error_count, int condition_code, 617 - int repeat_number, int halted, int skipped, int actual, int non_null) 618 - { 619 - struct u132_endp *endp = data; 620 - struct u132 *u132 = endp->u132; 621 - u8 address = u132->addr[endp->usb_addr].address; 622 - struct u132_udev *udev = &u132->udev[address]; 623 - mutex_lock(&u132->scheduler_lock); 624 - if (u132->going > 1) { 625 - dev_err(&u132->platform_dev->dev, "device has been removed %d\n" 626 - , u132->going); 627 - mutex_unlock(&u132->scheduler_lock); 628 - u132_hcd_forget_urb(u132, endp, urb, -ENODEV); 629 - return; 630 - } else if (endp->dequeueing) { 631 - endp->dequeueing = 0; 632 - mutex_unlock(&u132->scheduler_lock); 633 - u132_hcd_giveback_urb(u132, endp, urb, -EINTR); 634 - return; 635 - } else if (u132->going > 0) { 636 - dev_err(&u132->platform_dev->dev, "device is being removed " 637 - "urb=%p\n", urb); 638 - mutex_unlock(&u132->scheduler_lock); 639 - u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); 640 - return; 641 - } else if (!urb->unlinked) { 642 - struct u132_ring *ring = endp->ring; 643 - u8 *u = urb->transfer_buffer + urb->actual_length; 644 - u8 *b = buf; 645 - int L = len; 646 - 647 - while (L-- > 0) 648 - *u++ = *b++; 649 - 650 - urb->actual_length += len; 651 - if ((condition_code == TD_CC_NOERROR) && 652 - (urb->transfer_buffer_length > urb->actual_length)) { 653 - endp->toggle_bits = toggle_bits; 654 - usb_settoggle(udev->usb_device, endp->usb_endp, 0, 655 - 1 & toggle_bits); 656 - if (urb->actual_length > 0) { 657 - int retval; 658 - mutex_unlock(&u132->scheduler_lock); 659 - retval = edset_single(u132, ring, endp, urb, 660 - address, endp->toggle_bits, 661 - u132_hcd_interrupt_recv); 662 - if (retval != 0) 663 - u132_hcd_giveback_urb(u132, endp, urb, 664 - retval); 665 - } else { 666 - ring->in_use = 0; 667 - endp->active = 0; 668 - endp->jiffies = jiffies + 669 - msecs_to_jiffies(urb->interval); 670 - u132_ring_cancel_work(u132, ring); 671 - u132_ring_queue_work(u132, ring, 0); 672 - mutex_unlock(&u132->scheduler_lock); 673 - u132_endp_put_kref(u132, endp); 674 - } 675 - return; 676 - } else if ((condition_code == TD_DATAUNDERRUN) && 677 - ((urb->transfer_flags & URB_SHORT_NOT_OK) == 0)) { 678 - endp->toggle_bits = toggle_bits; 679 - usb_settoggle(udev->usb_device, endp->usb_endp, 0, 680 - 1 & toggle_bits); 681 - mutex_unlock(&u132->scheduler_lock); 682 - u132_hcd_giveback_urb(u132, endp, urb, 0); 683 - return; 684 - } else { 685 - if (condition_code == TD_CC_NOERROR) { 686 - endp->toggle_bits = toggle_bits; 687 - usb_settoggle(udev->usb_device, endp->usb_endp, 688 - 0, 1 & toggle_bits); 689 - } else if (condition_code == TD_CC_STALL) { 690 - endp->toggle_bits = 0x2; 691 - usb_settoggle(udev->usb_device, endp->usb_endp, 692 - 0, 0); 693 - } else { 694 - endp->toggle_bits = 0x2; 695 - usb_settoggle(udev->usb_device, endp->usb_endp, 696 - 0, 0); 697 - dev_err(&u132->platform_dev->dev, "urb=%p givin" 698 - "g back INTERRUPT %s\n", urb, 699 - cc_to_text[condition_code]); 700 - } 701 - mutex_unlock(&u132->scheduler_lock); 702 - u132_hcd_giveback_urb(u132, endp, urb, 703 - cc_to_error[condition_code]); 704 - return; 705 - } 706 - } else { 707 - dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p " 708 - "unlinked=%d\n", urb, urb->unlinked); 709 - mutex_unlock(&u132->scheduler_lock); 710 - u132_hcd_giveback_urb(u132, endp, urb, 0); 711 - return; 712 - } 713 - } 714 - 715 - static void u132_hcd_bulk_output_sent(void *data, struct urb *urb, u8 *buf, 716 - int len, int toggle_bits, int error_count, int condition_code, 717 - int repeat_number, int halted, int skipped, int actual, int non_null) 718 - { 719 - struct u132_endp *endp = data; 720 - struct u132 *u132 = endp->u132; 721 - u8 address = u132->addr[endp->usb_addr].address; 722 - mutex_lock(&u132->scheduler_lock); 723 - if (u132->going > 1) { 724 - dev_err(&u132->platform_dev->dev, "device has been removed %d\n" 725 - , u132->going); 726 - mutex_unlock(&u132->scheduler_lock); 727 - u132_hcd_forget_urb(u132, endp, urb, -ENODEV); 728 - return; 729 - } else if (endp->dequeueing) { 730 - endp->dequeueing = 0; 731 - mutex_unlock(&u132->scheduler_lock); 732 - u132_hcd_giveback_urb(u132, endp, urb, -EINTR); 733 - return; 734 - } else if (u132->going > 0) { 735 - dev_err(&u132->platform_dev->dev, "device is being removed " 736 - "urb=%p\n", urb); 737 - mutex_unlock(&u132->scheduler_lock); 738 - u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); 739 - return; 740 - } else if (!urb->unlinked) { 741 - struct u132_ring *ring = endp->ring; 742 - urb->actual_length += len; 743 - endp->toggle_bits = toggle_bits; 744 - if (urb->transfer_buffer_length > urb->actual_length) { 745 - int retval; 746 - mutex_unlock(&u132->scheduler_lock); 747 - retval = edset_output(u132, ring, endp, urb, address, 748 - endp->toggle_bits, u132_hcd_bulk_output_sent); 749 - if (retval != 0) 750 - u132_hcd_giveback_urb(u132, endp, urb, retval); 751 - return; 752 - } else { 753 - mutex_unlock(&u132->scheduler_lock); 754 - u132_hcd_giveback_urb(u132, endp, urb, 0); 755 - return; 756 - } 757 - } else { 758 - dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p " 759 - "unlinked=%d\n", urb, urb->unlinked); 760 - mutex_unlock(&u132->scheduler_lock); 761 - u132_hcd_giveback_urb(u132, endp, urb, 0); 762 - return; 763 - } 764 - } 765 - 766 - static void u132_hcd_bulk_input_recv(void *data, struct urb *urb, u8 *buf, 767 - int len, int toggle_bits, int error_count, int condition_code, 768 - int repeat_number, int halted, int skipped, int actual, int non_null) 769 - { 770 - struct u132_endp *endp = data; 771 - struct u132 *u132 = endp->u132; 772 - u8 address = u132->addr[endp->usb_addr].address; 773 - struct u132_udev *udev = &u132->udev[address]; 774 - mutex_lock(&u132->scheduler_lock); 775 - if (u132->going > 1) { 776 - dev_err(&u132->platform_dev->dev, "device has been removed %d\n" 777 - , u132->going); 778 - mutex_unlock(&u132->scheduler_lock); 779 - u132_hcd_forget_urb(u132, endp, urb, -ENODEV); 780 - return; 781 - } else if (endp->dequeueing) { 782 - endp->dequeueing = 0; 783 - mutex_unlock(&u132->scheduler_lock); 784 - u132_hcd_giveback_urb(u132, endp, urb, -EINTR); 785 - return; 786 - } else if (u132->going > 0) { 787 - dev_err(&u132->platform_dev->dev, "device is being removed " 788 - "urb=%p\n", urb); 789 - mutex_unlock(&u132->scheduler_lock); 790 - u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); 791 - return; 792 - } else if (!urb->unlinked) { 793 - struct u132_ring *ring = endp->ring; 794 - u8 *u = urb->transfer_buffer + urb->actual_length; 795 - u8 *b = buf; 796 - int L = len; 797 - 798 - while (L-- > 0) 799 - *u++ = *b++; 800 - 801 - urb->actual_length += len; 802 - if ((condition_code == TD_CC_NOERROR) && 803 - (urb->transfer_buffer_length > urb->actual_length)) { 804 - int retval; 805 - endp->toggle_bits = toggle_bits; 806 - usb_settoggle(udev->usb_device, endp->usb_endp, 0, 807 - 1 & toggle_bits); 808 - mutex_unlock(&u132->scheduler_lock); 809 - retval = usb_ftdi_elan_edset_input(u132->platform_dev, 810 - ring->number, endp, urb, address, 811 - endp->usb_endp, endp->toggle_bits, 812 - u132_hcd_bulk_input_recv); 813 - if (retval != 0) 814 - u132_hcd_giveback_urb(u132, endp, urb, retval); 815 - return; 816 - } else if (condition_code == TD_CC_NOERROR) { 817 - endp->toggle_bits = toggle_bits; 818 - usb_settoggle(udev->usb_device, endp->usb_endp, 0, 819 - 1 & toggle_bits); 820 - mutex_unlock(&u132->scheduler_lock); 821 - u132_hcd_giveback_urb(u132, endp, urb, 822 - cc_to_error[condition_code]); 823 - return; 824 - } else if ((condition_code == TD_DATAUNDERRUN) && 825 - ((urb->transfer_flags & URB_SHORT_NOT_OK) == 0)) { 826 - endp->toggle_bits = toggle_bits; 827 - usb_settoggle(udev->usb_device, endp->usb_endp, 0, 828 - 1 & toggle_bits); 829 - mutex_unlock(&u132->scheduler_lock); 830 - u132_hcd_giveback_urb(u132, endp, urb, 0); 831 - return; 832 - } else if (condition_code == TD_DATAUNDERRUN) { 833 - endp->toggle_bits = toggle_bits; 834 - usb_settoggle(udev->usb_device, endp->usb_endp, 0, 835 - 1 & toggle_bits); 836 - dev_warn(&u132->platform_dev->dev, "urb=%p(SHORT NOT OK" 837 - ") giving back BULK IN %s\n", urb, 838 - cc_to_text[condition_code]); 839 - mutex_unlock(&u132->scheduler_lock); 840 - u132_hcd_giveback_urb(u132, endp, urb, 0); 841 - return; 842 - } else if (condition_code == TD_CC_STALL) { 843 - endp->toggle_bits = 0x2; 844 - usb_settoggle(udev->usb_device, endp->usb_endp, 0, 0); 845 - mutex_unlock(&u132->scheduler_lock); 846 - u132_hcd_giveback_urb(u132, endp, urb, 847 - cc_to_error[condition_code]); 848 - return; 849 - } else { 850 - endp->toggle_bits = 0x2; 851 - usb_settoggle(udev->usb_device, endp->usb_endp, 0, 0); 852 - dev_err(&u132->platform_dev->dev, "urb=%p giving back B" 853 - "ULK IN code=%d %s\n", urb, condition_code, 854 - cc_to_text[condition_code]); 855 - mutex_unlock(&u132->scheduler_lock); 856 - u132_hcd_giveback_urb(u132, endp, urb, 857 - cc_to_error[condition_code]); 858 - return; 859 - } 860 - } else { 861 - dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p " 862 - "unlinked=%d\n", urb, urb->unlinked); 863 - mutex_unlock(&u132->scheduler_lock); 864 - u132_hcd_giveback_urb(u132, endp, urb, 0); 865 - return; 866 - } 867 - } 868 - 869 - static void u132_hcd_configure_empty_sent(void *data, struct urb *urb, u8 *buf, 870 - int len, int toggle_bits, int error_count, int condition_code, 871 - int repeat_number, int halted, int skipped, int actual, int non_null) 872 - { 873 - struct u132_endp *endp = data; 874 - struct u132 *u132 = endp->u132; 875 - mutex_lock(&u132->scheduler_lock); 876 - if (u132->going > 1) { 877 - dev_err(&u132->platform_dev->dev, "device has been removed %d\n" 878 - , u132->going); 879 - mutex_unlock(&u132->scheduler_lock); 880 - u132_hcd_forget_urb(u132, endp, urb, -ENODEV); 881 - return; 882 - } else if (endp->dequeueing) { 883 - endp->dequeueing = 0; 884 - mutex_unlock(&u132->scheduler_lock); 885 - u132_hcd_giveback_urb(u132, endp, urb, -EINTR); 886 - return; 887 - } else if (u132->going > 0) { 888 - dev_err(&u132->platform_dev->dev, "device is being removed " 889 - "urb=%p\n", urb); 890 - mutex_unlock(&u132->scheduler_lock); 891 - u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); 892 - return; 893 - } else if (!urb->unlinked) { 894 - mutex_unlock(&u132->scheduler_lock); 895 - u132_hcd_giveback_urb(u132, endp, urb, 0); 896 - return; 897 - } else { 898 - dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p " 899 - "unlinked=%d\n", urb, urb->unlinked); 900 - mutex_unlock(&u132->scheduler_lock); 901 - u132_hcd_giveback_urb(u132, endp, urb, 0); 902 - return; 903 - } 904 - } 905 - 906 - static void u132_hcd_configure_input_recv(void *data, struct urb *urb, u8 *buf, 907 - int len, int toggle_bits, int error_count, int condition_code, 908 - int repeat_number, int halted, int skipped, int actual, int non_null) 909 - { 910 - struct u132_endp *endp = data; 911 - struct u132 *u132 = endp->u132; 912 - u8 address = u132->addr[endp->usb_addr].address; 913 - mutex_lock(&u132->scheduler_lock); 914 - if (u132->going > 1) { 915 - dev_err(&u132->platform_dev->dev, "device has been removed %d\n" 916 - , u132->going); 917 - mutex_unlock(&u132->scheduler_lock); 918 - u132_hcd_forget_urb(u132, endp, urb, -ENODEV); 919 - return; 920 - } else if (endp->dequeueing) { 921 - endp->dequeueing = 0; 922 - mutex_unlock(&u132->scheduler_lock); 923 - u132_hcd_giveback_urb(u132, endp, urb, -EINTR); 924 - return; 925 - } else if (u132->going > 0) { 926 - dev_err(&u132->platform_dev->dev, "device is being removed " 927 - "urb=%p\n", urb); 928 - mutex_unlock(&u132->scheduler_lock); 929 - u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); 930 - return; 931 - } else if (!urb->unlinked) { 932 - struct u132_ring *ring = endp->ring; 933 - u8 *u = urb->transfer_buffer; 934 - u8 *b = buf; 935 - int L = len; 936 - 937 - while (L-- > 0) 938 - *u++ = *b++; 939 - 940 - urb->actual_length = len; 941 - if ((condition_code == TD_CC_NOERROR) || ((condition_code == 942 - TD_DATAUNDERRUN) && ((urb->transfer_flags & 943 - URB_SHORT_NOT_OK) == 0))) { 944 - int retval; 945 - mutex_unlock(&u132->scheduler_lock); 946 - retval = usb_ftdi_elan_edset_empty(u132->platform_dev, 947 - ring->number, endp, urb, address, 948 - endp->usb_endp, 0x3, 949 - u132_hcd_configure_empty_sent); 950 - if (retval != 0) 951 - u132_hcd_giveback_urb(u132, endp, urb, retval); 952 - return; 953 - } else if (condition_code == TD_CC_STALL) { 954 - mutex_unlock(&u132->scheduler_lock); 955 - dev_warn(&u132->platform_dev->dev, "giving back SETUP I" 956 - "NPUT STALL urb %p\n", urb); 957 - u132_hcd_giveback_urb(u132, endp, urb, 958 - cc_to_error[condition_code]); 959 - return; 960 - } else { 961 - mutex_unlock(&u132->scheduler_lock); 962 - dev_err(&u132->platform_dev->dev, "giving back SETUP IN" 963 - "PUT %s urb %p\n", cc_to_text[condition_code], 964 - urb); 965 - u132_hcd_giveback_urb(u132, endp, urb, 966 - cc_to_error[condition_code]); 967 - return; 968 - } 969 - } else { 970 - dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p " 971 - "unlinked=%d\n", urb, urb->unlinked); 972 - mutex_unlock(&u132->scheduler_lock); 973 - u132_hcd_giveback_urb(u132, endp, urb, 0); 974 - return; 975 - } 976 - } 977 - 978 - static void u132_hcd_configure_empty_recv(void *data, struct urb *urb, u8 *buf, 979 - int len, int toggle_bits, int error_count, int condition_code, 980 - int repeat_number, int halted, int skipped, int actual, int non_null) 981 - { 982 - struct u132_endp *endp = data; 983 - struct u132 *u132 = endp->u132; 984 - mutex_lock(&u132->scheduler_lock); 985 - if (u132->going > 1) { 986 - dev_err(&u132->platform_dev->dev, "device has been removed %d\n" 987 - , u132->going); 988 - mutex_unlock(&u132->scheduler_lock); 989 - u132_hcd_forget_urb(u132, endp, urb, -ENODEV); 990 - return; 991 - } else if (endp->dequeueing) { 992 - endp->dequeueing = 0; 993 - mutex_unlock(&u132->scheduler_lock); 994 - u132_hcd_giveback_urb(u132, endp, urb, -EINTR); 995 - return; 996 - } else if (u132->going > 0) { 997 - dev_err(&u132->platform_dev->dev, "device is being removed " 998 - "urb=%p\n", urb); 999 - mutex_unlock(&u132->scheduler_lock); 1000 - u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); 1001 - return; 1002 - } else if (!urb->unlinked) { 1003 - mutex_unlock(&u132->scheduler_lock); 1004 - u132_hcd_giveback_urb(u132, endp, urb, 0); 1005 - return; 1006 - } else { 1007 - dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p " 1008 - "unlinked=%d\n", urb, urb->unlinked); 1009 - mutex_unlock(&u132->scheduler_lock); 1010 - u132_hcd_giveback_urb(u132, endp, urb, 0); 1011 - return; 1012 - } 1013 - } 1014 - 1015 - static void u132_hcd_configure_setup_sent(void *data, struct urb *urb, u8 *buf, 1016 - int len, int toggle_bits, int error_count, int condition_code, 1017 - int repeat_number, int halted, int skipped, int actual, int non_null) 1018 - { 1019 - struct u132_endp *endp = data; 1020 - struct u132 *u132 = endp->u132; 1021 - u8 address = u132->addr[endp->usb_addr].address; 1022 - mutex_lock(&u132->scheduler_lock); 1023 - if (u132->going > 1) { 1024 - dev_err(&u132->platform_dev->dev, "device has been removed %d\n" 1025 - , u132->going); 1026 - mutex_unlock(&u132->scheduler_lock); 1027 - u132_hcd_forget_urb(u132, endp, urb, -ENODEV); 1028 - return; 1029 - } else if (endp->dequeueing) { 1030 - endp->dequeueing = 0; 1031 - mutex_unlock(&u132->scheduler_lock); 1032 - u132_hcd_giveback_urb(u132, endp, urb, -EINTR); 1033 - return; 1034 - } else if (u132->going > 0) { 1035 - dev_err(&u132->platform_dev->dev, "device is being removed " 1036 - "urb=%p\n", urb); 1037 - mutex_unlock(&u132->scheduler_lock); 1038 - u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); 1039 - return; 1040 - } else if (!urb->unlinked) { 1041 - if (usb_pipein(urb->pipe)) { 1042 - int retval; 1043 - struct u132_ring *ring = endp->ring; 1044 - mutex_unlock(&u132->scheduler_lock); 1045 - retval = usb_ftdi_elan_edset_input(u132->platform_dev, 1046 - ring->number, endp, urb, address, 1047 - endp->usb_endp, 0, 1048 - u132_hcd_configure_input_recv); 1049 - if (retval != 0) 1050 - u132_hcd_giveback_urb(u132, endp, urb, retval); 1051 - return; 1052 - } else { 1053 - int retval; 1054 - struct u132_ring *ring = endp->ring; 1055 - mutex_unlock(&u132->scheduler_lock); 1056 - retval = usb_ftdi_elan_edset_input(u132->platform_dev, 1057 - ring->number, endp, urb, address, 1058 - endp->usb_endp, 0, 1059 - u132_hcd_configure_empty_recv); 1060 - if (retval != 0) 1061 - u132_hcd_giveback_urb(u132, endp, urb, retval); 1062 - return; 1063 - } 1064 - } else { 1065 - dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p " 1066 - "unlinked=%d\n", urb, urb->unlinked); 1067 - mutex_unlock(&u132->scheduler_lock); 1068 - u132_hcd_giveback_urb(u132, endp, urb, 0); 1069 - return; 1070 - } 1071 - } 1072 - 1073 - static void u132_hcd_enumeration_empty_recv(void *data, struct urb *urb, 1074 - u8 *buf, int len, int toggle_bits, int error_count, int condition_code, 1075 - int repeat_number, int halted, int skipped, int actual, int non_null) 1076 - { 1077 - struct u132_endp *endp = data; 1078 - struct u132 *u132 = endp->u132; 1079 - u8 address = u132->addr[endp->usb_addr].address; 1080 - struct u132_udev *udev = &u132->udev[address]; 1081 - mutex_lock(&u132->scheduler_lock); 1082 - if (u132->going > 1) { 1083 - dev_err(&u132->platform_dev->dev, "device has been removed %d\n" 1084 - , u132->going); 1085 - mutex_unlock(&u132->scheduler_lock); 1086 - u132_hcd_forget_urb(u132, endp, urb, -ENODEV); 1087 - return; 1088 - } else if (endp->dequeueing) { 1089 - endp->dequeueing = 0; 1090 - mutex_unlock(&u132->scheduler_lock); 1091 - u132_hcd_giveback_urb(u132, endp, urb, -EINTR); 1092 - return; 1093 - } else if (u132->going > 0) { 1094 - dev_err(&u132->platform_dev->dev, "device is being removed " 1095 - "urb=%p\n", urb); 1096 - mutex_unlock(&u132->scheduler_lock); 1097 - u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); 1098 - return; 1099 - } else if (!urb->unlinked) { 1100 - u132->addr[0].address = 0; 1101 - endp->usb_addr = udev->usb_addr; 1102 - mutex_unlock(&u132->scheduler_lock); 1103 - u132_hcd_giveback_urb(u132, endp, urb, 0); 1104 - return; 1105 - } else { 1106 - dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p " 1107 - "unlinked=%d\n", urb, urb->unlinked); 1108 - mutex_unlock(&u132->scheduler_lock); 1109 - u132_hcd_giveback_urb(u132, endp, urb, 0); 1110 - return; 1111 - } 1112 - } 1113 - 1114 - static void u132_hcd_enumeration_address_sent(void *data, struct urb *urb, 1115 - u8 *buf, int len, int toggle_bits, int error_count, int condition_code, 1116 - int repeat_number, int halted, int skipped, int actual, int non_null) 1117 - { 1118 - struct u132_endp *endp = data; 1119 - struct u132 *u132 = endp->u132; 1120 - mutex_lock(&u132->scheduler_lock); 1121 - if (u132->going > 1) { 1122 - dev_err(&u132->platform_dev->dev, "device has been removed %d\n" 1123 - , u132->going); 1124 - mutex_unlock(&u132->scheduler_lock); 1125 - u132_hcd_forget_urb(u132, endp, urb, -ENODEV); 1126 - return; 1127 - } else if (endp->dequeueing) { 1128 - endp->dequeueing = 0; 1129 - mutex_unlock(&u132->scheduler_lock); 1130 - u132_hcd_giveback_urb(u132, endp, urb, -EINTR); 1131 - return; 1132 - } else if (u132->going > 0) { 1133 - dev_err(&u132->platform_dev->dev, "device is being removed " 1134 - "urb=%p\n", urb); 1135 - mutex_unlock(&u132->scheduler_lock); 1136 - u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); 1137 - return; 1138 - } else if (!urb->unlinked) { 1139 - int retval; 1140 - struct u132_ring *ring = endp->ring; 1141 - mutex_unlock(&u132->scheduler_lock); 1142 - retval = usb_ftdi_elan_edset_input(u132->platform_dev, 1143 - ring->number, endp, urb, 0, endp->usb_endp, 0, 1144 - u132_hcd_enumeration_empty_recv); 1145 - if (retval != 0) 1146 - u132_hcd_giveback_urb(u132, endp, urb, retval); 1147 - return; 1148 - } else { 1149 - dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p " 1150 - "unlinked=%d\n", urb, urb->unlinked); 1151 - mutex_unlock(&u132->scheduler_lock); 1152 - u132_hcd_giveback_urb(u132, endp, urb, 0); 1153 - return; 1154 - } 1155 - } 1156 - 1157 - static void u132_hcd_initial_empty_sent(void *data, struct urb *urb, u8 *buf, 1158 - int len, int toggle_bits, int error_count, int condition_code, 1159 - int repeat_number, int halted, int skipped, int actual, int non_null) 1160 - { 1161 - struct u132_endp *endp = data; 1162 - struct u132 *u132 = endp->u132; 1163 - mutex_lock(&u132->scheduler_lock); 1164 - if (u132->going > 1) { 1165 - dev_err(&u132->platform_dev->dev, "device has been removed %d\n" 1166 - , u132->going); 1167 - mutex_unlock(&u132->scheduler_lock); 1168 - u132_hcd_forget_urb(u132, endp, urb, -ENODEV); 1169 - return; 1170 - } else if (endp->dequeueing) { 1171 - endp->dequeueing = 0; 1172 - mutex_unlock(&u132->scheduler_lock); 1173 - u132_hcd_giveback_urb(u132, endp, urb, -EINTR); 1174 - return; 1175 - } else if (u132->going > 0) { 1176 - dev_err(&u132->platform_dev->dev, "device is being removed " 1177 - "urb=%p\n", urb); 1178 - mutex_unlock(&u132->scheduler_lock); 1179 - u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); 1180 - return; 1181 - } else if (!urb->unlinked) { 1182 - mutex_unlock(&u132->scheduler_lock); 1183 - u132_hcd_giveback_urb(u132, endp, urb, 0); 1184 - return; 1185 - } else { 1186 - dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p " 1187 - "unlinked=%d\n", urb, urb->unlinked); 1188 - mutex_unlock(&u132->scheduler_lock); 1189 - u132_hcd_giveback_urb(u132, endp, urb, 0); 1190 - return; 1191 - } 1192 - } 1193 - 1194 - static void u132_hcd_initial_input_recv(void *data, struct urb *urb, u8 *buf, 1195 - int len, int toggle_bits, int error_count, int condition_code, 1196 - int repeat_number, int halted, int skipped, int actual, int non_null) 1197 - { 1198 - struct u132_endp *endp = data; 1199 - struct u132 *u132 = endp->u132; 1200 - u8 address = u132->addr[endp->usb_addr].address; 1201 - mutex_lock(&u132->scheduler_lock); 1202 - if (u132->going > 1) { 1203 - dev_err(&u132->platform_dev->dev, "device has been removed %d\n" 1204 - , u132->going); 1205 - mutex_unlock(&u132->scheduler_lock); 1206 - u132_hcd_forget_urb(u132, endp, urb, -ENODEV); 1207 - return; 1208 - } else if (endp->dequeueing) { 1209 - endp->dequeueing = 0; 1210 - mutex_unlock(&u132->scheduler_lock); 1211 - u132_hcd_giveback_urb(u132, endp, urb, -EINTR); 1212 - return; 1213 - } else if (u132->going > 0) { 1214 - dev_err(&u132->platform_dev->dev, "device is being removed " 1215 - "urb=%p\n", urb); 1216 - mutex_unlock(&u132->scheduler_lock); 1217 - u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); 1218 - return; 1219 - } else if (!urb->unlinked) { 1220 - int retval; 1221 - struct u132_ring *ring = endp->ring; 1222 - u8 *u = urb->transfer_buffer; 1223 - u8 *b = buf; 1224 - int L = len; 1225 - 1226 - while (L-- > 0) 1227 - *u++ = *b++; 1228 - 1229 - urb->actual_length = len; 1230 - mutex_unlock(&u132->scheduler_lock); 1231 - retval = usb_ftdi_elan_edset_empty(u132->platform_dev, 1232 - ring->number, endp, urb, address, endp->usb_endp, 0x3, 1233 - u132_hcd_initial_empty_sent); 1234 - if (retval != 0) 1235 - u132_hcd_giveback_urb(u132, endp, urb, retval); 1236 - return; 1237 - } else { 1238 - dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p " 1239 - "unlinked=%d\n", urb, urb->unlinked); 1240 - mutex_unlock(&u132->scheduler_lock); 1241 - u132_hcd_giveback_urb(u132, endp, urb, 0); 1242 - return; 1243 - } 1244 - } 1245 - 1246 - static void u132_hcd_initial_setup_sent(void *data, struct urb *urb, u8 *buf, 1247 - int len, int toggle_bits, int error_count, int condition_code, 1248 - int repeat_number, int halted, int skipped, int actual, int non_null) 1249 - { 1250 - struct u132_endp *endp = data; 1251 - struct u132 *u132 = endp->u132; 1252 - u8 address = u132->addr[endp->usb_addr].address; 1253 - mutex_lock(&u132->scheduler_lock); 1254 - if (u132->going > 1) { 1255 - dev_err(&u132->platform_dev->dev, "device has been removed %d\n" 1256 - , u132->going); 1257 - mutex_unlock(&u132->scheduler_lock); 1258 - u132_hcd_forget_urb(u132, endp, urb, -ENODEV); 1259 - return; 1260 - } else if (endp->dequeueing) { 1261 - endp->dequeueing = 0; 1262 - mutex_unlock(&u132->scheduler_lock); 1263 - u132_hcd_giveback_urb(u132, endp, urb, -EINTR); 1264 - return; 1265 - } else if (u132->going > 0) { 1266 - dev_err(&u132->platform_dev->dev, "device is being removed " 1267 - "urb=%p\n", urb); 1268 - mutex_unlock(&u132->scheduler_lock); 1269 - u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); 1270 - return; 1271 - } else if (!urb->unlinked) { 1272 - int retval; 1273 - struct u132_ring *ring = endp->ring; 1274 - mutex_unlock(&u132->scheduler_lock); 1275 - retval = usb_ftdi_elan_edset_input(u132->platform_dev, 1276 - ring->number, endp, urb, address, endp->usb_endp, 0, 1277 - u132_hcd_initial_input_recv); 1278 - if (retval != 0) 1279 - u132_hcd_giveback_urb(u132, endp, urb, retval); 1280 - return; 1281 - } else { 1282 - dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p " 1283 - "unlinked=%d\n", urb, urb->unlinked); 1284 - mutex_unlock(&u132->scheduler_lock); 1285 - u132_hcd_giveback_urb(u132, endp, urb, 0); 1286 - return; 1287 - } 1288 - } 1289 - 1290 - /* 1291 - * this work function is only executed from the work queue 1292 - * 1293 - */ 1294 - static void u132_hcd_ring_work_scheduler(struct work_struct *work) 1295 - { 1296 - struct u132_ring *ring = 1297 - container_of(work, struct u132_ring, scheduler.work); 1298 - struct u132 *u132 = ring->u132; 1299 - mutex_lock(&u132->scheduler_lock); 1300 - if (ring->in_use) { 1301 - mutex_unlock(&u132->scheduler_lock); 1302 - u132_ring_put_kref(u132, ring); 1303 - return; 1304 - } else if (ring->curr_endp) { 1305 - struct u132_endp *endp, *last_endp = ring->curr_endp; 1306 - unsigned long wakeup = 0; 1307 - list_for_each_entry(endp, &last_endp->endp_ring, endp_ring) { 1308 - if (endp->queue_next == endp->queue_last) { 1309 - } else if ((endp->delayed == 0) 1310 - || time_after_eq(jiffies, endp->jiffies)) { 1311 - ring->curr_endp = endp; 1312 - u132_endp_cancel_work(u132, last_endp); 1313 - u132_endp_queue_work(u132, last_endp, 0); 1314 - mutex_unlock(&u132->scheduler_lock); 1315 - u132_ring_put_kref(u132, ring); 1316 - return; 1317 - } else { 1318 - unsigned long delta = endp->jiffies - jiffies; 1319 - if (delta > wakeup) 1320 - wakeup = delta; 1321 - } 1322 - } 1323 - if (last_endp->queue_next == last_endp->queue_last) { 1324 - } else if ((last_endp->delayed == 0) || time_after_eq(jiffies, 1325 - last_endp->jiffies)) { 1326 - u132_endp_cancel_work(u132, last_endp); 1327 - u132_endp_queue_work(u132, last_endp, 0); 1328 - mutex_unlock(&u132->scheduler_lock); 1329 - u132_ring_put_kref(u132, ring); 1330 - return; 1331 - } else { 1332 - unsigned long delta = last_endp->jiffies - jiffies; 1333 - if (delta > wakeup) 1334 - wakeup = delta; 1335 - } 1336 - if (wakeup > 0) { 1337 - u132_ring_requeue_work(u132, ring, wakeup); 1338 - mutex_unlock(&u132->scheduler_lock); 1339 - return; 1340 - } else { 1341 - mutex_unlock(&u132->scheduler_lock); 1342 - u132_ring_put_kref(u132, ring); 1343 - return; 1344 - } 1345 - } else { 1346 - mutex_unlock(&u132->scheduler_lock); 1347 - u132_ring_put_kref(u132, ring); 1348 - return; 1349 - } 1350 - } 1351 - 1352 - static void u132_hcd_endp_work_scheduler(struct work_struct *work) 1353 - { 1354 - struct u132_ring *ring; 1355 - struct u132_endp *endp = 1356 - container_of(work, struct u132_endp, scheduler.work); 1357 - struct u132 *u132 = endp->u132; 1358 - mutex_lock(&u132->scheduler_lock); 1359 - ring = endp->ring; 1360 - if (endp->edset_flush) { 1361 - endp->edset_flush = 0; 1362 - if (endp->dequeueing) 1363 - usb_ftdi_elan_edset_flush(u132->platform_dev, 1364 - ring->number, endp); 1365 - mutex_unlock(&u132->scheduler_lock); 1366 - u132_endp_put_kref(u132, endp); 1367 - return; 1368 - } else if (endp->active) { 1369 - mutex_unlock(&u132->scheduler_lock); 1370 - u132_endp_put_kref(u132, endp); 1371 - return; 1372 - } else if (ring->in_use) { 1373 - mutex_unlock(&u132->scheduler_lock); 1374 - u132_endp_put_kref(u132, endp); 1375 - return; 1376 - } else if (endp->queue_next == endp->queue_last) { 1377 - mutex_unlock(&u132->scheduler_lock); 1378 - u132_endp_put_kref(u132, endp); 1379 - return; 1380 - } else if (endp->pipetype == PIPE_INTERRUPT) { 1381 - u8 address = u132->addr[endp->usb_addr].address; 1382 - if (ring->in_use) { 1383 - mutex_unlock(&u132->scheduler_lock); 1384 - u132_endp_put_kref(u132, endp); 1385 - return; 1386 - } else { 1387 - int retval; 1388 - struct urb *urb = endp->urb_list[ENDP_QUEUE_MASK & 1389 - endp->queue_next]; 1390 - endp->active = 1; 1391 - ring->curr_endp = endp; 1392 - ring->in_use = 1; 1393 - mutex_unlock(&u132->scheduler_lock); 1394 - retval = edset_single(u132, ring, endp, urb, address, 1395 - endp->toggle_bits, u132_hcd_interrupt_recv); 1396 - if (retval != 0) 1397 - u132_hcd_giveback_urb(u132, endp, urb, retval); 1398 - return; 1399 - } 1400 - } else if (endp->pipetype == PIPE_CONTROL) { 1401 - u8 address = u132->addr[endp->usb_addr].address; 1402 - if (ring->in_use) { 1403 - mutex_unlock(&u132->scheduler_lock); 1404 - u132_endp_put_kref(u132, endp); 1405 - return; 1406 - } else if (address == 0) { 1407 - int retval; 1408 - struct urb *urb = endp->urb_list[ENDP_QUEUE_MASK & 1409 - endp->queue_next]; 1410 - endp->active = 1; 1411 - ring->curr_endp = endp; 1412 - ring->in_use = 1; 1413 - mutex_unlock(&u132->scheduler_lock); 1414 - retval = edset_setup(u132, ring, endp, urb, address, 1415 - 0x2, u132_hcd_initial_setup_sent); 1416 - if (retval != 0) 1417 - u132_hcd_giveback_urb(u132, endp, urb, retval); 1418 - return; 1419 - } else if (endp->usb_addr == 0) { 1420 - int retval; 1421 - struct urb *urb = endp->urb_list[ENDP_QUEUE_MASK & 1422 - endp->queue_next]; 1423 - endp->active = 1; 1424 - ring->curr_endp = endp; 1425 - ring->in_use = 1; 1426 - mutex_unlock(&u132->scheduler_lock); 1427 - retval = edset_setup(u132, ring, endp, urb, 0, 0x2, 1428 - u132_hcd_enumeration_address_sent); 1429 - if (retval != 0) 1430 - u132_hcd_giveback_urb(u132, endp, urb, retval); 1431 - return; 1432 - } else { 1433 - int retval; 1434 - struct urb *urb = endp->urb_list[ENDP_QUEUE_MASK & 1435 - endp->queue_next]; 1436 - address = u132->addr[endp->usb_addr].address; 1437 - endp->active = 1; 1438 - ring->curr_endp = endp; 1439 - ring->in_use = 1; 1440 - mutex_unlock(&u132->scheduler_lock); 1441 - retval = edset_setup(u132, ring, endp, urb, address, 1442 - 0x2, u132_hcd_configure_setup_sent); 1443 - if (retval != 0) 1444 - u132_hcd_giveback_urb(u132, endp, urb, retval); 1445 - return; 1446 - } 1447 - } else { 1448 - if (endp->input) { 1449 - u8 address = u132->addr[endp->usb_addr].address; 1450 - if (ring->in_use) { 1451 - mutex_unlock(&u132->scheduler_lock); 1452 - u132_endp_put_kref(u132, endp); 1453 - return; 1454 - } else { 1455 - int retval; 1456 - struct urb *urb = endp->urb_list[ 1457 - ENDP_QUEUE_MASK & endp->queue_next]; 1458 - endp->active = 1; 1459 - ring->curr_endp = endp; 1460 - ring->in_use = 1; 1461 - mutex_unlock(&u132->scheduler_lock); 1462 - retval = edset_input(u132, ring, endp, urb, 1463 - address, endp->toggle_bits, 1464 - u132_hcd_bulk_input_recv); 1465 - if (retval == 0) { 1466 - } else 1467 - u132_hcd_giveback_urb(u132, endp, urb, 1468 - retval); 1469 - return; 1470 - } 1471 - } else { /* output pipe */ 1472 - u8 address = u132->addr[endp->usb_addr].address; 1473 - if (ring->in_use) { 1474 - mutex_unlock(&u132->scheduler_lock); 1475 - u132_endp_put_kref(u132, endp); 1476 - return; 1477 - } else { 1478 - int retval; 1479 - struct urb *urb = endp->urb_list[ 1480 - ENDP_QUEUE_MASK & endp->queue_next]; 1481 - endp->active = 1; 1482 - ring->curr_endp = endp; 1483 - ring->in_use = 1; 1484 - mutex_unlock(&u132->scheduler_lock); 1485 - retval = edset_output(u132, ring, endp, urb, 1486 - address, endp->toggle_bits, 1487 - u132_hcd_bulk_output_sent); 1488 - if (retval == 0) { 1489 - } else 1490 - u132_hcd_giveback_urb(u132, endp, urb, 1491 - retval); 1492 - return; 1493 - } 1494 - } 1495 - } 1496 - } 1497 - #ifdef CONFIG_PM 1498 - 1499 - static void port_power(struct u132 *u132, int pn, int is_on) 1500 - { 1501 - u132->port[pn].power = is_on; 1502 - } 1503 - 1504 - #endif 1505 - 1506 - static void u132_power(struct u132 *u132, int is_on) 1507 - { 1508 - struct usb_hcd *hcd = u132_to_hcd(u132) 1509 - ; /* hub is inactive unless the port is powered */ 1510 - if (is_on) { 1511 - if (u132->power) 1512 - return; 1513 - u132->power = 1; 1514 - } else { 1515 - u132->power = 0; 1516 - hcd->state = HC_STATE_HALT; 1517 - } 1518 - } 1519 - 1520 - static int u132_periodic_reinit(struct u132 *u132) 1521 - { 1522 - int retval; 1523 - u32 fi = u132->hc_fminterval & 0x03fff; 1524 - u32 fit; 1525 - u32 fminterval; 1526 - retval = u132_read_pcimem(u132, fminterval, &fminterval); 1527 - if (retval) 1528 - return retval; 1529 - fit = fminterval & FIT; 1530 - retval = u132_write_pcimem(u132, fminterval, 1531 - (fit ^ FIT) | u132->hc_fminterval); 1532 - if (retval) 1533 - return retval; 1534 - return u132_write_pcimem(u132, periodicstart, 1535 - ((9 * fi) / 10) & 0x3fff); 1536 - } 1537 - 1538 - static char *hcfs2string(int state) 1539 - { 1540 - switch (state) { 1541 - case OHCI_USB_RESET: 1542 - return "reset"; 1543 - case OHCI_USB_RESUME: 1544 - return "resume"; 1545 - case OHCI_USB_OPER: 1546 - return "operational"; 1547 - case OHCI_USB_SUSPEND: 1548 - return "suspend"; 1549 - } 1550 - return "?"; 1551 - } 1552 - 1553 - static int u132_init(struct u132 *u132) 1554 - { 1555 - int retval; 1556 - u32 control; 1557 - u132_disable(u132); 1558 - u132->next_statechange = jiffies; 1559 - retval = u132_write_pcimem(u132, intrdisable, OHCI_INTR_MIE); 1560 - if (retval) 1561 - return retval; 1562 - retval = u132_read_pcimem(u132, control, &control); 1563 - if (retval) 1564 - return retval; 1565 - if (u132->num_ports == 0) { 1566 - u32 rh_a = -1; 1567 - retval = u132_read_pcimem(u132, roothub.a, &rh_a); 1568 - if (retval) 1569 - return retval; 1570 - u132->num_ports = rh_a & RH_A_NDP; 1571 - retval = read_roothub_info(u132); 1572 - if (retval) 1573 - return retval; 1574 - } 1575 - if (u132->num_ports > MAX_U132_PORTS) 1576 - return -EINVAL; 1577 - 1578 - return 0; 1579 - } 1580 - 1581 - 1582 - /* Start an OHCI controller, set the BUS operational 1583 - * resets USB and controller 1584 - * enable interrupts 1585 - */ 1586 - static int u132_run(struct u132 *u132) 1587 - { 1588 - int retval; 1589 - u32 control; 1590 - u32 status; 1591 - u32 fminterval; 1592 - u32 periodicstart; 1593 - u32 cmdstatus; 1594 - u32 roothub_a; 1595 - int mask = OHCI_INTR_INIT; 1596 - int first = u132->hc_fminterval == 0; 1597 - int sleep_time = 0; 1598 - int reset_timeout = 30; /* ... allow extra time */ 1599 - u132_disable(u132); 1600 - if (first) { 1601 - u32 temp; 1602 - retval = u132_read_pcimem(u132, fminterval, &temp); 1603 - if (retval) 1604 - return retval; 1605 - u132->hc_fminterval = temp & 0x3fff; 1606 - u132->hc_fminterval |= FSMP(u132->hc_fminterval) << 16; 1607 - } 1608 - retval = u132_read_pcimem(u132, control, &u132->hc_control); 1609 - if (retval) 1610 - return retval; 1611 - dev_info(&u132->platform_dev->dev, "resetting from state '%s', control " 1612 - "= %08X\n", hcfs2string(u132->hc_control & OHCI_CTRL_HCFS), 1613 - u132->hc_control); 1614 - switch (u132->hc_control & OHCI_CTRL_HCFS) { 1615 - case OHCI_USB_OPER: 1616 - sleep_time = 0; 1617 - break; 1618 - case OHCI_USB_SUSPEND: 1619 - case OHCI_USB_RESUME: 1620 - u132->hc_control &= OHCI_CTRL_RWC; 1621 - u132->hc_control |= OHCI_USB_RESUME; 1622 - sleep_time = 10; 1623 - break; 1624 - default: 1625 - u132->hc_control &= OHCI_CTRL_RWC; 1626 - u132->hc_control |= OHCI_USB_RESET; 1627 - sleep_time = 50; 1628 - break; 1629 - } 1630 - retval = u132_write_pcimem(u132, control, u132->hc_control); 1631 - if (retval) 1632 - return retval; 1633 - retval = u132_read_pcimem(u132, control, &control); 1634 - if (retval) 1635 - return retval; 1636 - msleep(sleep_time); 1637 - retval = u132_read_pcimem(u132, roothub.a, &roothub_a); 1638 - if (retval) 1639 - return retval; 1640 - if (!(roothub_a & RH_A_NPS)) { 1641 - int temp; /* power down each port */ 1642 - for (temp = 0; temp < u132->num_ports; temp++) { 1643 - retval = u132_write_pcimem(u132, 1644 - roothub.portstatus[temp], RH_PS_LSDA); 1645 - if (retval) 1646 - return retval; 1647 - } 1648 - } 1649 - retval = u132_read_pcimem(u132, control, &control); 1650 - if (retval) 1651 - return retval; 1652 - retry: 1653 - retval = u132_read_pcimem(u132, cmdstatus, &status); 1654 - if (retval) 1655 - return retval; 1656 - retval = u132_write_pcimem(u132, cmdstatus, OHCI_HCR); 1657 - if (retval) 1658 - return retval; 1659 - extra: { 1660 - retval = u132_read_pcimem(u132, cmdstatus, &status); 1661 - if (retval) 1662 - return retval; 1663 - if (0 != (status & OHCI_HCR)) { 1664 - if (--reset_timeout == 0) { 1665 - dev_err(&u132->platform_dev->dev, "USB HC reset" 1666 - " timed out!\n"); 1667 - return -ENODEV; 1668 - } else { 1669 - msleep(5); 1670 - goto extra; 1671 - } 1672 - } 1673 - } 1674 - if (u132->flags & OHCI_QUIRK_INITRESET) { 1675 - retval = u132_write_pcimem(u132, control, u132->hc_control); 1676 - if (retval) 1677 - return retval; 1678 - retval = u132_read_pcimem(u132, control, &control); 1679 - if (retval) 1680 - return retval; 1681 - } 1682 - retval = u132_write_pcimem(u132, ed_controlhead, 0x00000000); 1683 - if (retval) 1684 - return retval; 1685 - retval = u132_write_pcimem(u132, ed_bulkhead, 0x11000000); 1686 - if (retval) 1687 - return retval; 1688 - retval = u132_write_pcimem(u132, hcca, 0x00000000); 1689 - if (retval) 1690 - return retval; 1691 - retval = u132_periodic_reinit(u132); 1692 - if (retval) 1693 - return retval; 1694 - retval = u132_read_pcimem(u132, fminterval, &fminterval); 1695 - if (retval) 1696 - return retval; 1697 - retval = u132_read_pcimem(u132, periodicstart, &periodicstart); 1698 - if (retval) 1699 - return retval; 1700 - if (0 == (fminterval & 0x3fff0000) || 0 == periodicstart) { 1701 - if (!(u132->flags & OHCI_QUIRK_INITRESET)) { 1702 - u132->flags |= OHCI_QUIRK_INITRESET; 1703 - goto retry; 1704 - } else 1705 - dev_err(&u132->platform_dev->dev, "init err(%08x %04x)" 1706 - "\n", fminterval, periodicstart); 1707 - } /* start controller operations */ 1708 - u132->hc_control &= OHCI_CTRL_RWC; 1709 - u132->hc_control |= OHCI_CONTROL_INIT | OHCI_CTRL_BLE | OHCI_USB_OPER; 1710 - retval = u132_write_pcimem(u132, control, u132->hc_control); 1711 - if (retval) 1712 - return retval; 1713 - retval = u132_write_pcimem(u132, cmdstatus, OHCI_BLF); 1714 - if (retval) 1715 - return retval; 1716 - retval = u132_read_pcimem(u132, cmdstatus, &cmdstatus); 1717 - if (retval) 1718 - return retval; 1719 - retval = u132_read_pcimem(u132, control, &control); 1720 - if (retval) 1721 - return retval; 1722 - u132_to_hcd(u132)->state = HC_STATE_RUNNING; 1723 - retval = u132_write_pcimem(u132, roothub.status, RH_HS_DRWE); 1724 - if (retval) 1725 - return retval; 1726 - retval = u132_write_pcimem(u132, intrstatus, mask); 1727 - if (retval) 1728 - return retval; 1729 - retval = u132_write_pcimem(u132, intrdisable, 1730 - OHCI_INTR_MIE | OHCI_INTR_OC | OHCI_INTR_RHSC | OHCI_INTR_FNO | 1731 - OHCI_INTR_UE | OHCI_INTR_RD | OHCI_INTR_SF | OHCI_INTR_WDH | 1732 - OHCI_INTR_SO); 1733 - if (retval) 1734 - return retval; /* handle root hub init quirks ... */ 1735 - retval = u132_read_pcimem(u132, roothub.a, &roothub_a); 1736 - if (retval) 1737 - return retval; 1738 - roothub_a &= ~(RH_A_PSM | RH_A_OCPM); 1739 - if (u132->flags & OHCI_QUIRK_SUPERIO) { 1740 - roothub_a |= RH_A_NOCP; 1741 - roothub_a &= ~(RH_A_POTPGT | RH_A_NPS); 1742 - retval = u132_write_pcimem(u132, roothub.a, roothub_a); 1743 - if (retval) 1744 - return retval; 1745 - } else if ((u132->flags & OHCI_QUIRK_AMD756) || distrust_firmware) { 1746 - roothub_a |= RH_A_NPS; 1747 - retval = u132_write_pcimem(u132, roothub.a, roothub_a); 1748 - if (retval) 1749 - return retval; 1750 - } 1751 - retval = u132_write_pcimem(u132, roothub.status, RH_HS_LPSC); 1752 - if (retval) 1753 - return retval; 1754 - retval = u132_write_pcimem(u132, roothub.b, 1755 - (roothub_a & RH_A_NPS) ? 0 : RH_B_PPCM); 1756 - if (retval) 1757 - return retval; 1758 - retval = u132_read_pcimem(u132, control, &control); 1759 - if (retval) 1760 - return retval; 1761 - mdelay((roothub_a >> 23) & 0x1fe); 1762 - u132_to_hcd(u132)->state = HC_STATE_RUNNING; 1763 - return 0; 1764 - } 1765 - 1766 - static void u132_hcd_stop(struct usb_hcd *hcd) 1767 - { 1768 - struct u132 *u132 = hcd_to_u132(hcd); 1769 - if (u132->going > 1) { 1770 - dev_err(&u132->platform_dev->dev, "u132 device %p(hcd=%p) has b" 1771 - "een removed %d\n", u132, hcd, u132->going); 1772 - } else if (u132->going > 0) { 1773 - dev_err(&u132->platform_dev->dev, "device hcd=%p is being remov" 1774 - "ed\n", hcd); 1775 - } else { 1776 - mutex_lock(&u132->sw_lock); 1777 - msleep(100); 1778 - u132_power(u132, 0); 1779 - mutex_unlock(&u132->sw_lock); 1780 - } 1781 - } 1782 - 1783 - static int u132_hcd_start(struct usb_hcd *hcd) 1784 - { 1785 - struct u132 *u132 = hcd_to_u132(hcd); 1786 - if (u132->going > 1) { 1787 - dev_err(&u132->platform_dev->dev, "device has been removed %d\n" 1788 - , u132->going); 1789 - return -ENODEV; 1790 - } else if (u132->going > 0) { 1791 - dev_err(&u132->platform_dev->dev, "device is being removed\n"); 1792 - return -ESHUTDOWN; 1793 - } else if (hcd->self.controller) { 1794 - int retval; 1795 - struct platform_device *pdev = 1796 - to_platform_device(hcd->self.controller); 1797 - u16 vendor = ((struct u132_platform_data *) 1798 - dev_get_platdata(&pdev->dev))->vendor; 1799 - u16 device = ((struct u132_platform_data *) 1800 - dev_get_platdata(&pdev->dev))->device; 1801 - mutex_lock(&u132->sw_lock); 1802 - msleep(10); 1803 - if (vendor == PCI_VENDOR_ID_AMD && device == 0x740c) { 1804 - u132->flags = OHCI_QUIRK_AMD756; 1805 - } else if (vendor == PCI_VENDOR_ID_OPTI && device == 0xc861) { 1806 - dev_err(&u132->platform_dev->dev, "WARNING: OPTi workar" 1807 - "ounds unavailable\n"); 1808 - } else if (vendor == PCI_VENDOR_ID_COMPAQ && device == 0xa0f8) 1809 - u132->flags |= OHCI_QUIRK_ZFMICRO; 1810 - retval = u132_run(u132); 1811 - if (retval) { 1812 - u132_disable(u132); 1813 - u132->going = 1; 1814 - } 1815 - msleep(100); 1816 - mutex_unlock(&u132->sw_lock); 1817 - return retval; 1818 - } else { 1819 - dev_err(&u132->platform_dev->dev, "platform_device missing\n"); 1820 - return -ENODEV; 1821 - } 1822 - } 1823 - 1824 - static int u132_hcd_reset(struct usb_hcd *hcd) 1825 - { 1826 - struct u132 *u132 = hcd_to_u132(hcd); 1827 - if (u132->going > 1) { 1828 - dev_err(&u132->platform_dev->dev, "device has been removed %d\n" 1829 - , u132->going); 1830 - return -ENODEV; 1831 - } else if (u132->going > 0) { 1832 - dev_err(&u132->platform_dev->dev, "device is being removed\n"); 1833 - return -ESHUTDOWN; 1834 - } else { 1835 - int retval; 1836 - mutex_lock(&u132->sw_lock); 1837 - retval = u132_init(u132); 1838 - if (retval) { 1839 - u132_disable(u132); 1840 - u132->going = 1; 1841 - } 1842 - mutex_unlock(&u132->sw_lock); 1843 - return retval; 1844 - } 1845 - } 1846 - 1847 - static int create_endpoint_and_queue_int(struct u132 *u132, 1848 - struct u132_udev *udev, struct urb *urb, 1849 - struct usb_device *usb_dev, u8 usb_addr, u8 usb_endp, u8 address, 1850 - gfp_t mem_flags) 1851 - { 1852 - struct u132_ring *ring; 1853 - unsigned long irqs; 1854 - int rc; 1855 - u8 endp_number; 1856 - struct u132_endp *endp = kmalloc(sizeof(struct u132_endp), mem_flags); 1857 - 1858 - if (!endp) 1859 - return -ENOMEM; 1860 - 1861 - spin_lock_init(&endp->queue_lock.slock); 1862 - spin_lock_irqsave(&endp->queue_lock.slock, irqs); 1863 - rc = usb_hcd_link_urb_to_ep(u132_to_hcd(u132), urb); 1864 - if (rc) { 1865 - spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); 1866 - kfree(endp); 1867 - return rc; 1868 - } 1869 - 1870 - endp_number = ++u132->num_endpoints; 1871 - urb->ep->hcpriv = u132->endp[endp_number - 1] = endp; 1872 - INIT_DELAYED_WORK(&endp->scheduler, u132_hcd_endp_work_scheduler); 1873 - INIT_LIST_HEAD(&endp->urb_more); 1874 - ring = endp->ring = &u132->ring[0]; 1875 - if (ring->curr_endp) { 1876 - list_add_tail(&endp->endp_ring, &ring->curr_endp->endp_ring); 1877 - } else { 1878 - INIT_LIST_HEAD(&endp->endp_ring); 1879 - ring->curr_endp = endp; 1880 - } 1881 - ring->length += 1; 1882 - endp->dequeueing = 0; 1883 - endp->edset_flush = 0; 1884 - endp->active = 0; 1885 - endp->delayed = 0; 1886 - endp->endp_number = endp_number; 1887 - endp->u132 = u132; 1888 - endp->hep = urb->ep; 1889 - endp->pipetype = usb_pipetype(urb->pipe); 1890 - u132_endp_init_kref(u132, endp); 1891 - if (usb_pipein(urb->pipe)) { 1892 - endp->toggle_bits = 0x2; 1893 - usb_settoggle(udev->usb_device, usb_endp, 0, 0); 1894 - endp->input = 1; 1895 - endp->output = 0; 1896 - udev->endp_number_in[usb_endp] = endp_number; 1897 - u132_udev_get_kref(u132, udev); 1898 - } else { 1899 - endp->toggle_bits = 0x2; 1900 - usb_settoggle(udev->usb_device, usb_endp, 1, 0); 1901 - endp->input = 0; 1902 - endp->output = 1; 1903 - udev->endp_number_out[usb_endp] = endp_number; 1904 - u132_udev_get_kref(u132, udev); 1905 - } 1906 - urb->hcpriv = u132; 1907 - endp->delayed = 1; 1908 - endp->jiffies = jiffies + msecs_to_jiffies(urb->interval); 1909 - endp->udev_number = address; 1910 - endp->usb_addr = usb_addr; 1911 - endp->usb_endp = usb_endp; 1912 - endp->queue_size = 1; 1913 - endp->queue_last = 0; 1914 - endp->queue_next = 0; 1915 - endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] = urb; 1916 - spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); 1917 - u132_endp_queue_work(u132, endp, msecs_to_jiffies(urb->interval)); 1918 - return 0; 1919 - } 1920 - 1921 - static int queue_int_on_old_endpoint(struct u132 *u132, 1922 - struct u132_udev *udev, struct urb *urb, 1923 - struct usb_device *usb_dev, struct u132_endp *endp, u8 usb_addr, 1924 - u8 usb_endp, u8 address) 1925 - { 1926 - urb->hcpriv = u132; 1927 - endp->delayed = 1; 1928 - endp->jiffies = jiffies + msecs_to_jiffies(urb->interval); 1929 - if (endp->queue_size++ < ENDP_QUEUE_SIZE) { 1930 - endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] = urb; 1931 - } else { 1932 - struct u132_urbq *urbq = kmalloc(sizeof(struct u132_urbq), 1933 - GFP_ATOMIC); 1934 - if (urbq == NULL) { 1935 - endp->queue_size -= 1; 1936 - return -ENOMEM; 1937 - } else { 1938 - list_add_tail(&urbq->urb_more, &endp->urb_more); 1939 - urbq->urb = urb; 1940 - } 1941 - } 1942 - return 0; 1943 - } 1944 - 1945 - static int create_endpoint_and_queue_bulk(struct u132 *u132, 1946 - struct u132_udev *udev, struct urb *urb, 1947 - struct usb_device *usb_dev, u8 usb_addr, u8 usb_endp, u8 address, 1948 - gfp_t mem_flags) 1949 - { 1950 - int ring_number; 1951 - struct u132_ring *ring; 1952 - unsigned long irqs; 1953 - int rc; 1954 - u8 endp_number; 1955 - struct u132_endp *endp = kmalloc(sizeof(struct u132_endp), mem_flags); 1956 - 1957 - if (!endp) 1958 - return -ENOMEM; 1959 - 1960 - spin_lock_init(&endp->queue_lock.slock); 1961 - spin_lock_irqsave(&endp->queue_lock.slock, irqs); 1962 - rc = usb_hcd_link_urb_to_ep(u132_to_hcd(u132), urb); 1963 - if (rc) { 1964 - spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); 1965 - kfree(endp); 1966 - return rc; 1967 - } 1968 - 1969 - endp_number = ++u132->num_endpoints; 1970 - urb->ep->hcpriv = u132->endp[endp_number - 1] = endp; 1971 - INIT_DELAYED_WORK(&endp->scheduler, u132_hcd_endp_work_scheduler); 1972 - INIT_LIST_HEAD(&endp->urb_more); 1973 - endp->dequeueing = 0; 1974 - endp->edset_flush = 0; 1975 - endp->active = 0; 1976 - endp->delayed = 0; 1977 - endp->endp_number = endp_number; 1978 - endp->u132 = u132; 1979 - endp->hep = urb->ep; 1980 - endp->pipetype = usb_pipetype(urb->pipe); 1981 - u132_endp_init_kref(u132, endp); 1982 - if (usb_pipein(urb->pipe)) { 1983 - endp->toggle_bits = 0x2; 1984 - usb_settoggle(udev->usb_device, usb_endp, 0, 0); 1985 - ring_number = 3; 1986 - endp->input = 1; 1987 - endp->output = 0; 1988 - udev->endp_number_in[usb_endp] = endp_number; 1989 - u132_udev_get_kref(u132, udev); 1990 - } else { 1991 - endp->toggle_bits = 0x2; 1992 - usb_settoggle(udev->usb_device, usb_endp, 1, 0); 1993 - ring_number = 2; 1994 - endp->input = 0; 1995 - endp->output = 1; 1996 - udev->endp_number_out[usb_endp] = endp_number; 1997 - u132_udev_get_kref(u132, udev); 1998 - } 1999 - ring = endp->ring = &u132->ring[ring_number - 1]; 2000 - if (ring->curr_endp) { 2001 - list_add_tail(&endp->endp_ring, &ring->curr_endp->endp_ring); 2002 - } else { 2003 - INIT_LIST_HEAD(&endp->endp_ring); 2004 - ring->curr_endp = endp; 2005 - } 2006 - ring->length += 1; 2007 - urb->hcpriv = u132; 2008 - endp->udev_number = address; 2009 - endp->usb_addr = usb_addr; 2010 - endp->usb_endp = usb_endp; 2011 - endp->queue_size = 1; 2012 - endp->queue_last = 0; 2013 - endp->queue_next = 0; 2014 - endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] = urb; 2015 - spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); 2016 - u132_endp_queue_work(u132, endp, 0); 2017 - return 0; 2018 - } 2019 - 2020 - static int queue_bulk_on_old_endpoint(struct u132 *u132, struct u132_udev *udev, 2021 - struct urb *urb, 2022 - struct usb_device *usb_dev, struct u132_endp *endp, u8 usb_addr, 2023 - u8 usb_endp, u8 address) 2024 - { 2025 - urb->hcpriv = u132; 2026 - if (endp->queue_size++ < ENDP_QUEUE_SIZE) { 2027 - endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] = urb; 2028 - } else { 2029 - struct u132_urbq *urbq = kmalloc(sizeof(struct u132_urbq), 2030 - GFP_ATOMIC); 2031 - if (urbq == NULL) { 2032 - endp->queue_size -= 1; 2033 - return -ENOMEM; 2034 - } else { 2035 - list_add_tail(&urbq->urb_more, &endp->urb_more); 2036 - urbq->urb = urb; 2037 - } 2038 - } 2039 - return 0; 2040 - } 2041 - 2042 - static int create_endpoint_and_queue_control(struct u132 *u132, 2043 - struct urb *urb, 2044 - struct usb_device *usb_dev, u8 usb_addr, u8 usb_endp, 2045 - gfp_t mem_flags) 2046 - { 2047 - struct u132_ring *ring; 2048 - unsigned long irqs; 2049 - int rc; 2050 - u8 endp_number; 2051 - struct u132_endp *endp = kmalloc(sizeof(struct u132_endp), mem_flags); 2052 - 2053 - if (!endp) 2054 - return -ENOMEM; 2055 - 2056 - spin_lock_init(&endp->queue_lock.slock); 2057 - spin_lock_irqsave(&endp->queue_lock.slock, irqs); 2058 - rc = usb_hcd_link_urb_to_ep(u132_to_hcd(u132), urb); 2059 - if (rc) { 2060 - spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); 2061 - kfree(endp); 2062 - return rc; 2063 - } 2064 - 2065 - endp_number = ++u132->num_endpoints; 2066 - urb->ep->hcpriv = u132->endp[endp_number - 1] = endp; 2067 - INIT_DELAYED_WORK(&endp->scheduler, u132_hcd_endp_work_scheduler); 2068 - INIT_LIST_HEAD(&endp->urb_more); 2069 - ring = endp->ring = &u132->ring[0]; 2070 - if (ring->curr_endp) { 2071 - list_add_tail(&endp->endp_ring, &ring->curr_endp->endp_ring); 2072 - } else { 2073 - INIT_LIST_HEAD(&endp->endp_ring); 2074 - ring->curr_endp = endp; 2075 - } 2076 - ring->length += 1; 2077 - endp->dequeueing = 0; 2078 - endp->edset_flush = 0; 2079 - endp->active = 0; 2080 - endp->delayed = 0; 2081 - endp->endp_number = endp_number; 2082 - endp->u132 = u132; 2083 - endp->hep = urb->ep; 2084 - u132_endp_init_kref(u132, endp); 2085 - u132_endp_get_kref(u132, endp); 2086 - if (usb_addr == 0) { 2087 - u8 address = u132->addr[usb_addr].address; 2088 - struct u132_udev *udev = &u132->udev[address]; 2089 - endp->udev_number = address; 2090 - endp->usb_addr = usb_addr; 2091 - endp->usb_endp = usb_endp; 2092 - endp->input = 1; 2093 - endp->output = 1; 2094 - endp->pipetype = usb_pipetype(urb->pipe); 2095 - u132_udev_init_kref(u132, udev); 2096 - u132_udev_get_kref(u132, udev); 2097 - udev->endp_number_in[usb_endp] = endp_number; 2098 - udev->endp_number_out[usb_endp] = endp_number; 2099 - urb->hcpriv = u132; 2100 - endp->queue_size = 1; 2101 - endp->queue_last = 0; 2102 - endp->queue_next = 0; 2103 - endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] = urb; 2104 - spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); 2105 - u132_endp_queue_work(u132, endp, 0); 2106 - return 0; 2107 - } else { /*(usb_addr > 0) */ 2108 - u8 address = u132->addr[usb_addr].address; 2109 - struct u132_udev *udev = &u132->udev[address]; 2110 - endp->udev_number = address; 2111 - endp->usb_addr = usb_addr; 2112 - endp->usb_endp = usb_endp; 2113 - endp->input = 1; 2114 - endp->output = 1; 2115 - endp->pipetype = usb_pipetype(urb->pipe); 2116 - u132_udev_get_kref(u132, udev); 2117 - udev->enumeration = 2; 2118 - udev->endp_number_in[usb_endp] = endp_number; 2119 - udev->endp_number_out[usb_endp] = endp_number; 2120 - urb->hcpriv = u132; 2121 - endp->queue_size = 1; 2122 - endp->queue_last = 0; 2123 - endp->queue_next = 0; 2124 - endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] = urb; 2125 - spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); 2126 - u132_endp_queue_work(u132, endp, 0); 2127 - return 0; 2128 - } 2129 - } 2130 - 2131 - static int queue_control_on_old_endpoint(struct u132 *u132, 2132 - struct urb *urb, 2133 - struct usb_device *usb_dev, struct u132_endp *endp, u8 usb_addr, 2134 - u8 usb_endp) 2135 - { 2136 - if (usb_addr == 0) { 2137 - if (usb_pipein(urb->pipe)) { 2138 - urb->hcpriv = u132; 2139 - if (endp->queue_size++ < ENDP_QUEUE_SIZE) { 2140 - endp->urb_list[ENDP_QUEUE_MASK & 2141 - endp->queue_last++] = urb; 2142 - } else { 2143 - struct u132_urbq *urbq = 2144 - kmalloc(sizeof(struct u132_urbq), 2145 - GFP_ATOMIC); 2146 - if (urbq == NULL) { 2147 - endp->queue_size -= 1; 2148 - return -ENOMEM; 2149 - } else { 2150 - list_add_tail(&urbq->urb_more, 2151 - &endp->urb_more); 2152 - urbq->urb = urb; 2153 - } 2154 - } 2155 - return 0; 2156 - } else { /* usb_pipeout(urb->pipe) */ 2157 - struct u132_addr *addr = &u132->addr[usb_dev->devnum]; 2158 - int I = MAX_U132_UDEVS; 2159 - int i = 0; 2160 - while (--I > 0) { 2161 - struct u132_udev *udev = &u132->udev[++i]; 2162 - if (udev->usb_device) { 2163 - continue; 2164 - } else { 2165 - udev->enumeration = 1; 2166 - u132->addr[0].address = i; 2167 - endp->udev_number = i; 2168 - udev->udev_number = i; 2169 - udev->usb_addr = usb_dev->devnum; 2170 - u132_udev_init_kref(u132, udev); 2171 - udev->endp_number_in[usb_endp] = 2172 - endp->endp_number; 2173 - u132_udev_get_kref(u132, udev); 2174 - udev->endp_number_out[usb_endp] = 2175 - endp->endp_number; 2176 - udev->usb_device = usb_dev; 2177 - ((u8 *) (urb->setup_packet))[2] = 2178 - addr->address = i; 2179 - u132_udev_get_kref(u132, udev); 2180 - break; 2181 - } 2182 - } 2183 - if (I == 0) { 2184 - dev_err(&u132->platform_dev->dev, "run out of d" 2185 - "evice space\n"); 2186 - return -EINVAL; 2187 - } 2188 - urb->hcpriv = u132; 2189 - if (endp->queue_size++ < ENDP_QUEUE_SIZE) { 2190 - endp->urb_list[ENDP_QUEUE_MASK & 2191 - endp->queue_last++] = urb; 2192 - } else { 2193 - struct u132_urbq *urbq = 2194 - kmalloc(sizeof(struct u132_urbq), 2195 - GFP_ATOMIC); 2196 - if (urbq == NULL) { 2197 - endp->queue_size -= 1; 2198 - return -ENOMEM; 2199 - } else { 2200 - list_add_tail(&urbq->urb_more, 2201 - &endp->urb_more); 2202 - urbq->urb = urb; 2203 - } 2204 - } 2205 - return 0; 2206 - } 2207 - } else { /*(usb_addr > 0) */ 2208 - u8 address = u132->addr[usb_addr].address; 2209 - struct u132_udev *udev = &u132->udev[address]; 2210 - urb->hcpriv = u132; 2211 - if (udev->enumeration != 2) 2212 - udev->enumeration = 2; 2213 - if (endp->queue_size++ < ENDP_QUEUE_SIZE) { 2214 - endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] = 2215 - urb; 2216 - } else { 2217 - struct u132_urbq *urbq = 2218 - kmalloc(sizeof(struct u132_urbq), GFP_ATOMIC); 2219 - if (urbq == NULL) { 2220 - endp->queue_size -= 1; 2221 - return -ENOMEM; 2222 - } else { 2223 - list_add_tail(&urbq->urb_more, &endp->urb_more); 2224 - urbq->urb = urb; 2225 - } 2226 - } 2227 - return 0; 2228 - } 2229 - } 2230 - 2231 - static int u132_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, 2232 - gfp_t mem_flags) 2233 - { 2234 - struct u132 *u132 = hcd_to_u132(hcd); 2235 - if (irqs_disabled()) { 2236 - if (gfpflags_allow_blocking(mem_flags)) { 2237 - printk(KERN_ERR "invalid context for function that might sleep\n"); 2238 - return -EINVAL; 2239 - } 2240 - } 2241 - if (u132->going > 1) { 2242 - dev_err(&u132->platform_dev->dev, "device has been removed %d\n" 2243 - , u132->going); 2244 - return -ENODEV; 2245 - } else if (u132->going > 0) { 2246 - dev_err(&u132->platform_dev->dev, "device is being removed " 2247 - "urb=%p\n", urb); 2248 - return -ESHUTDOWN; 2249 - } else { 2250 - u8 usb_addr = usb_pipedevice(urb->pipe); 2251 - u8 usb_endp = usb_pipeendpoint(urb->pipe); 2252 - struct usb_device *usb_dev = urb->dev; 2253 - if (usb_pipetype(urb->pipe) == PIPE_INTERRUPT) { 2254 - u8 address = u132->addr[usb_addr].address; 2255 - struct u132_udev *udev = &u132->udev[address]; 2256 - struct u132_endp *endp = urb->ep->hcpriv; 2257 - urb->actual_length = 0; 2258 - if (endp) { 2259 - unsigned long irqs; 2260 - int retval; 2261 - spin_lock_irqsave(&endp->queue_lock.slock, 2262 - irqs); 2263 - retval = usb_hcd_link_urb_to_ep(hcd, urb); 2264 - if (retval == 0) { 2265 - retval = queue_int_on_old_endpoint( 2266 - u132, udev, urb, 2267 - usb_dev, endp, 2268 - usb_addr, usb_endp, 2269 - address); 2270 - if (retval) 2271 - usb_hcd_unlink_urb_from_ep( 2272 - hcd, urb); 2273 - } 2274 - spin_unlock_irqrestore(&endp->queue_lock.slock, 2275 - irqs); 2276 - if (retval) { 2277 - return retval; 2278 - } else { 2279 - u132_endp_queue_work(u132, endp, 2280 - msecs_to_jiffies(urb->interval)) 2281 - ; 2282 - return 0; 2283 - } 2284 - } else if (u132->num_endpoints == MAX_U132_ENDPS) { 2285 - return -EINVAL; 2286 - } else { /*(endp == NULL) */ 2287 - return create_endpoint_and_queue_int(u132, udev, 2288 - urb, usb_dev, usb_addr, 2289 - usb_endp, address, mem_flags); 2290 - } 2291 - } else if (usb_pipetype(urb->pipe) == PIPE_ISOCHRONOUS) { 2292 - dev_err(&u132->platform_dev->dev, "the hardware does no" 2293 - "t support PIPE_ISOCHRONOUS\n"); 2294 - return -EINVAL; 2295 - } else if (usb_pipetype(urb->pipe) == PIPE_BULK) { 2296 - u8 address = u132->addr[usb_addr].address; 2297 - struct u132_udev *udev = &u132->udev[address]; 2298 - struct u132_endp *endp = urb->ep->hcpriv; 2299 - urb->actual_length = 0; 2300 - if (endp) { 2301 - unsigned long irqs; 2302 - int retval; 2303 - spin_lock_irqsave(&endp->queue_lock.slock, 2304 - irqs); 2305 - retval = usb_hcd_link_urb_to_ep(hcd, urb); 2306 - if (retval == 0) { 2307 - retval = queue_bulk_on_old_endpoint( 2308 - u132, udev, urb, 2309 - usb_dev, endp, 2310 - usb_addr, usb_endp, 2311 - address); 2312 - if (retval) 2313 - usb_hcd_unlink_urb_from_ep( 2314 - hcd, urb); 2315 - } 2316 - spin_unlock_irqrestore(&endp->queue_lock.slock, 2317 - irqs); 2318 - if (retval) { 2319 - return retval; 2320 - } else { 2321 - u132_endp_queue_work(u132, endp, 0); 2322 - return 0; 2323 - } 2324 - } else if (u132->num_endpoints == MAX_U132_ENDPS) { 2325 - return -EINVAL; 2326 - } else 2327 - return create_endpoint_and_queue_bulk(u132, 2328 - udev, urb, usb_dev, usb_addr, 2329 - usb_endp, address, mem_flags); 2330 - } else { 2331 - struct u132_endp *endp = urb->ep->hcpriv; 2332 - u16 urb_size = 8; 2333 - u8 *b = urb->setup_packet; 2334 - int i = 0; 2335 - char data[30 * 3 + 4]; 2336 - char *d = data; 2337 - int m = (sizeof(data) - 1) / 3; 2338 - int l = 0; 2339 - data[0] = 0; 2340 - while (urb_size-- > 0) { 2341 - if (i > m) { 2342 - } else if (i++ < m) { 2343 - int w = sprintf(d, " %02X", *b++); 2344 - d += w; 2345 - l += w; 2346 - } else 2347 - d += sprintf(d, " .."); 2348 - } 2349 - if (endp) { 2350 - unsigned long irqs; 2351 - int retval; 2352 - spin_lock_irqsave(&endp->queue_lock.slock, 2353 - irqs); 2354 - retval = usb_hcd_link_urb_to_ep(hcd, urb); 2355 - if (retval == 0) { 2356 - retval = queue_control_on_old_endpoint( 2357 - u132, urb, usb_dev, 2358 - endp, usb_addr, 2359 - usb_endp); 2360 - if (retval) 2361 - usb_hcd_unlink_urb_from_ep( 2362 - hcd, urb); 2363 - } 2364 - spin_unlock_irqrestore(&endp->queue_lock.slock, 2365 - irqs); 2366 - if (retval) { 2367 - return retval; 2368 - } else { 2369 - u132_endp_queue_work(u132, endp, 0); 2370 - return 0; 2371 - } 2372 - } else if (u132->num_endpoints == MAX_U132_ENDPS) { 2373 - return -EINVAL; 2374 - } else 2375 - return create_endpoint_and_queue_control(u132, 2376 - urb, usb_dev, usb_addr, usb_endp, 2377 - mem_flags); 2378 - } 2379 - } 2380 - } 2381 - 2382 - static int dequeue_from_overflow_chain(struct u132 *u132, 2383 - struct u132_endp *endp, struct urb *urb) 2384 - { 2385 - struct u132_urbq *urbq; 2386 - 2387 - list_for_each_entry(urbq, &endp->urb_more, urb_more) { 2388 - if (urbq->urb == urb) { 2389 - struct usb_hcd *hcd = u132_to_hcd(u132); 2390 - list_del(&urbq->urb_more); 2391 - endp->queue_size -= 1; 2392 - urb->error_count = 0; 2393 - usb_hcd_giveback_urb(hcd, urb, 0); 2394 - return 0; 2395 - } 2396 - } 2397 - dev_err(&u132->platform_dev->dev, "urb=%p not found in endp[%d]=%p ring" 2398 - "[%d] %c%c usb_endp=%d usb_addr=%d size=%d next=%04X last=%04X" 2399 - "\n", urb, endp->endp_number, endp, endp->ring->number, 2400 - endp->input ? 'I' : ' ', endp->output ? 'O' : ' ', 2401 - endp->usb_endp, endp->usb_addr, endp->queue_size, 2402 - endp->queue_next, endp->queue_last); 2403 - return -EINVAL; 2404 - } 2405 - 2406 - static int u132_endp_urb_dequeue(struct u132 *u132, struct u132_endp *endp, 2407 - struct urb *urb, int status) 2408 - { 2409 - unsigned long irqs; 2410 - int rc; 2411 - 2412 - spin_lock_irqsave(&endp->queue_lock.slock, irqs); 2413 - rc = usb_hcd_check_unlink_urb(u132_to_hcd(u132), urb, status); 2414 - if (rc) { 2415 - spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); 2416 - return rc; 2417 - } 2418 - if (endp->queue_size == 0) { 2419 - dev_err(&u132->platform_dev->dev, "urb=%p not found in endp[%d]" 2420 - "=%p ring[%d] %c%c usb_endp=%d usb_addr=%d\n", urb, 2421 - endp->endp_number, endp, endp->ring->number, 2422 - endp->input ? 'I' : ' ', endp->output ? 'O' : ' ', 2423 - endp->usb_endp, endp->usb_addr); 2424 - spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); 2425 - return -EINVAL; 2426 - } 2427 - if (urb == endp->urb_list[ENDP_QUEUE_MASK & endp->queue_next]) { 2428 - if (endp->active) { 2429 - endp->dequeueing = 1; 2430 - endp->edset_flush = 1; 2431 - u132_endp_queue_work(u132, endp, 0); 2432 - spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); 2433 - return 0; 2434 - } else { 2435 - spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); 2436 - u132_hcd_abandon_urb(u132, endp, urb, status); 2437 - return 0; 2438 - } 2439 - } else { 2440 - u16 queue_list = 0; 2441 - u16 queue_size = endp->queue_size; 2442 - u16 queue_scan = endp->queue_next; 2443 - struct urb **urb_slot = NULL; 2444 - while (++queue_list < ENDP_QUEUE_SIZE && --queue_size > 0) { 2445 - if (urb == endp->urb_list[ENDP_QUEUE_MASK & 2446 - ++queue_scan]) { 2447 - urb_slot = &endp->urb_list[ENDP_QUEUE_MASK & 2448 - queue_scan]; 2449 - break; 2450 - } 2451 - } 2452 - while (++queue_list < ENDP_QUEUE_SIZE && --queue_size > 0) { 2453 - *urb_slot = endp->urb_list[ENDP_QUEUE_MASK & 2454 - ++queue_scan]; 2455 - urb_slot = &endp->urb_list[ENDP_QUEUE_MASK & 2456 - queue_scan]; 2457 - } 2458 - if (urb_slot) { 2459 - struct usb_hcd *hcd = u132_to_hcd(u132); 2460 - 2461 - usb_hcd_unlink_urb_from_ep(hcd, urb); 2462 - endp->queue_size -= 1; 2463 - if (list_empty(&endp->urb_more)) { 2464 - spin_unlock_irqrestore(&endp->queue_lock.slock, 2465 - irqs); 2466 - } else { 2467 - struct list_head *next = endp->urb_more.next; 2468 - struct u132_urbq *urbq = list_entry(next, 2469 - struct u132_urbq, urb_more); 2470 - list_del(next); 2471 - *urb_slot = urbq->urb; 2472 - spin_unlock_irqrestore(&endp->queue_lock.slock, 2473 - irqs); 2474 - kfree(urbq); 2475 - } 2476 - urb->error_count = 0; 2477 - usb_hcd_giveback_urb(hcd, urb, status); 2478 - return 0; 2479 - } else if (list_empty(&endp->urb_more)) { 2480 - dev_err(&u132->platform_dev->dev, "urb=%p not found in " 2481 - "endp[%d]=%p ring[%d] %c%c usb_endp=%d usb_addr" 2482 - "=%d size=%d next=%04X last=%04X\n", urb, 2483 - endp->endp_number, endp, endp->ring->number, 2484 - endp->input ? 'I' : ' ', 2485 - endp->output ? 'O' : ' ', endp->usb_endp, 2486 - endp->usb_addr, endp->queue_size, 2487 - endp->queue_next, endp->queue_last); 2488 - spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); 2489 - return -EINVAL; 2490 - } else { 2491 - int retval; 2492 - 2493 - usb_hcd_unlink_urb_from_ep(u132_to_hcd(u132), urb); 2494 - retval = dequeue_from_overflow_chain(u132, endp, 2495 - urb); 2496 - spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); 2497 - return retval; 2498 - } 2499 - } 2500 - } 2501 - 2502 - static int u132_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) 2503 - { 2504 - struct u132 *u132 = hcd_to_u132(hcd); 2505 - if (u132->going > 2) { 2506 - dev_err(&u132->platform_dev->dev, "device has been removed %d\n" 2507 - , u132->going); 2508 - return -ENODEV; 2509 - } else { 2510 - u8 usb_addr = usb_pipedevice(urb->pipe); 2511 - u8 usb_endp = usb_pipeendpoint(urb->pipe); 2512 - u8 address = u132->addr[usb_addr].address; 2513 - struct u132_udev *udev = &u132->udev[address]; 2514 - if (usb_pipein(urb->pipe)) { 2515 - u8 endp_number = udev->endp_number_in[usb_endp]; 2516 - struct u132_endp *endp = u132->endp[endp_number - 1]; 2517 - return u132_endp_urb_dequeue(u132, endp, urb, status); 2518 - } else { 2519 - u8 endp_number = udev->endp_number_out[usb_endp]; 2520 - struct u132_endp *endp = u132->endp[endp_number - 1]; 2521 - return u132_endp_urb_dequeue(u132, endp, urb, status); 2522 - } 2523 - } 2524 - } 2525 - 2526 - static void u132_endpoint_disable(struct usb_hcd *hcd, 2527 - struct usb_host_endpoint *hep) 2528 - { 2529 - struct u132 *u132 = hcd_to_u132(hcd); 2530 - if (u132->going > 2) { 2531 - dev_err(&u132->platform_dev->dev, "u132 device %p(hcd=%p hep=%p" 2532 - ") has been removed %d\n", u132, hcd, hep, 2533 - u132->going); 2534 - } else { 2535 - struct u132_endp *endp = hep->hcpriv; 2536 - if (endp) 2537 - u132_endp_put_kref(u132, endp); 2538 - } 2539 - } 2540 - 2541 - static int u132_get_frame(struct usb_hcd *hcd) 2542 - { 2543 - struct u132 *u132 = hcd_to_u132(hcd); 2544 - if (u132->going > 1) { 2545 - dev_err(&u132->platform_dev->dev, "device has been removed %d\n" 2546 - , u132->going); 2547 - return -ENODEV; 2548 - } else if (u132->going > 0) { 2549 - dev_err(&u132->platform_dev->dev, "device is being removed\n"); 2550 - return -ESHUTDOWN; 2551 - } else { 2552 - dev_err(&u132->platform_dev->dev, "TODO: u132_get_frame\n"); 2553 - mdelay(100); 2554 - return 0; 2555 - } 2556 - } 2557 - 2558 - static int u132_roothub_descriptor(struct u132 *u132, 2559 - struct usb_hub_descriptor *desc) 2560 - { 2561 - int retval; 2562 - u16 temp; 2563 - u32 rh_a = -1; 2564 - u32 rh_b = -1; 2565 - retval = u132_read_pcimem(u132, roothub.a, &rh_a); 2566 - if (retval) 2567 - return retval; 2568 - desc->bDescriptorType = USB_DT_HUB; 2569 - desc->bPwrOn2PwrGood = (rh_a & RH_A_POTPGT) >> 24; 2570 - desc->bHubContrCurrent = 0; 2571 - desc->bNbrPorts = u132->num_ports; 2572 - temp = 1 + (u132->num_ports / 8); 2573 - desc->bDescLength = 7 + 2 * temp; 2574 - temp = HUB_CHAR_COMMON_LPSM | HUB_CHAR_COMMON_OCPM; 2575 - if (rh_a & RH_A_NPS) 2576 - temp |= HUB_CHAR_NO_LPSM; 2577 - if (rh_a & RH_A_PSM) 2578 - temp |= HUB_CHAR_INDV_PORT_LPSM; 2579 - if (rh_a & RH_A_NOCP) 2580 - temp |= HUB_CHAR_NO_OCPM; 2581 - else if (rh_a & RH_A_OCPM) 2582 - temp |= HUB_CHAR_INDV_PORT_OCPM; 2583 - desc->wHubCharacteristics = cpu_to_le16(temp); 2584 - retval = u132_read_pcimem(u132, roothub.b, &rh_b); 2585 - if (retval) 2586 - return retval; 2587 - memset(desc->u.hs.DeviceRemovable, 0xff, 2588 - sizeof(desc->u.hs.DeviceRemovable)); 2589 - desc->u.hs.DeviceRemovable[0] = rh_b & RH_B_DR; 2590 - if (u132->num_ports > 7) { 2591 - desc->u.hs.DeviceRemovable[1] = (rh_b & RH_B_DR) >> 8; 2592 - desc->u.hs.DeviceRemovable[2] = 0xff; 2593 - } else 2594 - desc->u.hs.DeviceRemovable[1] = 0xff; 2595 - return 0; 2596 - } 2597 - 2598 - static int u132_roothub_status(struct u132 *u132, __le32 *desc) 2599 - { 2600 - u32 rh_status = -1; 2601 - int ret_status = u132_read_pcimem(u132, roothub.status, &rh_status); 2602 - *desc = cpu_to_le32(rh_status); 2603 - return ret_status; 2604 - } 2605 - 2606 - static int u132_roothub_portstatus(struct u132 *u132, __le32 *desc, u16 wIndex) 2607 - { 2608 - if (wIndex == 0 || wIndex > u132->num_ports) { 2609 - return -EINVAL; 2610 - } else { 2611 - int port = wIndex - 1; 2612 - u32 rh_portstatus = -1; 2613 - int ret_portstatus = u132_read_pcimem(u132, 2614 - roothub.portstatus[port], &rh_portstatus); 2615 - *desc = cpu_to_le32(rh_portstatus); 2616 - if (*(u16 *) (desc + 2)) { 2617 - dev_info(&u132->platform_dev->dev, "Port %d Status Chan" 2618 - "ge = %08X\n", port, *desc); 2619 - } 2620 - return ret_portstatus; 2621 - } 2622 - } 2623 - 2624 - 2625 - /* this timer value might be vendor-specific ... */ 2626 - #define PORT_RESET_HW_MSEC 10 2627 - #define PORT_RESET_MSEC 10 2628 - /* wrap-aware logic morphed from <linux/jiffies.h> */ 2629 - #define tick_before(t1, t2) ((s16)(((s16)(t1))-((s16)(t2))) < 0) 2630 - static int u132_roothub_portreset(struct u132 *u132, int port_index) 2631 - { 2632 - int retval; 2633 - u32 fmnumber; 2634 - u16 now; 2635 - u16 reset_done; 2636 - retval = u132_read_pcimem(u132, fmnumber, &fmnumber); 2637 - if (retval) 2638 - return retval; 2639 - now = fmnumber; 2640 - reset_done = now + PORT_RESET_MSEC; 2641 - do { 2642 - u32 portstat; 2643 - do { 2644 - retval = u132_read_pcimem(u132, 2645 - roothub.portstatus[port_index], &portstat); 2646 - if (retval) 2647 - return retval; 2648 - if (RH_PS_PRS & portstat) 2649 - continue; 2650 - else 2651 - break; 2652 - } while (tick_before(now, reset_done)); 2653 - if (RH_PS_PRS & portstat) 2654 - return -ENODEV; 2655 - if (RH_PS_CCS & portstat) { 2656 - if (RH_PS_PRSC & portstat) { 2657 - retval = u132_write_pcimem(u132, 2658 - roothub.portstatus[port_index], 2659 - RH_PS_PRSC); 2660 - if (retval) 2661 - return retval; 2662 - } 2663 - } else 2664 - break; /* start the next reset, 2665 - sleep till it's probably done */ 2666 - retval = u132_write_pcimem(u132, roothub.portstatus[port_index], 2667 - RH_PS_PRS); 2668 - if (retval) 2669 - return retval; 2670 - msleep(PORT_RESET_HW_MSEC); 2671 - retval = u132_read_pcimem(u132, fmnumber, &fmnumber); 2672 - if (retval) 2673 - return retval; 2674 - now = fmnumber; 2675 - } while (tick_before(now, reset_done)); 2676 - return 0; 2677 - } 2678 - 2679 - static int u132_roothub_setportfeature(struct u132 *u132, u16 wValue, 2680 - u16 wIndex) 2681 - { 2682 - if (wIndex == 0 || wIndex > u132->num_ports) { 2683 - return -EINVAL; 2684 - } else { 2685 - int port_index = wIndex - 1; 2686 - struct u132_port *port = &u132->port[port_index]; 2687 - port->Status &= ~(1 << wValue); 2688 - switch (wValue) { 2689 - case USB_PORT_FEAT_SUSPEND: 2690 - return u132_write_pcimem(u132, 2691 - roothub.portstatus[port_index], RH_PS_PSS); 2692 - case USB_PORT_FEAT_POWER: 2693 - return u132_write_pcimem(u132, 2694 - roothub.portstatus[port_index], RH_PS_PPS); 2695 - case USB_PORT_FEAT_RESET: 2696 - return u132_roothub_portreset(u132, port_index); 2697 - default: 2698 - return -EPIPE; 2699 - } 2700 - } 2701 - } 2702 - 2703 - static int u132_roothub_clearportfeature(struct u132 *u132, u16 wValue, 2704 - u16 wIndex) 2705 - { 2706 - if (wIndex == 0 || wIndex > u132->num_ports) { 2707 - return -EINVAL; 2708 - } else { 2709 - int port_index = wIndex - 1; 2710 - u32 temp; 2711 - struct u132_port *port = &u132->port[port_index]; 2712 - port->Status &= ~(1 << wValue); 2713 - switch (wValue) { 2714 - case USB_PORT_FEAT_ENABLE: 2715 - temp = RH_PS_CCS; 2716 - break; 2717 - case USB_PORT_FEAT_C_ENABLE: 2718 - temp = RH_PS_PESC; 2719 - break; 2720 - case USB_PORT_FEAT_SUSPEND: 2721 - temp = RH_PS_POCI; 2722 - if ((u132->hc_control & OHCI_CTRL_HCFS) 2723 - != OHCI_USB_OPER) { 2724 - dev_err(&u132->platform_dev->dev, "TODO resume_" 2725 - "root_hub\n"); 2726 - } 2727 - break; 2728 - case USB_PORT_FEAT_C_SUSPEND: 2729 - temp = RH_PS_PSSC; 2730 - break; 2731 - case USB_PORT_FEAT_POWER: 2732 - temp = RH_PS_LSDA; 2733 - break; 2734 - case USB_PORT_FEAT_C_CONNECTION: 2735 - temp = RH_PS_CSC; 2736 - break; 2737 - case USB_PORT_FEAT_C_OVER_CURRENT: 2738 - temp = RH_PS_OCIC; 2739 - break; 2740 - case USB_PORT_FEAT_C_RESET: 2741 - temp = RH_PS_PRSC; 2742 - break; 2743 - default: 2744 - return -EPIPE; 2745 - } 2746 - return u132_write_pcimem(u132, roothub.portstatus[port_index], 2747 - temp); 2748 - } 2749 - } 2750 - 2751 - 2752 - /* the virtual root hub timer IRQ checks for hub status*/ 2753 - static int u132_hub_status_data(struct usb_hcd *hcd, char *buf) 2754 - { 2755 - struct u132 *u132 = hcd_to_u132(hcd); 2756 - if (u132->going > 1) { 2757 - dev_err(&u132->platform_dev->dev, "device hcd=%p has been remov" 2758 - "ed %d\n", hcd, u132->going); 2759 - return -ENODEV; 2760 - } else if (u132->going > 0) { 2761 - dev_err(&u132->platform_dev->dev, "device hcd=%p is being remov" 2762 - "ed\n", hcd); 2763 - return -ESHUTDOWN; 2764 - } else { 2765 - int i, changed = 0, length = 1; 2766 - if (u132->flags & OHCI_QUIRK_AMD756) { 2767 - if ((u132->hc_roothub_a & RH_A_NDP) > MAX_ROOT_PORTS) { 2768 - dev_err(&u132->platform_dev->dev, "bogus NDP, r" 2769 - "ereads as NDP=%d\n", 2770 - u132->hc_roothub_a & RH_A_NDP); 2771 - goto done; 2772 - } 2773 - } 2774 - if (u132->hc_roothub_status & (RH_HS_LPSC | RH_HS_OCIC)) 2775 - buf[0] = changed = 1; 2776 - else 2777 - buf[0] = 0; 2778 - if (u132->num_ports > 7) { 2779 - buf[1] = 0; 2780 - length++; 2781 - } 2782 - for (i = 0; i < u132->num_ports; i++) { 2783 - if (u132->hc_roothub_portstatus[i] & (RH_PS_CSC | 2784 - RH_PS_PESC | RH_PS_PSSC | RH_PS_OCIC | 2785 - RH_PS_PRSC)) { 2786 - changed = 1; 2787 - if (i < 7) 2788 - buf[0] |= 1 << (i + 1); 2789 - else 2790 - buf[1] |= 1 << (i - 7); 2791 - continue; 2792 - } 2793 - if (!(u132->hc_roothub_portstatus[i] & RH_PS_CCS)) 2794 - continue; 2795 - 2796 - if ((u132->hc_roothub_portstatus[i] & RH_PS_PSS)) 2797 - continue; 2798 - } 2799 - done: 2800 - return changed ? length : 0; 2801 - } 2802 - } 2803 - 2804 - static int u132_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, 2805 - u16 wIndex, char *buf, u16 wLength) 2806 - { 2807 - struct u132 *u132 = hcd_to_u132(hcd); 2808 - if (u132->going > 1) { 2809 - dev_err(&u132->platform_dev->dev, "device has been removed %d\n" 2810 - , u132->going); 2811 - return -ENODEV; 2812 - } else if (u132->going > 0) { 2813 - dev_err(&u132->platform_dev->dev, "device is being removed\n"); 2814 - return -ESHUTDOWN; 2815 - } else { 2816 - int retval = 0; 2817 - mutex_lock(&u132->sw_lock); 2818 - switch (typeReq) { 2819 - case ClearHubFeature: 2820 - switch (wValue) { 2821 - case C_HUB_OVER_CURRENT: 2822 - case C_HUB_LOCAL_POWER: 2823 - break; 2824 - default: 2825 - goto stall; 2826 - } 2827 - break; 2828 - case SetHubFeature: 2829 - switch (wValue) { 2830 - case C_HUB_OVER_CURRENT: 2831 - case C_HUB_LOCAL_POWER: 2832 - break; 2833 - default: 2834 - goto stall; 2835 - } 2836 - break; 2837 - case ClearPortFeature:{ 2838 - retval = u132_roothub_clearportfeature(u132, 2839 - wValue, wIndex); 2840 - if (retval) 2841 - goto error; 2842 - break; 2843 - } 2844 - case GetHubDescriptor:{ 2845 - retval = u132_roothub_descriptor(u132, 2846 - (struct usb_hub_descriptor *)buf); 2847 - if (retval) 2848 - goto error; 2849 - break; 2850 - } 2851 - case GetHubStatus:{ 2852 - retval = u132_roothub_status(u132, 2853 - (__le32 *) buf); 2854 - if (retval) 2855 - goto error; 2856 - break; 2857 - } 2858 - case GetPortStatus:{ 2859 - retval = u132_roothub_portstatus(u132, 2860 - (__le32 *) buf, wIndex); 2861 - if (retval) 2862 - goto error; 2863 - break; 2864 - } 2865 - case SetPortFeature:{ 2866 - retval = u132_roothub_setportfeature(u132, 2867 - wValue, wIndex); 2868 - if (retval) 2869 - goto error; 2870 - break; 2871 - } 2872 - default: 2873 - goto stall; 2874 - error: 2875 - u132_disable(u132); 2876 - u132->going = 1; 2877 - break; 2878 - stall: 2879 - retval = -EPIPE; 2880 - break; 2881 - } 2882 - mutex_unlock(&u132->sw_lock); 2883 - return retval; 2884 - } 2885 - } 2886 - 2887 - static int u132_start_port_reset(struct usb_hcd *hcd, unsigned port_num) 2888 - { 2889 - struct u132 *u132 = hcd_to_u132(hcd); 2890 - if (u132->going > 1) { 2891 - dev_err(&u132->platform_dev->dev, "device has been removed %d\n" 2892 - , u132->going); 2893 - return -ENODEV; 2894 - } else if (u132->going > 0) { 2895 - dev_err(&u132->platform_dev->dev, "device is being removed\n"); 2896 - return -ESHUTDOWN; 2897 - } else 2898 - return 0; 2899 - } 2900 - 2901 - 2902 - #ifdef CONFIG_PM 2903 - static int u132_bus_suspend(struct usb_hcd *hcd) 2904 - { 2905 - struct u132 *u132 = hcd_to_u132(hcd); 2906 - if (u132->going > 1) { 2907 - dev_err(&u132->platform_dev->dev, "device has been removed %d\n" 2908 - , u132->going); 2909 - return -ENODEV; 2910 - } else if (u132->going > 0) { 2911 - dev_err(&u132->platform_dev->dev, "device is being removed\n"); 2912 - return -ESHUTDOWN; 2913 - } else 2914 - return 0; 2915 - } 2916 - 2917 - static int u132_bus_resume(struct usb_hcd *hcd) 2918 - { 2919 - struct u132 *u132 = hcd_to_u132(hcd); 2920 - if (u132->going > 1) { 2921 - dev_err(&u132->platform_dev->dev, "device has been removed %d\n" 2922 - , u132->going); 2923 - return -ENODEV; 2924 - } else if (u132->going > 0) { 2925 - dev_err(&u132->platform_dev->dev, "device is being removed\n"); 2926 - return -ESHUTDOWN; 2927 - } else 2928 - return 0; 2929 - } 2930 - 2931 - #else 2932 - #define u132_bus_suspend NULL 2933 - #define u132_bus_resume NULL 2934 - #endif 2935 - static const struct hc_driver u132_hc_driver = { 2936 - .description = hcd_name, 2937 - .hcd_priv_size = sizeof(struct u132), 2938 - .irq = NULL, 2939 - .flags = HCD_USB11 | HCD_MEMORY, 2940 - .reset = u132_hcd_reset, 2941 - .start = u132_hcd_start, 2942 - .stop = u132_hcd_stop, 2943 - .urb_enqueue = u132_urb_enqueue, 2944 - .urb_dequeue = u132_urb_dequeue, 2945 - .endpoint_disable = u132_endpoint_disable, 2946 - .get_frame_number = u132_get_frame, 2947 - .hub_status_data = u132_hub_status_data, 2948 - .hub_control = u132_hub_control, 2949 - .bus_suspend = u132_bus_suspend, 2950 - .bus_resume = u132_bus_resume, 2951 - .start_port_reset = u132_start_port_reset, 2952 - }; 2953 - 2954 - /* 2955 - * This function may be called by the USB core whilst the "usb_all_devices_rwsem" 2956 - * is held for writing, thus this module must not call usb_remove_hcd() 2957 - * synchronously - but instead should immediately stop activity to the 2958 - * device and asynchronously call usb_remove_hcd() 2959 - */ 2960 - static int u132_remove(struct platform_device *pdev) 2961 - { 2962 - struct usb_hcd *hcd = platform_get_drvdata(pdev); 2963 - if (hcd) { 2964 - struct u132 *u132 = hcd_to_u132(hcd); 2965 - if (u132->going++ > 1) { 2966 - dev_err(&u132->platform_dev->dev, "already being remove" 2967 - "d\n"); 2968 - return -ENODEV; 2969 - } else { 2970 - int rings = MAX_U132_RINGS; 2971 - int endps = MAX_U132_ENDPS; 2972 - dev_err(&u132->platform_dev->dev, "removing device u132" 2973 - ".%d\n", u132->sequence_num); 2974 - msleep(100); 2975 - mutex_lock(&u132->sw_lock); 2976 - u132_monitor_cancel_work(u132); 2977 - while (rings-- > 0) { 2978 - struct u132_ring *ring = &u132->ring[rings]; 2979 - u132_ring_cancel_work(u132, ring); 2980 - } 2981 - while (endps-- > 0) { 2982 - struct u132_endp *endp = u132->endp[endps]; 2983 - if (endp) 2984 - u132_endp_cancel_work(u132, endp); 2985 - } 2986 - u132->going += 1; 2987 - printk(KERN_INFO "removing device u132.%d\n", 2988 - u132->sequence_num); 2989 - mutex_unlock(&u132->sw_lock); 2990 - usb_remove_hcd(hcd); 2991 - u132_u132_put_kref(u132); 2992 - return 0; 2993 - } 2994 - } else 2995 - return 0; 2996 - } 2997 - 2998 - static void u132_initialise(struct u132 *u132, struct platform_device *pdev) 2999 - { 3000 - int rings = MAX_U132_RINGS; 3001 - int ports = MAX_U132_PORTS; 3002 - int addrs = MAX_U132_ADDRS; 3003 - int udevs = MAX_U132_UDEVS; 3004 - int endps = MAX_U132_ENDPS; 3005 - u132->board = dev_get_platdata(&pdev->dev); 3006 - u132->platform_dev = pdev; 3007 - u132->power = 0; 3008 - u132->reset = 0; 3009 - mutex_init(&u132->sw_lock); 3010 - mutex_init(&u132->scheduler_lock); 3011 - while (rings-- > 0) { 3012 - struct u132_ring *ring = &u132->ring[rings]; 3013 - ring->u132 = u132; 3014 - ring->number = rings + 1; 3015 - ring->length = 0; 3016 - ring->curr_endp = NULL; 3017 - INIT_DELAYED_WORK(&ring->scheduler, 3018 - u132_hcd_ring_work_scheduler); 3019 - } 3020 - mutex_lock(&u132->sw_lock); 3021 - INIT_DELAYED_WORK(&u132->monitor, u132_hcd_monitor_work); 3022 - while (ports-- > 0) { 3023 - struct u132_port *port = &u132->port[ports]; 3024 - port->u132 = u132; 3025 - port->reset = 0; 3026 - port->enable = 0; 3027 - port->power = 0; 3028 - port->Status = 0; 3029 - } 3030 - while (addrs-- > 0) { 3031 - struct u132_addr *addr = &u132->addr[addrs]; 3032 - addr->address = 0; 3033 - } 3034 - while (udevs-- > 0) { 3035 - struct u132_udev *udev = &u132->udev[udevs]; 3036 - int i = ARRAY_SIZE(udev->endp_number_in); 3037 - int o = ARRAY_SIZE(udev->endp_number_out); 3038 - udev->usb_device = NULL; 3039 - udev->udev_number = 0; 3040 - udev->usb_addr = 0; 3041 - udev->portnumber = 0; 3042 - while (i-- > 0) 3043 - udev->endp_number_in[i] = 0; 3044 - 3045 - while (o-- > 0) 3046 - udev->endp_number_out[o] = 0; 3047 - 3048 - } 3049 - while (endps-- > 0) 3050 - u132->endp[endps] = NULL; 3051 - 3052 - mutex_unlock(&u132->sw_lock); 3053 - } 3054 - 3055 - static int u132_probe(struct platform_device *pdev) 3056 - { 3057 - struct usb_hcd *hcd; 3058 - int retval; 3059 - u32 control; 3060 - u32 rh_a = -1; 3061 - 3062 - msleep(100); 3063 - if (u132_exiting > 0) 3064 - return -ENODEV; 3065 - 3066 - retval = ftdi_write_pcimem(pdev, intrdisable, OHCI_INTR_MIE); 3067 - if (retval) 3068 - return retval; 3069 - retval = ftdi_read_pcimem(pdev, control, &control); 3070 - if (retval) 3071 - return retval; 3072 - retval = ftdi_read_pcimem(pdev, roothub.a, &rh_a); 3073 - if (retval) 3074 - return retval; 3075 - 3076 - hcd = usb_create_hcd(&u132_hc_driver, &pdev->dev, dev_name(&pdev->dev)); 3077 - if (!hcd) { 3078 - printk(KERN_ERR "failed to create the usb hcd struct for U132\n" 3079 - ); 3080 - ftdi_elan_gone_away(pdev); 3081 - return -ENOMEM; 3082 - } else { 3083 - struct u132 *u132 = hcd_to_u132(hcd); 3084 - retval = 0; 3085 - hcd->rsrc_start = 0; 3086 - mutex_lock(&u132_module_lock); 3087 - u132->sequence_num = ++u132_instances; 3088 - mutex_unlock(&u132_module_lock); 3089 - u132_u132_init_kref(u132); 3090 - u132_initialise(u132, pdev); 3091 - hcd->product_desc = "ELAN U132 Host Controller"; 3092 - retval = usb_add_hcd(hcd, 0, 0); 3093 - if (retval != 0) { 3094 - dev_err(&u132->platform_dev->dev, "init error %d\n", 3095 - retval); 3096 - u132_u132_put_kref(u132); 3097 - return retval; 3098 - } else { 3099 - device_wakeup_enable(hcd->self.controller); 3100 - u132_monitor_queue_work(u132, 100); 3101 - return 0; 3102 - } 3103 - } 3104 - } 3105 - 3106 - 3107 - #ifdef CONFIG_PM 3108 - /* 3109 - * for this device there's no useful distinction between the controller 3110 - * and its root hub. 3111 - */ 3112 - static int u132_suspend(struct platform_device *pdev, pm_message_t state) 3113 - { 3114 - struct usb_hcd *hcd = platform_get_drvdata(pdev); 3115 - struct u132 *u132 = hcd_to_u132(hcd); 3116 - if (u132->going > 1) { 3117 - dev_err(&u132->platform_dev->dev, "device has been removed %d\n" 3118 - , u132->going); 3119 - return -ENODEV; 3120 - } else if (u132->going > 0) { 3121 - dev_err(&u132->platform_dev->dev, "device is being removed\n"); 3122 - return -ESHUTDOWN; 3123 - } else { 3124 - int retval = 0, ports; 3125 - 3126 - switch (state.event) { 3127 - case PM_EVENT_FREEZE: 3128 - retval = u132_bus_suspend(hcd); 3129 - break; 3130 - case PM_EVENT_SUSPEND: 3131 - case PM_EVENT_HIBERNATE: 3132 - ports = MAX_U132_PORTS; 3133 - while (ports-- > 0) { 3134 - port_power(u132, ports, 0); 3135 - } 3136 - break; 3137 - } 3138 - return retval; 3139 - } 3140 - } 3141 - 3142 - static int u132_resume(struct platform_device *pdev) 3143 - { 3144 - struct usb_hcd *hcd = platform_get_drvdata(pdev); 3145 - struct u132 *u132 = hcd_to_u132(hcd); 3146 - if (u132->going > 1) { 3147 - dev_err(&u132->platform_dev->dev, "device has been removed %d\n" 3148 - , u132->going); 3149 - return -ENODEV; 3150 - } else if (u132->going > 0) { 3151 - dev_err(&u132->platform_dev->dev, "device is being removed\n"); 3152 - return -ESHUTDOWN; 3153 - } else { 3154 - int retval = 0; 3155 - if (!u132->port[0].power) { 3156 - int ports = MAX_U132_PORTS; 3157 - while (ports-- > 0) { 3158 - port_power(u132, ports, 1); 3159 - } 3160 - retval = 0; 3161 - } else { 3162 - retval = u132_bus_resume(hcd); 3163 - } 3164 - return retval; 3165 - } 3166 - } 3167 - 3168 - #else 3169 - #define u132_suspend NULL 3170 - #define u132_resume NULL 3171 - #endif 3172 - /* 3173 - * this driver is loaded explicitly by ftdi_u132 3174 - * 3175 - * the platform_driver struct is static because it is per type of module 3176 - */ 3177 - static struct platform_driver u132_platform_driver = { 3178 - .probe = u132_probe, 3179 - .remove = u132_remove, 3180 - .suspend = u132_suspend, 3181 - .resume = u132_resume, 3182 - .driver = { 3183 - .name = hcd_name, 3184 - }, 3185 - }; 3186 - static int __init u132_hcd_init(void) 3187 - { 3188 - int retval; 3189 - u132_instances = 0; 3190 - u132_exiting = 0; 3191 - if (usb_disabled()) 3192 - return -ENODEV; 3193 - workqueue = create_singlethread_workqueue("u132"); 3194 - if (!workqueue) 3195 - return -ENOMEM; 3196 - retval = platform_driver_register(&u132_platform_driver); 3197 - if (retval) 3198 - destroy_workqueue(workqueue); 3199 - 3200 - return retval; 3201 - } 3202 - 3203 - 3204 - module_init(u132_hcd_init); 3205 - static void __exit u132_hcd_exit(void) 3206 - { 3207 - mutex_lock(&u132_module_lock); 3208 - u132_exiting += 1; 3209 - mutex_unlock(&u132_module_lock); 3210 - platform_driver_unregister(&u132_platform_driver); 3211 - printk(KERN_INFO "u132-hcd driver deregistered\n"); 3212 - wait_event(u132_hcd_wait, u132_instances == 0); 3213 - destroy_workqueue(workqueue); 3214 - } 3215 - 3216 - 3217 - module_exit(u132_hcd_exit); 3218 - MODULE_LICENSE("GPL"); 3219 - MODULE_ALIAS("platform:u132_hcd");
+187 -4
drivers/usb/host/xhci-dbgcap.c
··· 124 124 /* Set DbC context and info registers: */ 125 125 lo_hi_writeq(dbc->ctx->dma, &dbc->regs->dccp); 126 126 127 - dev_info = cpu_to_le32((DBC_VENDOR_ID << 16) | DBC_PROTOCOL); 127 + dev_info = (dbc->idVendor << 16) | dbc->bInterfaceProtocol; 128 128 writel(dev_info, &dbc->regs->devinfo1); 129 129 130 - dev_info = cpu_to_le32((DBC_DEVICE_REV << 16) | DBC_PRODUCT_ID); 130 + dev_info = (dbc->bcdDevice << 16) | dbc->idProduct; 131 131 writel(dev_info, &dbc->regs->devinfo2); 132 132 } 133 133 ··· 971 971 return count; 972 972 } 973 973 974 + static ssize_t dbc_idVendor_show(struct device *dev, 975 + struct device_attribute *attr, 976 + char *buf) 977 + { 978 + struct xhci_dbc *dbc; 979 + struct xhci_hcd *xhci; 980 + 981 + xhci = hcd_to_xhci(dev_get_drvdata(dev)); 982 + dbc = xhci->dbc; 983 + 984 + return sprintf(buf, "%04x\n", dbc->idVendor); 985 + } 986 + 987 + static ssize_t dbc_idVendor_store(struct device *dev, 988 + struct device_attribute *attr, 989 + const char *buf, size_t size) 990 + { 991 + struct xhci_dbc *dbc; 992 + struct xhci_hcd *xhci; 993 + void __iomem *ptr; 994 + u16 value; 995 + u32 dev_info; 996 + 997 + if (kstrtou16(buf, 0, &value)) 998 + return -EINVAL; 999 + 1000 + xhci = hcd_to_xhci(dev_get_drvdata(dev)); 1001 + dbc = xhci->dbc; 1002 + if (dbc->state != DS_DISABLED) 1003 + return -EBUSY; 1004 + 1005 + dbc->idVendor = value; 1006 + ptr = &dbc->regs->devinfo1; 1007 + dev_info = readl(ptr); 1008 + dev_info = (dev_info & ~(0xffffu << 16)) | (value << 16); 1009 + writel(dev_info, ptr); 1010 + 1011 + return size; 1012 + } 1013 + 1014 + static ssize_t dbc_idProduct_show(struct device *dev, 1015 + struct device_attribute *attr, 1016 + char *buf) 1017 + { 1018 + struct xhci_dbc *dbc; 1019 + struct xhci_hcd *xhci; 1020 + 1021 + xhci = hcd_to_xhci(dev_get_drvdata(dev)); 1022 + dbc = xhci->dbc; 1023 + 1024 + return sprintf(buf, "%04x\n", dbc->idProduct); 1025 + } 1026 + 1027 + static ssize_t dbc_idProduct_store(struct device *dev, 1028 + struct device_attribute *attr, 1029 + const char *buf, size_t size) 1030 + { 1031 + struct xhci_dbc *dbc; 1032 + struct xhci_hcd *xhci; 1033 + void __iomem *ptr; 1034 + u32 dev_info; 1035 + u16 value; 1036 + 1037 + if (kstrtou16(buf, 0, &value)) 1038 + return -EINVAL; 1039 + 1040 + xhci = hcd_to_xhci(dev_get_drvdata(dev)); 1041 + dbc = xhci->dbc; 1042 + if (dbc->state != DS_DISABLED) 1043 + return -EBUSY; 1044 + 1045 + dbc->idProduct = value; 1046 + ptr = &dbc->regs->devinfo2; 1047 + dev_info = readl(ptr); 1048 + dev_info = (dev_info & ~(0xffffu)) | value; 1049 + writel(dev_info, ptr); 1050 + return size; 1051 + } 1052 + 1053 + static ssize_t dbc_bcdDevice_show(struct device *dev, 1054 + struct device_attribute *attr, 1055 + char *buf) 1056 + { 1057 + struct xhci_dbc *dbc; 1058 + struct xhci_hcd *xhci; 1059 + 1060 + xhci = hcd_to_xhci(dev_get_drvdata(dev)); 1061 + dbc = xhci->dbc; 1062 + 1063 + return sprintf(buf, "%04x\n", dbc->bcdDevice); 1064 + } 1065 + 1066 + static ssize_t dbc_bcdDevice_store(struct device *dev, 1067 + struct device_attribute *attr, 1068 + const char *buf, size_t size) 1069 + { 1070 + struct xhci_dbc *dbc; 1071 + struct xhci_hcd *xhci; 1072 + void __iomem *ptr; 1073 + u32 dev_info; 1074 + u16 value; 1075 + 1076 + if (kstrtou16(buf, 0, &value)) 1077 + return -EINVAL; 1078 + 1079 + xhci = hcd_to_xhci(dev_get_drvdata(dev)); 1080 + dbc = xhci->dbc; 1081 + if (dbc->state != DS_DISABLED) 1082 + return -EBUSY; 1083 + 1084 + dbc->bcdDevice = value; 1085 + ptr = &dbc->regs->devinfo2; 1086 + dev_info = readl(ptr); 1087 + dev_info = (dev_info & ~(0xffffu << 16)) | (value << 16); 1088 + writel(dev_info, ptr); 1089 + 1090 + return size; 1091 + } 1092 + 1093 + static ssize_t dbc_bInterfaceProtocol_show(struct device *dev, 1094 + struct device_attribute *attr, 1095 + char *buf) 1096 + { 1097 + struct xhci_dbc *dbc; 1098 + struct xhci_hcd *xhci; 1099 + 1100 + xhci = hcd_to_xhci(dev_get_drvdata(dev)); 1101 + dbc = xhci->dbc; 1102 + 1103 + return sprintf(buf, "%02x\n", dbc->bInterfaceProtocol); 1104 + } 1105 + 1106 + static ssize_t dbc_bInterfaceProtocol_store(struct device *dev, 1107 + struct device_attribute *attr, 1108 + const char *buf, size_t size) 1109 + { 1110 + struct xhci_dbc *dbc; 1111 + struct xhci_hcd *xhci; 1112 + void __iomem *ptr; 1113 + u32 dev_info; 1114 + u8 value; 1115 + int ret; 1116 + 1117 + /* bInterfaceProtocol is 8 bit, but xhci only supports values 0 and 1 */ 1118 + ret = kstrtou8(buf, 0, &value); 1119 + if (ret || value > 1) 1120 + return -EINVAL; 1121 + 1122 + xhci = hcd_to_xhci(dev_get_drvdata(dev)); 1123 + dbc = xhci->dbc; 1124 + if (dbc->state != DS_DISABLED) 1125 + return -EBUSY; 1126 + 1127 + dbc->bInterfaceProtocol = value; 1128 + ptr = &dbc->regs->devinfo1; 1129 + dev_info = readl(ptr); 1130 + dev_info = (dev_info & ~(0xffu)) | value; 1131 + writel(dev_info, ptr); 1132 + 1133 + return size; 1134 + } 1135 + 974 1136 static DEVICE_ATTR_RW(dbc); 1137 + static DEVICE_ATTR_RW(dbc_idVendor); 1138 + static DEVICE_ATTR_RW(dbc_idProduct); 1139 + static DEVICE_ATTR_RW(dbc_bcdDevice); 1140 + static DEVICE_ATTR_RW(dbc_bInterfaceProtocol); 1141 + 1142 + static struct attribute *dbc_dev_attributes[] = { 1143 + &dev_attr_dbc.attr, 1144 + &dev_attr_dbc_idVendor.attr, 1145 + &dev_attr_dbc_idProduct.attr, 1146 + &dev_attr_dbc_bcdDevice.attr, 1147 + &dev_attr_dbc_bInterfaceProtocol.attr, 1148 + NULL 1149 + }; 1150 + 1151 + static const struct attribute_group dbc_dev_attrib_grp = { 1152 + .attrs = dbc_dev_attributes, 1153 + }; 975 1154 976 1155 struct xhci_dbc * 977 1156 xhci_alloc_dbc(struct device *dev, void __iomem *base, const struct dbc_driver *driver) ··· 1165 986 dbc->regs = base; 1166 987 dbc->dev = dev; 1167 988 dbc->driver = driver; 989 + dbc->idProduct = DBC_PRODUCT_ID; 990 + dbc->idVendor = DBC_VENDOR_ID; 991 + dbc->bcdDevice = DBC_DEVICE_REV; 992 + dbc->bInterfaceProtocol = DBC_PROTOCOL; 1168 993 1169 994 if (readl(&dbc->regs->control) & DBC_CTRL_DBC_ENABLE) 1170 995 goto err; ··· 1176 993 INIT_DELAYED_WORK(&dbc->event_work, xhci_dbc_handle_events); 1177 994 spin_lock_init(&dbc->lock); 1178 995 1179 - ret = device_create_file(dev, &dev_attr_dbc); 996 + ret = sysfs_create_group(&dev->kobj, &dbc_dev_attrib_grp); 1180 997 if (ret) 1181 998 goto err; 1182 999 ··· 1195 1012 xhci_dbc_stop(dbc); 1196 1013 1197 1014 /* remove sysfs files */ 1198 - device_remove_file(dbc->dev, &dev_attr_dbc); 1015 + sysfs_remove_group(&dbc->dev->kobj, &dbc_dev_attrib_grp); 1199 1016 1200 1017 kfree(dbc); 1201 1018 }
+4
drivers/usb/host/xhci-dbgcap.h
··· 132 132 struct dbc_str_descs *string; 133 133 dma_addr_t string_dma; 134 134 size_t string_size; 135 + u16 idVendor; 136 + u16 idProduct; 137 + u16 bcdDevice; 138 + u8 bInterfaceProtocol; 135 139 136 140 enum dbc_state state; 137 141 struct delayed_work event_work;
+1
drivers/usb/host/xhci-debugfs.c
··· 133 133 regset->regs = regs; 134 134 regset->nregs = nregs; 135 135 regset->base = hcd->regs + base; 136 + regset->dev = hcd->self.controller; 136 137 137 138 debugfs_create_regset32((const char *)rgs->name, 0444, parent, regset); 138 139 }
+33 -50
drivers/usb/host/xhci-mem.c
··· 9 9 */ 10 10 11 11 #include <linux/usb.h> 12 + #include <linux/overflow.h> 12 13 #include <linux/pci.h> 13 14 #include <linux/slab.h> 14 15 #include <linux/dmapool.h> ··· 544 543 size_t size = sizeof(struct xhci_stream_ctx) * num_stream_ctxs; 545 544 546 545 if (size > MEDIUM_STREAM_ARRAY_SIZE) 547 - dma_free_coherent(dev, size, 548 - stream_ctx, dma); 549 - else if (size <= SMALL_STREAM_ARRAY_SIZE) 550 - return dma_pool_free(xhci->small_streams_pool, 551 - stream_ctx, dma); 546 + dma_free_coherent(dev, size, stream_ctx, dma); 547 + else if (size > SMALL_STREAM_ARRAY_SIZE) 548 + dma_pool_free(xhci->medium_streams_pool, stream_ctx, dma); 552 549 else 553 - return dma_pool_free(xhci->medium_streams_pool, 554 - stream_ctx, dma); 550 + dma_pool_free(xhci->small_streams_pool, stream_ctx, dma); 555 551 } 556 552 557 553 /* ··· 566 568 gfp_t mem_flags) 567 569 { 568 570 struct device *dev = xhci_to_hcd(xhci)->self.sysdev; 569 - size_t size = sizeof(struct xhci_stream_ctx) * num_stream_ctxs; 571 + size_t size = size_mul(sizeof(struct xhci_stream_ctx), num_stream_ctxs); 570 572 571 573 if (size > MEDIUM_STREAM_ARRAY_SIZE) 572 - return dma_alloc_coherent(dev, size, 573 - dma, mem_flags); 574 - else if (size <= SMALL_STREAM_ARRAY_SIZE) 575 - return dma_pool_alloc(xhci->small_streams_pool, 576 - mem_flags, dma); 574 + return dma_alloc_coherent(dev, size, dma, mem_flags); 575 + if (size > SMALL_STREAM_ARRAY_SIZE) 576 + return dma_pool_zalloc(xhci->medium_streams_pool, mem_flags, dma); 577 577 else 578 - return dma_pool_alloc(xhci->medium_streams_pool, 579 - mem_flags, dma); 578 + return dma_pool_zalloc(xhci->small_streams_pool, mem_flags, dma); 580 579 } 581 580 582 581 struct xhci_ring *xhci_dma_to_transfer_ring( ··· 607 612 int ret; 608 613 struct device *dev = xhci_to_hcd(xhci)->self.sysdev; 609 614 610 - xhci_dbg(xhci, "Allocating %u streams and %u " 611 - "stream context array entries.\n", 615 + xhci_dbg(xhci, "Allocating %u streams and %u stream context array entries.\n", 612 616 num_streams, num_stream_ctxs); 613 617 if (xhci->cmd_ring_reserved_trbs == MAX_RSVD_CMD_TRBS) { 614 618 xhci_dbg(xhci, "Command ring has no reserved TRBs available\n"); ··· 636 642 mem_flags); 637 643 if (!stream_info->stream_ctx_array) 638 644 goto cleanup_ring_array; 639 - memset(stream_info->stream_ctx_array, 0, 640 - sizeof(struct xhci_stream_ctx)*num_stream_ctxs); 641 645 642 646 /* Allocate everything needed to free the stream rings later */ 643 647 stream_info->free_streams_command = ··· 665 673 cur_ring->cycle_state; 666 674 stream_info->stream_ctx_array[cur_stream].stream_ring = 667 675 cpu_to_le64(addr); 668 - xhci_dbg(xhci, "Setting stream %d ring ptr to 0x%08llx\n", 669 - cur_stream, (unsigned long long) addr); 676 + xhci_dbg(xhci, "Setting stream %d ring ptr to 0x%08llx\n", cur_stream, addr); 670 677 671 678 ret = xhci_update_stream_mapping(cur_ring, mem_flags); 672 679 if (ret) { ··· 975 984 if (!dev->out_ctx) 976 985 goto fail; 977 986 978 - xhci_dbg(xhci, "Slot %d output ctx = 0x%llx (dma)\n", slot_id, 979 - (unsigned long long)dev->out_ctx->dma); 987 + xhci_dbg(xhci, "Slot %d output ctx = 0x%pad (dma)\n", slot_id, &dev->out_ctx->dma); 980 988 981 989 /* Allocate the (input) device context for address device command */ 982 990 dev->in_ctx = xhci_alloc_container_ctx(xhci, XHCI_CTX_TYPE_INPUT, flags); 983 991 if (!dev->in_ctx) 984 992 goto fail; 985 993 986 - xhci_dbg(xhci, "Slot %d input ctx = 0x%llx (dma)\n", slot_id, 987 - (unsigned long long)dev->in_ctx->dma); 994 + xhci_dbg(xhci, "Slot %d input ctx = 0x%pad (dma)\n", slot_id, &dev->in_ctx->dma); 988 995 989 996 /* Initialize the cancellation and bandwidth list for each ep */ 990 997 for (i = 0; i < 31; i++) { ··· 1389 1400 if ((udev->speed >= USB_SPEED_SUPER_PLUS) && 1390 1401 USB_SS_SSP_ISOC_COMP(ep->ss_ep_comp.bmAttributes)) 1391 1402 return le32_to_cpu(ep->ssp_isoc_ep_comp.dwBytesPerInterval); 1403 + 1392 1404 /* SuperSpeed or SuperSpeedPlus Isoc ep with less than 48k per esit */ 1393 - else if (udev->speed >= USB_SPEED_SUPER) 1405 + if (udev->speed >= USB_SPEED_SUPER) 1394 1406 return le16_to_cpu(ep->ss_ep_comp.wBytesPerInterval); 1395 1407 1396 1408 max_packet = usb_endpoint_maxp(&ep->desc); ··· 1650 1660 goto fail_sp; 1651 1661 1652 1662 xhci->scratchpad->sp_array = dma_alloc_coherent(dev, 1653 - num_sp * sizeof(u64), 1663 + size_mul(sizeof(u64), num_sp), 1654 1664 &xhci->scratchpad->sp_dma, flags); 1655 1665 if (!xhci->scratchpad->sp_array) 1656 1666 goto fail_sp2; ··· 1675 1685 return 0; 1676 1686 1677 1687 fail_sp4: 1678 - for (i = i - 1; i >= 0; i--) { 1688 + while (i--) 1679 1689 dma_free_coherent(dev, xhci->page_size, 1680 1690 xhci->scratchpad->sp_buffers[i], 1681 1691 xhci->scratchpad->sp_array[i]); 1682 - } 1683 1692 1684 1693 kfree(xhci->scratchpad->sp_buffers); 1685 1694 ··· 1788 1799 struct xhci_segment *seg; 1789 1800 struct xhci_erst_entry *entry; 1790 1801 1791 - size = sizeof(struct xhci_erst_entry) * evt_ring->num_segs; 1802 + size = size_mul(sizeof(struct xhci_erst_entry), evt_ring->num_segs); 1792 1803 erst->entries = dma_alloc_coherent(xhci_to_hcd(xhci)->self.sysdev, 1793 1804 size, &erst->erst_dma_addr, flags); 1794 1805 if (!erst->entries) ··· 1819 1830 if (!ir) 1820 1831 return; 1821 1832 1822 - erst_size = sizeof(struct xhci_erst_entry) * (ir->erst.num_entries); 1833 + erst_size = sizeof(struct xhci_erst_entry) * ir->erst.num_entries; 1823 1834 if (ir->erst.entries) 1824 1835 dma_free_coherent(dev, erst_size, 1825 1836 ir->erst.entries, ··· 1949 1960 deq = xhci_trb_virt_to_dma(ir->event_ring->deq_seg, 1950 1961 ir->event_ring->dequeue); 1951 1962 if (!deq) 1952 - xhci_warn(xhci, "WARN something wrong with SW event ring " 1953 - "dequeue ptr.\n"); 1963 + xhci_warn(xhci, "WARN something wrong with SW event ring dequeue ptr.\n"); 1954 1964 /* Update HC event ring dequeue pointer */ 1955 1965 temp = xhci_read_64(xhci, &ir->ir_set->erst_dequeue); 1956 1966 temp &= ERST_PTR_MASK; ··· 1958 1970 */ 1959 1971 temp &= ~ERST_EHB; 1960 1972 xhci_dbg_trace(xhci, trace_xhci_dbg_init, 1961 - "// Write event ring dequeue pointer, " 1962 - "preserving EHB bit"); 1973 + "// Write event ring dequeue pointer, preserving EHB bit"); 1963 1974 xhci_write_64(xhci, ((u64) deq & (u64) ~ERST_PTR_MASK) | temp, 1964 1975 &ir->ir_set->erst_dequeue); 1965 1976 } ··· 1991 2004 } else if (major_revision <= 0x02) { 1992 2005 rhub = &xhci->usb2_rhub; 1993 2006 } else { 1994 - xhci_warn(xhci, "Ignoring unknown port speed, " 1995 - "Ext Cap %p, revision = 0x%x\n", 2007 + xhci_warn(xhci, "Ignoring unknown port speed, Ext Cap %p, revision = 0x%x\n", 1996 2008 addr, major_revision); 1997 2009 /* Ignoring port protocol we can't understand. FIXME */ 1998 2010 return; ··· 2006 2020 port_offset = XHCI_EXT_PORT_OFF(temp); 2007 2021 port_count = XHCI_EXT_PORT_COUNT(temp); 2008 2022 xhci_dbg_trace(xhci, trace_xhci_dbg_init, 2009 - "Ext Cap %p, port offset = %u, " 2010 - "count = %u, revision = 0x%x", 2011 - addr, port_offset, port_count, major_revision); 2023 + "Ext Cap %p, port offset = %u, count = %u, revision = 0x%x", 2024 + addr, port_offset, port_count, major_revision); 2012 2025 /* Port count includes the current port offset */ 2013 2026 if (port_offset == 0 || (port_offset + port_count - 1) > num_ports) 2014 2027 /* WTF? "Valid values are ‘1’ to MaxPorts" */ ··· 2064 2079 struct xhci_port *hw_port = &xhci->hw_ports[i]; 2065 2080 /* Duplicate entry. Ignore the port if the revisions differ. */ 2066 2081 if (hw_port->rhub) { 2067 - xhci_warn(xhci, "Duplicate port entry, Ext Cap %p," 2068 - " port %u\n", addr, i); 2069 - xhci_warn(xhci, "Port was marked as USB %u, " 2070 - "duplicated as USB %u\n", 2082 + xhci_warn(xhci, "Duplicate port entry, Ext Cap %p, port %u\n", addr, i); 2083 + xhci_warn(xhci, "Port was marked as USB %u, duplicated as USB %u\n", 2071 2084 hw_port->rhub->maj_rev, major_revision); 2072 2085 /* Only adjust the roothub port counts if we haven't 2073 2086 * found a similar duplicate. ··· 2341 2358 goto fail; 2342 2359 xhci->dcbaa->dma = dma; 2343 2360 xhci_dbg_trace(xhci, trace_xhci_dbg_init, 2344 - "// Device context base array address = 0x%llx (DMA), %p (virt)", 2345 - (unsigned long long)xhci->dcbaa->dma, xhci->dcbaa); 2361 + "// Device context base array address = 0x%pad (DMA), %p (virt)", 2362 + &xhci->dcbaa->dma, xhci->dcbaa); 2346 2363 xhci_write_64(xhci, dma, &xhci->op_regs->dcbaa_ptr); 2347 2364 2348 2365 /* ··· 2383 2400 goto fail; 2384 2401 xhci_dbg_trace(xhci, trace_xhci_dbg_init, 2385 2402 "Allocated command ring at %p", xhci->cmd_ring); 2386 - xhci_dbg_trace(xhci, trace_xhci_dbg_init, "First segment DMA is 0x%llx", 2387 - (unsigned long long)xhci->cmd_ring->first_seg->dma); 2403 + xhci_dbg_trace(xhci, trace_xhci_dbg_init, "First segment DMA is 0x%pad", 2404 + &xhci->cmd_ring->first_seg->dma); 2388 2405 2389 2406 /* Set the address in the Command Ring Control register */ 2390 2407 val_64 = xhci_read_64(xhci, &xhci->op_regs->cmd_ring); ··· 2404 2421 val = readl(&xhci->cap_regs->db_off); 2405 2422 val &= DBOFF_MASK; 2406 2423 xhci_dbg_trace(xhci, trace_xhci_dbg_init, 2407 - "// Doorbell array is located at offset 0x%x" 2408 - " from cap regs base addr", val); 2424 + "// Doorbell array is located at offset 0x%x from cap regs base addr", 2425 + val); 2409 2426 xhci->dba = (void __iomem *) xhci->cap_regs + val; 2410 2427 /* Set ir_set to interrupt register set 0 */ 2411 2428
+1
drivers/usb/host/xhci-mtk.c
··· 398 398 clks[2].id = "ref_ck"; 399 399 clks[3].id = "mcu_ck"; 400 400 clks[4].id = "dma_ck"; 401 + clks[5].id = "frmcnt_ck"; 401 402 402 403 return devm_clk_bulk_get_optional(mtk->dev, BULK_CLKS_NUM, clks); 403 404 }
+1 -1
drivers/usb/host/xhci-mtk.h
··· 15 15 16 16 #include "xhci.h" 17 17 18 - #define BULK_CLKS_NUM 5 18 + #define BULK_CLKS_NUM 6 19 19 #define BULK_VREGS_NUM 2 20 20 21 21 /* support at most 64 ep, use 32 size hash table */
+204 -11
drivers/usb/host/xhci-pci.c
··· 78 78 static struct hc_driver __read_mostly xhci_pci_hc_driver; 79 79 80 80 static int xhci_pci_setup(struct usb_hcd *hcd); 81 + static int xhci_pci_run(struct usb_hcd *hcd); 81 82 static int xhci_pci_update_hub_device(struct usb_hcd *hcd, struct usb_device *hdev, 82 83 struct usb_tt *tt, gfp_t mem_flags); 83 84 84 85 static const struct xhci_driver_overrides xhci_pci_overrides __initconst = { 85 86 .reset = xhci_pci_setup, 87 + .start = xhci_pci_run, 86 88 .update_hub_device = xhci_pci_update_hub_device, 87 89 }; 90 + 91 + static void xhci_msix_sync_irqs(struct xhci_hcd *xhci) 92 + { 93 + struct usb_hcd *hcd = xhci_to_hcd(xhci); 94 + 95 + if (hcd->msix_enabled) { 96 + struct pci_dev *pdev = to_pci_dev(hcd->self.controller); 97 + int i; 98 + 99 + for (i = 0; i < xhci->msix_count; i++) 100 + synchronize_irq(pci_irq_vector(pdev, i)); 101 + } 102 + } 103 + 104 + /* Free any IRQs and disable MSI-X */ 105 + static void xhci_cleanup_msix(struct xhci_hcd *xhci) 106 + { 107 + struct usb_hcd *hcd = xhci_to_hcd(xhci); 108 + struct pci_dev *pdev = to_pci_dev(hcd->self.controller); 109 + 110 + if (xhci->quirks & XHCI_PLAT) 111 + return; 112 + 113 + /* return if using legacy interrupt */ 114 + if (hcd->irq > 0) 115 + return; 116 + 117 + if (hcd->msix_enabled) { 118 + int i; 119 + 120 + for (i = 0; i < xhci->msix_count; i++) 121 + free_irq(pci_irq_vector(pdev, i), xhci_to_hcd(xhci)); 122 + } else { 123 + free_irq(pci_irq_vector(pdev, 0), xhci_to_hcd(xhci)); 124 + } 125 + 126 + pci_free_irq_vectors(pdev); 127 + hcd->msix_enabled = 0; 128 + } 129 + 130 + /* 131 + * Set up MSI 132 + */ 133 + static int xhci_setup_msi(struct xhci_hcd *xhci) 134 + { 135 + int ret; 136 + /* 137 + * TODO:Check with MSI Soc for sysdev 138 + */ 139 + struct pci_dev *pdev = to_pci_dev(xhci_to_hcd(xhci)->self.controller); 140 + 141 + ret = pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_MSI); 142 + if (ret < 0) { 143 + xhci_dbg_trace(xhci, trace_xhci_dbg_init, 144 + "failed to allocate MSI entry"); 145 + return ret; 146 + } 147 + 148 + ret = request_irq(pdev->irq, xhci_msi_irq, 149 + 0, "xhci_hcd", xhci_to_hcd(xhci)); 150 + if (ret) { 151 + xhci_dbg_trace(xhci, trace_xhci_dbg_init, 152 + "disable MSI interrupt"); 153 + pci_free_irq_vectors(pdev); 154 + } 155 + 156 + return ret; 157 + } 158 + 159 + /* 160 + * Set up MSI-X 161 + */ 162 + static int xhci_setup_msix(struct xhci_hcd *xhci) 163 + { 164 + int i, ret; 165 + struct usb_hcd *hcd = xhci_to_hcd(xhci); 166 + struct pci_dev *pdev = to_pci_dev(hcd->self.controller); 167 + 168 + /* 169 + * calculate number of msi-x vectors supported. 170 + * - HCS_MAX_INTRS: the max number of interrupts the host can handle, 171 + * with max number of interrupters based on the xhci HCSPARAMS1. 172 + * - num_online_cpus: maximum msi-x vectors per CPUs core. 173 + * Add additional 1 vector to ensure always available interrupt. 174 + */ 175 + xhci->msix_count = min(num_online_cpus() + 1, 176 + HCS_MAX_INTRS(xhci->hcs_params1)); 177 + 178 + ret = pci_alloc_irq_vectors(pdev, xhci->msix_count, xhci->msix_count, 179 + PCI_IRQ_MSIX); 180 + if (ret < 0) { 181 + xhci_dbg_trace(xhci, trace_xhci_dbg_init, 182 + "Failed to enable MSI-X"); 183 + return ret; 184 + } 185 + 186 + for (i = 0; i < xhci->msix_count; i++) { 187 + ret = request_irq(pci_irq_vector(pdev, i), xhci_msi_irq, 0, 188 + "xhci_hcd", xhci_to_hcd(xhci)); 189 + if (ret) 190 + goto disable_msix; 191 + } 192 + 193 + hcd->msix_enabled = 1; 194 + return ret; 195 + 196 + disable_msix: 197 + xhci_dbg_trace(xhci, trace_xhci_dbg_init, "disable MSI-X interrupt"); 198 + while (--i >= 0) 199 + free_irq(pci_irq_vector(pdev, i), xhci_to_hcd(xhci)); 200 + pci_free_irq_vectors(pdev); 201 + return ret; 202 + } 203 + 204 + static int xhci_try_enable_msi(struct usb_hcd *hcd) 205 + { 206 + struct xhci_hcd *xhci = hcd_to_xhci(hcd); 207 + struct pci_dev *pdev; 208 + int ret; 209 + 210 + /* The xhci platform device has set up IRQs through usb_add_hcd. */ 211 + if (xhci->quirks & XHCI_PLAT) 212 + return 0; 213 + 214 + pdev = to_pci_dev(xhci_to_hcd(xhci)->self.controller); 215 + /* 216 + * Some Fresco Logic host controllers advertise MSI, but fail to 217 + * generate interrupts. Don't even try to enable MSI. 218 + */ 219 + if (xhci->quirks & XHCI_BROKEN_MSI) 220 + goto legacy_irq; 221 + 222 + /* unregister the legacy interrupt */ 223 + if (hcd->irq) 224 + free_irq(hcd->irq, hcd); 225 + hcd->irq = 0; 226 + 227 + ret = xhci_setup_msix(xhci); 228 + if (ret) 229 + /* fall back to msi*/ 230 + ret = xhci_setup_msi(xhci); 231 + 232 + if (!ret) { 233 + hcd->msi_enabled = 1; 234 + return 0; 235 + } 236 + 237 + if (!pdev->irq) { 238 + xhci_err(xhci, "No msi-x/msi found and no IRQ in BIOS\n"); 239 + return -EINVAL; 240 + } 241 + 242 + legacy_irq: 243 + if (!strlen(hcd->irq_descr)) 244 + snprintf(hcd->irq_descr, sizeof(hcd->irq_descr), "%s:usb%d", 245 + hcd->driver->description, hcd->self.busnum); 246 + 247 + /* fall back to legacy interrupt*/ 248 + ret = request_irq(pdev->irq, &usb_hcd_irq, IRQF_SHARED, 249 + hcd->irq_descr, hcd); 250 + if (ret) { 251 + xhci_err(xhci, "request interrupt %d failed\n", 252 + pdev->irq); 253 + return ret; 254 + } 255 + hcd->irq = pdev->irq; 256 + return 0; 257 + } 258 + 259 + static int xhci_pci_run(struct usb_hcd *hcd) 260 + { 261 + int ret; 262 + 263 + if (usb_hcd_is_primary_hcd(hcd)) { 264 + ret = xhci_try_enable_msi(hcd); 265 + if (ret) 266 + return ret; 267 + } 268 + 269 + return xhci_run(hcd); 270 + } 271 + 272 + static void xhci_pci_stop(struct usb_hcd *hcd) 273 + { 274 + struct xhci_hcd *xhci = hcd_to_xhci(hcd); 275 + 276 + xhci_stop(hcd); 277 + 278 + if (usb_hcd_is_primary_hcd(hcd)) 279 + xhci_cleanup_msix(xhci); 280 + } 88 281 89 282 /* called after powerup, by probe or system-pm "wakeup" */ 90 283 static int xhci_pci_reinit(struct xhci_hcd *xhci, struct pci_dev *pdev) ··· 728 535 usb_hcd_pci_remove(dev); 729 536 } 730 537 731 - #ifdef CONFIG_PM 732 538 /* 733 539 * In some Intel xHCI controllers, in order to get D3 working, 734 540 * through a vendor specific SSIC CONFIG register at offset 0x883c, ··· 814 622 xhci_sparse_control_quirk(hcd); 815 623 816 624 ret = xhci_suspend(xhci, do_wakeup); 625 + 626 + /* synchronize irq when using MSI-X */ 627 + xhci_msix_sync_irqs(xhci); 628 + 817 629 if (ret && (xhci->quirks & XHCI_SSIC_PORT_UNUSED)) 818 630 xhci_ssic_port_unused_quirk(hcd, false); 819 631 ··· 920 724 struct pci_dev *pdev = to_pci_dev(hcd->self.controller); 921 725 922 726 xhci_shutdown(hcd); 727 + xhci_cleanup_msix(xhci); 923 728 924 729 /* Yet another workaround for spurious wakeups at shutdown with HSW */ 925 730 if (xhci->quirks & XHCI_SPURIOUS_WAKEUP) 926 731 pci_set_power_state(pdev, PCI_D3hot); 927 732 } 928 - #endif /* CONFIG_PM */ 929 733 930 734 /*-------------------------------------------------------------------------*/ 931 735 ··· 967 771 /* suspend and resume implemented later */ 968 772 969 773 .shutdown = usb_hcd_pci_shutdown, 970 - #ifdef CONFIG_PM 971 774 .driver = { 972 - .pm = &usb_hcd_pci_pm_ops 775 + .pm = pm_ptr(&usb_hcd_pci_pm_ops), 973 776 }, 974 - #endif 975 777 }; 976 778 977 779 static int __init xhci_pci_init(void) 978 780 { 979 781 xhci_init_driver(&xhci_pci_hc_driver, &xhci_pci_overrides); 980 - #ifdef CONFIG_PM 981 - xhci_pci_hc_driver.pci_suspend = xhci_pci_suspend; 982 - xhci_pci_hc_driver.pci_resume = xhci_pci_resume; 983 - xhci_pci_hc_driver.pci_poweroff_late = xhci_pci_poweroff_late; 984 - xhci_pci_hc_driver.shutdown = xhci_pci_shutdown; 985 - #endif 782 + xhci_pci_hc_driver.pci_suspend = pm_ptr(xhci_pci_suspend); 783 + xhci_pci_hc_driver.pci_resume = pm_ptr(xhci_pci_resume); 784 + xhci_pci_hc_driver.pci_poweroff_late = pm_ptr(xhci_pci_poweroff_late); 785 + xhci_pci_hc_driver.shutdown = pm_ptr(xhci_pci_shutdown); 786 + xhci_pci_hc_driver.stop = xhci_pci_stop; 986 787 return pci_register_driver(&xhci_pci_driver); 987 788 } 988 789 module_init(xhci_pci_init);
+16 -3
drivers/usb/host/xhci-plat.c
··· 291 291 goto dealloc_usb2_hcd; 292 292 } 293 293 294 + xhci->shared_hcd->usb_phy = devm_usb_get_phy_by_phandle(sysdev, 295 + "usb-phy", 1); 296 + if (IS_ERR(xhci->shared_hcd->usb_phy)) { 297 + if (PTR_ERR(xhci->shared_hcd->usb_phy) != -ENODEV) 298 + dev_err(sysdev, "%s get usb3phy fail (ret=%d)\n", 299 + __func__, 300 + (int)PTR_ERR(xhci->shared_hcd->usb_phy)); 301 + xhci->shared_hcd->usb_phy = NULL; 302 + } else { 303 + ret = usb_phy_init(xhci->shared_hcd->usb_phy); 304 + if (ret) 305 + dev_err(sysdev, "%s init usb3phy fail (ret=%d)\n", 306 + __func__, ret); 307 + } 308 + 294 309 xhci->shared_hcd->tpl_support = hcd->tpl_support; 295 310 } 296 311 ··· 377 362 if (is_of_node(sysdev->fwnode) || 378 363 is_acpi_device_node(sysdev->fwnode)) 379 364 break; 380 - #ifdef CONFIG_PCI 381 - else if (sysdev->bus == &pci_bus_type) 365 + else if (dev_is_pci(sysdev)) 382 366 break; 383 - #endif 384 367 } 385 368 386 369 if (!sysdev)
+3 -33
drivers/usb/host/xhci-rcar.c
··· 12 12 #include <linux/of.h> 13 13 #include <linux/of_device.h> 14 14 #include <linux/usb/phy.h> 15 - #include <linux/sys_soc.h> 16 15 17 16 #include "xhci.h" 18 17 #include "xhci-plat.h" 19 18 #include "xhci-rzv2m.h" 20 19 21 20 #define XHCI_RCAR_FIRMWARE_NAME_V1 "r8a779x_usb3_v1.dlmem" 22 - #define XHCI_RCAR_FIRMWARE_NAME_V2 "r8a779x_usb3_v2.dlmem" 23 21 #define XHCI_RCAR_FIRMWARE_NAME_V3 "r8a779x_usb3_v3.dlmem" 24 22 25 23 /* 26 - * - The V3 firmware is for almost all R-Car Gen3 (except r8a7795 ES1.x) 27 - * - The V2 firmware is for r8a7795 ES1.x. 24 + * - The V3 firmware is for all R-Car Gen3 28 25 * - The V2 firmware is possible to use on R-Car Gen2. However, the V2 causes 29 26 * performance degradation. So, this driver continues to use the V1 if R-Car 30 27 * Gen2. 31 28 * - The V1 firmware is impossible to use on R-Car Gen3. 32 29 */ 33 30 MODULE_FIRMWARE(XHCI_RCAR_FIRMWARE_NAME_V1); 34 - MODULE_FIRMWARE(XHCI_RCAR_FIRMWARE_NAME_V2); 35 31 MODULE_FIRMWARE(XHCI_RCAR_FIRMWARE_NAME_V3); 36 32 37 33 /*** Register Offset ***/ ··· 74 78 #define RCAR_USB3_RX_POL_VAL BIT(21) 75 79 #define RCAR_USB3_TX_POL_VAL BIT(4) 76 80 77 - /* For soc_device_attribute */ 78 - #define RCAR_XHCI_FIRMWARE_V2 BIT(0) /* FIRMWARE V2 */ 79 - #define RCAR_XHCI_FIRMWARE_V3 BIT(1) /* FIRMWARE V3 */ 80 - 81 - static const struct soc_device_attribute rcar_quirks_match[] = { 82 - { 83 - .soc_id = "r8a7795", .revision = "ES1.*", 84 - .data = (void *)RCAR_XHCI_FIRMWARE_V2, 85 - }, 86 - { /* sentinel */ } 87 - }; 88 - 89 81 static void xhci_rcar_start_gen2(struct usb_hcd *hcd) 90 82 { 91 83 /* LCLK Select */ ··· 119 135 const struct firmware *fw; 120 136 int retval, index, j; 121 137 u32 data, val, temp; 122 - u32 quirks = 0; 123 - const struct soc_device_attribute *attr; 124 - const char *firmware_name; 125 138 126 139 /* 127 140 * According to the datasheet, "Upon the completion of FW Download, ··· 127 146 if (readl(regs + RCAR_USB3_DL_CTRL) & RCAR_USB3_DL_CTRL_FW_SUCCESS) 128 147 return 0; 129 148 130 - attr = soc_device_match(rcar_quirks_match); 131 - if (attr) 132 - quirks = (uintptr_t)attr->data; 133 - 134 - if (quirks & RCAR_XHCI_FIRMWARE_V2) 135 - firmware_name = XHCI_RCAR_FIRMWARE_NAME_V2; 136 - else if (quirks & RCAR_XHCI_FIRMWARE_V3) 137 - firmware_name = XHCI_RCAR_FIRMWARE_NAME_V3; 138 - else 139 - firmware_name = priv->firmware_name; 140 - 141 149 /* request R-Car USB3.0 firmware */ 142 - retval = request_firmware(&fw, firmware_name, dev); 150 + retval = request_firmware(&fw, priv->firmware_name, dev); 143 151 if (retval) 144 152 return retval; 145 153 ··· 282 312 .driver = { 283 313 .name = "xhci-renesas-hcd", 284 314 .pm = &xhci_plat_pm_ops, 285 - .of_match_table = of_match_ptr(usb_xhci_of_match), 315 + .of_match_table = usb_xhci_of_match, 286 316 }, 287 317 }; 288 318 module_platform_driver(usb_xhci_renesas_driver);
+1
drivers/usb/host/xhci-ring.c
··· 3106 3106 { 3107 3107 return xhci_irq(hcd); 3108 3108 } 3109 + EXPORT_SYMBOL_GPL(xhci_msi_irq); 3109 3110 3110 3111 /**** Endpoint Ring Operations ****/ 3111 3112
+7 -10
drivers/usb/host/xhci-tegra.c
··· 1535 1535 1536 1536 static int tegra_xusb_probe(struct platform_device *pdev) 1537 1537 { 1538 - struct of_phandle_args args; 1539 1538 struct tegra_xusb *tegra; 1540 1539 struct device_node *np; 1541 1540 struct resource *regs; ··· 1593 1594 goto put_padctl; 1594 1595 } 1595 1596 1596 - /* Older device-trees don't have padctrl interrupt */ 1597 - err = of_irq_parse_one(np, 0, &args); 1598 - if (!err) { 1599 - tegra->padctl_irq = of_irq_get(np, 0); 1600 - if (tegra->padctl_irq <= 0) { 1601 - err = (tegra->padctl_irq == 0) ? -ENODEV : tegra->padctl_irq; 1602 - goto put_padctl; 1603 - } 1604 - } else { 1597 + tegra->padctl_irq = of_irq_get(np, 0); 1598 + if (tegra->padctl_irq == -EPROBE_DEFER) { 1599 + err = tegra->padctl_irq; 1600 + goto put_padctl; 1601 + } else if (tegra->padctl_irq <= 0) { 1602 + /* Older device-trees don't have padctrl interrupt */ 1603 + tegra->padctl_irq = 0; 1605 1604 dev_dbg(&pdev->dev, 1606 1605 "%pOF is missing an interrupt, disabling PM support\n", np); 1607 1606 }
+1
drivers/usb/host/xhci-trace.c
··· 12 12 #include "xhci-trace.h" 13 13 14 14 EXPORT_TRACEPOINT_SYMBOL_GPL(xhci_dbg_quirks); 15 + EXPORT_TRACEPOINT_SYMBOL_GPL(xhci_dbg_init);
+7 -13
drivers/usb/host/xhci-trace.h
··· 120 120 __field(u32, field1) 121 121 __field(u32, field2) 122 122 __field(u32, field3) 123 - __dynamic_array(char, str, XHCI_MSG_MAX) 124 123 ), 125 124 TP_fast_assign( 126 125 __entry->type = ring->type; ··· 129 130 __entry->field3 = le32_to_cpu(trb->field[3]); 130 131 ), 131 132 TP_printk("%s: %s", xhci_ring_type_string(__entry->type), 132 - xhci_decode_trb(__get_str(str), XHCI_MSG_MAX, __entry->field0, __entry->field1, 133 - __entry->field2, __entry->field3) 133 + xhci_decode_trb(__get_buf(XHCI_MSG_MAX), XHCI_MSG_MAX, __entry->field0, 134 + __entry->field1, __entry->field2, __entry->field3) 134 135 ) 135 136 ); 136 137 ··· 321 322 __field(u32, info2) 322 323 __field(u64, deq) 323 324 __field(u32, tx_info) 324 - __dynamic_array(char, str, XHCI_MSG_MAX) 325 325 ), 326 326 TP_fast_assign( 327 327 __entry->info = le32_to_cpu(ctx->ep_info); ··· 328 330 __entry->deq = le64_to_cpu(ctx->deq); 329 331 __entry->tx_info = le32_to_cpu(ctx->tx_info); 330 332 ), 331 - TP_printk("%s", xhci_decode_ep_context(__get_str(str), 333 + TP_printk("%s", xhci_decode_ep_context(__get_buf(XHCI_MSG_MAX), 332 334 __entry->info, __entry->info2, __entry->deq, __entry->tx_info) 333 335 ) 334 336 ); ··· 366 368 __field(u32, info2) 367 369 __field(u32, tt_info) 368 370 __field(u32, state) 369 - __dynamic_array(char, str, XHCI_MSG_MAX) 370 371 ), 371 372 TP_fast_assign( 372 373 __entry->info = le32_to_cpu(ctx->dev_info); ··· 373 376 __entry->tt_info = le64_to_cpu(ctx->tt_info); 374 377 __entry->state = le32_to_cpu(ctx->dev_state); 375 378 ), 376 - TP_printk("%s", xhci_decode_slot_context(__get_str(str), 379 + TP_printk("%s", xhci_decode_slot_context(__get_buf(XHCI_MSG_MAX), 377 380 __entry->info, __entry->info2, 378 381 __entry->tt_info, __entry->state) 379 382 ) ··· 430 433 TP_STRUCT__entry( 431 434 __field(u32, drop) 432 435 __field(u32, add) 433 - __dynamic_array(char, str, XHCI_MSG_MAX) 434 436 ), 435 437 TP_fast_assign( 436 438 __entry->drop = le32_to_cpu(ctrl_ctx->drop_flags); 437 439 __entry->add = le32_to_cpu(ctrl_ctx->add_flags); 438 440 ), 439 - TP_printk("%s", xhci_decode_ctrl_ctx(__get_str(str), __entry->drop, __entry->add) 441 + TP_printk("%s", xhci_decode_ctrl_ctx(__get_buf(XHCI_MSG_MAX), __entry->drop, __entry->add) 440 442 ) 441 443 ); 442 444 ··· 521 525 TP_STRUCT__entry( 522 526 __field(u32, portnum) 523 527 __field(u32, portsc) 524 - __dynamic_array(char, str, XHCI_MSG_MAX) 525 528 ), 526 529 TP_fast_assign( 527 530 __entry->portnum = portnum; ··· 528 533 ), 529 534 TP_printk("port-%d: %s", 530 535 __entry->portnum, 531 - xhci_decode_portsc(__get_str(str), __entry->portsc) 536 + xhci_decode_portsc(__get_buf(XHCI_MSG_MAX), __entry->portsc) 532 537 ) 533 538 ); 534 539 ··· 553 558 TP_STRUCT__entry( 554 559 __field(u32, slot) 555 560 __field(u32, doorbell) 556 - __dynamic_array(char, str, XHCI_MSG_MAX) 557 561 ), 558 562 TP_fast_assign( 559 563 __entry->slot = slot; 560 564 __entry->doorbell = doorbell; 561 565 ), 562 566 TP_printk("Ring doorbell for %s", 563 - xhci_decode_doorbell(__get_str(str), __entry->slot, __entry->doorbell) 567 + xhci_decode_doorbell(__get_buf(XHCI_MSG_MAX), __entry->slot, __entry->doorbell) 564 568 ) 565 569 ); 566 570
+2 -200
drivers/usb/host/xhci.c
··· 322 322 return 0; 323 323 } 324 324 325 - #ifdef CONFIG_USB_PCI 326 - /* 327 - * Set up MSI 328 - */ 329 - static int xhci_setup_msi(struct xhci_hcd *xhci) 330 - { 331 - int ret; 332 - /* 333 - * TODO:Check with MSI Soc for sysdev 334 - */ 335 - struct pci_dev *pdev = to_pci_dev(xhci_to_hcd(xhci)->self.controller); 336 - 337 - ret = pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_MSI); 338 - if (ret < 0) { 339 - xhci_dbg_trace(xhci, trace_xhci_dbg_init, 340 - "failed to allocate MSI entry"); 341 - return ret; 342 - } 343 - 344 - ret = request_irq(pdev->irq, xhci_msi_irq, 345 - 0, "xhci_hcd", xhci_to_hcd(xhci)); 346 - if (ret) { 347 - xhci_dbg_trace(xhci, trace_xhci_dbg_init, 348 - "disable MSI interrupt"); 349 - pci_free_irq_vectors(pdev); 350 - } 351 - 352 - return ret; 353 - } 354 - 355 - /* 356 - * Set up MSI-X 357 - */ 358 - static int xhci_setup_msix(struct xhci_hcd *xhci) 359 - { 360 - int i, ret; 361 - struct usb_hcd *hcd = xhci_to_hcd(xhci); 362 - struct pci_dev *pdev = to_pci_dev(hcd->self.controller); 363 - 364 - /* 365 - * calculate number of msi-x vectors supported. 366 - * - HCS_MAX_INTRS: the max number of interrupts the host can handle, 367 - * with max number of interrupters based on the xhci HCSPARAMS1. 368 - * - num_online_cpus: maximum msi-x vectors per CPUs core. 369 - * Add additional 1 vector to ensure always available interrupt. 370 - */ 371 - xhci->msix_count = min(num_online_cpus() + 1, 372 - HCS_MAX_INTRS(xhci->hcs_params1)); 373 - 374 - ret = pci_alloc_irq_vectors(pdev, xhci->msix_count, xhci->msix_count, 375 - PCI_IRQ_MSIX); 376 - if (ret < 0) { 377 - xhci_dbg_trace(xhci, trace_xhci_dbg_init, 378 - "Failed to enable MSI-X"); 379 - return ret; 380 - } 381 - 382 - for (i = 0; i < xhci->msix_count; i++) { 383 - ret = request_irq(pci_irq_vector(pdev, i), xhci_msi_irq, 0, 384 - "xhci_hcd", xhci_to_hcd(xhci)); 385 - if (ret) 386 - goto disable_msix; 387 - } 388 - 389 - hcd->msix_enabled = 1; 390 - return ret; 391 - 392 - disable_msix: 393 - xhci_dbg_trace(xhci, trace_xhci_dbg_init, "disable MSI-X interrupt"); 394 - while (--i >= 0) 395 - free_irq(pci_irq_vector(pdev, i), xhci_to_hcd(xhci)); 396 - pci_free_irq_vectors(pdev); 397 - return ret; 398 - } 399 - 400 - /* Free any IRQs and disable MSI-X */ 401 - static void xhci_cleanup_msix(struct xhci_hcd *xhci) 402 - { 403 - struct usb_hcd *hcd = xhci_to_hcd(xhci); 404 - struct pci_dev *pdev = to_pci_dev(hcd->self.controller); 405 - 406 - if (xhci->quirks & XHCI_PLAT) 407 - return; 408 - 409 - /* return if using legacy interrupt */ 410 - if (hcd->irq > 0) 411 - return; 412 - 413 - if (hcd->msix_enabled) { 414 - int i; 415 - 416 - for (i = 0; i < xhci->msix_count; i++) 417 - free_irq(pci_irq_vector(pdev, i), xhci_to_hcd(xhci)); 418 - } else { 419 - free_irq(pci_irq_vector(pdev, 0), xhci_to_hcd(xhci)); 420 - } 421 - 422 - pci_free_irq_vectors(pdev); 423 - hcd->msix_enabled = 0; 424 - } 425 - 426 - static void __maybe_unused xhci_msix_sync_irqs(struct xhci_hcd *xhci) 427 - { 428 - struct usb_hcd *hcd = xhci_to_hcd(xhci); 429 - 430 - if (hcd->msix_enabled) { 431 - struct pci_dev *pdev = to_pci_dev(hcd->self.controller); 432 - int i; 433 - 434 - for (i = 0; i < xhci->msix_count; i++) 435 - synchronize_irq(pci_irq_vector(pdev, i)); 436 - } 437 - } 438 - 439 - static int xhci_try_enable_msi(struct usb_hcd *hcd) 440 - { 441 - struct xhci_hcd *xhci = hcd_to_xhci(hcd); 442 - struct pci_dev *pdev; 443 - int ret; 444 - 445 - /* The xhci platform device has set up IRQs through usb_add_hcd. */ 446 - if (xhci->quirks & XHCI_PLAT) 447 - return 0; 448 - 449 - pdev = to_pci_dev(xhci_to_hcd(xhci)->self.controller); 450 - /* 451 - * Some Fresco Logic host controllers advertise MSI, but fail to 452 - * generate interrupts. Don't even try to enable MSI. 453 - */ 454 - if (xhci->quirks & XHCI_BROKEN_MSI) 455 - goto legacy_irq; 456 - 457 - /* unregister the legacy interrupt */ 458 - if (hcd->irq) 459 - free_irq(hcd->irq, hcd); 460 - hcd->irq = 0; 461 - 462 - ret = xhci_setup_msix(xhci); 463 - if (ret) 464 - /* fall back to msi*/ 465 - ret = xhci_setup_msi(xhci); 466 - 467 - if (!ret) { 468 - hcd->msi_enabled = 1; 469 - return 0; 470 - } 471 - 472 - if (!pdev->irq) { 473 - xhci_err(xhci, "No msi-x/msi found and no IRQ in BIOS\n"); 474 - return -EINVAL; 475 - } 476 - 477 - legacy_irq: 478 - if (!strlen(hcd->irq_descr)) 479 - snprintf(hcd->irq_descr, sizeof(hcd->irq_descr), "%s:usb%d", 480 - hcd->driver->description, hcd->self.busnum); 481 - 482 - /* fall back to legacy interrupt*/ 483 - ret = request_irq(pdev->irq, &usb_hcd_irq, IRQF_SHARED, 484 - hcd->irq_descr, hcd); 485 - if (ret) { 486 - xhci_err(xhci, "request interrupt %d failed\n", 487 - pdev->irq); 488 - return ret; 489 - } 490 - hcd->irq = pdev->irq; 491 - return 0; 492 - } 493 - 494 - #else 495 - 496 - static inline int xhci_try_enable_msi(struct usb_hcd *hcd) 497 - { 498 - return 0; 499 - } 500 - 501 - static inline void xhci_cleanup_msix(struct xhci_hcd *xhci) 502 - { 503 - } 504 - 505 - static inline void xhci_msix_sync_irqs(struct xhci_hcd *xhci) 506 - { 507 - } 508 - 509 - #endif 510 - 511 325 static void compliance_mode_recovery(struct timer_list *t) 512 326 { 513 327 struct xhci_hcd *xhci; ··· 519 705 520 706 xhci_dbg_trace(xhci, trace_xhci_dbg_init, "xhci_run"); 521 707 522 - ret = xhci_try_enable_msi(hcd); 523 - if (ret) 524 - return ret; 525 - 526 708 temp_64 = xhci_read_64(xhci, &ir->ir_set->erst_dequeue); 527 709 temp_64 &= ~ERST_PTR_MASK; 528 710 xhci_dbg_trace(xhci, trace_xhci_dbg_init, ··· 568 758 * Disable device contexts, disable IRQs, and quiesce the HC. 569 759 * Reset the HC, finish any completed transactions, and cleanup memory. 570 760 */ 571 - static void xhci_stop(struct usb_hcd *hcd) 761 + void xhci_stop(struct usb_hcd *hcd) 572 762 { 573 763 u32 temp; 574 764 struct xhci_hcd *xhci = hcd_to_xhci(hcd); ··· 590 780 xhci_halt(xhci); 591 781 xhci_reset(xhci, XHCI_RESET_SHORT_USEC); 592 782 spin_unlock_irq(&xhci->lock); 593 - 594 - xhci_cleanup_msix(xhci); 595 783 596 784 /* Deleting Compliance Mode Recovery Timer */ 597 785 if ((xhci->quirks & XHCI_COMP_MODE_QUIRK) && ··· 617 809 readl(&xhci->op_regs->status)); 618 810 mutex_unlock(&xhci->mutex); 619 811 } 812 + EXPORT_SYMBOL_GPL(xhci_stop); 620 813 621 814 /* 622 815 * Shutdown HC (not bus-specific) ··· 658 849 xhci_reset(xhci, XHCI_RESET_SHORT_USEC); 659 850 660 851 spin_unlock_irq(&xhci->lock); 661 - 662 - xhci_cleanup_msix(xhci); 663 852 664 853 xhci_dbg_trace(xhci, trace_xhci_dbg_init, 665 854 "xhci_shutdown completed - status = %x", ··· 950 1143 __func__); 951 1144 } 952 1145 953 - /* step 5: remove core well power */ 954 - /* synchronize irq when using MSI-X */ 955 - xhci_msix_sync_irqs(xhci); 956 - 957 1146 return rc; 958 1147 } 959 1148 EXPORT_SYMBOL_GPL(xhci_suspend); ··· 1053 1250 spin_unlock_irq(&xhci->lock); 1054 1251 if (retval) 1055 1252 return retval; 1056 - xhci_cleanup_msix(xhci); 1057 1253 1058 1254 xhci_dbg(xhci, "// Disabling event ring interrupts\n"); 1059 1255 temp = readl(&xhci->op_regs->status);
+1
drivers/usb/host/xhci.h
··· 2125 2125 int xhci_run(struct usb_hcd *hcd); 2126 2126 int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks); 2127 2127 void xhci_shutdown(struct usb_hcd *hcd); 2128 + void xhci_stop(struct usb_hcd *hcd); 2128 2129 void xhci_init_driver(struct hc_driver *drv, 2129 2130 const struct xhci_driver_overrides *over); 2130 2131 int xhci_add_endpoint(struct usb_hcd *hcd, struct usb_device *udev,
+29 -22
drivers/usb/misc/Kconfig
··· 4 4 # 5 5 comment "USB Miscellaneous drivers" 6 6 7 + config USB_USS720 8 + tristate "USS720 parport driver" 9 + depends on PARPORT 10 + select PARPORT_NOT_PC 11 + help 12 + This driver is for USB parallel port adapters that use the Lucent 13 + Technologies USS-720 chip. These cables are plugged into your USB 14 + port and provide USB compatibility to peripherals designed with 15 + parallel port interfaces. 16 + 17 + The chip has two modes: automatic mode and manual mode. In automatic 18 + mode, it looks to the computer like a standard USB printer. Only 19 + printers may be connected to the USS-720 in this mode. The generic 20 + USB printer driver ("USB Printer support", above) may be used in 21 + that mode, and you can say N here if you want to use the chip only 22 + in this mode. 23 + 24 + Manual mode is not limited to printers, any parallel port 25 + device should work. This driver utilizes manual mode. 26 + Note however that some operations are three orders of magnitude 27 + slower than on a PCI/ISA Parallel Port, so timing critical 28 + applications might not work. 29 + 30 + Say Y here if you own an USS-720 USB->Parport cable and intend to 31 + connect anything other than a printer to it. 32 + 33 + To compile this driver as a module, choose M here: the 34 + module will be called uss720. 35 + 7 36 config USB_EMI62 8 37 tristate "EMI 6|2m USB Audio interface support" 9 38 help ··· 136 107 which can be used by, e.g.,"cat /dev/idmouse0 > fingerprint.pnm". 137 108 138 109 See also <https://www.fs.tum.de/~echtler/idmouse/>. 139 - 140 - config USB_FTDI_ELAN 141 - tristate "Elan PCMCIA CardBus Adapter USB Client" 142 - help 143 - ELAN's Uxxx series of adapters are USB to PCMCIA CardBus adapters. 144 - Currently only the U132 adapter is available. 145 - 146 - The U132 is specifically designed for CardBus PC cards that contain 147 - an OHCI host controller. Typical PC cards are the Orange Mobile 3G 148 - Option GlobeTrotter Fusion card. The U132 adapter will *NOT* work 149 - with PC cards that do not contain an OHCI controller. To use a U132 150 - adapter you will need this "ftdi-elan" module as well as the "u132-hcd" 151 - module which is a USB host controller driver that talks to the OHCI 152 - controller within CardBus card that are inserted in the U132 adapter. 153 - 154 - This driver has been tested with a CardBus OHCI USB adapter, and 155 - worked with a USB PEN Drive inserted into the first USB port of 156 - the PCCARD. A rather pointless thing to do, but useful for testing. 157 - 158 - See also the USB_U132_HCD entry "Elan U132 Adapter Host Controller" 159 - 160 - It is safe to say M here. 161 110 162 111 config USB_APPLEDISPLAY 163 112 tristate "Apple Cinema Display support"
-1
drivers/usb/misc/Makefile
··· 10 10 obj-$(CONFIG_USB_EMI26) += emi26.o 11 11 obj-$(CONFIG_USB_EMI62) += emi62.o 12 12 obj-$(CONFIG_USB_EZUSB_FX2) += ezusb.o 13 - obj-$(CONFIG_USB_FTDI_ELAN) += ftdi-elan.o 14 13 obj-$(CONFIG_APPLE_MFI_FASTCHARGE) += apple-mfi-fastcharge.o 15 14 obj-$(CONFIG_USB_IDMOUSE) += idmouse.o 16 15 obj-$(CONFIG_USB_IOWARRIOR) += iowarrior.o
-2780
drivers/usb/misc/ftdi-elan.c
··· 1 - // SPDX-License-Identifier: GPL-2.0 2 - /* 3 - * USB FTDI client driver for Elan Digital Systems's Uxxx adapters 4 - * 5 - * Copyright(C) 2006 Elan Digital Systems Limited 6 - * http://www.elandigitalsystems.com 7 - * 8 - * Author and Maintainer - Tony Olech - Elan Digital Systems 9 - * tony.olech@elandigitalsystems.com 10 - * 11 - * This driver was written by Tony Olech(tony.olech@elandigitalsystems.com) 12 - * based on various USB client drivers in the 2.6.15 linux kernel 13 - * with constant reference to the 3rd Edition of Linux Device Drivers 14 - * published by O'Reilly 15 - * 16 - * The U132 adapter is a USB to CardBus adapter specifically designed 17 - * for PC cards that contain an OHCI host controller. Typical PC cards 18 - * are the Orange Mobile 3G Option GlobeTrotter Fusion card. 19 - * 20 - * The U132 adapter will *NOT *work with PC cards that do not contain 21 - * an OHCI controller. A simple way to test whether a PC card has an 22 - * OHCI controller as an interface is to insert the PC card directly 23 - * into a laptop(or desktop) with a CardBus slot and if "lspci" shows 24 - * a new USB controller and "lsusb -v" shows a new OHCI Host Controller 25 - * then there is a good chance that the U132 adapter will support the 26 - * PC card.(you also need the specific client driver for the PC card) 27 - * 28 - * Please inform the Author and Maintainer about any PC cards that 29 - * contain OHCI Host Controller and work when directly connected to 30 - * an embedded CardBus slot but do not work when they are connected 31 - * via an ELAN U132 adapter. 32 - * 33 - */ 34 - 35 - #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 36 - 37 - #include <linux/kernel.h> 38 - #include <linux/errno.h> 39 - #include <linux/init.h> 40 - #include <linux/list.h> 41 - #include <linux/ioctl.h> 42 - #include <linux/pci_ids.h> 43 - #include <linux/slab.h> 44 - #include <linux/module.h> 45 - #include <linux/kref.h> 46 - #include <linux/mutex.h> 47 - #include <linux/uaccess.h> 48 - #include <linux/usb.h> 49 - #include <linux/workqueue.h> 50 - #include <linux/platform_device.h> 51 - MODULE_AUTHOR("Tony Olech"); 52 - MODULE_DESCRIPTION("FTDI ELAN driver"); 53 - MODULE_LICENSE("GPL"); 54 - #define INT_MODULE_PARM(n, v) static int n = v;module_param(n, int, 0444) 55 - static bool distrust_firmware = 1; 56 - module_param(distrust_firmware, bool, 0); 57 - MODULE_PARM_DESC(distrust_firmware, 58 - "true to distrust firmware power/overcurrent setup"); 59 - extern struct platform_driver u132_platform_driver; 60 - /* 61 - * ftdi_module_lock exists to protect access to global variables 62 - * 63 - */ 64 - static struct mutex ftdi_module_lock; 65 - static int ftdi_instances = 0; 66 - static struct list_head ftdi_static_list; 67 - /* 68 - * end of the global variables protected by ftdi_module_lock 69 - */ 70 - #include "usb_u132.h" 71 - #include <asm/io.h> 72 - #include <linux/usb/hcd.h> 73 - 74 - /* FIXME ohci.h is ONLY for internal use by the OHCI driver. 75 - * If you're going to try stuff like this, you need to split 76 - * out shareable stuff (register declarations?) into its own 77 - * file, maybe name <linux/usb/ohci.h> 78 - */ 79 - 80 - #include "../host/ohci.h" 81 - /* Define these values to match your devices*/ 82 - #define USB_FTDI_ELAN_VENDOR_ID 0x0403 83 - #define USB_FTDI_ELAN_PRODUCT_ID 0xd6ea 84 - /* table of devices that work with this driver*/ 85 - static const struct usb_device_id ftdi_elan_table[] = { 86 - {USB_DEVICE(USB_FTDI_ELAN_VENDOR_ID, USB_FTDI_ELAN_PRODUCT_ID)}, 87 - { /* Terminating entry */ } 88 - }; 89 - 90 - MODULE_DEVICE_TABLE(usb, ftdi_elan_table); 91 - /* only the jtag(firmware upgrade device) interface requires 92 - * a device file and corresponding minor number, but the 93 - * interface is created unconditionally - I suppose it could 94 - * be configured or not according to a module parameter. 95 - * But since we(now) require one interface per device, 96 - * and since it unlikely that a normal installation would 97 - * require more than a couple of elan-ftdi devices, 8 seems 98 - * like a reasonable limit to have here, and if someone 99 - * really requires more than 8 devices, then they can frig the 100 - * code and recompile 101 - */ 102 - #define USB_FTDI_ELAN_MINOR_BASE 192 103 - #define COMMAND_BITS 5 104 - #define COMMAND_SIZE (1<<COMMAND_BITS) 105 - #define COMMAND_MASK (COMMAND_SIZE-1) 106 - struct u132_command { 107 - u8 header; 108 - u16 length; 109 - u8 address; 110 - u8 width; 111 - u32 value; 112 - int follows; 113 - void *buffer; 114 - }; 115 - #define RESPOND_BITS 5 116 - #define RESPOND_SIZE (1<<RESPOND_BITS) 117 - #define RESPOND_MASK (RESPOND_SIZE-1) 118 - struct u132_respond { 119 - u8 header; 120 - u8 address; 121 - u32 *value; 122 - int *result; 123 - struct completion wait_completion; 124 - }; 125 - struct u132_target { 126 - void *endp; 127 - struct urb *urb; 128 - int toggle_bits; 129 - int error_count; 130 - int condition_code; 131 - int repeat_number; 132 - int halted; 133 - int skipped; 134 - int actual; 135 - int non_null; 136 - int active; 137 - int abandoning; 138 - void (*callback)(void *endp, struct urb *urb, u8 *buf, int len, 139 - int toggle_bits, int error_count, int condition_code, 140 - int repeat_number, int halted, int skipped, int actual, 141 - int non_null); 142 - }; 143 - /* Structure to hold all of our device specific stuff*/ 144 - struct usb_ftdi { 145 - struct list_head ftdi_list; 146 - struct mutex u132_lock; 147 - int command_next; 148 - int command_head; 149 - struct u132_command command[COMMAND_SIZE]; 150 - int respond_next; 151 - int respond_head; 152 - struct u132_respond respond[RESPOND_SIZE]; 153 - struct u132_target target[4]; 154 - char device_name[16]; 155 - unsigned synchronized:1; 156 - unsigned enumerated:1; 157 - unsigned registered:1; 158 - unsigned initialized:1; 159 - unsigned card_ejected:1; 160 - int function; 161 - int sequence_num; 162 - int disconnected; 163 - int gone_away; 164 - int stuck_status; 165 - int status_queue_delay; 166 - struct semaphore sw_lock; 167 - struct usb_device *udev; 168 - struct usb_interface *interface; 169 - struct usb_class_driver *class; 170 - struct delayed_work status_work; 171 - struct delayed_work command_work; 172 - struct delayed_work respond_work; 173 - struct u132_platform_data platform_data; 174 - struct resource resources[0]; 175 - struct platform_device platform_dev; 176 - unsigned char *bulk_in_buffer; 177 - size_t bulk_in_size; 178 - size_t bulk_in_last; 179 - size_t bulk_in_left; 180 - __u8 bulk_in_endpointAddr; 181 - __u8 bulk_out_endpointAddr; 182 - struct kref kref; 183 - u32 controlreg; 184 - u8 response[4 + 1024]; 185 - int expected; 186 - int received; 187 - int ed_found; 188 - }; 189 - #define kref_to_usb_ftdi(d) container_of(d, struct usb_ftdi, kref) 190 - #define platform_device_to_usb_ftdi(d) container_of(d, struct usb_ftdi, \ 191 - platform_dev) 192 - static struct usb_driver ftdi_elan_driver; 193 - static void ftdi_elan_delete(struct kref *kref) 194 - { 195 - struct usb_ftdi *ftdi = kref_to_usb_ftdi(kref); 196 - dev_warn(&ftdi->udev->dev, "FREEING ftdi=%p\n", ftdi); 197 - usb_put_dev(ftdi->udev); 198 - ftdi->disconnected += 1; 199 - mutex_lock(&ftdi_module_lock); 200 - list_del_init(&ftdi->ftdi_list); 201 - ftdi_instances -= 1; 202 - mutex_unlock(&ftdi_module_lock); 203 - kfree(ftdi->bulk_in_buffer); 204 - ftdi->bulk_in_buffer = NULL; 205 - kfree(ftdi); 206 - } 207 - 208 - static void ftdi_elan_put_kref(struct usb_ftdi *ftdi) 209 - { 210 - kref_put(&ftdi->kref, ftdi_elan_delete); 211 - } 212 - 213 - static void ftdi_elan_get_kref(struct usb_ftdi *ftdi) 214 - { 215 - kref_get(&ftdi->kref); 216 - } 217 - 218 - static void ftdi_elan_init_kref(struct usb_ftdi *ftdi) 219 - { 220 - kref_init(&ftdi->kref); 221 - } 222 - 223 - static void ftdi_status_requeue_work(struct usb_ftdi *ftdi, unsigned int delta) 224 - { 225 - if (!schedule_delayed_work(&ftdi->status_work, delta)) 226 - kref_put(&ftdi->kref, ftdi_elan_delete); 227 - } 228 - 229 - static void ftdi_status_queue_work(struct usb_ftdi *ftdi, unsigned int delta) 230 - { 231 - if (schedule_delayed_work(&ftdi->status_work, delta)) 232 - kref_get(&ftdi->kref); 233 - } 234 - 235 - static void ftdi_status_cancel_work(struct usb_ftdi *ftdi) 236 - { 237 - if (cancel_delayed_work_sync(&ftdi->status_work)) 238 - kref_put(&ftdi->kref, ftdi_elan_delete); 239 - } 240 - 241 - static void ftdi_command_requeue_work(struct usb_ftdi *ftdi, unsigned int delta) 242 - { 243 - if (!schedule_delayed_work(&ftdi->command_work, delta)) 244 - kref_put(&ftdi->kref, ftdi_elan_delete); 245 - } 246 - 247 - static void ftdi_command_queue_work(struct usb_ftdi *ftdi, unsigned int delta) 248 - { 249 - if (schedule_delayed_work(&ftdi->command_work, delta)) 250 - kref_get(&ftdi->kref); 251 - } 252 - 253 - static void ftdi_command_cancel_work(struct usb_ftdi *ftdi) 254 - { 255 - if (cancel_delayed_work_sync(&ftdi->command_work)) 256 - kref_put(&ftdi->kref, ftdi_elan_delete); 257 - } 258 - 259 - static void ftdi_response_requeue_work(struct usb_ftdi *ftdi, 260 - unsigned int delta) 261 - { 262 - if (!schedule_delayed_work(&ftdi->respond_work, delta)) 263 - kref_put(&ftdi->kref, ftdi_elan_delete); 264 - } 265 - 266 - static void ftdi_respond_queue_work(struct usb_ftdi *ftdi, unsigned int delta) 267 - { 268 - if (schedule_delayed_work(&ftdi->respond_work, delta)) 269 - kref_get(&ftdi->kref); 270 - } 271 - 272 - static void ftdi_response_cancel_work(struct usb_ftdi *ftdi) 273 - { 274 - if (cancel_delayed_work_sync(&ftdi->respond_work)) 275 - kref_put(&ftdi->kref, ftdi_elan_delete); 276 - } 277 - 278 - void ftdi_elan_gone_away(struct platform_device *pdev) 279 - { 280 - struct usb_ftdi *ftdi = platform_device_to_usb_ftdi(pdev); 281 - ftdi->gone_away += 1; 282 - ftdi_elan_put_kref(ftdi); 283 - } 284 - 285 - 286 - EXPORT_SYMBOL_GPL(ftdi_elan_gone_away); 287 - static void ftdi_release_platform_dev(struct device *dev) 288 - { 289 - dev->parent = NULL; 290 - } 291 - 292 - static void ftdi_elan_do_callback(struct usb_ftdi *ftdi, 293 - struct u132_target *target, u8 *buffer, int length); 294 - static void ftdi_elan_kick_command_queue(struct usb_ftdi *ftdi); 295 - static void ftdi_elan_kick_respond_queue(struct usb_ftdi *ftdi); 296 - static int ftdi_elan_setupOHCI(struct usb_ftdi *ftdi); 297 - static int ftdi_elan_checkingPCI(struct usb_ftdi *ftdi); 298 - static int ftdi_elan_enumeratePCI(struct usb_ftdi *ftdi); 299 - static int ftdi_elan_synchronize(struct usb_ftdi *ftdi); 300 - static int ftdi_elan_stuck_waiting(struct usb_ftdi *ftdi); 301 - static int ftdi_elan_command_engine(struct usb_ftdi *ftdi); 302 - static int ftdi_elan_respond_engine(struct usb_ftdi *ftdi); 303 - static int ftdi_elan_hcd_init(struct usb_ftdi *ftdi) 304 - { 305 - if (ftdi->platform_dev.dev.parent) 306 - return -EBUSY; 307 - 308 - ftdi_elan_get_kref(ftdi); 309 - ftdi->platform_data.potpg = 100; 310 - ftdi->platform_data.reset = NULL; 311 - ftdi->platform_dev.id = ftdi->sequence_num; 312 - ftdi->platform_dev.resource = ftdi->resources; 313 - ftdi->platform_dev.num_resources = ARRAY_SIZE(ftdi->resources); 314 - ftdi->platform_dev.dev.platform_data = &ftdi->platform_data; 315 - ftdi->platform_dev.dev.parent = NULL; 316 - ftdi->platform_dev.dev.release = ftdi_release_platform_dev; 317 - ftdi->platform_dev.dev.dma_mask = NULL; 318 - snprintf(ftdi->device_name, sizeof(ftdi->device_name), "u132_hcd"); 319 - ftdi->platform_dev.name = ftdi->device_name; 320 - dev_info(&ftdi->udev->dev, "requesting module '%s'\n", "u132_hcd"); 321 - request_module("u132_hcd"); 322 - dev_info(&ftdi->udev->dev, "registering '%s'\n", 323 - ftdi->platform_dev.name); 324 - 325 - return platform_device_register(&ftdi->platform_dev); 326 - } 327 - 328 - static void ftdi_elan_abandon_completions(struct usb_ftdi *ftdi) 329 - { 330 - mutex_lock(&ftdi->u132_lock); 331 - while (ftdi->respond_next > ftdi->respond_head) { 332 - struct u132_respond *respond = &ftdi->respond[RESPOND_MASK & 333 - ftdi->respond_head++]; 334 - *respond->result = -ESHUTDOWN; 335 - *respond->value = 0; 336 - complete(&respond->wait_completion); 337 - } 338 - mutex_unlock(&ftdi->u132_lock); 339 - } 340 - 341 - static void ftdi_elan_abandon_targets(struct usb_ftdi *ftdi) 342 - { 343 - int ed_number = 4; 344 - mutex_lock(&ftdi->u132_lock); 345 - while (ed_number-- > 0) { 346 - struct u132_target *target = &ftdi->target[ed_number]; 347 - if (target->active == 1) { 348 - target->condition_code = TD_DEVNOTRESP; 349 - mutex_unlock(&ftdi->u132_lock); 350 - ftdi_elan_do_callback(ftdi, target, NULL, 0); 351 - mutex_lock(&ftdi->u132_lock); 352 - } 353 - } 354 - ftdi->received = 0; 355 - ftdi->expected = 4; 356 - ftdi->ed_found = 0; 357 - mutex_unlock(&ftdi->u132_lock); 358 - } 359 - 360 - static void ftdi_elan_flush_targets(struct usb_ftdi *ftdi) 361 - { 362 - int ed_number = 4; 363 - mutex_lock(&ftdi->u132_lock); 364 - while (ed_number-- > 0) { 365 - struct u132_target *target = &ftdi->target[ed_number]; 366 - target->abandoning = 1; 367 - wait_1:if (target->active == 1) { 368 - int command_size = ftdi->command_next - 369 - ftdi->command_head; 370 - if (command_size < COMMAND_SIZE) { 371 - struct u132_command *command = &ftdi->command[ 372 - COMMAND_MASK & ftdi->command_next]; 373 - command->header = 0x80 | (ed_number << 5) | 0x4; 374 - command->length = 0x00; 375 - command->address = 0x00; 376 - command->width = 0x00; 377 - command->follows = 0; 378 - command->value = 0; 379 - command->buffer = &command->value; 380 - ftdi->command_next += 1; 381 - ftdi_elan_kick_command_queue(ftdi); 382 - } else { 383 - mutex_unlock(&ftdi->u132_lock); 384 - msleep(100); 385 - mutex_lock(&ftdi->u132_lock); 386 - goto wait_1; 387 - } 388 - } 389 - wait_2:if (target->active == 1) { 390 - int command_size = ftdi->command_next - 391 - ftdi->command_head; 392 - if (command_size < COMMAND_SIZE) { 393 - struct u132_command *command = &ftdi->command[ 394 - COMMAND_MASK & ftdi->command_next]; 395 - command->header = 0x90 | (ed_number << 5); 396 - command->length = 0x00; 397 - command->address = 0x00; 398 - command->width = 0x00; 399 - command->follows = 0; 400 - command->value = 0; 401 - command->buffer = &command->value; 402 - ftdi->command_next += 1; 403 - ftdi_elan_kick_command_queue(ftdi); 404 - } else { 405 - mutex_unlock(&ftdi->u132_lock); 406 - msleep(100); 407 - mutex_lock(&ftdi->u132_lock); 408 - goto wait_2; 409 - } 410 - } 411 - } 412 - ftdi->received = 0; 413 - ftdi->expected = 4; 414 - ftdi->ed_found = 0; 415 - mutex_unlock(&ftdi->u132_lock); 416 - } 417 - 418 - static void ftdi_elan_cancel_targets(struct usb_ftdi *ftdi) 419 - { 420 - int ed_number = 4; 421 - mutex_lock(&ftdi->u132_lock); 422 - while (ed_number-- > 0) { 423 - struct u132_target *target = &ftdi->target[ed_number]; 424 - target->abandoning = 1; 425 - wait:if (target->active == 1) { 426 - int command_size = ftdi->command_next - 427 - ftdi->command_head; 428 - if (command_size < COMMAND_SIZE) { 429 - struct u132_command *command = &ftdi->command[ 430 - COMMAND_MASK & ftdi->command_next]; 431 - command->header = 0x80 | (ed_number << 5) | 0x4; 432 - command->length = 0x00; 433 - command->address = 0x00; 434 - command->width = 0x00; 435 - command->follows = 0; 436 - command->value = 0; 437 - command->buffer = &command->value; 438 - ftdi->command_next += 1; 439 - ftdi_elan_kick_command_queue(ftdi); 440 - } else { 441 - mutex_unlock(&ftdi->u132_lock); 442 - msleep(100); 443 - mutex_lock(&ftdi->u132_lock); 444 - goto wait; 445 - } 446 - } 447 - } 448 - ftdi->received = 0; 449 - ftdi->expected = 4; 450 - ftdi->ed_found = 0; 451 - mutex_unlock(&ftdi->u132_lock); 452 - } 453 - 454 - static void ftdi_elan_kick_command_queue(struct usb_ftdi *ftdi) 455 - { 456 - ftdi_command_queue_work(ftdi, 0); 457 - } 458 - 459 - static void ftdi_elan_command_work(struct work_struct *work) 460 - { 461 - struct usb_ftdi *ftdi = 462 - container_of(work, struct usb_ftdi, command_work.work); 463 - 464 - if (ftdi->disconnected > 0) { 465 - ftdi_elan_put_kref(ftdi); 466 - return; 467 - } else { 468 - int retval = ftdi_elan_command_engine(ftdi); 469 - if (retval == -ESHUTDOWN) { 470 - ftdi->disconnected += 1; 471 - } else if (retval == -ENODEV) { 472 - ftdi->disconnected += 1; 473 - } else if (retval) 474 - dev_err(&ftdi->udev->dev, "command error %d\n", retval); 475 - ftdi_command_requeue_work(ftdi, msecs_to_jiffies(10)); 476 - return; 477 - } 478 - } 479 - 480 - static void ftdi_elan_kick_respond_queue(struct usb_ftdi *ftdi) 481 - { 482 - ftdi_respond_queue_work(ftdi, 0); 483 - } 484 - 485 - static void ftdi_elan_respond_work(struct work_struct *work) 486 - { 487 - struct usb_ftdi *ftdi = 488 - container_of(work, struct usb_ftdi, respond_work.work); 489 - if (ftdi->disconnected > 0) { 490 - ftdi_elan_put_kref(ftdi); 491 - return; 492 - } else { 493 - int retval = ftdi_elan_respond_engine(ftdi); 494 - if (retval == 0) { 495 - } else if (retval == -ESHUTDOWN) { 496 - ftdi->disconnected += 1; 497 - } else if (retval == -ENODEV) { 498 - ftdi->disconnected += 1; 499 - } else if (retval == -EILSEQ) { 500 - ftdi->disconnected += 1; 501 - } else { 502 - ftdi->disconnected += 1; 503 - dev_err(&ftdi->udev->dev, "respond error %d\n", retval); 504 - } 505 - if (ftdi->disconnected > 0) { 506 - ftdi_elan_abandon_completions(ftdi); 507 - ftdi_elan_abandon_targets(ftdi); 508 - } 509 - ftdi_response_requeue_work(ftdi, msecs_to_jiffies(10)); 510 - return; 511 - } 512 - } 513 - 514 - 515 - /* 516 - * the sw_lock is initially held and will be freed 517 - * after the FTDI has been synchronized 518 - * 519 - */ 520 - static void ftdi_elan_status_work(struct work_struct *work) 521 - { 522 - struct usb_ftdi *ftdi = 523 - container_of(work, struct usb_ftdi, status_work.work); 524 - int work_delay_in_msec = 0; 525 - if (ftdi->disconnected > 0) { 526 - ftdi_elan_put_kref(ftdi); 527 - return; 528 - } else if (ftdi->synchronized == 0) { 529 - down(&ftdi->sw_lock); 530 - if (ftdi_elan_synchronize(ftdi) == 0) { 531 - ftdi->synchronized = 1; 532 - ftdi_command_queue_work(ftdi, 1); 533 - ftdi_respond_queue_work(ftdi, 1); 534 - up(&ftdi->sw_lock); 535 - work_delay_in_msec = 100; 536 - } else { 537 - dev_err(&ftdi->udev->dev, "synchronize failed\n"); 538 - up(&ftdi->sw_lock); 539 - work_delay_in_msec = 10 *1000; 540 - } 541 - } else if (ftdi->stuck_status > 0) { 542 - if (ftdi_elan_stuck_waiting(ftdi) == 0) { 543 - ftdi->stuck_status = 0; 544 - ftdi->synchronized = 0; 545 - } else if ((ftdi->stuck_status++ % 60) == 1) { 546 - dev_err(&ftdi->udev->dev, "WRONG type of card inserted - please remove\n"); 547 - } else 548 - dev_err(&ftdi->udev->dev, "WRONG type of card inserted - checked %d times\n", 549 - ftdi->stuck_status); 550 - work_delay_in_msec = 100; 551 - } else if (ftdi->enumerated == 0) { 552 - if (ftdi_elan_enumeratePCI(ftdi) == 0) { 553 - ftdi->enumerated = 1; 554 - work_delay_in_msec = 250; 555 - } else 556 - work_delay_in_msec = 1000; 557 - } else if (ftdi->initialized == 0) { 558 - if (ftdi_elan_setupOHCI(ftdi) == 0) { 559 - ftdi->initialized = 1; 560 - work_delay_in_msec = 500; 561 - } else { 562 - dev_err(&ftdi->udev->dev, "initialized failed - trying again in 10 seconds\n"); 563 - work_delay_in_msec = 1 *1000; 564 - } 565 - } else if (ftdi->registered == 0) { 566 - work_delay_in_msec = 10; 567 - if (ftdi_elan_hcd_init(ftdi) == 0) { 568 - ftdi->registered = 1; 569 - } else 570 - dev_err(&ftdi->udev->dev, "register failed\n"); 571 - work_delay_in_msec = 250; 572 - } else { 573 - if (ftdi_elan_checkingPCI(ftdi) == 0) { 574 - work_delay_in_msec = 250; 575 - } else if (ftdi->controlreg & 0x00400000) { 576 - if (ftdi->gone_away > 0) { 577 - dev_err(&ftdi->udev->dev, "PCI device eject confirmed platform_dev.dev.parent=%p platform_dev.dev=%p\n", 578 - ftdi->platform_dev.dev.parent, 579 - &ftdi->platform_dev.dev); 580 - platform_device_unregister(&ftdi->platform_dev); 581 - ftdi->platform_dev.dev.parent = NULL; 582 - ftdi->registered = 0; 583 - ftdi->enumerated = 0; 584 - ftdi->card_ejected = 0; 585 - ftdi->initialized = 0; 586 - ftdi->gone_away = 0; 587 - } else 588 - ftdi_elan_flush_targets(ftdi); 589 - work_delay_in_msec = 250; 590 - } else { 591 - dev_err(&ftdi->udev->dev, "PCI device has disappeared\n"); 592 - ftdi_elan_cancel_targets(ftdi); 593 - work_delay_in_msec = 500; 594 - ftdi->enumerated = 0; 595 - ftdi->initialized = 0; 596 - } 597 - } 598 - if (ftdi->disconnected > 0) { 599 - ftdi_elan_put_kref(ftdi); 600 - return; 601 - } else { 602 - ftdi_status_requeue_work(ftdi, 603 - msecs_to_jiffies(work_delay_in_msec)); 604 - return; 605 - } 606 - } 607 - 608 - 609 - /* 610 - * file_operations for the jtag interface 611 - * 612 - * the usage count for the device is incremented on open() 613 - * and decremented on release() 614 - */ 615 - static int ftdi_elan_open(struct inode *inode, struct file *file) 616 - { 617 - int subminor; 618 - struct usb_interface *interface; 619 - 620 - subminor = iminor(inode); 621 - interface = usb_find_interface(&ftdi_elan_driver, subminor); 622 - 623 - if (!interface) { 624 - pr_err("can't find device for minor %d\n", subminor); 625 - return -ENODEV; 626 - } else { 627 - struct usb_ftdi *ftdi = usb_get_intfdata(interface); 628 - if (!ftdi) { 629 - return -ENODEV; 630 - } else { 631 - if (down_interruptible(&ftdi->sw_lock)) { 632 - return -EINTR; 633 - } else { 634 - ftdi_elan_get_kref(ftdi); 635 - file->private_data = ftdi; 636 - return 0; 637 - } 638 - } 639 - } 640 - } 641 - 642 - static int ftdi_elan_release(struct inode *inode, struct file *file) 643 - { 644 - struct usb_ftdi *ftdi = file->private_data; 645 - if (ftdi == NULL) 646 - return -ENODEV; 647 - up(&ftdi->sw_lock); /* decrement the count on our device */ 648 - ftdi_elan_put_kref(ftdi); 649 - return 0; 650 - } 651 - 652 - 653 - /* 654 - * 655 - * blocking bulk reads are used to get data from the device 656 - * 657 - */ 658 - static ssize_t ftdi_elan_read(struct file *file, char __user *buffer, 659 - size_t count, loff_t *ppos) 660 - { 661 - char data[30 *3 + 4]; 662 - char *d = data; 663 - int m = (sizeof(data) - 1) / 3 - 1; 664 - int bytes_read = 0; 665 - int retry_on_empty = 10; 666 - int retry_on_timeout = 5; 667 - struct usb_ftdi *ftdi = file->private_data; 668 - if (ftdi->disconnected > 0) { 669 - return -ENODEV; 670 - } 671 - data[0] = 0; 672 - have:if (ftdi->bulk_in_left > 0) { 673 - if (count-- > 0) { 674 - char *p = ++ftdi->bulk_in_last + ftdi->bulk_in_buffer; 675 - ftdi->bulk_in_left -= 1; 676 - if (bytes_read < m) { 677 - d += sprintf(d, " %02X", 0x000000FF & *p); 678 - } else if (bytes_read > m) { 679 - } else 680 - d += sprintf(d, " .."); 681 - if (copy_to_user(buffer++, p, 1)) { 682 - return -EFAULT; 683 - } else { 684 - bytes_read += 1; 685 - goto have; 686 - } 687 - } else 688 - return bytes_read; 689 - } 690 - more:if (count > 0) { 691 - int packet_bytes = 0; 692 - int retval = usb_bulk_msg(ftdi->udev, 693 - usb_rcvbulkpipe(ftdi->udev, ftdi->bulk_in_endpointAddr), 694 - ftdi->bulk_in_buffer, ftdi->bulk_in_size, 695 - &packet_bytes, 50); 696 - if (packet_bytes > 2) { 697 - ftdi->bulk_in_left = packet_bytes - 2; 698 - ftdi->bulk_in_last = 1; 699 - goto have; 700 - } else if (retval == -ETIMEDOUT) { 701 - if (retry_on_timeout-- > 0) { 702 - goto more; 703 - } else if (bytes_read > 0) { 704 - return bytes_read; 705 - } else 706 - return retval; 707 - } else if (retval == 0) { 708 - if (retry_on_empty-- > 0) { 709 - goto more; 710 - } else 711 - return bytes_read; 712 - } else 713 - return retval; 714 - } else 715 - return bytes_read; 716 - } 717 - 718 - static void ftdi_elan_write_bulk_callback(struct urb *urb) 719 - { 720 - struct usb_ftdi *ftdi = urb->context; 721 - int status = urb->status; 722 - 723 - if (status && !(status == -ENOENT || status == -ECONNRESET || 724 - status == -ESHUTDOWN)) { 725 - dev_err(&ftdi->udev->dev, 726 - "urb=%p write bulk status received: %d\n", urb, status); 727 - } 728 - usb_free_coherent(urb->dev, urb->transfer_buffer_length, 729 - urb->transfer_buffer, urb->transfer_dma); 730 - } 731 - 732 - static int fill_buffer_with_all_queued_commands(struct usb_ftdi *ftdi, 733 - char *buf, int command_size, int total_size) 734 - { 735 - int ed_commands = 0; 736 - int b = 0; 737 - int I = command_size; 738 - int i = ftdi->command_head; 739 - while (I-- > 0) { 740 - struct u132_command *command = &ftdi->command[COMMAND_MASK & 741 - i++]; 742 - int F = command->follows; 743 - u8 *f = command->buffer; 744 - if (command->header & 0x80) { 745 - ed_commands |= 1 << (0x3 & (command->header >> 5)); 746 - } 747 - buf[b++] = command->header; 748 - buf[b++] = (command->length >> 0) & 0x00FF; 749 - buf[b++] = (command->length >> 8) & 0x00FF; 750 - buf[b++] = command->address; 751 - buf[b++] = command->width; 752 - while (F-- > 0) { 753 - buf[b++] = *f++; 754 - } 755 - } 756 - return ed_commands; 757 - } 758 - 759 - static int ftdi_elan_total_command_size(struct usb_ftdi *ftdi, int command_size) 760 - { 761 - int total_size = 0; 762 - int I = command_size; 763 - int i = ftdi->command_head; 764 - while (I-- > 0) { 765 - struct u132_command *command = &ftdi->command[COMMAND_MASK & 766 - i++]; 767 - total_size += 5 + command->follows; 768 - } 769 - return total_size; 770 - } 771 - 772 - static int ftdi_elan_command_engine(struct usb_ftdi *ftdi) 773 - { 774 - int retval; 775 - char *buf; 776 - int ed_commands; 777 - int total_size; 778 - struct urb *urb; 779 - int command_size = ftdi->command_next - ftdi->command_head; 780 - if (command_size == 0) 781 - return 0; 782 - total_size = ftdi_elan_total_command_size(ftdi, command_size); 783 - urb = usb_alloc_urb(0, GFP_KERNEL); 784 - if (!urb) 785 - return -ENOMEM; 786 - buf = usb_alloc_coherent(ftdi->udev, total_size, GFP_KERNEL, 787 - &urb->transfer_dma); 788 - if (!buf) { 789 - dev_err(&ftdi->udev->dev, "could not get a buffer to write %d commands totaling %d bytes to the Uxxx\n", 790 - command_size, total_size); 791 - usb_free_urb(urb); 792 - return -ENOMEM; 793 - } 794 - ed_commands = fill_buffer_with_all_queued_commands(ftdi, buf, 795 - command_size, total_size); 796 - usb_fill_bulk_urb(urb, ftdi->udev, usb_sndbulkpipe(ftdi->udev, 797 - ftdi->bulk_out_endpointAddr), buf, total_size, 798 - ftdi_elan_write_bulk_callback, ftdi); 799 - urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; 800 - if (ed_commands) { 801 - char diag[40 *3 + 4]; 802 - char *d = diag; 803 - int m = total_size; 804 - u8 *c = buf; 805 - int s = (sizeof(diag) - 1) / 3; 806 - diag[0] = 0; 807 - while (s-- > 0 && m-- > 0) { 808 - if (s > 0 || m == 0) { 809 - d += sprintf(d, " %02X", *c++); 810 - } else 811 - d += sprintf(d, " .."); 812 - } 813 - } 814 - retval = usb_submit_urb(urb, GFP_KERNEL); 815 - if (retval) { 816 - dev_err(&ftdi->udev->dev, "failed %d to submit urb %p to write %d commands totaling %d bytes to the Uxxx\n", 817 - retval, urb, command_size, total_size); 818 - usb_free_coherent(ftdi->udev, total_size, buf, urb->transfer_dma); 819 - usb_free_urb(urb); 820 - return retval; 821 - } 822 - usb_free_urb(urb); /* release our reference to this urb, 823 - the USB core will eventually free it entirely */ 824 - ftdi->command_head += command_size; 825 - ftdi_elan_kick_respond_queue(ftdi); 826 - return 0; 827 - } 828 - 829 - static void ftdi_elan_do_callback(struct usb_ftdi *ftdi, 830 - struct u132_target *target, u8 *buffer, int length) 831 - { 832 - struct urb *urb = target->urb; 833 - int halted = target->halted; 834 - int skipped = target->skipped; 835 - int actual = target->actual; 836 - int non_null = target->non_null; 837 - int toggle_bits = target->toggle_bits; 838 - int error_count = target->error_count; 839 - int condition_code = target->condition_code; 840 - int repeat_number = target->repeat_number; 841 - void (*callback) (void *, struct urb *, u8 *, int, int, int, int, int, 842 - int, int, int, int) = target->callback; 843 - target->active -= 1; 844 - target->callback = NULL; 845 - (*callback) (target->endp, urb, buffer, length, toggle_bits, 846 - error_count, condition_code, repeat_number, halted, skipped, 847 - actual, non_null); 848 - } 849 - 850 - static char *have_ed_set_response(struct usb_ftdi *ftdi, 851 - struct u132_target *target, u16 ed_length, int ed_number, int ed_type, 852 - char *b) 853 - { 854 - int payload = (ed_length >> 0) & 0x07FF; 855 - mutex_lock(&ftdi->u132_lock); 856 - target->actual = 0; 857 - target->non_null = (ed_length >> 15) & 0x0001; 858 - target->repeat_number = (ed_length >> 11) & 0x000F; 859 - if (ed_type == 0x02 || ed_type == 0x03) { 860 - if (payload == 0 || target->abandoning > 0) { 861 - target->abandoning = 0; 862 - mutex_unlock(&ftdi->u132_lock); 863 - ftdi_elan_do_callback(ftdi, target, 4 + ftdi->response, 864 - payload); 865 - ftdi->received = 0; 866 - ftdi->expected = 4; 867 - ftdi->ed_found = 0; 868 - return ftdi->response; 869 - } else { 870 - ftdi->expected = 4 + payload; 871 - ftdi->ed_found = 1; 872 - mutex_unlock(&ftdi->u132_lock); 873 - return b; 874 - } 875 - } else { 876 - target->abandoning = 0; 877 - mutex_unlock(&ftdi->u132_lock); 878 - ftdi_elan_do_callback(ftdi, target, 4 + ftdi->response, 879 - payload); 880 - ftdi->received = 0; 881 - ftdi->expected = 4; 882 - ftdi->ed_found = 0; 883 - return ftdi->response; 884 - } 885 - } 886 - 887 - static char *have_ed_get_response(struct usb_ftdi *ftdi, 888 - struct u132_target *target, u16 ed_length, int ed_number, int ed_type, 889 - char *b) 890 - { 891 - mutex_lock(&ftdi->u132_lock); 892 - target->condition_code = TD_DEVNOTRESP; 893 - target->actual = (ed_length >> 0) & 0x01FF; 894 - target->non_null = (ed_length >> 15) & 0x0001; 895 - target->repeat_number = (ed_length >> 11) & 0x000F; 896 - mutex_unlock(&ftdi->u132_lock); 897 - if (target->active) 898 - ftdi_elan_do_callback(ftdi, target, NULL, 0); 899 - target->abandoning = 0; 900 - ftdi->received = 0; 901 - ftdi->expected = 4; 902 - ftdi->ed_found = 0; 903 - return ftdi->response; 904 - } 905 - 906 - 907 - /* 908 - * The engine tries to empty the FTDI fifo 909 - * 910 - * all responses found in the fifo data are dispatched thus 911 - * the response buffer can only ever hold a maximum sized 912 - * response from the Uxxx. 913 - * 914 - */ 915 - static int ftdi_elan_respond_engine(struct usb_ftdi *ftdi) 916 - { 917 - u8 *b = ftdi->response + ftdi->received; 918 - int bytes_read = 0; 919 - int retry_on_empty = 1; 920 - int retry_on_timeout = 3; 921 - read:{ 922 - int packet_bytes = 0; 923 - int retval = usb_bulk_msg(ftdi->udev, 924 - usb_rcvbulkpipe(ftdi->udev, ftdi->bulk_in_endpointAddr), 925 - ftdi->bulk_in_buffer, ftdi->bulk_in_size, 926 - &packet_bytes, 500); 927 - char diag[30 *3 + 4]; 928 - char *d = diag; 929 - int m = packet_bytes; 930 - u8 *c = ftdi->bulk_in_buffer; 931 - int s = (sizeof(diag) - 1) / 3; 932 - diag[0] = 0; 933 - while (s-- > 0 && m-- > 0) { 934 - if (s > 0 || m == 0) { 935 - d += sprintf(d, " %02X", *c++); 936 - } else 937 - d += sprintf(d, " .."); 938 - } 939 - if (packet_bytes > 2) { 940 - ftdi->bulk_in_left = packet_bytes - 2; 941 - ftdi->bulk_in_last = 1; 942 - goto have; 943 - } else if (retval == -ETIMEDOUT) { 944 - if (retry_on_timeout-- > 0) { 945 - dev_err(&ftdi->udev->dev, "TIMED OUT with packet_bytes = %d with total %d bytes%s\n", 946 - packet_bytes, bytes_read, diag); 947 - goto more; 948 - } else if (bytes_read > 0) { 949 - dev_err(&ftdi->udev->dev, "ONLY %d bytes%s\n", 950 - bytes_read, diag); 951 - return -ENOMEM; 952 - } else { 953 - dev_err(&ftdi->udev->dev, "TIMED OUT with packet_bytes = %d with total %d bytes%s\n", 954 - packet_bytes, bytes_read, diag); 955 - return -ENOMEM; 956 - } 957 - } else if (retval == -EILSEQ) { 958 - dev_err(&ftdi->udev->dev, "error = %d with packet_bytes = %d with total %d bytes%s\n", 959 - retval, packet_bytes, bytes_read, diag); 960 - return retval; 961 - } else if (retval) { 962 - dev_err(&ftdi->udev->dev, "error = %d with packet_bytes = %d with total %d bytes%s\n", 963 - retval, packet_bytes, bytes_read, diag); 964 - return retval; 965 - } else { 966 - if (retry_on_empty-- > 0) { 967 - goto more; 968 - } else 969 - return 0; 970 - } 971 - } 972 - more:{ 973 - goto read; 974 - } 975 - have:if (ftdi->bulk_in_left > 0) { 976 - u8 c = ftdi->bulk_in_buffer[++ftdi->bulk_in_last]; 977 - bytes_read += 1; 978 - ftdi->bulk_in_left -= 1; 979 - if (ftdi->received == 0 && c == 0xFF) { 980 - goto have; 981 - } else 982 - *b++ = c; 983 - if (++ftdi->received < ftdi->expected) { 984 - goto have; 985 - } else if (ftdi->ed_found) { 986 - int ed_number = (ftdi->response[0] >> 5) & 0x03; 987 - u16 ed_length = (ftdi->response[2] << 8) | 988 - ftdi->response[1]; 989 - struct u132_target *target = &ftdi->target[ed_number]; 990 - int payload = (ed_length >> 0) & 0x07FF; 991 - char diag[30 *3 + 4]; 992 - char *d = diag; 993 - int m = payload; 994 - u8 *c = 4 + ftdi->response; 995 - int s = (sizeof(diag) - 1) / 3; 996 - diag[0] = 0; 997 - while (s-- > 0 && m-- > 0) { 998 - if (s > 0 || m == 0) { 999 - d += sprintf(d, " %02X", *c++); 1000 - } else 1001 - d += sprintf(d, " .."); 1002 - } 1003 - ftdi_elan_do_callback(ftdi, target, 4 + ftdi->response, 1004 - payload); 1005 - ftdi->received = 0; 1006 - ftdi->expected = 4; 1007 - ftdi->ed_found = 0; 1008 - b = ftdi->response; 1009 - goto have; 1010 - } else if (ftdi->expected == 8) { 1011 - u8 buscmd; 1012 - int respond_head = ftdi->respond_head++; 1013 - struct u132_respond *respond = &ftdi->respond[ 1014 - RESPOND_MASK & respond_head]; 1015 - u32 data = ftdi->response[7]; 1016 - data <<= 8; 1017 - data |= ftdi->response[6]; 1018 - data <<= 8; 1019 - data |= ftdi->response[5]; 1020 - data <<= 8; 1021 - data |= ftdi->response[4]; 1022 - *respond->value = data; 1023 - *respond->result = 0; 1024 - complete(&respond->wait_completion); 1025 - ftdi->received = 0; 1026 - ftdi->expected = 4; 1027 - ftdi->ed_found = 0; 1028 - b = ftdi->response; 1029 - buscmd = (ftdi->response[0] >> 0) & 0x0F; 1030 - if (buscmd == 0x00) { 1031 - } else if (buscmd == 0x02) { 1032 - } else if (buscmd == 0x06) { 1033 - } else if (buscmd == 0x0A) { 1034 - } else 1035 - dev_err(&ftdi->udev->dev, "Uxxx unknown(%0X) value = %08X\n", 1036 - buscmd, data); 1037 - goto have; 1038 - } else { 1039 - if ((ftdi->response[0] & 0x80) == 0x00) { 1040 - ftdi->expected = 8; 1041 - goto have; 1042 - } else { 1043 - int ed_number = (ftdi->response[0] >> 5) & 0x03; 1044 - int ed_type = (ftdi->response[0] >> 0) & 0x03; 1045 - u16 ed_length = (ftdi->response[2] << 8) | 1046 - ftdi->response[1]; 1047 - struct u132_target *target = &ftdi->target[ 1048 - ed_number]; 1049 - target->halted = (ftdi->response[0] >> 3) & 1050 - 0x01; 1051 - target->skipped = (ftdi->response[0] >> 2) & 1052 - 0x01; 1053 - target->toggle_bits = (ftdi->response[3] >> 6) 1054 - & 0x03; 1055 - target->error_count = (ftdi->response[3] >> 4) 1056 - & 0x03; 1057 - target->condition_code = (ftdi->response[ 1058 - 3] >> 0) & 0x0F; 1059 - if ((ftdi->response[0] & 0x10) == 0x00) { 1060 - b = have_ed_set_response(ftdi, target, 1061 - ed_length, ed_number, ed_type, 1062 - b); 1063 - goto have; 1064 - } else { 1065 - b = have_ed_get_response(ftdi, target, 1066 - ed_length, ed_number, ed_type, 1067 - b); 1068 - goto have; 1069 - } 1070 - } 1071 - } 1072 - } else 1073 - goto more; 1074 - } 1075 - 1076 - 1077 - /* 1078 - * create a urb, and a buffer for it, and copy the data to the urb 1079 - * 1080 - */ 1081 - static ssize_t ftdi_elan_write(struct file *file, 1082 - const char __user *user_buffer, size_t count, 1083 - loff_t *ppos) 1084 - { 1085 - int retval = 0; 1086 - struct urb *urb; 1087 - char *buf; 1088 - struct usb_ftdi *ftdi = file->private_data; 1089 - 1090 - if (ftdi->disconnected > 0) { 1091 - return -ENODEV; 1092 - } 1093 - if (count == 0) { 1094 - goto exit; 1095 - } 1096 - urb = usb_alloc_urb(0, GFP_KERNEL); 1097 - if (!urb) { 1098 - retval = -ENOMEM; 1099 - goto error_1; 1100 - } 1101 - buf = usb_alloc_coherent(ftdi->udev, count, GFP_KERNEL, 1102 - &urb->transfer_dma); 1103 - if (!buf) { 1104 - retval = -ENOMEM; 1105 - goto error_2; 1106 - } 1107 - if (copy_from_user(buf, user_buffer, count)) { 1108 - retval = -EFAULT; 1109 - goto error_3; 1110 - } 1111 - usb_fill_bulk_urb(urb, ftdi->udev, usb_sndbulkpipe(ftdi->udev, 1112 - ftdi->bulk_out_endpointAddr), buf, count, 1113 - ftdi_elan_write_bulk_callback, ftdi); 1114 - urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; 1115 - retval = usb_submit_urb(urb, GFP_KERNEL); 1116 - if (retval) { 1117 - dev_err(&ftdi->udev->dev, 1118 - "failed submitting write urb, error %d\n", retval); 1119 - goto error_3; 1120 - } 1121 - usb_free_urb(urb); 1122 - 1123 - exit: 1124 - return count; 1125 - error_3: 1126 - usb_free_coherent(ftdi->udev, count, buf, urb->transfer_dma); 1127 - error_2: 1128 - usb_free_urb(urb); 1129 - error_1: 1130 - return retval; 1131 - } 1132 - 1133 - static const struct file_operations ftdi_elan_fops = { 1134 - .owner = THIS_MODULE, 1135 - .llseek = no_llseek, 1136 - .read = ftdi_elan_read, 1137 - .write = ftdi_elan_write, 1138 - .open = ftdi_elan_open, 1139 - .release = ftdi_elan_release, 1140 - }; 1141 - 1142 - /* 1143 - * usb class driver info in order to get a minor number from the usb core, 1144 - * and to have the device registered with the driver core 1145 - */ 1146 - static struct usb_class_driver ftdi_elan_jtag_class = { 1147 - .name = "ftdi-%d-jtag", 1148 - .fops = &ftdi_elan_fops, 1149 - .minor_base = USB_FTDI_ELAN_MINOR_BASE, 1150 - }; 1151 - 1152 - /* 1153 - * the following definitions are for the 1154 - * ELAN FPGA state machgine processor that 1155 - * lies on the other side of the FTDI chip 1156 - */ 1157 - #define cPCIu132rd 0x0 1158 - #define cPCIu132wr 0x1 1159 - #define cPCIiord 0x2 1160 - #define cPCIiowr 0x3 1161 - #define cPCImemrd 0x6 1162 - #define cPCImemwr 0x7 1163 - #define cPCIcfgrd 0xA 1164 - #define cPCIcfgwr 0xB 1165 - #define cPCInull 0xF 1166 - #define cU132cmd_status 0x0 1167 - #define cU132flash 0x1 1168 - #define cPIDsetup 0x0 1169 - #define cPIDout 0x1 1170 - #define cPIDin 0x2 1171 - #define cPIDinonce 0x3 1172 - #define cCCnoerror 0x0 1173 - #define cCCcrc 0x1 1174 - #define cCCbitstuff 0x2 1175 - #define cCCtoggle 0x3 1176 - #define cCCstall 0x4 1177 - #define cCCnoresp 0x5 1178 - #define cCCbadpid1 0x6 1179 - #define cCCbadpid2 0x7 1180 - #define cCCdataoverrun 0x8 1181 - #define cCCdataunderrun 0x9 1182 - #define cCCbuffoverrun 0xC 1183 - #define cCCbuffunderrun 0xD 1184 - #define cCCnotaccessed 0xF 1185 - static int ftdi_elan_write_reg(struct usb_ftdi *ftdi, u32 data) 1186 - { 1187 - wait:if (ftdi->disconnected > 0) { 1188 - return -ENODEV; 1189 - } else { 1190 - int command_size; 1191 - mutex_lock(&ftdi->u132_lock); 1192 - command_size = ftdi->command_next - ftdi->command_head; 1193 - if (command_size < COMMAND_SIZE) { 1194 - struct u132_command *command = &ftdi->command[ 1195 - COMMAND_MASK & ftdi->command_next]; 1196 - command->header = 0x00 | cPCIu132wr; 1197 - command->length = 0x04; 1198 - command->address = 0x00; 1199 - command->width = 0x00; 1200 - command->follows = 4; 1201 - command->value = data; 1202 - command->buffer = &command->value; 1203 - ftdi->command_next += 1; 1204 - ftdi_elan_kick_command_queue(ftdi); 1205 - mutex_unlock(&ftdi->u132_lock); 1206 - return 0; 1207 - } else { 1208 - mutex_unlock(&ftdi->u132_lock); 1209 - msleep(100); 1210 - goto wait; 1211 - } 1212 - } 1213 - } 1214 - 1215 - static int ftdi_elan_write_config(struct usb_ftdi *ftdi, int config_offset, 1216 - u8 width, u32 data) 1217 - { 1218 - u8 addressofs = config_offset / 4; 1219 - wait:if (ftdi->disconnected > 0) { 1220 - return -ENODEV; 1221 - } else { 1222 - int command_size; 1223 - mutex_lock(&ftdi->u132_lock); 1224 - command_size = ftdi->command_next - ftdi->command_head; 1225 - if (command_size < COMMAND_SIZE) { 1226 - struct u132_command *command = &ftdi->command[ 1227 - COMMAND_MASK & ftdi->command_next]; 1228 - command->header = 0x00 | (cPCIcfgwr & 0x0F); 1229 - command->length = 0x04; 1230 - command->address = addressofs; 1231 - command->width = 0x00 | (width & 0x0F); 1232 - command->follows = 4; 1233 - command->value = data; 1234 - command->buffer = &command->value; 1235 - ftdi->command_next += 1; 1236 - ftdi_elan_kick_command_queue(ftdi); 1237 - mutex_unlock(&ftdi->u132_lock); 1238 - return 0; 1239 - } else { 1240 - mutex_unlock(&ftdi->u132_lock); 1241 - msleep(100); 1242 - goto wait; 1243 - } 1244 - } 1245 - } 1246 - 1247 - static int ftdi_elan_write_pcimem(struct usb_ftdi *ftdi, int mem_offset, 1248 - u8 width, u32 data) 1249 - { 1250 - u8 addressofs = mem_offset / 4; 1251 - wait:if (ftdi->disconnected > 0) { 1252 - return -ENODEV; 1253 - } else { 1254 - int command_size; 1255 - mutex_lock(&ftdi->u132_lock); 1256 - command_size = ftdi->command_next - ftdi->command_head; 1257 - if (command_size < COMMAND_SIZE) { 1258 - struct u132_command *command = &ftdi->command[ 1259 - COMMAND_MASK & ftdi->command_next]; 1260 - command->header = 0x00 | (cPCImemwr & 0x0F); 1261 - command->length = 0x04; 1262 - command->address = addressofs; 1263 - command->width = 0x00 | (width & 0x0F); 1264 - command->follows = 4; 1265 - command->value = data; 1266 - command->buffer = &command->value; 1267 - ftdi->command_next += 1; 1268 - ftdi_elan_kick_command_queue(ftdi); 1269 - mutex_unlock(&ftdi->u132_lock); 1270 - return 0; 1271 - } else { 1272 - mutex_unlock(&ftdi->u132_lock); 1273 - msleep(100); 1274 - goto wait; 1275 - } 1276 - } 1277 - } 1278 - 1279 - int usb_ftdi_elan_write_pcimem(struct platform_device *pdev, int mem_offset, 1280 - u8 width, u32 data) 1281 - { 1282 - struct usb_ftdi *ftdi = platform_device_to_usb_ftdi(pdev); 1283 - return ftdi_elan_write_pcimem(ftdi, mem_offset, width, data); 1284 - } 1285 - 1286 - 1287 - EXPORT_SYMBOL_GPL(usb_ftdi_elan_write_pcimem); 1288 - static int ftdi_elan_read_reg(struct usb_ftdi *ftdi, u32 *data) 1289 - { 1290 - wait:if (ftdi->disconnected > 0) { 1291 - return -ENODEV; 1292 - } else { 1293 - int command_size; 1294 - int respond_size; 1295 - mutex_lock(&ftdi->u132_lock); 1296 - command_size = ftdi->command_next - ftdi->command_head; 1297 - respond_size = ftdi->respond_next - ftdi->respond_head; 1298 - if (command_size < COMMAND_SIZE && respond_size < RESPOND_SIZE) 1299 - { 1300 - struct u132_command *command = &ftdi->command[ 1301 - COMMAND_MASK & ftdi->command_next]; 1302 - struct u132_respond *respond = &ftdi->respond[ 1303 - RESPOND_MASK & ftdi->respond_next]; 1304 - int result = -ENODEV; 1305 - respond->result = &result; 1306 - respond->header = command->header = 0x00 | cPCIu132rd; 1307 - command->length = 0x04; 1308 - respond->address = command->address = cU132cmd_status; 1309 - command->width = 0x00; 1310 - command->follows = 0; 1311 - command->value = 0; 1312 - command->buffer = NULL; 1313 - respond->value = data; 1314 - init_completion(&respond->wait_completion); 1315 - ftdi->command_next += 1; 1316 - ftdi->respond_next += 1; 1317 - ftdi_elan_kick_command_queue(ftdi); 1318 - mutex_unlock(&ftdi->u132_lock); 1319 - wait_for_completion(&respond->wait_completion); 1320 - return result; 1321 - } else { 1322 - mutex_unlock(&ftdi->u132_lock); 1323 - msleep(100); 1324 - goto wait; 1325 - } 1326 - } 1327 - } 1328 - 1329 - static int ftdi_elan_read_config(struct usb_ftdi *ftdi, int config_offset, 1330 - u8 width, u32 *data) 1331 - { 1332 - u8 addressofs = config_offset / 4; 1333 - wait:if (ftdi->disconnected > 0) { 1334 - return -ENODEV; 1335 - } else { 1336 - int command_size; 1337 - int respond_size; 1338 - mutex_lock(&ftdi->u132_lock); 1339 - command_size = ftdi->command_next - ftdi->command_head; 1340 - respond_size = ftdi->respond_next - ftdi->respond_head; 1341 - if (command_size < COMMAND_SIZE && respond_size < RESPOND_SIZE) 1342 - { 1343 - struct u132_command *command = &ftdi->command[ 1344 - COMMAND_MASK & ftdi->command_next]; 1345 - struct u132_respond *respond = &ftdi->respond[ 1346 - RESPOND_MASK & ftdi->respond_next]; 1347 - int result = -ENODEV; 1348 - respond->result = &result; 1349 - respond->header = command->header = 0x00 | (cPCIcfgrd & 1350 - 0x0F); 1351 - command->length = 0x04; 1352 - respond->address = command->address = addressofs; 1353 - command->width = 0x00 | (width & 0x0F); 1354 - command->follows = 0; 1355 - command->value = 0; 1356 - command->buffer = NULL; 1357 - respond->value = data; 1358 - init_completion(&respond->wait_completion); 1359 - ftdi->command_next += 1; 1360 - ftdi->respond_next += 1; 1361 - ftdi_elan_kick_command_queue(ftdi); 1362 - mutex_unlock(&ftdi->u132_lock); 1363 - wait_for_completion(&respond->wait_completion); 1364 - return result; 1365 - } else { 1366 - mutex_unlock(&ftdi->u132_lock); 1367 - msleep(100); 1368 - goto wait; 1369 - } 1370 - } 1371 - } 1372 - 1373 - static int ftdi_elan_read_pcimem(struct usb_ftdi *ftdi, int mem_offset, 1374 - u8 width, u32 *data) 1375 - { 1376 - u8 addressofs = mem_offset / 4; 1377 - wait:if (ftdi->disconnected > 0) { 1378 - return -ENODEV; 1379 - } else { 1380 - int command_size; 1381 - int respond_size; 1382 - mutex_lock(&ftdi->u132_lock); 1383 - command_size = ftdi->command_next - ftdi->command_head; 1384 - respond_size = ftdi->respond_next - ftdi->respond_head; 1385 - if (command_size < COMMAND_SIZE && respond_size < RESPOND_SIZE) 1386 - { 1387 - struct u132_command *command = &ftdi->command[ 1388 - COMMAND_MASK & ftdi->command_next]; 1389 - struct u132_respond *respond = &ftdi->respond[ 1390 - RESPOND_MASK & ftdi->respond_next]; 1391 - int result = -ENODEV; 1392 - respond->result = &result; 1393 - respond->header = command->header = 0x00 | (cPCImemrd & 1394 - 0x0F); 1395 - command->length = 0x04; 1396 - respond->address = command->address = addressofs; 1397 - command->width = 0x00 | (width & 0x0F); 1398 - command->follows = 0; 1399 - command->value = 0; 1400 - command->buffer = NULL; 1401 - respond->value = data; 1402 - init_completion(&respond->wait_completion); 1403 - ftdi->command_next += 1; 1404 - ftdi->respond_next += 1; 1405 - ftdi_elan_kick_command_queue(ftdi); 1406 - mutex_unlock(&ftdi->u132_lock); 1407 - wait_for_completion(&respond->wait_completion); 1408 - return result; 1409 - } else { 1410 - mutex_unlock(&ftdi->u132_lock); 1411 - msleep(100); 1412 - goto wait; 1413 - } 1414 - } 1415 - } 1416 - 1417 - int usb_ftdi_elan_read_pcimem(struct platform_device *pdev, int mem_offset, 1418 - u8 width, u32 *data) 1419 - { 1420 - struct usb_ftdi *ftdi = platform_device_to_usb_ftdi(pdev); 1421 - if (ftdi->initialized == 0) { 1422 - return -ENODEV; 1423 - } else 1424 - return ftdi_elan_read_pcimem(ftdi, mem_offset, width, data); 1425 - } 1426 - 1427 - 1428 - EXPORT_SYMBOL_GPL(usb_ftdi_elan_read_pcimem); 1429 - static int ftdi_elan_edset_setup(struct usb_ftdi *ftdi, u8 ed_number, 1430 - void *endp, struct urb *urb, u8 address, u8 ep_number, u8 toggle_bits, 1431 - void (*callback) (void *endp, struct urb *urb, u8 *buf, int len, 1432 - int toggle_bits, int error_count, int condition_code, int repeat_number, 1433 - int halted, int skipped, int actual, int non_null)) 1434 - { 1435 - u8 ed = ed_number - 1; 1436 - wait:if (ftdi->disconnected > 0) { 1437 - return -ENODEV; 1438 - } else if (ftdi->initialized == 0) { 1439 - return -ENODEV; 1440 - } else { 1441 - int command_size; 1442 - mutex_lock(&ftdi->u132_lock); 1443 - command_size = ftdi->command_next - ftdi->command_head; 1444 - if (command_size < COMMAND_SIZE) { 1445 - struct u132_target *target = &ftdi->target[ed]; 1446 - struct u132_command *command = &ftdi->command[ 1447 - COMMAND_MASK & ftdi->command_next]; 1448 - command->header = 0x80 | (ed << 5); 1449 - command->length = 0x8007; 1450 - command->address = (toggle_bits << 6) | (ep_number << 2) 1451 - | (address << 0); 1452 - command->width = usb_maxpacket(urb->dev, urb->pipe); 1453 - command->follows = 8; 1454 - command->value = 0; 1455 - command->buffer = urb->setup_packet; 1456 - target->callback = callback; 1457 - target->endp = endp; 1458 - target->urb = urb; 1459 - target->active = 1; 1460 - ftdi->command_next += 1; 1461 - ftdi_elan_kick_command_queue(ftdi); 1462 - mutex_unlock(&ftdi->u132_lock); 1463 - return 0; 1464 - } else { 1465 - mutex_unlock(&ftdi->u132_lock); 1466 - msleep(100); 1467 - goto wait; 1468 - } 1469 - } 1470 - } 1471 - 1472 - int usb_ftdi_elan_edset_setup(struct platform_device *pdev, u8 ed_number, 1473 - void *endp, struct urb *urb, u8 address, u8 ep_number, u8 toggle_bits, 1474 - void (*callback) (void *endp, struct urb *urb, u8 *buf, int len, 1475 - int toggle_bits, int error_count, int condition_code, int repeat_number, 1476 - int halted, int skipped, int actual, int non_null)) 1477 - { 1478 - struct usb_ftdi *ftdi = platform_device_to_usb_ftdi(pdev); 1479 - return ftdi_elan_edset_setup(ftdi, ed_number, endp, urb, address, 1480 - ep_number, toggle_bits, callback); 1481 - } 1482 - 1483 - 1484 - EXPORT_SYMBOL_GPL(usb_ftdi_elan_edset_setup); 1485 - static int ftdi_elan_edset_input(struct usb_ftdi *ftdi, u8 ed_number, 1486 - void *endp, struct urb *urb, u8 address, u8 ep_number, u8 toggle_bits, 1487 - void (*callback) (void *endp, struct urb *urb, u8 *buf, int len, 1488 - int toggle_bits, int error_count, int condition_code, int repeat_number, 1489 - int halted, int skipped, int actual, int non_null)) 1490 - { 1491 - u8 ed = ed_number - 1; 1492 - wait:if (ftdi->disconnected > 0) { 1493 - return -ENODEV; 1494 - } else if (ftdi->initialized == 0) { 1495 - return -ENODEV; 1496 - } else { 1497 - int command_size; 1498 - mutex_lock(&ftdi->u132_lock); 1499 - command_size = ftdi->command_next - ftdi->command_head; 1500 - if (command_size < COMMAND_SIZE) { 1501 - struct u132_target *target = &ftdi->target[ed]; 1502 - struct u132_command *command = &ftdi->command[ 1503 - COMMAND_MASK & ftdi->command_next]; 1504 - u32 remaining_length = urb->transfer_buffer_length - 1505 - urb->actual_length; 1506 - command->header = 0x82 | (ed << 5); 1507 - if (remaining_length == 0) { 1508 - command->length = 0x0000; 1509 - } else if (remaining_length > 1024) { 1510 - command->length = 0x8000 | 1023; 1511 - } else 1512 - command->length = 0x8000 | (remaining_length - 1513 - 1); 1514 - command->address = (toggle_bits << 6) | (ep_number << 2) 1515 - | (address << 0); 1516 - command->width = usb_maxpacket(urb->dev, urb->pipe); 1517 - command->follows = 0; 1518 - command->value = 0; 1519 - command->buffer = NULL; 1520 - target->callback = callback; 1521 - target->endp = endp; 1522 - target->urb = urb; 1523 - target->active = 1; 1524 - ftdi->command_next += 1; 1525 - ftdi_elan_kick_command_queue(ftdi); 1526 - mutex_unlock(&ftdi->u132_lock); 1527 - return 0; 1528 - } else { 1529 - mutex_unlock(&ftdi->u132_lock); 1530 - msleep(100); 1531 - goto wait; 1532 - } 1533 - } 1534 - } 1535 - 1536 - int usb_ftdi_elan_edset_input(struct platform_device *pdev, u8 ed_number, 1537 - void *endp, struct urb *urb, u8 address, u8 ep_number, u8 toggle_bits, 1538 - void (*callback) (void *endp, struct urb *urb, u8 *buf, int len, 1539 - int toggle_bits, int error_count, int condition_code, int repeat_number, 1540 - int halted, int skipped, int actual, int non_null)) 1541 - { 1542 - struct usb_ftdi *ftdi = platform_device_to_usb_ftdi(pdev); 1543 - return ftdi_elan_edset_input(ftdi, ed_number, endp, urb, address, 1544 - ep_number, toggle_bits, callback); 1545 - } 1546 - 1547 - 1548 - EXPORT_SYMBOL_GPL(usb_ftdi_elan_edset_input); 1549 - static int ftdi_elan_edset_empty(struct usb_ftdi *ftdi, u8 ed_number, 1550 - void *endp, struct urb *urb, u8 address, u8 ep_number, u8 toggle_bits, 1551 - void (*callback) (void *endp, struct urb *urb, u8 *buf, int len, 1552 - int toggle_bits, int error_count, int condition_code, int repeat_number, 1553 - int halted, int skipped, int actual, int non_null)) 1554 - { 1555 - u8 ed = ed_number - 1; 1556 - wait:if (ftdi->disconnected > 0) { 1557 - return -ENODEV; 1558 - } else if (ftdi->initialized == 0) { 1559 - return -ENODEV; 1560 - } else { 1561 - int command_size; 1562 - mutex_lock(&ftdi->u132_lock); 1563 - command_size = ftdi->command_next - ftdi->command_head; 1564 - if (command_size < COMMAND_SIZE) { 1565 - struct u132_target *target = &ftdi->target[ed]; 1566 - struct u132_command *command = &ftdi->command[ 1567 - COMMAND_MASK & ftdi->command_next]; 1568 - command->header = 0x81 | (ed << 5); 1569 - command->length = 0x0000; 1570 - command->address = (toggle_bits << 6) | (ep_number << 2) 1571 - | (address << 0); 1572 - command->width = usb_maxpacket(urb->dev, urb->pipe); 1573 - command->follows = 0; 1574 - command->value = 0; 1575 - command->buffer = NULL; 1576 - target->callback = callback; 1577 - target->endp = endp; 1578 - target->urb = urb; 1579 - target->active = 1; 1580 - ftdi->command_next += 1; 1581 - ftdi_elan_kick_command_queue(ftdi); 1582 - mutex_unlock(&ftdi->u132_lock); 1583 - return 0; 1584 - } else { 1585 - mutex_unlock(&ftdi->u132_lock); 1586 - msleep(100); 1587 - goto wait; 1588 - } 1589 - } 1590 - } 1591 - 1592 - int usb_ftdi_elan_edset_empty(struct platform_device *pdev, u8 ed_number, 1593 - void *endp, struct urb *urb, u8 address, u8 ep_number, u8 toggle_bits, 1594 - void (*callback) (void *endp, struct urb *urb, u8 *buf, int len, 1595 - int toggle_bits, int error_count, int condition_code, int repeat_number, 1596 - int halted, int skipped, int actual, int non_null)) 1597 - { 1598 - struct usb_ftdi *ftdi = platform_device_to_usb_ftdi(pdev); 1599 - return ftdi_elan_edset_empty(ftdi, ed_number, endp, urb, address, 1600 - ep_number, toggle_bits, callback); 1601 - } 1602 - 1603 - 1604 - EXPORT_SYMBOL_GPL(usb_ftdi_elan_edset_empty); 1605 - static int ftdi_elan_edset_output(struct usb_ftdi *ftdi, u8 ed_number, 1606 - void *endp, struct urb *urb, u8 address, u8 ep_number, u8 toggle_bits, 1607 - void (*callback) (void *endp, struct urb *urb, u8 *buf, int len, 1608 - int toggle_bits, int error_count, int condition_code, int repeat_number, 1609 - int halted, int skipped, int actual, int non_null)) 1610 - { 1611 - u8 ed = ed_number - 1; 1612 - wait:if (ftdi->disconnected > 0) { 1613 - return -ENODEV; 1614 - } else if (ftdi->initialized == 0) { 1615 - return -ENODEV; 1616 - } else { 1617 - int command_size; 1618 - mutex_lock(&ftdi->u132_lock); 1619 - command_size = ftdi->command_next - ftdi->command_head; 1620 - if (command_size < COMMAND_SIZE) { 1621 - u8 *b; 1622 - u16 urb_size; 1623 - int i = 0; 1624 - char data[30 *3 + 4]; 1625 - char *d = data; 1626 - int m = (sizeof(data) - 1) / 3 - 1; 1627 - struct u132_target *target = &ftdi->target[ed]; 1628 - struct u132_command *command = &ftdi->command[ 1629 - COMMAND_MASK & ftdi->command_next]; 1630 - command->header = 0x81 | (ed << 5); 1631 - command->address = (toggle_bits << 6) | (ep_number << 2) 1632 - | (address << 0); 1633 - command->width = usb_maxpacket(urb->dev, urb->pipe); 1634 - command->follows = min_t(u32, 1024, 1635 - urb->transfer_buffer_length - 1636 - urb->actual_length); 1637 - command->value = 0; 1638 - command->buffer = urb->transfer_buffer + 1639 - urb->actual_length; 1640 - command->length = 0x8000 | (command->follows - 1); 1641 - b = command->buffer; 1642 - urb_size = command->follows; 1643 - data[0] = 0; 1644 - while (urb_size-- > 0) { 1645 - if (i > m) { 1646 - } else if (i++ < m) { 1647 - int w = sprintf(d, " %02X", *b++); 1648 - d += w; 1649 - } else 1650 - d += sprintf(d, " .."); 1651 - } 1652 - target->callback = callback; 1653 - target->endp = endp; 1654 - target->urb = urb; 1655 - target->active = 1; 1656 - ftdi->command_next += 1; 1657 - ftdi_elan_kick_command_queue(ftdi); 1658 - mutex_unlock(&ftdi->u132_lock); 1659 - return 0; 1660 - } else { 1661 - mutex_unlock(&ftdi->u132_lock); 1662 - msleep(100); 1663 - goto wait; 1664 - } 1665 - } 1666 - } 1667 - 1668 - int usb_ftdi_elan_edset_output(struct platform_device *pdev, u8 ed_number, 1669 - void *endp, struct urb *urb, u8 address, u8 ep_number, u8 toggle_bits, 1670 - void (*callback) (void *endp, struct urb *urb, u8 *buf, int len, 1671 - int toggle_bits, int error_count, int condition_code, int repeat_number, 1672 - int halted, int skipped, int actual, int non_null)) 1673 - { 1674 - struct usb_ftdi *ftdi = platform_device_to_usb_ftdi(pdev); 1675 - return ftdi_elan_edset_output(ftdi, ed_number, endp, urb, address, 1676 - ep_number, toggle_bits, callback); 1677 - } 1678 - 1679 - 1680 - EXPORT_SYMBOL_GPL(usb_ftdi_elan_edset_output); 1681 - static int ftdi_elan_edset_single(struct usb_ftdi *ftdi, u8 ed_number, 1682 - void *endp, struct urb *urb, u8 address, u8 ep_number, u8 toggle_bits, 1683 - void (*callback) (void *endp, struct urb *urb, u8 *buf, int len, 1684 - int toggle_bits, int error_count, int condition_code, int repeat_number, 1685 - int halted, int skipped, int actual, int non_null)) 1686 - { 1687 - u8 ed = ed_number - 1; 1688 - wait:if (ftdi->disconnected > 0) { 1689 - return -ENODEV; 1690 - } else if (ftdi->initialized == 0) { 1691 - return -ENODEV; 1692 - } else { 1693 - int command_size; 1694 - mutex_lock(&ftdi->u132_lock); 1695 - command_size = ftdi->command_next - ftdi->command_head; 1696 - if (command_size < COMMAND_SIZE) { 1697 - u32 remaining_length = urb->transfer_buffer_length - 1698 - urb->actual_length; 1699 - struct u132_target *target = &ftdi->target[ed]; 1700 - struct u132_command *command = &ftdi->command[ 1701 - COMMAND_MASK & ftdi->command_next]; 1702 - command->header = 0x83 | (ed << 5); 1703 - if (remaining_length == 0) { 1704 - command->length = 0x0000; 1705 - } else if (remaining_length > 1024) { 1706 - command->length = 0x8000 | 1023; 1707 - } else 1708 - command->length = 0x8000 | (remaining_length - 1709 - 1); 1710 - command->address = (toggle_bits << 6) | (ep_number << 2) 1711 - | (address << 0); 1712 - command->width = usb_maxpacket(urb->dev, urb->pipe); 1713 - command->follows = 0; 1714 - command->value = 0; 1715 - command->buffer = NULL; 1716 - target->callback = callback; 1717 - target->endp = endp; 1718 - target->urb = urb; 1719 - target->active = 1; 1720 - ftdi->command_next += 1; 1721 - ftdi_elan_kick_command_queue(ftdi); 1722 - mutex_unlock(&ftdi->u132_lock); 1723 - return 0; 1724 - } else { 1725 - mutex_unlock(&ftdi->u132_lock); 1726 - msleep(100); 1727 - goto wait; 1728 - } 1729 - } 1730 - } 1731 - 1732 - int usb_ftdi_elan_edset_single(struct platform_device *pdev, u8 ed_number, 1733 - void *endp, struct urb *urb, u8 address, u8 ep_number, u8 toggle_bits, 1734 - void (*callback) (void *endp, struct urb *urb, u8 *buf, int len, 1735 - int toggle_bits, int error_count, int condition_code, int repeat_number, 1736 - int halted, int skipped, int actual, int non_null)) 1737 - { 1738 - struct usb_ftdi *ftdi = platform_device_to_usb_ftdi(pdev); 1739 - return ftdi_elan_edset_single(ftdi, ed_number, endp, urb, address, 1740 - ep_number, toggle_bits, callback); 1741 - } 1742 - 1743 - 1744 - EXPORT_SYMBOL_GPL(usb_ftdi_elan_edset_single); 1745 - static int ftdi_elan_edset_flush(struct usb_ftdi *ftdi, u8 ed_number, 1746 - void *endp) 1747 - { 1748 - u8 ed = ed_number - 1; 1749 - if (ftdi->disconnected > 0) { 1750 - return -ENODEV; 1751 - } else if (ftdi->initialized == 0) { 1752 - return -ENODEV; 1753 - } else { 1754 - struct u132_target *target = &ftdi->target[ed]; 1755 - mutex_lock(&ftdi->u132_lock); 1756 - if (target->abandoning > 0) { 1757 - mutex_unlock(&ftdi->u132_lock); 1758 - return 0; 1759 - } else { 1760 - target->abandoning = 1; 1761 - wait_1:if (target->active == 1) { 1762 - int command_size = ftdi->command_next - 1763 - ftdi->command_head; 1764 - if (command_size < COMMAND_SIZE) { 1765 - struct u132_command *command = 1766 - &ftdi->command[COMMAND_MASK & 1767 - ftdi->command_next]; 1768 - command->header = 0x80 | (ed << 5) | 1769 - 0x4; 1770 - command->length = 0x00; 1771 - command->address = 0x00; 1772 - command->width = 0x00; 1773 - command->follows = 0; 1774 - command->value = 0; 1775 - command->buffer = &command->value; 1776 - ftdi->command_next += 1; 1777 - ftdi_elan_kick_command_queue(ftdi); 1778 - } else { 1779 - mutex_unlock(&ftdi->u132_lock); 1780 - msleep(100); 1781 - mutex_lock(&ftdi->u132_lock); 1782 - goto wait_1; 1783 - } 1784 - } 1785 - mutex_unlock(&ftdi->u132_lock); 1786 - return 0; 1787 - } 1788 - } 1789 - } 1790 - 1791 - int usb_ftdi_elan_edset_flush(struct platform_device *pdev, u8 ed_number, 1792 - void *endp) 1793 - { 1794 - struct usb_ftdi *ftdi = platform_device_to_usb_ftdi(pdev); 1795 - return ftdi_elan_edset_flush(ftdi, ed_number, endp); 1796 - } 1797 - 1798 - 1799 - EXPORT_SYMBOL_GPL(usb_ftdi_elan_edset_flush); 1800 - static int ftdi_elan_flush_input_fifo(struct usb_ftdi *ftdi) 1801 - { 1802 - int retry_on_empty = 10; 1803 - int retry_on_timeout = 5; 1804 - int retry_on_status = 20; 1805 - more:{ 1806 - int packet_bytes = 0; 1807 - int retval = usb_bulk_msg(ftdi->udev, 1808 - usb_rcvbulkpipe(ftdi->udev, ftdi->bulk_in_endpointAddr), 1809 - ftdi->bulk_in_buffer, ftdi->bulk_in_size, 1810 - &packet_bytes, 100); 1811 - if (packet_bytes > 2) { 1812 - char diag[30 *3 + 4]; 1813 - char *d = diag; 1814 - int m = (sizeof(diag) - 1) / 3 - 1; 1815 - char *b = ftdi->bulk_in_buffer; 1816 - int bytes_read = 0; 1817 - diag[0] = 0; 1818 - while (packet_bytes-- > 0) { 1819 - char c = *b++; 1820 - if (bytes_read < m) { 1821 - d += sprintf(d, " %02X", 1822 - 0x000000FF & c); 1823 - } else if (bytes_read > m) { 1824 - } else 1825 - d += sprintf(d, " .."); 1826 - bytes_read += 1; 1827 - continue; 1828 - } 1829 - goto more; 1830 - } else if (packet_bytes > 1) { 1831 - char s1 = ftdi->bulk_in_buffer[0]; 1832 - char s2 = ftdi->bulk_in_buffer[1]; 1833 - if (s1 == 0x31 && s2 == 0x60) { 1834 - return 0; 1835 - } else if (retry_on_status-- > 0) { 1836 - goto more; 1837 - } else { 1838 - dev_err(&ftdi->udev->dev, "STATUS ERROR retry limit reached\n"); 1839 - return -EFAULT; 1840 - } 1841 - } else if (packet_bytes > 0) { 1842 - char b1 = ftdi->bulk_in_buffer[0]; 1843 - dev_err(&ftdi->udev->dev, "only one byte flushed from FTDI = %02X\n", 1844 - b1); 1845 - if (retry_on_status-- > 0) { 1846 - goto more; 1847 - } else { 1848 - dev_err(&ftdi->udev->dev, "STATUS ERROR retry limit reached\n"); 1849 - return -EFAULT; 1850 - } 1851 - } else if (retval == -ETIMEDOUT) { 1852 - if (retry_on_timeout-- > 0) { 1853 - goto more; 1854 - } else { 1855 - dev_err(&ftdi->udev->dev, "TIMED OUT retry limit reached\n"); 1856 - return -ENOMEM; 1857 - } 1858 - } else if (retval == 0) { 1859 - if (retry_on_empty-- > 0) { 1860 - goto more; 1861 - } else { 1862 - dev_err(&ftdi->udev->dev, "empty packet retry limit reached\n"); 1863 - return -ENOMEM; 1864 - } 1865 - } else { 1866 - dev_err(&ftdi->udev->dev, "error = %d\n", retval); 1867 - return retval; 1868 - } 1869 - } 1870 - return -1; 1871 - } 1872 - 1873 - 1874 - /* 1875 - * send the long flush sequence 1876 - * 1877 - */ 1878 - static int ftdi_elan_synchronize_flush(struct usb_ftdi *ftdi) 1879 - { 1880 - int retval; 1881 - struct urb *urb; 1882 - char *buf; 1883 - int I = 257; 1884 - int i = 0; 1885 - urb = usb_alloc_urb(0, GFP_KERNEL); 1886 - if (!urb) 1887 - return -ENOMEM; 1888 - buf = usb_alloc_coherent(ftdi->udev, I, GFP_KERNEL, &urb->transfer_dma); 1889 - if (!buf) { 1890 - dev_err(&ftdi->udev->dev, "could not get a buffer for flush sequence\n"); 1891 - usb_free_urb(urb); 1892 - return -ENOMEM; 1893 - } 1894 - while (I-- > 0) 1895 - buf[i++] = 0x55; 1896 - usb_fill_bulk_urb(urb, ftdi->udev, usb_sndbulkpipe(ftdi->udev, 1897 - ftdi->bulk_out_endpointAddr), buf, i, 1898 - ftdi_elan_write_bulk_callback, ftdi); 1899 - urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; 1900 - retval = usb_submit_urb(urb, GFP_KERNEL); 1901 - if (retval) { 1902 - dev_err(&ftdi->udev->dev, "failed to submit urb containing the flush sequence\n"); 1903 - usb_free_coherent(ftdi->udev, i, buf, urb->transfer_dma); 1904 - usb_free_urb(urb); 1905 - return -ENOMEM; 1906 - } 1907 - usb_free_urb(urb); 1908 - return 0; 1909 - } 1910 - 1911 - 1912 - /* 1913 - * send the reset sequence 1914 - * 1915 - */ 1916 - static int ftdi_elan_synchronize_reset(struct usb_ftdi *ftdi) 1917 - { 1918 - int retval; 1919 - struct urb *urb; 1920 - char *buf; 1921 - int I = 4; 1922 - int i = 0; 1923 - urb = usb_alloc_urb(0, GFP_KERNEL); 1924 - if (!urb) 1925 - return -ENOMEM; 1926 - buf = usb_alloc_coherent(ftdi->udev, I, GFP_KERNEL, &urb->transfer_dma); 1927 - if (!buf) { 1928 - dev_err(&ftdi->udev->dev, "could not get a buffer for the reset sequence\n"); 1929 - usb_free_urb(urb); 1930 - return -ENOMEM; 1931 - } 1932 - buf[i++] = 0x55; 1933 - buf[i++] = 0xAA; 1934 - buf[i++] = 0x5A; 1935 - buf[i++] = 0xA5; 1936 - usb_fill_bulk_urb(urb, ftdi->udev, usb_sndbulkpipe(ftdi->udev, 1937 - ftdi->bulk_out_endpointAddr), buf, i, 1938 - ftdi_elan_write_bulk_callback, ftdi); 1939 - urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; 1940 - retval = usb_submit_urb(urb, GFP_KERNEL); 1941 - if (retval) { 1942 - dev_err(&ftdi->udev->dev, "failed to submit urb containing the reset sequence\n"); 1943 - usb_free_coherent(ftdi->udev, i, buf, urb->transfer_dma); 1944 - usb_free_urb(urb); 1945 - return -ENOMEM; 1946 - } 1947 - usb_free_urb(urb); 1948 - return 0; 1949 - } 1950 - 1951 - static int ftdi_elan_synchronize(struct usb_ftdi *ftdi) 1952 - { 1953 - int retval; 1954 - int long_stop = 10; 1955 - int retry_on_timeout = 5; 1956 - int retry_on_empty = 10; 1957 - retval = ftdi_elan_flush_input_fifo(ftdi); 1958 - if (retval) 1959 - return retval; 1960 - ftdi->bulk_in_left = 0; 1961 - ftdi->bulk_in_last = -1; 1962 - while (long_stop-- > 0) { 1963 - int read_stop; 1964 - int read_stuck; 1965 - retval = ftdi_elan_synchronize_flush(ftdi); 1966 - if (retval) 1967 - return retval; 1968 - retval = ftdi_elan_flush_input_fifo(ftdi); 1969 - if (retval) 1970 - return retval; 1971 - reset:retval = ftdi_elan_synchronize_reset(ftdi); 1972 - if (retval) 1973 - return retval; 1974 - read_stop = 100; 1975 - read_stuck = 10; 1976 - read:{ 1977 - int packet_bytes = 0; 1978 - retval = usb_bulk_msg(ftdi->udev, 1979 - usb_rcvbulkpipe(ftdi->udev, 1980 - ftdi->bulk_in_endpointAddr), 1981 - ftdi->bulk_in_buffer, ftdi->bulk_in_size, 1982 - &packet_bytes, 500); 1983 - if (packet_bytes > 2) { 1984 - char diag[30 *3 + 4]; 1985 - char *d = diag; 1986 - int m = (sizeof(diag) - 1) / 3 - 1; 1987 - char *b = ftdi->bulk_in_buffer; 1988 - int bytes_read = 0; 1989 - unsigned char c = 0; 1990 - diag[0] = 0; 1991 - while (packet_bytes-- > 0) { 1992 - c = *b++; 1993 - if (bytes_read < m) { 1994 - d += sprintf(d, " %02X", c); 1995 - } else if (bytes_read > m) { 1996 - } else 1997 - d += sprintf(d, " .."); 1998 - bytes_read += 1; 1999 - continue; 2000 - } 2001 - if (c == 0x7E) { 2002 - return 0; 2003 - } else { 2004 - if (c == 0x55) { 2005 - goto read; 2006 - } else if (read_stop-- > 0) { 2007 - goto read; 2008 - } else { 2009 - dev_err(&ftdi->udev->dev, "retry limit reached\n"); 2010 - continue; 2011 - } 2012 - } 2013 - } else if (packet_bytes > 1) { 2014 - unsigned char s1 = ftdi->bulk_in_buffer[0]; 2015 - unsigned char s2 = ftdi->bulk_in_buffer[1]; 2016 - if (s1 == 0x31 && s2 == 0x00) { 2017 - if (read_stuck-- > 0) { 2018 - goto read; 2019 - } else 2020 - goto reset; 2021 - } else { 2022 - if (read_stop-- > 0) { 2023 - goto read; 2024 - } else { 2025 - dev_err(&ftdi->udev->dev, "retry limit reached\n"); 2026 - continue; 2027 - } 2028 - } 2029 - } else if (packet_bytes > 0) { 2030 - if (read_stop-- > 0) { 2031 - goto read; 2032 - } else { 2033 - dev_err(&ftdi->udev->dev, "retry limit reached\n"); 2034 - continue; 2035 - } 2036 - } else if (retval == -ETIMEDOUT) { 2037 - if (retry_on_timeout-- > 0) { 2038 - goto read; 2039 - } else { 2040 - dev_err(&ftdi->udev->dev, "TIMED OUT retry limit reached\n"); 2041 - continue; 2042 - } 2043 - } else if (retval == 0) { 2044 - if (retry_on_empty-- > 0) { 2045 - goto read; 2046 - } else { 2047 - dev_err(&ftdi->udev->dev, "empty packet retry limit reached\n"); 2048 - continue; 2049 - } 2050 - } else { 2051 - dev_err(&ftdi->udev->dev, "error = %d\n", 2052 - retval); 2053 - if (read_stop-- > 0) { 2054 - goto read; 2055 - } else { 2056 - dev_err(&ftdi->udev->dev, "retry limit reached\n"); 2057 - continue; 2058 - } 2059 - } 2060 - } 2061 - } 2062 - dev_err(&ftdi->udev->dev, "failed to synchronize\n"); 2063 - return -EFAULT; 2064 - } 2065 - 2066 - static int ftdi_elan_stuck_waiting(struct usb_ftdi *ftdi) 2067 - { 2068 - int retry_on_empty = 10; 2069 - int retry_on_timeout = 5; 2070 - int retry_on_status = 50; 2071 - more:{ 2072 - int packet_bytes = 0; 2073 - int retval = usb_bulk_msg(ftdi->udev, 2074 - usb_rcvbulkpipe(ftdi->udev, ftdi->bulk_in_endpointAddr), 2075 - ftdi->bulk_in_buffer, ftdi->bulk_in_size, 2076 - &packet_bytes, 1000); 2077 - if (packet_bytes > 2) { 2078 - char diag[30 *3 + 4]; 2079 - char *d = diag; 2080 - int m = (sizeof(diag) - 1) / 3 - 1; 2081 - char *b = ftdi->bulk_in_buffer; 2082 - int bytes_read = 0; 2083 - diag[0] = 0; 2084 - while (packet_bytes-- > 0) { 2085 - char c = *b++; 2086 - if (bytes_read < m) { 2087 - d += sprintf(d, " %02X", 2088 - 0x000000FF & c); 2089 - } else if (bytes_read > m) { 2090 - } else 2091 - d += sprintf(d, " .."); 2092 - bytes_read += 1; 2093 - } 2094 - goto more; 2095 - } else if (packet_bytes > 1) { 2096 - char s1 = ftdi->bulk_in_buffer[0]; 2097 - char s2 = ftdi->bulk_in_buffer[1]; 2098 - if (s1 == 0x31 && s2 == 0x60) { 2099 - return 0; 2100 - } else if (retry_on_status-- > 0) { 2101 - msleep(5); 2102 - goto more; 2103 - } else 2104 - return -EFAULT; 2105 - } else if (packet_bytes > 0) { 2106 - char b1 = ftdi->bulk_in_buffer[0]; 2107 - dev_err(&ftdi->udev->dev, "only one byte flushed from FTDI = %02X\n", b1); 2108 - if (retry_on_status-- > 0) { 2109 - msleep(5); 2110 - goto more; 2111 - } else { 2112 - dev_err(&ftdi->udev->dev, "STATUS ERROR retry limit reached\n"); 2113 - return -EFAULT; 2114 - } 2115 - } else if (retval == -ETIMEDOUT) { 2116 - if (retry_on_timeout-- > 0) { 2117 - goto more; 2118 - } else { 2119 - dev_err(&ftdi->udev->dev, "TIMED OUT retry limit reached\n"); 2120 - return -ENOMEM; 2121 - } 2122 - } else if (retval == 0) { 2123 - if (retry_on_empty-- > 0) { 2124 - goto more; 2125 - } else { 2126 - dev_err(&ftdi->udev->dev, "empty packet retry limit reached\n"); 2127 - return -ENOMEM; 2128 - } 2129 - } else { 2130 - dev_err(&ftdi->udev->dev, "error = %d\n", retval); 2131 - return -ENOMEM; 2132 - } 2133 - } 2134 - return -1; 2135 - } 2136 - 2137 - static int ftdi_elan_checkingPCI(struct usb_ftdi *ftdi) 2138 - { 2139 - int UxxxStatus = ftdi_elan_read_reg(ftdi, &ftdi->controlreg); 2140 - if (UxxxStatus) 2141 - return UxxxStatus; 2142 - if (ftdi->controlreg & 0x00400000) { 2143 - if (ftdi->card_ejected) { 2144 - } else { 2145 - ftdi->card_ejected = 1; 2146 - dev_err(&ftdi->udev->dev, "CARD EJECTED - controlreg = %08X\n", 2147 - ftdi->controlreg); 2148 - } 2149 - return -ENODEV; 2150 - } else { 2151 - u8 fn = ftdi->function - 1; 2152 - int activePCIfn = fn << 8; 2153 - u32 pcidata; 2154 - u32 pciVID; 2155 - u32 pciPID; 2156 - int reg = 0; 2157 - UxxxStatus = ftdi_elan_read_config(ftdi, activePCIfn | reg, 0, 2158 - &pcidata); 2159 - if (UxxxStatus) 2160 - return UxxxStatus; 2161 - pciVID = pcidata & 0xFFFF; 2162 - pciPID = (pcidata >> 16) & 0xFFFF; 2163 - if (pciVID == ftdi->platform_data.vendor && pciPID == 2164 - ftdi->platform_data.device) { 2165 - return 0; 2166 - } else { 2167 - dev_err(&ftdi->udev->dev, "vendor=%04X pciVID=%04X device=%04X pciPID=%04X\n", 2168 - ftdi->platform_data.vendor, pciVID, 2169 - ftdi->platform_data.device, pciPID); 2170 - return -ENODEV; 2171 - } 2172 - } 2173 - } 2174 - 2175 - 2176 - #define ftdi_read_pcimem(ftdi, member, data) ftdi_elan_read_pcimem(ftdi, \ 2177 - offsetof(struct ohci_regs, member), 0, data); 2178 - #define ftdi_write_pcimem(ftdi, member, data) ftdi_elan_write_pcimem(ftdi, \ 2179 - offsetof(struct ohci_regs, member), 0, data); 2180 - 2181 - #define OHCI_CONTROL_INIT OHCI_CTRL_CBSR 2182 - #define OHCI_INTR_INIT (OHCI_INTR_MIE | OHCI_INTR_UE | OHCI_INTR_RD | \ 2183 - OHCI_INTR_WDH) 2184 - static int ftdi_elan_check_controller(struct usb_ftdi *ftdi, int quirk) 2185 - { 2186 - int devices = 0; 2187 - int retval; 2188 - u32 hc_control; 2189 - int num_ports; 2190 - u32 control; 2191 - u32 rh_a = -1; 2192 - u32 status; 2193 - u32 fminterval; 2194 - u32 hc_fminterval; 2195 - u32 periodicstart; 2196 - u32 cmdstatus; 2197 - u32 roothub_a; 2198 - int mask = OHCI_INTR_INIT; 2199 - int sleep_time = 0; 2200 - int reset_timeout = 30; /* ... allow extra time */ 2201 - int temp; 2202 - retval = ftdi_write_pcimem(ftdi, intrdisable, OHCI_INTR_MIE); 2203 - if (retval) 2204 - return retval; 2205 - retval = ftdi_read_pcimem(ftdi, control, &control); 2206 - if (retval) 2207 - return retval; 2208 - retval = ftdi_read_pcimem(ftdi, roothub.a, &rh_a); 2209 - if (retval) 2210 - return retval; 2211 - num_ports = rh_a & RH_A_NDP; 2212 - retval = ftdi_read_pcimem(ftdi, fminterval, &hc_fminterval); 2213 - if (retval) 2214 - return retval; 2215 - hc_fminterval &= 0x3fff; 2216 - if (hc_fminterval != FI) { 2217 - } 2218 - hc_fminterval |= FSMP(hc_fminterval) << 16; 2219 - retval = ftdi_read_pcimem(ftdi, control, &hc_control); 2220 - if (retval) 2221 - return retval; 2222 - switch (hc_control & OHCI_CTRL_HCFS) { 2223 - case OHCI_USB_OPER: 2224 - sleep_time = 0; 2225 - break; 2226 - case OHCI_USB_SUSPEND: 2227 - case OHCI_USB_RESUME: 2228 - hc_control &= OHCI_CTRL_RWC; 2229 - hc_control |= OHCI_USB_RESUME; 2230 - sleep_time = 10; 2231 - break; 2232 - default: 2233 - hc_control &= OHCI_CTRL_RWC; 2234 - hc_control |= OHCI_USB_RESET; 2235 - sleep_time = 50; 2236 - break; 2237 - } 2238 - retval = ftdi_write_pcimem(ftdi, control, hc_control); 2239 - if (retval) 2240 - return retval; 2241 - retval = ftdi_read_pcimem(ftdi, control, &control); 2242 - if (retval) 2243 - return retval; 2244 - msleep(sleep_time); 2245 - retval = ftdi_read_pcimem(ftdi, roothub.a, &roothub_a); 2246 - if (retval) 2247 - return retval; 2248 - if (!(roothub_a & RH_A_NPS)) { /* power down each port */ 2249 - for (temp = 0; temp < num_ports; temp++) { 2250 - retval = ftdi_write_pcimem(ftdi, 2251 - roothub.portstatus[temp], RH_PS_LSDA); 2252 - if (retval) 2253 - return retval; 2254 - } 2255 - } 2256 - retval = ftdi_read_pcimem(ftdi, control, &control); 2257 - if (retval) 2258 - return retval; 2259 - retry:retval = ftdi_read_pcimem(ftdi, cmdstatus, &status); 2260 - if (retval) 2261 - return retval; 2262 - retval = ftdi_write_pcimem(ftdi, cmdstatus, OHCI_HCR); 2263 - if (retval) 2264 - return retval; 2265 - extra:{ 2266 - retval = ftdi_read_pcimem(ftdi, cmdstatus, &status); 2267 - if (retval) 2268 - return retval; 2269 - if (0 != (status & OHCI_HCR)) { 2270 - if (--reset_timeout == 0) { 2271 - dev_err(&ftdi->udev->dev, "USB HC reset timed out!\n"); 2272 - return -ENODEV; 2273 - } else { 2274 - msleep(5); 2275 - goto extra; 2276 - } 2277 - } 2278 - } 2279 - if (quirk & OHCI_QUIRK_INITRESET) { 2280 - retval = ftdi_write_pcimem(ftdi, control, hc_control); 2281 - if (retval) 2282 - return retval; 2283 - retval = ftdi_read_pcimem(ftdi, control, &control); 2284 - if (retval) 2285 - return retval; 2286 - } 2287 - retval = ftdi_write_pcimem(ftdi, ed_controlhead, 0x00000000); 2288 - if (retval) 2289 - return retval; 2290 - retval = ftdi_write_pcimem(ftdi, ed_bulkhead, 0x11000000); 2291 - if (retval) 2292 - return retval; 2293 - retval = ftdi_write_pcimem(ftdi, hcca, 0x00000000); 2294 - if (retval) 2295 - return retval; 2296 - retval = ftdi_read_pcimem(ftdi, fminterval, &fminterval); 2297 - if (retval) 2298 - return retval; 2299 - retval = ftdi_write_pcimem(ftdi, fminterval, 2300 - ((fminterval & FIT) ^ FIT) | hc_fminterval); 2301 - if (retval) 2302 - return retval; 2303 - retval = ftdi_write_pcimem(ftdi, periodicstart, 2304 - ((9 *hc_fminterval) / 10) & 0x3fff); 2305 - if (retval) 2306 - return retval; 2307 - retval = ftdi_read_pcimem(ftdi, fminterval, &fminterval); 2308 - if (retval) 2309 - return retval; 2310 - retval = ftdi_read_pcimem(ftdi, periodicstart, &periodicstart); 2311 - if (retval) 2312 - return retval; 2313 - if (0 == (fminterval & 0x3fff0000) || 0 == periodicstart) { 2314 - if (!(quirk & OHCI_QUIRK_INITRESET)) { 2315 - quirk |= OHCI_QUIRK_INITRESET; 2316 - goto retry; 2317 - } else 2318 - dev_err(&ftdi->udev->dev, "init err(%08x %04x)\n", 2319 - fminterval, periodicstart); 2320 - } /* start controller operations */ 2321 - hc_control &= OHCI_CTRL_RWC; 2322 - hc_control |= OHCI_CONTROL_INIT | OHCI_CTRL_BLE | OHCI_USB_OPER; 2323 - retval = ftdi_write_pcimem(ftdi, control, hc_control); 2324 - if (retval) 2325 - return retval; 2326 - retval = ftdi_write_pcimem(ftdi, cmdstatus, OHCI_BLF); 2327 - if (retval) 2328 - return retval; 2329 - retval = ftdi_read_pcimem(ftdi, cmdstatus, &cmdstatus); 2330 - if (retval) 2331 - return retval; 2332 - retval = ftdi_read_pcimem(ftdi, control, &control); 2333 - if (retval) 2334 - return retval; 2335 - retval = ftdi_write_pcimem(ftdi, roothub.status, RH_HS_DRWE); 2336 - if (retval) 2337 - return retval; 2338 - retval = ftdi_write_pcimem(ftdi, intrstatus, mask); 2339 - if (retval) 2340 - return retval; 2341 - retval = ftdi_write_pcimem(ftdi, intrdisable, 2342 - OHCI_INTR_MIE | OHCI_INTR_OC | OHCI_INTR_RHSC | OHCI_INTR_FNO | 2343 - OHCI_INTR_UE | OHCI_INTR_RD | OHCI_INTR_SF | OHCI_INTR_WDH | 2344 - OHCI_INTR_SO); 2345 - if (retval) 2346 - return retval; /* handle root hub init quirks ... */ 2347 - retval = ftdi_read_pcimem(ftdi, roothub.a, &roothub_a); 2348 - if (retval) 2349 - return retval; 2350 - roothub_a &= ~(RH_A_PSM | RH_A_OCPM); 2351 - if (quirk & OHCI_QUIRK_SUPERIO) { 2352 - roothub_a |= RH_A_NOCP; 2353 - roothub_a &= ~(RH_A_POTPGT | RH_A_NPS); 2354 - retval = ftdi_write_pcimem(ftdi, roothub.a, roothub_a); 2355 - if (retval) 2356 - return retval; 2357 - } else if ((quirk & OHCI_QUIRK_AMD756) || distrust_firmware) { 2358 - roothub_a |= RH_A_NPS; 2359 - retval = ftdi_write_pcimem(ftdi, roothub.a, roothub_a); 2360 - if (retval) 2361 - return retval; 2362 - } 2363 - retval = ftdi_write_pcimem(ftdi, roothub.status, RH_HS_LPSC); 2364 - if (retval) 2365 - return retval; 2366 - retval = ftdi_write_pcimem(ftdi, roothub.b, 2367 - (roothub_a & RH_A_NPS) ? 0 : RH_B_PPCM); 2368 - if (retval) 2369 - return retval; 2370 - retval = ftdi_read_pcimem(ftdi, control, &control); 2371 - if (retval) 2372 - return retval; 2373 - mdelay((roothub_a >> 23) & 0x1fe); 2374 - for (temp = 0; temp < num_ports; temp++) { 2375 - u32 portstatus; 2376 - retval = ftdi_read_pcimem(ftdi, roothub.portstatus[temp], 2377 - &portstatus); 2378 - if (retval) 2379 - return retval; 2380 - if (1 & portstatus) 2381 - devices += 1; 2382 - } 2383 - return devices; 2384 - } 2385 - 2386 - static int ftdi_elan_setup_controller(struct usb_ftdi *ftdi, int fn) 2387 - { 2388 - u32 latence_timer; 2389 - int UxxxStatus; 2390 - u32 pcidata; 2391 - int reg = 0; 2392 - int activePCIfn = fn << 8; 2393 - UxxxStatus = ftdi_elan_write_reg(ftdi, 0x0000025FL | 0x2800); 2394 - if (UxxxStatus) 2395 - return UxxxStatus; 2396 - reg = 16; 2397 - UxxxStatus = ftdi_elan_write_config(ftdi, activePCIfn | reg, 0, 2398 - 0xFFFFFFFF); 2399 - if (UxxxStatus) 2400 - return UxxxStatus; 2401 - UxxxStatus = ftdi_elan_read_config(ftdi, activePCIfn | reg, 0, 2402 - &pcidata); 2403 - if (UxxxStatus) 2404 - return UxxxStatus; 2405 - UxxxStatus = ftdi_elan_write_config(ftdi, activePCIfn | reg, 0, 2406 - 0xF0000000); 2407 - if (UxxxStatus) 2408 - return UxxxStatus; 2409 - UxxxStatus = ftdi_elan_read_config(ftdi, activePCIfn | reg, 0, 2410 - &pcidata); 2411 - if (UxxxStatus) 2412 - return UxxxStatus; 2413 - reg = 12; 2414 - UxxxStatus = ftdi_elan_read_config(ftdi, activePCIfn | reg, 0, 2415 - &latence_timer); 2416 - if (UxxxStatus) 2417 - return UxxxStatus; 2418 - latence_timer &= 0xFFFF00FF; 2419 - latence_timer |= 0x00001600; 2420 - UxxxStatus = ftdi_elan_write_config(ftdi, activePCIfn | reg, 0x00, 2421 - latence_timer); 2422 - if (UxxxStatus) 2423 - return UxxxStatus; 2424 - UxxxStatus = ftdi_elan_read_config(ftdi, activePCIfn | reg, 0, 2425 - &pcidata); 2426 - if (UxxxStatus) 2427 - return UxxxStatus; 2428 - reg = 4; 2429 - UxxxStatus = ftdi_elan_write_config(ftdi, activePCIfn | reg, 0x00, 2430 - 0x06); 2431 - if (UxxxStatus) 2432 - return UxxxStatus; 2433 - UxxxStatus = ftdi_elan_read_config(ftdi, activePCIfn | reg, 0, 2434 - &pcidata); 2435 - if (UxxxStatus) 2436 - return UxxxStatus; 2437 - for (reg = 0; reg <= 0x54; reg += 4) { 2438 - UxxxStatus = ftdi_elan_read_pcimem(ftdi, reg, 0, &pcidata); 2439 - if (UxxxStatus) 2440 - return UxxxStatus; 2441 - } 2442 - return 0; 2443 - } 2444 - 2445 - static int ftdi_elan_close_controller(struct usb_ftdi *ftdi, int fn) 2446 - { 2447 - u32 latence_timer; 2448 - int UxxxStatus; 2449 - u32 pcidata; 2450 - int reg = 0; 2451 - int activePCIfn = fn << 8; 2452 - UxxxStatus = ftdi_elan_write_reg(ftdi, 0x0000025FL | 0x2800); 2453 - if (UxxxStatus) 2454 - return UxxxStatus; 2455 - reg = 16; 2456 - UxxxStatus = ftdi_elan_write_config(ftdi, activePCIfn | reg, 0, 2457 - 0xFFFFFFFF); 2458 - if (UxxxStatus) 2459 - return UxxxStatus; 2460 - UxxxStatus = ftdi_elan_read_config(ftdi, activePCIfn | reg, 0, 2461 - &pcidata); 2462 - if (UxxxStatus) 2463 - return UxxxStatus; 2464 - UxxxStatus = ftdi_elan_write_config(ftdi, activePCIfn | reg, 0, 2465 - 0x00000000); 2466 - if (UxxxStatus) 2467 - return UxxxStatus; 2468 - UxxxStatus = ftdi_elan_read_config(ftdi, activePCIfn | reg, 0, 2469 - &pcidata); 2470 - if (UxxxStatus) 2471 - return UxxxStatus; 2472 - reg = 12; 2473 - UxxxStatus = ftdi_elan_read_config(ftdi, activePCIfn | reg, 0, 2474 - &latence_timer); 2475 - if (UxxxStatus) 2476 - return UxxxStatus; 2477 - latence_timer &= 0xFFFF00FF; 2478 - latence_timer |= 0x00001600; 2479 - UxxxStatus = ftdi_elan_write_config(ftdi, activePCIfn | reg, 0x00, 2480 - latence_timer); 2481 - if (UxxxStatus) 2482 - return UxxxStatus; 2483 - UxxxStatus = ftdi_elan_read_config(ftdi, activePCIfn | reg, 0, 2484 - &pcidata); 2485 - if (UxxxStatus) 2486 - return UxxxStatus; 2487 - reg = 4; 2488 - UxxxStatus = ftdi_elan_write_config(ftdi, activePCIfn | reg, 0x00, 2489 - 0x00); 2490 - if (UxxxStatus) 2491 - return UxxxStatus; 2492 - return ftdi_elan_read_config(ftdi, activePCIfn | reg, 0, &pcidata); 2493 - } 2494 - 2495 - static int ftdi_elan_found_controller(struct usb_ftdi *ftdi, int fn, int quirk) 2496 - { 2497 - int result; 2498 - int UxxxStatus; 2499 - UxxxStatus = ftdi_elan_setup_controller(ftdi, fn); 2500 - if (UxxxStatus) 2501 - return UxxxStatus; 2502 - result = ftdi_elan_check_controller(ftdi, quirk); 2503 - UxxxStatus = ftdi_elan_close_controller(ftdi, fn); 2504 - if (UxxxStatus) 2505 - return UxxxStatus; 2506 - return result; 2507 - } 2508 - 2509 - static int ftdi_elan_enumeratePCI(struct usb_ftdi *ftdi) 2510 - { 2511 - u32 controlreg; 2512 - u8 sensebits; 2513 - int UxxxStatus; 2514 - UxxxStatus = ftdi_elan_read_reg(ftdi, &controlreg); 2515 - if (UxxxStatus) 2516 - return UxxxStatus; 2517 - UxxxStatus = ftdi_elan_write_reg(ftdi, 0x00000000L); 2518 - if (UxxxStatus) 2519 - return UxxxStatus; 2520 - msleep(750); 2521 - UxxxStatus = ftdi_elan_write_reg(ftdi, 0x00000200L | 0x100); 2522 - if (UxxxStatus) 2523 - return UxxxStatus; 2524 - UxxxStatus = ftdi_elan_write_reg(ftdi, 0x00000200L | 0x500); 2525 - if (UxxxStatus) 2526 - return UxxxStatus; 2527 - UxxxStatus = ftdi_elan_read_reg(ftdi, &controlreg); 2528 - if (UxxxStatus) 2529 - return UxxxStatus; 2530 - UxxxStatus = ftdi_elan_write_reg(ftdi, 0x0000020CL | 0x000); 2531 - if (UxxxStatus) 2532 - return UxxxStatus; 2533 - UxxxStatus = ftdi_elan_write_reg(ftdi, 0x0000020DL | 0x000); 2534 - if (UxxxStatus) 2535 - return UxxxStatus; 2536 - msleep(250); 2537 - UxxxStatus = ftdi_elan_write_reg(ftdi, 0x0000020FL | 0x000); 2538 - if (UxxxStatus) 2539 - return UxxxStatus; 2540 - UxxxStatus = ftdi_elan_read_reg(ftdi, &controlreg); 2541 - if (UxxxStatus) 2542 - return UxxxStatus; 2543 - UxxxStatus = ftdi_elan_write_reg(ftdi, 0x0000025FL | 0x800); 2544 - if (UxxxStatus) 2545 - return UxxxStatus; 2546 - UxxxStatus = ftdi_elan_read_reg(ftdi, &controlreg); 2547 - if (UxxxStatus) 2548 - return UxxxStatus; 2549 - UxxxStatus = ftdi_elan_read_reg(ftdi, &controlreg); 2550 - if (UxxxStatus) 2551 - return UxxxStatus; 2552 - msleep(1000); 2553 - sensebits = (controlreg >> 16) & 0x000F; 2554 - if (0x0D == sensebits) 2555 - return 0; 2556 - else 2557 - return - ENXIO; 2558 - } 2559 - 2560 - static int ftdi_elan_setupOHCI(struct usb_ftdi *ftdi) 2561 - { 2562 - int UxxxStatus; 2563 - u32 pcidata; 2564 - int reg = 0; 2565 - u8 fn; 2566 - int activePCIfn = 0; 2567 - int max_devices = 0; 2568 - int controllers = 0; 2569 - int unrecognized = 0; 2570 - ftdi->function = 0; 2571 - for (fn = 0; (fn < 4); fn++) { 2572 - u32 pciVID = 0; 2573 - u32 pciPID = 0; 2574 - int devices = 0; 2575 - activePCIfn = fn << 8; 2576 - UxxxStatus = ftdi_elan_read_config(ftdi, activePCIfn | reg, 0, 2577 - &pcidata); 2578 - if (UxxxStatus) 2579 - return UxxxStatus; 2580 - pciVID = pcidata & 0xFFFF; 2581 - pciPID = (pcidata >> 16) & 0xFFFF; 2582 - if ((pciVID == PCI_VENDOR_ID_OPTI) && (pciPID == 0xc861)) { 2583 - devices = ftdi_elan_found_controller(ftdi, fn, 0); 2584 - controllers += 1; 2585 - } else if ((pciVID == PCI_VENDOR_ID_NEC) && (pciPID == 0x0035)) 2586 - { 2587 - devices = ftdi_elan_found_controller(ftdi, fn, 0); 2588 - controllers += 1; 2589 - } else if ((pciVID == PCI_VENDOR_ID_AL) && (pciPID == 0x5237)) { 2590 - devices = ftdi_elan_found_controller(ftdi, fn, 0); 2591 - controllers += 1; 2592 - } else if ((pciVID == PCI_VENDOR_ID_ATT) && (pciPID == 0x5802)) 2593 - { 2594 - devices = ftdi_elan_found_controller(ftdi, fn, 0); 2595 - controllers += 1; 2596 - } else if (pciVID == PCI_VENDOR_ID_AMD && pciPID == 0x740c) { 2597 - devices = ftdi_elan_found_controller(ftdi, fn, 2598 - OHCI_QUIRK_AMD756); 2599 - controllers += 1; 2600 - } else if (pciVID == PCI_VENDOR_ID_COMPAQ && pciPID == 0xa0f8) { 2601 - devices = ftdi_elan_found_controller(ftdi, fn, 2602 - OHCI_QUIRK_ZFMICRO); 2603 - controllers += 1; 2604 - } else if (0 == pcidata) { 2605 - } else 2606 - unrecognized += 1; 2607 - if (devices > max_devices) { 2608 - max_devices = devices; 2609 - ftdi->function = fn + 1; 2610 - ftdi->platform_data.vendor = pciVID; 2611 - ftdi->platform_data.device = pciPID; 2612 - } 2613 - } 2614 - if (ftdi->function > 0) { 2615 - return ftdi_elan_setup_controller(ftdi, ftdi->function - 1); 2616 - } else if (controllers > 0) { 2617 - return -ENXIO; 2618 - } else if (unrecognized > 0) { 2619 - return -ENXIO; 2620 - } else { 2621 - ftdi->enumerated = 0; 2622 - return -ENXIO; 2623 - } 2624 - } 2625 - 2626 - 2627 - /* 2628 - * we use only the first bulk-in and bulk-out endpoints 2629 - */ 2630 - static int ftdi_elan_probe(struct usb_interface *interface, 2631 - const struct usb_device_id *id) 2632 - { 2633 - struct usb_host_interface *iface_desc; 2634 - struct usb_endpoint_descriptor *bulk_in, *bulk_out; 2635 - int retval; 2636 - struct usb_ftdi *ftdi; 2637 - 2638 - ftdi = kzalloc(sizeof(struct usb_ftdi), GFP_KERNEL); 2639 - if (!ftdi) 2640 - return -ENOMEM; 2641 - 2642 - mutex_lock(&ftdi_module_lock); 2643 - list_add_tail(&ftdi->ftdi_list, &ftdi_static_list); 2644 - ftdi->sequence_num = ++ftdi_instances; 2645 - mutex_unlock(&ftdi_module_lock); 2646 - ftdi_elan_init_kref(ftdi); 2647 - sema_init(&ftdi->sw_lock, 1); 2648 - ftdi->udev = usb_get_dev(interface_to_usbdev(interface)); 2649 - ftdi->interface = interface; 2650 - mutex_init(&ftdi->u132_lock); 2651 - ftdi->expected = 4; 2652 - 2653 - iface_desc = interface->cur_altsetting; 2654 - retval = usb_find_common_endpoints(iface_desc, 2655 - &bulk_in, &bulk_out, NULL, NULL); 2656 - if (retval) { 2657 - dev_err(&ftdi->udev->dev, "Could not find both bulk-in and bulk-out endpoints\n"); 2658 - goto error; 2659 - } 2660 - 2661 - ftdi->bulk_in_size = usb_endpoint_maxp(bulk_in); 2662 - ftdi->bulk_in_endpointAddr = bulk_in->bEndpointAddress; 2663 - ftdi->bulk_in_buffer = kmalloc(ftdi->bulk_in_size, GFP_KERNEL); 2664 - if (!ftdi->bulk_in_buffer) { 2665 - retval = -ENOMEM; 2666 - goto error; 2667 - } 2668 - 2669 - ftdi->bulk_out_endpointAddr = bulk_out->bEndpointAddress; 2670 - 2671 - dev_info(&ftdi->udev->dev, "interface %d has I=%02X O=%02X\n", 2672 - iface_desc->desc.bInterfaceNumber, ftdi->bulk_in_endpointAddr, 2673 - ftdi->bulk_out_endpointAddr); 2674 - usb_set_intfdata(interface, ftdi); 2675 - if (iface_desc->desc.bInterfaceNumber == 0 && 2676 - ftdi->bulk_in_endpointAddr == 0x81 && 2677 - ftdi->bulk_out_endpointAddr == 0x02) { 2678 - retval = usb_register_dev(interface, &ftdi_elan_jtag_class); 2679 - if (retval) { 2680 - dev_err(&ftdi->udev->dev, "Not able to get a minor for this device\n"); 2681 - usb_set_intfdata(interface, NULL); 2682 - retval = -ENOMEM; 2683 - goto error; 2684 - } else { 2685 - ftdi->class = &ftdi_elan_jtag_class; 2686 - dev_info(&ftdi->udev->dev, "USB FDTI=%p JTAG interface %d now attached to ftdi%d\n", 2687 - ftdi, iface_desc->desc.bInterfaceNumber, 2688 - interface->minor); 2689 - return 0; 2690 - } 2691 - } else if (iface_desc->desc.bInterfaceNumber == 1 && 2692 - ftdi->bulk_in_endpointAddr == 0x83 && 2693 - ftdi->bulk_out_endpointAddr == 0x04) { 2694 - ftdi->class = NULL; 2695 - dev_info(&ftdi->udev->dev, "USB FDTI=%p ELAN interface %d now activated\n", 2696 - ftdi, iface_desc->desc.bInterfaceNumber); 2697 - INIT_DELAYED_WORK(&ftdi->status_work, ftdi_elan_status_work); 2698 - INIT_DELAYED_WORK(&ftdi->command_work, ftdi_elan_command_work); 2699 - INIT_DELAYED_WORK(&ftdi->respond_work, ftdi_elan_respond_work); 2700 - ftdi_status_queue_work(ftdi, msecs_to_jiffies(3 *1000)); 2701 - return 0; 2702 - } else { 2703 - dev_err(&ftdi->udev->dev, 2704 - "Could not find ELAN's U132 device\n"); 2705 - retval = -ENODEV; 2706 - goto error; 2707 - } 2708 - error:if (ftdi) { 2709 - ftdi_elan_put_kref(ftdi); 2710 - } 2711 - return retval; 2712 - } 2713 - 2714 - static void ftdi_elan_disconnect(struct usb_interface *interface) 2715 - { 2716 - struct usb_ftdi *ftdi = usb_get_intfdata(interface); 2717 - ftdi->disconnected += 1; 2718 - if (ftdi->class) { 2719 - int minor = interface->minor; 2720 - struct usb_class_driver *class = ftdi->class; 2721 - usb_set_intfdata(interface, NULL); 2722 - usb_deregister_dev(interface, class); 2723 - dev_info(&ftdi->udev->dev, "USB FTDI U132 jtag interface on minor %d now disconnected\n", 2724 - minor); 2725 - } else { 2726 - ftdi_status_cancel_work(ftdi); 2727 - ftdi_command_cancel_work(ftdi); 2728 - ftdi_response_cancel_work(ftdi); 2729 - ftdi_elan_abandon_completions(ftdi); 2730 - ftdi_elan_abandon_targets(ftdi); 2731 - if (ftdi->registered) { 2732 - platform_device_unregister(&ftdi->platform_dev); 2733 - ftdi->synchronized = 0; 2734 - ftdi->enumerated = 0; 2735 - ftdi->initialized = 0; 2736 - ftdi->registered = 0; 2737 - } 2738 - ftdi->disconnected += 1; 2739 - usb_set_intfdata(interface, NULL); 2740 - dev_info(&ftdi->udev->dev, "USB FTDI U132 host controller interface now disconnected\n"); 2741 - } 2742 - ftdi_elan_put_kref(ftdi); 2743 - } 2744 - 2745 - static struct usb_driver ftdi_elan_driver = { 2746 - .name = "ftdi-elan", 2747 - .probe = ftdi_elan_probe, 2748 - .disconnect = ftdi_elan_disconnect, 2749 - .id_table = ftdi_elan_table, 2750 - }; 2751 - static int __init ftdi_elan_init(void) 2752 - { 2753 - int result; 2754 - pr_info("driver %s\n", ftdi_elan_driver.name); 2755 - mutex_init(&ftdi_module_lock); 2756 - INIT_LIST_HEAD(&ftdi_static_list); 2757 - result = usb_register(&ftdi_elan_driver); 2758 - if (result) { 2759 - pr_err("usb_register failed. Error number %d\n", result); 2760 - } 2761 - return result; 2762 - 2763 - } 2764 - 2765 - static void __exit ftdi_elan_exit(void) 2766 - { 2767 - struct usb_ftdi *ftdi; 2768 - struct usb_ftdi *temp; 2769 - usb_deregister(&ftdi_elan_driver); 2770 - pr_info("ftdi_u132 driver deregistered\n"); 2771 - list_for_each_entry_safe(ftdi, temp, &ftdi_static_list, ftdi_list) { 2772 - ftdi_status_cancel_work(ftdi); 2773 - ftdi_command_cancel_work(ftdi); 2774 - ftdi_response_cancel_work(ftdi); 2775 - } 2776 - } 2777 - 2778 - 2779 - module_init(ftdi_elan_init); 2780 - module_exit(ftdi_elan_exit);
+14
drivers/usb/misc/sisusbvga/sisusbvga.c
··· 2778 2778 struct usb_device *dev = interface_to_usbdev(intf); 2779 2779 struct sisusb_usb_data *sisusb; 2780 2780 int retval = 0, i; 2781 + static const u8 ep_addresses[] = { 2782 + SISUSB_EP_GFX_IN | USB_DIR_IN, 2783 + SISUSB_EP_GFX_OUT | USB_DIR_OUT, 2784 + SISUSB_EP_GFX_BULK_OUT | USB_DIR_OUT, 2785 + SISUSB_EP_GFX_LBULK_OUT | USB_DIR_OUT, 2786 + SISUSB_EP_BRIDGE_IN | USB_DIR_IN, 2787 + SISUSB_EP_BRIDGE_OUT | USB_DIR_OUT, 2788 + 0}; 2789 + 2790 + /* Are the expected endpoints present? */ 2791 + if (!usb_check_bulk_endpoints(intf, ep_addresses)) { 2792 + dev_err(&intf->dev, "Invalid USB2VGA device\n"); 2793 + return -EINVAL; 2794 + } 2781 2795 2782 2796 dev_info(&dev->dev, "USB2VGA dongle found at address %d\n", 2783 2797 dev->devnum);
+16 -27
drivers/usb/misc/usb251xb.c
··· 377 377 return err; 378 378 } 379 379 380 - #ifdef CONFIG_OF 381 380 static void usb251xb_get_ports_field(struct usb251xb *hub, 382 381 const char *prop_name, u8 port_cnt, 383 382 bool ds_only, u8 *fld) ··· 409 410 return -ENODEV; 410 411 } 411 412 412 - if (of_get_property(np, "skip-config", NULL)) 413 - hub->skip_config = 1; 414 - else 415 - hub->skip_config = 0; 413 + hub->skip_config = of_property_read_bool(np, "skip-config"); 416 414 417 415 hub->gpio_reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH); 418 416 if (IS_ERR(hub->gpio_reset)) ··· 427 431 hub->device_id = USB251XB_DEF_DEVICE_ID; 428 432 429 433 hub->conf_data1 = USB251XB_DEF_CONFIG_DATA_1; 430 - if (of_get_property(np, "self-powered", NULL)) { 434 + if (of_property_read_bool(np, "self-powered")) { 431 435 hub->conf_data1 |= BIT(7); 432 436 433 437 /* Configure Over-Current sens when self-powered */ 434 438 hub->conf_data1 &= ~BIT(2); 435 - if (of_get_property(np, "ganged-sensing", NULL)) 439 + if (of_property_read_bool(np, "ganged-sensing")) 436 440 hub->conf_data1 &= ~BIT(1); 437 - else if (of_get_property(np, "individual-sensing", NULL)) 441 + else if (of_property_read_bool(np, "individual-sensing")) 438 442 hub->conf_data1 |= BIT(1); 439 - } else if (of_get_property(np, "bus-powered", NULL)) { 443 + } else if (of_property_read_bool(np, "bus-powered")) { 440 444 hub->conf_data1 &= ~BIT(7); 441 445 442 446 /* Disable Over-Current sense when bus-powered */ 443 447 hub->conf_data1 |= BIT(2); 444 448 } 445 449 446 - if (of_get_property(np, "disable-hi-speed", NULL)) 450 + if (of_property_read_bool(np, "disable-hi-speed")) 447 451 hub->conf_data1 |= BIT(5); 448 452 449 - if (of_get_property(np, "multi-tt", NULL)) 453 + if (of_property_read_bool(np, "multi-tt")) 450 454 hub->conf_data1 |= BIT(4); 451 - else if (of_get_property(np, "single-tt", NULL)) 455 + else if (of_property_read_bool(np, "single-tt")) 452 456 hub->conf_data1 &= ~BIT(4); 453 457 454 - if (of_get_property(np, "disable-eop", NULL)) 458 + if (of_property_read_bool(np, "disable-eop")) 455 459 hub->conf_data1 |= BIT(3); 456 460 457 - if (of_get_property(np, "individual-port-switching", NULL)) 461 + if (of_property_read_bool(np, "individual-port-switching")) 458 462 hub->conf_data1 |= BIT(0); 459 - else if (of_get_property(np, "ganged-port-switching", NULL)) 463 + else if (of_property_read_bool(np, "ganged-port-switching")) 460 464 hub->conf_data1 &= ~BIT(0); 461 465 462 466 hub->conf_data2 = USB251XB_DEF_CONFIG_DATA_2; 463 - if (of_get_property(np, "dynamic-power-switching", NULL)) 467 + if (of_property_read_bool(np, "dynamic-power-switching")) 464 468 hub->conf_data2 |= BIT(7); 465 469 466 470 if (!of_property_read_u32(np, "oc-delay-us", &property_u32)) { ··· 483 487 } 484 488 } 485 489 486 - if (of_get_property(np, "compound-device", NULL)) 490 + if (of_property_read_bool(np, "compound-device")) 487 491 hub->conf_data2 |= BIT(3); 488 492 489 493 hub->conf_data3 = USB251XB_DEF_CONFIG_DATA_3; 490 - if (of_get_property(np, "port-mapping-mode", NULL)) 494 + if (of_property_read_bool(np, "port-mapping-mode")) 491 495 hub->conf_data3 |= BIT(3); 492 496 493 497 if (data->led_support && of_get_property(np, "led-usb-mode", NULL)) 494 498 hub->conf_data3 &= ~BIT(1); 495 499 496 - if (of_get_property(np, "string-support", NULL)) 500 + if (of_property_read_bool(np, "string-support")) 497 501 hub->conf_data3 |= BIT(0); 498 502 499 503 hub->non_rem_dev = USB251XB_DEF_NON_REMOVABLE_DEVICES; ··· 622 626 } 623 627 }; 624 628 MODULE_DEVICE_TABLE(of, usb251xb_of_match); 625 - #else /* CONFIG_OF */ 626 - static int usb251xb_get_ofdata(struct usb251xb *hub, 627 - const struct usb251xb_data *data) 628 - { 629 - return 0; 630 - } 631 - #endif /* CONFIG_OF */ 632 629 633 630 static void usb251xb_regulator_disable_action(void *data) 634 631 { ··· 743 754 static struct i2c_driver usb251xb_i2c_driver = { 744 755 .driver = { 745 756 .name = DRIVER_NAME, 746 - .of_match_table = of_match_ptr(usb251xb_of_match), 757 + .of_match_table = usb251xb_of_match, 747 758 .pm = &usb251xb_pm_ops, 748 759 }, 749 760 .probe_new = usb251xb_i2c_probe,
+39 -25
drivers/usb/misc/usb3503.c
··· 46 46 struct device *dev; 47 47 struct clk *clk; 48 48 u8 port_off_mask; 49 + struct gpio_desc *bypass; 49 50 struct gpio_desc *intn; 50 51 struct gpio_desc *reset; 51 52 struct gpio_desc *connect; 52 53 bool secondary_ref_clk; 53 54 }; 54 55 55 - static int usb3503_reset(struct usb3503 *hub, int state) 56 - { 57 - if (!state && hub->connect) 58 - gpiod_set_value_cansleep(hub->connect, 0); 59 - 60 - if (hub->reset) 61 - gpiod_set_value_cansleep(hub->reset, !state); 62 - 63 - /* Wait T_HUBINIT == 4ms for hub logic to stabilize */ 64 - if (state) 65 - usleep_range(4000, 10000); 66 - 67 - return 0; 68 - } 69 - 70 56 static int usb3503_connect(struct usb3503 *hub) 71 57 { 72 58 struct device *dev = hub->dev; 73 59 int err; 74 - 75 - usb3503_reset(hub, 1); 76 60 77 61 if (hub->regmap) { 78 62 /* SP_ILOCK: set connect_n, config_n for config */ ··· 110 126 static int usb3503_switch_mode(struct usb3503 *hub, enum usb3503_mode mode) 111 127 { 112 128 struct device *dev = hub->dev; 113 - int err = 0; 129 + int rst, bypass, conn; 114 130 115 131 switch (mode) { 116 132 case USB3503_MODE_HUB: 117 - err = usb3503_connect(hub); 133 + conn = 1; 134 + rst = 0; 135 + bypass = 0; 118 136 break; 119 - 120 137 case USB3503_MODE_STANDBY: 121 - usb3503_reset(hub, 0); 138 + conn = 0; 139 + rst = 1; 140 + bypass = 1; 122 141 dev_info(dev, "switched to STANDBY mode\n"); 123 142 break; 124 - 143 + case USB3503_MODE_BYPASS: 144 + conn = 0; 145 + rst = 0; 146 + bypass = 1; 147 + break; 125 148 default: 126 149 dev_err(dev, "unknown mode is requested\n"); 127 - err = -EINVAL; 128 - break; 150 + return -EINVAL; 129 151 } 130 152 131 - return err; 153 + if (!conn && hub->connect) 154 + gpiod_set_value_cansleep(hub->connect, 0); 155 + 156 + if (hub->reset) 157 + gpiod_set_value_cansleep(hub->reset, rst); 158 + 159 + if (hub->bypass) 160 + gpiod_set_value_cansleep(hub->bypass, bypass); 161 + 162 + if (conn) { 163 + /* Wait T_HUBINIT == 4ms for hub logic to stabilize */ 164 + usleep_range(4000, 10000); 165 + return usb3503_connect(hub); 166 + } 167 + 168 + return 0; 132 169 } 133 170 134 171 static const struct regmap_config usb3503_regmap_config = { ··· 257 252 } 258 253 if (hub->connect) 259 254 gpiod_set_consumer_name(hub->connect, "usb3503 connect"); 255 + 256 + hub->bypass = devm_gpiod_get_optional(dev, "bypass", GPIOD_OUT_HIGH); 257 + if (IS_ERR(hub->bypass)) { 258 + err = PTR_ERR(hub->bypass); 259 + goto err_clk; 260 + } 261 + if (hub->bypass) 262 + gpiod_set_consumer_name(hub->bypass, "usb3503 bypass"); 260 263 261 264 hub->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH); 262 265 if (IS_ERR(hub->reset)) { ··· 401 388 static const struct of_device_id usb3503_of_match[] = { 402 389 { .compatible = "smsc,usb3503", }, 403 390 { .compatible = "smsc,usb3503a", }, 391 + { .compatible = "smsc,usb3803", }, 404 392 {}, 405 393 }; 406 394 MODULE_DEVICE_TABLE(of, usb3503_of_match);
+1 -1
drivers/usb/mtu3/mtu3.h
··· 90 90 */ 91 91 #define EP0_RESPONSE_BUF 6 92 92 93 - #define BULK_CLKS_CNT 4 93 + #define BULK_CLKS_CNT 6 94 94 95 95 /* device operated link and speed got from DEVICE_CONF register */ 96 96 enum mtu3_speed {
+1
drivers/usb/mtu3/mtu3_dr.c
··· 294 294 role_sx_desc.get = ssusb_role_sw_get; 295 295 role_sx_desc.fwnode = dev_fwnode(dev); 296 296 role_sx_desc.driver_data = ssusb; 297 + role_sx_desc.allow_userspace_control = true; 297 298 otg_sx->role_sw = usb_role_switch_register(dev, &role_sx_desc); 298 299 if (IS_ERR(otg_sx->role_sw)) 299 300 return PTR_ERR(otg_sx->role_sw);
+1 -1
drivers/usb/mtu3/mtu3_gadget.c
··· 23 23 req->status = status; 24 24 25 25 trace_mtu3_req_complete(mreq); 26 - spin_unlock(&mtu->lock); 27 26 28 27 /* ep0 makes use of PIO, needn't unmap it */ 29 28 if (mep->epnum) ··· 31 32 dev_dbg(mtu->dev, "%s complete req: %p, sts %d, %d/%d\n", 32 33 mep->name, req, req->status, req->actual, req->length); 33 34 35 + spin_unlock(&mtu->lock); 34 36 usb_gadget_giveback_request(&mep->ep, req); 35 37 spin_lock(&mtu->lock); 36 38 }
+1 -1
drivers/usb/mtu3/mtu3_host.c
··· 11 11 #include <linux/irq.h> 12 12 #include <linux/kernel.h> 13 13 #include <linux/mfd/syscon.h> 14 - #include <linux/of_device.h> 14 + #include <linux/of_platform.h> 15 15 #include <linux/regmap.h> 16 16 17 17 #include "mtu3.h"
+2
drivers/usb/mtu3/mtu3_plat.c
··· 234 234 clks[1].id = "ref_ck"; 235 235 clks[2].id = "mcu_ck"; 236 236 clks[3].id = "dma_ck"; 237 + clks[4].id = "xhci_ck"; 238 + clks[5].id = "frmcnt_ck"; 237 239 ret = devm_clk_bulk_get_optional(dev, BULK_CLKS_CNT, clks); 238 240 if (ret) 239 241 return ret;
+40 -4
drivers/usb/mtu3/mtu3_qmu.c
··· 210 210 return ring->enqueue; 211 211 } 212 212 213 + /* @dequeue may be NULL if ring is unallocated or freed */ 213 214 static struct qmu_gpd *advance_deq_gpd(struct mtu3_gpd_ring *ring) 214 215 { 215 216 if (ring->dequeue < ring->end) ··· 222 221 } 223 222 224 223 /* check if a ring is emtpy */ 225 - static int gpd_ring_empty(struct mtu3_gpd_ring *ring) 224 + static bool gpd_ring_empty(struct mtu3_gpd_ring *ring) 226 225 { 227 226 struct qmu_gpd *enq = ring->enqueue; 228 227 struct qmu_gpd *next; ··· 468 467 } 469 468 470 469 /* 470 + * when rx error happens (except zlperr), QMU will stop, and RQCPR saves 471 + * the GPD encountered error, Done irq will arise after resuming QMU again. 472 + */ 473 + static void qmu_error_rx(struct mtu3 *mtu, u8 epnum) 474 + { 475 + struct mtu3_ep *mep = mtu->out_eps + epnum; 476 + struct mtu3_gpd_ring *ring = &mep->gpd_ring; 477 + struct qmu_gpd *gpd_current = NULL; 478 + struct mtu3_request *mreq; 479 + dma_addr_t cur_gpd_dma; 480 + 481 + cur_gpd_dma = read_rxq_cur_addr(mtu->mac_base, epnum); 482 + gpd_current = gpd_dma_to_virt(ring, cur_gpd_dma); 483 + 484 + mreq = next_request(mep); 485 + if (!mreq || mreq->gpd != gpd_current) { 486 + dev_err(mtu->dev, "no correct RX req is found\n"); 487 + return; 488 + } 489 + 490 + mreq->request.status = -EAGAIN; 491 + 492 + /* by pass the current GDP */ 493 + gpd_current->dw0_info |= cpu_to_le32(GPD_FLAGS_BPS | GPD_FLAGS_HWO); 494 + mtu3_qmu_resume(mep); 495 + 496 + dev_dbg(mtu->dev, "%s EP%d, current=%p, req=%p\n", 497 + __func__, epnum, gpd_current, mreq); 498 + } 499 + 500 + /* 471 501 * NOTE: request list maybe is already empty as following case: 472 502 * queue_tx --> qmu_interrupt(clear interrupt pending, schedule tasklet)--> 473 503 * queue_tx --> process_tasklet(meanwhile, the second one is transferred, ··· 523 491 dev_dbg(mtu->dev, "%s EP%d, last=%p, current=%p, enq=%p\n", 524 492 __func__, epnum, gpd, gpd_current, ring->enqueue); 525 493 526 - while (gpd != gpd_current && !GET_GPD_HWO(gpd)) { 494 + while (gpd && gpd != gpd_current && !GET_GPD_HWO(gpd)) { 527 495 528 496 mreq = next_request(mep); 529 497 ··· 562 530 dev_dbg(mtu->dev, "%s EP%d, last=%p, current=%p, enq=%p\n", 563 531 __func__, epnum, gpd, gpd_current, ring->enqueue); 564 532 565 - while (gpd != gpd_current && !GET_GPD_HWO(gpd)) { 533 + while (gpd && gpd != gpd_current && !GET_GPD_HWO(gpd)) { 566 534 567 535 mreq = next_request(mep); 568 536 ··· 603 571 604 572 if ((qmu_status & RXQ_CSERR_INT) || (qmu_status & RXQ_LENERR_INT)) { 605 573 errval = mtu3_readl(mbase, U3D_RQERRIR0); 574 + mtu3_writel(mbase, U3D_RQERRIR0, errval); 575 + 606 576 for (i = 1; i < mtu->num_eps; i++) { 607 577 if (errval & QMU_RX_CS_ERR(i)) 608 578 dev_err(mtu->dev, "Rx %d CS error!\n", i); 609 579 610 580 if (errval & QMU_RX_LEN_ERR(i)) 611 581 dev_err(mtu->dev, "RX %d Length error\n", i); 582 + 583 + if (errval & (QMU_RX_CS_ERR(i) | QMU_RX_LEN_ERR(i))) 584 + qmu_error_rx(mtu, i); 612 585 } 613 - mtu3_writel(mbase, U3D_RQERRIR0, errval); 614 586 } 615 587 616 588 if (qmu_status & RXQ_ZLPERR_INT) {
+1 -1
drivers/usb/musb/Kconfig
··· 113 113 114 114 config USB_MUSB_POLARFIRE_SOC 115 115 tristate "Microchip PolarFire SoC platforms" 116 - depends on SOC_MICROCHIP_POLARFIRE || COMPILE_TEST 116 + depends on ARCH_MICROCHIP_POLARFIRE || COMPILE_TEST 117 117 depends on NOP_USB_XCEIV 118 118 select USB_MUSB_DUAL_ROLE 119 119 help
+2 -4
drivers/usb/musb/da8xx.c
··· 576 576 return ret; 577 577 } 578 578 579 - static int da8xx_remove(struct platform_device *pdev) 579 + static void da8xx_remove(struct platform_device *pdev) 580 580 { 581 581 struct da8xx_glue *glue = platform_get_drvdata(pdev); 582 582 583 583 platform_device_unregister(glue->musb); 584 584 usb_phy_generic_unregister(glue->usb_phy); 585 - 586 - return 0; 587 585 } 588 586 589 587 #ifdef CONFIG_PM_SLEEP ··· 624 626 625 627 static struct platform_driver da8xx_driver = { 626 628 .probe = da8xx_probe, 627 - .remove = da8xx_remove, 629 + .remove_new = da8xx_remove, 628 630 .driver = { 629 631 .name = "musb-da8xx", 630 632 .pm = &da8xx_pm_ops,
+2 -4
drivers/usb/musb/jz4740.c
··· 308 308 return ret; 309 309 } 310 310 311 - static int jz4740_remove(struct platform_device *pdev) 311 + static void jz4740_remove(struct platform_device *pdev) 312 312 { 313 313 struct jz4740_glue *glue = platform_get_drvdata(pdev); 314 314 315 315 platform_device_unregister(glue->pdev); 316 316 clk_disable_unprepare(glue->clk); 317 - 318 - return 0; 319 317 } 320 318 321 319 static const struct of_device_id jz4740_musb_of_match[] = { ··· 325 327 326 328 static struct platform_driver jz4740_driver = { 327 329 .probe = jz4740_probe, 328 - .remove = jz4740_remove, 330 + .remove_new = jz4740_remove, 329 331 .driver = { 330 332 .name = "musb-jz4740", 331 333 .of_match_table = jz4740_musb_of_match,
+2 -4
drivers/usb/musb/mediatek.c
··· 508 508 return ret; 509 509 } 510 510 511 - static int mtk_musb_remove(struct platform_device *pdev) 511 + static void mtk_musb_remove(struct platform_device *pdev) 512 512 { 513 513 struct mtk_glue *glue = platform_get_drvdata(pdev); 514 514 struct platform_device *usb_phy = glue->usb_phy; 515 515 516 516 platform_device_unregister(glue->musb_pdev); 517 517 usb_phy_generic_unregister(usb_phy); 518 - 519 - return 0; 520 518 } 521 519 522 520 #ifdef CONFIG_OF ··· 527 529 528 530 static struct platform_driver mtk_musb_driver = { 529 531 .probe = mtk_musb_probe, 530 - .remove = mtk_musb_remove, 532 + .remove_new = mtk_musb_remove, 531 533 .driver = { 532 534 .name = "musb-mtk", 533 535 .of_match_table = of_match_ptr(mtk_musb_match),
+2 -4
drivers/usb/musb/mpfs.c
··· 235 235 return ret; 236 236 } 237 237 238 - static int mpfs_remove(struct platform_device *pdev) 238 + static void mpfs_remove(struct platform_device *pdev) 239 239 { 240 240 struct mpfs_glue *glue = platform_get_drvdata(pdev); 241 241 242 242 clk_disable_unprepare(glue->clk); 243 243 platform_device_unregister(glue->musb); 244 244 usb_phy_generic_unregister(pdev); 245 - 246 - return 0; 247 245 } 248 246 249 247 #ifdef CONFIG_OF ··· 254 256 255 257 static struct platform_driver mpfs_musb_driver = { 256 258 .probe = mpfs_probe, 257 - .remove = mpfs_remove, 259 + .remove_new = mpfs_remove, 258 260 .driver = { 259 261 .name = "mpfs-musb", 260 262 .of_match_table = of_match_ptr(mpfs_id_table)
+2 -3
drivers/usb/musb/musb_core.c
··· 2621 2621 return musb_init_controller(dev, irq, base); 2622 2622 } 2623 2623 2624 - static int musb_remove(struct platform_device *pdev) 2624 + static void musb_remove(struct platform_device *pdev) 2625 2625 { 2626 2626 struct device *dev = &pdev->dev; 2627 2627 struct musb *musb = dev_to_musb(dev); ··· 2657 2657 usb_phy_shutdown(musb->xceiv); 2658 2658 musb_free(musb); 2659 2659 device_init_wakeup(dev, 0); 2660 - return 0; 2661 2660 } 2662 2661 2663 2662 #ifdef CONFIG_PM ··· 2954 2955 .dev_groups = musb_groups, 2955 2956 }, 2956 2957 .probe = musb_probe, 2957 - .remove = musb_remove, 2958 + .remove_new = musb_remove, 2958 2959 }; 2959 2960 2960 2961 module_platform_driver(musb_driver);
+2 -4
drivers/usb/musb/musb_dsps.c
··· 915 915 return ret; 916 916 } 917 917 918 - static int dsps_remove(struct platform_device *pdev) 918 + static void dsps_remove(struct platform_device *pdev) 919 919 { 920 920 struct dsps_glue *glue = platform_get_drvdata(pdev); 921 921 ··· 923 923 924 924 pm_runtime_disable(&pdev->dev); 925 925 iounmap(glue->usbss_base); 926 - 927 - return 0; 928 926 } 929 927 930 928 static const struct dsps_musb_wrapper am33xx_driver_data = { ··· 1034 1036 1035 1037 static struct platform_driver dsps_usbss_driver = { 1036 1038 .probe = dsps_probe, 1037 - .remove = dsps_remove, 1039 + .remove_new = dsps_remove, 1038 1040 .driver = { 1039 1041 .name = "musb-dsps", 1040 1042 .pm = &dsps_pm_ops,
+3 -5
drivers/usb/musb/omap2430.c
··· 334 334 * Legacy SoCs using omap_device get confused if node is moved 335 335 * because of interconnect properties mixed into the node. 336 336 */ 337 - if (of_get_property(np, "ti,hwmods", NULL)) { 337 + if (of_property_present(np, "ti,hwmods")) { 338 338 dev_warn(&pdev->dev, "please update to probe with ti-sysc\n"); 339 339 populate_irqs = true; 340 340 } else { ··· 471 471 return ret; 472 472 } 473 473 474 - static int omap2430_remove(struct platform_device *pdev) 474 + static void omap2430_remove(struct platform_device *pdev) 475 475 { 476 476 struct omap2430_glue *glue = platform_get_drvdata(pdev); 477 477 478 478 platform_device_unregister(glue->musb); 479 479 pm_runtime_disable(glue->dev); 480 - 481 - return 0; 482 480 } 483 481 484 482 #ifdef CONFIG_PM ··· 608 610 609 611 static struct platform_driver omap2430_driver = { 610 612 .probe = omap2430_probe, 611 - .remove = omap2430_remove, 613 + .remove_new = omap2430_remove, 612 614 .driver = { 613 615 .name = "musb-omap2430", 614 616 .pm = DEV_PM_OPS,
+2 -4
drivers/usb/musb/sunxi.c
··· 805 805 return ret; 806 806 } 807 807 808 - static int sunxi_musb_remove(struct platform_device *pdev) 808 + static void sunxi_musb_remove(struct platform_device *pdev) 809 809 { 810 810 struct sunxi_glue *glue = platform_get_drvdata(pdev); 811 811 struct platform_device *usb_phy = glue->usb_phy; 812 812 813 813 platform_device_unregister(glue->musb_pdev); 814 814 usb_phy_generic_unregister(usb_phy); 815 - 816 - return 0; 817 815 } 818 816 819 817 static const struct sunxi_musb_cfg sun4i_a10_musb_cfg = { ··· 860 862 861 863 static struct platform_driver sunxi_musb_driver = { 862 864 .probe = sunxi_musb_probe, 863 - .remove = sunxi_musb_remove, 865 + .remove_new = sunxi_musb_remove, 864 866 .driver = { 865 867 .name = "musb-sunxi", 866 868 .of_match_table = sunxi_musb_match,
+2 -4
drivers/usb/musb/tusb6010.c
··· 1258 1258 return 0; 1259 1259 } 1260 1260 1261 - static int tusb_remove(struct platform_device *pdev) 1261 + static void tusb_remove(struct platform_device *pdev) 1262 1262 { 1263 1263 struct tusb6010_glue *glue = platform_get_drvdata(pdev); 1264 1264 1265 1265 platform_device_unregister(glue->musb); 1266 1266 usb_phy_generic_unregister(glue->phy); 1267 - 1268 - return 0; 1269 1267 } 1270 1268 1271 1269 static struct platform_driver tusb_driver = { 1272 1270 .probe = tusb_probe, 1273 - .remove = tusb_remove, 1271 + .remove_new = tusb_remove, 1274 1272 .driver = { 1275 1273 .name = "musb-tusb", 1276 1274 },
+2 -4
drivers/usb/musb/ux500.c
··· 303 303 return ret; 304 304 } 305 305 306 - static int ux500_remove(struct platform_device *pdev) 306 + static void ux500_remove(struct platform_device *pdev) 307 307 { 308 308 struct ux500_glue *glue = platform_get_drvdata(pdev); 309 309 310 310 platform_device_unregister(glue->musb); 311 311 clk_disable_unprepare(glue->clk); 312 - 313 - return 0; 314 312 } 315 313 316 314 #ifdef CONFIG_PM_SLEEP ··· 355 357 356 358 static struct platform_driver ux500_driver = { 357 359 .probe = ux500_probe, 358 - .remove = ux500_remove, 360 + .remove_new = ux500_remove, 359 361 .driver = { 360 362 .name = "musb-ux500", 361 363 .pm = &ux500_pm_ops,
+2 -4
drivers/usb/phy/phy-ab8500-usb.c
··· 965 965 return 0; 966 966 } 967 967 968 - static int ab8500_usb_remove(struct platform_device *pdev) 968 + static void ab8500_usb_remove(struct platform_device *pdev) 969 969 { 970 970 struct ab8500_usb *ab = platform_get_drvdata(pdev); 971 971 ··· 977 977 ab8500_usb_host_phy_dis(ab); 978 978 else if (ab->mode == USB_PERIPHERAL) 979 979 ab8500_usb_peri_phy_dis(ab); 980 - 981 - return 0; 982 980 } 983 981 984 982 static const struct platform_device_id ab8500_usb_devtype[] = { ··· 987 989 988 990 static struct platform_driver ab8500_usb_driver = { 989 991 .probe = ab8500_usb_probe, 990 - .remove = ab8500_usb_remove, 992 + .remove_new = ab8500_usb_remove, 991 993 .id_table = ab8500_usb_devtype, 992 994 .driver = { 993 995 .name = "abx5x0-usb",
+2 -3
drivers/usb/phy/phy-am335x.c
··· 82 82 return usb_add_phy_dev(&am_phy->usb_phy_gen.phy); 83 83 } 84 84 85 - static int am335x_phy_remove(struct platform_device *pdev) 85 + static void am335x_phy_remove(struct platform_device *pdev) 86 86 { 87 87 struct am335x_phy *am_phy = platform_get_drvdata(pdev); 88 88 89 89 usb_remove_phy(&am_phy->usb_phy_gen.phy); 90 - return 0; 91 90 } 92 91 93 92 #ifdef CONFIG_PM_SLEEP ··· 133 134 134 135 static struct platform_driver am335x_phy_driver = { 135 136 .probe = am335x_phy_probe, 136 - .remove = am335x_phy_remove, 137 + .remove_new = am335x_phy_remove, 137 138 .driver = { 138 139 .name = "am335x-phy-driver", 139 140 .pm = &am335x_pm_ops,
+2 -4
drivers/usb/phy/phy-fsl-usb.c
··· 983 983 return ret; 984 984 } 985 985 986 - static int fsl_otg_remove(struct platform_device *pdev) 986 + static void fsl_otg_remove(struct platform_device *pdev) 987 987 { 988 988 struct fsl_usb2_platform_data *pdata = dev_get_platdata(&pdev->dev); 989 989 ··· 998 998 999 999 if (pdata->exit) 1000 1000 pdata->exit(pdev); 1001 - 1002 - return 0; 1003 1001 } 1004 1002 1005 1003 struct platform_driver fsl_otg_driver = { 1006 1004 .probe = fsl_otg_probe, 1007 - .remove = fsl_otg_remove, 1005 + .remove_new = fsl_otg_remove, 1008 1006 .driver = { 1009 1007 .name = driver_name, 1010 1008 .owner = THIS_MODULE,
+2 -4
drivers/usb/phy/phy-generic.c
··· 330 330 return 0; 331 331 } 332 332 333 - static int usb_phy_generic_remove(struct platform_device *pdev) 333 + static void usb_phy_generic_remove(struct platform_device *pdev) 334 334 { 335 335 struct usb_phy_generic *nop = platform_get_drvdata(pdev); 336 336 337 337 usb_remove_phy(&nop->phy); 338 - 339 - return 0; 340 338 } 341 339 342 340 static const struct of_device_id nop_xceiv_dt_ids[] = { ··· 346 348 347 349 static struct platform_driver usb_phy_generic_driver = { 348 350 .probe = usb_phy_generic_probe, 349 - .remove = usb_phy_generic_remove, 351 + .remove_new = usb_phy_generic_remove, 350 352 .driver = { 351 353 .name = "usb_phy_generic", 352 354 .of_match_table = nop_xceiv_dt_ids,
+2 -4
drivers/usb/phy/phy-gpio-vbus-usb.c
··· 325 325 return 0; 326 326 } 327 327 328 - static int gpio_vbus_remove(struct platform_device *pdev) 328 + static void gpio_vbus_remove(struct platform_device *pdev) 329 329 { 330 330 struct gpio_vbus_data *gpio_vbus = platform_get_drvdata(pdev); 331 331 ··· 333 333 cancel_delayed_work_sync(&gpio_vbus->work); 334 334 335 335 usb_remove_phy(&gpio_vbus->phy); 336 - 337 - return 0; 338 336 } 339 337 340 338 #ifdef CONFIG_PM ··· 384 386 .of_match_table = gpio_vbus_of_match, 385 387 }, 386 388 .probe = gpio_vbus_probe, 387 - .remove = gpio_vbus_remove, 389 + .remove_new = gpio_vbus_remove, 388 390 }; 389 391 390 392 module_platform_driver(gpio_vbus_driver);
+2 -4
drivers/usb/phy/phy-keystone.c
··· 88 88 return usb_add_phy_dev(&k_phy->usb_phy_gen.phy); 89 89 } 90 90 91 - static int keystone_usbphy_remove(struct platform_device *pdev) 91 + static void keystone_usbphy_remove(struct platform_device *pdev) 92 92 { 93 93 struct keystone_usbphy *k_phy = platform_get_drvdata(pdev); 94 94 95 95 usb_remove_phy(&k_phy->usb_phy_gen.phy); 96 - 97 - return 0; 98 96 } 99 97 100 98 static const struct of_device_id keystone_usbphy_ids[] = { ··· 103 105 104 106 static struct platform_driver keystone_usbphy_driver = { 105 107 .probe = keystone_usbphy_probe, 106 - .remove = keystone_usbphy_remove, 108 + .remove_new = keystone_usbphy_remove, 107 109 .driver = { 108 110 .name = "keystone-usbphy", 109 111 .of_match_table = keystone_usbphy_ids,
+2 -4
drivers/usb/phy/phy-mv-usb.c
··· 644 644 NULL, 645 645 }; 646 646 647 - static int mv_otg_remove(struct platform_device *pdev) 647 + static void mv_otg_remove(struct platform_device *pdev) 648 648 { 649 649 struct mv_otg *mvotg = platform_get_drvdata(pdev); 650 650 ··· 654 654 mv_otg_disable(mvotg); 655 655 656 656 usb_remove_phy(&mvotg->phy); 657 - 658 - return 0; 659 657 } 660 658 661 659 static int mv_otg_probe(struct platform_device *pdev) ··· 867 869 868 870 static struct platform_driver mv_otg_driver = { 869 871 .probe = mv_otg_probe, 870 - .remove = mv_otg_remove, 872 + .remove_new = mv_otg_remove, 871 873 .driver = { 872 874 .name = driver_name, 873 875 .dev_groups = mv_otg_groups,
+3 -5
drivers/usb/phy/phy-mxs-usb.c
··· 733 733 return -ENOMEM; 734 734 735 735 /* Some SoCs don't have anatop registers */ 736 - if (of_get_property(np, "fsl,anatop", NULL)) { 736 + if (of_property_present(np, "fsl,anatop")) { 737 737 mxs_phy->regmap_anatop = syscon_regmap_lookup_by_phandle 738 738 (np, "fsl,anatop"); 739 739 if (IS_ERR(mxs_phy->regmap_anatop)) { ··· 801 801 return usb_add_phy_dev(&mxs_phy->phy); 802 802 } 803 803 804 - static int mxs_phy_remove(struct platform_device *pdev) 804 + static void mxs_phy_remove(struct platform_device *pdev) 805 805 { 806 806 struct mxs_phy *mxs_phy = platform_get_drvdata(pdev); 807 807 808 808 usb_remove_phy(&mxs_phy->phy); 809 - 810 - return 0; 811 809 } 812 810 813 811 #ifdef CONFIG_PM_SLEEP ··· 851 853 852 854 static struct platform_driver mxs_phy_driver = { 853 855 .probe = mxs_phy_probe, 854 - .remove = mxs_phy_remove, 856 + .remove_new = mxs_phy_remove, 855 857 .driver = { 856 858 .name = DRIVER_NAME, 857 859 .of_match_table = mxs_phy_dt_ids,
+2 -4
drivers/usb/phy/phy-tahvo.c
··· 412 412 return ret; 413 413 } 414 414 415 - static int tahvo_usb_remove(struct platform_device *pdev) 415 + static void tahvo_usb_remove(struct platform_device *pdev) 416 416 { 417 417 struct tahvo_usb *tu = platform_get_drvdata(pdev); 418 418 ··· 420 420 usb_remove_phy(&tu->phy); 421 421 if (!IS_ERR(tu->ick)) 422 422 clk_disable(tu->ick); 423 - 424 - return 0; 425 423 } 426 424 427 425 static struct platform_driver tahvo_usb_driver = { 428 426 .probe = tahvo_usb_probe, 429 - .remove = tahvo_usb_remove, 427 + .remove_new = tahvo_usb_remove, 430 428 .driver = { 431 429 .name = "tahvo-usb", 432 430 .dev_groups = tahvo_groups,
+3 -5
drivers/usb/phy/phy-tegra-usb.c
··· 1375 1375 tegra_phy->is_legacy_phy = 1376 1376 of_property_read_bool(np, "nvidia,has-legacy-mode"); 1377 1377 1378 - if (of_find_property(np, "dr_mode", NULL)) 1378 + if (of_property_present(np, "dr_mode")) 1379 1379 tegra_phy->mode = usb_get_dr_mode(&pdev->dev); 1380 1380 else 1381 1381 tegra_phy->mode = USB_DR_MODE_HOST; ··· 1486 1486 return usb_add_phy_dev(&tegra_phy->u_phy); 1487 1487 } 1488 1488 1489 - static int tegra_usb_phy_remove(struct platform_device *pdev) 1489 + static void tegra_usb_phy_remove(struct platform_device *pdev) 1490 1490 { 1491 1491 struct tegra_usb_phy *tegra_phy = platform_get_drvdata(pdev); 1492 1492 1493 1493 usb_remove_phy(&tegra_phy->u_phy); 1494 - 1495 - return 0; 1496 1494 } 1497 1495 1498 1496 static struct platform_driver tegra_usb_phy_driver = { 1499 1497 .probe = tegra_usb_phy_probe, 1500 - .remove = tegra_usb_phy_remove, 1498 + .remove_new = tegra_usb_phy_remove, 1501 1499 .driver = { 1502 1500 .name = "tegra-phy", 1503 1501 .of_match_table = tegra_usb_phy_id_table,
+2 -4
drivers/usb/phy/phy-twl6030-usb.c
··· 409 409 return status; 410 410 } 411 411 412 - static int twl6030_usb_remove(struct platform_device *pdev) 412 + static void twl6030_usb_remove(struct platform_device *pdev) 413 413 { 414 414 struct twl6030_usb *twl = platform_get_drvdata(pdev); 415 415 ··· 422 422 free_irq(twl->irq2, twl); 423 423 regulator_put(twl->usb3v3); 424 424 cancel_work_sync(&twl->set_vbus_work); 425 - 426 - return 0; 427 425 } 428 426 429 427 static const struct of_device_id twl6030_usb_id_table[] = { ··· 432 434 433 435 static struct platform_driver twl6030_usb_driver = { 434 436 .probe = twl6030_usb_probe, 435 - .remove = twl6030_usb_remove, 437 + .remove_new = twl6030_usb_remove, 436 438 .driver = { 437 439 .name = "twl6030_usb", 438 440 .of_match_table = of_match_ptr(twl6030_usb_id_table),
+1 -1
drivers/usb/renesas_usbhs/common.c
··· 823 823 .driver = { 824 824 .name = "renesas_usbhs", 825 825 .pm = &usbhsc_pm_ops, 826 - .of_match_table = of_match_ptr(usbhs_of_match), 826 + .of_match_table = usbhs_of_match, 827 827 }, 828 828 .probe = usbhs_probe, 829 829 .remove = usbhs_remove,
+6
drivers/usb/serial/option.c
··· 595 595 #define SIERRA_VENDOR_ID 0x1199 596 596 #define SIERRA_PRODUCT_EM9191 0x90d3 597 597 598 + /* UNISOC (Spreadtrum) products */ 599 + #define UNISOC_VENDOR_ID 0x1782 600 + /* TOZED LT70-C based on UNISOC SL8563 uses UNISOC's vendor ID */ 601 + #define TOZED_PRODUCT_LT70C 0x4055 602 + 598 603 /* Device flags */ 599 604 600 605 /* Highest interface number which can be used with NCTRL() and RSVD() */ ··· 2230 2225 { USB_DEVICE_AND_INTERFACE_INFO(OPPO_VENDOR_ID, OPPO_PRODUCT_R11, 0xff, 0xff, 0x30) }, 2231 2226 { USB_DEVICE_AND_INTERFACE_INFO(SIERRA_VENDOR_ID, SIERRA_PRODUCT_EM9191, 0xff, 0xff, 0x30) }, 2232 2227 { USB_DEVICE_AND_INTERFACE_INFO(SIERRA_VENDOR_ID, SIERRA_PRODUCT_EM9191, 0xff, 0, 0) }, 2228 + { USB_DEVICE_AND_INTERFACE_INFO(UNISOC_VENDOR_ID, TOZED_PRODUCT_LT70C, 0xff, 0, 0) }, 2233 2229 { } /* Terminating entry */ 2234 2230 }; 2235 2231 MODULE_DEVICE_TABLE(usb, option_ids);
-8
drivers/usb/serial/quatech2.c
··· 176 176 NULL, 0, QT2_USB_TIMEOUT); 177 177 } 178 178 179 - static inline int qt2_setdevice(struct usb_device *dev, u8 *data) 180 - { 181 - u16 x = ((u16) (data[1] << 8) | (u16) (data[0])); 182 - 183 - return qt2_control_msg(dev, QT_SET_GET_DEVICE, x, 0); 184 - } 185 - 186 - 187 179 static inline int qt2_getregister(struct usb_device *dev, 188 180 u8 uart, 189 181 u8 reg,
+1 -1
drivers/usb/typec/hd3ss3220.c
··· 290 290 static struct i2c_driver hd3ss3220_driver = { 291 291 .driver = { 292 292 .name = "hd3ss3220", 293 - .of_match_table = of_match_ptr(dev_ids), 293 + .of_match_table = dev_ids, 294 294 }, 295 295 .probe_new = hd3ss3220_probe, 296 296 .remove = hd3ss3220_remove,
+2 -2
drivers/usb/typec/tcpm/fusb302.c
··· 190 190 191 191 static int fusb302_debug_show(struct seq_file *s, void *v) 192 192 { 193 - struct fusb302_chip *chip = (struct fusb302_chip *)s->private; 193 + struct fusb302_chip *chip = s->private; 194 194 int tail; 195 195 196 196 mutex_lock(&chip->logbuffer_lock); ··· 1813 1813 return 0; 1814 1814 } 1815 1815 1816 - static const struct of_device_id fusb302_dt_match[] = { 1816 + static const struct of_device_id fusb302_dt_match[] __maybe_unused = { 1817 1817 {.compatible = "fcs,fusb302"}, 1818 1818 {}, 1819 1819 };
-6
drivers/usb/typec/tcpm/tcpci_mt6360.c
··· 43 43 int irq; 44 44 }; 45 45 46 - static inline int mt6360_tcpc_read16(struct regmap *regmap, 47 - unsigned int reg, u16 *val) 48 - { 49 - return regmap_raw_read(regmap, reg, val, sizeof(u16)); 50 - } 51 - 52 46 static inline int mt6360_tcpc_write16(struct regmap *regmap, 53 47 unsigned int reg, u16 val) 54 48 {
+18 -2
drivers/usb/typec/tcpm/tcpm.c
··· 737 737 738 738 static int tcpm_debug_show(struct seq_file *s, void *v) 739 739 { 740 - struct tcpm_port *port = (struct tcpm_port *)s->private; 740 + struct tcpm_port *port = s->private; 741 741 int tail; 742 742 743 743 mutex_lock(&port->logbuffer_lock); ··· 1523 1523 pmdata->svids[pmdata->nsvids++] = svid; 1524 1524 tcpm_log(port, "SVID %d: 0x%x", pmdata->nsvids, svid); 1525 1525 } 1526 - return true; 1526 + 1527 + /* 1528 + * PD3.0 Spec 6.4.4.3.2: The SVIDs are returned 2 per VDO (see Table 1529 + * 6-43), and can be returned maximum 6 VDOs per response (see Figure 1530 + * 6-19). If the Respondersupports 12 or more SVID then the Discover 1531 + * SVIDs Command Shall be executed multiple times until a Discover 1532 + * SVIDs VDO is returned ending either with a SVID value of 0x0000 in 1533 + * the last part of the last VDO or with a VDO containing two SVIDs 1534 + * with values of 0x0000. 1535 + * 1536 + * However, some odd dockers support SVIDs less than 12 but without 1537 + * 0x0000 in the last VDO, so we need to break the Discover SVIDs 1538 + * request and return false here. 1539 + */ 1540 + return cnt == 7; 1527 1541 abort: 1528 1542 tcpm_log(port, "SVID_DISCOVERY_MAX(%d) too low!", SVID_DISCOVERY_MAX); 1529 1543 return false; ··· 6591 6577 port->port_type = port->typec_caps.type; 6592 6578 6593 6579 port->role_sw = usb_role_switch_get(port->dev); 6580 + if (!port->role_sw) 6581 + port->role_sw = fwnode_usb_role_switch_get(tcpc->fwnode); 6594 6582 if (IS_ERR(port->role_sw)) { 6595 6583 err = PTR_ERR(port->role_sw); 6596 6584 goto out_destroy_wq;
+36 -15
drivers/usb/typec/tipd/core.c
··· 16 16 #include <linux/usb/typec.h> 17 17 #include <linux/usb/typec_altmode.h> 18 18 #include <linux/usb/role.h> 19 + #include <linux/workqueue.h> 19 20 20 21 #include "tps6598x.h" 21 22 #include "trace.h" ··· 98 97 99 98 int wakeup; 100 99 u16 pwr_status; 100 + struct delayed_work wq_poll; 101 + irq_handler_t irq_handler; 101 102 }; 102 103 103 104 static enum power_supply_property tps6598x_psy_props[] = { ··· 178 175 static inline int tps6598x_read64(struct tps6598x *tps, u8 reg, u64 *val) 179 176 { 180 177 return tps6598x_block_read(tps, reg, val, sizeof(u64)); 181 - } 182 - 183 - static inline int tps6598x_write16(struct tps6598x *tps, u8 reg, u16 val) 184 - { 185 - return tps6598x_block_write(tps, reg, &val, sizeof(u16)); 186 - } 187 - 188 - static inline int tps6598x_write32(struct tps6598x *tps, u8 reg, u32 val) 189 - { 190 - return tps6598x_block_write(tps, reg, &val, sizeof(u32)); 191 178 } 192 179 193 180 static inline int tps6598x_write64(struct tps6598x *tps, u8 reg, u64 val) ··· 561 568 return IRQ_NONE; 562 569 } 563 570 571 + /* Time interval for Polling */ 572 + #define POLL_INTERVAL 500 /* msecs */ 573 + static void tps6598x_poll_work(struct work_struct *work) 574 + { 575 + struct tps6598x *tps = container_of(to_delayed_work(work), 576 + struct tps6598x, wq_poll); 577 + 578 + tps->irq_handler(0, tps); 579 + queue_delayed_work(system_power_efficient_wq, 580 + &tps->wq_poll, msecs_to_jiffies(POLL_INTERVAL)); 581 + } 582 + 564 583 static int tps6598x_check_mode(struct tps6598x *tps) 565 584 { 566 585 char mode[5] = { }; ··· 751 746 TPS_REG_INT_PLUG_EVENT; 752 747 } 753 748 749 + tps->irq_handler = irq_handler; 754 750 /* Make sure the controller has application firmware running */ 755 751 ret = tps6598x_check_mode(tps); 756 752 if (ret) ··· 843 837 dev_err(&client->dev, "failed to register partner\n"); 844 838 } 845 839 846 - ret = devm_request_threaded_irq(&client->dev, client->irq, NULL, 847 - irq_handler, 848 - IRQF_SHARED | IRQF_ONESHOT, 849 - dev_name(&client->dev), tps); 840 + if (client->irq) { 841 + ret = devm_request_threaded_irq(&client->dev, client->irq, NULL, 842 + irq_handler, 843 + IRQF_SHARED | IRQF_ONESHOT, 844 + dev_name(&client->dev), tps); 845 + } else { 846 + dev_warn(tps->dev, "Unable to find the interrupt, switching to polling\n"); 847 + INIT_DELAYED_WORK(&tps->wq_poll, tps6598x_poll_work); 848 + queue_delayed_work(system_power_efficient_wq, &tps->wq_poll, 849 + msecs_to_jiffies(POLL_INTERVAL)); 850 + } 851 + 850 852 if (ret) 851 853 goto err_disconnect; 852 854 ··· 862 848 fwnode_handle_put(fwnode); 863 849 864 850 tps->wakeup = device_property_read_bool(tps->dev, "wakeup-source"); 865 - if (tps->wakeup) { 851 + if (tps->wakeup && client->irq) { 866 852 device_init_wakeup(&client->dev, true); 867 853 enable_irq_wake(client->irq); 868 854 } ··· 901 887 enable_irq_wake(client->irq); 902 888 } 903 889 890 + if (!client->irq) 891 + cancel_delayed_work_sync(&tps->wq_poll); 892 + 904 893 return 0; 905 894 } 906 895 ··· 916 899 disable_irq_wake(client->irq); 917 900 enable_irq(client->irq); 918 901 } 902 + 903 + if (client->irq) 904 + queue_delayed_work(system_power_efficient_wq, &tps->wq_poll, 905 + msecs_to_jiffies(POLL_INTERVAL)); 919 906 920 907 return 0; 921 908 }
+10
drivers/usb/typec/ucsi/Kconfig
··· 58 58 To compile the driver as a module, choose M here: the module will be 59 59 called ucsi_stm32g0. 60 60 61 + config UCSI_PMIC_GLINK 62 + tristate "UCSI Qualcomm PMIC GLINK Interface Driver" 63 + depends on QCOM_PMIC_GLINK 64 + help 65 + This driver enables UCSI support on platforms that expose UCSI 66 + interface as PMIC GLINK device. 67 + 68 + To compile the driver as a module, choose M here: the module will be 69 + called ucsi_glink. 70 + 61 71 endif
+1
drivers/usb/typec/ucsi/Makefile
··· 18 18 obj-$(CONFIG_UCSI_ACPI) += ucsi_acpi.o 19 19 obj-$(CONFIG_UCSI_CCG) += ucsi_ccg.o 20 20 obj-$(CONFIG_UCSI_STM32G0) += ucsi_stm32g0.o 21 + obj-$(CONFIG_UCSI_PMIC_GLINK) += ucsi_glink.o
+4 -2
drivers/usb/typec/ucsi/ucsi.c
··· 1444 1444 1445 1445 ret = ucsi_init(ucsi); 1446 1446 if (ret) 1447 - dev_err(ucsi->dev, "PPM init failed (%d)\n", ret); 1447 + dev_err_probe(ucsi->dev, ret, "PPM init failed\n"); 1448 1448 1449 1449 if (ret == -EPROBE_DEFER) { 1450 - if (ucsi->work_count++ > UCSI_ROLE_SWITCH_WAIT_COUNT) 1450 + if (ucsi->work_count++ > UCSI_ROLE_SWITCH_WAIT_COUNT) { 1451 + dev_err(ucsi->dev, "PPM init failed, stop trying\n"); 1451 1452 return; 1453 + } 1452 1454 1453 1455 queue_delayed_work(system_long_wq, &ucsi->work, 1454 1456 UCSI_ROLE_SWITCH_INTERVAL);
+42 -2
drivers/usb/typec/ucsi/ucsi_acpi.c
··· 9 9 #include <linux/platform_device.h> 10 10 #include <linux/module.h> 11 11 #include <linux/acpi.h> 12 + #include <linux/dmi.h> 12 13 13 14 #include "ucsi.h" 14 15 ··· 24 23 struct completion complete; 25 24 unsigned long flags; 26 25 guid_t guid; 26 + u64 cmd; 27 27 }; 28 28 29 29 static int ucsi_acpi_dsm(struct ucsi_acpi *ua, int func) ··· 64 62 struct ucsi_acpi *ua = ucsi_get_drvdata(ucsi); 65 63 66 64 memcpy(ua->base + offset, val, val_len); 65 + ua->cmd = *(u64 *)val; 67 66 68 67 return ucsi_acpi_dsm(ua, UCSI_DSM_FUNC_WRITE); 69 68 } ··· 96 93 .async_write = ucsi_acpi_async_write 97 94 }; 98 95 96 + static int 97 + ucsi_zenbook_read(struct ucsi *ucsi, unsigned int offset, void *val, size_t val_len) 98 + { 99 + struct ucsi_acpi *ua = ucsi_get_drvdata(ucsi); 100 + int ret; 101 + 102 + if (offset == UCSI_VERSION || UCSI_COMMAND(ua->cmd) == UCSI_PPM_RESET) { 103 + ret = ucsi_acpi_dsm(ua, UCSI_DSM_FUNC_READ); 104 + if (ret) 105 + return ret; 106 + } 107 + 108 + memcpy(val, ua->base + offset, val_len); 109 + 110 + return 0; 111 + } 112 + 113 + static const struct ucsi_operations ucsi_zenbook_ops = { 114 + .read = ucsi_zenbook_read, 115 + .sync_write = ucsi_acpi_sync_write, 116 + .async_write = ucsi_acpi_async_write 117 + }; 118 + 119 + static const struct dmi_system_id zenbook_dmi_id[] = { 120 + { 121 + .matches = { 122 + DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), 123 + DMI_MATCH(DMI_PRODUCT_NAME, "ZenBook UX325UA_UM325UA"), 124 + }, 125 + }, 126 + { } 127 + }; 128 + 99 129 static void ucsi_acpi_notify(acpi_handle handle, u32 event, void *data) 100 130 { 101 131 struct ucsi_acpi *ua = data; 102 132 u32 cci; 103 133 int ret; 104 134 105 - ret = ucsi_acpi_read(ua->ucsi, UCSI_CCI, &cci, sizeof(cci)); 135 + ret = ua->ucsi->ops->read(ua->ucsi, UCSI_CCI, &cci, sizeof(cci)); 106 136 if (ret) 107 137 return; 108 138 ··· 150 114 static int ucsi_acpi_probe(struct platform_device *pdev) 151 115 { 152 116 struct acpi_device *adev = ACPI_COMPANION(&pdev->dev); 117 + const struct ucsi_operations *ops = &ucsi_acpi_ops; 153 118 struct ucsi_acpi *ua; 154 119 struct resource *res; 155 120 acpi_status status; ··· 180 143 init_completion(&ua->complete); 181 144 ua->dev = &pdev->dev; 182 145 183 - ua->ucsi = ucsi_create(&pdev->dev, &ucsi_acpi_ops); 146 + if (dmi_check_system(zenbook_dmi_id)) 147 + ops = &ucsi_zenbook_ops; 148 + 149 + ua->ucsi = ucsi_create(&pdev->dev, ops); 184 150 if (IS_ERR(ua->ucsi)) 185 151 return PTR_ERR(ua->ucsi); 186 152
+345
drivers/usb/typec/ucsi/ucsi_glink.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-only 2 + /* 3 + * Copyright (c) 2019-2020, The Linux Foundation. All rights reserved. 4 + * Copyright (c) 2023, Linaro Ltd 5 + */ 6 + #include <linux/auxiliary_bus.h> 7 + #include <linux/module.h> 8 + #include <linux/of_device.h> 9 + #include <linux/mutex.h> 10 + #include <linux/property.h> 11 + #include <linux/soc/qcom/pdr.h> 12 + #include <linux/soc/qcom/pmic_glink.h> 13 + #include "ucsi.h" 14 + 15 + #define UCSI_BUF_SIZE 48 16 + 17 + #define MSG_TYPE_REQ_RESP 1 18 + #define UCSI_BUF_SIZE 48 19 + 20 + #define UC_NOTIFY_RECEIVER_UCSI 0x0 21 + #define UC_UCSI_READ_BUF_REQ 0x11 22 + #define UC_UCSI_WRITE_BUF_REQ 0x12 23 + #define UC_UCSI_USBC_NOTIFY_IND 0x13 24 + 25 + struct ucsi_read_buf_req_msg { 26 + struct pmic_glink_hdr hdr; 27 + }; 28 + 29 + struct ucsi_read_buf_resp_msg { 30 + struct pmic_glink_hdr hdr; 31 + u8 buf[UCSI_BUF_SIZE]; 32 + u32 ret_code; 33 + }; 34 + 35 + struct ucsi_write_buf_req_msg { 36 + struct pmic_glink_hdr hdr; 37 + u8 buf[UCSI_BUF_SIZE]; 38 + u32 reserved; 39 + }; 40 + 41 + struct ucsi_write_buf_resp_msg { 42 + struct pmic_glink_hdr hdr; 43 + u32 ret_code; 44 + }; 45 + 46 + struct ucsi_notify_ind_msg { 47 + struct pmic_glink_hdr hdr; 48 + u32 notification; 49 + u32 receiver; 50 + u32 reserved; 51 + }; 52 + 53 + struct pmic_glink_ucsi { 54 + struct device *dev; 55 + 56 + struct pmic_glink_client *client; 57 + 58 + struct ucsi *ucsi; 59 + struct completion read_ack; 60 + struct completion write_ack; 61 + struct completion sync_ack; 62 + bool sync_pending; 63 + struct mutex lock; /* protects concurrent access to PMIC Glink interface */ 64 + 65 + int sync_val; 66 + 67 + struct work_struct notify_work; 68 + struct work_struct register_work; 69 + 70 + u8 read_buf[UCSI_BUF_SIZE]; 71 + }; 72 + 73 + static int pmic_glink_ucsi_read(struct ucsi *__ucsi, unsigned int offset, 74 + void *val, size_t val_len) 75 + { 76 + struct pmic_glink_ucsi *ucsi = ucsi_get_drvdata(__ucsi); 77 + struct ucsi_read_buf_req_msg req = {}; 78 + unsigned long left; 79 + int ret; 80 + 81 + req.hdr.owner = PMIC_GLINK_OWNER_USBC; 82 + req.hdr.type = MSG_TYPE_REQ_RESP; 83 + req.hdr.opcode = UC_UCSI_READ_BUF_REQ; 84 + 85 + mutex_lock(&ucsi->lock); 86 + memset(ucsi->read_buf, 0, sizeof(ucsi->read_buf)); 87 + reinit_completion(&ucsi->read_ack); 88 + 89 + ret = pmic_glink_send(ucsi->client, &req, sizeof(req)); 90 + if (ret < 0) { 91 + dev_err(ucsi->dev, "failed to send UCSI read request: %d\n", ret); 92 + goto out_unlock; 93 + } 94 + 95 + left = wait_for_completion_timeout(&ucsi->read_ack, 5 * HZ); 96 + if (!left) { 97 + dev_err(ucsi->dev, "timeout waiting for UCSI read response\n"); 98 + ret = -ETIMEDOUT; 99 + goto out_unlock; 100 + } 101 + 102 + memcpy(val, &ucsi->read_buf[offset], val_len); 103 + ret = 0; 104 + 105 + out_unlock: 106 + mutex_unlock(&ucsi->lock); 107 + 108 + return ret; 109 + } 110 + 111 + static int pmic_glink_ucsi_locked_write(struct pmic_glink_ucsi *ucsi, unsigned int offset, 112 + const void *val, size_t val_len) 113 + { 114 + struct ucsi_write_buf_req_msg req = {}; 115 + unsigned long left; 116 + int ret; 117 + 118 + req.hdr.owner = PMIC_GLINK_OWNER_USBC; 119 + req.hdr.type = MSG_TYPE_REQ_RESP; 120 + req.hdr.opcode = UC_UCSI_WRITE_BUF_REQ; 121 + memcpy(&req.buf[offset], val, val_len); 122 + 123 + reinit_completion(&ucsi->write_ack); 124 + 125 + ret = pmic_glink_send(ucsi->client, &req, sizeof(req)); 126 + if (ret < 0) { 127 + dev_err(ucsi->dev, "failed to send UCSI write request: %d\n", ret); 128 + return ret; 129 + } 130 + 131 + left = wait_for_completion_timeout(&ucsi->write_ack, 5 * HZ); 132 + if (!left) { 133 + dev_err(ucsi->dev, "timeout waiting for UCSI write response\n"); 134 + return -ETIMEDOUT; 135 + } 136 + 137 + return 0; 138 + } 139 + 140 + static int pmic_glink_ucsi_async_write(struct ucsi *__ucsi, unsigned int offset, 141 + const void *val, size_t val_len) 142 + { 143 + struct pmic_glink_ucsi *ucsi = ucsi_get_drvdata(__ucsi); 144 + int ret; 145 + 146 + mutex_lock(&ucsi->lock); 147 + ret = pmic_glink_ucsi_locked_write(ucsi, offset, val, val_len); 148 + mutex_unlock(&ucsi->lock); 149 + 150 + return ret; 151 + } 152 + 153 + static int pmic_glink_ucsi_sync_write(struct ucsi *__ucsi, unsigned int offset, 154 + const void *val, size_t val_len) 155 + { 156 + struct pmic_glink_ucsi *ucsi = ucsi_get_drvdata(__ucsi); 157 + unsigned long left; 158 + int ret; 159 + 160 + /* TOFIX: Downstream forces recipient to CON when UCSI_GET_ALTERNATE_MODES command */ 161 + 162 + mutex_lock(&ucsi->lock); 163 + ucsi->sync_val = 0; 164 + reinit_completion(&ucsi->sync_ack); 165 + ucsi->sync_pending = true; 166 + ret = pmic_glink_ucsi_locked_write(ucsi, offset, val, val_len); 167 + mutex_unlock(&ucsi->lock); 168 + 169 + left = wait_for_completion_timeout(&ucsi->sync_ack, 5 * HZ); 170 + if (!left) { 171 + dev_err(ucsi->dev, "timeout waiting for UCSI sync write response\n"); 172 + ret = -ETIMEDOUT; 173 + } else if (ucsi->sync_val) { 174 + dev_err(ucsi->dev, "sync write returned: %d\n", ucsi->sync_val); 175 + } 176 + 177 + ucsi->sync_pending = false; 178 + 179 + return ret; 180 + } 181 + 182 + static const struct ucsi_operations pmic_glink_ucsi_ops = { 183 + .read = pmic_glink_ucsi_read, 184 + .sync_write = pmic_glink_ucsi_sync_write, 185 + .async_write = pmic_glink_ucsi_async_write 186 + }; 187 + 188 + static void pmic_glink_ucsi_read_ack(struct pmic_glink_ucsi *ucsi, const void *data, int len) 189 + { 190 + const struct ucsi_read_buf_resp_msg *resp = data; 191 + 192 + if (resp->ret_code) 193 + return; 194 + 195 + memcpy(ucsi->read_buf, resp->buf, UCSI_BUF_SIZE); 196 + complete(&ucsi->read_ack); 197 + } 198 + 199 + static void pmic_glink_ucsi_write_ack(struct pmic_glink_ucsi *ucsi, const void *data, int len) 200 + { 201 + const struct ucsi_write_buf_resp_msg *resp = data; 202 + 203 + if (resp->ret_code) 204 + return; 205 + 206 + ucsi->sync_val = resp->ret_code; 207 + complete(&ucsi->write_ack); 208 + } 209 + 210 + static void pmic_glink_ucsi_notify(struct work_struct *work) 211 + { 212 + struct pmic_glink_ucsi *ucsi = container_of(work, struct pmic_glink_ucsi, notify_work); 213 + unsigned int con_num; 214 + u32 cci; 215 + int ret; 216 + 217 + ret = pmic_glink_ucsi_read(ucsi->ucsi, UCSI_CCI, &cci, sizeof(cci)); 218 + if (ret) { 219 + dev_err(ucsi->dev, "failed to read CCI on notification\n"); 220 + return; 221 + } 222 + 223 + con_num = UCSI_CCI_CONNECTOR(cci); 224 + if (con_num) 225 + ucsi_connector_change(ucsi->ucsi, con_num); 226 + 227 + if (ucsi->sync_pending && cci & UCSI_CCI_BUSY) { 228 + ucsi->sync_val = -EBUSY; 229 + complete(&ucsi->sync_ack); 230 + } else if (ucsi->sync_pending && 231 + (cci & (UCSI_CCI_ACK_COMPLETE | UCSI_CCI_COMMAND_COMPLETE))) { 232 + complete(&ucsi->sync_ack); 233 + } 234 + } 235 + 236 + static void pmic_glink_ucsi_register(struct work_struct *work) 237 + { 238 + struct pmic_glink_ucsi *ucsi = container_of(work, struct pmic_glink_ucsi, register_work); 239 + 240 + ucsi_register(ucsi->ucsi); 241 + } 242 + 243 + static void pmic_glink_ucsi_callback(const void *data, size_t len, void *priv) 244 + { 245 + struct pmic_glink_ucsi *ucsi = priv; 246 + const struct pmic_glink_hdr *hdr = data; 247 + 248 + switch (hdr->opcode) { 249 + case UC_UCSI_READ_BUF_REQ: 250 + pmic_glink_ucsi_read_ack(ucsi, data, len); 251 + break; 252 + case UC_UCSI_WRITE_BUF_REQ: 253 + pmic_glink_ucsi_write_ack(ucsi, data, len); 254 + break; 255 + case UC_UCSI_USBC_NOTIFY_IND: 256 + schedule_work(&ucsi->notify_work); 257 + break; 258 + }; 259 + } 260 + 261 + static void pmic_glink_ucsi_pdr_notify(void *priv, int state) 262 + { 263 + struct pmic_glink_ucsi *ucsi = priv; 264 + 265 + if (state == SERVREG_SERVICE_STATE_UP) 266 + schedule_work(&ucsi->register_work); 267 + else if (state == SERVREG_SERVICE_STATE_DOWN) 268 + ucsi_unregister(ucsi->ucsi); 269 + } 270 + 271 + static void pmic_glink_ucsi_destroy(void *data) 272 + { 273 + struct pmic_glink_ucsi *ucsi = data; 274 + 275 + /* Protect to make sure we're not in a middle of a transaction from a glink callback */ 276 + mutex_lock(&ucsi->lock); 277 + ucsi_destroy(ucsi->ucsi); 278 + mutex_unlock(&ucsi->lock); 279 + } 280 + 281 + static int pmic_glink_ucsi_probe(struct auxiliary_device *adev, 282 + const struct auxiliary_device_id *id) 283 + { 284 + struct pmic_glink_ucsi *ucsi; 285 + struct device *dev = &adev->dev; 286 + int ret; 287 + 288 + ucsi = devm_kzalloc(dev, sizeof(*ucsi), GFP_KERNEL); 289 + if (!ucsi) 290 + return -ENOMEM; 291 + 292 + ucsi->dev = dev; 293 + dev_set_drvdata(dev, ucsi); 294 + 295 + INIT_WORK(&ucsi->notify_work, pmic_glink_ucsi_notify); 296 + INIT_WORK(&ucsi->register_work, pmic_glink_ucsi_register); 297 + init_completion(&ucsi->read_ack); 298 + init_completion(&ucsi->write_ack); 299 + init_completion(&ucsi->sync_ack); 300 + mutex_init(&ucsi->lock); 301 + 302 + ucsi->ucsi = ucsi_create(dev, &pmic_glink_ucsi_ops); 303 + if (IS_ERR(ucsi->ucsi)) 304 + return PTR_ERR(ucsi->ucsi); 305 + 306 + /* Make sure we destroy *after* pmic_glink unregister */ 307 + ret = devm_add_action_or_reset(dev, pmic_glink_ucsi_destroy, ucsi); 308 + if (ret) 309 + return ret; 310 + 311 + ucsi_set_drvdata(ucsi->ucsi, ucsi); 312 + 313 + ucsi->client = devm_pmic_glink_register_client(dev, 314 + PMIC_GLINK_OWNER_USBC, 315 + pmic_glink_ucsi_callback, 316 + pmic_glink_ucsi_pdr_notify, 317 + ucsi); 318 + return PTR_ERR_OR_ZERO(ucsi->client); 319 + } 320 + 321 + static void pmic_glink_ucsi_remove(struct auxiliary_device *adev) 322 + { 323 + struct pmic_glink_ucsi *ucsi = dev_get_drvdata(&adev->dev); 324 + 325 + /* Unregister first to stop having read & writes */ 326 + ucsi_unregister(ucsi->ucsi); 327 + } 328 + 329 + static const struct auxiliary_device_id pmic_glink_ucsi_id_table[] = { 330 + { .name = "pmic_glink.ucsi", }, 331 + {}, 332 + }; 333 + MODULE_DEVICE_TABLE(auxiliary, pmic_glink_ucsi_id_table); 334 + 335 + static struct auxiliary_driver pmic_glink_ucsi_driver = { 336 + .name = "pmic_glink_ucsi", 337 + .probe = pmic_glink_ucsi_probe, 338 + .remove = pmic_glink_ucsi_remove, 339 + .id_table = pmic_glink_ucsi_id_table, 340 + }; 341 + 342 + module_auxiliary_driver(pmic_glink_ucsi_driver); 343 + 344 + MODULE_DESCRIPTION("Qualcomm PMIC GLINK UCSI driver"); 345 + MODULE_LICENSE("GPL");
+1
include/linux/platform_data/usb3503.h
··· 12 12 USB3503_MODE_UNKNOWN, 13 13 USB3503_MODE_HUB, 14 14 USB3503_MODE_STANDBY, 15 + USB3503_MODE_BYPASS, 15 16 }; 16 17 17 18 struct usb3503_platform_data {
+6 -2
include/linux/usb.h
··· 303 303 #define USB_MAXINTERFACES 32 304 304 #define USB_MAXIADS (USB_MAXINTERFACES/2) 305 305 306 + bool usb_check_bulk_endpoints( 307 + const struct usb_interface *intf, const u8 *ep_addrs); 308 + bool usb_check_int_endpoints( 309 + const struct usb_interface *intf, const u8 *ep_addrs); 310 + 306 311 /* 307 312 * USB Resume Timer: Every Host controller driver should drive the resume 308 313 * signalling on the bus for the amount of time defined by this macro. ··· 721 716 722 717 unsigned long active_duration; 723 718 724 - #ifdef CONFIG_PM 725 719 unsigned long connect_time; 726 720 727 721 unsigned do_remote_wakeup:1; 728 722 unsigned reset_resume:1; 729 723 unsigned port_is_suspended:1; 730 - #endif 724 + 731 725 struct wusb_dev *wusb_dev; 732 726 int slot_id; 733 727 struct usb2_lpm_parameters l1_params;
+8
include/linux/usb/composite.h
··· 150 150 * GetStatus() request when the recipient is Interface. 151 151 * @func_suspend: callback to be called when 152 152 * SetFeature(FUNCTION_SUSPEND) is reseived 153 + * @func_suspended: Indicates whether the function is in function suspend state. 154 + * @func_wakeup_armed: Indicates whether the function is armed by the host for 155 + * wakeup signaling. 153 156 * 154 157 * A single USB function uses one or more interfaces, and should in most 155 158 * cases support operation at both full and high speeds. Each function is ··· 223 220 int (*get_status)(struct usb_function *); 224 221 int (*func_suspend)(struct usb_function *, 225 222 u8 suspend_opt); 223 + bool func_suspended; 224 + bool func_wakeup_armed; 226 225 /* private: */ 227 226 /* internals */ 228 227 struct list_head list; ··· 246 241 247 242 int config_ep_by_speed(struct usb_gadget *g, struct usb_function *f, 248 243 struct usb_ep *_ep); 244 + int usb_func_wakeup(struct usb_function *func); 249 245 250 246 #define MAX_CONFIG_INTERFACES 16 /* arbitrary; max 255 */ 251 247 ··· 419 413 extern int composite_os_desc_req_prepare(struct usb_composite_dev *cdev, 420 414 struct usb_ep *ep0); 421 415 void composite_dev_cleanup(struct usb_composite_dev *cdev); 416 + void check_remote_wakeup_config(struct usb_gadget *g, 417 + struct usb_configuration *c); 422 418 423 419 static inline struct usb_composite_driver *to_cdriver( 424 420 struct usb_gadget_driver *gdrv)
+9
include/linux/usb/gadget.h
··· 310 310 struct usb_gadget_ops { 311 311 int (*get_frame)(struct usb_gadget *); 312 312 int (*wakeup)(struct usb_gadget *); 313 + int (*func_wakeup)(struct usb_gadget *gadget, int intf_id); 314 + int (*set_remote_wakeup)(struct usb_gadget *, int set); 313 315 int (*set_selfpowered) (struct usb_gadget *, int is_selfpowered); 314 316 int (*vbus_session) (struct usb_gadget *, int is_active); 315 317 int (*vbus_draw) (struct usb_gadget *, unsigned mA); ··· 386 384 * @connected: True if gadget is connected. 387 385 * @lpm_capable: If the gadget max_speed is FULL or HIGH, this flag 388 386 * indicates that it supports LPM as per the LPM ECN & errata. 387 + * @wakeup_capable: True if gadget is capable of sending remote wakeup. 388 + * @wakeup_armed: True if gadget is armed by the host for remote wakeup. 389 389 * @irq: the interrupt number for device controller. 390 390 * @id_number: a unique ID number for ensuring that gadget names are distinct 391 391 * ··· 449 445 unsigned deactivated:1; 450 446 unsigned connected:1; 451 447 unsigned lpm_capable:1; 448 + unsigned wakeup_capable:1; 449 + unsigned wakeup_armed:1; 452 450 int irq; 453 451 int id_number; 454 452 }; ··· 607 601 #if IS_ENABLED(CONFIG_USB_GADGET) 608 602 int usb_gadget_frame_number(struct usb_gadget *gadget); 609 603 int usb_gadget_wakeup(struct usb_gadget *gadget); 604 + int usb_gadget_set_remote_wakeup(struct usb_gadget *gadget, int set); 610 605 int usb_gadget_set_selfpowered(struct usb_gadget *gadget); 611 606 int usb_gadget_clear_selfpowered(struct usb_gadget *gadget); 612 607 int usb_gadget_vbus_connect(struct usb_gadget *gadget); ··· 622 615 static inline int usb_gadget_frame_number(struct usb_gadget *gadget) 623 616 { return 0; } 624 617 static inline int usb_gadget_wakeup(struct usb_gadget *gadget) 618 + { return 0; } 619 + static inline int usb_gadget_set_remote_wakeup(struct usb_gadget *gadget, int set) 625 620 { return 0; } 626 621 static inline int usb_gadget_set_selfpowered(struct usb_gadget *gadget) 627 622 { return 0; }
-2
include/linux/usb/hcd.h
··· 488 488 489 489 extern int usb_hcd_amd_remote_wakeup_quirk(struct pci_dev *dev); 490 490 491 - #ifdef CONFIG_PM 492 491 extern const struct dev_pm_ops usb_hcd_pci_pm_ops; 493 - #endif 494 492 #endif /* CONFIG_USB_PCI */ 495 493 496 494 /* pci-ish (pdev null is ok) buffer alloc/mapping support */