[PATCH 00/13] Add support for USB host and peripheral bootmodes on am65x-idk

The following patches add support for USB mass storage and USB dfu bootmodes on am654x-idk.
Because of space constrains and the size of the USB stack, there are two different usbmsc and usbdfu defconfigs for building R5 SPL. Fitting both of these into one defconfig requires some changes in the USB subsystem which is a longer term effort
Faiz Abbas (13): spl: usb: Create an API spl_usb_load() spl: usb: Only init usb once armv7R: K3: am654: Use full malloc in SPL both pre and post reloc arm: mach-k3: sysfw-loader: Add support to load SYSFW from USB arm: mach-k3: am6_init: Gate mmc related configurations with the appropriate config arm: mach-k3: am6_init: Do USB fixups to facilitate host and device boot modes arm: mach-k3: am6_init: Add support for USB boot mode arm: dts: k3-am654-r5-base-board: Add USB0 nodes arm: dts: k3-am654-base-board: Add support for USB0 in SPL configs: am65x_evm: Add support for DFU related configs configs: am65x_evm_a53: Enable USB Mass storage and DFU boot modes configs: Add new config for supporting USB mass storage boot configs: Add defconfig for USB DFU bootmode
arch/arm/dts/k3-am654-base-board-u-boot.dtsi | 27 +++++ arch/arm/dts/k3-am654-r5-base-board.dts | 35 ++++++ arch/arm/mach-k3/am6_init.c | 96 ++++++++++++++- arch/arm/mach-k3/include/mach/am6_hardware.h | 2 + arch/arm/mach-k3/include/mach/am6_spl.h | 3 +- arch/arm/mach-k3/sysfw-loader.c | 11 ++ common/spl/spl_usb.c | 31 +++-- configs/am65x_evm_a53_defconfig | 9 ++ configs/am65x_evm_r5_usbdfu_defconfig | 119 +++++++++++++++++++ configs/am65x_evm_r5_usbmsc_defconfig | 119 +++++++++++++++++++ include/configs/am65x_evm.h | 10 +- include/spl.h | 14 +++ 12 files changed, 461 insertions(+), 15 deletions(-) create mode 100644 configs/am65x_evm_r5_usbdfu_defconfig create mode 100644 configs/am65x_evm_r5_usbmsc_defconfig

