riscv: dts: spacemit: Add USB 3.0 support for K1
Subsystems (3)
v2 cover riscv: dts: spacemit: Add USB 3.0 support for K1
This patch series enables the DWC3 USB 3.0 host controller on the Spacemit K1 SoC and enables it for the Banana Pi F3 board.
For testing, the following kernel configurations should be enabled:
CONFIG_PHY_SPACEMIT_K1_USB2=yCONFIG_PHY_SPACEMIT_K1_PCIE=yCONFIG_USB_DWC3=yCONFIG_USB_ONBOARD_DEV=y
This series is based on the spacemit k1/for-next branch.
---
Changes in v2:
- rebased on spacemit k1/for-next
- Link to v1: https://lore.kernel.org/all/[email protected]/
---
Ze Huang (3):
riscv: dts: spacemit: Add USB2 PHY node for K1
riscv: dts: spacemit: Add DWC3 USB 3.0 controller node for K1
riscv: dts: spacemit: Enable USB3.0 on BananaPi-F3
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts | 48 +++++++++++++++++++++++++ arch/riscv/boot/dts/spacemit/k1.dtsi | 32 +++++++++++++++++ 2 files changed, 80 insertions(+)
---
base-commit: 4f67c877a9069c60dfb1767038fba5180bc12d68
change-id: 20260107-k1-usb3dts-v2-220c0fa7702a
Best regards,
Signature · 1 line
Ze Huang <[email protected]>
PATCH v2 1/3 riscv: dts: spacemit: Add USB2 PHY node for K1
K1's DWC3 USB 3.0 controller requires two separate PHYs to function:
the USB 3.0 combophy (for SuperSpeed) and a USB 2.0 PHY (for High-Speed, Full-Speed, etc.).
Add node for this second USB 2.0 PHY (usbphy2).
--- arch/riscv/boot/dts/spacemit/k1.dtsi | 8 ++++++++ 1 file changed, 8 insertions(+)
arch/riscv/boot/dts/spacemit/k1.dtsi +8 -0
@@ -424,6 +424,14 @@ i2c5: i2c@d4013800 { status = "disabled"; }; + usbphy2: phy@c0a30000 { + compatible = "spacemit,k1-usb2-phy"; + reg = <0x0 0xc0a30000 0x0 0x200>; + clocks = <&syscon_apmu CLK_USB30>; + #phy-cells = <0>; + status = "disabled"; + }; + combo_phy: phy@c0b10000 { compatible = "spacemit,k1-combo-phy"; reg = <0x0 0xc0b10000 0x0 0x1000>;
Signature · 1 line
2.52.0
PATCH v2 2/3 riscv: dts: spacemit: Add DWC3 USB 3.0 controller node for K1
In reply to Ze HuangAdd node for the Synopsys DWC3 USB 3.0 host controller on the K1 SoC. The controller resides on the 'storage-bus' and uses its DMA translations.
--- arch/riscv/boot/dts/spacemit/k1.dtsi | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
arch/riscv/boot/dts/spacemit/k1.dtsi +24 -0
@@ -1162,6 +1162,30 @@ storage-bus { #size-cells = <2>; dma-ranges = <0x0 0x00000000 0x0 0x00000000 0x0 0x80000000>; + usb_dwc3: usb@c0a00000 { + compatible = "spacemit,k1-dwc3"; + reg = <0x0 0xc0a00000 0x0 0x10000>; + clocks = <&syscon_apmu CLK_USB30>; + clock-names = "usbdrd30"; + interrupts = <125>; + phys = <&usbphy2>, <&combo_phy PHY_TYPE_USB3>; + phy-names = "usb2-phy", "usb3-phy"; + phy_type = "utmi"; + resets = <&syscon_apmu RESET_USB30_AHB>, + <&syscon_apmu RESET_USB30_VCC>, + <&syscon_apmu RESET_USB30_PHY>; + reset-names = "ahb", "vcc", "phy"; + reset-delay = <2>; + snps,hsphy_interface = "utmi"; + snps,dis_enblslpm_quirk; + snps,dis-u2-freeclk-exists-quirk; + snps,dis-del-phy-power-chg-quirk; + snps,dis_u2_susphy_quirk; + snps,dis_u3_susphy_quirk; + snps,dis_rxdet_inp3_quirk; + status = "disabled"; + }; + emmc: mmc@d4281000 { compatible = "spacemit,k1-sdhci"; reg = <0x0 0xd4281000 0x0 0x200>;
Signature · 1 line
2.52.0
PATCH v2 3/3 riscv: dts: spacemit: Enable USB3.0 on BananaPi-F3
In reply to Ze HuangEnable the DWC3 USB 3.0 controller and its associated usbphy2 on the Banana Pi F3 board.
The board utilizes a VLI VL817 hub, which requires two separate power
supplies: one VBUS and one for hub itself. Add two GPIO-controlled fixed-regulators to manage this.
--- arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts | 48 +++++++++++++++++++++++++ 1 file changed, 48 insertions(+)
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts +48 -0
@@ -59,6 +59,26 @@ reg_vcc_4v: vcc-4v { regulator-always-on; vin-supply = <®_dc_in>; }; + + usb3_vbus: regulator-vbus-5v { + compatible = "regulator-fixed"; + regulator-name = "USB30_VBUS"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + regulator-always-on; + gpio = <&gpio K1_GPIO(97) GPIO_ACTIVE_HIGH>; + enable-active-high; + }; + + usb3_vhub: regulator-vhub-5v { + compatible = "regulator-fixed"; + regulator-name = "USB30_VHUB"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + regulator-always-on; + gpio = <&gpio K1_GPIO(123) GPIO_ACTIVE_HIGH>; + enable-active-high; + }; }; &combo_phy {
@@ -67,6 +87,34 @@ &combo_phy { status = "okay"; }; +&usbphy2 { + status = "okay"; +}; + +&usb_dwc3 { + dr_mode = "host"; + vbus-supply = <&usb3_vbus>; + #address-cells = <1>; + #size-cells = <0>; + status = "okay"; + + hub_2_0: hub@1 { + compatible = "usb2109,2817"; + reg = <0x1>; + vdd-supply = <&usb3_vhub>; + peer-hub = <&hub_3_0>; + reset-gpios = <&gpio K1_GPIO(124) GPIO_ACTIVE_LOW>; + }; + + hub_3_0: hub@2 { + compatible = "usb2109,817"; + reg = <0x2>; + vdd-supply = <&usb3_vhub>; + peer-hub = <&hub_2_0>; + reset-gpios = <&gpio K1_GPIO(124) GPIO_ACTIVE_LOW>; + }; +}; + &emmc { bus-width = <8>; mmc-hs400-1_8v;
Signature · 1 line
2.52.0
Re: [PATCH v2 3/3] riscv: dts: spacemit: Enable USB3.0 on BananaPi-F3
Hi Ze,
thanks for your patch, I have few comments, see below..
Quoted 18 lines · Ze Huang
Enable the DWC3 USB 3.0 controller and its associated usbphy2 on the Banana Pi F3 board.
The board utilizes a VLI VL817 hub, which requires two separate power
supplies: one VBUS and one for hub itself. Add two GPIO-controlled fixed-regulators to manage this.Tested-by Aurelien Jarno <[email protected]>Signed-off-by Ze Huang <[email protected]>--- arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts | 48 +++++++++++++++++++++++++ 1 file changed, 48 insertions(+)arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts +0
-0
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts reg_vcc_4v: vcc-4v { · line 63
Quoted 5 lines
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts +2
-0@@ -59,6 +59,26 @@ reg_vcc_4v: vcc-4v { regulator-always-on; vin-supply = <®_dc_in>; }; + + usb3_vbus: regulator-vbus-5v {
I've checked the schematics, the name is 5V_VBUS there, so for the consistency with previous naming convention, let's change to:
usb3_vbus_5v: usb3-vbus-5v
Quoted 4 lines
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts +4
-0+ compatible = "regulator-fixed"; + regulator-name = "USB30_VBUS"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>;
..
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts
Quoted 1 line
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts +1
-0+ regulator-always-on;
do you think the "always-on" property really necessary? it indicate the power regulator is critical, and should never been disabled even during suspend/resume state, for the case of USB, I think it should be totally fine to poweroff once the device is not used(suspended) or even disabled
besides, the regulator is designed with a gpio enabling/disabling control which means it can be powered to on/off state?
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts reg_vcc_4v: vcc-4v { · line 73
Quoted 5 lines
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts +5
-0+ gpio = <&gpio K1_GPIO(97) GPIO_ACTIVE_HIGH>; + enable-active-high; + }; + + usb3_vhub: regulator-vhub-5v {
why use vhub, but not hub? where does this name come from?
and for same reason, the name in schematics is VCC5V0_HUB, so how about change it to:
usb3_hub_5v: usb3-hub-5v
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts
Quoted 2 lines
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts +2
-0+ compatible = "regulator-fixed"; + regulator-name = "USB30_VHUB";
~~~need to fix too, if above is valid
Quoted 2 lines
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts +2
-0+ regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>;
..
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts
Quoted 1 line
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts +1
-0+ regulator-always-on;
ditto
Quoted 10 lines
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts +3
-0+ gpio = <&gpio K1_GPIO(123) GPIO_ACTIVE_HIGH>; + enable-active-high; + }; }; &combo_phy {@@ -67,6 +87,34 @@ &combo_phy { status = "okay"; };
..
Quoted 18 lines
+&usbphy2 {
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts +17
-0+ status = "okay"; +}; + +&usb_dwc3 { + dr_mode = "host"; + vbus-supply = <&usb3_vbus>; + #address-cells = <1>; + #size-cells = <0>; + status = "okay"; + + hub_2_0: hub@1 { + compatible = "usb2109,2817"; + reg = <0x1>; + vdd-supply = <&usb3_vhub>; + peer-hub = <&hub_3_0>; + reset-gpios = <&gpio K1_GPIO(124) GPIO_ACTIVE_LOW>; + };
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts &combo_phy { · line 117
Quoted 10 lines
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts +10
-0+ + hub_3_0: hub@2 { + compatible = "usb2109,817"; + reg = <0x2>; + vdd-supply = <&usb3_vhub>; + peer-hub = <&hub_2_0>; + reset-gpios = <&gpio K1_GPIO(124) GPIO_ACTIVE_LOW>; + }; +}; +
can you move these two after &uart0? I'd like to keep them sorted by label alphabet order..
Quoted 7 lines
&emmc {
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts +0
-0bus-width = <8>; mmc-hs400-1_8v;Signature · 2 lines
-- 2.52.0
Signature · 1 line
Yixun Lan (dlan)
Re: [PATCH v2 3/3] riscv: dts: spacemit: Enable USB3.0 on BananaPi-F3
Hi Ze,
I've done a quick check of the "regulator-always-on" issue, it's ok to drop the one from hub, but not the vbus one..
Quoted 37 lines · Yixun Lan
Hi Ze,
thanks for your patch, I have few comments, see below..
Quoted 18 lines · Ze Huang
Enable the DWC3 USB 3.0 controller and its associated usbphy2 on the Banana Pi F3 board.
The board utilizes a VLI VL817 hub, which requires two separate power
supplies: one VBUS and one for hub itself. Add two GPIO-controlled fixed-regulators to manage this.Tested-by Aurelien Jarno <[email protected]>Signed-off-by Ze Huang <[email protected]>--- arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts | 48 +++++++++++++++++++++++++ 1 file changed, 48 insertions(+)arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts +0
-0arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts reg_vcc_4v: vcc-4v { · line 63
Quoted 5 lines
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts +2
-0@@ -59,6 +59,26 @@ reg_vcc_4v: vcc-4v { regulator-always-on; vin-supply = <®_dc_in>; }; + + usb3_vbus: regulator-vbus-5v {I've checked the schematics, the name is 5V_VBUS there, so for the consistency with previous naming convention, let's change to:
usb3_vbus_5v: usb3-vbus-5vQuoted 4 lines
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts +4
-0+ compatible = "regulator-fixed"; + regulator-name = "USB30_VBUS"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>;..
Quoted 9 lines
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts
Quoted 1 line
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts +1
-0+ regulator-always-on;do you think the "always-on" property really necessary? it indicate the power regulator is critical, and should never been disabled even during suspend/resume state, for the case of USB, I think it should be totally fine to poweroff once the device is not used(suspended) or even disabled
besides, the regulator is designed with a gpio enabling/disabling control which means it can be powered to on/off state?
not ok to drop, see comment below at &usb_dwc3
Quoted 11 lines
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts reg_vcc_4v: vcc-4v { · line 73
Quoted 5 lines
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts +5
-0+ gpio = <&gpio K1_GPIO(97) GPIO_ACTIVE_HIGH>; + enable-active-high; + }; + + usb3_vhub: regulator-vhub-5v {why use vhub, but not hub? where does this name come from?
and for same reason, the name in schematics is
VCC5V0_HUB, so how about change it to:usb3_hub_5v: usb3-hub-5v
Quoted 8 lines
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts
Quoted 2 lines
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts +2
-0+ compatible = "regulator-fixed"; + regulator-name = "USB30_VHUB";~~~need to fix too, if above is valid
Quoted 2 lines
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts +2
-0+ regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>;..
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts
Quoted 1 line
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts +1
-0+ regulator-always-on;ditto
ok to drop, as it's already handled at drivers/usb/misc/onboard_usb_dev.c which will explicitly request the regulator and enable it
Quoted 11 lines
Quoted 10 lines
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts +3
-0+ gpio = <&gpio K1_GPIO(123) GPIO_ACTIVE_HIGH>; + enable-active-high; + }; }; &combo_phy {@@ -67,6 +87,34 @@ &combo_phy { status = "okay"; };..
Quoted 7 lines
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts &combo_phy { · line 96
Quoted 7 lines
+&usbphy2 {
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts +6
-0+ status = "okay"; +}; + +&usb_dwc3 { + dr_mode = "host"; + vbus-supply = <&usb3_vbus>;
due to drivers/usb/dwc3/dwc3-generic-plat.c has no handler to request regulator there will be problem if "regulator-always-on" property is removed..
Quoted 4 lines
Quoted 4 lines
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts +4
-0+ #address-cells = <1>; + #size-cells = <0>; + status = "okay"; +
Signature · 1 line
Yixun Lan (dlan)
Re: [PATCH v2 3/3] riscv: dts: spacemit: Enable USB3.0 on BananaPi-F3
Quoted 5 lines · Yixun Lan
Hi Ze,
I've done a quick check of the "regulator-always-on" issue, it's ok to drop the one from hub, but not the vbus one..
Thanks for your double check
Quoted 87 lines · Yixun Lan
Quoted 37 lines
Hi Ze,
thanks for your patch, I have few comments, see below..
Quoted 18 lines · Ze Huang
Enable the DWC3 USB 3.0 controller and its associated usbphy2 on the Banana Pi F3 board.
The board utilizes a VLI VL817 hub, which requires two separate power
supplies: one VBUS and one for hub itself. Add two GPIO-controlled fixed-regulators to manage this.Tested-by Aurelien Jarno <[email protected]>Signed-off-by Ze Huang <[email protected]>--- arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts | 48 +++++++++++++++++++++++++ 1 file changed, 48 insertions(+)arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts +0
-0arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts reg_vcc_4v: vcc-4v { · line 63
Quoted 5 lines
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts +2
-0@@ -59,6 +59,26 @@ reg_vcc_4v: vcc-4v { regulator-always-on; vin-supply = <®_dc_in>; }; + + usb3_vbus: regulator-vbus-5v {I've checked the schematics, the name is 5V_VBUS there, so for the consistency with previous naming convention, let's change to:
usb3_vbus_5v: usb3-vbus-5vQuoted 4 lines
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts +4
-0+ compatible = "regulator-fixed"; + regulator-name = "USB30_VBUS"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>;..
Quoted 9 lines
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts
Quoted 1 line
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts +1
-0+ regulator-always-on;do you think the "always-on" property really necessary? it indicate the power regulator is critical, and should never been disabled even during suspend/resume state, for the case of USB, I think it should be totally fine to poweroff once the device is not used(suspended) or even disabled
besides, the regulator is designed with a gpio enabling/disabling control which means it can be powered to on/off state?
not ok to drop, see comment below at
&usb_dwc3Quoted 11 lines
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts reg_vcc_4v: vcc-4v { · line 73
Quoted 5 lines
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts +5
-0+ gpio = <&gpio K1_GPIO(97) GPIO_ACTIVE_HIGH>; + enable-active-high; + }; + + usb3_vhub: regulator-vhub-5v {why use vhub, but not hub? where does this name come from?
and for same reason, the name in schematics is
VCC5V0_HUB, so how about change it to:usb3_hub_5v: usb3-hub-5vQuoted 8 lines
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts
Quoted 2 lines
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts +2
-0+ compatible = "regulator-fixed"; + regulator-name = "USB30_VHUB";~~~need to fix too, if above is valid
Quoted 2 lines
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts +2
-0+ regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>;..
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts
Quoted 1 line
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts +1
-0+ regulator-always-on;ditto
ok to drop, as it's already handled at
drivers/usb/misc/onboard_usb_dev.cwhich will explicitly request the regulator and enable itQuoted 11 lines
Quoted 10 lines
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts +3
-0+ gpio = <&gpio K1_GPIO(123) GPIO_ACTIVE_HIGH>; + enable-active-high; + }; }; &combo_phy {@@ -67,6 +87,34 @@ &combo_phy { status = "okay"; };..
Quoted 9 lines
Quoted 7 lines
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts &combo_phy { · line 96
Quoted 7 lines
+&usbphy2 {
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts +6
-0+ status = "okay"; +}; + +&usb_dwc3 { + dr_mode = "host"; + vbus-supply = <&usb3_vbus>;due to
drivers/usb/dwc3/dwc3-generic-plat.chas no handler to request regulator there will be problem if "regulator-always-on" property is removed..
On the BananaPi-F3 and to Jupiter, the VL817 hub setup uses two distinct controls:
GPIO97 controls the physical VBUS supply. GPIO123 controls the VCC5V0_HUB supply for the hub logic.
(Note: This differs from the Orange Pi RV2, where only GPIO123 is used to control the VBUS supply).
dwc3-generic-plat can not currently handle the regulator request explicitly, keeping "regulator-always-on" forces the VBUS to remain active even when suspended, which consumes unnecessary power.
I prefer to drop regulator-always-on in the DTS to accurately describe the hardware capability, and let the driver manage the VBUS state. This ensures better power management.
If anyone have other ideas, please let me know.
Quoted 8 lines
Quoted 5 lines
Quoted 5 lines
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts +4
-0+ #address-cells = <1>; + #size-cells = <0>; + status = "okay"; +Signature · 1 line
Yixun Lan (dlan)
Re: [PATCH v2 3/3] riscv: dts: spacemit: Enable USB3.0 on BananaPi-F3
Hi Ze,
Quoted 118 lines · Ze Huang
Quoted 5 lines · Yixun Lan
Hi Ze,
I've done a quick check of the "regulator-always-on" issue, it's ok to drop the one from hub, but not the vbus one..
Thanks for your double check
Quoted 87 lines · Yixun Lan
Quoted 37 lines
Hi Ze,
thanks for your patch, I have few comments, see below..
Quoted 18 lines · Ze Huang
Enable the DWC3 USB 3.0 controller and its associated usbphy2 on the Banana Pi F3 board.
The board utilizes a VLI VL817 hub, which requires two separate power
supplies: one VBUS and one for hub itself. Add two GPIO-controlled fixed-regulators to manage this.Tested-by Aurelien Jarno <[email protected]>Signed-off-by Ze Huang <[email protected]>--- arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts | 48 +++++++++++++++++++++++++ 1 file changed, 48 insertions(+)arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts +0
-0arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts reg_vcc_4v: vcc-4v { · line 63
Quoted 5 lines
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts +2
-0@@ -59,6 +59,26 @@ reg_vcc_4v: vcc-4v { regulator-always-on; vin-supply = <®_dc_in>; }; + + usb3_vbus: regulator-vbus-5v {I've checked the schematics, the name is 5V_VBUS there, so for the consistency with previous naming convention, let's change to:
usb3_vbus_5v: usb3-vbus-5vQuoted 4 lines
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts +4
-0+ compatible = "regulator-fixed"; + regulator-name = "USB30_VBUS"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>;..
Quoted 9 lines
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts
Quoted 1 line
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts +1
-0+ regulator-always-on;do you think the "always-on" property really necessary? it indicate the power regulator is critical, and should never been disabled even during suspend/resume state, for the case of USB, I think it should be totally fine to poweroff once the device is not used(suspended) or even disabled
besides, the regulator is designed with a gpio enabling/disabling control which means it can be powered to on/off state?
not ok to drop, see comment below at
&usb_dwc3Quoted 11 lines
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts reg_vcc_4v: vcc-4v { · line 73
Quoted 5 lines
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts +5
-0+ gpio = <&gpio K1_GPIO(97) GPIO_ACTIVE_HIGH>; + enable-active-high; + }; + + usb3_vhub: regulator-vhub-5v {why use vhub, but not hub? where does this name come from?
and for same reason, the name in schematics is
VCC5V0_HUB, so how about change it to:usb3_hub_5v: usb3-hub-5vQuoted 8 lines
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts
Quoted 2 lines
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts +2
-0+ compatible = "regulator-fixed"; + regulator-name = "USB30_VHUB";~~~need to fix too, if above is valid
Quoted 2 lines
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts +2
-0+ regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>;..
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts
Quoted 1 line
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts +1
-0+ regulator-always-on;ditto
ok to drop, as it's already handled at
drivers/usb/misc/onboard_usb_dev.cwhich will explicitly request the regulator and enable itQuoted 11 lines
Quoted 10 lines
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts +3
-0+ gpio = <&gpio K1_GPIO(123) GPIO_ACTIVE_HIGH>; + enable-active-high; + }; }; &combo_phy {@@ -67,6 +87,34 @@ &combo_phy { status = "okay"; };..
Quoted 9 lines
Quoted 7 lines
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts &combo_phy { · line 96
Quoted 7 lines
+&usbphy2 {
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts +6
-0+ status = "okay"; +}; + +&usb_dwc3 { + dr_mode = "host"; + vbus-supply = <&usb3_vbus>;due to
drivers/usb/dwc3/dwc3-generic-plat.chas no handler to request regulator there will be problem if "regulator-always-on" property is removed..On the BananaPi-F3 and to Jupiter, the VL817 hub setup uses two distinct controls:
GPIO97 controls the physical VBUS supply. GPIO123 controls the
VCC5V0_HUBsupply for the hub logic.(Note: This differs from the Orange Pi RV2, where only GPIO123 is used to control the VBUS supply).
dwc3-generic-plat can not currently handle the regulator request explicitly, keeping "regulator-always-on" forces the VBUS to remain active even when suspended, which consumes unnecessary power.
Quoted 5 lines
I prefer to drop regulator-always-on in the DTS to accurately describe the hardware capability, and let the driver manage the VBUS state. This ensures better power management.
If anyone have other ideas, please let me know.
If a USB device requires board-level resources to function, then the USB device itself (not the controller) needs a DT node that references these resources. This is the purpose of the usb-device.yaml binding. For the VL817 hub, there is a specific binding that links the highspeed and superspeed hubs together. See Documentation/devicetree/bindings/usb/vialab,vl817.yaml. These nodes are matched with the Linux usb-onboard-hub driver.
Regards,
Samuel
Re: [PATCH v2 3/3] riscv: dts: spacemit: Enable USB3.0 on BananaPi-F3
Quoted 125 lines · Samuel Holland
Hi Ze,
Quoted 122 lines · Ze Huang
Quoted 5 lines · Yixun Lan
Hi Ze,
I've done a quick check of the "regulator-always-on" issue, it's ok to drop the one from hub, but not the vbus one..
Thanks for your double check
Quoted 87 lines · Yixun Lan
Quoted 37 lines
Hi Ze,
thanks for your patch, I have few comments, see below..
Quoted 18 lines · Ze Huang
Enable the DWC3 USB 3.0 controller and its associated usbphy2 on the Banana Pi F3 board.
The board utilizes a VLI VL817 hub, which requires two separate power
supplies: one VBUS and one for hub itself. Add two GPIO-controlled fixed-regulators to manage this.Tested-by Aurelien Jarno <[email protected]>Signed-off-by Ze Huang <[email protected]>--- arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts | 48 +++++++++++++++++++++++++ 1 file changed, 48 insertions(+)arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts +0
-0arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts reg_vcc_4v: vcc-4v { · line 63
Quoted 5 lines
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts +2
-0@@ -59,6 +59,26 @@ reg_vcc_4v: vcc-4v { regulator-always-on; vin-supply = <®_dc_in>; }; + + usb3_vbus: regulator-vbus-5v {I've checked the schematics, the name is 5V_VBUS there, so for the consistency with previous naming convention, let's change to:
usb3_vbus_5v: usb3-vbus-5vQuoted 4 lines
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts +4
-0+ compatible = "regulator-fixed"; + regulator-name = "USB30_VBUS"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>;..
Quoted 9 lines
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts
Quoted 1 line
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts +1
-0+ regulator-always-on;do you think the "always-on" property really necessary? it indicate the power regulator is critical, and should never been disabled even during suspend/resume state, for the case of USB, I think it should be totally fine to poweroff once the device is not used(suspended) or even disabled
besides, the regulator is designed with a gpio enabling/disabling control which means it can be powered to on/off state?
not ok to drop, see comment below at
&usb_dwc3Quoted 11 lines
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts reg_vcc_4v: vcc-4v { · line 73
Quoted 5 lines
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts +5
-0+ gpio = <&gpio K1_GPIO(97) GPIO_ACTIVE_HIGH>; + enable-active-high; + }; + + usb3_vhub: regulator-vhub-5v {why use vhub, but not hub? where does this name come from?
and for same reason, the name in schematics is
VCC5V0_HUB, so how about change it to:usb3_hub_5v: usb3-hub-5vQuoted 8 lines
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts
Quoted 2 lines
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts +2
-0+ compatible = "regulator-fixed"; + regulator-name = "USB30_VHUB";~~~need to fix too, if above is valid
Quoted 2 lines
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts +2
-0+ regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>;..
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts
Quoted 1 line
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts +1
-0+ regulator-always-on;ditto
ok to drop, as it's already handled at
drivers/usb/misc/onboard_usb_dev.cwhich will explicitly request the regulator and enable itQuoted 11 lines
Quoted 10 lines
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts +3
-0+ gpio = <&gpio K1_GPIO(123) GPIO_ACTIVE_HIGH>; + enable-active-high; + }; }; &combo_phy {@@ -67,6 +87,34 @@ &combo_phy { status = "okay"; };..
Quoted 9 lines
Quoted 7 lines
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts &combo_phy { · line 96
Quoted 7 lines
+&usbphy2 {
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts +6
-0+ status = "okay"; +}; + +&usb_dwc3 { + dr_mode = "host"; + vbus-supply = <&usb3_vbus>;due to
drivers/usb/dwc3/dwc3-generic-plat.chas no handler to request regulator there will be problem if "regulator-always-on" property is removed..On the BananaPi-F3 and to Jupiter, the VL817 hub setup uses two distinct controls:
GPIO97 controls the physical VBUS supply. GPIO123 controls the
VCC5V0_HUBsupply for the hub logic.(Note: This differs from the Orange Pi RV2, where only GPIO123 is used to control the VBUS supply).
dwc3-generic-plat can not currently handle the regulator request explicitly, keeping "regulator-always-on" forces the VBUS to remain active even when suspended, which consumes unnecessary power.
I prefer to drop regulator-always-on in the DTS to accurately describe the hardware capability, and let the driver manage the VBUS state. This ensures better power management.
Quoted 9 lines
Quoted 1 line
If anyone have other ideas, please let me know.
If a USB device requires board-level resources to function, then the USB device itself (not the controller) needs a DT node that references these resources. This is the purpose of the
usb-device.yamlbinding. For the VL817 hub, there is a specific binding that links the highspeed and superspeed hubs together. SeeDocumentation/devicetree/bindings/usb/vialab,vl817.yaml. These nodes are matched with the Linux usb-onboard-hub driver.
Hi Samuel,
Thank you for the guidance. I agree that VBUS control is a board-level resource and handling it at host controller level is not appropriate.
I noticed Marco Felsch's patch series "[PATCH v4 0/5] Add onboard-dev USB hub host managed vbus handling support", which adds support for optional vbus-supply at the USB port level. This matches our hardware situation perfectly.
To avoid dependencies on unmerged code, I plan to stick with the "regulator-always-on" approach in the next version (v3). Once Marco's series is merged into the kernel, I will follow up with a patch to switch to the port-based VBUS supply method.
Best regards, Ze
Quoted 3 lines
Regards,
Samuel
Re: [PATCH v2 3/3] riscv: dts: spacemit: Enable USB3.0 on BananaPi-F3
Hi Ze,
Quoted 138 lines · Ze Huang
Quoted 125 lines · Samuel Holland
Hi Ze,
Quoted 122 lines · Ze Huang
Quoted 5 lines · Yixun Lan
Hi Ze,
I've done a quick check of the "regulator-always-on" issue, it's ok to drop the one from hub, but not the vbus one..
Thanks for your double check
Quoted 87 lines · Yixun Lan
Quoted 37 lines
Hi Ze,
thanks for your patch, I have few comments, see below..
Quoted 18 lines · Ze Huang
Enable the DWC3 USB 3.0 controller and its associated usbphy2 on the Banana Pi F3 board.
The board utilizes a VLI VL817 hub, which requires two separate power
supplies: one VBUS and one for hub itself. Add two GPIO-controlled fixed-regulators to manage this.Tested-by Aurelien Jarno <[email protected]>Signed-off-by Ze Huang <[email protected]>--- arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts | 48 +++++++++++++++++++++++++ 1 file changed, 48 insertions(+)arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts +0
-0arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts reg_vcc_4v: vcc-4v { · line 63
Quoted 5 lines
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts +2
-0@@ -59,6 +59,26 @@ reg_vcc_4v: vcc-4v { regulator-always-on; vin-supply = <®_dc_in>; }; + + usb3_vbus: regulator-vbus-5v {I've checked the schematics, the name is 5V_VBUS there, so for the consistency with previous naming convention, let's change to:
usb3_vbus_5v: usb3-vbus-5vQuoted 4 lines
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts +4
-0+ compatible = "regulator-fixed"; + regulator-name = "USB30_VBUS"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>;..
Quoted 9 lines
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts
Quoted 1 line
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts +1
-0+ regulator-always-on;do you think the "always-on" property really necessary? it indicate the power regulator is critical, and should never been disabled even during suspend/resume state, for the case of USB, I think it should be totally fine to poweroff once the device is not used(suspended) or even disabled
besides, the regulator is designed with a gpio enabling/disabling control which means it can be powered to on/off state?
not ok to drop, see comment below at
&usb_dwc3Quoted 11 lines
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts reg_vcc_4v: vcc-4v { · line 73
Quoted 5 lines
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts +5
-0+ gpio = <&gpio K1_GPIO(97) GPIO_ACTIVE_HIGH>; + enable-active-high; + }; + + usb3_vhub: regulator-vhub-5v {why use vhub, but not hub? where does this name come from?
and for same reason, the name in schematics is
VCC5V0_HUB, so how about change it to:usb3_hub_5v: usb3-hub-5vQuoted 8 lines
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts
Quoted 2 lines
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts +2
-0+ compatible = "regulator-fixed"; + regulator-name = "USB30_VHUB";~~~need to fix too, if above is valid
Quoted 2 lines
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts +2
-0+ regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>;..
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts
Quoted 1 line
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts +1
-0+ regulator-always-on;ditto
ok to drop, as it's already handled at
drivers/usb/misc/onboard_usb_dev.cwhich will explicitly request the regulator and enable itQuoted 11 lines
Quoted 10 lines
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts +3
-0+ gpio = <&gpio K1_GPIO(123) GPIO_ACTIVE_HIGH>; + enable-active-high; + }; }; &combo_phy {@@ -67,6 +87,34 @@ &combo_phy { status = "okay"; };..
Quoted 9 lines
Quoted 7 lines
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts &combo_phy { · line 96
Quoted 7 lines
+&usbphy2 {
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts +6
-0+ status = "okay"; +}; + +&usb_dwc3 { + dr_mode = "host"; + vbus-supply = <&usb3_vbus>;due to
drivers/usb/dwc3/dwc3-generic-plat.chas no handler to request regulator there will be problem if "regulator-always-on" property is removed..On the BananaPi-F3 and to Jupiter, the VL817 hub setup uses two distinct controls:
GPIO97 controls the physical VBUS supply. GPIO123 controls the
VCC5V0_HUBsupply for the hub logic.(Note: This differs from the Orange Pi RV2, where only GPIO123 is used to control the VBUS supply).
dwc3-generic-plat can not currently handle the regulator request explicitly, keeping "regulator-always-on" forces the VBUS to remain active even when suspended, which consumes unnecessary power.
I prefer to drop regulator-always-on in the DTS to accurately describe the hardware capability, and let the driver manage the VBUS state. This ensures better power management.
Quoted 9 lines
Quoted 1 line
If anyone have other ideas, please let me know.
If a USB device requires board-level resources to function, then the USB device itself (not the controller) needs a DT node that references these resources. This is the purpose of the
usb-device.yamlbinding. For the VL817 hub, there is a specific binding that links the highspeed and superspeed hubs together. SeeDocumentation/devicetree/bindings/usb/vialab,vl817.yaml. These nodes are matched with the Linux usb-onboard-hub driver.Hi Samuel,
Quoted 8 lines
Thank you for the guidance. I agree that VBUS control is a board-level resource and handling it at host controller level is not appropriate.
I noticed Marco Felsch's patch series "[PATCH v4 0/5] Add onboard-dev USB hub host managed vbus handling support", which adds support for optional vbus-supply at the USB port level. This matches our hardware situation perfectly.
thanks for digging this, the patch looks exactly what we need..
Quoted 5 lines
To avoid dependencies on unmerged code, I plan to stick with the "regulator-always-on" approach in the next version (v3). Once Marco's series is merged into the kernel, I will follow up with a patch to switch to the port-based VBUS supply method.
going forward with "regulator-always-on" approach currently is kind of acceptable, I wouldn't consider there is break if we switch to more proper solution later on, and thanks for pushing this
Quoted 8 lines
Best regards, Ze
Quoted 3 lines
Regards,
Samuel
Signature · 1 line
Yixun Lan (dlan)
Re: [PATCH v2 3/3] riscv: dts: spacemit: Enable USB3.0 on BananaPi-F3
In reply to Yixun LanQuoted 30 lines · Yixun Lan
Hi Ze,
thanks for your patch, I have few comments, see below..
Quoted 18 lines · Ze Huang
Enable the DWC3 USB 3.0 controller and its associated usbphy2 on the Banana Pi F3 board.
The board utilizes a VLI VL817 hub, which requires two separate power
supplies: one VBUS and one for hub itself. Add two GPIO-controlled fixed-regulators to manage this.Tested-by Aurelien Jarno <[email protected]>Signed-off-by Ze Huang <[email protected]>--- arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts | 48 +++++++++++++++++++++++++ 1 file changed, 48 insertions(+)arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts +0
-0arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts reg_vcc_4v: vcc-4v { · line 63
Quoted 5 lines
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts +2
-0@@ -59,6 +59,26 @@ reg_vcc_4v: vcc-4v { regulator-always-on; vin-supply = <®_dc_in>; }; + + usb3_vbus: regulator-vbus-5v {I've checked the schematics, the name is 5V_VBUS there, so for the consistency with previous naming convention, let's change to:
Quoted 1 line
usb3_vbus_5v: usb3-vbus-5v
Agreed. I will rename it to match the schematic.
Quoted 6 lines
Quoted 5 lines
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts +4
-0+ compatible = "regulator-fixed"; + regulator-name = "USB30_VBUS"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>;..
Quoted 9 lines
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts
Quoted 1 line
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts +1
-0+ regulator-always-on;do you think the "always-on" property really necessary? it indicate the power regulator is critical, and should never been disabled even during suspend/resume state, for the case of USB, I think it should be totally fine to poweroff once the device is not used(suspended) or even disabled
besides, the regulator is designed with a gpio enabling/disabling control which means it can be powered to on/off state?
As you pointed out in the following email, dwc3-generic-plat did not manage any regulator. So, either keep "always-on" here, or manage vbus in dwc3-generic-plat.
Quoted 11 lines
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts reg_vcc_4v: vcc-4v { · line 73
Quoted 5 lines
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts +5
-0+ gpio = <&gpio K1_GPIO(97) GPIO_ACTIVE_HIGH>; + enable-active-high; + }; + + usb3_vhub: regulator-vhub-5v {why use vhub, but not hub? where does this name come from?
and for same reason, the name in schematics is
VCC5V0_HUB, so how about change it to:usb3_hub_5v: usb3-hub-5v
I previously used 'vhub' just to align with the 'vbus'. However, using the schematic name is better. I will update it to usb3_hub_5v.
Quoted 41 lines
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts
Quoted 2 lines
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts +2
-0+ compatible = "regulator-fixed"; + regulator-name = "USB30_VHUB";~~~need to fix too, if above is valid
Quoted 2 lines
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts +2
-0+ regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>;..
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts
Quoted 1 line
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts +1
-0+ regulator-always-on;ditto
Quoted 10 lines
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts +3
-0+ gpio = <&gpio K1_GPIO(123) GPIO_ACTIVE_HIGH>; + enable-active-high; + }; }; &combo_phy {@@ -67,6 +87,34 @@ &combo_phy { status = "okay"; };..
Quoted 22 lines
+&usbphy2 {
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts +21
-0+ status = "okay"; +}; + +&usb_dwc3 { + dr_mode = "host"; + vbus-supply = <&usb3_vbus>; + #address-cells = <1>; + #size-cells = <0>; + status = "okay"; + + hub_2_0: hub@1 { + compatible = "usb2109,2817"; + reg = <0x1>; + vdd-supply = <&usb3_vhub>; + peer-hub = <&hub_3_0>; + reset-gpios = <&gpio K1_GPIO(124) GPIO_ACTIVE_LOW>; + }; + + hub_3_0: hub@2 { + compatible = "usb2109,817"; + reg = <0x2>;
Quoted 9 lines
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts &combo_phy { · line 117
Quoted 6 lines
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts +6
-0+ vdd-supply = <&usb3_vhub>; + peer-hub = <&hub_2_0>; + reset-gpios = <&gpio K1_GPIO(124) GPIO_ACTIVE_LOW>; + }; +}; +can you move these two after &uart0? I'd like to keep them sorted by label alphabet order..
OK
Quoted 10 lines
Quoted 7 lines
&emmc {
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts +0
-0bus-width = <8>; mmc-hs400-1_8v;Signature · 2 lines
-- 2.52.0Signature · 1 line
Yixun Lan (dlan)