summaryrefslogtreecommitdiff
path: root/drivers/usb/gadget
AgeCommit message (Collapse)AuthorFilesLines
2020-09-01fastboot: Fix fastboot reboot fail by changing functions orderyurii.pidhornyi1-2/+2
It was revealed that when the fastboot_tx_write_str function is called without the previously initialized fastboot_func->in_req->complete field, a copy of in_req will be sent to the I/O requests queue without an initialized field. Moving a piece of code with the initializing of the fastboot_func->in_req->complete field above transmit_tx allows to solve this problem. Fixes: 65c96757fe9 "usb: fastboot: Convert USB f_fastboot to shared fastboot" Signed-off-by: yurii.pidhornyi <yurii.pidhornyi@globallogic.com>
2020-09-01f_sdp: Change bInterval of interrupt endpoint to 3Sherry Sun1-2/+2
Since the USB HID limits the maximum bandwidth(3072) for interrupt endpoint transfers, when the bInterval set to 1, we can only support 3 boards to run sdp at the same time. In order to support more boards, change the bInterval of interrupt endpoint to 3, which will not affect the transmission speed. Reviewed-by: Ye Li <ye.li@nxp.com> Signed-off-by: Sherry Sun <sherry.sun@nxp.com> Signed-off-by: Peng Fan <peng.fan@nxp.com>
2020-09-01f_sdp: Add EP1_OUT as default data receive pipe in sdpSherry Sun1-16/+107
EP0 has been used to transfer file data in sdp before, but the max packetsize of ep0 is 64 bytes. So in order to improve the file transfer speed, here add the EP1_OUT interrupt endpoint which max packetsize is set to 1024 byte. After testing, it turns out that using ep1out is twice as fast as using ep0 while receiving data in sdp. Signed-off-by: Sherry Sun <sherry.sun@nxp.com> Reviewed-by: Ye Li <ye.li@nxp.com> Signed-off-by: Peng Fan <peng.fan@nxp.com>
2020-09-01f_sdp: Support searching and loading FIT or container imagePeng Fan1-12/+58
Add support to f_sdp to search and load iMX8 container image or iMX8M FIT image by new UUU command SDPV. When using the SDPV, the uuu will continue to send out data after first level boot loader used by ROM. This means uuu won't skip to the offset of the second boot loader, and the padding data before second boot loader will be sent out. So we have to search the FIT header or container header in the buffer that SDP received. Also change to more common method to exit f_sdp handler not depending on SPL_FIT_FOUND flag because container loader won't set this. Signed-off-by: Peng Fan <peng.fan@nxp.com>
2020-09-01f_sdp: Fix wrong usb request sizeYe Li1-1/+1
Because the buffer length of sdp usb request is 65, we have to allocate 65 bytes not 64 bytes. Otherwise there is potential buffer overflow. Signed-off-by: Ye Li <ye.li@nxp.com> Signed-off-by: Peng Fan <peng.fan@nxp.com> Reviewed-by: Lukasz Majewski <lukma@denx.de>
2020-09-01f_sdp: Add high speed endpoint descriptorYe Li1-2/+28
Add HS endpoint descriptor for SDP. So that we can use high speed endpoint, and the SDP device can send packet with 512 byte size. Signed-off-by: Ye Li <ye.li@nxp.com> Signed-off-by: Peng Fan <peng.fan@nxp.com> Reviewed-by: Lukasz Majewski <lukma@denx.de>
2020-09-01usb: max3420: add the gadget driverJassi Brar4-0/+890
MAX3420 implements FullSpeed USB Device over SPI. Another version MAX3421, also implements USB Host mode. This driver should be good for the device mode of max3421 as well. Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
2020-09-01fastboot: Add support for 'reboot fastboot' commandRoman Kovalivskyi1-0/+2
Android 10 adds support for dynamic partitions and in order to support this userspace fastboot must be used[1]. New tool fastbootd is included into recovery. Userspace fastboot works from recovery and is launched if: 1) - Dynamic partitioning is enabled 2) - Boot control block has 'boot-fastboot' value into command field The bootloader is expected to load and boot into the recovery image upon seeing boot-fastboot in the BCB command. Recovery then parses the BCB message and switches to fastbootd mode[2]. Please note that boot script is expected to handle 'boot-fastboot' command in BCB and load into recovery mode. Bootloader must support 'reboot fastboot' command which should reboot device into userspace fastboot to accomodate those changes[3]. Another command that bootloader must support[3] is 'reboot recovery'. This command should simply reboot device into recovery mode. [1] - https://source.android.com/devices/bootloader/fastbootd [2] - https://source.android.com/devices/bootloader/fastbootd#unified_fastboot_and_recovery [3] - https://source.android.com/devices/bootloader/fastbootd#modifications_to_the_bootloader Signed-off-by: Roman Kovalivskyi <roman.kovalivskyi@globallogic.com> Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com> Change-Id: I9d2bdc9a6f6f31ea98572fe155e1cc8341e9af76
2020-09-01usb: ci_udc: Add function to remove usb deviceYe Li1-0/+7
When unregister gadget driver in ci_udc, the usb device is not removed or stop. This causes next "usb start" fails to work. Add a new interface "usb_remove_ehci_gadget" in usb-uclass to remove the usb device for DM driver. Using "usb_lowlevel_stop" for non-DM driver. Signed-off-by: Ye Li <ye.li@nxp.com> Signed-off-by: Peng Fan <peng.fan@nxp.com>
2020-09-01usb: gadget: Fix controller index in UMSYe Li1-2/+4
The usb mass storage (f_mass_storage.c) uses fixed usb index 0, this causes problem while CDNS3 USB controller index is 1. Modify the API of fsg to pass the controller index. Reviewed-by: Jun Li <jun.li@nxp.com> Signed-off-by: Ye Li <ye.li@nxp.com> Signed-off-by: Peng Fan <peng.fan@nxp.com>
2020-08-14linux/compat.h: Add wait_event_timeout macroOleksandr Andrushchenko1-1/+0
Add wait_event_timeout - sleep until a condition gets true or a timeout elapses. This is a stripped version of the same from Linux kernel with the following u-boot specific modifications: - no wait queues supported - use u-boot timer to detect timeouts - check for Ctrl-C pressed during wait Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com> Signed-off-by: Anastasiia Lukianenko <anastasiia_lukianenko@epam.com> [trini: Drop atomic_read from gadget/ether.c as this has existed for a while and now causes problems] Signed-off-by: Tom Rini <trini@konsulko.com>
2020-07-17treewide: convert bd_t to struct bd_info by coccinelleMasahiro Yamada1-2/+2
The Linux coding style guide (Documentation/process/coding-style.rst) clearly says: It's a **mistake** to use typedef for structures and pointers. Besides, using typedef for structures is annoying when you try to make headers self-contained. Let's say you have the following function declaration in a header: void foo(bd_t *bd); This is not self-contained since bd_t is not defined. To tell the compiler what 'bd_t' is, you need to include <asm/u-boot.h> #include <asm/u-boot.h> void foo(bd_t *bd); Then, the include direcective pulls in more bloat needlessly. If you use 'struct bd_info' instead, it is enough to put a forward declaration as follows: struct bd_info; void foo(struct bd_info *bd); Right, typedef'ing bd_t is a mistake. I used coccinelle to generate this commit. The semantic patch that makes this change is as follows: <smpl> @@ typedef bd_t; @@ -bd_t +struct bd_info </smpl> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
2020-05-19common: Drop linux/bitops.h from common headerSimon Glass2-0/+2
Move this uncommon header out of the common header. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-05-19common: Drop linux/delay.h from common headerSimon Glass9-0/+9
Move this uncommon header out of the common header. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-05-19common: Drop linux/bug.h from common headerSimon Glass6-0/+6
Move this uncommon header out of the common header. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-05-19common: Drop log.h from common headerSimon Glass16-0/+16
Move this header out of the common header. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-05-19command: Remove the cmd_tbl_t typedefSimon Glass2-0/+2
We should not use typedefs in U-Boot. They cannot be used as forward declarations which means that header files must include the full header to access them. Drop the typedef and rename the struct to remove the _s suffix which is now not useful. This requires quite a few header-file additions. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-05-19common: Drop init.h from common headerSimon Glass1-0/+1
Move this uncommon header out of the common header. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-05-19common: Drop part.h from common headerSimon Glass2-0/+2
Move this uncommon header out of the common header. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-05-19common: Drop net.h from common headerSimon Glass1-0/+1
Move this header out of the common header. Network support is used in quite a few places but it still does not warrant blanket inclusion. Note that this net.h header itself has quite a lot in it. It could be split into the driver-mode support, functions, structures, checksumming, etc. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-05-14usb: gadget: g_dnl: add function g_dnl_set_productPatrick Delaunay1-0/+8
Add a function g_dnl_set_product to change the Product string used in USB enumeration in any command based on download gadget. If the function is called with NULL pointer, the product string is set to the default value (product[] = "USB download gadget"). Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com> Reviewed-by: Patrice Chotard <patrice.chotard@st.com>
2020-05-10Merge branch 'master' of git://git.denx.de/u-bootStefano Babic1-76/+17
2020-05-03usb: gadget: sdp: use CONFIG_SDP_LOADADDR as default load addressFrank Li2-2/+6
If SDP_WRITE and SDP_JUMP addr is zero, use CONFIG_SDP_LOADADDR as default address Signed-off-by: Frank Li <Frank.Li@nxp.com> Signed-off-by: Peng Fan <peng.fan@nxp.com>
2020-05-02usb: dwc2_udc_otg: use the phy bulk API to get physChunfeng Yun1-76/+17
Use the phy bulk API to get a group of phys Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com> Signed-off-by: Frank Wunderlich <frank-w@public-files.de> Reviewed-by: Weijie Gao <weijie.gao@mediatek.com>
2020-04-28usb: ether: avoid NULL check before free()Heinrich Schuchardt1-2/+1
free() checks if its argument is NULL. Do not duplicate this check. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-03-30usb: Migrate to support live DT for some driverKever Yang1-3/+2
Use ofnode_ instead of fdt_ APIs so that the drivers can support live DT. This patch updates usb_get_dr_mode() and usb_get_maximum_speed() to use ofnode as parameter instead of fdt offset. And all the drivers who use these APIs update to use live dt APIs at the same time. Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
2020-03-01gadget: f_thor: add missing line breaks for pr_err()Seung-Woo Kim1-12/+12
After the commit 9b643e312d52 ("treewide: replace with error() with pr_err()"), there are pr_err() usages without line break. Add missing line breaks for pr_err() used in f_thor. Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
2020-03-01dfu: Reset timeout in case of DFU requestAndy Shevchenko1-0/+5
In case dfu command is being executed with timeout option, the timer may expire in the middle of DFU operation. If there is DFU request coming, we may simple reset timeout value to prevent aborting of ongoing DFU operation. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Tested-by: Ferry Toth <ftoth@exalondelft.nl>
2020-02-19dma-mapping: move dma_map_(un)single() to <linux/dma-mapping.h>Masahiro Yamada1-1/+1
The implementation of dma_map_single() and dma_unmap_single() is exactly the same for all the architectures that support them. Factor them out to <linux/dma-mapping.h>, and make all drivers to include <linux/dma-mapping.h> instead of <asm/dma-mapping.h>. If we need to differentiate them for some architectures, we can move the generic definitions to <asm-generic/dma-mapping.h>. Add some comments to the helpers. The concept is quite similar to the DMA-API of Linux kernel. Drivers are agnostic about what is going on behind the scene. Just call dma_map_single() before the DMA, and dma_unmap_single() after it. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2020-02-19dma-mapping: fix the prototype of dma_unmap_single()Masahiro Yamada1-1/+1
dma_unmap_single() takes the dma address, not virtual address. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2020-02-06dm: core: Create a new header file for 'compat' featuresSimon Glass3-0/+3
At present dm/device.h includes the linux-compatible features. This requires including linux/compat.h which in turn includes a lot of headers. One of these is malloc.h which we thus end up including in every file in U-Boot. Apart from the inefficiency of this, it is problematic for sandbox which needs to use the system malloc() in some files. Move the compatibility features into a separate header file. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-02-06dm: core: Require users of devres to include the headerSimon Glass6-0/+7
At present devres.h is included in all files that include dm.h but few make use of it. Also this pulls in linux/compat which adds several more headers. Drop the automatic inclusion and require files to include devres themselves. This provides a good indication of which files use devres. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Anatolij Gustschin <agust@denx.de>
2020-01-29usb: dwc2_udc_otg: add bcm2835 SoC (Raspberry Pi4) supportMarek Szyprowski2-6/+8
Broadcom 2835 SoC requires special conversion of physical memory addresses for DMA purpose, so add needed wrappers to dwc2_udc_otg driver. Also extend the list of compatible devices with 'brcm,bcm2835-usb' entry. This allows to use USB gadget drivers (i.e. DFU) on Raspberry Pi4 boards. Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com> Reviewed-by: Lukasz Majewski <lukma@denx.de> Signed-off-by: Matthias Brugger <mbrugger@suse.com>
2020-01-17common: Rename and move source()Simon Glass1-1/+1
This function has a very generic name which does not adequately describe its purpose. Rename it and move it to image.h, since it relates to reading a script from an image. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-01-08usb: Drop use of BUG_ON() and WARN_ON()Simon Glass2-0/+8
These macros use __FILE__ which inserts the full path of the object file into U-Boot, thus increasing file size. Drop these usages. An older version of this patch was submitted here: http://patchwork.ozlabs.org/patch/1205784/ Signed-off-by: Simon Glass <sjg@chromium.org>
2019-12-03common: Move command functions out of common.hSimon Glass1-0/+1
Move these functions into the command.h header file which is a better fit. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Tom Rini <trini@konsulko.com>
2019-12-03common: Move ARM cache operations out of common.hSimon Glass3-0/+5
These functions are CPU-related and do not use driver model. Move them to cpu_func.h Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com> Reviewed-by: Tom Rini <trini@konsulko.com>
2019-12-03common: Move serial_printf() to the serial headerSimon Glass3-1/+4
Move this function header to serial.h since this function is clearly related to serial. The function itself stays in console.c since we don't have a single serial file. DM and non-DM each has a separate file so we would have to either create a new common serial file, or repeat the function in both serial.c and serial-uclass.c, neither of which seem worthwhile. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Tom Rini <trini@konsulko.com>
2019-11-24Merge tag 'u-boot-rockchip-20191124' of ↵Tom Rini1-0/+7
https://gitlab.denx.de/u-boot/custodians/u-boot-rockchip - Clean vid/pid in Kconfig and add fastboot for rk3399 - add 'u-boot, spl-fifo-mode' for mmc - Use FIT generator for rk3229 optee and rk3368 ATF - fan53555: add support for Silergy SYR82X and SYR83X
2019-11-23gadget: rockchip: Add rk3399 USB_GADGET_PRODUCT_NUMJagan Teki1-0/+1
Add 0x330c for rk3399 gadget product number. Tested-by: Levin Du <djw@t-chip.com.cn> Signed-off-by: Jagan Teki <jagan@amarulasolutions.com> Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
2019-11-23gadget: rockchip: Add rk3128 USB_GADGET_PRODUCT_NUMJagan Teki1-0/+1
Add 0x310c for rk3128 gadget product number. Tested-by: Levin Du <djw@t-chip.com.cn> Signed-off-by: Jagan Teki <jagan@amarulasolutions.com> Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
2019-11-23gadget: rockchip: USB_GADGET_PRODUCT_NUMJagan Teki1-0/+3
Rockchip support differnet or common gadget product number between Rockchip SoCs like, 0x310a - rk3036 0x320a - rk3229, rk3288 0x330a - rk3328 So, select them on Kconfig based on platform specific config defined.     This eventually drop the explicit configs defined in supporting board defconfig files. Tested-by: Levin Du <djw@t-chip.com.cn> Signed-off-by: Jagan Teki <jagan@amarulasolutions.com> Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
2019-11-23gadget: Select USB_GADGET_VENDOR_NUM for rockchipJagan Teki1-0/+1
Gadget vendor number, 0x2207 is common across all platfroms supported in Rockchip SoC. So, select the same number globally, if ARCH_ROCKCHIP. This eventually drop the explicit configs defined in supported board defconfig files. Tested-by: Levin Du <djw@t-chip.com.cn> Signed-off-by: Jagan Teki <jagan@amarulasolutions.com> Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
2019-11-23gadget: Select USB_GADGET_MANUFACTURER for rockchipJagan Teki1-0/+1
Select the gadget manufacturer as 'Rockchip' for all rockchip platform SoC's. This eventually drop the explicit defined added on supported board defconfig files. Tested-by: Levin Du <djw@t-chip.com.cn> Signed-off-by: Jagan Teki <jagan@amarulasolutions.com> Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
2019-11-22usb: dwc2: fix possible alignment issuesSimon Goldschmidt1-2/+2
Since upgrading to gcc9, warnings are issued: "taking address of packed member of ‘...’ may result in an unaligned pointer value" Fix this by converting dwc2_fifo_read to use unaligned access since packed structures may be on an unaligned address, depending on USB hardware. Signed-off-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
2019-11-22usb: composite: fix possible alignment issuesSimon Goldschmidt1-7/+18
Since upgrading to gcc9, warnings are issued: "taking address of packed member of ‘...’ may result in an unaligned pointer value" Fix this by converting two functions to use unaligned access since packed structures may be on an unaligned address, depending on USB hardware. Signed-off-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
2019-11-07usb: composite: add BOS descriptor support to composite frameworkT Karthik Reddy1-6/+55
To add usb-3.0 support to peripheral device add BOS & SS capability descriptors to gadget composite framework. Signed-off-by: T Karthik Reddy <t.karthik.reddy@xilinx.com> Signed-off-by: Siva Durga Prasad Paladugu <siva.durga.paladugu@xilinx.com> Signed-off-by: Michal Simek <michal.simek@xilinx.com> Reviewed-by: Roger Quadros <rogerq@ti.com>
2019-11-07usb: gadget: Add gadget_is_cdns3() macroVignesh Raghavendra1-0/+8
Add a new bcdDevice entry for Cadence USB gadget controller similar to other controller and add gadget_is_cdns3() macro as well. Signed-off-by: Vignesh Raghavendra <vigneshr@ti.com>
2019-11-07usb: udc: Introduce ->udc_set_speed() methodSherry Sun1-0/+23
This patch was copied from kernel commit: 67fdfda4a99ed. Sometimes, the gadget driver we want to run has max_speed lower than what the UDC supports. In such situations, UDC might want to make sure we don't try to connect on speeds not supported by the gadget driver because that will just fail. So here introduce a new optional ->udc_set_speed() method which can be implemented by interested UDC drivers to achieve this purpose. Signed-off-by: Sherry Sun <sherry.sun@nxp.com> Signed-off-by: Vignesh Raghavendra <vigneshr@ti.com>
2019-11-07usb: gadget: Add match_ep() op to usb_gadget_opsVignesh Raghavendra1-0/+3
Add match_ep() op to usb_gadget_ops similar to Linux kernel which is useful in finding a suitable ep match for the function driver. This will avoid adding more gadget_is_xxx() handling code to usb_ep_autoconfig(). Also sync usb_ep_caps struct thats is usually used in the match_ep() callback by the gadget controller driver Signed-off-by: Vignesh Raghavendra <vigneshr@ti.com>