summaryrefslogtreecommitdiff
path: root/drivers/usb
AgeCommit message (Collapse)AuthorFilesLines
2020-03-16usb: chipidea: udc: using structure ci_hdrc device for runtime PMPeter Chen1-8/+5
At current code, it doesn't maintain ci->gadget.dev's runtime PM status well, eg, during the PM operation, the PM counter for ci->gadget.dev doesn't be changed accordingly. In this commit, we use ci_hdrc device instead of ci->gadget.dev for runtime PM APIs at udc driver, in the way, we handle runtime PM APIs using unify device structure between core and udc driver. Reviewed-by: Jun Li <jun.li@nxp.com> Signed-off-by: Peter Chen <peter.chen@nxp.com>
2020-03-15usb: gadget: aspeed: add ast2600 vhub supportTao Ren2-2/+5
Add AST2600 support in aspeed-vhub driver. There are 3 major differences between AST2500 and AST2600 vhub: - AST2600 supports 7 downstream ports while AST2500 supports 5. - AST2600 supports 21 generic endpoints while AST2500 supports 15. - EP0 data buffer's 8-byte DMA alignment restriction is removed from AST2600. Signed-off-by: Tao Ren <rentao.bupt@gmail.com> Reviewed-by: Andrew Jeffery <andrew@aj.id.au> Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Felipe Balbi <balbi@kernel.org>
2020-03-15usb: gadget: aspeed: read vhub properties from device treeTao Ren5-57/+88
The patch introduces 2 DT properties ("aspeed,vhub-downstream-ports" and "aspeed,vhub-generic-endpoints") which replaces hardcoded port/endpoint number. It is to make it more convenient to add support for newer vhub revisions with different number of ports and endpoints. Signed-off-by: Tao Ren <rentao.bupt@gmail.com> Reviewed-by: Joel Stanley <joel@jms.id.au> Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Felipe Balbi <balbi@kernel.org>
2020-03-15usb: gadget: aspeed: support per-vhub usb descriptorsTao Ren2-12/+46
This patch store vhub's standard usb descriptors in struct "ast_vhub" so it's more convenient to customize descriptors and potentially support multiple vhub instances in the future. Signed-off-by: Tao Ren <rentao.bupt@gmail.com> Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Felipe Balbi <balbi@kernel.org>
2020-03-15usb: gadget: f_phonet: Replace zero-length array with flexible-array memberGustavo A. R. Silva1-1/+1
The current codebase makes use of the zero-length array language extension to the C90 standard, but the preferred mechanism to declare variable-length types such as these ones is a flexible array member[1][2], introduced in C99: struct foo { int stuff; struct boo array[]; }; By making use of the mechanism above, we will get a compiler warning in case the flexible array does not occur last in the structure, which will help us prevent some kind of undefined behavior bugs from being inadvertenly introduced[3] to the codebase from now on. This issue was found with the help of Coccinelle. [1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html [2] https://github.com/KSPP/linux/issues/21 [3] commit 76497732932f ("cxgb3/l2t: Fix undefined behaviour") Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com> Signed-off-by: Felipe Balbi <balbi@kernel.org>
2020-03-15usb: gadget: composite: Inform controller driver of self-poweredThinh Nguyen1-0/+9
Different configuration/condition may draw different power. Inform the controller driver of the change so it can respond properly (e.g. GET_STATUS request). This fixes an issue with setting MaxPower from configfs. The composite driver doesn't check this value when setting self-powered. Cc: stable@vger.kernel.org Fixes: 88af8bbe4ef7 ("usb: gadget: the start of the configfs interface") Signed-off-by: Thinh Nguyen <thinhn@synopsys.com> Signed-off-by: Felipe Balbi <balbi@kernel.org>
2020-03-15usb: gadget: amd5536udc: fix spelling mistake "reserverd" -> "reserved"Alexandre Belloni1-1/+1
The variable is named reserved, the comment should say so. Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Felipe Balbi <balbi@kernel.org>
2020-03-15udc: s3c-hsudc: Silence warning about supplies during deferred probeMarek Szyprowski1-1/+2
Don't confuse user with meaningless warning about the failure in getting supplies in case of deferred probe. Reviewed-by: Krzysztof Kozlowski <krzk@kernel.org> Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com> Signed-off-by: Felipe Balbi <balbi@kernel.org>
2020-03-15usb: dwc2: Silence warning about supplies during deferred probeMarek Szyprowski1-1/+3
Don't confuse user with meaningless warning about the failure in getting supplies in case of deferred probe. Acked-by: Minas Harutyunyan <hminas@synopsys.com> Reviewed-by: Krzysztof Kozlowski <krzk@kernel.org> Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com> Signed-off-by: Felipe Balbi <balbi@kernel.org>
2020-03-15usb: gadget: add raw-gadget interfaceAndrey Konovalov3-0/+1090
USB Raw Gadget is a kernel module that provides a userspace interface for the USB Gadget subsystem. Essentially it allows to emulate USB devices from userspace. Enabled with CONFIG_USB_RAW_GADGET. Raw Gadget is currently a strictly debugging feature and shouldn't be used in production. Raw Gadget is similar to GadgetFS, but provides a more low-level and direct access to the USB Gadget layer for the userspace. The key differences are: 1. Every USB request is passed to the userspace to get a response, while GadgetFS responds to some USB requests internally based on the provided descriptors. However note, that the UDC driver might respond to some requests on its own and never forward them to the Gadget layer. 2. GadgetFS performs some sanity checks on the provided USB descriptors, while Raw Gadget allows you to provide arbitrary data as responses to USB requests. 3. Raw Gadget provides a way to select a UDC device/driver to bind to, while GadgetFS currently binds to the first available UDC. 4. Raw Gadget uses predictable endpoint names (handles) across different UDCs (as long as UDCs have enough endpoints of each required transfer type). 5. Raw Gadget has ioctl-based interface instead of a filesystem-based one. Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Andrey Konovalov <andreyknvl@google.com> Signed-off-by: Felipe Balbi <balbi@kernel.org>
2020-03-15usb: dwc2: Implement set_selfpowered()John Keeping1-1/+23
dwc2 always reports as self-powered in response to a device status request. Implement the set_selfpowered() operations so that the gadget can report as bus-powered when appropriate. This is modelled on the dwc3 implementation. Acked-by: Minas Harutyunyan <hminas@synopsys.com> Signed-off-by: John Keeping <john@metanate.com> Signed-off-by: Felipe Balbi <balbi@kernel.org>
2020-03-15usb: dwc3: qcom: Replace <linux/clk-provider.h> by <linux/of_clk.h>Geert Uytterhoeven1-1/+1
The DWC3 USB driver is not a clock provider, and just needs to call of_clk_get_parent_count(). Hence it can include <linux/of_clk.h> instead of <linux/clk-provider.h>. Reviewed-by: Stephen Boyd <sboyd@kernel.org> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Felipe Balbi <balbi@kernel.org>
2020-03-15usb: dwc3: core: don't do suspend for device mode if already suspendedLi Jun1-0/+2
If dwc->dev in device mode already runtime suspended, don't do it again for system suspend. Signed-off-by: Li Jun <jun.li@nxp.com> Signed-off-by: Felipe Balbi <balbi@kernel.org>
2020-03-15usb: dwc3: Rework resets initialization to be more flexibleJohn Stultz1-1/+1
The dwc3 core binding specifies one reset. However some variants of the hardware may have more. Previously this was handled by using the dwc3-of-simple glue driver, but that resulted in a proliferation of bindings for for every variant, when the only difference was the clocks and resets lists. So this patch reworks the reading of the resets to fetch all the resets specified in the dts together. This patch was recommended by Rob Herring <robh@kernel.org> as an alternative to creating multiple bindings for each variant of hardware. Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Rob Herring <robh+dt@kernel.org> Cc: Mark Rutland <mark.rutland@arm.com> CC: ShuFan Lee <shufan_lee@richtek.com> Cc: Heikki Krogerus <heikki.krogerus@linux.intel.com> Cc: Suzuki K Poulose <suzuki.poulose@arm.com> Cc: Chunfeng Yun <chunfeng.yun@mediatek.com> Cc: Yu Chen <chenyu56@huawei.com> Cc: Felipe Balbi <balbi@kernel.org> Cc: Hans de Goede <hdegoede@redhat.com> Cc: Andy Shevchenko <andy.shevchenko@gmail.com> Cc: Jun Li <lijun.kernel@gmail.com> Cc: Valentin Schneider <valentin.schneider@arm.com> Cc: Guillaume Gardet <Guillaume.Gardet@arm.com> Cc: Jack Pham <jackp@codeaurora.org> Cc: linux-usb@vger.kernel.org Cc: devicetree@vger.kernel.org Suggested-by: Rob Herring <robh@kernel.org> Signed-off-by: John Stultz <john.stultz@linaro.org> Signed-off-by: Felipe Balbi <balbi@kernel.org>
2020-03-15usb: dwc3: Rework clock initialization to be more flexibleJohn Stultz1-15/+5
The dwc3 core binding specifies three clocks: ref, bus_early, and suspend which are all controlled in the driver together. However some variants of the hardware my not have all three clks, or some may have more. Usually this was handled by using the dwc3-of-simple glue driver, but that resulted in a proliferation of bindings for for every variant, when the only difference was the clocks and resets lists. So this patch reworks the reading of the clks from the dts to use devm_clk_bulk_get_all() will will fetch all the clocks specified in the dts together. This patch was recommended by Rob Herring <robh@kernel.org> as an alternative to creating multiple bindings for each variant of hardware. Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Rob Herring <robh+dt@kernel.org> Cc: Mark Rutland <mark.rutland@arm.com> CC: ShuFan Lee <shufan_lee@richtek.com> Cc: Heikki Krogerus <heikki.krogerus@linux.intel.com> Cc: Suzuki K Poulose <suzuki.poulose@arm.com> Cc: Chunfeng Yun <chunfeng.yun@mediatek.com> Cc: Yu Chen <chenyu56@huawei.com> Cc: Felipe Balbi <balbi@kernel.org> Cc: Hans de Goede <hdegoede@redhat.com> Cc: Andy Shevchenko <andy.shevchenko@gmail.com> Cc: Jun Li <lijun.kernel@gmail.com> Cc: Valentin Schneider <valentin.schneider@arm.com> Cc: Guillaume Gardet <Guillaume.Gardet@arm.com> Cc: Jack Pham <jackp@codeaurora.org> Cc: linux-usb@vger.kernel.org Cc: devicetree@vger.kernel.org Suggested-by: Rob Herring <robh@kernel.org> Signed-off-by: John Stultz <john.stultz@linaro.org> Signed-off-by: Felipe Balbi <balbi@kernel.org>
2020-03-15usb: dwc3: Add support for role-switch-default-mode bindingJohn Stultz2-3/+25
Support the new role-switch-default-mode binding for configuring the default role the controller assumes as when the usb role is USB_ROLE_NONE This patch was split out from a larger patch originally by Yu Chen <chenyu56@huawei.com> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Rob Herring <robh+dt@kernel.org> Cc: Mark Rutland <mark.rutland@arm.com> CC: ShuFan Lee <shufan_lee@richtek.com> Cc: Heikki Krogerus <heikki.krogerus@linux.intel.com> Cc: Suzuki K Poulose <suzuki.poulose@arm.com> Cc: Chunfeng Yun <chunfeng.yun@mediatek.com> Cc: Yu Chen <chenyu56@huawei.com> Cc: Felipe Balbi <balbi@kernel.org> Cc: Hans de Goede <hdegoede@redhat.com> Cc: Andy Shevchenko <andy.shevchenko@gmail.com> Cc: Jun Li <lijun.kernel@gmail.com> Cc: Valentin Schneider <valentin.schneider@arm.com> Cc: Guillaume Gardet <Guillaume.Gardet@arm.com> Cc: Bryan O'Donoghue <bryan.odonoghue@linaro.org> Cc: Jack Pham <jackp@codeaurora.org> Cc: linux-usb@vger.kernel.org Cc: devicetree@vger.kernel.org Tested-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> Signed-off-by: John Stultz <john.stultz@linaro.org> Signed-off-by: Felipe Balbi <balbi@kernel.org>
2020-03-15usb: dwc3: Registering a role switch in the DRD code.Yu Chen2-1/+79
The Type-C drivers use USB role switch API to inform the system about the negotiated data role, so registering a role switch in the DRD code in order to support platforms with USB Type-C connectors. Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Rob Herring <robh+dt@kernel.org> Cc: Mark Rutland <mark.rutland@arm.com> CC: ShuFan Lee <shufan_lee@richtek.com> Cc: Heikki Krogerus <heikki.krogerus@linux.intel.com> Cc: Suzuki K Poulose <suzuki.poulose@arm.com> Cc: Chunfeng Yun <chunfeng.yun@mediatek.com> Cc: Yu Chen <chenyu56@huawei.com> Cc: Felipe Balbi <balbi@kernel.org> Cc: Hans de Goede <hdegoede@redhat.com> Cc: Andy Shevchenko <andy.shevchenko@gmail.com> Cc: Jun Li <lijun.kernel@gmail.com> Cc: Valentin Schneider <valentin.schneider@arm.com> Cc: Guillaume Gardet <Guillaume.Gardet@arm.com> Cc: Jack Pham <jackp@codeaurora.org> Cc: Bryan O'Donoghue <bryan.odonoghue@linaro.org> Cc: linux-usb@vger.kernel.org Cc: devicetree@vger.kernel.org Suggested-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Tested-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> Signed-off-by: Yu Chen <chenyu56@huawei.com> Signed-off-by: John Stultz <john.stultz@linaro.org> Signed-off-by: Felipe Balbi <balbi@kernel.org>
2020-03-15usb: dwc3: core: add support for disabling SS instances in park modeNeil Armstrong2-0/+9
In certain circumstances, the XHCI SuperSpeed instance in park mode can fail to recover, thus on Amlogic G12A/G12B/SM1 SoCs when there is high load on the single XHCI SuperSpeed instance, the controller can crash like: xhci-hcd xhci-hcd.0.auto: xHCI host not responding to stop endpoint command. xhci-hcd xhci-hcd.0.auto: Host halt failed, -110 xhci-hcd xhci-hcd.0.auto: xHCI host controller not responding, assume dead xhci-hcd xhci-hcd.0.auto: xHCI host not responding to stop endpoint command. hub 2-1.1:1.0: hub_ext_port_status failed (err = -22) xhci-hcd xhci-hcd.0.auto: HC died; cleaning up usb 2-1.1-port1: cannot reset (err = -22) Setting the PARKMODE_DISABLE_SS bit in the DWC3_USB3_GUCTL1 mitigates the issue. The bit is described as : "When this bit is set to '1' all SS bus instances in park mode are disabled" Synopsys explains: The GUCTL1.PARKMODE_DISABLE_SS is only available in dwc_usb3 controller running in host mode. This should not be set for other IPs. This can be disabled by default based on IP, but I recommend to have a property to enable this feature for devices that need this. CC: Dongjin Kim <tobetter@gmail.com> Cc: Jianxin Pan <jianxin.pan@amlogic.com> Cc: Thinh Nguyen <thinhn@synopsys.com> Cc: Jun Li <lijun.kernel@gmail.com> Reported-by: Tim <elatllat@gmail.com> Signed-off-by: Neil Armstrong <narmstrong@baylibre.com> Signed-off-by: Felipe Balbi <balbi@kernel.org>
2020-03-15usb: dwc3: gadget: Wrap around when skip TRBsThinh Nguyen1-1/+1
When skipping TRBs, we need to account for wrapping around the ring buffer and not modifying some invalid TRBs. Without this fix, dwc3 won't be able to check for available TRBs. Cc: stable <stable@vger.kernel.org> Fixes: 7746a8dfb3f9 ("usb: dwc3: gadget: extract dwc3_gadget_ep_skip_trbs()") Signed-off-by: Thinh Nguyen <thinhn@synopsys.com> Signed-off-by: Felipe Balbi <balbi@kernel.org>
2020-03-15usb: dwc3: gadget: Don't clear flags before transfer endedThinh Nguyen1-3/+1
We track END_TRANSFER command completion. Don't clear transfer started/ended flag prematurely. Otherwise, we'd run into the problem with restarting transfer before END_TRANSFER command finishes. Fixes: 6d8a019614f3 ("usb: dwc3: gadget: check for Missed Isoc from event status") Signed-off-by: Thinh Nguyen <thinhn@synopsys.com> Signed-off-by: Felipe Balbi <balbi@kernel.org>
2020-03-15usb: dwc3: Remove kernel doc annotation where it's not neededAndy Shevchenko1-1/+1
The main comment in the file mistakenly marked with kernel doc annotation which makes the parser unhappy: .../dwc3/host.c:16: warning: Function parameter or member 'dwc' not described in 'dwc3_host_get_irq' Drop kernel doc annotation from host.c module. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Felipe Balbi <balbi@kernel.org>
2020-03-15usb: dwc3: Add ACPI support for xHCI portsAndy Shevchenko1-0/+2
The ACPI companion of the adapter has to be set for xHCI controller code to read and attach the ports described in the ACPI table. Use ACPI_COMPANION_SET macro to set this. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Felipe Balbi <balbi@kernel.org>
2020-03-15usb: dwc3: exynos: Add support for Exynos5422 suspend clkAnand Moon1-0/+9
Exynos5422 DWC3 module support two clk USBD300 and SCLK_USBD300 so add missing code to enable/disable code and suspend clk, for this add a new compatible samsung,exynos5420-dwusb3 to help configure dwc3 code and dwc3 suspend clock. Suspend clock controls the PHY power change from P0 to P1/P2/P3 during U0 to U1/U2/U3 transition. Signed-off-by: Anand Moon <linux.amoon@gmail.com> Signed-off-by: Felipe Balbi <balbi@kernel.org>
2020-03-15usb: dwc3: meson-g12a: Don't use ret uninitialized in dwc3_meson_g12a_otg_initNathan Chancellor1-1/+1
Clang warns: ../drivers/usb/dwc3/dwc3-meson-g12a.c:421:6: warning: variable 'ret' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized] if (priv->otg_mode == USB_DR_MODE_OTG) { ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../drivers/usb/dwc3/dwc3-meson-g12a.c:455:9: note: uninitialized use occurs here return ret; ^~~ ../drivers/usb/dwc3/dwc3-meson-g12a.c:421:2: note: remove the 'if' if its condition is always true if (priv->otg_mode == USB_DR_MODE_OTG) { ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../drivers/usb/dwc3/dwc3-meson-g12a.c:415:9: note: initialize the variable 'ret' to silence this warning int ret, irq; ^ = 0 1 warning generated. It is not wrong, ret is only used when that if statement is true. Just directly return 0 at the end to avoid this. Fixes: 729149c53f04 ("usb: dwc3: Add Amlogic A1 DWC3 glue") Reported-by: kbuild test robot <lkp@intel.com> Link: https://groups.google.com/d/msg/clang-built-linux/w5iBENco_m4/PPuXreAxBQAJ Link: https://github.com/ClangBuiltLinux/linux/issues/869 Signed-off-by: Nathan Chancellor <natechancellor@gmail.com> Signed-off-by: Felipe Balbi <balbi@kernel.org>
2020-03-15usb: cdns3: remove redundant assignment to pointer trbColin Ian King1-1/+1
Pointer trb being assigned with a value that is never read, it is assigned a new value later on. The assignment is redundant and can be removed. Addresses-Coverity: ("Unused value") Signed-off-by: Colin Ian King <colin.king@canonical.com> Signed-off-by: Felipe Balbi <balbi@kernel.org>
2020-03-15usb: gadget: remove redundant assignment to variable statusColin Ian King1-2/+0
Variable status is being assigned with a value that is never read, it is assigned a new value immediately afterwards. The assignment is redundant and can be removed. Addresses-Coverity: ("Unused value") Signed-off-by: Colin Ian King <colin.king@canonical.com> Signed-off-by: Felipe Balbi <balbi@kernel.org>
2020-03-15usb: gadget: xudc: Remove redundant platform_get_irq error messageYueHaibing1-4/+1
platform_get_irq() will call dev_err() itself on failure, so there is no need for the driver to also do this. This is detected by coccinelle. Acked-by: Thierry Reding <treding@nvidia.com> Reviewed-by: Nagarjuna Kristam <nkristam@nvidia.com> Signed-off-by: YueHaibing <yuehaibing@huawei.com> Signed-off-by: Felipe Balbi <balbi@kernel.org>
2020-03-15usb: dwc2: add support for STM32MP15 SoCs USB OTG HS and FSAmelie Delaunay4-2/+141
This patch introduces a new parameter to activate external ID pin and valid vbus level detection, required on STM32MP15 SoC to support dual role, either in HS or FS. The STM32MP15 SoC uses the GGPIO register to enable the level detection. The level detector requires to be powered. Also adds the params structures for STM32MP15 OTG HS and STM32MP1 OTG FS. Acked-by: Minas Harutyunyan <hminas@synopsys.com> Signed-off-by: Amelie Delaunay <amelie.delaunay@st.com> Signed-off-by: Felipe Balbi <balbi@kernel.org>
2020-03-15usb: dwc3: Add Amlogic A1 DWC3 glueHanjie Lin1-56/+116
Adds support for Amlogic A1 USB Control Glue HW. The Amlogic A1 SoC Family embeds 1 USB Controllers: - a DWC3 IP configured as Host for USB2 and USB3 A glue connects the controllers to the USB2 PHY of A1 SoC. Signed-off-by: Yue Wang <yue.wang@amlogic.com> Signed-off-by: Hanjie Lin <hanjie.lin@amlogic.com> Reviewed-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com> Signed-off-by: Felipe Balbi <balbi@kernel.org>
2020-03-15usb: gadget: add udc driver for max3420Jassi Brar3-0/+1342
The MAX3420 is USB2.0 only, UDC-over-SPI controller. This driver also supports the peripheral mode of MAX3421. Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org> Signed-off-by: Felipe Balbi <balbi@kernel.org>
2020-03-15usb: dwc3: trace: print enqueue/dequeue pointers tooFelipe Balbi1-2/+7
By printing enqueue/dequeue pointers, we can make sure that our TRB handling is correct. We've had a recent situation where we were not always dequeueing all TRBs in an SG list and this helped figure out what the problem was. Signed-off-by: Felipe Balbi <balbi@kernel.org>
2020-03-12xhci-pci: Allow host runtime PM as default for Intel Tiger Lake xHCIMika Westerberg1-1/+3
In the same way as Intel Ice Lake TCSS (Type-C Subsystem) the Tiger Lake TCSS xHCI needs to be runtime suspended whenever possible to allow the TCSS hardware block to enter D3cold and thus save energy. Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com> Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Link: https://lore.kernel.org/r/20200312144517.1593-10-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-03-12xhci: Finetune host initiated USB3 rootport link suspend and resumeMathias Nyman1-11/+25
Depending on the current link state the steps to resume the link to U0 varies. The normal case when a port is suspended (U3) we set the link to U0 and wait for a port event when U3exit completed and port moved to U0. If the port is in U1/U2, then no event is issued, just set link to U0 If port is in Resume or Recovery state then the device has already initiated resume, and this host initiated resume is racing against it. Port event handler for device initiated resume will set link to U0, just wait for the port to reach U0 before returning. Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Link: https://lore.kernel.org/r/20200312144517.1593-9-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-03-12xhci: Wait until link state trainsits to U0 after setting USB_SS_PORT_LS_U0Kai-Heng Feng4-13/+34
Like U3 case, xHCI spec doesn't specify the upper bound of U0 transition time. The 20ms is not enough for some devices. Intead of polling PLS or PLC, we can facilitate the port change event to know that the link transits to U0 is completed. While at it, also separate U0 and U3 case to make the code cleaner. [variable rename to u3exit, and skip completion for usb2 ports -Mathias ] Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com> Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Link: https://lore.kernel.org/r/20200312144517.1593-8-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-03-12xhci: Ensure link state is U3 after setting USB_SS_PORT_LS_U3Kai-Heng Feng1-1/+10
The xHCI spec doesn't specify the upper bound of U3 transition time. For some devices 20ms is not enough, so we need to make sure the link state is in U3 before further actions. I've tried to use U3 Entry Capability by setting U3 Entry Enable in config register, however the port change event for U3 transition interrupts the system suspend process. For now let's use the less ideal method by polling PLS. [use usleep_range(), and shorten the delay time while polling -Mathias] Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com> Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Link: https://lore.kernel.org/r/20200312144517.1593-7-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-03-12usb: host: xhci-tegra: Tegra186/Tegra194 LPMJC Kuo1-0/+7
Tegra186 and Tegra194 xHC supports USB 3.0 LPM. This commit enables XHCI_LPM_SUPPORT quirk for Tegra186 and Tegra194. Signed-off-by: JC Kuo <jckuo@nvidia.com> Acked-by: Thierry Reding <treding@nvidia.com> Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Link: https://lore.kernel.org/r/20200312144517.1593-6-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-03-12usb: xhci: Enable LPM for VIA LABS VL805Nicolas Saenz Julienne1-0/+3
This PCIe controller chip is used on the Raspberry Pi 4 and multiple adapter cards. There is no publicly available documentation for the chip, yet both the downstream RPi4 kernel and the controller cards support/advertise LPM support. Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de> Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Link: https://lore.kernel.org/r/20200312144517.1593-5-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-03-12xhci: Show host status when watchdog triggers and host is assumed dead.Mathias Nyman2-0/+33
Additional debugging to show xHC USBSTS register when stop endpoint command watchdog triggers and host is assumed dead. useful to know the current status before the controller is stopped by the xhci driver and everything is released and freed. Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Link: https://lore.kernel.org/r/20200312144517.1593-4-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-03-12xhci: Add a separate debug message for split transaction errors.Mathias Nyman1-0/+4
Don't show the same error message for transaction errors and split transaction errors. It's very confusing while debugging. Transaction errors are often due to electrical interference. Split transaction errors are about xHC not being able to schedule start and complete split transactions needed to address low- and full-speed devices behind high-speed hubs. Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Link: https://lore.kernel.org/r/20200312144517.1593-3-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-03-12xhci: bail out early if driver can't accress host in resumeMathias Nyman1-1/+3
Bail out early if the xHC host needs to be reset at resume but driver can't access xHC PCI registers. If xhci driver already fails to reset the controller then there is no point in attempting to free, re-initialize, re-allocate and re-start the host. If failure to access the host is detected later, failing the resume, xhci interrupts will be double freed when remove is called. Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Link: https://lore.kernel.org/r/20200312144517.1593-2-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-03-12USB: serial: pl2303: add device-id for HP LD381Scott Chen2-0/+2
Add a device id for HP LD381 Display LD381: 03f0:0f7f Signed-off-by: Scott Chen <scott@labau.com.tw> Cc: stable <stable@vger.kernel.org> Signed-off-by: Johan Hovold <johan@kernel.org>
2020-03-12USB: serial: option: add ME910G1 ECM composition 0x110bDaniele Palmas1-0/+2
Add ME910G1 ECM composition 0x110b: tty, tty, tty, ecm Signed-off-by: Daniele Palmas <dnlplm@gmail.com> Link: https://lore.kernel.org/r/20200304104310.2938-1-dnlplm@gmail.com Cc: stable <stable@vger.kernel.org> Signed-off-by: Johan Hovold <johan@kernel.org>
2020-03-12usb: phy: Add driver for the Ingenic JZ4770 USB transceiverPaul Cercueil3-0/+252
Add a driver to support the USB PHY found in the JZ4770 SoC from Ingenic. Signed-off-by: Paul Cercueil <paul@crapouillou.net> Link: https://lore.kernel.org/r/20200229161820.17824-2-paul@crapouillou.net Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-03-12USB: EHCI: ehci-mv: use a unique bus nameLubomir Rintel1-1/+1
In case there are multiple Marvell EHCI blocks in system, we need a different bus name for each one. Otherwise debugfs gets mildly upset about a directory name in usb/ehci: debugfs: Directory 'mv ehci' with parent 'ehci' already present! Signed-off-by: Lubomir Rintel <lkundrak@v3.sk> Acked-by: Alan Stern <stern@rowland.harvard.edu> Link: https://lore.kernel.org/r/20200309130014.548168-2-lkundrak@v3.sk Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-03-12USB: EHCI: ehci-mv: switch the HSIC HCI to HSIC modeLubomir Rintel1-0/+9
Turns out the undocumented and reserved bits of port status/control register of the root port need to be set to use the HCI in HSIC mode. Typically the firmware does this, but that is not always good enough, because the bits get lost if the HSIC clock is disabled (e.g. when ehci-mv is build as a module). This supplements commit 7b104f890ade ("USB: EHCI: ehci-mv: add HSIC support"). Signed-off-by: Lubomir Rintel <lkundrak@v3.sk> Acked-by: Alan Stern <stern@rowland.harvard.edu> Link: https://lore.kernel.org/r/20200309130014.548168-1-lkundrak@v3.sk Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-03-12usb: typec: ucsi_ccg: workaround for NVIDIA test deviceAjay Gupta2-5/+52
NVIDIA VirtualLink (svid 0x955) has two altmode, vdo=0x1 for VirtualLink DP mode and vdo=0x3 for NVIDIA test mode. NVIDIA test device FTB (Function Test Board) reports altmode list with vdo=0x3 first and then vdo=0x1. The list is: SVID VDO 0xff01 0xc05 0x28de 0x8085 0x955 0x3 0x955 0x1 Current logic to assign mode value is based on order in altmode list. This causes a mismatch of CON and SOP altmodes since NVIDIA GPU connector has order of vdo=0x1 first and then vdo=0x3. Fixing this by changing the order of vdo values reported by NVIDIA test device. the new list will be: SVID VDO 0xff01 0xc05 0x28de 0x8085 0x955 0x1085 0x955 0x3 Also NVIDIA VirtualLink (svid 0x955) uses pin E for display mode. NVIDIA test device reports vdo of 0x1 so make sure vdo values always have pin E assignement. Signed-off-by: Ajay Gupta <ajayg@nvidia.com> Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Link: https://lore.kernel.org/r/20200310121912.57879-1-heikki.krogerus@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-03-12USB: mon: Use scnprintf() for avoiding potential buffer overflowTakashi Iwai1-18/+18
Since snprintf() returns the would-be-output size instead of the actual output size, the succeeding calls may go beyond the given buffer limit. Fix it by replacing with scnprintf(). Signed-off-by: Takashi Iwai <tiwai@suse.de> Link: https://lore.kernel.org/r/20200311093003.24604-1-tiwai@suse.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-03-12usb: host: xhci-plat: add a shutdownRan Wang1-0/+1
When loading new kernel via kexec, we need to shutdown host controller to avoid any un-expected memory accessing during new kernel boot. Signed-off-by: Ran Wang <ran.wang_1@nxp.com> Cc: stable <stable@vger.kernel.org> Tested-by: Stephen Boyd <swboyd@chromium.org> Reviewed-by: Peter Chen <peter.chen@nxp.com> Link: https://lore.kernel.org/r/20200306092328.41253-1-ran.wang_1@nxp.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-03-12usb: typec: ucsi: displayport: Fix a potential race during registrationHeikki Krogerus1-1/+8
Locking the connector in ucsi_register_displayport() to make sure that nothing can access the displayport alternate mode before the function has finished and the alternate mode is actually ready. Fixes: af8622f6a585 ("usb: typec: ucsi: Support for DisplayPort alt mode") Cc: stable@vger.kernel.org Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Link: https://lore.kernel.org/r/20200311130006.41288-3-heikki.krogerus@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-03-12usb: typec: ucsi: displayport: Fix NULL pointer dereferenceHeikki Krogerus1-0/+3
If the registration of the DisplayPort was not successful, or if the port does not support DisplayPort alt mode in the first place, the function ucsi_displayport_remove_partner() will fail with NULL pointer dereference when it attempts to access the driver data. Adding a check to the function to make sure there really is driver data for the device before modifying it. Fixes: af8622f6a585 ("usb: typec: ucsi: Support for DisplayPort alt mode") Reported-by: Andrea Gagliardi La Gala <andrea.lagala@gmail.com> BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=206365 Cc: stable@vger.kernel.org Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Link: https://lore.kernel.org/r/20200311130006.41288-2-heikki.krogerus@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>