Skip to contentSkip to conversation

arm64: dts: rockchip: orangepi-5-plus: Enable USB 3.0 ports

PATCH Applied Chen-Yu Tsai 3 participants 3 messages Dec 20, 2024 – Jan 8, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 arm64: dts: rockchip: orangepi-5-plus: Enable USB 3.0 ports

From: Chen-Yu Tsai <[email protected]>

The Orange Pi 5 Plus has its first USB 3.0 interface on the SoC wired directly to the USB type C port next to the MASKROM button, and the second interface wired to a USB 3.0 hub which in turn is connected to the USB 3.0 host ports on the board, as well as the USB 2.0 connection on the M.2 E-key slot.

---
Changes since v1:
- Dropped source current to 1.4A
- Dropped sink current to 10mA, since it doesn't actually sink current
- Added try-power-role
- Added newline before endpoint device nodes in USB connector node

---
 .../dts/rockchip/rk3588-orangepi-5-plus.dts   | 133 ++++++++++++++++++
 1 file changed, 133 insertions(+)
arch/arm64/boot/dts/rockchip/rk3588-orangepi-5-plus.dts +133 -0
index 9f5a38b290bf..000d353645a9 100644
@@ -218,6 +218,18 @@ vcc5v0_sys: regulator-vcc5v0-sys {
 		regulator-max-microvolt = <5000000>;
 	};
 
