Repository navigation
Pixel 8 Pro battery: CMU_PERIC1, USI11 and the MAX77759 bus - #163
Conversation
|
Thanks Lef, this is careful work. I checked every offset, field width and parent in the clock driver against Google's zuma CMUCAL tables, and the DT against stock (USI11's sysreg offset, SPI 659, the interrupt pins, the 5 mΩ shunt, and your fix for stock's gpp22-1 typo), and it all matches. The husky DTB validates with nothing new. A few things before I merge:
Smaller things: stock's final hsi2c11 pins are pull-up ( |
The Pixel 8 Pro's USI11 bus (hsi2c_11, at 0x10cb0000, as in Google's devicetree) is the same Samsung HSI2C controller as the other Google SoCs in this list. Add the zuma compatible, which the zuma devicetree uses for it. Signed-off-by: Lef <me@lefteros.com> Assisted-by: LLM
USI11 is at 0x10cb00c0 and its SW_CONF is at offset 0xc of the PERIC1 sysreg (0x10c21000), as in Google's devicetree. Add the zuma compatible to the list of sysregs and to the condition that groups the PERIC sysregs of the other Google SoCs. Signed-off-by: Lef <me@lefteros.com> Assisted-by: LLM
CMU_PERIC1 supplies USI11, the I2C bus of the Pixel 8 Pro's MAX77759 fuel gauge, charger, Type-C controller and PMIC. Its NoC and USI input clocks come from CMU_TOP. Register layout and parents are from Google's GPL cal-if/zuma tables (android-gs-shusky-6.1-android16). Signed-off-by: Lef <me@lefteros.com> Assisted-by: LLM
Add the CMU_TOP PERIC1 NoC and IP clocks (firmware-owned, read-only) and CMU_PERIC1 with USI11's user mux, divider and gates, for the I2C bus of the battery, charger and Type-C chips. The layout follows the Pixel 9a's PERIC1 code, which comes from the same cal-if/zuma tables; USI11 is the next slot after USI10 there (mux 0x640, divider 0x1810, gates 0x2048/0x204c/0x2094). The USI11 gates keep the mode firmware set. Signed-off-by: Lef <me@lefteros.com> Assisted-by: LLM
All disabled. USI11 is at 0x10cb00c0 with its SW_CONF at offset 0xc of the PERIC1 sysreg, and the bus is hsi2c_11 at 0x10cb0000 on GIC SPI 659, as in Google's device tree. Add its pins (gpp21-0/1, the board's pair) and the MAX77759 interrupt pins on the ALIVE banks gpa7 and gpa8. The bus pins get a pull-up. Stock's board file sets no pull (pud 0) on hsi2c11_bus, but its Type-C file, applied after it, sets pud 3, which is the final value. Signed-off-by: Lef <me@lefteros.com> Assisted-by: LLM
…c_11 Add the battery, and the fuel gauge (0x36), PMIC (0x66) and Type-C controller (0x25) on hsi2c_11, as on the Pixel 7 Pro. The bus stays disabled here and bring-up overlays enable it. No gauge model yet: the pack is not known and a wrong model would be written on power-on reset. The Type-C controller stays disabled. The charge limits are conservative (4.2 V, 0.3 C) until stock's step charging is described. The MFD driver binds only if PMIC_ID reads 59 (0x3b), and it does on the Pixel 8 Pro: PMIC_ID 0x3b, PMIC_REVISION 0x02, OTP_REVISION 0x31 (i2cget on 0x66). So the chip at 0x66 is a MAX77759, and not the MAX77729 that Google's devicetree names on the same interrupt. Binding the PMIC creates its charger cell, which programs charge limits from the battery node, so in the boots for this series a modprobe.d file on the phone kept max77759_charger, gpio_max77759, nvmem_max77759 and tcpci_maxim from loading, and lsmod shows the charger was not loaded. Signed-off-by: Lef <me@lefteros.com> Assisted-by: LLM
de37101 to
7b80e83
Compare
|
Thanks Derek, that was a careful review and every point was fair. I pushed all of it (the branch now has 6 commits, new tip 7b80e83). Going through them in your order, including what I did not test.
The pins. You're right, I had missed that zuma-typec.dtsi is applied after the battery file. Stock's board file sets hsi2c11_bus to no pull (pud 0), its Type-C file sets pud 3 later, so the pins end up with the pull-up. I matched that (GS101_PIN_PULL_UP) and put the two stock entries in the comment and the commit message. The tree I booted all day still had the old no-pull, so I booted the pull-up separately with a one-line overlay (samsung,pin-pud = <3> on hsi2c11-bus-pins): the running device tree shows pin-pud 3 on gpp21-0/1, the gauge (max17042), the PMIC (max77759) and the dummy client at 0x69 all bind, the Type-C chip answers on the bus (its USB switch register reads 0x09), dmesg has no i2c errors and the battery reads normally. I did not test the pull-up under any other conditions than that boot. PMIC_ID. Your catch about Google's comment naming a MAX77729 on that interrupt was right to question, so I checked: the MFD driver only binds if PMIC_ID reads 59 (0x3b) and it does, and reading it back on the phone gives PMIC_ID 0x3b, PMIC_REVISION 0x02, OTP_REVISION 0x31. So the chip at 0x66 is a MAX77759. That is in the husky commit message now (the driver prints nothing on success, so there is no probe line to quote, the check is in the code and the read is from i2cget). On the CMU_TOP numbering with Brett's #157: understood, merge this one first and I'll renumber if it comes to that, tell me. Checks on the new branch: kernel-pr-check --build --merge is clean in the container (clean merge onto b0d62d9, sign-offs, subject prefixes, checkpatch --strict, W=1 build of the touched C file, 8 device trees W=1), dt-doc-validate is clean on the three bindings, dt_binding_check is clean for them, and dtbs_check on zuma-husky.dtb only shows the same two eusb2-phy supply warnings as before, nothing about hsi2c, peric1, sysreg, max77759 or the pinctrl. The commits also carry the trailer the kernel process doc asks for, so the commit hashes changed once more after those runs; the tree did not. Since a force push needs your approval for CI again, could you approve the run? What this PR does not claim: nothing about the charger, the Type-C chip or charging, those need their own steps. For anyone who wants the whole story of what I ran on top of it (the gauge model, three guarded charger runs, the USB replug problem, the numbers): derekross/omarchy-mobile#249 has device/husky/BATTERY-NOTES.md, and the overview is in issue #1: derekross/omarchy-mobile#1 (comment). tools/phone-smoke from the booted kernelphone-smoke: huskyKernel
Packages: hyprland 0.56.2-5.1, libcamera 0.7.2-4.22, mesa 1:26.2.4-1.4, omacam 0.3.3-1, omamobile-apps 0.2.0-1, omamobile-device-husky 0.1.1-1, omamobile-firstboot 0.1.2-1, omamobile-keyring 20261026-1, omamobile-mirror 0.1.1-1, omamobile-omarchy 0.1.20-1, omamobile-owl-widgets 0.1.1-1, omamobile-shell 0.2.45-1, omarchy 4.0.6-1, quickshell 0.3.2.r7.g2b4501a-1 |
|
Thanks Lef, that's a thorough answer, and every point is in. What I checked:
The pins: you're right. In Google's On my side: One small thing, which doesn't need another push here: the CMU_PERIC1 comment in |
|
Thanks Derek. Fixed the MAX77729 name in the CMU_PERIC1 comment, it says MAX77759 now. It's in the USI9 clock commit of #175 (force-pushed, the rest of the tree is the same). |
…si2c_9 The Pixel 8 Pro's battery pack has an EEPROM on USI9 / hsi2c_9: stock has it as "at,24c08" at 0x50 on a 400 kHz bus. Its byte 0x17 is the battery ID that Google's driver matches against the fuel gauge models (0 the default model, 1 ATL, 2 COS, 3 LSN, 170 Google's dummy), and which pack the phone has is what decides the right model. The rest of the EEPROM holds the pack's part number, dates and history, so the node is read-only. Mainline's at24 driver wants "atmel,24c08", not stock's alias. The bus and USI9 stay disabled in the board file, like hsi2c_11; a bring-up overlay enables them. Nothing feeds the ID to the gauge yet. Tested on a Pixel 8 Pro (slot B, release 7.3.0-rc6-omamobile-push1- g7975b84a8017: Brett's c6 tree with derekross#163 and the four commits of this series, as the branch husky-pack-eeprom-booted). A bring-up overlay enabled cmu_peric1, the sysreg, USI9 and hsi2c_9. The log shows at24 0-0050: 1024 byte 24c08 EEPROM, read-only and a one-byte read of offset 0x17 returned 1, the ATL pack. Signed-off-by: Lef <me@lefteros.com> Assisted-by: LLM
…si2c_9 The Pixel 8 Pro's battery pack has an EEPROM on USI9 / hsi2c_9: stock has it as "at,24c08" at 0x50 on a 400 kHz bus. Its byte 0x17 is the battery ID that Google's driver matches against the fuel gauge models (0 the default model, 1 ATL, 2 COS, 3 LSN, 170 Google's dummy), and which pack the phone has is what decides the right model. The rest of the EEPROM holds the pack's part number, dates and history, so the node is read-only. Mainline's at24 driver wants "atmel,24c08", not stock's alias. The bus and USI9 stay disabled in the board file, like hsi2c_11; a bring-up overlay enables them. Nothing feeds the ID to the gauge yet. Tested on a Pixel 8 Pro (slot B, release 7.3.0-rc6-omamobile-push1- g7975b84a8017: Brett's c6 tree with derekross#163 and the four commits of this series, as the branch husky-pack-eeprom-booted). A bring-up overlay enabled cmu_peric1, the sysreg, USI9 and hsi2c_9. The log shows at24 0-0050: 1024 byte 24c08 EEPROM, read-only and a one-byte read of offset 0x17 returned 1, the ATL pack. Signed-off-by: Lef <me@lefteros.com> Assisted-by: LLM
…si2c_9 The Pixel 8 Pro's battery pack has an EEPROM on USI9 / hsi2c_9: stock has it as "at,24c08" at 0x50 on a 400 kHz bus. Its byte 0x17 is the battery ID that Google's driver matches against the fuel gauge models (0 the default model, 1 ATL, 2 COS, 3 LSN, 170 Google's dummy), and which pack the phone has is what decides the right model. The rest of the EEPROM holds the pack's part number, dates and history, so the node is read-only. Mainline's at24 driver wants "atmel,24c08", not stock's alias. The bus and USI9 stay disabled in the board file, like hsi2c_11; a bring-up overlay enables them. Nothing feeds the ID to the gauge yet. Tested on a Pixel 8 Pro (slot B, release 7.3.0-rc6-omamobile-push1- g7975b84a8017: Brett's c6 tree with #163 and the four commits of this series, as the branch husky-pack-eeprom-booted). A bring-up overlay enabled cmu_peric1, the sysreg, USI9 and hsi2c_9. The log shows at24 0-0050: 1024 byte 24c08 EEPROM, read-only and a one-byte read of offset 0x17 returned 1, the ATL pack. Signed-off-by: Lef <me@lefteros.com> Assisted-by: LLM
First step of the battery work on the 8 Pro, the one Brett and I agreed on in omarchy-mobile#1. This gets the I2C bus the MAX77759 chips sit on, nothing more.
Four commits: the CMU_PERIC1 bindings, the clk-zuma path to USI11 (the gates and layout follow the 9a's PERIC1 code and Google's cal-if/zuma tables), the zuma.dtsi nodes for cmu_peric1, usi11 and hsi2c_11, and the husky side with the battery and the gauge, PMIC and Type-C nodes. Everything new is disabled in the board DTS, so the default DTB behaves like before.
I tested it on my Kioxia husky with a device tree overlay that enables the nodes (the overlay is not in this PR). CMU_PERIC1 probes, the clocks show up in clk_summary with sane rates, and the bus registers with clients at 0x36 and 0x66. Loading max17042_battery gives a battery that reads about 86% at 4.2 V, 32 C, discharging. Loading the max77759 MFD binds, its PMIC_ID check passes, the interrupt lines stay quiet and there are no I2C errors. I did not load the charger or the Type-C driver, and I did not test charging at all.
Checks: kernel-pr-check --build --merge is clean (in the build container), dt-doc-validate passes on the three bindings, and dtbs_check on zuma-husky only shows the two eusb2-phy supply warnings that are already there.
Things I would like a second pair of eyes on:
It is on top of the current omamobile. Brett's husky-test-20261031-c6 tag has the same four commits on an older base, and the only conflict was a duplicated comment in zuma.dtsi.
Update after Derek's review: the branch has 6 commits now (the bindings are split into three, one per file), the comment above &hsi2c_11 is corrected, hsi2c11's pins use the pull-up that stock ends up with, and the PMIC_ID is in the husky commit message. The tree I booted is Brett's c6 plus the first version of these commits applied before the build (hence the -dirty release), and those commits as booted are on https://github.com/Somnius/linux-omarchy-mobile/tree/husky-battery-i2c-booted. Details and the smoke report are in the comment below.