[PATCH v3] ARM: imx: Switch Data Modul i.MX8M Mini eDM SBC to USB251x Hub driver

Marek Vasut marex at denx.de
Tue Jun 14 22:05:42 CEST 2022


Replace the ad-hoc I2C register programming scripted in board
environment with U-Boot DM driver.

Signed-off-by: Marek Vasut <marex at denx.de>
Cc: Fabio Estevam <festevam at gmail.com>
Cc: Peng Fan <peng.fan at nxp.com>
Cc: Stefano Babic <sbabic at denx.de>
---
V2: Use uclass_get_device_by_name()
V3: Reinstate the device-internal.h, needed for device_probe()
---
 .../imx8mm_data_modul_edm_sbc.c               |  9 +++++++++
 configs/imx8mm_data_modul_edm_sbc_defconfig   |  1 +
 include/configs/imx8mm_data_modul_edm_sbc.h   | 20 -------------------
 3 files changed, 10 insertions(+), 20 deletions(-)

diff --git a/board/data_modul/imx8mm_edm_sbc/imx8mm_data_modul_edm_sbc.c b/board/data_modul/imx8mm_edm_sbc/imx8mm_data_modul_edm_sbc.c
index 46cb6f77b59..07d9effbbb9 100644
--- a/board/data_modul/imx8mm_edm_sbc/imx8mm_data_modul_edm_sbc.c
+++ b/board/data_modul/imx8mm_edm_sbc/imx8mm_data_modul_edm_sbc.c
@@ -9,6 +9,7 @@
 #include <asm/io.h>
 #include <asm/mach-imx/boot_mode.h>
 #include <dm.h>
+#include <dm/device-internal.h>
 #include <i2c_eeprom.h>
 #include <malloc.h>
 #include <net.h>
@@ -104,7 +105,15 @@ int board_init(void)
 
 int board_late_init(void)
 {
+	struct udevice *dev;
+	int ret;
+
 	setup_boot_device();
 	setup_mac_address();
+
+	ret = uclass_get_device_by_name(UCLASS_MISC, "usb-hub at 2c", &dev);
+	if (!ret)
+		device_probe(dev);
+
 	return 0;
 }
diff --git a/configs/imx8mm_data_modul_edm_sbc_defconfig b/configs/imx8mm_data_modul_edm_sbc_defconfig
index d55efa6d00e..99a1f862200 100644
--- a/configs/imx8mm_data_modul_edm_sbc_defconfig
+++ b/configs/imx8mm_data_modul_edm_sbc_defconfig
@@ -156,6 +156,7 @@ CONFIG_MXC_GPIO=y
 CONFIG_DM_I2C=y
 # CONFIG_INPUT is not set
 CONFIG_MISC=y
+CONFIG_USB_HUB_USB251XB=y
 CONFIG_I2C_EEPROM=y
 CONFIG_SYS_I2C_EEPROM_ADDR=0x50
 CONFIG_SUPPORT_EMMC_BOOT=y
diff --git a/include/configs/imx8mm_data_modul_edm_sbc.h b/include/configs/imx8mm_data_modul_edm_sbc.h
index 67667dd523d..419258f949a 100644
--- a/include/configs/imx8mm_data_modul_edm_sbc.h
+++ b/include/configs/imx8mm_data_modul_edm_sbc.h
@@ -71,7 +71,6 @@
 		"mtd nor0=sf raw 0x0 0x1000000\0"			\
 	"dmo_preboot="							\
 		"sf probe ; " /* Scan for SPI NOR, needed by DFU */	\
-		"run dmo_usb_start_hub ; "				\
 		/* Attempt to start USB and Network console */		\
 		"run dmo_usb_cdc_acm_start ; "				\
 		"run dmo_netconsole_start\0"				\
@@ -91,25 +90,6 @@
 				"setenv stdin ${stdin},usbacm ; "	\
 			"fi ; "						\
 		"fi\0"							\
-	"dmo_usb_start_hub="						\
-		"i2c dev 1 ; "						\
-		/* Reset the USB USB */					\
-		"gpio clear GPIO5_2 ; sleep 0.01 ; " /* t1 > 1us */	\
-		"gpio set GPIO5_2 ; sleep 0.01 ; " /* t5 > 3us */	\
-		/* Write chunks of descriptor into the USB HUB */	\
-		"mw.l 0x7e1000 0x14042417 ; mw.l 0x7e1004 0x9b0bb325 ; "\
-		"mw.l 0x7e1008 0x00000220 ; mw.l 0x7e100c 0x01320100 ; "\
-		"mw.l 0x7e1010 0x00003232 ; mw.l 0x7e1014 0x4d000909 ; "\
-		"i2c write 0x7e1000 0x2c 0x00 0x18 -s ; "		\
-		"mw.l 0x7e1000 0x6300690f ; mw.l 0x7e1004 0x6f007200 ; "\
-		"mw.l 0x7e1008 0x68006300 ; mw.l 0x7e100c 0x70006900 ; "\
-		"i2c write 0x7e1000 0x2c 0x18 0x10 -s ; "		\
-		"mw.l 0x7e1000 0x53005511 ; mw.l 0x7e1004 0x32004200 ; "\
-		"mw.l 0x7e1008 0x31003500 ; mw.l 0x7e100c 0x42003400 ; "\
-		"mw.l 0x7e1010 0x00006900 ; "				\
-		"i2c write 0x7e1000 0x2c 0x54 0x12 -s ; "		\
-		"mw.l 0x7e1000 0x00000101 ; "				\
-		"i2c write 0x7e1000 0x2c 0xff 0x2 -s\0"			\
 	"dmo_netconsole_start="						\
 		"if test \"${dmo_netconsole_enabled}\" = \"true\" ; then "\
 			"setenv autoload false && "			\
-- 
2.35.1



More information about the U-Boot mailing list