Create a new API spl_usb_load() that takes the filename as a parameter instead of taking the default U-boot PAYLOAD_NAME
Signed-off-by: Faiz Abbas faiz_abbas@ti.com --- common/spl/spl_usb.c | 20 +++++++++++++------- include/spl.h | 14 ++++++++++++++ 2 files changed, 27 insertions(+), 7 deletions(-)
diff --git a/common/spl/spl_usb.c b/common/spl/spl_usb.c index 08837b38fc..92ae96f66e 100644 --- a/common/spl/spl_usb.c +++ b/common/spl/spl_usb.c @@ -18,8 +18,9 @@
static int usb_stor_curr_dev = -1; /* current device */
-static int spl_usb_load_image(struct spl_image_info *spl_image, - struct spl_boot_device *bootdev) +int spl_usb_load(struct spl_image_info *spl_image, + struct spl_boot_device *bootdev, int partition, + const char *filename) { int err; struct blk_desc *stor_dev; @@ -43,13 +44,10 @@ static int spl_usb_load_image(struct spl_image_info *spl_image,
#ifdef CONFIG_SPL_OS_BOOT if (spl_start_uboot() || - spl_load_image_fat_os(spl_image, stor_dev, - CONFIG_SYS_USB_FAT_BOOT_PARTITION)) + spl_load_image_fat_os(spl_image, stor_dev, partition)) #endif { - err = spl_load_image_fat(spl_image, stor_dev, - CONFIG_SYS_USB_FAT_BOOT_PARTITION, - CONFIG_SPL_FS_LOAD_PAYLOAD_NAME); + err = spl_load_image_fat(spl_image, stor_dev, partition, filename); }
if (err) { @@ -59,4 +57,12 @@ static int spl_usb_load_image(struct spl_image_info *spl_image,
return 0; } + +static int spl_usb_load_image(struct spl_image_info *spl_image, + struct spl_boot_device *bootdev) +{ + return spl_usb_load(spl_image, bootdev, + CONFIG_SYS_USB_FAT_BOOT_PARTITION, + CONFIG_SPL_FS_LOAD_PAYLOAD_NAME); +} SPL_LOAD_IMAGE_METHOD("USB", 0, BOOT_DEVICE_USB, spl_usb_load_image); diff --git a/include/spl.h b/include/spl.h index b31c9bb4ab..9c050efcf9 100644 --- a/include/spl.h +++ b/include/spl.h @@ -503,6 +503,20 @@ int spl_mmc_load(struct spl_image_info *spl_image, int raw_part, unsigned long raw_sect);
+/** + * spl_usb_load() - Load an image file from USB mass storage + * + * @param spl_image Image data filled in by loading process + * @param bootdev Describes which device to load from + * @param raw_part Fat partition to load from + * @param filename Name of file to load + * + * @return 0 on success, otherwise error code + */ +int spl_usb_load(struct spl_image_info *spl_image, + struct spl_boot_device *bootdev, + int partition, const char *filename); + int spl_ymodem_load_image(struct spl_image_info *spl_image, struct spl_boot_device *bootdev);

usb_init() may be called multiple times for fetching multiple images from SPL. Skip reinitializing USB if its already been done
Signed-off-by: Faiz Abbas faiz_abbas@ti.com --- common/spl/spl_usb.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/common/spl/spl_usb.c b/common/spl/spl_usb.c index 92ae96f66e..3648de3492 100644 --- a/common/spl/spl_usb.c +++ b/common/spl/spl_usb.c @@ -22,11 +22,16 @@ int spl_usb_load(struct spl_image_info *spl_image, struct spl_boot_device *bootdev, int partition, const char *filename) { - int err; + int err = 0; struct blk_desc *stor_dev; + static bool usb_init_pending = true; + + if (usb_init_pending) { + usb_stop(); + err = usb_init(); + usb_init_pending = false; + }
- usb_stop(); - err = usb_init(); if (err) { #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT printf("%s: usb init failed: err - %d\n", __func__, err);

In order to be able to use things like file system drivers early on in SPL (before relocation) in a memory-constrained environment when DDR is not yet available we cannot use the simple malloc scheme which does not implement the freeing of previously allocated memory blocks. To address this issue go ahead and enable the use of the full malloc by manually initializing the required functionality inside board_init_f by creating a full malloc pool inside the pre-relocation malloc pool.
Signed-off-by: Faiz Abbas faiz_abbas@ti.com --- arch/arm/mach-k3/am6_init.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
diff --git a/arch/arm/mach-k3/am6_init.c b/arch/arm/mach-k3/am6_init.c index 516a02e8a8..74557c4bb7 100644 --- a/arch/arm/mach-k3/am6_init.c +++ b/arch/arm/mach-k3/am6_init.c @@ -18,7 +18,9 @@ #include <dm/uclass-internal.h> #include <dm/pinctrl.h> #include <linux/soc/ti/ti_sci_protocol.h> +#include <log.h> #include <mmc.h> +#include <stdlib.h>
#ifdef CONFIG_SPL_BUILD #ifdef CONFIG_K3_LOAD_SYSFW @@ -119,6 +121,8 @@ void board_init_f(ulong dummy) { #if defined(CONFIG_K3_LOAD_SYSFW) || defined(CONFIG_K3_AM654_DDRSS) struct udevice *dev; + size_t pool_size; + void *pool_addr; int ret; #endif /* @@ -149,6 +153,20 @@ void board_init_f(ulong dummy) #endif
#ifdef CONFIG_K3_LOAD_SYSFW + /* + * Initialize an early full malloc environment. Do so by allocating a + * new malloc area inside the currently active pre-relocation "first" + * malloc pool of which we use all that's left. + */ + pool_size = CONFIG_VAL(SYS_MALLOC_F_LEN) - gd->malloc_ptr; + pool_addr = malloc(pool_size); + if (!pool_addr) + panic("ERROR: Can't allocate full malloc pool!\n"); + + mem_malloc_init((ulong)pool_addr, (ulong)pool_size); + gd->flags |= GD_FLG_FULL_MALLOC_INIT; + debug("%s: initialized an early full malloc pool at 0x%08lx of 0x%lx bytes\n", + __func__, (unsigned long)pool_addr, (unsigned long)pool_size); /* * Process pinctrl for the serial0 a.k.a. WKUP_UART0 module and continue * regardless of the result of pinctrl. Do this without probing the

Add support for loading system firmware from a USB mass storage device
Signed-off-by: Faiz Abbas faiz_abbas@ti.com --- arch/arm/mach-k3/sysfw-loader.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
diff --git a/arch/arm/mach-k3/sysfw-loader.c b/arch/arm/mach-k3/sysfw-loader.c index 513be09c68..0ebd8c56a7 100644 --- a/arch/arm/mach-k3/sysfw-loader.c +++ b/arch/arm/mach-k3/sysfw-loader.c @@ -299,6 +299,17 @@ void k3_sysfw_loader(void (*config_pm_pre_callback) (void), ret = k3_sysfw_dfu_download(sysfw_load_address); break; #endif +#if CONFIG_IS_ENABLED(USB_STORAGE) + case BOOT_DEVICE_USB: + ret = spl_usb_load(&spl_image, &bootdev, + CONFIG_SYS_USB_FAT_BOOT_PARTITION, +#ifdef CONFIG_K3_SYSFW_IMAGE_NAME + CONFIG_K3_SYSFW_IMAGE_NAME); +#else + NULL); +#endif +#endif + break; default: panic("Loading SYSFW image from device %u not supported!\n", bootdev.boot_device);

Gate mmc related system related configurations with DM_MMC to avoid build errors when MMC is not enabled
Signed-off-by: Faiz Abbas faiz_abbas@ti.com --- arch/arm/mach-k3/am6_init.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/arch/arm/mach-k3/am6_init.c b/arch/arm/mach-k3/am6_init.c index 74557c4bb7..42d13a39f8 100644 --- a/arch/arm/mach-k3/am6_init.c +++ b/arch/arm/mach-k3/am6_init.c @@ -90,7 +90,7 @@ static void store_boot_index_from_rom(void) bootindex = *(u32 *)(CONFIG_SYS_K3_BOOT_PARAM_TABLE_INDEX); }
-#if defined(CONFIG_K3_LOAD_SYSFW) +#if defined(CONFIG_K3_LOAD_SYSFW) && CONFIG_IS_ENABLED(DM_MMC) void k3_mmc_stop_clock(void) { if (spl_boot_device() == BOOT_DEVICE_MMC1) { @@ -115,6 +115,9 @@ void k3_mmc_restart_clock(void) mmc_set_clock(mmc, mmc->saved_clock, false); } } +#else +void k3_mmc_stop_clock(void) {} +void k3_mmc_restart_clock(void) {} #endif
void board_init_f(ulong dummy)

U-boot only supports either USB host or device mode for a node at a time in dts To support both host and dfu bootmodes, set "peripheral" as the default dr_mode but fixup property to "host" if host bootmode is detected
This needs to happen before the dwc3 generic layer binds the usb device to a host or device driver. Therefore, open code the configurations in spl_early_init() and add the fixup after the fdtdec_setup() and before the dm_init_scan()
Also use the same fixup function to set the USB-PCIe Serdes mux to PCIe in both the host and device cases. This is required for accessing the interface at USB 2.0 speeds
Signed-off-by: Faiz Abbas faiz_abbas@ti.com --- arch/arm/mach-k3/am6_init.c | 68 +++++++++++++++++++++++++++++++++++-- 1 file changed, 66 insertions(+), 2 deletions(-)
diff --git a/arch/arm/mach-k3/am6_init.c b/arch/arm/mach-k3/am6_init.c index 42d13a39f8..b65860fef3 100644 --- a/arch/arm/mach-k3/am6_init.c +++ b/arch/arm/mach-k3/am6_init.c @@ -7,6 +7,7 @@ */
#include <common.h> +#include <fdt_support.h> #include <init.h> #include <asm/io.h> #include <spl.h> @@ -17,11 +18,15 @@ #include <dm.h> #include <dm/uclass-internal.h> #include <dm/pinctrl.h> +#include <dm/root.h> +#include <linux/compiler.h> #include <linux/soc/ti/ti_sci_protocol.h> #include <log.h> #include <mmc.h> #include <stdlib.h>
+DECLARE_GLOBAL_DATA_PTR; + #ifdef CONFIG_SPL_BUILD #ifdef CONFIG_K3_LOAD_SYSFW #ifdef CONFIG_TI_SECURE_DEVICE @@ -119,7 +124,67 @@ void k3_mmc_restart_clock(void) void k3_mmc_stop_clock(void) {} void k3_mmc_restart_clock(void) {} #endif +#if CONFIG_IS_ENABLED(DFU) || CONFIG_IS_ENABLED(USB_STORAGE) +#define CTRLMMR_SERDES0_CTRL 0x00104080 +#define PCIE_LANE0 0x1 +void fixup_usb_boot(void) +{ + int ret;
+ switch (spl_boot_device()) { + case BOOT_DEVICE_USB: + /* + * If bootmode is Host bootmode, fixup the dr_mode to host + * before the dwc3 bind takes place + */ + ret = fdt_find_and_setprop((void *)gd->fdt_blob, + "/interconnect@100000/dwc3@4000000/usb@10000", + "dr_mode", "host", 11, 0); + if (ret) + printf("%s: fdt_find_and_setprop() failed:%d\n", __func__, + ret); + /* fallthrough */ + case BOOT_DEVICE_DFU: + /* + * The serdes mux between PCIe and USB3 needs to be set to PCIe for + * accessing the interface at USB 2.0 + */ + writel(PCIE_LANE0, CTRLMMR_SERDES0_CTRL); + default: + ; + } +} +#endif +int am6_spl_early_init(void) +{ + int ret; +#if CONFIG_VAL(SYS_MALLOC_F_LEN) +#ifdef CONFIG_MALLOC_F_ADDR + gd->malloc_base = CONFIG_MALLOC_F_ADDR; +#endif + gd->malloc_limit = CONFIG_VAL(SYS_MALLOC_F_LEN); + gd->malloc_ptr = 0; +#endif + ret = fdtdec_setup(); + if (ret) { + printf("fdtdec_setup() returned error %d\n", ret); + return ret; + } + +#if CONFIG_IS_ENABLED(DFU) || CONFIG_IS_ENABLED(USB_STORAGE) + fixup_usb_boot(); +#endif + /* With CONFIG_SPL_OF_PLATDATA, bring in all devices */ + ret = dm_init_and_scan(!CONFIG_IS_ENABLED(OF_PLATDATA)); + if (ret) { + printf("dm_init_and_scan() returned error %d\n", ret); + return ret; + } + + gd->flags |= GD_FLG_SPL_EARLY_INIT; + + return 0; +} void board_init_f(ulong dummy) { #if defined(CONFIG_K3_LOAD_SYSFW) || defined(CONFIG_K3_AM654_DDRSS) @@ -141,9 +206,8 @@ void board_init_f(ulong dummy) disable_linefill_optimization(); setup_k3_mpu_regions(); #endif - /* Init DM early in-order to invoke system controller */ - spl_early_init(); + am6_spl_early_init();
#ifdef CONFIG_K3_EARLY_CONS /*

Hi,
On 02/07/20 1:32 pm, Faiz Abbas wrote:
[...]
int am6_spl_early_init(void)
Can this be static or do you intend to use this outside of this func file?
+{
- int ret;
+#if CONFIG_VAL(SYS_MALLOC_F_LEN) +#ifdef CONFIG_MALLOC_F_ADDR
- gd->malloc_base = CONFIG_MALLOC_F_ADDR;
+#endif
- gd->malloc_limit = CONFIG_VAL(SYS_MALLOC_F_LEN);
- gd->malloc_ptr = 0;
+#endif
- ret = fdtdec_setup();
- if (ret) {
printf("fdtdec_setup() returned error %d\n", ret);
return ret;
- }
+#if CONFIG_IS_ENABLED(DFU) || CONFIG_IS_ENABLED(USB_STORAGE)
- fixup_usb_boot();
+#endif
- /* With CONFIG_SPL_OF_PLATDATA, bring in all devices */
- ret = dm_init_and_scan(!CONFIG_IS_ENABLED(OF_PLATDATA));
- if (ret) {
printf("dm_init_and_scan() returned error %d\n", ret);
return ret;
- }
- gd->flags |= GD_FLG_SPL_EARLY_INIT;
- return 0;
+} void board_init_f(ulong dummy) { #if defined(CONFIG_K3_LOAD_SYSFW) || defined(CONFIG_K3_AM654_DDRSS) @@ -141,9 +206,8 @@ void board_init_f(ulong dummy) disable_linefill_optimization(); setup_k3_mpu_regions(); #endif
- /* Init DM early in-order to invoke system controller */
- spl_early_init();
I don't like this part as patch now open codes part of spl_early_init() here and any fixes/enhancements to that core code would not be available for am6 unless explicitly ported....
How about having a arch specific post fdtdec_setup() hook instead, that gets called from spl_common_init()?
- am6_spl_early_init();
#ifdef CONFIG_K3_EARLY_CONS /* -- 2.17.1
Regards Vignesh

Hi Vignesh,
On 03/07/20 1:04 pm, Vignesh Raghavendra wrote:
Hi,
On 02/07/20 1:32 pm, Faiz Abbas wrote:
[...]
int am6_spl_early_init(void)
Can this be static or do you intend to use this outside of this func file?
Fixed this in v2.
+{
- int ret;
+#if CONFIG_VAL(SYS_MALLOC_F_LEN) +#ifdef CONFIG_MALLOC_F_ADDR
- gd->malloc_base = CONFIG_MALLOC_F_ADDR;
+#endif
- gd->malloc_limit = CONFIG_VAL(SYS_MALLOC_F_LEN);
- gd->malloc_ptr = 0;
+#endif
- ret = fdtdec_setup();
- if (ret) {
printf("fdtdec_setup() returned error %d\n", ret);
return ret;
- }
+#if CONFIG_IS_ENABLED(DFU) || CONFIG_IS_ENABLED(USB_STORAGE)
- fixup_usb_boot();
+#endif
- /* With CONFIG_SPL_OF_PLATDATA, bring in all devices */
- ret = dm_init_and_scan(!CONFIG_IS_ENABLED(OF_PLATDATA));
- if (ret) {
printf("dm_init_and_scan() returned error %d\n", ret);
return ret;
- }
- gd->flags |= GD_FLG_SPL_EARLY_INIT;
- return 0;
+} void board_init_f(ulong dummy) { #if defined(CONFIG_K3_LOAD_SYSFW) || defined(CONFIG_K3_AM654_DDRSS) @@ -141,9 +206,8 @@ void board_init_f(ulong dummy) disable_linefill_optimization(); setup_k3_mpu_regions(); #endif
- /* Init DM early in-order to invoke system controller */
- spl_early_init();
I don't like this part as patch now open codes part of spl_early_init() here and any fixes/enhancements to that core code would not be available for am6 unless explicitly ported....
How about having a arch specific post fdtdec_setup() hook instead, that gets called from spl_common_init()?
there was an fdtdec_board_setup() which can be overridden for this. Implemented using that in v2.
Thanks, Faiz

On 02/07/20 1:32 pm, Faiz Abbas wrote:
U-boot only supports either USB host or device mode for a node at a time in dts To support both host and dfu bootmodes, set "peripheral" as the default dr_mode but fixup property to "host" if host bootmode is detected
This needs to happen before the dwc3 generic layer binds the usb device to a host or device driver. Therefore, open code the configurations in spl_early_init() and add the fixup after the fdtdec_setup() and before the dm_init_scan()
Also use the same fixup function to set the USB-PCIe Serdes mux to PCIe in both the host and device cases. This is required for accessing the interface at USB 2.0 speeds
Signed-off-by: Faiz Abbas faiz_abbas@ti.com
arch/arm/mach-k3/am6_init.c | 68 +++++++++++++++++++++++++++++++++++-- 1 file changed, 66 insertions(+), 2 deletions(-)
diff --git a/arch/arm/mach-k3/am6_init.c b/arch/arm/mach-k3/am6_init.c index 42d13a39f8..b65860fef3 100644 --- a/arch/arm/mach-k3/am6_init.c +++ b/arch/arm/mach-k3/am6_init.c @@ -7,6 +7,7 @@ */
#include <common.h> +#include <fdt_support.h> #include <init.h> #include <asm/io.h> #include <spl.h> @@ -17,11 +18,15 @@ #include <dm.h> #include <dm/uclass-internal.h> #include <dm/pinctrl.h> +#include <dm/root.h> +#include <linux/compiler.h> #include <linux/soc/ti/ti_sci_protocol.h> #include <log.h> #include <mmc.h> #include <stdlib.h>
+DECLARE_GLOBAL_DATA_PTR;
#ifdef CONFIG_SPL_BUILD #ifdef CONFIG_K3_LOAD_SYSFW #ifdef CONFIG_TI_SECURE_DEVICE @@ -119,7 +124,67 @@ void k3_mmc_restart_clock(void) void k3_mmc_stop_clock(void) {} void k3_mmc_restart_clock(void) {} #endif +#if CONFIG_IS_ENABLED(DFU) || CONFIG_IS_ENABLED(USB_STORAGE) +#define CTRLMMR_SERDES0_CTRL 0x00104080 +#define PCIE_LANE0 0x1 +void fixup_usb_boot(void) +{
int ret;
switch (spl_boot_device()) {
case BOOT_DEVICE_USB:
/*
* If bootmode is Host bootmode, fixup the dr_mode to host
* before the dwc3 bind takes place
*/
ret = fdt_find_and_setprop((void *)gd->fdt_blob,
"/interconnect@100000/dwc3@4000000/usb@10000",
"dr_mode", "host", 11, 0);
if (ret)
printf("%s: fdt_find_and_setprop() failed:%d\n", __func__,
ret);
/* fallthrough */
case BOOT_DEVICE_DFU:
/*
* The serdes mux between PCIe and USB3 needs to be set to PCIe for
* accessing the interface at USB 2.0
*/
writel(PCIE_LANE0, CTRLMMR_SERDES0_CTRL);
default:
;
}
+} +#endif +int am6_spl_early_init(void) +{
- int ret;
+#if CONFIG_VAL(SYS_MALLOC_F_LEN) +#ifdef CONFIG_MALLOC_F_ADDR
- gd->malloc_base = CONFIG_MALLOC_F_ADDR;
+#endif
- gd->malloc_limit = CONFIG_VAL(SYS_MALLOC_F_LEN);
- gd->malloc_ptr = 0;
+#endif
- ret = fdtdec_setup();
- if (ret) {
printf("fdtdec_setup() returned error %d\n", ret);
return ret;
- }
+#if CONFIG_IS_ENABLED(DFU) || CONFIG_IS_ENABLED(USB_STORAGE)
- fixup_usb_boot();
+#endif
- /* With CONFIG_SPL_OF_PLATDATA, bring in all devices */
- ret = dm_init_and_scan(!CONFIG_IS_ENABLED(OF_PLATDATA));
- if (ret) {
printf("dm_init_and_scan() returned error %d\n", ret);
return ret;
- }
- gd->flags |= GD_FLG_SPL_EARLY_INIT;
- return 0;
+} void board_init_f(ulong dummy) { #if defined(CONFIG_K3_LOAD_SYSFW) || defined(CONFIG_K3_AM654_DDRSS) @@ -141,9 +206,8 @@ void board_init_f(ulong dummy) disable_linefill_optimization(); setup_k3_mpu_regions(); #endif
- /* Init DM early in-order to invoke system controller */
- spl_early_init();
- am6_spl_early_init();
Nack. Try the below sequence for your case: - spl_early_init - if (usb dt fixup required) fdt_fixups() device_remove dm_init.
Thanks and regards, Lokesh

Add support for identifying USB host and device boot modes
Signed-off-by: Faiz Abbas faiz_abbas@ti.com --- arch/arm/mach-k3/am6_init.c | 5 +++++ arch/arm/mach-k3/include/mach/am6_hardware.h | 2 ++ arch/arm/mach-k3/include/mach/am6_spl.h | 3 ++- 3 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/arch/arm/mach-k3/am6_init.c b/arch/arm/mach-k3/am6_init.c index b65860fef3..59ab782116 100644 --- a/arch/arm/mach-k3/am6_init.c +++ b/arch/arm/mach-k3/am6_init.c @@ -357,6 +357,11 @@ static u32 __get_primary_bootmedia(u32 devstat) CTRLMMR_MAIN_DEVSTAT_EMMC_PORT_SHIFT; if (port == 0x1) bootmode = BOOT_DEVICE_MMC2; + } else if (bootmode == BOOT_DEVICE_DFU) { + u32 mode = (devstat & CTRLMMR_MAIN_DEVSTAT_USB_MODE_MASK) >> + CTRLMMR_MAIN_DEVSTAT_USB_MODE_SHIFT; + if (mode == 0x2) + bootmode = BOOT_DEVICE_USB; }
return bootmode; diff --git a/arch/arm/mach-k3/include/mach/am6_hardware.h b/arch/arm/mach-k3/include/mach/am6_hardware.h index a91ef5f735..1908a13f0f 100644 --- a/arch/arm/mach-k3/include/mach/am6_hardware.h +++ b/arch/arm/mach-k3/include/mach/am6_hardware.h @@ -25,6 +25,8 @@ #define CTRLMMR_MAIN_DEVSTAT_EMMC_PORT_SHIFT 14 #define CTRLMMR_MAIN_DEVSTAT_BKUP_MMC_PORT_MASK GENMASK(17, 17) #define CTRLMMR_MAIN_DEVSTAT_BKUP_MMC_PORT_SHIFT 12 +#define CTRLMMR_MAIN_DEVSTAT_USB_MODE_SHIFT 9 +#define CTRLMMR_MAIN_DEVSTAT_USB_MODE_MASK GENMASK(10, 9)
#define WKUP_CTRL_MMR0_BASE 0x43000000 #define MCU_CTRL_MMR0_BASE 0x40f00000 diff --git a/arch/arm/mach-k3/include/mach/am6_spl.h b/arch/arm/mach-k3/include/mach/am6_spl.h index e97d8143c6..61e0380927 100644 --- a/arch/arm/mach-k3/include/mach/am6_spl.h +++ b/arch/arm/mach-k3/include/mach/am6_spl.h @@ -14,7 +14,8 @@ #define BOOT_DEVICE_I2C 0x05 #define BOOT_DEVICE_MMC2 0x06 #define BOOT_DEVICE_ETHERNET 0x07 -#define BOOT_DEVICE_USB 0x08 +#define BOOT_DEVICE_DFU 0x08 +#define BOOT_DEVICE_USB 0x408 #define BOOT_DEVICE_PCIE 0x09 #define BOOT_DEVICE_UART 0x0a #define BOOT_DEVICE_NAND 0x0c

Add USB0 nodes and set them to host mode to support USB host and peripheral boot modes
Signed-off-by: Faiz Abbas faiz_abbas@ti.com --- arch/arm/dts/k3-am654-r5-base-board.dts | 35 +++++++++++++++++++++++++ 1 file changed, 35 insertions(+)
diff --git a/arch/arm/dts/k3-am654-r5-base-board.dts b/arch/arm/dts/k3-am654-r5-base-board.dts index e6b78643c1..d43a4edc71 100644 --- a/arch/arm/dts/k3-am654-r5-base-board.dts +++ b/arch/arm/dts/k3-am654-r5-base-board.dts @@ -278,3 +278,38 @@ #size-cells = <1>; }; }; + +&main_pmx0 { + u-boot,dm-spl; + usb0_pins_default: usb0_pins_default { + pinctrl-single,pins = < + AM65X_IOPAD(0x02bc, PIN_OUTPUT, 0) /* (AD9) USB0_DRVVBUS */ + >; + u-boot,dm-spl; + }; +}; + +&dwc3_0 { + status = "okay"; + u-boot,dm-spl; + /delete-property/ power-domains; + /delete-property/ assigned-clocks; + /delete-property/ assigned-clock-parents; +}; + +&usb0_phy { + status = "okay"; + u-boot,dm-spl; + /delete-property/ clocks; +}; + +&usb0 { + pinctrl-names = "default"; + pinctrl-0 = <&usb0_pins_default>; + dr_mode = "peripheral"; + u-boot,dm-spl; +}; + +&scm_conf { + u-boot,dm-spl; +};

Add nodes for USB0 in SPL to enable USB host boot mode
Signed-off-by: Faiz Abbas faiz_abbas@ti.com --- arch/arm/dts/k3-am654-base-board-u-boot.dtsi | 27 ++++++++++++++++++++ 1 file changed, 27 insertions(+)
diff --git a/arch/arm/dts/k3-am654-base-board-u-boot.dtsi b/arch/arm/dts/k3-am654-base-board-u-boot.dtsi index a7e5eb0553..b3d609430c 100644 --- a/arch/arm/dts/k3-am654-base-board-u-boot.dtsi +++ b/arch/arm/dts/k3-am654-base-board-u-boot.dtsi @@ -287,6 +287,12 @@ u-boot,dm-spl; };
+ usb0_pins_default: usb0_pins_default { + pinctrl-single,pins = < + AM65X_IOPAD(0x02bc, PIN_OUTPUT, 0) /* (AD9) USB0_DRVVBUS */ + >; + u-boot,dm-spl; + }; };
&main_pmx1 { @@ -393,3 +399,24 @@ u-boot,dm-spl; }; }; + +&dwc3_0 { + status = "okay"; + u-boot,dm-spl; +}; + +&usb0_phy { + status = "okay"; + u-boot,dm-spl; +}; + +&usb0 { + pinctrl-names = "default"; + pinctrl-0 = <&usb0_pins_default>; + dr_mode = "peripheral"; + u-boot,dm-spl; +}; + +&scm_conf { + u-boot,dm-spl; +};

Add offset and environment related configs used for booting from DFU.
Signed-off-by: Faiz Abbas faiz_abbas@ti.com --- include/configs/am65x_evm.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/include/configs/am65x_evm.h b/include/configs/am65x_evm.h index 19d861d402..5435ef85c7 100644 --- a/include/configs/am65x_evm.h +++ b/include/configs/am65x_evm.h @@ -22,6 +22,9 @@ #ifdef CONFIG_TARGET_AM654_A53_EVM #define CONFIG_SYS_INIT_SP_ADDR (CONFIG_SPL_TEXT_BASE + \ CONFIG_SYS_K3_NON_SECURE_MSRAM_SIZE) +/* Image load address in RAM for DFU boot*/ +#define CONFIG_SPL_LOAD_FIT_ADDRESS 0x81000000 +#define CONFIG_SYS_DFU_DATA_BUF_SIZE 0x20000 #else /* * Maximum size in memory allocated to the SPL BSS. Keep it as tight as @@ -44,6 +47,9 @@ /* Configure R5 SPL post-relocation malloc pool in DDR */ #define CONFIG_SYS_SPL_MALLOC_START 0x84000000 #define CONFIG_SYS_SPL_MALLOC_SIZE SZ_16M +/* Image load address in RAM for DFU boot*/ +#define CONFIG_SPL_LOAD_FIT_ADDRESS 0x80080000 +#define CONFIG_SYS_DFU_DATA_BUF_SIZE 0x5000 #endif
#ifdef CONFIG_SYS_K3_SPL_ATF @@ -124,8 +130,8 @@ "rootfstype=ubifs root=ubi0:rootfs rw ubi.mtd=ospi.rootfs\0"
#define EXTRA_ENV_DFUARGS \ - "dfu_bufsiz=0x20000\0" \ DFU_ALT_INFO_MMC \ + DFU_ALT_INFO_RAM \ DFU_ALT_INFO_EMMC \ DFU_ALT_INFO_OSPI

Enable configs to facilitate booting from USB Mass Storage devices as well as USB peripheral boot
Signed-off-by: Faiz Abbas faiz_abbas@ti.com --- configs/am65x_evm_a53_defconfig | 9 +++++++++ include/configs/am65x_evm.h | 2 ++ 2 files changed, 11 insertions(+)
diff --git a/configs/am65x_evm_a53_defconfig b/configs/am65x_evm_a53_defconfig index d74a2d0930..6a10e0b97d 100644 --- a/configs/am65x_evm_a53_defconfig +++ b/configs/am65x_evm_a53_defconfig @@ -33,14 +33,20 @@ CONFIG_SPL_SEPARATE_BSS=y CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR=y CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0x1400 CONFIG_SPL_DMA=y +CONFIG_SPL_ENV_SUPPORT=y CONFIG_SPL_I2C_SUPPORT=y CONFIG_SPL_DM_MAILBOX=y CONFIG_SPL_MTD_SUPPORT=y CONFIG_SPL_DM_RESET=y CONFIG_SPL_POWER_DOMAIN=y +CONFIG_SPL_RAM_SUPPORT=y # CONFIG_SPL_SPI_FLASH_TINY is not set CONFIG_SPL_SPI_FLASH_SFDP_SUPPORT=y CONFIG_SPL_SPI_LOAD=y +CONFIG_SPL_USB_HOST_SUPPORT=y +CONFIG_SPL_USB_STORAGE=y +CONFIG_SPL_USB_GADGET=y +CONFIG_SPL_DFU=y CONFIG_SPL_YMODEM_SUPPORT=y CONFIG_CMD_ASKENV=y CONFIG_CMD_DFU=y @@ -69,6 +75,7 @@ CONFIG_DM=y CONFIG_SPL_DM=y CONFIG_SPL_DM_SEQ_ALIAS=y CONFIG_SPL_REGMAP=y +CONFIG_SPL_SYSCON=y CONFIG_SPL_OF_TRANSLATE=y CONFIG_CLK=y CONFIG_SPL_CLK=y @@ -109,6 +116,7 @@ CONFIG_PCI=y CONFIG_DM_PCI=y CONFIG_PCI_KEYSTONE=y CONFIG_PHY=y +CONFIG_SPL_PHY=y CONFIG_AM654_PHY=y CONFIG_OMAP_USB2_PHY=y CONFIG_PINCTRL=y @@ -132,6 +140,7 @@ CONFIG_SYSRESET_TI_SCI=y CONFIG_USB=y CONFIG_DM_USB=y CONFIG_DM_USB_GADGET=y +CONFIG_SPL_DM_USB_GADGET=y CONFIG_USB_XHCI_HCD=y CONFIG_USB_XHCI_DWC3=y CONFIG_USB_DWC3=y diff --git a/include/configs/am65x_evm.h b/include/configs/am65x_evm.h index 5435ef85c7..9ae8c23c62 100644 --- a/include/configs/am65x_evm.h +++ b/include/configs/am65x_evm.h @@ -152,6 +152,8 @@ #define CONFIG_SYS_MMC_ENV_PART 1 #endif
+#define CONFIG_SYS_USB_FAT_BOOT_PARTITION 1 + /* Now for the remaining common defines */ #include <configs/ti_armv7_common.h>

Because of space constraints, create a new USB defconfig for R5 to faciliate booting from USB mass storage devices
Signed-off-by: Faiz Abbas faiz_abbas@ti.com --- configs/am65x_evm_r5_usbmsc_defconfig | 119 ++++++++++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 configs/am65x_evm_r5_usbmsc_defconfig
diff --git a/configs/am65x_evm_r5_usbmsc_defconfig b/configs/am65x_evm_r5_usbmsc_defconfig new file mode 100644 index 0000000000..14682c8d27 --- /dev/null +++ b/configs/am65x_evm_r5_usbmsc_defconfig @@ -0,0 +1,119 @@ +CONFIG_ARM=y +CONFIG_ARCH_K3=y +CONFIG_SPL_GPIO_SUPPORT=y +CONFIG_SPL_LIBCOMMON_SUPPORT=y +CONFIG_SPL_LIBGENERIC_SUPPORT=y +CONFIG_SYS_MALLOC_F_LEN=0x55000 +CONFIG_SOC_K3_AM6=y +CONFIG_K3_EARLY_CONS=y +CONFIG_TARGET_AM654_R5_EVM=y +CONFIG_SPL_SERIAL_SUPPORT=y +CONFIG_SPL_DRIVERS_MISC_SUPPORT=y +CONFIG_ENV_SIZE=0x20000 +CONFIG_SPL_STACK_R_ADDR=0x82000000 +CONFIG_NR_DRAM_BANKS=2 +CONFIG_SPL_FS_FAT=y +CONFIG_SPL_LIBDISK_SUPPORT=y +CONFIG_SPL_TEXT_BASE=0x41c00000 +# CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set +CONFIG_SPL_LOAD_FIT=y +CONFIG_USE_BOOTCOMMAND=y +# CONFIG_DISPLAY_CPUINFO is not set +CONFIG_SPL_STACK_R=y +CONFIG_SPL_SEPARATE_BSS=y +CONFIG_SPL_EARLY_BSS=y +CONFIG_SPL_DMA=y +CONFIG_SPL_ENV_SUPPORT=y +CONFIG_SPL_I2C_SUPPORT=y +CONFIG_SPL_DM_MAILBOX=y +CONFIG_SPL_DM_RESET=y +CONFIG_SPL_POWER_SUPPORT=y +CONFIG_SPL_POWER_DOMAIN=y +CONFIG_SPL_RAM_SUPPORT=y +CONFIG_SPL_RAM_DEVICE=y +CONFIG_SPL_REMOTEPROC=y +CONFIG_SPL_USB_HOST_SUPPORT=y +CONFIG_SPL_USB_STORAGE=y +CONFIG_SPL_USB_GADGET=y +CONFIG_SPL_YMODEM_SUPPORT=y +CONFIG_HUSH_PARSER=y +CONFIG_CMD_BOOTZ=y +CONFIG_CMD_ASKENV=y +CONFIG_CMD_GPT=y +CONFIG_CMD_I2C=y +CONFIG_CMD_REMOTEPROC=y +# CONFIG_CMD_SETEXPR is not set +CONFIG_CMD_TIME=y +CONFIG_CMD_FAT=y +CONFIG_OF_CONTROL=y +CONFIG_SPL_OF_CONTROL=y +CONFIG_DEFAULT_DEVICE_TREE="k3-am654-r5-base-board" +CONFIG_SPL_MULTI_DTB_FIT=y +CONFIG_SPL_MULTI_DTB_FIT_NO_COMPRESSION=y +CONFIG_SYS_RELOC_GD_ENV_ADDR=y +CONFIG_DM=y +CONFIG_SPL_DM=y +CONFIG_SPL_DM_SEQ_ALIAS=y +CONFIG_REGMAP=y +CONFIG_SPL_REGMAP=y +CONFIG_SYSCON=y +CONFIG_SPL_SYSCON=y +CONFIG_SPL_OF_TRANSLATE=y +CONFIG_BLK=y +CONFIG_CLK=y +CONFIG_SPL_CLK=y +CONFIG_CLK_TI_SCI=y +CONFIG_TI_SCI_PROTOCOL=y +CONFIG_DM_GPIO=y +CONFIG_DA8XX_GPIO=y +CONFIG_DM_I2C=y +CONFIG_I2C_SET_DEFAULT_BUS_NUM=y +CONFIG_SYS_I2C_OMAP24XX=y +CONFIG_DM_MAILBOX=y +CONFIG_K3_SEC_PROXY=y +CONFIG_MISC=y +CONFIG_K3_AVS0=y +# CONFIG_MMC is not set +CONFIG_PHY=y +CONFIG_SPL_PHY=y +CONFIG_OMAP_USB2_PHY=y +CONFIG_PINCTRL=y +# CONFIG_PINCTRL_GENERIC is not set +CONFIG_SPL_PINCTRL=y +# CONFIG_SPL_PINCTRL_GENERIC is not set +CONFIG_PINCTRL_SINGLE=y +CONFIG_POWER_DOMAIN=y +CONFIG_TI_SCI_POWER_DOMAIN=y +CONFIG_DM_REGULATOR=y +CONFIG_SPL_DM_REGULATOR=y +CONFIG_DM_REGULATOR_GPIO=y +CONFIG_SPL_DM_REGULATOR_GPIO=y +CONFIG_DM_REGULATOR_TPS62360=y +CONFIG_RAM=y +CONFIG_SPL_RAM=y +CONFIG_K3_SYSTEM_CONTROLLER=y +CONFIG_REMOTEPROC_TI_K3_ARM64=y +CONFIG_DM_RESET=y +CONFIG_RESET_TI_SCI=y +CONFIG_DM_SERIAL=y +CONFIG_SYSRESET=y +CONFIG_SPL_SYSRESET=y +CONFIG_SYSRESET_TI_SCI=y +CONFIG_TIMER=y +CONFIG_SPL_TIMER=y +CONFIG_OMAP_TIMER=y +CONFIG_USB=y +CONFIG_DM_USB=y +CONFIG_DM_USB_GADGET=y +CONFIG_SPL_DM_USB_GADGET=y +CONFIG_USB_XHCI_HCD=y +CONFIG_USB_XHCI_DWC3=y +CONFIG_USB_DWC3=y +CONFIG_USB_DWC3_GENERIC=y +CONFIG_USB_STORAGE=y +CONFIG_USB_GADGET=y +CONFIG_USB_GADGET_MANUFACTURER="Texas Instruments" +CONFIG_USB_GADGET_VENDOR_NUM=0x0451 +CONFIG_USB_GADGET_PRODUCT_NUM=0x6162 +CONFIG_USB_GADGET_DOWNLOAD=y +CONFIG_FS_FAT_MAX_CLUSTSIZE=16384

Because of space constraints, create a new USB defconfig for R5 to faciliate booting in USB peripheral (DFU) bootmode
Signed-off-by: Faiz Abbas faiz_abbas@ti.com --- configs/am65x_evm_r5_usbdfu_defconfig | 119 ++++++++++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 configs/am65x_evm_r5_usbdfu_defconfig
diff --git a/configs/am65x_evm_r5_usbdfu_defconfig b/configs/am65x_evm_r5_usbdfu_defconfig new file mode 100644 index 0000000000..2dd671e562 --- /dev/null +++ b/configs/am65x_evm_r5_usbdfu_defconfig @@ -0,0 +1,119 @@ +CONFIG_ARM=y +CONFIG_ARCH_K3=y +CONFIG_SPL_GPIO_SUPPORT=y +CONFIG_SPL_LIBCOMMON_SUPPORT=y +CONFIG_SPL_LIBGENERIC_SUPPORT=y +CONFIG_SYS_MALLOC_F_LEN=0x55000 +CONFIG_SOC_K3_AM6=y +CONFIG_K3_EARLY_CONS=y +CONFIG_TARGET_AM654_R5_EVM=y +CONFIG_ENV_SIZE=0x20000 +CONFIG_DM_GPIO=y +CONFIG_SPL_TEXT_BASE=0x41c00000 +CONFIG_SPL_SERIAL_SUPPORT=y +CONFIG_SPL_DRIVERS_MISC_SUPPORT=y +CONFIG_SPL_STACK_R_ADDR=0x82000000 +CONFIG_NR_DRAM_BANKS=2 +CONFIG_SPL_FS_FAT=y +CONFIG_SPL_LIBDISK_SUPPORT=y +# CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set +CONFIG_SPL_LOAD_FIT=y +CONFIG_USE_BOOTCOMMAND=y +# CONFIG_DISPLAY_CPUINFO is not set +CONFIG_SPL_STACK_R=y +CONFIG_SPL_SEPARATE_BSS=y +CONFIG_SPL_EARLY_BSS=y +CONFIG_SPL_DMA=y +CONFIG_SPL_ENV_SUPPORT=y +CONFIG_SPL_I2C_SUPPORT=y +CONFIG_SPL_DM_MAILBOX=y +CONFIG_SPL_DM_RESET=y +CONFIG_SPL_POWER_SUPPORT=y +CONFIG_SPL_POWER_DOMAIN=y +CONFIG_SPL_RAM_SUPPORT=y +CONFIG_SPL_RAM_DEVICE=y +CONFIG_SPL_REMOTEPROC=y +CONFIG_SPL_USB_GADGET=y +CONFIG_SPL_DFU=y +CONFIG_SPL_YMODEM_SUPPORT=y +CONFIG_HUSH_PARSER=y +CONFIG_CMD_BOOTZ=y +CONFIG_CMD_ASKENV=y +CONFIG_CMD_DFU=y +CONFIG_CMD_GPT=y +CONFIG_CMD_I2C=y +CONFIG_CMD_REMOTEPROC=y +# CONFIG_CMD_SETEXPR is not set +CONFIG_CMD_TIME=y +CONFIG_CMD_FAT=y +CONFIG_OF_CONTROL=y +CONFIG_SPL_OF_CONTROL=y +CONFIG_DEFAULT_DEVICE_TREE="k3-am654-r5-base-board" +CONFIG_SPL_MULTI_DTB_FIT=y +CONFIG_SPL_MULTI_DTB_FIT_NO_COMPRESSION=y +CONFIG_SYS_RELOC_GD_ENV_ADDR=y +CONFIG_DM=y +CONFIG_SPL_DM=y +CONFIG_SPL_DM_SEQ_ALIAS=y +CONFIG_REGMAP=y +CONFIG_SPL_REGMAP=y +CONFIG_SYSCON=y +CONFIG_SPL_SYSCON=y +CONFIG_SPL_OF_TRANSLATE=y +CONFIG_BLK=y +CONFIG_CLK=y +CONFIG_SPL_CLK=y +CONFIG_CLK_TI_SCI=y +CONFIG_TI_SCI_PROTOCOL=y +CONFIG_DA8XX_GPIO=y +CONFIG_DM_I2C=y +CONFIG_I2C_SET_DEFAULT_BUS_NUM=y +CONFIG_SYS_I2C_OMAP24XX=y +CONFIG_DM_MAILBOX=y +CONFIG_K3_SEC_PROXY=y +CONFIG_MISC=y +CONFIG_K3_AVS0=y +# CONFIG_MMC is not set +CONFIG_PHY=y +CONFIG_SPL_PHY=y +CONFIG_OMAP_USB2_PHY=y +CONFIG_PINCTRL=y +# CONFIG_PINCTRL_GENERIC is not set +CONFIG_SPL_PINCTRL=y +# CONFIG_SPL_PINCTRL_GENERIC is not set +CONFIG_PINCTRL_SINGLE=y +CONFIG_POWER_DOMAIN=y +CONFIG_TI_SCI_POWER_DOMAIN=y +CONFIG_DM_REGULATOR=y +CONFIG_SPL_DM_REGULATOR=y +CONFIG_DM_REGULATOR_GPIO=y +CONFIG_SPL_DM_REGULATOR_GPIO=y +CONFIG_DM_REGULATOR_TPS62360=y +CONFIG_RAM=y +CONFIG_SPL_RAM=y +CONFIG_K3_SYSTEM_CONTROLLER=y +CONFIG_REMOTEPROC_TI_K3_ARM64=y +CONFIG_DM_RESET=y +CONFIG_RESET_TI_SCI=y +CONFIG_DM_SERIAL=y +CONFIG_SYSRESET=y +CONFIG_SPL_SYSRESET=y +CONFIG_SYSRESET_TI_SCI=y +CONFIG_TIMER=y +CONFIG_SPL_TIMER=y +CONFIG_OMAP_TIMER=y +CONFIG_USB=y +CONFIG_DM_USB=y +CONFIG_DM_USB_GADGET=y +CONFIG_SPL_DM_USB_GADGET=y +CONFIG_USB_XHCI_HCD=y +CONFIG_USB_XHCI_DWC3=y +CONFIG_USB_DWC3=y +CONFIG_USB_DWC3_GENERIC=y +CONFIG_USB_STORAGE=y +CONFIG_USB_GADGET=y +CONFIG_USB_GADGET_MANUFACTURER="Texas Instruments" +CONFIG_USB_GADGET_VENDOR_NUM=0x0451 +CONFIG_USB_GADGET_PRODUCT_NUM=0x6162 +CONFIG_USB_GADGET_DOWNLOAD=y +CONFIG_FS_FAT_MAX_CLUSTSIZE=16384
participants (3)
-
Faiz Abbas
-
Lokesh Vutla
-
Vignesh Raghavendra