Improvements for the dwc3_generic driver
Subsystems (6)
v4 cover Improvements for the dwc3_generic driver
This series aims at bringing improvements to the dwc3_generic driver so that it can be used by most of the platforms using the dwc3 controller.
I tested this on with DRA7 and AM57x platforms for both Peripheral and Host operations. The code to enable DM USB host & dev support for those platforms will be submitted in a separate series.
Michal Simek has tested this series:
" I have tested it on zcu100 with usb stick, usb to ethernet converter and also dfu.
Enhancements:
- use separate Kconfig option for DM USB Periphal and DM USB Host. This allow platforms to keep their non-DM USB peripheral code and use the DM USB host.
- fixes the bind/probe confusion in dwc3_generic. The probe is done when the USB device is first needed.
- handles PHYs when in the peripheral mode. The code to handle the PHYs is shared with the host side
- handles clock and reset
- bind host controller to the more generic driver 'xhci-dwc3'
Changes in v4:
- rebased on latest U-Boot
- renamed DM_USB_DEV as DM_USB_GADGET
- Add a new commit to create a new UCLASS for USB gadget drivers
Changes in v3:
- fixes bug dwc3_setup_phy(): the phy arrays wasn't returned. This was visible only when the device is removed.
- Stub the DWC3 PHY operations if CONFIG_IS_ENABLED(PHY) is false. This fixes all build issues but one (evb-rk3328).
- Fix build issue with evb-rk3328 by enabling CONFIG_USB_DWC3. This has little impact on the footprint and should not break the runtime as the xhci-rockchip driver has its own probe function. Nevertheless this was !!! NOT TESTED !!! by lack of hw
Changes in v2:
- Updated commit log
- Fixed typo in thordown.c
- select DM_USB_DEV by default for zynqmp platforms
Jean-Jacques Hiblot (10):
usb: gadget: Do not call board_usb_xxx() directly in USB gadget
drivers
usb: introduce a separate config option for DM USB device
usb: udc: implement DM versions of
usb_gadget_initialize()/_release()/_handle_interrupt()
dwc3_generic: do not probe the USB device driver when it's bound
dwc3: move phy operation to core.c
dm: usb: create a new UCLASS ID for USB gadget devices
configs: evb-rk3328: Enable CONFIG_USB_DWC3
dwc3-generic: Handle the PHYs, the clocks and the reset lines
dwc3-generic: Add select_dr_mode operation
usb: dwc3: Fix a compilation error with the edison defconfig
arch/arm/Kconfig | 2 + board/sunxi/board.c | 2 +- cmd/fastboot.c | 4 +- cmd/rockusb.c | 4 +- cmd/thordown.c | 4 +- cmd/usb_gadget_sdp.c | 4 +- cmd/usb_mass_storage.c | 4 +- common/dfu.c | 6 +- configs/evb-rk3328_defconfig | 1 + drivers/usb/Kconfig | 14 +++ drivers/usb/dwc3/Kconfig | 7 +- drivers/usb/dwc3/core.c | 89 ++++++++++++++- drivers/usb/dwc3/dwc3-generic.c | 208 ++++++++++++++++++++++++++++-------- drivers/usb/dwc3/ep0.c | 2 +- drivers/usb/gadget/ether.c | 40 ++----- drivers/usb/gadget/udc/Makefile | 4 + drivers/usb/gadget/udc/udc-core.c | 3 +- drivers/usb/gadget/udc/udc-uclass.c | 58 ++++++++++ drivers/usb/host/xhci-dwc3.c | 95 ++-------------- drivers/usb/musb-new/omap2430.c | 2 +- drivers/usb/musb-new/sunxi.c | 2 +- include/dm/uclass-id.h | 1 + include/dwc3-uboot.h | 19 ++++ include/linux/usb/gadget.h | 18 ++++ 24 files changed, 401 insertions(+), 192 deletions(-) create mode 100644 drivers/usb/gadget/udc/udc-uclass.c
Signature · 1 line
2.7.4
PATCH v4 1/10 usb: gadget: Do not call board_usb_xxx() directly in USB gadget drivers
Add 2 functions to wrap the calls to board_usb_init() and board_usb_cleanup().
This is a preparatory work for DM support for UDC drivers (DM_USB_GADGET).
---
Changes in v4: None
Changes in v3: None
Changes in v2:
- Updated commit log
- Fixed typo in thordown.c
cmd/fastboot.c | 4 ++-- cmd/rockusb.c | 4 ++-- cmd/thordown.c | 4 ++-- cmd/usb_gadget_sdp.c | 4 ++-- cmd/usb_mass_storage.c | 4 ++-- common/dfu.c | 6 +++--- drivers/usb/gadget/ether.c | 38 +++++--------------------------------- include/linux/usb/gadget.h | 10 ++++++++++ 8 files changed, 28 insertions(+), 46 deletions(-)
cmd/fastboot.c +2 -2
@@ -51,7 +51,7 @@ static int do_fastboot_usb(int argc, char *const argv[],return CMD_RET_FAILURE ; } - ret =board_usb_init (controller_index,USB_INIT_DEVICE ); + ret =usb_gadget_initialize (controller_index);if (ret) {pr_err ("USB init failed: %d\n" , ret);return CMD_RET_FAILURE ;
@@ -82,7 +82,7 @@ static int do_fastboot_usb(int argc, char *const argv[], exit:g_dnl_unregister ();g_dnl_clear_detach (); -board_usb_cleanup (controller_index,USB_INIT_DEVICE ); +usb_gadget_release (controller_index);return ret;#else
cmd/rockusb.c +2 -2
@@ -33,7 +33,7 @@ static int do_rockusb(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) dev_index =simple_strtoul (devnum,NULL ,0 );rockusb_dev_init (devtype, dev_index); - ret =board_usb_init (controller_index,USB_INIT_DEVICE ); + ret =usb_gadget_initialize (controller_index);if (ret) {printf ("USB init failed: %d\n" , ret);return CMD_RET_FAILURE ;
@@ -62,7 +62,7 @@ static int do_rockusb(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) exit:g_dnl_unregister ();g_dnl_clear_detach (); -board_usb_cleanup (controller_index,USB_INIT_DEVICE ); +usb_gadget_release (controller_index);return ret; }
cmd/thordown.c +2 -2
@@ -30,7 +30,7 @@ int do_thor_down(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) goto done;int controller_index =simple_strtoul (usb_controller,NULL ,0 ); - ret =board_usb_init (controller_index,USB_INIT_DEVICE ); + ret =usb_gadget_initialize (controller_index);if (ret) {pr_err ("USB init failed: %d\n" , ret); ret =CMD_RET_FAILURE ;
@@ -55,7 +55,7 @@ int do_thor_down(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) exit:g_dnl_unregister (); -board_usb_cleanup (controller_index,USB_INIT_DEVICE ); +usb_gadget_release (controller_index); done:dfu_free_entities ();
cmd/usb_gadget_sdp.c +2 -2
@@ -20,7 +20,7 @@ static int do_sdp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])char *usb_controller = argv[1 ];int controller_index =simple_strtoul (usb_controller,NULL ,0 ); -board_usb_init (controller_index,USB_INIT_DEVICE ); +usb_gadget_initialize (controller_index);g_dnl_clear_detach ();g_dnl_register ("usb_dnl_sdp" );
@@ -37,7 +37,7 @@ static int do_sdp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) exit:g_dnl_unregister (); -board_usb_cleanup (controller_index,USB_INIT_DEVICE ); +usb_gadget_release (controller_index);return ret; }
cmd/usb_mass_storage.c +2 -2
@@ -160,7 +160,7 @@ static int do_usb_mass_storage(cmd_tbl_t *cmdtp, int flag, controller_index = (unsigned int )(simple_strtoul ( usb_controller,NULL ,0 )); -if (board_usb_init (controller_index,USB_INIT_DEVICE )) { +if (usb_gadget_initialize (controller_index)) {pr_err ("Couldn't init USB controller.\n" ); rc =CMD_RET_FAILURE ; goto cleanup_ums_init;
@@ -231,7 +231,7 @@ static int do_usb_mass_storage(cmd_tbl_t *cmdtp, int flag, cleanup_register:g_dnl_unregister (); cleanup_board: -board_usb_cleanup (controller_index,USB_INIT_DEVICE ); +usb_gadget_release (controller_index); cleanup_ums_init:ums_fini ();
common/dfu.c +3 -3
@@ -23,9 +23,9 @@ int run_usb_dnl_gadget(int usbctrl_index, char *usb_dnl_gadget)bool dfu_reset = false;int ret, i =0 ; - ret =board_usb_init (usbctrl_index,USB_INIT_DEVICE ); + ret =usb_gadget_initialize (usbctrl_index);if (ret) { -pr_err ("board usb init failed\n" ); +pr_err ("usb_gadget_initialize failed\n" );return CMD_RET_FAILURE ; }g_dnl_clear_detach ();
@@ -84,7 +84,7 @@ int run_usb_dnl_gadget(int usbctrl_index, char *usb_dnl_gadget) } exit:g_dnl_unregister (); -board_usb_cleanup (usbctrl_index,USB_INIT_DEVICE ); +usb_gadget_release (usbctrl_index);if (dfu_reset)do_reset (NULL ,0 ,0 ,NULL );
drivers/usb/gadget/ether.c +5 -33
@@ -100,9 +100,6 @@ struct eth_dev {struct usb_gadget *gadget;struct usb_request *req;/* for control responses */ struct usb_request *stat_req;/* for cdc & rndis status */ -#if CONFIG_IS_ENABLED (DM_USB ) -struct udevice *usb_udev; -#endif u8 config;struct usb_ep *in_ep, *out_ep, *status_ep;
@@ -2336,40 +2333,17 @@ fail: }/*-------------------------------------------------------------------------*/ - -#if CONFIG_IS_ENABLED (DM_USB ) -int dm_usb_init (struct eth_dev *e_dev) -{ -struct udevice *dev =NULL ; -int ret; - - ret =uclass_first_device (UCLASS_USB_DEV_GENERIC , &dev); -if (!dev || ret) { -pr_err ("No USB device found\n" ); -return -ENODEV ; - } - - e_dev->usb_udev = dev; - -return ret; -} -#endif -static int _usb_eth_init (struct ether_priv *priv) {struct eth_dev *dev = &priv->ethdev;struct usb_gadget *gadget;unsigned long ts; +int ret;unsigned long timeout =USB_CONNECT_TIMEOUT ; -#if CONFIG_IS_ENABLED (DM_USB ) -if (dm_usb_init (dev)) { -pr_err ("USB ether not found\n" ); -return -ENODEV ; - } -#else -board_usb_init (0 ,USB_INIT_DEVICE ); -#endif + ret =usb_gadget_initialize (0 ); +if (ret) +return ret;/* Configure default mac-addresses for the USB ethernet device */ #ifdef CONFIG_USBNET_DEV_ADDR
@@ -2541,9 +2515,7 @@ void _usb_eth_halt(struct ether_priv *priv) }usb_gadget_unregister_driver (&priv->eth_driver); -#if !CONFIG_IS_ENABLED (DM_USB ) -board_usb_cleanup (0 ,USB_INIT_DEVICE ); -#endif +usb_gadget_release (0 ); }#ifndef CONFIG_DM_ETH
include/linux/usb/gadget.h +10 -0
@@ -19,6 +19,7 @@#define __LINUX_USB_GADGET_H#include <errno.h> +#include <usb.h> #include <linux/compat.h> #include <linux/list.h>
@@ -926,4 +927,13 @@ extern void usb_ep_autoconfig_reset(struct usb_gadget *);extern int usb_gadget_handle_interrupts (int index); +static inline int usb_gadget_initialize (int index) +{ +return board_usb_init (index,USB_INIT_DEVICE ); +} + +static inline int usb_gadget_release (int index) +{ +return board_usb_cleanup (index,USB_INIT_DEVICE ); +}#endif /* __LINUX_USB_GADGET_H */
Signature · 1 line
2.7.4
PATCH v4 2/10 usb: introduce a separate config option for DM USB device
In reply to Jean-Jacques HiblotUsing CONFIG_DM_USB for this purpose prevents using DM_USB for host and not for device.
---
Changes in v4:
- renamed DM_USB_DEV as DM_USB_GADGET
Changes in v3: None
Changes in v2:
- select DM_USB_DEV by default for zynqmp platforms
arch/arm/Kconfig | 2 ++ drivers/usb/Kconfig | 14 ++++++++++++++ drivers/usb/dwc3/core.c | 3 +-- drivers/usb/dwc3/dwc3-generic.c | 4 ++-- 4 files changed, 19 insertions(+), 4 deletions(-)
arch/arm/Kconfig +2 -0
@@ -917,6 +917,7 @@ config ARCH_ZYNQMP_R5 select DM_SERIAL select OF_CONTROL imply CMD_DM + imply DM_USB_GADGET config ARCH_ZYNQMP bool "Xilinx ZynqMP based platform"
@@ -933,6 +934,7 @@ config ARCH_ZYNQMP imply CMD_DM imply FAT_WRITE imply MP + imply DM_USB_GADGET config TEGRA bool "NVIDIA Tegra"
drivers/usb/Kconfig +14 -0
@@ -52,6 +52,20 @@ config SPL_DM_USB depends on DM_USB default y +config DM_USB_GADGET + bool "Enable driver model for USB Gadget" + depends on DM_USB + help + Enable driver model for USB Gadget (Peripheral + mode) + +config SPL_DM_USB_GADGET + bool "Enable driver model for USB Gadget in sPL" + depends on SPL_DM_USB + help + Enable driver model for USB Gadget in SPL + (Peripheral mode) + source "drivers/usb/host/Kconfig" source "drivers/usb/dwc3/Kconfig"
drivers/usb/dwc3/core.c +1 -2
@@ -789,8 +789,7 @@ MODULE_AUTHOR("Felipe Balbi <[email protected]>");MODULE_LICENSE ("GPL v2" );MODULE_DESCRIPTION ("DesignWare USB3 DRD Controller Driver" ); -#if CONFIG_IS_ENABLED (DM_USB ) - +#if CONFIG_IS_ENABLED (DM_USB_GADGET )int dwc3_init (struct dwc3 *dwc) {int ret;
drivers/usb/dwc3/dwc3-generic.c +2 -2
@@ -21,8 +21,7 @@#include "gadget.h" #include "linux-compat.h" -DECLARE_GLOBAL_DATA_PTR ; - +#if CONFIG_IS_ENABLED (DM_USB_GADGET )int usb_gadget_handle_interrupts (int index) {struct dwc3 *priv;
@@ -97,6 +96,7 @@ U_BOOT_DRIVER(dwc3_generic_peripheral) = { .priv_auto_alloc_size = sizeof(struct dwc3), .flags = DM_FLAG_ALLOC_PRIV_DMA, }; +#endif static int dwc3_generic_bind (struct udevice *parent) {
Signature · 1 line
2.7.4
PATCH v4 3/10 usb: udc: implement DM versions of usb_gadget_initialize()/_release()/_handle_interrupt()
In reply to Jean-Jacques HiblotWhen DM_USB_GADGET the platform code for the USB device must be replaced by calls to a USB device driver.
usb_gadget_initialize() probes the USB device driver. usb_gadget_release() removes the USB device driver.
---
Changes in v4: None
Changes in v3: None
Changes in v2: None
drivers/usb/dwc3/dwc3-generic.c | 14 ++----------- drivers/usb/gadget/udc/udc-core.c | 44 ++++++++++++++++++++++++++++++++++++++- include/linux/usb/gadget.h | 8 +++++++ 3 files changed, 53 insertions(+), 13 deletions(-)
drivers/usb/dwc3/dwc3-generic.c +2 -12
@@ -22,19 +22,9 @@#include "linux-compat.h" #if CONFIG_IS_ENABLED (DM_USB_GADGET ) -int usb_gadget_handle_interrupts (int index) +int dm_usb_gadget_handle_interrupts (struct udevice *dev) { -struct dwc3 *priv; -struct udevice *dev; -int ret; - - ret =uclass_first_device (UCLASS_USB_DEV_GENERIC , &dev); -if (!dev || ret) { -pr_err ("No USB device found\n" ); -return -ENODEV ; - } - - priv =dev_get_priv (dev); +struct dwc3 *priv =dev_get_priv (dev);dwc3_gadget_uboot_handle_interrupt (priv);
drivers/usb/gadget/udc/udc-core.c +43 -1
53 lines not on this page · raw message
include/linux/usb/gadget.h +8 -0
@@ -927,6 +927,12 @@ extern void usb_ep_autoconfig_reset(struct usb_gadget *);extern int usb_gadget_handle_interrupts (int index); +#if CONFIG_IS_ENABLED (DM_USB_GADGET ) +int usb_gadget_initialize (int index); +int usb_gadget_release (int index); +int dm_usb_gadget_handle_interrupts (struct udevice *dev); +#else +#include <usb.h> static inline int usb_gadget_initialize (int index) {return board_usb_init (index,USB_INIT_DEVICE );
@@ -936,4 +942,6 @@ static inline int usb_gadget_release(int index) {return board_usb_cleanup (index,USB_INIT_DEVICE ); } +#endif +#endif /* __LINUX_USB_GADGET_H */
Signature · 1 line
2.7.4
PATCH v4 4/10 dwc3_generic: do not probe the USB device driver when it's bound
In reply to Jean-Jacques HiblotThe driver will be probed when usb_gadget_initialize() is called.
---
Changes in v4: None
Changes in v3: None
Changes in v2: None
drivers/usb/dwc3/dwc3-generic.c | 7 ------- 1 file changed, 7 deletions(-)
drivers/usb/dwc3/dwc3-generic.c +0 -7
@@ -70,21 +70,14 @@ static int dwc3_generic_peripheral_ofdata_to_platdata(struct udevice *dev) return 0; } -static int dwc3_generic_peripheral_bind (struct udevice *dev) -{ -return device_probe (dev); -} -U_BOOT_DRIVER (dwc3_generic_peripheral) = { .name ="dwc3-generic-peripheral" , .id =UCLASS_USB_DEV_GENERIC , .ofdata_to_platdata = dwc3_generic_peripheral_ofdata_to_platdata, .probe = dwc3_generic_peripheral_probe, .remove = dwc3_generic_peripheral_remove, - .bind = dwc3_generic_peripheral_bind, .platdata_auto_alloc_size =sizeof (struct usb_platdata ), .priv_auto_alloc_size =sizeof (struct dwc3 ), - .flags =DM_FLAG_ALLOC_PRIV_DMA , };#endif
Signature · 1 line
2.7.4
PATCH v4 5/10 dwc3: move phy operation to core.c
In reply to Jean-Jacques HiblotThose operations can be used for peripheral operation as well as host operation.
# Conflicts:
# drivers/usb/dwc3/core.c
# drivers/usb/host/xhci-dwc3.c
---
Changes in v4: None
Changes in v3:
- fixes bug dwc3_setup_phy(): the phy arrays wasn't returned. This was visible only when the device is removed.
- Stub the DWC3 PHY operations if CONFIG_IS_ENABLED(PHY) is false. This fixes all build issues but one (evb-rk3328).
Changes in v2: None
drivers/usb/dwc3/core.c | 88 +++++++++++++++++++++++++++++++++++++++- drivers/usb/host/xhci-dwc3.c | 95 ++++---------------------------------------- include/dwc3-uboot.h | 19 +++++++++ 3 files changed, 112 insertions(+), 90 deletions(-)
drivers/usb/dwc3/core.c +86 -2
@@ -19,7 +19,7 @@#include <asm/dma-mapping.h> #include <linux/ioport.h> #include <dm.h> - +#include <generic-phy.h> #include <linux/usb/ch9.h> #include <linux/usb/gadget.h>
@@ -789,6 +789,91 @@ MODULE_AUTHOR("Felipe Balbi <[email protected]>");MODULE_LICENSE ("GPL v2" );MODULE_DESCRIPTION ("DesignWare USB3 DRD Controller Driver" ); +#if CONFIG_IS_ENABLED (PHY ) &&CONFIG_IS_ENABLED (DM_USB ) +int dwc3_setup_phy (struct udevice *dev,struct phy **array,int *num_phys) +{ +int i, ret, count; +struct phy *usb_phys; + +/* Return if no phy declared */ +if (!dev_read_prop (dev,"phys" ,NULL )) +return 0 ; + count =dev_count_phandle_with_args (dev,"phys" ,"#phy-cells" ); +if (count <=0 ) +return count; + + usb_phys =devm_kcalloc (dev, count,sizeof (struct phy ), +GFP_KERNEL ); +if (!usb_phys) +return -ENOMEM ; + +for (i =0 ; i < count; i++) { + ret =generic_phy_get_by_index (dev, i, &usb_phys[i]); +if (ret && ret != -ENOENT ) { +pr_err ("Failed to get USB PHY%d for %s\n" , + i, dev->name); +return ret; + } + } + +for (i =0 ; i < count; i++) { + ret =generic_phy_init (&usb_phys[i]); +if (ret) { +pr_err ("Can't init USB PHY%d for %s\n" , + i, dev->name); + goto phys_init_err; + } + } + +for (i =0 ; i < count; i++) { + ret =generic_phy_power_on (&usb_phys[i]); +if (ret) { +pr_err ("Can't power USB PHY%d for %s\n" , + i, dev->name); + goto phys_poweron_err; + } + } + + *array = usb_phys; + *num_phys = count; +return 0 ; + +phys_poweron_err: +for (i = count -1 ; i >=0 ; i--) +generic_phy_power_off (&usb_phys[i]); + +for (i =0 ; i < count; i++) +generic_phy_exit (&usb_phys[i]); + +return ret; + +phys_init_err: +for (; i >=0 ; i--) +generic_phy_exit (&usb_phys[i]); + +return ret; +} + +int dwc3_shutdown_phy (struct udevice *dev,struct phy *usb_phys,int num_phys) +{ +int i, ret; + +for (i =0 ; i < num_phys; i++) { +if (!generic_phy_valid (&usb_phys[i])) +continue ; + + ret =generic_phy_power_off (&usb_phys[i]); + ret |=generic_phy_exit (&usb_phys[i]); +if (ret) { +pr_err ("Can't shutdown USB PHY%d for %s\n" , + i, dev->name); + } + } + +return 0 ; +} +#endif +#if CONFIG_IS_ENABLED (DM_USB_GADGET )int dwc3_init (struct dwc3 *dwc) {
@@ -840,5 +925,4 @@ void dwc3_remove(struct dwc3 *dwc)dwc3_core_exit (dwc); kfree(dwc->mem); } -#endif
drivers/usb/host/xhci-dwc3.c +7 -88
125 lines not on this page · raw message
include/dwc3-uboot.h +19 -0
@@ -38,4 +38,23 @@ struct dwc3_device {int dwc3_uboot_init (struct dwc3_device *dev);void dwc3_uboot_exit (int index);void dwc3_uboot_handle_interrupt (int index); + +struct phy ; +#if CONFIG_IS_ENABLED (PHY ) &&CONFIG_IS_ENABLED (DM_USB ) +int dwc3_setup_phy (struct udevice *dev,struct phy **array,int *num_phys); +int dwc3_shutdown_phy (struct udevice *dev,struct phy *usb_phys,int num_phys); +#else +static inline int dwc3_setup_phy (struct udevice *dev,struct phy **array, +int *num_phys) +{ +return -ENOTSUPP ; +} + +static inline int dwc3_shutdown_phy (struct udevice *dev,struct phy *usb_phys, +int num_phys) +{ +return -ENOTSUPP ; +} +#endif +#endif /* __DWC3_UBOOT_H_ */
Signature · 1 line
2.7.4
PATCH v4 6/10 dm: usb: create a new UCLASS ID for USB gadget devices
In reply to Jean-Jacques HiblotUCLASS_USB_DEV_GENERIC was meant for USB devices connected to host controllers, not gadget devices.
Adding a new UCLASS for gadget devices alone.
Also move the generic DM code for USB gadgets in a separate file for clarity.
---
Changes in v4: None
Changes in v3: None
Changes in v2: None
board/sunxi/board.c | 2 +- drivers/usb/dwc3/dwc3-generic.c | 2 +- drivers/usb/gadget/ether.c | 2 +- drivers/usb/gadget/udc/Makefile | 4 +++ drivers/usb/gadget/udc/udc-core.c | 41 -------------------------- drivers/usb/gadget/udc/udc-uclass.c | 58 +++++++++++++++++++++++++++++++++++++ drivers/usb/musb-new/omap2430.c | 2 +- drivers/usb/musb-new/sunxi.c | 2 +- include/dm/uclass-id.h | 1 + 9 files changed, 68 insertions(+), 46 deletions(-) create mode 100644 drivers/usb/gadget/udc/udc-uclass.c
board/sunxi/board.c +1 -1
@@ -663,7 +663,7 @@ int g_dnl_board_usb_cable_connected(void)struct phy phy;int ret; - ret =uclass_get_device (UCLASS_USB_DEV_GENERIC ,0 , &dev); + ret =uclass_get_device (UCLASS_USB_GADGET_GENERIC ,0 , &dev);if (ret) {pr_err ("%s: Cannot find USB device\n" , __func__);return ret;
drivers/usb/dwc3/dwc3-generic.c +1 -1
@@ -72,7 +72,7 @@ static int dwc3_generic_peripheral_ofdata_to_platdata(struct udevice *dev)U_BOOT_DRIVER (dwc3_generic_peripheral) = { .name ="dwc3-generic-peripheral" , - .id =UCLASS_USB_DEV_GENERIC , + .id =UCLASS_USB_GADGET_GENERIC , .ofdata_to_platdata = dwc3_generic_peripheral_ofdata_to_platdata, .probe = dwc3_generic_peripheral_probe, .remove = dwc3_generic_peripheral_remove,
drivers/usb/gadget/ether.c +1 -1
@@ -2671,7 +2671,7 @@ int usb_ether_init(void)struct udevice *usb_dev;int ret; - ret =uclass_first_device (UCLASS_USB_DEV_GENERIC , &usb_dev); + ret =uclass_first_device (UCLASS_USB_GADGET_GENERIC , &usb_dev);if (!usb_dev || ret) {pr_err ("No USB device found\n" );return ret;
drivers/usb/gadget/udc/Makefile +4 -0
@@ -2,4 +2,8 @@ # # USB peripheral controller drivers +ifndef CONFIG_$(SPL_)DM_USB_GADGET obj-$(CONFIG_USB_DWC3_GADGET) += udc-core.o +endif + +obj-$(CONFIG_$(SPL_)DM_USB_GADGET) += udc-uclass.o udc-core.o
drivers/usb/gadget/udc/udc-core.c +0 -41
44 lines not on this page · raw message
drivers/usb/gadget/udc/udc-uclass.c new file +58 -0
58 lines not on this page · raw message
drivers/usb/musb-new/omap2430.c +1 -1
@@ -263,7 +263,7 @@ U_BOOT_DRIVER(omap2430_musb) = {#ifdef CONFIG_USB_MUSB_HOST .id = UCLASS_USB, #else - .id = UCLASS_USB_DEV_GENERIC, + .id = UCLASS_USB_GADGET_GENERIC, #endif .of_match = omap2430_musb_ids, .ofdata_to_platdata = omap2430_musb_ofdata_to_platdata,
drivers/usb/musb-new/sunxi.c +1 -1
@@ -535,7 +535,7 @@ U_BOOT_DRIVER(usb_musb) = {#ifdef CONFIG_USB_MUSB_HOST .id = UCLASS_USB, #else - .id = UCLASS_USB_DEV_GENERIC, + .id = UCLASS_USB_GADGET_GENERIC, #endif .of_match = sunxi_musb_ids, .probe = musb_usb_probe,
include/dm/uclass-id.h +1 -0
@@ -92,6 +92,7 @@ enum uclass_id {UCLASS_USB ,/* USB bus */ UCLASS_USB_DEV_GENERIC ,/* USB generic device */ UCLASS_USB_HUB ,/* USB hub */ +UCLASS_USB_GADGET_GENERIC ,/* USB generic device */ UCLASS_VIDEO ,/* Video or LCD device */ UCLASS_VIDEO_BRIDGE ,/* Video bridge, e.g. DisplayPort to LVDS */ UCLASS_VIDEO_CONSOLE, /* Text console driver for video device */
Signature · 1 line
2.7.4
PATCH v4 6/10 dm: usb: create a new UCLASS ID for USB gadget devices
Hi Jean-Jacques,
Quoted 16 lines · Jean-Jacques Hiblot
UCLASS_USB_DEV_GENERICwas meant for USB devices connected to host controllers, not gadget devices.
Adding a new UCLASS for gadget devices alone.Also move the generic DM code for USB gadgets in a separate file for clarity.
Signed-off-by Jean-Jacques Hiblot <[email protected]>---
Changes in v4: None
Changes in v3: None
Changes in v2: None
Quoted 11 lines
board/sunxi/board.c | 2 +- drivers/usb/dwc3/dwc3-generic.c | 2 +- drivers/usb/gadget/ether.c | 2 +- drivers/usb/gadget/udc/Makefile | 4 +++ drivers/usb/gadget/udc/udc-core.c | 41 -------------------------- drivers/usb/gadget/udc/udc-uclass.c | 58 +++++++++++++++++++++++++++++++++++++ drivers/usb/musb-new/omap2430.c | 2 +- drivers/usb/musb-new/sunxi.c | 2 +- include/dm/uclass-id.h | 1 + 9 files changed, 68 insertions(+), 46 deletions(-) create mode 100644 drivers/usb/gadget/udc/udc-uclass.c
We should have a test for this, with a sandbox driver for this uclass, as we have done for UCLASS_USB.
Regards,
Simon
PATCH v4 6/10 dm: usb: create a new UCLASS ID for USB gadget devices
In reply to Jean-Jacques HiblotQuoted 33 lines · Jean-Jacques Hiblot
UCLASS_USB_DEV_GENERICwas meant for USB devices connected to host controllers, not gadget devices.
Adding a new UCLASS for gadget devices alone.Also move the generic DM code for USB gadgets in a separate file for clarity.
Signed-off-by Jean-Jacques Hiblot <[email protected]>---
Changes in v4: None
Changes in v3: None
Changes in v2: Noneboard/sunxi/board.c | 2 +- drivers/usb/dwc3/dwc3-generic.c | 2 +- drivers/usb/gadget/ether.c | 2 +- drivers/usb/gadget/udc/Makefile | 4 +++ drivers/usb/gadget/udc/udc-core.c | 41 -------------------------- drivers/usb/gadget/udc/udc-uclass.c | 58 +++++++++++++++++++++++++++++++++++++ drivers/usb/musb-new/omap2430.c | 2 +- drivers/usb/musb-new/sunxi.c | 2 +- include/dm/uclass-id.h | 1 + 9 files changed, 68 insertions(+), 46 deletions(-) create mode 100644 drivers/usb/gadget/udc/udc-uclass.cboard/sunxi/board.c +0
-0
board/sunxi/board.c int g_dnl_board_usb_cable_connected(void) · line 666
Quoted 5 lines
board/sunxi/board.c +1
-1@@ -663,7 +663,7 @@ int g_dnl_board_usb_cable_connected(void)struct phy phy;int ret; - ret =uclass_get_device (UCLASS_USB_DEV_GENERIC ,0 , &dev); + ret =uclass_get_device (UCLASS_USB_GADGET_GENERIC ,0 , &dev);
This is breaking sunxi boards which uses gadget mode.
U-Boot 2019.01-rc2 (Dec 18 2018 - 17:31:53 +0530) Allwinner Technology
CPU: Allwinner H3 (SUN8I 1680) Model: Banana Pi BPI-M2-Plus DRAM: 1 GiB
Error binding driver 'sunxi-musb': -96
Some drivers failed to bind
Error binding driver 'generic_simple_bus': -96 Some drivers failed to bind
initcall sequence 7dfd127c failed at call 4a00c3a3 (err=-96) ### ERROR ### Please RESET the board ###
PATCH v4 6/10 dm: usb: create a new UCLASS ID for USB gadget devices
Quoted 48 lines · Jagan Teki
Quoted 33 lines · Jean-Jacques Hiblot
UCLASS_USB_DEV_GENERICwas meant for USB devices connected to host controllers, not gadget devices.
Adding a new UCLASS for gadget devices alone.Also move the generic DM code for USB gadgets in a separate file for clarity.
Signed-off-by Jean-Jacques Hiblot <[email protected]>---
Changes in v4: None
Changes in v3: None
Changes in v2: Noneboard/sunxi/board.c | 2 +- drivers/usb/dwc3/dwc3-generic.c | 2 +- drivers/usb/gadget/ether.c | 2 +- drivers/usb/gadget/udc/Makefile | 4 +++ drivers/usb/gadget/udc/udc-core.c | 41 -------------------------- drivers/usb/gadget/udc/udc-uclass.c | 58 +++++++++++++++++++++++++++++++++++++ drivers/usb/musb-new/omap2430.c | 2 +- drivers/usb/musb-new/sunxi.c | 2 +- include/dm/uclass-id.h | 1 + 9 files changed, 68 insertions(+), 46 deletions(-) create mode 100644 drivers/usb/gadget/udc/udc-uclass.cboard/sunxi/board.c +0
-0board/sunxi/board.c int g_dnl_board_usb_cable_connected(void) · line 666
Quoted 5 lines
board/sunxi/board.c +1
-1@@ -663,7 +663,7 @@ int g_dnl_board_usb_cable_connected(void)struct phy phy;int ret; - ret =uclass_get_device (UCLASS_USB_DEV_GENERIC ,0 , &dev); + ret =uclass_get_device (UCLASS_USB_GADGET_GENERIC ,0 , &dev);This is breaking sunxi boards which uses gadget mode.
U-Boot 2019.01-rc2 (Dec 18 2018 - 17:31:53 +0530) Allwinner Technology
CPU: Allwinner H3 (SUN8I 1680) Model: Banana Pi BPI-M2-Plus DRAM: 1 GiB
Quoted 6 lines
Error binding driver 'sunxi-musb': -96
Some drivers failed to bind
Error binding driver 'generic_simple_bus': -96 Some drivers failed to bind
initcall sequence7dfd127cfailed at call4a00c3a3(err=-96) ### ERROR ### Please RESET the board ###
I got a similar error when I tried to port the work done for the gadget mode to the omap2420 glue. I don't know if they're related, but the messages are the same (-96). I ended up just ignoring the generic device all together and used the #ifdef to load either host or gadget in the patch I submitted for the omap2430 glue. If this gets resolved, I might re-evaluate how I did the patch.
adam
Quoted 4 lines
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot
PATCH v4 6/10 dm: usb: create a new UCLASS ID for USB gadget devices
In reply to Jagan TekiQuoted 40 lines · Jagan Teki
Quoted 32 lines · Jean-Jacques Hiblot
UCLASS_USB_DEV_GENERICwas meant for USB devices connected to host controllers, not gadget devices.
Adding a new UCLASS for gadget devices alone.Also move the generic DM code for USB gadgets in a separate file for clarity.
Signed-off-by Jean-Jacques Hiblot <[email protected]>---
Changes in v4: None
Changes in v3: None
Changes in v2: Noneboard/sunxi/board.c | 2 +- drivers/usb/dwc3/dwc3-generic.c | 2 +- drivers/usb/gadget/ether.c | 2 +- drivers/usb/gadget/udc/Makefile | 4 +++ drivers/usb/gadget/udc/udc-core.c | 41 -------------------------- drivers/usb/gadget/udc/udc-uclass.c | 58 +++++++++++++++++++++++++++++++++++++ drivers/usb/musb-new/omap2430.c | 2 +- drivers/usb/musb-new/sunxi.c | 2 +- include/dm/uclass-id.h | 1 + 9 files changed, 68 insertions(+), 46 deletions(-)create mode 100644
drivers/usb/gadget/udc/udc-uclass.cboard/sunxi/board.c +0
-0board/sunxi/board.c int g_dnl_board_usb_cable_connected(void) · line 666
Quoted 5 lines
board/sunxi/board.c +1
-1@@ -663,7 +663,7 @@ int g_dnl_board_usb_cable_connected(void)struct phy phy;int ret; - ret =uclass_get_device (UCLASS_USB_DEV_GENERIC ,0 , &dev); + ret =uclass_get_device (UCLASS_USB_GADGET_GENERIC ,0 , &dev);This is breaking sunxi boards which uses gadget mode.
Quoted 7 lines
U-Boot 2019.01-rc2 (Dec 18 2018 - 17:31:53 +0530) Allwinner Technology
CPU: Allwinner H3 (SUN8I 1680) Model: Banana Pi BPI-M2-Plus DRAM: 1 GiBError binding driver 'sunxi-musb': -96 Some drivers failed to bind
Can you try with DM_USB_GADGET enabled ?
JJ
Quoted 5 lines
Error binding driver '
generic_simple_bus': -96 Some drivers failed to bind
initcall sequence7dfd127cfailed at call4a00c3a3(err=-96) ### ERROR ### Please RESET the board ###
PATCH v4 6/10 dm: usb: create a new UCLASS ID for USB gadget devices
Quoted 46 lines · Jean-Jacques Hiblot
Quoted 44 lines · Jagan Teki
Quoted 33 lines · Jean-Jacques Hiblot
UCLASS_USB_DEV_GENERICwas meant for USB devices connected to host controllers, not gadget devices.
Adding a new UCLASS for gadget devices alone.Also move the generic DM code for USB gadgets in a separate file for clarity.
Signed-off-by Jean-Jacques Hiblot <[email protected]>---
Changes in v4: None
Changes in v3: None
Changes in v2: Noneboard/sunxi/board.c | 2 +- drivers/usb/dwc3/dwc3-generic.c | 2 +- drivers/usb/gadget/ether.c | 2 +- drivers/usb/gadget/udc/Makefile | 4 +++ drivers/usb/gadget/udc/udc-core.c | 41 --------------------------
drivers/usb/gadget/udc/udc-uclass.c| 58
+++++++++++++++++++++++++++++++++++++
drivers/usb/musb-new/omap2430.c | 2 +- drivers/usb/musb-new/sunxi.c | 2 +- include/dm/uclass-id.h | 1 +9 files changed, 68 insertions(+), 46 deletions(-)create mode 100644
drivers/usb/gadget/udc/udc-uclass.cboard/sunxi/board.c +0
-0board/sunxi/board.c int g_dnl_board_usb_cable_connected(void) · line 666
Quoted 5 lines
board/sunxi/board.c +1
-1@@ -663,7 +663,7 @@ int g_dnl_board_usb_cable_connected(void) struct phy phy; int ret; - ret = uclass_get_device(UCLASS_USB_DEV_GENERIC, 0, &dev); + ret = uclass_get_device(UCLASS_USB_GADGET_GENERIC, 0, &dev);This is breaking sunxi boards which uses gadget mode.
U-Boot 2019.01-rc2 (Dec 18 2018 - 17:31:53 +0530) Allwinner Technology
Quoted 7 lines
Quoted 5 lines
CPU: Allwinner H3 (SUN8I 1680)
Model: Banana Pi BPI-M2-Plus
DRAM: 1 GiB
Error binding driver 'sunxi-musb': -96
Some drivers failed to bindCan you try with
DM_USB_GADGETenabled ?
The reasoning is that UCLASS_DRIVER(usb_gadget_generic) is defined if and only if DM_USB_GADGET is enabled.
Quoted 13 lines
JJ
Quoted 5 lines
Error binding driver '
generic_simple_bus': -96 Some drivers failed to bind
initcall sequence7dfd127cfailed at call4a00c3a3(err=-96) ### ERROR ### Please RESET the board ###_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot
PATCH v4 6/10 dm: usb: create a new UCLASS ID for USB gadget devices
Quoted 55 lines · Jean-Jacques Hiblot
Quoted 52 lines · Jean-Jacques Hiblot
Quoted 49 lines · Jagan Teki
Quoted 33 lines · Jean-Jacques Hiblot
UCLASS_USB_DEV_GENERICwas meant for USB devices connected to host controllers, not gadget devices.
Adding a new UCLASS for gadget devices alone.Also move the generic DM code for USB gadgets in a separate file for clarity.
Signed-off-by Jean-Jacques Hiblot <[email protected]>---
Changes in v4: None
Changes in v3: None
Changes in v2: Noneboard/sunxi/board.c | 2 +- drivers/usb/dwc3/dwc3-generic.c | 2 +- drivers/usb/gadget/ether.c | 2 +- drivers/usb/gadget/udc/Makefile | 4 +++ drivers/usb/gadget/udc/udc-core.c | 41 -------------------------- drivers/usb/gadget/udc/udc-uclass.c | 58 +++++++++++++++++++++++++++++++++++++ drivers/usb/musb-new/omap2430.c | 2 +- drivers/usb/musb-new/sunxi.c | 2 +- include/dm/uclass-id.h | 1 + 9 files changed, 68 insertions(+), 46 deletions(-)create mode 100644
drivers/usb/gadget/udc/udc-uclass.cboard/sunxi/board.c +0
-0board/sunxi/board.c int g_dnl_board_usb_cable_connected(void) · line 666
Quoted 5 lines
board/sunxi/board.c +1
-1@@ -663,7 +663,7 @@ int g_dnl_board_usb_cable_connected(void)struct phy phy;int ret; - ret =uclass_get_device (UCLASS_USB_DEV_GENERIC ,0 , &dev); + ret =uclass_get_device (UCLASS_USB_GADGET_GENERIC ,0 , &dev);This is breaking sunxi boards which uses gadget mode.
U-Boot 2019.01-rc2 (Dec 18 2018 - 17:31:53 +0530) Allwinner Technology
CPU: Allwinner H3 (SUN8I 1680) Model: Banana Pi BPI-M2-Plus DRAM: 1 GiBError binding driver 'sunxi-musb': -96 Some drivers failed to bind
Quoted 4 lines
Quoted 1 line
Can you try with
DM_USB_GADGETenabled ?The reasoning is that
UCLASS_DRIVER(usb_gadget_generic)is defined if and only ifDM_USB_GADGETis enabled.
I tried this when trying to port to the omap2430 glue, and got the same -96 error when using the MISC class driver and I enabled DM_USB_GADGET.
adam
Quoted 18 lines
Quoted 10 lines
JJ
Quoted 5 lines
Error binding driver '
generic_simple_bus': -96 Some drivers failed to bind
initcall sequence7dfd127cfailed at call4a00c3a3(err=-96) ### ERROR ### Please RESET the board ###Quoted 4 lines
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot
PATCH v4 7/10 configs: evb-rk3328: Enable CONFIG_USB_DWC3
In reply to Jean-Jacques HiblotThis is now required because the PHY operations used by xhci-dwc3 are part of the dwc3 core.
---
Changes in v4: None
Changes in v3:
- Fix build issue with evb-rk3328 by enabling CONFIG_USB_DWC3. This has little impact on the footprint and should not break the runtime as the xhci-rockchip driver has its own probe function. Nevertheless this was !!! NOT TESTED !!! by lack of hw
Changes in v2: None
configs/evb-rk3328_defconfig | 1 + 1 file changed, 1 insertion(+)
configs/evb-rk3328_defconfig +1 -0
@@ -49,6 +49,7 @@ CONFIG_BAUDRATE=1500000 CONFIG_DEBUG_UART_SHIFT=2 CONFIG_SYSRESET=y CONFIG_USB=y +CONFIG_USB_DWC3=y CONFIG_USB_XHCI_HCD=y CONFIG_USB_XHCI_DWC3=y CONFIG_USB_EHCI_HCD=y
Signature · 1 line
2.7.4
PATCH v4 8/10 dwc3-generic: Handle the PHYs, the clocks and the reset lines
In reply to Jean-Jacques HiblotThis make the driver more generic. At this point this driver can replace the dwc3-of-simple implementation.
Make the description in the Kconfig more generic too.
---
Changes in v4: None
Changes in v3: None
Changes in v2: None
drivers/usb/dwc3/Kconfig | 7 +- drivers/usb/dwc3/dwc3-generic.c | 159 +++++++++++++++++++++++++++++++++------- 2 files changed, 137 insertions(+), 29 deletions(-)
drivers/usb/dwc3/Kconfig +4 -3
@@ -38,10 +38,11 @@ config USB_DWC3_OMAP Say 'Y' here if you have one such device config USB_DWC3_GENERIC - bool "Xilinx ZynqMP and similar Platforms" - depends on DM_USB && USB_DWC3 + bool "Generic implementation of a DWC3 wrapper (aka dwc3 glue)" + depends on DM_USB && USB_DWC3 && MISC help - Some platforms can reuse this DWC3 generic implementation. + Select this for Xilinx ZynqMP and similar Platforms. + This wrapper supports Host and Peripheral operation modes. config USB_DWC3_UNIPHIER bool "DesignWare USB3 Host Support on UniPhier Platforms"
drivers/usb/dwc3/dwc3-generic.c +133 -26
245 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v4 9/10 dwc3-generic: Add select_dr_mode operation
In reply to Jean-Jacques HiblotThe select_dr_mode operation is executed when the glue driver is probed. The role of this optional function is to configure the operating mode of the controller at the glue level.
---
Changes in v4: None
Changes in v3: None
Changes in v2: None
drivers/usb/dwc3/dwc3-generic.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)
drivers/usb/dwc3/dwc3-generic.c +26 -0
@@ -8,6 +8,7 @@*/ #include <common.h> +#include <asm-generic/io.h> #include <dm.h> #include <dm/device-internal.h> #include <dm/lists.h>
@@ -110,6 +111,12 @@ U_BOOT_DRIVER(dwc3_generic_peripheral) = {struct dwc3_glue_data {struct clk_bulk clks;struct reset_ctl_bulk resets; +fdt_addr_t regs; +}; + +struct dwc3_glue_ops { +void (*select_dr_mode)(struct udevice *dev,int index, +enum usb_dr_mode mode); };static int dwc3_glue_bind (struct udevice *parent)
@@ -205,9 +212,14 @@ static int dwc3_glue_clk_init(struct udevice *dev,static int dwc3_glue_probe (struct udevice *dev) { +struct dwc3_glue_ops *ops = (struct dwc3_glue_ops *)dev_get_driver_data (dev);struct dwc3_glue_data *glue =dev_get_platdata (dev); +struct udevice *child =NULL ; +int index =0 ;int ret; + glue->regs =dev_read_addr (dev); + ret =dwc3_glue_clk_init (dev, glue);if (ret)return ret;
@@ -216,6 +228,20 @@ static int dwc3_glue_probe(struct udevice *dev)if (ret)return ret; + ret =device_find_first_child (dev, &child); +if (ret) +return ret; + +while (child) { +enum usb_dr_mode dr_mode; + + dr_mode =usb_get_dr_mode (dev_of_offset (child)); +device_find_next_child (&child); +if (ops && ops->select_dr_mode) + ops->select_dr_mode (dev, index, dr_mode); + index++; + } +return 0 ; }
Signature · 1 line
2.7.4
PATCH v4 10/10 usb: dwc3: Fix a compilation error with the edison defconfig
In reply to Jean-Jacques HiblotThe error is:
In file included from include/part.h:10:0,
from include/usb.h:18,
from include/linux/usb/gadget.h:22,
from drivers/usb/dwc3/ep0.c:20:include/ide.h:62:14: error: unknown type name ‘uchar’
void ide_led(uchar led, uchar status);
Fixing it by including common.h that defines the uchar type.
---
Changes in v4: None
Changes in v3: None
Changes in v2: None
drivers/usb/dwc3/ep0.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/dwc3/ep0.c +1 -1
@@ -12,7 +12,7 @@* * commit c00552ebaf : Merge 3.18-rc7 into usb-next */ - +#include <common.h> #include <linux/kernel.h> #include <linux/list.h>
Signature · 1 line
2.7.4
v4 cover Improvements for the dwc3_generic driver
In reply to Jean-Jacques HiblotHi,
I re-tested this series on Khadas VIM1 and it still fix the USB issue I had with 'usb reset' (I already tested v2 patches).
I just have a message and I'm not sure that I had it last time:
"Error disabling PHY supply
Can't shutdown USB PHY1 for dwc3 at c9000000"
But USB stack looks ok, I can plug/unplug USB key and do the reset, all works as expected.
Since my last test lot of changes has been done in Amlogic SoCs, maybe it's because of this?
So if you want you can add my tested-by flag.
Quoted 86 lines · Jean-Jacques Hiblot
This series aims at bringing improvements to the
dwc3_genericdriver so that it can be used by most of the platforms using the dwc3 controller.I tested this on with DRA7 and AM57x platforms for both Peripheral and Host operations. The code to enable DM USB host & dev support for those platforms will be submitted in a separate series.
Michal Simek has tested this series:
" I have tested it on zcu100 with usb stick, usb to ethernet converter and also dfu.Tested-by Michal Simek <[email protected]>"Enhancements:
- use separateKconfigoption for DM USB Periphal and DM USB Host. This allow platforms to keep their non-DM USB peripheral code and use the DM USB host.
- fixes the bind/probe confusion indwc3_generic. The probe is done when the USB device is first needed.
- handles PHYs when in the peripheral mode. The code to handle the PHYs is shared with the host side
- handles clock and reset
- bind host controller to the more generic driver 'xhci-dwc3'Changes in v4:
- rebased on latest U-Boot
- renamedDM_USB_DEVasDM_USB_GADGET
- Add a new commit to create a new UCLASS for USB gadget driversChanges in v3:
- fixes bugdwc3_setup_phy(): the phy arrays wasn't returned. This was visible only when the device is removed.
- Stub the DWC3 PHY operations ifCONFIG_IS_ENABLED(PHY)is false. This fixes all build issues but one (evb-rk3328).
- Fix build issue with evb-rk3328 by enablingCONFIG_USB_DWC3. This has little impact on the footprint and should not break the runtime as the xhci-rockchip driver has its own probe function. Nevertheless this was !!! NOT TESTED !!! by lack of hwChanges in v2:
- Updated commit log
- Fixed typo inthordown.c
- selectDM_USB_DEVby default for zynqmp platformsJean-Jacques Hiblot (10):
usb: gadget: Do not callboard_usb_xxx()directly in USB gadget
drivers
usb: introduce a separate config option for DM USB device
usb: udc: implement DM versions of
usb_gadget_initialize()/_release()/_handle_interrupt()
dwc3_generic: do not probe the USB device driver when it's bound
dwc3: move phy operation tocore.c
dm: usb: create a new UCLASS ID for USB gadget devices
configs: evb-rk3328: EnableCONFIG_USB_DWC3
dwc3-generic: Handle the PHYs, the clocks and the reset lines
dwc3-generic: Addselect_dr_modeoperation
usb: dwc3: Fix a compilation error with the edison defconfigarch/arm/Kconfig | 2 + board/sunxi/board.c | 2 +- cmd/fastboot.c | 4 +- cmd/rockusb.c | 4 +- cmd/thordown.c | 4 +- cmd/usb_gadget_sdp.c | 4 +- cmd/usb_mass_storage.c | 4 +- common/dfu.c | 6 +- configs/evb-rk3328_defconfig | 1 + drivers/usb/Kconfig | 14 +++ drivers/usb/dwc3/Kconfig | 7 +- drivers/usb/dwc3/core.c | 89 ++++++++++++++- drivers/usb/dwc3/dwc3-generic.c | 208 ++++++++++++++++++++++++++++-------- drivers/usb/dwc3/ep0.c | 2 +- drivers/usb/gadget/ether.c | 40 ++----- drivers/usb/gadget/udc/Makefile | 4 + drivers/usb/gadget/udc/udc-core.c | 3 +- drivers/usb/gadget/udc/udc-uclass.c | 58 ++++++++++ drivers/usb/host/xhci-dwc3.c | 95 ++-------------- drivers/usb/musb-new/omap2430.c | 2 +- drivers/usb/musb-new/sunxi.c | 2 +- include/dm/uclass-id.h | 1 + include/dwc3-uboot.h | 19 ++++ include/linux/usb/gadget.h | 18 ++++ 24 files changed, 401 insertions(+), 192 deletions(-) create mode 100644 drivers/usb/gadget/udc/udc-uclass.c
Signature · 15 lines
Loic Devulder <[email protected]> | ldevulder at irc 0x175A963893C85F55 | D220 DEF5 56A3 DE00 9DAA 78BA 175A 9638 93C8 5F55 Senior QA Engineer | Container & Storage Solutions Quality Assurance team (qa-css) SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nuernberg, Germany GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton HRB, 21284 (AG Nuernberg) -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 488 bytes Desc: OpenPGP digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181206/becb48b3/attachment.sig>
v4 cover Improvements for the dwc3_generic driver
Quoted 9 lines · Loic Devulder
Hi,
I re-tested this series on Khadas VIM1 and it still fix the USB issue I had with 'usb reset' (I already tested v2 patches).
I just have a message and I'm not sure that I had it last time:
"Error disabling PHY supply
Can't shutdown USB PHY1 for dwc3 atc9000000"
Quoted 8 lines
But USB stack looks ok, I can plug/unplug USB key and do the reset, all works as expected.
Since my last test lot of changes has been done in Amlogic SoCs, maybe it's because of this?
So if you want you can add my tested-by flag.
Tested-by Loic Devulder <[email protected]>
Thank you for testing
Quoted 87 lines · Jean-Jacques Hiblot
Quoted 85 lines
This series aims at bringing improvements to the
dwc3_genericdriver so that it can be used by most of the platforms using the dwc3 controller.I tested this on with DRA7 and AM57x platforms for both Peripheral and Host operations. The code to enable DM USB host & dev support for those platforms will be submitted in a separate series.
Michal Simek has tested this series:
" I have tested it on zcu100 with usb stick, usb to ethernet converter and also dfu.Tested-by Michal Simek <[email protected]>"Enhancements:
- use separateKconfigoption for DM USB Periphal and DM USB Host. This allow platforms to keep their non-DM USB peripheral code and use the DM USB host.
- fixes the bind/probe confusion indwc3_generic. The probe is done when the USB device is first needed.
- handles PHYs when in the peripheral mode. The code to handle the PHYs is shared with the host side
- handles clock and reset
- bind host controller to the more generic driver 'xhci-dwc3'Changes in v4:
- rebased on latest U-Boot
- renamedDM_USB_DEVasDM_USB_GADGET
- Add a new commit to create a new UCLASS for USB gadget driversChanges in v3:
- fixes bugdwc3_setup_phy(): the phy arrays wasn't returned. This was visible only when the device is removed.
- Stub the DWC3 PHY operations ifCONFIG_IS_ENABLED(PHY)is false. This fixes all build issues but one (evb-rk3328).
- Fix build issue with evb-rk3328 by enablingCONFIG_USB_DWC3. This has little impact on the footprint and should not break the runtime as the xhci-rockchip driver has its own probe function. Nevertheless this was !!! NOT TESTED !!! by lack of hwChanges in v2:
- Updated commit log
- Fixed typo inthordown.c
- selectDM_USB_DEVby default for zynqmp platformsJean-Jacques Hiblot (10):
usb: gadget: Do not callboard_usb_xxx()directly in USB gadget
drivers
usb: introduce a separate config option for DM USB device
usb: udc: implement DM versions of
usb_gadget_initialize()/_release()/_handle_interrupt()
dwc3_generic: do not probe the USB device driver when it's bound
dwc3: move phy operation tocore.c
dm: usb: create a new UCLASS ID for USB gadget devices
configs: evb-rk3328: EnableCONFIG_USB_DWC3
dwc3-generic: Handle the PHYs, the clocks and the reset lines
dwc3-generic: Addselect_dr_modeoperation
usb: dwc3: Fix a compilation error with the edison defconfigarch/arm/Kconfig | 2 + board/sunxi/board.c | 2 +- cmd/fastboot.c | 4 +- cmd/rockusb.c | 4 +- cmd/thordown.c | 4 +- cmd/usb_gadget_sdp.c | 4 +- cmd/usb_mass_storage.c | 4 +- common/dfu.c | 6 +- configs/evb-rk3328_defconfig | 1 + drivers/usb/Kconfig | 14 +++ drivers/usb/dwc3/Kconfig | 7 +- drivers/usb/dwc3/core.c | 89 ++++++++++++++- drivers/usb/dwc3/dwc3-generic.c | 208 ++++++++++++++++++++++++++++-------- drivers/usb/dwc3/ep0.c | 2 +- drivers/usb/gadget/ether.c | 40 ++----- drivers/usb/gadget/udc/Makefile | 4 + drivers/usb/gadget/udc/udc-core.c | 3 +- drivers/usb/gadget/udc/udc-uclass.c | 58 ++++++++++ drivers/usb/host/xhci-dwc3.c | 95 ++-------------- drivers/usb/musb-new/omap2430.c | 2 +- drivers/usb/musb-new/sunxi.c | 2 +- include/dm/uclass-id.h | 1 + include/dwc3-uboot.h | 19 ++++ include/linux/usb/gadget.h | 18 ++++ 24 files changed, 401 insertions(+), 192 deletions(-)create mode 100644
drivers/usb/gadget/udc/udc-uclass.c
v4 cover Improvements for the dwc3_generic driver
Quoted 108 lines · Jean-Jacques Hiblot
Quoted 9 lines · Loic Devulder
Hi,
I re-tested this series on Khadas VIM1 and it still fix the USB issue I had with 'usb reset' (I already tested v2 patches).
I just have a message and I'm not sure that I had it last time:
"Error disabling PHY supply
Can't shutdown USB PHY1 for dwc3 atc9000000"Quoted 8 lines
But USB stack looks ok, I can plug/unplug USB key and do the reset, all works as expected.
Since my last test lot of changes has been done in Amlogic SoCs, maybe it's because of this?
So if you want you can add my tested-by flag.
Tested-by Loic Devulder <[email protected]>Thank you for testing
Quoted 79 lines · Jean-Jacques Hiblot
Quoted 77 lines
This series aims at bringing improvements to the
dwc3_genericdriver so that it can be used by most of the platforms using the dwc3 controller.I tested this on with DRA7 and AM57x platforms for both Peripheral and Host operations. The code to enable DM USB host & dev support for those platforms will be submitted in a separate series.
Michal Simek has tested this series:
" I have tested it on zcu100 with usb stick, usb to ethernet converter and also dfu.Tested-by Michal Simek <[email protected]>"Enhancements:
- use separateKconfigoption for DM USB Periphal and DM USB Host. This allow platforms to keep their non-DM USB peripheral code and use the DM USB host.
- fixes the bind/probe confusion indwc3_generic. The probe is done when the USB device is first needed.
- handles PHYs when in the peripheral mode. The code to handle the PHYs is shared with the host side
- handles clock and reset
- bind host controller to the more generic driver 'xhci-dwc3'Changes in v4:
- rebased on latest U-Boot
- renamedDM_USB_DEVasDM_USB_GADGET
- Add a new commit to create a new UCLASS for USB gadget driversChanges in v3:
- fixes bugdwc3_setup_phy(): the phy arrays wasn't returned. This was visible only when the device is removed.
- Stub the DWC3 PHY operations ifCONFIG_IS_ENABLED(PHY)is false. This fixes all build issues but one (evb-rk3328).
- Fix build issue with evb-rk3328 by enablingCONFIG_USB_DWC3. This has little impact on the footprint and should not break the runtime as the xhci-rockchip driver has its own probe function. Nevertheless this was !!! NOT TESTED !!! by lack of hwChanges in v2:
- Updated commit log
- Fixed typo inthordown.c
- selectDM_USB_DEVby default for zynqmp platformsJean-Jacques Hiblot (10):
usb: gadget: Do not callboard_usb_xxx()directly in USB gadget
drivers
usb: introduce a separate config option for DM USB device
usb: udc: implement DM versions of
usb_gadget_initialize()/_release()/_handle_interrupt()
dwc3_generic: do not probe the USB device driver when it's bound
dwc3: move phy operation tocore.c
dm: usb: create a new UCLASS ID for USB gadget devices
configs: evb-rk3328: EnableCONFIG_USB_DWC3
dwc3-generic: Handle the PHYs, the clocks and the reset lines
dwc3-generic: Addselect_dr_modeoperation
usb: dwc3: Fix a compilation error with the edison defconfigarch/arm/Kconfig | 2 + board/sunxi/board.c | 2 +- cmd/fastboot.c | 4 +- cmd/rockusb.c | 4 +- cmd/thordown.c | 4 +- cmd/usb_gadget_sdp.c | 4 +- cmd/usb_mass_storage.c | 4 +- common/dfu.c | 6 +- configs/evb-rk3328_defconfig | 1 + drivers/usb/Kconfig | 14 +++ drivers/usb/dwc3/Kconfig | 7 +- drivers/usb/dwc3/core.c | 89 ++++++++++++++- drivers/usb/dwc3/dwc3-generic.c | 208 ++++++++++++++++++++++++++++-------- drivers/usb/dwc3/ep0.c | 2 +- drivers/usb/gadget/ether.c | 40 ++----- drivers/usb/gadget/udc/Makefile | 4 + drivers/usb/gadget/udc/udc-core.c | 3 +- drivers/usb/gadget/udc/udc-uclass.c | 58 ++++++++++ drivers/usb/host/xhci-dwc3.c | 95 ++--------------Quoted 8 lines
Quoted 8 lines
drivers/usb/musb-new/omap2430.c | 2 +- drivers/usb/musb-new/sunxi.c | 2 +- include/dm/uclass-id.h | 1 + include/dwc3-uboot.h | 19 ++++ include/linux/usb/gadget.h | 18 ++++ 24 files changed, 401 insertions(+), 192 deletions(-)create mode 100644
drivers/usb/gadget/udc/udc-uclass.c
Quoted 4 lines
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot
First off thanks for the work. I have imported it into my u-boot tree for the iMX8M and now have both usb host and gadget mode working simultaneously. There is one catch. Currently, the iMX8M codebase does not support clock and power device initialization from DM. I have patched the driver to punt back to the board to do these initializations in the following patch. Yes I know not ideal, but functional. I am wondering if we should support architecture specific implementation quirks for boards that don't fully support DM initialization yet. I am open to writing something more complete if we decide it is something worth pursuing, otherwise I will carry this patch in my tree for time being.
-Jon
drivers/usb/dwc3/dwc3-generic.c +13 -0
@@ -119,6 +119,15 @@ struct dwc3_glue_ops { enum usb_dr_mode mode); }; +__weak int board_usb_of_init (struct udevice *dev) +{ +return 0 ; +} + +__weak void board_usb_of_cleanup (struct udevice *dev) +{ +} +static int dwc3_glue_bind (struct udevice *parent) {const void *fdt = gd->fdt_blob;
@@ -242,6 +251,8 @@ static int dwc3_glue_probe(struct udevice *dev) index++; } + ret =board_usb_of_init (dev); +return 0 ; }
@@ -249,6 +260,8 @@ static int dwc3_glue_remove(struct udevice *dev) {struct dwc3_glue_data *glue =dev_get_platdata (dev); +board_usb_of_cleanup (dev); +reset_release_bulk (&glue->resets);clk_release_bulk (&glue->clks);
@@ -257,6 +270,7 @@ static int dwc3_glue_remove(struct udevice *dev) }
v4 cover Improvements for the dwc3_generic driver
Quoted 111 lines · Jon Nettleton
Quoted 106 lines · Jean-Jacques Hiblot
Quoted 9 lines · Loic Devulder
Hi,
I re-tested this series on Khadas VIM1 and it still fix the USB issue I had with 'usb reset' (I already tested v2 patches).
I just have a message and I'm not sure that I had it last time:
"Error disabling PHY supply
Can't shutdown USB PHY1 for dwc3 atc9000000"Quoted 8 lines
But USB stack looks ok, I can plug/unplug USB key and do the reset, all works as expected.
Since my last test lot of changes has been done in Amlogic SoCs, maybe it's because of this?
So if you want you can add my tested-by flag.
Tested-by Loic Devulder <[email protected]>Thank you for testing
Quoted 78 lines · Jean-Jacques Hiblot
Quoted 77 lines
This series aims at bringing improvements to the
dwc3_genericdriver so that it can be used by most of the platforms using the dwc3 controller.I tested this on with DRA7 and AM57x platforms for both Peripheral and Host operations. The code to enable DM USB host & dev support for those platforms will be submitted in a separate series.
Michal Simek has tested this series:
" I have tested it on zcu100 with usb stick, usb to ethernet converter and also dfu.Tested-by Michal Simek <[email protected]>"Enhancements:
- use separateKconfigoption for DM USB Periphal and DM USB Host. This allow platforms to keep their non-DM USB peripheral code and use the DM USB host.
- fixes the bind/probe confusion indwc3_generic. The probe is done when the USB device is first needed.
- handles PHYs when in the peripheral mode. The code to handle the PHYs is shared with the host side
- handles clock and reset
- bind host controller to the more generic driver 'xhci-dwc3'Changes in v4:
- rebased on latest U-Boot
- renamedDM_USB_DEVasDM_USB_GADGET
- Add a new commit to create a new UCLASS for USB gadget driversChanges in v3:
- fixes bugdwc3_setup_phy(): the phy arrays wasn't returned. This was visible only when the device is removed.
- Stub the DWC3 PHY operations ifCONFIG_IS_ENABLED(PHY)is false. This fixes all build issues but one (evb-rk3328).
- Fix build issue with evb-rk3328 by enablingCONFIG_USB_DWC3. This has little impact on the footprint and should not break the runtime as the xhci-rockchip driver has its own probe function. Nevertheless this was !!! NOT TESTED !!! by lack of hwChanges in v2:
- Updated commit log
- Fixed typo inthordown.c
- selectDM_USB_DEVby default for zynqmp platformsJean-Jacques Hiblot (10):
usb: gadget: Do not callboard_usb_xxx()directly in USB gadget
drivers
usb: introduce a separate config option for DM USB device
usb: udc: implement DM versions of
usb_gadget_initialize()/_release()/_handle_interrupt()
dwc3_generic: do not probe the USB device driver when it's bound
dwc3: move phy operation tocore.c
dm: usb: create a new UCLASS ID for USB gadget devices
configs: evb-rk3328: EnableCONFIG_USB_DWC3
dwc3-generic: Handle the PHYs, the clocks and the reset lines
dwc3-generic: Addselect_dr_modeoperation
usb: dwc3: Fix a compilation error with the edison defconfigarch/arm/Kconfig | 2 + board/sunxi/board.c | 2 +- cmd/fastboot.c | 4 +- cmd/rockusb.c | 4 +- cmd/thordown.c | 4 +- cmd/usb_gadget_sdp.c | 4 +- cmd/usb_mass_storage.c | 4 +- common/dfu.c | 6 +- configs/evb-rk3328_defconfig | 1 + drivers/usb/Kconfig | 14 +++ drivers/usb/dwc3/Kconfig | 7 +- drivers/usb/dwc3/core.c | 89 ++++++++++++++- drivers/usb/dwc3/dwc3-generic.c | 208 ++++++++++++++++++++++++++++-------- drivers/usb/dwc3/ep0.c | 2 +- drivers/usb/gadget/ether.c | 40 ++----- drivers/usb/gadget/udc/Makefile | 4 + drivers/usb/gadget/udc/udc-core.c | 3 +- drivers/usb/gadget/udc/udc-uclass.c | 58 ++++++++++ drivers/usb/host/xhci-dwc3.c | 95 ++--------------Quoted 8 lines
Quoted 8 lines
drivers/usb/musb-new/omap2430.c | 2 +- drivers/usb/musb-new/sunxi.c | 2 +- include/dm/uclass-id.h | 1 + include/dwc3-uboot.h | 19 ++++ include/linux/usb/gadget.h | 18 ++++ 24 files changed, 401 insertions(+), 192 deletions(-)create mode 100644
drivers/usb/gadget/udc/udc-uclass.cQuoted 4 lines
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot
Quoted 9 lines
First off thanks for the work. I have imported it into my u-boot tree for the iMX8M and now have both usb host and gadget mode working simultaneously. There is one catch. Currently, the iMX8M codebase does not support clock and power device initialization from DM. I have patched the driver to punt back to the board to do these initializations in the following patch. Yes I know not ideal, but functional. I am wondering if we should support architecture specific implementation quirks for boards that don't fully support DM initialization yet.
That is not fitting the DM model. I had the same issue and finally enabled the clocks in the board_late_init():
board/ti/dra7xx/evm.c:662:int board_late_init(void)
Quoted 3 lines
I am open to writing something more complete if
we decide it is something worth pursuing, otherwise I will carry this patch in my tree for time being.
The true solution would be to implement the support for clk.
Quoted 44 lines
(quoted diff) +0
-1-Jondrivers/usb/dwc3/dwc3-generic.c +13
-0@@ -119,6 +119,15 @@ struct dwc3_glue_ops { enum usb_dr_mode mode); }; +__weak int board_usb_of_init (struct udevice *dev) +{ +return 0 ; +} + +__weak void board_usb_of_cleanup (struct udevice *dev) +{ +} +static int dwc3_glue_bind (struct udevice *parent) {const void *fdt = gd->fdt_blob;@@ -242,6 +251,8 @@ static int dwc3_glue_probe(struct udevice *dev) index++; } + ret =board_usb_of_init (dev); +return 0 ; }@@ -249,6 +260,8 @@ static int dwc3_glue_remove(struct udevice *dev) {struct dwc3_glue_data *glue =dev_get_platdata (dev); +board_usb_of_cleanup (dev); +reset_release_bulk (&glue->resets);clk_release_bulk (&glue->clks);@@ -257,6 +270,7 @@ static int dwc3_glue_remove(struct udevice *dev) }
v4 cover Improvements for the dwc3_generic driver
Hi Jean-Jacques,
Quoted 125 lines · Jon Nettleton
Quoted 114 lines
Quoted 108 lines · Jean-Jacques Hiblot
Quoted 9 lines · Loic Devulder
Hi,
I re-tested this series on Khadas VIM1 and it still fix the USB issue I had with 'usb reset' (I already tested v2 patches).
I just have a message and I'm not sure that I had it last time:
"Error disabling PHY supply
Can't shutdown USB PHY1 for dwc3 atc9000000"Quoted 8 lines
But USB stack looks ok, I can plug/unplug USB key and do the reset, all works as expected.
Since my last test lot of changes has been done in Amlogic SoCs, maybe it's because of this?
So if you want you can add my tested-by flag.
Tested-by Loic Devulder <[email protected]>Thank you for testing
Quoted 80 lines · Jean-Jacques Hiblot
Quoted 79 lines
This series aims at bringing improvements to the
dwc3_genericdriver so that it can be used by most of the platforms using the dwc3 controller.I tested this on with DRA7 and AM57x platforms for both Peripheral and Host operations. The code to enable DM USB host & dev support for those platforms will be submitted in a separate series.
Michal Simek has tested this series:
" I have tested it on zcu100 with usb stick, usb to ethernet converter and also dfu.Tested-by Michal Simek <[email protected]>"Enhancements:
- use separateKconfigoption for DM USB Periphal and DM USB Host. This allow platforms to keep their non-DM USB peripheral code and use the DM USB host.
- fixes the bind/probe confusion indwc3_generic. The probe is done when the USB device is first needed.
- handles PHYs when in the peripheral mode. The code to handle the PHYs is shared with the host side
- handles clock and reset
- bind host controller to the more generic driver 'xhci-dwc3'Changes in v4:
- rebased on latest U-Boot
- renamedDM_USB_DEVasDM_USB_GADGET
- Add a new commit to create a new UCLASS for USB gadget driversChanges in v3:
- fixes bugdwc3_setup_phy(): the phy arrays wasn't returned. This was visible only when the device is removed.
- Stub the DWC3 PHY operations ifCONFIG_IS_ENABLED(PHY)is false. This fixes all build issues but one (evb-rk3328).
- Fix build issue with evb-rk3328 by enablingCONFIG_USB_DWC3. This has little impact on the footprint and should not break the runtime as the xhci-rockchip driver has its own probe function. Nevertheless this was !!! NOT TESTED !!! by lack of hwChanges in v2:
- Updated commit log
- Fixed typo inthordown.c
- selectDM_USB_DEVby default for zynqmp platformsJean-Jacques Hiblot (10):
usb: gadget: Do not callboard_usb_xxx()directly in USB
gadget drivers
usb: introduce a separate config option for DM USB device
usb: udc: implement DM versions of
usb_gadget_initialize()/_release()/_handle_interrupt()
dwc3_generic: do not probe the USB device driver when it's
bound dwc3: move phy operation tocore.c
dm: usb: create a new UCLASS ID for USB gadget devices
configs: evb-rk3328: EnableCONFIG_USB_DWC3
dwc3-generic: Handle the PHYs, the clocks and the reset lines
dwc3-generic: Addselect_dr_modeoperation
usb: dwc3: Fix a compilation error with the edison defconfigarch/arm/Kconfig | 2 + board/sunxi/board.c | 2 +- cmd/fastboot.c | 4 +- cmd/rockusb.c | 4 +- cmd/thordown.c | 4 +- cmd/usb_gadget_sdp.c | 4 +- cmd/usb_mass_storage.c | 4 +- common/dfu.c | 6 +- configs/evb-rk3328_defconfig | 1 + drivers/usb/Kconfig | 14 +++ drivers/usb/dwc3/Kconfig | 7 +- drivers/usb/dwc3/core.c | 89 ++++++++++++++- drivers/usb/dwc3/dwc3-generic.c | 208 ++++++++++++++++++++++++++++-------- drivers/usb/dwc3/ep0.c | 2 +- drivers/usb/gadget/ether.c | 40 ++----- drivers/usb/gadget/udc/Makefile | 4 + drivers/usb/gadget/udc/udc-core.c | 3 +- drivers/usb/gadget/udc/udc-uclass.c | 58 ++++++++++Quoted 8 lines
Quoted 8 lines
drivers/usb/host/xhci-dwc3.c | 95 ++-------------- drivers/usb/musb-new/omap2430.c | 2 +- drivers/usb/musb-new/sunxi.c | 2 +- include/dm/uclass-id.h | 1 + include/dwc3-uboot.h | 19 ++++ include/linux/usb/gadget.h | 18 ++++ 24 files changed,401 insertions(+), 192 deletions(-) create mode 100644
drivers/usb/gadget/udc/udc-uclass.cQuoted 4 lines
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-bootQuoted 9 lines
First off thanks for the work. I have imported it into my u-boot tree for the iMX8M and now have both usb host and gadget mode working simultaneously. There is one catch. Currently, the iMX8M codebase does not support clock and power device initialization from DM. I have patched the driver to punt back to the board to do these initializations in the following patch. Yes I know not ideal, but functional. I am wondering if we should support architecture specific implementation quirks for boards that don't fully support DM initialization yet.
Quoted 8 lines
That is not fitting the DM model. I had the same issue and finally enabled the clocks in the
board_late_init():
board/ti/dra7xx/evm.c:662:intboard_late_init(void)Quoted 3 lines
I am open to writing something more complete if
we decide it is something worth pursuing, otherwise I will carry this patch in my tree for time being.The true solution would be to implement the support for clk.
Many other people on the ML (including me) see the urgent need to implement the DM_CLK for e.g. imx6/5/7/8, etc.
I think that it would be best to add it clock by clock. The stubs in board code/files is a dead end, IMHO.
Quoted 36 lines
Quoted 36 lines
(quoted diff) +0
-1-Jon(quoted diff) +0
-0
b/drivers/usb/dwc3/dwc3-generic.cindex6d9be9b245..90d4ff2ea7100644 ---a/drivers/usb/dwc3/dwc3-generic.c
+++b/drivers/usb/dwc3/dwc3-generic.cdrivers/usb/dwc3/dwc3-generic.c +11
-0@@ -119,6 +119,15 @@ struct dwc3_glue_ops { enum usb_dr_mode mode); }; +__weak int board_usb_of_init (struct udevice *dev) +{ +return 0 ; +} + +__weak void board_usb_of_cleanup (struct udevice *dev) +{ +} +static int dwc3_glue_bind (struct udevice *parent) {const void *fdt = gd->fdt_blob;@@ -242,6 +251,8 @@ static int dwc3_glue_probe(struct udevice *dev) index++; } + ret =board_usb_of_init (dev); +return 0 ; }@@ -249,6 +260,8 @@ static int dwc3_glue_remove(struct udevice *dev) {struct dwc3_glue_data *glue =dev_get_platdata (dev);
Quoted 8 lines
drivers/usb/dwc3/dwc3-generic.c static int dwc3_glue_remove(struct udevice *dev) · line 271
Quoted 8 lines
drivers/usb/dwc3/dwc3-generic.c +2
-0+board_usb_of_cleanup (dev); +reset_release_bulk (&glue->resets);clk_release_bulk (&glue->clks);@@ -257,6 +270,7 @@ static int dwc3_glue_remove(struct udevice *dev) }
Best regards,
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma at denx.de -------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190104/f0ef8bb8/attachment.sig>
v4 cover Improvements for the dwc3_generic driver
Quoted 132 lines · Lukasz Majewski
Hi Jean-Jacques,
Quoted 130 lines · Jon Nettleton
Quoted 113 lines
Quoted 107 lines · Jean-Jacques Hiblot
Quoted 9 lines · Loic Devulder
Hi,
I re-tested this series on Khadas VIM1 and it still fix the USB issue I had with 'usb reset' (I already tested v2 patches).
I just have a message and I'm not sure that I had it last time:
"Error disabling PHY supply
Can't shutdown USB PHY1 for dwc3 atc9000000"Quoted 8 lines
But USB stack looks ok, I can plug/unplug USB key and do the reset, all works as expected.
Since my last test lot of changes has been done in Amlogic SoCs, maybe it's because of this?
So if you want you can add my tested-by flag.
Tested-by Loic Devulder <[email protected]>Thank you for testing
Quoted 80 lines · Jean-Jacques Hiblot
Quoted 79 lines
This series aims at bringing improvements to the
dwc3_genericdriver so that it can be used by most of the platforms using the dwc3 controller.I tested this on with DRA7 and AM57x platforms for both Peripheral and Host operations. The code to enable DM USB host & dev support for those platforms will be submitted in a separate series.
Michal Simek has tested this series:
" I have tested it on zcu100 with usb stick, usb to ethernet converter and also dfu.Tested-by Michal Simek <[email protected]>"Enhancements:
- use separateKconfigoption for DM USB Periphal and DM USB Host. This allow platforms to keep their non-DM USB peripheral code and use the DM USB host.
- fixes the bind/probe confusion indwc3_generic. The probe is done when the USB device is first needed.
- handles PHYs when in the peripheral mode. The code to handle the PHYs is shared with the host side
- handles clock and reset
- bind host controller to the more generic driver 'xhci-dwc3'Changes in v4:
- rebased on latest U-Boot
- renamedDM_USB_DEVasDM_USB_GADGET
- Add a new commit to create a new UCLASS for USB gadget driversChanges in v3:
- fixes bugdwc3_setup_phy(): the phy arrays wasn't returned. This was visible only when the device is removed.
- Stub the DWC3 PHY operations ifCONFIG_IS_ENABLED(PHY)is false. This fixes all build issues but one (evb-rk3328).
- Fix build issue with evb-rk3328 by enablingCONFIG_USB_DWC3. This has little impact on the footprint and should not break the runtime as the xhci-rockchip driver has its own probe function. Nevertheless this was !!! NOT TESTED !!! by lack of hwChanges in v2:
- Updated commit log
- Fixed typo inthordown.c
- selectDM_USB_DEVby default for zynqmp platformsJean-Jacques Hiblot (10):
usb: gadget: Do not callboard_usb_xxx()directly in USB
gadget drivers
usb: introduce a separate config option for DM USB device
usb: udc: implement DM versions of
usb_gadget_initialize()/_release()/_handle_interrupt()
dwc3_generic: do not probe the USB device driver when it's
bound dwc3: move phy operation tocore.c
dm: usb: create a new UCLASS ID for USB gadget devices
configs: evb-rk3328: EnableCONFIG_USB_DWC3
dwc3-generic: Handle the PHYs, the clocks and the reset lines
dwc3-generic: Addselect_dr_modeoperation
usb: dwc3: Fix a compilation error with the edison defconfig
arch/arm/Kconfig| 2 +
board/sunxi/board.c| 2 +-
cmd/fastboot.c| 4 +-
cmd/rockusb.c| 4 +-
cmd/thordown.c| 4 +-
cmd/usb_gadget_sdp.c| 4 +-
cmd/usb_mass_storage.c| 4 +-
common/dfu.c| 6 +-
configs/evb-rk3328_defconfig | 1 +
drivers/usb/Kconfig| 14 +++
drivers/usb/dwc3/Kconfig| 7 +-
drivers/usb/dwc3/core.c| 89 ++++++++++++++-
drivers/usb/dwc3/dwc3-generic.c| 208
++++++++++++++++++++++++++++--------drivers/usb/dwc3/ep0.c | 2 +- drivers/usb/gadget/ether.c | 40 ++----- drivers/usb/gadget/udc/Makefile | 4 + drivers/usb/gadget/udc/udc-core.c | 3 +- drivers/usb/gadget/udc/udc-uclass.c | 58 ++++++++++Quoted 8 lines
Quoted 8 lines
drivers/usb/host/xhci-dwc3.c | 95 ++-------------- drivers/usb/musb-new/omap2430.c | 2 +- drivers/usb/musb-new/sunxi.c | 2 +- include/dm/uclass-id.h | 1 + include/dwc3-uboot.h | 19 ++++ include/linux/usb/gadget.h | 18 ++++ 24 files changed,401 insertions(+), 192 deletions(-) create mode 100644
drivers/usb/gadget/udc/udc-uclass.cQuoted 4 lines
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-bootQuoted 9 lines
First off thanks for the work. I have imported it into my u-boot tree for the iMX8M and now have both usb host and gadget mode working simultaneously. There is one catch. Currently, the iMX8M codebase does not support clock and power device initialization from DM. I have patched the driver to punt back to the board to do these initializations in the following patch. Yes I know not ideal, but functional. I am wondering if we should support architecture specific implementation quirks for boards that don't fully support DM initialization yet.
That is not fitting the DM model. I had the same issue and finally enabled the clocks in the
board_late_init():
board/ti/dra7xx/evm.c:662:intboard_late_init(void)Quoted 3 lines
I am open to writing something more complete if
we decide it is something worth pursuing, otherwise I will carry this patch in my tree for time being.
Quoted 6 lines
Quoted 1 line
The true solution would be to implement the support for clk.
Many other people on the ML (including me) see the urgent need to implement the
DM_CLKfor e.g. imx6/5/7/8, etc.I think that it would be best to add it clock by clock. The stubs in board code/files is a dead end, IMHO.
I agree 100%.
We had a similar discussion for the TI platforms, but due to the specific design of the TI power/clk in Linux (hwmod), we chose to keep the clocks handling in the board file at the moment.
Quoted 56 lines
Quoted 36 lines
Quoted 36 lines
(quoted diff) +0
-1-Jon(quoted diff) +0
-0
b/drivers/usb/dwc3/dwc3-generic.cindex6d9be9b245..90d4ff2ea7100644 ---a/drivers/usb/dwc3/dwc3-generic.c
+++b/drivers/usb/dwc3/dwc3-generic.cdrivers/usb/dwc3/dwc3-generic.c +11
-0@@ -119,6 +119,15 @@ struct dwc3_glue_ops { enum usb_dr_mode mode); }; +__weak int board_usb_of_init (struct udevice *dev) +{ +return 0 ; +} + +__weak void board_usb_of_cleanup (struct udevice *dev) +{ +} +static int dwc3_glue_bind (struct udevice *parent) {const void *fdt = gd->fdt_blob;@@ -242,6 +251,8 @@ static int dwc3_glue_probe(struct udevice *dev) index++; } + ret =board_usb_of_init (dev); +return 0 ; }@@ -249,6 +260,8 @@ static int dwc3_glue_remove(struct udevice *dev) {struct dwc3_glue_data *glue =dev_get_platdata (dev);Quoted 8 lines
drivers/usb/dwc3/dwc3-generic.c static int dwc3_glue_remove(struct udevice *dev) · line 271
Quoted 8 lines
drivers/usb/dwc3/dwc3-generic.c +2
-0+board_usb_of_cleanup (dev); +reset_release_bulk (&glue->resets);clk_release_bulk (&glue->clks);@@ -257,6 +270,7 @@ static int dwc3_glue_remove(struct udevice *dev) }Best regards,
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma at denx.de
v4 cover Improvements for the dwc3_generic driver
Quoted 139 lines · Jean-Jacques Hiblot
Quoted 136 lines · Lukasz Majewski
Hi Jean-Jacques,
Quoted 123 lines · Jon Nettleton
Quoted 113 lines
Quoted 107 lines · Jean-Jacques Hiblot
Quoted 9 lines · Loic Devulder
Hi,
I re-tested this series on Khadas VIM1 and it still fix the USB issue I had with 'usb reset' (I already tested v2 patches).
I just have a message and I'm not sure that I had it last time:
"Error disabling PHY supply
Can't shutdown USB PHY1 for dwc3 atc9000000"Quoted 8 lines
But USB stack looks ok, I can plug/unplug USB key and do the reset, all works as expected.
Since my last test lot of changes has been done in Amlogic SoCs, maybe it's because of this?
So if you want you can add my tested-by flag.
Tested-by Loic Devulder <[email protected]>Thank you for testing
Quoted 80 lines · Jean-Jacques Hiblot
Quoted 79 lines
This series aims at bringing improvements to the
dwc3_genericdriver so that it can be used by most of the platforms using the dwc3 controller.I tested this on with DRA7 and AM57x platforms for both Peripheral and Host operations. The code to enable DM USB host & dev support for those platforms will be submitted in a separate series.
Michal Simek has tested this series:
" I have tested it on zcu100 with usb stick, usb to ethernet converter and also dfu.Tested-by Michal Simek <[email protected]>"Enhancements:
- use separateKconfigoption for DM USB Periphal and DM USB Host. This allow platforms to keep their non-DM USB peripheral code and use the DM USB host.
- fixes the bind/probe confusion indwc3_generic. The probe is done when the USB device is first needed.
- handles PHYs when in the peripheral mode. The code to handle the PHYs is shared with the host side
- handles clock and reset
- bind host controller to the more generic driver 'xhci-dwc3'Changes in v4:
- rebased on latest U-Boot
- renamedDM_USB_DEVasDM_USB_GADGET
- Add a new commit to create a new UCLASS for USB gadget driversChanges in v3:
- fixes bugdwc3_setup_phy(): the phy arrays wasn't returned. This was visible only when the device is removed.
- Stub the DWC3 PHY operations ifCONFIG_IS_ENABLED(PHY)is false. This fixes all build issues but one (evb-rk3328).
- Fix build issue with evb-rk3328 by enablingCONFIG_USB_DWC3. This has little impact on the footprint and should not break the runtime as the xhci-rockchip driver has its own probe function. Nevertheless this was !!! NOT TESTED !!! by lack of hwChanges in v2:
- Updated commit log
- Fixed typo inthordown.c
- selectDM_USB_DEVby default for zynqmp platformsJean-Jacques Hiblot (10):
usb: gadget: Do not callboard_usb_xxx()directly in USB
gadget drivers
usb: introduce a separate config option for DM USB device
usb: udc: implement DM versions of
usb_gadget_initialize()/_release()/_handle_interrupt()
dwc3_generic: do not probe the USB device driver when it's
bound dwc3: move phy operation tocore.c
dm: usb: create a new UCLASS ID for USB gadget devices
configs: evb-rk3328: EnableCONFIG_USB_DWC3
dwc3-generic: Handle the PHYs, the clocks and the reset lines
dwc3-generic: Addselect_dr_modeoperation
usb: dwc3: Fix a compilation error with the edison defconfig
arch/arm/Kconfig| 2 +
board/sunxi/board.c| 2 +-
cmd/fastboot.c| 4 +-
cmd/rockusb.c| 4 +-
cmd/thordown.c| 4 +-
cmd/usb_gadget_sdp.c| 4 +-
cmd/usb_mass_storage.c| 4 +-
common/dfu.c| 6 +-
configs/evb-rk3328_defconfig | 1 +
drivers/usb/Kconfig| 14 +++
drivers/usb/dwc3/Kconfig| 7 +-
drivers/usb/dwc3/core.c| 89 ++++++++++++++-
drivers/usb/dwc3/dwc3-generic.c| 208
++++++++++++++++++++++++++++--------drivers/usb/dwc3/ep0.c | 2 +- drivers/usb/gadget/ether.c | 40 ++----- drivers/usb/gadget/udc/Makefile | 4 + drivers/usb/gadget/udc/udc-core.c | 3 +- drivers/usb/gadget/udc/udc-uclass.c | 58 ++++++++++Quoted 8 lines
Quoted 8 lines
drivers/usb/host/xhci-dwc3.c | 95 ++-------------- drivers/usb/musb-new/omap2430.c | 2 +- drivers/usb/musb-new/sunxi.c | 2 +- include/dm/uclass-id.h | 1 + include/dwc3-uboot.h | 19 ++++ include/linux/usb/gadget.h | 18 ++++ 24 files changed,401 insertions(+), 192 deletions(-) create mode 100644
drivers/usb/gadget/udc/udc-uclass.cQuoted 4 lines
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-bootQuoted 9 lines
First off thanks for the work. I have imported it into my u-boot tree for the iMX8M and now have both usb host and gadget mode working simultaneously. There is one catch. Currently, the iMX8M codebase does not support clock and power device initialization from DM. I have patched the driver to punt back to the board to do these initializations in the following patch. Yes I know not ideal, but functional. I am wondering if we should support architecture specific implementation quirks for boards that don't fully support DM initialization yet.
Quoted 8 lines
That is not fitting the DM model. I had the same issue and finally enabled the clocks in the
board_late_init():
board/ti/dra7xx/evm.c:662:intboard_late_init(void)Quoted 3 lines
I am open to writing something more complete if
we decide it is something worth pursuing, otherwise I will carry this patch in my tree for time being.The true solution would be to implement the support for clk.
Many other people on the ML (including me) see the urgent need to implement the
DM_CLKfor e.g. imx6/5/7/8, etc.
Quoted 66 lines
Quoted 2 lines
I think that it would be best to add it clock by clock. The stubs in board code/files is a dead end, IMHO.
I agree 100%.
We had a similar discussion for the TI platforms, but due to the specific design of the TI power/clk in Linux (hwmod), we chose to keep the clocks handling in the board file at the moment.
Quoted 56 lines
Quoted 36 lines
Quoted 36 lines
(quoted diff) +0
-1-Jon(quoted diff) +0
-0
b/drivers/usb/dwc3/dwc3-generic.cindex6d9be9b245..90d4ff2ea7100644 ---a/drivers/usb/dwc3/dwc3-generic.c
+++b/drivers/usb/dwc3/dwc3-generic.cdrivers/usb/dwc3/dwc3-generic.c +11
-0@@ -119,6 +119,15 @@ struct dwc3_glue_ops { enum usb_dr_mode mode); }; +__weak int board_usb_of_init (struct udevice *dev) +{ +return 0 ; +} + +__weak void board_usb_of_cleanup (struct udevice *dev) +{ +} +static int dwc3_glue_bind (struct udevice *parent) {const void *fdt = gd->fdt_blob;@@ -242,6 +251,8 @@ static int dwc3_glue_probe(struct udevice *dev) index++; } + ret =board_usb_of_init (dev); +return 0 ; }@@ -249,6 +260,8 @@ static int dwc3_glue_remove(struct udevice *dev) {struct dwc3_glue_data *glue =dev_get_platdata (dev);Quoted 8 lines
drivers/usb/dwc3/dwc3-generic.c static int dwc3_glue_remove(struct udevice *dev) · line 271
Quoted 8 lines
drivers/usb/dwc3/dwc3-generic.c +2
-0+board_usb_of_cleanup (dev); +reset_release_bulk (&glue->resets);clk_release_bulk (&glue->clks);@@ -257,6 +270,7 @@ static int dwc3_glue_remove(struct udevice *dev) }Best regards,
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma at denx.de
Obviously the proper solution is implementing a proper DM clk driver. I generally refrain from just enabling a bunch of clocks and code in our board file, since our devices are SOM + carrier, and many customers design their own boards and then continue to use our bootloader. I am fine carrying the patch until we have the time to build the proper infrastructure in mainline.
v4 cover Improvements for the dwc3_generic driver
Quoted 208 lines · Jon Nettleton
Quoted 139 lines · Jean-Jacques Hiblot
Quoted 136 lines · Lukasz Majewski
Hi Jean-Jacques,
Quoted 123 lines · Jon Nettleton
Quoted 113 lines
Quoted 107 lines · Jean-Jacques Hiblot
Quoted 9 lines · Loic Devulder
Hi,
I re-tested this series on Khadas VIM1 and it still fix the USB issue I had with 'usb reset' (I already tested v2 patches).
I just have a message and I'm not sure that I had it last time:
"Error disabling PHY supply
Can't shutdown USB PHY1 for dwc3 atc9000000"Quoted 8 lines
But USB stack looks ok, I can plug/unplug USB key and do the reset, all works as expected.
Since my last test lot of changes has been done in Amlogic SoCs, maybe it's because of this?
So if you want you can add my tested-by flag.
Tested-by Loic Devulder <[email protected]>Thank you for testing
Quoted 80 lines · Jean-Jacques Hiblot
Quoted 79 lines
This series aims at bringing improvements to the
dwc3_genericdriver so that it can be used by most of the platforms using the dwc3 controller.I tested this on with DRA7 and AM57x platforms for both Peripheral and Host operations. The code to enable DM USB host & dev support for those platforms will be submitted in a separate series.
Michal Simek has tested this series:
" I have tested it on zcu100 with usb stick, usb to ethernet converter and also dfu.Tested-by Michal Simek <[email protected]>"Enhancements:
- use separateKconfigoption for DM USB Periphal and DM USB Host. This allow platforms to keep their non-DM USB peripheral code and use the DM USB host.
- fixes the bind/probe confusion indwc3_generic. The probe is done when the USB device is first needed.
- handles PHYs when in the peripheral mode. The code to handle the PHYs is shared with the host side
- handles clock and reset
- bind host controller to the more generic driver 'xhci-dwc3'Changes in v4:
- rebased on latest U-Boot
- renamedDM_USB_DEVasDM_USB_GADGET
- Add a new commit to create a new UCLASS for USB gadget driversChanges in v3:
- fixes bugdwc3_setup_phy(): the phy arrays wasn't returned. This was visible only when the device is removed.
- Stub the DWC3 PHY operations ifCONFIG_IS_ENABLED(PHY)is false. This fixes all build issues but one (evb-rk3328).
- Fix build issue with evb-rk3328 by enablingCONFIG_USB_DWC3. This has little impact on the footprint and should not break the runtime as the xhci-rockchip driver has its own probe function. Nevertheless this was !!! NOT TESTED !!! by lack of hwChanges in v2:
- Updated commit log
- Fixed typo inthordown.c
- selectDM_USB_DEVby default for zynqmp platformsJean-Jacques Hiblot (10):
usb: gadget: Do not callboard_usb_xxx()directly in USB
gadget drivers
usb: introduce a separate config option for DM USB device
usb: udc: implement DM versions of
usb_gadget_initialize()/_release()/_handle_interrupt()
dwc3_generic: do not probe the USB device driver when it's
bound dwc3: move phy operation tocore.c
dm: usb: create a new UCLASS ID for USB gadget devices
configs: evb-rk3328: EnableCONFIG_USB_DWC3
dwc3-generic: Handle the PHYs, the clocks and the reset lines
dwc3-generic: Addselect_dr_modeoperation
usb: dwc3: Fix a compilation error with the edison defconfig
arch/arm/Kconfig| 2 +
board/sunxi/board.c| 2 +-
cmd/fastboot.c| 4 +-
cmd/rockusb.c| 4 +-
cmd/thordown.c| 4 +-
cmd/usb_gadget_sdp.c| 4 +-
cmd/usb_mass_storage.c| 4 +-
common/dfu.c| 6 +-
configs/evb-rk3328_defconfig | 1 +
drivers/usb/Kconfig| 14 +++
drivers/usb/dwc3/Kconfig| 7 +-
drivers/usb/dwc3/core.c| 89 ++++++++++++++-
drivers/usb/dwc3/dwc3-generic.c| 208
++++++++++++++++++++++++++++--------drivers/usb/dwc3/ep0.c | 2 +- drivers/usb/gadget/ether.c | 40 ++----- drivers/usb/gadget/udc/Makefile | 4 + drivers/usb/gadget/udc/udc-core.c | 3 +- drivers/usb/gadget/udc/udc-uclass.c | 58 ++++++++++Quoted 8 lines
Quoted 8 lines
drivers/usb/host/xhci-dwc3.c | 95 ++-------------- drivers/usb/musb-new/omap2430.c | 2 +- drivers/usb/musb-new/sunxi.c | 2 +- include/dm/uclass-id.h | 1 + include/dwc3-uboot.h | 19 ++++ include/linux/usb/gadget.h | 18 ++++ 24 files changed,401 insertions(+), 192 deletions(-) create mode 100644
drivers/usb/gadget/udc/udc-uclass.cQuoted 4 lines
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-bootQuoted 9 lines
First off thanks for the work. I have imported it into my u-boot tree for the iMX8M and now have both usb host and gadget mode working simultaneously. There is one catch. Currently, the iMX8M codebase does not support clock and power device initialization from DM. I have patched the driver to punt back to the board to do these initializations in the following patch. Yes I know not ideal, but functional. I am wondering if we should support architecture specific implementation quirks for boards that don't fully support DM initialization yet.
Quoted 8 lines
That is not fitting the DM model. I had the same issue and finally enabled the clocks in the
board_late_init():
board/ti/dra7xx/evm.c:662:intboard_late_init(void)Quoted 3 lines
I am open to writing something more complete if
we decide it is something worth pursuing, otherwise I will carry this patch in my tree for time being.The true solution would be to implement the support for clk.
Many other people on the ML (including me) see the urgent need to implement the
DM_CLKfor e.g. imx6/5/7/8, etc.Quoted 66 lines
Quoted 2 lines
I think that it would be best to add it clock by clock. The stubs in board code/files is a dead end, IMHO.
I agree 100%.
We had a similar discussion for the TI platforms, but due to the specific design of the TI power/clk in Linux (hwmod), we chose to keep the clocks handling in the board file at the moment.
Quoted 56 lines
Quoted 36 lines
Quoted 36 lines
(quoted diff) +0
-1-Jon(quoted diff) +0
-0
b/drivers/usb/dwc3/dwc3-generic.cindex6d9be9b245..90d4ff2ea7100644 ---a/drivers/usb/dwc3/dwc3-generic.c
+++b/drivers/usb/dwc3/dwc3-generic.cdrivers/usb/dwc3/dwc3-generic.c +11
-0@@ -119,6 +119,15 @@ struct dwc3_glue_ops { enum usb_dr_mode mode); }; +__weak int board_usb_of_init (struct udevice *dev) +{ +return 0 ; +} + +__weak void board_usb_of_cleanup (struct udevice *dev) +{ +} +static int dwc3_glue_bind (struct udevice *parent) {const void *fdt = gd->fdt_blob;@@ -242,6 +251,8 @@ static int dwc3_glue_probe(struct udevice *dev) index++; } + ret =board_usb_of_init (dev); +return 0 ; }@@ -249,6 +260,8 @@ static int dwc3_glue_remove(struct udevice *dev) {struct dwc3_glue_data *glue =dev_get_platdata (dev);Quoted 8 lines
drivers/usb/dwc3/dwc3-generic.c static int dwc3_glue_remove(struct udevice *dev) · line 271
Quoted 8 lines
drivers/usb/dwc3/dwc3-generic.c +2
-0+board_usb_of_cleanup (dev); +reset_release_bulk (&glue->resets);clk_release_bulk (&glue->clks);@@ -257,6 +270,7 @@ static int dwc3_glue_remove(struct udevice *dev) }Best regards,
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma at denx.de
Quoted 6 lines
Obviously the proper solution is implementing a proper DM clk driver. I generally refrain from just enabling a bunch of clocks and code in our board file, since our devices are SOM + carrier, and many customers design their own boards and then continue to use our bootloader. I am fine carrying the patch until we have the time to build the proper infrastructure in mainline.
Quick followup.
Has anyone tried to build this into SPL? I am getting lots of undefined symbols. undefined reference to usb_get_dr_mode' , undefined reference to device_bind_driver_to_node' etc.
-Jon
v4 cover Improvements for the dwc3_generic driver
Quoted 209 lines · Jon Nettleton
Quoted 202 lines · Jon Nettleton
Quoted 138 lines · Jean-Jacques Hiblot
Quoted 136 lines · Lukasz Majewski
Hi Jean-Jacques,
Quoted 123 lines · Jon Nettleton
Quoted 113 lines
Quoted 107 lines · Jean-Jacques Hiblot
Quoted 9 lines · Loic Devulder
Hi,
I re-tested this series on Khadas VIM1 and it still fix the USB issue I had with 'usb reset' (I already tested v2 patches).
I just have a message and I'm not sure that I had it last time:
"Error disabling PHY supply
Can't shutdown USB PHY1 for dwc3 atc9000000"Quoted 8 lines
But USB stack looks ok, I can plug/unplug USB key and do the reset, all works as expected.
Since my last test lot of changes has been done in Amlogic SoCs, maybe it's because of this?
So if you want you can add my tested-by flag.
Tested-by Loic Devulder <[email protected]>Thank you for testing
Quoted 80 lines · Jean-Jacques Hiblot
Quoted 79 lines
This series aims at bringing improvements to the
dwc3_genericdriver so that it can be used by most of the platforms using the dwc3 controller.I tested this on with DRA7 and AM57x platforms for both Peripheral and Host operations. The code to enable DM USB host & dev support for those platforms will be submitted in a separate series.
Michal Simek has tested this series:
" I have tested it on zcu100 with usb stick, usb to ethernet converter and also dfu.Tested-by Michal Simek <[email protected]>"Enhancements:
- use separateKconfigoption for DM USB Periphal and DM USB Host. This allow platforms to keep their non-DM USB peripheral code and use the DM USB host.
- fixes the bind/probe confusion indwc3_generic. The probe is done when the USB device is first needed.
- handles PHYs when in the peripheral mode. The code to handle the PHYs is shared with the host side
- handles clock and reset
- bind host controller to the more generic driver 'xhci-dwc3'Changes in v4:
- rebased on latest U-Boot
- renamedDM_USB_DEVasDM_USB_GADGET
- Add a new commit to create a new UCLASS for USB gadget driversChanges in v3:
- fixes bugdwc3_setup_phy(): the phy arrays wasn't returned. This was visible only when the device is removed.
- Stub the DWC3 PHY operations ifCONFIG_IS_ENABLED(PHY)is false. This fixes all build issues but one (evb-rk3328).
- Fix build issue with evb-rk3328 by enablingCONFIG_USB_DWC3. This has little impact on the footprint and should not break the runtime as the xhci-rockchip driver has its own probe function. Nevertheless this was !!! NOT TESTED !!! by lack of hwChanges in v2:
- Updated commit log
- Fixed typo inthordown.c
- selectDM_USB_DEVby default for zynqmp platformsJean-Jacques Hiblot (10):
usb: gadget: Do not callboard_usb_xxx()directly in USB
gadget drivers
usb: introduce a separate config option for DM USB device
usb: udc: implement DM versions of
usb_gadget_initialize()/_release()/_handle_interrupt()
dwc3_generic: do not probe the USB device driver when it's
bound dwc3: move phy operation tocore.c
dm: usb: create a new UCLASS ID for USB gadget devices
configs: evb-rk3328: EnableCONFIG_USB_DWC3
dwc3-generic: Handle the PHYs, the clocks and the reset lines
dwc3-generic: Addselect_dr_modeoperation
usb: dwc3: Fix a compilation error with the edison defconfig
arch/arm/Kconfig| 2 +
board/sunxi/board.c| 2 +-
cmd/fastboot.c| 4 +-
cmd/rockusb.c| 4 +-
cmd/thordown.c| 4 +-
cmd/usb_gadget_sdp.c| 4 +-
cmd/usb_mass_storage.c| 4 +-
common/dfu.c| 6 +-
configs/evb-rk3328_defconfig | 1 +
drivers/usb/Kconfig| 14 +++
drivers/usb/dwc3/Kconfig| 7 +-
drivers/usb/dwc3/core.c| 89 ++++++++++++++-
drivers/usb/dwc3/dwc3-generic.c| 208
++++++++++++++++++++++++++++--------drivers/usb/dwc3/ep0.c | 2 +- drivers/usb/gadget/ether.c | 40 ++----- drivers/usb/gadget/udc/Makefile | 4 + drivers/usb/gadget/udc/udc-core.c | 3 +- drivers/usb/gadget/udc/udc-uclass.c | 58 ++++++++++Quoted 8 lines
Quoted 8 lines
drivers/usb/host/xhci-dwc3.c | 95 ++-------------- drivers/usb/musb-new/omap2430.c | 2 +- drivers/usb/musb-new/sunxi.c | 2 +- include/dm/uclass-id.h | 1 + include/dwc3-uboot.h | 19 ++++ include/linux/usb/gadget.h | 18 ++++ 24 files changed,401 insertions(+), 192 deletions(-) create mode 100644
drivers/usb/gadget/udc/udc-uclass.cQuoted 4 lines
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-bootQuoted 9 lines
First off thanks for the work. I have imported it into my u-boot tree for the iMX8M and now have both usb host and gadget mode working simultaneously. There is one catch. Currently, the iMX8M codebase does not support clock and power device initialization from DM. I have patched the driver to punt back to the board to do these initializations in the following patch. Yes I know not ideal, but functional. I am wondering if we should support architecture specific implementation quirks for boards that don't fully support DM initialization yet.
Quoted 8 lines
That is not fitting the DM model. I had the same issue and finally enabled the clocks in the
board_late_init():
board/ti/dra7xx/evm.c:662:intboard_late_init(void)Quoted 3 lines
I am open to writing something more complete if
we decide it is something worth pursuing, otherwise I will carry this patch in my tree for time being.The true solution would be to implement the support for clk.
Many other people on the ML (including me) see the urgent need to implement the
DM_CLKfor e.g. imx6/5/7/8, etc.Quoted 63 lines
Quoted 2 lines
I think that it would be best to add it clock by clock. The stubs in board code/files is a dead end, IMHO.
I agree 100%.
We had a similar discussion for the TI platforms, but due to the specific design of the TI power/clk in Linux (hwmod), we chose to keep the clocks handling in the board file at the moment.
Quoted 54 lines
Quoted 35 lines
Quoted 35 lines
(quoted diff) +0
-1-Jon(quoted diff) +0
-0
b/drivers/usb/dwc3/dwc3-generic.cindex6d9be9b245..90d4ff2ea7100644 ---a/drivers/usb/dwc3/dwc3-generic.c
+++b/drivers/usb/dwc3/dwc3-generic.cdrivers/usb/dwc3/dwc3-generic.c +11
-0@@ -119,6 +119,15 @@ struct dwc3_glue_ops { enum usb_dr_mode mode); }; +__weak int board_usb_of_init (struct udevice *dev) +{ +return 0 ; +} + +__weak void board_usb_of_cleanup (struct udevice *dev) +{ +} +static int dwc3_glue_bind (struct udevice *parent) {const void *fdt = gd->fdt_blob;@@ -242,6 +251,8 @@ static int dwc3_glue_probe(struct udevice *dev) index++; } + ret =board_usb_of_init (dev); +return 0 ; }@@ -249,6 +260,8 @@ static int dwc3_glue_remove(struct udevice *dev) {struct dwc3_glue_data *glue =dev_get_platdata (dev);Quoted 8 lines
drivers/usb/dwc3/dwc3-generic.c static int dwc3_glue_remove(struct udevice *dev) · line 271
Quoted 8 lines
drivers/usb/dwc3/dwc3-generic.c +2
-0+board_usb_of_cleanup (dev); +reset_release_bulk (&glue->resets);clk_release_bulk (&glue->clks);@@ -257,6 +270,7 @@ static int dwc3_glue_remove(struct udevice *dev) }Best regards,
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma at denx.deQuoted 6 lines
Obviously the proper solution is implementing a proper DM clk driver. I generally refrain from just enabling a bunch of clocks and code in our board file, since our devices are SOM + carrier, and many customers design their own boards and then continue to use our bootloader. I am fine carrying the patch until we have the time to build the proper infrastructure in mainline.
Quoted 5 lines
Quick followup.
Has anyone tried to build this into SPL? I am getting lots of undefined symbols. undefined reference to
usb_get_dr_mode' , undefined reference todevice_bind_driver_to_node' etc.
I've used it in SPL on am33xx based platforms. You may have to enable a couple of options, including SPL_DM.
Quoted 2 lines
-Jon