power: regulator: s2mps11: declaratively define LDOs and BUCKs
authorKaustabh Chakraborty <kauschluss@disroot.org>
Fri, 17 Oct 2025 15:28:18 +0000 (20:58 +0530)
committerPeng Fan <peng.fan@nxp.com>
Thu, 30 Oct 2025 02:11:18 +0000 (10:11 +0800)
commit2d49a7e75ce176b07288397742fb9a72d6caf134
treeb20bdfb1bf5dc774a011fa44b1b9088ff377f9ce
parent73a85502bd2a4373d82f638b1b4c3e1f79e394e3
power: regulator: s2mps11: declaratively define LDOs and BUCKs

In the Linux kernel driver, all information related to LDO and BUCK
regulators are stored in descriptive arrays. This also allows multiple
variants to be supported by the same driver.

Define a struct sec_regulator_desc which holds all values required by a
regulator. Create an array of said struct containing all regulators. The
descriptors are designed to follow a style similar to what's seen in the
Linux driver, so comparing one with the other is simple.

In functions such as s2mps11_{buck,ldo}_{val,mode} these values are to
be used, make necessary modifications to pull them from the descriptors.
Since multiple variants have varying descriptors, select them from
within a switch-case block.

Functions s2mps11_{buck,ldo}_{volt2hex,hex2volt} and arrays
s2mps11_buck_{ctrl,out} are phased out as the calculations are now
hardcoded in descriptors, thusly, it reduces clutter and enhances
readability.

Two macros in s2mps11.h, S2MPS11_LDO_NUM and S2MPS11_BUCK_NUM are
removed as they are no longer being used.

Signed-off-by: Kaustabh Chakraborty <kauschluss@disroot.org>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
drivers/power/regulator/s2mps11_regulator.c
include/power/s2mps11.h