Skip to contentSkip to conversation

usb: onboard-hub: VL817 support for SpacemiT K1 boards

PATCH Superseded Hung-Chun Tseng 3 participants 7 messages Oct 26 – Oct 28 RISC-V SpacemiT SoC Support

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover usb: onboard-hub: VL817 support for SpacemiT K1 boards

The Milk-V Jupiter and the Banana Pi BPI-F3 put a VIA Labs VL817 hub in front of all their USB ports. Its supply and reset are GPIOs, so with the K1 USB support now in main, usb start only finds the root hub until someone powers the hub by hand.

This adds the VL817 to the onboard hub driver and enables it for K1.

Tested on a Milk-V Jupiter, cold boot from SD: usb start finds both VL817 hubs and a USB 3 stick at 5 Gb/s, with no manual GPIO setup. For that test, U-Boot was limited to 4 GiB of DRAM: on this 4 GB board it reports 8 GiB, and with the extra memory usb start hung after "efi_free_pool: illegal free 0x000000027fffa040". That is a separate K1 DRAM sizing bug; I will send a fix for it on its own.

Hung-Chun Tseng (2):
usb: onboard-hub: Add support for VIA Labs VL817
configs: spacemit_k1: Enable onboard USB hub support

 common/usb_onboard_hub.c      | 14 +++++++++++++-
 configs/spacemit_k1_defconfig |  1 +
 2 files changed, 14 insertions(+), 1 deletion(-)
Signature · 1 line
2.43.0
#1 lore raw

PATCH 1/2 usb: onboard-hub: Add support for VIA Labs VL817

The VL817 is a USB 3.1 Gen 1 hub controller with one supply and a reset pin. Use the same reset time as Linux.

The Milk-V Jupiter and the Banana Pi BPI-F3 have one in front of all their USB ports. Without this, U-Boot leaves the hub unpowered and in reset, so no USB device is found.

---
 common/usb_onboard_hub.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
common/usb_onboard_hub.c +13 -1
index 0684f7bfd..0ed70a6ba 100644
@@ -289,9 +289,21 @@ static const struct onboard_hub_data usbhx3_data = {
 	.supply_names = { "vdd-supply", "vdd2-supply" },
 };
 
