History

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

Pull USB/PHY updates from Greg KH: "Here is the big USB/PHY driver pull request for 5.1-rc1. The usual set of gadget driver updates, phy driver updates, xhci updates, and typec additions. Also included in here are a lot of small cleanups and fixes and driver updates where needed. All of these have been in linux-next for a while with no reported issues" * tag 'usb-5.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (167 commits) wusb: Remove unnecessary static function ckhdid_printf usb: core: make default autosuspend delay configurable usb: core: Fix typo in description of "authorized_default" usb: chipidea: Refactor USB PHY selection and keep a single PHY usb: chipidea: Grab the (legacy) USB PHY by phandle first usb: chipidea: imx: set power polarity dt-bindings: usb: ci-hdrc-usb2: add property power-active-high usb: chipidea: imx: remove unused header files usb: chipidea: tegra: Fix missed ci_hdrc_remove_device() usb: core: add option of only authorizing internal devices usb: typec: tps6598x: handle block writes separately with plain-I2C adapters usb: xhci: Fix for Enabling USB ROLE SWITCH QUIRK on INTEL_SUNRISEPOINT_LP_XHCI usb: xhci: fix build warning - missing prototype usb: xhci: dbc: Fixing typo error. usb: xhci: remove unused member 'parent' in xhci_regset struct xhci: tegra: Prevent error pointer dereference USB: serial: option: add Telit ME910 ECM composition usb: core: Replace hardcoded check with inline function from usb.h usb: core: skip interfaces disabled in devicetree usb: typec: mux: remove redundant check on variable match ...

Linus Torvalds committed 7 years ago

Commit f90d6442 parents 67e79a6 1c7cf3d203 files · +2951 −1110Browse files

Unified · Split

203 files
  1. Documentation/ABI/testing/sysfs-bus-usb +1 −1
  2. Documentation/admin-guide/kernel-parameters.txt +2 −1
  3. Documentation/devicetree/bindings/arm/atmel-sysregs.txt +1 −0
  4. Documentation/devicetree/bindings/display/bridge/cdns,dsi.txt +0 −21
  5. Documentation/devicetree/bindings/phy/cdns,dphy.txt +20 −0
  6. Documentation/devicetree/bindings/phy/phy-mvebu-comphy.txt +53 −12
  7. Documentation/devicetree/bindings/phy/phy-mvebu-utmi.txt +38 −0
  8. Documentation/devicetree/bindings/phy/phy-rockchip-inno-usb2.txt +2 −0
  9. Documentation/devicetree/bindings/phy/qcom-qmp-phy.txt +9 −0
  10. Documentation/devicetree/bindings/phy/qcom-qusb2-phy.txt +1 −0
  11. Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb2.txt +2 −0
  12. Documentation/devicetree/bindings/phy/ti-phy.txt +1 −0
  13. Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt +1 −0
  14. Documentation/devicetree/bindings/usb/ingenic,jz4740-musb.txt +24 −0
  15. Documentation/devicetree/bindings/usb/keystone-usb.txt +4 −2
  16. Documentation/devicetree/bindings/usb/qcom,dwc3.txt +1 −0
  17. Documentation/devicetree/bindings/usb/renesas_usb3.txt +1 −0
  18. Documentation/devicetree/bindings/usb/renesas_usbhs.txt +1 −0
  19. Documentation/devicetree/bindings/usb/usb251xb.txt +4 −0
  20. Documentation/usb/authorization.txt +3 −1
  21. MAINTAINERS +8 −0
  22. drivers/base/devcon.c +59 −3
  23. drivers/phy/broadcom/phy-bcm-sr-pcie.c +2 −2
  24. drivers/phy/cadence/Kconfig +12 −1
  25. drivers/phy/cadence/Makefile +1 −0
  26. drivers/phy/cadence/cdns-dphy.c +391 −0
  27. drivers/phy/freescale/Kconfig +1 −1
  28. drivers/phy/marvell/Kconfig +21 −0
  29. drivers/phy/marvell/Makefile +2 −0
  30. drivers/phy/marvell/phy-armada375-usb2.c +2 −11
  31. drivers/phy/marvell/phy-mvebu-a3700-comphy.c +318 −0
  32. drivers/phy/marvell/phy-mvebu-a3700-utmi.c +278 −0
  33. drivers/phy/marvell/phy-mvebu-cp110-comphy.c +0 −2
  34. drivers/phy/marvell/phy-mvebu-sata.c +2 −7
  35. drivers/phy/phy-core-mipi-dphy.c +4 −4
  36. drivers/phy/phy-core.c +1 −11
  37. drivers/phy/qualcomm/phy-qcom-qmp.c +143 −0
  38. drivers/phy/qualcomm/phy-qcom-qmp.h +4 −0
  39. drivers/phy/qualcomm/phy-qcom-qusb2.c +40 −0
  40. drivers/phy/qualcomm/phy-qcom-ufs-i.h +1 −18
  41. drivers/phy/rockchip/phy-rockchip-inno-usb2.c +20 −28
  42. drivers/phy/ti/Kconfig +2 −4
  43. drivers/phy/ti/phy-omap-usb2.c +64 −41
  44. drivers/platform/x86/intel_cht_int33fe.c +6 −9
  45. drivers/usb/Kconfig +1 −0
  46. drivers/usb/README +0 −54
  47. drivers/usb/atm/Kconfig +1 −0
  48. drivers/usb/chipidea/Kconfig +2 −0
  49. drivers/usb/chipidea/ci_hdrc_imx.c +2 −4
  50. drivers/usb/chipidea/ci_hdrc_imx.h +1 −0
  51. drivers/usb/chipidea/ci_hdrc_tegra.c +1 −0
  52. drivers/usb/chipidea/core.c +34 −12
  53. drivers/usb/chipidea/usbmisc_imx.c +7 −0
  54. drivers/usb/class/Kconfig +1 −0
  55. drivers/usb/class/cdc-wdm.c +1 −1
  56. drivers/usb/core/Kconfig +13 −0
  57. drivers/usb/core/config.c +5 −9
  58. drivers/usb/core/devio.c +4 −6
  59. drivers/usb/core/driver.c +19 −4
  60. drivers/usb/core/generic.c +25 −19
  61. drivers/usb/core/hcd.c +36 −20
  62. drivers/usb/core/hub.c +50 −16
  63. drivers/usb/core/hub.h +2 −0
  64. drivers/usb/core/message.c +8 −2
  65. drivers/usb/core/phy.c +28 −0
  66. drivers/usb/core/phy.h +2 −0
  67. drivers/usb/core/sysfs.c +4 −1
  68. drivers/usb/core/urb.c +2 −3
  69. drivers/usb/core/usb.c +28 −9
  70. drivers/usb/core/usb.h +8 −2
  71. drivers/usb/dwc2/Kconfig +2 −0
  72. drivers/usb/dwc2/gadget.c +78 −36
  73. drivers/usb/dwc2/hcd.c +1 −3
  74. drivers/usb/dwc3/Kconfig +5 −3
  75. drivers/usb/dwc3/core.h +9 −3
  76. drivers/usb/dwc3/debug.h +85 −71
  77. drivers/usb/dwc3/drd.c +7 −2
  78. drivers/usb/dwc3/dwc3-haps.c +9 −0
  79. drivers/usb/dwc3/dwc3-keystone.c +10 −1
  80. drivers/usb/dwc3/dwc3-qcom.c +1 −0
  81. drivers/usb/dwc3/gadget.c +34 −31
  82. drivers/usb/dwc3/gadget.h +2 −2
  83. drivers/usb/dwc3/trace.h +5 −5
  84. drivers/usb/gadget/Kconfig +1 −0
  85. drivers/usb/gadget/epautoconf.c +24 −17
  86. drivers/usb/gadget/function/f_fs.c +12 −0
  87. drivers/usb/gadget/function/f_uac1.c +6 −4
  88. drivers/usb/gadget/function/u_ecm.h +1 −1
  89. drivers/usb/gadget/function/u_eem.h +1 −1
  90. drivers/usb/gadget/function/u_ether_configfs.h +1 −1
  91. drivers/usb/gadget/function/u_fs.h +1 −1
  92. drivers/usb/gadget/function/u_gether.h +1 −1
  93. drivers/usb/gadget/function/u_hid.h +1 −1
  94. drivers/usb/gadget/function/u_midi.h +1 −1
  95. drivers/usb/gadget/function/u_ncm.h +1 −1
  96. drivers/usb/gadget/function/u_printer.h +1 −1
  97. drivers/usb/gadget/function/u_rndis.h +1 −1
  98. drivers/usb/gadget/function/u_serial.c +14 −21
  99. drivers/usb/gadget/function/u_uac2.h +1 −1
  100. drivers/usb/gadget/function/u_uvc.h +1 −1
  101. drivers/usb/gadget/function/uvc.h +2 −0
  102. drivers/usb/gadget/function/uvc_configfs.c +1 −9
  103. drivers/usb/gadget/function/uvc_configfs.h +1 −1
  104. drivers/usb/gadget/function/uvc_v4l2.h +1 −1
  105. drivers/usb/gadget/function/uvc_video.h +1 −1
  106. drivers/usb/gadget/legacy/Kconfig +1 −0
  107. drivers/usb/gadget/legacy/inode.c +20 −20
  108. drivers/usb/gadget/u_f.c +1 −1
  109. drivers/usb/gadget/u_f.h +1 −1
  110. drivers/usb/gadget/u_os_desc.h +1 −1
  111. drivers/usb/gadget/udc/Kconfig +1 −0
  112. drivers/usb/gadget/udc/aspeed-vhub/epn.c +1 −1
  113. drivers/usb/gadget/udc/aspeed-vhub/hub.c +1 −1
  114. drivers/usb/gadget/udc/bdc/Kconfig +2 −0
  115. drivers/usb/gadget/udc/bdc/bdc_cmd.c +2 −2
  116. drivers/usb/gadget/udc/core.c +4 −4
  117. drivers/usb/gadget/udc/fotg210-udc.c +4 −7
  118. drivers/usb/gadget/udc/net2280.c +3 −3
  119. drivers/usb/gadget/udc/renesas_usb3.c +4 −0
  120. drivers/usb/gadget/udc/snps_udc_core.c +8 −9
  121. drivers/usb/host/Kconfig +4 −4
  122. drivers/usb/host/ehci-fsl.c +42 −27
  123. drivers/usb/host/ehci-orion.c +21 −23
  124. drivers/usb/host/fsl-mph-dr-of.c +6 −0
  125. drivers/usb/host/ohci-at91.c +5 −2
  126. drivers/usb/host/oxu210hp-hcd.c +2 −8
  127. drivers/usb/host/u132-hcd.c +4 −2
  128. drivers/usb/host/whci/Makefile +2 −0
  129. drivers/usb/host/xhci-dbgcap.c +3 −3
  130. drivers/usb/host/xhci-debugfs.h +0 −1
  131. drivers/usb/host/xhci-mem.c +1 −1
  132. drivers/usb/host/xhci-mvebu.c +11 −0
  133. drivers/usb/host/xhci-mvebu.h +6 −0
  134. drivers/usb/host/xhci-pci.c +1 −0
  135. drivers/usb/host/xhci-plat.c +7 −0
  136. drivers/usb/host/xhci-tegra.c +2 −2
  137. drivers/usb/host/xhci.c +1 −2
  138. drivers/usb/image/Kconfig +1 −0
  139. drivers/usb/isp1760/Kconfig +2 −0
  140. drivers/usb/misc/Kconfig +1 −0
  141. drivers/usb/misc/ftdi-elan.c +0 −26
  142. drivers/usb/misc/sisusbvga/Kconfig +1 −0
  143. drivers/usb/misc/sisusbvga/Makefile +2 −1
  144. drivers/usb/misc/sisusbvga/sisusb.c +16 −16
  145. drivers/usb/misc/sisusbvga/sisusb.h +1 −14
  146. drivers/usb/misc/sisusbvga/sisusb_con.c +51 −76
  147. drivers/usb/misc/sisusbvga/sisusb_init.c +0 −5
  148. drivers/usb/misc/usb251xb.c +13 −2
  149. drivers/usb/misc/usb3503.c +30 −8
  150. drivers/usb/misc/usbtest.c +24 −4
  151. drivers/usb/mon/Kconfig +1 −0
  152. drivers/usb/mtu3/Kconfig +2 −0
  153. drivers/usb/musb/Kconfig +3 −2
  154. drivers/usb/musb/jz4740.c +10 −0
  155. drivers/usb/musb/musb_host.c +2 −2
  156. drivers/usb/phy/Kconfig +1 −0
  157. drivers/usb/phy/phy-twl6030-usb.c +1 −1
  158. drivers/usb/renesas_usbhs/mod_host.c +1 −1
  159. drivers/usb/renesas_usbhs/rcar3.c +1 −1
  160. drivers/usb/renesas_usbhs/rza.c +1 −1
  161. drivers/usb/roles/Kconfig +2 −0
  162. drivers/usb/roles/Makefile +2 −0
  163. drivers/usb/roles/class.c +18 −3
  164. drivers/usb/serial/Kconfig +1 −0
  165. drivers/usb/serial/cp210x.c +111 −19
  166. drivers/usb/serial/ftdi_sio.c +2 −0
  167. drivers/usb/serial/ftdi_sio_ids.h +6 −0
  168. drivers/usb/serial/option.c +2 −0
  169. drivers/usb/storage/Kconfig +1 −0
  170. drivers/usb/storage/karma.c +2 −0
  171. drivers/usb/typec/Kconfig +1 −0
  172. drivers/usb/typec/altmodes/Kconfig +1 −0
  173. drivers/usb/typec/altmodes/Makefile +2 −0
  174. drivers/usb/typec/altmodes/displayport.c +0 −4
  175. drivers/usb/typec/class.c +24 −9
  176. drivers/usb/typec/mux.c +79 −15
  177. drivers/usb/typec/mux/Kconfig +2 −0
  178. drivers/usb/typec/tcpm/Kconfig +2 −0
  179. drivers/usb/typec/tcpm/tcpm.c +5 −63
  180. drivers/usb/typec/tps6598x.c +69 −10
  181. drivers/usb/typec/ucsi/Kconfig +2 −0
  182. drivers/usb/typec/ucsi/debug.h +0 −65
  183. drivers/usb/typec/ucsi/trace.c +59 −0
  184. drivers/usb/typec/ucsi/trace.h +5 −2
  185. drivers/usb/usbip/Kconfig +2 −0
  186. drivers/usb/usbip/vhci_hcd.c +4 −2
  187. drivers/usb/usbip/vudc_dev.c +2 −1
  188. drivers/usb/wusbcore/Kconfig +1 −0
  189. drivers/usb/wusbcore/cbaf.c +4 −11
  190. drivers/usb/wusbcore/dev-sysfs.c +2 −3
  191. drivers/usb/wusbcore/devconnect.c +1 −1
  192. drivers/usb/wusbcore/wa-xfer.c +7 −8
  193. drivers/usb/wusbcore/wusbhc.c +1 −5
  194. drivers/uwb/drp-ie.c +2 −3
  195. include/linux/device.h +6 −0
  196. include/linux/fsl_devices.h +4 −3
  197. include/linux/phy/phy-mipi-dphy.h +6 −7
  198. include/linux/usb/hcd.h +7 −3
  199. include/linux/usb/role.h +2 −0
  200. include/linux/usb/tcpm.h +0 −6
  201. include/linux/usb/typec_dp.h +4 −0
  202. include/linux/usb/typec_mux.h +2 −1
  203. include/linux/usb/wusb.h +0 −16
Documentation/ABI/testing/sysfs-bus-usb+1−1
@@ -186,7 +186,7 @@ Contact: Lan Tianyu <tianyu.lan@intel.com> · 185 unmodified lines
186186 Description:
187187 Some platforms provide usb port connect types through ACPI.
188188 This attribute is to expose these information to user space.
189− The file will read "hotplug", "wired" and "not used" if the
189+ The file will read "hotplug", "hardwired" and "not used" if the
190190 information is available, and "unknown" otherwise.
191191
192192 What: /sys/bus/usb/devices/.../(hub interface)/portX/location
Documentation/admin-guide/kernel-parameters.txt+2−1
@@ -4718,7 +4718,8 @@ · 4717 unmodified lines
47184718 usbcore.authorized_default=
47194719 [USB] Default USB device authorization:
47204720 (default -1 = authorized except for wireless USB,
4721− 0 = not authorized, 1 = authorized)
4721+ 0 = not authorized, 1 = authorized, 2 = authorized
4722+ if device connected to internal port)
47224723
47234724 usbcore.autosuspend=
47244725 [USB] The autosuspend time delay (in seconds) used
Documentation/devicetree/bindings/arm/atmel-sysregs.txt+1−0
@@ -147,6 +147,7 @@ required properties: · 146 unmodified lines
147147 - compatible: Should be "atmel,<chip>-sfr", "syscon" or
148148 "atmel,<chip>-sfrbu", "syscon"
149149 <chip> can be "sama5d3", "sama5d4" or "sama5d2".
150+ It also can be "microchip,sam9x60-sfr", "syscon".
150151 - reg: Should contain registers location and length
151152
152153 sfr@f0038000 {
Documentation/devicetree/bindings/display/bridge/cdns,dsi.txt+0−21
@@ -31,28 +31,7 @@ Required subnodes: · 30 unmodified lines
3131 - one subnode per DSI device connected on the DSI bus. Each DSI device should
3232 contain a reg property encoding its virtual channel.
3333
34−Cadence DPHY
35−============
36−
37−Cadence DPHY block.
38−
39−Required properties:
40−- compatible: should be set to "cdns,dphy".
41−- reg: physical base address and length of the DPHY registers.
42−- clocks: DPHY reference clocks.
43−- clock-names: must contain "psm" and "pll_ref".
44−- #phy-cells: must be set to 0.
45−
46−
4734 Example:
48− dphy0: dphy@fd0e0000{
49− compatible = "cdns,dphy";
50− reg = <0x0 0xfd0e0000 0x0 0x1000>;
51− clocks = <&psm_clk>, <&pll_ref_clk>;
52− clock-names = "psm", "pll_ref";
53− #phy-cells = <0>;
54− };
55−
5635 dsi0: dsi@fd0c0000 {
5736 compatible = "cdns,dsi";
5837 reg = <0x0 0xfd0c0000 0x0 0x1000>;
Documentation/devicetree/bindings/phy/cdns,dphy.txt+20−0
@@ -0,0 +1,20 @@
1+Cadence DPHY
2+============
3+
4+Cadence DPHY block.
5+
6+Required properties:
7+- compatible: should be set to "cdns,dphy".
8+- reg: physical base address and length of the DPHY registers.
9+- clocks: DPHY reference clocks.
10+- clock-names: must contain "psm" and "pll_ref".
11+- #phy-cells: must be set to 0.
12+
13+Example:
14+ dphy0: dphy@fd0e0000{
15+ compatible = "cdns,dphy";
16+ reg = <0x0 0xfd0e0000 0x0 0x1000>;
17+ clocks = <&psm_clk>, <&pll_ref_clk>;
18+ clock-names = "psm", "pll_ref";
19+ #phy-cells = <0>;
20+ };
Documentation/devicetree/bindings/phy/phy-mvebu-comphy.txt+53−12
@@ -1,16 +1,27 @@
1−mvebu comphy driver
2−-------------------
1+MVEBU comphy drivers
2+--------------------
33
4−A comphy controller can be found on Marvell Armada 7k/8k on the CP110. It
5−provides a number of shared PHYs used by various interfaces (network, sata,
6−usb, PCIe...).
4+COMPHY controllers can be found on the following Marvell MVEBU SoCs:
5+* Armada 7k/8k (on the CP110)
6+* Armada 3700
7+It provides a number of shared PHYs used by various interfaces (network, SATA,
8+USB, PCIe...).
79
810 Required properties:
911
10−- compatible: should be "marvell,comphy-cp110"
11−- reg: should contain the comphy register location and length.
12−- marvell,system-controller: should contain a phandle to the
13− system controller node.
12+- compatible: should be one of:
13+ * "marvell,comphy-cp110" for Armada 7k/8k
14+ * "marvell,comphy-a3700" for Armada 3700
15+- reg: should contain the COMPHY register(s) location(s) and length(s).
16+ * 1 entry for Armada 7k/8k
17+ * 4 entries for Armada 3700 along with the corresponding reg-names
18+ properties, memory areas are:
19+ * Generic COMPHY registers
20+ * Lane 1 (PCIe/GbE)
21+ * Lane 0 (USB3/GbE)
22+ * Lane 2 (SATA/USB3)
23+- marvell,system-controller: should contain a phandle to the system
24+ controller node (only for Armada 7k/8k)
1425 - #address-cells: should be 1.
1526 - #size-cells: should be 0.
1627
@@ -18,11 +29,11 @@ A sub-node is required for each comphy lane provided by the comphy. · 1 unmodified line
1829
1930 Required properties (child nodes):
2031
21−- reg: comphy lane number.
22−- #phy-cells : from the generic phy bindings, must be 1. Defines the
32+- reg: COMPHY lane number.
33+- #phy-cells : from the generic PHY bindings, must be 1. Defines the
2334 input port to use for a given comphy lane.
2435
25−Example:
36+Examples:
2637
2738 cpm_comphy: phy@120000 {
2839 compatible = "marvell,comphy-cp110";
@@ -41,3 +52,33 @@ Example: · 12 unmodified lines
4152 #phy-cells = <1>;
4253 };
4354 };
55+
56+ comphy: phy@18300 {
57+ compatible = "marvell,comphy-a3700";
58+ reg = <0x18300 0x300>,
59+ <0x1F000 0x400>,
60+ <0x5C000 0x400>,
61+ <0xe0178 0x8>;
62+ reg-names = "comphy",
63+ "lane1_pcie_gbe",
64+ "lane0_usb3_gbe",
65+ "lane2_sata_usb3";
66+ #address-cells = <1>;
67+ #size-cells = <0>;
68+
69+
70+ comphy0: phy@0 {
71+ reg = <0>;
72+ #phy-cells = <1>;
73+ };
74+
75+ comphy1: phy@1 {
76+ reg = <1>;
77+ #phy-cells = <1>;
78+ };
79+
80+ comphy2: phy@2 {
81+ reg = <2>;
82+ #phy-cells = <1>;
83+ };
84+ };
Documentation/devicetree/bindings/phy/phy-mvebu-utmi.txt+38−0
@@ -0,0 +1,38 @@
1+MVEBU A3700 UTMI PHY
2+--------------------
3+
4+USB2 UTMI+ PHY controllers can be found on the following Marvell MVEBU SoCs:
5+* Armada 3700
6+
7+On Armada 3700, there are two USB controllers, one is compatible with the USB2
8+and USB3 specifications and supports OTG. The other one is USB2 compliant and
9+only supports host mode. Both of these controllers come with a slightly
10+different UTMI PHY.
11+
12+Required Properties:
13+
14+- compatible: Should be one of:
15+ * "marvell,a3700-utmi-host-phy" for the PHY connected to
16+ the USB2 host-only controller.
17+ * "marvell,a3700-utmi-otg-phy" for the PHY connected to
18+ the USB3 and USB2 OTG capable controller.
19+- reg: PHY IP register range.
20+- marvell,usb-misc-reg: handle on the "USB miscellaneous registers" shared
21+ region covering registers related to both the host
22+ controller and the PHY.
23+- #phy-cells: Standard property (Documentation: phy-bindings.txt) Should be 0.
24+
25+
26+Example:
27+
28+ usb2_utmi_host_phy: phy@5f000 {
29+ compatible = "marvell,armada-3700-utmi-host-phy";
30+ reg = <0x5f000 0x800>;
31+ marvell,usb-misc-reg = <&usb2_syscon>;
32+ #phy-cells = <0>;
33+ };
34+
35+ usb2_syscon: system-controller@5f800 {
36+ compatible = "marvell,armada-3700-usb2-host-misc", "syscon";
37+ reg = <0x5f800 0x800>;
38+ };
Documentation/devicetree/bindings/phy/phy-rockchip-inno-usb2.txt+2−0
@@ -23,6 +23,8 @@ Optional properties: · 22 unmodified lines
2323 register files". When set driver will request its
2424 phandle as one companion-grf for some special SoCs
2525 (e.g RV1108).
26+ - extcon : phandle to the extcon device providing the cable state for
27+ the otg phy.
2628
2729 Required nodes : a sub-node is required for each port the phy provides.
2830 The sub-node name is used to identify host or otg port,
Documentation/devicetree/bindings/phy/qcom-qmp-phy.txt+9−0
@@ -9,6 +9,8 @@ Required properties: · 8 unmodified lines
99 "qcom,ipq8074-qmp-pcie-phy" for PCIe phy on IPQ8074
1010 "qcom,msm8996-qmp-pcie-phy" for 14nm PCIe phy on msm8996,
1111 "qcom,msm8996-qmp-usb3-phy" for 14nm USB3 phy on msm8996,
12+ "qcom,msm8998-qmp-usb3-phy" for USB3 QMP V3 phy on msm8998,
13+ "qcom,msm8998-qmp-ufs-phy" for UFS QMP phy on msm8998,
1214 "qcom,sdm845-qmp-usb3-phy" for USB3 QMP V3 phy on sdm845,
1315 "qcom,sdm845-qmp-usb3-uni-phy" for USB3 QMP V3 UNI phy on sdm845,
1416 "qcom,sdm845-qmp-ufs-phy" for UFS QMP phy on sdm845.
@@ -42,6 +44,10 @@ Required properties: · 27 unmodified lines
4244 "aux", "cfg_ahb", "ref".
4345 For "qcom,msm8996-qmp-usb3-phy" must contain:
4446 "aux", "cfg_ahb", "ref".
47+ For "qcom,msm8998-qmp-usb3-phy" must contain:
48+ "aux", "cfg_ahb", "ref".
49+ For "qcom,msm8998-qmp-ufs-phy" must contain:
50+ "ref", "ref_aux".
4551 For "qcom,sdm845-qmp-usb3-phy" must contain:
4652 "aux", "cfg_ahb", "ref", "com_aux".
4753 For "qcom,sdm845-qmp-usb3-uni-phy" must contain:
@@ -61,6 +67,9 @@ Required properties: · 13 unmodified lines
6167 "phy", "common", "cfg".
6268 For "qcom,msm8996-qmp-usb3-phy" must contain
6369 "phy", "common".
70+ For "qcom,msm8998-qmp-usb3-phy" must contain
71+ "phy", "common".
72+ For "qcom,msm8998-qmp-ufs-phy": no resets are listed.
6473 For "qcom,sdm845-qmp-usb3-phy" must contain:
6574 "phy", "common".
6675 For "qcom,sdm845-qmp-usb3-uni-phy" must contain:
Documentation/devicetree/bindings/phy/qcom-qusb2-phy.txt+1−0
@@ -6,6 +6,7 @@ QUSB2 controller supports LS/FS/HS usb connectivity on Qualcomm chipsets. · 5 unmodified lines
66 Required properties:
77 - compatible: compatible list, contains
88 "qcom,msm8996-qusb2-phy" for 14nm PHY on msm8996,
9+ "qcom,msm8998-qusb2-phy" for 10nm PHY on msm8998,
910 "qcom,sdm845-qusb2-phy" for 10nm PHY on sdm845.
1011
1112 - reg: offset and length of the PHY register set.
Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb2.txt+2−0
@@ -5,6 +5,8 @@ This file provides information on what the device node for the R-Car generation · 4 unmodified lines
55
66 Required properties:
77 - compatible: "renesas,usb2-phy-r8a774a1" if the device is a part of an R8A774A1
8+ SoC.
9+ "renesas,usb2-phy-r8a774c0" if the device is a part of an R8A774C0
810 SoC.
911 "renesas,usb2-phy-r8a7795" if the device is a part of an R8A7795
1012 SoC.
Documentation/devicetree/bindings/phy/ti-phy.txt+1−0
@@ -35,6 +35,7 @@ Required properties: · 34 unmodified lines
3535 DRA7x
3636 Should be "ti,dra7x-usb2-phy2" for the 2nd instance of USB2 PHY
3737 in DRA7x
38+ Should be "ti,am654-usb2" for the USB2 PHYs on AM654.
3839 - reg : Address and length of the register set for the device.
3940 - #phy-cells: determine the number of cells that should be given in the
4041 phandle while referencing this phy.
Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt+1−0
@@ -93,6 +93,7 @@ i.mx specific properties · 92 unmodified lines
9393 - over-current-active-low: over current signal polarity is active low.
9494 - over-current-active-high: over current signal polarity is active high.
9595 It's recommended to specify the over current polarity.
96+- power-active-high: power signal polarity is active high
9697 - external-vbus-divider: enables off-chip resistor divider for Vbus
9798
9899 Example:
Documentation/devicetree/bindings/usb/ingenic,jz4740-musb.txt+24−0
@@ -0,0 +1,24 @@
1+Ingenic JZ4740 MUSB driver
2+
3+Required properties:
4+
5+- compatible: Must be "ingenic,jz4740-musb"
6+- reg: Address range of the UDC register set
7+- interrupts: IRQ number related to the UDC hardware
8+- interrupt-names: must be "mc"
9+- clocks: phandle to the "udc" clock
10+- clock-names: must be "udc"
11+
12+Example:
13+
14+udc: usb@13040000 {
15+ compatible = "ingenic,jz4740-musb";
16+ reg = <0x13040000 0x10000>;
17+
18+ interrupt-parent = <&intc>;
19+ interrupts = <24>;
20+ interrupt-names = "mc";
21+
22+ clocks = <&cgu JZ4740_CLK_UDC>;
23+ clock-names = "udc";
24+};
Documentation/devicetree/bindings/usb/keystone-usb.txt+4−2
@@ -3,7 +3,9 @@ TI Keystone Soc USB Controller · 2 unmodified lines
33 DWC3 GLUE
44
55 Required properties:
6− - compatible: should be "ti,keystone-dwc3".
6+ - compatible: should be
7+ "ti,keystone-dwc3" for Keystone 2 SoCs
8+ "ti,am654-dwc3" for AM654 SoC
79 - #address-cells, #size-cells : should be '1' if the device has sub-nodes
810 with 'reg' property.
911 - reg : Address and length of the register set for the USB subsystem on
@@ -21,7 +23,7 @@ SoCs only: · 11 unmodified lines
2123 - clock-names: Must be "usb".
2224
2325
24−The following are mandatory properties for Keystone 2 66AK2G SoCs only:
26+The following are mandatory properties for 66AK2G and AM654:
2527
2628 - power-domains: Should contain a phandle to a PM domain provider node
2729 and an args specifier containing the USB device id
Documentation/devicetree/bindings/usb/qcom,dwc3.txt+1−0
@@ -4,6 +4,7 @@ Required properties: · 3 unmodified lines
44 - compatible: Compatible list, contains
55 "qcom,dwc3"
66 "qcom,msm8996-dwc3" for msm8996 SOC.
7+ "qcom,msm8998-dwc3" for msm8998 SOC.
78 "qcom,sdm845-dwc3" for sdm845 SOC.
89 - reg: Offset and length of register set for QSCRATCH wrapper
910 - power-domains: specifies a phandle to PM domain provider node
Documentation/devicetree/bindings/usb/renesas_usb3.txt+1−0
@@ -3,6 +3,7 @@ Renesas Electronics USB3.0 Peripheral driver · 2 unmodified lines
33 Required properties:
44 - compatible: Must contain one of the following:
55 - "renesas,r8a774a1-usb3-peri"
6+ - "renesas,r8a774c0-usb3-peri"
67 - "renesas,r8a7795-usb3-peri"
78 - "renesas,r8a7796-usb3-peri"
89 - "renesas,r8a77965-usb3-peri"
Documentation/devicetree/bindings/usb/renesas_usbhs.txt+1−0
@@ -7,6 +7,7 @@ Required properties: · 6 unmodified lines
77 - "renesas,usbhs-r8a7744" for r8a7744 (RZ/G1N) compatible device
88 - "renesas,usbhs-r8a7745" for r8a7745 (RZ/G1E) compatible device
99 - "renesas,usbhs-r8a774a1" for r8a774a1 (RZ/G2M) compatible device
10+ - "renesas,usbhs-r8a774c0" for r8a774c0 (RZ/G2E) compatible device
1011 - "renesas,usbhs-r8a7790" for r8a7790 (R-Car H2) compatible device
1112 - "renesas,usbhs-r8a7791" for r8a7791 (R-Car M2-W) compatible device
1213 - "renesas,usbhs-r8a7792" for r8a7792 (R-Car V2H) compatible device
Documentation/devicetree/bindings/usb/usb251xb.txt+4−0
@@ -64,6 +64,8 @@ Optional properties : · 63 unmodified lines
6464 - power-on-time-ms : Specifies the time it takes from the time the host
6565 initiates the power-on sequence to a port until the port has adequate
6666 power. The value is given in ms in a 0 - 510 range (default is 100ms).
67+ - swap-dx-lanes : Specifies the ports which will swap the differential-pair
68+ (D+/D-), default is not-swapped.
6769
6870 Examples:
6971 usb2512b@2c {
@@ -81,4 +83,6 @@ Examples: · 11 unmodified lines
8183 manufacturer = "Foo";
8284 product = "Foo-Bar";
8385 serial = "1234567890A";
86+ /* correct misplaced usb connectors on port 1,2 */
87+ swap-dx-lanes = <1 2>;
8488 };
Documentation/usb/authorization.txt+3−1
@@ -34,7 +34,9 @@ $ echo 1 > /sys/bus/usb/devices/usbX/authorized_default · 33 unmodified lines
3434 By default, Wired USB devices are authorized by default to
3535 connect. Wireless USB hosts deauthorize by default all new connected
3636 devices (this is so because we need to do an authentication phase
37−before authorizing).
37+before authorizing). Writing "2" to the authorized_default attribute
38+causes kernel to only authorize by default devices connected to internal
39+USB ports.
3840
3941
4042 Example system lockdown (lame)
MAINTAINERS+8−0
@@ -9178,6 +9178,14 @@ F: drivers/gpu/drm/armada/ · 9177 unmodified lines
91789178 F: include/uapi/drm/armada_drm.h
91799179 F: Documentation/devicetree/bindings/display/armada/
91809180
9181+MARVELL ARMADA 3700 PHY DRIVERS
9182+M: Miquel Raynal <miquel.raynal@bootlin.com>
9183+S: Maintained
9184+F: drivers/phy/marvell/phy-mvebu-a3700-comphy.c
9185+F: drivers/phy/marvell/phy-mvebu-a3700-utmi.c
9186+F: Documentation/devicetree/bindings/phy/phy-mvebu-comphy.txt
9187+F: Documentation/devicetree/bindings/phy/phy-mvebu-utmi.txt
9188+
91819189 MARVELL CRYPTO DRIVER
91829190 M: Boris Brezillon <bbrezillon@kernel.org>
91839191 M: Arnaud Ebalard <arno@natisbad.org>
drivers/base/devcon.c+59−3
@@ -7,10 +7,37 @@ · 6 unmodified lines
77 */
88
99 #include <linux/device.h>
10+#include <linux/property.h>
1011
1112 static DEFINE_MUTEX(devcon_lock);
1213 static LIST_HEAD(devcon_list);
1314
15+typedef void *(*devcon_match_fn_t)(struct device_connection *con, int ep,
16+ void *data);
17+
18+static void *
19+fwnode_graph_devcon_match(struct fwnode_handle *fwnode, const char *con_id,
20+ void *data, devcon_match_fn_t match)
21+{
22+ struct device_connection con = { .id = con_id };
23+ struct fwnode_handle *ep;
24+ void *ret;
25+
26+ fwnode_graph_for_each_endpoint(fwnode, ep) {
27+ con.fwnode = fwnode_graph_get_remote_port_parent(ep);
28+ if (!fwnode_device_is_available(con.fwnode))
29+ continue;
30+
31+ ret = match(&con, -1, data);
32+ fwnode_handle_put(con.fwnode);
33+ if (ret) {
34+ fwnode_handle_put(ep);
35+ return ret;
36+ }
37+ }
38+ return NULL;
39+}
40+
1441 /**
1542 * device_connection_find_match - Find physical connection to a device
1643 * @dev: Device with the connection
@@ -23,10 +50,9 @@ static LIST_HEAD(devcon_list); · 6 unmodified lines
2350 * caller is expecting to be returned.
2451 */
2552 void *device_connection_find_match(struct device *dev, const char *con_id,
26− void *data,
27− void *(*match)(struct device_connection *con,
28− int ep, void *data))
53+ void *data, devcon_match_fn_t match)
2954 {
55+ struct fwnode_handle *fwnode = dev_fwnode(dev);
3056 const char *devname = dev_name(dev);
3157 struct device_connection *con;
3258 void *ret = NULL;
@@ -35,6 +61,12 @@ void *device_connection_find_match(struct device *dev, const char *con_id, · 2 unmodified lines
3561 if (!match)
3662 return NULL;
3763
64+ if (fwnode) {
65+ ret = fwnode_graph_devcon_match(fwnode, con_id, data, match);
66+ if (ret)
67+ return ret;
68+ }
69+
3870 mutex_lock(&devcon_lock);
3971
4072 list_for_each_entry(con, &devcon_list, list) {
@@ -75,12 +107,36 @@ static struct bus_type *generic_match_buses[] = { · 34 unmodified lines
75107 NULL,
76108 };
77109
110+static int device_fwnode_match(struct device *dev, void *fwnode)
111+{
112+ return dev_fwnode(dev) == fwnode;
113+}
114+
115+static void *device_connection_fwnode_match(struct device_connection *con)
116+{
117+ struct bus_type *bus;
118+ struct device *dev;
119+
120+ for (bus = generic_match_buses[0]; bus; bus++) {
121+ dev = bus_find_device(bus, NULL, (void *)con->fwnode,
122+ device_fwnode_match);
123+ if (dev && !strncmp(dev_name(dev), con->id, strlen(con->id)))
124+ return dev;
125+
126+ put_device(dev);
127+ }
128+ return NULL;
129+}
130+
78131 /* This tries to find the device from the most common bus types by name. */
79132 static void *generic_match(struct device_connection *con, int ep, void *data)
80133 {
81134 struct bus_type *bus;
82135 struct device *dev;
83136
137+ if (con->fwnode)
138+ return device_connection_fwnode_match(con);
139+
84140 for (bus = generic_match_buses[0]; bus; bus++) {
85141 dev = bus_find_device_by_name(bus, NULL, con->endpoint[ep]);
86142 if (dev)
drivers/phy/broadcom/phy-bcm-sr-pcie.c+2−2
@@ -78,8 +78,8 @@ struct sr_pcie_phy_core { · 77 unmodified lines
7878 static const u8 pipemux_table[] = {
7979 /* PIPEMUX = 0, EP 1x16 */
8080 0x00,
81− /* PIPEMUX = 1, EP 2x8 */
82− 0x00,
81+ /* PIPEMUX = 1, EP 1x8 + RC 1x8, core 7 */
82+ 0x80,
8383 /* PIPEMUX = 2, EP 4x4 */
8484 0x00,
8585 /* PIPEMUX = 3, RC 2x8, cores 0, 7 */
drivers/phy/cadence/Kconfig+12−1
@@ -1,6 +1,7 @@
11 #
22 # Phy drivers for Cadence PHYs
33 #
4+
45 config PHY_CADENCE_DP
56 tristate "Cadence MHDP DisplayPort PHY driver"
67 depends on OF
@@ -9,9 +10,19 @@ config PHY_CADENCE_DP · 2 unmodified lines
910 help
1011 Support for Cadence MHDP DisplayPort PHY.
1112
13+config PHY_CADENCE_DPHY
14+ tristate "Cadence D-PHY Support"
15+ depends on HAS_IOMEM && OF
16+ select GENERIC_PHY
17+ select GENERIC_PHY_MIPI_DPHY
18+ help
19+ Choose this option if you have a Cadence D-PHY in your
20+ system. If M is selected, the module will be called
21+ cdns-dphy.
22+
1223 config PHY_CADENCE_SIERRA
1324 tristate "Cadence Sierra PHY Driver"
1425 depends on OF && HAS_IOMEM && RESET_CONTROLLER
1526 select GENERIC_PHY
1627 help
17− Enable this to support the Cadence Sierra PHY driver
28+ Enable this to support the Cadence Sierra PHY driver
drivers/phy/cadence/Makefile+1−0
@@ -1,2 +1,3 @@
11 obj-$(CONFIG_PHY_CADENCE_DP) += phy-cadence-dp.o
2+obj-$(CONFIG_PHY_CADENCE_DPHY) += cdns-dphy.o
23 obj-$(CONFIG_PHY_CADENCE_SIERRA) += phy-cadence-sierra.o
drivers/phy/cadence/cdns-dphy.c+391−0
@@ -0,0 +1,391 @@
1+// SPDX-License-Identifier: GPL-2.0+
2+/*
3+ * Copyright: 2017-2018 Cadence Design Systems, Inc.
4+ */
5+
6+#include <linux/bitops.h>
7+#include <linux/clk.h>
8+#include <linux/io.h>
9+#include <linux/module.h>
10+#include <linux/of_address.h>
11+#include <linux/of_device.h>
12+#include <linux/platform_device.h>
13+#include <linux/reset.h>
14+
15+#include <linux/phy/phy.h>
16+#include <linux/phy/phy-mipi-dphy.h>
17+
18+#define REG_WAKEUP_TIME_NS 800
19+#define DPHY_PLL_RATE_HZ 108000000
20+
21+/* DPHY registers */
22+#define DPHY_PMA_CMN(reg) (reg)
23+#define DPHY_PMA_LCLK(reg) (0x100 + (reg))
24+#define DPHY_PMA_LDATA(lane, reg) (0x200 + ((lane) * 0x100) + (reg))
25+#define DPHY_PMA_RCLK(reg) (0x600 + (reg))
26+#define DPHY_PMA_RDATA(lane, reg) (0x700 + ((lane) * 0x100) + (reg))
27+#define DPHY_PCS(reg) (0xb00 + (reg))
28+
29+#define DPHY_CMN_SSM DPHY_PMA_CMN(0x20)
30+#define DPHY_CMN_SSM_EN BIT(0)
31+#define DPHY_CMN_TX_MODE_EN BIT(9)
32+
33+#define DPHY_CMN_PWM DPHY_PMA_CMN(0x40)
34+#define DPHY_CMN_PWM_DIV(x) ((x) << 20)
35+#define DPHY_CMN_PWM_LOW(x) ((x) << 10)
36+#define DPHY_CMN_PWM_HIGH(x) (x)
37+
38+#define DPHY_CMN_FBDIV DPHY_PMA_CMN(0x4c)
39+#define DPHY_CMN_FBDIV_VAL(low, high) (((high) << 11) | ((low) << 22))
40+#define DPHY_CMN_FBDIV_FROM_REG (BIT(10) | BIT(21))
41+
42+#define DPHY_CMN_OPIPDIV DPHY_PMA_CMN(0x50)
43+#define DPHY_CMN_IPDIV_FROM_REG BIT(0)
44+#define DPHY_CMN_IPDIV(x) ((x) << 1)
45+#define DPHY_CMN_OPDIV_FROM_REG BIT(6)
46+#define DPHY_CMN_OPDIV(x) ((x) << 7)
47+
48+#define DPHY_PSM_CFG DPHY_PCS(0x4)
49+#define DPHY_PSM_CFG_FROM_REG BIT(0)
50+#define DPHY_PSM_CLK_DIV(x) ((x) << 1)
51+
52+#define DSI_HBP_FRAME_OVERHEAD 12
53+#define DSI_HSA_FRAME_OVERHEAD 14
54+#define DSI_HFP_FRAME_OVERHEAD 6
55+#define DSI_HSS_VSS_VSE_FRAME_OVERHEAD 4
56+#define DSI_BLANKING_FRAME_OVERHEAD 6
57+#define DSI_NULL_FRAME_OVERHEAD 6
58+#define DSI_EOT_PKT_SIZE 4
59+
60+struct cdns_dphy_cfg {
61+ u8 pll_ipdiv;
62+ u8 pll_opdiv;
63+ u16 pll_fbdiv;
64+ unsigned int nlanes;
65+};
66+
67+enum cdns_dphy_clk_lane_cfg {
68+ DPHY_CLK_CFG_LEFT_DRIVES_ALL = 0,
69+ DPHY_CLK_CFG_LEFT_DRIVES_RIGHT = 1,
70+ DPHY_CLK_CFG_LEFT_DRIVES_LEFT = 2,
71+ DPHY_CLK_CFG_RIGHT_DRIVES_ALL = 3,
72+};
73+
74+struct cdns_dphy;
75+struct cdns_dphy_ops {
76+ int (*probe)(struct cdns_dphy *dphy);
77+ void (*remove)(struct cdns_dphy *dphy);
78+ void (*set_psm_div)(struct cdns_dphy *dphy, u8 div);
79+ void (*set_clk_lane_cfg)(struct cdns_dphy *dphy,
80+ enum cdns_dphy_clk_lane_cfg cfg);
81+ void (*set_pll_cfg)(struct cdns_dphy *dphy,
82+ const struct cdns_dphy_cfg *cfg);
83+ unsigned long (*get_wakeup_time_ns)(struct cdns_dphy *dphy);
84+};
85+
86+struct cdns_dphy {
87+ struct cdns_dphy_cfg cfg;
88+ void __iomem *regs;
89+ struct clk *psm_clk;
90+ struct clk *pll_ref_clk;
91+ const struct cdns_dphy_ops *ops;
92+ struct phy *phy;
93+};
94+
95+static int cdns_dsi_get_dphy_pll_cfg(struct cdns_dphy *dphy,
96+ struct cdns_dphy_cfg *cfg,
97+ struct phy_configure_opts_mipi_dphy *opts,
98+ unsigned int *dsi_hfp_ext)
99+{
100+ unsigned long pll_ref_hz = clk_get_rate(dphy->pll_ref_clk);
101+ u64 dlane_bps;
102+
103+ memset(cfg, 0, sizeof(*cfg));
104+
105+ if (pll_ref_hz < 9600000 || pll_ref_hz >= 150000000)
106+ return -EINVAL;
107+ else if (pll_ref_hz < 19200000)
108+ cfg->pll_ipdiv = 1;
109+ else if (pll_ref_hz < 38400000)
110+ cfg->pll_ipdiv = 2;
111+ else if (pll_ref_hz < 76800000)
112+ cfg->pll_ipdiv = 4;
113+ else
114+ cfg->pll_ipdiv = 8;
115+
116+ dlane_bps = opts->hs_clk_rate;
117+
118+ if (dlane_bps > 2500000000UL || dlane_bps < 160000000UL)
119+ return -EINVAL;
120+ else if (dlane_bps >= 1250000000)
121+ cfg->pll_opdiv = 1;
122+ else if (dlane_bps >= 630000000)
123+ cfg->pll_opdiv = 2;
124+ else if (dlane_bps >= 320000000)
125+ cfg->pll_opdiv = 4;
126+ else if (dlane_bps >= 160000000)
127+ cfg->pll_opdiv = 8;
128+
129+ cfg->pll_fbdiv = DIV_ROUND_UP_ULL(dlane_bps * 2 * cfg->pll_opdiv *
130+ cfg->pll_ipdiv,
131+ pll_ref_hz);
132+
133+ return 0;
134+}
135+
136+static int cdns_dphy_setup_psm(struct cdns_dphy *dphy)
137+{
138+ unsigned long psm_clk_hz = clk_get_rate(dphy->psm_clk);
139+ unsigned long psm_div;
140+
141+ if (!psm_clk_hz || psm_clk_hz > 100000000)
142+ return -EINVAL;
143+
144+ psm_div = DIV_ROUND_CLOSEST(psm_clk_hz, 1000000);
145+ if (dphy->ops->set_psm_div)
146+ dphy->ops->set_psm_div(dphy, psm_div);
147+
148+ return 0;
149+}
150+
151+static void cdns_dphy_set_clk_lane_cfg(struct cdns_dphy *dphy,
152+ enum cdns_dphy_clk_lane_cfg cfg)
153+{
154+ if (dphy->ops->set_clk_lane_cfg)
155+ dphy->ops->set_clk_lane_cfg(dphy, cfg);
156+}
157+
158+static void cdns_dphy_set_pll_cfg(struct cdns_dphy *dphy,
159+ const struct cdns_dphy_cfg *cfg)
160+{
161+ if (dphy->ops->set_pll_cfg)
162+ dphy->ops->set_pll_cfg(dphy, cfg);
163+}
164+
165+static unsigned long cdns_dphy_get_wakeup_time_ns(struct cdns_dphy *dphy)
166+{
167+ return dphy->ops->get_wakeup_time_ns(dphy);
168+}
169+
170+static unsigned long cdns_dphy_ref_get_wakeup_time_ns(struct cdns_dphy *dphy)
171+{
172+ /* Default wakeup time is 800 ns (in a simulated environment). */
173+ return 800;
174+}
175+
176+static void cdns_dphy_ref_set_pll_cfg(struct cdns_dphy *dphy,
177+ const struct cdns_dphy_cfg *cfg)
178+{
179+ u32 fbdiv_low, fbdiv_high;
180+
181+ fbdiv_low = (cfg->pll_fbdiv / 4) - 2;
182+ fbdiv_high = cfg->pll_fbdiv - fbdiv_low - 2;
183+
184+ writel(DPHY_CMN_IPDIV_FROM_REG | DPHY_CMN_OPDIV_FROM_REG |
185+ DPHY_CMN_IPDIV(cfg->pll_ipdiv) |
186+ DPHY_CMN_OPDIV(cfg->pll_opdiv),
187+ dphy->regs + DPHY_CMN_OPIPDIV);
188+ writel(DPHY_CMN_FBDIV_FROM_REG |
189+ DPHY_CMN_FBDIV_VAL(fbdiv_low, fbdiv_high),
190+ dphy->regs + DPHY_CMN_FBDIV);
191+ writel(DPHY_CMN_PWM_HIGH(6) | DPHY_CMN_PWM_LOW(0x101) |
192+ DPHY_CMN_PWM_DIV(0x8),
193+ dphy->regs + DPHY_CMN_PWM);
194+}
195+
196+static void cdns_dphy_ref_set_psm_div(struct cdns_dphy *dphy, u8 div)
197+{
198+ writel(DPHY_PSM_CFG_FROM_REG | DPHY_PSM_CLK_DIV(div),
199+ dphy->regs + DPHY_PSM_CFG);
200+}
201+
202+/*
203+ * This is the reference implementation of DPHY hooks. Specific integration of
204+ * this IP may have to re-implement some of them depending on how they decided
205+ * to wire things in the SoC.
206+ */
207+static const struct cdns_dphy_ops ref_dphy_ops = {
208+ .get_wakeup_time_ns = cdns_dphy_ref_get_wakeup_time_ns,
209+ .set_pll_cfg = cdns_dphy_ref_set_pll_cfg,
210+ .set_psm_div = cdns_dphy_ref_set_psm_div,
211+};
212+
213+static int cdns_dphy_config_from_opts(struct phy *phy,
214+ struct phy_configure_opts_mipi_dphy *opts,
215+ struct cdns_dphy_cfg *cfg)
216+{
217+ struct cdns_dphy *dphy = phy_get_drvdata(phy);
218+ unsigned int dsi_hfp_ext = 0;
219+ int ret;
220+
221+ ret = phy_mipi_dphy_config_validate(opts);
222+ if (ret)
223+ return ret;
224+
225+ ret = cdns_dsi_get_dphy_pll_cfg(dphy, cfg,
226+ opts, &dsi_hfp_ext);
227+ if (ret)
228+ return ret;
229+
230+ opts->wakeup = cdns_dphy_get_wakeup_time_ns(dphy) / 1000;
231+
232+ return 0;
233+}
234+
235+static int cdns_dphy_validate(struct phy *phy, enum phy_mode mode, int submode,
236+ union phy_configure_opts *opts)
237+{
238+ struct cdns_dphy_cfg cfg = { 0 };
239+
240+ if (mode != PHY_MODE_MIPI_DPHY)
241+ return -EINVAL;
242+
243+ return cdns_dphy_config_from_opts(phy, &opts->mipi_dphy, &cfg);
244+}
245+
246+static int cdns_dphy_configure(struct phy *phy, union phy_configure_opts *opts)
247+{
248+ struct cdns_dphy *dphy = phy_get_drvdata(phy);
249+ struct cdns_dphy_cfg cfg = { 0 };
250+ int ret;
251+
252+ ret = cdns_dphy_config_from_opts(phy, &opts->mipi_dphy, &cfg);
253+ if (ret)
254+ return ret;
255+
256+ /*
257+ * Configure the internal PSM clk divider so that the DPHY has a
258+ * 1MHz clk (or something close).
259+ */
260+ ret = cdns_dphy_setup_psm(dphy);
261+ if (ret)
262+ return ret;
263+
264+ /*
265+ * Configure attach clk lanes to data lanes: the DPHY has 2 clk lanes
266+ * and 8 data lanes, each clk lane can be attache different set of
267+ * data lanes. The 2 groups are named 'left' and 'right', so here we
268+ * just say that we want the 'left' clk lane to drive the 'left' data
269+ * lanes.
270+ */
271+ cdns_dphy_set_clk_lane_cfg(dphy, DPHY_CLK_CFG_LEFT_DRIVES_LEFT);
272+
273+ /*
274+ * Configure the DPHY PLL that will be used to generate the TX byte
275+ * clk.
276+ */
277+ cdns_dphy_set_pll_cfg(dphy, &cfg);
278+
279+ return 0;
280+}
281+
282+static int cdns_dphy_power_on(struct phy *phy)
283+{
284+ struct cdns_dphy *dphy = phy_get_drvdata(phy);
285+
286+ clk_prepare_enable(dphy->psm_clk);
287+ clk_prepare_enable(dphy->pll_ref_clk);
288+
289+ /* Start TX state machine. */
290+ writel(DPHY_CMN_SSM_EN | DPHY_CMN_TX_MODE_EN,
291+ dphy->regs + DPHY_CMN_SSM);
292+
293+ return 0;
294+}
295+
296+static int cdns_dphy_power_off(struct phy *phy)
297+{
298+ struct cdns_dphy *dphy = phy_get_drvdata(phy);
299+
300+ clk_disable_unprepare(dphy->pll_ref_clk);
301+ clk_disable_unprepare(dphy->psm_clk);
302+
303+ return 0;
304+}
305+
306+static const struct phy_ops cdns_dphy_ops = {
307+ .configure = cdns_dphy_configure,
308+ .validate = cdns_dphy_validate,
309+ .power_on = cdns_dphy_power_on,
310+ .power_off = cdns_dphy_power_off,
311+};
312+
313+static int cdns_dphy_probe(struct platform_device *pdev)
314+{
315+ struct phy_provider *phy_provider;
316+ struct cdns_dphy *dphy;
317+ struct resource *res;
318+ int ret;
319+
320+ dphy = devm_kzalloc(&pdev->dev, sizeof(*dphy), GFP_KERNEL);
321+ if (!dphy)
322+ return -ENOMEM;
323+ dev_set_drvdata(&pdev->dev, dphy);
324+
325+ dphy->ops = of_device_get_match_data(&pdev->dev);
326+ if (!dphy->ops)
327+ return -EINVAL;
328+
329+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
330+ dphy->regs = devm_ioremap_resource(&pdev->dev, res);
331+ if (IS_ERR(dphy->regs))
332+ return PTR_ERR(dphy->regs);
333+
334+ dphy->psm_clk = devm_clk_get(&pdev->dev, "psm");
335+ if (IS_ERR(dphy->psm_clk))
336+ return PTR_ERR(dphy->psm_clk);
337+
338+ dphy->pll_ref_clk = devm_clk_get(&pdev->dev, "pll_ref");
339+ if (IS_ERR(dphy->pll_ref_clk))
340+ return PTR_ERR(dphy->pll_ref_clk);
341+
342+ if (dphy->ops->probe) {
343+ ret = dphy->ops->probe(dphy);
344+ if (ret)
345+ return ret;
346+ }
347+
348+ dphy->phy = devm_phy_create(&pdev->dev, NULL, &cdns_dphy_ops);
349+ if (IS_ERR(dphy->phy)) {
350+ dev_err(&pdev->dev, "failed to create PHY\n");
351+ if (dphy->ops->remove)
352+ dphy->ops->remove(dphy);
353+ return PTR_ERR(dphy->phy);
354+ }
355+
356+ phy_set_drvdata(dphy->phy, dphy);
357+ phy_provider = devm_of_phy_provider_register(&pdev->dev,
358+ of_phy_simple_xlate);
359+
360+ return PTR_ERR_OR_ZERO(phy_provider);
361+}
362+
363+static int cdns_dphy_remove(struct platform_device *pdev)
364+{
365+ struct cdns_dphy *dphy = dev_get_drvdata(&pdev->dev);
366+
367+ if (dphy->ops->remove)
368+ dphy->ops->remove(dphy);
369+
370+ return 0;
371+}
372+
373+static const struct of_device_id cdns_dphy_of_match[] = {
374+ { .compatible = "cdns,dphy", .data = &ref_dphy_ops },
375+ { /* sentinel */ },
376+};
377+MODULE_DEVICE_TABLE(of, cdns_dphy_of_match);
378+
379+static struct platform_driver cdns_dphy_platform_driver = {
380+ .probe = cdns_dphy_probe,
381+ .remove = cdns_dphy_remove,
382+ .driver = {
383+ .name = "cdns-mipi-dphy",
384+ .of_match_table = cdns_dphy_of_match,
385+ },
386+};
387+module_platform_driver(cdns_dphy_platform_driver);
388+
389+MODULE_AUTHOR("Maxime Ripard <maxime.ripard@bootlin.com>");
390+MODULE_DESCRIPTION("Cadence MIPI D-PHY Driver");
391+MODULE_LICENSE("GPL");
drivers/phy/freescale/Kconfig+1−1
@@ -2,4 +2,4 @@ config PHY_FSL_IMX8MQ_USB · 1 unmodified line
22 tristate "Freescale i.MX8M USB3 PHY"
33 depends on OF && HAS_IOMEM
44 select GENERIC_PHY
5− default SOC_IMX8MQ
5+ default ARCH_MXC && ARM64
drivers/phy/marvell/Kconfig+21−0
@@ -21,6 +21,27 @@ config PHY_BERLIN_USB · 20 unmodified lines
2121 help
2222 Enable this to support the USB PHY on Marvell Berlin SoCs.
2323
24+config PHY_MVEBU_A3700_COMPHY
25+ tristate "Marvell A3700 comphy driver"
26+ depends on ARCH_MVEBU || COMPILE_TEST
27+ depends on OF
28+ depends on HAVE_ARM_SMCCC
29+ default y
30+ select GENERIC_PHY
31+ help
32+ This driver allows to control the comphy, a hardware block providing
33+ shared serdes PHYs on Marvell Armada 3700. Its serdes lanes can be
34+ used by various controllers: Ethernet, SATA, USB3, PCIe.
35+
36+config PHY_MVEBU_A3700_UTMI
37+ tristate "Marvell A3700 UTMI driver"
38+ depends on ARCH_MVEBU || COMPILE_TEST
39+ depends on OF
40+ default y
41+ select GENERIC_PHY
42+ help
43+ Enable this to support Marvell A3700 UTMI PHY driver.
44+
2445 config PHY_MVEBU_A38X_COMPHY
2546 tristate "Marvell Armada 38x comphy driver"
2647 depends on ARCH_MVEBU || COMPILE_TEST
drivers/phy/marvell/Makefile+2−0
@@ -2,6 +2,8 @@ · 1 unmodified line
22 obj-$(CONFIG_ARMADA375_USBCLUSTER_PHY) += phy-armada375-usb2.o
33 obj-$(CONFIG_PHY_BERLIN_SATA) += phy-berlin-sata.o
44 obj-$(CONFIG_PHY_BERLIN_USB) += phy-berlin-usb.o
5+obj-$(CONFIG_PHY_MVEBU_A3700_COMPHY) += phy-mvebu-a3700-comphy.o
6+obj-$(CONFIG_PHY_MVEBU_A3700_UTMI) += phy-mvebu-a3700-utmi.o
57 obj-$(CONFIG_PHY_MVEBU_A38X_COMPHY) += phy-armada38x-comphy.o
68 obj-$(CONFIG_PHY_MVEBU_CP110_COMPHY) += phy-mvebu-cp110-comphy.o
79 obj-$(CONFIG_PHY_MVEBU_SATA) += phy-mvebu-sata.o
drivers/phy/marvell/phy-armada375-usb2.c+2−11
@@ -1,3 +1,4 @@
1+// SPDX-License-Identifier: GPL-2.0+
12 /*
23 * USB cluster support for Armada 375 platform.
34 *
@@ -5,10 +6,6 @@ · 1 unmodified line
56 *
67 * Gregory CLEMENT <gregory.clement@free-electrons.com>
78 *
8− * This file is licensed under the terms of the GNU General Public
9− * License version 2 or later. This program is licensed "as is"
10− * without any warranty of any kind, whether express or implied.
11− *
129 * Armada 375 comes with an USB2 host and device controller and an
1310 * USB3 controller. The USB cluster control register allows to manage
1411 * common features of both USB controllers.
@@ -18,7 +15,6 @@ · 3 unmodified lines
1815 #include <linux/init.h>
1916 #include <linux/io.h>
2017 #include <linux/kernel.h>
21−#include <linux/module.h>
2218 #include <linux/of_address.h>
2319 #include <linux/phy/phy.h>
2420 #include <linux/platform_device.h>
@@ -142,7 +138,6 @@ static const struct of_device_id of_usb_cluster_table[] = { · 117 unmodified lines
142138 { .compatible = "marvell,armada-375-usb-cluster", },
143139 { /* end of list */ },
144140 };
145−MODULE_DEVICE_TABLE(of, of_usb_cluster_table);
146141
147142 static struct platform_driver armada375_usb_phy_driver = {
148143 .probe = armada375_usb_phy_probe,
@@ -151,8 +146,4 @@ static struct platform_driver armada375_usb_phy_driver = { · 2 unmodified lines
151146 .name = "armada-375-usb-cluster",
152147 }
153148 };
154−module_platform_driver(armada375_usb_phy_driver);
155−
156−MODULE_DESCRIPTION("Armada 375 USB cluster driver");
157−MODULE_AUTHOR("Gregory CLEMENT <gregory.clement@free-electrons.com>");
158−MODULE_LICENSE("GPL");
149+builtin_platform_driver(armada375_usb_phy_driver);
drivers/phy/marvell/phy-mvebu-a3700-comphy.c+318−0
@@ -0,0 +1,318 @@
1+// SPDX-License-Identifier: GPL-2.0
2+/*
3+ * Copyright (C) 2018 Marvell
4+ *
5+ * Authors:
6+ * Evan Wang <xswang@marvell.com>
7+ * Miquèl Raynal <miquel.raynal@bootlin.com>
8+ *
9+ * Structure inspired from phy-mvebu-cp110-comphy.c written by Antoine Tenart.
10+ * SMC call initial support done by Grzegorz Jaszczyk.
11+ */
12+
13+#include <linux/arm-smccc.h>
14+#include <linux/io.h>
15+#include <linux/iopoll.h>
16+#include <linux/mfd/syscon.h>
17+#include <linux/module.h>
18+#include <linux/phy.h>
19+#include <linux/phy/phy.h>
20+#include <linux/platform_device.h>
21+
22+#define MVEBU_A3700_COMPHY_LANES 3
23+#define MVEBU_A3700_COMPHY_PORTS 2
24+
25+/* COMPHY Fast SMC function identifiers */
26+#define COMPHY_SIP_POWER_ON 0x82000001
27+#define COMPHY_SIP_POWER_OFF 0x82000002
28+#define COMPHY_SIP_PLL_LOCK 0x82000003
29+
30+#define COMPHY_FW_MODE_SATA 0x1
31+#define COMPHY_FW_MODE_SGMII 0x2
32+#define COMPHY_FW_MODE_HS_SGMII 0x3
33+#define COMPHY_FW_MODE_USB3H 0x4
34+#define COMPHY_FW_MODE_USB3D 0x5
35+#define COMPHY_FW_MODE_PCIE 0x6
36+#define COMPHY_FW_MODE_RXAUI 0x7
37+#define COMPHY_FW_MODE_XFI 0x8
38+#define COMPHY_FW_MODE_SFI 0x9
39+#define COMPHY_FW_MODE_USB3 0xa
40+
41+#define COMPHY_FW_SPEED_1_25G 0 /* SGMII 1G */
42+#define COMPHY_FW_SPEED_2_5G 1
43+#define COMPHY_FW_SPEED_3_125G 2 /* SGMII 2.5G */
44+#define COMPHY_FW_SPEED_5G 3
45+#define COMPHY_FW_SPEED_5_15625G 4 /* XFI 5G */
46+#define COMPHY_FW_SPEED_6G 5
47+#define COMPHY_FW_SPEED_10_3125G 6 /* XFI 10G */
48+#define COMPHY_FW_SPEED_MAX 0x3F
49+
50+#define COMPHY_FW_MODE(mode) ((mode) << 12)
51+#define COMPHY_FW_NET(mode, idx, speed) (COMPHY_FW_MODE(mode) | \
52+ ((idx) << 8) | \
53+ ((speed) << 2))
54+#define COMPHY_FW_PCIE(mode, idx, speed, width) (COMPHY_FW_NET(mode, idx, speed) | \
55+ ((width) << 18))
56+
57+struct mvebu_a3700_comphy_conf {
58+ unsigned int lane;
59+ enum phy_mode mode;
60+ int submode;
61+ unsigned int port;
62+ u32 fw_mode;
63+};
64+
65+#define MVEBU_A3700_COMPHY_CONF(_lane, _mode, _smode, _port, _fw) \
66+ { \
67+ .lane = _lane, \
68+ .mode = _mode, \
69+ .submode = _smode, \
70+ .port = _port, \
71+ .fw_mode = _fw, \
72+ }
73+
74+#define MVEBU_A3700_COMPHY_CONF_GEN(_lane, _mode, _port, _fw) \
75+ MVEBU_A3700_COMPHY_CONF(_lane, _mode, PHY_INTERFACE_MODE_NA, _port, _fw)
76+
77+#define MVEBU_A3700_COMPHY_CONF_ETH(_lane, _smode, _port, _fw) \
78+ MVEBU_A3700_COMPHY_CONF(_lane, PHY_MODE_ETHERNET, _smode, _port, _fw)
79+
80+static const struct mvebu_a3700_comphy_conf mvebu_a3700_comphy_modes[] = {
81+ /* lane 0 */
82+ MVEBU_A3700_COMPHY_CONF_GEN(0, PHY_MODE_USB_HOST_SS, 0,
83+ COMPHY_FW_MODE_USB3H),
84+ MVEBU_A3700_COMPHY_CONF_ETH(0, PHY_INTERFACE_MODE_SGMII, 1,
85+ COMPHY_FW_MODE_SGMII),
86+ MVEBU_A3700_COMPHY_CONF_ETH(0, PHY_INTERFACE_MODE_2500BASEX, 1,
87+ COMPHY_FW_MODE_HS_SGMII),
88+ /* lane 1 */
89+ MVEBU_A3700_COMPHY_CONF_GEN(1, PHY_MODE_PCIE, 0,
90+ COMPHY_FW_MODE_PCIE),
91+ MVEBU_A3700_COMPHY_CONF_ETH(1, PHY_INTERFACE_MODE_SGMII, 0,
92+ COMPHY_FW_MODE_SGMII),
93+ MVEBU_A3700_COMPHY_CONF_ETH(1, PHY_INTERFACE_MODE_2500BASEX, 0,
94+ COMPHY_FW_MODE_HS_SGMII),
95+ /* lane 2 */
96+ MVEBU_A3700_COMPHY_CONF_GEN(2, PHY_MODE_SATA, 0,
97+ COMPHY_FW_MODE_SATA),
98+ MVEBU_A3700_COMPHY_CONF_GEN(2, PHY_MODE_USB_HOST_SS, 0,
99+ COMPHY_FW_MODE_USB3H),
100+};
101+
102+struct mvebu_a3700_comphy_lane {
103+ struct device *dev;
104+ unsigned int id;
105+ enum phy_mode mode;
106+ int submode;
107+ int port;
108+};
109+
110+static int mvebu_a3700_comphy_smc(unsigned long function, unsigned long lane,
111+ unsigned long mode)
112+{
113+ struct arm_smccc_res res;
114+
115+ arm_smccc_smc(function, lane, mode, 0, 0, 0, 0, 0, &res);
116+
117+ return res.a0;
118+}
119+
120+static int mvebu_a3700_comphy_get_fw_mode(int lane, int port,
121+ enum phy_mode mode,
122+ int submode)
123+{
124+ int i, n = ARRAY_SIZE(mvebu_a3700_comphy_modes);
125+
126+ /* Unused PHY mux value is 0x0 */
127+ if (mode == PHY_MODE_INVALID)
128+ return -EINVAL;
129+
130+ for (i = 0; i < n; i++) {
131+ if (mvebu_a3700_comphy_modes[i].lane == lane &&
132+ mvebu_a3700_comphy_modes[i].port == port &&
133+ mvebu_a3700_comphy_modes[i].mode == mode &&
134+ mvebu_a3700_comphy_modes[i].submode == submode)
135+ break;
136+ }
137+
138+ if (i == n)
139+ return -EINVAL;
140+
141+ return mvebu_a3700_comphy_modes[i].fw_mode;
142+}
143+
144+static int mvebu_a3700_comphy_set_mode(struct phy *phy, enum phy_mode mode,
145+ int submode)
146+{
147+ struct mvebu_a3700_comphy_lane *lane = phy_get_drvdata(phy);
148+ int fw_mode;
149+
150+ if (submode == PHY_INTERFACE_MODE_1000BASEX)
151+ submode = PHY_INTERFACE_MODE_SGMII;
152+
153+ fw_mode = mvebu_a3700_comphy_get_fw_mode(lane->id, lane->port, mode,
154+ submode);
155+ if (fw_mode < 0) {
156+ dev_err(lane->dev, "invalid COMPHY mode\n");
157+ return fw_mode;
158+ }
159+
160+ /* Just remember the mode, ->power_on() will do the real setup */
161+ lane->mode = mode;
162+ lane->submode = submode;
163+
164+ return 0;
165+}
166+
167+static int mvebu_a3700_comphy_power_on(struct phy *phy)
168+{
169+ struct mvebu_a3700_comphy_lane *lane = phy_get_drvdata(phy);
170+ u32 fw_param;
171+ int fw_mode;
172+
173+ fw_mode = mvebu_a3700_comphy_get_fw_mode(lane->id, lane->port,
174+ lane->mode, lane->submode);
175+ if (fw_mode < 0) {
176+ dev_err(lane->dev, "invalid COMPHY mode\n");
177+ return fw_mode;
178+ }
179+
180+ switch (lane->mode) {
181+ case PHY_MODE_USB_HOST_SS:
182+ dev_dbg(lane->dev, "set lane %d to USB3 host mode\n", lane->id);
183+ fw_param = COMPHY_FW_MODE(fw_mode);
184+ break;
185+ case PHY_MODE_SATA:
186+ dev_dbg(lane->dev, "set lane %d to SATA mode\n", lane->id);
187+ fw_param = COMPHY_FW_MODE(fw_mode);
188+ break;
189+ case PHY_MODE_ETHERNET:
190+ switch (lane->submode) {
191+ case PHY_INTERFACE_MODE_SGMII:
192+ dev_dbg(lane->dev, "set lane %d to SGMII mode\n",
193+ lane->id);
194+ fw_param = COMPHY_FW_NET(fw_mode, lane->port,
195+ COMPHY_FW_SPEED_1_25G);
196+ break;
197+ case PHY_INTERFACE_MODE_2500BASEX:
198+ dev_dbg(lane->dev, "set lane %d to HS SGMII mode\n",
199+ lane->id);
200+ fw_param = COMPHY_FW_NET(fw_mode, lane->port,
201+ COMPHY_FW_SPEED_3_125G);
202+ break;
203+ default:
204+ dev_err(lane->dev, "unsupported PHY submode (%d)\n",
205+ lane->submode);
206+ return -ENOTSUPP;
207+ }
208+ break;
209+ case PHY_MODE_PCIE:
210+ dev_dbg(lane->dev, "set lane %d to PCIe mode\n", lane->id);
211+ fw_param = COMPHY_FW_PCIE(fw_mode, lane->port,
212+ COMPHY_FW_SPEED_5G,
213+ phy->attrs.bus_width);
214+ break;
215+ default:
216+ dev_err(lane->dev, "unsupported PHY mode (%d)\n", lane->mode);
217+ return -ENOTSUPP;
218+ }
219+
220+ return mvebu_a3700_comphy_smc(COMPHY_SIP_POWER_ON, lane->id, fw_param);
221+}
222+
223+static int mvebu_a3700_comphy_power_off(struct phy *phy)
224+{
225+ struct mvebu_a3700_comphy_lane *lane = phy_get_drvdata(phy);
226+
227+ return mvebu_a3700_comphy_smc(COMPHY_SIP_POWER_OFF, lane->id, 0);
228+}
229+
230+static const struct phy_ops mvebu_a3700_comphy_ops = {
231+ .power_on = mvebu_a3700_comphy_power_on,
232+ .power_off = mvebu_a3700_comphy_power_off,
233+ .set_mode = mvebu_a3700_comphy_set_mode,
234+ .owner = THIS_MODULE,
235+};
236+
237+static struct phy *mvebu_a3700_comphy_xlate(struct device *dev,
238+ struct of_phandle_args *args)
239+{
240+ struct mvebu_a3700_comphy_lane *lane;
241+ struct phy *phy;
242+
243+ if (WARN_ON(args->args[0] >= MVEBU_A3700_COMPHY_PORTS))
244+ return ERR_PTR(-EINVAL);
245+
246+ phy = of_phy_simple_xlate(dev, args);
247+ if (IS_ERR(phy))
248+ return phy;
249+
250+ lane = phy_get_drvdata(phy);
251+ lane->port = args->args[0];
252+
253+ return phy;
254+}
255+
256+static int mvebu_a3700_comphy_probe(struct platform_device *pdev)
257+{
258+ struct phy_provider *provider;
259+ struct device_node *child;
260+
261+ for_each_available_child_of_node(pdev->dev.of_node, child) {
262+ struct mvebu_a3700_comphy_lane *lane;
263+ struct phy *phy;
264+ int ret;
265+ u32 lane_id;
266+
267+ ret = of_property_read_u32(child, "reg", &lane_id);
268+ if (ret < 0) {
269+ dev_err(&pdev->dev, "missing 'reg' property (%d)\n",
270+ ret);
271+ continue;
272+ }
273+
274+ if (lane_id >= MVEBU_A3700_COMPHY_LANES) {
275+ dev_err(&pdev->dev, "invalid 'reg' property\n");
276+ continue;
277+ }
278+
279+ lane = devm_kzalloc(&pdev->dev, sizeof(*lane), GFP_KERNEL);
280+ if (!lane)
281+ return -ENOMEM;
282+
283+ phy = devm_phy_create(&pdev->dev, child,
284+ &mvebu_a3700_comphy_ops);
285+ if (IS_ERR(phy))
286+ return PTR_ERR(phy);
287+
288+ lane->dev = &pdev->dev;
289+ lane->mode = PHY_MODE_INVALID;
290+ lane->submode = PHY_INTERFACE_MODE_NA;
291+ lane->id = lane_id;
292+ lane->port = -1;
293+ phy_set_drvdata(phy, lane);
294+ }
295+
296+ provider = devm_of_phy_provider_register(&pdev->dev,
297+ mvebu_a3700_comphy_xlate);
298+ return PTR_ERR_OR_ZERO(provider);
299+}
300+
301+static const struct of_device_id mvebu_a3700_comphy_of_match_table[] = {
302+ { .compatible = "marvell,comphy-a3700" },
303+ { },
304+};
305+MODULE_DEVICE_TABLE(of, mvebu_a3700_comphy_of_match_table);
306+
307+static struct platform_driver mvebu_a3700_comphy_driver = {
308+ .probe = mvebu_a3700_comphy_probe,
309+ .driver = {
310+ .name = "mvebu-a3700-comphy",
311+ .of_match_table = mvebu_a3700_comphy_of_match_table,
312+ },
313+};
314+module_platform_driver(mvebu_a3700_comphy_driver);
315+
316+MODULE_AUTHOR("Miquèl Raynal <miquel.raynal@bootlin.com>");
317+MODULE_DESCRIPTION("Common PHY driver for A3700");
318+MODULE_LICENSE("GPL v2");
drivers/phy/marvell/phy-mvebu-a3700-utmi.c+278−0
@@ -0,0 +1,278 @@
1+// SPDX-License-Identifier: GPL-2.0
2+/*
3+ * Copyright (C) 2018 Marvell
4+ *
5+ * Authors:
6+ * Igal Liberman <igall@marvell.com>
7+ * Miquèl Raynal <miquel.raynal@bootlin.com>
8+ *
9+ * Marvell A3700 UTMI PHY driver
10+ */
11+
12+#include <linux/io.h>
13+#include <linux/iopoll.h>
14+#include <linux/mfd/syscon.h>
15+#include <linux/module.h>
16+#include <linux/of_device.h>
17+#include <linux/phy/phy.h>
18+#include <linux/platform_device.h>
19+#include <linux/regmap.h>
20+
21+/* Armada 3700 UTMI PHY registers */
22+#define USB2_PHY_PLL_CTRL_REG0 0x0
23+#define PLL_REF_DIV_OFF 0
24+#define PLL_REF_DIV_MASK GENMASK(6, 0)
25+#define PLL_REF_DIV_5 5
26+#define PLL_FB_DIV_OFF 16
27+#define PLL_FB_DIV_MASK GENMASK(24, 16)
28+#define PLL_FB_DIV_96 96
29+#define PLL_SEL_LPFR_OFF 28
30+#define PLL_SEL_LPFR_MASK GENMASK(29, 28)
31+#define PLL_READY BIT(31)
32+#define USB2_PHY_CAL_CTRL 0x8
33+#define PHY_PLLCAL_DONE BIT(31)
34+#define PHY_IMPCAL_DONE BIT(23)
35+#define USB2_RX_CHAN_CTRL1 0x18
36+#define USB2PHY_SQCAL_DONE BIT(31)
37+#define USB2_PHY_OTG_CTRL 0x34
38+#define PHY_PU_OTG BIT(4)
39+#define USB2_PHY_CHRGR_DETECT 0x38
40+#define PHY_CDP_EN BIT(2)
41+#define PHY_DCP_EN BIT(3)
42+#define PHY_PD_EN BIT(4)
43+#define PHY_PU_CHRG_DTC BIT(5)
44+#define PHY_CDP_DM_AUTO BIT(7)
45+#define PHY_ENSWITCH_DP BIT(12)
46+#define PHY_ENSWITCH_DM BIT(13)
47+
48+/* Armada 3700 USB miscellaneous registers */
49+#define USB2_PHY_CTRL(usb32) (usb32 ? 0x20 : 0x4)
50+#define RB_USB2PHY_PU BIT(0)
51+#define USB2_DP_PULLDN_DEV_MODE BIT(5)
52+#define USB2_DM_PULLDN_DEV_MODE BIT(6)
53+#define RB_USB2PHY_SUSPM(usb32) (usb32 ? BIT(14) : BIT(7))
54+
55+#define PLL_LOCK_DELAY_US 10000
56+#define PLL_LOCK_TIMEOUT_US 1000000
57+
58+/**
59+ * struct mvebu_a3700_utmi_caps - PHY capabilities
60+ *
61+ * @usb32: Flag indicating which PHY is in use (impacts the register map):
62+ * - The UTMI PHY wired to the USB3/USB2 controller (otg)
63+ * - The UTMI PHY wired to the USB2 controller (host only)
64+ * @ops: PHY operations
65+ */
66+struct mvebu_a3700_utmi_caps {
67+ int usb32;
68+ const struct phy_ops *ops;
69+};
70+
71+/**
72+ * struct mvebu_a3700_utmi - PHY driver data
73+ *
74+ * @regs: PHY registers
75+ * @usb_mis: Regmap with USB miscellaneous registers including PHY ones
76+ * @caps: PHY capabilities
77+ * @phy: PHY handle
78+ */
79+struct mvebu_a3700_utmi {
80+ void __iomem *regs;
81+ struct regmap *usb_misc;
82+ const struct mvebu_a3700_utmi_caps *caps;
83+ struct phy *phy;
84+};
85+
86+static int mvebu_a3700_utmi_phy_power_on(struct phy *phy)
87+{
88+ struct mvebu_a3700_utmi *utmi = phy_get_drvdata(phy);
89+ struct device *dev = &phy->dev;
90+ int usb32 = utmi->caps->usb32;
91+ int ret = 0;
92+ u32 reg;
93+
94+ /*
95+ * Setup PLL. 40MHz clock used to be the default, being 25MHz now.
96+ * See "PLL Settings for Typical REFCLK" table.
97+ */
98+ reg = readl(utmi->regs + USB2_PHY_PLL_CTRL_REG0);
99+ reg &= ~(PLL_REF_DIV_MASK | PLL_FB_DIV_MASK | PLL_SEL_LPFR_MASK);
100+ reg |= (PLL_REF_DIV_5 << PLL_REF_DIV_OFF) |
101+ (PLL_FB_DIV_96 << PLL_FB_DIV_OFF);
102+ writel(reg, utmi->regs + USB2_PHY_PLL_CTRL_REG0);
103+
104+ /* Enable PHY pull up and disable USB2 suspend */
105+ regmap_update_bits(utmi->usb_misc, USB2_PHY_CTRL(usb32),
106+ RB_USB2PHY_SUSPM(usb32) | RB_USB2PHY_PU,
107+ RB_USB2PHY_SUSPM(usb32) | RB_USB2PHY_PU);
108+
109+ if (usb32) {
110+ /* Power up OTG module */
111+ reg = readl(utmi->regs + USB2_PHY_OTG_CTRL);
112+ reg |= PHY_PU_OTG;
113+ writel(reg, utmi->regs + USB2_PHY_OTG_CTRL);
114+
115+ /* Disable PHY charger detection */
116+ reg = readl(utmi->regs + USB2_PHY_CHRGR_DETECT);
117+ reg &= ~(PHY_CDP_EN | PHY_DCP_EN | PHY_PD_EN | PHY_PU_CHRG_DTC |
118+ PHY_CDP_DM_AUTO | PHY_ENSWITCH_DP | PHY_ENSWITCH_DM);
119+ writel(reg, utmi->regs + USB2_PHY_CHRGR_DETECT);
120+
121+ /* Disable PHY DP/DM pull-down (used for device mode) */
122+ regmap_update_bits(utmi->usb_misc, USB2_PHY_CTRL(usb32),
123+ USB2_DP_PULLDN_DEV_MODE |
124+ USB2_DM_PULLDN_DEV_MODE, 0);
125+ }
126+
127+ /* Wait for PLL calibration */
128+ ret = readl_poll_timeout(utmi->regs + USB2_PHY_CAL_CTRL, reg,
129+ reg & PHY_PLLCAL_DONE,
130+ PLL_LOCK_DELAY_US, PLL_LOCK_TIMEOUT_US);
131+ if (ret) {
132+ dev_err(dev, "Failed to end USB2 PLL calibration\n");
133+ return ret;
134+ }
135+
136+ /* Wait for impedance calibration */
137+ ret = readl_poll_timeout(utmi->regs + USB2_PHY_CAL_CTRL, reg,
138+ reg & PHY_IMPCAL_DONE,
139+ PLL_LOCK_DELAY_US, PLL_LOCK_TIMEOUT_US);
140+ if (ret) {
141+ dev_err(dev, "Failed to end USB2 impedance calibration\n");
142+ return ret;
143+ }
144+
145+ /* Wait for squelch calibration */
146+ ret = readl_poll_timeout(utmi->regs + USB2_RX_CHAN_CTRL1, reg,
147+ reg & USB2PHY_SQCAL_DONE,
148+ PLL_LOCK_DELAY_US, PLL_LOCK_TIMEOUT_US);
149+ if (ret) {
150+ dev_err(dev, "Failed to end USB2 unknown calibration\n");
151+ return ret;
152+ }
153+
154+ /* Wait for PLL to be locked */
155+ ret = readl_poll_timeout(utmi->regs + USB2_PHY_PLL_CTRL_REG0, reg,
156+ reg & PLL_READY,
157+ PLL_LOCK_DELAY_US, PLL_LOCK_TIMEOUT_US);
158+ if (ret)
159+ dev_err(dev, "Failed to lock USB2 PLL\n");
160+
161+ return ret;
162+}
163+
164+static int mvebu_a3700_utmi_phy_power_off(struct phy *phy)
165+{
166+ struct mvebu_a3700_utmi *utmi = phy_get_drvdata(phy);
167+ int usb32 = utmi->caps->usb32;
168+ u32 reg;
169+
170+ /* Disable PHY pull-up and enable USB2 suspend */
171+ reg = readl(utmi->regs + USB2_PHY_CTRL(usb32));
172+ reg &= ~(RB_USB2PHY_PU | RB_USB2PHY_SUSPM(usb32));
173+ writel(reg, utmi->regs + USB2_PHY_CTRL(usb32));
174+
175+ /* Power down OTG module */
176+ if (usb32) {
177+ reg = readl(utmi->regs + USB2_PHY_OTG_CTRL);
178+ reg &= ~PHY_PU_OTG;
179+ writel(reg, utmi->regs + USB2_PHY_OTG_CTRL);
180+ }
181+
182+ return 0;
183+}
184+
185+static const struct phy_ops mvebu_a3700_utmi_phy_ops = {
186+ .power_on = mvebu_a3700_utmi_phy_power_on,
187+ .power_off = mvebu_a3700_utmi_phy_power_off,
188+ .owner = THIS_MODULE,
189+};
190+
191+static const struct mvebu_a3700_utmi_caps mvebu_a3700_utmi_otg_phy_caps = {
192+ .usb32 = true,
193+ .ops = &mvebu_a3700_utmi_phy_ops,
194+};
195+
196+static const struct mvebu_a3700_utmi_caps mvebu_a3700_utmi_host_phy_caps = {
197+ .usb32 = false,
198+ .ops = &mvebu_a3700_utmi_phy_ops,
199+};
200+
201+static const struct of_device_id mvebu_a3700_utmi_of_match[] = {
202+ {
203+ .compatible = "marvell,a3700-utmi-otg-phy",
204+ .data = &mvebu_a3700_utmi_otg_phy_caps,
205+ },
206+ {
207+ .compatible = "marvell,a3700-utmi-host-phy",
208+ .data = &mvebu_a3700_utmi_host_phy_caps,
209+ },
210+ {},
211+};
212+MODULE_DEVICE_TABLE(of, mvebu_a3700_utmi_of_match);
213+
214+static int mvebu_a3700_utmi_phy_probe(struct platform_device *pdev)
215+{
216+ struct device *dev = &pdev->dev;
217+ struct mvebu_a3700_utmi *utmi;
218+ struct phy_provider *provider;
219+ struct resource *res;
220+
221+ utmi = devm_kzalloc(dev, sizeof(*utmi), GFP_KERNEL);
222+ if (!utmi)
223+ return -ENOMEM;
224+
225+ /* Get UTMI memory region */
226+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
227+ if (!res) {
228+ dev_err(dev, "Missing UTMI PHY memory resource\n");
229+ return -ENODEV;
230+ }
231+
232+ utmi->regs = devm_ioremap_resource(dev, res);
233+ if (IS_ERR(utmi->regs))
234+ return PTR_ERR(utmi->regs);
235+
236+ /* Get miscellaneous Host/PHY region */
237+ utmi->usb_misc = syscon_regmap_lookup_by_phandle(dev->of_node,
238+ "marvell,usb-misc-reg");
239+ if (IS_ERR(utmi->usb_misc)) {
240+ dev_err(dev,
241+ "Missing USB misc purpose system controller\n");
242+ return PTR_ERR(utmi->usb_misc);
243+ }
244+
245+ /* Retrieve PHY capabilities */
246+ utmi->caps = of_device_get_match_data(dev);
247+
248+ /* Instantiate the PHY */
249+ utmi->phy = devm_phy_create(dev, NULL, utmi->caps->ops);
250+ if (IS_ERR(utmi->phy)) {
251+ dev_err(dev, "Failed to create the UTMI PHY\n");
252+ return PTR_ERR(utmi->phy);
253+ }
254+
255+ phy_set_drvdata(utmi->phy, utmi);
256+
257+ /* Ensure the PHY is powered off */
258+ utmi->caps->ops->power_off(utmi->phy);
259+
260+ provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
261+
262+ return PTR_ERR_OR_ZERO(provider);
263+}
264+
265+static struct platform_driver mvebu_a3700_utmi_driver = {
266+ .probe = mvebu_a3700_utmi_phy_probe,
267+ .driver = {
268+ .name = "mvebu-a3700-utmi-phy",
269+ .owner = THIS_MODULE,
270+ .of_match_table = mvebu_a3700_utmi_of_match,
271+ },
272+};
273+module_platform_driver(mvebu_a3700_utmi_driver);
274+
275+MODULE_AUTHOR("Igal Liberman <igall@marvell.com>");
276+MODULE_AUTHOR("Miquel Raynal <miquel.raynal@bootlin.com>");
277+MODULE_DESCRIPTION("Marvell EBU A3700 UTMI PHY driver");
278+MODULE_LICENSE("GPL v2");
drivers/phy/marvell/phy-mvebu-cp110-comphy.c+0−2
@@ -580,8 +580,6 @@ static struct phy *mvebu_comphy_xlate(struct device *dev, · 579 unmodified lines
580580 return phy;
581581
582582 lane = phy_get_drvdata(phy);
583− if (lane->port >= 0)
584− return ERR_PTR(-EBUSY);
585583 lane->port = args->args[0];
586584
587585 return phy;
drivers/phy/marvell/phy-mvebu-sata.c+2−7
@@ -10,7 +10,7 @@ · 9 unmodified lines
1010 */
1111
1212 #include <linux/kernel.h>
13−#include <linux/module.h>
13+#include <linux/init.h>
1414 #include <linux/clk.h>
1515 #include <linux/phy/phy.h>
1616 #include <linux/io.h>
@@ -122,7 +122,6 @@ static const struct of_device_id phy_mvebu_sata_of_match[] = { · 105 unmodified lines
122122 { .compatible = "marvell,mvebu-sata-phy" },
123123 { },
124124 };
125−MODULE_DEVICE_TABLE(of, phy_mvebu_sata_of_match);
126125
127126 static struct platform_driver phy_mvebu_sata_driver = {
128127 .probe = phy_mvebu_sata_probe,
@@ -131,8 +130,4 @@ static struct platform_driver phy_mvebu_sata_driver = { · 2 unmodified lines
131130 .of_match_table = phy_mvebu_sata_of_match,
132131 }
133132 };
134−module_platform_driver(phy_mvebu_sata_driver);
135−
136−MODULE_AUTHOR("Andrew Lunn <andrew@lunn.ch>");
137−MODULE_DESCRIPTION("Marvell MVEBU SATA PHY driver");
138−MODULE_LICENSE("GPL v2");
133+builtin_platform_driver(phy_mvebu_sata_driver);
drivers/phy/phy-core-mipi-dphy.c+4−4
@@ -65,12 +65,12 @@ int phy_mipi_dphy_get_default_config(unsigned long pixel_clock, · 64 unmodified lines
6565 */
6666 cfg->hs_trail = max(4 * 8 * ui, 60000 + 4 * 4 * ui);
6767
68− cfg->init = 100000000;
68+ cfg->init = 100;
6969 cfg->lpx = 60000;
7070 cfg->ta_get = 5 * cfg->lpx;
7171 cfg->ta_go = 4 * cfg->lpx;
7272 cfg->ta_sure = 2 * cfg->lpx;
73− cfg->wakeup = 1000000000;
73+ cfg->wakeup = 1000;
7474
7575 cfg->hs_clk_rate = hs_clk_rate;
7676 cfg->lanes = lanes;
@@ -143,7 +143,7 @@ int phy_mipi_dphy_config_validate(struct phy_configure_opts_mipi_dphy *cfg) · 66 unmodified lines
143143 if (cfg->hs_trail < max(8 * ui, 60000 + 4 * ui))
144144 return -EINVAL;
145145
146− if (cfg->init < 100000000)
146+ if (cfg->init < 100)
147147 return -EINVAL;
148148
149149 if (cfg->lpx < 50000)
@@ -158,7 +158,7 @@ int phy_mipi_dphy_config_validate(struct phy_configure_opts_mipi_dphy *cfg) · 8 unmodified lines
158158 if (cfg->ta_sure < cfg->lpx || cfg->ta_sure > (2 * cfg->lpx))
159159 return -EINVAL;
160160
161− if (cfg->wakeup < 1000000000)
161+ if (cfg->wakeup < 1000)
162162 return -EINVAL;
163163
164164 return 0;
drivers/phy/phy-core.c+1−11
@@ -1112,14 +1112,4 @@ static int __init phy_core_init(void) · 1111 unmodified lines
11121112
11131113 return 0;
11141114 }
1115−module_init(phy_core_init);
1116−
1117−static void __exit phy_core_exit(void)
1118−{
1119− class_destroy(phy_class);
1120−}
1121−module_exit(phy_core_exit);
1122−
1123−MODULE_DESCRIPTION("Generic PHY Framework");
1124−MODULE_AUTHOR("Kishon Vijay Abraham I <kishon@ti.com>");
1125−MODULE_LICENSE("GPL v2");
1115+device_initcall(phy_core_init);
drivers/phy/qualcomm/phy-qcom-qmp.c+143−0
@@ -687,6 +687,116 @@ static const struct qmp_phy_init_tbl sdm845_ufsphy_pcs_tbl[] = { · 686 unmodified lines
687687 QMP_PHY_INIT_CFG(QPHY_V3_PCS_MULTI_LANE_CTRL1, 0x02),
688688 };
689689
690+static const struct qmp_phy_init_tbl msm8998_usb3_serdes_tbl[] = {
691+ QMP_PHY_INIT_CFG(QSERDES_V3_COM_CLK_SELECT, 0x30),
692+ QMP_PHY_INIT_CFG(QSERDES_V3_COM_BIAS_EN_CLKBUFLR_EN, 0x04),
693+ QMP_PHY_INIT_CFG(QSERDES_V3_COM_SYSCLK_EN_SEL, 0x14),
694+ QMP_PHY_INIT_CFG(QSERDES_V3_COM_SYS_CLK_CTRL, 0x06),
695+ QMP_PHY_INIT_CFG(QSERDES_V3_COM_RESETSM_CNTRL2, 0x08),
696+ QMP_PHY_INIT_CFG(QSERDES_V3_COM_CMN_CONFIG, 0x06),
697+ QMP_PHY_INIT_CFG(QSERDES_V3_COM_SVS_MODE_CLK_SEL, 0x01),
698+ QMP_PHY_INIT_CFG(QSERDES_V3_COM_HSCLK_SEL, 0x80),
699+ QMP_PHY_INIT_CFG(QSERDES_V3_COM_DEC_START_MODE0, 0x82),
700+ QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START1_MODE0, 0xab),
701+ QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START2_MODE0, 0xea),
702+ QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START3_MODE0, 0x02),
703+ QMP_PHY_INIT_CFG(QSERDES_V3_COM_CP_CTRL_MODE0, 0x06),
704+ QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_RCTRL_MODE0, 0x16),
705+ QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_CCTRL_MODE0, 0x36),
706+ QMP_PHY_INIT_CFG(QSERDES_V3_COM_INTEGLOOP_GAIN1_MODE0, 0x00),
707+ QMP_PHY_INIT_CFG(QSERDES_V3_COM_INTEGLOOP_GAIN0_MODE0, 0x3f),
708+ QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE2_MODE0, 0x01),
709+ QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE1_MODE0, 0xc9),
710+ QMP_PHY_INIT_CFG(QSERDES_V3_COM_CORECLK_DIV_MODE0, 0x0a),
711+ QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP3_MODE0, 0x00),
712+ QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP2_MODE0, 0x34),
713+ QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP1_MODE0, 0x15),
714+ QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP_EN, 0x04),
715+ QMP_PHY_INIT_CFG(QSERDES_V3_COM_CORE_CLK_EN, 0x00),
716+ QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP_CFG, 0x00),
717+ QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE_MAP, 0x00),
718+ QMP_PHY_INIT_CFG(QSERDES_V3_COM_BG_TIMER, 0x0a),
719+ QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_IVCO, 0x07),
720+ QMP_PHY_INIT_CFG(QSERDES_V3_COM_INTEGLOOP_INITVAL, 0x80),
721+ QMP_PHY_INIT_CFG(QSERDES_V3_COM_CMN_MODE, 0x01),
722+ QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_EN_CENTER, 0x01),
723+ QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_PER1, 0x31),
724+ QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_PER2, 0x01),
725+ QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_ADJ_PER1, 0x00),
726+ QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_ADJ_PER2, 0x00),
727+ QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_STEP_SIZE1, 0x85),
728+ QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_STEP_SIZE2, 0x07),
729+};
730+
731+static const struct qmp_phy_init_tbl msm8998_usb3_tx_tbl[] = {
732+ QMP_PHY_INIT_CFG(QSERDES_V3_TX_HIGHZ_DRVR_EN, 0x10),
733+ QMP_PHY_INIT_CFG(QSERDES_V3_TX_RCV_DETECT_LVL_2, 0x12),
734+ QMP_PHY_INIT_CFG(QSERDES_V3_TX_LANE_MODE_1, 0x16),
735+ QMP_PHY_INIT_CFG(QSERDES_V3_TX_RES_CODE_LANE_OFFSET_TX, 0x00),
736+};
737+
738+static const struct qmp_phy_init_tbl msm8998_usb3_rx_tbl[] = {
739+ QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_FASTLOCK_FO_GAIN, 0x0b),
740+ QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL2, 0x0f),
741+ QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL3, 0x4e),
742+ QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL4, 0x18),
743+ QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQ_OFFSET_ADAPTOR_CNTRL1, 0x07),
744+ QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_OFFSET_ADAPTOR_CNTRL2, 0x80),
745+ QMP_PHY_INIT_CFG(QSERDES_V3_RX_SIGDET_CNTRL, 0x43),
746+ QMP_PHY_INIT_CFG(QSERDES_V3_RX_SIGDET_DEGLITCH_CNTRL, 0x1c),
747+ QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_SO_SATURATION_AND_ENABLE, 0x75),
748+ QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_FASTLOCK_COUNT_LOW, 0x00),
749+ QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_FASTLOCK_COUNT_HIGH, 0x00),
750+ QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_PI_CONTROLS, 0x80),
751+ QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_FO_GAIN, 0x0a),
752+ QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_SO_GAIN, 0x06),
753+ QMP_PHY_INIT_CFG(QSERDES_V3_RX_SIGDET_ENABLES, 0x00),
754+ QMP_PHY_INIT_CFG(QSERDES_V3_RX_VGA_CAL_CNTRL2, 0x03),
755+ QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_MODE_00, 0x05),
756+};
757+
758+static const struct qmp_phy_init_tbl msm8998_usb3_pcs_tbl[] = {
759+ QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_CNTRL2, 0x83),
760+ QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_CNT_VAL_L, 0x09),
761+ QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_CNT_VAL_H_TOL, 0xa2),
762+ QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_MAN_CODE, 0x40),
763+ QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_CNTRL1, 0x02),
764+ QMP_PHY_INIT_CFG(QPHY_V3_PCS_LOCK_DETECT_CONFIG1, 0xd1),
765+ QMP_PHY_INIT_CFG(QPHY_V3_PCS_LOCK_DETECT_CONFIG2, 0x1f),
766+ QMP_PHY_INIT_CFG(QPHY_V3_PCS_LOCK_DETECT_CONFIG3, 0x47),
767+ QMP_PHY_INIT_CFG(QPHY_V3_PCS_POWER_STATE_CONFIG2, 0x1b),
768+ QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXMGN_V0, 0x9f),
769+ QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXMGN_V1, 0x9f),
770+ QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXMGN_V2, 0xb7),
771+ QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXMGN_V3, 0x4e),
772+ QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXMGN_V4, 0x65),
773+ QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXMGN_LS, 0x6b),
774+ QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M6DB_V0, 0x15),
775+ QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M3P5DB_V0, 0x0d),
776+ QMP_PHY_INIT_CFG(QPHY_V3_PCS_TX_LARGE_AMP_DRV_LVL, 0x15),
777+ QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M3P5DB_V1, 0x0d),
778+ QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M6DB_V2, 0x15),
779+ QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M3P5DB_V2, 0x0d),
780+ QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M6DB_V3, 0x15),
781+ QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M3P5DB_V3, 0x0d),
782+ QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M6DB_V4, 0x15),
783+ QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M3P5DB_V4, 0x0d),
784+ QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M6DB_LS, 0x15),
785+ QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M3P5DB_LS, 0x0d),
786+ QMP_PHY_INIT_CFG(QPHY_V3_PCS_RATE_SLEW_CNTRL, 0x02),
787+ QMP_PHY_INIT_CFG(QPHY_V3_PCS_PWRUP_RESET_DLY_TIME_AUXCLK, 0x04),
788+ QMP_PHY_INIT_CFG(QPHY_V3_PCS_TSYNC_RSYNC_TIME, 0x44),
789+ QMP_PHY_INIT_CFG(QPHY_V3_PCS_RCVR_DTCT_DLY_P1U2_L, 0xe7),
790+ QMP_PHY_INIT_CFG(QPHY_V3_PCS_RCVR_DTCT_DLY_P1U2_H, 0x03),
791+ QMP_PHY_INIT_CFG(QPHY_V3_PCS_RCVR_DTCT_DLY_U3_L, 0x40),
792+ QMP_PHY_INIT_CFG(QPHY_V3_PCS_RCVR_DTCT_DLY_U3_H, 0x00),
793+ QMP_PHY_INIT_CFG(QPHY_V3_PCS_RX_SIGDET_LVL, 0x8a),
794+ QMP_PHY_INIT_CFG(QPHY_V3_PCS_RXEQTRAINING_WAIT_TIME, 0x75),
795+ QMP_PHY_INIT_CFG(QPHY_V3_PCS_LFPS_TX_ECSTART_EQTLOCK, 0x86),
796+ QMP_PHY_INIT_CFG(QPHY_V3_PCS_RXEQTRAINING_RUN_TIME, 0x13),
797+};
798+
799+
690800 /* struct qmp_phy_cfg - per-PHY initialization config */
691801 struct qmp_phy_cfg {
692802 /* phy-type - PCIE/UFS/USB */
@@ -1036,6 +1146,33 @@ static const struct qmp_phy_cfg sdm845_ufsphy_cfg = { · 343 unmodified lines
10361146 .no_pcs_sw_reset = true,
10371147 };
10381148
1149+static const struct qmp_phy_cfg msm8998_usb3phy_cfg = {
1150+ .type = PHY_TYPE_USB3,
1151+ .nlanes = 1,
1152+
1153+ .serdes_tbl = msm8998_usb3_serdes_tbl,
1154+ .serdes_tbl_num = ARRAY_SIZE(msm8998_usb3_serdes_tbl),
1155+ .tx_tbl = msm8998_usb3_tx_tbl,
1156+ .tx_tbl_num = ARRAY_SIZE(msm8998_usb3_tx_tbl),
1157+ .rx_tbl = msm8998_usb3_rx_tbl,
1158+ .rx_tbl_num = ARRAY_SIZE(msm8998_usb3_rx_tbl),
1159+ .pcs_tbl = msm8998_usb3_pcs_tbl,
1160+ .pcs_tbl_num = ARRAY_SIZE(msm8998_usb3_pcs_tbl),
1161+ .clk_list = msm8996_phy_clk_l,
1162+ .num_clks = ARRAY_SIZE(msm8996_phy_clk_l),
1163+ .reset_list = msm8996_usb3phy_reset_l,
1164+ .num_resets = ARRAY_SIZE(msm8996_usb3phy_reset_l),
1165+ .vreg_list = qmp_phy_vreg_l,
1166+ .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l),
1167+ .regs = qmp_v3_usb3phy_regs_layout,
1168+
1169+ .start_ctrl = SERDES_START | PCS_START,
1170+ .pwrdn_ctrl = SW_PWRDN,
1171+ .mask_pcs_ready = PHYSTATUS,
1172+
1173+ .is_dual_lane_phy = true,
1174+};
1175+
10391176 static void qcom_qmp_phy_configure(void __iomem *base,
10401177 const unsigned int *regs,
10411178 const struct qmp_phy_init_tbl tbl[],
@@ -1735,6 +1872,9 @@ static const struct of_device_id qcom_qmp_phy_of_match_table[] = { · 693 unmodified lines
17351872 }, {
17361873 .compatible = "qcom,msm8996-qmp-usb3-phy",
17371874 .data = &msm8996_usb3phy_cfg,
1875+ }, {
1876+ .compatible = "qcom,msm8998-qmp-ufs-phy",
1877+ .data = &sdm845_ufsphy_cfg,
17381878 }, {
17391879 .compatible = "qcom,ipq8074-qmp-pcie-phy",
17401880 .data = &ipq8074_pciephy_cfg,
@@ -1747,6 +1887,9 @@ static const struct of_device_id qcom_qmp_phy_of_match_table[] = { · 6 unmodified lines
17471887 }, {
17481888 .compatible = "qcom,sdm845-qmp-ufs-phy",
17491889 .data = &sdm845_ufsphy_cfg,
1890+ }, {
1891+ .compatible = "qcom,msm8998-qmp-usb3-phy",
1892+ .data = &msm8998_usb3phy_cfg,
17501893 },
17511894 { },
17521895 };
drivers/phy/qualcomm/phy-qcom-qmp.h+4−0
@@ -174,6 +174,7 @@ · 173 unmodified lines
174174 #define QSERDES_V3_COM_DIV_FRAC_START1_MODE1 0x0c4
175175 #define QSERDES_V3_COM_DIV_FRAC_START2_MODE1 0x0c8
176176 #define QSERDES_V3_COM_DIV_FRAC_START3_MODE1 0x0cc
177+#define QSERDES_V3_COM_INTEGLOOP_INITVAL 0x0d0
177178 #define QSERDES_V3_COM_INTEGLOOP_GAIN0_MODE0 0x0d8
178179 #define QSERDES_V3_COM_INTEGLOOP_GAIN1_MODE0 0x0dc
179180 #define QSERDES_V3_COM_INTEGLOOP_GAIN0_MODE1 0x0e0
@@ -201,6 +202,7 @@ · 21 unmodified lines
201202 #define QSERDES_V3_COM_DEBUG_BUS2 0x170
202203 #define QSERDES_V3_COM_DEBUG_BUS3 0x174
203204 #define QSERDES_V3_COM_DEBUG_BUS_SEL 0x178
205+#define QSERDES_V3_COM_CMN_MODE 0x184
204206
205207 /* Only for QMP V3 PHY - TX registers */
206208 #define QSERDES_V3_TX_RES_CODE_LANE_OFFSET_TX 0x044
@@ -211,6 +213,7 @@ · 4 unmodified lines
211213 #define QSERDES_V3_TX_RCV_DETECT_LVL_2 0x0a4
212214
213215 /* Only for QMP V3 PHY - RX registers */
216+#define QSERDES_V3_RX_UCDR_FO_GAIN 0x008
214217 #define QSERDES_V3_RX_UCDR_SO_GAIN_HALF 0x00c
215218 #define QSERDES_V3_RX_UCDR_SO_GAIN 0x014
216219 #define QSERDES_V3_RX_UCDR_SVS_SO_GAIN_HALF 0x024
@@ -219,6 +222,7 @@ · 2 unmodified lines
219222 #define QSERDES_V3_RX_UCDR_FASTLOCK_FO_GAIN 0x030
220223 #define QSERDES_V3_RX_UCDR_SO_SATURATION_AND_ENABLE 0x034
221224 #define QSERDES_V3_RX_UCDR_FASTLOCK_COUNT_LOW 0x03c
225+#define QSERDES_V3_RX_UCDR_FASTLOCK_COUNT_HIGH 0x040
222226 #define QSERDES_V3_RX_UCDR_PI_CONTROLS 0x044
223227 #define QSERDES_V3_RX_RX_TERM_BW 0x07c
224228 #define QSERDES_V3_RX_VGA_CAL_CNTRL1 0x0bc
drivers/phy/qualcomm/phy-qcom-qusb2.c+40−0
@@ -152,6 +152,31 @@ static const struct qusb2_phy_init_tbl msm8996_init_tbl[] = { · 151 unmodified lines
152152 QUSB2_PHY_INIT_CFG(QUSB2PHY_PLL_PWR_CTRL, 0x00),
153153 };
154154
155+static const unsigned int msm8998_regs_layout[] = {
156+ [QUSB2PHY_PLL_CORE_INPUT_OVERRIDE] = 0xa8,
157+ [QUSB2PHY_PLL_STATUS] = 0x1a0,
158+ [QUSB2PHY_PORT_TUNE1] = 0x23c,
159+ [QUSB2PHY_PORT_TUNE2] = 0x240,
160+ [QUSB2PHY_PORT_TUNE3] = 0x244,
161+ [QUSB2PHY_PORT_TUNE4] = 0x248,
162+ [QUSB2PHY_PORT_TEST1] = 0x24c,
163+ [QUSB2PHY_PORT_TEST2] = 0x250,
164+ [QUSB2PHY_PORT_POWERDOWN] = 0x210,
165+ [QUSB2PHY_INTR_CTRL] = 0x22c,
166+};
167+
168+static const struct qusb2_phy_init_tbl msm8998_init_tbl[] = {
169+ QUSB2_PHY_INIT_CFG(QUSB2PHY_PLL_ANALOG_CONTROLS_TWO, 0x13),
170+ QUSB2_PHY_INIT_CFG(QUSB2PHY_PLL_CLOCK_INVERTERS, 0x7c),
171+ QUSB2_PHY_INIT_CFG(QUSB2PHY_PLL_CMODE, 0x80),
172+ QUSB2_PHY_INIT_CFG(QUSB2PHY_PLL_LOCK_DELAY, 0x0a),
173+
174+ QUSB2_PHY_INIT_CFG_L(QUSB2PHY_PORT_TUNE1, 0xa5),
175+ QUSB2_PHY_INIT_CFG_L(QUSB2PHY_PORT_TUNE2, 0x09),
176+
177+ QUSB2_PHY_INIT_CFG(QUSB2PHY_PLL_DIGITAL_TIMERS_TWO, 0x19),
178+};
179+
155180 static const unsigned int sdm845_regs_layout[] = {
156181 [QUSB2PHY_PLL_CORE_INPUT_OVERRIDE] = 0xa8,
157182 [QUSB2PHY_PLL_STATUS] = 0x1a0,
@@ -221,6 +246,18 @@ static const struct qusb2_phy_cfg msm8996_phy_cfg = { · 63 unmodified lines
221246 .autoresume_en = BIT(3),
222247 };
223248
249+static const struct qusb2_phy_cfg msm8998_phy_cfg = {
250+ .tbl = msm8998_init_tbl,
251+ .tbl_num = ARRAY_SIZE(msm8998_init_tbl),
252+ .regs = msm8998_regs_layout,
253+
254+ .disable_ctrl = POWER_DOWN,
255+ .mask_core_ready = CORE_READY_STATUS,
256+ .has_pll_override = true,
257+ .autoresume_en = BIT(0),
258+ .update_tune1_with_efuse = true,
259+};
260+
224261 static const struct qusb2_phy_cfg sdm845_phy_cfg = {
225262 .tbl = sdm845_init_tbl,
226263 .tbl_num = ARRAY_SIZE(sdm845_init_tbl),
@@ -733,6 +770,9 @@ static const struct of_device_id qusb2_phy_of_match_table[] = { · 506 unmodified lines
733770 {
734771 .compatible = "qcom,msm8996-qusb2-phy",
735772 .data = &msm8996_phy_cfg,
773+ }, {
774+ .compatible = "qcom,msm8998-qusb2-phy",
775+ .data = &msm8998_phy_cfg,
736776 }, {
737777 .compatible = "qcom,sdm845-qusb2-phy",
738778 .data = &sdm845_phy_cfg,
drivers/phy/qualcomm/phy-qcom-ufs-i.h+1−18
@@ -23,24 +23,7 @@ · 22 unmodified lines
2323 #include <linux/platform_device.h>
2424 #include <linux/io.h>
2525 #include <linux/delay.h>
26−
27−#define readl_poll_timeout(addr, val, cond, sleep_us, timeout_us) \
28−({ \
29− ktime_t timeout = ktime_add_us(ktime_get(), timeout_us); \
30− might_sleep_if(timeout_us); \
31− for (;;) { \
32− (val) = readl(addr); \
33− if (cond) \
34− break; \
35− if (timeout_us && ktime_compare(ktime_get(), timeout) > 0) { \
36− (val) = readl(addr); \
37− break; \
38− } \
39− if (sleep_us) \
40− usleep_range(DIV_ROUND_UP(sleep_us, 4), sleep_us); \
41− } \
42− (cond) ? 0 : -ETIMEDOUT; \
43−})
26+#include <linux/iopoll.h>
4427
4528 #define UFS_QCOM_PHY_CAL_ENTRY(reg, val) \
4629 { \
drivers/phy/rockchip/phy-rockchip-inno-usb2.c+20−28
@@ -55,16 +55,16 @@ enum rockchip_usb2phy_host_state { · 54 unmodified lines
5555 };
5656
5757 /**
58− * Different states involved in USB charger detection.
59− * USB_CHG_STATE_UNDEFINED USB charger is not connected or detection
58+ * enum usb_chg_state - Different states involved in USB charger detection.
59+ * @USB_CHG_STATE_UNDEFINED: USB charger is not connected or detection
6060 * process is not yet started.
61− * USB_CHG_STATE_WAIT_FOR_DCD Waiting for Data pins contact.
62− * USB_CHG_STATE_DCD_DONE Data pin contact is detected.
63− * USB_CHG_STATE_PRIMARY_DONE Primary detection is completed (Detects
61+ * @USB_CHG_STATE_WAIT_FOR_DCD: Waiting for Data pins contact.
62+ * @USB_CHG_STATE_DCD_DONE: Data pin contact is detected.
63+ * @USB_CHG_STATE_PRIMARY_DONE: Primary detection is completed (Detects
6464 * between SDP and DCP/CDP).
65− * USB_CHG_STATE_SECONDARY_DONE Secondary detection is completed (Detects
66− * between DCP and CDP).
67− * USB_CHG_STATE_DETECTED USB charger type is determined.
65+ * @USB_CHG_STATE_SECONDARY_DONE: Secondary detection is completed (Detects
66+ * between DCP and CDP).
67+ * @USB_CHG_STATE_DETECTED: USB charger type is determined.
6868 */
6969 enum usb_chg_state {
7070 USB_CHG_STATE_UNDEFINED = 0,
@@ -94,7 +94,7 @@ struct usb2phy_reg { · 23 unmodified lines
9494 };
9595
9696 /**
97− * struct rockchip_chg_det_reg: usb charger detect registers
97+ * struct rockchip_chg_det_reg - usb charger detect registers
9898 * @cp_det: charging port detected successfully.
9999 * @dcp_det: dedicated charging port detected successfully.
100100 * @dp_det: assert data pin connect successfully.
@@ -120,7 +120,7 @@ struct rockchip_chg_det_reg { · 19 unmodified lines
120120 };
121121
122122 /**
123− * struct rockchip_usb2phy_port_cfg: usb-phy port configuration.
123+ * struct rockchip_usb2phy_port_cfg - usb-phy port configuration.
124124 * @phy_sus: phy suspend register.
125125 * @bvalid_det_en: vbus valid rise detection enable register.
126126 * @bvalid_det_st: vbus valid rise detection status register.
@@ -148,10 +148,11 @@ struct rockchip_usb2phy_port_cfg { · 21 unmodified lines
148148 };
149149
150150 /**
151− * struct rockchip_usb2phy_cfg: usb-phy configuration.
151+ * struct rockchip_usb2phy_cfg - usb-phy configuration.
152152 * @reg: the address offset of grf for usb-phy config.
153153 * @num_ports: specify how many ports that the phy has.
154154 * @clkout_ctl: keep on/turn off output clk of phy.
155+ * @port_cfgs: usb-phy port configurations.
155156 * @chg_det: charger detection registers.
156157 */
157158 struct rockchip_usb2phy_cfg {
@@ -163,12 +164,10 @@ struct rockchip_usb2phy_cfg { · 5 unmodified lines
163164 };
164165
165166 /**
166− * struct rockchip_usb2phy_port: usb-phy port data.
167+ * struct rockchip_usb2phy_port - usb-phy port data.
168+ * @phy: generic phy.
167169 * @port_id: flag for otg port or host port.
168170 * @suspended: phy suspended flag.
169− * @utmi_avalid: utmi avalid status usage flag.
170− * true - use avalid to get vbus status
171− * flase - use bvalid to get vbus status
172171 * @vbus_attached: otg device vbus status.
173172 * @bvalid_irq: IRQ number assigned for vbus valid rise detection.
174173 * @ls_irq: IRQ number assigned for linestate detection.
@@ -178,7 +177,7 @@ struct rockchip_usb2phy_cfg { · 3 unmodified lines
178177 * @chg_work: charge detect work.
179178 * @otg_sm_work: OTG state machine work.
180179 * @sm_work: HOST state machine work.
181− * @phy_cfg: port register configuration, assigned by driver data.
180+ * @port_cfg: port register configuration, assigned by driver data.
182181 * @event_nb: hold event notification callback.
183182 * @state: define OTG enumeration states before device reset.
184183 * @mode: the dr_mode of the controller.
@@ -187,7 +186,6 @@ struct rockchip_usb2phy_port { · 2 unmodified lines
187186 struct phy *phy;
188187 unsigned int port_id;
189188 bool suspended;
190− bool utmi_avalid;
191189 bool vbus_attached;
192190 int bvalid_irq;
193191 int ls_irq;
@@ -203,12 +201,13 @@ struct rockchip_usb2phy_port { · 9 unmodified lines
203201 };
204202
205203 /**
206− * struct rockchip_usb2phy: usb2.0 phy driver data.
204+ * struct rockchip_usb2phy - usb2.0 phy driver data.
205+ * @dev: pointer to device.
207206 * @grf: General Register Files regmap.
208207 * @usbgrf: USB General Register Files regmap.
209208 * @clk: clock struct of phy input clk.
210209 * @clk480m: clock struct of phy output clk.
211− * @clk_hw: clock struct of phy output clk management.
210+ * @clk480m_hw: clock struct of phy output clk management.
212211 * @chg_state: states involved in USB charger detection.
213212 * @chg_type: USB charger types.
214213 * @dcd_retries: The retry count used to track Data contact
@@ -542,12 +541,8 @@ static void rockchip_usb2phy_otg_sm_work(struct work_struct *work) · 327 unmodified lines
542541 unsigned long delay;
543542 bool vbus_attach, sch_work, notify_charger;
544543
545− if (rport->utmi_avalid)
546− vbus_attach = property_enabled(rphy->grf,
547− &rport->port_cfg->utmi_avalid);
548− else
549− vbus_attach = property_enabled(rphy->grf,
550− &rport->port_cfg->utmi_bvalid);
544+ vbus_attach = property_enabled(rphy->grf,
545+ &rport->port_cfg->utmi_bvalid);
551546
552547 sch_work = false;
553548 notify_charger = false;
@@ -1021,9 +1016,6 @@ static int rockchip_usb2phy_otg_port_init(struct rockchip_usb2phy *rphy, · 467 unmodified lines
10211016 INIT_DELAYED_WORK(&rport->chg_work, rockchip_chg_detect_work);
10221017 INIT_DELAYED_WORK(&rport->otg_sm_work, rockchip_usb2phy_otg_sm_work);
10231018
1024− rport->utmi_avalid =
1025− of_property_read_bool(child_np, "rockchip,utmi-avalid");
1026−
10271019 /*
10281020 * Some SoCs use one interrupt with otg-id/otg-bvalid/linestate
10291021 * interrupts muxed together, so probe the otg-mux interrupt first,
drivers/phy/ti/Kconfig+2−4
@@ -33,12 +33,11 @@ config OMAP_CONTROL_PHY · 32 unmodified lines
3333
3434 config OMAP_USB2
3535 tristate "OMAP USB2 PHY Driver"
36− depends on ARCH_OMAP2PLUS
36+ depends on ARCH_OMAP2PLUS || ARCH_K3
3737 depends on USB_SUPPORT
3838 select GENERIC_PHY
3939 select USB_PHY
40− select OMAP_CONTROL_PHY
41− depends on OMAP_OCP2SCP
40+ select OMAP_CONTROL_PHY if ARCH_OMAP2PLUS
4241 help
4342 Enable this to support the transceiver that is part of SOC. This
4443 driver takes care of all the PHY functionality apart from comparator.
@@ -50,7 +49,6 @@ config TI_PIPE3 · 5 unmodified lines
5049 depends on ARCH_OMAP2PLUS || COMPILE_TEST
5150 select GENERIC_PHY
5251 select OMAP_CONTROL_PHY
53− depends on OMAP_OCP2SCP
5452 help
5553 Enable this to support the PIPE3 PHY that is part of TI SOCs. This
5654 driver takes care of all the PHY functionality apart from comparator.
drivers/phy/ti/phy-omap-usb2.c+64−41
@@ -36,6 +36,10 @@ · 35 unmodified lines
3636 #define USB2PHY_DISCON_BYP_LATCH (1 << 31)
3737 #define USB2PHY_ANA_CONFIG1 0x4c
3838
39+#define AM654_USB2_OTG_PD BIT(8)
40+#define AM654_USB2_VBUS_DET_EN BIT(5)
41+#define AM654_USB2_VBUSVALID_DET_EN BIT(4)
42+
3943 /**
4044 * omap_usb2_set_comparator - links the comparator present in the sytem with
4145 * this phy
@@ -135,9 +139,9 @@ static int omap_usb_power_on(struct phy *x) · 93 unmodified lines
135139
136140 static int omap_usb2_disable_clocks(struct omap_usb *phy)
137141 {
138− clk_disable(phy->wkupclk);
142+ clk_disable_unprepare(phy->wkupclk);
139143 if (!IS_ERR(phy->optclk))
140− clk_disable(phy->optclk);
144+ clk_disable_unprepare(phy->optclk);
141145
142146 return 0;
143147 }
@@ -146,14 +150,14 @@ static int omap_usb2_enable_clocks(struct omap_usb *phy) · 2 unmodified lines
146150 {
147151 int ret;
148152
149− ret = clk_enable(phy->wkupclk);
153+ ret = clk_prepare_enable(phy->wkupclk);
150154 if (ret < 0) {
151155 dev_err(phy->dev, "Failed to enable wkupclk %d\n", ret);
152156 goto err0;
153157 }
154158
155159 if (!IS_ERR(phy->optclk)) {
156− ret = clk_enable(phy->optclk);
160+ ret = clk_prepare_enable(phy->optclk);
157161 if (ret < 0) {
158162 dev_err(phy->dev, "Failed to enable optclk %d\n", ret);
159163 goto err1;
@@ -245,6 +249,15 @@ static const struct usb_phy_data am437x_usb2_data = { · 85 unmodified lines
245249 .power_off = AM437X_USB2_PHY_PD | AM437X_USB2_OTG_PD,
246250 };
247251
252+static const struct usb_phy_data am654_usb2_data = {
253+ .label = "am654_usb2",
254+ .flags = OMAP_USB2_CALIBRATE_FALSE_DISCONNECT,
255+ .mask = AM654_USB2_OTG_PD | AM654_USB2_VBUS_DET_EN |
256+ AM654_USB2_VBUSVALID_DET_EN,
257+ .power_on = AM654_USB2_VBUS_DET_EN | AM654_USB2_VBUSVALID_DET_EN,
258+ .power_off = AM654_USB2_OTG_PD,
259+};
260+
248261 static const struct of_device_id omap_usb2_id_table[] = {
249262 {
250263 .compatible = "ti,omap-usb2",
@@ -266,6 +279,10 @@ static const struct of_device_id omap_usb2_id_table[] = { · 15 unmodified lines
266279 .compatible = "ti,am437x-usb2",
267280 .data = &am437x_usb2_data,
268281 },
282+ {
283+ .compatible = "ti,am654-usb2",
284+ .data = &am654_usb2_data,
285+ },
269286 {},
270287 };
271288 MODULE_DEVICE_TABLE(of, omap_usb2_id_table);
@@ -346,63 +363,72 @@ static int omap_usb2_probe(struct platform_device *pdev) · 74 unmodified lines
346363 }
347364 }
348365
349− otg->set_host = omap_usb_set_host;
350− otg->set_peripheral = omap_usb_set_peripheral;
351− if (phy_data->flags & OMAP_USB2_HAS_SET_VBUS)
352− otg->set_vbus = omap_usb_set_vbus;
353− if (phy_data->flags & OMAP_USB2_HAS_START_SRP)
354− otg->start_srp = omap_usb_start_srp;
355− otg->usb_phy = &phy->phy;
356−
357− platform_set_drvdata(pdev, phy);
358− pm_runtime_enable(phy->dev);
359−
360− generic_phy = devm_phy_create(phy->dev, NULL, &ops);
361− if (IS_ERR(generic_phy)) {
362− pm_runtime_disable(phy->dev);
363− return PTR_ERR(generic_phy);
364− }
365−
366− phy_set_drvdata(generic_phy, phy);
367− omap_usb_power_off(generic_phy);
368−
369− phy_provider = devm_of_phy_provider_register(phy->dev,
370− of_phy_simple_xlate);
371− if (IS_ERR(phy_provider)) {
372− pm_runtime_disable(phy->dev);
373− return PTR_ERR(phy_provider);
374− }
375366
376367 phy->wkupclk = devm_clk_get(phy->dev, "wkupclk");
377368 if (IS_ERR(phy->wkupclk)) {
378− dev_warn(&pdev->dev, "unable to get wkupclk, trying old name\n");
369+ if (PTR_ERR(phy->wkupclk) == -EPROBE_DEFER)
370+ return -EPROBE_DEFER;
371+
372+ dev_warn(&pdev->dev, "unable to get wkupclk %ld, trying old name\n",
373+ PTR_ERR(phy->wkupclk));
379374 phy->wkupclk = devm_clk_get(phy->dev, "usb_phy_cm_clk32k");
375+
380376 if (IS_ERR(phy->wkupclk)) {
381− dev_err(&pdev->dev, "unable to get usb_phy_cm_clk32k\n");
382− pm_runtime_disable(phy->dev);
377+ if (PTR_ERR(phy->wkupclk) != -EPROBE_DEFER)
378+ dev_err(&pdev->dev, "unable to get usb_phy_cm_clk32k\n");
383379 return PTR_ERR(phy->wkupclk);
384380 } else {
385381 dev_warn(&pdev->dev,
386382 "found usb_phy_cm_clk32k, please fix DTS\n");
387383 }
388384 }
389− clk_prepare(phy->wkupclk);
390385
391386 phy->optclk = devm_clk_get(phy->dev, "refclk");
392387 if (IS_ERR(phy->optclk)) {
388+ if (PTR_ERR(phy->optclk) == -EPROBE_DEFER)
389+ return -EPROBE_DEFER;
390+
393391 dev_dbg(&pdev->dev, "unable to get refclk, trying old name\n");
394392 phy->optclk = devm_clk_get(phy->dev, "usb_otg_ss_refclk960m");
393+
395394 if (IS_ERR(phy->optclk)) {
396− dev_dbg(&pdev->dev,
397− "unable to get usb_otg_ss_refclk960m\n");
395+ if (PTR_ERR(phy->optclk) != -EPROBE_DEFER) {
396+ dev_dbg(&pdev->dev,
397+ "unable to get usb_otg_ss_refclk960m\n");
398+ }
398399 } else {
399400 dev_warn(&pdev->dev,
400401 "found usb_otg_ss_refclk960m, please fix DTS\n");
401402 }
402403 }
403404
404− if (!IS_ERR(phy->optclk))
405− clk_prepare(phy->optclk);
405+ otg->set_host = omap_usb_set_host;
406+ otg->set_peripheral = omap_usb_set_peripheral;
407+ if (phy_data->flags & OMAP_USB2_HAS_SET_VBUS)
408+ otg->set_vbus = omap_usb_set_vbus;
409+ if (phy_data->flags & OMAP_USB2_HAS_START_SRP)
410+ otg->start_srp = omap_usb_start_srp;
411+ otg->usb_phy = &phy->phy;
412+
413+ platform_set_drvdata(pdev, phy);
414+ pm_runtime_enable(phy->dev);
415+
416+ generic_phy = devm_phy_create(phy->dev, NULL, &ops);
417+ if (IS_ERR(generic_phy)) {
418+ pm_runtime_disable(phy->dev);
419+ return PTR_ERR(generic_phy);
420+ }
421+
422+ phy_set_drvdata(generic_phy, phy);
423+ omap_usb_power_off(generic_phy);
424+
425+ phy_provider = devm_of_phy_provider_register(phy->dev,
426+ of_phy_simple_xlate);
427+ if (IS_ERR(phy_provider)) {
428+ pm_runtime_disable(phy->dev);
429+ return PTR_ERR(phy_provider);
430+ }
431+
406432
407433 usb_add_phy_dev(&phy->phy);
408434
@@ -413,9 +439,6 @@ static int omap_usb2_remove(struct platform_device *pdev) · 4 unmodified lines
413439 {
414440 struct omap_usb *phy = platform_get_drvdata(pdev);
415441
416− clk_unprepare(phy->wkupclk);
417− if (!IS_ERR(phy->optclk))
418− clk_unprepare(phy->optclk);
419442 usb_remove_phy(&phy->phy);
420443 pm_runtime_disable(phy->dev);
421444
drivers/platform/x86/intel_cht_int33fe.c+6−9
@@ -32,7 +32,7 @@ struct cht_int33fe_data { · 31 unmodified lines
3232 struct i2c_client *fusb302;
3333 struct i2c_client *pi3usb30532;
3434 /* Contain a list-head must be per device */
35− struct device_connection connections[5];
35+ struct device_connection connections[4];
3636 };
3737
3838 /*
@@ -174,16 +174,13 @@ static int cht_int33fe_probe(struct platform_device *pdev) · 135 unmodified lines
174174
175175 data->connections[0].endpoint[0] = "port0";
176176 data->connections[0].endpoint[1] = "i2c-pi3usb30532";
177− data->connections[0].id = "typec-switch";
177+ data->connections[0].id = "orientation-switch";
178178 data->connections[1].endpoint[0] = "port0";
179179 data->connections[1].endpoint[1] = "i2c-pi3usb30532";
180− data->connections[1].id = "typec-mux";
181− data->connections[2].endpoint[0] = "port0";
182− data->connections[2].endpoint[1] = "i2c-pi3usb30532";
183− data->connections[2].id = "idff01m01";
184− data->connections[3].endpoint[0] = "i2c-fusb302";
185− data->connections[3].endpoint[1] = "intel_xhci_usb_sw-role-switch";
186− data->connections[3].id = "usb-role-switch";
180+ data->connections[1].id = "mode-switch";
181+ data->connections[2].endpoint[0] = "i2c-fusb302";
182+ data->connections[2].endpoint[1] = "intel_xhci_usb_sw-role-switch";
183+ data->connections[2].id = "usb-role-switch";
187184
188185 device_connections_add(data->connections);
189186
drivers/usb/Kconfig+1−0
@@ -1,3 +1,4 @@
1+# SPDX-License-Identifier: GPL-2.0
12 #
23 # USB device configuration
34 #
drivers/usb/README+0−54
@@ -1,54 +0,0 @@
1−To understand all the Linux-USB framework, you'll use these resources:
2−
3− * This source code. This is necessarily an evolving work, and
4− includes kerneldoc that should help you get a current overview.
5− ("make pdfdocs", and then look at "usb.pdf" for host side and
6− "gadget.pdf" for peripheral side.) Also, Documentation/usb has
7− more information.
8−
9− * The USB 2.0 specification (from www.usb.org), with supplements
10− such as those for USB OTG and the various device classes.
11− The USB specification has a good overview chapter, and USB
12− peripherals conform to the widely known "Chapter 9".
13−
14− * Chip specifications for USB controllers. Examples include
15− host controllers (on PCs, servers, and more); peripheral
16− controllers (in devices with Linux firmware, like printers or
17− cell phones); and hard-wired peripherals like Ethernet adapters.
18−
19− * Specifications for other protocols implemented by USB peripheral
20− functions. Some are vendor-specific; others are vendor-neutral
21− but just standardized outside of the www.usb.org team.
22−
23−Here is a list of what each subdirectory here is, and what is contained in
24−them.
25−
26−core/ - This is for the core USB host code, including the
27− usbfs files and the hub class driver ("hub_wq").
28−
29−host/ - This is for USB host controller drivers. This
30− includes UHCI, OHCI, EHCI, and others that might
31− be used with more specialized "embedded" systems.
32−
33−gadget/ - This is for USB peripheral controller drivers and
34− the various gadget drivers which talk to them.
35−
36−
37−Individual USB driver directories. A new driver should be added to the
38−first subdirectory in the list below that it fits into.
39−
40−image/ - This is for still image drivers, like scanners or
41− digital cameras.
42−../input/ - This is for any driver that uses the input subsystem,
43− like keyboard, mice, touchscreens, tablets, etc.
44−../media/ - This is for multimedia drivers, like video cameras,
45− radios, and any other drivers that talk to the v4l
46− subsystem.
47−../net/ - This is for network drivers.
48−serial/ - This is for USB to serial drivers.
49−storage/ - This is for USB mass-storage drivers.
50−class/ - This is for all USB device drivers that do not fit
51− into any of the above categories, and work for a range
52− of USB Class specified devices.
53−misc/ - This is for all USB device drivers that do not fit
54− into any of the above categories.
drivers/usb/atm/Kconfig+1−0
@@ -1,3 +1,4 @@
1+# SPDX-License-Identifier: GPL-2.0
12 #
23 # USB/ATM DSL configuration
34 #
drivers/usb/chipidea/Kconfig+2−0
@@ -1,3 +1,5 @@
1+# SPDX-License-Identifier: GPL-2.0
2+
13 config USB_CHIPIDEA
24 tristate "ChipIdea Highspeed Dual Role Controller"
35 depends on ((USB_EHCI_HCD && USB_GADGET) || (USB_EHCI_HCD && !USB_GADGET) || (!USB_EHCI_HCD && USB_GADGET)) && HAS_DMA
drivers/usb/chipidea/ci_hdrc_imx.c+2−4
@@ -7,10 +7,8 @@ · 6 unmodified lines
77
88 #include <linux/module.h>
99 #include <linux/of_platform.h>
10−#include <linux/of_gpio.h>
1110 #include <linux/platform_device.h>
1211 #include <linux/pm_runtime.h>
13−#include <linux/dma-mapping.h>
1412 #include <linux/usb/chipidea.h>
1513 #include <linux/usb/of.h>
1614 #include <linux/clk.h>
@@ -152,8 +150,8 @@ static struct imx_usbmisc_data *usbmisc_get_init_data(struct device *dev) · 135 unmodified lines
152150 dev_warn(dev, "No over current polarity defined\n");
153151 }
154152
155− if (of_find_property(np, "external-vbus-divider", NULL))
156− data->evdo = 1;
153+ data->pwr_pol = of_property_read_bool(np, "power-active-high");
154+ data->evdo = of_property_read_bool(np, "external-vbus-divider");
157155
158156 if (of_usb_get_phy_mode(np) == USBPHY_INTERFACE_MODE_ULPI)
159157 data->ulpi = 1;
drivers/usb/chipidea/ci_hdrc_imx.h+1−0
@@ -18,6 +18,7 @@ struct imx_usbmisc_data { · 17 unmodified lines
1818 /* true if dt specifies polarity */
1919 unsigned int oc_pol_configured:1;
2020
21+ unsigned int pwr_pol:1; /* power polarity */
2122 unsigned int evdo:1; /* set external vbus divider option */
2223 unsigned int ulpi:1; /* connected to an ULPI phy */
2324 unsigned int hsic:1; /* HSIC controlller */
drivers/usb/chipidea/ci_hdrc_tegra.c+1−0
@@ -130,6 +130,7 @@ static int tegra_udc_remove(struct platform_device *pdev) · 129 unmodified lines
130130 {
131131 struct tegra_udc *udc = platform_get_drvdata(pdev);
132132
133+ ci_hdrc_remove_device(udc->dev);
133134 usb_phy_set_suspend(udc->phy, 1);
134135 clk_disable_unprepare(udc->clk);
135136
drivers/usb/chipidea/core.c+34−12
@@ -954,25 +954,47 @@ static int ci_hdrc_probe(struct platform_device *pdev) · 953 unmodified lines
954954 } else if (ci->platdata->usb_phy) {
955955 ci->usb_phy = ci->platdata->usb_phy;
956956 } else {
957+ /* Look for a generic PHY first */
957958 ci->phy = devm_phy_get(dev->parent, "usb-phy");
958− ci->usb_phy = devm_usb_get_phy(dev->parent, USB_PHY_TYPE_USB2);
959959
960− /* if both generic PHY and USB PHY layers aren't enabled */
961− if (PTR_ERR(ci->phy) == -ENOSYS &&
962− PTR_ERR(ci->usb_phy) == -ENXIO) {
963− ret = -ENXIO;
960+ if (PTR_ERR(ci->phy) == -EPROBE_DEFER) {
961+ ret = -EPROBE_DEFER;
964962 goto ulpi_exit;
963+ } else if (IS_ERR(ci->phy)) {
964+ ci->phy = NULL;
965965 }
966966
967− if (IS_ERR(ci->phy) && IS_ERR(ci->usb_phy)) {
968− ret = -EPROBE_DEFER;
969− goto ulpi_exit;
967+ /* Look for a legacy USB PHY from device-tree next */
968+ if (!ci->phy) {
969+ ci->usb_phy = devm_usb_get_phy_by_phandle(dev->parent,
970+ "phys", 0);
971+
972+ if (PTR_ERR(ci->usb_phy) == -EPROBE_DEFER) {
973+ ret = -EPROBE_DEFER;
974+ goto ulpi_exit;
975+ } else if (IS_ERR(ci->usb_phy)) {
976+ ci->usb_phy = NULL;
977+ }
970978 }
971979
972− if (IS_ERR(ci->phy))
973− ci->phy = NULL;
974− else if (IS_ERR(ci->usb_phy))
975− ci->usb_phy = NULL;
980+ /* Look for any registered legacy USB PHY as last resort */
981+ if (!ci->phy && !ci->usb_phy) {
982+ ci->usb_phy = devm_usb_get_phy(dev->parent,
983+ USB_PHY_TYPE_USB2);
984+
985+ if (PTR_ERR(ci->usb_phy) == -EPROBE_DEFER) {
986+ ret = -EPROBE_DEFER;
987+ goto ulpi_exit;
988+ } else if (IS_ERR(ci->usb_phy)) {
989+ ci->usb_phy = NULL;
990+ }
991+ }
992+
993+ /* No USB PHY was found in the end */
994+ if (!ci->phy && !ci->usb_phy) {
995+ ret = -ENXIO;
996+ goto ulpi_exit;
997+ }
976998 }
977999
9781000 ret = ci_usb_phy_init(ci);
drivers/usb/chipidea/usbmisc_imx.c+7−0
@@ -63,6 +63,7 @@ · 62 unmodified lines
6363 #define MX6_BM_NON_BURST_SETTING BIT(1)
6464 #define MX6_BM_OVER_CUR_DIS BIT(7)
6565 #define MX6_BM_OVER_CUR_POLARITY BIT(8)
66+#define MX6_BM_PWR_POLARITY BIT(9)
6667 #define MX6_BM_WAKEUP_ENABLE BIT(10)
6768 #define MX6_BM_UTMI_ON_CLOCK BIT(13)
6869 #define MX6_BM_ID_WAKEUP BIT(16)
@@ -383,6 +384,9 @@ static int usbmisc_imx6q_init(struct imx_usbmisc_data *data) · 314 unmodified lines
383384 else if (data->oc_pol_configured)
384385 reg &= ~MX6_BM_OVER_CUR_POLARITY;
385386 }
387+ /* If the polarity is not set keep it as setup by the bootlader */
388+ if (data->pwr_pol == 1)
389+ reg |= MX6_BM_PWR_POLARITY;
386390 writel(reg, usbmisc->base + data->index * 4);
387391
388392 /* SoC non-burst setting */
@@ -585,6 +589,9 @@ static int usbmisc_imx7d_init(struct imx_usbmisc_data *data) · 196 unmodified lines
585589 else if (data->oc_pol_configured)
586590 reg &= ~MX6_BM_OVER_CUR_POLARITY;
587591 }
592+ /* If the polarity is not set keep it as setup by the bootlader */
593+ if (data->pwr_pol == 1)
594+ reg |= MX6_BM_PWR_POLARITY;
588595 writel(reg, usbmisc->base);
589596
590597 reg = readl(usbmisc->base + MX7D_USBNC_USB_CTRL2);
drivers/usb/class/Kconfig+1−0
@@ -1,3 +1,4 @@
1+# SPDX-License-Identifier: GPL-2.0
12 #
23 # USB Class driver configuration
34 #
drivers/usb/class/cdc-wdm.c+1−1
@@ -1099,7 +1099,7 @@ static int wdm_post_reset(struct usb_interface *intf) · 1098 unmodified lines
10991099 rv = recover_from_urb_loss(desc);
11001100 mutex_unlock(&desc->wlock);
11011101 mutex_unlock(&desc->rlock);
1102− return 0;
1102+ return rv;
11031103 }
11041104
11051105 static struct usb_driver wdm_driver = {
drivers/usb/core/Kconfig+13−0
@@ -1,3 +1,4 @@
1+# SPDX-License-Identifier: GPL-2.0
12 #
23 # USB Core configuration
34 #
@@ -90,3 +91,15 @@ config USB_LEDS_TRIGGER_USBPORT · 86 unmodified lines
9091 This driver allows LEDs to be controlled by USB events. Enabling this
9192 trigger allows specifying list of USB ports that should turn on LED
9293 when some USB device gets connected.
94+
95+config USB_AUTOSUSPEND_DELAY
96+ int "Default autosuspend delay"
97+ depends on USB
98+ default 2
99+ help
100+ The default autosuspend delay in seconds. Can be overridden
101+ with the usbcore.autosuspend command line or module parameter.
102+
103+ The default value Linux has always had is 2 seconds. Change
104+ this value if you want a different delay and cannot modify
105+ the command line or module parameter.
drivers/usb/core/config.c+5−9
@@ -552,7 +552,7 @@ static int usb_parse_configuration(struct usb_device *dev, int cfgidx, · 551 unmodified lines
552552 unsigned char *buffer2;
553553 int size2;
554554 struct usb_descriptor_header *header;
555− int len, retval;
555+ int retval;
556556 u8 inums[USB_MAXINTERFACES], nalts[USB_MAXINTERFACES];
557557 unsigned iad_num = 0;
558558
@@ -707,8 +707,8 @@ static int usb_parse_configuration(struct usb_device *dev, int cfgidx, · 148 unmodified lines
707707 nalts[i] = j = USB_MAXALTSETTING;
708708 }
709709
710− len = sizeof(*intfc) + sizeof(struct usb_host_interface) * j;
711− config->intf_cache[i] = intfc = kzalloc(len, GFP_KERNEL);
710+ intfc = kzalloc(struct_size(intfc, altsetting, j), GFP_KERNEL);
711+ config->intf_cache[i] = intfc;
712712 if (!intfc)
713713 return -ENOMEM;
714714 kref_init(&intfc->ref);
@@ -800,13 +800,11 @@ int usb_get_configuration(struct usb_device *dev) · 85 unmodified lines
800800 {
801801 struct device *ddev = &dev->dev;
802802 int ncfg = dev->descriptor.bNumConfigurations;
803− int result = 0;
803+ int result = -ENOMEM;
804804 unsigned int cfgno, length;
805805 unsigned char *bigbuffer;
806806 struct usb_config_descriptor *desc;
807807
808− cfgno = 0;
809− result = -ENOMEM;
810808 if (ncfg > USB_MAXCONFIG) {
811809 dev_warn(ddev, "too many configurations: %d, "
812810 "using maximum allowed: %d\n", ncfg, USB_MAXCONFIG);
@@ -832,8 +830,7 @@ int usb_get_configuration(struct usb_device *dev) · 19 unmodified lines
832830 if (!desc)
833831 goto err2;
834832
835− result = 0;
836− for (; cfgno < ncfg; cfgno++) {
833+ for (cfgno = 0; cfgno < ncfg; cfgno++) {
837834 /* We grab just the first descriptor so we know how long
838835 * the whole configuration is */
839836 result = usb_get_descriptor(dev, USB_DT_CONFIG, cfgno,
@@ -889,7 +886,6 @@ int usb_get_configuration(struct usb_device *dev) · 49 unmodified lines
889886 goto err;
890887 }
891888 }
892− result = 0;
893889
894890 err:
895891 kfree(desc);
drivers/usb/core/devio.c+4−6
@@ -604,7 +604,7 @@ static void async_completed(struct urb *urb) · 603 unmodified lines
604604 snoop(&urb->dev->dev, "urb complete\n");
605605 snoop_urb(urb->dev, as->userurb, urb->pipe, urb->actual_length,
606606 as->status, COMPLETE, NULL, 0);
607− if ((urb->transfer_flags & URB_DIR_MASK) == URB_DIR_IN)
607+ if (usb_urb_dir_in(urb))
608608 snoop_urb_data(urb, urb->actual_length);
609609
610610 if (as->status < 0 && as->bulk_addr && as->status != -ECONNRESET &&
@@ -1564,12 +1564,10 @@ static int proc_do_submiturb(struct usb_dev_state *ps, struct usbdevfs_urb *uurb · 953 unmodified lines
15641564 }
15651565 for (totlen = u = 0; u < number_of_packets; u++) {
15661566 /*
1567− * arbitrary limit need for USB 3.0
1568− * bMaxBurst (0~15 allowed, 1~16 packets)
1569− * bmAttributes (bit 1:0, mult 0~2, 1~3 packets)
1570− * sizemax: 1024 * 16 * 3 = 49152
1567+ * arbitrary limit need for USB 3.1 Gen2
1568+ * sizemax: 96 DPs at SSP, 96 * 1024 = 98304
15711569 */
1572− if (isopkt[u].length > 49152) {
1570+ if (isopkt[u].length > 98304) {
15731571 ret = -EINVAL;
15741572 goto error;
15751573 }
drivers/usb/core/driver.c+19−4
@@ -1896,14 +1896,11 @@ int usb_runtime_idle(struct device *dev) · 1895 unmodified lines
18961896 return -EBUSY;
18971897 }
18981898
1899−int usb_set_usb2_hardware_lpm(struct usb_device *udev, int enable)
1899+static int usb_set_usb2_hardware_lpm(struct usb_device *udev, int enable)
19001900 {
19011901 struct usb_hcd *hcd = bus_to_hcd(udev->bus);
19021902 int ret = -EPERM;
19031903
1904− if (enable && !udev->usb2_hw_lpm_allowed)
1905− return 0;
1906−
19071904 if (hcd->driver->set_usb2_hw_lpm) {
19081905 ret = hcd->driver->set_usb2_hw_lpm(hcd, udev, enable);
19091906 if (!ret)
@@ -1913,6 +1910,24 @@ int usb_set_usb2_hardware_lpm(struct usb_device *udev, int enable) · 3 unmodified lines
19131910 return ret;
19141911 }
19151912
1913+int usb_enable_usb2_hardware_lpm(struct usb_device *udev)
1914+{
1915+ if (!udev->usb2_hw_lpm_capable ||
1916+ !udev->usb2_hw_lpm_allowed ||
1917+ udev->usb2_hw_lpm_enabled)
1918+ return 0;
1919+
1920+ return usb_set_usb2_hardware_lpm(udev, 1);
1921+}
1922+
1923+int usb_disable_usb2_hardware_lpm(struct usb_device *udev)
1924+{
1925+ if (!udev->usb2_hw_lpm_enabled)
1926+ return 0;
1927+
1928+ return usb_set_usb2_hardware_lpm(udev, 0);
1929+}
1930+
19161931 #endif /* CONFIG_PM */
19171932
19181933 struct bus_type usb_bus_type = {
drivers/usb/core/generic.c+25−19
@@ -118,6 +118,31 @@ int usb_choose_configuration(struct usb_device *udev) · 117 unmodified lines
118118 continue;
119119 }
120120
121+ /*
122+ * Select first configuration as default for audio so that
123+ * devices that don't comply with UAC3 protocol are supported.
124+ * But, still iterate through other configurations and
125+ * select UAC3 compliant config if present.
126+ */
127+ if (desc && is_audio(desc)) {
128+ /* Always prefer the first found UAC3 config */
129+ if (is_uac3_config(desc)) {
130+ best = c;
131+ break;
132+ }
133+
134+ /* If there is no UAC3 config, prefer the first config */
135+ else if (i == 0)
136+ best = c;
137+
138+ /* Unconditional continue, because the rest of the code
139+ * in the loop is irrelevant for audio devices, and
140+ * because it can reassign best, which for audio devices
141+ * we don't want.
142+ */
143+ continue;
144+ }
145+
121146 /* When the first config's first interface is one of Microsoft's
122147 * pet nonstandard Ethernet-over-USB protocols, ignore it unless
123148 * this kernel has enabled the necessary host side driver.
@@ -132,25 +157,6 @@ int usb_choose_configuration(struct usb_device *udev) · 8 unmodified lines
132157 #endif
133158 }
134159
135− /*
136− * Select first configuration as default for audio so that
137− * devices that don't comply with UAC3 protocol are supported.
138− * But, still iterate through other configurations and
139− * select UAC3 compliant config if present.
140− */
141− if (i == 0 && num_configs > 1 && desc && is_audio(desc)) {
142− best = c;
143− continue;
144− }
145−
146− if (i > 0 && desc && is_audio(desc)) {
147− if (is_uac3_config(desc)) {
148− best = c;
149− break;
150− }
151− continue;
152− }
153−
154160 /* From the remaining configs, choose the first one whose
155161 * first interface is for a non-vendor-specific class.
156162 * Reason: Linux is more likely to have a class driver
drivers/usb/core/hcd.c+36−20
@@ -373,13 +373,19 @@ static const u8 ss_rh_config_descriptor[] = { · 372 unmodified lines
373373 * -1 is authorized for all devices except wireless (old behaviour)
374374 * 0 is unauthorized for all devices
375375 * 1 is authorized for all devices
376+ * 2 is authorized for internal devices
376377 */
377−static int authorized_default = -1;
378+#define USB_AUTHORIZE_WIRED -1
379+#define USB_AUTHORIZE_NONE 0
380+#define USB_AUTHORIZE_ALL 1
381+#define USB_AUTHORIZE_INTERNAL 2
382+
383+static int authorized_default = USB_AUTHORIZE_WIRED;
378384 module_param(authorized_default, int, S_IRUGO|S_IWUSR);
379385 MODULE_PARM_DESC(authorized_default,
380386 "Default USB device authorization: 0 is not authorized, 1 is "
381− "authorized, -1 is authorized except for wireless USB (default, "
382− "old behaviour");
387+ "authorized, 2 is authorized for internal devices, -1 is "
388+ "authorized except for wireless USB (default, old behaviour)");
383389 /*-------------------------------------------------------------------------*/
384390
385391 /**
@@ -884,7 +890,7 @@ static ssize_t authorized_default_show(struct device *dev, · 498 unmodified lines
884890 struct usb_hcd *hcd;
885891
886892 hcd = bus_to_hcd(usb_bus);
887− return snprintf(buf, PAGE_SIZE, "%u\n", !!HCD_DEV_AUTHORIZED(hcd));
893+ return snprintf(buf, PAGE_SIZE, "%u\n", hcd->dev_policy);
888894 }
889895
890896 static ssize_t authorized_default_store(struct device *dev,
@@ -900,11 +906,8 @@ static ssize_t authorized_default_store(struct device *dev, · 9 unmodified lines
900906 hcd = bus_to_hcd(usb_bus);
901907 result = sscanf(buf, "%u\n", &val);
902908 if (result == 1) {
903− if (val)
904− set_bit(HCD_FLAG_DEV_AUTHORIZED, &hcd->flags);
905− else
906− clear_bit(HCD_FLAG_DEV_AUTHORIZED, &hcd->flags);
907−
909+ hcd->dev_policy = val <= USB_DEVICE_AUTHORIZE_INTERNAL ?
910+ val : USB_DEVICE_AUTHORIZE_ALL;
908911 result = size;
909912 } else {
910913 result = -EINVAL;
@@ -2736,6 +2739,11 @@ int usb_add_hcd(struct usb_hcd *hcd, · 1825 unmodified lines
27362739 if (retval)
27372740 return retval;
27382741
2742+ retval = usb_phy_roothub_set_mode(hcd->phy_roothub,
2743+ PHY_MODE_USB_HOST_SS);
2744+ if (retval)
2745+ goto err_usb_phy_roothub_power_on;
2746+
27392747 retval = usb_phy_roothub_power_on(hcd->phy_roothub);
27402748 if (retval)
27412749 goto err_usb_phy_roothub_power_on;
@@ -2743,18 +2751,26 @@ int usb_add_hcd(struct usb_hcd *hcd, · 1 unmodified line
27432751
27442752 dev_info(hcd->self.controller, "%s\n", hcd->product_desc);
27452753
2746− /* Keep old behaviour if authorized_default is not in [0, 1]. */
2747− if (authorized_default < 0 || authorized_default > 1) {
2748− if (hcd->wireless)
2749− clear_bit(HCD_FLAG_DEV_AUTHORIZED, &hcd->flags);
2750− else
2751− set_bit(HCD_FLAG_DEV_AUTHORIZED, &hcd->flags);
2752− } else {
2753− if (authorized_default)
2754− set_bit(HCD_FLAG_DEV_AUTHORIZED, &hcd->flags);
2755− else
2756− clear_bit(HCD_FLAG_DEV_AUTHORIZED, &hcd->flags);
2754+ switch (authorized_default) {
2755+ case USB_AUTHORIZE_NONE:
2756+ hcd->dev_policy = USB_DEVICE_AUTHORIZE_NONE;
2757+ break;
2758+
2759+ case USB_AUTHORIZE_ALL:
2760+ hcd->dev_policy = USB_DEVICE_AUTHORIZE_ALL;
2761+ break;
2762+
2763+ case USB_AUTHORIZE_INTERNAL:
2764+ hcd->dev_policy = USB_DEVICE_AUTHORIZE_INTERNAL;
2765+ break;
2766+
2767+ case USB_AUTHORIZE_WIRED:
2768+ default:
2769+ hcd->dev_policy = hcd->wireless ?
2770+ USB_DEVICE_AUTHORIZE_NONE : USB_DEVICE_AUTHORIZE_ALL;
2771+ break;
27572772 }
2773+
27582774 set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
27592775
27602776 /* per default all interfaces are authorized */
drivers/usb/core/hub.c+50−16
@@ -108,6 +108,8 @@ EXPORT_SYMBOL_GPL(ehci_cf_port_reset_rwsem); · 107 unmodified lines
108108 static void hub_release(struct kref *kref);
109109 static int usb_reset_and_verify_device(struct usb_device *udev);
110110 static int hub_port_disable(struct usb_hub *hub, int port1, int set_state);
111+static bool hub_port_warm_reset_required(struct usb_hub *hub, int port1,
112+ u16 portstatus);
111113
112114 static inline char *portspeed(struct usb_hub *hub, int portstatus)
113115 {
@@ -607,6 +609,36 @@ static int hub_port_status(struct usb_hub *hub, int port1, · 493 unmodified lines
607609 status, change, NULL);
608610 }
609611
612+static void hub_resubmit_irq_urb(struct usb_hub *hub)
613+{
614+ unsigned long flags;
615+ int status;
616+
617+ spin_lock_irqsave(&hub->irq_urb_lock, flags);
618+
619+ if (hub->quiescing) {
620+ spin_unlock_irqrestore(&hub->irq_urb_lock, flags);
621+ return;
622+ }
623+
624+ status = usb_submit_urb(hub->urb, GFP_ATOMIC);
625+ if (status && status != -ENODEV && status != -EPERM &&
626+ status != -ESHUTDOWN) {
627+ dev_err(hub->intfdev, "resubmit --> %d\n", status);
628+ mod_timer(&hub->irq_urb_retry, jiffies + HZ);
629+ }
630+
631+ spin_unlock_irqrestore(&hub->irq_urb_lock, flags);
632+}
633+
634+static void hub_retry_irq_urb(struct timer_list *t)
635+{
636+ struct usb_hub *hub = from_timer(hub, t, irq_urb_retry);
637+
638+ hub_resubmit_irq_urb(hub);
639+}
640+
641+
610642 static void kick_hub_wq(struct usb_hub *hub)
611643 {
612644 struct usb_interface *intf;
@@ -709,12 +741,7 @@ static void hub_irq(struct urb *urb) · 96 unmodified lines
709741 kick_hub_wq(hub);
710742
711743 resubmit:
712− if (hub->quiescing)
713− return;
714−
715− status = usb_submit_urb(hub->urb, GFP_ATOMIC);
716− if (status != 0 && status != -ENODEV && status != -EPERM)
717− dev_err(hub->intfdev, "resubmit --> %d\n", status);
744+ hub_resubmit_irq_urb(hub);
718745 }
719746
720747 /* USB 2.0 spec Section 11.24.2.3 */
@@ -1112,6 +1139,11 @@ static void hub_activate(struct usb_hub *hub, enum hub_activation_type type) · 391 unmodified lines
11121139 USB_PORT_FEAT_ENABLE);
11131140 }
11141141
1142+ /* Make sure a warm-reset request is handled by port_event */
1143+ if (type == HUB_RESUME &&
1144+ hub_port_warm_reset_required(hub, port1, portstatus))
1145+ set_bit(port1, hub->event_bits);
1146+
11151147 /*
11161148 * Add debounce if USB3 link is in polling/link training state.
11171149 * Link will automatically transition to Enabled state after
@@ -1264,10 +1296,13 @@ enum hub_quiescing_type { · 146 unmodified lines
12641296 static void hub_quiesce(struct usb_hub *hub, enum hub_quiescing_type type)
12651297 {
12661298 struct usb_device *hdev = hub->hdev;
1299+ unsigned long flags;
12671300 int i;
12681301
12691302 /* hub_wq and related activity won't re-trigger */
1303+ spin_lock_irqsave(&hub->irq_urb_lock, flags);
12701304 hub->quiescing = 1;
1305+ spin_unlock_irqrestore(&hub->irq_urb_lock, flags);
12711306
12721307 if (type != HUB_SUSPEND) {
12731308 /* Disconnect all the children */
@@ -1278,6 +1313,7 @@ static void hub_quiesce(struct usb_hub *hub, enum hub_quiescing_type type) · 4 unmodified lines
12781313 }
12791314
12801315 /* Stop hub_wq and related activity */
1316+ del_timer_sync(&hub->irq_urb_retry);
12811317 usb_kill_urb(hub->urb);
12821318 if (hub->has_indicators)
12831319 cancel_delayed_work_sync(&hub->leds);
@@ -1810,6 +1846,8 @@ static int hub_probe(struct usb_interface *intf, const struct usb_device_id *id) · 526 unmodified lines
18101846 INIT_DELAYED_WORK(&hub->leds, led_work);
18111847 INIT_DELAYED_WORK(&hub->init_work, NULL);
18121848 INIT_WORK(&hub->events, hub_event);
1849+ spin_lock_init(&hub->irq_urb_lock);
1850+ timer_setup(&hub->irq_urb_retry, hub_retry_irq_urb, 0);
18131851 usb_get_intf(intf);
18141852 usb_get_dev(hdev);
18151853
@@ -3220,8 +3258,7 @@ int usb_port_suspend(struct usb_device *udev, pm_message_t msg) · 1404 unmodified lines
32203258 }
32213259
32223260 /* disable USB2 hardware LPM */
3223− if (udev->usb2_hw_lpm_enabled == 1)
3224− usb_set_usb2_hardware_lpm(udev, 0);
3261+ usb_disable_usb2_hardware_lpm(udev);
32253262
32263263 if (usb_disable_ltm(udev)) {
32273264 dev_err(&udev->dev, "Failed to disable LTM before suspend\n");
@@ -3259,8 +3296,7 @@ int usb_port_suspend(struct usb_device *udev, pm_message_t msg) · 31 unmodified lines
32593296 usb_enable_ltm(udev);
32603297 err_ltm:
32613298 /* Try to enable USB2 hardware LPM again */
3262− if (udev->usb2_hw_lpm_capable == 1)
3263− usb_set_usb2_hardware_lpm(udev, 1);
3299+ usb_enable_usb2_hardware_lpm(udev);
32643300
32653301 if (udev->do_remote_wakeup)
32663302 (void) usb_disable_remote_wakeup(udev);
@@ -3543,8 +3579,7 @@ int usb_port_resume(struct usb_device *udev, pm_message_t msg) · 276 unmodified lines
35433579 hub_port_logical_disconnect(hub, port1);
35443580 } else {
35453581 /* Try to enable USB2 hardware LPM */
3546− if (udev->usb2_hw_lpm_capable == 1)
3547− usb_set_usb2_hardware_lpm(udev, 1);
3582+ usb_enable_usb2_hardware_lpm(udev);
35483583
35493584 /* Try to enable USB3 LTM */
35503585 usb_enable_ltm(udev);
@@ -4435,7 +4470,7 @@ static void hub_set_initial_usb2_lpm_policy(struct usb_device *udev) · 884 unmodified lines
44354470 if ((udev->bos->ext_cap->bmAttributes & cpu_to_le32(USB_BESL_SUPPORT)) ||
44364471 connect_type == USB_PORT_CONNECT_TYPE_HARD_WIRED) {
44374472 udev->usb2_hw_lpm_allowed = 1;
4438− usb_set_usb2_hardware_lpm(udev, 1);
4473+ usb_enable_usb2_hardware_lpm(udev);
44394474 }
44404475 }
44414476
@@ -5649,8 +5684,7 @@ static int usb_reset_and_verify_device(struct usb_device *udev) · 1207 unmodified lines
56495684 /* Disable USB2 hardware LPM.
56505685 * It will be re-enabled by the enumeration process.
56515686 */
5652− if (udev->usb2_hw_lpm_enabled == 1)
5653− usb_set_usb2_hardware_lpm(udev, 0);
5687+ usb_disable_usb2_hardware_lpm(udev);
56545688
56555689 /* Disable LPM while we reset the device and reinstall the alt settings.
56565690 * Device-initiated LPM, and system exit latency settings are cleared
@@ -5753,7 +5787,7 @@ static int usb_reset_and_verify_device(struct usb_device *udev) · 96 unmodified lines
57535787
57545788 done:
57555789 /* Now that the alt settings are re-installed, enable LTM and LPM. */
5756− usb_set_usb2_hardware_lpm(udev, 1);
5790+ usb_enable_usb2_hardware_lpm(udev);
57575791 usb_unlocked_enable_lpm(udev);
57585792 usb_enable_ltm(udev);
57595793 usb_release_bos_descriptor(udev);
drivers/usb/core/hub.h+2−0
@@ -69,6 +69,8 @@ struct usb_hub { · 68 unmodified lines
6969 struct delayed_work leds;
7070 struct delayed_work init_work;
7171 struct work_struct events;
72+ spinlock_t irq_urb_lock;
73+ struct timer_list irq_urb_retry;
7274 struct usb_port **ports;
7375 };
7476
drivers/usb/core/message.c+8−2
@@ -1243,8 +1243,7 @@ void usb_disable_device(struct usb_device *dev, int skip_ep0) · 1242 unmodified lines
12431243 dev->actconfig->interface[i] = NULL;
12441244 }
12451245
1246− if (dev->usb2_hw_lpm_enabled == 1)
1247− usb_set_usb2_hardware_lpm(dev, 0);
1246+ usb_disable_usb2_hardware_lpm(dev);
12481247 usb_unlocked_disable_lpm(dev);
12491248 usb_disable_ltm(dev);
12501249
@@ -2007,6 +2006,13 @@ free_interfaces: · 756 unmodified lines
20072006 for (i = 0; i < nintf; ++i) {
20082007 struct usb_interface *intf = cp->interface[i];
20092008
2009+ if (intf->dev.of_node &&
2010+ !of_device_is_available(intf->dev.of_node)) {
2011+ dev_info(&dev->dev, "skipping disabled interface %d\n",
2012+ intf->cur_altsetting->desc.bInterfaceNumber);
2013+ continue;
2014+ }
2015+
20102016 dev_dbg(&dev->dev,
20112017 "adding %s (config #%d, interface %d)\n",
20122018 dev_name(&intf->dev), configuration,
drivers/usb/core/phy.c+28−0
@@ -123,6 +123,34 @@ int usb_phy_roothub_exit(struct usb_phy_roothub *phy_roothub) · 122 unmodified lines
123123 }
124124 EXPORT_SYMBOL_GPL(usb_phy_roothub_exit);
125125
126+int usb_phy_roothub_set_mode(struct usb_phy_roothub *phy_roothub,
127+ enum phy_mode mode)
128+{
129+ struct usb_phy_roothub *roothub_entry;
130+ struct list_head *head;
131+ int err;
132+
133+ if (!phy_roothub)
134+ return 0;
135+
136+ head = &phy_roothub->list;
137+
138+ list_for_each_entry(roothub_entry, head, list) {
139+ err = phy_set_mode(roothub_entry->phy, mode);
140+ if (err)
141+ goto err_out;
142+ }
143+
144+ return 0;
145+
146+err_out:
147+ list_for_each_entry_continue_reverse(roothub_entry, head, list)
148+ phy_power_off(roothub_entry->phy);
149+
150+ return err;
151+}
152+EXPORT_SYMBOL_GPL(usb_phy_roothub_set_mode);
153+
126154 int usb_phy_roothub_power_on(struct usb_phy_roothub *phy_roothub)
127155 {
128156 struct usb_phy_roothub *roothub_entry;
drivers/usb/core/phy.h+2−0
@@ -16,6 +16,8 @@ struct usb_phy_roothub *usb_phy_roothub_alloc(struct device *dev); · 15 unmodified lines
1616 int usb_phy_roothub_init(struct usb_phy_roothub *phy_roothub);
1717 int usb_phy_roothub_exit(struct usb_phy_roothub *phy_roothub);
1818
19+int usb_phy_roothub_set_mode(struct usb_phy_roothub *phy_roothub,
20+ enum phy_mode mode);
1921 int usb_phy_roothub_power_on(struct usb_phy_roothub *phy_roothub);
2022 void usb_phy_roothub_power_off(struct usb_phy_roothub *phy_roothub);
2123
drivers/usb/core/sysfs.c+4−1
@@ -528,7 +528,10 @@ static ssize_t usb2_hardware_lpm_store(struct device *dev, · 527 unmodified lines
528528
529529 if (!ret) {
530530 udev->usb2_hw_lpm_allowed = value;
531− ret = usb_set_usb2_hardware_lpm(udev, value);
531+ if (value)
532+ ret = usb_enable_usb2_hardware_lpm(udev);
533+ else
534+ ret = usb_disable_usb2_hardware_lpm(udev);
532535 }
533536
534537 usb_unlock_device(udev);
drivers/usb/core/urb.c+2−3
@@ -70,9 +70,8 @@ struct urb *usb_alloc_urb(int iso_packets, gfp_t mem_flags) · 69 unmodified lines
7070 {
7171 struct urb *urb;
7272
73− urb = kmalloc(sizeof(struct urb) +
74− iso_packets * sizeof(struct usb_iso_packet_descriptor),
75− mem_flags);
73+ urb = kmalloc(struct_size(urb, iso_frame_desc, iso_packets),
74+ mem_flags);
7675 if (!urb)
7776 return NULL;
7877 usb_init_urb(urb);
drivers/usb/core/usb.c+28−9
@@ -46,8 +46,7 @@ · 45 unmodified lines
4646 #include <linux/mm.h>
4747 #include <linux/dma-mapping.h>
4848
49−#include "usb.h"
50−
49+#include "hub.h"
5150
5251 const char *usbcore_name = "usbcore";
5352
@@ -65,8 +64,8 @@ int usb_disabled(void) · 11 unmodified lines
6564 EXPORT_SYMBOL_GPL(usb_disabled);
6665
6766 #ifdef CONFIG_PM
68−static int usb_autosuspend_delay = 2; /* Default delay value,
69− * in seconds */
67+/* Default delay value, in seconds */
68+static int usb_autosuspend_delay = CONFIG_USB_AUTOSUSPEND_DELAY;
7069 module_param_named(autosuspend, usb_autosuspend_delay, int, 0644);
7170 MODULE_PARM_DESC(autosuspend, "default autosuspend delay");
7271
@@ -536,6 +535,27 @@ static unsigned usb_bus_is_wusb(struct usb_bus *bus) · 463 unmodified lines
536535 return hcd->wireless;
537536 }
538537
538+static bool usb_dev_authorized(struct usb_device *dev, struct usb_hcd *hcd)
539+{
540+ struct usb_hub *hub;
541+
542+ if (!dev->parent)
543+ return true; /* Root hub always ok [and always wired] */
544+
545+ switch (hcd->dev_policy) {
546+ case USB_DEVICE_AUTHORIZE_NONE:
547+ default:
548+ return false;
549+
550+ case USB_DEVICE_AUTHORIZE_ALL:
551+ return true;
552+
553+ case USB_DEVICE_AUTHORIZE_INTERNAL:
554+ hub = usb_hub_to_struct_hub(dev->parent);
555+ return hub->ports[dev->portnum - 1]->connect_type ==
556+ USB_PORT_CONNECT_TYPE_HARD_WIRED;
557+ }
558+}
539559
540560 /**
541561 * usb_alloc_dev - usb device constructor (usbcore-internal)
@@ -663,12 +683,11 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent, · 121 unmodified lines
663683 dev->connect_time = jiffies;
664684 dev->active_duration = -jiffies;
665685 #endif
666− if (root_hub) /* Root hub always ok [and always wired] */
667− dev->authorized = 1;
668− else {
669− dev->authorized = !!HCD_DEV_AUTHORIZED(usb_hcd);
686+
687+ dev->authorized = usb_dev_authorized(dev, usb_hcd);
688+ if (!root_hub)
670689 dev->wusb = usb_bus_is_wusb(bus) ? 1 : 0;
671− }
690+
672691 return dev;
673692 }
674693 EXPORT_SYMBOL_GPL(usb_alloc_dev);
drivers/usb/core/usb.h+8−2
@@ -92,7 +92,8 @@ extern int usb_remote_wakeup(struct usb_device *dev); · 91 unmodified lines
9292 extern int usb_runtime_suspend(struct device *dev);
9393 extern int usb_runtime_resume(struct device *dev);
9494 extern int usb_runtime_idle(struct device *dev);
95−extern int usb_set_usb2_hardware_lpm(struct usb_device *udev, int enable);
95+extern int usb_enable_usb2_hardware_lpm(struct usb_device *udev);
96+extern int usb_disable_usb2_hardware_lpm(struct usb_device *udev);
9697
9798 #else
9899
@@ -112,7 +113,12 @@ static inline int usb_autoresume_device(struct usb_device *udev) · 13 unmodified lines
112113 return 0;
113114 }
114115
115−static inline int usb_set_usb2_hardware_lpm(struct usb_device *udev, int enable)
116+static inline int usb_enable_usb2_hardware_lpm(struct usb_device *udev)
117+{
118+ return 0;
119+}
120+
121+static inline int usb_disable_usb2_hardware_lpm(struct usb_device *udev)
116122 {
117123 return 0;
118124 }
drivers/usb/dwc2/Kconfig+2−0
@@ -1,3 +1,5 @@
1+# SPDX-License-Identifier: GPL-2.0
2+
13 config USB_DWC2
24 tristate "DesignWare USB2 DRD Core Support"
35 depends on HAS_DMA
drivers/usb/dwc2/gadget.c+78−36
@@ -768,22 +768,13 @@ static u32 dwc2_gadget_get_desc_params(struct dwc2_hsotg_ep *hs_ep, u32 *mask) · 767 unmodified lines
768768 return desc_size;
769769 }
770770
771−/*
772− * dwc2_gadget_config_nonisoc_xfer_ddma - prepare non ISOC DMA desc chain.
773− * @hs_ep: The endpoint
774− * @dma_buff: DMA address to use
775− * @len: Length of the transfer
776− *
777− * This function will iterate over descriptor chain and fill its entries
778− * with corresponding information based on transfer data.
779− */
780−static void dwc2_gadget_config_nonisoc_xfer_ddma(struct dwc2_hsotg_ep *hs_ep,
771+static void dwc2_gadget_fill_nonisoc_xfer_ddma_one(struct dwc2_hsotg_ep *hs_ep,
772+ struct dwc2_dma_desc **desc,
781773 dma_addr_t dma_buff,
782− unsigned int len)
774+ unsigned int len,
775+ bool true_last)
783776 {
784− struct dwc2_hsotg *hsotg = hs_ep->parent;
785777 int dir_in = hs_ep->dir_in;
786− struct dwc2_dma_desc *desc = hs_ep->desc_list;
787778 u32 mps = hs_ep->ep.maxpacket;
788779 u32 maxsize = 0;
789780 u32 offset = 0;
@@ -798,39 +789,77 @@ static void dwc2_gadget_config_nonisoc_xfer_ddma(struct dwc2_hsotg_ep *hs_ep, · 8 unmodified lines
798789 hs_ep->desc_count = 1;
799790
800791 for (i = 0; i < hs_ep->desc_count; ++i) {
801− desc->status = 0;
802− desc->status |= (DEV_DMA_BUFF_STS_HBUSY
792+ (*desc)->status = 0;
793+ (*desc)->status |= (DEV_DMA_BUFF_STS_HBUSY
803794 << DEV_DMA_BUFF_STS_SHIFT);
804795
805796 if (len > maxsize) {
806797 if (!hs_ep->index && !dir_in)
807− desc->status |= (DEV_DMA_L | DEV_DMA_IOC);
798+ (*desc)->status |= (DEV_DMA_L | DEV_DMA_IOC);
808799
809− desc->status |= (maxsize <<
810− DEV_DMA_NBYTES_SHIFT & mask);
811− desc->buf = dma_buff + offset;
800+ (*desc)->status |=
801+ maxsize << DEV_DMA_NBYTES_SHIFT & mask;
802+ (*desc)->buf = dma_buff + offset;
812803
813804 len -= maxsize;
814805 offset += maxsize;
815806 } else {
816− desc->status |= (DEV_DMA_L | DEV_DMA_IOC);
807+ if (true_last)
808+ (*desc)->status |= (DEV_DMA_L | DEV_DMA_IOC);
817809
818810 if (dir_in)
819− desc->status |= (len % mps) ? DEV_DMA_SHORT :
820− ((hs_ep->send_zlp) ? DEV_DMA_SHORT : 0);
821− if (len > maxsize)
822− dev_err(hsotg->dev, "wrong len %d\n", len);
811+ (*desc)->status |= (len % mps) ? DEV_DMA_SHORT :
812+ ((hs_ep->send_zlp && true_last) ?
813+ DEV_DMA_SHORT : 0);
823814
824− desc->status |=
815+ (*desc)->status |=
825816 len << DEV_DMA_NBYTES_SHIFT & mask;
826− desc->buf = dma_buff + offset;
817+ (*desc)->buf = dma_buff + offset;
827818 }
828819
829− desc->status &= ~DEV_DMA_BUFF_STS_MASK;
830− desc->status |= (DEV_DMA_BUFF_STS_HREADY
820+ (*desc)->status &= ~DEV_DMA_BUFF_STS_MASK;
821+ (*desc)->status |= (DEV_DMA_BUFF_STS_HREADY
831822 << DEV_DMA_BUFF_STS_SHIFT);
832− desc++;
823+ (*desc)++;
824+ }
825+}
826+
827+/*
828+ * dwc2_gadget_config_nonisoc_xfer_ddma - prepare non ISOC DMA desc chain.
829+ * @hs_ep: The endpoint
830+ * @ureq: Request to transfer
831+ * @offset: offset in bytes
832+ * @len: Length of the transfer
833+ *
834+ * This function will iterate over descriptor chain and fill its entries
835+ * with corresponding information based on transfer data.
836+ */
837+static void dwc2_gadget_config_nonisoc_xfer_ddma(struct dwc2_hsotg_ep *hs_ep,
838+ struct usb_request *ureq,
839+ unsigned int offset,
840+ unsigned int len)
841+{
842+ struct dwc2_dma_desc *desc = hs_ep->desc_list;
843+ struct scatterlist *sg;
844+ int i;
845+ u8 desc_count = 0;
846+
847+ /* non-DMA sg buffer */
848+ if (!ureq->num_sgs) {
849+ dwc2_gadget_fill_nonisoc_xfer_ddma_one(hs_ep, &desc,
850+ ureq->dma + offset, len, true);
851+ return;
833852 }
853+
854+ /* DMA sg buffer */
855+ for_each_sg(ureq->sg, sg, ureq->num_sgs, i) {
856+ dwc2_gadget_fill_nonisoc_xfer_ddma_one(hs_ep, &desc,
857+ sg_dma_address(sg) + sg->offset, sg_dma_len(sg),
858+ sg_is_last(sg));
859+ desc_count += hs_ep->desc_count;
860+ }
861+
862+ hs_ep->desc_count = desc_count;
834863 }
835864
836865 /*
@@ -944,7 +973,13 @@ static void dwc2_gadget_start_isoc_ddma(struct dwc2_hsotg_ep *hs_ep) · 107 unmodified lines
944973
945974 hs_ep->next_desc = 0;
946975 list_for_each_entry_safe(hs_req, treq, &hs_ep->queue, queue) {
947− ret = dwc2_gadget_fill_isoc_desc(hs_ep, hs_req->req.dma,
976+ dma_addr_t dma_addr = hs_req->req.dma;
977+
978+ if (hs_req->req.num_sgs) {
979+ WARN_ON(hs_req->req.num_sgs > 1);
980+ dma_addr = sg_dma_address(hs_req->req.sg);
981+ }
982+ ret = dwc2_gadget_fill_isoc_desc(hs_ep, dma_addr,
948983 hs_req->req.length);
949984 if (ret)
950985 break;
@@ -1100,7 +1135,7 @@ static void dwc2_hsotg_start_req(struct dwc2_hsotg *hsotg, · 149 unmodified lines
11001135 offset = ureq->actual;
11011136
11021137 /* Fill DDMA chain entries */
1103− dwc2_gadget_config_nonisoc_xfer_ddma(hs_ep, ureq->dma + offset,
1138+ dwc2_gadget_config_nonisoc_xfer_ddma(hs_ep, ureq, offset,
11041139 length);
11051140
11061141 /* write descriptor chain address to control register */
@@ -1399,7 +1434,13 @@ static int dwc2_hsotg_ep_queue(struct usb_ep *ep, struct usb_request *req, · 292 unmodified lines
13991434 */
14001435 if (using_desc_dma(hs) && hs_ep->isochronous) {
14011436 if (hs_ep->target_frame != TARGET_FRAME_INITIAL) {
1402− dwc2_gadget_fill_isoc_desc(hs_ep, hs_req->req.dma,
1437+ dma_addr_t dma_addr = hs_req->req.dma;
1438+
1439+ if (hs_req->req.num_sgs) {
1440+ WARN_ON(hs_req->req.num_sgs > 1);
1441+ dma_addr = sg_dma_address(hs_req->req.sg);
1442+ }
1443+ dwc2_gadget_fill_isoc_desc(hs_ep, dma_addr,
14031444 hs_req->req.length);
14041445 }
14051446 return 0;
@@ -1987,13 +2028,12 @@ static void dwc2_hsotg_program_zlp(struct dwc2_hsotg *hsotg, · 581 unmodified lines
19872028 dev_dbg(hsotg->dev, "Receiving zero-length packet on ep%d\n",
19882029 index);
19892030 if (using_desc_dma(hsotg)) {
1990− /* Not specific buffer needed for ep0 ZLP */
1991− dma_addr_t dma = hs_ep->desc_list_dma;
1992−
19932031 if (!index)
19942032 dwc2_gadget_set_ep0_desc_chain(hsotg, hs_ep);
19952033
1996− dwc2_gadget_config_nonisoc_xfer_ddma(hs_ep, dma, 0);
2034+ /* Not specific buffer needed for ep0 ZLP */
2035+ dwc2_gadget_fill_nonisoc_xfer_ddma_one(hs_ep, &hs_ep->desc_list,
2036+ hs_ep->desc_list_dma, 0, true);
19972037 } else {
19982038 dwc2_writel(hsotg, DXEPTSIZ_MC(1) | DXEPTSIZ_PKTCNT(1) |
19992039 DXEPTSIZ_XFERSIZE(0),
@@ -4005,6 +4045,7 @@ static int dwc2_hsotg_ep_enable(struct usb_ep *ep, · 2005 unmodified lines
40054045 ret = -ENOMEM;
40064046 goto error1;
40074047 }
4048+ epctrl &= ~(DXEPCTL_TXFNUM_LIMIT << DXEPCTL_TXFNUM_SHIFT);
40084049 hsotg->fifo_map |= 1 << fifo_index;
40094050 epctrl |= DXEPCTL_TXFNUM(fifo_index);
40104051 hs_ep->fifo_index = fifo_index;
@@ -4385,6 +4426,7 @@ static int dwc2_hsotg_udc_start(struct usb_gadget *gadget, · 374 unmodified lines
43854426 hsotg->enabled = 0;
43864427 spin_unlock_irqrestore(&hsotg->lock, flags);
43874428
4429+ gadget->sg_supported = using_desc_dma(hsotg);
43884430 dev_info(hsotg->dev, "bound driver %s\n", driver->driver.name);
43894431
43904432 return 0;
drivers/usb/dwc2/hcd.c+1−3
@@ -3981,10 +3981,8 @@ static struct dwc2_hcd_urb *dwc2_hcd_urb_alloc(struct dwc2_hsotg *hsotg, · 3980 unmodified lines
39813981 gfp_t mem_flags)
39823982 {
39833983 struct dwc2_hcd_urb *urb;
3984− u32 size = sizeof(*urb) + iso_desc_count *
3985− sizeof(struct dwc2_hcd_iso_packet_desc);
39863984
3987− urb = kzalloc(size, mem_flags);
3985+ urb = kzalloc(struct_size(urb, iso_descs, iso_desc_count), mem_flags);
39883986 if (urb)
39893987 urb->packet_count = iso_desc_count;
39903988 return urb;
drivers/usb/dwc3/Kconfig+5−3
@@ -1,3 +1,5 @@
1+# SPDX-License-Identifier: GPL-2.0
2+
13 config USB_DWC3
24 tristate "DesignWare USB3 DRD Core Support"
35 depends on (USB || USB_GADGET) && HAS_DMA
@@ -86,11 +88,11 @@ config USB_DWC3_HAPS · 82 unmodified lines
8688 platform, please say 'Y' or 'M' here.
8789
8890 config USB_DWC3_KEYSTONE
89− tristate "Texas Instruments Keystone2 Platforms"
90− depends on ARCH_KEYSTONE || COMPILE_TEST
91+ tristate "Texas Instruments Keystone2/AM654 Platforms"
92+ depends on ARCH_KEYSTONE || ARCH_K3 || COMPILE_TEST
9193 default USB_DWC3
9294 help
93− Support of USB2/3 functionality in TI Keystone2 platforms.
95+ Support of USB2/3 functionality in TI Keystone2 and AM654 platforms.
9496 Say 'Y' or 'M' here if you have one such device
9597
9698 config USB_DWC3_OF_SIMPLE
drivers/usb/dwc3/core.h+9−3
@@ -692,7 +692,6 @@ struct dwc3_ep { · 691 unmodified lines
692692 #define DWC3_EP_WEDGE BIT(2)
693693 #define DWC3_EP_TRANSFER_STARTED BIT(3)
694694 #define DWC3_EP_PENDING_REQUEST BIT(5)
695−#define DWC3_EP_END_TRANSFER_PENDING BIT(7)
696695
697696 /* This last one is specific to EP0 */
698697 #define DWC3_EP0_DIR_IN BIT(31)
@@ -863,6 +862,7 @@ struct dwc3_hwparams { · 164 unmodified lines
863862 * @num_pending_sgs: counter to pending sgs
864863 * @num_queued_sgs: counter to the number of sgs which already got queued
865864 * @remaining: amount of data remaining
865+ * @status: internal dwc3 request status tracking
866866 * @epnum: endpoint number to which this request refers
867867 * @trb: pointer to struct dwc3_trb
868868 * @trb_dma: DMA address of @trb
@@ -871,7 +871,6 @@ struct dwc3_hwparams { · 2 unmodified lines
871871 * or unaligned OUT)
872872 * @direction: IN or OUT direction flag
873873 * @mapped: true when request has been dma-mapped
874− * @started: request is started
875874 */
876875 struct dwc3_request {
877876 struct usb_request request;
@@ -883,6 +882,14 @@ struct dwc3_request { · 5 unmodified lines
883882 unsigned num_pending_sgs;
884883 unsigned int num_queued_sgs;
885884 unsigned remaining;
885+
886+ unsigned int status;
887+#define DWC3_REQUEST_STATUS_QUEUED 0
888+#define DWC3_REQUEST_STATUS_STARTED 1
889+#define DWC3_REQUEST_STATUS_CANCELLED 2
890+#define DWC3_REQUEST_STATUS_COMPLETED 3
891+#define DWC3_REQUEST_STATUS_UNKNOWN -1
892+
886893 u8 epnum;
887894 struct dwc3_trb *trb;
888895 dma_addr_t trb_dma;
@@ -892,7 +899,6 @@ struct dwc3_request { · 3 unmodified lines
892899 unsigned needs_extra_trb:1;
893900 unsigned direction:1;
894901 unsigned mapped:1;
895− unsigned started:1;
896902 };
897903
898904 /*
drivers/usb/dwc3/debug.h+85−71
@@ -193,65 +193,69 @@ static inline const char *dwc3_ep0_state_string(enum dwc3_ep0_state state) · 192 unmodified lines
193193 * dwc3_gadget_event_string - returns event name
194194 * @event: the event code
195195 */
196−static inline const char *
197−dwc3_gadget_event_string(char *str, const struct dwc3_event_devt *event)
196+static inline const char *dwc3_gadget_event_string(char *str, size_t size,
197+ const struct dwc3_event_devt *event)
198198 {
199199 enum dwc3_link_state state = event->event_info & DWC3_LINK_STATE_MASK;
200200
201201 switch (event->type) {
202202 case DWC3_DEVICE_EVENT_DISCONNECT:
203− sprintf(str, "Disconnect: [%s]",
203+ snprintf(str, size, "Disconnect: [%s]",
204204 dwc3_gadget_link_string(state));
205205 break;
206206 case DWC3_DEVICE_EVENT_RESET:
207− sprintf(str, "Reset [%s]", dwc3_gadget_link_string(state));
207+ snprintf(str, size, "Reset [%s]",
208+ dwc3_gadget_link_string(state));
208209 break;
209210 case DWC3_DEVICE_EVENT_CONNECT_DONE:
210− sprintf(str, "Connection Done [%s]",
211+ snprintf(str, size, "Connection Done [%s]",
211212 dwc3_gadget_link_string(state));
212213 break;
213214 case DWC3_DEVICE_EVENT_LINK_STATUS_CHANGE:
214− sprintf(str, "Link Change [%s]",
215+ snprintf(str, size, "Link Change [%s]",
215216 dwc3_gadget_link_string(state));
216217 break;
217218 case DWC3_DEVICE_EVENT_WAKEUP:
218− sprintf(str, "WakeUp [%s]", dwc3_gadget_link_string(state));
219+ snprintf(str, size, "WakeUp [%s]",
220+ dwc3_gadget_link_string(state));
219221 break;
220222 case DWC3_DEVICE_EVENT_EOPF:
221− sprintf(str, "End-Of-Frame [%s]",
223+ snprintf(str, size, "End-Of-Frame [%s]",
222224 dwc3_gadget_link_string(state));
223225 break;
224226 case DWC3_DEVICE_EVENT_SOF:
225− sprintf(str, "Start-Of-Frame [%s]",
227+ snprintf(str, size, "Start-Of-Frame [%s]",
226228 dwc3_gadget_link_string(state));
227229 break;
228230 case DWC3_DEVICE_EVENT_ERRATIC_ERROR:
229− sprintf(str, "Erratic Error [%s]",
231+ snprintf(str, size, "Erratic Error [%s]",
230232 dwc3_gadget_link_string(state));
231233 break;
232234 case DWC3_DEVICE_EVENT_CMD_CMPL:
233− sprintf(str, "Command Complete [%s]",
235+ snprintf(str, size, "Command Complete [%s]",
234236 dwc3_gadget_link_string(state));
235237 break;
236238 case DWC3_DEVICE_EVENT_OVERFLOW:
237− sprintf(str, "Overflow [%s]", dwc3_gadget_link_string(state));
239+ snprintf(str, size, "Overflow [%s]",
240+ dwc3_gadget_link_string(state));
238241 break;
239242 default:
240− sprintf(str, "UNKNOWN");
243+ snprintf(str, size, "UNKNOWN");
241244 }
242245
243246 return str;
244247 }
245248
246−static inline void dwc3_decode_get_status(__u8 t, __u16 i, __u16 l, char *str)
249+static inline void dwc3_decode_get_status(__u8 t, __u16 i, __u16 l, char *str,
250+ size_t size)
247251 {
248252 switch (t & USB_RECIP_MASK) {
249253 case USB_RECIP_INTERFACE:
250− sprintf(str, "Get Interface Status(Intf = %d, Length = %d)",
251− i, l);
254+ snprintf(str, size, "Get Interface Status(Intf = %d, Length = %d)",
255+ i, l);
252256 break;
253257 case USB_RECIP_ENDPOINT:
254− sprintf(str, "Get Endpoint Status(ep%d%s)",
258+ snprintf(str, size, "Get Endpoint Status(ep%d%s)",
255259 i & ~USB_DIR_IN,
256260 i & USB_DIR_IN ? "in" : "out");
257261 break;
@@ -259,11 +263,11 @@ static inline void dwc3_decode_get_status(__u8 t, __u16 i, __u16 l, char *str) · 1 unmodified line
259263 }
260264
261265 static inline void dwc3_decode_set_clear_feature(__u8 t, __u8 b, __u16 v,
262− __u16 i, char *str)
266+ __u16 i, char *str, size_t size)
263267 {
264268 switch (t & USB_RECIP_MASK) {
265269 case USB_RECIP_DEVICE:
266− sprintf(str, "%s Device Feature(%s%s)",
270+ snprintf(str, size, "%s Device Feature(%s%s)",
267271 b == USB_REQ_CLEAR_FEATURE ? "Clear" : "Set",
268272 ({char *s;
269273 switch (v) {
@@ -311,13 +315,13 @@ static inline void dwc3_decode_set_clear_feature(__u8 t, __u8 b, __u16 v, · 41 unmodified lines
311315 } s; }) : "");
312316 break;
313317 case USB_RECIP_INTERFACE:
314− sprintf(str, "%s Interface Feature(%s)",
318+ snprintf(str, size, "%s Interface Feature(%s)",
315319 b == USB_REQ_CLEAR_FEATURE ? "Clear" : "Set",
316320 v == USB_INTRF_FUNC_SUSPEND ?
317321 "Function Suspend" : "UNKNOWN");
318322 break;
319323 case USB_RECIP_ENDPOINT:
320− sprintf(str, "%s Endpoint Feature(%s ep%d%s)",
324+ snprintf(str, size, "%s Endpoint Feature(%s ep%d%s)",
321325 b == USB_REQ_CLEAR_FEATURE ? "Clear" : "Set",
322326 v == USB_ENDPOINT_HALT ? "Halt" : "UNKNOWN",
323327 i & ~USB_DIR_IN,
@@ -326,15 +330,15 @@ static inline void dwc3_decode_set_clear_feature(__u8 t, __u8 b, __u16 v, · 2 unmodified lines
326330 }
327331 }
328332
329−static inline void dwc3_decode_set_address(__u16 v, char *str)
333+static inline void dwc3_decode_set_address(__u16 v, char *str, size_t size)
330334 {
331− sprintf(str, "Set Address(Addr = %02x)", v);
335+ snprintf(str, size, "Set Address(Addr = %02x)", v);
332336 }
333337
334338 static inline void dwc3_decode_get_set_descriptor(__u8 t, __u8 b, __u16 v,
335− __u16 i, __u16 l, char *str)
339+ __u16 i, __u16 l, char *str, size_t size)
336340 {
337− sprintf(str, "%s %s Descriptor(Index = %d, Length = %d)",
341+ snprintf(str, size, "%s %s Descriptor(Index = %d, Length = %d)",
338342 b == USB_REQ_GET_DESCRIPTOR ? "Get" : "Set",
339343 ({ char *s;
340344 switch (v >> 8) {
@@ -393,87 +397,92 @@ static inline void dwc3_decode_get_set_descriptor(__u8 t, __u8 b, __u16 v, · 52 unmodified lines
393397 }
394398
395399
396−static inline void dwc3_decode_get_configuration(__u16 l, char *str)
400+static inline void dwc3_decode_get_configuration(__u16 l, char *str,
401+ size_t size)
397402 {
398− sprintf(str, "Get Configuration(Length = %d)", l);
403+ snprintf(str, size, "Get Configuration(Length = %d)", l);
399404 }
400405
401−static inline void dwc3_decode_set_configuration(__u8 v, char *str)
406+static inline void dwc3_decode_set_configuration(__u8 v, char *str, size_t size)
402407 {
403− sprintf(str, "Set Configuration(Config = %d)", v);
408+ snprintf(str, size, "Set Configuration(Config = %d)", v);
404409 }
405410
406−static inline void dwc3_decode_get_intf(__u16 i, __u16 l, char *str)
411+static inline void dwc3_decode_get_intf(__u16 i, __u16 l, char *str,
412+ size_t size)
407413 {
408− sprintf(str, "Get Interface(Intf = %d, Length = %d)", i, l);
414+ snprintf(str, size, "Get Interface(Intf = %d, Length = %d)", i, l);
409415 }
410416
411−static inline void dwc3_decode_set_intf(__u8 v, __u16 i, char *str)
417+static inline void dwc3_decode_set_intf(__u8 v, __u16 i, char *str, size_t size)
412418 {
413− sprintf(str, "Set Interface(Intf = %d, Alt.Setting = %d)", i, v);
419+ snprintf(str, size, "Set Interface(Intf = %d, Alt.Setting = %d)", i, v);
414420 }
415421
416−static inline void dwc3_decode_synch_frame(__u16 i, __u16 l, char *str)
422+static inline void dwc3_decode_synch_frame(__u16 i, __u16 l, char *str,
423+ size_t size)
417424 {
418− sprintf(str, "Synch Frame(Endpoint = %d, Length = %d)", i, l);
425+ snprintf(str, size, "Synch Frame(Endpoint = %d, Length = %d)", i, l);
419426 }
420427
421−static inline void dwc3_decode_set_sel(__u16 l, char *str)
428+static inline void dwc3_decode_set_sel(__u16 l, char *str, size_t size)
422429 {
423− sprintf(str, "Set SEL(Length = %d)", l);
430+ snprintf(str, size, "Set SEL(Length = %d)", l);
424431 }
425432
426−static inline void dwc3_decode_set_isoch_delay(__u8 v, char *str)
433+static inline void dwc3_decode_set_isoch_delay(__u8 v, char *str, size_t size)
427434 {
428− sprintf(str, "Set Isochronous Delay(Delay = %d ns)", v);
435+ snprintf(str, size, "Set Isochronous Delay(Delay = %d ns)", v);
429436 }
430437
431438 /**
432439 * dwc3_decode_ctrl - returns a string represetion of ctrl request
433440 */
434−static inline const char *dwc3_decode_ctrl(char *str, __u8 bRequestType,
435− __u8 bRequest, __u16 wValue, __u16 wIndex, __u16 wLength)
441+static inline const char *dwc3_decode_ctrl(char *str, size_t size,
442+ __u8 bRequestType, __u8 bRequest, __u16 wValue, __u16 wIndex,
443+ __u16 wLength)
436444 {
437445 switch (bRequest) {
438446 case USB_REQ_GET_STATUS:
439− dwc3_decode_get_status(bRequestType, wIndex, wLength, str);
447+ dwc3_decode_get_status(bRequestType, wIndex, wLength, str,
448+ size);
440449 break;
441450 case USB_REQ_CLEAR_FEATURE:
442451 case USB_REQ_SET_FEATURE:
443452 dwc3_decode_set_clear_feature(bRequestType, bRequest, wValue,
444− wIndex, str);
453+ wIndex, str, size);
445454 break;
446455 case USB_REQ_SET_ADDRESS:
447− dwc3_decode_set_address(wValue, str);
456+ dwc3_decode_set_address(wValue, str, size);
448457 break;
449458 case USB_REQ_GET_DESCRIPTOR:
450459 case USB_REQ_SET_DESCRIPTOR:
451460 dwc3_decode_get_set_descriptor(bRequestType, bRequest, wValue,
452− wIndex, wLength, str);
461+ wIndex, wLength, str, size);
453462 break;
454463 case USB_REQ_GET_CONFIGURATION:
455− dwc3_decode_get_configuration(wLength, str);
464+ dwc3_decode_get_configuration(wLength, str, size);
456465 break;
457466 case USB_REQ_SET_CONFIGURATION:
458− dwc3_decode_set_configuration(wValue, str);
467+ dwc3_decode_set_configuration(wValue, str, size);
459468 break;
460469 case USB_REQ_GET_INTERFACE:
461− dwc3_decode_get_intf(wIndex, wLength, str);
470+ dwc3_decode_get_intf(wIndex, wLength, str, size);
462471 break;
463472 case USB_REQ_SET_INTERFACE:
464− dwc3_decode_set_intf(wValue, wIndex, str);
473+ dwc3_decode_set_intf(wValue, wIndex, str, size);
465474 break;
466475 case USB_REQ_SYNCH_FRAME:
467− dwc3_decode_synch_frame(wIndex, wLength, str);
476+ dwc3_decode_synch_frame(wIndex, wLength, str, size);
468477 break;
469478 case USB_REQ_SET_SEL:
470− dwc3_decode_set_sel(wLength, str);
479+ dwc3_decode_set_sel(wLength, str, size);
471480 break;
472481 case USB_REQ_SET_ISOCH_DELAY:
473− dwc3_decode_set_isoch_delay(wValue, str);
482+ dwc3_decode_set_isoch_delay(wValue, str, size);
474483 break;
475484 default:
476− sprintf(str, "%02x %02x %02x %02x %02x %02x %02x %02x",
485+ snprintf(str, size, "%02x %02x %02x %02x %02x %02x %02x %02x",
477486 bRequestType, bRequest,
478487 cpu_to_le16(wValue) & 0xff,
479488 cpu_to_le16(wValue) >> 8,
@@ -490,16 +499,15 @@ static inline const char *dwc3_decode_ctrl(char *str, __u8 bRequestType, · 10 unmodified lines
490499 * dwc3_ep_event_string - returns event name
491500 * @event: then event code
492501 */
493−static inline const char *
494−dwc3_ep_event_string(char *str, const struct dwc3_event_depevt *event,
495− u32 ep0state)
502+static inline const char *dwc3_ep_event_string(char *str, size_t size,
503+ const struct dwc3_event_depevt *event, u32 ep0state)
496504 {
497505 u8 epnum = event->endpoint_number;
498506 size_t len;
499507 int status;
500508 int ret;
501509
502− ret = sprintf(str, "ep%d%s: ", epnum >> 1,
510+ ret = snprintf(str, size, "ep%d%s: ", epnum >> 1,
503511 (epnum & 1) ? "in" : "out");
504512 if (ret < 0)
505513 return "UNKNOWN";
@@ -509,7 +517,7 @@ dwc3_ep_event_string(char *str, const struct dwc3_event_depevt *event, · 3 unmodified lines
509517 switch (event->endpoint_event) {
510518 case DWC3_DEPEVT_XFERCOMPLETE:
511519 len = strlen(str);
512− sprintf(str + len, "Transfer Complete (%c%c%c)",
520+ snprintf(str + len, size - len, "Transfer Complete (%c%c%c)",
513521 status & DEPEVT_STATUS_SHORT ? 'S' : 's',
514522 status & DEPEVT_STATUS_IOC ? 'I' : 'i',
515523 status & DEPEVT_STATUS_LST ? 'L' : 'l');
@@ -517,12 +525,13 @@ dwc3_ep_event_string(char *str, const struct dwc3_event_depevt *event, · 1 unmodified line
517525 len = strlen(str);
518526
519527 if (epnum <= 1)
520− sprintf(str + len, " [%s]", dwc3_ep0_state_string(ep0state));
528+ snprintf(str + len, size - len, " [%s]",
529+ dwc3_ep0_state_string(ep0state));
521530 break;
522531 case DWC3_DEPEVT_XFERINPROGRESS:
523532 len = strlen(str);
524533
525− sprintf(str + len, "Transfer In Progress [%d] (%c%c%c)",
534+ snprintf(str + len, size - len, "Transfer In Progress [%d] (%c%c%c)",
526535 event->parameters,
527536 status & DEPEVT_STATUS_SHORT ? 'S' : 's',
528537 status & DEPEVT_STATUS_IOC ? 'I' : 'i',
@@ -531,47 +540,51 @@ dwc3_ep_event_string(char *str, const struct dwc3_event_depevt *event, · 2 unmodified lines
531540 case DWC3_DEPEVT_XFERNOTREADY:
532541 len = strlen(str);
533542
534− sprintf(str + len, "Transfer Not Ready [%d]%s",
543+ snprintf(str + len, size - len, "Transfer Not Ready [%d]%s",
535544 event->parameters,
536545 status & DEPEVT_STATUS_TRANSFER_ACTIVE ?
537546 " (Active)" : " (Not Active)");
538547
548+ len = strlen(str);
549+
539550 /* Control Endpoints */
540551 if (epnum <= 1) {
541552 int phase = DEPEVT_STATUS_CONTROL_PHASE(event->status);
542553
543554 switch (phase) {
544555 case DEPEVT_STATUS_CONTROL_DATA:
545− strcat(str, " [Data Phase]");
556+ snprintf(str + ret, size - ret,
557+ " [Data Phase]");
546558 break;
547559 case DEPEVT_STATUS_CONTROL_STATUS:
548− strcat(str, " [Status Phase]");
560+ snprintf(str + ret, size - ret,
561+ " [Status Phase]");
549562 }
550563 }
551564 break;
552565 case DWC3_DEPEVT_RXTXFIFOEVT:
553− strcat(str, "FIFO");
566+ snprintf(str + ret, size - ret, "FIFO");
554567 break;
555568 case DWC3_DEPEVT_STREAMEVT:
556569 status = event->status;
557570
558571 switch (status) {
559572 case DEPEVT_STREAMEVT_FOUND:
560− sprintf(str + ret, " Stream %d Found",
573+ snprintf(str + ret, size - ret, " Stream %d Found",
561574 event->parameters);
562575 break;
563576 case DEPEVT_STREAMEVT_NOTFOUND:
564577 default:
565− strcat(str, " Stream Not Found");
578+ snprintf(str + ret, size - ret, " Stream Not Found");
566579 break;
567580 }
568581
569582 break;
570583 case DWC3_DEPEVT_EPCMDCMPLT:
571− strcat(str, "Endpoint Command Complete");
584+ snprintf(str + ret, size - ret, "Endpoint Command Complete");
572585 break;
573586 default:
574− sprintf(str, "UNKNOWN");
587+ snprintf(str, size, "UNKNOWN");
575588 }
576589
577590 return str;
@@ -611,14 +624,15 @@ static inline const char *dwc3_gadget_event_type_string(u8 event) · 33 unmodified lines
611624 }
612625 }
613626
614−static inline const char *dwc3_decode_event(char *str, u32 event, u32 ep0state)
627+static inline const char *dwc3_decode_event(char *str, size_t size, u32 event,
628+ u32 ep0state)
615629 {
616630 const union dwc3_event evt = (union dwc3_event) event;
617631
618632 if (evt.type.is_devspec)
619− return dwc3_gadget_event_string(str, &evt.devt);
633+ return dwc3_gadget_event_string(str, size, &evt.devt);
620634 else
621− return dwc3_ep_event_string(str, &evt.depevt, ep0state);
635+ return dwc3_ep_event_string(str, size, &evt.depevt, ep0state);
622636 }
623637
624638 static inline const char *dwc3_ep_cmd_status_string(int status)
drivers/usb/dwc3/drd.c+7−2
@@ -457,8 +457,13 @@ static struct extcon_dev *dwc3_get_extcon(struct dwc3 *dwc) · 456 unmodified lines
457457 * This device property is for kernel internal use only and
458458 * is expected to be set by the glue code.
459459 */
460− if (device_property_read_string(dev, "linux,extcon-name", &name) == 0)
461− return extcon_get_extcon_dev(name);
460+ if (device_property_read_string(dev, "linux,extcon-name", &name) == 0) {
461+ edev = extcon_get_extcon_dev(name);
462+ if (!edev)
463+ return ERR_PTR(-EPROBE_DEFER);
464+
465+ return edev;
466+ }
462467
463468 np_phy = of_parse_phandle(dev->of_node, "phys", 0);
464469 np_conn = of_graph_get_remote_node(np_phy, -1, -1);
drivers/usb/dwc3/dwc3-haps.c+9−0
@@ -106,6 +106,15 @@ static const struct pci_device_id dwc3_haps_id_table[] = { · 105 unmodified lines
106106 {
107107 PCI_DEVICE(PCI_VENDOR_ID_SYNOPSYS,
108108 PCI_DEVICE_ID_SYNOPSYS_HAPSUSB3),
109+ /*
110+ * i.MX6QP and i.MX7D platform use a PCIe controller with the
111+ * same VID and PID as this USB controller. The system may
112+ * incorrectly match this driver to that PCIe controller. To
113+ * workaround this, specifically use class type USB to prevent
114+ * incorrect driver matching.
115+ */
116+ .class = (PCI_CLASS_SERIAL_USB << 8),
117+ .class_mask = 0xffff00,
109118 },
110119 {
111120 PCI_DEVICE(PCI_VENDOR_ID_SYNOPSYS,
drivers/usb/dwc3/dwc3-keystone.c+10−1
@@ -106,6 +106,10 @@ static int kdwc3_probe(struct platform_device *pdev) · 105 unmodified lines
106106 goto err_irq;
107107 }
108108
109+ /* IRQ processing not required currently for AM65 */
110+ if (of_device_is_compatible(node, "ti,am654-dwc3"))
111+ goto skip_irq;
112+
109113 irq = platform_get_irq(pdev, 0);
110114 if (irq < 0) {
111115 dev_err(&pdev->dev, "missing irq\n");
@@ -123,6 +127,7 @@ static int kdwc3_probe(struct platform_device *pdev) · 11 unmodified lines
123127
124128 kdwc3_enable_irqs(kdwc);
125129
130+skip_irq:
126131 error = of_platform_populate(node, NULL, NULL, dev);
127132 if (error) {
128133 dev_err(&pdev->dev, "failed to create dwc3 core\n");
@@ -152,8 +157,11 @@ static int kdwc3_remove_core(struct device *dev, void *c) · 23 unmodified lines
152157 static int kdwc3_remove(struct platform_device *pdev)
153158 {
154159 struct dwc3_keystone *kdwc = platform_get_drvdata(pdev);
160+ struct device_node *node = pdev->dev.of_node;
161+
162+ if (!of_device_is_compatible(node, "ti,am654-dwc3"))
163+ kdwc3_disable_irqs(kdwc);
155164
156− kdwc3_disable_irqs(kdwc);
157165 device_for_each_child(&pdev->dev, NULL, kdwc3_remove_core);
158166 pm_runtime_put_sync(kdwc->dev);
159167 pm_runtime_disable(kdwc->dev);
@@ -165,6 +173,7 @@ static int kdwc3_remove(struct platform_device *pdev) · 5 unmodified lines
165173
166174 static const struct of_device_id kdwc3_of_match[] = {
167175 { .compatible = "ti,keystone-dwc3", },
176+ { .compatible = "ti,am654-dwc3" },
168177 {},
169178 };
170179 MODULE_DEVICE_TABLE(of, kdwc3_of_match);
drivers/usb/dwc3/dwc3-qcom.c+1−0
@@ -595,6 +595,7 @@ static const struct dev_pm_ops dwc3_qcom_dev_pm_ops = { · 594 unmodified lines
595595 static const struct of_device_id dwc3_qcom_of_match[] = {
596596 { .compatible = "qcom,dwc3" },
597597 { .compatible = "qcom,msm8996-dwc3" },
598+ { .compatible = "qcom,msm8998-dwc3" },
598599 { .compatible = "qcom,sdm845-dwc3" },
599600 { }
600601 };
drivers/usb/dwc3/gadget.c+34−31
@@ -174,7 +174,6 @@ static void dwc3_gadget_del_and_unmap_request(struct dwc3_ep *dep, · 173 unmodified lines
174174 {
175175 struct dwc3 *dwc = dep->dwc;
176176
177− req->started = false;
178177 list_del(&req->list);
179178 req->remaining = 0;
180179 req->needs_extra_trb = false;
@@ -209,6 +208,7 @@ void dwc3_gadget_giveback(struct dwc3_ep *dep, struct dwc3_request *req, · 28 unmodified lines
209208 struct dwc3 *dwc = dep->dwc;
210209
211210 dwc3_gadget_del_and_unmap_request(dep, req, status);
211+ req->status = DWC3_REQUEST_STATUS_COMPLETED;
212212
213213 spin_unlock(&dwc->lock);
214214 usb_gadget_giveback_request(&dep->endpoint, &req->request);
@@ -384,19 +384,9 @@ int dwc3_send_gadget_ep_cmd(struct dwc3_ep *dep, unsigned cmd, · 169 unmodified lines
384384
385385 trace_dwc3_gadget_ep_cmd(dep, cmd, params, cmd_status);
386386
387− if (ret == 0) {
388− switch (DWC3_DEPCMD_CMD(cmd)) {
389− case DWC3_DEPCMD_STARTTRANSFER:
390− dep->flags |= DWC3_EP_TRANSFER_STARTED;
391− dwc3_gadget_ep_get_transfer_index(dep);
392− break;
393− case DWC3_DEPCMD_ENDTRANSFER:
394− dep->flags &= ~DWC3_EP_TRANSFER_STARTED;
395− break;
396− default:
397− /* nothing */
398− break;
399− }
387+ if (ret == 0 && DWC3_DEPCMD_CMD(cmd) == DWC3_DEPCMD_STARTTRANSFER) {
388+ dep->flags |= DWC3_EP_TRANSFER_STARTED;
389+ dwc3_gadget_ep_get_transfer_index(dep);
400390 }
401391
402392 if (saved_config) {
@@ -642,7 +632,6 @@ static int __dwc3_gadget_ep_enable(struct dwc3_ep *dep, unsigned int action) · 239 unmodified lines
642632
643633 dep->type = usb_endpoint_type(desc);
644634 dep->flags |= DWC3_EP_ENABLED;
645− dep->flags &= ~DWC3_EP_END_TRANSFER_PENDING;
646635
647636 reg = dwc3_readl(dwc->regs, DWC3_DALEPENA);
648637 reg |= DWC3_DALEPENA_EP(dep->number);
@@ -698,12 +687,13 @@ out: · 49 unmodified lines
698687 return 0;
699688 }
700689
701−static void dwc3_stop_active_transfer(struct dwc3_ep *dep, bool force);
690+static void dwc3_stop_active_transfer(struct dwc3_ep *dep, bool force,
691+ bool interrupt);
702692 static void dwc3_remove_requests(struct dwc3 *dwc, struct dwc3_ep *dep)
703693 {
704694 struct dwc3_request *req;
705695
706− dwc3_stop_active_transfer(dep, true);
696+ dwc3_stop_active_transfer(dep, true, false);
707697
708698 /* - giveback all requests to gadget driver */
709699 while (!list_empty(&dep->started_list)) {
@@ -748,7 +738,7 @@ static int __dwc3_gadget_ep_disable(struct dwc3_ep *dep) · 38 unmodified lines
748738
749739 dep->stream_capable = false;
750740 dep->type = 0;
751− dep->flags &= DWC3_EP_END_TRANSFER_PENDING;
741+ dep->flags = 0;
752742
753743 /* Clear out the ep descriptors for non-ep0 */
754744 if (dep->number > 1) {
@@ -847,6 +837,7 @@ static struct usb_request *dwc3_gadget_ep_alloc_request(struct usb_ep *ep, · 92 unmodified lines
847837 req->direction = dep->direction;
848838 req->epnum = dep->number;
849839 req->dep = dep;
840+ req->status = DWC3_REQUEST_STATUS_UNKNOWN;
850841
851842 trace_dwc3_alloc_request(req);
852843
@@ -1360,7 +1351,7 @@ static int dwc3_gadget_start_isoc_quirk(struct dwc3_ep *dep) · 507 unmodified lines
13601351 * to wait for the next XferNotReady to test the command again
13611352 */
13621353 if (cmd_status == 0) {
1363− dwc3_stop_active_transfer(dep, true);
1354+ dwc3_stop_active_transfer(dep, true, true);
13641355 return 0;
13651356 }
13661357 }
@@ -1435,6 +1426,11 @@ static int __dwc3_gadget_ep_queue(struct dwc3_ep *dep, struct dwc3_request *req) · 68 unmodified lines
14351426 &req->request, req->dep->name))
14361427 return -EINVAL;
14371428
1429+ if (WARN(req->status < DWC3_REQUEST_STATUS_COMPLETED,
1430+ "%s: request %pK already in flight\n",
1431+ dep->name, &req->request))
1432+ return -EINVAL;
1433+
14381434 pm_runtime_get(dwc->dev);
14391435
14401436 req->request.actual = 0;
@@ -1443,6 +1439,7 @@ static int __dwc3_gadget_ep_queue(struct dwc3_ep *dep, struct dwc3_request *req) · 2 unmodified lines
14431439 trace_dwc3_ep_queue(req);
14441440
14451441 list_add_tail(&req->list, &dep->pending_list);
1442+ req->status = DWC3_REQUEST_STATUS_QUEUED;
14461443
14471444 /*
14481445 * NOTICE: Isochronous endpoints should NEVER be prestarted. We must
@@ -1506,6 +1503,8 @@ static void dwc3_gadget_ep_skip_trbs(struct dwc3_ep *dep, struct dwc3_request *r · 57 unmodified lines
15061503 trb->ctrl &= ~DWC3_TRB_CTRL_HWO;
15071504 dwc3_ep_inc_deq(dep);
15081505 }
1506+
1507+ req->num_trbs = 0;
15091508 }
15101509
15111510 static void dwc3_gadget_ep_cleanup_cancelled_requests(struct dwc3_ep *dep)
@@ -1547,13 +1546,16 @@ static int dwc3_gadget_ep_dequeue(struct usb_ep *ep, · 35 unmodified lines
15471546 }
15481547 if (r == req) {
15491548 /* wait until it is processed */
1550− dwc3_stop_active_transfer(dep, true);
1549+ dwc3_stop_active_transfer(dep, true, true);
15511550
15521551 if (!r->trb)
15531552 goto out0;
15541553
15551554 dwc3_gadget_move_cancelled_request(req);
1556− goto out0;
1555+ if (dep->flags & DWC3_EP_TRANSFER_STARTED)
1556+ goto out0;
1557+ else
1558+ goto out1;
15571559 }
15581560 dev_err(dwc->dev, "request %pK was not queued to %s\n",
15591561 request, ep->name);
@@ -1561,6 +1563,7 @@ static int dwc3_gadget_ep_dequeue(struct usb_ep *ep, · 1 unmodified line
15611563 goto out0;
15621564 }
15631565
1566+out1:
15641567 dwc3_gadget_giveback(dep, req, -ECONNRESET);
15651568
15661569 out0:
@@ -2500,7 +2503,7 @@ static void dwc3_gadget_endpoint_transfer_in_progress(struct dwc3_ep *dep, · 933 unmodified lines
25002503 dwc3_gadget_ep_cleanup_completed_requests(dep, event, status);
25012504
25022505 if (stop) {
2503− dwc3_stop_active_transfer(dep, true);
2506+ dwc3_stop_active_transfer(dep, true, true);
25042507 dep->flags = DWC3_EP_ENABLED;
25052508 }
25062509
@@ -2547,7 +2550,7 @@ static void dwc3_endpoint_interrupt(struct dwc3 *dwc, · 40 unmodified lines
25472550 dep = dwc->eps[epnum];
25482551
25492552 if (!(dep->flags & DWC3_EP_ENABLED)) {
2550− if (!(dep->flags & DWC3_EP_END_TRANSFER_PENDING))
2553+ if (!(dep->flags & DWC3_EP_TRANSFER_STARTED))
25512554 return;
25522555
25532556 /* Handle only EPCMDCMPLT when EP disabled */
@@ -2571,7 +2574,7 @@ static void dwc3_endpoint_interrupt(struct dwc3 *dwc, · 17 unmodified lines
25712574 cmd = DEPEVT_PARAMETER_CMD(event->parameters);
25722575
25732576 if (cmd == DWC3_DEPCMD_ENDTRANSFER) {
2574− dep->flags &= ~DWC3_EP_END_TRANSFER_PENDING;
2577+ dep->flags &= ~DWC3_EP_TRANSFER_STARTED;
25752578 dwc3_gadget_ep_cleanup_cancelled_requests(dep);
25762579 }
25772580 break;
@@ -2621,15 +2624,15 @@ static void dwc3_reset_gadget(struct dwc3 *dwc) · 43 unmodified lines
26212624 }
26222625 }
26232626
2624−static void dwc3_stop_active_transfer(struct dwc3_ep *dep, bool force)
2627+static void dwc3_stop_active_transfer(struct dwc3_ep *dep, bool force,
2628+ bool interrupt)
26252629 {
26262630 struct dwc3 *dwc = dep->dwc;
26272631 struct dwc3_gadget_ep_cmd_params params;
26282632 u32 cmd;
26292633 int ret;
26302634
2631− if ((dep->flags & DWC3_EP_END_TRANSFER_PENDING) ||
2632− !dep->resource_index)
2635+ if (!(dep->flags & DWC3_EP_TRANSFER_STARTED))
26332636 return;
26342637
26352638 /*
@@ -2665,17 +2668,15 @@ static void dwc3_stop_active_transfer(struct dwc3_ep *dep, bool force) · 29 unmodified lines
26652668
26662669 cmd = DWC3_DEPCMD_ENDTRANSFER;
26672670 cmd |= force ? DWC3_DEPCMD_HIPRI_FORCERM : 0;
2668− cmd |= DWC3_DEPCMD_CMDIOC;
2671+ cmd |= interrupt ? DWC3_DEPCMD_CMDIOC : 0;
26692672 cmd |= DWC3_DEPCMD_PARAM(dep->resource_index);
26702673 memset(&params, 0, sizeof(params));
26712674 ret = dwc3_send_gadget_ep_cmd(dep, cmd, &params);
26722675 WARN_ON_ONCE(ret);
26732676 dep->resource_index = 0;
26742677
2675− if (dwc3_is_usb31(dwc) || dwc->revision < DWC3_REVISION_310A) {
2676− dep->flags |= DWC3_EP_END_TRANSFER_PENDING;
2678+ if (dwc3_is_usb31(dwc) || dwc->revision < DWC3_REVISION_310A)
26772679 udelay(100);
2678− }
26792680 }
26802681
26812682 static void dwc3_clear_stall_all_ep(struct dwc3 *dwc)
@@ -3339,6 +3340,8 @@ int dwc3_gadget_init(struct dwc3 *dwc) · 657 unmodified lines
33393340 goto err4;
33403341 }
33413342
3343+ dwc3_gadget_set_speed(&dwc->gadget, dwc->maximum_speed);
3344+
33423345 return 0;
33433346
33443347 err4:
drivers/usb/dwc3/gadget.h+2−2
@@ -75,7 +75,7 @@ static inline void dwc3_gadget_move_started_request(struct dwc3_request *req) · 74 unmodified lines
7575 {
7676 struct dwc3_ep *dep = req->dep;
7777
78− req->started = true;
78+ req->status = DWC3_REQUEST_STATUS_STARTED;
7979 list_move_tail(&req->list, &dep->started_list);
8080 }
8181
@@ -90,7 +90,7 @@ static inline void dwc3_gadget_move_cancelled_request(struct dwc3_request *req) · 8 unmodified lines
9090 {
9191 struct dwc3_ep *dep = req->dep;
9292
93− req->started = false;
93+ req->status = DWC3_REQUEST_STATUS_CANCELLED;
9494 list_move_tail(&req->list, &dep->cancelled_list);
9595 }
9696
drivers/usb/dwc3/trace.h+5−5
@@ -59,8 +59,8 @@ DECLARE_EVENT_CLASS(dwc3_log_event, · 58 unmodified lines
5959 __entry->ep0state = dwc->ep0state;
6060 ),
6161 TP_printk("event (%08x): %s", __entry->event,
62− dwc3_decode_event(__get_str(str), __entry->event,
63− __entry->ep0state))
62+ dwc3_decode_event(__get_str(str), DWC3_MSG_MAX,
63+ __entry->event, __entry->ep0state))
6464 );
6565
6666 DEFINE_EVENT(dwc3_log_event, dwc3_event,
@@ -86,7 +86,8 @@ DECLARE_EVENT_CLASS(dwc3_log_ctrl, · 19 unmodified lines
8686 __entry->wIndex = le16_to_cpu(ctrl->wIndex);
8787 __entry->wLength = le16_to_cpu(ctrl->wLength);
8888 ),
89− TP_printk("%s", dwc3_decode_ctrl(__get_str(str), __entry->bRequestType,
89+ TP_printk("%s", dwc3_decode_ctrl(__get_str(str), DWC3_MSG_MAX,
90+ __entry->bRequestType,
9091 __entry->bRequest, __entry->wValue,
9192 __entry->wIndex, __entry->wLength)
9293 )
@@ -305,7 +306,7 @@ DECLARE_EVENT_CLASS(dwc3_log_ep, · 212 unmodified lines
305306 __entry->trb_enqueue = dep->trb_enqueue;
306307 __entry->trb_dequeue = dep->trb_dequeue;
307308 ),
308− TP_printk("%s: mps %d/%d streams %d burst %d ring %d/%d flags %c:%c%c%c%c:%c:%c",
309+ TP_printk("%s: mps %d/%d streams %d burst %d ring %d/%d flags %c:%c%c%c%c:%c",
309310 __get_str(name), __entry->maxpacket,
310311 __entry->maxpacket_limit, __entry->max_streams,
311312 __entry->maxburst, __entry->trb_enqueue,
@@ -315,7 +316,6 @@ DECLARE_EVENT_CLASS(dwc3_log_ep, · 3 unmodified lines
315316 __entry->flags & DWC3_EP_WEDGE ? 'W' : 'w',
316317 __entry->flags & DWC3_EP_TRANSFER_STARTED ? 'B' : 'b',
317318 __entry->flags & DWC3_EP_PENDING_REQUEST ? 'P' : 'p',
318− __entry->flags & DWC3_EP_END_TRANSFER_PENDING ? 'E' : 'e',
319319 __entry->direction ? '<' : '>'
320320 )
321321 );
drivers/usb/gadget/Kconfig+1−0
@@ -1,3 +1,4 @@
1+# SPDX-License-Identifier: GPL-2.0
12 #
23 # USB Gadget support on a system involves
34 # (a) a peripheral controller, and
drivers/usb/gadget/epautoconf.c+24−17
@@ -67,9 +67,6 @@ struct usb_ep *usb_ep_autoconfig_ss( · 66 unmodified lines
6767 )
6868 {
6969 struct usb_ep *ep;
70− u8 type;
71−
72− type = desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK;
7370
7471 if (gadget->ops->match_ep) {
7572 ep = gadget->ops->match_ep(gadget, desc, ep_comp);
@@ -109,16 +106,6 @@ found_ep: · 33 unmodified lines
109106 desc->bEndpointAddress |= gadget->out_epnum;
110107 }
111108
112− /* report (variable) full speed bulk maxpacket */
113− if ((type == USB_ENDPOINT_XFER_BULK) && !ep_comp) {
114− int size = ep->maxpacket_limit;
115−
116− /* min() doesn't work on bitfields with gcc-3.5 */
117− if (size > 64)
118− size = 64;
119− desc->wMaxPacketSize = cpu_to_le16(size);
120− }
121−
122109 ep->address = desc->bEndpointAddress;
123110 ep->desc = NULL;
124111 ep->comp_desc = NULL;
@@ -152,9 +139,10 @@ EXPORT_SYMBOL_GPL(usb_ep_autoconfig_ss); · 27 unmodified lines
152139 *
153140 * On success, this returns an claimed usb_ep, and modifies the endpoint
154141 * descriptor bEndpointAddress. For bulk endpoints, the wMaxPacket value
155− * is initialized as if the endpoint were used at full speed. To prevent
156− * the endpoint from being returned by a later autoconfig call, claims it
157− * by assigning ep->claimed to true.
142+ * is initialized as if the endpoint were used at full speed. Because of
143+ * that the users must consider adjusting the autoconfigured descriptor.
144+ * To prevent the endpoint from being returned by a later autoconfig call,
145+ * claims it by assigning ep->claimed to true.
158146 *
159147 * On failure, this returns a null endpoint descriptor.
160148 */
@@ -163,7 +151,26 @@ struct usb_ep *usb_ep_autoconfig( · 2 unmodified lines
163151 struct usb_endpoint_descriptor *desc
164152 )
165153 {
166− return usb_ep_autoconfig_ss(gadget, desc, NULL);
154+ struct usb_ep *ep;
155+ u8 type;
156+
157+ ep = usb_ep_autoconfig_ss(gadget, desc, NULL);
158+ if (!ep)
159+ return NULL;
160+
161+ type = desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK;
162+
163+ /* report (variable) full speed bulk maxpacket */
164+ if (type == USB_ENDPOINT_XFER_BULK) {
165+ int size = ep->maxpacket_limit;
166+
167+ /* min() doesn't work on bitfields with gcc-3.5 */
168+ if (size > 64)
169+ size = 64;
170+ desc->wMaxPacketSize = cpu_to_le16(size);
171+ }
172+
173+ return ep;
167174 }
168175 EXPORT_SYMBOL_GPL(usb_ep_autoconfig);
169176
drivers/usb/gadget/function/f_fs.c+12−0
@@ -1082,6 +1082,7 @@ static ssize_t ffs_epfile_io(struct file *file, struct ffs_io_data *io_data) · 1081 unmodified lines
10821082 * condition with req->complete callback.
10831083 */
10841084 usb_ep_dequeue(ep->ep, req);
1085+ wait_for_completion(&done);
10851086 interrupted = ep->status < 0;
10861087 }
10871088
@@ -2843,12 +2844,18 @@ static int __ffs_func_bind_do_descs(enum ffs_entity_type type, u8 *valuep, · 1755 unmodified lines
28432844 struct usb_request *req;
28442845 struct usb_ep *ep;
28452846 u8 bEndpointAddress;
2847+ u16 wMaxPacketSize;
28462848
28472849 /*
28482850 * We back up bEndpointAddress because autoconfig overwrites
28492851 * it with physical endpoint address.
28502852 */
28512853 bEndpointAddress = ds->bEndpointAddress;
2854+ /*
2855+ * We back up wMaxPacketSize because autoconfig treats
2856+ * endpoint descriptors as if they were full speed.
2857+ */
2858+ wMaxPacketSize = ds->wMaxPacketSize;
28522859 pr_vdebug("autoconfig\n");
28532860 ep = usb_ep_autoconfig(func->gadget, ds);
28542861 if (unlikely(!ep))
@@ -2869,6 +2876,11 @@ static int __ffs_func_bind_do_descs(enum ffs_entity_type type, u8 *valuep, · 14 unmodified lines
28692876 */
28702877 if (func->ffs->user_flags & FUNCTIONFS_VIRTUAL_ADDR)
28712878 ds->bEndpointAddress = bEndpointAddress;
2879+ /*
2880+ * Restore wMaxPacketSize which was potentially
2881+ * overwritten by autoconfig.
2882+ */
2883+ ds->wMaxPacketSize = wMaxPacketSize;
28722884 }
28732885 ffs_dump_mem(": Rewritten ep desc", ds, ds->bLength);
28742886
drivers/usb/gadget/function/f_uac1.c+6−4
@@ -459,10 +459,10 @@ static int f_audio_set_alt(struct usb_function *f, unsigned intf, unsigned alt) · 458 unmodified lines
459459 } else if (intf == uac1->as_in_intf) {
460460 uac1->as_in_alt = alt;
461461
462− if (alt)
463− ret = u_audio_start_playback(&uac1->g_audio);
464− else
465− u_audio_stop_playback(&uac1->g_audio);
462+ if (alt)
463+ ret = u_audio_start_playback(&uac1->g_audio);
464+ else
465+ u_audio_stop_playback(&uac1->g_audio);
466466 } else {
467467 dev_err(dev, "%s:%d Error!\n", __func__, __LINE__);
468468 return -EINVAL;
@@ -568,6 +568,7 @@ static int f_audio_bind(struct usb_configuration *c, struct usb_function *f) · 99 unmodified lines
568568 goto fail;
569569 as_out_interface_alt_0_desc.bInterfaceNumber = status;
570570 as_out_interface_alt_1_desc.bInterfaceNumber = status;
571+ ac_header_desc.baInterfaceNr[0] = status;
571572 uac1->as_out_intf = status;
572573 uac1->as_out_alt = 0;
573574
@@ -576,6 +577,7 @@ static int f_audio_bind(struct usb_configuration *c, struct usb_function *f) · 2 unmodified lines
576577 goto fail;
577578 as_in_interface_alt_0_desc.bInterfaceNumber = status;
578579 as_in_interface_alt_1_desc.bInterfaceNumber = status;
580+ ac_header_desc.baInterfaceNr[1] = status;
579581 uac1->as_in_intf = status;
580582 uac1->as_in_alt = 0;
581583
drivers/usb/gadget/function/u_ecm.h+1−1
@@ -7,7 +7,7 @@ · 6 unmodified lines
77 * Copyright (c) 2013 Samsung Electronics Co., Ltd.
88 * http://www.samsung.com
99 *
10− * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
10+ * Author: Andrzej Pietrasiewicz <andrzejtp2010@gmail.com>
1111 */
1212
1313 #ifndef U_ECM_H
drivers/usb/gadget/function/u_eem.h+1−1
@@ -7,7 +7,7 @@ · 6 unmodified lines
77 * Copyright (c) 2013 Samsung Electronics Co., Ltd.
88 * http://www.samsung.com
99 *
10− * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
10+ * Author: Andrzej Pietrasiewicz <andrzejtp2010@gmail.com>
1111 */
1212
1313 #ifndef U_EEM_H
drivers/usb/gadget/function/u_ether_configfs.h+1−1
@@ -7,7 +7,7 @@ · 6 unmodified lines
77 * Copyright (c) 2013 Samsung Electronics Co., Ltd.
88 * http://www.samsung.com
99 *
10− * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
10+ * Author: Andrzej Pietrasiewicz <andrzejtp2010@gmail.com>
1111 */
1212
1313 #ifndef __U_ETHER_CONFIGFS_H
drivers/usb/gadget/function/u_fs.h+1−1
@@ -7,7 +7,7 @@ · 6 unmodified lines
77 * Copyright (c) 2013 Samsung Electronics Co., Ltd.
88 * http://www.samsung.com
99 *
10− * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
10+ * Author: Andrzej Pietrasiewicz <andrzejtp2010@gmail.com>
1111 */
1212
1313 #ifndef U_FFS_H
drivers/usb/gadget/function/u_gether.h+1−1
@@ -7,7 +7,7 @@ · 6 unmodified lines
77 * Copyright (c) 2013 Samsung Electronics Co., Ltd.
88 * http://www.samsung.com
99 *
10− * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
10+ * Author: Andrzej Pietrasiewicz <andrzejtp2010@gmail.com>
1111 */
1212
1313 #ifndef U_GETHER_H
drivers/usb/gadget/function/u_hid.h+1−1
@@ -7,7 +7,7 @@ · 6 unmodified lines
77 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
88 * http://www.samsung.com
99 *
10− * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
10+ * Author: Andrzej Pietrasiewicz <andrzejtp2010@gmail.com>
1111 */
1212
1313 #ifndef U_HID_H
drivers/usb/gadget/function/u_midi.h+1−1
@@ -7,7 +7,7 @@ · 6 unmodified lines
77 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
88 * http://www.samsung.com
99 *
10− * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
10+ * Author: Andrzej Pietrasiewicz <andrzejtp2010@gmail.com>
1111 */
1212
1313 #ifndef U_MIDI_H
drivers/usb/gadget/function/u_ncm.h+1−1
@@ -7,7 +7,7 @@ · 6 unmodified lines
77 * Copyright (c) 2013 Samsung Electronics Co., Ltd.
88 * http://www.samsung.com
99 *
10− * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
10+ * Author: Andrzej Pietrasiewicz <andrzejtp2010@gmail.com>
1111 */
1212
1313 #ifndef U_NCM_H
drivers/usb/gadget/function/u_printer.h+1−1
@@ -7,7 +7,7 @@ · 6 unmodified lines
77 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
88 * http://www.samsung.com
99 *
10− * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
10+ * Author: Andrzej Pietrasiewicz <andrzejtp2010@gmail.com>
1111 */
1212
1313 #ifndef U_PRINTER_H
drivers/usb/gadget/function/u_rndis.h+1−1
@@ -7,7 +7,7 @@ · 6 unmodified lines
77 * Copyright (c) 2013 Samsung Electronics Co., Ltd.
88 * http://www.samsung.com
99 *
10− * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
10+ * Author: Andrzej Pietrasiewicz <andrzejtp2010@gmail.com>
1111 */
1212
1313 #ifndef U_RNDIS_H
drivers/usb/gadget/function/u_serial.c+14−21
@@ -16,7 +16,6 @@ · 15 unmodified lines
1616
1717 #include <linux/kernel.h>
1818 #include <linux/sched.h>
19−#include <linux/interrupt.h>
2019 #include <linux/device.h>
2120 #include <linux/delay.h>
2221 #include <linux/tty.h>
@@ -26,6 +25,7 @@ · 3 unmodified lines
2625 #include <linux/module.h>
2726 #include <linux/console.h>
2827 #include <linux/kthread.h>
28+#include <linux/workqueue.h>
2929 #include <linux/kfifo.h>
3030
3131 #include "u_serial.h"
@@ -110,7 +110,7 @@ struct gs_port { · 78 unmodified lines
110110 int read_allocated;
111111 struct list_head read_queue;
112112 unsigned n_read;
113− struct tasklet_struct push;
113+ struct delayed_work push;
114114
115115 struct list_head write_pool;
116116 int write_started;
@@ -352,9 +352,10 @@ __acquires(&port->port_lock) · 235 unmodified lines
352352 * So QUEUE_SIZE packets plus however many the FIFO holds (usually two)
353353 * can be buffered before the TTY layer's buffers (currently 64 KB).
354354 */
355−static void gs_rx_push(unsigned long _port)
355+static void gs_rx_push(struct work_struct *work)
356356 {
357− struct gs_port *port = (void *)_port;
357+ struct delayed_work *w = to_delayed_work(work);
358+ struct gs_port *port = container_of(w, struct gs_port, push);
358359 struct tty_struct *tty;
359360 struct list_head *queue = &port->read_queue;
360361 bool disconnect = false;
@@ -429,21 +430,13 @@ static void gs_rx_push(unsigned long _port) · 68 unmodified lines
429430
430431 /* We want our data queue to become empty ASAP, keeping data
431432 * in the tty and ldisc (not here). If we couldn't push any
432− * this time around, there may be trouble unless there's an
433− * implicit tty_unthrottle() call on its way...
433+ * this time around, RX may be starved, so wait until next jiffy.
434434 *
435− * REVISIT we should probably add a timer to keep the tasklet
436− * from starving ... but it's not clear that case ever happens.
435+ * We may leave non-empty queue only when there is a tty, and
436+ * either it is throttled or there is no more room in flip buffer.
437437 */
438− if (!list_empty(queue) && tty) {
439− if (!tty_throttled(tty)) {
440− if (do_push)
441− tasklet_schedule(&port->push);
442− else
443− pr_warn("ttyGS%d: RX not scheduled?\n",
444− port->port_num);
445− }
446− }
438+ if (!list_empty(queue) && !tty_throttled(tty))
439+ schedule_delayed_work(&port->push, 1);
447440
448441 /* If we're still connected, refill the USB RX queue. */
449442 if (!disconnect && port->port_usb)
@@ -459,7 +452,7 @@ static void gs_read_complete(struct usb_ep *ep, struct usb_request *req) · 9 unmodified lines
459452 /* Queue all received data until the tty layer is ready for it. */
460453 spin_lock(&port->port_lock);
461454 list_add_tail(&req->list, &port->read_queue);
462− tasklet_schedule(&port->push);
455+ schedule_delayed_work(&port->push, 0);
463456 spin_unlock(&port->port_lock);
464457 }
465458
@@ -854,8 +847,8 @@ static void gs_unthrottle(struct tty_struct *tty) · 388 unmodified lines
854847 * rts/cts, or other handshaking with the host, but if the
855848 * read queue backs up enough we'll be NAKing OUT packets.
856849 */
857− tasklet_schedule(&port->push);
858850 pr_vdebug("ttyGS%d: unthrottle\n", port->port_num);
851+ schedule_delayed_work(&port->push, 0);
859852 }
860853 spin_unlock_irqrestore(&port->port_lock, flags);
861854 }
@@ -1159,7 +1152,7 @@ gs_port_alloc(unsigned port_num, struct usb_cdc_line_coding *coding) · 297 unmodified lines
11591152 init_waitqueue_head(&port->drain_wait);
11601153 init_waitqueue_head(&port->close_wait);
11611154
1162− tasklet_init(&port->push, gs_rx_push, (unsigned long) port);
1155+ INIT_DELAYED_WORK(&port->push, gs_rx_push);
11631156
11641157 INIT_LIST_HEAD(&port->read_pool);
11651158 INIT_LIST_HEAD(&port->read_queue);
@@ -1186,7 +1179,7 @@ static int gs_closed(struct gs_port *port) · 20 unmodified lines
11861179
11871180 static void gserial_free_port(struct gs_port *port)
11881181 {
1189− tasklet_kill(&port->push);
1182+ cancel_delayed_work_sync(&port->push);
11901183 /* wait for old opens to finish */
11911184 wait_event(port->close_wait, gs_closed(port));
11921185 WARN_ON(port->port_usb != NULL);
drivers/usb/gadget/function/u_uac2.h+1−1
@@ -7,7 +7,7 @@ · 6 unmodified lines
77 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
88 * http://www.samsung.com
99 *
10− * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
10+ * Author: Andrzej Pietrasiewicz <andrzejtp2010@gmail.com>
1111 */
1212
1313 #ifndef U_UAC2_H
drivers/usb/gadget/function/u_uvc.h+1−1
@@ -7,7 +7,7 @@ · 6 unmodified lines
77 * Copyright (c) 2013-2014 Samsung Electronics Co., Ltd.
88 * http://www.samsung.com
99 *
10− * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
10+ * Author: Andrzej Pietrasiewicz <andrzejtp2010@gmail.com>
1111 */
1212
1313 #ifndef U_UVC_H
drivers/usb/gadget/function/uvc.h+2−0
@@ -56,6 +56,8 @@ extern unsigned int uvc_gadget_trace_param; · 55 unmodified lines
5656 dev_dbg(&(f)->config->cdev->gadget->dev, "%s: " fmt, (f)->name, ##args)
5757 #define uvcg_info(f, fmt, args...) \
5858 dev_info(&(f)->config->cdev->gadget->dev, "%s: " fmt, (f)->name, ##args)
59+#define uvcg_warn(f, fmt, args...) \
60+ dev_warn(&(f)->config->cdev->gadget->dev, "%s: " fmt, (f)->name, ##args)
5961 #define uvcg_err(f, fmt, args...) \
6062 dev_err(&(f)->config->cdev->gadget->dev, "%s: " fmt, (f)->name, ##args)
6163
drivers/usb/gadget/function/uvc_configfs.c+1−9
@@ -7,7 +7,7 @@ · 6 unmodified lines
77 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
88 * http://www.samsung.com
99 *
10− * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
10+ * Author: Andrzej Pietrasiewicz <andrzejtp2010@gmail.com>
1111 */
1212
1313 #include <linux/sort.h>
@@ -1570,10 +1570,6 @@ uvcg_uncompressed_##cname##_store(struct config_item *item, \ · 1556 unmodified lines
15701570 if (ret) \
15711571 goto end; \
15721572 \
1573− if (num > 255) { \
1574− ret = -EINVAL; \
1575− goto end; \
1576− } \
15771573 u->desc.aname = num; \
15781574 ret = len; \
15791575 end: \
@@ -1767,10 +1763,6 @@ uvcg_mjpeg_##cname##_store(struct config_item *item, \ · 187 unmodified lines
17671763 if (ret) \
17681764 goto end; \
17691765 \
1770− if (num > 255) { \
1771− ret = -EINVAL; \
1772− goto end; \
1773− } \
17741766 u->desc.aname = num; \
17751767 ret = len; \
17761768 end: \
drivers/usb/gadget/function/uvc_configfs.h+1−1
@@ -7,7 +7,7 @@ · 6 unmodified lines
77 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
88 * http://www.samsung.com
99 *
10− * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
10+ * Author: Andrzej Pietrasiewicz <andrzejtp2010@gmail.com>
1111 */
1212 #ifndef UVC_CONFIGFS_H
1313 #define UVC_CONFIGFS_H
drivers/usb/gadget/function/uvc_v4l2.h+1−1
@@ -7,7 +7,7 @@ · 6 unmodified lines
77 *
88 * Copyright (c) 2013 Samsung Electronics Co., Ltd.
99 * http://www.samsung.com
10− * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
10+ * Author: Andrzej Pietrasiewicz <andrzejtp2010@gmail.com>
1111 */
1212
1313 #ifndef __UVC_V4L2_H__
drivers/usb/gadget/function/uvc_video.h+1−1
@@ -7,7 +7,7 @@ · 6 unmodified lines
77 *
88 * Copyright (c) 2013 Samsung Electronics Co., Ltd.
99 * http://www.samsung.com
10− * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
10+ * Author: Andrzej Pietrasiewicz <andrzejtp2010@gmail.com>
1111 */
1212 #ifndef __UVC_VIDEO_H__
1313 #define __UVC_VIDEO_H__
drivers/usb/gadget/legacy/Kconfig+1−0
@@ -1,3 +1,4 @@
1+# SPDX-License-Identifier: GPL-2.0
12 #
23 # USB Gadget support on a system involves
34 # (a) a peripheral controller, and
drivers/usb/gadget/legacy/inode.c+20−20
@@ -1218,27 +1218,27 @@ ep0_poll (struct file *fd, poll_table *wait) · 1217 unmodified lines
12181218 if (dev->state <= STATE_DEV_OPENED)
12191219 return DEFAULT_POLLMASK;
12201220
1221− poll_wait(fd, &dev->wait, wait);
1222−
1223− spin_lock_irq (&dev->lock);
1224−
1225− /* report fd mode change before acting on it */
1226− if (dev->setup_abort) {
1227− dev->setup_abort = 0;
1228− mask = EPOLLHUP;
1229− goto out;
1230− }
1231−
1232− if (dev->state == STATE_DEV_SETUP) {
1233− if (dev->setup_in || dev->setup_can_stall)
1234− mask = EPOLLOUT;
1235− } else {
1236− if (dev->ev_next != 0)
1237− mask = EPOLLIN;
1238− }
1221+ poll_wait(fd, &dev->wait, wait);
1222+
1223+ spin_lock_irq(&dev->lock);
1224+
1225+ /* report fd mode change before acting on it */
1226+ if (dev->setup_abort) {
1227+ dev->setup_abort = 0;
1228+ mask = EPOLLHUP;
1229+ goto out;
1230+ }
1231+
1232+ if (dev->state == STATE_DEV_SETUP) {
1233+ if (dev->setup_in || dev->setup_can_stall)
1234+ mask = EPOLLOUT;
1235+ } else {
1236+ if (dev->ev_next != 0)
1237+ mask = EPOLLIN;
1238+ }
12391239 out:
1240− spin_unlock_irq(&dev->lock);
1241− return mask;
1240+ spin_unlock_irq(&dev->lock);
1241+ return mask;
12421242 }
12431243
12441244 static long dev_ioctl (struct file *fd, unsigned code, unsigned long value)
drivers/usb/gadget/u_f.c+1−1
@@ -5,7 +5,7 @@ · 4 unmodified lines
55 * Copyright (c) 2013 Samsung Electronics Co., Ltd.
66 * http://www.samsung.com
77 *
8− * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
8+ * Author: Andrzej Pietrasiewicz <andrzejtp2010@gmail.com>
99 */
1010
1111 #include "u_f.h"
drivers/usb/gadget/u_f.h+1−1
@@ -7,7 +7,7 @@ · 6 unmodified lines
77 * Copyright (c) 2013 Samsung Electronics Co., Ltd.
88 * http://www.samsung.com
99 *
10− * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
10+ * Author: Andrzej Pietrasiewicz <andrzejtp2010@gmail.com>
1111 */
1212
1313 #ifndef __U_F_H__
drivers/usb/gadget/u_os_desc.h+1−1
@@ -7,7 +7,7 @@ · 6 unmodified lines
77 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
88 * http://www.samsung.com
99 *
10− * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
10+ * Author: Andrzej Pietrasiewicz <andrzejtp2010@gmail.com>
1111 */
1212
1313 #ifndef __U_OS_DESC_H__
drivers/usb/gadget/udc/Kconfig+1−0
@@ -1,3 +1,4 @@
1+# SPDX-License-Identifier: GPL-2.0
12 #
23 # USB Gadget support on a system involves
34 # (a) a peripheral controller, and
drivers/usb/gadget/udc/aspeed-vhub/epn.c+1−1
@@ -120,7 +120,7 @@ static void ast_vhub_epn_handle_ack(struct ast_vhub_ep *ep) · 119 unmodified lines
120120 /* No current DMA ongoing */
121121 req->active = false;
122122
123− /* Grab lenght out of HW */
123+ /* Grab length out of HW */
124124 len = VHUB_EP_DMA_TX_SIZE(stat);
125125
126126 /* If not using DMA, copy data out if needed */
drivers/usb/gadget/udc/aspeed-vhub/hub.c+1−1
@@ -295,7 +295,7 @@ static int ast_vhub_rep_desc(struct ast_vhub_ep *ep, · 294 unmodified lines
295295 dsize = AST_VHUB_HUB_DESC_SIZE;
296296 memcpy(ep->buf, &ast_vhub_hub_desc, dsize);
297297 BUILD_BUG_ON(dsize > sizeof(ast_vhub_hub_desc));
298− BUILD_BUG_ON(AST_VHUB_HUB_DESC_SIZE >= AST_VHUB_EP0_MAX_PACKET);
298+ BUILD_BUG_ON(AST_VHUB_HUB_DESC_SIZE >= AST_VHUB_EP0_MAX_PACKET);
299299 break;
300300 default:
301301 return std_req_stall;
drivers/usb/gadget/udc/bdc/Kconfig+2−0
@@ -1,3 +1,5 @@
1+# SPDX-License-Identifier: GPL-2.0
2+
13 config USB_BDC_UDC
24 tristate "Broadcom USB3.0 device controller IP driver(BDC)"
35 depends on USB_GADGET && HAS_DMA
drivers/usb/gadget/udc/bdc/bdc_cmd.c+2−2
@@ -311,8 +311,8 @@ int bdc_ep_clear_stall(struct bdc *bdc, int epnum) · 310 unmodified lines
311311 /* if the endpoint it not stallled */
312312 if (!(ep->flags & BDC_EP_STALL)) {
313313 ret = bdc_ep_set_stall(bdc, epnum);
314− if (ret)
315− return ret;
314+ if (ret)
315+ return ret;
316316 }
317317 }
318318 /* Preserve the seq number for ep0 only */
drivers/usb/gadget/udc/core.c+4−4
@@ -281,10 +281,10 @@ EXPORT_SYMBOL_GPL(usb_ep_queue); · 280 unmodified lines
281281 * @ep:the endpoint associated with the request
282282 * @req:the request being canceled
283283 *
284− * If the request is still active on the endpoint, it is dequeued and its
285− * completion routine is called (with status -ECONNRESET); else a negative
286− * error code is returned. This is guaranteed to happen before the call to
287− * usb_ep_dequeue() returns.
284+ * If the request is still active on the endpoint, it is dequeued and
285+ * eventually its completion routine is called (with status -ECONNRESET);
286+ * else a negative error code is returned. This routine is asynchronous,
287+ * that is, it may return before the completion routine runs.
288288 *
289289 * Note that some hardware can't clear out write fifos (to unlink the request
290290 * at the head of the queue) except as part of disconnecting from usb. Such
drivers/usb/gadget/udc/fotg210-udc.c+4−7
@@ -326,6 +326,7 @@ dma_reset: · 325 unmodified lines
326326 static void fotg210_start_dma(struct fotg210_ep *ep,
327327 struct fotg210_request *req)
328328 {
329+ struct device *dev = &ep->fotg210->gadget.dev;
329330 dma_addr_t d;
330331 u8 *buffer;
331332 u32 length;
@@ -348,18 +349,14 @@ static void fotg210_start_dma(struct fotg210_ep *ep, · 16 unmodified lines
348349 length = req->req.length;
349350 }
350351
351− d = dma_map_single(NULL, buffer, length,
352+ d = dma_map_single(dev, buffer, length,
352353 ep->dir_in ? DMA_TO_DEVICE : DMA_FROM_DEVICE);
353354
354− if (dma_mapping_error(NULL, d)) {
355+ if (dma_mapping_error(dev, d)) {
355356 pr_err("dma_mapping_error\n");
356357 return;
357358 }
358359
359− dma_sync_single_for_device(NULL, d, length,
360− ep->dir_in ? DMA_TO_DEVICE :
361− DMA_FROM_DEVICE);
362−
363360 fotg210_enable_dma(ep, d, length);
364361
365362 /* check if dma is done */
@@ -370,7 +367,7 @@ static void fotg210_start_dma(struct fotg210_ep *ep, · 4 unmodified lines
370367 /* update actual transfer length */
371368 req->req.actual += length;
372369
373− dma_unmap_single(NULL, d, length, DMA_TO_DEVICE);
370+ dma_unmap_single(dev, d, length, DMA_TO_DEVICE);
374371 }
375372
376373 static void fotg210_ep0_queue(struct fotg210_ep *ep,
drivers/usb/gadget/udc/net2280.c+3−3
@@ -516,8 +516,8 @@ static int net2280_disable(struct usb_ep *_ep) · 515 unmodified lines
516516 unsigned long flags;
517517
518518 ep = container_of(_ep, struct net2280_ep, ep);
519− if (!_ep || !ep->desc || _ep->name == ep0name) {
520− pr_err("%s: Invalid ep=%p or ep->desc\n", __func__, _ep);
519+ if (!_ep || _ep->name == ep0name) {
520+ pr_err("%s: Invalid ep=%p\n", __func__, _ep);
521521 return -EINVAL;
522522 }
523523 spin_lock_irqsave(&ep->dev->lock, flags);
@@ -2279,7 +2279,7 @@ static void usb_reinit_338x(struct net2280 *dev) · 1755 unmodified lines
22792279 * - It is safe to set for all connection speeds; all chip revisions.
22802280 * - R-M-W to leave other bits undisturbed.
22812281 * - Reference PLX TT-7372
2282− */
2282+ */
22832283 val = readl(&dev->ll_chicken_reg->ll_tsn_chicken_bit);
22842284 val |= BIT(RECOVERY_IDLE_TO_RECOVER_FMW);
22852285 writel(val, &dev->ll_chicken_reg->ll_tsn_chicken_bit);
drivers/usb/gadget/udc/renesas_usb3.c+4−0
@@ -2629,6 +2629,10 @@ static const struct of_device_id usb3_of_match[] = { · 2628 unmodified lines
26292629 MODULE_DEVICE_TABLE(of, usb3_of_match);
26302630
26312631 static const struct soc_device_attribute renesas_usb3_quirks_match[] = {
2632+ {
2633+ .soc_id = "r8a774c0",
2634+ .data = &renesas_usb3_priv_r8a77990,
2635+ },
26322636 {
26332637 .soc_id = "r8a7795", .revision = "ES1.*",
26342638 .data = &renesas_usb3_priv_r8a7795_es1,
drivers/usb/gadget/udc/snps_udc_core.c+8−9
@@ -947,15 +947,14 @@ static int prep_dma(struct udc_ep *ep, struct udc_request *req, gfp_t gfp) · 946 unmodified lines
947947 UDC_DMA_STP_STS_BS_HOST_READY,
948948 UDC_DMA_STP_STS_BS);
949949
950−
951− /* clear NAK by writing CNAK */
952− if (ep->naking) {
953− tmp = readl(&ep->regs->ctl);
954− tmp |= AMD_BIT(UDC_EPCTL_CNAK);
955− writel(tmp, &ep->regs->ctl);
956− ep->naking = 0;
957− UDC_QUEUE_CNAK(ep, ep->num);
958− }
950+ /* clear NAK by writing CNAK */
951+ if (ep->naking) {
952+ tmp = readl(&ep->regs->ctl);
953+ tmp |= AMD_BIT(UDC_EPCTL_CNAK);
954+ writel(tmp, &ep->regs->ctl);
955+ ep->naking = 0;
956+ UDC_QUEUE_CNAK(ep, ep->num);
957+ }
959958
960959 }
961960
drivers/usb/host/Kconfig+4−4
@@ -1,3 +1,4 @@
1+# SPDX-License-Identifier: GPL-2.0
12 #
23 # USB Host Controller Drivers
34 #
@@ -69,13 +70,13 @@ config USB_XHCI_MTK · 65 unmodified lines
6970 If unsure, say N.
7071
7172 config USB_XHCI_MVEBU
72− tristate "xHCI support for Marvell Armada 375/38x"
73+ tristate "xHCI support for Marvell Armada 375/38x/37xx"
7374 select USB_XHCI_PLATFORM
7475 depends on HAS_IOMEM
7576 depends on ARCH_MVEBU || COMPILE_TEST
7677 ---help---
7778 Say 'Y' to enable the support for the xHCI host controller
78− found in Marvell Armada 375/38x ARM SOCs.
79+ found in Marvell Armada 375/38x/37xx ARM SOCs.
7980
8081 config USB_XHCI_RCAR
8182 tristate "xHCI support for Renesas R-Car SoCs"
@@ -179,8 +180,7 @@ config XPS_USB_HCD_XILINX · 97 unmodified lines
179180 devices only.
180181
181182 config USB_EHCI_FSL
182− tristate "Support for Freescale PPC on-chip EHCI USB controller"
183− depends on FSL_SOC
183+ tristate "Support for Freescale on-chip EHCI USB controller"
184184 select USB_EHCI_ROOT_HUB_TT
185185 ---help---
186186 Variation of ARC USB block used in some Freescale chips.
drivers/usb/host/ehci-fsl.c+42−27
@@ -23,6 +23,7 @@ · 22 unmodified lines
2323 #include <linux/platform_device.h>
2424 #include <linux/fsl_devices.h>
2525 #include <linux/of_platform.h>
26+#include <linux/io.h>
2627
2728 #include "ehci.h"
2829 #include "ehci-fsl.h"
@@ -50,6 +51,7 @@ static int fsl_ehci_drv_probe(struct platform_device *pdev) · 21 unmodified lines
5051 struct resource *res;
5152 int irq;
5253 int retval;
54+ u32 tmp;
5355
5456 pr_debug("initializing FSL-SOC USB Controller\n");
5557
@@ -114,17 +116,22 @@ static int fsl_ehci_drv_probe(struct platform_device *pdev) · 58 unmodified lines
114116 }
115117
116118 /* Enable USB controller, 83xx or 8536 */
117− if (pdata->have_sysif_regs && pdata->controller_ver < FSL_USB_VER_1_6)
118− clrsetbits_be32(hcd->regs + FSL_SOC_USB_CTRL,
119− CONTROL_REGISTER_W1C_MASK, 0x4);
120−
119+ if (pdata->have_sysif_regs && pdata->controller_ver < FSL_USB_VER_1_6) {
120+ tmp = ioread32be(hcd->regs + FSL_SOC_USB_CTRL);
121+ tmp &= ~CONTROL_REGISTER_W1C_MASK;
122+ tmp |= 0x4;
123+ iowrite32be(tmp, hcd->regs + FSL_SOC_USB_CTRL);
124+ }
121125 /*
122126 * Enable UTMI phy and program PTS field in UTMI mode before asserting
123127 * controller reset for USB Controller version 2.5
124128 */
125129 if (pdata->has_fsl_erratum_a007792) {
126− clrsetbits_be32(hcd->regs + FSL_SOC_USB_CTRL,
127− CONTROL_REGISTER_W1C_MASK, CTRL_UTMI_PHY_EN);
130+ tmp = ioread32be(hcd->regs + FSL_SOC_USB_CTRL);
131+ tmp &= ~CONTROL_REGISTER_W1C_MASK;
132+ tmp |= CTRL_UTMI_PHY_EN;
133+ iowrite32be(tmp, hcd->regs + FSL_SOC_USB_CTRL);
134+
128135 writel(PORT_PTS_UTMI, hcd->regs + FSL_SOC_USB_PORTSC1);
129136 }
130137
@@ -174,7 +181,7 @@ static int ehci_fsl_setup_phy(struct usb_hcd *hcd, · 43 unmodified lines
174181 enum fsl_usb2_phy_modes phy_mode,
175182 unsigned int port_offset)
176183 {
177− u32 portsc;
184+ u32 portsc, tmp;
178185 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
179186 void __iomem *non_ehci = hcd->regs;
180187 struct device *dev = hcd->self.controller;
@@ -192,11 +199,16 @@ static int ehci_fsl_setup_phy(struct usb_hcd *hcd, · 11 unmodified lines
192199 case FSL_USB2_PHY_ULPI:
193200 if (pdata->have_sysif_regs && pdata->controller_ver) {
194201 /* controller version 1.6 or above */
195− clrbits32(non_ehci + FSL_SOC_USB_CTRL,
196− CONTROL_REGISTER_W1C_MASK | UTMI_PHY_EN);
197− clrsetbits_be32(non_ehci + FSL_SOC_USB_CTRL,
198− CONTROL_REGISTER_W1C_MASK,
199− ULPI_PHY_CLK_SEL | USB_CTRL_USB_EN);
202+ /* turn off UTMI PHY first */
203+ tmp = ioread32be(non_ehci + FSL_SOC_USB_CTRL);
204+ tmp &= ~(CONTROL_REGISTER_W1C_MASK | UTMI_PHY_EN);
205+ iowrite32be(tmp, non_ehci + FSL_SOC_USB_CTRL);
206+
207+ /* then turn on ULPI and enable USB controller */
208+ tmp = ioread32be(non_ehci + FSL_SOC_USB_CTRL);
209+ tmp &= ~CONTROL_REGISTER_W1C_MASK;
210+ tmp |= ULPI_PHY_CLK_SEL | USB_CTRL_USB_EN;
211+ iowrite32be(tmp, non_ehci + FSL_SOC_USB_CTRL);
200212 }
201213 portsc |= PORT_PTS_ULPI;
202214 break;
@@ -210,16 +222,21 @@ static int ehci_fsl_setup_phy(struct usb_hcd *hcd, · 7 unmodified lines
210222 case FSL_USB2_PHY_UTMI_DUAL:
211223 if (pdata->have_sysif_regs && pdata->controller_ver) {
212224 /* controller version 1.6 or above */
213− clrsetbits_be32(non_ehci + FSL_SOC_USB_CTRL,
214− CONTROL_REGISTER_W1C_MASK, UTMI_PHY_EN);
225+ tmp = ioread32be(non_ehci + FSL_SOC_USB_CTRL);
226+ tmp &= ~CONTROL_REGISTER_W1C_MASK;
227+ tmp |= UTMI_PHY_EN;
228+ iowrite32be(tmp, non_ehci + FSL_SOC_USB_CTRL);
229+
215230 mdelay(FSL_UTMI_PHY_DLY); /* Delay for UTMI PHY CLK to
216231 become stable - 10ms*/
217232 }
218233 /* enable UTMI PHY */
219− if (pdata->have_sysif_regs)
220− clrsetbits_be32(non_ehci + FSL_SOC_USB_CTRL,
221− CONTROL_REGISTER_W1C_MASK,
222− CTRL_UTMI_PHY_EN);
234+ if (pdata->have_sysif_regs) {
235+ tmp = ioread32be(non_ehci + FSL_SOC_USB_CTRL);
236+ tmp &= ~CONTROL_REGISTER_W1C_MASK;
237+ tmp |= CTRL_UTMI_PHY_EN;
238+ iowrite32be(tmp, non_ehci + FSL_SOC_USB_CTRL);
239+ }
223240 portsc |= PORT_PTS_UTMI;
224241 break;
225242 case FSL_USB2_PHY_NONE:
@@ -241,9 +258,12 @@ static int ehci_fsl_setup_phy(struct usb_hcd *hcd, · 15 unmodified lines
241258
242259 ehci_writel(ehci, portsc, &ehci->regs->port_status[port_offset]);
243260
244− if (phy_mode != FSL_USB2_PHY_ULPI && pdata->have_sysif_regs)
245− clrsetbits_be32(non_ehci + FSL_SOC_USB_CTRL,
246− CONTROL_REGISTER_W1C_MASK, USB_CTRL_USB_EN);
261+ if (phy_mode != FSL_USB2_PHY_ULPI && pdata->have_sysif_regs) {
262+ tmp = ioread32be(non_ehci + FSL_SOC_USB_CTRL);
263+ tmp &= ~CONTROL_REGISTER_W1C_MASK;
264+ tmp |= USB_CTRL_USB_EN;
265+ iowrite32be(tmp, non_ehci + FSL_SOC_USB_CTRL);
266+ }
247267
248268 return 0;
249269 }
@@ -284,14 +304,9 @@ static int ehci_fsl_usb_setup(struct ehci_hcd *ehci) · 34 unmodified lines
284304 return -EINVAL;
285305
286306 if (pdata->operating_mode == FSL_USB2_MPH_HOST) {
287− unsigned int chip, rev, svr;
288−
289− svr = mfspr(SPRN_SVR);
290− chip = svr >> 16;
291− rev = (svr >> 4) & 0xf;
292307
293308 /* Deal with USB Erratum #14 on MPC834x Rev 1.0 & 1.1 chips */
294− if ((rev == 1) && (chip >= 0x8050) && (chip <= 0x8055))
309+ if (pdata->has_fsl_erratum_14 == 1)
295310 ehci->has_fsl_port_bug = 1;
296311
297312 if (pdata->port_enables & FSL_USB2_PORT0_ENABLED)
drivers/usb/host/ehci-orion.c+21−23
@@ -182,6 +182,23 @@ static int ehci_orion_drv_reset(struct usb_hcd *hcd) · 181 unmodified lines
182182 return ret;
183183 }
184184
185+static int __maybe_unused ehci_orion_drv_suspend(struct device *dev)
186+{
187+ struct usb_hcd *hcd = dev_get_drvdata(dev);
188+
189+ return ehci_suspend(hcd, device_may_wakeup(dev));
190+}
191+
192+static int __maybe_unused ehci_orion_drv_resume(struct device *dev)
193+{
194+ struct usb_hcd *hcd = dev_get_drvdata(dev);
195+
196+ return ehci_resume(hcd, false);
197+}
198+
199+static SIMPLE_DEV_PM_OPS(ehci_orion_pm_ops, ehci_orion_drv_suspend,
200+ ehci_orion_drv_resume);
201+
185202 static const struct ehci_driver_overrides orion_overrides __initconst = {
186203 .extra_priv_size = sizeof(struct orion_ehci_hcd),
187204 .reset = ehci_orion_drv_reset,
@@ -257,15 +274,7 @@ static int ehci_orion_drv_probe(struct platform_device *pdev) · 69 unmodified lines
257274 if (IS_ERR(priv->phy)) {
258275 err = PTR_ERR(priv->phy);
259276 if (err != -ENOSYS)
260− goto err_phy_get;
261− } else {
262− err = phy_init(priv->phy);
263− if (err)
264− goto err_phy_init;
265−
266− err = phy_power_on(priv->phy);
267− if (err)
268− goto err_phy_power_on;
277+ goto err_dis_clk;
269278 }
270279
271280 /*
@@ -297,19 +306,12 @@ static int ehci_orion_drv_probe(struct platform_device *pdev) · 25 unmodified lines
297306
298307 err = usb_add_hcd(hcd, irq, IRQF_SHARED);
299308 if (err)
300− goto err_add_hcd;
309+ goto err_dis_clk;
301310
302311 device_wakeup_enable(hcd->self.controller);
303312 return 0;
304313
305−err_add_hcd:
306− if (!IS_ERR(priv->phy))
307− phy_power_off(priv->phy);
308−err_phy_power_on:
309− if (!IS_ERR(priv->phy))
310− phy_exit(priv->phy);
311−err_phy_init:
312−err_phy_get:
314+err_dis_clk:
313315 if (!IS_ERR(priv->clk))
314316 clk_disable_unprepare(priv->clk);
315317 usb_put_hcd(hcd);
@@ -327,11 +329,6 @@ static int ehci_orion_drv_remove(struct platform_device *pdev) · 11 unmodified lines
327329
328330 usb_remove_hcd(hcd);
329331
330− if (!IS_ERR(priv->phy)) {
331− phy_power_off(priv->phy);
332− phy_exit(priv->phy);
333− }
334−
335332 if (!IS_ERR(priv->clk))
336333 clk_disable_unprepare(priv->clk);
337334
@@ -354,6 +351,7 @@ static struct platform_driver ehci_orion_driver = { · 16 unmodified lines
354351 .driver = {
355352 .name = "orion-ehci",
356353 .of_match_table = ehci_orion_dt_ids,
354+ .pm = &ehci_orion_pm_ops,
357355 },
358356 };
359357
drivers/usb/host/fsl-mph-dr-of.c+6−0
@@ -225,6 +225,12 @@ static int fsl_usb2_mph_dr_of_probe(struct platform_device *ofdev) · 224 unmodified lines
225225 pdata->has_fsl_erratum_a005697 =
226226 of_property_read_bool(np, "fsl,usb_erratum-a005697");
227227
228+ if (of_get_property(np, "fsl,usb_erratum_14", NULL))
229+ pdata->has_fsl_erratum_14 = 1;
230+ else
231+ pdata->has_fsl_erratum_14 = 0;
232+
233+
228234 /*
229235 * Determine whether phy_clk_valid needs to be checked
230236 * by reading property in device tree
drivers/usb/host/ohci-at91.c+5−2
@@ -141,8 +141,11 @@ static struct regmap *at91_dt_syscon_sfr(void) · 140 unmodified lines
141141 struct regmap *regmap;
142142
143143 regmap = syscon_regmap_lookup_by_compatible("atmel,sama5d2-sfr");
144− if (IS_ERR(regmap))
145− regmap = NULL;
144+ if (IS_ERR(regmap)) {
145+ regmap = syscon_regmap_lookup_by_compatible("microchip,sam9x60-sfr");
146+ if (IS_ERR(regmap))
147+ regmap = NULL;
148+ }
146149
147150 return regmap;
148151 }
drivers/usb/host/oxu210hp-hcd.c+2−8
@@ -1323,7 +1323,7 @@ static struct list_head *qh_urb_transaction(struct oxu_hcd *oxu, · 1322 unmodified lines
13231323 }
13241324
13251325 /* by default, enable interrupt on urb completion */
1326− qtd->hw_token |= cpu_to_le32(QTD_IOC);
1326+ qtd->hw_token |= cpu_to_le32(QTD_IOC);
13271327 return head;
13281328
13291329 cleanup:
@@ -2253,16 +2253,12 @@ static void scan_periodic(struct oxu_hcd *oxu) · 923 unmodified lines
22532253 for (;;) {
22542254 union ehci_shadow q, *q_p;
22552255 __le32 type, *hw_p;
2256− unsigned uframes;
22572256
22582257 /* don't scan past the live uframe */
22592258 frame = now_uframe >> 3;
2260− if (frame == (clock >> 3))
2261− uframes = now_uframe & 0x07;
2262− else {
2259+ if (frame != (clock >> 3)) {
22632260 /* safe to scan the whole frame at once */
22642261 now_uframe |= 0x07;
2265− uframes = 8;
22662262 }
22672263
22682264 restart:
@@ -2832,7 +2828,6 @@ static int oxu_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, · 563 unmodified lines
28322828 {
28332829 struct oxu_hcd *oxu = hcd_to_oxu(hcd);
28342830 int num, rem;
2835− int transfer_buffer_length;
28362831 void *transfer_buffer;
28372832 struct urb *murb;
28382833 int i, ret;
@@ -2843,7 +2838,6 @@ static int oxu_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, · 4 unmodified lines
28432838
28442839 /* Otherwise we should verify the USB transfer buffer size! */
28452840 transfer_buffer = urb->transfer_buffer;
2846− transfer_buffer_length = urb->transfer_buffer_length;
28472841
28482842 num = urb->transfer_buffer_length / 4096;
28492843 rem = urb->transfer_buffer_length % 4096;
drivers/usb/host/u132-hcd.c+4−2
@@ -2477,7 +2477,8 @@ static int u132_endp_urb_dequeue(struct u132 *u132, struct u132_endp *endp, · 2476 unmodified lines
24772477 spin_unlock_irqrestore(&endp->queue_lock.slock,
24782478 irqs);
24792479 kfree(urbq);
2480− } urb->error_count = 0;
2480+ }
2481+ urb->error_count = 0;
24812482 usb_hcd_giveback_urb(hcd, urb, status);
24822483 return 0;
24832484 } else if (list_empty(&endp->urb_more)) {
@@ -2982,7 +2983,8 @@ static int u132_remove(struct platform_device *pdev) · 498 unmodified lines
29822983 while (rings-- > 0) {
29832984 struct u132_ring *ring = &u132->ring[rings];
29842985 u132_ring_cancel_work(u132, ring);
2985− } while (endps-- > 0) {
2986+ }
2987+ while (endps-- > 0) {
29862988 struct u132_endp *endp = u132->endp[endps];
29872989 if (endp)
29882990 u132_endp_cancel_work(u132, endp);
drivers/usb/host/whci/Makefilerenamed from drivers/usb/host/whci/Kbuild+2−0
@@ -1,3 +1,5 @@
1+# SPDX-License-Identifier: GPL-2.0
2+
13 obj-$(CONFIG_USB_WHCI_HCD) += whci-hcd.o
24
35 whci-hcd-y := \
drivers/usb/host/xhci-dbgcap.c+3−3
@@ -181,7 +181,7 @@ static void xhci_dbc_flush_endpoint_requests(struct dbc_ep *dep) · 180 unmodified lines
181181 xhci_dbc_flush_single_request(req);
182182 }
183183
184−static void xhci_dbc_flush_reqests(struct xhci_dbc *dbc)
184+static void xhci_dbc_flush_requests(struct xhci_dbc *dbc)
185185 {
186186 xhci_dbc_flush_endpoint_requests(&dbc->eps[BULK_OUT]);
187187 xhci_dbc_flush_endpoint_requests(&dbc->eps[BULK_IN]);
@@ -687,7 +687,7 @@ static enum evtreturn xhci_dbc_do_handle_events(struct xhci_dbc *dbc) · 499 unmodified lines
687687 !(portsc & DBC_PORTSC_CONN_STATUS)) {
688688 xhci_info(xhci, "DbC cable unplugged\n");
689689 dbc->state = DS_ENABLED;
690− xhci_dbc_flush_reqests(dbc);
690+ xhci_dbc_flush_requests(dbc);
691691
692692 return EVT_DISC;
693693 }
@@ -697,7 +697,7 @@ static enum evtreturn xhci_dbc_do_handle_events(struct xhci_dbc *dbc) · 3 unmodified lines
697697 xhci_info(xhci, "DbC port reset\n");
698698 writel(portsc, &dbc->regs->portsc);
699699 dbc->state = DS_ENABLED;
700− xhci_dbc_flush_reqests(dbc);
700+ xhci_dbc_flush_requests(dbc);
701701
702702 return EVT_DISC;
703703 }
drivers/usb/host/xhci-debugfs.h+0−1
@@ -80,7 +80,6 @@ struct xhci_regset { · 79 unmodified lines
8080 char name[DEBUGFS_NAMELEN];
8181 struct debugfs_regset32 regset;
8282 size_t nregs;
83− struct dentry *parent;
8483 struct list_head list;
8584 };
8685
drivers/usb/host/xhci-mem.c+1−1
@@ -933,7 +933,7 @@ void xhci_free_virt_device(struct xhci_hcd *xhci, int slot_id) · 932 unmodified lines
933933 * that tt_info, then free the child first. Recursive.
934934 * We can't rely on udev at this point to find child-parent relationships.
935935 */
936−void xhci_free_virt_devices_depth_first(struct xhci_hcd *xhci, int slot_id)
936+static void xhci_free_virt_devices_depth_first(struct xhci_hcd *xhci, int slot_id)
937937 {
938938 struct xhci_virt_device *vdev;
939939 struct list_head *tt_list_head;
drivers/usb/host/xhci-mvebu.c+11−0
@@ -13,6 +13,7 @@ · 12 unmodified lines
1313 #include <linux/usb/hcd.h>
1414
1515 #include "xhci-mvebu.h"
16+#include "xhci.h"
1617
1718 #define USB3_MAX_WINDOWS 4
1819 #define USB3_WIN_CTRL(w) (0x0 + ((w) * 8))
@@ -72,3 +73,13 @@ int xhci_mvebu_mbus_init_quirk(struct usb_hcd *hcd) · 53 unmodified lines
7273
7374 return 0;
7475 }
76+
77+int xhci_mvebu_a3700_init_quirk(struct usb_hcd *hcd)
78+{
79+ struct xhci_hcd *xhci = hcd_to_xhci(hcd);
80+
81+ /* Without reset on resume, the HC won't work at all */
82+ xhci->quirks |= XHCI_RESET_ON_RESUME;
83+
84+ return 0;
85+}
drivers/usb/host/xhci-mvebu.h+6−0
@@ -12,10 +12,16 @@ struct usb_hcd; · 11 unmodified lines
1212
1313 #if IS_ENABLED(CONFIG_USB_XHCI_MVEBU)
1414 int xhci_mvebu_mbus_init_quirk(struct usb_hcd *hcd);
15+int xhci_mvebu_a3700_init_quirk(struct usb_hcd *hcd);
1516 #else
1617 static inline int xhci_mvebu_mbus_init_quirk(struct usb_hcd *hcd)
1718 {
1819 return 0;
1920 }
21+
22+static inline int xhci_mvebu_a3700_init_quirk(struct usb_hcd *hcd)
23+{
24+ return 0;
25+}
2026 #endif
2127 #endif /* __LINUX_XHCI_MVEBU_H */
drivers/usb/host/xhci-pci.c+1−0
@@ -194,6 +194,7 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci) · 193 unmodified lines
194194 xhci->quirks |= XHCI_SSIC_PORT_UNUSED;
195195 if (pdev->vendor == PCI_VENDOR_ID_INTEL &&
196196 (pdev->device == PCI_DEVICE_ID_INTEL_CHERRYVIEW_XHCI ||
197+ pdev->device == PCI_DEVICE_ID_INTEL_SUNRISEPOINT_LP_XHCI ||
197198 pdev->device == PCI_DEVICE_ID_INTEL_APL_XHCI))
198199 xhci->quirks |= XHCI_INTEL_USB_ROLE_SW;
199200 if (pdev->vendor == PCI_VENDOR_ID_INTEL &&
drivers/usb/host/xhci-plat.c+7−0
@@ -98,6 +98,10 @@ static const struct xhci_plat_priv xhci_plat_marvell_armada = { · 97 unmodified lines
9898 .init_quirk = xhci_mvebu_mbus_init_quirk,
9999 };
100100
101+static const struct xhci_plat_priv xhci_plat_marvell_armada3700 = {
102+ .init_quirk = xhci_mvebu_a3700_init_quirk,
103+};
104+
101105 static const struct xhci_plat_priv xhci_plat_renesas_rcar_gen2 = {
102106 .firmware_name = XHCI_RCAR_FIRMWARE_NAME_V1,
103107 .init_quirk = xhci_rcar_init_quirk,
@@ -123,6 +127,9 @@ static const struct of_device_id usb_xhci_of_match[] = { · 19 unmodified lines
123127 }, {
124128 .compatible = "marvell,armada-380-xhci",
125129 .data = &xhci_plat_marvell_armada,
130+ }, {
131+ .compatible = "marvell,armada3700-xhci",
132+ .data = &xhci_plat_marvell_armada3700,
126133 }, {
127134 .compatible = "renesas,xhci-r8a7790",
128135 .data = &xhci_plat_renesas_rcar_gen2,
drivers/usb/host/xhci-tegra.c+2−2
@@ -941,9 +941,9 @@ static void tegra_xusb_powerdomain_remove(struct device *dev, · 940 unmodified lines
941941 device_link_del(tegra->genpd_dl_ss);
942942 if (tegra->genpd_dl_host)
943943 device_link_del(tegra->genpd_dl_host);
944− if (tegra->genpd_dev_ss)
944+ if (!IS_ERR_OR_NULL(tegra->genpd_dev_ss))
945945 dev_pm_domain_detach(tegra->genpd_dev_ss, true);
946− if (tegra->genpd_dev_host)
946+ if (!IS_ERR_OR_NULL(tegra->genpd_dev_host))
947947 dev_pm_domain_detach(tegra->genpd_dev_host, true);
948948 }
949949
drivers/usb/host/xhci.c+1−2
@@ -1455,8 +1455,7 @@ static int xhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flag · 1454 unmodified lines
14551455 else
14561456 num_tds = 1;
14571457
1458− urb_priv = kzalloc(sizeof(struct urb_priv) +
1459− num_tds * sizeof(struct xhci_td), mem_flags);
1458+ urb_priv = kzalloc(struct_size(urb_priv, td, num_tds), mem_flags);
14601459 if (!urb_priv)
14611460 return -ENOMEM;
14621461
drivers/usb/image/Kconfig+1−0
@@ -1,3 +1,4 @@
1+# SPDX-License-Identifier: GPL-2.0
12 #
23 # USB Imaging devices configuration
34 #
drivers/usb/isp1760/Kconfig+2−0
@@ -1,3 +1,5 @@
1+# SPDX-License-Identifier: GPL-2.0
2+
13 config USB_ISP1760
24 tristate "NXP ISP 1760/1761 support"
35 depends on USB || USB_GADGET
drivers/usb/misc/Kconfig+1−0
@@ -1,3 +1,4 @@
1+# SPDX-License-Identifier: GPL-2.0
12 #
23 # USB Miscellaneous driver configuration
34 #
drivers/usb/misc/ftdi-elan.c+0−26
@@ -915,7 +915,6 @@ static int ftdi_elan_respond_engine(struct usb_ftdi *ftdi) · 914 unmodified lines
915915 int bytes_read = 0;
916916 int retry_on_empty = 1;
917917 int retry_on_timeout = 3;
918− int empty_packets = 0;
919918 read:{
920919 int packet_bytes = 0;
921920 int retval = usb_bulk_msg(ftdi->udev,
@@ -960,31 +959,6 @@ read:{ · 38 unmodified lines
960959 dev_err(&ftdi->udev->dev, "error = %d with packet_bytes = %d with total %d bytes%s\n",
961960 retval, packet_bytes, bytes_read, diag);
962961 return retval;
963− } else if (packet_bytes == 2) {
964− unsigned char s0 = ftdi->bulk_in_buffer[0];
965− unsigned char s1 = ftdi->bulk_in_buffer[1];
966− empty_packets += 1;
967− if (s0 == 0x31 && s1 == 0x60) {
968− if (retry_on_empty-- > 0) {
969− goto more;
970− } else
971− return 0;
972− } else if (s0 == 0x31 && s1 == 0x00) {
973− if (retry_on_empty-- > 0) {
974− goto more;
975− } else
976− return 0;
977− } else {
978− if (retry_on_empty-- > 0) {
979− goto more;
980− } else
981− return 0;
982− }
983− } else if (packet_bytes == 1) {
984− if (retry_on_empty-- > 0) {
985− goto more;
986− } else
987− return 0;
988962 } else {
989963 if (retry_on_empty-- > 0) {
990964 goto more;
drivers/usb/misc/sisusbvga/Kconfig+1−0
@@ -1,3 +1,4 @@
1+# SPDX-License-Identifier: GPL-2.0
12
23 config USB_SISUSBVGA
34 tristate "USB 2.0 SVGA dongle support (Net2280/SiS315)"
drivers/usb/misc/sisusbvga/Makefile+2−1
@@ -5,4 +5,5 @@ · 4 unmodified lines
55
66 obj-$(CONFIG_USB_SISUSBVGA) += sisusbvga.o
77
8−sisusbvga-y := sisusb.o sisusb_init.o sisusb_con.o
8+sisusbvga-y := sisusb.o
9+sisusbvga-$(CONFIG_USB_SISUSBVGA_CON) += sisusb_con.o sisusb_init.o
drivers/usb/misc/sisusbvga/sisusb.c+16−16
@@ -53,7 +53,7 @@ · 52 unmodified lines
5353 #include "sisusb.h"
5454 #include "sisusb_init.h"
5555
56−#ifdef INCL_SISUSB_CON
56+#ifdef CONFIG_USB_SISUSBVGA_CON
5757 #include <linux/font.h>
5858 #endif
5959
@@ -61,7 +61,7 @@ · 1 unmodified line
6161
6262 /* Forward declarations / clean-up routines */
6363
64−#ifdef INCL_SISUSB_CON
64+#ifdef CONFIG_USB_SISUSBVGA_CON
6565 static int sisusb_first_vc;
6666 static int sisusb_last_vc;
6767 module_param_named(first, sisusb_first_vc, int, 0);
@@ -1198,7 +1198,7 @@ static int sisusb_read_mem_bulk(struct sisusb_usb_data *sisusb, u32 addr, · 1130 unmodified lines
11981198
11991199 /* High level: Gfx (indexed) register access */
12001200
1201−#ifdef INCL_SISUSB_CON
1201+#ifdef CONFIG_USB_SISUSBVGA_CON
12021202 int sisusb_setreg(struct sisusb_usb_data *sisusb, int port, u8 data)
12031203 {
12041204 return sisusb_write_memio_byte(sisusb, SISUSB_TYPE_IO, port, data);
@@ -1272,7 +1272,7 @@ int sisusb_setidxregand(struct sisusb_usb_data *sisusb, int port, · 67 unmodified lines
12721272
12731273 /* Write/read video ram */
12741274
1275−#ifdef INCL_SISUSB_CON
1275+#ifdef CONFIG_USB_SISUSBVGA_CON
12761276 int sisusb_writeb(struct sisusb_usb_data *sisusb, u32 adr, u8 data)
12771277 {
12781278 return sisusb_write_memio_byte(sisusb, SISUSB_TYPE_MEM, adr, data);
@@ -2255,7 +2255,7 @@ static int sisusb_init_gfxdevice(struct sisusb_usb_data *sisusb, int initscreen) · 976 unmodified lines
22552255 }
22562256
22572257
2258−#ifdef INCL_SISUSB_CON
2258+#ifdef CONFIG_USB_SISUSBVGA_CON
22592259
22602260 /* Set up default text mode:
22612261 * - Set text mode (0x03)
@@ -2448,7 +2448,7 @@ void sisusb_delete(struct kref *kref) · 186 unmodified lines
24482448 sisusb->sisusb_dev = NULL;
24492449 sisusb_free_buffers(sisusb);
24502450 sisusb_free_urbs(sisusb);
2451−#ifdef INCL_SISUSB_CON
2451+#ifdef CONFIG_USB_SISUSBVGA_CON
24522452 kfree(sisusb->SiS_Pr);
24532453 #endif
24542454 kfree(sisusb);
@@ -2844,7 +2844,7 @@ static int sisusb_handle_command(struct sisusb_usb_data *sisusb, · 389 unmodified lines
28442844
28452845 case SUCMD_HANDLETEXTMODE:
28462846 retval = 0;
2847−#ifdef INCL_SISUSB_CON
2847+#ifdef CONFIG_USB_SISUSBVGA_CON
28482848 /* Gfx core must be initialized, SiS_Pr must exist */
28492849 if (!sisusb->gfxinit || !sisusb->SiS_Pr)
28502850 return -ENODEV;
@@ -2860,7 +2860,7 @@ static int sisusb_handle_command(struct sisusb_usb_data *sisusb, · 9 unmodified lines
28602860 #endif
28612861 break;
28622862
2863−#ifdef INCL_SISUSB_CON
2863+#ifdef CONFIG_USB_SISUSBVGA_CON
28642864 case SUCMD_SETMODE:
28652865 /* Gfx core must be initialized, SiS_Pr must exist */
28662866 if (!sisusb->gfxinit || !sisusb->SiS_Pr)
@@ -2944,7 +2944,7 @@ static long sisusb_ioctl(struct file *file, unsigned int cmd, unsigned long arg) · 77 unmodified lines
29442944 x.sisusb_vramsize = sisusb->vramsize;
29452945 x.sisusb_minor = sisusb->minor;
29462946 x.sisusb_fbdevactive = 0;
2947−#ifdef INCL_SISUSB_CON
2947+#ifdef CONFIG_USB_SISUSBVGA_CON
29482948 x.sisusb_conactive = sisusb->haveconsole ? 1 : 0;
29492949 #else
29502950 x.sisusb_conactive = 0;
@@ -2975,7 +2975,7 @@ err_out: · 24 unmodified lines
29752975 return retval;
29762976 }
29772977
2978−#ifdef SISUSB_NEW_CONFIG_COMPAT
2978+#ifdef CONFIG_COMPAT
29792979 static long sisusb_compat_ioctl(struct file *f, unsigned int cmd,
29802980 unsigned long arg)
29812981 {
@@ -2998,7 +2998,7 @@ static const struct file_operations usb_sisusb_fops = { · 16 unmodified lines
29982998 .read = sisusb_read,
29992999 .write = sisusb_write,
30003000 .llseek = sisusb_lseek,
3001−#ifdef SISUSB_NEW_CONFIG_COMPAT
3001+#ifdef CONFIG_COMPAT
30023002 .compat_ioctl = sisusb_compat_ioctl,
30033003 #endif
30043004 .unlocked_ioctl = sisusb_ioctl
@@ -3091,7 +3091,7 @@ static int sisusb_probe(struct usb_interface *intf, · 86 unmodified lines
30913091 dev_info(&sisusb->sisusb_dev->dev, "Allocated %d output buffers\n",
30923092 sisusb->numobufs);
30933093
3094−#ifdef INCL_SISUSB_CON
3094+#ifdef CONFIG_USB_SISUSBVGA_CON
30953095 /* Allocate our SiS_Pr */
30963096 sisusb->SiS_Pr = kmalloc(sizeof(struct SiS_Private), GFP_KERNEL);
30973097 if (!sisusb->SiS_Pr) {
@@ -3112,7 +3112,7 @@ static int sisusb_probe(struct usb_interface *intf, · 14 unmodified lines
31123112
31133113 if (dev->speed == USB_SPEED_HIGH || dev->speed >= USB_SPEED_SUPER) {
31143114 int initscreen = 1;
3115−#ifdef INCL_SISUSB_CON
3115+#ifdef CONFIG_USB_SISUSBVGA_CON
31163116 if (sisusb_first_vc > 0 && sisusb_last_vc > 0 &&
31173117 sisusb_first_vc <= sisusb_last_vc &&
31183118 sisusb_last_vc <= MAX_NR_CONSOLES)
@@ -3134,7 +3134,7 @@ static int sisusb_probe(struct usb_interface *intf, · 15 unmodified lines
31343134 dev_dbg(&sisusb->sisusb_dev->dev, "*** RWTEST END ***\n");
31353135 #endif
31363136
3137−#ifdef INCL_SISUSB_CON
3137+#ifdef CONFIG_USB_SISUSBVGA_CON
31383138 sisusb_console_init(sisusb, sisusb_first_vc, sisusb_last_vc);
31393139 #endif
31403140
@@ -3160,7 +3160,7 @@ static void sisusb_disconnect(struct usb_interface *intf) · 19 unmodified lines
31603160 if (!sisusb)
31613161 return;
31623162
3163−#ifdef INCL_SISUSB_CON
3163+#ifdef CONFIG_USB_SISUSBVGA_CON
31643164 sisusb_console_exit(sisusb);
31653165 #endif
31663166
@@ -3210,7 +3210,7 @@ static struct usb_driver sisusb_driver = { · 43 unmodified lines
32103210 static int __init usb_sisusb_init(void)
32113211 {
32123212
3213−#ifdef INCL_SISUSB_CON
3213+#ifdef CONFIG_USB_SISUSBVGA_CON
32143214 sisusb_init_concode();
32153215 #endif
32163216
drivers/usb/misc/sisusbvga/sisusb.h+1−14
@@ -38,17 +38,8 @@ · 37 unmodified lines
3838 #ifndef _SISUSB_H_
3939 #define _SISUSB_H_
4040
41−#ifdef CONFIG_COMPAT
42−#define SISUSB_NEW_CONFIG_COMPAT
43−#endif
44−
4541 #include <linux/mutex.h>
4642
47−/* For older kernels, support for text consoles is by default
48− * off. To enable text console support, change the following:
49− */
50−/* #define CONFIG_USB_SISUSBVGA_CON */
51−
5243 /* Version Information */
5344
5445 #define SISUSB_VERSION 0
@@ -57,10 +48,6 @@ · 2 unmodified lines
5748
5849 /* Include console and mode switching code? */
5950
60−#ifdef CONFIG_USB_SISUSBVGA_CON
61−#define INCL_SISUSB_CON 1
62−#endif
63−
6451 #include <linux/console.h>
6552 #include <linux/vt_kern.h>
6653 #include "sisusb_struct.h"
@@ -139,7 +126,7 @@ struct sisusb_usb_data { · 72 unmodified lines
139126 unsigned char gfxinit; /* graphics core initialized? */
140127 unsigned short chipid, chipvendor;
141128 unsigned short chiprevision;
142−#ifdef INCL_SISUSB_CON
129+#ifdef CONFIG_USB_SISUSBVGA_CON
143130 struct SiS_Private *SiS_Pr;
144131 unsigned long scrbuf;
145132 unsigned int scrbuf_size;
drivers/usb/misc/sisusbvga/sisusb_con.c+51−76
@@ -70,13 +70,6 @@ · 69 unmodified lines
7070 #include "sisusb.h"
7171 #include "sisusb_init.h"
7272
73−#ifdef INCL_SISUSB_CON
74−
75−#define sisusbcon_writew(val, addr) (*(addr) = (val))
76−#define sisusbcon_readw(addr) (*(addr))
77−#define sisusbcon_memmovew(d, s, c) memmove(d, s, c)
78−#define sisusbcon_memcpyw(d, s, c) memcpy(d, s, c)
79−
8073 /* vc_data -> sisusb conversion table */
8174 static struct sisusb_usb_data *mysisusbs[MAX_NR_CONSOLES];
8275
@@ -86,9 +79,7 @@ static const struct consw sisusb_con; · 3 unmodified lines
8679 static inline void
8780 sisusbcon_memsetw(u16 *s, u16 c, unsigned int count)
8881 {
89− count /= 2;
90− while (count--)
91− sisusbcon_writew(c, s++);
82+ memset16(s, c, count / 2);
9283 }
9384
9485 static inline void
@@ -346,25 +337,30 @@ sisusbcon_invert_region(struct vc_data *vc, u16 *p, int count) · 251 unmodified lines
346337 */
347338
348339 while (count--) {
349− u16 a = sisusbcon_readw(p);
350−
351− a = ((a) & 0x88ff) |
352− (((a) & 0x7000) >> 4) |
353− (((a) & 0x0700) << 4);
340+ u16 a = *p;
354341
355− sisusbcon_writew(a, p++);
342+ *p++ = ((a) & 0x88ff) |
343+ (((a) & 0x7000) >> 4) |
344+ (((a) & 0x0700) << 4);
356345 }
357346 }
358347
359−#define SISUSB_VADDR(x,y) \
360− ((u16 *)c->vc_origin + \
361− (y) * sisusb->sisusb_num_columns + \
362− (x))
348+static inline void *sisusb_vaddr(const struct sisusb_usb_data *sisusb,
349+ const struct vc_data *c, unsigned int x, unsigned int y)
350+{
351+ return (u16 *)c->vc_origin + y * sisusb->sisusb_num_columns + x;
352+}
353+
354+static inline unsigned long sisusb_haddr(const struct sisusb_usb_data *sisusb,
355+ const struct vc_data *c, unsigned int x, unsigned int y)
356+{
357+ unsigned long offset = c->vc_origin - sisusb->scrbuf;
363358
364−#define SISUSB_HADDR(x,y) \
365− ((u16 *)(sisusb->vrambase + (c->vc_origin - sisusb->scrbuf)) + \
366− (y) * sisusb->sisusb_num_columns + \
367− (x))
359+ /* 2 bytes per each character */
360+ offset += 2 * (y * sisusb->sisusb_num_columns + x);
361+
362+ return sisusb->vrambase + offset;
363+}
368364
369365 /* Interface routine */
370366 static void
@@ -382,9 +378,8 @@ sisusbcon_putc(struct vc_data *c, int ch, int y, int x) · 11 unmodified lines
382378 return;
383379 }
384380
385−
386− sisusb_copy_memory(sisusb, (char *)SISUSB_VADDR(x, y),
387− (long)SISUSB_HADDR(x, y), 2);
381+ sisusb_copy_memory(sisusb, sisusb_vaddr(sisusb, c, x, y),
382+ sisusb_haddr(sisusb, c, x, y), 2);
388383
389384 mutex_unlock(&sisusb->lock);
390385 }
@@ -395,8 +390,6 @@ sisusbcon_putcs(struct vc_data *c, const unsigned short *s, · 4 unmodified lines
395390 int count, int y, int x)
396391 {
397392 struct sisusb_usb_data *sisusb;
398− u16 *dest;
399− int i;
400393
401394 sisusb = sisusb_get_sisusb_lock_and_check(c->vc_num);
402395 if (!sisusb)
@@ -408,18 +401,15 @@ sisusbcon_putcs(struct vc_data *c, const unsigned short *s, · 5 unmodified lines
408401 * because the vt does this AFTER calling us.
409402 */
410403
411− dest = SISUSB_VADDR(x, y);
412−
413− for (i = count; i > 0; i--)
414− sisusbcon_writew(sisusbcon_readw(s++), dest++);
404+ memcpy(sisusb_vaddr(sisusb, c, x, y), s, count * 2);
415405
416406 if (sisusb_is_inactive(c, sisusb)) {
417407 mutex_unlock(&sisusb->lock);
418408 return;
419409 }
420410
421− sisusb_copy_memory(sisusb, (char *)SISUSB_VADDR(x, y),
422− (long)SISUSB_HADDR(x, y), count * 2);
411+ sisusb_copy_memory(sisusb, sisusb_vaddr(sisusb, c, x, y),
412+ sisusb_haddr(sisusb, c, x, y), count * 2);
423413
424414 mutex_unlock(&sisusb->lock);
425415 }
@@ -446,7 +436,7 @@ sisusbcon_clear(struct vc_data *c, int y, int x, int height, int width) · 20 unmodified lines
446436 * this AFTER calling us.
447437 */
448438
449− dest = SISUSB_VADDR(x, y);
439+ dest = sisusb_vaddr(sisusb, c, x, y);
450440
451441 cols = sisusb->sisusb_num_columns;
452442
@@ -472,8 +462,8 @@ sisusbcon_clear(struct vc_data *c, int y, int x, int height, int width) · 19 unmodified lines
472462 length = ((height * cols) - x - (cols - width - x)) * 2;
473463
474464
475− sisusb_copy_memory(sisusb, (unsigned char *)SISUSB_VADDR(x, y),
476− (long)SISUSB_HADDR(x, y), length);
465+ sisusb_copy_memory(sisusb, sisusb_vaddr(sisusb, c, x, y),
466+ sisusb_haddr(sisusb, c, x, y), length);
477467
478468 mutex_unlock(&sisusb->lock);
479469 }
@@ -517,12 +507,10 @@ sisusbcon_switch(struct vc_data *c) · 37 unmodified lines
517507 (int)(sisusb->scrbuf + sisusb->scrbuf_size - c->vc_origin));
518508
519509 /* Restore the screen contents */
520− sisusbcon_memcpyw((u16 *)c->vc_origin, (u16 *)c->vc_screenbuf,
521− length);
510+ memcpy((u16 *)c->vc_origin, (u16 *)c->vc_screenbuf, length);
522511
523− sisusb_copy_memory(sisusb, (unsigned char *)c->vc_origin,
524− (long)SISUSB_HADDR(0, 0),
525− length);
512+ sisusb_copy_memory(sisusb, (char *)c->vc_origin,
513+ sisusb_haddr(sisusb, c, 0, 0), length);
526514
527515 mutex_unlock(&sisusb->lock);
528516
@@ -556,8 +544,7 @@ sisusbcon_save_screen(struct vc_data *c) · 27 unmodified lines
556544 (int)(sisusb->scrbuf + sisusb->scrbuf_size - c->vc_origin));
557545
558546 /* Save the screen contents to vc's private buffer */
559− sisusbcon_memcpyw((u16 *)c->vc_screenbuf, (u16 *)c->vc_origin,
560− length);
547+ memcpy((u16 *)c->vc_screenbuf, (u16 *)c->vc_origin, length);
561548
562549 mutex_unlock(&sisusb->lock);
563550 }
@@ -628,10 +615,8 @@ sisusbcon_blank(struct vc_data *c, int blank, int mode_switch) · 64 unmodified lines
628615 sisusbcon_memsetw((u16 *)c->vc_origin,
629616 c->vc_video_erase_char,
630617 c->vc_screenbuf_size);
631− sisusb_copy_memory(sisusb,
632− (unsigned char *)c->vc_origin,
633− (u32)(sisusb->vrambase +
634− (c->vc_origin - sisusb->scrbuf)),
618+ sisusb_copy_memory(sisusb, (char *)c->vc_origin,
619+ sisusb_haddr(sisusb, c, 0, 0),
635620 c->vc_screenbuf_size);
636621 sisusb->con_blanked = 1;
637622 ret = 1;
@@ -796,24 +781,24 @@ sisusbcon_scroll_area(struct vc_data *c, struct sisusb_usb_data *sisusb, · 158 unmodified lines
796781 switch (dir) {
797782
798783 case SM_UP:
799− sisusbcon_memmovew(SISUSB_VADDR(0, t),
800− SISUSB_VADDR(0, t + lines),
784+ memmove(sisusb_vaddr(sisusb, c, 0, t),
785+ sisusb_vaddr(sisusb, c, 0, t + lines),
801786 (b - t - lines) * cols * 2);
802− sisusbcon_memsetw(SISUSB_VADDR(0, b - lines), eattr,
803− lines * cols * 2);
787+ sisusbcon_memsetw(sisusb_vaddr(sisusb, c, 0, b - lines),
788+ eattr, lines * cols * 2);
804789 break;
805790
806791 case SM_DOWN:
807− sisusbcon_memmovew(SISUSB_VADDR(0, t + lines),
808− SISUSB_VADDR(0, t),
792+ memmove(sisusb_vaddr(sisusb, c, 0, t + lines),
793+ sisusb_vaddr(sisusb, c, 0, t),
809794 (b - t - lines) * cols * 2);
810− sisusbcon_memsetw(SISUSB_VADDR(0, t), eattr,
795+ sisusbcon_memsetw(sisusb_vaddr(sisusb, c, 0, t), eattr,
811796 lines * cols * 2);
812797 break;
813798 }
814799
815− sisusb_copy_memory(sisusb, (char *)SISUSB_VADDR(0, t),
816− (long)SISUSB_HADDR(0, t), length);
800+ sisusb_copy_memory(sisusb, sisusb_vaddr(sisusb, c, 0, t),
801+ sisusb_haddr(sisusb, c, 0, t), length);
817802
818803 mutex_unlock(&sisusb->lock);
819804
@@ -830,7 +815,6 @@ sisusbcon_scroll(struct vc_data *c, unsigned int t, unsigned int b, · 10 unmodified lines
830815 int copyall = 0;
831816 unsigned long oldorigin;
832817 unsigned int delta = lines * c->vc_size_row;
833− u32 originoffset;
834818
835819 /* Returning != 0 means we have done the scrolling successfully.
836820 * Returning 0 makes vt do the scrolling on its own.
@@ -874,7 +858,7 @@ sisusbcon_scroll(struct vc_data *c, unsigned int t, unsigned int b, · 37 unmodified lines
874858
875859 if (c->vc_scr_end + delta >=
876860 sisusb->scrbuf + sisusb->scrbuf_size) {
877− sisusbcon_memcpyw((u16 *)sisusb->scrbuf,
861+ memcpy((u16 *)sisusb->scrbuf,
878862 (u16 *)(oldorigin + delta),
879863 c->vc_screenbuf_size - delta);
880864 c->vc_origin = sisusb->scrbuf;
@@ -892,12 +876,10 @@ sisusbcon_scroll(struct vc_data *c, unsigned int t, unsigned int b, · 11 unmodified lines
892876 case SM_DOWN:
893877
894878 if (oldorigin - delta < sisusb->scrbuf) {
895− sisusbcon_memmovew((u16 *)(sisusb->scrbuf +
896− sisusb->scrbuf_size -
897− c->vc_screenbuf_size +
898− delta),
899− (u16 *)oldorigin,
900− c->vc_screenbuf_size - delta);
879+ memmove((void *)sisusb->scrbuf + sisusb->scrbuf_size -
880+ c->vc_screenbuf_size + delta,
881+ (u16 *)oldorigin,
882+ c->vc_screenbuf_size - delta);
901883 c->vc_origin = sisusb->scrbuf +
902884 sisusb->scrbuf_size -
903885 c->vc_screenbuf_size;
@@ -913,23 +895,21 @@ sisusbcon_scroll(struct vc_data *c, unsigned int t, unsigned int b, · 9 unmodified lines
913895 break;
914896 }
915897
916− originoffset = (u32)(c->vc_origin - sisusb->scrbuf);
917−
918898 if (copyall)
919899 sisusb_copy_memory(sisusb,
920900 (char *)c->vc_origin,
921− (u32)(sisusb->vrambase + originoffset),
901+ sisusb_haddr(sisusb, c, 0, 0),
922902 c->vc_screenbuf_size);
923903 else if (dir == SM_UP)
924904 sisusb_copy_memory(sisusb,
925905 (char *)c->vc_origin + c->vc_screenbuf_size - delta,
926− (u32)sisusb->vrambase + originoffset +
906+ sisusb_haddr(sisusb, c, 0, 0) +
927907 c->vc_screenbuf_size - delta,
928908 delta);
929909 else
930910 sisusb_copy_memory(sisusb,
931911 (char *)c->vc_origin,
932− (u32)(sisusb->vrambase + originoffset),
912+ sisusb_haddr(sisusb, c, 0, 0),
933913 delta);
934914
935915 c->vc_scr_end = c->vc_origin + c->vc_screenbuf_size;
@@ -1534,8 +1514,3 @@ void __init sisusb_init_concode(void) · 598 unmodified lines
15341514 for (i = 0; i < MAX_NR_CONSOLES; i++)
15351515 mysisusbs[i] = NULL;
15361516 }
1537−
1538−#endif /* INCL_CON */
1539−
1540−
1541−
drivers/usb/misc/sisusbvga/sisusb_init.c+0−5
@@ -44,9 +44,6 @@ · 43 unmodified lines
4444 #include <linux/spinlock.h>
4545
4646 #include "sisusb.h"
47−
48−#ifdef INCL_SISUSB_CON
49−
5047 #include "sisusb_init.h"
5148
5249 /*********************************************/
@@ -955,5 +952,3 @@ int SiSUSBSetVESAMode(struct SiS_Private *SiS_Pr, unsigned short VModeNo) · 902 unmodified lines
955952
956953 return SiSUSBSetMode(SiS_Pr, ModeNo);
957954 }
958−
959−#endif /* INCL_SISUSB_CON */
drivers/usb/misc/usb251xb.c+13−2
@@ -337,10 +337,12 @@ static int usb251xb_get_ofdata(struct usb251xb *hub, · 336 unmodified lines
337337 struct device *dev = hub->dev;
338338 struct device_node *np = dev->of_node;
339339 int len, err, i;
340− u32 property_u32 = 0;
340+ u32 port, property_u32 = 0;
341341 const u32 *cproperty_u32;
342342 const char *cproperty_char;
343343 char str[USB251XB_STRING_BUFSIZE / 2];
344+ struct property *prop;
345+ const __be32 *p;
344346
345347 if (!np) {
346348 dev_err(dev, "failed to get ofdata\n");
@@ -539,6 +541,16 @@ static int usb251xb_get_ofdata(struct usb251xb *hub, · 192 unmodified lines
539541 (wchar_t *)hub->serial,
540542 USB251XB_STRING_BUFSIZE);
541543
544+ /*
545+ * The datasheet documents the register as 'Port Swap' but in real the
546+ * register controls the USB DP/DM signal swapping for each port.
547+ */
548+ hub->port_swap = USB251XB_DEF_PORT_SWAP;
549+ of_property_for_each_u32(np, "swap-dx-lanes", prop, p, port) {
550+ if ((port >= 0) && (port <= data->port_cnt))
551+ hub->port_swap |= BIT(port);
552+ }
553+
542554 /* The following parameters are currently not exposed to devicetree, but
543555 * may be as soon as needed.
544556 */
@@ -546,7 +558,6 @@ static int usb251xb_get_ofdata(struct usb251xb *hub, · 1 unmodified line
546558 hub->boost_up = USB251XB_DEF_BOOST_UP;
547559 hub->boost_57 = USB251XB_DEF_BOOST_57;
548560 hub->boost_14 = USB251XB_DEF_BOOST_14;
549− hub->port_swap = USB251XB_DEF_PORT_SWAP;
550561 hub->port_map12 = USB251XB_DEF_PORT_MAP_12;
551562 hub->port_map34 = USB251XB_DEF_PORT_MAP_34;
552563 hub->port_map56 = USB251XB_DEF_PORT_MAP_56;
drivers/usb/misc/usb3503.c+30−8
@@ -355,11 +355,8 @@ static int usb3503_platform_remove(struct platform_device *pdev) · 354 unmodified lines
355355 }
356356
357357 #ifdef CONFIG_PM_SLEEP
358−static int usb3503_i2c_suspend(struct device *dev)
358+static int usb3503_suspend(struct usb3503 *hub)
359359 {
360− struct i2c_client *client = to_i2c_client(dev);
361− struct usb3503 *hub = i2c_get_clientdata(client);
362−
363360 usb3503_switch_mode(hub, USB3503_MODE_STANDBY);
364361
365362 if (hub->clk)
@@ -368,11 +365,8 @@ static int usb3503_i2c_suspend(struct device *dev) · 2 unmodified lines
368365 return 0;
369366 }
370367
371−static int usb3503_i2c_resume(struct device *dev)
368+static int usb3503_resume(struct usb3503 *hub)
372369 {
373− struct i2c_client *client = to_i2c_client(dev);
374− struct usb3503 *hub = i2c_get_clientdata(client);
375−
376370 if (hub->clk)
377371 clk_prepare_enable(hub->clk);
378372
@@ -380,11 +374,38 @@ static int usb3503_i2c_resume(struct device *dev) · 1 unmodified line
380374
381375 return 0;
382376 }
377+
378+static int usb3503_i2c_suspend(struct device *dev)
379+{
380+ struct i2c_client *client = to_i2c_client(dev);
381+
382+ return usb3503_suspend(i2c_get_clientdata(client));
383+}
384+
385+static int usb3503_i2c_resume(struct device *dev)
386+{
387+ struct i2c_client *client = to_i2c_client(dev);
388+
389+ return usb3503_resume(i2c_get_clientdata(client));
390+}
391+
392+static int usb3503_platform_suspend(struct device *dev)
393+{
394+ return usb3503_suspend(dev_get_drvdata(dev));
395+}
396+
397+static int usb3503_platform_resume(struct device *dev)
398+{
399+ return usb3503_resume(dev_get_drvdata(dev));
400+}
383401 #endif
384402
385403 static SIMPLE_DEV_PM_OPS(usb3503_i2c_pm_ops, usb3503_i2c_suspend,
386404 usb3503_i2c_resume);
387405
406+static SIMPLE_DEV_PM_OPS(usb3503_platform_pm_ops, usb3503_platform_suspend,
407+ usb3503_platform_resume);
408+
388409 static const struct i2c_device_id usb3503_id[] = {
389410 { USB3503_I2C_NAME, 0 },
390411 { }
@@ -415,6 +436,7 @@ static struct platform_driver usb3503_platform_driver = { · 24 unmodified lines
415436 .driver = {
416437 .name = USB3503_I2C_NAME,
417438 .of_match_table = of_match_ptr(usb3503_of_match),
439+ .pm = &usb3503_platform_pm_ops,
418440 },
419441 .probe = usb3503_platform_probe,
420442 .remove = usb3503_platform_remove,
drivers/usb/misc/usbtest.c+24−4
@@ -347,6 +347,14 @@ static unsigned get_maxpacket(struct usb_device *udev, int pipe) · 346 unmodified lines
347347 return le16_to_cpup(&ep->desc.wMaxPacketSize);
348348 }
349349
350+static int ss_isoc_get_packet_num(struct usb_device *udev, int pipe)
351+{
352+ struct usb_host_endpoint *ep = usb_pipe_endpoint(udev, pipe);
353+
354+ return USB_SS_MULT(ep->ss_ep_comp.bmAttributes)
355+ * (1 + ep->ss_ep_comp.bMaxBurst);
356+}
357+
350358 static void simple_fill_buf(struct urb *urb)
351359 {
352360 unsigned i;
@@ -1976,8 +1984,13 @@ static struct urb *iso_alloc_urb( · 1623 unmodified lines
19761984
19771985 if (bytes < 0 || !desc)
19781986 return NULL;
1987+
19791988 maxp = usb_endpoint_maxp(desc);
1980− maxp *= usb_endpoint_maxp_mult(desc);
1989+ if (udev->speed >= USB_SPEED_SUPER)
1990+ maxp *= ss_isoc_get_packet_num(udev, pipe);
1991+ else
1992+ maxp *= usb_endpoint_maxp_mult(desc);
1993+
19811994 packets = DIV_ROUND_UP(bytes, maxp);
19821995
19831996 urb = usb_alloc_urb(packets, GFP_KERNEL);
@@ -2065,17 +2078,24 @@ test_queue(struct usbtest_dev *dev, struct usbtest_param_32 *param, · 81 unmodified lines
20652078 packets *= param->iterations;
20662079
20672080 if (context.is_iso) {
2081+ int transaction_num;
2082+
2083+ if (udev->speed >= USB_SPEED_SUPER)
2084+ transaction_num = ss_isoc_get_packet_num(udev, pipe);
2085+ else
2086+ transaction_num = usb_endpoint_maxp_mult(desc);
2087+
20682088 dev_info(&dev->intf->dev,
20692089 "iso period %d %sframes, wMaxPacket %d, transactions: %d\n",
20702090 1 << (desc->bInterval - 1),
2071− (udev->speed == USB_SPEED_HIGH) ? "micro" : "",
2091+ (udev->speed >= USB_SPEED_HIGH) ? "micro" : "",
20722092 usb_endpoint_maxp(desc),
2073− usb_endpoint_maxp_mult(desc));
2093+ transaction_num);
20742094
20752095 dev_info(&dev->intf->dev,
20762096 "total %lu msec (%lu packets)\n",
20772097 (packets * (1 << (desc->bInterval - 1)))
2078− / ((udev->speed == USB_SPEED_HIGH) ? 8 : 1),
2098+ / ((udev->speed >= USB_SPEED_HIGH) ? 8 : 1),
20792099 packets);
20802100 }
20812101
drivers/usb/mon/Kconfig+1−0
@@ -1,3 +1,4 @@
1+# SPDX-License-Identifier: GPL-2.0
12 #
23 # USB Monitor configuration
34 #
drivers/usb/mtu3/Kconfig+2−0
@@ -1,3 +1,5 @@
1+# SPDX-License-Identifier: GPL-2.0
2+#
13 # For MTK USB3.0 IP
24
35 config USB_MTU3
drivers/usb/musb/Kconfig+3−2
@@ -1,3 +1,4 @@
1+# SPDX-License-Identifier: GPL-2.0
12 #
23 # USB Dual Role (OTG-ready) Controller Drivers
34 # for silicon based on Mentor Graphics INVENTRA designs
@@ -111,9 +112,9 @@ config USB_MUSB_UX500 · 107 unmodified lines
111112 config USB_MUSB_JZ4740
112113 tristate "JZ4740"
113114 depends on NOP_USB_XCEIV
114− depends on MACH_JZ4740 || COMPILE_TEST
115+ depends on MIPS || COMPILE_TEST
115116 depends on USB_MUSB_GADGET
116− depends on USB_OTG_BLACKLIST_HUB
117+ depends on USB=n || USB_OTG_BLACKLIST_HUB
117118
118119 config USB_MUSB_AM335X_CHILD
119120 tristate
drivers/usb/musb/jz4740.c+10−0
@@ -10,6 +10,7 @@ · 9 unmodified lines
1010 #include <linux/errno.h>
1111 #include <linux/kernel.h>
1212 #include <linux/module.h>
13+#include <linux/of_device.h>
1314 #include <linux/platform_device.h>
1415 #include <linux/usb/usb_phy_generic.h>
1516
@@ -188,11 +189,20 @@ static int jz4740_remove(struct platform_device *pdev) · 172 unmodified lines
188189 return 0;
189190 }
190191
192+#ifdef CONFIG_OF
193+static const struct of_device_id jz4740_musb_of_match[] = {
194+ { .compatible = "ingenic,jz4740-musb" },
195+ {},
196+};
197+MODULE_DEVICE_TABLE(of, jz4740_musb_of_match);
198+#endif
199+
191200 static struct platform_driver jz4740_driver = {
192201 .probe = jz4740_probe,
193202 .remove = jz4740_remove,
194203 .driver = {
195204 .name = "musb-jz4740",
205+ .of_match_table = of_match_ptr(jz4740_musb_of_match),
196206 },
197207 };
198208
drivers/usb/musb/musb_host.c+2−2
@@ -378,7 +378,7 @@ static void musb_advance_schedule(struct musb *musb, struct urb *urb, · 377 unmodified lines
378378 qh = first_qh(head);
379379 break;
380380 }
381− /* else: fall through */
381+ /* fall through */
382382
383383 case USB_ENDPOINT_XFER_ISOC:
384384 case USB_ENDPOINT_XFER_INT:
@@ -1283,7 +1283,7 @@ void musb_host_tx(struct musb *musb, u8 epnum) · 898 unmodified lines
12831283 MUSB_TXCSR_H_WZC_BITS
12841284 | MUSB_TXCSR_TXPKTRDY);
12851285 }
1286− return;
1286+ return;
12871287 }
12881288
12891289 done:
drivers/usb/phy/Kconfig+1−0
@@ -1,3 +1,4 @@
1+# SPDX-License-Identifier: GPL-2.0
12 #
23 # Physical Layer USB driver configuration
34 #
drivers/usb/phy/phy-twl6030-usb.c+1−1
@@ -400,7 +400,7 @@ static int twl6030_usb_remove(struct platform_device *pdev) · 399 unmodified lines
400400 {
401401 struct twl6030_usb *twl = platform_get_drvdata(pdev);
402402
403− cancel_delayed_work(&twl->get_status_work);
403+ cancel_delayed_work_sync(&twl->get_status_work);
404404 twl6030_interrupt_mask(TWL6030_USBOTG_INT_MASK,
405405 REG_INT_MSK_LINE_C);
406406 twl6030_interrupt_mask(TWL6030_USBOTG_INT_MASK,
drivers/usb/renesas_usbhs/mod_host.c+1−1
@@ -340,7 +340,7 @@ static void usbhsh_pipe_detach(struct usbhsh_hpriv *hpriv, · 339 unmodified lines
340340 pipe = usbhsh_uep_to_pipe(uep);
341341
342342 if (unlikely(!pipe)) {
343− dev_err(dev, "uep doens't have pipe\n");
343+ dev_err(dev, "uep doesn't have pipe\n");
344344 } else if (1 == uep->counter--) { /* last user */
345345 struct usb_host_endpoint *ep = usbhsh_uep_to_ep(uep);
346346 struct usbhsh_device *udev = usbhsh_uep_to_udev(uep);
drivers/usb/renesas_usbhs/rcar3.c+1−1
@@ -59,7 +59,7 @@ static int usbhs_rcar3_power_ctrl(struct platform_device *pdev, · 58 unmodified lines
5959 if (enable) {
6060 usbhs_bset(priv, LPSTS, LPSTS_SUSPM, LPSTS_SUSPM);
6161 /* The controller on R-Car Gen3 needs to wait up to 45 usec */
62− udelay(45);
62+ usleep_range(45, 90);
6363 } else {
6464 usbhs_bset(priv, LPSTS, LPSTS_SUSPM, 0);
6565 }
drivers/usb/renesas_usbhs/rza.c+1−1
@@ -35,7 +35,7 @@ static int usbhs_rza1_hardware_init(struct platform_device *pdev) · 34 unmodified lines
3535
3636 /* Enable USB PLL (NOTE: ch0 controls both ch0 and ch1) */
3737 usbhs_bset(priv, SYSCFG, UPLLE, UPLLE);
38− udelay(1000);
38+ usleep_range(1000, 2000);
3939 usbhs_bset(priv, SUSPMODE, SUSPM, SUSPM);
4040
4141 return 0;
drivers/usb/roles/Kconfig+2−0
@@ -1,3 +1,5 @@
1+# SPDX-License-Identifier: GPL-2.0
2+
13 config USB_ROLE_SWITCH
24 tristate "USB Role Switch Support"
35 help
drivers/usb/roles/Makefile+2−0
@@ -1,3 +1,5 @@
1+# SPDX-License-Identifier: GPL-2.0
2+
13 obj-$(CONFIG_USB_ROLE_SWITCH) += roles.o
24 roles-y := class.o
35 obj-$(CONFIG_USB_ROLES_INTEL_XHCI) += intel-xhci-usb-role-switch.o
drivers/usb/roles/class.c+18−3
@@ -8,6 +8,7 @@ · 7 unmodified lines
88 */
99
1010 #include <linux/usb/role.h>
11+#include <linux/property.h>
1112 #include <linux/device.h>
1213 #include <linux/module.h>
1314 #include <linux/mutex.h>
@@ -84,7 +85,12 @@ enum usb_role usb_role_switch_get_role(struct usb_role_switch *sw) · 70 unmodified lines
8485 }
8586 EXPORT_SYMBOL_GPL(usb_role_switch_get_role);
8687
87−static int __switch_match(struct device *dev, const void *name)
88+static int switch_fwnode_match(struct device *dev, const void *fwnode)
89+{
90+ return dev_fwnode(dev) == fwnode;
91+}
92+
93+static int switch_name_match(struct device *dev, const void *name)
8894 {
8995 return !strcmp((const char *)name, dev_name(dev));
9096 }
@@ -94,8 +100,16 @@ static void *usb_role_switch_match(struct device_connection *con, int ep, · 3 unmodified lines
94100 {
95101 struct device *dev;
96102
97− dev = class_find_device(role_class, NULL, con->endpoint[ep],
98− __switch_match);
103+ if (con->fwnode) {
104+ if (!fwnode_property_present(con->fwnode, con->id))
105+ return NULL;
106+
107+ dev = class_find_device(role_class, NULL, con->fwnode,
108+ switch_fwnode_match);
109+ } else {
110+ dev = class_find_device(role_class, NULL, con->endpoint[ep],
111+ switch_name_match);
112+ }
99113
100114 return dev ? to_role_switch(dev) : ERR_PTR(-EPROBE_DEFER);
101115 }
@@ -266,6 +280,7 @@ usb_role_switch_register(struct device *parent, · 164 unmodified lines
266280 sw->get = desc->get;
267281
268282 sw->dev.parent = parent;
283+ sw->dev.fwnode = desc->fwnode;
269284 sw->dev.class = role_class;
270285 sw->dev.type = &usb_role_dev_type;
271286 dev_set_name(&sw->dev, "%s-role-switch", dev_name(parent));
drivers/usb/serial/Kconfig+1−0
@@ -1,3 +1,4 @@
1+# SPDX-License-Identifier: GPL-2.0
12 #
23 # USB Serial device configuration
34 #
drivers/usb/serial/cp210x.c+111−19
@@ -61,6 +61,7 @@ static const struct usb_device_id id_table[] = { · 60 unmodified lines
6161 { USB_DEVICE(0x08e6, 0x5501) }, /* Gemalto Prox-PU/CU contactless smartcard reader */
6262 { USB_DEVICE(0x08FD, 0x000A) }, /* Digianswer A/S , ZigBee/802.15.4 MAC Device */
6363 { USB_DEVICE(0x0908, 0x01FF) }, /* Siemens RUGGEDCOM USB Serial Console */
64+ { USB_DEVICE(0x0B00, 0x3070) }, /* Ingenico 3070 */
6465 { USB_DEVICE(0x0BED, 0x1100) }, /* MEI (TM) Cashflow-SC Bill/Voucher Acceptor */
6566 { USB_DEVICE(0x0BED, 0x1101) }, /* MEI series 2000 Combo Acceptor */
6667 { USB_DEVICE(0x0FCF, 0x1003) }, /* Dynastream ANT development board */
@@ -245,6 +246,7 @@ struct cp210x_serial_private { · 178 unmodified lines
245246 u8 gpio_input;
246247 #endif
247248 u8 partnum;
249+ speed_t min_speed;
248250 speed_t max_speed;
249251 bool use_actual_rate;
250252 };
@@ -443,10 +445,10 @@ struct cp210x_pin_mode { · 192 unmodified lines
443445 #define CP210X_PIN_MODE_GPIO BIT(0)
444446
445447 /*
446− * CP210X_VENDOR_SPECIFIC, CP210X_GET_PORTCONFIG call reads these 0xf bytes.
447− * Structure needs padding due to unused/unspecified bytes.
448+ * CP210X_VENDOR_SPECIFIC, CP210X_GET_PORTCONFIG call reads these 0xf bytes
449+ * on a CP2105 chip. Structure needs padding due to unused/unspecified bytes.
448450 */
449−struct cp210x_config {
451+struct cp210x_dual_port_config {
450452 __le16 gpio_mode;
451453 u8 __pad0[2];
452454 __le16 reset_state;
@@ -457,6 +459,19 @@ struct cp210x_config { · 4 unmodified lines
457459 u8 device_cfg;
458460 } __packed;
459461
462+/*
463+ * CP210X_VENDOR_SPECIFIC, CP210X_GET_PORTCONFIG call reads these 0xd bytes
464+ * on a CP2104 chip. Structure needs padding due to unused/unspecified bytes.
465+ */
466+struct cp210x_single_port_config {
467+ __le16 gpio_mode;
468+ u8 __pad0[2];
469+ __le16 reset_state;
470+ u8 __pad1[4];
471+ __le16 suspend_state;
472+ u8 device_cfg;
473+} __packed;
474+
460475 /* GPIO modes */
461476 #define CP210X_SCI_GPIO_MODE_OFFSET 9
462477 #define CP210X_SCI_GPIO_MODE_MASK GENMASK(11, 9)
@@ -464,11 +479,19 @@ struct cp210x_config { · 1 unmodified line
464479 #define CP210X_ECI_GPIO_MODE_OFFSET 2
465480 #define CP210X_ECI_GPIO_MODE_MASK GENMASK(3, 2)
466481
482+#define CP210X_GPIO_MODE_OFFSET 8
483+#define CP210X_GPIO_MODE_MASK GENMASK(11, 8)
484+
467485 /* CP2105 port configuration values */
468486 #define CP2105_GPIO0_TXLED_MODE BIT(0)
469487 #define CP2105_GPIO1_RXLED_MODE BIT(1)
470488 #define CP2105_GPIO1_RS485_MODE BIT(2)
471489
490+/* CP2104 port configuration values */
491+#define CP2104_GPIO0_TXLED_MODE BIT(0)
492+#define CP2104_GPIO1_RXLED_MODE BIT(1)
493+#define CP2104_GPIO2_RS485_MODE BIT(2)
494+
472495 /* CP2102N configuration array indices */
473496 #define CP210X_2NCONFIG_CONFIG_VERSION_IDX 2
474497 #define CP210X_2NCONFIG_GPIO_MODE_IDX 581
@@ -1051,14 +1074,11 @@ static speed_t cp210x_get_an205_rate(speed_t baud) · 576 unmodified lines
10511074 return cp210x_an205_table1[i].rate;
10521075 }
10531076
1054−static speed_t cp210x_get_actual_rate(struct usb_serial *serial, speed_t baud)
1077+static speed_t cp210x_get_actual_rate(speed_t baud)
10551078 {
1056− struct cp210x_serial_private *priv = usb_get_serial_data(serial);
10571079 unsigned int prescale = 1;
10581080 unsigned int div;
10591081
1060− baud = clamp(baud, 300u, priv->max_speed);
1061−
10621082 if (baud <= 365)
10631083 prescale = 4;
10641084
@@ -1101,20 +1121,18 @@ static void cp210x_change_speed(struct tty_struct *tty, · 36 unmodified lines
11011121 struct cp210x_serial_private *priv = usb_get_serial_data(serial);
11021122 u32 baud;
11031123
1104− baud = tty->termios.c_ospeed;
1105−
11061124 /*
11071125 * This maps the requested rate to the actual rate, a valid rate on
11081126 * cp2102 or cp2103, or to an arbitrary rate in [1M, max_speed].
11091127 *
11101128 * NOTE: B0 is not implemented.
11111129 */
1130+ baud = clamp(tty->termios.c_ospeed, priv->min_speed, priv->max_speed);
1131+
11121132 if (priv->use_actual_rate)
1113− baud = cp210x_get_actual_rate(serial, baud);
1133+ baud = cp210x_get_actual_rate(baud);
11141134 else if (baud < 1000000)
11151135 baud = cp210x_get_an205_rate(baud);
1116− else if (baud > priv->max_speed)
1117− baud = priv->max_speed;
11181136
11191137 dev_dbg(&port->dev, "%s - setting baud rate to %u\n", __func__, baud);
11201138 if (cp210x_write_u32_reg(port, CP210X_SET_BAUDRATE, baud)) {
@@ -1353,8 +1371,13 @@ static int cp210x_gpio_get(struct gpio_chip *gc, unsigned int gpio) · 232 unmodified lines
13531371 if (priv->partnum == CP210X_PARTNUM_CP2105)
13541372 req_type = REQTYPE_INTERFACE_TO_HOST;
13551373
1374+ result = usb_autopm_get_interface(serial->interface);
1375+ if (result)
1376+ return result;
1377+
13561378 result = cp210x_read_vendor_block(serial, req_type,
13571379 CP210X_READ_LATCH, &buf, sizeof(buf));
1380+ usb_autopm_put_interface(serial->interface);
13581381 if (result < 0)
13591382 return result;
13601383
@@ -1375,6 +1398,10 @@ static void cp210x_gpio_set(struct gpio_chip *gc, unsigned int gpio, int value) · 14 unmodified lines
13751398
13761399 buf.mask = BIT(gpio);
13771400
1401+ result = usb_autopm_get_interface(serial->interface);
1402+ if (result)
1403+ goto out;
1404+
13781405 if (priv->partnum == CP210X_PARTNUM_CP2105) {
13791406 result = cp210x_write_vendor_block(serial,
13801407 REQTYPE_HOST_TO_INTERFACE,
@@ -1392,6 +1419,8 @@ static void cp210x_gpio_set(struct gpio_chip *gc, unsigned int gpio, int value) · 11 unmodified lines
13921419 NULL, 0, USB_CTRL_SET_TIMEOUT);
13931420 }
13941421
1422+ usb_autopm_put_interface(serial->interface);
1423+out:
13951424 if (result < 0) {
13961425 dev_err(&serial->interface->dev, "failed to set GPIO value: %d\n",
13971426 result);
@@ -1470,7 +1499,7 @@ static int cp2105_gpioconf_init(struct usb_serial *serial) · 72 unmodified lines
14701499 {
14711500 struct cp210x_serial_private *priv = usb_get_serial_data(serial);
14721501 struct cp210x_pin_mode mode;
1473− struct cp210x_config config;
1502+ struct cp210x_dual_port_config config;
14741503 u8 intf_num = cp210x_interface_num(serial);
14751504 u8 iface_config;
14761505 int result;
@@ -1529,6 +1558,56 @@ static int cp2105_gpioconf_init(struct usb_serial *serial) · 52 unmodified lines
15291558 return 0;
15301559 }
15311560
1561+static int cp2104_gpioconf_init(struct usb_serial *serial)
1562+{
1563+ struct cp210x_serial_private *priv = usb_get_serial_data(serial);
1564+ struct cp210x_single_port_config config;
1565+ u8 iface_config;
1566+ u8 gpio_latch;
1567+ int result;
1568+ u8 i;
1569+
1570+ result = cp210x_read_vendor_block(serial, REQTYPE_DEVICE_TO_HOST,
1571+ CP210X_GET_PORTCONFIG, &config,
1572+ sizeof(config));
1573+ if (result < 0)
1574+ return result;
1575+
1576+ priv->gc.ngpio = 4;
1577+
1578+ iface_config = config.device_cfg;
1579+ priv->gpio_pushpull = (u8)((le16_to_cpu(config.gpio_mode) &
1580+ CP210X_GPIO_MODE_MASK) >>
1581+ CP210X_GPIO_MODE_OFFSET);
1582+ gpio_latch = (u8)((le16_to_cpu(config.reset_state) &
1583+ CP210X_GPIO_MODE_MASK) >>
1584+ CP210X_GPIO_MODE_OFFSET);
1585+
1586+ /* mark all pins which are not in GPIO mode */
1587+ if (iface_config & CP2104_GPIO0_TXLED_MODE) /* GPIO 0 */
1588+ priv->gpio_altfunc |= BIT(0);
1589+ if (iface_config & CP2104_GPIO1_RXLED_MODE) /* GPIO 1 */
1590+ priv->gpio_altfunc |= BIT(1);
1591+ if (iface_config & CP2104_GPIO2_RS485_MODE) /* GPIO 2 */
1592+ priv->gpio_altfunc |= BIT(2);
1593+
1594+ /*
1595+ * Like CP2102N, CP2104 has also no strict input and output pin
1596+ * modes.
1597+ * Do the same input mode emulation as CP2102N.
1598+ */
1599+ for (i = 0; i < priv->gc.ngpio; ++i) {
1600+ /*
1601+ * Set direction to "input" iff pin is open-drain and reset
1602+ * value is 1.
1603+ */
1604+ if (!(priv->gpio_pushpull & BIT(i)) && (gpio_latch & BIT(i)))
1605+ priv->gpio_input |= BIT(i);
1606+ }
1607+
1608+ return 0;
1609+}
1610+
15321611 static int cp2102n_gpioconf_init(struct usb_serial *serial)
15331612 {
15341613 struct cp210x_serial_private *priv = usb_get_serial_data(serial);
@@ -1574,12 +1653,6 @@ static int cp2102n_gpioconf_init(struct usb_serial *serial) · 39 unmodified lines
15741653 if (config_version != 0x01)
15751654 return -ENOTSUPP;
15761655
1577− /*
1578− * We only support 4 GPIOs even on the QFN28 package, because
1579− * config locations of GPIOs 4-6 determined using reverse
1580− * engineering revealed conflicting offsets with other
1581− * documented functions. So we'll just play it safe for now.
1582− */
15831656 priv->gc.ngpio = 4;
15841657
15851658 /*
@@ -1594,6 +1667,19 @@ static int cp2102n_gpioconf_init(struct usb_serial *serial) · 8 unmodified lines
15941667 /* 0 indicates GPIO mode, 1 is alternate function */
15951668 priv->gpio_altfunc = (gpio_ctrl >> 2) & 0x0f;
15961669
1670+ if (priv->partnum == CP210X_PARTNUM_CP2102N_QFN28) {
1671+ /*
1672+ * For the QFN28 package, GPIO4-6 are controlled by
1673+ * the low three bits of the mode/latch fields.
1674+ * Contrary to the document linked above, the bits for
1675+ * the SUSPEND pins are elsewhere. No alternate
1676+ * function is available for these pins.
1677+ */
1678+ priv->gc.ngpio = 7;
1679+ gpio_latch |= (gpio_rst_latch & 7) << 4;
1680+ priv->gpio_pushpull |= (gpio_pushpull & 7) << 4;
1681+ }
1682+
15971683 /*
15981684 * The CP2102N does not strictly has input and output pin modes,
15991685 * it only knows open-drain and push-pull modes which is set at
@@ -1620,6 +1706,9 @@ static int cp210x_gpio_init(struct usb_serial *serial) · 20 unmodified lines
16201706 int result;
16211707
16221708 switch (priv->partnum) {
1709+ case CP210X_PARTNUM_CP2104:
1710+ result = cp2104_gpioconf_init(serial);
1711+ break;
16231712 case CP210X_PARTNUM_CP2105:
16241713 result = cp2105_gpioconf_init(serial);
16251714 break;
@@ -1716,6 +1805,7 @@ static void cp210x_init_max_speed(struct usb_serial *serial) · 90 unmodified lines
17161805 {
17171806 struct cp210x_serial_private *priv = usb_get_serial_data(serial);
17181807 bool use_actual_rate = false;
1808+ speed_t min = 300;
17191809 speed_t max;
17201810
17211811 switch (priv->partnum) {
@@ -1738,6 +1828,7 @@ static void cp210x_init_max_speed(struct usb_serial *serial) · 16 unmodified lines
17381828 use_actual_rate = true;
17391829 max = 2000000; /* ECI */
17401830 } else {
1831+ min = 2400;
17411832 max = 921600; /* SCI */
17421833 }
17431834 break;
@@ -1752,6 +1843,7 @@ static void cp210x_init_max_speed(struct usb_serial *serial) · 8 unmodified lines
17521843 break;
17531844 }
17541845
1846+ priv->min_speed = min;
17551847 priv->max_speed = max;
17561848 priv->use_actual_rate = use_actual_rate;
17571849 }
drivers/usb/serial/ftdi_sio.c+2−0
@@ -1025,6 +1025,8 @@ static const struct usb_device_id id_table_combined[] = { · 1024 unmodified lines
10251025 { USB_DEVICE(CYPRESS_VID, CYPRESS_WICED_BT_USB_PID) },
10261026 { USB_DEVICE(CYPRESS_VID, CYPRESS_WICED_WL_USB_PID) },
10271027 { USB_DEVICE(AIRBUS_DS_VID, AIRBUS_DS_P8GR) },
1028+ /* EZPrototypes devices */
1029+ { USB_DEVICE(EZPROTOTYPES_VID, HJELMSLUND_USB485_ISO_PID) },
10281030 { } /* Terminating entry */
10291031 };
10301032
drivers/usb/serial/ftdi_sio_ids.h+6−0
@@ -1308,6 +1308,12 @@ · 1307 unmodified lines
13081308 #define IONICS_VID 0x1c0c
13091309 #define IONICS_PLUGCOMPUTER_PID 0x0102
13101310
1311+/*
1312+ * EZPrototypes (PID reseller)
1313+ */
1314+#define EZPROTOTYPES_VID 0x1c40
1315+#define HJELMSLUND_USB485_ISO_PID 0x0477
1316+
13111317 /*
13121318 * Dresden Elektronik Sensor Terminal Board
13131319 */
drivers/usb/serial/option.c+2−0
@@ -1148,6 +1148,8 @@ static const struct usb_device_id option_ids[] = { · 1147 unmodified lines
11481148 .driver_info = NCTRL(0) | RSVD(1) | RSVD(3) },
11491149 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_ME910_DUAL_MODEM),
11501150 .driver_info = NCTRL(0) | RSVD(3) },
1151+ { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x1102, 0xff), /* Telit ME910 (ECM) */
1152+ .driver_info = NCTRL(0) },
11511153 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE910),
11521154 .driver_info = NCTRL(0) | RSVD(1) | RSVD(2) },
11531155 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE910_USBCFG4),
drivers/usb/storage/Kconfig+1−0
@@ -1,3 +1,4 @@
1+# SPDX-License-Identifier: GPL-2.0
12 #
23 # USB Storage driver configuration
34 #
drivers/usb/storage/karma.c+2−0
@@ -167,6 +167,7 @@ static int rio_karma_transport(struct scsi_cmnd *srb, struct us_data *us) · 166 unmodified lines
167167 static void rio_karma_destructor(void *extra)
168168 {
169169 struct karma_data *data = (struct karma_data *) extra;
170+
170171 kfree(data->recv);
171172 }
172173
@@ -174,6 +175,7 @@ static int rio_karma_init(struct us_data *us) · 1 unmodified line
174175 {
175176 int ret = 0;
176177 struct karma_data *data = kzalloc(sizeof(struct karma_data), GFP_NOIO);
178+
177179 if (!data)
178180 goto out;
179181
drivers/usb/typec/Kconfig+1−0
@@ -1,3 +1,4 @@
1+# SPDX-License-Identifier: GPL-2.0
12
23 menuconfig TYPEC
34 tristate "USB Type-C Support"
drivers/usb/typec/altmodes/Kconfig+1−0
@@ -1,3 +1,4 @@
1+# SPDX-License-Identifier: GPL-2.0
12
23 menu "USB Type-C Alternate Mode drivers"
34
drivers/usb/typec/altmodes/Makefile+2−0
@@ -1,2 +1,4 @@
1+# SPDX-License-Identifier: GPL-2.0
2+
13 obj-$(CONFIG_TYPEC_DP_ALTMODE) += typec_displayport.o
24 typec_displayport-y := displayport.o
drivers/usb/typec/altmodes/displayport.c+0−4
@@ -24,10 +24,6 @@ enum { · 23 unmodified lines
2424 DP_CONF_DUAL_D,
2525 };
2626
27−/* Helper for setting/getting the pin assignement value to the configuration */
28−#define DP_CONF_SET_PIN_ASSIGN(_a_) ((_a_) << 8)
29−#define DP_CONF_GET_PIN_ASSIGN(_conf_) (((_conf_) & GENMASK(15, 8)) >> 8)
30−
3127 /* Pin assignments that use USB3.1 Gen2 signaling to carry DP protocol */
3228 #define DP_PIN_ASSIGN_GEN2_BR_MASK (BIT(DP_PIN_ASSIGN_A) | \
3329 BIT(DP_PIN_ASSIGN_B))
drivers/usb/typec/class.c+24−9
@@ -9,6 +9,7 @@ · 8 unmodified lines
99 #include <linux/device.h>
1010 #include <linux/module.h>
1111 #include <linux/mutex.h>
12+#include <linux/property.h>
1213 #include <linux/slab.h>
1314
1415 #include "bus.h"
@@ -204,15 +205,32 @@ static void typec_altmode_put_partner(struct altmode *altmode) · 189 unmodified lines
204205 put_device(&adev->dev);
205206 }
206207
207−static int __typec_port_match(struct device *dev, const void *name)
208+static int typec_port_fwnode_match(struct device *dev, const void *fwnode)
209+{
210+ return dev_fwnode(dev) == fwnode;
211+}
212+
213+static int typec_port_name_match(struct device *dev, const void *name)
208214 {
209215 return !strcmp((const char *)name, dev_name(dev));
210216 }
211217
212218 static void *typec_port_match(struct device_connection *con, int ep, void *data)
213219 {
214− return class_find_device(typec_class, NULL, con->endpoint[ep],
215− __typec_port_match);
220+ struct device *dev;
221+
222+ /*
223+ * FIXME: Check does the fwnode supports the requested SVID. If it does
224+ * we need to return ERR_PTR(-PROBE_DEFER) when there is no device.
225+ */
226+ if (con->fwnode)
227+ return class_find_device(typec_class, NULL, con->fwnode,
228+ typec_port_fwnode_match);
229+
230+ dev = class_find_device(typec_class, NULL, con->endpoint[ep],
231+ typec_port_name_match);
232+
233+ return dev ? dev : ERR_PTR(-EPROBE_DEFER);
216234 }
217235
218236 struct typec_altmode *
@@ -277,7 +295,7 @@ void typec_altmode_update_active(struct typec_altmode *adev, bool active) · 58 unmodified lines
277295 if (adev->active == active)
278296 return;
279297
280− if (!is_typec_port(adev->dev.parent)) {
298+ if (!is_typec_port(adev->dev.parent) && adev->dev.driver) {
281299 if (!active)
282300 module_put(adev->dev.driver->owner);
283301 else
@@ -1496,11 +1514,8 @@ typec_port_register_altmode(struct typec_port *port, · 1212 unmodified lines
14961514 {
14971515 struct typec_altmode *adev;
14981516 struct typec_mux *mux;
1499− char id[10];
1500−
1501− sprintf(id, "id%04xm%02x", desc->svid, desc->mode);
15021517
1503− mux = typec_mux_get(&port->dev, id);
1518+ mux = typec_mux_get(&port->dev, desc);
15041519 if (IS_ERR(mux))
15051520 return ERR_CAST(mux);
15061521
@@ -1593,7 +1608,7 @@ struct typec_port *typec_register_port(struct device *parent, · 86 unmodified lines
15931608 return ERR_CAST(port->sw);
15941609 }
15951610
1596− port->mux = typec_mux_get(&port->dev, "typec-mux");
1611+ port->mux = typec_mux_get(&port->dev, NULL);
15971612 if (IS_ERR(port->mux)) {
15981613 put_device(&port->dev);
15991614 return ERR_CAST(port->mux);
drivers/usb/typec/mux.c+79−15
@@ -11,6 +11,8 @@ · 10 unmodified lines
1111 #include <linux/list.h>
1212 #include <linux/module.h>
1313 #include <linux/mutex.h>
14+#include <linux/property.h>
15+#include <linux/slab.h>
1416 #include <linux/usb/typec_mux.h>
1517
1618 static DEFINE_MUTEX(switch_lock);
@@ -23,15 +25,25 @@ static void *typec_switch_match(struct device_connection *con, int ep, · 6 unmodified lines
2325 {
2426 struct typec_switch *sw;
2527
26− list_for_each_entry(sw, &switch_list, entry)
27− if (!strcmp(con->endpoint[ep], dev_name(sw->dev)))
28− return sw;
28+ if (!con->fwnode) {
29+ list_for_each_entry(sw, &switch_list, entry)
30+ if (!strcmp(con->endpoint[ep], dev_name(sw->dev)))
31+ return sw;
32+ return ERR_PTR(-EPROBE_DEFER);
33+ }
2934
3035 /*
31− * We only get called if a connection was found, tell the caller to
32− * wait for the switch to show up.
36+ * With OF graph the mux node must have a boolean device property named
37+ * "orientation-switch".
3338 */
34− return ERR_PTR(-EPROBE_DEFER);
39+ if (con->id && !fwnode_property_present(con->fwnode, con->id))
40+ return NULL;
41+
42+ list_for_each_entry(sw, &switch_list, entry)
43+ if (dev_fwnode(sw->dev) == con->fwnode)
44+ return sw;
45+
46+ return con->id ? ERR_PTR(-EPROBE_DEFER) : NULL;
3547 }
3648
3749 /**
@@ -48,7 +60,7 @@ struct typec_switch *typec_switch_get(struct device *dev) · 10 unmodified lines
4860 struct typec_switch *sw;
4961
5062 mutex_lock(&switch_lock);
51− sw = device_connection_find_match(dev, "typec-switch", NULL,
63+ sw = device_connection_find_match(dev, "orientation-switch", NULL,
5264 typec_switch_match);
5365 if (!IS_ERR_OR_NULL(sw)) {
5466 WARN_ON(!try_module_get(sw->dev->driver->owner));
@@ -112,35 +124,87 @@ EXPORT_SYMBOL_GPL(typec_switch_unregister); · 57 unmodified lines
112124
113125 static void *typec_mux_match(struct device_connection *con, int ep, void *data)
114126 {
127+ const struct typec_altmode_desc *desc = data;
115128 struct typec_mux *mux;
129+ int nval;
130+ bool match;
131+ u16 *val;
132+ int i;
116133
117− list_for_each_entry(mux, &mux_list, entry)
118− if (!strcmp(con->endpoint[ep], dev_name(mux->dev)))
119− return mux;
134+ if (!con->fwnode) {
135+ list_for_each_entry(mux, &mux_list, entry)
136+ if (!strcmp(con->endpoint[ep], dev_name(mux->dev)))
137+ return mux;
138+ return ERR_PTR(-EPROBE_DEFER);
139+ }
120140
121141 /*
122− * We only get called if a connection was found, tell the caller to
123− * wait for the switch to show up.
142+ * Check has the identifier already been "consumed". If it
143+ * has, no need to do any extra connection identification.
124144 */
145+ match = !con->id;
146+ if (match)
147+ goto find_mux;
148+
149+ /* Accessory Mode muxes */
150+ if (!desc) {
151+ match = fwnode_property_present(con->fwnode, "accessory");
152+ if (match)
153+ goto find_mux;
154+ return NULL;
155+ }
156+
157+ /* Alternate Mode muxes */
158+ nval = fwnode_property_read_u16_array(con->fwnode, "svid", NULL, 0);
159+ if (nval <= 0)
160+ return NULL;
161+
162+ val = kcalloc(nval, sizeof(*val), GFP_KERNEL);
163+ if (!val)
164+ return ERR_PTR(-ENOMEM);
165+
166+ nval = fwnode_property_read_u16_array(con->fwnode, "svid", val, nval);
167+ if (nval < 0) {
168+ kfree(val);
169+ return ERR_PTR(nval);
170+ }
171+
172+ for (i = 0; i < nval; i++) {
173+ match = val[i] == desc->svid;
174+ if (match) {
175+ kfree(val);
176+ goto find_mux;
177+ }
178+ }
179+ kfree(val);
180+ return NULL;
181+
182+find_mux:
183+ list_for_each_entry(mux, &mux_list, entry)
184+ if (dev_fwnode(mux->dev) == con->fwnode)
185+ return mux;
186+
125187 return ERR_PTR(-EPROBE_DEFER);
126188 }
127189
128190 /**
129191 * typec_mux_get - Find USB Type-C Multiplexer
130192 * @dev: The caller device
131− * @name: Mux identifier
193+ * @desc: Alt Mode description
132194 *
133195 * Finds a mux linked to the caller. This function is primarily meant for the
134196 * Type-C drivers. Returns a reference to the mux on success, NULL if no
135197 * matching connection was found, or ERR_PTR(-EPROBE_DEFER) when a connection
136198 * was found but the mux has not been enumerated yet.
137199 */
138−struct typec_mux *typec_mux_get(struct device *dev, const char *name)
200+struct typec_mux *typec_mux_get(struct device *dev,
201+ const struct typec_altmode_desc *desc)
139202 {
140203 struct typec_mux *mux;
141204
142205 mutex_lock(&mux_lock);
143− mux = device_connection_find_match(dev, name, NULL, typec_mux_match);
206+ mux = device_connection_find_match(dev, "mode-switch", (void *)desc,
207+ typec_mux_match);
144208 if (!IS_ERR_OR_NULL(mux)) {
145209 WARN_ON(!try_module_get(mux->dev->driver->owner));
146210 get_device(mux->dev);
drivers/usb/typec/mux/Kconfig+2−0
@@ -1,3 +1,5 @@
1+# SPDX-License-Identifier: GPL-2.0
2+
13 menu "USB Type-C Multiplexer/DeMultiplexer Switch support"
24
35 config TYPEC_MUX_PI3USB30532
drivers/usb/typec/tcpm/Kconfig+2−0
@@ -1,3 +1,5 @@
1+# SPDX-License-Identifier: GPL-2.0
2+
13 config TYPEC_TCPM
24 tristate "USB Type-C Port Controller Manager"
35 depends on USB
drivers/usb/typec/tcpm/tcpm.c+5−63
@@ -4435,66 +4435,6 @@ sink: · 4434 unmodified lines
44354435 return 0;
44364436 }
44374437
4438−int tcpm_update_source_capabilities(struct tcpm_port *port, const u32 *pdo,
4439− unsigned int nr_pdo)
4440−{
4441− if (tcpm_validate_caps(port, pdo, nr_pdo))
4442− return -EINVAL;
4443−
4444− mutex_lock(&port->lock);
4445− port->nr_src_pdo = tcpm_copy_pdos(port->src_pdo, pdo, nr_pdo);
4446− switch (port->state) {
4447− case SRC_UNATTACHED:
4448− case SRC_ATTACH_WAIT:
4449− case SRC_TRYWAIT:
4450− tcpm_set_cc(port, tcpm_rp_cc(port));
4451− break;
4452− case SRC_SEND_CAPABILITIES:
4453− case SRC_NEGOTIATE_CAPABILITIES:
4454− case SRC_READY:
4455− case SRC_WAIT_NEW_CAPABILITIES:
4456− tcpm_set_cc(port, tcpm_rp_cc(port));
4457− tcpm_set_state(port, SRC_SEND_CAPABILITIES, 0);
4458− break;
4459− default:
4460− break;
4461− }
4462− mutex_unlock(&port->lock);
4463− return 0;
4464−}
4465−EXPORT_SYMBOL_GPL(tcpm_update_source_capabilities);
4466−
4467−int tcpm_update_sink_capabilities(struct tcpm_port *port, const u32 *pdo,
4468− unsigned int nr_pdo,
4469− unsigned int operating_snk_mw)
4470−{
4471− if (tcpm_validate_caps(port, pdo, nr_pdo))
4472− return -EINVAL;
4473−
4474− mutex_lock(&port->lock);
4475− port->nr_snk_pdo = tcpm_copy_pdos(port->snk_pdo, pdo, nr_pdo);
4476− port->operating_snk_mw = operating_snk_mw;
4477− port->update_sink_caps = true;
4478−
4479− switch (port->state) {
4480− case SNK_NEGOTIATE_CAPABILITIES:
4481− case SNK_NEGOTIATE_PPS_CAPABILITIES:
4482− case SNK_READY:
4483− case SNK_TRANSITION_SINK:
4484− case SNK_TRANSITION_SINK_VBUS:
4485− if (port->pps_data.active)
4486− tcpm_set_state(port, SNK_NEGOTIATE_PPS_CAPABILITIES, 0);
4487− else
4488− tcpm_set_state(port, SNK_NEGOTIATE_CAPABILITIES, 0);
4489− break;
4490− default:
4491− break;
4492− }
4493− mutex_unlock(&port->lock);
4494− return 0;
4495−}
4496−EXPORT_SYMBOL_GPL(tcpm_update_sink_capabilities);
4497−
44984438 /* Power Supply access to expose source power information */
44994439 enum tcpm_psy_online_states {
45004440 TCPM_PSY_OFFLINE = 0,
@@ -4811,12 +4751,12 @@ struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc) · 310 unmodified lines
48114751
48124752 err = devm_tcpm_psy_register(port);
48134753 if (err)
4814− goto out_destroy_wq;
4754+ goto out_role_sw_put;
48154755
48164756 port->typec_port = typec_register_port(port->dev, &port->typec_caps);
48174757 if (IS_ERR(port->typec_port)) {
48184758 err = PTR_ERR(port->typec_port);
4819− goto out_destroy_wq;
4759+ goto out_role_sw_put;
48204760 }
48214761
48224762 if (tcpc->config && tcpc->config->alt_modes) {
@@ -4849,8 +4789,10 @@ struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc) · 26 unmodified lines
48494789 tcpm_log(port, "%s: registered", dev_name(dev));
48504790 return port;
48514791
4852−out_destroy_wq:
4792+out_role_sw_put:
48534793 usb_role_switch_put(port->role_sw);
4794+out_destroy_wq:
4795+ tcpm_debugfs_exit(port);
48544796 destroy_workqueue(port->wq);
48554797 return ERR_PTR(err);
48564798 }
drivers/usb/typec/tps6598x.c+69−10
@@ -14,6 +14,8 @@ · 13 unmodified lines
1414 #include <linux/usb/typec.h>
1515
1616 /* Register offsets */
17+#define TPS_REG_VID 0x00
18+#define TPS_REG_MODE 0x03
1719 #define TPS_REG_CMD1 0x08
1820 #define TPS_REG_DATA1 0x09
1921 #define TPS_REG_INT_EVENT1 0x14
@@ -66,6 +68,20 @@ struct tps6598x_rx_identity_reg { · 46 unmodified lines
6668 #define TPS_TASK_TIMEOUT 1
6769 #define TPS_TASK_REJECTED 3
6870
71+enum {
72+ TPS_MODE_APP,
73+ TPS_MODE_BOOT,
74+ TPS_MODE_BIST,
75+ TPS_MODE_DISC,
76+};
77+
78+static const char *const modes[] = {
79+ [TPS_MODE_APP] = "APP ",
80+ [TPS_MODE_BOOT] = "BOOT",
81+ [TPS_MODE_BIST] = "BIST",
82+ [TPS_MODE_DISC] = "DISC",
83+};
84+
6985 /* Unrecognized commands will be replaced with "!CMD" */
7086 #define INVALID_CMD(_cmd_) (_cmd_ == 0x444d4321)
7187
@@ -110,6 +126,20 @@ tps6598x_block_read(struct tps6598x *tps, u8 reg, void *val, size_t len) · 38 unmodified lines
110126 return 0;
111127 }
112128
129+static int tps6598x_block_write(struct tps6598x *tps, u8 reg,
130+ void *val, size_t len)
131+{
132+ u8 data[TPS_MAX_LEN + 1];
133+
134+ if (!tps->i2c_protocol)
135+ return regmap_raw_write(tps->regmap, reg, val, len);
136+
137+ data[0] = len;
138+ memcpy(&data[1], val, len);
139+
140+ return regmap_raw_write(tps->regmap, reg, data, sizeof(data));
141+}
142+
113143 static inline int tps6598x_read16(struct tps6598x *tps, u8 reg, u16 *val)
114144 {
115145 return tps6598x_block_read(tps, reg, val, sizeof(u16));
@@ -127,23 +157,23 @@ static inline int tps6598x_read64(struct tps6598x *tps, u8 reg, u64 *val) · 11 unmodified lines
127157
128158 static inline int tps6598x_write16(struct tps6598x *tps, u8 reg, u16 val)
129159 {
130− return regmap_raw_write(tps->regmap, reg, &val, sizeof(u16));
160+ return tps6598x_block_write(tps, reg, &val, sizeof(u16));
131161 }
132162
133163 static inline int tps6598x_write32(struct tps6598x *tps, u8 reg, u32 val)
134164 {
135− return regmap_raw_write(tps->regmap, reg, &val, sizeof(u32));
165+ return tps6598x_block_write(tps, reg, &val, sizeof(u32));
136166 }
137167
138168 static inline int tps6598x_write64(struct tps6598x *tps, u8 reg, u64 val)
139169 {
140− return regmap_raw_write(tps->regmap, reg, &val, sizeof(u64));
170+ return tps6598x_block_write(tps, reg, &val, sizeof(u64));
141171 }
142172
143173 static inline int
144174 tps6598x_write_4cc(struct tps6598x *tps, u8 reg, const char *val)
145175 {
146− return regmap_raw_write(tps->regmap, reg, &val, sizeof(u32));
176+ return tps6598x_block_write(tps, reg, &val, sizeof(u32));
147177 }
148178
149179 static int tps6598x_read_partner_identity(struct tps6598x *tps)
@@ -229,8 +259,8 @@ static int tps6598x_exec_cmd(struct tps6598x *tps, const char *cmd, · 79 unmodified lines
229259 return -EBUSY;
230260
231261 if (in_len) {
232− ret = regmap_raw_write(tps->regmap, TPS_REG_DATA1,
233− in_data, in_len);
262+ ret = tps6598x_block_write(tps, TPS_REG_DATA1,
263+ in_data, in_len);
234264 if (ret)
235265 return ret;
236266 }
@@ -384,6 +414,32 @@ err_unlock: · 147 unmodified lines
384414 return IRQ_HANDLED;
385415 }
386416
417+static int tps6598x_check_mode(struct tps6598x *tps)
418+{
419+ char mode[5] = { };
420+ int ret;
421+
422+ ret = tps6598x_read32(tps, TPS_REG_MODE, (void *)mode);
423+ if (ret)
424+ return ret;
425+
426+ switch (match_string(modes, ARRAY_SIZE(modes), mode)) {
427+ case TPS_MODE_APP:
428+ return 0;
429+ case TPS_MODE_BOOT:
430+ dev_warn(tps->dev, "dead-battery condition\n");
431+ return 0;
432+ case TPS_MODE_BIST:
433+ case TPS_MODE_DISC:
434+ default:
435+ dev_err(tps->dev, "controller in unsupported mode \"%s\"\n",
436+ mode);
437+ break;
438+ }
439+
440+ return -ENODEV;
441+}
442+
387443 static const struct regmap_config tps6598x_regmap_config = {
388444 .reg_bits = 8,
389445 .val_bits = 8,
@@ -409,10 +465,8 @@ static int tps6598x_probe(struct i2c_client *client) · 19 unmodified lines
409465 if (IS_ERR(tps->regmap))
410466 return PTR_ERR(tps->regmap);
411467
412− ret = tps6598x_read32(tps, 0, &vid);
413− if (ret < 0)
414− return ret;
415− if (!vid)
468+ ret = tps6598x_read32(tps, TPS_REG_VID, &vid);
469+ if (ret < 0 || !vid)
416470 return -ENODEV;
417471
418472 /*
@@ -425,6 +479,11 @@ static int tps6598x_probe(struct i2c_client *client) · 6 unmodified lines
425479 if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C))
426480 tps->i2c_protocol = true;
427481
482+ /* Make sure the controller has application firmware running */
483+ ret = tps6598x_check_mode(tps);
484+ if (ret)
485+ return ret;
486+
428487 ret = tps6598x_read32(tps, TPS_REG_STATUS, &status);
429488 if (ret < 0)
430489 return ret;
drivers/usb/typec/ucsi/Kconfig+2−0
@@ -1,3 +1,5 @@
1+# SPDX-License-Identifier: GPL-2.0
2+
13 config TYPEC_UCSI
24 tristate "USB Type-C Connector System Software Interface driver"
35 depends on !CPU_BIG_ENDIAN
drivers/usb/typec/ucsi/debug.h+0−65
@@ -1,65 +0,0 @@
1−/* SPDX-License-Identifier: GPL-2.0 */
2−#ifndef __UCSI_DEBUG_H
3−#define __UCSI_DEBUG_H
4−
5−#include "ucsi.h"
6−
7−static const char * const ucsi_cmd_strs[] = {
8− [0] = "Unknown command",
9− [UCSI_PPM_RESET] = "PPM_RESET",
10− [UCSI_CANCEL] = "CANCEL",
11− [UCSI_CONNECTOR_RESET] = "CONNECTOR_RESET",
12− [UCSI_ACK_CC_CI] = "ACK_CC_CI",
13− [UCSI_SET_NOTIFICATION_ENABLE] = "SET_NOTIFICATION_ENABLE",
14− [UCSI_GET_CAPABILITY] = "GET_CAPABILITY",
15− [UCSI_GET_CONNECTOR_CAPABILITY] = "GET_CONNECTOR_CAPABILITY",
16− [UCSI_SET_UOM] = "SET_UOM",
17− [UCSI_SET_UOR] = "SET_UOR",
18− [UCSI_SET_PDM] = "SET_PDM",
19− [UCSI_SET_PDR] = "SET_PDR",
20− [UCSI_GET_ALTERNATE_MODES] = "GET_ALTERNATE_MODES",
21− [UCSI_GET_CAM_SUPPORTED] = "GET_CAM_SUPPORTED",
22− [UCSI_GET_CURRENT_CAM] = "GET_CURRENT_CAM",
23− [UCSI_SET_NEW_CAM] = "SET_NEW_CAM",
24− [UCSI_GET_PDOS] = "GET_PDOS",
25− [UCSI_GET_CABLE_PROPERTY] = "GET_CABLE_PROPERTY",
26− [UCSI_GET_CONNECTOR_STATUS] = "GET_CONNECTOR_STATUS",
27− [UCSI_GET_ERROR_STATUS] = "GET_ERROR_STATUS",
28−};
29−
30−static inline const char *ucsi_cmd_str(u64 raw_cmd)
31−{
32− u8 cmd = raw_cmd & GENMASK(7, 0);
33−
34− return ucsi_cmd_strs[(cmd >= ARRAY_SIZE(ucsi_cmd_strs)) ? 0 : cmd];
35−}
36−
37−static const char * const ucsi_ack_strs[] = {
38− [0] = "",
39− [UCSI_ACK_EVENT] = "event",
40− [UCSI_ACK_CMD] = "command",
41−};
42−
43−static inline const char *ucsi_ack_str(u8 ack)
44−{
45− return ucsi_ack_strs[(ack >= ARRAY_SIZE(ucsi_ack_strs)) ? 0 : ack];
46−}
47−
48−static inline const char *ucsi_cci_str(u32 cci)
49−{
50− if (cci & GENMASK(7, 0)) {
51− if (cci & BIT(29))
52− return "Event pending (ACK completed)";
53− if (cci & BIT(31))
54− return "Event pending (command completed)";
55− return "Connector Change";
56− }
57− if (cci & BIT(29))
58− return "ACK completed";
59− if (cci & BIT(31))
60− return "Command completed";
61−
62− return "";
63−}
64−
65−#endif /* __UCSI_DEBUG_H */
drivers/usb/typec/ucsi/trace.c+59−0
@@ -1,3 +1,62 @@
11 // SPDX-License-Identifier: GPL-2.0
22 #define CREATE_TRACE_POINTS
3+#include "ucsi.h"
34 #include "trace.h"
5+
6+static const char * const ucsi_cmd_strs[] = {
7+ [0] = "Unknown command",
8+ [UCSI_PPM_RESET] = "PPM_RESET",
9+ [UCSI_CANCEL] = "CANCEL",
10+ [UCSI_CONNECTOR_RESET] = "CONNECTOR_RESET",
11+ [UCSI_ACK_CC_CI] = "ACK_CC_CI",
12+ [UCSI_SET_NOTIFICATION_ENABLE] = "SET_NOTIFICATION_ENABLE",
13+ [UCSI_GET_CAPABILITY] = "GET_CAPABILITY",
14+ [UCSI_GET_CONNECTOR_CAPABILITY] = "GET_CONNECTOR_CAPABILITY",
15+ [UCSI_SET_UOM] = "SET_UOM",
16+ [UCSI_SET_UOR] = "SET_UOR",
17+ [UCSI_SET_PDM] = "SET_PDM",
18+ [UCSI_SET_PDR] = "SET_PDR",
19+ [UCSI_GET_ALTERNATE_MODES] = "GET_ALTERNATE_MODES",
20+ [UCSI_GET_CAM_SUPPORTED] = "GET_CAM_SUPPORTED",
21+ [UCSI_GET_CURRENT_CAM] = "GET_CURRENT_CAM",
22+ [UCSI_SET_NEW_CAM] = "SET_NEW_CAM",
23+ [UCSI_GET_PDOS] = "GET_PDOS",
24+ [UCSI_GET_CABLE_PROPERTY] = "GET_CABLE_PROPERTY",
25+ [UCSI_GET_CONNECTOR_STATUS] = "GET_CONNECTOR_STATUS",
26+ [UCSI_GET_ERROR_STATUS] = "GET_ERROR_STATUS",
27+};
28+
29+const char *ucsi_cmd_str(u64 raw_cmd)
30+{
31+ u8 cmd = raw_cmd & GENMASK(7, 0);
32+
33+ return ucsi_cmd_strs[(cmd >= ARRAY_SIZE(ucsi_cmd_strs)) ? 0 : cmd];
34+}
35+
36+static const char * const ucsi_ack_strs[] = {
37+ [0] = "",
38+ [UCSI_ACK_EVENT] = "event",
39+ [UCSI_ACK_CMD] = "command",
40+};
41+
42+const char *ucsi_ack_str(u8 ack)
43+{
44+ return ucsi_ack_strs[(ack >= ARRAY_SIZE(ucsi_ack_strs)) ? 0 : ack];
45+}
46+
47+const char *ucsi_cci_str(u32 cci)
48+{
49+ if (cci & GENMASK(7, 0)) {
50+ if (cci & BIT(29))
51+ return "Event pending (ACK completed)";
52+ if (cci & BIT(31))
53+ return "Event pending (command completed)";
54+ return "Connector Change";
55+ }
56+ if (cci & BIT(29))
57+ return "ACK completed";
58+ if (cci & BIT(31))
59+ return "Command completed";
60+
61+ return "";
62+}
drivers/usb/typec/ucsi/trace.h+5−2
@@ -7,8 +7,11 @@ · 6 unmodified lines
77 #define __UCSI_TRACE_H
88
99 #include <linux/tracepoint.h>
10−#include "ucsi.h"
11−#include "debug.h"
10+
11+const char *ucsi_cmd_str(u64 raw_cmd);
12+const char *ucsi_ack_str(u8 ack);
13+const char *ucsi_cci_str(u32 cci);
14+const char *ucsi_recipient_str(u8 recipient);
1215
1316 DECLARE_EVENT_CLASS(ucsi_log_ack,
1417 TP_PROTO(u8 ack),
drivers/usb/usbip/Kconfig+2−0
@@ -1,3 +1,5 @@
1+# SPDX-License-Identifier: GPL-2.0
2+
13 config USBIP_CORE
24 tristate "USB/IP support"
35 depends on NET
drivers/usb/usbip/vhci_hcd.c+4−2
@@ -702,8 +702,10 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flag · 701 unmodified lines
702702 }
703703 vdev = &vhci_hcd->vdev[portnum-1];
704704
705− /* patch to usb_sg_init() is in 2.5.60 */
706− BUG_ON(!urb->transfer_buffer && urb->transfer_buffer_length);
705+ if (!urb->transfer_buffer && urb->transfer_buffer_length) {
706+ dev_dbg(dev, "Null URB transfer buffer\n");
707+ return -EINVAL;
708+ }
707709
708710 spin_lock_irqsave(&vhci->lock, flags);
709711
drivers/usb/usbip/vudc_dev.c+2−1
@@ -297,7 +297,8 @@ static void vep_free_request(struct usb_ep *_ep, struct usb_request *_req) · 296 unmodified lines
297297 {
298298 struct vrequest *req;
299299
300− if (WARN_ON(!_ep || !_req))
300+ /* ep is always valid here - see usb_ep_free_request() */
301+ if (!_req)
301302 return;
302303
303304 req = to_vrequest(_req);
drivers/usb/wusbcore/Kconfig+1−0
@@ -1,3 +1,4 @@
1+# SPDX-License-Identifier: GPL-2.0
12 #
23 # Wireless USB Core configuration
34 #
drivers/usb/wusbcore/cbaf.c+4−11
@@ -302,10 +302,8 @@ static ssize_t cbaf_wusb_chid_show(struct device *dev, · 301 unmodified lines
302302 {
303303 struct usb_interface *iface = to_usb_interface(dev);
304304 struct cbaf *cbaf = usb_get_intfdata(iface);
305− char pr_chid[WUSB_CKHDID_STRSIZE];
306305
307− ckhdid_printf(pr_chid, sizeof(pr_chid), &cbaf->chid);
308− return scnprintf(buf, PAGE_SIZE, "%s\n", pr_chid);
306+ return sprintf(buf, "%16ph\n", cbaf->chid.data);
309307 }
310308
311309 static ssize_t cbaf_wusb_chid_store(struct device *dev,
@@ -415,10 +413,8 @@ static ssize_t cbaf_wusb_cdid_show(struct device *dev, · 103 unmodified lines
415413 {
416414 struct usb_interface *iface = to_usb_interface(dev);
417415 struct cbaf *cbaf = usb_get_intfdata(iface);
418− char pr_cdid[WUSB_CKHDID_STRSIZE];
419416
420− ckhdid_printf(pr_cdid, sizeof(pr_cdid), &cbaf->cdid);
421− return scnprintf(buf, PAGE_SIZE, "%s\n", pr_cdid);
417+ return sprintf(buf, "%16ph\n", cbaf->cdid.data);
422418 }
423419
424420 static ssize_t cbaf_wusb_cdid_store(struct device *dev,
@@ -503,7 +499,6 @@ static int cbaf_cc_upload(struct cbaf *cbaf) · 78 unmodified lines
503499 int result;
504500 struct device *dev = &cbaf->usb_iface->dev;
505501 struct wusb_cbaf_cc_data *ccd;
506− char pr_cdid[WUSB_CKHDID_STRSIZE];
507502
508503 ccd = cbaf->buffer;
509504 *ccd = cbaf_cc_data_defaults;
@@ -513,10 +508,8 @@ static int cbaf_cc_upload(struct cbaf *cbaf) · 3 unmodified lines
513508 ccd->BandGroups = cpu_to_le16(cbaf->host_band_groups);
514509
515510 dev_dbg(dev, "Trying to upload CC:\n");
516− ckhdid_printf(pr_cdid, sizeof(pr_cdid), &ccd->CHID);
517− dev_dbg(dev, " CHID %s\n", pr_cdid);
518− ckhdid_printf(pr_cdid, sizeof(pr_cdid), &ccd->CDID);
519− dev_dbg(dev, " CDID %s\n", pr_cdid);
511+ dev_dbg(dev, " CHID %16ph\n", ccd->CHID.data);
512+ dev_dbg(dev, " CDID %16ph\n", ccd->CDID.data);
520513 dev_dbg(dev, " Bandgroups 0x%04x\n", cbaf->host_band_groups);
521514
522515 result = usb_control_msg(
drivers/usb/wusbcore/dev-sysfs.c+2−3
@@ -50,10 +50,9 @@ static ssize_t wusb_cdid_show(struct device *dev, · 49 unmodified lines
5050 wusb_dev = wusb_dev_get_by_usb_dev(to_usb_device(dev));
5151 if (wusb_dev == NULL)
5252 return -ENODEV;
53− result = ckhdid_printf(buf, PAGE_SIZE, &wusb_dev->cdid);
54− strcat(buf, "\n");
53+ result = sprintf(buf, "%16ph\n", wusb_dev->cdid.data);
5554 wusb_dev_put(wusb_dev);
56− return result + 1;
55+ return result;
5756 }
5857 static DEVICE_ATTR_RO(wusb_cdid);
5958
drivers/usb/wusbcore/devconnect.c+1−1
@@ -532,7 +532,7 @@ static void wusbhc_handle_dn_connect(struct wusbhc *wusbhc, · 531 unmodified lines
532532 }
533533
534534 dnc = container_of(dn_hdr, struct wusb_dn_connect, hdr);
535− ckhdid_printf(pr_cdid, sizeof(pr_cdid), &dnc->CDID);
535+ sprintf(pr_cdid, "%16ph", dnc->CDID.data);
536536 dev_info(dev, "DN CONNECT: device %s @ %x (%s) wants to %s\n",
537537 pr_cdid,
538538 wusb_dn_connect_prev_dev_addr(dnc),
drivers/usb/wusbcore/wa-xfer.c+7−8
@@ -662,9 +662,9 @@ static void __wa_setup_isoc_packet_descr( · 661 unmodified lines
662662
663663 /* populate isoc packet descriptor. */
664664 packet_desc->bPacketType = WA_XFER_ISO_PACKET_INFO;
665− packet_desc->wLength = cpu_to_le16(sizeof(*packet_desc) +
666− (sizeof(packet_desc->PacketLength[0]) *
667− seg->isoc_frame_count));
665+ packet_desc->wLength = cpu_to_le16(struct_size(packet_desc,
666+ PacketLength,
667+ seg->isoc_frame_count));
668668 for (frame_index = 0; frame_index < seg->isoc_frame_count;
669669 ++frame_index) {
670670 int offset_index = frame_index + seg->isoc_frame_offset;
@@ -2438,7 +2438,7 @@ static int wa_process_iso_packet_status(struct wahc *wa, struct urb *urb) · 1767 unmodified lines
24382438 struct wa_rpipe *rpipe;
24392439 unsigned done = 0, dti_busy = 0, data_frame_count = 0, seg_index;
24402440 unsigned first_frame_index = 0, rpipe_ready = 0;
2441− int expected_size;
2441+ size_t expected_size;
24422442
24432443 /* We have a xfer result buffer; check it */
24442444 dev_dbg(dev, "DTI: isoc packet status %d bytes at %p\n",
@@ -2460,11 +2460,10 @@ static int wa_process_iso_packet_status(struct wahc *wa, struct urb *urb) · 15 unmodified lines
24602460 goto error_bad_seg;
24612461 seg = xfer->seg[wa->dti_isoc_xfer_seg];
24622462 rpipe = xfer->ep->hcpriv;
2463− expected_size = sizeof(*packet_status) +
2464− (sizeof(packet_status->PacketStatus[0]) *
2465− seg->isoc_frame_count);
2463+ expected_size = struct_size(packet_status, PacketStatus,
2464+ seg->isoc_frame_count);
24662465 if (urb->actual_length != expected_size) {
2467− dev_err(dev, "DTI Error: isoc packet status--bad urb length (%d bytes vs %d needed)\n",
2466+ dev_err(dev, "DTI Error: isoc packet status--bad urb length (%d bytes vs %zu needed)\n",
24682467 urb->actual_length, expected_size);
24692468 goto error_bad_seg;
24702469 }
drivers/usb/wusbcore/wusbhc.c+1−5
@@ -80,17 +80,13 @@ static ssize_t wusb_chid_show(struct device *dev, · 79 unmodified lines
8080 {
8181 struct wusbhc *wusbhc = usbhc_dev_to_wusbhc(dev);
8282 const struct wusb_ckhdid *chid;
83− ssize_t result = 0;
8483
8584 if (wusbhc->wuie_host_info != NULL)
8685 chid = &wusbhc->wuie_host_info->CHID;
8786 else
8887 chid = &wusb_ckhdid_zero;
8988
90− result += ckhdid_printf(buf, PAGE_SIZE, chid);
91− result += sprintf(buf + result, "\n");
92−
93− return result;
89+ return sprintf(buf, "%16ph\n", chid->data);
9490 }
9591
9692 /*
drivers/uwb/drp-ie.c+2−3
@@ -125,9 +125,8 @@ static struct uwb_ie_drp *uwb_drp_ie_alloc(void) · 124 unmodified lines
125125 {
126126 struct uwb_ie_drp *drp_ie;
127127
128− drp_ie = kzalloc(sizeof(struct uwb_ie_drp) +
129− UWB_NUM_ZONES * sizeof(struct uwb_drp_alloc),
130− GFP_KERNEL);
128+ drp_ie = kzalloc(struct_size(drp_ie, allocs, UWB_NUM_ZONES),
129+ GFP_KERNEL);
131130 if (drp_ie)
132131 drp_ie->hdr.element_id = UWB_IE_DRP;
133132 return drp_ie;
include/linux/device.h+6−0
@@ -758,11 +758,17 @@ struct device_dma_parameters { · 757 unmodified lines
758758
759759 /**
760760 * struct device_connection - Device Connection Descriptor
761+ * @fwnode: The device node of the connected device
761762 * @endpoint: The names of the two devices connected together
762763 * @id: Unique identifier for the connection
763764 * @list: List head, private, for internal use only
765+ *
766+ * NOTE: @fwnode is not used together with @endpoint. @fwnode is used when
767+ * platform firmware defines the connection. When the connection is registered
768+ * with device_connection_add() @endpoint is used instead.
764769 */
765770 struct device_connection {
771+ struct fwnode_handle *fwnode;
766772 const char *endpoint[2];
767773 const char *id;
768774 struct list_head list;
include/linux/fsl_devices.h+4−3
@@ -98,10 +98,11 @@ struct fsl_usb2_platform_data { · 97 unmodified lines
9898
9999 unsigned suspended:1;
100100 unsigned already_suspended:1;
101− unsigned has_fsl_erratum_a007792:1;
102− unsigned has_fsl_erratum_a005275:1;
101+ unsigned has_fsl_erratum_a007792:1;
102+ unsigned has_fsl_erratum_14:1;
103+ unsigned has_fsl_erratum_a005275:1;
103104 unsigned has_fsl_erratum_a005697:1;
104− unsigned check_phy_clk_valid:1;
105+ unsigned check_phy_clk_valid:1;
105106
106107 /* register save area for suspend/resume */
107108 u32 pm_command;
include/linux/phy/phy-mipi-dphy.h+6−7
@@ -6,8 +6,6 @@ · 5 unmodified lines
66 #ifndef __PHY_MIPI_DPHY_H_
77 #define __PHY_MIPI_DPHY_H_
88
9−#include <video/videomode.h>
10−
119 /**
1210 * struct phy_configure_opts_mipi_dphy - MIPI D-PHY configuration set
1311 *
@@ -192,10 +190,10 @@ struct phy_configure_opts_mipi_dphy { · 178 unmodified lines
192190 /**
193191 * @init:
194192 *
195− * Time, in picoseconds for the initialization period to
193+ * Time, in microseconds for the initialization period to
196194 * complete.
197195 *
198− * Minimum value: 100000000 ps
196+ * Minimum value: 100 us
199197 */
200198 unsigned int init;
201199
@@ -246,11 +244,11 @@ struct phy_configure_opts_mipi_dphy { · 44 unmodified lines
246244 /**
247245 * @wakeup:
248246 *
249− * Time, in picoseconds, that a transmitter drives a Mark-1
247+ * Time, in microseconds, that a transmitter drives a Mark-1
250248 * state prior to a Stop state in order to initiate an exit
251249 * from ULPS.
252250 *
253− * Minimum value: 1000000000 ps
251+ * Minimum value: 1000 us
254252 */
255253 unsigned int wakeup;
256254
@@ -271,7 +269,8 @@ struct phy_configure_opts_mipi_dphy { · 14 unmodified lines
271269 /**
272270 * @lanes:
273271 *
274− * Number of active data lanes used for the transmissions.
272+ * Number of active, consecutive, data lanes, starting from
273+ * lane 0, used for the transmissions.
275274 */
276275 unsigned char lanes;
277276 };
include/linux/usb/hcd.h+7−3
@@ -72,6 +72,12 @@ struct giveback_urb_bh { · 71 unmodified lines
7272 struct usb_host_endpoint *completing_ep;
7373 };
7474
75+enum usb_dev_authorize_policy {
76+ USB_DEVICE_AUTHORIZE_NONE = 0,
77+ USB_DEVICE_AUTHORIZE_ALL = 1,
78+ USB_DEVICE_AUTHORIZE_INTERNAL = 2,
79+};
80+
7581 struct usb_hcd {
7682
7783 /*
@@ -117,7 +123,6 @@ struct usb_hcd { · 39 unmodified lines
117123 #define HCD_FLAG_RH_RUNNING 5 /* root hub is running? */
118124 #define HCD_FLAG_DEAD 6 /* controller has died? */
119125 #define HCD_FLAG_INTF_AUTHORIZED 7 /* authorize interfaces? */
120−#define HCD_FLAG_DEV_AUTHORIZED 8 /* authorize devices? */
121126
122127 /* The flags can be tested using these macros; they are likely to
123128 * be slightly faster than test_bit().
@@ -142,8 +147,7 @@ struct usb_hcd { · 18 unmodified lines
142147 * or they require explicit user space authorization; this bit is
143148 * settable through /sys/class/usb_host/X/authorized_default
144149 */
145−#define HCD_DEV_AUTHORIZED(hcd) \
146− ((hcd)->flags & (1U << HCD_FLAG_DEV_AUTHORIZED))
150+ enum usb_dev_authorize_policy dev_policy;
147151
148152 /* Flags that get set only during HCD registration or removal. */
149153 unsigned rh_registered:1;/* is root hub registered? */
include/linux/usb/role.h+2−0
@@ -18,6 +18,7 @@ typedef enum usb_role (*usb_role_switch_get_t)(struct device *dev); · 17 unmodified lines
1818
1919 /**
2020 * struct usb_role_switch_desc - USB Role Switch Descriptor
21+ * @fwnode: The device node to be associated with the role switch
2122 * @usb2_port: Optional reference to the host controller port device (USB2)
2223 * @usb3_port: Optional reference to the host controller port device (USB3)
2324 * @udc: Optional reference to the peripheral controller device
@@ -32,6 +33,7 @@ typedef enum usb_role (*usb_role_switch_get_t)(struct device *dev); · 8 unmodified lines
3233 * usb_role_switch_register() before registering the switch.
3334 */
3435 struct usb_role_switch_desc {
36+ struct fwnode_handle *fwnode;
3537 struct device *usb2_port;
3638 struct device *usb3_port;
3739 struct device *udc;
include/linux/usb/tcpm.h+0−6
@@ -159,12 +159,6 @@ struct tcpm_port; · 158 unmodified lines
159159 struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc);
160160 void tcpm_unregister_port(struct tcpm_port *port);
161161
162−int tcpm_update_source_capabilities(struct tcpm_port *port, const u32 *pdo,
163− unsigned int nr_pdo);
164−int tcpm_update_sink_capabilities(struct tcpm_port *port, const u32 *pdo,
165− unsigned int nr_pdo,
166− unsigned int operating_snk_mw);
167−
168162 void tcpm_vbus_change(struct tcpm_port *port);
169163 void tcpm_cc_change(struct tcpm_port *port);
170164 void tcpm_pd_receive(struct tcpm_port *port,
include/linux/usb/typec_dp.h+4−0
@@ -92,4 +92,8 @@ enum { · 91 unmodified lines
9292 #define DP_CONF_PIN_ASSIGNEMENT_SHIFT 8
9393 #define DP_CONF_PIN_ASSIGNEMENT_MASK GENMASK(15, 8)
9494
95+/* Helper for setting/getting the pin assignement value to the configuration */
96+#define DP_CONF_SET_PIN_ASSIGN(_a_) ((_a_) << 8)
97+#define DP_CONF_GET_PIN_ASSIGN(_conf_) (((_conf_) & GENMASK(15, 8)) >> 8)
98+
9599 #endif /* __USB_TYPEC_DP_H */
include/linux/usb/typec_mux.h+2−1
@@ -47,7 +47,8 @@ void typec_switch_put(struct typec_switch *sw); · 46 unmodified lines
4747 int typec_switch_register(struct typec_switch *sw);
4848 void typec_switch_unregister(struct typec_switch *sw);
4949
50−struct typec_mux *typec_mux_get(struct device *dev, const char *name);
50+struct typec_mux *
51+typec_mux_get(struct device *dev, const struct typec_altmode_desc *desc);
5152 void typec_mux_put(struct typec_mux *mux);
5253 int typec_mux_register(struct typec_mux *mux);
5354 void typec_mux_unregister(struct typec_mux *mux);
include/linux/usb/wusb.h+0−16
@@ -236,22 +236,6 @@ enum { · 235 unmodified lines
236236 WUSB_TRUST_TIMEOUT_MS = 4000, /* [WUSB] section 4.15.1 */
237237 };
238238
239−static inline size_t ckhdid_printf(char *pr_ckhdid, size_t size,
240− const struct wusb_ckhdid *ckhdid)
241−{
242− return scnprintf(pr_ckhdid, size,
243− "%02hx %02hx %02hx %02hx %02hx %02hx %02hx %02hx "
244− "%02hx %02hx %02hx %02hx %02hx %02hx %02hx %02hx",
245− ckhdid->data[0], ckhdid->data[1],
246− ckhdid->data[2], ckhdid->data[3],
247− ckhdid->data[4], ckhdid->data[5],
248− ckhdid->data[6], ckhdid->data[7],
249− ckhdid->data[8], ckhdid->data[9],
250− ckhdid->data[10], ckhdid->data[11],
251− ckhdid->data[12], ckhdid->data[13],
252− ckhdid->data[14], ckhdid->data[15]);
253−}
254−
255239 /*
256240 * WUSB Crypto stuff (WUSB1.0[6])
257241 */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t