[PATCH v3 07/10] regulator: ab8500: Use linear ranges for LDO voltages
From: Linus Walleij
Date: Mon Sep 14 2026 - 03:54:50 EST
VINTCORE uses consecutive selectors with uniform 25 mV steps, with
AB8505 duplicating the highest voltage at selector 7. AB8505 VAUDIO
likewise has uniform 100 mV steps followed by a duplicate selector for
its highest voltage.
Describe these selector encodings with linear ranges and the matching
regulator helpers instead of enumerated voltage tables. Keep tables for
the irregular and non-monotonic VAUX and VANA selectors.
Assisted-by: LLM
Signed-off-by: Linus Walleij <linusw@xxxxxxxxxx>
---
drivers/regulator/ab8500.c | 74 +++++++++++++++++++++++-----------------------
1 file changed, 37 insertions(+), 37 deletions(-)
diff --git a/drivers/regulator/ab8500.c b/drivers/regulator/ab8500.c
index e4c3502c8dbc..d1540099104c 100644
--- a/drivers/regulator/ab8500.c
+++ b/drivers/regulator/ab8500.c
@@ -258,25 +258,13 @@ static const unsigned int ldo_vaux56_voltages[] = {
2790000,
};
-static const unsigned int ldo_vintcore_voltages[] = {
- 1200000,
- 1225000,
- 1250000,
- 1275000,
- 1300000,
- 1325000,
- 1350000,
+static const struct linear_range ldo_vintcore_ranges[] = {
+ REGULATOR_LINEAR_RANGE(1200000, 0, 6, 25000),
};
-static const unsigned int ldo_vintcore_ab8505_voltages[] = {
- 1200000,
- 1225000,
- 1250000,
- 1275000,
- 1300000,
- 1325000,
- 1350000,
- 1350000,
+static const struct linear_range ldo_vintcore_ab8505_ranges[] = {
+ REGULATOR_LINEAR_RANGE(1200000, 0, 6, 25000),
+ REGULATOR_LINEAR_RANGE(1350000, 7, 7, 0),
};
static const unsigned int fixed_1200000_voltage[] = {
@@ -306,15 +294,10 @@ static const unsigned int ldo_vana_voltages[] = {
1225000,
};
-static const unsigned int ldo_vaudio_voltages[] = {
- 2000000,
- 2100000,
- 2200000,
- 2300000,
- 2400000,
- 2500000,
- 2600000,
- 2600000, /* Duplicated in Vaudio and IsoUicc Control register. */
+static const struct linear_range ldo_vaudio_ranges[] = {
+ REGULATOR_LINEAR_RANGE(2000000, 0, 6, 100000),
+ /* Duplicated in Vaudio and IsoUicc Control register. */
+ REGULATOR_LINEAR_RANGE(2600000, 7, 7, 0),
};
static DEFINE_MUTEX(shared_mode_mutex);
@@ -720,13 +703,27 @@ static const struct regulator_ops ab8500_regulator_volt_mode_expand_ops = {
.list_voltage = regulator_list_voltage_table,
};
-static const struct regulator_ops ab8500_regulator_volt_ops = {
+static const struct regulator_ops ab8500_regulator_linear_range_volt_mode_ops = {
+ .enable = ab8500_regulator_enable,
+ .disable = ab8500_regulator_disable,
+ .is_enabled = ab8500_regulator_is_enabled,
+ .get_optimum_mode = ab8500_regulator_get_optimum_mode,
+ .set_mode = ab8500_regulator_set_mode,
+ .get_mode = ab8500_regulator_get_mode,
+ .get_voltage_sel = ab8500_regulator_get_voltage_sel,
+ .set_voltage_sel = ab8500_regulator_set_voltage_sel,
+ .list_voltage = regulator_list_voltage_linear_range,
+ .map_voltage = regulator_map_voltage_linear_range,
+};
+
+static const struct regulator_ops ab8500_regulator_linear_range_volt_ops = {
.enable = ab8500_regulator_enable,
.disable = ab8500_regulator_disable,
.is_enabled = ab8500_regulator_is_enabled,
.get_voltage_sel = ab8500_regulator_get_voltage_sel,
.set_voltage_sel = ab8500_regulator_set_voltage_sel,
- .list_voltage = regulator_list_voltage_table,
+ .list_voltage = regulator_list_voltage_linear_range,
+ .map_voltage = regulator_map_voltage_linear_range,
};
static const struct regulator_ops ab8500_regulator_mode_ops = {
@@ -836,12 +833,13 @@ static struct ab8500_regulator_info
[AB8500_LDO_INTCORE] = {
.desc = {
.name = "LDO-INTCORE",
- .ops = &ab8500_regulator_volt_mode_ops,
+ .ops = &ab8500_regulator_linear_range_volt_mode_ops,
.type = REGULATOR_VOLTAGE,
.id = AB8500_LDO_INTCORE,
.owner = THIS_MODULE,
- .n_voltages = ARRAY_SIZE(ldo_vintcore_voltages),
- .volt_table = ldo_vintcore_voltages,
+ .n_voltages = 7,
+ .linear_ranges = ldo_vintcore_ranges,
+ .n_linear_ranges = ARRAY_SIZE(ldo_vintcore_ranges),
.enable_time = 750,
},
.load_lp_uA = 5000,
@@ -1121,12 +1119,13 @@ static struct ab8500_regulator_info
[AB8505_LDO_INTCORE] = {
.desc = {
.name = "LDO-INTCORE",
- .ops = &ab8500_regulator_volt_mode_ops,
+ .ops = &ab8500_regulator_linear_range_volt_mode_ops,
.type = REGULATOR_VOLTAGE,
.id = AB8505_LDO_INTCORE,
.owner = THIS_MODULE,
- .n_voltages = ARRAY_SIZE(ldo_vintcore_ab8505_voltages),
- .volt_table = ldo_vintcore_ab8505_voltages,
+ .n_voltages = 8,
+ .linear_ranges = ldo_vintcore_ab8505_ranges,
+ .n_linear_ranges = ARRAY_SIZE(ldo_vintcore_ab8505_ranges),
},
.load_lp_uA = 5000,
.update_bank = 0x03,
@@ -1169,12 +1168,13 @@ static struct ab8500_regulator_info
[AB8505_LDO_AUDIO] = {
.desc = {
.name = "LDO-AUDIO",
- .ops = &ab8500_regulator_volt_ops,
+ .ops = &ab8500_regulator_linear_range_volt_ops,
.type = REGULATOR_VOLTAGE,
.id = AB8505_LDO_AUDIO,
.owner = THIS_MODULE,
- .n_voltages = ARRAY_SIZE(ldo_vaudio_voltages),
- .volt_table = ldo_vaudio_voltages,
+ .n_voltages = 8,
+ .linear_ranges = ldo_vaudio_ranges,
+ .n_linear_ranges = ARRAY_SIZE(ldo_vaudio_ranges),
},
.update_bank = 0x03,
.update_reg = 0x83,
--
2.55.0