+	vbus5v0_typec: vbus-typec-regulator {
+		compatible = "regulator-fixed";
+		enable-active-high;
+		gpio = <&gpio4 RK_PB0 GPIO_ACTIVE_HIGH>;
+		pinctrl-names = "default";
+		pinctrl-0 = <&typec5v_pwren>;
+		regulator-name = "vbus5v0_typec";
+		regulator-min-microvolt = <5000000>;
+		regulator-max-microvolt = <5000000>;
+		vin-supply = <&vcc5v0_sys>;
+	};
+
 	vcc5v0_usb20: regulator-vcc5v0-usb20 {
 		compatible = "regulator-fixed";
 		enable-active-high;
@@ -344,6 +356,57 @@ &i2c6 {
 	clock-frequency = <400000>;
 	status = "okay";
 
+	usbc0: usb-typec@22 {
+		compatible = "fcs,fusb302";
+		reg = <0x22>;
+		interrupt-parent = <&gpio0>;
+		interrupts = <RK_PD3 IRQ_TYPE_LEVEL_LOW>;
+		pinctrl-names = "default";
+		pinctrl-0 = <&usbc0_int>;
+		vbus-supply = <&vbus5v0_typec>;
+		status = "okay";
+
+		usb_con: connector {
+			compatible = "usb-c-connector";
+			label = "USB-C";
+			data-role = "dual";
+			power-role = "dual";
+			source-pdos = <PDO_FIXED(5000, 1400, PDO_FIXED_USB_COMM)>;
+			sink-pdos = <PDO_FIXED(5000, 10, PDO_FIXED_USB_COMM)>;
+			op-sink-microwatt = <10>;
+			try-power-role = "source";
+
+			ports {
+				#address-cells = <1>;
+				#size-cells = <0>;
+
+				port@0 {
+					reg = <0>;
+
+					usbc0_hs: endpoint {
+						remote-endpoint = <&usb_host0_xhci_drd_sw>;
+					};
+				};
+
+				port@1 {
+					reg = <1>;
+
+					usbc0_ss: endpoint {
+						remote-endpoint = <&usbdp_phy0_typec_ss>;
+					};
+				};
+
+				port@2 {
+					reg = <2>;
+
+					usbc0_sbu: endpoint {
+						remote-endpoint = <&usbdp_phy0_typec_sbu>;
+					};
+				};
+			};
+		};
+	};
+
 	hym8563: rtc@51 {
 		compatible = "haoyu,hym8563";
 		reg = <0x51>;
@@ -485,6 +548,16 @@ vcc5v0_usb20_en: vcc5v0-usb20-en {
 			rockchip,pins = <3 RK_PB7 RK_FUNC_GPIO &pcfg_pull_none>;
 		};
 	};
+
+	usb-typec {
+		usbc0_int: usbc0-int {
+			rockchip,pins = <0 RK_PD3 RK_FUNC_GPIO &pcfg_pull_up>;
+		};
+
+		typec5v_pwren: typec5v-pwren {
+			rockchip,pins = <4 RK_PB0 RK_FUNC_GPIO &pcfg_pull_none>;
+		};
+	};
 };
 
 &pwm2 {
@@ -876,6 +949,23 @@ &tsadc {
 	status = "okay";
 };
 
+&u2phy0 {
+	status = "okay";
+};
+
+&u2phy0_otg {
+	status = "okay";
+};
+
+&u2phy1 {
+	status = "okay";
+};
+
+&u2phy1_otg {
+	phy-supply = <&vcc5v0_sys>;
+	status = "okay";
+};
+
 &u2phy2 {
 	status = "okay";
 };
@@ -904,6 +994,33 @@ &uart9 {
 	status = "okay";
 };
 
+&usbdp_phy0 {
+	mode-switch;
+	orientation-switch;
+	sbu1-dc-gpios = <&gpio4 RK_PA6 GPIO_ACTIVE_HIGH>;
+	sbu2-dc-gpios = <&gpio4 RK_PA7 GPIO_ACTIVE_HIGH>;
+	status = "okay";
+
+	port {
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		usbdp_phy0_typec_ss: endpoint@0 {
+			reg = <0>;
+			remote-endpoint = <&usbc0_ss>;
+		};
+
+		usbdp_phy0_typec_sbu: endpoint@1 {
+			reg = <1>;
+			remote-endpoint = <&usbc0_sbu>;
+		};
+	};
+};
+
+&usbdp_phy1 {
+	status = "okay";
+};
+
 &usb_host0_ehci {
 	status = "okay";
 };
@@ -912,6 +1029,17 @@ &usb_host0_ohci {
 	status = "okay";
 };
 
+&usb_host0_xhci {
+	usb-role-switch;
+	status = "okay";
+
+	port {
+		usb_host0_xhci_drd_sw: endpoint {
+			remote-endpoint = <&usbc0_hs>;
+		};
+	};
+};
+
 &usb_host1_ehci {
 	status = "okay";
 };
@@ -920,6 +1048,11 @@ &usb_host1_ohci {
 	status = "okay";
 };
 
+&usb_host1_xhci {
+	dr_mode = "host";
+	status = "okay";
+};
+
 &vop_mmu {
 	status = "okay";
 };
Signature · 1 line
2.39.5
Reviewed-by on v2 1/1
#1 lore raw

Hello Chen-Yu,

Quoted 25 lines · Chen-Yu Tsai

From: Chen-Yu Tsai <[email protected]>

The Orange Pi 5 Plus has its first USB 3.0 interface on the SoC wired directly to the USB type C port next to the MASKROM button, and the second interface wired to a USB 3.0 hub which in turn is connected to the USB 3.0 host ports on the board, as well as the USB 2.0 connection on the M.2 E-key slot.

---
Changes since v1:
- Dropped source current to 1.4A
- Dropped sink current to 10mA, since it doesn't actually sink current
- Added try-power-role
- Added newline before endpoint device nodes in USB connector node

---
 .../dts/rockchip/rk3588-orangepi-5-plus.dts   | 133 ++++++++++++++++++
 1 file changed, 133 insertions(+)
arch/arm64/boot/dts/rockchip/rk3588-orangepi-5-plus.dts +0 -0
index 9f5a38b290bf..000d353645a9 100644

arch/arm64/boot/dts/rockchip/rk3588-orangepi-5-plus.dts vcc5v0_sys: regulator-vcc5v0-sys { · line 221

Quoted 4 lines
arch/arm64/boot/dts/rockchip/rk3588-orangepi-5-plus.dts +1 -0
@@ -218,6 +218,18 @@ vcc5v0_sys: regulator-vcc5v0-sys {
 		regulator-max-microvolt = <5000000>;
 	};
 
+	vbus5v0_typec: vbus-typec-regulator {

I think the new policy is to prefix with 'regulator-' so eg.:

vbus5v0_typec: regulator-vbus5v0-typec

With that:

thank you,

	o.
maintainer Applied
#2 lore raw
In reply to Chen-Yu Tsai
Quoted 8 lines · Chen-Yu Tsai

The Orange Pi 5 Plus has its first USB 3.0 interface on the SoC wired directly to the USB type C port next to the MASKROM button, and the second interface wired to a USB 3.0 hub which in turn is connected to the USB 3.0 host ports on the board, as well as the USB 2.0 connection on the M.2 E-key slot.

[...]

Applied, thanks!

[1/1] arm64: dts: rockchip: orangepi-5-plus: Enable USB 3.0 ports

      commit: a15d12f36eb78692d5c3ebd8a5db7fddf3ea160c

Renamed the regulator node according to convention (regulator-foo) and moved it to its correct alphabetical position.

Best regards,

Signature · 1 line
Heiko Stuebner <[email protected]>