[U-Boot] [PATCH v1 00/16] Add support for DM_USB and DM_USB_DEV to TI's am335x and am43xx_evm platforms

This series applies on top of the series "Add support for DM_USB and DM_USB_DEV to TI's K2G platforms" and "Add support for DM_USB and DM_USB_DEV for TI's DRA7 EVMs and AM57 EVMs platforms."
The am433x platforms can use the generic DWC3 driver instead of relying on the dwc3-xhci driver. The am335x platforms use the musb controller. With a bit of work it can be made to support DM as well. This series only enables DM_USB and DM_USB_GADGET on am335x_boneblack_vboot. The changes for the other am335x based platforms will come in a subsequent series that reworks the configs of several TI boards.
This is part of a work to move all TI's platforms to support DM_USB and DM_USB_DEV. As a side effect it makes it easy to support the full USB RDNIS bootflow (bootrom loads SPL over RNDIS, SPL loads u-boot over RNDIS, u-boot loads the images over RNDIS)
This series is made of 3 parts: - some generic changes: rename DM_USB_DEV in DM_USB_GADGET and create UCLASS_USB_GADGET for the USB peripheral drivers. - am437x support for DM_USB and DM_USB_GADGET - am335x support for DM_USB and DM_USB_GADGET
Tested on: - am4372 evm - beaglebone black - am335x evm (to verify that it doesn't break anything)
Jean-Jacques Hiblot (16): usb: rename CONFIG_DM_USB_DEV as CONFIG_DM_USB_GADGET dm: usb: create a new UCLASS ID for USB gadget devices spl: drivers: Link usb common library to SPL if USB gadget is enabled spl: net: dm: usb: bind the gadget before attempting to load the image phy: omap_usb2: Add support for am437x dwc3-generic: Add support for the am437x board: ti: am43xx: turn on USB clocks dts: Add a u-boot specific dtsi file for the am4372 dts: am4372: Enable USB1 in SPL configs: am43xx_evm: Enable DM_USB and DM_USB_GADGET configs: am43xx: Enable RNDIS support in SPL usb: musb-new: Allow the diver not to use the set_phy_power() callback usb: musb-new: Add support for DM_USB_GADGET arm: am33xx: Register USB controllers if DM_USB is used but not OF_CONTROL configs: am335x_evm: Do not disable DM_USB in SPL configs: am335x_boneblack_vboot: enable DM_USB and RNDIS boot in SPl
arch/arm/Kconfig | 4 +- arch/arm/dts/am4372-generic-u-boot.dtsi | 2 + arch/arm/dts/am4372-u-boot.dtsi | 40 +++++++ arch/arm/dts/am437x-gp-evm-u-boot.dtsi | 2 + arch/arm/dts/am437x-idk-evm-u-boot.dtsi | 2 + arch/arm/dts/am437x-sk-evm-u-boot.dtsi | 2 + arch/arm/include/asm/omap_musb.h | 8 ++ arch/arm/mach-omap2/am33xx/board.c | 58 ++++++++-- board/sunxi/board.c | 2 +- board/ti/am43xx/board.c | 22 ++++ common/Makefile | 3 + common/spl/spl_net.c | 4 +- configs/am335x_boneblack_vboot_defconfig | 8 ++ configs/am43xx_evm_defconfig | 17 +++ configs/am57xx_evm_defconfig | 2 +- configs/am57xx_hs_evm_defconfig | 2 +- configs/dra7xx_evm_defconfig | 2 +- configs/dra7xx_hs_evm_defconfig | 2 +- configs/k2g_evm_defconfig | 2 +- configs/k2g_hs_evm_defconfig | 2 +- drivers/Makefile | 1 + drivers/phy/omap-usb2-phy.c | 45 ++++++-- drivers/usb/Kconfig | 2 +- drivers/usb/dwc3/core.c | 2 +- drivers/usb/dwc3/dwc3-generic.c | 7 +- drivers/usb/gadget/ether.c | 2 +- drivers/usb/gadget/udc/Makefile | 4 + drivers/usb/gadget/udc/udc-core.c | 41 ------- drivers/usb/musb-new/am35x.c | 8 +- drivers/usb/musb-new/musb_dsps.c | 8 +- drivers/usb/musb-new/musb_gadget.c | 11 ++ drivers/usb/musb-new/musb_uboot.c | 4 +- drivers/usb/musb-new/omap2430.c | 2 +- drivers/usb/musb-new/sunxi.c | 2 +- drivers/usb/musb-new/ti-musb.c | 179 +++++++++++++++++++++++-------- include/configs/am335x_evm.h | 1 - include/dm/uclass-id.h | 1 + include/linux/usb/gadget.h | 2 +- 38 files changed, 375 insertions(+), 133 deletions(-) create mode 100644 arch/arm/dts/am4372-u-boot.dtsi

DM_USB_DEV is ambiguous as it could be interpreted as USB host device. Renaming it as DM_USB_GADGET to make it clear that is related to gadget devices.
Signed-off-by: Jean-Jacques Hiblot jjhiblot@ti.com ---
arch/arm/Kconfig | 4 ++-- configs/am57xx_evm_defconfig | 2 +- configs/am57xx_hs_evm_defconfig | 2 +- configs/dra7xx_evm_defconfig | 2 +- configs/dra7xx_hs_evm_defconfig | 2 +- configs/k2g_evm_defconfig | 2 +- configs/k2g_hs_evm_defconfig | 2 +- drivers/usb/Kconfig | 2 +- drivers/usb/dwc3/core.c | 2 +- drivers/usb/dwc3/dwc3-generic.c | 4 ++-- drivers/usb/gadget/udc/udc-core.c | 2 +- include/linux/usb/gadget.h | 2 +- 12 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 9e232d7..05b6ebf 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -917,7 +917,7 @@ config ARCH_ZYNQMP_R5 select DM_SERIAL select OF_CONTROL imply CMD_DM - imply DM_USB_DEV + imply DM_USB_GADGET
config ARCH_ZYNQMP bool "Xilinx ZynqMP based platform" @@ -934,7 +934,7 @@ config ARCH_ZYNQMP imply CMD_DM imply FAT_WRITE imply MP - imply DM_USB_DEV + imply DM_USB_GADGET
config TEGRA bool "NVIDIA Tegra" diff --git a/configs/am57xx_evm_defconfig b/configs/am57xx_evm_defconfig index 038c3ba..a6feae7 100644 --- a/configs/am57xx_evm_defconfig +++ b/configs/am57xx_evm_defconfig @@ -75,7 +75,7 @@ CONFIG_DM_SPI=y CONFIG_TI_QSPI=y CONFIG_USB=y CONFIG_DM_USB=y -CONFIG_DM_USB_DEV=y +CONFIG_DM_USB_GADGET=y CONFIG_USB_XHCI_HCD=y CONFIG_USB_XHCI_DWC3=y CONFIG_USB_DWC3=y diff --git a/configs/am57xx_hs_evm_defconfig b/configs/am57xx_hs_evm_defconfig index a3eedca..e9897d8 100644 --- a/configs/am57xx_hs_evm_defconfig +++ b/configs/am57xx_hs_evm_defconfig @@ -78,7 +78,7 @@ CONFIG_DM_SPI=y CONFIG_TI_QSPI=y CONFIG_USB=y CONFIG_DM_USB=y -CONFIG_DM_USB_DEV=y +CONFIG_DM_USB_GADGET=y CONFIG_USB_XHCI_HCD=y CONFIG_USB_XHCI_DWC3=y CONFIG_USB_DWC3=y diff --git a/configs/dra7xx_evm_defconfig b/configs/dra7xx_evm_defconfig index 943ae71..19a5f98 100644 --- a/configs/dra7xx_evm_defconfig +++ b/configs/dra7xx_evm_defconfig @@ -89,7 +89,7 @@ CONFIG_TIMER=y CONFIG_OMAP_TIMER=y CONFIG_USB=y CONFIG_DM_USB=y -CONFIG_DM_USB_DEV=y +CONFIG_DM_USB_GADGET=y CONFIG_USB_XHCI_HCD=y CONFIG_USB_XHCI_DWC3=y CONFIG_USB_DWC3=y diff --git a/configs/dra7xx_hs_evm_defconfig b/configs/dra7xx_hs_evm_defconfig index 9137ee7..150d70b 100644 --- a/configs/dra7xx_hs_evm_defconfig +++ b/configs/dra7xx_hs_evm_defconfig @@ -88,7 +88,7 @@ CONFIG_TIMER=y CONFIG_OMAP_TIMER=y CONFIG_USB=y CONFIG_DM_USB=y -CONFIG_DM_USB_DEV=y +CONFIG_DM_USB_GADGET=y CONFIG_USB_XHCI_HCD=y CONFIG_USB_XHCI_DWC3=y CONFIG_USB_DWC3=y diff --git a/configs/k2g_evm_defconfig b/configs/k2g_evm_defconfig index b71edf0..8a07039 100644 --- a/configs/k2g_evm_defconfig +++ b/configs/k2g_evm_defconfig @@ -62,7 +62,7 @@ CONFIG_DM_SPI=y CONFIG_DAVINCI_SPI=y CONFIG_USB=y CONFIG_DM_USB=y -CONFIG_DM_USB_DEV=y +CONFIG_DM_USB_GADGET=y CONFIG_USB_XHCI_HCD=y CONFIG_USB_XHCI_DWC3=y CONFIG_USB_DWC3=y diff --git a/configs/k2g_hs_evm_defconfig b/configs/k2g_hs_evm_defconfig index 16872f4..5f91f11 100644 --- a/configs/k2g_hs_evm_defconfig +++ b/configs/k2g_hs_evm_defconfig @@ -55,7 +55,7 @@ CONFIG_DM_SPI=y CONFIG_DAVINCI_SPI=y CONFIG_USB=y CONFIG_DM_USB=y -CONFIG_DM_USB_DEV=y +CONFIG_DM_USB_GADGET=y CONFIG_USB_XHCI_HCD=y CONFIG_USB_XHCI_DWC3=y CONFIG_USB_DWC3=y diff --git a/drivers/usb/Kconfig b/drivers/usb/Kconfig index 3587ba4..91a431d 100644 --- a/drivers/usb/Kconfig +++ b/drivers/usb/Kconfig @@ -47,7 +47,7 @@ config DM_USB declared with the U_BOOT_USB_DEVICE() macro and will be automatically probed when found on the bus.
-config DM_USB_DEV +config DM_USB_GADGET bool "Enable driver model for USB (Peripheral mode)" depends on DM_USB help diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 325fe8c..e226f06 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -875,7 +875,7 @@ int dwc3_shutdown_phy(struct udevice *dev, struct phy *usb_phys, int num_phys) } #endif
-#ifdef CONFIG_DM_USB_DEV +#ifdef CONFIG_DM_USB_GADGET int dwc3_init(struct dwc3 *dwc) { int ret; diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c index d54a25c..f908d7f 100644 --- a/drivers/usb/dwc3/dwc3-generic.c +++ b/drivers/usb/dwc3/dwc3-generic.c @@ -22,7 +22,7 @@ #include <reset.h> #include <clk.h>
-#ifdef CONFIG_DM_USB_DEV +#ifdef CONFIG_DM_USB_GADGET
struct dwc3_generic_peripheral { struct dwc3 dwc3; @@ -224,7 +224,7 @@ static int dwc3_glue_bind(struct udevice *parent) switch (dr_mode) { case USB_DR_MODE_PERIPHERAL: case USB_DR_MODE_OTG: -#ifdef CONFIG_DM_USB_DEV +#ifdef CONFIG_DM_USB_GADGET debug("%s: dr_mode: OTG or Peripheral\n", __func__); driver = "dwc3-generic-peripheral"; #endif diff --git a/drivers/usb/gadget/udc/udc-core.c b/drivers/usb/gadget/udc/udc-core.c index 42c9ea9..bae71a2 100644 --- a/drivers/usb/gadget/udc/udc-core.c +++ b/drivers/usb/gadget/udc/udc-core.c @@ -353,7 +353,7 @@ MODULE_DESCRIPTION("UDC Framework"); MODULE_AUTHOR("Felipe Balbi balbi@ti.com"); MODULE_LICENSE("GPL v2");
-#ifdef CONFIG_DM_USB_DEV +#ifdef CONFIG_DM_USB_GADGET #define MAX_UDC_DEVICES 4 static struct udevice *dev_array[MAX_UDC_DEVICES]; int usb_gadget_initialize(int index) diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h index a094e31..78407c9 100644 --- a/include/linux/usb/gadget.h +++ b/include/linux/usb/gadget.h @@ -927,7 +927,7 @@ extern void usb_ep_autoconfig_reset(struct usb_gadget *);
extern int usb_gadget_handle_interrupts(int index);
-#ifdef CONFIG_DM_USB_DEV +#ifdef CONFIG_DM_USB_GADGET int usb_gadget_initialize(int index); int usb_gadget_release(int index); int dm_usb_gadget_handle_interrupts(struct udevice *dev);

On Wed, Nov 21, 2018 at 11:51:03AM +0100, Jean-Jacques Hiblot wrote:
DM_USB_DEV is ambiguous as it could be interpreted as USB host device. Renaming it as DM_USB_GADGET to make it clear that is related to gadget devices.
Signed-off-by: Jean-Jacques Hiblot jjhiblot@ti.com
Reviewed-by: Tom Rini trini@konsulko.com

UCLASS_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.
Signed-off-by: Jean-Jacques Hiblot jjhiblot@ti.com ---
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/musb-new/omap2430.c | 2 +- drivers/usb/musb-new/sunxi.c | 2 +- include/dm/uclass-id.h | 1 + 8 files changed, 10 insertions(+), 46 deletions(-)
diff --git a/board/sunxi/board.c b/board/sunxi/board.c index 64ccbc7..9b36cc7 100644 --- a/board/sunxi/board.c +++ b/board/sunxi/board.c @@ -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; diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c index f908d7f..bfd5bf3 100644 --- a/drivers/usb/dwc3/dwc3-generic.c +++ b/drivers/usb/dwc3/dwc3-generic.c @@ -101,7 +101,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, diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c index 5a9ffd7..3b3d9af 100644 --- a/drivers/usb/gadget/ether.c +++ b/drivers/usb/gadget/ether.c @@ -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; diff --git a/drivers/usb/gadget/udc/Makefile b/drivers/usb/gadget/udc/Makefile index 449339f..d1a5963 100644 --- a/drivers/usb/gadget/udc/Makefile +++ b/drivers/usb/gadget/udc/Makefile @@ -2,4 +2,8 @@ # # USB peripheral controller drivers
+ifndef CONFIG_DM_USB_GADGET obj-$(CONFIG_USB_DWC3_GADGET) += udc-core.o +endif + +obj-$(CONFIG_DM_USB_GADGET) += udc-uclass.o udc-core.o diff --git a/drivers/usb/gadget/udc/udc-core.c b/drivers/usb/gadget/udc/udc-core.c index bae71a2..62b4778 100644 --- a/drivers/usb/gadget/udc/udc-core.c +++ b/drivers/usb/gadget/udc/udc-core.c @@ -352,44 +352,3 @@ EXPORT_SYMBOL_GPL(usb_gadget_unregister_driver); MODULE_DESCRIPTION("UDC Framework"); MODULE_AUTHOR("Felipe Balbi balbi@ti.com"); MODULE_LICENSE("GPL v2"); - -#ifdef CONFIG_DM_USB_GADGET -#define MAX_UDC_DEVICES 4 -static struct udevice *dev_array[MAX_UDC_DEVICES]; -int usb_gadget_initialize(int index) -{ - int ret; - struct udevice *dev = NULL; - - if (index < 0 || index >= ARRAY_SIZE(dev_array)) - return -EINVAL; - if (dev_array[index]) - return 0; - ret = uclass_get_device(UCLASS_USB_DEV_GENERIC, index, &dev); - if (!dev || ret) { - pr_err("No USB device found\n"); - return -ENODEV; - } - dev_array[index] = dev; - return 0; -} - -int usb_gadget_release(int index) -{ - int ret; - - if (index < 0 || index >= ARRAY_SIZE(dev_array)) - return -EINVAL; - ret = device_remove(dev_array[index], DM_REMOVE_NORMAL); - if (!ret) - dev_array[index] = NULL; - return ret; -} - -int usb_gadget_handle_interrupts(int index) -{ - if (index < 0 || index >= ARRAY_SIZE(dev_array)) - return -EINVAL; - return dm_usb_gadget_handle_interrupts(dev_array[index]); -} -#endif diff --git a/drivers/usb/musb-new/omap2430.c b/drivers/usb/musb-new/omap2430.c index 342d76b..971f953 100644 --- a/drivers/usb/musb-new/omap2430.c +++ b/drivers/usb/musb-new/omap2430.c @@ -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, diff --git a/drivers/usb/musb-new/sunxi.c b/drivers/usb/musb-new/sunxi.c index 6cf9826..d7170a3 100644 --- a/drivers/usb/musb-new/sunxi.c +++ b/drivers/usb/musb-new/sunxi.c @@ -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, diff --git a/include/dm/uclass-id.h b/include/dm/uclass-id.h index c91dca1..1601100 100644 --- a/include/dm/uclass-id.h +++ b/include/dm/uclass-id.h @@ -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 */

On Wed, 21 Nov 2018 at 03:51, Jean-Jacques Hiblot jjhiblot@ti.com wrote:
UCLASS_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.
Signed-off-by: Jean-Jacques Hiblot jjhiblot@ti.com
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/musb-new/omap2430.c | 2 +- drivers/usb/musb-new/sunxi.c | 2 +- include/dm/uclass-id.h | 1 + 8 files changed, 10 insertions(+), 46 deletions(-)
Reviewed-by: Simon Glass sjg@chromium.org

Some drivers might need to access common USB functions such as usb_get_maximum_speed() or usb_get_dr_mode().
Signed-off-by: Jean-Jacques Hiblot jjhiblot@ti.com ---
drivers/Makefile | 1 + 1 file changed, 1 insertion(+)
diff --git a/drivers/Makefile b/drivers/Makefile index 4453c62..b5c64d9 100644 --- a/drivers/Makefile +++ b/drivers/Makefile @@ -45,6 +45,7 @@ obj-$(CONFIG_SPL_PCH_SUPPORT) += pch/ obj-$(CONFIG_SPL_RTC_SUPPORT) += rtc/ obj-$(CONFIG_SPL_MUSB_NEW_SUPPORT) += usb/musb-new/ obj-$(CONFIG_SPL_USB_GADGET_SUPPORT) += usb/gadget/ +obj-$(CONFIG_SPL_USB_GADGET_SUPPORT) += usb/common/ obj-$(CONFIG_SPL_USB_GADGET_SUPPORT) += usb/gadget/udc/ obj-$(CONFIG_SPL_DFU_SUPPORT) += dfu/ obj-$(CONFIG_SPL_WATCHDOG_SUPPORT) += watchdog/

On Wed, Nov 21, 2018 at 11:51:05AM +0100, Jean-Jacques Hiblot wrote:
Some drivers might need to access common USB functions such as usb_get_maximum_speed() or usb_get_dr_mode().
Signed-off-by: Jean-Jacques Hiblot jjhiblot@ti.com
Reviewed-by: Tom Rini trini@konsulko.com

If DM_USB_GADGET is used, the usb ethernet gadget driver must be bound to a controller before the image can be downloaded over the network. In u-boot this can be done with the bind command. In SPL it must be done programmatically.
Signed-off-by: Jean-Jacques Hiblot jjhiblot@ti.com ---
common/spl/spl_net.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/common/spl/spl_net.c b/common/spl/spl_net.c index b6967ff..15d7915 100644 --- a/common/spl/spl_net.c +++ b/common/spl/spl_net.c @@ -85,7 +85,9 @@ int spl_net_load_image_usb(struct spl_image_info *spl_image, struct spl_boot_device *bootdev) { bootdev->boot_device_name = "usb_ether"; - +#ifdef CONFIG_DM_USB_GADGET + usb_ether_init(); +#endif return spl_net_load_image(spl_image, bootdev); } SPL_LOAD_IMAGE_METHOD("USB eth", 0, BOOT_DEVICE_USBETH, spl_net_load_image_usb);

On Wed, Nov 21, 2018 at 11:51:06AM +0100, Jean-Jacques Hiblot wrote:
If DM_USB_GADGET is used, the usb ethernet gadget driver must be bound to a controller before the image can be downloaded over the network. In u-boot this can be done with the bind command. In SPL it must be done programmatically.
Signed-off-by: Jean-Jacques Hiblot jjhiblot@ti.com
Reviewed-by: Tom Rini trini@konsulko.com

Signed-off-by: Jean-Jacques Hiblot jjhiblot@ti.com ---
drivers/phy/omap-usb2-phy.c | 45 ++++++++++++++++++++++++++++++++++----------- 1 file changed, 34 insertions(+), 11 deletions(-)
diff --git a/drivers/phy/omap-usb2-phy.c b/drivers/phy/omap-usb2-phy.c index 671539b..a8d3ccd 100644 --- a/drivers/phy/omap-usb2-phy.c +++ b/drivers/phy/omap-usb2-phy.c @@ -19,6 +19,11 @@ #define OMAP_DEV_PHY_PD BIT(0) #define OMAP_USB2_PHY_PD BIT(28)
+#define AM437X_USB2_PHY_PD BIT(0) +#define AM437X_USB2_OTG_PD BIT(1) +#define AM437X_USB2_OTGVDET_EN BIT(19) +#define AM437X_USB2_OTGSESSEND_EN BIT(20) + #define USB2PHY_DISCON_BYP_LATCH BIT(31) #define USB2PHY_ANA_CONFIG1 (0x4c)
@@ -60,6 +65,15 @@ static const struct usb_phy_data dra7x_usb2_phy2_data = { .power_off = OMAP_USB2_PHY_PD, };
+static const struct usb_phy_data am437x_usb2_data = { + .label = "am437x_usb2", + .flags = 0, + .mask = AM437X_USB2_PHY_PD | AM437X_USB2_OTG_PD | + AM437X_USB2_OTGVDET_EN | AM437X_USB2_OTGSESSEND_EN, + .power_on = AM437X_USB2_OTGVDET_EN | AM437X_USB2_OTGSESSEND_EN, + .power_off = AM437X_USB2_PHY_PD | AM437X_USB2_OTG_PD, +}; + static const struct udevice_id omap_usb2_id_table[] = { { .compatible = "ti,omap5-usb2", @@ -73,6 +87,10 @@ static const struct udevice_id omap_usb2_id_table[] = { .compatible = "ti,dra7x-usb2-phy2", .data = (ulong)&dra7x_usb2_phy2_data, }, + { + .compatible = "ti,am437x-usb2", + .data = (ulong)&am437x_usb2_data, + }, {}, };
@@ -170,20 +188,25 @@ int omap_usb2_phy_probe(struct udevice *dev) }
regmap = syscon_regmap_lookup_by_phandle(dev, "syscon-phy-power"); - if (IS_ERR(regmap)) { - printf("can't get regmap (err %ld)\n", PTR_ERR(regmap)); - return PTR_ERR(regmap); + if (!IS_ERR(regmap)) { + priv->pwr_regmap = regmap; + rc = dev_read_u32_array(dev, "syscon-phy-power", tmp, 2); + if (rc) { + printf("couldn't get power reg. offset (err %d)\n", rc); + return rc; + } + priv->pwr_reg_offset = tmp[1]; + return 0; } - priv->pwr_regmap = regmap; - - rc = dev_read_u32_array(dev, "syscon-phy-power", tmp, 2); - if (rc) { - printf("couldn't get power reg. offset (err %d)\n", rc); - return rc; + regmap = syscon_regmap_lookup_by_phandle(dev, "ctrl-module"); + if (!IS_ERR(regmap)) { + priv->pwr_regmap = regmap; + priv->pwr_reg_offset = 0; + return 0; } - priv->pwr_reg_offset = tmp[1];
- return 0; + printf("can't get regmap (err %ld)\n", PTR_ERR(regmap)); + return PTR_ERR(regmap); }
U_BOOT_DRIVER(omap_usb2_phy) = {

On Wed, Nov 21, 2018 at 11:51:07AM +0100, Jean-Jacques Hiblot wrote:
Signed-off-by: Jean-Jacques Hiblot jjhiblot@ti.com
Reviewed-by: Tom Rini trini@konsulko.com

Signed-off-by: Jean-Jacques Hiblot jjhiblot@ti.com ---
drivers/usb/dwc3/dwc3-generic.c | 1 + 1 file changed, 1 insertion(+)
diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c index bfd5bf3..095f336 100644 --- a/drivers/usb/dwc3/dwc3-generic.c +++ b/drivers/usb/dwc3/dwc3-generic.c @@ -345,6 +345,7 @@ static const struct udevice_id dwc3_glue_ids[] = { { .compatible = "xlnx,zynqmp-dwc3" }, { .compatible = "ti,keystone-dwc3"}, { .compatible = "ti,dwc3", .data = (ulong)&ti_ops }, + { .compatible = "ti,am437x-dwc3", .data = (ulong)&ti_ops }, { } };

On Wed, Nov 21, 2018 at 11:51:08AM +0100, Jean-Jacques Hiblot wrote:
Signed-off-by: Jean-Jacques Hiblot jjhiblot@ti.com
Reviewed-by: Tom Rini trini@konsulko.com

Enable USB clocks in late init stage to support ports under DM_USB.
Signed-off-by: Jean-Jacques Hiblot jjhiblot@ti.com ---
board/ti/am43xx/board.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
diff --git a/board/ti/am43xx/board.c b/board/ti/am43xx/board.c index 2a59b06..be12b30 100644 --- a/board/ti/am43xx/board.c +++ b/board/ti/am43xx/board.c @@ -681,6 +681,19 @@ int board_init(void) }
#ifdef CONFIG_BOARD_LATE_INIT +#if CONFIG_IS_ENABLED(DM_USB) && CONFIG_IS_ENABLED(OF_CONTROL) +static int device_okay(const char *path) +{ + int node; + + node = fdt_path_offset(gd->fdt_blob, path); + if (node < 0) + return 0; + + return fdtdec_get_is_enabled(gd->fdt_blob, node); +} +#endif + int board_late_init(void) { #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG @@ -693,10 +706,18 @@ int board_late_init(void) if (get_device_type() == HS_DEVICE) env_set("boot_fit", "1"); #endif + +#if CONFIG_IS_ENABLED(DM_USB) && CONFIG_IS_ENABLED(OF_CONTROL) + if (device_okay("/ocp/omap_dwc3@48380000")) + enable_usb_clocks(0); + if (device_okay("/ocp/omap_dwc3@483c0000")) + enable_usb_clocks(1); +#endif return 0; } #endif
+#ifndef CONFIG_DM_USB_GADGET #ifdef CONFIG_USB_DWC3 static struct dwc3_device usb_otg_ss1 = { .maximum_speed = USB_SPEED_HIGH, @@ -799,6 +820,7 @@ int board_usb_cleanup(int index, enum usb_init_type init) return 0; } #endif /* defined(CONFIG_USB_DWC3) || defined(CONFIG_USB_XHCI_OMAP) */ +#endif
#ifdef CONFIG_DRIVER_TI_CPSW

On Wed, Nov 21, 2018 at 11:51:09AM +0100, Jean-Jacques Hiblot wrote:
Enable USB clocks in late init stage to support ports under DM_USB.
Signed-off-by: Jean-Jacques Hiblot jjhiblot@ti.com
Reviewed-by: Tom Rini trini@konsulko.com

This file is used to override the values found in am4372.dtsi Use it to fix the "compatible" options for the controllers used to support the USB (parent bus and syscons).
Signed-off-by: Jean-Jacques Hiblot jjhiblot@ti.com ---
arch/arm/dts/am4372-generic-u-boot.dtsi | 2 ++ arch/arm/dts/am4372-u-boot.dtsi | 20 ++++++++++++++++++++ arch/arm/dts/am437x-gp-evm-u-boot.dtsi | 2 ++ arch/arm/dts/am437x-idk-evm-u-boot.dtsi | 2 ++ arch/arm/dts/am437x-sk-evm-u-boot.dtsi | 2 ++ 5 files changed, 28 insertions(+) create mode 100644 arch/arm/dts/am4372-u-boot.dtsi
diff --git a/arch/arm/dts/am4372-generic-u-boot.dtsi b/arch/arm/dts/am4372-generic-u-boot.dtsi index d485679..6ba5c16 100644 --- a/arch/arm/dts/am4372-generic-u-boot.dtsi +++ b/arch/arm/dts/am4372-generic-u-boot.dtsi @@ -3,6 +3,8 @@ * Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com/ */
+#include "am4372-u-boot.dtsi" + /{ ocp { u-boot,dm-pre-reloc; diff --git a/arch/arm/dts/am4372-u-boot.dtsi b/arch/arm/dts/am4372-u-boot.dtsi new file mode 100644 index 0000000..cda4214 --- /dev/null +++ b/arch/arm/dts/am4372-u-boot.dtsi @@ -0,0 +1,20 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com/ + */ + +&am43xx_control_usb2phy1 { + compatible = "ti,control-phy-usb2-am437", "syscon"; +}; + +&am43xx_control_usb2phy2 { + compatible = "ti,control-phy-usb2-am437", "syscon"; +}; + +&ocp2scp0 { + compatible = "ti,am437x-ocp2scp", "ti,omap-ocp2scp", "simple-bus"; +}; + +&ocp2scp1 { + compatible = "ti,am437x-ocp2scp", "ti,omap-ocp2scp", "simple-bus"; +}; diff --git a/arch/arm/dts/am437x-gp-evm-u-boot.dtsi b/arch/arm/dts/am437x-gp-evm-u-boot.dtsi index 530f549..616debe 100644 --- a/arch/arm/dts/am437x-gp-evm-u-boot.dtsi +++ b/arch/arm/dts/am437x-gp-evm-u-boot.dtsi @@ -7,6 +7,8 @@ * Based on "dra7.dtsi" */
+#include "am4372-u-boot.dtsi" + /{ ocp { u-boot,dm-spl; diff --git a/arch/arm/dts/am437x-idk-evm-u-boot.dtsi b/arch/arm/dts/am437x-idk-evm-u-boot.dtsi index 0a3d79a..3aa9195 100644 --- a/arch/arm/dts/am437x-idk-evm-u-boot.dtsi +++ b/arch/arm/dts/am437x-idk-evm-u-boot.dtsi @@ -3,6 +3,8 @@ * Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com/ */
+#include "am4372-u-boot.dtsi" + /{ ocp { u-boot,dm-spl; diff --git a/arch/arm/dts/am437x-sk-evm-u-boot.dtsi b/arch/arm/dts/am437x-sk-evm-u-boot.dtsi index 0a3d79a..3aa9195 100644 --- a/arch/arm/dts/am437x-sk-evm-u-boot.dtsi +++ b/arch/arm/dts/am437x-sk-evm-u-boot.dtsi @@ -3,6 +3,8 @@ * Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com/ */
+#include "am4372-u-boot.dtsi" + /{ ocp { u-boot,dm-spl;

On Wed, Nov 21, 2018 at 11:51:10AM +0100, Jean-Jacques Hiblot wrote:
This file is used to override the values found in am4372.dtsi Use it to fix the "compatible" options for the controllers used to support the USB (parent bus and syscons).
Signed-off-by: Jean-Jacques Hiblot jjhiblot@ti.com
Reviewed-by: Tom Rini trini@konsulko.com

USB1 can be used by the romboot on all am4372 platforms to download a firmware (SPL in our case). It makes sense to enable USB1 in the SPL to download u-boot.
Signed-off-by: Jean-Jacques Hiblot jjhiblot@ti.com ---
arch/arm/dts/am4372-u-boot.dtsi | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
diff --git a/arch/arm/dts/am4372-u-boot.dtsi b/arch/arm/dts/am4372-u-boot.dtsi index cda4214..99922ca 100644 --- a/arch/arm/dts/am4372-u-boot.dtsi +++ b/arch/arm/dts/am4372-u-boot.dtsi @@ -18,3 +18,23 @@ &ocp2scp1 { compatible = "ti,am437x-ocp2scp", "ti,omap-ocp2scp", "simple-bus"; }; + +&dwc3_1 { + u-boot,dm-spl; +}; + +&usb1 { + u-boot,dm-spl; +}; + +&usb2_phy1 { + u-boot,dm-spl; +}; + +&am43xx_control_usb2phy1 { + u-boot,dm-spl; +}; + +&ocp2scp0 { + u-boot,dm-spl; +};

On Wed, Nov 21, 2018 at 11:51:11AM +0100, Jean-Jacques Hiblot wrote:
USB1 can be used by the romboot on all am4372 platforms to download a firmware (SPL in our case). It makes sense to enable USB1 in the SPL to download u-boot.
Signed-off-by: Jean-Jacques Hiblot jjhiblot@ti.com
Reviewed-by: Tom Rini trini@konsulko.com

Enable DM_USB and DM_USB_GADGET for AM43xx EVM boards.
Signed-off-by: Jean-Jacques Hiblot jjhiblot@ti.com ---
configs/am43xx_evm_defconfig | 8 ++++++++ 1 file changed, 8 insertions(+)
diff --git a/configs/am43xx_evm_defconfig b/configs/am43xx_evm_defconfig index 7601263..aeecdc2 100644 --- a/configs/am43xx_evm_defconfig +++ b/configs/am43xx_evm_defconfig @@ -27,11 +27,14 @@ CONFIG_DEFAULT_DEVICE_TREE="am437x-gp-evm" CONFIG_OF_LIST="am437x-gp-evm am437x-sk-evm am43x-epos-evm am437x-idk-evm" CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y CONFIG_DM=y +CONFIG_REGMAP=y +CONFIG_SYSCON=y # CONFIG_BLK is not set CONFIG_DFU_MMC=y CONFIG_DFU_RAM=y CONFIG_DFU_SF=y CONFIG_DM_GPIO=y +CONFIG_MISC=y CONFIG_DM_MMC=y CONFIG_MMC_OMAP_HS=y CONFIG_NAND=y @@ -40,17 +43,22 @@ CONFIG_SPI_FLASH_MACRONIX=y CONFIG_DRIVER_TI_CPSW=y CONFIG_PHY_GIGE=y CONFIG_MII=y +CONFIG_PHY=y +CONFIG_OMAP_USB2_PHY=y CONFIG_DM_SERIAL=y CONFIG_SPI=y CONFIG_TI_QSPI=y CONFIG_TIMER=y CONFIG_OMAP_TIMER=y CONFIG_USB=y +CONFIG_DM_USB=y +CONFIG_DM_USB_GADGET=y CONFIG_USB_XHCI_HCD=y CONFIG_USB_XHCI_DWC3=y CONFIG_USB_DWC3=y CONFIG_USB_DWC3_GADGET=y CONFIG_USB_DWC3_OMAP=y +CONFIG_USB_DWC3_GENERIC=y CONFIG_USB_DWC3_PHY_OMAP=y CONFIG_OMAP_USB_PHY=y CONFIG_USB_STORAGE=y

On Wed, Nov 21, 2018 at 11:51:12AM +0100, Jean-Jacques Hiblot wrote:
Enable DM_USB and DM_USB_GADGET for AM43xx EVM boards.
Signed-off-by: Jean-Jacques Hiblot jjhiblot@ti.com
Reviewed-by: Tom Rini trini@konsulko.com

The AM43xx SOCs have the ability to download the SPl through USB (RNDIS). Adding support for RNDIS in SPL allows to also download u-boot through USB.
Signed-off-by: Jean-Jacques Hiblot jjhiblot@ti.com ---
configs/am43xx_evm_defconfig | 9 +++++++++ 1 file changed, 9 insertions(+)
diff --git a/configs/am43xx_evm_defconfig b/configs/am43xx_evm_defconfig index aeecdc2..537a794 100644 --- a/configs/am43xx_evm_defconfig +++ b/configs/am43xx_evm_defconfig @@ -3,6 +3,7 @@ CONFIG_ARCH_OMAP2PLUS=y CONFIG_TI_COMMON_CMD_OPTIONS=y CONFIG_SYS_MALLOC_F_LEN=0x2000 CONFIG_AM43XX=y +CONFIG_SPL_DRIVERS_MISC_SUPPORT=y CONFIG_SPL=y CONFIG_DISTRO_DEFAULTS=y CONFIG_SPL_LOAD_FIT=y @@ -12,7 +13,11 @@ CONFIG_SYS_CONSOLE_INFO_QUIET=y # CONFIG_MISC_INIT_R is not set CONFIG_VERSION_VARIABLE=y CONFIG_SPL_MTD_SUPPORT=y +CONFIG_SPL_NET_SUPPORT=y +CONFIG_SPL_NET_VCI_STRING="AM43xx U-Boot SPL" CONFIG_SPL_OS_BOOT=y +CONFIG_SPL_USB_GADGET_SUPPORT=y +CONFIG_SPL_USB_ETHER=y CONFIG_CMD_SPL=y CONFIG_CMD_SPL_NAND_OFS=0x00100000 CONFIG_CMD_SPL_WRITE_SIZE=0x40000 @@ -28,7 +33,9 @@ CONFIG_OF_LIST="am437x-gp-evm am437x-sk-evm am43x-epos-evm am437x-idk-evm" CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y CONFIG_DM=y CONFIG_REGMAP=y +CONFIG_SPL_REGMAP=y CONFIG_SYSCON=y +CONFIG_SPL_SYSCON=y # CONFIG_BLK is not set CONFIG_DFU_MMC=y CONFIG_DFU_RAM=y @@ -44,6 +51,7 @@ CONFIG_DRIVER_TI_CPSW=y CONFIG_PHY_GIGE=y CONFIG_MII=y CONFIG_PHY=y +CONFIG_SPL_PHY=y CONFIG_OMAP_USB2_PHY=y CONFIG_DM_SERIAL=y CONFIG_SPI=y @@ -67,3 +75,4 @@ CONFIG_USB_GADGET_MANUFACTURER="Texas Instruments" CONFIG_USB_GADGET_VENDOR_NUM=0x0403 CONFIG_USB_GADGET_PRODUCT_NUM=0xbd00 CONFIG_USB_GADGET_DOWNLOAD=y +CONFIG_USB_ETHER=y

On Wed, Nov 21, 2018 at 11:51:13AM +0100, Jean-Jacques Hiblot wrote:
The AM43xx SOCs have the ability to download the SPl through USB (RNDIS). Adding support for RNDIS in SPL allows to also download u-boot through USB.
Signed-off-by: Jean-Jacques Hiblot jjhiblot@ti.com
Reviewed-by: Tom Rini trini@konsulko.com

The set_phy_power() callback is part of struct omap_musb_board_data. This structure is part of the platform data passed to the musb-new driver. This does not really fit with the Driver Model, so allow not to use struct omap_musb_board_data to turn the phy on or off.
Signed-off-by: Jean-Jacques Hiblot jjhiblot@ti.com ---
drivers/usb/musb-new/am35x.c | 8 ++++---- drivers/usb/musb-new/musb_dsps.c | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/drivers/usb/musb-new/am35x.c b/drivers/usb/musb-new/am35x.c index 251b4e9..bda099c 100644 --- a/drivers/usb/musb-new/am35x.c +++ b/drivers/usb/musb-new/am35x.c @@ -406,7 +406,7 @@ static int am35x_musb_init(struct musb *musb) musb_writel(reg_base, USB_CTRL_REG, AM35X_SOFT_RESET_MASK);
/* Start the on-chip PHY and its PLL. */ - if (data->set_phy_power) + if (data && data->set_phy_power) data->set_phy_power(data->dev, 1);
msleep(5); @@ -437,7 +437,7 @@ static int am35x_musb_exit(struct musb *musb) #endif
/* Shutdown the on-chip PHY and its PLL. */ - if (data->set_phy_power) + if (data && data->set_phy_power) data->set_phy_power(data->dev, 0);
#ifndef __UBOOT__ @@ -628,7 +628,7 @@ static int am35x_suspend(struct device *dev) struct omap_musb_board_data *data = plat->board_data;
/* Shutdown the on-chip PHY and its PLL. */ - if (data->set_phy_power) + if (data && data->set_phy_power) data->set_phy_power(data->dev, 0);
clk_disable(glue->phy_clk); @@ -645,7 +645,7 @@ static int am35x_resume(struct device *dev) int ret;
/* Start the on-chip PHY and its PLL. */ - if (data->set_phy_power) + if (data && data->set_phy_power) data->set_phy_power(data->dev, 1);
ret = clk_enable(glue->phy_clk); diff --git a/drivers/usb/musb-new/musb_dsps.c b/drivers/usb/musb-new/musb_dsps.c index 9b814f4..0c794b3 100644 --- a/drivers/usb/musb-new/musb_dsps.c +++ b/drivers/usb/musb-new/musb_dsps.c @@ -450,7 +450,7 @@ static int dsps_musb_init(struct musb *musb) dsps_writel(reg_base, wrp->control, (1 << wrp->reset));
/* Start the on-chip PHY and its PLL. */ - if (data->set_phy_power) + if (data && data->set_phy_power) data->set_phy_power(data->dev, 1);
musb->isr = dsps_interrupt; @@ -491,7 +491,7 @@ static int dsps_musb_exit(struct musb *musb) #endif
/* Shutdown the on-chip PHY and its PLL. */ - if (data->set_phy_power) + if (data && data->set_phy_power) data->set_phy_power(data->dev, 0);
#ifndef __UBOOT__ @@ -691,7 +691,7 @@ static int dsps_suspend(struct device *dev) struct omap_musb_board_data *data = plat->board_data;
/* Shutdown the on-chip PHY and its PLL. */ - if (data->set_phy_power) + if (data && data->set_phy_power) data->set_phy_power(data->dev, 0);
return 0; @@ -703,7 +703,7 @@ static int dsps_resume(struct device *dev) struct omap_musb_board_data *data = plat->board_data;
/* Start the on-chip PHY and its PLL. */ - if (data->set_phy_power) + if (data && data->set_phy_power) data->set_phy_power(data->dev, 1);
return 0;

On Wed, Nov 21, 2018 at 11:51:14AM +0100, Jean-Jacques Hiblot wrote:
The set_phy_power() callback is part of struct omap_musb_board_data. This structure is part of the platform data passed to the musb-new driver. This does not really fit with the Driver Model, so allow not to use struct omap_musb_board_data to turn the phy on or off.
Signed-off-by: Jean-Jacques Hiblot jjhiblot@ti.com
Reviewed-by: Tom Rini trini@konsulko.com

Enable DM for USB peripheral in the musb-new driver. Also make sure that the driver can be used in the SPL. This implies that: * the driver must work with and without the OF_CONTROL option. That in turn, implies that the platform data can be passed in a struct ti_musb_platdata or be read from the dtb * usb.o is linked in the SPL if host support is enabled
Signed-off-by: Jean-Jacques Hiblot jjhiblot@ti.com ---
arch/arm/include/asm/omap_musb.h | 8 ++ common/Makefile | 3 + drivers/usb/musb-new/musb_gadget.c | 11 +++ drivers/usb/musb-new/musb_uboot.c | 4 +- drivers/usb/musb-new/ti-musb.c | 179 ++++++++++++++++++++++++++++--------- 5 files changed, 160 insertions(+), 45 deletions(-)
diff --git a/arch/arm/include/asm/omap_musb.h b/arch/arm/include/asm/omap_musb.h index 875f100..b40ea00 100644 --- a/arch/arm/include/asm/omap_musb.h +++ b/arch/arm/include/asm/omap_musb.h @@ -7,6 +7,7 @@
#ifndef __ASM_ARM_OMAP_MUSB_H #define __ASM_ARM_OMAP_MUSB_H +#include <linux/usb/musb.h>
extern struct musb_platform_ops musb_dsps_ops; extern const struct musb_platform_ops am35x_ops; @@ -21,4 +22,11 @@ struct omap_musb_board_data { };
enum musb_interface {MUSB_INTERFACE_ULPI, MUSB_INTERFACE_UTMI}; + +struct ti_musb_platdata { + void *base; + void *ctrl_mod_base; + struct musb_hdrc_platform_data plat; +}; + #endif /* __ASM_ARM_OMAP_MUSB_H */ diff --git a/common/Makefile b/common/Makefile index a238836..44fdb92 100644 --- a/common/Makefile +++ b/common/Makefile @@ -72,9 +72,12 @@ obj-$(CONFIG_SPL_YMODEM_SUPPORT) += xyzModem.o obj-$(CONFIG_SPL_LOAD_FIT) += common_fit.o obj-$(CONFIG_SPL_NET_SUPPORT) += miiphyutil.o obj-$(CONFIG_$(SPL_TPL_)OF_LIBFDT) += fdt_support.o + ifdef CONFIG_SPL_USB_HOST_SUPPORT obj-$(CONFIG_SPL_USB_SUPPORT) += usb.o usb_hub.o obj-$(CONFIG_USB_STORAGE) += usb_storage.o +else +obj-$(CONFIG_USB_MUSB_HOST) += usb.o endif endif #others diff --git a/drivers/usb/musb-new/musb_gadget.c b/drivers/usb/musb-new/musb_gadget.c index 8b6cec1..b35d33f 100644 --- a/drivers/usb/musb-new/musb_gadget.c +++ b/drivers/usb/musb-new/musb_gadget.c @@ -1775,6 +1775,14 @@ static int musb_gadget_start(struct usb_gadget *g, struct usb_gadget_driver *driver); static int musb_gadget_stop(struct usb_gadget *g, struct usb_gadget_driver *driver); +#else +static int musb_gadget_stop(struct usb_gadget *g) +{ + struct musb *musb = gadget_to_musb(g); + + musb_stop(musb); + return 0; +} #endif
static const struct usb_gadget_ops musb_gadget_operations = { @@ -1787,6 +1795,9 @@ static const struct usb_gadget_ops musb_gadget_operations = { #ifndef __UBOOT__ .udc_start = musb_gadget_start, .udc_stop = musb_gadget_stop, +#else + .udc_start = musb_gadget_start, + .udc_stop = musb_gadget_stop, #endif };
diff --git a/drivers/usb/musb-new/musb_uboot.c b/drivers/usb/musb-new/musb_uboot.c index 2bf918e..90db5ef 100644 --- a/drivers/usb/musb-new/musb_uboot.c +++ b/drivers/usb/musb-new/musb_uboot.c @@ -367,7 +367,7 @@ struct dm_usb_ops musb_usb_ops = { #endif /* CONFIG_DM_USB */ #endif /* CONFIG_USB_MUSB_HOST */
-#ifdef CONFIG_USB_MUSB_GADGET +#if defined(CONFIG_USB_MUSB_GADGET) && !defined(CONFIG_DM_USB_GADGET) static struct musb *gadget;
int usb_gadget_handle_interrupts(int index) @@ -430,7 +430,7 @@ struct musb *musb_register(struct musb_hdrc_platform_data *plat, void *bdata, musbp = &musb_host.host; break; #endif -#ifdef CONFIG_USB_MUSB_GADGET +#if defined(CONFIG_USB_MUSB_GADGET) && !defined(CONFIG_DM_USB_GADGET) case MUSB_PERIPHERAL: musbp = &gadget; break; diff --git a/drivers/usb/musb-new/ti-musb.c b/drivers/usb/musb-new/ti-musb.c index 9fbe2d6..c3d9ef0 100644 --- a/drivers/usb/musb-new/ti-musb.c +++ b/drivers/usb/musb-new/ti-musb.c @@ -20,22 +20,33 @@ DECLARE_GLOBAL_DATA_PTR;
#ifdef CONFIG_DM_USB - /* USB 2.0 PHY Control */ #define CM_PHY_PWRDN (1 << 0) #define CM_PHY_OTG_PWRDN (1 << 1) #define OTGVDET_EN (1 << 19) #define OTGSESSENDEN (1 << 20)
+#define AM335X_USB0_CTRL 0x0 #define AM335X_USB1_CTRL 0x8
-struct ti_musb_platdata { - void *base; - void *ctrl_mod_base; - struct musb_hdrc_platform_data plat; - struct musb_hdrc_config musb_config; - struct omap_musb_board_data otg_board_data; -}; +static void ti_musb_set_phy_power(struct udevice *dev, u8 on) +{ + struct ti_musb_platdata *platdata = dev_get_platdata(dev); + + if (!platdata->ctrl_mod_base) + return; + + if (on) { + clrsetbits_le32(platdata->ctrl_mod_base, + CM_PHY_PWRDN | CM_PHY_OTG_PWRDN, + OTGVDET_EN | OTGSESSENDEN); + } else { + clrsetbits_le32(platdata->ctrl_mod_base, 0, + CM_PHY_PWRDN | CM_PHY_OTG_PWRDN); + } +} + +#if CONFIG_IS_ENABLED(OF_CONTROL)
static int ti_musb_get_usb_index(int node) { @@ -64,20 +75,6 @@ static int ti_musb_get_usb_index(int node) return -ENOENT; }
-static void ti_musb_set_phy_power(struct udevice *dev, u8 on) -{ - struct ti_musb_platdata *platdata = dev_get_platdata(dev); - - if (on) { - clrsetbits_le32(platdata->ctrl_mod_base, - CM_PHY_PWRDN | CM_PHY_OTG_PWRDN, - OTGVDET_EN | OTGSESSENDEN); - } else { - clrsetbits_le32(platdata->ctrl_mod_base, 0, - CM_PHY_PWRDN | CM_PHY_OTG_PWRDN); - } -} - static int ti_musb_ofdata_to_platdata(struct udevice *dev) { struct ti_musb_platdata *platdata = dev_get_platdata(dev); @@ -86,6 +83,7 @@ static int ti_musb_ofdata_to_platdata(struct udevice *dev) int phys; int ctrl_mod; int usb_index; + struct musb_hdrc_config *musb_config;
platdata->base = (void *)devfdt_get_addr_index(dev, 1);
@@ -96,38 +94,41 @@ static int ti_musb_ofdata_to_platdata(struct udevice *dev) switch (usb_index) { case 1: platdata->ctrl_mod_base += AM335X_USB1_CTRL; + break; case 0: + platdata->ctrl_mod_base += AM335X_USB0_CTRL; + break; default: break; }
- platdata->musb_config.multipoint = fdtdec_get_int(fdt, node, - "mentor,multipoint", - -1); - if (platdata->musb_config.multipoint < 0) { + musb_config = malloc(sizeof(struct musb_hdrc_config)); + memset(musb_config, 0, sizeof(struct musb_hdrc_config)); + + musb_config->multipoint = fdtdec_get_int(fdt, node, + "mentor,multipoint", -1); + if (musb_config->multipoint < 0) { pr_err("MUSB multipoint DT entry missing\n"); return -ENOENT; }
- platdata->musb_config.dyn_fifo = 1; + musb_config->dyn_fifo = 1;
- platdata->musb_config.num_eps = fdtdec_get_int(fdt, node, - "mentor,num-eps", -1); - if (platdata->musb_config.num_eps < 0) { + musb_config->num_eps = fdtdec_get_int(fdt, node, "mentor,num-eps", + -1); + if (musb_config->num_eps < 0) { pr_err("MUSB num-eps DT entry missing\n"); return -ENOENT; }
- platdata->musb_config.ram_bits = fdtdec_get_int(fdt, node, - "mentor,ram-bits", -1); - if (platdata->musb_config.ram_bits < 0) { + musb_config->ram_bits = fdtdec_get_int(fdt, node, "mentor,ram-bits", + -1); + if (musb_config->ram_bits < 0) { pr_err("MUSB ram-bits DT entry missing\n"); return -ENOENT; }
- platdata->otg_board_data.set_phy_power = ti_musb_set_phy_power; - platdata->otg_board_data.dev = dev; - platdata->plat.config = &platdata->musb_config; + platdata->plat.config = musb_config;
platdata->plat.power = fdtdec_get_int(fdt, node, "mentor,power", -1); if (platdata->plat.power < 0) { @@ -136,29 +137,27 @@ static int ti_musb_ofdata_to_platdata(struct udevice *dev) }
platdata->plat.platform_ops = &musb_dsps_ops; - platdata->plat.board_data = &platdata->otg_board_data;
return 0; } +#endif
static int ti_musb_host_probe(struct udevice *dev) { struct musb_host_data *host = dev_get_priv(dev); struct ti_musb_platdata *platdata = dev_get_platdata(dev); struct usb_bus_priv *priv = dev_get_uclass_priv(dev); - struct omap_musb_board_data *otg_board_data; int ret;
priv->desc_before_addr = true;
- otg_board_data = &platdata->otg_board_data; - host->host = musb_init_controller(&platdata->plat, - (struct device *)otg_board_data, + NULL, platdata->base); if (!host->host) return -EIO;
+ ti_musb_set_phy_power(dev, 1); ret = musb_lowlevel_init(host);
return ret; @@ -169,10 +168,12 @@ static int ti_musb_host_remove(struct udevice *dev) struct musb_host_data *host = dev_get_priv(dev);
musb_stop(host->host); + ti_musb_set_phy_power(dev, 0);
return 0; }
+#if CONFIG_IS_ENABLED(OF_CONTROL) static int ti_musb_host_ofdata_to_platdata(struct udevice *dev) { struct ti_musb_platdata *platdata = dev_get_platdata(dev); @@ -190,11 +191,14 @@ static int ti_musb_host_ofdata_to_platdata(struct udevice *dev)
return 0; } +#endif
U_BOOT_DRIVER(ti_musb_host) = { .name = "ti-musb-host", .id = UCLASS_USB, +#if CONFIG_IS_ENABLED(OF_CONTROL) .ofdata_to_platdata = ti_musb_host_ofdata_to_platdata, +#endif .probe = ti_musb_host_probe, .remove = ti_musb_host_remove, .ops = &musb_usb_ops, @@ -202,6 +206,82 @@ U_BOOT_DRIVER(ti_musb_host) = { .priv_auto_alloc_size = sizeof(struct musb_host_data), };
+#ifdef CONFIG_DM_USB_GADGET +struct ti_musb_peripheral { + struct musb *periph; +}; + +#if CONFIG_IS_ENABLED(OF_CONTROL) +static int ti_musb_peripheral_ofdata_to_platdata(struct udevice *dev) +{ + struct ti_musb_platdata *platdata = dev_get_platdata(dev); + const void *fdt = gd->fdt_blob; + int node = dev_of_offset(dev); + int ret; + + ret = ti_musb_ofdata_to_platdata(dev); + if (ret) { + pr_err("platdata dt parse error\n"); + return ret; + } + platdata->plat.mode = MUSB_PERIPHERAL; + + return 0; +} +#endif + +int dm_usb_gadget_handle_interrupts(struct udevice *dev) +{ + struct ti_musb_peripheral *priv = dev_get_priv(dev); + + priv->periph->isr(0, priv->periph); + + return 0; +} + +static int ti_musb_peripheral_probe(struct udevice *dev) +{ + struct ti_musb_peripheral *priv = dev_get_priv(dev); + struct ti_musb_platdata *platdata = dev_get_platdata(dev); + int ret; + + priv->periph = musb_init_controller(&platdata->plat, + NULL, + platdata->base); + if (!priv->periph) + return -EIO; + + ti_musb_set_phy_power(dev, 1); + musb_gadget_setup(priv->periph); + return usb_add_gadget_udc((struct device *)dev, &priv->periph->g); +} + +static int ti_musb_peripheral_remove(struct udevice *dev) +{ + struct ti_musb_peripheral *priv = dev_get_priv(dev); + + usb_del_gadget_udc(&priv->periph->g); + ti_musb_set_phy_power(dev, 0); + + return 0; +} + +U_BOOT_DRIVER(ti_musb_peripheral) = { + .name = "ti-musb-peripheral", + .id = UCLASS_USB_GADGET_GENERIC, +#if CONFIG_IS_ENABLED(OF_CONTROL) + .ofdata_to_platdata = ti_musb_peripheral_ofdata_to_platdata, +#endif + .probe = ti_musb_peripheral_probe, + .remove = ti_musb_peripheral_remove, + .ops = &musb_usb_ops, + .platdata_auto_alloc_size = sizeof(struct ti_musb_platdata), + .priv_auto_alloc_size = sizeof(struct ti_musb_peripheral), + .flags = DM_FLAG_PRE_RELOC, +}; +#endif + +#if CONFIG_IS_ENABLED(OF_CONTROL) static int ti_musb_wrapper_bind(struct udevice *parent) { const void *fdt = gd->fdt_blob; @@ -222,11 +302,23 @@ static int ti_musb_wrapper_bind(struct udevice *parent) switch (dr_mode) { case USB_DR_MODE_PERIPHERAL: /* Bind MUSB device */ + ret = device_bind_driver_to_node(parent, + "ti-musb-peripheral", + name, + offset_to_ofnode(node), + &dev); + if (ret) { + pr_err("musb - not able to bind usb peripheral node\n"); + return ret; + } break; case USB_DR_MODE_HOST: /* Bind MUSB host */ - ret = device_bind_driver_to_node(parent, "ti-musb-host", - name, offset_to_ofnode(node), &dev); + ret = device_bind_driver_to_node(parent, + "ti-musb-host", + name, + offset_to_ofnode(node), + &dev); if (ret) { pr_err("musb - not able to bind usb host node\n"); return ret; @@ -250,5 +342,6 @@ U_BOOT_DRIVER(ti_musb_wrapper) = { .of_match = ti_musb_ids, .bind = ti_musb_wrapper_bind, }; +#endif /* CONFIG_IS_ENABLED(OF_CONTROL) */
#endif /* CONFIG_DM_USB */

On Wed, Nov 21, 2018 at 11:51:15AM +0100, Jean-Jacques Hiblot wrote:
Enable DM for USB peripheral in the musb-new driver. Also make sure that the driver can be used in the SPL. This implies that:
- the driver must work with and without the OF_CONTROL option. That
in turn, implies that the platform data can be passed in a struct ti_musb_platdata or be read from the dtb
- usb.o is linked in the SPL if host support is enabled
Signed-off-by: Jean-Jacques Hiblot jjhiblot@ti.com
Reviewed-by: Tom Rini trini@konsulko.com

When DM_USB is used, either the USB controllers are bound when the DTB is parsed (when OF_CONTROL is enabled) or they are bound using the U_BOOT_DEVICES() macro. In the later case, the platform data is passed in a struct ti_musb_platdata because it cannot be read from the DTB.
Signed-off-by: Jean-Jacques Hiblot jjhiblot@ti.com ---
arch/arm/mach-omap2/am33xx/board.c | 58 ++++++++++++++++++++++++++++++++------ 1 file changed, 50 insertions(+), 8 deletions(-)
diff --git a/arch/arm/mach-omap2/am33xx/board.c b/arch/arm/mach-omap2/am33xx/board.c index f5f2bd5..001c668 100644 --- a/arch/arm/mach-omap2/am33xx/board.c +++ b/arch/arm/mach-omap2/am33xx/board.c @@ -159,7 +159,55 @@ int cpu_mmc_init(bd_t *bis) /* AM33XX has two MUSB controllers which can be host or gadget */ #if (defined(CONFIG_USB_MUSB_GADGET) || defined(CONFIG_USB_MUSB_HOST)) && \ (defined(CONFIG_AM335X_USB0) || defined(CONFIG_AM335X_USB1)) && \ - (!defined(CONFIG_DM_USB)) + (!defined(CONFIG_DM_USB) || !CONFIG_IS_ENABLED(OF_CONTROL)) && \ + (!defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_MUSB_NEW_SUPPORT)) + +static struct musb_hdrc_config musb_config = { + .multipoint = 1, + .dyn_fifo = 1, + .num_eps = 16, + .ram_bits = 12, +}; + +#if defined(CONFIG_DM_USB) && !CONFIG_IS_ENABLED(OF_CONTROL) +static struct ti_musb_platdata usb0 = { + .base = (void *)USB0_OTG_BASE, + .ctrl_mod_base = &((struct ctrl_dev *)CTRL_DEVICE_BASE)->usb_ctrl0, + .plat = { + .config = &musb_config, + .power = 50, + .platform_ops = &musb_dsps_ops, + }, +}; + +static struct ti_musb_platdata usb1 = { + .base = (void *)USB1_OTG_BASE, + .ctrl_mod_base = &((struct ctrl_dev *)CTRL_DEVICE_BASE)->usb_ctrl1, + .plat = { + .config = &musb_config, + .power = 50, + .platform_ops = &musb_dsps_ops, + }, +}; + +U_BOOT_DEVICES(am33xx_usbs) = { +#if CONFIG_AM335X_USB0_MODE == MUSB_PERIPHERAL + { "ti-musb-peripheral", &usb0 }, +#elif CONFIG_AM335X_USB0_MODE == MUSB_HOST + { "ti-musb-host", &usb0 }, +#endif +#if CONFIG_AM335X_USB1_MODE == MUSB_PERIPHERAL + { "ti-musb-peripheral", &usb1 }, +#elif CONFIG_AM335X_USB1_MODE == MUSB_HOST + { "ti-musb-host", &usb1 }, +#endif +}; + +int arch_misc_init(void) +{ + return 0; +} +#else static struct ctrl_dev *cdev = (struct ctrl_dev *)CTRL_DEVICE_BASE;
/* USB 2.0 PHY Control */ @@ -178,13 +226,6 @@ static void am33xx_usb_set_phy_power(u8 on, u32 *reg_addr) } }
-static struct musb_hdrc_config musb_config = { - .multipoint = 1, - .dyn_fifo = 1, - .num_eps = 16, - .ram_bits = 12, -}; - #ifdef CONFIG_AM335X_USB0 static void am33xx_otg0_set_phy_power(struct udevice *dev, u8 on) { @@ -235,6 +276,7 @@ int arch_misc_init(void) #endif return 0; } +#endif
#else /* CONFIG_USB_MUSB_* && CONFIG_AM335X_USB* && !CONFIG_DM_USB */

On Wed, Nov 21, 2018 at 11:51:16AM +0100, Jean-Jacques Hiblot wrote:
When DM_USB is used, either the USB controllers are bound when the DTB is parsed (when OF_CONTROL is enabled) or they are bound using the U_BOOT_DEVICES() macro. In the later case, the platform data is passed in a struct ti_musb_platdata because it cannot be read from the DTB.
Signed-off-by: Jean-Jacques Hiblot jjhiblot@ti.com
Reviewed-by: Tom Rini trini@konsulko.com

DM_USB is now supported in the SPL. Do not undef it
Signed-off-by: Jean-Jacques Hiblot jjhiblot@ti.com ---
include/configs/am335x_evm.h | 1 - 1 file changed, 1 deletion(-)
diff --git a/include/configs/am335x_evm.h b/include/configs/am335x_evm.h index 5d5b09b..3bd96b9 100644 --- a/include/configs/am335x_evm.h +++ b/include/configs/am335x_evm.h @@ -253,7 +253,6 @@ #ifdef CONFIG_SPL_BUILD #undef CONFIG_DM_MMC #undef CONFIG_TIMER -#undef CONFIG_DM_USB #endif
#if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_USB_ETHER)

On 21/11/18 4:21 PM, Jean-Jacques Hiblot wrote:
DM_USB is now supported in the SPL. Do not undef it
Signed-off-by: Jean-Jacques Hiblot jjhiblot@ti.com
With this, I guess we can merge am335x_evm_usbspl_defconfig into am335x_evm_defconfig? or am I missing something?
Thanks and regards, Lokesh
include/configs/am335x_evm.h | 1 - 1 file changed, 1 deletion(-)
diff --git a/include/configs/am335x_evm.h b/include/configs/am335x_evm.h index 5d5b09b..3bd96b9 100644 --- a/include/configs/am335x_evm.h +++ b/include/configs/am335x_evm.h @@ -253,7 +253,6 @@ #ifdef CONFIG_SPL_BUILD #undef CONFIG_DM_MMC #undef CONFIG_TIMER -#undef CONFIG_DM_USB #endif
#if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_USB_ETHER)

On Thu, Nov 22, 2018 at 04:13:58PM +0530, Lokesh Vutla wrote:
On 21/11/18 4:21 PM, Jean-Jacques Hiblot wrote:
DM_USB is now supported in the SPL. Do not undef it
Signed-off-by: Jean-Jacques Hiblot jjhiblot@ti.com
With this, I guess we can merge am335x_evm_usbspl_defconfig into am335x_evm_defconfig? or am I missing something?
The main reason for _usbspl_defconfig is size constraints, we can't (or at least, couldn't before) fit all the various methods into a single binary.

Hi Tom,
On 22/11/2018 13:45, Tom Rini wrote:
On Thu, Nov 22, 2018 at 04:13:58PM +0530, Lokesh Vutla wrote:
On 21/11/18 4:21 PM, Jean-Jacques Hiblot wrote:
DM_USB is now supported in the SPL. Do not undef it
Signed-off-by: Jean-Jacques Hiblot jjhiblot@ti.com
With this, I guess we can merge am335x_evm_usbspl_defconfig into am335x_evm_defconfig? or am I missing something?
The main reason for _usbspl_defconfig is size constraints, we can't (or at least, couldn't before) fit all the various methods into a single binary.
I'm working on reducing the difference between the am335x evm defconfigs, and also reduce their numbers if possible.
I'm having trouble testing the NOR and SPI configurations. Even with the u-boot/master branch, I can't boot.
Have you tried them recently ? If so can you provide some guidelines?
JJ

On Thu, Nov 22, 2018 at 02:36:11PM +0100, Jean-Jacques Hiblot wrote:
Hi Tom,
On 22/11/2018 13:45, Tom Rini wrote:
On Thu, Nov 22, 2018 at 04:13:58PM +0530, Lokesh Vutla wrote:
On 21/11/18 4:21 PM, Jean-Jacques Hiblot wrote:
DM_USB is now supported in the SPL. Do not undef it
Signed-off-by: Jean-Jacques Hiblot jjhiblot@ti.com
With this, I guess we can merge am335x_evm_usbspl_defconfig into am335x_evm_defconfig? or am I missing something?
The main reason for _usbspl_defconfig is size constraints, we can't (or at least, couldn't before) fit all the various methods into a single binary.
I'm working on reducing the difference between the am335x evm defconfigs, and also reduce their numbers if possible.
I'm having trouble testing the NOR and SPI configurations. Even with the u-boot/master branch, I can't boot.
Have you tried them recently ? If so can you provide some guidelines?
I haven't tried the NOR one in years (I'm not 100% sure I have a functional BBW + NOR cape honestly) and it's been a while since I did the SPI one either. You did write MLO.byteswap right?

On 22/11/2018 15:18, Tom Rini wrote:
On Thu, Nov 22, 2018 at 02:36:11PM +0100, Jean-Jacques Hiblot wrote:
Hi Tom,
On 22/11/2018 13:45, Tom Rini wrote:
On Thu, Nov 22, 2018 at 04:13:58PM +0530, Lokesh Vutla wrote:
On 21/11/18 4:21 PM, Jean-Jacques Hiblot wrote:
DM_USB is now supported in the SPL. Do not undef it
Signed-off-by: Jean-Jacques Hiblot jjhiblot@ti.com
With this, I guess we can merge am335x_evm_usbspl_defconfig into am335x_evm_defconfig? or am I missing something?
The main reason for _usbspl_defconfig is size constraints, we can't (or at least, couldn't before) fit all the various methods into a single binary.
I'm working on reducing the difference between the am335x evm defconfigs, and also reduce their numbers if possible.
I'm having trouble testing the NOR and SPI configurations. Even with the u-boot/master branch, I can't boot.
Have you tried them recently ? If so can you provide some guidelines?
I haven't tried the NOR one in years (I'm not 100% sure I have a functional BBW + NOR cape honestly) and it's been a while since I did the SPI one either. You did write MLO.byteswap right?
Haven't been this far. I can't even write to the SPI flash (not detected)
Maybe I'm not using the right platform (am335x evm + GP daughter board).
What board did you use to test those configurations ?
JJ

On Thu, Nov 22, 2018 at 03:25:07PM +0100, Jean-Jacques Hiblot wrote:
On 22/11/2018 15:18, Tom Rini wrote:
On Thu, Nov 22, 2018 at 02:36:11PM +0100, Jean-Jacques Hiblot wrote:
Hi Tom,
On 22/11/2018 13:45, Tom Rini wrote:
On Thu, Nov 22, 2018 at 04:13:58PM +0530, Lokesh Vutla wrote:
On 21/11/18 4:21 PM, Jean-Jacques Hiblot wrote:
DM_USB is now supported in the SPL. Do not undef it
Signed-off-by: Jean-Jacques Hiblot jjhiblot@ti.com
With this, I guess we can merge am335x_evm_usbspl_defconfig into am335x_evm_defconfig? or am I missing something?
The main reason for _usbspl_defconfig is size constraints, we can't (or at least, couldn't before) fit all the various methods into a single binary.
I'm working on reducing the difference between the am335x evm defconfigs, and also reduce their numbers if possible.
I'm having trouble testing the NOR and SPI configurations. Even with the u-boot/master branch, I can't boot.
Have you tried them recently ? If so can you provide some guidelines?
I haven't tried the NOR one in years (I'm not 100% sure I have a functional BBW + NOR cape honestly) and it's been a while since I did the SPI one either. You did write MLO.byteswap right?
Haven't been this far. I can't even write to the SPI flash (not detected)
Maybe I'm not using the right platform (am335x evm + GP daughter board).
What board did you use to test those configurations ?
... the one thing at the back of my mind is that you may need to set DIP switches for SPI flash to be present, on that board?

On 22/11/2018 15:43, Tom Rini wrote:
On Thu, Nov 22, 2018 at 03:25:07PM +0100, Jean-Jacques Hiblot wrote:
On 22/11/2018 15:18, Tom Rini wrote:
On Thu, Nov 22, 2018 at 02:36:11PM +0100, Jean-Jacques Hiblot wrote:
Hi Tom,
On 22/11/2018 13:45, Tom Rini wrote:
On Thu, Nov 22, 2018 at 04:13:58PM +0530, Lokesh Vutla wrote:
On 21/11/18 4:21 PM, Jean-Jacques Hiblot wrote: > DM_USB is now supported in the SPL. Do not undef it > > Signed-off-by: Jean-Jacques Hiblot jjhiblot@ti.com > --- With this, I guess we can merge am335x_evm_usbspl_defconfig into am335x_evm_defconfig? or am I missing something?
The main reason for _usbspl_defconfig is size constraints, we can't (or at least, couldn't before) fit all the various methods into a single binary.
I'm working on reducing the difference between the am335x evm defconfigs, and also reduce their numbers if possible.
I'm having trouble testing the NOR and SPI configurations. Even with the u-boot/master branch, I can't boot.
Have you tried them recently ? If so can you provide some guidelines?
I haven't tried the NOR one in years (I'm not 100% sure I have a functional BBW + NOR cape honestly) and it's been a while since I did the SPI one either. You did write MLO.byteswap right?
Haven't been this far. I can't even write to the SPI flash (not detected)
Maybe I'm not using the right platform (am335x evm + GP daughter board).
What board did you use to test those configurations ?
... the one thing at the back of my mind is that you may need to set DIP switches for SPI flash to be present, on that board?
I found it. There is a DIP switch on the daughter board too that you need to set.
For the record, in case someone needs it someday: on AM335x EVM, SPI boot work with Profile #2. The profile is selected with the DIP switch located on the GP daughter board.
Thanks,
JJ

