Skip to content

arm64: dts: qcom: sm7150-sunfish: enable PM6150 QGauge fuel-gauge#53

Open
miromraz wants to merge 3 commits into
sm7150-mainline:v7.1from
miromraz:sunfish-battery-enable
Open

arm64: dts: qcom: sm7150-sunfish: enable PM6150 QGauge fuel-gauge#53
miromraz wants to merge 3 commits into
sm7150-mainline:v7.1from
miromraz:sunfish-battery-enable

Conversation

@miromraz
Copy link
Copy Markdown

Summary

Enables qcom_qg (Qualcomm PMIC QGauge) on the Google Pixel 4a (sunfish) by:

  1. Adding a simple-battery node at the root of the sunfish DTS with the Pixel 4a's design parameters.
  2. Adding a &pm6150_qgauge override that points monitored-battery at the new battery node and flips status to okay.

qcom_qg is built in this tree and matches qcom,pm6150-qg. Before this patch the driver could not bind because (a) the qgauge node was status="disabled" in pm6150.dtsi and (b) the driver's probe calls power_supply_get_battery_info(), which fails without a monitored-battery reference to a simple-battery node carrying voltage min/max and charge-full-design.

After this patch, /sys/class/power_supply/qcom_qg/ exposes the standard battery psy properties (capacity, voltage_now, voltage_avg, voltage_ocv, current_now, temp, charge_full_design, charge_full, technology).

Battery values

Match Google's downstream sunfish ATL/LSN cell profiles (3080 mAh, 4.45 V max, 3.30 V min) rather than the rounded product-page figures (3140 mAh / 4.4 V). The downstream kernel selects ATL vs LSN per-cell profiles at runtime via a battery-ID resistor; this single static DT node uses the pack data that's shared between both cell vendors.

Caveat documented in the commit body: phones whose LSN cells received the post-incident software mitigation (max charge limited to 3.95 V) will see qcom_qg's voltage-based SOC plateau below 100 %. The mitigation reference is Google downstream commit c6d66c401d23 ("UPSTREAM: power: supply: qpnp-qg: lower the max-voltage of LSN battery to 3.95V").

Why charger@1000 is left disabled

qcom_smbx binds to PM6150 via the qcom,pm8150b-charger fallback compatible, but its smb_init_hw() writes Type-C / OTG configuration registers (SMB5_TYPE_C_MODE_CFG, OTG_CFG, TYPE_C_CFG, ...) that conflict with the already-running qcom,pm6150-typec TCPM driver on this board. Enabling the charger requires either a PM6150-specific match-data entry in qcom_smbx whose init_seq omits the Type-C writes, or a runtime check that skips them when a TCPM is present. That's a follow-up.

adc-tm

Left disabled. qcom_qg consumes only the pm6150_adc bat_therm IIO channel (already enabled), not the ADC-TM threshold monitor.

Test plan

Tested on Google Pixel 4a (sunfish) with kernel 7.1.0-rc3-sm7150:

  • qcom_qg autoloads via udev (alias matches qcom,pm6150-qg)
  • power_supply symlink appears at /sys/class/power_supply/qcom_qg
  • capacity returns plausible % that tracks voltage across discharge cycles
  • voltage_now, current_now, temp read sensible values
  • voltage_ocv persists across reboot (sourced from PMIC SDAM nvmem)
  • dtbs build clean — no new warnings vs unpatched tree (only pre-existing sm7150.dtsi duplicate-unit-address warnings on geniqup nodes)
  • Codex independent code review: no blocking issues

Files changed

arch/arm64/boot/dts/qcom/sm7150-google-sunfish.dts only — +21 lines.

miromraz added 3 commits May 18, 2026 11:53
The pm6150.dtsi disables qgauge@4800 by default because the QGauge
driver (qcom_qg) needs per-board battery parameters before its probe
can succeed: it calls power_supply_get_battery_info() and refuses
to bind without a "monitored-battery" pointing at a simple-battery
node that supplies design voltage min/max and design capacity.

Add a simple-battery node for the Pixel 4a, wire it to
&pm6150_qgauge via monitored-battery, and flip the gauge status to
"okay". After this change qcom_qg binds and exposes the standard
battery power_supply sysfs (capacity, voltage_now, current_now,
temp, voltage_ocv, charge_full_design, ...) under
/sys/class/power_supply/qcom_qg/. Reported capacity is voltage-
linearly-interpolated between voltage_min_design and
voltage_max_design until the driver's stub capacity routine is
replaced upstream.

Battery values mirror Google's downstream sunfish ATL/LSN cell
profiles (3080 mAh, 4.45 V max, 3.30 V min) rather than the
rounded Google product-page figures (3140 mAh, 4.4 V). Downstream
selects between per-cell profiles at runtime via a battery-ID
resistor; this single static DT node uses the pack data the two
cell vendors share. Phones whose LSN cells received the
post-incident software mitigation (max charge limited to 3.95 V)
will see qcom_qg's voltage-based SOC plateau below 100 %; the
mitigation is documented in Google's downstream tree at commit
c6d66c401d23 ("UPSTREAM: power: supply: qpnp-qg: lower the
max-voltage of LSN battery to 3.95V").

charger@1000 is intentionally left disabled. qcom_smbx binds to
PM6150 via the qcom,pm8150b-charger fallback compatible, and its
smb_init_hw() writes Type-C / OTG configuration registers
(SMB5_TYPE_C_MODE_CFG, OTG_CFG, TYPE_C_CFG, ...) that conflict
with the already-running qcom,pm6150-typec TCPM driver on this
board. A proper PM6150-specific match data without those writes is
needed before enabling the charger here.

adc-tm@3500 is left disabled as well: qcom_qg consumes only the
ADC5 bat_therm IIO channel (already enabled via pm6150_adc), not
ADC-TM threshold monitoring.

Tested on Google Pixel 4a (sunfish): qcom_qg probes cleanly, all
power_supply properties read sensible values across charge and
discharge cycles. dtbs build clean with no new warnings.

Signed-off-by: miromraz <mraz.miro@seznam.cz>
Enable the PM6150 SMB2 charger (pm6150_charger node) with a reference
to the battery node so qcom_smbx sets the correct float voltage and
charge current limits.

Wire power-supplies on the fuel gauge so qcom_qg (and UPower above it)
can report Charging/Discharging/Full status correctly.

Fix the USB-C connector: change power-role from "source" to "dual",
add op-sink-microwatt, and add sink-pdos (5V/3A + variable up to 9V/3A)
so the TCPM can negotiate receiving power from a charger.
Instead of always returning UNKNOWN, use power_supply_am_i_supplied()
to check whether a wired charger (listed in DT power-supplies) is
online and return CHARGING or DISCHARGING accordingly. This makes
UPower and userspace correctly reflect charge state.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant