Skip to contentSkip to conversation

common: usb_onboard_hub: Add support for Odroid onboard USB hub reset

RFC In review Anand Moon 4 participants 27 messages May 9, 2025 – May 22, 2025 1 message not in the archive

lore
Share & tools
lore

Anand Moon

author
#0 lore raw

cover common: usb_onboard_hub: Add support for Odroid onboard USB hub reset

Odroid C1+/C2/C4/N2/N2-plus devices have an onboard USB hub controlled by a reset GPIO pin. Adds changes to the onboard USB hub driver to perform a proper reset of the USB hub.

Added conditional compilation for I2C initialization based on CONFIG_DM_I2C for failed to compile.

Thanks
-Anand

Anand Moon (7):
usb: onboard-hub: Add support for Genesys GL852G hub
configs: odorid-c2: Enable Onboard HUB driver
usb: onboard-hub: Add support for Genesys GL853G
configs: odorid-n2: Enable Oboard HUB driver
usb: onboard-hub: Add support for VL817 USB hub
configs: odorid-c4: Enable Oboard HUB driver
usb: onboard-hub: Add conditional compilation for I2C initialization

 common/usb_onboard_hub.c    | 28 ++++++++++++++++++++++++++++
 configs/odroid-c2_defconfig |  1 +
 configs/odroid-c4_defconfig |  1 +
 configs/odroid-n2_defconfig |  1 +
 4 files changed, 31 insertions(+)

base-commit: 48db49b0977cc1c9c9abf82c0fb704238fcef4fd

Signature · 1 line
2.49.0
author
#1 lore raw

RFC 1/7 usb: onboard-hub: Add support for Genesys GL852G hub

Add support for the Genesys GL852G USB2.0 Hub on Odroid C1+ and Odroid C2. The GL852G driver trigger hub reset signal which toggles the gpio.

---
Still some issue with USB hub on Odroid C2
=> dm tree

 vidconsole    0  [ + ]   vidconsole0           |   |   `-- [email protected]
 display       0  [   ]   meson_dw_hdmi         |   |-- hdmi-tx@c883a000
 phy           0  [ + ]   meson_gxbb_usb2_phy   |   |-- phy@c0000020
 usb           0  [ + ]   dwc2_usb              |   `-- usb@c9100000
 usb_hub       0  [ + ]   usb_hub               |       `-- usb_hub
 usb_hub       1  [ + ]   usb_hub               |           `-- usb_hub
 regulator     0  [ + ]   regulator_fixed       |-- regulator-usb-pwrs
---
 common/usb_onboard_hub.c | 7 +++++++
 1 file changed, 7 insertions(+)
common/usb_onboard_hub.c +7 -0
index 7fe62b043e6..39bbc1aefa2 100644
@@ -227,6 +227,10 @@ static const struct onboard_hub_data usb5744_data = {
 	.reset_us = 5,
 };
 
