summaryrefslogtreecommitdiff
path: root/drivers/usb
AgeCommit message (Collapse)Author
4 daysMerge patch series "Fix dma_addr_t for R5 SPL"Tom Rini
Anshul Dalal <anshuld@ti.com> says: On various TI's K3 platforms boot failure was observed on SPI NOR since the commit 5609f200d062 ("arm: Kconfig: enable LTO for ARCH_K3"). This issue was root caused to stack corruption by the 'udma_transfer' function. Where the local variable 'paddr' of type 'dma_addr_t' was being written to as a 64-bit value which overwrote the stack frame of the caller (dma_memcpy) as only 32-bits had been reserved for paddr on the stack, specifically the r4 register in the frame of dma_memcpy was being overwritten with a 0. drivers/dma/ti/k3-udma.c:2192: int udma_transfer(...) { ... dma_addr_t paddr = 0; ... /* paddr was written to as 64-bit value here */ udma_poll_completion(uc, &paddr); } drivers/dma/dma-uclass.c:234: int dma_memcpy(...) { dma_addr_t destination; dma_addr_t source; int ret; ... /* This call resolves to udma_transfer */ ret = ops->transfer(...); ... dma_unmap_single(destination, ...); dma_unmap_single(...); return ret; } Enabling LTO changed how gcc mapped local variables of dma_memcpy to CPU registers, where earlier the bug was hidden since the overwritten register 'r4' was allotted to 'ret' but was allotted to 'destination' once LTO was enabled. And since the overwritten value was 0, the bug remained undetected as it just meant ret was 0, but having 'destination' set to 0 caused dma_unmap_single to fail silently leading to boot failures. The fix entails enabling DMA_ADDR_T_64BIT which changes dma_addr_t from u32 to u64 for the R5 SPL thus reserving enough space for 'paddr' to prevent the overflow. Link: https://lore.kernel.org/r/20250903115207.572304-1-anshuld@ti.com
4 daysdma: ti: k3-udma: fix dma_addr_t typecastsAnshul Dalal
dma_addr_t is used to store any valid DMA address which might not necessarily be the same size as host architecture's word size. Though various typecasts in k3's dma and usb driver expect dma_addr_t to be the same size as the word size. This leads the compiler to throw a "cast from pointer to integer of different size" warning when the condition is not met, for example when enabling CONFIG_DMA_ADDR_T_64BIT for the R5 core. Therefore this patch fixes the typecasts by using 'uintptr_t' as an intermediary type which is guaranteed to be the same size as void* on the host architecture. Thus, eliminating the compiler warning. Signed-off-by: Anshul Dalal <anshuld@ti.com>
10 daysMerge branch 'master' of https://source.denx.de/u-boot/custodians/u-boot-samsungTom Rini
- Fix issues reported by smatch - exynos4210-origen cleanups - e850-96 improvements
2025-09-01usb: host: dwc3-of-simple: Add exynos850 compatibleSam Protsenko
Enable support for Exynos850 SoC in DWC3 host glue layer driver. Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org> Reviewed-by: Marek Vasut <marek.vasut@mailbox.org> Signed-off-by: Minkyu Kang <mk7.kang@samsung.com>
2025-08-30usb: dwc3-generic: Use combined glue and ctrl node for RK3528Jonas Karlman
Like Rockchip RK3328, RK3568 and RK3588, the RK3528 also have a single node to represent the glue and ctrl for USB 3.0. Use rk_ops as driver data to select correct ctrl node for RK3528 DWC3. Signed-off-by: Jonas Karlman <jonas@kwiboo.se> Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
2025-08-30usb: dwc3-generic: Use combined glue and ctrl node for RK3576Jonas Karlman
Like Rockchip RK3328, RK3568 and RK3588, the RK3576 also have a single node to represent the glue and ctrl for USB 3.0. Use rk_ops as driver data to select correct ctrl node for RK3576 DWC3. Signed-off-by: Jonas Karlman <jonas@kwiboo.se> Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
2025-08-30rockchip: Add default USB_GADGET_PRODUCT_NUM for RK3576Jonas Karlman
Use 0x350e as the default USB Product ID for Rockchip RK3576, same PID being used by the BootROM when the device is in MASKROM mode. Signed-off-by: Jonas Karlman <jonas@kwiboo.se> Reviewed-by: Mattijs Korpershoek <mkorpershoek@kernel.org> Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
2025-08-30usb: gadget: rockchip: Fix spacing around the Kconfig optionTom Rini
This Kconfig option used spaces and not tabs for indentation. Switch to tabs. Signed-off-by: Tom Rini <trini@konsulko.com> Reviewed-by: Quentin Schulz <quentin.schulz@cherry.de> Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
2025-08-30usb: gadget: rockchip: Add missing dependencyTom Rini
The rockchip usb gadget driver cannot build without platform specific headers being available. Express that requirement in Kconfig as well. Signed-off-by: Tom Rini <trini@konsulko.com> Reviewed-by: Quentin Schulz <quentin.schulz@cherry.de> Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
2025-08-29usb: cdns3: Do not access memory after freeAndrew Goodbody
The call to cdns3_gadget_ep_free_request will free priv_req so do the call to list_del_init which accesses the memory pointed to by priv_req before the free. This issue was found by Smatch. Signed-off-by: Andrew Goodbody <andrew.goodbody@linaro.org> Reviewed-by: Siddharth Vadapalli <s-vadapalli@ti.com>
2025-08-23usb: dwc2: fix reset logic in dwc2_core_resetPatrick Delaunay
Use GUSBCFG_FORCEHOSTMODE to detected the HOST forced mode as it is done in the Linux driver drivers/usb/dwc2/core.c:dwc2_core_reset(). The host polling must be executed only if the current mode is host, either due to the force HOST mode (which persists after core reset) or the connector id pin. The GUSBCFG_FORCEDEVMODE bits is used to force the device mode (for example used on STM32MP1x platform) and when it is activated the DWC2 reset failed with the trace: "dwc2_core_reset: Waiting for GINTSTS_CURMODE_HOST timeout" Fixes: c5d685b8993c ("usb: dwc2: Unify flush and reset logic with v4.20a support") Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com> Reviewed-by: Junhui Liu <junhui.liu@pigmoral.tech> Tested-by: Patrice Chotard <patrice.chotard@foss.st.com> Reviewed-by: Marek Vasut <marek.vasut@mailbox.org>
2025-08-23usb: ehci-mx6: Add i.MX95 OTG supportTim Harvey
When the usb node is defined dr_mode="otg" ehci_usb_phy_mode() is called to determine the mode from status registers. The IMX95RM does not currently define the USBNC STATUS register but it is assumed to be an omission as the first three registers are defined. It has been expirimentally verified that the USBNC_PHY_STATUS register at offset 0x23C bit4 (USBNC_PHYSTATUS_ID_DIG) reads 0 when USB_ID is GND and 1 when floating. Use is_imx9() as this driver works for i.MX91, i.MX93 and i.MX95 and all of these determine the role based on the USBNC_PHY_STATUS register. Fixes: 801b5fafd35d "(usb: ehci-mx6: Add i.MX95 support") Signed-off-by: Tim Harvey <tharvey@gateworks.com> Reviewed-by: Alice Guo <alice.guo@nxp.com> Reviewed-by: Peng Fan <peng.fan@nxp.com> Reviewed-by: Fabio Estevam <festevam@gmail.com>
2025-07-30Merge patch series "Extend usb_onboard_hub driver to support Cypress HX3 hub ↵Tom Rini
family" Lukasz Czechowski <lukasz.czechowski@thaumatec.com> says: This patch series extends the usb_onboard_hub driver to allow for support of more types of onboard hub devices, and adds the Cypress HX3 hub family. First patch in the series updates the bind function, so that it no longer uses hardcoded compatible strings. Next patch simplifies the code, by removing unnecessary dm_gpio function call. Third patch updates the remove function, which allows the prevent issues with usb devices reenumeration, in case of calling "usb reset". Although the issue could still occur in case of invalid initial state of reset gpio, it is minimized with no impact on main usb_hub driver. Fourth patch extends the driver with support for multiple power supplies, the same way it is done in kernel driver. Finally, last patch provides hub data and of_match table entries for Cypress HX3 Link: https://lore.kernel.org/r/20250722-usb_onboard_hub_cypress_hx3-v4-0-91c3ee958c0e@thaumatec.com
2025-07-30usb: onboard-hub: Use devm API do automatically free the reset GPIOLukasz Czechowski
The reset GPIO is obtained during driver probing by the function devm_gpiod_get_optional, which means the GPIO will be automatically freed when the device is removed. Because of this, explicit call to free the reset GPIO in hub remove function is not needed. To support the Managed device resources, the DEVRES config must be enabled, otherwise the devres functions fall back to non-managed variants. Set the necessary dependency to DEVRES in Kconfig. Reviewed-by: Quentin Schulz <quentin.schulz@cherry.de> Signed-off-by: Lukasz Czechowski <lukasz.czechowski@thaumatec.com>
2025-07-25usb: dwc3-generic: Add Exynos850 supportSam Protsenko
The only thing needed from DWC3 glue layer for Exynos850 is to enable USB clocks. The generic glue layer driver already does that. Add Exynos850 dwc3 compatible string to enable support for this chip. Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org> Reviewed-by: Mattijs Korpershoek <mkorpershoek@kernel.org> Signed-off-by: Minkyu Kang <mk7.kang@samsung.com>
2025-06-18Merge patch series "list.h/treewide: get rid of no-op prefetch()"Tom Rini
Rasmus Villemoes <ravi@prevas.dk> says: While looking through list.h, I saw that the regular list_* helpers (and one of the hlist_* ones) still contain the prefetch() that was removed in linux 14 years ago. It doesn't do anything, but makes the macros harder to read, so get rid of it, and the fallback, no-op definition that they relied on. That requires removing a few uses outside list.h as well. checkpatch warns about some whitespace issues in list.h, but as I've copied whole kerneldoc+#define blocks directly from the linux kernel, I think it's better to just accept that so that we don't introduce needless diffs. The "macro argument reuse" arguments should also be ignored, as e.g. the "member" arguments are obviously always just bare identifiers, and the "pos" arguments must be assigned to multiple times. Link: https://lore.kernel.org/r/20250507121246.518691-1-ravi@prevas.dk
2025-06-18treewide: drop no-op prefetch() callsRasmus Villemoes
These all end up using the no-op prefetch() defined in linux/list.h, because the only possible real implementation is in arch/mips/include/asm/processor.h, which is behing CONFIG_CPU_HAS_PREFETCH which is nowhere defined. In order to be able to drop that fallback definition from list.h, first remove all uses. Signed-off-by: Rasmus Villemoes <ravi@prevas.dk>
2025-06-16Merge tag 'u-boot-dfu-next-20250616' of ↵Tom Rini
https://source.denx.de/u-boot/custodians/u-boot-dfu into next u-boot-dfu-next-20250616 CI: https://source.denx.de/u-boot/custodians/u-boot-dfu/-/pipelines/26704 Usb gadget: - Atmel: Improve gadget disconnect stability by power cycling
2025-06-16Merge tag 'u-boot-dfu-next-20250616' of ↵Tom Rini
https://source.denx.de/u-boot/custodians/u-boot-dfu into next u-boot-dfu-next-20250616 CI: https://source.denx.de/u-boot/custodians/u-boot-dfu/-/pipelines/26704 Usb gadget: - Fix ti_musb driver in gadget mode (with DM_USB_GADGET) DFU: - mmc/scsi backends when using 10 or more partitions
2025-06-16usb: gadget: atmel: reliably generate disconnect by disabling controllerZixun LI
Contrary to the datasheet, setting both DETACH and PULLD_DIS bits to 1 does not always drive the DP and DM lines to high-impedance. This prevents the host from reliably detecting a USB disconnect and subsequent reconnect. The symptom is that the first gadget command (e.g., dhcp) succeeds, while subsequent commands (e.g., nfs) fail. Disabling and re-enabling the controller entirely, instead of toggling the PULLD_DIS bit, reliably generates a disconnect event. The Linux driver works correctly because gadget_disconnect/gadget_connect are always followed by gadget_udc_start/gadget_udc_stop. In U-Boot pullup() is used solely. This behavior has been observed on the SAM9X60-Curiosity and AT91SAM9G25-EK boards and has been reported to Microchip. Signed-off-by: Zixun LI <admin@hifiphile.com> Link: https://lore.kernel.org/r/20250602-pullup-v1-1-edcde5a050dd@hifiphile.com [mkorpershoek: reworded commit title + comment to usba_udc_pullup()] Signed-off-by: Mattijs Korpershoek <mkorpershoek@kernel.org>
2025-06-16usb: gadget: musb: Fix duplicate ops assignment in ti_musb_peripheralKory Maincent
Remove duplicate .ops assignment that was overriding the correct ti_musb_gadget_ops with musb_usb_ops (host ops) in the ti_musb_peripheral driver. This was causing U-Boot crashes when trying to call the handle_interrupts operation since the wrong ops structure was being used. Fixes: 7d98dbcc3dc ("usb: musb-new: Add support for DM_USB") Fixes: 281eaf1ed83a ("usb: gadget: musb: Convert interrupt handling to usb_gadget_generic_ops") Signed-off-by: Kory Maincent <kory.maincent@bootlin.com> Reviewed-by: Mattijs Korpershoek <mkorpershoek@kernel.org> Link: https://lore.kernel.org/r/20250611171031.840277-1-kory.maincent@bootlin.com Signed-off-by: Mattijs Korpershoek <mkorpershoek@kernel.org>
2025-06-13spl: Rename jump_to_image_no_args()Simon Glass
This function is currently a misnomer at times as we have cases where it passes arguments to the image. In preparation for making that be a more common case rename this function to jump_to_image(...). In order to do this, rename jump_to_image in board_init_r(...) to jumper so that we do not have a conflict. Signed-off-by: Simon Glass <sjg@chromium.org> [trini: Reword the commit message, adding missing cases of jump_to_image_no_args()] Signed-off-by: Tom Rini <trini@konsulko.com>
2025-06-02usb: dwc2: Refactor register operations with clrsetbits macrosJunhui Liu
Refactor DWC2 USB gadget driver to replace manual read-modify-write operations with `clrsetbits_le32`, `setbits_le32`, and `clrbits_le32` macros, which simplify the code and improve readability. Signed-off-by: Junhui Liu <junhui.liu@pigmoral.tech> Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com> Reviewed-by: Marek Vasut <marex@denx.de> Link: https://lore.kernel.org/r/20250126-dwc2-clrsetbits-refactor-v1-1-68c27e1b6f84@pigmoral.tech Signed-off-by: Mattijs Korpershoek <mkorpershoek@kernel.org>
2025-06-02usb: dwc2: Replace uint<x>_t types with u<x>Kongyang Liu
Updates all instances of uint8_t, uint16_t, and uint32_t to u8, u16, and u32 respectively, ensuring consistent use of kernel-preferred types and resolving checkpatch.pl warnings. Signed-off-by: Kongyang Liu <seashell11234455@gmail.com> Reviewed-by: Marek Vasut <marex@denx.de> Tested-by: Peter Robinson <pbrobinson@gmail.com> Signed-off-by: Junhui Liu <junhui.liu@pigmoral.tech> Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com> Link: https://lore.kernel.org/r/20250110-dwc2-dev-v4-8-987f4fd6f8b2@pigmoral.tech Signed-off-by: Mattijs Korpershoek <mkorpershoek@kernel.org>
2025-06-02usb: dwc2: Unify flush and reset logic with v4.20a supportKongyang Liu
This patch merges flush and reset logic for both host and gadget code into a common set of functions, reducing duplication. It also adds support for the updated reset logic to compatible with core version since v4.20a. This patch mainly refers to the patch in the kernel. link: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=65dc2e725286106f99c6f6b78e3d9c52c15f3a9c Signed-off-by: Kongyang Liu <seashell11234455@gmail.com> Tested-by: Peter Robinson <pbrobinson@gmail.com> Signed-off-by: Junhui Liu <junhui.liu@pigmoral.tech> Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com> Reviewed-by: Marek Vasut <marex@denx.de> Link: https://lore.kernel.org/r/20250110-dwc2-dev-v4-7-987f4fd6f8b2@pigmoral.tech Signed-off-by: Mattijs Korpershoek <mkorpershoek@kernel.org>
2025-06-02usb: dwc2: Extract macro definitions to common headerKongyang Liu
Some macros are shared between host and gadget code, causing duplicated definitions. Move DWC2 macro definitions from host and gadget code into a common header to reduce duplication. Signed-off-by: Kongyang Liu <seashell11234455@gmail.com> Reviewed-by: Marek Vasut <marex@denx.de> Tested-by: Peter Robinson <pbrobinson@gmail.com> Signed-off-by: Junhui Liu <junhui.liu@pigmoral.tech> Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com> Link: https://lore.kernel.org/r/20250110-dwc2-dev-v4-6-987f4fd6f8b2@pigmoral.tech Signed-off-by: Mattijs Korpershoek <mkorpershoek@kernel.org>
2025-06-02usb: dwc2: Align macros with Linux kernel definitionsKongyang Liu
Update the DWC2 macros to match those used in the Linux kernel, making it easier to synchronize updates with kernel. Also removed some unused macros to cleanup the code. Signed-off-by: Kongyang Liu <seashell11234455@gmail.com> Reviewed-by: Marek Vasut <marex@denx.de> Tested-by: Peter Robinson <pbrobinson@gmail.com> Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com> Signed-off-by: Junhui Liu <junhui.liu@pigmoral.tech> Link: https://lore.kernel.org/r/20250110-dwc2-dev-v4-5-987f4fd6f8b2@pigmoral.tech Signed-off-by: Mattijs Korpershoek <mkorpershoek@kernel.org>
2025-06-02usb: dwc2: Clean up with bitfield macrosKongyang Liu
Use FIELD_PREP, FIELD_GET, BIT, and GENMASK macros to standardize bit manipulation across the DWC2 code, improving readability and maintainability without altering functionality. Signed-off-by: Kongyang Liu <seashell11234455@gmail.com> Reviewed-by: Marek Vasut <marex@denx.de> Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com> Tested-by: Peter Robinson <pbrobinson@gmail.com> Signed-off-by: Junhui Liu <junhui.liu@pigmoral.tech> Link: https://lore.kernel.org/r/20250110-dwc2-dev-v4-4-987f4fd6f8b2@pigmoral.tech Signed-off-by: Mattijs Korpershoek <mkorpershoek@kernel.org>
2025-06-02usb: dwc2: Fix HBstLen setting for external DMA modeKongyang Liu
The loop used to calculate HBstLen for extern DMA mode does not produce the correct result according to the datasheet [1]. Replacing that loop with a direct calculation using LOG2 to correctly assign the burst length in the GAHBCFG register for external DMA mode. [1] https://rockchip.fr/RK312X%20TRM/chapter-26-usb-otg-2-0.pdf#page=24 Signed-off-by: Kongyang Liu <seashell11234455@gmail.com> Reviewed-by: Marek Vasut <marex@denx.de> Tested-by: Peter Robinson <pbrobinson@gmail.com> Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com> Signed-off-by: Junhui Liu <junhui.liu@pigmoral.tech> Link: https://lore.kernel.org/r/20250110-dwc2-dev-v4-3-987f4fd6f8b2@pigmoral.tech Signed-off-by: Mattijs Korpershoek <mkorpershoek@kernel.org>
2025-06-02usb: dwc2: Fix incorrect ULPI_UTMI_SEL bit settingJunhui Liu
The ULPI_UTMI_SEL bit in the DWC2 driver was set incorrectly. According to the datasheet [1], this bit should be set to 0 for UTMI interface and 1 for ULPI interface. The existing code had this logic reversed, causing the interface selection to be incorrect. This commit corrects the ULPI_UTMI_SEL bit setting to match the datasheet's description. Referencing the kernel's code [2] also confirms this fix. [1] https://rockchip.fr/RK312X%20TRM/chapter-26-usb-otg-2-0.pdf#page=30 [2] https://github.com/torvalds/linux/blob/v6.13-rc3/drivers/usb/dwc2/core.c#L1106 Reviewed-by: Marek Vasut <marex@denx.de> Tested-by: Peter Robinson <pbrobinson@gmail.com> Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com> Signed-off-by: Junhui Liu <junhui.liu@pigmoral.tech> Link: https://lore.kernel.org/r/20250110-dwc2-dev-v4-2-987f4fd6f8b2@pigmoral.tech Signed-off-by: Mattijs Korpershoek <mkorpershoek@kernel.org>
2025-06-02usb: dwc2: Extract register definitions to common header fileKongyang Liu
The same registers are accessed in both the otg and gatet drivers of dwc2, and these registers are repeatedly defined in these two parts. Extract register definitions into a common header file to reduce redundancy and make the code more maintainable. Signed-off-by: Kongyang Liu <seashell11234455@gmail.com> Reviewed-by: Marek Vasut <marex@denx.de> Tested-by: Peter Robinson <pbrobinson@gmail.com> Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com> Signed-off-by: Junhui Liu <junhui.liu@pigmoral.tech> Link: https://lore.kernel.org/r/20250110-dwc2-dev-v4-1-987f4fd6f8b2@pigmoral.tech Signed-off-by: Mattijs Korpershoek <mkorpershoek@kernel.org>
2025-05-25usb: ulpi: Clean up how we enable supportTom Rini
The way we enable ULPI support today isn't something that should work. The "optional" keyword in a choice statement is not a documented feature. To make this work in a supported way, make USB_ULPI something we ask about if USB_HOST is set. Next, we move the choice of what viewer to use to be after the framework portion and to depend on that. We then borrow a few words from the top-level README to make the help text here clearer. Finally we make the Qualcomm driver select ULPI as it's required and we make the tegra driver not duplicate a check that Kconfig now handles for us. Signed-off-by: Tom Rini <trini@konsulko.com>
2025-05-25usb: ulpi: Remove unused omap-ulpi-viewport driverTom Rini
The last platform to enable this driver was removed in 2019. Remove this unused code and documentation now. Signed-off-by: Tom Rini <trini@konsulko.com>
2025-05-25usb: dwc3: core: Fix timeout checkVaradarajan Narayanan
dwc3_core_init loops 'timeout' times to check if the IP block is out of reset using 'while (timeout--)'. If there is some issue and the block doesn't come out of reset, the loop will run till 'timeout' becomes zero and the post decrement operator would set timeout to 0xffffffff. Though the IP block is not out reset, the subsequent if check 'if !timeout' would fail as timeout is not equal to zero and the function proceeds with the initialization. Use poll API instead to resolve this. Signed-off-by: Varadarajan Narayanan <quic_varada@quicinc.com> Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com> Reviewed-by: Caleb Connolly <caleb.connolly@linaro.org>
2025-04-24Merge tag 'u-boot-dfu-20250424' of ↵Tom Rini
https://source.denx.de/u-boot/custodians/u-boot-dfu u-boot-dfu-20250425 Usb gadget: - Fix ACM gadget release - Allow ACM gadget restart after releasing it - Add 'enabled' flag to usb_ep structure DFU: - Fix alt buffer clearing for DeveloperBox board
2025-04-23Merge patch series "Uthreads"Tom Rini
Jerome Forissier <jerome.forissier@linaro.org> says: This series introduces threads and uses them to improve the performance of the USB bus scanning code and to implement background jobs in the shell via two new commands: 'spawn' and 'wait'. The threading framework is called 'uthread' and is inspired from the barebox threads [2]. setjmp() and longjmp() are used to save and restore contexts, as well as a non-standard extension called initjmp(). This new function is added in several patches, one for each architecture that supports HAVE_SETJMP. A new symbol is defined: HAVE_INITJMP. Two tests, one for initjmp() and one for the uthread scheduling, are added to the lib suite. After introducing threads and making schedule() and udelay() a thread re-scheduling point, the USB stack initialization is modified to benefit from concurrency when UTHREAD is enabled, where uthreads are used in usb_init() to initialize and scan multiple busses at the same time. The code was tested on arm64 and arm QEMU with 4 simulated XHCI buses and some devices. On this platform the USB scan takes 2.2 s instead of 5.6 s. Tested on i.MX93 EVK with two USB hubs, one ethernet adapter and one webcam on each, "usb start" takes 2.4 s instead of 4.6 s. Finally, the spawn and wait commands are introduced, allowing the use of threads from the shell. Tested on the i.MX93 EVK with a spinning HDD connected to USB1 and the network connected to ENET1. The USB plus DHCP init sequence "spawn usb start; spawn dhcp; wait" takes 4.5 seconds instead of 8 seconds for "usb start; dhcp". [1] https://patchwork.ozlabs.org/project/uboot/list/?series=446674 [2] https://github.com/barebox/barebox/blob/master/common/bthread.c Link: https://lore.kernel.org/r/20250418141114.2056981-1-jerome.forissier@linaro.org
2025-04-23dm: usb: initialize and scan multiple buses simultaneously with uthreadJerome Forissier
Use the uthread framework to initialize and scan USB buses in parallel for better performance. The console output is slightly modified with a final per-bus report of the number of devices found, common to UTHREAD and !UTHREAD. The USB tests are updated accordingly. Tested on two platforms: 1. arm64 QEMU on a somewhat contrived example (4 USB buses, each with one audio device, one keyboard, one mouse and one tablet) $ make qemu_arm64_defconfig $ make -j$(nproc) CROSS_COMPILE="ccache aarch64-linux-gnu-" $ qemu-system-aarch64 -M virt -nographic -cpu max -bios u-boot.bin \ $(for i in {1..4}; do echo -device qemu-xhci,id=xhci$i \ -device\ usb-{audio,kbd,mouse,tablet},bus=xhci$i.0; \ done) 2. i.MX93 EVK (imx93_11x11_evk_defconfig) with two USB hubs, each with one webcam and one ethernet adapter, resulting in the following device tree: USB device tree: 1 Hub (480 Mb/s, 0mA) | u-boot EHCI Host Controller | +-2 Hub (480 Mb/s, 100mA) | GenesysLogic USB2.1 Hub | +-3 Vendor specific (480 Mb/s, 350mA) | Realtek USB 10/100/1000 LAN 001000001 | +-4 (480 Mb/s, 500mA) HD Pro Webcam C920 8F7CD51F 1 Hub (480 Mb/s, 0mA) | u-boot EHCI Host Controller | +-2 Hub (480 Mb/s, 100mA) | USB 2.0 Hub | +-3 Vendor specific (480 Mb/s, 200mA) | Realtek USB 10/100/1000 LAN 000001 | +-4 (480 Mb/s, 500mA) Generic OnLan-CS30 201801010008 Note that i.MX was tested on top of the downstream repository [1] since USB doesn't work in the upstream master branch. [1] https://github.com/nxp-imx/uboot-imx/tree/lf-6.6.52-2.2.0 commit 6c4545203d12 ("LF-13928 update key for capsule") The time spent in usb_init() ("usb start" command) is reported on the console. Here are the results: | CONFIG_UTHREAD=n | CONFIG_UTHREAD=y --------+------------------+----------------- QEMU | 5628 ms | 2212 ms i.MX93 | 4591 ms | 2441 ms Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
2025-04-23dm: usb: move bus initialization into new static function usb_init_bus()Jerome Forissier
To prepare for the introduction of threads in the USB initialization sequence, move code out of usb_init() into a new helper function: usb_init_bus() and count the number of USB controllers initialized successfully by using the DM device_active() function. Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
2025-04-23arch: arm: rockchip: Add initial support for RK3528Jonas Karlman
Rockchip RK3528 is a ARM-based SoC with quad-core Cortex-A53. Add initial arch support for the RK3528 SoC. Signed-off-by: Jonas Karlman <jonas@kwiboo.se> Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
2025-04-23usb: gadget: f_acm: Allow restarting ACM console after stopping itStephan Gerhold
When using IOMUX, the "usbacm" console can be added/removed dynamically from the stdout/stderr/stdin environment variables to allow temporarily starting other USB gadgets (e.g. Fastboot). However, right now acm_stdio_stop() does not completely undo acm_stdio_start(): The USB gadget is unregistered, but as long as dev->priv stays set acm_stdio_start() will never register the USB gadget again. Clear dev->priv after we detach to make sure a start operation after a stop operation registers the gadget again. Fixes: fc2b399ac03b ("usb: gadget: Add CDC ACM function") Signed-off-by: Stephan Gerhold <stephan.gerhold@linaro.org> Reviewed-by: Mattijs Korpershoek <mkorpershoek@kernel.org> Link: https://lore.kernel.org/r/20250407-acm-fixes-v1-2-e3dcb592d6d6@linaro.org Signed-off-by: Mattijs Korpershoek <mkorpershoek@kernel.org>
2025-04-23usb: gadget: f_acm: Claim requested USB endpointsStephan Gerhold
U-Boot has an older version of the Linux gadget API, where USB endpoints returned by usb_ep_autoconfig() are not automatically claimed. As written in the documentation comment: "To prevent the endpoint from being returned by a later autoconfig call, claim it by assigning ep->driver_data to some non-null value." Right now f_acm doesn't do that, which means that e.g. ep_in and ep_notify may end up being assigned the same endpoint. Surprisingly, the ACM console is still somehow working, but this is not the expected behavior. It will break with a later commit that disallows calling usb_ep_enable() multiple times. Fix this by assigning some data to ep->driver_data, similar to the other gadget drivers. Fixes: fc2b399ac03b ("usb: gadget: Add CDC ACM function") Signed-off-by: Stephan Gerhold <stephan.gerhold@linaro.org> Reviewed-by: Mattijs Korpershoek <mkorpershoek@kernel.org> Link: https://lore.kernel.org/r/20250407-acm-fixes-v1-1-e3dcb592d6d6@linaro.org Signed-off-by: Mattijs Korpershoek <mkorpershoek@kernel.org>
2025-04-11Merge patch series "Switch to using $(PHASE_) in Makefiles"Tom Rini
Tom Rini <trini@konsulko.com> says: This series switches to always using $(PHASE_) in Makefiles when building rather than $(PHASE_) or $(XPL_). It also starts on documenting this part of the build, but as a follow-up we need to rename doc/develop/spl.rst and expand on explaining things a bit. Link: https://lore.kernel.org/r/20250401225851.1125678-1-trini@konsulko.com
2025-04-11Kbuild: Always use $(PHASE_)Tom Rini
It is confusing to have both "$(PHASE_)" and "$(XPL_)" be used in our Makefiles as part of the macros to determine when to do something in our Makefiles based on what phase of the build we are in. For consistency, bring this down to a single macro and use "$(PHASE_)" only. Signed-off-by: Tom Rini <trini@konsulko.com>
2025-04-10usb: gadget: atmel: Add SAM9X60 supportZixun LI
Compared to SAM9X5 the only difference is the DPRAM memory from the USB High Speed Device Port (UDPHS) hardware block was increased, so we can reuse the same endpoint data. Also add compatible "microchip,sam9x60-udc". Signed-off-by: Zixun LI <admin@hifiphile.com> Reviewed-by: Mattijs Korpershoek <mkorpershoek@kernel.org> Link: https://lore.kernel.org/r/20250331162611.1557759-2-admin@hifiphile.com Signed-off-by: Mattijs Korpershoek <mkorpershoek@kernel.org>
2025-04-10usb: gadget: f_mass_storage: Fix memory leak of fsg buffersMattijs Korpershoek
In fsg_common_init, we allocate some buffers via memalign(). However, these buffers are never freed. Because of that, we cannot call => ums command multiple times on boards with low memory (CONFIG_SYS_MALLOC_LEN=0x81000): => ums 0 mmc 2 UMS: LUN 0, dev mmc 2, hwpart 0, sector 0x0, count 0x3a3e000 |crq->brequest:0x0 CTRL+C - Operation aborted => ums 0 mmc 2 UMS: LUN 0, dev mmc 2, hwpart 0, sector 0x0, count 0x3a3e000 failed to start <NULL>: -12 g_dnl_register: failed!, error: -12 g_dnl_register failed Make sure the fsg buffers are freed when the gadget is unbound by calling fsg_common_release() in fsg_unbind(). Reported-by: Zixun LI <admin@hifiphile.com> Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com> Tested-by: Zixun LI <admin@hifiphile.com> # on SAM9X60 Link: https://lore.kernel.org/r/20250328-ums-gadget-leak-v1-4-3b677db99bde@baylibre.com Signed-off-by: Mattijs Korpershoek <mkorpershoek@kernel.org>
2025-04-10usb: gadget: f_mass_storage: Fix NULL dereference in fsg_add()Mattijs Korpershoek
fsg_common_init() can fail when memory is low. In that case, it returns PTR_ERR(). fsg_add() does not check for failure, and thus dereferences an invalid fsg_common later, which crashes. Verify if we receive an error from fsg_common_init() and handle it gracefully. Reported-by: Zixun LI <admin@hifiphile.com> Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com> Tested-by: Zixun LI <admin@hifiphile.com> # on SAM9X60 Link: https://lore.kernel.org/r/20250328-ums-gadget-leak-v1-3-3b677db99bde@baylibre.com Signed-off-by: Mattijs Korpershoek <mkorpershoek@kernel.org>
2025-04-10usb: gadget: f_mass_storage: Drop invalid kfree() in fsg_common_release()Mattijs Korpershoek
Boards with low memory (CONFIG_SYS_MALLOC_LEN=0x81000), can be crashed using the => ums command twice in row: => ums 0 mmc 2 UMS: LUN 0, dev mmc 2, hwpart 0, sector 0x0, count 0x3a3e000 |crq->brequest:0x0 CTRL+C - Operation aborted => ums 0 mmc 2 UMS: LUN 0, dev mmc 2, hwpart 0, sector 0x0, count 0x3a3e000 "Synchronous Abort" handler, esr 0x96000004, far 0xfffffffff2ea20f0 elr: 000000000102ea78 lr : 000000000105e028 (reloc) elr: 00000000f2f33a78 lr : 00000000f2f63028 x0 : 0000000100000000 x1 : 0000000100000000 x2 : 0000000000000000 x3 : fffffffff2ea20e0 x4 : 00000000f2fc9720 x5 : 00000000f2ea20e0 x6 : 00000000f2fc9730 x7 : 00000000f2ee4780 x8 : 000000000000003f x9 : 0000000000000004 x10: 0000000000000058 x11: 00000000000058c4 x12: 0000000000000000 x13: 00000000f2e60800 x14: 00000000f4ec0040 x15: 0000000000000000 x16: 00000000f2f62f2c x17: 0000000000c0c0c0 x18: 00000000f2e73e00 x19: 00000000f2ea2010 x20: 00000000fffffff4 x21: 00000000f2e9b500 x22: 00000000f2ea20f0 x23: 00000000f2ea2050 x24: 00000000f2f61eec x25: 00000000f2fcf000 x26: 00000000f2e9fcd0 x27: 0000000000000000 x28: 0000000000000000 x29: 00000000f2e60290 Code: d00004a6 911cc0c6 cb000063 8b000021 (f9400860) Resetting CPU ... This happens when fsg_common_init() fails to allocate memory and calls fsg_common_release(). fsg_common_release() then calls kfree() which frees common->luns. However, common->luns was never allocated via kmalloc/calloc(), resulting in a crash. Drop the invalid kfree. The memory from common->luns will be reclaimed when we kfree(common) later in fgs_common_release(). Reported-by: Zixun LI <admin@hifiphile.com> Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com> Tested-by: Zixun LI <admin@hifiphile.com> # on SAM9X60 Link: https://lore.kernel.org/r/20250328-ums-gadget-leak-v1-2-3b677db99bde@baylibre.com Signed-off-by: Mattijs Korpershoek <mkorpershoek@kernel.org>
2025-04-10usb: gadget: f_mass_storage: Remove kref structure useMattijs Korpershoek
The kref structure is locally to f_mass_storage and is not used anywhere beside in fsg_common_release(). Remove it and use struct fsg_common* instead. No functional change. Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com> Tested-by: Zixun LI <admin@hifiphile.com> # on SAM9X60 Link: https://lore.kernel.org/r/20250328-ums-gadget-leak-v1-1-3b677db99bde@baylibre.com Signed-off-by: Mattijs Korpershoek <mkorpershoek@kernel.org>
2025-04-10usb: dwc3: gadget: Fix excepts/expects typoMarek Vasut
Fix the excepts typo to expects , no functional change. Fixes: 0916053ebc56 ("usb: dwc3: gadget: Fix match_ep callback for NXP UUU tool") Signed-off-by: Marek Vasut <marex@denx.de> Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org> Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com> Link: https://lore.kernel.org/r/20250324143956.91791-1-marex@denx.de Signed-off-by: Mattijs Korpershoek <mkorpershoek@kernel.org>
2025-04-08Merge patch series "Annotate switch/case fallthrough cases"Tom Rini
Andre Przywara <andre.przywara@arm.com> says: C's implicit fallthrough behaviour in switch/case statements can lead to subtle bugs. Quite some while ago many compilers introduced warnings in those cases, requiring intentional fallthrough's to be annotated. So far we were not enabling that compiler option, so many ambiguities and some bugs in the code went unnoticed. This series adds the required annotations in code paths that the first stage of the U-Boot CI covers. There is a large number of cases left in the libbz2 code. The usage of switch/case is borderline insane there, labels are hidden in macros, and there are no breaks, but just goto's. Upstream still uses very similar code, without any annotations. I still am not 100% sure those are meant to fall through or not, and plan to do further investigations, but didn't want to hold the rest of the patches back. You can see for yourself by applying patch 18/18 and building for sandbox64, for instance. Because of this we cannot quite enable the warning in the Makefile yet, but those fixes are worth regardless, and be it to increase readability. Please note that those patches do not fix anything, really, they just add those fallthrough annotations, so the series is not really critical. Link: https://lore.kernel.org/r/20250327153313.2105227-1-andre.przywara@arm.com