On 22/11/2018 11:43, Lokesh Vutla wrote:
On 21/11/18 4:21 PM, Jean-Jacques Hiblot wrote:
DM_USB is now supported in the SPL. Do not undef it
Signed-off-by: Jean-Jacques Hiblot jjhiblot@ti.com
With this, I guess we can merge am335x_evm_usbspl_defconfig into am335x_evm_defconfig? or am I missing something?
Yes I'm working on it.
I'm hoping to be able to reduce the number of defconfigs.
JJ
Thanks and regards, Lokesh
include/configs/am335x_evm.h | 1 - 1 file changed, 1 deletion(-)
diff --git a/include/configs/am335x_evm.h b/include/configs/am335x_evm.h index 5d5b09b..3bd96b9 100644 --- a/include/configs/am335x_evm.h +++ b/include/configs/am335x_evm.h @@ -253,7 +253,6 @@ #ifdef CONFIG_SPL_BUILD #undef CONFIG_DM_MMC #undef CONFIG_TIMER -#undef CONFIG_DM_USB #endif #if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_USB_ETHER)

On Wed, Nov 21, 2018 at 11:51:17AM +0100, Jean-Jacques Hiblot wrote:
DM_USB is now supported in the SPL. Do not undef it
Signed-off-by: Jean-Jacques Hiblot jjhiblot@ti.com
Reviewed-by: Tom Rini trini@konsulko.com

