Skip to content

regulator: mt6363: Fix the regmap value width and the VSRAM LDO registers

GIBEOM LEE (이기범) linux-arm-kernel linux-mediatek lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 5 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2regulator: mt6363: Use 8-bit regmap valuesdrivers/regulator/mt6363-regulator.c+1 -11 reply
2/2regulator: mt6363: Fix the registers of the VSRAM CPU and APU LDOsdrivers/regulator/mt6363-regulator.c+14 -111 reply

Reviews trailers per patch

None of the 2 patches has a Reviewed-by or Acked-by.

PatchAlexandre Mergnat
1/2
2/2T-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH 0/2] regulator: mt6363: Fix the regmap value width and the VSRAM LDO registers

These patches fix two problems in the MT6363 regulator driver that can be seen from the code. They are on top of regulator for-next, where the driver is the same as in master and v7.2.12.

Patch 1: the registers have 8 bits but the regmap has 16-bit values, so every write also writes the next register. For example, disabling one of VS2 and VBUCK1-7 also disables VS1, VS3 and VSRAM_{DIGRF,MDFE,MODEM}. The MT6373 driver on the list has 16-bit values too, so its next version will want the same change.

Patch 2: VSRAM_{CPUB,CPUM,CPUL,APU} use the enable and low power registers of the BUCK1 group instead of their own, so disabling one of them disables VS1.

Testing: none of this has run on hardware, because the bootloader of my board (Lenovo TB375FC, MT6897) is still locked. Each patch builds with W=1. The driver file also ran unchanged in user space, against a model of the registers made from MediaTek's header and driver, before and after the patches:

- 16 of the 33 checks of the model fail before and pass after. The 9 that still fail are about the VEMC voltage callbacks and the overcurrent handling, for which I have fixes that I would like to test first.
- ASan reports a stack buffer overflow in the BUCK_TOP key write before patch 1, and nothing after it.
- The resolved table of the 35 rails differs from MediaTek's driver in 8 entries before patch 2, and in none after it.

The model comes from MediaTek's sources, so it does not show how the chip really behaves. A Tested-by from anyone with an MT8196 or MT6991 board would be very welcome.

How this was made: Claude (claude-opus-5-5, an AI coding assistant) found both problems while comparing the driver with MediaTek's driver in the OnePlus MT6897 kernel, during a longer session of porting mainline Linux to this tablet. It wrote the patches, their changelogs and this letter, and it ran the checks above. I reviewed the result before signing off.

GIBEOM LEE (이기범) (2):
regulator: mt6363: Use 8-bit regmap values
regulator: mt6363: Fix the registers of the VSRAM CPU and APU LDOs

 drivers/regulator/mt6363-regulator.c | 27 +++++++++++++++------------
 1 file changed, 15 insertions(+), 12 deletions(-)