Skip to contentSkip to conversation

riscv: dts: starfive: jh7110-milkv-mars: enable usb0 host function

PATCH Superseded E Shattow 4 participants 9 messages Nov 26, 2024 – Nov 30, 2024

Subsystems (3)

v5 of 6 Superseded Latest is v6 →

lore
Share & tools
lore

E Shattow

author
#0 lore raw

v5 cover riscv: dts: starfive: jh7110-milkv-mars: enable usb0 host function

Enable host mode JH7110 on-chip USB for Milk-V Mars by setting host mode and connect vbus pinctrl.

This functionality depends on setting the USB over-current register to disable at bootloader phase, for example U-Boot:
https://patchwork.ozlabs.org/project/uboot/patch/[email protected]/

If the over-current register is not prepared for us then the result is no change in functional outcome with this patch applied; there is an error visible to the user and this additional usb configuration fails (same as it is now). On Milk-V Mars with four USB-A ports this applies to one of the ports and the remaining three VL805-connected ports via PCIe are not changed.

Changes since v4:
- Rebase on latest master

Changes since v3:
- Rebase on linux-next/master
- use tabs for code indent

Changes since v2:
- Rebase on 6.12

E Shattow (1):
riscv: dts: starfive: jh7110-milkv-mars: enable usb0 host function

 .../boot/dts/starfive/jh7110-milkv-mars.dts    | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)
Signature · 1 line
2.45.2
author
#1 lore raw

PATCH v5 1/1 riscv: dts: starfive: jh7110-milkv-mars: enable usb0 host function

Milk-V Mars set JH7110 on-chip USB host mode and vbus pin assignment

---
 .../boot/dts/starfive/jh7110-milkv-mars.dts    | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)
arch/riscv/boot/dts/starfive/jh7110-milkv-mars.dts +17 -1
index 0d248b671d4b..3bd62ab78523 100644
@@ -53,7 +53,23 @@ &spi0 {
 	status = "okay";
 };
 
+&sysgpio {
+	usb0_pins: usb0-0 {
+		vbus-pins {
+			pinmux = <GPIOMUX(25, GPOUT_SYS_USB_DRIVE_VBUS,
+					      GPOEN_ENABLE,
+					      GPI_NONE)>;
+			bias-disable;
+			input-disable;
+			input-schmitt-disable;
+			slew-rate = <0>;
+		};
+	};
+};
+
 &usb0 {
-	dr_mode = "peripheral";
+	dr_mode = "host";
+	pinctrl-names = "default";
+	pinctrl-0 = <&usb0_pins>;
 	status = "okay";
 };
Signature · 1 line
2.45.2
maintainer
#2 lore raw

Emil,

Quoted 3 lines · E Shattow

Milk-V Mars set JH7110 on-chip USB host mode and vbus pin assignment

Could you look at this please?

Thanks,
Conor.

Quoted 36 lines
---
 .../boot/dts/starfive/jh7110-milkv-mars.dts    | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)
arch/riscv/boot/dts/starfive/jh7110-milkv-mars.dts +17 -1
index 0d248b671d4b..3bd62ab78523 100644
@@ -53,7 +53,23 @@ &spi0 {
 	status = "okay";
 };
 
+&sysgpio {
+	usb0_pins: usb0-0 {
+		vbus-pins {
+			pinmux = <GPIOMUX(25, GPOUT_SYS_USB_DRIVE_VBUS,
+					      GPOEN_ENABLE,
+					      GPI_NONE)>;
+			bias-disable;
+			input-disable;
+			input-schmitt-disable;
+			slew-rate = <0>;
+		};
+	};
+};
+
 &usb0 {
-	dr_mode = "peripheral";
+	dr_mode = "host";
+	pinctrl-names = "default";
+	pinctrl-0 = <&usb0_pins>;
 	status = "okay";
 };
Signature · 1 line
2.45.2
#3 lore raw
In reply to E Shattow
Quoted 6 lines · E Shattow

Enable host mode JH7110 on-chip USB for Milk-V Mars by setting host mode and connect vbus pinctrl.

This functionality depends on setting the USB over-current register to disable at bootloader phase, for example U-Boot:
https://patchwork.ozlabs.org/project/uboot/patch/[email protected]/

Hi E,

Ideally the JH7110 pinctrl driver would be updated, so Linux can do this itself and doesn't need to rely on u-boot doing it. I already asked for this here:

https://lore.kernel.org/all/CAJM55Z-+Cxdebcn4MLXfQdOVhx4c2SQ+zMH8cjn-Yq35xO8g0A@mail.gmail.com/

Quoted 6 lines

If the over-current register is not prepared for us then the result is no change in functional outcome with this patch applied; there is an error visible to the user and this additional usb configuration fails (same as it is now). On Milk-V Mars with four USB-A ports this applies to one of the ports and the remaining three VL805-connected ports via PCIe are not changed.

Thanks for the patches. I don't quite understand when you write "no change in functional outcome with this patch applied". The USB-C port is already configured as a peripheral, and I just tried setting up an ethernet gadget on my VF2 running 6.12 and that works quite well. Does it not work on the Milk-V Mars board? If it does then these patches would break that functionality.

