Repository navigation
Conversation
|
Thank you, @Somnius, for putting the float last in the series and for saying in the description exactly what the device-tree change does when the guard is off. I checked the DONE rule against Google's driver ( I can't raise the float yet, though. In order of weight:
What I'd need to merge it, once 1 to 4 are settled, attended, on this branch's head on the published base:
And as on #266: please, no more runs at a raised float until we've been through the dead-man limits on omarchy-mobile#761. This merges after #265 and #266. |
The temperature guard takes its voltage tiers and its charge currents from three constant arrays, the step-charging table of the gs201 phones. The Pixel 8 Pro (husky) has another battery and another table: four tiers, 4.20/4.30/4.35/4.48 V, instead of three. Put the tiers and the currents in a struct guard_table, with the number of tiers in use, and let the driver pick the table at probe. The default table holds the numbers the arrays held, so nothing changes for the Pixel 7 Pro, the Pixel 6 Pro and every other board. A machine compatible with "google,zuma-husky" gets the husky table: the chg-cv-limits and chg-cc-limits of the google,battery node in Google's tree (kernel/devices/google/shusky, branch android-gs-shusky-6.1-android16): dts/zuma-shusky-battery.dtsi for the temperature and voltage limits, dts/zuma-husky-battery.dtsi for the 4950 mAh and the six rows, in percent of that design capacity. The temperature bands are the same in both and stay as they are. The tier and limit arithmetic of the guard work moves into two functions without side effects, guard_next_tier() and guard_limits(), so that it can be tested. The limits from the battery description still cap the float voltage and the charge current, and temp_guard is still off by default. With the husky battery node as it is today, 4.20 V and 1.485 A, the float stays 4.20 V in every band and the current 1.485 A, the lowest row of the husky table being 30 % of 4950 mAh. One case differs from the default table on that board: from 0 to 10 C with the battery at 4.20 V or more the current limit was 495 mA and is 1.485 A now, as the Google table has it. With the battery node's 1.485 A cap, every cell of the husky table that charges comes out at the cap, so the current does not change from band to band. What the table changes is the float per band (4.30 V at 0-10 C and 46-48 C, 4.20 V at 48-55 C), which only shows once the battery node asks for more than 4.20 V, and the one cold cell above. The same Google file also ages the table: google,aact-cc-limits lowers the 20-42 C row with use, and google,aafv-ref-offset lowers the float by up to 100 mV with cycles. That is not done here; it doesn't matter at 4.20 V and 0.3 C. Add KUnit tests, built into the driver with CHARGER_MAX77759_KUNIT_TEST: each band edge, the hysteresis, the tier steps of both tables, both tables against their numbers, and the limits with and without the caps of the battery description. They pass under UML (10 of 10), and the driver builds and links as an arm64 module, W=1 clean, with and without the tests. The MAINTAINERS entry of the driver now matches the test file too. Not run on a phone, neither a Pixel 8 Pro nor a Pixel 7 Pro. The choice of the table by the machine compatible is not covered by the tests. Signed-off-by: Lef <me@lefteros.com>
6fbd312 to
0323623
Compare
|
@derekross answers to the open points here, not the DONE fixes yet (those come with the next push of this PR).
93 to 100 % in 18 minutes. You're right that it doesn't add up, and the log shows why: the percent isn't following the charge there. From 19:00:48 (93 %) to 19:18:54 (100 %) I integrated the stretch, 10 s samples (capacity, voltage_now, ocv, current_now, temp)Why
So on the published tree the gauge reads whatever thermistor setup it already holds. Why exactly 22.0 isn't settled until someone reads the registers on a unit like Colin's; one read-only line would do it: For the fix I'd rather not put the whole pack model in the published tree, since the packs' models differ. The smaller fix is a driver patch that writes only Config, TGain and TOff from DT on the max77759 path when there's no model, with Google's three values in husky's node. I'll send that as its own PR as you asked, and show And noted on the float: nothing at a raised float until we've been through the limits on #761. |
0323623 to
bbd1992
Compare
|
Thank you, @Somnius, for the answers, and for moving the DONE functions out from under
Everything else from my last comment stands, and I know the DONE fixes are coming: a DONE below the last tier, the restart count that never comes back on husky (the defender now reads CHGIN itself, the DONE state doesn't), On where the higher float should live: this morning's accident decides it for me. A device tree that carries 4.45 V goes wherever that kernel is booted, guard or no guard. Please leave the battery node at 4.20 V and let the husky table raise the float only while the guard runs; I'll confirm the value itself once I have the cycle counts. The husky package change (loading the charger with Thank you for reporting this morning straight away. I've written about it on #266. No charge at a raised float until we've been through the limits on omarchy-mobile#761; that review is mine to do and I'll do it next. |
bbd1992 to
da8aa6c
Compare
|
@derekross reworked and force-pushed as da8aa6c, now on #266's new head (1244cde):
54 KUnit cases pass, and I also updated the description and title, since the old text was about the 4.45 V DTS. |
|
@derekross one thing I should have put here before proposing a patch that writes only Config, TGain and TOff. I tried exactly those three by hand on 2026-11-01, and they're not enough. From my notes and logs that day, gauge TEMP register 0x08, no second sensor, phone on USB:
Logs: So a probe-time write of only those three would likely give a temperature that's 15 to 20 C high, which is worse than a stuck 22.0 for the guard. The working path on my phone is the whole model load, like #171 for the Pixel 7. I haven't tested whether a write at probe behaves like my hand writes. Colin's read is still worth having to see if his unit sits in the same power-on state. But I'd change the plan from "write the three registers" to "load the model on husky", and the pack question (which model for which pack) comes with it. I'll hold the gauge patch until you say which way. |
|
@derekross, @Somnius, both reads from my unit: published Status (00) read
|
|
@gitColinX thank you, that's the read I was hoping for: your gauge is in the same power-on state mine was on 11-01 (Status 0x0002, Config 0x2354, TGain 0xeb8d, TOff 0x20aa, Temp stuck at 22.0 °C). So it's the port, not my unit. @derekross together with what I posted here last night: Colin's unit matches the power-on state mine was in on 11-01, and on mine writing only Google's three values gave a temperature 15 to 20 °C high, while the full model load gave a plausible one. So the fix I'd propose is loading the model on husky (as #171 does for the Pixel 7), not the three-register write. I'm holding the gauge patch until you say which way. |
set_fast_charge_current_limit() and set_float_voltage_limit() pick the step at or above the requested value (linear_range_get_selector_high_array()), so a request between two steps is written as the next step up. On husky the battery node's 1485000 uA becomes 1533400 uA, 48 mA above the battery's limit. Take the step at or below the request instead, for both, as Google's driver does (max77759_set_charger_current_max_ua() in google-modules/bms rounds down too). The current, at probe: cheetah and raven ask for 1466730 uA, an exact step, so probe writes the same value as before. akita's 1320000 uA goes from 1333390 uA to 1266720 uA. husky's 1485000 uA becomes 1466730 uA. A request above the highest step (4000190 uA) or below the lowest is still -EINVAL, through a new cc_selector() like the float's: a battery node without constant-charge-current-max-microamp leaves -EINVAL in the field, and max77759_charger_init() copies it into a u32, which must stay a failed probe and not become a 4 A current with no cap. The current, under the temperature guard (temp_guard=1), this changes the Pixel 7 Pro, the 6 Pro and the Pixel 7 too: every guard current that falls between two steps is now one step lower. At 0-10 C between 4.20 and 4.30 V the default table asks for 10 % of the capacity, 492.6 mA on the 7 Pro, which was written as 533 mA and is now 467 mA (the 6 Pro's 490.5 mA the same); on the Pixel 7, 427.7 mA was 467 mA and is now 400 mA. Stock rounds down there, so this is a fix for those phones as well. The float: a new fv_selector() takes the step at or below the request, 3900 mV between the two ranges, and still refuses a request below the lowest step or above the highest (4500 mV) with -EINVAL rather than clamping it. Every float in use (4200, 4300, 4450 mV and the guard table's) is a multiple of 10 mV, an exact step, so no written float changes today on any board. Tested: KUnit under UML (new cases for the float steps, the range gap and the limits, and for the current: 1485000, 4000190, 4000191 and (u32)-EINVAL); arm64 objects at W=1 with and without the KUnit option. On a Pixel 8 Pro, 2026-11-18, slot B, kernel 7.3.0-rc6-omamobile-push1-gc4d94a1c1fe5 (an earlier head of this series, linux-omarchy-mobile#266, which still had the charge defender and the husky float restore, now in their own PR, before the -EINVAL above the top current step and the read-back values in the dev_err, which KUnit covers, on the published base, nothing else on top; the charger options from /etc/modprobe.d, temp_guard=1 charge_defender=1 default_ilim_ua=500000; a 500 mA desktop USB port): the probe logged "fast charge 1466730 uA" for husky's 1485000 uA (the bootloader had left 1933420 uA). The float written at probe, 4200 mV, is an exact step, so the float rounding is covered by KUnit only. Not tested: anything on a Pixel 7 Pro, 6 Pro, Pixel 7 or akita; a guard current between two steps on hardware. Signed-off-by: Lef <me@lefteros.com>
Add charge_control_end_threshold and charge_control_start_threshold to
the charger. At 100 / 0, the default, they do nothing and the guard work
reads and writes nothing more than before. With a lower end, charging
stops (buck only, as the temperature guard does) once the battery's
capacity reaches it, and resumes at the start threshold, or 5 % below
the end when start is 0 or not below the end.
Each threshold is checked on its own, so the order of two writes does
not matter: an end at or below the start sets the start back to 0.
charge_control_start_threshold reads back the value in force, so with
an end of 80 and a start of 0 it reads 75, the level charging resumes
at. With the end at 100 it reads the stored start.
The two inhibits, the temperature guard's and the threshold's, are kept
apart so that neither clears the other. The thresholds run first in each
guard run, so a stop is in place before the guard clears its own
inhibit, and a flag only changes once the mode write has worked, so a
failed write is tried again at the next run. The thresholds are checked
by the guard work, at most 30 s after a change in capacity. On unbind,
after the guard work is cancelled, a threshold stop is cleared before
charging is left on.
While either inhibit holds the charge with the cable in (buck only, the
chip reports CHG_DTLS off and CHGIN valid), status now reads Not
charging instead of Discharging. With no input it reads Discharging,
whatever the flags and the last mode written. This reaches the Pixel 7
Pro, the 6 Pro and the Pixel 7 too when they run with temp_guard=1:
while the temperature guard inhibits charging with the cable in, their
status changes from Discharging to Not charging. One more change for
them with temp_guard=1: the guard's inhibit flag is now rolled back when
its mode write fails, and the write is tried again at the next run,
where before the flag stayed set with the chip still charging.
The guard work is delayed work and s2idle stops it, so the thresholds
are only checked while the phone is awake: asleep on the charger, the
chip carries on to the float, and a stop already in place stays in
place. temp_guard's description now says the guard work only runs while
the phone is awake.
The rules are side-effect free functions with KUnit tests; the two
inhibits, the status and the stop and resume on a fake capacity are
tested on a regmap backed by an array, and the tests read their own
fake battery and register their charger supply under a test name, so
they leave guard_psy and the real max77759-charger alone.
Tested: KUnit under UML; arm64 objects at W=1 with and without the KUnit
option.
On a Pixel 8 Pro, 2026-11-18, slot B, kernel
7.3.0-rc6-omamobile-push1-gc4d94a1c1fe5 (an earlier head of this series,
linux-omarchy-mobile#266, which still had the charge defender and the
husky float restore, now in their own PR, before the -EINVAL above the
top current step and the read-back values in the dev_err, which KUnit
covers, on the published base, nothing else on top; the charger options
from /etc/modprobe.d, temp_guard=1 charge_defender=1
default_ilim_ua=500000; a 500 mA desktop USB port):
an end of 90, saved by the Settings unit and applied at boot, stopped
charging 36 s after boot ("charge stopped at 90 %"), status read Not
charging with the cable in and the start read back 85. Unplugged,
online read 0 and status Discharging; plugged back in at 89 %, status
stayed Not charging (resume at 85 % or less). An end of 100 read the
start back as 0, logged "charge resumed: no limit" and status read
Charging; an end of 90 again at 89 % did not stop it (the stop is at
90 % or more) and the start read 85. After a reboot the bootloader had
put the charger mode back (a threshold stop does not survive a reboot)
and the saved end of 90 and start of 85 came back. Status read Full at
89 % once, with the battery at 4.26 V above the 4.20 V float.
Not tested: a stop that reaches the start and resumes on its own,
suspend while plugged in, poweroff (that base lacks the rtc fix, so
reboots only), anything on a Pixel 7 Pro, 6 Pro or Pixel 7.
Signed-off-by: Lef <me@lefteros.com>
…atile The charger regmap caches every register but the interrupt and status ones. CHG_CNFG_00 to CHG_CNFG_04 hold the charger mode, the fast charge current and the float voltage. The charger driver is going to read them back after it writes them, to make sure the chip holds what was asked, and a cached read would only return the value it just wrote. Mark 0xb9-0xbd volatile so reads go to the chip. Writes are the same as before; regmap_update_bits() now reads the chip instead of the cache first, one more i2c read per update. This reaches every board with the MAX77759, the Pixel 7 Pro, the 6 Pro and the Pixel 7 too: every read of these registers, the sysfs reads of the current and the float and every update of them, now goes to the chip, and with temp_guard=1 every guard run talks to the chip. The MFD has no cache sync or cache-only path on suspend, so no resume path changes. Tested: arm64 objects at W=1 with and without the KUnit option; the charger's KUnit tests under UML. On a Pixel 8 Pro, 2026-11-18, slot B, kernel 7.3.0-rc6-omamobile-push1-gc4d94a1c1fe5 (an earlier head of this series, linux-omarchy-mobile#266, which still had the charge defender and the husky float restore, now in their own PR, before the -EINVAL above the top current step and the read-back values in the dev_err, which KUnit covers, on the published base, nothing else on top; the charger options from /etc/modprobe.d, temp_guard=1 charge_defender=1 default_ilim_ua=500000; a 500 mA desktop USB port): probe, the thresholds and the guard ran with no visible change from this; read-only through regmap debugfs the charger registers matched what the driver logged (a 4200 mV float written over the bootloader's 4350 mV, again after a reboot). On 2026-11-16, on an earlier form of this series, 0xbd read 0x2d after probe and 0x23 after unbind (the float restore, since moved to its own PR), the values the driver wrote. Not tested: anything on a Pixel 7 Pro, 6 Pro or Pixel 7. Signed-off-by: Lef <me@lefteros.com>
The temperature guard writes the float voltage and the charge current and has so far ignored a failed write. Read both back from the chip after writing them (the registers are volatile since the previous patch) and keep charging inhibited when the chip does not hold the step the request maps to, or when a write or a read fails. The next guard run tries again; the error is logged once, when it starts, with the float and current asked for and what the chip holds. The release back to the battery's own limits does the same and stays active until the chip is seen to hold them. The write order is unchanged: float, then current. This runs on every board with temp_guard=1, the Pixel 7 Pro, the 6 Pro and the Pixel 7 too: each guard run now writes and reads the two registers on the chip, and a mismatch or a failed read now stops charging (buck only) where a failed write used to be ignored. With temp_guard=0, the default, nothing changes. The expected values come from the same step rounding the setters use, at or below the request for both, so a request between two steps is no mismatch. Tested on a regmap backed by an array: the write order and values, a wrong read-back of the float and of the current gives -EIO with the values the chip holds and puts the chip in buck-only mode, a request refused before the write reads nothing back, and a good one resumes charging. KUnit under UML; arm64 objects at W=1 with and without the KUnit option. On a Pixel 8 Pro, 2026-11-18, slot B, kernel 7.3.0-rc6-omamobile-push1-gc4d94a1c1fe5 (an earlier head of this series, linux-omarchy-mobile#266, which still had the charge defender and the husky float restore, now in their own PR, before the -EINVAL above the top current step and the read-back values in the dev_err, which KUnit covers, on the published base, nothing else on top; the charger options from /etc/modprobe.d, temp_guard=1 charge_defender=1 default_ilim_ua=500000; a 500 mA desktop USB port): the guard logged "battery 38.6 C, 4308 mV: band 20-42 C, float 4200 mV, charge 1485000 uA", and no read-back error or inhibit was logged through the run and a reboot. Not tested: a real mismatch or failed read on hardware (the failure path is KUnit only), anything on a Pixel 7 Pro, 6 Pro or Pixel 7. Signed-off-by: Lef <me@lefteros.com>
Add the charge defender of the stock Pixel 8 Pro charger driver, behind a new charge_defender module parameter that is off by default and only acts on husky: plugged in at 4.27 V or more, time at 35.0 C or more is counted, and after 6 h charging stops at 80 % and resumes at 79 % until the cable comes out. It only stops charging (buck only); nothing drains the battery, so one already above 80 % when it latches stays there until use brings it down. A voltage below 4.27 V starts the count again; a lower temperature only pauses it. A user end threshold below 80 % stays in force. While it is latched, charge_control_end_threshold and charge_control_start_threshold read back the values in force, 80 and 79 (or the user's lower ones), as the start threshold already reads 75 for an end of 80. The numbers are the stock ones from zuma-shusky-charging.dtsi (kernel/devices/google/shusky, branch android-gs-shusky-6.1-android16): google,bd-trigger-voltage 4270000, bd-trigger-temp 350, bd-trigger-time 21600, bd-drainto-soc 80 and bd-recharge-soc 79. Stock's resume conditions (google,bd-resume-abs-temp, bd-resume-soc, bd-resume-time, bd-resume-temp) are not copied: here the stop lasts until unplugged. Each guard run reads CHGIN itself and an input gone clears the defender. On husky that read is what sees an unplug: no TCPM supply notifies this driver there, so the psy work does not run. An unplug and replug that both fall between two guard runs (30 s apart) is missed. On boards where the psy work runs, an unplug it sees is kept for the next guard run, so a quick replug still counts there. The same dtsi also sets google,bd-temp-dry-run. With it, google_charger.c (google-modules/bms) still counts and, on trigger, still calls bd_batt_set_state(), but bd_recharge_logic() returns before it turns charging off, so stock only stops charging once dry run is cleared at run time (its bd_temp_dry_run sysfs file or vote). Whether Android clears it on the 8 Pro is not known here. This driver has no dry run: with charge_defender=1 it stops charging. It uses the threshold stop of the earlier patch, so it is buck only with the cable in and status reads Not charging. The defender runs in the guard work, which is delayed work: s2idle stops it. Each run counts at most 60 s, so time asleep never counts toward the six hours. While the phone sleeps on the charger, a stop already in place stays (buck only), but a charge below 80 % goes on to the float with nothing to stop it at 80 %. The parameter's description says so too. Nothing changes on other boards, with the parameter on or off. The defender step and the choice of thresholds are side-effect free functions with KUnit tests (21599 s does not latch, 21600 s does, the latch holds until unplugged, 4.269 V resets, 34.9 C pauses, one long gap counts at most 60 s); an unplug seen by the psy work, an unplug seen only by the guard run's CHGIN read, and the read-back while latched are tested on a regmap backed by an array. Tested: KUnit under UML; arm64 objects at W=1 with and without the KUnit option. On a Pixel 8 Pro, 2026-11-18, slot B, kernel 7.3.0-rc6-omamobile-push1-gc4d94a1c1fe5 (an earlier head of this series, linux-omarchy-mobile#266, before the -EINVAL above the top current step and the read-back values in the dev_err, which KUnit covers, on the published base, nothing else on top; the charger options from /etc/modprobe.d, temp_guard=1 charge_defender=1 default_ilim_ua=500000; a 500 mA desktop USB port): the charger loaded and charged normally with charge_defender=1, and the threshold stop it uses worked (see the thresholds patch). The defender itself was not exercised: with the husky float at 4.20 V the battery never reaches 4.27 V, so it cannot latch. Not tested: the defender firing on the phone (it needs a float above 4.27 V and 6 h plugged in at 35 C or more), suspend while plugged in, the unplug seen by the guard run while latched. Until a float above 4.27 V it is covered by KUnit only. Signed-off-by: Lef <me@lefteros.com>
On husky, unbind and a new .shutdown put back the float the bootloader left (read at probe before the battery's float replaces it, and capped at the 4.35 V the husky bootloader sets, so a float left by an earlier driver run is not taken for the bootloader's, and taken to be 4.35 V when it cannot be read), but only when the chip's float is above it, so this never raises the float. The restore is read back. When the float cannot be read, or the chip does not hold the restored one, that is logged and charging is stopped (buck only); unbind then leaves it stopped instead of clearing the stop, so the phone does not charge on what may be the raised float. Charging comes back when the driver is bound again, or at the next boot when the bootloader rewrites the charger mode. On unbind the order is: the guard work is cancelled, the float is restored, a threshold stop is cleared (unless the restore failed), and only then is charging left on, so charging never resumes on the raised float. .shutdown disables the guard work on every board, the Pixel 7 Pro, the 6 Pro and the Pixel 7 too, so no guard run, not even one the notifier kicks, writes to the chip after it; the float restore that follows acts on husky only. .shutdown does not clear a threshold or defender stop: a stop in place at shutdown (buck only) stays until the bootloader rewrites the charger mode. With the husky battery node at 4.20 V and the bootloader at 4.35 V the restore does nothing today; it matters once the float is raised. The restore rule is a side-effect free function with KUnit tests (4200 / 4350 and 4350 / 4350 leave it, 4360 / 4350 lowers it, an unknown boot float leaves it), as is the boot float (husky caps it at 4350 mV and falls back to 4350 mV); the restore on husky, the untouched other boards, and a failed read and a failed read-back (charging stays stopped through unbind) are tested on a regmap backed by an array. Tested: KUnit under UML; arm64 objects at W=1 with and without the KUnit option. On a Pixel 8 Pro, 2026-11-18, slot B, kernel 7.3.0-rc6-omamobile-push1-gc4d94a1c1fe5 (an earlier head of this series, linux-omarchy-mobile#266, before the -EINVAL above the top current step and the read-back values in the dev_err, which KUnit covers, on the published base, nothing else on top; the charger options from /etc/modprobe.d, temp_guard=1 charge_defender=1 default_ilim_ua=500000; a 500 mA desktop USB port): the probe read the bootloader's 4350 mV and wrote 4200 mV, so nothing was raised and the restore had nothing to do; a reboot went through .shutdown and the next boot found the bootloader's mode 0x5 and 4350 mV again. On 2026-11-16, on an earlier form of this series with the float raised to 4.45 V, unbinding put it back to 4.35 V (0xbd 0x2d to 0x23). Not tested: a restore that lowers the float on the head of this series (unbind or .shutdown), a failed restore on hardware, poweroff, anything on a Pixel 7 Pro, 6 Pro or Pixel 7. Signed-off-by: Lef <me@lefteros.com>
The chip can report DONE below the float: on a husky left at the bootloader's 4.35 V float, CHG_DTLS read DONE with the gauge at 4.296 V and 92 %. The stock husky charger (max77759_is_full()) only takes that as full in the last voltage tier and within 50 mV of the float; otherwise it turns the charger off and on again so the charge goes on. Do the same in the temperature guard, on husky only. The last tier is the first one whose voltage reaches the float the guard applies: at the battery node's 4.20 V that is the first tier, so a DONE at 4.20 V is full there and does not restart. - in the last tier, DONE at vbatt >= float - 50 mV is full, and stays full until the capacity falls to 95 % or the voltage 250 mV below the float; - in a band that reaches the last tier, DONE in a lower tier is never full (a small adapter under load can reach top-off there, as Google's comment at the top-off interrupt says); - otherwise set the mode off and back to charging, at most once per 10 minutes and 5 times per plug-in, then warn once. Only a restart that ran counts: none while charging is held off or when the off write fails. Putting the mode back is tried three times; then an error is logged and the next guard run, with temp_guard on or off, writes the mode again; - in a band capped below the last tier, DONE is that band's limit and nothing is done, and a full found earlier is cleared. A plug-in gets its restarts back when the psy work sees the source go or, since husky's Type-C node is disabled and no TCPM supply notifies, when the guard run reads CHGIN clear, as the defender does. An unplug and replug that both fall between two runs is missed. While the check runs, status reads Full only for a DONE it accepted; a DONE it restarts, refuses or takes as a band's limit, has not looked at yet (up to one guard period), or sees while the guard has no reading or holds charging off, reads Not charging. It runs only with temp_guard on (off by default), and never while the guard or a charge threshold holds charging off. Other boards are unchanged. The guard run after the gauge read is split out as guard_run(), so KUnit can drive it whole. The rule is a side-effect free function with tests for the full margin, a DONE below the last tier, the tier in force, the recharge levels and the rate limit; the restart writes (off then on), the CHGIN reset, the status and whole guard runs are tested on the array-backed regmap. Tested: KUnit under UML (50 cases pass); an arm64 W=1 build of the driver without the KUnit option. Not tested: anything on hardware at this head. The restart (mode off, then on, with the cable in), its count, and the count coming back after a replug have only run in KUnit; they need one attended run on a weak port with the screen on, at the 4.20 V float, which is not a raised one. Whether CHGIN stays set in CHG_INT_OK across the off/on restart is not known; if it drops, a guard run that sees it clear gives the count back. Nothing on a Pixel 7 Pro, 6 Pro or Pixel 7. Signed-off-by: Lef <me@lefteros.com>
The husky battery node asks for a 4.20 V float, and stays at that: a device tree that carries a higher float applies wherever that kernel is booted, guard or no guard, and so does a driver loaded by hand or with a stale options file. Give the guard table its own float cap, used in place of the battery description's while the guard runs, and set it to 4.45 V for husky. With temp_guard on, the guard takes the battery through the stock tiers up to 4.45 V, with the DONE check, whose last tier follows the cap. When temp_guard is set to 0 at run time, the next guard run puts the node's 4.20 V back, so the raised float can hold for up to one guard period (30 s) after. On unbind or shutdown the float is put back to the bootloader's (at most 4.35 V). With temp_guard off from boot (the default) nothing changes: 4.20 V at probe. Other boards' tables have no cap of their own and keep their node's float. No guard runs while the phone sleeps, so add suspend and resume hooks: suspend stops the guard work and, when the guard has raised the float, puts the node's 4.20 V back and reads it; if the chip does not take it, charging is inhibited instead, and if that write fails too the sleep is refused with -EIO. Resume starts the guard work again, and its first run raises the float if the band allows. Google's husky data (kernel/devices/google/shusky, branch android-gs-shusky-6.1-android16) has google,fv-max-uv = <4480000> in dts/zuma-shusky-charging.dtsi, lowered by google,aafv-ref-cycles and google,aafv-ref-offset in dts/zuma-husky-battery.dtsi by 20 mV per 200 cycles, to 4.38 V from 1000 cycles. 4.45 V is in neither: it is a choice, under the maximum for a new pack and over the schedule past 400 cycles, and stays open until the float is decided. Tested: KUnit under UML (54 cases pass), with cases for the cap the guard run uses on husky and on the default table, a whole guard run raising the float and taking a DONE at 4.42 V as full, a 46-48 C run whose DONE is the band's limit only under the husky cap, the sleep float (lowered, left alone at 4.20 V, raised again by the next run, inhibit when the write fails), and the suspend and resume hooks (float lowered, sleep refused when both writes fail, work queued again on resume). Not tested: anything on hardware, including the suspend and resume hooks on a real s2idle. Whether the chip still reports DONE right after a resume from a sleep at 4.20 V is not known: if it does, the first run after resume, back at 4.45 V, can spend one restart on it. An attended s2idle on the cable settles it. Nothing has charged at this float on this head, and nothing will until the limits on omarchy-mobile#761 are reviewed. Signed-off-by: Lef <me@lefteros.com>
da8aa6c to
c4aca6f
Compare
|
@derekross heads up: after the #266 split this one stacks on the new defender PR (#277) instead of #266, because its two commits need the defender code and don't apply on #266's five alone. The code didn't change, only the hashes below it moved: head is now c4aca6f (was da8aa6c). KUnit is 54/54 and the gate passes. Like the defender, it waits for the gauge temperature fix and for derekross/omarchy-mobile#761. |
@derekross third and last for the 92 % stop on my Pixel 8 Pro, stacked on #277 (the defender and float restore split out of #266), which sits on #266, so only the last two commits are new here. Reworked on 11-18 after your review: the device tree no longer carries 4.45 V.
statusreads Full only for a DONE it accepted. Husky only, only withtemp_guardon, never while charging is held off.Tested: 54 KUnit cases under UML pass (50 at the first commit), the charger builds with W=1 and no warnings through
tools/kernel-pr-check --buildfrom today's main, checkpatch --strict is clean on both, no device tree is touched. The cases drive the guard run itself, the suspend and resume hooks, the restart counting and a failed mode write.Not tested: nothing of this head ran on the phone. The runs from my first version (90 % to 100 % in about 38 minutes, a DONE at 4.43 V accepted) were at the old 4.45 V DTS, so they don't count for this head. Still owed: one attended restart on hardware, which can be done at 4.20 V, and an attended s2idle on the cable (does DONE still show right after resume, and does CHGIN stay set during a restart). The gauge temperature write waits for @gitColinX's register read, and the husky package side (charger options and sleep on the cable, inert) is derekross/omarchy-mobile#899.