Pull USB/PHY updates from Greg KH: "Here is the big USB/PHY driver pull request for 5.1-rc1. The usual set of gadget driver updates, phy driver updates, xhci updates, and typec additions. Also included in here are a lot of small cleanups and fixes and driver updates where needed. All of these have been in linux-next for a while with no reported issues" * tag 'usb-5.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (167 commits) wusb: Remove unnecessary static function ckhdid_printf usb: core: make default autosuspend delay configurable usb: core: Fix typo in description of "authorized_default" usb: chipidea: Refactor USB PHY selection and keep a single PHY usb: chipidea: Grab the (legacy) USB PHY by phandle first usb: chipidea: imx: set power polarity dt-bindings: usb: ci-hdrc-usb2: add property power-active-high usb: chipidea: imx: remove unused header files usb: chipidea: tegra: Fix missed ci_hdrc_remove_device() usb: core: add option of only authorizing internal devices usb: typec: tps6598x: handle block writes separately with plain-I2C adapters usb: xhci: Fix for Enabling USB ROLE SWITCH QUIRK on INTEL_SUNRISEPOINT_LP_XHCI usb: xhci: fix build warning - missing prototype usb: xhci: dbc: Fixing typo error. usb: xhci: remove unused member 'parent' in xhci_regset struct xhci: tegra: Prevent error pointer dereference USB: serial: option: add Telit ME910 ECM composition usb: core: Replace hardcoded check with inline function from usb.h usb: core: skip interfaces disabled in devicetree usb: typec: mux: remove redundant check on variable match ...
Unified · Split
| @@ -186,7 +186,7 @@ Contact: Lan Tianyu <tianyu.lan@intel.com> · 185 unmodified lines | |||
| 186 | Description: | 186 | Description: |
| 187 | Some platforms provide usb port connect types through ACPI. | 187 | Some platforms provide usb port connect types through ACPI. |
| 188 | This attribute is to expose these information to user space. | 188 | This attribute is to expose these information to user space. |
| 189 | The file will read "hotplug", "wired" and "not used" if the | 189 | The file will read "hotplug", "hardwired" and "not used" if the |
| 190 | information is available, and "unknown" otherwise. | 190 | information is available, and "unknown" otherwise. |
| 191 | 191 | ||
| 192 | What: /sys/bus/usb/devices/.../(hub interface)/portX/location | 192 | What: /sys/bus/usb/devices/.../(hub interface)/portX/location |
| @@ -4718,7 +4718,8 @@ · 4717 unmodified lines | |||
| 4718 | usbcore.authorized_default= | 4718 | usbcore.authorized_default= |
| 4719 | [USB] Default USB device authorization: | 4719 | [USB] Default USB device authorization: |
| 4720 | (default -1 = authorized except for wireless USB, | 4720 | (default -1 = authorized except for wireless USB, |
| 4721 | 0 = not authorized, 1 = authorized) | 4721 | 0 = not authorized, 1 = authorized, 2 = authorized |
| 4722 | if device connected to internal port) | ||
| 4722 | 4723 | ||
| 4723 | usbcore.autosuspend= | 4724 | usbcore.autosuspend= |
| 4724 | [USB] The autosuspend time delay (in seconds) used | 4725 | [USB] The autosuspend time delay (in seconds) used |
| @@ -147,6 +147,7 @@ required properties: · 146 unmodified lines | |||
| 147 | - compatible: Should be "atmel,<chip>-sfr", "syscon" or | 147 | - compatible: Should be "atmel,<chip>-sfr", "syscon" or |
| 148 | "atmel,<chip>-sfrbu", "syscon" | 148 | "atmel,<chip>-sfrbu", "syscon" |
| 149 | <chip> can be "sama5d3", "sama5d4" or "sama5d2". | 149 | <chip> can be "sama5d3", "sama5d4" or "sama5d2". |
| 150 | It also can be "microchip,sam9x60-sfr", "syscon". | ||
| 150 | - reg: Should contain registers location and length | 151 | - reg: Should contain registers location and length |
| 151 | 152 | ||
| 152 | sfr@f0038000 { | 153 | sfr@f0038000 { |
| @@ -31,28 +31,7 @@ Required subnodes: · 30 unmodified lines | |||
| 31 | - one subnode per DSI device connected on the DSI bus. Each DSI device should | 31 | - one subnode per DSI device connected on the DSI bus. Each DSI device should |
| 32 | contain a reg property encoding its virtual channel. | 32 | contain a reg property encoding its virtual channel. |
| 33 | 33 | ||
| 34 | Cadence DPHY | ||
| 35 | ============ | ||
| 36 | |||
| 37 | Cadence DPHY block. | ||
| 38 | |||
| 39 | Required properties: | ||
| 40 | - compatible: should be set to "cdns,dphy". | ||
| 41 | - reg: physical base address and length of the DPHY registers. | ||
| 42 | - clocks: DPHY reference clocks. | ||
| 43 | - clock-names: must contain "psm" and "pll_ref". | ||
| 44 | - #phy-cells: must be set to 0. | ||
| 45 | |||
| 46 | |||
| 47 | Example: | 34 | Example: |
| 48 | dphy0: dphy@fd0e0000{ | ||
| 49 | compatible = "cdns,dphy"; | ||
| 50 | reg = <0x0 0xfd0e0000 0x0 0x1000>; | ||
| 51 | clocks = <&psm_clk>, <&pll_ref_clk>; | ||
| 52 | clock-names = "psm", "pll_ref"; | ||
| 53 | #phy-cells = <0>; | ||
| 54 | }; | ||
| 55 | |||
| 56 | dsi0: dsi@fd0c0000 { | 35 | dsi0: dsi@fd0c0000 { |
| 57 | compatible = "cdns,dsi"; | 36 | compatible = "cdns,dsi"; |
| 58 | reg = <0x0 0xfd0c0000 0x0 0x1000>; | 37 | reg = <0x0 0xfd0c0000 0x0 0x1000>; |
| @@ -0,0 +1,20 @@ | |||
| 1 | Cadence DPHY | ||
| 2 | ============ | ||
| 3 | |||
| 4 | Cadence DPHY block. | ||
| 5 | |||
| 6 | Required properties: | ||
| 7 | - compatible: should be set to "cdns,dphy". | ||
| 8 | - reg: physical base address and length of the DPHY registers. | ||
| 9 | - clocks: DPHY reference clocks. | ||
| 10 | - clock-names: must contain "psm" and "pll_ref". | ||
| 11 | - #phy-cells: must be set to 0. | ||
| 12 | |||
| 13 | Example: | ||
| 14 | dphy0: dphy@fd0e0000{ | ||
| 15 | compatible = "cdns,dphy"; | ||
| 16 | reg = <0x0 0xfd0e0000 0x0 0x1000>; | ||
| 17 | clocks = <&psm_clk>, <&pll_ref_clk>; | ||
| 18 | clock-names = "psm", "pll_ref"; | ||
| 19 | #phy-cells = <0>; | ||
| 20 | }; | ||
| @@ -1,16 +1,27 @@ | |||
| 1 | mvebu comphy driver | 1 | MVEBU comphy drivers |
| 2 | ------------------- | 2 | -------------------- |
| 3 | 3 | ||
| 4 | A comphy controller can be found on Marvell Armada 7k/8k on the CP110. It | 4 | COMPHY controllers can be found on the following Marvell MVEBU SoCs: |
| 5 | provides a number of shared PHYs used by various interfaces (network, sata, | 5 | * Armada 7k/8k (on the CP110) |
| 6 | usb, PCIe...). | 6 | * Armada 3700 |
| 7 | It provides a number of shared PHYs used by various interfaces (network, SATA, | ||
| 8 | USB, PCIe...). | ||
| 7 | 9 | ||
| 8 | Required properties: | 10 | Required properties: |
| 9 | 11 | ||
| 10 | - compatible: should be "marvell,comphy-cp110" | 12 | - compatible: should be one of: |
| 11 | - reg: should contain the comphy register location and length. | 13 | * "marvell,comphy-cp110" for Armada 7k/8k |
| 12 | - marvell,system-controller: should contain a phandle to the | 14 | * "marvell,comphy-a3700" for Armada 3700 |
| 13 | system controller node. | 15 | - reg: should contain the COMPHY register(s) location(s) and length(s). |
| 16 | * 1 entry for Armada 7k/8k | ||
| 17 | * 4 entries for Armada 3700 along with the corresponding reg-names | ||
| 18 | properties, memory areas are: | ||
| 19 | * Generic COMPHY registers | ||
| 20 | * Lane 1 (PCIe/GbE) | ||
| 21 | * Lane 0 (USB3/GbE) | ||
| 22 | * Lane 2 (SATA/USB3) | ||
| 23 | - marvell,system-controller: should contain a phandle to the system | ||
| 24 | controller node (only for Armada 7k/8k) | ||
| 14 | - #address-cells: should be 1. | 25 | - #address-cells: should be 1. |
| 15 | - #size-cells: should be 0. | 26 | - #size-cells: should be 0. |
| 16 | 27 | ||
| @@ -18,11 +29,11 @@ A sub-node is required for each comphy lane provided by the comphy. · 1 unmodified line | |||
| 18 | 29 | ||
| 19 | Required properties (child nodes): | 30 | Required properties (child nodes): |
| 20 | 31 | ||
| 21 | - reg: comphy lane number. | 32 | - reg: COMPHY lane number. |
| 22 | - #phy-cells : from the generic phy bindings, must be 1. Defines the | 33 | - #phy-cells : from the generic PHY bindings, must be 1. Defines the |
| 23 | input port to use for a given comphy lane. | 34 | input port to use for a given comphy lane. |
| 24 | 35 | ||
| 25 | Example: | 36 | Examples: |
| 26 | 37 | ||
| 27 | cpm_comphy: phy@120000 { | 38 | cpm_comphy: phy@120000 { |
| 28 | compatible = "marvell,comphy-cp110"; | 39 | compatible = "marvell,comphy-cp110"; |
| @@ -41,3 +52,33 @@ Example: · 12 unmodified lines | |||
| 41 | #phy-cells = <1>; | 52 | #phy-cells = <1>; |
| 42 | }; | 53 | }; |
| 43 | }; | 54 | }; |
| 55 | |||
| 56 | comphy: phy@18300 { | ||
| 57 | compatible = "marvell,comphy-a3700"; | ||
| 58 | reg = <0x18300 0x300>, | ||
| 59 | <0x1F000 0x400>, | ||
| 60 | <0x5C000 0x400>, | ||
| 61 | <0xe0178 0x8>; | ||
| 62 | reg-names = "comphy", | ||
| 63 | "lane1_pcie_gbe", | ||
| 64 | "lane0_usb3_gbe", | ||
| 65 | "lane2_sata_usb3"; | ||
| 66 | #address-cells = <1>; | ||
| 67 | #size-cells = <0>; | ||
| 68 | |||
| 69 | |||
| 70 | comphy0: phy@0 { | ||
| 71 | reg = <0>; | ||
| 72 | #phy-cells = <1>; | ||
| 73 | }; | ||
| 74 | |||
| 75 | comphy1: phy@1 { | ||
| 76 | reg = <1>; | ||
| 77 | #phy-cells = <1>; | ||
| 78 | }; | ||
| 79 | |||
| 80 | comphy2: phy@2 { | ||
| 81 | reg = <2>; | ||
| 82 | #phy-cells = <1>; | ||
| 83 | }; | ||
| 84 | }; | ||
| @@ -0,0 +1,38 @@ | |||
| 1 | MVEBU A3700 UTMI PHY | ||
| 2 | -------------------- | ||
| 3 | |||
| 4 | USB2 UTMI+ PHY controllers can be found on the following Marvell MVEBU SoCs: | ||
| 5 | * Armada 3700 | ||
| 6 | |||
| 7 | On Armada 3700, there are two USB controllers, one is compatible with the USB2 | ||
| 8 | and USB3 specifications and supports OTG. The other one is USB2 compliant and | ||
| 9 | only supports host mode. Both of these controllers come with a slightly | ||
| 10 | different UTMI PHY. | ||
| 11 | |||
| 12 | Required Properties: | ||
| 13 | |||
| 14 | - compatible: Should be one of: | ||
| 15 | * "marvell,a3700-utmi-host-phy" for the PHY connected to | ||
| 16 | the USB2 host-only controller. | ||
| 17 | * "marvell,a3700-utmi-otg-phy" for the PHY connected to | ||
| 18 | the USB3 and USB2 OTG capable controller. | ||
| 19 | - reg: PHY IP register range. | ||
| 20 | - marvell,usb-misc-reg: handle on the "USB miscellaneous registers" shared | ||
| 21 | region covering registers related to both the host | ||
| 22 | controller and the PHY. | ||
| 23 | - #phy-cells: Standard property (Documentation: phy-bindings.txt) Should be 0. | ||
| 24 | |||
| 25 | |||
| 26 | Example: | ||
| 27 | |||
| 28 | usb2_utmi_host_phy: phy@5f000 { | ||
| 29 | compatible = "marvell,armada-3700-utmi-host-phy"; | ||
| 30 | reg = <0x5f000 0x800>; | ||
| 31 | marvell,usb-misc-reg = <&usb2_syscon>; | ||
| 32 | #phy-cells = <0>; | ||
| 33 | }; | ||
| 34 | |||
| 35 | usb2_syscon: system-controller@5f800 { | ||
| 36 | compatible = "marvell,armada-3700-usb2-host-misc", "syscon"; | ||
| 37 | reg = <0x5f800 0x800>; | ||
| 38 | }; | ||
| @@ -23,6 +23,8 @@ Optional properties: · 22 unmodified lines | |||
| 23 | register files". When set driver will request its | 23 | register files". When set driver will request its |
| 24 | phandle as one companion-grf for some special SoCs | 24 | phandle as one companion-grf for some special SoCs |
| 25 | (e.g RV1108). | 25 | (e.g RV1108). |
| 26 | - extcon : phandle to the extcon device providing the cable state for | ||
| 27 | the otg phy. | ||
| 26 | 28 | ||
| 27 | Required nodes : a sub-node is required for each port the phy provides. | 29 | Required nodes : a sub-node is required for each port the phy provides. |
| 28 | The sub-node name is used to identify host or otg port, | 30 | The sub-node name is used to identify host or otg port, |
| @@ -9,6 +9,8 @@ Required properties: · 8 unmodified lines | |||
| 9 | "qcom,ipq8074-qmp-pcie-phy" for PCIe phy on IPQ8074 | 9 | "qcom,ipq8074-qmp-pcie-phy" for PCIe phy on IPQ8074 |
| 10 | "qcom,msm8996-qmp-pcie-phy" for 14nm PCIe phy on msm8996, | 10 | "qcom,msm8996-qmp-pcie-phy" for 14nm PCIe phy on msm8996, |
| 11 | "qcom,msm8996-qmp-usb3-phy" for 14nm USB3 phy on msm8996, | 11 | "qcom,msm8996-qmp-usb3-phy" for 14nm USB3 phy on msm8996, |
| 12 | "qcom,msm8998-qmp-usb3-phy" for USB3 QMP V3 phy on msm8998, | ||
| 13 | "qcom,msm8998-qmp-ufs-phy" for UFS QMP phy on msm8998, | ||
| 12 | "qcom,sdm845-qmp-usb3-phy" for USB3 QMP V3 phy on sdm845, | 14 | "qcom,sdm845-qmp-usb3-phy" for USB3 QMP V3 phy on sdm845, |
| 13 | "qcom,sdm845-qmp-usb3-uni-phy" for USB3 QMP V3 UNI phy on sdm845, | 15 | "qcom,sdm845-qmp-usb3-uni-phy" for USB3 QMP V3 UNI phy on sdm845, |
| 14 | "qcom,sdm845-qmp-ufs-phy" for UFS QMP phy on sdm845. | 16 | "qcom,sdm845-qmp-ufs-phy" for UFS QMP phy on sdm845. |
| @@ -42,6 +44,10 @@ Required properties: · 27 unmodified lines | |||
| 42 | "aux", "cfg_ahb", "ref". | 44 | "aux", "cfg_ahb", "ref". |
| 43 | For "qcom,msm8996-qmp-usb3-phy" must contain: | 45 | For "qcom,msm8996-qmp-usb3-phy" must contain: |
| 44 | "aux", "cfg_ahb", "ref". | 46 | "aux", "cfg_ahb", "ref". |
| 47 | For "qcom,msm8998-qmp-usb3-phy" must contain: | ||
| 48 | "aux", "cfg_ahb", "ref". | ||
| 49 | For "qcom,msm8998-qmp-ufs-phy" must contain: | ||
| 50 | "ref", "ref_aux". | ||
| 45 | For "qcom,sdm845-qmp-usb3-phy" must contain: | 51 | For "qcom,sdm845-qmp-usb3-phy" must contain: |
| 46 | "aux", "cfg_ahb", "ref", "com_aux". | 52 | "aux", "cfg_ahb", "ref", "com_aux". |
| 47 | For "qcom,sdm845-qmp-usb3-uni-phy" must contain: | 53 | For "qcom,sdm845-qmp-usb3-uni-phy" must contain: |
| @@ -61,6 +67,9 @@ Required properties: · 13 unmodified lines | |||
| 61 | "phy", "common", "cfg". | 67 | "phy", "common", "cfg". |
| 62 | For "qcom,msm8996-qmp-usb3-phy" must contain | 68 | For "qcom,msm8996-qmp-usb3-phy" must contain |
| 63 | "phy", "common". | 69 | "phy", "common". |
| 70 | For "qcom,msm8998-qmp-usb3-phy" must contain | ||
| 71 | "phy", "common". | ||
| 72 | For "qcom,msm8998-qmp-ufs-phy": no resets are listed. | ||
| 64 | For "qcom,sdm845-qmp-usb3-phy" must contain: | 73 | For "qcom,sdm845-qmp-usb3-phy" must contain: |
| 65 | "phy", "common". | 74 | "phy", "common". |
| 66 | For "qcom,sdm845-qmp-usb3-uni-phy" must contain: | 75 | For "qcom,sdm845-qmp-usb3-uni-phy" must contain: |
| @@ -6,6 +6,7 @@ QUSB2 controller supports LS/FS/HS usb connectivity on Qualcomm chipsets. · 5 unmodified lines | |||
| 6 | Required properties: | 6 | Required properties: |
| 7 | - compatible: compatible list, contains | 7 | - compatible: compatible list, contains |
| 8 | "qcom,msm8996-qusb2-phy" for 14nm PHY on msm8996, | 8 | "qcom,msm8996-qusb2-phy" for 14nm PHY on msm8996, |
| 9 | "qcom,msm8998-qusb2-phy" for 10nm PHY on msm8998, | ||
| 9 | "qcom,sdm845-qusb2-phy" for 10nm PHY on sdm845. | 10 | "qcom,sdm845-qusb2-phy" for 10nm PHY on sdm845. |
| 10 | 11 | ||
| 11 | - reg: offset and length of the PHY register set. | 12 | - reg: offset and length of the PHY register set. |
| @@ -5,6 +5,8 @@ This file provides information on what the device node for the R-Car generation · 4 unmodified lines | |||
| 5 | 5 | ||
| 6 | Required properties: | 6 | Required properties: |
| 7 | - compatible: "renesas,usb2-phy-r8a774a1" if the device is a part of an R8A774A1 | 7 | - compatible: "renesas,usb2-phy-r8a774a1" if the device is a part of an R8A774A1 |
| 8 | SoC. | ||
| 9 | "renesas,usb2-phy-r8a774c0" if the device is a part of an R8A774C0 | ||
| 8 | SoC. | 10 | SoC. |
| 9 | "renesas,usb2-phy-r8a7795" if the device is a part of an R8A7795 | 11 | "renesas,usb2-phy-r8a7795" if the device is a part of an R8A7795 |
| 10 | SoC. | 12 | SoC. |
| @@ -35,6 +35,7 @@ Required properties: · 34 unmodified lines | |||
| 35 | DRA7x | 35 | DRA7x |
| 36 | Should be "ti,dra7x-usb2-phy2" for the 2nd instance of USB2 PHY | 36 | Should be "ti,dra7x-usb2-phy2" for the 2nd instance of USB2 PHY |
| 37 | in DRA7x | 37 | in DRA7x |
| 38 | Should be "ti,am654-usb2" for the USB2 PHYs on AM654. | ||
| 38 | - reg : Address and length of the register set for the device. | 39 | - reg : Address and length of the register set for the device. |
| 39 | - #phy-cells: determine the number of cells that should be given in the | 40 | - #phy-cells: determine the number of cells that should be given in the |
| 40 | phandle while referencing this phy. | 41 | phandle while referencing this phy. |
| @@ -93,6 +93,7 @@ i.mx specific properties · 92 unmodified lines | |||
| 93 | - over-current-active-low: over current signal polarity is active low. | 93 | - over-current-active-low: over current signal polarity is active low. |
| 94 | - over-current-active-high: over current signal polarity is active high. | 94 | - over-current-active-high: over current signal polarity is active high. |
| 95 | It's recommended to specify the over current polarity. | 95 | It's recommended to specify the over current polarity. |
| 96 | - power-active-high: power signal polarity is active high | ||
| 96 | - external-vbus-divider: enables off-chip resistor divider for Vbus | 97 | - external-vbus-divider: enables off-chip resistor divider for Vbus |
| 97 | 98 | ||
| 98 | Example: | 99 | Example: |
| @@ -0,0 +1,24 @@ | |||
| 1 | Ingenic JZ4740 MUSB driver | ||
| 2 | |||
| 3 | Required properties: | ||
| 4 | |||
| 5 | - compatible: Must be "ingenic,jz4740-musb" | ||
| 6 | - reg: Address range of the UDC register set | ||
| 7 | - interrupts: IRQ number related to the UDC hardware | ||
| 8 | - interrupt-names: must be "mc" | ||
| 9 | - clocks: phandle to the "udc" clock | ||
| 10 | - clock-names: must be "udc" | ||
| 11 | |||
| 12 | Example: | ||
| 13 | |||
| 14 | udc: usb@13040000 { | ||
| 15 | compatible = "ingenic,jz4740-musb"; | ||
| 16 | reg = <0x13040000 0x10000>; | ||
| 17 | |||
| 18 | interrupt-parent = <&intc>; | ||
| 19 | interrupts = <24>; | ||
| 20 | interrupt-names = "mc"; | ||
| 21 | |||
| 22 | clocks = <&cgu JZ4740_CLK_UDC>; | ||
| 23 | clock-names = "udc"; | ||
| 24 | }; | ||
| @@ -3,7 +3,9 @@ TI Keystone Soc USB Controller · 2 unmodified lines | |||
| 3 | DWC3 GLUE | 3 | DWC3 GLUE |
| 4 | 4 | ||
| 5 | Required properties: | 5 | Required properties: |
| 6 | - compatible: should be "ti,keystone-dwc3". | 6 | - compatible: should be |
| 7 | "ti,keystone-dwc3" for Keystone 2 SoCs | ||
| 8 | "ti,am654-dwc3" for AM654 SoC | ||
| 7 | - #address-cells, #size-cells : should be '1' if the device has sub-nodes | 9 | - #address-cells, #size-cells : should be '1' if the device has sub-nodes |
| 8 | with 'reg' property. | 10 | with 'reg' property. |
| 9 | - reg : Address and length of the register set for the USB subsystem on | 11 | - reg : Address and length of the register set for the USB subsystem on |
| @@ -21,7 +23,7 @@ SoCs only: · 11 unmodified lines | |||
| 21 | - clock-names: Must be "usb". | 23 | - clock-names: Must be "usb". |
| 22 | 24 | ||
| 23 | 25 | ||
| 24 | The following are mandatory properties for Keystone 2 66AK2G SoCs only: | 26 | The following are mandatory properties for 66AK2G and AM654: |
| 25 | 27 | ||
| 26 | - power-domains: Should contain a phandle to a PM domain provider node | 28 | - power-domains: Should contain a phandle to a PM domain provider node |
| 27 | and an args specifier containing the USB device id | 29 | and an args specifier containing the USB device id |
| @@ -4,6 +4,7 @@ Required properties: · 3 unmodified lines | |||
| 4 | - compatible: Compatible list, contains | 4 | - compatible: Compatible list, contains |
| 5 | "qcom,dwc3" | 5 | "qcom,dwc3" |
| 6 | "qcom,msm8996-dwc3" for msm8996 SOC. | 6 | "qcom,msm8996-dwc3" for msm8996 SOC. |
| 7 | "qcom,msm8998-dwc3" for msm8998 SOC. | ||
| 7 | "qcom,sdm845-dwc3" for sdm845 SOC. | 8 | "qcom,sdm845-dwc3" for sdm845 SOC. |
| 8 | - reg: Offset and length of register set for QSCRATCH wrapper | 9 | - reg: Offset and length of register set for QSCRATCH wrapper |
| 9 | - power-domains: specifies a phandle to PM domain provider node | 10 | - power-domains: specifies a phandle to PM domain provider node |
| @@ -3,6 +3,7 @@ Renesas Electronics USB3.0 Peripheral driver · 2 unmodified lines | |||
| 3 | Required properties: | 3 | Required properties: |
| 4 | - compatible: Must contain one of the following: | 4 | - compatible: Must contain one of the following: |
| 5 | - "renesas,r8a774a1-usb3-peri" | 5 | - "renesas,r8a774a1-usb3-peri" |
| 6 | - "renesas,r8a774c0-usb3-peri" | ||
| 6 | - "renesas,r8a7795-usb3-peri" | 7 | - "renesas,r8a7795-usb3-peri" |
| 7 | - "renesas,r8a7796-usb3-peri" | 8 | - "renesas,r8a7796-usb3-peri" |
| 8 | - "renesas,r8a77965-usb3-peri" | 9 | - "renesas,r8a77965-usb3-peri" |
| @@ -7,6 +7,7 @@ Required properties: · 6 unmodified lines | |||
| 7 | - "renesas,usbhs-r8a7744" for r8a7744 (RZ/G1N) compatible device | 7 | - "renesas,usbhs-r8a7744" for r8a7744 (RZ/G1N) compatible device |
| 8 | - "renesas,usbhs-r8a7745" for r8a7745 (RZ/G1E) compatible device | 8 | - "renesas,usbhs-r8a7745" for r8a7745 (RZ/G1E) compatible device |
| 9 | - "renesas,usbhs-r8a774a1" for r8a774a1 (RZ/G2M) compatible device | 9 | - "renesas,usbhs-r8a774a1" for r8a774a1 (RZ/G2M) compatible device |
| 10 | - "renesas,usbhs-r8a774c0" for r8a774c0 (RZ/G2E) compatible device | ||
| 10 | - "renesas,usbhs-r8a7790" for r8a7790 (R-Car H2) compatible device | 11 | - "renesas,usbhs-r8a7790" for r8a7790 (R-Car H2) compatible device |
| 11 | - "renesas,usbhs-r8a7791" for r8a7791 (R-Car M2-W) compatible device | 12 | - "renesas,usbhs-r8a7791" for r8a7791 (R-Car M2-W) compatible device |
| 12 | - "renesas,usbhs-r8a7792" for r8a7792 (R-Car V2H) compatible device | 13 | - "renesas,usbhs-r8a7792" for r8a7792 (R-Car V2H) compatible device |
| @@ -64,6 +64,8 @@ Optional properties : · 63 unmodified lines | |||
| 64 | - power-on-time-ms : Specifies the time it takes from the time the host | 64 | - power-on-time-ms : Specifies the time it takes from the time the host |
| 65 | initiates the power-on sequence to a port until the port has adequate | 65 | initiates the power-on sequence to a port until the port has adequate |
| 66 | power. The value is given in ms in a 0 - 510 range (default is 100ms). | 66 | power. The value is given in ms in a 0 - 510 range (default is 100ms). |
| 67 | - swap-dx-lanes : Specifies the ports which will swap the differential-pair | ||
| 68 | (D+/D-), default is not-swapped. | ||
| 67 | 69 | ||
| 68 | Examples: | 70 | Examples: |
| 69 | usb2512b@2c { | 71 | usb2512b@2c { |
| @@ -81,4 +83,6 @@ Examples: · 11 unmodified lines | |||
| 81 | manufacturer = "Foo"; | 83 | manufacturer = "Foo"; |
| 82 | product = "Foo-Bar"; | 84 | product = "Foo-Bar"; |
| 83 | serial = "1234567890A"; | 85 | serial = "1234567890A"; |
| 86 | /* correct misplaced usb connectors on port 1,2 */ | ||
| 87 | swap-dx-lanes = <1 2>; | ||
| 84 | }; | 88 | }; |
| @@ -34,7 +34,9 @@ $ echo 1 > /sys/bus/usb/devices/usbX/authorized_default · 33 unmodified lines | |||
| 34 | By default, Wired USB devices are authorized by default to | 34 | By default, Wired USB devices are authorized by default to |
| 35 | connect. Wireless USB hosts deauthorize by default all new connected | 35 | connect. Wireless USB hosts deauthorize by default all new connected |
| 36 | devices (this is so because we need to do an authentication phase | 36 | devices (this is so because we need to do an authentication phase |
| 37 | before authorizing). | 37 | before authorizing). Writing "2" to the authorized_default attribute |
| 38 | causes kernel to only authorize by default devices connected to internal | ||
| 39 | USB ports. | ||
| 38 | 40 | ||
| 39 | 41 | ||
| 40 | Example system lockdown (lame) | 42 | Example system lockdown (lame) |
| @@ -9178,6 +9178,14 @@ F: drivers/gpu/drm/armada/ · 9177 unmodified lines | |||
| 9178 | F: include/uapi/drm/armada_drm.h | 9178 | F: include/uapi/drm/armada_drm.h |
| 9179 | F: Documentation/devicetree/bindings/display/armada/ | 9179 | F: Documentation/devicetree/bindings/display/armada/ |
| 9180 | 9180 | ||
| 9181 | MARVELL ARMADA 3700 PHY DRIVERS | ||
| 9182 | M: Miquel Raynal <miquel.raynal@bootlin.com> | ||
| 9183 | S: Maintained | ||
| 9184 | F: drivers/phy/marvell/phy-mvebu-a3700-comphy.c | ||
| 9185 | F: drivers/phy/marvell/phy-mvebu-a3700-utmi.c | ||
| 9186 | F: Documentation/devicetree/bindings/phy/phy-mvebu-comphy.txt | ||
| 9187 | F: Documentation/devicetree/bindings/phy/phy-mvebu-utmi.txt | ||
| 9188 | |||
| 9181 | MARVELL CRYPTO DRIVER | 9189 | MARVELL CRYPTO DRIVER |
| 9182 | M: Boris Brezillon <bbrezillon@kernel.org> | 9190 | M: Boris Brezillon <bbrezillon@kernel.org> |
| 9183 | M: Arnaud Ebalard <arno@natisbad.org> | 9191 | M: Arnaud Ebalard <arno@natisbad.org> |
| @@ -7,10 +7,37 @@ · 6 unmodified lines | |||
| 7 | */ | 7 | */ |
| 8 | 8 | ||
| 9 | #include <linux/device.h> | 9 | #include <linux/device.h> |
| 10 | #include <linux/property.h> | ||
| 10 | 11 | ||
| 11 | static DEFINE_MUTEX(devcon_lock); | 12 | static DEFINE_MUTEX(devcon_lock); |
| 12 | static LIST_HEAD(devcon_list); | 13 | static LIST_HEAD(devcon_list); |
| 13 | 14 | ||
| 15 | typedef void *(*devcon_match_fn_t)(struct device_connection *con, int ep, | ||
| 16 | void *data); | ||
| 17 | |||
| 18 | static void * | ||
| 19 | fwnode_graph_devcon_match(struct fwnode_handle *fwnode, const char *con_id, | ||
| 20 | void *data, devcon_match_fn_t match) | ||
| 21 | { | ||
| 22 | struct device_connection con = { .id = con_id }; | ||
| 23 | struct fwnode_handle *ep; | ||
| 24 | void *ret; | ||
| 25 | |||
| 26 | fwnode_graph_for_each_endpoint(fwnode, ep) { | ||
| 27 | con.fwnode = fwnode_graph_get_remote_port_parent(ep); | ||
| 28 | if (!fwnode_device_is_available(con.fwnode)) | ||
| 29 | continue; | ||
| 30 | |||
| 31 | ret = match(&con, -1, data); | ||
| 32 | fwnode_handle_put(con.fwnode); | ||
| 33 | if (ret) { | ||
| 34 | fwnode_handle_put(ep); | ||
| 35 | return ret; | ||
| 36 | } | ||
| 37 | } | ||
| 38 | return NULL; | ||
| 39 | } | ||
| 40 | |||
| 14 | /** | 41 | /** |
| 15 | * device_connection_find_match - Find physical connection to a device | 42 | * device_connection_find_match - Find physical connection to a device |
| 16 | * @dev: Device with the connection | 43 | * @dev: Device with the connection |
| @@ -23,10 +50,9 @@ static LIST_HEAD(devcon_list); · 6 unmodified lines | |||
| 23 | * caller is expecting to be returned. | 50 | * caller is expecting to be returned. |
| 24 | */ | 51 | */ |
| 25 | void *device_connection_find_match(struct device *dev, const char *con_id, | 52 | void *device_connection_find_match(struct device *dev, const char *con_id, |
| 26 | void *data, | 53 | void *data, devcon_match_fn_t match) |
| 27 | void *(*match)(struct device_connection *con, | ||
| 28 | int ep, void *data)) | ||
| 29 | { | 54 | { |
| 55 | struct fwnode_handle *fwnode = dev_fwnode(dev); | ||
| 30 | const char *devname = dev_name(dev); | 56 | const char *devname = dev_name(dev); |
| 31 | struct device_connection *con; | 57 | struct device_connection *con; |
| 32 | void *ret = NULL; | 58 | void *ret = NULL; |
| @@ -35,6 +61,12 @@ void *device_connection_find_match(struct device *dev, const char *con_id, · 2 unmodified lines | |||
| 35 | if (!match) | 61 | if (!match) |
| 36 | return NULL; | 62 | return NULL; |
| 37 | 63 | ||
| 64 | if (fwnode) { | ||
| 65 | ret = fwnode_graph_devcon_match(fwnode, con_id, data, match); | ||
| 66 | if (ret) | ||
| 67 | return ret; | ||
| 68 | } | ||
| 69 | |||
| 38 | mutex_lock(&devcon_lock); | 70 | mutex_lock(&devcon_lock); |
| 39 | 71 | ||
| 40 | list_for_each_entry(con, &devcon_list, list) { | 72 | list_for_each_entry(con, &devcon_list, list) { |
| @@ -75,12 +107,36 @@ static struct bus_type *generic_match_buses[] = { · 34 unmodified lines | |||
| 75 | NULL, | 107 | NULL, |
| 76 | }; | 108 | }; |
| 77 | 109 | ||
| 110 | static int device_fwnode_match(struct device *dev, void *fwnode) | ||
| 111 | { | ||
| 112 | return dev_fwnode(dev) == fwnode; | ||
| 113 | } | ||
| 114 | |||
| 115 | static void *device_connection_fwnode_match(struct device_connection *con) | ||
| 116 | { | ||
| 117 | struct bus_type *bus; | ||
| 118 | struct device *dev; | ||
| 119 | |||
| 120 | for (bus = generic_match_buses[0]; bus; bus++) { | ||
| 121 | dev = bus_find_device(bus, NULL, (void *)con->fwnode, | ||
| 122 | device_fwnode_match); | ||
| 123 | if (dev && !strncmp(dev_name(dev), con->id, strlen(con->id))) | ||
| 124 | return dev; | ||
| 125 | |||
| 126 | put_device(dev); | ||
| 127 | } | ||
| 128 | return NULL; | ||
| 129 | } | ||
| 130 | |||
| 78 | /* This tries to find the device from the most common bus types by name. */ | 131 | /* This tries to find the device from the most common bus types by name. */ |
| 79 | static void *generic_match(struct device_connection *con, int ep, void *data) | 132 | static void *generic_match(struct device_connection *con, int ep, void *data) |
| 80 | { | 133 | { |
| 81 | struct bus_type *bus; | 134 | struct bus_type *bus; |
| 82 | struct device *dev; | 135 | struct device *dev; |
| 83 | 136 | ||
| 137 | if (con->fwnode) | ||
| 138 | return device_connection_fwnode_match(con); | ||
| 139 | |||
| 84 | for (bus = generic_match_buses[0]; bus; bus++) { | 140 | for (bus = generic_match_buses[0]; bus; bus++) { |
| 85 | dev = bus_find_device_by_name(bus, NULL, con->endpoint[ep]); | 141 | dev = bus_find_device_by_name(bus, NULL, con->endpoint[ep]); |
| 86 | if (dev) | 142 | if (dev) |
| @@ -78,8 +78,8 @@ struct sr_pcie_phy_core { · 77 unmodified lines | |||
| 78 | static const u8 pipemux_table[] = { | 78 | static const u8 pipemux_table[] = { |
| 79 | /* PIPEMUX = 0, EP 1x16 */ | 79 | /* PIPEMUX = 0, EP 1x16 */ |
| 80 | 0x00, | 80 | 0x00, |
| 81 | /* PIPEMUX = 1, EP 2x8 */ | 81 | /* PIPEMUX = 1, EP 1x8 + RC 1x8, core 7 */ |
| 82 | 0x00, | 82 | 0x80, |
| 83 | /* PIPEMUX = 2, EP 4x4 */ | 83 | /* PIPEMUX = 2, EP 4x4 */ |
| 84 | 0x00, | 84 | 0x00, |
| 85 | /* PIPEMUX = 3, RC 2x8, cores 0, 7 */ | 85 | /* PIPEMUX = 3, RC 2x8, cores 0, 7 */ |
| @@ -1,6 +1,7 @@ | |||
| 1 | # | 1 | # |
| 2 | # Phy drivers for Cadence PHYs | 2 | # Phy drivers for Cadence PHYs |
| 3 | # | 3 | # |
| 4 | |||
| 4 | config PHY_CADENCE_DP | 5 | config PHY_CADENCE_DP |
| 5 | tristate "Cadence MHDP DisplayPort PHY driver" | 6 | tristate "Cadence MHDP DisplayPort PHY driver" |
| 6 | depends on OF | 7 | depends on OF |
| @@ -9,9 +10,19 @@ config PHY_CADENCE_DP · 2 unmodified lines | |||
| 9 | help | 10 | help |
| 10 | Support for Cadence MHDP DisplayPort PHY. | 11 | Support for Cadence MHDP DisplayPort PHY. |
| 11 | 12 | ||
| 13 | config PHY_CADENCE_DPHY | ||
| 14 | tristate "Cadence D-PHY Support" | ||
| 15 | depends on HAS_IOMEM && OF | ||
| 16 | select GENERIC_PHY | ||
| 17 | select GENERIC_PHY_MIPI_DPHY | ||
| 18 | help | ||
| 19 | Choose this option if you have a Cadence D-PHY in your | ||
| 20 | system. If M is selected, the module will be called | ||
| 21 | cdns-dphy. | ||
| 22 | |||
| 12 | config PHY_CADENCE_SIERRA | 23 | config PHY_CADENCE_SIERRA |
| 13 | tristate "Cadence Sierra PHY Driver" | 24 | tristate "Cadence Sierra PHY Driver" |
| 14 | depends on OF && HAS_IOMEM && RESET_CONTROLLER | 25 | depends on OF && HAS_IOMEM && RESET_CONTROLLER |
| 15 | select GENERIC_PHY | 26 | select GENERIC_PHY |
| 16 | help | 27 | help |
| 17 | Enable this to support the Cadence Sierra PHY driver | 28 | Enable this to support the Cadence Sierra PHY driver |
| @@ -1,2 +1,3 @@ | |||
| 1 | obj-$(CONFIG_PHY_CADENCE_DP) += phy-cadence-dp.o | 1 | obj-$(CONFIG_PHY_CADENCE_DP) += phy-cadence-dp.o |
| 2 | obj-$(CONFIG_PHY_CADENCE_DPHY) += cdns-dphy.o | ||
| 2 | obj-$(CONFIG_PHY_CADENCE_SIERRA) += phy-cadence-sierra.o | 3 | obj-$(CONFIG_PHY_CADENCE_SIERRA) += phy-cadence-sierra.o |
| @@ -0,0 +1,391 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-2.0+ | ||
| 2 | /* | ||
| 3 | * Copyright: 2017-2018 Cadence Design Systems, Inc. | ||
| 4 | */ | ||
| 5 | |||
| 6 | #include <linux/bitops.h> | ||
| 7 | #include <linux/clk.h> | ||
| 8 | #include <linux/io.h> | ||
| 9 | #include <linux/module.h> | ||
| 10 | #include <linux/of_address.h> | ||
| 11 | #include <linux/of_device.h> | ||
| 12 | #include <linux/platform_device.h> | ||
| 13 | #include <linux/reset.h> | ||
| 14 | |||
| 15 | #include <linux/phy/phy.h> | ||
| 16 | #include <linux/phy/phy-mipi-dphy.h> | ||
| 17 | |||
| 18 | #define REG_WAKEUP_TIME_NS 800 | ||
| 19 | #define DPHY_PLL_RATE_HZ 108000000 | ||
| 20 | |||
| 21 | /* DPHY registers */ | ||
| 22 | #define DPHY_PMA_CMN(reg) (reg) | ||
| 23 | #define DPHY_PMA_LCLK(reg) (0x100 + (reg)) | ||
| 24 | #define DPHY_PMA_LDATA(lane, reg) (0x200 + ((lane) * 0x100) + (reg)) | ||
| 25 | #define DPHY_PMA_RCLK(reg) (0x600 + (reg)) | ||
| 26 | #define DPHY_PMA_RDATA(lane, reg) (0x700 + ((lane) * 0x100) + (reg)) | ||
| 27 | #define DPHY_PCS(reg) (0xb00 + (reg)) | ||
| 28 | |||
| 29 | #define DPHY_CMN_SSM DPHY_PMA_CMN(0x20) | ||
| 30 | #define DPHY_CMN_SSM_EN BIT(0) | ||
| 31 | #define DPHY_CMN_TX_MODE_EN BIT(9) | ||
| 32 | |||
| 33 | #define DPHY_CMN_PWM DPHY_PMA_CMN(0x40) | ||
| 34 | #define DPHY_CMN_PWM_DIV(x) ((x) << 20) | ||
| 35 | #define DPHY_CMN_PWM_LOW(x) ((x) << 10) | ||
| 36 | #define DPHY_CMN_PWM_HIGH(x) (x) | ||
| 37 | |||
| 38 | #define DPHY_CMN_FBDIV DPHY_PMA_CMN(0x4c) | ||
| 39 | #define DPHY_CMN_FBDIV_VAL(low, high) (((high) << 11) | ((low) << 22)) | ||
| 40 | #define DPHY_CMN_FBDIV_FROM_REG (BIT(10) | BIT(21)) | ||
| 41 | |||
| 42 | #define DPHY_CMN_OPIPDIV DPHY_PMA_CMN(0x50) | ||
| 43 | #define DPHY_CMN_IPDIV_FROM_REG BIT(0) | ||
| 44 | #define DPHY_CMN_IPDIV(x) ((x) << 1) | ||
| 45 | #define DPHY_CMN_OPDIV_FROM_REG BIT(6) | ||
| 46 | #define DPHY_CMN_OPDIV(x) ((x) << 7) | ||
| 47 | |||
| 48 | #define DPHY_PSM_CFG DPHY_PCS(0x4) | ||
| 49 | #define DPHY_PSM_CFG_FROM_REG BIT(0) | ||
| 50 | #define DPHY_PSM_CLK_DIV(x) ((x) << 1) | ||
| 51 | |||
| 52 | #define DSI_HBP_FRAME_OVERHEAD 12 | ||
| 53 | #define DSI_HSA_FRAME_OVERHEAD 14 | ||
| 54 | #define DSI_HFP_FRAME_OVERHEAD 6 | ||
| 55 | #define DSI_HSS_VSS_VSE_FRAME_OVERHEAD 4 | ||
| 56 | #define DSI_BLANKING_FRAME_OVERHEAD 6 | ||
| 57 | #define DSI_NULL_FRAME_OVERHEAD 6 | ||
| 58 | #define DSI_EOT_PKT_SIZE 4 | ||
| 59 | |||
| 60 | struct cdns_dphy_cfg { | ||
| 61 | u8 pll_ipdiv; | ||
| 62 | u8 pll_opdiv; | ||
| 63 | u16 pll_fbdiv; | ||
| 64 | unsigned int nlanes; | ||
| 65 | }; | ||
| 66 | |||
| 67 | enum cdns_dphy_clk_lane_cfg { | ||
| 68 | DPHY_CLK_CFG_LEFT_DRIVES_ALL = 0, | ||
| 69 | DPHY_CLK_CFG_LEFT_DRIVES_RIGHT = 1, | ||
| 70 | DPHY_CLK_CFG_LEFT_DRIVES_LEFT = 2, | ||
| 71 | DPHY_CLK_CFG_RIGHT_DRIVES_ALL = 3, | ||
| 72 | }; | ||
| 73 | |||
| 74 | struct cdns_dphy; | ||
| 75 | struct cdns_dphy_ops { | ||
| 76 | int (*probe)(struct cdns_dphy *dphy); | ||
| 77 | void (*remove)(struct cdns_dphy *dphy); | ||
| 78 | void (*set_psm_div)(struct cdns_dphy *dphy, u8 div); | ||
| 79 | void (*set_clk_lane_cfg)(struct cdns_dphy *dphy, | ||
| 80 | enum cdns_dphy_clk_lane_cfg cfg); | ||
| 81 | void (*set_pll_cfg)(struct cdns_dphy *dphy, | ||
| 82 | const struct cdns_dphy_cfg *cfg); | ||
| 83 | unsigned long (*get_wakeup_time_ns)(struct cdns_dphy *dphy); | ||
| 84 | }; | ||
| 85 | |||
| 86 | struct cdns_dphy { | ||
| 87 | struct cdns_dphy_cfg cfg; | ||
| 88 | void __iomem *regs; | ||
| 89 | struct clk *psm_clk; | ||
| 90 | struct clk *pll_ref_clk; | ||
| 91 | const struct cdns_dphy_ops *ops; | ||
| 92 | struct phy *phy; | ||
| 93 | }; | ||
| 94 | |||
| 95 | static int cdns_dsi_get_dphy_pll_cfg(struct cdns_dphy *dphy, | ||
| 96 | struct cdns_dphy_cfg *cfg, | ||
| 97 | struct phy_configure_opts_mipi_dphy *opts, | ||
| 98 | unsigned int *dsi_hfp_ext) | ||
| 99 | { | ||
| 100 | unsigned long pll_ref_hz = clk_get_rate(dphy->pll_ref_clk); | ||
| 101 | u64 dlane_bps; | ||
| 102 | |||
| 103 | memset(cfg, 0, sizeof(*cfg)); | ||
| 104 | |||
| 105 | if (pll_ref_hz < 9600000 || pll_ref_hz >= 150000000) | ||
| 106 | return -EINVAL; | ||
| 107 | else if (pll_ref_hz < 19200000) | ||
| 108 | cfg->pll_ipdiv = 1; | ||
| 109 | else if (pll_ref_hz < 38400000) | ||
| 110 | cfg->pll_ipdiv = 2; | ||
| 111 | else if (pll_ref_hz < 76800000) | ||
| 112 | cfg->pll_ipdiv = 4; | ||
| 113 | else | ||
| 114 | cfg->pll_ipdiv = 8; | ||
| 115 | |||
| 116 | dlane_bps = opts->hs_clk_rate; | ||
| 117 | |||
| 118 | if (dlane_bps > 2500000000UL || dlane_bps < 160000000UL) | ||
| 119 | return -EINVAL; | ||
| 120 | else if (dlane_bps >= 1250000000) | ||
| 121 | cfg->pll_opdiv = 1; | ||
| 122 | else if (dlane_bps >= 630000000) | ||
| 123 | cfg->pll_opdiv = 2; | ||
| 124 | else if (dlane_bps >= 320000000) | ||
| 125 | cfg->pll_opdiv = 4; | ||
| 126 | else if (dlane_bps >= 160000000) | ||
| 127 | cfg->pll_opdiv = 8; | ||
| 128 | |||
| 129 | cfg->pll_fbdiv = DIV_ROUND_UP_ULL(dlane_bps * 2 * cfg->pll_opdiv * | ||
| 130 | cfg->pll_ipdiv, | ||
| 131 | pll_ref_hz); | ||
| 132 | |||
| 133 | return 0; | ||
| 134 | } | ||
| 135 | |||
| 136 | static int cdns_dphy_setup_psm(struct cdns_dphy *dphy) | ||
| 137 | { | ||
| 138 | unsigned long psm_clk_hz = clk_get_rate(dphy->psm_clk); | ||
| 139 | unsigned long psm_div; | ||
| 140 | |||
| 141 | if (!psm_clk_hz || psm_clk_hz > 100000000) | ||
| 142 | return -EINVAL; | ||
| 143 | |||
| 144 | psm_div = DIV_ROUND_CLOSEST(psm_clk_hz, 1000000); | ||
| 145 | if (dphy->ops->set_psm_div) | ||
| 146 | dphy->ops->set_psm_div(dphy, psm_div); | ||
| 147 | |||
| 148 | return 0; | ||
| 149 | } | ||
| 150 | |||
| 151 | static void cdns_dphy_set_clk_lane_cfg(struct cdns_dphy *dphy, | ||
| 152 | enum cdns_dphy_clk_lane_cfg cfg) | ||
| 153 | { | ||
| 154 | if (dphy->ops->set_clk_lane_cfg) | ||
| 155 | dphy->ops->set_clk_lane_cfg(dphy, cfg); | ||
| 156 | } | ||
| 157 | |||
| 158 | static void cdns_dphy_set_pll_cfg(struct cdns_dphy *dphy, | ||
| 159 | const struct cdns_dphy_cfg *cfg) | ||
| 160 | { | ||
| 161 | if (dphy->ops->set_pll_cfg) | ||
| 162 | dphy->ops->set_pll_cfg(dphy, cfg); | ||
| 163 | } | ||
| 164 | |||
| 165 | static unsigned long cdns_dphy_get_wakeup_time_ns(struct cdns_dphy *dphy) | ||
| 166 | { | ||
| 167 | return dphy->ops->get_wakeup_time_ns(dphy); | ||
| 168 | } | ||
| 169 | |||
| 170 | static unsigned long cdns_dphy_ref_get_wakeup_time_ns(struct cdns_dphy *dphy) | ||
| 171 | { | ||
| 172 | /* Default wakeup time is 800 ns (in a simulated environment). */ | ||
| 173 | return 800; | ||
| 174 | } | ||
| 175 | |||
| 176 | static void cdns_dphy_ref_set_pll_cfg(struct cdns_dphy *dphy, | ||
| 177 | const struct cdns_dphy_cfg *cfg) | ||
| 178 | { | ||
| 179 | u32 fbdiv_low, fbdiv_high; | ||
| 180 | |||
| 181 | fbdiv_low = (cfg->pll_fbdiv / 4) - 2; | ||
| 182 | fbdiv_high = cfg->pll_fbdiv - fbdiv_low - 2; | ||
| 183 | |||
| 184 | writel(DPHY_CMN_IPDIV_FROM_REG | DPHY_CMN_OPDIV_FROM_REG | | ||
| 185 | DPHY_CMN_IPDIV(cfg->pll_ipdiv) | | ||
| 186 | DPHY_CMN_OPDIV(cfg->pll_opdiv), | ||
| 187 | dphy->regs + DPHY_CMN_OPIPDIV); | ||
| 188 | writel(DPHY_CMN_FBDIV_FROM_REG | | ||
| 189 | DPHY_CMN_FBDIV_VAL(fbdiv_low, fbdiv_high), | ||
| 190 | dphy->regs + DPHY_CMN_FBDIV); | ||
| 191 | writel(DPHY_CMN_PWM_HIGH(6) | DPHY_CMN_PWM_LOW(0x101) | | ||
| 192 | DPHY_CMN_PWM_DIV(0x8), | ||
| 193 | dphy->regs + DPHY_CMN_PWM); | ||
| 194 | } | ||
| 195 | |||
| 196 | static void cdns_dphy_ref_set_psm_div(struct cdns_dphy *dphy, u8 div) | ||
| 197 | { | ||
| 198 | writel(DPHY_PSM_CFG_FROM_REG | DPHY_PSM_CLK_DIV(div), | ||
| 199 | dphy->regs + DPHY_PSM_CFG); | ||
| 200 | } | ||
| 201 | |||
| 202 | /* | ||
| 203 | * This is the reference implementation of DPHY hooks. Specific integration of | ||
| 204 | * this IP may have to re-implement some of them depending on how they decided | ||
| 205 | * to wire things in the SoC. | ||
| 206 | */ | ||
| 207 | static const struct cdns_dphy_ops ref_dphy_ops = { | ||
| 208 | .get_wakeup_time_ns = cdns_dphy_ref_get_wakeup_time_ns, | ||
| 209 | .set_pll_cfg = cdns_dphy_ref_set_pll_cfg, | ||
| 210 | .set_psm_div = cdns_dphy_ref_set_psm_div, | ||
| 211 | }; | ||
| 212 | |||
| 213 | static int cdns_dphy_config_from_opts(struct phy *phy, | ||
| 214 | struct phy_configure_opts_mipi_dphy *opts, | ||
| 215 | struct cdns_dphy_cfg *cfg) | ||
| 216 | { | ||
| 217 | struct cdns_dphy *dphy = phy_get_drvdata(phy); | ||
| 218 | unsigned int dsi_hfp_ext = 0; | ||
| 219 | int ret; | ||
| 220 | |||
| 221 | ret = phy_mipi_dphy_config_validate(opts); | ||
| 222 | if (ret) | ||
| 223 | return ret; | ||
| 224 | |||
| 225 | ret = cdns_dsi_get_dphy_pll_cfg(dphy, cfg, | ||
| 226 | opts, &dsi_hfp_ext); | ||
| 227 | if (ret) | ||
| 228 | return ret; | ||
| 229 | |||
| 230 | opts->wakeup = cdns_dphy_get_wakeup_time_ns(dphy) / 1000; | ||
| 231 | |||
| 232 | return 0; | ||
| 233 | } | ||
| 234 | |||
| 235 | static int cdns_dphy_validate(struct phy *phy, enum phy_mode mode, int submode, | ||
| 236 | union phy_configure_opts *opts) | ||
| 237 | { | ||
| 238 | struct cdns_dphy_cfg cfg = { 0 }; | ||
| 239 | |||
| 240 | if (mode != PHY_MODE_MIPI_DPHY) | ||
| 241 | return -EINVAL; | ||
| 242 | |||
| 243 | return cdns_dphy_config_from_opts(phy, &opts->mipi_dphy, &cfg); | ||
| 244 | } | ||
| 245 | |||
| 246 | static int cdns_dphy_configure(struct phy *phy, union phy_configure_opts *opts) | ||
| 247 | { | ||
| 248 | struct cdns_dphy *dphy = phy_get_drvdata(phy); | ||
| 249 | struct cdns_dphy_cfg cfg = { 0 }; | ||
| 250 | int ret; | ||
| 251 | |||
| 252 | ret = cdns_dphy_config_from_opts(phy, &opts->mipi_dphy, &cfg); | ||
| 253 | if (ret) | ||
| 254 | return ret; | ||
| 255 | |||
| 256 | /* | ||
| 257 | * Configure the internal PSM clk divider so that the DPHY has a | ||
| 258 | * 1MHz clk (or something close). | ||
| 259 | */ | ||
| 260 | ret = cdns_dphy_setup_psm(dphy); | ||
| 261 | if (ret) | ||
| 262 | return ret; | ||
| 263 | |||
| 264 | /* | ||
| 265 | * Configure attach clk lanes to data lanes: the DPHY has 2 clk lanes | ||
| 266 | * and 8 data lanes, each clk lane can be attache different set of | ||
| 267 | * data lanes. The 2 groups are named 'left' and 'right', so here we | ||
| 268 | * just say that we want the 'left' clk lane to drive the 'left' data | ||
| 269 | * lanes. | ||
| 270 | */ | ||
| 271 | cdns_dphy_set_clk_lane_cfg(dphy, DPHY_CLK_CFG_LEFT_DRIVES_LEFT); | ||
| 272 | |||
| 273 | /* | ||
| 274 | * Configure the DPHY PLL that will be used to generate the TX byte | ||
| 275 | * clk. | ||
| 276 | */ | ||
| 277 | cdns_dphy_set_pll_cfg(dphy, &cfg); | ||
| 278 | |||
| 279 | return 0; | ||
| 280 | } | ||
| 281 | |||
| 282 | static int cdns_dphy_power_on(struct phy *phy) | ||
| 283 | { | ||
| 284 | struct cdns_dphy *dphy = phy_get_drvdata(phy); | ||
| 285 | |||
| 286 | clk_prepare_enable(dphy->psm_clk); | ||
| 287 | clk_prepare_enable(dphy->pll_ref_clk); | ||
| 288 | |||
| 289 | /* Start TX state machine. */ | ||
| 290 | writel(DPHY_CMN_SSM_EN | DPHY_CMN_TX_MODE_EN, | ||
| 291 | dphy->regs + DPHY_CMN_SSM); | ||
| 292 | |||
| 293 | return 0; | ||
| 294 | } | ||
| 295 | |||
| 296 | static int cdns_dphy_power_off(struct phy *phy) | ||
| 297 | { | ||
| 298 | struct cdns_dphy *dphy = phy_get_drvdata(phy); | ||
| 299 | |||
| 300 | clk_disable_unprepare(dphy->pll_ref_clk); | ||
| 301 | clk_disable_unprepare(dphy->psm_clk); | ||
| 302 | |||
| 303 | return 0; | ||
| 304 | } | ||
| 305 | |||
| 306 | static const struct phy_ops cdns_dphy_ops = { | ||
| 307 | .configure = cdns_dphy_configure, | ||
| 308 | .validate = cdns_dphy_validate, | ||
| 309 | .power_on = cdns_dphy_power_on, | ||
| 310 | .power_off = cdns_dphy_power_off, | ||
| 311 | }; | ||
| 312 | |||
| 313 | static int cdns_dphy_probe(struct platform_device *pdev) | ||
| 314 | { | ||
| 315 | struct phy_provider *phy_provider; | ||
| 316 | struct cdns_dphy *dphy; | ||
| 317 | struct resource *res; | ||
| 318 | int ret; | ||
| 319 | |||
| 320 | dphy = devm_kzalloc(&pdev->dev, sizeof(*dphy), GFP_KERNEL); | ||
| 321 | if (!dphy) | ||
| 322 | return -ENOMEM; | ||
| 323 | dev_set_drvdata(&pdev->dev, dphy); | ||
| 324 | |||
| 325 | dphy->ops = of_device_get_match_data(&pdev->dev); | ||
| 326 | if (!dphy->ops) | ||
| 327 | return -EINVAL; | ||
| 328 | |||
| 329 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
| 330 | dphy->regs = devm_ioremap_resource(&pdev->dev, res); | ||
| 331 | if (IS_ERR(dphy->regs)) | ||
| 332 | return PTR_ERR(dphy->regs); | ||
| 333 | |||
| 334 | dphy->psm_clk = devm_clk_get(&pdev->dev, "psm"); | ||
| 335 | if (IS_ERR(dphy->psm_clk)) | ||
| 336 | return PTR_ERR(dphy->psm_clk); | ||
| 337 | |||
| 338 | dphy->pll_ref_clk = devm_clk_get(&pdev->dev, "pll_ref"); | ||
| 339 | if (IS_ERR(dphy->pll_ref_clk)) | ||
| 340 | return PTR_ERR(dphy->pll_ref_clk); | ||
| 341 | |||
| 342 | if (dphy->ops->probe) { | ||
| 343 | ret = dphy->ops->probe(dphy); | ||
| 344 | if (ret) | ||
| 345 | return ret; | ||
| 346 | } | ||
| 347 | |||
| 348 | dphy->phy = devm_phy_create(&pdev->dev, NULL, &cdns_dphy_ops); | ||
| 349 | if (IS_ERR(dphy->phy)) { | ||
| 350 | dev_err(&pdev->dev, "failed to create PHY\n"); | ||
| 351 | if (dphy->ops->remove) | ||
| 352 | dphy->ops->remove(dphy); | ||
| 353 | return PTR_ERR(dphy->phy); | ||
| 354 | } | ||
| 355 | |||
| 356 | phy_set_drvdata(dphy->phy, dphy); | ||
| 357 | phy_provider = devm_of_phy_provider_register(&pdev->dev, | ||
| 358 | of_phy_simple_xlate); | ||
| 359 | |||
| 360 | return PTR_ERR_OR_ZERO(phy_provider); | ||
| 361 | } | ||
| 362 | |||
| 363 | static int cdns_dphy_remove(struct platform_device *pdev) | ||
| 364 | { | ||
| 365 | struct cdns_dphy *dphy = dev_get_drvdata(&pdev->dev); | ||
| 366 | |||
| 367 | if (dphy->ops->remove) | ||
| 368 | dphy->ops->remove(dphy); | ||
| 369 | |||
| 370 | return 0; | ||
| 371 | } | ||
| 372 | |||
| 373 | static const struct of_device_id cdns_dphy_of_match[] = { | ||
| 374 | { .compatible = "cdns,dphy", .data = &ref_dphy_ops }, | ||
| 375 | { /* sentinel */ }, | ||
| 376 | }; | ||
| 377 | MODULE_DEVICE_TABLE(of, cdns_dphy_of_match); | ||
| 378 | |||
| 379 | static struct platform_driver cdns_dphy_platform_driver = { | ||
| 380 | .probe = cdns_dphy_probe, | ||
| 381 | .remove = cdns_dphy_remove, | ||
| 382 | .driver = { | ||
| 383 | .name = "cdns-mipi-dphy", | ||
| 384 | .of_match_table = cdns_dphy_of_match, | ||
| 385 | }, | ||
| 386 | }; | ||
| 387 | module_platform_driver(cdns_dphy_platform_driver); | ||
| 388 | |||
| 389 | MODULE_AUTHOR("Maxime Ripard <maxime.ripard@bootlin.com>"); | ||
| 390 | MODULE_DESCRIPTION("Cadence MIPI D-PHY Driver"); | ||
| 391 | MODULE_LICENSE("GPL"); | ||
| @@ -2,4 +2,4 @@ config PHY_FSL_IMX8MQ_USB · 1 unmodified line | |||
| 2 | tristate "Freescale i.MX8M USB3 PHY" | 2 | tristate "Freescale i.MX8M USB3 PHY" |
| 3 | depends on OF && HAS_IOMEM | 3 | depends on OF && HAS_IOMEM |
| 4 | select GENERIC_PHY | 4 | select GENERIC_PHY |
| 5 | default SOC_IMX8MQ | 5 | default ARCH_MXC && ARM64 |
| @@ -21,6 +21,27 @@ config PHY_BERLIN_USB · 20 unmodified lines | |||
| 21 | help | 21 | help |
| 22 | Enable this to support the USB PHY on Marvell Berlin SoCs. | 22 | Enable this to support the USB PHY on Marvell Berlin SoCs. |
| 23 | 23 | ||
| 24 | config PHY_MVEBU_A3700_COMPHY | ||
| 25 | tristate "Marvell A3700 comphy driver" | ||
| 26 | depends on ARCH_MVEBU || COMPILE_TEST | ||
| 27 | depends on OF | ||
| 28 | depends on HAVE_ARM_SMCCC | ||
| 29 | default y | ||
| 30 | select GENERIC_PHY | ||
| 31 | help | ||
| 32 | This driver allows to control the comphy, a hardware block providing | ||
| 33 | shared serdes PHYs on Marvell Armada 3700. Its serdes lanes can be | ||
| 34 | used by various controllers: Ethernet, SATA, USB3, PCIe. | ||
| 35 | |||
| 36 | config PHY_MVEBU_A3700_UTMI | ||
| 37 | tristate "Marvell A3700 UTMI driver" | ||
| 38 | depends on ARCH_MVEBU || COMPILE_TEST | ||
| 39 | depends on OF | ||
| 40 | default y | ||
| 41 | select GENERIC_PHY | ||
| 42 | help | ||
| 43 | Enable this to support Marvell A3700 UTMI PHY driver. | ||
| 44 | |||
| 24 | config PHY_MVEBU_A38X_COMPHY | 45 | config PHY_MVEBU_A38X_COMPHY |
| 25 | tristate "Marvell Armada 38x comphy driver" | 46 | tristate "Marvell Armada 38x comphy driver" |
| 26 | depends on ARCH_MVEBU || COMPILE_TEST | 47 | depends on ARCH_MVEBU || COMPILE_TEST |
| @@ -2,6 +2,8 @@ · 1 unmodified line | |||
| 2 | obj-$(CONFIG_ARMADA375_USBCLUSTER_PHY) += phy-armada375-usb2.o | 2 | obj-$(CONFIG_ARMADA375_USBCLUSTER_PHY) += phy-armada375-usb2.o |
| 3 | obj-$(CONFIG_PHY_BERLIN_SATA) += phy-berlin-sata.o | 3 | obj-$(CONFIG_PHY_BERLIN_SATA) += phy-berlin-sata.o |
| 4 | obj-$(CONFIG_PHY_BERLIN_USB) += phy-berlin-usb.o | 4 | obj-$(CONFIG_PHY_BERLIN_USB) += phy-berlin-usb.o |
| 5 | obj-$(CONFIG_PHY_MVEBU_A3700_COMPHY) += phy-mvebu-a3700-comphy.o | ||
| 6 | obj-$(CONFIG_PHY_MVEBU_A3700_UTMI) += phy-mvebu-a3700-utmi.o | ||
| 5 | obj-$(CONFIG_PHY_MVEBU_A38X_COMPHY) += phy-armada38x-comphy.o | 7 | obj-$(CONFIG_PHY_MVEBU_A38X_COMPHY) += phy-armada38x-comphy.o |
| 6 | obj-$(CONFIG_PHY_MVEBU_CP110_COMPHY) += phy-mvebu-cp110-comphy.o | 8 | obj-$(CONFIG_PHY_MVEBU_CP110_COMPHY) += phy-mvebu-cp110-comphy.o |
| 7 | obj-$(CONFIG_PHY_MVEBU_SATA) += phy-mvebu-sata.o | 9 | obj-$(CONFIG_PHY_MVEBU_SATA) += phy-mvebu-sata.o |
| @@ -1,3 +1,4 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-2.0+ | ||
| 1 | /* | 2 | /* |
| 2 | * USB cluster support for Armada 375 platform. | 3 | * USB cluster support for Armada 375 platform. |
| 3 | * | 4 | * |
| @@ -5,10 +6,6 @@ · 1 unmodified line | |||
| 5 | * | 6 | * |
| 6 | * Gregory CLEMENT <gregory.clement@free-electrons.com> | 7 | * Gregory CLEMENT <gregory.clement@free-electrons.com> |
| 7 | * | 8 | * |
| 8 | * This file is licensed under the terms of the GNU General Public | ||
| 9 | * License version 2 or later. This program is licensed "as is" | ||
| 10 | * without any warranty of any kind, whether express or implied. | ||
| 11 | * | ||
| 12 | * Armada 375 comes with an USB2 host and device controller and an | 9 | * Armada 375 comes with an USB2 host and device controller and an |
| 13 | * USB3 controller. The USB cluster control register allows to manage | 10 | * USB3 controller. The USB cluster control register allows to manage |
| 14 | * common features of both USB controllers. | 11 | * common features of both USB controllers. |
| @@ -18,7 +15,6 @@ · 3 unmodified lines | |||
| 18 | #include <linux/init.h> | 15 | #include <linux/init.h> |
| 19 | #include <linux/io.h> | 16 | #include <linux/io.h> |
| 20 | #include <linux/kernel.h> | 17 | #include <linux/kernel.h> |
| 21 | #include <linux/module.h> | ||
| 22 | #include <linux/of_address.h> | 18 | #include <linux/of_address.h> |
| 23 | #include <linux/phy/phy.h> | 19 | #include <linux/phy/phy.h> |
| 24 | #include <linux/platform_device.h> | 20 | #include <linux/platform_device.h> |
| @@ -142,7 +138,6 @@ static const struct of_device_id of_usb_cluster_table[] = { · 117 unmodified lines | |||
| 142 | { .compatible = "marvell,armada-375-usb-cluster", }, | 138 | { .compatible = "marvell,armada-375-usb-cluster", }, |
| 143 | { /* end of list */ }, | 139 | { /* end of list */ }, |
| 144 | }; | 140 | }; |
| 145 | MODULE_DEVICE_TABLE(of, of_usb_cluster_table); | ||
| 146 | 141 | ||
| 147 | static struct platform_driver armada375_usb_phy_driver = { | 142 | static struct platform_driver armada375_usb_phy_driver = { |
| 148 | .probe = armada375_usb_phy_probe, | 143 | .probe = armada375_usb_phy_probe, |
| @@ -151,8 +146,4 @@ static struct platform_driver armada375_usb_phy_driver = { · 2 unmodified lines | |||
| 151 | .name = "armada-375-usb-cluster", | 146 | .name = "armada-375-usb-cluster", |
| 152 | } | 147 | } |
| 153 | }; | 148 | }; |
| 154 | module_platform_driver(armada375_usb_phy_driver); | 149 | builtin_platform_driver(armada375_usb_phy_driver); |
| 155 | |||
| 156 | MODULE_DESCRIPTION("Armada 375 USB cluster driver"); | ||
| 157 | MODULE_AUTHOR("Gregory CLEMENT <gregory.clement@free-electrons.com>"); | ||
| 158 | MODULE_LICENSE("GPL"); | ||
| @@ -0,0 +1,318 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-2.0 | ||
| 2 | /* | ||
| 3 | * Copyright (C) 2018 Marvell | ||
| 4 | * | ||
| 5 | * Authors: | ||
| 6 | * Evan Wang <xswang@marvell.com> | ||
| 7 | * Miquèl Raynal <miquel.raynal@bootlin.com> | ||
| 8 | * | ||
| 9 | * Structure inspired from phy-mvebu-cp110-comphy.c written by Antoine Tenart. | ||
| 10 | * SMC call initial support done by Grzegorz Jaszczyk. | ||
| 11 | */ | ||
| 12 | |||
| 13 | #include <linux/arm-smccc.h> | ||
| 14 | #include <linux/io.h> | ||
| 15 | #include <linux/iopoll.h> | ||
| 16 | #include <linux/mfd/syscon.h> | ||
| 17 | #include <linux/module.h> | ||
| 18 | #include <linux/phy.h> | ||
| 19 | #include <linux/phy/phy.h> | ||
| 20 | #include <linux/platform_device.h> | ||
| 21 | |||
| 22 | #define MVEBU_A3700_COMPHY_LANES 3 | ||
| 23 | #define MVEBU_A3700_COMPHY_PORTS 2 | ||
| 24 | |||
| 25 | /* COMPHY Fast SMC function identifiers */ | ||
| 26 | #define COMPHY_SIP_POWER_ON 0x82000001 | ||
| 27 | #define COMPHY_SIP_POWER_OFF 0x82000002 | ||
| 28 | #define COMPHY_SIP_PLL_LOCK 0x82000003 | ||
| 29 | |||
| 30 | #define COMPHY_FW_MODE_SATA 0x1 | ||
| 31 | #define COMPHY_FW_MODE_SGMII 0x2 | ||
| 32 | #define COMPHY_FW_MODE_HS_SGMII 0x3 | ||
| 33 | #define COMPHY_FW_MODE_USB3H 0x4 | ||
| 34 | #define COMPHY_FW_MODE_USB3D 0x5 | ||
| 35 | #define COMPHY_FW_MODE_PCIE 0x6 | ||
| 36 | #define COMPHY_FW_MODE_RXAUI 0x7 | ||
| 37 | #define COMPHY_FW_MODE_XFI 0x8 | ||
| 38 | #define COMPHY_FW_MODE_SFI 0x9 | ||
| 39 | #define COMPHY_FW_MODE_USB3 0xa | ||
| 40 | |||
| 41 | #define COMPHY_FW_SPEED_1_25G 0 /* SGMII 1G */ | ||
| 42 | #define COMPHY_FW_SPEED_2_5G 1 | ||
| 43 | #define COMPHY_FW_SPEED_3_125G 2 /* SGMII 2.5G */ | ||
| 44 | #define COMPHY_FW_SPEED_5G 3 | ||
| 45 | #define COMPHY_FW_SPEED_5_15625G 4 /* XFI 5G */ | ||
| 46 | #define COMPHY_FW_SPEED_6G 5 | ||
| 47 | #define COMPHY_FW_SPEED_10_3125G 6 /* XFI 10G */ | ||
| 48 | #define COMPHY_FW_SPEED_MAX 0x3F | ||
| 49 | |||
| 50 | #define COMPHY_FW_MODE(mode) ((mode) << 12) | ||
| 51 | #define COMPHY_FW_NET(mode, idx, speed) (COMPHY_FW_MODE(mode) | \ | ||
| 52 | ((idx) << 8) | \ | ||
| 53 | ((speed) << 2)) | ||
| 54 | #define COMPHY_FW_PCIE(mode, idx, speed, width) (COMPHY_FW_NET(mode, idx, speed) | \ | ||
| 55 | ((width) << 18)) | ||
| 56 | |||
| 57 | struct mvebu_a3700_comphy_conf { | ||
| 58 | unsigned int lane; | ||
| 59 | enum phy_mode mode; | ||
| 60 | int submode; | ||
| 61 | unsigned int port; | ||
| 62 | u32 fw_mode; | ||
| 63 | }; | ||
| 64 | |||
| 65 | #define MVEBU_A3700_COMPHY_CONF(_lane, _mode, _smode, _port, _fw) \ | ||
| 66 | { \ | ||
| 67 | .lane = _lane, \ | ||
| 68 | .mode = _mode, \ | ||
| 69 | .submode = _smode, \ | ||
| 70 | .port = _port, \ | ||
| 71 | .fw_mode = _fw, \ | ||
| 72 | } | ||
| 73 | |||
| 74 | #define MVEBU_A3700_COMPHY_CONF_GEN(_lane, _mode, _port, _fw) \ | ||
| 75 | MVEBU_A3700_COMPHY_CONF(_lane, _mode, PHY_INTERFACE_MODE_NA, _port, _fw) | ||
| 76 | |||
| 77 | #define MVEBU_A3700_COMPHY_CONF_ETH(_lane, _smode, _port, _fw) \ | ||
| 78 | MVEBU_A3700_COMPHY_CONF(_lane, PHY_MODE_ETHERNET, _smode, _port, _fw) | ||
| 79 | |||
| 80 | static const struct mvebu_a3700_comphy_conf mvebu_a3700_comphy_modes[] = { | ||
| 81 | /* lane 0 */ | ||
| 82 | MVEBU_A3700_COMPHY_CONF_GEN(0, PHY_MODE_USB_HOST_SS, 0, | ||
| 83 | COMPHY_FW_MODE_USB3H), | ||
| 84 | MVEBU_A3700_COMPHY_CONF_ETH(0, PHY_INTERFACE_MODE_SGMII, 1, | ||
| 85 | COMPHY_FW_MODE_SGMII), | ||
| 86 | MVEBU_A3700_COMPHY_CONF_ETH(0, PHY_INTERFACE_MODE_2500BASEX, 1, | ||
| 87 | COMPHY_FW_MODE_HS_SGMII), | ||
| 88 | /* lane 1 */ | ||
| 89 | MVEBU_A3700_COMPHY_CONF_GEN(1, PHY_MODE_PCIE, 0, | ||
| 90 | COMPHY_FW_MODE_PCIE), | ||
| 91 | MVEBU_A3700_COMPHY_CONF_ETH(1, PHY_INTERFACE_MODE_SGMII, 0, | ||
| 92 | COMPHY_FW_MODE_SGMII), | ||
| 93 | MVEBU_A3700_COMPHY_CONF_ETH(1, PHY_INTERFACE_MODE_2500BASEX, 0, | ||
| 94 | COMPHY_FW_MODE_HS_SGMII), | ||
| 95 | /* lane 2 */ | ||
| 96 | MVEBU_A3700_COMPHY_CONF_GEN(2, PHY_MODE_SATA, 0, | ||
| 97 | COMPHY_FW_MODE_SATA), | ||
| 98 | MVEBU_A3700_COMPHY_CONF_GEN(2, PHY_MODE_USB_HOST_SS, 0, | ||
| 99 | COMPHY_FW_MODE_USB3H), | ||
| 100 | }; | ||
| 101 | |||
| 102 | struct mvebu_a3700_comphy_lane { | ||
| 103 | struct device *dev; | ||
| 104 | unsigned int id; | ||
| 105 | enum phy_mode mode; | ||
| 106 | int submode; | ||
| 107 | int port; | ||
| 108 | }; | ||
| 109 | |||
| 110 | static int mvebu_a3700_comphy_smc(unsigned long function, unsigned long lane, | ||
| 111 | unsigned long mode) | ||
| 112 | { | ||
| 113 | struct arm_smccc_res res; | ||
| 114 | |||
| 115 | arm_smccc_smc(function, lane, mode, 0, 0, 0, 0, 0, &res); | ||
| 116 | |||
| 117 | return res.a0; | ||
| 118 | } | ||
| 119 | |||
| 120 | static int mvebu_a3700_comphy_get_fw_mode(int lane, int port, | ||
| 121 | enum phy_mode mode, | ||
| 122 | int submode) | ||
| 123 | { | ||
| 124 | int i, n = ARRAY_SIZE(mvebu_a3700_comphy_modes); | ||
| 125 | |||
| 126 | /* Unused PHY mux value is 0x0 */ | ||
| 127 | if (mode == PHY_MODE_INVALID) | ||
| 128 | return -EINVAL; | ||
| 129 | |||
| 130 | for (i = 0; i < n; i++) { | ||
| 131 | if (mvebu_a3700_comphy_modes[i].lane == lane && | ||
| 132 | mvebu_a3700_comphy_modes[i].port == port && | ||
| 133 | mvebu_a3700_comphy_modes[i].mode == mode && | ||
| 134 | mvebu_a3700_comphy_modes[i].submode == submode) | ||
| 135 | break; | ||
| 136 | } | ||
| 137 | |||
| 138 | if (i == n) | ||
| 139 | return -EINVAL; | ||
| 140 | |||
| 141 | return mvebu_a3700_comphy_modes[i].fw_mode; | ||
| 142 | } | ||
| 143 | |||
| 144 | static int mvebu_a3700_comphy_set_mode(struct phy *phy, enum phy_mode mode, | ||
| 145 | int submode) | ||
| 146 | { | ||
| 147 | struct mvebu_a3700_comphy_lane *lane = phy_get_drvdata(phy); | ||
| 148 | int fw_mode; | ||
| 149 | |||
| 150 | if (submode == PHY_INTERFACE_MODE_1000BASEX) | ||
| 151 | submode = PHY_INTERFACE_MODE_SGMII; | ||
| 152 | |||
| 153 | fw_mode = mvebu_a3700_comphy_get_fw_mode(lane->id, lane->port, mode, | ||
| 154 | submode); | ||
| 155 | if (fw_mode < 0) { | ||
| 156 | dev_err(lane->dev, "invalid COMPHY mode\n"); | ||
| 157 | return fw_mode; | ||
| 158 | } | ||
| 159 | |||
| 160 | /* Just remember the mode, ->power_on() will do the real setup */ | ||
| 161 | lane->mode = mode; | ||
| 162 | lane->submode = submode; | ||
| 163 | |||
| 164 | return 0; | ||
| 165 | } | ||
| 166 | |||
| 167 | static int mvebu_a3700_comphy_power_on(struct phy *phy) | ||
| 168 | { | ||
| 169 | struct mvebu_a3700_comphy_lane *lane = phy_get_drvdata(phy); | ||
| 170 | u32 fw_param; | ||
| 171 | int fw_mode; | ||
| 172 | |||
| 173 | fw_mode = mvebu_a3700_comphy_get_fw_mode(lane->id, lane->port, | ||
| 174 | lane->mode, lane->submode); | ||
| 175 | if (fw_mode < 0) { | ||
| 176 | dev_err(lane->dev, "invalid COMPHY mode\n"); | ||
| 177 | return fw_mode; | ||
| 178 | } | ||
| 179 | |||
| 180 | switch (lane->mode) { | ||
| 181 | case PHY_MODE_USB_HOST_SS: | ||
| 182 | dev_dbg(lane->dev, "set lane %d to USB3 host mode\n", lane->id); | ||
| 183 | fw_param = COMPHY_FW_MODE(fw_mode); | ||
| 184 | break; | ||
| 185 | case PHY_MODE_SATA: | ||
| 186 | dev_dbg(lane->dev, "set lane %d to SATA mode\n", lane->id); | ||
| 187 | fw_param = COMPHY_FW_MODE(fw_mode); | ||
| 188 | break; | ||
| 189 | case PHY_MODE_ETHERNET: | ||
| 190 | switch (lane->submode) { | ||
| 191 | case PHY_INTERFACE_MODE_SGMII: | ||
| 192 | dev_dbg(lane->dev, "set lane %d to SGMII mode\n", | ||
| 193 | lane->id); | ||
| 194 | fw_param = COMPHY_FW_NET(fw_mode, lane->port, | ||
| 195 | COMPHY_FW_SPEED_1_25G); | ||
| 196 | break; | ||
| 197 | case PHY_INTERFACE_MODE_2500BASEX: | ||
| 198 | dev_dbg(lane->dev, "set lane %d to HS SGMII mode\n", | ||
| 199 | lane->id); | ||
| 200 | fw_param = COMPHY_FW_NET(fw_mode, lane->port, | ||
| 201 | COMPHY_FW_SPEED_3_125G); | ||
| 202 | break; | ||
| 203 | default: | ||
| 204 | dev_err(lane->dev, "unsupported PHY submode (%d)\n", | ||
| 205 | lane->submode); | ||
| 206 | return -ENOTSUPP; | ||
| 207 | } | ||
| 208 | break; | ||
| 209 | case PHY_MODE_PCIE: | ||
| 210 | dev_dbg(lane->dev, "set lane %d to PCIe mode\n", lane->id); | ||
| 211 | fw_param = COMPHY_FW_PCIE(fw_mode, lane->port, | ||
| 212 | COMPHY_FW_SPEED_5G, | ||
| 213 | phy->attrs.bus_width); | ||
| 214 | break; | ||
| 215 | default: | ||
| 216 | dev_err(lane->dev, "unsupported PHY mode (%d)\n", lane->mode); | ||
| 217 | return -ENOTSUPP; | ||
| 218 | } | ||
| 219 | |||
| 220 | return mvebu_a3700_comphy_smc(COMPHY_SIP_POWER_ON, lane->id, fw_param); | ||
| 221 | } | ||
| 222 | |||
| 223 | static int mvebu_a3700_comphy_power_off(struct phy *phy) | ||
| 224 | { | ||
| 225 | struct mvebu_a3700_comphy_lane *lane = phy_get_drvdata(phy); | ||
| 226 | |||
| 227 | return mvebu_a3700_comphy_smc(COMPHY_SIP_POWER_OFF, lane->id, 0); | ||
| 228 | } | ||
| 229 | |||
| 230 | static const struct phy_ops mvebu_a3700_comphy_ops = { | ||
| 231 | .power_on = mvebu_a3700_comphy_power_on, | ||
| 232 | .power_off = mvebu_a3700_comphy_power_off, | ||
| 233 | .set_mode = mvebu_a3700_comphy_set_mode, | ||
| 234 | .owner = THIS_MODULE, | ||
| 235 | }; | ||
| 236 | |||
| 237 | static struct phy *mvebu_a3700_comphy_xlate(struct device *dev, | ||
| 238 | struct of_phandle_args *args) | ||
| 239 | { | ||
| 240 | struct mvebu_a3700_comphy_lane *lane; | ||
| 241 | struct phy *phy; | ||
| 242 | |||
| 243 | if (WARN_ON(args->args[0] >= MVEBU_A3700_COMPHY_PORTS)) | ||
| 244 | return ERR_PTR(-EINVAL); | ||
| 245 | |||
| 246 | phy = of_phy_simple_xlate(dev, args); | ||
| 247 | if (IS_ERR(phy)) | ||
| 248 | return phy; | ||
| 249 | |||
| 250 | lane = phy_get_drvdata(phy); | ||
| 251 | lane->port = args->args[0]; | ||
| 252 | |||
| 253 | return phy; | ||
| 254 | } | ||
| 255 | |||
| 256 | static int mvebu_a3700_comphy_probe(struct platform_device *pdev) | ||
| 257 | { | ||
| 258 | struct phy_provider *provider; | ||
| 259 | struct device_node *child; | ||
| 260 | |||
| 261 | for_each_available_child_of_node(pdev->dev.of_node, child) { | ||
| 262 | struct mvebu_a3700_comphy_lane *lane; | ||
| 263 | struct phy *phy; | ||
| 264 | int ret; | ||
| 265 | u32 lane_id; | ||
| 266 | |||
| 267 | ret = of_property_read_u32(child, "reg", &lane_id); | ||
| 268 | if (ret < 0) { | ||
| 269 | dev_err(&pdev->dev, "missing 'reg' property (%d)\n", | ||
| 270 | ret); | ||
| 271 | continue; | ||
| 272 | } | ||
| 273 | |||
| 274 | if (lane_id >= MVEBU_A3700_COMPHY_LANES) { | ||
| 275 | dev_err(&pdev->dev, "invalid 'reg' property\n"); | ||
| 276 | continue; | ||
| 277 | } | ||
| 278 | |||
| 279 | lane = devm_kzalloc(&pdev->dev, sizeof(*lane), GFP_KERNEL); | ||
| 280 | if (!lane) | ||
| 281 | return -ENOMEM; | ||
| 282 | |||
| 283 | phy = devm_phy_create(&pdev->dev, child, | ||
| 284 | &mvebu_a3700_comphy_ops); | ||
| 285 | if (IS_ERR(phy)) | ||
| 286 | return PTR_ERR(phy); | ||
| 287 | |||
| 288 | lane->dev = &pdev->dev; | ||
| 289 | lane->mode = PHY_MODE_INVALID; | ||
| 290 | lane->submode = PHY_INTERFACE_MODE_NA; | ||
| 291 | lane->id = lane_id; | ||
| 292 | lane->port = -1; | ||
| 293 | phy_set_drvdata(phy, lane); | ||
| 294 | } | ||
| 295 | |||
| 296 | provider = devm_of_phy_provider_register(&pdev->dev, | ||
| 297 | mvebu_a3700_comphy_xlate); | ||
| 298 | return PTR_ERR_OR_ZERO(provider); | ||
| 299 | } | ||
| 300 | |||
| 301 | static const struct of_device_id mvebu_a3700_comphy_of_match_table[] = { | ||
| 302 | { .compatible = "marvell,comphy-a3700" }, | ||
| 303 | { }, | ||
| 304 | }; | ||
| 305 | MODULE_DEVICE_TABLE(of, mvebu_a3700_comphy_of_match_table); | ||
| 306 | |||
| 307 | static struct platform_driver mvebu_a3700_comphy_driver = { | ||
| 308 | .probe = mvebu_a3700_comphy_probe, | ||
| 309 | .driver = { | ||
| 310 | .name = "mvebu-a3700-comphy", | ||
| 311 | .of_match_table = mvebu_a3700_comphy_of_match_table, | ||
| 312 | }, | ||
| 313 | }; | ||
| 314 | module_platform_driver(mvebu_a3700_comphy_driver); | ||
| 315 | |||
| 316 | MODULE_AUTHOR("Miquèl Raynal <miquel.raynal@bootlin.com>"); | ||
| 317 | MODULE_DESCRIPTION("Common PHY driver for A3700"); | ||
| 318 | MODULE_LICENSE("GPL v2"); | ||
| @@ -0,0 +1,278 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-2.0 | ||
| 2 | /* | ||
| 3 | * Copyright (C) 2018 Marvell | ||
| 4 | * | ||
| 5 | * Authors: | ||
| 6 | * Igal Liberman <igall@marvell.com> | ||
| 7 | * Miquèl Raynal <miquel.raynal@bootlin.com> | ||
| 8 | * | ||
| 9 | * Marvell A3700 UTMI PHY driver | ||
| 10 | */ | ||
| 11 | |||
| 12 | #include <linux/io.h> | ||
| 13 | #include <linux/iopoll.h> | ||
| 14 | #include <linux/mfd/syscon.h> | ||
| 15 | #include <linux/module.h> | ||
| 16 | #include <linux/of_device.h> | ||
| 17 | #include <linux/phy/phy.h> | ||
| 18 | #include <linux/platform_device.h> | ||
| 19 | #include <linux/regmap.h> | ||
| 20 | |||
| 21 | /* Armada 3700 UTMI PHY registers */ | ||
| 22 | #define USB2_PHY_PLL_CTRL_REG0 0x0 | ||
| 23 | #define PLL_REF_DIV_OFF 0 | ||
| 24 | #define PLL_REF_DIV_MASK GENMASK(6, 0) | ||
| 25 | #define PLL_REF_DIV_5 5 | ||
| 26 | #define PLL_FB_DIV_OFF 16 | ||
| 27 | #define PLL_FB_DIV_MASK GENMASK(24, 16) | ||
| 28 | #define PLL_FB_DIV_96 96 | ||
| 29 | #define PLL_SEL_LPFR_OFF 28 | ||
| 30 | #define PLL_SEL_LPFR_MASK GENMASK(29, 28) | ||
| 31 | #define PLL_READY BIT(31) | ||
| 32 | #define USB2_PHY_CAL_CTRL 0x8 | ||
| 33 | #define PHY_PLLCAL_DONE BIT(31) | ||
| 34 | #define PHY_IMPCAL_DONE BIT(23) | ||
| 35 | #define USB2_RX_CHAN_CTRL1 0x18 | ||
| 36 | #define USB2PHY_SQCAL_DONE BIT(31) | ||
| 37 | #define USB2_PHY_OTG_CTRL 0x34 | ||
| 38 | #define PHY_PU_OTG BIT(4) | ||
| 39 | #define USB2_PHY_CHRGR_DETECT 0x38 | ||
| 40 | #define PHY_CDP_EN BIT(2) | ||
| 41 | #define PHY_DCP_EN BIT(3) | ||
| 42 | #define PHY_PD_EN BIT(4) | ||
| 43 | #define PHY_PU_CHRG_DTC BIT(5) | ||
| 44 | #define PHY_CDP_DM_AUTO BIT(7) | ||
| 45 | #define PHY_ENSWITCH_DP BIT(12) | ||
| 46 | #define PHY_ENSWITCH_DM BIT(13) | ||
| 47 | |||
| 48 | /* Armada 3700 USB miscellaneous registers */ | ||
| 49 | #define USB2_PHY_CTRL(usb32) (usb32 ? 0x20 : 0x4) | ||
| 50 | #define RB_USB2PHY_PU BIT(0) | ||
| 51 | #define USB2_DP_PULLDN_DEV_MODE BIT(5) | ||
| 52 | #define USB2_DM_PULLDN_DEV_MODE BIT(6) | ||
| 53 | #define RB_USB2PHY_SUSPM(usb32) (usb32 ? BIT(14) : BIT(7)) | ||
| 54 | |||
| 55 | #define PLL_LOCK_DELAY_US 10000 | ||
| 56 | #define PLL_LOCK_TIMEOUT_US 1000000 | ||
| 57 | |||
| 58 | /** | ||
| 59 | * struct mvebu_a3700_utmi_caps - PHY capabilities | ||
| 60 | * | ||
| 61 | * @usb32: Flag indicating which PHY is in use (impacts the register map): | ||
| 62 | * - The UTMI PHY wired to the USB3/USB2 controller (otg) | ||
| 63 | * - The UTMI PHY wired to the USB2 controller (host only) | ||
| 64 | * @ops: PHY operations | ||
| 65 | */ | ||
| 66 | struct mvebu_a3700_utmi_caps { | ||
| 67 | int usb32; | ||
| 68 | const struct phy_ops *ops; | ||
| 69 | }; | ||
| 70 | |||
| 71 | /** | ||
| 72 | * struct mvebu_a3700_utmi - PHY driver data | ||
| 73 | * | ||
| 74 | * @regs: PHY registers | ||
| 75 | * @usb_mis: Regmap with USB miscellaneous registers including PHY ones | ||
| 76 | * @caps: PHY capabilities | ||
| 77 | * @phy: PHY handle | ||
| 78 | */ | ||
| 79 | struct mvebu_a3700_utmi { | ||
| 80 | void __iomem *regs; | ||
| 81 | struct regmap *usb_misc; | ||
| 82 | const struct mvebu_a3700_utmi_caps *caps; | ||
| 83 | struct phy *phy; | ||
| 84 | }; | ||
| 85 | |||
| 86 | static int mvebu_a3700_utmi_phy_power_on(struct phy *phy) | ||
| 87 | { | ||
| 88 | struct mvebu_a3700_utmi *utmi = phy_get_drvdata(phy); | ||
| 89 | struct device *dev = &phy->dev; | ||
| 90 | int usb32 = utmi->caps->usb32; | ||
| 91 | int ret = 0; | ||
| 92 | u32 reg; | ||
| 93 | |||
| 94 | /* | ||
| 95 | * Setup PLL. 40MHz clock used to be the default, being 25MHz now. | ||
| 96 | * See "PLL Settings for Typical REFCLK" table. | ||
| 97 | */ | ||
| 98 | reg = readl(utmi->regs + USB2_PHY_PLL_CTRL_REG0); | ||
| 99 | reg &= ~(PLL_REF_DIV_MASK | PLL_FB_DIV_MASK | PLL_SEL_LPFR_MASK); | ||
| 100 | reg |= (PLL_REF_DIV_5 << PLL_REF_DIV_OFF) | | ||
| 101 | (PLL_FB_DIV_96 << PLL_FB_DIV_OFF); | ||
| 102 | writel(reg, utmi->regs + USB2_PHY_PLL_CTRL_REG0); | ||
| 103 | |||
| 104 | /* Enable PHY pull up and disable USB2 suspend */ | ||
| 105 | regmap_update_bits(utmi->usb_misc, USB2_PHY_CTRL(usb32), | ||
| 106 | RB_USB2PHY_SUSPM(usb32) | RB_USB2PHY_PU, | ||
| 107 | RB_USB2PHY_SUSPM(usb32) | RB_USB2PHY_PU); | ||
| 108 | |||
| 109 | if (usb32) { | ||
| 110 | /* Power up OTG module */ | ||
| 111 | reg = readl(utmi->regs + USB2_PHY_OTG_CTRL); | ||
| 112 | reg |= PHY_PU_OTG; | ||
| 113 | writel(reg, utmi->regs + USB2_PHY_OTG_CTRL); | ||
| 114 | |||
| 115 | /* Disable PHY charger detection */ | ||
| 116 | reg = readl(utmi->regs + USB2_PHY_CHRGR_DETECT); | ||
| 117 | reg &= ~(PHY_CDP_EN | PHY_DCP_EN | PHY_PD_EN | PHY_PU_CHRG_DTC | | ||
| 118 | PHY_CDP_DM_AUTO | PHY_ENSWITCH_DP | PHY_ENSWITCH_DM); | ||
| 119 | writel(reg, utmi->regs + USB2_PHY_CHRGR_DETECT); | ||
| 120 | |||
| 121 | /* Disable PHY DP/DM pull-down (used for device mode) */ | ||
| 122 | regmap_update_bits(utmi->usb_misc, USB2_PHY_CTRL(usb32), | ||
| 123 | USB2_DP_PULLDN_DEV_MODE | | ||
| 124 | USB2_DM_PULLDN_DEV_MODE, 0); | ||
| 125 | } | ||
| 126 | |||
| 127 | /* Wait for PLL calibration */ | ||
| 128 | ret = readl_poll_timeout(utmi->regs + USB2_PHY_CAL_CTRL, reg, | ||
| 129 | reg & PHY_PLLCAL_DONE, | ||
| 130 | PLL_LOCK_DELAY_US, PLL_LOCK_TIMEOUT_US); | ||
| 131 | if (ret) { | ||
| 132 | dev_err(dev, "Failed to end USB2 PLL calibration\n"); | ||
| 133 | return ret; | ||
| 134 | } | ||
| 135 | |||
| 136 | /* Wait for impedance calibration */ | ||
| 137 | ret = readl_poll_timeout(utmi->regs + USB2_PHY_CAL_CTRL, reg, | ||
| 138 | reg & PHY_IMPCAL_DONE, | ||
| 139 | PLL_LOCK_DELAY_US, PLL_LOCK_TIMEOUT_US); | ||
| 140 | if (ret) { | ||
| 141 | dev_err(dev, "Failed to end USB2 impedance calibration\n"); | ||
| 142 | return ret; | ||
| 143 | } | ||
| 144 | |||
| 145 | /* Wait for squelch calibration */ | ||
| 146 | ret = readl_poll_timeout(utmi->regs + USB2_RX_CHAN_CTRL1, reg, | ||
| 147 | reg & USB2PHY_SQCAL_DONE, | ||
| 148 | PLL_LOCK_DELAY_US, PLL_LOCK_TIMEOUT_US); | ||
| 149 | if (ret) { | ||
| 150 | dev_err(dev, "Failed to end USB2 unknown calibration\n"); | ||
| 151 | return ret; | ||
| 152 | } | ||
| 153 | |||
| 154 | /* Wait for PLL to be locked */ | ||
| 155 | ret = readl_poll_timeout(utmi->regs + USB2_PHY_PLL_CTRL_REG0, reg, | ||
| 156 | reg & PLL_READY, | ||
| 157 | PLL_LOCK_DELAY_US, PLL_LOCK_TIMEOUT_US); | ||
| 158 | if (ret) | ||
| 159 | dev_err(dev, "Failed to lock USB2 PLL\n"); | ||
| 160 | |||
| 161 | return ret; | ||
| 162 | } | ||
| 163 | |||
| 164 | static int mvebu_a3700_utmi_phy_power_off(struct phy *phy) | ||
| 165 | { | ||
| 166 | struct mvebu_a3700_utmi *utmi = phy_get_drvdata(phy); | ||
| 167 | int usb32 = utmi->caps->usb32; | ||
| 168 | u32 reg; | ||
| 169 | |||
| 170 | /* Disable PHY pull-up and enable USB2 suspend */ | ||
| 171 | reg = readl(utmi->regs + USB2_PHY_CTRL(usb32)); | ||
| 172 | reg &= ~(RB_USB2PHY_PU | RB_USB2PHY_SUSPM(usb32)); | ||
| 173 | writel(reg, utmi->regs + USB2_PHY_CTRL(usb32)); | ||
| 174 | |||
| 175 | /* Power down OTG module */ | ||
| 176 | if (usb32) { | ||
| 177 | reg = readl(utmi->regs + USB2_PHY_OTG_CTRL); | ||
| 178 | reg &= ~PHY_PU_OTG; | ||
| 179 | writel(reg, utmi->regs + USB2_PHY_OTG_CTRL); | ||
| 180 | } | ||
| 181 | |||
| 182 | return 0; | ||
| 183 | } | ||
| 184 | |||
| 185 | static const struct phy_ops mvebu_a3700_utmi_phy_ops = { | ||
| 186 | .power_on = mvebu_a3700_utmi_phy_power_on, | ||
| 187 | .power_off = mvebu_a3700_utmi_phy_power_off, | ||
| 188 | .owner = THIS_MODULE, | ||
| 189 | }; | ||
| 190 | |||
| 191 | static const struct mvebu_a3700_utmi_caps mvebu_a3700_utmi_otg_phy_caps = { | ||
| 192 | .usb32 = true, | ||
| 193 | .ops = &mvebu_a3700_utmi_phy_ops, | ||
| 194 | }; | ||
| 195 | |||
| 196 | static const struct mvebu_a3700_utmi_caps mvebu_a3700_utmi_host_phy_caps = { | ||
| 197 | .usb32 = false, | ||
| 198 | .ops = &mvebu_a3700_utmi_phy_ops, | ||
| 199 | }; | ||
| 200 | |||
| 201 | static const struct of_device_id mvebu_a3700_utmi_of_match[] = { | ||
| 202 | { | ||
| 203 | .compatible = "marvell,a3700-utmi-otg-phy", | ||
| 204 | .data = &mvebu_a3700_utmi_otg_phy_caps, | ||
| 205 | }, | ||
| 206 | { | ||
| 207 | .compatible = "marvell,a3700-utmi-host-phy", | ||
| 208 | .data = &mvebu_a3700_utmi_host_phy_caps, | ||
| 209 | }, | ||
| 210 | {}, | ||
| 211 | }; | ||
| 212 | MODULE_DEVICE_TABLE(of, mvebu_a3700_utmi_of_match); | ||
| 213 | |||
| 214 | static int mvebu_a3700_utmi_phy_probe(struct platform_device *pdev) | ||
| 215 | { | ||
| 216 | struct device *dev = &pdev->dev; | ||
| 217 | struct mvebu_a3700_utmi *utmi; | ||
| 218 | struct phy_provider *provider; | ||
| 219 | struct resource *res; | ||
| 220 | |||
| 221 | utmi = devm_kzalloc(dev, sizeof(*utmi), GFP_KERNEL); | ||
| 222 | if (!utmi) | ||
| 223 | return -ENOMEM; | ||
| 224 | |||
| 225 | /* Get UTMI memory region */ | ||
| 226 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
| 227 | if (!res) { | ||
| 228 | dev_err(dev, "Missing UTMI PHY memory resource\n"); | ||
| 229 | return -ENODEV; | ||
| 230 | } | ||
| 231 | |||
| 232 | utmi->regs = devm_ioremap_resource(dev, res); | ||
| 233 | if (IS_ERR(utmi->regs)) | ||
| 234 | return PTR_ERR(utmi->regs); | ||
| 235 | |||
| 236 | /* Get miscellaneous Host/PHY region */ | ||
| 237 | utmi->usb_misc = syscon_regmap_lookup_by_phandle(dev->of_node, | ||
| 238 | "marvell,usb-misc-reg"); | ||
| 239 | if (IS_ERR(utmi->usb_misc)) { | ||
| 240 | dev_err(dev, | ||
| 241 | "Missing USB misc purpose system controller\n"); | ||
| 242 | return PTR_ERR(utmi->usb_misc); | ||
| 243 | } | ||
| 244 | |||
| 245 | /* Retrieve PHY capabilities */ | ||
| 246 | utmi->caps = of_device_get_match_data(dev); | ||
| 247 | |||
| 248 | /* Instantiate the PHY */ | ||
| 249 | utmi->phy = devm_phy_create(dev, NULL, utmi->caps->ops); | ||
| 250 | if (IS_ERR(utmi->phy)) { | ||
| 251 | dev_err(dev, "Failed to create the UTMI PHY\n"); | ||
| 252 | return PTR_ERR(utmi->phy); | ||
| 253 | } | ||
| 254 | |||
| 255 | phy_set_drvdata(utmi->phy, utmi); | ||
| 256 | |||
| 257 | /* Ensure the PHY is powered off */ | ||
| 258 | utmi->caps->ops->power_off(utmi->phy); | ||
| 259 | |||
| 260 | provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate); | ||
| 261 | |||
| 262 | return PTR_ERR_OR_ZERO(provider); | ||
| 263 | } | ||
| 264 | |||
| 265 | static struct platform_driver mvebu_a3700_utmi_driver = { | ||
| 266 | .probe = mvebu_a3700_utmi_phy_probe, | ||
| 267 | .driver = { | ||
| 268 | .name = "mvebu-a3700-utmi-phy", | ||
| 269 | .owner = THIS_MODULE, | ||
| 270 | .of_match_table = mvebu_a3700_utmi_of_match, | ||
| 271 | }, | ||
| 272 | }; | ||
| 273 | module_platform_driver(mvebu_a3700_utmi_driver); | ||
| 274 | |||
| 275 | MODULE_AUTHOR("Igal Liberman <igall@marvell.com>"); | ||
| 276 | MODULE_AUTHOR("Miquel Raynal <miquel.raynal@bootlin.com>"); | ||
| 277 | MODULE_DESCRIPTION("Marvell EBU A3700 UTMI PHY driver"); | ||
| 278 | MODULE_LICENSE("GPL v2"); | ||
| @@ -580,8 +580,6 @@ static struct phy *mvebu_comphy_xlate(struct device *dev, · 579 unmodified lines | |||
| 580 | return phy; | 580 | return phy; |
| 581 | 581 | ||
| 582 | lane = phy_get_drvdata(phy); | 582 | lane = phy_get_drvdata(phy); |
| 583 | if (lane->port >= 0) | ||
| 584 | return ERR_PTR(-EBUSY); | ||
| 585 | lane->port = args->args[0]; | 583 | lane->port = args->args[0]; |
| 586 | 584 | ||
| 587 | return phy; | 585 | return phy; |
| @@ -10,7 +10,7 @@ · 9 unmodified lines | |||
| 10 | */ | 10 | */ |
| 11 | 11 | ||
| 12 | #include <linux/kernel.h> | 12 | #include <linux/kernel.h> |
| 13 | #include <linux/module.h> | 13 | #include <linux/init.h> |
| 14 | #include <linux/clk.h> | 14 | #include <linux/clk.h> |
| 15 | #include <linux/phy/phy.h> | 15 | #include <linux/phy/phy.h> |
| 16 | #include <linux/io.h> | 16 | #include <linux/io.h> |
| @@ -122,7 +122,6 @@ static const struct of_device_id phy_mvebu_sata_of_match[] = { · 105 unmodified lines | |||
| 122 | { .compatible = "marvell,mvebu-sata-phy" }, | 122 | { .compatible = "marvell,mvebu-sata-phy" }, |
| 123 | { }, | 123 | { }, |
| 124 | }; | 124 | }; |
| 125 | MODULE_DEVICE_TABLE(of, phy_mvebu_sata_of_match); | ||
| 126 | 125 | ||
| 127 | static struct platform_driver phy_mvebu_sata_driver = { | 126 | static struct platform_driver phy_mvebu_sata_driver = { |
| 128 | .probe = phy_mvebu_sata_probe, | 127 | .probe = phy_mvebu_sata_probe, |
| @@ -131,8 +130,4 @@ static struct platform_driver phy_mvebu_sata_driver = { · 2 unmodified lines | |||
| 131 | .of_match_table = phy_mvebu_sata_of_match, | 130 | .of_match_table = phy_mvebu_sata_of_match, |
| 132 | } | 131 | } |
| 133 | }; | 132 | }; |
| 134 | module_platform_driver(phy_mvebu_sata_driver); | 133 | builtin_platform_driver(phy_mvebu_sata_driver); |
| 135 | |||
| 136 | MODULE_AUTHOR("Andrew Lunn <andrew@lunn.ch>"); | ||
| 137 | MODULE_DESCRIPTION("Marvell MVEBU SATA PHY driver"); | ||
| 138 | MODULE_LICENSE("GPL v2"); | ||
| @@ -65,12 +65,12 @@ int phy_mipi_dphy_get_default_config(unsigned long pixel_clock, · 64 unmodified lines | |||
| 65 | */ | 65 | */ |
| 66 | cfg->hs_trail = max(4 * 8 * ui, 60000 + 4 * 4 * ui); | 66 | cfg->hs_trail = max(4 * 8 * ui, 60000 + 4 * 4 * ui); |
| 67 | 67 | ||
| 68 | cfg->init = 100000000; | 68 | cfg->init = 100; |
| 69 | cfg->lpx = 60000; | 69 | cfg->lpx = 60000; |
| 70 | cfg->ta_get = 5 * cfg->lpx; | 70 | cfg->ta_get = 5 * cfg->lpx; |
| 71 | cfg->ta_go = 4 * cfg->lpx; | 71 | cfg->ta_go = 4 * cfg->lpx; |
| 72 | cfg->ta_sure = 2 * cfg->lpx; | 72 | cfg->ta_sure = 2 * cfg->lpx; |
| 73 | cfg->wakeup = 1000000000; | 73 | cfg->wakeup = 1000; |
| 74 | 74 | ||
| 75 | cfg->hs_clk_rate = hs_clk_rate; | 75 | cfg->hs_clk_rate = hs_clk_rate; |
| 76 | cfg->lanes = lanes; | 76 | cfg->lanes = lanes; |
| @@ -143,7 +143,7 @@ int phy_mipi_dphy_config_validate(struct phy_configure_opts_mipi_dphy *cfg) · 66 unmodified lines | |||
| 143 | if (cfg->hs_trail < max(8 * ui, 60000 + 4 * ui)) | 143 | if (cfg->hs_trail < max(8 * ui, 60000 + 4 * ui)) |
| 144 | return -EINVAL; | 144 | return -EINVAL; |
| 145 | 145 | ||
| 146 | if (cfg->init < 100000000) | 146 | if (cfg->init < 100) |
| 147 | return -EINVAL; | 147 | return -EINVAL; |
| 148 | 148 | ||
| 149 | if (cfg->lpx < 50000) | 149 | if (cfg->lpx < 50000) |
| @@ -158,7 +158,7 @@ int phy_mipi_dphy_config_validate(struct phy_configure_opts_mipi_dphy *cfg) · 8 unmodified lines | |||
| 158 | if (cfg->ta_sure < cfg->lpx || cfg->ta_sure > (2 * cfg->lpx)) | 158 | if (cfg->ta_sure < cfg->lpx || cfg->ta_sure > (2 * cfg->lpx)) |
| 159 | return -EINVAL; | 159 | return -EINVAL; |
| 160 | 160 | ||
| 161 | if (cfg->wakeup < 1000000000) | 161 | if (cfg->wakeup < 1000) |
| 162 | return -EINVAL; | 162 | return -EINVAL; |
| 163 | 163 | ||
| 164 | return 0; | 164 | return 0; |
| @@ -1112,14 +1112,4 @@ static int __init phy_core_init(void) · 1111 unmodified lines | |||
| 1112 | 1112 | ||
| 1113 | return 0; | 1113 | return 0; |
| 1114 | } | 1114 | } |
| 1115 | module_init(phy_core_init); | 1115 | device_initcall(phy_core_init); |
| 1116 | |||
| 1117 | static void __exit phy_core_exit(void) | ||
| 1118 | { | ||
| 1119 | class_destroy(phy_class); | ||
| 1120 | } | ||
| 1121 | module_exit(phy_core_exit); | ||
| 1122 | |||
| 1123 | MODULE_DESCRIPTION("Generic PHY Framework"); | ||
| 1124 | MODULE_AUTHOR("Kishon Vijay Abraham I <kishon@ti.com>"); | ||
| 1125 | MODULE_LICENSE("GPL v2"); | ||
| @@ -687,6 +687,116 @@ static const struct qmp_phy_init_tbl sdm845_ufsphy_pcs_tbl[] = { · 686 unmodified lines | |||
| 687 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_MULTI_LANE_CTRL1, 0x02), | 687 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_MULTI_LANE_CTRL1, 0x02), |
| 688 | }; | 688 | }; |
| 689 | 689 | ||
| 690 | static const struct qmp_phy_init_tbl msm8998_usb3_serdes_tbl[] = { | ||
| 691 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_CLK_SELECT, 0x30), | ||
| 692 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_BIAS_EN_CLKBUFLR_EN, 0x04), | ||
| 693 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SYSCLK_EN_SEL, 0x14), | ||
| 694 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SYS_CLK_CTRL, 0x06), | ||
| 695 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_RESETSM_CNTRL2, 0x08), | ||
| 696 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_CMN_CONFIG, 0x06), | ||
| 697 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SVS_MODE_CLK_SEL, 0x01), | ||
| 698 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_HSCLK_SEL, 0x80), | ||
| 699 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_DEC_START_MODE0, 0x82), | ||
| 700 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START1_MODE0, 0xab), | ||
| 701 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START2_MODE0, 0xea), | ||
| 702 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START3_MODE0, 0x02), | ||
| 703 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_CP_CTRL_MODE0, 0x06), | ||
| 704 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_RCTRL_MODE0, 0x16), | ||
| 705 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_CCTRL_MODE0, 0x36), | ||
| 706 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_INTEGLOOP_GAIN1_MODE0, 0x00), | ||
| 707 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_INTEGLOOP_GAIN0_MODE0, 0x3f), | ||
| 708 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE2_MODE0, 0x01), | ||
| 709 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE1_MODE0, 0xc9), | ||
| 710 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_CORECLK_DIV_MODE0, 0x0a), | ||
| 711 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP3_MODE0, 0x00), | ||
| 712 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP2_MODE0, 0x34), | ||
| 713 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP1_MODE0, 0x15), | ||
| 714 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP_EN, 0x04), | ||
| 715 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_CORE_CLK_EN, 0x00), | ||
| 716 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP_CFG, 0x00), | ||
| 717 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE_MAP, 0x00), | ||
| 718 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_BG_TIMER, 0x0a), | ||
| 719 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_IVCO, 0x07), | ||
| 720 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_INTEGLOOP_INITVAL, 0x80), | ||
| 721 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_CMN_MODE, 0x01), | ||
| 722 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_EN_CENTER, 0x01), | ||
| 723 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_PER1, 0x31), | ||
| 724 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_PER2, 0x01), | ||
| 725 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_ADJ_PER1, 0x00), | ||
| 726 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_ADJ_PER2, 0x00), | ||
| 727 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_STEP_SIZE1, 0x85), | ||
| 728 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_STEP_SIZE2, 0x07), | ||
| 729 | }; | ||
| 730 | |||
| 731 | static const struct qmp_phy_init_tbl msm8998_usb3_tx_tbl[] = { | ||
| 732 | QMP_PHY_INIT_CFG(QSERDES_V3_TX_HIGHZ_DRVR_EN, 0x10), | ||
| 733 | QMP_PHY_INIT_CFG(QSERDES_V3_TX_RCV_DETECT_LVL_2, 0x12), | ||
| 734 | QMP_PHY_INIT_CFG(QSERDES_V3_TX_LANE_MODE_1, 0x16), | ||
| 735 | QMP_PHY_INIT_CFG(QSERDES_V3_TX_RES_CODE_LANE_OFFSET_TX, 0x00), | ||
| 736 | }; | ||
| 737 | |||
| 738 | static const struct qmp_phy_init_tbl msm8998_usb3_rx_tbl[] = { | ||
| 739 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_FASTLOCK_FO_GAIN, 0x0b), | ||
| 740 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL2, 0x0f), | ||
| 741 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL3, 0x4e), | ||
| 742 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL4, 0x18), | ||
| 743 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQ_OFFSET_ADAPTOR_CNTRL1, 0x07), | ||
| 744 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_OFFSET_ADAPTOR_CNTRL2, 0x80), | ||
| 745 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_SIGDET_CNTRL, 0x43), | ||
| 746 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_SIGDET_DEGLITCH_CNTRL, 0x1c), | ||
| 747 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_SO_SATURATION_AND_ENABLE, 0x75), | ||
| 748 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_FASTLOCK_COUNT_LOW, 0x00), | ||
| 749 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_FASTLOCK_COUNT_HIGH, 0x00), | ||
| 750 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_PI_CONTROLS, 0x80), | ||
| 751 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_FO_GAIN, 0x0a), | ||
| 752 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_SO_GAIN, 0x06), | ||
| 753 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_SIGDET_ENABLES, 0x00), | ||
| 754 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_VGA_CAL_CNTRL2, 0x03), | ||
| 755 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_MODE_00, 0x05), | ||
| 756 | }; | ||
| 757 | |||
| 758 | static const struct qmp_phy_init_tbl msm8998_usb3_pcs_tbl[] = { | ||
| 759 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_CNTRL2, 0x83), | ||
| 760 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_CNT_VAL_L, 0x09), | ||
| 761 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_CNT_VAL_H_TOL, 0xa2), | ||
| 762 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_MAN_CODE, 0x40), | ||
| 763 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_CNTRL1, 0x02), | ||
| 764 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_LOCK_DETECT_CONFIG1, 0xd1), | ||
| 765 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_LOCK_DETECT_CONFIG2, 0x1f), | ||
| 766 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_LOCK_DETECT_CONFIG3, 0x47), | ||
| 767 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_POWER_STATE_CONFIG2, 0x1b), | ||
| 768 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXMGN_V0, 0x9f), | ||
| 769 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXMGN_V1, 0x9f), | ||
| 770 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXMGN_V2, 0xb7), | ||
| 771 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXMGN_V3, 0x4e), | ||
| 772 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXMGN_V4, 0x65), | ||
| 773 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXMGN_LS, 0x6b), | ||
| 774 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M6DB_V0, 0x15), | ||
| 775 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M3P5DB_V0, 0x0d), | ||
| 776 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TX_LARGE_AMP_DRV_LVL, 0x15), | ||
| 777 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M3P5DB_V1, 0x0d), | ||
| 778 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M6DB_V2, 0x15), | ||
| 779 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M3P5DB_V2, 0x0d), | ||
| 780 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M6DB_V3, 0x15), | ||
| 781 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M3P5DB_V3, 0x0d), | ||
| 782 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M6DB_V4, 0x15), | ||
| 783 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M3P5DB_V4, 0x0d), | ||
| 784 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M6DB_LS, 0x15), | ||
| 785 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M3P5DB_LS, 0x0d), | ||
| 786 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_RATE_SLEW_CNTRL, 0x02), | ||
| 787 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_PWRUP_RESET_DLY_TIME_AUXCLK, 0x04), | ||
| 788 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TSYNC_RSYNC_TIME, 0x44), | ||
| 789 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_RCVR_DTCT_DLY_P1U2_L, 0xe7), | ||
| 790 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_RCVR_DTCT_DLY_P1U2_H, 0x03), | ||
| 791 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_RCVR_DTCT_DLY_U3_L, 0x40), | ||
| 792 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_RCVR_DTCT_DLY_U3_H, 0x00), | ||
| 793 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_RX_SIGDET_LVL, 0x8a), | ||
| 794 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_RXEQTRAINING_WAIT_TIME, 0x75), | ||
| 795 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_LFPS_TX_ECSTART_EQTLOCK, 0x86), | ||
| 796 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_RXEQTRAINING_RUN_TIME, 0x13), | ||
| 797 | }; | ||
| 798 | |||
| 799 | |||
| 690 | /* struct qmp_phy_cfg - per-PHY initialization config */ | 800 | /* struct qmp_phy_cfg - per-PHY initialization config */ |
| 691 | struct qmp_phy_cfg { | 801 | struct qmp_phy_cfg { |
| 692 | /* phy-type - PCIE/UFS/USB */ | 802 | /* phy-type - PCIE/UFS/USB */ |
| @@ -1036,6 +1146,33 @@ static const struct qmp_phy_cfg sdm845_ufsphy_cfg = { · 343 unmodified lines | |||
| 1036 | .no_pcs_sw_reset = true, | 1146 | .no_pcs_sw_reset = true, |
| 1037 | }; | 1147 | }; |
| 1038 | 1148 | ||
| 1149 | static const struct qmp_phy_cfg msm8998_usb3phy_cfg = { | ||
| 1150 | .type = PHY_TYPE_USB3, | ||
| 1151 | .nlanes = 1, | ||
| 1152 | |||
| 1153 | .serdes_tbl = msm8998_usb3_serdes_tbl, | ||
| 1154 | .serdes_tbl_num = ARRAY_SIZE(msm8998_usb3_serdes_tbl), | ||
| 1155 | .tx_tbl = msm8998_usb3_tx_tbl, | ||
| 1156 | .tx_tbl_num = ARRAY_SIZE(msm8998_usb3_tx_tbl), | ||
| 1157 | .rx_tbl = msm8998_usb3_rx_tbl, | ||
| 1158 | .rx_tbl_num = ARRAY_SIZE(msm8998_usb3_rx_tbl), | ||
| 1159 | .pcs_tbl = msm8998_usb3_pcs_tbl, | ||
| 1160 | .pcs_tbl_num = ARRAY_SIZE(msm8998_usb3_pcs_tbl), | ||
| 1161 | .clk_list = msm8996_phy_clk_l, | ||
| 1162 | .num_clks = ARRAY_SIZE(msm8996_phy_clk_l), | ||
| 1163 | .reset_list = msm8996_usb3phy_reset_l, | ||
| 1164 | .num_resets = ARRAY_SIZE(msm8996_usb3phy_reset_l), | ||
| 1165 | .vreg_list = qmp_phy_vreg_l, | ||
| 1166 | .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l), | ||
| 1167 | .regs = qmp_v3_usb3phy_regs_layout, | ||
| 1168 | |||
| 1169 | .start_ctrl = SERDES_START | PCS_START, | ||
| 1170 | .pwrdn_ctrl = SW_PWRDN, | ||
| 1171 | .mask_pcs_ready = PHYSTATUS, | ||
| 1172 | |||
| 1173 | .is_dual_lane_phy = true, | ||
| 1174 | }; | ||
| 1175 | |||
| 1039 | static void qcom_qmp_phy_configure(void __iomem *base, | 1176 | static void qcom_qmp_phy_configure(void __iomem *base, |
| 1040 | const unsigned int *regs, | 1177 | const unsigned int *regs, |
| 1041 | const struct qmp_phy_init_tbl tbl[], | 1178 | const struct qmp_phy_init_tbl tbl[], |
| @@ -1735,6 +1872,9 @@ static const struct of_device_id qcom_qmp_phy_of_match_table[] = { · 693 unmodified lines | |||
| 1735 | }, { | 1872 | }, { |
| 1736 | .compatible = "qcom,msm8996-qmp-usb3-phy", | 1873 | .compatible = "qcom,msm8996-qmp-usb3-phy", |
| 1737 | .data = &msm8996_usb3phy_cfg, | 1874 | .data = &msm8996_usb3phy_cfg, |
| 1875 | }, { | ||
| 1876 | .compatible = "qcom,msm8998-qmp-ufs-phy", | ||
| 1877 | .data = &sdm845_ufsphy_cfg, | ||
| 1738 | }, { | 1878 | }, { |
| 1739 | .compatible = "qcom,ipq8074-qmp-pcie-phy", | 1879 | .compatible = "qcom,ipq8074-qmp-pcie-phy", |
| 1740 | .data = &ipq8074_pciephy_cfg, | 1880 | .data = &ipq8074_pciephy_cfg, |
| @@ -1747,6 +1887,9 @@ static const struct of_device_id qcom_qmp_phy_of_match_table[] = { · 6 unmodified lines | |||
| 1747 | }, { | 1887 | }, { |
| 1748 | .compatible = "qcom,sdm845-qmp-ufs-phy", | 1888 | .compatible = "qcom,sdm845-qmp-ufs-phy", |
| 1749 | .data = &sdm845_ufsphy_cfg, | 1889 | .data = &sdm845_ufsphy_cfg, |
| 1890 | }, { | ||
| 1891 | .compatible = "qcom,msm8998-qmp-usb3-phy", | ||
| 1892 | .data = &msm8998_usb3phy_cfg, | ||
| 1750 | }, | 1893 | }, |
| 1751 | { }, | 1894 | { }, |
| 1752 | }; | 1895 | }; |
| @@ -174,6 +174,7 @@ · 173 unmodified lines | |||
| 174 | #define QSERDES_V3_COM_DIV_FRAC_START1_MODE1 0x0c4 | 174 | #define QSERDES_V3_COM_DIV_FRAC_START1_MODE1 0x0c4 |
| 175 | #define QSERDES_V3_COM_DIV_FRAC_START2_MODE1 0x0c8 | 175 | #define QSERDES_V3_COM_DIV_FRAC_START2_MODE1 0x0c8 |
| 176 | #define QSERDES_V3_COM_DIV_FRAC_START3_MODE1 0x0cc | 176 | #define QSERDES_V3_COM_DIV_FRAC_START3_MODE1 0x0cc |
| 177 | #define QSERDES_V3_COM_INTEGLOOP_INITVAL 0x0d0 | ||
| 177 | #define QSERDES_V3_COM_INTEGLOOP_GAIN0_MODE0 0x0d8 | 178 | #define QSERDES_V3_COM_INTEGLOOP_GAIN0_MODE0 0x0d8 |
| 178 | #define QSERDES_V3_COM_INTEGLOOP_GAIN1_MODE0 0x0dc | 179 | #define QSERDES_V3_COM_INTEGLOOP_GAIN1_MODE0 0x0dc |
| 179 | #define QSERDES_V3_COM_INTEGLOOP_GAIN0_MODE1 0x0e0 | 180 | #define QSERDES_V3_COM_INTEGLOOP_GAIN0_MODE1 0x0e0 |
| @@ -201,6 +202,7 @@ · 21 unmodified lines | |||
| 201 | #define QSERDES_V3_COM_DEBUG_BUS2 0x170 | 202 | #define QSERDES_V3_COM_DEBUG_BUS2 0x170 |
| 202 | #define QSERDES_V3_COM_DEBUG_BUS3 0x174 | 203 | #define QSERDES_V3_COM_DEBUG_BUS3 0x174 |
| 203 | #define QSERDES_V3_COM_DEBUG_BUS_SEL 0x178 | 204 | #define QSERDES_V3_COM_DEBUG_BUS_SEL 0x178 |
| 205 | #define QSERDES_V3_COM_CMN_MODE 0x184 | ||
| 204 | 206 | ||
| 205 | /* Only for QMP V3 PHY - TX registers */ | 207 | /* Only for QMP V3 PHY - TX registers */ |
| 206 | #define QSERDES_V3_TX_RES_CODE_LANE_OFFSET_TX 0x044 | 208 | #define QSERDES_V3_TX_RES_CODE_LANE_OFFSET_TX 0x044 |
| @@ -211,6 +213,7 @@ · 4 unmodified lines | |||
| 211 | #define QSERDES_V3_TX_RCV_DETECT_LVL_2 0x0a4 | 213 | #define QSERDES_V3_TX_RCV_DETECT_LVL_2 0x0a4 |
| 212 | 214 | ||
| 213 | /* Only for QMP V3 PHY - RX registers */ | 215 | /* Only for QMP V3 PHY - RX registers */ |
| 216 | #define QSERDES_V3_RX_UCDR_FO_GAIN 0x008 | ||
| 214 | #define QSERDES_V3_RX_UCDR_SO_GAIN_HALF 0x00c | 217 | #define QSERDES_V3_RX_UCDR_SO_GAIN_HALF 0x00c |
| 215 | #define QSERDES_V3_RX_UCDR_SO_GAIN 0x014 | 218 | #define QSERDES_V3_RX_UCDR_SO_GAIN 0x014 |
| 216 | #define QSERDES_V3_RX_UCDR_SVS_SO_GAIN_HALF 0x024 | 219 | #define QSERDES_V3_RX_UCDR_SVS_SO_GAIN_HALF 0x024 |
| @@ -219,6 +222,7 @@ · 2 unmodified lines | |||
| 219 | #define QSERDES_V3_RX_UCDR_FASTLOCK_FO_GAIN 0x030 | 222 | #define QSERDES_V3_RX_UCDR_FASTLOCK_FO_GAIN 0x030 |
| 220 | #define QSERDES_V3_RX_UCDR_SO_SATURATION_AND_ENABLE 0x034 | 223 | #define QSERDES_V3_RX_UCDR_SO_SATURATION_AND_ENABLE 0x034 |
| 221 | #define QSERDES_V3_RX_UCDR_FASTLOCK_COUNT_LOW 0x03c | 224 | #define QSERDES_V3_RX_UCDR_FASTLOCK_COUNT_LOW 0x03c |
| 225 | #define QSERDES_V3_RX_UCDR_FASTLOCK_COUNT_HIGH 0x040 | ||
| 222 | #define QSERDES_V3_RX_UCDR_PI_CONTROLS 0x044 | 226 | #define QSERDES_V3_RX_UCDR_PI_CONTROLS 0x044 |
| 223 | #define QSERDES_V3_RX_RX_TERM_BW 0x07c | 227 | #define QSERDES_V3_RX_RX_TERM_BW 0x07c |
| 224 | #define QSERDES_V3_RX_VGA_CAL_CNTRL1 0x0bc | 228 | #define QSERDES_V3_RX_VGA_CAL_CNTRL1 0x0bc |
| @@ -152,6 +152,31 @@ static const struct qusb2_phy_init_tbl msm8996_init_tbl[] = { · 151 unmodified lines | |||
| 152 | QUSB2_PHY_INIT_CFG(QUSB2PHY_PLL_PWR_CTRL, 0x00), | 152 | QUSB2_PHY_INIT_CFG(QUSB2PHY_PLL_PWR_CTRL, 0x00), |
| 153 | }; | 153 | }; |
| 154 | 154 | ||
| 155 | static const unsigned int msm8998_regs_layout[] = { | ||
| 156 | [QUSB2PHY_PLL_CORE_INPUT_OVERRIDE] = 0xa8, | ||
| 157 | [QUSB2PHY_PLL_STATUS] = 0x1a0, | ||
| 158 | [QUSB2PHY_PORT_TUNE1] = 0x23c, | ||
| 159 | [QUSB2PHY_PORT_TUNE2] = 0x240, | ||
| 160 | [QUSB2PHY_PORT_TUNE3] = 0x244, | ||
| 161 | [QUSB2PHY_PORT_TUNE4] = 0x248, | ||
| 162 | [QUSB2PHY_PORT_TEST1] = 0x24c, | ||
| 163 | [QUSB2PHY_PORT_TEST2] = 0x250, | ||
| 164 | [QUSB2PHY_PORT_POWERDOWN] = 0x210, | ||
| 165 | [QUSB2PHY_INTR_CTRL] = 0x22c, | ||
| 166 | }; | ||
| 167 | |||
| 168 | static const struct qusb2_phy_init_tbl msm8998_init_tbl[] = { | ||
| 169 | QUSB2_PHY_INIT_CFG(QUSB2PHY_PLL_ANALOG_CONTROLS_TWO, 0x13), | ||
| 170 | QUSB2_PHY_INIT_CFG(QUSB2PHY_PLL_CLOCK_INVERTERS, 0x7c), | ||
| 171 | QUSB2_PHY_INIT_CFG(QUSB2PHY_PLL_CMODE, 0x80), | ||
| 172 | QUSB2_PHY_INIT_CFG(QUSB2PHY_PLL_LOCK_DELAY, 0x0a), | ||
| 173 | |||
| 174 | QUSB2_PHY_INIT_CFG_L(QUSB2PHY_PORT_TUNE1, 0xa5), | ||
| 175 | QUSB2_PHY_INIT_CFG_L(QUSB2PHY_PORT_TUNE2, 0x09), | ||
| 176 | |||
| 177 | QUSB2_PHY_INIT_CFG(QUSB2PHY_PLL_DIGITAL_TIMERS_TWO, 0x19), | ||
| 178 | }; | ||
| 179 | |||
| 155 | static const unsigned int sdm845_regs_layout[] = { | 180 | static const unsigned int sdm845_regs_layout[] = { |
| 156 | [QUSB2PHY_PLL_CORE_INPUT_OVERRIDE] = 0xa8, | 181 | [QUSB2PHY_PLL_CORE_INPUT_OVERRIDE] = 0xa8, |
| 157 | [QUSB2PHY_PLL_STATUS] = 0x1a0, | 182 | [QUSB2PHY_PLL_STATUS] = 0x1a0, |
| @@ -221,6 +246,18 @@ static const struct qusb2_phy_cfg msm8996_phy_cfg = { · 63 unmodified lines | |||
| 221 | .autoresume_en = BIT(3), | 246 | .autoresume_en = BIT(3), |
| 222 | }; | 247 | }; |
| 223 | 248 | ||
| 249 | static const struct qusb2_phy_cfg msm8998_phy_cfg = { | ||
| 250 | .tbl = msm8998_init_tbl, | ||
| 251 | .tbl_num = ARRAY_SIZE(msm8998_init_tbl), | ||
| 252 | .regs = msm8998_regs_layout, | ||
| 253 | |||
| 254 | .disable_ctrl = POWER_DOWN, | ||
| 255 | .mask_core_ready = CORE_READY_STATUS, | ||
| 256 | .has_pll_override = true, | ||
| 257 | .autoresume_en = BIT(0), | ||
| 258 | .update_tune1_with_efuse = true, | ||
| 259 | }; | ||
| 260 | |||
| 224 | static const struct qusb2_phy_cfg sdm845_phy_cfg = { | 261 | static const struct qusb2_phy_cfg sdm845_phy_cfg = { |
| 225 | .tbl = sdm845_init_tbl, | 262 | .tbl = sdm845_init_tbl, |
| 226 | .tbl_num = ARRAY_SIZE(sdm845_init_tbl), | 263 | .tbl_num = ARRAY_SIZE(sdm845_init_tbl), |
| @@ -733,6 +770,9 @@ static const struct of_device_id qusb2_phy_of_match_table[] = { · 506 unmodified lines | |||
| 733 | { | 770 | { |
| 734 | .compatible = "qcom,msm8996-qusb2-phy", | 771 | .compatible = "qcom,msm8996-qusb2-phy", |
| 735 | .data = &msm8996_phy_cfg, | 772 | .data = &msm8996_phy_cfg, |
| 773 | }, { | ||
| 774 | .compatible = "qcom,msm8998-qusb2-phy", | ||
| 775 | .data = &msm8998_phy_cfg, | ||
| 736 | }, { | 776 | }, { |
| 737 | .compatible = "qcom,sdm845-qusb2-phy", | 777 | .compatible = "qcom,sdm845-qusb2-phy", |
| 738 | .data = &sdm845_phy_cfg, | 778 | .data = &sdm845_phy_cfg, |
| @@ -23,24 +23,7 @@ · 22 unmodified lines | |||
| 23 | #include <linux/platform_device.h> | 23 | #include <linux/platform_device.h> |
| 24 | #include <linux/io.h> | 24 | #include <linux/io.h> |
| 25 | #include <linux/delay.h> | 25 | #include <linux/delay.h> |
| 26 | 26 | #include <linux/iopoll.h> | |
| 27 | #define readl_poll_timeout(addr, val, cond, sleep_us, timeout_us) \ | ||
| 28 | ({ \ | ||
| 29 | ktime_t timeout = ktime_add_us(ktime_get(), timeout_us); \ | ||
| 30 | might_sleep_if(timeout_us); \ | ||
| 31 | for (;;) { \ | ||
| 32 | (val) = readl(addr); \ | ||
| 33 | if (cond) \ | ||
| 34 | break; \ | ||
| 35 | if (timeout_us && ktime_compare(ktime_get(), timeout) > 0) { \ | ||
| 36 | (val) = readl(addr); \ | ||
| 37 | break; \ | ||
| 38 | } \ | ||
| 39 | if (sleep_us) \ | ||
| 40 | usleep_range(DIV_ROUND_UP(sleep_us, 4), sleep_us); \ | ||
| 41 | } \ | ||
| 42 | (cond) ? 0 : -ETIMEDOUT; \ | ||
| 43 | }) | ||
| 44 | 27 | ||
| 45 | #define UFS_QCOM_PHY_CAL_ENTRY(reg, val) \ | 28 | #define UFS_QCOM_PHY_CAL_ENTRY(reg, val) \ |
| 46 | { \ | 29 | { \ |
| @@ -55,16 +55,16 @@ enum rockchip_usb2phy_host_state { · 54 unmodified lines | |||
| 55 | }; | 55 | }; |
| 56 | 56 | ||
| 57 | /** | 57 | /** |
| 58 | * Different states involved in USB charger detection. | 58 | * enum usb_chg_state - Different states involved in USB charger detection. |
| 59 | * USB_CHG_STATE_UNDEFINED USB charger is not connected or detection | 59 | * @USB_CHG_STATE_UNDEFINED: USB charger is not connected or detection |
| 60 | * process is not yet started. | 60 | * process is not yet started. |
| 61 | * USB_CHG_STATE_WAIT_FOR_DCD Waiting for Data pins contact. | 61 | * @USB_CHG_STATE_WAIT_FOR_DCD: Waiting for Data pins contact. |
| 62 | * USB_CHG_STATE_DCD_DONE Data pin contact is detected. | 62 | * @USB_CHG_STATE_DCD_DONE: Data pin contact is detected. |
| 63 | * USB_CHG_STATE_PRIMARY_DONE Primary detection is completed (Detects | 63 | * @USB_CHG_STATE_PRIMARY_DONE: Primary detection is completed (Detects |
| 64 | * between SDP and DCP/CDP). | 64 | * between SDP and DCP/CDP). |
| 65 | * USB_CHG_STATE_SECONDARY_DONE Secondary detection is completed (Detects | 65 | * @USB_CHG_STATE_SECONDARY_DONE: Secondary detection is completed (Detects |
| 66 | * between DCP and CDP). | 66 | * between DCP and CDP). |
| 67 | * USB_CHG_STATE_DETECTED USB charger type is determined. | 67 | * @USB_CHG_STATE_DETECTED: USB charger type is determined. |
| 68 | */ | 68 | */ |
| 69 | enum usb_chg_state { | 69 | enum usb_chg_state { |
| 70 | USB_CHG_STATE_UNDEFINED = 0, | 70 | USB_CHG_STATE_UNDEFINED = 0, |
| @@ -94,7 +94,7 @@ struct usb2phy_reg { · 23 unmodified lines | |||
| 94 | }; | 94 | }; |
| 95 | 95 | ||
| 96 | /** | 96 | /** |
| 97 | * struct rockchip_chg_det_reg: usb charger detect registers | 97 | * struct rockchip_chg_det_reg - usb charger detect registers |
| 98 | * @cp_det: charging port detected successfully. | 98 | * @cp_det: charging port detected successfully. |
| 99 | * @dcp_det: dedicated charging port detected successfully. | 99 | * @dcp_det: dedicated charging port detected successfully. |
| 100 | * @dp_det: assert data pin connect successfully. | 100 | * @dp_det: assert data pin connect successfully. |
| @@ -120,7 +120,7 @@ struct rockchip_chg_det_reg { · 19 unmodified lines | |||
| 120 | }; | 120 | }; |
| 121 | 121 | ||
| 122 | /** | 122 | /** |
| 123 | * struct rockchip_usb2phy_port_cfg: usb-phy port configuration. | 123 | * struct rockchip_usb2phy_port_cfg - usb-phy port configuration. |
| 124 | * @phy_sus: phy suspend register. | 124 | * @phy_sus: phy suspend register. |
| 125 | * @bvalid_det_en: vbus valid rise detection enable register. | 125 | * @bvalid_det_en: vbus valid rise detection enable register. |
| 126 | * @bvalid_det_st: vbus valid rise detection status register. | 126 | * @bvalid_det_st: vbus valid rise detection status register. |
| @@ -148,10 +148,11 @@ struct rockchip_usb2phy_port_cfg { · 21 unmodified lines | |||
| 148 | }; | 148 | }; |
| 149 | 149 | ||
| 150 | /** | 150 | /** |
| 151 | * struct rockchip_usb2phy_cfg: usb-phy configuration. | 151 | * struct rockchip_usb2phy_cfg - usb-phy configuration. |
| 152 | * @reg: the address offset of grf for usb-phy config. | 152 | * @reg: the address offset of grf for usb-phy config. |
| 153 | * @num_ports: specify how many ports that the phy has. | 153 | * @num_ports: specify how many ports that the phy has. |
| 154 | * @clkout_ctl: keep on/turn off output clk of phy. | 154 | * @clkout_ctl: keep on/turn off output clk of phy. |
| 155 | * @port_cfgs: usb-phy port configurations. | ||
| 155 | * @chg_det: charger detection registers. | 156 | * @chg_det: charger detection registers. |
| 156 | */ | 157 | */ |
| 157 | struct rockchip_usb2phy_cfg { | 158 | struct rockchip_usb2phy_cfg { |
| @@ -163,12 +164,10 @@ struct rockchip_usb2phy_cfg { · 5 unmodified lines | |||
| 163 | }; | 164 | }; |
| 164 | 165 | ||
| 165 | /** | 166 | /** |
| 166 | * struct rockchip_usb2phy_port: usb-phy port data. | 167 | * struct rockchip_usb2phy_port - usb-phy port data. |
| 168 | * @phy: generic phy. | ||
| 167 | * @port_id: flag for otg port or host port. | 169 | * @port_id: flag for otg port or host port. |
| 168 | * @suspended: phy suspended flag. | 170 | * @suspended: phy suspended flag. |
| 169 | * @utmi_avalid: utmi avalid status usage flag. | ||
| 170 | * true - use avalid to get vbus status | ||
| 171 | * flase - use bvalid to get vbus status | ||
| 172 | * @vbus_attached: otg device vbus status. | 171 | * @vbus_attached: otg device vbus status. |
| 173 | * @bvalid_irq: IRQ number assigned for vbus valid rise detection. | 172 | * @bvalid_irq: IRQ number assigned for vbus valid rise detection. |
| 174 | * @ls_irq: IRQ number assigned for linestate detection. | 173 | * @ls_irq: IRQ number assigned for linestate detection. |
| @@ -178,7 +177,7 @@ struct rockchip_usb2phy_cfg { · 3 unmodified lines | |||
| 178 | * @chg_work: charge detect work. | 177 | * @chg_work: charge detect work. |
| 179 | * @otg_sm_work: OTG state machine work. | 178 | * @otg_sm_work: OTG state machine work. |
| 180 | * @sm_work: HOST state machine work. | 179 | * @sm_work: HOST state machine work. |
| 181 | * @phy_cfg: port register configuration, assigned by driver data. | 180 | * @port_cfg: port register configuration, assigned by driver data. |
| 182 | * @event_nb: hold event notification callback. | 181 | * @event_nb: hold event notification callback. |
| 183 | * @state: define OTG enumeration states before device reset. | 182 | * @state: define OTG enumeration states before device reset. |
| 184 | * @mode: the dr_mode of the controller. | 183 | * @mode: the dr_mode of the controller. |
| @@ -187,7 +186,6 @@ struct rockchip_usb2phy_port { · 2 unmodified lines | |||
| 187 | struct phy *phy; | 186 | struct phy *phy; |
| 188 | unsigned int port_id; | 187 | unsigned int port_id; |
| 189 | bool suspended; | 188 | bool suspended; |
| 190 | bool utmi_avalid; | ||
| 191 | bool vbus_attached; | 189 | bool vbus_attached; |
| 192 | int bvalid_irq; | 190 | int bvalid_irq; |
| 193 | int ls_irq; | 191 | int ls_irq; |
| @@ -203,12 +201,13 @@ struct rockchip_usb2phy_port { · 9 unmodified lines | |||
| 203 | }; | 201 | }; |
| 204 | 202 | ||
| 205 | /** | 203 | /** |
| 206 | * struct rockchip_usb2phy: usb2.0 phy driver data. | 204 | * struct rockchip_usb2phy - usb2.0 phy driver data. |
| 205 | * @dev: pointer to device. | ||
| 207 | * @grf: General Register Files regmap. | 206 | * @grf: General Register Files regmap. |
| 208 | * @usbgrf: USB General Register Files regmap. | 207 | * @usbgrf: USB General Register Files regmap. |
| 209 | * @clk: clock struct of phy input clk. | 208 | * @clk: clock struct of phy input clk. |
| 210 | * @clk480m: clock struct of phy output clk. | 209 | * @clk480m: clock struct of phy output clk. |
| 211 | * @clk_hw: clock struct of phy output clk management. | 210 | * @clk480m_hw: clock struct of phy output clk management. |
| 212 | * @chg_state: states involved in USB charger detection. | 211 | * @chg_state: states involved in USB charger detection. |
| 213 | * @chg_type: USB charger types. | 212 | * @chg_type: USB charger types. |
| 214 | * @dcd_retries: The retry count used to track Data contact | 213 | * @dcd_retries: The retry count used to track Data contact |
| @@ -542,12 +541,8 @@ static void rockchip_usb2phy_otg_sm_work(struct work_struct *work) · 327 unmodified lines | |||
| 542 | unsigned long delay; | 541 | unsigned long delay; |
| 543 | bool vbus_attach, sch_work, notify_charger; | 542 | bool vbus_attach, sch_work, notify_charger; |
| 544 | 543 | ||
| 545 | if (rport->utmi_avalid) | 544 | vbus_attach = property_enabled(rphy->grf, |
| 546 | vbus_attach = property_enabled(rphy->grf, | 545 | &rport->port_cfg->utmi_bvalid); |
| 547 | &rport->port_cfg->utmi_avalid); | ||
| 548 | else | ||
| 549 | vbus_attach = property_enabled(rphy->grf, | ||
| 550 | &rport->port_cfg->utmi_bvalid); | ||
| 551 | 546 | ||
| 552 | sch_work = false; | 547 | sch_work = false; |
| 553 | notify_charger = false; | 548 | notify_charger = false; |
| @@ -1021,9 +1016,6 @@ static int rockchip_usb2phy_otg_port_init(struct rockchip_usb2phy *rphy, · 467 unmodified lines | |||
| 1021 | INIT_DELAYED_WORK(&rport->chg_work, rockchip_chg_detect_work); | 1016 | INIT_DELAYED_WORK(&rport->chg_work, rockchip_chg_detect_work); |
| 1022 | INIT_DELAYED_WORK(&rport->otg_sm_work, rockchip_usb2phy_otg_sm_work); | 1017 | INIT_DELAYED_WORK(&rport->otg_sm_work, rockchip_usb2phy_otg_sm_work); |
| 1023 | 1018 | ||
| 1024 | rport->utmi_avalid = | ||
| 1025 | of_property_read_bool(child_np, "rockchip,utmi-avalid"); | ||
| 1026 | |||
| 1027 | /* | 1019 | /* |
| 1028 | * Some SoCs use one interrupt with otg-id/otg-bvalid/linestate | 1020 | * Some SoCs use one interrupt with otg-id/otg-bvalid/linestate |
| 1029 | * interrupts muxed together, so probe the otg-mux interrupt first, | 1021 | * interrupts muxed together, so probe the otg-mux interrupt first, |
| @@ -33,12 +33,11 @@ config OMAP_CONTROL_PHY · 32 unmodified lines | |||
| 33 | 33 | ||
| 34 | config OMAP_USB2 | 34 | config OMAP_USB2 |
| 35 | tristate "OMAP USB2 PHY Driver" | 35 | tristate "OMAP USB2 PHY Driver" |
| 36 | depends on ARCH_OMAP2PLUS | 36 | depends on ARCH_OMAP2PLUS || ARCH_K3 |
| 37 | depends on USB_SUPPORT | 37 | depends on USB_SUPPORT |
| 38 | select GENERIC_PHY | 38 | select GENERIC_PHY |
| 39 | select USB_PHY | 39 | select USB_PHY |
| 40 | select OMAP_CONTROL_PHY | 40 | select OMAP_CONTROL_PHY if ARCH_OMAP2PLUS |
| 41 | depends on OMAP_OCP2SCP | ||
| 42 | help | 41 | help |
| 43 | Enable this to support the transceiver that is part of SOC. This | 42 | Enable this to support the transceiver that is part of SOC. This |
| 44 | driver takes care of all the PHY functionality apart from comparator. | 43 | driver takes care of all the PHY functionality apart from comparator. |
| @@ -50,7 +49,6 @@ config TI_PIPE3 · 5 unmodified lines | |||
| 50 | depends on ARCH_OMAP2PLUS || COMPILE_TEST | 49 | depends on ARCH_OMAP2PLUS || COMPILE_TEST |
| 51 | select GENERIC_PHY | 50 | select GENERIC_PHY |
| 52 | select OMAP_CONTROL_PHY | 51 | select OMAP_CONTROL_PHY |
| 53 | depends on OMAP_OCP2SCP | ||
| 54 | help | 52 | help |
| 55 | Enable this to support the PIPE3 PHY that is part of TI SOCs. This | 53 | Enable this to support the PIPE3 PHY that is part of TI SOCs. This |
| 56 | driver takes care of all the PHY functionality apart from comparator. | 54 | driver takes care of all the PHY functionality apart from comparator. |
| @@ -36,6 +36,10 @@ · 35 unmodified lines | |||
| 36 | #define USB2PHY_DISCON_BYP_LATCH (1 << 31) | 36 | #define USB2PHY_DISCON_BYP_LATCH (1 << 31) |
| 37 | #define USB2PHY_ANA_CONFIG1 0x4c | 37 | #define USB2PHY_ANA_CONFIG1 0x4c |
| 38 | 38 | ||
| 39 | #define AM654_USB2_OTG_PD BIT(8) | ||
| 40 | #define AM654_USB2_VBUS_DET_EN BIT(5) | ||
| 41 | #define AM654_USB2_VBUSVALID_DET_EN BIT(4) | ||
| 42 | |||
| 39 | /** | 43 | /** |
| 40 | * omap_usb2_set_comparator - links the comparator present in the sytem with | 44 | * omap_usb2_set_comparator - links the comparator present in the sytem with |
| 41 | * this phy | 45 | * this phy |
| @@ -135,9 +139,9 @@ static int omap_usb_power_on(struct phy *x) · 93 unmodified lines | |||
| 135 | 139 | ||
| 136 | static int omap_usb2_disable_clocks(struct omap_usb *phy) | 140 | static int omap_usb2_disable_clocks(struct omap_usb *phy) |
| 137 | { | 141 | { |
| 138 | clk_disable(phy->wkupclk); | 142 | clk_disable_unprepare(phy->wkupclk); |
| 139 | if (!IS_ERR(phy->optclk)) | 143 | if (!IS_ERR(phy->optclk)) |
| 140 | clk_disable(phy->optclk); | 144 | clk_disable_unprepare(phy->optclk); |
| 141 | 145 | ||
| 142 | return 0; | 146 | return 0; |
| 143 | } | 147 | } |
| @@ -146,14 +150,14 @@ static int omap_usb2_enable_clocks(struct omap_usb *phy) · 2 unmodified lines | |||
| 146 | { | 150 | { |
| 147 | int ret; | 151 | int ret; |
| 148 | 152 | ||
| 149 | ret = clk_enable(phy->wkupclk); | 153 | ret = clk_prepare_enable(phy->wkupclk); |
| 150 | if (ret < 0) { | 154 | if (ret < 0) { |
| 151 | dev_err(phy->dev, "Failed to enable wkupclk %d\n", ret); | 155 | dev_err(phy->dev, "Failed to enable wkupclk %d\n", ret); |
| 152 | goto err0; | 156 | goto err0; |
| 153 | } | 157 | } |
| 154 | 158 | ||
| 155 | if (!IS_ERR(phy->optclk)) { | 159 | if (!IS_ERR(phy->optclk)) { |
| 156 | ret = clk_enable(phy->optclk); | 160 | ret = clk_prepare_enable(phy->optclk); |
| 157 | if (ret < 0) { | 161 | if (ret < 0) { |
| 158 | dev_err(phy->dev, "Failed to enable optclk %d\n", ret); | 162 | dev_err(phy->dev, "Failed to enable optclk %d\n", ret); |
| 159 | goto err1; | 163 | goto err1; |
| @@ -245,6 +249,15 @@ static const struct usb_phy_data am437x_usb2_data = { · 85 unmodified lines | |||
| 245 | .power_off = AM437X_USB2_PHY_PD | AM437X_USB2_OTG_PD, | 249 | .power_off = AM437X_USB2_PHY_PD | AM437X_USB2_OTG_PD, |
| 246 | }; | 250 | }; |
| 247 | 251 | ||
| 252 | static const struct usb_phy_data am654_usb2_data = { | ||
| 253 | .label = "am654_usb2", | ||
| 254 | .flags = OMAP_USB2_CALIBRATE_FALSE_DISCONNECT, | ||
| 255 | .mask = AM654_USB2_OTG_PD | AM654_USB2_VBUS_DET_EN | | ||
| 256 | AM654_USB2_VBUSVALID_DET_EN, | ||
| 257 | .power_on = AM654_USB2_VBUS_DET_EN | AM654_USB2_VBUSVALID_DET_EN, | ||
| 258 | .power_off = AM654_USB2_OTG_PD, | ||
| 259 | }; | ||
| 260 | |||
| 248 | static const struct of_device_id omap_usb2_id_table[] = { | 261 | static const struct of_device_id omap_usb2_id_table[] = { |
| 249 | { | 262 | { |
| 250 | .compatible = "ti,omap-usb2", | 263 | .compatible = "ti,omap-usb2", |
| @@ -266,6 +279,10 @@ static const struct of_device_id omap_usb2_id_table[] = { · 15 unmodified lines | |||
| 266 | .compatible = "ti,am437x-usb2", | 279 | .compatible = "ti,am437x-usb2", |
| 267 | .data = &am437x_usb2_data, | 280 | .data = &am437x_usb2_data, |
| 268 | }, | 281 | }, |
| 282 | { | ||
| 283 | .compatible = "ti,am654-usb2", | ||
| 284 | .data = &am654_usb2_data, | ||
| 285 | }, | ||
| 269 | {}, | 286 | {}, |
| 270 | }; | 287 | }; |
| 271 | MODULE_DEVICE_TABLE(of, omap_usb2_id_table); | 288 | MODULE_DEVICE_TABLE(of, omap_usb2_id_table); |
| @@ -346,63 +363,72 @@ static int omap_usb2_probe(struct platform_device *pdev) · 74 unmodified lines | |||
| 346 | } | 363 | } |
| 347 | } | 364 | } |
| 348 | 365 | ||
| 349 | otg->set_host = omap_usb_set_host; | ||
| 350 | otg->set_peripheral = omap_usb_set_peripheral; | ||
| 351 | if (phy_data->flags & OMAP_USB2_HAS_SET_VBUS) | ||
| 352 | otg->set_vbus = omap_usb_set_vbus; | ||
| 353 | if (phy_data->flags & OMAP_USB2_HAS_START_SRP) | ||
| 354 | otg->start_srp = omap_usb_start_srp; | ||
| 355 | otg->usb_phy = &phy->phy; | ||
| 356 | |||
| 357 | platform_set_drvdata(pdev, phy); | ||
| 358 | pm_runtime_enable(phy->dev); | ||
| 359 | |||
| 360 | generic_phy = devm_phy_create(phy->dev, NULL, &ops); | ||
| 361 | if (IS_ERR(generic_phy)) { | ||
| 362 | pm_runtime_disable(phy->dev); | ||
| 363 | return PTR_ERR(generic_phy); | ||
| 364 | } | ||
| 365 | |||
| 366 | phy_set_drvdata(generic_phy, phy); | ||
| 367 | omap_usb_power_off(generic_phy); | ||
| 368 | |||
| 369 | phy_provider = devm_of_phy_provider_register(phy->dev, | ||
| 370 | of_phy_simple_xlate); | ||
| 371 | if (IS_ERR(phy_provider)) { | ||
| 372 | pm_runtime_disable(phy->dev); | ||
| 373 | return PTR_ERR(phy_provider); | ||
| 374 | } | ||
| 375 | 366 | ||
| 376 | phy->wkupclk = devm_clk_get(phy->dev, "wkupclk"); | 367 | phy->wkupclk = devm_clk_get(phy->dev, "wkupclk"); |
| 377 | if (IS_ERR(phy->wkupclk)) { | 368 | if (IS_ERR(phy->wkupclk)) { |
| 378 | dev_warn(&pdev->dev, "unable to get wkupclk, trying old name\n"); | 369 | if (PTR_ERR(phy->wkupclk) == -EPROBE_DEFER) |
| 370 | return -EPROBE_DEFER; | ||
| 371 | |||
| 372 | dev_warn(&pdev->dev, "unable to get wkupclk %ld, trying old name\n", | ||
| 373 | PTR_ERR(phy->wkupclk)); | ||
| 379 | phy->wkupclk = devm_clk_get(phy->dev, "usb_phy_cm_clk32k"); | 374 | phy->wkupclk = devm_clk_get(phy->dev, "usb_phy_cm_clk32k"); |
| 375 | |||
| 380 | if (IS_ERR(phy->wkupclk)) { | 376 | if (IS_ERR(phy->wkupclk)) { |
| 381 | dev_err(&pdev->dev, "unable to get usb_phy_cm_clk32k\n"); | 377 | if (PTR_ERR(phy->wkupclk) != -EPROBE_DEFER) |
| 382 | pm_runtime_disable(phy->dev); | 378 | dev_err(&pdev->dev, "unable to get usb_phy_cm_clk32k\n"); |
| 383 | return PTR_ERR(phy->wkupclk); | 379 | return PTR_ERR(phy->wkupclk); |
| 384 | } else { | 380 | } else { |
| 385 | dev_warn(&pdev->dev, | 381 | dev_warn(&pdev->dev, |
| 386 | "found usb_phy_cm_clk32k, please fix DTS\n"); | 382 | "found usb_phy_cm_clk32k, please fix DTS\n"); |
| 387 | } | 383 | } |
| 388 | } | 384 | } |
| 389 | clk_prepare(phy->wkupclk); | ||
| 390 | 385 | ||
| 391 | phy->optclk = devm_clk_get(phy->dev, "refclk"); | 386 | phy->optclk = devm_clk_get(phy->dev, "refclk"); |
| 392 | if (IS_ERR(phy->optclk)) { | 387 | if (IS_ERR(phy->optclk)) { |
| 388 | if (PTR_ERR(phy->optclk) == -EPROBE_DEFER) | ||
| 389 | return -EPROBE_DEFER; | ||
| 390 | |||
| 393 | dev_dbg(&pdev->dev, "unable to get refclk, trying old name\n"); | 391 | dev_dbg(&pdev->dev, "unable to get refclk, trying old name\n"); |
| 394 | phy->optclk = devm_clk_get(phy->dev, "usb_otg_ss_refclk960m"); | 392 | phy->optclk = devm_clk_get(phy->dev, "usb_otg_ss_refclk960m"); |
| 393 | |||
| 395 | if (IS_ERR(phy->optclk)) { | 394 | if (IS_ERR(phy->optclk)) { |
| 396 | dev_dbg(&pdev->dev, | 395 | if (PTR_ERR(phy->optclk) != -EPROBE_DEFER) { |
| 397 | "unable to get usb_otg_ss_refclk960m\n"); | 396 | dev_dbg(&pdev->dev, |
| 397 | "unable to get usb_otg_ss_refclk960m\n"); | ||
| 398 | } | ||
| 398 | } else { | 399 | } else { |
| 399 | dev_warn(&pdev->dev, | 400 | dev_warn(&pdev->dev, |
| 400 | "found usb_otg_ss_refclk960m, please fix DTS\n"); | 401 | "found usb_otg_ss_refclk960m, please fix DTS\n"); |
| 401 | } | 402 | } |
| 402 | } | 403 | } |
| 403 | 404 | ||
| 404 | if (!IS_ERR(phy->optclk)) | 405 | otg->set_host = omap_usb_set_host; |
| 405 | clk_prepare(phy->optclk); | 406 | otg->set_peripheral = omap_usb_set_peripheral; |
| 407 | if (phy_data->flags & OMAP_USB2_HAS_SET_VBUS) | ||
| 408 | otg->set_vbus = omap_usb_set_vbus; | ||
| 409 | if (phy_data->flags & OMAP_USB2_HAS_START_SRP) | ||
| 410 | otg->start_srp = omap_usb_start_srp; | ||
| 411 | otg->usb_phy = &phy->phy; | ||
| 412 | |||
| 413 | platform_set_drvdata(pdev, phy); | ||
| 414 | pm_runtime_enable(phy->dev); | ||
| 415 | |||
| 416 | generic_phy = devm_phy_create(phy->dev, NULL, &ops); | ||
| 417 | if (IS_ERR(generic_phy)) { | ||
| 418 | pm_runtime_disable(phy->dev); | ||
| 419 | return PTR_ERR(generic_phy); | ||
| 420 | } | ||
| 421 | |||
| 422 | phy_set_drvdata(generic_phy, phy); | ||
| 423 | omap_usb_power_off(generic_phy); | ||
| 424 | |||
| 425 | phy_provider = devm_of_phy_provider_register(phy->dev, | ||
| 426 | of_phy_simple_xlate); | ||
| 427 | if (IS_ERR(phy_provider)) { | ||
| 428 | pm_runtime_disable(phy->dev); | ||
| 429 | return PTR_ERR(phy_provider); | ||
| 430 | } | ||
| 431 | |||
| 406 | 432 | ||
| 407 | usb_add_phy_dev(&phy->phy); | 433 | usb_add_phy_dev(&phy->phy); |
| 408 | 434 | ||
| @@ -413,9 +439,6 @@ static int omap_usb2_remove(struct platform_device *pdev) · 4 unmodified lines | |||
| 413 | { | 439 | { |
| 414 | struct omap_usb *phy = platform_get_drvdata(pdev); | 440 | struct omap_usb *phy = platform_get_drvdata(pdev); |
| 415 | 441 | ||
| 416 | clk_unprepare(phy->wkupclk); | ||
| 417 | if (!IS_ERR(phy->optclk)) | ||
| 418 | clk_unprepare(phy->optclk); | ||
| 419 | usb_remove_phy(&phy->phy); | 442 | usb_remove_phy(&phy->phy); |
| 420 | pm_runtime_disable(phy->dev); | 443 | pm_runtime_disable(phy->dev); |
| 421 | 444 | ||
| @@ -32,7 +32,7 @@ struct cht_int33fe_data { · 31 unmodified lines | |||
| 32 | struct i2c_client *fusb302; | 32 | struct i2c_client *fusb302; |
| 33 | struct i2c_client *pi3usb30532; | 33 | struct i2c_client *pi3usb30532; |
| 34 | /* Contain a list-head must be per device */ | 34 | /* Contain a list-head must be per device */ |
| 35 | struct device_connection connections[5]; | 35 | struct device_connection connections[4]; |
| 36 | }; | 36 | }; |
| 37 | 37 | ||
| 38 | /* | 38 | /* |
| @@ -174,16 +174,13 @@ static int cht_int33fe_probe(struct platform_device *pdev) · 135 unmodified lines | |||
| 174 | 174 | ||
| 175 | data->connections[0].endpoint[0] = "port0"; | 175 | data->connections[0].endpoint[0] = "port0"; |
| 176 | data->connections[0].endpoint[1] = "i2c-pi3usb30532"; | 176 | data->connections[0].endpoint[1] = "i2c-pi3usb30532"; |
| 177 | data->connections[0].id = "typec-switch"; | 177 | data->connections[0].id = "orientation-switch"; |
| 178 | data->connections[1].endpoint[0] = "port0"; | 178 | data->connections[1].endpoint[0] = "port0"; |
| 179 | data->connections[1].endpoint[1] = "i2c-pi3usb30532"; | 179 | data->connections[1].endpoint[1] = "i2c-pi3usb30532"; |
| 180 | data->connections[1].id = "typec-mux"; | 180 | data->connections[1].id = "mode-switch"; |
| 181 | data->connections[2].endpoint[0] = "port0"; | 181 | data->connections[2].endpoint[0] = "i2c-fusb302"; |
| 182 | data->connections[2].endpoint[1] = "i2c-pi3usb30532"; | 182 | data->connections[2].endpoint[1] = "intel_xhci_usb_sw-role-switch"; |
| 183 | data->connections[2].id = "idff01m01"; | 183 | data->connections[2].id = "usb-role-switch"; |
| 184 | data->connections[3].endpoint[0] = "i2c-fusb302"; | ||
| 185 | data->connections[3].endpoint[1] = "intel_xhci_usb_sw-role-switch"; | ||
| 186 | data->connections[3].id = "usb-role-switch"; | ||
| 187 | 184 | ||
| 188 | device_connections_add(data->connections); | 185 | device_connections_add(data->connections); |
| 189 | 186 | ||
| @@ -1,3 +1,4 @@ | |||
| 1 | # SPDX-License-Identifier: GPL-2.0 | ||
| 1 | # | 2 | # |
| 2 | # USB device configuration | 3 | # USB device configuration |
| 3 | # | 4 | # |
| @@ -1,54 +0,0 @@ | |||
| 1 | To understand all the Linux-USB framework, you'll use these resources: | ||
| 2 | |||
| 3 | * This source code. This is necessarily an evolving work, and | ||
| 4 | includes kerneldoc that should help you get a current overview. | ||
| 5 | ("make pdfdocs", and then look at "usb.pdf" for host side and | ||
| 6 | "gadget.pdf" for peripheral side.) Also, Documentation/usb has | ||
| 7 | more information. | ||
| 8 | |||
| 9 | * The USB 2.0 specification (from www.usb.org), with supplements | ||
| 10 | such as those for USB OTG and the various device classes. | ||
| 11 | The USB specification has a good overview chapter, and USB | ||
| 12 | peripherals conform to the widely known "Chapter 9". | ||
| 13 | |||
| 14 | * Chip specifications for USB controllers. Examples include | ||
| 15 | host controllers (on PCs, servers, and more); peripheral | ||
| 16 | controllers (in devices with Linux firmware, like printers or | ||
| 17 | cell phones); and hard-wired peripherals like Ethernet adapters. | ||
| 18 | |||
| 19 | * Specifications for other protocols implemented by USB peripheral | ||
| 20 | functions. Some are vendor-specific; others are vendor-neutral | ||
| 21 | but just standardized outside of the www.usb.org team. | ||
| 22 | |||
| 23 | Here is a list of what each subdirectory here is, and what is contained in | ||
| 24 | them. | ||
| 25 | |||
| 26 | core/ - This is for the core USB host code, including the | ||
| 27 | usbfs files and the hub class driver ("hub_wq"). | ||
| 28 | |||
| 29 | host/ - This is for USB host controller drivers. This | ||
| 30 | includes UHCI, OHCI, EHCI, and others that might | ||
| 31 | be used with more specialized "embedded" systems. | ||
| 32 | |||
| 33 | gadget/ - This is for USB peripheral controller drivers and | ||
| 34 | the various gadget drivers which talk to them. | ||
| 35 | |||
| 36 | |||
| 37 | Individual USB driver directories. A new driver should be added to the | ||
| 38 | first subdirectory in the list below that it fits into. | ||
| 39 | |||
| 40 | image/ - This is for still image drivers, like scanners or | ||
| 41 | digital cameras. | ||
| 42 | ../input/ - This is for any driver that uses the input subsystem, | ||
| 43 | like keyboard, mice, touchscreens, tablets, etc. | ||
| 44 | ../media/ - This is for multimedia drivers, like video cameras, | ||
| 45 | radios, and any other drivers that talk to the v4l | ||
| 46 | subsystem. | ||
| 47 | ../net/ - This is for network drivers. | ||
| 48 | serial/ - This is for USB to serial drivers. | ||
| 49 | storage/ - This is for USB mass-storage drivers. | ||
| 50 | class/ - This is for all USB device drivers that do not fit | ||
| 51 | into any of the above categories, and work for a range | ||
| 52 | of USB Class specified devices. | ||
| 53 | misc/ - This is for all USB device drivers that do not fit | ||
| 54 | into any of the above categories. | ||
| @@ -1,3 +1,4 @@ | |||
| 1 | # SPDX-License-Identifier: GPL-2.0 | ||
| 1 | # | 2 | # |
| 2 | # USB/ATM DSL configuration | 3 | # USB/ATM DSL configuration |
| 3 | # | 4 | # |
| @@ -1,3 +1,5 @@ | |||
| 1 | # SPDX-License-Identifier: GPL-2.0 | ||
| 2 | |||
| 1 | config USB_CHIPIDEA | 3 | config USB_CHIPIDEA |
| 2 | tristate "ChipIdea Highspeed Dual Role Controller" | 4 | tristate "ChipIdea Highspeed Dual Role Controller" |
| 3 | depends on ((USB_EHCI_HCD && USB_GADGET) || (USB_EHCI_HCD && !USB_GADGET) || (!USB_EHCI_HCD && USB_GADGET)) && HAS_DMA | 5 | depends on ((USB_EHCI_HCD && USB_GADGET) || (USB_EHCI_HCD && !USB_GADGET) || (!USB_EHCI_HCD && USB_GADGET)) && HAS_DMA |
| @@ -7,10 +7,8 @@ · 6 unmodified lines | |||
| 7 | 7 | ||
| 8 | #include <linux/module.h> | 8 | #include <linux/module.h> |
| 9 | #include <linux/of_platform.h> | 9 | #include <linux/of_platform.h> |
| 10 | #include <linux/of_gpio.h> | ||
| 11 | #include <linux/platform_device.h> | 10 | #include <linux/platform_device.h> |
| 12 | #include <linux/pm_runtime.h> | 11 | #include <linux/pm_runtime.h> |
| 13 | #include <linux/dma-mapping.h> | ||
| 14 | #include <linux/usb/chipidea.h> | 12 | #include <linux/usb/chipidea.h> |
| 15 | #include <linux/usb/of.h> | 13 | #include <linux/usb/of.h> |
| 16 | #include <linux/clk.h> | 14 | #include <linux/clk.h> |
| @@ -152,8 +150,8 @@ static struct imx_usbmisc_data *usbmisc_get_init_data(struct device *dev) · 135 unmodified lines | |||
| 152 | dev_warn(dev, "No over current polarity defined\n"); | 150 | dev_warn(dev, "No over current polarity defined\n"); |
| 153 | } | 151 | } |
| 154 | 152 | ||
| 155 | if (of_find_property(np, "external-vbus-divider", NULL)) | 153 | data->pwr_pol = of_property_read_bool(np, "power-active-high"); |
| 156 | data->evdo = 1; | 154 | data->evdo = of_property_read_bool(np, "external-vbus-divider"); |
| 157 | 155 | ||
| 158 | if (of_usb_get_phy_mode(np) == USBPHY_INTERFACE_MODE_ULPI) | 156 | if (of_usb_get_phy_mode(np) == USBPHY_INTERFACE_MODE_ULPI) |
| 159 | data->ulpi = 1; | 157 | data->ulpi = 1; |
| @@ -18,6 +18,7 @@ struct imx_usbmisc_data { · 17 unmodified lines | |||
| 18 | /* true if dt specifies polarity */ | 18 | /* true if dt specifies polarity */ |
| 19 | unsigned int oc_pol_configured:1; | 19 | unsigned int oc_pol_configured:1; |
| 20 | 20 | ||
| 21 | unsigned int pwr_pol:1; /* power polarity */ | ||
| 21 | unsigned int evdo:1; /* set external vbus divider option */ | 22 | unsigned int evdo:1; /* set external vbus divider option */ |
| 22 | unsigned int ulpi:1; /* connected to an ULPI phy */ | 23 | unsigned int ulpi:1; /* connected to an ULPI phy */ |
| 23 | unsigned int hsic:1; /* HSIC controlller */ | 24 | unsigned int hsic:1; /* HSIC controlller */ |
| @@ -130,6 +130,7 @@ static int tegra_udc_remove(struct platform_device *pdev) · 129 unmodified lines | |||
| 130 | { | 130 | { |
| 131 | struct tegra_udc *udc = platform_get_drvdata(pdev); | 131 | struct tegra_udc *udc = platform_get_drvdata(pdev); |
| 132 | 132 | ||
| 133 | ci_hdrc_remove_device(udc->dev); | ||
| 133 | usb_phy_set_suspend(udc->phy, 1); | 134 | usb_phy_set_suspend(udc->phy, 1); |
| 134 | clk_disable_unprepare(udc->clk); | 135 | clk_disable_unprepare(udc->clk); |
| 135 | 136 | ||
| @@ -954,25 +954,47 @@ static int ci_hdrc_probe(struct platform_device *pdev) · 953 unmodified lines | |||
| 954 | } else if (ci->platdata->usb_phy) { | 954 | } else if (ci->platdata->usb_phy) { |
| 955 | ci->usb_phy = ci->platdata->usb_phy; | 955 | ci->usb_phy = ci->platdata->usb_phy; |
| 956 | } else { | 956 | } else { |
| 957 | /* Look for a generic PHY first */ | ||
| 957 | ci->phy = devm_phy_get(dev->parent, "usb-phy"); | 958 | ci->phy = devm_phy_get(dev->parent, "usb-phy"); |
| 958 | ci->usb_phy = devm_usb_get_phy(dev->parent, USB_PHY_TYPE_USB2); | ||
| 959 | 959 | ||
| 960 | /* if both generic PHY and USB PHY layers aren't enabled */ | 960 | if (PTR_ERR(ci->phy) == -EPROBE_DEFER) { |
| 961 | if (PTR_ERR(ci->phy) == -ENOSYS && | 961 | ret = -EPROBE_DEFER; |
| 962 | PTR_ERR(ci->usb_phy) == -ENXIO) { | ||
| 963 | ret = -ENXIO; | ||
| 964 | goto ulpi_exit; | 962 | goto ulpi_exit; |
| 963 | } else if (IS_ERR(ci->phy)) { | ||
| 964 | ci->phy = NULL; | ||
| 965 | } | 965 | } |
| 966 | 966 | ||
| 967 | if (IS_ERR(ci->phy) && IS_ERR(ci->usb_phy)) { | 967 | /* Look for a legacy USB PHY from device-tree next */ |
| 968 | ret = -EPROBE_DEFER; | 968 | if (!ci->phy) { |
| 969 | goto ulpi_exit; | 969 | ci->usb_phy = devm_usb_get_phy_by_phandle(dev->parent, |
| 970 | "phys", 0); | ||
| 971 | |||
| 972 | if (PTR_ERR(ci->usb_phy) == -EPROBE_DEFER) { | ||
| 973 | ret = -EPROBE_DEFER; | ||
| 974 | goto ulpi_exit; | ||
| 975 | } else if (IS_ERR(ci->usb_phy)) { | ||
| 976 | ci->usb_phy = NULL; | ||
| 977 | } | ||
| 970 | } | 978 | } |
| 971 | 979 | ||
| 972 | if (IS_ERR(ci->phy)) | 980 | /* Look for any registered legacy USB PHY as last resort */ |
| 973 | ci->phy = NULL; | 981 | if (!ci->phy && !ci->usb_phy) { |
| 974 | else if (IS_ERR(ci->usb_phy)) | 982 | ci->usb_phy = devm_usb_get_phy(dev->parent, |
| 975 | ci->usb_phy = NULL; | 983 | USB_PHY_TYPE_USB2); |
| 984 | |||
| 985 | if (PTR_ERR(ci->usb_phy) == -EPROBE_DEFER) { | ||
| 986 | ret = -EPROBE_DEFER; | ||
| 987 | goto ulpi_exit; | ||
| 988 | } else if (IS_ERR(ci->usb_phy)) { | ||
| 989 | ci->usb_phy = NULL; | ||
| 990 | } | ||
| 991 | } | ||
| 992 | |||
| 993 | /* No USB PHY was found in the end */ | ||
| 994 | if (!ci->phy && !ci->usb_phy) { | ||
| 995 | ret = -ENXIO; | ||
| 996 | goto ulpi_exit; | ||
| 997 | } | ||
| 976 | } | 998 | } |
| 977 | 999 | ||
| 978 | ret = ci_usb_phy_init(ci); | 1000 | ret = ci_usb_phy_init(ci); |
| @@ -63,6 +63,7 @@ · 62 unmodified lines | |||
| 63 | #define MX6_BM_NON_BURST_SETTING BIT(1) | 63 | #define MX6_BM_NON_BURST_SETTING BIT(1) |
| 64 | #define MX6_BM_OVER_CUR_DIS BIT(7) | 64 | #define MX6_BM_OVER_CUR_DIS BIT(7) |
| 65 | #define MX6_BM_OVER_CUR_POLARITY BIT(8) | 65 | #define MX6_BM_OVER_CUR_POLARITY BIT(8) |
| 66 | #define MX6_BM_PWR_POLARITY BIT(9) | ||
| 66 | #define MX6_BM_WAKEUP_ENABLE BIT(10) | 67 | #define MX6_BM_WAKEUP_ENABLE BIT(10) |
| 67 | #define MX6_BM_UTMI_ON_CLOCK BIT(13) | 68 | #define MX6_BM_UTMI_ON_CLOCK BIT(13) |
| 68 | #define MX6_BM_ID_WAKEUP BIT(16) | 69 | #define MX6_BM_ID_WAKEUP BIT(16) |
| @@ -383,6 +384,9 @@ static int usbmisc_imx6q_init(struct imx_usbmisc_data *data) · 314 unmodified lines | |||
| 383 | else if (data->oc_pol_configured) | 384 | else if (data->oc_pol_configured) |
| 384 | reg &= ~MX6_BM_OVER_CUR_POLARITY; | 385 | reg &= ~MX6_BM_OVER_CUR_POLARITY; |
| 385 | } | 386 | } |
| 387 | /* If the polarity is not set keep it as setup by the bootlader */ | ||
| 388 | if (data->pwr_pol == 1) | ||
| 389 | reg |= MX6_BM_PWR_POLARITY; | ||
| 386 | writel(reg, usbmisc->base + data->index * 4); | 390 | writel(reg, usbmisc->base + data->index * 4); |
| 387 | 391 | ||
| 388 | /* SoC non-burst setting */ | 392 | /* SoC non-burst setting */ |
| @@ -585,6 +589,9 @@ static int usbmisc_imx7d_init(struct imx_usbmisc_data *data) · 196 unmodified lines | |||
| 585 | else if (data->oc_pol_configured) | 589 | else if (data->oc_pol_configured) |
| 586 | reg &= ~MX6_BM_OVER_CUR_POLARITY; | 590 | reg &= ~MX6_BM_OVER_CUR_POLARITY; |
| 587 | } | 591 | } |
| 592 | /* If the polarity is not set keep it as setup by the bootlader */ | ||
| 593 | if (data->pwr_pol == 1) | ||
| 594 | reg |= MX6_BM_PWR_POLARITY; | ||
| 588 | writel(reg, usbmisc->base); | 595 | writel(reg, usbmisc->base); |
| 589 | 596 | ||
| 590 | reg = readl(usbmisc->base + MX7D_USBNC_USB_CTRL2); | 597 | reg = readl(usbmisc->base + MX7D_USBNC_USB_CTRL2); |
| @@ -1,3 +1,4 @@ | |||
| 1 | # SPDX-License-Identifier: GPL-2.0 | ||
| 1 | # | 2 | # |
| 2 | # USB Class driver configuration | 3 | # USB Class driver configuration |
| 3 | # | 4 | # |
| @@ -1099,7 +1099,7 @@ static int wdm_post_reset(struct usb_interface *intf) · 1098 unmodified lines | |||
| 1099 | rv = recover_from_urb_loss(desc); | 1099 | rv = recover_from_urb_loss(desc); |
| 1100 | mutex_unlock(&desc->wlock); | 1100 | mutex_unlock(&desc->wlock); |
| 1101 | mutex_unlock(&desc->rlock); | 1101 | mutex_unlock(&desc->rlock); |
| 1102 | return 0; | 1102 | return rv; |
| 1103 | } | 1103 | } |
| 1104 | 1104 | ||
| 1105 | static struct usb_driver wdm_driver = { | 1105 | static struct usb_driver wdm_driver = { |
| @@ -1,3 +1,4 @@ | |||
| 1 | # SPDX-License-Identifier: GPL-2.0 | ||
| 1 | # | 2 | # |
| 2 | # USB Core configuration | 3 | # USB Core configuration |
| 3 | # | 4 | # |
| @@ -90,3 +91,15 @@ config USB_LEDS_TRIGGER_USBPORT · 86 unmodified lines | |||
| 90 | This driver allows LEDs to be controlled by USB events. Enabling this | 91 | This driver allows LEDs to be controlled by USB events. Enabling this |
| 91 | trigger allows specifying list of USB ports that should turn on LED | 92 | trigger allows specifying list of USB ports that should turn on LED |
| 92 | when some USB device gets connected. | 93 | when some USB device gets connected. |
| 94 | |||
| 95 | config USB_AUTOSUSPEND_DELAY | ||
| 96 | int "Default autosuspend delay" | ||
| 97 | depends on USB | ||
| 98 | default 2 | ||
| 99 | help | ||
| 100 | The default autosuspend delay in seconds. Can be overridden | ||
| 101 | with the usbcore.autosuspend command line or module parameter. | ||
| 102 | |||
| 103 | The default value Linux has always had is 2 seconds. Change | ||
| 104 | this value if you want a different delay and cannot modify | ||
| 105 | the command line or module parameter. | ||
| @@ -552,7 +552,7 @@ static int usb_parse_configuration(struct usb_device *dev, int cfgidx, · 551 unmodified lines | |||
| 552 | unsigned char *buffer2; | 552 | unsigned char *buffer2; |
| 553 | int size2; | 553 | int size2; |
| 554 | struct usb_descriptor_header *header; | 554 | struct usb_descriptor_header *header; |
| 555 | int len, retval; | 555 | int retval; |
| 556 | u8 inums[USB_MAXINTERFACES], nalts[USB_MAXINTERFACES]; | 556 | u8 inums[USB_MAXINTERFACES], nalts[USB_MAXINTERFACES]; |
| 557 | unsigned iad_num = 0; | 557 | unsigned iad_num = 0; |
| 558 | 558 | ||
| @@ -707,8 +707,8 @@ static int usb_parse_configuration(struct usb_device *dev, int cfgidx, · 148 unmodified lines | |||
| 707 | nalts[i] = j = USB_MAXALTSETTING; | 707 | nalts[i] = j = USB_MAXALTSETTING; |
| 708 | } | 708 | } |
| 709 | 709 | ||
| 710 | len = sizeof(*intfc) + sizeof(struct usb_host_interface) * j; | 710 | intfc = kzalloc(struct_size(intfc, altsetting, j), GFP_KERNEL); |
| 711 | config->intf_cache[i] = intfc = kzalloc(len, GFP_KERNEL); | 711 | config->intf_cache[i] = intfc; |
| 712 | if (!intfc) | 712 | if (!intfc) |
| 713 | return -ENOMEM; | 713 | return -ENOMEM; |
| 714 | kref_init(&intfc->ref); | 714 | kref_init(&intfc->ref); |
| @@ -800,13 +800,11 @@ int usb_get_configuration(struct usb_device *dev) · 85 unmodified lines | |||
| 800 | { | 800 | { |
| 801 | struct device *ddev = &dev->dev; | 801 | struct device *ddev = &dev->dev; |
| 802 | int ncfg = dev->descriptor.bNumConfigurations; | 802 | int ncfg = dev->descriptor.bNumConfigurations; |
| 803 | int result = 0; | 803 | int result = -ENOMEM; |
| 804 | unsigned int cfgno, length; | 804 | unsigned int cfgno, length; |
| 805 | unsigned char *bigbuffer; | 805 | unsigned char *bigbuffer; |
| 806 | struct usb_config_descriptor *desc; | 806 | struct usb_config_descriptor *desc; |
| 807 | 807 | ||
| 808 | cfgno = 0; | ||
| 809 | result = -ENOMEM; | ||
| 810 | if (ncfg > USB_MAXCONFIG) { | 808 | if (ncfg > USB_MAXCONFIG) { |
| 811 | dev_warn(ddev, "too many configurations: %d, " | 809 | dev_warn(ddev, "too many configurations: %d, " |
| 812 | "using maximum allowed: %d\n", ncfg, USB_MAXCONFIG); | 810 | "using maximum allowed: %d\n", ncfg, USB_MAXCONFIG); |
| @@ -832,8 +830,7 @@ int usb_get_configuration(struct usb_device *dev) · 19 unmodified lines | |||
| 832 | if (!desc) | 830 | if (!desc) |
| 833 | goto err2; | 831 | goto err2; |
| 834 | 832 | ||
| 835 | result = 0; | 833 | for (cfgno = 0; cfgno < ncfg; cfgno++) { |
| 836 | for (; cfgno < ncfg; cfgno++) { | ||
| 837 | /* We grab just the first descriptor so we know how long | 834 | /* We grab just the first descriptor so we know how long |
| 838 | * the whole configuration is */ | 835 | * the whole configuration is */ |
| 839 | result = usb_get_descriptor(dev, USB_DT_CONFIG, cfgno, | 836 | result = usb_get_descriptor(dev, USB_DT_CONFIG, cfgno, |
| @@ -889,7 +886,6 @@ int usb_get_configuration(struct usb_device *dev) · 49 unmodified lines | |||
| 889 | goto err; | 886 | goto err; |
| 890 | } | 887 | } |
| 891 | } | 888 | } |
| 892 | result = 0; | ||
| 893 | 889 | ||
| 894 | err: | 890 | err: |
| 895 | kfree(desc); | 891 | kfree(desc); |
| @@ -604,7 +604,7 @@ static void async_completed(struct urb *urb) · 603 unmodified lines | |||
| 604 | snoop(&urb->dev->dev, "urb complete\n"); | 604 | snoop(&urb->dev->dev, "urb complete\n"); |
| 605 | snoop_urb(urb->dev, as->userurb, urb->pipe, urb->actual_length, | 605 | snoop_urb(urb->dev, as->userurb, urb->pipe, urb->actual_length, |
| 606 | as->status, COMPLETE, NULL, 0); | 606 | as->status, COMPLETE, NULL, 0); |
| 607 | if ((urb->transfer_flags & URB_DIR_MASK) == URB_DIR_IN) | 607 | if (usb_urb_dir_in(urb)) |
| 608 | snoop_urb_data(urb, urb->actual_length); | 608 | snoop_urb_data(urb, urb->actual_length); |
| 609 | 609 | ||
| 610 | if (as->status < 0 && as->bulk_addr && as->status != -ECONNRESET && | 610 | if (as->status < 0 && as->bulk_addr && as->status != -ECONNRESET && |
| @@ -1564,12 +1564,10 @@ static int proc_do_submiturb(struct usb_dev_state *ps, struct usbdevfs_urb *uurb · 953 unmodified lines | |||
| 1564 | } | 1564 | } |
| 1565 | for (totlen = u = 0; u < number_of_packets; u++) { | 1565 | for (totlen = u = 0; u < number_of_packets; u++) { |
| 1566 | /* | 1566 | /* |
| 1567 | * arbitrary limit need for USB 3.0 | 1567 | * arbitrary limit need for USB 3.1 Gen2 |
| 1568 | * bMaxBurst (0~15 allowed, 1~16 packets) | 1568 | * sizemax: 96 DPs at SSP, 96 * 1024 = 98304 |
| 1569 | * bmAttributes (bit 1:0, mult 0~2, 1~3 packets) | ||
| 1570 | * sizemax: 1024 * 16 * 3 = 49152 | ||
| 1571 | */ | 1569 | */ |
| 1572 | if (isopkt[u].length > 49152) { | 1570 | if (isopkt[u].length > 98304) { |
| 1573 | ret = -EINVAL; | 1571 | ret = -EINVAL; |
| 1574 | goto error; | 1572 | goto error; |
| 1575 | } | 1573 | } |
| @@ -1896,14 +1896,11 @@ int usb_runtime_idle(struct device *dev) · 1895 unmodified lines | |||
| 1896 | return -EBUSY; | 1896 | return -EBUSY; |
| 1897 | } | 1897 | } |
| 1898 | 1898 | ||
| 1899 | int usb_set_usb2_hardware_lpm(struct usb_device *udev, int enable) | 1899 | static int usb_set_usb2_hardware_lpm(struct usb_device *udev, int enable) |
| 1900 | { | 1900 | { |
| 1901 | struct usb_hcd *hcd = bus_to_hcd(udev->bus); | 1901 | struct usb_hcd *hcd = bus_to_hcd(udev->bus); |
| 1902 | int ret = -EPERM; | 1902 | int ret = -EPERM; |
| 1903 | 1903 | ||
| 1904 | if (enable && !udev->usb2_hw_lpm_allowed) | ||
| 1905 | return 0; | ||
| 1906 | |||
| 1907 | if (hcd->driver->set_usb2_hw_lpm) { | 1904 | if (hcd->driver->set_usb2_hw_lpm) { |
| 1908 | ret = hcd->driver->set_usb2_hw_lpm(hcd, udev, enable); | 1905 | ret = hcd->driver->set_usb2_hw_lpm(hcd, udev, enable); |
| 1909 | if (!ret) | 1906 | if (!ret) |
| @@ -1913,6 +1910,24 @@ int usb_set_usb2_hardware_lpm(struct usb_device *udev, int enable) · 3 unmodified lines | |||
| 1913 | return ret; | 1910 | return ret; |
| 1914 | } | 1911 | } |
| 1915 | 1912 | ||
| 1913 | int usb_enable_usb2_hardware_lpm(struct usb_device *udev) | ||
| 1914 | { | ||
| 1915 | if (!udev->usb2_hw_lpm_capable || | ||
| 1916 | !udev->usb2_hw_lpm_allowed || | ||
| 1917 | udev->usb2_hw_lpm_enabled) | ||
| 1918 | return 0; | ||
| 1919 | |||
| 1920 | return usb_set_usb2_hardware_lpm(udev, 1); | ||
| 1921 | } | ||
| 1922 | |||
| 1923 | int usb_disable_usb2_hardware_lpm(struct usb_device *udev) | ||
| 1924 | { | ||
| 1925 | if (!udev->usb2_hw_lpm_enabled) | ||
| 1926 | return 0; | ||
| 1927 | |||
| 1928 | return usb_set_usb2_hardware_lpm(udev, 0); | ||
| 1929 | } | ||
| 1930 | |||
| 1916 | #endif /* CONFIG_PM */ | 1931 | #endif /* CONFIG_PM */ |
| 1917 | 1932 | ||
| 1918 | struct bus_type usb_bus_type = { | 1933 | struct bus_type usb_bus_type = { |
| @@ -118,6 +118,31 @@ int usb_choose_configuration(struct usb_device *udev) · 117 unmodified lines | |||
| 118 | continue; | 118 | continue; |
| 119 | } | 119 | } |
| 120 | 120 | ||
| 121 | /* | ||
| 122 | * Select first configuration as default for audio so that | ||
| 123 | * devices that don't comply with UAC3 protocol are supported. | ||
| 124 | * But, still iterate through other configurations and | ||
| 125 | * select UAC3 compliant config if present. | ||
| 126 | */ | ||
| 127 | if (desc && is_audio(desc)) { | ||
| 128 | /* Always prefer the first found UAC3 config */ | ||
| 129 | if (is_uac3_config(desc)) { | ||
| 130 | best = c; | ||
| 131 | break; | ||
| 132 | } | ||
| 133 | |||
| 134 | /* If there is no UAC3 config, prefer the first config */ | ||
| 135 | else if (i == 0) | ||
| 136 | best = c; | ||
| 137 | |||
| 138 | /* Unconditional continue, because the rest of the code | ||
| 139 | * in the loop is irrelevant for audio devices, and | ||
| 140 | * because it can reassign best, which for audio devices | ||
| 141 | * we don't want. | ||
| 142 | */ | ||
| 143 | continue; | ||
| 144 | } | ||
| 145 | |||
| 121 | /* When the first config's first interface is one of Microsoft's | 146 | /* When the first config's first interface is one of Microsoft's |
| 122 | * pet nonstandard Ethernet-over-USB protocols, ignore it unless | 147 | * pet nonstandard Ethernet-over-USB protocols, ignore it unless |
| 123 | * this kernel has enabled the necessary host side driver. | 148 | * this kernel has enabled the necessary host side driver. |
| @@ -132,25 +157,6 @@ int usb_choose_configuration(struct usb_device *udev) · 8 unmodified lines | |||
| 132 | #endif | 157 | #endif |
| 133 | } | 158 | } |
| 134 | 159 | ||
| 135 | /* | ||
| 136 | * Select first configuration as default for audio so that | ||
| 137 | * devices that don't comply with UAC3 protocol are supported. | ||
| 138 | * But, still iterate through other configurations and | ||
| 139 | * select UAC3 compliant config if present. | ||
| 140 | */ | ||
| 141 | if (i == 0 && num_configs > 1 && desc && is_audio(desc)) { | ||
| 142 | best = c; | ||
| 143 | continue; | ||
| 144 | } | ||
| 145 | |||
| 146 | if (i > 0 && desc && is_audio(desc)) { | ||
| 147 | if (is_uac3_config(desc)) { | ||
| 148 | best = c; | ||
| 149 | break; | ||
| 150 | } | ||
| 151 | continue; | ||
| 152 | } | ||
| 153 | |||
| 154 | /* From the remaining configs, choose the first one whose | 160 | /* From the remaining configs, choose the first one whose |
| 155 | * first interface is for a non-vendor-specific class. | 161 | * first interface is for a non-vendor-specific class. |
| 156 | * Reason: Linux is more likely to have a class driver | 162 | * Reason: Linux is more likely to have a class driver |
| @@ -373,13 +373,19 @@ static const u8 ss_rh_config_descriptor[] = { · 372 unmodified lines | |||
| 373 | * -1 is authorized for all devices except wireless (old behaviour) | 373 | * -1 is authorized for all devices except wireless (old behaviour) |
| 374 | * 0 is unauthorized for all devices | 374 | * 0 is unauthorized for all devices |
| 375 | * 1 is authorized for all devices | 375 | * 1 is authorized for all devices |
| 376 | * 2 is authorized for internal devices | ||
| 376 | */ | 377 | */ |
| 377 | static int authorized_default = -1; | 378 | #define USB_AUTHORIZE_WIRED -1 |
| 379 | #define USB_AUTHORIZE_NONE 0 | ||
| 380 | #define USB_AUTHORIZE_ALL 1 | ||
| 381 | #define USB_AUTHORIZE_INTERNAL 2 | ||
| 382 | |||
| 383 | static int authorized_default = USB_AUTHORIZE_WIRED; | ||
| 378 | module_param(authorized_default, int, S_IRUGO|S_IWUSR); | 384 | module_param(authorized_default, int, S_IRUGO|S_IWUSR); |
| 379 | MODULE_PARM_DESC(authorized_default, | 385 | MODULE_PARM_DESC(authorized_default, |
| 380 | "Default USB device authorization: 0 is not authorized, 1 is " | 386 | "Default USB device authorization: 0 is not authorized, 1 is " |
| 381 | "authorized, -1 is authorized except for wireless USB (default, " | 387 | "authorized, 2 is authorized for internal devices, -1 is " |
| 382 | "old behaviour"); | 388 | "authorized except for wireless USB (default, old behaviour)"); |
| 383 | /*-------------------------------------------------------------------------*/ | 389 | /*-------------------------------------------------------------------------*/ |
| 384 | 390 | ||
| 385 | /** | 391 | /** |
| @@ -884,7 +890,7 @@ static ssize_t authorized_default_show(struct device *dev, · 498 unmodified lines | |||
| 884 | struct usb_hcd *hcd; | 890 | struct usb_hcd *hcd; |
| 885 | 891 | ||
| 886 | hcd = bus_to_hcd(usb_bus); | 892 | hcd = bus_to_hcd(usb_bus); |
| 887 | return snprintf(buf, PAGE_SIZE, "%u\n", !!HCD_DEV_AUTHORIZED(hcd)); | 893 | return snprintf(buf, PAGE_SIZE, "%u\n", hcd->dev_policy); |
| 888 | } | 894 | } |
| 889 | 895 | ||
| 890 | static ssize_t authorized_default_store(struct device *dev, | 896 | static ssize_t authorized_default_store(struct device *dev, |
| @@ -900,11 +906,8 @@ static ssize_t authorized_default_store(struct device *dev, · 9 unmodified lines | |||
| 900 | hcd = bus_to_hcd(usb_bus); | 906 | hcd = bus_to_hcd(usb_bus); |
| 901 | result = sscanf(buf, "%u\n", &val); | 907 | result = sscanf(buf, "%u\n", &val); |
| 902 | if (result == 1) { | 908 | if (result == 1) { |
| 903 | if (val) | 909 | hcd->dev_policy = val <= USB_DEVICE_AUTHORIZE_INTERNAL ? |
| 904 | set_bit(HCD_FLAG_DEV_AUTHORIZED, &hcd->flags); | 910 | val : USB_DEVICE_AUTHORIZE_ALL; |
| 905 | else | ||
| 906 | clear_bit(HCD_FLAG_DEV_AUTHORIZED, &hcd->flags); | ||
| 907 | |||
| 908 | result = size; | 911 | result = size; |
| 909 | } else { | 912 | } else { |
| 910 | result = -EINVAL; | 913 | result = -EINVAL; |
| @@ -2736,6 +2739,11 @@ int usb_add_hcd(struct usb_hcd *hcd, · 1825 unmodified lines | |||
| 2736 | if (retval) | 2739 | if (retval) |
| 2737 | return retval; | 2740 | return retval; |
| 2738 | 2741 | ||
| 2742 | retval = usb_phy_roothub_set_mode(hcd->phy_roothub, | ||
| 2743 | PHY_MODE_USB_HOST_SS); | ||
| 2744 | if (retval) | ||
| 2745 | goto err_usb_phy_roothub_power_on; | ||
| 2746 | |||
| 2739 | retval = usb_phy_roothub_power_on(hcd->phy_roothub); | 2747 | retval = usb_phy_roothub_power_on(hcd->phy_roothub); |
| 2740 | if (retval) | 2748 | if (retval) |
| 2741 | goto err_usb_phy_roothub_power_on; | 2749 | goto err_usb_phy_roothub_power_on; |
| @@ -2743,18 +2751,26 @@ int usb_add_hcd(struct usb_hcd *hcd, · 1 unmodified line | |||
| 2743 | 2751 | ||
| 2744 | dev_info(hcd->self.controller, "%s\n", hcd->product_desc); | 2752 | dev_info(hcd->self.controller, "%s\n", hcd->product_desc); |
| 2745 | 2753 | ||
| 2746 | /* Keep old behaviour if authorized_default is not in [0, 1]. */ | 2754 | switch (authorized_default) { |
| 2747 | if (authorized_default < 0 || authorized_default > 1) { | 2755 | case USB_AUTHORIZE_NONE: |
| 2748 | if (hcd->wireless) | 2756 | hcd->dev_policy = USB_DEVICE_AUTHORIZE_NONE; |
| 2749 | clear_bit(HCD_FLAG_DEV_AUTHORIZED, &hcd->flags); | 2757 | break; |
| 2750 | else | 2758 | |
| 2751 | set_bit(HCD_FLAG_DEV_AUTHORIZED, &hcd->flags); | 2759 | case USB_AUTHORIZE_ALL: |
| 2752 | } else { | 2760 | hcd->dev_policy = USB_DEVICE_AUTHORIZE_ALL; |
| 2753 | if (authorized_default) | 2761 | break; |
| 2754 | set_bit(HCD_FLAG_DEV_AUTHORIZED, &hcd->flags); | 2762 | |
| 2755 | else | 2763 | case USB_AUTHORIZE_INTERNAL: |
| 2756 | clear_bit(HCD_FLAG_DEV_AUTHORIZED, &hcd->flags); | 2764 | hcd->dev_policy = USB_DEVICE_AUTHORIZE_INTERNAL; |
| 2765 | break; | ||
| 2766 | |||
| 2767 | case USB_AUTHORIZE_WIRED: | ||
| 2768 | default: | ||
| 2769 | hcd->dev_policy = hcd->wireless ? | ||
| 2770 | USB_DEVICE_AUTHORIZE_NONE : USB_DEVICE_AUTHORIZE_ALL; | ||
| 2771 | break; | ||
| 2757 | } | 2772 | } |
| 2773 | |||
| 2758 | set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); | 2774 | set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); |
| 2759 | 2775 | ||
| 2760 | /* per default all interfaces are authorized */ | 2776 | /* per default all interfaces are authorized */ |
| @@ -108,6 +108,8 @@ EXPORT_SYMBOL_GPL(ehci_cf_port_reset_rwsem); · 107 unmodified lines | |||
| 108 | static void hub_release(struct kref *kref); | 108 | static void hub_release(struct kref *kref); |
| 109 | static int usb_reset_and_verify_device(struct usb_device *udev); | 109 | static int usb_reset_and_verify_device(struct usb_device *udev); |
| 110 | static int hub_port_disable(struct usb_hub *hub, int port1, int set_state); | 110 | static int hub_port_disable(struct usb_hub *hub, int port1, int set_state); |
| 111 | static bool hub_port_warm_reset_required(struct usb_hub *hub, int port1, | ||
| 112 | u16 portstatus); | ||
| 111 | 113 | ||
| 112 | static inline char *portspeed(struct usb_hub *hub, int portstatus) | 114 | static inline char *portspeed(struct usb_hub *hub, int portstatus) |
| 113 | { | 115 | { |
| @@ -607,6 +609,36 @@ static int hub_port_status(struct usb_hub *hub, int port1, · 493 unmodified lines | |||
| 607 | status, change, NULL); | 609 | status, change, NULL); |
| 608 | } | 610 | } |
| 609 | 611 | ||
| 612 | static void hub_resubmit_irq_urb(struct usb_hub *hub) | ||
| 613 | { | ||
| 614 | unsigned long flags; | ||
| 615 | int status; | ||
| 616 | |||
| 617 | spin_lock_irqsave(&hub->irq_urb_lock, flags); | ||
| 618 | |||
| 619 | if (hub->quiescing) { | ||
| 620 | spin_unlock_irqrestore(&hub->irq_urb_lock, flags); | ||
| 621 | return; | ||
| 622 | } | ||
| 623 | |||
| 624 | status = usb_submit_urb(hub->urb, GFP_ATOMIC); | ||
| 625 | if (status && status != -ENODEV && status != -EPERM && | ||
| 626 | status != -ESHUTDOWN) { | ||
| 627 | dev_err(hub->intfdev, "resubmit --> %d\n", status); | ||
| 628 | mod_timer(&hub->irq_urb_retry, jiffies + HZ); | ||
| 629 | } | ||
| 630 | |||
| 631 | spin_unlock_irqrestore(&hub->irq_urb_lock, flags); | ||
| 632 | } | ||
| 633 | |||
| 634 | static void hub_retry_irq_urb(struct timer_list *t) | ||
| 635 | { | ||
| 636 | struct usb_hub *hub = from_timer(hub, t, irq_urb_retry); | ||
| 637 | |||
| 638 | hub_resubmit_irq_urb(hub); | ||
| 639 | } | ||
| 640 | |||
| 641 | |||
| 610 | static void kick_hub_wq(struct usb_hub *hub) | 642 | static void kick_hub_wq(struct usb_hub *hub) |
| 611 | { | 643 | { |
| 612 | struct usb_interface *intf; | 644 | struct usb_interface *intf; |
| @@ -709,12 +741,7 @@ static void hub_irq(struct urb *urb) · 96 unmodified lines | |||
| 709 | kick_hub_wq(hub); | 741 | kick_hub_wq(hub); |
| 710 | 742 | ||
| 711 | resubmit: | 743 | resubmit: |
| 712 | if (hub->quiescing) | 744 | hub_resubmit_irq_urb(hub); |
| 713 | return; | ||
| 714 | |||
| 715 | status = usb_submit_urb(hub->urb, GFP_ATOMIC); | ||
| 716 | if (status != 0 && status != -ENODEV && status != -EPERM) | ||
| 717 | dev_err(hub->intfdev, "resubmit --> %d\n", status); | ||
| 718 | } | 745 | } |
| 719 | 746 | ||
| 720 | /* USB 2.0 spec Section 11.24.2.3 */ | 747 | /* USB 2.0 spec Section 11.24.2.3 */ |
| @@ -1112,6 +1139,11 @@ static void hub_activate(struct usb_hub *hub, enum hub_activation_type type) · 391 unmodified lines | |||
| 1112 | USB_PORT_FEAT_ENABLE); | 1139 | USB_PORT_FEAT_ENABLE); |
| 1113 | } | 1140 | } |
| 1114 | 1141 | ||
| 1142 | /* Make sure a warm-reset request is handled by port_event */ | ||
| 1143 | if (type == HUB_RESUME && | ||
| 1144 | hub_port_warm_reset_required(hub, port1, portstatus)) | ||
| 1145 | set_bit(port1, hub->event_bits); | ||
| 1146 | |||
| 1115 | /* | 1147 | /* |
| 1116 | * Add debounce if USB3 link is in polling/link training state. | 1148 | * Add debounce if USB3 link is in polling/link training state. |
| 1117 | * Link will automatically transition to Enabled state after | 1149 | * Link will automatically transition to Enabled state after |
| @@ -1264,10 +1296,13 @@ enum hub_quiescing_type { · 146 unmodified lines | |||
| 1264 | static void hub_quiesce(struct usb_hub *hub, enum hub_quiescing_type type) | 1296 | static void hub_quiesce(struct usb_hub *hub, enum hub_quiescing_type type) |
| 1265 | { | 1297 | { |
| 1266 | struct usb_device *hdev = hub->hdev; | 1298 | struct usb_device *hdev = hub->hdev; |
| 1299 | unsigned long flags; | ||
| 1267 | int i; | 1300 | int i; |
| 1268 | 1301 | ||
| 1269 | /* hub_wq and related activity won't re-trigger */ | 1302 | /* hub_wq and related activity won't re-trigger */ |
| 1303 | spin_lock_irqsave(&hub->irq_urb_lock, flags); | ||
| 1270 | hub->quiescing = 1; | 1304 | hub->quiescing = 1; |
| 1305 | spin_unlock_irqrestore(&hub->irq_urb_lock, flags); | ||
| 1271 | 1306 | ||
| 1272 | if (type != HUB_SUSPEND) { | 1307 | if (type != HUB_SUSPEND) { |
| 1273 | /* Disconnect all the children */ | 1308 | /* Disconnect all the children */ |
| @@ -1278,6 +1313,7 @@ static void hub_quiesce(struct usb_hub *hub, enum hub_quiescing_type type) · 4 unmodified lines | |||
| 1278 | } | 1313 | } |
| 1279 | 1314 | ||
| 1280 | /* Stop hub_wq and related activity */ | 1315 | /* Stop hub_wq and related activity */ |
| 1316 | del_timer_sync(&hub->irq_urb_retry); | ||
| 1281 | usb_kill_urb(hub->urb); | 1317 | usb_kill_urb(hub->urb); |
| 1282 | if (hub->has_indicators) | 1318 | if (hub->has_indicators) |
| 1283 | cancel_delayed_work_sync(&hub->leds); | 1319 | cancel_delayed_work_sync(&hub->leds); |
| @@ -1810,6 +1846,8 @@ static int hub_probe(struct usb_interface *intf, const struct usb_device_id *id) · 526 unmodified lines | |||
| 1810 | INIT_DELAYED_WORK(&hub->leds, led_work); | 1846 | INIT_DELAYED_WORK(&hub->leds, led_work); |
| 1811 | INIT_DELAYED_WORK(&hub->init_work, NULL); | 1847 | INIT_DELAYED_WORK(&hub->init_work, NULL); |
| 1812 | INIT_WORK(&hub->events, hub_event); | 1848 | INIT_WORK(&hub->events, hub_event); |
| 1849 | spin_lock_init(&hub->irq_urb_lock); | ||
| 1850 | timer_setup(&hub->irq_urb_retry, hub_retry_irq_urb, 0); | ||
| 1813 | usb_get_intf(intf); | 1851 | usb_get_intf(intf); |
| 1814 | usb_get_dev(hdev); | 1852 | usb_get_dev(hdev); |
| 1815 | 1853 | ||
| @@ -3220,8 +3258,7 @@ int usb_port_suspend(struct usb_device *udev, pm_message_t msg) · 1404 unmodified lines | |||
| 3220 | } | 3258 | } |
| 3221 | 3259 | ||
| 3222 | /* disable USB2 hardware LPM */ | 3260 | /* disable USB2 hardware LPM */ |
| 3223 | if (udev->usb2_hw_lpm_enabled == 1) | 3261 | usb_disable_usb2_hardware_lpm(udev); |
| 3224 | usb_set_usb2_hardware_lpm(udev, 0); | ||
| 3225 | 3262 | ||
| 3226 | if (usb_disable_ltm(udev)) { | 3263 | if (usb_disable_ltm(udev)) { |
| 3227 | dev_err(&udev->dev, "Failed to disable LTM before suspend\n"); | 3264 | dev_err(&udev->dev, "Failed to disable LTM before suspend\n"); |
| @@ -3259,8 +3296,7 @@ int usb_port_suspend(struct usb_device *udev, pm_message_t msg) · 31 unmodified lines | |||
| 3259 | usb_enable_ltm(udev); | 3296 | usb_enable_ltm(udev); |
| 3260 | err_ltm: | 3297 | err_ltm: |
| 3261 | /* Try to enable USB2 hardware LPM again */ | 3298 | /* Try to enable USB2 hardware LPM again */ |
| 3262 | if (udev->usb2_hw_lpm_capable == 1) | 3299 | usb_enable_usb2_hardware_lpm(udev); |
| 3263 | usb_set_usb2_hardware_lpm(udev, 1); | ||
| 3264 | 3300 | ||
| 3265 | if (udev->do_remote_wakeup) | 3301 | if (udev->do_remote_wakeup) |
| 3266 | (void) usb_disable_remote_wakeup(udev); | 3302 | (void) usb_disable_remote_wakeup(udev); |
| @@ -3543,8 +3579,7 @@ int usb_port_resume(struct usb_device *udev, pm_message_t msg) · 276 unmodified lines | |||
| 3543 | hub_port_logical_disconnect(hub, port1); | 3579 | hub_port_logical_disconnect(hub, port1); |
| 3544 | } else { | 3580 | } else { |
| 3545 | /* Try to enable USB2 hardware LPM */ | 3581 | /* Try to enable USB2 hardware LPM */ |
| 3546 | if (udev->usb2_hw_lpm_capable == 1) | 3582 | usb_enable_usb2_hardware_lpm(udev); |
| 3547 | usb_set_usb2_hardware_lpm(udev, 1); | ||
| 3548 | 3583 | ||
| 3549 | /* Try to enable USB3 LTM */ | 3584 | /* Try to enable USB3 LTM */ |
| 3550 | usb_enable_ltm(udev); | 3585 | usb_enable_ltm(udev); |
| @@ -4435,7 +4470,7 @@ static void hub_set_initial_usb2_lpm_policy(struct usb_device *udev) · 884 unmodified lines | |||
| 4435 | if ((udev->bos->ext_cap->bmAttributes & cpu_to_le32(USB_BESL_SUPPORT)) || | 4470 | if ((udev->bos->ext_cap->bmAttributes & cpu_to_le32(USB_BESL_SUPPORT)) || |
| 4436 | connect_type == USB_PORT_CONNECT_TYPE_HARD_WIRED) { | 4471 | connect_type == USB_PORT_CONNECT_TYPE_HARD_WIRED) { |
| 4437 | udev->usb2_hw_lpm_allowed = 1; | 4472 | udev->usb2_hw_lpm_allowed = 1; |
| 4438 | usb_set_usb2_hardware_lpm(udev, 1); | 4473 | usb_enable_usb2_hardware_lpm(udev); |
| 4439 | } | 4474 | } |
| 4440 | } | 4475 | } |
| 4441 | 4476 | ||
| @@ -5649,8 +5684,7 @@ static int usb_reset_and_verify_device(struct usb_device *udev) · 1207 unmodified lines | |||
| 5649 | /* Disable USB2 hardware LPM. | 5684 | /* Disable USB2 hardware LPM. |
| 5650 | * It will be re-enabled by the enumeration process. | 5685 | * It will be re-enabled by the enumeration process. |
| 5651 | */ | 5686 | */ |
| 5652 | if (udev->usb2_hw_lpm_enabled == 1) | 5687 | usb_disable_usb2_hardware_lpm(udev); |
| 5653 | usb_set_usb2_hardware_lpm(udev, 0); | ||
| 5654 | 5688 | ||
| 5655 | /* Disable LPM while we reset the device and reinstall the alt settings. | 5689 | /* Disable LPM while we reset the device and reinstall the alt settings. |
| 5656 | * Device-initiated LPM, and system exit latency settings are cleared | 5690 | * Device-initiated LPM, and system exit latency settings are cleared |
| @@ -5753,7 +5787,7 @@ static int usb_reset_and_verify_device(struct usb_device *udev) · 96 unmodified lines | |||
| 5753 | 5787 | ||
| 5754 | done: | 5788 | done: |
| 5755 | /* Now that the alt settings are re-installed, enable LTM and LPM. */ | 5789 | /* Now that the alt settings are re-installed, enable LTM and LPM. */ |
| 5756 | usb_set_usb2_hardware_lpm(udev, 1); | 5790 | usb_enable_usb2_hardware_lpm(udev); |
| 5757 | usb_unlocked_enable_lpm(udev); | 5791 | usb_unlocked_enable_lpm(udev); |
| 5758 | usb_enable_ltm(udev); | 5792 | usb_enable_ltm(udev); |
| 5759 | usb_release_bos_descriptor(udev); | 5793 | usb_release_bos_descriptor(udev); |
| @@ -69,6 +69,8 @@ struct usb_hub { · 68 unmodified lines | |||
| 69 | struct delayed_work leds; | 69 | struct delayed_work leds; |
| 70 | struct delayed_work init_work; | 70 | struct delayed_work init_work; |
| 71 | struct work_struct events; | 71 | struct work_struct events; |
| 72 | spinlock_t irq_urb_lock; | ||
| 73 | struct timer_list irq_urb_retry; | ||
| 72 | struct usb_port **ports; | 74 | struct usb_port **ports; |
| 73 | }; | 75 | }; |
| 74 | 76 | ||
| @@ -1243,8 +1243,7 @@ void usb_disable_device(struct usb_device *dev, int skip_ep0) · 1242 unmodified lines | |||
| 1243 | dev->actconfig->interface[i] = NULL; | 1243 | dev->actconfig->interface[i] = NULL; |
| 1244 | } | 1244 | } |
| 1245 | 1245 | ||
| 1246 | if (dev->usb2_hw_lpm_enabled == 1) | 1246 | usb_disable_usb2_hardware_lpm(dev); |
| 1247 | usb_set_usb2_hardware_lpm(dev, 0); | ||
| 1248 | usb_unlocked_disable_lpm(dev); | 1247 | usb_unlocked_disable_lpm(dev); |
| 1249 | usb_disable_ltm(dev); | 1248 | usb_disable_ltm(dev); |
| 1250 | 1249 | ||
| @@ -2007,6 +2006,13 @@ free_interfaces: · 756 unmodified lines | |||
| 2007 | for (i = 0; i < nintf; ++i) { | 2006 | for (i = 0; i < nintf; ++i) { |
| 2008 | struct usb_interface *intf = cp->interface[i]; | 2007 | struct usb_interface *intf = cp->interface[i]; |
| 2009 | 2008 | ||
| 2009 | if (intf->dev.of_node && | ||
| 2010 | !of_device_is_available(intf->dev.of_node)) { | ||
| 2011 | dev_info(&dev->dev, "skipping disabled interface %d\n", | ||
| 2012 | intf->cur_altsetting->desc.bInterfaceNumber); | ||
| 2013 | continue; | ||
| 2014 | } | ||
| 2015 | |||
| 2010 | dev_dbg(&dev->dev, | 2016 | dev_dbg(&dev->dev, |
| 2011 | "adding %s (config #%d, interface %d)\n", | 2017 | "adding %s (config #%d, interface %d)\n", |
| 2012 | dev_name(&intf->dev), configuration, | 2018 | dev_name(&intf->dev), configuration, |
| @@ -123,6 +123,34 @@ int usb_phy_roothub_exit(struct usb_phy_roothub *phy_roothub) · 122 unmodified lines | |||
| 123 | } | 123 | } |
| 124 | EXPORT_SYMBOL_GPL(usb_phy_roothub_exit); | 124 | EXPORT_SYMBOL_GPL(usb_phy_roothub_exit); |
| 125 | 125 | ||
| 126 | int usb_phy_roothub_set_mode(struct usb_phy_roothub *phy_roothub, | ||
| 127 | enum phy_mode mode) | ||
| 128 | { | ||
| 129 | struct usb_phy_roothub *roothub_entry; | ||
| 130 | struct list_head *head; | ||
| 131 | int err; | ||
| 132 | |||
| 133 | if (!phy_roothub) | ||
| 134 | return 0; | ||
| 135 | |||
| 136 | head = &phy_roothub->list; | ||
| 137 | |||
| 138 | list_for_each_entry(roothub_entry, head, list) { | ||
| 139 | err = phy_set_mode(roothub_entry->phy, mode); | ||
| 140 | if (err) | ||
| 141 | goto err_out; | ||
| 142 | } | ||
| 143 | |||
| 144 | return 0; | ||
| 145 | |||
| 146 | err_out: | ||
| 147 | list_for_each_entry_continue_reverse(roothub_entry, head, list) | ||
| 148 | phy_power_off(roothub_entry->phy); | ||
| 149 | |||
| 150 | return err; | ||
| 151 | } | ||
| 152 | EXPORT_SYMBOL_GPL(usb_phy_roothub_set_mode); | ||
| 153 | |||
| 126 | int usb_phy_roothub_power_on(struct usb_phy_roothub *phy_roothub) | 154 | int usb_phy_roothub_power_on(struct usb_phy_roothub *phy_roothub) |
| 127 | { | 155 | { |
| 128 | struct usb_phy_roothub *roothub_entry; | 156 | struct usb_phy_roothub *roothub_entry; |
| @@ -16,6 +16,8 @@ struct usb_phy_roothub *usb_phy_roothub_alloc(struct device *dev); · 15 unmodified lines | |||
| 16 | int usb_phy_roothub_init(struct usb_phy_roothub *phy_roothub); | 16 | int usb_phy_roothub_init(struct usb_phy_roothub *phy_roothub); |
| 17 | int usb_phy_roothub_exit(struct usb_phy_roothub *phy_roothub); | 17 | int usb_phy_roothub_exit(struct usb_phy_roothub *phy_roothub); |
| 18 | 18 | ||
| 19 | int usb_phy_roothub_set_mode(struct usb_phy_roothub *phy_roothub, | ||
| 20 | enum phy_mode mode); | ||
| 19 | int usb_phy_roothub_power_on(struct usb_phy_roothub *phy_roothub); | 21 | int usb_phy_roothub_power_on(struct usb_phy_roothub *phy_roothub); |
| 20 | void usb_phy_roothub_power_off(struct usb_phy_roothub *phy_roothub); | 22 | void usb_phy_roothub_power_off(struct usb_phy_roothub *phy_roothub); |
| 21 | 23 | ||
| @@ -528,7 +528,10 @@ static ssize_t usb2_hardware_lpm_store(struct device *dev, · 527 unmodified lines | |||
| 528 | 528 | ||
| 529 | if (!ret) { | 529 | if (!ret) { |
| 530 | udev->usb2_hw_lpm_allowed = value; | 530 | udev->usb2_hw_lpm_allowed = value; |
| 531 | ret = usb_set_usb2_hardware_lpm(udev, value); | 531 | if (value) |
| 532 | ret = usb_enable_usb2_hardware_lpm(udev); | ||
| 533 | else | ||
| 534 | ret = usb_disable_usb2_hardware_lpm(udev); | ||
| 532 | } | 535 | } |
| 533 | 536 | ||
| 534 | usb_unlock_device(udev); | 537 | usb_unlock_device(udev); |
| @@ -70,9 +70,8 @@ struct urb *usb_alloc_urb(int iso_packets, gfp_t mem_flags) · 69 unmodified lines | |||
| 70 | { | 70 | { |
| 71 | struct urb *urb; | 71 | struct urb *urb; |
| 72 | 72 | ||
| 73 | urb = kmalloc(sizeof(struct urb) + | 73 | urb = kmalloc(struct_size(urb, iso_frame_desc, iso_packets), |
| 74 | iso_packets * sizeof(struct usb_iso_packet_descriptor), | 74 | mem_flags); |
| 75 | mem_flags); | ||
| 76 | if (!urb) | 75 | if (!urb) |
| 77 | return NULL; | 76 | return NULL; |
| 78 | usb_init_urb(urb); | 77 | usb_init_urb(urb); |
| @@ -46,8 +46,7 @@ · 45 unmodified lines | |||
| 46 | #include <linux/mm.h> | 46 | #include <linux/mm.h> |
| 47 | #include <linux/dma-mapping.h> | 47 | #include <linux/dma-mapping.h> |
| 48 | 48 | ||
| 49 | #include "usb.h" | 49 | #include "hub.h" |
| 50 | |||
| 51 | 50 | ||
| 52 | const char *usbcore_name = "usbcore"; | 51 | const char *usbcore_name = "usbcore"; |
| 53 | 52 | ||
| @@ -65,8 +64,8 @@ int usb_disabled(void) · 11 unmodified lines | |||
| 65 | EXPORT_SYMBOL_GPL(usb_disabled); | 64 | EXPORT_SYMBOL_GPL(usb_disabled); |
| 66 | 65 | ||
| 67 | #ifdef CONFIG_PM | 66 | #ifdef CONFIG_PM |
| 68 | static int usb_autosuspend_delay = 2; /* Default delay value, | 67 | /* Default delay value, in seconds */ |
| 69 | * in seconds */ | 68 | static int usb_autosuspend_delay = CONFIG_USB_AUTOSUSPEND_DELAY; |
| 70 | module_param_named(autosuspend, usb_autosuspend_delay, int, 0644); | 69 | module_param_named(autosuspend, usb_autosuspend_delay, int, 0644); |
| 71 | MODULE_PARM_DESC(autosuspend, "default autosuspend delay"); | 70 | MODULE_PARM_DESC(autosuspend, "default autosuspend delay"); |
| 72 | 71 | ||
| @@ -536,6 +535,27 @@ static unsigned usb_bus_is_wusb(struct usb_bus *bus) · 463 unmodified lines | |||
| 536 | return hcd->wireless; | 535 | return hcd->wireless; |
| 537 | } | 536 | } |
| 538 | 537 | ||
| 538 | static bool usb_dev_authorized(struct usb_device *dev, struct usb_hcd *hcd) | ||
| 539 | { | ||
| 540 | struct usb_hub *hub; | ||
| 541 | |||
| 542 | if (!dev->parent) | ||
| 543 | return true; /* Root hub always ok [and always wired] */ | ||
| 544 | |||
| 545 | switch (hcd->dev_policy) { | ||
| 546 | case USB_DEVICE_AUTHORIZE_NONE: | ||
| 547 | default: | ||
| 548 | return false; | ||
| 549 | |||
| 550 | case USB_DEVICE_AUTHORIZE_ALL: | ||
| 551 | return true; | ||
| 552 | |||
| 553 | case USB_DEVICE_AUTHORIZE_INTERNAL: | ||
| 554 | hub = usb_hub_to_struct_hub(dev->parent); | ||
| 555 | return hub->ports[dev->portnum - 1]->connect_type == | ||
| 556 | USB_PORT_CONNECT_TYPE_HARD_WIRED; | ||
| 557 | } | ||
| 558 | } | ||
| 539 | 559 | ||
| 540 | /** | 560 | /** |
| 541 | * usb_alloc_dev - usb device constructor (usbcore-internal) | 561 | * usb_alloc_dev - usb device constructor (usbcore-internal) |
| @@ -663,12 +683,11 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent, · 121 unmodified lines | |||
| 663 | dev->connect_time = jiffies; | 683 | dev->connect_time = jiffies; |
| 664 | dev->active_duration = -jiffies; | 684 | dev->active_duration = -jiffies; |
| 665 | #endif | 685 | #endif |
| 666 | if (root_hub) /* Root hub always ok [and always wired] */ | 686 | |
| 667 | dev->authorized = 1; | 687 | dev->authorized = usb_dev_authorized(dev, usb_hcd); |
| 668 | else { | 688 | if (!root_hub) |
| 669 | dev->authorized = !!HCD_DEV_AUTHORIZED(usb_hcd); | ||
| 670 | dev->wusb = usb_bus_is_wusb(bus) ? 1 : 0; | 689 | dev->wusb = usb_bus_is_wusb(bus) ? 1 : 0; |
| 671 | } | 690 | |
| 672 | return dev; | 691 | return dev; |
| 673 | } | 692 | } |
| 674 | EXPORT_SYMBOL_GPL(usb_alloc_dev); | 693 | EXPORT_SYMBOL_GPL(usb_alloc_dev); |
| @@ -92,7 +92,8 @@ extern int usb_remote_wakeup(struct usb_device *dev); · 91 unmodified lines | |||
| 92 | extern int usb_runtime_suspend(struct device *dev); | 92 | extern int usb_runtime_suspend(struct device *dev); |
| 93 | extern int usb_runtime_resume(struct device *dev); | 93 | extern int usb_runtime_resume(struct device *dev); |
| 94 | extern int usb_runtime_idle(struct device *dev); | 94 | extern int usb_runtime_idle(struct device *dev); |
| 95 | extern int usb_set_usb2_hardware_lpm(struct usb_device *udev, int enable); | 95 | extern int usb_enable_usb2_hardware_lpm(struct usb_device *udev); |
| 96 | extern int usb_disable_usb2_hardware_lpm(struct usb_device *udev); | ||
| 96 | 97 | ||
| 97 | #else | 98 | #else |
| 98 | 99 | ||
| @@ -112,7 +113,12 @@ static inline int usb_autoresume_device(struct usb_device *udev) · 13 unmodified lines | |||
| 112 | return 0; | 113 | return 0; |
| 113 | } | 114 | } |
| 114 | 115 | ||
| 115 | static inline int usb_set_usb2_hardware_lpm(struct usb_device *udev, int enable) | 116 | static inline int usb_enable_usb2_hardware_lpm(struct usb_device *udev) |
| 117 | { | ||
| 118 | return 0; | ||
| 119 | } | ||
| 120 | |||
| 121 | static inline int usb_disable_usb2_hardware_lpm(struct usb_device *udev) | ||
| 116 | { | 122 | { |
| 117 | return 0; | 123 | return 0; |
| 118 | } | 124 | } |
| @@ -1,3 +1,5 @@ | |||
| 1 | # SPDX-License-Identifier: GPL-2.0 | ||
| 2 | |||
| 1 | config USB_DWC2 | 3 | config USB_DWC2 |
| 2 | tristate "DesignWare USB2 DRD Core Support" | 4 | tristate "DesignWare USB2 DRD Core Support" |
| 3 | depends on HAS_DMA | 5 | depends on HAS_DMA |
| @@ -768,22 +768,13 @@ static u32 dwc2_gadget_get_desc_params(struct dwc2_hsotg_ep *hs_ep, u32 *mask) · 767 unmodified lines | |||
| 768 | return desc_size; | 768 | return desc_size; |
| 769 | } | 769 | } |
| 770 | 770 | ||
| 771 | /* | 771 | static void dwc2_gadget_fill_nonisoc_xfer_ddma_one(struct dwc2_hsotg_ep *hs_ep, |
| 772 | * dwc2_gadget_config_nonisoc_xfer_ddma - prepare non ISOC DMA desc chain. | 772 | struct dwc2_dma_desc **desc, |
| 773 | * @hs_ep: The endpoint | ||
| 774 | * @dma_buff: DMA address to use | ||
| 775 | * @len: Length of the transfer | ||
| 776 | * | ||
| 777 | * This function will iterate over descriptor chain and fill its entries | ||
| 778 | * with corresponding information based on transfer data. | ||
| 779 | */ | ||
| 780 | static void dwc2_gadget_config_nonisoc_xfer_ddma(struct dwc2_hsotg_ep *hs_ep, | ||
| 781 | dma_addr_t dma_buff, | 773 | dma_addr_t dma_buff, |
| 782 | unsigned int len) | 774 | unsigned int len, |
| 775 | bool true_last) | ||
| 783 | { | 776 | { |
| 784 | struct dwc2_hsotg *hsotg = hs_ep->parent; | ||
| 785 | int dir_in = hs_ep->dir_in; | 777 | int dir_in = hs_ep->dir_in; |
| 786 | struct dwc2_dma_desc *desc = hs_ep->desc_list; | ||
| 787 | u32 mps = hs_ep->ep.maxpacket; | 778 | u32 mps = hs_ep->ep.maxpacket; |
| 788 | u32 maxsize = 0; | 779 | u32 maxsize = 0; |
| 789 | u32 offset = 0; | 780 | u32 offset = 0; |
| @@ -798,39 +789,77 @@ static void dwc2_gadget_config_nonisoc_xfer_ddma(struct dwc2_hsotg_ep *hs_ep, · 8 unmodified lines | |||
| 798 | hs_ep->desc_count = 1; | 789 | hs_ep->desc_count = 1; |
| 799 | 790 | ||
| 800 | for (i = 0; i < hs_ep->desc_count; ++i) { | 791 | for (i = 0; i < hs_ep->desc_count; ++i) { |
| 801 | desc->status = 0; | 792 | (*desc)->status = 0; |
| 802 | desc->status |= (DEV_DMA_BUFF_STS_HBUSY | 793 | (*desc)->status |= (DEV_DMA_BUFF_STS_HBUSY |
| 803 | << DEV_DMA_BUFF_STS_SHIFT); | 794 | << DEV_DMA_BUFF_STS_SHIFT); |
| 804 | 795 | ||
| 805 | if (len > maxsize) { | 796 | if (len > maxsize) { |
| 806 | if (!hs_ep->index && !dir_in) | 797 | if (!hs_ep->index && !dir_in) |
| 807 | desc->status |= (DEV_DMA_L | DEV_DMA_IOC); | 798 | (*desc)->status |= (DEV_DMA_L | DEV_DMA_IOC); |
| 808 | 799 | ||
| 809 | desc->status |= (maxsize << | 800 | (*desc)->status |= |
| 810 | DEV_DMA_NBYTES_SHIFT & mask); | 801 | maxsize << DEV_DMA_NBYTES_SHIFT & mask; |
| 811 | desc->buf = dma_buff + offset; | 802 | (*desc)->buf = dma_buff + offset; |
| 812 | 803 | ||
| 813 | len -= maxsize; | 804 | len -= maxsize; |
| 814 | offset += maxsize; | 805 | offset += maxsize; |
| 815 | } else { | 806 | } else { |
| 816 | desc->status |= (DEV_DMA_L | DEV_DMA_IOC); | 807 | if (true_last) |
| 808 | (*desc)->status |= (DEV_DMA_L | DEV_DMA_IOC); | ||
| 817 | 809 | ||
| 818 | if (dir_in) | 810 | if (dir_in) |
| 819 | desc->status |= (len % mps) ? DEV_DMA_SHORT : | 811 | (*desc)->status |= (len % mps) ? DEV_DMA_SHORT : |
| 820 | ((hs_ep->send_zlp) ? DEV_DMA_SHORT : 0); | 812 | ((hs_ep->send_zlp && true_last) ? |
| 821 | if (len > maxsize) | 813 | DEV_DMA_SHORT : 0); |
| 822 | dev_err(hsotg->dev, "wrong len %d\n", len); | ||
| 823 | 814 | ||
| 824 | desc->status |= | 815 | (*desc)->status |= |
| 825 | len << DEV_DMA_NBYTES_SHIFT & mask; | 816 | len << DEV_DMA_NBYTES_SHIFT & mask; |
| 826 | desc->buf = dma_buff + offset; | 817 | (*desc)->buf = dma_buff + offset; |
| 827 | } | 818 | } |
| 828 | 819 | ||
| 829 | desc->status &= ~DEV_DMA_BUFF_STS_MASK; | 820 | (*desc)->status &= ~DEV_DMA_BUFF_STS_MASK; |
| 830 | desc->status |= (DEV_DMA_BUFF_STS_HREADY | 821 | (*desc)->status |= (DEV_DMA_BUFF_STS_HREADY |
| 831 | << DEV_DMA_BUFF_STS_SHIFT); | 822 | << DEV_DMA_BUFF_STS_SHIFT); |
| 832 | desc++; | 823 | (*desc)++; |
| 824 | } | ||
| 825 | } | ||
| 826 | |||
| 827 | /* | ||
| 828 | * dwc2_gadget_config_nonisoc_xfer_ddma - prepare non ISOC DMA desc chain. | ||
| 829 | * @hs_ep: The endpoint | ||
| 830 | * @ureq: Request to transfer | ||
| 831 | * @offset: offset in bytes | ||
| 832 | * @len: Length of the transfer | ||
| 833 | * | ||
| 834 | * This function will iterate over descriptor chain and fill its entries | ||
| 835 | * with corresponding information based on transfer data. | ||
| 836 | */ | ||
| 837 | static void dwc2_gadget_config_nonisoc_xfer_ddma(struct dwc2_hsotg_ep *hs_ep, | ||
| 838 | struct usb_request *ureq, | ||
| 839 | unsigned int offset, | ||
| 840 | unsigned int len) | ||
| 841 | { | ||
| 842 | struct dwc2_dma_desc *desc = hs_ep->desc_list; | ||
| 843 | struct scatterlist *sg; | ||
| 844 | int i; | ||
| 845 | u8 desc_count = 0; | ||
| 846 | |||
| 847 | /* non-DMA sg buffer */ | ||
| 848 | if (!ureq->num_sgs) { | ||
| 849 | dwc2_gadget_fill_nonisoc_xfer_ddma_one(hs_ep, &desc, | ||
| 850 | ureq->dma + offset, len, true); | ||
| 851 | return; | ||
| 833 | } | 852 | } |
| 853 | |||
| 854 | /* DMA sg buffer */ | ||
| 855 | for_each_sg(ureq->sg, sg, ureq->num_sgs, i) { | ||
| 856 | dwc2_gadget_fill_nonisoc_xfer_ddma_one(hs_ep, &desc, | ||
| 857 | sg_dma_address(sg) + sg->offset, sg_dma_len(sg), | ||
| 858 | sg_is_last(sg)); | ||
| 859 | desc_count += hs_ep->desc_count; | ||
| 860 | } | ||
| 861 | |||
| 862 | hs_ep->desc_count = desc_count; | ||
| 834 | } | 863 | } |
| 835 | 864 | ||
| 836 | /* | 865 | /* |
| @@ -944,7 +973,13 @@ static void dwc2_gadget_start_isoc_ddma(struct dwc2_hsotg_ep *hs_ep) · 107 unmodified lines | |||
| 944 | 973 | ||
| 945 | hs_ep->next_desc = 0; | 974 | hs_ep->next_desc = 0; |
| 946 | list_for_each_entry_safe(hs_req, treq, &hs_ep->queue, queue) { | 975 | list_for_each_entry_safe(hs_req, treq, &hs_ep->queue, queue) { |
| 947 | ret = dwc2_gadget_fill_isoc_desc(hs_ep, hs_req->req.dma, | 976 | dma_addr_t dma_addr = hs_req->req.dma; |
| 977 | |||
| 978 | if (hs_req->req.num_sgs) { | ||
| 979 | WARN_ON(hs_req->req.num_sgs > 1); | ||
| 980 | dma_addr = sg_dma_address(hs_req->req.sg); | ||
| 981 | } | ||
| 982 | ret = dwc2_gadget_fill_isoc_desc(hs_ep, dma_addr, | ||
| 948 | hs_req->req.length); | 983 | hs_req->req.length); |
| 949 | if (ret) | 984 | if (ret) |
| 950 | break; | 985 | break; |
| @@ -1100,7 +1135,7 @@ static void dwc2_hsotg_start_req(struct dwc2_hsotg *hsotg, · 149 unmodified lines | |||
| 1100 | offset = ureq->actual; | 1135 | offset = ureq->actual; |
| 1101 | 1136 | ||
| 1102 | /* Fill DDMA chain entries */ | 1137 | /* Fill DDMA chain entries */ |
| 1103 | dwc2_gadget_config_nonisoc_xfer_ddma(hs_ep, ureq->dma + offset, | 1138 | dwc2_gadget_config_nonisoc_xfer_ddma(hs_ep, ureq, offset, |
| 1104 | length); | 1139 | length); |
| 1105 | 1140 | ||
| 1106 | /* write descriptor chain address to control register */ | 1141 | /* write descriptor chain address to control register */ |
| @@ -1399,7 +1434,13 @@ static int dwc2_hsotg_ep_queue(struct usb_ep *ep, struct usb_request *req, · 292 unmodified lines | |||
| 1399 | */ | 1434 | */ |
| 1400 | if (using_desc_dma(hs) && hs_ep->isochronous) { | 1435 | if (using_desc_dma(hs) && hs_ep->isochronous) { |
| 1401 | if (hs_ep->target_frame != TARGET_FRAME_INITIAL) { | 1436 | if (hs_ep->target_frame != TARGET_FRAME_INITIAL) { |
| 1402 | dwc2_gadget_fill_isoc_desc(hs_ep, hs_req->req.dma, | 1437 | dma_addr_t dma_addr = hs_req->req.dma; |
| 1438 | |||
| 1439 | if (hs_req->req.num_sgs) { | ||
| 1440 | WARN_ON(hs_req->req.num_sgs > 1); | ||
| 1441 | dma_addr = sg_dma_address(hs_req->req.sg); | ||
| 1442 | } | ||
| 1443 | dwc2_gadget_fill_isoc_desc(hs_ep, dma_addr, | ||
| 1403 | hs_req->req.length); | 1444 | hs_req->req.length); |
| 1404 | } | 1445 | } |
| 1405 | return 0; | 1446 | return 0; |
| @@ -1987,13 +2028,12 @@ static void dwc2_hsotg_program_zlp(struct dwc2_hsotg *hsotg, · 581 unmodified lines | |||
| 1987 | dev_dbg(hsotg->dev, "Receiving zero-length packet on ep%d\n", | 2028 | dev_dbg(hsotg->dev, "Receiving zero-length packet on ep%d\n", |
| 1988 | index); | 2029 | index); |
| 1989 | if (using_desc_dma(hsotg)) { | 2030 | if (using_desc_dma(hsotg)) { |
| 1990 | /* Not specific buffer needed for ep0 ZLP */ | ||
| 1991 | dma_addr_t dma = hs_ep->desc_list_dma; | ||
| 1992 | |||
| 1993 | if (!index) | 2031 | if (!index) |
| 1994 | dwc2_gadget_set_ep0_desc_chain(hsotg, hs_ep); | 2032 | dwc2_gadget_set_ep0_desc_chain(hsotg, hs_ep); |
| 1995 | 2033 | ||
| 1996 | dwc2_gadget_config_nonisoc_xfer_ddma(hs_ep, dma, 0); | 2034 | /* Not specific buffer needed for ep0 ZLP */ |
| 2035 | dwc2_gadget_fill_nonisoc_xfer_ddma_one(hs_ep, &hs_ep->desc_list, | ||
| 2036 | hs_ep->desc_list_dma, 0, true); | ||
| 1997 | } else { | 2037 | } else { |
| 1998 | dwc2_writel(hsotg, DXEPTSIZ_MC(1) | DXEPTSIZ_PKTCNT(1) | | 2038 | dwc2_writel(hsotg, DXEPTSIZ_MC(1) | DXEPTSIZ_PKTCNT(1) | |
| 1999 | DXEPTSIZ_XFERSIZE(0), | 2039 | DXEPTSIZ_XFERSIZE(0), |
| @@ -4005,6 +4045,7 @@ static int dwc2_hsotg_ep_enable(struct usb_ep *ep, · 2005 unmodified lines | |||
| 4005 | ret = -ENOMEM; | 4045 | ret = -ENOMEM; |
| 4006 | goto error1; | 4046 | goto error1; |
| 4007 | } | 4047 | } |
| 4048 | epctrl &= ~(DXEPCTL_TXFNUM_LIMIT << DXEPCTL_TXFNUM_SHIFT); | ||
| 4008 | hsotg->fifo_map |= 1 << fifo_index; | 4049 | hsotg->fifo_map |= 1 << fifo_index; |
| 4009 | epctrl |= DXEPCTL_TXFNUM(fifo_index); | 4050 | epctrl |= DXEPCTL_TXFNUM(fifo_index); |
| 4010 | hs_ep->fifo_index = fifo_index; | 4051 | hs_ep->fifo_index = fifo_index; |
| @@ -4385,6 +4426,7 @@ static int dwc2_hsotg_udc_start(struct usb_gadget *gadget, · 374 unmodified lines | |||
| 4385 | hsotg->enabled = 0; | 4426 | hsotg->enabled = 0; |
| 4386 | spin_unlock_irqrestore(&hsotg->lock, flags); | 4427 | spin_unlock_irqrestore(&hsotg->lock, flags); |
| 4387 | 4428 | ||
| 4429 | gadget->sg_supported = using_desc_dma(hsotg); | ||
| 4388 | dev_info(hsotg->dev, "bound driver %s\n", driver->driver.name); | 4430 | dev_info(hsotg->dev, "bound driver %s\n", driver->driver.name); |
| 4389 | 4431 | ||
| 4390 | return 0; | 4432 | return 0; |
| @@ -3981,10 +3981,8 @@ static struct dwc2_hcd_urb *dwc2_hcd_urb_alloc(struct dwc2_hsotg *hsotg, · 3980 unmodified lines | |||
| 3981 | gfp_t mem_flags) | 3981 | gfp_t mem_flags) |
| 3982 | { | 3982 | { |
| 3983 | struct dwc2_hcd_urb *urb; | 3983 | struct dwc2_hcd_urb *urb; |
| 3984 | u32 size = sizeof(*urb) + iso_desc_count * | ||
| 3985 | sizeof(struct dwc2_hcd_iso_packet_desc); | ||
| 3986 | 3984 | ||
| 3987 | urb = kzalloc(size, mem_flags); | 3985 | urb = kzalloc(struct_size(urb, iso_descs, iso_desc_count), mem_flags); |
| 3988 | if (urb) | 3986 | if (urb) |
| 3989 | urb->packet_count = iso_desc_count; | 3987 | urb->packet_count = iso_desc_count; |
| 3990 | return urb; | 3988 | return urb; |
| @@ -1,3 +1,5 @@ | |||
| 1 | # SPDX-License-Identifier: GPL-2.0 | ||
| 2 | |||
| 1 | config USB_DWC3 | 3 | config USB_DWC3 |
| 2 | tristate "DesignWare USB3 DRD Core Support" | 4 | tristate "DesignWare USB3 DRD Core Support" |
| 3 | depends on (USB || USB_GADGET) && HAS_DMA | 5 | depends on (USB || USB_GADGET) && HAS_DMA |
| @@ -86,11 +88,11 @@ config USB_DWC3_HAPS · 82 unmodified lines | |||
| 86 | platform, please say 'Y' or 'M' here. | 88 | platform, please say 'Y' or 'M' here. |
| 87 | 89 | ||
| 88 | config USB_DWC3_KEYSTONE | 90 | config USB_DWC3_KEYSTONE |
| 89 | tristate "Texas Instruments Keystone2 Platforms" | 91 | tristate "Texas Instruments Keystone2/AM654 Platforms" |
| 90 | depends on ARCH_KEYSTONE || COMPILE_TEST | 92 | depends on ARCH_KEYSTONE || ARCH_K3 || COMPILE_TEST |
| 91 | default USB_DWC3 | 93 | default USB_DWC3 |
| 92 | help | 94 | help |
| 93 | Support of USB2/3 functionality in TI Keystone2 platforms. | 95 | Support of USB2/3 functionality in TI Keystone2 and AM654 platforms. |
| 94 | Say 'Y' or 'M' here if you have one such device | 96 | Say 'Y' or 'M' here if you have one such device |
| 95 | 97 | ||
| 96 | config USB_DWC3_OF_SIMPLE | 98 | config USB_DWC3_OF_SIMPLE |
| @@ -692,7 +692,6 @@ struct dwc3_ep { · 691 unmodified lines | |||
| 692 | #define DWC3_EP_WEDGE BIT(2) | 692 | #define DWC3_EP_WEDGE BIT(2) |
| 693 | #define DWC3_EP_TRANSFER_STARTED BIT(3) | 693 | #define DWC3_EP_TRANSFER_STARTED BIT(3) |
| 694 | #define DWC3_EP_PENDING_REQUEST BIT(5) | 694 | #define DWC3_EP_PENDING_REQUEST BIT(5) |
| 695 | #define DWC3_EP_END_TRANSFER_PENDING BIT(7) | ||
| 696 | 695 | ||
| 697 | /* This last one is specific to EP0 */ | 696 | /* This last one is specific to EP0 */ |
| 698 | #define DWC3_EP0_DIR_IN BIT(31) | 697 | #define DWC3_EP0_DIR_IN BIT(31) |
| @@ -863,6 +862,7 @@ struct dwc3_hwparams { · 164 unmodified lines | |||
| 863 | * @num_pending_sgs: counter to pending sgs | 862 | * @num_pending_sgs: counter to pending sgs |
| 864 | * @num_queued_sgs: counter to the number of sgs which already got queued | 863 | * @num_queued_sgs: counter to the number of sgs which already got queued |
| 865 | * @remaining: amount of data remaining | 864 | * @remaining: amount of data remaining |
| 865 | * @status: internal dwc3 request status tracking | ||
| 866 | * @epnum: endpoint number to which this request refers | 866 | * @epnum: endpoint number to which this request refers |
| 867 | * @trb: pointer to struct dwc3_trb | 867 | * @trb: pointer to struct dwc3_trb |
| 868 | * @trb_dma: DMA address of @trb | 868 | * @trb_dma: DMA address of @trb |
| @@ -871,7 +871,6 @@ struct dwc3_hwparams { · 2 unmodified lines | |||
| 871 | * or unaligned OUT) | 871 | * or unaligned OUT) |
| 872 | * @direction: IN or OUT direction flag | 872 | * @direction: IN or OUT direction flag |
| 873 | * @mapped: true when request has been dma-mapped | 873 | * @mapped: true when request has been dma-mapped |
| 874 | * @started: request is started | ||
| 875 | */ | 874 | */ |
| 876 | struct dwc3_request { | 875 | struct dwc3_request { |
| 877 | struct usb_request request; | 876 | struct usb_request request; |
| @@ -883,6 +882,14 @@ struct dwc3_request { · 5 unmodified lines | |||
| 883 | unsigned num_pending_sgs; | 882 | unsigned num_pending_sgs; |
| 884 | unsigned int num_queued_sgs; | 883 | unsigned int num_queued_sgs; |
| 885 | unsigned remaining; | 884 | unsigned remaining; |
| 885 | |||
| 886 | unsigned int status; | ||
| 887 | #define DWC3_REQUEST_STATUS_QUEUED 0 | ||
| 888 | #define DWC3_REQUEST_STATUS_STARTED 1 | ||
| 889 | #define DWC3_REQUEST_STATUS_CANCELLED 2 | ||
| 890 | #define DWC3_REQUEST_STATUS_COMPLETED 3 | ||
| 891 | #define DWC3_REQUEST_STATUS_UNKNOWN -1 | ||
| 892 | |||
| 886 | u8 epnum; | 893 | u8 epnum; |
| 887 | struct dwc3_trb *trb; | 894 | struct dwc3_trb *trb; |
| 888 | dma_addr_t trb_dma; | 895 | dma_addr_t trb_dma; |
| @@ -892,7 +899,6 @@ struct dwc3_request { · 3 unmodified lines | |||
| 892 | unsigned needs_extra_trb:1; | 899 | unsigned needs_extra_trb:1; |
| 893 | unsigned direction:1; | 900 | unsigned direction:1; |
| 894 | unsigned mapped:1; | 901 | unsigned mapped:1; |
| 895 | unsigned started:1; | ||
| 896 | }; | 902 | }; |
| 897 | 903 | ||
| 898 | /* | 904 | /* |
| @@ -193,65 +193,69 @@ static inline const char *dwc3_ep0_state_string(enum dwc3_ep0_state state) · 192 unmodified lines | |||
| 193 | * dwc3_gadget_event_string - returns event name | 193 | * dwc3_gadget_event_string - returns event name |
| 194 | * @event: the event code | 194 | * @event: the event code |
| 195 | */ | 195 | */ |
| 196 | static inline const char * | 196 | static inline const char *dwc3_gadget_event_string(char *str, size_t size, |
| 197 | dwc3_gadget_event_string(char *str, const struct dwc3_event_devt *event) | 197 | const struct dwc3_event_devt *event) |
| 198 | { | 198 | { |
| 199 | enum dwc3_link_state state = event->event_info & DWC3_LINK_STATE_MASK; | 199 | enum dwc3_link_state state = event->event_info & DWC3_LINK_STATE_MASK; |
| 200 | 200 | ||
| 201 | switch (event->type) { | 201 | switch (event->type) { |
| 202 | case DWC3_DEVICE_EVENT_DISCONNECT: | 202 | case DWC3_DEVICE_EVENT_DISCONNECT: |
| 203 | sprintf(str, "Disconnect: [%s]", | 203 | snprintf(str, size, "Disconnect: [%s]", |
| 204 | dwc3_gadget_link_string(state)); | 204 | dwc3_gadget_link_string(state)); |
| 205 | break; | 205 | break; |
| 206 | case DWC3_DEVICE_EVENT_RESET: | 206 | case DWC3_DEVICE_EVENT_RESET: |
| 207 | sprintf(str, "Reset [%s]", dwc3_gadget_link_string(state)); | 207 | snprintf(str, size, "Reset [%s]", |
| 208 | dwc3_gadget_link_string(state)); | ||
| 208 | break; | 209 | break; |
| 209 | case DWC3_DEVICE_EVENT_CONNECT_DONE: | 210 | case DWC3_DEVICE_EVENT_CONNECT_DONE: |
| 210 | sprintf(str, "Connection Done [%s]", | 211 | snprintf(str, size, "Connection Done [%s]", |
| 211 | dwc3_gadget_link_string(state)); | 212 | dwc3_gadget_link_string(state)); |
| 212 | break; | 213 | break; |
| 213 | case DWC3_DEVICE_EVENT_LINK_STATUS_CHANGE: | 214 | case DWC3_DEVICE_EVENT_LINK_STATUS_CHANGE: |
| 214 | sprintf(str, "Link Change [%s]", | 215 | snprintf(str, size, "Link Change [%s]", |
| 215 | dwc3_gadget_link_string(state)); | 216 | dwc3_gadget_link_string(state)); |
| 216 | break; | 217 | break; |
| 217 | case DWC3_DEVICE_EVENT_WAKEUP: | 218 | case DWC3_DEVICE_EVENT_WAKEUP: |
| 218 | sprintf(str, "WakeUp [%s]", dwc3_gadget_link_string(state)); | 219 | snprintf(str, size, "WakeUp [%s]", |
| 220 | dwc3_gadget_link_string(state)); | ||
| 219 | break; | 221 | break; |
| 220 | case DWC3_DEVICE_EVENT_EOPF: | 222 | case DWC3_DEVICE_EVENT_EOPF: |
| 221 | sprintf(str, "End-Of-Frame [%s]", | 223 | snprintf(str, size, "End-Of-Frame [%s]", |
| 222 | dwc3_gadget_link_string(state)); | 224 | dwc3_gadget_link_string(state)); |
| 223 | break; | 225 | break; |
| 224 | case DWC3_DEVICE_EVENT_SOF: | 226 | case DWC3_DEVICE_EVENT_SOF: |
| 225 | sprintf(str, "Start-Of-Frame [%s]", | 227 | snprintf(str, size, "Start-Of-Frame [%s]", |
| 226 | dwc3_gadget_link_string(state)); | 228 | dwc3_gadget_link_string(state)); |
| 227 | break; | 229 | break; |
| 228 | case DWC3_DEVICE_EVENT_ERRATIC_ERROR: | 230 | case DWC3_DEVICE_EVENT_ERRATIC_ERROR: |
| 229 | sprintf(str, "Erratic Error [%s]", | 231 | snprintf(str, size, "Erratic Error [%s]", |
| 230 | dwc3_gadget_link_string(state)); | 232 | dwc3_gadget_link_string(state)); |
| 231 | break; | 233 | break; |
| 232 | case DWC3_DEVICE_EVENT_CMD_CMPL: | 234 | case DWC3_DEVICE_EVENT_CMD_CMPL: |
| 233 | sprintf(str, "Command Complete [%s]", | 235 | snprintf(str, size, "Command Complete [%s]", |
| 234 | dwc3_gadget_link_string(state)); | 236 | dwc3_gadget_link_string(state)); |
| 235 | break; | 237 | break; |
| 236 | case DWC3_DEVICE_EVENT_OVERFLOW: | 238 | case DWC3_DEVICE_EVENT_OVERFLOW: |
| 237 | sprintf(str, "Overflow [%s]", dwc3_gadget_link_string(state)); | 239 | snprintf(str, size, "Overflow [%s]", |
| 240 | dwc3_gadget_link_string(state)); | ||
| 238 | break; | 241 | break; |
| 239 | default: | 242 | default: |
| 240 | sprintf(str, "UNKNOWN"); | 243 | snprintf(str, size, "UNKNOWN"); |
| 241 | } | 244 | } |
| 242 | 245 | ||
| 243 | return str; | 246 | return str; |
| 244 | } | 247 | } |
| 245 | 248 | ||
| 246 | static inline void dwc3_decode_get_status(__u8 t, __u16 i, __u16 l, char *str) | 249 | static inline void dwc3_decode_get_status(__u8 t, __u16 i, __u16 l, char *str, |
| 250 | size_t size) | ||
| 247 | { | 251 | { |
| 248 | switch (t & USB_RECIP_MASK) { | 252 | switch (t & USB_RECIP_MASK) { |
| 249 | case USB_RECIP_INTERFACE: | 253 | case USB_RECIP_INTERFACE: |
| 250 | sprintf(str, "Get Interface Status(Intf = %d, Length = %d)", | 254 | snprintf(str, size, "Get Interface Status(Intf = %d, Length = %d)", |
| 251 | i, l); | 255 | i, l); |
| 252 | break; | 256 | break; |
| 253 | case USB_RECIP_ENDPOINT: | 257 | case USB_RECIP_ENDPOINT: |
| 254 | sprintf(str, "Get Endpoint Status(ep%d%s)", | 258 | snprintf(str, size, "Get Endpoint Status(ep%d%s)", |
| 255 | i & ~USB_DIR_IN, | 259 | i & ~USB_DIR_IN, |
| 256 | i & USB_DIR_IN ? "in" : "out"); | 260 | i & USB_DIR_IN ? "in" : "out"); |
| 257 | break; | 261 | break; |
| @@ -259,11 +263,11 @@ static inline void dwc3_decode_get_status(__u8 t, __u16 i, __u16 l, char *str) · 1 unmodified line | |||
| 259 | } | 263 | } |
| 260 | 264 | ||
| 261 | static inline void dwc3_decode_set_clear_feature(__u8 t, __u8 b, __u16 v, | 265 | static inline void dwc3_decode_set_clear_feature(__u8 t, __u8 b, __u16 v, |
| 262 | __u16 i, char *str) | 266 | __u16 i, char *str, size_t size) |
| 263 | { | 267 | { |
| 264 | switch (t & USB_RECIP_MASK) { | 268 | switch (t & USB_RECIP_MASK) { |
| 265 | case USB_RECIP_DEVICE: | 269 | case USB_RECIP_DEVICE: |
| 266 | sprintf(str, "%s Device Feature(%s%s)", | 270 | snprintf(str, size, "%s Device Feature(%s%s)", |
| 267 | b == USB_REQ_CLEAR_FEATURE ? "Clear" : "Set", | 271 | b == USB_REQ_CLEAR_FEATURE ? "Clear" : "Set", |
| 268 | ({char *s; | 272 | ({char *s; |
| 269 | switch (v) { | 273 | switch (v) { |
| @@ -311,13 +315,13 @@ static inline void dwc3_decode_set_clear_feature(__u8 t, __u8 b, __u16 v, · 41 unmodified lines | |||
| 311 | } s; }) : ""); | 315 | } s; }) : ""); |
| 312 | break; | 316 | break; |
| 313 | case USB_RECIP_INTERFACE: | 317 | case USB_RECIP_INTERFACE: |
| 314 | sprintf(str, "%s Interface Feature(%s)", | 318 | snprintf(str, size, "%s Interface Feature(%s)", |
| 315 | b == USB_REQ_CLEAR_FEATURE ? "Clear" : "Set", | 319 | b == USB_REQ_CLEAR_FEATURE ? "Clear" : "Set", |
| 316 | v == USB_INTRF_FUNC_SUSPEND ? | 320 | v == USB_INTRF_FUNC_SUSPEND ? |
| 317 | "Function Suspend" : "UNKNOWN"); | 321 | "Function Suspend" : "UNKNOWN"); |
| 318 | break; | 322 | break; |
| 319 | case USB_RECIP_ENDPOINT: | 323 | case USB_RECIP_ENDPOINT: |
| 320 | sprintf(str, "%s Endpoint Feature(%s ep%d%s)", | 324 | snprintf(str, size, "%s Endpoint Feature(%s ep%d%s)", |
| 321 | b == USB_REQ_CLEAR_FEATURE ? "Clear" : "Set", | 325 | b == USB_REQ_CLEAR_FEATURE ? "Clear" : "Set", |
| 322 | v == USB_ENDPOINT_HALT ? "Halt" : "UNKNOWN", | 326 | v == USB_ENDPOINT_HALT ? "Halt" : "UNKNOWN", |
| 323 | i & ~USB_DIR_IN, | 327 | i & ~USB_DIR_IN, |
| @@ -326,15 +330,15 @@ static inline void dwc3_decode_set_clear_feature(__u8 t, __u8 b, __u16 v, · 2 unmodified lines | |||
| 326 | } | 330 | } |
| 327 | } | 331 | } |
| 328 | 332 | ||
| 329 | static inline void dwc3_decode_set_address(__u16 v, char *str) | 333 | static inline void dwc3_decode_set_address(__u16 v, char *str, size_t size) |
| 330 | { | 334 | { |
| 331 | sprintf(str, "Set Address(Addr = %02x)", v); | 335 | snprintf(str, size, "Set Address(Addr = %02x)", v); |
| 332 | } | 336 | } |
| 333 | 337 | ||
| 334 | static inline void dwc3_decode_get_set_descriptor(__u8 t, __u8 b, __u16 v, | 338 | static inline void dwc3_decode_get_set_descriptor(__u8 t, __u8 b, __u16 v, |
| 335 | __u16 i, __u16 l, char *str) | 339 | __u16 i, __u16 l, char *str, size_t size) |
| 336 | { | 340 | { |
| 337 | sprintf(str, "%s %s Descriptor(Index = %d, Length = %d)", | 341 | snprintf(str, size, "%s %s Descriptor(Index = %d, Length = %d)", |
| 338 | b == USB_REQ_GET_DESCRIPTOR ? "Get" : "Set", | 342 | b == USB_REQ_GET_DESCRIPTOR ? "Get" : "Set", |
| 339 | ({ char *s; | 343 | ({ char *s; |
| 340 | switch (v >> 8) { | 344 | switch (v >> 8) { |
| @@ -393,87 +397,92 @@ static inline void dwc3_decode_get_set_descriptor(__u8 t, __u8 b, __u16 v, · 52 unmodified lines | |||
| 393 | } | 397 | } |
| 394 | 398 | ||
| 395 | 399 | ||
| 396 | static inline void dwc3_decode_get_configuration(__u16 l, char *str) | 400 | static inline void dwc3_decode_get_configuration(__u16 l, char *str, |
| 401 | size_t size) | ||
| 397 | { | 402 | { |
| 398 | sprintf(str, "Get Configuration(Length = %d)", l); | 403 | snprintf(str, size, "Get Configuration(Length = %d)", l); |
| 399 | } | 404 | } |
| 400 | 405 | ||
| 401 | static inline void dwc3_decode_set_configuration(__u8 v, char *str) | 406 | static inline void dwc3_decode_set_configuration(__u8 v, char *str, size_t size) |
| 402 | { | 407 | { |
| 403 | sprintf(str, "Set Configuration(Config = %d)", v); | 408 | snprintf(str, size, "Set Configuration(Config = %d)", v); |
| 404 | } | 409 | } |
| 405 | 410 | ||
| 406 | static inline void dwc3_decode_get_intf(__u16 i, __u16 l, char *str) | 411 | static inline void dwc3_decode_get_intf(__u16 i, __u16 l, char *str, |
| 412 | size_t size) | ||
| 407 | { | 413 | { |
| 408 | sprintf(str, "Get Interface(Intf = %d, Length = %d)", i, l); | 414 | snprintf(str, size, "Get Interface(Intf = %d, Length = %d)", i, l); |
| 409 | } | 415 | } |
| 410 | 416 | ||
| 411 | static inline void dwc3_decode_set_intf(__u8 v, __u16 i, char *str) | 417 | static inline void dwc3_decode_set_intf(__u8 v, __u16 i, char *str, size_t size) |
| 412 | { | 418 | { |
| 413 | sprintf(str, "Set Interface(Intf = %d, Alt.Setting = %d)", i, v); | 419 | snprintf(str, size, "Set Interface(Intf = %d, Alt.Setting = %d)", i, v); |
| 414 | } | 420 | } |
| 415 | 421 | ||
| 416 | static inline void dwc3_decode_synch_frame(__u16 i, __u16 l, char *str) | 422 | static inline void dwc3_decode_synch_frame(__u16 i, __u16 l, char *str, |
| 423 | size_t size) | ||
| 417 | { | 424 | { |
| 418 | sprintf(str, "Synch Frame(Endpoint = %d, Length = %d)", i, l); | 425 | snprintf(str, size, "Synch Frame(Endpoint = %d, Length = %d)", i, l); |
| 419 | } | 426 | } |
| 420 | 427 | ||
| 421 | static inline void dwc3_decode_set_sel(__u16 l, char *str) | 428 | static inline void dwc3_decode_set_sel(__u16 l, char *str, size_t size) |
| 422 | { | 429 | { |
| 423 | sprintf(str, "Set SEL(Length = %d)", l); | 430 | snprintf(str, size, "Set SEL(Length = %d)", l); |
| 424 | } | 431 | } |
| 425 | 432 | ||
| 426 | static inline void dwc3_decode_set_isoch_delay(__u8 v, char *str) | 433 | static inline void dwc3_decode_set_isoch_delay(__u8 v, char *str, size_t size) |
| 427 | { | 434 | { |
| 428 | sprintf(str, "Set Isochronous Delay(Delay = %d ns)", v); | 435 | snprintf(str, size, "Set Isochronous Delay(Delay = %d ns)", v); |
| 429 | } | 436 | } |
| 430 | 437 | ||
| 431 | /** | 438 | /** |
| 432 | * dwc3_decode_ctrl - returns a string represetion of ctrl request | 439 | * dwc3_decode_ctrl - returns a string represetion of ctrl request |
| 433 | */ | 440 | */ |
| 434 | static inline const char *dwc3_decode_ctrl(char *str, __u8 bRequestType, | 441 | static inline const char *dwc3_decode_ctrl(char *str, size_t size, |
| 435 | __u8 bRequest, __u16 wValue, __u16 wIndex, __u16 wLength) | 442 | __u8 bRequestType, __u8 bRequest, __u16 wValue, __u16 wIndex, |
| 443 | __u16 wLength) | ||
| 436 | { | 444 | { |
| 437 | switch (bRequest) { | 445 | switch (bRequest) { |
| 438 | case USB_REQ_GET_STATUS: | 446 | case USB_REQ_GET_STATUS: |
| 439 | dwc3_decode_get_status(bRequestType, wIndex, wLength, str); | 447 | dwc3_decode_get_status(bRequestType, wIndex, wLength, str, |
| 448 | size); | ||
| 440 | break; | 449 | break; |
| 441 | case USB_REQ_CLEAR_FEATURE: | 450 | case USB_REQ_CLEAR_FEATURE: |
| 442 | case USB_REQ_SET_FEATURE: | 451 | case USB_REQ_SET_FEATURE: |
| 443 | dwc3_decode_set_clear_feature(bRequestType, bRequest, wValue, | 452 | dwc3_decode_set_clear_feature(bRequestType, bRequest, wValue, |
| 444 | wIndex, str); | 453 | wIndex, str, size); |
| 445 | break; | 454 | break; |
| 446 | case USB_REQ_SET_ADDRESS: | 455 | case USB_REQ_SET_ADDRESS: |
| 447 | dwc3_decode_set_address(wValue, str); | 456 | dwc3_decode_set_address(wValue, str, size); |
| 448 | break; | 457 | break; |
| 449 | case USB_REQ_GET_DESCRIPTOR: | 458 | case USB_REQ_GET_DESCRIPTOR: |
| 450 | case USB_REQ_SET_DESCRIPTOR: | 459 | case USB_REQ_SET_DESCRIPTOR: |
| 451 | dwc3_decode_get_set_descriptor(bRequestType, bRequest, wValue, | 460 | dwc3_decode_get_set_descriptor(bRequestType, bRequest, wValue, |
| 452 | wIndex, wLength, str); | 461 | wIndex, wLength, str, size); |
| 453 | break; | 462 | break; |
| 454 | case USB_REQ_GET_CONFIGURATION: | 463 | case USB_REQ_GET_CONFIGURATION: |
| 455 | dwc3_decode_get_configuration(wLength, str); | 464 | dwc3_decode_get_configuration(wLength, str, size); |
| 456 | break; | 465 | break; |
| 457 | case USB_REQ_SET_CONFIGURATION: | 466 | case USB_REQ_SET_CONFIGURATION: |
| 458 | dwc3_decode_set_configuration(wValue, str); | 467 | dwc3_decode_set_configuration(wValue, str, size); |
| 459 | break; | 468 | break; |
| 460 | case USB_REQ_GET_INTERFACE: | 469 | case USB_REQ_GET_INTERFACE: |
| 461 | dwc3_decode_get_intf(wIndex, wLength, str); | 470 | dwc3_decode_get_intf(wIndex, wLength, str, size); |
| 462 | break; | 471 | break; |
| 463 | case USB_REQ_SET_INTERFACE: | 472 | case USB_REQ_SET_INTERFACE: |
| 464 | dwc3_decode_set_intf(wValue, wIndex, str); | 473 | dwc3_decode_set_intf(wValue, wIndex, str, size); |
| 465 | break; | 474 | break; |
| 466 | case USB_REQ_SYNCH_FRAME: | 475 | case USB_REQ_SYNCH_FRAME: |
| 467 | dwc3_decode_synch_frame(wIndex, wLength, str); | 476 | dwc3_decode_synch_frame(wIndex, wLength, str, size); |
| 468 | break; | 477 | break; |
| 469 | case USB_REQ_SET_SEL: | 478 | case USB_REQ_SET_SEL: |
| 470 | dwc3_decode_set_sel(wLength, str); | 479 | dwc3_decode_set_sel(wLength, str, size); |
| 471 | break; | 480 | break; |
| 472 | case USB_REQ_SET_ISOCH_DELAY: | 481 | case USB_REQ_SET_ISOCH_DELAY: |
| 473 | dwc3_decode_set_isoch_delay(wValue, str); | 482 | dwc3_decode_set_isoch_delay(wValue, str, size); |
| 474 | break; | 483 | break; |
| 475 | default: | 484 | default: |
| 476 | sprintf(str, "%02x %02x %02x %02x %02x %02x %02x %02x", | 485 | snprintf(str, size, "%02x %02x %02x %02x %02x %02x %02x %02x", |
| 477 | bRequestType, bRequest, | 486 | bRequestType, bRequest, |
| 478 | cpu_to_le16(wValue) & 0xff, | 487 | cpu_to_le16(wValue) & 0xff, |
| 479 | cpu_to_le16(wValue) >> 8, | 488 | cpu_to_le16(wValue) >> 8, |
| @@ -490,16 +499,15 @@ static inline const char *dwc3_decode_ctrl(char *str, __u8 bRequestType, · 10 unmodified lines | |||
| 490 | * dwc3_ep_event_string - returns event name | 499 | * dwc3_ep_event_string - returns event name |
| 491 | * @event: then event code | 500 | * @event: then event code |
| 492 | */ | 501 | */ |
| 493 | static inline const char * | 502 | static inline const char *dwc3_ep_event_string(char *str, size_t size, |
| 494 | dwc3_ep_event_string(char *str, const struct dwc3_event_depevt *event, | 503 | const struct dwc3_event_depevt *event, u32 ep0state) |
| 495 | u32 ep0state) | ||
| 496 | { | 504 | { |
| 497 | u8 epnum = event->endpoint_number; | 505 | u8 epnum = event->endpoint_number; |
| 498 | size_t len; | 506 | size_t len; |
| 499 | int status; | 507 | int status; |
| 500 | int ret; | 508 | int ret; |
| 501 | 509 | ||
| 502 | ret = sprintf(str, "ep%d%s: ", epnum >> 1, | 510 | ret = snprintf(str, size, "ep%d%s: ", epnum >> 1, |
| 503 | (epnum & 1) ? "in" : "out"); | 511 | (epnum & 1) ? "in" : "out"); |
| 504 | if (ret < 0) | 512 | if (ret < 0) |
| 505 | return "UNKNOWN"; | 513 | return "UNKNOWN"; |
| @@ -509,7 +517,7 @@ dwc3_ep_event_string(char *str, const struct dwc3_event_depevt *event, · 3 unmodified lines | |||
| 509 | switch (event->endpoint_event) { | 517 | switch (event->endpoint_event) { |
| 510 | case DWC3_DEPEVT_XFERCOMPLETE: | 518 | case DWC3_DEPEVT_XFERCOMPLETE: |
| 511 | len = strlen(str); | 519 | len = strlen(str); |
| 512 | sprintf(str + len, "Transfer Complete (%c%c%c)", | 520 | snprintf(str + len, size - len, "Transfer Complete (%c%c%c)", |
| 513 | status & DEPEVT_STATUS_SHORT ? 'S' : 's', | 521 | status & DEPEVT_STATUS_SHORT ? 'S' : 's', |
| 514 | status & DEPEVT_STATUS_IOC ? 'I' : 'i', | 522 | status & DEPEVT_STATUS_IOC ? 'I' : 'i', |
| 515 | status & DEPEVT_STATUS_LST ? 'L' : 'l'); | 523 | status & DEPEVT_STATUS_LST ? 'L' : 'l'); |
| @@ -517,12 +525,13 @@ dwc3_ep_event_string(char *str, const struct dwc3_event_depevt *event, · 1 unmodified line | |||
| 517 | len = strlen(str); | 525 | len = strlen(str); |
| 518 | 526 | ||
| 519 | if (epnum <= 1) | 527 | if (epnum <= 1) |
| 520 | sprintf(str + len, " [%s]", dwc3_ep0_state_string(ep0state)); | 528 | snprintf(str + len, size - len, " [%s]", |
| 529 | dwc3_ep0_state_string(ep0state)); | ||
| 521 | break; | 530 | break; |
| 522 | case DWC3_DEPEVT_XFERINPROGRESS: | 531 | case DWC3_DEPEVT_XFERINPROGRESS: |
| 523 | len = strlen(str); | 532 | len = strlen(str); |
| 524 | 533 | ||
| 525 | sprintf(str + len, "Transfer In Progress [%d] (%c%c%c)", | 534 | snprintf(str + len, size - len, "Transfer In Progress [%d] (%c%c%c)", |
| 526 | event->parameters, | 535 | event->parameters, |
| 527 | status & DEPEVT_STATUS_SHORT ? 'S' : 's', | 536 | status & DEPEVT_STATUS_SHORT ? 'S' : 's', |
| 528 | status & DEPEVT_STATUS_IOC ? 'I' : 'i', | 537 | status & DEPEVT_STATUS_IOC ? 'I' : 'i', |
| @@ -531,47 +540,51 @@ dwc3_ep_event_string(char *str, const struct dwc3_event_depevt *event, · 2 unmodified lines | |||
| 531 | case DWC3_DEPEVT_XFERNOTREADY: | 540 | case DWC3_DEPEVT_XFERNOTREADY: |
| 532 | len = strlen(str); | 541 | len = strlen(str); |
| 533 | 542 | ||
| 534 | sprintf(str + len, "Transfer Not Ready [%d]%s", | 543 | snprintf(str + len, size - len, "Transfer Not Ready [%d]%s", |
| 535 | event->parameters, | 544 | event->parameters, |
| 536 | status & DEPEVT_STATUS_TRANSFER_ACTIVE ? | 545 | status & DEPEVT_STATUS_TRANSFER_ACTIVE ? |
| 537 | " (Active)" : " (Not Active)"); | 546 | " (Active)" : " (Not Active)"); |
| 538 | 547 | ||
| 548 | len = strlen(str); | ||
| 549 | |||
| 539 | /* Control Endpoints */ | 550 | /* Control Endpoints */ |
| 540 | if (epnum <= 1) { | 551 | if (epnum <= 1) { |
| 541 | int phase = DEPEVT_STATUS_CONTROL_PHASE(event->status); | 552 | int phase = DEPEVT_STATUS_CONTROL_PHASE(event->status); |
| 542 | 553 | ||
| 543 | switch (phase) { | 554 | switch (phase) { |
| 544 | case DEPEVT_STATUS_CONTROL_DATA: | 555 | case DEPEVT_STATUS_CONTROL_DATA: |
| 545 | strcat(str, " [Data Phase]"); | 556 | snprintf(str + ret, size - ret, |
| 557 | " [Data Phase]"); | ||
| 546 | break; | 558 | break; |
| 547 | case DEPEVT_STATUS_CONTROL_STATUS: | 559 | case DEPEVT_STATUS_CONTROL_STATUS: |
| 548 | strcat(str, " [Status Phase]"); | 560 | snprintf(str + ret, size - ret, |
| 561 | " [Status Phase]"); | ||
| 549 | } | 562 | } |
| 550 | } | 563 | } |
| 551 | break; | 564 | break; |
| 552 | case DWC3_DEPEVT_RXTXFIFOEVT: | 565 | case DWC3_DEPEVT_RXTXFIFOEVT: |
| 553 | strcat(str, "FIFO"); | 566 | snprintf(str + ret, size - ret, "FIFO"); |
| 554 | break; | 567 | break; |
| 555 | case DWC3_DEPEVT_STREAMEVT: | 568 | case DWC3_DEPEVT_STREAMEVT: |
| 556 | status = event->status; | 569 | status = event->status; |
| 557 | 570 | ||
| 558 | switch (status) { | 571 | switch (status) { |
| 559 | case DEPEVT_STREAMEVT_FOUND: | 572 | case DEPEVT_STREAMEVT_FOUND: |
| 560 | sprintf(str + ret, " Stream %d Found", | 573 | snprintf(str + ret, size - ret, " Stream %d Found", |
| 561 | event->parameters); | 574 | event->parameters); |
| 562 | break; | 575 | break; |
| 563 | case DEPEVT_STREAMEVT_NOTFOUND: | 576 | case DEPEVT_STREAMEVT_NOTFOUND: |
| 564 | default: | 577 | default: |
| 565 | strcat(str, " Stream Not Found"); | 578 | snprintf(str + ret, size - ret, " Stream Not Found"); |
| 566 | break; | 579 | break; |
| 567 | } | 580 | } |
| 568 | 581 | ||
| 569 | break; | 582 | break; |
| 570 | case DWC3_DEPEVT_EPCMDCMPLT: | 583 | case DWC3_DEPEVT_EPCMDCMPLT: |
| 571 | strcat(str, "Endpoint Command Complete"); | 584 | snprintf(str + ret, size - ret, "Endpoint Command Complete"); |
| 572 | break; | 585 | break; |
| 573 | default: | 586 | default: |
| 574 | sprintf(str, "UNKNOWN"); | 587 | snprintf(str, size, "UNKNOWN"); |
| 575 | } | 588 | } |
| 576 | 589 | ||
| 577 | return str; | 590 | return str; |
| @@ -611,14 +624,15 @@ static inline const char *dwc3_gadget_event_type_string(u8 event) · 33 unmodified lines | |||
| 611 | } | 624 | } |
| 612 | } | 625 | } |
| 613 | 626 | ||
| 614 | static inline const char *dwc3_decode_event(char *str, u32 event, u32 ep0state) | 627 | static inline const char *dwc3_decode_event(char *str, size_t size, u32 event, |
| 628 | u32 ep0state) | ||
| 615 | { | 629 | { |
| 616 | const union dwc3_event evt = (union dwc3_event) event; | 630 | const union dwc3_event evt = (union dwc3_event) event; |
| 617 | 631 | ||
| 618 | if (evt.type.is_devspec) | 632 | if (evt.type.is_devspec) |
| 619 | return dwc3_gadget_event_string(str, &evt.devt); | 633 | return dwc3_gadget_event_string(str, size, &evt.devt); |
| 620 | else | 634 | else |
| 621 | return dwc3_ep_event_string(str, &evt.depevt, ep0state); | 635 | return dwc3_ep_event_string(str, size, &evt.depevt, ep0state); |
| 622 | } | 636 | } |
| 623 | 637 | ||
| 624 | static inline const char *dwc3_ep_cmd_status_string(int status) | 638 | static inline const char *dwc3_ep_cmd_status_string(int status) |
| @@ -457,8 +457,13 @@ static struct extcon_dev *dwc3_get_extcon(struct dwc3 *dwc) · 456 unmodified lines | |||
| 457 | * This device property is for kernel internal use only and | 457 | * This device property is for kernel internal use only and |
| 458 | * is expected to be set by the glue code. | 458 | * is expected to be set by the glue code. |
| 459 | */ | 459 | */ |
| 460 | if (device_property_read_string(dev, "linux,extcon-name", &name) == 0) | 460 | if (device_property_read_string(dev, "linux,extcon-name", &name) == 0) { |
| 461 | return extcon_get_extcon_dev(name); | 461 | edev = extcon_get_extcon_dev(name); |
| 462 | if (!edev) | ||
| 463 | return ERR_PTR(-EPROBE_DEFER); | ||
| 464 | |||
| 465 | return edev; | ||
| 466 | } | ||
| 462 | 467 | ||
| 463 | np_phy = of_parse_phandle(dev->of_node, "phys", 0); | 468 | np_phy = of_parse_phandle(dev->of_node, "phys", 0); |
| 464 | np_conn = of_graph_get_remote_node(np_phy, -1, -1); | 469 | np_conn = of_graph_get_remote_node(np_phy, -1, -1); |
| @@ -106,6 +106,15 @@ static const struct pci_device_id dwc3_haps_id_table[] = { · 105 unmodified lines | |||
| 106 | { | 106 | { |
| 107 | PCI_DEVICE(PCI_VENDOR_ID_SYNOPSYS, | 107 | PCI_DEVICE(PCI_VENDOR_ID_SYNOPSYS, |
| 108 | PCI_DEVICE_ID_SYNOPSYS_HAPSUSB3), | 108 | PCI_DEVICE_ID_SYNOPSYS_HAPSUSB3), |
| 109 | /* | ||
| 110 | * i.MX6QP and i.MX7D platform use a PCIe controller with the | ||
| 111 | * same VID and PID as this USB controller. The system may | ||
| 112 | * incorrectly match this driver to that PCIe controller. To | ||
| 113 | * workaround this, specifically use class type USB to prevent | ||
| 114 | * incorrect driver matching. | ||
| 115 | */ | ||
| 116 | .class = (PCI_CLASS_SERIAL_USB << 8), | ||
| 117 | .class_mask = 0xffff00, | ||
| 109 | }, | 118 | }, |
| 110 | { | 119 | { |
| 111 | PCI_DEVICE(PCI_VENDOR_ID_SYNOPSYS, | 120 | PCI_DEVICE(PCI_VENDOR_ID_SYNOPSYS, |
| @@ -106,6 +106,10 @@ static int kdwc3_probe(struct platform_device *pdev) · 105 unmodified lines | |||
| 106 | goto err_irq; | 106 | goto err_irq; |
| 107 | } | 107 | } |
| 108 | 108 | ||
| 109 | /* IRQ processing not required currently for AM65 */ | ||
| 110 | if (of_device_is_compatible(node, "ti,am654-dwc3")) | ||
| 111 | goto skip_irq; | ||
| 112 | |||
| 109 | irq = platform_get_irq(pdev, 0); | 113 | irq = platform_get_irq(pdev, 0); |
| 110 | if (irq < 0) { | 114 | if (irq < 0) { |
| 111 | dev_err(&pdev->dev, "missing irq\n"); | 115 | dev_err(&pdev->dev, "missing irq\n"); |
| @@ -123,6 +127,7 @@ static int kdwc3_probe(struct platform_device *pdev) · 11 unmodified lines | |||
| 123 | 127 | ||
| 124 | kdwc3_enable_irqs(kdwc); | 128 | kdwc3_enable_irqs(kdwc); |
| 125 | 129 | ||
| 130 | skip_irq: | ||
| 126 | error = of_platform_populate(node, NULL, NULL, dev); | 131 | error = of_platform_populate(node, NULL, NULL, dev); |
| 127 | if (error) { | 132 | if (error) { |
| 128 | dev_err(&pdev->dev, "failed to create dwc3 core\n"); | 133 | dev_err(&pdev->dev, "failed to create dwc3 core\n"); |
| @@ -152,8 +157,11 @@ static int kdwc3_remove_core(struct device *dev, void *c) · 23 unmodified lines | |||
| 152 | static int kdwc3_remove(struct platform_device *pdev) | 157 | static int kdwc3_remove(struct platform_device *pdev) |
| 153 | { | 158 | { |
| 154 | struct dwc3_keystone *kdwc = platform_get_drvdata(pdev); | 159 | struct dwc3_keystone *kdwc = platform_get_drvdata(pdev); |
| 160 | struct device_node *node = pdev->dev.of_node; | ||
| 161 | |||
| 162 | if (!of_device_is_compatible(node, "ti,am654-dwc3")) | ||
| 163 | kdwc3_disable_irqs(kdwc); | ||
| 155 | 164 | ||
| 156 | kdwc3_disable_irqs(kdwc); | ||
| 157 | device_for_each_child(&pdev->dev, NULL, kdwc3_remove_core); | 165 | device_for_each_child(&pdev->dev, NULL, kdwc3_remove_core); |
| 158 | pm_runtime_put_sync(kdwc->dev); | 166 | pm_runtime_put_sync(kdwc->dev); |
| 159 | pm_runtime_disable(kdwc->dev); | 167 | pm_runtime_disable(kdwc->dev); |
| @@ -165,6 +173,7 @@ static int kdwc3_remove(struct platform_device *pdev) · 5 unmodified lines | |||
| 165 | 173 | ||
| 166 | static const struct of_device_id kdwc3_of_match[] = { | 174 | static const struct of_device_id kdwc3_of_match[] = { |
| 167 | { .compatible = "ti,keystone-dwc3", }, | 175 | { .compatible = "ti,keystone-dwc3", }, |
| 176 | { .compatible = "ti,am654-dwc3" }, | ||
| 168 | {}, | 177 | {}, |
| 169 | }; | 178 | }; |
| 170 | MODULE_DEVICE_TABLE(of, kdwc3_of_match); | 179 | MODULE_DEVICE_TABLE(of, kdwc3_of_match); |
| @@ -595,6 +595,7 @@ static const struct dev_pm_ops dwc3_qcom_dev_pm_ops = { · 594 unmodified lines | |||
| 595 | static const struct of_device_id dwc3_qcom_of_match[] = { | 595 | static const struct of_device_id dwc3_qcom_of_match[] = { |
| 596 | { .compatible = "qcom,dwc3" }, | 596 | { .compatible = "qcom,dwc3" }, |
| 597 | { .compatible = "qcom,msm8996-dwc3" }, | 597 | { .compatible = "qcom,msm8996-dwc3" }, |
| 598 | { .compatible = "qcom,msm8998-dwc3" }, | ||
| 598 | { .compatible = "qcom,sdm845-dwc3" }, | 599 | { .compatible = "qcom,sdm845-dwc3" }, |
| 599 | { } | 600 | { } |
| 600 | }; | 601 | }; |
| @@ -174,7 +174,6 @@ static void dwc3_gadget_del_and_unmap_request(struct dwc3_ep *dep, · 173 unmodified lines | |||
| 174 | { | 174 | { |
| 175 | struct dwc3 *dwc = dep->dwc; | 175 | struct dwc3 *dwc = dep->dwc; |
| 176 | 176 | ||
| 177 | req->started = false; | ||
| 178 | list_del(&req->list); | 177 | list_del(&req->list); |
| 179 | req->remaining = 0; | 178 | req->remaining = 0; |
| 180 | req->needs_extra_trb = false; | 179 | req->needs_extra_trb = false; |
| @@ -209,6 +208,7 @@ void dwc3_gadget_giveback(struct dwc3_ep *dep, struct dwc3_request *req, · 28 unmodified lines | |||
| 209 | struct dwc3 *dwc = dep->dwc; | 208 | struct dwc3 *dwc = dep->dwc; |
| 210 | 209 | ||
| 211 | dwc3_gadget_del_and_unmap_request(dep, req, status); | 210 | dwc3_gadget_del_and_unmap_request(dep, req, status); |
| 211 | req->status = DWC3_REQUEST_STATUS_COMPLETED; | ||
| 212 | 212 | ||
| 213 | spin_unlock(&dwc->lock); | 213 | spin_unlock(&dwc->lock); |
| 214 | usb_gadget_giveback_request(&dep->endpoint, &req->request); | 214 | usb_gadget_giveback_request(&dep->endpoint, &req->request); |
| @@ -384,19 +384,9 @@ int dwc3_send_gadget_ep_cmd(struct dwc3_ep *dep, unsigned cmd, · 169 unmodified lines | |||
| 384 | 384 | ||
| 385 | trace_dwc3_gadget_ep_cmd(dep, cmd, params, cmd_status); | 385 | trace_dwc3_gadget_ep_cmd(dep, cmd, params, cmd_status); |
| 386 | 386 | ||
| 387 | if (ret == 0) { | 387 | if (ret == 0 && DWC3_DEPCMD_CMD(cmd) == DWC3_DEPCMD_STARTTRANSFER) { |
| 388 | switch (DWC3_DEPCMD_CMD(cmd)) { | 388 | dep->flags |= DWC3_EP_TRANSFER_STARTED; |
| 389 | case DWC3_DEPCMD_STARTTRANSFER: | 389 | dwc3_gadget_ep_get_transfer_index(dep); |
| 390 | dep->flags |= DWC3_EP_TRANSFER_STARTED; | ||
| 391 | dwc3_gadget_ep_get_transfer_index(dep); | ||
| 392 | break; | ||
| 393 | case DWC3_DEPCMD_ENDTRANSFER: | ||
| 394 | dep->flags &= ~DWC3_EP_TRANSFER_STARTED; | ||
| 395 | break; | ||
| 396 | default: | ||
| 397 | /* nothing */ | ||
| 398 | break; | ||
| 399 | } | ||
| 400 | } | 390 | } |
| 401 | 391 | ||
| 402 | if (saved_config) { | 392 | if (saved_config) { |
| @@ -642,7 +632,6 @@ static int __dwc3_gadget_ep_enable(struct dwc3_ep *dep, unsigned int action) · 239 unmodified lines | |||
| 642 | 632 | ||
| 643 | dep->type = usb_endpoint_type(desc); | 633 | dep->type = usb_endpoint_type(desc); |
| 644 | dep->flags |= DWC3_EP_ENABLED; | 634 | dep->flags |= DWC3_EP_ENABLED; |
| 645 | dep->flags &= ~DWC3_EP_END_TRANSFER_PENDING; | ||
| 646 | 635 | ||
| 647 | reg = dwc3_readl(dwc->regs, DWC3_DALEPENA); | 636 | reg = dwc3_readl(dwc->regs, DWC3_DALEPENA); |
| 648 | reg |= DWC3_DALEPENA_EP(dep->number); | 637 | reg |= DWC3_DALEPENA_EP(dep->number); |
| @@ -698,12 +687,13 @@ out: · 49 unmodified lines | |||
| 698 | return 0; | 687 | return 0; |
| 699 | } | 688 | } |
| 700 | 689 | ||
| 701 | static void dwc3_stop_active_transfer(struct dwc3_ep *dep, bool force); | 690 | static void dwc3_stop_active_transfer(struct dwc3_ep *dep, bool force, |
| 691 | bool interrupt); | ||
| 702 | static void dwc3_remove_requests(struct dwc3 *dwc, struct dwc3_ep *dep) | 692 | static void dwc3_remove_requests(struct dwc3 *dwc, struct dwc3_ep *dep) |
| 703 | { | 693 | { |
| 704 | struct dwc3_request *req; | 694 | struct dwc3_request *req; |
| 705 | 695 | ||
| 706 | dwc3_stop_active_transfer(dep, true); | 696 | dwc3_stop_active_transfer(dep, true, false); |
| 707 | 697 | ||
| 708 | /* - giveback all requests to gadget driver */ | 698 | /* - giveback all requests to gadget driver */ |
| 709 | while (!list_empty(&dep->started_list)) { | 699 | while (!list_empty(&dep->started_list)) { |
| @@ -748,7 +738,7 @@ static int __dwc3_gadget_ep_disable(struct dwc3_ep *dep) · 38 unmodified lines | |||
| 748 | 738 | ||
| 749 | dep->stream_capable = false; | 739 | dep->stream_capable = false; |
| 750 | dep->type = 0; | 740 | dep->type = 0; |
| 751 | dep->flags &= DWC3_EP_END_TRANSFER_PENDING; | 741 | dep->flags = 0; |
| 752 | 742 | ||
| 753 | /* Clear out the ep descriptors for non-ep0 */ | 743 | /* Clear out the ep descriptors for non-ep0 */ |
| 754 | if (dep->number > 1) { | 744 | if (dep->number > 1) { |
| @@ -847,6 +837,7 @@ static struct usb_request *dwc3_gadget_ep_alloc_request(struct usb_ep *ep, · 92 unmodified lines | |||
| 847 | req->direction = dep->direction; | 837 | req->direction = dep->direction; |
| 848 | req->epnum = dep->number; | 838 | req->epnum = dep->number; |
| 849 | req->dep = dep; | 839 | req->dep = dep; |
| 840 | req->status = DWC3_REQUEST_STATUS_UNKNOWN; | ||
| 850 | 841 | ||
| 851 | trace_dwc3_alloc_request(req); | 842 | trace_dwc3_alloc_request(req); |
| 852 | 843 | ||
| @@ -1360,7 +1351,7 @@ static int dwc3_gadget_start_isoc_quirk(struct dwc3_ep *dep) · 507 unmodified lines | |||
| 1360 | * to wait for the next XferNotReady to test the command again | 1351 | * to wait for the next XferNotReady to test the command again |
| 1361 | */ | 1352 | */ |
| 1362 | if (cmd_status == 0) { | 1353 | if (cmd_status == 0) { |
| 1363 | dwc3_stop_active_transfer(dep, true); | 1354 | dwc3_stop_active_transfer(dep, true, true); |
| 1364 | return 0; | 1355 | return 0; |
| 1365 | } | 1356 | } |
| 1366 | } | 1357 | } |
| @@ -1435,6 +1426,11 @@ static int __dwc3_gadget_ep_queue(struct dwc3_ep *dep, struct dwc3_request *req) · 68 unmodified lines | |||
| 1435 | &req->request, req->dep->name)) | 1426 | &req->request, req->dep->name)) |
| 1436 | return -EINVAL; | 1427 | return -EINVAL; |
| 1437 | 1428 | ||
| 1429 | if (WARN(req->status < DWC3_REQUEST_STATUS_COMPLETED, | ||
| 1430 | "%s: request %pK already in flight\n", | ||
| 1431 | dep->name, &req->request)) | ||
| 1432 | return -EINVAL; | ||
| 1433 | |||
| 1438 | pm_runtime_get(dwc->dev); | 1434 | pm_runtime_get(dwc->dev); |
| 1439 | 1435 | ||
| 1440 | req->request.actual = 0; | 1436 | req->request.actual = 0; |
| @@ -1443,6 +1439,7 @@ static int __dwc3_gadget_ep_queue(struct dwc3_ep *dep, struct dwc3_request *req) · 2 unmodified lines | |||
| 1443 | trace_dwc3_ep_queue(req); | 1439 | trace_dwc3_ep_queue(req); |
| 1444 | 1440 | ||
| 1445 | list_add_tail(&req->list, &dep->pending_list); | 1441 | list_add_tail(&req->list, &dep->pending_list); |
| 1442 | req->status = DWC3_REQUEST_STATUS_QUEUED; | ||
| 1446 | 1443 | ||
| 1447 | /* | 1444 | /* |
| 1448 | * NOTICE: Isochronous endpoints should NEVER be prestarted. We must | 1445 | * NOTICE: Isochronous endpoints should NEVER be prestarted. We must |
| @@ -1506,6 +1503,8 @@ static void dwc3_gadget_ep_skip_trbs(struct dwc3_ep *dep, struct dwc3_request *r · 57 unmodified lines | |||
| 1506 | trb->ctrl &= ~DWC3_TRB_CTRL_HWO; | 1503 | trb->ctrl &= ~DWC3_TRB_CTRL_HWO; |
| 1507 | dwc3_ep_inc_deq(dep); | 1504 | dwc3_ep_inc_deq(dep); |
| 1508 | } | 1505 | } |
| 1506 | |||
| 1507 | req->num_trbs = 0; | ||
| 1509 | } | 1508 | } |
| 1510 | 1509 | ||
| 1511 | static void dwc3_gadget_ep_cleanup_cancelled_requests(struct dwc3_ep *dep) | 1510 | static void dwc3_gadget_ep_cleanup_cancelled_requests(struct dwc3_ep *dep) |
| @@ -1547,13 +1546,16 @@ static int dwc3_gadget_ep_dequeue(struct usb_ep *ep, · 35 unmodified lines | |||
| 1547 | } | 1546 | } |
| 1548 | if (r == req) { | 1547 | if (r == req) { |
| 1549 | /* wait until it is processed */ | 1548 | /* wait until it is processed */ |
| 1550 | dwc3_stop_active_transfer(dep, true); | 1549 | dwc3_stop_active_transfer(dep, true, true); |
| 1551 | 1550 | ||
| 1552 | if (!r->trb) | 1551 | if (!r->trb) |
| 1553 | goto out0; | 1552 | goto out0; |
| 1554 | 1553 | ||
| 1555 | dwc3_gadget_move_cancelled_request(req); | 1554 | dwc3_gadget_move_cancelled_request(req); |
| 1556 | goto out0; | 1555 | if (dep->flags & DWC3_EP_TRANSFER_STARTED) |
| 1556 | goto out0; | ||
| 1557 | else | ||
| 1558 | goto out1; | ||
| 1557 | } | 1559 | } |
| 1558 | dev_err(dwc->dev, "request %pK was not queued to %s\n", | 1560 | dev_err(dwc->dev, "request %pK was not queued to %s\n", |
| 1559 | request, ep->name); | 1561 | request, ep->name); |
| @@ -1561,6 +1563,7 @@ static int dwc3_gadget_ep_dequeue(struct usb_ep *ep, · 1 unmodified line | |||
| 1561 | goto out0; | 1563 | goto out0; |
| 1562 | } | 1564 | } |
| 1563 | 1565 | ||
| 1566 | out1: | ||
| 1564 | dwc3_gadget_giveback(dep, req, -ECONNRESET); | 1567 | dwc3_gadget_giveback(dep, req, -ECONNRESET); |
| 1565 | 1568 | ||
| 1566 | out0: | 1569 | out0: |
| @@ -2500,7 +2503,7 @@ static void dwc3_gadget_endpoint_transfer_in_progress(struct dwc3_ep *dep, · 933 unmodified lines | |||
| 2500 | dwc3_gadget_ep_cleanup_completed_requests(dep, event, status); | 2503 | dwc3_gadget_ep_cleanup_completed_requests(dep, event, status); |
| 2501 | 2504 | ||
| 2502 | if (stop) { | 2505 | if (stop) { |
| 2503 | dwc3_stop_active_transfer(dep, true); | 2506 | dwc3_stop_active_transfer(dep, true, true); |
| 2504 | dep->flags = DWC3_EP_ENABLED; | 2507 | dep->flags = DWC3_EP_ENABLED; |
| 2505 | } | 2508 | } |
| 2506 | 2509 | ||
| @@ -2547,7 +2550,7 @@ static void dwc3_endpoint_interrupt(struct dwc3 *dwc, · 40 unmodified lines | |||
| 2547 | dep = dwc->eps[epnum]; | 2550 | dep = dwc->eps[epnum]; |
| 2548 | 2551 | ||
| 2549 | if (!(dep->flags & DWC3_EP_ENABLED)) { | 2552 | if (!(dep->flags & DWC3_EP_ENABLED)) { |
| 2550 | if (!(dep->flags & DWC3_EP_END_TRANSFER_PENDING)) | 2553 | if (!(dep->flags & DWC3_EP_TRANSFER_STARTED)) |
| 2551 | return; | 2554 | return; |
| 2552 | 2555 | ||
| 2553 | /* Handle only EPCMDCMPLT when EP disabled */ | 2556 | /* Handle only EPCMDCMPLT when EP disabled */ |
| @@ -2571,7 +2574,7 @@ static void dwc3_endpoint_interrupt(struct dwc3 *dwc, · 17 unmodified lines | |||
| 2571 | cmd = DEPEVT_PARAMETER_CMD(event->parameters); | 2574 | cmd = DEPEVT_PARAMETER_CMD(event->parameters); |
| 2572 | 2575 | ||
| 2573 | if (cmd == DWC3_DEPCMD_ENDTRANSFER) { | 2576 | if (cmd == DWC3_DEPCMD_ENDTRANSFER) { |
| 2574 | dep->flags &= ~DWC3_EP_END_TRANSFER_PENDING; | 2577 | dep->flags &= ~DWC3_EP_TRANSFER_STARTED; |
| 2575 | dwc3_gadget_ep_cleanup_cancelled_requests(dep); | 2578 | dwc3_gadget_ep_cleanup_cancelled_requests(dep); |
| 2576 | } | 2579 | } |
| 2577 | break; | 2580 | break; |
| @@ -2621,15 +2624,15 @@ static void dwc3_reset_gadget(struct dwc3 *dwc) · 43 unmodified lines | |||
| 2621 | } | 2624 | } |
| 2622 | } | 2625 | } |
| 2623 | 2626 | ||
| 2624 | static void dwc3_stop_active_transfer(struct dwc3_ep *dep, bool force) | 2627 | static void dwc3_stop_active_transfer(struct dwc3_ep *dep, bool force, |
| 2628 | bool interrupt) | ||
| 2625 | { | 2629 | { |
| 2626 | struct dwc3 *dwc = dep->dwc; | 2630 | struct dwc3 *dwc = dep->dwc; |
| 2627 | struct dwc3_gadget_ep_cmd_params params; | 2631 | struct dwc3_gadget_ep_cmd_params params; |
| 2628 | u32 cmd; | 2632 | u32 cmd; |
| 2629 | int ret; | 2633 | int ret; |
| 2630 | 2634 | ||
| 2631 | if ((dep->flags & DWC3_EP_END_TRANSFER_PENDING) || | 2635 | if (!(dep->flags & DWC3_EP_TRANSFER_STARTED)) |
| 2632 | !dep->resource_index) | ||
| 2633 | return; | 2636 | return; |
| 2634 | 2637 | ||
| 2635 | /* | 2638 | /* |
| @@ -2665,17 +2668,15 @@ static void dwc3_stop_active_transfer(struct dwc3_ep *dep, bool force) · 29 unmodified lines | |||
| 2665 | 2668 | ||
| 2666 | cmd = DWC3_DEPCMD_ENDTRANSFER; | 2669 | cmd = DWC3_DEPCMD_ENDTRANSFER; |
| 2667 | cmd |= force ? DWC3_DEPCMD_HIPRI_FORCERM : 0; | 2670 | cmd |= force ? DWC3_DEPCMD_HIPRI_FORCERM : 0; |
| 2668 | cmd |= DWC3_DEPCMD_CMDIOC; | 2671 | cmd |= interrupt ? DWC3_DEPCMD_CMDIOC : 0; |
| 2669 | cmd |= DWC3_DEPCMD_PARAM(dep->resource_index); | 2672 | cmd |= DWC3_DEPCMD_PARAM(dep->resource_index); |
| 2670 | memset(¶ms, 0, sizeof(params)); | 2673 | memset(¶ms, 0, sizeof(params)); |
| 2671 | ret = dwc3_send_gadget_ep_cmd(dep, cmd, ¶ms); | 2674 | ret = dwc3_send_gadget_ep_cmd(dep, cmd, ¶ms); |
| 2672 | WARN_ON_ONCE(ret); | 2675 | WARN_ON_ONCE(ret); |
| 2673 | dep->resource_index = 0; | 2676 | dep->resource_index = 0; |
| 2674 | 2677 | ||
| 2675 | if (dwc3_is_usb31(dwc) || dwc->revision < DWC3_REVISION_310A) { | 2678 | if (dwc3_is_usb31(dwc) || dwc->revision < DWC3_REVISION_310A) |
| 2676 | dep->flags |= DWC3_EP_END_TRANSFER_PENDING; | ||
| 2677 | udelay(100); | 2679 | udelay(100); |
| 2678 | } | ||
| 2679 | } | 2680 | } |
| 2680 | 2681 | ||
| 2681 | static void dwc3_clear_stall_all_ep(struct dwc3 *dwc) | 2682 | static void dwc3_clear_stall_all_ep(struct dwc3 *dwc) |
| @@ -3339,6 +3340,8 @@ int dwc3_gadget_init(struct dwc3 *dwc) · 657 unmodified lines | |||
| 3339 | goto err4; | 3340 | goto err4; |
| 3340 | } | 3341 | } |
| 3341 | 3342 | ||
| 3343 | dwc3_gadget_set_speed(&dwc->gadget, dwc->maximum_speed); | ||
| 3344 | |||
| 3342 | return 0; | 3345 | return 0; |
| 3343 | 3346 | ||
| 3344 | err4: | 3347 | err4: |
| @@ -75,7 +75,7 @@ static inline void dwc3_gadget_move_started_request(struct dwc3_request *req) · 74 unmodified lines | |||
| 75 | { | 75 | { |
| 76 | struct dwc3_ep *dep = req->dep; | 76 | struct dwc3_ep *dep = req->dep; |
| 77 | 77 | ||
| 78 | req->started = true; | 78 | req->status = DWC3_REQUEST_STATUS_STARTED; |
| 79 | list_move_tail(&req->list, &dep->started_list); | 79 | list_move_tail(&req->list, &dep->started_list); |
| 80 | } | 80 | } |
| 81 | 81 | ||
| @@ -90,7 +90,7 @@ static inline void dwc3_gadget_move_cancelled_request(struct dwc3_request *req) · 8 unmodified lines | |||
| 90 | { | 90 | { |
| 91 | struct dwc3_ep *dep = req->dep; | 91 | struct dwc3_ep *dep = req->dep; |
| 92 | 92 | ||
| 93 | req->started = false; | 93 | req->status = DWC3_REQUEST_STATUS_CANCELLED; |
| 94 | list_move_tail(&req->list, &dep->cancelled_list); | 94 | list_move_tail(&req->list, &dep->cancelled_list); |
| 95 | } | 95 | } |
| 96 | 96 | ||
| @@ -59,8 +59,8 @@ DECLARE_EVENT_CLASS(dwc3_log_event, · 58 unmodified lines | |||
| 59 | __entry->ep0state = dwc->ep0state; | 59 | __entry->ep0state = dwc->ep0state; |
| 60 | ), | 60 | ), |
| 61 | TP_printk("event (%08x): %s", __entry->event, | 61 | TP_printk("event (%08x): %s", __entry->event, |
| 62 | dwc3_decode_event(__get_str(str), __entry->event, | 62 | dwc3_decode_event(__get_str(str), DWC3_MSG_MAX, |
| 63 | __entry->ep0state)) | 63 | __entry->event, __entry->ep0state)) |
| 64 | ); | 64 | ); |
| 65 | 65 | ||
| 66 | DEFINE_EVENT(dwc3_log_event, dwc3_event, | 66 | DEFINE_EVENT(dwc3_log_event, dwc3_event, |
| @@ -86,7 +86,8 @@ DECLARE_EVENT_CLASS(dwc3_log_ctrl, · 19 unmodified lines | |||
| 86 | __entry->wIndex = le16_to_cpu(ctrl->wIndex); | 86 | __entry->wIndex = le16_to_cpu(ctrl->wIndex); |
| 87 | __entry->wLength = le16_to_cpu(ctrl->wLength); | 87 | __entry->wLength = le16_to_cpu(ctrl->wLength); |
| 88 | ), | 88 | ), |
| 89 | TP_printk("%s", dwc3_decode_ctrl(__get_str(str), __entry->bRequestType, | 89 | TP_printk("%s", dwc3_decode_ctrl(__get_str(str), DWC3_MSG_MAX, |
| 90 | __entry->bRequestType, | ||
| 90 | __entry->bRequest, __entry->wValue, | 91 | __entry->bRequest, __entry->wValue, |
| 91 | __entry->wIndex, __entry->wLength) | 92 | __entry->wIndex, __entry->wLength) |
| 92 | ) | 93 | ) |
| @@ -305,7 +306,7 @@ DECLARE_EVENT_CLASS(dwc3_log_ep, · 212 unmodified lines | |||
| 305 | __entry->trb_enqueue = dep->trb_enqueue; | 306 | __entry->trb_enqueue = dep->trb_enqueue; |
| 306 | __entry->trb_dequeue = dep->trb_dequeue; | 307 | __entry->trb_dequeue = dep->trb_dequeue; |
| 307 | ), | 308 | ), |
| 308 | TP_printk("%s: mps %d/%d streams %d burst %d ring %d/%d flags %c:%c%c%c%c:%c:%c", | 309 | TP_printk("%s: mps %d/%d streams %d burst %d ring %d/%d flags %c:%c%c%c%c:%c", |
| 309 | __get_str(name), __entry->maxpacket, | 310 | __get_str(name), __entry->maxpacket, |
| 310 | __entry->maxpacket_limit, __entry->max_streams, | 311 | __entry->maxpacket_limit, __entry->max_streams, |
| 311 | __entry->maxburst, __entry->trb_enqueue, | 312 | __entry->maxburst, __entry->trb_enqueue, |
| @@ -315,7 +316,6 @@ DECLARE_EVENT_CLASS(dwc3_log_ep, · 3 unmodified lines | |||
| 315 | __entry->flags & DWC3_EP_WEDGE ? 'W' : 'w', | 316 | __entry->flags & DWC3_EP_WEDGE ? 'W' : 'w', |
| 316 | __entry->flags & DWC3_EP_TRANSFER_STARTED ? 'B' : 'b', | 317 | __entry->flags & DWC3_EP_TRANSFER_STARTED ? 'B' : 'b', |
| 317 | __entry->flags & DWC3_EP_PENDING_REQUEST ? 'P' : 'p', | 318 | __entry->flags & DWC3_EP_PENDING_REQUEST ? 'P' : 'p', |
| 318 | __entry->flags & DWC3_EP_END_TRANSFER_PENDING ? 'E' : 'e', | ||
| 319 | __entry->direction ? '<' : '>' | 319 | __entry->direction ? '<' : '>' |
| 320 | ) | 320 | ) |
| 321 | ); | 321 | ); |
| @@ -1,3 +1,4 @@ | |||
| 1 | # SPDX-License-Identifier: GPL-2.0 | ||
| 1 | # | 2 | # |
| 2 | # USB Gadget support on a system involves | 3 | # USB Gadget support on a system involves |
| 3 | # (a) a peripheral controller, and | 4 | # (a) a peripheral controller, and |
| @@ -67,9 +67,6 @@ struct usb_ep *usb_ep_autoconfig_ss( · 66 unmodified lines | |||
| 67 | ) | 67 | ) |
| 68 | { | 68 | { |
| 69 | struct usb_ep *ep; | 69 | struct usb_ep *ep; |
| 70 | u8 type; | ||
| 71 | |||
| 72 | type = desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK; | ||
| 73 | 70 | ||
| 74 | if (gadget->ops->match_ep) { | 71 | if (gadget->ops->match_ep) { |
| 75 | ep = gadget->ops->match_ep(gadget, desc, ep_comp); | 72 | ep = gadget->ops->match_ep(gadget, desc, ep_comp); |
| @@ -109,16 +106,6 @@ found_ep: · 33 unmodified lines | |||
| 109 | desc->bEndpointAddress |= gadget->out_epnum; | 106 | desc->bEndpointAddress |= gadget->out_epnum; |
| 110 | } | 107 | } |
| 111 | 108 | ||
| 112 | /* report (variable) full speed bulk maxpacket */ | ||
| 113 | if ((type == USB_ENDPOINT_XFER_BULK) && !ep_comp) { | ||
| 114 | int size = ep->maxpacket_limit; | ||
| 115 | |||
| 116 | /* min() doesn't work on bitfields with gcc-3.5 */ | ||
| 117 | if (size > 64) | ||
| 118 | size = 64; | ||
| 119 | desc->wMaxPacketSize = cpu_to_le16(size); | ||
| 120 | } | ||
| 121 | |||
| 122 | ep->address = desc->bEndpointAddress; | 109 | ep->address = desc->bEndpointAddress; |
| 123 | ep->desc = NULL; | 110 | ep->desc = NULL; |
| 124 | ep->comp_desc = NULL; | 111 | ep->comp_desc = NULL; |
| @@ -152,9 +139,10 @@ EXPORT_SYMBOL_GPL(usb_ep_autoconfig_ss); · 27 unmodified lines | |||
| 152 | * | 139 | * |
| 153 | * On success, this returns an claimed usb_ep, and modifies the endpoint | 140 | * On success, this returns an claimed usb_ep, and modifies the endpoint |
| 154 | * descriptor bEndpointAddress. For bulk endpoints, the wMaxPacket value | 141 | * descriptor bEndpointAddress. For bulk endpoints, the wMaxPacket value |
| 155 | * is initialized as if the endpoint were used at full speed. To prevent | 142 | * is initialized as if the endpoint were used at full speed. Because of |
| 156 | * the endpoint from being returned by a later autoconfig call, claims it | 143 | * that the users must consider adjusting the autoconfigured descriptor. |
| 157 | * by assigning ep->claimed to true. | 144 | * To prevent the endpoint from being returned by a later autoconfig call, |
| 145 | * claims it by assigning ep->claimed to true. | ||
| 158 | * | 146 | * |
| 159 | * On failure, this returns a null endpoint descriptor. | 147 | * On failure, this returns a null endpoint descriptor. |
| 160 | */ | 148 | */ |
| @@ -163,7 +151,26 @@ struct usb_ep *usb_ep_autoconfig( · 2 unmodified lines | |||
| 163 | struct usb_endpoint_descriptor *desc | 151 | struct usb_endpoint_descriptor *desc |
| 164 | ) | 152 | ) |
| 165 | { | 153 | { |
| 166 | return usb_ep_autoconfig_ss(gadget, desc, NULL); | 154 | struct usb_ep *ep; |
| 155 | u8 type; | ||
| 156 | |||
| 157 | ep = usb_ep_autoconfig_ss(gadget, desc, NULL); | ||
| 158 | if (!ep) | ||
| 159 | return NULL; | ||
| 160 | |||
| 161 | type = desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK; | ||
| 162 | |||
| 163 | /* report (variable) full speed bulk maxpacket */ | ||
| 164 | if (type == USB_ENDPOINT_XFER_BULK) { | ||
| 165 | int size = ep->maxpacket_limit; | ||
| 166 | |||
| 167 | /* min() doesn't work on bitfields with gcc-3.5 */ | ||
| 168 | if (size > 64) | ||
| 169 | size = 64; | ||
| 170 | desc->wMaxPacketSize = cpu_to_le16(size); | ||
| 171 | } | ||
| 172 | |||
| 173 | return ep; | ||
| 167 | } | 174 | } |
| 168 | EXPORT_SYMBOL_GPL(usb_ep_autoconfig); | 175 | EXPORT_SYMBOL_GPL(usb_ep_autoconfig); |
| 169 | 176 | ||
| @@ -1082,6 +1082,7 @@ static ssize_t ffs_epfile_io(struct file *file, struct ffs_io_data *io_data) · 1081 unmodified lines | |||
| 1082 | * condition with req->complete callback. | 1082 | * condition with req->complete callback. |
| 1083 | */ | 1083 | */ |
| 1084 | usb_ep_dequeue(ep->ep, req); | 1084 | usb_ep_dequeue(ep->ep, req); |
| 1085 | wait_for_completion(&done); | ||
| 1085 | interrupted = ep->status < 0; | 1086 | interrupted = ep->status < 0; |
| 1086 | } | 1087 | } |
| 1087 | 1088 | ||
| @@ -2843,12 +2844,18 @@ static int __ffs_func_bind_do_descs(enum ffs_entity_type type, u8 *valuep, · 1755 unmodified lines | |||
| 2843 | struct usb_request *req; | 2844 | struct usb_request *req; |
| 2844 | struct usb_ep *ep; | 2845 | struct usb_ep *ep; |
| 2845 | u8 bEndpointAddress; | 2846 | u8 bEndpointAddress; |
| 2847 | u16 wMaxPacketSize; | ||
| 2846 | 2848 | ||
| 2847 | /* | 2849 | /* |
| 2848 | * We back up bEndpointAddress because autoconfig overwrites | 2850 | * We back up bEndpointAddress because autoconfig overwrites |
| 2849 | * it with physical endpoint address. | 2851 | * it with physical endpoint address. |
| 2850 | */ | 2852 | */ |
| 2851 | bEndpointAddress = ds->bEndpointAddress; | 2853 | bEndpointAddress = ds->bEndpointAddress; |
| 2854 | /* | ||
| 2855 | * We back up wMaxPacketSize because autoconfig treats | ||
| 2856 | * endpoint descriptors as if they were full speed. | ||
| 2857 | */ | ||
| 2858 | wMaxPacketSize = ds->wMaxPacketSize; | ||
| 2852 | pr_vdebug("autoconfig\n"); | 2859 | pr_vdebug("autoconfig\n"); |
| 2853 | ep = usb_ep_autoconfig(func->gadget, ds); | 2860 | ep = usb_ep_autoconfig(func->gadget, ds); |
| 2854 | if (unlikely(!ep)) | 2861 | if (unlikely(!ep)) |
| @@ -2869,6 +2876,11 @@ static int __ffs_func_bind_do_descs(enum ffs_entity_type type, u8 *valuep, · 14 unmodified lines | |||
| 2869 | */ | 2876 | */ |
| 2870 | if (func->ffs->user_flags & FUNCTIONFS_VIRTUAL_ADDR) | 2877 | if (func->ffs->user_flags & FUNCTIONFS_VIRTUAL_ADDR) |
| 2871 | ds->bEndpointAddress = bEndpointAddress; | 2878 | ds->bEndpointAddress = bEndpointAddress; |
| 2879 | /* | ||
| 2880 | * Restore wMaxPacketSize which was potentially | ||
| 2881 | * overwritten by autoconfig. | ||
| 2882 | */ | ||
| 2883 | ds->wMaxPacketSize = wMaxPacketSize; | ||
| 2872 | } | 2884 | } |
| 2873 | ffs_dump_mem(": Rewritten ep desc", ds, ds->bLength); | 2885 | ffs_dump_mem(": Rewritten ep desc", ds, ds->bLength); |
| 2874 | 2886 | ||
| @@ -459,10 +459,10 @@ static int f_audio_set_alt(struct usb_function *f, unsigned intf, unsigned alt) · 458 unmodified lines | |||
| 459 | } else if (intf == uac1->as_in_intf) { | 459 | } else if (intf == uac1->as_in_intf) { |
| 460 | uac1->as_in_alt = alt; | 460 | uac1->as_in_alt = alt; |
| 461 | 461 | ||
| 462 | if (alt) | 462 | if (alt) |
| 463 | ret = u_audio_start_playback(&uac1->g_audio); | 463 | ret = u_audio_start_playback(&uac1->g_audio); |
| 464 | else | 464 | else |
| 465 | u_audio_stop_playback(&uac1->g_audio); | 465 | u_audio_stop_playback(&uac1->g_audio); |
| 466 | } else { | 466 | } else { |
| 467 | dev_err(dev, "%s:%d Error!\n", __func__, __LINE__); | 467 | dev_err(dev, "%s:%d Error!\n", __func__, __LINE__); |
| 468 | return -EINVAL; | 468 | return -EINVAL; |
| @@ -568,6 +568,7 @@ static int f_audio_bind(struct usb_configuration *c, struct usb_function *f) · 99 unmodified lines | |||
| 568 | goto fail; | 568 | goto fail; |
| 569 | as_out_interface_alt_0_desc.bInterfaceNumber = status; | 569 | as_out_interface_alt_0_desc.bInterfaceNumber = status; |
| 570 | as_out_interface_alt_1_desc.bInterfaceNumber = status; | 570 | as_out_interface_alt_1_desc.bInterfaceNumber = status; |
| 571 | ac_header_desc.baInterfaceNr[0] = status; | ||
| 571 | uac1->as_out_intf = status; | 572 | uac1->as_out_intf = status; |
| 572 | uac1->as_out_alt = 0; | 573 | uac1->as_out_alt = 0; |
| 573 | 574 | ||
| @@ -576,6 +577,7 @@ static int f_audio_bind(struct usb_configuration *c, struct usb_function *f) · 2 unmodified lines | |||
| 576 | goto fail; | 577 | goto fail; |
| 577 | as_in_interface_alt_0_desc.bInterfaceNumber = status; | 578 | as_in_interface_alt_0_desc.bInterfaceNumber = status; |
| 578 | as_in_interface_alt_1_desc.bInterfaceNumber = status; | 579 | as_in_interface_alt_1_desc.bInterfaceNumber = status; |
| 580 | ac_header_desc.baInterfaceNr[1] = status; | ||
| 579 | uac1->as_in_intf = status; | 581 | uac1->as_in_intf = status; |
| 580 | uac1->as_in_alt = 0; | 582 | uac1->as_in_alt = 0; |
| 581 | 583 | ||
| @@ -7,7 +7,7 @@ · 6 unmodified lines | |||
| 7 | * Copyright (c) 2013 Samsung Electronics Co., Ltd. | 7 | * Copyright (c) 2013 Samsung Electronics Co., Ltd. |
| 8 | * http://www.samsung.com | 8 | * http://www.samsung.com |
| 9 | * | 9 | * |
| 10 | * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com> | 10 | * Author: Andrzej Pietrasiewicz <andrzejtp2010@gmail.com> |
| 11 | */ | 11 | */ |
| 12 | 12 | ||
| 13 | #ifndef U_ECM_H | 13 | #ifndef U_ECM_H |
| @@ -7,7 +7,7 @@ · 6 unmodified lines | |||
| 7 | * Copyright (c) 2013 Samsung Electronics Co., Ltd. | 7 | * Copyright (c) 2013 Samsung Electronics Co., Ltd. |
| 8 | * http://www.samsung.com | 8 | * http://www.samsung.com |
| 9 | * | 9 | * |
| 10 | * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com> | 10 | * Author: Andrzej Pietrasiewicz <andrzejtp2010@gmail.com> |
| 11 | */ | 11 | */ |
| 12 | 12 | ||
| 13 | #ifndef U_EEM_H | 13 | #ifndef U_EEM_H |
| @@ -7,7 +7,7 @@ · 6 unmodified lines | |||
| 7 | * Copyright (c) 2013 Samsung Electronics Co., Ltd. | 7 | * Copyright (c) 2013 Samsung Electronics Co., Ltd. |
| 8 | * http://www.samsung.com | 8 | * http://www.samsung.com |
| 9 | * | 9 | * |
| 10 | * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com> | 10 | * Author: Andrzej Pietrasiewicz <andrzejtp2010@gmail.com> |
| 11 | */ | 11 | */ |
| 12 | 12 | ||
| 13 | #ifndef __U_ETHER_CONFIGFS_H | 13 | #ifndef __U_ETHER_CONFIGFS_H |
| @@ -7,7 +7,7 @@ · 6 unmodified lines | |||
| 7 | * Copyright (c) 2013 Samsung Electronics Co., Ltd. | 7 | * Copyright (c) 2013 Samsung Electronics Co., Ltd. |
| 8 | * http://www.samsung.com | 8 | * http://www.samsung.com |
| 9 | * | 9 | * |
| 10 | * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com> | 10 | * Author: Andrzej Pietrasiewicz <andrzejtp2010@gmail.com> |
| 11 | */ | 11 | */ |
| 12 | 12 | ||
| 13 | #ifndef U_FFS_H | 13 | #ifndef U_FFS_H |
| @@ -7,7 +7,7 @@ · 6 unmodified lines | |||
| 7 | * Copyright (c) 2013 Samsung Electronics Co., Ltd. | 7 | * Copyright (c) 2013 Samsung Electronics Co., Ltd. |
| 8 | * http://www.samsung.com | 8 | * http://www.samsung.com |
| 9 | * | 9 | * |
| 10 | * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com> | 10 | * Author: Andrzej Pietrasiewicz <andrzejtp2010@gmail.com> |
| 11 | */ | 11 | */ |
| 12 | 12 | ||
| 13 | #ifndef U_GETHER_H | 13 | #ifndef U_GETHER_H |
| @@ -7,7 +7,7 @@ · 6 unmodified lines | |||
| 7 | * Copyright (c) 2014 Samsung Electronics Co., Ltd. | 7 | * Copyright (c) 2014 Samsung Electronics Co., Ltd. |
| 8 | * http://www.samsung.com | 8 | * http://www.samsung.com |
| 9 | * | 9 | * |
| 10 | * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com> | 10 | * Author: Andrzej Pietrasiewicz <andrzejtp2010@gmail.com> |
| 11 | */ | 11 | */ |
| 12 | 12 | ||
| 13 | #ifndef U_HID_H | 13 | #ifndef U_HID_H |
| @@ -7,7 +7,7 @@ · 6 unmodified lines | |||
| 7 | * Copyright (c) 2014 Samsung Electronics Co., Ltd. | 7 | * Copyright (c) 2014 Samsung Electronics Co., Ltd. |
| 8 | * http://www.samsung.com | 8 | * http://www.samsung.com |
| 9 | * | 9 | * |
| 10 | * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com> | 10 | * Author: Andrzej Pietrasiewicz <andrzejtp2010@gmail.com> |
| 11 | */ | 11 | */ |
| 12 | 12 | ||
| 13 | #ifndef U_MIDI_H | 13 | #ifndef U_MIDI_H |
| @@ -7,7 +7,7 @@ · 6 unmodified lines | |||
| 7 | * Copyright (c) 2013 Samsung Electronics Co., Ltd. | 7 | * Copyright (c) 2013 Samsung Electronics Co., Ltd. |
| 8 | * http://www.samsung.com | 8 | * http://www.samsung.com |
| 9 | * | 9 | * |
| 10 | * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com> | 10 | * Author: Andrzej Pietrasiewicz <andrzejtp2010@gmail.com> |
| 11 | */ | 11 | */ |
| 12 | 12 | ||
| 13 | #ifndef U_NCM_H | 13 | #ifndef U_NCM_H |
| @@ -7,7 +7,7 @@ · 6 unmodified lines | |||
| 7 | * Copyright (c) 2015 Samsung Electronics Co., Ltd. | 7 | * Copyright (c) 2015 Samsung Electronics Co., Ltd. |
| 8 | * http://www.samsung.com | 8 | * http://www.samsung.com |
| 9 | * | 9 | * |
| 10 | * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com> | 10 | * Author: Andrzej Pietrasiewicz <andrzejtp2010@gmail.com> |
| 11 | */ | 11 | */ |
| 12 | 12 | ||
| 13 | #ifndef U_PRINTER_H | 13 | #ifndef U_PRINTER_H |
| @@ -7,7 +7,7 @@ · 6 unmodified lines | |||
| 7 | * Copyright (c) 2013 Samsung Electronics Co., Ltd. | 7 | * Copyright (c) 2013 Samsung Electronics Co., Ltd. |
| 8 | * http://www.samsung.com | 8 | * http://www.samsung.com |
| 9 | * | 9 | * |
| 10 | * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com> | 10 | * Author: Andrzej Pietrasiewicz <andrzejtp2010@gmail.com> |
| 11 | */ | 11 | */ |
| 12 | 12 | ||
| 13 | #ifndef U_RNDIS_H | 13 | #ifndef U_RNDIS_H |
| @@ -16,7 +16,6 @@ · 15 unmodified lines | |||
| 16 | 16 | ||
| 17 | #include <linux/kernel.h> | 17 | #include <linux/kernel.h> |
| 18 | #include <linux/sched.h> | 18 | #include <linux/sched.h> |
| 19 | #include <linux/interrupt.h> | ||
| 20 | #include <linux/device.h> | 19 | #include <linux/device.h> |
| 21 | #include <linux/delay.h> | 20 | #include <linux/delay.h> |
| 22 | #include <linux/tty.h> | 21 | #include <linux/tty.h> |
| @@ -26,6 +25,7 @@ · 3 unmodified lines | |||
| 26 | #include <linux/module.h> | 25 | #include <linux/module.h> |
| 27 | #include <linux/console.h> | 26 | #include <linux/console.h> |
| 28 | #include <linux/kthread.h> | 27 | #include <linux/kthread.h> |
| 28 | #include <linux/workqueue.h> | ||
| 29 | #include <linux/kfifo.h> | 29 | #include <linux/kfifo.h> |
| 30 | 30 | ||
| 31 | #include "u_serial.h" | 31 | #include "u_serial.h" |
| @@ -110,7 +110,7 @@ struct gs_port { · 78 unmodified lines | |||
| 110 | int read_allocated; | 110 | int read_allocated; |
| 111 | struct list_head read_queue; | 111 | struct list_head read_queue; |
| 112 | unsigned n_read; | 112 | unsigned n_read; |
| 113 | struct tasklet_struct push; | 113 | struct delayed_work push; |
| 114 | 114 | ||
| 115 | struct list_head write_pool; | 115 | struct list_head write_pool; |
| 116 | int write_started; | 116 | int write_started; |
| @@ -352,9 +352,10 @@ __acquires(&port->port_lock) · 235 unmodified lines | |||
| 352 | * So QUEUE_SIZE packets plus however many the FIFO holds (usually two) | 352 | * So QUEUE_SIZE packets plus however many the FIFO holds (usually two) |
| 353 | * can be buffered before the TTY layer's buffers (currently 64 KB). | 353 | * can be buffered before the TTY layer's buffers (currently 64 KB). |
| 354 | */ | 354 | */ |
| 355 | static void gs_rx_push(unsigned long _port) | 355 | static void gs_rx_push(struct work_struct *work) |
| 356 | { | 356 | { |
| 357 | struct gs_port *port = (void *)_port; | 357 | struct delayed_work *w = to_delayed_work(work); |
| 358 | struct gs_port *port = container_of(w, struct gs_port, push); | ||
| 358 | struct tty_struct *tty; | 359 | struct tty_struct *tty; |
| 359 | struct list_head *queue = &port->read_queue; | 360 | struct list_head *queue = &port->read_queue; |
| 360 | bool disconnect = false; | 361 | bool disconnect = false; |
| @@ -429,21 +430,13 @@ static void gs_rx_push(unsigned long _port) · 68 unmodified lines | |||
| 429 | 430 | ||
| 430 | /* We want our data queue to become empty ASAP, keeping data | 431 | /* We want our data queue to become empty ASAP, keeping data |
| 431 | * in the tty and ldisc (not here). If we couldn't push any | 432 | * in the tty and ldisc (not here). If we couldn't push any |
| 432 | * this time around, there may be trouble unless there's an | 433 | * this time around, RX may be starved, so wait until next jiffy. |
| 433 | * implicit tty_unthrottle() call on its way... | ||
| 434 | * | 434 | * |
| 435 | * REVISIT we should probably add a timer to keep the tasklet | 435 | * We may leave non-empty queue only when there is a tty, and |
| 436 | * from starving ... but it's not clear that case ever happens. | 436 | * either it is throttled or there is no more room in flip buffer. |
| 437 | */ | 437 | */ |
| 438 | if (!list_empty(queue) && tty) { | 438 | if (!list_empty(queue) && !tty_throttled(tty)) |
| 439 | if (!tty_throttled(tty)) { | 439 | schedule_delayed_work(&port->push, 1); |
| 440 | if (do_push) | ||
| 441 | tasklet_schedule(&port->push); | ||
| 442 | else | ||
| 443 | pr_warn("ttyGS%d: RX not scheduled?\n", | ||
| 444 | port->port_num); | ||
| 445 | } | ||
| 446 | } | ||
| 447 | 440 | ||
| 448 | /* If we're still connected, refill the USB RX queue. */ | 441 | /* If we're still connected, refill the USB RX queue. */ |
| 449 | if (!disconnect && port->port_usb) | 442 | if (!disconnect && port->port_usb) |
| @@ -459,7 +452,7 @@ static void gs_read_complete(struct usb_ep *ep, struct usb_request *req) · 9 unmodified lines | |||
| 459 | /* Queue all received data until the tty layer is ready for it. */ | 452 | /* Queue all received data until the tty layer is ready for it. */ |
| 460 | spin_lock(&port->port_lock); | 453 | spin_lock(&port->port_lock); |
| 461 | list_add_tail(&req->list, &port->read_queue); | 454 | list_add_tail(&req->list, &port->read_queue); |
| 462 | tasklet_schedule(&port->push); | 455 | schedule_delayed_work(&port->push, 0); |
| 463 | spin_unlock(&port->port_lock); | 456 | spin_unlock(&port->port_lock); |
| 464 | } | 457 | } |
| 465 | 458 | ||
| @@ -854,8 +847,8 @@ static void gs_unthrottle(struct tty_struct *tty) · 388 unmodified lines | |||
| 854 | * rts/cts, or other handshaking with the host, but if the | 847 | * rts/cts, or other handshaking with the host, but if the |
| 855 | * read queue backs up enough we'll be NAKing OUT packets. | 848 | * read queue backs up enough we'll be NAKing OUT packets. |
| 856 | */ | 849 | */ |
| 857 | tasklet_schedule(&port->push); | ||
| 858 | pr_vdebug("ttyGS%d: unthrottle\n", port->port_num); | 850 | pr_vdebug("ttyGS%d: unthrottle\n", port->port_num); |
| 851 | schedule_delayed_work(&port->push, 0); | ||
| 859 | } | 852 | } |
| 860 | spin_unlock_irqrestore(&port->port_lock, flags); | 853 | spin_unlock_irqrestore(&port->port_lock, flags); |
| 861 | } | 854 | } |
| @@ -1159,7 +1152,7 @@ gs_port_alloc(unsigned port_num, struct usb_cdc_line_coding *coding) · 297 unmodified lines | |||
| 1159 | init_waitqueue_head(&port->drain_wait); | 1152 | init_waitqueue_head(&port->drain_wait); |
| 1160 | init_waitqueue_head(&port->close_wait); | 1153 | init_waitqueue_head(&port->close_wait); |
| 1161 | 1154 | ||
| 1162 | tasklet_init(&port->push, gs_rx_push, (unsigned long) port); | 1155 | INIT_DELAYED_WORK(&port->push, gs_rx_push); |
| 1163 | 1156 | ||
| 1164 | INIT_LIST_HEAD(&port->read_pool); | 1157 | INIT_LIST_HEAD(&port->read_pool); |
| 1165 | INIT_LIST_HEAD(&port->read_queue); | 1158 | INIT_LIST_HEAD(&port->read_queue); |
| @@ -1186,7 +1179,7 @@ static int gs_closed(struct gs_port *port) · 20 unmodified lines | |||
| 1186 | 1179 | ||
| 1187 | static void gserial_free_port(struct gs_port *port) | 1180 | static void gserial_free_port(struct gs_port *port) |
| 1188 | { | 1181 | { |
| 1189 | tasklet_kill(&port->push); | 1182 | cancel_delayed_work_sync(&port->push); |
| 1190 | /* wait for old opens to finish */ | 1183 | /* wait for old opens to finish */ |
| 1191 | wait_event(port->close_wait, gs_closed(port)); | 1184 | wait_event(port->close_wait, gs_closed(port)); |
| 1192 | WARN_ON(port->port_usb != NULL); | 1185 | WARN_ON(port->port_usb != NULL); |
| @@ -7,7 +7,7 @@ · 6 unmodified lines | |||
| 7 | * Copyright (c) 2014 Samsung Electronics Co., Ltd. | 7 | * Copyright (c) 2014 Samsung Electronics Co., Ltd. |
| 8 | * http://www.samsung.com | 8 | * http://www.samsung.com |
| 9 | * | 9 | * |
| 10 | * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com> | 10 | * Author: Andrzej Pietrasiewicz <andrzejtp2010@gmail.com> |
| 11 | */ | 11 | */ |
| 12 | 12 | ||
| 13 | #ifndef U_UAC2_H | 13 | #ifndef U_UAC2_H |
| @@ -7,7 +7,7 @@ · 6 unmodified lines | |||
| 7 | * Copyright (c) 2013-2014 Samsung Electronics Co., Ltd. | 7 | * Copyright (c) 2013-2014 Samsung Electronics Co., Ltd. |
| 8 | * http://www.samsung.com | 8 | * http://www.samsung.com |
| 9 | * | 9 | * |
| 10 | * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com> | 10 | * Author: Andrzej Pietrasiewicz <andrzejtp2010@gmail.com> |
| 11 | */ | 11 | */ |
| 12 | 12 | ||
| 13 | #ifndef U_UVC_H | 13 | #ifndef U_UVC_H |
| @@ -56,6 +56,8 @@ extern unsigned int uvc_gadget_trace_param; · 55 unmodified lines | |||
| 56 | dev_dbg(&(f)->config->cdev->gadget->dev, "%s: " fmt, (f)->name, ##args) | 56 | dev_dbg(&(f)->config->cdev->gadget->dev, "%s: " fmt, (f)->name, ##args) |
| 57 | #define uvcg_info(f, fmt, args...) \ | 57 | #define uvcg_info(f, fmt, args...) \ |
| 58 | dev_info(&(f)->config->cdev->gadget->dev, "%s: " fmt, (f)->name, ##args) | 58 | dev_info(&(f)->config->cdev->gadget->dev, "%s: " fmt, (f)->name, ##args) |
| 59 | #define uvcg_warn(f, fmt, args...) \ | ||
| 60 | dev_warn(&(f)->config->cdev->gadget->dev, "%s: " fmt, (f)->name, ##args) | ||
| 59 | #define uvcg_err(f, fmt, args...) \ | 61 | #define uvcg_err(f, fmt, args...) \ |
| 60 | dev_err(&(f)->config->cdev->gadget->dev, "%s: " fmt, (f)->name, ##args) | 62 | dev_err(&(f)->config->cdev->gadget->dev, "%s: " fmt, (f)->name, ##args) |
| 61 | 63 | ||
| @@ -7,7 +7,7 @@ · 6 unmodified lines | |||
| 7 | * Copyright (c) 2014 Samsung Electronics Co., Ltd. | 7 | * Copyright (c) 2014 Samsung Electronics Co., Ltd. |
| 8 | * http://www.samsung.com | 8 | * http://www.samsung.com |
| 9 | * | 9 | * |
| 10 | * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com> | 10 | * Author: Andrzej Pietrasiewicz <andrzejtp2010@gmail.com> |
| 11 | */ | 11 | */ |
| 12 | 12 | ||
| 13 | #include <linux/sort.h> | 13 | #include <linux/sort.h> |
| @@ -1570,10 +1570,6 @@ uvcg_uncompressed_##cname##_store(struct config_item *item, \ · 1556 unmodified lines | |||
| 1570 | if (ret) \ | 1570 | if (ret) \ |
| 1571 | goto end; \ | 1571 | goto end; \ |
| 1572 | \ | 1572 | \ |
| 1573 | if (num > 255) { \ | ||
| 1574 | ret = -EINVAL; \ | ||
| 1575 | goto end; \ | ||
| 1576 | } \ | ||
| 1577 | u->desc.aname = num; \ | 1573 | u->desc.aname = num; \ |
| 1578 | ret = len; \ | 1574 | ret = len; \ |
| 1579 | end: \ | 1575 | end: \ |
| @@ -1767,10 +1763,6 @@ uvcg_mjpeg_##cname##_store(struct config_item *item, \ · 187 unmodified lines | |||
| 1767 | if (ret) \ | 1763 | if (ret) \ |
| 1768 | goto end; \ | 1764 | goto end; \ |
| 1769 | \ | 1765 | \ |
| 1770 | if (num > 255) { \ | ||
| 1771 | ret = -EINVAL; \ | ||
| 1772 | goto end; \ | ||
| 1773 | } \ | ||
| 1774 | u->desc.aname = num; \ | 1766 | u->desc.aname = num; \ |
| 1775 | ret = len; \ | 1767 | ret = len; \ |
| 1776 | end: \ | 1768 | end: \ |
| @@ -7,7 +7,7 @@ · 6 unmodified lines | |||
| 7 | * Copyright (c) 2014 Samsung Electronics Co., Ltd. | 7 | * Copyright (c) 2014 Samsung Electronics Co., Ltd. |
| 8 | * http://www.samsung.com | 8 | * http://www.samsung.com |
| 9 | * | 9 | * |
| 10 | * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com> | 10 | * Author: Andrzej Pietrasiewicz <andrzejtp2010@gmail.com> |
| 11 | */ | 11 | */ |
| 12 | #ifndef UVC_CONFIGFS_H | 12 | #ifndef UVC_CONFIGFS_H |
| 13 | #define UVC_CONFIGFS_H | 13 | #define UVC_CONFIGFS_H |
| @@ -7,7 +7,7 @@ · 6 unmodified lines | |||
| 7 | * | 7 | * |
| 8 | * Copyright (c) 2013 Samsung Electronics Co., Ltd. | 8 | * Copyright (c) 2013 Samsung Electronics Co., Ltd. |
| 9 | * http://www.samsung.com | 9 | * http://www.samsung.com |
| 10 | * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com> | 10 | * Author: Andrzej Pietrasiewicz <andrzejtp2010@gmail.com> |
| 11 | */ | 11 | */ |
| 12 | 12 | ||
| 13 | #ifndef __UVC_V4L2_H__ | 13 | #ifndef __UVC_V4L2_H__ |
| @@ -7,7 +7,7 @@ · 6 unmodified lines | |||
| 7 | * | 7 | * |
| 8 | * Copyright (c) 2013 Samsung Electronics Co., Ltd. | 8 | * Copyright (c) 2013 Samsung Electronics Co., Ltd. |
| 9 | * http://www.samsung.com | 9 | * http://www.samsung.com |
| 10 | * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com> | 10 | * Author: Andrzej Pietrasiewicz <andrzejtp2010@gmail.com> |
| 11 | */ | 11 | */ |
| 12 | #ifndef __UVC_VIDEO_H__ | 12 | #ifndef __UVC_VIDEO_H__ |
| 13 | #define __UVC_VIDEO_H__ | 13 | #define __UVC_VIDEO_H__ |
| @@ -1,3 +1,4 @@ | |||
| 1 | # SPDX-License-Identifier: GPL-2.0 | ||
| 1 | # | 2 | # |
| 2 | # USB Gadget support on a system involves | 3 | # USB Gadget support on a system involves |
| 3 | # (a) a peripheral controller, and | 4 | # (a) a peripheral controller, and |
| @@ -1218,27 +1218,27 @@ ep0_poll (struct file *fd, poll_table *wait) · 1217 unmodified lines | |||
| 1218 | if (dev->state <= STATE_DEV_OPENED) | 1218 | if (dev->state <= STATE_DEV_OPENED) |
| 1219 | return DEFAULT_POLLMASK; | 1219 | return DEFAULT_POLLMASK; |
| 1220 | 1220 | ||
| 1221 | poll_wait(fd, &dev->wait, wait); | 1221 | poll_wait(fd, &dev->wait, wait); |
| 1222 | 1222 | ||
| 1223 | spin_lock_irq (&dev->lock); | 1223 | spin_lock_irq(&dev->lock); |
| 1224 | 1224 | ||
| 1225 | /* report fd mode change before acting on it */ | 1225 | /* report fd mode change before acting on it */ |
| 1226 | if (dev->setup_abort) { | 1226 | if (dev->setup_abort) { |
| 1227 | dev->setup_abort = 0; | 1227 | dev->setup_abort = 0; |
| 1228 | mask = EPOLLHUP; | 1228 | mask = EPOLLHUP; |
| 1229 | goto out; | 1229 | goto out; |
| 1230 | } | 1230 | } |
| 1231 | 1231 | ||
| 1232 | if (dev->state == STATE_DEV_SETUP) { | 1232 | if (dev->state == STATE_DEV_SETUP) { |
| 1233 | if (dev->setup_in || dev->setup_can_stall) | 1233 | if (dev->setup_in || dev->setup_can_stall) |
| 1234 | mask = EPOLLOUT; | 1234 | mask = EPOLLOUT; |
| 1235 | } else { | 1235 | } else { |
| 1236 | if (dev->ev_next != 0) | 1236 | if (dev->ev_next != 0) |
| 1237 | mask = EPOLLIN; | 1237 | mask = EPOLLIN; |
| 1238 | } | 1238 | } |
| 1239 | out: | 1239 | out: |
| 1240 | spin_unlock_irq(&dev->lock); | 1240 | spin_unlock_irq(&dev->lock); |
| 1241 | return mask; | 1241 | return mask; |
| 1242 | } | 1242 | } |
| 1243 | 1243 | ||
| 1244 | static long dev_ioctl (struct file *fd, unsigned code, unsigned long value) | 1244 | static long dev_ioctl (struct file *fd, unsigned code, unsigned long value) |
| @@ -5,7 +5,7 @@ · 4 unmodified lines | |||
| 5 | * Copyright (c) 2013 Samsung Electronics Co., Ltd. | 5 | * Copyright (c) 2013 Samsung Electronics Co., Ltd. |
| 6 | * http://www.samsung.com | 6 | * http://www.samsung.com |
| 7 | * | 7 | * |
| 8 | * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com> | 8 | * Author: Andrzej Pietrasiewicz <andrzejtp2010@gmail.com> |
| 9 | */ | 9 | */ |
| 10 | 10 | ||
| 11 | #include "u_f.h" | 11 | #include "u_f.h" |
| @@ -7,7 +7,7 @@ · 6 unmodified lines | |||
| 7 | * Copyright (c) 2013 Samsung Electronics Co., Ltd. | 7 | * Copyright (c) 2013 Samsung Electronics Co., Ltd. |
| 8 | * http://www.samsung.com | 8 | * http://www.samsung.com |
| 9 | * | 9 | * |
| 10 | * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com> | 10 | * Author: Andrzej Pietrasiewicz <andrzejtp2010@gmail.com> |
| 11 | */ | 11 | */ |
| 12 | 12 | ||
| 13 | #ifndef __U_F_H__ | 13 | #ifndef __U_F_H__ |
| @@ -7,7 +7,7 @@ · 6 unmodified lines | |||
| 7 | * Copyright (c) 2014 Samsung Electronics Co., Ltd. | 7 | * Copyright (c) 2014 Samsung Electronics Co., Ltd. |
| 8 | * http://www.samsung.com | 8 | * http://www.samsung.com |
| 9 | * | 9 | * |
| 10 | * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com> | 10 | * Author: Andrzej Pietrasiewicz <andrzejtp2010@gmail.com> |
| 11 | */ | 11 | */ |
| 12 | 12 | ||
| 13 | #ifndef __U_OS_DESC_H__ | 13 | #ifndef __U_OS_DESC_H__ |
| @@ -1,3 +1,4 @@ | |||
| 1 | # SPDX-License-Identifier: GPL-2.0 | ||
| 1 | # | 2 | # |
| 2 | # USB Gadget support on a system involves | 3 | # USB Gadget support on a system involves |
| 3 | # (a) a peripheral controller, and | 4 | # (a) a peripheral controller, and |
| @@ -120,7 +120,7 @@ static void ast_vhub_epn_handle_ack(struct ast_vhub_ep *ep) · 119 unmodified lines | |||
| 120 | /* No current DMA ongoing */ | 120 | /* No current DMA ongoing */ |
| 121 | req->active = false; | 121 | req->active = false; |
| 122 | 122 | ||
| 123 | /* Grab lenght out of HW */ | 123 | /* Grab length out of HW */ |
| 124 | len = VHUB_EP_DMA_TX_SIZE(stat); | 124 | len = VHUB_EP_DMA_TX_SIZE(stat); |
| 125 | 125 | ||
| 126 | /* If not using DMA, copy data out if needed */ | 126 | /* If not using DMA, copy data out if needed */ |
| @@ -295,7 +295,7 @@ static int ast_vhub_rep_desc(struct ast_vhub_ep *ep, · 294 unmodified lines | |||
| 295 | dsize = AST_VHUB_HUB_DESC_SIZE; | 295 | dsize = AST_VHUB_HUB_DESC_SIZE; |
| 296 | memcpy(ep->buf, &ast_vhub_hub_desc, dsize); | 296 | memcpy(ep->buf, &ast_vhub_hub_desc, dsize); |
| 297 | BUILD_BUG_ON(dsize > sizeof(ast_vhub_hub_desc)); | 297 | BUILD_BUG_ON(dsize > sizeof(ast_vhub_hub_desc)); |
| 298 | BUILD_BUG_ON(AST_VHUB_HUB_DESC_SIZE >= AST_VHUB_EP0_MAX_PACKET); | 298 | BUILD_BUG_ON(AST_VHUB_HUB_DESC_SIZE >= AST_VHUB_EP0_MAX_PACKET); |
| 299 | break; | 299 | break; |
| 300 | default: | 300 | default: |
| 301 | return std_req_stall; | 301 | return std_req_stall; |
| @@ -1,3 +1,5 @@ | |||
| 1 | # SPDX-License-Identifier: GPL-2.0 | ||
| 2 | |||
| 1 | config USB_BDC_UDC | 3 | config USB_BDC_UDC |
| 2 | tristate "Broadcom USB3.0 device controller IP driver(BDC)" | 4 | tristate "Broadcom USB3.0 device controller IP driver(BDC)" |
| 3 | depends on USB_GADGET && HAS_DMA | 5 | depends on USB_GADGET && HAS_DMA |
| @@ -311,8 +311,8 @@ int bdc_ep_clear_stall(struct bdc *bdc, int epnum) · 310 unmodified lines | |||
| 311 | /* if the endpoint it not stallled */ | 311 | /* if the endpoint it not stallled */ |
| 312 | if (!(ep->flags & BDC_EP_STALL)) { | 312 | if (!(ep->flags & BDC_EP_STALL)) { |
| 313 | ret = bdc_ep_set_stall(bdc, epnum); | 313 | ret = bdc_ep_set_stall(bdc, epnum); |
| 314 | if (ret) | 314 | if (ret) |
| 315 | return ret; | 315 | return ret; |
| 316 | } | 316 | } |
| 317 | } | 317 | } |
| 318 | /* Preserve the seq number for ep0 only */ | 318 | /* Preserve the seq number for ep0 only */ |
| @@ -281,10 +281,10 @@ EXPORT_SYMBOL_GPL(usb_ep_queue); · 280 unmodified lines | |||
| 281 | * @ep:the endpoint associated with the request | 281 | * @ep:the endpoint associated with the request |
| 282 | * @req:the request being canceled | 282 | * @req:the request being canceled |
| 283 | * | 283 | * |
| 284 | * If the request is still active on the endpoint, it is dequeued and its | 284 | * If the request is still active on the endpoint, it is dequeued and |
| 285 | * completion routine is called (with status -ECONNRESET); else a negative | 285 | * eventually its completion routine is called (with status -ECONNRESET); |
| 286 | * error code is returned. This is guaranteed to happen before the call to | 286 | * else a negative error code is returned. This routine is asynchronous, |
| 287 | * usb_ep_dequeue() returns. | 287 | * that is, it may return before the completion routine runs. |
| 288 | * | 288 | * |
| 289 | * Note that some hardware can't clear out write fifos (to unlink the request | 289 | * Note that some hardware can't clear out write fifos (to unlink the request |
| 290 | * at the head of the queue) except as part of disconnecting from usb. Such | 290 | * at the head of the queue) except as part of disconnecting from usb. Such |
| @@ -326,6 +326,7 @@ dma_reset: · 325 unmodified lines | |||
| 326 | static void fotg210_start_dma(struct fotg210_ep *ep, | 326 | static void fotg210_start_dma(struct fotg210_ep *ep, |
| 327 | struct fotg210_request *req) | 327 | struct fotg210_request *req) |
| 328 | { | 328 | { |
| 329 | struct device *dev = &ep->fotg210->gadget.dev; | ||
| 329 | dma_addr_t d; | 330 | dma_addr_t d; |
| 330 | u8 *buffer; | 331 | u8 *buffer; |
| 331 | u32 length; | 332 | u32 length; |
| @@ -348,18 +349,14 @@ static void fotg210_start_dma(struct fotg210_ep *ep, · 16 unmodified lines | |||
| 348 | length = req->req.length; | 349 | length = req->req.length; |
| 349 | } | 350 | } |
| 350 | 351 | ||
| 351 | d = dma_map_single(NULL, buffer, length, | 352 | d = dma_map_single(dev, buffer, length, |
| 352 | ep->dir_in ? DMA_TO_DEVICE : DMA_FROM_DEVICE); | 353 | ep->dir_in ? DMA_TO_DEVICE : DMA_FROM_DEVICE); |
| 353 | 354 | ||
| 354 | if (dma_mapping_error(NULL, d)) { | 355 | if (dma_mapping_error(dev, d)) { |
| 355 | pr_err("dma_mapping_error\n"); | 356 | pr_err("dma_mapping_error\n"); |
| 356 | return; | 357 | return; |
| 357 | } | 358 | } |
| 358 | 359 | ||
| 359 | dma_sync_single_for_device(NULL, d, length, | ||
| 360 | ep->dir_in ? DMA_TO_DEVICE : | ||
| 361 | DMA_FROM_DEVICE); | ||
| 362 | |||
| 363 | fotg210_enable_dma(ep, d, length); | 360 | fotg210_enable_dma(ep, d, length); |
| 364 | 361 | ||
| 365 | /* check if dma is done */ | 362 | /* check if dma is done */ |
| @@ -370,7 +367,7 @@ static void fotg210_start_dma(struct fotg210_ep *ep, · 4 unmodified lines | |||
| 370 | /* update actual transfer length */ | 367 | /* update actual transfer length */ |
| 371 | req->req.actual += length; | 368 | req->req.actual += length; |
| 372 | 369 | ||
| 373 | dma_unmap_single(NULL, d, length, DMA_TO_DEVICE); | 370 | dma_unmap_single(dev, d, length, DMA_TO_DEVICE); |
| 374 | } | 371 | } |
| 375 | 372 | ||
| 376 | static void fotg210_ep0_queue(struct fotg210_ep *ep, | 373 | static void fotg210_ep0_queue(struct fotg210_ep *ep, |
| @@ -516,8 +516,8 @@ static int net2280_disable(struct usb_ep *_ep) · 515 unmodified lines | |||
| 516 | unsigned long flags; | 516 | unsigned long flags; |
| 517 | 517 | ||
| 518 | ep = container_of(_ep, struct net2280_ep, ep); | 518 | ep = container_of(_ep, struct net2280_ep, ep); |
| 519 | if (!_ep || !ep->desc || _ep->name == ep0name) { | 519 | if (!_ep || _ep->name == ep0name) { |
| 520 | pr_err("%s: Invalid ep=%p or ep->desc\n", __func__, _ep); | 520 | pr_err("%s: Invalid ep=%p\n", __func__, _ep); |
| 521 | return -EINVAL; | 521 | return -EINVAL; |
| 522 | } | 522 | } |
| 523 | spin_lock_irqsave(&ep->dev->lock, flags); | 523 | spin_lock_irqsave(&ep->dev->lock, flags); |
| @@ -2279,7 +2279,7 @@ static void usb_reinit_338x(struct net2280 *dev) · 1755 unmodified lines | |||
| 2279 | * - It is safe to set for all connection speeds; all chip revisions. | 2279 | * - It is safe to set for all connection speeds; all chip revisions. |
| 2280 | * - R-M-W to leave other bits undisturbed. | 2280 | * - R-M-W to leave other bits undisturbed. |
| 2281 | * - Reference PLX TT-7372 | 2281 | * - Reference PLX TT-7372 |
| 2282 | */ | 2282 | */ |
| 2283 | val = readl(&dev->ll_chicken_reg->ll_tsn_chicken_bit); | 2283 | val = readl(&dev->ll_chicken_reg->ll_tsn_chicken_bit); |
| 2284 | val |= BIT(RECOVERY_IDLE_TO_RECOVER_FMW); | 2284 | val |= BIT(RECOVERY_IDLE_TO_RECOVER_FMW); |
| 2285 | writel(val, &dev->ll_chicken_reg->ll_tsn_chicken_bit); | 2285 | writel(val, &dev->ll_chicken_reg->ll_tsn_chicken_bit); |
| @@ -2629,6 +2629,10 @@ static const struct of_device_id usb3_of_match[] = { · 2628 unmodified lines | |||
| 2629 | MODULE_DEVICE_TABLE(of, usb3_of_match); | 2629 | MODULE_DEVICE_TABLE(of, usb3_of_match); |
| 2630 | 2630 | ||
| 2631 | static const struct soc_device_attribute renesas_usb3_quirks_match[] = { | 2631 | static const struct soc_device_attribute renesas_usb3_quirks_match[] = { |
| 2632 | { | ||
| 2633 | .soc_id = "r8a774c0", | ||
| 2634 | .data = &renesas_usb3_priv_r8a77990, | ||
| 2635 | }, | ||
| 2632 | { | 2636 | { |
| 2633 | .soc_id = "r8a7795", .revision = "ES1.*", | 2637 | .soc_id = "r8a7795", .revision = "ES1.*", |
| 2634 | .data = &renesas_usb3_priv_r8a7795_es1, | 2638 | .data = &renesas_usb3_priv_r8a7795_es1, |
| @@ -947,15 +947,14 @@ static int prep_dma(struct udc_ep *ep, struct udc_request *req, gfp_t gfp) · 946 unmodified lines | |||
| 947 | UDC_DMA_STP_STS_BS_HOST_READY, | 947 | UDC_DMA_STP_STS_BS_HOST_READY, |
| 948 | UDC_DMA_STP_STS_BS); | 948 | UDC_DMA_STP_STS_BS); |
| 949 | 949 | ||
| 950 | 950 | /* clear NAK by writing CNAK */ | |
| 951 | /* clear NAK by writing CNAK */ | 951 | if (ep->naking) { |
| 952 | if (ep->naking) { | 952 | tmp = readl(&ep->regs->ctl); |
| 953 | tmp = readl(&ep->regs->ctl); | 953 | tmp |= AMD_BIT(UDC_EPCTL_CNAK); |
| 954 | tmp |= AMD_BIT(UDC_EPCTL_CNAK); | 954 | writel(tmp, &ep->regs->ctl); |
| 955 | writel(tmp, &ep->regs->ctl); | 955 | ep->naking = 0; |
| 956 | ep->naking = 0; | 956 | UDC_QUEUE_CNAK(ep, ep->num); |
| 957 | UDC_QUEUE_CNAK(ep, ep->num); | 957 | } |
| 958 | } | ||
| 959 | 958 | ||
| 960 | } | 959 | } |
| 961 | 960 | ||
| @@ -1,3 +1,4 @@ | |||
| 1 | # SPDX-License-Identifier: GPL-2.0 | ||
| 1 | # | 2 | # |
| 2 | # USB Host Controller Drivers | 3 | # USB Host Controller Drivers |
| 3 | # | 4 | # |
| @@ -69,13 +70,13 @@ config USB_XHCI_MTK · 65 unmodified lines | |||
| 69 | If unsure, say N. | 70 | If unsure, say N. |
| 70 | 71 | ||
| 71 | config USB_XHCI_MVEBU | 72 | config USB_XHCI_MVEBU |
| 72 | tristate "xHCI support for Marvell Armada 375/38x" | 73 | tristate "xHCI support for Marvell Armada 375/38x/37xx" |
| 73 | select USB_XHCI_PLATFORM | 74 | select USB_XHCI_PLATFORM |
| 74 | depends on HAS_IOMEM | 75 | depends on HAS_IOMEM |
| 75 | depends on ARCH_MVEBU || COMPILE_TEST | 76 | depends on ARCH_MVEBU || COMPILE_TEST |
| 76 | ---help--- | 77 | ---help--- |
| 77 | Say 'Y' to enable the support for the xHCI host controller | 78 | Say 'Y' to enable the support for the xHCI host controller |
| 78 | found in Marvell Armada 375/38x ARM SOCs. | 79 | found in Marvell Armada 375/38x/37xx ARM SOCs. |
| 79 | 80 | ||
| 80 | config USB_XHCI_RCAR | 81 | config USB_XHCI_RCAR |
| 81 | tristate "xHCI support for Renesas R-Car SoCs" | 82 | tristate "xHCI support for Renesas R-Car SoCs" |
| @@ -179,8 +180,7 @@ config XPS_USB_HCD_XILINX · 97 unmodified lines | |||
| 179 | devices only. | 180 | devices only. |
| 180 | 181 | ||
| 181 | config USB_EHCI_FSL | 182 | config USB_EHCI_FSL |
| 182 | tristate "Support for Freescale PPC on-chip EHCI USB controller" | 183 | tristate "Support for Freescale on-chip EHCI USB controller" |
| 183 | depends on FSL_SOC | ||
| 184 | select USB_EHCI_ROOT_HUB_TT | 184 | select USB_EHCI_ROOT_HUB_TT |
| 185 | ---help--- | 185 | ---help--- |
| 186 | Variation of ARC USB block used in some Freescale chips. | 186 | Variation of ARC USB block used in some Freescale chips. |
| @@ -23,6 +23,7 @@ · 22 unmodified lines | |||
| 23 | #include <linux/platform_device.h> | 23 | #include <linux/platform_device.h> |
| 24 | #include <linux/fsl_devices.h> | 24 | #include <linux/fsl_devices.h> |
| 25 | #include <linux/of_platform.h> | 25 | #include <linux/of_platform.h> |
| 26 | #include <linux/io.h> | ||
| 26 | 27 | ||
| 27 | #include "ehci.h" | 28 | #include "ehci.h" |
| 28 | #include "ehci-fsl.h" | 29 | #include "ehci-fsl.h" |
| @@ -50,6 +51,7 @@ static int fsl_ehci_drv_probe(struct platform_device *pdev) · 21 unmodified lines | |||
| 50 | struct resource *res; | 51 | struct resource *res; |
| 51 | int irq; | 52 | int irq; |
| 52 | int retval; | 53 | int retval; |
| 54 | u32 tmp; | ||
| 53 | 55 | ||
| 54 | pr_debug("initializing FSL-SOC USB Controller\n"); | 56 | pr_debug("initializing FSL-SOC USB Controller\n"); |
| 55 | 57 | ||
| @@ -114,17 +116,22 @@ static int fsl_ehci_drv_probe(struct platform_device *pdev) · 58 unmodified lines | |||
| 114 | } | 116 | } |
| 115 | 117 | ||
| 116 | /* Enable USB controller, 83xx or 8536 */ | 118 | /* Enable USB controller, 83xx or 8536 */ |
| 117 | if (pdata->have_sysif_regs && pdata->controller_ver < FSL_USB_VER_1_6) | 119 | if (pdata->have_sysif_regs && pdata->controller_ver < FSL_USB_VER_1_6) { |
| 118 | clrsetbits_be32(hcd->regs + FSL_SOC_USB_CTRL, | 120 | tmp = ioread32be(hcd->regs + FSL_SOC_USB_CTRL); |
| 119 | CONTROL_REGISTER_W1C_MASK, 0x4); | 121 | tmp &= ~CONTROL_REGISTER_W1C_MASK; |
| 120 | 122 | tmp |= 0x4; | |
| 123 | iowrite32be(tmp, hcd->regs + FSL_SOC_USB_CTRL); | ||
| 124 | } | ||
| 121 | /* | 125 | /* |
| 122 | * Enable UTMI phy and program PTS field in UTMI mode before asserting | 126 | * Enable UTMI phy and program PTS field in UTMI mode before asserting |
| 123 | * controller reset for USB Controller version 2.5 | 127 | * controller reset for USB Controller version 2.5 |
| 124 | */ | 128 | */ |
| 125 | if (pdata->has_fsl_erratum_a007792) { | 129 | if (pdata->has_fsl_erratum_a007792) { |
| 126 | clrsetbits_be32(hcd->regs + FSL_SOC_USB_CTRL, | 130 | tmp = ioread32be(hcd->regs + FSL_SOC_USB_CTRL); |
| 127 | CONTROL_REGISTER_W1C_MASK, CTRL_UTMI_PHY_EN); | 131 | tmp &= ~CONTROL_REGISTER_W1C_MASK; |
| 132 | tmp |= CTRL_UTMI_PHY_EN; | ||
| 133 | iowrite32be(tmp, hcd->regs + FSL_SOC_USB_CTRL); | ||
| 134 | |||
| 128 | writel(PORT_PTS_UTMI, hcd->regs + FSL_SOC_USB_PORTSC1); | 135 | writel(PORT_PTS_UTMI, hcd->regs + FSL_SOC_USB_PORTSC1); |
| 129 | } | 136 | } |
| 130 | 137 | ||
| @@ -174,7 +181,7 @@ static int ehci_fsl_setup_phy(struct usb_hcd *hcd, · 43 unmodified lines | |||
| 174 | enum fsl_usb2_phy_modes phy_mode, | 181 | enum fsl_usb2_phy_modes phy_mode, |
| 175 | unsigned int port_offset) | 182 | unsigned int port_offset) |
| 176 | { | 183 | { |
| 177 | u32 portsc; | 184 | u32 portsc, tmp; |
| 178 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); | 185 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); |
| 179 | void __iomem *non_ehci = hcd->regs; | 186 | void __iomem *non_ehci = hcd->regs; |
| 180 | struct device *dev = hcd->self.controller; | 187 | struct device *dev = hcd->self.controller; |
| @@ -192,11 +199,16 @@ static int ehci_fsl_setup_phy(struct usb_hcd *hcd, · 11 unmodified lines | |||
| 192 | case FSL_USB2_PHY_ULPI: | 199 | case FSL_USB2_PHY_ULPI: |
| 193 | if (pdata->have_sysif_regs && pdata->controller_ver) { | 200 | if (pdata->have_sysif_regs && pdata->controller_ver) { |
| 194 | /* controller version 1.6 or above */ | 201 | /* controller version 1.6 or above */ |
| 195 | clrbits32(non_ehci + FSL_SOC_USB_CTRL, | 202 | /* turn off UTMI PHY first */ |
| 196 | CONTROL_REGISTER_W1C_MASK | UTMI_PHY_EN); | 203 | tmp = ioread32be(non_ehci + FSL_SOC_USB_CTRL); |
| 197 | clrsetbits_be32(non_ehci + FSL_SOC_USB_CTRL, | 204 | tmp &= ~(CONTROL_REGISTER_W1C_MASK | UTMI_PHY_EN); |
| 198 | CONTROL_REGISTER_W1C_MASK, | 205 | iowrite32be(tmp, non_ehci + FSL_SOC_USB_CTRL); |
| 199 | ULPI_PHY_CLK_SEL | USB_CTRL_USB_EN); | 206 | |
| 207 | /* then turn on ULPI and enable USB controller */ | ||
| 208 | tmp = ioread32be(non_ehci + FSL_SOC_USB_CTRL); | ||
| 209 | tmp &= ~CONTROL_REGISTER_W1C_MASK; | ||
| 210 | tmp |= ULPI_PHY_CLK_SEL | USB_CTRL_USB_EN; | ||
| 211 | iowrite32be(tmp, non_ehci + FSL_SOC_USB_CTRL); | ||
| 200 | } | 212 | } |
| 201 | portsc |= PORT_PTS_ULPI; | 213 | portsc |= PORT_PTS_ULPI; |
| 202 | break; | 214 | break; |
| @@ -210,16 +222,21 @@ static int ehci_fsl_setup_phy(struct usb_hcd *hcd, · 7 unmodified lines | |||
| 210 | case FSL_USB2_PHY_UTMI_DUAL: | 222 | case FSL_USB2_PHY_UTMI_DUAL: |
| 211 | if (pdata->have_sysif_regs && pdata->controller_ver) { | 223 | if (pdata->have_sysif_regs && pdata->controller_ver) { |
| 212 | /* controller version 1.6 or above */ | 224 | /* controller version 1.6 or above */ |
| 213 | clrsetbits_be32(non_ehci + FSL_SOC_USB_CTRL, | 225 | tmp = ioread32be(non_ehci + FSL_SOC_USB_CTRL); |
| 214 | CONTROL_REGISTER_W1C_MASK, UTMI_PHY_EN); | 226 | tmp &= ~CONTROL_REGISTER_W1C_MASK; |
| 227 | tmp |= UTMI_PHY_EN; | ||
| 228 | iowrite32be(tmp, non_ehci + FSL_SOC_USB_CTRL); | ||
| 229 | |||
| 215 | mdelay(FSL_UTMI_PHY_DLY); /* Delay for UTMI PHY CLK to | 230 | mdelay(FSL_UTMI_PHY_DLY); /* Delay for UTMI PHY CLK to |
| 216 | become stable - 10ms*/ | 231 | become stable - 10ms*/ |
| 217 | } | 232 | } |
| 218 | /* enable UTMI PHY */ | 233 | /* enable UTMI PHY */ |
| 219 | if (pdata->have_sysif_regs) | 234 | if (pdata->have_sysif_regs) { |
| 220 | clrsetbits_be32(non_ehci + FSL_SOC_USB_CTRL, | 235 | tmp = ioread32be(non_ehci + FSL_SOC_USB_CTRL); |
| 221 | CONTROL_REGISTER_W1C_MASK, | 236 | tmp &= ~CONTROL_REGISTER_W1C_MASK; |
| 222 | CTRL_UTMI_PHY_EN); | 237 | tmp |= CTRL_UTMI_PHY_EN; |
| 238 | iowrite32be(tmp, non_ehci + FSL_SOC_USB_CTRL); | ||
| 239 | } | ||
| 223 | portsc |= PORT_PTS_UTMI; | 240 | portsc |= PORT_PTS_UTMI; |
| 224 | break; | 241 | break; |
| 225 | case FSL_USB2_PHY_NONE: | 242 | case FSL_USB2_PHY_NONE: |
| @@ -241,9 +258,12 @@ static int ehci_fsl_setup_phy(struct usb_hcd *hcd, · 15 unmodified lines | |||
| 241 | 258 | ||
| 242 | ehci_writel(ehci, portsc, &ehci->regs->port_status[port_offset]); | 259 | ehci_writel(ehci, portsc, &ehci->regs->port_status[port_offset]); |
| 243 | 260 | ||
| 244 | if (phy_mode != FSL_USB2_PHY_ULPI && pdata->have_sysif_regs) | 261 | if (phy_mode != FSL_USB2_PHY_ULPI && pdata->have_sysif_regs) { |
| 245 | clrsetbits_be32(non_ehci + FSL_SOC_USB_CTRL, | 262 | tmp = ioread32be(non_ehci + FSL_SOC_USB_CTRL); |
| 246 | CONTROL_REGISTER_W1C_MASK, USB_CTRL_USB_EN); | 263 | tmp &= ~CONTROL_REGISTER_W1C_MASK; |
| 264 | tmp |= USB_CTRL_USB_EN; | ||
| 265 | iowrite32be(tmp, non_ehci + FSL_SOC_USB_CTRL); | ||
| 266 | } | ||
| 247 | 267 | ||
| 248 | return 0; | 268 | return 0; |
| 249 | } | 269 | } |
| @@ -284,14 +304,9 @@ static int ehci_fsl_usb_setup(struct ehci_hcd *ehci) · 34 unmodified lines | |||
| 284 | return -EINVAL; | 304 | return -EINVAL; |
| 285 | 305 | ||
| 286 | if (pdata->operating_mode == FSL_USB2_MPH_HOST) { | 306 | if (pdata->operating_mode == FSL_USB2_MPH_HOST) { |
| 287 | unsigned int chip, rev, svr; | ||
| 288 | |||
| 289 | svr = mfspr(SPRN_SVR); | ||
| 290 | chip = svr >> 16; | ||
| 291 | rev = (svr >> 4) & 0xf; | ||
| 292 | 307 | ||
| 293 | /* Deal with USB Erratum #14 on MPC834x Rev 1.0 & 1.1 chips */ | 308 | /* Deal with USB Erratum #14 on MPC834x Rev 1.0 & 1.1 chips */ |
| 294 | if ((rev == 1) && (chip >= 0x8050) && (chip <= 0x8055)) | 309 | if (pdata->has_fsl_erratum_14 == 1) |
| 295 | ehci->has_fsl_port_bug = 1; | 310 | ehci->has_fsl_port_bug = 1; |
| 296 | 311 | ||
| 297 | if (pdata->port_enables & FSL_USB2_PORT0_ENABLED) | 312 | if (pdata->port_enables & FSL_USB2_PORT0_ENABLED) |
| @@ -182,6 +182,23 @@ static int ehci_orion_drv_reset(struct usb_hcd *hcd) · 181 unmodified lines | |||
| 182 | return ret; | 182 | return ret; |
| 183 | } | 183 | } |
| 184 | 184 | ||
| 185 | static int __maybe_unused ehci_orion_drv_suspend(struct device *dev) | ||
| 186 | { | ||
| 187 | struct usb_hcd *hcd = dev_get_drvdata(dev); | ||
| 188 | |||
| 189 | return ehci_suspend(hcd, device_may_wakeup(dev)); | ||
| 190 | } | ||
| 191 | |||
| 192 | static int __maybe_unused ehci_orion_drv_resume(struct device *dev) | ||
| 193 | { | ||
| 194 | struct usb_hcd *hcd = dev_get_drvdata(dev); | ||
| 195 | |||
| 196 | return ehci_resume(hcd, false); | ||
| 197 | } | ||
| 198 | |||
| 199 | static SIMPLE_DEV_PM_OPS(ehci_orion_pm_ops, ehci_orion_drv_suspend, | ||
| 200 | ehci_orion_drv_resume); | ||
| 201 | |||
| 185 | static const struct ehci_driver_overrides orion_overrides __initconst = { | 202 | static const struct ehci_driver_overrides orion_overrides __initconst = { |
| 186 | .extra_priv_size = sizeof(struct orion_ehci_hcd), | 203 | .extra_priv_size = sizeof(struct orion_ehci_hcd), |
| 187 | .reset = ehci_orion_drv_reset, | 204 | .reset = ehci_orion_drv_reset, |
| @@ -257,15 +274,7 @@ static int ehci_orion_drv_probe(struct platform_device *pdev) · 69 unmodified lines | |||
| 257 | if (IS_ERR(priv->phy)) { | 274 | if (IS_ERR(priv->phy)) { |
| 258 | err = PTR_ERR(priv->phy); | 275 | err = PTR_ERR(priv->phy); |
| 259 | if (err != -ENOSYS) | 276 | if (err != -ENOSYS) |
| 260 | goto err_phy_get; | 277 | goto err_dis_clk; |
| 261 | } else { | ||
| 262 | err = phy_init(priv->phy); | ||
| 263 | if (err) | ||
| 264 | goto err_phy_init; | ||
| 265 | |||
| 266 | err = phy_power_on(priv->phy); | ||
| 267 | if (err) | ||
| 268 | goto err_phy_power_on; | ||
| 269 | } | 278 | } |
| 270 | 279 | ||
| 271 | /* | 280 | /* |
| @@ -297,19 +306,12 @@ static int ehci_orion_drv_probe(struct platform_device *pdev) · 25 unmodified lines | |||
| 297 | 306 | ||
| 298 | err = usb_add_hcd(hcd, irq, IRQF_SHARED); | 307 | err = usb_add_hcd(hcd, irq, IRQF_SHARED); |
| 299 | if (err) | 308 | if (err) |
| 300 | goto err_add_hcd; | 309 | goto err_dis_clk; |
| 301 | 310 | ||
| 302 | device_wakeup_enable(hcd->self.controller); | 311 | device_wakeup_enable(hcd->self.controller); |
| 303 | return 0; | 312 | return 0; |
| 304 | 313 | ||
| 305 | err_add_hcd: | 314 | err_dis_clk: |
| 306 | if (!IS_ERR(priv->phy)) | ||
| 307 | phy_power_off(priv->phy); | ||
| 308 | err_phy_power_on: | ||
| 309 | if (!IS_ERR(priv->phy)) | ||
| 310 | phy_exit(priv->phy); | ||
| 311 | err_phy_init: | ||
| 312 | err_phy_get: | ||
| 313 | if (!IS_ERR(priv->clk)) | 315 | if (!IS_ERR(priv->clk)) |
| 314 | clk_disable_unprepare(priv->clk); | 316 | clk_disable_unprepare(priv->clk); |
| 315 | usb_put_hcd(hcd); | 317 | usb_put_hcd(hcd); |
| @@ -327,11 +329,6 @@ static int ehci_orion_drv_remove(struct platform_device *pdev) · 11 unmodified lines | |||
| 327 | 329 | ||
| 328 | usb_remove_hcd(hcd); | 330 | usb_remove_hcd(hcd); |
| 329 | 331 | ||
| 330 | if (!IS_ERR(priv->phy)) { | ||
| 331 | phy_power_off(priv->phy); | ||
| 332 | phy_exit(priv->phy); | ||
| 333 | } | ||
| 334 | |||
| 335 | if (!IS_ERR(priv->clk)) | 332 | if (!IS_ERR(priv->clk)) |
| 336 | clk_disable_unprepare(priv->clk); | 333 | clk_disable_unprepare(priv->clk); |
| 337 | 334 | ||
| @@ -354,6 +351,7 @@ static struct platform_driver ehci_orion_driver = { · 16 unmodified lines | |||
| 354 | .driver = { | 351 | .driver = { |
| 355 | .name = "orion-ehci", | 352 | .name = "orion-ehci", |
| 356 | .of_match_table = ehci_orion_dt_ids, | 353 | .of_match_table = ehci_orion_dt_ids, |
| 354 | .pm = &ehci_orion_pm_ops, | ||
| 357 | }, | 355 | }, |
| 358 | }; | 356 | }; |
| 359 | 357 | ||
| @@ -225,6 +225,12 @@ static int fsl_usb2_mph_dr_of_probe(struct platform_device *ofdev) · 224 unmodified lines | |||
| 225 | pdata->has_fsl_erratum_a005697 = | 225 | pdata->has_fsl_erratum_a005697 = |
| 226 | of_property_read_bool(np, "fsl,usb_erratum-a005697"); | 226 | of_property_read_bool(np, "fsl,usb_erratum-a005697"); |
| 227 | 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 | |||
| 233 | |||
| 228 | /* | 234 | /* |
| 229 | * Determine whether phy_clk_valid needs to be checked | 235 | * Determine whether phy_clk_valid needs to be checked |
| 230 | * by reading property in device tree | 236 | * by reading property in device tree |
| @@ -141,8 +141,11 @@ static struct regmap *at91_dt_syscon_sfr(void) · 140 unmodified lines | |||
| 141 | struct regmap *regmap; | 141 | struct regmap *regmap; |
| 142 | 142 | ||
| 143 | regmap = syscon_regmap_lookup_by_compatible("atmel,sama5d2-sfr"); | 143 | regmap = syscon_regmap_lookup_by_compatible("atmel,sama5d2-sfr"); |
| 144 | if (IS_ERR(regmap)) | 144 | if (IS_ERR(regmap)) { |
| 145 | regmap = NULL; | 145 | regmap = syscon_regmap_lookup_by_compatible("microchip,sam9x60-sfr"); |
| 146 | if (IS_ERR(regmap)) | ||
| 147 | regmap = NULL; | ||
| 148 | } | ||
| 146 | 149 | ||
| 147 | return regmap; | 150 | return regmap; |
| 148 | } | 151 | } |
| @@ -1323,7 +1323,7 @@ static struct list_head *qh_urb_transaction(struct oxu_hcd *oxu, · 1322 unmodified lines | |||
| 1323 | } | 1323 | } |
| 1324 | 1324 | ||
| 1325 | /* by default, enable interrupt on urb completion */ | 1325 | /* by default, enable interrupt on urb completion */ |
| 1326 | qtd->hw_token |= cpu_to_le32(QTD_IOC); | 1326 | qtd->hw_token |= cpu_to_le32(QTD_IOC); |
| 1327 | return head; | 1327 | return head; |
| 1328 | 1328 | ||
| 1329 | cleanup: | 1329 | cleanup: |
| @@ -2253,16 +2253,12 @@ static void scan_periodic(struct oxu_hcd *oxu) · 923 unmodified lines | |||
| 2253 | for (;;) { | 2253 | for (;;) { |
| 2254 | union ehci_shadow q, *q_p; | 2254 | union ehci_shadow q, *q_p; |
| 2255 | __le32 type, *hw_p; | 2255 | __le32 type, *hw_p; |
| 2256 | unsigned uframes; | ||
| 2257 | 2256 | ||
| 2258 | /* don't scan past the live uframe */ | 2257 | /* don't scan past the live uframe */ |
| 2259 | frame = now_uframe >> 3; | 2258 | frame = now_uframe >> 3; |
| 2260 | if (frame == (clock >> 3)) | 2259 | if (frame != (clock >> 3)) { |
| 2261 | uframes = now_uframe & 0x07; | ||
| 2262 | else { | ||
| 2263 | /* safe to scan the whole frame at once */ | 2260 | /* safe to scan the whole frame at once */ |
| 2264 | now_uframe |= 0x07; | 2261 | now_uframe |= 0x07; |
| 2265 | uframes = 8; | ||
| 2266 | } | 2262 | } |
| 2267 | 2263 | ||
| 2268 | restart: | 2264 | restart: |
| @@ -2832,7 +2828,6 @@ static int oxu_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, · 563 unmodified lines | |||
| 2832 | { | 2828 | { |
| 2833 | struct oxu_hcd *oxu = hcd_to_oxu(hcd); | 2829 | struct oxu_hcd *oxu = hcd_to_oxu(hcd); |
| 2834 | int num, rem; | 2830 | int num, rem; |
| 2835 | int transfer_buffer_length; | ||
| 2836 | void *transfer_buffer; | 2831 | void *transfer_buffer; |
| 2837 | struct urb *murb; | 2832 | struct urb *murb; |
| 2838 | int i, ret; | 2833 | int i, ret; |
| @@ -2843,7 +2838,6 @@ static int oxu_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, · 4 unmodified lines | |||
| 2843 | 2838 | ||
| 2844 | /* Otherwise we should verify the USB transfer buffer size! */ | 2839 | /* Otherwise we should verify the USB transfer buffer size! */ |
| 2845 | transfer_buffer = urb->transfer_buffer; | 2840 | transfer_buffer = urb->transfer_buffer; |
| 2846 | transfer_buffer_length = urb->transfer_buffer_length; | ||
| 2847 | 2841 | ||
| 2848 | num = urb->transfer_buffer_length / 4096; | 2842 | num = urb->transfer_buffer_length / 4096; |
| 2849 | rem = urb->transfer_buffer_length % 4096; | 2843 | rem = urb->transfer_buffer_length % 4096; |
| @@ -2477,7 +2477,8 @@ static int u132_endp_urb_dequeue(struct u132 *u132, struct u132_endp *endp, · 2476 unmodified lines | |||
| 2477 | spin_unlock_irqrestore(&endp->queue_lock.slock, | 2477 | spin_unlock_irqrestore(&endp->queue_lock.slock, |
| 2478 | irqs); | 2478 | irqs); |
| 2479 | kfree(urbq); | 2479 | kfree(urbq); |
| 2480 | } urb->error_count = 0; | 2480 | } |
| 2481 | urb->error_count = 0; | ||
| 2481 | usb_hcd_giveback_urb(hcd, urb, status); | 2482 | usb_hcd_giveback_urb(hcd, urb, status); |
| 2482 | return 0; | 2483 | return 0; |
| 2483 | } else if (list_empty(&endp->urb_more)) { | 2484 | } else if (list_empty(&endp->urb_more)) { |
| @@ -2982,7 +2983,8 @@ static int u132_remove(struct platform_device *pdev) · 498 unmodified lines | |||
| 2982 | while (rings-- > 0) { | 2983 | while (rings-- > 0) { |
| 2983 | struct u132_ring *ring = &u132->ring[rings]; | 2984 | struct u132_ring *ring = &u132->ring[rings]; |
| 2984 | u132_ring_cancel_work(u132, ring); | 2985 | u132_ring_cancel_work(u132, ring); |
| 2985 | } while (endps-- > 0) { | 2986 | } |
| 2987 | while (endps-- > 0) { | ||
| 2986 | struct u132_endp *endp = u132->endp[endps]; | 2988 | struct u132_endp *endp = u132->endp[endps]; |
| 2987 | if (endp) | 2989 | if (endp) |
| 2988 | u132_endp_cancel_work(u132, endp); | 2990 | u132_endp_cancel_work(u132, endp); |
| @@ -1,3 +1,5 @@ | |||
| 1 | # SPDX-License-Identifier: GPL-2.0 | ||
| 2 | |||
| 1 | obj-$(CONFIG_USB_WHCI_HCD) += whci-hcd.o | 3 | obj-$(CONFIG_USB_WHCI_HCD) += whci-hcd.o |
| 2 | 4 | ||
| 3 | whci-hcd-y := \ | 5 | whci-hcd-y := \ |
| @@ -181,7 +181,7 @@ static void xhci_dbc_flush_endpoint_requests(struct dbc_ep *dep) · 180 unmodified lines | |||
| 181 | xhci_dbc_flush_single_request(req); | 181 | xhci_dbc_flush_single_request(req); |
| 182 | } | 182 | } |
| 183 | 183 | ||
| 184 | static void xhci_dbc_flush_reqests(struct xhci_dbc *dbc) | 184 | static void xhci_dbc_flush_requests(struct xhci_dbc *dbc) |
| 185 | { | 185 | { |
| 186 | xhci_dbc_flush_endpoint_requests(&dbc->eps[BULK_OUT]); | 186 | xhci_dbc_flush_endpoint_requests(&dbc->eps[BULK_OUT]); |
| 187 | xhci_dbc_flush_endpoint_requests(&dbc->eps[BULK_IN]); | 187 | xhci_dbc_flush_endpoint_requests(&dbc->eps[BULK_IN]); |
| @@ -687,7 +687,7 @@ static enum evtreturn xhci_dbc_do_handle_events(struct xhci_dbc *dbc) · 499 unmodified lines | |||
| 687 | !(portsc & DBC_PORTSC_CONN_STATUS)) { | 687 | !(portsc & DBC_PORTSC_CONN_STATUS)) { |
| 688 | xhci_info(xhci, "DbC cable unplugged\n"); | 688 | xhci_info(xhci, "DbC cable unplugged\n"); |
| 689 | dbc->state = DS_ENABLED; | 689 | dbc->state = DS_ENABLED; |
| 690 | xhci_dbc_flush_reqests(dbc); | 690 | xhci_dbc_flush_requests(dbc); |
| 691 | 691 | ||
| 692 | return EVT_DISC; | 692 | return EVT_DISC; |
| 693 | } | 693 | } |
| @@ -697,7 +697,7 @@ static enum evtreturn xhci_dbc_do_handle_events(struct xhci_dbc *dbc) · 3 unmodified lines | |||
| 697 | xhci_info(xhci, "DbC port reset\n"); | 697 | xhci_info(xhci, "DbC port reset\n"); |
| 698 | writel(portsc, &dbc->regs->portsc); | 698 | writel(portsc, &dbc->regs->portsc); |
| 699 | dbc->state = DS_ENABLED; | 699 | dbc->state = DS_ENABLED; |
| 700 | xhci_dbc_flush_reqests(dbc); | 700 | xhci_dbc_flush_requests(dbc); |
| 701 | 701 | ||
| 702 | return EVT_DISC; | 702 | return EVT_DISC; |
| 703 | } | 703 | } |
| @@ -80,7 +80,6 @@ struct xhci_regset { · 79 unmodified lines | |||
| 80 | char name[DEBUGFS_NAMELEN]; | 80 | char name[DEBUGFS_NAMELEN]; |
| 81 | struct debugfs_regset32 regset; | 81 | struct debugfs_regset32 regset; |
| 82 | size_t nregs; | 82 | size_t nregs; |
| 83 | struct dentry *parent; | ||
| 84 | struct list_head list; | 83 | struct list_head list; |
| 85 | }; | 84 | }; |
| 86 | 85 | ||
| @@ -933,7 +933,7 @@ void xhci_free_virt_device(struct xhci_hcd *xhci, int slot_id) · 932 unmodified lines | |||
| 933 | * that tt_info, then free the child first. Recursive. | 933 | * that tt_info, then free the child first. Recursive. |
| 934 | * We can't rely on udev at this point to find child-parent relationships. | 934 | * We can't rely on udev at this point to find child-parent relationships. |
| 935 | */ | 935 | */ |
| 936 | void xhci_free_virt_devices_depth_first(struct xhci_hcd *xhci, int slot_id) | 936 | static void xhci_free_virt_devices_depth_first(struct xhci_hcd *xhci, int slot_id) |
| 937 | { | 937 | { |
| 938 | struct xhci_virt_device *vdev; | 938 | struct xhci_virt_device *vdev; |
| 939 | struct list_head *tt_list_head; | 939 | struct list_head *tt_list_head; |
| @@ -13,6 +13,7 @@ · 12 unmodified lines | |||
| 13 | #include <linux/usb/hcd.h> | 13 | #include <linux/usb/hcd.h> |
| 14 | 14 | ||
| 15 | #include "xhci-mvebu.h" | 15 | #include "xhci-mvebu.h" |
| 16 | #include "xhci.h" | ||
| 16 | 17 | ||
| 17 | #define USB3_MAX_WINDOWS 4 | 18 | #define USB3_MAX_WINDOWS 4 |
| 18 | #define USB3_WIN_CTRL(w) (0x0 + ((w) * 8)) | 19 | #define USB3_WIN_CTRL(w) (0x0 + ((w) * 8)) |
| @@ -72,3 +73,13 @@ int xhci_mvebu_mbus_init_quirk(struct usb_hcd *hcd) · 53 unmodified lines | |||
| 72 | 73 | ||
| 73 | return 0; | 74 | return 0; |
| 74 | } | 75 | } |
| 76 | |||
| 77 | int xhci_mvebu_a3700_init_quirk(struct usb_hcd *hcd) | ||
| 78 | { | ||
| 79 | struct xhci_hcd *xhci = hcd_to_xhci(hcd); | ||
| 80 | |||
| 81 | /* Without reset on resume, the HC won't work at all */ | ||
| 82 | xhci->quirks |= XHCI_RESET_ON_RESUME; | ||
| 83 | |||
| 84 | return 0; | ||
| 85 | } | ||
| @@ -12,10 +12,16 @@ struct usb_hcd; · 11 unmodified lines | |||
| 12 | 12 | ||
| 13 | #if IS_ENABLED(CONFIG_USB_XHCI_MVEBU) | 13 | #if IS_ENABLED(CONFIG_USB_XHCI_MVEBU) |
| 14 | int xhci_mvebu_mbus_init_quirk(struct usb_hcd *hcd); | 14 | int xhci_mvebu_mbus_init_quirk(struct usb_hcd *hcd); |
| 15 | int xhci_mvebu_a3700_init_quirk(struct usb_hcd *hcd); | ||
| 15 | #else | 16 | #else |
| 16 | static inline int xhci_mvebu_mbus_init_quirk(struct usb_hcd *hcd) | 17 | static inline int xhci_mvebu_mbus_init_quirk(struct usb_hcd *hcd) |
| 17 | { | 18 | { |
| 18 | return 0; | 19 | return 0; |
| 19 | } | 20 | } |
| 21 | |||
| 22 | static inline int xhci_mvebu_a3700_init_quirk(struct usb_hcd *hcd) | ||
| 23 | { | ||
| 24 | return 0; | ||
| 25 | } | ||
| 20 | #endif | 26 | #endif |
| 21 | #endif /* __LINUX_XHCI_MVEBU_H */ | 27 | #endif /* __LINUX_XHCI_MVEBU_H */ |
| @@ -194,6 +194,7 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci) · 193 unmodified lines | |||
| 194 | xhci->quirks |= XHCI_SSIC_PORT_UNUSED; | 194 | xhci->quirks |= XHCI_SSIC_PORT_UNUSED; |
| 195 | if (pdev->vendor == PCI_VENDOR_ID_INTEL && | 195 | if (pdev->vendor == PCI_VENDOR_ID_INTEL && |
| 196 | (pdev->device == PCI_DEVICE_ID_INTEL_CHERRYVIEW_XHCI || | 196 | (pdev->device == PCI_DEVICE_ID_INTEL_CHERRYVIEW_XHCI || |
| 197 | pdev->device == PCI_DEVICE_ID_INTEL_SUNRISEPOINT_LP_XHCI || | ||
| 197 | pdev->device == PCI_DEVICE_ID_INTEL_APL_XHCI)) | 198 | pdev->device == PCI_DEVICE_ID_INTEL_APL_XHCI)) |
| 198 | xhci->quirks |= XHCI_INTEL_USB_ROLE_SW; | 199 | xhci->quirks |= XHCI_INTEL_USB_ROLE_SW; |
| 199 | if (pdev->vendor == PCI_VENDOR_ID_INTEL && | 200 | if (pdev->vendor == PCI_VENDOR_ID_INTEL && |
| @@ -98,6 +98,10 @@ static const struct xhci_plat_priv xhci_plat_marvell_armada = { · 97 unmodified lines | |||
| 98 | .init_quirk = xhci_mvebu_mbus_init_quirk, | 98 | .init_quirk = xhci_mvebu_mbus_init_quirk, |
| 99 | }; | 99 | }; |
| 100 | 100 | ||
| 101 | static const struct xhci_plat_priv xhci_plat_marvell_armada3700 = { | ||
| 102 | .init_quirk = xhci_mvebu_a3700_init_quirk, | ||
| 103 | }; | ||
| 104 | |||
| 101 | static const struct xhci_plat_priv xhci_plat_renesas_rcar_gen2 = { | 105 | static const struct xhci_plat_priv xhci_plat_renesas_rcar_gen2 = { |
| 102 | .firmware_name = XHCI_RCAR_FIRMWARE_NAME_V1, | 106 | .firmware_name = XHCI_RCAR_FIRMWARE_NAME_V1, |
| 103 | .init_quirk = xhci_rcar_init_quirk, | 107 | .init_quirk = xhci_rcar_init_quirk, |
| @@ -123,6 +127,9 @@ static const struct of_device_id usb_xhci_of_match[] = { · 19 unmodified lines | |||
| 123 | }, { | 127 | }, { |
| 124 | .compatible = "marvell,armada-380-xhci", | 128 | .compatible = "marvell,armada-380-xhci", |
| 125 | .data = &xhci_plat_marvell_armada, | 129 | .data = &xhci_plat_marvell_armada, |
| 130 | }, { | ||
| 131 | .compatible = "marvell,armada3700-xhci", | ||
| 132 | .data = &xhci_plat_marvell_armada3700, | ||
| 126 | }, { | 133 | }, { |
| 127 | .compatible = "renesas,xhci-r8a7790", | 134 | .compatible = "renesas,xhci-r8a7790", |
| 128 | .data = &xhci_plat_renesas_rcar_gen2, | 135 | .data = &xhci_plat_renesas_rcar_gen2, |
| @@ -941,9 +941,9 @@ static void tegra_xusb_powerdomain_remove(struct device *dev, · 940 unmodified lines | |||
| 941 | device_link_del(tegra->genpd_dl_ss); | 941 | device_link_del(tegra->genpd_dl_ss); |
| 942 | if (tegra->genpd_dl_host) | 942 | if (tegra->genpd_dl_host) |
| 943 | device_link_del(tegra->genpd_dl_host); | 943 | device_link_del(tegra->genpd_dl_host); |
| 944 | if (tegra->genpd_dev_ss) | 944 | if (!IS_ERR_OR_NULL(tegra->genpd_dev_ss)) |
| 945 | dev_pm_domain_detach(tegra->genpd_dev_ss, true); | 945 | dev_pm_domain_detach(tegra->genpd_dev_ss, true); |
| 946 | if (tegra->genpd_dev_host) | 946 | if (!IS_ERR_OR_NULL(tegra->genpd_dev_host)) |
| 947 | dev_pm_domain_detach(tegra->genpd_dev_host, true); | 947 | dev_pm_domain_detach(tegra->genpd_dev_host, true); |
| 948 | } | 948 | } |
| 949 | 949 | ||
| @@ -1455,8 +1455,7 @@ static int xhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flag · 1454 unmodified lines | |||
| 1455 | else | 1455 | else |
| 1456 | num_tds = 1; | 1456 | num_tds = 1; |
| 1457 | 1457 | ||
| 1458 | urb_priv = kzalloc(sizeof(struct urb_priv) + | 1458 | urb_priv = kzalloc(struct_size(urb_priv, td, num_tds), mem_flags); |
| 1459 | num_tds * sizeof(struct xhci_td), mem_flags); | ||
| 1460 | if (!urb_priv) | 1459 | if (!urb_priv) |
| 1461 | return -ENOMEM; | 1460 | return -ENOMEM; |
| 1462 | 1461 | ||
| @@ -1,3 +1,4 @@ | |||
| 1 | # SPDX-License-Identifier: GPL-2.0 | ||
| 1 | # | 2 | # |
| 2 | # USB Imaging devices configuration | 3 | # USB Imaging devices configuration |
| 3 | # | 4 | # |
| @@ -1,3 +1,5 @@ | |||
| 1 | # SPDX-License-Identifier: GPL-2.0 | ||
| 2 | |||
| 1 | config USB_ISP1760 | 3 | config USB_ISP1760 |
| 2 | tristate "NXP ISP 1760/1761 support" | 4 | tristate "NXP ISP 1760/1761 support" |
| 3 | depends on USB || USB_GADGET | 5 | depends on USB || USB_GADGET |
| @@ -1,3 +1,4 @@ | |||
| 1 | # SPDX-License-Identifier: GPL-2.0 | ||
| 1 | # | 2 | # |
| 2 | # USB Miscellaneous driver configuration | 3 | # USB Miscellaneous driver configuration |
| 3 | # | 4 | # |
| @@ -915,7 +915,6 @@ static int ftdi_elan_respond_engine(struct usb_ftdi *ftdi) · 914 unmodified lines | |||
| 915 | int bytes_read = 0; | 915 | int bytes_read = 0; |
| 916 | int retry_on_empty = 1; | 916 | int retry_on_empty = 1; |
| 917 | int retry_on_timeout = 3; | 917 | int retry_on_timeout = 3; |
| 918 | int empty_packets = 0; | ||
| 919 | read:{ | 918 | read:{ |
| 920 | int packet_bytes = 0; | 919 | int packet_bytes = 0; |
| 921 | int retval = usb_bulk_msg(ftdi->udev, | 920 | int retval = usb_bulk_msg(ftdi->udev, |
| @@ -960,31 +959,6 @@ read:{ · 38 unmodified lines | |||
| 960 | dev_err(&ftdi->udev->dev, "error = %d with packet_bytes = %d with total %d bytes%s\n", | 959 | dev_err(&ftdi->udev->dev, "error = %d with packet_bytes = %d with total %d bytes%s\n", |
| 961 | retval, packet_bytes, bytes_read, diag); | 960 | retval, packet_bytes, bytes_read, diag); |
| 962 | return retval; | 961 | return retval; |
| 963 | } else if (packet_bytes == 2) { | ||
| 964 | unsigned char s0 = ftdi->bulk_in_buffer[0]; | ||
| 965 | unsigned char s1 = ftdi->bulk_in_buffer[1]; | ||
| 966 | empty_packets += 1; | ||
| 967 | if (s0 == 0x31 && s1 == 0x60) { | ||
| 968 | if (retry_on_empty-- > 0) { | ||
| 969 | goto more; | ||
| 970 | } else | ||
| 971 | return 0; | ||
| 972 | } else if (s0 == 0x31 && s1 == 0x00) { | ||
| 973 | if (retry_on_empty-- > 0) { | ||
| 974 | goto more; | ||
| 975 | } else | ||
| 976 | return 0; | ||
| 977 | } else { | ||
| 978 | if (retry_on_empty-- > 0) { | ||
| 979 | goto more; | ||
| 980 | } else | ||
| 981 | return 0; | ||
| 982 | } | ||
| 983 | } else if (packet_bytes == 1) { | ||
| 984 | if (retry_on_empty-- > 0) { | ||
| 985 | goto more; | ||
| 986 | } else | ||
| 987 | return 0; | ||
| 988 | } else { | 962 | } else { |
| 989 | if (retry_on_empty-- > 0) { | 963 | if (retry_on_empty-- > 0) { |
| 990 | goto more; | 964 | goto more; |
| @@ -1,3 +1,4 @@ | |||
| 1 | # SPDX-License-Identifier: GPL-2.0 | ||
| 1 | 2 | ||
| 2 | config USB_SISUSBVGA | 3 | config USB_SISUSBVGA |
| 3 | tristate "USB 2.0 SVGA dongle support (Net2280/SiS315)" | 4 | tristate "USB 2.0 SVGA dongle support (Net2280/SiS315)" |
| @@ -5,4 +5,5 @@ · 4 unmodified lines | |||
| 5 | 5 | ||
| 6 | obj-$(CONFIG_USB_SISUSBVGA) += sisusbvga.o | 6 | obj-$(CONFIG_USB_SISUSBVGA) += sisusbvga.o |
| 7 | 7 | ||
| 8 | sisusbvga-y := sisusb.o sisusb_init.o sisusb_con.o | 8 | sisusbvga-y := sisusb.o |
| 9 | sisusbvga-$(CONFIG_USB_SISUSBVGA_CON) += sisusb_con.o sisusb_init.o | ||
| @@ -53,7 +53,7 @@ · 52 unmodified lines | |||
| 53 | #include "sisusb.h" | 53 | #include "sisusb.h" |
| 54 | #include "sisusb_init.h" | 54 | #include "sisusb_init.h" |
| 55 | 55 | ||
| 56 | #ifdef INCL_SISUSB_CON | 56 | #ifdef CONFIG_USB_SISUSBVGA_CON |
| 57 | #include <linux/font.h> | 57 | #include <linux/font.h> |
| 58 | #endif | 58 | #endif |
| 59 | 59 | ||
| @@ -61,7 +61,7 @@ · 1 unmodified line | |||
| 61 | 61 | ||
| 62 | /* Forward declarations / clean-up routines */ | 62 | /* Forward declarations / clean-up routines */ |
| 63 | 63 | ||
| 64 | #ifdef INCL_SISUSB_CON | 64 | #ifdef CONFIG_USB_SISUSBVGA_CON |
| 65 | static int sisusb_first_vc; | 65 | static int sisusb_first_vc; |
| 66 | static int sisusb_last_vc; | 66 | static int sisusb_last_vc; |
| 67 | module_param_named(first, sisusb_first_vc, int, 0); | 67 | module_param_named(first, sisusb_first_vc, int, 0); |
| @@ -1198,7 +1198,7 @@ static int sisusb_read_mem_bulk(struct sisusb_usb_data *sisusb, u32 addr, · 1130 unmodified lines | |||
| 1198 | 1198 | ||
| 1199 | /* High level: Gfx (indexed) register access */ | 1199 | /* High level: Gfx (indexed) register access */ |
| 1200 | 1200 | ||
| 1201 | #ifdef INCL_SISUSB_CON | 1201 | #ifdef CONFIG_USB_SISUSBVGA_CON |
| 1202 | int sisusb_setreg(struct sisusb_usb_data *sisusb, int port, u8 data) | 1202 | int sisusb_setreg(struct sisusb_usb_data *sisusb, int port, u8 data) |
| 1203 | { | 1203 | { |
| 1204 | return sisusb_write_memio_byte(sisusb, SISUSB_TYPE_IO, port, data); | 1204 | return sisusb_write_memio_byte(sisusb, SISUSB_TYPE_IO, port, data); |
| @@ -1272,7 +1272,7 @@ int sisusb_setidxregand(struct sisusb_usb_data *sisusb, int port, · 67 unmodified lines | |||
| 1272 | 1272 | ||
| 1273 | /* Write/read video ram */ | 1273 | /* Write/read video ram */ |
| 1274 | 1274 | ||
| 1275 | #ifdef INCL_SISUSB_CON | 1275 | #ifdef CONFIG_USB_SISUSBVGA_CON |
| 1276 | int sisusb_writeb(struct sisusb_usb_data *sisusb, u32 adr, u8 data) | 1276 | int sisusb_writeb(struct sisusb_usb_data *sisusb, u32 adr, u8 data) |
| 1277 | { | 1277 | { |
| 1278 | return sisusb_write_memio_byte(sisusb, SISUSB_TYPE_MEM, adr, data); | 1278 | return sisusb_write_memio_byte(sisusb, SISUSB_TYPE_MEM, adr, data); |
| @@ -2255,7 +2255,7 @@ static int sisusb_init_gfxdevice(struct sisusb_usb_data *sisusb, int initscreen) · 976 unmodified lines | |||
| 2255 | } | 2255 | } |
| 2256 | 2256 | ||
| 2257 | 2257 | ||
| 2258 | #ifdef INCL_SISUSB_CON | 2258 | #ifdef CONFIG_USB_SISUSBVGA_CON |
| 2259 | 2259 | ||
| 2260 | /* Set up default text mode: | 2260 | /* Set up default text mode: |
| 2261 | * - Set text mode (0x03) | 2261 | * - Set text mode (0x03) |
| @@ -2448,7 +2448,7 @@ void sisusb_delete(struct kref *kref) · 186 unmodified lines | |||
| 2448 | sisusb->sisusb_dev = NULL; | 2448 | sisusb->sisusb_dev = NULL; |
| 2449 | sisusb_free_buffers(sisusb); | 2449 | sisusb_free_buffers(sisusb); |
| 2450 | sisusb_free_urbs(sisusb); | 2450 | sisusb_free_urbs(sisusb); |
| 2451 | #ifdef INCL_SISUSB_CON | 2451 | #ifdef CONFIG_USB_SISUSBVGA_CON |
| 2452 | kfree(sisusb->SiS_Pr); | 2452 | kfree(sisusb->SiS_Pr); |
| 2453 | #endif | 2453 | #endif |
| 2454 | kfree(sisusb); | 2454 | kfree(sisusb); |
| @@ -2844,7 +2844,7 @@ static int sisusb_handle_command(struct sisusb_usb_data *sisusb, · 389 unmodified lines | |||
| 2844 | 2844 | ||
| 2845 | case SUCMD_HANDLETEXTMODE: | 2845 | case SUCMD_HANDLETEXTMODE: |
| 2846 | retval = 0; | 2846 | retval = 0; |
| 2847 | #ifdef INCL_SISUSB_CON | 2847 | #ifdef CONFIG_USB_SISUSBVGA_CON |
| 2848 | /* Gfx core must be initialized, SiS_Pr must exist */ | 2848 | /* Gfx core must be initialized, SiS_Pr must exist */ |
| 2849 | if (!sisusb->gfxinit || !sisusb->SiS_Pr) | 2849 | if (!sisusb->gfxinit || !sisusb->SiS_Pr) |
| 2850 | return -ENODEV; | 2850 | return -ENODEV; |
| @@ -2860,7 +2860,7 @@ static int sisusb_handle_command(struct sisusb_usb_data *sisusb, · 9 unmodified lines | |||
| 2860 | #endif | 2860 | #endif |
| 2861 | break; | 2861 | break; |
| 2862 | 2862 | ||
| 2863 | #ifdef INCL_SISUSB_CON | 2863 | #ifdef CONFIG_USB_SISUSBVGA_CON |
| 2864 | case SUCMD_SETMODE: | 2864 | case SUCMD_SETMODE: |
| 2865 | /* Gfx core must be initialized, SiS_Pr must exist */ | 2865 | /* Gfx core must be initialized, SiS_Pr must exist */ |
| 2866 | if (!sisusb->gfxinit || !sisusb->SiS_Pr) | 2866 | if (!sisusb->gfxinit || !sisusb->SiS_Pr) |
| @@ -2944,7 +2944,7 @@ static long sisusb_ioctl(struct file *file, unsigned int cmd, unsigned long arg) · 77 unmodified lines | |||
| 2944 | x.sisusb_vramsize = sisusb->vramsize; | 2944 | x.sisusb_vramsize = sisusb->vramsize; |
| 2945 | x.sisusb_minor = sisusb->minor; | 2945 | x.sisusb_minor = sisusb->minor; |
| 2946 | x.sisusb_fbdevactive = 0; | 2946 | x.sisusb_fbdevactive = 0; |
| 2947 | #ifdef INCL_SISUSB_CON | 2947 | #ifdef CONFIG_USB_SISUSBVGA_CON |
| 2948 | x.sisusb_conactive = sisusb->haveconsole ? 1 : 0; | 2948 | x.sisusb_conactive = sisusb->haveconsole ? 1 : 0; |
| 2949 | #else | 2949 | #else |
| 2950 | x.sisusb_conactive = 0; | 2950 | x.sisusb_conactive = 0; |
| @@ -2975,7 +2975,7 @@ err_out: · 24 unmodified lines | |||
| 2975 | return retval; | 2975 | return retval; |
| 2976 | } | 2976 | } |
| 2977 | 2977 | ||
| 2978 | #ifdef SISUSB_NEW_CONFIG_COMPAT | 2978 | #ifdef CONFIG_COMPAT |
| 2979 | static long sisusb_compat_ioctl(struct file *f, unsigned int cmd, | 2979 | static long sisusb_compat_ioctl(struct file *f, unsigned int cmd, |
| 2980 | unsigned long arg) | 2980 | unsigned long arg) |
| 2981 | { | 2981 | { |
| @@ -2998,7 +2998,7 @@ static const struct file_operations usb_sisusb_fops = { · 16 unmodified lines | |||
| 2998 | .read = sisusb_read, | 2998 | .read = sisusb_read, |
| 2999 | .write = sisusb_write, | 2999 | .write = sisusb_write, |
| 3000 | .llseek = sisusb_lseek, | 3000 | .llseek = sisusb_lseek, |
| 3001 | #ifdef SISUSB_NEW_CONFIG_COMPAT | 3001 | #ifdef CONFIG_COMPAT |
| 3002 | .compat_ioctl = sisusb_compat_ioctl, | 3002 | .compat_ioctl = sisusb_compat_ioctl, |
| 3003 | #endif | 3003 | #endif |
| 3004 | .unlocked_ioctl = sisusb_ioctl | 3004 | .unlocked_ioctl = sisusb_ioctl |
| @@ -3091,7 +3091,7 @@ static int sisusb_probe(struct usb_interface *intf, · 86 unmodified lines | |||
| 3091 | dev_info(&sisusb->sisusb_dev->dev, "Allocated %d output buffers\n", | 3091 | dev_info(&sisusb->sisusb_dev->dev, "Allocated %d output buffers\n", |
| 3092 | sisusb->numobufs); | 3092 | sisusb->numobufs); |
| 3093 | 3093 | ||
| 3094 | #ifdef INCL_SISUSB_CON | 3094 | #ifdef CONFIG_USB_SISUSBVGA_CON |
| 3095 | /* Allocate our SiS_Pr */ | 3095 | /* Allocate our SiS_Pr */ |
| 3096 | sisusb->SiS_Pr = kmalloc(sizeof(struct SiS_Private), GFP_KERNEL); | 3096 | sisusb->SiS_Pr = kmalloc(sizeof(struct SiS_Private), GFP_KERNEL); |
| 3097 | if (!sisusb->SiS_Pr) { | 3097 | if (!sisusb->SiS_Pr) { |
| @@ -3112,7 +3112,7 @@ static int sisusb_probe(struct usb_interface *intf, · 14 unmodified lines | |||
| 3112 | 3112 | ||
| 3113 | if (dev->speed == USB_SPEED_HIGH || dev->speed >= USB_SPEED_SUPER) { | 3113 | if (dev->speed == USB_SPEED_HIGH || dev->speed >= USB_SPEED_SUPER) { |
| 3114 | int initscreen = 1; | 3114 | int initscreen = 1; |
| 3115 | #ifdef INCL_SISUSB_CON | 3115 | #ifdef CONFIG_USB_SISUSBVGA_CON |
| 3116 | if (sisusb_first_vc > 0 && sisusb_last_vc > 0 && | 3116 | if (sisusb_first_vc > 0 && sisusb_last_vc > 0 && |
| 3117 | sisusb_first_vc <= sisusb_last_vc && | 3117 | sisusb_first_vc <= sisusb_last_vc && |
| 3118 | sisusb_last_vc <= MAX_NR_CONSOLES) | 3118 | sisusb_last_vc <= MAX_NR_CONSOLES) |
| @@ -3134,7 +3134,7 @@ static int sisusb_probe(struct usb_interface *intf, · 15 unmodified lines | |||
| 3134 | dev_dbg(&sisusb->sisusb_dev->dev, "*** RWTEST END ***\n"); | 3134 | dev_dbg(&sisusb->sisusb_dev->dev, "*** RWTEST END ***\n"); |
| 3135 | #endif | 3135 | #endif |
| 3136 | 3136 | ||
| 3137 | #ifdef INCL_SISUSB_CON | 3137 | #ifdef CONFIG_USB_SISUSBVGA_CON |
| 3138 | sisusb_console_init(sisusb, sisusb_first_vc, sisusb_last_vc); | 3138 | sisusb_console_init(sisusb, sisusb_first_vc, sisusb_last_vc); |
| 3139 | #endif | 3139 | #endif |
| 3140 | 3140 | ||
| @@ -3160,7 +3160,7 @@ static void sisusb_disconnect(struct usb_interface *intf) · 19 unmodified lines | |||
| 3160 | if (!sisusb) | 3160 | if (!sisusb) |
| 3161 | return; | 3161 | return; |
| 3162 | 3162 | ||
| 3163 | #ifdef INCL_SISUSB_CON | 3163 | #ifdef CONFIG_USB_SISUSBVGA_CON |
| 3164 | sisusb_console_exit(sisusb); | 3164 | sisusb_console_exit(sisusb); |
| 3165 | #endif | 3165 | #endif |
| 3166 | 3166 | ||
| @@ -3210,7 +3210,7 @@ static struct usb_driver sisusb_driver = { · 43 unmodified lines | |||
| 3210 | static int __init usb_sisusb_init(void) | 3210 | static int __init usb_sisusb_init(void) |
| 3211 | { | 3211 | { |
| 3212 | 3212 | ||
| 3213 | #ifdef INCL_SISUSB_CON | 3213 | #ifdef CONFIG_USB_SISUSBVGA_CON |
| 3214 | sisusb_init_concode(); | 3214 | sisusb_init_concode(); |
| 3215 | #endif | 3215 | #endif |
| 3216 | 3216 | ||
| @@ -38,17 +38,8 @@ · 37 unmodified lines | |||
| 38 | #ifndef _SISUSB_H_ | 38 | #ifndef _SISUSB_H_ |
| 39 | #define _SISUSB_H_ | 39 | #define _SISUSB_H_ |
| 40 | 40 | ||
| 41 | #ifdef CONFIG_COMPAT | ||
| 42 | #define SISUSB_NEW_CONFIG_COMPAT | ||
| 43 | #endif | ||
| 44 | |||
| 45 | #include <linux/mutex.h> | 41 | #include <linux/mutex.h> |
| 46 | 42 | ||
| 47 | /* For older kernels, support for text consoles is by default | ||
| 48 | * off. To enable text console support, change the following: | ||
| 49 | */ | ||
| 50 | /* #define CONFIG_USB_SISUSBVGA_CON */ | ||
| 51 | |||
| 52 | /* Version Information */ | 43 | /* Version Information */ |
| 53 | 44 | ||
| 54 | #define SISUSB_VERSION 0 | 45 | #define SISUSB_VERSION 0 |
| @@ -57,10 +48,6 @@ · 2 unmodified lines | |||
| 57 | 48 | ||
| 58 | /* Include console and mode switching code? */ | 49 | /* Include console and mode switching code? */ |
| 59 | 50 | ||
| 60 | #ifdef CONFIG_USB_SISUSBVGA_CON | ||
| 61 | #define INCL_SISUSB_CON 1 | ||
| 62 | #endif | ||
| 63 | |||
| 64 | #include <linux/console.h> | 51 | #include <linux/console.h> |
| 65 | #include <linux/vt_kern.h> | 52 | #include <linux/vt_kern.h> |
| 66 | #include "sisusb_struct.h" | 53 | #include "sisusb_struct.h" |
| @@ -139,7 +126,7 @@ struct sisusb_usb_data { · 72 unmodified lines | |||
| 139 | unsigned char gfxinit; /* graphics core initialized? */ | 126 | unsigned char gfxinit; /* graphics core initialized? */ |
| 140 | unsigned short chipid, chipvendor; | 127 | unsigned short chipid, chipvendor; |
| 141 | unsigned short chiprevision; | 128 | unsigned short chiprevision; |
| 142 | #ifdef INCL_SISUSB_CON | 129 | #ifdef CONFIG_USB_SISUSBVGA_CON |
| 143 | struct SiS_Private *SiS_Pr; | 130 | struct SiS_Private *SiS_Pr; |
| 144 | unsigned long scrbuf; | 131 | unsigned long scrbuf; |
| 145 | unsigned int scrbuf_size; | 132 | unsigned int scrbuf_size; |
| @@ -70,13 +70,6 @@ · 69 unmodified lines | |||
| 70 | #include "sisusb.h" | 70 | #include "sisusb.h" |
| 71 | #include "sisusb_init.h" | 71 | #include "sisusb_init.h" |
| 72 | 72 | ||
| 73 | #ifdef INCL_SISUSB_CON | ||
| 74 | |||
| 75 | #define sisusbcon_writew(val, addr) (*(addr) = (val)) | ||
| 76 | #define sisusbcon_readw(addr) (*(addr)) | ||
| 77 | #define sisusbcon_memmovew(d, s, c) memmove(d, s, c) | ||
| 78 | #define sisusbcon_memcpyw(d, s, c) memcpy(d, s, c) | ||
| 79 | |||
| 80 | /* vc_data -> sisusb conversion table */ | 73 | /* vc_data -> sisusb conversion table */ |
| 81 | static struct sisusb_usb_data *mysisusbs[MAX_NR_CONSOLES]; | 74 | static struct sisusb_usb_data *mysisusbs[MAX_NR_CONSOLES]; |
| 82 | 75 | ||
| @@ -86,9 +79,7 @@ static const struct consw sisusb_con; · 3 unmodified lines | |||
| 86 | static inline void | 79 | static inline void |
| 87 | sisusbcon_memsetw(u16 *s, u16 c, unsigned int count) | 80 | sisusbcon_memsetw(u16 *s, u16 c, unsigned int count) |
| 88 | { | 81 | { |
| 89 | count /= 2; | 82 | memset16(s, c, count / 2); |
| 90 | while (count--) | ||
| 91 | sisusbcon_writew(c, s++); | ||
| 92 | } | 83 | } |
| 93 | 84 | ||
| 94 | static inline void | 85 | static inline void |
| @@ -346,25 +337,30 @@ sisusbcon_invert_region(struct vc_data *vc, u16 *p, int count) · 251 unmodified lines | |||
| 346 | */ | 337 | */ |
| 347 | 338 | ||
| 348 | while (count--) { | 339 | while (count--) { |
| 349 | u16 a = sisusbcon_readw(p); | 340 | u16 a = *p; |
| 350 | |||
| 351 | a = ((a) & 0x88ff) | | ||
| 352 | (((a) & 0x7000) >> 4) | | ||
| 353 | (((a) & 0x0700) << 4); | ||
| 354 | 341 | ||
| 355 | sisusbcon_writew(a, p++); | 342 | *p++ = ((a) & 0x88ff) | |
| 343 | (((a) & 0x7000) >> 4) | | ||
| 344 | (((a) & 0x0700) << 4); | ||
| 356 | } | 345 | } |
| 357 | } | 346 | } |
| 358 | 347 | ||
| 359 | #define SISUSB_VADDR(x,y) \ | 348 | static inline void *sisusb_vaddr(const struct sisusb_usb_data *sisusb, |
| 360 | ((u16 *)c->vc_origin + \ | 349 | const struct vc_data *c, unsigned int x, unsigned int y) |
| 361 | (y) * sisusb->sisusb_num_columns + \ | 350 | { |
| 362 | (x)) | 351 | return (u16 *)c->vc_origin + y * sisusb->sisusb_num_columns + x; |
| 352 | } | ||
| 353 | |||
| 354 | static inline unsigned long sisusb_haddr(const struct sisusb_usb_data *sisusb, | ||
| 355 | const struct vc_data *c, unsigned int x, unsigned int y) | ||
| 356 | { | ||
| 357 | unsigned long offset = c->vc_origin - sisusb->scrbuf; | ||
| 363 | 358 | ||
| 364 | #define SISUSB_HADDR(x,y) \ | 359 | /* 2 bytes per each character */ |
| 365 | ((u16 *)(sisusb->vrambase + (c->vc_origin - sisusb->scrbuf)) + \ | 360 | offset += 2 * (y * sisusb->sisusb_num_columns + x); |
| 366 | (y) * sisusb->sisusb_num_columns + \ | 361 | |
| 367 | (x)) | 362 | return sisusb->vrambase + offset; |
| 363 | } | ||
| 368 | 364 | ||
| 369 | /* Interface routine */ | 365 | /* Interface routine */ |
| 370 | static void | 366 | static void |
| @@ -382,9 +378,8 @@ sisusbcon_putc(struct vc_data *c, int ch, int y, int x) · 11 unmodified lines | |||
| 382 | return; | 378 | return; |
| 383 | } | 379 | } |
| 384 | 380 | ||
| 385 | 381 | sisusb_copy_memory(sisusb, sisusb_vaddr(sisusb, c, x, y), | |
| 386 | sisusb_copy_memory(sisusb, (char *)SISUSB_VADDR(x, y), | 382 | sisusb_haddr(sisusb, c, x, y), 2); |
| 387 | (long)SISUSB_HADDR(x, y), 2); | ||
| 388 | 383 | ||
| 389 | mutex_unlock(&sisusb->lock); | 384 | mutex_unlock(&sisusb->lock); |
| 390 | } | 385 | } |
| @@ -395,8 +390,6 @@ sisusbcon_putcs(struct vc_data *c, const unsigned short *s, · 4 unmodified lines | |||
| 395 | int count, int y, int x) | 390 | int count, int y, int x) |
| 396 | { | 391 | { |
| 397 | struct sisusb_usb_data *sisusb; | 392 | struct sisusb_usb_data *sisusb; |
| 398 | u16 *dest; | ||
| 399 | int i; | ||
| 400 | 393 | ||
| 401 | sisusb = sisusb_get_sisusb_lock_and_check(c->vc_num); | 394 | sisusb = sisusb_get_sisusb_lock_and_check(c->vc_num); |
| 402 | if (!sisusb) | 395 | if (!sisusb) |
| @@ -408,18 +401,15 @@ sisusbcon_putcs(struct vc_data *c, const unsigned short *s, · 5 unmodified lines | |||
| 408 | * because the vt does this AFTER calling us. | 401 | * because the vt does this AFTER calling us. |
| 409 | */ | 402 | */ |
| 410 | 403 | ||
| 411 | dest = SISUSB_VADDR(x, y); | 404 | memcpy(sisusb_vaddr(sisusb, c, x, y), s, count * 2); |
| 412 | |||
| 413 | for (i = count; i > 0; i--) | ||
| 414 | sisusbcon_writew(sisusbcon_readw(s++), dest++); | ||
| 415 | 405 | ||
| 416 | if (sisusb_is_inactive(c, sisusb)) { | 406 | if (sisusb_is_inactive(c, sisusb)) { |
| 417 | mutex_unlock(&sisusb->lock); | 407 | mutex_unlock(&sisusb->lock); |
| 418 | return; | 408 | return; |
| 419 | } | 409 | } |
| 420 | 410 | ||
| 421 | sisusb_copy_memory(sisusb, (char *)SISUSB_VADDR(x, y), | 411 | sisusb_copy_memory(sisusb, sisusb_vaddr(sisusb, c, x, y), |
| 422 | (long)SISUSB_HADDR(x, y), count * 2); | 412 | sisusb_haddr(sisusb, c, x, y), count * 2); |
| 423 | 413 | ||
| 424 | mutex_unlock(&sisusb->lock); | 414 | mutex_unlock(&sisusb->lock); |
| 425 | } | 415 | } |
| @@ -446,7 +436,7 @@ sisusbcon_clear(struct vc_data *c, int y, int x, int height, int width) · 20 unmodified lines | |||
| 446 | * this AFTER calling us. | 436 | * this AFTER calling us. |
| 447 | */ | 437 | */ |
| 448 | 438 | ||
| 449 | dest = SISUSB_VADDR(x, y); | 439 | dest = sisusb_vaddr(sisusb, c, x, y); |
| 450 | 440 | ||
| 451 | cols = sisusb->sisusb_num_columns; | 441 | cols = sisusb->sisusb_num_columns; |
| 452 | 442 | ||
| @@ -472,8 +462,8 @@ sisusbcon_clear(struct vc_data *c, int y, int x, int height, int width) · 19 unmodified lines | |||
| 472 | length = ((height * cols) - x - (cols - width - x)) * 2; | 462 | length = ((height * cols) - x - (cols - width - x)) * 2; |
| 473 | 463 | ||
| 474 | 464 | ||
| 475 | sisusb_copy_memory(sisusb, (unsigned char *)SISUSB_VADDR(x, y), | 465 | sisusb_copy_memory(sisusb, sisusb_vaddr(sisusb, c, x, y), |
| 476 | (long)SISUSB_HADDR(x, y), length); | 466 | sisusb_haddr(sisusb, c, x, y), length); |
| 477 | 467 | ||
| 478 | mutex_unlock(&sisusb->lock); | 468 | mutex_unlock(&sisusb->lock); |
| 479 | } | 469 | } |
| @@ -517,12 +507,10 @@ sisusbcon_switch(struct vc_data *c) · 37 unmodified lines | |||
| 517 | (int)(sisusb->scrbuf + sisusb->scrbuf_size - c->vc_origin)); | 507 | (int)(sisusb->scrbuf + sisusb->scrbuf_size - c->vc_origin)); |
| 518 | 508 | ||
| 519 | /* Restore the screen contents */ | 509 | /* Restore the screen contents */ |
| 520 | sisusbcon_memcpyw((u16 *)c->vc_origin, (u16 *)c->vc_screenbuf, | 510 | memcpy((u16 *)c->vc_origin, (u16 *)c->vc_screenbuf, length); |
| 521 | length); | ||
| 522 | 511 | ||
| 523 | sisusb_copy_memory(sisusb, (unsigned char *)c->vc_origin, | 512 | sisusb_copy_memory(sisusb, (char *)c->vc_origin, |
| 524 | (long)SISUSB_HADDR(0, 0), | 513 | sisusb_haddr(sisusb, c, 0, 0), length); |
| 525 | length); | ||
| 526 | 514 | ||
| 527 | mutex_unlock(&sisusb->lock); | 515 | mutex_unlock(&sisusb->lock); |
| 528 | 516 | ||
| @@ -556,8 +544,7 @@ sisusbcon_save_screen(struct vc_data *c) · 27 unmodified lines | |||
| 556 | (int)(sisusb->scrbuf + sisusb->scrbuf_size - c->vc_origin)); | 544 | (int)(sisusb->scrbuf + sisusb->scrbuf_size - c->vc_origin)); |
| 557 | 545 | ||
| 558 | /* Save the screen contents to vc's private buffer */ | 546 | /* Save the screen contents to vc's private buffer */ |
| 559 | sisusbcon_memcpyw((u16 *)c->vc_screenbuf, (u16 *)c->vc_origin, | 547 | memcpy((u16 *)c->vc_screenbuf, (u16 *)c->vc_origin, length); |
| 560 | length); | ||
| 561 | 548 | ||
| 562 | mutex_unlock(&sisusb->lock); | 549 | mutex_unlock(&sisusb->lock); |
| 563 | } | 550 | } |
| @@ -628,10 +615,8 @@ sisusbcon_blank(struct vc_data *c, int blank, int mode_switch) · 64 unmodified lines | |||
| 628 | sisusbcon_memsetw((u16 *)c->vc_origin, | 615 | sisusbcon_memsetw((u16 *)c->vc_origin, |
| 629 | c->vc_video_erase_char, | 616 | c->vc_video_erase_char, |
| 630 | c->vc_screenbuf_size); | 617 | c->vc_screenbuf_size); |
| 631 | sisusb_copy_memory(sisusb, | 618 | sisusb_copy_memory(sisusb, (char *)c->vc_origin, |
| 632 | (unsigned char *)c->vc_origin, | 619 | sisusb_haddr(sisusb, c, 0, 0), |
| 633 | (u32)(sisusb->vrambase + | ||
| 634 | (c->vc_origin - sisusb->scrbuf)), | ||
| 635 | c->vc_screenbuf_size); | 620 | c->vc_screenbuf_size); |
| 636 | sisusb->con_blanked = 1; | 621 | sisusb->con_blanked = 1; |
| 637 | ret = 1; | 622 | ret = 1; |
| @@ -796,24 +781,24 @@ sisusbcon_scroll_area(struct vc_data *c, struct sisusb_usb_data *sisusb, · 158 unmodified lines | |||
| 796 | switch (dir) { | 781 | switch (dir) { |
| 797 | 782 | ||
| 798 | case SM_UP: | 783 | case SM_UP: |
| 799 | sisusbcon_memmovew(SISUSB_VADDR(0, t), | 784 | memmove(sisusb_vaddr(sisusb, c, 0, t), |
| 800 | SISUSB_VADDR(0, t + lines), | 785 | sisusb_vaddr(sisusb, c, 0, t + lines), |
| 801 | (b - t - lines) * cols * 2); | 786 | (b - t - lines) * cols * 2); |
| 802 | sisusbcon_memsetw(SISUSB_VADDR(0, b - lines), eattr, | 787 | sisusbcon_memsetw(sisusb_vaddr(sisusb, c, 0, b - lines), |
| 803 | lines * cols * 2); | 788 | eattr, lines * cols * 2); |
| 804 | break; | 789 | break; |
| 805 | 790 | ||
| 806 | case SM_DOWN: | 791 | case SM_DOWN: |
| 807 | sisusbcon_memmovew(SISUSB_VADDR(0, t + lines), | 792 | memmove(sisusb_vaddr(sisusb, c, 0, t + lines), |
| 808 | SISUSB_VADDR(0, t), | 793 | sisusb_vaddr(sisusb, c, 0, t), |
| 809 | (b - t - lines) * cols * 2); | 794 | (b - t - lines) * cols * 2); |
| 810 | sisusbcon_memsetw(SISUSB_VADDR(0, t), eattr, | 795 | sisusbcon_memsetw(sisusb_vaddr(sisusb, c, 0, t), eattr, |
| 811 | lines * cols * 2); | 796 | lines * cols * 2); |
| 812 | break; | 797 | break; |
| 813 | } | 798 | } |
| 814 | 799 | ||
| 815 | sisusb_copy_memory(sisusb, (char *)SISUSB_VADDR(0, t), | 800 | sisusb_copy_memory(sisusb, sisusb_vaddr(sisusb, c, 0, t), |
| 816 | (long)SISUSB_HADDR(0, t), length); | 801 | sisusb_haddr(sisusb, c, 0, t), length); |
| 817 | 802 | ||
| 818 | mutex_unlock(&sisusb->lock); | 803 | mutex_unlock(&sisusb->lock); |
| 819 | 804 | ||
| @@ -830,7 +815,6 @@ sisusbcon_scroll(struct vc_data *c, unsigned int t, unsigned int b, · 10 unmodified lines | |||
| 830 | int copyall = 0; | 815 | int copyall = 0; |
| 831 | unsigned long oldorigin; | 816 | unsigned long oldorigin; |
| 832 | unsigned int delta = lines * c->vc_size_row; | 817 | unsigned int delta = lines * c->vc_size_row; |
| 833 | u32 originoffset; | ||
| 834 | 818 | ||
| 835 | /* Returning != 0 means we have done the scrolling successfully. | 819 | /* Returning != 0 means we have done the scrolling successfully. |
| 836 | * Returning 0 makes vt do the scrolling on its own. | 820 | * Returning 0 makes vt do the scrolling on its own. |
| @@ -874,7 +858,7 @@ sisusbcon_scroll(struct vc_data *c, unsigned int t, unsigned int b, · 37 unmodified lines | |||
| 874 | 858 | ||
| 875 | if (c->vc_scr_end + delta >= | 859 | if (c->vc_scr_end + delta >= |
| 876 | sisusb->scrbuf + sisusb->scrbuf_size) { | 860 | sisusb->scrbuf + sisusb->scrbuf_size) { |
| 877 | sisusbcon_memcpyw((u16 *)sisusb->scrbuf, | 861 | memcpy((u16 *)sisusb->scrbuf, |
| 878 | (u16 *)(oldorigin + delta), | 862 | (u16 *)(oldorigin + delta), |
| 879 | c->vc_screenbuf_size - delta); | 863 | c->vc_screenbuf_size - delta); |
| 880 | c->vc_origin = sisusb->scrbuf; | 864 | c->vc_origin = sisusb->scrbuf; |
| @@ -892,12 +876,10 @@ sisusbcon_scroll(struct vc_data *c, unsigned int t, unsigned int b, · 11 unmodified lines | |||
| 892 | case SM_DOWN: | 876 | case SM_DOWN: |
| 893 | 877 | ||
| 894 | if (oldorigin - delta < sisusb->scrbuf) { | 878 | if (oldorigin - delta < sisusb->scrbuf) { |
| 895 | sisusbcon_memmovew((u16 *)(sisusb->scrbuf + | 879 | memmove((void *)sisusb->scrbuf + sisusb->scrbuf_size - |
| 896 | sisusb->scrbuf_size - | 880 | c->vc_screenbuf_size + delta, |
| 897 | c->vc_screenbuf_size + | 881 | (u16 *)oldorigin, |
| 898 | delta), | 882 | c->vc_screenbuf_size - delta); |
| 899 | (u16 *)oldorigin, | ||
| 900 | c->vc_screenbuf_size - delta); | ||
| 901 | c->vc_origin = sisusb->scrbuf + | 883 | c->vc_origin = sisusb->scrbuf + |
| 902 | sisusb->scrbuf_size - | 884 | sisusb->scrbuf_size - |
| 903 | c->vc_screenbuf_size; | 885 | c->vc_screenbuf_size; |
| @@ -913,23 +895,21 @@ sisusbcon_scroll(struct vc_data *c, unsigned int t, unsigned int b, · 9 unmodified lines | |||
| 913 | break; | 895 | break; |
| 914 | } | 896 | } |
| 915 | 897 | ||
| 916 | originoffset = (u32)(c->vc_origin - sisusb->scrbuf); | ||
| 917 | |||
| 918 | if (copyall) | 898 | if (copyall) |
| 919 | sisusb_copy_memory(sisusb, | 899 | sisusb_copy_memory(sisusb, |
| 920 | (char *)c->vc_origin, | 900 | (char *)c->vc_origin, |
| 921 | (u32)(sisusb->vrambase + originoffset), | 901 | sisusb_haddr(sisusb, c, 0, 0), |
| 922 | c->vc_screenbuf_size); | 902 | c->vc_screenbuf_size); |
| 923 | else if (dir == SM_UP) | 903 | else if (dir == SM_UP) |
| 924 | sisusb_copy_memory(sisusb, | 904 | sisusb_copy_memory(sisusb, |
| 925 | (char *)c->vc_origin + c->vc_screenbuf_size - delta, | 905 | (char *)c->vc_origin + c->vc_screenbuf_size - delta, |
| 926 | (u32)sisusb->vrambase + originoffset + | 906 | sisusb_haddr(sisusb, c, 0, 0) + |
| 927 | c->vc_screenbuf_size - delta, | 907 | c->vc_screenbuf_size - delta, |
| 928 | delta); | 908 | delta); |
| 929 | else | 909 | else |
| 930 | sisusb_copy_memory(sisusb, | 910 | sisusb_copy_memory(sisusb, |
| 931 | (char *)c->vc_origin, | 911 | (char *)c->vc_origin, |
| 932 | (u32)(sisusb->vrambase + originoffset), | 912 | sisusb_haddr(sisusb, c, 0, 0), |
| 933 | delta); | 913 | delta); |
| 934 | 914 | ||
| 935 | c->vc_scr_end = c->vc_origin + c->vc_screenbuf_size; | 915 | c->vc_scr_end = c->vc_origin + c->vc_screenbuf_size; |
| @@ -1534,8 +1514,3 @@ void __init sisusb_init_concode(void) · 598 unmodified lines | |||
| 1534 | for (i = 0; i < MAX_NR_CONSOLES; i++) | 1514 | for (i = 0; i < MAX_NR_CONSOLES; i++) |
| 1535 | mysisusbs[i] = NULL; | 1515 | mysisusbs[i] = NULL; |
| 1536 | } | 1516 | } |
| 1537 | |||
| 1538 | #endif /* INCL_CON */ | ||
| 1539 | |||
| 1540 | |||
| 1541 | |||
| @@ -44,9 +44,6 @@ · 43 unmodified lines | |||
| 44 | #include <linux/spinlock.h> | 44 | #include <linux/spinlock.h> |
| 45 | 45 | ||
| 46 | #include "sisusb.h" | 46 | #include "sisusb.h" |
| 47 | |||
| 48 | #ifdef INCL_SISUSB_CON | ||
| 49 | |||
| 50 | #include "sisusb_init.h" | 47 | #include "sisusb_init.h" |
| 51 | 48 | ||
| 52 | /*********************************************/ | 49 | /*********************************************/ |
| @@ -955,5 +952,3 @@ int SiSUSBSetVESAMode(struct SiS_Private *SiS_Pr, unsigned short VModeNo) · 902 unmodified lines | |||
| 955 | 952 | ||
| 956 | return SiSUSBSetMode(SiS_Pr, ModeNo); | 953 | return SiSUSBSetMode(SiS_Pr, ModeNo); |
| 957 | } | 954 | } |
| 958 | |||
| 959 | #endif /* INCL_SISUSB_CON */ | ||
| @@ -337,10 +337,12 @@ static int usb251xb_get_ofdata(struct usb251xb *hub, · 336 unmodified lines | |||
| 337 | struct device *dev = hub->dev; | 337 | struct device *dev = hub->dev; |
| 338 | struct device_node *np = dev->of_node; | 338 | struct device_node *np = dev->of_node; |
| 339 | int len, err, i; | 339 | int len, err, i; |
| 340 | u32 property_u32 = 0; | 340 | u32 port, property_u32 = 0; |
| 341 | const u32 *cproperty_u32; | 341 | const u32 *cproperty_u32; |
| 342 | const char *cproperty_char; | 342 | const char *cproperty_char; |
| 343 | char str[USB251XB_STRING_BUFSIZE / 2]; | 343 | char str[USB251XB_STRING_BUFSIZE / 2]; |
| 344 | struct property *prop; | ||
| 345 | const __be32 *p; | ||
| 344 | 346 | ||
| 345 | if (!np) { | 347 | if (!np) { |
| 346 | dev_err(dev, "failed to get ofdata\n"); | 348 | dev_err(dev, "failed to get ofdata\n"); |
| @@ -539,6 +541,16 @@ static int usb251xb_get_ofdata(struct usb251xb *hub, · 192 unmodified lines | |||
| 539 | (wchar_t *)hub->serial, | 541 | (wchar_t *)hub->serial, |
| 540 | USB251XB_STRING_BUFSIZE); | 542 | USB251XB_STRING_BUFSIZE); |
| 541 | 543 | ||
| 544 | /* | ||
| 545 | * The datasheet documents the register as 'Port Swap' but in real the | ||
| 546 | * register controls the USB DP/DM signal swapping for each port. | ||
| 547 | */ | ||
| 548 | hub->port_swap = USB251XB_DEF_PORT_SWAP; | ||
| 549 | of_property_for_each_u32(np, "swap-dx-lanes", prop, p, port) { | ||
| 550 | if ((port >= 0) && (port <= data->port_cnt)) | ||
| 551 | hub->port_swap |= BIT(port); | ||
| 552 | } | ||
| 553 | |||
| 542 | /* The following parameters are currently not exposed to devicetree, but | 554 | /* The following parameters are currently not exposed to devicetree, but |
| 543 | * may be as soon as needed. | 555 | * may be as soon as needed. |
| 544 | */ | 556 | */ |
| @@ -546,7 +558,6 @@ static int usb251xb_get_ofdata(struct usb251xb *hub, · 1 unmodified line | |||
| 546 | hub->boost_up = USB251XB_DEF_BOOST_UP; | 558 | hub->boost_up = USB251XB_DEF_BOOST_UP; |
| 547 | hub->boost_57 = USB251XB_DEF_BOOST_57; | 559 | hub->boost_57 = USB251XB_DEF_BOOST_57; |
| 548 | hub->boost_14 = USB251XB_DEF_BOOST_14; | 560 | hub->boost_14 = USB251XB_DEF_BOOST_14; |
| 549 | hub->port_swap = USB251XB_DEF_PORT_SWAP; | ||
| 550 | hub->port_map12 = USB251XB_DEF_PORT_MAP_12; | 561 | hub->port_map12 = USB251XB_DEF_PORT_MAP_12; |
| 551 | hub->port_map34 = USB251XB_DEF_PORT_MAP_34; | 562 | hub->port_map34 = USB251XB_DEF_PORT_MAP_34; |
| 552 | hub->port_map56 = USB251XB_DEF_PORT_MAP_56; | 563 | hub->port_map56 = USB251XB_DEF_PORT_MAP_56; |
| @@ -355,11 +355,8 @@ static int usb3503_platform_remove(struct platform_device *pdev) · 354 unmodified lines | |||
| 355 | } | 355 | } |
| 356 | 356 | ||
| 357 | #ifdef CONFIG_PM_SLEEP | 357 | #ifdef CONFIG_PM_SLEEP |
| 358 | static int usb3503_i2c_suspend(struct device *dev) | 358 | static int usb3503_suspend(struct usb3503 *hub) |
| 359 | { | 359 | { |
| 360 | struct i2c_client *client = to_i2c_client(dev); | ||
| 361 | struct usb3503 *hub = i2c_get_clientdata(client); | ||
| 362 | |||
| 363 | usb3503_switch_mode(hub, USB3503_MODE_STANDBY); | 360 | usb3503_switch_mode(hub, USB3503_MODE_STANDBY); |
| 364 | 361 | ||
| 365 | if (hub->clk) | 362 | if (hub->clk) |
| @@ -368,11 +365,8 @@ static int usb3503_i2c_suspend(struct device *dev) · 2 unmodified lines | |||
| 368 | return 0; | 365 | return 0; |
| 369 | } | 366 | } |
| 370 | 367 | ||
| 371 | static int usb3503_i2c_resume(struct device *dev) | 368 | static int usb3503_resume(struct usb3503 *hub) |
| 372 | { | 369 | { |
| 373 | struct i2c_client *client = to_i2c_client(dev); | ||
| 374 | struct usb3503 *hub = i2c_get_clientdata(client); | ||
| 375 | |||
| 376 | if (hub->clk) | 370 | if (hub->clk) |
| 377 | clk_prepare_enable(hub->clk); | 371 | clk_prepare_enable(hub->clk); |
| 378 | 372 | ||
| @@ -380,11 +374,38 @@ static int usb3503_i2c_resume(struct device *dev) · 1 unmodified line | |||
| 380 | 374 | ||
| 381 | return 0; | 375 | return 0; |
| 382 | } | 376 | } |
| 377 | |||
| 378 | static int usb3503_i2c_suspend(struct device *dev) | ||
| 379 | { | ||
| 380 | struct i2c_client *client = to_i2c_client(dev); | ||
| 381 | |||
| 382 | return usb3503_suspend(i2c_get_clientdata(client)); | ||
| 383 | } | ||
| 384 | |||
| 385 | static int usb3503_i2c_resume(struct device *dev) | ||
| 386 | { | ||
| 387 | struct i2c_client *client = to_i2c_client(dev); | ||
| 388 | |||
| 389 | return usb3503_resume(i2c_get_clientdata(client)); | ||
| 390 | } | ||
| 391 | |||
| 392 | static int usb3503_platform_suspend(struct device *dev) | ||
| 393 | { | ||
| 394 | return usb3503_suspend(dev_get_drvdata(dev)); | ||
| 395 | } | ||
| 396 | |||
| 397 | static int usb3503_platform_resume(struct device *dev) | ||
| 398 | { | ||
| 399 | return usb3503_resume(dev_get_drvdata(dev)); | ||
| 400 | } | ||
| 383 | #endif | 401 | #endif |
| 384 | 402 | ||
| 385 | static SIMPLE_DEV_PM_OPS(usb3503_i2c_pm_ops, usb3503_i2c_suspend, | 403 | static SIMPLE_DEV_PM_OPS(usb3503_i2c_pm_ops, usb3503_i2c_suspend, |
| 386 | usb3503_i2c_resume); | 404 | usb3503_i2c_resume); |
| 387 | 405 | ||
| 406 | static SIMPLE_DEV_PM_OPS(usb3503_platform_pm_ops, usb3503_platform_suspend, | ||
| 407 | usb3503_platform_resume); | ||
| 408 | |||
| 388 | static const struct i2c_device_id usb3503_id[] = { | 409 | static const struct i2c_device_id usb3503_id[] = { |
| 389 | { USB3503_I2C_NAME, 0 }, | 410 | { USB3503_I2C_NAME, 0 }, |
| 390 | { } | 411 | { } |
| @@ -415,6 +436,7 @@ static struct platform_driver usb3503_platform_driver = { · 24 unmodified lines | |||
| 415 | .driver = { | 436 | .driver = { |
| 416 | .name = USB3503_I2C_NAME, | 437 | .name = USB3503_I2C_NAME, |
| 417 | .of_match_table = of_match_ptr(usb3503_of_match), | 438 | .of_match_table = of_match_ptr(usb3503_of_match), |
| 439 | .pm = &usb3503_platform_pm_ops, | ||
| 418 | }, | 440 | }, |
| 419 | .probe = usb3503_platform_probe, | 441 | .probe = usb3503_platform_probe, |
| 420 | .remove = usb3503_platform_remove, | 442 | .remove = usb3503_platform_remove, |
| @@ -347,6 +347,14 @@ static unsigned get_maxpacket(struct usb_device *udev, int pipe) · 346 unmodified lines | |||
| 347 | return le16_to_cpup(&ep->desc.wMaxPacketSize); | 347 | return le16_to_cpup(&ep->desc.wMaxPacketSize); |
| 348 | } | 348 | } |
| 349 | 349 | ||
| 350 | static int ss_isoc_get_packet_num(struct usb_device *udev, int pipe) | ||
| 351 | { | ||
| 352 | struct usb_host_endpoint *ep = usb_pipe_endpoint(udev, pipe); | ||
| 353 | |||
| 354 | return USB_SS_MULT(ep->ss_ep_comp.bmAttributes) | ||
| 355 | * (1 + ep->ss_ep_comp.bMaxBurst); | ||
| 356 | } | ||
| 357 | |||
| 350 | static void simple_fill_buf(struct urb *urb) | 358 | static void simple_fill_buf(struct urb *urb) |
| 351 | { | 359 | { |
| 352 | unsigned i; | 360 | unsigned i; |
| @@ -1976,8 +1984,13 @@ static struct urb *iso_alloc_urb( · 1623 unmodified lines | |||
| 1976 | 1984 | ||
| 1977 | if (bytes < 0 || !desc) | 1985 | if (bytes < 0 || !desc) |
| 1978 | return NULL; | 1986 | return NULL; |
| 1987 | |||
| 1979 | maxp = usb_endpoint_maxp(desc); | 1988 | maxp = usb_endpoint_maxp(desc); |
| 1980 | maxp *= usb_endpoint_maxp_mult(desc); | 1989 | if (udev->speed >= USB_SPEED_SUPER) |
| 1990 | maxp *= ss_isoc_get_packet_num(udev, pipe); | ||
| 1991 | else | ||
| 1992 | maxp *= usb_endpoint_maxp_mult(desc); | ||
| 1993 | |||
| 1981 | packets = DIV_ROUND_UP(bytes, maxp); | 1994 | packets = DIV_ROUND_UP(bytes, maxp); |
| 1982 | 1995 | ||
| 1983 | urb = usb_alloc_urb(packets, GFP_KERNEL); | 1996 | urb = usb_alloc_urb(packets, GFP_KERNEL); |
| @@ -2065,17 +2078,24 @@ test_queue(struct usbtest_dev *dev, struct usbtest_param_32 *param, · 81 unmodified lines | |||
| 2065 | packets *= param->iterations; | 2078 | packets *= param->iterations; |
| 2066 | 2079 | ||
| 2067 | if (context.is_iso) { | 2080 | if (context.is_iso) { |
| 2081 | int transaction_num; | ||
| 2082 | |||
| 2083 | if (udev->speed >= USB_SPEED_SUPER) | ||
| 2084 | transaction_num = ss_isoc_get_packet_num(udev, pipe); | ||
| 2085 | else | ||
| 2086 | transaction_num = usb_endpoint_maxp_mult(desc); | ||
| 2087 | |||
| 2068 | dev_info(&dev->intf->dev, | 2088 | dev_info(&dev->intf->dev, |
| 2069 | "iso period %d %sframes, wMaxPacket %d, transactions: %d\n", | 2089 | "iso period %d %sframes, wMaxPacket %d, transactions: %d\n", |
| 2070 | 1 << (desc->bInterval - 1), | 2090 | 1 << (desc->bInterval - 1), |
| 2071 | (udev->speed == USB_SPEED_HIGH) ? "micro" : "", | 2091 | (udev->speed >= USB_SPEED_HIGH) ? "micro" : "", |
| 2072 | usb_endpoint_maxp(desc), | 2092 | usb_endpoint_maxp(desc), |
| 2073 | usb_endpoint_maxp_mult(desc)); | 2093 | transaction_num); |
| 2074 | 2094 | ||
| 2075 | dev_info(&dev->intf->dev, | 2095 | dev_info(&dev->intf->dev, |
| 2076 | "total %lu msec (%lu packets)\n", | 2096 | "total %lu msec (%lu packets)\n", |
| 2077 | (packets * (1 << (desc->bInterval - 1))) | 2097 | (packets * (1 << (desc->bInterval - 1))) |
| 2078 | / ((udev->speed == USB_SPEED_HIGH) ? 8 : 1), | 2098 | / ((udev->speed >= USB_SPEED_HIGH) ? 8 : 1), |
| 2079 | packets); | 2099 | packets); |
| 2080 | } | 2100 | } |
| 2081 | 2101 | ||
| @@ -1,3 +1,4 @@ | |||
| 1 | # SPDX-License-Identifier: GPL-2.0 | ||
| 1 | # | 2 | # |
| 2 | # USB Monitor configuration | 3 | # USB Monitor configuration |
| 3 | # | 4 | # |
| @@ -1,3 +1,5 @@ | |||
| 1 | # SPDX-License-Identifier: GPL-2.0 | ||
| 2 | # | ||
| 1 | # For MTK USB3.0 IP | 3 | # For MTK USB3.0 IP |
| 2 | 4 | ||
| 3 | config USB_MTU3 | 5 | config USB_MTU3 |
| @@ -1,3 +1,4 @@ | |||
| 1 | # SPDX-License-Identifier: GPL-2.0 | ||
| 1 | # | 2 | # |
| 2 | # USB Dual Role (OTG-ready) Controller Drivers | 3 | # USB Dual Role (OTG-ready) Controller Drivers |
| 3 | # for silicon based on Mentor Graphics INVENTRA designs | 4 | # for silicon based on Mentor Graphics INVENTRA designs |
| @@ -111,9 +112,9 @@ config USB_MUSB_UX500 · 107 unmodified lines | |||
| 111 | config USB_MUSB_JZ4740 | 112 | config USB_MUSB_JZ4740 |
| 112 | tristate "JZ4740" | 113 | tristate "JZ4740" |
| 113 | depends on NOP_USB_XCEIV | 114 | depends on NOP_USB_XCEIV |
| 114 | depends on MACH_JZ4740 || COMPILE_TEST | 115 | depends on MIPS || COMPILE_TEST |
| 115 | depends on USB_MUSB_GADGET | 116 | depends on USB_MUSB_GADGET |
| 116 | depends on USB_OTG_BLACKLIST_HUB | 117 | depends on USB=n || USB_OTG_BLACKLIST_HUB |
| 117 | 118 | ||
| 118 | config USB_MUSB_AM335X_CHILD | 119 | config USB_MUSB_AM335X_CHILD |
| 119 | tristate | 120 | tristate |
| @@ -10,6 +10,7 @@ · 9 unmodified lines | |||
| 10 | #include <linux/errno.h> | 10 | #include <linux/errno.h> |
| 11 | #include <linux/kernel.h> | 11 | #include <linux/kernel.h> |
| 12 | #include <linux/module.h> | 12 | #include <linux/module.h> |
| 13 | #include <linux/of_device.h> | ||
| 13 | #include <linux/platform_device.h> | 14 | #include <linux/platform_device.h> |
| 14 | #include <linux/usb/usb_phy_generic.h> | 15 | #include <linux/usb/usb_phy_generic.h> |
| 15 | 16 | ||
| @@ -188,11 +189,20 @@ static int jz4740_remove(struct platform_device *pdev) · 172 unmodified lines | |||
| 188 | return 0; | 189 | return 0; |
| 189 | } | 190 | } |
| 190 | 191 | ||
| 192 | #ifdef CONFIG_OF | ||
| 193 | static const struct of_device_id jz4740_musb_of_match[] = { | ||
| 194 | { .compatible = "ingenic,jz4740-musb" }, | ||
| 195 | {}, | ||
| 196 | }; | ||
| 197 | MODULE_DEVICE_TABLE(of, jz4740_musb_of_match); | ||
| 198 | #endif | ||
| 199 | |||
| 191 | static struct platform_driver jz4740_driver = { | 200 | static struct platform_driver jz4740_driver = { |
| 192 | .probe = jz4740_probe, | 201 | .probe = jz4740_probe, |
| 193 | .remove = jz4740_remove, | 202 | .remove = jz4740_remove, |
| 194 | .driver = { | 203 | .driver = { |
| 195 | .name = "musb-jz4740", | 204 | .name = "musb-jz4740", |
| 205 | .of_match_table = of_match_ptr(jz4740_musb_of_match), | ||
| 196 | }, | 206 | }, |
| 197 | }; | 207 | }; |
| 198 | 208 | ||
| @@ -378,7 +378,7 @@ static void musb_advance_schedule(struct musb *musb, struct urb *urb, · 377 unmodified lines | |||
| 378 | qh = first_qh(head); | 378 | qh = first_qh(head); |
| 379 | break; | 379 | break; |
| 380 | } | 380 | } |
| 381 | /* else: fall through */ | 381 | /* fall through */ |
| 382 | 382 | ||
| 383 | case USB_ENDPOINT_XFER_ISOC: | 383 | case USB_ENDPOINT_XFER_ISOC: |
| 384 | case USB_ENDPOINT_XFER_INT: | 384 | case USB_ENDPOINT_XFER_INT: |
| @@ -1283,7 +1283,7 @@ void musb_host_tx(struct musb *musb, u8 epnum) · 898 unmodified lines | |||
| 1283 | MUSB_TXCSR_H_WZC_BITS | 1283 | MUSB_TXCSR_H_WZC_BITS |
| 1284 | | MUSB_TXCSR_TXPKTRDY); | 1284 | | MUSB_TXCSR_TXPKTRDY); |
| 1285 | } | 1285 | } |
| 1286 | return; | 1286 | return; |
| 1287 | } | 1287 | } |
| 1288 | 1288 | ||
| 1289 | done: | 1289 | done: |
| @@ -1,3 +1,4 @@ | |||
| 1 | # SPDX-License-Identifier: GPL-2.0 | ||
| 1 | # | 2 | # |
| 2 | # Physical Layer USB driver configuration | 3 | # Physical Layer USB driver configuration |
| 3 | # | 4 | # |
| @@ -400,7 +400,7 @@ static int twl6030_usb_remove(struct platform_device *pdev) · 399 unmodified lines | |||
| 400 | { | 400 | { |
| 401 | struct twl6030_usb *twl = platform_get_drvdata(pdev); | 401 | struct twl6030_usb *twl = platform_get_drvdata(pdev); |
| 402 | 402 | ||
| 403 | cancel_delayed_work(&twl->get_status_work); | 403 | cancel_delayed_work_sync(&twl->get_status_work); |
| 404 | twl6030_interrupt_mask(TWL6030_USBOTG_INT_MASK, | 404 | twl6030_interrupt_mask(TWL6030_USBOTG_INT_MASK, |
| 405 | REG_INT_MSK_LINE_C); | 405 | REG_INT_MSK_LINE_C); |
| 406 | twl6030_interrupt_mask(TWL6030_USBOTG_INT_MASK, | 406 | twl6030_interrupt_mask(TWL6030_USBOTG_INT_MASK, |
| @@ -340,7 +340,7 @@ static void usbhsh_pipe_detach(struct usbhsh_hpriv *hpriv, · 339 unmodified lines | |||
| 340 | pipe = usbhsh_uep_to_pipe(uep); | 340 | pipe = usbhsh_uep_to_pipe(uep); |
| 341 | 341 | ||
| 342 | if (unlikely(!pipe)) { | 342 | if (unlikely(!pipe)) { |
| 343 | dev_err(dev, "uep doens't have pipe\n"); | 343 | dev_err(dev, "uep doesn't have pipe\n"); |
| 344 | } else if (1 == uep->counter--) { /* last user */ | 344 | } else if (1 == uep->counter--) { /* last user */ |
| 345 | struct usb_host_endpoint *ep = usbhsh_uep_to_ep(uep); | 345 | struct usb_host_endpoint *ep = usbhsh_uep_to_ep(uep); |
| 346 | struct usbhsh_device *udev = usbhsh_uep_to_udev(uep); | 346 | struct usbhsh_device *udev = usbhsh_uep_to_udev(uep); |
| @@ -59,7 +59,7 @@ static int usbhs_rcar3_power_ctrl(struct platform_device *pdev, · 58 unmodified lines | |||
| 59 | if (enable) { | 59 | if (enable) { |
| 60 | usbhs_bset(priv, LPSTS, LPSTS_SUSPM, LPSTS_SUSPM); | 60 | usbhs_bset(priv, LPSTS, LPSTS_SUSPM, LPSTS_SUSPM); |
| 61 | /* The controller on R-Car Gen3 needs to wait up to 45 usec */ | 61 | /* The controller on R-Car Gen3 needs to wait up to 45 usec */ |
| 62 | udelay(45); | 62 | usleep_range(45, 90); |
| 63 | } else { | 63 | } else { |
| 64 | usbhs_bset(priv, LPSTS, LPSTS_SUSPM, 0); | 64 | usbhs_bset(priv, LPSTS, LPSTS_SUSPM, 0); |
| 65 | } | 65 | } |
| @@ -35,7 +35,7 @@ static int usbhs_rza1_hardware_init(struct platform_device *pdev) · 34 unmodified lines | |||
| 35 | 35 | ||
| 36 | /* Enable USB PLL (NOTE: ch0 controls both ch0 and ch1) */ | 36 | /* Enable USB PLL (NOTE: ch0 controls both ch0 and ch1) */ |
| 37 | usbhs_bset(priv, SYSCFG, UPLLE, UPLLE); | 37 | usbhs_bset(priv, SYSCFG, UPLLE, UPLLE); |
| 38 | udelay(1000); | 38 | usleep_range(1000, 2000); |
| 39 | usbhs_bset(priv, SUSPMODE, SUSPM, SUSPM); | 39 | usbhs_bset(priv, SUSPMODE, SUSPM, SUSPM); |
| 40 | 40 | ||
| 41 | return 0; | 41 | return 0; |
| @@ -1,3 +1,5 @@ | |||
| 1 | # SPDX-License-Identifier: GPL-2.0 | ||
| 2 | |||
| 1 | config USB_ROLE_SWITCH | 3 | config USB_ROLE_SWITCH |
| 2 | tristate "USB Role Switch Support" | 4 | tristate "USB Role Switch Support" |
| 3 | help | 5 | help |
| @@ -1,3 +1,5 @@ | |||
| 1 | # SPDX-License-Identifier: GPL-2.0 | ||
| 2 | |||
| 1 | obj-$(CONFIG_USB_ROLE_SWITCH) += roles.o | 3 | obj-$(CONFIG_USB_ROLE_SWITCH) += roles.o |
| 2 | roles-y := class.o | 4 | roles-y := class.o |
| 3 | obj-$(CONFIG_USB_ROLES_INTEL_XHCI) += intel-xhci-usb-role-switch.o | 5 | obj-$(CONFIG_USB_ROLES_INTEL_XHCI) += intel-xhci-usb-role-switch.o |
| @@ -8,6 +8,7 @@ · 7 unmodified lines | |||
| 8 | */ | 8 | */ |
| 9 | 9 | ||
| 10 | #include <linux/usb/role.h> | 10 | #include <linux/usb/role.h> |
| 11 | #include <linux/property.h> | ||
| 11 | #include <linux/device.h> | 12 | #include <linux/device.h> |
| 12 | #include <linux/module.h> | 13 | #include <linux/module.h> |
| 13 | #include <linux/mutex.h> | 14 | #include <linux/mutex.h> |
| @@ -84,7 +85,12 @@ enum usb_role usb_role_switch_get_role(struct usb_role_switch *sw) · 70 unmodified lines | |||
| 84 | } | 85 | } |
| 85 | EXPORT_SYMBOL_GPL(usb_role_switch_get_role); | 86 | EXPORT_SYMBOL_GPL(usb_role_switch_get_role); |
| 86 | 87 | ||
| 87 | static int __switch_match(struct device *dev, const void *name) | 88 | static int switch_fwnode_match(struct device *dev, const void *fwnode) |
| 89 | { | ||
| 90 | return dev_fwnode(dev) == fwnode; | ||
| 91 | } | ||
| 92 | |||
| 93 | static int switch_name_match(struct device *dev, const void *name) | ||
| 88 | { | 94 | { |
| 89 | return !strcmp((const char *)name, dev_name(dev)); | 95 | return !strcmp((const char *)name, dev_name(dev)); |
| 90 | } | 96 | } |
| @@ -94,8 +100,16 @@ static void *usb_role_switch_match(struct device_connection *con, int ep, · 3 unmodified lines | |||
| 94 | { | 100 | { |
| 95 | struct device *dev; | 101 | struct device *dev; |
| 96 | 102 | ||
| 97 | dev = class_find_device(role_class, NULL, con->endpoint[ep], | 103 | if (con->fwnode) { |
| 98 | __switch_match); | 104 | if (!fwnode_property_present(con->fwnode, con->id)) |
| 105 | return NULL; | ||
| 106 | |||
| 107 | dev = class_find_device(role_class, NULL, con->fwnode, | ||
| 108 | switch_fwnode_match); | ||
| 109 | } else { | ||
| 110 | dev = class_find_device(role_class, NULL, con->endpoint[ep], | ||
| 111 | switch_name_match); | ||
| 112 | } | ||
| 99 | 113 | ||
| 100 | return dev ? to_role_switch(dev) : ERR_PTR(-EPROBE_DEFER); | 114 | return dev ? to_role_switch(dev) : ERR_PTR(-EPROBE_DEFER); |
| 101 | } | 115 | } |
| @@ -266,6 +280,7 @@ usb_role_switch_register(struct device *parent, · 164 unmodified lines | |||
| 266 | sw->get = desc->get; | 280 | sw->get = desc->get; |
| 267 | 281 | ||
| 268 | sw->dev.parent = parent; | 282 | sw->dev.parent = parent; |
| 283 | sw->dev.fwnode = desc->fwnode; | ||
| 269 | sw->dev.class = role_class; | 284 | sw->dev.class = role_class; |
| 270 | sw->dev.type = &usb_role_dev_type; | 285 | sw->dev.type = &usb_role_dev_type; |
| 271 | dev_set_name(&sw->dev, "%s-role-switch", dev_name(parent)); | 286 | dev_set_name(&sw->dev, "%s-role-switch", dev_name(parent)); |
| @@ -1,3 +1,4 @@ | |||
| 1 | # SPDX-License-Identifier: GPL-2.0 | ||
| 1 | # | 2 | # |
| 2 | # USB Serial device configuration | 3 | # USB Serial device configuration |
| 3 | # | 4 | # |
| @@ -61,6 +61,7 @@ static const struct usb_device_id id_table[] = { · 60 unmodified lines | |||
| 61 | { USB_DEVICE(0x08e6, 0x5501) }, /* Gemalto Prox-PU/CU contactless smartcard reader */ | 61 | { USB_DEVICE(0x08e6, 0x5501) }, /* Gemalto Prox-PU/CU contactless smartcard reader */ |
| 62 | { USB_DEVICE(0x08FD, 0x000A) }, /* Digianswer A/S , ZigBee/802.15.4 MAC Device */ | 62 | { USB_DEVICE(0x08FD, 0x000A) }, /* Digianswer A/S , ZigBee/802.15.4 MAC Device */ |
| 63 | { USB_DEVICE(0x0908, 0x01FF) }, /* Siemens RUGGEDCOM USB Serial Console */ | 63 | { USB_DEVICE(0x0908, 0x01FF) }, /* Siemens RUGGEDCOM USB Serial Console */ |
| 64 | { USB_DEVICE(0x0B00, 0x3070) }, /* Ingenico 3070 */ | ||
| 64 | { USB_DEVICE(0x0BED, 0x1100) }, /* MEI (TM) Cashflow-SC Bill/Voucher Acceptor */ | 65 | { USB_DEVICE(0x0BED, 0x1100) }, /* MEI (TM) Cashflow-SC Bill/Voucher Acceptor */ |
| 65 | { USB_DEVICE(0x0BED, 0x1101) }, /* MEI series 2000 Combo Acceptor */ | 66 | { USB_DEVICE(0x0BED, 0x1101) }, /* MEI series 2000 Combo Acceptor */ |
| 66 | { USB_DEVICE(0x0FCF, 0x1003) }, /* Dynastream ANT development board */ | 67 | { USB_DEVICE(0x0FCF, 0x1003) }, /* Dynastream ANT development board */ |
| @@ -245,6 +246,7 @@ struct cp210x_serial_private { · 178 unmodified lines | |||
| 245 | u8 gpio_input; | 246 | u8 gpio_input; |
| 246 | #endif | 247 | #endif |
| 247 | u8 partnum; | 248 | u8 partnum; |
| 249 | speed_t min_speed; | ||
| 248 | speed_t max_speed; | 250 | speed_t max_speed; |
| 249 | bool use_actual_rate; | 251 | bool use_actual_rate; |
| 250 | }; | 252 | }; |
| @@ -443,10 +445,10 @@ struct cp210x_pin_mode { · 192 unmodified lines | |||
| 443 | #define CP210X_PIN_MODE_GPIO BIT(0) | 445 | #define CP210X_PIN_MODE_GPIO BIT(0) |
| 444 | 446 | ||
| 445 | /* | 447 | /* |
| 446 | * CP210X_VENDOR_SPECIFIC, CP210X_GET_PORTCONFIG call reads these 0xf bytes. | 448 | * CP210X_VENDOR_SPECIFIC, CP210X_GET_PORTCONFIG call reads these 0xf bytes |
| 447 | * Structure needs padding due to unused/unspecified bytes. | 449 | * on a CP2105 chip. Structure needs padding due to unused/unspecified bytes. |
| 448 | */ | 450 | */ |
| 449 | struct cp210x_config { | 451 | struct cp210x_dual_port_config { |
| 450 | __le16 gpio_mode; | 452 | __le16 gpio_mode; |
| 451 | u8 __pad0[2]; | 453 | u8 __pad0[2]; |
| 452 | __le16 reset_state; | 454 | __le16 reset_state; |
| @@ -457,6 +459,19 @@ struct cp210x_config { · 4 unmodified lines | |||
| 457 | u8 device_cfg; | 459 | u8 device_cfg; |
| 458 | } __packed; | 460 | } __packed; |
| 459 | 461 | ||
| 462 | /* | ||
| 463 | * CP210X_VENDOR_SPECIFIC, CP210X_GET_PORTCONFIG call reads these 0xd bytes | ||
| 464 | * on a CP2104 chip. Structure needs padding due to unused/unspecified bytes. | ||
| 465 | */ | ||
| 466 | struct cp210x_single_port_config { | ||
| 467 | __le16 gpio_mode; | ||
| 468 | u8 __pad0[2]; | ||
| 469 | __le16 reset_state; | ||
| 470 | u8 __pad1[4]; | ||
| 471 | __le16 suspend_state; | ||
| 472 | u8 device_cfg; | ||
| 473 | } __packed; | ||
| 474 | |||
| 460 | /* GPIO modes */ | 475 | /* GPIO modes */ |
| 461 | #define CP210X_SCI_GPIO_MODE_OFFSET 9 | 476 | #define CP210X_SCI_GPIO_MODE_OFFSET 9 |
| 462 | #define CP210X_SCI_GPIO_MODE_MASK GENMASK(11, 9) | 477 | #define CP210X_SCI_GPIO_MODE_MASK GENMASK(11, 9) |
| @@ -464,11 +479,19 @@ struct cp210x_config { · 1 unmodified line | |||
| 464 | #define CP210X_ECI_GPIO_MODE_OFFSET 2 | 479 | #define CP210X_ECI_GPIO_MODE_OFFSET 2 |
| 465 | #define CP210X_ECI_GPIO_MODE_MASK GENMASK(3, 2) | 480 | #define CP210X_ECI_GPIO_MODE_MASK GENMASK(3, 2) |
| 466 | 481 | ||
| 482 | #define CP210X_GPIO_MODE_OFFSET 8 | ||
| 483 | #define CP210X_GPIO_MODE_MASK GENMASK(11, 8) | ||
| 484 | |||
| 467 | /* CP2105 port configuration values */ | 485 | /* CP2105 port configuration values */ |
| 468 | #define CP2105_GPIO0_TXLED_MODE BIT(0) | 486 | #define CP2105_GPIO0_TXLED_MODE BIT(0) |
| 469 | #define CP2105_GPIO1_RXLED_MODE BIT(1) | 487 | #define CP2105_GPIO1_RXLED_MODE BIT(1) |
| 470 | #define CP2105_GPIO1_RS485_MODE BIT(2) | 488 | #define CP2105_GPIO1_RS485_MODE BIT(2) |
| 471 | 489 | ||
| 490 | /* CP2104 port configuration values */ | ||
| 491 | #define CP2104_GPIO0_TXLED_MODE BIT(0) | ||
| 492 | #define CP2104_GPIO1_RXLED_MODE BIT(1) | ||
| 493 | #define CP2104_GPIO2_RS485_MODE BIT(2) | ||
| 494 | |||
| 472 | /* CP2102N configuration array indices */ | 495 | /* CP2102N configuration array indices */ |
| 473 | #define CP210X_2NCONFIG_CONFIG_VERSION_IDX 2 | 496 | #define CP210X_2NCONFIG_CONFIG_VERSION_IDX 2 |
| 474 | #define CP210X_2NCONFIG_GPIO_MODE_IDX 581 | 497 | #define CP210X_2NCONFIG_GPIO_MODE_IDX 581 |
| @@ -1051,14 +1074,11 @@ static speed_t cp210x_get_an205_rate(speed_t baud) · 576 unmodified lines | |||
| 1051 | return cp210x_an205_table1[i].rate; | 1074 | return cp210x_an205_table1[i].rate; |
| 1052 | } | 1075 | } |
| 1053 | 1076 | ||
| 1054 | static speed_t cp210x_get_actual_rate(struct usb_serial *serial, speed_t baud) | 1077 | static speed_t cp210x_get_actual_rate(speed_t baud) |
| 1055 | { | 1078 | { |
| 1056 | struct cp210x_serial_private *priv = usb_get_serial_data(serial); | ||
| 1057 | unsigned int prescale = 1; | 1079 | unsigned int prescale = 1; |
| 1058 | unsigned int div; | 1080 | unsigned int div; |
| 1059 | 1081 | ||
| 1060 | baud = clamp(baud, 300u, priv->max_speed); | ||
| 1061 | |||
| 1062 | if (baud <= 365) | 1082 | if (baud <= 365) |
| 1063 | prescale = 4; | 1083 | prescale = 4; |
| 1064 | 1084 | ||
| @@ -1101,20 +1121,18 @@ static void cp210x_change_speed(struct tty_struct *tty, · 36 unmodified lines | |||
| 1101 | struct cp210x_serial_private *priv = usb_get_serial_data(serial); | 1121 | struct cp210x_serial_private *priv = usb_get_serial_data(serial); |
| 1102 | u32 baud; | 1122 | u32 baud; |
| 1103 | 1123 | ||
| 1104 | baud = tty->termios.c_ospeed; | ||
| 1105 | |||
| 1106 | /* | 1124 | /* |
| 1107 | * This maps the requested rate to the actual rate, a valid rate on | 1125 | * This maps the requested rate to the actual rate, a valid rate on |
| 1108 | * cp2102 or cp2103, or to an arbitrary rate in [1M, max_speed]. | 1126 | * cp2102 or cp2103, or to an arbitrary rate in [1M, max_speed]. |
| 1109 | * | 1127 | * |
| 1110 | * NOTE: B0 is not implemented. | 1128 | * NOTE: B0 is not implemented. |
| 1111 | */ | 1129 | */ |
| 1130 | baud = clamp(tty->termios.c_ospeed, priv->min_speed, priv->max_speed); | ||
| 1131 | |||
| 1112 | if (priv->use_actual_rate) | 1132 | if (priv->use_actual_rate) |
| 1113 | baud = cp210x_get_actual_rate(serial, baud); | 1133 | baud = cp210x_get_actual_rate(baud); |
| 1114 | else if (baud < 1000000) | 1134 | else if (baud < 1000000) |
| 1115 | baud = cp210x_get_an205_rate(baud); | 1135 | baud = cp210x_get_an205_rate(baud); |
| 1116 | else if (baud > priv->max_speed) | ||
| 1117 | baud = priv->max_speed; | ||
| 1118 | 1136 | ||
| 1119 | dev_dbg(&port->dev, "%s - setting baud rate to %u\n", __func__, baud); | 1137 | dev_dbg(&port->dev, "%s - setting baud rate to %u\n", __func__, baud); |
| 1120 | if (cp210x_write_u32_reg(port, CP210X_SET_BAUDRATE, baud)) { | 1138 | if (cp210x_write_u32_reg(port, CP210X_SET_BAUDRATE, baud)) { |
| @@ -1353,8 +1371,13 @@ static int cp210x_gpio_get(struct gpio_chip *gc, unsigned int gpio) · 232 unmodified lines | |||
| 1353 | if (priv->partnum == CP210X_PARTNUM_CP2105) | 1371 | if (priv->partnum == CP210X_PARTNUM_CP2105) |
| 1354 | req_type = REQTYPE_INTERFACE_TO_HOST; | 1372 | req_type = REQTYPE_INTERFACE_TO_HOST; |
| 1355 | 1373 | ||
| 1374 | result = usb_autopm_get_interface(serial->interface); | ||
| 1375 | if (result) | ||
| 1376 | return result; | ||
| 1377 | |||
| 1356 | result = cp210x_read_vendor_block(serial, req_type, | 1378 | result = cp210x_read_vendor_block(serial, req_type, |
| 1357 | CP210X_READ_LATCH, &buf, sizeof(buf)); | 1379 | CP210X_READ_LATCH, &buf, sizeof(buf)); |
| 1380 | usb_autopm_put_interface(serial->interface); | ||
| 1358 | if (result < 0) | 1381 | if (result < 0) |
| 1359 | return result; | 1382 | return result; |
| 1360 | 1383 | ||
| @@ -1375,6 +1398,10 @@ static void cp210x_gpio_set(struct gpio_chip *gc, unsigned int gpio, int value) · 14 unmodified lines | |||
| 1375 | 1398 | ||
| 1376 | buf.mask = BIT(gpio); | 1399 | buf.mask = BIT(gpio); |
| 1377 | 1400 | ||
| 1401 | result = usb_autopm_get_interface(serial->interface); | ||
| 1402 | if (result) | ||
| 1403 | goto out; | ||
| 1404 | |||
| 1378 | if (priv->partnum == CP210X_PARTNUM_CP2105) { | 1405 | if (priv->partnum == CP210X_PARTNUM_CP2105) { |
| 1379 | result = cp210x_write_vendor_block(serial, | 1406 | result = cp210x_write_vendor_block(serial, |
| 1380 | REQTYPE_HOST_TO_INTERFACE, | 1407 | REQTYPE_HOST_TO_INTERFACE, |
| @@ -1392,6 +1419,8 @@ static void cp210x_gpio_set(struct gpio_chip *gc, unsigned int gpio, int value) · 11 unmodified lines | |||
| 1392 | NULL, 0, USB_CTRL_SET_TIMEOUT); | 1419 | NULL, 0, USB_CTRL_SET_TIMEOUT); |
| 1393 | } | 1420 | } |
| 1394 | 1421 | ||
| 1422 | usb_autopm_put_interface(serial->interface); | ||
| 1423 | out: | ||
| 1395 | if (result < 0) { | 1424 | if (result < 0) { |
| 1396 | dev_err(&serial->interface->dev, "failed to set GPIO value: %d\n", | 1425 | dev_err(&serial->interface->dev, "failed to set GPIO value: %d\n", |
| 1397 | result); | 1426 | result); |
| @@ -1470,7 +1499,7 @@ static int cp2105_gpioconf_init(struct usb_serial *serial) · 72 unmodified lines | |||
| 1470 | { | 1499 | { |
| 1471 | struct cp210x_serial_private *priv = usb_get_serial_data(serial); | 1500 | struct cp210x_serial_private *priv = usb_get_serial_data(serial); |
| 1472 | struct cp210x_pin_mode mode; | 1501 | struct cp210x_pin_mode mode; |
| 1473 | struct cp210x_config config; | 1502 | struct cp210x_dual_port_config config; |
| 1474 | u8 intf_num = cp210x_interface_num(serial); | 1503 | u8 intf_num = cp210x_interface_num(serial); |
| 1475 | u8 iface_config; | 1504 | u8 iface_config; |
| 1476 | int result; | 1505 | int result; |
| @@ -1529,6 +1558,56 @@ static int cp2105_gpioconf_init(struct usb_serial *serial) · 52 unmodified lines | |||
| 1529 | return 0; | 1558 | return 0; |
| 1530 | } | 1559 | } |
| 1531 | 1560 | ||
| 1561 | static int cp2104_gpioconf_init(struct usb_serial *serial) | ||
| 1562 | { | ||
| 1563 | struct cp210x_serial_private *priv = usb_get_serial_data(serial); | ||
| 1564 | struct cp210x_single_port_config config; | ||
| 1565 | u8 iface_config; | ||
| 1566 | u8 gpio_latch; | ||
| 1567 | int result; | ||
| 1568 | u8 i; | ||
| 1569 | |||
| 1570 | result = cp210x_read_vendor_block(serial, REQTYPE_DEVICE_TO_HOST, | ||
| 1571 | CP210X_GET_PORTCONFIG, &config, | ||
| 1572 | sizeof(config)); | ||
| 1573 | if (result < 0) | ||
| 1574 | return result; | ||
| 1575 | |||
| 1576 | priv->gc.ngpio = 4; | ||
| 1577 | |||
| 1578 | iface_config = config.device_cfg; | ||
| 1579 | priv->gpio_pushpull = (u8)((le16_to_cpu(config.gpio_mode) & | ||
| 1580 | CP210X_GPIO_MODE_MASK) >> | ||
| 1581 | CP210X_GPIO_MODE_OFFSET); | ||
| 1582 | gpio_latch = (u8)((le16_to_cpu(config.reset_state) & | ||
| 1583 | CP210X_GPIO_MODE_MASK) >> | ||
| 1584 | CP210X_GPIO_MODE_OFFSET); | ||
| 1585 | |||
| 1586 | /* mark all pins which are not in GPIO mode */ | ||
| 1587 | if (iface_config & CP2104_GPIO0_TXLED_MODE) /* GPIO 0 */ | ||
| 1588 | priv->gpio_altfunc |= BIT(0); | ||
| 1589 | if (iface_config & CP2104_GPIO1_RXLED_MODE) /* GPIO 1 */ | ||
| 1590 | priv->gpio_altfunc |= BIT(1); | ||
| 1591 | if (iface_config & CP2104_GPIO2_RS485_MODE) /* GPIO 2 */ | ||
| 1592 | priv->gpio_altfunc |= BIT(2); | ||
| 1593 | |||
| 1594 | /* | ||
| 1595 | * Like CP2102N, CP2104 has also no strict input and output pin | ||
| 1596 | * modes. | ||
| 1597 | * Do the same input mode emulation as CP2102N. | ||
| 1598 | */ | ||
| 1599 | for (i = 0; i < priv->gc.ngpio; ++i) { | ||
| 1600 | /* | ||
| 1601 | * Set direction to "input" iff pin is open-drain and reset | ||
| 1602 | * value is 1. | ||
| 1603 | */ | ||
| 1604 | if (!(priv->gpio_pushpull & BIT(i)) && (gpio_latch & BIT(i))) | ||
| 1605 | priv->gpio_input |= BIT(i); | ||
| 1606 | } | ||
| 1607 | |||
| 1608 | return 0; | ||
| 1609 | } | ||
| 1610 | |||
| 1532 | static int cp2102n_gpioconf_init(struct usb_serial *serial) | 1611 | static int cp2102n_gpioconf_init(struct usb_serial *serial) |
| 1533 | { | 1612 | { |
| 1534 | struct cp210x_serial_private *priv = usb_get_serial_data(serial); | 1613 | struct cp210x_serial_private *priv = usb_get_serial_data(serial); |
| @@ -1574,12 +1653,6 @@ static int cp2102n_gpioconf_init(struct usb_serial *serial) · 39 unmodified lines | |||
| 1574 | if (config_version != 0x01) | 1653 | if (config_version != 0x01) |
| 1575 | return -ENOTSUPP; | 1654 | return -ENOTSUPP; |
| 1576 | 1655 | ||
| 1577 | /* | ||
| 1578 | * We only support 4 GPIOs even on the QFN28 package, because | ||
| 1579 | * config locations of GPIOs 4-6 determined using reverse | ||
| 1580 | * engineering revealed conflicting offsets with other | ||
| 1581 | * documented functions. So we'll just play it safe for now. | ||
| 1582 | */ | ||
| 1583 | priv->gc.ngpio = 4; | 1656 | priv->gc.ngpio = 4; |
| 1584 | 1657 | ||
| 1585 | /* | 1658 | /* |
| @@ -1594,6 +1667,19 @@ static int cp2102n_gpioconf_init(struct usb_serial *serial) · 8 unmodified lines | |||
| 1594 | /* 0 indicates GPIO mode, 1 is alternate function */ | 1667 | /* 0 indicates GPIO mode, 1 is alternate function */ |
| 1595 | priv->gpio_altfunc = (gpio_ctrl >> 2) & 0x0f; | 1668 | priv->gpio_altfunc = (gpio_ctrl >> 2) & 0x0f; |
| 1596 | 1669 | ||
| 1670 | if (priv->partnum == CP210X_PARTNUM_CP2102N_QFN28) { | ||
| 1671 | /* | ||
| 1672 | * For the QFN28 package, GPIO4-6 are controlled by | ||
| 1673 | * the low three bits of the mode/latch fields. | ||
| 1674 | * Contrary to the document linked above, the bits for | ||
| 1675 | * the SUSPEND pins are elsewhere. No alternate | ||
| 1676 | * function is available for these pins. | ||
| 1677 | */ | ||
| 1678 | priv->gc.ngpio = 7; | ||
| 1679 | gpio_latch |= (gpio_rst_latch & 7) << 4; | ||
| 1680 | priv->gpio_pushpull |= (gpio_pushpull & 7) << 4; | ||
| 1681 | } | ||
| 1682 | |||
| 1597 | /* | 1683 | /* |
| 1598 | * The CP2102N does not strictly has input and output pin modes, | 1684 | * The CP2102N does not strictly has input and output pin modes, |
| 1599 | * it only knows open-drain and push-pull modes which is set at | 1685 | * it only knows open-drain and push-pull modes which is set at |
| @@ -1620,6 +1706,9 @@ static int cp210x_gpio_init(struct usb_serial *serial) · 20 unmodified lines | |||
| 1620 | int result; | 1706 | int result; |
| 1621 | 1707 | ||
| 1622 | switch (priv->partnum) { | 1708 | switch (priv->partnum) { |
| 1709 | case CP210X_PARTNUM_CP2104: | ||
| 1710 | result = cp2104_gpioconf_init(serial); | ||
| 1711 | break; | ||
| 1623 | case CP210X_PARTNUM_CP2105: | 1712 | case CP210X_PARTNUM_CP2105: |
| 1624 | result = cp2105_gpioconf_init(serial); | 1713 | result = cp2105_gpioconf_init(serial); |
| 1625 | break; | 1714 | break; |
| @@ -1716,6 +1805,7 @@ static void cp210x_init_max_speed(struct usb_serial *serial) · 90 unmodified lines | |||
| 1716 | { | 1805 | { |
| 1717 | struct cp210x_serial_private *priv = usb_get_serial_data(serial); | 1806 | struct cp210x_serial_private *priv = usb_get_serial_data(serial); |
| 1718 | bool use_actual_rate = false; | 1807 | bool use_actual_rate = false; |
| 1808 | speed_t min = 300; | ||
| 1719 | speed_t max; | 1809 | speed_t max; |
| 1720 | 1810 | ||
| 1721 | switch (priv->partnum) { | 1811 | switch (priv->partnum) { |
| @@ -1738,6 +1828,7 @@ static void cp210x_init_max_speed(struct usb_serial *serial) · 16 unmodified lines | |||
| 1738 | use_actual_rate = true; | 1828 | use_actual_rate = true; |
| 1739 | max = 2000000; /* ECI */ | 1829 | max = 2000000; /* ECI */ |
| 1740 | } else { | 1830 | } else { |
| 1831 | min = 2400; | ||
| 1741 | max = 921600; /* SCI */ | 1832 | max = 921600; /* SCI */ |
| 1742 | } | 1833 | } |
| 1743 | break; | 1834 | break; |
| @@ -1752,6 +1843,7 @@ static void cp210x_init_max_speed(struct usb_serial *serial) · 8 unmodified lines | |||
| 1752 | break; | 1843 | break; |
| 1753 | } | 1844 | } |
| 1754 | 1845 | ||
| 1846 | priv->min_speed = min; | ||
| 1755 | priv->max_speed = max; | 1847 | priv->max_speed = max; |
| 1756 | priv->use_actual_rate = use_actual_rate; | 1848 | priv->use_actual_rate = use_actual_rate; |
| 1757 | } | 1849 | } |
| @@ -1025,6 +1025,8 @@ static const struct usb_device_id id_table_combined[] = { · 1024 unmodified lines | |||
| 1025 | { USB_DEVICE(CYPRESS_VID, CYPRESS_WICED_BT_USB_PID) }, | 1025 | { USB_DEVICE(CYPRESS_VID, CYPRESS_WICED_BT_USB_PID) }, |
| 1026 | { USB_DEVICE(CYPRESS_VID, CYPRESS_WICED_WL_USB_PID) }, | 1026 | { USB_DEVICE(CYPRESS_VID, CYPRESS_WICED_WL_USB_PID) }, |
| 1027 | { USB_DEVICE(AIRBUS_DS_VID, AIRBUS_DS_P8GR) }, | 1027 | { USB_DEVICE(AIRBUS_DS_VID, AIRBUS_DS_P8GR) }, |
| 1028 | /* EZPrototypes devices */ | ||
| 1029 | { USB_DEVICE(EZPROTOTYPES_VID, HJELMSLUND_USB485_ISO_PID) }, | ||
| 1028 | { } /* Terminating entry */ | 1030 | { } /* Terminating entry */ |
| 1029 | }; | 1031 | }; |
| 1030 | 1032 | ||
| @@ -1308,6 +1308,12 @@ · 1307 unmodified lines | |||
| 1308 | #define IONICS_VID 0x1c0c | 1308 | #define IONICS_VID 0x1c0c |
| 1309 | #define IONICS_PLUGCOMPUTER_PID 0x0102 | 1309 | #define IONICS_PLUGCOMPUTER_PID 0x0102 |
| 1310 | 1310 | ||
| 1311 | /* | ||
| 1312 | * EZPrototypes (PID reseller) | ||
| 1313 | */ | ||
| 1314 | #define EZPROTOTYPES_VID 0x1c40 | ||
| 1315 | #define HJELMSLUND_USB485_ISO_PID 0x0477 | ||
| 1316 | |||
| 1311 | /* | 1317 | /* |
| 1312 | * Dresden Elektronik Sensor Terminal Board | 1318 | * Dresden Elektronik Sensor Terminal Board |
| 1313 | */ | 1319 | */ |
| @@ -1148,6 +1148,8 @@ static const struct usb_device_id option_ids[] = { · 1147 unmodified lines | |||
| 1148 | .driver_info = NCTRL(0) | RSVD(1) | RSVD(3) }, | 1148 | .driver_info = NCTRL(0) | RSVD(1) | RSVD(3) }, |
| 1149 | { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_ME910_DUAL_MODEM), | 1149 | { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_ME910_DUAL_MODEM), |
| 1150 | .driver_info = NCTRL(0) | RSVD(3) }, | 1150 | .driver_info = NCTRL(0) | RSVD(3) }, |
| 1151 | { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x1102, 0xff), /* Telit ME910 (ECM) */ | ||
| 1152 | .driver_info = NCTRL(0) }, | ||
| 1151 | { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE910), | 1153 | { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE910), |
| 1152 | .driver_info = NCTRL(0) | RSVD(1) | RSVD(2) }, | 1154 | .driver_info = NCTRL(0) | RSVD(1) | RSVD(2) }, |
| 1153 | { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE910_USBCFG4), | 1155 | { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE910_USBCFG4), |
| @@ -1,3 +1,4 @@ | |||
| 1 | # SPDX-License-Identifier: GPL-2.0 | ||
| 1 | # | 2 | # |
| 2 | # USB Storage driver configuration | 3 | # USB Storage driver configuration |
| 3 | # | 4 | # |
| @@ -167,6 +167,7 @@ static int rio_karma_transport(struct scsi_cmnd *srb, struct us_data *us) · 166 unmodified lines | |||
| 167 | static void rio_karma_destructor(void *extra) | 167 | static void rio_karma_destructor(void *extra) |
| 168 | { | 168 | { |
| 169 | struct karma_data *data = (struct karma_data *) extra; | 169 | struct karma_data *data = (struct karma_data *) extra; |
| 170 | |||
| 170 | kfree(data->recv); | 171 | kfree(data->recv); |
| 171 | } | 172 | } |
| 172 | 173 | ||
| @@ -174,6 +175,7 @@ static int rio_karma_init(struct us_data *us) · 1 unmodified line | |||
| 174 | { | 175 | { |
| 175 | int ret = 0; | 176 | int ret = 0; |
| 176 | struct karma_data *data = kzalloc(sizeof(struct karma_data), GFP_NOIO); | 177 | struct karma_data *data = kzalloc(sizeof(struct karma_data), GFP_NOIO); |
| 178 | |||
| 177 | if (!data) | 179 | if (!data) |
| 178 | goto out; | 180 | goto out; |
| 179 | 181 | ||
| @@ -1,3 +1,4 @@ | |||
| 1 | # SPDX-License-Identifier: GPL-2.0 | ||
| 1 | 2 | ||
| 2 | menuconfig TYPEC | 3 | menuconfig TYPEC |
| 3 | tristate "USB Type-C Support" | 4 | tristate "USB Type-C Support" |
| @@ -1,3 +1,4 @@ | |||
| 1 | # SPDX-License-Identifier: GPL-2.0 | ||
| 1 | 2 | ||
| 2 | menu "USB Type-C Alternate Mode drivers" | 3 | menu "USB Type-C Alternate Mode drivers" |
| 3 | 4 | ||
| @@ -1,2 +1,4 @@ | |||
| 1 | # SPDX-License-Identifier: GPL-2.0 | ||
| 2 | |||
| 1 | obj-$(CONFIG_TYPEC_DP_ALTMODE) += typec_displayport.o | 3 | obj-$(CONFIG_TYPEC_DP_ALTMODE) += typec_displayport.o |
| 2 | typec_displayport-y := displayport.o | 4 | typec_displayport-y := displayport.o |
| @@ -24,10 +24,6 @@ enum { · 23 unmodified lines | |||
| 24 | DP_CONF_DUAL_D, | 24 | DP_CONF_DUAL_D, |
| 25 | }; | 25 | }; |
| 26 | 26 | ||
| 27 | /* Helper for setting/getting the pin assignement value to the configuration */ | ||
| 28 | #define DP_CONF_SET_PIN_ASSIGN(_a_) ((_a_) << 8) | ||
| 29 | #define DP_CONF_GET_PIN_ASSIGN(_conf_) (((_conf_) & GENMASK(15, 8)) >> 8) | ||
| 30 | |||
| 31 | /* Pin assignments that use USB3.1 Gen2 signaling to carry DP protocol */ | 27 | /* Pin assignments that use USB3.1 Gen2 signaling to carry DP protocol */ |
| 32 | #define DP_PIN_ASSIGN_GEN2_BR_MASK (BIT(DP_PIN_ASSIGN_A) | \ | 28 | #define DP_PIN_ASSIGN_GEN2_BR_MASK (BIT(DP_PIN_ASSIGN_A) | \ |
| 33 | BIT(DP_PIN_ASSIGN_B)) | 29 | BIT(DP_PIN_ASSIGN_B)) |
| @@ -9,6 +9,7 @@ · 8 unmodified lines | |||
| 9 | #include <linux/device.h> | 9 | #include <linux/device.h> |
| 10 | #include <linux/module.h> | 10 | #include <linux/module.h> |
| 11 | #include <linux/mutex.h> | 11 | #include <linux/mutex.h> |
| 12 | #include <linux/property.h> | ||
| 12 | #include <linux/slab.h> | 13 | #include <linux/slab.h> |
| 13 | 14 | ||
| 14 | #include "bus.h" | 15 | #include "bus.h" |
| @@ -204,15 +205,32 @@ static void typec_altmode_put_partner(struct altmode *altmode) · 189 unmodified lines | |||
| 204 | put_device(&adev->dev); | 205 | put_device(&adev->dev); |
| 205 | } | 206 | } |
| 206 | 207 | ||
| 207 | static int __typec_port_match(struct device *dev, const void *name) | 208 | static int typec_port_fwnode_match(struct device *dev, const void *fwnode) |
| 209 | { | ||
| 210 | return dev_fwnode(dev) == fwnode; | ||
| 211 | } | ||
| 212 | |||
| 213 | static int typec_port_name_match(struct device *dev, const void *name) | ||
| 208 | { | 214 | { |
| 209 | return !strcmp((const char *)name, dev_name(dev)); | 215 | return !strcmp((const char *)name, dev_name(dev)); |
| 210 | } | 216 | } |
| 211 | 217 | ||
| 212 | static void *typec_port_match(struct device_connection *con, int ep, void *data) | 218 | static void *typec_port_match(struct device_connection *con, int ep, void *data) |
| 213 | { | 219 | { |
| 214 | return class_find_device(typec_class, NULL, con->endpoint[ep], | 220 | struct device *dev; |
| 215 | __typec_port_match); | 221 | |
| 222 | /* | ||
| 223 | * FIXME: Check does the fwnode supports the requested SVID. If it does | ||
| 224 | * we need to return ERR_PTR(-PROBE_DEFER) when there is no device. | ||
| 225 | */ | ||
| 226 | if (con->fwnode) | ||
| 227 | return class_find_device(typec_class, NULL, con->fwnode, | ||
| 228 | typec_port_fwnode_match); | ||
| 229 | |||
| 230 | dev = class_find_device(typec_class, NULL, con->endpoint[ep], | ||
| 231 | typec_port_name_match); | ||
| 232 | |||
| 233 | return dev ? dev : ERR_PTR(-EPROBE_DEFER); | ||
| 216 | } | 234 | } |
| 217 | 235 | ||
| 218 | struct typec_altmode * | 236 | struct typec_altmode * |
| @@ -277,7 +295,7 @@ void typec_altmode_update_active(struct typec_altmode *adev, bool active) · 58 unmodified lines | |||
| 277 | if (adev->active == active) | 295 | if (adev->active == active) |
| 278 | return; | 296 | return; |
| 279 | 297 | ||
| 280 | if (!is_typec_port(adev->dev.parent)) { | 298 | if (!is_typec_port(adev->dev.parent) && adev->dev.driver) { |
| 281 | if (!active) | 299 | if (!active) |
| 282 | module_put(adev->dev.driver->owner); | 300 | module_put(adev->dev.driver->owner); |
| 283 | else | 301 | else |
| @@ -1496,11 +1514,8 @@ typec_port_register_altmode(struct typec_port *port, · 1212 unmodified lines | |||
| 1496 | { | 1514 | { |
| 1497 | struct typec_altmode *adev; | 1515 | struct typec_altmode *adev; |
| 1498 | struct typec_mux *mux; | 1516 | struct typec_mux *mux; |
| 1499 | char id[10]; | ||
| 1500 | |||
| 1501 | sprintf(id, "id%04xm%02x", desc->svid, desc->mode); | ||
| 1502 | 1517 | ||
| 1503 | mux = typec_mux_get(&port->dev, id); | 1518 | mux = typec_mux_get(&port->dev, desc); |
| 1504 | if (IS_ERR(mux)) | 1519 | if (IS_ERR(mux)) |
| 1505 | return ERR_CAST(mux); | 1520 | return ERR_CAST(mux); |
| 1506 | 1521 | ||
| @@ -1593,7 +1608,7 @@ struct typec_port *typec_register_port(struct device *parent, · 86 unmodified lines | |||
| 1593 | return ERR_CAST(port->sw); | 1608 | return ERR_CAST(port->sw); |
| 1594 | } | 1609 | } |
| 1595 | 1610 | ||
| 1596 | port->mux = typec_mux_get(&port->dev, "typec-mux"); | 1611 | port->mux = typec_mux_get(&port->dev, NULL); |
| 1597 | if (IS_ERR(port->mux)) { | 1612 | if (IS_ERR(port->mux)) { |
| 1598 | put_device(&port->dev); | 1613 | put_device(&port->dev); |
| 1599 | return ERR_CAST(port->mux); | 1614 | return ERR_CAST(port->mux); |
| @@ -11,6 +11,8 @@ · 10 unmodified lines | |||
| 11 | #include <linux/list.h> | 11 | #include <linux/list.h> |
| 12 | #include <linux/module.h> | 12 | #include <linux/module.h> |
| 13 | #include <linux/mutex.h> | 13 | #include <linux/mutex.h> |
| 14 | #include <linux/property.h> | ||
| 15 | #include <linux/slab.h> | ||
| 14 | #include <linux/usb/typec_mux.h> | 16 | #include <linux/usb/typec_mux.h> |
| 15 | 17 | ||
| 16 | static DEFINE_MUTEX(switch_lock); | 18 | static DEFINE_MUTEX(switch_lock); |
| @@ -23,15 +25,25 @@ static void *typec_switch_match(struct device_connection *con, int ep, · 6 unmodified lines | |||
| 23 | { | 25 | { |
| 24 | struct typec_switch *sw; | 26 | struct typec_switch *sw; |
| 25 | 27 | ||
| 26 | list_for_each_entry(sw, &switch_list, entry) | 28 | if (!con->fwnode) { |
| 27 | if (!strcmp(con->endpoint[ep], dev_name(sw->dev))) | 29 | list_for_each_entry(sw, &switch_list, entry) |
| 28 | return sw; | 30 | if (!strcmp(con->endpoint[ep], dev_name(sw->dev))) |
| 31 | return sw; | ||
| 32 | return ERR_PTR(-EPROBE_DEFER); | ||
| 33 | } | ||
| 29 | 34 | ||
| 30 | /* | 35 | /* |
| 31 | * We only get called if a connection was found, tell the caller to | 36 | * With OF graph the mux node must have a boolean device property named |
| 32 | * wait for the switch to show up. | 37 | * "orientation-switch". |
| 33 | */ | 38 | */ |
| 34 | return ERR_PTR(-EPROBE_DEFER); | 39 | if (con->id && !fwnode_property_present(con->fwnode, con->id)) |
| 40 | return NULL; | ||
| 41 | |||
| 42 | list_for_each_entry(sw, &switch_list, entry) | ||
| 43 | if (dev_fwnode(sw->dev) == con->fwnode) | ||
| 44 | return sw; | ||
| 45 | |||
| 46 | return con->id ? ERR_PTR(-EPROBE_DEFER) : NULL; | ||
| 35 | } | 47 | } |
| 36 | 48 | ||
| 37 | /** | 49 | /** |
| @@ -48,7 +60,7 @@ struct typec_switch *typec_switch_get(struct device *dev) · 10 unmodified lines | |||
| 48 | struct typec_switch *sw; | 60 | struct typec_switch *sw; |
| 49 | 61 | ||
| 50 | mutex_lock(&switch_lock); | 62 | mutex_lock(&switch_lock); |
| 51 | sw = device_connection_find_match(dev, "typec-switch", NULL, | 63 | sw = device_connection_find_match(dev, "orientation-switch", NULL, |
| 52 | typec_switch_match); | 64 | typec_switch_match); |
| 53 | if (!IS_ERR_OR_NULL(sw)) { | 65 | if (!IS_ERR_OR_NULL(sw)) { |
| 54 | WARN_ON(!try_module_get(sw->dev->driver->owner)); | 66 | WARN_ON(!try_module_get(sw->dev->driver->owner)); |
| @@ -112,35 +124,87 @@ EXPORT_SYMBOL_GPL(typec_switch_unregister); · 57 unmodified lines | |||
| 112 | 124 | ||
| 113 | static void *typec_mux_match(struct device_connection *con, int ep, void *data) | 125 | static void *typec_mux_match(struct device_connection *con, int ep, void *data) |
| 114 | { | 126 | { |
| 127 | const struct typec_altmode_desc *desc = data; | ||
| 115 | struct typec_mux *mux; | 128 | struct typec_mux *mux; |
| 129 | int nval; | ||
| 130 | bool match; | ||
| 131 | u16 *val; | ||
| 132 | int i; | ||
| 116 | 133 | ||
| 117 | list_for_each_entry(mux, &mux_list, entry) | 134 | if (!con->fwnode) { |
| 118 | if (!strcmp(con->endpoint[ep], dev_name(mux->dev))) | 135 | list_for_each_entry(mux, &mux_list, entry) |
| 119 | return mux; | 136 | if (!strcmp(con->endpoint[ep], dev_name(mux->dev))) |
| 137 | return mux; | ||
| 138 | return ERR_PTR(-EPROBE_DEFER); | ||
| 139 | } | ||
| 120 | 140 | ||
| 121 | /* | 141 | /* |
| 122 | * We only get called if a connection was found, tell the caller to | 142 | * Check has the identifier already been "consumed". If it |
| 123 | * wait for the switch to show up. | 143 | * has, no need to do any extra connection identification. |
| 124 | */ | 144 | */ |
| 145 | match = !con->id; | ||
| 146 | if (match) | ||
| 147 | goto find_mux; | ||
| 148 | |||
| 149 | /* Accessory Mode muxes */ | ||
| 150 | if (!desc) { | ||
| 151 | match = fwnode_property_present(con->fwnode, "accessory"); | ||
| 152 | if (match) | ||
| 153 | goto find_mux; | ||
| 154 | return NULL; | ||
| 155 | } | ||
| 156 | |||
| 157 | /* Alternate Mode muxes */ | ||
| 158 | nval = fwnode_property_read_u16_array(con->fwnode, "svid", NULL, 0); | ||
| 159 | if (nval <= 0) | ||
| 160 | return NULL; | ||
| 161 | |||
| 162 | val = kcalloc(nval, sizeof(*val), GFP_KERNEL); | ||
| 163 | if (!val) | ||
| 164 | return ERR_PTR(-ENOMEM); | ||
| 165 | |||
| 166 | nval = fwnode_property_read_u16_array(con->fwnode, "svid", val, nval); | ||
| 167 | if (nval < 0) { | ||
| 168 | kfree(val); | ||
| 169 | return ERR_PTR(nval); | ||
| 170 | } | ||
| 171 | |||
| 172 | for (i = 0; i < nval; i++) { | ||
| 173 | match = val[i] == desc->svid; | ||
| 174 | if (match) { | ||
| 175 | kfree(val); | ||
| 176 | goto find_mux; | ||
| 177 | } | ||
| 178 | } | ||
| 179 | kfree(val); | ||
| 180 | return NULL; | ||
| 181 | |||
| 182 | find_mux: | ||
| 183 | list_for_each_entry(mux, &mux_list, entry) | ||
| 184 | if (dev_fwnode(mux->dev) == con->fwnode) | ||
| 185 | return mux; | ||
| 186 | |||
| 125 | return ERR_PTR(-EPROBE_DEFER); | 187 | return ERR_PTR(-EPROBE_DEFER); |
| 126 | } | 188 | } |
| 127 | 189 | ||
| 128 | /** | 190 | /** |
| 129 | * typec_mux_get - Find USB Type-C Multiplexer | 191 | * typec_mux_get - Find USB Type-C Multiplexer |
| 130 | * @dev: The caller device | 192 | * @dev: The caller device |
| 131 | * @name: Mux identifier | 193 | * @desc: Alt Mode description |
| 132 | * | 194 | * |
| 133 | * Finds a mux linked to the caller. This function is primarily meant for the | 195 | * Finds a mux linked to the caller. This function is primarily meant for the |
| 134 | * Type-C drivers. Returns a reference to the mux on success, NULL if no | 196 | * Type-C drivers. Returns a reference to the mux on success, NULL if no |
| 135 | * matching connection was found, or ERR_PTR(-EPROBE_DEFER) when a connection | 197 | * matching connection was found, or ERR_PTR(-EPROBE_DEFER) when a connection |
| 136 | * was found but the mux has not been enumerated yet. | 198 | * was found but the mux has not been enumerated yet. |
| 137 | */ | 199 | */ |
| 138 | struct typec_mux *typec_mux_get(struct device *dev, const char *name) | 200 | struct typec_mux *typec_mux_get(struct device *dev, |
| 201 | const struct typec_altmode_desc *desc) | ||
| 139 | { | 202 | { |
| 140 | struct typec_mux *mux; | 203 | struct typec_mux *mux; |
| 141 | 204 | ||
| 142 | mutex_lock(&mux_lock); | 205 | mutex_lock(&mux_lock); |
| 143 | mux = device_connection_find_match(dev, name, NULL, typec_mux_match); | 206 | mux = device_connection_find_match(dev, "mode-switch", (void *)desc, |
| 207 | typec_mux_match); | ||
| 144 | if (!IS_ERR_OR_NULL(mux)) { | 208 | if (!IS_ERR_OR_NULL(mux)) { |
| 145 | WARN_ON(!try_module_get(mux->dev->driver->owner)); | 209 | WARN_ON(!try_module_get(mux->dev->driver->owner)); |
| 146 | get_device(mux->dev); | 210 | get_device(mux->dev); |
| @@ -1,3 +1,5 @@ | |||
| 1 | # SPDX-License-Identifier: GPL-2.0 | ||
| 2 | |||
| 1 | menu "USB Type-C Multiplexer/DeMultiplexer Switch support" | 3 | menu "USB Type-C Multiplexer/DeMultiplexer Switch support" |
| 2 | 4 | ||
| 3 | config TYPEC_MUX_PI3USB30532 | 5 | config TYPEC_MUX_PI3USB30532 |
| @@ -1,3 +1,5 @@ | |||
| 1 | # SPDX-License-Identifier: GPL-2.0 | ||
| 2 | |||
| 1 | config TYPEC_TCPM | 3 | config TYPEC_TCPM |
| 2 | tristate "USB Type-C Port Controller Manager" | 4 | tristate "USB Type-C Port Controller Manager" |
| 3 | depends on USB | 5 | depends on USB |
| @@ -4435,66 +4435,6 @@ sink: · 4434 unmodified lines | |||
| 4435 | return 0; | 4435 | return 0; |
| 4436 | } | 4436 | } |
| 4437 | 4437 | ||
| 4438 | int tcpm_update_source_capabilities(struct tcpm_port *port, const u32 *pdo, | ||
| 4439 | unsigned int nr_pdo) | ||
| 4440 | { | ||
| 4441 | if (tcpm_validate_caps(port, pdo, nr_pdo)) | ||
| 4442 | return -EINVAL; | ||
| 4443 | |||
| 4444 | mutex_lock(&port->lock); | ||
| 4445 | port->nr_src_pdo = tcpm_copy_pdos(port->src_pdo, pdo, nr_pdo); | ||
| 4446 | switch (port->state) { | ||
| 4447 | case SRC_UNATTACHED: | ||
| 4448 | case SRC_ATTACH_WAIT: | ||
| 4449 | case SRC_TRYWAIT: | ||
| 4450 | tcpm_set_cc(port, tcpm_rp_cc(port)); | ||
| 4451 | break; | ||
| 4452 | case SRC_SEND_CAPABILITIES: | ||
| 4453 | case SRC_NEGOTIATE_CAPABILITIES: | ||
| 4454 | case SRC_READY: | ||
| 4455 | case SRC_WAIT_NEW_CAPABILITIES: | ||
| 4456 | tcpm_set_cc(port, tcpm_rp_cc(port)); | ||
| 4457 | tcpm_set_state(port, SRC_SEND_CAPABILITIES, 0); | ||
| 4458 | break; | ||
| 4459 | default: | ||
| 4460 | break; | ||
| 4461 | } | ||
| 4462 | mutex_unlock(&port->lock); | ||
| 4463 | return 0; | ||
| 4464 | } | ||
| 4465 | EXPORT_SYMBOL_GPL(tcpm_update_source_capabilities); | ||
| 4466 | |||
| 4467 | int tcpm_update_sink_capabilities(struct tcpm_port *port, const u32 *pdo, | ||
| 4468 | unsigned int nr_pdo, | ||
| 4469 | unsigned int operating_snk_mw) | ||
| 4470 | { | ||
| 4471 | if (tcpm_validate_caps(port, pdo, nr_pdo)) | ||
| 4472 | return -EINVAL; | ||
| 4473 | |||
| 4474 | mutex_lock(&port->lock); | ||
| 4475 | port->nr_snk_pdo = tcpm_copy_pdos(port->snk_pdo, pdo, nr_pdo); | ||
| 4476 | port->operating_snk_mw = operating_snk_mw; | ||
| 4477 | port->update_sink_caps = true; | ||
| 4478 | |||
| 4479 | switch (port->state) { | ||
| 4480 | case SNK_NEGOTIATE_CAPABILITIES: | ||
| 4481 | case SNK_NEGOTIATE_PPS_CAPABILITIES: | ||
| 4482 | case SNK_READY: | ||
| 4483 | case SNK_TRANSITION_SINK: | ||
| 4484 | case SNK_TRANSITION_SINK_VBUS: | ||
| 4485 | if (port->pps_data.active) | ||
| 4486 | tcpm_set_state(port, SNK_NEGOTIATE_PPS_CAPABILITIES, 0); | ||
| 4487 | else | ||
| 4488 | tcpm_set_state(port, SNK_NEGOTIATE_CAPABILITIES, 0); | ||
| 4489 | break; | ||
| 4490 | default: | ||
| 4491 | break; | ||
| 4492 | } | ||
| 4493 | mutex_unlock(&port->lock); | ||
| 4494 | return 0; | ||
| 4495 | } | ||
| 4496 | EXPORT_SYMBOL_GPL(tcpm_update_sink_capabilities); | ||
| 4497 | |||
| 4498 | /* Power Supply access to expose source power information */ | 4438 | /* Power Supply access to expose source power information */ |
| 4499 | enum tcpm_psy_online_states { | 4439 | enum tcpm_psy_online_states { |
| 4500 | TCPM_PSY_OFFLINE = 0, | 4440 | TCPM_PSY_OFFLINE = 0, |
| @@ -4811,12 +4751,12 @@ struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc) · 310 unmodified lines | |||
| 4811 | 4751 | ||
| 4812 | err = devm_tcpm_psy_register(port); | 4752 | err = devm_tcpm_psy_register(port); |
| 4813 | if (err) | 4753 | if (err) |
| 4814 | goto out_destroy_wq; | 4754 | goto out_role_sw_put; |
| 4815 | 4755 | ||
| 4816 | port->typec_port = typec_register_port(port->dev, &port->typec_caps); | 4756 | port->typec_port = typec_register_port(port->dev, &port->typec_caps); |
| 4817 | if (IS_ERR(port->typec_port)) { | 4757 | if (IS_ERR(port->typec_port)) { |
| 4818 | err = PTR_ERR(port->typec_port); | 4758 | err = PTR_ERR(port->typec_port); |
| 4819 | goto out_destroy_wq; | 4759 | goto out_role_sw_put; |
| 4820 | } | 4760 | } |
| 4821 | 4761 | ||
| 4822 | if (tcpc->config && tcpc->config->alt_modes) { | 4762 | if (tcpc->config && tcpc->config->alt_modes) { |
| @@ -4849,8 +4789,10 @@ struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc) · 26 unmodified lines | |||
| 4849 | tcpm_log(port, "%s: registered", dev_name(dev)); | 4789 | tcpm_log(port, "%s: registered", dev_name(dev)); |
| 4850 | return port; | 4790 | return port; |
| 4851 | 4791 | ||
| 4852 | out_destroy_wq: | 4792 | out_role_sw_put: |
| 4853 | usb_role_switch_put(port->role_sw); | 4793 | usb_role_switch_put(port->role_sw); |
| 4794 | out_destroy_wq: | ||
| 4795 | tcpm_debugfs_exit(port); | ||
| 4854 | destroy_workqueue(port->wq); | 4796 | destroy_workqueue(port->wq); |
| 4855 | return ERR_PTR(err); | 4797 | return ERR_PTR(err); |
| 4856 | } | 4798 | } |
| @@ -14,6 +14,8 @@ · 13 unmodified lines | |||
| 14 | #include <linux/usb/typec.h> | 14 | #include <linux/usb/typec.h> |
| 15 | 15 | ||
| 16 | /* Register offsets */ | 16 | /* Register offsets */ |
| 17 | #define TPS_REG_VID 0x00 | ||
| 18 | #define TPS_REG_MODE 0x03 | ||
| 17 | #define TPS_REG_CMD1 0x08 | 19 | #define TPS_REG_CMD1 0x08 |
| 18 | #define TPS_REG_DATA1 0x09 | 20 | #define TPS_REG_DATA1 0x09 |
| 19 | #define TPS_REG_INT_EVENT1 0x14 | 21 | #define TPS_REG_INT_EVENT1 0x14 |
| @@ -66,6 +68,20 @@ struct tps6598x_rx_identity_reg { · 46 unmodified lines | |||
| 66 | #define TPS_TASK_TIMEOUT 1 | 68 | #define TPS_TASK_TIMEOUT 1 |
| 67 | #define TPS_TASK_REJECTED 3 | 69 | #define TPS_TASK_REJECTED 3 |
| 68 | 70 | ||
| 71 | enum { | ||
| 72 | TPS_MODE_APP, | ||
| 73 | TPS_MODE_BOOT, | ||
| 74 | TPS_MODE_BIST, | ||
| 75 | TPS_MODE_DISC, | ||
| 76 | }; | ||
| 77 | |||
| 78 | static const char *const modes[] = { | ||
| 79 | [TPS_MODE_APP] = "APP ", | ||
| 80 | [TPS_MODE_BOOT] = "BOOT", | ||
| 81 | [TPS_MODE_BIST] = "BIST", | ||
| 82 | [TPS_MODE_DISC] = "DISC", | ||
| 83 | }; | ||
| 84 | |||
| 69 | /* Unrecognized commands will be replaced with "!CMD" */ | 85 | /* Unrecognized commands will be replaced with "!CMD" */ |
| 70 | #define INVALID_CMD(_cmd_) (_cmd_ == 0x444d4321) | 86 | #define INVALID_CMD(_cmd_) (_cmd_ == 0x444d4321) |
| 71 | 87 | ||
| @@ -110,6 +126,20 @@ tps6598x_block_read(struct tps6598x *tps, u8 reg, void *val, size_t len) · 38 unmodified lines | |||
| 110 | return 0; | 126 | return 0; |
| 111 | } | 127 | } |
| 112 | 128 | ||
| 129 | static int tps6598x_block_write(struct tps6598x *tps, u8 reg, | ||
| 130 | void *val, size_t len) | ||
| 131 | { | ||
| 132 | u8 data[TPS_MAX_LEN + 1]; | ||
| 133 | |||
| 134 | if (!tps->i2c_protocol) | ||
| 135 | return regmap_raw_write(tps->regmap, reg, val, len); | ||
| 136 | |||
| 137 | data[0] = len; | ||
| 138 | memcpy(&data[1], val, len); | ||
| 139 | |||
| 140 | return regmap_raw_write(tps->regmap, reg, data, sizeof(data)); | ||
| 141 | } | ||
| 142 | |||
| 113 | static inline int tps6598x_read16(struct tps6598x *tps, u8 reg, u16 *val) | 143 | static inline int tps6598x_read16(struct tps6598x *tps, u8 reg, u16 *val) |
| 114 | { | 144 | { |
| 115 | return tps6598x_block_read(tps, reg, val, sizeof(u16)); | 145 | return tps6598x_block_read(tps, reg, val, sizeof(u16)); |
| @@ -127,23 +157,23 @@ static inline int tps6598x_read64(struct tps6598x *tps, u8 reg, u64 *val) · 11 unmodified lines | |||
| 127 | 157 | ||
| 128 | static inline int tps6598x_write16(struct tps6598x *tps, u8 reg, u16 val) | 158 | static inline int tps6598x_write16(struct tps6598x *tps, u8 reg, u16 val) |
| 129 | { | 159 | { |
| 130 | return regmap_raw_write(tps->regmap, reg, &val, sizeof(u16)); | 160 | return tps6598x_block_write(tps, reg, &val, sizeof(u16)); |
| 131 | } | 161 | } |
| 132 | 162 | ||
| 133 | static inline int tps6598x_write32(struct tps6598x *tps, u8 reg, u32 val) | 163 | static inline int tps6598x_write32(struct tps6598x *tps, u8 reg, u32 val) |
| 134 | { | 164 | { |
| 135 | return regmap_raw_write(tps->regmap, reg, &val, sizeof(u32)); | 165 | return tps6598x_block_write(tps, reg, &val, sizeof(u32)); |
| 136 | } | 166 | } |
| 137 | 167 | ||
| 138 | static inline int tps6598x_write64(struct tps6598x *tps, u8 reg, u64 val) | 168 | static inline int tps6598x_write64(struct tps6598x *tps, u8 reg, u64 val) |
| 139 | { | 169 | { |
| 140 | return regmap_raw_write(tps->regmap, reg, &val, sizeof(u64)); | 170 | return tps6598x_block_write(tps, reg, &val, sizeof(u64)); |
| 141 | } | 171 | } |
| 142 | 172 | ||
| 143 | static inline int | 173 | static inline int |
| 144 | tps6598x_write_4cc(struct tps6598x *tps, u8 reg, const char *val) | 174 | tps6598x_write_4cc(struct tps6598x *tps, u8 reg, const char *val) |
| 145 | { | 175 | { |
| 146 | return regmap_raw_write(tps->regmap, reg, &val, sizeof(u32)); | 176 | return tps6598x_block_write(tps, reg, &val, sizeof(u32)); |
| 147 | } | 177 | } |
| 148 | 178 | ||
| 149 | static int tps6598x_read_partner_identity(struct tps6598x *tps) | 179 | static int tps6598x_read_partner_identity(struct tps6598x *tps) |
| @@ -229,8 +259,8 @@ static int tps6598x_exec_cmd(struct tps6598x *tps, const char *cmd, · 79 unmodified lines | |||
| 229 | return -EBUSY; | 259 | return -EBUSY; |
| 230 | 260 | ||
| 231 | if (in_len) { | 261 | if (in_len) { |
| 232 | ret = regmap_raw_write(tps->regmap, TPS_REG_DATA1, | 262 | ret = tps6598x_block_write(tps, TPS_REG_DATA1, |
| 233 | in_data, in_len); | 263 | in_data, in_len); |
| 234 | if (ret) | 264 | if (ret) |
| 235 | return ret; | 265 | return ret; |
| 236 | } | 266 | } |
| @@ -384,6 +414,32 @@ err_unlock: · 147 unmodified lines | |||
| 384 | return IRQ_HANDLED; | 414 | return IRQ_HANDLED; |
| 385 | } | 415 | } |
| 386 | 416 | ||
| 417 | static int tps6598x_check_mode(struct tps6598x *tps) | ||
| 418 | { | ||
| 419 | char mode[5] = { }; | ||
| 420 | int ret; | ||
| 421 | |||
| 422 | ret = tps6598x_read32(tps, TPS_REG_MODE, (void *)mode); | ||
| 423 | if (ret) | ||
| 424 | return ret; | ||
| 425 | |||
| 426 | switch (match_string(modes, ARRAY_SIZE(modes), mode)) { | ||
| 427 | case TPS_MODE_APP: | ||
| 428 | return 0; | ||
| 429 | case TPS_MODE_BOOT: | ||
| 430 | dev_warn(tps->dev, "dead-battery condition\n"); | ||
| 431 | return 0; | ||
| 432 | case TPS_MODE_BIST: | ||
| 433 | case TPS_MODE_DISC: | ||
| 434 | default: | ||
| 435 | dev_err(tps->dev, "controller in unsupported mode \"%s\"\n", | ||
| 436 | mode); | ||
| 437 | break; | ||
| 438 | } | ||
| 439 | |||
| 440 | return -ENODEV; | ||
| 441 | } | ||
| 442 | |||
| 387 | static const struct regmap_config tps6598x_regmap_config = { | 443 | static const struct regmap_config tps6598x_regmap_config = { |
| 388 | .reg_bits = 8, | 444 | .reg_bits = 8, |
| 389 | .val_bits = 8, | 445 | .val_bits = 8, |
| @@ -409,10 +465,8 @@ static int tps6598x_probe(struct i2c_client *client) · 19 unmodified lines | |||
| 409 | if (IS_ERR(tps->regmap)) | 465 | if (IS_ERR(tps->regmap)) |
| 410 | return PTR_ERR(tps->regmap); | 466 | return PTR_ERR(tps->regmap); |
| 411 | 467 | ||
| 412 | ret = tps6598x_read32(tps, 0, &vid); | 468 | ret = tps6598x_read32(tps, TPS_REG_VID, &vid); |
| 413 | if (ret < 0) | 469 | if (ret < 0 || !vid) |
| 414 | return ret; | ||
| 415 | if (!vid) | ||
| 416 | return -ENODEV; | 470 | return -ENODEV; |
| 417 | 471 | ||
| 418 | /* | 472 | /* |
| @@ -425,6 +479,11 @@ static int tps6598x_probe(struct i2c_client *client) · 6 unmodified lines | |||
| 425 | if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) | 479 | if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) |
| 426 | tps->i2c_protocol = true; | 480 | tps->i2c_protocol = true; |
| 427 | 481 | ||
| 482 | /* Make sure the controller has application firmware running */ | ||
| 483 | ret = tps6598x_check_mode(tps); | ||
| 484 | if (ret) | ||
| 485 | return ret; | ||
| 486 | |||
| 428 | ret = tps6598x_read32(tps, TPS_REG_STATUS, &status); | 487 | ret = tps6598x_read32(tps, TPS_REG_STATUS, &status); |
| 429 | if (ret < 0) | 488 | if (ret < 0) |
| 430 | return ret; | 489 | return ret; |
| @@ -1,3 +1,5 @@ | |||
| 1 | # SPDX-License-Identifier: GPL-2.0 | ||
| 2 | |||
| 1 | config TYPEC_UCSI | 3 | config TYPEC_UCSI |
| 2 | tristate "USB Type-C Connector System Software Interface driver" | 4 | tristate "USB Type-C Connector System Software Interface driver" |
| 3 | depends on !CPU_BIG_ENDIAN | 5 | depends on !CPU_BIG_ENDIAN |
| @@ -1,65 +0,0 @@ | |||
| 1 | /* SPDX-License-Identifier: GPL-2.0 */ | ||
| 2 | #ifndef __UCSI_DEBUG_H | ||
| 3 | #define __UCSI_DEBUG_H | ||
| 4 | |||
| 5 | #include "ucsi.h" | ||
| 6 | |||
| 7 | static const char * const ucsi_cmd_strs[] = { | ||
| 8 | [0] = "Unknown command", | ||
| 9 | [UCSI_PPM_RESET] = "PPM_RESET", | ||
| 10 | [UCSI_CANCEL] = "CANCEL", | ||
| 11 | [UCSI_CONNECTOR_RESET] = "CONNECTOR_RESET", | ||
| 12 | [UCSI_ACK_CC_CI] = "ACK_CC_CI", | ||
| 13 | [UCSI_SET_NOTIFICATION_ENABLE] = "SET_NOTIFICATION_ENABLE", | ||
| 14 | [UCSI_GET_CAPABILITY] = "GET_CAPABILITY", | ||
| 15 | [UCSI_GET_CONNECTOR_CAPABILITY] = "GET_CONNECTOR_CAPABILITY", | ||
| 16 | [UCSI_SET_UOM] = "SET_UOM", | ||
| 17 | [UCSI_SET_UOR] = "SET_UOR", | ||
| 18 | [UCSI_SET_PDM] = "SET_PDM", | ||
| 19 | [UCSI_SET_PDR] = "SET_PDR", | ||
| 20 | [UCSI_GET_ALTERNATE_MODES] = "GET_ALTERNATE_MODES", | ||
| 21 | [UCSI_GET_CAM_SUPPORTED] = "GET_CAM_SUPPORTED", | ||
| 22 | [UCSI_GET_CURRENT_CAM] = "GET_CURRENT_CAM", | ||
| 23 | [UCSI_SET_NEW_CAM] = "SET_NEW_CAM", | ||
| 24 | [UCSI_GET_PDOS] = "GET_PDOS", | ||
| 25 | [UCSI_GET_CABLE_PROPERTY] = "GET_CABLE_PROPERTY", | ||
| 26 | [UCSI_GET_CONNECTOR_STATUS] = "GET_CONNECTOR_STATUS", | ||
| 27 | [UCSI_GET_ERROR_STATUS] = "GET_ERROR_STATUS", | ||
| 28 | }; | ||
| 29 | |||
| 30 | static inline const char *ucsi_cmd_str(u64 raw_cmd) | ||
| 31 | { | ||
| 32 | u8 cmd = raw_cmd & GENMASK(7, 0); | ||
| 33 | |||
| 34 | return ucsi_cmd_strs[(cmd >= ARRAY_SIZE(ucsi_cmd_strs)) ? 0 : cmd]; | ||
| 35 | } | ||
| 36 | |||
| 37 | static const char * const ucsi_ack_strs[] = { | ||
| 38 | [0] = "", | ||
| 39 | [UCSI_ACK_EVENT] = "event", | ||
| 40 | [UCSI_ACK_CMD] = "command", | ||
| 41 | }; | ||
| 42 | |||
| 43 | static inline const char *ucsi_ack_str(u8 ack) | ||
| 44 | { | ||
| 45 | return ucsi_ack_strs[(ack >= ARRAY_SIZE(ucsi_ack_strs)) ? 0 : ack]; | ||
| 46 | } | ||
| 47 | |||
| 48 | static inline const char *ucsi_cci_str(u32 cci) | ||
| 49 | { | ||
| 50 | if (cci & GENMASK(7, 0)) { | ||
| 51 | if (cci & BIT(29)) | ||
| 52 | return "Event pending (ACK completed)"; | ||
| 53 | if (cci & BIT(31)) | ||
| 54 | return "Event pending (command completed)"; | ||
| 55 | return "Connector Change"; | ||
| 56 | } | ||
| 57 | if (cci & BIT(29)) | ||
| 58 | return "ACK completed"; | ||
| 59 | if (cci & BIT(31)) | ||
| 60 | return "Command completed"; | ||
| 61 | |||
| 62 | return ""; | ||
| 63 | } | ||
| 64 | |||
| 65 | #endif /* __UCSI_DEBUG_H */ | ||
| @@ -1,3 +1,62 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-2.0 | 1 | // SPDX-License-Identifier: GPL-2.0 |
| 2 | #define CREATE_TRACE_POINTS | 2 | #define CREATE_TRACE_POINTS |
| 3 | #include "ucsi.h" | ||
| 3 | #include "trace.h" | 4 | #include "trace.h" |
| 5 | |||
| 6 | static const char * const ucsi_cmd_strs[] = { | ||
| 7 | [0] = "Unknown command", | ||
| 8 | [UCSI_PPM_RESET] = "PPM_RESET", | ||
| 9 | [UCSI_CANCEL] = "CANCEL", | ||
| 10 | [UCSI_CONNECTOR_RESET] = "CONNECTOR_RESET", | ||
| 11 | [UCSI_ACK_CC_CI] = "ACK_CC_CI", | ||
| 12 | [UCSI_SET_NOTIFICATION_ENABLE] = "SET_NOTIFICATION_ENABLE", | ||
| 13 | [UCSI_GET_CAPABILITY] = "GET_CAPABILITY", | ||
| 14 | [UCSI_GET_CONNECTOR_CAPABILITY] = "GET_CONNECTOR_CAPABILITY", | ||
| 15 | [UCSI_SET_UOM] = "SET_UOM", | ||
| 16 | [UCSI_SET_UOR] = "SET_UOR", | ||
| 17 | [UCSI_SET_PDM] = "SET_PDM", | ||
| 18 | [UCSI_SET_PDR] = "SET_PDR", | ||
| 19 | [UCSI_GET_ALTERNATE_MODES] = "GET_ALTERNATE_MODES", | ||
| 20 | [UCSI_GET_CAM_SUPPORTED] = "GET_CAM_SUPPORTED", | ||
| 21 | [UCSI_GET_CURRENT_CAM] = "GET_CURRENT_CAM", | ||
| 22 | [UCSI_SET_NEW_CAM] = "SET_NEW_CAM", | ||
| 23 | [UCSI_GET_PDOS] = "GET_PDOS", | ||
| 24 | [UCSI_GET_CABLE_PROPERTY] = "GET_CABLE_PROPERTY", | ||
| 25 | [UCSI_GET_CONNECTOR_STATUS] = "GET_CONNECTOR_STATUS", | ||
| 26 | [UCSI_GET_ERROR_STATUS] = "GET_ERROR_STATUS", | ||
| 27 | }; | ||
| 28 | |||
| 29 | const char *ucsi_cmd_str(u64 raw_cmd) | ||
| 30 | { | ||
| 31 | u8 cmd = raw_cmd & GENMASK(7, 0); | ||
| 32 | |||
| 33 | return ucsi_cmd_strs[(cmd >= ARRAY_SIZE(ucsi_cmd_strs)) ? 0 : cmd]; | ||
| 34 | } | ||
| 35 | |||
| 36 | static const char * const ucsi_ack_strs[] = { | ||
| 37 | [0] = "", | ||
| 38 | [UCSI_ACK_EVENT] = "event", | ||
| 39 | [UCSI_ACK_CMD] = "command", | ||
| 40 | }; | ||
| 41 | |||
| 42 | const char *ucsi_ack_str(u8 ack) | ||
| 43 | { | ||
| 44 | return ucsi_ack_strs[(ack >= ARRAY_SIZE(ucsi_ack_strs)) ? 0 : ack]; | ||
| 45 | } | ||
| 46 | |||
| 47 | const char *ucsi_cci_str(u32 cci) | ||
| 48 | { | ||
| 49 | if (cci & GENMASK(7, 0)) { | ||
| 50 | if (cci & BIT(29)) | ||
| 51 | return "Event pending (ACK completed)"; | ||
| 52 | if (cci & BIT(31)) | ||
| 53 | return "Event pending (command completed)"; | ||
| 54 | return "Connector Change"; | ||
| 55 | } | ||
| 56 | if (cci & BIT(29)) | ||
| 57 | return "ACK completed"; | ||
| 58 | if (cci & BIT(31)) | ||
| 59 | return "Command completed"; | ||
| 60 | |||
| 61 | return ""; | ||
| 62 | } | ||
| @@ -7,8 +7,11 @@ · 6 unmodified lines | |||
| 7 | #define __UCSI_TRACE_H | 7 | #define __UCSI_TRACE_H |
| 8 | 8 | ||
| 9 | #include <linux/tracepoint.h> | 9 | #include <linux/tracepoint.h> |
| 10 | #include "ucsi.h" | 10 | |
| 11 | #include "debug.h" | 11 | const char *ucsi_cmd_str(u64 raw_cmd); |
| 12 | const char *ucsi_ack_str(u8 ack); | ||
| 13 | const char *ucsi_cci_str(u32 cci); | ||
| 14 | const char *ucsi_recipient_str(u8 recipient); | ||
| 12 | 15 | ||
| 13 | DECLARE_EVENT_CLASS(ucsi_log_ack, | 16 | DECLARE_EVENT_CLASS(ucsi_log_ack, |
| 14 | TP_PROTO(u8 ack), | 17 | TP_PROTO(u8 ack), |
| @@ -1,3 +1,5 @@ | |||
| 1 | # SPDX-License-Identifier: GPL-2.0 | ||
| 2 | |||
| 1 | config USBIP_CORE | 3 | config USBIP_CORE |
| 2 | tristate "USB/IP support" | 4 | tristate "USB/IP support" |
| 3 | depends on NET | 5 | depends on NET |
| @@ -702,8 +702,10 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flag · 701 unmodified lines | |||
| 702 | } | 702 | } |
| 703 | vdev = &vhci_hcd->vdev[portnum-1]; | 703 | vdev = &vhci_hcd->vdev[portnum-1]; |
| 704 | 704 | ||
| 705 | /* patch to usb_sg_init() is in 2.5.60 */ | 705 | if (!urb->transfer_buffer && urb->transfer_buffer_length) { |
| 706 | BUG_ON(!urb->transfer_buffer && urb->transfer_buffer_length); | 706 | dev_dbg(dev, "Null URB transfer buffer\n"); |
| 707 | return -EINVAL; | ||
| 708 | } | ||
| 707 | 709 | ||
| 708 | spin_lock_irqsave(&vhci->lock, flags); | 710 | spin_lock_irqsave(&vhci->lock, flags); |
| 709 | 711 | ||
| @@ -297,7 +297,8 @@ static void vep_free_request(struct usb_ep *_ep, struct usb_request *_req) · 296 unmodified lines | |||
| 297 | { | 297 | { |
| 298 | struct vrequest *req; | 298 | struct vrequest *req; |
| 299 | 299 | ||
| 300 | if (WARN_ON(!_ep || !_req)) | 300 | /* ep is always valid here - see usb_ep_free_request() */ |
| 301 | if (!_req) | ||
| 301 | return; | 302 | return; |
| 302 | 303 | ||
| 303 | req = to_vrequest(_req); | 304 | req = to_vrequest(_req); |
| @@ -1,3 +1,4 @@ | |||
| 1 | # SPDX-License-Identifier: GPL-2.0 | ||
| 1 | # | 2 | # |
| 2 | # Wireless USB Core configuration | 3 | # Wireless USB Core configuration |
| 3 | # | 4 | # |
| @@ -302,10 +302,8 @@ static ssize_t cbaf_wusb_chid_show(struct device *dev, · 301 unmodified lines | |||
| 302 | { | 302 | { |
| 303 | struct usb_interface *iface = to_usb_interface(dev); | 303 | struct usb_interface *iface = to_usb_interface(dev); |
| 304 | struct cbaf *cbaf = usb_get_intfdata(iface); | 304 | struct cbaf *cbaf = usb_get_intfdata(iface); |
| 305 | char pr_chid[WUSB_CKHDID_STRSIZE]; | ||
| 306 | 305 | ||
| 307 | ckhdid_printf(pr_chid, sizeof(pr_chid), &cbaf->chid); | 306 | return sprintf(buf, "%16ph\n", cbaf->chid.data); |
| 308 | return scnprintf(buf, PAGE_SIZE, "%s\n", pr_chid); | ||
| 309 | } | 307 | } |
| 310 | 308 | ||
| 311 | static ssize_t cbaf_wusb_chid_store(struct device *dev, | 309 | static ssize_t cbaf_wusb_chid_store(struct device *dev, |
| @@ -415,10 +413,8 @@ static ssize_t cbaf_wusb_cdid_show(struct device *dev, · 103 unmodified lines | |||
| 415 | { | 413 | { |
| 416 | struct usb_interface *iface = to_usb_interface(dev); | 414 | struct usb_interface *iface = to_usb_interface(dev); |
| 417 | struct cbaf *cbaf = usb_get_intfdata(iface); | 415 | struct cbaf *cbaf = usb_get_intfdata(iface); |
| 418 | char pr_cdid[WUSB_CKHDID_STRSIZE]; | ||
| 419 | 416 | ||
| 420 | ckhdid_printf(pr_cdid, sizeof(pr_cdid), &cbaf->cdid); | 417 | return sprintf(buf, "%16ph\n", cbaf->cdid.data); |
| 421 | return scnprintf(buf, PAGE_SIZE, "%s\n", pr_cdid); | ||
| 422 | } | 418 | } |
| 423 | 419 | ||
| 424 | static ssize_t cbaf_wusb_cdid_store(struct device *dev, | 420 | static ssize_t cbaf_wusb_cdid_store(struct device *dev, |
| @@ -503,7 +499,6 @@ static int cbaf_cc_upload(struct cbaf *cbaf) · 78 unmodified lines | |||
| 503 | int result; | 499 | int result; |
| 504 | struct device *dev = &cbaf->usb_iface->dev; | 500 | struct device *dev = &cbaf->usb_iface->dev; |
| 505 | struct wusb_cbaf_cc_data *ccd; | 501 | struct wusb_cbaf_cc_data *ccd; |
| 506 | char pr_cdid[WUSB_CKHDID_STRSIZE]; | ||
| 507 | 502 | ||
| 508 | ccd = cbaf->buffer; | 503 | ccd = cbaf->buffer; |
| 509 | *ccd = cbaf_cc_data_defaults; | 504 | *ccd = cbaf_cc_data_defaults; |
| @@ -513,10 +508,8 @@ static int cbaf_cc_upload(struct cbaf *cbaf) · 3 unmodified lines | |||
| 513 | ccd->BandGroups = cpu_to_le16(cbaf->host_band_groups); | 508 | ccd->BandGroups = cpu_to_le16(cbaf->host_band_groups); |
| 514 | 509 | ||
| 515 | dev_dbg(dev, "Trying to upload CC:\n"); | 510 | dev_dbg(dev, "Trying to upload CC:\n"); |
| 516 | ckhdid_printf(pr_cdid, sizeof(pr_cdid), &ccd->CHID); | 511 | dev_dbg(dev, " CHID %16ph\n", ccd->CHID.data); |
| 517 | dev_dbg(dev, " CHID %s\n", pr_cdid); | 512 | dev_dbg(dev, " CDID %16ph\n", ccd->CDID.data); |
| 518 | ckhdid_printf(pr_cdid, sizeof(pr_cdid), &ccd->CDID); | ||
| 519 | dev_dbg(dev, " CDID %s\n", pr_cdid); | ||
| 520 | dev_dbg(dev, " Bandgroups 0x%04x\n", cbaf->host_band_groups); | 513 | dev_dbg(dev, " Bandgroups 0x%04x\n", cbaf->host_band_groups); |
| 521 | 514 | ||
| 522 | result = usb_control_msg( | 515 | result = usb_control_msg( |
| @@ -50,10 +50,9 @@ static ssize_t wusb_cdid_show(struct device *dev, · 49 unmodified lines | |||
| 50 | wusb_dev = wusb_dev_get_by_usb_dev(to_usb_device(dev)); | 50 | wusb_dev = wusb_dev_get_by_usb_dev(to_usb_device(dev)); |
| 51 | if (wusb_dev == NULL) | 51 | if (wusb_dev == NULL) |
| 52 | return -ENODEV; | 52 | return -ENODEV; |
| 53 | result = ckhdid_printf(buf, PAGE_SIZE, &wusb_dev->cdid); | 53 | result = sprintf(buf, "%16ph\n", wusb_dev->cdid.data); |
| 54 | strcat(buf, "\n"); | ||
| 55 | wusb_dev_put(wusb_dev); | 54 | wusb_dev_put(wusb_dev); |
| 56 | return result + 1; | 55 | return result; |
| 57 | } | 56 | } |
| 58 | static DEVICE_ATTR_RO(wusb_cdid); | 57 | static DEVICE_ATTR_RO(wusb_cdid); |
| 59 | 58 | ||
| @@ -532,7 +532,7 @@ static void wusbhc_handle_dn_connect(struct wusbhc *wusbhc, · 531 unmodified lines | |||
| 532 | } | 532 | } |
| 533 | 533 | ||
| 534 | dnc = container_of(dn_hdr, struct wusb_dn_connect, hdr); | 534 | dnc = container_of(dn_hdr, struct wusb_dn_connect, hdr); |
| 535 | ckhdid_printf(pr_cdid, sizeof(pr_cdid), &dnc->CDID); | 535 | sprintf(pr_cdid, "%16ph", dnc->CDID.data); |
| 536 | dev_info(dev, "DN CONNECT: device %s @ %x (%s) wants to %s\n", | 536 | dev_info(dev, "DN CONNECT: device %s @ %x (%s) wants to %s\n", |
| 537 | pr_cdid, | 537 | pr_cdid, |
| 538 | wusb_dn_connect_prev_dev_addr(dnc), | 538 | wusb_dn_connect_prev_dev_addr(dnc), |
| @@ -662,9 +662,9 @@ static void __wa_setup_isoc_packet_descr( · 661 unmodified lines | |||
| 662 | 662 | ||
| 663 | /* populate isoc packet descriptor. */ | 663 | /* populate isoc packet descriptor. */ |
| 664 | packet_desc->bPacketType = WA_XFER_ISO_PACKET_INFO; | 664 | packet_desc->bPacketType = WA_XFER_ISO_PACKET_INFO; |
| 665 | packet_desc->wLength = cpu_to_le16(sizeof(*packet_desc) + | 665 | packet_desc->wLength = cpu_to_le16(struct_size(packet_desc, |
| 666 | (sizeof(packet_desc->PacketLength[0]) * | 666 | PacketLength, |
| 667 | seg->isoc_frame_count)); | 667 | seg->isoc_frame_count)); |
| 668 | for (frame_index = 0; frame_index < seg->isoc_frame_count; | 668 | for (frame_index = 0; frame_index < seg->isoc_frame_count; |
| 669 | ++frame_index) { | 669 | ++frame_index) { |
| 670 | int offset_index = frame_index + seg->isoc_frame_offset; | 670 | int offset_index = frame_index + seg->isoc_frame_offset; |
| @@ -2438,7 +2438,7 @@ static int wa_process_iso_packet_status(struct wahc *wa, struct urb *urb) · 1767 unmodified lines | |||
| 2438 | struct wa_rpipe *rpipe; | 2438 | struct wa_rpipe *rpipe; |
| 2439 | unsigned done = 0, dti_busy = 0, data_frame_count = 0, seg_index; | 2439 | unsigned done = 0, dti_busy = 0, data_frame_count = 0, seg_index; |
| 2440 | unsigned first_frame_index = 0, rpipe_ready = 0; | 2440 | unsigned first_frame_index = 0, rpipe_ready = 0; |
| 2441 | int expected_size; | 2441 | size_t expected_size; |
| 2442 | 2442 | ||
| 2443 | /* We have a xfer result buffer; check it */ | 2443 | /* We have a xfer result buffer; check it */ |
| 2444 | dev_dbg(dev, "DTI: isoc packet status %d bytes at %p\n", | 2444 | dev_dbg(dev, "DTI: isoc packet status %d bytes at %p\n", |
| @@ -2460,11 +2460,10 @@ static int wa_process_iso_packet_status(struct wahc *wa, struct urb *urb) · 15 unmodified lines | |||
| 2460 | goto error_bad_seg; | 2460 | goto error_bad_seg; |
| 2461 | seg = xfer->seg[wa->dti_isoc_xfer_seg]; | 2461 | seg = xfer->seg[wa->dti_isoc_xfer_seg]; |
| 2462 | rpipe = xfer->ep->hcpriv; | 2462 | rpipe = xfer->ep->hcpriv; |
| 2463 | expected_size = sizeof(*packet_status) + | 2463 | expected_size = struct_size(packet_status, PacketStatus, |
| 2464 | (sizeof(packet_status->PacketStatus[0]) * | 2464 | seg->isoc_frame_count); |
| 2465 | seg->isoc_frame_count); | ||
| 2466 | if (urb->actual_length != expected_size) { | 2465 | if (urb->actual_length != expected_size) { |
| 2467 | dev_err(dev, "DTI Error: isoc packet status--bad urb length (%d bytes vs %d needed)\n", | 2466 | dev_err(dev, "DTI Error: isoc packet status--bad urb length (%d bytes vs %zu needed)\n", |
| 2468 | urb->actual_length, expected_size); | 2467 | urb->actual_length, expected_size); |
| 2469 | goto error_bad_seg; | 2468 | goto error_bad_seg; |
| 2470 | } | 2469 | } |
| @@ -80,17 +80,13 @@ static ssize_t wusb_chid_show(struct device *dev, · 79 unmodified lines | |||
| 80 | { | 80 | { |
| 81 | struct wusbhc *wusbhc = usbhc_dev_to_wusbhc(dev); | 81 | struct wusbhc *wusbhc = usbhc_dev_to_wusbhc(dev); |
| 82 | const struct wusb_ckhdid *chid; | 82 | const struct wusb_ckhdid *chid; |
| 83 | ssize_t result = 0; | ||
| 84 | 83 | ||
| 85 | if (wusbhc->wuie_host_info != NULL) | 84 | if (wusbhc->wuie_host_info != NULL) |
| 86 | chid = &wusbhc->wuie_host_info->CHID; | 85 | chid = &wusbhc->wuie_host_info->CHID; |
| 87 | else | 86 | else |
| 88 | chid = &wusb_ckhdid_zero; | 87 | chid = &wusb_ckhdid_zero; |
| 89 | 88 | ||
| 90 | result += ckhdid_printf(buf, PAGE_SIZE, chid); | 89 | return sprintf(buf, "%16ph\n", chid->data); |
| 91 | result += sprintf(buf + result, "\n"); | ||
| 92 | |||
| 93 | return result; | ||
| 94 | } | 90 | } |
| 95 | 91 | ||
| 96 | /* | 92 | /* |
| @@ -125,9 +125,8 @@ static struct uwb_ie_drp *uwb_drp_ie_alloc(void) · 124 unmodified lines | |||
| 125 | { | 125 | { |
| 126 | struct uwb_ie_drp *drp_ie; | 126 | struct uwb_ie_drp *drp_ie; |
| 127 | 127 | ||
| 128 | drp_ie = kzalloc(sizeof(struct uwb_ie_drp) + | 128 | drp_ie = kzalloc(struct_size(drp_ie, allocs, UWB_NUM_ZONES), |
| 129 | UWB_NUM_ZONES * sizeof(struct uwb_drp_alloc), | 129 | GFP_KERNEL); |
| 130 | GFP_KERNEL); | ||
| 131 | if (drp_ie) | 130 | if (drp_ie) |
| 132 | drp_ie->hdr.element_id = UWB_IE_DRP; | 131 | drp_ie->hdr.element_id = UWB_IE_DRP; |
| 133 | return drp_ie; | 132 | return drp_ie; |
| @@ -758,11 +758,17 @@ struct device_dma_parameters { · 757 unmodified lines | |||
| 758 | 758 | ||
| 759 | /** | 759 | /** |
| 760 | * struct device_connection - Device Connection Descriptor | 760 | * struct device_connection - Device Connection Descriptor |
| 761 | * @fwnode: The device node of the connected device | ||
| 761 | * @endpoint: The names of the two devices connected together | 762 | * @endpoint: The names of the two devices connected together |
| 762 | * @id: Unique identifier for the connection | 763 | * @id: Unique identifier for the connection |
| 763 | * @list: List head, private, for internal use only | 764 | * @list: List head, private, for internal use only |
| 765 | * | ||
| 766 | * NOTE: @fwnode is not used together with @endpoint. @fwnode is used when | ||
| 767 | * platform firmware defines the connection. When the connection is registered | ||
| 768 | * with device_connection_add() @endpoint is used instead. | ||
| 764 | */ | 769 | */ |
| 765 | struct device_connection { | 770 | struct device_connection { |
| 771 | struct fwnode_handle *fwnode; | ||
| 766 | const char *endpoint[2]; | 772 | const char *endpoint[2]; |
| 767 | const char *id; | 773 | const char *id; |
| 768 | struct list_head list; | 774 | struct list_head list; |
| @@ -98,10 +98,11 @@ struct fsl_usb2_platform_data { · 97 unmodified lines | |||
| 98 | 98 | ||
| 99 | unsigned suspended:1; | 99 | unsigned suspended:1; |
| 100 | unsigned already_suspended:1; | 100 | unsigned already_suspended:1; |
| 101 | unsigned has_fsl_erratum_a007792:1; | 101 | unsigned has_fsl_erratum_a007792:1; |
| 102 | unsigned has_fsl_erratum_a005275:1; | 102 | unsigned has_fsl_erratum_14:1; |
| 103 | unsigned has_fsl_erratum_a005275:1; | ||
| 103 | unsigned has_fsl_erratum_a005697:1; | 104 | unsigned has_fsl_erratum_a005697:1; |
| 104 | unsigned check_phy_clk_valid:1; | 105 | unsigned check_phy_clk_valid:1; |
| 105 | 106 | ||
| 106 | /* register save area for suspend/resume */ | 107 | /* register save area for suspend/resume */ |
| 107 | u32 pm_command; | 108 | u32 pm_command; |
| @@ -6,8 +6,6 @@ · 5 unmodified lines | |||
| 6 | #ifndef __PHY_MIPI_DPHY_H_ | 6 | #ifndef __PHY_MIPI_DPHY_H_ |
| 7 | #define __PHY_MIPI_DPHY_H_ | 7 | #define __PHY_MIPI_DPHY_H_ |
| 8 | 8 | ||
| 9 | #include <video/videomode.h> | ||
| 10 | |||
| 11 | /** | 9 | /** |
| 12 | * struct phy_configure_opts_mipi_dphy - MIPI D-PHY configuration set | 10 | * struct phy_configure_opts_mipi_dphy - MIPI D-PHY configuration set |
| 13 | * | 11 | * |
| @@ -192,10 +190,10 @@ struct phy_configure_opts_mipi_dphy { · 178 unmodified lines | |||
| 192 | /** | 190 | /** |
| 193 | * @init: | 191 | * @init: |
| 194 | * | 192 | * |
| 195 | * Time, in picoseconds for the initialization period to | 193 | * Time, in microseconds for the initialization period to |
| 196 | * complete. | 194 | * complete. |
| 197 | * | 195 | * |
| 198 | * Minimum value: 100000000 ps | 196 | * Minimum value: 100 us |
| 199 | */ | 197 | */ |
| 200 | unsigned int init; | 198 | unsigned int init; |
| 201 | 199 | ||
| @@ -246,11 +244,11 @@ struct phy_configure_opts_mipi_dphy { · 44 unmodified lines | |||
| 246 | /** | 244 | /** |
| 247 | * @wakeup: | 245 | * @wakeup: |
| 248 | * | 246 | * |
| 249 | * Time, in picoseconds, that a transmitter drives a Mark-1 | 247 | * Time, in microseconds, that a transmitter drives a Mark-1 |
| 250 | * state prior to a Stop state in order to initiate an exit | 248 | * state prior to a Stop state in order to initiate an exit |
| 251 | * from ULPS. | 249 | * from ULPS. |
| 252 | * | 250 | * |
| 253 | * Minimum value: 1000000000 ps | 251 | * Minimum value: 1000 us |
| 254 | */ | 252 | */ |
| 255 | unsigned int wakeup; | 253 | unsigned int wakeup; |
| 256 | 254 | ||
| @@ -271,7 +269,8 @@ struct phy_configure_opts_mipi_dphy { · 14 unmodified lines | |||
| 271 | /** | 269 | /** |
| 272 | * @lanes: | 270 | * @lanes: |
| 273 | * | 271 | * |
| 274 | * Number of active data lanes used for the transmissions. | 272 | * Number of active, consecutive, data lanes, starting from |
| 273 | * lane 0, used for the transmissions. | ||
| 275 | */ | 274 | */ |
| 276 | unsigned char lanes; | 275 | unsigned char lanes; |
| 277 | }; | 276 | }; |
| @@ -72,6 +72,12 @@ struct giveback_urb_bh { · 71 unmodified lines | |||
| 72 | struct usb_host_endpoint *completing_ep; | 72 | struct usb_host_endpoint *completing_ep; |
| 73 | }; | 73 | }; |
| 74 | 74 | ||
| 75 | enum usb_dev_authorize_policy { | ||
| 76 | USB_DEVICE_AUTHORIZE_NONE = 0, | ||
| 77 | USB_DEVICE_AUTHORIZE_ALL = 1, | ||
| 78 | USB_DEVICE_AUTHORIZE_INTERNAL = 2, | ||
| 79 | }; | ||
| 80 | |||
| 75 | struct usb_hcd { | 81 | struct usb_hcd { |
| 76 | 82 | ||
| 77 | /* | 83 | /* |
| @@ -117,7 +123,6 @@ struct usb_hcd { · 39 unmodified lines | |||
| 117 | #define HCD_FLAG_RH_RUNNING 5 /* root hub is running? */ | 123 | #define HCD_FLAG_RH_RUNNING 5 /* root hub is running? */ |
| 118 | #define HCD_FLAG_DEAD 6 /* controller has died? */ | 124 | #define HCD_FLAG_DEAD 6 /* controller has died? */ |
| 119 | #define HCD_FLAG_INTF_AUTHORIZED 7 /* authorize interfaces? */ | 125 | #define HCD_FLAG_INTF_AUTHORIZED 7 /* authorize interfaces? */ |
| 120 | #define HCD_FLAG_DEV_AUTHORIZED 8 /* authorize devices? */ | ||
| 121 | 126 | ||
| 122 | /* The flags can be tested using these macros; they are likely to | 127 | /* The flags can be tested using these macros; they are likely to |
| 123 | * be slightly faster than test_bit(). | 128 | * be slightly faster than test_bit(). |
| @@ -142,8 +147,7 @@ struct usb_hcd { · 18 unmodified lines | |||
| 142 | * or they require explicit user space authorization; this bit is | 147 | * or they require explicit user space authorization; this bit is |
| 143 | * settable through /sys/class/usb_host/X/authorized_default | 148 | * settable through /sys/class/usb_host/X/authorized_default |
| 144 | */ | 149 | */ |
| 145 | #define HCD_DEV_AUTHORIZED(hcd) \ | 150 | enum usb_dev_authorize_policy dev_policy; |
| 146 | ((hcd)->flags & (1U << HCD_FLAG_DEV_AUTHORIZED)) | ||
| 147 | 151 | ||
| 148 | /* Flags that get set only during HCD registration or removal. */ | 152 | /* Flags that get set only during HCD registration or removal. */ |
| 149 | unsigned rh_registered:1;/* is root hub registered? */ | 153 | unsigned rh_registered:1;/* is root hub registered? */ |
| @@ -18,6 +18,7 @@ typedef enum usb_role (*usb_role_switch_get_t)(struct device *dev); · 17 unmodified lines | |||
| 18 | 18 | ||
| 19 | /** | 19 | /** |
| 20 | * struct usb_role_switch_desc - USB Role Switch Descriptor | 20 | * struct usb_role_switch_desc - USB Role Switch Descriptor |
| 21 | * @fwnode: The device node to be associated with the role switch | ||
| 21 | * @usb2_port: Optional reference to the host controller port device (USB2) | 22 | * @usb2_port: Optional reference to the host controller port device (USB2) |
| 22 | * @usb3_port: Optional reference to the host controller port device (USB3) | 23 | * @usb3_port: Optional reference to the host controller port device (USB3) |
| 23 | * @udc: Optional reference to the peripheral controller device | 24 | * @udc: Optional reference to the peripheral controller device |
| @@ -32,6 +33,7 @@ typedef enum usb_role (*usb_role_switch_get_t)(struct device *dev); · 8 unmodified lines | |||
| 32 | * usb_role_switch_register() before registering the switch. | 33 | * usb_role_switch_register() before registering the switch. |
| 33 | */ | 34 | */ |
| 34 | struct usb_role_switch_desc { | 35 | struct usb_role_switch_desc { |
| 36 | struct fwnode_handle *fwnode; | ||
| 35 | struct device *usb2_port; | 37 | struct device *usb2_port; |
| 36 | struct device *usb3_port; | 38 | struct device *usb3_port; |
| 37 | struct device *udc; | 39 | struct device *udc; |
| @@ -159,12 +159,6 @@ struct tcpm_port; · 158 unmodified lines | |||
| 159 | struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc); | 159 | struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc); |
| 160 | void tcpm_unregister_port(struct tcpm_port *port); | 160 | void tcpm_unregister_port(struct tcpm_port *port); |
| 161 | 161 | ||
| 162 | int tcpm_update_source_capabilities(struct tcpm_port *port, const u32 *pdo, | ||
| 163 | unsigned int nr_pdo); | ||
| 164 | int tcpm_update_sink_capabilities(struct tcpm_port *port, const u32 *pdo, | ||
| 165 | unsigned int nr_pdo, | ||
| 166 | unsigned int operating_snk_mw); | ||
| 167 | |||
| 168 | void tcpm_vbus_change(struct tcpm_port *port); | 162 | void tcpm_vbus_change(struct tcpm_port *port); |
| 169 | void tcpm_cc_change(struct tcpm_port *port); | 163 | void tcpm_cc_change(struct tcpm_port *port); |
| 170 | void tcpm_pd_receive(struct tcpm_port *port, | 164 | void tcpm_pd_receive(struct tcpm_port *port, |
| @@ -92,4 +92,8 @@ enum { · 91 unmodified lines | |||
| 92 | #define DP_CONF_PIN_ASSIGNEMENT_SHIFT 8 | 92 | #define DP_CONF_PIN_ASSIGNEMENT_SHIFT 8 |
| 93 | #define DP_CONF_PIN_ASSIGNEMENT_MASK GENMASK(15, 8) | 93 | #define DP_CONF_PIN_ASSIGNEMENT_MASK GENMASK(15, 8) |
| 94 | 94 | ||
| 95 | /* Helper for setting/getting the pin assignement value to the configuration */ | ||
| 96 | #define DP_CONF_SET_PIN_ASSIGN(_a_) ((_a_) << 8) | ||
| 97 | #define DP_CONF_GET_PIN_ASSIGN(_conf_) (((_conf_) & GENMASK(15, 8)) >> 8) | ||
| 98 | |||
| 95 | #endif /* __USB_TYPEC_DP_H */ | 99 | #endif /* __USB_TYPEC_DP_H */ |
| @@ -47,7 +47,8 @@ void typec_switch_put(struct typec_switch *sw); · 46 unmodified lines | |||
| 47 | int typec_switch_register(struct typec_switch *sw); | 47 | int typec_switch_register(struct typec_switch *sw); |
| 48 | void typec_switch_unregister(struct typec_switch *sw); | 48 | void typec_switch_unregister(struct typec_switch *sw); |
| 49 | 49 | ||
| 50 | struct typec_mux *typec_mux_get(struct device *dev, const char *name); | 50 | struct typec_mux * |
| 51 | typec_mux_get(struct device *dev, const struct typec_altmode_desc *desc); | ||
| 51 | void typec_mux_put(struct typec_mux *mux); | 52 | void typec_mux_put(struct typec_mux *mux); |
| 52 | int typec_mux_register(struct typec_mux *mux); | 53 | int typec_mux_register(struct typec_mux *mux); |
| 53 | void typec_mux_unregister(struct typec_mux *mux); | 54 | void typec_mux_unregister(struct typec_mux *mux); |
| @@ -236,22 +236,6 @@ enum { · 235 unmodified lines | |||
| 236 | WUSB_TRUST_TIMEOUT_MS = 4000, /* [WUSB] section 4.15.1 */ | 236 | WUSB_TRUST_TIMEOUT_MS = 4000, /* [WUSB] section 4.15.1 */ |
| 237 | }; | 237 | }; |
| 238 | 238 | ||
| 239 | static inline size_t ckhdid_printf(char *pr_ckhdid, size_t size, | ||
| 240 | const struct wusb_ckhdid *ckhdid) | ||
| 241 | { | ||
| 242 | return scnprintf(pr_ckhdid, size, | ||
| 243 | "%02hx %02hx %02hx %02hx %02hx %02hx %02hx %02hx " | ||
| 244 | "%02hx %02hx %02hx %02hx %02hx %02hx %02hx %02hx", | ||
| 245 | ckhdid->data[0], ckhdid->data[1], | ||
| 246 | ckhdid->data[2], ckhdid->data[3], | ||
| 247 | ckhdid->data[4], ckhdid->data[5], | ||
| 248 | ckhdid->data[6], ckhdid->data[7], | ||
| 249 | ckhdid->data[8], ckhdid->data[9], | ||
| 250 | ckhdid->data[10], ckhdid->data[11], | ||
| 251 | ckhdid->data[12], ckhdid->data[13], | ||
| 252 | ckhdid->data[14], ckhdid->data[15]); | ||
| 253 | } | ||
| 254 | |||
| 255 | /* | 239 | /* |
| 256 | * WUSB Crypto stuff (WUSB1.0[6]) | 240 | * WUSB Crypto stuff (WUSB1.0[6]) |
| 257 | */ | 241 | */ |