Here is the script I used for that:
https://paste.c-net.org/BravoLonely

At the very least you'll need to explain in the commit message itself why changing the USB-C port from peripheral mode to host mode is OK. But ideally maybe you could make it work in OTG mode, so userspace can choose how they want to use the port. The same goes for the PINE64 board too.

/Emil

Quoted 20 lines

Changes since v4:
- Rebase on latest master

Changes since v3:
- Rebase on linux-next/master
- use tabs for code indent

Changes since v2:
- Rebase on 6.12

E Shattow (1):
riscv: dts: starfive: jh7110-milkv-mars: enable usb0 host function

 .../boot/dts/starfive/jh7110-milkv-mars.dts    | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

--
2.45.2

author
#4 lore raw

Hi Emil, thanks for taking time to review!

Added CC: Minda Chen, Hal Feng

Please Minda and Hal can you follow-up on Emil's comments as well?

Quoted 7 lines · Emil Renner Berthing
Quoted 6 lines · E Shattow

Enable host mode JH7110 on-chip USB for Milk-V Mars by setting host mode and connect vbus pinctrl.

This functionality depends on setting the USB over-current register to disable at bootloader phase, for example U-Boot:
https://patchwork.ozlabs.org/project/uboot/patch/[email protected]/

Quoted 6 lines

Hi E,

Ideally the JH7110 pinctrl driver would be updated, so Linux can do this itself and doesn't need to rely on u-boot doing it. I already asked for this here:

https://lore.kernel.org/all/CAJM55Z-+Cxdebcn4MLXfQdOVhx4c2SQ+zMH8cjn-Yq35xO8g0A@mail.gmail.com/

Yes, I agree, and Linux is not the only consumer of devicetree. I would like USB function to work for users of Linux and U-Boot on these boards by copying what the vendor Board Support Package does what is shipped with the products. If it is more in-depth than this I will defer to Hal or Minda.

For some wider context, upstream U-Boot is about to adopt the dt-rebasing via Hal's OF_UPSTREAM for JH7110 boards series and then also there is a patch set from Minda Chen to add the on-chip JH7110 USB support to U-Boot, and so then and there it will depend on these dts changes. If you have Milk-V Mars then already there are three of four USB-A receptacle ports which are functional on PCIe-connected VL805 USB chipset.

Quoted 15 lines
Quoted 6 lines

If the over-current register is not prepared for us then the result is no change in functional outcome with this patch applied; there is an error visible to the user and this additional usb configuration fails (same as it is now). On Milk-V Mars with four USB-A ports this applies to one of the ports and the remaining three VL805-connected ports via PCIe are not changed.

Thanks for the patches. I don't quite understand when you write "no change in functional outcome with this patch applied". The USB-C port is already configured as a peripheral, and I just tried setting up an ethernet gadget on my VF2 running 6.12 and that works quite well. Does it not work on the Milk-V Mars board? If it does then these patches would break that functionality.

Here is the script I used for that:
https://paste.c-net.org/BravoLonely

Quoted 6 lines

At the very least you'll need to explain in the commit message itself why changing the USB-C port from peripheral mode to host mode is OK. But ideally maybe you could make it work in OTG mode, so userspace can choose how they want to use the port. The same goes for the PINE64 board too.

/Emil

USB-C port on Mars is not wired for data here, that is only true for VisionFive2. If the user wants to use their USB-A receptacle as OTG port I will not object to a future improvement, but here we want the basic expectations of users covered that they should have four working USB-A receptacle ports in U-Boot (and possibly in Linux, depending on the overcurrent register wherever it is set). This is what I am meaning, there may be somebody using a male-male USB-A USB-A cable for OTG but more likely is that people just want to plug in USB peripherals to host ports and use their mouse / keyboard / flash memory, I think.

There is no USB-C port on Star64.

Quoted 14 lines
Quoted 14 lines

Changes since v4:
- Rebase on latest master

Changes since v3:
- Rebase on linux-next/master
- use tabs for code indent

Changes since v2:
- Rebase on 6.12

E Shattow (1):
riscv: dts: starfive: jh7110-milkv-mars: enable usb0 host function

Quoted 6 lines
Quoted 6 lines
  .../boot/dts/starfive/jh7110-milkv-mars.dts    | 18 +++++++++++++++++-
  1 file changed, 17 insertions(+), 1 deletion(-)

--
2.45.2

Thanks again Emil.  -E

#5 lore raw
Quoted 58 lines · E Shattow

Hi Emil, thanks for taking time to review!

Added CC: Minda Chen, Hal Feng

Please Minda and Hal can you follow-up on Emil's comments as well?

Quoted 7 lines · Emil Renner Berthing
Quoted 6 lines · E Shattow

Enable host mode JH7110 on-chip USB for Milk-V Mars by setting host mode and connect vbus pinctrl.

This functionality depends on setting the USB over-current register to disable at bootloader phase, for example U-Boot:
https://patchwork.ozlabs.org/project/uboot/patch/[email protected]/

Quoted 6 lines

Hi E,

Ideally the JH7110 pinctrl driver would be updated, so Linux can do this itself and doesn't need to rely on u-boot doing it. I already asked for this here:

