summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndré Draszik <andre.draszik@linaro.org>2026-01-22 15:43:45 +0000
committerMark Brown <broonie@kernel.org>2026-02-04 13:35:39 +0000
commit102dd11fc98261675a0664de1466616d7dad8d91 (patch)
tree4f35fa1c72314cb69b648b1858c92e2fa0dc8adf
parent8f23cfbe4463c3de2e552aed106e179c0c932b6e (diff)
regulator: s2mps11: refactor S2MPG10 regulator macros for S2MPG11 reuse
Rails in the S2MPG11 share a very similar set of properties with S2MPG10 with slight differences. Update the existing macros to allow reuse by the upcoming S2MPG11 driver. Signed-off-by: André Draszik <andre.draszik@linaro.org> Link: https://patch.msgid.link/20260122-s2mpg1x-regulators-v7-18-3b1f9831fffd@linaro.org Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--drivers/regulator/s2mps11.c69
1 files changed, 42 insertions, 27 deletions
diff --git a/drivers/regulator/s2mps11.c b/drivers/regulator/s2mps11.c
index 5e3584060547..c75ee0bd3437 100644
--- a/drivers/regulator/s2mps11.c
+++ b/drivers/regulator/s2mps11.c
@@ -655,31 +655,44 @@ static const struct regulator_ops s2mpg10_reg_buck_ops[] = {
* (12.5mV/μs) while our ::set_voltage_time() takes the value in ramp_reg
* into account.
*/
-#define regulator_desc_s2mpg10_buck(_num, _vrange, _r_reg) { \
- .name = "buck"#_num "m", \
- .supply_name = "vinb"#_num "m", \
- .of_match = of_match_ptr("buck"#_num "m"), \
+#define regulator_desc_s2mpg1x_buck_cmn(_name, _id, _supply, _ops, \
+ _vrange, _vsel_reg, _vsel_mask, _en_reg, _en_mask, \
+ _r_reg, _r_mask, _r_table, _r_table_sz, \
+ _en_time) { \
+ .name = "buck" _name, \
+ .supply_name = _supply, \
+ .of_match = of_match_ptr("buck" _name), \
.regulators_node = of_match_ptr("regulators"), \
.of_parse_cb = s2mpg10_of_parse_cb, \
- .id = S2MPG10_BUCK##_num, \
- .ops = &s2mpg10_reg_buck_ops[0], \
+ .id = _id, \
+ .ops = &(_ops)[0], \
.type = REGULATOR_VOLTAGE, \
.owner = THIS_MODULE, \
.linear_ranges = _vrange, \
.n_linear_ranges = ARRAY_SIZE(_vrange), \
.n_voltages = _vrange##_count, \
- .vsel_reg = S2MPG10_PMIC_B##_num##M_OUT1, \
- .vsel_mask = 0xff, \
- .enable_reg = S2MPG10_PMIC_B##_num##M_CTRL, \
- .enable_mask = GENMASK(7, 6), \
- .ramp_reg = S2MPG10_PMIC_##_r_reg, \
- .ramp_mask = s2mpg10_buck_to_ramp_mask(S2MPG10_BUCK##_num \
- - S2MPG10_BUCK1), \
- .ramp_delay_table = s2mpg10_buck_ramp_table, \
- .n_ramp_values = ARRAY_SIZE(s2mpg10_buck_ramp_table), \
- .enable_time = 30, /* + V/enable_ramp_rate */ \
+ .vsel_reg = _vsel_reg, \
+ .vsel_mask = _vsel_mask, \
+ .enable_reg = _en_reg, \
+ .enable_mask = _en_mask, \
+ .ramp_reg = _r_reg, \
+ .ramp_mask = _r_mask, \
+ .ramp_delay_table = _r_table, \
+ .n_ramp_values = _r_table_sz, \
+ .enable_time = _en_time, /* + V/enable_ramp_rate */ \
}
+#define regulator_desc_s2mpg10_buck(_num, _vrange, _r_reg) \
+ regulator_desc_s2mpg1x_buck_cmn(#_num "m", S2MPG10_BUCK##_num, \
+ "vinb"#_num "m", s2mpg10_reg_buck_ops, _vrange, \
+ S2MPG10_PMIC_B##_num##M_OUT1, GENMASK(7, 0), \
+ S2MPG10_PMIC_B##_num##M_CTRL, GENMASK(7, 6), \
+ S2MPG10_PMIC_##_r_reg, \
+ s2mpg10_buck_to_ramp_mask(S2MPG10_BUCK##_num \
+ - S2MPG10_BUCK1), \
+ s2mpg10_buck_ramp_table, \
+ ARRAY_SIZE(s2mpg10_buck_ramp_table), 30)
+
#define s2mpg10_regulator_desc_buck_cm(_num, _vrange, _r_reg) \
.desc = regulator_desc_s2mpg10_buck(_num, _vrange, _r_reg), \
.enable_ramp_rate = 12500
@@ -743,24 +756,24 @@ static const struct regulator_ops s2mpg10_reg_ldo_ramp_ops[] = {
}
};
-#define regulator_desc_s2mpg10_ldo_cmn(_num, _supply, _ops, _vrange, \
- _vsel_reg_sfx, _vsel_mask, _en_reg, _en_mask, \
+#define regulator_desc_s2mpg1x_ldo_cmn(_name, _id, _supply, _ops, \
+ _vrange, _vsel_reg, _vsel_mask, _en_reg, _en_mask, \
_ramp_delay, _r_reg, _r_mask, _r_table, _r_table_sz) { \
- .name = "ldo"#_num "m", \
+ .name = "ldo" _name, \
.supply_name = _supply, \
- .of_match = of_match_ptr("ldo"#_num "m"), \
+ .of_match = of_match_ptr("ldo" _name), \
.regulators_node = of_match_ptr("regulators"), \
.of_parse_cb = s2mpg10_of_parse_cb, \
- .id = S2MPG10_LDO##_num, \
+ .id = _id, \
.ops = &(_ops)[0], \
.type = REGULATOR_VOLTAGE, \
.owner = THIS_MODULE, \
.linear_ranges = _vrange, \
.n_linear_ranges = ARRAY_SIZE(_vrange), \
.n_voltages = _vrange##_count, \
- .vsel_reg = S2MPG10_PMIC_L##_num##M_##_vsel_reg_sfx, \
+ .vsel_reg = _vsel_reg, \
.vsel_mask = _vsel_mask, \
- .enable_reg = S2MPG10_PMIC_##_en_reg, \
+ .enable_reg = _en_reg, \
.enable_mask = _en_mask, \
.ramp_delay = _ramp_delay, \
.ramp_reg = _r_reg, \
@@ -775,10 +788,12 @@ static const struct regulator_ops s2mpg10_reg_ldo_ramp_ops[] = {
_ramp_delay, _r_reg, _r_mask, _r_table, _r_table_sz, \
_pc_reg, _pc_mask) \
[S2MPG10_LDO##_num] = { \
- .desc = regulator_desc_s2mpg10_ldo_cmn(_num, _supply, \
- _ops, \
- _vrange, _vsel_reg_sfx, _vsel_mask, \
- _en_reg, _en_mask, \
+ .desc = regulator_desc_s2mpg1x_ldo_cmn(#_num "m", \
+ S2MPG10_LDO##_num, _supply, _ops, \
+ _vrange, \
+ S2MPG10_PMIC_L##_num##M_##_vsel_reg_sfx, \
+ _vsel_mask, \
+ S2MPG10_PMIC_##_en_reg, _en_mask, \
_ramp_delay, _r_reg, _r_mask, _r_table, \
_r_table_sz), \
.pctrlsel_reg = _pc_reg, \