diff options
author | Tom Rini <trini@konsulko.com> | 2016-10-01 04:58:44 +0300 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2016-10-01 04:58:44 +0300 |
commit | fe4ba689a0cb2bb2ceafb88556a57bd80814b648 (patch) | |
tree | 1012656ba1d3e9f8288d69de33c71417b2f22466 | |
parent | f413d1cae89143ad45b066b3d3bc602deafcb50a (diff) | |
parent | 4c043712e9910ef1d612aedbd8304a1f7348ef5f (diff) | |
download | u-boot-fe4ba689a0cb2bb2ceafb88556a57bd80814b648.tar.xz |
Merge branch 'master' of git://git.denx.de/u-boot-usb
Signed-off-by: Tom Rini <trini@konsulko.com>
Conflicts:
include/configs/dra7xx_evm.h
62 files changed, 574 insertions, 156 deletions
@@ -291,6 +291,33 @@ config FIT_IMAGE_POST_PROCESS injected into the FIT creation (i.e. the blobs would have been pre- processed before being added to the FIT image). +config SPL_DFU_SUPPORT + bool "Enable SPL with DFU to load binaries to memory device" + depends on USB + help + Currently the SPL does not have capability to load the + binaries or boot images to boot devices like ram,eMMC,SPI,etc. + This feature enables the DFU (Device Firmware Upgarde) in SPL with + RAM memory device support. The ROM code will load and execute + the SPL built with dfu. The user can load binaries (u-boot/kernel) to + selected device partition from host-pc using dfu-utils. + This feature will be useful to flash the binaries to factory + or bare-metal boards using USB interface. + +choice + bool "DFU device selection" + depends on SPL_DFU_SUPPORT + +config SPL_DFU_RAM + bool "RAM device" + depends on SPL_DFU_SUPPORT + help + select RAM/DDR memory device for loading binary images + (u-boot/kernel) to the selected device partition using + DFU and execute the u-boot/kernel from RAM. + +endchoice + config SYS_CLK_FREQ depends on ARC || ARCH_SUNXI int "CPU clock frequency" diff --git a/arch/arm/cpu/armv7/omap-common/boot-common.c b/arch/arm/cpu/armv7/omap-common/boot-common.c index 60c367a202..385310ba1e 100644 --- a/arch/arm/cpu/armv7/omap-common/boot-common.c +++ b/arch/arm/cpu/armv7/omap-common/boot-common.c @@ -91,6 +91,11 @@ void save_omap_boot_params(void) sys_boot_device = 1; break; #endif +#if defined(BOOT_DEVICE_DFU) && !defined(CONFIG_SPL_DFU_SUPPORT) + case BOOT_DEVICE_DFU: + sys_boot_device = 1; + break; +#endif } if (sys_boot_device) { diff --git a/arch/arm/dts/vf-colibri.dtsi b/arch/arm/dts/vf-colibri.dtsi index dc52748c09..c2f104a89b 100644 --- a/arch/arm/dts/vf-colibri.dtsi +++ b/arch/arm/dts/vf-colibri.dtsi @@ -21,6 +21,17 @@ }; }; +&ehci0 { + dr_mode = "otg"; + fsl,cdet-gpio = <&gpio3 6 GPIO_ACTIVE_HIGH>; + status = "okay"; +}; + +&ehci1 { + dr_mode = "host"; + status = "okay"; +}; + &uart0 { status = "okay"; }; diff --git a/arch/arm/dts/vf.dtsi b/arch/arm/dts/vf.dtsi index 1530d2fc87..d7d21a37ad 100644 --- a/arch/arm/dts/vf.dtsi +++ b/arch/arm/dts/vf.dtsi @@ -4,6 +4,7 @@ * SPDX-License-Identifier: GPL-2.0+ or X11 */ /include/ "skeleton.dtsi" +#include <dt-bindings/gpio/gpio.h> / { aliases { @@ -20,6 +21,8 @@ serial5 = &uart5; spi0 = &dspi0; spi1 = &dspi1; + ehci0 = &ehci0; + ehci1 = &ehci1; }; soc { @@ -113,6 +116,12 @@ reg = <0x400ff100 0x40>; #gpio-cells = <2>; }; + + ehci0: ehci@40034000 { + compatible = "fsl,vf610-usb"; + reg = <0x40034000 0x800>; + status = "disabled"; + }; }; aips1: aips-bus@40080000 { @@ -133,6 +142,11 @@ status = "disabled"; }; + ehci1: ehci@400b4000 { + compatible = "fsl,vf610-usb"; + reg = <0x400b4000 0x800>; + status = "disabled"; + }; }; }; }; diff --git a/arch/arm/include/asm/arch-omap5/spl.h b/arch/arm/include/asm/arch-omap5/spl.h index 468ff5afd5..3582880424 100644 --- a/arch/arm/include/asm/arch-omap5/spl.h +++ b/arch/arm/include/asm/arch-omap5/spl.h @@ -20,7 +20,7 @@ #define BOOT_DEVICE_QSPI_1 0x0A #define BOOT_DEVICE_QSPI_4 0x0B #define BOOT_DEVICE_UART 0x43 -#define BOOT_DEVICE_USB 0x45 +#define BOOT_DEVICE_DFU 0x45 #define MMC_BOOT_DEVICES_START BOOT_DEVICE_MMC1 #define MMC_BOOT_DEVICES_END BOOT_DEVICE_MMC2_2 diff --git a/board/Arcturus/ucp1020/ucp1020.c b/board/Arcturus/ucp1020/ucp1020.c index 0fc2bac55d..0d086e87fa 100644 --- a/board/Arcturus/ucp1020/ucp1020.c +++ b/board/Arcturus/ucp1020/ucp1020.c @@ -315,7 +315,7 @@ int ft_board_setup(void *blob, bd_t *bd) FT_FSL_PCI_SETUP; #if defined(CONFIG_HAS_FSL_DR_USB) - fdt_fixup_dr_usb(blob, bd); + fsl_fdt_fixup_dr_usb(blob, bd); #endif #if defined(CONFIG_SDCARD) || defined(CONFIG_SPIFLASH) diff --git a/board/freescale/b4860qds/b4860qds.c b/board/freescale/b4860qds/b4860qds.c index 1642a7d1ae..c2ceb8014e 100644 --- a/board/freescale/b4860qds/b4860qds.c +++ b/board/freescale/b4860qds/b4860qds.c @@ -1209,7 +1209,7 @@ int ft_board_setup(void *blob, bd_t *bd) fdt_fixup_liodn(blob); #ifdef CONFIG_HAS_FSL_DR_USB - fdt_fixup_dr_usb(blob, bd); + fsl_fdt_fixup_dr_usb(blob, bd); #endif #ifdef CONFIG_SYS_DPAA_FMAN diff --git a/board/freescale/bsc9131rdb/bsc9131rdb.c b/board/freescale/bsc9131rdb/bsc9131rdb.c index 75e114217b..fb8bb39d87 100644 --- a/board/freescale/bsc9131rdb/bsc9131rdb.c +++ b/board/freescale/bsc9131rdb/bsc9131rdb.c @@ -73,7 +73,7 @@ int ft_board_setup(void *blob, bd_t *bd) fdt_fixup_mtdparts(blob, nodes, ARRAY_SIZE(nodes)); #endif - fdt_fixup_dr_usb(blob, bd); + fsl_fdt_fixup_dr_usb(blob, bd); return 0; } diff --git a/board/freescale/bsc9132qds/bsc9132qds.c b/board/freescale/bsc9132qds/bsc9132qds.c index 71a7bb55c4..2c836da63b 100644 --- a/board/freescale/bsc9132qds/bsc9132qds.c +++ b/board/freescale/bsc9132qds/bsc9132qds.c @@ -394,7 +394,7 @@ int ft_board_setup(void *blob, bd_t *bd) /* remove dts usb node */ fdt_del_node_compat(blob, "fsl-usb2-dr"); } else { - fdt_fixup_dr_usb(blob, bd); + fsl_fdt_fixup_dr_usb(blob, bd); fdt_del_node_and_alias(blob, "serial2"); } } diff --git a/board/freescale/corenet_ds/corenet_ds.c b/board/freescale/corenet_ds/corenet_ds.c index f41985d2f6..8a44a9a972 100644 --- a/board/freescale/corenet_ds/corenet_ds.c +++ b/board/freescale/corenet_ds/corenet_ds.c @@ -201,7 +201,7 @@ int ft_board_setup(void *blob, bd_t *bd) #endif fdt_fixup_liodn(blob); - fdt_fixup_dr_usb(blob, bd); + fsl_fdt_fixup_dr_usb(blob, bd); #ifdef CONFIG_SYS_DPAA_FMAN fdt_fixup_fman_ethernet(blob); diff --git a/board/freescale/ls2080aqds/ls2080aqds.c b/board/freescale/ls2080aqds/ls2080aqds.c index ca4a2e5cb7..d07ca18af9 100644 --- a/board/freescale/ls2080aqds/ls2080aqds.c +++ b/board/freescale/ls2080aqds/ls2080aqds.c @@ -313,7 +313,7 @@ int ft_board_setup(void *blob, bd_t *bd) fdt_fixup_memory_banks(blob, base, size, 2); - fdt_fixup_dr_usb(blob, bd); + fsl_fdt_fixup_dr_usb(blob, bd); #ifdef CONFIG_FSL_MC_ENET fdt_fixup_board_enet(blob); diff --git a/board/freescale/ls2080ardb/ls2080ardb.c b/board/freescale/ls2080ardb/ls2080ardb.c index 7d8a7115dc..83d9e7ec12 100644 --- a/board/freescale/ls2080ardb/ls2080ardb.c +++ b/board/freescale/ls2080ardb/ls2080ardb.c @@ -277,7 +277,7 @@ int ft_board_setup(void *blob, bd_t *bd) fdt_fixup_memory_banks(blob, base, size, 2); - fdt_fixup_dr_usb(blob, bd); + fsl_fdt_fixup_dr_usb(blob, bd); #ifdef CONFIG_FSL_MC_ENET fdt_fixup_board_enet(blob); diff --git a/board/freescale/mpc8308rdb/mpc8308rdb.c b/board/freescale/mpc8308rdb/mpc8308rdb.c index 93e1c50f39..b4a0dd5d1a 100644 --- a/board/freescale/mpc8308rdb/mpc8308rdb.c +++ b/board/freescale/mpc8308rdb/mpc8308rdb.c @@ -164,7 +164,7 @@ int misc_init_r(void) int ft_board_setup(void *blob, bd_t *bd) { ft_cpu_setup(blob, bd); - fdt_fixup_dr_usb(blob, bd); + fsl_fdt_fixup_dr_usb(blob, bd); fdt_fixup_esdhc(blob, bd); return 0; diff --git a/board/freescale/mpc8315erdb/mpc8315erdb.c b/board/freescale/mpc8315erdb/mpc8315erdb.c index ed611c56c3..3cec09b586 100644 --- a/board/freescale/mpc8315erdb/mpc8315erdb.c +++ b/board/freescale/mpc8315erdb/mpc8315erdb.c @@ -194,7 +194,7 @@ int ft_board_setup(void *blob, bd_t *bd) #ifdef CONFIG_PCI ft_pci_setup(blob, bd); #endif - fdt_fixup_dr_usb(blob, bd); + fsl_fdt_fixup_dr_usb(blob, bd); fdt_tsec1_fixup(blob, bd); return 0; diff --git a/board/freescale/mpc837xemds/mpc837xemds.c b/board/freescale/mpc837xemds/mpc837xemds.c index 572913c7ac..045841d57b 100644 --- a/board/freescale/mpc837xemds/mpc837xemds.c +++ b/board/freescale/mpc837xemds/mpc837xemds.c @@ -332,7 +332,7 @@ int ft_board_setup(void *blob, bd_t *bd) { ft_cpu_setup(blob, bd); ft_tsec_fixup(blob, bd); - fdt_fixup_dr_usb(blob, bd); + fsl_fdt_fixup_dr_usb(blob, bd); fdt_fixup_esdhc(blob, bd); #ifdef CONFIG_PCI ft_pci_setup(blob, bd); diff --git a/board/freescale/mpc837xerdb/mpc837xerdb.c b/board/freescale/mpc837xerdb/mpc837xerdb.c index 565f815781..07c0599858 100644 --- a/board/freescale/mpc837xerdb/mpc837xerdb.c +++ b/board/freescale/mpc837xerdb/mpc837xerdb.c @@ -210,7 +210,7 @@ int ft_board_setup(void *blob, bd_t *bd) ft_pci_setup(blob, bd); #endif ft_cpu_setup(blob, bd); - fdt_fixup_dr_usb(blob, bd); + fsl_fdt_fixup_dr_usb(blob, bd); fdt_fixup_esdhc(blob, bd); return 0; diff --git a/board/freescale/mpc8536ds/mpc8536ds.c b/board/freescale/mpc8536ds/mpc8536ds.c index 7b0f461971..cede1da634 100644 --- a/board/freescale/mpc8536ds/mpc8536ds.c +++ b/board/freescale/mpc8536ds/mpc8536ds.c @@ -282,7 +282,7 @@ int ft_board_setup(void *blob, bd_t *bd) #endif #ifdef CONFIG_HAS_FSL_MPH_USB - fdt_fixup_dr_usb(blob, bd); + fsl_fdt_fixup_dr_usb(blob, bd); #endif return 0; diff --git a/board/freescale/p1010rdb/p1010rdb.c b/board/freescale/p1010rdb/p1010rdb.c index 1ae15407db..8eecb0647b 100644 --- a/board/freescale/p1010rdb/p1010rdb.c +++ b/board/freescale/p1010rdb/p1010rdb.c @@ -463,7 +463,7 @@ int ft_board_setup(void *blob, bd_t *bd) fdt_fixup_memory(blob, (u64)base, (u64)size); #if defined(CONFIG_HAS_FSL_DR_USB) - fdt_fixup_dr_usb(blob, bd); + fsl_fdt_fixup_dr_usb(blob, bd); #endif /* P1014 and it's derivatives don't support CAN and eTSEC3 */ diff --git a/board/freescale/p1022ds/p1022ds.c b/board/freescale/p1022ds/p1022ds.c index d7dd478dff..345feac0b2 100644 --- a/board/freescale/p1022ds/p1022ds.c +++ b/board/freescale/p1022ds/p1022ds.c @@ -345,7 +345,7 @@ int ft_board_setup(void *blob, bd_t *bd) fdt_fixup_memory(blob, (u64)base, (u64)size); #ifdef CONFIG_HAS_FSL_DR_USB - fdt_fixup_dr_usb(blob, bd); + fsl_fdt_fixup_dr_usb(blob, bd); #endif FT_FSL_PCI_SETUP; diff --git a/board/freescale/p1023rdb/p1023rdb.c b/board/freescale/p1023rdb/p1023rdb.c index 074b71326f..0451722603 100644 --- a/board/freescale/p1023rdb/p1023rdb.c +++ b/board/freescale/p1023rdb/p1023rdb.c @@ -143,7 +143,7 @@ int ft_board_setup(void *blob, bd_t *bd) fdt_fixup_memory(blob, (u64)base, (u64)size); #ifdef CONFIG_HAS_FSL_DR_USB - fdt_fixup_dr_usb(blob, bd); + fsl_fdt_fixup_dr_usb(blob, bd); #endif fdt_fixup_fman_ethernet(blob); diff --git a/board/freescale/p1_p2_rdb_pc/p1_p2_rdb_pc.c b/board/freescale/p1_p2_rdb_pc/p1_p2_rdb_pc.c index 61b7a91333..d61c3a5413 100644 --- a/board/freescale/p1_p2_rdb_pc/p1_p2_rdb_pc.c +++ b/board/freescale/p1_p2_rdb_pc/p1_p2_rdb_pc.c @@ -454,7 +454,7 @@ int ft_board_setup(void *blob, bd_t *bd) #endif #if defined(CONFIG_HAS_FSL_DR_USB) - fdt_fixup_dr_usb(blob, bd); + fsl_fdt_fixup_dr_usb(blob, bd); #endif #if defined(CONFIG_SDCARD) || defined(CONFIG_SPIFLASH) diff --git a/board/freescale/p1_twr/p1_twr.c b/board/freescale/p1_twr/p1_twr.c index a40bea328b..f54a6ff8dc 100644 --- a/board/freescale/p1_twr/p1_twr.c +++ b/board/freescale/p1_twr/p1_twr.c @@ -282,7 +282,7 @@ int ft_board_setup(void *blob, bd_t *bd) #if defined(CONFIG_TWR_P1025) fdt_board_fixup_qe_pins(blob); #endif - fdt_fixup_dr_usb(blob, bd); + fsl_fdt_fixup_dr_usb(blob, bd); return 0; } diff --git a/board/freescale/p2041rdb/p2041rdb.c b/board/freescale/p2041rdb/p2041rdb.c index c6a724217f..21fb66f184 100644 --- a/board/freescale/p2041rdb/p2041rdb.c +++ b/board/freescale/p2041rdb/p2041rdb.c @@ -225,7 +225,7 @@ int ft_board_setup(void *blob, bd_t *bd) fdt_fixup_memory(blob, (u64)base, (u64)size); #if defined(CONFIG_HAS_FSL_DR_USB) || defined(CONFIG_HAS_FSL_MPH_USB) - fdt_fixup_dr_usb(blob, bd); + fsl_fdt_fixup_dr_usb(blob, bd); #endif #ifdef CONFIG_PCI diff --git a/board/freescale/t102xqds/t102xqds.c b/board/freescale/t102xqds/t102xqds.c index 76793a1186..1affa0b3a8 100644 --- a/board/freescale/t102xqds/t102xqds.c +++ b/board/freescale/t102xqds/t102xqds.c @@ -375,7 +375,7 @@ int ft_board_setup(void *blob, bd_t *bd) fdt_fixup_liodn(blob); #ifdef CONFIG_HAS_FSL_DR_USB - fdt_fixup_dr_usb(blob, bd); + fsl_fdt_fixup_dr_usb(blob, bd); #endif #ifdef CONFIG_SYS_DPAA_FMAN diff --git a/board/freescale/t102xrdb/t102xrdb.c b/board/freescale/t102xrdb/t102xrdb.c index 01dbf381bd..24df4b440f 100644 --- a/board/freescale/t102xrdb/t102xrdb.c +++ b/board/freescale/t102xrdb/t102xrdb.c @@ -189,7 +189,7 @@ int ft_board_setup(void *blob, bd_t *bd) #endif fdt_fixup_liodn(blob); - fdt_fixup_dr_usb(blob, bd); + fsl_fdt_fixup_dr_usb(blob, bd); #ifdef CONFIG_SYS_DPAA_FMAN fdt_fixup_fman_ethernet(blob); diff --git a/board/freescale/t1040qds/t1040qds.c b/board/freescale/t1040qds/t1040qds.c index d7d56b47c8..5466fbf5f6 100644 --- a/board/freescale/t1040qds/t1040qds.c +++ b/board/freescale/t1040qds/t1040qds.c @@ -257,7 +257,7 @@ int ft_board_setup(void *blob, bd_t *bd) fdt_fixup_liodn(blob); #ifdef CONFIG_HAS_FSL_DR_USB - fdt_fixup_dr_usb(blob, bd); + fsl_fdt_fixup_dr_usb(blob, bd); #endif #ifdef CONFIG_SYS_DPAA_FMAN diff --git a/board/freescale/t104xrdb/t104xrdb.c b/board/freescale/t104xrdb/t104xrdb.c index ec97677df8..6bad6a4540 100644 --- a/board/freescale/t104xrdb/t104xrdb.c +++ b/board/freescale/t104xrdb/t104xrdb.c @@ -144,7 +144,7 @@ int ft_board_setup(void *blob, bd_t *bd) fdt_fixup_liodn(blob); #ifdef CONFIG_HAS_FSL_DR_USB - fdt_fixup_dr_usb(blob, bd); + fsl_fdt_fixup_dr_usb(blob, bd); #endif #ifdef CONFIG_SYS_DPAA_FMAN diff --git a/board/freescale/t208xqds/t208xqds.c b/board/freescale/t208xqds/t208xqds.c index bfea3a1556..d016329cd1 100644 --- a/board/freescale/t208xqds/t208xqds.c +++ b/board/freescale/t208xqds/t208xqds.c @@ -461,7 +461,7 @@ int ft_board_setup(void *blob, bd_t *bd) #endif fdt_fixup_liodn(blob); - fdt_fixup_dr_usb(blob, bd); + fsl_fdt_fixup_dr_usb(blob, bd); #ifdef CONFIG_SYS_DPAA_FMAN fdt_fixup_fman_ethernet(blob); diff --git a/board/freescale/t208xrdb/t208xrdb.c b/board/freescale/t208xrdb/t208xrdb.c index 0cb05aa03f..1ab05ec9fd 100644 --- a/board/freescale/t208xrdb/t208xrdb.c +++ b/board/freescale/t208xrdb/t208xrdb.c @@ -128,7 +128,7 @@ int ft_board_setup(void *blob, bd_t *bd) #endif fdt_fixup_liodn(blob); - fdt_fixup_dr_usb(blob, bd); + fsl_fdt_fixup_dr_usb(blob, bd); #ifdef CONFIG_SYS_DPAA_FMAN fdt_fixup_fman_ethernet(blob); diff --git a/board/freescale/t4qds/t4240emu.c b/board/freescale/t4qds/t4240emu.c index f1393f25f9..35ad19e045 100644 --- a/board/freescale/t4qds/t4240emu.c +++ b/board/freescale/t4qds/t4240emu.c @@ -76,7 +76,7 @@ int ft_board_setup(void *blob, bd_t *bd) fdt_fixup_memory(blob, (u64)base, (u64)size); fdt_fixup_liodn(blob); - fdt_fixup_dr_usb(blob, bd); + fsl_fdt_fixup_dr_usb(blob, bd); return 0; } diff --git a/board/freescale/t4qds/t4240qds.c b/board/freescale/t4qds/t4240qds.c index d6df144730..8f9e7e8255 100644 --- a/board/freescale/t4qds/t4240qds.c +++ b/board/freescale/t4qds/t4240qds.c @@ -694,7 +694,7 @@ int ft_board_setup(void *blob, bd_t *bd) #endif fdt_fixup_liodn(blob); - fdt_fixup_dr_usb(blob, bd); + fsl_fdt_fixup_dr_usb(blob, bd); #ifdef CONFIG_SYS_DPAA_FMAN fdt_fixup_fman_ethernet(blob); diff --git a/board/freescale/t4rdb/t4240rdb.c b/board/freescale/t4rdb/t4240rdb.c index 406fb132ae..bdd6f4ef49 100644 --- a/board/freescale/t4rdb/t4240rdb.c +++ b/board/freescale/t4rdb/t4240rdb.c @@ -107,7 +107,7 @@ int ft_board_setup(void *blob, bd_t *bd) #endif fdt_fixup_liodn(blob); - fdt_fixup_dr_usb(blob, bd); + fsl_fdt_fixup_dr_usb(blob, bd); #ifdef CONFIG_SYS_DPAA_FMAN fdt_fixup_fman_ethernet(blob); diff --git a/board/gdsys/mpc8308/hrcon.c b/board/gdsys/mpc8308/hrcon.c index f55893f79c..c6566e9196 100644 --- a/board/gdsys/mpc8308/hrcon.c +++ b/board/gdsys/mpc8308/hrcon.c @@ -358,7 +358,7 @@ ulong board_flash_get_legacy(ulong base, int banknum, flash_info_t *info) int ft_board_setup(void *blob, bd_t *bd) { ft_cpu_setup(blob, bd); - fdt_fixup_dr_usb(blob, bd); + fsl_fdt_fixup_dr_usb(blob, bd); fdt_fixup_esdhc(blob, bd); return 0; diff --git a/board/gdsys/mpc8308/strider.c b/board/gdsys/mpc8308/strider.c index b8dde5f1ba..34e9d1956e 100644 --- a/board/gdsys/mpc8308/strider.c +++ b/board/gdsys/mpc8308/strider.c @@ -413,7 +413,7 @@ ulong board_flash_get_legacy(ulong base, int banknum, flash_info_t *info) int ft_board_setup(void *blob, bd_t *bd) { ft_cpu_setup(blob, bd); - fdt_fixup_dr_usb(blob, bd); + fsl_fdt_fixup_dr_usb(blob, bd); fdt_fixup_esdhc(blob, bd); return 0; diff --git a/board/gdsys/p1022/controlcenterd.c b/board/gdsys/p1022/controlcenterd.c index 2f98e4757f..01064dcfde 100644 --- a/board/gdsys/p1022/controlcenterd.c +++ b/board/gdsys/p1022/controlcenterd.c @@ -341,7 +341,7 @@ int ft_board_setup(void *blob, bd_t *bd) fdt_fixup_memory(blob, (u64)base, (u64)size); #ifdef CONFIG_HAS_FSL_DR_USB - fdt_fixup_dr_usb(blob, bd); + fsl_fdt_fixup_dr_usb(blob, bd); #endif FT_FSL_PCI_SETUP; diff --git a/board/keymile/kmp204x/kmp204x.c b/board/keymile/kmp204x/kmp204x.c index eebb47fc21..abb20196c5 100644 --- a/board/keymile/kmp204x/kmp204x.c +++ b/board/keymile/kmp204x/kmp204x.c @@ -277,7 +277,7 @@ int ft_board_setup(void *blob, bd_t *bd) fdt_fixup_memory(blob, (u64)base, (u64)size); #if defined(CONFIG_HAS_FSL_DR_USB) || defined(CONFIG_HAS_FSL_MPH_USB) - fdt_fixup_dr_usb(blob, bd); + fsl_fdt_fixup_dr_usb(blob, bd); #endif #ifdef CONFIG_PCI diff --git a/board/mpc8308_p1m/mpc8308_p1m.c b/board/mpc8308_p1m/mpc8308_p1m.c index 688cc12a6c..234a387801 100644 --- a/board/mpc8308_p1m/mpc8308_p1m.c +++ b/board/mpc8308_p1m/mpc8308_p1m.c @@ -65,7 +65,7 @@ void pci_init_board(void) int ft_board_setup(void *blob, bd_t *bd) { ft_cpu_setup(blob, bd); - fdt_fixup_dr_usb(blob, bd); + fsl_fdt_fixup_dr_usb(blob, bd); return 0; } diff --git a/board/varisys/cyrus/cyrus.c b/board/varisys/cyrus/cyrus.c index 79c363cf84..74f4473877 100644 --- a/board/varisys/cyrus/cyrus.c +++ b/board/varisys/cyrus/cyrus.c @@ -97,7 +97,7 @@ int ft_board_setup(void *blob, bd_t *bd) #endif fdt_fixup_liodn(blob); - fdt_fixup_dr_usb(blob, bd); + fsl_fdt_fixup_dr_usb(blob, bd); #ifdef CONFIG_SYS_DPAA_FMAN fdt_fixup_fman_ethernet(blob); @@ -21,7 +21,6 @@ static int do_dfu(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { - bool dfu_reset = false; if (argc < 4) return CMD_RET_USAGE; @@ -30,7 +29,7 @@ static int do_dfu(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) char *interface = argv[2]; char *devstring = argv[3]; - int ret, i = 0; + int ret; #ifdef CONFIG_DFU_TFTP unsigned long addr = 0; if (!strcmp(argv[1], "tftp")) { @@ -52,67 +51,11 @@ static int do_dfu(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) } int controller_index = simple_strtoul(usb_controller, NULL, 0); - board_usb_init(controller_index, USB_INIT_DEVICE); - g_dnl_clear_detach(); - g_dnl_register("usb_dnl_dfu"); - while (1) { - if (g_dnl_detach()) { - /* - * Check if USB bus reset is performed after detach, - * which indicates that -R switch has been passed to - * dfu-util. In this case reboot the device - */ - if (dfu_usb_get_reset()) { - dfu_reset = true; - goto exit; - } - /* - * This extra number of usb_gadget_handle_interrupts() - * calls is necessary to assure correct transmission - * completion with dfu-util - */ - if (++i == 10000) - goto exit; - } + run_usb_dnl_gadget(controller_index, "usb_dnl_dfu"); - if (ctrlc()) - goto exit; - - if (dfu_get_defer_flush()) { - /* - * Call to usb_gadget_handle_interrupts() is necessary - * to act on ZLP OUT transaction from HOST PC after - * transmitting the whole file. - * - * If this ZLP OUT packet is NAK'ed, the HOST libusb - * function fails after timeout (by default it is set to - * 5 seconds). In such situation the dfu-util program - * exits with error message. - */ - usb_gadget_handle_interrupts(controller_index); - ret = dfu_flush(dfu_get_defer_flush(), NULL, 0, 0); - dfu_set_defer_flush(NULL); - if (ret) { - error("Deferred dfu_flush() failed!"); - goto exit; - } - } - - WATCHDOG_RESET(); - usb_gadget_handle_interrupts(controller_index); - } -exit: - g_dnl_unregister(); - board_usb_cleanup(controller_index, USB_INIT_DEVICE); done: dfu_free_entities(); - - if (dfu_reset) - run_command("reset", 0); - - g_dnl_clear_detach(); - return ret; } diff --git a/common/Makefile b/common/Makefile index 9a9a065ad2..ecc23e6fd3 100644 --- a/common/Makefile +++ b/common/Makefile @@ -89,6 +89,8 @@ obj-$(CONFIG_USB_KEYBOARD) += usb_kbd.o endif # !CONFIG_SPL_BUILD ifdef CONFIG_SPL_BUILD +obj-$(CONFIG_SPL_DFU_SUPPORT) += dfu.o +obj-$(CONFIG_SPL_DFU_SUPPORT) += cli_hush.o obj-$(CONFIG_SPL_HASH_SUPPORT) += hash.o obj-$(CONFIG_ENV_IS_IN_FLASH) += env_flash.o obj-$(CONFIG_SPL_YMODEM_SUPPORT) += xyzModem.o @@ -171,6 +173,7 @@ obj-$(CONFIG_CMDLINE) += cli_simple.o obj-y += cli.o obj-$(CONFIG_CMDLINE) += cli_readline.o +obj-$(CONFIG_CMD_DFU) += dfu.o obj-y += command.o obj-y += s_record.o obj-y += xyzModem.o diff --git a/common/dfu.c b/common/dfu.c new file mode 100644 index 0000000000..4c529f7c36 --- /dev/null +++ b/common/dfu.c @@ -0,0 +1,92 @@ +/* + * dfu.c -- dfu command + * + * Copyright (C) 2015 + * Lukasz Majewski <l.majewski@majess.pl> + * + * Copyright (C) 2012 Samsung Electronics + * authors: Andrzej Pietrasiewicz <andrzej.p@samsung.com> + * Lukasz Majewski <l.majewski@samsung.com> + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include <common.h> +#include <watchdog.h> +#include <dfu.h> +#include <console.h> +#include <g_dnl.h> +#include <usb.h> +#include <net.h> + +int run_usb_dnl_gadget(int usbctrl_index, char *usb_dnl_gadget) +{ + bool dfu_reset = false; + int ret, i = 0; + + board_usb_init(usbctrl_index, USB_INIT_DEVICE); + g_dnl_clear_detach(); + ret = g_dnl_register(usb_dnl_gadget); + if (ret) { + error("g_dnl_register failed"); + return CMD_RET_FAILURE; + } + + while (1) { + if (g_dnl_detach()) { + /* + * Check if USB bus reset is performed after detach, + * which indicates that -R switch has been passed to + * dfu-util. In this case reboot the device + */ + if (dfu_usb_get_reset()) { + dfu_reset = true; + goto exit; + } + + /* + * This extra number of usb_gadget_handle_interrupts() + * calls is necessary to assure correct transmission + * completion with dfu-util + */ + if (++i == 10000) + goto exit; + } + + if (ctrlc()) + goto exit; + + if (dfu_get_defer_flush()) { + /* + * Call to usb_gadget_handle_interrupts() is necessary + * to act on ZLP OUT transaction from HOST PC after + * transmitting the whole file. + * + * If this ZLP OUT packet is NAK'ed, the HOST libusb + * function fails after timeout (by default it is set to + * 5 seconds). In such situation the dfu-util program + * exits with error message. + */ + usb_gadget_handle_interrupts(usbctrl_index); + ret = dfu_flush(dfu_get_defer_flush(), NULL, 0, 0); + dfu_set_defer_flush(NULL); + if (ret) { + error("Deferred dfu_flush() failed!"); + goto exit; + } + } + + WATCHDOG_RESET(); + usb_gadget_handle_interrupts(usbctrl_index); + } +exit: + g_dnl_unregister(); + board_usb_cleanup(usbctrl_index, USB_INIT_DEVICE); + + if (dfu_reset) + run_command("reset", 0); + + g_dnl_clear_detach(); + + return ret; +} diff --git a/common/spl/Makefile b/common/spl/Makefile index b15f0f6dcd..5bd0b1841e 100644 --- a/common/spl/Makefile +++ b/common/spl/Makefile @@ -24,4 +24,5 @@ obj-$(CONFIG_SPL_USB_SUPPORT) += spl_usb.o obj-$(CONFIG_SPL_FAT_SUPPORT) += spl_fat.o obj-$(CONFIG_SPL_EXT_SUPPORT) += spl_ext.o obj-$(CONFIG_SPL_SATA_SUPPORT) += spl_sata.o +obj-$(CONFIG_SPL_DFU_SUPPORT) += spl_dfu.o endif diff --git a/common/spl/spl.c b/common/spl/spl.c index e14ec8052e..57b73af4a7 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -174,7 +174,7 @@ __weak void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image) # define CONFIG_SPL_LOAD_FIT_ADDRESS 0 #endif -#ifdef CONFIG_SPL_RAM_DEVICE +#if defined(CONFIG_SPL_RAM_DEVICE) || defined(CONFIG_SPL_DFU_SUPPORT) static ulong spl_ram_load_read(struct spl_load_info *load, ulong sector, ulong count, void *buf) { @@ -312,6 +312,9 @@ struct boot_device_name boot_name_table[] = { #ifdef CONFIG_SPL_USB_SUPPORT { BOOT_DEVICE_USB, "USB" }, #endif +#ifdef CONFIG_SPL_DFU_SUPPORT + { BOOT_DEVICE_DFU, "USB DFU" }, +#endif #ifdef CONFIG_SPL_SATA_SUPPORT { BOOT_DEVICE_SATA, "SATA" }, #endif @@ -398,6 +401,11 @@ static int spl_load_image(u32 boot_device) case BOOT_DEVICE_USB: return spl_usb_load_image(); #endif +#ifdef CONFIG_SPL_DFU_SUPPORT + case BOOT_DEVICE_DFU: + spl_dfu_cmd(0, "dfu_alt_info_ram", "ram", "0"); + return spl_ram_load_image(); +#endif #ifdef CONFIG_SPL_SATA_SUPPORT case BOOT_DEVICE_SATA: return spl_sata_load_image(); diff --git a/common/spl/spl_dfu.c b/common/spl/spl_dfu.c new file mode 100644 index 0000000000..e8d0ba18e6 --- /dev/null +++ b/common/spl/spl_dfu.c @@ -0,0 +1,57 @@ +/* + * (C) Copyright 2016 + * Texas Instruments, <www.ti.com> + * + * Ravi B <ravibabu@ti.com> + * + * SPDX-License-Identifier: GPL-2.0+ + */ +#include <common.h> +#include <spl.h> +#include <linux/compiler.h> +#include <errno.h> +#include <watchdog.h> +#include <console.h> +#include <g_dnl.h> +#include <usb.h> +#include <dfu.h> +#include <environment.h> + +static int run_dfu(int usb_index, char *interface, char *devstring) +{ + int ret; + + ret = dfu_init_env_entities(interface, devstring); + if (ret) { + dfu_free_entities(); + goto exit; + } + + run_usb_dnl_gadget(usb_index, "usb_dnl_dfu"); +exit: + dfu_free_entities(); + return ret; +} + +int spl_dfu_cmd(int usbctrl, char *dfu_alt_info, char *interface, char *devstr) +{ + char *str_env; + int ret; + + /* set default environment */ + set_default_env(0); + str_env = getenv(dfu_alt_info); + if (!str_env) { + error("\"dfu_alt_info\" env variable not defined!\n"); + return -EINVAL; + } + + ret = setenv("dfu_alt_info", str_env); + if (ret) { + error("unable to set env variable \"dfu_alt_info\"!\n"); + return -EINVAL; + } + + /* invoke dfu command */ + return run_dfu(usbctrl, interface, devstr); +} diff --git a/configs/colibri_vf_defconfig b/configs/colibri_vf_defconfig index 235f0042b4..fce6bac5c9 100644 --- a/configs/colibri_vf_defconfig +++ b/configs/colibri_vf_defconfig @@ -39,6 +39,7 @@ CONFIG_DM_SPI=y CONFIG_FSL_DSPI=y CONFIG_USB=y CONFIG_USB_STORAGE=y +CONFIG_DM_USB=y CONFIG_USB_GADGET=y CONFIG_CI_UDC=y CONFIG_USB_GADGET_DOWNLOAD=y diff --git a/drivers/usb/common/fsl-dt-fixup.c b/drivers/usb/common/fsl-dt-fixup.c index 9c48852ea0..63a24f74ad 100644 --- a/drivers/usb/common/fsl-dt-fixup.c +++ b/drivers/usb/common/fsl-dt-fixup.c @@ -86,8 +86,9 @@ static int fdt_fixup_usb_mode_phy_type(void *blob, const char *mode, return node_offset; } -static int fdt_fixup_usb_erratum(void *blob, const char *prop_erratum, - const char *controller_type, int start_offset) +static int fsl_fdt_fixup_usb_erratum(void *blob, const char *prop_erratum, + const char *controller_type, + int start_offset) { int node_offset, err; const char *node_type = NULL; @@ -114,24 +115,24 @@ static int fdt_fixup_usb_erratum(void *blob, const char *prop_erratum, return node_offset; } -static int fdt_fixup_erratum(int *usb_erratum_off, void *blob, - const char *controller_type, char *str, - bool (*has_erratum)(void)) +static int fsl_fdt_fixup_erratum(int *usb_erratum_off, void *blob, + const char *controller_type, char *str, + bool (*has_erratum)(void)) { char buf[32] = {0}; snprintf(buf, sizeof(buf), "fsl,usb-erratum-%s", str); if (!has_erratum()) return -EINVAL; - *usb_erratum_off = fdt_fixup_usb_erratum(blob, buf, controller_type, - *usb_erratum_off); + *usb_erratum_off = fsl_fdt_fixup_usb_erratum(blob, buf, controller_type, + *usb_erratum_off); if (*usb_erratum_off < 0) return -ENOSPC; debug("Adding USB erratum %s\n", str); return 0; } -void fdt_fixup_dr_usb(void *blob, bd_t *bd) +void fsl_fdt_fixup_dr_usb(void *blob, bd_t *bd) { static const char * const modes[] = { "host", "peripheral", "otg" }; static const char * const phys[] = { "ulpi", "utmi", "utmi_dual" }; @@ -198,29 +199,29 @@ void fdt_fixup_dr_usb(void *blob, bd_t *bd) if (usb_phy_off < 0) return; - ret = fdt_fixup_erratum(&usb_erratum_a006261_off, blob, - CHIPIDEA_USB2, "a006261", - has_erratum_a006261); + ret = fsl_fdt_fixup_erratum(&usb_erratum_a006261_off, blob, + CHIPIDEA_USB2, "a006261", + has_erratum_a006261); if (ret == -ENOSPC) return; - ret = fdt_fixup_erratum(&usb_erratum_a007075_off, blob, - CHIPIDEA_USB2, "a007075", - has_erratum_a007075); + ret = fsl_fdt_fixup_erratum(&usb_erratum_a007075_off, blob, + CHIPIDEA_USB2, "a007075", + has_erratum_a007075); if (ret == -ENOSPC) return; - ret = fdt_fixup_erratum(&usb_erratum_a007792_off, blob, - CHIPIDEA_USB2, "a007792", - has_erratum_a007792); + ret = fsl_fdt_fixup_erratum(&usb_erratum_a007792_off, blob, + CHIPIDEA_USB2, "a007792", + has_erratum_a007792); if (ret == -ENOSPC) return; - ret = fdt_fixup_erratum(&usb_erratum_a005697_off, blob, - CHIPIDEA_USB2, "a005697", - has_erratum_a005697); + ret = fsl_fdt_fixup_erratum(&usb_erratum_a005697_off, blob, + CHIPIDEA_USB2, "a005697", + has_erratum_a005697); if (ret == -ENOSPC) return; - ret = fdt_fixup_erratum(&usb_erratum_a008751_off, blob, - SNPS_DWC3, "a008751", - has_erratum_a008751); + ret = fsl_fdt_fixup_erratum(&usb_erratum_a008751_off, blob, + SNPS_DWC3, "a008751", + has_erratum_a008751); if (ret == -ENOSPC) return; diff --git a/drivers/usb/common/fsl-errata.c b/drivers/usb/common/fsl-errata.c index 972016ceb3..0dc3dd8117 100644 --- a/drivers/usb/common/fsl-errata.c +++ b/drivers/usb/common/fsl-errata.c @@ -185,4 +185,30 @@ bool has_erratum_a008751(void) return false; } +bool has_erratum_a010151(void) +{ + u32 svr = get_svr(); + u32 soc = SVR_SOC_VER(svr); + + switch (soc) { +#ifdef CONFIG_ARM64 + case SVR_LS2080A: + case SVR_LS2085A: + case SVR_LS1046A: + case SVR_LS1012A: + return IS_SVR_REV(svr, 1, 0); + case SVR_LS1043A: + return IS_SVR_REV(svr, 1, 0) || IS_SVR_REV(svr, 1, 1); +#endif +#ifdef CONFIG_LS102XA + case SOC_VER_LS1020: + case SOC_VER_LS1021: + case SOC_VER_LS1022: + case SOC_VER_SLS1020: + return IS_SVR_REV(svr, 2, 0); +#endif + } + return false; +} + #endif diff --git a/drivers/usb/eth/asix.c b/drivers/usb/eth/asix.c index a610ae447b..1c6e967db1 100644 --- a/drivers/usb/eth/asix.c +++ b/drivers/usb/eth/asix.c @@ -67,11 +67,8 @@ AX_MEDIUM_AC | AX_MEDIUM_RE) /* AX88772 & AX88178 RX_CTL values */ -#define AX_RX_CTL_RH2M 0x0200 /* 32-bit aligned RX IP header */ -#define AX_RX_CTL_RH1M 0x0100 /* Enable RX header format type 1 */ -#define AX_RX_CTL_SO 0x0080 -#define AX_RX_CTL_AB 0x0008 -#define AX_RX_HEADER_DEFAULT (AX_RX_CTL_RH1M | AX_RX_CTL_RH2M) +#define AX_RX_CTL_SO 0x0080 +#define AX_RX_CTL_AB 0x0008 #define AX_DEFAULT_RX_CTL \ (AX_RX_CTL_SO | AX_RX_CTL_AB) @@ -98,8 +95,6 @@ #define FLAG_TYPE_AX88772B (1U << 2) #define FLAG_EEPROM_MAC (1U << 3) /* initial mac address in eeprom */ -#define ASIX_USB_VENDOR_ID 0x0b95 -#define AX88772B_USB_PRODUCT_ID 0x772b /* driver private */ struct asix_private { @@ -431,15 +426,10 @@ static int asix_init_common(struct ueth_data *dev, uint8_t *enetaddr) int timeout = 0; #define TIMEOUT_RESOLUTION 50 /* ms */ int link_detected; - u32 ctl = AX_DEFAULT_RX_CTL; debug("** %s()\n", __func__); - if ((dev->pusb_dev->descriptor.idVendor == ASIX_USB_VENDOR_ID) && - (dev->pusb_dev->descriptor.idProduct == AX88772B_USB_PRODUCT_ID)) - ctl |= AX_RX_HEADER_DEFAULT; - - if (asix_write_rx_ctl(dev, ctl) < 0) + if (asix_write_rx_ctl(dev, AX_DEFAULT_RX_CTL) < 0) goto out_err; if (asix_write_hwaddr_common(dev, enetaddr) < 0) @@ -572,12 +562,6 @@ static int asix_recv(struct eth_device *eth) return -1; } - if ((dev->pusb_dev->descriptor.idVendor == - ASIX_USB_VENDOR_ID) && - (dev->pusb_dev->descriptor.idProduct == - AX88772B_USB_PRODUCT_ID)) - buf_ptr += 2; - /* Notify net stack */ net_process_received_packet(buf_ptr + sizeof(packet_len), packet_len); @@ -819,11 +803,6 @@ int asix_eth_recv(struct udevice *dev, int flags, uchar **packetp) } *packetp = ptr + sizeof(packet_len); - - if ((ueth->pusb_dev->descriptor.idVendor == ASIX_USB_VENDOR_ID) && - (ueth->pusb_dev->descriptor.idProduct == AX88772B_USB_PRODUCT_ID)) - *packetp += 2; - return packet_len; err: diff --git a/drivers/usb/host/ehci-vf.c b/drivers/usb/host/ehci-vf.c index 61789dddc3..f6f9efb6cd 100644 --- a/drivers/usb/host/ehci-vf.c +++ b/drivers/usb/host/ehci-vf.c @@ -8,16 +8,20 @@ */ #include <common.h> +#include <dm.h> #include <usb.h> #include <errno.h> #include <linux/compiler.h> #include <asm/io.h> +#include <asm-generic/gpio.h> #include <asm/arch/clock.h> #include <asm/arch/imx-regs.h> #include <asm/arch/crm_regs.h> #include <asm/imx-common/iomux-v3.h> #include <asm/imx-common/regs-usbphy.h> #include <usb/ehci-ci.h> +#include <libfdt.h> +#include <fdtdec.h> #include "ehci.h" @@ -32,6 +36,8 @@ #define UCMD_RUN_STOP (1 << 0) /* controller run/stop */ #define UCMD_RESET (1 << 1) /* controller reset */ +DECLARE_GLOBAL_DATA_PTR; + static const unsigned phy_bases[] = { USB_PHY0_BASE_ADDR, USB_PHY1_BASE_ADDR, @@ -131,24 +137,39 @@ int __weak board_ehci_hcd_init(int port) return 0; } +int ehci_vf_common_init(struct usb_ehci *ehci, int index) +{ + int ret; + + /* Do board specific initialisation */ + ret = board_ehci_hcd_init(index); + if (ret) + return ret; + + usb_power_config(index); + usb_oc_config(index); + usb_internal_phy_clock_gate(index); + usb_phy_enable(index, ehci); + + return 0; +} + +#ifndef CONFIG_DM_USB int ehci_hcd_init(int index, enum usb_init_type init, struct ehci_hccr **hccr, struct ehci_hcor **hcor) { struct usb_ehci *ehci; enum usb_init_type type; + int ret; if (index >= ARRAY_SIZE(nc_reg_bases)) return -EINVAL; ehci = (struct usb_ehci *)nc_reg_bases[index]; - /* Do board specific initialisation */ - board_ehci_hcd_init(index); - - usb_power_config(index); - usb_oc_config(index); - usb_internal_phy_clock_gate(index); - usb_phy_enable(index, ehci); + ret = ehci_vf_common_init(index); + if (ret) + return ret; *hccr = (struct ehci_hccr *)((uint32_t)&ehci->caplength); *hcor = (struct ehci_hcor *)((uint32_t)*hccr + @@ -175,3 +196,176 @@ int ehci_hcd_stop(int index) { return 0; } +#else +/* Possible port types (dual role mode) */ +enum dr_mode { + DR_MODE_NONE = 0, + DR_MODE_HOST, /* supports host operation */ + DR_MODE_DEVICE, /* supports device operation */ + DR_MODE_OTG, /* supports both */ +}; + +struct ehci_vf_priv_data { + struct ehci_ctrl ctrl; + struct usb_ehci *ehci; + struct gpio_desc cdet_gpio; + enum usb_init_type init_type; + enum dr_mode dr_mode; + u32 portnr; +}; + +static int vf_usb_ofdata_to_platdata(struct udevice *dev) +{ + struct ehci_vf_priv_data *priv = dev_get_priv(dev); + const void *dt_blob = gd->fdt_blob; + int node = dev->of_offset; + const char *mode; + + priv->portnr = dev->seq; + + priv->ehci = (struct usb_ehci *)dev_get_addr(dev); + mode = fdt_getprop(dt_blob, node, "dr_mode", NULL); + if (mode) { + if (0 == strcmp(mode, "host")) { + priv->dr_mode = DR_MODE_HOST; + priv->init_type = USB_INIT_HOST; + } else if (0 == strcmp(mode, "peripheral")) { + priv->dr_mode = DR_MODE_DEVICE; + priv->init_type = USB_INIT_DEVICE; + } else if (0 == strcmp(mode, "otg")) { + priv->dr_mode = DR_MODE_OTG; + /* + * We set init_type to device by default when OTG + * mode is requested. If a valid gpio is provided + * we will switch the init_type based on the state + * of the gpio pin. + */ + priv->init_type = USB_INIT_DEVICE; + } else { + debug("%s: Cannot decode dr_mode '%s'\n", + __func__, mode); + return -EINVAL; + } + } else { + priv->dr_mode = DR_MODE_HOST; + priv->init_type = USB_INIT_HOST; + } + + if (priv->dr_mode == DR_MODE_OTG) { + gpio_request_by_name_nodev(dt_blob, node, "fsl,cdet-gpio", 0, + &priv->cdet_gpio, GPIOD_IS_IN); + if (dm_gpio_is_valid(&priv->cdet_gpio)) { + if (dm_gpio_get_value(&priv->cdet_gpio)) + priv->init_type = USB_INIT_DEVICE; + else + priv->init_type = USB_INIT_HOST; + } + } + + return 0; +} + +static int vf_init_after_reset(struct ehci_ctrl *dev) +{ + struct ehci_vf_priv_data *priv = dev->priv; + enum usb_init_type type = priv->init_type; + struct usb_ehci *ehci = priv->ehci; + int ret; + + ret = ehci_vf_common_init(priv->ehci, priv->portnr); + if (ret) + return ret; + + if (type == USB_INIT_DEVICE) + return 0; + + setbits_le32(&ehci->usbmode, CM_HOST); + writel((PORT_PTS_UTMI | PORT_PTS_PTW), &ehci->portsc); + setbits_le32(&ehci->portsc, USB_EN); + + mdelay(10); + + return 0; +} + +static const struct ehci_ops vf_ehci_ops = { + .init_after_reset = vf_init_after_reset +}; + +static int vf_usb_bind(struct udevice *dev) +{ + static int num_controllers; + + /* + * Without this hack, if we return ENODEV for USB Controller 0, on + * probe for the next controller, USB Controller 1 will be given a + * sequence number of 0. This conflicts with our requirement of + * sequence numbers while initialising the peripherals. + */ + dev->req_seq = num_controllers; + num_controllers++; + + return 0; +} + +static int ehci_usb_probe(struct udevice *dev) +{ + struct usb_platdata *plat = dev_get_platdata(dev); + struct ehci_vf_priv_data *priv = dev_get_priv(dev); + struct usb_ehci *ehci = priv->ehci; + struct ehci_hccr *hccr; + struct ehci_hcor *hcor; + int ret; + + ret = ehci_vf_common_init(ehci, priv->portnr); + if (ret) + return ret; + + if (priv->init_type != plat->init_type) + return -ENODEV; + + if (priv->init_type == USB_INIT_HOST) { + setbits_le32(&ehci->usbmode, CM_HOST); + writel((PORT_PTS_UTMI | PORT_PTS_PTW), &ehci->portsc); + setbits_le32(&ehci->portsc, USB_EN); + } + + mdelay(10); + + hccr = (struct ehci_hccr *)((uint32_t)&ehci->caplength); + hcor = (struct ehci_hcor *)((uint32_t)hccr + + HC_LENGTH(ehci_readl(&hccr->cr_capbase))); + + return ehci_register(dev, hccr, hcor, &vf_ehci_ops, 0, priv->init_type); +} + +static int ehci_usb_remove(struct udevice *dev) +{ + int ret; + + ret = ehci_deregister(dev); + if (ret) + return ret; + + return 0; +} + +static const struct udevice_id vf_usb_ids[] = { + { .compatible = "fsl,vf610-usb" }, + { } +}; + +U_BOOT_DRIVER(usb_ehci) = { + .name = "ehci_vf", + .id = UCLASS_USB, + .of_match = vf_usb_ids, + .bind = vf_usb_bind, + .probe = ehci_usb_probe, + .remove = ehci_usb_remove, + .ops = &ehci_usb_ops, + .ofdata_to_platdata = vf_usb_ofdata_to_platdata, + .platdata_auto_alloc_size = sizeof(struct usb_platdata), + .priv_auto_alloc_size = sizeof(struct ehci_vf_priv_data), + .flags = DM_FLAG_ALLOC_PRIV_DMA, +}; +#endif diff --git a/drivers/usb/host/xhci-fsl.c b/drivers/usb/host/xhci-fsl.c index bda5b5f913..798c358fd9 100644 --- a/drivers/usb/host/xhci-fsl.c +++ b/drivers/usb/host/xhci-fsl.c @@ -58,6 +58,13 @@ static void fsl_apply_xhci_errata(void) } } +static void fsl_xhci_set_beat_burst_length(struct dwc3 *dwc3_reg) +{ + clrsetbits_le32(&dwc3_reg->g_sbuscfg0, USB3_ENABLE_BEAT_BURST_MASK, + USB3_ENABLE_BEAT_BURST); + setbits_le32(&dwc3_reg->g_sbuscfg1, USB3_SET_BEAT_BURST_LIMIT); +} + static int fsl_xhci_core_init(struct fsl_xhci *fsl_xhci) { int ret = 0; @@ -74,6 +81,22 @@ static int fsl_xhci_core_init(struct fsl_xhci *fsl_xhci) /* Set GFLADJ_30MHZ as 20h as per XHCI spec default value */ dwc3_set_fladj(fsl_xhci->dwc3_reg, GFLADJ_30MHZ_DEFAULT); + /* Change beat burst and outstanding pipelined transfers requests */ + fsl_xhci_set_beat_burst_length(fsl_xhci->dwc3_reg); + + /* + * A-010151: The dwc3 phy TSMC 28-nm HPM 0.9/1.8 V does not + * reliably support Rx Detect in P3 mode(P3 is the default + * setting). Therefore, some USB3.0 devices may not be detected + * reliably in Super Speed mode. So, USB controller to configure + * USB in P2 mode whenever the Receive Detect feature is required. + * whenever the Receive Detect feature is required. + */ + if (has_erratum_a010151()) + clrsetbits_le32(&fsl_xhci->dwc3_reg->g_usb3pipectl[0], + DWC3_GUSB3PIPECTL_DISRXDETP3, + DWC3_GUSB3PIPECTL_DISRXDETP3); + return ret; } diff --git a/include/configs/apalis_t30.h b/include/configs/apalis_t30.h index 8c76605f8b..3fc177906b 100644 --- a/include/configs/apalis_t30.h +++ b/include/configs/apalis_t30.h @@ -52,7 +52,7 @@ /* General networking support */ #define CONFIG_IP_DEFRAG -#define CONFIG_TFTP_BLOCKSIZE 16384 +#define CONFIG_TFTP_BLOCKSIZE 16352 #define CONFIG_TFTP_TSIZE /* Miscellaneous commands */ diff --git a/include/configs/colibri_imx7.h b/include/configs/colibri_imx7.h index e911303788..16ae952f37 100644 --- a/include/configs/colibri_imx7.h +++ b/include/configs/colibri_imx7.h @@ -44,9 +44,9 @@ #define CONFIG_PHYLIB #define CONFIG_PHY_MICREL -#define CONFIG_TFTP_TSIZE #define CONFIG_IP_DEFRAG -#define CONFIG_TFTP_BLOCKSIZE 16384 +#define CONFIG_TFTP_BLOCKSIZE 16352 +#define CONFIG_TFTP_TSIZE /* ENET1 */ #define IMX_FEC_BASE ENET_IPS_BASE_ADDR diff --git a/include/configs/colibri_t30.h b/include/configs/colibri_t30.h index fbb235d82c..e2a2549fb6 100644 --- a/include/configs/colibri_t30.h +++ b/include/configs/colibri_t30.h @@ -48,7 +48,7 @@ /* General networking support */ #define CONFIG_IP_DEFRAG -#define CONFIG_TFTP_BLOCKSIZE 16384 +#define CONFIG_TFTP_BLOCKSIZE 16352 #define CONFIG_TFTP_TSIZE /* Miscellaneous commands */ diff --git a/include/configs/dra7xx_evm.h b/include/configs/dra7xx_evm.h index cecb00f252..66ce82cabb 100644 --- a/include/configs/dra7xx_evm.h +++ b/include/configs/dra7xx_evm.h @@ -132,6 +132,23 @@ #define CONFIG_FASTBOOT_FLASH_MMC_DEV 1 #endif +#ifdef CONFIG_SPL_BUILD +#undef CONFIG_CMD_BOOTD +#ifdef CONFIG_SPL_DFU_SUPPORT +#define CONFIG_SPL_LOAD_FIT_ADDRESS 0x80200000 +#define CONFIG_SPL_ENV_SUPPORT +#define CONFIG_SPL_HASH_SUPPORT +#define DFU_ALT_INFO_RAM \ + "dfu_alt_info_ram=" \ + "kernel ram 0x80200000 0x4000000;" \ + "fdt ram 0x80f80000 0x80000;" \ + "ramdisk ram 0x81000000 0x4000000\0" +#define DFUARGS \ + "dfu_bufsiz=0x10000\0" \ + DFU_ALT_INFO_RAM +#endif +#endif + #include <configs/ti_omap5_common.h> /* Enhance our eMMC support / experience. */ diff --git a/include/configs/ti_omap5_common.h b/include/configs/ti_omap5_common.h index cbdf0bc0db..ea11226620 100644 --- a/include/configs/ti_omap5_common.h +++ b/include/configs/ti_omap5_common.h @@ -64,7 +64,6 @@ #define DFUARGS #endif -#ifndef CONFIG_SPL_BUILD #define CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG #define CONFIG_EXTRA_ENV_SETTINGS \ DEFAULT_LINUX_BOOT_ENV \ @@ -128,7 +127,6 @@ "setenv mmcroot /dev/mmcblk0p2 rw; " \ "run mmcboot;" \ "" -#endif /* * SPL related defines. The Public RAM memory map the ROM defines the diff --git a/include/fdt_support.h b/include/fdt_support.h index e9f3497ab6..8f402310f6 100644 --- a/include/fdt_support.h +++ b/include/fdt_support.h @@ -114,9 +114,9 @@ void fdt_fixup_qe_firmware(void *fdt); int fdt_fixup_display(void *blob, const char *path, const char *display); #if defined(CONFIG_USB_EHCI_FSL) || defined(CONFIG_USB_XHCI_FSL) -void fdt_fixup_dr_usb(void *blob, bd_t *bd); +void fsl_fdt_fixup_dr_usb(void *blob, bd_t *bd); #else -static inline void fdt_fixup_dr_usb(void *blob, bd_t *bd) {} +static inline void fsl_fdt_fixup_dr_usb(void *blob, bd_t *bd) {} #endif /* defined(CONFIG_USB_EHCI_FSL) || defined(CONFIG_USB_XHCI_FSL) */ #if defined(CONFIG_SYS_FSL_SEC_COMPAT) diff --git a/include/fsl_usb.h b/include/fsl_usb.h index fc72fb9384..73235b8c73 100644 --- a/include/fsl_usb.h +++ b/include/fsl_usb.h @@ -95,5 +95,6 @@ bool has_erratum_a007792(void); bool has_erratum_a005697(void); bool has_erratum_a004477(void); bool has_erratum_a008751(void); +bool has_erratum_a010151(void); #endif #endif /*_ASM_FSL_USB_H_ */ diff --git a/include/g_dnl.h b/include/g_dnl.h index ba49f1f5cb..bd29a9f83a 100644 --- a/include/g_dnl.h +++ b/include/g_dnl.h @@ -43,5 +43,6 @@ void g_dnl_set_serialnumber(char *); bool g_dnl_detach(void); void g_dnl_trigger_detach(void); void g_dnl_clear_detach(void); +int run_usb_dnl_gadget(int usbctrl_index, char *usb_dnl_gadget); #endif /* __G_DOWNLOAD_H_ */ diff --git a/include/linux/usb/dwc3.h b/include/linux/usb/dwc3.h index a0274461cc..c1b23b2f1b 100644 --- a/include/linux/usb/dwc3.h +++ b/include/linux/usb/dwc3.h @@ -198,6 +198,7 @@ struct dwc3 { /* offset: 0xC100 */ /* Global USB3 PIPE Control Register */ #define DWC3_GUSB3PIPECTL_PHYSOFTRST (1 << 31) +#define DWC3_GUSB3PIPECTL_DISRXDETP3 (1 << 28) #define DWC3_GUSB3PIPECTL_SUSPHY (1 << 17) /* Global TX Fifo Size Register */ diff --git a/include/linux/usb/xhci-fsl.h b/include/linux/usb/xhci-fsl.h index d04e3cc95a..15cac40e9d 100644 --- a/include/linux/usb/xhci-fsl.h +++ b/include/linux/usb/xhci-fsl.h @@ -20,6 +20,9 @@ #define USB3_PHY_TX_RX_POWERON (USB3_PHY_RX_POWERON | USB3_PHY_TX_POWERON) #define USB3_PWRCTL_CLK_CMD_SHIFT 14 #define USB3_PWRCTL_CLK_FREQ_SHIFT 22 +#define USB3_ENABLE_BEAT_BURST 0xF +#define USB3_ENABLE_BEAT_BURST_MASK 0xFF +#define USB3_SET_BEAT_BURST_LIMIT 0xF00 /* USBOTGSS_WRAPPER definitions */ #define USBOTGSS_WRAPRESET BIT(17) diff --git a/include/spl.h b/include/spl.h index 8afa0856c5..30eda36fef 100644 --- a/include/spl.h +++ b/include/spl.h @@ -144,4 +144,12 @@ void spl_board_init(void); */ bool spl_was_boot_source(void); +/** + * spl_dfu_cmd- run dfu command with chosen mmc device interface + * @param usb_index - usb controller number + * @param mmc_dev - mmc device nubmer + * + * @return 0 on success, otherwise error code + */ +int spl_dfu_cmd(int usbctrl, char *dfu_alt_info, char *interface, char *devstr); #endif diff --git a/scripts/Makefile.spl b/scripts/Makefile.spl index 5a7f79c25a..4febc6b401 100644 --- a/scripts/Makefile.spl +++ b/scripts/Makefile.spl @@ -66,6 +66,10 @@ endif libs-$(CONFIG_SPL_LIBDISK_SUPPORT) += disk/ libs-y += drivers/ +libs-$(CONFIG_SPL_DFU_SUPPORT) += drivers/dfu/ +libs-$(CONFIG_SPL_DFU_SUPPORT) += drivers/usb/gadget/ +libs-$(CONFIG_SPL_DFU_SUPPORT) += drivers/usb/gadget/udc/ +libs-$(CONFIG_SPL_DFU_SUPPORT) += drivers/usb/dwc3/ libs-y += dts/ libs-y += fs/ libs-$(CONFIG_SPL_POST_MEM_SUPPORT) += post/drivers/ |