https://lore.kernel.org/all/CAJM55Z-+Cxdebcn4MLXfQdOVhx4c2SQ+zMH8cjn-Yq35xO8g0A@mail.gmail.com/

Yes, I agree, and Linux is not the only consumer of devicetree. I would like USB function to work for users of Linux and U-Boot on these boards by copying what the vendor Board Support Package does what is shipped with the products. If it is more in-depth than this I will defer to Hal or Minda.

For some wider context, upstream U-Boot is about to adopt the dt-rebasing via Hal's OF_UPSTREAM for JH7110 boards series and then also there is a patch set from Minda Chen to add the on-chip JH7110 USB support to U-Boot, and so then and there it will depend on these dts changes. If you have Milk-V Mars then already there are three of four USB-A receptacle ports which are functional on PCIe-connected VL805 USB chipset.

Quoted 15 lines
Quoted 6 lines

If the over-current register is not prepared for us then the result is no change in functional outcome with this patch applied; there is an error visible to the user and this additional usb configuration fails (same as it is now). On Milk-V Mars with four USB-A ports this applies to one of the ports and the remaining three VL805-connected ports via PCIe are not changed.

Thanks for the patches. I don't quite understand when you write "no change in functional outcome with this patch applied". The USB-C port is already configured as a peripheral, and I just tried setting up an ethernet gadget on my VF2 running 6.12 and that works quite well. Does it not work on the Milk-V Mars board? If it does then these patches would break that functionality.

Here is the script I used for that:
https://paste.c-net.org/BravoLonely

Quoted 6 lines

At the very least you'll need to explain in the commit message itself why changing the USB-C port from peripheral mode to host mode is OK. But ideally maybe you could make it work in OTG mode, so userspace can choose how they want to use the port. The same goes for the PINE64 board too.

/Emil

Quoted 9 lines

USB-C port on Mars is not wired for data here, that is only true for VisionFive2. If the user wants to use their USB-A receptacle as OTG port I will not object to a future improvement, but here we want the basic expectations of users covered that they should have four working USB-A receptacle ports in U-Boot (and possibly in Linux, depending on the overcurrent register wherever it is set). This is what I am meaning, there may be somebody using a male-male USB-A USB-A cable for OTG but more likely is that people just want to plug in USB peripherals to host ports and use their mouse / keyboard / flash memory, I think.

You're right, sorry. I'm so used to the JH7110 boards being similar, but this is actually one of the few differences between the Mars and VF2 that was not caught when the Mars dts was first upstreamed.

Yes, with 4 similar USB-A ports you'd definitely expect all of them to work in host mode. With an explanation like the above in the commit message I (now) think your changes makes sense.

Thanks!
/Emil

Quoted 26 lines

There is no USB-C port on Star64.

Quoted 14 lines
Quoted 14 lines

Changes since v4:
- Rebase on latest master

Changes since v3:
- Rebase on linux-next/master
- use tabs for code indent

Changes since v2:
- Rebase on 6.12

E Shattow (1):
riscv: dts: starfive: jh7110-milkv-mars: enable usb0 host function

Quoted 6 lines
Quoted 6 lines
  .../boot/dts/starfive/jh7110-milkv-mars.dts    | 18 +++++++++++++++++-
  1 file changed, 17 insertions(+), 1 deletion(-)

--
2.45.2

Thanks again Emil.  -E

#6 lore raw
Quoted 84 lines
Quoted 19 lines · E Shattow

Hi Emil, thanks for taking time to review!

Added CC: Minda Chen, Hal Feng

Please Minda and Hal can you follow-up on Emil's comments as well?

Quoted 12 lines · Emil Renner Berthing
Quoted 7 lines · E Shattow

Enable host mode JH7110 on-chip USB for Milk-V Mars by setting host mode and connect vbus pinctrl.

This functionality depends on setting the USB over-current register to disable at bootloader phase, for example U-Boot:
https://patchwork.ozlabs.org/project/uboot/patch/20241012031328.426
[email protected]/

Hi E,

Ideally the JH7110 pinctrl driver would be updated, so Linux can do this itself and doesn't need to rely on u-boot doing it. I already asked for this

here:

Quoted 2 lines
Quoted 2 lines

https://lore.kernel.org/all/CAJM55Z-+Cxdebcn4MLXfQdOVhx4c2SQ+zMH8cjn

Quoted 9 lines
Quoted 1 line

[email protected]/

Yes, I agree, and Linux is not the only consumer of devicetree. I would like USB function to work for users of Linux and U-Boot on these boards by copying what the vendor Board Support Package does what is shipped with the products. If it is more in-depth than this I will defer to Hal or Minda.

Quoted 14 lines

For some wider context, upstream U-Boot is about to adopt the dt-rebasing via Hal's OF_UPSTREAM for JH7110 boards series and then also there is a patch set from Minda Chen to add the on-chip JH7110 USB support to U-Boot, and so then and there it will depend on these dts changes. If you have Milk-V Mars then already there are three of four USB-A receptacle ports which are functional on PCIe-connected VL805 USB chipset.

Quoted 6 lines
Quoted 6 lines