Enable DM_USB and DM_USB_GADGET for this platform. Also enable RNDIS boot support (SPL load u-boot over USB RNDIS)
Signed-off-by: Jean-Jacques Hiblot jjhiblot@ti.com ---
configs/am335x_boneblack_vboot_defconfig | 8 ++++++++ 1 file changed, 8 insertions(+)
diff --git a/configs/am335x_boneblack_vboot_defconfig b/configs/am335x_boneblack_vboot_defconfig index d625599..2a7e72c 100644 --- a/configs/am335x_boneblack_vboot_defconfig +++ b/configs/am335x_boneblack_vboot_defconfig @@ -13,7 +13,11 @@ CONFIG_VERSION_VARIABLE=y CONFIG_ARCH_MISC_INIT=y CONFIG_SPL_MUSB_NEW_SUPPORT=y # CONFIG_SPL_NAND_SUPPORT is not set +CONFIG_SPL_NET_SUPPORT=y +CONFIG_SPL_NET_VCI_STRING="AM33xx U-Boot SPL" CONFIG_SPL_OS_BOOT=y +CONFIG_SPL_USB_GADGET_SUPPORT=y +CONFIG_SPL_USB_ETHER=y CONFIG_AUTOBOOT_KEYED=y CONFIG_AUTOBOOT_PROMPT="Press SPACE to abort autoboot in %d seconds\n" CONFIG_AUTOBOOT_DELAY_STR="d" @@ -31,6 +35,7 @@ CONFIG_DFU_MMC=y CONFIG_DFU_RAM=y CONFIG_USB_FUNCTION_FASTBOOT=y CONFIG_DM_I2C=y +CONFIG_MISC=y CONFIG_DM_MMC=y CONFIG_MMC_OMAP_HS=y CONFIG_SPI_FLASH=y @@ -44,8 +49,11 @@ CONFIG_OMAP3_SPI=y CONFIG_TIMER=y CONFIG_OMAP_TIMER=y CONFIG_USB=y +CONFIG_DM_USB=y +CONFIG_DM_USB_GADGET=y CONFIG_USB_MUSB_HOST=y CONFIG_USB_MUSB_GADGET=y +CONFIG_USB_MUSB_TI=y CONFIG_USB_MUSB_DSPS=y CONFIG_USB_STORAGE=y CONFIG_USB_GADGET=y

