Skip to content

soc: samsung: gs201: battery current limiter for the Pixel 7 - #274

Open
angelrenefm wants to merge 3 commits into
derekross:omamobilefrom
angelrenefm:pr/gs201-bcl
Open

angelrenefm wants to merge 3 commits into
derekross:omamobilefrom
angelrenefm:pr/gs201-bcl

Conversation

@angelrenefm

Copy link
Copy Markdown
Contributor

Stock Android lets the Pixel 7 run its big cluster at 2850 MHz and the GPU at 848 MHz. It can do that because the battery current limiter (BCL) pulls the clocks back when the battery droops. Without a BCL, omamobile stops at 2252 MHz and 572 MHz, the levels stock falls back to during a droop. This series adds the listener half of that limiter, so those caps can be lifted later.

What it does:

  • It listens on the three droop lines Google's gs201-cloudripper-bcl.dtsi uses: vdroop1 and vdroop2 from the MAX77759 on gpa5-5/6, and SMPL_WARN from the S2MPG12 on gpa5-0.
  • While a line is asserted, it caps the CPU clusters through cpufreq QoS and the GPU through devfreq QoS. The values are stock's freq_qos table.
  • It writes nothing to either PMIC, so the MAX77759 can stay on the blocklist. It doesn't program the clusters' hardware clock dividers, so it covers droops that last milliseconds, not microsecond transients.
  • debugfs shows each line's state and count, and can force a line asserted to test the caps.

Tested on a Pixel 7 (panther):

  • As a module on the running kernel. The driver is this branch's file plus a platform-data hook for a test-only shim that hands it the GPIOs without the DT node. The shim is not part of this PR.
  • The three lines bind as edge interrupts on gpa5 and stay idle at rest.
  • Forcing each line from debugfs applies its caps to the three policies and the GPU, and two lines at once take the stricter row. On release everything goes back.
  • A real load test at 20 % battery with no charger, the driver armed, the GPU forced to 848 MHz and the CPU with boost on: glmark2, 8 CPU spinners and full brightness for 5 minutes. The minimum battery voltage was 3534 mV at about 1.9 A. The phone didn't shut down. I ran it twice. The second run started at 21 % with the battery logged at 32-34 °C: minimum 3547 mV, peak 3.05 A, and the GPU stayed at 848 MHz the whole time. No droop line asserted in either run, so this shows 848 MHz holds at 20 %, but not the limiter braking on a real droop.
  • tools/kernel-pr-check --build passes on omamobile: sign-offs, checkpatch --strict, the W=1 build, dtbs_check and dt_binding_check.

Not in this PR:

  • CONFIG_GS201_BCL=m in omarchy-mobile's omamobile.config.
  • Lifting gs201_gpu_max_khz=572000 and dropping turbo-mode from the OPPs for panther. Those are your call once this is in, and I'd send them separately.

Not tested:

  • A cold battery (below about 15 °C), which gives less voltage under the same load.
  • The Pixel 7 Pro (cheetah). The DT node is only added to panther.
  • Hours of use with the limiter armed.

I used AI help (Claude) to work on this.

On Google Tensor G2 phones the MAX77759 raises vdroop1 (SYS_UVLO1) and
vdroop2 (SYS_UVLO2 or BAT_OILO) on two GPIOs, and the S2MPG12 lowers
SMPL_WARN on a third, when the battery voltage droops or its current goes
over the limit. Describe the three lines and the GPU whose frequency is
capped with the CPUs' while one is asserted.

The pins are those of Google's gs201-cloudripper-bcl.dtsi.

Assisted-by: LLM
Signed-off-by: Ángel René <17342133+angelrenefm@users.noreply.github.com>
Stock Android on the Pixel 7 and 7 Pro runs the CPU clusters up to
1803/2348/2850 MHz and the GPU up to 848 MHz because its battery current
limiter pulls them back when the battery can't keep up. Without one, the
mid and big clusters stop at 1999/2252 MHz and the GPU at 572 MHz, the
levels stock falls back to on a droop.

Take the three lines (vdroop1, vdroop2, SMPL_WARN) and, while one is
asserted, cap the clusters through cpufreq QoS and the GPU through devfreq
QoS at stock's values (freq_qos in gs201-cloudripper-bcl.dtsi). vdroop2
shares its pin with BAT_OILO and can't be told apart without the
MAX77759's interrupt register, so it takes the stricter of the two rows.
Each line is taken on its asserting edge, read again every 5 ms, and
released once it has been clear for 20 ms. debugfs shows each line's
state and counts, and can force a line asserted to test the caps.

It writes nothing to either PMIC, and it doesn't program the clusters'
hardware clock dividers, so it covers droops that last milliseconds, not
microsecond transients.

Tested on a Pixel 7 as a module, with a test-only shim for the GPIOs: the
three lines bind as edge interrupts on gpa5, idle; forcing each line
applies its caps to the three policies and the GPU's devfreq and lifts them
on release, and two lines at once take the stricter caps.

Assisted-by: LLM
Signed-off-by: Ángel René <17342133+angelrenefm@users.noreply.github.com>
…miter

The MAX77759's vdroop1 and vdroop2 on gpa5-5/6 and the S2MPG12's SMPL_WARN
on gpa5-0, as Google's gs201-cloudripper-bcl.dtsi, with the GPU to cap.

Assisted-by: LLM
Signed-off-by: Ángel René <17342133+angelrenefm@users.noreply.github.com>
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