aboutsummaryrefslogtreecommitdiff
path: root/drivers/usb
Commit message (Collapse)AuthorAgeFilesLines
* musb-new: omap2430: fix compiling in DM_USB_GADGET configAndreas Kemnade2023-01-181-0/+19
| | | | | | Add the separate IRQ handling function and change the registration. Signed-off-by: Andreas Kemnade <andreas@kemnade.info>
* musb-new: omap2430: no host data access in gadget modeAndreas Kemnade2023-01-181-18/+16
| | | | | | | Avoid accessing structures (usb_bus_priv) only present when musb is in host mode. Signed-off-by: Andreas Kemnade <andreas@kemnade.info>
* image: Move common image code to image_board and commandSimon Glass2023-01-161-1/+1
| | | | | | | | | | | We should use the cmd/ directory for commands rather than for common code used elsewhere in U-Boot. Move the common 'source' code into image-board.c to achieve this. The image_source_script() function needs to call run_command_list() so seems to belong better in the command library. Move and rename it. Signed-off-by: Simon Glass <sjg@chromium.org>
* usb: gadget: dwc2_udc_otg: implement pullup()Mattijs Korpershoek2023-01-141-0/+9
| | | | | | | | | | | | | | | Pullup is used by the usb framework in order to do software-controlled usb_gadget_connect() and usb_gadget_disconnect(). Implement pullup() for dwc2 using the SOFT_DISCONNECT bit in the dctl register: * when pullup is on, clear SOFT_DISCONNECT * when pullup is off, set SOFT_DISCONNECT This is especially useful when a gadget disconnection is initiated but no board_usb_cleanup() is called. Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
* usb: gadget: fastboot: detach usb just before rebootingDario Binacchi2023-01-141-1/+1
| | | | | | | | | | | | | | | | | | The patch fixes the following error when updating a BSH SMM S2 board: 3:72>Start Cmd:FB[-t 8000]: ucmd nand write ${loadaddr} nanddtb ${filesize} 3:72>Okay (0.023s) 3:72>Start Cmd:FB: reboot 3:72>Fail Bulk(R):LIBUSB_ERROR_IO(0s) The "fastboot reboot" command detaches the USB when it still needs to be used. So let's detach the USB just before the reset. CC: Mattijs Korpershoek <mkorpershoek@baylibre.com> Fixes: 5f7e01e9d5d800 ("usb: gadget: fastboot: detach usb on reboot commands") Suggested-by: Michael Trimarchi <michael@amarulasolutions.com> Co-developed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com> Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com> Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
* Merge tag 'u-boot-stm32-20230113' of ↵Tom Rini2023-01-132-6/+20
|\ | | | | | | | | | | | | | | | | | | | | https://source.denx.de/u-boot/custodians/u-boot-stm Add driver to manage onboard hub supplies Add calibration support for stm32-adc Linux kernel v6.1 DT synchronization for stm32mp151.dtsi stm32mp157a-dk1-scmi-u-boot.dtsi update Add support of OP-TEE and STM32MP13x in bsec driver ECDSA various fixes for stm32mp
| * usb: onboard-hub: add driver to manage onboard hub suppliesFabrice Gasnier2023-01-122-6/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The main issue the driver addresses is that a USB hub needs to be powered before it can be discovered. This is often solved by using "regulator-always-on". This driver is inspired by the Linux v6.1 driver. It only enables (or disables) the hub vdd (3v3) supply, so it can be enumerated. Scanning of the device tree is done in a similar manner to the sandbox, by the usb-uclass. DT part looks like: &usbh_ehci { ... #address-cells = <1>; #size-cells = <0>; hub@1 { compatible = "usb424,2514"; reg = <1>; vdd-supply = <&v3v3>; }; }; When the bus gets probed, the driver is automatically probed/removed from the bus tree, as an example on stm32: STM32MP> usb start starting USB... STM32MP> dm tree Class Index Probed Driver Name ----------------------------------------------------------- usb 0 [ + ] ehci_generic | |-- usb@5800d000 usb_hub 0 [ + ] usb_onboard_hub | | `-- hub@1 usb_hub 1 [ + ] usb_hub | | `-- usb_hub STM32MP> usb tree USB device tree: 1 Hub (480 Mb/s, 0mA) | u-boot EHCI Host Controller | +-2 Hub (480 Mb/s, 2mA) Signed-off-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com> Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com> Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
* | fastboot: remove #ifdef CONFIG when it is possiblePatrick Delaunay2023-01-111-5/+2
|/ | | | | | | | | | | Much of the fastboot code predates the introduction of Kconfig and has quite a few #ifdefs in it which is unnecessary now that we can use IS_ENABLED() et al. Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com> Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com> Reviewed-by: Sean Anderson <sean.anderson@seco.com> Tested-by: Mattijs Korpershoek <mkorpershoek@baylibre.com> # on vim3l
* cmd: source: Support specifying config nameSean Anderson2022-12-311-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | As discussed previously [1,2], the source command is not safe to use with verified boot unless there is a key with required = "images" (which has its own problems). This is because if such a key is absent, signatures are verified but not required. It is assumed that configuration nodes will provide the signature. Because the source command does not use configurations to determine the image to source, effectively no verification takes place. To address this, allow specifying configuration nodes. We use the same syntax as the bootm command (helpfully provided for us by fit_parse_conf). By default, we first try the default config and then the default image. To force using a config, # must be present in the command (e.g. `source $loadaddr#my-conf`). For convenience, the config may be omitted, just like the address may be (e.g. `source \#`). This also works for images (`source :` behaves exactly like `source` currently does). [1] https://lore.kernel.org/u-boot/7d711133-d513-5bcb-52f2-a9dbaa9eeded@prevas.dk/ [2] https://lore.kernel.org/u-boot/042dcb34-f85f-351e-1b0e-513f89005fdd@gmail.com/ Signed-off-by: Sean Anderson <sean.anderson@seco.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* treewide: Use NULL for script image nameSean Anderson2022-12-311-1/+1
| | | | | | | | | | | | | | Two callers of image_source_script specify an image name. However, both use the deprecated @ syntax, indicating that they have not been updated in a while. If CONFIG_FIT_SIGNATURE is enabled, we will reject such names outright. Back in commit 152576a598c ("stm32mp: stm32prog: handle U-Boot script in flashlayout alternate"), we even renamed one of the nodes. Instead of hard-coding a script image name, just use the default image. Signed-off-by: Sean Anderson <sean.anderson@seco.com> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
* global: Migrate CONFIG_USB_ISP1301_I2C_ADDR to CFGTom Rini2022-12-231-1/+1
| | | | | | Perform a simple rename of CONFIG_USB_ISP1301_I2C_ADDR to CFG_USB_ISP1301_I2C_ADDR Signed-off-by: Tom Rini <trini@konsulko.com>
* global: Migrate CONFIG_MXC_USB_FLAGS et al to CFGTom Rini2022-12-232-6/+6
| | | | | | | | | Perform simple renames of: CONFIG_MXC_USB_FLAGS to CFG_MXC_USB_FLAGS CONFIG_MXC_USB_PORT to CFG_MXC_USB_PORT CONFIG_MXC_USB_PORTSC to CFG_MXC_USB_PORTSC Signed-off-by: Tom Rini <trini@konsulko.com>
* usb: Remove CONFIG_USBD_HSTom Rini2022-12-221-19/+0
| | | | | | | This define is not enabled by the only platform which currently enables the legacy option of CONFIG_USB_DEVICE. We can drop this code. Signed-off-by: Tom Rini <trini@konsulko.com>
* usb: Update USB_STORAGE dependenciesTom Rini2022-12-211-1/+0
| | | | | | | | As it's no longer possible to have !DM_USB set, we can remove these dependencies. Signed-off-by: Tom Rini <trini@konsulko.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* Merge tag 'v2023.01-rc4' into nextTom Rini2022-12-212-7/+10
|\ | | | | | | | | | | Prepare v2023.01-rc4 Signed-off-by: Tom Rini <trini@konsulko.com>
| * usb: gadget: rndis: Prevent InformationBufferOffset manipulationSzymon Heidrich2022-12-081-3/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Prevent access to arbitrary memory locations in gen_ndis_set_resp via manipulation of buf->InformationBufferOffset. Original implementation permits manipulation of InformationBufferOffset to exploit OID_GEN_CURRENT_PACKET_FILTER to set arbitrary memory contents within a 32byte offset as the devices packet filter. The packet filter value may be next retrieved using gen_ndis_query_resp so it is possible to extract specific memory regions two bytes a time. The rndis_query_response was not modified as neither the buffer offset nor length passed to gen_ndis_query_resp is used. Signed-off-by: Szymon Heidrich <szymon.heidrich@gmail.com>
| * usb: gadget: dfu: Fix check of transfer directionHugo SIMELIERE2022-12-081-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | Commit fbce985e28eaca3af82afecc11961aadaf971a7e to fix CVE-2022-2347 blocks DFU usb requests. The verification of the transfer direction was done by an equality but it is a bit mask. Signed-off-by: Hugo SIMELIERE <hsimeliere.opensource@witekio.com> Reviewed-by: Fabio Estevam <festevam@denx.de> Reviewed-by: Sultan Qasim Khan <sultan.qasimkhan@nccgroup.com> Reviewed-by: Marek Vasut <marex@denx.de> Tested-by: Marek Vasut <marex@denx.de>
* | usb: gadget: Remove non-DM_ETH codeTom Rini2022-12-073-117/+0
| | | | | | | | | | | | | | As DM_ETH is required for all network drivers, it's now safe to remove the non-DM_ETH support code. Signed-off-by: Tom Rini <trini@konsulko.com>
* | usb: eth: Remove non-DM_ETH codeTom Rini2022-12-072-242/+0
| | | | | | | | | | | | | | As DM_ETH is required for all network drivers, it's now safe to remove the non-DM_ETH support code fro usb_ether itself. Signed-off-by: Tom Rini <trini@konsulko.com>
* | usb: eth: smsc95xx: Remove non-DM_ETH codeTom Rini2022-12-071-234/+0
| | | | | | | | | | | | | | As DM_ETH is required for all network drivers, it's now safe to remove the non-DM_ETH support code. Signed-off-by: Tom Rini <trini@konsulko.com>
* | usb: eth: r8152: Remove non-DM_ETH codeTom Rini2022-12-072-277/+0
| | | | | | | | | | | | | | As DM_ETH is required for all network drivers, it's now safe to remove the non-DM_ETH support code. Signed-off-by: Tom Rini <trini@konsulko.com>
* | usb: eth: msc7830: Remove non-DM_ETH codeTom Rini2022-12-071-276/+0
| | | | | | | | | | | | | | As DM_ETH is required for all network drivers, it's now safe to remove the non-DM_ETH support code. Signed-off-by: Tom Rini <trini@konsulko.com>
* | usb: eth: asix88179: Remove non-DM_ETH codeTom Rini2022-12-071-250/+0
| | | | | | | | | | | | | | As DM_ETH is required for all network drivers, it's now safe to remove the non-DM_ETH support code. Signed-off-by: Tom Rini <trini@konsulko.com>
* | usb: eth: asix: Remove non-DM_ETH codeTom Rini2022-12-071-255/+0
| | | | | | | | | | | | | | As DM_ETH is required for all network drivers, it's now safe to remove the non-DM_ETH support code. Signed-off-by: Tom Rini <trini@konsulko.com>
* | Convert CONFIG_USB_GADGET_AT91 to KconfigTom Rini2022-12-051-0/+4
| | | | | | | | | | | | | | This converts the following to Kconfig: CONFIG_USB_GADGET_AT91 Signed-off-by: Tom Rini <trini@konsulko.com>
* | global: Move remaining CONFIG_SYS_* to CFG_SYS_*Tom Rini2022-12-051-1/+1
| | | | | | | | | | | | | | | | | | | | The rest of the unmigrated CONFIG symbols in the CONFIG_SYS namespace do not easily transition to Kconfig. In many cases they likely should come from the device tree instead. Move these out of CONFIG namespace and in to CFG namespace. Signed-off-by: Tom Rini <trini@konsulko.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* | global: Move remaining CONFIG_SYS_SDRAM_* to CFG_SYS_SDRAM_*Tom Rini2022-12-051-2/+2
|/ | | | | | | | | | The rest of the unmigrated CONFIG symbols in the CONFIG_SYS_SDRAM namespace do not easily transition to Kconfig. In many cases they likely should come from the device tree instead. Move these out of CONFIG namespace and in to CFG namespace. Signed-off-by: Tom Rini <trini@konsulko.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* usb: dwc3: Drop support for "snps, ref-clock-period-ns" DT propertyMarek Vasut2022-11-271-4/+0
| | | | | | | | Drop support for quickly deprecated DT property "snps,ref-clock-period-ns" to prevent its proliferation. Reviewed-by: Sean Anderson <seanga2@gmail.com> Signed-off-by: Marek Vasut <marex@denx.de>
* usb: dwc3: Program GFLADJSean Anderson2022-11-272-0/+44
| | | | | | | | | | | | | | | | | | | | | | GUCTL.REFCLKPER can only account for clock frequencies with integer periods. To address this, program REFCLK_FLADJ with the relative error caused by period truncation. The formula given in the register reference has been rearranged to allow calculation based on rate (instead of period), and to allow for fixed-point arithmetic. Additionally, calculate a value for 240MHZDECR. This configures a simulated 240Mhz clock using a counter with one fractional bit (PLS1). This register is programmed only for versions >= 2.50a, since this is the check also used by commit db2be4e9e30c ("usb: dwc3: Add frame length adjustment quirk"). [ marek: Ported from Linux kernel commit 596c87856e08d ("usb: dwc3: Program GFLADJ") ] Reviewed-by: Sean Anderson <seanga2@gmail.com> Signed-off-by: Sean Anderson <sean.anderson@seco.com> Signed-off-by: Marek Vasut <marex@denx.de> # Port from Linux
* usb: dwc3: Calculate REFCLKPER based on reference clockSean Anderson2022-11-271-2/+13
| | | | | | | | | | | | | | | Instead of using a special property to determine the reference clock period, use the rate of the reference clock. When we have a legacy snps,ref-clock-period-ns property and no reference clock, use it instead. Fractional clocks are not currently supported, and will be dealt with in the next commit. [ marek: Ported from Linux kernel commit 5114c3ee24875 ("usb: dwc3: Calculate REFCLKPER based on reference clock") ] Reviewed-by: Sean Anderson <seanga2@gmail.com> Signed-off-by: Sean Anderson <sean.anderson@seco.com> Signed-off-by: Marek Vasut <marex@denx.de> # Port from Linux
* usb: dwc3: reference clock period configurationBalaji Prakash J2022-11-272-0/+33
| | | | | | | | | | | | | | | | | | | | | | | Set reference clock period when it differs from dwc3 default hardware set. We could calculate clock period based on reference clock frequency. But this information is not always available. This is the case of PCI bus attached USB host. For that reason we use a custom property. Tested (USB2 only) on IPQ6010 SoC based board with 24 MHz reference clock while hardware default is 19.2 MHz. [ baruch: rewrite commit message; drop GFLADJ code; remove 'quirk-' from property name; mention tested hardware ] [ marek: Ported from Linux kernel commit 7bee318838890 ("usb: dwc3: reference clock period configuration") ] Reviewed-by: Sean Anderson <seanga2@gmail.com> Signed-off-by: Balaji Prakash J <bjagadee@codeaurora.org> Signed-off-by: Baruch Siach <baruch@tkos.co.il> Signed-off-by: Marek Vasut <marex@denx.de> # Port from Linux
* usb: dwc3: Cache ref_clk pointer in struct dwc3Marek Vasut2022-11-272-0/+12
| | | | | | | | | | | | | Cache ref_clk clock pointer in struct dwc3 . This is a preparatory patch for subsequent backports from Linux kernel which configure GFLADJ register content based on the ref_clk rate and therefore need access to the ref_clk pointer. It is possible to extract the clock pointer from existing clk_bulk list of already claimed clock, no need to call clk_get*() again. Reviewed-by: Sean Anderson <seanga2@gmail.com> Signed-off-by: Marek Vasut <marex@denx.de>
* usb: Expand buffer size in usb_find_and_bind_driver()Marek Vasut2022-11-271-1/+1
| | | | | | | | | | The "generic_bus_%x_dev_%x" string which is printed into this buffer can be up to 34 characters long ("generic_bus_12345678_dev_12345678"). The buffer would be clipped by snprintf() if both %x were at maximum range. Make sure the buffer is long enough to cover such possibility. Signed-off-by: Marek Vasut <marex@denx.de> Reviewed-by: Simon Glass <sjg@chromium.org>
* sandbox: check lseek return value in handle_ufi_commandHeinrich Schuchardt2022-11-221-3/+7
| | | | | | | Invoking lseek() may result in an error. Handle it. Addresses-Coverity-ID: 376212 ("Error handling issues (CHECKED_RETURN)") Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
* usb: gadget: dfu: Fix the unchecked length fieldVenkatesh Yadav Abbarapu2022-11-211-21/+37
| | | | | | | | | | | | DFU implementation does not bound the length field in USB DFU download setup packets, and it does not verify that the transfer direction. Fixing the length and transfer direction. CVE-2022-2347 Signed-off-by: Venkatesh Yadav Abbarapu <venkatesh.abbarapu@amd.com> Reviewed-by: Marek Vasut <marex@denx.de>
* usb: ehci: ehci-marvell: Support for marvell,ac5-ehciChris Packham2022-11-072-8/+46
| | | | | | | | | | Unlike the other 64-bit mvebu SoCs the AlleyCat5 uses the older ehci block from the 32-bit SoCs. Adapt the ehci-marvell.c driver to cope with the fact that the ac5 does not have the mbus infrastructure the 32-bit SoCs have and ensure USB_EHCI_IS_TDI is selected. Signed-off-by: Chris Packham <judge.packham@gmail.com> Reviewed-by: Stefan Roese <sr@denx.de>
* usb: ohci: Use a flexible array member for portstatusSamuel Holland2022-11-032-14/+1
| | | | | | | The struct is only used to overlay the MMIO region, so the behavior is the same. This obsoletes the Kconfig option for the number of ports. Signed-off-by: Samuel Holland <samuel@sholland.org>
* usb: Update the test to cover reading and writingSimon Glass2022-10-311-4/+31
| | | | | | | | | Add test coverage for blk_write() as well. The blk_erase() is not tested for now as the USB stor interface does not support erase. Signed-off-by: Simon Glass <sjg@chromium.org>
* usb: ether: Fix error handling in usb_ether_initMichal Suchanek2022-10-171-6/+5
| | | | | | | | | | | | The code checks the return value from uclass_first_device as well as that the device exists but it passes on the return value which may be zero if there are no gadget devices. Just check that a device was returned and return -ENODEV otherwise. Also remove the dev variable which is not really used for anything. Signed-off-by: Michal Suchanek <msuchanek@suse.de> Reviewed-by: Simon Glass <sjg@chromium.org>
* Fix typo in CONFIG_USBNET_DEVADDRIgnacio Zamora2022-10-122-2/+2
| | | | | | | | Fix typo that was caused by the same feature being split in to 2 different configuration options. Replace CONFIG_USBNET_DEVADDR with CONFIG_USBNET_DEV_ADDR Signed-off-by: Ignacio Zamora <nachopitt@gmail.com>
* usb: gadget: fastboot: detach usb on reboot commandsMattijs Korpershoek2022-10-101-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | When host issues "fastboot reboot fastboot", it's expected that the board drops the USB connection before resetting. On some boards, such as Khadas VIM3L and SEI610, this is not the case. We observe the following error: $ fastboot reboot fastboot Rebooting into fastboot OKAY [ 0.004s] fastboot: error: Failed to boot into userspace fastboot; one or more components might be unbootable. This does not happen when we use the RST button on the board. It can be reproduced in linux with: # echo b > /proc/sysrq-trigger In this case, we hit a undefined hardware behavior, where D+ and D- are in an unknown state. Therefore the host can't detect usb disconnection. Make sure we always call usb_gadget_release() when a "fastboot reboot" command is issued. Note: usb_gadget_release() should be called before g_dnl_unregister() because g_dnl_unregister() triggers a complete() call on each endpoint (thus calling do_reset()). Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
* usb: ehci: Remove unused ehci_{setup,shutdown}_phy() helpersPatrice Chotard2022-10-102-70/+0
| | | | | | | | | Remove unused ehci_{setup,shutdown}_phy() helpers now replaced by generic_{setup,shutdown}_phy(). Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com> Cc: Marek Vasut <marex@denx.de> Cc: Simon Glass <sjg@chromium.org>
* usb: ehci: Make usage of generic_{setup,shutdown}_phy() helpersPatrice Chotard2022-10-104-10/+10
| | | | | | | | | Replace ehci_setup_phy() and ehci_shutdown_phy () by respectively generic_setup_phy() and generic_shutdown_phy(). Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com> Cc: Marek Vasut <marex@denx.de> Cc: Simon Glass <sjg@chromium.org>
* usb: ohci: Make usage of generic_{setup,shutdown}_phy() helpersPatrice Chotard2022-10-101-53/+3
| | | | | | | | | Replace ohci_setup_phy() and ohci_shutdown_phy () by respectively generic_setup_phy() and generic_shutdown_phy(). Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com> Cc: Marek Vasut <marex@denx.de> Cc: Simon Glass <sjg@chromium.org>
* usb: gadget: Clean up Makefile ifdefferyMarek Vasut2022-10-101-10/+7
| | | | | | | | | | | | Take the USB_ETHER ifdef block apart and make use of obj-$(VAR) instead to include the source files in build. The duplicate CI_UDC entry is now removed, the USB_DEVICE ifdef is now reduced to core.o ep.o addition, the ether.o can be conditionally compiled in using USB_ETHER. No functional change. Signed-off-by: Marek Vasut <marex@denx.de> Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>
* Merge branch 'next'Tom Rini2022-10-036-148/+77
|\
| * treewide: Drop image_header_t typedefSimon Glass2022-09-291-1/+1
| | | | | | | | | | | | | | This is not needed and we should avoid typedefs. Use the struct instead and rename it to indicate that it really is a legacy struct. Signed-off-by: Simon Glass <sjg@chromium.org>
| * Merge branch 'next' of https://gitlab.denx.de/u-boot/custodians/u-boot-riscv ↵Tom Rini2022-09-263-1023/+1
| |\ | | | | | | | | | into next
| * | sandbox: scsi: Move request-handling code to scsi_emulSimon Glass2022-09-251-77/+10
| | | | | | | | | | | | | | | | | | | | | Move this code into the emulator file so it can be used by multiple drivers. Signed-off-by: Simon Glass <sjg@chromium.org>
| * | sandbox: scsi: Move structs to header fileSimon Glass2022-09-251-26/+0
| | | | | | | | | | | | | | | | | | | | | Move these to the SCSI header file so we can access them from multiple emulators. Signed-off-by: Simon Glass <sjg@chromium.org>