[PATCH 0/3] phycore-imx8mp: Add USB support

add support for various USB features like USB storage, USB mass storage as well as booting and flashing emmc via UUU.
Signed-off-by: Benjamin Hahn B.Hahn@phytec.de --- Benjamin Hahn (3): phycore-imx8mp: add USB host support phycore-imx8mp: add USB mass storage support phycore-imx8mp: add support for booting and flashing emmc via UUU
.../arm/dts/imx8mp-phyboard-pollux-rdk-u-boot.dtsi | 26 +++++++++++++++++ board/phytec/phycore_imx8mp/phycore-imx8mp.c | 4 +++ configs/phycore-imx8mp_defconfig | 33 +++++++++++++++++++++- include/configs/phycore_imx8mp.h | 5 ++++ 4 files changed, 67 insertions(+), 1 deletion(-) --- base-commit: e7f9e5eb584dd0b5d1b1ff82fe607d6da9940cc6 change-id: 20240126-usb_support-403f47d71ac1
Best regards,

The phyBOARD Pollux has two USB ports. Add support for USB host and USB storage for the USB1 port.
Signed-off-by: Benjamin Hahn B.Hahn@phytec.de --- arch/arm/dts/imx8mp-phyboard-pollux-rdk-u-boot.dtsi | 13 +++++++++++++ configs/phycore-imx8mp_defconfig | 10 ++++++++++ 2 files changed, 23 insertions(+)
diff --git a/arch/arm/dts/imx8mp-phyboard-pollux-rdk-u-boot.dtsi b/arch/arm/dts/imx8mp-phyboard-pollux-rdk-u-boot.dtsi index 1c7b250549..5d6974f8fa 100644 --- a/arch/arm/dts/imx8mp-phyboard-pollux-rdk-u-boot.dtsi +++ b/arch/arm/dts/imx8mp-phyboard-pollux-rdk-u-boot.dtsi @@ -70,6 +70,19 @@ bootph-pre-ram; };
+&usb3_1 { + status = "okay"; + dr_mode = "host"; +}; + +&usb_dwc3_1 { + status = "okay"; +}; + +&usb3_phy1 { + status = "okay"; +}; + &usdhc2 { bootph-pre-ram; }; diff --git a/configs/phycore-imx8mp_defconfig b/configs/phycore-imx8mp_defconfig index 519e0cfb3d..74450b957b 100644 --- a/configs/phycore-imx8mp_defconfig +++ b/configs/phycore-imx8mp_defconfig @@ -65,6 +65,7 @@ CONFIG_CMD_FUSE=y CONFIG_CMD_GPIO=y CONFIG_CMD_I2C=y CONFIG_CMD_MMC=y +CONFIG_CMD_USB=y CONFIG_CMD_DHCP=y CONFIG_CMD_MII=y CONFIG_CMD_PING=y @@ -104,6 +105,7 @@ CONFIG_DM_ETH_PHY=y CONFIG_FEC_MXC=y CONFIG_RGMII=y CONFIG_MII=y +CONFIG_PHY_IMX8MQ_USB=y CONFIG_PINCTRL=y CONFIG_SPL_PINCTRL=y CONFIG_PINCTRL_IMX8M=y @@ -120,4 +122,12 @@ CONFIG_SPL_SYSRESET=y CONFIG_SYSRESET_PSCI=y CONFIG_SYSRESET_WATCHDOG=y CONFIG_DM_THERMAL=y +CONFIG_USB=y +CONFIG_USB_XHCI_HCD=y +CONFIG_USB_XHCI_DWC3=y +CONFIG_USB_XHCI_DWC3_OF_SIMPLE=y +CONFIG_USB_EHCI_HCD=y +CONFIG_USB_DWC3=y +CONFIG_USB_DWC3_GENERIC=y +CONFIG_USB_STORAGE=y CONFIG_IMX_WATCHDOG=y

Hi Benjamin,
On Mon, Jan 29, 2024 at 4:56 AM Benjamin Hahn B.Hahn@phytec.de wrote:
diff --git a/arch/arm/dts/imx8mp-phyboard-pollux-rdk-u-boot.dtsi b/arch/arm/dts/imx8mp-phyboard-pollux-rdk-u-boot.dtsi index 1c7b250549..5d6974f8fa 100644 --- a/arch/arm/dts/imx8mp-phyboard-pollux-rdk-u-boot.dtsi +++ b/arch/arm/dts/imx8mp-phyboard-pollux-rdk-u-boot.dtsi @@ -70,6 +70,19 @@ bootph-pre-ram; };
+&usb3_1 {
status = "okay";
dr_mode = "host";
+};
+&usb_dwc3_1 {
status = "okay";
+};
+&usb3_phy1 {
status = "okay";
+};
Why are these USB nodes being added to -u-boot.dtsi?
These nodes are already present in the kernel dts:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch...
Please add a patch to the series that syncs imx8mp-phyboard-pollux-rdk.dts with the upstream version, then you don't need to touch u-boot.dtsi.

