Skip to contentSkip to conversation

Pinephone Pro Connectivity: Adding Modem, Bluetooth, and Wi-Fi

PATCH New Rudraksha Gupta 2 participants 5 messages Aug 25

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

v2 cover Pinephone Pro Connectivity: Adding Modem, Bluetooth, and Wi-Fi

Continuing the work on upstreaming Pinephone Pro functionality, this patch series gets the connectivity side of the Pinephone Pro mainlined. Here are the following sources:

- https://codeberg.org/megi/linux
- https://gitlab.com/pine64-org/linux/-/commit/f9f847c6fd1

All credits to the following folks:
- Martijn Braam: original author for the Pinephone Pro bringup
- Kamil Trzcinski: original author for the Pinephone Pro bringup. No longer credited as I can't seem to contact this person
- Ondrej Jirman: maintains https://codeberg.org/megi/linux
- Dang Huynh: for the modem patch above

As far as I can tell, I've credited everyone that I know about, but may be missing some because of how long its been since the original implementation till now has been.

I've also included a short guide on how to test these patches. This generally follows this page:
https://wiki.postmarketos.org/wiki/PINE64_PinePhone_Pro_(pine64-pinephonepro)

To test, please follow the following steps:
https://wiki.postmarketos.org/wiki/PINE64_PinePhone_Pro_(pine64-pinephonepro)#External_storage_(microSD_card)

To build your own image, you will need to do something like this:
pmbootstrap init # I typically choose Phosh. Defaults should work
wget https://gitlab.postmarketos.org/postmarketOS/pmaports/-/raw/main/device/community/linux-pine64-pinephonepro/config-pine64-pinephonepro.aarch64 -O arch/arm64/configs/orangepi_defconfig make LLVM=1 CC="ccache clang" O=.output ARCH=arm64 -j $(nproc) W=1 orangepi_defconfig all
pmbootstrap build --envkernel linux-pine64-pinephonepro
pmbootstrap build --force device-pine64-pinephonepro
pmbootstrap install --sdcard=/dev/sdX # Change /dev/sdX appropriately
pmbootstrap -y zap -a # Cleanup everything

---
Changes in v2:
- dropped removing the interrupt GPIO for Wifi as that is now merged into mainline
- reworked clkout2
- dropped all the signed-off-by's. credited in cover letter
- Link to v1: https://lore.kernel.org/r/[email protected]

To: Rob Herring <[email protected]>
To: Krzysztof Kozlowski <[email protected]>
To: Conor Dooley <[email protected]>
To: Heiko Stuebner <[email protected]>
To: Michael Turquette <[email protected]>
To: Stephen Boyd <[email protected]>
To: Brian Masney <[email protected]>
To: Lee Jones <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]

---
Martijn Braam (2):
arm64: dts: rockchip: Enable the EG25-G modem on the Pinephone Pro
clk: rk808: Select the clock function of CLK32KOUT2 on the RK818

 .../boot/dts/rockchip/rk3399-pinephone-pro.dts     | 69 ++++++++++++++++++++++
 drivers/clk/clk-rk808.c                            | 46 ++++++++++++++-
 include/linux/mfd/rk808.h                          |  1 +
 3 files changed, 115 insertions(+), 1 deletion(-)

---
base-commit: 237a1c39e8dfd3e1c6f1f023eea37a48ec04cc63
change-id: 20260112-ppp_connectivity-5edddd7b4904

Best regards,

Signature · 1 line
Rudraksha Gupta <[email protected]>
#1 lore raw

PATCH v2 1/2 arm64: dts: rockchip: Enable the EG25-G modem on the Pinephone Pro

From: Martijn Braam <[email protected]>

The Quectel EG25-G modem is soldered to the board. It sits on the USB 2.0 host controller behind u2phy1, with uart3 as its AT command port, and draws from two switched rails: vcc_4g_5v off the RK818 boost, and vcc_4g off vcc_sys.

Neither rail supplies anything but the modem, which has to stay powered for the board to work as a phone, so both are always-on.

The modem itself has no binding and no in-kernel driver, so it is not described here; its control lines are driven from userspace.

Based on work by Martijn Braam, Kamil Trzciński, Ondrej Jirman and Dang Huynh.

---
 .../boot/dts/rockchip/rk3399-pinephone-pro.dts     | 69 ++++++++++++++++++++++
 1 file changed, 69 insertions(+)