If the over-current register is not prepared for us then the result is no change in functional outcome with this patch applied; there is an error visible to the user and this additional usb configuration fails (same as it is now). On Milk-V Mars with four USB-A ports this applies to one of the ports and the remaining three

VL805-connected ports via PCIe are not changed.

Quoted 5 lines
Quoted 5 lines

Thanks for the patches. I don't quite understand when you write "no change in functional outcome with this patch applied". The USB-C port is already configured as a peripheral, and I just tried setting up an ethernet gadget on my VF2 running 6.12 and that works quite well. Does it not work on the Milk-V Mars board? If it does then these

patches would break that functionality.

Quoted 8 lines
Quoted 8 lines

Here is the script I used for that:
https://paste.c-net.org/BravoLonely

At the very least you'll need to explain in the commit message itself why changing the USB-C port from peripheral mode to host mode is OK. But ideally maybe you could make it work in OTG mode, so userspace can choose how they want to use the port. The same goes for the

PINE64 board too.

Quoted 12 lines
Quoted 2 lines

/Emil

USB-C port on Mars is not wired for data here, that is only true for VisionFive2. If the user wants to use their USB-A receptacle as OTG port I will not object to a future improvement, but here we want the basic expectations of users covered that they should have four working USB-A receptacle ports in U-Boot (and possibly in Linux, depending on the overcurrent register wherever it is set). This is what I am meaning, there may be somebody using a male-male USB-A USB-A cable for OTG but more likely is that people just want to plug in USB peripherals to host ports and use their mouse / keyboard / flash memory, I

think.

You're right, sorry. I'm so used to the JH7110 boards being similar, but this is actually one of the few differences between the Mars and VF2 that was not caught when the Mars dts was first upstreamed.

Quoted 7 lines

Yes, with 4 similar USB-A ports you'd definitely expect all of them to work in host mode. With an explanation like the above in the commit message I (now) think your changes makes sense.

Thanks!
/Emil

Thanks. E Shadow

The USB and PCIe0 setting in some JH7110 boards.
PCIe0 cadence USB controller
VF2: connect with VL805 USB3.0 ( 4 USB 3.0 type A ports) (USB 2.0)Type C port(role: peripheral)
Milkv mars connect with VL805 USB3.0 ( 3 USB 3.0 type A ports) (USB 2.0)1 Type A port (role:host)
Milkv cm PCIe slot (USB 2.0)micro B port (role:host)
Star64 disabled(pcie PHY0 connect to cadence USB) 1 usb 3.0 port + USB 2.0 hub (role:host)

H E Shadow
I see you also add star64 USB configuration. I hope also add this to star64 board dts base on V6.13-rc1. Thanks.

&pcie0 {
	status = "disabled";
};
&pciephy0 {
	starfive,sys-syscon = <&sys_syscon 0x18>;
	starfive,stg-syscon = <&stg_syscon 0x148 0x1f4>;
	status = "okay";
};
&usb0 {
	pinctrl-names = "default";
	pinctrl-0 = <&usb_pins>;
	dr_mode = "host";
	status = "okay";
};
&usb_cdns3 {
	phys = <&usbphy0>, <&pciephy0>;
	phy-names = "cdns3,usb2-phy", "cdns3,usb3-phy";
};
Quoted 28 lines
Quoted 20 lines

There is no USB-C port on Star64.

Quoted 16 lines
Quoted 16 lines

Changes since v4:
- Rebase on latest master

Changes since v3:
- Rebase on linux-next/master
- use tabs for code indent

Changes since v2:
- Rebase on 6.12

E Shattow (1):
riscv: dts: starfive: jh7110-milkv-mars: enable usb0 host
function

  .../boot/dts/starfive/jh7110-milkv-mars.dts    | 18

+++++++++++++++++-

Quoted 7 lines
Quoted 5 lines
Quoted 5 lines
  1 file changed, 17 insertions(+), 1 deletion(-)

--
2.45.2

Thanks again Emil.  -E

author
#7 lore raw

Re-sending my reply plain text not HTML format. -E

Quoted 74 lines · Minda Chen
Quoted 74 lines
Quoted 19 lines · E Shattow

Hi Emil, thanks for taking time to review!

Added CC: Minda Chen, Hal Feng

Please Minda and Hal can you follow-up on Emil's comments as well?

Quoted 12 lines · Emil Renner Berthing
Quoted 7 lines · E Shattow

Enable host mode JH7110 on-chip USB for Milk-V Mars by setting host mode and connect vbus pinctrl.

This functionality depends on setting the USB over-current register to disable at bootloader phase, for example U-Boot:
https://patchwork.ozlabs.org/project/uboot/patch/20241012031328.426
[email protected]/

Hi E,

Ideally the JH7110 pinctrl driver would be updated, so Linux can do this itself and doesn't need to rely on u-boot doing it. I already asked for this

here:
https://lore.kernel.org/all/CAJM55Z-+Cxdebcn4MLXfQdOVhx4c2SQ+zMH8cjn

Quoted 8 lines
Quoted 1 line

[email protected]/

Yes, I agree, and Linux is not the only consumer of devicetree. I would like USB function to work for users of Linux and U-Boot on these boards by copying what the vendor Board Support Package does what is shipped with the products. If it is more in-depth than this I will defer to Hal or Minda.

