Skip to content

power: supply: MAX77759 charging and battery-alert fixes (curated 1/8) - #140

Closed
derekross wants to merge 5 commits into
omamobilefrom
curated/1-charging
Closed

derekross wants to merge 5 commits into
omamobilefrom
curated/1-charging

Conversation

@derekross

Copy link
Copy Markdown
Owner

Five commits:

  • max17042_battery (3): use dSOCi for MAX77759 SOC alerts, wait for the MAX77759 to release ALRT, and ignore interrupts with no status bit set.
  • max77759 (2): disable the fast-charge safety timer, as Google's driver does, and stay online while a full battery is on the charger. Before this, CHG_OK cleared at DONE and upower treated a full phone on the cable as on battery.

Evidence: device/cheetah/NOTES.md 2026-10-30. Overnight on 00568 the charge went CC, CV, top-off, then DONE, with CNFG_01 at 0x98. On 00571 the charger reads online at Full.

These drivers are shared with the Pixel 6 Pro, so raven needs a charge test before merge.

Part of the curated Pixel 7 Pro publish (8 stacked PRs, merged in order, commit by commit). This branch is based on the previous series' branch; after each merge the next PR is retargeted to omamobile. The whole stack equals the integration kernel the reference phone runs, merged with omamobile: 7.3.0-rc6-omamobile-push1-gaae3b058ef98 booted on the Pixel 7 Pro on 2026-10-30 with tools/phone-smoke all ok (display, GPU, touch, Wi-Fi, Bluetooth, sound, sensors, four cameras, charging). Every series end builds with no new warnings. Fixups and reverts are folded, and pure debugging code was dropped. Every commit carries the author's Signed-off-by.

Draft until the Pixel 6 Pro (raven) check of the shared drivers is done.

🤖 Generated with Claude Code

derekross and others added 5 commits October 30, 2026 10:02
The MAX77759 fuel gauge has the same Config2.dSOCen / Status.dSOCi
1 % change alert as the MAX17055, and the battery model loaded on POR
enables it (Config2 0x0090 on the Pixel 7 Pro). The driver still
treated the MAX77759 like the older gauges and also armed a SALRT
window of +/-1 % around the current SOC, re-armed from the integer
part of RepSOC on every alert. Both alerts then watch the same
whole-percent boundary.

On a Pixel 7 Pro (gs201) the gauge interrupt fires in bursts of 300
to 460 interrupts within about a second, each time RepSOC crosses a
whole percent, while charging and while discharging; one boot counted
43960 gauge interrupts before the battery ran flat. SALRT read the
window around the new percent (0x1412 at 19.00 %) at every burst.

Use the MAX17055 scheme on the MAX77759: dSOCi for the 1 % steps and
SALRT only for the critical SOC threshold. Google's driver for this
gauge does the same; it enables dSOCen through the model's Config2 and
never programs SALRT. It also drops the 1 % window during suspend, so a
suspended phone is no longer woken on every percent, which is what the
MAX17055 path already does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Derek Ross <derekross@gmail.com>
The MAX77759 fuel gauge doesn't release its ALRT output when the host
clears Status; it does so at a later fuel-gauge update, up to one task
period afterwards. Google's driver for this gauge says so ("gauge will
take up to 351 ms to clear ALRM1") and sleeps 500 ms at the end of its
threaded handler for that reason.

This driver requests the interrupt oneshot and the line is level-low,
so the interrupt is unmasked as soon as the handler returns and taken
again while ALRT is still asserted. On a Pixel 7 Pro (gs201, TaskPeriod
0x2d00, 351.6 ms) every whole-percent change produced a burst of 300 to
460 interrupts within about a second, and Status read 0x0000 around the
bursts. Each pass reads Status over I2C and sends a power_supply
uevent, which also wakes userspace hundreds of times per percent.

Keep the interrupt masked for one and a half task periods after a pass
on the MAX77759. The period is read from the gauge, so a battery model
that changes TaskPeriod changes the wait too. An alert that is still
pending afterwards keeps the line low and is taken on the next pass, so
none is lost. Other gauges are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Derek Ross <derekross@gmail.com>
… set

The threaded handler reports a power supply change on every interrupt,
even when Status has no bit set. The interrupt is requested shared, so
such an interrupt may belong to another device; on a gauge that is
slow to release ALRT it is the same alert taken again. On a Pixel 7 Pro
(MAX77759) the second case sent hundreds of power_supply uevents per
whole-percent change, each read again by userspace.

Return IRQ_NONE without a uevent when Status reads zero, so a shared
line is reported correctly and a line that stays asserted with nothing
latched is caught by the spurious interrupt detector instead of turning
into a stream of uevents. On the MAX77759 the alert hold-off applies on
this path too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Derek Ross <derekross@gmail.com>
The driver leaves CHG_CNFG_01's FCHGTIME at the value it finds, so the
charger's fast-charge safety timer stays armed. With the input limited
to 500 mA a charge from empty takes longer than that timer: on a Pixel 7
Pro charging from 0 % on a laptop port, the charger stopped after about
12 hours at 92 %, reading offline and "Not charging" with the cable in
and USB still working, until a reboot started it again.

Google's max77759_charger.c clears FCHGTIME at probe ("disable fast
charge safety timer"), leaving charge termination to the charger's own
done detection and the battery's temperature limits. Do the same in
init, inside the window where the protected registers are unlocked.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Derek Ross <derekross@gmail.com>
…harger

charger_input_valid() required both CHGIN_OK and CHG_OK in CHG_INT_OK.
CHG_OK clears when the charge is done: on a Pixel 7 Pro on a laptop port,
CHG_INT_OK went from 0xdd to 0xcd as CHG_DETAILS_01 reached DONE (0x4),
and online and present dropped to 0 with the cable in and the mode still
CHG_BUCK_ON. Userspace then counts a full phone on the charger as running
on battery (upower applies its battery policy).

Report the input from CHGIN_OK alone; the status property already says
Full, and charger faults through status and health.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Derek Ross <derekross@gmail.com>
@derekross

Copy link
Copy Markdown
Owner Author

Landed in kernel-2026.11.01 (2219cc6) on omamobile. The dSOCi, safety-timer and full-battery commits are there as they are. The two ALRT commits were replaced by #170 and #180 (the one-task-period wait), as said on #170. Closing.

@derekross derekross closed this Nov 2, 2026
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