+static const struct onboard_hub_data genesys_gl852g_data = {
+	.reset_us = 50,
+};
+
 static const struct udevice_id usb_onboard_hub_ids[] = {
 	/* Use generic usbVID,PID dt-bindings (usb-device.yaml) */
 	{	.compatible = "usb424,2514",	/* USB2514B USB 2.0 */
@@ -237,6 +241,9 @@ static const struct udevice_id usb_onboard_hub_ids[] = {
 	}, {
 		.compatible = "usb424,5744",	/* USB5744 USB 3.0 */
 		.data = (ulong)&usb5744_data,
+	}, {
+		.compatible = "usb5e3,610",     /* GL852G USB 2.0 */
+		.data = (ulong)&genesys_gl852g_data,
 	}
 };
 
Signature · 1 line
2.49.0
author
#3 lore raw

RFC 2/7 configs: odorid-c2: Enable Onboard HUB driver

In reply to Anand Moon

Enable the onboard USB HUB driver to power the
USB_HUB_GL852G-OHG on the Odroid C2.

---
 configs/odroid-c2_defconfig | 1 +
 1 file changed, 1 insertion(+)
configs/odroid-c2_defconfig +1 -0
index bcaab46f8bc..f8a66a923c9 100644
@@ -59,6 +59,7 @@ CONFIG_SYSINFO_SMBIOS=y
 CONFIG_USB=y
 CONFIG_USB_DWC2=y
 CONFIG_USB_KEYBOARD=y
+CONFIG_USB_ONBOARD_HUB=y
 CONFIG_VIDEO=y
 # CONFIG_VIDEO_BPP8 is not set
 # CONFIG_VIDEO_BPP16 is not set
Signature · 1 line
2.49.0
author
#6 lore raw

RFC 3/7 usb: onboard-hub: Add support for Genesys GL853G

In reply to Anand Moon

Enable support for the Genesys GL853G USB2.0 and USB3.1 Hub on the Odroid N2 and N2-plus. The GL853G driver activates the hub reset signal, which toggles the GPIO.

---
=> dm tree

 simple_bus   11  [ + ]   dwc3-meson-g12a       |   `-- usb@ffe09000
 usb_gadget    0  [   ]   dwc2-udc-otg          |       |-- usb@ff400000
 usb           0  [ + ]   xhci-dwc3             |       `-- usb@ff500000
 usb_hub       0  [ + ]   usb_hub               |           `-- usb_hub
 usb_hub       1  [ + ]   usb_hub               |               |-- usb_hub
 usb_mass_s    0  [ + ]   usb_mass_storage      |               |   `-- usb_mass_storage
 blk           2  [ + ]   usb_storage_blk       |               |       |-- usb_mass_storage.lun0
 partition     0  [ + ]   blk_partition         |               |       |   `-- usb_mass_storage.lun0:1
 bootdev       3  [   ]   usb_bootdev           |               |       `-- usb_mass_storage.lun0.bootdev
 usb_hub       2  [ + ]   usb_hub               |               `-- usb_hub
 clk           2  [ + ]   fixed_clock           |-- xtal-clk
---
 common/usb_onboard_hub.c | 7 +++++++
 1 file changed, 7 insertions(+)
common/usb_onboard_hub.c +7 -0
index 39bbc1aefa2..3914e2f773d 100644
@@ -231,6 +231,10 @@ static const struct onboard_hub_data genesys_gl852g_data = {
 	.reset_us = 50,
 };
 
+static const struct onboard_hub_data genesys_gl853g_data = {
+	.reset_us = 50,
+};
+
 static const struct udevice_id usb_onboard_hub_ids[] = {
 	/* Use generic usbVID,PID dt-bindings (usb-device.yaml) */
 	{	.compatible = "usb424,2514",	/* USB2514B USB 2.0 */
@@ -244,6 +248,9 @@ static const struct udevice_id usb_onboard_hub_ids[] = {
 	}, {
 		.compatible = "usb5e3,610",     /* GL852G USB 2.0 */
 		.data = (ulong)&genesys_gl852g_data,
+	}, {
+		.compatible = "usb5e3,620",     /* GL852G USB 3.1 */
+		.data = (ulong)&genesys_gl853g_data,
 	}
 };
 
Signature · 1 line
2.49.0
author
#8 lore raw

RFC 4/7 configs: odorid-n2: Enable Oboard HUB driver

In reply to Anand Moon

Enable the onboard USB HUB driver to power the USB_HUB_GL853G-OHG on the Odroid N2 and Odroid N2-pluss.

---
 configs/odroid-n2_defconfig | 1 +
 1 file changed, 1 insertion(+)
configs/odroid-n2_defconfig +1 -0
index a8cbaee3c96..1bf687c1e6d 100644
@@ -64,6 +64,7 @@ CONFIG_USB_DWC3=y
 # CONFIG_USB_DWC3_GADGET is not set
 CONFIG_USB_DWC3_MESON_G12A=y
 CONFIG_USB_KEYBOARD=y
+CONFIG_USB_ONBOARD_HUB=y
 CONFIG_USB_GADGET=y
 CONFIG_USB_GADGET_VENDOR_NUM=0x1b8e
 CONFIG_USB_GADGET_PRODUCT_NUM=0xfada
Signature · 1 line
2.49.0
author
#10 lore raw

RFC 5/7 usb: onboard-hub: Add support for VL817 USB hub

In reply to Anand Moon

Enable support for the Via labs VL817 USB2.0 and USB3.1 Hub on the Odroid C4. The Via labs VL817 USB driver activates the hub reset signal, which toggles the GPIO.

---
=> dm tree

 simple_bus   11  [ + ]   dwc3-meson-g12a       |   `-- usb@ffe09000
 usb_gadget    0  [   ]   dwc2-udc-otg          |       |-- usb@ff400000
 usb           0  [ + ]   xhci-dwc3             |       `-- usb@ff500000
 usb_hub       0  [ + ]   usb_hub               |           `-- usb_hub
 usb_hub       1  [ + ]   usb_hub               |               |-- usb_hub
 usb_mass_s    0  [ + ]   usb_mass_storage      |               |   `-- usb_mass_storage
 blk           2  [ + ]   usb_storage_blk       |               |       |-- usb_mass_storage.lun0
 partition     0  [ + ]   blk_partition         |               |       |   |-- usb_mass_storage.lun0:1
 partition     1  [ + ]   blk_partition         |               |       |   |-- usb_mass_storage.lun0:2
 partition     2  [ + ]   blk_partition         |               |       |   |-- usb_mass_storage.lun0:3
 partition     3  [ + ]   blk_partition         |               |       |   `-- usb_mass_storage.lun0:4
 bootdev       3  [   ]   usb_bootdev           |               |       `-- usb_mass_storage.lun0.bootdev
 usb_hub       2  [ + ]   usb_hub               |               `-- usb_hub
---
 common/usb_onboard_hub.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
common/usb_onboard_hub.c +10 -0
index 3914e2f773d..1242513c631 100644
@@ -235,6 +235,10 @@ static const struct onboard_hub_data genesys_gl853g_data = {
 	.reset_us = 50,
 };
 
+static const struct onboard_hub_data vialab_vl817_data = {
+	.reset_us = 10,
+};
+
 static const struct udevice_id usb_onboard_hub_ids[] = {
 	/* Use generic usbVID,PID dt-bindings (usb-device.yaml) */
 	{	.compatible = "usb424,2514",	/* USB2514B USB 2.0 */
@@ -251,6 +255,12 @@ static const struct udevice_id usb_onboard_hub_ids[] = {
 	}, {
 		.compatible = "usb5e3,620",     /* GL852G USB 3.1 */
 		.data = (ulong)&genesys_gl853g_data,
+	}, {
+		.compatible = "usb2109,817",	/* Via labs VL817 2.0 */
+		.data = (ulong)&vialab_vl817_data,
+	}, {
+		.compatible = "usb2109,2817",	/* Via labs VL817 3.1 */
+		.data = (ulong)&vialab_vl817_data,
 	}
 };
 
Signature · 1 line
2.49.0
author
#12 lore raw

RFC 6/7 configs: odorid-c4: Enable Oboard HUB driver

In reply to Anand Moon

Enable the onboard USB HUB driver to power the
Via labs VL817 USB 3.1 hub on the Odroid C4.

---
 configs/odroid-c4_defconfig | 1 +
 1 file changed, 1 insertion(+)
configs/odroid-c4_defconfig +1 -0
index cc3d7fc7484..3c5e53828a1 100644
@@ -64,6 +64,7 @@ CONFIG_USB_DWC3=y
 # CONFIG_USB_DWC3_GADGET is not set
 CONFIG_USB_DWC3_MESON_G12A=y
 CONFIG_USB_KEYBOARD=y
+CONFIG_USB_ONBOARD_HUB=y
 CONFIG_USB_GADGET=y
 CONFIG_USB_GADGET_VENDOR_NUM=0x1b8e
 CONFIG_USB_GADGET_PRODUCT_NUM=0xfada
Signature · 1 line
2.49.0
author
#14 lore raw

RFC 7/7 usb: onboard-hub: Add conditional compilation for I2C initialization

In reply to Anand Moon

Add conditional compilation for the usb5744_i2c_init() function based on the CONFIG_DM_I2C configuration, to avoid compilation failure.

  CC      net/net-common.o
  AR      net/built-in.o
  LDS     u-boot.lds
  LD      u-boot

aarch64-linux-gnu-ld.bfd: common/usb_onboard_hub.o: in function `usb5744_i2c_init':
/home/amoon/mainline/u-boot/amlogic/u-boot-maineline/common/usb_onboard_hub.c:74:(.text.usb5744_i2c_init+0xfc): undefined reference to i2c_get_chip' aarch64-linux-gnu-ld.bfd: /home/amoon/mainline/u-boot/amlogic/u-boot-maineline/common/usb_onboard_hub.c:89:(.text.usb5744_i2c_init+0x1a0): undefined reference to dm_i2c_write' aarch64-linux-gnu-ld.bfd: /home/amoon/mainline/u-boot/amlogic/u-boot-maineline/common/usb_onboard_hub.c:96:(.text.usb5744_i2c_init+0x1c8): undefined reference to dm_i2c_write' aarch64-linux-gnu-ld.bfd: /home/amoon/mainline/u-boot/amlogic/u-boot-maineline/common/usb_onboard_hub.c:104:(.text.usb5744_i2c_init+0x1f0): undefined reference to dm_i2c_write' Segmentation fault (core dumped)
make: *** [Makefile:1824: u-boot] Error 139
make: *** Deleting file 'u-boot'

---
 common/usb_onboard_hub.c | 4 ++++
 1 file changed, 4 insertions(+)
common/usb_onboard_hub.c +4 -0
index 1242513c631..92e3f3a92c9 100644
@@ -30,6 +30,7 @@ struct onboard_hub_data {
 	int (*init)(struct udevice *dev);
 };
 
+#if CONFIG_IS_ENABLED(DM_I2C)
 static int usb5744_i2c_init(struct udevice *dev)
 {
 	/*
@@ -109,6 +110,7 @@ static int usb5744_i2c_init(struct udevice *dev)
 
 	return 0;
 }
+#endif
 
 int usb_onboard_hub_reset(struct udevice *dev)
 {
@@ -222,7 +224,9 @@ static const struct onboard_hub_data usb2514_data = {
 };
 
 static const struct onboard_hub_data usb5744_data = {
+#if CONFIG_IS_ENABLED(DM_I2C)
 	.init = usb5744_i2c_init,
+#endif
 	.power_on_delay_us = 1000,
 	.reset_us = 5,
 };
Signature · 1 line
2.49.0
#2 lore raw

Re: [RFC v1 1/7] usb: onboard-hub: Add support for Genesys GL852G hub

In reply to Anand Moon
Quoted 7 lines · Anand Moon

Add support for the Genesys GL852G USB2.0 Hub on Odroid C1+ and Odroid C2. The GL852G driver trigger hub reset signal which toggles the gpio.

---
Still some issue with USB hub on Odroid C2

What does that mean ?

Quoted 38 lines

=> dm tree

  vidconsole    0  [ + ]   vidconsole0           |   |   `-- [email protected]
  display       0  [   ]   meson_dw_hdmi         |   |-- hdmi-tx@c883a000
  phy           0  [ + ]   meson_gxbb_usb2_phy   |   |-- phy@c0000020
  usb           0  [ + ]   dwc2_usb              |   `-- usb@c9100000
  usb_hub       0  [ + ]   usb_hub               |       `-- usb_hub
  usb_hub       1  [ + ]   usb_hub               |           `-- usb_hub
  regulator     0  [ + ]   regulator_fixed       |-- regulator-usb-pwrs
---
  common/usb_onboard_hub.c | 7 +++++++
  1 file changed, 7 insertions(+)
common/usb_onboard_hub.c +7 -0
index 7fe62b043e6..39bbc1aefa2 100644
@@ -227,6 +227,10 @@ static const struct onboard_hub_data usb5744_data = {
  	.reset_us = 5,
  };
 
+static const struct onboard_hub_data genesys_gl852g_data = {
+	.reset_us = 50,
+};
+
  static const struct udevice_id usb_onboard_hub_ids[] = {
  	/* Use generic usbVID,PID dt-bindings (usb-device.yaml) */
  	{	.compatible = "usb424,2514",	/* USB2514B USB 2.0 */
@@ -237,6 +241,9 @@ static const struct udevice_id usb_onboard_hub_ids[] = {
  	}, {
  		.compatible = "usb424,5744",	/* USB5744 USB 3.0 */
  		.data = (ulong)&usb5744_data,
+	}, {
+		.compatible = "usb5e3,610",     /* GL852G USB 2.0 */
+		.data = (ulong)&genesys_gl852g_data,
  	}
  };
 
Reviewed-by on v1 2/7
#4 lore raw

Re: [RFC v1 2/7] configs: odorid-c2: Enable Onboard HUB driver

In reply to Anand Moon

s/odorid-c2/odroid-c2/ in the subject

Quoted 13 lines · Anand Moon

Enable the onboard USB HUB driver to power the
USB_HUB_GL852G-OHG on the Odroid C2.

---
  configs/odroid-c2_defconfig | 1 +
  1 file changed, 1 insertion(+)
configs/odroid-c2_defconfig +0 -0
index bcaab46f8bc..f8a66a923c9 100644

configs/odroid-c2_defconfig CONFIG_SYSINFO_SMBIOS=y · line 65

Quoted 7 lines
configs/odroid-c2_defconfig +1 -0
@@ -59,6 +59,7 @@ CONFIG_SYSINFO_SMBIOS=y
  CONFIG_USB=y
  CONFIG_USB_DWC2=y
  CONFIG_USB_KEYBOARD=y
+CONFIG_USB_ONBOARD_HUB=y
  CONFIG_VIDEO=y
  # CONFIG_VIDEO_BPP8 is not set
  # CONFIG_VIDEO_BPP16 is not set

With that fixed:

Reviewed-by on v1 4/7
#9 lore raw

Re: [RFC v1 4/7] configs: odorid-n2: Enable Oboard HUB driver

In reply to Anand Moon
Quoted 13 lines · Anand Moon

Enable the onboard USB HUB driver to power the USB_HUB_GL853G-OHG on the Odroid N2 and Odroid N2-pluss.

---
  configs/odroid-n2_defconfig | 1 +
  1 file changed, 1 insertion(+)
configs/odroid-n2_defconfig +0 -0
index a8cbaee3c96..1bf687c1e6d 100644

configs/odroid-n2_defconfig CONFIG_USB_DWC3=y · line 70

Quoted 7 lines
configs/odroid-n2_defconfig +1 -0
@@ -64,6 +64,7 @@ CONFIG_USB_DWC3=y
  # CONFIG_USB_DWC3_GADGET is not set
  CONFIG_USB_DWC3_MESON_G12A=y
  CONFIG_USB_KEYBOARD=y
+CONFIG_USB_ONBOARD_HUB=y
  CONFIG_USB_GADGET=y
  CONFIG_USB_GADGET_VENDOR_NUM=0x1b8e
  CONFIG_USB_GADGET_PRODUCT_NUM=0xfada

Same as patch 2, with that fixed:

Reviewed-by on v1 6/7
#13 lore raw

Re: [RFC v1 6/7] configs: odorid-c4: Enable Oboard HUB driver

In reply to Anand Moon
Quoted 13 lines · Anand Moon

Enable the onboard USB HUB driver to power the
Via labs VL817 USB 3.1 hub on the Odroid C4.

---
  configs/odroid-c4_defconfig | 1 +
  1 file changed, 1 insertion(+)
configs/odroid-c4_defconfig +0 -0
index cc3d7fc7484..3c5e53828a1 100644

configs/odroid-c4_defconfig CONFIG_USB_DWC3=y · line 70

Quoted 7 lines
configs/odroid-c4_defconfig +1 -0
@@ -64,6 +64,7 @@ CONFIG_USB_DWC3=y
  # CONFIG_USB_DWC3_GADGET is not set
  CONFIG_USB_DWC3_MESON_G12A=y
  CONFIG_USB_KEYBOARD=y
+CONFIG_USB_ONBOARD_HUB=y
  CONFIG_USB_GADGET=y
  CONFIG_USB_GADGET_VENDOR_NUM=0x1b8e
  CONFIG_USB_GADGET_PRODUCT_NUM=0xfada

Same as patch 2, with that fixed:

#15 lore raw

Re: [RFC v1 7/7] usb: onboard-hub: Add conditional compilation for I2C initialization

In reply to Anand Moon
Quoted 42 lines · Anand Moon

Add conditional compilation for the usb5744_i2c_init() function based on the CONFIG_DM_I2C configuration, to avoid compilation failure.

   CC      net/net-common.o
   AR      net/built-in.o
   LDS     u-boot.lds
   LD      u-boot

aarch64-linux-gnu-ld.bfd: common/usb_onboard_hub.o: in function `usb5744_i2c_init':
/home/amoon/mainline/u-boot/amlogic/u-boot-maineline/common/usb_onboard_hub.c:74:(.text.usb5744_i2c_init+0xfc): undefined reference to i2c_get_chip' aarch64-linux-gnu-ld.bfd: /home/amoon/mainline/u-boot/amlogic/u-boot-maineline/common/usb_onboard_hub.c:89:(.text.usb5744_i2c_init+0x1a0): undefined reference to dm_i2c_write' aarch64-linux-gnu-ld.bfd: /home/amoon/mainline/u-boot/amlogic/u-boot-maineline/common/usb_onboard_hub.c:96:(.text.usb5744_i2c_init+0x1c8): undefined reference to dm_i2c_write' aarch64-linux-gnu-ld.bfd: /home/amoon/mainline/u-boot/amlogic/u-boot-maineline/common/usb_onboard_hub.c:104:(.text.usb5744_i2c_init+0x1f0): undefined reference to dm_i2c_write' Segmentation fault (core dumped)
make: *** [Makefile:1824: u-boot] Error 139
make: *** Deleting file 'u-boot'

---
  common/usb_onboard_hub.c | 4 ++++
  1 file changed, 4 insertions(+)
common/usb_onboard_hub.c +2 -0
index 1242513c631..92e3f3a92c9 100644
@@ -30,6 +30,7 @@ struct onboard_hub_data {
  	int (*init)(struct udevice *dev);
  };
 
+#if CONFIG_IS_ENABLED(DM_I2C)
  static int usb5744_i2c_init(struct udevice *dev)
  {
  	/*
@@ -109,6 +110,7 @@ static int usb5744_i2c_init(struct udevice *dev)
 
  	return 0;
  }
+#endif
 
  int usb_onboard_hub_reset(struct udevice *dev)
  {

common/usb_onboard_hub.c static const struct onboard_hub_data usb2514_data = { · line 232

Quoted 9 lines
common/usb_onboard_hub.c +2 -0
@@ -222,7 +224,9 @@ static const struct onboard_hub_data usb2514_data = {
  };
 
  static const struct onboard_hub_data usb5744_data = {
+#if CONFIG_IS_ENABLED(DM_I2C)
  	.init = usb5744_i2c_init,
+#endif
  	.power_on_delay_us = 1000,
  	.reset_us = 5,
  };

I think you should completely disable usb5744_data in this case

Neil

Reviewed-by on v1 5/7
#11 lore raw

Re: [RFC v1 5/7] usb: onboard-hub: Add support for VL817 USB hub

In reply to Anand Moon
Quoted 42 lines · Anand Moon

Enable support for the Via labs VL817 USB2.0 and USB3.1 Hub on the Odroid C4. The Via labs VL817 USB driver activates the hub reset signal, which toggles the GPIO.

---
=> dm tree

  simple_bus   11  [ + ]   dwc3-meson-g12a       |   `-- usb@ffe09000
  usb_gadget    0  [   ]   dwc2-udc-otg          |       |-- usb@ff400000
  usb           0  [ + ]   xhci-dwc3             |       `-- usb@ff500000
  usb_hub       0  [ + ]   usb_hub               |           `-- usb_hub
  usb_hub       1  [ + ]   usb_hub               |               |-- usb_hub
  usb_mass_s    0  [ + ]   usb_mass_storage      |               |   `-- usb_mass_storage
  blk           2  [ + ]   usb_storage_blk       |               |       |-- usb_mass_storage.lun0
  partition     0  [ + ]   blk_partition         |               |       |   |-- usb_mass_storage.lun0:1
  partition     1  [ + ]   blk_partition         |               |       |   |-- usb_mass_storage.lun0:2
  partition     2  [ + ]   blk_partition         |               |       |   |-- usb_mass_storage.lun0:3
  partition     3  [ + ]   blk_partition         |               |       |   `-- usb_mass_storage.lun0:4
  bootdev       3  [   ]   usb_bootdev           |               |       `-- usb_mass_storage.lun0.bootdev
  usb_hub       2  [ + ]   usb_hub               |               `-- usb_hub
---
  common/usb_onboard_hub.c | 10 ++++++++++
  1 file changed, 10 insertions(+)
common/usb_onboard_hub.c +4 -0
index 3914e2f773d..1242513c631 100644
@@ -235,6 +235,10 @@ static const struct onboard_hub_data genesys_gl853g_data = {
  	.reset_us = 50,
  };
 
+static const struct onboard_hub_data vialab_vl817_data = {
+	.reset_us = 10,
+};
+
  static const struct udevice_id usb_onboard_hub_ids[] = {
  	/* Use generic usbVID,PID dt-bindings (usb-device.yaml) */
  	{	.compatible = "usb424,2514",	/* USB2514B USB 2.0 */
@@ -251,6 +255,12 @@ static const struct udevice_id usb_onboard_hub_ids[] = {
  	}, {
  		.compatible = "usb5e3,620",     /* GL852G USB 3.1 */

common/usb_onboard_hub.c static const struct udevice_id usb_onboard_hub_ids[] = { · line 266

Quoted 10 lines
common/usb_onboard_hub.c +6 -0
  		.data = (ulong)&genesys_gl853g_data,
+	}, {
+		.compatible = "usb2109,817",	/* Via labs VL817 2.0 */
+		.data = (ulong)&vialab_vl817_data,
+	}, {
+		.compatible = "usb2109,2817",	/* Via labs VL817 3.1 */
+		.data = (ulong)&vialab_vl817_data,
  	}
  };
 
Reviewed-by on v1 3/7
#7 lore raw

Re: [RFC v1 3/7] usb: onboard-hub: Add support for Genesys GL853G

In reply to Anand Moon
Quoted 39 lines · Anand Moon

Enable support for the Genesys GL853G USB2.0 and USB3.1 Hub on the Odroid N2 and N2-plus. The GL853G driver activates the hub reset signal, which toggles the GPIO.

---
=> dm tree

  simple_bus   11  [ + ]   dwc3-meson-g12a       |   `-- usb@ffe09000
  usb_gadget    0  [   ]   dwc2-udc-otg          |       |-- usb@ff400000
  usb           0  [ + ]   xhci-dwc3             |       `-- usb@ff500000
  usb_hub       0  [ + ]   usb_hub               |           `-- usb_hub
  usb_hub       1  [ + ]   usb_hub               |               |-- usb_hub
  usb_mass_s    0  [ + ]   usb_mass_storage      |               |   `-- usb_mass_storage
  blk           2  [ + ]   usb_storage_blk       |               |       |-- usb_mass_storage.lun0
  partition     0  [ + ]   blk_partition         |               |       |   `-- usb_mass_storage.lun0:1
  bootdev       3  [   ]   usb_bootdev           |               |       `-- usb_mass_storage.lun0.bootdev
  usb_hub       2  [ + ]   usb_hub               |               `-- usb_hub
  clk           2  [ + ]   fixed_clock           |-- xtal-clk
---
  common/usb_onboard_hub.c | 7 +++++++
  1 file changed, 7 insertions(+)
common/usb_onboard_hub.c +4 -0
index 39bbc1aefa2..3914e2f773d 100644
@@ -231,6 +231,10 @@ static const struct onboard_hub_data genesys_gl852g_data = {
  	.reset_us = 50,
  };
 
+static const struct onboard_hub_data genesys_gl853g_data = {
+	.reset_us = 50,
+};
+
  static const struct udevice_id usb_onboard_hub_ids[] = {
  	/* Use generic usbVID,PID dt-bindings (usb-device.yaml) */
  	{	.compatible = "usb424,2514",	/* USB2514B USB 2.0 */

common/usb_onboard_hub.c static const struct udevice_id usb_onboard_hub_ids[] = { · line 256

Quoted 9 lines
common/usb_onboard_hub.c +3 -0
@@ -244,6 +248,9 @@ static const struct udevice_id usb_onboard_hub_ids[] = {
  	}, {
  		.compatible = "usb5e3,610",     /* GL852G USB 2.0 */
  		.data = (ulong)&genesys_gl852g_data,
+	}, {
+		.compatible = "usb5e3,620",     /* GL852G USB 3.1 */
+		.data = (ulong)&genesys_gl853g_data,
  	}
  };
 
author
#5 lore raw

Re: [RFC v1 2/7] configs: odorid-c2: Enable Onboard HUB driver

In reply to Neil Armstrong

Hi Neil,

Quoted 3 lines · Neil Armstrong

s/odorid-c2/odroid-c2/ in the subject

Oops, I will fix this in the next version.

Quoted 23 lines · Anand Moon
Quoted 13 lines

Enable the onboard USB HUB driver to power the
USB_HUB_GL852G-OHG on the Odroid C2.

---
  configs/odroid-c2_defconfig | 1 +
  1 file changed, 1 insertion(+)
configs/odroid-c2_defconfig +0 -0
index bcaab46f8bc..f8a66a923c9 100644

configs/odroid-c2_defconfig CONFIG_SYSINFO_SMBIOS=y · line 65

Quoted 7 lines
configs/odroid-c2_defconfig +1 -0
@@ -59,6 +59,7 @@ CONFIG_SYSINFO_SMBIOS=y
  CONFIG_USB=y
  CONFIG_USB_DWC2=y
  CONFIG_USB_KEYBOARD=y
+CONFIG_USB_ONBOARD_HUB=y
  CONFIG_VIDEO=y
  # CONFIG_VIDEO_BPP8 is not set
  # CONFIG_VIDEO_BPP16 is not set

With that fixed:

Quoted 1 line

Thanks
-Anand

author
#16 lore raw

Re: [RFC v1 7/7] usb: onboard-hub: Add conditional compilation for I2C initialization

In reply to Neil Armstrong

Hi Neil,

Quoted 46 lines · Neil Armstrong
Quoted 44 lines · Anand Moon

Add conditional compilation for the usb5744_i2c_init() function based on the CONFIG_DM_I2C configuration, to avoid compilation failure.

   CC      net/net-common.o
   AR      net/built-in.o
   LDS     u-boot.lds
   LD      u-boot

aarch64-linux-gnu-ld.bfd: common/usb_onboard_hub.o: in function `usb5744_i2c_init':
/home/amoon/mainline/u-boot/amlogic/u-boot-maineline/common/usb_onboard_hub.c:74:(.text.usb5744_i2c_init+0xfc): undefined reference to i2c_get_chip' aarch64-linux-gnu-ld.bfd: /home/amoon/mainline/u-boot/amlogic/u-boot-maineline/common/usb_onboard_hub.c:89:(.text.usb5744_i2c_init+0x1a0): undefined reference to dm_i2c_write' aarch64-linux-gnu-ld.bfd: /home/amoon/mainline/u-boot/amlogic/u-boot-maineline/common/usb_onboard_hub.c:96:(.text.usb5744_i2c_init+0x1c8): undefined reference to dm_i2c_write' aarch64-linux-gnu-ld.bfd: /home/amoon/mainline/u-boot/amlogic/u-boot-maineline/common/usb_onboard_hub.c:104:(.text.usb5744_i2c_init+0x1f0): undefined reference to dm_i2c_write' Segmentation fault (core dumped)
make: *** [Makefile:1824: u-boot] Error 139
make: *** Deleting file 'u-boot'

---
  common/usb_onboard_hub.c | 4 ++++
  1 file changed, 4 insertions(+)
common/usb_onboard_hub.c +2 -0
index 1242513c631..92e3f3a92c9 100644
@@ -30,6 +30,7 @@ struct onboard_hub_data {
      int (*init)(struct udevice *dev);
  };
 
+#if CONFIG_IS_ENABLED(DM_I2C)
  static int usb5744_i2c_init(struct udevice *dev)
  {
      /*
@@ -109,6 +110,7 @@ static int usb5744_i2c_init(struct udevice *dev)
 
      return 0;
  }
+#endif
 
  int usb_onboard_hub_reset(struct udevice *dev)
  {
@@ -222,7 +224,9 @@ static const struct onboard_hub_data usb2514_data = {
  };
 
Quoted 10 lines

common/usb_onboard_hub.c static const struct onboard_hub_data usb2514_data = { · line 232

Quoted 7 lines
common/usb_onboard_hub.c +2 -0
  static const struct onboard_hub_data usb5744_data = {
+#if CONFIG_IS_ENABLED(DM_I2C)
      .init = usb5744_i2c_init,
+#endif
      .power_on_delay_us = 1000,
      .reset_us = 5,
  };

I think you should completely disable usb5744_data in this case

Let me check this. I will update it in the next version.

Quoted 1 line

Neil

Thanks
-Anand

#17 lore raw

Re: [RFC v1 7/7] usb: onboard-hub: Add conditional compilation for I2C initialization

In reply to Neil Armstrong

Hi Neil, Anand,

Quoted 42 lines · Neil Armstrong
Quoted 41 lines · Anand Moon

Add conditional compilation for the usb5744_i2c_init() function based on the CONFIG_DM_I2C configuration, to avoid compilation failure.

   CC      net/net-common.o
   AR      net/built-in.o
   LDS     u-boot.lds
   LD      u-boot
aarch64-linux-gnu-ld.bfd: common/usb_onboard_hub.o: in function `usb5744_i2c_init':
/home/amoon/mainline/u-boot/amlogic/u-boot-maineline/common/ usb_onboard_hub.c:74:(.text.usb5744_i2c_init+0xfc): undefined reference to i2c_get_chip' aarch64-linux-gnu-ld.bfd: /home/amoon/mainline/u-boot/amlogic/u-boot- maineline/common/usb_onboard_hub.c:89:(.text.usb5744_i2c_init+0x1a0): undefined reference to dm_i2c_write' aarch64-linux-gnu-ld.bfd: /home/amoon/mainline/u-boot/amlogic/u-boot- maineline/common/usb_onboard_hub.c:96:(.text.usb5744_i2c_init+0x1c8): undefined reference to dm_i2c_write' aarch64-linux-gnu-ld.bfd: /home/amoon/mainline/u-boot/amlogic/u-boot- maineline/common/usb_onboard_hub.c:104:(.text.usb5744_i2c_init+0x1f0): undefined reference to dm_i2c_write' Segmentation fault (core dumped)
make: *** [Makefile:1824: u-boot] Error 139
make: *** Deleting file 'u-boot'

---
  common/usb_onboard_hub.c | 4 ++++

  1 file changed, 4 insertions(+)
common/usb_onboard_hub.c +2 -0
index 1242513c631..92e3f3a92c9 100644
@@ -30,6 +30,7 @@ struct onboard_hub_data {
       int (*init)(struct udevice *dev);
   };
+#if CONFIG_IS_ENABLED(DM_I2C)
   static int usb5744_i2c_init(struct udevice *dev)
   {
       /*
@@ -109,6 +110,7 @@ static int usb5744_i2c_init(struct udevice *dev)
       return 0;
   }
+#endif
   int usb_onboard_hub_reset(struct udevice *dev)
   {
@@ -222,7 +224,9 @@ static const struct onboard_hub_data usb2514_data = {
   };
   static const struct onboard_hub_data usb5744_data = {
Quoted 9 lines

common/usb_onboard_hub.c static const struct onboard_hub_data usb2514_data = { · line 232

Quoted 6 lines
common/usb_onboard_hub.c +2 -0
+#if CONFIG_IS_ENABLED(DM_I2C)
       .init = usb5744_i2c_init,
+#endif
       .power_on_delay_us = 1000,
       .reset_us = 5,
   };

I think you should completely disable usb5744_data in this case

I would recommend to go the same route as the Linux kernel which has a special Kconfig option for it, c.f. USB_ONBOARD_DEV_USB5744 which adds the necessary dependencies.

We probably should be careful and figure out which boards are actually using the usb5744 and add this symbol to their defconfig so they don't regress.

Cheers,
Quentin

author
#18 lore raw

Re: [RFC v1 7/7] usb: onboard-hub: Add conditional compilation for I2C initialization

Hi Quentin,

Quoted 65 lines · Quentin Schulz

Hi Neil, Anand,

Quoted 51 lines · Neil Armstrong
Quoted 50 lines · Anand Moon

Add conditional compilation for the usb5744_i2c_init() function based on the CONFIG_DM_I2C configuration, to avoid compilation failure.

   CC      net/net-common.o
   AR      net/built-in.o
   LDS     u-boot.lds
   LD      u-boot

aarch64-linux-gnu-ld.bfd: common/usb_onboard_hub.o: in function `usb5744_i2c_init':
/home/amoon/mainline/u-boot/amlogic/u-boot-maineline/common/ usb_onboard_hub.c:74:(.text.usb5744_i2c_init+0xfc): undefined reference to `i2c_get_chip'
aarch64-linux-gnu-ld.bfd: /home/amoon/mainline/u-boot/amlogic/u-boot- maineline/common/usb_onboard_hub.c:89:(.text.usb5744_i2c_init+0x1a0):
undefined reference to `dm_i2c_write' aarch64-linux-gnu-ld.bfd: /home/amoon/mainline/u-boot/amlogic/u-boot- maineline/common/usb_onboard_hub.c:96:(.text.usb5744_i2c_init+0x1c8):
undefined reference to `dm_i2c_write' aarch64-linux-gnu-ld.bfd: /home/amoon/mainline/u-boot/amlogic/u-boot- maineline/common/usb_onboard_hub.c:104:(.text.usb5744_i2c_init+0x1f0):
undefined reference to `dm_i2c_write'
Segmentation fault (core dumped)
make: *** [Makefile:1824: u-boot] Error 139
make: *** Deleting file 'u-boot'

---
  common/usb_onboard_hub.c | 4 ++++
  1 file changed, 4 insertions(+)
common/usb_onboard_hub.c +2 -0
index 1242513c631..92e3f3a92c9 100644
@@ -30,6 +30,7 @@ struct onboard_hub_data {
      int (*init)(struct udevice *dev);
  };
+#if CONFIG_IS_ENABLED(DM_I2C)
  static int usb5744_i2c_init(struct udevice *dev)
  {
      /*
@@ -109,6 +110,7 @@ static int usb5744_i2c_init(struct udevice *dev)
      return 0;
  }
+#endif
  int usb_onboard_hub_reset(struct udevice *dev)
  {
@@ -222,7 +224,9 @@ static const struct onboard_hub_data usb2514_data = {
  };
  static const struct onboard_hub_data usb5744_data = {
Quoted 9 lines

common/usb_onboard_hub.c static const struct onboard_hub_data usb2514_data = { · line 232

Quoted 6 lines
common/usb_onboard_hub.c +2 -0
+#if CONFIG_IS_ENABLED(DM_I2C)
      .init = usb5744_i2c_init,
+#endif
      .power_on_delay_us = 1000,
      .reset_us = 5,
  };

I think you should completely disable usb5744_data in this case

Quoted 4 lines

I would recommend to go the same route as the Linux kernel which has a special Kconfig option for it, c.f. USB_ONBOARD_DEV_USB5744 which adds the necessary dependencies.

On Linux kernel, it needs to parse the device node with i2c-bus.

Quoted 4 lines

We probably should be careful and figure out which boards are actually using the usb5744 and add this symbol to their defconfig so they don't regress.

From my initial analysis configs/xilinx_zynqmp_kria_defconfig which use CONFIG_USB_ONBOARD_HUB
I believe using DM_I2C to guard the code is the best approach. it should be around .init() callback to guard this to work.

Quoted 2 lines

Cheers,
Quentin

Thanks
-Anand

#19 lore raw

Re: [RFC v1 7/7] usb: onboard-hub: Add conditional compilation for I2C initialization

Hi Anand,

Quoted 68 lines · Anand Moon

Hi Quentin,

Quoted 65 lines · Quentin Schulz

Hi Neil, Anand,

Quoted 60 lines · Neil Armstrong
Quoted 48 lines · Anand Moon

Add conditional compilation for the usb5744_i2c_init() function based on the CONFIG_DM_I2C configuration, to avoid compilation failure.

    CC      net/net-common.o
    AR      net/built-in.o
    LDS     u-boot.lds
    LD      u-boot

aarch64-linux-gnu-ld.bfd: common/usb_onboard_hub.o: in function `usb5744_i2c_init':
/home/amoon/mainline/u-boot/amlogic/u-boot-maineline/common/ usb_onboard_hub.c:74:(.text.usb5744_i2c_init+0xfc): undefined reference to `i2c_get_chip'
aarch64-linux-gnu-ld.bfd: /home/amoon/mainline/u-boot/amlogic/u-boot- maineline/common/usb_onboard_hub.c:89:(.text.usb5744_i2c_init+0x1a0):
undefined reference to `dm_i2c_write' aarch64-linux-gnu-ld.bfd: /home/amoon/mainline/u-boot/amlogic/u-boot- maineline/common/usb_onboard_hub.c:96:(.text.usb5744_i2c_init+0x1c8):
undefined reference to `dm_i2c_write' aarch64-linux-gnu-ld.bfd: /home/amoon/mainline/u-boot/amlogic/u-boot- maineline/common/usb_onboard_hub.c:104:(.text.usb5744_i2c_init+0x1f0):
undefined reference to `dm_i2c_write'
Segmentation fault (core dumped)
make: *** [Makefile:1824: u-boot] Error 139
make: *** Deleting file 'u-boot'

---
   common/usb_onboard_hub.c | 4 ++++
   1 file changed, 4 insertions(+)
common/usb_onboard_hub.c +2 -0
index 1242513c631..92e3f3a92c9 100644
@@ -30,6 +30,7 @@ struct onboard_hub_data {
       int (*init)(struct udevice *dev);
   };
+#if CONFIG_IS_ENABLED(DM_I2C)
   static int usb5744_i2c_init(struct udevice *dev)
   {
       /*
@@ -109,6 +110,7 @@ static int usb5744_i2c_init(struct udevice *dev)
       return 0;
   }
+#endif
   int usb_onboard_hub_reset(struct udevice *dev)
   {

common/usb_onboard_hub.c static const struct onboard_hub_data usb2514_data = { · line 231

Quoted 8 lines
common/usb_onboard_hub.c +2 -0
@@ -222,7 +224,9 @@ static const struct onboard_hub_data usb2514_data = {
   };
   static const struct onboard_hub_data usb5744_data = {
+#if CONFIG_IS_ENABLED(DM_I2C)
       .init = usb5744_i2c_init,
+#endif
       .power_on_delay_us = 1000,
       .reset_us = 5,
   };

I think you should completely disable usb5744_data in this case

Quoted 6 lines
Quoted 4 lines

I would recommend to go the same route as the Linux kernel which has a special Kconfig option for it, c.f. USB_ONBOARD_DEV_USB5744 which adds the necessary dependencies.

On Linux kernel, it needs to parse the device node with i2c-bus.

Seems like it does in U-Boot too? c.f. usb5744_i2c_init() with dev_read_phandle_with_args with i2c-bus?

Quoted 9 lines
Quoted 4 lines

We probably should be careful and figure out which boards are actually using the usb5744 and add this symbol to their defconfig so they don't regress.

From my initial analysis configs/xilinx_zynqmp_kria_defconfig
which use CONFIG_USB_ONBOARD_HUB
I believe using DM_I2C to guard the code is the best approach. it should be around .init() callback to guard this to work.

I disagree. The driver clearly supports the USB5744 and the driver is compiled regardless of DM_I2C support which is required (as far as I understood, maybe that's incorrect?) for being able to use USB5744? I don't like hidden dependencies.

Also, I believe Neil's point is we shouldn't try to probe the USB5744 if there is no DM_I2C support, simply excluding .init() callback will probably just render this "support" of USB5744 non-functional?

Cheers,
Quentin

Quoted 4 lines
Quoted 2 lines

Cheers,
Quentin

Thanks
-Anand

author
#20 lore raw

Re: [RFC v1 7/7] usb: onboard-hub: Add conditional compilation for I2C initialization

Hi Quentin,

Quoted 76 lines · Quentin Schulz

Hi Anand,

Quoted 72 lines · Anand Moon

Hi Quentin,

Quoted 69 lines · Quentin Schulz

Hi Neil, Anand,

Quoted 51 lines · Neil Armstrong
Quoted 50 lines · Anand Moon

Add conditional compilation for the usb5744_i2c_init() function based on the CONFIG_DM_I2C configuration, to avoid compilation failure.

    CC      net/net-common.o
    AR      net/built-in.o
    LDS     u-boot.lds
    LD      u-boot

aarch64-linux-gnu-ld.bfd: common/usb_onboard_hub.o: in function `usb5744_i2c_init':
/home/amoon/mainline/u-boot/amlogic/u-boot-maineline/common/ usb_onboard_hub.c:74:(.text.usb5744_i2c_init+0xfc): undefined reference to `i2c_get_chip'
aarch64-linux-gnu-ld.bfd: /home/amoon/mainline/u-boot/amlogic/u-boot- maineline/common/usb_onboard_hub.c:89:(.text.usb5744_i2c_init+0x1a0):
undefined reference to `dm_i2c_write' aarch64-linux-gnu-ld.bfd: /home/amoon/mainline/u-boot/amlogic/u-boot- maineline/common/usb_onboard_hub.c:96:(.text.usb5744_i2c_init+0x1c8):
undefined reference to `dm_i2c_write' aarch64-linux-gnu-ld.bfd: /home/amoon/mainline/u-boot/amlogic/u-boot- maineline/common/usb_onboard_hub.c:104:(.text.usb5744_i2c_init+0x1f0):
undefined reference to `dm_i2c_write'
Segmentation fault (core dumped)
make: *** [Makefile:1824: u-boot] Error 139
make: *** Deleting file 'u-boot'

---
   common/usb_onboard_hub.c | 4 ++++
   1 file changed, 4 insertions(+)
common/usb_onboard_hub.c +2 -0
index 1242513c631..92e3f3a92c9 100644
@@ -30,6 +30,7 @@ struct onboard_hub_data {
       int (*init)(struct udevice *dev);
   };
+#if CONFIG_IS_ENABLED(DM_I2C)
   static int usb5744_i2c_init(struct udevice *dev)
   {
       /*
@@ -109,6 +110,7 @@ static int usb5744_i2c_init(struct udevice *dev)
       return 0;
   }
+#endif
   int usb_onboard_hub_reset(struct udevice *dev)
   {
@@ -222,7 +224,9 @@ static const struct onboard_hub_data usb2514_data = {
   };
   static const struct onboard_hub_data usb5744_data = {
Quoted 9 lines

common/usb_onboard_hub.c static const struct onboard_hub_data usb2514_data = { · line 232

Quoted 6 lines
common/usb_onboard_hub.c +2 -0
+#if CONFIG_IS_ENABLED(DM_I2C)
       .init = usb5744_i2c_init,
+#endif
       .power_on_delay_us = 1000,
       .reset_us = 5,
   };

I think you should completely disable usb5744_data in this case

I would recommend to go the same route as the Linux kernel which has a special Kconfig option for it, c.f. USB_ONBOARD_DEV_USB5744 which adds the necessary dependencies.

Quoted 6 lines
Quoted 2 lines

On Linux kernel, it needs to parse the device node with i2c-bus.

Seems like it does in U-Boot too? c.f. usb5744_i2c_init() with dev_read_phandle_with_args with i2c-bus?

ok.

Quoted 10 lines
Quoted 9 lines
Quoted 4 lines

We probably should be careful and figure out which boards are actually using the usb5744 and add this symbol to their defconfig so they don't regress.

From my initial analysis configs/xilinx_zynqmp_kria_defconfig
which use CONFIG_USB_ONBOARD_HUB
I believe using DM_I2C to guard the code is the best approach. it should be around .init() callback to guard this to work.

Quoted 5 lines

I disagree. The driver clearly supports the USB5744 and the driver is compiled regardless of DM_I2C support which is required (as far as I understood, maybe that's incorrect?) for being able to use USB5744? I don't like hidden dependencies.

Okay, I will add a new configuration option to guard the code as done in the Linux kernel.

Quoted 4 lines

Also, I believe Neil's point is we shouldn't try to probe the USB5744 if there is no DM_I2C support, simply excluding .init() callback will probably just render this "support" of USB5744 non-functional?

Let me debug this more, I will update the next version. I need to check if this binds correctly to the USB hub reset.

Quoted 2 lines

Cheers,
Quentin

Thanks
-Anand

author
#22 lore raw

Re: [RFC v1 7/7] usb: onboard-hub: Add conditional compilation for I2C initialization

In reply to a message not in the archive

Hi All,

Quoted 102 lines · Anand Moon via groups.io

Hi Quentin,

Quoted 76 lines · Quentin Schulz

Hi Anand,

Quoted 72 lines · Anand Moon

Hi Quentin,

Quoted 69 lines · Quentin Schulz

Hi Neil, Anand,

Quoted 51 lines · Neil Armstrong
Quoted 50 lines · Anand Moon

Add conditional compilation for the usb5744_i2c_init() function based on the CONFIG_DM_I2C configuration, to avoid compilation failure.

    CC      net/net-common.o
    AR      net/built-in.o
    LDS     u-boot.lds
    LD      u-boot

aarch64-linux-gnu-ld.bfd: common/usb_onboard_hub.o: in function `usb5744_i2c_init':
/home/amoon/mainline/u-boot/amlogic/u-boot-maineline/common/ usb_onboard_hub.c:74:(.text.usb5744_i2c_init+0xfc): undefined reference to `i2c_get_chip'
aarch64-linux-gnu-ld.bfd: /home/amoon/mainline/u-boot/amlogic/u-boot- maineline/common/usb_onboard_hub.c:89:(.text.usb5744_i2c_init+0x1a0):
undefined reference to `dm_i2c_write' aarch64-linux-gnu-ld.bfd: /home/amoon/mainline/u-boot/amlogic/u-boot- maineline/common/usb_onboard_hub.c:96:(.text.usb5744_i2c_init+0x1c8):
undefined reference to `dm_i2c_write' aarch64-linux-gnu-ld.bfd: /home/amoon/mainline/u-boot/amlogic/u-boot- maineline/common/usb_onboard_hub.c:104:(.text.usb5744_i2c_init+0x1f0):
undefined reference to `dm_i2c_write'
Segmentation fault (core dumped)
make: *** [Makefile:1824: u-boot] Error 139
make: *** Deleting file 'u-boot'

---
   common/usb_onboard_hub.c | 4 ++++
   1 file changed, 4 insertions(+)
common/usb_onboard_hub.c +2 -0
index 1242513c631..92e3f3a92c9 100644
@@ -30,6 +30,7 @@ struct onboard_hub_data {
       int (*init)(struct udevice *dev);
   };
+#if CONFIG_IS_ENABLED(DM_I2C)
   static int usb5744_i2c_init(struct udevice *dev)
   {
       /*
@@ -109,6 +110,7 @@ static int usb5744_i2c_init(struct udevice *dev)
       return 0;
   }
+#endif
   int usb_onboard_hub_reset(struct udevice *dev)
   {
@@ -222,7 +224,9 @@ static const struct onboard_hub_data usb2514_data = {
   };
   static const struct onboard_hub_data usb5744_data = {
Quoted 9 lines

common/usb_onboard_hub.c static const struct onboard_hub_data usb2514_data = { · line 232

Quoted 6 lines
common/usb_onboard_hub.c +2 -0
+#if CONFIG_IS_ENABLED(DM_I2C)
       .init = usb5744_i2c_init,
+#endif
       .power_on_delay_us = 1000,
       .reset_us = 5,
   };

I think you should completely disable usb5744_data in this case

I would recommend to go the same route as the Linux kernel which has a special Kconfig option for it, c.f. USB_ONBOARD_DEV_USB5744 which adds the necessary dependencies.

Quoted 6 lines
Quoted 2 lines

On Linux kernel, it needs to parse the device node with i2c-bus.

Seems like it does in U-Boot too? c.f. usb5744_i2c_init() with dev_read_phandle_with_args with i2c-bus?

ok.

Quoted 10 lines
Quoted 9 lines
Quoted 4 lines

We probably should be careful and figure out which boards are actually using the usb5744 and add this symbol to their defconfig so they don't regress.

From my initial analysis configs/xilinx_zynqmp_kria_defconfig
which use CONFIG_USB_ONBOARD_HUB
I believe using DM_I2C to guard the code is the best approach. it should be around .init() callback to guard this to work.

Quoted 5 lines

I disagree. The driver clearly supports the USB5744 and the driver is compiled regardless of DM_I2C support which is required (as far as I understood, maybe that's incorrect?) for being able to use USB5744? I don't like hidden dependencies.

Quoted 8 lines

Okay, I will add a new configuration option to guard the code as done in the Linux kernel.

Quoted 4 lines

Also, I believe Neil's point is we shouldn't try to probe the USB5744 if there is no DM_I2C support, simply excluding .init() callback will probably just render this "support" of USB5744 non-functional?

Let me debug this more, I will update the next version. I need to check if this binds correctly to the USB hub reset.

I am trying to get the usb_onboard_hub to bind. but this driver is not getting probed in the first place, I am missing some configuration to get this working.

Hit any key to stop autoboot: 0
=> usb start
starting USB...
Register 3000140 NbrPorts 3
Starting the controller
USB XHCI 1.10
Bus usb@ff500000: 4 USB Device(s) found
scanning usb for storage devices... 1 Storage Device(s) found
=> dm tree
...
mmc 1 [ + ] meson_gx_mmc | |-- mmc@ffe07000

 blk           1  [   ]   mmc_blk               |   |   |-- [email protected]
 bootdev       2  [   ]   mmc_bootdev           |   |   `-- [email protected]
 simple_bus   11  [ + ]   dwc3-meson-g12a       |   `-- usb@ffe09000
 usb_gadget    0  [   ]   dwc2-udc-otg          |       |-- usb@ff400000
 usb           0  [ + ]   xhci-dwc3             |       `-- usb@ff500000
 usb_hub       0  [ + ]   usb_hub               |           `-- usb_hub
 usb_hub       1  [ + ]   usb_hub               |               |-- usb_hub
 usb_hub       2  [ + ]   usb_hub               |               `-- usb_hub
 usb_mass_s    0  [ + ]   usb_mass_storage      |

`-- usb_mass_storage
blk 2 [ + ] usb_storage_blk |
|-- usb_mass_storage.lun0
partition 0 [ + ] blk_partition |
| `-- usb_mass_storage.lun0:1
bootdev 3 [ ] usb_bootdev |
`-- usb_mass_storage.lun0.bootdev
clk 2 [ + ] fixed_clock |-- xtal-clk

Thanks
-Anand

#23 lore raw

Re: [RFC v1 7/7] usb: onboard-hub: Add conditional compilation for I2C initialization

Hi Anand,

Quoted 112 lines · Anand Moon

Hi All,

Quoted 108 lines · Anand Moon via groups.io

Hi Quentin,

Quoted 76 lines · Quentin Schulz

Hi Anand,

Quoted 72 lines · Anand Moon

Hi Quentin,

Quoted 69 lines · Quentin Schulz

Hi Neil, Anand,

Quoted 51 lines · Neil Armstrong
Quoted 50 lines · Anand Moon

Add conditional compilation for the usb5744_i2c_init() function based on the CONFIG_DM_I2C configuration, to avoid compilation failure.

     CC      net/net-common.o
     AR      net/built-in.o
     LDS     u-boot.lds
     LD      u-boot

aarch64-linux-gnu-ld.bfd: common/usb_onboard_hub.o: in function `usb5744_i2c_init':
/home/amoon/mainline/u-boot/amlogic/u-boot-maineline/common/ usb_onboard_hub.c:74:(.text.usb5744_i2c_init+0xfc): undefined reference to `i2c_get_chip'
aarch64-linux-gnu-ld.bfd: /home/amoon/mainline/u-boot/amlogic/u-boot- maineline/common/usb_onboard_hub.c:89:(.text.usb5744_i2c_init+0x1a0):
undefined reference to `dm_i2c_write' aarch64-linux-gnu-ld.bfd: /home/amoon/mainline/u-boot/amlogic/u-boot- maineline/common/usb_onboard_hub.c:96:(.text.usb5744_i2c_init+0x1c8):
undefined reference to `dm_i2c_write' aarch64-linux-gnu-ld.bfd: /home/amoon/mainline/u-boot/amlogic/u-boot- maineline/common/usb_onboard_hub.c:104:(.text.usb5744_i2c_init+0x1f0):
undefined reference to `dm_i2c_write'
Segmentation fault (core dumped)
make: *** [Makefile:1824: u-boot] Error 139
make: *** Deleting file 'u-boot'

---
    common/usb_onboard_hub.c | 4 ++++
    1 file changed, 4 insertions(+)
common/usb_onboard_hub.c +2 -0
index 1242513c631..92e3f3a92c9 100644
@@ -30,6 +30,7 @@ struct onboard_hub_data {
        int (*init)(struct udevice *dev);
    };
+#if CONFIG_IS_ENABLED(DM_I2C)
    static int usb5744_i2c_init(struct udevice *dev)
    {
        /*
@@ -109,6 +110,7 @@ static int usb5744_i2c_init(struct udevice *dev)
        return 0;
    }
+#endif
    int usb_onboard_hub_reset(struct udevice *dev)
    {
@@ -222,7 +224,9 @@ static const struct onboard_hub_data usb2514_data = {
    };
    static const struct onboard_hub_data usb5744_data = {
Quoted 9 lines

common/usb_onboard_hub.c static const struct onboard_hub_data usb2514_data = { · line 231

Quoted 6 lines
common/usb_onboard_hub.c +2 -0
+#if CONFIG_IS_ENABLED(DM_I2C)
        .init = usb5744_i2c_init,
+#endif
        .power_on_delay_us = 1000,
        .reset_us = 5,
    };

I think you should completely disable usb5744_data in this case

I would recommend to go the same route as the Linux kernel which has a special Kconfig option for it, c.f. USB_ONBOARD_DEV_USB5744 which adds the necessary dependencies.

Quoted 6 lines
Quoted 2 lines

On Linux kernel, it needs to parse the device node with i2c-bus.

Seems like it does in U-Boot too? c.f. usb5744_i2c_init() with dev_read_phandle_with_args with i2c-bus?

ok.

Quoted 10 lines
Quoted 9 lines
Quoted 4 lines

We probably should be careful and figure out which boards are actually using the usb5744 and add this symbol to their defconfig so they don't regress.

From my initial analysis configs/xilinx_zynqmp_kria_defconfig
which use CONFIG_USB_ONBOARD_HUB
I believe using DM_I2C to guard the code is the best approach. it should be around .init() callback to guard this to work.

Quoted 5 lines

I disagree. The driver clearly supports the USB5744 and the driver is compiled regardless of DM_I2C support which is required (as far as I understood, maybe that's incorrect?) for being able to use USB5744? I don't like hidden dependencies.

Okay, I will add a new configuration option to guard the code as done in the Linux kernel.

Quoted 4 lines

Also, I believe Neil's point is we shouldn't try to probe the USB5744 if there is no DM_I2C support, simply excluding .init() callback will probably just render this "support" of USB5744 non-functional?

Quoted 7 lines
Quoted 2 lines

Let me debug this more, I will update the next version. I need to check if this binds correctly to the USB hub reset.

I am trying to get the usb_onboard_hub to bind. but this driver is not getting probed in the first place, I am missing some configuration to get this working.

Don't know your setup, but maybe have a look at https://lore.kernel.org/u-boot/20250425-usb_onboard_hub_cypress_hx3-v1-1-3cc5a06087cf@thaumatec.com/ ?

Cheers,
Quentin

author
#24 lore raw

Re: [RFC v1 7/7] usb: onboard-hub: Add conditional compilation for I2C initialization

Hi Quentin,

Quoted 119 lines · Quentin Schulz

Hi Anand,

Quoted 115 lines · Anand Moon

Hi All,

Quoted 110 lines · Anand Moon via groups.io

Hi Quentin,

Quoted 76 lines · Quentin Schulz

Hi Anand,

Quoted 72 lines · Anand Moon

Hi Quentin,

Quoted 69 lines · Quentin Schulz

Hi Neil, Anand,

Quoted 51 lines · Neil Armstrong
Quoted 50 lines · Anand Moon

Add conditional compilation for the usb5744_i2c_init() function based on the CONFIG_DM_I2C configuration, to avoid compilation failure.

     CC      net/net-common.o
     AR      net/built-in.o
     LDS     u-boot.lds
     LD      u-boot

aarch64-linux-gnu-ld.bfd: common/usb_onboard_hub.o: in function `usb5744_i2c_init':
/home/amoon/mainline/u-boot/amlogic/u-boot-maineline/common/ usb_onboard_hub.c:74:(.text.usb5744_i2c_init+0xfc): undefined reference to `i2c_get_chip'
aarch64-linux-gnu-ld.bfd: /home/amoon/mainline/u-boot/amlogic/u-boot- maineline/common/usb_onboard_hub.c:89:(.text.usb5744_i2c_init+0x1a0):
undefined reference to `dm_i2c_write' aarch64-linux-gnu-ld.bfd: /home/amoon/mainline/u-boot/amlogic/u-boot- maineline/common/usb_onboard_hub.c:96:(.text.usb5744_i2c_init+0x1c8):
undefined reference to `dm_i2c_write' aarch64-linux-gnu-ld.bfd: /home/amoon/mainline/u-boot/amlogic/u-boot- maineline/common/usb_onboard_hub.c:104:(.text.usb5744_i2c_init+0x1f0):
undefined reference to `dm_i2c_write'
Segmentation fault (core dumped)
make: *** [Makefile:1824: u-boot] Error 139
make: *** Deleting file 'u-boot'

---
    common/usb_onboard_hub.c | 4 ++++
    1 file changed, 4 insertions(+)
common/usb_onboard_hub.c +2 -0
index 1242513c631..92e3f3a92c9 100644
@@ -30,6 +30,7 @@ struct onboard_hub_data {
        int (*init)(struct udevice *dev);
    };
+#if CONFIG_IS_ENABLED(DM_I2C)
    static int usb5744_i2c_init(struct udevice *dev)
    {
        /*
@@ -109,6 +110,7 @@ static int usb5744_i2c_init(struct udevice *dev)
        return 0;
    }
+#endif
    int usb_onboard_hub_reset(struct udevice *dev)
    {
@@ -222,7 +224,9 @@ static const struct onboard_hub_data usb2514_data = {
    };
    static const struct onboard_hub_data usb5744_data = {
Quoted 9 lines

common/usb_onboard_hub.c static const struct onboard_hub_data usb2514_data = { · line 231

Quoted 6 lines
common/usb_onboard_hub.c +2 -0
+#if CONFIG_IS_ENABLED(DM_I2C)
        .init = usb5744_i2c_init,
+#endif
        .power_on_delay_us = 1000,
        .reset_us = 5,
    };

I think you should completely disable usb5744_data in this case

I would recommend to go the same route as the Linux kernel which has a special Kconfig option for it, c.f. USB_ONBOARD_DEV_USB5744 which adds the necessary dependencies.

Quoted 6 lines
Quoted 2 lines

On Linux kernel, it needs to parse the device node with i2c-bus.

Seems like it does in U-Boot too? c.f. usb5744_i2c_init() with dev_read_phandle_with_args with i2c-bus?

ok.

Quoted 10 lines
Quoted 9 lines
Quoted 4 lines

We probably should be careful and figure out which boards are actually using the usb5744 and add this symbol to their defconfig so they don't regress.

From my initial analysis configs/xilinx_zynqmp_kria_defconfig
which use CONFIG_USB_ONBOARD_HUB
I believe using DM_I2C to guard the code is the best approach. it should be around .init() callback to guard this to work.

Quoted 5 lines

I disagree. The driver clearly supports the USB5744 and the driver is compiled regardless of DM_I2C support which is required (as far as I understood, maybe that's incorrect?) for being able to use USB5744? I don't like hidden dependencies.

Okay, I will add a new configuration option to guard the code as done in the Linux kernel.

Quoted 4 lines

Also, I believe Neil's point is we shouldn't try to probe the USB5744 if there is no DM_I2C support, simply excluding .init() callback will probably just render this "support" of USB5744 non-functional?

Let me debug this more, I will update the next version. I need to check if this binds correctly to the USB hub reset.

Quoted 8 lines
Quoted 4 lines

I am trying to get the usb_onboard_hub to bind. but this driver is not getting probed in the first place, I am missing some configuration to get this working.

Don't know your setup, but maybe have a look at
https://lore.kernel.org/u-boot/20250425-usb_onboard_hub_cypress_hx3-v1-1-3cc5a06087cf@thaumatec.com/
?

Thank you for the tip. I've incorporated all the changes as suggested in this series. However, I'm still unable to get the usb_onboard_hub_probe to execute, which is preventing me from further debugging.

Quoted 3 lines

Cheers,
Quentin

Thanks
-Anand

#25 lore raw

Re: [RFC v1 7/7] usb: onboard-hub: Add conditional compilation for I2C initialization

In reply to Quentin Schulz
Quoted 90 lines · Quentin Schulz

Hi Anand,

Quoted 68 lines · Anand Moon

Hi Quentin,

Quoted 65 lines · Quentin Schulz

Hi Neil, Anand,

Quoted 60 lines · Neil Armstrong
Quoted 48 lines · Anand Moon

Add conditional compilation for the usb5744_i2c_init() function based on the CONFIG_DM_I2C configuration, to avoid compilation failure.

    CC      net/net-common.o
    AR      net/built-in.o
    LDS     u-boot.lds
    LD      u-boot
aarch64-linux-gnu-ld.bfd: common/usb_onboard_hub.o: in function `usb5744_i2c_init':
/home/amoon/mainline/u-boot/amlogic/u-boot-maineline/common/ usb_onboard_hub.c:74:(.text.usb5744_i2c_init+0xfc): undefined reference to `i2c_get_chip'
aarch64-linux-gnu-ld.bfd: /home/amoon/mainline/u-boot/amlogic/u-boot- maineline/common/usb_onboard_hub.c:89:(.text.usb5744_i2c_init+0x1a0):
undefined reference to `dm_i2c_write' aarch64-linux-gnu-ld.bfd: /home/amoon/mainline/u-boot/amlogic/u-boot- maineline/common/usb_onboard_hub.c:96:(.text.usb5744_i2c_init+0x1c8):
undefined reference to `dm_i2c_write' aarch64-linux-gnu-ld.bfd: /home/amoon/mainline/u-boot/amlogic/u-boot- maineline/common/usb_onboard_hub.c:104:(.text.usb5744_i2c_init+0x1f0):
undefined reference to `dm_i2c_write'
Segmentation fault (core dumped)
make: *** [Makefile:1824: u-boot] Error 139
make: *** Deleting file 'u-boot'

---
   common/usb_onboard_hub.c | 4 ++++

   1 file changed, 4 insertions(+)
common/usb_onboard_hub.c +2 -0
index 1242513c631..92e3f3a92c9 100644
@@ -30,6 +30,7 @@ struct onboard_hub_data {
        int (*init)(struct udevice *dev);
    };
+#if CONFIG_IS_ENABLED(DM_I2C)
    static int usb5744_i2c_init(struct udevice *dev)
    {
        /*
@@ -109,6 +110,7 @@ static int usb5744_i2c_init(struct udevice *dev)
        return 0;
    }
+#endif
    int usb_onboard_hub_reset(struct udevice *dev)
    {

common/usb_onboard_hub.c static const struct onboard_hub_data usb2514_data = { · line 231

Quoted 8 lines
common/usb_onboard_hub.c +2 -0
@@ -222,7 +224,9 @@ static const struct onboard_hub_data usb2514_data = {
    };
    static const struct onboard_hub_data usb5744_data = {
+#if CONFIG_IS_ENABLED(DM_I2C)
        .init = usb5744_i2c_init,
+#endif
        .power_on_delay_us = 1000,
        .reset_us = 5,
    };

I think you should completely disable usb5744_data in this case

Quoted 6 lines
Quoted 4 lines

I would recommend to go the same route as the Linux kernel which has a special Kconfig option for it, c.f. USB_ONBOARD_DEV_USB5744 which adds the necessary dependencies.

On Linux kernel, it needs to parse the device node with i2c-bus.

Seems like it does in U-Boot too? c.f. usb5744_i2c_init() with dev_read_phandle_with_args with i2c-bus?

Quoted 9 lines
Quoted 4 lines

We probably should be careful and figure out which boards are actually using the usb5744 and add this symbol to their defconfig so they don't regress.

 From my initial analysis configs/xilinx_zynqmp_kria_defconfig which use CONFIG_USB_ONBOARD_HUB
I believe using DM_I2C to guard the code is the best approach. it should be around .init() callback to guard this to work.

Quoted 3 lines

I disagree. The driver clearly supports the USB5744 and the driver is compiled regardless of DM_I2C support which is required (as far as I understood, maybe that's incorrect?) for being able to use USB5744? I don't like hidden dependencies.

Also, I believe Neil's point is we shouldn't try to probe the USB5744 if there is no DM_I2C support, simply excluding .init() callback will probably just render this "support" of USB5744 non-functional?

USB5744 can be configured differently. We are using two configurations.
1. no initialization over i2c
(but still you can have a need to have driver for reset or power)
2. initialization over i2c to start the hub

And there is also one more configuration via SPI.

It means I don't think DM_I2C should be real dependency on getting usb5744 to operate.

Thanks,
Michal

#26 lore raw

Re: [RFC v1 7/7] usb: onboard-hub: Add conditional compilation for I2C initialization

Hi Michal,

Quoted 94 lines · Michal Simek
Quoted 91 lines · Quentin Schulz

Hi Anand,

Quoted 69 lines · Anand Moon

Hi Quentin,

Quoted 66 lines · Quentin Schulz

Hi Neil, Anand,

Quoted 61 lines · Neil Armstrong
Quoted 48 lines · Anand Moon

Add conditional compilation for the usb5744_i2c_init() function based on the CONFIG_DM_I2C configuration, to avoid compilation failure.

    CC      net/net-common.o
    AR      net/built-in.o
    LDS     u-boot.lds
    LD      u-boot
aarch64-linux-gnu-ld.bfd: common/usb_onboard_hub.o: in function `usb5744_i2c_init':
/home/amoon/mainline/u-boot/amlogic/u-boot-maineline/common/ usb_onboard_hub.c:74:(.text.usb5744_i2c_init+0xfc): undefined reference to `i2c_get_chip'
aarch64-linux-gnu-ld.bfd: /home/amoon/mainline/u-boot/amlogic/u-boot- maineline/common/usb_onboard_hub.c:89:(.text.usb5744_i2c_init+0x1a0):
undefined reference to `dm_i2c_write' aarch64-linux-gnu-ld.bfd: /home/amoon/mainline/u-boot/amlogic/u-boot- maineline/common/usb_onboard_hub.c:96:(.text.usb5744_i2c_init+0x1c8):
undefined reference to `dm_i2c_write' aarch64-linux-gnu-ld.bfd: /home/amoon/mainline/u-boot/amlogic/u-boot- maineline/common/usb_onboard_hub.c:104: (.text.usb5744_i2c_init+0x1f0):
undefined reference to `dm_i2c_write'
Segmentation fault (core dumped)
make: *** [Makefile:1824: u-boot] Error 139
make: *** Deleting file 'u-boot'

---
   common/usb_onboard_hub.c | 4 ++++

   1 file changed, 4 insertions(+)
common/usb_onboard_hub.c +2 -0
index 1242513c631..92e3f3a92c9 100644
@@ -30,6 +30,7 @@ struct onboard_hub_data {
        int (*init)(struct udevice *dev);
    };
+#if CONFIG_IS_ENABLED(DM_I2C)
    static int usb5744_i2c_init(struct udevice *dev)
    {
        /*
@@ -109,6 +110,7 @@ static int usb5744_i2c_init(struct udevice *dev)
        return 0;
    }
+#endif
    int usb_onboard_hub_reset(struct udevice *dev)
    {

common/usb_onboard_hub.c static const struct onboard_hub_data · line 232

Quoted 9 lines
common/usb_onboard_hub.c +2 -0
@@ -222,7 +224,9 @@ static const struct onboard_hub_data 
 usb2514_data = {
    };
    static const struct onboard_hub_data usb5744_data = {
+#if CONFIG_IS_ENABLED(DM_I2C)
        .init = usb5744_i2c_init,
+#endif
        .power_on_delay_us = 1000,
        .reset_us = 5,
    };

I think you should completely disable usb5744_data in this case

Quoted 6 lines
Quoted 4 lines

I would recommend to go the same route as the Linux kernel which has a special Kconfig option for it, c.f. USB_ONBOARD_DEV_USB5744 which adds the necessary dependencies.

On Linux kernel, it needs to parse the device node with i2c-bus.

Seems like it does in U-Boot too? c.f. usb5744_i2c_init() with dev_read_phandle_with_args with i2c-bus?

Quoted 9 lines
Quoted 4 lines

We probably should be careful and figure out which boards are actually using the usb5744 and add this symbol to their defconfig so they don't regress.

 From my initial analysis configs/xilinx_zynqmp_kria_defconfig which use CONFIG_USB_ONBOARD_HUB
I believe using DM_I2C to guard the code is the best approach. it should be around .init() callback to guard this to work.

Quoted 7 lines
Quoted 3 lines

I disagree. The driver clearly supports the USB5744 and the driver is compiled regardless of DM_I2C support which is required (as far as I understood, maybe that's incorrect?) for being able to use USB5744? I don't like hidden dependencies.

Also, I believe Neil's point is we shouldn't try to probe the USB5744 if there is no DM_I2C support, simply excluding .init() callback will probably just render this "support" of USB5744 non-functional?

USB5744 can be configured differently. We are using two configurations.
1. no initialization over i2c
(but still you can have a need to have driver for reset or power)

Fair enough, some hubs are configured "properly" by default so don't necessarily need an interface. Such is the case for the Cypress HX3 we use on RK3399 Puma for example. The default is enough so we don't need the i2c interface even though it's exposed by the IC. Thanks for the reminder.

Quoted 6 lines

2. initialization over i2c to start the hub

And there is also one more configuration via SPI.

It means I don't think DM_I2C should be real dependency on getting usb5744 to operate.

Would diverge from how it's handled in the kernel (today) though.

Can we please follow the same logic as in the kernel though? Meaning we should report some message if the i2c-bus property is present but DM_I2C is not enabled, in which case it's likely a misconfiguration of the bootloader.

Cheers,
Quentin

#27 lore raw

Re: [RFC v1 7/7] usb: onboard-hub: Add conditional compilation for I2C initialization

Quoted 108 lines · Quentin Schulz

Hi Michal,

Quoted 93 lines · Michal Simek
Quoted 90 lines · Quentin Schulz

Hi Anand,

Quoted 68 lines · Anand Moon

Hi Quentin,

Quoted 65 lines · Quentin Schulz

Hi Neil, Anand,

Quoted 60 lines · Neil Armstrong
Quoted 48 lines · Anand Moon

Add conditional compilation for the usb5744_i2c_init() function based on the CONFIG_DM_I2C configuration, to avoid compilation failure.

    CC      net/net-common.o
    AR      net/built-in.o
    LDS     u-boot.lds
    LD      u-boot
aarch64-linux-gnu-ld.bfd: common/usb_onboard_hub.o: in function `usb5744_i2c_init':
/home/amoon/mainline/u-boot/amlogic/u-boot-maineline/common/ usb_onboard_hub.c:74:(.text.usb5744_i2c_init+0xfc): undefined reference to `i2c_get_chip'
aarch64-linux-gnu-ld.bfd: /home/amoon/mainline/u-boot/amlogic/u-boot- maineline/common/usb_onboard_hub.c:89:(.text.usb5744_i2c_init+0x1a0):
undefined reference to `dm_i2c_write' aarch64-linux-gnu-ld.bfd: /home/amoon/mainline/u-boot/amlogic/u-boot- maineline/common/usb_onboard_hub.c:96:(.text.usb5744_i2c_init+0x1c8):
undefined reference to `dm_i2c_write' aarch64-linux-gnu-ld.bfd: /home/amoon/mainline/u-boot/amlogic/u-boot- maineline/common/usb_onboard_hub.c:104: (.text.usb5744_i2c_init+0x1f0):
undefined reference to `dm_i2c_write'
Segmentation fault (core dumped)
make: *** [Makefile:1824: u-boot] Error 139
make: *** Deleting file 'u-boot'

---
   common/usb_onboard_hub.c | 4 ++++

   1 file changed, 4 insertions(+)
common/usb_onboard_hub.c +2 -0
index 1242513c631..92e3f3a92c9 100644
@@ -30,6 +30,7 @@ struct onboard_hub_data {
        int (*init)(struct udevice *dev);
    };
+#if CONFIG_IS_ENABLED(DM_I2C)
    static int usb5744_i2c_init(struct udevice *dev)
    {
        /*
@@ -109,6 +110,7 @@ static int usb5744_i2c_init(struct udevice *dev)
        return 0;
    }
+#endif
    int usb_onboard_hub_reset(struct udevice *dev)
    {

common/usb_onboard_hub.c static const struct onboard_hub_data usb2514_data = { · line 231

Quoted 8 lines
common/usb_onboard_hub.c +2 -0
@@ -222,7 +224,9 @@ static const struct onboard_hub_data usb2514_data = {
    };
    static const struct onboard_hub_data usb5744_data = {
+#if CONFIG_IS_ENABLED(DM_I2C)
        .init = usb5744_i2c_init,
+#endif
        .power_on_delay_us = 1000,
        .reset_us = 5,
    };

I think you should completely disable usb5744_data in this case

Quoted 6 lines
Quoted 4 lines

I would recommend to go the same route as the Linux kernel which has a special Kconfig option for it, c.f. USB_ONBOARD_DEV_USB5744 which adds the necessary dependencies.

On Linux kernel, it needs to parse the device node with i2c-bus.

Seems like it does in U-Boot too? c.f. usb5744_i2c_init() with dev_read_phandle_with_args with i2c-bus?

Quoted 9 lines
Quoted 4 lines

We probably should be careful and figure out which boards are actually using the usb5744 and add this symbol to their defconfig so they don't regress.

 From my initial analysis configs/xilinx_zynqmp_kria_defconfig which use CONFIG_USB_ONBOARD_HUB
I believe using DM_I2C to guard the code is the best approach. it should be around .init() callback to guard this to work.

Quoted 7 lines
Quoted 3 lines

I disagree. The driver clearly supports the USB5744 and the driver is compiled regardless of DM_I2C support which is required (as far as I understood, maybe that's incorrect?) for being able to use USB5744? I don't like hidden dependencies.

Also, I believe Neil's point is we shouldn't try to probe the USB5744 if there is no DM_I2C support, simply excluding .init() callback will probably just render this "support" of USB5744 non-functional?

USB5744 can be configured differently. We are using two configurations.
1. no initialization over i2c
(but still you can have a need to have driver for reset or power)

Fair enough, some hubs are configured "properly" by default so don't necessarily need an interface. Such is the case for the Cypress HX3 we use on RK3399 Puma for example. The default is enough so we don't need the i2c interface even though it's exposed by the IC. Thanks for the reminder.

Quoted 2 lines

2. initialization over i2c to start the hub

Quoted 8 lines
Quoted 4 lines

And there is also one more configuration via SPI.

It means I don't think DM_I2C should be real dependency on getting usb5744 to operate.

Would diverge from how it's handled in the kernel (today) though.

Can we please follow the same logic as in the kernel though? Meaning we should report some message if the i2c-bus property is present but DM_I2C is not enabled, in which case it's likely a misconfiguration of the bootloader.

Make sense.

M