[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250604-s2mpg1x-regulators-v1-15-6038740f49ae@linaro.org>
Date: Wed, 04 Jun 2025 16:25:54 +0100
From: André Draszik <andre.draszik@...aro.org>
To: Tudor Ambarus <tudor.ambarus@...aro.org>, Rob Herring <robh@...nel.org>,
Conor Dooley <conor+dt@...nel.org>, Krzysztof Kozlowski <krzk@...nel.org>,
Liam Girdwood <lgirdwood@...il.com>, Mark Brown <broonie@...nel.org>,
Lee Jones <lee@...nel.org>, Linus Walleij <linus.walleij@...aro.org>,
Bartosz Golaszewski <brgl@...ev.pl>
Cc: Peter Griffin <peter.griffin@...aro.org>,
Will McVicker <willmcvicker@...gle.com>, kernel-team@...roid.com,
linux-kernel@...r.kernel.org, linux-samsung-soc@...r.kernel.org,
devicetree@...r.kernel.org, linux-gpio@...r.kernel.org,
André Draszik <andre.draszik@...aro.org>
Subject: [PATCH 15/17] regulator: s2mps11: refactor S2MPG10 regulator
macros for S2MPG11 reuse
Rails in the S2MPG11 share a very similar set of properties with
S2MP10 with slight differences. Update the existing macros to allow
reuse by the upcoming S2MPG11 driver.
Signed-off-by: André Draszik <andre.draszik@...aro.org>
---
Note: checkpatch complains about unused macro arguments _r_mask,
_r_table, and _r_table_sz, but these are false-positives due to patch
context.
---
drivers/regulator/s2mps11.c | 70 ++++++++++++++++++++++++++++-----------------
1 file changed, 43 insertions(+), 27 deletions(-)
diff --git a/drivers/regulator/s2mps11.c b/drivers/regulator/s2mps11.c
index f427895637a32f26e2960ce7c7879632f0bc2dcb..74f09b949ca7d6f1d61decd086480996fd444dbd 100644
--- a/drivers/regulator/s2mps11.c
+++ b/drivers/regulator/s2mps11.c
@@ -638,24 +638,24 @@ static const struct regulator_ops s2mpg10_reg_buck_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, \
@@ -670,10 +670,12 @@ static const struct regulator_ops s2mpg10_reg_buck_ops[] = {
_ramp_delay, _r_reg, _r_mask, _r_table, _r_table_sz, \
_pc_reg, _pc_mask) \
{ \
- .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, \
@@ -728,31 +730,45 @@ 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), \
.of_parse_cb = s2mpg10_of_parse_cb, \
.regulators_node = of_match_ptr("regulators"), \
- .id = S2MPG10_BUCK##_num, \
- .ops = &s2mpg10_reg_buck_ops[0], \
+ .of_parse_cb = s2mpg10_of_parse_cb, \
+ .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
--
2.49.0.1204.g71687c7c1d-goog
Powered by blists - more mailing lists