Skip to content

gpio: Add the Maxim MAX77779 PMIC's SGPIO block (Pixel 9a) - #155

Draft
W4HO-ham wants to merge 2 commits into
derekross:omamobilefrom
W4HO-ham:tegu-max77779-pmic-v3
Draft

W4HO-ham wants to merge 2 commits into
derekross:omamobilefrom
W4HO-ham:tegu-max77779-pmic-v3

Conversation

@W4HO-ham

Copy link
Copy Markdown
Contributor

The piece #127 point 4 turned out to need: the RT9470 boost's interrupt and chip enable are MAX77779 sub-GPIOs (SGPIO6 and SGPIO7 on the PMIC block at 0x66, stock's rt,intr_gpio and rt,ceb_gpio), and Google's driver services the boost's 40 s watchdog from that interrupt. Nothing on omamobile provided the block, so here it is: a binding, a GPIO driver with an interrupt chip for the eight SGPIOs (edge triggers per pin in CNFG, level requests re-checked by the handler as Google's driver does, pulls through set_config), and a MAINTAINERS entry. The register map is Google's max77779_regs.h, cited by commit in the message, and the shape follows mainline's gpio-max77759 (the 7 Pro's chip), minus the MFD core, since on this chip the other blocks already have their own drivers and lines.

Tested on the palmtop against the running kernel, the device instantiated on hsi2c6 by hand (no interrupt line in the running tree): the block answers ID 0x79, revision 0x02, the chip registers eight lines, and the register readout is the OTP default (SGPIO6 an input with its pull-down, SGPIO7 off), which also says the boost's enable isn't driven by anyone today. The interrupt path and the pin states stock applies (pull-up on SGPIO6, SGPIO7 as the enable) need the board node (interrupts = <&gpa8 0 LEVEL_LOW>, pinned like stock's if_pmic_irq) and the RT9470's lines on it; that is the next commit on the host-mode series and a boot I'll do with the owner at the palmtop, so this stays a draft until then.

checkpatch --strict: clean per commit (the ENOTSUPP in set_config is what gpiolib tests for an unsupported configuration). W=1 build of the driver clean; dt_binding_check on the binding and its example passes.

Opened from tegu-max77779-pmic-v3, as asked on #139, which this replaces; the content is the v3 you reviewed there.

The MAX77779 interface PMIC (Google Pixel 9a) is a set of I2C blocks on
one chip; the charger, the fuel gauge and the Type-C port controller
have their bindings. The PMIC block at 0x66 owns the chip's interrupt
line and eight SGPIO pins with interrupt support, which carry the
board's charger side signals (the RT9470 boost's interrupt and enable,
the wireless charger's lines). Describe it as a GPIO and interrupt
controller.

Signed-off-by: W4HO <87742609+W4HO-ham@users.noreply.github.com>
@derekross

Copy link
Copy Markdown
Owner

Thank you, @W4HO-ham, for reopening this from the v3 branch. I checked it against my five points on #139, and each one is in the code: an unmapped pin is skipped, every trigger is cleared at probe and masked bits aren't dispatched; a masked level line is acknowledged and re-checked at unmask; wake is forwarded to the chip's line; the comments describe the other sources as on stock; MAINTAINERS is folded into the driver commit. The registers and fields match Google's max77779_v20240115_regs.h, and probe's mask-all-then-clear matches max77779_pmic_irq.c. The checks pass on today's omamobile; the two checkpatch warnings are fine to leave.

Two things before it merges:

  1. The tested paragraph describes the earlier driver. USB-HOST-PLAN's H2b record says that boot ran "the kernel gpio: Add the Maxim MAX77779 PMIC's SGPIO block (Pixel 9a) #139 SGPIO driver (that PR's head)" on 10-30 at 07:50, which was 0f96204ff220, before the rework; your comment on gpio: Add the Maxim MAX77779 PMIC's SGPIO block (Pixel 9a) #139 that evening says the v3 module wasn't installed yet. v3 changes about 160 lines (handler, probe, wake). The same record says the PMIC's interrupt count stayed at 0 over 10 s and that the RT9470's watchdog was off, so "watchdog serviced from interrupt 90" is the boost driver naming its line at probe, not an interrupt that arrived. Could you reword the paragraph to say exactly that, and, as your description says, keep this as a draft until a boot with v3 where the line really fires (a count above zero on 24-0066 and on the SGPIO6 line, for example with the RT9470's watchdog on)? GitHub shows it as ready for review, so marking it a draft would match. A tools/phone-smoke report from that boot would complete it.

  2. What the interrupt cells mean. Here the block's interrupt cells number the eight SGPIOs, but the merged maxim,max77779-charger binding says the charger's interrupt comes "through the PMIC's interrupt controller". On stock, the gauge, charger, I2C master and VIMON use the PMIC's source interrupts (sources 1-4), and the SGPIOs are a separate controller on source 5. Once this binding is in a board, a charger node can't name its source without changing what the cells mean, so I'd like to settle the shape now: either the block as a parent with an interrupt controller for its sources and an SGPIO child (stock's layout, and mfd/maxim,max77759.yaml's), or one sentence in the binding and the message saying the block's controller is the SGPIOs only, with the charger binding's description corrected. The first is what I'd expect upstream, but either is fine if it's stated.

Smaller things: a readable/writeable regmap table (the writes are INTSRC_STS, INTB_MASK and 0xe8-0xf4); set_config could clear the opposite pull before setting the new one; and a rate-limited error on the dropped regmap_write results would help when the bus misbehaves. The masked-level handling and the wake forwarding are carefully done. Thank you for that.

The MAX77779 (Google Pixel 9a) is a set of I2C blocks on one chip. The
PMIC block at 0x66 owns the chip's interrupt line (INTB) and eight SGPIO
pins; on the 9a they carry the RT9470 OTG boost's interrupt (SGPIO6) and
chip enable (SGPIO7) and the wireless charger's lines. Without them the
boost can't keep its 40 s I2C watchdog, which Google's driver services
from that interrupt.

Add a driver for the block: a GPIO chip for the eight pins (direction,
level, pull-up and pull-down through set_config) with an interrupt
chip. Each pin's edge trigger is programmed in its CNFG register; a
level request takes the edge into the level and the handler re-checks
the pin, leaving the interrupt uncleared while the level holds, as
Google's driver does. Probe clears every pin's trigger before the
source is unmasked, so a trigger left by OTP or the bootloader can't
latch a bit on a pin nobody requested, and the handler dispatches only
pins with a mapping and not masked; a masked pin's bit is acknowledged
and, for a level line, the pin is checked again at unmask by running
the handler once more. irq_set_wake is forwarded to the chip's line
while any pin asks for it, so the boost's watchdog interrupt can wake
the SoC from s2idle.

The handler reads INTSRC_STS, dispatches the SGPIO source and
acknowledges the rest. On stock the gauge, the charger, the I2C master
and VIMON interrupt through this block as well and only the Type-C port
controller has its own line to the SoC; on this tree their nodes have
no interrupts, so those sources stay masked. The register map is
Google's max77779_regs.h (google-modules/bms): ID 0x00, INTSRC_STS
0x22, INTB_MASK 0x24, SGPIO_INT 0xe8, PU 0xe9, PD 0xea, CNFG0-7
0xed-0xf4.

Tested on the Pixel 9a against the running kernel. Without an interrupt
line the block answers with ID 0x79, revision 0x02, OTP 0x21, the chip
registers eight lines and the readout matches the OTP defaults (SGPIO6
an input, pull-down set; SGPIO7 off). With the board's node (the chip's
line on gpa8-0, the boost's interrupt on SGPIO6), an earlier version of
this driver probed with its interrupt on 2026-10-30 and caused no
interrupt storm; the PMIC's interrupt count stayed at 0 over 10 s with
the RT9470's watchdog off, so no interrupt has come through this block
yet. This version has not been booted with the board's node.

Link: https://android.googlesource.com/kernel/google-modules/bms/+/183509aff980610401869deca9f6ce8836980fe7/max77779_pmic_sgpio.c
Link: https://android.googlesource.com/kernel/devices/google/zuma/+/42395e8adcb880aa336f0da6bb2a19ed53929c40/dts/zuma-max777xx.dtsi
Signed-off-by: W4HO <87742609+W4HO-ham@users.noreply.github.com>
@W4HO-ham
W4HO-ham force-pushed the tegu-max77779-pmic-v3 branch from 18653d0 to 3283751 Compare November 1, 2026 09:32
@W4HO-ham
W4HO-ham marked this pull request as draft November 1, 2026 09:32
@W4HO-ham

W4HO-ham commented Nov 1, 2026

Copy link
Copy Markdown
Contributor Author

You're right on point 1, thanks for catching it. The driver commit's tested paragraph now says exactly what happened: an earlier version probed with its interrupt on 10-30 with no storm, the PMIC's count stayed at 0 over 10 s with the RT9470's watchdog off, and this version hasn't booted with the board's node. I've marked the PR as a draft until a v3 boot where the line really fires (a count above zero on 24-0066 and on SGPIO6, with the boost's watchdog on). The smoke report will come from that boot.

On the interrupt cells, I'll take the first shape: the block as a parent with an interrupt controller for its sources and an SGPIO child, as mfd/maxim,max77759.yaml does. That way the charger can name its source later. I'll fold in the regmap tables, the pull clearing in set_config, and the rate-limited write errors with that rework.

@derekross

Copy link
Copy Markdown
Owner

Thank you, @W4HO-ham. The new tested paragraph is accurate: it says what the 10-30 boot ran, that no interrupt has come through the block yet, and that this version hasn't booted with the board's node. Draft is the right state for it. I checked that this push changed only the message (the tree is identical to the previous head), and the checks pass on today's omamobile.

The parent-and-child shape is a good choice: the block as the interrupt controller for its sources, with the SGPIOs as a child, as mfd/maxim,max77759.yaml does. Two things to keep in mind for that rework:

  • When the block's cells name sources rather than pins, please fix the maxim,max77779-charger binding's description in the same series, so the two bindings agree on what "through the PMIC's interrupt controller" means.
  • The regmap tables: reads of what probe and the handler read, writes only to INTSRC_STS, INTB_MASK and 0xe8-0xf4, as before.

Nothing else needed from me until the rework and the boot where the line really fires. Take your time.

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