add support for USB mass storage to USB0 port of phyBOARD Pollux.
tested with "ums 0 mmc 2"
Signed-off-by: Benjamin Hahn B.Hahn@phytec.de --- arch/arm/dts/imx8mp-phyboard-pollux-rdk-u-boot.dtsi | 13 +++++++++++++ configs/phycore-imx8mp_defconfig | 7 +++++++ 2 files changed, 20 insertions(+)
diff --git a/arch/arm/dts/imx8mp-phyboard-pollux-rdk-u-boot.dtsi b/arch/arm/dts/imx8mp-phyboard-pollux-rdk-u-boot.dtsi index 5d6974f8fa..dcef4d4c2a 100644 --- a/arch/arm/dts/imx8mp-phyboard-pollux-rdk-u-boot.dtsi +++ b/arch/arm/dts/imx8mp-phyboard-pollux-rdk-u-boot.dtsi @@ -70,15 +70,28 @@ bootph-pre-ram; };
+&usb3_0 { + status = "okay"; + dr_mode = "peripheral"; +}; + &usb3_1 { status = "okay"; dr_mode = "host"; };
+&usb_dwc3_0 { + status = "okay"; +}; + &usb_dwc3_1 { status = "okay"; };
+&usb3_phy0 { + status = "okay"; +}; + &usb3_phy1 { status = "okay"; }; diff --git a/configs/phycore-imx8mp_defconfig b/configs/phycore-imx8mp_defconfig index 74450b957b..e3fe4ed94e 100644 --- a/configs/phycore-imx8mp_defconfig +++ b/configs/phycore-imx8mp_defconfig @@ -66,6 +66,7 @@ CONFIG_CMD_GPIO=y CONFIG_CMD_I2C=y CONFIG_CMD_MMC=y CONFIG_CMD_USB=y +CONFIG_CMD_USB_MASS_STORAGE=y CONFIG_CMD_DHCP=y CONFIG_CMD_MII=y CONFIG_CMD_PING=y @@ -123,6 +124,7 @@ CONFIG_SYSRESET_PSCI=y CONFIG_SYSRESET_WATCHDOG=y CONFIG_DM_THERMAL=y CONFIG_USB=y +CONFIG_DM_USB_GADGET=y CONFIG_USB_XHCI_HCD=y CONFIG_USB_XHCI_DWC3=y CONFIG_USB_XHCI_DWC3_OF_SIMPLE=y @@ -130,4 +132,9 @@ CONFIG_USB_EHCI_HCD=y CONFIG_USB_DWC3=y CONFIG_USB_DWC3_GENERIC=y CONFIG_USB_STORAGE=y +CONFIG_USB_GADGET=y +CONFIG_USB_GADGET_MANUFACTURER="FSL" +CONFIG_USB_GADGET_VENDOR_NUM=0x0525 +CONFIG_USB_GADGET_PRODUCT_NUM=0xa4a5 +CONFIG_USB_GADGET_DOWNLOAD=y CONFIG_IMX_WATCHDOG=y

On Mon, Jan 29, 2024 at 4:56 AM Benjamin Hahn B.Hahn@phytec.de wrote:
+&usb3_0 {
status = "okay";
dr_mode = "peripheral";
+};
Same comment as patch 1/3. Please sync the dts with Linux.

