diff --git a/hosts/modules/hal/pine64-pinephone-pro/default.nix b/hosts/modules/hal/pine64-pinephone-pro/default.nix index e232cff81..d352e2093 100644 --- a/hosts/modules/hal/pine64-pinephone-pro/default.nix +++ b/hosts/modules/hal/pine64-pinephone-pro/default.nix @@ -68,6 +68,10 @@ in name = "rk3399-pinephone-pro-sound"; dtsFile = ./rk3399-pinephone-pro-sound.dtso; } + { + name = "rk3399-pinephone-pro-modem"; + dtsFile = ./rk3399-pinephone-pro-modem.dtso; + } ]; # this seems to not actually be necessary (unless maybe my *overlay* #include's stuff) diff --git a/hosts/modules/hal/pine64-pinephone-pro/rk3399-pinephone-pro-modem.dtso b/hosts/modules/hal/pine64-pinephone-pro/rk3399-pinephone-pro-modem.dtso new file mode 100644 index 000000000..cdcd3fb62 --- /dev/null +++ b/hosts/modules/hal/pine64-pinephone-pro/rk3399-pinephone-pro-modem.dtso @@ -0,0 +1,132 @@ +// checked against pine64-org/linux 6.6-20231104-22589 +// i.e. the kernel used by postmarketOS +// schematics for reference: +// +// modem gets power on these lines: +// VCC3V3_S3 +// - comes from RK818's LDO8; already enable in mainline DTS +// VCC_4G +// - generated by feeding VCC_SYS through some gates +// - requires 4G_PWR (RK3399:GPIO4_C7) to be high +// - requires hardware kill-switch to be enabled +// - VCC_SYS is surely already enabled (this is the main power rails) +// VCC_4G_5V +// - generated by feeding VCC5V0_SYS through some gates +// - requires 4G_5V_ON (RK3399:GPIO1_C7) to be high +// - VCC5V0_SYS appears to come from RK818 BOOST_1/BOOST_2 +// alternately supplied by Type-C VCONN_12,VCONN_13 +// +// modem is connected to RK3399 I2C1, via level shifter +// - pine64-org/linux specs i2c1 as 400kHz, which is precisely what RK818 (the PMIC) specs in its datasheet +// however, RK818 isn't documented as being on any I2C line in the PPP schematics. +// - I2C1 frequency would be limited by EG25 modem itself +// and by the level shifter +// and by the ALC5640 codec (system's) +// - max I2C clock is 400kHz +// - max rise: 300ns +// - max fall: 300ns +// and by the ALC5616 codec (modem's) +// and by the AXT530124 MIPI controllers for the front and rear cameras +// and by the OV8858 front camera (via MIPI) (maybe?) +// and by the IMX258 rear camera (via MIPI) (maybe?) +// - I2C1 is pulled up by VCC1V8_CODEC (4.7kOhm) + +// for RK_PC7, other pins +#include +// for GPIO_ACTIVE_HIGH +#include + +/dts-v1/; +/plugin/; + +/ { + /* ensure this overlay applies only to the correct board */ + compatible = "pine64,pinephone-pro"; +}; + +&{/} { + 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>; + regulator-always-on; + }; + + 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"; + // 3.8V is copied from pine64-org/linux. + // i think vcc_4g should match whatever vcc_sys is set to (it's input). + // and vcc_sys would seem to be the battery voltage? + // (even when powered via USB) + regulator-min-microvolt = <3800000>; + regulator-max-microvolt = <3800000>; + vin-supply = <&vcc_sys>; + regulator-always-on; + }; + + vcc5v0_sys: vcc5v0-host-regulator { + compatible = "regulator-fixed"; + regulator-name = "vcc5v0_sys"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + regulator-always-on; + regulator-boot-on; + vin-supply = <&boost_otg>; + + regulator-state-mem { + regulator-on-in-suspend; + }; + }; +}; + +&pinctrl { + 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>; + }; + }; +}; + +// rk3399-pinephone-pro-sound sets this 'okay', but do that here also to avoid implicit dependencies. +&i2c1 { + status = "okay"; + // N.B.: these values are duplicated in rk3399-pinephone-pro-sound.dtso + clock-frequency = <400000>; + i2c-scl-rising-time-ns = <300>; + i2c-scl-falling-time-ns = <15>; +}; + +&rk818 { + regulators { + boost_otg: DCDC_BOOST { + regulator-name = "boost_otg"; + regulator-always-on; + regulator-boot-on; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + regulator-state-mem { + regulator-on-in-suspend; + }; + }; + + // probably not strictly required here + otg_switch: OTG_SWITCH { + regulator-name = "otg_switch"; + }; + }; +};