[PATCH 2/6] regulator: pm8008: Add PM8010 support
From: Jishnu Prakash
Date: Fri Sep 18 2026 - 12:59:54 EST
From: Konrad Dybcio <konrad.dybcio@xxxxxxxxxxxxxxxx>
PM8010 is effectively the next generation of PM8008.
Like PM8008, PM8010 also has 7 LDOs under it which are used to power
camera sensors. The PM8010 LDO are of different types from the PM8008
ones and have different voltage dropout values. PM8010 LDOs do not have
a voltage step rate configuration register.
Add the necessary changes to support PM8010 LDOs.
Signed-off-by: Konrad Dybcio <konrad.dybcio@xxxxxxxxxxxxxxxx>
Co-developed-by: Dhruvin Rajpura <drajpura@xxxxxxxxxxxxxxxx>
Signed-off-by: Dhruvin Rajpura <drajpura@xxxxxxxxxxxxxxxx>
Co-developed-by: Jishnu Prakash <jishnu.prakash@xxxxxxxxxxxxxxxx>
Signed-off-by: Jishnu Prakash <jishnu.prakash@xxxxxxxxxxxxxxxx>
---
drivers/regulator/qcom-pm8008-regulator.c | 109 +++++++++++++++++++++++-------
1 file changed, 85 insertions(+), 24 deletions(-)
diff --git a/drivers/regulator/qcom-pm8008-regulator.c b/drivers/regulator/qcom-pm8008-regulator.c
index 9c9b8be2e15a..b484c0f73eea 100644
--- a/drivers/regulator/qcom-pm8008-regulator.c
+++ b/drivers/regulator/qcom-pm8008-regulator.c
@@ -39,24 +39,59 @@ struct pm8008_regulator_data {
unsigned int base;
int min_dropout_uV;
const struct linear_range *voltage_range;
+ int n_linear_ranges;
};
-static const struct linear_range nldo_ranges[] = {
+struct pm8008_match_data {
+ const bool has_stepper_ctl_reg;
+ const struct pm8008_regulator_data *regulator_data;
+ const int num_regulators;
+};
+
+static const struct linear_range pm8008_nldo_ranges[] = {
REGULATOR_LINEAR_RANGE(528000, 0, 122, 8000),
};
-static const struct linear_range pldo_ranges[] = {
+static const struct linear_range pm8008_pldo_ranges[] = {
REGULATOR_LINEAR_RANGE(1504000, 0, 237, 8000),
};
+static const struct linear_range pm8010_nldo_ranges[] = {
+ REGULATOR_LINEAR_RANGE(528000, 0, 127, 8000),
+};
+
+static const struct linear_range pm8010_pldo_ranges[] = {
+ REGULATOR_LINEAR_RANGE(1504000, 0, 255, 8000),
+};
+
+static const struct linear_range pm8010_pldo_lv_ranges[] = {
+ REGULATOR_LINEAR_RANGE(1800000, 0, 2, 200000),
+ REGULATOR_LINEAR_RANGE(2608000, 3, 28, 16000),
+ REGULATOR_LINEAR_RANGE(3104000, 29, 30, 96000),
+ REGULATOR_LINEAR_RANGE(3312000, 31, 31, 0),
+};
+
+#define PM8008_REGULATOR(_name, _supply, _base, _dropout, _range) \
+ { _name, _supply, _base, _dropout, _range, ARRAY_SIZE(_range) }
+
static const struct pm8008_regulator_data pm8008_reg_data[] = {
- { "ldo1", "vdd-l1-l2", 0x4000, 225000, nldo_ranges, },
- { "ldo2", "vdd-l1-l2", 0x4100, 225000, nldo_ranges, },
- { "ldo3", "vdd-l3-l4", 0x4200, 300000, pldo_ranges, },
- { "ldo4", "vdd-l3-l4", 0x4300, 300000, pldo_ranges, },
- { "ldo5", "vdd-l5", 0x4400, 200000, pldo_ranges, },
- { "ldo6", "vdd-l6", 0x4500, 200000, pldo_ranges, },
- { "ldo7", "vdd-l7", 0x4600, 200000, pldo_ranges, },
+ PM8008_REGULATOR("ldo1", "vdd-l1-l2", 0x4000, 225000, pm8008_nldo_ranges),
+ PM8008_REGULATOR("ldo2", "vdd-l1-l2", 0x4100, 225000, pm8008_nldo_ranges),
+ PM8008_REGULATOR("ldo3", "vdd-l3-l4", 0x4200, 300000, pm8008_pldo_ranges),
+ PM8008_REGULATOR("ldo4", "vdd-l3-l4", 0x4300, 300000, pm8008_pldo_ranges),
+ PM8008_REGULATOR("ldo5", "vdd-l5", 0x4400, 200000, pm8008_pldo_ranges),
+ PM8008_REGULATOR("ldo6", "vdd-l6", 0x4500, 200000, pm8008_pldo_ranges),
+ PM8008_REGULATOR("ldo7", "vdd-l7", 0x4600, 200000, pm8008_pldo_ranges),
+};
+
+static const struct pm8008_regulator_data pm8010_reg_data[] = {
+ PM8008_REGULATOR("ldo1", "vdd-l1-l2", 0x4000, 172000, pm8010_nldo_ranges),
+ PM8008_REGULATOR("ldo2", "vdd-l1-l2", 0x4100, 172000, pm8010_nldo_ranges),
+ PM8008_REGULATOR("ldo3", "vdd-l3-l4", 0x4200, 80000, pm8010_pldo_lv_ranges),
+ PM8008_REGULATOR("ldo4", "vdd-l3-l4", 0x4300, 80000, pm8010_pldo_lv_ranges),
+ PM8008_REGULATOR("ldo5", "vdd-l5", 0x4400, 296000, pm8010_pldo_ranges),
+ PM8008_REGULATOR("ldo6", "vdd-l6", 0x4500, 80000, pm8010_pldo_lv_ranges),
+ PM8008_REGULATOR("ldo7", "vdd-l7", 0x4600, 296000, pm8010_pldo_ranges),
};
static int pm8008_regulator_set_voltage_sel(struct regulator_dev *rdev, unsigned int sel)
@@ -100,7 +135,7 @@ static int pm8008_regulator_get_voltage_sel(struct regulator_dev *rdev)
}
static const struct regulator_ops pm8008_regulator_ops = {
- .list_voltage = regulator_list_voltage_linear,
+ .list_voltage = regulator_list_voltage_linear_range,
.set_voltage_sel = pm8008_regulator_set_voltage_sel,
.get_voltage_sel = pm8008_regulator_get_voltage_sel,
.enable = regulator_enable_regmap,
@@ -110,8 +145,10 @@ static const struct regulator_ops pm8008_regulator_ops = {
static int pm8008_regulator_probe(struct platform_device *pdev)
{
+ const struct pm8008_match_data *match_data;
const struct pm8008_regulator_data *data;
struct regulator_config config = {};
+ const struct platform_device_id *id;
struct device *dev = &pdev->dev;
struct pm8008_regulator *preg;
struct regulator_desc *desc;
@@ -120,12 +157,20 @@ static int pm8008_regulator_probe(struct platform_device *pdev)
unsigned int val;
int ret, i;
+ id = platform_get_device_id(pdev);
+ if (!id)
+ return dev_err_probe(dev, -ENODEV, "Missing platform device id\n");
+
+ match_data = (const struct pm8008_match_data *)id->driver_data;
+ if (!match_data)
+ return dev_err_probe(dev, -ENODATA, "Missing driver match data\n");
+
regmap = dev_get_regmap(dev->parent, "secondary");
if (!regmap)
return -EINVAL;
- for (i = 0; i < ARRAY_SIZE(pm8008_reg_data); i++) {
- data = &pm8008_reg_data[i];
+ for (i = 0; i < match_data->num_regulators; i++) {
+ data = &match_data->regulator_data[i];
preg = devm_kzalloc(dev, sizeof(*preg), GFP_KERNEL);
if (!preg)
@@ -145,18 +190,21 @@ static int pm8008_regulator_probe(struct platform_device *pdev)
desc->owner = THIS_MODULE;
desc->linear_ranges = data->voltage_range;
- desc->n_linear_ranges = 1;
- desc->uV_step = desc->linear_ranges[0].step;
- desc->min_uV = desc->linear_ranges[0].min;
- desc->n_voltages = linear_range_values_in_range(&desc->linear_ranges[0]);
-
- ret = regmap_read(regmap, preg->base + LDO_STEPPER_CTL_REG, &val);
- if (ret < 0) {
- dev_err(dev, "failed to read step rate: %d\n", ret);
- return ret;
+ desc->n_linear_ranges = data->n_linear_ranges;
+ desc->n_voltages = linear_range_values_in_range_array(desc->linear_ranges,
+ desc->n_linear_ranges);
+
+ if (match_data->has_stepper_ctl_reg) {
+ ret = regmap_read(regmap, preg->base + LDO_STEPPER_CTL_REG, &val);
+ if (ret < 0) {
+ dev_err(dev, "failed to read step rate: %d\n", ret);
+ return ret;
+ }
+ val &= STEP_RATE_MASK;
+ desc->ramp_delay = DEFAULT_VOLTAGE_STEPPER_RATE >> val;
+ } else {
+ desc->ramp_delay = DEFAULT_VOLTAGE_STEPPER_RATE;
}
- val &= STEP_RATE_MASK;
- desc->ramp_delay = DEFAULT_VOLTAGE_STEPPER_RATE >> val;
desc->min_dropout_uV = data->min_dropout_uV;
@@ -179,8 +227,21 @@ static int pm8008_regulator_probe(struct platform_device *pdev)
return 0;
}
+static const struct pm8008_match_data pm8008_data = {
+ .has_stepper_ctl_reg = true,
+ .regulator_data = pm8008_reg_data,
+ .num_regulators = ARRAY_SIZE(pm8008_reg_data),
+};
+
+static const struct pm8008_match_data pm8010_data = {
+ .has_stepper_ctl_reg = false,
+ .regulator_data = pm8010_reg_data,
+ .num_regulators = ARRAY_SIZE(pm8010_reg_data),
+};
+
static const struct platform_device_id pm8008_regulator_id_table[] = {
- { .name = "pm8008-regulator" },
+ { .name = "pm8008-regulator", .driver_data = (kernel_ulong_t)&pm8008_data },
+ { .name = "pm8010-regulator", .driver_data = (kernel_ulong_t)&pm8010_data },
{ }
};
MODULE_DEVICE_TABLE(platform, pm8008_regulator_id_table);
--
2.43.0