On Wed, Nov 21, 2018 at 11:51:18AM +0100, Jean-Jacques Hiblot wrote:
Enable DM_USB and DM_USB_GADGET for this platform. Also enable RNDIS boot support (SPL load u-boot over USB RNDIS)
Signed-off-by: Jean-Jacques Hiblot jjhiblot@ti.com
configs/am335x_boneblack_vboot_defconfig | 8 ++++++++ 1 file changed, 8 insertions(+)
In _this_ case I don't think it's worthwhile. We should probably do it for the main boneblack config tho.

On 22/11/18 6:59 PM, Tom Rini wrote:
On Wed, Nov 21, 2018 at 11:51:18AM +0100, Jean-Jacques Hiblot wrote:
Enable DM_USB and DM_USB_GADGET for this platform. Also enable RNDIS boot support (SPL load u-boot over USB RNDIS)
Signed-off-by: Jean-Jacques Hiblot jjhiblot@ti.com
configs/am335x_boneblack_vboot_defconfig | 8 ++++++++ 1 file changed, 8 insertions(+)
In _this_ case I don't think it's worthwhile. We should probably do it for the main boneblack config tho.
Actually I was thinking that we can drop both the beaglebone specific configs. am335x_evm_defconfig support BBB and all other variants.. Any reason to still have these specific configs?
Thanks and regards, Lokesh

