driver model bring-up of dwc3 usb peripheral
Subsystems (7)
cover driver model bring-up of dwc3 usb peripheral
This patch series enables ti dwc3 usb peripherial driver to adopt driver model and DT. And also adds support for to USB device boot using RNDIS for AM437x.
Tested on AM437x GP EVM in USB RNDIS boot mode. ROM downloads SPL, SPL loads U-Boot via usb ether and then U-Boot loads kernel image using the same interface.
Based on previous work submitted by Mugunthan here:
https://lists.denx.de/pipermail/u-boot/2016-March/250115.html
Mugunthan V N (7):
drivers: usb: dwc3: remove devm_zalloc from linux_compact
drivers: usb: dwc3-omap: move usb_gadget_handle_interrupts from board
files to drivers
am437x: board: do not register usb devices when CONFIG_DM_USB is
defined
omap5/am57xx/dra7xx: board: do not register usb devices when
CONFIG_DM_USB is defined
drivers: usb: dwc3: add ti dwc3 misc driver for wrapper
drivers: usb: common: add support to get maximum speed from dt
drivers: usb: dwc3: add ti dwc3 peripheral driver with driver model
support
Vignesh R (4):
dwc3: Add support for USB device boot
am43xx: Add USB device boot support
configs: am43xx: Enable configs to support USB device boot
ARM: am437x-gp-evm-u-boot.dtsi: Enable nodes for USB device boot
arch/arm/dts/am437x-gp-evm-u-boot.dtsi | 20 +++ arch/arm/mach-omap2/boot-common.c | 3 +- board/ti/am43xx/board.c | 41 +++--- board/ti/am57xx/board.c | 13 +- board/ti/dra7xx/evm.c | 13 +- board/ti/omap5_uevm/evm.c | 13 +- configs/am43xx_evm_defconfig | 13 +- configs/am43xx_evm_usbhost_boot_defconfig | 1 + drivers/usb/common/common.c | 29 ++++ drivers/usb/dwc3/core.c | 64 ++++++++- drivers/usb/dwc3/core.h | 6 + drivers/usb/dwc3/dwc3-omap.c | 232 +++++++++++++++++++++++++++++- drivers/usb/dwc3/gadget.c | 2 +- drivers/usb/dwc3/linux-compat.h | 5 - drivers/usb/dwc3/ti_usb_phy.c | 1 + drivers/usb/gadget/ether.c | 9 +- drivers/usb/gadget/gadget_chips.h | 2 + include/configs/am43xx_evm.h | 27 ++-- include/linux/usb/otg.h | 9 ++ scripts/Makefile.spl | 1 + 20 files changed, 418 insertions(+), 86 deletions(-)
Signature · 1 line
2.13.0
PATCH 1/11 drivers: usb: dwc3: remove devm_zalloc from linux_compact
From: Mugunthan V N <[email protected]>
devm_zalloc() is already defined in dm/device.h header, so devm_zalloc can be removed from linux_compact.h beader file.
--- drivers/usb/dwc3/core.c | 7 +++++-- drivers/usb/dwc3/dwc3-omap.c | 3 ++- drivers/usb/dwc3/linux-compat.h | 5 ----- drivers/usb/dwc3/ti_usb_phy.c | 1 + 4 files changed, 8 insertions(+), 8 deletions(-)
drivers/usb/dwc3/core.c +5 -2
@@ -19,6 +19,7 @@#include <dwc3-uboot.h> #include <asm/dma-mapping.h> #include <linux/ioport.h> +#include <dm.h> #include <linux/usb/ch9.h> #include <linux/usb/gadget.h>
@@ -111,7 +112,8 @@ static struct dwc3_event_buffer *dwc3_alloc_one_event_buffer(struct dwc3 *dwc, {struct dwc3_event_buffer *evt; - evt =devm_kzalloc (dwc->dev,sizeof (*evt),GFP_KERNEL ); + evt =devm_kzalloc ((struct udevice *)dwc->dev,sizeof (*evt), +GFP_KERNEL );if (!evt)return ERR_PTR (-ENOMEM );
@@ -624,7 +626,8 @@ int dwc3_uboot_init(struct dwc3_device *dwc3_dev)void *mem; - mem =devm_kzalloc (dev,sizeof (*dwc) +DWC3_ALIGN_MASK ,GFP_KERNEL ); + mem =devm_kzalloc ((struct udevice *)dev, +sizeof (*dwc) +DWC3_ALIGN_MASK ,GFP_KERNEL );if (!mem)return -ENOMEM ;
drivers/usb/dwc3/dwc3-omap.c +2 -1
@@ -20,6 +20,7 @@#include <dwc3-omap-uboot.h> #include <linux/usb/dwc3-omap.h> #include <linux/ioport.h> +#include <dm.h> #include <linux/usb/otg.h> #include <linux/compat.h>
@@ -377,7 +378,7 @@ int dwc3_omap_uboot_init(struct dwc3_omap_device *omap_dev)struct device *dev =NULL ;struct dwc3_omap *omap; - omap =devm_kzalloc (dev,sizeof (*omap),GFP_KERNEL ); + omap =devm_kzalloc ((struct udevice *)dev,sizeof (*omap),GFP_KERNEL );if (!omap)return -ENOMEM ;
drivers/usb/dwc3/linux-compat.h +0 -5
@@ -23,9 +23,4 @@ static inline size_t strlcat(char *dest, const char *src, size_t n) return strlen(dest) + strlen(src); } -static inline void *devm_kzalloc (struct device *dev,unsigned int size, -unsigned int flags) -{ -return kzalloc (size, flags); -}#endif
drivers/usb/dwc3/ti_usb_phy.c +1 -0
@@ -24,6 +24,7 @@#include <linux/ioport.h> #include <asm/io.h> #include <asm/arch/sys_proto.h> +#include <dm.h> #include "linux-compat.h"
Signature · 1 line
2.13.0
PATCH 2/11 drivers: usb: dwc3-omap: move usb_gadget_handle_interrupts from board files to drivers
In reply to Vignesh RFrom: Mugunthan V N <[email protected]>
In board files of am437x, dra7xx, omap5 and am5xx, usb_gadget_handle_interrupts() is just a place holder to handle dwc3 interrupts, nothing related to board is handled here, so move usb_gadget_handle_interrupts() from board files to dwc3-omap.c to avoid code duplication based on boards.
--- board/ti/am43xx/board.c | 11 ----------- board/ti/dra7xx/evm.c | 11 ----------- board/ti/omap5_uevm/evm.c | 11 ----------- drivers/usb/dwc3/dwc3-omap.c | 12 ++++++++++++ 4 files changed, 12 insertions(+), 33 deletions(-)
board/ti/am43xx/board.c +0 -11
@@ -660,17 +660,6 @@ static struct ti_usb_phy_device usb_phy2_device = { .usb2_phy_power = (void *)USB2_PHY2_POWER, .index = 1, }; - -int usb_gadget_handle_interrupts (int index) -{ -u32 status; - - status =dwc3_omap_uboot_interrupt_status (index); -if (status) -dwc3_uboot_handle_interrupt (index); - -return 0 ; -}#endif /* CONFIG_USB_DWC3 */ #if defined(CONFIG_USB_DWC3 ) || defined(CONFIG_USB_XHCI_OMAP )
board/ti/dra7xx/evm.c +0 -11
@@ -802,17 +802,6 @@ int omap_xhci_board_usb_cleanup(int index, enum usb_init_type init)disable_usb_clocks (index); return 0; } - -int usb_gadget_handle_interrupts (int index) -{ -u32 status; - - status =dwc3_omap_uboot_interrupt_status (index); -if (status) -dwc3_uboot_handle_interrupt (index); - -return 0 ; -}#endif #if defined(CONFIG_SPL_BUILD ) && defined(CONFIG_SPL_OS_BOOT )
board/ti/omap5_uevm/evm.c +0 -11
@@ -117,17 +117,6 @@ int board_usb_cleanup(int index, enum usb_init_type init) return 0; } - -int usb_gadget_handle_interrupts (int index) -{ -u32 status; - - status =dwc3_omap_uboot_interrupt_status (index); -if (status) -dwc3_uboot_handle_interrupt (index); - -return 0 ; -}#endif /**
drivers/usb/dwc3/dwc3-omap.c +12 -0
@@ -24,6 +24,7 @@#include <linux/usb/otg.h> #include <linux/compat.h> +#include <dwc3-uboot.h> #include "linux-compat.h"
@@ -446,6 +447,17 @@ int dwc3_omap_uboot_interrupt_status(int index)return 0 ; } +int usb_gadget_handle_interrupts (int index) +{ +u32 status; + + status =dwc3_omap_uboot_interrupt_status (index); +if (status) +dwc3_uboot_handle_interrupt (index); + +return 0 ; +} +MODULE_ALIAS ("platform:omap-dwc3" );MODULE_AUTHOR ("Felipe Balbi <[email protected]>" );MODULE_LICENSE ("GPL v2" );
Signature · 1 line
2.13.0
PATCH 3/11 am437x: board: do not register usb devices when CONFIG_DM_USB is defined
In reply to Vignesh RFrom: Mugunthan V N <[email protected]>
Do not register usb devices when CONFIG_DM_USB is define.
--- board/ti/am43xx/board.c | 10 ++-------- configs/am43xx_evm_usbhost_boot_defconfig | 1 + 2 files changed, 3 insertions(+), 8 deletions(-)
board/ti/am43xx/board.c +2 -8
@@ -624,7 +624,7 @@ int board_late_init(void) }#endif -#ifdef CONFIG_USB_DWC3 +#if defined(CONFIG_USB_DWC3 ) && !defined(CONFIG_DM_USB )static struct dwc3_device usb_otg_ss1 = { .maximum_speed =USB_SPEED_HIGH , .base = USB_OTG_SS1_BASE,
@@ -660,13 +660,10 @@ static struct ti_usb_phy_device usb_phy2_device = { .usb2_phy_power = (void *)USB2_PHY2_POWER, .index = 1, }; -#endif /* CONFIG_USB_DWC3 */ -#if defined(CONFIG_USB_DWC3 ) || defined(CONFIG_USB_XHCI_OMAP )int omap_xhci_board_usb_init (int index,enum usb_init_type init) {enable_usb_clocks (index); -#ifdef CONFIG_USB_DWC3 switch (index) {case 0 :if (init ==USB_INIT_DEVICE ) {
@@ -689,14 +686,12 @@ int omap_xhci_board_usb_init(int index, enum usb_init_type init)default :printf ("Invalid Controller Index\n" ); } -#endif return 0 ; }int omap_xhci_board_usb_cleanup (int index,enum usb_init_type init) { -#ifdef CONFIG_USB_DWC3 switch (index) {case 0 :case 1 :
@@ -709,12 +704,11 @@ int omap_xhci_board_usb_cleanup(int index, enum usb_init_type init)default : printf("Invalid Controller Index\n"); } -#endif disable_usb_clocks (index);return 0 ; } -#endif /* defined(CONFIG_USB_DWC3) || defined(CONFIG_USB_XHCI_OMAP) */ +#endif /* defined(CONFIG_USB_DWC3) && !defined(CONFIG_DM_USB) */ #ifdef CONFIG_DRIVER_TI_CPSW
configs/am43xx_evm_usbhost_boot_defconfig +1 -0
@@ -69,6 +69,7 @@ CONFIG_USB_DWC3_PHY_OMAP=y CONFIG_USB_STORAGE=y CONFIG_USB_GADGET=y CONFIG_USB_GADGET_DOWNLOAD=y +CONFIG_SPL_USB_GADGET_SUPPORT=y CONFIG_G_DNL_MANUFACTURER="Texas Instruments" CONFIG_G_DNL_VENDOR_NUM=0x0403 CONFIG_G_DNL_PRODUCT_NUM=0xbd00
Signature · 1 line
2.13.0
PATCH 4/11 omap5/am57xx/dra7xx: board: do not register usb devices when CONFIG_DM_USB is defined
In reply to Vignesh RFrom: Mugunthan V N <[email protected]>
Do not register usb devices when CONFIG_DM_USB is define.
--- board/ti/am57xx/board.c | 2 +- board/ti/dra7xx/evm.c | 2 +- board/ti/omap5_uevm/evm.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
board/ti/am57xx/board.c +1 -1
@@ -688,7 +688,7 @@ int spl_start_uboot(void) }#endif -#ifdef CONFIG_USB_DWC3 +#if defined(CONFIG_USB_DWC3 ) && !defined(CONFIG_DM_USB )static struct dwc3_device usb_otg_ss2 = { .maximum_speed =USB_SPEED_HIGH , .base = DRA7_USB_OTG_SS2_BASE,
board/ti/dra7xx/evm.c +1 -1
@@ -711,7 +711,7 @@ int board_mmc_init(bd_t *bis) }#endif -#ifdef CONFIG_USB_DWC3 +#if defined(CONFIG_USB_DWC3 ) && !defined(CONFIG_DM_USB )static struct dwc3_device usb_otg_ss1 = { .maximum_speed =USB_SPEED_SUPER , .base = DRA7_USB_OTG_SS1_BASE,
board/ti/omap5_uevm/evm.c +1 -1
@@ -59,7 +59,7 @@ struct tca642x_bank_info tca642x_init[] = { .configuration_reg = 0x40 }, }; -#ifdef CONFIG_USB_DWC3 +#if defined(CONFIG_USB_DWC3 ) && !defined(CONFIG_DM_USB )static struct dwc3_device usb_otg_ss = { .maximum_speed =USB_SPEED_SUPER , .base = OMAP5XX_USB_OTG_SS_BASE,
Signature · 1 line
2.13.0
PATCH 5/11 drivers: usb: dwc3: add ti dwc3 misc driver for wrapper
In reply to Vignesh RFrom: Mugunthan V N <[email protected]>
Add a misc driver for DWC3 wrapper, so that based on dr_mode the USB devices can bind to USB host or USB device drivers.
--- board/ti/am57xx/board.c | 11 ---------- drivers/usb/dwc3/core.h | 4 ++++ drivers/usb/dwc3/dwc3-omap.c | 52 ++++++++++++++++++++++++++++++++++++++++++++ drivers/usb/dwc3/gadget.c | 2 +- 4 files changed, 57 insertions(+), 12 deletions(-)
board/ti/am57xx/board.c +0 -11
@@ -706,17 +706,6 @@ static struct ti_usb_phy_device usb_phy2_device = { .usb2_phy_power = (void *)DRA7_USB2_PHY2_POWER, .index = 1, }; - -int usb_gadget_handle_interrupts (int index) -{ -u32 status; - - status =dwc3_omap_uboot_interrupt_status (index); -if (status) -dwc3_uboot_handle_interrupt (index); - -return 0 ; -}#endif /* CONFIG_USB_DWC3 */ #if defined(CONFIG_USB_DWC3 ) || defined(CONFIG_USB_XHCI_OMAP )
drivers/usb/dwc3/core.h +4 -0
@@ -713,7 +713,11 @@ struct dwc3 {/* device lock */ spinlock_t lock; +#ifndef CONFIG_DM_USB struct device *dev; +#else +struct udevice *dev; +#endif struct platform_device *xhci;struct resource xhci_resources[DWC3_XHCI_RESOURCES_NUM ];
drivers/usb/dwc3/dwc3-omap.c +52 -0
67 lines not on this page · raw message
drivers/usb/dwc3/gadget.c +1 -1
@@ -2610,7 +2610,7 @@ int dwc3_gadget_init(struct dwc3 *dwc)if (ret) goto err4; - ret =usb_add_gadget_udc (dwc->dev, &dwc->gadget); + ret =usb_add_gadget_udc ((struct device *)dwc->dev, &dwc->gadget);if (ret) {dev_err (dwc->dev,"failed to register udc\n" ); goto err4;
Signature · 1 line
2.13.0
PATCH 6/11 drivers: usb: common: add support to get maximum speed from dt
In reply to Vignesh RFrom: Mugunthan V N <[email protected]>
Add support to get maximum speed from dt so that usb drivers makes use of it for DT parsing.
--- drivers/usb/common/common.c | 29 +++++++++++++++++++++++++++++ include/linux/usb/otg.h | 9 +++++++++ scripts/Makefile.spl | 1 + 3 files changed, 39 insertions(+)
drivers/usb/common/common.c +29 -0
@@ -10,6 +10,7 @@#include <common.h> #include <libfdt.h> #include <linux/usb/otg.h> +#include <linux/usb/ch9.h> DECLARE_GLOBAL_DATA_PTR ;
@@ -38,3 +39,31 @@ enum usb_dr_mode usb_get_dr_mode(int node)return USB_DR_MODE_UNKNOWN ; } + +static const char *const speed_names[] = { + [USB_SPEED_UNKNOWN ] ="UNKNOWN" , + [USB_SPEED_LOW ] ="low-speed" , + [USB_SPEED_FULL ] ="full-speed" , + [USB_SPEED_HIGH ] ="high-speed" , + [USB_SPEED_WIRELESS ] ="wireless" , + [USB_SPEED_SUPER ] ="super-speed" , +}; + +enum usb_device_speed usb_get_maximum_speed (int node) +{ +const void *fdt = gd->fdt_blob; +const char *max_speed; +int i; + + max_speed =fdt_getprop (fdt, node,"maximum-speed" ,NULL ); +if (!max_speed) { +error ("usb dr_mode not found\n" ); +return USB_DR_MODE_UNKNOWN ; + } + +for (i =0 ; i <ARRAY_SIZE (speed_names); i++) +if (!strcmp (max_speed, speed_names[i])) +return i; + +return USB_SPEED_UNKNOWN ; +}
include/linux/usb/otg.h +9 -0
@@ -26,4 +26,13 @@ enum usb_dr_mode {*/ enum usb_dr_mode usb_get_dr_mode (int node); +/** +* usb_get_maximum_speed() - Get maximum speed for given device +* @node: Node offset to the given device +* +* The function gets phy interface string from property 'maximum-speed', +* and returns the correspondig enum usb_device_speed +*/ +enum usb_device_speed usb_get_maximum_speed (int node); +#endif /* __LINUX_USB_OTG_H */
scripts/Makefile.spl +1 -0
@@ -78,6 +78,7 @@ endif libs-$(CONFIG_SPL_LIBDISK_SUPPORT) += disk/ libs-y += drivers/ +libs-y += drivers/usb/common/ libs-$(CONFIG_SPL_USB_GADGET_SUPPORT) += drivers/usb/dwc3/ libs-y += dts/ libs-y += fs/
Signature · 1 line
2.13.0
PATCH 7/11 drivers: usb: dwc3: add ti dwc3 peripheral driver with driver model support
In reply to Vignesh RFrom: Mugunthan V N <[email protected]>
Add a TI DWC3 peripheral driver with driver model support and the driver will be bound by the DWC3 wrapper driver based on the dr_mode device tree entry.
--- drivers/usb/dwc3/core.c | 57 +++++++++++++++ drivers/usb/dwc3/core.h | 2 + drivers/usb/dwc3/dwc3-omap.c | 167 ++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 225 insertions(+), 1 deletion(-)
drivers/usb/dwc3/core.c +57 -0
@@ -603,6 +603,8 @@ static void dwc3_core_exit_mode(struct dwc3 *dwc)#define DWC3_ALIGN_MASK (16 - 1) +#ifndef CONFIG_DM_USB +/** * dwc3_uboot_init - dwc3 core uboot initialization code * @dwc3_dev: struct dwc3_device containing initialization data
@@ -789,3 +791,58 @@ MODULE_ALIAS("platform:dwc3");MODULE_AUTHOR ("Felipe Balbi <[email protected]>" );MODULE_LICENSE ("GPL v2" );MODULE_DESCRIPTION ("DesignWare USB3 DRD Controller Driver" ); + +#else + +int dwc3_init (struct dwc3 *dwc) +{ +int ret; + +dwc3_cache_hwparams (dwc); + + ret =dwc3_alloc_event_buffers (dwc,DWC3_EVENT_BUFFERS_SIZE ); +if (ret) { +dev_err (dwc->dev,"failed to allocate event buffers\n" ); +return -ENOMEM ; + } + + ret =dwc3_core_init (dwc); +if (ret) { +dev_err (dev,"failed to initialize core\n" ); + goto err0; + } + + ret =dwc3_event_buffers_setup (dwc); +if (ret) { +dev_err (dwc->dev,"failed to setup event buffers\n" ); + goto err1; + } + + ret =dwc3_core_init_mode (dwc); +if (ret) + goto err2; + +return 0 ; + +err2: +dwc3_event_buffers_cleanup (dwc); + +err1: +dwc3_core_exit (dwc); + +err0: +dwc3_free_event_buffers (dwc); + +return ret; +} + +void dwc3_remove (struct dwc3 *dwc) +{ +dwc3_core_exit_mode (dwc); +dwc3_event_buffers_cleanup (dwc); +dwc3_free_event_buffers (dwc); +dwc3_core_exit (dwc); +kfree (dwc->mem); +} + +#endif
drivers/usb/dwc3/core.h +2 -0
@@ -992,6 +992,8 @@ struct dwc3_gadget_ep_cmd_params {/* prototypes */ int dwc3_gadget_resize_tx_fifos (struct dwc3 *dwc); +int dwc3_init (struct dwc3 *dwc); +void dwc3_remove (struct dwc3 *dwc);#ifdef CONFIG_USB_DWC3_HOST int dwc3_host_init (struct dwc3 *dwc);
drivers/usb/dwc3/dwc3-omap.c +166 -1
209 lines not on this page · raw message
Signature · 1 line
2.13.0
PATCH 8/11 dwc3: Add support for USB device boot
In reply to Vignesh RAdd support to for USB device boot for dwc3 gadget, so that RNDIS can be used in SPL to download next stage.
Provide a way to read MAC address for usb_ether device from board function.
--- drivers/usb/gadget/ether.c | 9 ++++++++- drivers/usb/gadget/gadget_chips.h | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-)
drivers/usb/gadget/ether.c +8 -1
@@ -2383,6 +2383,7 @@ static int _usb_eth_init(struct ether_priv *priv)#ifdef CONFIG_USBNET_HOST_ADDR strlcpy (host_addr,CONFIG_USBNET_HOST_ADDR ,sizeof (host_addr));#endif +/* Check if the user overruled the MAC addresses */ if (getenv ("usbnet_devaddr" )) strlcpy(dev_addr, getenv("usbnet_devaddr"),
@@ -2619,6 +2620,10 @@ int usb_eth_initialize(bd_t *bi) return 0; }#else +void __weak board_set_usbnet_devaddr (void ) +{ +} +static int usb_eth_start (struct udevice *dev) {struct ether_priv *priv =dev_get_priv (dev);
@@ -2683,6 +2688,8 @@ static int usb_eth_probe(struct udevice *dev) priv->netdev = dev; l_priv = priv; +/* Get MAC address for USB ETH interface */ +board_set_usbnet_devaddr ();get_ether_addr (CONFIG_USBNET_DEVADDR , pdata->enetaddr);eth_setenv_enetaddr ("usbnet_devaddr" , pdata->enetaddr);
@@ -2726,6 +2733,6 @@ U_BOOT_DRIVER(eth_usb) = { .ops = &usb_eth_ops, .priv_auto_alloc_size = sizeof(struct ether_priv), .platdata_auto_alloc_size = sizeof(struct eth_pdata), - .flags = DM_FLAG_ALLOC_PRIV_DMA, + .flags = DM_FLAG_ALLOC_PRIV_DMA | DM_FLAG_PRE_RELOC, };#endif /* CONFIG_DM_ETH */
drivers/usb/gadget/gadget_chips.h +2 -0
@@ -231,5 +231,7 @@ static inline int usb_gadget_controller_number(struct usb_gadget *gadget)return 0x21 ; else if (gadget_is_fotg210(gadget)) return 0x22; + else if (gadget_is_dwc3(gadget)) + return 0x23;return -ENOENT ; }
Signature · 1 line
2.13.0
PATCH 9/11 am43xx: Add USB device boot support
In reply to Vignesh RAdd function to populate MAC address for usb ether device to support RNDIS in SPL. Also make arch_misc_init() available when CONFIG_SPL_USBEHT_SUPPORT is defined so that usb_ether_init() is called for am43xx as well.
--- arch/arm/mach-omap2/boot-common.c | 3 ++- board/ti/am43xx/board.c | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-)
arch/arm/mach-omap2/boot-common.c +2 -1
@@ -194,7 +194,8 @@ void spl_board_init(void)#ifdef CONFIG_SPL_I2C_SUPPORT i2c_init (CONFIG_SYS_OMAP24_I2C_SPEED ,CONFIG_SYS_OMAP24_I2C_SLAVE );#endif -#if defined(CONFIG_AM33XX ) && defined(CONFIG_SPL_MUSB_NEW_SUPPORT ) +#if (defined(CONFIG_AM33XX ) && defined(CONFIG_SPL_MUSB_NEW_SUPPORT )) || \ + defined(CONFIG_SPL_USBETH_SUPPORT )arch_misc_init ();#endif #if defined(CONFIG_HW_WATCHDOG )
board/ti/am43xx/board.c +20 -0
@@ -813,6 +813,26 @@ int board_eth_init(bd_t *bis) }#endif +#if defined(CONFIG_DM_ETH ) && defined(CONFIG_SPL_USBETH_SUPPORT ) +void board_set_usbnet_devaddr (void ) +{ +uint8_t mac_addr[6 ]; +uint32_t mac_hi, mac_lo; + + mac_lo =readl (&cdev->macid0l); + mac_hi =readl (&cdev->macid0h); + mac_addr[0 ] = mac_hi &0xFF ; + mac_addr[1 ] = (mac_hi &0xFF00 ) >>8 ; + mac_addr[2 ] = (mac_hi &0xFF0000 ) >>16 ; + mac_addr[3 ] = (mac_hi &0xFF000000 ) >>24 ; + mac_addr[4 ] = mac_lo &0xFF ; + mac_addr[5 ] = (mac_lo &0xFF00 ) >>8 ; + +if (is_valid_ethaddr (mac_addr)) +eth_setenv_enetaddr ("usbnet_devaddr" , mac_addr); +} +#endif +#ifdef CONFIG_SPL_LOAD_FIT int board_fit_config_name_match (const char *name) {
Signature · 1 line
2.13.0
PATCH 10/11 configs: am43xx: Enable configs to support USB device boot
In reply to Vignesh RClean up include/configs/am43xx_evm.h and add configs to support USB device boot for am43xx evm.
--- configs/am43xx_evm_defconfig | 13 ++++++++++++- include/configs/am43xx_evm.h | 27 ++++++++------------------- 2 files changed, 20 insertions(+), 20 deletions(-)
configs/am43xx_evm_defconfig +12 -1
@@ -22,7 +22,7 @@ CONFIG_ISO_PARTITION=y CONFIG_OF_CONTROL=y CONFIG_OF_LIST="am437x-gp-evm am437x-sk-evm am43x-epos-evm am437x-idk-evm" CONFIG_DM=y -# CONFIG_BLK is not set +CONFIG_BLK=y CONFIG_DFU_MMC=y CONFIG_DFU_RAM=y CONFIG_DFU_SF=y
@@ -50,3 +50,14 @@ CONFIG_USB_GADGET_DOWNLOAD=y CONFIG_G_DNL_MANUFACTURER="Texas Instruments" CONFIG_G_DNL_VENDOR_NUM=0x0403 CONFIG_G_DNL_PRODUCT_NUM=0xbd00 +CONFIG_MISC=y +CONFIG_DM_USB=y +CONFIG_CMD_USB=y +CONFIG_DM_ETH=y +CONFIG_SPL_USBETH_SUPPORT=y +CONFIG_SPL_USB_GADGET_SUPPORT=y +CONFIG_SPL_DRIVERS_MISC_SUPPORT=y +CONFIG_SPL_USB_HOST_SUPPORT=y +CONFIG_SPL_USB_SUPPORT=y +CONFIG_SPL_NET_SUPPORT=y +CONFIG_SPL_NET_VCI_STRING="AM43xx U-Boot SPL"
include/configs/am43xx_evm.h +8 -19
@@ -90,20 +90,6 @@#define CONFIG_AM437X_USB2PHY2_HOST #endif -#if defined(CONFIG_SPL_BUILD ) && !defined(CONFIG_SPL_USBETH_SUPPORT ) -#undef CONFIG_USB_DWC3_PHY_OMAP -#undef CONFIG_USB_DWC3_OMAP -#undef CONFIG_USB_DWC3 -#undef CONFIG_USB_DWC3_GADGET - -#undef CONFIG_USB_GADGET_DOWNLOAD -#undef CONFIG_USB_GADGET_VBUS_DRAW -#undef CONFIG_G_DNL_MANUFACTURER -#undef CONFIG_G_DNL_VENDOR_NUM -#undef CONFIG_G_DNL_PRODUCT_NUM -#undef CONFIG_USB_GADGET_DUALSPEED -#endif -/* * Disable MMC DM for SPL build and can be re-enabled after adding * DM support in SPL
@@ -258,11 +244,6 @@#define CONFIG_PHYLIB #define PHY_ANEG_TIMEOUT 8000/* PHY needs longer aneg time at 1G */ -#if defined(CONFIG_SPL_BUILD ) && defined(CONFIG_SPL_ETH_SUPPORT ) -#undef CONFIG_ENV_IS_IN_FAT -#define CONFIG_ENV_IS_NOWHERE -#endif -#define CONFIG_SYS_RX_ETH_BUFFER 64/* NAND support */
@@ -347,4 +328,12 @@#define NANDBOOT #endif /* CONFIG_NAND */ +#define CONFIG_ARCH_MISC_INIT + +#ifdef CONFIG_SPL_USBETH_SUPPORT +#define CONFIG_USB_ETHER +#define CONFIG_USB_ETH_RNDIS +#define CONFIG_USBNET_HOST_ADDR "de:ad:be:af:00:00" +#endif +#endif /* __CONFIG_AM43XX_EVM_H */
Signature · 1 line
2.13.0
PATCH 11/11 ARM: am437x-gp-evm-u-boot.dtsi: Enable nodes for USB device boot
In reply to Vignesh REnable USB nodes required to support RNDIS boot in SPL.
--- arch/arm/dts/am437x-gp-evm-u-boot.dtsi | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
arch/arm/dts/am437x-gp-evm-u-boot.dtsi +20 -0
@@ -36,3 +36,23 @@ &phy_sel { u-boot,dm-pre-reloc; }; + +&am43xx_control_usb2phy1 { + u-boot,dm-pre-reloc; +}; + +&ocp2scp0 { + u-boot,dm-pre-reloc; + + phy at 483a8000 { + u-boot,dm-pre-reloc; + }; +}; + +&dwc3_1 { + u-boot,dm-pre-reloc; + + usb at 48390000 { + u-boot,dm-pre-reloc; + }; +};
Signature · 1 line
2.13.0
PATCH 11/11 ARM: am437x-gp-evm-u-boot.dtsi: Enable nodes for USB device boot
Quoted 12 lines · Vignesh R
Enable USB nodes required to support RNDIS boot in SPL.
Signed-off-by Vignesh R <[email protected]>--- arch/arm/dts/am437x-gp-evm-u-boot.dtsi | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)arch/arm/dts/am437x-gp-evm-u-boot.dtsi +0
-0
arch/arm/dts/am437x-gp-evm-u-boot.dtsi line 38
Quoted 3 lines
arch/arm/dts/am437x-gp-evm-u-boot.dtsi +0
-0@@ -36,3 +36,23 @@ &phy_sel { u-boot,dm-pre-reloc; };
Can you mark all the below node as "u-boot,dm-spl" instead of u-boot,dm-pre-reloc?
Thanks and regards,
Lokesh
Quoted 21 lines
arch/arm/dts/am437x-gp-evm-u-boot.dtsi +20
-0+ +&am43xx_control_usb2phy1 { + u-boot,dm-pre-reloc; +}; + +&ocp2scp0 { + u-boot,dm-pre-reloc; + + phy at 483a8000 { + u-boot,dm-pre-reloc; + }; +}; + +&dwc3_1 { + u-boot,dm-pre-reloc; + + usb at 48390000 { + u-boot,dm-pre-reloc; + }; +};
PATCH 1/11 drivers: usb: dwc3: remove devm_zalloc from linux_compact
In reply to Vignesh R+Masahiro
Quoted 5 lines · Vignesh R
From: Mugunthan V N <[email protected]>
devm_zalloc()is already defined indm/device.hheader, sodevm_zalloccan be removed fromlinux_compact.hbeader file.
Quoted 8 lines
Signed-off-by Mugunthan V N <[email protected]>Signed-off-by Vignesh R <[email protected]>--- drivers/usb/dwc3/core.c | 7 +++++-- drivers/usb/dwc3/dwc3-omap.c | 3 ++- drivers/usb/dwc3/linux-compat.h | 5 ----- drivers/usb/dwc3/ti_usb_phy.c | 1 + 4 files changed, 8 insertions(+), 8 deletions(-)
PATCH 2/11 drivers: usb: dwc3-omap: move usb_gadget_handle_interrupts from board files to drivers
In reply to Vignesh RQuoted 8 lines · Vignesh R
From: Mugunthan V N <[email protected]>
In board files of am437x, dra7xx, omap5 and am5xx,
usb_gadget_handle_interrupts()is just a place holder to handle dwc3 interrupts, nothing related to board is handled here, so moveusb_gadget_handle_interrupts()from board files todwc3-omap.cto avoid code duplication based on boards.
Quoted 9 lines
Signed-off-by Mugunthan V N <[email protected]>Signed-off-by Vignesh R <[email protected]>--- board/ti/am43xx/board.c | 11 ----------- board/ti/dra7xx/evm.c | 11 ----------- board/ti/omap5_uevm/evm.c | 11 ----------- drivers/usb/dwc3/dwc3-omap.c | 12 ++++++++++++ 4 files changed, 12 insertions(+), 33 deletions(-)
PATCH 4/11 omap5/am57xx/dra7xx: board: do not register usb devices when CONFIG_DM_USB is defined
In reply to Vignesh RQuoted 11 lines · Vignesh R
From: Mugunthan V N <[email protected]>
Do not register usb devices when
CONFIG_DM_USBis define.Signed-off-by Mugunthan V N <[email protected]>Signed-off-by Vignesh R <[email protected]>--- board/ti/am57xx/board.c | 2 +- board/ti/dra7xx/evm.c | 2 +- board/ti/omap5_uevm/evm.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
PATCH 5/11 drivers: usb: dwc3: add ti dwc3 misc driver for wrapper
In reply to Vignesh RQuoted 5 lines · Vignesh R
From: Mugunthan V N <[email protected]>
Add a misc driver for DWC3 wrapper, so that based on
dr_modethe USB devices can bind to USB host or USB device drivers.
Quoted 8 lines
Signed-off-by Mugunthan V N <[email protected]>Signed-off-by Vignesh R <[email protected]>--- board/ti/am57xx/board.c | 11 ---------- drivers/usb/dwc3/core.h | 4 ++++ drivers/usb/dwc3/dwc3-omap.c | 52 ++++++++++++++++++++++++++++++++++++++++++++ drivers/usb/dwc3/gadget.c | 2 +- 4 files changed, 57 insertions(+), 12 deletions(-)
Can you explain why this is a misc driver, and how it will be instantiated?
PATCH 6/11 drivers: usb: common: add support to get maximum speed from dt
In reply to Vignesh RQuoted 5 lines · Vignesh R
From: Mugunthan V N <[email protected]>
Add support to get maximum speed from dt so that usb drivers makes use of it for DT parsing.
Quoted 7 lines
Signed-off-by Mugunthan V N <[email protected]>Signed-off-by Vignesh R <[email protected]>--- drivers/usb/common/common.c | 29 +++++++++++++++++++++++++++++ include/linux/usb/otg.h | 9 +++++++++ scripts/Makefile.spl | 1 + 3 files changed, 39 insertions(+)
PATCH 8/11 dwc3: Add support for USB device boot
In reply to Vignesh RQuoted 10 lines · Vignesh R
Add support to for USB device boot for dwc3 gadget, so that RNDIS can be used in SPL to download next stage.
Provide a way to read MAC address forusb_etherdevice from board function.Signed-off-by Vignesh R <[email protected]>--- drivers/usb/gadget/ether.c | 9 ++++++++- drivers/usb/gadget/gadget_chips.h | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-)
It looks like there are a few changes in here and it should be split into 2-3 patches.
Regards,
Simon
PATCH 3/11 am437x: board: do not register usb devices when CONFIG_DM_USB is defined
In reply to Vignesh RQuoted 3 lines · Vignesh R
From: Mugunthan V N <[email protected]>
Do not register usb devices when
CONFIG_DM_USBis define.
I suggest s/define/enabled/
PATCH 5/11 drivers: usb: dwc3: add ti dwc3 misc driver for wrapper
In reply to Simon GlassHi,
Quoted 15 lines · Simon Glass
Quoted 5 lines · Vignesh R
From: Mugunthan V N <[email protected]>
Add a misc driver for DWC3 wrapper, so that based on
dr_modethe USB devices can bind to USB host or USB device drivers.Quoted 8 lines
Signed-off-by Mugunthan V N <[email protected]>Signed-off-by Vignesh R <[email protected]>--- board/ti/am57xx/board.c | 11 ---------- drivers/usb/dwc3/core.h | 4 ++++ drivers/usb/dwc3/dwc3-omap.c | 52 ++++++++++++++++++++++++++++++++++++++++++++ drivers/usb/dwc3/gadget.c | 2 +- 4 files changed, 57 insertions(+), 12 deletions(-)
Quoted 1 line
Can you explain why this is a misc driver, and how it will be instantiated?
Based on dr_mode property, the device node needs to bind to either "host" driver or "peripheral" driver. Therefore, this wrapper is written for DWC3, which on bind will read dr_mode property and appropriately associate USB DT node with DWC3 peripheral driver or host driver.
This is similar to what exists today for MUSB[1] and is instantiated by arch_misc_init() function for am33xx and am43xx
I got these patch from U-Boot list which the author had submitted previosuly and got Reviewed-by and did not look deep into it. But looks like this patch really needs be read along with patch 7/10. I will re-split and reorder this patch in the next version.
[1]https://www.mail-archive.com/u-boot at lists.denx.de/msg231076.html
Signature · 2 lines
Regards Vignesh
PATCH 5/11 drivers: usb: dwc3: add ti dwc3 misc driver for wrapper
In reply to Simon GlassHi,
Quoted 15 lines · Simon Glass
Quoted 5 lines · Vignesh R
From: Mugunthan V N <[email protected]>
Add a misc driver for DWC3 wrapper, so that based on
dr_modethe USB devices can bind to USB host or USB device drivers.Quoted 8 lines
Signed-off-by Mugunthan V N <[email protected]>Signed-off-by Vignesh R <[email protected]>--- board/ti/am57xx/board.c | 11 ---------- drivers/usb/dwc3/core.h | 4 ++++ drivers/usb/dwc3/dwc3-omap.c | 52 ++++++++++++++++++++++++++++++++++++++++++++ drivers/usb/dwc3/gadget.c | 2 +- 4 files changed, 57 insertions(+), 12 deletions(-)
Quoted 1 line
Can you explain why this is a misc driver, and how it will be instantiated?
Based on dr_mode property, the device node needs to bind to either "host" driver or "peripheral" driver. Therefore, this wrapper is written for DWC3, which on bind will read dr_mode property and appropriately associate USB DT node with DWC3 peripheral driver or host driver.
This is similar to what exists today for MUSB[1] and is instantiated by arch_misc_init() function for am33xx and am43xx
I got these patch from U-Boot list which the author had submitted previously and got Reviewed-by and did not look deep into it. But looks like this patch really needs be read along with patch 7/10. I will re-split and reorder this patch in the next version.
[1]https://www.mail-archive.com/u-boot at lists.denx.de/msg231076.html
Signature · 2 lines
Regards Vignesh
PATCH 8/11 dwc3: Add support for USB device boot
In reply to Simon GlassQuoted 6 lines · Simon Glass
Quoted 5 lines · Vignesh R
Add support to for USB device boot for dwc3 gadget, so that RNDIS can be used in SPL to download next stage.
Provide a way to read MAC address forusb_etherdevice from board function.
Quoted 9 lines
Quoted 5 lines
Signed-off-by Vignesh R <[email protected]>--- drivers/usb/gadget/ether.c | 9 ++++++++- drivers/usb/gadget/gadget_chips.h | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-)It looks like there are a few changes in here and it should be split into 2-3 patches.
Ok, will do.
Signature · 2 lines
Regards Vignesh