summaryrefslogtreecommitdiff
path: root/drivers/usb
AgeCommit message (Collapse)AuthorFilesLines
2023-09-04usb: dwc3: Fix enabling USB_DR_MODE_HOSTOleksandr Suvorov1-1/+1
The original logic always enables USB_DR_MODE_HOST operation mode in dwc3_layerscape_bind() in u-boot. Prevent choosing USB_DR_MODE_HOST operation mode if USB_HOST is not enabled. Fixes: 2b0b51d0bed ("usb: dwc3: add layerscape support") Signed-off-by: Oleksandr Suvorov <oleksandr.suvorov@foundries.io>
2023-09-04usb: dwc3: Fix renaming SPL_USB_HOST_SUPPORT to SPL_USB_HOSTOleksandr Suvorov1-3/+2
In the usb/dwc3-layerscape driver the first option should be renamed to the latter as well. Do it. Fix original logic in dwc3_layerscape_bind() - do not enable Fixes: 333e4a621df ("Rename SPL_USB_HOST_SUPPORT to SPL_USB_HOST") Signed-off-by: Oleksandr Suvorov <oleksandr.suvorov@foundries.io>
2023-08-25usb: dwc3: Fix remove function if there is no ulpi_reset gpioVenkatesh Yadav Abbarapu1-1/+2
As ulpi_reset gpio is now optional, we need to check it when doing the 'dwc3_generic_remove' function. Check if it is declared before accessing the ulpi_reset. Fixes: 237d1f60b1d ("usb: dwc3: Use the devm_gpiod_get_optional() API for reset gpio") Reported-by: Thomas Nizan <tnizan@witekio.com> Signed-off-by: Venkatesh Yadav Abbarapu <venkatesh.abbarapu@amd.com>
2023-08-09usb: Return -ENOENT when no devices are foundSimon Glass1-1/+1
When USB finds no devices it currently returns -EPERM which bootstd does not understand. This causes other bootdevs of the same priority to be skipped. Fix this by returning the correct error code. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2023-08-05usb: gadget: ether: Handle gadget driver registration in probe and removeMarek Vasut1-45/+52
Move the ethernet gadget driver registration and removal from ethernet bind and unbind callbacks into driver DM probe and remove callbacks. This way, when the driver is bound, which is triggered deliberately using 'bind' command, the USB ethernet gadget driver is instantiated and bound to the matching UDC. In reverse, when the driver is unbound, which is again triggered deliberately using 'unbind' command, the USB ethernet gadget driver instance is removed. Effectively, this now behaves like running either 'ums' or 'dfu' or any other commands utilizing USB gadget functionality. This also drops use of usb_gadget_release() and moves the use of usb_gadget_initialize() into usb_ether_init() used only by legacy platforms that do not use 'bind' command properly yet. Those have no place in drivers. Signed-off-by: Marek Vasut <marex@denx.de> Tested-by: Tom Rini <trini@konsulko.com> Reviewed-by: Tom Rini <trini@konsulko.com>
2023-08-05usb: gadget: ether: Move probe function above driver structureMarek Vasut1-14/+14
Move the driver probe function above the driver structure, so it can be placed alongside other related functions, like upcoming remove function. No functional change. Signed-off-by: Marek Vasut <marex@denx.de> Tested-by: Tom Rini <trini@konsulko.com> Tested-by: Miquel Raynal <miquel.raynal@bootlin.com> Tested-by: Miquel Raynal <miquel.raynal@bootlin.com> Reviewed-by: Tom Rini <trini@konsulko.com>
2023-08-05usb: gadget: ether: Inline functions used onceMarek Vasut1-39/+9
These functions here are only ever called once since drop of non-DM networking code. Inline them. No functional change. Signed-off-by: Marek Vasut <marex@denx.de> Tested-by: Tom Rini <trini@konsulko.com> Tested-by: Miquel Raynal <miquel.raynal@bootlin.com> Reviewed-by: Tom Rini <trini@konsulko.com>
2023-07-31usb: dwc3-generic: Restrict single ctrl node for RK3328Jagan Teki1-1/+1
Like Rockchip RK3568, the RK3328 also have single node to represent the glue and ctrl for USB 3.0. So, use the driver data to use single ctrl for RK3328 DWC3. Reviewed-by: Marek Vasut <marex@denx.de> Signed-off-by: Jagan Teki <jagan@amarulasolutions.com> Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
2023-07-31usb: dwc3-generic: Add rk3568 supportJonas Karlman1-0/+14
RK3568 share glue and ctrl in a single node. Use glue_get_ctrl_dev to return the glue node as the ctrl node. Signed-off-by: Jonas Karlman <jonas@kwiboo.se> Reviewed-by: Jagan Teki <jagan@amarulasolutions.com> Reviewed-by: Marek Vasut <marex@denx.de>
2023-07-31usb: dwc3-generic: Relax unsupported dr_mode checkJonas Karlman1-19/+8
When dr_mode is peripheral or otg and U-Boot has not been built with DM_USB_GADGET support, booting such device may end up with: dwc3_glue_bind_common: subnode name: usb@fcc00000 Error binding driver 'dwc3-generic-wrapper': -6 Some drivers failed to bind initcall sequence 00000000effbca08 failed at call 0000000000a217c8 (err=-6) ### ERROR ### Please RESET the board ### Instead fail gracfully with ENODEV to allow board continue booting. dwc3_glue_bind_common: subnode name: usb@fcc00000 dwc3_glue_bind_common: unsupported dr_mode 3 Also use CONFIG_IS_ENABLED(USB_HOST) and change switch to if statements to improve readability of the code. Fixes: 446e3a205b87 ("dwc3-generic: Handle the PHYs, the clocks and the reset lines") Signed-off-by: Jonas Karlman <jonas@kwiboo.se> Reviewed-by: Marek Vasut <marex@denx.de>
2023-07-31usb: dwc3-generic: Return early when there is no child nodeJonas Karlman1-3/+3
The current error check for device_find_first_child is not working as expected, the documentation for device_find_first_child mention: @devp: Returns first child device, or NULL if none Return: 0 Change to return early when there is no child node to avoid any possible null pointer dereference. Signed-off-by: Jonas Karlman <jonas@kwiboo.se> Reviewed-by: Marek Vasut <marex@denx.de> Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
2023-07-27Merge https://source.denx.de/u-boot/custodians/u-boot-usbTom Rini3-17/+4
2023-07-27usb: xhci: Fix double free on failureRichard Habeeb1-1/+0
drivers/core/device.c will call `device_free()` after xhci_register already frees the private device data. This can cause a crash later during the boot process, observed on aarch64 RPi4b as a synchronous exception. All callers of xhci_register use priv_auto, so this won't lead to memory leaks. Signed-off-by: Richard Habeeb <richard.habeeb@gmail.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-07-21usb: cdns3: gadget: Configure speed in udc_startRavi Gunasekaran1-0/+4
When one of the functions does not support super speed, the composite driver forces the gadget to high speed. But the speed is never configured in the cdns3 gadget driver. So configure the speed in cdns3_gadget_udc_start just like in the kernel. Signed-off-by: Ravi Gunasekaran <r-gunasekaran@ti.com> Reviewed-by: Marek Vasut <marex@denx.de>
2023-07-21usb: ehci-mx6: remove unnecessary regulator enable from probeTim Harvey1-16/+0
Remove the regulator_set_enable() call from device probe which resolves a regulator imbalance. This is unnecessary as regulator_set_enable() will be called when ehci_register calls the init_after_reset hook. Suggested-by: Marek Vasut <marex@denx.de> Signed-off-by: Tim Harvey <tharvey@gateworks.com>
2023-07-21sunxi: Kconfig: rework PHY_USB_SUN4I selectionAndre Przywara1-0/+1
At the moment we use "select" in each Allwinner SoC's Kconfig section to include the USB PHY driver in the build. This means it cannot be disabled via Kconfig, although USB is not really a strictly required core functionality, and a particular board might not even include USB ports. Rework the Kconfig part by removing the "select" lines for each SoC's section, and instead letting it default to "y" in the PHY driver section itself. We use "depends on !" to exclude the few SoCs we don't support (yet). The Allwinner V3s does not enable USB (PHY) support at the moment, even though it should work: let the PHY default to "n" to keep the current behaviour. Also the MUSB USB driver directly calls some functions from the PHY driver, so let the former depend on the PHY driver. Signed-off-by: Andre Przywara <andre.przywara@arm.com> Reviewed-by: Jernej Skrabec <jernej.skrabec@gmail.com> Tested-by: Sam Edwards <CFSworks@gmail.com>
2023-07-16bootstd: Use bootdev instead of bootdeviceSimon Glass1-1/+1
It seems better to call this a 'bootdev' since this is name used in the documentation. The older 'Bootdevice' name is no-longer used and may cause confusion with the 'bootdevice' environment variable. Update throughout to use bootdev. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2023-07-06Merge branch 'master' of https://source.denx.de/u-boot/custodians/u-boot-usb ↵Tom Rini1-1/+1
into next
2023-07-05Merge tag 'v2023.07-rc6' into nextTom Rini2-26/+12
Prepare v2023.07-rc6
2023-07-03usb: dwc3-generic: Ensure reset GPIO is configured as an outputPeter Korsgaard1-1/+1
GPIOD_ACTIVE_LOW is not enough to configure a GPIO as an output, we need GPIOD_IS_OUT as well. Fixes: b252d79b0936d60b ("usb: dwc3: Add support to reset usb ULPI phy") Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
2023-06-21usb: dwc2: Fix the write to W1C fields in HPRT registerTeik Heng Chong2-26/+12
Fix the write to the HPRT register which treat W1C fields as if they were mere RW. This leads to unintended clearing of such fields This bug was found during the testing on Simics model. Referring to specification DesignWare Cores USB 2.0 Hi-Speed On-The-Go (OTG) Databook (3.30a)"5.3.4.8 Host Port Control and Status Register (HPRT)", the HPRT.PrtPwr is cleared by this mistake. In the Linux driver (contrary to U-Boot), HPRT is always read using dwc2_read_hprt0 helper function which clears W1C bits. So after write back those bits are zeroes. Signed-off-by: Teik Heng Chong <teik.heng.chong@intel.com>
2023-06-20usb: eth: lan78xx: Fix logic in lan78xx_read_otp() to avoid a warningTom Rini1-4/+2
In lan78xx_read_otp() we want to know if sig is LAN78XX_OTP_INDICATOR_1 or LAN78XX_OTP_INDICATOR_2. In the case of matching the first one we set offset to itself, and clang warns about this. Rework the logic so that if sig is the second indicator we adjust the offset as today and if it does not match the first indicator we return -EINVAL Cc: Marek Vasut <marex@denx.de> Reviewed-by: Marek Vasut <marex@denx.de> Signed-off-by: Tom Rini <trini@konsulko.com>
2023-06-12Merge tag v2023.07-rc4 into nextTom Rini5-6/+6
Signed-off-by: Tom Rini <trini@konsulko.com>
2023-06-08usb: musb-new: sunxi: remove unused defineSam Edwards1-2/+0
This is a remnant from when the USB controller driver managed the reset signal itself. A patch from the very end of 2018 changed this driver to delegate reset (and clock) management to the proper control unit driver, but left this unused define behind. Signed-off-by: Sam Edwards <CFSworks@gmail.com> Reviewed-by: Marek Vasut <marex@denx.de>
2023-06-07usb: musb-new: sunxi: fix error checkSam Edwards1-1/+1
The `musb_register` function returns some ERR_PTR(...) on failure, not NULL, so update the check here appropriately. Signed-off-by: Sam Edwards <CFSworks@gmail.com> Reviewed-by: Marek Vasut <marex@denx.de>
2023-05-17usb: gadget: Add and use matching SPL USB ethernet gadget Kconfig symbolsMarek Vasut2-2/+25
Define SPL_USB_ETH_RNDIS symbol to make it possible to select USB gadget ethernet support in SPL and U-Boot separately in Kconfig . Make use of the new symbols in gadget Makefile and move the rndis.o just below the now merged USB_ETHER symbol in Makefile. Signed-off-by: Marek Vasut <marex@denx.de> Reviewed-by: Tom Rini <trini@konsulko.com>
2023-05-17usb: Move SPL_USB_GADGET and related Kconfig symbols to drivers/usb/Marek Vasut2-3/+66
To avoid piling up all the various Kconfig symbols in one place, i.e. common/spl/Kconfig, move the USB Kconfig symbols into drivers/usb/ . This commit moves SPL_USB_GADGET and related symbols. Fix typo and rename SPL_USB_GADGET to "USB Gadget Support in SPL" . Update the gadget Makefile to match the symbol changes. Signed-off-by: Marek Vasut <marex@denx.de> Reviewed-by: Tom Rini <trini@konsulko.com>
2023-05-17usb: Move SPL_USB_STORAGE Kconfig symbol to drivers/usb/Marek Vasut1-0/+22
To avoid piling up all the various Kconfig symbols in one place, i.e. common/spl/Kconfig, move the USB Kconfig symbols into drivers/usb/ . This commit moves SPL_USB_STORAGE and matching SYS_USB_FAT_BOOT_PARTITION . Signed-off-by: Marek Vasut <marex@denx.de> Reviewed-by: Tom Rini <trini@konsulko.com>
2023-05-17usb: Move SPL_USB_HOST Kconfig symbol to drivers/usb/Marek Vasut1-0/+13
To avoid piling up all the various Kconfig symbols in one place, i.e. common/spl/Kconfig, move the USB Kconfig symbols into drivers/usb/ . This commit moves SPL_USB_HOST and updates help text of both USB_HOST and SPL_USB_HOST . Signed-off-by: Marek Vasut <marex@denx.de> Reviewed-by: Tom Rini <trini@konsulko.com>
2023-05-13bootstd: usb: Avoid initing USB twiceSimon Glass1-0/+3
This causes crashes on some boards, e.g. rockpro64. In any case, we should not do it. Check the usb_started flag to avoid this. Signed-off-by: Simon Glass <sjg@chromium.org> Tested-by: Jonas Karlman <jonas@kwiboo.se> Tested-by: Tom Rini <trini@konsulko.com>
2023-05-13usb: Tidy up the usb_start flagSimon Glass1-1/+0
This should be declared in a header file so that type-checking works correctly. Add a single declaration to usb.h and remove the others. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Marek Vasut <marex@denx.de> Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
2023-05-06drivers: use devfdt_get_addr_index_ptr when cast to pointerJohan Jonker1-1/+1
The fdt_addr_t and phys_addr_t size have been decoupled. A 32bit CPU can expect 64-bit data from the device tree parser, so use devfdt_get_addr_index_ptr instead of the devfdt_get_addr_index function in the various files in the drivers directory that cast to a pointer. As we are there also streamline the error response to -EINVAL on return. Signed-off-by: Johan Jonker <jbx6244@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-05-06drivers: use dev_read_addr_ptr when cast to pointerJohan Jonker1-1/+1
The fdt_addr_t and phys_addr_t size have been decoupled. A 32bit CPU can expect 64-bit data from the device tree parser, so use dev_read_addr_ptr instead of the dev_read_addr function in the various files in the drivers directory that cast to a pointer. As we are there also streamline the error response to -EINVAL on return. Signed-off-by: Johan Jonker <jbx6244@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-05-02usb: ehci-mx6: move phy setup before register accessTim Harvey1-6/+4
For the CONFIG_PHY case, move the PHY setup before the register access. This avoids a hang when updating the imx8mm.dtsi which moves the USB OTG power-domains to the PHY. Signed-off-by: Tim Harvey <tharvey@gateworks.com> Tested-by: Fabio Estevam <festevam@denx.de>
2023-04-28sandbox: fix sandbox_hub_submit_control_msg()Heinrich Schuchardt1-21/+9
Avoid incorrect fall through: A USB_RT_HUB request should not be treated as USB_RT_PORT. Simplify the coding: Avoid duplicate debug() statements. This fixes all -Wimplicit-fallthrough warnings. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-04-28sandbox: fix fall through in sandbox_flash_bulk()Heinrich Schuchardt1-0/+1
Handling of SANDBOX_FLASH_EP_OUT should never fall through to SANDBOX_FLASH_EP_IN. This addresses a warning shown when compiling with -Wimplicit-fallthrough. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-04-25usb: gadget: f_mass_storage: Rework do_request_sense slightlyTom Rini1-2/+1
When building with clang, it notes that sdinfo may be unused uninitialized in some cases. This appears to be true from reading the code, and we can simply set the variable to zero to start with and be as correct as before. Signed-off-by: Tom Rini <trini@konsulko.com> Reviewed-by: Marek Vasut <marex@denx.de>
2023-04-03Merge https://source.denx.de/u-boot/custodians/u-boot-usbTom Rini2-1/+2
- Two USB gadget fixes
2023-04-04usb: gadget: f_sdp: Add missing spl_board_prepare_for_boot() callMarek Vasut1-0/+1
The spl_board_prepare_for_boot() should be called before jump_to_image_no_args() to perform board-specific deinitialization before jumping to the next stage. This board-specific deinitialization can be very much anything, e.g. disable dcache in case it was enabled, or such. Add the missing spl_board_prepare_for_boot() call into f_sdp . Signed-off-by: Marek Vasut <marex@denx.de>
2023-04-04usb: gadget: missing fallthrough in composite_setup()Heinrich Schuchardt1-1/+1
Add a missing fallthrough macro. This fixes a -Wimplicit-fallthrough warning. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2023-03-14Merge tag 'v2023.04-rc4' into nextTom Rini1-0/+11
Prepare v2023.04-rc4 Signed-off-by: Tom Rini <trini@konsulko.com>
2023-03-10usb: move CONFIG_USB_HUB_DEBOUNCE_TIMEOUT to USBHeinrich Schuchardt1-0/+11
This configuration setting is only relevant if the board supports USB. It should not be in the main menu but in the USB menu. The setting is only relevant in USB host mode. Fixes: 5454dea3137d ("usb: hub: allow to increase HUB_DEBOUNCE_TIMEOUT") Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Marek Vasut <marex@denx.de> Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
2023-03-02usb: xhci-mtk: modify the SOF/ITP interval for mt8195Chunfeng Yun1-1/+48
There are 4 USB controllers on MT8195, the controllers (IP1~IP3, exclude IP0) have a wrong default SOF/ITP interval which is calculated from the frame counter clock 24Mhz by default, but in fact, the frame counter clock is 48Mhz, so we shall set the accurate interval according to 48Mhz for those controllers. Note: The first controller no need set it, but if set it, shall change tphy's pll at the same time. Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com> Reviewed-by: Marek Vasut <marex@denx.de>
2023-03-02usb: dwc3-meson-g12a: Select PHY instead of imply PHYMarek Vasut1-2/+2
Imply means you can turn off the option and expect things to work - "it's a good idea to have X enabled" is when to use imply - "you must have X for Y to work" is when to use select Use "select" here. Signed-off-by: Marek Vasut <marex@denx.de> Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
2023-02-27Merge tag 'v2023.04-rc3' into nextTom Rini2-19/+22
Prepare v2023.04-rc3
2023-02-23ARM: tegra: provide default USB gadget setupMaxim Schwalm1-0/+3
All Nvidia boards use the same manufacturer, vendor ID and product ID for the gadgets. Make them the defaults to remove some boilerplate from the defconfigs. Inspired by commit e02687bda96c ("sunxi: provide default USB gadget setup") which did the same for Allwinner boards. Tested-by: Thierry Reding <treding@nvidia.com> # T30 and T124 Signed-off-by: Maxim Schwalm <maxim.schwalm@gmail.com> Signed-off-by: Tom <twarren@nvidia.com>
2023-02-23usb: dwc3-uniphier: Select PHYMarek Vasut1-0/+1
Make sure the PHY subsystem is activated for the uniphier DWC3 glue logic, as it depends on PHY implementation there. Signed-off-by: Marek Vasut <marex@denx.de>
2023-02-22usb: dwc3-uniphier: Use dwc3-generic instead of xhci-dwc3Kunihiko Hayashi2-42/+78
dwc3-uniphier depends on xhci-dwc3 framework, however, it is preferable to use dwc3-generic. This driver calls the exported dwc3-generic functions and redefine the SoC-dependent operations to fit dwc3-generic. Signed-off-by: Kunihiko Hayashi <hayashi.kunihiko@socionext.com> Reviewed-by: Marek Vasut <marex@denx.de>
2023-02-22usb: dwc3-generic: Add the size of regs property to glue structureKunihiko Hayashi2-1/+2
Add the size of regs property to the glue structure to correctly specify the register region to map. Signed-off-by: Kunihiko Hayashi <hayashi.kunihiko@socionext.com> Reviewed-by: Marek Vasut <marex@denx.de>
2023-02-22usb: dwc3-generic: Export glue structures and functionsKunihiko Hayashi2-14/+36
In order to allow external SoC-dependent glue drivers to use dwc3-generic functions, push the glue structures and export the functions to a header file. The exported structures and functions are: - struct dwc3_glue_data - struct dwc3_glue_ops - dwc3_glue_bind() - dwc3_glue_probe() - dwc3_glue_remove() The SoC-dependent glue drivers can only define their own wrapper driver and specify these functions. The drivers can also add their own compatible strings and configure functions. Signed-off-by: Kunihiko Hayashi <hayashi.kunihiko@socionext.com> Reviewed-by: Marek Vasut <marex@denx.de>