On Thu, Nov 22, 2018 at 07:01:27PM +0530, Lokesh Vutla wrote:
On 22/11/18 6:59 PM, Tom Rini wrote:
On Wed, Nov 21, 2018 at 11:51:18AM +0100, Jean-Jacques Hiblot wrote:
Enable DM_USB and DM_USB_GADGET for this platform. Also enable RNDIS boot support (SPL load u-boot over USB RNDIS)
Signed-off-by: Jean-Jacques Hiblot jjhiblot@ti.com
configs/am335x_boneblack_vboot_defconfig | 8 ++++++++ 1 file changed, 8 insertions(+)
In _this_ case I don't think it's worthwhile. We should probably do it for the main boneblack config tho.
Actually I was thinking that we can drop both the beaglebone specific configs. am335x_evm_defconfig support BBB and all other variants.. Any reason to still have these specific configs?
So, since we have _evm defaulting to FAT env now, I think we only need the, or a, _vboot example config still.

On 11/21/2018 11:51 AM, Jean-Jacques Hiblot wrote:
This series applies on top of the series "Add support for DM_USB and DM_USB_DEV to TI's K2G platforms" and "Add support for DM_USB and DM_USB_DEV for TI's DRA7 EVMs and AM57 EVMs platforms."
The am433x platforms can use the generic DWC3 driver instead of relying on the dwc3-xhci driver. The am335x platforms use the musb controller. With a bit of work it can be made to support DM as well. This series only enables DM_USB and DM_USB_GADGET on am335x_boneblack_vboot. The changes for the other am335x based platforms will come in a subsequent series that reworks the configs of several TI boards.
This is part of a work to move all TI's platforms to support DM_USB and DM_USB_DEV. As a side effect it makes it easy to support the full USB RDNIS bootflow (bootrom loads SPL over RNDIS, SPL loads u-boot over RNDIS, u-boot loads the images over RNDIS)
This series is made of 3 parts:
- some generic changes: rename DM_USB_DEV in DM_USB_GADGET and create
UCLASS_USB_GADGET for the USB peripheral drivers.
- am437x support for DM_USB and DM_USB_GADGET
- am335x support for DM_USB and DM_USB_GADGET
Real glad to see this work happening, thanks for that. I'll let Lukasz handle the reviews since he's doing the gadget stuff.
participants (5)
-
Jean-Jacques Hiblot
-
Lokesh Vutla
-
Marek Vasut
-
Simon Glass
-
Tom Rini