arch/arm64/boot/dts/rockchip/rk3399-pinephone-pro.dts +69 -0
index 8d26bd9b7500..8d2b6a46b39d 100644
@@ -134,6 +134,32 @@ vcca1v8_s3: regulator-vcc1v8-s3 {
 		regulator-boot-on;
 	};
 
+	vcc_4g: regulator-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>;
+		regulator-always-on;
+	};
+
+	vcc_4g_5v: regulator-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>;
+		regulator-always-on;
+	};
+
 	vcc1v8_codec: regulator-vcc1v8-codec {
 		compatible = "regulator-fixed";
 		enable-active-high;
@@ -264,6 +290,7 @@ rk818: pmic@1c {
 		system-power-controller;
 		wakeup-source;
 
+		boost-supply = <&vcc_sys>;
 		vcc1-supply = <&vcc_sys>;
 		vcc2-supply = <&vcc_sys>;
 		vcc3-supply = <&vcc_sys>;
@@ -318,6 +345,17 @@ regulator-state-mem {
 				};
 			};
 
+			vcc5v0_sys: DCDC_BOOST {
+				regulator-name = "vcc5v0_sys";
+				regulator-always-on;
+				regulator-boot-on;
+				regulator-min-microvolt = <5000000>;
+				regulator-max-microvolt = <5000000>;
+				regulator-state-mem {
+					regulator-on-in-suspend;
+				};
+			};
+
 			vcca3v0_codec: LDO_REG1 {
 				regulator-name = "vcca3v0_codec";
 				regulator-min-microvolt = <3000000>;
@@ -702,6 +740,16 @@ blue_led_pin: blue-led-pin {
 		};
 	};
 
+	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>;
+		};
+	};
+
 	pmic {
 		pmic_int_l: pmic-int-l {
 			rockchip,pins = <1 RK_PC5 RK_FUNC_GPIO &pcfg_pull_up>;
@@ -827,6 +875,15 @@ &tsadc {
 	status = "okay";
 };
 
+&u2phy1 {
+	status = "okay";
+};
+
+&u2phy1_host {
+	phy-supply = <&vcc5v0_sys>;
+	status = "okay";
+};
+
 &uart0 {
 	pinctrl-names = "default";
 	pinctrl-0 = <&uart0_xfer &uart0_cts &uart0_rts>;
@@ -852,6 +909,18 @@ &uart2 {
 	status = "okay";
 };
 
+&uart3 {
+	status = "okay";
+};
+
+&usb_host1_ehci {
+	status = "okay";
+};
+
+&usb_host1_ohci {
+	status = "okay";
+};
+
 &vopb {
 	status = "okay";
 	assigned-clocks = <&cru DCLK_VOP0_DIV>, <&cru DCLK_VOP0>,
Signature · 1 line
2.55.0
#2 lore raw

Re: [PATCH v2 1/2] arm64: dts: rockchip: Enable the EG25-G modem on the Pinephone Pro

Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 10 lines

From: Martijn Braam <[email protected]>

The Quectel EG25-G modem is soldered to the board. It sits on the USB 2.0 host controller behind u2phy1, with uart3 as its AT command port, and draws from two switched rails: vcc_4g_5v off the RK818 boost, and vcc_4g off vcc_sys.

Neither rail supplies anything but the modem, which has to stay powered for the board to work as a phone, so both are always-on.

Quoted 8 lines

The modem itself has no binding and no in-kernel driver, so it is not described here; its control lines are driven from userspace.

Based on work by Martijn Braam, Kamil Trzciński, Ondrej Jirman and Dang Huynh.

Sashiko has reviewed this patch and found no issues. It looks great!

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
#3 lore raw

PATCH v2 2/2 clk: rk808: Select the clock function of CLK32KOUT2 on the RK818

In reply to Rudraksha Gupta

From: Martijn Braam <[email protected]>

On the RK818 the CLK32KOUT2 pin is shared between the 32.768 kHz clock output and a recovery function, selected by bit 1 of RK808_CLK32OUT_REG. CLK32KOUT2_EN only takes effect on the clock function, so the output can be enabled and still be silent. The datasheet resets the register to zero, but that cannot be relied on: on the Pine64 PinePhone Pro it reads 0x03 once Linux is up, leaving the wifi and bluetooth without their 32.768 kHz reference.

Select the clock function when the output is prepared, so that it can also be given back, and report the output as prepared only when it is enabled and on the clock function. The bit is not defined on the other variants, so give the RK818 its own clk_ops. Boards that never take the clock are unaffected.

Based on an out-of-tree patch by Martijn Braam & Kamil Trzciński, carried by Ondrej Jirman.

---
 drivers/clk/clk-rk808.c   | 46 +++++++++++++++++++++++++++++++++++++++++++++-
 include/linux/mfd/rk808.h |  1 +
 2 files changed, 46 insertions(+), 1 deletion(-)
drivers/clk/clk-rk808.c +45 -1
index 5a75b5c91555..4aabe0234769 100644
@@ -71,6 +71,49 @@ static const struct clk_ops rk808_clkout2_ops = {
 	.recalc_rate = rk808_clkout_recalc_rate,
 };
 
+static int rk818_clkout2_enable(struct clk_hw *hw, bool enable)
+{
+	struct rk808_clkout *rk808_clkout = container_of(hw,
+							 struct rk808_clkout,
+							 clkout2_hw);
+
+	return regmap_update_bits(rk808_clkout->regmap, RK808_CLK32OUT_REG,
+				  RK818_CLK32KOUT2_FUNC_MASK | CLK32KOUT2_EN,
+				  enable ? CLK32KOUT2_EN : 0);
+}
+
+static int rk818_clkout2_prepare(struct clk_hw *hw)
+{
+	return rk818_clkout2_enable(hw, true);
+}
+
+static void rk818_clkout2_unprepare(struct clk_hw *hw)
+{
+	rk818_clkout2_enable(hw, false);
+}
+
+static int rk818_clkout2_is_prepared(struct clk_hw *hw)
+{
+	struct rk808_clkout *rk808_clkout = container_of(hw,
+							 struct rk808_clkout,
+							 clkout2_hw);
+	u32 val;
+
+	int ret = regmap_read(rk808_clkout->regmap, RK808_CLK32OUT_REG, &val);
+
+	if (ret < 0)
+		return 0;
+
+	return (val & (RK818_CLK32KOUT2_FUNC_MASK | CLK32KOUT2_EN)) == CLK32KOUT2_EN;
+}
+
+static const struct clk_ops rk818_clkout2_ops = {
+	.prepare = rk818_clkout2_prepare,
+	.unprepare = rk818_clkout2_unprepare,
+	.is_prepared = rk818_clkout2_is_prepared,
+	.recalc_rate = rk808_clkout_recalc_rate,
+};
+
 static struct clk_hw *
 of_clk_rk808_get(struct of_phandle_args *clkspec, void *data)
 {
@@ -134,11 +177,12 @@ static const struct clk_ops *rkpmic_get_ops(long variant)
 	case RK809_ID:
 	case RK817_ID:
 		return &rk817_clkout2_ops;
+	case RK818_ID:
+		return &rk818_clkout2_ops;
 	/*
 	 * For the default case, it match the following PMIC type.
 	 * RK805_ID
 	 * RK808_ID
-	 * RK818_ID
 	 */
 	default:
 		return &rk808_clkout2_ops;
include/linux/mfd/rk808.h +1 -0
index 7ffc904c864c..e3cb586d34a0 100644
@@ -1051,6 +1051,7 @@ enum rk806_dvs_mode {
 
 #define VOUT_LO_INT	BIT(0)
 #define CLK32KOUT2_EN	BIT(0)
+#define RK818_CLK32KOUT2_FUNC_MASK	BIT(1)
 
 #define TEMP105C			0x08
 #define TEMP115C			0x0c
Signature · 1 line
2.55.0
#4 lore raw

Re: [PATCH v2 2/2] clk: rk808: Select the clock function of CLK32KOUT2 on the RK818

Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 16 lines

From: Martijn Braam <[email protected]>

On the RK818 the CLK32KOUT2 pin is shared between the 32.768 kHz clock output and a recovery function, selected by bit 1 of RK808_CLK32OUT_REG. CLK32KOUT2_EN only takes effect on the clock function, so the output can be enabled and still be silent. The datasheet resets the register to zero, but that cannot be relied on: on the Pine64 PinePhone Pro it reads 0x03 once Linux is up, leaving the wifi and bluetooth without their 32.768 kHz reference.

Select the clock function when the output is prepared, so that it can also be given back, and report the output as prepared only when it is enabled and on the clock function. The bit is not defined on the other variants, so give the RK818 its own clk_ops. Boards that never take the clock are unaffected.

Quoted 5 lines

Based on an out-of-tree patch by Martijn Braam & Kamil Trzciński, carried by Ondrej Jirman.

Sashiko has reviewed this patch and found no issues. It looks great!

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2