summaryrefslogtreecommitdiff
path: root/drivers/usb
AgeCommit message (Collapse)Author
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
2025-04-08usb: xhci: annotate switch/case fallthrough properlyAndre Przywara
The USB XHCI code uses an implicit switch/case fallthrough to share code for handling full speed and low speed transfers. Add our "fallthrough;" statement-like macro before the second label in the XHCI code, to avoid a warning when GCC's -Wimplicit-fallthrough warning option is enabled. Signed-off-by: Andre Przywara <andre.przywara@arm.com> Reviewed-by: Tom Rini <trini@konsulko.com>
2025-04-08usb: ohci-hcd: annotate switch/case fallthroughAndre Przywara
The USB OCHI code uses an implicit switch/case fallthrough after checking for valid descriptor IDs. Add our "fallthrough;" statement-like macro before the default branch in the OHCI code, to avoid a warning when GCC's -Wimplicit-fallthrough warning option is enabled. Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2025-04-08gadget: f_thor: annotate switch/case fallthroughAndre Przywara
Even though we seem to catch POWEROFF and EFSCLEAR commands in the THOR protocol request handling, we ultimately do not seem to handle them (apart from sending a response), so those commands still print an error message. Annotate the switch/case fallthrough in this case, to make this clear to the compiler. Signed-off-by: Andre Przywara <andre.przywara@arm.com> Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
2025-04-03Merge patch series "membuff: Add tests and update to support a flag for ↵Tom Rini
empty/full" Simon Glass <sjg@chromium.org> says: The membuff implementation curently has no tests. It also assumes that head and tail can never correspond unless the buffer is empty. This series provides a compile-time flag to support a 'full' flag. It also adds some tests of the main routines. The data structure is also renamed to membuf which fits better with U-Boot. There may be some cases in the code which could be optimised a little, but the implementation is functional. Link: https://lore.kernel.org/r/20250318152059.1464369-1-sjg@chromium.org
2025-04-03membuf: Rename structSimon Glass
Rename the struct to match the function prefix and filenames. Signed-off-by: Simon Glass <sjg@chromium.org>
2025-04-03membuff: Rename functions to have membuf_ prefixSimon Glass
The double 'f' is not necessary and is a bit annoying as elsewhere in U-Boot we use 'buf'. Rename all the functions before it is used more widely. Signed-off-by: Simon Glass <sjg@chromium.org>
2025-03-24Merge tag 'v2025.04-rc5' into nextTom Rini
Prepare v2025.04-rc5
2025-03-21usb: dwc3: gadget: Fix match_ep callback for NXP UUU toolMarek Vasut
The UUU tool excepts the interrupt-in endpoint to be ep1in, otherwise it crashes. This is a result of the previous hard-coded EP setup in drivers/usb/gadget/epautoconf.c which did special-case EP allocation for SPL builds, and which was since converted to this callback, but without the special-case EP allocation in SPL part. This reinstates the SPL part in an isolated manner, only for NXP iMX SoCs, only for SPL builds, and only for the ep1in interrupt-in endpoint. Fixes: 1918b8010c32 ("usb: dwc3: gadget: Convert epautoconf workaround to match_ep callback") Signed-off-by: Marek Vasut <marex@denx.de> Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com> Link: https://lore.kernel.org/r/20250319220805.219001-1-marex@denx.de Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
2025-03-17usb: cdns: starfive: Add cdns USB driverMinda Chen
Add Starfive cdns USB3 wrapper driver. Signed-off-by: Minda Chen <minda.chen@starfivetech.com> Reviewed-by: Marek Vasut <marex@denx.de> Tested-by: E Shattow <lucent@gmail.com>
2025-03-17usb: cdns: starfive: Get dr mode from wrapper device dts nodeMinda Chen
Cdns core driver also get dr mode from wrapper devcie dts node to make it is same with Starfive cdns USB Linux kernel driver, Starfive 7110 OF_UPSTREAM is enabled Signed-off-by: Minda Chen <minda.chen@starfivetech.com> Reviewed-by: Marek Vasut <marex@denx.de>
2025-03-17usb: cdns3: Set USB PHY mode in cdns3_drd_update_mode()Minda Chen
USB PHY maybe need to set PHY mode in different USB dr mode. So translate USB PHY mode to generic PHY mode and call generic_phy_set_mode(). Signed-off-by: Minda Chen <minda.chen@starfivetech.com> Reviewed-by: Marek Vasut <marex@denx.de>
2025-03-12Merge patch series "drivers: Driver support for ADI SC5xx SoCs"Tom Rini
Greg Malysa <malysagreg@gmail.com> says: This series adds all of the supported peripheral drivers for the sc5xx series of SoCs from Analog Devices and other drivers that are used by the evaluation kits, such as a GPIO expander used by the EZLITE carrier boards. This series passes gitlab CI tests. Link: https://lore.kernel.org/r/20250226173150.13198-1-malysagreg@gmail.com
2025-03-12usb: musb-new: Add support for Analog Devices SC5xx SoCsNathan Barrett-Morrison
This adds support for the MUSB-based USB controller found in the Analog Devices SC57x and SC58x SoCs. Co-developed-by: Greg Malysa <malysagreg@gmail.com> Signed-off-by: Greg Malysa <malysagreg@gmail.com> Co-developed-by: Ian Roberts <ian.roberts@timesys.com> Signed-off-by: Ian Roberts <ian.roberts@timesys.com> Signed-off-by: Vasileios Bimpikas <vasileios.bimpikas@analog.com> Signed-off-by: Utsav Agarwal <utsav.agarwal@analog.com> Signed-off-by: Arturs Artamonovs <arturs.artamonovs@analog.com> Signed-off-by: Oliver Gaskell <Oliver.Gaskell@analog.com> Signed-off-by: Nathan Barrett-Morrison <nathan.morrison@timesys.com>
2025-03-10usb: gadget: Remove final remnants of CONFIG_USB_DEVICETom Rini
The lone user of the legacy USB device framework have been removed for some time. Remove the final parts of the code that were missed. Signed-off-by: Tom Rini <trini@konsulko.com> Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com> Link: https://lore.kernel.org/r/20250227205101.4127604-1-trini@konsulko.com Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
2025-02-11usb: dwc3-generic: Add STih407 supportPatrice Chotard
Add STi glue logic to manage the DWC3 HC on STiH407 SoC family. It configures the internal glue logic and syscfg registers. Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com> Cc: Marek Vasut <marex@denx.de> Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com> Link: https://lore.kernel.org/r/20250130163547.512990-6-patrice.chotard@foss.st.com Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>