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

Merge tag 'usb-5.3-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 and PHY driver pull request for 5.3-rc1.

Lots of stuff here, all of which has been in linux-next for a while
with no reported issues. Nothing is earth-shattering, just constant
forward progress for more devices supported and cleanups and small
fixes:

- USB gadget driver updates and fixes

- new USB gadget driver for some hardware, followed by a quick revert
of those patches as they were not ready to be merged...

- PHY driver updates

- Lots of new driver additions and cleanups with a few fixes mixed
in"

* tag 'usb-5.3-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (145 commits)
Revert "usb: gadget: storage: Remove warning message"
Revert "dt-bindings: add binding for USBSS-DRD controller."
Revert "usb:gadget Separated decoding functions from dwc3 driver."
Revert "usb:gadget Patch simplify usb_decode_set_clear_feature function."
Revert "usb:gadget Simplify usb_decode_get_set_descriptor function."
Revert "usb:cdns3 Add Cadence USB3 DRD Driver"
Revert "usb:cdns3 Fix for stuck packets in on-chip OUT buffer."
usb :fsl: Change string format for errata property
usb: host: Stops USB controller init if PLL fails to lock
usb: linux/fsl_device: Add platform member has_fsl_erratum_a006918
usb: phy: Workaround for USB erratum-A005728
usb: fsl: Set USB_EN bit to select ULPI phy
usb: Handle USB3 remote wakeup for LPM enabled devices correctly
drivers/usb/typec/tps6598x.c: fix 4CC cmd write
drivers/usb/typec/tps6598x.c: fix portinfo width
usb: storage: scsiglue: Do not skip VPD if try_vpd_pages is set
usb: renesas_usbhs: add a workaround for a race condition of workqueue
usb: gadget: udc: renesas_usb3: remove redundant assignment to ret
usb: dwc2: use a longer AHB idle timeout in dwc2_core_reset()
USB: gadget: function: fix issue Unneeded variable: "value"
...