Quoted 13 lines

For some wider context, upstream U-Boot is about to adopt the dt-rebasing via Hal's OF_UPSTREAM for JH7110 boards series and then also there is a patch set from Minda Chen to add the on-chip JH7110 USB support to U-Boot, and so then and there it will depend on these dts changes. If you have Milk-V Mars then already there are three of four USB-A receptacle ports which are functional on PCIe-connected VL805 USB chipset.

Quoted 5 lines
Quoted 5 lines

If the over-current register is not prepared for us then the result is no change in functional outcome with this patch applied; there is an error visible to the user and this additional usb configuration fails (same as it is now). On Milk-V Mars with four USB-A ports this applies to one of the ports and the remaining three

VL805-connected ports via PCIe are not changed.

Quoted 5 lines
Quoted 5 lines

Thanks for the patches. I don't quite understand when you write "no change in functional outcome with this patch applied". The USB-C port is already configured as a peripheral, and I just tried setting up an ethernet gadget on my VF2 running 6.12 and that works quite well. Does it not work on the Milk-V Mars board? If it does then these

patches would break that functionality.

Quoted 7 lines
Quoted 7 lines

Here is the script I used for that:
https://paste.c-net.org/BravoLonely

At the very least you'll need to explain in the commit message itself why changing the USB-C port from peripheral mode to host mode is OK. But ideally maybe you could make it work in OTG mode, so userspace can choose how they want to use the port. The same goes for the

PINE64 board too.

Quoted 10 lines
Quoted 1 line

/Emil

USB-C port on Mars is not wired for data here, that is only true for VisionFive2. If the user wants to use their USB-A receptacle as OTG port I will not object to a future improvement, but here we want the basic expectations of users covered that they should have four working USB-A receptacle ports in U-Boot (and possibly in Linux, depending on the overcurrent register wherever it is set). This is what I am meaning, there may be somebody using a male-male USB-A USB-A cable for OTG but more likely is that people just want to plug in USB peripherals to host ports and use their mouse / keyboard / flash memory, I

think.

You're right, sorry. I'm so used to the JH7110 boards being similar, but this is actually one of the few differences between the Mars and VF2 that was not caught when the Mars dts was first upstreamed.

Quoted 7 lines
Quoted 7 lines

Yes, with 4 similar USB-A ports you'd definitely expect all of them to work in host mode. With an explanation like the above in the commit message I (now) think your changes makes sense.

Thanks!
/Emil

Hi Minda, thanks for taking time to review and explain the multiple USB configurations.

Quoted 9 lines

Thanks. E Shadow

The USB and PCIe0 setting in some JH7110 boards.
PCIe0 cadence USB controller
VF2: connect with VL805 USB3.0 ( 4 USB 3.0 type A ports) (USB 2.0)Type C port(role: peripheral)
Milkv mars connect with VL805 USB3.0 ( 3 USB 3.0 type A ports) (USB 2.0)1 Type A port (role:host)
Milkv cm PCIe slot (USB 2.0)micro B port (role:host)
Star64 disabled(pcie PHY0 connect to cadence USB) 1 usb 3.0 port + USB 2.0 hub (role:host)

Quoted 3 lines

H E Shadow
I see you also add star64 USB configuration. I hope also add this to star64 board dts base on V6.13-rc1. Thanks.

Yes, on Star64 board I see there is one "blue colour" USB-A port and three "black colour" USB-A port. The product webpage https://wiki.pine64.org/wiki/STAR64 does say "1× USB3.0 Dedicated Host port / 3× USB2.0 Host port".

Quoted 3 lines
&pcie0 {
	status = "disabled";
};

For JH7110 is it allowed to have PCIe0 "okay" PCIe1 "okay" and also have USB 2.0?  We disable this PCIe0 here because of JH7110 USB3.0 design on Mars and on Star64?  Can JH7110 have USB 3.0 and USB 2.0 together (does Star64 do this, or is it USB 2.0 hub attach to JH7110 USB 3.0?)

Quoted 5 lines
&pciephy0 {
	starfive,sys-syscon = <&sys_syscon 0x18>;
	starfive,stg-syscon = <&stg_syscon 0x148 0x1f4>;
	status = "okay";
};

Minda, I need your help to make a good description of these numbers 0x18 0x148 0x1f4, for the patch to Linux.

First is 'starfive,sys-sycon':

JH7110 Technical Reference Manual, Table 7. "SYS SYSCONSAIF SYSCFG 24 Register Description"

https://doc-en.rvspace.org/JH7110/TRM/JH7110_TRM/sys_syscon.html#sys_syscon__table_c3l_fqs_wsb

Register SYS SYSCONSAIF SYSCFG 24 at offset 0x18 why is this needed?  Your patch series for Linux 6.12 "Fix configuration for on-chip USB 2.0 support"

https://lore.kernel.org/lkml/[email protected]/

changes u0_pdrstn_split_sw_usbpipe_plugen in the driver and why do we need this now in the Star64 USB 3.0 dts for Linux 6.13?  Is this needed for USB function only u0_pdrstn_split_sw_usbpipe_plugen or is more from this register important here ?  And, can you make an explanation so I can learn what is the purpose of "u0_pdrstn_split_sw_usbpipe_plugen" or any other part of this register we need here (for USB)?

