@@ -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
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@linaro.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(-)