From 158c8223fe365af24a9e36f87886f08a2013517c Mon Sep 17 00:00:00 2001 From: Alejandro Garcia Date: Sat, 31 Oct 2026 17:12:43 -0700 Subject: [PATCH 1/2] arm64: dts: exynos: google: gs201-panther: add the fuel gauge and the battery Describe the MAX77759's fuel gauge at 0x36 on USI13, as on the Pixel 7 Pro: interrupt on gpa9-3, low, with a pull-up, and the 5 mOhm sense resistor, all as in the Pixel 7's live device tree. The battery takes the live tree's values: 4277 mAh (google,chg-battery-capacity), 4.45 V maximum (google,fv-max-uv) and 3.3 V empty (VEmpty of its gauge models). There is no battery model yet, so the gauge reports from its default one: voltage and current are measured, while the capacity, the percentage and the temperature are approximate. Without a model the driver writes only the gauge's alert settings. Tested on a Pixel 7 from slot B (7.3.0-rc6), with the touchscreen, GPU, haptics and USB rescue: max17042_battery binds to 1-0036 and registers max170xx_battery, reading 4.33 V, 99 % and Charging on the cable, with no I2C errors and no interrupts on gpa9-3. upower and the shell show the battery. With the cable out for a minute, btop showed a discharge of about 1.3 W from it; after the replug it read Charging again. As expected with no model, the temperature stays at 22.0 C and charge_full is the default model's. Assisted-by: Claude Opus 5.5 Signed-off-by: Alejandro Garcia --- .../boot/dts/exynos/google/gs201-panther.dts | 38 ++++++++++++++++++- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/arch/arm64/boot/dts/exynos/google/gs201-panther.dts b/arch/arm64/boot/dts/exynos/google/gs201-panther.dts index 6fef68870c..a3008a7da8 100644 --- a/arch/arm64/boot/dts/exynos/google/gs201-panther.dts +++ b/arch/arm64/boot/dts/exynos/google/gs201-panther.dts @@ -5,7 +5,8 @@ * USB (NCM + ACM), the cluster watchdogs from gs201.dtsi, a * simple-framebuffer on the buffer ABL leaves DPP0 scanning out, UFS, the * three keys, the touchscreen with its rails on the main PMIC, the GPU, the - * haptics and the MAX77759's I2C bus. The panel driver stays disabled. + * haptics and the MAX77759's I2C bus with its fuel gauge. The panel driver + * stays disabled. */ /dts-v1/; @@ -48,6 +49,15 @@ }; }; + battery: battery { + compatible = "simple-battery"; + /* google,chg-battery-capacity in the live tree */ + charge-full-design-microamp-hours = <4277000>; + /* google,fv-max-uv; VEmpty of the live tree's gauge models */ + voltage-max-design-microvolt = <4450000>; + voltage-min-design-microvolt = <3300000>; + }; + /* The same pins as cheetah's (Google's gs201-common.dtsi). */ gpio-keys { compatible = "gpio-keys"; @@ -176,7 +186,7 @@ /* * MAX77759 (charger, Type-C port controller, fuel gauge) on USI13, as on * the Pixel 7 Pro: TCPC 0x25, PMIC 0x66, fuel gauge 0x36, charger 0x69, - * bus pins gpp25-0/1. Its devices are not described yet: the Type-C port + * bus pins gpp25-0/1. Only the fuel gauge is described: the Type-C port * controller would take over VBUS and the data role from the forced-VBUS * setup the USB PHY uses, and the USB link is our only way into the phone. */ @@ -188,6 +198,21 @@ &hsi2c_13 { clock-frequency = <400000>; status = "okay"; + + /* + * No battery model yet: the gauge reports from its default one, so + * the capacity and the temperature are approximate. + */ + fuel-gauge@36 { + compatible = "maxim,max77759-fg"; + reg = <0x36>; + interrupts-extended = <&gpa9 3 IRQ_TYPE_LEVEL_LOW>; + pinctrl-0 = <&if_pmic_fg_int>; + pinctrl-names = "default"; + /* maxim,rsense-default = <500> (10 uOhm units) in the live tree */ + shunt-resistor-micro-ohms = <5000>; + monitored-battery = <&battery>; + }; }; /* @@ -206,6 +231,15 @@ }; }; +&pinctrl_gpio_alive { + if_pmic_fg_int: if-pmic-fg-int-pins { + samsung,pins = "gpa9-3"; + samsung,pin-function = ; + samsung,pin-pud = ; + samsung,pin-drv = ; + }; +}; + &pinctrl_peric0 { status = "okay"; }; From c006c7de386a2515e83f13c6108034609d7cac53 Mon Sep 17 00:00:00 2001 From: Alejandro Garcia Date: Sat, 31 Oct 2026 18:05:20 -0700 Subject: [PATCH 2/2] arm64: dts: exynos: google: gs201-panther: give the fuel gauge its battery model Give the gauge the ModelGauge m5 model that the stock kernel loads for the pack with a 1 kOhm ID resistor (Coslight, cos-a1-1k in Google's gs201-panther-battery-data.dtsi), as the Pixel 7 Pro does with its own. The phone's pack is that one: under stock's driver the gauge's TempCo read 0x1a02, this model's, where the 0 and 3 kOhm models have 0x223e and 0x1802. RelaxCfg takes the value stock writes over the model at boot (r_regval_1720x in the live device tree); the rest, FilterCfg included, is Google's, and the same as the live tree's. On a POR, the driver writes the model into the gauge's RAM and clears POR. With it, the gauge measures the battery thermistor, and one capacity LSB becomes 2 mAh (TaskPeriod 0x2d00). Tested on a Pixel 7 from slot B (7.3.0-rc6), on top of the previous patch, with the gauge in POR: the driver logs "battery model loaded (DesignCap 0x873, TaskPeriod 0x2d00)". On the cable it then read 92 % (99 % with the default model), 4.33 V, 33.1 C (22.0 C before), charge_full 4324 mAh of 4326 mAh design, and Charging. upower and the shell show 92 %. With the cable out for a minute, btop showed a discharge of 1.38-1.67 W from it. No I2C errors. The gauge's interrupt fired in bursts, about 1300 times while the model loaded and about 400 during the unplug, and was quiet otherwise. Assisted-by: Claude Opus 5.5 Signed-off-by: Alejandro Garcia --- .../boot/dts/exynos/google/gs201-panther.dts | 51 +++++++++++++++++-- 1 file changed, 47 insertions(+), 4 deletions(-) diff --git a/arch/arm64/boot/dts/exynos/google/gs201-panther.dts b/arch/arm64/boot/dts/exynos/google/gs201-panther.dts index a3008a7da8..cae0e762a9 100644 --- a/arch/arm64/boot/dts/exynos/google/gs201-panther.dts +++ b/arch/arm64/boot/dts/exynos/google/gs201-panther.dts @@ -199,10 +199,6 @@ clock-frequency = <400000>; status = "okay"; - /* - * No battery model yet: the gauge reports from its default one, so - * the capacity and the temperature are approximate. - */ fuel-gauge@36 { compatible = "maxim,max77759-fg"; reg = <0x36>; @@ -212,6 +208,53 @@ /* maxim,rsense-default = <500> (10 uOhm units) in the live tree */ shunt-resistor-micro-ohms = <5000>; monitored-battery = <&battery>; + + /* + * Battery model for the pack with a 1 kOhm ID resistor, the one + * this phone has (the gauge's TempCo read 0x1a02 under stock's + * driver, which is this model's). From Google's + * gs201-panther-battery-data.dtsi (cos-a1-1k, model version 2), + * except RelaxCfg 0x143b, the value stock writes over the + * model's at boot (r_regval_1720x). TaskPeriod 0x2d00 makes one + * capacity LSB 2 mAh with 5 mOhm: DesignCap 0x0873 = 4326 mAh. + */ + maxim,fg-model = /bits/ 16 < + 0x8c80 0xb770 0xb8f0 0xba50 0xbb40 0xbc30 0xbe00 0xbfd0 + 0xc1b0 0xc3a0 0xc6b0 0xc9c0 0xd020 0xd300 0xd5e0 0xdc30 + 0x0080 0x1070 0x1020 0x0ed0 0x0f00 0x1700 0x1530 0x0c20 + 0x0c40 0x07f0 0x07f0 0x06f0 0x0710 0x06d0 0x06f0 0x06f0 + 0x0200 0x0200 0x0200 0x0200 0x0200 0x0200 0x0200 0x0200 + 0x0200 0x0200 0x0200 0x0200 0x0200 0x0200 0x0200 0x0200 + >; + maxim,fg-params = /bits/ 16 < + 0xf060 /* IAvgEmpty */ + 0x143b /* RelaxCfg */ + 0x260e /* LearnCfg */ + 0x4217 /* Config: external thermistor, TEx clear */ + 0x0090 /* Config2 */ + 0x5f00 /* FullSOCThr */ + 0x0873 /* FullCapRep */ + 0x0873 /* DesignCap */ + 0x3200 /* dPAcc */ + 0x021c /* dQAcc */ + 0x0873 /* FullCapNom */ + 0xa561 /* VEmpty */ + 0x1f00 /* QRTable00 */ + 0x0d80 /* QRTable10 */ + 0x0480 /* QRTable20 */ + 0x0400 /* QRTable30 */ + 0x0740 /* RComp0 */ + 0x1a02 /* TempCo */ + 0x0557 /* IChgTerm */ + 0xed51 /* TGain */ + 0x1eba /* TOff */ + 0x0014 /* Curve */ + 0x3870 /* MiscCfg */ + 0x1900 /* AtRate */ + 0x2241 /* ConvgCfg */ + 0xc613 /* FilterCfg */ + 0x2d00 /* TaskPeriod */ + >; }; };