From a44df1c36a77d0d62ba80314482e24987bf786d0 Mon Sep 17 00:00:00 2001
From: Ondrej Jirman <megi@xff.cz>
Date: Fri, 9 Sep 2022 16:39:58 +0200
Subject: [PATCH 284/389] arm64: dts: pinephone-pro: Add modem support

- Host USB for the modem
- Power supplies
- Power controller driver

Signed-off-by: Ondrej Jirman <megi@xff.cz>
---
 .../dts/rockchip/rk3399-pinephone-pro.dts     | 93 +++++++++++++++++++
 1 file changed, 93 insertions(+)

diff --git a/arch/arm64/boot/dts/rockchip/rk3399-pinephone-pro.dts b/arch/arm64/boot/dts/rockchip/rk3399-pinephone-pro.dts
index 33561aebef48..f880465865bf 100644
--- a/arch/arm64/boot/dts/rockchip/rk3399-pinephone-pro.dts
+++ b/arch/arm64/boot/dts/rockchip/rk3399-pinephone-pro.dts
@@ -287,6 +287,30 @@ vcca1v8_s3: vcc1v8-s3-regulator {
 		regulator-boot-on;
 	};
 
+	vcc_4g_5v: vcc-4g-5v {
+		compatible = "regulator-fixed";
+		enable-active-high;
+		gpio = <&gpio1 RK_PC7 GPIO_ACTIVE_HIGH>;
+		pinctrl-names = "default";
+		pinctrl-0 = <&vcc_4g_5v_en>;
+		regulator-name = "vcc_4g_5v";
+		regulator-min-microvolt = <5000000>;
+		regulator-max-microvolt = <5000000>;
+		vin-supply = <&vcc5v0_sys>;
+	};
+
+	vcc_4g: vcc-4g {
+		compatible = "regulator-fixed";
+		enable-active-high;
+		gpio = <&gpio4 RK_PC7 GPIO_ACTIVE_HIGH>;
+		pinctrl-names = "default";
+		pinctrl-0 = <&vcc_4g_en>;
+		regulator-name = "vcc_4g";
+		regulator-min-microvolt = <3800000>;
+		regulator-max-microvolt = <3800000>;
+		vin-supply = <&vcc_sys>;
+	};
+
 	vcc1v8_codec: vcc1v8-codec-regulator {
 		compatible = "regulator-fixed";
 		enable-active-high;
@@ -975,6 +999,35 @@ mipi_in_panel: endpoint {
 	};
 };
 
+&uart3 {
+	status = "okay";
+
+	modem {
+		compatible = "quectel,eg25";
+		char-device-name = "modem-power";
+
+		pinctrl-names = "default";
+		pinctrl-0 = <&modem_control_pins>;
+
+		power-supply = <&vcc_4g>;
+		vbus-supply = <&vcc_4g_5v>;
+
+		enable-gpios = <&gpio0 RK_PB0 GPIO_ACTIVE_HIGH>; // W_DISABLE#
+		reset-gpios = <&gpio3 RK_PB0 GPIO_ACTIVE_HIGH>;
+		status-gpios = <&gpio3 RK_PA6 GPIO_ACTIVE_HIGH>;
+		pwrkey-gpios = <&gpio0 RK_PB5 GPIO_ACTIVE_HIGH>;
+
+		host-ready-gpios = <&gpio0 RK_PB4 GPIO_ACTIVE_HIGH>; // apready
+		wakeup-gpios = <&gpio0 RK_PA1 GPIO_ACTIVE_HIGH>; // ri
+
+		dtr-gpios = <&gpio0 RK_PA3 GPIO_ACTIVE_HIGH>;
+		cts-gpios = <&gpio3 RK_PC0 GPIO_ACTIVE_HIGH>;
+		rts-gpios = <&gpio3 RK_PC1 GPIO_ACTIVE_HIGH>;
+
+		quectel,qdai = "3,0,0,4,0,0,1,1";
+	};
+};
+
 &pmu_io_domains {
 	pmu1830-supply = <&vcc_1v8>;
 	status = "okay";
@@ -1045,6 +1098,29 @@ flash_pins: flash-pins {
 		};
 	};
 
+	modem {
+		vcc_4g_5v_en: vcc-4g-5v-en-pin {
+			rockchip,pins = <1 RK_PC7 RK_FUNC_GPIO &pcfg_pull_none>;
+		};
+
+		vcc_4g_en: vcc-4g-en-pin {
+			rockchip,pins = <4 RK_PC7 RK_FUNC_GPIO &pcfg_pull_none>;
+		};
+
+		modem_control_pins: modem-control-pins {
+			rockchip,pins =
+				<0 RK_PB0 RK_FUNC_GPIO &pcfg_pull_none>,
+				<3 RK_PB0 RK_FUNC_GPIO &pcfg_pull_none>,
+				<3 RK_PA6 RK_FUNC_GPIO &pcfg_pull_none>,
+				<0 RK_PB5 RK_FUNC_GPIO &pcfg_pull_none>,
+				<0 RK_PB4 RK_FUNC_GPIO &pcfg_pull_none>,
+				<0 RK_PA1 RK_FUNC_GPIO &pcfg_pull_none>,
+				<0 RK_PA3 RK_FUNC_GPIO &pcfg_pull_none>,
+				<3 RK_PC0 RK_FUNC_GPIO &pcfg_pull_none>,
+				<3 RK_PC1 RK_FUNC_GPIO &pcfg_pull_none>;
+		};
+	};
+
 	pmic {
 		pmic_int_l: pmic-int-l {
 			rockchip,pins = <1 RK_PC5 RK_FUNC_GPIO &pcfg_pull_up>;
@@ -1201,6 +1277,15 @@ &u2phy0_host {
 	phy-supply = <&vcc5v0_sys>;
 };
 
+&u2phy1 {
+	status = "okay";
+};
+
+&u2phy1_host {
+	status = "okay";
+	phy-supply = <&vcc5v0_sys>;
+};
+
 &uart0 {
 	pinctrl-names = "default";
 	pinctrl-0 = <&uart0_xfer &uart0_cts &uart0_rts>;
@@ -1234,6 +1319,14 @@ &usb_host0_ohci {
 	status = "okay";
 };
 
+&usb_host1_ehci {
+	status = "okay";
+};
+
+&usb_host1_ohci {
+	status = "okay";
+};
+
 &usbdrd3_0 {
 	status = "okay";
 };
-- 
2.35.3