+static const struct onboard_hub_data vialab_vl817_data = {
+	.reset_us = 10,
+	.num_supplies = 1,
+	.supply_names = { "vdd-supply" },
+};
+
 static const struct udevice_id usb_onboard_hub_ids[] = {
 	/* Use generic usbVID,PID dt-bindings (usb-device.yaml) */
-	{	.compatible = "usb3431,6241",	/* Corechips SL6341 USB 2.0 */
+	{	.compatible = "usb2109,2817",	/* VIA Labs VL817 USB 2.0 */
+		.data = (ulong)&vialab_vl817_data,
+	}, {
+		.compatible = "usb2109,817",	/* VIA Labs VL817 USB 3.0 */
+		.data = (ulong)&vialab_vl817_data,
+	}, {
+		.compatible = "usb3431,6241",	/* Corechips SL6341 USB 2.0 */
 		.data = (ulong)&corechips_sl6341_data,
 	}, {
 		.compatible = "usb3431,6341",	/* Corechips SL6341 USB 3.0 */
Signature · 1 line
2.43.0
Tested-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] usb: onboard-hub: Add support for VIA Labs VL817

Quoted 29 lines · Hung-Chun Tseng

The VL817 is a USB 3.1 Gen 1 hub controller with one supply and a reset pin. Use the same reset time as Linux.

The Milk-V Jupiter and the Banana Pi BPI-F3 have one in front of all their USB ports. Without this, U-Boot leaves the hub unpowered and in reset, so no USB device is found.

---
  common/usb_onboard_hub.c | 14 +++++++++++++-
  1 file changed, 13 insertions(+), 1 deletion(-)
common/usb_onboard_hub.c +6 -1
index 0684f7bfd..0ed70a6ba 100644
@@ -289,9 +289,21 @@ static const struct onboard_hub_data usbhx3_data = {
  	.supply_names = { "vdd-supply", "vdd2-supply" },
  };
 
+static const struct onboard_hub_data vialab_vl817_data = {
+	.reset_us = 10,
+	.num_supplies = 1,
+	.supply_names = { "vdd-supply" },
+};
+
  static const struct udevice_id usb_onboard_hub_ids[] = {
  	/* Use generic usbVID,PID dt-bindings (usb-device.yaml) */
-	{	.compatible = "usb3431,6241",	/* Corechips SL6341 USB 2.0 */

common/usb_onboard_hub.c static const struct onboard_hub_data usbhx3_data = { · line 309

Quoted 10 lines
common/usb_onboard_hub.c +7 -0
+	{	.compatible = "usb2109,2817",	/* VIA Labs VL817 USB 2.0 */
+		.data = (ulong)&vialab_vl817_data,
+	}, {
+		.compatible = "usb2109,817",	/* VIA Labs VL817 USB 3.0 */
+		.data = (ulong)&vialab_vl817_data,
+	}, {
+		.compatible = "usb3431,6241",	/* Corechips SL6341 USB 2.0 */
  		.data = (ulong)&corechips_sl6341_data,
  	}, {
  		.compatible = "usb3431,6341",	/* Corechips SL6341 USB 3.0 */

It’s similar to my local version :-)

Regards,
Zixian

#3 lore raw

Re: [PATCH 1/2] usb: onboard-hub: Add support for VIA Labs VL817

In reply to Hung-Chun Tseng
Quoted 23 lines · Hung-Chun Tseng

The VL817 is a USB 3.1 Gen 1 hub controller with one supply and a reset pin. Use the same reset time as Linux.

The Milk-V Jupiter and the Banana Pi BPI-F3 have one in front of all their USB ports. Without this, U-Boot leaves the hub unpowered and in reset, so no USB device is found.

---
  common/usb_onboard_hub.c | 14 +++++++++++++-
  1 file changed, 13 insertions(+), 1 deletion(-)
common/usb_onboard_hub.c +3 -0
index 0684f7bfd..0ed70a6ba 100644
@@ -289,9 +289,21 @@ static const struct onboard_hub_data usbhx3_data = {
  	.supply_names = { "vdd-supply", "vdd2-supply" },
  };
 
+static const struct onboard_hub_data vialab_vl817_data = {
+	.reset_us = 10,
+	.num_supplies = 1,

common/usb_onboard_hub.c static const struct onboard_hub_data usbhx3_data = { · line 303

Quoted 10 lines
common/usb_onboard_hub.c +7 -1
+	.supply_names = { "vdd-supply" },
+};
+
  static const struct udevice_id usb_onboard_hub_ids[] = {
  	/* Use generic usbVID,PID dt-bindings (usb-device.yaml) */
-	{	.compatible = "usb3431,6241",	/* Corechips SL6341 USB 2.0 */
+	{	.compatible = "usb2109,2817",	/* VIA Labs VL817 USB 2.0 */
+		.data = (ulong)&vialab_vl817_data,
+	}, {
+		.compatible = "usb2109,817",	/* VIA Labs VL817 USB 3.0 */

Please keep the list sorted.

[...]

#4 lore raw

Re: [PATCH 1/2] usb: onboard-hub: Add support for VIA Labs VL817

Hi Marek,

Quoted 9 lines · Marek Vasut

common/usb_onboard_hub.c static const struct onboard_hub_data usbhx3_data = { · line 303

Quoted 7 lines
  static const struct udevice_id usb_onboard_hub_ids[] = {
  	/* Use generic usbVID,PID dt-bindings (usb-device.yaml) */
common/usb_onboard_hub.c +4 -1
-	{	.compatible = "usb3431,6241",	/* Corechips SL6341 USB 2.0 */
+	{	.compatible = "usb2109,2817",	/* VIA Labs VL817 USB 2.0 */
+		.data = (ulong)&vialab_vl817_data,
+	}, {
+		.compatible = "usb2109,817",	/* VIA Labs VL817 USB 3.0 */

Please keep the list sorted.

I put the new entries first to keep the list in string order: the existing entries go usb3431, usb424, usb4b4, and "usb2109" sorts before all of them.

Did you mean sorting by vendor ID as a number instead (0x424, 0x4b4, 0x2109, 0x3431)? That moves the existing entries too, so I would do it in a separate patch before this one in v2.

Thanks,
Hung-Chun

#5 lore raw

Re: [PATCH 1/2] usb: onboard-hub: Add support for VIA Labs VL817

Quoted 13 lines · Hung-Chun Tseng

Hi Marek,

Quoted 9 lines · Marek Vasut

common/usb_onboard_hub.c static const struct onboard_hub_data usbhx3_data = { · line 303

Quoted 7 lines
   static const struct udevice_id usb_onboard_hub_ids[] = {
   	/* Use generic usbVID,PID dt-bindings (usb-device.yaml) */
common/usb_onboard_hub.c +4 -1
-	{	.compatible = "usb3431,6241",	/* Corechips SL6341 USB 2.0 */
+	{	.compatible = "usb2109,2817",	/* VIA Labs VL817 USB 2.0 */
+		.data = (ulong)&vialab_vl817_data,
+	}, {
+		.compatible = "usb2109,817",	/* VIA Labs VL817 USB 3.0 */

Please keep the list sorted.

Quoted 1 line

I put the new entries first to keep the list in string order

All right.

#6 lore raw

PATCH 2/2 configs: spacemit_k1: Enable onboard USB hub support

In reply to Hung-Chun Tseng

The Milk-V Jupiter and the Banana Pi BPI-F3 need the VL817 hub to be powered and taken out of reset before their USB ports work.

---
 configs/spacemit_k1_defconfig | 1 +
 1 file changed, 1 insertion(+)
configs/spacemit_k1_defconfig +1 -0
index 8ee9baa13..8a9badfde 100644
@@ -116,4 +116,5 @@ CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_DWC3=y
 CONFIG_USB_DWC3_GENERIC=y
 CONFIG_USB_STORAGE=y
+CONFIG_USB_ONBOARD_HUB=y
 CONFIG_SPL_LIB_RATIONAL=y
Signature · 1 line
2.43.0