Next is 'stg-syscon':

JH7110 Technical Reference Manual, Table 82. "STG SYSCONSAIF SYSCFG 328 Register Description"

https://doc-en.rvspace.org/JH7110/TRM/JH7110_TRM/stg_syscon.html#stg_syscon__table_mc4_n5s_wsb

Register STG SYSCONSAIF SYSCFG 328 at offset 0x148 what is this? Something PCIe?  Does this have to do with wires on the board going from USB-A port to PCIe? What is the explanation why we need this for USB?

JH7110 Technical Reference Manual, Table 125. "STG SYSCONSAIF SYSCFG 500 Register Description"

https://doc-en.rvspace.org/JH7110/TRM/JH7110_TRM/stg_syscon.html#stg_syscon__table_njd_45s_wsb

Register STG SYSCONSAIF SYSCFG 500 at offset 0x1f4 is more usb3 bitfield names, what is a general description why this is needed? Is this "all the Cadence IP USB3 things" ?

The documentation devicetree/bindings/phy/starfive,jh7110-pcie-phy.yaml is not enough information to make a good description. "Total 2 registers offset" is a description of the place where the numbers exist for the schema but does not say if there is an ordering first,last and the expected register names in JH7110 TRM.  Is there more than one possibility? or else, will it 100% be exactly STG SYSCONSAIF SYSCFG registers 328 and 500 at offsets 0x148 and 0x1f4?

Quoted 7 lines
&usb0 {
	pinctrl-names = "default";
	pinctrl-0 = <&usb_pins>;
	dr_mode = "host";
	status = "okay";
};
Quoted 30 lines
&usb_cdns3 {
	phys = <&usbphy0>, <&pciephy0>;
	phy-names = "cdns3,usb2-phy", "cdns3,usb3-phy";
};
Quoted 25 lines
Quoted 17 lines

There is no USB-C port on Star64.

Quoted 15 lines
Quoted 15 lines

Changes since v4:
- Rebase on latest master

Changes since v3:
- Rebase on linux-next/master
- use tabs for code indent

Changes since v2:
- Rebase on 6.12

E Shattow (1):
riscv: dts: starfive: jh7110-milkv-mars: enable usb0 host
function

   .../boot/dts/starfive/jh7110-milkv-mars.dts    | 18

+++++++++++++++++-

Quoted 7 lines
Quoted 5 lines
Quoted 5 lines
   1 file changed, 17 insertions(+), 1 deletion(-)

--
2.45.2

Thanks again Emil.  -E

For Emil, my patches of Star64 and Mars are limited in scope to do the work of turning up host mode and adding the necessary vbus GPIO assignment;  so it's not wrong, and given the advice from Minda it's also not the complete support for all USB-A ports that I would like. I can extend this series to also include this adjacent USB 3.0 configuration, or follow up in another series that is specific in topic for USB 3.0? Where I'm at on this is the host mode and GPIO configuration clearly belongs in dts but I have questions about this additional (USB 3.0 specific) configuration. And if we do, what do you think about the addition of syscon register offset values in devicetree, should they be #define'd somewhere? When it is the vbus GPIO there's literal sequential number of GPIO's so I did not find it was any problem to use the value. But, when I read "0x1f4" I think, what is that?

Best regards,

-E Shattow "Shadow"

#8 lore raw
Quoted 133 lines

-----邮件原件-----
发件人: E Shattow <[email protected]>
发送时间: 2024年11月28日 16:01
收件人: Minda Chen <[email protected]>; Emil Renner Berthing <[email protected]>; Jisheng Zhang <[email protected]> 抄送: Emil Renner Berthing <[email protected]>; Conor Dooley <[email protected]>; Rob Herring <[email protected]>; Krzysztof Kozlowski <[email protected]>; Paul Walmsley <[email protected]>; Palmer Dabbelt <[email protected]>; Albert Ou <[email protected]>; [email protected]; [email protected]; [email protected]; Hal Feng <[email protected]> 主题: Re: [PATCH v5 0/1] riscv: dts: starfive: jh7110-milkv-mars: enable usb0 host function

Re-sending my reply plain text not HTML format. -E

Quoted 17 lines · Minda Chen
Quoted 17 lines
Quoted 16 lines · E Shattow

Hi Emil, thanks for taking time to review!

Added CC: Minda Chen, Hal Feng

Please Minda and Hal can you follow-up on Emil's comments as well?

Quoted 9 lines · Emil Renner Berthing
Quoted 8 lines · E Shattow

Enable host mode JH7110 on-chip USB for Milk-V Mars by setting host mode and connect vbus pinctrl.

This functionality depends on setting the USB over-current register to disable at bootloader phase, for example U-Boot:
https://patchwork.ozlabs.org/project/uboot/patch/20241012031328.42
6
[email protected]/

Quoted 7 lines
Quoted 7 lines
Quoted 5 lines
Quoted 5 lines

Hi E,

Ideally the JH7110 pinctrl driver would be updated, so Linux can do this itself and doesn't need to rely on u-boot doing it. I already asked for this

here:

