aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAswath Govindraju <a-govindraju@ti.com>2021-06-04 22:00:33 +0530
committerLokesh Vutla <lokeshvutla@ti.com>2021-06-09 22:23:44 +0530
commit669a03e0ff8bc4c69c848769806125c7ebb5782e (patch)
tree81a334aadddc56809663ef5a9bbbc17b6636173c
parent3ae127c4e20649da19fbe7653b0f8fd726ccfcda (diff)
downloadu-boot-669a03e0ff8bc4c69c848769806125c7ebb5782e.zip
u-boot-669a03e0ff8bc4c69c848769806125c7ebb5782e.tar.gz
u-boot-669a03e0ff8bc4c69c848769806125c7ebb5782e.tar.bz2
arm: mach-k3: am642_init: Do USB fixups to facilitate host and device boot modes
U-Boot either supports USB host or device mode for a node at a time in the device tree nodes. To support both host and dfu bootmodes, dr_mode is set to "peripheral" by default and then fixed based on the mode selected by the boot mode config dip switches on the board. This needs to happen before the cdns3 generic layer binds the usb device to a host or a device driver. Therefore, use fdtdec_setup_board() implementation to fixup the device tree property. Signed-off-by: Aswath Govindraju <a-govindraju@ti.com> Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com> Link: https://lore.kernel.org/r/20210604163043.12811-4-a-govindraju@ti.com
-rw-r--r--arch/arm/mach-k3/am642_init.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/arch/arm/mach-k3/am642_init.c b/arch/arm/mach-k3/am642_init.c
index 1a2bc4b..579dbac 100644
--- a/arch/arm/mach-k3/am642_init.c
+++ b/arch/arm/mach-k3/am642_init.c
@@ -8,6 +8,7 @@
*/
#include <common.h>
+#include <fdt_support.h>
#include <spl.h>
#include <asm/io.h>
#include <asm/arch/hardware.h>
@@ -106,6 +107,38 @@ void do_dt_magic(void)
}
#endif
+#if CONFIG_IS_ENABLED(USB_STORAGE)
+static int fixup_usb_boot(const void *fdt_blob)
+{
+ int ret = 0;
+
+ switch (spl_boot_device()) {
+ case BOOT_DEVICE_USB:
+ /*
+ * If the boot mode is host, fixup the dr_mode to host
+ * before cdns3 bind takes place
+ */
+ ret = fdt_find_and_setprop((void *)fdt_blob,
+ "/bus@f4000/cdns-usb@f900000/usb@f400000",
+ "dr_mode", "host", 5, 0);
+ if (ret)
+ printf("%s: fdt_find_and_setprop() failed:%d\n",
+ __func__, ret);
+ fallthrough;
+ default:
+ break;
+ }
+
+ return ret;
+}
+
+int fdtdec_board_setup(const void *fdt_blob)
+{
+ /* Can use the pointer from the function parameters */
+ return fixup_usb_boot(fdt_blob);
+}
+#endif
+
void board_init_f(ulong dummy)
{
#if defined(CONFIG_K3_LOAD_SYSFW)