+2348 -750
+29
Documentation/devicetree/bindings/phy/mixel,mipi-dsi-phy.txt
··· 1 + Mixel DSI PHY for i.MX8 2 + 3 + The Mixel MIPI-DSI PHY IP block is e.g. found on i.MX8 platforms (along the 4 + MIPI-DSI IP from Northwest Logic). It represents the physical layer for the 5 + electrical signals for DSI. 6 + 7 + Required properties: 8 + - compatible: Must be: 9 + - "fsl,imx8mq-mipi-dphy" 10 + - clocks: Must contain an entry for each entry in clock-names. 11 + - clock-names: Must contain the following entries: 12 + - "phy_ref": phandle and specifier referring to the DPHY ref clock 13 + - reg: the register range of the PHY controller 14 + - #phy-cells: number of cells in PHY, as defined in 15 + Documentation/devicetree/bindings/phy/phy-bindings.txt 16 + this must be <0> 17 + 18 + Optional properties: 19 + - power-domains: phandle to power domain 20 + 21 + Example: 22 + dphy: dphy@30a0030 { 23 + compatible = "fsl,imx8mq-mipi-dphy"; 24 + clocks = <&clk IMX8MQ_CLK_DSI_PHY_REF>; 25 + clock-names = "phy_ref"; 26 + reg = <0x30a00300 0x100>; 27 + power-domains = <&pd_mipi0>; 28 + #phy-cells = <0>; 29 + };
+2 -1
Documentation/devicetree/bindings/phy/mxs-usb-phy.txt
··· 7 7 * "fsl,imx6sl-usbphy" for imx6sl 8 8 * "fsl,vf610-usbphy" for Vybrid vf610 9 9 * "fsl,imx6sx-usbphy" for imx6sx 10 + * "fsl,imx7ulp-usbphy" for imx7ulp 10 11 "fsl,imx23-usbphy" is still a fallback for other strings 11 12 - reg: Should contain registers location and length 12 13 - interrupts: Should contain phy interrupt ··· 24 23 the 17.78mA TX reference current. Default: 100 25 24 26 25 Example: 27 - usbphy1: usbphy@20c9000 { 26 + usbphy1: usb-phy@20c9000 { 28 27 compatible = "fsl,imx6q-usbphy", "fsl,imx23-usbphy"; 29 28 reg = <0x020c9000 0x1000>; 30 29 interrupts = <0 44 0x04>;
+12
Documentation/devicetree/bindings/phy/nvidia,tegra124-xusb-padctl.txt
··· 42 42 - reset-names: Must include the following entries: 43 43 - "padctl" 44 44 45 + For Tegra124: 46 + - avdd-pll-utmip-supply: UTMI PLL power supply. Must supply 1.8 V. 47 + - avdd-pll-erefe-supply: PLLE reference PLL power supply. Must supply 1.05 V. 48 + - avdd-pex-pll-supply: PCIe/USB3 PLL power supply. Must supply 1.05 V. 49 + - hvdd-pex-pll-e-supply: High-voltage PLLE power supply. Must supply 3.3 V. 50 + 51 + For Tegra210: 52 + - avdd-pll-utmip-supply: UTMI PLL power supply. Must supply 1.8 V. 53 + - avdd-pll-uerefe-supply: PLLE reference PLL power supply. Must supply 1.05 V. 54 + - dvdd-pex-pll-supply: PCIe/USB3 PLL power supply. Must supply 1.05 V. 55 + - hvdd-pex-pll-e-supply: High-voltage PLLE power supply. Must supply 1.8 V. 56 + 45 57 For Tegra186: 46 58 - avdd-pll-erefeut-supply: UPHY brick and reference clock as well as UTMI PHY 47 59 power supply. Must supply 1.8 V.
+18
Documentation/devicetree/bindings/phy/phy-pxa-usb.txt
··· 1 + Marvell PXA USB PHY 2 + ------------------- 3 + 4 + Required properties: 5 + - compatible: one of: "marvell,mmp2-usb-phy", "marvell,pxa910-usb-phy", 6 + "marvell,pxa168-usb-phy", 7 + - #phy-cells: must be 0 8 + 9 + Example: 10 + usb-phy: usbphy@d4207000 { 11 + compatible = "marvell,mmp2-usb-phy"; 12 + reg = <0xd4207000 0x40>; 13 + #phy-cells = <0>; 14 + status = "okay"; 15 + }; 16 + 17 + This document explains the device tree binding. For general 18 + information about PHY subsystem refer to Documentation/phy.txt
+42
Documentation/devicetree/bindings/phy/qcom-pcie2-phy.txt
··· 1 + Qualcomm PCIe2 PHY controller 2 + ============================= 3 + 4 + The Qualcomm PCIe2 PHY is a Synopsys based phy found in a number of Qualcomm 5 + platforms. 6 + 7 + Required properties: 8 + - compatible: compatible list, should be: 9 + "qcom,qcs404-pcie2-phy", "qcom,pcie2-phy" 10 + 11 + - reg: offset and length of the PHY register set. 12 + - #phy-cells: must be 0. 13 + 14 + - clocks: a clock-specifier pair for the "pipe" clock 15 + 16 + - vdda-vp-supply: phandle to low voltage regulator 17 + - vdda-vph-supply: phandle to high voltage regulator 18 + 19 + - resets: reset-specifier pairs for the "phy" and "pipe" resets 20 + - reset-names: list of resets, should contain: 21 + "phy" and "pipe" 22 + 23 + - clock-output-names: name of the outgoing clock signal from the PHY PLL 24 + - #clock-cells: must be 0 25 + 26 + Example: 27 + phy@7786000 { 28 + compatible = "qcom,qcs404-pcie2-phy", "qcom,pcie2-phy"; 29 + reg = <0x07786000 0xb8>; 30 + 31 + clocks = <&gcc GCC_PCIE_0_PIPE_CLK>; 32 + resets = <&gcc GCC_PCIEPHY_0_PHY_BCR>, 33 + <&gcc GCC_PCIE_0_PIPE_ARES>; 34 + reset-names = "phy", "pipe"; 35 + 36 + vdda-vp-supply = <&vreg_l3_1p05>; 37 + vdda-vph-supply = <&vreg_l5_1p8>; 38 + 39 + clock-output-names = "pcie_0_pipe_clk"; 40 + #clock-cells = <0>; 41 + #phy-cells = <0>; 42 + };
+9 -4
Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb2.txt
··· 1 1 * Renesas R-Car generation 3 USB 2.0 PHY 2 2 3 3 This file provides information on what the device node for the R-Car generation 4 - 3, RZ/G1C and RZ/G2 USB 2.0 PHY contain. 4 + 3, RZ/G1C, RZ/G2 and RZ/A2 USB 2.0 PHY contain. 5 5 6 6 Required properties: 7 - - compatible: "renesas,usb2-phy-r8a77470" if the device is a part of an R8A77470 7 + - compatible: "renesas,usb2-phy-r7s9210" if the device is a part of an R7S9210 8 + SoC. 9 + "renesas,usb2-phy-r8a77470" if the device is a part of an R8A77470 8 10 SoC. 9 11 "renesas,usb2-phy-r8a774a1" if the device is a part of an R8A774A1 10 12 SoC. ··· 22 20 R8A77990 SoC. 23 21 "renesas,usb2-phy-r8a77995" if the device is a part of an 24 22 R8A77995 SoC. 25 - "renesas,rcar-gen3-usb2-phy" for a generic R-Car Gen3 or RZ/G2 26 - compatible device. 23 + "renesas,rcar-gen3-usb2-phy" for a generic R-Car Gen3, RZ/G2 or 24 + RZ/A2 compatible device. 27 25 28 26 When compatible with the generic version, nodes must list the 29 27 SoC-specific version corresponding to the platform first ··· 48 46 regulator will be managed during the PHY power on/off sequence. 49 47 - renesas,no-otg-pins: boolean, specify when a board does not provide proper 50 48 otg pins. 49 + - dr_mode: string, indicates the working mode for the PHY. Can be "host", 50 + "peripheral", or "otg". Should be set if otg controller is not used. 51 + 51 52 52 53 Example (R-Car H3): 53 54
+3
Documentation/devicetree/bindings/usb/dwc2.txt
··· 42 42 - g-rx-fifo-size: size of rx fifo size in gadget mode. 43 43 - g-np-tx-fifo-size: size of non-periodic tx fifo size in gadget mode. 44 44 - g-tx-fifo-size: size of periodic tx fifo per endpoint (except ep0) in gadget mode. 45 + - snps,need-phy-for-wake: If present indicates that the phy needs to be left 46 + on for remote wakeup during suspend. 45 47 - snps,reset-phy-on-wake: If present indicates that we need to reset the PHY when 46 48 we detect a wakeup. This is due to a hardware errata. 47 49 ··· 60 58 clock-names = "otg"; 61 59 phys = <&usbphy>; 62 60 phy-names = "usb2-phy"; 61 + snps,need-phy-for-wake; 63 62 };
+2
Documentation/devicetree/bindings/usb/dwc3.txt
··· 64 64 - snps,dis_u2_susphy_quirk: when set core will disable USB2 suspend phy. 65 65 - snps,dis_enblslpm_quirk: when set clears the enblslpm in GUSB2PHYCFG, 66 66 disabling the suspend signal to the PHY. 67 + - snps,dis-u1-entry-quirk: set if link entering into U1 needs to be disabled. 68 + - snps,dis-u2-entry-quirk: set if link entering into U2 needs to be disabled. 67 69 - snps,dis_rxdet_inp3_quirk: when set core will disable receiver detection 68 70 in PHY P3 power state. 69 71 - snps,dis-u2-freeclk-exists-quirk: when set, clear the u2_freeclk_exists
Documentation/devicetree/bindings/usb/renesas_usb3.txt Documentation/devicetree/bindings/usb/renesas,usb3.txt
+2
Documentation/devicetree/bindings/usb/renesas_usbhs.txt Documentation/devicetree/bindings/usb/renesas,usbhs.txt
··· 20 20 - "renesas,usbhs-r8a77990" for r8a77990 (R-Car E3) compatible device 21 21 - "renesas,usbhs-r8a77995" for r8a77995 (R-Car D3) compatible device 22 22 - "renesas,usbhs-r7s72100" for r7s72100 (RZ/A1) compatible device 23 + - "renesas,usbhs-r7s9210" for r7s9210 (RZ/A2) compatible device 23 24 - "renesas,rcar-gen2-usbhs" for R-Car Gen2 or RZ/G1 compatible devices 24 25 - "renesas,rcar-gen3-usbhs" for R-Car Gen3 or RZ/G2 compatible devices 25 26 - "renesas,rza1-usbhs" for RZ/A1 compatible device 27 + - "renesas,rza2-usbhs" for RZ/A2 compatible device 26 28 27 29 When compatible with the generic version, nodes must list the 28 30 SoC-specific version corresponding to the platform first followed
+1
Documentation/index.rst
··· 101 101 filesystems/index 102 102 vm/index 103 103 bpf/index 104 + usb/index 104 105 misc-devices/index 105 106 106 107 Architecture-specific documentation
Documentation/usb/WUSB-Design-overview.txt Documentation/usb/wusb-design-overview.rst
Documentation/usb/acm.txt Documentation/usb/acm.rst
Documentation/usb/authorization.txt Documentation/usb/authorization.rst
Documentation/usb/chipidea.txt Documentation/usb/chipidea.rst
Documentation/usb/dwc3.txt Documentation/usb/dwc3.rst
Documentation/usb/ehci.txt Documentation/usb/ehci.rst
Documentation/usb/functionfs.txt Documentation/usb/functionfs.rst
+2 -2
Documentation/usb/gadget-testing.txt Documentation/usb/gadget-testing.rst
··· 254 254 - connect the gadget to a host, preferably not the one used 255 255 to control the gadget 256 256 - run a program which writes to /dev/hidg<N>, e.g. 257 - a userspace program found in Documentation/usb/gadget_hid.txt:: 257 + a userspace program found in Documentation/usb/gadget_hid.rst:: 258 258 259 259 $ ./hid_gadget_test /dev/hidg0 keyboard 260 260 ··· 886 886 # cat /dev/usb/lp0 887 887 888 888 More advanced testing can be done with the prn_example 889 - described in Documentation/usb/gadget_printer.txt. 889 + described in Documentation/usb/gadget_printer.rst. 890 890 891 891 892 892 20. UAC1 function (virtual ALSA card, using u_audio API)
Documentation/usb/gadget_configfs.txt Documentation/usb/gadget_configfs.rst
Documentation/usb/gadget_hid.txt Documentation/usb/gadget_hid.rst
Documentation/usb/gadget_multi.txt Documentation/usb/gadget_multi.rst
Documentation/usb/gadget_printer.txt Documentation/usb/gadget_printer.rst
Documentation/usb/gadget_serial.txt Documentation/usb/gadget_serial.rst
+39
Documentation/usb/index.rst
··· 1 + =========== 2 + USB support 3 + =========== 4 + 5 + .. toctree:: 6 + :maxdepth: 1 7 + 8 + acm 9 + authorization 10 + chipidea 11 + dwc3 12 + ehci 13 + functionfs 14 + gadget_configfs 15 + gadget_hid 16 + gadget_multi 17 + gadget_printer 18 + gadget_serial 19 + gadget-testing 20 + iuu_phoenix 21 + mass-storage 22 + misc_usbsevseg 23 + mtouchusb 24 + ohci 25 + rio 26 + usbip_protocol 27 + usbmon 28 + usb-serial 29 + wusb-design-overview 30 + 31 + usb-help 32 + text_files 33 + 34 + .. only:: subproject and html 35 + 36 + Indices 37 + ======= 38 + 39 + * :ref:`genindex`
Documentation/usb/iuu_phoenix.txt Documentation/usb/iuu_phoenix.rst
Documentation/usb/mass-storage.txt Documentation/usb/mass-storage.rst
Documentation/usb/misc_usbsevseg.txt Documentation/usb/misc_usbsevseg.rst
Documentation/usb/mtouchusb.txt Documentation/usb/mtouchusb.rst
Documentation/usb/ohci.txt Documentation/usb/ohci.rst
Documentation/usb/rio.txt Documentation/usb/rio.rst
+29
Documentation/usb/text_files.rst
··· 1 + Linux CDC ACM inf 2 + ----------------- 3 + 4 + .. include:: linux-cdc-acm.inf 5 + :literal: 6 + 7 + Linux inf 8 + --------- 9 + 10 + .. include:: linux.inf 11 + :literal: 12 + 13 + USB devfs drop permissions source 14 + --------------------------------- 15 + 16 + .. literalinclude:: usbdevfs-drop-permissions.c 17 + :language: c 18 + 19 + WUSB command line script to manipulate auth credentials 20 + ------------------------------------------------------- 21 + 22 + .. literalinclude:: wusb-cbaf 23 + :language: shell 24 + 25 + Credits 26 + ------- 27 + 28 + .. include:: CREDITS 29 + :literal:
Documentation/usb/usb-help.txt Documentation/usb/usb-help.rst
Documentation/usb/usb-serial.txt Documentation/usb/usb-serial.rst
Documentation/usb/usbip_protocol.txt Documentation/usb/usbip_protocol.rst
Documentation/usb/usbmon.txt Documentation/usb/usbmon.rst
+6 -6
MAINTAINERS
··· 3792 3792 CERTIFIED WIRELESS USB (WUSB) SUBSYSTEM: 3793 3793 L: linux-usb@vger.kernel.org 3794 3794 S: Orphan 3795 - F: Documentation/usb/WUSB-Design-overview.txt 3795 + F: Documentation/usb/wusb-design-overview.rst 3796 3796 F: Documentation/usb/wusb-cbaf 3797 3797 F: drivers/usb/host/hwa-hc.c 3798 3798 F: drivers/usb/host/whci/ ··· 16422 16422 M: Oliver Neukum <oneukum@suse.com> 16423 16423 L: linux-usb@vger.kernel.org 16424 16424 S: Maintained 16425 - F: Documentation/usb/acm.txt 16425 + F: Documentation/usb/acm.rst 16426 16426 F: drivers/usb/class/cdc-acm.* 16427 16427 16428 16428 USB AR5523 WIRELESS DRIVER ··· 16475 16475 M: Alan Stern <stern@rowland.harvard.edu> 16476 16476 L: linux-usb@vger.kernel.org 16477 16477 S: Maintained 16478 - F: Documentation/usb/ehci.txt 16478 + F: Documentation/usb/ehci.rst 16479 16479 F: drivers/usb/host/ehci* 16480 16480 16481 16481 USB GADGET/PERIPHERAL SUBSYSTEM ··· 16549 16549 M: Alan Stern <stern@rowland.harvard.edu> 16550 16550 L: linux-usb@vger.kernel.org 16551 16551 S: Maintained 16552 - F: Documentation/usb/ohci.txt 16552 + F: Documentation/usb/ohci.rst 16553 16553 F: drivers/usb/host/ohci* 16554 16554 16555 16555 USB OTG FSM (Finite State Machine) ··· 16565 16565 M: Shuah Khan <skhan@linuxfoundation.org> 16566 16566 L: linux-usb@vger.kernel.org 16567 16567 S: Maintained 16568 - F: Documentation/usb/usbip_protocol.txt 16568 + F: Documentation/usb/usbip_protocol.rst 16569 16569 F: drivers/usb/usbip/ 16570 16570 F: tools/usb/usbip/ 16571 16571 F: tools/testing/selftests/drivers/usb/usbip/ ··· 16613 16613 L: linux-usb@vger.kernel.org 16614 16614 T: git git://git.kernel.org/pub/scm/linux/kernel/git/johan/usb-serial.git 16615 16615 S: Maintained 16616 - F: Documentation/usb/usb-serial.txt 16616 + F: Documentation/usb/usb-serial.rst 16617 16617 F: drivers/usb/serial/ 16618 16618 F: include/linux/usb/serial.h 16619 16619
+2
arch/arm/boot/dts/rk3288-veyron.dtsi
··· 424 424 425 425 &usb_host1 { 426 426 status = "okay"; 427 + snps,need-phy-for-wake; 427 428 }; 428 429 429 430 &usb_otg { ··· 433 432 assigned-clocks = <&cru SCLK_USBPHY480M_SRC>; 434 433 assigned-clock-parents = <&usbphy0>; 435 434 dr_mode = "host"; 435 + snps,need-phy-for-wake; 436 436 }; 437 437 438 438 &vopb {
+1
crypto/ccm.c
··· 1009 1009 MODULE_ALIAS_CRYPTO("ccm_base"); 1010 1010 MODULE_ALIAS_CRYPTO("rfc4309"); 1011 1011 MODULE_ALIAS_CRYPTO("ccm"); 1012 + MODULE_ALIAS_CRYPTO("cbcmac");
+1 -1
drivers/phy/amlogic/phy-meson-g12a-usb3-pcie.c
··· 188 188 .reg_read = phy_g12a_usb3_pcie_cr_bus_read, 189 189 .reg_write = phy_g12a_usb3_pcie_cr_bus_write, 190 190 .max_register = 0xffff, 191 - .fast_io = true, 191 + .disable_locking = true, 192 192 }; 193 193 194 194 static int phy_g12a_usb3_init(struct phy *phy)
+8 -1
drivers/phy/broadcom/phy-brcm-usb.c
··· 368 368 return PTR_ERR_OR_ZERO(phy_provider); 369 369 } 370 370 371 + static int brcm_usb_phy_remove(struct platform_device *pdev) 372 + { 373 + sysfs_remove_group(&pdev->dev.kobj, &brcm_usb_phy_group); 374 + 375 + return 0; 376 + } 377 + 371 378 #ifdef CONFIG_PM_SLEEP 372 379 static int brcm_usb_phy_suspend(struct device *dev) 373 380 { ··· 440 433 441 434 static struct platform_driver brcm_usb_driver = { 442 435 .probe = brcm_usb_phy_probe, 436 + .remove = brcm_usb_phy_remove, 443 437 .driver = { 444 438 .name = "brcmstb-usb-phy", 445 - .owner = THIS_MODULE, 446 439 .pm = &brcm_usb_phy_pm_ops, 447 440 .of_match_table = brcm_usb_dt_ids, 448 441 },
+10
drivers/phy/freescale/Kconfig
··· 4 4 depends on OF && HAS_IOMEM 5 5 select GENERIC_PHY 6 6 default ARCH_MXC && ARM64 7 + 8 + config PHY_MIXEL_MIPI_DPHY 9 + tristate "Mixel MIPI DSI PHY support" 10 + depends on OF && HAS_IOMEM 11 + select GENERIC_PHY 12 + select GENERIC_PHY_MIPI_DPHY 13 + select REGMAP_MMIO 14 + help 15 + Enable this to add support for the Mixel DSI PHY as found 16 + on NXP's i.MX8 family of SOCs.
+1
drivers/phy/freescale/Makefile
··· 1 1 # SPDX-License-Identifier: GPL-2.0-only 2 2 obj-$(CONFIG_PHY_FSL_IMX8MQ_USB) += phy-fsl-imx8mq-usb.o 3 + obj-$(CONFIG_PHY_MIXEL_MIPI_DPHY) += phy-fsl-imx8-mipi-dphy.o
+497
drivers/phy/freescale/phy-fsl-imx8-mipi-dphy.c
··· 1 + // SPDX-License-Identifier: GPL-2.0+ 2 + /* 3 + * Copyright 2017,2018 NXP 4 + * Copyright 2019 Purism SPC 5 + */ 6 + 7 + #include <linux/clk.h> 8 + #include <linux/clk-provider.h> 9 + #include <linux/delay.h> 10 + #include <linux/io.h> 11 + #include <linux/kernel.h> 12 + #include <linux/module.h> 13 + #include <linux/of.h> 14 + #include <linux/of_platform.h> 15 + #include <linux/phy/phy.h> 16 + #include <linux/platform_device.h> 17 + #include <linux/regmap.h> 18 + 19 + /* DPHY registers */ 20 + #define DPHY_PD_DPHY 0x00 21 + #define DPHY_M_PRG_HS_PREPARE 0x04 22 + #define DPHY_MC_PRG_HS_PREPARE 0x08 23 + #define DPHY_M_PRG_HS_ZERO 0x0c 24 + #define DPHY_MC_PRG_HS_ZERO 0x10 25 + #define DPHY_M_PRG_HS_TRAIL 0x14 26 + #define DPHY_MC_PRG_HS_TRAIL 0x18 27 + #define DPHY_PD_PLL 0x1c 28 + #define DPHY_TST 0x20 29 + #define DPHY_CN 0x24 30 + #define DPHY_CM 0x28 31 + #define DPHY_CO 0x2c 32 + #define DPHY_LOCK 0x30 33 + #define DPHY_LOCK_BYP 0x34 34 + #define DPHY_REG_BYPASS_PLL 0x4C 35 + 36 + #define MBPS(x) ((x) * 1000000) 37 + 38 + #define DATA_RATE_MAX_SPEED MBPS(1500) 39 + #define DATA_RATE_MIN_SPEED MBPS(80) 40 + 41 + #define PLL_LOCK_SLEEP 10 42 + #define PLL_LOCK_TIMEOUT 1000 43 + 44 + #define CN_BUF 0xcb7a89c0 45 + #define CO_BUF 0x63 46 + #define CM(x) ( \ 47 + ((x) < 32) ? 0xe0 | ((x) - 16) : \ 48 + ((x) < 64) ? 0xc0 | ((x) - 32) : \ 49 + ((x) < 128) ? 0x80 | ((x) - 64) : \ 50 + ((x) - 128)) 51 + #define CN(x) (((x) == 1) ? 0x1f : (((CN_BUF) >> ((x) - 1)) & 0x1f)) 52 + #define CO(x) ((CO_BUF) >> (8 - (x)) & 0x03) 53 + 54 + /* PHY power on is active low */ 55 + #define PWR_ON 0 56 + #define PWR_OFF 1 57 + 58 + enum mixel_dphy_devtype { 59 + MIXEL_IMX8MQ, 60 + }; 61 + 62 + struct mixel_dphy_devdata { 63 + u8 reg_tx_rcal; 64 + u8 reg_auto_pd_en; 65 + u8 reg_rxlprp; 66 + u8 reg_rxcdrp; 67 + u8 reg_rxhs_settle; 68 + }; 69 + 70 + static const struct mixel_dphy_devdata mixel_dphy_devdata[] = { 71 + [MIXEL_IMX8MQ] = { 72 + .reg_tx_rcal = 0x38, 73 + .reg_auto_pd_en = 0x3c, 74 + .reg_rxlprp = 0x40, 75 + .reg_rxcdrp = 0x44, 76 + .reg_rxhs_settle = 0x48, 77 + }, 78 + }; 79 + 80 + struct mixel_dphy_cfg { 81 + /* DPHY PLL parameters */ 82 + u32 cm; 83 + u32 cn; 84 + u32 co; 85 + /* DPHY register values */ 86 + u8 mc_prg_hs_prepare; 87 + u8 m_prg_hs_prepare; 88 + u8 mc_prg_hs_zero; 89 + u8 m_prg_hs_zero; 90 + u8 mc_prg_hs_trail; 91 + u8 m_prg_hs_trail; 92 + u8 rxhs_settle; 93 + }; 94 + 95 + struct mixel_dphy_priv { 96 + struct mixel_dphy_cfg cfg; 97 + struct regmap *regmap; 98 + struct clk *phy_ref_clk; 99 + const struct mixel_dphy_devdata *devdata; 100 + }; 101 + 102 + static const struct regmap_config mixel_dphy_regmap_config = { 103 + .reg_bits = 8, 104 + .val_bits = 32, 105 + .reg_stride = 4, 106 + .max_register = DPHY_REG_BYPASS_PLL, 107 + .name = "mipi-dphy", 108 + }; 109 + 110 + static int phy_write(struct phy *phy, u32 value, unsigned int reg) 111 + { 112 + struct mixel_dphy_priv *priv = phy_get_drvdata(phy); 113 + int ret; 114 + 115 + ret = regmap_write(priv->regmap, reg, value); 116 + if (ret < 0) 117 + dev_err(&phy->dev, "Failed to write DPHY reg %d: %d\n", reg, 118 + ret); 119 + return ret; 120 + } 121 + 122 + /* 123 + * Find a ratio close to the desired one using continued fraction 124 + * approximation ending either at exact match or maximum allowed 125 + * nominator, denominator. 126 + */ 127 + static void get_best_ratio(u32 *pnum, u32 *pdenom, u32 max_n, u32 max_d) 128 + { 129 + u32 a = *pnum; 130 + u32 b = *pdenom; 131 + u32 c; 132 + u32 n[] = {0, 1}; 133 + u32 d[] = {1, 0}; 134 + u32 whole; 135 + unsigned int i = 1; 136 + 137 + while (b) { 138 + i ^= 1; 139 + whole = a / b; 140 + n[i] += (n[i ^ 1] * whole); 141 + d[i] += (d[i ^ 1] * whole); 142 + if ((n[i] > max_n) || (d[i] > max_d)) { 143 + i ^= 1; 144 + break; 145 + } 146 + c = a - (b * whole); 147 + a = b; 148 + b = c; 149 + } 150 + *pnum = n[i]; 151 + *pdenom = d[i]; 152 + } 153 + 154 + static int mixel_dphy_config_from_opts(struct phy *phy, 155 + struct phy_configure_opts_mipi_dphy *dphy_opts, 156 + struct mixel_dphy_cfg *cfg) 157 + { 158 + struct mixel_dphy_priv *priv = dev_get_drvdata(phy->dev.parent); 159 + unsigned long ref_clk = clk_get_rate(priv->phy_ref_clk); 160 + u32 lp_t, numerator, denominator; 161 + unsigned long long tmp; 162 + u32 n; 163 + int i; 164 + 165 + if (dphy_opts->hs_clk_rate > DATA_RATE_MAX_SPEED || 166 + dphy_opts->hs_clk_rate < DATA_RATE_MIN_SPEED) 167 + return -EINVAL; 168 + 169 + numerator = dphy_opts->hs_clk_rate; 170 + denominator = ref_clk; 171 + get_best_ratio(&numerator, &denominator, 255, 256); 172 + if (!numerator || !denominator) { 173 + dev_err(&phy->dev, "Invalid %d/%d for %ld/%ld\n", 174 + numerator, denominator, 175 + dphy_opts->hs_clk_rate, ref_clk); 176 + return -EINVAL; 177 + } 178 + 179 + while ((numerator < 16) && (denominator <= 128)) { 180 + numerator <<= 1; 181 + denominator <<= 1; 182 + } 183 + /* 184 + * CM ranges between 16 and 255 185 + * CN ranges between 1 and 32 186 + * CO is power of 2: 1, 2, 4, 8 187 + */ 188 + i = __ffs(denominator); 189 + if (i > 3) 190 + i = 3; 191 + cfg->cn = denominator >> i; 192 + cfg->co = 1 << i; 193 + cfg->cm = numerator; 194 + 195 + if (cfg->cm < 16 || cfg->cm > 255 || 196 + cfg->cn < 1 || cfg->cn > 32 || 197 + cfg->co < 1 || cfg->co > 8) { 198 + dev_err(&phy->dev, "Invalid CM/CN/CO values: %u/%u/%u\n", 199 + cfg->cm, cfg->cn, cfg->co); 200 + dev_err(&phy->dev, "for hs_clk/ref_clk=%ld/%ld ~ %d/%d\n", 201 + dphy_opts->hs_clk_rate, ref_clk, 202 + numerator, denominator); 203 + return -EINVAL; 204 + } 205 + 206 + dev_dbg(&phy->dev, "hs_clk/ref_clk=%ld/%ld ~ %d/%d\n", 207 + dphy_opts->hs_clk_rate, ref_clk, numerator, denominator); 208 + 209 + /* LP clock period */ 210 + tmp = 1000000000000LL; 211 + do_div(tmp, dphy_opts->lp_clk_rate); /* ps */ 212 + if (tmp > ULONG_MAX) 213 + return -EINVAL; 214 + 215 + lp_t = tmp; 216 + dev_dbg(&phy->dev, "LP clock %lu, period: %u ps\n", 217 + dphy_opts->lp_clk_rate, lp_t); 218 + 219 + /* hs_prepare: in lp clock periods */ 220 + if (2 * dphy_opts->hs_prepare > 5 * lp_t) { 221 + dev_err(&phy->dev, 222 + "hs_prepare (%u) > 2.5 * lp clock period (%u)\n", 223 + dphy_opts->hs_prepare, lp_t); 224 + return -EINVAL; 225 + } 226 + /* 00: lp_t, 01: 1.5 * lp_t, 10: 2 * lp_t, 11: 2.5 * lp_t */ 227 + if (dphy_opts->hs_prepare < lp_t) { 228 + n = 0; 229 + } else { 230 + tmp = 2 * (dphy_opts->hs_prepare - lp_t); 231 + do_div(tmp, lp_t); 232 + n = tmp; 233 + } 234 + cfg->m_prg_hs_prepare = n; 235 + 236 + /* clk_prepare: in lp clock periods */ 237 + if (2 * dphy_opts->clk_prepare > 3 * lp_t) { 238 + dev_err(&phy->dev, 239 + "clk_prepare (%u) > 1.5 * lp clock period (%u)\n", 240 + dphy_opts->clk_prepare, lp_t); 241 + return -EINVAL; 242 + } 243 + /* 00: lp_t, 01: 1.5 * lp_t */ 244 + cfg->mc_prg_hs_prepare = dphy_opts->clk_prepare > lp_t ? 1 : 0; 245 + 246 + /* hs_zero: formula from NXP BSP */ 247 + n = (144 * (dphy_opts->hs_clk_rate / 1000000) - 47500) / 10000; 248 + cfg->m_prg_hs_zero = n < 1 ? 1 : n; 249 + 250 + /* clk_zero: formula from NXP BSP */ 251 + n = (34 * (dphy_opts->hs_clk_rate / 1000000) - 2500) / 1000; 252 + cfg->mc_prg_hs_zero = n < 1 ? 1 : n; 253 + 254 + /* clk_trail, hs_trail: formula from NXP BSP */ 255 + n = (103 * (dphy_opts->hs_clk_rate / 1000000) + 10000) / 10000; 256 + if (n > 15) 257 + n = 15; 258 + if (n < 1) 259 + n = 1; 260 + cfg->m_prg_hs_trail = n; 261 + cfg->mc_prg_hs_trail = n; 262 + 263 + /* rxhs_settle: formula from NXP BSP */ 264 + if (dphy_opts->hs_clk_rate < MBPS(80)) 265 + cfg->rxhs_settle = 0x0d; 266 + else if (dphy_opts->hs_clk_rate < MBPS(90)) 267 + cfg->rxhs_settle = 0x0c; 268 + else if (dphy_opts->hs_clk_rate < MBPS(125)) 269 + cfg->rxhs_settle = 0x0b; 270 + else if (dphy_opts->hs_clk_rate < MBPS(150)) 271 + cfg->rxhs_settle = 0x0a; 272 + else if (dphy_opts->hs_clk_rate < MBPS(225)) 273 + cfg->rxhs_settle = 0x09; 274 + else if (dphy_opts->hs_clk_rate < MBPS(500)) 275 + cfg->rxhs_settle = 0x08; 276 + else 277 + cfg->rxhs_settle = 0x07; 278 + 279 + dev_dbg(&phy->dev, "phy_config: %u %u %u %u %u %u %u\n", 280 + cfg->m_prg_hs_prepare, cfg->mc_prg_hs_prepare, 281 + cfg->m_prg_hs_zero, cfg->mc_prg_hs_zero, 282 + cfg->m_prg_hs_trail, cfg->mc_prg_hs_trail, 283 + cfg->rxhs_settle); 284 + 285 + return 0; 286 + } 287 + 288 + static void mixel_phy_set_hs_timings(struct phy *phy) 289 + { 290 + struct mixel_dphy_priv *priv = phy_get_drvdata(phy); 291 + 292 + phy_write(phy, priv->cfg.m_prg_hs_prepare, DPHY_M_PRG_HS_PREPARE); 293 + phy_write(phy, priv->cfg.mc_prg_hs_prepare, DPHY_MC_PRG_HS_PREPARE); 294 + phy_write(phy, priv->cfg.m_prg_hs_zero, DPHY_M_PRG_HS_ZERO); 295 + phy_write(phy, priv->cfg.mc_prg_hs_zero, DPHY_MC_PRG_HS_ZERO); 296 + phy_write(phy, priv->cfg.m_prg_hs_trail, DPHY_M_PRG_HS_TRAIL); 297 + phy_write(phy, priv->cfg.mc_prg_hs_trail, DPHY_MC_PRG_HS_TRAIL); 298 + phy_write(phy, priv->cfg.rxhs_settle, priv->devdata->reg_rxhs_settle); 299 + } 300 + 301 + static int mixel_dphy_set_pll_params(struct phy *phy) 302 + { 303 + struct mixel_dphy_priv *priv = dev_get_drvdata(phy->dev.parent); 304 + 305 + if (priv->cfg.cm < 16 || priv->cfg.cm > 255 || 306 + priv->cfg.cn < 1 || priv->cfg.cn > 32 || 307 + priv->cfg.co < 1 || priv->cfg.co > 8) { 308 + dev_err(&phy->dev, "Invalid CM/CN/CO values! (%u/%u/%u)\n", 309 + priv->cfg.cm, priv->cfg.cn, priv->cfg.co); 310 + return -EINVAL; 311 + } 312 + dev_dbg(&phy->dev, "Using CM:%u CN:%u CO:%u\n", 313 + priv->cfg.cm, priv->cfg.cn, priv->cfg.co); 314 + phy_write(phy, CM(priv->cfg.cm), DPHY_CM); 315 + phy_write(phy, CN(priv->cfg.cn), DPHY_CN); 316 + phy_write(phy, CO(priv->cfg.co), DPHY_CO); 317 + return 0; 318 + } 319 + 320 + static int mixel_dphy_configure(struct phy *phy, union phy_configure_opts *opts) 321 + { 322 + struct mixel_dphy_priv *priv = phy_get_drvdata(phy); 323 + struct mixel_dphy_cfg cfg = { 0 }; 324 + int ret; 325 + 326 + ret = mixel_dphy_config_from_opts(phy, &opts->mipi_dphy, &cfg); 327 + if (ret) 328 + return ret; 329 + 330 + /* Update the configuration */ 331 + memcpy(&priv->cfg, &cfg, sizeof(struct mixel_dphy_cfg)); 332 + 333 + phy_write(phy, 0x00, DPHY_LOCK_BYP); 334 + phy_write(phy, 0x01, priv->devdata->reg_tx_rcal); 335 + phy_write(phy, 0x00, priv->devdata->reg_auto_pd_en); 336 + phy_write(phy, 0x02, priv->devdata->reg_rxlprp); 337 + phy_write(phy, 0x02, priv->devdata->reg_rxcdrp); 338 + phy_write(phy, 0x25, DPHY_TST); 339 + 340 + mixel_phy_set_hs_timings(phy); 341 + ret = mixel_dphy_set_pll_params(phy); 342 + if (ret < 0) 343 + return ret; 344 + 345 + return 0; 346 + } 347 + 348 + static int mixel_dphy_validate(struct phy *phy, enum phy_mode mode, int submode, 349 + union phy_configure_opts *opts) 350 + { 351 + struct mixel_dphy_cfg cfg = { 0 }; 352 + 353 + if (mode != PHY_MODE_MIPI_DPHY) 354 + return -EINVAL; 355 + 356 + return mixel_dphy_config_from_opts(phy, &opts->mipi_dphy, &cfg); 357 + } 358 + 359 + static int mixel_dphy_init(struct phy *phy) 360 + { 361 + phy_write(phy, PWR_OFF, DPHY_PD_PLL); 362 + phy_write(phy, PWR_OFF, DPHY_PD_DPHY); 363 + 364 + return 0; 365 + } 366 + 367 + static int mixel_dphy_exit(struct phy *phy) 368 + { 369 + phy_write(phy, 0, DPHY_CM); 370 + phy_write(phy, 0, DPHY_CN); 371 + phy_write(phy, 0, DPHY_CO); 372 + 373 + return 0; 374 + } 375 + 376 + static int mixel_dphy_power_on(struct phy *phy) 377 + { 378 + struct mixel_dphy_priv *priv = phy_get_drvdata(phy); 379 + u32 locked; 380 + int ret; 381 + 382 + ret = clk_prepare_enable(priv->phy_ref_clk); 383 + if (ret < 0) 384 + return ret; 385 + 386 + phy_write(phy, PWR_ON, DPHY_PD_PLL); 387 + ret = regmap_read_poll_timeout(priv->regmap, DPHY_LOCK, locked, 388 + locked, PLL_LOCK_SLEEP, 389 + PLL_LOCK_TIMEOUT); 390 + if (ret < 0) { 391 + dev_err(&phy->dev, "Could not get DPHY lock (%d)!\n", ret); 392 + goto clock_disable; 393 + } 394 + phy_write(phy, PWR_ON, DPHY_PD_DPHY); 395 + 396 + return 0; 397 + clock_disable: 398 + clk_disable_unprepare(priv->phy_ref_clk); 399 + return ret; 400 + } 401 + 402 + static int mixel_dphy_power_off(struct phy *phy) 403 + { 404 + struct mixel_dphy_priv *priv = phy_get_drvdata(phy); 405 + 406 + phy_write(phy, PWR_OFF, DPHY_PD_PLL); 407 + phy_write(phy, PWR_OFF, DPHY_PD_DPHY); 408 + 409 + clk_disable_unprepare(priv->phy_ref_clk); 410 + 411 + return 0; 412 + } 413 + 414 + static const struct phy_ops mixel_dphy_phy_ops = { 415 + .init = mixel_dphy_init, 416 + .exit = mixel_dphy_exit, 417 + .power_on = mixel_dphy_power_on, 418 + .power_off = mixel_dphy_power_off, 419 + .configure = mixel_dphy_configure, 420 + .validate = mixel_dphy_validate, 421 + .owner = THIS_MODULE, 422 + }; 423 + 424 + static const struct of_device_id mixel_dphy_of_match[] = { 425 + { .compatible = "fsl,imx8mq-mipi-dphy", 426 + .data = &mixel_dphy_devdata[MIXEL_IMX8MQ] }, 427 + { /* sentinel */ }, 428 + }; 429 + MODULE_DEVICE_TABLE(of, mixel_dphy_of_match); 430 + 431 + static int mixel_dphy_probe(struct platform_device *pdev) 432 + { 433 + struct device *dev = &pdev->dev; 434 + struct device_node *np = dev->of_node; 435 + struct phy_provider *phy_provider; 436 + struct mixel_dphy_priv *priv; 437 + struct resource *res; 438 + struct phy *phy; 439 + void __iomem *base; 440 + 441 + if (!np) 442 + return -ENODEV; 443 + 444 + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); 445 + if (!priv) 446 + return -ENOMEM; 447 + 448 + priv->devdata = of_device_get_match_data(&pdev->dev); 449 + if (!priv->devdata) 450 + return -EINVAL; 451 + 452 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 453 + base = devm_ioremap_resource(dev, res); 454 + if (IS_ERR(base)) 455 + return PTR_ERR(base); 456 + 457 + priv->regmap = devm_regmap_init_mmio(&pdev->dev, base, 458 + &mixel_dphy_regmap_config); 459 + if (IS_ERR(priv->regmap)) { 460 + dev_err(dev, "Couldn't create the DPHY regmap\n"); 461 + return PTR_ERR(priv->regmap); 462 + } 463 + 464 + priv->phy_ref_clk = devm_clk_get(&pdev->dev, "phy_ref"); 465 + if (IS_ERR(priv->phy_ref_clk)) { 466 + dev_err(dev, "No phy_ref clock found\n"); 467 + return PTR_ERR(priv->phy_ref_clk); 468 + } 469 + dev_dbg(dev, "phy_ref clock rate: %lu\n", 470 + clk_get_rate(priv->phy_ref_clk)); 471 + 472 + dev_set_drvdata(dev, priv); 473 + 474 + phy = devm_phy_create(dev, np, &mixel_dphy_phy_ops); 475 + if (IS_ERR(phy)) { 476 + dev_err(dev, "Failed to create phy %ld\n", PTR_ERR(phy)); 477 + return PTR_ERR(phy); 478 + } 479 + phy_set_drvdata(phy, priv); 480 + 481 + phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate); 482 + 483 + return PTR_ERR_OR_ZERO(phy_provider); 484 + } 485 + 486 + static struct platform_driver mixel_dphy_driver = { 487 + .probe = mixel_dphy_probe, 488 + .driver = { 489 + .name = "mixel-mipi-dphy", 490 + .of_match_table = mixel_dphy_of_match, 491 + } 492 + }; 493 + module_platform_driver(mixel_dphy_driver); 494 + 495 + MODULE_AUTHOR("NXP Semiconductor"); 496 + MODULE_DESCRIPTION("Mixel MIPI-DSI PHY driver"); 497 + MODULE_LICENSE("GPL");
+8
drivers/phy/qualcomm/Kconfig
··· 25 25 depends on OF 26 26 select GENERIC_PHY 27 27 28 + config PHY_QCOM_PCIE2 29 + tristate "Qualcomm PCIe Gen2 PHY Driver" 30 + depends on OF && COMMON_CLK && (ARCH_QCOM || COMPILE_TEST) 31 + select GENERIC_PHY 32 + help 33 + Enable this to support the Qualcomm PCIe PHY, used with the Synopsys 34 + based PCIe controller. 35 + 28 36 config PHY_QCOM_QMP 29 37 tristate "Qualcomm QMP PHY Driver" 30 38 depends on OF && COMMON_CLK && (ARCH_QCOM || COMPILE_TEST)
+1
drivers/phy/qualcomm/Makefile
··· 2 2 obj-$(CONFIG_PHY_ATH79_USB) += phy-ath79-usb.o 3 3 obj-$(CONFIG_PHY_QCOM_APQ8064_SATA) += phy-qcom-apq8064-sata.o 4 4 obj-$(CONFIG_PHY_QCOM_IPQ806X_SATA) += phy-qcom-ipq806x-sata.o 5 + obj-$(CONFIG_PHY_QCOM_PCIE2) += phy-qcom-pcie2.o 5 6 obj-$(CONFIG_PHY_QCOM_QMP) += phy-qcom-qmp.o 6 7 obj-$(CONFIG_PHY_QCOM_QUSB2) += phy-qcom-qusb2.o 7 8 obj-$(CONFIG_PHY_QCOM_UFS) += phy-qcom-ufs.o
+331
drivers/phy/qualcomm/phy-qcom-pcie2.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + /* 3 + * Copyright (c) 2014-2017, The Linux Foundation. All rights reserved. 4 + * Copyright (c) 2019, Linaro Ltd. 5 + */ 6 + 7 + #include <linux/clk-provider.h> 8 + #include <linux/clk.h> 9 + #include <linux/iopoll.h> 10 + #include <linux/module.h> 11 + #include <linux/phy/phy.h> 12 + #include <linux/platform_device.h> 13 + #include <linux/reset.h> 14 + #include <linux/slab.h> 15 + 16 + #include <dt-bindings/phy/phy.h> 17 + 18 + #define PCIE20_PARF_PHY_STTS 0x3c 19 + #define PCIE2_PHY_RESET_CTRL 0x44 20 + #define PCIE20_PARF_PHY_REFCLK_CTRL2 0xa0 21 + #define PCIE20_PARF_PHY_REFCLK_CTRL3 0xa4 22 + #define PCIE20_PARF_PCS_SWING_CTRL1 0x88 23 + #define PCIE20_PARF_PCS_SWING_CTRL2 0x8c 24 + #define PCIE20_PARF_PCS_DEEMPH1 0x74 25 + #define PCIE20_PARF_PCS_DEEMPH2 0x78 26 + #define PCIE20_PARF_PCS_DEEMPH3 0x7c 27 + #define PCIE20_PARF_CONFIGBITS 0x84 28 + #define PCIE20_PARF_PHY_CTRL3 0x94 29 + #define PCIE20_PARF_PCS_CTRL 0x80 30 + 31 + #define TX_AMP_VAL 120 32 + #define PHY_RX0_EQ_GEN1_VAL 0 33 + #define PHY_RX0_EQ_GEN2_VAL 4 34 + #define TX_DEEMPH_GEN1_VAL 24 35 + #define TX_DEEMPH_GEN2_3_5DB_VAL 26 36 + #define TX_DEEMPH_GEN2_6DB_VAL 36 37 + #define PHY_TX0_TERM_OFFST_VAL 0 38 + 39 + struct qcom_phy { 40 + struct device *dev; 41 + void __iomem *base; 42 + 43 + struct regulator_bulk_data vregs[2]; 44 + 45 + struct reset_control *phy_reset; 46 + struct reset_control *pipe_reset; 47 + struct clk *pipe_clk; 48 + }; 49 + 50 + static int qcom_pcie2_phy_init(struct phy *phy) 51 + { 52 + struct qcom_phy *qphy = phy_get_drvdata(phy); 53 + int ret; 54 + 55 + ret = reset_control_deassert(qphy->phy_reset); 56 + if (ret) { 57 + dev_err(qphy->dev, "cannot deassert pipe reset\n"); 58 + return ret; 59 + } 60 + 61 + ret = regulator_bulk_enable(ARRAY_SIZE(qphy->vregs), qphy->vregs); 62 + if (ret) 63 + reset_control_assert(qphy->phy_reset); 64 + 65 + return ret; 66 + } 67 + 68 + static int qcom_pcie2_phy_power_on(struct phy *phy) 69 + { 70 + struct qcom_phy *qphy = phy_get_drvdata(phy); 71 + int ret; 72 + u32 val; 73 + 74 + /* Program REF_CLK source */ 75 + val = readl(qphy->base + PCIE20_PARF_PHY_REFCLK_CTRL2); 76 + val &= ~BIT(1); 77 + writel(val, qphy->base + PCIE20_PARF_PHY_REFCLK_CTRL2); 78 + 79 + usleep_range(1000, 2000); 80 + 81 + /* Don't use PAD for refclock */ 82 + val = readl(qphy->base + PCIE20_PARF_PHY_REFCLK_CTRL2); 83 + val &= ~BIT(0); 84 + writel(val, qphy->base + PCIE20_PARF_PHY_REFCLK_CTRL2); 85 + 86 + /* Program SSP ENABLE */ 87 + val = readl(qphy->base + PCIE20_PARF_PHY_REFCLK_CTRL3); 88 + val |= BIT(0); 89 + writel(val, qphy->base + PCIE20_PARF_PHY_REFCLK_CTRL3); 90 + 91 + usleep_range(1000, 2000); 92 + 93 + /* Assert Phy SW Reset */ 94 + val = readl(qphy->base + PCIE2_PHY_RESET_CTRL); 95 + val |= BIT(0); 96 + writel(val, qphy->base + PCIE2_PHY_RESET_CTRL); 97 + 98 + /* Program Tx Amplitude */ 99 + val = readl(qphy->base + PCIE20_PARF_PCS_SWING_CTRL1); 100 + val &= ~0x7f; 101 + val |= TX_AMP_VAL; 102 + writel(val, qphy->base + PCIE20_PARF_PCS_SWING_CTRL1); 103 + 104 + val = readl(qphy->base + PCIE20_PARF_PCS_SWING_CTRL2); 105 + val &= ~0x7f; 106 + val |= TX_AMP_VAL; 107 + writel(val, qphy->base + PCIE20_PARF_PCS_SWING_CTRL2); 108 + 109 + /* Program De-Emphasis */ 110 + val = readl(qphy->base + PCIE20_PARF_PCS_DEEMPH1); 111 + val &= ~0x3f; 112 + val |= TX_DEEMPH_GEN2_6DB_VAL; 113 + writel(val, qphy->base + PCIE20_PARF_PCS_DEEMPH1); 114 + 115 + val = readl(qphy->base + PCIE20_PARF_PCS_DEEMPH2); 116 + val &= ~0x3f; 117 + val |= TX_DEEMPH_GEN2_3_5DB_VAL; 118 + writel(val, qphy->base + PCIE20_PARF_PCS_DEEMPH2); 119 + 120 + val = readl(qphy->base + PCIE20_PARF_PCS_DEEMPH3); 121 + val &= ~0x3f; 122 + val |= TX_DEEMPH_GEN1_VAL; 123 + writel(val, qphy->base + PCIE20_PARF_PCS_DEEMPH3); 124 + 125 + /* Program Rx_Eq */ 126 + val = readl(qphy->base + PCIE20_PARF_CONFIGBITS); 127 + val &= ~0x7; 128 + val |= PHY_RX0_EQ_GEN2_VAL; 129 + writel(val, qphy->base + PCIE20_PARF_CONFIGBITS); 130 + 131 + /* Program Tx0_term_offset */ 132 + val = readl(qphy->base + PCIE20_PARF_PHY_CTRL3); 133 + val &= ~0x1f; 134 + val |= PHY_TX0_TERM_OFFST_VAL; 135 + writel(val, qphy->base + PCIE20_PARF_PHY_CTRL3); 136 + 137 + /* disable Tx2Rx Loopback */ 138 + val = readl(qphy->base + PCIE20_PARF_PCS_CTRL); 139 + val &= ~BIT(1); 140 + writel(val, qphy->base + PCIE20_PARF_PCS_CTRL); 141 + 142 + /* De-assert Phy SW Reset */ 143 + val = readl(qphy->base + PCIE2_PHY_RESET_CTRL); 144 + val &= ~BIT(0); 145 + writel(val, qphy->base + PCIE2_PHY_RESET_CTRL); 146 + 147 + usleep_range(1000, 2000); 148 + 149 + ret = reset_control_deassert(qphy->pipe_reset); 150 + if (ret) { 151 + dev_err(qphy->dev, "cannot deassert pipe reset\n"); 152 + goto out; 153 + } 154 + 155 + clk_set_rate(qphy->pipe_clk, 250000000); 156 + 157 + ret = clk_prepare_enable(qphy->pipe_clk); 158 + if (ret) { 159 + dev_err(qphy->dev, "failed to enable pipe clock\n"); 160 + goto out; 161 + } 162 + 163 + ret = readl_poll_timeout(qphy->base + PCIE20_PARF_PHY_STTS, val, 164 + !(val & BIT(0)), 1000, 10); 165 + if (ret) 166 + dev_err(qphy->dev, "phy initialization failed\n"); 167 + 168 + out: 169 + return ret; 170 + } 171 + 172 + static int qcom_pcie2_phy_power_off(struct phy *phy) 173 + { 174 + struct qcom_phy *qphy = phy_get_drvdata(phy); 175 + u32 val; 176 + 177 + val = readl(qphy->base + PCIE2_PHY_RESET_CTRL); 178 + val |= BIT(0); 179 + writel(val, qphy->base + PCIE2_PHY_RESET_CTRL); 180 + 181 + clk_disable_unprepare(qphy->pipe_clk); 182 + reset_control_assert(qphy->pipe_reset); 183 + 184 + return 0; 185 + } 186 + 187 + static int qcom_pcie2_phy_exit(struct phy *phy) 188 + { 189 + struct qcom_phy *qphy = phy_get_drvdata(phy); 190 + 191 + regulator_bulk_disable(ARRAY_SIZE(qphy->vregs), qphy->vregs); 192 + reset_control_assert(qphy->phy_reset); 193 + 194 + return 0; 195 + } 196 + 197 + static const struct phy_ops qcom_pcie2_ops = { 198 + .init = qcom_pcie2_phy_init, 199 + .power_on = qcom_pcie2_phy_power_on, 200 + .power_off = qcom_pcie2_phy_power_off, 201 + .exit = qcom_pcie2_phy_exit, 202 + .owner = THIS_MODULE, 203 + }; 204 + 205 + /* 206 + * Register a fixed rate pipe clock. 207 + * 208 + * The <s>_pipe_clksrc generated by PHY goes to the GCC that gate 209 + * controls it. The <s>_pipe_clk coming out of the GCC is requested 210 + * by the PHY driver for its operations. 211 + * We register the <s>_pipe_clksrc here. The gcc driver takes care 212 + * of assigning this <s>_pipe_clksrc as parent to <s>_pipe_clk. 213 + * Below picture shows this relationship. 214 + * 215 + * +---------------+ 216 + * | PHY block |<<---------------------------------------+ 217 + * | | | 218 + * | +-------+ | +-----+ | 219 + * I/P---^-->| PLL |---^--->pipe_clksrc--->| GCC |--->pipe_clk---+ 220 + * clk | +-------+ | +-----+ 221 + * +---------------+ 222 + */ 223 + static int phy_pipe_clksrc_register(struct qcom_phy *qphy) 224 + { 225 + struct device_node *np = qphy->dev->of_node; 226 + struct clk_fixed_rate *fixed; 227 + struct clk_init_data init = { }; 228 + int ret; 229 + 230 + ret = of_property_read_string(np, "clock-output-names", &init.name); 231 + if (ret) { 232 + dev_err(qphy->dev, "%s: No clock-output-names\n", np->name); 233 + return ret; 234 + } 235 + 236 + fixed = devm_kzalloc(qphy->dev, sizeof(*fixed), GFP_KERNEL); 237 + if (!fixed) 238 + return -ENOMEM; 239 + 240 + init.ops = &clk_fixed_rate_ops; 241 + 242 + /* controllers using QMP phys use 250MHz pipe clock interface */ 243 + fixed->fixed_rate = 250000000; 244 + fixed->hw.init = &init; 245 + 246 + return devm_clk_hw_register(qphy->dev, &fixed->hw); 247 + } 248 + 249 + static int qcom_pcie2_phy_probe(struct platform_device *pdev) 250 + { 251 + struct phy_provider *phy_provider; 252 + struct qcom_phy *qphy; 253 + struct resource *res; 254 + struct device *dev = &pdev->dev; 255 + struct phy *phy; 256 + int ret; 257 + 258 + qphy = devm_kzalloc(dev, sizeof(*qphy), GFP_KERNEL); 259 + if (!qphy) 260 + return -ENOMEM; 261 + 262 + qphy->dev = dev; 263 + 264 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 265 + qphy->base = devm_ioremap_resource(dev, res); 266 + if (IS_ERR(qphy->base)) 267 + return PTR_ERR(qphy->base); 268 + 269 + ret = phy_pipe_clksrc_register(qphy); 270 + if (ret) { 271 + dev_err(dev, "failed to register pipe_clk\n"); 272 + return ret; 273 + } 274 + 275 + qphy->vregs[0].supply = "vdda-vp"; 276 + qphy->vregs[1].supply = "vdda-vph"; 277 + ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(qphy->vregs), qphy->vregs); 278 + if (ret < 0) 279 + return ret; 280 + 281 + qphy->pipe_clk = devm_clk_get(dev, NULL); 282 + if (IS_ERR(qphy->pipe_clk)) { 283 + dev_err(dev, "failed to acquire pipe clock\n"); 284 + return PTR_ERR(qphy->pipe_clk); 285 + } 286 + 287 + qphy->phy_reset = devm_reset_control_get_exclusive(dev, "phy"); 288 + if (IS_ERR(qphy->phy_reset)) { 289 + dev_err(dev, "failed to acquire phy reset\n"); 290 + return PTR_ERR(qphy->phy_reset); 291 + } 292 + 293 + qphy->pipe_reset = devm_reset_control_get_exclusive(dev, "pipe"); 294 + if (IS_ERR(qphy->pipe_reset)) { 295 + dev_err(dev, "failed to acquire pipe reset\n"); 296 + return PTR_ERR(qphy->pipe_reset); 297 + } 298 + 299 + phy = devm_phy_create(dev, dev->of_node, &qcom_pcie2_ops); 300 + if (IS_ERR(phy)) { 301 + dev_err(dev, "failed to create phy\n"); 302 + return PTR_ERR(phy); 303 + } 304 + 305 + phy_set_drvdata(phy, qphy); 306 + 307 + phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate); 308 + if (IS_ERR(phy_provider)) 309 + dev_err(dev, "failed to register phy provider\n"); 310 + 311 + return PTR_ERR_OR_ZERO(phy_provider); 312 + } 313 + 314 + static const struct of_device_id qcom_pcie2_phy_match_table[] = { 315 + { .compatible = "qcom,pcie2-phy" }, 316 + {} 317 + }; 318 + MODULE_DEVICE_TABLE(of, qcom_pcie2_phy_match_table); 319 + 320 + static struct platform_driver qcom_pcie2_phy_driver = { 321 + .probe = qcom_pcie2_phy_probe, 322 + .driver = { 323 + .name = "phy-qcom-pcie2", 324 + .of_match_table = qcom_pcie2_phy_match_table, 325 + }, 326 + }; 327 + 328 + module_platform_driver(qcom_pcie2_phy_driver); 329 + 330 + MODULE_DESCRIPTION("Qualcomm PCIe PHY driver"); 331 + MODULE_LICENSE("GPL v2");
+3 -2
drivers/phy/qualcomm/phy-qcom-qmp.c
··· 1074 1074 1075 1075 .start_ctrl = PCS_START | PLL_READY_GATE_EN, 1076 1076 .pwrdn_ctrl = SW_PWRDN | REFCLK_DRV_DSBL, 1077 + .mask_pcs_ready = PHYSTATUS, 1077 1078 .mask_com_pcs_ready = PCS_READY, 1078 1079 1079 1080 .has_phy_com_ctrl = true, ··· 1254 1253 1255 1254 .start_ctrl = SERDES_START | PCS_START, 1256 1255 .pwrdn_ctrl = SW_PWRDN | REFCLK_DRV_DSBL, 1257 - .mask_com_pcs_ready = PCS_READY, 1256 + .mask_pcs_ready = PHYSTATUS, 1258 1257 }; 1259 1258 1260 1259 static const struct qmp_phy_cfg msm8998_usb3phy_cfg = { ··· 1548 1547 status = pcs + cfg->regs[QPHY_PCS_READY_STATUS]; 1549 1548 mask = cfg->mask_pcs_ready; 1550 1549 1551 - ret = readl_poll_timeout(status, val, !(val & mask), 1, 1550 + ret = readl_poll_timeout(status, val, val & mask, 10, 1552 1551 PHY_INIT_COMPLETE_TIMEOUT); 1553 1552 if (ret) { 1554 1553 dev_err(qmp->dev, "phy initialization timed-out\n");
+1 -1
drivers/phy/qualcomm/phy-qcom-qusb2.c
··· 564 564 } 565 565 566 566 if (!qphy->has_se_clk_scheme) { 567 - clk_prepare_enable(qphy->ref_clk); 567 + ret = clk_prepare_enable(qphy->ref_clk); 568 568 if (ret) { 569 569 dev_err(dev, "failed to enable ref clk, %d\n", ret); 570 570 goto disable_ahb_clk;
+2
drivers/phy/renesas/phy-rcar-gen2.c
··· 391 391 error = of_property_read_u32(np, "reg", &channel_num); 392 392 if (error || channel_num > 2) { 393 393 dev_err(dev, "Invalid \"reg\" property\n"); 394 + of_node_put(np); 394 395 return error; 395 396 } 396 397 channel->select_mask = select_mask[channel_num]; ··· 407 406 data->gen2_phy_ops); 408 407 if (IS_ERR(phy->phy)) { 409 408 dev_err(dev, "Failed to create PHY\n"); 409 + of_node_put(np); 410 410 return PTR_ERR(phy->phy); 411 411 } 412 412 phy_set_drvdata(phy->phy, phy);
+15 -4
drivers/phy/renesas/phy-rcar-gen3-usb2.c
··· 13 13 #include <linux/interrupt.h> 14 14 #include <linux/io.h> 15 15 #include <linux/module.h> 16 + #include <linux/mutex.h> 16 17 #include <linux/of.h> 17 18 #include <linux/of_address.h> 18 19 #include <linux/of_device.h> ··· 107 106 struct rcar_gen3_phy rphys[NUM_OF_PHYS]; 108 107 struct regulator *vbus; 109 108 struct work_struct work; 109 + struct mutex lock; /* protects rphys[...].powered */ 110 110 enum usb_dr_mode dr_mode; 111 111 bool extcon_host; 112 112 bool is_otg_channel; ··· 439 437 struct rcar_gen3_chan *channel = rphy->ch; 440 438 void __iomem *usb2_base = channel->base; 441 439 u32 val; 442 - int ret; 440 + int ret = 0; 443 441 442 + mutex_lock(&channel->lock); 444 443 if (!rcar_gen3_are_all_rphys_power_off(channel)) 445 - return 0; 444 + goto out; 446 445 447 446 if (channel->vbus) { 448 447 ret = regulator_enable(channel->vbus); 449 448 if (ret) 450 - return ret; 449 + goto out; 451 450 } 452 451 453 452 val = readl(usb2_base + USB2_USBCTR); ··· 457 454 val &= ~USB2_USBCTR_PLL_RST; 458 455 writel(val, usb2_base + USB2_USBCTR); 459 456 457 + out: 458 + /* The powered flag should be set for any other phys anyway */ 460 459 rphy->powered = true; 460 + mutex_unlock(&channel->lock); 461 461 462 462 return 0; 463 463 } ··· 471 465 struct rcar_gen3_chan *channel = rphy->ch; 472 466 int ret = 0; 473 467 468 + mutex_lock(&channel->lock); 474 469 rphy->powered = false; 475 470 476 471 if (!rcar_gen3_are_all_rphys_power_off(channel)) 477 - return 0; 472 + goto out; 478 473 479 474 if (channel->vbus) 480 475 ret = regulator_disable(channel->vbus); 476 + 477 + out: 478 + mutex_unlock(&channel->lock); 481 479 482 480 return ret; 483 481 } ··· 649 639 if (!phy_usb2_ops) 650 640 return -EINVAL; 651 641 642 + mutex_init(&channel->lock); 652 643 for (i = 0; i < NUM_OF_PHYS; i++) { 653 644 channel->rphys[i].phy = devm_phy_create(dev, NULL, 654 645 phy_usb2_ops);
+2 -3
drivers/phy/samsung/phy-samsung-usb2.c
··· 156 156 if (!cfg) 157 157 return -EINVAL; 158 158 159 - drv = devm_kzalloc(dev, sizeof(struct samsung_usb2_phy_driver) + 160 - cfg->num_phys * sizeof(struct samsung_usb2_phy_instance), 161 - GFP_KERNEL); 159 + drv = devm_kzalloc(dev, struct_size(drv, instances, cfg->num_phys), 160 + GFP_KERNEL); 162 161 if (!drv) 163 162 return -ENOMEM; 164 163
+9
drivers/phy/tegra/xusb-tegra124.c
··· 1713 1713 .hsic_set_idle = tegra124_hsic_set_idle, 1714 1714 }; 1715 1715 1716 + static const char * const tegra124_xusb_padctl_supply_names[] = { 1717 + "avdd-pll-utmip", 1718 + "avdd-pll-erefe", 1719 + "avdd-pex-pll", 1720 + "hvdd-pex-pll-e", 1721 + }; 1722 + 1716 1723 const struct tegra_xusb_padctl_soc tegra124_xusb_padctl_soc = { 1717 1724 .num_pads = ARRAY_SIZE(tegra124_pads), 1718 1725 .pads = tegra124_pads, ··· 1742 1735 }, 1743 1736 }, 1744 1737 .ops = &tegra124_xusb_padctl_ops, 1738 + .supply_names = tegra124_xusb_padctl_supply_names, 1739 + .num_supplies = ARRAY_SIZE(tegra124_xusb_padctl_supply_names), 1745 1740 }; 1746 1741 EXPORT_SYMBOL_GPL(tegra124_xusb_padctl_soc); 1747 1742
+9
drivers/phy/tegra/xusb-tegra210.c
··· 2009 2009 .hsic_set_idle = tegra210_hsic_set_idle, 2010 2010 }; 2011 2011 2012 + static const char * const tegra210_xusb_padctl_supply_names[] = { 2013 + "avdd-pll-utmip", 2014 + "avdd-pll-uerefe", 2015 + "dvdd-pex-pll", 2016 + "hvdd-pex-pll-e", 2017 + }; 2018 + 2012 2019 const struct tegra_xusb_padctl_soc tegra210_xusb_padctl_soc = { 2013 2020 .num_pads = ARRAY_SIZE(tegra210_pads), 2014 2021 .pads = tegra210_pads, ··· 2034 2027 }, 2035 2028 }, 2036 2029 .ops = &tegra210_xusb_padctl_ops, 2030 + .supply_names = tegra210_xusb_padctl_supply_names, 2031 + .num_supplies = ARRAY_SIZE(tegra210_xusb_padctl_supply_names), 2037 2032 }; 2038 2033 EXPORT_SYMBOL_GPL(tegra210_xusb_padctl_soc); 2039 2034
+2 -2
drivers/phy/ti/phy-am654-serdes.c
··· 247 247 mux_control_deselect(phy->control); 248 248 } 249 249 250 - struct phy *serdes_am654_xlate(struct device *dev, struct of_phandle_args 251 - *args) 250 + static struct phy *serdes_am654_xlate(struct device *dev, 251 + struct of_phandle_args *args) 252 252 { 253 253 struct serdes_am654 *am654_phy; 254 254 struct phy *phy;
+15 -6
drivers/soc/qcom/qcom-geni-se.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 2 2 // Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. 3 3 4 + #include <linux/acpi.h> 4 5 #include <linux/clk.h> 5 6 #include <linux/slab.h> 6 7 #include <linux/dma-mapping.h> ··· 451 450 { 452 451 int ret; 453 452 453 + if (has_acpi_companion(se->dev)) 454 + return 0; 455 + 454 456 ret = pinctrl_pm_select_sleep_state(se->dev); 455 457 if (ret) 456 458 return ret; ··· 490 486 int geni_se_resources_on(struct geni_se *se) 491 487 { 492 488 int ret; 489 + 490 + if (has_acpi_companion(se->dev)) 491 + return 0; 493 492 494 493 ret = geni_se_clks_on(se); 495 494 if (ret) ··· 731 724 if (IS_ERR(wrapper->base)) 732 725 return PTR_ERR(wrapper->base); 733 726 734 - wrapper->ahb_clks[0].id = "m-ahb"; 735 - wrapper->ahb_clks[1].id = "s-ahb"; 736 - ret = devm_clk_bulk_get(dev, NUM_AHB_CLKS, wrapper->ahb_clks); 737 - if (ret) { 738 - dev_err(dev, "Err getting AHB clks %d\n", ret); 739 - return ret; 727 + if (!has_acpi_companion(&pdev->dev)) { 728 + wrapper->ahb_clks[0].id = "m-ahb"; 729 + wrapper->ahb_clks[1].id = "s-ahb"; 730 + ret = devm_clk_bulk_get(dev, NUM_AHB_CLKS, wrapper->ahb_clks); 731 + if (ret) { 732 + dev_err(dev, "Err getting AHB clks %d\n", ret); 733 + return ret; 734 + } 740 735 } 741 736 742 737 dev_set_drvdata(dev, wrapper);
+1 -1
drivers/usb/Kconfig
··· 74 74 After choosing your HCD, then select drivers for the USB peripherals 75 75 you'll be using. You may want to check out the information provided 76 76 in <file:Documentation/usb/> and especially the links given in 77 - <file:Documentation/usb/usb-help.txt>. 77 + <file:Documentation/usb/usb-help.rst>. 78 78 79 79 To compile this driver as a module, choose M here: the 80 80 module will be called usbcore.
+1 -2
drivers/usb/Makefile
··· 5 5 6 6 # Object files in subdirectories 7 7 8 + obj-$(CONFIG_USB_COMMON) += common/ 8 9 obj-$(CONFIG_USB) += core/ 9 10 obj-$(CONFIG_USB_SUPPORT) += phy/ 10 11 ··· 60 59 obj-$(CONFIG_USB_CHIPIDEA) += chipidea/ 61 60 obj-$(CONFIG_USB_RENESAS_USBHS) += renesas_usbhs/ 62 61 obj-$(CONFIG_USB_GADGET) += gadget/ 63 - 64 - obj-$(CONFIG_USB_COMMON) += common/ 65 62 66 63 obj-$(CONFIG_USBIP_CORE) += usbip/ 67 64
-1
drivers/usb/atm/Kconfig
··· 7 7 tristate "USB DSL modem support" 8 8 depends on ATM 9 9 select CRC32 10 - default n 11 10 help 12 11 Say Y here if you want to connect a USB Digital Subscriber Line (DSL) 13 12 modem to your computer's USB port. You will then need to choose your
+2 -46
drivers/usb/atm/ueagle-atm.c
··· 1 - // SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) 2 - /*- 1 + // SPDX-License-Identifier: (GPL-2.0+ OR BSD-2-Clause) 2 + /* 3 3 * Copyright (c) 2003, 2004 4 4 * Damien Bergamini <damien.bergamini@free.fr>. All rights reserved. 5 5 * 6 6 * Copyright (c) 2005-2007 Matthieu Castet <castet.matthieu@free.fr> 7 7 * Copyright (c) 2005-2007 Stanislaw Gruszka <stf_xl@wp.pl> 8 - * 9 - * This software is available to you under a choice of one of two 10 - * licenses. You may choose to be licensed under the terms of the GNU 11 - * General Public License (GPL) Version 2, available from the file 12 - * COPYING in the main directory of this source tree, or the 13 - * BSD license below: 14 - * 15 - * Redistribution and use in source and binary forms, with or without 16 - * modification, are permitted provided that the following conditions 17 - * are met: 18 - * 1. Redistributions of source code must retain the above copyright 19 - * notice unmodified, this list of conditions, and the following 20 - * disclaimer. 21 - * 2. Redistributions in binary form must reproduce the above copyright 22 - * notice, this list of conditions and the following disclaimer in the 23 - * documentation and/or other materials provided with the distribution. 24 - * 25 - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 26 - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27 - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 28 - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 29 - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 30 - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 31 - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 32 - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 34 - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 35 - * SUCH DAMAGE. 36 - * 37 - * GPL license : 38 - * This program is free software; you can redistribute it and/or 39 - * modify it under the terms of the GNU General Public License 40 - * as published by the Free Software Foundation; either version 2 41 - * of the License, or (at your option) any later version. 42 - * 43 - * This program is distributed in the hope that it will be useful, 44 - * but WITHOUT ANY WARRANTY; without even the implied warranty of 45 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 46 - * GNU General Public License for more details. 47 - * 48 - * You should have received a copy of the GNU General Public License 49 - * along with this program; if not, write to the Free Software 50 - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 51 - * 52 8 * 53 9 * HISTORY : some part of the code was base on ueagle 1.3 BSD driver, 54 10 * Damien Bergamini agree to put his code under a DUAL GPL/BSD license.
+30 -3
drivers/usb/chipidea/ci_hdrc_imx.c
··· 13 13 #include <linux/usb/of.h> 14 14 #include <linux/clk.h> 15 15 #include <linux/pinctrl/consumer.h> 16 + #include <linux/pm_qos.h> 16 17 17 18 #include "ci.h" 18 19 #include "ci_hdrc_imx.h" ··· 64 63 .flags = CI_HDRC_SUPPORTS_RUNTIME_PM, 65 64 }; 66 65 66 + static const struct ci_hdrc_imx_platform_flag imx7ulp_usb_data = { 67 + .flags = CI_HDRC_SUPPORTS_RUNTIME_PM | 68 + CI_HDRC_PMQOS, 69 + }; 70 + 67 71 static const struct of_device_id ci_hdrc_imx_dt_ids[] = { 68 72 { .compatible = "fsl,imx23-usb", .data = &imx23_usb_data}, 69 73 { .compatible = "fsl,imx28-usb", .data = &imx28_usb_data}, ··· 78 72 { .compatible = "fsl,imx6sx-usb", .data = &imx6sx_usb_data}, 79 73 { .compatible = "fsl,imx6ul-usb", .data = &imx6ul_usb_data}, 80 74 { .compatible = "fsl,imx7d-usb", .data = &imx7d_usb_data}, 75 + { .compatible = "fsl,imx7ulp-usb", .data = &imx7ulp_usb_data}, 81 76 { /* sentinel */ } 82 77 }; 83 78 MODULE_DEVICE_TABLE(of, ci_hdrc_imx_dt_ids); ··· 100 93 struct clk *clk_ahb; 101 94 struct clk *clk_per; 102 95 /* --------------------------------- */ 96 + struct pm_qos_request pm_qos_req; 97 + const struct ci_hdrc_imx_platform_flag *plat_data; 103 98 }; 104 99 105 100 /* Common functions shared by usbmisc drivers */ ··· 318 309 if (!data) 319 310 return -ENOMEM; 320 311 312 + data->plat_data = imx_platform_flag; 313 + pdata.flags |= imx_platform_flag->flags; 321 314 platform_set_drvdata(pdev, data); 322 315 data->usbmisc_data = usbmisc_get_init_data(dev); 323 316 if (IS_ERR(data->usbmisc_data)) ··· 380 369 } 381 370 } 382 371 } 372 + 373 + if (pdata.flags & CI_HDRC_PMQOS) 374 + pm_qos_add_request(&data->pm_qos_req, 375 + PM_QOS_CPU_DMA_LATENCY, 0); 376 + 383 377 ret = imx_get_clks(dev); 384 378 if (ret) 385 379 goto disable_hsic_regulator; ··· 398 382 ret = PTR_ERR(data->phy); 399 383 /* Return -EINVAL if no usbphy is available */ 400 384 if (ret == -ENODEV) 401 - ret = -EINVAL; 402 - goto err_clk; 385 + data->phy = NULL; 386 + else 387 + goto err_clk; 403 388 } 404 389 405 390 pdata.usb_phy = data->phy; ··· 413 396 usb_phy_init(pdata.usb_phy); 414 397 } 415 398 416 - pdata.flags |= imx_platform_flag->flags; 417 399 if (pdata.flags & CI_HDRC_SUPPORTS_RUNTIME_PM) 418 400 data->supports_runtime_pm = true; 419 401 ··· 455 439 disable_hsic_regulator: 456 440 if (data->hsic_pad_regulator) 457 441 ret = regulator_disable(data->hsic_pad_regulator); 442 + if (pdata.flags & CI_HDRC_PMQOS) 443 + pm_qos_remove_request(&data->pm_qos_req); 458 444 return ret; 459 445 } 460 446 ··· 473 455 if (data->override_phy_control) 474 456 usb_phy_shutdown(data->phy); 475 457 imx_disable_unprepare_clks(&pdev->dev); 458 + if (data->plat_data->flags & CI_HDRC_PMQOS) 459 + pm_qos_remove_request(&data->pm_qos_req); 476 460 if (data->hsic_pad_regulator) 477 461 regulator_disable(data->hsic_pad_regulator); 478 462 ··· 500 480 } 501 481 502 482 imx_disable_unprepare_clks(dev); 483 + if (data->plat_data->flags & CI_HDRC_PMQOS) 484 + pm_qos_remove_request(&data->pm_qos_req); 485 + 503 486 data->in_lpm = true; 504 487 505 488 return 0; ··· 519 496 WARN_ON(1); 520 497 return 0; 521 498 } 499 + 500 + if (data->plat_data->flags & CI_HDRC_PMQOS) 501 + pm_qos_add_request(&data->pm_qos_req, 502 + PM_QOS_CPU_DMA_LATENCY, 0); 522 503 523 504 ret = imx_prepare_enable_clks(dev); 524 505 if (ret)
+1 -3
drivers/usb/chipidea/ci_hdrc_msm.c
··· 175 175 struct platform_device *plat_ci; 176 176 struct clk *clk; 177 177 struct reset_control *reset; 178 - struct resource *res; 179 178 int ret; 180 179 struct device_node *ulpi_node, *phy_node; 181 180 ··· 208 209 if (IS_ERR(clk)) 209 210 return PTR_ERR(clk); 210 211 211 - res = platform_get_resource(pdev, IORESOURCE_MEM, 1); 212 - ci->base = devm_ioremap_resource(&pdev->dev, res); 212 + ci->base = devm_platform_ioremap_resource(pdev, 1); 213 213 if (IS_ERR(ci->base)) 214 214 return PTR_ERR(ci->base); 215 215
+3 -2
drivers/usb/chipidea/core.c
··· 523 523 hw_write(ci, OP_USBMODE, USBMODE_SLOM, USBMODE_SLOM); 524 524 525 525 if (hw_read(ci, OP_USBMODE, USBMODE_CM) != USBMODE_CM_DC) { 526 - pr_err("cannot enter in %s device mode", ci_role(ci)->name); 527 - pr_err("lpm = %i", ci->hw_bank.lpm); 526 + dev_err(ci->dev, "cannot enter in %s device mode\n", 527 + ci_role(ci)->name); 528 + dev_err(ci->dev, "lpm = %i\n", ci->hw_bank.lpm); 528 529 return -ENODEV; 529 530 } 530 531
+5 -3
drivers/usb/chipidea/usbmisc_imx.c
··· 763 763 .compatible = "fsl,imx7d-usbmisc", 764 764 .data = &imx7d_usbmisc_ops, 765 765 }, 766 + { 767 + .compatible = "fsl,imx7ulp-usbmisc", 768 + .data = &imx7d_usbmisc_ops, 769 + }, 766 770 { /* sentinel */ } 767 771 }; 768 772 MODULE_DEVICE_TABLE(of, usbmisc_imx_dt_ids); 769 773 770 774 static int usbmisc_imx_probe(struct platform_device *pdev) 771 775 { 772 - struct resource *res; 773 776 struct imx_usbmisc *data; 774 777 const struct of_device_id *of_id; 775 778 ··· 786 783 787 784 spin_lock_init(&data->lock); 788 785 789 - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 790 - data->base = devm_ioremap_resource(&pdev->dev, res); 786 + data->base = devm_platform_ioremap_resource(pdev, 0); 791 787 if (IS_ERR(data->base)) 792 788 return PTR_ERR(data->base); 793 789
+1 -1
drivers/usb/class/Kconfig
··· 10 10 ---help--- 11 11 This driver supports USB modems and ISDN adapters which support the 12 12 Communication Device Class Abstract Control Model interface. 13 - Please read <file:Documentation/usb/acm.txt> for details. 13 + Please read <file:Documentation/usb/acm.rst> for details. 14 14 15 15 If your modem only reports "Cls=ff(vend.)" in the descriptors in 16 16 /sys/kernel/debug/usb/devices, then your modem will not work with this
+1 -1
drivers/usb/class/cdc-wdm.c
··· 949 949 int bufsize, 950 950 int (*manage_power)(struct usb_interface *, int)) 951 951 { 952 - int rv = -EINVAL; 952 + int rv; 953 953 954 954 rv = wdm_create(intf, ep, bufsize, manage_power); 955 955 if (rv < 0)
+21
drivers/usb/common/common.c
··· 15 15 #include <linux/usb/of.h> 16 16 #include <linux/usb/otg.h> 17 17 #include <linux/of_platform.h> 18 + #include <linux/debugfs.h> 19 + #include "common.h" 18 20 19 21 static const char *const ep_type_names[] = { 20 22 [USB_ENDPOINT_XFER_CONTROL] = "ctrl", ··· 292 290 } 293 291 EXPORT_SYMBOL_GPL(usb_of_get_companion_dev); 294 292 #endif 293 + 294 + struct dentry *usb_debug_root; 295 + EXPORT_SYMBOL_GPL(usb_debug_root); 296 + 297 + static int __init usb_common_init(void) 298 + { 299 + usb_debug_root = debugfs_create_dir("usb", NULL); 300 + ledtrig_usb_init(); 301 + return 0; 302 + } 303 + 304 + static void __exit usb_common_exit(void) 305 + { 306 + ledtrig_usb_exit(); 307 + debugfs_remove_recursive(usb_debug_root); 308 + } 309 + 310 + subsys_initcall(usb_common_init); 311 + module_exit(usb_common_exit); 295 312 296 313 MODULE_LICENSE("GPL");
+14
drivers/usb/common/common.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + 3 + #ifndef __LINUX_USB_COMMON_H 4 + #define __LINUX_USB_COMMON_H 5 + 6 + #if defined(CONFIG_USB_LED_TRIG) 7 + void ledtrig_usb_init(void); 8 + void ledtrig_usb_exit(void); 9 + #else 10 + static inline void ledtrig_usb_init(void) { } 11 + static inline void ledtrig_usb_exit(void) { } 12 + #endif 13 + 14 + #endif /* __LINUX_USB_COMMON_H */
+3 -6
drivers/usb/common/led.c
··· 10 10 #include <linux/init.h> 11 11 #include <linux/leds.h> 12 12 #include <linux/usb.h> 13 + #include "common.h" 13 14 14 15 #define BLINK_DELAY 30 15 16 ··· 37 36 EXPORT_SYMBOL_GPL(usb_led_activity); 38 37 39 38 40 - static int __init ledtrig_usb_init(void) 39 + void __init ledtrig_usb_init(void) 41 40 { 42 41 led_trigger_register_simple("usb-gadget", &ledtrig_usb_gadget); 43 42 led_trigger_register_simple("usb-host", &ledtrig_usb_host); 44 - return 0; 45 43 } 46 44 47 - static void __exit ledtrig_usb_exit(void) 45 + void __exit ledtrig_usb_exit(void) 48 46 { 49 47 led_trigger_unregister_simple(ledtrig_usb_gadget); 50 48 led_trigger_unregister_simple(ledtrig_usb_host); 51 49 } 52 - 53 - module_init(ledtrig_usb_init); 54 - module_exit(ledtrig_usb_exit);
-1
drivers/usb/core/Kconfig
··· 45 45 config USB_OTG 46 46 bool "OTG support" 47 47 depends on PM 48 - default n 49 48 help 50 49 The most notable feature of USB OTG is support for a 51 50 "Dual-Role" device, which can act as either a device
+50 -21
drivers/usb/core/devio.c
··· 48 48 #define USB_DEVICE_MAX (USB_MAXBUS * 128) 49 49 #define USB_SG_SIZE 16384 /* split-size for large txs */ 50 50 51 - /* Mutual exclusion for removal, open, and release */ 52 - DEFINE_MUTEX(usbfs_mutex); 53 - 54 51 struct usb_dev_state { 55 52 struct list_head list; /* state list */ 56 53 struct usb_device *dev; ··· 974 977 975 978 ret = -ENODEV; 976 979 977 - /* Protect against simultaneous removal or release */ 978 - mutex_lock(&usbfs_mutex); 979 - 980 980 /* usbdev device-node */ 981 981 if (imajor(inode) == USB_DEVICE_MAJOR) 982 982 dev = usbdev_lookup_by_devt(inode->i_rdev); 983 - 984 - mutex_unlock(&usbfs_mutex); 985 - 986 983 if (!dev) 987 984 goto out_free_ps; 988 985 ··· 1297 1306 return 0; 1298 1307 } 1299 1308 1309 + static int proc_conninfo_ex(struct usb_dev_state *ps, 1310 + void __user *arg, size_t size) 1311 + { 1312 + struct usbdevfs_conninfo_ex ci; 1313 + struct usb_device *udev = ps->dev; 1314 + 1315 + if (size < sizeof(ci.size)) 1316 + return -EINVAL; 1317 + 1318 + memset(&ci, 0, sizeof(ci)); 1319 + ci.size = sizeof(ci); 1320 + ci.busnum = udev->bus->busnum; 1321 + ci.devnum = udev->devnum; 1322 + ci.speed = udev->speed; 1323 + 1324 + while (udev && udev->portnum != 0) { 1325 + if (++ci.num_ports <= ARRAY_SIZE(ci.ports)) 1326 + ci.ports[ARRAY_SIZE(ci.ports) - ci.num_ports] = 1327 + udev->portnum; 1328 + udev = udev->parent; 1329 + } 1330 + 1331 + if (ci.num_ports < ARRAY_SIZE(ci.ports)) 1332 + memmove(&ci.ports[0], 1333 + &ci.ports[ARRAY_SIZE(ci.ports) - ci.num_ports], 1334 + ci.num_ports); 1335 + 1336 + if (copy_to_user(arg, &ci, min(sizeof(ci), size))) 1337 + return -EFAULT; 1338 + 1339 + return 0; 1340 + } 1341 + 1300 1342 static int proc_resetdevice(struct usb_dev_state *ps) 1301 1343 { 1302 1344 struct usb_host_config *actconfig = ps->dev->actconfig; ··· 1508 1484 ret = -EFAULT; 1509 1485 goto error; 1510 1486 } 1511 - if (uurb->buffer_length < (le16_to_cpup(&dr->wLength) + 8)) { 1487 + if (uurb->buffer_length < (le16_to_cpu(dr->wLength) + 8)) { 1512 1488 ret = -EINVAL; 1513 1489 goto error; 1514 1490 } 1515 1491 ret = check_ctrlrecip(ps, dr->bRequestType, dr->bRequest, 1516 - le16_to_cpup(&dr->wIndex)); 1492 + le16_to_cpu(dr->wIndex)); 1517 1493 if (ret) 1518 1494 goto error; 1519 - uurb->buffer_length = le16_to_cpup(&dr->wLength); 1495 + uurb->buffer_length = le16_to_cpu(dr->wLength); 1520 1496 uurb->buffer += 8; 1521 1497 if ((dr->bRequestType & USB_DIR_IN) && uurb->buffer_length) { 1522 1498 is_in = 1; ··· 1531 1507 "bRequest=%02x wValue=%04x " 1532 1508 "wIndex=%04x wLength=%04x\n", 1533 1509 dr->bRequestType, dr->bRequest, 1534 - __le16_to_cpup(&dr->wValue), 1535 - __le16_to_cpup(&dr->wIndex), 1536 - __le16_to_cpup(&dr->wLength)); 1510 + __le16_to_cpu(dr->wValue), 1511 + __le16_to_cpu(dr->wIndex), 1512 + __le16_to_cpu(dr->wLength)); 1537 1513 u = sizeof(struct usb_ctrlrequest); 1538 1514 break; 1539 1515 ··· 2161 2137 if (ps->privileges_dropped) 2162 2138 return -EACCES; 2163 2139 2140 + if (!connected(ps)) 2141 + return -ENODEV; 2142 + 2164 2143 /* alloc buffer */ 2165 2144 size = _IOC_SIZE(ctl->ioctl_code); 2166 2145 if (size > 0) { ··· 2178 2151 } else { 2179 2152 memset(buf, 0, size); 2180 2153 } 2181 - } 2182 - 2183 - if (!connected(ps)) { 2184 - kfree(buf); 2185 - return -ENODEV; 2186 2154 } 2187 2155 2188 2156 if (ps->dev->state != USB_STATE_CONFIGURED) ··· 2281 2259 2282 2260 caps = USBDEVFS_CAP_ZERO_PACKET | USBDEVFS_CAP_NO_PACKET_SIZE_LIM | 2283 2261 USBDEVFS_CAP_REAP_AFTER_DISCONNECT | USBDEVFS_CAP_MMAP | 2284 - USBDEVFS_CAP_DROP_PRIVILEGES; 2262 + USBDEVFS_CAP_DROP_PRIVILEGES | USBDEVFS_CAP_CONNINFO_EX; 2285 2263 if (!ps->dev->bus->no_stop_on_short) 2286 2264 caps |= USBDEVFS_CAP_BULK_CONTINUATION; 2287 2265 if (ps->dev->bus->sg_tablesize) ··· 2577 2555 break; 2578 2556 case USBDEVFS_GET_SPEED: 2579 2557 ret = ps->dev->speed; 2558 + break; 2559 + } 2560 + 2561 + /* Handle variable-length commands */ 2562 + switch (cmd & ~IOCSIZE_MASK) { 2563 + case USBDEVFS_CONNINFO_EX(0): 2564 + ret = proc_conninfo_ex(ps, p, _IOC_SIZE(cmd)); 2580 2565 break; 2581 2566 } 2582 2567
+27 -18
drivers/usb/core/hub.c
··· 873 873 /* info that CLEAR_TT_BUFFER needs */ 874 874 clear->tt = tt->multi ? udev->ttport : 1; 875 875 clear->devinfo = usb_pipeendpoint (pipe); 876 - clear->devinfo |= udev->devnum << 4; 876 + clear->devinfo |= ((u16)udev->devaddr) << 4; 877 877 clear->devinfo |= usb_pipecontrol(pipe) 878 878 ? (USB_ENDPOINT_XFER_CONTROL << 11) 879 879 : (USB_ENDPOINT_XFER_BULK << 11); ··· 2125 2125 /* The address for a WUSB device is managed by wusbcore. */ 2126 2126 if (!udev->wusb) 2127 2127 udev->devnum = devnum; 2128 + if (!udev->devaddr) 2129 + udev->devaddr = (u8)devnum; 2128 2130 } 2129 2131 2130 2132 static void hub_free_dev(struct usb_device *udev) ··· 2721 2719 } 2722 2720 2723 2721 /* Is a USB 3.0 port in the Inactive or Compliance Mode state? 2724 - * Port worm reset is required to recover 2722 + * Port warm reset is required to recover 2725 2723 */ 2726 2724 static bool hub_port_warm_reset_required(struct usb_hub *hub, int port1, 2727 2725 u16 portstatus) ··· 3619 3617 struct usb_device *hdev; 3620 3618 struct usb_device *udev; 3621 3619 int connect_change = 0; 3620 + u16 link_state; 3622 3621 int ret; 3623 3622 3624 3623 hdev = hub->hdev; ··· 3629 3626 return 0; 3630 3627 usb_clear_port_feature(hdev, port, USB_PORT_FEAT_C_SUSPEND); 3631 3628 } else { 3629 + link_state = portstatus & USB_PORT_STAT_LINK_STATE; 3632 3630 if (!udev || udev->state != USB_STATE_SUSPENDED || 3633 - (portstatus & USB_PORT_STAT_LINK_STATE) != 3634 - USB_SS_PORT_LS_U0) 3631 + (link_state != USB_SS_PORT_LS_U0 && 3632 + link_state != USB_SS_PORT_LS_U1 && 3633 + link_state != USB_SS_PORT_LS_U2)) 3635 3634 return 0; 3636 3635 } 3637 3636 ··· 4004 3999 * control transfers to set the hub timeout or enable device-initiated U1/U2 4005 4000 * will be successful. 4006 4001 * 4002 + * If the control transfer to enable device-initiated U1/U2 entry fails, then 4003 + * hub-initiated U1/U2 will be disabled. 4004 + * 4007 4005 * If we cannot set the parent hub U1/U2 timeout, we attempt to let the xHCI 4008 4006 * driver know about it. If that call fails, it should be harmless, and just 4009 4007 * take up more slightly more bus bandwidth for unnecessary U1/U2 exit latency. ··· 4061 4053 * host know that this link state won't be enabled. 4062 4054 */ 4063 4055 hcd->driver->disable_usb3_lpm_timeout(hcd, udev, state); 4064 - } else { 4065 - /* Only a configured device will accept the Set Feature 4066 - * U1/U2_ENABLE 4067 - */ 4068 - if (udev->actconfig) 4069 - usb_set_device_initiated_lpm(udev, state, true); 4056 + return; 4057 + } 4070 4058 4071 - /* As soon as usb_set_lpm_timeout(timeout) returns 0, the 4072 - * hub-initiated LPM is enabled. Thus, LPM is enabled no 4073 - * matter the result of usb_set_device_initiated_lpm(). 4074 - * The only difference is whether device is able to initiate 4075 - * LPM. 4076 - */ 4059 + /* Only a configured device will accept the Set Feature 4060 + * U1/U2_ENABLE 4061 + */ 4062 + if (udev->actconfig && 4063 + usb_set_device_initiated_lpm(udev, state, true) == 0) { 4077 4064 if (state == USB3_LPM_U1) 4078 4065 udev->usb3_lpm_u1_enabled = 1; 4079 4066 else if (state == USB3_LPM_U2) 4080 4067 udev->usb3_lpm_u2_enabled = 1; 4068 + } else { 4069 + /* Don't request U1/U2 entry if the device 4070 + * cannot transition to U1/U2. 4071 + */ 4072 + usb_set_lpm_timeout(udev, state, 0); 4073 + hcd->driver->disable_usb3_lpm_timeout(hcd, udev, state); 4081 4074 } 4082 4075 } 4083 4076 ··· 4148 4139 if (!udev || !udev->parent || 4149 4140 udev->speed < USB_SPEED_SUPER || 4150 4141 !udev->lpm_capable || 4151 - udev->state < USB_STATE_DEFAULT) 4142 + udev->state < USB_STATE_CONFIGURED) 4152 4143 return 0; 4153 4144 4154 4145 hcd = bus_to_hcd(udev->bus); ··· 4207 4198 if (!udev || !udev->parent || 4208 4199 udev->speed < USB_SPEED_SUPER || 4209 4200 !udev->lpm_capable || 4210 - udev->state < USB_STATE_DEFAULT) 4201 + udev->state < USB_STATE_CONFIGURED) 4211 4202 return; 4212 4203 4213 4204 udev->lpm_disable_count--;
-3
drivers/usb/core/notify.c
··· 53 53 54 54 void usb_notify_remove_device(struct usb_device *udev) 55 55 { 56 - /* Protect against simultaneous usbfs open */ 57 - mutex_lock(&usbfs_mutex); 58 56 blocking_notifier_call_chain(&usb_notifier_list, 59 57 USB_DEVICE_REMOVE, udev); 60 - mutex_unlock(&usbfs_mutex); 61 58 } 62 59 63 60 void usb_notify_add_bus(struct usb_bus *ubus)
+4 -6
drivers/usb/core/usb.c
··· 1185 1185 .notifier_call = usb_bus_notify, 1186 1186 }; 1187 1187 1188 - struct dentry *usb_debug_root; 1189 - EXPORT_SYMBOL_GPL(usb_debug_root); 1188 + static struct dentry *usb_devices_root; 1190 1189 1191 1190 static void usb_debugfs_init(void) 1192 1191 { 1193 - usb_debug_root = debugfs_create_dir("usb", NULL); 1194 - debugfs_create_file("devices", 0444, usb_debug_root, NULL, 1195 - &usbfs_devices_fops); 1192 + usb_devices_root = debugfs_create_file("devices", 0444, usb_debug_root, 1193 + NULL, &usbfs_devices_fops); 1196 1194 } 1197 1195 1198 1196 static void usb_debugfs_cleanup(void) 1199 1197 { 1200 - debugfs_remove_recursive(usb_debug_root); 1198 + debugfs_remove(usb_devices_root); 1201 1199 } 1202 1200 1203 1201 /*
-1
drivers/usb/core/usb.h
··· 169 169 extern const struct attribute_group *usb_interface_groups[]; 170 170 171 171 /* usbfs stuff */ 172 - extern struct mutex usbfs_mutex; 173 172 extern struct usb_driver usbfs_driver; 174 173 extern const struct file_operations usbfs_devices_fops; 175 174 extern const struct file_operations usbdev_file_operations;
-1
drivers/usb/dwc2/Kconfig
··· 58 58 tristate "DWC2 PCI" 59 59 depends on USB_PCI 60 60 depends on USB_GADGET || !USB_GADGET 61 - default n 62 61 select NOP_USB_XCEIV 63 62 help 64 63 The Designware USB2.0 PCI interface module for controllers
+1 -1
drivers/usb/dwc2/core.c
··· 531 531 } 532 532 533 533 /* Wait for AHB master IDLE state */ 534 - if (dwc2_hsotg_wait_bit_set(hsotg, GRSTCTL, GRSTCTL_AHBIDLE, 50)) { 534 + if (dwc2_hsotg_wait_bit_set(hsotg, GRSTCTL, GRSTCTL_AHBIDLE, 10000)) { 535 535 dev_warn(hsotg->dev, "%s: HANG! AHB Idle timeout GRSTCTL GRSTCTL_AHBIDLE\n", 536 536 __func__); 537 537 return -EBUSY;
+8
drivers/usb/dwc2/core.h
··· 861 861 * @hibernated: True if core is hibernated 862 862 * @reset_phy_on_wake: Quirk saying that we should assert PHY reset on a 863 863 * remote wakeup. 864 + * @phy_off_for_suspend: Status of whether we turned the PHY off at suspend. 865 + * @need_phy_for_wake: Quirk saying that we should keep the PHY on at 866 + * suspend if we need USB to wake us up. 864 867 * @frame_number: Frame number read from the core. For both device 865 868 * and host modes. The value ranges are from 0 866 869 * to HFNUM_MAX_FRNUM. ··· 1052 1049 unsigned int ll_hw_enabled:1; 1053 1050 unsigned int hibernated:1; 1054 1051 unsigned int reset_phy_on_wake:1; 1052 + unsigned int need_phy_for_wake:1; 1053 + unsigned int phy_off_for_suspend:1; 1055 1054 u16 frame_number; 1056 1055 1057 1056 struct phy *phy; ··· 1443 1438 int dwc2_host_enter_hibernation(struct dwc2_hsotg *hsotg); 1444 1439 int dwc2_host_exit_hibernation(struct dwc2_hsotg *hsotg, 1445 1440 int rem_wakeup, int reset); 1441 + bool dwc2_host_can_poweroff_phy(struct dwc2_hsotg *dwc2); 1446 1442 static inline void dwc2_host_schedule_phy_reset(struct dwc2_hsotg *hsotg) 1447 1443 { schedule_work(&hsotg->phy_reset_work); } 1448 1444 #else ··· 1469 1463 static inline int dwc2_host_exit_hibernation(struct dwc2_hsotg *hsotg, 1470 1464 int rem_wakeup, int reset) 1471 1465 { return 0; } 1466 + static inline bool dwc2_host_can_poweroff_phy(struct dwc2_hsotg *dwc2) 1467 + { return false; } 1472 1468 static inline void dwc2_host_schedule_phy_reset(struct dwc2_hsotg *hsotg) {} 1473 1469 1474 1470 #endif
+19 -1
drivers/usb/dwc2/hcd.c
··· 4685 4685 spin_unlock_irqrestore(&hsotg->lock, flags); 4686 4686 urb->hcpriv = NULL; 4687 4687 kfree(qtd); 4688 - qtd = NULL; 4689 4688 fail1: 4690 4689 if (qh_allocated) { 4691 4690 struct dwc2_qtd *qtd2, *qtd2_tmp; ··· 5585 5586 hsotg->lx_state = DWC2_L0; 5586 5587 dev_dbg(hsotg->dev, "Host hibernation restore complete\n"); 5587 5588 return ret; 5589 + } 5590 + 5591 + bool dwc2_host_can_poweroff_phy(struct dwc2_hsotg *dwc2) 5592 + { 5593 + struct usb_device *root_hub = dwc2_hsotg_to_hcd(dwc2)->self.root_hub; 5594 + 5595 + /* If the controller isn't allowed to wakeup then we can power off. */ 5596 + if (!device_may_wakeup(dwc2->dev)) 5597 + return true; 5598 + 5599 + /* 5600 + * We don't want to power off the PHY if something under the 5601 + * root hub has wakeup enabled. 5602 + */ 5603 + if (usb_wakeup_enabled_descendants(root_hub)) 5604 + return false; 5605 + 5606 + /* No reason to keep the PHY powered, so allow poweroff */ 5607 + return true; 5588 5608 }
-1
drivers/usb/dwc2/hcd.h
··· 582 582 { 583 583 list_del(&qtd->qtd_list_entry); 584 584 kfree(qtd); 585 - qtd = NULL; 586 585 } 587 586 588 587 /* Descriptor DMA support functions */
+1
drivers/usb/dwc2/params.c
··· 76 76 struct dwc2_core_params *p = &hsotg->params; 77 77 78 78 p->power_down = 0; 79 + p->phy_utmi_width = 8; 79 80 } 80 81 81 82 static void dwc2_set_rk_params(struct dwc2_hsotg *hsotg)
+20 -3
drivers/usb/dwc2/platform.c
··· 438 438 if (retval) 439 439 goto error; 440 440 441 + hsotg->need_phy_for_wake = 442 + of_property_read_bool(dev->dev.of_node, 443 + "snps,need-phy-for-wake"); 444 + 441 445 /* 442 446 * Reset before dwc2_get_hwparams() then it could get power-on real 443 447 * reset value form registers. ··· 472 468 goto error; 473 469 hsotg->gadget_enabled = 1; 474 470 } 471 + 472 + /* 473 + * If we need PHY for wakeup we must be wakeup capable. 474 + * When we have a device that can wake without the PHY we 475 + * can adjust this condition. 476 + */ 477 + if (hsotg->need_phy_for_wake) 478 + device_set_wakeup_capable(&dev->dev, true); 475 479 476 480 hsotg->reset_phy_on_wake = 477 481 of_property_read_bool(dev->dev.of_node, ··· 519 507 static int __maybe_unused dwc2_suspend(struct device *dev) 520 508 { 521 509 struct dwc2_hsotg *dwc2 = dev_get_drvdata(dev); 510 + bool is_device_mode = dwc2_is_device_mode(dwc2); 522 511 int ret = 0; 523 512 524 - if (dwc2_is_device_mode(dwc2)) 513 + if (is_device_mode) 525 514 dwc2_hsotg_suspend(dwc2); 526 515 527 - if (dwc2->ll_hw_enabled) 516 + if (dwc2->ll_hw_enabled && 517 + (is_device_mode || dwc2_host_can_poweroff_phy(dwc2))) { 528 518 ret = __dwc2_lowlevel_hw_disable(dwc2); 519 + dwc2->phy_off_for_suspend = true; 520 + } 529 521 530 522 return ret; 531 523 } ··· 539 523 struct dwc2_hsotg *dwc2 = dev_get_drvdata(dev); 540 524 int ret = 0; 541 525 542 - if (dwc2->ll_hw_enabled) { 526 + if (dwc2->phy_off_for_suspend && dwc2->ll_hw_enabled) { 543 527 ret = __dwc2_lowlevel_hw_enable(dwc2); 544 528 if (ret) 545 529 return ret; 546 530 } 531 + dwc2->phy_off_for_suspend = false; 547 532 548 533 if (dwc2_is_device_mode(dwc2)) 549 534 ret = dwc2_hsotg_resume(dwc2);
+1 -1
drivers/usb/dwc3/Kconfig
··· 128 128 tristate "Qualcomm Platform" 129 129 depends on ARCH_QCOM || COMPILE_TEST 130 130 depends on EXTCON || !EXTCON 131 - depends on OF 131 + depends on (OF || ACPI) 132 132 default USB_DWC3 133 133 help 134 134 Some Qualcomm SoCs use DesignWare Core IP for USB2/3
+11 -5
drivers/usb/dwc3/core.c
··· 1282 1282 "snps,dis_u2_susphy_quirk"); 1283 1283 dwc->dis_enblslpm_quirk = device_property_read_bool(dev, 1284 1284 "snps,dis_enblslpm_quirk"); 1285 + dwc->dis_u1_entry_quirk = device_property_read_bool(dev, 1286 + "snps,dis-u1-entry-quirk"); 1287 + dwc->dis_u2_entry_quirk = device_property_read_bool(dev, 1288 + "snps,dis-u2-entry-quirk"); 1285 1289 dwc->dis_rxdet_inp3_quirk = device_property_read_bool(dev, 1286 1290 "snps,dis_rxdet_inp3_quirk"); 1287 1291 dwc->dis_u2_freeclk_exists_quirk = device_property_read_bool(dev, ··· 1427 1423 dwc->regs = regs; 1428 1424 dwc->regs_size = resource_size(&dwc_res); 1429 1425 1430 - if (!dwc3_core_is_valid(dwc)) { 1431 - dev_err(dwc->dev, "this is not a DesignWare USB3 DRD Core\n"); 1432 - return -ENODEV; 1433 - } 1434 - 1435 1426 dwc3_get_properties(dwc); 1436 1427 1437 1428 dwc->reset = devm_reset_control_get_optional_shared(dev, NULL); ··· 1458 1459 ret = clk_bulk_enable(dwc->num_clks, dwc->clks); 1459 1460 if (ret) 1460 1461 goto unprepare_clks; 1462 + 1463 + if (!dwc3_core_is_valid(dwc)) { 1464 + dev_err(dwc->dev, "this is not a DesignWare USB3 DRD Core\n"); 1465 + ret = -ENODEV; 1466 + goto disable_clks; 1467 + } 1461 1468 1462 1469 platform_set_drvdata(pdev, dwc); 1463 1470 dwc3_cache_hwparams(dwc); ··· 1530 1525 pm_runtime_put_sync(&pdev->dev); 1531 1526 pm_runtime_disable(&pdev->dev); 1532 1527 1528 + disable_clks: 1533 1529 clk_bulk_disable(dwc->num_clks, dwc->clks); 1534 1530 unprepare_clks: 1535 1531 clk_bulk_unprepare(dwc->num_clks, dwc->clks);
+4 -2
drivers/usb/dwc3/core.h
··· 649 649 * @cancelled_list: list of cancelled requests for this endpoint 650 650 * @pending_list: list of pending requests for this endpoint 651 651 * @started_list: list of started requests on this endpoint 652 - * @lock: spinlock for endpoint request queue traversal 653 652 * @regs: pointer to first endpoint register 654 653 * @trb_pool: array of transaction buffers 655 654 * @trb_pool_dma: dma address of @trb_pool ··· 676 677 struct list_head pending_list; 677 678 struct list_head started_list; 678 679 679 - spinlock_t lock; 680 680 void __iomem *regs; 681 681 682 682 struct dwc3_trb *trb_pool; ··· 1012 1014 * @dis_u2_susphy_quirk: set if we disable usb2 suspend phy 1013 1015 * @dis_enblslpm_quirk: set if we clear enblslpm in GUSB2PHYCFG, 1014 1016 * disabling the suspend signal to the PHY. 1017 + * @dis_u1_entry_quirk: set if link entering into U1 state needs to be disabled. 1018 + * @dis_u2_entry_quirk: set if link entering into U2 state needs to be disabled. 1015 1019 * @dis_rxdet_inp3_quirk: set if we disable Rx.Detect in P3 1016 1020 * @dis_u2_freeclk_exists_quirk : set if we clear u2_freeclk_exists 1017 1021 * in GUSB2PHYCFG, specify that USB2 PHY doesn't ··· 1205 1205 unsigned dis_u3_susphy_quirk:1; 1206 1206 unsigned dis_u2_susphy_quirk:1; 1207 1207 unsigned dis_enblslpm_quirk:1; 1208 + unsigned dis_u1_entry_quirk:1; 1209 + unsigned dis_u2_entry_quirk:1; 1208 1210 unsigned dis_rxdet_inp3_quirk:1; 1209 1211 unsigned dis_u2_freeclk_exists_quirk:1; 1210 1212 unsigned dis_del_phy_power_chg_quirk:1;
+31 -5
drivers/usb/dwc3/dwc3-meson-g12a.c
··· 11 11 * - Control registers for each USB2 Ports 12 12 * - Control registers for the USB PHY layer 13 13 * - SuperSpeed PHY can be enabled only if port is used 14 - * 15 - * TOFIX: 16 - * - Add dynamic OTG switching with ID change interrupt 14 + * - Dynamic OTG switching with ID change interrupt 17 15 */ 18 16 19 17 #include <linux/module.h> ··· 346 348 USB_ROLE_HOST : USB_ROLE_DEVICE; 347 349 } 348 350 351 + static irqreturn_t dwc3_meson_g12a_irq_thread(int irq, void *data) 352 + { 353 + struct dwc3_meson_g12a *priv = data; 354 + enum phy_mode otg_id; 355 + 356 + otg_id = dwc3_meson_g12a_get_id(priv); 357 + if (otg_id != priv->otg_phy_mode) { 358 + if (dwc3_meson_g12a_otg_mode_set(priv, otg_id)) 359 + dev_warn(priv->dev, "Failed to switch OTG mode\n"); 360 + } 361 + 362 + regmap_update_bits(priv->regmap, USB_R5, USB_R5_ID_DIG_IRQ, 0); 363 + 364 + return IRQ_HANDLED; 365 + } 366 + 349 367 static struct device *dwc3_meson_g12_find_child(struct device *dev, 350 368 const char *compatible) 351 369 { ··· 388 374 void __iomem *base; 389 375 struct resource *res; 390 376 enum phy_mode otg_id; 391 - int ret, i; 377 + int ret, i, irq; 392 378 393 379 priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); 394 380 if (!priv) ··· 450 436 /* Get dr_mode */ 451 437 priv->otg_mode = usb_get_dr_mode(dev); 452 438 439 + if (priv->otg_mode == USB_DR_MODE_OTG) { 440 + /* Ack irq before registering */ 441 + regmap_update_bits(priv->regmap, USB_R5, 442 + USB_R5_ID_DIG_IRQ, 0); 443 + 444 + irq = platform_get_irq(pdev, 0); 445 + ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, 446 + dwc3_meson_g12a_irq_thread, 447 + IRQF_ONESHOT, pdev->name, priv); 448 + if (ret) 449 + return ret; 450 + } 451 + 453 452 dwc3_meson_g12a_usb_init(priv); 454 453 455 454 /* Init PHYs */ ··· 487 460 488 461 /* Setup OTG mode corresponding to the ID pin */ 489 462 if (priv->otg_mode == USB_DR_MODE_OTG) { 490 - /* TOFIX Handle ID mode toggling via IRQ */ 491 463 otg_id = dwc3_meson_g12a_get_id(priv); 492 464 if (otg_id != priv->otg_phy_mode) { 493 465 if (dwc3_meson_g12a_otg_mode_set(priv, otg_id))
+8
drivers/usb/dwc3/dwc3-pci.c
··· 34 34 #define PCI_DEVICE_ID_INTEL_CNPLP 0x9dee 35 35 #define PCI_DEVICE_ID_INTEL_CNPH 0xa36e 36 36 #define PCI_DEVICE_ID_INTEL_ICLLP 0x34ee 37 + #define PCI_DEVICE_ID_INTEL_EHLLP 0x4b7e 38 + #define PCI_DEVICE_ID_INTEL_TGPLP 0xa0ee 37 39 38 40 #define PCI_INTEL_BXT_DSM_GUID "732b85d5-b7a7-4a1b-9ba0-4bbd00ffd511" 39 41 #define PCI_INTEL_BXT_FUNC_PMU_PWR 4 ··· 339 337 (kernel_ulong_t) &dwc3_pci_intel_properties, }, 340 338 341 339 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_ICLLP), 340 + (kernel_ulong_t) &dwc3_pci_intel_properties, }, 341 + 342 + { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_EHLLP), 343 + (kernel_ulong_t) &dwc3_pci_intel_properties, }, 344 + 345 + { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_TGPLP), 342 346 (kernel_ulong_t) &dwc3_pci_intel_properties, }, 343 347 344 348 { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_NL_USB),
+194 -30
drivers/usb/dwc3/dwc3-qcom.c
··· 4 4 * Inspired by dwc3-of-simple.c 5 5 */ 6 6 7 + #include <linux/acpi.h> 7 8 #include <linux/io.h> 8 9 #include <linux/of.h> 9 10 #include <linux/clk.h> ··· 39 38 #define PWR_EVNT_LPM_IN_L2_MASK BIT(4) 40 39 #define PWR_EVNT_LPM_OUT_L2_MASK BIT(5) 41 40 41 + #define SDM845_QSCRATCH_BASE_OFFSET 0xf8800 42 + #define SDM845_QSCRATCH_SIZE 0x400 43 + #define SDM845_DWC3_CORE_SIZE 0xcd00 44 + 45 + struct dwc3_acpi_pdata { 46 + u32 qscratch_base_offset; 47 + u32 qscratch_base_size; 48 + u32 dwc3_core_base_size; 49 + int hs_phy_irq_index; 50 + int dp_hs_phy_irq_index; 51 + int dm_hs_phy_irq_index; 52 + int ss_phy_irq_index; 53 + }; 54 + 42 55 struct dwc3_qcom { 43 56 struct device *dev; 44 57 void __iomem *qscratch_base; ··· 70 55 struct extcon_dev *host_edev; 71 56 struct notifier_block vbus_nb; 72 57 struct notifier_block host_nb; 58 + 59 + const struct dwc3_acpi_pdata *acpi_pdata; 73 60 74 61 enum usb_dr_mode mode; 75 62 bool is_suspended; ··· 317 300 PIPE_UTMI_CLK_DIS); 318 301 } 319 302 303 + static int dwc3_qcom_get_irq(struct platform_device *pdev, 304 + const char *name, int num) 305 + { 306 + struct device_node *np = pdev->dev.of_node; 307 + int ret; 308 + 309 + if (np) 310 + ret = platform_get_irq_byname(pdev, name); 311 + else 312 + ret = platform_get_irq(pdev, num); 313 + 314 + return ret; 315 + } 316 + 320 317 static int dwc3_qcom_setup_irq(struct platform_device *pdev) 321 318 { 322 319 struct dwc3_qcom *qcom = platform_get_drvdata(pdev); 320 + const struct dwc3_acpi_pdata *pdata = qcom->acpi_pdata; 323 321 int irq, ret; 324 - 325 - irq = platform_get_irq_byname(pdev, "hs_phy_irq"); 322 + irq = dwc3_qcom_get_irq(pdev, "hs_phy_irq", 323 + pdata ? pdata->hs_phy_irq_index : -1); 326 324 if (irq > 0) { 327 325 /* Keep wakeup interrupts disabled until suspend */ 328 326 irq_set_status_flags(irq, IRQ_NOAUTOEN); ··· 352 320 qcom->hs_phy_irq = irq; 353 321 } 354 322 355 - irq = platform_get_irq_byname(pdev, "dp_hs_phy_irq"); 323 + irq = dwc3_qcom_get_irq(pdev, "dp_hs_phy_irq", 324 + pdata ? pdata->dp_hs_phy_irq_index : -1); 356 325 if (irq > 0) { 357 326 irq_set_status_flags(irq, IRQ_NOAUTOEN); 358 327 ret = devm_request_threaded_irq(qcom->dev, irq, NULL, ··· 367 334 qcom->dp_hs_phy_irq = irq; 368 335 } 369 336 370 - irq = platform_get_irq_byname(pdev, "dm_hs_phy_irq"); 337 + irq = dwc3_qcom_get_irq(pdev, "dm_hs_phy_irq", 338 + pdata ? pdata->dm_hs_phy_irq_index : -1); 371 339 if (irq > 0) { 372 340 irq_set_status_flags(irq, IRQ_NOAUTOEN); 373 341 ret = devm_request_threaded_irq(qcom->dev, irq, NULL, ··· 382 348 qcom->dm_hs_phy_irq = irq; 383 349 } 384 350 385 - irq = platform_get_irq_byname(pdev, "ss_phy_irq"); 351 + irq = dwc3_qcom_get_irq(pdev, "ss_phy_irq", 352 + pdata ? pdata->ss_phy_irq_index : -1); 386 353 if (irq > 0) { 387 354 irq_set_status_flags(irq, IRQ_NOAUTOEN); 388 355 ret = devm_request_threaded_irq(qcom->dev, irq, NULL, ··· 406 371 struct device_node *np = dev->of_node; 407 372 int i; 408 373 409 - qcom->num_clocks = count; 410 - 411 - if (!count) 374 + if (!np || !count) 412 375 return 0; 376 + 377 + if (count < 0) 378 + return count; 379 + 380 + qcom->num_clocks = count; 413 381 414 382 qcom->clks = devm_kcalloc(dev, qcom->num_clocks, 415 383 sizeof(struct clk *), GFP_KERNEL); ··· 447 409 return 0; 448 410 } 449 411 450 - static int dwc3_qcom_probe(struct platform_device *pdev) 412 + static const struct property_entry dwc3_qcom_acpi_properties[] = { 413 + PROPERTY_ENTRY_STRING("dr_mode", "host"), 414 + {} 415 + }; 416 + 417 + static int dwc3_qcom_acpi_register_core(struct platform_device *pdev) 451 418 { 419 + struct dwc3_qcom *qcom = platform_get_drvdata(pdev); 420 + struct device *dev = &pdev->dev; 421 + struct resource *res, *child_res = NULL; 422 + int irq; 423 + int ret; 424 + 425 + qcom->dwc3 = platform_device_alloc("dwc3", PLATFORM_DEVID_AUTO); 426 + if (!qcom->dwc3) 427 + return -ENOMEM; 428 + 429 + qcom->dwc3->dev.parent = dev; 430 + qcom->dwc3->dev.type = dev->type; 431 + qcom->dwc3->dev.dma_mask = dev->dma_mask; 432 + qcom->dwc3->dev.dma_parms = dev->dma_parms; 433 + qcom->dwc3->dev.coherent_dma_mask = dev->coherent_dma_mask; 434 + 435 + child_res = kcalloc(2, sizeof(*child_res), GFP_KERNEL); 436 + if (!child_res) 437 + return -ENOMEM; 438 + 439 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 440 + if (!res) { 441 + dev_err(&pdev->dev, "failed to get memory resource\n"); 442 + ret = -ENODEV; 443 + goto out; 444 + } 445 + 446 + child_res[0].flags = res->flags; 447 + child_res[0].start = res->start; 448 + child_res[0].end = child_res[0].start + 449 + qcom->acpi_pdata->dwc3_core_base_size; 450 + 451 + irq = platform_get_irq(pdev, 0); 452 + child_res[1].flags = IORESOURCE_IRQ; 453 + child_res[1].start = child_res[1].end = irq; 454 + 455 + ret = platform_device_add_resources(qcom->dwc3, child_res, 2); 456 + if (ret) { 457 + dev_err(&pdev->dev, "failed to add resources\n"); 458 + goto out; 459 + } 460 + 461 + ret = platform_device_add_properties(qcom->dwc3, 462 + dwc3_qcom_acpi_properties); 463 + if (ret < 0) { 464 + dev_err(&pdev->dev, "failed to add properties\n"); 465 + goto out; 466 + } 467 + 468 + ret = platform_device_add(qcom->dwc3); 469 + if (ret) 470 + dev_err(&pdev->dev, "failed to add device\n"); 471 + 472 + out: 473 + kfree(child_res); 474 + return ret; 475 + } 476 + 477 + static int dwc3_qcom_of_register_core(struct platform_device *pdev) 478 + { 479 + struct dwc3_qcom *qcom = platform_get_drvdata(pdev); 452 480 struct device_node *np = pdev->dev.of_node, *dwc3_np; 453 481 struct device *dev = &pdev->dev; 482 + int ret; 483 + 484 + dwc3_np = of_get_child_by_name(np, "dwc3"); 485 + if (!dwc3_np) { 486 + dev_err(dev, "failed to find dwc3 core child\n"); 487 + return -ENODEV; 488 + } 489 + 490 + ret = of_platform_populate(np, NULL, NULL, dev); 491 + if (ret) { 492 + dev_err(dev, "failed to register dwc3 core - %d\n", ret); 493 + return ret; 494 + } 495 + 496 + qcom->dwc3 = of_find_device_by_node(dwc3_np); 497 + if (!qcom->dwc3) { 498 + dev_err(dev, "failed to get dwc3 platform device\n"); 499 + return -ENODEV; 500 + } 501 + 502 + return 0; 503 + } 504 + 505 + static const struct dwc3_acpi_pdata sdm845_acpi_pdata = { 506 + .qscratch_base_offset = SDM845_QSCRATCH_BASE_OFFSET, 507 + .qscratch_base_size = SDM845_QSCRATCH_SIZE, 508 + .dwc3_core_base_size = SDM845_DWC3_CORE_SIZE, 509 + .hs_phy_irq_index = 1, 510 + .dp_hs_phy_irq_index = 4, 511 + .dm_hs_phy_irq_index = 3, 512 + .ss_phy_irq_index = 2 513 + }; 514 + 515 + static int dwc3_qcom_probe(struct platform_device *pdev) 516 + { 517 + struct device_node *np = pdev->dev.of_node; 518 + struct device *dev = &pdev->dev; 454 519 struct dwc3_qcom *qcom; 455 - struct resource *res; 520 + struct resource *res, *parent_res = NULL; 456 521 int ret, i; 457 522 bool ignore_pipe_clk; 458 523 ··· 565 424 566 425 platform_set_drvdata(pdev, qcom); 567 426 qcom->dev = &pdev->dev; 427 + 428 + if (has_acpi_companion(dev)) { 429 + qcom->acpi_pdata = acpi_device_get_match_data(dev); 430 + if (!qcom->acpi_pdata) { 431 + dev_err(&pdev->dev, "no supporting ACPI device data\n"); 432 + return -EINVAL; 433 + } 434 + } 568 435 569 436 qcom->resets = devm_reset_control_array_get_optional_exclusive(dev); 570 437 if (IS_ERR(qcom->resets)) { ··· 595 446 goto reset_assert; 596 447 } 597 448 598 - ret = dwc3_qcom_clk_init(qcom, of_count_phandle_with_args(np, 599 - "clocks", "#clock-cells")); 449 + ret = dwc3_qcom_clk_init(qcom, of_clk_get_parent_count(np)); 600 450 if (ret) { 601 451 dev_err(dev, "failed to get clocks\n"); 602 452 goto reset_assert; 603 453 } 604 454 605 455 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 606 - qcom->qscratch_base = devm_ioremap_resource(dev, res); 456 + 457 + if (np) { 458 + parent_res = res; 459 + } else { 460 + parent_res = kmemdup(res, sizeof(struct resource), GFP_KERNEL); 461 + if (!parent_res) 462 + return -ENOMEM; 463 + 464 + parent_res->start = res->start + 465 + qcom->acpi_pdata->qscratch_base_offset; 466 + parent_res->end = parent_res->start + 467 + qcom->acpi_pdata->qscratch_base_size; 468 + } 469 + 470 + qcom->qscratch_base = devm_ioremap_resource(dev, parent_res); 607 471 if (IS_ERR(qcom->qscratch_base)) { 608 472 dev_err(dev, "failed to map qscratch, err=%d\n", ret); 609 473 ret = PTR_ERR(qcom->qscratch_base); ··· 624 462 } 625 463 626 464 ret = dwc3_qcom_setup_irq(pdev); 627 - if (ret) 628 - goto clk_disable; 629 - 630 - dwc3_np = of_get_child_by_name(np, "dwc3"); 631 - if (!dwc3_np) { 632 - dev_err(dev, "failed to find dwc3 core child\n"); 633 - ret = -ENODEV; 465 + if (ret) { 466 + dev_err(dev, "failed to setup IRQs, err=%d\n", ret); 634 467 goto clk_disable; 635 468 } 636 469 ··· 638 481 if (ignore_pipe_clk) 639 482 dwc3_qcom_select_utmi_clk(qcom); 640 483 641 - ret = of_platform_populate(np, NULL, NULL, dev); 642 - if (ret) { 643 - dev_err(dev, "failed to register dwc3 core - %d\n", ret); 644 - goto clk_disable; 645 - } 484 + if (np) 485 + ret = dwc3_qcom_of_register_core(pdev); 486 + else 487 + ret = dwc3_qcom_acpi_register_core(pdev); 646 488 647 - qcom->dwc3 = of_find_device_by_node(dwc3_np); 648 - if (!qcom->dwc3) { 649 - dev_err(&pdev->dev, "failed to get dwc3 platform device\n"); 650 - ret = -ENODEV; 489 + if (ret) { 490 + dev_err(dev, "failed to register DWC3 Core, err=%d\n", ret); 651 491 goto depopulate; 652 492 } 653 493 ··· 668 514 return 0; 669 515 670 516 depopulate: 671 - of_platform_depopulate(&pdev->dev); 517 + if (np) 518 + of_platform_depopulate(&pdev->dev); 519 + else 520 + platform_device_put(pdev); 672 521 clk_disable: 673 522 for (i = qcom->num_clocks - 1; i >= 0; i--) { 674 523 clk_disable_unprepare(qcom->clks[i]); ··· 758 601 }; 759 602 MODULE_DEVICE_TABLE(of, dwc3_qcom_of_match); 760 603 604 + static const struct acpi_device_id dwc3_qcom_acpi_match[] = { 605 + { "QCOM2430", (unsigned long)&sdm845_acpi_pdata }, 606 + { }, 607 + }; 608 + MODULE_DEVICE_TABLE(acpi, dwc3_qcom_acpi_match); 609 + 761 610 static struct platform_driver dwc3_qcom_driver = { 762 611 .probe = dwc3_qcom_probe, 763 612 .remove = dwc3_qcom_remove, ··· 771 608 .name = "dwc3-qcom", 772 609 .pm = &dwc3_qcom_dev_pm_ops, 773 610 .of_match_table = dwc3_qcom_of_match, 611 + .acpi_match_table = ACPI_PTR(dwc3_qcom_acpi_match), 774 612 }, 775 613 }; 776 614
+8 -1
drivers/usb/dwc3/ep0.c
··· 379 379 if ((dwc->speed != DWC3_DSTS_SUPERSPEED) && 380 380 (dwc->speed != DWC3_DSTS_SUPERSPEED_PLUS)) 381 381 return -EINVAL; 382 + if (set && dwc->dis_u1_entry_quirk) 383 + return -EINVAL; 382 384 383 385 reg = dwc3_readl(dwc->regs, DWC3_DCTL); 384 386 if (set) ··· 402 400 return -EINVAL; 403 401 if ((dwc->speed != DWC3_DSTS_SUPERSPEED) && 404 402 (dwc->speed != DWC3_DSTS_SUPERSPEED_PLUS)) 403 + return -EINVAL; 404 + if (set && dwc->dis_u2_entry_quirk) 405 405 return -EINVAL; 406 406 407 407 reg = dwc3_readl(dwc->regs, DWC3_DCTL); ··· 630 626 * nothing is pending from application. 631 627 */ 632 628 reg = dwc3_readl(dwc->regs, DWC3_DCTL); 633 - reg |= (DWC3_DCTL_ACCEPTU1ENA | DWC3_DCTL_ACCEPTU2ENA); 629 + if (!dwc->dis_u1_entry_quirk) 630 + reg |= DWC3_DCTL_ACCEPTU1ENA; 631 + if (!dwc->dis_u2_entry_quirk) 632 + reg |= DWC3_DCTL_ACCEPTU2ENA; 634 633 dwc3_writel(dwc->regs, DWC3_DCTL, reg); 635 634 } 636 635 break;
+20 -2
drivers/usb/dwc3/gadget.c
··· 2073 2073 return 0; 2074 2074 } 2075 2075 2076 + static void dwc3_gadget_config_params(struct usb_gadget *g, 2077 + struct usb_dcd_config_params *params) 2078 + { 2079 + struct dwc3 *dwc = gadget_to_dwc(g); 2080 + 2081 + /* U1 Device exit Latency */ 2082 + if (dwc->dis_u1_entry_quirk) 2083 + params->bU1devExitLat = 0; 2084 + else 2085 + params->bU1devExitLat = DWC3_DEFAULT_U1_DEV_EXIT_LAT; 2086 + 2087 + /* U2 Device exit Latency */ 2088 + if (dwc->dis_u2_entry_quirk) 2089 + params->bU2DevExitLat = 0; 2090 + else 2091 + params->bU2DevExitLat = 2092 + cpu_to_le16(DWC3_DEFAULT_U2_DEV_EXIT_LAT); 2093 + } 2094 + 2076 2095 static void dwc3_gadget_set_speed(struct usb_gadget *g, 2077 2096 enum usb_device_speed speed) 2078 2097 { ··· 2161 2142 .udc_start = dwc3_gadget_start, 2162 2143 .udc_stop = dwc3_gadget_stop, 2163 2144 .udc_set_speed = dwc3_gadget_set_speed, 2145 + .get_config_params = dwc3_gadget_config_params, 2164 2146 }; 2165 2147 2166 2148 /* -------------------------------------------------------------------------- */ ··· 2270 2250 dep->endpoint.desc = &dwc3_gadget_ep0_desc; 2271 2251 dep->endpoint.comp_desc = NULL; 2272 2252 } 2273 - 2274 - spin_lock_init(&dep->lock); 2275 2253 2276 2254 if (num == 0) 2277 2255 ret = dwc3_gadget_init_control_endpoint(dep);
+6
drivers/usb/dwc3/gadget.h
··· 48 48 /* DEPXFERCFG parameter 0 */ 49 49 #define DWC3_DEPXFERCFG_NUM_XFER_RES(n) ((n) & 0xffff) 50 50 51 + /* U1 Device exit Latency */ 52 + #define DWC3_DEFAULT_U1_DEV_EXIT_LAT 0x0A /* Less then 10 microsec */ 53 + 54 + /* U2 Device exit Latency */ 55 + #define DWC3_DEFAULT_U2_DEV_EXIT_LAT 0x1FF /* Less then 511 microsec */ 56 + 51 57 /* -------------------------------------------------------------------------- */ 52 58 53 59 #define to_dwc3_request(r) (container_of(r, struct dwc3_request, request))
+3 -3
drivers/usb/gadget/Kconfig
··· 228 228 specified simply by creating appropriate directories in configfs. 229 229 Associating functions with configurations is done by creating 230 230 appropriate symbolic links. 231 - For more information see Documentation/usb/gadget_configfs.txt. 231 + For more information see Documentation/usb/gadget_configfs.rst. 232 232 233 233 config USB_CONFIGFS_SERIAL 234 234 bool "Generic serial bulk in/out" ··· 441 441 The HID function driver provides generic emulation of USB 442 442 Human Interface Devices (HID). 443 443 444 - For more information, see Documentation/usb/gadget_hid.txt. 444 + For more information, see Documentation/usb/gadget_hid.rst. 445 445 446 446 config USB_CONFIGFS_F_UVC 447 447 bool "USB Webcam function" ··· 466 466 receive or send printer data. It can use ioctl calls to 467 467 the device file to get or set printer status. 468 468 469 - For more information, see Documentation/usb/gadget_printer.txt 469 + For more information, see Documentation/usb/gadget_printer.rst 470 470 which includes sample code for accessing the device file. 471 471 472 472 config USB_CONFIGFS_F_TCM
+1 -1
drivers/usb/gadget/composite.c
··· 653 653 654 654 /* Get Controller configuration */ 655 655 if (cdev->gadget->ops->get_config_params) { 656 - cdev->gadget->ops->get_config_params( 656 + cdev->gadget->ops->get_config_params(cdev->gadget, 657 657 &dcd_config_params); 658 658 } else { 659 659 dcd_config_params.bU1devExitLat =
+1 -2
drivers/usb/gadget/function/f_eem.c
··· 166 166 static int eem_setup(struct usb_function *f, const struct usb_ctrlrequest *ctrl) 167 167 { 168 168 struct usb_composite_dev *cdev = f->config->cdev; 169 - int value = -EOPNOTSUPP; 170 169 u16 w_index = le16_to_cpu(ctrl->wIndex); 171 170 u16 w_value = le16_to_cpu(ctrl->wValue); 172 171 u16 w_length = le16_to_cpu(ctrl->wLength); ··· 175 176 w_value, w_index, w_length); 176 177 177 178 /* device either stalls (value < 0) or reports success */ 178 - return value; 179 + return -EOPNOTSUPP; 179 180 } 180 181 181 182
+6 -3
drivers/usb/gadget/function/f_fs.c
··· 997 997 * earlier 998 998 */ 999 999 gadget = epfile->ffs->gadget; 1000 - io_data->use_sg = gadget->sg_supported && data_len > PAGE_SIZE; 1001 1000 1002 1001 spin_lock_irq(&epfile->ffs->eps_lock); 1003 1002 /* In the meantime, endpoint got disabled or changed. */ ··· 1011 1012 */ 1012 1013 if (io_data->read) 1013 1014 data_len = usb_ep_align_maybe(gadget, ep->ep, data_len); 1015 + 1016 + io_data->use_sg = gadget->sg_supported && data_len > PAGE_SIZE; 1014 1017 spin_unlock_irq(&epfile->ffs->eps_lock); 1015 1018 1016 1019 data = ffs_alloc_buffer(io_data, data_len); ··· 1183 1182 ENTER(); 1184 1183 1185 1184 if (!is_sync_kiocb(kiocb)) { 1186 - p = kmalloc(sizeof(io_data), GFP_KERNEL); 1185 + p = kzalloc(sizeof(io_data), GFP_KERNEL); 1187 1186 if (unlikely(!p)) 1188 1187 return -ENOMEM; 1189 1188 p->aio = true; 1190 1189 } else { 1190 + memset(p, 0, sizeof(*p)); 1191 1191 p->aio = false; 1192 1192 } 1193 1193 ··· 1220 1218 ENTER(); 1221 1219 1222 1220 if (!is_sync_kiocb(kiocb)) { 1223 - p = kmalloc(sizeof(io_data), GFP_KERNEL); 1221 + p = kzalloc(sizeof(io_data), GFP_KERNEL); 1224 1222 if (unlikely(!p)) 1225 1223 return -ENOMEM; 1226 1224 p->aio = true; 1227 1225 } else { 1226 + memset(p, 0, sizeof(*p)); 1228 1227 p->aio = false; 1229 1228 } 1230 1229
+1 -1
drivers/usb/gadget/function/f_mass_storage.c
··· 47 47 * 48 48 * For more information about MSF and in particular its module 49 49 * parameters and sysfs interface read the 50 - * <Documentation/usb/mass-storage.txt> file. 50 + * <Documentation/usb/mass-storage.rst> file. 51 51 */ 52 52 53 53 /*
+2 -2
drivers/usb/gadget/function/u_audio.c
··· 40 40 41 41 void *rbuf; 42 42 43 - unsigned max_psize; /* MaxPacketSize of endpoint */ 43 + unsigned int max_psize; /* MaxPacketSize of endpoint */ 44 44 struct uac_req *ureq; 45 45 46 46 spinlock_t lock; ··· 78 78 79 79 static void u_audio_iso_complete(struct usb_ep *ep, struct usb_request *req) 80 80 { 81 - unsigned pending; 81 + unsigned int pending; 82 82 unsigned long flags, flags2; 83 83 unsigned int hw_ptr; 84 84 int status = req->status;
+6 -4
drivers/usb/gadget/function/u_ether.c
··· 186 186 out = dev->port_usb->out_ep; 187 187 else 188 188 out = NULL; 189 - spin_unlock_irqrestore(&dev->lock, flags); 190 189 191 190 if (!out) 191 + { 192 + spin_unlock_irqrestore(&dev->lock, flags); 192 193 return -ENOTCONN; 193 - 194 + } 194 195 195 196 /* Padding up to RX_EXTRA handles minor disagreements with host. 196 197 * Normally we use the USB "terminate on short read" convention; ··· 215 214 216 215 if (dev->port_usb->is_fixed) 217 216 size = max_t(size_t, size, dev->port_usb->fixed_out_len); 217 + spin_unlock_irqrestore(&dev->lock, flags); 218 218 219 219 skb = __netdev_alloc_skb(dev->net, size + NET_IP_ALIGN, gfp_flags); 220 220 if (skb == NULL) { ··· 1006 1004 int ret; 1007 1005 1008 1006 rtnl_lock(); 1009 - ret = snprintf(name, len, "%s\n", netdev_name(net)); 1007 + ret = scnprintf(name, len, "%s\n", netdev_name(net)); 1010 1008 rtnl_unlock(); 1011 - return ret < len ? ret : len; 1009 + return ret; 1012 1010 } 1013 1011 EXPORT_SYMBOL_GPL(gether_get_ifname); 1014 1012
+3 -5
drivers/usb/gadget/legacy/Kconfig
··· 153 153 depends on USB_ETH 154 154 select USB_LIBCOMPOSITE 155 155 select USB_F_EEM 156 - default n 157 156 help 158 157 CDC EEM is a newer USB standard that is somewhat simpler than CDC ECM 159 158 and therefore can be supported by more hardware. Technically ECM and ··· 287 288 Say "y" to link the driver statically, or "m" to build a 288 289 dynamically linked module called "g_serial". 289 290 290 - For more information, see Documentation/usb/gadget_serial.txt 291 + For more information, see Documentation/usb/gadget_serial.rst 291 292 which includes instructions and a "driver info file" needed to 292 293 make MS-Windows work with CDC ACM. 293 294 ··· 321 322 Say "y" to link the driver statically, or "m" to build a 322 323 dynamically linked module called "g_printer". 323 324 324 - For more information, see Documentation/usb/gadget_printer.txt 325 + For more information, see Documentation/usb/gadget_printer.rst 325 326 which includes sample code for accessing the device file. 326 327 327 328 if TTY ··· 418 419 config USB_G_MULTI_CDC 419 420 bool "CDC Ethernet + CDC Serial + Storage configuration" 420 421 depends on USB_G_MULTI 421 - default n 422 422 select USB_F_ECM 423 423 help 424 424 This option enables a configuration with CDC Ethernet (ECM), CDC ··· 436 438 The HID gadget driver provides generic emulation of USB 437 439 Human Interface Devices (HID). 438 440 439 - For more information, see Documentation/usb/gadget_hid.txt which 441 + For more information, see Documentation/usb/gadget_hid.rst which 440 442 includes sample code for accessing the device files. 441 443 442 444 Say "y" to link the driver statically, or "m" to build a
+1 -2
drivers/usb/gadget/udc/at91_udc.c
··· 799 799 { 800 800 struct at91_udc *udc = to_udc(gadget); 801 801 u32 glbstate; 802 - int status = -EINVAL; 803 802 unsigned long flags; 804 803 805 804 DBG("%s\n", __func__ ); ··· 817 818 818 819 done: 819 820 spin_unlock_irqrestore(&udc->lock, flags); 820 - return status; 821 + return 0; 821 822 } 822 823 823 824 /* reinit == restore initial software state */
+1 -2
drivers/usb/gadget/udc/fotg210-udc.c
··· 481 481 struct fotg210_ep *ep; 482 482 struct fotg210_udc *fotg210; 483 483 unsigned long flags; 484 - int ret = 0; 485 484 486 485 ep = container_of(_ep, struct fotg210_ep, ep); 487 486 ··· 503 504 } 504 505 505 506 spin_unlock_irqrestore(&ep->fotg210->lock, flags); 506 - return ret; 507 + return 0; 507 508 } 508 509 509 510 static int fotg210_ep_set_halt(struct usb_ep *_ep, int value)
-5
drivers/usb/gadget/udc/net2272.c
··· 1178 1178 size = PAGE_SIZE; 1179 1179 spin_lock_irqsave(&dev->lock, flags); 1180 1180 1181 - if (dev->driver) 1182 - s = dev->driver->driver.name; 1183 - else 1184 - s = "(none)"; 1185 - 1186 1181 /* Main Control Registers */ 1187 1182 t = scnprintf(next, size, "%s version %s," 1188 1183 "chiprev %02x, locctl %02x\n"
+1 -2
drivers/usb/gadget/udc/omap_udc.c
··· 2103 2103 static int omap_udc_stop(struct usb_gadget *g) 2104 2104 { 2105 2105 unsigned long flags; 2106 - int status = -ENODEV; 2107 2106 2108 2107 if (udc->dc_clk != NULL) 2109 2108 omap_udc_enable_clock(1); ··· 2124 2125 if (udc->dc_clk != NULL) 2125 2126 omap_udc_enable_clock(0); 2126 2127 2127 - return status; 2128 + return 0; 2128 2129 } 2129 2130 2130 2131 /*-------------------------------------------------------------------------*/
+85 -8
drivers/usb/gadget/udc/renesas_usb3.c
··· 351 351 int disabled_count; 352 352 353 353 struct usb_request *ep0_req; 354 + 355 + enum usb_role connection_state; 354 356 u16 test_mode; 355 357 u8 ep0_buf[USB3_EP0_BUF_SIZE]; 356 358 bool softconnect; ··· 361 359 bool extcon_usb; /* check vbus and set EXTCON_USB */ 362 360 bool forced_b_device; 363 361 bool start_to_connect; 362 + bool role_sw_by_connector; 364 363 }; 365 364 366 365 #define gadget_to_renesas_usb3(_gadget) \ ··· 702 699 unsigned long flags; 703 700 704 701 spin_lock_irqsave(&usb3->lock, flags); 705 - usb3_set_mode_by_role_sw(usb3, host); 706 - usb3_vbus_out(usb3, a_dev); 702 + if (!usb3->role_sw_by_connector || 703 + usb3->connection_state != USB_ROLE_NONE) { 704 + usb3_set_mode_by_role_sw(usb3, host); 705 + usb3_vbus_out(usb3, a_dev); 706 + } 707 707 /* for A-Peripheral or forced B-device mode */ 708 708 if ((!host && a_dev) || usb3->start_to_connect) 709 709 usb3_connect(usb3); ··· 722 716 { 723 717 usb3->extcon_host = usb3_is_a_device(usb3); 724 718 725 - if (usb3->extcon_host && !usb3->forced_b_device) 719 + if ((!usb3->role_sw_by_connector && usb3->extcon_host && 720 + !usb3->forced_b_device) || usb3->connection_state == USB_ROLE_HOST) 726 721 usb3_mode_config(usb3, true, true); 727 722 else 728 723 usb3_mode_config(usb3, false, false); ··· 1168 1161 static void usb3_p0_xfer(struct renesas_usb3_ep *usb3_ep, 1169 1162 struct renesas_usb3_request *usb3_req) 1170 1163 { 1171 - int ret = -EAGAIN; 1164 + int ret; 1172 1165 1173 1166 if (usb3_ep->dir_in) 1174 1167 ret = usb3_write_pipe(usb3_ep, usb3_req, USB3_P0_WRITE); ··· 2350 2343 return cur_role; 2351 2344 } 2352 2345 2353 - static int renesas_usb3_role_switch_set(struct device *dev, 2354 - enum usb_role role) 2346 + static void handle_ext_role_switch_states(struct device *dev, 2347 + enum usb_role role) 2355 2348 { 2356 2349 struct renesas_usb3 *usb3 = dev_get_drvdata(dev); 2357 2350 struct device *host = usb3->host_dev; 2358 2351 enum usb_role cur_role = renesas_usb3_role_switch_get(dev); 2359 2352 2360 - pm_runtime_get_sync(dev); 2353 + switch (role) { 2354 + case USB_ROLE_NONE: 2355 + usb3->connection_state = USB_ROLE_NONE; 2356 + if (usb3->driver) 2357 + usb3_disconnect(usb3); 2358 + usb3_vbus_out(usb3, false); 2359 + break; 2360 + case USB_ROLE_DEVICE: 2361 + if (usb3->connection_state == USB_ROLE_NONE) { 2362 + usb3->connection_state = USB_ROLE_DEVICE; 2363 + usb3_set_mode(usb3, false); 2364 + if (usb3->driver) 2365 + usb3_connect(usb3); 2366 + } else if (cur_role == USB_ROLE_HOST) { 2367 + device_release_driver(host); 2368 + usb3_set_mode(usb3, false); 2369 + if (usb3->driver) 2370 + usb3_connect(usb3); 2371 + } 2372 + usb3_vbus_out(usb3, false); 2373 + break; 2374 + case USB_ROLE_HOST: 2375 + if (usb3->connection_state == USB_ROLE_NONE) { 2376 + if (usb3->driver) 2377 + usb3_disconnect(usb3); 2378 + 2379 + usb3->connection_state = USB_ROLE_HOST; 2380 + usb3_set_mode(usb3, true); 2381 + usb3_vbus_out(usb3, true); 2382 + if (device_attach(host) < 0) 2383 + dev_err(dev, "device_attach(host) failed\n"); 2384 + } else if (cur_role == USB_ROLE_DEVICE) { 2385 + usb3_disconnect(usb3); 2386 + /* Must set the mode before device_attach of the host */ 2387 + usb3_set_mode(usb3, true); 2388 + /* This device_attach() might sleep */ 2389 + if (device_attach(host) < 0) 2390 + dev_err(dev, "device_attach(host) failed\n"); 2391 + } 2392 + break; 2393 + default: 2394 + break; 2395 + } 2396 + } 2397 + 2398 + static void handle_role_switch_states(struct device *dev, 2399 + enum usb_role role) 2400 + { 2401 + struct renesas_usb3 *usb3 = dev_get_drvdata(dev); 2402 + struct device *host = usb3->host_dev; 2403 + enum usb_role cur_role = renesas_usb3_role_switch_get(dev); 2404 + 2361 2405 if (cur_role == USB_ROLE_HOST && role == USB_ROLE_DEVICE) { 2362 2406 device_release_driver(host); 2363 2407 usb3_set_mode(usb3, false); ··· 2419 2361 if (device_attach(host) < 0) 2420 2362 dev_err(dev, "device_attach(host) failed\n"); 2421 2363 } 2364 + } 2365 + 2366 + static int renesas_usb3_role_switch_set(struct device *dev, 2367 + enum usb_role role) 2368 + { 2369 + struct renesas_usb3 *usb3 = dev_get_drvdata(dev); 2370 + 2371 + pm_runtime_get_sync(dev); 2372 + 2373 + if (usb3->role_sw_by_connector) 2374 + handle_ext_role_switch_states(dev, role); 2375 + else 2376 + handle_role_switch_states(dev, role); 2377 + 2422 2378 pm_runtime_put(dev); 2423 2379 2424 2380 return 0; ··· 2722 2650 EXTCON_NONE, 2723 2651 }; 2724 2652 2725 - static const struct usb_role_switch_desc renesas_usb3_role_switch_desc = { 2653 + static struct usb_role_switch_desc renesas_usb3_role_switch_desc = { 2726 2654 .set = renesas_usb3_role_switch_set, 2727 2655 .get = renesas_usb3_role_switch_get, 2728 2656 .allow_userspace_control = true, ··· 2812 2740 ret = device_create_file(&pdev->dev, &dev_attr_role); 2813 2741 if (ret < 0) 2814 2742 goto err_dev_create; 2743 + 2744 + if (device_property_read_bool(&pdev->dev, "usb-role-switch")) { 2745 + usb3->role_sw_by_connector = true; 2746 + renesas_usb3_role_switch_desc.fwnode = dev_fwnode(&pdev->dev); 2747 + } 2815 2748 2816 2749 INIT_WORK(&usb3->role_work, renesas_usb3_role_work); 2817 2750 usb3->role_sw = usb_role_switch_register(&pdev->dev,
+1 -6
drivers/usb/host/Kconfig
··· 114 114 Controller Driver or UHCI (for Via motherboards) Host Controller 115 115 Driver too. 116 116 117 - You may want to read <file:Documentation/usb/ehci.txt>. 117 + You may want to read <file:Documentation/usb/ehci.rst>. 118 118 119 119 To compile this driver as a module, choose M here: the 120 120 module will be called ehci-hcd. ··· 161 161 config USB_EHCI_HCD_PMC_MSP 162 162 tristate "EHCI support for on-chip PMC MSP71xx USB controller" 163 163 depends on MSP_HAS_USB 164 - default n 165 164 select USB_EHCI_BIG_ENDIAN_DESC 166 165 select USB_EHCI_BIG_ENDIAN_MMIO 167 166 ---help--- ··· 307 308 308 309 config USB_EHCI_HCD_PLATFORM 309 310 tristate "Generic EHCI driver for a platform device" 310 - default n 311 311 ---help--- 312 312 Adds an EHCI host driver for a generic platform device, which 313 313 provides a memory space and an irq. ··· 316 318 config USB_OCTEON_EHCI 317 319 bool "Octeon on-chip EHCI support (DEPRECATED)" 318 320 depends on CAVIUM_OCTEON_SOC 319 - default n 320 321 select USB_EHCI_BIG_ENDIAN_MMIO if CPU_BIG_ENDIAN 321 322 select USB_EHCI_HCD_PLATFORM 322 323 help ··· 523 526 depends on (SSB = y || SSB = USB_OHCI_HCD) 524 527 select USB_HCD_SSB 525 528 select USB_OHCI_HCD_PLATFORM 526 - default n 527 529 ---help--- 528 530 This option is deprecated now and the driver was removed, use 529 531 USB_HCD_SSB and USB_OHCI_HCD_PLATFORM instead. ··· 565 569 566 570 config USB_OHCI_HCD_PLATFORM 567 571 tristate "Generic OHCI driver for a platform device" 568 - default n 569 572 ---help--- 570 573 Adds an OHCI host driver for a generic platform device, which 571 574 provides a memory space and an irq.
+11
drivers/usb/host/ehci-exynos.c
··· 39 39 40 40 struct exynos_ehci_hcd { 41 41 struct clk *clk; 42 + struct device_node *of_node; 42 43 struct phy *phy[PHY_NUMBER]; 43 44 }; 44 45 ··· 204 203 ehci = hcd_to_ehci(hcd); 205 204 ehci->caps = hcd->regs; 206 205 206 + /* 207 + * Workaround: reset of_node pointer to avoid conflict between Exynos 208 + * EHCI port subnodes and generic USB device bindings 209 + */ 210 + exynos_ehci->of_node = pdev->dev.of_node; 211 + pdev->dev.of_node = NULL; 212 + 207 213 /* DMA burst Enable */ 208 214 writel(EHCI_INSNREG00_ENABLE_DMA_BURST, EHCI_INSNREG00(hcd->regs)); 209 215 ··· 227 219 228 220 fail_add_hcd: 229 221 exynos_ehci_phy_disable(&pdev->dev); 222 + pdev->dev.of_node = exynos_ehci->of_node; 230 223 fail_io: 231 224 clk_disable_unprepare(exynos_ehci->clk); 232 225 fail_clk: ··· 239 230 { 240 231 struct usb_hcd *hcd = platform_get_drvdata(pdev); 241 232 struct exynos_ehci_hcd *exynos_ehci = to_exynos_ehci(hcd); 233 + 234 + pdev->dev.of_node = exynos_ehci->of_node; 242 235 243 236 usb_remove_hcd(hcd); 244 237
+41 -11
drivers/usb/host/ehci-fsl.c
··· 122 122 tmp |= 0x4; 123 123 iowrite32be(tmp, hcd->regs + FSL_SOC_USB_CTRL); 124 124 } 125 + 126 + /* Set USB_EN bit to select ULPI phy for USB controller version 2.5 */ 127 + if (pdata->controller_ver == FSL_USB_VER_2_5 && 128 + pdata->phy_mode == FSL_USB2_PHY_ULPI) 129 + iowrite32be(USB_CTRL_USB_EN, hcd->regs + FSL_SOC_USB_CTRL); 130 + 125 131 /* 126 132 * Enable UTMI phy and program PTS field in UTMI mode before asserting 127 133 * controller reset for USB Controller version 2.5 ··· 183 177 return retval; 184 178 } 185 179 180 + static bool usb_phy_clk_valid(struct usb_hcd *hcd) 181 + { 182 + void __iomem *non_ehci = hcd->regs; 183 + bool ret = true; 184 + 185 + if (!(ioread32be(non_ehci + FSL_SOC_USB_CTRL) & PHY_CLK_VALID)) 186 + ret = false; 187 + 188 + return ret; 189 + } 190 + 186 191 static int ehci_fsl_setup_phy(struct usb_hcd *hcd, 187 192 enum fsl_usb2_phy_modes phy_mode, 188 193 unsigned int port_offset) ··· 236 219 portsc |= PORT_PTS_PTW; 237 220 /* fall through */ 238 221 case FSL_USB2_PHY_UTMI: 222 + /* Presence of this node "has_fsl_erratum_a006918" 223 + * in device-tree is used to stop USB controller 224 + * initialization in Linux 225 + */ 226 + if (pdata->has_fsl_erratum_a006918) { 227 + dev_warn(dev, "USB PHY clock invalid\n"); 228 + return -EINVAL; 229 + } 230 + /* fall through */ 239 231 case FSL_USB2_PHY_UTMI_DUAL: 232 + /* PHY_CLK_VALID bit is de-featured from all controller 233 + * versions below 2.4 and is to be checked only for 234 + * internal UTMI phy 235 + */ 236 + if (pdata->controller_ver > FSL_USB_VER_2_4 && 237 + pdata->have_sysif_regs && !usb_phy_clk_valid(hcd)) { 238 + dev_err(dev, "USB PHY clock invalid\n"); 239 + return -EINVAL; 240 + } 241 + 240 242 if (pdata->have_sysif_regs && pdata->controller_ver) { 241 243 /* controller version 1.6 or above */ 242 244 tmp = ioread32be(non_ehci + FSL_SOC_USB_CTRL); ··· 279 243 break; 280 244 } 281 245 282 - /* 283 - * check PHY_CLK_VALID to determine phy clock presence before writing 284 - * to portsc 285 - */ 286 - if (pdata->check_phy_clk_valid) { 287 - if (!(ioread32be(non_ehci + FSL_SOC_USB_CTRL) & 288 - PHY_CLK_VALID)) { 289 - dev_warn(hcd->self.controller, 290 - "USB PHY clock invalid\n"); 291 - return -EINVAL; 292 - } 246 + if (pdata->have_sysif_regs && 247 + pdata->controller_ver > FSL_USB_VER_1_6 && 248 + !usb_phy_clk_valid(hcd)) { 249 + dev_warn(hcd->self.controller, "USB PHY clock invalid\n"); 250 + return -EINVAL; 293 251 } 294 252 295 253 ehci_writel(ehci, portsc, &ehci->regs->port_status[port_offset]);
+3
drivers/usb/host/ehci-fsl.h
··· 50 50 #define UTMI_PHY_EN (1<<9) 51 51 #define ULPI_PHY_CLK_SEL (1<<10) 52 52 #define PHY_CLK_VALID (1<<17) 53 + 54 + /* Retry count for checking UTMI PHY CLK validity */ 55 + #define UTMI_PHY_CLK_VALID_CHK_RETRY 5 53 56 #endif /* _EHCI_FSL_H */
-2
drivers/usb/host/ehci-st.c
··· 152 152 struct resource *res_mem; 153 153 struct usb_ehci_pdata *pdata = &ehci_platform_defaults; 154 154 struct st_ehci_platform_priv *priv; 155 - struct ehci_hcd *ehci; 156 155 int err, irq, clk = 0; 157 156 158 157 if (usb_disabled()) ··· 176 177 platform_set_drvdata(dev, hcd); 177 178 dev->dev.platform_data = pdata; 178 179 priv = hcd_to_ehci_priv(hcd); 179 - ehci = hcd_to_ehci(hcd); 180 180 181 181 priv->phy = devm_phy_get(&dev->dev, "usb"); 182 182 if (IS_ERR(priv->phy)) {
+10
drivers/usb/host/fotg210-hcd.c
··· 10 10 * Most of code borrowed from the Linux-3.7 EHCI driver 11 11 */ 12 12 #include <linux/module.h> 13 + #include <linux/of.h> 13 14 #include <linux/device.h> 14 15 #include <linux/dmapool.h> 15 16 #include <linux/kernel.h> ··· 5670 5669 return 0; 5671 5670 } 5672 5671 5672 + #ifdef CONFIG_OF 5673 + static const struct of_device_id fotg210_of_match[] = { 5674 + { .compatible = "faraday,fotg210" }, 5675 + {}, 5676 + }; 5677 + MODULE_DEVICE_TABLE(of, fotg210_of_match); 5678 + #endif 5679 + 5673 5680 static struct platform_driver fotg210_hcd_driver = { 5674 5681 .driver = { 5675 5682 .name = "fotg210-hcd", 5683 + .of_match_table = of_match_ptr(fotg210_of_match), 5676 5684 }, 5677 5685 .probe = fotg210_hcd_probe, 5678 5686 .remove = fotg210_hcd_remove,
+4 -6
drivers/usb/host/fsl-mph-dr-of.c
··· 224 224 of_property_read_bool(np, "fsl,usb-erratum-a005275"); 225 225 pdata->has_fsl_erratum_a005697 = 226 226 of_property_read_bool(np, "fsl,usb_erratum-a005697"); 227 - 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 - 227 + pdata->has_fsl_erratum_a006918 = 228 + of_property_read_bool(np, "fsl,usb_erratum-a006918"); 229 + pdata->has_fsl_erratum_14 = 230 + of_property_read_bool(np, "fsl,usb_erratum-14"); 233 231 234 232 /* 235 233 * Determine whether phy_clk_valid needs to be checked
+1 -1
drivers/usb/host/isp1362.h
··· 11 11 12 12 #define USE_32BIT 0 13 13 14 - /* These options are mutually eclusive */ 14 + /* These options are mutually exclusive */ 15 15 #define USE_PLATFORM_DELAY 0 16 16 #define USE_NDELAY 0 17 17
+11
drivers/usb/host/ohci-exynos.c
··· 30 30 31 31 struct exynos_ohci_hcd { 32 32 struct clk *clk; 33 + struct device_node *of_node; 33 34 struct phy *phy[PHY_NUMBER]; 34 35 }; 35 36 ··· 171 170 goto fail_io; 172 171 } 173 172 173 + /* 174 + * Workaround: reset of_node pointer to avoid conflict between Exynos 175 + * OHCI port subnodes and generic USB device bindings 176 + */ 177 + exynos_ohci->of_node = pdev->dev.of_node; 178 + pdev->dev.of_node = NULL; 179 + 174 180 err = usb_add_hcd(hcd, irq, IRQF_SHARED); 175 181 if (err) { 176 182 dev_err(&pdev->dev, "Failed to add USB HCD\n"); ··· 188 180 189 181 fail_add_hcd: 190 182 exynos_ohci_phy_disable(&pdev->dev); 183 + pdev->dev.of_node = exynos_ohci->of_node; 191 184 fail_io: 192 185 clk_disable_unprepare(exynos_ohci->clk); 193 186 fail_clk: ··· 200 191 { 201 192 struct usb_hcd *hcd = platform_get_drvdata(pdev); 202 193 struct exynos_ohci_hcd *exynos_ohci = to_exynos_ohci(hcd); 194 + 195 + pdev->dev.of_node = exynos_ohci->of_node; 203 196 204 197 usb_remove_hcd(hcd); 205 198
+1 -1
drivers/usb/host/ohci-pci.c
··· 274 274 .reset = ohci_pci_reset, 275 275 }; 276 276 277 - static const struct pci_device_id pci_ids [] = { { 277 + static const struct pci_device_id pci_ids[] = { { 278 278 /* handle any USB OHCI controller */ 279 279 PCI_DEVICE_CLASS(PCI_CLASS_SERIAL_USB_OHCI, ~0), 280 280 .driver_data = (unsigned long) &ohci_pci_hc_driver,
-2
drivers/usb/host/ohci-s3c2410.c
··· 293 293 static void s3c2410_hcd_oc(struct s3c2410_hcd_info *info, int port_oc) 294 294 { 295 295 struct s3c2410_hcd_port *port; 296 - struct usb_hcd *hcd; 297 296 unsigned long flags; 298 297 int portno; 299 298 ··· 300 301 return; 301 302 302 303 port = &info->port[0]; 303 - hcd = info->hcd; 304 304 305 305 local_irq_save(flags); 306 306
-3
drivers/usb/host/ohci-spear.c
··· 35 35 static int spear_ohci_hcd_drv_probe(struct platform_device *pdev) 36 36 { 37 37 const struct hc_driver *driver = &ohci_spear_hc_driver; 38 - struct ohci_hcd *ohci; 39 38 struct usb_hcd *hcd = NULL; 40 39 struct clk *usbh_clk; 41 40 struct spear_ohci *sohci_p; ··· 83 84 sohci_p->clk = usbh_clk; 84 85 85 86 clk_prepare_enable(sohci_p->clk); 86 - 87 - ohci = hcd_to_ohci(hcd); 88 87 89 88 retval = usb_add_hcd(hcd, platform_get_irq(pdev, 0), 0); 90 89 if (retval == 0) {
-2
drivers/usb/host/ohci-st.c
··· 132 132 struct resource *res_mem; 133 133 struct usb_ohci_pdata *pdata = &ohci_platform_defaults; 134 134 struct st_ohci_platform_priv *priv; 135 - struct ohci_hcd *ohci; 136 135 int err, irq, clk = 0; 137 136 138 137 if (usb_disabled()) ··· 157 158 platform_set_drvdata(dev, hcd); 158 159 dev->dev.platform_data = pdata; 159 160 priv = hcd_to_ohci_priv(hcd); 160 - ohci = hcd_to_ohci(hcd); 161 161 162 162 priv->phy = devm_phy_get(&dev->dev, "usb"); 163 163 if (IS_ERR(priv->phy)) {
+1 -2
drivers/usb/host/u132-hcd.c
··· 2554 2554 dev_err(&u132->platform_dev->dev, "device is being removed\n"); 2555 2555 return -ESHUTDOWN; 2556 2556 } else { 2557 - int frame = 0; 2558 2557 dev_err(&u132->platform_dev->dev, "TODO: u132_get_frame\n"); 2559 2558 mdelay(100); 2560 - return frame; 2559 + return 0; 2561 2560 } 2562 2561 } 2563 2562
+26 -1
drivers/usb/host/xhci-ring.c
··· 399 399 * stream once the endpoint is on the HW schedule. 400 400 */ 401 401 if ((ep_state & EP_STOP_CMD_PENDING) || (ep_state & SET_DEQ_PENDING) || 402 - (ep_state & EP_HALTED)) 402 + (ep_state & EP_HALTED) || (ep_state & EP_CLEARING_TT)) 403 403 return; 404 404 writel(DB_VALUE(ep_index, stream_id), db_addr); 405 405 /* The CPU has better things to do at this point than wait for a ··· 431 431 xhci_ring_ep_doorbell(xhci, slot_id, ep_index, 432 432 stream_id); 433 433 } 434 + } 435 + 436 + void xhci_ring_doorbell_for_active_rings(struct xhci_hcd *xhci, 437 + unsigned int slot_id, 438 + unsigned int ep_index) 439 + { 440 + ring_doorbell_for_active_rings(xhci, slot_id, ep_index); 434 441 } 435 442 436 443 /* Get the right ring for the given slot_id, ep_index and stream_id. ··· 1806 1799 return NULL; 1807 1800 } 1808 1801 1802 + static void xhci_clear_hub_tt_buffer(struct xhci_hcd *xhci, struct xhci_td *td, 1803 + struct xhci_virt_ep *ep) 1804 + { 1805 + /* 1806 + * As part of low/full-speed endpoint-halt processing 1807 + * we must clear the TT buffer (USB 2.0 specification 11.17.5). 1808 + */ 1809 + if (td->urb->dev->tt && !usb_pipeint(td->urb->pipe) && 1810 + (td->urb->dev->tt->hub != xhci_to_hcd(xhci)->self.root_hub) && 1811 + !(ep->ep_state & EP_CLEARING_TT)) { 1812 + ep->ep_state |= EP_CLEARING_TT; 1813 + td->urb->ep->hcpriv = td->urb->dev; 1814 + if (usb_hub_clear_tt_buffer(td->urb)) 1815 + ep->ep_state &= ~EP_CLEARING_TT; 1816 + } 1817 + } 1818 + 1809 1819 static void xhci_cleanup_halted_endpoint(struct xhci_hcd *xhci, 1810 1820 unsigned int slot_id, unsigned int ep_index, 1811 1821 unsigned int stream_id, struct xhci_td *td, ··· 1849 1825 if (reset_type == EP_HARD_RESET) { 1850 1826 ep->ep_state |= EP_HARD_CLEAR_TOGGLE; 1851 1827 xhci_cleanup_stalled_ring(xhci, ep_index, stream_id, td); 1828 + xhci_clear_hub_tt_buffer(xhci, td, ep); 1852 1829 } 1853 1830 xhci_ring_cmd_db(xhci); 1854 1831 }
-23
drivers/usb/host/xhci-tegra.c
··· 354 354 MBOX_CMD_NAK 355 355 }; 356 356 357 - static const char * const mbox_cmd_name[] = { 358 - [ 1] = "MSG_ENABLE", 359 - [ 2] = "INC_FALCON_CLOCK", 360 - [ 3] = "DEC_FALCON_CLOCK", 361 - [ 4] = "INC_SSPI_CLOCK", 362 - [ 5] = "DEC_SSPI_CLOCK", 363 - [ 6] = "SET_BW", 364 - [ 7] = "SET_SS_PWR_GATING", 365 - [ 8] = "SET_SS_PWR_UNGATING", 366 - [ 9] = "SAVE_DFE_CTLE_CTX", 367 - [ 10] = "AIRPLANE_MODE_ENABLED", 368 - [ 11] = "AIRPLANE_MODE_DISABLED", 369 - [ 12] = "START_HSIC_IDLE", 370 - [ 13] = "STOP_HSIC_IDLE", 371 - [ 14] = "DBC_WAKE_STACK", 372 - [ 15] = "HSIC_PRETEND_CONNECT", 373 - [ 16] = "RESET_SSPI", 374 - [ 17] = "DISABLE_SS_LFPS_DETECTION", 375 - [ 18] = "ENABLE_SS_LFPS_DETECTION", 376 - [128] = "ACK", 377 - [129] = "NAK", 378 - }; 379 - 380 357 struct tegra_xusb_mbox_msg { 381 358 u32 cmd; 382 359 u32 data;
+23
drivers/usb/host/xhci.c
··· 4130 4130 /* Zero the input context control for later use */ 4131 4131 ctrl_ctx->add_flags = 0; 4132 4132 ctrl_ctx->drop_flags = 0; 4133 + slot_ctx = xhci_get_slot_ctx(xhci, virt_dev->out_ctx); 4134 + udev->devaddr = (u8)(le32_to_cpu(slot_ctx->dev_state) & DEV_ADDR_MASK); 4133 4135 4134 4136 xhci_dbg_trace(xhci, trace_xhci_dbg_address, 4135 4137 "Internal device address = %d", ··· 5178 5176 } 5179 5177 EXPORT_SYMBOL_GPL(xhci_gen_setup); 5180 5178 5179 + static void xhci_clear_tt_buffer_complete(struct usb_hcd *hcd, 5180 + struct usb_host_endpoint *ep) 5181 + { 5182 + struct xhci_hcd *xhci; 5183 + struct usb_device *udev; 5184 + unsigned int slot_id; 5185 + unsigned int ep_index; 5186 + unsigned long flags; 5187 + 5188 + xhci = hcd_to_xhci(hcd); 5189 + udev = (struct usb_device *)ep->hcpriv; 5190 + slot_id = udev->slot_id; 5191 + ep_index = xhci_get_endpoint_index(&ep->desc); 5192 + 5193 + spin_lock_irqsave(&xhci->lock, flags); 5194 + xhci->devs[slot_id]->eps[ep_index].ep_state &= ~EP_CLEARING_TT; 5195 + xhci_ring_doorbell_for_active_rings(xhci, slot_id, ep_index); 5196 + spin_unlock_irqrestore(&xhci->lock, flags); 5197 + } 5198 + 5181 5199 static const struct hc_driver xhci_hc_driver = { 5182 5200 .description = "xhci-hcd", 5183 5201 .product_desc = "xHCI Host Controller", ··· 5259 5237 .enable_usb3_lpm_timeout = xhci_enable_usb3_lpm_timeout, 5260 5238 .disable_usb3_lpm_timeout = xhci_disable_usb3_lpm_timeout, 5261 5239 .find_raw_port_number = xhci_find_raw_port_number, 5240 + .clear_tt_buffer_complete = xhci_clear_tt_buffer_complete, 5262 5241 }; 5263 5242 5264 5243 void xhci_init_driver(struct hc_driver *drv,
+5
drivers/usb/host/xhci.h
··· 936 936 #define EP_GETTING_NO_STREAMS (1 << 5) 937 937 #define EP_HARD_CLEAR_TOGGLE (1 << 6) 938 938 #define EP_SOFT_CLEAR_TOGGLE (1 << 7) 939 + /* usb_hub_clear_tt_buffer is in progress */ 940 + #define EP_CLEARING_TT (1 << 8) 939 941 /* ---- Related to URB cancellation ---- */ 940 942 struct list_head cancelled_td_list; 941 943 /* Watchdog timer for stop endpoint command to cancel URBs */ ··· 2113 2111 2114 2112 void xhci_ring_ep_doorbell(struct xhci_hcd *xhci, unsigned int slot_id, 2115 2113 unsigned int ep_index, unsigned int stream_id); 2114 + void xhci_ring_doorbell_for_active_rings(struct xhci_hcd *xhci, 2115 + unsigned int slot_id, 2116 + unsigned int ep_index); 2116 2117 void xhci_cleanup_command_queue(struct xhci_hcd *xhci); 2117 2118 void inc_deq(struct xhci_hcd *xhci, struct xhci_ring *ring); 2118 2119 unsigned int count_trbs(u64 addr, u64 len);
+1 -1
drivers/usb/misc/Kconfig
··· 51 51 tristate "USB Diamond Rio500 support" 52 52 help 53 53 Say Y here if you want to connect a USB Rio500 mp3 player to your 54 - computer's USB port. Please read <file:Documentation/usb/rio.txt> 54 + computer's USB port. Please read <file:Documentation/usb/rio.rst> 55 55 for more information. 56 56 57 57 To compile this driver as a module, choose M here: the
+7 -9
drivers/usb/misc/adutux.c
··· 343 343 struct adu_device *dev; 344 344 size_t bytes_read = 0; 345 345 size_t bytes_to_read = count; 346 - int i; 347 346 int retval = 0; 348 347 int timeout = 0; 349 348 int should_submit = 0; ··· 370 371 timeout = COMMAND_TIMEOUT; 371 372 dev_dbg(&dev->udev->dev, "%s : about to start looping\n", __func__); 372 373 while (bytes_to_read) { 373 - int data_in_secondary = dev->secondary_tail - dev->secondary_head; 374 + size_t data_in_secondary = dev->secondary_tail - dev->secondary_head; 374 375 dev_dbg(&dev->udev->dev, 375 - "%s : while, data_in_secondary=%d, status=%d\n", 376 + "%s : while, data_in_secondary=%zu, status=%d\n", 376 377 __func__, data_in_secondary, 377 378 dev->interrupt_in_urb->status); 378 379 379 380 if (data_in_secondary) { 380 381 /* drain secondary buffer */ 381 - int amount = bytes_to_read < data_in_secondary ? bytes_to_read : data_in_secondary; 382 - i = copy_to_user(buffer, dev->read_buffer_secondary+dev->secondary_head, amount); 383 - if (i) { 382 + size_t amount = min(bytes_to_read, data_in_secondary); 383 + if (copy_to_user(buffer, dev->read_buffer_secondary+dev->secondary_head, amount)) { 384 384 retval = -EFAULT; 385 385 goto exit; 386 386 } 387 - dev->secondary_head += (amount - i); 388 - bytes_read += (amount - i); 389 - bytes_to_read -= (amount - i); 387 + dev->secondary_head += amount; 388 + bytes_read += amount; 389 + bytes_to_read -= amount; 390 390 } else { 391 391 /* we check the primary buffer */ 392 392 spin_lock_irqsave (&dev->buflock, flags);
-7
drivers/usb/misc/ftdi-elan.c
··· 2023 2023 goto read; 2024 2024 } else 2025 2025 goto reset; 2026 - } else if (s1 == 0x31 && s2 == 0x60) { 2027 - if (read_stop-- > 0) { 2028 - goto read; 2029 - } else { 2030 - dev_err(&ftdi->udev->dev, "retry limit reached\n"); 2031 - continue; 2032 - } 2033 2026 } else { 2034 2027 if (read_stop-- > 0) { 2035 2028 goto read;
+4 -6
drivers/usb/misc/sisusbvga/sisusb.c
··· 1747 1747 return ret; 1748 1748 } 1749 1749 1750 - static int sisusb_set_default_mode(struct sisusb_usb_data *sisusb, 1750 + static void sisusb_set_default_mode(struct sisusb_usb_data *sisusb, 1751 1751 int touchengines) 1752 1752 { 1753 - int ret = 0, i, j, modex, bpp, du; 1753 + int i, j, modex, bpp, du; 1754 1754 u8 sr31, cr63, tmp8; 1755 1755 static const char attrdata[] = { 1756 1756 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, ··· 1873 1873 } 1874 1874 1875 1875 SETIREG(SISCR, 0x34, 0x44); /* we just set std mode #44 */ 1876 - 1877 - return ret; 1878 1876 } 1879 1877 1880 1878 static int sisusb_init_gfxcore(struct sisusb_usb_data *sisusb) ··· 2017 2019 2018 2020 ret |= SETIREG(SISCR, 0x83, 0x00); 2019 2021 2020 - ret |= sisusb_set_default_mode(sisusb, 0); 2022 + sisusb_set_default_mode(sisusb, 0); 2021 2023 2022 2024 ret |= SETIREGAND(SISSR, 0x21, 0xdf); 2023 2025 ret |= SETIREGOR(SISSR, 0x01, 0x20); ··· 2244 2246 if (sisusb_init_gfxcore(sisusb) == 0) { 2245 2247 sisusb->gfxinit = 1; 2246 2248 sisusb_get_ramconfig(sisusb); 2247 - ret |= sisusb_set_default_mode(sisusb, 1); 2249 + sisusb_set_default_mode(sisusb, 1); 2248 2250 ret |= sisusb_setup_screen(sisusb, 1, initscreen); 2249 2251 } 2250 2252 }
+1 -1
drivers/usb/mon/Kconfig
··· 8 8 help 9 9 If you select this option, a component which captures the USB traffic 10 10 between peripheral-specific drivers and HC drivers will be built. 11 - For more information, see <file:Documentation/usb/usbmon.txt>. 11 + For more information, see <file:Documentation/usb/usbmon.rst>. 12 12 13 13 If unsure, say Y, if allowed, otherwise M.
+2 -1
drivers/usb/mtu3/mtu3_debugfs.c
··· 528 528 529 529 void ssusb_debugfs_create_root(struct ssusb_mtk *ssusb) 530 530 { 531 - ssusb->dbgfs_root = debugfs_create_dir(dev_name(ssusb->dev), NULL); 531 + ssusb->dbgfs_root = 532 + debugfs_create_dir(dev_name(ssusb->dev), usb_debug_root); 532 533 } 533 534 534 535 void ssusb_debugfs_remove_root(struct ssusb_mtk *ssusb)
-2
drivers/usb/phy/phy-mv-usb.c
··· 401 401 static void mv_otg_work(struct work_struct *work) 402 402 { 403 403 struct mv_otg *mvotg; 404 - struct usb_phy *phy; 405 404 struct usb_otg *otg; 406 405 int old_state; 407 406 ··· 408 409 409 410 run: 410 411 /* work queue is single thread, or we need spin_lock to protect */ 411 - phy = &mvotg->phy; 412 412 otg = mvotg->phy.otg; 413 413 old_state = otg->state; 414 414
+66 -1
drivers/usb/phy/phy-mxs-usb.c
··· 17 17 #include <linux/of_device.h> 18 18 #include <linux/regmap.h> 19 19 #include <linux/mfd/syscon.h> 20 + #include <linux/iopoll.h> 20 21 21 22 #define DRIVER_NAME "mxs_phy" 22 23 24 + /* Register Macro */ 23 25 #define HW_USBPHY_PWD 0x00 24 26 #define HW_USBPHY_TX 0x10 25 27 #define HW_USBPHY_CTRL 0x30 ··· 38 36 #define GM_USBPHY_TX_TXCAL45DP(x) (((x) & 0xf) << 16) 39 37 #define GM_USBPHY_TX_TXCAL45DN(x) (((x) & 0xf) << 8) 40 38 #define GM_USBPHY_TX_D_CAL(x) (((x) & 0xf) << 0) 39 + 40 + /* imx7ulp */ 41 + #define HW_USBPHY_PLL_SIC 0xa0 42 + #define HW_USBPHY_PLL_SIC_SET 0xa4 43 + #define HW_USBPHY_PLL_SIC_CLR 0xa8 41 44 42 45 #define BM_USBPHY_CTRL_SFTRST BIT(31) 43 46 #define BM_USBPHY_CTRL_CLKGATE BIT(30) ··· 62 55 #define BM_USBPHY_IP_FIX (BIT(17) | BIT(18)) 63 56 64 57 #define BM_USBPHY_DEBUG_CLKGATE BIT(30) 58 + /* imx7ulp */ 59 + #define BM_USBPHY_PLL_LOCK BIT(31) 60 + #define BM_USBPHY_PLL_REG_ENABLE BIT(21) 61 + #define BM_USBPHY_PLL_BYPASS BIT(16) 62 + #define BM_USBPHY_PLL_POWER BIT(12) 63 + #define BM_USBPHY_PLL_EN_USB_CLKS BIT(6) 65 64 66 65 /* Anatop Registers */ 67 66 #define ANADIG_ANA_MISC0 0x150 ··· 181 168 .flags = MXS_PHY_DISCONNECT_LINE_WITHOUT_VBUS, 182 169 }; 183 170 171 + static const struct mxs_phy_data imx7ulp_phy_data = { 172 + }; 173 + 184 174 static const struct of_device_id mxs_phy_dt_ids[] = { 185 175 { .compatible = "fsl,imx6sx-usbphy", .data = &imx6sx_phy_data, }, 186 176 { .compatible = "fsl,imx6sl-usbphy", .data = &imx6sl_phy_data, }, ··· 191 175 { .compatible = "fsl,imx23-usbphy", .data = &imx23_phy_data, }, 192 176 { .compatible = "fsl,vf610-usbphy", .data = &vf610_phy_data, }, 193 177 { .compatible = "fsl,imx6ul-usbphy", .data = &imx6ul_phy_data, }, 178 + { .compatible = "fsl,imx7ulp-usbphy", .data = &imx7ulp_phy_data, }, 194 179 { /* sentinel */ } 195 180 }; 196 181 MODULE_DEVICE_TABLE(of, mxs_phy_dt_ids); ··· 214 197 static inline bool is_imx6sl_phy(struct mxs_phy *mxs_phy) 215 198 { 216 199 return mxs_phy->data == &imx6sl_phy_data; 200 + } 201 + 202 + static inline bool is_imx7ulp_phy(struct mxs_phy *mxs_phy) 203 + { 204 + return mxs_phy->data == &imx7ulp_phy_data; 217 205 } 218 206 219 207 /* ··· 244 222 } 245 223 } 246 224 225 + static int mxs_phy_pll_enable(void __iomem *base, bool enable) 226 + { 227 + int ret = 0; 228 + 229 + if (enable) { 230 + u32 value; 231 + 232 + writel(BM_USBPHY_PLL_REG_ENABLE, base + HW_USBPHY_PLL_SIC_SET); 233 + writel(BM_USBPHY_PLL_BYPASS, base + HW_USBPHY_PLL_SIC_CLR); 234 + writel(BM_USBPHY_PLL_POWER, base + HW_USBPHY_PLL_SIC_SET); 235 + ret = readl_poll_timeout(base + HW_USBPHY_PLL_SIC, 236 + value, (value & BM_USBPHY_PLL_LOCK) != 0, 237 + 100, 10000); 238 + if (ret) 239 + return ret; 240 + 241 + writel(BM_USBPHY_PLL_EN_USB_CLKS, base + 242 + HW_USBPHY_PLL_SIC_SET); 243 + } else { 244 + writel(BM_USBPHY_PLL_EN_USB_CLKS, base + 245 + HW_USBPHY_PLL_SIC_CLR); 246 + writel(BM_USBPHY_PLL_POWER, base + HW_USBPHY_PLL_SIC_CLR); 247 + writel(BM_USBPHY_PLL_BYPASS, base + HW_USBPHY_PLL_SIC_SET); 248 + writel(BM_USBPHY_PLL_REG_ENABLE, base + HW_USBPHY_PLL_SIC_CLR); 249 + } 250 + 251 + return ret; 252 + } 253 + 247 254 static int mxs_phy_hw_init(struct mxs_phy *mxs_phy) 248 255 { 249 256 int ret; 250 257 void __iomem *base = mxs_phy->phy.io_priv; 251 258 259 + if (is_imx7ulp_phy(mxs_phy)) { 260 + ret = mxs_phy_pll_enable(base, true); 261 + if (ret) 262 + return ret; 263 + } 264 + 252 265 ret = stmp_reset_block(base + HW_USBPHY_CTRL); 253 266 if (ret) 254 - return ret; 267 + goto disable_pll; 255 268 256 269 /* Power up the PHY */ 257 270 writel(0, base + HW_USBPHY_PWD); ··· 324 267 mxs_phy_tx_init(mxs_phy); 325 268 326 269 return 0; 270 + 271 + disable_pll: 272 + if (is_imx7ulp_phy(mxs_phy)) 273 + mxs_phy_pll_enable(base, false); 274 + return ret; 327 275 } 328 276 329 277 /* Return true if the vbus is there */ ··· 449 387 450 388 writel(BM_USBPHY_CTRL_CLKGATE, 451 389 phy->io_priv + HW_USBPHY_CTRL_SET); 390 + 391 + if (is_imx7ulp_phy(mxs_phy)) 392 + mxs_phy_pll_enable(phy->io_priv, false); 452 393 453 394 clk_disable_unprepare(mxs_phy->clk); 454 395 }
-1
drivers/usb/renesas_usbhs/Kconfig
··· 8 8 depends on USB_GADGET 9 9 depends on ARCH_RENESAS || SUPERH || COMPILE_TEST 10 10 depends on EXTCON || !EXTCON # if EXTCON=m, USBHS cannot be built-in 11 - default n 12 11 help 13 12 Renesas USBHS is a discrete USB host and peripheral controller chip 14 13 that supports both full and high speed USB 2.0 data transfers.
+1 -1
drivers/usb/renesas_usbhs/Makefile
··· 5 5 6 6 obj-$(CONFIG_USB_RENESAS_USBHS) += renesas_usbhs.o 7 7 8 - renesas_usbhs-y := common.o mod.o pipe.o fifo.o rcar2.o rcar3.o rza.o 8 + renesas_usbhs-y := common.o mod.o pipe.o fifo.o rcar2.o rcar3.o rza.o rza2.o 9 9 10 10 ifneq ($(CONFIG_USB_RENESAS_USBHS_HCD),) 11 11 renesas_usbhs-y += mod_host.o
+81 -133
drivers/usb/renesas_usbhs/common.c
··· 3 3 * Renesas USB driver 4 4 * 5 5 * Copyright (C) 2011 Renesas Solutions Corp. 6 + * Copyright (C) 2019 Renesas Electronics Corporation 6 7 * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> 7 8 */ 8 9 #include <linux/clk.h> ··· 44 43 * | .... | +-----------+ 45 44 */ 46 45 47 - 48 - #define USBHSF_RUNTIME_PWCTRL (1 << 0) 49 - 50 - /* status */ 51 - #define usbhsc_flags_init(p) do {(p)->flags = 0; } while (0) 52 - #define usbhsc_flags_set(p, b) ((p)->flags |= (b)) 53 - #define usbhsc_flags_clr(p, b) ((p)->flags &= ~(b)) 54 - #define usbhsc_flags_has(p, b) ((p)->flags & (b)) 55 - 56 46 /* 57 47 * platform call back 58 48 * ··· 53 61 */ 54 62 #define usbhs_platform_call(priv, func, args...)\ 55 63 (!(priv) ? -ENODEV : \ 56 - !((priv)->pfunc.func) ? 0 : \ 57 - (priv)->pfunc.func(args)) 64 + !((priv)->pfunc->func) ? 0 : \ 65 + (priv)->pfunc->func(args)) 58 66 59 67 /* 60 68 * common functions ··· 84 92 return dev_get_drvdata(&pdev->dev); 85 93 } 86 94 95 + int usbhs_get_id_as_gadget(struct platform_device *pdev) 96 + { 97 + return USBHS_GADGET; 98 + } 99 + 87 100 /* 88 101 * syscfg functions 89 102 */ ··· 101 104 { 102 105 u16 mask = DCFM | DRPD | DPRPU | HSE | USBE; 103 106 u16 val = DCFM | DRPD | HSE | USBE; 104 - int has_otg = usbhs_get_dparam(priv, has_otg); 105 - 106 - if (has_otg) 107 - usbhs_bset(priv, DVSTCTR, (EXTLP | PWEN), (EXTLP | PWEN)); 108 107 109 108 /* 110 109 * if enable ··· 115 122 { 116 123 u16 mask = DCFM | DRPD | DPRPU | HSE | USBE; 117 124 u16 val = HSE | USBE; 125 + 126 + /* CNEN bit is required for function operation */ 127 + if (usbhs_get_dparam(priv, has_cnen)) { 128 + mask |= CNEN; 129 + val |= CNEN; 130 + } 118 131 119 132 /* 120 133 * if enable ··· 293 294 294 295 static bool usbhsc_is_multi_clks(struct usbhs_priv *priv) 295 296 { 296 - if (priv->dparam.type == USBHS_TYPE_RCAR_GEN3 || 297 - priv->dparam.type == USBHS_TYPE_RCAR_GEN3_WITH_PLL) 298 - return true; 299 - 300 - return false; 297 + return priv->dparam.multi_clks; 301 298 } 302 299 303 300 static int usbhsc_clk_get(struct device *dev, struct usbhs_priv *priv) ··· 302 307 return 0; 303 308 304 309 /* The first clock should exist */ 305 - priv->clks[0] = of_clk_get(dev->of_node, 0); 310 + priv->clks[0] = of_clk_get(dev_of_node(dev), 0); 306 311 if (IS_ERR(priv->clks[0])) 307 312 return PTR_ERR(priv->clks[0]); 308 313 ··· 310 315 * To backward compatibility with old DT, this driver checks the return 311 316 * value if it's -ENOENT or not. 312 317 */ 313 - priv->clks[1] = of_clk_get(dev->of_node, 1); 318 + priv->clks[1] = of_clk_get(dev_of_node(dev), 1); 314 319 if (PTR_ERR(priv->clks[1]) == -ENOENT) 315 320 priv->clks[1] = NULL; 316 321 else if (IS_ERR(priv->clks[1])) ··· 449 454 /* 450 455 * get vbus status from platform 451 456 */ 452 - enable = usbhs_platform_call(priv, get_vbus, pdev); 457 + enable = usbhs_mod_info_call(priv, get_vbus, pdev); 453 458 454 459 /* 455 460 * get id from platform ··· 474 479 dev_dbg(&pdev->dev, "%s enable\n", __func__); 475 480 476 481 /* power on */ 477 - if (usbhsc_flags_has(priv, USBHSF_RUNTIME_PWCTRL)) 482 + if (usbhs_get_dparam(priv, runtime_pwctrl)) 478 483 usbhsc_power_ctrl(priv, enable); 479 484 480 485 /* bus init */ ··· 494 499 usbhsc_bus_init(priv); 495 500 496 501 /* power off */ 497 - if (usbhsc_flags_has(priv, USBHSF_RUNTIME_PWCTRL)) 502 + if (usbhs_get_dparam(priv, runtime_pwctrl)) 498 503 usbhsc_power_ctrl(priv, enable); 499 504 500 505 usbhs_mod_change(priv, -1); ··· 515 520 usbhsc_hotplug(priv); 516 521 } 517 522 518 - static int usbhsc_drvcllbck_notify_hotplug(struct platform_device *pdev) 523 + int usbhsc_schedule_notify_hotplug(struct platform_device *pdev) 519 524 { 520 525 struct usbhs_priv *priv = usbhs_pdev_to_priv(pdev); 521 526 int delay = usbhs_get_dparam(priv, detection_delay); ··· 536 541 static const struct of_device_id usbhs_of_match[] = { 537 542 { 538 543 .compatible = "renesas,usbhs-r8a774c0", 539 - .data = (void *)USBHS_TYPE_RCAR_GEN3_WITH_PLL, 544 + .data = &usbhs_rcar_gen3_with_pll_plat_info, 540 545 }, 541 546 { 542 547 .compatible = "renesas,usbhs-r8a7790", 543 - .data = (void *)USBHS_TYPE_RCAR_GEN2, 548 + .data = &usbhs_rcar_gen2_plat_info, 544 549 }, 545 550 { 546 551 .compatible = "renesas,usbhs-r8a7791", 547 - .data = (void *)USBHS_TYPE_RCAR_GEN2, 552 + .data = &usbhs_rcar_gen2_plat_info, 548 553 }, 549 554 { 550 555 .compatible = "renesas,usbhs-r8a7794", 551 - .data = (void *)USBHS_TYPE_RCAR_GEN2, 556 + .data = &usbhs_rcar_gen2_plat_info, 552 557 }, 553 558 { 554 559 .compatible = "renesas,usbhs-r8a7795", 555 - .data = (void *)USBHS_TYPE_RCAR_GEN3, 560 + .data = &usbhs_rcar_gen3_plat_info, 556 561 }, 557 562 { 558 563 .compatible = "renesas,usbhs-r8a7796", 559 - .data = (void *)USBHS_TYPE_RCAR_GEN3, 564 + .data = &usbhs_rcar_gen3_plat_info, 560 565 }, 561 566 { 562 567 .compatible = "renesas,usbhs-r8a77990", 563 - .data = (void *)USBHS_TYPE_RCAR_GEN3_WITH_PLL, 568 + .data = &usbhs_rcar_gen3_with_pll_plat_info, 564 569 }, 565 570 { 566 571 .compatible = "renesas,usbhs-r8a77995", 567 - .data = (void *)USBHS_TYPE_RCAR_GEN3_WITH_PLL, 572 + .data = &usbhs_rcar_gen3_with_pll_plat_info, 568 573 }, 569 574 { 570 575 .compatible = "renesas,rcar-gen2-usbhs", 571 - .data = (void *)USBHS_TYPE_RCAR_GEN2, 576 + .data = &usbhs_rcar_gen2_plat_info, 572 577 }, 573 578 { 574 579 .compatible = "renesas,rcar-gen3-usbhs", 575 - .data = (void *)USBHS_TYPE_RCAR_GEN3, 580 + .data = &usbhs_rcar_gen3_plat_info, 576 581 }, 577 582 { 578 583 .compatible = "renesas,rza1-usbhs", 579 - .data = (void *)USBHS_TYPE_RZA1, 584 + .data = &usbhs_rza1_plat_info, 585 + }, 586 + { 587 + .compatible = "renesas,rza2-usbhs", 588 + .data = &usbhs_rza2_plat_info, 580 589 }, 581 590 { }, 582 591 }; 583 592 MODULE_DEVICE_TABLE(of, usbhs_of_match); 584 593 585 - static struct renesas_usbhs_platform_info *usbhs_parse_dt(struct device *dev) 586 - { 587 - struct renesas_usbhs_platform_info *info; 588 - struct renesas_usbhs_driver_param *dparam; 589 - u32 tmp; 590 - int gpio; 591 - 592 - info = devm_kzalloc(dev, sizeof(*info), GFP_KERNEL); 593 - if (!info) 594 - return NULL; 595 - 596 - dparam = &info->driver_param; 597 - dparam->type = (uintptr_t)of_device_get_match_data(dev); 598 - if (!of_property_read_u32(dev->of_node, "renesas,buswait", &tmp)) 599 - dparam->buswait_bwait = tmp; 600 - gpio = of_get_named_gpio_flags(dev->of_node, "renesas,enable-gpio", 0, 601 - NULL); 602 - if (gpio > 0) 603 - dparam->enable_gpio = gpio; 604 - 605 - if (dparam->type == USBHS_TYPE_RCAR_GEN2 || 606 - dparam->type == USBHS_TYPE_RCAR_GEN3 || 607 - dparam->type == USBHS_TYPE_RCAR_GEN3_WITH_PLL) { 608 - dparam->has_usb_dmac = 1; 609 - dparam->pipe_configs = usbhsc_new_pipe; 610 - dparam->pipe_size = ARRAY_SIZE(usbhsc_new_pipe); 611 - } 612 - 613 - if (dparam->type == USBHS_TYPE_RZA1) { 614 - dparam->pipe_configs = usbhsc_new_pipe; 615 - dparam->pipe_size = ARRAY_SIZE(usbhsc_new_pipe); 616 - } 617 - 618 - return info; 619 - } 620 - 621 594 static int usbhs_probe(struct platform_device *pdev) 622 595 { 623 - struct renesas_usbhs_platform_info *info = renesas_usbhs_get_info(pdev); 624 - struct renesas_usbhs_driver_callback *dfunc; 596 + const struct renesas_usbhs_platform_info *info; 625 597 struct usbhs_priv *priv; 626 598 struct resource *res, *irq_res; 627 - int ret; 599 + struct device *dev = &pdev->dev; 600 + int ret, gpio; 601 + u32 tmp; 628 602 629 603 /* check device node */ 630 - if (pdev->dev.of_node) 631 - info = pdev->dev.platform_data = usbhs_parse_dt(&pdev->dev); 604 + if (dev_of_node(dev)) 605 + info = of_device_get_match_data(dev); 606 + else 607 + info = renesas_usbhs_get_info(pdev); 632 608 633 609 /* check platform information */ 634 610 if (!info) { 635 - dev_err(&pdev->dev, "no platform information\n"); 611 + dev_err(dev, "no platform information\n"); 636 612 return -EINVAL; 637 613 } 638 614 639 615 /* platform data */ 640 616 irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); 641 617 if (!irq_res) { 642 - dev_err(&pdev->dev, "Not enough Renesas USB platform resources.\n"); 618 + dev_err(dev, "Not enough Renesas USB platform resources.\n"); 643 619 return -ENODEV; 644 620 } 645 621 646 622 /* usb private data */ 647 - priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); 623 + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); 648 624 if (!priv) 649 625 return -ENOMEM; 650 626 ··· 624 658 if (IS_ERR(priv->base)) 625 659 return PTR_ERR(priv->base); 626 660 627 - if (of_property_read_bool(pdev->dev.of_node, "extcon")) { 628 - priv->edev = extcon_get_edev_by_phandle(&pdev->dev, 0); 661 + if (of_property_read_bool(dev_of_node(dev), "extcon")) { 662 + priv->edev = extcon_get_edev_by_phandle(dev, 0); 629 663 if (IS_ERR(priv->edev)) 630 664 return PTR_ERR(priv->edev); 631 665 } 632 666 633 - priv->rsts = devm_reset_control_array_get_optional_shared(&pdev->dev); 667 + priv->rsts = devm_reset_control_array_get_optional_shared(dev); 634 668 if (IS_ERR(priv->rsts)) 635 669 return PTR_ERR(priv->rsts); 636 670 ··· 638 672 * care platform info 639 673 */ 640 674 641 - memcpy(&priv->dparam, 642 - &info->driver_param, 643 - sizeof(struct renesas_usbhs_driver_param)); 675 + priv->dparam = info->driver_param; 644 676 645 - switch (priv->dparam.type) { 646 - case USBHS_TYPE_RCAR_GEN2: 647 - priv->pfunc = usbhs_rcar2_ops; 648 - break; 649 - case USBHS_TYPE_RCAR_GEN3: 650 - priv->pfunc = usbhs_rcar3_ops; 651 - break; 652 - case USBHS_TYPE_RCAR_GEN3_WITH_PLL: 653 - priv->pfunc = usbhs_rcar3_with_pll_ops; 654 - break; 655 - case USBHS_TYPE_RZA1: 656 - priv->pfunc = usbhs_rza1_ops; 657 - break; 658 - default: 659 - if (!info->platform_callback.get_id) { 660 - dev_err(&pdev->dev, "no platform callbacks"); 661 - return -EINVAL; 662 - } 663 - memcpy(&priv->pfunc, 664 - &info->platform_callback, 665 - sizeof(struct renesas_usbhs_platform_callback)); 666 - break; 677 + if (!info->platform_callback.get_id) { 678 + dev_err(dev, "no platform callbacks\n"); 679 + return -EINVAL; 667 680 } 668 - 669 - /* set driver callback functions for platform */ 670 - dfunc = &info->driver_callback; 671 - dfunc->notify_hotplug = usbhsc_drvcllbck_notify_hotplug; 681 + priv->pfunc = &info->platform_callback; 672 682 673 683 /* set default param if platform doesn't have */ 674 - if (!priv->dparam.pipe_configs) { 684 + if (usbhs_get_dparam(priv, has_new_pipe_configs)) { 685 + priv->dparam.pipe_configs = usbhsc_new_pipe; 686 + priv->dparam.pipe_size = ARRAY_SIZE(usbhsc_new_pipe); 687 + } else if (!priv->dparam.pipe_configs) { 675 688 priv->dparam.pipe_configs = usbhsc_default_pipe; 676 689 priv->dparam.pipe_size = ARRAY_SIZE(usbhsc_default_pipe); 677 690 } 678 691 if (!priv->dparam.pio_dma_border) 679 692 priv->dparam.pio_dma_border = 64; /* 64byte */ 693 + if (!of_property_read_u32(dev_of_node(dev), "renesas,buswait", &tmp)) 694 + priv->dparam.buswait_bwait = tmp; 695 + gpio = of_get_named_gpio_flags(dev_of_node(dev), "renesas,enable-gpio", 696 + 0, NULL); 697 + if (gpio > 0) 698 + priv->dparam.enable_gpio = gpio; 680 699 681 700 /* FIXME */ 682 701 /* runtime power control ? */ 683 - if (priv->pfunc.get_vbus) 684 - usbhsc_flags_set(priv, USBHSF_RUNTIME_PWCTRL); 702 + if (priv->pfunc->get_vbus) 703 + usbhs_get_dparam(priv, runtime_pwctrl) = 1; 685 704 686 705 /* 687 706 * priv settings ··· 698 747 if (ret) 699 748 goto probe_fail_rst; 700 749 701 - ret = usbhsc_clk_get(&pdev->dev, priv); 750 + ret = usbhsc_clk_get(dev, priv); 702 751 if (ret) 703 752 goto probe_fail_clks; 704 753 ··· 714 763 ret = !gpio_get_value(priv->dparam.enable_gpio); 715 764 gpio_free(priv->dparam.enable_gpio); 716 765 if (ret) { 717 - dev_warn(&pdev->dev, 718 - "USB function not selected (GPIO %d)\n", 766 + dev_warn(dev, "USB function not selected (GPIO %d)\n", 719 767 priv->dparam.enable_gpio); 720 768 ret = -ENOTSUPP; 721 769 goto probe_end_mod_exit; ··· 730 780 */ 731 781 ret = usbhs_platform_call(priv, hardware_init, pdev); 732 782 if (ret < 0) { 733 - dev_err(&pdev->dev, "platform init failed.\n"); 783 + dev_err(dev, "platform init failed.\n"); 734 784 goto probe_end_mod_exit; 735 785 } 736 786 ··· 738 788 usbhs_platform_call(priv, phy_reset, pdev); 739 789 740 790 /* power control */ 741 - pm_runtime_enable(&pdev->dev); 742 - if (!usbhsc_flags_has(priv, USBHSF_RUNTIME_PWCTRL)) { 791 + pm_runtime_enable(dev); 792 + if (!usbhs_get_dparam(priv, runtime_pwctrl)) { 743 793 usbhsc_power_ctrl(priv, 1); 744 794 usbhs_mod_autonomy_mode(priv); 795 + } else { 796 + usbhs_mod_non_autonomy_mode(priv); 745 797 } 746 798 747 799 /* 748 800 * manual call notify_hotplug for cold plug 749 801 */ 750 - usbhsc_drvcllbck_notify_hotplug(pdev); 802 + usbhsc_schedule_notify_hotplug(pdev); 751 803 752 - dev_info(&pdev->dev, "probed\n"); 804 + dev_info(dev, "probed\n"); 753 805 754 806 return ret; 755 807 ··· 766 814 probe_end_pipe_exit: 767 815 usbhs_pipe_remove(priv); 768 816 769 - dev_info(&pdev->dev, "probe failed (%d)\n", ret); 817 + dev_info(dev, "probe failed (%d)\n", ret); 770 818 771 819 return ret; 772 820 } ··· 774 822 static int usbhs_remove(struct platform_device *pdev) 775 823 { 776 824 struct usbhs_priv *priv = usbhs_pdev_to_priv(pdev); 777 - struct renesas_usbhs_platform_info *info = renesas_usbhs_get_info(pdev); 778 - struct renesas_usbhs_driver_callback *dfunc = &info->driver_callback; 779 825 780 826 dev_dbg(&pdev->dev, "usb remove\n"); 781 827 782 - dfunc->notify_hotplug = NULL; 783 - 784 828 /* power off */ 785 - if (!usbhsc_flags_has(priv, USBHSF_RUNTIME_PWCTRL)) 829 + if (!usbhs_get_dparam(priv, runtime_pwctrl)) 786 830 usbhsc_power_ctrl(priv, 0); 787 831 788 832 pm_runtime_disable(&pdev->dev); ··· 803 855 usbhs_mod_change(priv, -1); 804 856 } 805 857 806 - if (mod || !usbhsc_flags_has(priv, USBHSF_RUNTIME_PWCTRL)) 858 + if (mod || !usbhs_get_dparam(priv, runtime_pwctrl)) 807 859 usbhsc_power_ctrl(priv, 0); 808 860 809 861 return 0; ··· 814 866 struct usbhs_priv *priv = dev_get_drvdata(dev); 815 867 struct platform_device *pdev = usbhs_priv_to_pdev(priv); 816 868 817 - if (!usbhsc_flags_has(priv, USBHSF_RUNTIME_PWCTRL)) { 869 + if (!usbhs_get_dparam(priv, runtime_pwctrl)) { 818 870 usbhsc_power_ctrl(priv, 1); 819 871 usbhs_mod_autonomy_mode(priv); 820 872 } 821 873 822 874 usbhs_platform_call(priv, phy_reset, pdev); 823 875 824 - usbhsc_drvcllbck_notify_hotplug(pdev); 876 + usbhsc_schedule_notify_hotplug(pdev); 825 877 826 878 return 0; 827 879 }
+6 -3
drivers/usb/renesas_usbhs/common.h
··· 3 3 * Renesas USB driver 4 4 * 5 5 * Copyright (C) 2011 Renesas Solutions Corp. 6 + * Copyright (C) 2019 Renesas Electronics Corporation 6 7 * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> 7 8 */ 8 9 #ifndef RENESAS_USB_DRIVER_H ··· 105 104 106 105 /* SYSCFG */ 107 106 #define SCKE (1 << 10) /* USB Module Clock Enable */ 107 + #define CNEN (1 << 8) /* Single-ended receiver operation Enable */ 108 108 #define HSE (1 << 7) /* High-Speed Operation Enable */ 109 109 #define DCFM (1 << 6) /* Controller Function Select */ 110 110 #define DRPD (1 << 5) /* D+ Line/D- Line Resistance Control */ ··· 252 250 unsigned int irq; 253 251 unsigned long irqflags; 254 252 255 - struct renesas_usbhs_platform_callback pfunc; 253 + const struct renesas_usbhs_platform_callback *pfunc; 256 254 struct renesas_usbhs_driver_param dparam; 257 255 258 256 struct delayed_work notify_hotplug_work; ··· 261 259 struct extcon_dev *edev; 262 260 263 261 spinlock_t lock; 264 - 265 - u32 flags; 266 262 267 263 /* 268 264 * module control ··· 292 292 #define usbhs_lock(p, f) spin_lock_irqsave(usbhs_priv_to_lock(p), f) 293 293 #define usbhs_unlock(p, f) spin_unlock_irqrestore(usbhs_priv_to_lock(p), f) 294 294 295 + int usbhs_get_id_as_gadget(struct platform_device *pdev); 296 + 295 297 /* 296 298 * sysconfig 297 299 */ ··· 315 313 void usbhs_bus_send_reset(struct usbhs_priv *priv); 316 314 int usbhs_bus_get_speed(struct usbhs_priv *priv); 317 315 int usbhs_vbus_ctrl(struct usbhs_priv *priv, int enable); 316 + int usbhsc_schedule_notify_hotplug(struct platform_device *pdev); 318 317 319 318 /* 320 319 * frame
+32 -20
drivers/usb/renesas_usbhs/fifo.c
··· 3 3 * Renesas USB driver 4 4 * 5 5 * Copyright (C) 2011 Renesas Solutions Corp. 6 + * Copyright (C) 2019 Renesas Electronics Corporation 6 7 * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> 7 8 */ 8 9 #include <linux/delay.h> ··· 13 12 #include "pipe.h" 14 13 15 14 #define usbhsf_get_cfifo(p) (&((p)->fifo_info.cfifo)) 16 - #define usbhsf_is_cfifo(p, f) (usbhsf_get_cfifo(p) == f) 17 15 18 16 #define usbhsf_fifo_is_busy(f) ((f)->pipe) /* see usbhs_pipe_select_fifo */ 19 17 ··· 325 325 } 326 326 327 327 /* "base" will be used below */ 328 - if (usbhs_get_dparam(priv, has_sudmac) && !usbhsf_is_cfifo(priv, fifo)) 329 - usbhs_write(priv, fifo->sel, base); 330 - else 331 - usbhs_write(priv, fifo->sel, base | MBW_32); 328 + usbhs_write(priv, fifo->sel, base | MBW_32); 332 329 333 330 /* check ISEL and CURPIPE value */ 334 331 while (timeout--) { ··· 540 543 } 541 544 542 545 /* the rest operation */ 543 - for (i = 0; i < len; i++) 544 - iowrite8(buf[i], addr + (0x03 - (i & 0x03))); 546 + if (usbhs_get_dparam(priv, cfifo_byte_addr)) { 547 + for (i = 0; i < len; i++) 548 + iowrite8(buf[i], addr + (i & 0x03)); 549 + } else { 550 + for (i = 0; i < len; i++) 551 + iowrite8(buf[i], addr + (0x03 - (i & 0x03))); 552 + } 545 553 546 554 /* 547 555 * variable update ··· 804 802 } 805 803 806 804 static void usbhsf_dma_complete(void *arg); 807 - static void xfer_work(struct work_struct *work) 805 + static void usbhsf_dma_xfer_preparing(struct usbhs_pkt *pkt) 808 806 { 809 - struct usbhs_pkt *pkt = container_of(work, struct usbhs_pkt, work); 810 807 struct usbhs_pipe *pipe = pkt->pipe; 811 808 struct usbhs_fifo *fifo; 812 809 struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe); ··· 813 812 struct dma_chan *chan; 814 813 struct device *dev = usbhs_priv_to_dev(priv); 815 814 enum dma_transfer_direction dir; 816 - unsigned long flags; 817 815 818 - usbhs_lock(priv, flags); 819 816 fifo = usbhs_pipe_to_fifo(pipe); 820 817 if (!fifo) 821 - goto xfer_work_end; 818 + return; 822 819 823 820 chan = usbhsf_dma_chan_get(fifo, pkt); 824 821 dir = usbhs_pipe_is_dir_in(pipe) ? DMA_DEV_TO_MEM : DMA_MEM_TO_DEV; ··· 825 826 pkt->trans, dir, 826 827 DMA_PREP_INTERRUPT | DMA_CTRL_ACK); 827 828 if (!desc) 828 - goto xfer_work_end; 829 + return; 829 830 830 831 desc->callback = usbhsf_dma_complete; 831 832 desc->callback_param = pipe; ··· 833 834 pkt->cookie = dmaengine_submit(desc); 834 835 if (pkt->cookie < 0) { 835 836 dev_err(dev, "Failed to submit dma descriptor\n"); 836 - goto xfer_work_end; 837 + return; 837 838 } 838 839 839 840 dev_dbg(dev, " %s %d (%d/ %d)\n", ··· 844 845 dma_async_issue_pending(chan); 845 846 usbhsf_dma_start(pipe, fifo); 846 847 usbhs_pipe_enable(pipe); 848 + } 847 849 848 - xfer_work_end: 850 + static void xfer_work(struct work_struct *work) 851 + { 852 + struct usbhs_pkt *pkt = container_of(work, struct usbhs_pkt, work); 853 + struct usbhs_pipe *pipe = pkt->pipe; 854 + struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe); 855 + unsigned long flags; 856 + 857 + usbhs_lock(priv, flags); 858 + usbhsf_dma_xfer_preparing(pkt); 849 859 usbhs_unlock(priv, flags); 850 860 } 851 861 ··· 907 899 pkt->trans = len; 908 900 909 901 usbhsf_tx_irq_ctrl(pipe, 0); 910 - INIT_WORK(&pkt->work, xfer_work); 911 - schedule_work(&pkt->work); 902 + /* FIXME: Workaound for usb dmac that driver can be used in atomic */ 903 + if (usbhs_get_dparam(priv, has_usb_dmac)) { 904 + usbhsf_dma_xfer_preparing(pkt); 905 + } else { 906 + INIT_WORK(&pkt->work, xfer_work); 907 + schedule_work(&pkt->work); 908 + } 912 909 913 910 return 0; 914 911 ··· 1019 1006 1020 1007 pkt->trans = pkt->length; 1021 1008 1022 - INIT_WORK(&pkt->work, xfer_work); 1023 - schedule_work(&pkt->work); 1009 + usbhsf_dma_xfer_preparing(pkt); 1024 1010 1025 1011 return 0; 1026 1012 ··· 1288 1276 { 1289 1277 struct device *dev = usbhs_priv_to_dev(priv); 1290 1278 1291 - if (dev->of_node) 1279 + if (dev_of_node(dev)) 1292 1280 usbhsf_dma_init_dt(dev, fifo, channel); 1293 1281 else 1294 1282 usbhsf_dma_init_pdev(fifo);
+11 -12
drivers/usb/renesas_usbhs/mod.c
··· 3 3 * Renesas USB driver 4 4 * 5 5 * Copyright (C) 2011 Renesas Solutions Corp. 6 + * Copyright (C) 2019 Renesas Electronics Corporation 6 7 * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> 7 8 */ 8 9 #include <linux/interrupt.h> 9 10 10 11 #include "common.h" 11 12 #include "mod.h" 12 - 13 - #define usbhs_priv_to_modinfo(priv) (&priv->mod_info) 14 - #define usbhs_mod_info_call(priv, func, param...) \ 15 - ({ \ 16 - struct usbhs_mod_info *info; \ 17 - info = usbhs_priv_to_modinfo(priv); \ 18 - !info->func ? 0 : \ 19 - info->func(param); \ 20 - }) 21 13 22 14 /* 23 15 * autonomy ··· 33 41 { 34 42 struct platform_device *pdev = usbhs_priv_to_pdev(priv); 35 43 36 - renesas_usbhs_call_notify_hotplug(pdev); 44 + usbhsc_schedule_notify_hotplug(pdev); 37 45 38 46 return 0; 39 47 } ··· 42 50 { 43 51 struct usbhs_mod_info *info = usbhs_priv_to_modinfo(priv); 44 52 45 - info->irq_vbus = usbhsm_autonomy_irq_vbus; 46 - priv->pfunc.get_vbus = usbhsm_autonomy_get_vbus; 53 + info->irq_vbus = usbhsm_autonomy_irq_vbus; 54 + info->get_vbus = usbhsm_autonomy_get_vbus; 47 55 48 56 usbhs_irq_callback_update(priv, NULL); 57 + } 58 + 59 + void usbhs_mod_non_autonomy_mode(struct usbhs_priv *priv) 60 + { 61 + struct usbhs_mod_info *info = usbhs_priv_to_modinfo(priv); 62 + 63 + info->get_vbus = priv->pfunc->get_vbus; 49 64 } 50 65 51 66 /*
+21 -5
drivers/usb/renesas_usbhs/mod.h
··· 3 3 * Renesas USB driver 4 4 * 5 5 * Copyright (C) 2011 Renesas Solutions Corp. 6 + * Copyright (C) 2019 Renesas Electronics Corporation 6 7 * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> 7 8 */ 8 9 #ifndef RENESAS_USB_MOD_H ··· 85 84 /* 86 85 * INTSTS0 :: VBINT 87 86 * 88 - * This function will be used as autonomy mode 89 - * when platform cannot call notify_hotplug. 87 + * This function will be used as autonomy mode (runtime_pwctrl == 0) 88 + * when the platform doesn't have own get_vbus function. 90 89 * 91 - * This callback cannot be member of "struct usbhs_mod" 92 - * because it will be used even though 93 - * host/gadget has not been selected. 90 + * This callback cannot be member of "struct usbhs_mod" because it 91 + * will be used even though host/gadget has not been selected. 94 92 */ 95 93 int (*irq_vbus)(struct usbhs_priv *priv, 96 94 struct usbhs_irq_state *irq_state); 95 + 96 + /* 97 + * This function will be used on any gadget mode. To simplify the code, 98 + * this member is in here. 99 + */ 100 + int (*get_vbus)(struct platform_device *pdev); 97 101 }; 98 102 99 103 /* ··· 113 107 void usbhs_mod_remove(struct usbhs_priv *priv); 114 108 115 109 void usbhs_mod_autonomy_mode(struct usbhs_priv *priv); 110 + void usbhs_mod_non_autonomy_mode(struct usbhs_priv *priv); 116 111 117 112 /* 118 113 * status functions ··· 135 128 !mod->func ? 0 : \ 136 129 mod->func(param); \ 137 130 }) 131 + 132 + #define usbhs_priv_to_modinfo(priv) (&priv->mod_info) 133 + #define usbhs_mod_info_call(priv, func, param...) \ 134 + ({ \ 135 + struct usbhs_mod_info *info; \ 136 + info = usbhs_priv_to_modinfo(priv); \ 137 + !info->func ? 0 : \ 138 + info->func(param); \ 139 + }) 138 140 139 141 /* 140 142 * host / gadget control
+4 -3
drivers/usb/renesas_usbhs/mod_gadget.c
··· 3 3 * Renesas USB driver 4 4 * 5 5 * Copyright (C) 2011 Renesas Solutions Corp. 6 + * Copyright (C) 2019 Renesas Electronics Corporation 6 7 * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> 7 8 */ 8 9 #include <linux/delay.h> ··· 915 914 { 916 915 struct usbhs_mod_info *info = &priv->mod_info; 917 916 918 - info->irq_vbus = NULL; 919 - priv->pfunc.get_vbus = usbhsm_phy_get_vbus; 917 + info->irq_vbus = NULL; 918 + info->get_vbus = usbhsm_phy_get_vbus; 920 919 921 920 usbhs_irq_callback_update(priv, NULL); 922 921 } ··· 1024 1023 1025 1024 gpriv->vbus_active = !!is_active; 1026 1025 1027 - renesas_usbhs_call_notify_hotplug(pdev); 1026 + usbhsc_schedule_notify_hotplug(pdev); 1028 1027 1029 1028 return 0; 1030 1029 }
+12 -10
drivers/usb/renesas_usbhs/rcar2.c
··· 3 3 * Renesas USB driver R-Car Gen. 2 initialization and power control 4 4 * 5 5 * Copyright (C) 2014 Ulrich Hecht 6 + * Copyright (C) 2019 Renesas Electronics Corporation 6 7 */ 7 8 8 9 #include <linux/gpio.h> ··· 63 62 return retval; 64 63 } 65 64 66 - static int usbhs_rcar2_get_id(struct platform_device *pdev) 67 - { 68 - return USBHS_GADGET; 69 - } 70 - 71 - const struct renesas_usbhs_platform_callback usbhs_rcar2_ops = { 72 - .hardware_init = usbhs_rcar2_hardware_init, 73 - .hardware_exit = usbhs_rcar2_hardware_exit, 74 - .power_ctrl = usbhs_rcar2_power_ctrl, 75 - .get_id = usbhs_rcar2_get_id, 65 + const struct renesas_usbhs_platform_info usbhs_rcar_gen2_plat_info = { 66 + .platform_callback = { 67 + .hardware_init = usbhs_rcar2_hardware_init, 68 + .hardware_exit = usbhs_rcar2_hardware_exit, 69 + .power_ctrl = usbhs_rcar2_power_ctrl, 70 + .get_id = usbhs_get_id_as_gadget, 71 + }, 72 + .driver_param = { 73 + .has_usb_dmac = 1, 74 + .has_new_pipe_configs = 1, 75 + }, 76 76 };
+1 -2
drivers/usb/renesas_usbhs/rcar2.h
··· 1 1 // SPDX-License-Identifier: GPL-2.0 2 2 #include "common.h" 3 3 4 - extern const struct renesas_usbhs_platform_callback 5 - usbhs_rcar2_ops; 4 + extern const struct renesas_usbhs_platform_info usbhs_rcar_gen2_plat_info;
+21 -12
drivers/usb/renesas_usbhs/rcar3.c
··· 2 2 /* 3 3 * Renesas USB driver R-Car Gen. 3 initialization and power control 4 4 * 5 - * Copyright (C) 2016 Renesas Electronics Corporation 5 + * Copyright (C) 2016-2019 Renesas Electronics Corporation 6 6 */ 7 7 8 8 #include <linux/delay.h> ··· 95 95 return 0; 96 96 } 97 97 98 - static int usbhs_rcar3_get_id(struct platform_device *pdev) 99 - { 100 - return USBHS_GADGET; 101 - } 102 - 103 - const struct renesas_usbhs_platform_callback usbhs_rcar3_ops = { 104 - .power_ctrl = usbhs_rcar3_power_ctrl, 105 - .get_id = usbhs_rcar3_get_id, 98 + const struct renesas_usbhs_platform_info usbhs_rcar_gen3_plat_info = { 99 + .platform_callback = { 100 + .power_ctrl = usbhs_rcar3_power_ctrl, 101 + .get_id = usbhs_get_id_as_gadget, 102 + }, 103 + .driver_param = { 104 + .has_usb_dmac = 1, 105 + .multi_clks = 1, 106 + .has_new_pipe_configs = 1, 107 + }, 106 108 }; 107 109 108 - const struct renesas_usbhs_platform_callback usbhs_rcar3_with_pll_ops = { 109 - .power_ctrl = usbhs_rcar3_power_and_pll_ctrl, 110 - .get_id = usbhs_rcar3_get_id, 110 + const struct renesas_usbhs_platform_info usbhs_rcar_gen3_with_pll_plat_info = { 111 + .platform_callback = { 112 + .power_ctrl = usbhs_rcar3_power_and_pll_ctrl, 113 + .get_id = usbhs_get_id_as_gadget, 114 + }, 115 + .driver_param = { 116 + .has_usb_dmac = 1, 117 + .multi_clks = 1, 118 + .has_new_pipe_configs = 1, 119 + }, 111 120 };
+3 -2
drivers/usb/renesas_usbhs/rcar3.h
··· 1 1 // SPDX-License-Identifier: GPL-2.0 2 2 #include "common.h" 3 3 4 - extern const struct renesas_usbhs_platform_callback usbhs_rcar3_ops; 5 - extern const struct renesas_usbhs_platform_callback usbhs_rcar3_with_pll_ops; 4 + extern const struct renesas_usbhs_platform_info usbhs_rcar_gen3_plat_info; 5 + extern const struct renesas_usbhs_platform_info 6 + usbhs_rcar_gen3_with_pll_plat_info;
+9 -9
drivers/usb/renesas_usbhs/rza.c
··· 3 3 * Renesas USB driver RZ/A initialization and power control 4 4 * 5 5 * Copyright (C) 2018 Chris Brandt 6 - * Copyright (C) 2018 Renesas Electronics Corporation 6 + * Copyright (C) 2018-2019 Renesas Electronics Corporation 7 7 */ 8 8 9 9 #include <linux/delay.h> ··· 41 41 return 0; 42 42 } 43 43 44 - static int usbhs_rza_get_id(struct platform_device *pdev) 45 - { 46 - return USBHS_GADGET; 47 - } 48 - 49 - const struct renesas_usbhs_platform_callback usbhs_rza1_ops = { 50 - .hardware_init = usbhs_rza1_hardware_init, 51 - .get_id = usbhs_rza_get_id, 44 + const struct renesas_usbhs_platform_info usbhs_rza1_plat_info = { 45 + .platform_callback = { 46 + .hardware_init = usbhs_rza1_hardware_init, 47 + .get_id = usbhs_get_id_as_gadget, 48 + }, 49 + .driver_param = { 50 + .has_new_pipe_configs = 1, 51 + }, 52 52 };
+2 -1
drivers/usb/renesas_usbhs/rza.h
··· 1 1 // SPDX-License-Identifier: GPL-2.0 2 2 #include "common.h" 3 3 4 - extern const struct renesas_usbhs_platform_callback usbhs_rza1_ops; 4 + extern const struct renesas_usbhs_platform_info usbhs_rza1_plat_info; 5 + extern const struct renesas_usbhs_platform_info usbhs_rza2_plat_info;
+74
drivers/usb/renesas_usbhs/rza2.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + /* 3 + * Renesas USB driver RZ/A2 initialization and power control 4 + * 5 + * Copyright (C) 2019 Chris Brandt 6 + * Copyright (C) 2019 Renesas Electronics Corporation 7 + */ 8 + 9 + #include <linux/delay.h> 10 + #include <linux/io.h> 11 + #include <linux/of_device.h> 12 + #include <linux/phy/phy.h> 13 + #include "common.h" 14 + #include "rza.h" 15 + 16 + static int usbhs_rza2_hardware_init(struct platform_device *pdev) 17 + { 18 + struct usbhs_priv *priv = usbhs_pdev_to_priv(pdev); 19 + struct phy *phy = phy_get(&pdev->dev, "usb"); 20 + 21 + if (IS_ERR(phy)) 22 + return PTR_ERR(phy); 23 + 24 + priv->phy = phy; 25 + return 0; 26 + } 27 + 28 + static int usbhs_rza2_hardware_exit(struct platform_device *pdev) 29 + { 30 + struct usbhs_priv *priv = usbhs_pdev_to_priv(pdev); 31 + 32 + phy_put(priv->phy); 33 + priv->phy = NULL; 34 + 35 + return 0; 36 + } 37 + 38 + static int usbhs_rza2_power_ctrl(struct platform_device *pdev, 39 + void __iomem *base, int enable) 40 + { 41 + struct usbhs_priv *priv = usbhs_pdev_to_priv(pdev); 42 + int retval = 0; 43 + 44 + if (!priv->phy) 45 + return -ENODEV; 46 + 47 + if (enable) { 48 + retval = phy_init(priv->phy); 49 + usbhs_bset(priv, SUSPMODE, SUSPM, SUSPM); 50 + udelay(100); /* Wait for PLL to become stable */ 51 + if (!retval) 52 + retval = phy_power_on(priv->phy); 53 + } else { 54 + usbhs_bset(priv, SUSPMODE, SUSPM, 0); 55 + phy_power_off(priv->phy); 56 + phy_exit(priv->phy); 57 + } 58 + 59 + return retval; 60 + } 61 + 62 + const struct renesas_usbhs_platform_info usbhs_rza2_plat_info = { 63 + .platform_callback = { 64 + .hardware_init = usbhs_rza2_hardware_init, 65 + .hardware_exit = usbhs_rza2_hardware_exit, 66 + .power_ctrl = usbhs_rza2_power_ctrl, 67 + .get_id = usbhs_get_id_as_gadget, 68 + }, 69 + .driver_param = { 70 + .has_cnen = 1, 71 + .cfifo_byte_addr = 1, 72 + .has_new_pipe_configs = 1, 73 + }, 74 + };
+5 -5
drivers/usb/serial/Kconfig
··· 11 11 ports, or acts like a serial device, and you want to connect it to 12 12 your USB bus. 13 13 14 - Please read <file:Documentation/usb/usb-serial.txt> for more 14 + Please read <file:Documentation/usb/usb-serial.rst> for more 15 15 information on the specifics of the different devices that are 16 16 supported, and on how to use them. 17 17 ··· 47 47 bool "USB Generic Serial Driver" 48 48 help 49 49 Say Y here if you want to use the generic USB serial driver. Please 50 - read <file:Documentation/usb/usb-serial.txt> for more information on 50 + read <file:Documentation/usb/usb-serial.rst> for more information on 51 51 using this driver. It is recommended that the "USB Serial converter 52 52 support" be compiled as a module for this driver to be used 53 53 properly. ··· 163 163 help 164 164 Say Y here if you want to connect to your Empeg empeg-car Mark I/II 165 165 mp3 player via USB. The driver uses a single ttyUSB{0,1,2,...} 166 - device node. See <file:Documentation/usb/usb-serial.txt> for more 166 + device node. See <file:Documentation/usb/usb-serial.rst> for more 167 167 tidbits of information. 168 168 169 169 To compile this driver as a module, choose M here: the ··· 199 199 Say Y here if you want to connect to your Compaq iPAQ, HP Jornada 200 200 or any other PDA running Windows CE 3.0 or PocketPC 2002 201 201 using a USB cradle/cable. For information on using the driver, 202 - read <file:Documentation/usb/usb-serial.txt>. 202 + read <file:Documentation/usb/usb-serial.rst>. 203 203 204 204 To compile this driver as a module, choose M here: the 205 205 module will be called ipaq. ··· 334 334 adapter sold by Palm Inc. for use with their Palm III and Palm V 335 335 series PDAs. 336 336 337 - Please read <file:Documentation/usb/usb-serial.txt> for more 337 + Please read <file:Documentation/usb/usb-serial.rst> for more 338 338 information. 339 339 340 340 To compile this driver as a module, choose M here: the
+1 -1
drivers/usb/serial/belkin_sa.c
··· 10 10 * and associated source files. Please see the usb/serial files for 11 11 * individual credits and copyrights. 12 12 * 13 - * See Documentation/usb/usb-serial.txt for more information on using this 13 + * See Documentation/usb/usb-serial.rst for more information on using this 14 14 * driver 15 15 * 16 16 * TODO:
+1 -1
drivers/usb/serial/belkin_sa.h
··· 9 9 * and associated source files. Please see the usb/serial files for 10 10 * individual credits and copyrights. 11 11 * 12 - * See Documentation/usb/usb-serial.txt for more information on using this 12 + * See Documentation/usb/usb-serial.rst for more information on using this 13 13 * driver 14 14 * 15 15 * 12-Mar-2001 gkh
+1 -1
drivers/usb/serial/cypress_m8.c
··· 7 7 * Copyright (C) 2003,2004 8 8 * Neil Whelchel (koyama@firstlight.net) 9 9 * 10 - * See Documentation/usb/usb-serial.txt for more information on using this 10 + * See Documentation/usb/usb-serial.rst for more information on using this 11 11 * driver 12 12 * 13 13 * See http://geocities.com/i0xox0i for information on this driver and the
+1 -1
drivers/usb/serial/empeg.c
··· 8 8 * Copyright (C) 1999 - 2001 9 9 * Greg Kroah-Hartman (greg@kroah.com) 10 10 * 11 - * See Documentation/usb/usb-serial.txt for more information on using this 11 + * See Documentation/usb/usb-serial.rst for more information on using this 12 12 * driver 13 13 */ 14 14
+2 -1
drivers/usb/serial/ftdi_sio.c
··· 10 10 * Copyright (C) 2002 11 11 * Kuba Ober (kuba@mareimbrium.org) 12 12 * 13 - * See Documentation/usb/usb-serial.txt for more information on using this 13 + * See Documentation/usb/usb-serial.rst for more information on using this 14 14 * driver 15 15 * 16 16 * See http://ftdi-usb-sio.sourceforge.net for up to date testing info ··· 1029 1029 { USB_DEVICE(AIRBUS_DS_VID, AIRBUS_DS_P8GR) }, 1030 1030 /* EZPrototypes devices */ 1031 1031 { USB_DEVICE(EZPROTOTYPES_VID, HJELMSLUND_USB485_ISO_PID) }, 1032 + { USB_DEVICE_INTERFACE_NUMBER(UNJO_VID, UNJO_ISODEBUG_V1_PID, 1) }, 1032 1033 { } /* Terminating entry */ 1033 1034 }; 1034 1035
+6
drivers/usb/serial/ftdi_sio_ids.h
··· 1543 1543 #define CHETCO_SEASMART_DISPLAY_PID 0xA5AD /* SeaSmart NMEA2000 Display */ 1544 1544 #define CHETCO_SEASMART_LITE_PID 0xA5AE /* SeaSmart Lite USB Adapter */ 1545 1545 #define CHETCO_SEASMART_ANALOG_PID 0xA5AF /* SeaSmart Analog Adapter */ 1546 + 1547 + /* 1548 + * Unjo AB 1549 + */ 1550 + #define UNJO_VID 0x22B7 1551 + #define UNJO_ISODEBUG_V1_PID 0x150D
+1 -1
drivers/usb/serial/ir-usb.c
··· 16 16 * was written by Roman Weissgaerber <weissg@vienna.at>, Dag Brattli 17 17 * <dag@brattli.net>, and Jean Tourrilhes <jt@hpl.hp.com> 18 18 * 19 - * See Documentation/usb/usb-serial.txt for more information on using this 19 + * See Documentation/usb/usb-serial.rst for more information on using this 20 20 * driver 21 21 */ 22 22
+1 -1
drivers/usb/serial/keyspan_pda.c
··· 6 6 * Copyright (C) 1999, 2000 Brian Warner <warner@lothar.com> 7 7 * Copyright (C) 2000 Al Borchers <borchers@steinerpoint.com> 8 8 * 9 - * See Documentation/usb/usb-serial.txt for more information on using this 9 + * See Documentation/usb/usb-serial.rst for more information on using this 10 10 * driver 11 11 */ 12 12
+1 -1
drivers/usb/serial/omninet.c
··· 4 4 * 5 5 * Copyright (C) 2013,2017 Johan Hovold <johan@kernel.org> 6 6 * 7 - * See Documentation/usb/usb-serial.txt for more information on using this 7 + * See Documentation/usb/usb-serial.rst for more information on using this 8 8 * driver 9 9 * 10 10 * Please report both successes and troubles to the author at omninet@kroah.com
+1
drivers/usb/serial/option.c
··· 1343 1343 .driver_info = RSVD(4) }, 1344 1344 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0414, 0xff, 0xff, 0xff) }, 1345 1345 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0417, 0xff, 0xff, 0xff) }, 1346 + { USB_DEVICE_INTERFACE_CLASS(ZTE_VENDOR_ID, 0x0601, 0xff) }, /* GosunCn ZTE WeLink ME3630 (RNDIS mode) */ 1346 1347 { USB_DEVICE_INTERFACE_CLASS(ZTE_VENDOR_ID, 0x0602, 0xff) }, /* GosunCn ZTE WeLink ME3630 (MBIM mode) */ 1347 1348 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1008, 0xff, 0xff, 0xff), 1348 1349 .driver_info = RSVD(4) },
+1 -1
drivers/usb/serial/oti6858.c
··· 22 22 * So, THIS CODE CAN DESTROY OTi-6858 AND ANY OTHER DEVICES, THAT ARE 23 23 * CONNECTED TO IT! 24 24 * 25 - * See Documentation/usb/usb-serial.txt for more information on using this 25 + * See Documentation/usb/usb-serial.rst for more information on using this 26 26 * driver 27 27 * 28 28 * TODO:
+1 -1
drivers/usb/serial/pl2303.c
··· 7 7 * 8 8 * Original driver for 2.2.x by anonymous 9 9 * 10 - * See Documentation/usb/usb-serial.txt for more information on using this 10 + * See Documentation/usb/usb-serial.rst for more information on using this 11 11 * driver 12 12 */ 13 13
+1 -1
drivers/usb/serial/usb-serial.c
··· 10 10 * This driver was originally based on the ACM driver by Armin Fuerst (which was 11 11 * based on a driver by Brad Keryan) 12 12 * 13 - * See Documentation/usb/usb-serial.txt for more information on using this 13 + * See Documentation/usb/usb-serial.rst for more information on using this 14 14 * driver 15 15 */ 16 16
+1 -1
drivers/usb/serial/visor.c
··· 6 6 * Copyright (C) 1999 - 2004 7 7 * Greg Kroah-Hartman (greg@kroah.com) 8 8 * 9 - * See Documentation/usb/usb-serial.txt for more information on using this 9 + * See Documentation/usb/usb-serial.rst for more information on using this 10 10 * driver 11 11 * 12 12 */
+1 -1
drivers/usb/serial/visor.h
··· 5 5 * Copyright (C) 1999 - 2003 6 6 * Greg Kroah-Hartman (greg@kroah.com) 7 7 * 8 - * See Documentation/usb/usb-serial.txt for more information on using this 8 + * See Documentation/usb/usb-serial.rst for more information on using this 9 9 * driver. 10 10 * 11 11 */
+1 -1
drivers/usb/serial/whiteheat.c
··· 8 8 * Copyright (C) 1999 - 2001 9 9 * Greg Kroah-Hartman (greg@kroah.com) 10 10 * 11 - * See Documentation/usb/usb-serial.txt for more information on using this 11 + * See Documentation/usb/usb-serial.rst for more information on using this 12 12 * driver 13 13 */ 14 14
+1 -1
drivers/usb/serial/whiteheat.h
··· 8 8 * Copyright (C) 1999, 2000 9 9 * Greg Kroah-Hartman (greg@kroah.com) 10 10 * 11 - * See Documentation/usb/usb-serial.txt for more information on using this 11 + * See Documentation/usb/usb-serial.rst for more information on using this 12 12 * driver 13 13 * 14 14 */
+5 -2
drivers/usb/storage/scsiglue.c
··· 195 195 */ 196 196 sdev->skip_ms_page_8 = 1; 197 197 198 - /* Some devices don't handle VPD pages correctly */ 199 - sdev->skip_vpd_pages = 1; 198 + /* 199 + * Some devices don't handle VPD pages correctly, so skip vpd 200 + * pages if not forced by SCSI layer. 201 + */ 202 + sdev->skip_vpd_pages = !sdev->try_vpd_pages; 200 203 201 204 /* Do not attempt to use REPORT SUPPORTED OPERATION CODES */ 202 205 sdev->no_report_opcodes = 1;
+1 -2
drivers/usb/typec/tcpm/fusb302.c
··· 1697 1697 const struct i2c_device_id *id) 1698 1698 { 1699 1699 struct fusb302_chip *chip; 1700 - struct i2c_adapter *adapter; 1700 + struct i2c_adapter *adapter = client->adapter; 1701 1701 struct device *dev = &client->dev; 1702 1702 const char *name; 1703 1703 int ret = 0; 1704 1704 u32 v; 1705 1705 1706 - adapter = to_i2c_adapter(client->dev.parent); 1707 1706 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_I2C_BLOCK)) { 1708 1707 dev_err(&client->dev, 1709 1708 "I2C/SMBus block functionality not supported!\n");
+3 -3
drivers/usb/typec/tps6598x.c
··· 41 41 #define TPS_STATUS_VCONN(s) (!!((s) & BIT(7))) 42 42 43 43 /* TPS_REG_SYSTEM_CONF bits */ 44 - #define TPS_SYSCONF_PORTINFO(c) ((c) & 3) 44 + #define TPS_SYSCONF_PORTINFO(c) ((c) & 7) 45 45 46 46 enum { 47 47 TPS_PORTINFO_SINK, ··· 127 127 } 128 128 129 129 static int tps6598x_block_write(struct tps6598x *tps, u8 reg, 130 - void *val, size_t len) 130 + const void *val, size_t len) 131 131 { 132 132 u8 data[TPS_MAX_LEN + 1]; 133 133 ··· 173 173 static inline int 174 174 tps6598x_write_4cc(struct tps6598x *tps, u8 reg, const char *val) 175 175 { 176 - return tps6598x_block_write(tps, reg, &val, sizeof(u32)); 176 + return tps6598x_block_write(tps, reg, val, 4); 177 177 } 178 178 179 179 static int tps6598x_read_partner_identity(struct tps6598x *tps)
+3 -5
drivers/usb/usbip/stub_main.c
··· 201 201 202 202 static int do_rebind(char *busid, struct bus_id_priv *busid_priv) 203 203 { 204 - int ret; 204 + int ret = 0; 205 205 206 206 /* device_attach() callers should hold parent lock for USB */ 207 207 if (busid_priv->udev->dev.parent) ··· 209 209 ret = device_attach(&busid_priv->udev->dev); 210 210 if (busid_priv->udev->dev.parent) 211 211 device_unlock(busid_priv->udev->dev.parent); 212 - if (ret < 0) { 212 + if (ret < 0) 213 213 dev_err(&busid_priv->udev->dev, "rebind failed\n"); 214 - return ret; 215 - } 216 - return 0; 214 + return ret; 217 215 } 218 216 219 217 static void stub_device_rebind(void)
+5 -7
drivers/usb/usbip/vhci_tx.c
··· 144 144 struct vhci_unlink *unlink = NULL; 145 145 146 146 struct msghdr msg; 147 - struct kvec iov[3]; 147 + struct kvec iov; 148 148 size_t txsize; 149 - 150 149 size_t total_size = 0; 151 150 152 151 while ((unlink = dequeue_from_unlink_tx(vdev)) != NULL) { 153 152 int ret; 154 153 struct usbip_header pdu_header; 155 154 156 - txsize = 0; 157 155 memset(&pdu_header, 0, sizeof(pdu_header)); 158 156 memset(&msg, 0, sizeof(msg)); 159 157 memset(&iov, 0, sizeof(iov)); ··· 167 169 168 170 usbip_header_correct_endian(&pdu_header, 1); 169 171 170 - iov[0].iov_base = &pdu_header; 171 - iov[0].iov_len = sizeof(pdu_header); 172 - txsize += sizeof(pdu_header); 172 + iov.iov_base = &pdu_header; 173 + iov.iov_len = sizeof(pdu_header); 174 + txsize = sizeof(pdu_header); 173 175 174 - ret = kernel_sendmsg(vdev->ud.tcp_socket, &msg, iov, 1, txsize); 176 + ret = kernel_sendmsg(vdev->ud.tcp_socket, &msg, &iov, 1, txsize); 175 177 if (ret != txsize) { 176 178 pr_err("sendmsg failed!, ret=%d for %zd\n", ret, 177 179 txsize);
+3 -5
drivers/usb/wusbcore/Kconfig
··· 5 5 config USB_WUSB 6 6 tristate "Enable Wireless USB extensions" 7 7 depends on UWB 8 - select CRYPTO 9 - select CRYPTO_BLKCIPHER 10 - select CRYPTO_CBC 11 - select CRYPTO_MANAGER 12 - select CRYPTO_AES 8 + select CRYPTO 9 + select CRYPTO_AES 10 + select CRYPTO_CCM 13 11 help 14 12 Enable the host-side support for Wireless USB. 15 13
+44 -125
drivers/usb/wusbcore/crypto.c
··· 31 31 * funneled through AES are...16 bytes in size! 32 32 */ 33 33 34 + #include <crypto/aes.h> 35 + #include <crypto/algapi.h> 36 + #include <crypto/hash.h> 34 37 #include <crypto/skcipher.h> 35 38 #include <linux/crypto.h> 36 39 #include <linux/module.h> ··· 112 109 __be16 counter; /* Value of x */ 113 110 } __attribute__((packed)); 114 111 115 - static void bytewise_xor(void *_bo, const void *_bi1, const void *_bi2, 116 - size_t size) 117 - { 118 - u8 *bo = _bo; 119 - const u8 *bi1 = _bi1, *bi2 = _bi2; 120 - size_t itr; 121 - for (itr = 0; itr < size; itr++) 122 - bo[itr] = bi1[itr] ^ bi2[itr]; 123 - } 124 - 125 112 /* Scratch space for MAC calculations. */ 126 113 struct wusb_mac_scratch { 127 114 struct aes_ccm_b0 b0; ··· 143 150 * @a: ASCII string, 14 bytes long (I guess zero padded if needed; 144 151 * we use exactly 14 bytes). 145 152 * 146 - * @b: data stream to be processed; cannot be a global or const local 147 - * (will confuse the scatterlists) 153 + * @b: data stream to be processed 148 154 * 149 155 * @blen: size of b... 150 156 * ··· 152 160 * @key. We bytewise xor B0 with B1 (1) and AES-crypt that. Then we 153 161 * take the payload and divide it in blocks (16 bytes), xor them with 154 162 * the previous crypto result (16 bytes) and crypt it, repeat the next 155 - * block with the output of the previous one, rinse wash (I guess this 156 - * is what AES CBC mode means...but I truly have no idea). So we use 157 - * the CBC(AES) blkcipher, that does precisely that. The IV (Initial 163 + * block with the output of the previous one, rinse wash. So we use 164 + * the CBC-MAC(AES) shash, that does precisely that. The IV (Initial 158 165 * Vector) is 16 bytes and is set to zero, so 159 - * 160 - * See rfc3610. Linux crypto has a CBC implementation, but the 161 - * documentation is scarce, to say the least, and the example code is 162 - * so intricated that is difficult to understand how things work. Most 163 - * of this is guess work -- bite me. 164 166 * 165 167 * (1) Created as 6.5 says, again, using as l(a) 'Blen + 14', and 166 168 * using the 14 bytes of @a to fill up ··· 175 189 * NOTE: blen is not aligned to a block size, we'll pad zeros, that's 176 190 * what sg[4] is for. Maybe there is a smarter way to do this. 177 191 */ 178 - static int wusb_ccm_mac(struct crypto_sync_skcipher *tfm_cbc, 179 - struct crypto_cipher *tfm_aes, 192 + static int wusb_ccm_mac(struct crypto_shash *tfm_cbcmac, 180 193 struct wusb_mac_scratch *scratch, 181 194 void *mic, 182 195 const struct aes_ccm_nonce *n, 183 196 const struct aes_ccm_label *a, const void *b, 184 197 size_t blen) 185 198 { 186 - int result = 0; 187 - SYNC_SKCIPHER_REQUEST_ON_STACK(req, tfm_cbc); 188 - struct scatterlist sg[4], sg_dst; 189 - void *dst_buf; 190 - size_t dst_size; 191 - u8 *iv; 192 - size_t zero_padding; 199 + SHASH_DESC_ON_STACK(desc, tfm_cbcmac); 200 + u8 iv[AES_BLOCK_SIZE]; 193 201 194 202 /* 195 203 * These checks should be compile time optimized out 196 204 * ensure @a fills b1's mac_header and following fields 197 205 */ 198 - WARN_ON(sizeof(*a) != sizeof(scratch->b1) - sizeof(scratch->b1.la)); 199 - WARN_ON(sizeof(scratch->b0) != sizeof(struct aes_ccm_block)); 200 - WARN_ON(sizeof(scratch->b1) != sizeof(struct aes_ccm_block)); 201 - WARN_ON(sizeof(scratch->ax) != sizeof(struct aes_ccm_block)); 202 - 203 - result = -ENOMEM; 204 - zero_padding = blen % sizeof(struct aes_ccm_block); 205 - if (zero_padding) 206 - zero_padding = sizeof(struct aes_ccm_block) - zero_padding; 207 - dst_size = blen + sizeof(scratch->b0) + sizeof(scratch->b1) + 208 - zero_padding; 209 - dst_buf = kzalloc(dst_size, GFP_KERNEL); 210 - if (!dst_buf) 211 - goto error_dst_buf; 212 - 213 - iv = kzalloc(crypto_sync_skcipher_ivsize(tfm_cbc), GFP_KERNEL); 214 - if (!iv) 215 - goto error_iv; 206 + BUILD_BUG_ON(sizeof(*a) != sizeof(scratch->b1) - sizeof(scratch->b1.la)); 207 + BUILD_BUG_ON(sizeof(scratch->b0) != sizeof(struct aes_ccm_block)); 208 + BUILD_BUG_ON(sizeof(scratch->b1) != sizeof(struct aes_ccm_block)); 209 + BUILD_BUG_ON(sizeof(scratch->ax) != sizeof(struct aes_ccm_block)); 216 210 217 211 /* Setup B0 */ 218 212 scratch->b0.flags = 0x59; /* Format B0 */ ··· 209 243 scratch->b1.la = cpu_to_be16(blen + 14); 210 244 memcpy(&scratch->b1.mac_header, a, sizeof(*a)); 211 245 212 - sg_init_table(sg, ARRAY_SIZE(sg)); 213 - sg_set_buf(&sg[0], &scratch->b0, sizeof(scratch->b0)); 214 - sg_set_buf(&sg[1], &scratch->b1, sizeof(scratch->b1)); 215 - sg_set_buf(&sg[2], b, blen); 216 - /* 0 if well behaved :) */ 217 - sg_set_page(&sg[3], ZERO_PAGE(0), zero_padding, 0); 218 - sg_init_one(&sg_dst, dst_buf, dst_size); 219 - 220 - skcipher_request_set_sync_tfm(req, tfm_cbc); 221 - skcipher_request_set_callback(req, 0, NULL, NULL); 222 - skcipher_request_set_crypt(req, sg, &sg_dst, dst_size, iv); 223 - result = crypto_skcipher_encrypt(req); 224 - skcipher_request_zero(req); 225 - if (result < 0) { 226 - printk(KERN_ERR "E: can't compute CBC-MAC tag (MIC): %d\n", 227 - result); 228 - goto error_cbc_crypt; 229 - } 246 + desc->tfm = tfm_cbcmac; 247 + crypto_shash_init(desc); 248 + crypto_shash_update(desc, (u8 *)&scratch->b0, sizeof(scratch->b0) + 249 + sizeof(scratch->b1)); 250 + crypto_shash_finup(desc, b, blen, iv); 230 251 231 252 /* Now we crypt the MIC Tag (*iv) with Ax -- values per WUSB1.0[6.5] 232 253 * The procedure is to AES crypt the A0 block and XOR the MIC 233 254 * Tag against it; we only do the first 8 bytes and place it 234 255 * directly in the destination buffer. 235 - * 236 - * POS Crypto API: size is assumed to be AES's block size. 237 - * Thanks for documenting it -- tip taken from airo.c 238 256 */ 239 257 scratch->ax.flags = 0x01; /* as per WUSB 1.0 spec */ 240 258 scratch->ax.ccm_nonce = *n; 241 259 scratch->ax.counter = 0; 242 - crypto_cipher_encrypt_one(tfm_aes, (void *)&scratch->ax, 243 - (void *)&scratch->ax); 244 - bytewise_xor(mic, &scratch->ax, iv, 8); 245 - result = 8; 246 - error_cbc_crypt: 247 - kfree(iv); 248 - error_iv: 249 - kfree(dst_buf); 250 - error_dst_buf: 251 - return result; 260 + 261 + /* reuse the CBC-MAC transform to perform the single block encryption */ 262 + crypto_shash_digest(desc, (u8 *)&scratch->ax, sizeof(scratch->ax), 263 + (u8 *)&scratch->ax); 264 + 265 + crypto_xor_cpy(mic, (u8 *)&scratch->ax, iv, 8); 266 + 267 + return 8; 252 268 } 253 269 254 270 /* ··· 246 298 { 247 299 ssize_t result, bytes = 0, bitr; 248 300 struct aes_ccm_nonce n = *_n; 249 - struct crypto_sync_skcipher *tfm_cbc; 250 - struct crypto_cipher *tfm_aes; 251 - struct wusb_mac_scratch *scratch; 301 + struct crypto_shash *tfm_cbcmac; 302 + struct wusb_mac_scratch scratch; 252 303 u64 sfn = 0; 253 304 __le64 sfn_le; 254 305 255 - tfm_cbc = crypto_alloc_sync_skcipher("cbc(aes)", 0, 0); 256 - if (IS_ERR(tfm_cbc)) { 257 - result = PTR_ERR(tfm_cbc); 258 - printk(KERN_ERR "E: can't load CBC(AES): %d\n", (int)result); 259 - goto error_alloc_cbc; 260 - } 261 - result = crypto_sync_skcipher_setkey(tfm_cbc, key, 16); 262 - if (result < 0) { 263 - printk(KERN_ERR "E: can't set CBC key: %d\n", (int)result); 264 - goto error_setkey_cbc; 306 + tfm_cbcmac = crypto_alloc_shash("cbcmac(aes)", 0, 0); 307 + if (IS_ERR(tfm_cbcmac)) { 308 + result = PTR_ERR(tfm_cbcmac); 309 + printk(KERN_ERR "E: can't load CBCMAC-AES: %d\n", (int)result); 310 + goto error_alloc_cbcmac; 265 311 } 266 312 267 - tfm_aes = crypto_alloc_cipher("aes", 0, 0); 268 - if (IS_ERR(tfm_aes)) { 269 - result = PTR_ERR(tfm_aes); 270 - printk(KERN_ERR "E: can't load AES: %d\n", (int)result); 271 - goto error_alloc_aes; 272 - } 273 - result = crypto_cipher_setkey(tfm_aes, key, 16); 313 + result = crypto_shash_setkey(tfm_cbcmac, key, AES_BLOCK_SIZE); 274 314 if (result < 0) { 275 - printk(KERN_ERR "E: can't set AES key: %d\n", (int)result); 276 - goto error_setkey_aes; 277 - } 278 - scratch = kmalloc(sizeof(*scratch), GFP_KERNEL); 279 - if (!scratch) { 280 - result = -ENOMEM; 281 - goto error_alloc_scratch; 315 + printk(KERN_ERR "E: can't set CBCMAC-AES key: %d\n", (int)result); 316 + goto error_setkey_cbcmac; 282 317 } 283 318 284 319 for (bitr = 0; bitr < (len + 63) / 64; bitr++) { 285 320 sfn_le = cpu_to_le64(sfn++); 286 321 memcpy(&n.sfn, &sfn_le, sizeof(n.sfn)); /* n.sfn++... */ 287 - result = wusb_ccm_mac(tfm_cbc, tfm_aes, scratch, out + bytes, 322 + result = wusb_ccm_mac(tfm_cbcmac, &scratch, out + bytes, 288 323 &n, a, b, blen); 289 324 if (result < 0) 290 325 goto error_ccm_mac; ··· 275 344 } 276 345 result = bytes; 277 346 278 - kfree(scratch); 279 - error_alloc_scratch: 280 347 error_ccm_mac: 281 - error_setkey_aes: 282 - crypto_free_cipher(tfm_aes); 283 - error_alloc_aes: 284 - error_setkey_cbc: 285 - crypto_free_sync_skcipher(tfm_cbc); 286 - error_alloc_cbc: 348 + error_setkey_cbcmac: 349 + crypto_free_shash(tfm_cbcmac); 350 + error_alloc_cbcmac: 287 351 return result; 288 352 } 289 353 ··· 303 377 { 304 378 int result; 305 379 u8 mic[8]; 306 - /* WUSB1.0[A.2] test vectors 307 - * 308 - * Need to keep it in the local stack as GCC 4.1.3something 309 - * messes up and generates noise. 310 - */ 311 - struct usb_handshake stv_hsmic_hs = { 380 + /* WUSB1.0[A.2] test vectors */ 381 + static const struct usb_handshake stv_hsmic_hs = { 312 382 .bMessageNumber = 2, 313 383 .bStatus = 00, 314 384 .tTKID = { 0x76, 0x98, 0x01 }, ··· 379 457 { 380 458 int result = 0; 381 459 struct wusb_keydvt_out keydvt_out; 382 - /* These come from WUSB1.0[A.1] + 2006/12 errata 383 - * NOTE: can't make this const or global -- somehow it seems 384 - * the scatterlists for crypto get confused and we get 385 - * bad data. There is no doc on this... */ 386 - struct wusb_keydvt_in stv_keydvt_in_a1 = { 460 + /* These come from WUSB1.0[A.1] + 2006/12 errata */ 461 + static const struct wusb_keydvt_in stv_keydvt_in_a1 = { 387 462 .hnonce = { 388 463 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 389 464 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f
+1
include/linux/fsl_devices.h
··· 98 98 unsigned has_fsl_erratum_14:1; 99 99 unsigned has_fsl_erratum_a005275:1; 100 100 unsigned has_fsl_erratum_a005697:1; 101 + unsigned has_fsl_erratum_a006918:1; 101 102 unsigned check_phy_clk_valid:1; 102 103 103 104 /* register save area for suspend/resume */
+2
include/linux/usb.h
··· 578 578 * @bus_mA: Current available from the bus 579 579 * @portnum: parent port number (origin 1) 580 580 * @level: number of USB hub ancestors 581 + * @devaddr: device address, XHCI: assigned by HW, others: same as devnum 581 582 * @can_submit: URBs may be submitted 582 583 * @persist_enabled: USB_PERSIST enabled for this device 583 584 * @have_langid: whether string_langid is valid ··· 662 661 unsigned short bus_mA; 663 662 u8 portnum; 664 663 u8 level; 664 + u8 devaddr; 665 665 666 666 unsigned can_submit:1; 667 667 unsigned persist_enabled:1;
+1
include/linux/usb/chipidea.h
··· 61 61 #define CI_HDRC_OVERRIDE_PHY_CONTROL BIT(12) /* Glue layer manages phy */ 62 62 #define CI_HDRC_REQUIRES_ALIGNED_DMA BIT(13) 63 63 #define CI_HDRC_IMX_IS_HSIC BIT(14) 64 + #define CI_HDRC_PMQOS BIT(15) 64 65 enum usb_dr_mode dr_mode; 65 66 #define CI_HDRC_CONTROLLER_RESET_EVENT 0 66 67 #define CI_HDRC_CONTROLLER_STOPPED_EVENT 1
+2 -1
include/linux/usb/gadget.h
··· 310 310 int (*pullup) (struct usb_gadget *, int is_on); 311 311 int (*ioctl)(struct usb_gadget *, 312 312 unsigned code, unsigned long param); 313 - void (*get_config_params)(struct usb_dcd_config_params *); 313 + void (*get_config_params)(struct usb_gadget *, 314 + struct usb_dcd_config_params *); 314 315 int (*udc_start)(struct usb_gadget *, 315 316 struct usb_gadget_driver *); 316 317 int (*udc_stop)(struct usb_gadget *);
+6 -33
include/linux/usb/renesas_usbhs.h
··· 3 3 * Renesas USB 4 4 * 5 5 * Copyright (C) 2011 Renesas Solutions Corp. 6 + * Copyright (C) 2019 Renesas Electronics Corporation 6 7 * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> 7 8 * 8 9 * This program is distributed in the hope that it will be useful, ··· 31 30 USBHS_HOST = 0, 32 31 USBHS_GADGET, 33 32 USBHS_MAX, 34 - }; 35 - 36 - /* 37 - * callback functions table for driver 38 - * 39 - * These functions are called from platform for driver. 40 - * Callback function's pointer will be set before 41 - * renesas_usbhs_platform_callback :: hardware_init was called 42 - */ 43 - struct renesas_usbhs_driver_callback { 44 - int (*notify_hotplug)(struct platform_device *pdev); 45 33 }; 46 34 47 35 /* ··· 170 180 */ 171 181 int pio_dma_border; /* default is 64byte */ 172 182 173 - uintptr_t type; 174 183 u32 enable_gpio; 175 184 176 185 /* 177 186 * option: 178 187 */ 179 - u32 has_otg:1; /* for controlling PWEN/EXTLP */ 180 - u32 has_sudmac:1; /* for SUDMAC */ 181 188 u32 has_usb_dmac:1; /* for USB-DMAC */ 189 + u32 runtime_pwctrl:1; 190 + u32 has_cnen:1; 191 + u32 cfifo_byte_addr:1; /* CFIFO is byte addressable */ 182 192 #define USBHS_USB_DMAC_XFER_SIZE 32 /* hardcode the xfer size */ 193 + u32 multi_clks:1; 194 + u32 has_new_pipe_configs:1; 183 195 }; 184 - 185 - #define USBHS_TYPE_RCAR_GEN2 1 186 - #define USBHS_TYPE_RCAR_GEN3 2 187 - #define USBHS_TYPE_RCAR_GEN3_WITH_PLL 3 188 - #define USBHS_TYPE_RZA1 4 189 196 190 197 /* 191 198 * option: ··· 199 212 struct renesas_usbhs_platform_callback platform_callback; 200 213 201 214 /* 202 - * driver set these callback functions pointer. 203 - * platform can use it on callback functions 204 - */ 205 - struct renesas_usbhs_driver_callback driver_callback; 206 - 207 - /* 208 215 * option: 209 216 * 210 217 * driver use these param for some register ··· 211 230 */ 212 231 #define renesas_usbhs_get_info(pdev)\ 213 232 ((struct renesas_usbhs_platform_info *)(pdev)->dev.platform_data) 214 - 215 - #define renesas_usbhs_call_notify_hotplug(pdev) \ 216 - ({ \ 217 - struct renesas_usbhs_driver_callback *dc; \ 218 - dc = &(renesas_usbhs_get_info(pdev)->driver_callback); \ 219 - if (dc && dc->notify_hotplug) \ 220 - dc->notify_hotplug(pdev); \ 221 - }) 222 233 #endif /* RENESAS_USB_H */
+26
include/uapi/linux/usbdevice_fs.h
··· 76 76 unsigned char slow; 77 77 }; 78 78 79 + struct usbdevfs_conninfo_ex { 80 + __u32 size; /* Size of the structure from the kernel's */ 81 + /* point of view. Can be used by userspace */ 82 + /* to determine how much data can be */ 83 + /* used/trusted. */ 84 + __u32 busnum; /* USB bus number, as enumerated by the */ 85 + /* kernel, the device is connected to. */ 86 + __u32 devnum; /* Device address on the bus. */ 87 + __u32 speed; /* USB_SPEED_* constants from ch9.h */ 88 + __u8 num_ports; /* Number of ports the device is connected */ 89 + /* to on the way to the root hub. It may */ 90 + /* be bigger than size of 'ports' array so */ 91 + /* userspace can detect overflows. */ 92 + __u8 ports[7]; /* List of ports on the way from the root */ 93 + /* hub to the device. Current limit in */ 94 + /* USB specification is 7 tiers (root hub, */ 95 + /* 5 intermediate hubs, device), which */ 96 + /* gives at most 6 port entries. */ 97 + }; 98 + 79 99 #define USBDEVFS_URB_SHORT_NOT_OK 0x01 80 100 #define USBDEVFS_URB_ISO_ASAP 0x02 81 101 #define USBDEVFS_URB_BULK_CONTINUATION 0x04 ··· 157 137 #define USBDEVFS_CAP_REAP_AFTER_DISCONNECT 0x10 158 138 #define USBDEVFS_CAP_MMAP 0x20 159 139 #define USBDEVFS_CAP_DROP_PRIVILEGES 0x40 140 + #define USBDEVFS_CAP_CONNINFO_EX 0x80 160 141 161 142 /* USBDEVFS_DISCONNECT_CLAIM flags & struct */ 162 143 ··· 218 197 #define USBDEVFS_FREE_STREAMS _IOR('U', 29, struct usbdevfs_streams) 219 198 #define USBDEVFS_DROP_PRIVILEGES _IOW('U', 30, __u32) 220 199 #define USBDEVFS_GET_SPEED _IO('U', 31) 200 + /* 201 + * Returns struct usbdevfs_conninfo_ex; length is variable to allow 202 + * extending size of the data returned. 203 + */ 204 + #define USBDEVFS_CONNINFO_EX(len) _IOC(_IOC_READ, 'U', 32, len) 221 205 222 206 #endif /* _UAPI_LINUX_USBDEVICE_FS_H */