Skip to content

regulator: s2mps11: Let the S2MPG14 touch supplies set their voltage - #240

Closed
aninmucek wants to merge 1 commit into
derekross:omamobilefrom
aninmucek:omamobile-s2mpg14-ldo-voltage
Closed

aninmucek wants to merge 1 commit into
derekross:omamobilefrom
aninmucek:omamobile-s2mpg14-ldo-voltage

Conversation

@aninmucek

Copy link
Copy Markdown
Contributor

The voltage setter for the S2MPG14 touch supplies, as you asked on #238. It's its own PR, with one commit on today's omamobile (fc7086a68). It only covers LDO4M and LDO25M: every other S2MPG14 output keeps its firmware-owned selector, as 5e4cda3a7 left it. Nothing in this PR powers anything. akita's supplies and touch node follow in a later PR, from a later boot.

1. The selector table, from Google's source and proven on an 8a.

  • Google's s2mpg14-regulator.c (the commit 5e4cda3a7 links) puts LDO4M in voltage group 5 and LDO25M in group 4.

  • Its s2mpg14-register.h gives:

    • group 5: S2MPG14_REG_MIN5 1800000, S2MPG14_REG_STEP5 25000;
    • group 4: MIN4 700000, STEP4 25000;
    • N_VOLTAGES_64, with vsel_mask = n - 1;
    • S2MPG14_PM_L4M_CTRL = 0x2E and S2MPG14_PM_L25M_CTRL = 0x43.

    That's exactly what our descriptors already have (min_uV, uV_step, n_voltages, vsel_mask = GENMASK(5, 0), vsel_reg). Google's s2m_set_voltage_sel writes the selector under that mask, as regulator_set_voltage_sel_regmap does here.

  • One boot on a Pixel 8a with this commit, the board file fixing LDO4M at 3.0 V and LDO25M at 1.8 V, no consumer, and no regulator_ignore_unused:

    • the core logs touch-avdd: Bringing 3300000uV into 3000000-3000000uV;
    • /sys/class/regulator then reads touch-avdd: 3000000 uV, disabled, 0 users and touch-vdd: 1800000 uV, disabled, 0 users;
    • both read the same 41 s into boot, after the unused-regulator cleanup.
    • These are hardware reads: s2mpg14_regmap_config_pmic has no cache, so get_voltage_sel reads the register through ACPM.
    • A boot before this, without the setter and with the driver's whole range, read ABL's selector as 3.3 V on LDO4M and 1.8 V on LDO25M, both off.

2. The other two boards are unchanged. From the DTBs this tree builds:

  • zumapro-tegu: ldo4m and ldo25m have no regulator-min/max-microvolt, so apply_uV stays false and machine_constraints_voltage never calls _regulator_do_set_voltage.
  • zuma-husky: both are fixed (0x325aa0 = 3.3 V, 0x1b7740 = 1.8 V). With apply_uV, the core calls the setter only when the current voltage is outside the constraint (target_min != current_uV || target_max != current_uV, drivers/regulator/core.c). Without a setter today, any mismatch fails the probe with -EINVAL, as it did on the 8a. So husky's touch working on today's omamobile means its ABL leaves exactly 3.3 V and 1.8 V, and the setter won't be called there. That's from the code path, not a read on an 8 Pro, so an 8 Pro owner's boot log would settle it: there should be no "Bringing" line.
The two rails in the three zuma-family DTBs
== zumapro-tegu.dtb: s2mpg14 ldo4m/ldo25m
					touch_avdd: ldo4m {
						regulator-name = "touch-avdd";
						phandle = <0x3a>;
					};
					touch_vdd: ldo25m {
						regulator-name = "touch-vdd";
						phandle = <0x39>;
					};
== zuma-husky.dtb: s2mpg14 ldo4m/ldo25m
					touch_avdd: ldo4m {
						regulator-name = "touch-avdd";
						regulator-min-microvolt = <0x325aa0>;
						regulator-max-microvolt = <0x325aa0>;
						phandle = <0x31>;
					};
					touch_vdd: ldo25m {
						regulator-name = "touch-vdd";
						regulator-min-microvolt = <0x1b7740>;
						regulator-max-microvolt = <0x1b7740>;
						phandle = <0x30>;
					};
== zuma-akita.dtb: s2mpg14 ldo4m/ldo25m
					touch_avdd: ldo4m {
						regulator-name = "touch-avdd";
						regulator-min-microvolt = <0x2dc6c0>;
						regulator-max-microvolt = <0x2dc6c0>;
						phandle = <0x3d>;
					};
					touch_vdd: ldo25m {
						regulator-name = "touch-vdd";
						regulator-min-microvolt = <0x1b7740>;
						regulator-max-microvolt = <0x1b7740>;
						phandle = <0x3e>;
					};