add support for Serial Downloader Boot via UUU as well as flashing emmc via UUU on USB0 Port of phyBOARD Pollux.
Signed-off-by: Benjamin Hahn B.Hahn@phytec.de --- board/phytec/phycore_imx8mp/phycore-imx8mp.c | 4 ++++ configs/phycore-imx8mp_defconfig | 18 ++++++++++++++++-- include/configs/phycore_imx8mp.h | 5 +++++ 3 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/board/phytec/phycore_imx8mp/phycore-imx8mp.c b/board/phytec/phycore_imx8mp/phycore-imx8mp.c index a8f0821437..dbdd6bb793 100644 --- a/board/phytec/phycore_imx8mp/phycore-imx8mp.c +++ b/board/phytec/phycore_imx8mp/phycore-imx8mp.c @@ -46,6 +46,10 @@ int board_late_init(void) case MMC3_BOOT: env_set_ulong("mmcdev", 2); break; + case USB_BOOT: + printf("Detect USB boot. Will enter fastboot mode!\n"); + env_set_ulong("dofastboot", 1); + break; default: break; } diff --git a/configs/phycore-imx8mp_defconfig b/configs/phycore-imx8mp_defconfig index e3fe4ed94e..0f37286d5d 100644 --- a/configs/phycore-imx8mp_defconfig +++ b/configs/phycore-imx8mp_defconfig @@ -27,7 +27,7 @@ CONFIG_FIT_EXTERNAL_OFFSET=0x3000 CONFIG_SPL_LOAD_FIT=y CONFIG_OF_SYSTEM_SETUP=y CONFIG_USE_BOOTCOMMAND=y -CONFIG_BOOTCOMMAND="mmc dev ${mmcdev}; if mmc rescan; then if run loadimage; then run mmcboot; else run netboot; fi; fi;" +CONFIG_BOOTCOMMAND="if test ${dofastboot} = 1; then fastboot 0; fi; mmc dev ${mmcdev}; if mmc rescan; then if run loadimage; then run mmcboot; else run netboot; fi; fi;" CONFIG_DEFAULT_FDT_FILE="oftree" CONFIG_SYS_CBSIZE=2048 CONFIG_SYS_PBSIZE=2074 @@ -66,6 +66,7 @@ CONFIG_CMD_GPIO=y CONFIG_CMD_I2C=y CONFIG_CMD_MMC=y CONFIG_CMD_USB=y +CONFIG_CMD_USB_SDP=y CONFIG_CMD_USB_MASS_STORAGE=y CONFIG_CMD_DHCP=y CONFIG_CMD_MII=y @@ -87,6 +88,17 @@ CONFIG_NET_RANDOM_ETHADDR=y CONFIG_SPL_DM=y CONFIG_CLK_COMPOSITE_CCF=y CONFIG_CLK_IMX8MP=y +CONFIG_USB_FUNCTION_FASTBOOT=y +CONFIG_FASTBOOT_BUF_ADDR=0x42800000 +CONFIG_FASTBOOT_BUF_SIZE=0x13000000 +CONFIG_FASTBOOT_FLASH=y +CONFIG_FASTBOOT_UUU_SUPPORT=y +CONFIG_FASTBOOT_FLASH_MMC_DEV=2 +CONFIG_FASTBOOT_MMC_BOOT_SUPPORT=y +CONFIG_FASTBOOT_MMC_BOOT1_NAME="mmc2boot0" +CONFIG_FASTBOOT_MMC_BOOT2_NAME="mmc2boot1" +CONFIG_FASTBOOT_MMC_USER_SUPPORT=y +CONFIG_FASTBOOT_MMC_USER_NAME="mmc2" CONFIG_MXC_GPIO=y CONFIG_DM_I2C=y # CONFIG_SPL_DM_I2C is not set @@ -111,6 +123,9 @@ CONFIG_PINCTRL=y CONFIG_SPL_PINCTRL=y CONFIG_PINCTRL_IMX8M=y CONFIG_SPL_POWER_LEGACY=y +CONFIG_POWER_DOMAIN=y +CONFIG_IMX8M_POWER_DOMAIN=y +CONFIG_IMX8MP_HSIOMIX_BLKCTRL=y CONFIG_POWER_PCA9450=y CONFIG_DM_REGULATOR=y CONFIG_DM_REGULATOR_FIXED=y @@ -136,5 +151,4 @@ CONFIG_USB_GADGET=y CONFIG_USB_GADGET_MANUFACTURER="FSL" CONFIG_USB_GADGET_VENDOR_NUM=0x0525 CONFIG_USB_GADGET_PRODUCT_NUM=0xa4a5 -CONFIG_USB_GADGET_DOWNLOAD=y CONFIG_IMX_WATCHDOG=y diff --git a/include/configs/phycore_imx8mp.h b/include/configs/phycore_imx8mp.h index d79d364c8e..11a17be7fe 100644 --- a/include/configs/phycore_imx8mp.h +++ b/include/configs/phycore_imx8mp.h @@ -19,6 +19,11 @@ "fdt_addr=0x48000000\0" \ "fdt_file=" CONFIG_DEFAULT_FDT_FILE "\0" \ "ip_dyn=yes\0" \ + "dofastboot=0\0" \ + "fastboot_raw_partition_bootloader=64 8128\0" \ + "fastboot_raw_partition_all=0 4194304\0" \ + "emmc_dev=2\0" \ + "sd_dev=1\0" \ "mmcdev=" __stringify(CONFIG_SYS_MMC_ENV_DEV) "\0" \ "mmcpart=1\0" \ "mmcroot=2\0" \

On Mon, Jan 29, 2024 at 4:56 AM Benjamin Hahn B.Hahn@phytec.de wrote:
add support for Serial Downloader Boot via UUU as well as flashing emmc via UUU on USB0 Port of phyBOARD Pollux.
Signed-off-by: Benjamin Hahn B.Hahn@phytec.de
Reviewed-by: Fabio Estevam festevam@gmail.com
participants (2)
-
Benjamin Hahn
-
Fabio Estevam