arm64: dts: qcom: sm7150-sunfish: enable PM6150 QGauge fuel-gauge#53
Open
miromraz wants to merge 3 commits into
Open
arm64: dts: qcom: sm7150-sunfish: enable PM6150 QGauge fuel-gauge#53miromraz wants to merge 3 commits into
miromraz wants to merge 3 commits into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Enables
qcom_qg(Qualcomm PMIC QGauge) on the Google Pixel 4a (sunfish) by:simple-batterynode at the root of the sunfish DTS with the Pixel 4a's design parameters.&pm6150_qgaugeoverride that pointsmonitored-batteryat the new battery node and flips status tookay.qcom_qgis built in this tree and matchesqcom,pm6150-qg. Before this patch the driver could not bind because (a) the qgauge node wasstatus="disabled"inpm6150.dtsiand (b) the driver's probe callspower_supply_get_battery_info(), which fails without amonitored-batteryreference to asimple-batterynode 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 Vmax,3.30 Vmin) 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 commitc6d66c401d23("UPSTREAM: power: supply: qpnp-qg: lower the max-voltage of LSN battery to 3.95V").Why charger@1000 is left disabled
qcom_smbxbinds to PM6150 via theqcom,pm8150b-chargerfallback compatible, but itssmb_init_hw()writes Type-C / OTG configuration registers (SMB5_TYPE_C_MODE_CFG,OTG_CFG,TYPE_C_CFG, ...) that conflict with the already-runningqcom,pm6150-typecTCPM driver on this board. Enabling the charger requires either a PM6150-specific match-data entry inqcom_smbxwhoseinit_seqomits 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_qgconsumes only thepm6150_adcbat_thermIIO 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_qgautoloads via udev (alias matchesqcom,pm6150-qg)power_supplysymlink appears at/sys/class/power_supply/qcom_qgcapacityreturns plausible % that tracks voltage across discharge cyclesvoltage_now,current_now,tempread sensible valuesvoltage_ocvpersists across reboot (sourced from PMIC SDAM nvmem)dtbsbuild clean — no new warnings vs unpatched tree (only pre-existingsm7150.dtsiduplicate-unit-address warnings ongeniqupnodes)Files changed
arch/arm64/boot/dts/qcom/sm7150-google-sunfish.dtsonly — +21 lines.