3. Touch comes in a later boot, one change per boot. The next akita boot adds the GT9895 node on top of this. The rails are read back at 3.0 V and 1.8 V before the driver enables them.

tools/kernel-pr-check --build OUT --merge origin/omamobile passes everything:

  • a clean merge onto fc7086a68;
  • the sign-off: 1 commit, signed off by its author, none by an AI;
  • checkpatch --strict with no errors and no warnings;
  • the policy checks;
  • drivers/regulator/s2mps11.c builds with W=1 (arm64, LLVM) and no warnings.

No device tree is touched.

🤖 Generated with Claude Code

ABL can leave LDO4M at another voltage than the touch controller needs:
on a Pixel 8a it leaves 3.3 V, read back through the driver's own
get_voltage_sel, while the stock phone runs the Goodix GT9895 there at
3.0 V (its live device tree). With voltage selectors firmware-owned, a
board that fixes 3.0 V fails to probe ("failed to apply
3000000-3000000uV constraint: -EINVAL"), and one without a constraint
would power the controller at ABL's 3.3 V.

Give LDO4M and LDO25M a set_voltage_sel through the regmap, which goes
to the PMIC through ACPM as enable does. The selector tables are
Google's: s2mpg14-regulator.c puts LDO4M in voltage group 5 (1.8 V
minimum) and LDO25M in group 4 (0.7 V), each with 64 steps of 25 mV
(s2mpg14-register.h), and writes the selector into the low six bits of
the control register (0x2e and 0x43), as the descriptors here already
read it. The other S2MPG14 outputs keep firmware-owned selectors.

The core calls the setter only to bring a voltage into the board's
constraints, so a board without voltage constraints (zumapro-tegu), or
whose constraint already matches what ABL left (zuma-husky's fixed
3.3 V, which probes today without a setter), sees no write.

Tested on a Pixel 8a from slot B (7.3.0-rc6), with LDO4M fixed at
3.0 V and LDO25M at 1.8 V in the board file and nothing consuming them:
the core logs "touch-avdd: Bringing 3300000uV into 3000000-3000000uV";
both rails then read back 3000000 and 1800000 uV (the PMIC regmap has
no cache, so that is the register through ACPM), disabled, with no
users, and stay so past the unused-regulator cleanup. Nothing enabled
them in that boot.

Link: https://android.googlesource.com/kernel/google-modules/soc/gs/+/204078758737776959ecc85c527a00fd2cabb62f/drivers/regulator/s2mpg14-regulator.c
Link: https://android.googlesource.com/kernel/google-modules/soc/gs/+/204078758737776959ecc85c527a00fd2cabb62f/include/linux/mfd/samsung/s2mpg14-register.h
Assisted-by: Claude Opus 5.5
Signed-off-by: DarekM <149845949+aninmucek@users.noreply.github.com>
@derekross

Copy link
Copy Markdown
Owner

Thank you, @aninmucek. This is exactly the shape I asked for on #238: its own PR, two outputs only, the selector tables cited from Google's files at a fixed commit, and a boot with no consumer that shows the core moving LDO4M from 3.3 V to 3.0 V before anything is powered.

What I checked:

  • The gate passes on today's omamobile (fc7086a68): a clean merge, your sign-off, checkpatch --strict with nothing to read, and the W=1 build. CI is green.
  • The table is only reached for samsung,s2mpg14-pmic, so the Pixel 7 Pro, 7, 7a, Fold and the Pixel 6 family (S2MPG10 to 13) don't see it, and no function changes, only a second ops table and two pointers.
  • On the 9a the two rails have no voltage constraint, so nothing can call the setter there.
  • On the 8 Pro your reasoning holds, and the phone agrees: husky's notes record that the firmware leaves LDO4M at 3.3 V and LDO25M at 1.8 V, both off, so the rails are already inside their constraint and nothing is written.
  • sec-acpm's write table already allows both control registers, and the selector mask leaves the enable bit alone.

Nothing to change. I'll land it together with #241, which carries this commit as its first.

@derekross

Copy link
Copy Markdown
Owner

Landed with #241, which carried this commit first. Thank you, @aninmucek.

@derekross derekross closed this Nov 12, 2026
@aninmucek
aninmucek deleted the omamobile-s2mpg14-ldo-voltage branch November 12, 2026 06:24
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