Skip to content

power: supply: max77759: add a guard table per board and one for husky - #265

Open
Somnius wants to merge 1 commit into
derekross:omamobilefrom
Somnius:husky-charger-table-1116
Open

Somnius wants to merge 1 commit into
derekross:omamobilefrom
Somnius:husky-charger-table-1116

Conversation

@Somnius

@Somnius Somnius commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

@derekross first of three for the 92 % stop on my Pixel 8 Pro (derekross/omarchy-mobile#761). The cause is the bootloader's 4.35 V float that nothing in Linux raises yet. As you said on derekross/omarchy-mobile#272, the raise should come with the charger work in the kernel, so this starts there.

This one only gives husky its own step-charging table: four tiers, 4.20/4.30/4.35/4.48 V, with the currents from the factory device tree's google,battery node, in percent of 4950 mAh. The table is picked at probe by the google,zuma-husky compatible. The default table is byte for byte what the three arrays held, so the 7 Pro and 6 Pro don't change. The float doesn't move with this PR, husky still sits at 4.20 V from its battery node, and temp_guard stays off by default.

The one thing that differs on husky: from 0 to 10 C at 4.20 V or more the current limit was 495 mA and is now 1.485 A, as the factory table has it. Details in the commit message.

Tested: 10 KUnit cases under UML, all pass on the current tip (26867fc). The driver object builds for arm64 with W=1 and no warnings on that tip, and checkpatch --strict is clean. Not run on a phone, and the compatible match isn't covered by the tests.

Next two, after this one: the end and start thresholds plus a battery defender like stock's (4.27 V and 35 C for 6 hours, then hold at 80 %), then the husky float raise to 4.45 V with the DONE check last, so the float never goes up before the stop rule is in.

@Somnius

Somnius commented Nov 16, 2026

Copy link
Copy Markdown
Contributor Author

@derekross the failing check is the W=1 build step of tools/kernel-pr-check: it builds max77759_charger_test.c on its own, and that file is only meant to be built from inside the driver, which #includes it at the end like drm_panic.c does with its test. The driver itself builds clean with W=1 and the 10 KUnit tests pass under UML. I opened derekross/omarchy-mobile#851 so the checker builds the including file in that case; with it, every check on this branch is ok when I run it here. If you'd rather I move the tests into a separate module instead, say so and I'll change it.

@derekross

Copy link
Copy Markdown
Owner

Thank you, @Somnius, for starting this in the kernel and for splitting it so the table comes first with nothing else attached. I checked the husky table against 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), and it matches cell for cell. The default table is the old arrays, number for number, and I built the driver with and without the KUnit option at W=1: no warnings.

Two things before it can go in, neither of them a fault in the patch:

  1. CI. You're right about the red check: the gate builds every touched .c on its own, and max77759_charger_test.c can only be built through the driver. I reproduced it here, and the driver itself passes. That's the tool's problem, and I'll look at omarchy-mobile#851 for it. This one waits for that and a re-run.
  2. The Pixel 7 Pro. This is the function the 7 Pro, the 6 Pro and soon the Pixel 7 charge under, and it moved into new helpers, so I can't show identical objects. By reading, nothing changes for the default table. I'll boot it once on my 7 Pro on the charger and compare the guard's line and the float and current registers with today's kernel before I merge. Nothing for you to do there.

One change, please: the message and the comment above guard_table_husky say "the phone's factory device tree". Could you name Google's two files and the branch instead? That's the source I could check.

Two smaller things you may want in the message:

  • With the battery node's 1.485 A cap, every cell of the husky table that charges comes out at the cap, so today the table only changes the float per band (4.30 V at 0-10 C and 46-48 C, 4.20 V at 48-55 C) and the one cold cell you already describe.
  • 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. It doesn't matter at 4.20 V and 0.3 C. It does for max77759: husky DONE check, and the float raised only while the guard runs #267, and I've written about it there.

When this lands it will have a new commit id (kernel PRs are rebase merges), so #266 and #267 will need git rebase --onto omamobile ed5f2e6acbe7 <branch>.

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>
@Somnius
Somnius force-pushed the husky-charger-table-1116 branch from ed5f2e6 to 0d68188 Compare November 18, 2026 08:52
@Somnius

Somnius commented Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

@derekross done in 0d68188. The message and the comment above guard_table_husky now name Google's tree instead of "the phone's factory device tree": kernel/devices/google/shusky, branch android-gs-shusky-6.1-android16, dts/zuma-shusky-battery.dtsi for the temperature and voltage limits and dts/zuma-husky-battery.dtsi for the 4950 mAh and the six rows.

I added your two notes to the message too: with the battery node's 1.485 A cap every charging cell comes out at the cap, and the same file ages the table (google,aact-cc-limits, and google,aafv-ref-offset up to 100 mV), which this patch doesn't do. One wording change on the first one: the message already said the float stays 4.20 V in every band with today's node, so it now says the per-band float only shows once the battery node asks for more than 4.20 V. Otherwise the two sentences would contradict each other.

The gate fix for the red check is #851, which I updated today: derekross/omarchy-mobile#851 (comment). #266 and #267 are already rebased on this head.

@derekross

Copy link
Copy Markdown
Owner

Thank you, @Somnius. The message and the comment now name Google's tree, branch and the two files, and that is the source I checked the table against, so that point is done. Your wording for the cap ("the per-band float only shows once the battery node asks for more than 4.20 V") is better than mine was. Nothing else changed in the code, and the commit builds here at W=1 with and without the tests.

Two things are left and both are mine:

  1. The red check is still the gate building max77759_charger_test.c on its own. It goes green once omarchy-mobile#851 is in and I re-run it.
  2. The boot on my 7 Pro, on the charger, comparing the guard's line and the float and current registers with today's kernel.

When this lands it gets a new commit id, so #266 will need git rebase --onto omamobile 0d68188c380e <branch>.

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.

2 participants