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

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

Pull USB/PHY updates from Greg KH:
"Here is the big set of USB and PHY driver patches for 4.21-rc1.

All of the usual bits are in here:

- loads of USB gadget driver updates and additions

- new device ids

- phy driver updates

- xhci reworks and new features

- typec updates

Full details are in the shortlog.

All of these have been in linux-next for a long time with no reported
issues"

* tag 'usb-4.21-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (142 commits)
USB: serial: option: add Fibocom NL678 series
cdc-acm: fix abnormal DATA RX issue for Mediatek Preloader.
usb: r8a66597: Fix a possible concurrency use-after-free bug in r8a66597_endpoint_disable()
usb: typec: tcpm: Extend the matching rules on PPS APDO selection
usb: typec: Improve Alt Mode documentation
usb: musb: dsps: fix runtime pm for peripheral mode
usb: musb: dsps: fix otg state machine
USB: serial: pl2303: add ids for Hewlett-Packard HP POS pole displays
usb: renesas_usbhs: add support for RZ/G2E
usb: ehci-omap: Fix deferred probe for phy handling
usb: roles: Add a description for the class to Kconfig
usb: renesas_usbhs: mark PM functions as __maybe_unused
usb: core: Remove unnecessary memset()
usb: host: isp1362-hcd: convert to DEFINE_SHOW_ATTRIBUTE
phy: qcom-qmp: Expose provided clocks to DT
dt-bindings: phy-qcom-qmp: Move #clock-cells to child
phy: qcom-qmp: Utilize fully-specified DT registers
dt-bindings: phy-qcom-qmp: Fix register underspecification
phy: ti: fix semicolon.cocci warnings
phy: dphy: Add configuration helpers
...

+3634 -844
+2
Documentation/devicetree/bindings/connector/usb-connector.txt
··· 14 14 - label: symbolic name for the connector, 15 15 - type: size of the connector, should be specified in case of USB-A, USB-B 16 16 non-fullsize connectors: "mini", "micro". 17 + - self-powered: Set this property if the usb device that has its own power 18 + source. 17 19 18 20 Optional properties for usb-c-connector: 19 21 - power-role: should be one of "source", "sink" or "dual"(DRP) if typec
+7 -1
Documentation/devicetree/bindings/net/cpsw.txt
··· 22 22 - cpsw-phy-sel : Specifies the phandle to the CPSW phy mode selection 23 23 device. See also cpsw-phy-sel.txt for it's binding. 24 24 Note that in legacy cases cpsw-phy-sel may be 25 - a child device instead of a phandle. 25 + a child device instead of a phandle 26 + (DEPRECATED, use phys property instead). 26 27 27 28 Optional properties: 28 29 - ti,hwmods : Must be "cpgmac0" ··· 45 44 Slave Properties: 46 45 Required properties: 47 46 - phy-mode : See ethernet.txt file in the same directory 47 + - phys : phandle on phy-gmii-sel PHY (see phy/ti-phy-gmii-sel.txt) 48 48 49 49 Optional properties: 50 50 - dual_emac_res_vlan : Specifies VID to be used to segregate the ports ··· 87 85 phy-mode = "rgmii-txid"; 88 86 /* Filled in by U-Boot */ 89 87 mac-address = [ 00 00 00 00 00 00 ]; 88 + phys = <&phy_gmii_sel 1 0>; 90 89 }; 91 90 cpsw_emac1: slave@1 { 92 91 phy_id = <&davinci_mdio>, <1>; 93 92 phy-mode = "rgmii-txid"; 94 93 /* Filled in by U-Boot */ 95 94 mac-address = [ 00 00 00 00 00 00 ]; 95 + phys = <&phy_gmii_sel 2 0>; 96 96 }; 97 97 }; 98 98 ··· 118 114 phy-mode = "rgmii-txid"; 119 115 /* Filled in by U-Boot */ 120 116 mac-address = [ 00 00 00 00 00 00 ]; 117 + phys = <&phy_gmii_sel 1 0>; 121 118 }; 122 119 cpsw_emac1: slave@1 { 123 120 phy_id = <&davinci_mdio>, <1>; 124 121 phy-mode = "rgmii-txid"; 125 122 /* Filled in by U-Boot */ 126 123 mac-address = [ 00 00 00 00 00 00 ]; 124 + phys = <&phy_gmii_sel 2 0>; 127 125 }; 128 126 };
+17
Documentation/devicetree/bindings/phy/fsl,imx8mq-usb-phy.txt
··· 1 + * Freescale i.MX8MQ USB3 PHY binding 2 + 3 + Required properties: 4 + - compatible: Should be "fsl,imx8mq-usb-phy" 5 + - #phys-cells: must be 0 (see phy-bindings.txt in this directory) 6 + - reg: The base address and length of the registers 7 + - clocks: phandles to the clocks for each clock listed in clock-names 8 + - clock-names: must contain "phy" 9 + 10 + Example: 11 + usb3_phy0: phy@381f0040 { 12 + compatible = "fsl,imx8mq-usb-phy"; 13 + reg = <0x381f0040 0x40>; 14 + clocks = <&clk IMX8MQ_CLK_USB1_PHY_ROOT>; 15 + clock-names = "phy"; 16 + #phy-cells = <0>; 17 + };
+66 -13
Documentation/devicetree/bindings/phy/qcom-qmp-phy.txt
··· 25 25 - For all others: 26 26 - The reg-names property shouldn't be defined. 27 27 28 - - #clock-cells: must be 1 29 - - Phy pll outputs a bunch of clocks for Tx, Rx and Pipe 30 - interface (for pipe based PHYs). These clock are then gate-controlled 31 - by gcc. 32 28 - #address-cells: must be 1 33 29 - #size-cells: must be 1 34 30 - ranges: must be present ··· 78 82 - Each device node of QMP phy is required to have as many child nodes as 79 83 the number of lanes the PHY has. 80 84 81 - Required properties for child node: 85 + Required properties for child nodes of PCIe PHYs (one child per lane): 82 86 - reg: list of offset and length pairs of register sets for PHY blocks - 83 - - index 0: tx 84 - - index 1: rx 85 - - index 2: pcs 86 - - index 3: pcs_misc (optional) 87 - 87 + tx, rx, pcs, and pcs_misc (optional). 88 88 - #phy-cells: must be 0 89 89 90 - Required properties child node of pcie and usb3 qmp phys: 90 + Required properties for a single "lanes" child node of non-PCIe PHYs: 91 + - reg: list of offset and length pairs of register sets for PHY blocks 92 + For 1-lane devices: 93 + tx, rx, pcs, and (optionally) pcs_misc 94 + For 2-lane devices: 95 + tx0, rx0, pcs, tx1, rx1, and (optionally) pcs_misc 96 + - #phy-cells: must be 0 97 + 98 + Required properties for child node of PCIe and USB3 qmp phys: 91 99 - clocks: a list of phandles and clock-specifier pairs, 92 100 one for each entry in clock-names. 93 101 - clock-names: Must contain following: 94 102 "pipe<lane-number>" for pipe clock specific to each lane. 95 103 - clock-output-names: Name of the PHY clock that will be the parent for 96 104 the above pipe clock. 97 - 98 105 For "qcom,ipq8074-qmp-pcie-phy": 99 106 - "pcie20_phy0_pipe_clk" Pipe Clock parent 100 107 (or) 101 108 "pcie20_phy1_pipe_clk" 109 + - #clock-cells: must be 0 110 + - Phy pll outputs pipe clocks for pipe based PHYs. These clocks are then 111 + gate-controlled by the gcc. 102 112 103 113 Required properties for child node of PHYs with lane reset, AKA: 104 114 "qcom,msm8996-qmp-pcie-phy" ··· 117 115 phy@34000 { 118 116 compatible = "qcom,msm8996-qmp-pcie-phy"; 119 117 reg = <0x34000 0x488>; 120 - #clock-cells = <1>; 121 118 #address-cells = <1>; 122 119 #size-cells = <1>; 123 120 ranges; ··· 138 137 reg = <0x35000 0x130>, 139 138 <0x35200 0x200>, 140 139 <0x35400 0x1dc>; 140 + #clock-cells = <0>; 141 141 #phy-cells = <0>; 142 142 143 143 clocks = <&gcc GCC_PCIE_0_PIPE_CLK>; ··· 151 149 pciephy_1: lane@36000 { 152 150 ... 153 151 ... 152 + }; 153 + 154 + phy@88eb000 { 155 + compatible = "qcom,sdm845-qmp-usb3-uni-phy"; 156 + reg = <0x88eb000 0x18c>; 157 + #address-cells = <1>; 158 + #size-cells = <1>; 159 + ranges; 160 + 161 + clocks = <&gcc GCC_USB3_SEC_PHY_AUX_CLK>, 162 + <&gcc GCC_USB_PHY_CFG_AHB2PHY_CLK>, 163 + <&gcc GCC_USB3_SEC_CLKREF_CLK>, 164 + <&gcc GCC_USB3_SEC_PHY_COM_AUX_CLK>; 165 + clock-names = "aux", "cfg_ahb", "ref", "com_aux"; 166 + 167 + resets = <&gcc GCC_USB3PHY_PHY_SEC_BCR>, 168 + <&gcc GCC_USB3_PHY_SEC_BCR>; 169 + reset-names = "phy", "common"; 170 + 171 + lane@88eb200 { 172 + reg = <0x88eb200 0x128>, 173 + <0x88eb400 0x1fc>, 174 + <0x88eb800 0x218>, 175 + <0x88eb600 0x70>; 176 + #clock-cells = <0>; 177 + #phy-cells = <0>; 178 + clocks = <&gcc GCC_USB3_SEC_PHY_PIPE_CLK>; 179 + clock-names = "pipe0"; 180 + clock-output-names = "usb3_uni_phy_pipe_clk_src"; 181 + }; 182 + }; 183 + 184 + phy@1d87000 { 185 + compatible = "qcom,sdm845-qmp-ufs-phy"; 186 + reg = <0x1d87000 0x18c>; 187 + #address-cells = <1>; 188 + #size-cells = <1>; 189 + ranges; 190 + clock-names = "ref", 191 + "ref_aux"; 192 + clocks = <&gcc GCC_UFS_MEM_CLKREF_CLK>, 193 + <&gcc GCC_UFS_PHY_PHY_AUX_CLK>; 194 + 195 + lanes@1d87400 { 196 + reg = <0x1d87400 0x108>, 197 + <0x1d87600 0x1e0>, 198 + <0x1d87c00 0x1dc>, 199 + <0x1d87800 0x108>, 200 + <0x1d87a00 0x1e0>; 201 + #phy-cells = <0>; 202 + }; 154 203 };
+5 -3
Documentation/devicetree/bindings/phy/sun4i-usb-phy.txt
··· 14 14 * allwinner,sun8i-r40-usb-phy 15 15 * allwinner,sun8i-v3s-usb-phy 16 16 * allwinner,sun50i-a64-usb-phy 17 + * allwinner,sun50i-h6-usb-phy 17 18 - reg : a list of offset + length pairs 18 19 - reg-names : 19 20 * "phy_ctrl" 20 - * "pmu0" for H3, V3s and A64 21 + * "pmu0" for H3, V3s, A64 or H6 21 22 * "pmu1" 22 23 * "pmu2" for sun4i, sun6i, sun7i, sun8i-a83t or sun8i-h3 23 - * "pmu3" for sun8i-h3 24 + * "pmu3" for sun8i-h3 or sun50i-h6 24 25 - #phy-cells : from the generic phy bindings, must be 1 25 26 - clocks : phandle + clock specifier for the phy clocks 26 27 - clock-names : ··· 30 29 * "usb0_phy", "usb1_phy" for sun8i 31 30 * "usb0_phy", "usb1_phy", "usb2_phy" and "usb2_hsic_12M" for sun8i-a83t 32 31 * "usb0_phy", "usb1_phy", "usb2_phy" and "usb3_phy" for sun8i-h3 32 + * "usb0_phy" and "usb3_phy" for sun50i-h6 33 33 - resets : a list of phandle + reset specifier pairs 34 34 - reset-names : 35 35 * "usb0_reset" 36 36 * "usb1_reset" 37 37 * "usb2_reset" for sun4i, sun6i, sun7i, sun8i-a83t or sun8i-h3 38 - * "usb3_reset" for sun8i-h3 38 + * "usb3_reset" for sun8i-h3 and sun50i-h6 39 39 40 40 Optional properties: 41 41 - usb0_id_det-gpios : gpio phandle for reading the otg id pin value
+68
Documentation/devicetree/bindings/phy/ti-phy-gmii-sel.txt
··· 1 + CPSW Port's Interface Mode Selection PHY Tree Bindings 2 + ----------------------------------------------- 3 + 4 + TI am335x/am437x/dra7(am5)/dm814x CPSW3G Ethernet Subsystem supports 5 + two 10/100/1000 Ethernet ports with selectable G/MII, RMII, and RGMII interfaces. 6 + The interface mode is selected by configuring the MII mode selection register(s) 7 + (GMII_SEL) in the System Control Module chapter (SCM). GMII_SEL register(s) and 8 + bit fields placement in SCM are different between SoCs while fields meaning 9 + is the same. 10 + +--------------+ 11 + +-------------------------------+ |SCM | 12 + | CPSW | | +---------+ | 13 + | +--------------------------------+gmii_sel | | 14 + | | | | +---------+ | 15 + | +----v---+ +--------+ | +--------------+ 16 + | |Port 1..<--+-->GMII/MII<-------> 17 + | | | | | | | 18 + | +--------+ | +--------+ | 19 + | | | 20 + | | +--------+ | 21 + | | | RMII <-------> 22 + | +--> | | 23 + | | +--------+ | 24 + | | | 25 + | | +--------+ | 26 + | | | RGMII <-------> 27 + | +--> | | 28 + | +--------+ | 29 + +-------------------------------+ 30 + 31 + CPSW Port's Interface Mode Selection PHY describes MII interface mode between 32 + CPSW Port and Ethernet PHY which depends on Eth PHY and board configuration. 33 + 34 + CPSW Port's Interface Mode Selection PHY device should defined as child device 35 + of SCM node (scm_conf) and can be attached to each CPSW port node using standard 36 + PHY bindings (See phy/phy-bindings.txt). 37 + 38 + Required properties: 39 + - compatible : Should be "ti,am3352-phy-gmii-sel" for am335x platform 40 + "ti,dra7xx-phy-gmii-sel" for dra7xx/am57xx platform 41 + "ti,am43xx-phy-gmii-sel" for am43xx platform 42 + "ti,dm814-phy-gmii-sel" for dm814x platform 43 + - reg : Address and length of the register set for the device 44 + - #phy-cells : must be 2. 45 + cell 1 - CPSW port number (starting from 1) 46 + cell 2 - RMII refclk mode 47 + 48 + Examples: 49 + phy_gmii_sel: phy-gmii-sel { 50 + compatible = "ti,am3352-phy-gmii-sel"; 51 + reg = <0x650 0x4>; 52 + #phy-cells = <2>; 53 + }; 54 + 55 + mac: ethernet@4a100000 { 56 + compatible = "ti,am335x-cpsw","ti,cpsw"; 57 + ... 58 + 59 + cpsw_emac0: slave@4a100200 { 60 + ... 61 + phys = <&phy_gmii_sel 1 1>; 62 + }; 63 + 64 + cpsw_emac1: slave@4a100300 { 65 + ... 66 + phys = <&phy_gmii_sel 2 1>; 67 + }; 68 + };
+33 -3
Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt
··· 80 80 controller. It's expected that a mux state of 0 indicates device mode and a 81 81 mux state of 1 indicates host mode. 82 82 - mux-control-names: Shall be "usb_switch" if mux-controls is specified. 83 - - pinctrl-names: Names for optional pin modes in "default", "host", "device" 83 + - pinctrl-names: Names for optional pin modes in "default", "host", "device". 84 + In case of HSIC-mode, "idle" and "active" pin modes are mandatory. In this 85 + case, the "idle" state needs to pull down the data and strobe pin 86 + and the "active" state needs to pull up the strobe pin. 84 87 - pinctrl-n: alternate pin modes 85 88 86 89 i.mx specific properties 87 90 - fsl,usbmisc: phandler of non-core register device, with one 88 91 argument that indicate usb controller index 89 92 - disable-over-current: disable over current detect 90 - - over-current-active-high: over current signal polarity is high active, 91 - typically over current signal polarity is low active. 93 + - over-current-active-low: over current signal polarity is active low. 94 + - over-current-active-high: over current signal polarity is active high. 95 + It's recommended to specify the over current polarity. 92 96 - external-vbus-divider: enables off-chip resistor divider for Vbus 93 97 94 98 Example: ··· 114 110 phy-clkgate-delay-us = <400>; 115 111 mux-controls = <&usb_switch>; 116 112 mux-control-names = "usb_switch"; 113 + }; 114 + 115 + Example for HSIC: 116 + 117 + usb@2184400 { 118 + compatible = "fsl,imx6q-usb", "fsl,imx27-usb"; 119 + reg = <0x02184400 0x200>; 120 + interrupts = <0 41 IRQ_TYPE_LEVEL_HIGH>; 121 + clocks = <&clks IMX6QDL_CLK_USBOH3>; 122 + fsl,usbphy = <&usbphynop1>; 123 + fsl,usbmisc = <&usbmisc 2>; 124 + phy_type = "hsic"; 125 + dr_mode = "host"; 126 + ahb-burst-config = <0x0>; 127 + tx-burst-size-dword = <0x10>; 128 + rx-burst-size-dword = <0x10>; 129 + pinctrl-names = "idle", "active"; 130 + pinctrl-0 = <&pinctrl_usbh2_idle>; 131 + pinctrl-1 = <&pinctrl_usbh2_active>; 132 + #address-cells = <1>; 133 + #size-cells = <0>; 134 + 135 + usbnet: smsc@1 { 136 + compatible = "usb424,9730"; 137 + reg = <1>; 138 + }; 117 139 };
+4
Documentation/devicetree/bindings/usb/dwc3.txt
··· 37 37 - phy-names: from the *Generic PHY* bindings; supported names are "usb2-phy" 38 38 or "usb3-phy". 39 39 - resets: a single pair of phandle and reset specifier 40 + - snps,usb2-lpm-disable: indicate if we don't want to enable USB2 HW LPM 40 41 - snps,usb3_lpm_capable: determines if platform is USB3 LPM capable 42 + - snps,dis-start-transfer-quirk: when set, disable isoc START TRANSFER command 43 + failure SW work-around for DWC_usb31 version 1.70a-ea06 44 + and prior. 41 45 - snps,disable_scramble_quirk: true when SW should disable data scrambling. 42 46 Only really useful for FPGA builds. 43 47 - snps,has-lpm-erratum: true when DWC3 was configured with LPM Erratum enabled
+1
Documentation/driver-api/usb/index.rst
··· 19 19 dwc3 20 20 writing_musb_glue_layer 21 21 typec 22 + typec_bus 22 23 usb3-debug-port 23 24 24 25 .. only:: subproject and html
+1
Documentation/driver-api/usb/typec.rst
··· 1 + .. _typec: 1 2 2 3 USB Type-C connector class 3 4 ==========================
+12 -12
Documentation/driver-api/usb/typec_bus.rst
··· 13 13 USB Type-C bus allows binding a driver to the discovered partner alternate 14 14 modes by using the SVID and the mode number. 15 15 16 - USB Type-C Connector Class provides a device for every alternate mode a port 17 - supports, and separate device for every alternate mode the partner supports. 18 - The drivers for the alternate modes are bound to the partner alternate mode 19 - devices, and the port alternate mode devices must be handled by the port 16 + :ref:`USB Type-C Connector Class <typec>` provides a device for every alternate 17 + mode a port supports, and separate device for every alternate mode the partner 18 + supports. The drivers for the alternate modes are bound to the partner alternate 19 + mode devices, and the port alternate mode devices must be handled by the port 20 20 drivers. 21 21 22 22 When a new partner alternate mode device is registered, it is linked to the ··· 46 46 ``->vdm`` is the most important callback in the operation callbacks vector. It 47 47 will be used to deliver all the SVID specific commands from the partner to the 48 48 alternate mode driver, and vice versa in case of port drivers. The drivers send 49 - the SVID specific commands to each other using :c:func:`typec_altmode_vmd()`. 49 + the SVID specific commands to each other using :c:func:`typec_altmode_vdm()`. 50 50 51 51 If the communication with the partner using the SVID specific commands results 52 52 in need to reconfigure the pins on the connector, the alternate mode driver ··· 67 67 after the mode has been exited. 68 68 69 69 An example of working definitions for SVID specific pin configurations would 70 - look like this: 70 + look like this:: 71 71 72 - enum { 73 - ALTMODEX_CONF_A = TYPEC_STATE_MODAL, 74 - ALTMODEX_CONF_B, 75 - ... 76 - }; 72 + enum { 73 + ALTMODEX_CONF_A = TYPEC_STATE_MODAL, 74 + ALTMODEX_CONF_B, 75 + ... 76 + }; 77 77 78 - Helper macro ``TYPEC_MODAL_STATE()`` can also be used: 78 + Helper macro ``TYPEC_MODAL_STATE()`` can also be used:: 79 79 80 80 #define ALTMODEX_CONF_A = TYPEC_MODAL_STATE(0); 81 81 #define ALTMODEX_CONF_B = TYPEC_MODAL_STATE(1);
+1 -1
Documentation/usb/authorization.txt
··· 119 119 be triggered manually by writing INTERFACE to /sys/bus/usb/drivers_probe 120 120 121 121 For drivers that need multiple interfaces all needed interfaces should be 122 - authroized first. After that the drivers should be probed. 122 + authorized first. After that the drivers should be probed. 123 123 This avoids side effects.
+1
MAINTAINERS
··· 6310 6310 S: Supported 6311 6311 F: drivers/phy/ 6312 6312 F: include/linux/phy/ 6313 + F: Documentation/devicetree/bindings/phy/ 6313 6314 6314 6315 GENERIC PINCTRL I2C DEMULTIPLEXER DRIVER 6315 6316 M: Wolfram Sang <wsa+renesas@sang-engineering.com>
+2 -17
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
··· 1165 1165 */ 1166 1166 static int mvpp22_comphy_init(struct mvpp2_port *port) 1167 1167 { 1168 - enum phy_mode mode; 1169 1168 int ret; 1170 1169 1171 1170 if (!port->comphy) 1172 1171 return 0; 1173 1172 1174 - switch (port->phy_interface) { 1175 - case PHY_INTERFACE_MODE_SGMII: 1176 - case PHY_INTERFACE_MODE_1000BASEX: 1177 - mode = PHY_MODE_SGMII; 1178 - break; 1179 - case PHY_INTERFACE_MODE_2500BASEX: 1180 - mode = PHY_MODE_2500SGMII; 1181 - break; 1182 - case PHY_INTERFACE_MODE_10GKR: 1183 - mode = PHY_MODE_10GKR; 1184 - break; 1185 - default: 1186 - return -EINVAL; 1187 - } 1188 - 1189 - ret = phy_set_mode(port->comphy, mode); 1173 + ret = phy_set_mode_ext(port->comphy, PHY_MODE_ETHERNET, 1174 + port->phy_interface); 1190 1175 if (ret) 1191 1176 return ret; 1192 1177
+2 -7
drivers/net/ethernet/mscc/ocelot.c
··· 471 471 { 472 472 struct ocelot_port *port = netdev_priv(dev); 473 473 struct ocelot *ocelot = port->ocelot; 474 - enum phy_mode phy_mode; 475 474 int err; 476 475 477 476 /* Enable receiving frames on the port, and activate auto-learning of ··· 482 483 ANA_PORT_PORT_CFG, port->chip_port); 483 484 484 485 if (port->serdes) { 485 - if (port->phy_mode == PHY_INTERFACE_MODE_SGMII) 486 - phy_mode = PHY_MODE_SGMII; 487 - else 488 - phy_mode = PHY_MODE_QSGMII; 489 - 490 - err = phy_set_mode(port->serdes, phy_mode); 486 + err = phy_set_mode_ext(port->serdes, PHY_MODE_ETHERNET, 487 + port->phy_mode); 491 488 if (err) { 492 489 netdev_err(dev, "Could not set mode of SerDes\n"); 493 490 return err;
+18 -1
drivers/net/ethernet/ti/cpsw.c
··· 26 26 #include <linux/netdevice.h> 27 27 #include <linux/net_tstamp.h> 28 28 #include <linux/phy.h> 29 + #include <linux/phy/phy.h> 29 30 #include <linux/workqueue.h> 30 31 #include <linux/delay.h> 31 32 #include <linux/pm_runtime.h> ··· 388 387 int phy_if; 389 388 u8 mac_addr[ETH_ALEN]; 390 389 u16 dual_emac_res_vlan; /* Reserved VLAN for DualEMAC */ 390 + struct phy *ifphy; 391 391 }; 392 392 393 393 struct cpsw_platform_data { ··· 1626 1624 phy_start(slave->phy); 1627 1625 1628 1626 /* Configure GMII_SEL register */ 1629 - cpsw_phy_sel(cpsw->dev, slave->phy->interface, slave->slave_num); 1627 + if (!IS_ERR(slave->data->ifphy)) 1628 + phy_set_mode_ext(slave->data->ifphy, PHY_MODE_ETHERNET, 1629 + slave->data->phy_if); 1630 + else 1631 + cpsw_phy_sel(cpsw->dev, slave->phy->interface, 1632 + slave->slave_num); 1630 1633 } 1631 1634 1632 1635 static inline void cpsw_add_default_vlan(struct cpsw_priv *priv) ··· 3280 3273 /* This is no slave child node, continue */ 3281 3274 if (!of_node_name_eq(slave_node, "slave")) 3282 3275 continue; 3276 + 3277 + slave_data->ifphy = devm_of_phy_get(&pdev->dev, slave_node, 3278 + NULL); 3279 + if (!IS_ENABLED(CONFIG_TI_CPSW_PHY_SEL) && 3280 + IS_ERR(slave_data->ifphy)) { 3281 + ret = PTR_ERR(slave_data->ifphy); 3282 + dev_err(&pdev->dev, 3283 + "%d: Error retrieving port phy: %d\n", i, ret); 3284 + return ret; 3285 + } 3283 3286 3284 3287 slave_data->phy_node = of_parse_phandle(slave_node, 3285 3288 "phy-handle", 0);
+9
drivers/phy/Kconfig
··· 15 15 phy users can obtain reference to the PHY. All the users of this 16 16 framework should select this config. 17 17 18 + config GENERIC_PHY_MIPI_DPHY 19 + bool 20 + help 21 + Generic MIPI D-PHY support. 22 + 23 + Provides a number of helpers a core functions for MIPI D-PHY 24 + drivers to us. 25 + 18 26 config PHY_LPC18XX_USB_OTG 19 27 tristate "NXP LPC18xx/43xx SoC USB OTG PHY driver" 20 28 depends on OF && (ARCH_LPC18XX || COMPILE_TEST) ··· 52 44 source "drivers/phy/amlogic/Kconfig" 53 45 source "drivers/phy/broadcom/Kconfig" 54 46 source "drivers/phy/cadence/Kconfig" 47 + source "drivers/phy/freescale/Kconfig" 55 48 source "drivers/phy/hisilicon/Kconfig" 56 49 source "drivers/phy/lantiq/Kconfig" 57 50 source "drivers/phy/marvell/Kconfig"
+2
drivers/phy/Makefile
··· 4 4 # 5 5 6 6 obj-$(CONFIG_GENERIC_PHY) += phy-core.o 7 + obj-$(CONFIG_GENERIC_PHY_MIPI_DPHY) += phy-core-mipi-dphy.o 7 8 obj-$(CONFIG_PHY_LPC18XX_USB_OTG) += phy-lpc18xx-usb-otg.o 8 9 obj-$(CONFIG_PHY_XGENE) += phy-xgene.o 9 10 obj-$(CONFIG_PHY_PISTACHIO_USB) += phy-pistachio-usb.o ··· 17 16 obj-$(CONFIG_ARCH_TEGRA) += tegra/ 18 17 obj-y += broadcom/ \ 19 18 cadence/ \ 19 + freescale/ \ 20 20 hisilicon/ \ 21 21 marvell/ \ 22 22 motorola/ \
+26 -3
drivers/phy/allwinner/phy-sun4i-usb.c
··· 115 115 sun8i_r40_phy, 116 116 sun8i_v3s_phy, 117 117 sun50i_a64_phy, 118 + sun50i_h6_phy, 118 119 }; 119 120 120 121 struct sun4i_usb_phy_cfg { ··· 127 126 bool dedicated_clocks; 128 127 bool enable_pmu_unk1; 129 128 bool phy0_dual_route; 129 + int missing_phys; 130 130 }; 131 131 132 132 struct sun4i_usb_phy_data { ··· 296 294 return ret; 297 295 } 298 296 299 - if (data->cfg->type == sun8i_a83t_phy) { 297 + if (data->cfg->type == sun8i_a83t_phy || 298 + data->cfg->type == sun50i_h6_phy) { 300 299 if (phy->index == 0) { 301 300 val = readl(data->base + data->cfg->phyctl_offset); 302 301 val |= PHY_CTL_VBUSVLDEXT; ··· 346 343 struct sun4i_usb_phy_data *data = to_sun4i_usb_phy_data(phy); 347 344 348 345 if (phy->index == 0) { 349 - if (data->cfg->type == sun8i_a83t_phy) { 346 + if (data->cfg->type == sun8i_a83t_phy || 347 + data->cfg->type == sun50i_h6_phy) { 350 348 void __iomem *phyctl = data->base + 351 349 data->cfg->phyctl_offset; 352 350 ··· 478 474 return 0; 479 475 } 480 476 481 - static int sun4i_usb_phy_set_mode(struct phy *_phy, enum phy_mode mode) 477 + static int sun4i_usb_phy_set_mode(struct phy *_phy, 478 + enum phy_mode mode, int submode) 482 479 { 483 480 struct sun4i_usb_phy *phy = phy_get_drvdata(_phy); 484 481 struct sun4i_usb_phy_data *data = to_sun4i_usb_phy_data(phy); ··· 651 646 if (args->args[0] >= data->cfg->num_phys) 652 647 return ERR_PTR(-ENODEV); 653 648 649 + if (data->cfg->missing_phys & BIT(args->args[0])) 650 + return ERR_PTR(-ENODEV); 651 + 654 652 return data->phys[args->args[0]].phy; 655 653 } 656 654 ··· 748 740 for (i = 0; i < data->cfg->num_phys; i++) { 749 741 struct sun4i_usb_phy *phy = data->phys + i; 750 742 char name[16]; 743 + 744 + if (data->cfg->missing_phys & BIT(i)) 745 + continue; 751 746 752 747 snprintf(name, sizeof(name), "usb%d_vbus", i); 753 748 phy->vbus = devm_regulator_get_optional(dev, name); ··· 963 952 .phy0_dual_route = true, 964 953 }; 965 954 955 + static const struct sun4i_usb_phy_cfg sun50i_h6_cfg = { 956 + .num_phys = 4, 957 + .type = sun50i_h6_phy, 958 + .disc_thresh = 3, 959 + .phyctl_offset = REG_PHYCTL_A33, 960 + .dedicated_clocks = true, 961 + .enable_pmu_unk1 = true, 962 + .phy0_dual_route = true, 963 + .missing_phys = BIT(1) | BIT(2), 964 + }; 965 + 966 966 static const struct of_device_id sun4i_usb_phy_of_match[] = { 967 967 { .compatible = "allwinner,sun4i-a10-usb-phy", .data = &sun4i_a10_cfg }, 968 968 { .compatible = "allwinner,sun5i-a13-usb-phy", .data = &sun5i_a13_cfg }, ··· 987 965 { .compatible = "allwinner,sun8i-v3s-usb-phy", .data = &sun8i_v3s_cfg }, 988 966 { .compatible = "allwinner,sun50i-a64-usb-phy", 989 967 .data = &sun50i_a64_cfg}, 968 + { .compatible = "allwinner,sun50i-h6-usb-phy", .data = &sun50i_h6_cfg }, 990 969 { }, 991 970 }; 992 971 MODULE_DEVICE_TABLE(of, sun4i_usb_phy_of_match);
+3 -2
drivers/phy/amlogic/phy-meson-gxl-usb2.c
··· 152 152 return 0; 153 153 } 154 154 155 - static int phy_meson_gxl_usb2_set_mode(struct phy *phy, enum phy_mode mode) 155 + static int phy_meson_gxl_usb2_set_mode(struct phy *phy, 156 + enum phy_mode mode, int submode) 156 157 { 157 158 struct phy_meson_gxl_usb2_priv *priv = phy_get_drvdata(phy); 158 159 ··· 210 209 /* power on the PHY by taking it out of reset mode */ 211 210 regmap_update_bits(priv->regmap, U2P_R0, U2P_R0_POWER_ON_RESET, 0); 212 211 213 - ret = phy_meson_gxl_usb2_set_mode(phy, priv->mode); 212 + ret = phy_meson_gxl_usb2_set_mode(phy, priv->mode, 0); 214 213 if (ret) { 215 214 phy_meson_gxl_usb2_power_off(phy); 216 215
+3 -2
drivers/phy/amlogic/phy-meson-gxl-usb3.c
··· 119 119 return 0; 120 120 } 121 121 122 - static int phy_meson_gxl_usb3_set_mode(struct phy *phy, enum phy_mode mode) 122 + static int phy_meson_gxl_usb3_set_mode(struct phy *phy, 123 + enum phy_mode mode, int submode) 123 124 { 124 125 struct phy_meson_gxl_usb3_priv *priv = phy_get_drvdata(phy); 125 126 ··· 165 164 if (ret) 166 165 goto err_disable_clk_phy; 167 166 168 - ret = phy_meson_gxl_usb3_set_mode(phy, priv->mode); 167 + ret = phy_meson_gxl_usb3_set_mode(phy, priv->mode, 0); 169 168 if (ret) 170 169 goto err_disable_clk_peripheral; 171 170
+8 -1
drivers/phy/cadence/Kconfig
··· 1 1 # 2 - # Phy driver for Cadence MHDP DisplayPort controller 2 + # Phy drivers for Cadence PHYs 3 3 # 4 4 config PHY_CADENCE_DP 5 5 tristate "Cadence MHDP DisplayPort PHY driver" ··· 8 8 select GENERIC_PHY 9 9 help 10 10 Support for Cadence MHDP DisplayPort PHY. 11 + 12 + config PHY_CADENCE_SIERRA 13 + tristate "Cadence Sierra PHY Driver" 14 + depends on OF && HAS_IOMEM && RESET_CONTROLLER 15 + select GENERIC_PHY 16 + help 17 + Enable this to support the Cadence Sierra PHY driver
+1
drivers/phy/cadence/Makefile
··· 1 1 obj-$(CONFIG_PHY_CADENCE_DP) += phy-cadence-dp.o 2 + obj-$(CONFIG_PHY_CADENCE_SIERRA) += phy-cadence-sierra.o
+395
drivers/phy/cadence/phy-cadence-sierra.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + /* 3 + * Cadence Sierra PHY Driver 4 + * 5 + * Copyright (c) 2018 Cadence Design Systems 6 + * Author: Alan Douglas <adouglas@cadence.com> 7 + * 8 + */ 9 + #include <linux/clk.h> 10 + #include <linux/delay.h> 11 + #include <linux/err.h> 12 + #include <linux/io.h> 13 + #include <linux/module.h> 14 + #include <linux/phy/phy.h> 15 + #include <linux/platform_device.h> 16 + #include <linux/pm_runtime.h> 17 + #include <linux/regmap.h> 18 + #include <linux/reset.h> 19 + #include <linux/slab.h> 20 + #include <linux/of.h> 21 + #include <linux/of_platform.h> 22 + #include <dt-bindings/phy/phy.h> 23 + 24 + /* PHY register offsets */ 25 + #define SIERRA_PHY_PLL_CFG (0xc00e << 2) 26 + #define SIERRA_DET_STANDEC_A (0x4000 << 2) 27 + #define SIERRA_DET_STANDEC_B (0x4001 << 2) 28 + #define SIERRA_DET_STANDEC_C (0x4002 << 2) 29 + #define SIERRA_DET_STANDEC_D (0x4003 << 2) 30 + #define SIERRA_DET_STANDEC_E (0x4004 << 2) 31 + #define SIERRA_PSM_LANECAL (0x4008 << 2) 32 + #define SIERRA_PSM_DIAG (0x4015 << 2) 33 + #define SIERRA_PSC_TX_A0 (0x4028 << 2) 34 + #define SIERRA_PSC_TX_A1 (0x4029 << 2) 35 + #define SIERRA_PSC_TX_A2 (0x402A << 2) 36 + #define SIERRA_PSC_TX_A3 (0x402B << 2) 37 + #define SIERRA_PSC_RX_A0 (0x4030 << 2) 38 + #define SIERRA_PSC_RX_A1 (0x4031 << 2) 39 + #define SIERRA_PSC_RX_A2 (0x4032 << 2) 40 + #define SIERRA_PSC_RX_A3 (0x4033 << 2) 41 + #define SIERRA_PLLCTRL_SUBRATE (0x403A << 2) 42 + #define SIERRA_PLLCTRL_GEN_D (0x403E << 2) 43 + #define SIERRA_DRVCTRL_ATTEN (0x406A << 2) 44 + #define SIERRA_CLKPATHCTRL_TMR (0x4081 << 2) 45 + #define SIERRA_RX_CREQ_FLTR_A_MODE1 (0x4087 << 2) 46 + #define SIERRA_RX_CREQ_FLTR_A_MODE0 (0x4088 << 2) 47 + #define SIERRA_CREQ_CCLKDET_MODE01 (0x408E << 2) 48 + #define SIERRA_RX_CTLE_MAINTENANCE (0x4091 << 2) 49 + #define SIERRA_CREQ_FSMCLK_SEL (0x4092 << 2) 50 + #define SIERRA_CTLELUT_CTRL (0x4098 << 2) 51 + #define SIERRA_DFE_ECMP_RATESEL (0x40C0 << 2) 52 + #define SIERRA_DFE_SMP_RATESEL (0x40C1 << 2) 53 + #define SIERRA_DEQ_VGATUNE_CTRL (0x40E1 << 2) 54 + #define SIERRA_TMRVAL_MODE3 (0x416E << 2) 55 + #define SIERRA_TMRVAL_MODE2 (0x416F << 2) 56 + #define SIERRA_TMRVAL_MODE1 (0x4170 << 2) 57 + #define SIERRA_TMRVAL_MODE0 (0x4171 << 2) 58 + #define SIERRA_PICNT_MODE1 (0x4174 << 2) 59 + #define SIERRA_CPI_OUTBUF_RATESEL (0x417C << 2) 60 + #define SIERRA_LFPSFILT_NS (0x418A << 2) 61 + #define SIERRA_LFPSFILT_RD (0x418B << 2) 62 + #define SIERRA_LFPSFILT_MP (0x418C << 2) 63 + #define SIERRA_SDFILT_H2L_A (0x4191 << 2) 64 + 65 + #define SIERRA_MACRO_ID 0x00007364 66 + #define SIERRA_MAX_LANES 4 67 + 68 + struct cdns_sierra_inst { 69 + struct phy *phy; 70 + u32 phy_type; 71 + u32 num_lanes; 72 + u32 mlane; 73 + struct reset_control *lnk_rst; 74 + }; 75 + 76 + struct cdns_reg_pairs { 77 + u16 val; 78 + u32 off; 79 + }; 80 + 81 + struct cdns_sierra_data { 82 + u32 id_value; 83 + u32 pcie_regs; 84 + u32 usb_regs; 85 + struct cdns_reg_pairs *pcie_vals; 86 + struct cdns_reg_pairs *usb_vals; 87 + }; 88 + 89 + struct cdns_sierra_phy { 90 + struct device *dev; 91 + void __iomem *base; 92 + struct cdns_sierra_data *init_data; 93 + struct cdns_sierra_inst phys[SIERRA_MAX_LANES]; 94 + struct reset_control *phy_rst; 95 + struct reset_control *apb_rst; 96 + struct clk *clk; 97 + int nsubnodes; 98 + bool autoconf; 99 + }; 100 + 101 + static void cdns_sierra_phy_init(struct phy *gphy) 102 + { 103 + struct cdns_sierra_inst *ins = phy_get_drvdata(gphy); 104 + struct cdns_sierra_phy *phy = dev_get_drvdata(gphy->dev.parent); 105 + int i, j; 106 + struct cdns_reg_pairs *vals; 107 + u32 num_regs; 108 + 109 + if (ins->phy_type == PHY_TYPE_PCIE) { 110 + num_regs = phy->init_data->pcie_regs; 111 + vals = phy->init_data->pcie_vals; 112 + } else if (ins->phy_type == PHY_TYPE_USB3) { 113 + num_regs = phy->init_data->usb_regs; 114 + vals = phy->init_data->usb_vals; 115 + } else { 116 + return; 117 + } 118 + for (i = 0; i < ins->num_lanes; i++) 119 + for (j = 0; j < num_regs ; j++) 120 + writel(vals[j].val, phy->base + 121 + vals[j].off + (i + ins->mlane) * 0x800); 122 + } 123 + 124 + static int cdns_sierra_phy_on(struct phy *gphy) 125 + { 126 + struct cdns_sierra_inst *ins = phy_get_drvdata(gphy); 127 + 128 + /* Take the PHY lane group out of reset */ 129 + return reset_control_deassert(ins->lnk_rst); 130 + } 131 + 132 + static int cdns_sierra_phy_off(struct phy *gphy) 133 + { 134 + struct cdns_sierra_inst *ins = phy_get_drvdata(gphy); 135 + 136 + return reset_control_assert(ins->lnk_rst); 137 + } 138 + 139 + static const struct phy_ops ops = { 140 + .power_on = cdns_sierra_phy_on, 141 + .power_off = cdns_sierra_phy_off, 142 + .owner = THIS_MODULE, 143 + }; 144 + 145 + static int cdns_sierra_get_optional(struct cdns_sierra_inst *inst, 146 + struct device_node *child) 147 + { 148 + if (of_property_read_u32(child, "reg", &inst->mlane)) 149 + return -EINVAL; 150 + 151 + if (of_property_read_u32(child, "cdns,num-lanes", &inst->num_lanes)) 152 + return -EINVAL; 153 + 154 + if (of_property_read_u32(child, "cdns,phy-type", &inst->phy_type)) 155 + return -EINVAL; 156 + 157 + return 0; 158 + } 159 + 160 + static const struct of_device_id cdns_sierra_id_table[]; 161 + 162 + static int cdns_sierra_phy_probe(struct platform_device *pdev) 163 + { 164 + struct cdns_sierra_phy *sp; 165 + struct phy_provider *phy_provider; 166 + struct device *dev = &pdev->dev; 167 + const struct of_device_id *match; 168 + struct resource *res; 169 + int i, ret, node = 0; 170 + struct device_node *dn = dev->of_node, *child; 171 + 172 + if (of_get_child_count(dn) == 0) 173 + return -ENODEV; 174 + 175 + sp = devm_kzalloc(dev, sizeof(*sp), GFP_KERNEL); 176 + if (!sp) 177 + return -ENOMEM; 178 + dev_set_drvdata(dev, sp); 179 + sp->dev = dev; 180 + 181 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 182 + sp->base = devm_ioremap_resource(dev, res); 183 + if (IS_ERR(sp->base)) { 184 + dev_err(dev, "missing \"reg\"\n"); 185 + return PTR_ERR(sp->base); 186 + } 187 + 188 + /* Get init data for this PHY */ 189 + match = of_match_device(cdns_sierra_id_table, dev); 190 + if (!match) 191 + return -EINVAL; 192 + sp->init_data = (struct cdns_sierra_data *)match->data; 193 + 194 + platform_set_drvdata(pdev, sp); 195 + 196 + sp->clk = devm_clk_get(dev, "phy_clk"); 197 + if (IS_ERR(sp->clk)) { 198 + dev_err(dev, "failed to get clock phy_clk\n"); 199 + return PTR_ERR(sp->clk); 200 + } 201 + 202 + sp->phy_rst = devm_reset_control_get(dev, "sierra_reset"); 203 + if (IS_ERR(sp->phy_rst)) { 204 + dev_err(dev, "failed to get reset\n"); 205 + return PTR_ERR(sp->phy_rst); 206 + } 207 + 208 + sp->apb_rst = devm_reset_control_get(dev, "sierra_apb"); 209 + if (IS_ERR(sp->apb_rst)) { 210 + dev_err(dev, "failed to get apb reset\n"); 211 + return PTR_ERR(sp->apb_rst); 212 + } 213 + 214 + ret = clk_prepare_enable(sp->clk); 215 + if (ret) 216 + return ret; 217 + 218 + /* Enable APB */ 219 + reset_control_deassert(sp->apb_rst); 220 + 221 + /* Check that PHY is present */ 222 + if (sp->init_data->id_value != readl(sp->base)) { 223 + ret = -EINVAL; 224 + goto clk_disable; 225 + } 226 + 227 + sp->autoconf = of_property_read_bool(dn, "cdns,autoconf"); 228 + 229 + for_each_available_child_of_node(dn, child) { 230 + struct phy *gphy; 231 + 232 + sp->phys[node].lnk_rst = 233 + of_reset_control_get_exclusive_by_index(child, 0); 234 + 235 + if (IS_ERR(sp->phys[node].lnk_rst)) { 236 + dev_err(dev, "failed to get reset %s\n", 237 + child->full_name); 238 + ret = PTR_ERR(sp->phys[node].lnk_rst); 239 + goto put_child2; 240 + } 241 + 242 + if (!sp->autoconf) { 243 + ret = cdns_sierra_get_optional(&sp->phys[node], child); 244 + if (ret) { 245 + dev_err(dev, "missing property in node %s\n", 246 + child->name); 247 + goto put_child; 248 + } 249 + } 250 + 251 + gphy = devm_phy_create(dev, child, &ops); 252 + 253 + if (IS_ERR(gphy)) { 254 + ret = PTR_ERR(gphy); 255 + goto put_child; 256 + } 257 + sp->phys[node].phy = gphy; 258 + phy_set_drvdata(gphy, &sp->phys[node]); 259 + 260 + /* Initialise the PHY registers, unless auto configured */ 261 + if (!sp->autoconf) 262 + cdns_sierra_phy_init(gphy); 263 + 264 + node++; 265 + } 266 + sp->nsubnodes = node; 267 + 268 + /* If more than one subnode, configure the PHY as multilink */ 269 + if (!sp->autoconf && sp->nsubnodes > 1) 270 + writel(2, sp->base + SIERRA_PHY_PLL_CFG); 271 + 272 + pm_runtime_enable(dev); 273 + phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate); 274 + reset_control_deassert(sp->phy_rst); 275 + return PTR_ERR_OR_ZERO(phy_provider); 276 + 277 + put_child: 278 + node++; 279 + put_child2: 280 + for (i = 0; i < node; i++) 281 + reset_control_put(sp->phys[i].lnk_rst); 282 + of_node_put(child); 283 + clk_disable: 284 + clk_disable_unprepare(sp->clk); 285 + reset_control_assert(sp->apb_rst); 286 + return ret; 287 + } 288 + 289 + static int cdns_sierra_phy_remove(struct platform_device *pdev) 290 + { 291 + struct cdns_sierra_phy *phy = dev_get_drvdata(pdev->dev.parent); 292 + int i; 293 + 294 + reset_control_assert(phy->phy_rst); 295 + reset_control_assert(phy->apb_rst); 296 + pm_runtime_disable(&pdev->dev); 297 + 298 + /* 299 + * The device level resets will be put automatically. 300 + * Need to put the subnode resets here though. 301 + */ 302 + for (i = 0; i < phy->nsubnodes; i++) { 303 + reset_control_assert(phy->phys[i].lnk_rst); 304 + reset_control_put(phy->phys[i].lnk_rst); 305 + } 306 + return 0; 307 + } 308 + 309 + static struct cdns_reg_pairs cdns_usb_regs[] = { 310 + /* 311 + * Write USB configuration parameters to the PHY. 312 + * These values are specific to this specific hardware 313 + * configuration. 314 + */ 315 + {0xFE0A, SIERRA_DET_STANDEC_A}, 316 + {0x000F, SIERRA_DET_STANDEC_B}, 317 + {0x55A5, SIERRA_DET_STANDEC_C}, 318 + {0x69AD, SIERRA_DET_STANDEC_D}, 319 + {0x0241, SIERRA_DET_STANDEC_E}, 320 + {0x0110, SIERRA_PSM_LANECAL}, 321 + {0xCF00, SIERRA_PSM_DIAG}, 322 + {0x001F, SIERRA_PSC_TX_A0}, 323 + {0x0007, SIERRA_PSC_TX_A1}, 324 + {0x0003, SIERRA_PSC_TX_A2}, 325 + {0x0003, SIERRA_PSC_TX_A3}, 326 + {0x0FFF, SIERRA_PSC_RX_A0}, 327 + {0x0003, SIERRA_PSC_RX_A1}, 328 + {0x0003, SIERRA_PSC_RX_A2}, 329 + {0x0001, SIERRA_PSC_RX_A3}, 330 + {0x0001, SIERRA_PLLCTRL_SUBRATE}, 331 + {0x0406, SIERRA_PLLCTRL_GEN_D}, 332 + {0x0000, SIERRA_DRVCTRL_ATTEN}, 333 + {0x823E, SIERRA_CLKPATHCTRL_TMR}, 334 + {0x078F, SIERRA_RX_CREQ_FLTR_A_MODE1}, 335 + {0x078F, SIERRA_RX_CREQ_FLTR_A_MODE0}, 336 + {0x7B3C, SIERRA_CREQ_CCLKDET_MODE01}, 337 + {0x023C, SIERRA_RX_CTLE_MAINTENANCE}, 338 + {0x3232, SIERRA_CREQ_FSMCLK_SEL}, 339 + {0x8452, SIERRA_CTLELUT_CTRL}, 340 + {0x4121, SIERRA_DFE_ECMP_RATESEL}, 341 + {0x4121, SIERRA_DFE_SMP_RATESEL}, 342 + {0x9999, SIERRA_DEQ_VGATUNE_CTRL}, 343 + {0x0330, SIERRA_TMRVAL_MODE0}, 344 + {0x01FF, SIERRA_PICNT_MODE1}, 345 + {0x0009, SIERRA_CPI_OUTBUF_RATESEL}, 346 + {0x000F, SIERRA_LFPSFILT_NS}, 347 + {0x0009, SIERRA_LFPSFILT_RD}, 348 + {0x0001, SIERRA_LFPSFILT_MP}, 349 + {0x8013, SIERRA_SDFILT_H2L_A}, 350 + {0x0400, SIERRA_TMRVAL_MODE1}, 351 + }; 352 + 353 + static struct cdns_reg_pairs cdns_pcie_regs[] = { 354 + /* 355 + * Write PCIe configuration parameters to the PHY. 356 + * These values are specific to this specific hardware 357 + * configuration. 358 + */ 359 + {0x891f, SIERRA_DET_STANDEC_D}, 360 + {0x0053, SIERRA_DET_STANDEC_E}, 361 + {0x0400, SIERRA_TMRVAL_MODE2}, 362 + {0x0200, SIERRA_TMRVAL_MODE3}, 363 + }; 364 + 365 + static const struct cdns_sierra_data cdns_map_sierra = { 366 + SIERRA_MACRO_ID, 367 + ARRAY_SIZE(cdns_pcie_regs), 368 + ARRAY_SIZE(cdns_usb_regs), 369 + cdns_pcie_regs, 370 + cdns_usb_regs 371 + }; 372 + 373 + static const struct of_device_id cdns_sierra_id_table[] = { 374 + { 375 + .compatible = "cdns,sierra-phy-t0", 376 + .data = &cdns_map_sierra, 377 + }, 378 + {} 379 + }; 380 + MODULE_DEVICE_TABLE(of, cdns_sierra_id_table); 381 + 382 + static struct platform_driver cdns_sierra_driver = { 383 + .probe = cdns_sierra_phy_probe, 384 + .remove = cdns_sierra_phy_remove, 385 + .driver = { 386 + .name = "cdns-sierra-phy", 387 + .of_match_table = cdns_sierra_id_table, 388 + }, 389 + }; 390 + module_platform_driver(cdns_sierra_driver); 391 + 392 + MODULE_ALIAS("platform:cdns_sierra"); 393 + MODULE_AUTHOR("Cadence Design Systems"); 394 + MODULE_DESCRIPTION("CDNS sierra phy driver"); 395 + MODULE_LICENSE("GPL v2");
+5
drivers/phy/freescale/Kconfig
··· 1 + config PHY_FSL_IMX8MQ_USB 2 + tristate "Freescale i.MX8M USB3 PHY" 3 + depends on OF && HAS_IOMEM 4 + select GENERIC_PHY 5 + default SOC_IMX8MQ
+1
drivers/phy/freescale/Makefile
··· 1 + obj-$(CONFIG_PHY_FSL_IMX8MQ_USB) += phy-fsl-imx8mq-usb.o
+127
drivers/phy/freescale/phy-fsl-imx8mq-usb.c
··· 1 + // SPDX-License-Identifier: GPL-2.0+ 2 + /* Copyright (c) 2017 NXP. */ 3 + 4 + #include <linux/clk.h> 5 + #include <linux/io.h> 6 + #include <linux/module.h> 7 + #include <linux/phy/phy.h> 8 + #include <linux/platform_device.h> 9 + 10 + #define PHY_CTRL0 0x0 11 + #define PHY_CTRL0_REF_SSP_EN BIT(2) 12 + 13 + #define PHY_CTRL1 0x4 14 + #define PHY_CTRL1_RESET BIT(0) 15 + #define PHY_CTRL1_COMMONONN BIT(1) 16 + #define PHY_CTRL1_ATERESET BIT(3) 17 + #define PHY_CTRL1_VDATSRCENB0 BIT(19) 18 + #define PHY_CTRL1_VDATDETENB0 BIT(20) 19 + 20 + #define PHY_CTRL2 0x8 21 + #define PHY_CTRL2_TXENABLEN0 BIT(8) 22 + 23 + struct imx8mq_usb_phy { 24 + struct phy *phy; 25 + struct clk *clk; 26 + void __iomem *base; 27 + }; 28 + 29 + static int imx8mq_usb_phy_init(struct phy *phy) 30 + { 31 + struct imx8mq_usb_phy *imx_phy = phy_get_drvdata(phy); 32 + u32 value; 33 + 34 + value = readl(imx_phy->base + PHY_CTRL1); 35 + value &= ~(PHY_CTRL1_VDATSRCENB0 | PHY_CTRL1_VDATDETENB0 | 36 + PHY_CTRL1_COMMONONN); 37 + value |= PHY_CTRL1_RESET | PHY_CTRL1_ATERESET; 38 + writel(value, imx_phy->base + PHY_CTRL1); 39 + 40 + value = readl(imx_phy->base + PHY_CTRL0); 41 + value |= PHY_CTRL0_REF_SSP_EN; 42 + writel(value, imx_phy->base + PHY_CTRL0); 43 + 44 + value = readl(imx_phy->base + PHY_CTRL2); 45 + value |= PHY_CTRL2_TXENABLEN0; 46 + writel(value, imx_phy->base + PHY_CTRL2); 47 + 48 + value = readl(imx_phy->base + PHY_CTRL1); 49 + value &= ~(PHY_CTRL1_RESET | PHY_CTRL1_ATERESET); 50 + writel(value, imx_phy->base + PHY_CTRL1); 51 + 52 + return 0; 53 + } 54 + 55 + static int imx8mq_phy_power_on(struct phy *phy) 56 + { 57 + struct imx8mq_usb_phy *imx_phy = phy_get_drvdata(phy); 58 + 59 + return clk_prepare_enable(imx_phy->clk); 60 + } 61 + 62 + static int imx8mq_phy_power_off(struct phy *phy) 63 + { 64 + struct imx8mq_usb_phy *imx_phy = phy_get_drvdata(phy); 65 + 66 + clk_disable_unprepare(imx_phy->clk); 67 + 68 + return 0; 69 + } 70 + 71 + static struct phy_ops imx8mq_usb_phy_ops = { 72 + .init = imx8mq_usb_phy_init, 73 + .power_on = imx8mq_phy_power_on, 74 + .power_off = imx8mq_phy_power_off, 75 + .owner = THIS_MODULE, 76 + }; 77 + 78 + static int imx8mq_usb_phy_probe(struct platform_device *pdev) 79 + { 80 + struct phy_provider *phy_provider; 81 + struct device *dev = &pdev->dev; 82 + struct imx8mq_usb_phy *imx_phy; 83 + struct resource *res; 84 + 85 + imx_phy = devm_kzalloc(dev, sizeof(*imx_phy), GFP_KERNEL); 86 + if (!imx_phy) 87 + return -ENOMEM; 88 + 89 + imx_phy->clk = devm_clk_get(dev, "phy"); 90 + if (IS_ERR(imx_phy->clk)) { 91 + dev_err(dev, "failed to get imx8mq usb phy clock\n"); 92 + return PTR_ERR(imx_phy->clk); 93 + } 94 + 95 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 96 + imx_phy->base = devm_ioremap_resource(dev, res); 97 + if (IS_ERR(imx_phy->base)) 98 + return PTR_ERR(imx_phy->base); 99 + 100 + imx_phy->phy = devm_phy_create(dev, NULL, &imx8mq_usb_phy_ops); 101 + if (IS_ERR(imx_phy->phy)) 102 + return PTR_ERR(imx_phy->phy); 103 + 104 + phy_set_drvdata(imx_phy->phy, imx_phy); 105 + 106 + phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate); 107 + 108 + return PTR_ERR_OR_ZERO(phy_provider); 109 + } 110 + 111 + static const struct of_device_id imx8mq_usb_phy_of_match[] = { 112 + {.compatible = "fsl,imx8mq-usb-phy",}, 113 + { }, 114 + }; 115 + MODULE_DEVICE_TABLE(of, imx8mq_usb_phy_of_match); 116 + 117 + static struct platform_driver imx8mq_usb_phy_driver = { 118 + .probe = imx8mq_usb_phy_probe, 119 + .driver = { 120 + .name = "imx8mq-usb-phy", 121 + .of_match_table = imx8mq_usb_phy_of_match, 122 + } 123 + }; 124 + module_platform_driver(imx8mq_usb_phy_driver); 125 + 126 + MODULE_DESCRIPTION("FSL IMX8MQ USB PHY driver"); 127 + MODULE_LICENSE("GPL");
+55 -42
drivers/phy/marvell/phy-mvebu-cp110-comphy.c
··· 9 9 #include <linux/iopoll.h> 10 10 #include <linux/mfd/syscon.h> 11 11 #include <linux/module.h> 12 + #include <linux/phy.h> 12 13 #include <linux/phy/phy.h> 13 14 #include <linux/platform_device.h> 14 15 #include <linux/regmap.h> ··· 115 114 #define MVEBU_COMPHY_LANES 6 116 115 #define MVEBU_COMPHY_PORTS 3 117 116 118 - struct mvebu_comhy_conf { 117 + struct mvebu_comphy_conf { 119 118 enum phy_mode mode; 119 + int submode; 120 120 unsigned lane; 121 121 unsigned port; 122 122 u32 mux; 123 123 }; 124 124 125 - #define MVEBU_COMPHY_CONF(_lane, _port, _mode, _mux) \ 125 + #define MVEBU_COMPHY_CONF(_lane, _port, _submode, _mux) \ 126 126 { \ 127 127 .lane = _lane, \ 128 128 .port = _port, \ 129 - .mode = _mode, \ 129 + .mode = PHY_MODE_ETHERNET, \ 130 + .submode = _submode, \ 130 131 .mux = _mux, \ 131 132 } 132 133 133 - static const struct mvebu_comhy_conf mvebu_comphy_cp110_modes[] = { 134 + static const struct mvebu_comphy_conf mvebu_comphy_cp110_modes[] = { 134 135 /* lane 0 */ 135 - MVEBU_COMPHY_CONF(0, 1, PHY_MODE_SGMII, 0x1), 136 - MVEBU_COMPHY_CONF(0, 1, PHY_MODE_2500SGMII, 0x1), 136 + MVEBU_COMPHY_CONF(0, 1, PHY_INTERFACE_MODE_SGMII, 0x1), 137 + MVEBU_COMPHY_CONF(0, 1, PHY_INTERFACE_MODE_2500BASEX, 0x1), 137 138 /* lane 1 */ 138 - MVEBU_COMPHY_CONF(1, 2, PHY_MODE_SGMII, 0x1), 139 - MVEBU_COMPHY_CONF(1, 2, PHY_MODE_2500SGMII, 0x1), 139 + MVEBU_COMPHY_CONF(1, 2, PHY_INTERFACE_MODE_SGMII, 0x1), 140 + MVEBU_COMPHY_CONF(1, 2, PHY_INTERFACE_MODE_2500BASEX, 0x1), 140 141 /* lane 2 */ 141 - MVEBU_COMPHY_CONF(2, 0, PHY_MODE_SGMII, 0x1), 142 - MVEBU_COMPHY_CONF(2, 0, PHY_MODE_2500SGMII, 0x1), 143 - MVEBU_COMPHY_CONF(2, 0, PHY_MODE_10GKR, 0x1), 142 + MVEBU_COMPHY_CONF(2, 0, PHY_INTERFACE_MODE_SGMII, 0x1), 143 + MVEBU_COMPHY_CONF(2, 0, PHY_INTERFACE_MODE_2500BASEX, 0x1), 144 + MVEBU_COMPHY_CONF(2, 0, PHY_INTERFACE_MODE_10GKR, 0x1), 144 145 /* lane 3 */ 145 - MVEBU_COMPHY_CONF(3, 1, PHY_MODE_SGMII, 0x2), 146 - MVEBU_COMPHY_CONF(3, 1, PHY_MODE_2500SGMII, 0x2), 146 + MVEBU_COMPHY_CONF(3, 1, PHY_INTERFACE_MODE_SGMII, 0x2), 147 + MVEBU_COMPHY_CONF(3, 1, PHY_INTERFACE_MODE_2500BASEX, 0x2), 147 148 /* lane 4 */ 148 - MVEBU_COMPHY_CONF(4, 0, PHY_MODE_SGMII, 0x2), 149 - MVEBU_COMPHY_CONF(4, 0, PHY_MODE_2500SGMII, 0x2), 150 - MVEBU_COMPHY_CONF(4, 0, PHY_MODE_10GKR, 0x2), 151 - MVEBU_COMPHY_CONF(4, 1, PHY_MODE_SGMII, 0x1), 149 + MVEBU_COMPHY_CONF(4, 0, PHY_INTERFACE_MODE_SGMII, 0x2), 150 + MVEBU_COMPHY_CONF(4, 0, PHY_INTERFACE_MODE_2500BASEX, 0x2), 151 + MVEBU_COMPHY_CONF(4, 0, PHY_INTERFACE_MODE_10GKR, 0x2), 152 + MVEBU_COMPHY_CONF(4, 1, PHY_INTERFACE_MODE_SGMII, 0x1), 152 153 /* lane 5 */ 153 - MVEBU_COMPHY_CONF(5, 2, PHY_MODE_SGMII, 0x1), 154 - MVEBU_COMPHY_CONF(5, 2, PHY_MODE_2500SGMII, 0x1), 154 + MVEBU_COMPHY_CONF(5, 2, PHY_INTERFACE_MODE_SGMII, 0x1), 155 + MVEBU_COMPHY_CONF(5, 2, PHY_INTERFACE_MODE_2500BASEX, 0x1), 155 156 }; 156 157 157 158 struct mvebu_comphy_priv { ··· 166 163 struct mvebu_comphy_priv *priv; 167 164 unsigned id; 168 165 enum phy_mode mode; 166 + int submode; 169 167 int port; 170 168 }; 171 169 172 - static int mvebu_comphy_get_mux(int lane, int port, enum phy_mode mode) 170 + static int mvebu_comphy_get_mux(int lane, int port, 171 + enum phy_mode mode, int submode) 173 172 { 174 173 int i, n = ARRAY_SIZE(mvebu_comphy_cp110_modes); 175 174 ··· 182 177 for (i = 0; i < n; i++) { 183 178 if (mvebu_comphy_cp110_modes[i].lane == lane && 184 179 mvebu_comphy_cp110_modes[i].port == port && 185 - mvebu_comphy_cp110_modes[i].mode == mode) 180 + mvebu_comphy_cp110_modes[i].mode == mode && 181 + mvebu_comphy_cp110_modes[i].submode == submode) 186 182 break; 187 183 } 188 184 ··· 193 187 return mvebu_comphy_cp110_modes[i].mux; 194 188 } 195 189 196 - static void mvebu_comphy_ethernet_init_reset(struct mvebu_comphy_lane *lane, 197 - enum phy_mode mode) 190 + static void mvebu_comphy_ethernet_init_reset(struct mvebu_comphy_lane *lane) 198 191 { 199 192 struct mvebu_comphy_priv *priv = lane->priv; 200 193 u32 val; ··· 211 206 MVEBU_COMPHY_SERDES_CFG0_HALF_BUS | 212 207 MVEBU_COMPHY_SERDES_CFG0_GEN_RX(0xf) | 213 208 MVEBU_COMPHY_SERDES_CFG0_GEN_TX(0xf)); 214 - if (mode == PHY_MODE_10GKR) 209 + if (lane->submode == PHY_INTERFACE_MODE_10GKR) 215 210 val |= MVEBU_COMPHY_SERDES_CFG0_GEN_RX(0xe) | 216 211 MVEBU_COMPHY_SERDES_CFG0_GEN_TX(0xe); 217 - else if (mode == PHY_MODE_2500SGMII) 212 + else if (lane->submode == PHY_INTERFACE_MODE_2500BASEX) 218 213 val |= MVEBU_COMPHY_SERDES_CFG0_GEN_RX(0x8) | 219 214 MVEBU_COMPHY_SERDES_CFG0_GEN_TX(0x8) | 220 215 MVEBU_COMPHY_SERDES_CFG0_HALF_BUS; 221 - else if (mode == PHY_MODE_SGMII) 216 + else if (lane->submode == PHY_INTERFACE_MODE_SGMII) 222 217 val |= MVEBU_COMPHY_SERDES_CFG0_GEN_RX(0x6) | 223 218 MVEBU_COMPHY_SERDES_CFG0_GEN_TX(0x6) | 224 219 MVEBU_COMPHY_SERDES_CFG0_HALF_BUS; ··· 248 243 /* refclk selection */ 249 244 val = readl(priv->base + MVEBU_COMPHY_MISC_CTRL0(lane->id)); 250 245 val &= ~MVEBU_COMPHY_MISC_CTRL0_REFCLK_SEL; 251 - if (mode == PHY_MODE_10GKR) 246 + if (lane->submode == PHY_INTERFACE_MODE_10GKR) 252 247 val |= MVEBU_COMPHY_MISC_CTRL0_ICP_FORCE; 253 248 writel(val, priv->base + MVEBU_COMPHY_MISC_CTRL0(lane->id)); 254 249 ··· 266 261 writel(val, priv->base + MVEBU_COMPHY_LOOPBACK(lane->id)); 267 262 } 268 263 269 - static int mvebu_comphy_init_plls(struct mvebu_comphy_lane *lane, 270 - enum phy_mode mode) 264 + static int mvebu_comphy_init_plls(struct mvebu_comphy_lane *lane) 271 265 { 272 266 struct mvebu_comphy_priv *priv = lane->priv; 273 267 u32 val; ··· 307 303 return 0; 308 304 } 309 305 310 - static int mvebu_comphy_set_mode_sgmii(struct phy *phy, enum phy_mode mode) 306 + static int mvebu_comphy_set_mode_sgmii(struct phy *phy) 311 307 { 312 308 struct mvebu_comphy_lane *lane = phy_get_drvdata(phy); 313 309 struct mvebu_comphy_priv *priv = lane->priv; 314 310 u32 val; 315 311 316 - mvebu_comphy_ethernet_init_reset(lane, mode); 312 + mvebu_comphy_ethernet_init_reset(lane); 317 313 318 314 val = readl(priv->base + MVEBU_COMPHY_RX_CTRL1(lane->id)); 319 315 val &= ~MVEBU_COMPHY_RX_CTRL1_CLK8T_EN; ··· 334 330 val |= MVEBU_COMPHY_GEN1_S0_TX_EMPH(0x1); 335 331 writel(val, priv->base + MVEBU_COMPHY_GEN1_S0(lane->id)); 336 332 337 - return mvebu_comphy_init_plls(lane, PHY_MODE_SGMII); 333 + return mvebu_comphy_init_plls(lane); 338 334 } 339 335 340 336 static int mvebu_comphy_set_mode_10gkr(struct phy *phy) ··· 343 339 struct mvebu_comphy_priv *priv = lane->priv; 344 340 u32 val; 345 341 346 - mvebu_comphy_ethernet_init_reset(lane, PHY_MODE_10GKR); 342 + mvebu_comphy_ethernet_init_reset(lane); 347 343 348 344 val = readl(priv->base + MVEBU_COMPHY_RX_CTRL1(lane->id)); 349 345 val |= MVEBU_COMPHY_RX_CTRL1_RXCLK2X_SEL | ··· 473 469 val |= MVEBU_COMPHY_EXT_SELV_RX_SAMPL(0x1a); 474 470 writel(val, priv->base + MVEBU_COMPHY_EXT_SELV(lane->id)); 475 471 476 - return mvebu_comphy_init_plls(lane, PHY_MODE_10GKR); 472 + return mvebu_comphy_init_plls(lane); 477 473 } 478 474 479 475 static int mvebu_comphy_power_on(struct phy *phy) ··· 483 479 int ret, mux; 484 480 u32 val; 485 481 486 - mux = mvebu_comphy_get_mux(lane->id, lane->port, lane->mode); 482 + mux = mvebu_comphy_get_mux(lane->id, lane->port, 483 + lane->mode, lane->submode); 487 484 if (mux < 0) 488 485 return -ENOTSUPP; 489 486 ··· 497 492 val |= mux << MVEBU_COMPHY_SELECTOR_PHY(lane->id); 498 493 regmap_write(priv->regmap, MVEBU_COMPHY_SELECTOR, val); 499 494 500 - switch (lane->mode) { 501 - case PHY_MODE_SGMII: 502 - case PHY_MODE_2500SGMII: 503 - ret = mvebu_comphy_set_mode_sgmii(phy, lane->mode); 495 + switch (lane->submode) { 496 + case PHY_INTERFACE_MODE_SGMII: 497 + case PHY_INTERFACE_MODE_2500BASEX: 498 + ret = mvebu_comphy_set_mode_sgmii(phy); 504 499 break; 505 - case PHY_MODE_10GKR: 500 + case PHY_INTERFACE_MODE_10GKR: 506 501 ret = mvebu_comphy_set_mode_10gkr(phy); 507 502 break; 508 503 default: ··· 517 512 return ret; 518 513 } 519 514 520 - static int mvebu_comphy_set_mode(struct phy *phy, enum phy_mode mode) 515 + static int mvebu_comphy_set_mode(struct phy *phy, 516 + enum phy_mode mode, int submode) 521 517 { 522 518 struct mvebu_comphy_lane *lane = phy_get_drvdata(phy); 523 519 524 - if (mvebu_comphy_get_mux(lane->id, lane->port, mode) < 0) 520 + if (mode != PHY_MODE_ETHERNET) 521 + return -EINVAL; 522 + 523 + if (submode == PHY_INTERFACE_MODE_1000BASEX) 524 + submode = PHY_INTERFACE_MODE_SGMII; 525 + 526 + if (mvebu_comphy_get_mux(lane->id, lane->port, mode, submode) < 0) 525 527 return -EINVAL; 526 528 527 529 lane->mode = mode; 530 + lane->submode = submode; 528 531 return 0; 529 532 } 530 533
+1 -1
drivers/phy/mediatek/phy-mtk-tphy.c
··· 971 971 return 0; 972 972 } 973 973 974 - static int mtk_phy_set_mode(struct phy *phy, enum phy_mode mode) 974 + static int mtk_phy_set_mode(struct phy *phy, enum phy_mode mode, int submode) 975 975 { 976 976 struct mtk_phy_instance *instance = phy_get_drvdata(phy); 977 977 struct mtk_tphy *tphy = dev_get_drvdata(phy->dev.parent);
+1 -1
drivers/phy/mediatek/phy-mtk-xsphy.c
··· 426 426 return 0; 427 427 } 428 428 429 - static int mtk_phy_set_mode(struct phy *phy, enum phy_mode mode) 429 + static int mtk_phy_set_mode(struct phy *phy, enum phy_mode mode, int submode) 430 430 { 431 431 struct xsphy_instance *inst = phy_get_drvdata(phy); 432 432 struct mtk_xsphy *xsphy = dev_get_drvdata(phy->dev.parent);
+51 -20
drivers/phy/motorola/phy-mapphone-mdm6600.c
··· 16 16 #include <linux/gpio/consumer.h> 17 17 #include <linux/of_platform.h> 18 18 #include <linux/phy/phy.h> 19 + #include <linux/pinctrl/consumer.h> 19 20 20 21 #define PHY_MDM6600_PHY_DELAY_MS 4000 /* PHY enable 2.2s to 3.5s */ 21 22 #define PHY_MDM6600_ENABLED_DELAY_MS 8000 /* 8s more total for MDM6600 */ ··· 121 120 { 122 121 struct phy_mdm6600 *ddata = phy_get_drvdata(x); 123 122 struct gpio_desc *enable_gpio = ddata->ctrl_gpios[PHY_MDM6600_ENABLE]; 123 + int error; 124 124 125 125 if (!ddata->enabled) 126 126 return -ENODEV; 127 127 128 + error = pinctrl_pm_select_default_state(ddata->dev); 129 + if (error) 130 + dev_warn(ddata->dev, "%s: error with default_state: %i\n", 131 + __func__, error); 132 + 128 133 gpiod_set_value_cansleep(enable_gpio, 1); 134 + 135 + /* Allow aggressive PM for USB, it's only needed for n_gsm port */ 136 + if (pm_runtime_enabled(&x->dev)) 137 + phy_pm_runtime_put(x); 129 138 130 139 return 0; 131 140 } ··· 144 133 { 145 134 struct phy_mdm6600 *ddata = phy_get_drvdata(x); 146 135 struct gpio_desc *enable_gpio = ddata->ctrl_gpios[PHY_MDM6600_ENABLE]; 136 + int error; 147 137 148 138 if (!ddata->enabled) 149 139 return -ENODEV; 150 140 141 + /* Paired with phy_pm_runtime_put() in phy_mdm6600_power_on() */ 142 + if (pm_runtime_enabled(&x->dev)) { 143 + error = phy_pm_runtime_get(x); 144 + if (error < 0 && error != -EINPROGRESS) 145 + dev_warn(ddata->dev, "%s: phy_pm_runtime_get: %i\n", 146 + __func__, error); 147 + } 148 + 151 149 gpiod_set_value_cansleep(enable_gpio, 0); 150 + 151 + error = pinctrl_pm_select_sleep_state(ddata->dev); 152 + if (error) 153 + dev_warn(ddata->dev, "%s: error with sleep_state: %i\n", 154 + __func__, error); 152 155 153 156 return 0; 154 157 } ··· 554 529 ddata->dev = &pdev->dev; 555 530 platform_set_drvdata(pdev, ddata); 556 531 532 + /* Active state selected in phy_mdm6600_power_on() */ 533 + error = pinctrl_pm_select_sleep_state(ddata->dev); 534 + if (error) 535 + dev_warn(ddata->dev, "%s: error with sleep_state: %i\n", 536 + __func__, error); 537 + 557 538 error = phy_mdm6600_init_lines(ddata); 558 539 if (error) 559 540 return error; 560 541 561 542 phy_mdm6600_init_irq(ddata); 562 - 563 - ddata->generic_phy = devm_phy_create(ddata->dev, NULL, &gpio_usb_ops); 564 - if (IS_ERR(ddata->generic_phy)) { 565 - error = PTR_ERR(ddata->generic_phy); 566 - goto cleanup; 567 - } 568 - 569 - phy_set_drvdata(ddata->generic_phy, ddata); 570 - 571 - ddata->phy_provider = 572 - devm_of_phy_provider_register(ddata->dev, 573 - of_phy_simple_xlate); 574 - if (IS_ERR(ddata->phy_provider)) { 575 - error = PTR_ERR(ddata->phy_provider); 576 - goto cleanup; 577 - } 578 - 579 543 schedule_delayed_work(&ddata->bootup_work, 0); 580 544 581 545 /* ··· 588 574 if (error < 0) { 589 575 dev_warn(ddata->dev, "failed to wake modem: %i\n", error); 590 576 pm_runtime_put_noidle(ddata->dev); 577 + goto cleanup; 591 578 } 579 + 580 + ddata->generic_phy = devm_phy_create(ddata->dev, NULL, &gpio_usb_ops); 581 + if (IS_ERR(ddata->generic_phy)) { 582 + error = PTR_ERR(ddata->generic_phy); 583 + goto idle; 584 + } 585 + 586 + phy_set_drvdata(ddata->generic_phy, ddata); 587 + 588 + ddata->phy_provider = 589 + devm_of_phy_provider_register(ddata->dev, 590 + of_phy_simple_xlate); 591 + if (IS_ERR(ddata->phy_provider)) 592 + error = PTR_ERR(ddata->phy_provider); 593 + 594 + idle: 592 595 pm_runtime_mark_last_busy(ddata->dev); 593 596 pm_runtime_put_autosuspend(ddata->dev); 594 597 595 - return 0; 596 - 597 598 cleanup: 598 - phy_mdm6600_device_power_off(ddata); 599 + if (error < 0) 600 + phy_mdm6600_device_power_off(ddata); 601 + 599 602 return error; 600 603 } 601 604
+17 -7
drivers/phy/mscc/phy-ocelot-serdes.c
··· 11 11 #include <linux/module.h> 12 12 #include <linux/of.h> 13 13 #include <linux/of_platform.h> 14 + #include <linux/phy.h> 14 15 #include <linux/phy/phy.h> 15 16 #include <linux/platform_device.h> 16 17 #include <linux/regmap.h> ··· 105 104 u8 idx; 106 105 u8 port; 107 106 enum phy_mode mode; 107 + int submode; 108 108 u32 mask; 109 109 u32 mux; 110 110 }; 111 111 112 - #define SERDES_MUX(_idx, _port, _mode, _mask, _mux) { \ 112 + #define SERDES_MUX(_idx, _port, _mode, _submode, _mask, _mux) { \ 113 113 .idx = _idx, \ 114 114 .port = _port, \ 115 115 .mode = _mode, \ 116 + .submode = _submode, \ 116 117 .mask = _mask, \ 117 118 .mux = _mux, \ 118 119 } 119 120 120 - #define SERDES_MUX_SGMII(i, p, m, c) SERDES_MUX(i, p, PHY_MODE_SGMII, m, c) 121 - #define SERDES_MUX_QSGMII(i, p, m, c) SERDES_MUX(i, p, PHY_MODE_QSGMII, m, c) 121 + #define SERDES_MUX_SGMII(i, p, m, c) \ 122 + SERDES_MUX(i, p, PHY_MODE_ETHERNET, PHY_INTERFACE_MODE_SGMII, m, c) 123 + #define SERDES_MUX_QSGMII(i, p, m, c) \ 124 + SERDES_MUX(i, p, PHY_MODE_ETHERNET, PHY_INTERFACE_MODE_QSGMII, m, c) 122 125 123 126 static const struct serdes_mux ocelot_serdes_muxes[] = { 124 127 SERDES_MUX_SGMII(SERDES1G(0), 0, 0, 0), ··· 159 154 SERDES_MUX_SGMII(SERDES6G(1), 8, 0, 0), 160 155 SERDES_MUX_SGMII(SERDES6G(2), 10, HSIO_HW_CFG_PCIE_ENA | 161 156 HSIO_HW_CFG_DEV2G5_10_MODE, 0), 162 - SERDES_MUX(SERDES6G(2), 10, PHY_MODE_PCIE, HSIO_HW_CFG_PCIE_ENA, 157 + SERDES_MUX(SERDES6G(2), 10, PHY_MODE_PCIE, 0, HSIO_HW_CFG_PCIE_ENA, 163 158 HSIO_HW_CFG_PCIE_ENA), 164 159 }; 165 160 166 - static int serdes_set_mode(struct phy *phy, enum phy_mode mode) 161 + static int serdes_set_mode(struct phy *phy, enum phy_mode mode, int submode) 167 162 { 168 163 struct serdes_macro *macro = phy_get_drvdata(phy); 169 164 unsigned int i; 170 165 int ret; 171 166 167 + /* As of now only PHY_MODE_ETHERNET is supported */ 168 + if (mode != PHY_MODE_ETHERNET) 169 + return -EOPNOTSUPP; 170 + 172 171 for (i = 0; i < ARRAY_SIZE(ocelot_serdes_muxes); i++) { 173 172 if (macro->idx != ocelot_serdes_muxes[i].idx || 174 - mode != ocelot_serdes_muxes[i].mode) 173 + mode != ocelot_serdes_muxes[i].mode || 174 + submode != ocelot_serdes_muxes[i].submode) 175 175 continue; 176 176 177 - if (mode != PHY_MODE_QSGMII && 177 + if (submode != PHY_INTERFACE_MODE_QSGMII && 178 178 macro->port != ocelot_serdes_muxes[i].port) 179 179 continue; 180 180
+166
drivers/phy/phy-core-mipi-dphy.c
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + /* 3 + * Copyright (C) 2013 NVIDIA Corporation 4 + * Copyright (C) 2018 Cadence Design Systems Inc. 5 + */ 6 + 7 + #include <linux/errno.h> 8 + #include <linux/export.h> 9 + #include <linux/kernel.h> 10 + #include <linux/time64.h> 11 + 12 + #include <linux/phy/phy.h> 13 + #include <linux/phy/phy-mipi-dphy.h> 14 + 15 + #define PSEC_PER_SEC 1000000000000LL 16 + 17 + /* 18 + * Minimum D-PHY timings based on MIPI D-PHY specification. Derived 19 + * from the valid ranges specified in Section 6.9, Table 14, Page 41 20 + * of the D-PHY specification (v2.1). 21 + */ 22 + int phy_mipi_dphy_get_default_config(unsigned long pixel_clock, 23 + unsigned int bpp, 24 + unsigned int lanes, 25 + struct phy_configure_opts_mipi_dphy *cfg) 26 + { 27 + unsigned long long hs_clk_rate; 28 + unsigned long long ui; 29 + 30 + if (!cfg) 31 + return -EINVAL; 32 + 33 + hs_clk_rate = pixel_clock * bpp; 34 + do_div(hs_clk_rate, lanes); 35 + 36 + ui = ALIGN(PSEC_PER_SEC, hs_clk_rate); 37 + do_div(ui, hs_clk_rate); 38 + 39 + cfg->clk_miss = 0; 40 + cfg->clk_post = 60000 + 52 * ui; 41 + cfg->clk_pre = 8000; 42 + cfg->clk_prepare = 38000; 43 + cfg->clk_settle = 95000; 44 + cfg->clk_term_en = 0; 45 + cfg->clk_trail = 60000; 46 + cfg->clk_zero = 262000; 47 + cfg->d_term_en = 0; 48 + cfg->eot = 0; 49 + cfg->hs_exit = 100000; 50 + cfg->hs_prepare = 40000 + 4 * ui; 51 + cfg->hs_zero = 105000 + 6 * ui; 52 + cfg->hs_settle = 85000 + 6 * ui; 53 + cfg->hs_skip = 40000; 54 + 55 + /* 56 + * The MIPI D-PHY specification (Section 6.9, v1.2, Table 14, Page 40) 57 + * contains this formula as: 58 + * 59 + * T_HS-TRAIL = max(n * 8 * ui, 60 + n * 4 * ui) 60 + * 61 + * where n = 1 for forward-direction HS mode and n = 4 for reverse- 62 + * direction HS mode. There's only one setting and this function does 63 + * not parameterize on anything other that ui, so this code will 64 + * assumes that reverse-direction HS mode is supported and uses n = 4. 65 + */ 66 + cfg->hs_trail = max(4 * 8 * ui, 60000 + 4 * 4 * ui); 67 + 68 + cfg->init = 100000000; 69 + cfg->lpx = 60000; 70 + cfg->ta_get = 5 * cfg->lpx; 71 + cfg->ta_go = 4 * cfg->lpx; 72 + cfg->ta_sure = 2 * cfg->lpx; 73 + cfg->wakeup = 1000000000; 74 + 75 + cfg->hs_clk_rate = hs_clk_rate; 76 + cfg->lanes = lanes; 77 + 78 + return 0; 79 + } 80 + EXPORT_SYMBOL(phy_mipi_dphy_get_default_config); 81 + 82 + /* 83 + * Validate D-PHY configuration according to MIPI D-PHY specification 84 + * (v1.2, Section Section 6.9 "Global Operation Timing Parameters"). 85 + */ 86 + int phy_mipi_dphy_config_validate(struct phy_configure_opts_mipi_dphy *cfg) 87 + { 88 + unsigned long long ui; 89 + 90 + if (!cfg) 91 + return -EINVAL; 92 + 93 + ui = ALIGN(PSEC_PER_SEC, cfg->hs_clk_rate); 94 + do_div(ui, cfg->hs_clk_rate); 95 + 96 + if (cfg->clk_miss > 60000) 97 + return -EINVAL; 98 + 99 + if (cfg->clk_post < (60000 + 52 * ui)) 100 + return -EINVAL; 101 + 102 + if (cfg->clk_pre < 8000) 103 + return -EINVAL; 104 + 105 + if (cfg->clk_prepare < 38000 || cfg->clk_prepare > 95000) 106 + return -EINVAL; 107 + 108 + if (cfg->clk_settle < 95000 || cfg->clk_settle > 300000) 109 + return -EINVAL; 110 + 111 + if (cfg->clk_term_en > 38000) 112 + return -EINVAL; 113 + 114 + if (cfg->clk_trail < 60000) 115 + return -EINVAL; 116 + 117 + if ((cfg->clk_prepare + cfg->clk_zero) < 300000) 118 + return -EINVAL; 119 + 120 + if (cfg->d_term_en > (35000 + 4 * ui)) 121 + return -EINVAL; 122 + 123 + if (cfg->eot > (105000 + 12 * ui)) 124 + return -EINVAL; 125 + 126 + if (cfg->hs_exit < 100000) 127 + return -EINVAL; 128 + 129 + if (cfg->hs_prepare < (40000 + 4 * ui) || 130 + cfg->hs_prepare > (85000 + 6 * ui)) 131 + return -EINVAL; 132 + 133 + if ((cfg->hs_prepare + cfg->hs_zero) < (145000 + 10 * ui)) 134 + return -EINVAL; 135 + 136 + if ((cfg->hs_settle < (85000 + 6 * ui)) || 137 + (cfg->hs_settle > (145000 + 10 * ui))) 138 + return -EINVAL; 139 + 140 + if (cfg->hs_skip < 40000 || cfg->hs_skip > (55000 + 4 * ui)) 141 + return -EINVAL; 142 + 143 + if (cfg->hs_trail < max(8 * ui, 60000 + 4 * ui)) 144 + return -EINVAL; 145 + 146 + if (cfg->init < 100000000) 147 + return -EINVAL; 148 + 149 + if (cfg->lpx < 50000) 150 + return -EINVAL; 151 + 152 + if (cfg->ta_get != (5 * cfg->lpx)) 153 + return -EINVAL; 154 + 155 + if (cfg->ta_go != (4 * cfg->lpx)) 156 + return -EINVAL; 157 + 158 + if (cfg->ta_sure < cfg->lpx || cfg->ta_sure > (2 * cfg->lpx)) 159 + return -EINVAL; 160 + 161 + if (cfg->wakeup < 1000000000) 162 + return -EINVAL; 163 + 164 + return 0; 165 + } 166 + EXPORT_SYMBOL(phy_mipi_dphy_config_validate);
+67 -3
drivers/phy/phy-core.c
··· 360 360 } 361 361 EXPORT_SYMBOL_GPL(phy_power_off); 362 362 363 - int phy_set_mode(struct phy *phy, enum phy_mode mode) 363 + int phy_set_mode_ext(struct phy *phy, enum phy_mode mode, int submode) 364 364 { 365 365 int ret; 366 366 ··· 368 368 return 0; 369 369 370 370 mutex_lock(&phy->mutex); 371 - ret = phy->ops->set_mode(phy, mode); 371 + ret = phy->ops->set_mode(phy, mode, submode); 372 372 if (!ret) 373 373 phy->attrs.mode = mode; 374 374 mutex_unlock(&phy->mutex); 375 375 376 376 return ret; 377 377 } 378 - EXPORT_SYMBOL_GPL(phy_set_mode); 378 + EXPORT_SYMBOL_GPL(phy_set_mode_ext); 379 379 380 380 int phy_reset(struct phy *phy) 381 381 { ··· 406 406 return ret; 407 407 } 408 408 EXPORT_SYMBOL_GPL(phy_calibrate); 409 + 410 + /** 411 + * phy_configure() - Changes the phy parameters 412 + * @phy: the phy returned by phy_get() 413 + * @opts: New configuration to apply 414 + * 415 + * Used to change the PHY parameters. phy_init() must have been called 416 + * on the phy. The configuration will be applied on the current phy 417 + * mode, that can be changed using phy_set_mode(). 418 + * 419 + * Returns: 0 if successful, an negative error code otherwise 420 + */ 421 + int phy_configure(struct phy *phy, union phy_configure_opts *opts) 422 + { 423 + int ret; 424 + 425 + if (!phy) 426 + return -EINVAL; 427 + 428 + if (!phy->ops->configure) 429 + return -EOPNOTSUPP; 430 + 431 + mutex_lock(&phy->mutex); 432 + ret = phy->ops->configure(phy, opts); 433 + mutex_unlock(&phy->mutex); 434 + 435 + return ret; 436 + } 437 + EXPORT_SYMBOL_GPL(phy_configure); 438 + 439 + /** 440 + * phy_validate() - Checks the phy parameters 441 + * @phy: the phy returned by phy_get() 442 + * @mode: phy_mode the configuration is applicable to. 443 + * @submode: PHY submode the configuration is applicable to. 444 + * @opts: Configuration to check 445 + * 446 + * Used to check that the current set of parameters can be handled by 447 + * the phy. Implementations are free to tune the parameters passed as 448 + * arguments if needed by some implementation detail or 449 + * constraints. It will not change any actual configuration of the 450 + * PHY, so calling it as many times as deemed fit will have no side 451 + * effect. 452 + * 453 + * Returns: 0 if successful, an negative error code otherwise 454 + */ 455 + int phy_validate(struct phy *phy, enum phy_mode mode, int submode, 456 + union phy_configure_opts *opts) 457 + { 458 + int ret; 459 + 460 + if (!phy) 461 + return -EINVAL; 462 + 463 + if (!phy->ops->validate) 464 + return -EOPNOTSUPP; 465 + 466 + mutex_lock(&phy->mutex); 467 + ret = phy->ops->validate(phy, mode, submode, opts); 468 + mutex_unlock(&phy->mutex); 469 + 470 + return ret; 471 + } 472 + EXPORT_SYMBOL_GPL(phy_validate); 409 473 410 474 /** 411 475 * _of_phy_get() - lookup and obtain a reference to a phy by phandle
+62 -15
drivers/phy/qualcomm/phy-qcom-qmp.c
··· 72 72 73 73 #define MAX_PROP_NAME 32 74 74 75 + /* Define the assumed distance between lanes for underspecified device trees. */ 76 + #define QMP_PHY_LEGACY_LANE_STRIDE 0x400 77 + 75 78 struct qmp_phy_init_tbl { 76 79 unsigned int offset; 77 80 unsigned int val; ··· 736 733 bool has_phy_dp_com_ctrl; 737 734 /* true, if PHY has secondary tx/rx lanes to be configured */ 738 735 bool is_dual_lane_phy; 739 - /* Register offset of secondary tx/rx lanes for USB DP combo PHY */ 740 - unsigned int tx_b_lane_offset; 741 - unsigned int rx_b_lane_offset; 742 736 743 737 /* true, if PCS block has no separate SW_RESET register */ 744 738 bool no_pcs_sw_reset; ··· 748 748 * @tx: iomapped memory space for lane's tx 749 749 * @rx: iomapped memory space for lane's rx 750 750 * @pcs: iomapped memory space for lane's pcs 751 + * @tx2: iomapped memory space for second lane's tx (in dual lane PHYs) 752 + * @rx2: iomapped memory space for second lane's rx (in dual lane PHYs) 751 753 * @pcs_misc: iomapped memory space for lane's pcs_misc 752 754 * @pipe_clk: pipe lock 753 755 * @index: lane index ··· 761 759 void __iomem *tx; 762 760 void __iomem *rx; 763 761 void __iomem *pcs; 762 + void __iomem *tx2; 763 + void __iomem *rx2; 764 764 void __iomem *pcs_misc; 765 765 struct clk *pipe_clk; 766 766 unsigned int index; ··· 979 975 980 976 .has_phy_dp_com_ctrl = true, 981 977 .is_dual_lane_phy = true, 982 - .tx_b_lane_offset = 0x400, 983 - .rx_b_lane_offset = 0x400, 984 978 }; 985 979 986 980 static const struct qmp_phy_cfg qmp_v3_usb3_uniphy_cfg = { ··· 1033 1031 .mask_pcs_ready = PCS_READY, 1034 1032 1035 1033 .is_dual_lane_phy = true, 1036 - .tx_b_lane_offset = 0x400, 1037 - .rx_b_lane_offset = 0x400, 1038 - 1039 1034 .no_pcs_sw_reset = true, 1040 1035 }; 1041 1036 ··· 1237 1238 qcom_qmp_phy_configure(tx, cfg->regs, cfg->tx_tbl, cfg->tx_tbl_num); 1238 1239 /* Configuration for other LANE for USB-DP combo PHY */ 1239 1240 if (cfg->is_dual_lane_phy) 1240 - qcom_qmp_phy_configure(tx + cfg->tx_b_lane_offset, cfg->regs, 1241 + qcom_qmp_phy_configure(qphy->tx2, cfg->regs, 1241 1242 cfg->tx_tbl, cfg->tx_tbl_num); 1242 1243 1243 1244 qcom_qmp_phy_configure(rx, cfg->regs, cfg->rx_tbl, cfg->rx_tbl_num); 1244 1245 if (cfg->is_dual_lane_phy) 1245 - qcom_qmp_phy_configure(rx + cfg->rx_b_lane_offset, cfg->regs, 1246 + qcom_qmp_phy_configure(qphy->rx2, cfg->regs, 1246 1247 cfg->rx_tbl, cfg->rx_tbl_num); 1247 1248 1248 1249 qcom_qmp_phy_configure(pcs, cfg->regs, cfg->pcs_tbl, cfg->pcs_tbl_num); ··· 1364 1365 return ret; 1365 1366 } 1366 1367 1367 - static int qcom_qmp_phy_set_mode(struct phy *phy, enum phy_mode mode) 1368 + static int qcom_qmp_phy_set_mode(struct phy *phy, 1369 + enum phy_mode mode, int submode) 1368 1370 { 1369 1371 struct qmp_phy *qphy = phy_get_drvdata(phy); 1370 1372 struct qcom_qmp *qmp = qphy->qmp; ··· 1542 1542 return devm_clk_bulk_get(dev, num, qmp->clks); 1543 1543 } 1544 1544 1545 + static void phy_pipe_clk_release_provider(void *res) 1546 + { 1547 + of_clk_del_provider(res); 1548 + } 1549 + 1545 1550 /* 1546 1551 * Register a fixed rate pipe clock. 1547 1552 * ··· 1593 1588 fixed->fixed_rate = 125000000; 1594 1589 fixed->hw.init = &init; 1595 1590 1596 - return devm_clk_hw_register(qmp->dev, &fixed->hw); 1591 + ret = devm_clk_hw_register(qmp->dev, &fixed->hw); 1592 + if (ret) 1593 + return ret; 1594 + 1595 + ret = of_clk_add_hw_provider(np, of_clk_hw_simple_get, &fixed->hw); 1596 + if (ret) 1597 + return ret; 1598 + 1599 + /* 1600 + * Roll a devm action because the clock provider is the child node, but 1601 + * the child node is not actually a device. 1602 + */ 1603 + ret = devm_add_action(qmp->dev, phy_pipe_clk_release_provider, np); 1604 + if (ret) 1605 + phy_pipe_clk_release_provider(np); 1606 + 1607 + return ret; 1597 1608 } 1598 1609 1599 1610 static const struct phy_ops qcom_qmp_phy_gen_ops = { ··· 1635 1614 1636 1615 /* 1637 1616 * Get memory resources for each phy lane: 1638 - * Resources are indexed as: tx -> 0; rx -> 1; pcs -> 2; and 1639 - * pcs_misc (optional) -> 3. 1617 + * Resources are indexed as: tx -> 0; rx -> 1; pcs -> 2. 1618 + * For dual lane PHYs: tx2 -> 3, rx2 -> 4, pcs_misc (optional) -> 5 1619 + * For single lane PHYs: pcs_misc (optional) -> 3. 1640 1620 */ 1641 1621 qphy->tx = of_iomap(np, 0); 1642 1622 if (!qphy->tx) ··· 1651 1629 if (!qphy->pcs) 1652 1630 return -ENOMEM; 1653 1631 1654 - qphy->pcs_misc = of_iomap(np, 3); 1632 + /* 1633 + * If this is a dual-lane PHY, then there should be registers for the 1634 + * second lane. Some old device trees did not specify this, so fall 1635 + * back to old legacy behavior of assuming they can be reached at an 1636 + * offset from the first lane. 1637 + */ 1638 + if (qmp->cfg->is_dual_lane_phy) { 1639 + qphy->tx2 = of_iomap(np, 3); 1640 + qphy->rx2 = of_iomap(np, 4); 1641 + if (!qphy->tx2 || !qphy->rx2) { 1642 + dev_warn(dev, 1643 + "Underspecified device tree, falling back to legacy register regions\n"); 1644 + 1645 + /* In the old version, pcs_misc is at index 3. */ 1646 + qphy->pcs_misc = qphy->tx2; 1647 + qphy->tx2 = qphy->tx + QMP_PHY_LEGACY_LANE_STRIDE; 1648 + qphy->rx2 = qphy->rx + QMP_PHY_LEGACY_LANE_STRIDE; 1649 + 1650 + } else { 1651 + qphy->pcs_misc = of_iomap(np, 5); 1652 + } 1653 + 1654 + } else { 1655 + qphy->pcs_misc = of_iomap(np, 3); 1656 + } 1657 + 1655 1658 if (!qphy->pcs_misc) 1656 1659 dev_vdbg(dev, "PHY pcs_misc-reg not used\n"); 1657 1660
+2 -1
drivers/phy/qualcomm/phy-qcom-qusb2.c
··· 425 425 HSTX_TRIM_MASK); 426 426 } 427 427 428 - static int qusb2_phy_set_mode(struct phy *phy, enum phy_mode mode) 428 + static int qusb2_phy_set_mode(struct phy *phy, 429 + enum phy_mode mode, int submode) 429 430 { 430 431 struct qusb2_phy *qphy = phy_get_drvdata(phy); 431 432
+2 -1
drivers/phy/qualcomm/phy-qcom-ufs-qmp-14nm.c
··· 65 65 } 66 66 67 67 static 68 - int ufs_qcom_phy_qmp_14nm_set_mode(struct phy *generic_phy, enum phy_mode mode) 68 + int ufs_qcom_phy_qmp_14nm_set_mode(struct phy *generic_phy, 69 + enum phy_mode mode, int submode) 69 70 { 70 71 struct ufs_qcom_phy *phy_common = get_ufs_qcom_phy(generic_phy); 71 72
+2 -1
drivers/phy/qualcomm/phy-qcom-ufs-qmp-20nm.c
··· 84 84 } 85 85 86 86 static 87 - int ufs_qcom_phy_qmp_20nm_set_mode(struct phy *generic_phy, enum phy_mode mode) 87 + int ufs_qcom_phy_qmp_20nm_set_mode(struct phy *generic_phy, 88 + enum phy_mode mode, int submode) 88 89 { 89 90 struct ufs_qcom_phy *phy_common = get_ufs_qcom_phy(generic_phy); 90 91
+2 -1
drivers/phy/qualcomm/phy-qcom-usb-hs.c
··· 42 42 struct notifier_block vbus_notify; 43 43 }; 44 44 45 - static int qcom_usb_hs_phy_set_mode(struct phy *phy, enum phy_mode mode) 45 + static int qcom_usb_hs_phy_set_mode(struct phy *phy, 46 + enum phy_mode mode, int submode) 46 47 { 47 48 struct qcom_usb_hs_phy *uphy = phy_get_drvdata(phy); 48 49 u8 addr;
+11 -6
drivers/phy/renesas/phy-rcar-gen3-usb2.c
··· 307 307 void __iomem *usb2_base = ch->base; 308 308 u32 val; 309 309 310 + /* Should not use functions of read-modify-write a register */ 311 + val = readl(usb2_base + USB2_LINECTRL1); 312 + val = (val & ~USB2_LINECTRL1_DP_RPD) | USB2_LINECTRL1_DPRPD_EN | 313 + USB2_LINECTRL1_DMRPD_EN | USB2_LINECTRL1_DM_RPD; 314 + writel(val, usb2_base + USB2_LINECTRL1); 315 + 310 316 val = readl(usb2_base + USB2_VBCTRL); 311 317 writel(val | USB2_VBCTRL_DRVVBUSSEL, usb2_base + USB2_VBCTRL); 312 - writel(USB2_OBINT_BITS, usb2_base + USB2_OBINTSTA); 313 - rcar_gen3_control_otg_irq(ch, 1); 314 318 val = readl(usb2_base + USB2_ADPCTRL); 315 319 writel(val | USB2_ADPCTRL_IDPULLUP, usb2_base + USB2_ADPCTRL); 316 - val = readl(usb2_base + USB2_LINECTRL1); 317 - rcar_gen3_set_linectrl(ch, 0, 0); 318 - writel(val | USB2_LINECTRL1_DPRPD_EN | USB2_LINECTRL1_DMRPD_EN, 319 - usb2_base + USB2_LINECTRL1); 320 + 321 + msleep(20); 322 + 323 + writel(0xffffffff, usb2_base + USB2_OBINTSTA); 324 + writel(USB2_OBINT_BITS, usb2_base + USB2_OBINTEN); 320 325 321 326 rcar_gen3_device_recognition(ch); 322 327 }
+3 -3
drivers/phy/rockchip/phy-rockchip-inno-usb2.c
··· 1168 1168 struct phy *phy; 1169 1169 1170 1170 /* This driver aims to support both otg-port and host-port */ 1171 - if (of_node_cmp(child_np->name, "host-port") && 1172 - of_node_cmp(child_np->name, "otg-port")) 1171 + if (!of_node_name_eq(child_np, "host-port") && 1172 + !of_node_name_eq(child_np, "otg-port")) 1173 1173 goto next_child; 1174 1174 1175 1175 phy = devm_phy_create(dev, child_np, &rockchip_usb2phy_ops); ··· 1183 1183 phy_set_drvdata(rport->phy, rport); 1184 1184 1185 1185 /* initialize otg/host port separately */ 1186 - if (!of_node_cmp(child_np->name, "host-port")) { 1186 + if (of_node_name_eq(child_np, "host-port")) { 1187 1187 ret = rockchip_usb2phy_host_port_init(rphy, rport, 1188 1188 child_np); 1189 1189 if (ret)
+2 -2
drivers/phy/rockchip/phy-rockchip-typec.c
··· 1176 1176 for_each_available_child_of_node(np, child_np) { 1177 1177 struct phy *phy; 1178 1178 1179 - if (!of_node_cmp(child_np->name, "dp-port")) 1179 + if (of_node_name_eq(child_np, "dp-port")) 1180 1180 phy = devm_phy_create(dev, child_np, 1181 1181 &rockchip_dp_phy_ops); 1182 - else if (!of_node_cmp(child_np->name, "usb3-port")) 1182 + else if (of_node_name_eq(child_np, "usb3-port")) 1183 1183 phy = devm_phy_create(dev, child_np, 1184 1184 &rockchip_usb3_phy_ops); 1185 1185 else
+10
drivers/phy/ti/Kconfig
··· 76 76 family chips (including the TWL5030 and TPS659x0 devices). 77 77 This transceiver supports high and full speed devices plus, 78 78 in host mode, low speed. 79 + 80 + config PHY_TI_GMII_SEL 81 + tristate 82 + default y if TI_CPSW=y 83 + depends on TI_CPSW || COMPILE_TEST 84 + select GENERIC_PHY 85 + default m 86 + help 87 + This driver supports configuring of the TI CPSW Port mode depending on 88 + the Ethernet PHY connected to the CPSW Port.
+1
drivers/phy/ti/Makefile
··· 6 6 obj-$(CONFIG_TI_PIPE3) += phy-ti-pipe3.o 7 7 obj-$(CONFIG_PHY_TUSB1210) += phy-tusb1210.o 8 8 obj-$(CONFIG_TWL4030_USB) += phy-twl4030-usb.o 9 + obj-$(CONFIG_PHY_TI_GMII_SEL) += phy-gmii-sel.o
+2 -1
drivers/phy/ti/phy-da8xx-usb.c
··· 93 93 return 0; 94 94 } 95 95 96 - static int da8xx_usb20_phy_set_mode(struct phy *phy, enum phy_mode mode) 96 + static int da8xx_usb20_phy_set_mode(struct phy *phy, 97 + enum phy_mode mode, int submode) 97 98 { 98 99 struct da8xx_usb_phy *d_phy = phy_get_drvdata(phy); 99 100 u32 val;
+349
drivers/phy/ti/phy-gmii-sel.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + /* 3 + * Texas Instruments CPSW Port's PHY Interface Mode selection Driver 4 + * 5 + * Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com/ 6 + * 7 + * Based on cpsw-phy-sel.c driver created by Mugunthan V N <mugunthanvnm@ti.com> 8 + */ 9 + 10 + #include <linux/platform_device.h> 11 + #include <linux/module.h> 12 + #include <linux/mfd/syscon.h> 13 + #include <linux/of.h> 14 + #include <linux/of_net.h> 15 + #include <linux/phy.h> 16 + #include <linux/phy/phy.h> 17 + #include <linux/regmap.h> 18 + 19 + /* AM33xx SoC specific definitions for the CONTROL port */ 20 + #define AM33XX_GMII_SEL_MODE_MII 0 21 + #define AM33XX_GMII_SEL_MODE_RMII 1 22 + #define AM33XX_GMII_SEL_MODE_RGMII 2 23 + 24 + enum { 25 + PHY_GMII_SEL_PORT_MODE, 26 + PHY_GMII_SEL_RGMII_ID_MODE, 27 + PHY_GMII_SEL_RMII_IO_CLK_EN, 28 + PHY_GMII_SEL_LAST, 29 + }; 30 + 31 + struct phy_gmii_sel_phy_priv { 32 + struct phy_gmii_sel_priv *priv; 33 + u32 id; 34 + struct phy *if_phy; 35 + int rmii_clock_external; 36 + int phy_if_mode; 37 + struct regmap_field *fields[PHY_GMII_SEL_LAST]; 38 + }; 39 + 40 + struct phy_gmii_sel_soc_data { 41 + u32 num_ports; 42 + u32 features; 43 + const struct reg_field (*regfields)[PHY_GMII_SEL_LAST]; 44 + }; 45 + 46 + struct phy_gmii_sel_priv { 47 + struct device *dev; 48 + const struct phy_gmii_sel_soc_data *soc_data; 49 + struct regmap *regmap; 50 + struct phy_provider *phy_provider; 51 + struct phy_gmii_sel_phy_priv *if_phys; 52 + }; 53 + 54 + static int phy_gmii_sel_mode(struct phy *phy, enum phy_mode mode, int submode) 55 + { 56 + struct phy_gmii_sel_phy_priv *if_phy = phy_get_drvdata(phy); 57 + const struct phy_gmii_sel_soc_data *soc_data = if_phy->priv->soc_data; 58 + struct device *dev = if_phy->priv->dev; 59 + struct regmap_field *regfield; 60 + int ret, rgmii_id = 0; 61 + u32 gmii_sel_mode = 0; 62 + 63 + if (mode != PHY_MODE_ETHERNET) 64 + return -EINVAL; 65 + 66 + switch (submode) { 67 + case PHY_INTERFACE_MODE_RMII: 68 + gmii_sel_mode = AM33XX_GMII_SEL_MODE_RMII; 69 + break; 70 + 71 + case PHY_INTERFACE_MODE_RGMII: 72 + gmii_sel_mode = AM33XX_GMII_SEL_MODE_RGMII; 73 + break; 74 + 75 + case PHY_INTERFACE_MODE_RGMII_ID: 76 + case PHY_INTERFACE_MODE_RGMII_RXID: 77 + case PHY_INTERFACE_MODE_RGMII_TXID: 78 + gmii_sel_mode = AM33XX_GMII_SEL_MODE_RGMII; 79 + rgmii_id = 1; 80 + break; 81 + 82 + case PHY_INTERFACE_MODE_MII: 83 + mode = AM33XX_GMII_SEL_MODE_MII; 84 + break; 85 + 86 + default: 87 + dev_warn(dev, 88 + "port%u: unsupported mode: \"%s\". Defaulting to MII.\n", 89 + if_phy->id, phy_modes(rgmii_id)); 90 + return -EINVAL; 91 + } 92 + 93 + if_phy->phy_if_mode = submode; 94 + 95 + dev_dbg(dev, "%s id:%u mode:%u rgmii_id:%d rmii_clk_ext:%d\n", 96 + __func__, if_phy->id, mode, rgmii_id, 97 + if_phy->rmii_clock_external); 98 + 99 + regfield = if_phy->fields[PHY_GMII_SEL_PORT_MODE]; 100 + ret = regmap_field_write(regfield, gmii_sel_mode); 101 + if (ret) { 102 + dev_err(dev, "port%u: set mode fail %d", if_phy->id, ret); 103 + return ret; 104 + } 105 + 106 + if (soc_data->features & BIT(PHY_GMII_SEL_RGMII_ID_MODE) && 107 + if_phy->fields[PHY_GMII_SEL_RGMII_ID_MODE]) { 108 + regfield = if_phy->fields[PHY_GMII_SEL_RGMII_ID_MODE]; 109 + ret = regmap_field_write(regfield, rgmii_id); 110 + if (ret) 111 + return ret; 112 + } 113 + 114 + if (soc_data->features & BIT(PHY_GMII_SEL_RMII_IO_CLK_EN) && 115 + if_phy->fields[PHY_GMII_SEL_RMII_IO_CLK_EN]) { 116 + regfield = if_phy->fields[PHY_GMII_SEL_RMII_IO_CLK_EN]; 117 + ret = regmap_field_write(regfield, 118 + if_phy->rmii_clock_external); 119 + } 120 + 121 + return 0; 122 + } 123 + 124 + static const 125 + struct reg_field phy_gmii_sel_fields_am33xx[][PHY_GMII_SEL_LAST] = { 126 + { 127 + [PHY_GMII_SEL_PORT_MODE] = REG_FIELD(0x650, 0, 1), 128 + [PHY_GMII_SEL_RGMII_ID_MODE] = REG_FIELD(0x650, 4, 4), 129 + [PHY_GMII_SEL_RMII_IO_CLK_EN] = REG_FIELD(0x650, 6, 6), 130 + }, 131 + { 132 + [PHY_GMII_SEL_PORT_MODE] = REG_FIELD(0x650, 2, 3), 133 + [PHY_GMII_SEL_RGMII_ID_MODE] = REG_FIELD(0x650, 5, 5), 134 + [PHY_GMII_SEL_RMII_IO_CLK_EN] = REG_FIELD(0x650, 7, 7), 135 + }, 136 + }; 137 + 138 + static const 139 + struct phy_gmii_sel_soc_data phy_gmii_sel_soc_am33xx = { 140 + .num_ports = 2, 141 + .features = BIT(PHY_GMII_SEL_RGMII_ID_MODE) | 142 + BIT(PHY_GMII_SEL_RMII_IO_CLK_EN), 143 + .regfields = phy_gmii_sel_fields_am33xx, 144 + }; 145 + 146 + static const 147 + struct reg_field phy_gmii_sel_fields_dra7[][PHY_GMII_SEL_LAST] = { 148 + { 149 + [PHY_GMII_SEL_PORT_MODE] = REG_FIELD(0x554, 0, 1), 150 + [PHY_GMII_SEL_RGMII_ID_MODE] = REG_FIELD((~0), 0, 0), 151 + [PHY_GMII_SEL_RMII_IO_CLK_EN] = REG_FIELD((~0), 0, 0), 152 + }, 153 + { 154 + [PHY_GMII_SEL_PORT_MODE] = REG_FIELD(0x554, 4, 5), 155 + [PHY_GMII_SEL_RGMII_ID_MODE] = REG_FIELD((~0), 0, 0), 156 + [PHY_GMII_SEL_RMII_IO_CLK_EN] = REG_FIELD((~0), 0, 0), 157 + }, 158 + }; 159 + 160 + static const 161 + struct phy_gmii_sel_soc_data phy_gmii_sel_soc_dra7 = { 162 + .num_ports = 2, 163 + .regfields = phy_gmii_sel_fields_dra7, 164 + }; 165 + 166 + static const 167 + struct phy_gmii_sel_soc_data phy_gmii_sel_soc_dm814 = { 168 + .num_ports = 2, 169 + .features = BIT(PHY_GMII_SEL_RGMII_ID_MODE), 170 + .regfields = phy_gmii_sel_fields_am33xx, 171 + }; 172 + 173 + static const struct of_device_id phy_gmii_sel_id_table[] = { 174 + { 175 + .compatible = "ti,am3352-phy-gmii-sel", 176 + .data = &phy_gmii_sel_soc_am33xx, 177 + }, 178 + { 179 + .compatible = "ti,dra7xx-phy-gmii-sel", 180 + .data = &phy_gmii_sel_soc_dra7, 181 + }, 182 + { 183 + .compatible = "ti,am43xx-phy-gmii-sel", 184 + .data = &phy_gmii_sel_soc_am33xx, 185 + }, 186 + { 187 + .compatible = "ti,dm814-phy-gmii-sel", 188 + .data = &phy_gmii_sel_soc_dm814, 189 + }, 190 + {} 191 + }; 192 + MODULE_DEVICE_TABLE(of, phy_gmii_sel_id_table); 193 + 194 + static const struct phy_ops phy_gmii_sel_ops = { 195 + .set_mode = phy_gmii_sel_mode, 196 + .owner = THIS_MODULE, 197 + }; 198 + 199 + static struct phy *phy_gmii_sel_of_xlate(struct device *dev, 200 + struct of_phandle_args *args) 201 + { 202 + struct phy_gmii_sel_priv *priv = dev_get_drvdata(dev); 203 + int phy_id = args->args[0]; 204 + 205 + if (args->args_count < 1) 206 + return ERR_PTR(-EINVAL); 207 + if (priv->soc_data->features & BIT(PHY_GMII_SEL_RMII_IO_CLK_EN) && 208 + args->args_count < 2) 209 + return ERR_PTR(-EINVAL); 210 + if (!priv || !priv->if_phys) 211 + return ERR_PTR(-ENODEV); 212 + if (phy_id > priv->soc_data->num_ports) 213 + return ERR_PTR(-EINVAL); 214 + if (phy_id != priv->if_phys[phy_id - 1].id) 215 + return ERR_PTR(-EINVAL); 216 + 217 + phy_id--; 218 + if (priv->soc_data->features & BIT(PHY_GMII_SEL_RMII_IO_CLK_EN)) 219 + priv->if_phys[phy_id].rmii_clock_external = args->args[1]; 220 + dev_dbg(dev, "%s id:%u ext:%d\n", __func__, 221 + priv->if_phys[phy_id].id, args->args[1]); 222 + 223 + return priv->if_phys[phy_id].if_phy; 224 + } 225 + 226 + static int phy_gmii_sel_init_ports(struct phy_gmii_sel_priv *priv) 227 + { 228 + const struct phy_gmii_sel_soc_data *soc_data = priv->soc_data; 229 + struct device *dev = priv->dev; 230 + struct phy_gmii_sel_phy_priv *if_phys; 231 + int i, num_ports, ret; 232 + 233 + num_ports = priv->soc_data->num_ports; 234 + 235 + if_phys = devm_kcalloc(priv->dev, num_ports, 236 + sizeof(*if_phys), GFP_KERNEL); 237 + if (!if_phys) 238 + return -ENOMEM; 239 + dev_dbg(dev, "%s %d\n", __func__, num_ports); 240 + 241 + for (i = 0; i < num_ports; i++) { 242 + const struct reg_field *field; 243 + struct regmap_field *regfield; 244 + 245 + if_phys[i].id = i + 1; 246 + if_phys[i].priv = priv; 247 + 248 + field = &soc_data->regfields[i][PHY_GMII_SEL_PORT_MODE]; 249 + dev_dbg(dev, "%s field %x %d %d\n", __func__, 250 + field->reg, field->msb, field->lsb); 251 + 252 + regfield = devm_regmap_field_alloc(dev, priv->regmap, *field); 253 + if (IS_ERR(regfield)) 254 + return PTR_ERR(regfield); 255 + if_phys[i].fields[PHY_GMII_SEL_PORT_MODE] = regfield; 256 + 257 + field = &soc_data->regfields[i][PHY_GMII_SEL_RGMII_ID_MODE]; 258 + if (field->reg != (~0)) { 259 + regfield = devm_regmap_field_alloc(dev, 260 + priv->regmap, 261 + *field); 262 + if (IS_ERR(regfield)) 263 + return PTR_ERR(regfield); 264 + if_phys[i].fields[PHY_GMII_SEL_RGMII_ID_MODE] = 265 + regfield; 266 + } 267 + 268 + field = &soc_data->regfields[i][PHY_GMII_SEL_RMII_IO_CLK_EN]; 269 + if (field->reg != (~0)) { 270 + regfield = devm_regmap_field_alloc(dev, 271 + priv->regmap, 272 + *field); 273 + if (IS_ERR(regfield)) 274 + return PTR_ERR(regfield); 275 + if_phys[i].fields[PHY_GMII_SEL_RMII_IO_CLK_EN] = 276 + regfield; 277 + } 278 + 279 + if_phys[i].if_phy = devm_phy_create(dev, 280 + priv->dev->of_node, 281 + &phy_gmii_sel_ops); 282 + if (IS_ERR(if_phys[i].if_phy)) { 283 + ret = PTR_ERR(if_phys[i].if_phy); 284 + dev_err(dev, "Failed to create phy%d %d\n", i, ret); 285 + return ret; 286 + } 287 + phy_set_drvdata(if_phys[i].if_phy, &if_phys[i]); 288 + } 289 + 290 + priv->if_phys = if_phys; 291 + return 0; 292 + } 293 + 294 + static int phy_gmii_sel_probe(struct platform_device *pdev) 295 + { 296 + struct device *dev = &pdev->dev; 297 + struct device_node *node = dev->of_node; 298 + const struct of_device_id *of_id; 299 + struct phy_gmii_sel_priv *priv; 300 + int ret; 301 + 302 + of_id = of_match_node(phy_gmii_sel_id_table, pdev->dev.of_node); 303 + if (!of_id) 304 + return -EINVAL; 305 + 306 + priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); 307 + if (!priv) 308 + return -ENOMEM; 309 + 310 + priv->dev = &pdev->dev; 311 + priv->soc_data = of_id->data; 312 + 313 + priv->regmap = syscon_node_to_regmap(node->parent); 314 + if (IS_ERR(priv->regmap)) { 315 + ret = PTR_ERR(priv->regmap); 316 + dev_err(dev, "Failed to get syscon %d\n", ret); 317 + return ret; 318 + } 319 + 320 + ret = phy_gmii_sel_init_ports(priv); 321 + if (ret) 322 + return ret; 323 + 324 + dev_set_drvdata(&pdev->dev, priv); 325 + 326 + priv->phy_provider = 327 + devm_of_phy_provider_register(dev, 328 + phy_gmii_sel_of_xlate); 329 + if (IS_ERR(priv->phy_provider)) { 330 + ret = PTR_ERR(priv->phy_provider); 331 + dev_err(dev, "Failed to create phy provider %d\n", ret); 332 + return ret; 333 + } 334 + 335 + return 0; 336 + } 337 + 338 + static struct platform_driver phy_gmii_sel_driver = { 339 + .probe = phy_gmii_sel_probe, 340 + .driver = { 341 + .name = "phy-gmii-sel", 342 + .of_match_table = phy_gmii_sel_id_table, 343 + }, 344 + }; 345 + module_platform_driver(phy_gmii_sel_driver); 346 + 347 + MODULE_LICENSE("GPL v2"); 348 + MODULE_AUTHOR("Grygorii Strashko <grygorii.strashko@ti.com>"); 349 + MODULE_DESCRIPTION("TI CPSW Port's PHY Interface Mode selection Driver");
+1 -1
drivers/phy/ti/phy-tusb1210.c
··· 53 53 return 0; 54 54 } 55 55 56 - static int tusb1210_set_mode(struct phy *phy, enum phy_mode mode) 56 + static int tusb1210_set_mode(struct phy *phy, enum phy_mode mode, int submode) 57 57 { 58 58 struct tusb1210 *tusb = phy_get_drvdata(phy); 59 59 int ret;
+1 -1
drivers/platform/x86/intel_cht_int33fe.c
··· 79 79 }; 80 80 81 81 static const struct property_entry fusb302_props[] = { 82 - PROPERTY_ENTRY_STRING("fcs,extcon-name", "cht_wcove_pwrsrc"), 82 + PROPERTY_ENTRY_STRING("linux,extcon-name", "cht_wcove_pwrsrc"), 83 83 PROPERTY_ENTRY_U32("fcs,max-sink-microvolt", 12000000), 84 84 PROPERTY_ENTRY_U32("fcs,max-sink-microamp", 3000000), 85 85 PROPERTY_ENTRY_U32("fcs,max-sink-microwatt", 36000000),
-4
drivers/usb/Kconfig
··· 205 205 To compile this driver as a module, choose M here: the module will 206 206 be called ulpi. 207 207 208 - config USB_ROLE_SWITCH 209 - tristate 210 - select USB_COMMON 211 - 212 208 endif # USB_SUPPORT
+140 -22
drivers/usb/chipidea/ci_hdrc_imx.c
··· 14 14 #include <linux/usb/chipidea.h> 15 15 #include <linux/usb/of.h> 16 16 #include <linux/clk.h> 17 + #include <linux/pinctrl/consumer.h> 17 18 18 19 #include "ci.h" 19 20 #include "ci_hdrc_imx.h" ··· 86 85 bool supports_runtime_pm; 87 86 bool override_phy_control; 88 87 bool in_lpm; 88 + struct pinctrl *pinctrl; 89 + struct pinctrl_state *pinctrl_hsic_active; 90 + struct regulator *hsic_pad_regulator; 89 91 /* SoC before i.mx6 (except imx23/imx28) needs three clks */ 90 92 bool need_three_clks; 91 93 struct clk *clk_ipg; ··· 136 132 137 133 data->dev = &misc_pdev->dev; 138 134 139 - if (of_find_property(np, "disable-over-current", NULL)) 135 + /* 136 + * Check the various over current related properties. If over current 137 + * detection is disabled we're not interested in the polarity. 138 + */ 139 + if (of_find_property(np, "disable-over-current", NULL)) { 140 140 data->disable_oc = 1; 141 - 142 - if (of_find_property(np, "over-current-active-high", NULL)) 143 - data->oc_polarity = 1; 141 + } else if (of_find_property(np, "over-current-active-high", NULL)) { 142 + data->oc_pol_active_low = 0; 143 + data->oc_pol_configured = 1; 144 + } else if (of_find_property(np, "over-current-active-low", NULL)) { 145 + data->oc_pol_active_low = 1; 146 + data->oc_pol_configured = 1; 147 + } else { 148 + dev_warn(dev, "No over current polarity defined\n"); 149 + } 144 150 145 151 if (of_find_property(np, "external-vbus-divider", NULL)) 146 152 data->evdo = 1; ··· 259 245 } 260 246 } 261 247 248 + static int ci_hdrc_imx_notify_event(struct ci_hdrc *ci, unsigned int event) 249 + { 250 + struct device *dev = ci->dev->parent; 251 + struct ci_hdrc_imx_data *data = dev_get_drvdata(dev); 252 + int ret = 0; 253 + 254 + switch (event) { 255 + case CI_HDRC_IMX_HSIC_ACTIVE_EVENT: 256 + ret = pinctrl_select_state(data->pinctrl, 257 + data->pinctrl_hsic_active); 258 + if (ret) 259 + dev_err(dev, "hsic_active select failed, err=%d\n", 260 + ret); 261 + break; 262 + case CI_HDRC_IMX_HSIC_SUSPEND_EVENT: 263 + ret = imx_usbmisc_hsic_set_connect(data->usbmisc_data); 264 + if (ret) 265 + dev_err(dev, 266 + "hsic_set_connect failed, err=%d\n", ret); 267 + break; 268 + default: 269 + break; 270 + } 271 + 272 + return ret; 273 + } 274 + 262 275 static int ci_hdrc_imx_probe(struct platform_device *pdev) 263 276 { 264 277 struct ci_hdrc_imx_data *data; 265 278 struct ci_hdrc_platform_data pdata = { 266 279 .name = dev_name(&pdev->dev), 267 280 .capoffset = DEF_CAPOFFSET, 281 + .notify_event = ci_hdrc_imx_notify_event, 268 282 }; 269 283 int ret; 270 284 const struct of_device_id *of_id; 271 285 const struct ci_hdrc_imx_platform_flag *imx_platform_flag; 272 286 struct device_node *np = pdev->dev.of_node; 287 + struct device *dev = &pdev->dev; 288 + struct pinctrl_state *pinctrl_hsic_idle; 273 289 274 - of_id = of_match_device(ci_hdrc_imx_dt_ids, &pdev->dev); 290 + of_id = of_match_device(ci_hdrc_imx_dt_ids, dev); 275 291 if (!of_id) 276 292 return -ENODEV; 277 293 ··· 312 268 return -ENOMEM; 313 269 314 270 platform_set_drvdata(pdev, data); 315 - data->usbmisc_data = usbmisc_get_init_data(&pdev->dev); 271 + data->usbmisc_data = usbmisc_get_init_data(dev); 316 272 if (IS_ERR(data->usbmisc_data)) 317 273 return PTR_ERR(data->usbmisc_data); 318 274 319 - ret = imx_get_clks(&pdev->dev); 320 - if (ret) 321 - return ret; 275 + if (of_usb_get_phy_mode(dev->of_node) == USBPHY_INTERFACE_MODE_HSIC) { 276 + pdata.flags |= CI_HDRC_IMX_IS_HSIC; 277 + data->usbmisc_data->hsic = 1; 278 + data->pinctrl = devm_pinctrl_get(dev); 279 + if (IS_ERR(data->pinctrl)) { 280 + dev_err(dev, "pinctrl get failed, err=%ld\n", 281 + PTR_ERR(data->pinctrl)); 282 + return PTR_ERR(data->pinctrl); 283 + } 322 284 323 - ret = imx_prepare_enable_clks(&pdev->dev); 324 - if (ret) 325 - return ret; 285 + pinctrl_hsic_idle = pinctrl_lookup_state(data->pinctrl, "idle"); 286 + if (IS_ERR(pinctrl_hsic_idle)) { 287 + dev_err(dev, 288 + "pinctrl_hsic_idle lookup failed, err=%ld\n", 289 + PTR_ERR(pinctrl_hsic_idle)); 290 + return PTR_ERR(pinctrl_hsic_idle); 291 + } 326 292 327 - data->phy = devm_usb_get_phy_by_phandle(&pdev->dev, "fsl,usbphy", 0); 293 + ret = pinctrl_select_state(data->pinctrl, pinctrl_hsic_idle); 294 + if (ret) { 295 + dev_err(dev, "hsic_idle select failed, err=%d\n", ret); 296 + return ret; 297 + } 298 + 299 + data->pinctrl_hsic_active = pinctrl_lookup_state(data->pinctrl, 300 + "active"); 301 + if (IS_ERR(data->pinctrl_hsic_active)) { 302 + dev_err(dev, 303 + "pinctrl_hsic_active lookup failed, err=%ld\n", 304 + PTR_ERR(data->pinctrl_hsic_active)); 305 + return PTR_ERR(data->pinctrl_hsic_active); 306 + } 307 + 308 + data->hsic_pad_regulator = devm_regulator_get(dev, "hsic"); 309 + if (PTR_ERR(data->hsic_pad_regulator) == -EPROBE_DEFER) { 310 + return -EPROBE_DEFER; 311 + } else if (PTR_ERR(data->hsic_pad_regulator) == -ENODEV) { 312 + /* no pad regualator is needed */ 313 + data->hsic_pad_regulator = NULL; 314 + } else if (IS_ERR(data->hsic_pad_regulator)) { 315 + dev_err(dev, "Get HSIC pad regulator error: %ld\n", 316 + PTR_ERR(data->hsic_pad_regulator)); 317 + return PTR_ERR(data->hsic_pad_regulator); 318 + } 319 + 320 + if (data->hsic_pad_regulator) { 321 + ret = regulator_enable(data->hsic_pad_regulator); 322 + if (ret) { 323 + dev_err(dev, 324 + "Failed to enable HSIC pad regulator\n"); 325 + return ret; 326 + } 327 + } 328 + } 329 + ret = imx_get_clks(dev); 330 + if (ret) 331 + goto disable_hsic_regulator; 332 + 333 + ret = imx_prepare_enable_clks(dev); 334 + if (ret) 335 + goto disable_hsic_regulator; 336 + 337 + data->phy = devm_usb_get_phy_by_phandle(dev, "fsl,usbphy", 0); 328 338 if (IS_ERR(data->phy)) { 329 339 ret = PTR_ERR(data->phy); 330 340 /* Return -EINVAL if no usbphy is available */ ··· 403 305 404 306 ret = imx_usbmisc_init(data->usbmisc_data); 405 307 if (ret) { 406 - dev_err(&pdev->dev, "usbmisc init failed, ret=%d\n", ret); 308 + dev_err(dev, "usbmisc init failed, ret=%d\n", ret); 407 309 goto err_clk; 408 310 } 409 311 410 - data->ci_pdev = ci_hdrc_add_device(&pdev->dev, 312 + data->ci_pdev = ci_hdrc_add_device(dev, 411 313 pdev->resource, pdev->num_resources, 412 314 &pdata); 413 315 if (IS_ERR(data->ci_pdev)) { 414 316 ret = PTR_ERR(data->ci_pdev); 415 317 if (ret != -EPROBE_DEFER) 416 - dev_err(&pdev->dev, 417 - "ci_hdrc_add_device failed, err=%d\n", ret); 318 + dev_err(dev, "ci_hdrc_add_device failed, err=%d\n", 319 + ret); 418 320 goto err_clk; 419 321 } 420 322 421 323 ret = imx_usbmisc_init_post(data->usbmisc_data); 422 324 if (ret) { 423 - dev_err(&pdev->dev, "usbmisc post failed, ret=%d\n", ret); 325 + dev_err(dev, "usbmisc post failed, ret=%d\n", ret); 424 326 goto disable_device; 425 327 } 426 328 427 329 if (data->supports_runtime_pm) { 428 - pm_runtime_set_active(&pdev->dev); 429 - pm_runtime_enable(&pdev->dev); 330 + pm_runtime_set_active(dev); 331 + pm_runtime_enable(dev); 430 332 } 431 333 432 - device_set_wakeup_capable(&pdev->dev, true); 334 + device_set_wakeup_capable(dev, true); 433 335 434 336 return 0; 435 337 436 338 disable_device: 437 339 ci_hdrc_remove_device(data->ci_pdev); 438 340 err_clk: 439 - imx_disable_unprepare_clks(&pdev->dev); 341 + imx_disable_unprepare_clks(dev); 342 + disable_hsic_regulator: 343 + if (data->hsic_pad_regulator) 344 + ret = regulator_disable(data->hsic_pad_regulator); 440 345 return ret; 441 346 } 442 347 ··· 456 355 if (data->override_phy_control) 457 356 usb_phy_shutdown(data->phy); 458 357 imx_disable_unprepare_clks(&pdev->dev); 358 + if (data->hsic_pad_regulator) 359 + regulator_disable(data->hsic_pad_regulator); 459 360 460 361 return 0; 461 362 } ··· 470 367 static int __maybe_unused imx_controller_suspend(struct device *dev) 471 368 { 472 369 struct ci_hdrc_imx_data *data = dev_get_drvdata(dev); 370 + int ret = 0; 473 371 474 372 dev_dbg(dev, "at %s\n", __func__); 373 + 374 + ret = imx_usbmisc_hsic_set_clk(data->usbmisc_data, false); 375 + if (ret) { 376 + dev_err(dev, "usbmisc hsic_set_clk failed, ret=%d\n", ret); 377 + return ret; 378 + } 475 379 476 380 imx_disable_unprepare_clks(dev); 477 381 data->in_lpm = true; ··· 510 400 goto clk_disable; 511 401 } 512 402 403 + ret = imx_usbmisc_hsic_set_clk(data->usbmisc_data, true); 404 + if (ret) { 405 + dev_err(dev, "usbmisc hsic_set_clk failed, ret=%d\n", ret); 406 + goto hsic_set_clk_fail; 407 + } 408 + 513 409 return 0; 514 410 411 + hsic_set_clk_fail: 412 + imx_usbmisc_set_wakeup(data->usbmisc_data, true); 515 413 clk_disable: 516 414 imx_disable_unprepare_clks(dev); 517 415 return ret;
+13 -4
drivers/usb/chipidea/ci_hdrc_imx.h
··· 11 11 int index; 12 12 13 13 unsigned int disable_oc:1; /* over current detect disabled */ 14 - unsigned int oc_polarity:1; /* over current polarity if oc enabled */ 14 + 15 + /* true if over-current polarity is active low */ 16 + unsigned int oc_pol_active_low:1; 17 + 18 + /* true if dt specifies polarity */ 19 + unsigned int oc_pol_configured:1; 20 + 15 21 unsigned int evdo:1; /* set external vbus divider option */ 16 22 unsigned int ulpi:1; /* connected to an ULPI phy */ 23 + unsigned int hsic:1; /* HSIC controlller */ 17 24 }; 18 25 19 - int imx_usbmisc_init(struct imx_usbmisc_data *); 20 - int imx_usbmisc_init_post(struct imx_usbmisc_data *); 21 - int imx_usbmisc_set_wakeup(struct imx_usbmisc_data *, bool); 26 + int imx_usbmisc_init(struct imx_usbmisc_data *data); 27 + int imx_usbmisc_init_post(struct imx_usbmisc_data *data); 28 + int imx_usbmisc_set_wakeup(struct imx_usbmisc_data *data, bool enabled); 29 + int imx_usbmisc_hsic_set_connect(struct imx_usbmisc_data *data); 30 + int imx_usbmisc_hsic_set_clk(struct imx_usbmisc_data *data, bool on); 22 31 23 32 #endif /* __DRIVER_USB_CHIPIDEA_CI_HDRC_IMX_H */
+92
drivers/usb/chipidea/host.c
··· 170 170 otg->host = &hcd->self; 171 171 hcd->self.otg_port = 1; 172 172 } 173 + 174 + if (ci->platdata->notify_event && 175 + (ci->platdata->flags & CI_HDRC_IMX_IS_HSIC)) 176 + ci->platdata->notify_event 177 + (ci, CI_HDRC_IMX_HSIC_ACTIVE_EVENT); 173 178 } 174 179 175 180 return ret; ··· 220 215 host_stop(ci); 221 216 } 222 217 218 + /* The below code is based on tegra ehci driver */ 219 + static int ci_ehci_hub_control( 220 + struct usb_hcd *hcd, 221 + u16 typeReq, 222 + u16 wValue, 223 + u16 wIndex, 224 + char *buf, 225 + u16 wLength 226 + ) 227 + { 228 + struct ehci_hcd *ehci = hcd_to_ehci(hcd); 229 + u32 __iomem *status_reg; 230 + u32 temp; 231 + unsigned long flags; 232 + int retval = 0; 233 + struct device *dev = hcd->self.controller; 234 + struct ci_hdrc *ci = dev_get_drvdata(dev); 235 + 236 + status_reg = &ehci->regs->port_status[(wIndex & 0xff) - 1]; 237 + 238 + spin_lock_irqsave(&ehci->lock, flags); 239 + 240 + if (typeReq == SetPortFeature && wValue == USB_PORT_FEAT_SUSPEND) { 241 + temp = ehci_readl(ehci, status_reg); 242 + if ((temp & PORT_PE) == 0 || (temp & PORT_RESET) != 0) { 243 + retval = -EPIPE; 244 + goto done; 245 + } 246 + 247 + temp &= ~(PORT_RWC_BITS | PORT_WKCONN_E); 248 + temp |= PORT_WKDISC_E | PORT_WKOC_E; 249 + ehci_writel(ehci, temp | PORT_SUSPEND, status_reg); 250 + 251 + /* 252 + * If a transaction is in progress, there may be a delay in 253 + * suspending the port. Poll until the port is suspended. 254 + */ 255 + if (ehci_handshake(ehci, status_reg, PORT_SUSPEND, 256 + PORT_SUSPEND, 5000)) 257 + ehci_err(ehci, "timeout waiting for SUSPEND\n"); 258 + 259 + if (ci->platdata->flags & CI_HDRC_IMX_IS_HSIC) { 260 + if (ci->platdata->notify_event) 261 + ci->platdata->notify_event(ci, 262 + CI_HDRC_IMX_HSIC_SUSPEND_EVENT); 263 + 264 + temp = ehci_readl(ehci, status_reg); 265 + temp &= ~(PORT_WKDISC_E | PORT_WKCONN_E); 266 + ehci_writel(ehci, temp, status_reg); 267 + } 268 + 269 + set_bit((wIndex & 0xff) - 1, &ehci->suspended_ports); 270 + goto done; 271 + } 272 + 273 + /* 274 + * After resume has finished, it needs do some post resume 275 + * operation for some SoCs. 276 + */ 277 + else if (typeReq == ClearPortFeature && 278 + wValue == USB_PORT_FEAT_C_SUSPEND) { 279 + /* Make sure the resume has finished, it should be finished */ 280 + if (ehci_handshake(ehci, status_reg, PORT_RESUME, 0, 25000)) 281 + ehci_err(ehci, "timeout waiting for resume\n"); 282 + } 283 + 284 + spin_unlock_irqrestore(&ehci->lock, flags); 285 + 286 + /* Handle the hub control events here */ 287 + return ehci_hub_control(hcd, typeReq, wValue, wIndex, buf, wLength); 288 + done: 289 + spin_unlock_irqrestore(&ehci->lock, flags); 290 + return retval; 291 + } 223 292 static int ci_ehci_bus_suspend(struct usb_hcd *hcd) 224 293 { 225 294 struct ehci_hcd *ehci = hcd_to_ehci(hcd); 295 + struct device *dev = hcd->self.controller; 296 + struct ci_hdrc *ci = dev_get_drvdata(dev); 226 297 int port; 227 298 u32 tmp; 228 299 ··· 330 249 * It needs a short delay between set RS bit and PHCD. 331 250 */ 332 251 usleep_range(150, 200); 252 + /* 253 + * Need to clear WKCN and WKOC for imx HSIC, 254 + * otherwise, there will be wakeup event. 255 + */ 256 + if (ci->platdata->flags & CI_HDRC_IMX_IS_HSIC) { 257 + tmp = ehci_readl(ehci, reg); 258 + tmp &= ~(PORT_WKDISC_E | PORT_WKCONN_E); 259 + ehci_writel(ehci, tmp, reg); 260 + } 261 + 333 262 break; 334 263 } 335 264 } ··· 372 281 ehci_init_driver(&ci_ehci_hc_driver, &ehci_ci_overrides); 373 282 orig_bus_suspend = ci_ehci_hc_driver.bus_suspend; 374 283 ci_ehci_hc_driver.bus_suspend = ci_ehci_bus_suspend; 284 + ci_ehci_hc_driver.hub_control = ci_ehci_hub_control; 375 285 }
+176 -7
drivers/usb/chipidea/usbmisc_imx.c
··· 64 64 #define MX6_BM_OVER_CUR_DIS BIT(7) 65 65 #define MX6_BM_OVER_CUR_POLARITY BIT(8) 66 66 #define MX6_BM_WAKEUP_ENABLE BIT(10) 67 + #define MX6_BM_UTMI_ON_CLOCK BIT(13) 67 68 #define MX6_BM_ID_WAKEUP BIT(16) 68 69 #define MX6_BM_VBUS_WAKEUP BIT(17) 69 70 #define MX6SX_BM_DPDM_WAKEUP_EN BIT(29) 70 71 #define MX6_BM_WAKEUP_INTR BIT(31) 72 + 73 + #define MX6_USB_HSIC_CTRL_OFFSET 0x10 74 + /* Send resume signal without 480Mhz PHY clock */ 75 + #define MX6SX_BM_HSIC_AUTO_RESUME BIT(23) 76 + /* set before portsc.suspendM = 1 */ 77 + #define MX6_BM_HSIC_DEV_CONN BIT(21) 78 + /* HSIC enable */ 79 + #define MX6_BM_HSIC_EN BIT(12) 80 + /* Force HSIC module 480M clock on, even when in Host is in suspend mode */ 81 + #define MX6_BM_HSIC_CLK_ON BIT(11) 82 + 71 83 #define MX6_USB_OTG1_PHY_CTRL 0x18 72 84 /* For imx6dql, it is host-only controller, for later imx6, it is otg's */ 73 85 #define MX6_USB_OTG2_PHY_CTRL 0x1c ··· 106 94 int (*post)(struct imx_usbmisc_data *data); 107 95 /* It's called when we need to enable/disable usb wakeup */ 108 96 int (*set_wakeup)(struct imx_usbmisc_data *data, bool enabled); 97 + /* It's called before setting portsc.suspendM */ 98 + int (*hsic_set_connect)(struct imx_usbmisc_data *data); 99 + /* It's called during suspend/resume */ 100 + int (*hsic_set_clk)(struct imx_usbmisc_data *data, bool enabled); 109 101 }; 110 102 111 103 struct imx_usbmisc { ··· 136 120 val &= ~(MX25_OTG_SIC_MASK | MX25_OTG_PP_BIT); 137 121 val |= (MX25_EHCI_INTERFACE_DIFF_UNI & MX25_EHCI_INTERFACE_MASK) << MX25_OTG_SIC_SHIFT; 138 122 val |= (MX25_OTG_PM_BIT | MX25_OTG_OCPOL_BIT); 123 + 124 + /* 125 + * If the polarity is not configured assume active high for 126 + * historical reasons. 127 + */ 128 + if (data->oc_pol_configured && data->oc_pol_active_low) 129 + val &= ~MX25_OTG_OCPOL_BIT; 130 + 139 131 writel(val, usbmisc->base); 140 132 break; 141 133 case 1: ··· 152 128 val |= (MX25_EHCI_INTERFACE_SINGLE_UNI & MX25_EHCI_INTERFACE_MASK) << MX25_H1_SIC_SHIFT; 153 129 val |= (MX25_H1_PM_BIT | MX25_H1_OCPOL_BIT | MX25_H1_TLL_BIT | 154 130 MX25_H1_USBTE_BIT | MX25_H1_IPPUE_DOWN_BIT); 131 + 132 + /* 133 + * If the polarity is not configured assume active high for 134 + * historical reasons. 135 + */ 136 + if (data->oc_pol_configured && data->oc_pol_active_low) 137 + val &= ~MX25_H1_OCPOL_BIT; 155 138 156 139 writel(val, usbmisc->base); 157 140 ··· 371 340 reg = readl(usbmisc->base + data->index * 4); 372 341 if (data->disable_oc) { 373 342 reg |= MX6_BM_OVER_CUR_DIS; 374 - } else if (data->oc_polarity == 1) { 375 - /* High active */ 376 - reg &= ~(MX6_BM_OVER_CUR_DIS | MX6_BM_OVER_CUR_POLARITY); 377 343 } else { 378 - reg &= ~(MX6_BM_OVER_CUR_DIS); 344 + reg &= ~MX6_BM_OVER_CUR_DIS; 345 + 346 + /* 347 + * If the polarity is not configured keep it as setup by the 348 + * bootloader. 349 + */ 350 + if (data->oc_pol_configured && data->oc_pol_active_low) 351 + reg |= MX6_BM_OVER_CUR_POLARITY; 352 + else if (data->oc_pol_configured) 353 + reg &= ~MX6_BM_OVER_CUR_POLARITY; 379 354 } 380 355 writel(reg, usbmisc->base + data->index * 4); 381 356 ··· 390 353 writel(reg | MX6_BM_NON_BURST_SETTING, 391 354 usbmisc->base + data->index * 4); 392 355 356 + /* For HSIC controller */ 357 + if (data->hsic) { 358 + reg = readl(usbmisc->base + data->index * 4); 359 + writel(reg | MX6_BM_UTMI_ON_CLOCK, 360 + usbmisc->base + data->index * 4); 361 + reg = readl(usbmisc->base + MX6_USB_HSIC_CTRL_OFFSET 362 + + (data->index - 2) * 4); 363 + reg |= MX6_BM_HSIC_EN | MX6_BM_HSIC_CLK_ON; 364 + writel(reg, usbmisc->base + MX6_USB_HSIC_CTRL_OFFSET 365 + + (data->index - 2) * 4); 366 + } 367 + 393 368 spin_unlock_irqrestore(&usbmisc->lock, flags); 394 369 395 370 usbmisc_imx6q_set_wakeup(data, false); 396 371 397 372 return 0; 398 373 } 374 + 375 + static int usbmisc_imx6_hsic_get_reg_offset(struct imx_usbmisc_data *data) 376 + { 377 + int offset, ret = 0; 378 + 379 + if (data->index == 2 || data->index == 3) { 380 + offset = (data->index - 2) * 4; 381 + } else if (data->index == 0) { 382 + /* 383 + * For SoCs like i.MX7D and later, each USB controller has 384 + * its own non-core register region. For SoCs before i.MX7D, 385 + * the first two USB controllers are non-HSIC controllers. 386 + */ 387 + offset = 0; 388 + } else { 389 + dev_err(data->dev, "index is error for usbmisc\n"); 390 + ret = -EINVAL; 391 + } 392 + 393 + return ret ? ret : offset; 394 + } 395 + 396 + static int usbmisc_imx6_hsic_set_connect(struct imx_usbmisc_data *data) 397 + { 398 + unsigned long flags; 399 + u32 val; 400 + struct imx_usbmisc *usbmisc = dev_get_drvdata(data->dev); 401 + int offset; 402 + 403 + spin_lock_irqsave(&usbmisc->lock, flags); 404 + offset = usbmisc_imx6_hsic_get_reg_offset(data); 405 + if (offset < 0) { 406 + spin_unlock_irqrestore(&usbmisc->lock, flags); 407 + return offset; 408 + } 409 + 410 + val = readl(usbmisc->base + MX6_USB_HSIC_CTRL_OFFSET + offset); 411 + if (!(val & MX6_BM_HSIC_DEV_CONN)) 412 + writel(val | MX6_BM_HSIC_DEV_CONN, 413 + usbmisc->base + MX6_USB_HSIC_CTRL_OFFSET + offset); 414 + 415 + spin_unlock_irqrestore(&usbmisc->lock, flags); 416 + 417 + return 0; 418 + } 419 + 420 + static int usbmisc_imx6_hsic_set_clk(struct imx_usbmisc_data *data, bool on) 421 + { 422 + unsigned long flags; 423 + u32 val; 424 + struct imx_usbmisc *usbmisc = dev_get_drvdata(data->dev); 425 + int offset; 426 + 427 + spin_lock_irqsave(&usbmisc->lock, flags); 428 + offset = usbmisc_imx6_hsic_get_reg_offset(data); 429 + if (offset < 0) { 430 + spin_unlock_irqrestore(&usbmisc->lock, flags); 431 + return offset; 432 + } 433 + 434 + val = readl(usbmisc->base + MX6_USB_HSIC_CTRL_OFFSET + offset); 435 + val |= MX6_BM_HSIC_EN | MX6_BM_HSIC_CLK_ON; 436 + if (on) 437 + val |= MX6_BM_HSIC_CLK_ON; 438 + else 439 + val &= ~MX6_BM_HSIC_CLK_ON; 440 + 441 + writel(val, usbmisc->base + MX6_USB_HSIC_CTRL_OFFSET + offset); 442 + spin_unlock_irqrestore(&usbmisc->lock, flags); 443 + 444 + return 0; 445 + } 446 + 399 447 400 448 static int usbmisc_imx6sx_init(struct imx_usbmisc_data *data) 401 449 { ··· 505 383 writel(val & ~MX6SX_BM_DPDM_WAKEUP_EN, 506 384 usbmisc->base + data->index * 4); 507 385 spin_unlock_irqrestore(&usbmisc->lock, flags); 386 + } 387 + 388 + /* For HSIC controller */ 389 + if (data->hsic) { 390 + val = readl(usbmisc->base + MX6_USB_HSIC_CTRL_OFFSET); 391 + val |= MX6SX_BM_HSIC_AUTO_RESUME; 392 + writel(val, usbmisc->base + MX6_USB_HSIC_CTRL_OFFSET); 508 393 } 509 394 510 395 return 0; ··· 573 444 reg = readl(usbmisc->base); 574 445 if (data->disable_oc) { 575 446 reg |= MX6_BM_OVER_CUR_DIS; 576 - } else if (data->oc_polarity == 1) { 577 - /* High active */ 578 - reg &= ~(MX6_BM_OVER_CUR_DIS | MX6_BM_OVER_CUR_POLARITY); 447 + } else { 448 + reg &= ~MX6_BM_OVER_CUR_DIS; 449 + 450 + /* 451 + * If the polarity is not configured keep it as setup by the 452 + * bootloader. 453 + */ 454 + if (data->oc_pol_configured && data->oc_pol_active_low) 455 + reg |= MX6_BM_OVER_CUR_POLARITY; 456 + else if (data->oc_pol_configured) 457 + reg &= ~MX6_BM_OVER_CUR_POLARITY; 579 458 } 580 459 writel(reg, usbmisc->base); 581 460 ··· 591 454 reg &= ~MX7D_USB_VBUS_WAKEUP_SOURCE_MASK; 592 455 writel(reg | MX7D_USB_VBUS_WAKEUP_SOURCE_BVALID, 593 456 usbmisc->base + MX7D_USBNC_USB_CTRL2); 457 + 594 458 spin_unlock_irqrestore(&usbmisc->lock, flags); 595 459 596 460 usbmisc_imx7d_set_wakeup(data, false); ··· 619 481 static const struct usbmisc_ops imx6q_usbmisc_ops = { 620 482 .set_wakeup = usbmisc_imx6q_set_wakeup, 621 483 .init = usbmisc_imx6q_init, 484 + .hsic_set_connect = usbmisc_imx6_hsic_set_connect, 485 + .hsic_set_clk = usbmisc_imx6_hsic_set_clk, 622 486 }; 623 487 624 488 static const struct usbmisc_ops vf610_usbmisc_ops = { ··· 630 490 static const struct usbmisc_ops imx6sx_usbmisc_ops = { 631 491 .set_wakeup = usbmisc_imx6q_set_wakeup, 632 492 .init = usbmisc_imx6sx_init, 493 + .hsic_set_connect = usbmisc_imx6_hsic_set_connect, 494 + .hsic_set_clk = usbmisc_imx6_hsic_set_clk, 633 495 }; 634 496 635 497 static const struct usbmisc_ops imx7d_usbmisc_ops = { ··· 688 546 } 689 547 EXPORT_SYMBOL_GPL(imx_usbmisc_set_wakeup); 690 548 549 + int imx_usbmisc_hsic_set_connect(struct imx_usbmisc_data *data) 550 + { 551 + struct imx_usbmisc *usbmisc; 552 + 553 + if (!data) 554 + return 0; 555 + 556 + usbmisc = dev_get_drvdata(data->dev); 557 + if (!usbmisc->ops->hsic_set_connect || !data->hsic) 558 + return 0; 559 + return usbmisc->ops->hsic_set_connect(data); 560 + } 561 + EXPORT_SYMBOL_GPL(imx_usbmisc_hsic_set_connect); 562 + 563 + int imx_usbmisc_hsic_set_clk(struct imx_usbmisc_data *data, bool on) 564 + { 565 + struct imx_usbmisc *usbmisc; 566 + 567 + if (!data) 568 + return 0; 569 + 570 + usbmisc = dev_get_drvdata(data->dev); 571 + if (!usbmisc->ops->hsic_set_clk || !data->hsic) 572 + return 0; 573 + return usbmisc->ops->hsic_set_clk(data, on); 574 + } 575 + EXPORT_SYMBOL_GPL(imx_usbmisc_hsic_set_clk); 691 576 static const struct of_device_id usbmisc_imx_dt_ids[] = { 692 577 { 693 578 .compatible = "fsl,imx25-usbmisc",
+10
drivers/usb/class/cdc-acm.c
··· 581 581 if (retval) 582 582 goto error_init_termios; 583 583 584 + /* 585 + * Suppress initial echoing for some devices which might send data 586 + * immediately after acm driver has been installed. 587 + */ 588 + if (acm->quirks & DISABLE_ECHO) 589 + tty->termios.c_lflag &= ~ECHO; 590 + 584 591 tty->driver_data = acm; 585 592 586 593 return 0; ··· 1663 1656 }, 1664 1657 { USB_DEVICE(0x0e8d, 0x0003), /* FIREFLY, MediaTek Inc; andrey.arapov@gmail.com */ 1665 1658 .driver_info = NO_UNION_NORMAL, /* has no union descriptor */ 1659 + }, 1660 + { USB_DEVICE(0x0e8d, 0x2000), /* MediaTek Inc Preloader */ 1661 + .driver_info = DISABLE_ECHO, /* DISABLE ECHO in termios flag */ 1666 1662 }, 1667 1663 { USB_DEVICE(0x0e8d, 0x3329), /* MediaTek Inc GPS */ 1668 1664 .driver_info = NO_UNION_NORMAL, /* has no union descriptor */
+1
drivers/usb/class/cdc-acm.h
··· 140 140 #define QUIRK_CONTROL_LINE_STATE BIT(6) 141 141 #define CLEAR_HALT_CONDITIONS BIT(7) 142 142 #define SEND_ZERO_PACKET BIT(8) 143 + #define DISABLE_ECHO BIT(9)
-1
drivers/usb/common/Makefile
··· 9 9 10 10 obj-$(CONFIG_USB_OTG_FSM) += usb-otg-fsm.o 11 11 obj-$(CONFIG_USB_ULPI_BUS) += ulpi.o 12 - obj-$(CONFIG_USB_ROLE_SWITCH) += roles.o
drivers/usb/common/roles.c drivers/usb/roles/class.c
-2
drivers/usb/core/hcd.c
··· 1074 1074 1075 1075 usb_dev->devnum = devnum; 1076 1076 usb_dev->bus->devnum_next = devnum + 1; 1077 - memset (&usb_dev->bus->devmap.devicemap, 0, 1078 - sizeof usb_dev->bus->devmap.devicemap); 1079 1077 set_bit (devnum, usb_dev->bus->devmap.devicemap); 1080 1078 usb_set_device_state(usb_dev, USB_STATE_ADDRESS); 1081 1079
+10
drivers/usb/core/hub.c
··· 1112 1112 USB_PORT_FEAT_ENABLE); 1113 1113 } 1114 1114 1115 + /* 1116 + * Add debounce if USB3 link is in polling/link training state. 1117 + * Link will automatically transition to Enabled state after 1118 + * link training completes. 1119 + */ 1120 + if (hub_is_superspeed(hdev) && 1121 + ((portstatus & USB_PORT_STAT_LINK_STATE) == 1122 + USB_SS_PORT_LS_POLLING)) 1123 + need_debounce_delay = true; 1124 + 1115 1125 /* Clear status-change flags; we'll debounce later */ 1116 1126 if (portchange & USB_PORT_STAT_C_CONNECTION) { 1117 1127 need_debounce_delay = true;
+25 -19
drivers/usb/dwc2/gadget.c
··· 262 262 if (gintsts2 & GINTSTS2_WKUP_ALERT_INT) { 263 263 dev_dbg(hsotg->dev, "%s: Wkup_Alert_Int\n", __func__); 264 264 dwc2_clear_bit(hsotg, GINTSTS2, GINTSTS2_WKUP_ALERT_INT); 265 - dwc2_set_bit(hsotg, DCFG, DCTL_RMTWKUPSIG); 265 + dwc2_set_bit(hsotg, DCTL, DCTL_RMTWKUPSIG); 266 266 } 267 267 } 268 268 ··· 3165 3165 dwc2_hsotg_txfifo_flush(hsotg, ep->fifo_index); 3166 3166 } 3167 3167 3168 - static int dwc2_hsotg_ep_disable(struct usb_ep *ep); 3169 - 3170 3168 /** 3171 3169 * dwc2_hsotg_disconnect - disconnect service 3172 3170 * @hsotg: The device state. ··· 3186 3188 /* all endpoints should be shutdown */ 3187 3189 for (ep = 0; ep < hsotg->num_of_eps; ep++) { 3188 3190 if (hsotg->eps_in[ep]) 3189 - dwc2_hsotg_ep_disable(&hsotg->eps_in[ep]->ep); 3191 + kill_all_requests(hsotg, hsotg->eps_in[ep], 3192 + -ESHUTDOWN); 3190 3193 if (hsotg->eps_out[ep]) 3191 - dwc2_hsotg_ep_disable(&hsotg->eps_out[ep]->ep); 3194 + kill_all_requests(hsotg, hsotg->eps_out[ep], 3195 + -ESHUTDOWN); 3192 3196 } 3193 3197 3194 3198 call_gadget(hsotg, disconnect); ··· 3234 3234 GINTSTS_PTXFEMP | \ 3235 3235 GINTSTS_RXFLVL) 3236 3236 3237 + static int dwc2_hsotg_ep_disable(struct usb_ep *ep); 3237 3238 /** 3238 3239 * dwc2_hsotg_core_init - issue softreset to the core 3239 3240 * @hsotg: The device state ··· 4070 4069 struct dwc2_hsotg *hsotg = hs_ep->parent; 4071 4070 int dir_in = hs_ep->dir_in; 4072 4071 int index = hs_ep->index; 4073 - unsigned long flags; 4074 4072 u32 epctrl_reg; 4075 4073 u32 ctrl; 4076 - int locked; 4077 4074 4078 4075 dev_dbg(hsotg->dev, "%s(ep %p)\n", __func__, ep); 4079 4076 ··· 4086 4087 } 4087 4088 4088 4089 epctrl_reg = dir_in ? DIEPCTL(index) : DOEPCTL(index); 4089 - 4090 - locked = spin_is_locked(&hsotg->lock); 4091 - if (!locked) 4092 - spin_lock_irqsave(&hsotg->lock, flags); 4093 4090 4094 4091 ctrl = dwc2_readl(hsotg, epctrl_reg); 4095 4092 ··· 4109 4114 hs_ep->fifo_index = 0; 4110 4115 hs_ep->fifo_size = 0; 4111 4116 4112 - if (!locked) 4113 - spin_unlock_irqrestore(&hsotg->lock, flags); 4114 - 4115 4117 return 0; 4118 + } 4119 + 4120 + static int dwc2_hsotg_ep_disable_lock(struct usb_ep *ep) 4121 + { 4122 + struct dwc2_hsotg_ep *hs_ep = our_ep(ep); 4123 + struct dwc2_hsotg *hsotg = hs_ep->parent; 4124 + unsigned long flags; 4125 + int ret; 4126 + 4127 + spin_lock_irqsave(&hsotg->lock, flags); 4128 + ret = dwc2_hsotg_ep_disable(ep); 4129 + spin_unlock_irqrestore(&hsotg->lock, flags); 4130 + return ret; 4116 4131 } 4117 4132 4118 4133 /** ··· 4272 4267 4273 4268 static const struct usb_ep_ops dwc2_hsotg_ep_ops = { 4274 4269 .enable = dwc2_hsotg_ep_enable, 4275 - .disable = dwc2_hsotg_ep_disable, 4270 + .disable = dwc2_hsotg_ep_disable_lock, 4276 4271 .alloc_request = dwc2_hsotg_ep_alloc_request, 4277 4272 .free_request = dwc2_hsotg_ep_free_request, 4278 4273 .queue = dwc2_hsotg_ep_queue_lock, ··· 4412 4407 /* all endpoints should be shutdown */ 4413 4408 for (ep = 1; ep < hsotg->num_of_eps; ep++) { 4414 4409 if (hsotg->eps_in[ep]) 4415 - dwc2_hsotg_ep_disable(&hsotg->eps_in[ep]->ep); 4410 + dwc2_hsotg_ep_disable_lock(&hsotg->eps_in[ep]->ep); 4416 4411 if (hsotg->eps_out[ep]) 4417 - dwc2_hsotg_ep_disable(&hsotg->eps_out[ep]->ep); 4412 + dwc2_hsotg_ep_disable_lock(&hsotg->eps_out[ep]->ep); 4418 4413 } 4419 4414 4420 4415 spin_lock_irqsave(&hsotg->lock, flags); ··· 4862 4857 4863 4858 for (ep = 0; ep < hsotg->num_of_eps; ep++) { 4864 4859 if (hsotg->eps_in[ep]) 4865 - dwc2_hsotg_ep_disable(&hsotg->eps_in[ep]->ep); 4860 + dwc2_hsotg_ep_disable_lock(&hsotg->eps_in[ep]->ep); 4866 4861 if (hsotg->eps_out[ep]) 4867 - dwc2_hsotg_ep_disable(&hsotg->eps_out[ep]->ep); 4862 + dwc2_hsotg_ep_disable_lock(&hsotg->eps_out[ep]->ep); 4868 4863 } 4869 4864 } 4870 4865 ··· 5031 5026 val |= hsotg->params.lpm_clock_gating ? GLPMCFG_ENBLSLPM : 0; 5032 5027 val |= hsotg->params.hird_threshold << GLPMCFG_HIRD_THRES_SHIFT; 5033 5028 val |= hsotg->params.besl ? GLPMCFG_ENBESL : 0; 5029 + val |= GLPMCFG_LPM_ACCEPT_CTRL_ISOC; 5034 5030 dwc2_writel(hsotg, val, GLPMCFG); 5035 5031 dev_dbg(hsotg->dev, "GLPMCFG=0x%08x\n", dwc2_readl(hsotg, GLPMCFG)); 5036 5032
+1 -1
drivers/usb/dwc2/hcd.h
··· 366 366 u32 desc_list_sz; 367 367 u32 *n_bytes; 368 368 struct timer_list unreserve_timer; 369 - struct timer_list wait_timer; 369 + struct hrtimer wait_timer; 370 370 struct dwc2_tt *dwc_tt; 371 371 int ttport; 372 372 unsigned tt_buffer_dirty:1;
+12 -7
drivers/usb/dwc2/hcd_queue.c
··· 59 59 #define DWC2_UNRESERVE_DELAY (msecs_to_jiffies(5)) 60 60 61 61 /* If we get a NAK, wait this long before retrying */ 62 - #define DWC2_RETRY_WAIT_DELAY (msecs_to_jiffies(1)) 62 + #define DWC2_RETRY_WAIT_DELAY 1*1E6L 63 63 64 64 /** 65 65 * dwc2_periodic_channel_available() - Checks that a channel is available for a ··· 1464 1464 * qh back to the "inactive" list, then queues transactions. 1465 1465 * 1466 1466 * @t: Pointer to wait_timer in a qh. 1467 + * 1468 + * Return: HRTIMER_NORESTART to not automatically restart this timer. 1467 1469 */ 1468 - static void dwc2_wait_timer_fn(struct timer_list *t) 1470 + static enum hrtimer_restart dwc2_wait_timer_fn(struct hrtimer *t) 1469 1471 { 1470 - struct dwc2_qh *qh = from_timer(qh, t, wait_timer); 1472 + struct dwc2_qh *qh = container_of(t, struct dwc2_qh, wait_timer); 1471 1473 struct dwc2_hsotg *hsotg = qh->hsotg; 1472 1474 unsigned long flags; 1473 1475 ··· 1493 1491 } 1494 1492 1495 1493 spin_unlock_irqrestore(&hsotg->lock, flags); 1494 + return HRTIMER_NORESTART; 1496 1495 } 1497 1496 1498 1497 /** ··· 1524 1521 /* Initialize QH */ 1525 1522 qh->hsotg = hsotg; 1526 1523 timer_setup(&qh->unreserve_timer, dwc2_unreserve_timer_fn, 0); 1527 - timer_setup(&qh->wait_timer, dwc2_wait_timer_fn, 0); 1524 + hrtimer_init(&qh->wait_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); 1525 + qh->wait_timer.function = &dwc2_wait_timer_fn; 1528 1526 qh->ep_type = ep_type; 1529 1527 qh->ep_is_in = ep_is_in; 1530 1528 ··· 1694 1690 * won't do anything anyway, but we want it to finish before we free 1695 1691 * memory. 1696 1692 */ 1697 - del_timer_sync(&qh->wait_timer); 1693 + hrtimer_cancel(&qh->wait_timer); 1698 1694 1699 1695 dwc2_host_put_tt_info(hsotg, qh->dwc_tt); 1700 1696 ··· 1720 1716 { 1721 1717 int status; 1722 1718 u32 intr_mask; 1719 + ktime_t delay; 1723 1720 1724 1721 if (dbg_qh(qh)) 1725 1722 dev_vdbg(hsotg->dev, "%s()\n", __func__); ··· 1739 1734 list_add_tail(&qh->qh_list_entry, 1740 1735 &hsotg->non_periodic_sched_waiting); 1741 1736 qh->wait_timer_cancel = false; 1742 - mod_timer(&qh->wait_timer, 1743 - jiffies + DWC2_RETRY_WAIT_DELAY + 1); 1737 + delay = ktime_set(0, DWC2_RETRY_WAIT_DELAY); 1738 + hrtimer_start(&qh->wait_timer, delay, HRTIMER_MODE_REL); 1744 1739 } else { 1745 1740 list_add_tail(&qh->qh_list_entry, 1746 1741 &hsotg->non_periodic_sched_inactive);
+2
drivers/usb/dwc2/hw.h
··· 333 333 #define GLPMCFG_SNDLPM BIT(24) 334 334 #define GLPMCFG_RETRY_CNT_MASK (0x7 << 21) 335 335 #define GLPMCFG_RETRY_CNT_SHIFT 21 336 + #define GLPMCFG_LPM_ACCEPT_CTRL_CONTROL BIT(21) 337 + #define GLPMCFG_LPM_ACCEPT_CTRL_ISOC BIT(22) 336 338 #define GLPMCFG_LPM_CHNL_INDX_MASK (0xf << 17) 337 339 #define GLPMCFG_LPM_CHNL_INDX_SHIFT 17 338 340 #define GLPMCFG_L1RESUMEOK BIT(16)
+10 -1
drivers/usb/dwc2/params.c
··· 71 71 p->power_down = false; 72 72 } 73 73 74 + static void dwc2_set_s3c6400_params(struct dwc2_hsotg *hsotg) 75 + { 76 + struct dwc2_core_params *p = &hsotg->params; 77 + 78 + p->power_down = 0; 79 + } 80 + 74 81 static void dwc2_set_rk_params(struct dwc2_hsotg *hsotg) 75 82 { 76 83 struct dwc2_core_params *p = &hsotg->params; ··· 118 111 p->phy_type = DWC2_PHY_TYPE_PARAM_UTMI; 119 112 p->ahbcfg = GAHBCFG_HBSTLEN_INCR8 << 120 113 GAHBCFG_HBSTLEN_SHIFT; 114 + p->power_down = DWC2_POWER_DOWN_PARAM_NONE; 121 115 } 122 116 123 117 static void dwc2_set_amcc_params(struct dwc2_hsotg *hsotg) ··· 159 151 { .compatible = "lantiq,arx100-usb", .data = dwc2_set_ltq_params }, 160 152 { .compatible = "lantiq,xrx200-usb", .data = dwc2_set_ltq_params }, 161 153 { .compatible = "snps,dwc2" }, 162 - { .compatible = "samsung,s3c6400-hsotg" }, 154 + { .compatible = "samsung,s3c6400-hsotg", 155 + .data = dwc2_set_s3c6400_params }, 163 156 { .compatible = "amlogic,meson8-usb", 164 157 .data = dwc2_set_amlogic_params }, 165 158 { .compatible = "amlogic,meson8b-usb",
+14 -5
drivers/usb/dwc3/core.c
··· 80 80 mode = USB_DR_MODE_PERIPHERAL; 81 81 82 82 /* 83 - * dwc_usb31 does not support OTG mode. If the controller 84 - * supports DRD but the dr_mode is not specified or set to OTG, 85 - * then set the mode to peripheral. 83 + * DWC_usb31 and DWC_usb3 v3.30a and higher do not support OTG 84 + * mode. If the controller supports DRD but the dr_mode is not 85 + * specified or set to OTG, then set the mode to peripheral. 86 86 */ 87 - if (mode == USB_DR_MODE_OTG && dwc3_is_usb31(dwc)) 87 + if (mode == USB_DR_MODE_OTG && 88 + dwc->revision >= DWC3_REVISION_330A) 88 89 mode = USB_DR_MODE_PERIPHERAL; 89 90 } 90 91 ··· 662 661 663 662 if (dwc->dis_enblslpm_quirk) 664 663 reg &= ~DWC3_GUSB2PHYCFG_ENBLSLPM; 664 + else 665 + reg |= DWC3_GUSB2PHYCFG_ENBLSLPM; 665 666 666 667 if (dwc->dis_u2_freeclk_exists_quirk) 667 668 reg &= ~DWC3_GUSB2PHYCFG_U2_FREECLK_EXISTS; ··· 705 702 /* Detected DWC_usb31 IP */ 706 703 dwc->revision = dwc3_readl(dwc->regs, DWC3_VER_NUMBER); 707 704 dwc->revision |= DWC3_REVISION_IS_DWC31; 705 + dwc->version_type = dwc3_readl(dwc->regs, DWC3_VER_TYPE); 708 706 } else { 709 707 return false; 710 708 } ··· 1248 1244 "snps,is-utmi-l1-suspend"); 1249 1245 device_property_read_u8(dev, "snps,hird-threshold", 1250 1246 &hird_threshold); 1247 + dwc->dis_start_transfer_quirk = device_property_read_bool(dev, 1248 + "snps,dis-start-transfer-quirk"); 1251 1249 dwc->usb3_lpm_capable = device_property_read_bool(dev, 1252 1250 "snps,usb3_lpm_capable"); 1251 + dwc->usb2_lpm_disable = device_property_read_bool(dev, 1252 + "snps,usb2-lpm-disable"); 1253 1253 device_property_read_u8(dev, "snps,rx-thr-num-pkt-prd", 1254 1254 &rx_thr_num_pkt_prd); 1255 1255 device_property_read_u8(dev, "snps,rx-max-burst-prd", ··· 1490 1482 1491 1483 ret = dwc3_core_init(dwc); 1492 1484 if (ret) { 1493 - dev_err(dev, "failed to initialize core\n"); 1485 + if (ret != -EPROBE_DEFER) 1486 + dev_err(dev, "failed to initialize core: %d\n", ret); 1494 1487 goto err4; 1495 1488 } 1496 1489
+51 -9
drivers/usb/dwc3/core.h
··· 37 37 #define DWC3_EP0_SETUP_SIZE 512 38 38 #define DWC3_ENDPOINTS_NUM 32 39 39 #define DWC3_XHCI_RESOURCES_NUM 2 40 + #define DWC3_ISOC_MAX_RETRIES 5 40 41 41 42 #define DWC3_SCRATCHBUF_SIZE 4096 /* each buffer is assumed to be 4KiB */ 42 43 #define DWC3_EVENT_BUFFERS_SIZE 4096 ··· 175 174 #define DWC3_GSBUSCFG0_INCRBRSTENA (1 << 0) /* undefined length enable */ 176 175 #define DWC3_GSBUSCFG0_INCRBRST_MASK 0xff 177 176 177 + /* Global Debug LSP MUX Select */ 178 + #define DWC3_GDBGLSPMUX_ENDBC BIT(15) /* Host only */ 179 + #define DWC3_GDBGLSPMUX_HOSTSELECT(n) ((n) & 0x3fff) 180 + #define DWC3_GDBGLSPMUX_DEVSELECT(n) (((n) & 0xf) << 4) 181 + #define DWC3_GDBGLSPMUX_EPSELECT(n) ((n) & 0xf) 182 + 178 183 /* Global Debug Queue/FIFO Space Available Register */ 179 184 #define DWC3_GDBGFIFOSPACE_NUM(n) ((n) & 0x1f) 180 185 #define DWC3_GDBGFIFOSPACE_TYPE(n) (((n) << 5) & 0x1e0) 181 186 #define DWC3_GDBGFIFOSPACE_SPACE_AVAILABLE(n) (((n) >> 16) & 0xffff) 182 187 183 - #define DWC3_TXFIFOQ 0 184 - #define DWC3_RXFIFOQ 1 188 + #define DWC3_TXFIFO 0 189 + #define DWC3_RXFIFO 1 185 190 #define DWC3_TXREQQ 2 186 191 #define DWC3_RXREQQ 3 187 192 #define DWC3_RXINFOQ 4 ··· 260 253 #define DWC3_GSTS_DEVICE_IP BIT(6) 261 254 #define DWC3_GSTS_CSR_TIMEOUT BIT(5) 262 255 #define DWC3_GSTS_BUS_ERR_ADDR_VLD BIT(4) 256 + #define DWC3_GSTS_CURMOD(n) ((n) & 0x3) 257 + #define DWC3_GSTS_CURMOD_DEVICE 0 258 + #define DWC3_GSTS_CURMOD_HOST 1 263 259 264 260 /* Global USB2 PHY Configuration Register */ 265 261 #define DWC3_GUSB2PHYCFG_PHYSOFTRST BIT(31) ··· 331 321 #define DWC3_GHWPARAMS1_EN_PWROPT_HIB 2 332 322 #define DWC3_GHWPARAMS1_PWROPT(n) ((n) << 24) 333 323 #define DWC3_GHWPARAMS1_PWROPT_MASK DWC3_GHWPARAMS1_PWROPT(3) 324 + #define DWC3_GHWPARAMS1_ENDBC BIT(31) 334 325 335 326 /* Global HWPARAMS3 Register */ 336 327 #define DWC3_GHWPARAMS3_SSPHY_IFC(n) ((n) & 3) ··· 647 636 /** 648 637 * struct dwc3_ep - device side endpoint representation 649 638 * @endpoint: usb endpoint 639 + * @cancelled_list: list of cancelled requests for this endpoint 650 640 * @pending_list: list of pending requests for this endpoint 651 641 * @started_list: list of started requests on this endpoint 652 - * @wait_end_transfer: wait_queue_head_t for waiting on End Transfer complete 653 642 * @lock: spinlock for endpoint request queue traversal 654 643 * @regs: pointer to first endpoint register 655 644 * @trb_pool: array of transaction buffers ··· 667 656 * @name: a human readable name e.g. ep1out-bulk 668 657 * @direction: true for TX, false for RX 669 658 * @stream_capable: true when streams are enabled 659 + * @combo_num: the test combination BIT[15:14] of the frame number to test 660 + * isochronous START TRANSFER command failure workaround 661 + * @start_cmd_status: the status of testing START TRANSFER command with 662 + * combo_num = 'b00 670 663 */ 671 664 struct dwc3_ep { 672 665 struct usb_ep endpoint; 666 + struct list_head cancelled_list; 673 667 struct list_head pending_list; 674 668 struct list_head started_list; 675 - 676 - wait_queue_head_t wait_end_transfer; 677 669 678 670 spinlock_t lock; 679 671 void __iomem *regs; ··· 719 705 720 706 unsigned direction:1; 721 707 unsigned stream_capable:1; 708 + 709 + /* For isochronous START TRANSFER workaround only */ 710 + u8 combo_num; 711 + int start_cmd_status; 722 712 }; 723 713 724 714 enum dwc3_phy { ··· 784 766 #define DWC3_TRB_CTRL_ISP_IMI BIT(10) 785 767 #define DWC3_TRB_CTRL_IOC BIT(11) 786 768 #define DWC3_TRB_CTRL_SID_SOFN(n) (((n) & 0xffff) << 14) 769 + #define DWC3_TRB_CTRL_GET_SID_SOFN(n) (((n) & (0xffff << 14)) >> 14) 787 770 788 771 #define DWC3_TRBCTL_TYPE(n) ((n) & (0x3f << 4)) 789 772 #define DWC3_TRBCTL_NORMAL DWC3_TRB_CTRL_TRBCTL(1) ··· 866 847 * @epnum: endpoint number to which this request refers 867 848 * @trb: pointer to struct dwc3_trb 868 849 * @trb_dma: DMA address of @trb 869 - * @unaligned: true for OUT endpoints with length not divisible by maxp 850 + * @num_trbs: number of TRBs used by this request 851 + * @needs_extra_trb: true when request needs one extra TRB (either due to ZLP 852 + * or unaligned OUT) 870 853 * @direction: IN or OUT direction flag 871 854 * @mapped: true when request has been dma-mapped 872 855 * @started: request is started 873 - * @zero: wants a ZLP 874 856 */ 875 857 struct dwc3_request { 876 858 struct usb_request request; ··· 887 867 struct dwc3_trb *trb; 888 868 dma_addr_t trb_dma; 889 869 890 - unsigned unaligned:1; 870 + unsigned num_trbs; 871 + 872 + unsigned needs_extra_trb:1; 891 873 unsigned direction:1; 892 874 unsigned mapped:1; 893 875 unsigned started:1; 894 - unsigned zero:1; 895 876 }; 896 877 897 878 /* ··· 939 918 * @u1u2: only used on revisions <1.83a for workaround 940 919 * @maximum_speed: maximum speed requested (mainly for testing purposes) 941 920 * @revision: revision register contents 921 + * @version_type: VERSIONTYPE register contents, a sub release of a revision 942 922 * @dr_mode: requested mode of operation 943 923 * @current_dr_role: current role of operation when in dual-role mode 944 924 * @desired_dr_role: desired role of operation when in dual-role mode ··· 967 945 * @hwparams: copy of hwparams registers 968 946 * @root: debugfs root folder pointer 969 947 * @regset: debugfs pointer to regdump file 948 + * @dbg_lsp_select: current debug lsp mux register selection 970 949 * @test_mode: true when we're entering a USB test mode 971 950 * @test_mode_nr: test feature selector 972 951 * @lpm_nyet_threshold: LPM NYET response threshold ··· 993 970 * @pullups_connected: true when Run/Stop bit is set 994 971 * @setup_packet_pending: true when there's a Setup Packet in FIFO. Workaround 995 972 * @three_stage_setup: set if we perform a three phase setup 973 + * @dis_start_transfer_quirk: set if start_transfer failure SW workaround is 974 + * not needed for DWC_usb31 version 1.70a-ea06 and below 996 975 * @usb3_lpm_capable: set if hadrware supports Link Power Management 976 + * @usb2_lpm_disable: set to disable usb2 lpm 997 977 * @disable_scramble_quirk: set if we enable the disable scramble quirk 998 978 * @u2exit_lfps_quirk: set if we enable u2exit lfps quirk 999 979 * @u2ss_inp3_quirk: set if we enable P3 OK for U2/SS Inactive quirk ··· 1121 1095 #define DWC3_REVISION_290A 0x5533290a 1122 1096 #define DWC3_REVISION_300A 0x5533300a 1123 1097 #define DWC3_REVISION_310A 0x5533310a 1098 + #define DWC3_REVISION_330A 0x5533330a 1124 1099 1125 1100 /* 1126 1101 * NOTICE: we're using bit 31 as a "is usb 3.1" flag. This is really ··· 1130 1103 #define DWC3_REVISION_IS_DWC31 0x80000000 1131 1104 #define DWC3_USB31_REVISION_110A (0x3131302a | DWC3_REVISION_IS_DWC31) 1132 1105 #define DWC3_USB31_REVISION_120A (0x3132302a | DWC3_REVISION_IS_DWC31) 1106 + #define DWC3_USB31_REVISION_160A (0x3136302a | DWC3_REVISION_IS_DWC31) 1107 + #define DWC3_USB31_REVISION_170A (0x3137302a | DWC3_REVISION_IS_DWC31) 1108 + 1109 + u32 version_type; 1110 + 1111 + #define DWC31_VERSIONTYPE_EA01 0x65613031 1112 + #define DWC31_VERSIONTYPE_EA02 0x65613032 1113 + #define DWC31_VERSIONTYPE_EA03 0x65613033 1114 + #define DWC31_VERSIONTYPE_EA04 0x65613034 1115 + #define DWC31_VERSIONTYPE_EA05 0x65613035 1116 + #define DWC31_VERSIONTYPE_EA06 0x65613036 1133 1117 1134 1118 enum dwc3_ep0_next ep0_next_event; 1135 1119 enum dwc3_ep0_state ep0state; ··· 1158 1120 struct dwc3_hwparams hwparams; 1159 1121 struct dentry *root; 1160 1122 struct debugfs_regset32 *regset; 1123 + 1124 + u32 dbg_lsp_select; 1161 1125 1162 1126 u8 test_mode; 1163 1127 u8 test_mode_nr; ··· 1185 1145 unsigned pullups_connected:1; 1186 1146 unsigned setup_packet_pending:1; 1187 1147 unsigned three_stage_setup:1; 1148 + unsigned dis_start_transfer_quirk:1; 1188 1149 unsigned usb3_lpm_capable:1; 1150 + unsigned usb2_lpm_disable:1; 1189 1151 1190 1152 unsigned disable_scramble_quirk:1; 1191 1153 unsigned u2exit_lfps_quirk:1;
+29
drivers/usb/dwc3/debug.h
··· 117 117 } 118 118 119 119 /** 120 + * dwc3_gadget_hs_link_string - returns highspeed and below link name 121 + * @link_state: link state code 122 + */ 123 + static inline const char * 124 + dwc3_gadget_hs_link_string(enum dwc3_link_state link_state) 125 + { 126 + switch (link_state) { 127 + case DWC3_LINK_STATE_U0: 128 + return "On"; 129 + case DWC3_LINK_STATE_U2: 130 + return "Sleep"; 131 + case DWC3_LINK_STATE_U3: 132 + return "Suspend"; 133 + case DWC3_LINK_STATE_SS_DIS: 134 + return "Disconnected"; 135 + case DWC3_LINK_STATE_RX_DET: 136 + return "Early Suspend"; 137 + case DWC3_LINK_STATE_RECOV: 138 + return "Recovery"; 139 + case DWC3_LINK_STATE_RESET: 140 + return "Reset"; 141 + case DWC3_LINK_STATE_RESUME: 142 + return "Resume"; 143 + default: 144 + return "UNKNOWN link state\n"; 145 + } 146 + } 147 + 148 + /** 120 149 * dwc3_trb_type_string - returns TRB type as a string 121 150 * @type: the type of the TRB 122 151 */
+187 -14
drivers/usb/dwc3/debugfs.c
··· 25 25 #include "io.h" 26 26 #include "debug.h" 27 27 28 + #define DWC3_LSP_MUX_UNSELECTED 0xfffff 29 + 28 30 #define dump_register(nm) \ 29 31 { \ 30 32 .name = __stringify(nm), \ ··· 84 82 dump_register(GDBGFIFOSPACE), 85 83 dump_register(GDBGLTSSM), 86 84 dump_register(GDBGBMU), 87 - dump_register(GDBGLSPMUX), 88 - dump_register(GDBGLSP), 89 - dump_register(GDBGEPINFO0), 90 - dump_register(GDBGEPINFO1), 91 85 dump_register(GPRTBIMAP_HS0), 92 86 dump_register(GPRTBIMAP_HS1), 93 87 dump_register(GPRTBIMAP_FS0), ··· 277 279 dump_register(OSTS), 278 280 }; 279 281 282 + static void dwc3_host_lsp(struct seq_file *s) 283 + { 284 + struct dwc3 *dwc = s->private; 285 + bool dbc_enabled; 286 + u32 sel; 287 + u32 reg; 288 + u32 val; 289 + 290 + dbc_enabled = !!(dwc->hwparams.hwparams1 & DWC3_GHWPARAMS1_ENDBC); 291 + 292 + sel = dwc->dbg_lsp_select; 293 + if (sel == DWC3_LSP_MUX_UNSELECTED) { 294 + seq_puts(s, "Write LSP selection to print for host\n"); 295 + return; 296 + } 297 + 298 + reg = DWC3_GDBGLSPMUX_HOSTSELECT(sel); 299 + 300 + dwc3_writel(dwc->regs, DWC3_GDBGLSPMUX, reg); 301 + val = dwc3_readl(dwc->regs, DWC3_GDBGLSP); 302 + seq_printf(s, "GDBGLSP[%d] = 0x%08x\n", sel, val); 303 + 304 + if (dbc_enabled && sel < 256) { 305 + reg |= DWC3_GDBGLSPMUX_ENDBC; 306 + dwc3_writel(dwc->regs, DWC3_GDBGLSPMUX, reg); 307 + val = dwc3_readl(dwc->regs, DWC3_GDBGLSP); 308 + seq_printf(s, "GDBGLSP_DBC[%d] = 0x%08x\n", sel, val); 309 + } 310 + } 311 + 312 + static void dwc3_gadget_lsp(struct seq_file *s) 313 + { 314 + struct dwc3 *dwc = s->private; 315 + int i; 316 + u32 reg; 317 + 318 + for (i = 0; i < 16; i++) { 319 + reg = DWC3_GDBGLSPMUX_DEVSELECT(i); 320 + dwc3_writel(dwc->regs, DWC3_GDBGLSPMUX, reg); 321 + reg = dwc3_readl(dwc->regs, DWC3_GDBGLSP); 322 + seq_printf(s, "GDBGLSP[%d] = 0x%08x\n", i, reg); 323 + } 324 + } 325 + 326 + static int dwc3_lsp_show(struct seq_file *s, void *unused) 327 + { 328 + struct dwc3 *dwc = s->private; 329 + unsigned int current_mode; 330 + unsigned long flags; 331 + u32 reg; 332 + 333 + spin_lock_irqsave(&dwc->lock, flags); 334 + reg = dwc3_readl(dwc->regs, DWC3_GSTS); 335 + current_mode = DWC3_GSTS_CURMOD(reg); 336 + 337 + switch (current_mode) { 338 + case DWC3_GSTS_CURMOD_HOST: 339 + dwc3_host_lsp(s); 340 + break; 341 + case DWC3_GSTS_CURMOD_DEVICE: 342 + dwc3_gadget_lsp(s); 343 + break; 344 + default: 345 + seq_puts(s, "Mode is unknown, no LSP register printed\n"); 346 + break; 347 + } 348 + spin_unlock_irqrestore(&dwc->lock, flags); 349 + 350 + return 0; 351 + } 352 + 353 + static int dwc3_lsp_open(struct inode *inode, struct file *file) 354 + { 355 + return single_open(file, dwc3_lsp_show, inode->i_private); 356 + } 357 + 358 + static ssize_t dwc3_lsp_write(struct file *file, const char __user *ubuf, 359 + size_t count, loff_t *ppos) 360 + { 361 + struct seq_file *s = file->private_data; 362 + struct dwc3 *dwc = s->private; 363 + unsigned long flags; 364 + char buf[32] = { 0 }; 365 + u32 sel; 366 + int ret; 367 + 368 + if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count))) 369 + return -EFAULT; 370 + 371 + ret = kstrtouint(buf, 0, &sel); 372 + if (ret) 373 + return ret; 374 + 375 + spin_lock_irqsave(&dwc->lock, flags); 376 + dwc->dbg_lsp_select = sel; 377 + spin_unlock_irqrestore(&dwc->lock, flags); 378 + 379 + return count; 380 + } 381 + 382 + static const struct file_operations dwc3_lsp_fops = { 383 + .open = dwc3_lsp_open, 384 + .write = dwc3_lsp_write, 385 + .read = seq_read, 386 + .llseek = seq_lseek, 387 + .release = single_release, 388 + }; 389 + 280 390 static int dwc3_mode_show(struct seq_file *s, void *unused) 281 391 { 282 392 struct dwc3 *dwc = s->private; ··· 539 433 unsigned long flags; 540 434 enum dwc3_link_state state; 541 435 u32 reg; 436 + u8 speed; 542 437 543 438 spin_lock_irqsave(&dwc->lock, flags); 439 + reg = dwc3_readl(dwc->regs, DWC3_GSTS); 440 + if (DWC3_GSTS_CURMOD(reg) != DWC3_GSTS_CURMOD_DEVICE) { 441 + seq_puts(s, "Not available\n"); 442 + spin_unlock_irqrestore(&dwc->lock, flags); 443 + return 0; 444 + } 445 + 544 446 reg = dwc3_readl(dwc->regs, DWC3_DSTS); 545 447 state = DWC3_DSTS_USBLNKST(reg); 546 - spin_unlock_irqrestore(&dwc->lock, flags); 448 + speed = reg & DWC3_DSTS_CONNECTSPD; 547 449 548 - seq_printf(s, "%s\n", dwc3_gadget_link_string(state)); 450 + seq_printf(s, "%s\n", (speed >= DWC3_DSTS_SUPERSPEED) ? 451 + dwc3_gadget_link_string(state) : 452 + dwc3_gadget_hs_link_string(state)); 453 + spin_unlock_irqrestore(&dwc->lock, flags); 549 454 550 455 return 0; 551 456 } ··· 574 457 unsigned long flags; 575 458 enum dwc3_link_state state = 0; 576 459 char buf[32]; 460 + u32 reg; 461 + u8 speed; 577 462 578 463 if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count))) 579 464 return -EFAULT; ··· 596 477 return -EINVAL; 597 478 598 479 spin_lock_irqsave(&dwc->lock, flags); 480 + reg = dwc3_readl(dwc->regs, DWC3_GSTS); 481 + if (DWC3_GSTS_CURMOD(reg) != DWC3_GSTS_CURMOD_DEVICE) { 482 + spin_unlock_irqrestore(&dwc->lock, flags); 483 + return -EINVAL; 484 + } 485 + 486 + reg = dwc3_readl(dwc->regs, DWC3_DSTS); 487 + speed = reg & DWC3_DSTS_CONNECTSPD; 488 + 489 + if (speed < DWC3_DSTS_SUPERSPEED && 490 + state != DWC3_LINK_STATE_RECOV) { 491 + spin_unlock_irqrestore(&dwc->lock, flags); 492 + return -EINVAL; 493 + } 494 + 599 495 dwc3_gadget_set_link_state(dwc, state); 600 496 spin_unlock_irqrestore(&dwc->lock, flags); 601 497 ··· 630 496 const struct file_operations *const fops; 631 497 }; 632 498 633 - static int dwc3_tx_fifo_queue_show(struct seq_file *s, void *unused) 499 + static int dwc3_tx_fifo_size_show(struct seq_file *s, void *unused) 634 500 { 635 501 struct dwc3_ep *dep = s->private; 636 502 struct dwc3 *dwc = dep->dwc; ··· 638 504 u32 val; 639 505 640 506 spin_lock_irqsave(&dwc->lock, flags); 641 - val = dwc3_core_fifo_space(dep, DWC3_TXFIFOQ); 507 + val = dwc3_core_fifo_space(dep, DWC3_TXFIFO); 508 + 509 + /* Convert to bytes */ 510 + val *= DWC3_MDWIDTH(dwc->hwparams.hwparams0); 511 + val >>= 3; 642 512 seq_printf(s, "%u\n", val); 643 513 spin_unlock_irqrestore(&dwc->lock, flags); 644 514 645 515 return 0; 646 516 } 647 517 648 - static int dwc3_rx_fifo_queue_show(struct seq_file *s, void *unused) 518 + static int dwc3_rx_fifo_size_show(struct seq_file *s, void *unused) 649 519 { 650 520 struct dwc3_ep *dep = s->private; 651 521 struct dwc3 *dwc = dep->dwc; ··· 657 519 u32 val; 658 520 659 521 spin_lock_irqsave(&dwc->lock, flags); 660 - val = dwc3_core_fifo_space(dep, DWC3_RXFIFOQ); 522 + val = dwc3_core_fifo_space(dep, DWC3_RXFIFO); 523 + 524 + /* Convert to bytes */ 525 + val *= DWC3_MDWIDTH(dwc->hwparams.hwparams0); 526 + val >>= 3; 661 527 seq_printf(s, "%u\n", val); 662 528 spin_unlock_irqrestore(&dwc->lock, flags); 663 529 ··· 817 675 return 0; 818 676 } 819 677 820 - DEFINE_SHOW_ATTRIBUTE(dwc3_tx_fifo_queue); 821 - DEFINE_SHOW_ATTRIBUTE(dwc3_rx_fifo_queue); 678 + static int dwc3_ep_info_register_show(struct seq_file *s, void *unused) 679 + { 680 + struct dwc3_ep *dep = s->private; 681 + struct dwc3 *dwc = dep->dwc; 682 + unsigned long flags; 683 + u64 ep_info; 684 + u32 lower_32_bits; 685 + u32 upper_32_bits; 686 + u32 reg; 687 + 688 + spin_lock_irqsave(&dwc->lock, flags); 689 + reg = DWC3_GDBGLSPMUX_EPSELECT(dep->number); 690 + dwc3_writel(dwc->regs, DWC3_GDBGLSPMUX, reg); 691 + 692 + lower_32_bits = dwc3_readl(dwc->regs, DWC3_GDBGEPINFO0); 693 + upper_32_bits = dwc3_readl(dwc->regs, DWC3_GDBGEPINFO1); 694 + 695 + ep_info = ((u64)upper_32_bits << 32) | lower_32_bits; 696 + seq_printf(s, "0x%016llx\n", ep_info); 697 + spin_unlock_irqrestore(&dwc->lock, flags); 698 + 699 + return 0; 700 + } 701 + 702 + DEFINE_SHOW_ATTRIBUTE(dwc3_tx_fifo_size); 703 + DEFINE_SHOW_ATTRIBUTE(dwc3_rx_fifo_size); 822 704 DEFINE_SHOW_ATTRIBUTE(dwc3_tx_request_queue); 823 705 DEFINE_SHOW_ATTRIBUTE(dwc3_rx_request_queue); 824 706 DEFINE_SHOW_ATTRIBUTE(dwc3_rx_info_queue); ··· 850 684 DEFINE_SHOW_ATTRIBUTE(dwc3_event_queue); 851 685 DEFINE_SHOW_ATTRIBUTE(dwc3_transfer_type); 852 686 DEFINE_SHOW_ATTRIBUTE(dwc3_trb_ring); 687 + DEFINE_SHOW_ATTRIBUTE(dwc3_ep_info_register); 853 688 854 689 static const struct dwc3_ep_file_map dwc3_ep_file_map[] = { 855 - { "tx_fifo_queue", &dwc3_tx_fifo_queue_fops, }, 856 - { "rx_fifo_queue", &dwc3_rx_fifo_queue_fops, }, 690 + { "tx_fifo_size", &dwc3_tx_fifo_size_fops, }, 691 + { "rx_fifo_size", &dwc3_rx_fifo_size_fops, }, 857 692 { "tx_request_queue", &dwc3_tx_request_queue_fops, }, 858 693 { "rx_request_queue", &dwc3_rx_request_queue_fops, }, 859 694 { "rx_info_queue", &dwc3_rx_info_queue_fops, }, ··· 862 695 { "event_queue", &dwc3_event_queue_fops, }, 863 696 { "transfer_type", &dwc3_transfer_type_fops, }, 864 697 { "trb_ring", &dwc3_trb_ring_fops, }, 698 + { "GDBGEPINFO", &dwc3_ep_info_register_fops, }, 865 699 }; 866 700 867 701 static void dwc3_debugfs_create_endpoint_files(struct dwc3_ep *dep, ··· 910 742 if (!dwc->regset) 911 743 return; 912 744 745 + dwc->dbg_lsp_select = DWC3_LSP_MUX_UNSELECTED; 746 + 913 747 dwc->regset->regs = dwc3_regs; 914 748 dwc->regset->nregs = ARRAY_SIZE(dwc3_regs); 915 749 dwc->regset->base = dwc->regs - DWC3_GLOBALS_REGS_START; ··· 920 750 dwc->root = root; 921 751 922 752 debugfs_create_regset32("regdump", S_IRUGO, root, dwc->regset); 753 + 754 + debugfs_create_file("lsp_dump", S_IRUGO | S_IWUSR, root, dwc, 755 + &dwc3_lsp_fops); 923 756 924 757 if (IS_ENABLED(CONFIG_USB_DWC3_DUAL_ROLE)) { 925 758 debugfs_create_file("mode", S_IRUGO | S_IWUSR, root, dwc,
+13 -2
drivers/usb/dwc3/drd.c
··· 10 10 #include <linux/extcon.h> 11 11 #include <linux/of_graph.h> 12 12 #include <linux/platform_device.h> 13 + #include <linux/property.h> 13 14 14 15 #include "debug.h" 15 16 #include "core.h" ··· 446 445 struct device *dev = dwc->dev; 447 446 struct device_node *np_phy, *np_conn; 448 447 struct extcon_dev *edev; 448 + const char *name; 449 449 450 - if (of_property_read_bool(dev->of_node, "extcon")) 451 - return extcon_get_edev_by_phandle(dwc->dev, 0); 450 + if (device_property_read_bool(dev, "extcon")) 451 + return extcon_get_edev_by_phandle(dev, 0); 452 + 453 + /* 454 + * Device tree platforms should get extcon via phandle. 455 + * On ACPI platforms, we get the name from a device property. 456 + * This device property is for kernel internal use only and 457 + * is expected to be set by the glue code. 458 + */ 459 + if (device_property_read_string(dev, "linux,extcon-name", &name) == 0) 460 + return extcon_get_extcon_dev(name); 452 461 453 462 np_phy = of_parse_phandle(dev->of_node, "phys", 0); 454 463 np_conn = of_graph_get_remote_node(np_phy, -1, -1);
+4 -4
drivers/usb/dwc3/dwc3-pci.c
··· 170 170 * put the gpio descriptors again here because the phy driver 171 171 * might want to grab them, too. 172 172 */ 173 - gpio = devm_gpiod_get_optional(&pdev->dev, "cs", 174 - GPIOD_OUT_LOW); 173 + gpio = gpiod_get_optional(&pdev->dev, "cs", GPIOD_OUT_LOW); 175 174 if (IS_ERR(gpio)) 176 175 return PTR_ERR(gpio); 177 176 178 177 gpiod_set_value_cansleep(gpio, 1); 178 + gpiod_put(gpio); 179 179 180 - gpio = devm_gpiod_get_optional(&pdev->dev, "reset", 181 - GPIOD_OUT_LOW); 180 + gpio = gpiod_get_optional(&pdev->dev, "reset", GPIOD_OUT_LOW); 182 181 if (IS_ERR(gpio)) 183 182 return PTR_ERR(gpio); 184 183 185 184 if (gpio) { 186 185 gpiod_set_value_cansleep(gpio, 1); 186 + gpiod_put(gpio); 187 187 usleep_range(10000, 11000); 188 188 } 189 189 }
+224 -122
drivers/usb/dwc3/gadget.c
··· 27 27 #include "gadget.h" 28 28 #include "io.h" 29 29 30 - #define DWC3_ALIGN_FRAME(d) (((d)->frame_number + (d)->interval) \ 30 + #define DWC3_ALIGN_FRAME(d, n) (((d)->frame_number + ((d)->interval * (n))) \ 31 31 & ~((d)->interval - 1)) 32 32 33 33 /** ··· 647 647 reg |= DWC3_DALEPENA_EP(dep->number); 648 648 dwc3_writel(dwc->regs, DWC3_DALEPENA, reg); 649 649 650 - init_waitqueue_head(&dep->wait_end_transfer); 651 - 652 650 if (usb_endpoint_xfer_control(desc)) 653 651 goto out; 654 652 ··· 670 672 * Issue StartTransfer here with no-op TRB so we can always rely on No 671 673 * Response Update Transfer command. 672 674 */ 673 - if (usb_endpoint_xfer_bulk(desc) || 675 + if ((usb_endpoint_xfer_bulk(desc) && !dep->stream_capable) || 674 676 usb_endpoint_xfer_int(desc)) { 675 677 struct dwc3_gadget_ep_cmd_params params; 676 678 struct dwc3_trb *trb; ··· 917 919 struct usb_gadget *gadget = &dwc->gadget; 918 920 enum usb_device_speed speed = gadget->speed; 919 921 920 - dwc3_ep_inc_enq(dep); 921 - 922 922 trb->size = DWC3_TRB_SIZE_LENGTH(length); 923 923 trb->bpl = lower_32_bits(dma); 924 924 trb->bph = upper_32_bits(dma); ··· 986 990 usb_endpoint_type(dep->endpoint.desc)); 987 991 } 988 992 989 - /* always enable Continue on Short Packet */ 993 + /* 994 + * Enable Continue on Short Packet 995 + * when endpoint is not a stream capable 996 + */ 990 997 if (usb_endpoint_dir_out(dep->endpoint.desc)) { 991 - trb->ctrl |= DWC3_TRB_CTRL_CSP; 998 + if (!dep->stream_capable) 999 + trb->ctrl |= DWC3_TRB_CTRL_CSP; 992 1000 993 1001 if (short_not_ok) 994 1002 trb->ctrl |= DWC3_TRB_CTRL_ISP_IMI; 995 1003 } 996 1004 997 1005 if ((!no_interrupt && !chain) || 998 - (dwc3_calc_trbs_left(dep) == 0)) 1006 + (dwc3_calc_trbs_left(dep) == 1)) 999 1007 trb->ctrl |= DWC3_TRB_CTRL_IOC; 1000 1008 1001 1009 if (chain) ··· 1009 1009 trb->ctrl |= DWC3_TRB_CTRL_SID_SOFN(stream_id); 1010 1010 1011 1011 trb->ctrl |= DWC3_TRB_CTRL_HWO; 1012 + 1013 + dwc3_ep_inc_enq(dep); 1012 1014 1013 1015 trace_dwc3_prepare_trb(dep, trb); 1014 1016 } ··· 1048 1046 req->trb_dma = dwc3_trb_dma_offset(dep, trb); 1049 1047 } 1050 1048 1049 + req->num_trbs++; 1050 + 1051 1051 __dwc3_prepare_one_trb(dep, trb, dma, length, chain, node, 1052 1052 stream_id, short_not_ok, no_interrupt); 1053 1053 } ··· 1077 1073 struct dwc3 *dwc = dep->dwc; 1078 1074 struct dwc3_trb *trb; 1079 1075 1080 - req->unaligned = true; 1076 + req->needs_extra_trb = true; 1081 1077 1082 1078 /* prepare normal TRB */ 1083 1079 dwc3_prepare_one_trb(dep, req, true, i); 1084 1080 1085 1081 /* Now prepare one extra TRB to align transfer size */ 1086 1082 trb = &dep->trb_pool[dep->trb_enqueue]; 1083 + req->num_trbs++; 1087 1084 __dwc3_prepare_one_trb(dep, trb, dwc->bounce_addr, 1088 1085 maxp - rem, false, 1, 1089 1086 req->request.stream_id, ··· 1122 1117 struct dwc3 *dwc = dep->dwc; 1123 1118 struct dwc3_trb *trb; 1124 1119 1125 - req->unaligned = true; 1120 + req->needs_extra_trb = true; 1126 1121 1127 1122 /* prepare normal TRB */ 1128 1123 dwc3_prepare_one_trb(dep, req, true, 0); 1129 1124 1130 1125 /* Now prepare one extra TRB to align transfer size */ 1131 1126 trb = &dep->trb_pool[dep->trb_enqueue]; 1127 + req->num_trbs++; 1132 1128 __dwc3_prepare_one_trb(dep, trb, dwc->bounce_addr, maxp - rem, 1133 1129 false, 1, req->request.stream_id, 1134 1130 req->request.short_not_ok, ··· 1139 1133 struct dwc3 *dwc = dep->dwc; 1140 1134 struct dwc3_trb *trb; 1141 1135 1142 - req->zero = true; 1136 + req->needs_extra_trb = true; 1143 1137 1144 1138 /* prepare normal TRB */ 1145 1139 dwc3_prepare_one_trb(dep, req, true, 0); 1146 1140 1147 1141 /* Now prepare one extra TRB to handle ZLP */ 1148 1142 trb = &dep->trb_pool[dep->trb_enqueue]; 1143 + req->num_trbs++; 1149 1144 __dwc3_prepare_one_trb(dep, trb, dwc->bounce_addr, 0, 1150 1145 false, 1, req->request.stream_id, 1151 1146 req->request.short_not_ok, ··· 1239 1232 params.param1 = lower_32_bits(req->trb_dma); 1240 1233 cmd = DWC3_DEPCMD_STARTTRANSFER; 1241 1234 1235 + if (dep->stream_capable) 1236 + cmd |= DWC3_DEPCMD_PARAM(req->request.stream_id); 1237 + 1242 1238 if (usb_endpoint_xfer_isoc(dep->endpoint.desc)) 1243 1239 cmd |= DWC3_DEPCMD_PARAM(dep->frame_number); 1244 1240 } else { ··· 1273 1263 return DWC3_DSTS_SOFFN(reg); 1274 1264 } 1275 1265 1276 - static void __dwc3_gadget_start_isoc(struct dwc3_ep *dep) 1266 + /** 1267 + * dwc3_gadget_start_isoc_quirk - workaround invalid frame number 1268 + * @dep: isoc endpoint 1269 + * 1270 + * This function tests for the correct combination of BIT[15:14] from the 16-bit 1271 + * microframe number reported by the XferNotReady event for the future frame 1272 + * number to start the isoc transfer. 1273 + * 1274 + * In DWC_usb31 version 1.70a-ea06 and prior, for highspeed and fullspeed 1275 + * isochronous IN, BIT[15:14] of the 16-bit microframe number reported by the 1276 + * XferNotReady event are invalid. The driver uses this number to schedule the 1277 + * isochronous transfer and passes it to the START TRANSFER command. Because 1278 + * this number is invalid, the command may fail. If BIT[15:14] matches the 1279 + * internal 16-bit microframe, the START TRANSFER command will pass and the 1280 + * transfer will start at the scheduled time, if it is off by 1, the command 1281 + * will still pass, but the transfer will start 2 seconds in the future. For all 1282 + * other conditions, the START TRANSFER command will fail with bus-expiry. 1283 + * 1284 + * In order to workaround this issue, we can test for the correct combination of 1285 + * BIT[15:14] by sending START TRANSFER commands with different values of 1286 + * BIT[15:14]: 'b00, 'b01, 'b10, and 'b11. Each combination is 2^14 uframe apart 1287 + * (or 2 seconds). 4 seconds into the future will result in a bus-expiry status. 1288 + * As the result, within the 4 possible combinations for BIT[15:14], there will 1289 + * be 2 successful and 2 failure START COMMAND status. One of the 2 successful 1290 + * command status will result in a 2-second delay start. The smaller BIT[15:14] 1291 + * value is the correct combination. 1292 + * 1293 + * Since there are only 4 outcomes and the results are ordered, we can simply 1294 + * test 2 START TRANSFER commands with BIT[15:14] combinations 'b00 and 'b01 to 1295 + * deduce the smaller successful combination. 1296 + * 1297 + * Let test0 = test status for combination 'b00 and test1 = test status for 'b01 1298 + * of BIT[15:14]. The correct combination is as follow: 1299 + * 1300 + * if test0 fails and test1 passes, BIT[15:14] is 'b01 1301 + * if test0 fails and test1 fails, BIT[15:14] is 'b10 1302 + * if test0 passes and test1 fails, BIT[15:14] is 'b11 1303 + * if test0 passes and test1 passes, BIT[15:14] is 'b00 1304 + * 1305 + * Synopsys STAR 9001202023: Wrong microframe number for isochronous IN 1306 + * endpoints. 1307 + */ 1308 + static int dwc3_gadget_start_isoc_quirk(struct dwc3_ep *dep) 1277 1309 { 1278 - if (list_empty(&dep->pending_list)) { 1279 - dev_info(dep->dwc->dev, "%s: ran out of requests\n", 1280 - dep->name); 1281 - dep->flags |= DWC3_EP_PENDING_REQUEST; 1282 - return; 1310 + int cmd_status = 0; 1311 + bool test0; 1312 + bool test1; 1313 + 1314 + while (dep->combo_num < 2) { 1315 + struct dwc3_gadget_ep_cmd_params params; 1316 + u32 test_frame_number; 1317 + u32 cmd; 1318 + 1319 + /* 1320 + * Check if we can start isoc transfer on the next interval or 1321 + * 4 uframes in the future with BIT[15:14] as dep->combo_num 1322 + */ 1323 + test_frame_number = dep->frame_number & 0x3fff; 1324 + test_frame_number |= dep->combo_num << 14; 1325 + test_frame_number += max_t(u32, 4, dep->interval); 1326 + 1327 + params.param0 = upper_32_bits(dep->dwc->bounce_addr); 1328 + params.param1 = lower_32_bits(dep->dwc->bounce_addr); 1329 + 1330 + cmd = DWC3_DEPCMD_STARTTRANSFER; 1331 + cmd |= DWC3_DEPCMD_PARAM(test_frame_number); 1332 + cmd_status = dwc3_send_gadget_ep_cmd(dep, cmd, &params); 1333 + 1334 + /* Redo if some other failure beside bus-expiry is received */ 1335 + if (cmd_status && cmd_status != -EAGAIN) { 1336 + dep->start_cmd_status = 0; 1337 + dep->combo_num = 0; 1338 + return 0; 1339 + } 1340 + 1341 + /* Store the first test status */ 1342 + if (dep->combo_num == 0) 1343 + dep->start_cmd_status = cmd_status; 1344 + 1345 + dep->combo_num++; 1346 + 1347 + /* 1348 + * End the transfer if the START_TRANSFER command is successful 1349 + * to wait for the next XferNotReady to test the command again 1350 + */ 1351 + if (cmd_status == 0) { 1352 + dwc3_stop_active_transfer(dep, true); 1353 + return 0; 1354 + } 1283 1355 } 1284 1356 1285 - dep->frame_number = DWC3_ALIGN_FRAME(dep); 1286 - __dwc3_gadget_kick_transfer(dep); 1357 + /* test0 and test1 are both completed at this point */ 1358 + test0 = (dep->start_cmd_status == 0); 1359 + test1 = (cmd_status == 0); 1360 + 1361 + if (!test0 && test1) 1362 + dep->combo_num = 1; 1363 + else if (!test0 && !test1) 1364 + dep->combo_num = 2; 1365 + else if (test0 && !test1) 1366 + dep->combo_num = 3; 1367 + else if (test0 && test1) 1368 + dep->combo_num = 0; 1369 + 1370 + dep->frame_number &= 0x3fff; 1371 + dep->frame_number |= dep->combo_num << 14; 1372 + dep->frame_number += max_t(u32, 4, dep->interval); 1373 + 1374 + /* Reinitialize test variables */ 1375 + dep->start_cmd_status = 0; 1376 + dep->combo_num = 0; 1377 + 1378 + return __dwc3_gadget_kick_transfer(dep); 1379 + } 1380 + 1381 + static int __dwc3_gadget_start_isoc(struct dwc3_ep *dep) 1382 + { 1383 + struct dwc3 *dwc = dep->dwc; 1384 + int ret; 1385 + int i; 1386 + 1387 + if (list_empty(&dep->pending_list)) { 1388 + dep->flags |= DWC3_EP_PENDING_REQUEST; 1389 + return -EAGAIN; 1390 + } 1391 + 1392 + if (!dwc->dis_start_transfer_quirk && dwc3_is_usb31(dwc) && 1393 + (dwc->revision <= DWC3_USB31_REVISION_160A || 1394 + (dwc->revision == DWC3_USB31_REVISION_170A && 1395 + dwc->version_type >= DWC31_VERSIONTYPE_EA01 && 1396 + dwc->version_type <= DWC31_VERSIONTYPE_EA06))) { 1397 + 1398 + if (dwc->gadget.speed <= USB_SPEED_HIGH && dep->direction) 1399 + return dwc3_gadget_start_isoc_quirk(dep); 1400 + } 1401 + 1402 + for (i = 0; i < DWC3_ISOC_MAX_RETRIES; i++) { 1403 + dep->frame_number = DWC3_ALIGN_FRAME(dep, i + 1); 1404 + 1405 + ret = __dwc3_gadget_kick_transfer(dep); 1406 + if (ret != -EAGAIN) 1407 + break; 1408 + } 1409 + 1410 + return ret; 1287 1411 } 1288 1412 1289 1413 static int __dwc3_gadget_ep_queue(struct dwc3_ep *dep, struct dwc3_request *req) ··· 1458 1314 1459 1315 if ((dep->flags & DWC3_EP_PENDING_REQUEST)) { 1460 1316 if (!(dep->flags & DWC3_EP_TRANSFER_STARTED)) { 1461 - __dwc3_gadget_start_isoc(dep); 1462 - return 0; 1317 + return __dwc3_gadget_start_isoc(dep); 1463 1318 } 1464 1319 } 1465 1320 } ··· 1482 1339 spin_unlock_irqrestore(&dwc->lock, flags); 1483 1340 1484 1341 return ret; 1342 + } 1343 + 1344 + static void dwc3_gadget_ep_skip_trbs(struct dwc3_ep *dep, struct dwc3_request *req) 1345 + { 1346 + int i; 1347 + 1348 + /* 1349 + * If request was already started, this means we had to 1350 + * stop the transfer. With that we also need to ignore 1351 + * all TRBs used by the request, however TRBs can only 1352 + * be modified after completion of END_TRANSFER 1353 + * command. So what we do here is that we wait for 1354 + * END_TRANSFER completion and only after that, we jump 1355 + * over TRBs by clearing HWO and incrementing dequeue 1356 + * pointer. 1357 + */ 1358 + for (i = 0; i < req->num_trbs; i++) { 1359 + struct dwc3_trb *trb; 1360 + 1361 + trb = req->trb + i; 1362 + trb->ctrl &= ~DWC3_TRB_CTRL_HWO; 1363 + dwc3_ep_inc_deq(dep); 1364 + } 1365 + } 1366 + 1367 + static void dwc3_gadget_ep_cleanup_cancelled_requests(struct dwc3_ep *dep) 1368 + { 1369 + struct dwc3_request *req; 1370 + struct dwc3_request *tmp; 1371 + 1372 + list_for_each_entry_safe(req, tmp, &dep->cancelled_list, list) { 1373 + dwc3_gadget_ep_skip_trbs(dep, req); 1374 + dwc3_gadget_giveback(dep, req, -ECONNRESET); 1375 + } 1485 1376 } 1486 1377 1487 1378 static int dwc3_gadget_ep_dequeue(struct usb_ep *ep, ··· 1548 1371 /* wait until it is processed */ 1549 1372 dwc3_stop_active_transfer(dep, true); 1550 1373 1551 - /* 1552 - * If request was already started, this means we had to 1553 - * stop the transfer. With that we also need to ignore 1554 - * all TRBs used by the request, however TRBs can only 1555 - * be modified after completion of END_TRANSFER 1556 - * command. So what we do here is that we wait for 1557 - * END_TRANSFER completion and only after that, we jump 1558 - * over TRBs by clearing HWO and incrementing dequeue 1559 - * pointer. 1560 - * 1561 - * Note that we have 2 possible types of transfers here: 1562 - * 1563 - * i) Linear buffer request 1564 - * ii) SG-list based request 1565 - * 1566 - * SG-list based requests will have r->num_pending_sgs 1567 - * set to a valid number (> 0). Linear requests, 1568 - * normally use a single TRB. 1569 - * 1570 - * For each of these two cases, if r->unaligned flag is 1571 - * set, one extra TRB has been used to align transfer 1572 - * size to wMaxPacketSize. 1573 - * 1574 - * All of these cases need to be taken into 1575 - * consideration so we don't mess up our TRB ring 1576 - * pointers. 1577 - */ 1578 - wait_event_lock_irq(dep->wait_end_transfer, 1579 - !(dep->flags & DWC3_EP_END_TRANSFER_PENDING), 1580 - dwc->lock); 1581 - 1582 1374 if (!r->trb) 1583 1375 goto out0; 1584 1376 1585 - if (r->num_pending_sgs) { 1586 - struct dwc3_trb *trb; 1587 - int i = 0; 1588 - 1589 - for (i = 0; i < r->num_pending_sgs; i++) { 1590 - trb = r->trb + i; 1591 - trb->ctrl &= ~DWC3_TRB_CTRL_HWO; 1592 - dwc3_ep_inc_deq(dep); 1593 - } 1594 - 1595 - if (r->unaligned || r->zero) { 1596 - trb = r->trb + r->num_pending_sgs + 1; 1597 - trb->ctrl &= ~DWC3_TRB_CTRL_HWO; 1598 - dwc3_ep_inc_deq(dep); 1599 - } 1600 - } else { 1601 - struct dwc3_trb *trb = r->trb; 1602 - 1603 - trb->ctrl &= ~DWC3_TRB_CTRL_HWO; 1604 - dwc3_ep_inc_deq(dep); 1605 - 1606 - if (r->unaligned || r->zero) { 1607 - trb = r->trb + 1; 1608 - trb->ctrl &= ~DWC3_TRB_CTRL_HWO; 1609 - dwc3_ep_inc_deq(dep); 1610 - } 1611 - } 1612 - goto out1; 1377 + dwc3_gadget_move_cancelled_request(req); 1378 + goto out0; 1613 1379 } 1614 1380 dev_err(dwc->dev, "request %pK was not queued to %s\n", 1615 1381 request, ep->name); 1616 1382 ret = -EINVAL; 1617 1383 goto out0; 1618 1384 } 1619 - 1620 - out1: 1621 - /* giveback the request */ 1622 1385 1623 1386 dwc3_gadget_giveback(dep, req, -ECONNRESET); 1624 1387 ··· 2051 1934 { 2052 1935 struct dwc3 *dwc = gadget_to_dwc(g); 2053 1936 unsigned long flags; 2054 - int epnum; 2055 - u32 tmo_eps = 0; 2056 1937 2057 1938 spin_lock_irqsave(&dwc->lock, flags); 2058 1939 ··· 2058 1943 goto out; 2059 1944 2060 1945 __dwc3_gadget_stop(dwc); 2061 - 2062 - for (epnum = 2; epnum < DWC3_ENDPOINTS_NUM; epnum++) { 2063 - struct dwc3_ep *dep = dwc->eps[epnum]; 2064 - int ret; 2065 - 2066 - if (!dep) 2067 - continue; 2068 - 2069 - if (!(dep->flags & DWC3_EP_END_TRANSFER_PENDING)) 2070 - continue; 2071 - 2072 - ret = wait_event_interruptible_lock_irq_timeout(dep->wait_end_transfer, 2073 - !(dep->flags & DWC3_EP_END_TRANSFER_PENDING), 2074 - dwc->lock, msecs_to_jiffies(5)); 2075 - 2076 - if (ret <= 0) { 2077 - /* Timed out or interrupted! There's nothing much 2078 - * we can do so we just log here and print which 2079 - * endpoints timed out at the end. 2080 - */ 2081 - tmo_eps |= 1 << epnum; 2082 - dep->flags &= DWC3_EP_END_TRANSFER_PENDING; 2083 - } 2084 - } 2085 - 2086 - if (tmo_eps) { 2087 - dev_err(dwc->dev, 2088 - "end transfer timed out on endpoints 0x%x [bitmap]\n", 2089 - tmo_eps); 2090 - } 2091 1946 2092 1947 out: 2093 1948 dwc->gadget_driver = NULL; ··· 2233 2148 dep->direction = direction; 2234 2149 dep->regs = dwc->regs + DWC3_DEP_BASE(epnum); 2235 2150 dwc->eps[epnum] = dep; 2151 + dep->combo_num = 0; 2152 + dep->start_cmd_status = 0; 2236 2153 2237 2154 snprintf(dep->name, sizeof(dep->name), "ep%u%s", num, 2238 2155 direction ? "in" : "out"); ··· 2263 2176 2264 2177 INIT_LIST_HEAD(&dep->pending_list); 2265 2178 INIT_LIST_HEAD(&dep->started_list); 2179 + INIT_LIST_HEAD(&dep->cancelled_list); 2266 2180 2267 2181 return 0; 2268 2182 } ··· 2323 2235 dwc3_ep_inc_deq(dep); 2324 2236 2325 2237 trace_dwc3_complete_trb(dep, trb); 2238 + req->num_trbs--; 2326 2239 2327 2240 /* 2328 2241 * If we're in the middle of series of chained TRBs and we ··· 2339 2250 trb->ctrl &= ~DWC3_TRB_CTRL_HWO; 2340 2251 2341 2252 /* 2253 + * For isochronous transfers, the first TRB in a service interval must 2254 + * have the Isoc-First type. Track and report its interval frame number. 2255 + */ 2256 + if (usb_endpoint_xfer_isoc(dep->endpoint.desc) && 2257 + (trb->ctrl & DWC3_TRBCTL_ISOCHRONOUS_FIRST)) { 2258 + unsigned int frame_number; 2259 + 2260 + frame_number = DWC3_TRB_CTRL_GET_SID_SOFN(trb->ctrl); 2261 + frame_number &= ~(dep->interval - 1); 2262 + req->request.frame_number = frame_number; 2263 + } 2264 + 2265 + /* 2342 2266 * If we're dealing with unaligned size OUT transfer, we will be left 2343 2267 * with one TRB pending in the ring. We need to manually clear HWO bit 2344 2268 * from that TRB. 2345 2269 */ 2346 - if ((req->zero || req->unaligned) && !(trb->ctrl & DWC3_TRB_CTRL_CHN)) { 2270 + 2271 + if (req->needs_extra_trb && !(trb->ctrl & DWC3_TRB_CTRL_CHN)) { 2347 2272 trb->ctrl &= ~DWC3_TRB_CTRL_HWO; 2348 2273 return 1; 2349 2274 } ··· 2434 2331 ret = dwc3_gadget_ep_reclaim_trb_linear(dep, req, event, 2435 2332 status); 2436 2333 2437 - if (req->unaligned || req->zero) { 2334 + if (req->needs_extra_trb) { 2438 2335 ret = dwc3_gadget_ep_reclaim_trb_linear(dep, req, event, 2439 2336 status); 2440 - req->unaligned = false; 2441 - req->zero = false; 2337 + req->needs_extra_trb = false; 2442 2338 } 2443 2339 2444 2340 req->request.actual = req->request.length - req->remaining; ··· 2532 2430 const struct dwc3_event_depevt *event) 2533 2431 { 2534 2432 dwc3_gadget_endpoint_frame_from_event(dep, event); 2535 - __dwc3_gadget_start_isoc(dep); 2433 + (void) __dwc3_gadget_start_isoc(dep); 2536 2434 } 2537 2435 2538 2436 static void dwc3_endpoint_interrupt(struct dwc3 *dwc, ··· 2570 2468 2571 2469 if (cmd == DWC3_DEPCMD_ENDTRANSFER) { 2572 2470 dep->flags &= ~DWC3_EP_END_TRANSFER_PENDING; 2573 - wake_up(&dep->wait_end_transfer); 2471 + dwc3_gadget_ep_cleanup_cancelled_requests(dep); 2574 2472 } 2575 2473 break; 2576 2474 case DWC3_DEPEVT_STREAMEVT:
+15
drivers/usb/dwc3/gadget.h
··· 79 79 list_move_tail(&req->list, &dep->started_list); 80 80 } 81 81 82 + /** 83 + * dwc3_gadget_move_cancelled_request - move @req to the cancelled_list 84 + * @req: the request to be moved 85 + * 86 + * Caller should take care of locking. This function will move @req from its 87 + * current list to the endpoint's cancelled_list. 88 + */ 89 + static inline void dwc3_gadget_move_cancelled_request(struct dwc3_request *req) 90 + { 91 + struct dwc3_ep *dep = req->dep; 92 + 93 + req->started = false; 94 + list_move_tail(&req->list, &dep->cancelled_list); 95 + } 96 + 82 97 void dwc3_gadget_giveback(struct dwc3_ep *dep, struct dwc3_request *req, 83 98 int status); 84 99
+4 -1
drivers/usb/dwc3/host.c
··· 46 46 47 47 int dwc3_host_init(struct dwc3 *dwc) 48 48 { 49 - struct property_entry props[3]; 49 + struct property_entry props[4]; 50 50 struct platform_device *xhci; 51 51 int ret, irq; 52 52 struct resource *res; ··· 92 92 93 93 if (dwc->usb3_lpm_capable) 94 94 props[prop_idx++].name = "usb3-lpm-capable"; 95 + 96 + if (dwc->usb2_lpm_disable) 97 + props[prop_idx++].name = "usb2-lpm-disable"; 95 98 96 99 /** 97 100 * WORKAROUND: dwc3 revisions <=3.00a have a limitation
+3 -1
drivers/usb/dwc3/trace.h
··· 199 199 __entry->param2 = params->param2; 200 200 __entry->cmd_status = cmd_status; 201 201 ), 202 - TP_printk("%s: cmd '%s' [%d] params %08x %08x %08x --> status: %s", 202 + TP_printk("%s: cmd '%s' [%x] params %08x %08x %08x --> status: %s", 203 203 __get_str(name), dwc3_gadget_ep_cmd_string(__entry->cmd), 204 204 __entry->cmd, __entry->param0, 205 205 __entry->param1, __entry->param2, ··· 251 251 s = "2x "; 252 252 break; 253 253 case 3: 254 + default: 254 255 s = "3x "; 255 256 break; 256 257 } 258 + break; 257 259 default: 258 260 s = ""; 259 261 } s; }),
+19 -19
drivers/usb/early/ehci-dbgp.c
··· 631 631 if (!(portsc & PORT_RESET)) 632 632 break; 633 633 } 634 - if (portsc & PORT_RESET) { 635 - /* force reset to complete */ 636 - loop = 100 * 1000; 637 - writel(portsc & ~(PORT_RWC_BITS | PORT_RESET), 638 - &ehci_regs->port_status[port - 1]); 639 - do { 640 - udelay(1); 641 - portsc = readl(&ehci_regs->port_status[port-1]); 642 - } while ((portsc & PORT_RESET) && (--loop > 0)); 643 - } 634 + if (portsc & PORT_RESET) { 635 + /* force reset to complete */ 636 + loop = 100 * 1000; 637 + writel(portsc & ~(PORT_RWC_BITS | PORT_RESET), 638 + &ehci_regs->port_status[port - 1]); 639 + do { 640 + udelay(1); 641 + portsc = readl(&ehci_regs->port_status[port-1]); 642 + } while ((portsc & PORT_RESET) && (--loop > 0)); 643 + } 644 644 645 - /* Device went away? */ 646 - if (!(portsc & PORT_CONNECT)) 647 - return -ENOTCONN; 645 + /* Device went away? */ 646 + if (!(portsc & PORT_CONNECT)) 647 + return -ENOTCONN; 648 648 649 - /* bomb out completely if something weird happened */ 650 - if ((portsc & PORT_CSC)) 651 - return -EINVAL; 649 + /* bomb out completely if something weird happened */ 650 + if ((portsc & PORT_CSC)) 651 + return -EINVAL; 652 652 653 - /* If we've finished resetting, then break out of the loop */ 654 - if (!(portsc & PORT_RESET) && (portsc & PORT_PE)) 655 - return 0; 653 + /* If we've finished resetting, then break out of the loop */ 654 + if (!(portsc & PORT_RESET) && (portsc & PORT_PE)) 655 + return 0; 656 656 return -EBUSY; 657 657 } 658 658
+108 -14
drivers/usb/gadget/function/f_fs.c
··· 18 18 #include <linux/pagemap.h> 19 19 #include <linux/export.h> 20 20 #include <linux/hid.h> 21 + #include <linux/mm.h> 21 22 #include <linux/module.h> 23 + #include <linux/scatterlist.h> 22 24 #include <linux/sched/signal.h> 23 25 #include <linux/uio.h> 26 + #include <linux/vmalloc.h> 24 27 #include <asm/unaligned.h> 25 28 29 + #include <linux/usb/ccid.h> 26 30 #include <linux/usb/composite.h> 27 31 #include <linux/usb/functionfs.h> 28 32 ··· 222 218 223 219 struct usb_ep *ep; 224 220 struct usb_request *req; 221 + struct sg_table sgt; 222 + bool use_sg; 225 223 226 224 struct ffs_data *ffs; 227 225 }; ··· 755 749 return ret; 756 750 } 757 751 752 + /* 753 + * allocate a virtually contiguous buffer and create a scatterlist describing it 754 + * @sg_table - pointer to a place to be filled with sg_table contents 755 + * @size - required buffer size 756 + */ 757 + static void *ffs_build_sg_list(struct sg_table *sgt, size_t sz) 758 + { 759 + struct page **pages; 760 + void *vaddr, *ptr; 761 + unsigned int n_pages; 762 + int i; 763 + 764 + vaddr = vmalloc(sz); 765 + if (!vaddr) 766 + return NULL; 767 + 768 + n_pages = PAGE_ALIGN(sz) >> PAGE_SHIFT; 769 + pages = kvmalloc_array(n_pages, sizeof(struct page *), GFP_KERNEL); 770 + if (!pages) { 771 + vfree(vaddr); 772 + 773 + return NULL; 774 + } 775 + for (i = 0, ptr = vaddr; i < n_pages; ++i, ptr += PAGE_SIZE) 776 + pages[i] = vmalloc_to_page(ptr); 777 + 778 + if (sg_alloc_table_from_pages(sgt, pages, n_pages, 0, sz, GFP_KERNEL)) { 779 + kvfree(pages); 780 + vfree(vaddr); 781 + 782 + return NULL; 783 + } 784 + kvfree(pages); 785 + 786 + return vaddr; 787 + } 788 + 789 + static inline void *ffs_alloc_buffer(struct ffs_io_data *io_data, 790 + size_t data_len) 791 + { 792 + if (io_data->use_sg) 793 + return ffs_build_sg_list(&io_data->sgt, data_len); 794 + 795 + return kmalloc(data_len, GFP_KERNEL); 796 + } 797 + 798 + static inline void ffs_free_buffer(struct ffs_io_data *io_data) 799 + { 800 + if (!io_data->buf) 801 + return; 802 + 803 + if (io_data->use_sg) { 804 + sg_free_table(&io_data->sgt); 805 + vfree(io_data->buf); 806 + } else { 807 + kfree(io_data->buf); 808 + } 809 + } 810 + 758 811 static void ffs_user_copy_worker(struct work_struct *work) 759 812 { 760 813 struct ffs_io_data *io_data = container_of(work, struct ffs_io_data, ··· 841 776 842 777 if (io_data->read) 843 778 kfree(io_data->to_free); 844 - kfree(io_data->buf); 779 + ffs_free_buffer(io_data); 845 780 kfree(io_data); 846 781 } 847 782 ··· 997 932 * earlier 998 933 */ 999 934 gadget = epfile->ffs->gadget; 935 + io_data->use_sg = gadget->sg_supported && data_len > PAGE_SIZE; 1000 936 1001 937 spin_lock_irq(&epfile->ffs->eps_lock); 1002 938 /* In the meantime, endpoint got disabled or changed. */ ··· 1014 948 data_len = usb_ep_align_maybe(gadget, ep->ep, data_len); 1015 949 spin_unlock_irq(&epfile->ffs->eps_lock); 1016 950 1017 - data = kmalloc(data_len, GFP_KERNEL); 951 + data = ffs_alloc_buffer(io_data, data_len); 1018 952 if (unlikely(!data)) { 1019 953 ret = -ENOMEM; 1020 954 goto error_mutex; ··· 1054 988 bool interrupted = false; 1055 989 1056 990 req = ep->req; 1057 - req->buf = data; 1058 - req->length = data_len; 991 + if (io_data->use_sg) { 992 + req->buf = NULL; 993 + req->sg = io_data->sgt.sgl; 994 + req->num_sgs = io_data->sgt.nents; 995 + } else { 996 + req->buf = data; 997 + } 998 + req->length = data_len; 999 + 1000 + io_data->buf = data; 1059 1001 1060 1002 req->context = &done; 1061 1003 req->complete = ffs_epfile_io_complete; ··· 1096 1022 } else if (!(req = usb_ep_alloc_request(ep->ep, GFP_ATOMIC))) { 1097 1023 ret = -ENOMEM; 1098 1024 } else { 1099 - req->buf = data; 1100 - req->length = data_len; 1025 + if (io_data->use_sg) { 1026 + req->buf = NULL; 1027 + req->sg = io_data->sgt.sgl; 1028 + req->num_sgs = io_data->sgt.nents; 1029 + } else { 1030 + req->buf = data; 1031 + } 1032 + req->length = data_len; 1101 1033 1102 1034 io_data->buf = data; 1103 1035 io_data->ep = ep->ep; ··· 1132 1052 error_mutex: 1133 1053 mutex_unlock(&epfile->mutex); 1134 1054 error: 1135 - kfree(data); 1055 + ffs_free_buffer(io_data); 1136 1056 return ret; 1137 1057 } 1138 1058 ··· 2006 1926 2007 1927 static int __must_check ffs_do_single_desc(char *data, unsigned len, 2008 1928 ffs_entity_callback entity, 2009 - void *priv) 1929 + void *priv, int *current_class) 2010 1930 { 2011 1931 struct usb_descriptor_header *_ds = (void *)data; 2012 1932 u8 length; ··· 2064 1984 __entity(INTERFACE, ds->bInterfaceNumber); 2065 1985 if (ds->iInterface) 2066 1986 __entity(STRING, ds->iInterface); 1987 + *current_class = ds->bInterfaceClass; 2067 1988 } 2068 1989 break; 2069 1990 ··· 2078 1997 } 2079 1998 break; 2080 1999 2081 - case HID_DT_HID: 2082 - pr_vdebug("hid descriptor\n"); 2083 - if (length != sizeof(struct hid_descriptor)) 2084 - goto inv_length; 2085 - break; 2000 + case USB_TYPE_CLASS | 0x01: 2001 + if (*current_class == USB_INTERFACE_CLASS_HID) { 2002 + pr_vdebug("hid descriptor\n"); 2003 + if (length != sizeof(struct hid_descriptor)) 2004 + goto inv_length; 2005 + break; 2006 + } else if (*current_class == USB_INTERFACE_CLASS_CCID) { 2007 + pr_vdebug("ccid descriptor\n"); 2008 + if (length != sizeof(struct ccid_descriptor)) 2009 + goto inv_length; 2010 + break; 2011 + } else { 2012 + pr_vdebug("unknown descriptor: %d for class %d\n", 2013 + _ds->bDescriptorType, *current_class); 2014 + return -EINVAL; 2015 + } 2086 2016 2087 2017 case USB_DT_OTG: 2088 2018 if (length != sizeof(struct usb_otg_descriptor)) ··· 2150 2058 { 2151 2059 const unsigned _len = len; 2152 2060 unsigned long num = 0; 2061 + int current_class = -1; 2153 2062 2154 2063 ENTER(); 2155 2064 ··· 2171 2078 if (!data) 2172 2079 return _len - len; 2173 2080 2174 - ret = ffs_do_single_desc(data, len, entity, priv); 2081 + ret = ffs_do_single_desc(data, len, entity, priv, 2082 + &current_class); 2175 2083 if (unlikely(ret < 0)) { 2176 2084 pr_debug("%s returns %d\n", __func__, ret); 2177 2085 return ret;
+1 -1
drivers/usb/gadget/function/uvc_queue.c
··· 102 102 spin_unlock_irqrestore(&queue->irqlock, flags); 103 103 } 104 104 105 - static struct vb2_ops uvc_queue_qops = { 105 + static const struct vb2_ops uvc_queue_qops = { 106 106 .queue_setup = uvc_queue_setup, 107 107 .buf_prepare = uvc_buffer_prepare, 108 108 .buf_queue = uvc_buffer_queue,
+1 -1
drivers/usb/gadget/udc/aspeed-vhub/dev.c
··· 438 438 return 0; 439 439 } 440 440 441 - static struct usb_gadget_ops ast_vhub_udc_ops = { 441 + static const struct usb_gadget_ops ast_vhub_udc_ops = { 442 442 .get_frame = ast_vhub_udc_get_frame, 443 443 .wakeup = ast_vhub_udc_wakeup, 444 444 .pullup = ast_vhub_udc_pullup,
+1 -1
drivers/usb/gadget/udc/pch_udc.c
··· 1330 1330 } 1331 1331 1332 1332 /** 1333 - * pch_vbus_gpio_irq() - IRQ handler for GPIO intrerrupt for changing VBUS 1333 + * pch_vbus_gpio_irq() - IRQ handler for GPIO interrupt for changing VBUS 1334 1334 * @irq: Interrupt request number 1335 1335 * @dev: Reference to the device structure 1336 1336 *
+10 -5
drivers/usb/gadget/udc/renesas_usb3.c
··· 358 358 bool extcon_host; /* check id and set EXTCON_USB_HOST */ 359 359 bool extcon_usb; /* check vbus and set EXTCON_USB */ 360 360 bool forced_b_device; 361 + bool start_to_connect; 361 362 }; 362 363 363 364 #define gadget_to_renesas_usb3(_gadget) \ ··· 477 476 static void usb3_init_epc_registers(struct renesas_usb3 *usb3) 478 477 { 479 478 usb3_write(usb3, ~0, USB3_USB_INT_STA_1); 480 - usb3_enable_irq_1(usb3, USB_INT_1_VBUS_CNG); 479 + if (!usb3->workaround_for_vbus) 480 + usb3_enable_irq_1(usb3, USB_INT_1_VBUS_CNG); 481 481 } 482 482 483 483 static bool usb3_wakeup_usb2_phy(struct renesas_usb3 *usb3) ··· 702 700 usb3_set_mode_by_role_sw(usb3, host); 703 701 usb3_vbus_out(usb3, a_dev); 704 702 /* for A-Peripheral or forced B-device mode */ 705 - if ((!host && a_dev) || 706 - (usb3->workaround_for_vbus && usb3->forced_b_device)) 703 + if ((!host && a_dev) || usb3->start_to_connect) 707 704 usb3_connect(usb3); 708 705 spin_unlock_irqrestore(&usb3->lock, flags); 709 706 } ··· 2433 2432 if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count))) 2434 2433 return -EFAULT; 2435 2434 2436 - if (!strncmp(buf, "1", 1)) 2435 + usb3->start_to_connect = false; 2436 + if (usb3->workaround_for_vbus && usb3->forced_b_device && 2437 + !strncmp(buf, "2", 1)) 2438 + usb3->start_to_connect = true; 2439 + else if (!strncmp(buf, "1", 1)) 2437 2440 usb3->forced_b_device = true; 2438 2441 else 2439 2442 usb3->forced_b_device = false; ··· 2445 2440 if (usb3->workaround_for_vbus) 2446 2441 usb3_disconnect(usb3); 2447 2442 2448 - /* Let this driver call usb3_connect() anyway */ 2443 + /* Let this driver call usb3_connect() if needed */ 2449 2444 usb3_check_id(usb3); 2450 2445 2451 2446 return count;
+2 -15
drivers/usb/gadget/udc/s3c2410_udc.c
··· 119 119 } 120 120 #endif 121 121 122 - static int s3c2410_udc_debugfs_seq_show(struct seq_file *m, void *p) 122 + static int s3c2410_udc_debugfs_show(struct seq_file *m, void *p) 123 123 { 124 124 u32 addr_reg, pwr_reg, ep_int_reg, usb_int_reg; 125 125 u32 ep_int_en_reg, usb_int_en_reg, ep0_csr; ··· 168 168 169 169 return 0; 170 170 } 171 - 172 - static int s3c2410_udc_debugfs_fops_open(struct inode *inode, 173 - struct file *file) 174 - { 175 - return single_open(file, s3c2410_udc_debugfs_seq_show, NULL); 176 - } 177 - 178 - static const struct file_operations s3c2410_udc_debugfs_fops = { 179 - .open = s3c2410_udc_debugfs_fops_open, 180 - .read = seq_read, 181 - .llseek = seq_lseek, 182 - .release = single_release, 183 - .owner = THIS_MODULE, 184 - }; 171 + DEFINE_SHOW_ATTRIBUTE(s3c2410_udc_debugfs); 185 172 186 173 /* io macros */ 187 174
+5 -4
drivers/usb/host/ehci-omap.c
··· 159 159 /* get the PHY device */ 160 160 phy = devm_usb_get_phy_by_phandle(dev, "phys", i); 161 161 if (IS_ERR(phy)) { 162 - /* Don't bail out if PHY is not absolutely necessary */ 163 - if (pdata->port_mode[i] != OMAP_EHCI_PORT_MODE_PHY) 164 - continue; 165 - 166 162 ret = PTR_ERR(phy); 163 + if (ret == -ENODEV) { /* no PHY */ 164 + phy = NULL; 165 + continue; 166 + } 167 + 167 168 if (ret != -EPROBE_DEFER) 168 169 dev_err(dev, "Can't get PHY for port %d: %d\n", 169 170 i, ret);
+3 -13
drivers/usb/host/isp1362-hcd.c
··· 2159 2159 2160 2160 return 0; 2161 2161 } 2162 - 2163 - static int isp1362_open(struct inode *inode, struct file *file) 2164 - { 2165 - return single_open(file, isp1362_show, inode); 2166 - } 2167 - 2168 - static const struct file_operations debug_ops = { 2169 - .open = isp1362_open, 2170 - .read = seq_read, 2171 - .llseek = seq_lseek, 2172 - .release = single_release, 2173 - }; 2162 + DEFINE_SHOW_ATTRIBUTE(isp1362); 2174 2163 2175 2164 /* expect just one isp1362_hcd per system */ 2176 2165 static void create_debug_file(struct isp1362_hcd *isp1362_hcd) 2177 2166 { 2178 2167 isp1362_hcd->debug_file = debugfs_create_file("isp1362", S_IRUGO, 2179 2168 usb_debug_root, 2180 - isp1362_hcd, &debug_ops); 2169 + isp1362_hcd, 2170 + &isp1362_fops); 2181 2171 } 2182 2172 2183 2173 static void remove_debug_file(struct isp1362_hcd *isp1362_hcd)
+4 -8
drivers/usb/host/ohci-mem.c
··· 57 57 58 58 static void ohci_mem_cleanup (struct ohci_hcd *ohci) 59 59 { 60 - if (ohci->td_cache) { 61 - dma_pool_destroy (ohci->td_cache); 62 - ohci->td_cache = NULL; 63 - } 64 - if (ohci->ed_cache) { 65 - dma_pool_destroy (ohci->ed_cache); 66 - ohci->ed_cache = NULL; 67 - } 60 + dma_pool_destroy(ohci->td_cache); 61 + ohci->td_cache = NULL; 62 + dma_pool_destroy(ohci->ed_cache); 63 + ohci->ed_cache = NULL; 68 64 } 69 65 70 66 /*-------------------------------------------------------------------------*/
+4 -1
drivers/usb/host/r8a66597-hcd.c
··· 1979 1979 1980 1980 static void r8a66597_endpoint_disable(struct usb_hcd *hcd, 1981 1981 struct usb_host_endpoint *hep) 1982 + __acquires(r8a66597->lock) 1983 + __releases(r8a66597->lock) 1982 1984 { 1983 1985 struct r8a66597 *r8a66597 = hcd_to_r8a66597(hcd); 1984 1986 struct r8a66597_pipe *pipe = (struct r8a66597_pipe *)hep->hcpriv; ··· 1993 1991 return; 1994 1992 pipenum = pipe->info.pipenum; 1995 1993 1994 + spin_lock_irqsave(&r8a66597->lock, flags); 1996 1995 if (pipenum == 0) { 1997 1996 kfree(hep->hcpriv); 1998 1997 hep->hcpriv = NULL; 1998 + spin_unlock_irqrestore(&r8a66597->lock, flags); 1999 1999 return; 2000 2000 } 2001 2001 2002 - spin_lock_irqsave(&r8a66597->lock, flags); 2003 2002 pipe_stop(r8a66597, pipe); 2004 2003 pipe_irq_disable(r8a66597, pipenum); 2005 2004 disable_irq_empty(r8a66597, pipenum);
+197 -156
drivers/usb/host/xhci-hub.c
··· 714 714 } 715 715 } 716 716 717 - /* Updates Link Status for USB 2.1 port */ 718 - static void xhci_hub_report_usb2_link_state(u32 *status, u32 status_reg) 719 - { 720 - if ((status_reg & PORT_PLS_MASK) == XDEV_U2) 721 - *status |= USB_PORT_STAT_L1; 722 - } 723 - 724 717 /* Updates Link Status for super Speed port */ 725 718 static void xhci_hub_report_usb3_link_state(struct xhci_hcd *xhci, 726 719 u32 *status, u32 status_reg) ··· 795 802 } 796 803 } 797 804 805 + static int xhci_handle_usb2_port_link_resume(struct xhci_port *port, 806 + u32 *status, u32 portsc, 807 + unsigned long flags) 808 + { 809 + struct xhci_bus_state *bus_state; 810 + struct xhci_hcd *xhci; 811 + struct usb_hcd *hcd; 812 + int slot_id; 813 + u32 wIndex; 814 + 815 + hcd = port->rhub->hcd; 816 + bus_state = &port->rhub->bus_state; 817 + xhci = hcd_to_xhci(hcd); 818 + wIndex = port->hcd_portnum; 819 + 820 + if ((portsc & PORT_RESET) || !(portsc & PORT_PE)) { 821 + *status = 0xffffffff; 822 + return -EINVAL; 823 + } 824 + /* did port event handler already start resume timing? */ 825 + if (!bus_state->resume_done[wIndex]) { 826 + /* If not, maybe we are in a host initated resume? */ 827 + if (test_bit(wIndex, &bus_state->resuming_ports)) { 828 + /* Host initated resume doesn't time the resume 829 + * signalling using resume_done[]. 830 + * It manually sets RESUME state, sleeps 20ms 831 + * and sets U0 state. This should probably be 832 + * changed, but not right now. 833 + */ 834 + } else { 835 + /* port resume was discovered now and here, 836 + * start resume timing 837 + */ 838 + unsigned long timeout = jiffies + 839 + msecs_to_jiffies(USB_RESUME_TIMEOUT); 840 + 841 + set_bit(wIndex, &bus_state->resuming_ports); 842 + bus_state->resume_done[wIndex] = timeout; 843 + mod_timer(&hcd->rh_timer, timeout); 844 + usb_hcd_start_port_resume(&hcd->self, wIndex); 845 + } 846 + /* Has resume been signalled for USB_RESUME_TIME yet? */ 847 + } else if (time_after_eq(jiffies, bus_state->resume_done[wIndex])) { 848 + int time_left; 849 + 850 + xhci_dbg(xhci, "Resume USB2 port %d\n", wIndex + 1); 851 + bus_state->resume_done[wIndex] = 0; 852 + clear_bit(wIndex, &bus_state->resuming_ports); 853 + 854 + set_bit(wIndex, &bus_state->rexit_ports); 855 + 856 + xhci_test_and_clear_bit(xhci, port, PORT_PLC); 857 + xhci_set_link_state(xhci, port, XDEV_U0); 858 + 859 + spin_unlock_irqrestore(&xhci->lock, flags); 860 + time_left = wait_for_completion_timeout( 861 + &bus_state->rexit_done[wIndex], 862 + msecs_to_jiffies(XHCI_MAX_REXIT_TIMEOUT_MS)); 863 + spin_lock_irqsave(&xhci->lock, flags); 864 + 865 + if (time_left) { 866 + slot_id = xhci_find_slot_id_by_port(hcd, xhci, 867 + wIndex + 1); 868 + if (!slot_id) { 869 + xhci_dbg(xhci, "slot_id is zero\n"); 870 + *status = 0xffffffff; 871 + return -ENODEV; 872 + } 873 + xhci_ring_device(xhci, slot_id); 874 + } else { 875 + int port_status = readl(port->addr); 876 + 877 + xhci_warn(xhci, "Port resume %i msec timed out, portsc = 0x%x\n", 878 + XHCI_MAX_REXIT_TIMEOUT_MS, 879 + port_status); 880 + *status |= USB_PORT_STAT_SUSPEND; 881 + clear_bit(wIndex, &bus_state->rexit_ports); 882 + } 883 + 884 + usb_hcd_end_port_resume(&hcd->self, wIndex); 885 + bus_state->port_c_suspend |= 1 << wIndex; 886 + bus_state->suspended_ports &= ~(1 << wIndex); 887 + } else { 888 + /* 889 + * The resume has been signaling for less than 890 + * USB_RESUME_TIME. Report the port status as SUSPEND, 891 + * let the usbcore check port status again and clear 892 + * resume signaling later. 893 + */ 894 + *status |= USB_PORT_STAT_SUSPEND; 895 + } 896 + return 0; 897 + } 898 + 798 899 static u32 xhci_get_ext_port_status(u32 raw_port_status, u32 port_li) 799 900 { 800 901 u32 ext_stat = 0; ··· 903 816 ext_stat |= PORT_TX_LANES(port_li) << 12; /* bits 15:12 Tx lane count */ 904 817 905 818 return ext_stat; 819 + } 820 + 821 + static void xhci_get_usb3_port_status(struct xhci_port *port, u32 *status, 822 + u32 portsc) 823 + { 824 + struct xhci_bus_state *bus_state; 825 + struct xhci_hcd *xhci; 826 + u32 link_state; 827 + u32 portnum; 828 + 829 + bus_state = &port->rhub->bus_state; 830 + xhci = hcd_to_xhci(port->rhub->hcd); 831 + link_state = portsc & PORT_PLS_MASK; 832 + portnum = port->hcd_portnum; 833 + 834 + /* USB3 specific wPortChange bits 835 + * 836 + * Port link change with port in resume state should not be 837 + * reported to usbcore, as this is an internal state to be 838 + * handled by xhci driver. Reporting PLC to usbcore may 839 + * cause usbcore clearing PLC first and port change event 840 + * irq won't be generated. 841 + */ 842 + 843 + if (portsc & PORT_PLC && (link_state != XDEV_RESUME)) 844 + *status |= USB_PORT_STAT_C_LINK_STATE << 16; 845 + if (portsc & PORT_WRC) 846 + *status |= USB_PORT_STAT_C_BH_RESET << 16; 847 + if (portsc & PORT_CEC) 848 + *status |= USB_PORT_STAT_C_CONFIG_ERROR << 16; 849 + 850 + /* USB3 specific wPortStatus bits */ 851 + if (portsc & PORT_POWER) { 852 + *status |= USB_SS_PORT_STAT_POWER; 853 + /* link state handling */ 854 + if (link_state == XDEV_U0) 855 + bus_state->suspended_ports &= ~(1 << portnum); 856 + } 857 + 858 + xhci_hub_report_usb3_link_state(xhci, status, portsc); 859 + xhci_del_comp_mod_timer(xhci, portsc, portnum); 860 + } 861 + 862 + static void xhci_get_usb2_port_status(struct xhci_port *port, u32 *status, 863 + u32 portsc, unsigned long flags) 864 + { 865 + struct xhci_bus_state *bus_state; 866 + u32 link_state; 867 + u32 portnum; 868 + int ret; 869 + 870 + bus_state = &port->rhub->bus_state; 871 + link_state = portsc & PORT_PLS_MASK; 872 + portnum = port->hcd_portnum; 873 + 874 + /* USB2 wPortStatus bits */ 875 + if (portsc & PORT_POWER) { 876 + *status |= USB_PORT_STAT_POWER; 877 + 878 + /* link state is only valid if port is powered */ 879 + if (link_state == XDEV_U3) 880 + *status |= USB_PORT_STAT_SUSPEND; 881 + if (link_state == XDEV_U2) 882 + *status |= USB_PORT_STAT_L1; 883 + if (link_state == XDEV_U0) { 884 + bus_state->resume_done[portnum] = 0; 885 + clear_bit(portnum, &bus_state->resuming_ports); 886 + if (bus_state->suspended_ports & (1 << portnum)) { 887 + bus_state->suspended_ports &= ~(1 << portnum); 888 + bus_state->port_c_suspend |= 1 << portnum; 889 + } 890 + } 891 + if (link_state == XDEV_RESUME) { 892 + ret = xhci_handle_usb2_port_link_resume(port, status, 893 + portsc, flags); 894 + if (ret) 895 + return; 896 + } 897 + } 906 898 } 907 899 908 900 /* ··· 1001 835 __releases(&xhci->lock) 1002 836 __acquires(&xhci->lock) 1003 837 { 1004 - struct xhci_hcd *xhci = hcd_to_xhci(hcd); 1005 838 u32 status = 0; 1006 - int slot_id; 1007 839 struct xhci_hub *rhub; 1008 840 struct xhci_port *port; 1009 841 1010 842 rhub = xhci_get_rhub(hcd); 1011 843 port = rhub->ports[wIndex]; 1012 844 1013 - /* wPortChange bits */ 845 + /* common wPortChange bits */ 1014 846 if (raw_port_status & PORT_CSC) 1015 847 status |= USB_PORT_STAT_C_CONNECTION << 16; 1016 848 if (raw_port_status & PORT_PEC) ··· 1017 853 status |= USB_PORT_STAT_C_OVERCURRENT << 16; 1018 854 if ((raw_port_status & PORT_RC)) 1019 855 status |= USB_PORT_STAT_C_RESET << 16; 1020 - /* USB3.0 only */ 1021 - if (hcd->speed >= HCD_USB3) { 1022 - /* Port link change with port in resume state should not be 1023 - * reported to usbcore, as this is an internal state to be 1024 - * handled by xhci driver. Reporting PLC to usbcore may 1025 - * cause usbcore clearing PLC first and port change event 1026 - * irq won't be generated. 1027 - */ 1028 - if ((raw_port_status & PORT_PLC) && 1029 - (raw_port_status & PORT_PLS_MASK) != XDEV_RESUME) 1030 - status |= USB_PORT_STAT_C_LINK_STATE << 16; 1031 - if ((raw_port_status & PORT_WRC)) 1032 - status |= USB_PORT_STAT_C_BH_RESET << 16; 1033 - if ((raw_port_status & PORT_CEC)) 1034 - status |= USB_PORT_STAT_C_CONFIG_ERROR << 16; 856 + 857 + /* common wPortStatus bits */ 858 + if (raw_port_status & PORT_CONNECT) { 859 + status |= USB_PORT_STAT_CONNECTION; 860 + status |= xhci_port_speed(raw_port_status); 1035 861 } 862 + if (raw_port_status & PORT_PE) 863 + status |= USB_PORT_STAT_ENABLE; 864 + if (raw_port_status & PORT_OC) 865 + status |= USB_PORT_STAT_OVERCURRENT; 866 + if (raw_port_status & PORT_RESET) 867 + status |= USB_PORT_STAT_RESET; 1036 868 1037 - if (hcd->speed < HCD_USB3) { 1038 - if ((raw_port_status & PORT_PLS_MASK) == XDEV_U3 1039 - && (raw_port_status & PORT_POWER)) 1040 - status |= USB_PORT_STAT_SUSPEND; 1041 - } 1042 - if ((raw_port_status & PORT_PLS_MASK) == XDEV_RESUME && 1043 - !DEV_SUPERSPEED_ANY(raw_port_status) && hcd->speed < HCD_USB3) { 1044 - if ((raw_port_status & PORT_RESET) || 1045 - !(raw_port_status & PORT_PE)) 1046 - return 0xffffffff; 1047 - /* did port event handler already start resume timing? */ 1048 - if (!bus_state->resume_done[wIndex]) { 1049 - /* If not, maybe we are in a host initated resume? */ 1050 - if (test_bit(wIndex, &bus_state->resuming_ports)) { 1051 - /* Host initated resume doesn't time the resume 1052 - * signalling using resume_done[]. 1053 - * It manually sets RESUME state, sleeps 20ms 1054 - * and sets U0 state. This should probably be 1055 - * changed, but not right now. 1056 - */ 1057 - } else { 1058 - /* port resume was discovered now and here, 1059 - * start resume timing 1060 - */ 1061 - unsigned long timeout = jiffies + 1062 - msecs_to_jiffies(USB_RESUME_TIMEOUT); 1063 - 1064 - set_bit(wIndex, &bus_state->resuming_ports); 1065 - bus_state->resume_done[wIndex] = timeout; 1066 - mod_timer(&hcd->rh_timer, timeout); 1067 - usb_hcd_start_port_resume(&hcd->self, wIndex); 1068 - } 1069 - /* Has resume been signalled for USB_RESUME_TIME yet? */ 1070 - } else if (time_after_eq(jiffies, 1071 - bus_state->resume_done[wIndex])) { 1072 - int time_left; 1073 - 1074 - xhci_dbg(xhci, "Resume USB2 port %d\n", 1075 - wIndex + 1); 1076 - bus_state->resume_done[wIndex] = 0; 1077 - clear_bit(wIndex, &bus_state->resuming_ports); 1078 - 1079 - set_bit(wIndex, &bus_state->rexit_ports); 1080 - 1081 - xhci_test_and_clear_bit(xhci, port, PORT_PLC); 1082 - xhci_set_link_state(xhci, port, XDEV_U0); 1083 - 1084 - spin_unlock_irqrestore(&xhci->lock, flags); 1085 - time_left = wait_for_completion_timeout( 1086 - &bus_state->rexit_done[wIndex], 1087 - msecs_to_jiffies( 1088 - XHCI_MAX_REXIT_TIMEOUT_MS)); 1089 - spin_lock_irqsave(&xhci->lock, flags); 1090 - 1091 - if (time_left) { 1092 - slot_id = xhci_find_slot_id_by_port(hcd, 1093 - xhci, wIndex + 1); 1094 - if (!slot_id) { 1095 - xhci_dbg(xhci, "slot_id is zero\n"); 1096 - return 0xffffffff; 1097 - } 1098 - xhci_ring_device(xhci, slot_id); 1099 - } else { 1100 - int port_status = readl(port->addr); 1101 - xhci_warn(xhci, "Port resume took longer than %i msec, port status = 0x%x\n", 1102 - XHCI_MAX_REXIT_TIMEOUT_MS, 1103 - port_status); 1104 - status |= USB_PORT_STAT_SUSPEND; 1105 - clear_bit(wIndex, &bus_state->rexit_ports); 1106 - } 1107 - 1108 - usb_hcd_end_port_resume(&hcd->self, wIndex); 1109 - bus_state->port_c_suspend |= 1 << wIndex; 1110 - bus_state->suspended_ports &= ~(1 << wIndex); 1111 - } else { 1112 - /* 1113 - * The resume has been signaling for less than 1114 - * USB_RESUME_TIME. Report the port status as SUSPEND, 1115 - * let the usbcore check port status again and clear 1116 - * resume signaling later. 1117 - */ 1118 - status |= USB_PORT_STAT_SUSPEND; 1119 - } 1120 - } 869 + /* USB2 and USB3 specific bits, including Port Link State */ 870 + if (hcd->speed >= HCD_USB3) 871 + xhci_get_usb3_port_status(port, &status, raw_port_status); 872 + else 873 + xhci_get_usb2_port_status(port, &status, raw_port_status, 874 + flags); 1121 875 /* 1122 876 * Clear stale usb2 resume signalling variables in case port changed 1123 877 * state during resume signalling. For example on error ··· 1049 967 usb_hcd_end_port_resume(&hcd->self, wIndex); 1050 968 } 1051 969 1052 - 1053 - if ((raw_port_status & PORT_PLS_MASK) == XDEV_U0 && 1054 - (raw_port_status & PORT_POWER)) { 1055 - if (bus_state->suspended_ports & (1 << wIndex)) { 1056 - bus_state->suspended_ports &= ~(1 << wIndex); 1057 - if (hcd->speed < HCD_USB3) 1058 - bus_state->port_c_suspend |= 1 << wIndex; 1059 - } 1060 - bus_state->resume_done[wIndex] = 0; 1061 - clear_bit(wIndex, &bus_state->resuming_ports); 1062 - } 1063 - if (raw_port_status & PORT_CONNECT) { 1064 - status |= USB_PORT_STAT_CONNECTION; 1065 - status |= xhci_port_speed(raw_port_status); 1066 - } 1067 - if (raw_port_status & PORT_PE) 1068 - status |= USB_PORT_STAT_ENABLE; 1069 - if (raw_port_status & PORT_OC) 1070 - status |= USB_PORT_STAT_OVERCURRENT; 1071 - if (raw_port_status & PORT_RESET) 1072 - status |= USB_PORT_STAT_RESET; 1073 - if (raw_port_status & PORT_POWER) { 1074 - if (hcd->speed >= HCD_USB3) 1075 - status |= USB_SS_PORT_STAT_POWER; 1076 - else 1077 - status |= USB_PORT_STAT_POWER; 1078 - } 1079 - /* Update Port Link State */ 1080 - if (hcd->speed >= HCD_USB3) { 1081 - xhci_hub_report_usb3_link_state(xhci, &status, raw_port_status); 1082 - /* 1083 - * Verify if all USB3 Ports Have entered U0 already. 1084 - * Delete Compliance Mode Timer if so. 1085 - */ 1086 - xhci_del_comp_mod_timer(xhci, raw_port_status, wIndex); 1087 - } else { 1088 - xhci_hub_report_usb2_link_state(&status, raw_port_status); 1089 - } 1090 970 if (bus_state->port_c_suspend & (1 << wIndex)) 1091 971 status |= USB_PORT_STAT_C_SUSPEND << 16; 1092 972 ··· 1075 1031 rhub = xhci_get_rhub(hcd); 1076 1032 ports = rhub->ports; 1077 1033 max_ports = rhub->num_ports; 1078 - bus_state = &xhci->bus_state[hcd_index(hcd)]; 1034 + bus_state = &rhub->bus_state; 1079 1035 1080 1036 spin_lock_irqsave(&xhci->lock, flags); 1081 1037 switch (typeReq) { ··· 1465 1421 rhub = xhci_get_rhub(hcd); 1466 1422 ports = rhub->ports; 1467 1423 max_ports = rhub->num_ports; 1468 - bus_state = &xhci->bus_state[hcd_index(hcd)]; 1424 + bus_state = &rhub->bus_state; 1469 1425 1470 1426 /* Initial status is no changes */ 1471 1427 retval = (max_ports + 8) / 8; ··· 1524 1480 rhub = xhci_get_rhub(hcd); 1525 1481 ports = rhub->ports; 1526 1482 max_ports = rhub->num_ports; 1527 - bus_state = &xhci->bus_state[hcd_index(hcd)]; 1483 + bus_state = &rhub->bus_state; 1528 1484 wake_enabled = hcd->self.root_hub->do_remote_wakeup; 1529 1485 1530 1486 spin_lock_irqsave(&xhci->lock, flags); ··· 1667 1623 rhub = xhci_get_rhub(hcd); 1668 1624 ports = rhub->ports; 1669 1625 max_ports = rhub->num_ports; 1670 - bus_state = &xhci->bus_state[hcd_index(hcd)]; 1626 + bus_state = &rhub->bus_state; 1671 1627 1672 1628 if (time_before(jiffies, bus_state->next_statechange)) 1673 1629 msleep(5); ··· 1768 1724 1769 1725 unsigned long xhci_get_resuming_ports(struct usb_hcd *hcd) 1770 1726 { 1771 - struct xhci_hcd *xhci = hcd_to_xhci(hcd); 1772 - struct xhci_bus_state *bus_state; 1773 - 1774 - bus_state = &xhci->bus_state[hcd_index(hcd)]; 1727 + struct xhci_hub *rhub = xhci_get_rhub(hcd); 1775 1728 1776 1729 /* USB3 port wakeups are reported via usb_wakeup_notification() */ 1777 - return bus_state->resuming_ports; /* USB2 ports only */ 1730 + return rhub->bus_state.resuming_ports; /* USB2 ports only */ 1778 1731 } 1779 1732 1780 1733 #endif /* CONFIG_PM */
+9 -21
drivers/usb/host/xhci-mem.c
··· 1922 1922 1923 1923 xhci->page_size = 0; 1924 1924 xhci->page_shift = 0; 1925 - xhci->bus_state[0].bus_suspended = 0; 1926 - xhci->bus_state[1].bus_suspended = 0; 1925 + xhci->usb2_rhub.bus_state.bus_suspended = 0; 1926 + xhci->usb3_rhub.bus_state.bus_suspended = 0; 1927 1927 } 1928 1928 1929 1929 static int xhci_test_trb_in_td(struct xhci_hcd *xhci, ··· 2181 2181 if (major_revision < 0x03 && xhci->num_ext_caps < max_caps) 2182 2182 xhci->ext_caps[xhci->num_ext_caps++] = temp; 2183 2183 2184 - /* Check the host's USB2 LPM capability */ 2185 - if ((xhci->hci_version == 0x96) && (major_revision != 0x03) && 2186 - (temp & XHCI_L1C)) { 2184 + if ((xhci->hci_version >= 0x100) && (major_revision != 0x03) && 2185 + (temp & XHCI_HLC)) { 2187 2186 xhci_dbg_trace(xhci, trace_xhci_dbg_init, 2188 - "xHCI 0.96: support USB2 software lpm"); 2189 - xhci->sw_lpm_support = 1; 2190 - } 2191 - 2192 - if ((xhci->hci_version >= 0x100) && (major_revision != 0x03)) { 2193 - xhci_dbg_trace(xhci, trace_xhci_dbg_init, 2194 - "xHCI 1.0: support USB2 software lpm"); 2195 - xhci->sw_lpm_support = 1; 2196 - if (temp & XHCI_HLC) { 2197 - xhci_dbg_trace(xhci, trace_xhci_dbg_init, 2198 - "xHCI 1.0: support USB2 hardware lpm"); 2199 - xhci->hw_lpm_support = 1; 2200 - } 2187 + "xHCI 1.0: support USB2 hardware lpm"); 2188 + xhci->hw_lpm_support = 1; 2201 2189 } 2202 2190 2203 2191 port_offset--; ··· 2524 2536 for (i = 0; i < MAX_HC_SLOTS; i++) 2525 2537 xhci->devs[i] = NULL; 2526 2538 for (i = 0; i < USB_MAXCHILDREN; i++) { 2527 - xhci->bus_state[0].resume_done[i] = 0; 2528 - xhci->bus_state[1].resume_done[i] = 0; 2539 + xhci->usb2_rhub.bus_state.resume_done[i] = 0; 2540 + xhci->usb3_rhub.bus_state.resume_done[i] = 0; 2529 2541 /* Only the USB 2.0 completions will ever be used. */ 2530 - init_completion(&xhci->bus_state[1].rexit_done[i]); 2542 + init_completion(&xhci->usb2_rhub.bus_state.rexit_done[i]); 2531 2543 } 2532 2544 2533 2545 if (scratchpad_alloc(xhci, flags))
+1 -1
drivers/usb/host/xhci-ring.c
··· 1593 1593 } 1594 1594 1595 1595 hcd = port->rhub->hcd; 1596 - bus_state = &xhci->bus_state[hcd_index(hcd)]; 1596 + bus_state = &port->rhub->bus_state; 1597 1597 hcd_portnum = port->hcd_portnum; 1598 1598 portsc = readl(port->addr); 1599 1599
+11 -11
drivers/usb/host/xhci.c
··· 169 169 { 170 170 u32 command; 171 171 u32 state; 172 - int ret, i; 172 + int ret; 173 173 174 174 state = readl(&xhci->op_regs->status); 175 175 ··· 215 215 ret = xhci_handshake(&xhci->op_regs->status, 216 216 STS_CNR, 0, 10 * 1000 * 1000); 217 217 218 - for (i = 0; i < 2; i++) { 219 - xhci->bus_state[i].port_c_suspend = 0; 220 - xhci->bus_state[i].suspended_ports = 0; 221 - xhci->bus_state[i].resuming_ports = 0; 222 - } 218 + xhci->usb2_rhub.bus_state.port_c_suspend = 0; 219 + xhci->usb2_rhub.bus_state.suspended_ports = 0; 220 + xhci->usb2_rhub.bus_state.resuming_ports = 0; 221 + xhci->usb3_rhub.bus_state.port_c_suspend = 0; 222 + xhci->usb3_rhub.bus_state.suspended_ports = 0; 223 + xhci->usb3_rhub.bus_state.resuming_ports = 0; 223 224 224 225 return ret; 225 226 } ··· 1088 1087 /* Wait a bit if either of the roothubs need to settle from the 1089 1088 * transition into bus suspend. 1090 1089 */ 1091 - if (time_before(jiffies, xhci->bus_state[0].next_statechange) || 1092 - time_before(jiffies, 1093 - xhci->bus_state[1].next_statechange)) 1090 + 1091 + if (time_before(jiffies, xhci->usb2_rhub.bus_state.next_statechange) || 1092 + time_before(jiffies, xhci->usb3_rhub.bus_state.next_statechange)) 1094 1093 msleep(100); 1095 1094 1096 1095 set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); ··· 4389 4388 struct xhci_hcd *xhci = hcd_to_xhci(hcd); 4390 4389 int portnum = udev->portnum - 1; 4391 4390 4392 - if (hcd->speed >= HCD_USB3 || !xhci->sw_lpm_support || 4393 - !udev->lpm_capable) 4391 + if (hcd->speed >= HCD_USB3 || !udev->lpm_capable) 4394 4392 return 0; 4395 4393 4396 4394 /* we only support lpm for non-hub device connected to root hub yet */
+2 -11
drivers/usb/host/xhci.h
··· 1682 1682 */ 1683 1683 #define XHCI_MAX_REXIT_TIMEOUT_MS 20 1684 1684 1685 - static inline unsigned int hcd_index(struct usb_hcd *hcd) 1686 - { 1687 - if (hcd->speed >= HCD_USB3) 1688 - return 0; 1689 - else 1690 - return 1; 1691 - } 1692 1685 struct xhci_port { 1693 1686 __le32 __iomem *addr; 1694 1687 int hw_portnum; ··· 1693 1700 struct xhci_port **ports; 1694 1701 unsigned int num_ports; 1695 1702 struct usb_hcd *hcd; 1703 + /* keep track of bus suspend info */ 1704 + struct xhci_bus_state bus_state; 1696 1705 /* supported prococol extended capabiliy values */ 1697 1706 u8 maj_rev; 1698 1707 u8 min_rev; ··· 1849 1854 1850 1855 unsigned int num_active_eps; 1851 1856 unsigned int limit_active_eps; 1852 - /* There are two roothubs to keep track of bus suspend info for */ 1853 - struct xhci_bus_state bus_state[2]; 1854 1857 struct xhci_port *hw_ports; 1855 1858 struct xhci_hub usb2_rhub; 1856 1859 struct xhci_hub usb3_rhub; 1857 - /* support xHCI 0.96 spec USB2 software LPM */ 1858 - unsigned sw_lpm_support:1; 1859 1860 /* support xHCI 1.0 spec USB2 hardware LPM */ 1860 1861 unsigned hw_lpm_support:1; 1861 1862 /* Broken Suspend flag for SNPS Suspend resume issue */
+1 -7
drivers/usb/misc/appledisplay.c
··· 69 69 70 70 struct delayed_work work; 71 71 int button_pressed; 72 - spinlock_t lock; 73 72 struct mutex sysfslock; /* concurrent read and write */ 74 73 }; 75 74 ··· 78 79 { 79 80 struct appledisplay *pdata = urb->context; 80 81 struct device *dev = &pdata->udev->dev; 81 - unsigned long flags; 82 82 int status = urb->status; 83 83 int retval; 84 84 ··· 103 105 goto exit; 104 106 } 105 107 106 - spin_lock_irqsave(&pdata->lock, flags); 107 - 108 108 switch(pdata->urbdata[1]) { 109 109 case ACD_BTN_BRIGHT_UP: 110 110 case ACD_BTN_BRIGHT_DOWN: ··· 114 118 pdata->button_pressed = 0; 115 119 break; 116 120 } 117 - 118 - spin_unlock_irqrestore(&pdata->lock, flags); 119 121 120 122 exit: 121 123 retval = usb_submit_urb(pdata->urb, GFP_ATOMIC); ··· 223 229 224 230 pdata->udev = udev; 225 231 226 - spin_lock_init(&pdata->lock); 227 232 INIT_DELAYED_WORK(&pdata->work, appledisplay_work); 228 233 mutex_init(&pdata->sysfslock); 229 234 ··· 254 261 usb_rcvintpipe(udev, int_in_endpointAddr), 255 262 pdata->urbdata, ACD_URB_BUFFER_LEN, appledisplay_complete, 256 263 pdata, 1); 264 + pdata->urb->transfer_flags = URB_NO_TRANSFER_DMA_MAP; 257 265 if (usb_submit_urb(pdata->urb, GFP_KERNEL)) { 258 266 retval = -EIO; 259 267 dev_err(&iface->dev, "Submitting URB failed\n");
+9 -11
drivers/usb/mtu3/mtu3_core.c
··· 180 180 mtu3_writel(mbase, U3D_LV1IESR, value); 181 181 182 182 /* Enable U2 common USB interrupts */ 183 - value = SUSPEND_INTR | RESUME_INTR | RESET_INTR | LPM_RESUME_INTR; 183 + value = SUSPEND_INTR | RESUME_INTR | RESET_INTR; 184 184 mtu3_writel(mbase, U3D_COMMON_USB_INTR_ENABLE, value); 185 185 186 186 if (mtu->is_u3_ip) { ··· 484 484 mtu3_writel(mtu->mac_base, U3D_EP0CSR, csr); 485 485 486 486 /* Enable EP0 interrupt */ 487 - mtu3_writel(mtu->mac_base, U3D_EPIESR, EP0ISR); 487 + mtu3_writel(mtu->mac_base, U3D_EPIESR, EP0ISR | SETUPENDISR); 488 488 } 489 489 490 490 static int mtu3_mem_alloc(struct mtu3 *mtu) ··· 578 578 if (mtu->is_u3_ip) { 579 579 /* disable LGO_U1/U2 by default */ 580 580 mtu3_clrbits(mbase, U3D_LINK_POWER_CONTROL, 581 - SW_U1_ACCEPT_ENABLE | SW_U2_ACCEPT_ENABLE | 582 581 SW_U1_REQUEST_ENABLE | SW_U2_REQUEST_ENABLE); 582 + /* enable accept LGO_U1/U2 link command from host */ 583 + mtu3_setbits(mbase, U3D_LINK_POWER_CONTROL, 584 + SW_U1_ACCEPT_ENABLE | SW_U2_ACCEPT_ENABLE); 583 585 /* device responses to u3_exit from host automatically */ 584 586 mtu3_clrbits(mbase, U3D_LTSSM_CTRL, SOFT_U3_EXIT_EN); 585 587 /* automatically build U2 link when U3 detect fail */ 586 588 mtu3_setbits(mbase, U3D_USB2_TEST_MODE, U2U3_AUTO_SWITCH); 589 + /* auto clear SOFT_CONN when clear USB3_EN if work as HS */ 590 + mtu3_setbits(mbase, U3D_U3U2_SWITCH_CTRL, SOFTCON_CLR_AUTO_EN); 587 591 } 588 592 589 593 mtu3_set_speed(mtu); ··· 596 592 mtu3_clrbits(mbase, U3D_LINK_RESET_INFO, WTCHRP_MSK); 597 593 /* U2/U3 detected by HW */ 598 594 mtu3_writel(mbase, U3D_DEVICE_CONF, 0); 599 - /* enable QMU 16B checksum */ 600 - mtu3_setbits(mbase, U3D_QCR0, QMU_CS16B_EN); 601 595 /* vbus detected by HW */ 602 596 mtu3_clrbits(mbase, U3D_MISC_CTRL, VBUS_FRC_EN | VBUS_ON); 597 + /* enable automatical HWRW from L1 */ 598 + mtu3_setbits(mbase, U3D_POWER_MANAGEMENT, LPM_HRWE); 603 599 } 604 600 605 601 static irqreturn_t mtu3_link_isr(struct mtu3 *mtu) ··· 711 707 712 708 if (u2comm & RESET_INTR) 713 709 mtu3_gadget_reset(mtu); 714 - 715 - if (u2comm & LPM_RESUME_INTR) { 716 - if (!(mtu3_readl(mbase, U3D_POWER_MANAGEMENT) & LPM_HRWE)) 717 - mtu3_setbits(mbase, U3D_USB20_MISC_CONTROL, 718 - LPM_U3_ACK_EN); 719 - } 720 710 721 711 return IRQ_HANDLED; 722 712 }
+9 -5
drivers/usb/mtu3/mtu3_gadget_ep0.c
··· 336 336 337 337 lpc = mtu3_readl(mbase, U3D_LINK_POWER_CONTROL); 338 338 if (set) 339 - lpc |= SW_U1_ACCEPT_ENABLE; 339 + lpc |= SW_U1_REQUEST_ENABLE; 340 340 else 341 - lpc &= ~SW_U1_ACCEPT_ENABLE; 341 + lpc &= ~SW_U1_REQUEST_ENABLE; 342 342 mtu3_writel(mbase, U3D_LINK_POWER_CONTROL, lpc); 343 343 344 344 mtu->u1_enable = !!set; ··· 351 351 352 352 lpc = mtu3_readl(mbase, U3D_LINK_POWER_CONTROL); 353 353 if (set) 354 - lpc |= SW_U2_ACCEPT_ENABLE; 354 + lpc |= SW_U2_REQUEST_ENABLE; 355 355 else 356 - lpc &= ~SW_U2_ACCEPT_ENABLE; 356 + lpc &= ~SW_U2_REQUEST_ENABLE; 357 357 mtu3_writel(mbase, U3D_LINK_POWER_CONTROL, lpc); 358 358 359 359 mtu->u2_enable = !!set; ··· 692 692 mtu3_writel(mbase, U3D_EPISR, int_status); /* W1C */ 693 693 694 694 /* only handle ep0's */ 695 - if (!(int_status & EP0ISR)) 695 + if (!(int_status & (EP0ISR | SETUPENDISR))) 696 696 return IRQ_NONE; 697 + 698 + /* abort current SETUP, and process new one */ 699 + if (int_status & SETUPENDISR) 700 + mtu->ep0_state = MU3D_EP0_STATE_SETUP; 697 701 698 702 csr = mtu3_readl(mbase, U3D_EP0CSR); 699 703
+6
drivers/usb/mtu3/mtu3_hw_regs.h
··· 104 104 105 105 /* U3D_EPISR */ 106 106 #define EPRISR(x) (BIT(16) << (x)) 107 + #define SETUPENDISR BIT(16) 107 108 #define EPTISR(x) (BIT(0) << (x)) 108 109 #define EP0ISR BIT(0) 109 110 ··· 268 267 #define U3D_LTSSM_INTR_ENABLE (SSUSB_USB3_MAC_CSR_BASE + 0x013C) 269 268 #define U3D_LTSSM_INTR (SSUSB_USB3_MAC_CSR_BASE + 0x0140) 270 269 270 + #define U3D_U3U2_SWITCH_CTRL (SSUSB_USB3_MAC_CSR_BASE + 0x0170) 271 + 271 272 /*---------------- SSUSB_USB3_MAC_CSR FIELD DEFINITION ----------------*/ 272 273 273 274 /* U3D_LTSSM_CTRL */ ··· 303 300 #define COMPLIANCE_INTR BIT(2) 304 301 #define SS_DISABLE_INTR BIT(1) 305 302 #define SS_INACTIVE_INTR BIT(0) 303 + 304 + /* U3D_U3U2_SWITCH_CTRL */ 305 + #define SOFTCON_CLR_AUTO_EN BIT(0) 306 306 307 307 /*---------------- SSUSB_USB3_SYS_CSR REGISTER DEFINITION ----------------*/ 308 308
+8
drivers/usb/mtu3/mtu3_plat.c
··· 200 200 mtu3_setbits(ssusb->ippc_base, U3D_SSUSB_IP_PW_CTRL0, SSUSB_IP_SW_RST); 201 201 udelay(1); 202 202 mtu3_clrbits(ssusb->ippc_base, U3D_SSUSB_IP_PW_CTRL0, SSUSB_IP_SW_RST); 203 + 204 + /* 205 + * device ip may be powered on in firmware/BROM stage before entering 206 + * kernel stage; 207 + * power down device ip, otherwise ip-sleep will fail when working as 208 + * host only mode 209 + */ 210 + mtu3_setbits(ssusb->ippc_base, U3D_SSUSB_IP_PW_CTRL2, SSUSB_IP_DEV_PDN); 203 211 } 204 212 205 213 /* ignore the error if the clock does not exist */
+1 -27
drivers/usb/mtu3/mtu3_qmu.c
··· 154 154 memset(ring, 0, sizeof(*ring)); 155 155 } 156 156 157 - /* 158 - * calculate check sum of a gpd or bd 159 - * add "noinline" and "mb" to prevent wrong calculation 160 - */ 161 - static noinline u8 qmu_calc_checksum(u8 *data) 162 - { 163 - u8 chksum = 0; 164 - int i; 165 - 166 - data[1] = 0x0; /* set checksum to 0 */ 167 - 168 - mb(); /* ensure the gpd/bd is really up-to-date */ 169 - for (i = 0; i < QMU_CHECKSUM_LEN; i++) 170 - chksum += data[i]; 171 - 172 - /* Default: HWO=1, @flag[bit0] */ 173 - chksum += 1; 174 - 175 - return 0xFF - chksum; 176 - } 177 - 178 157 void mtu3_qmu_resume(struct mtu3_ep *mep) 179 158 { 180 159 struct mtu3 *mtu = mep->mtu; ··· 239 260 if (req->zero) 240 261 gpd->ext_flag |= GPD_EXT_FLAG_ZLP; 241 262 242 - gpd->chksum = qmu_calc_checksum((u8 *)gpd); 243 263 gpd->flag |= GPD_FLAGS_HWO; 244 264 245 265 mreq->gpd = gpd; ··· 273 295 gpd->next_gpd = cpu_to_le32(lower_32_bits(enq_dma)); 274 296 ext_addr |= GPD_EXT_NGP(upper_32_bits(enq_dma)); 275 297 gpd->rx_ext_addr = cpu_to_le16(ext_addr); 276 - gpd->chksum = qmu_calc_checksum((u8 *)gpd); 277 298 gpd->flag |= GPD_FLAGS_HWO; 278 299 279 300 mreq->gpd = gpd; ··· 300 323 /* set QMU start address */ 301 324 write_txq_start_addr(mbase, epnum, ring->dma); 302 325 mtu3_setbits(mbase, MU3D_EP_TXCR0(epnum), TX_DMAREQEN); 303 - mtu3_setbits(mbase, U3D_QCR0, QMU_TX_CS_EN(epnum)); 304 326 /* send zero length packet according to ZLP flag in GPD */ 305 327 mtu3_setbits(mbase, U3D_QCR1, QMU_TX_ZLP(epnum)); 306 328 mtu3_writel(mbase, U3D_TQERRIESR0, ··· 314 338 } else { 315 339 write_rxq_start_addr(mbase, epnum, ring->dma); 316 340 mtu3_setbits(mbase, MU3D_EP_RXCR0(epnum), RX_DMAREQEN); 317 - mtu3_setbits(mbase, U3D_QCR0, QMU_RX_CS_EN(epnum)); 318 341 /* don't expect ZLP */ 319 342 mtu3_clrbits(mbase, U3D_QCR3, QMU_RX_ZLP(epnum)); 320 343 /* move to next GPD when receive ZLP */ ··· 402 427 return; 403 428 } 404 429 405 - dev_dbg(mtu->dev, "%s send ZLP for req=%p\n", __func__, mreq); 430 + dev_dbg(mtu->dev, "%s send ZLP for req=%p\n", __func__, req); 406 431 407 432 mtu3_clrbits(mbase, MU3D_EP_TXCR0(mep->epnum), TX_DMAREQEN); 408 433 ··· 416 441 417 442 /* by pass the current GDP */ 418 443 gpd_current->flag |= GPD_FLAGS_BPS; 419 - gpd_current->chksum = qmu_calc_checksum((u8 *)gpd_current); 420 444 gpd_current->flag |= GPD_FLAGS_HWO; 421 445 422 446 /*enable DMAREQEN, switch back to QMU mode */
+16 -5
drivers/usb/musb/musb_dsps.c
··· 181 181 182 182 musb_writel(reg_base, wrp->epintr_set, epmask); 183 183 musb_writel(reg_base, wrp->coreintr_set, coremask); 184 - /* start polling for ID change in dual-role idle mode */ 185 - if (musb->xceiv->otg->state == OTG_STATE_B_IDLE && 186 - musb->port_mode == MUSB_OTG) 184 + /* 185 + * start polling for runtime PM active and idle, 186 + * and for ID change in dual-role idle mode. 187 + */ 188 + if (musb->xceiv->otg->state == OTG_STATE_B_IDLE) 187 189 dsps_mod_timer(glue, -1); 188 190 } 189 191 ··· 229 227 230 228 switch (musb->xceiv->otg->state) { 231 229 case OTG_STATE_A_WAIT_VRISE: 232 - dsps_mod_timer_optional(glue); 233 - break; 230 + if (musb->port_mode == MUSB_HOST) { 231 + musb->xceiv->otg->state = OTG_STATE_A_WAIT_BCON; 232 + dsps_mod_timer_optional(glue); 233 + break; 234 + } 235 + /* fall through */ 236 + 234 237 case OTG_STATE_A_WAIT_BCON: 235 238 /* keep VBUS on for host-only mode */ 236 239 if (musb->port_mode == MUSB_HOST) { ··· 256 249 musb->xceiv->otg->state = OTG_STATE_A_IDLE; 257 250 MUSB_HST_MODE(musb); 258 251 } 252 + 253 + if (musb->port_mode == MUSB_PERIPHERAL) 254 + skip_session = 1; 255 + 259 256 if (!(devctl & MUSB_DEVCTL_SESSION) && !skip_session) 260 257 musb_writeb(mregs, MUSB_DEVCTL, 261 258 MUSB_DEVCTL_SESSION);
+7 -20
drivers/usb/renesas_usbhs/common.c
··· 540 540 */ 541 541 static const struct of_device_id usbhs_of_match[] = { 542 542 { 543 + .compatible = "renesas,usbhs-r8a774c0", 544 + .data = (void *)USBHS_TYPE_RCAR_GEN3_WITH_PLL, 545 + }, 546 + { 543 547 .compatible = "renesas,usbhs-r8a7790", 544 548 .data = (void *)USBHS_TYPE_RCAR_GEN2, 545 549 }, ··· 845 841 return 0; 846 842 } 847 843 848 - static int usbhsc_suspend(struct device *dev) 844 + static __maybe_unused int usbhsc_suspend(struct device *dev) 849 845 { 850 846 struct usbhs_priv *priv = dev_get_drvdata(dev); 851 847 struct usbhs_mod *mod = usbhs_mod_get_current(priv); ··· 861 857 return 0; 862 858 } 863 859 864 - static int usbhsc_resume(struct device *dev) 860 + static __maybe_unused int usbhsc_resume(struct device *dev) 865 861 { 866 862 struct usbhs_priv *priv = dev_get_drvdata(dev); 867 863 struct platform_device *pdev = usbhs_priv_to_pdev(priv); ··· 878 874 return 0; 879 875 } 880 876 881 - static int usbhsc_runtime_nop(struct device *dev) 882 - { 883 - /* Runtime PM callback shared between ->runtime_suspend() 884 - * and ->runtime_resume(). Simply returns success. 885 - * 886 - * This driver re-initializes all registers after 887 - * pm_runtime_get_sync() anyway so there is no need 888 - * to save and restore registers here. 889 - */ 890 - return 0; 891 - } 892 - 893 - static const struct dev_pm_ops usbhsc_pm_ops = { 894 - .suspend = usbhsc_suspend, 895 - .resume = usbhsc_resume, 896 - .runtime_suspend = usbhsc_runtime_nop, 897 - .runtime_resume = usbhsc_runtime_nop, 898 - }; 877 + static SIMPLE_DEV_PM_OPS(usbhsc_pm_ops, usbhsc_suspend, usbhsc_resume); 899 878 900 879 static struct platform_driver renesas_usbhs_driver = { 901 880 .driver = {
+13
drivers/usb/roles/Kconfig
··· 1 + config USB_ROLE_SWITCH 2 + tristate "USB Role Switch Support" 3 + help 4 + USB Role Switch is a device that can select the USB role - host or 5 + device - for a USB port (connector). In most cases dual-role capable 6 + USB controller will also represent the switch, but on some platforms 7 + multiplexer/demultiplexer switch is used to route the data lines on 8 + the USB connector between separate USB host and device controllers. 9 + 10 + Say Y here if your USB connectors support both device and host roles. 11 + To compile the driver as module, choose M here: the module will be 12 + called roles.ko. 13 + 1 14 if USB_ROLE_SWITCH 2 15 3 16 config USB_ROLES_INTEL_XHCI
+3 -1
drivers/usb/roles/Makefile
··· 1 - obj-$(CONFIG_USB_ROLES_INTEL_XHCI) += intel-xhci-usb-role-switch.o 1 + obj-$(CONFIG_USB_ROLE_SWITCH) += roles.o 2 + roles-y := class.o 3 + obj-$(CONFIG_USB_ROLES_INTEL_XHCI) += intel-xhci-usb-role-switch.o
+17 -3
drivers/usb/serial/f81534.c
··· 45 45 #define F81534_CONFIG1_REG (0x09 + F81534_UART_BASE_ADDRESS) 46 46 47 47 #define F81534_DEF_CONF_ADDRESS_START 0x3000 48 - #define F81534_DEF_CONF_SIZE 8 48 + #define F81534_DEF_CONF_SIZE 12 49 49 50 50 #define F81534_CUSTOM_ADDRESS_START 0x2f00 51 51 #define F81534_CUSTOM_DATA_SIZE 0x10 52 52 #define F81534_CUSTOM_NO_CUSTOM_DATA 0xff 53 53 #define F81534_CUSTOM_VALID_TOKEN 0xf0 54 54 #define F81534_CONF_OFFSET 1 55 - #define F81534_CONF_GPIO_OFFSET 4 55 + #define F81534_CONF_INIT_GPIO_OFFSET 4 56 + #define F81534_CONF_WORK_GPIO_OFFSET 8 57 + #define F81534_CONF_GPIO_SHUTDOWN 7 58 + #define F81534_CONF_GPIO_RS232 1 56 59 57 60 #define F81534_MAX_DATA_BLOCK 64 58 61 #define F81534_MAX_BUS_RETRY 20 ··· 1340 1337 serial_priv = usb_get_serial_data(serial); 1341 1338 port_priv = usb_get_serial_port_data(port); 1342 1339 1343 - idx = F81534_CONF_GPIO_OFFSET + port_priv->phy_num; 1340 + idx = F81534_CONF_INIT_GPIO_OFFSET + port_priv->phy_num; 1344 1341 value = serial_priv->conf_data[idx]; 1342 + if (value >= F81534_CONF_GPIO_SHUTDOWN) { 1343 + /* 1344 + * Newer IC configure will make transceiver in shutdown mode on 1345 + * initial power on. We need enable it before using UARTs. 1346 + */ 1347 + idx = F81534_CONF_WORK_GPIO_OFFSET + port_priv->phy_num; 1348 + value = serial_priv->conf_data[idx]; 1349 + if (value >= F81534_CONF_GPIO_SHUTDOWN) 1350 + value = F81534_CONF_GPIO_RS232; 1351 + } 1352 + 1345 1353 pins = &f81534_port_out_pins[port_priv->phy_num]; 1346 1354 1347 1355 for (i = 0; i < ARRAY_SIZE(pins->pin); ++i) {
+3 -3
drivers/usb/serial/ftdi_sio.c
··· 1130 1130 { 1131 1131 unsigned short int divisor; 1132 1132 /* divisor shifted 3 bits to the left */ 1133 - int divisor3 = base / 2 / baud; 1133 + int divisor3 = DIV_ROUND_CLOSEST(base, 2 * baud); 1134 1134 if ((divisor3 & 0x7) == 7) 1135 1135 divisor3++; /* round x.7/8 up to x+1 */ 1136 1136 divisor = divisor3 >> 3; ··· 1156 1156 static const unsigned char divfrac[8] = { 0, 3, 2, 4, 1, 5, 6, 7 }; 1157 1157 u32 divisor; 1158 1158 /* divisor shifted 3 bits to the left */ 1159 - int divisor3 = base / 2 / baud; 1159 + int divisor3 = DIV_ROUND_CLOSEST(base, 2 * baud); 1160 1160 divisor = divisor3 >> 3; 1161 1161 divisor |= (u32)divfrac[divisor3 & 0x7] << 14; 1162 1162 /* Deal with special cases for highest baud rates. */ ··· 1179 1179 int divisor3; 1180 1180 1181 1181 /* hi-speed baud rate is 10-bit sampling instead of 16-bit */ 1182 - divisor3 = base * 8 / (baud * 10); 1182 + divisor3 = DIV_ROUND_CLOSEST(8 * base, 10 * baud); 1183 1183 1184 1184 divisor = divisor3 >> 3; 1185 1185 divisor |= (u32)divfrac[divisor3 & 0x7] << 14;
+25 -46
drivers/usb/serial/mos7840.c
··· 94 94 /* The native mos7840/7820 component */ 95 95 #define USB_VENDOR_ID_MOSCHIP 0x9710 96 96 #define MOSCHIP_DEVICE_ID_7840 0x7840 97 + #define MOSCHIP_DEVICE_ID_7843 0x7843 97 98 #define MOSCHIP_DEVICE_ID_7820 0x7820 98 99 #define MOSCHIP_DEVICE_ID_7810 0x7810 99 100 /* The native component can have its vendor/device id's overridden ··· 177 176 178 177 static const struct usb_device_id id_table[] = { 179 178 {USB_DEVICE(USB_VENDOR_ID_MOSCHIP, MOSCHIP_DEVICE_ID_7840)}, 179 + {USB_DEVICE(USB_VENDOR_ID_MOSCHIP, MOSCHIP_DEVICE_ID_7843)}, 180 180 {USB_DEVICE(USB_VENDOR_ID_MOSCHIP, MOSCHIP_DEVICE_ID_7820)}, 181 181 {USB_DEVICE(USB_VENDOR_ID_MOSCHIP, MOSCHIP_DEVICE_ID_7810)}, 182 182 {USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_USO9ML2_2)}, ··· 300 298 val = val & 0x00ff; 301 299 /* For the UART control registers, the application number need 302 300 to be Or'ed */ 303 - if (port->serial->num_ports == 4) { 301 + if (port->serial->num_ports == 2 && port->port_number != 0) 302 + val |= ((__u16)port->port_number + 2) << 8; 303 + else 304 304 val |= ((__u16)port->port_number + 1) << 8; 305 - } else { 306 - if (port->port_number == 0) { 307 - val |= ((__u16)port->port_number + 1) << 8; 308 - } else { 309 - val |= ((__u16)port->port_number + 2) << 8; 310 - } 311 - } 312 305 dev_dbg(&port->dev, "%s application number is %x\n", __func__, val); 313 306 return usb_control_msg(dev, usb_sndctrlpipe(dev, 0), MCS_WRREQ, 314 307 MCS_WR_RTYPE, val, reg, NULL, 0, ··· 329 332 return -ENOMEM; 330 333 331 334 /* Wval is same as application number */ 332 - if (port->serial->num_ports == 4) { 335 + if (port->serial->num_ports == 2 && port->port_number != 0) 336 + Wval = ((__u16)port->port_number + 2) << 8; 337 + else 333 338 Wval = ((__u16)port->port_number + 1) << 8; 334 - } else { 335 - if (port->port_number == 0) { 336 - Wval = ((__u16)port->port_number + 1) << 8; 337 - } else { 338 - Wval = ((__u16)port->port_number + 2) << 8; 339 - } 340 - } 341 339 dev_dbg(&port->dev, "%s application number is %x\n", __func__, Wval); 342 340 ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), MCS_RDREQ, 343 341 MCS_RD_RTYPE, Wval, reg, buf, VENDOR_READ_LENGTH, ··· 593 601 struct usb_serial *serial; 594 602 __u16 Data; 595 603 unsigned char *data; 596 - __u8 sp[5], st; 604 + __u8 sp[5]; 597 605 int i, rv = 0; 598 606 __u16 wval, wreg = 0; 599 607 int status = urb->status; ··· 636 644 sp[1] = (__u8) data[1]; 637 645 sp[2] = (__u8) data[2]; 638 646 sp[3] = (__u8) data[3]; 639 - st = (__u8) data[4]; 640 647 641 648 for (i = 0; i < serial->num_ports; i++) { 642 649 mos7840_port = mos7840_get_port_private(serial->port[i]); ··· 1291 1300 struct urb *urb; 1292 1301 /* __u16 Data; */ 1293 1302 const unsigned char *current_position = data; 1294 - unsigned char *data1; 1295 1303 1296 1304 if (mos7840_port_paranoia_check(port, __func__)) 1297 1305 return -1; ··· 1351 1361 mos7840_bulk_out_data_callback, mos7840_port); 1352 1362 } 1353 1363 1354 - data1 = urb->transfer_buffer; 1355 1364 dev_dbg(&port->dev, "bulkout endpoint is %d\n", port->bulk_out_endpointAddress); 1356 1365 1357 1366 if (mos7840_port->has_led) ··· 1581 1592 int divisor = 0; 1582 1593 int status; 1583 1594 __u16 Data; 1584 - unsigned char number; 1585 1595 __u16 clk_sel_val; 1586 1596 struct usb_serial_port *port; 1587 1597 ··· 1593 1605 1594 1606 if (mos7840_serial_paranoia_check(port->serial, __func__)) 1595 1607 return -1; 1596 - 1597 - number = mos7840_port->port->port_number; 1598 1608 1599 1609 dev_dbg(&port->dev, "%s - baud = %d\n", __func__, baudRate); 1600 1610 /* reset clk_uart_sel in spregOffset */ ··· 1683 1697 { 1684 1698 int baud; 1685 1699 unsigned cflag; 1686 - unsigned iflag; 1687 1700 __u8 lData; 1688 1701 __u8 lParity; 1689 1702 __u8 lStop; 1690 1703 int status; 1691 1704 __u16 Data; 1692 1705 struct usb_serial_port *port; 1693 - struct usb_serial *serial; 1694 1706 1695 1707 if (mos7840_port == NULL) 1696 1708 return; ··· 1701 1717 if (mos7840_serial_paranoia_check(port->serial, __func__)) 1702 1718 return; 1703 1719 1704 - serial = port->serial; 1705 - 1706 1720 if (!mos7840_port->open) { 1707 1721 dev_dbg(&port->dev, "%s - port not opened\n", __func__); 1708 1722 return; ··· 1711 1729 lParity = LCR_PAR_NONE; 1712 1730 1713 1731 cflag = tty->termios.c_cflag; 1714 - iflag = tty->termios.c_iflag; 1715 1732 1716 1733 /* Change the number of bits */ 1717 1734 switch (cflag & CSIZE) { ··· 2024 2043 int device_type; 2025 2044 2026 2045 if (product == MOSCHIP_DEVICE_ID_7810 || 2027 - product == MOSCHIP_DEVICE_ID_7820) { 2046 + product == MOSCHIP_DEVICE_ID_7820 || 2047 + product == MOSCHIP_DEVICE_ID_7843) { 2028 2048 device_type = product; 2029 2049 goto out; 2030 2050 } ··· 2059 2077 int device_type = (unsigned long)usb_get_serial_data(serial); 2060 2078 int num_ports; 2061 2079 2062 - num_ports = (device_type >> 4) & 0x000F; 2080 + if (device_type == MOSCHIP_DEVICE_ID_7843) 2081 + num_ports = 3; 2082 + else 2083 + num_ports = (device_type >> 4) & 0x000F; 2063 2084 2064 2085 /* 2065 2086 * num_ports is currently never zero as device_type is one of ··· 2117 2132 mos7840_port->SpRegOffset = 0x0; 2118 2133 mos7840_port->ControlRegOffset = 0x1; 2119 2134 mos7840_port->DcrRegOffset = 0x4; 2120 - } else if ((mos7840_port->port_num == 2) && (serial->num_ports == 4)) { 2121 - mos7840_port->SpRegOffset = 0x8; 2122 - mos7840_port->ControlRegOffset = 0x9; 2123 - mos7840_port->DcrRegOffset = 0x16; 2124 - } else if ((mos7840_port->port_num == 2) && (serial->num_ports == 2)) { 2125 - mos7840_port->SpRegOffset = 0xa; 2126 - mos7840_port->ControlRegOffset = 0xb; 2127 - mos7840_port->DcrRegOffset = 0x19; 2128 - } else if ((mos7840_port->port_num == 3) && (serial->num_ports == 4)) { 2129 - mos7840_port->SpRegOffset = 0xa; 2130 - mos7840_port->ControlRegOffset = 0xb; 2131 - mos7840_port->DcrRegOffset = 0x19; 2132 - } else if ((mos7840_port->port_num == 4) && (serial->num_ports == 4)) { 2133 - mos7840_port->SpRegOffset = 0xc; 2134 - mos7840_port->ControlRegOffset = 0xd; 2135 - mos7840_port->DcrRegOffset = 0x1c; 2135 + } else { 2136 + u8 phy_num = mos7840_port->port_num; 2137 + 2138 + /* Port 2 in the 2-port case uses registers of port 3 */ 2139 + if (serial->num_ports == 2) 2140 + phy_num = 3; 2141 + 2142 + mos7840_port->SpRegOffset = 0x8 + 2 * (phy_num - 2); 2143 + mos7840_port->ControlRegOffset = 0x9 + 2 * (phy_num - 2); 2144 + mos7840_port->DcrRegOffset = 0x16 + 3 * (phy_num - 2); 2136 2145 } 2137 2146 mos7840_dump_serial_port(port, mos7840_port); 2138 2147 mos7840_set_port_private(port, mos7840_port);
+4
drivers/usb/serial/option.c
··· 1955 1955 { USB_DEVICE_AND_INTERFACE_INFO(0x03f0, 0xa31d, 0xff, 0x06, 0x1b) }, 1956 1956 { USB_DEVICE(0x1508, 0x1001), /* Fibocom NL668 */ 1957 1957 .driver_info = RSVD(4) | RSVD(5) | RSVD(6) }, 1958 + { USB_DEVICE(0x2cb7, 0x0104), /* Fibocom NL678 series */ 1959 + .driver_info = RSVD(4) | RSVD(5) }, 1960 + { USB_DEVICE_INTERFACE_CLASS(0x2cb7, 0x0105, 0xff), /* Fibocom NL678 series */ 1961 + .driver_info = RSVD(6) }, 1958 1962 { } /* Terminating entry */ 1959 1963 }; 1960 1964 MODULE_DEVICE_TABLE(usb, option_ids);
+5
drivers/usb/serial/pl2303.c
··· 91 91 { USB_DEVICE(YCCABLE_VENDOR_ID, YCCABLE_PRODUCT_ID) }, 92 92 { USB_DEVICE(SUPERIAL_VENDOR_ID, SUPERIAL_PRODUCT_ID) }, 93 93 { USB_DEVICE(HP_VENDOR_ID, HP_LD220_PRODUCT_ID) }, 94 + { USB_DEVICE(HP_VENDOR_ID, HP_LD220TA_PRODUCT_ID) }, 94 95 { USB_DEVICE(HP_VENDOR_ID, HP_LD960_PRODUCT_ID) }, 96 + { USB_DEVICE(HP_VENDOR_ID, HP_LD960TA_PRODUCT_ID) }, 95 97 { USB_DEVICE(HP_VENDOR_ID, HP_LCM220_PRODUCT_ID) }, 96 98 { USB_DEVICE(HP_VENDOR_ID, HP_LCM960_PRODUCT_ID) }, 99 + { USB_DEVICE(HP_VENDOR_ID, HP_LM920_PRODUCT_ID) }, 100 + { USB_DEVICE(HP_VENDOR_ID, HP_LM940_PRODUCT_ID) }, 101 + { USB_DEVICE(HP_VENDOR_ID, HP_TD620_PRODUCT_ID) }, 97 102 { USB_DEVICE(CRESSI_VENDOR_ID, CRESSI_EDY_PRODUCT_ID) }, 98 103 { USB_DEVICE(ZEAGLE_VENDOR_ID, ZEAGLE_N2ITION3_PRODUCT_ID) }, 99 104 { USB_DEVICE(SONY_VENDOR_ID, SONY_QN3USB_PRODUCT_ID) },
+5
drivers/usb/serial/pl2303.h
··· 119 119 120 120 /* Hewlett-Packard POS Pole Displays */ 121 121 #define HP_VENDOR_ID 0x03f0 122 + #define HP_LM920_PRODUCT_ID 0x026b 123 + #define HP_TD620_PRODUCT_ID 0x0956 122 124 #define HP_LD960_PRODUCT_ID 0x0b39 123 125 #define HP_LCM220_PRODUCT_ID 0x3139 124 126 #define HP_LCM960_PRODUCT_ID 0x3239 125 127 #define HP_LD220_PRODUCT_ID 0x3524 128 + #define HP_LD220TA_PRODUCT_ID 0x4349 129 + #define HP_LD960TA_PRODUCT_ID 0x4439 130 + #define HP_LM940_PRODUCT_ID 0x5039 126 131 127 132 /* Cressi Edy (diving computer) PC interface */ 128 133 #define CRESSI_VENDOR_ID 0x04b8
-3
drivers/usb/serial/quatech2.c
··· 500 500 struct usb_serial *serial; 501 501 struct qt2_serial_private *serial_priv; 502 502 struct usb_serial_port *port; 503 - struct qt2_port_private *port_priv; 504 503 bool escapeflag; 505 504 unsigned char *ch; 506 505 int i; ··· 513 514 serial = urb->context; 514 515 serial_priv = usb_get_serial_data(serial); 515 516 port = serial->port[serial_priv->current_port]; 516 - port_priv = usb_get_serial_port_data(port); 517 517 518 518 for (i = 0; i < urb->actual_length; i++) { 519 519 ch = (unsigned char *)urb->transfer_buffer + i; ··· 564 566 565 567 serial_priv->current_port = newport; 566 568 port = serial->port[serial_priv->current_port]; 567 - port_priv = usb_get_serial_port_data(port); 568 569 i += 3; 569 570 escapeflag = true; 570 571 break;
+1 -1
drivers/usb/storage/ene_ub6250.c
··· 1131 1131 1132 1132 ms_lib_clear_writebuf(us); 1133 1133 1134 - return 0; 1134 + return 0; 1135 1135 } 1136 1136 1137 1137 static int ms_lib_force_setlogical_pair(struct us_data *us, u16 logblk, u16 phyblk)
+1 -1
drivers/usb/typec/tcpm/fusb302.c
··· 1765 1765 * to be set by the platform code which also registers the i2c client 1766 1766 * for the fusb302. 1767 1767 */ 1768 - if (device_property_read_string(dev, "fcs,extcon-name", &name) == 0) { 1768 + if (device_property_read_string(dev, "linux,extcon-name", &name) == 0) { 1769 1769 chip->extcon = extcon_get_extcon_dev(name); 1770 1770 if (!chip->extcon) 1771 1771 return -EPROBE_DEFER;
+37 -17
drivers/usb/typec/tcpm/tcpm.c
··· 317 317 /* Deadline in jiffies to exit src_try_wait state */ 318 318 unsigned long max_wait; 319 319 320 + /* port belongs to a self powered device */ 321 + bool self_powered; 322 + 320 323 #ifdef CONFIG_DEBUG_FS 321 324 struct dentry *dentry; 322 325 struct mutex logbuffer_lock; /* log buffer access lock */ ··· 2213 2210 unsigned int i, j, max_mw = 0, max_mv = 0; 2214 2211 unsigned int min_src_mv, max_src_mv, src_ma, src_mw; 2215 2212 unsigned int min_snk_mv, max_snk_mv; 2216 - u32 pdo; 2213 + unsigned int max_op_mv; 2214 + u32 pdo, src, snk; 2217 2215 unsigned int src_pdo = 0, snk_pdo = 0; 2218 2216 2219 2217 /* ··· 2264 2260 continue; 2265 2261 } 2266 2262 2267 - if (max_src_mv <= max_snk_mv && 2268 - min_src_mv >= min_snk_mv) { 2263 + if (min_src_mv <= max_snk_mv && 2264 + max_src_mv >= min_snk_mv) { 2265 + max_op_mv = min(max_src_mv, max_snk_mv); 2266 + src_mw = (max_op_mv * src_ma) / 1000; 2269 2267 /* Prefer higher voltages if available */ 2270 2268 if ((src_mw == max_mw && 2271 - min_src_mv > max_mv) || 2269 + max_op_mv > max_mv) || 2272 2270 src_mw > max_mw) { 2273 2271 src_pdo = i; 2274 2272 snk_pdo = j; 2275 2273 max_mw = src_mw; 2276 - max_mv = max_src_mv; 2274 + max_mv = max_op_mv; 2277 2275 } 2278 2276 } 2279 2277 } ··· 2288 2282 } 2289 2283 2290 2284 if (src_pdo) { 2291 - pdo = port->source_caps[src_pdo]; 2285 + src = port->source_caps[src_pdo]; 2286 + snk = port->snk_pdo[snk_pdo]; 2292 2287 2293 - port->pps_data.min_volt = pdo_pps_apdo_min_voltage(pdo); 2294 - port->pps_data.max_volt = pdo_pps_apdo_max_voltage(pdo); 2295 - port->pps_data.max_curr = 2296 - min_pps_apdo_current(pdo, port->snk_pdo[snk_pdo]); 2297 - port->pps_data.out_volt = 2298 - min(pdo_pps_apdo_max_voltage(pdo), port->pps_data.out_volt); 2299 - port->pps_data.op_curr = 2300 - min(port->pps_data.max_curr, port->pps_data.op_curr); 2288 + port->pps_data.min_volt = max(pdo_pps_apdo_min_voltage(src), 2289 + pdo_pps_apdo_min_voltage(snk)); 2290 + port->pps_data.max_volt = min(pdo_pps_apdo_max_voltage(src), 2291 + pdo_pps_apdo_max_voltage(snk)); 2292 + port->pps_data.max_curr = min_pps_apdo_current(src, snk); 2293 + port->pps_data.out_volt = min(port->pps_data.max_volt, 2294 + port->pps_data.out_volt); 2295 + port->pps_data.op_curr = min(port->pps_data.max_curr, 2296 + port->pps_data.op_curr); 2301 2297 } 2302 2298 2303 2299 return src_pdo; ··· 3262 3254 case SRC_HARD_RESET_VBUS_OFF: 3263 3255 tcpm_set_vconn(port, true); 3264 3256 tcpm_set_vbus(port, false); 3265 - tcpm_set_roles(port, false, TYPEC_SOURCE, TYPEC_HOST); 3257 + tcpm_set_roles(port, port->self_powered, TYPEC_SOURCE, 3258 + TYPEC_HOST); 3266 3259 tcpm_set_state(port, SRC_HARD_RESET_VBUS_ON, PD_T_SRC_RECOVER); 3267 3260 break; 3268 3261 case SRC_HARD_RESET_VBUS_ON: ··· 3275 3266 case SNK_HARD_RESET_SINK_OFF: 3276 3267 memset(&port->pps_data, 0, sizeof(port->pps_data)); 3277 3268 tcpm_set_vconn(port, false); 3278 - tcpm_set_charge(port, false); 3279 - tcpm_set_roles(port, false, TYPEC_SINK, TYPEC_DEVICE); 3269 + if (port->pd_capable) 3270 + tcpm_set_charge(port, false); 3271 + tcpm_set_roles(port, port->self_powered, TYPEC_SINK, 3272 + TYPEC_DEVICE); 3280 3273 /* 3281 3274 * VBUS may or may not toggle, depending on the adapter. 3282 3275 * If it doesn't toggle, transition to SNK_HARD_RESET_SINK_ON ··· 3308 3297 * Similar, dual-mode ports in source mode should transition 3309 3298 * to PE_SNK_Transition_to_default. 3310 3299 */ 3300 + if (port->pd_capable) { 3301 + tcpm_set_current_limit(port, 3302 + tcpm_get_current_limit(port), 3303 + 5000); 3304 + tcpm_set_charge(port, true); 3305 + } 3311 3306 tcpm_set_attached_state(port, true); 3312 3307 tcpm_set_state(port, SNK_STARTUP, 0); 3313 3308 break; ··· 4429 4412 return -EINVAL; 4430 4413 port->operating_snk_mw = mw / 1000; 4431 4414 4415 + port->self_powered = fwnode_property_read_bool(fwnode, "self-powered"); 4416 + 4432 4417 return 0; 4433 4418 } 4434 4419 ··· 4739 4720 port->typec_caps.prefer_role = tcfg->default_role; 4740 4721 port->typec_caps.type = tcfg->type; 4741 4722 port->typec_caps.data = tcfg->data; 4723 + port->self_powered = port->tcpc->config->self_powered; 4742 4724 4743 4725 return 0; 4744 4726 }
+1 -1
drivers/uwb/i1480/dfu/usb.c
··· 309 309 if (result < 0) { 310 310 dev_err(dev, "%s: cannot submit NEEP read: %d\n", 311 311 cmd_name, result); 312 - goto error_submit_ep1; 312 + goto error_submit_ep1; 313 313 } 314 314 /* Now post the command on EP0 */ 315 315 result = usb_control_msg(
+285
include/linux/phy/phy-mipi-dphy.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + /* 3 + * Copyright (C) 2018 Cadence Design Systems Inc. 4 + */ 5 + 6 + #ifndef __PHY_MIPI_DPHY_H_ 7 + #define __PHY_MIPI_DPHY_H_ 8 + 9 + #include <video/videomode.h> 10 + 11 + /** 12 + * struct phy_configure_opts_mipi_dphy - MIPI D-PHY configuration set 13 + * 14 + * This structure is used to represent the configuration state of a 15 + * MIPI D-PHY phy. 16 + */ 17 + struct phy_configure_opts_mipi_dphy { 18 + /** 19 + * @clk_miss: 20 + * 21 + * Timeout, in picoseconds, for receiver to detect absence of 22 + * Clock transitions and disable the Clock Lane HS-RX. 23 + * 24 + * Maximum value: 60000 ps 25 + */ 26 + unsigned int clk_miss; 27 + 28 + /** 29 + * @clk_post: 30 + * 31 + * Time, in picoseconds, that the transmitter continues to 32 + * send HS clock after the last associated Data Lane has 33 + * transitioned to LP Mode. Interval is defined as the period 34 + * from the end of @hs_trail to the beginning of @clk_trail. 35 + * 36 + * Minimum value: 60000 ps + 52 * @hs_clk_rate period in ps 37 + */ 38 + unsigned int clk_post; 39 + 40 + /** 41 + * @clk_pre: 42 + * 43 + * Time, in UI, that the HS clock shall be driven by 44 + * the transmitter prior to any associated Data Lane beginning 45 + * the transition from LP to HS mode. 46 + * 47 + * Minimum value: 8 UI 48 + */ 49 + unsigned int clk_pre; 50 + 51 + /** 52 + * @clk_prepare: 53 + * 54 + * Time, in picoseconds, that the transmitter drives the Clock 55 + * Lane LP-00 Line state immediately before the HS-0 Line 56 + * state starting the HS transmission. 57 + * 58 + * Minimum value: 38000 ps 59 + * Maximum value: 95000 ps 60 + */ 61 + unsigned int clk_prepare; 62 + 63 + /** 64 + * @clk_settle: 65 + * 66 + * Time interval, in picoseconds, during which the HS receiver 67 + * should ignore any Clock Lane HS transitions, starting from 68 + * the beginning of @clk_prepare. 69 + * 70 + * Minimum value: 95000 ps 71 + * Maximum value: 300000 ps 72 + */ 73 + unsigned int clk_settle; 74 + 75 + /** 76 + * @clk_term_en: 77 + * 78 + * Time, in picoseconds, for the Clock Lane receiver to enable 79 + * the HS line termination. 80 + * 81 + * Maximum value: 38000 ps 82 + */ 83 + unsigned int clk_term_en; 84 + 85 + /** 86 + * @clk_trail: 87 + * 88 + * Time, in picoseconds, that the transmitter drives the HS-0 89 + * state after the last payload clock bit of a HS transmission 90 + * burst. 91 + * 92 + * Minimum value: 60000 ps 93 + */ 94 + unsigned int clk_trail; 95 + 96 + /** 97 + * @clk_zero: 98 + * 99 + * Time, in picoseconds, that the transmitter drives the HS-0 100 + * state prior to starting the Clock. 101 + */ 102 + unsigned int clk_zero; 103 + 104 + /** 105 + * @d_term_en: 106 + * 107 + * Time, in picoseconds, for the Data Lane receiver to enable 108 + * the HS line termination. 109 + * 110 + * Maximum value: 35000 ps + 4 * @hs_clk_rate period in ps 111 + */ 112 + unsigned int d_term_en; 113 + 114 + /** 115 + * @eot: 116 + * 117 + * Transmitted time interval, in picoseconds, from the start 118 + * of @hs_trail or @clk_trail, to the start of the LP- 11 119 + * state following a HS burst. 120 + * 121 + * Maximum value: 105000 ps + 12 * @hs_clk_rate period in ps 122 + */ 123 + unsigned int eot; 124 + 125 + /** 126 + * @hs_exit: 127 + * 128 + * Time, in picoseconds, that the transmitter drives LP-11 129 + * following a HS burst. 130 + * 131 + * Minimum value: 100000 ps 132 + */ 133 + unsigned int hs_exit; 134 + 135 + /** 136 + * @hs_prepare: 137 + * 138 + * Time, in picoseconds, that the transmitter drives the Data 139 + * Lane LP-00 Line state immediately before the HS-0 Line 140 + * state starting the HS transmission. 141 + * 142 + * Minimum value: 40000 ps + 4 * @hs_clk_rate period in ps 143 + * Maximum value: 85000 ps + 6 * @hs_clk_rate period in ps 144 + */ 145 + unsigned int hs_prepare; 146 + 147 + /** 148 + * @hs_settle: 149 + * 150 + * Time interval, in picoseconds, during which the HS receiver 151 + * shall ignore any Data Lane HS transitions, starting from 152 + * the beginning of @hs_prepare. 153 + * 154 + * Minimum value: 85000 ps + 6 * @hs_clk_rate period in ps 155 + * Maximum value: 145000 ps + 10 * @hs_clk_rate period in ps 156 + */ 157 + unsigned int hs_settle; 158 + 159 + /** 160 + * @hs_skip: 161 + * 162 + * Time interval, in picoseconds, during which the HS-RX 163 + * should ignore any transitions on the Data Lane, following a 164 + * HS burst. The end point of the interval is defined as the 165 + * beginning of the LP-11 state following the HS burst. 166 + * 167 + * Minimum value: 40000 ps 168 + * Maximum value: 55000 ps + 4 * @hs_clk_rate period in ps 169 + */ 170 + unsigned int hs_skip; 171 + 172 + /** 173 + * @hs_trail: 174 + * 175 + * Time, in picoseconds, that the transmitter drives the 176 + * flipped differential state after last payload data bit of a 177 + * HS transmission burst 178 + * 179 + * Minimum value: max(8 * @hs_clk_rate period in ps, 180 + * 60000 ps + 4 * @hs_clk_rate period in ps) 181 + */ 182 + unsigned int hs_trail; 183 + 184 + /** 185 + * @hs_zero: 186 + * 187 + * Time, in picoseconds, that the transmitter drives the HS-0 188 + * state prior to transmitting the Sync sequence. 189 + */ 190 + unsigned int hs_zero; 191 + 192 + /** 193 + * @init: 194 + * 195 + * Time, in picoseconds for the initialization period to 196 + * complete. 197 + * 198 + * Minimum value: 100000000 ps 199 + */ 200 + unsigned int init; 201 + 202 + /** 203 + * @lpx: 204 + * 205 + * Transmitted length, in picoseconds, of any Low-Power state 206 + * period. 207 + * 208 + * Minimum value: 50000 ps 209 + */ 210 + unsigned int lpx; 211 + 212 + /** 213 + * @ta_get: 214 + * 215 + * Time, in picoseconds, that the new transmitter drives the 216 + * Bridge state (LP-00) after accepting control during a Link 217 + * Turnaround. 218 + * 219 + * Value: 5 * @lpx 220 + */ 221 + unsigned int ta_get; 222 + 223 + /** 224 + * @ta_go: 225 + * 226 + * Time, in picoseconds, that the transmitter drives the 227 + * Bridge state (LP-00) before releasing control during a Link 228 + * Turnaround. 229 + * 230 + * Value: 4 * @lpx 231 + */ 232 + unsigned int ta_go; 233 + 234 + /** 235 + * @ta_sure: 236 + * 237 + * Time, in picoseconds, that the new transmitter waits after 238 + * the LP-10 state before transmitting the Bridge state 239 + * (LP-00) during a Link Turnaround. 240 + * 241 + * Minimum value: @lpx 242 + * Maximum value: 2 * @lpx 243 + */ 244 + unsigned int ta_sure; 245 + 246 + /** 247 + * @wakeup: 248 + * 249 + * Time, in picoseconds, that a transmitter drives a Mark-1 250 + * state prior to a Stop state in order to initiate an exit 251 + * from ULPS. 252 + * 253 + * Minimum value: 1000000000 ps 254 + */ 255 + unsigned int wakeup; 256 + 257 + /** 258 + * @hs_clk_rate: 259 + * 260 + * Clock rate, in Hertz, of the high-speed clock. 261 + */ 262 + unsigned long hs_clk_rate; 263 + 264 + /** 265 + * @lp_clk_rate: 266 + * 267 + * Clock rate, in Hertz, of the low-power clock. 268 + */ 269 + unsigned long lp_clk_rate; 270 + 271 + /** 272 + * @lanes: 273 + * 274 + * Number of active data lanes used for the transmissions. 275 + */ 276 + unsigned char lanes; 277 + }; 278 + 279 + int phy_mipi_dphy_get_default_config(unsigned long pixel_clock, 280 + unsigned int bpp, 281 + unsigned int lanes, 282 + struct phy_configure_opts_mipi_dphy *cfg); 283 + int phy_mipi_dphy_config_validate(struct phy_configure_opts_mipi_dphy *cfg); 284 + 285 + #endif /* __PHY_MIPI_DPHY_H_ */
+76 -7
include/linux/phy/phy.h
··· 20 20 #include <linux/pm_runtime.h> 21 21 #include <linux/regulator/consumer.h> 22 22 23 + #include <linux/phy/phy-mipi-dphy.h> 24 + 23 25 struct phy; 24 26 25 27 enum phy_mode { ··· 37 35 PHY_MODE_USB_DEVICE_HS, 38 36 PHY_MODE_USB_DEVICE_SS, 39 37 PHY_MODE_USB_OTG, 40 - PHY_MODE_SGMII, 41 - PHY_MODE_2500SGMII, 42 - PHY_MODE_QSGMII, 43 - PHY_MODE_10GKR, 44 38 PHY_MODE_UFS_HS_A, 45 39 PHY_MODE_UFS_HS_B, 46 40 PHY_MODE_PCIE, 41 + PHY_MODE_ETHERNET, 42 + PHY_MODE_MIPI_DPHY, 43 + }; 44 + 45 + /** 46 + * union phy_configure_opts - Opaque generic phy configuration 47 + * 48 + * @mipi_dphy: Configuration set applicable for phys supporting 49 + * the MIPI_DPHY phy mode. 50 + */ 51 + union phy_configure_opts { 52 + struct phy_configure_opts_mipi_dphy mipi_dphy; 47 53 }; 48 54 49 55 /** ··· 70 60 int (*exit)(struct phy *phy); 71 61 int (*power_on)(struct phy *phy); 72 62 int (*power_off)(struct phy *phy); 73 - int (*set_mode)(struct phy *phy, enum phy_mode mode); 63 + int (*set_mode)(struct phy *phy, enum phy_mode mode, int submode); 64 + 65 + /** 66 + * @configure: 67 + * 68 + * Optional. 69 + * 70 + * Used to change the PHY parameters. phy_init() must have 71 + * been called on the phy. 72 + * 73 + * Returns: 0 if successful, an negative error code otherwise 74 + */ 75 + int (*configure)(struct phy *phy, union phy_configure_opts *opts); 76 + 77 + /** 78 + * @validate: 79 + * 80 + * Optional. 81 + * 82 + * Used to check that the current set of parameters can be 83 + * handled by the phy. Implementations are free to tune the 84 + * parameters passed as arguments if needed by some 85 + * implementation detail or constraints. It must not change 86 + * any actual configuration of the PHY, so calling it as many 87 + * times as deemed fit by the consumer must have no side 88 + * effect. 89 + * 90 + * Returns: 0 if the configuration can be applied, an negative 91 + * error code otherwise 92 + */ 93 + int (*validate)(struct phy *phy, enum phy_mode mode, int submode, 94 + union phy_configure_opts *opts); 74 95 int (*reset)(struct phy *phy); 75 96 int (*calibrate)(struct phy *phy); 76 97 struct module *owner; ··· 205 164 int phy_exit(struct phy *phy); 206 165 int phy_power_on(struct phy *phy); 207 166 int phy_power_off(struct phy *phy); 208 - int phy_set_mode(struct phy *phy, enum phy_mode mode); 167 + int phy_set_mode_ext(struct phy *phy, enum phy_mode mode, int submode); 168 + #define phy_set_mode(phy, mode) \ 169 + phy_set_mode_ext(phy, mode, 0) 170 + int phy_configure(struct phy *phy, union phy_configure_opts *opts); 171 + int phy_validate(struct phy *phy, enum phy_mode mode, int submode, 172 + union phy_configure_opts *opts); 173 + 209 174 static inline enum phy_mode phy_get_mode(struct phy *phy) 210 175 { 211 176 return phy->attrs.mode; ··· 325 278 return -ENOSYS; 326 279 } 327 280 328 - static inline int phy_set_mode(struct phy *phy, enum phy_mode mode) 281 + static inline int phy_set_mode_ext(struct phy *phy, enum phy_mode mode, 282 + int submode) 329 283 { 330 284 if (!phy) 331 285 return 0; 332 286 return -ENOSYS; 333 287 } 288 + 289 + #define phy_set_mode(phy, mode) \ 290 + phy_set_mode_ext(phy, mode, 0) 334 291 335 292 static inline enum phy_mode phy_get_mode(struct phy *phy) 336 293 { ··· 352 301 { 353 302 if (!phy) 354 303 return 0; 304 + return -ENOSYS; 305 + } 306 + 307 + static inline int phy_configure(struct phy *phy, 308 + union phy_configure_opts *opts) 309 + { 310 + if (!phy) 311 + return 0; 312 + 313 + return -ENOSYS; 314 + } 315 + 316 + static inline int phy_validate(struct phy *phy, enum phy_mode mode, int submode, 317 + union phy_configure_opts *opts) 318 + { 319 + if (!phy) 320 + return 0; 321 + 355 322 return -ENOSYS; 356 323 } 357 324
+51
include/linux/usb/ccid.h
··· 1 + /* 2 + * Copyright (c) 2018 Vincent Pelletier 3 + */ 4 + /* 5 + * This program is free software; you can redistribute it and/or modify 6 + * it under the terms of the GNU General Public License as published by 7 + * the Free Software Foundation; either version 2 of the License, or 8 + * (at your option) any later version. 9 + * 10 + * This program is distributed in the hope that it will be useful, 11 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 + * GNU General Public License for more details. 14 + * 15 + * You should have received a copy of the GNU General Public License 16 + * along with this program; if not, write to the Free Software 17 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 + */ 19 + #ifndef __CCID_H 20 + #define __CCID_H 21 + 22 + #include <linux/types.h> 23 + 24 + #define USB_INTERFACE_CLASS_CCID 0x0b 25 + 26 + struct ccid_descriptor { 27 + __u8 bLength; 28 + __u8 bDescriptorType; 29 + __le16 bcdCCID; 30 + __u8 bMaxSlotIndex; 31 + __u8 bVoltageSupport; 32 + __le32 dwProtocols; 33 + __le32 dwDefaultClock; 34 + __le32 dwMaximumClock; 35 + __u8 bNumClockSupported; 36 + __le32 dwDataRate; 37 + __le32 dwMaxDataRate; 38 + __u8 bNumDataRatesSupported; 39 + __le32 dwMaxIFSD; 40 + __le32 dwSynchProtocols; 41 + __le32 dwMechanical; 42 + __le32 dwFeatures; 43 + __le32 dwMaxCCIDMessageLength; 44 + __u8 bClassGetResponse; 45 + __u8 bClassEnvelope; 46 + __le16 wLcdLayout; 47 + __u8 bPINSupport; 48 + __u8 bMaxCCIDBusySlots; 49 + } __attribute__ ((packed)); 50 + 51 + #endif /* __CCID_H */
+3
include/linux/usb/chipidea.h
··· 60 60 #define CI_HDRC_OVERRIDE_RX_BURST BIT(11) 61 61 #define CI_HDRC_OVERRIDE_PHY_CONTROL BIT(12) /* Glue layer manages phy */ 62 62 #define CI_HDRC_REQUIRES_ALIGNED_DMA BIT(13) 63 + #define CI_HDRC_IMX_IS_HSIC BIT(14) 63 64 enum usb_dr_mode dr_mode; 64 65 #define CI_HDRC_CONTROLLER_RESET_EVENT 0 65 66 #define CI_HDRC_CONTROLLER_STOPPED_EVENT 1 67 + #define CI_HDRC_IMX_HSIC_ACTIVE_EVENT 2 68 + #define CI_HDRC_IMX_HSIC_SUSPEND_EVENT 3 66 69 int (*notify_event) (struct ci_hdrc *ci, unsigned event); 67 70 struct regulator *reg_vbus; 68 71 struct usb_otg_caps ci_otg_caps;
+4
include/linux/usb/gadget.h
··· 61 61 * invalidated by the error may first be dequeued. 62 62 * @context: For use by the completion callback 63 63 * @list: For use by the gadget driver. 64 + * @frame_number: Reports the interval number in (micro)frame in which the 65 + * isochronous transfer was transmitted or received. 64 66 * @status: Reports completion code, zero or a negative errno. 65 67 * Normally, faults block the transfer queue from advancing until 66 68 * the completion callback returns. ··· 113 111 struct usb_request *req); 114 112 void *context; 115 113 struct list_head list; 114 + 115 + unsigned frame_number; /* ISO ONLY */ 116 116 117 117 int status; 118 118 unsigned actual;
-5
include/linux/usb/hcd.h
··· 235 235 return container_of(bus, struct usb_hcd, self); 236 236 } 237 237 238 - struct hcd_timeout { /* timeouts we allocate */ 239 - struct list_head timeout_list; 240 - struct timer_list timer; 241 - }; 242 - 243 238 /*-------------------------------------------------------------------------*/ 244 239 245 240
+1
include/linux/usb/tcpm.h
··· 89 89 enum typec_port_data data; 90 90 enum typec_role default_role; 91 91 bool try_role_hw; /* try.{src,snk} implemented in hardware */ 92 + bool self_powered; /* port belongs to a self powered device */ 92 93 93 94 const struct typec_altmode_desc *alt_modes; 94 95 };