https://lore.kernel.org/all/CAJM55Z-+Cxdebcn4MLXfQdOVhx4c2SQ+zMH8cjn

Quoted 56 lines
Quoted 56 lines
Quoted 8 lines
Quoted 1 line

[email protected]/

Yes, I agree, and Linux is not the only consumer of devicetree. I would like USB function to work for users of Linux and U-Boot on these boards by copying what the vendor Board Support Package does what is shipped with the products. If it is more in-depth than this I will defer to Hal or Minda.

Quoted 14 lines

For some wider context, upstream U-Boot is about to adopt the dt-rebasing via Hal's OF_UPSTREAM for JH7110 boards series and then also there is a patch set from Minda Chen to add the on-chip JH7110 USB support to U-Boot, and so then and there it will depend on these dts changes. If you have Milk-V Mars then already there are three of four USB-A receptacle ports which are functional on PCIe-connected VL805 USB chipset.

Quoted 6 lines
Quoted 6 lines

If the over-current register is not prepared for us then the result is no change in functional outcome with this patch applied; there is an error visible to the user and this additional usb configuration fails (same as it is now). On Milk-V Mars with four USB-A ports this applies to one of the ports and the remaining three

VL805-connected ports via PCIe are not changed.

Quoted 6 lines
Quoted 6 lines

Thanks for the patches. I don't quite understand when you write "no change in functional outcome with this patch applied". The USB-C port is already configured as a peripheral, and I just tried setting up an ethernet gadget on my VF2 running 6.12 and that works quite well. Does it not work on the Milk-V Mars board? If it does then these

patches would break that functionality.

Quoted 8 lines
Quoted 8 lines

Here is the script I used for that:
https://paste.c-net.org/BravoLonely

At the very least you'll need to explain in the commit message itself why changing the USB-C port from peripheral mode to host mode is OK. But ideally maybe you could make it work in OTG mode, so userspace can choose how they want to use the port. The same goes for the

PINE64 board too.

Quoted 11 lines
Quoted 1 line

/Emil

USB-C port on Mars is not wired for data here, that is only true for VisionFive2. If the user wants to use their USB-A receptacle as OTG port I will not object to a future improvement, but here we want the basic expectations of users covered that they should have four working USB-A receptacle ports in U-Boot (and possibly in Linux, depending on the overcurrent register wherever it is set). This is what I am meaning, there may be somebody using a male-male USB-A USB-A cable for OTG but more likely is that people just want to plug in USB peripherals to host ports and use their mouse / keyboard / flash memory, I

think.

You're right, sorry. I'm so used to the JH7110 boards being similar, but this is actually one of the few differences between the Mars and VF2 that was not caught when the Mars dts was first upstreamed.

Quoted 7 lines
Quoted 7 lines

Yes, with 4 similar USB-A ports you'd definitely expect all of them to work in host mode. With an explanation like the above in the commit message I (now) think your changes makes sense.

Thanks!
/Emil

Hi Minda, thanks for taking time to review and explain the multiple USB configurations.

Quoted 4 lines

Thanks. E Shadow

The USB and PCIe0 setting in some JH7110 boards.
PCIe0

cadence USB controller

Quoted 1 line

VF2: connect with VL805 USB3.0 ( 4 USB 3.0 type A ports)

(USB 2.0)Type C port(role: peripheral)

Quoted 1 line

Milkv mars connect with VL805 USB3.0 ( 3 USB 3.0 type A ports)

(USB 2.0)1 Type A port (role:host)

Quoted 1 line

Milkv cm PCIe slot (USB

2.0)micro B port (role:host)

Quoted 1 line

Star64 disabled(pcie PHY0 connect to cadence USB) 1 usb

3.0 port + USB 2.0 hub (role:host)

Quoted 4 lines

H E Shadow
I see you also add star64 USB configuration. I hope also add this to star64 board dts base on V6.13-rc1. Thanks.

Yes, on Star64 board I see there is one "blue colour" USB-A port and three "black colour" USB-A port. The product webpage
https://wiki.pine64.org/wiki/STAR64 does say "1× USB3.0 Dedicated Host port / 3× USB2.0 Host port".

Quoted 9 lines
Quoted 3 lines
&pcie0 {
	status = "disabled";
};

For JH7110 is it allowed to have PCIe0 "okay" PCIe1 "okay" and also have USB 2.0?  We disable this PCIe0 here because of JH7110 USB3.0 design on Mars and on Star64?  Can JH7110 have USB 3.0 and USB 2.0 together (does Star64 do this, or is it USB 2.0 hub attach to JH7110 USB 3.0?)

Now you can see only JH7110 contain 2 pcie 2.0 combo PHY and 1 USB 2.0 PHY Only PCIe0 PHY can move to Cadence USB 3.0 Controller.
So if enable Cadence USB 3.0 port. Only PCIe1 can be used.
Two solution
2 PCIe + USB 2.0 eg: VF2/ milk-v mars board.
1 PCIe + USB 3.0/ 2.0 eg: star64/starfive devkits board.

Quoted 9 lines
Quoted 5 lines
&pciephy0 {
	starfive,sys-syscon = <&sys_syscon 0x18>;
	starfive,stg-syscon = <&stg_syscon 0x148 0x1f4>;
	status = "okay";
};

Minda, I need your help to make a good description of these numbers 0x18 0x148 0x1f4, for the patch to Linux.

JH7110 syscon/stgcon register offset.
Maybe move this to the PHY code is better.

Quoted 16 lines

First is 'starfive,sys-sycon':

JH7110 Technical Reference Manual, Table 7. "SYS SYSCONSAIF SYSCFG 24 Register Description"

https://doc-en.rvspace.org/JH7110/TRM/JH7110_TRM/sys_syscon.html#sys_sys
con__table_c3l_fqs_wsb

Register SYS SYSCONSAIF SYSCFG 24 at offset 0x18 why is this needed? Your patch series for Linux 6.12 "Fix configuration for on-chip USB 2.0 support"

https://lore.kernel.org/lkml/20241015070444.20972-1-minda.chen@starfivete
ch.com/

Quoted 7 lines

changes u0_pdrstn_split_sw_usbpipe_plugen in the driver and why do we need this now in the Star64 USB 3.0 dts for Linux 6.13?  Is this needed for USB function only u0_pdrstn_split_sw_usbpipe_plugen or is more from this register important here ?  And, can you make an explanation so I can learn what is the purpose of "u0_pdrstn_split_sw_usbpipe_plugen" or any other part of this register we need here (for USB)?

The bit mean split pcie PHY from cadence USB. So if use USB 2.0 only. The bit must be set. But if PHY connect to Cadence USB. The bit must be cleared. I think the bit should reset to 1 for the PHY default connect to PCIe but the reset Value is 0. And it is a little issue in JH7110 IC.

Quoted 17 lines

Next is 'stg-syscon':

JH7110 Technical Reference Manual, Table 82. "STG SYSCONSAIF SYSCFG 328 Register Description"

https://doc-en.rvspace.org/JH7110/TRM/JH7110_TRM/stg_syscon.html#stg_sy
scon__table_mc4_n5s_wsb

Register STG SYSCONSAIF SYSCFG 328 at offset 0x148 what is this? Something PCIe?  Does this have to do with wires on the board going from USB-A port to PCIe? What is the explanation why we need this for USB?

JH7110 Technical Reference Manual, Table 125. "STG SYSCONSAIF SYSCFG 500 Register Description"

Quoted 7 lines

https://doc-en.rvspace.org/JH7110/TRM/JH7110_TRM/stg_syscon.html#stg_sy
scon__table_njd_45s_wsb

Register STG SYSCONSAIF SYSCFG 500 at offset 0x1f4 is more usb3 bitfield names, what is a general description why this is needed? Is this "all the Cadence IP USB3 things" ?

The USB 3.0 PHY stg syscon setting. To make Cadence USB 3.0 work. Must set Some syscon register. It is belong to JH7110 IC.
You can check this in PCIe PHY code.

Quoted 62 lines

The documentation devicetree/bindings/phy/starfive,jh7110-pcie-phy.yaml is not enough information to make a good description. "Total 2 registers offset" is a description of the place where the numbers exist for the schema but does not say if there is an ordering first,last and the expected register names in JH7110 TRM.  Is there more than one possibility? or else, will it 100% be exactly STG SYSCONSAIF SYSCFG registers 328 and 500 at offsets 0x148 and 0x1f4?

Quoted 7 lines
&usb0 {
	pinctrl-names = "default";
	pinctrl-0 = <&usb_pins>;
	dr_mode = "host";
	status = "okay";
};
Quoted 30 lines
&usb_cdns3 {
	phys = <&usbphy0>, <&pciephy0>;
	phy-names = "cdns3,usb2-phy", "cdns3,usb3-phy";
};
Quoted 25 lines
Quoted 17 lines

There is no USB-C port on Star64.

Quoted 15 lines
Quoted 15 lines

Changes since v4:
- Rebase on latest master

Changes since v3:
- Rebase on linux-next/master
- use tabs for code indent

Changes since v2:
- Rebase on 6.12

E Shattow (1):
riscv: dts: starfive: jh7110-milkv-mars: enable usb0 host
function

   .../boot/dts/starfive/jh7110-milkv-mars.dts    | 18

+++++++++++++++++-

Quoted 7 lines
Quoted 5 lines
Quoted 5 lines
   1 file changed, 17 insertions(+), 1 deletion(-)

--
2.45.2

Thanks again Emil.  -E

For Emil, my patches of Star64 and Mars are limited in scope to do the work of turning up host mode and adding the necessary vbus GPIO assignment;  so it's not wrong, and given the advice from Minda it's also not the complete support for all USB-A ports that I would like. I can extend this series to also include this adjacent USB 3.0 configuration, or follow up in another series that is specific in topic for USB 3.0? Where I'm at on this is the host mode and GPIO configuration clearly belongs in dts but I have questions about this additional (USB 3.0 specific) configuration. And if we do, what do you think about the addition of syscon register offset values in devicetree, should they be #define'd somewhere? When it is the vbus GPIO there's literal sequential number of GPIO's so I did not find it was any problem to use the value. But, when I read "0x1f4" I think, what is that?

Quoted 3 lines

Best regards,

-E Shattow "Shadow"

_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv