Skip to content

Commit 3f2e457

Browse files
shramamoorthybroonie
authored andcommitted
regulator: tps65219: Add support for TPS65215 regulator resources
Isolate all changes involving TPS65215 regulator desc and range resources. - 'chipid' will identify which PMIC to support, and the corresponding chip_data struct element to use in probe(). The chip_data struct is helpful for any new PMICs added to this driver. The goal is to add future PMIC info to necessary structs and minimize probe() function edits. - The probe() will now loop through common (overlapping) regulators first, then device-specific structs identified in the chip_data struct. - Add TI TPS65215 PMIC to the existing platform_device_id struct, so the regulator probe() can handle which PMIC chip_data information to use. Signed-off-by: Shree Ramamoorthy <s-ramamoorthy@ti.com> Link: https://patch.msgid.link/20250425205736.76433-3-s-ramamoorthy@ti.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 8c04144 commit 3f2e457

File tree

2 files changed

+75
-18
lines changed

2 files changed

+75
-18
lines changed

drivers/regulator/Kconfig

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1590,10 +1590,11 @@ config REGULATOR_TPS65219
15901590
tristate "TI TPS65219 Power regulators"
15911591
depends on MFD_TPS65219 && OF
15921592
help
1593-
This driver supports TPS65219 voltage regulator chips.
1593+
This driver supports TPS65219 series and TPS65215 voltage regulator chips.
15941594
TPS65219 series of PMICs have 3 single phase BUCKs & 4 LDOs
1595-
voltage regulators. It supports software based voltage control
1596-
for different voltage domains.
1595+
voltage regulators.
1596+
TPS65215 PMIC has 3 single phase BUCKs & 2 LDOs.
1597+
Both PMICs support software based voltage control for different voltage domains.
15971598

15981599
config REGULATOR_TPS6594
15991600
tristate "TI TPS6594 Power regulators"

drivers/regulator/tps65219-regulator.c

Lines changed: 71 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
// SPDX-License-Identifier: GPL-2.0
22
//
3-
// tps65219-regulator.c
4-
//
5-
// Regulator driver for TPS65219 PMIC
3+
// Regulator driver for TPS65215/TPS65219 PMIC
64
//
75
// Copyright (C) 2022 BayLibre Incorporated - https://www.baylibre.com/
6+
// Copyright (C) 2024 Texas Instruments Incorporated - https://www.ti.com/
87
//
98
// This implementation derived from tps65218 authored by
109
// "J Keerthy <j-keerthy@ti.com>"
@@ -130,6 +129,11 @@ static const struct linear_range ldo_1_range[] = {
130129
REGULATOR_LINEAR_RANGE(3400000, 0x38, 0x3f, 0),
131130
};
132131

132+
static const struct linear_range tps65215_ldo_2_range[] = {
133+
REGULATOR_LINEAR_RANGE(1200000, 0x0, 0xC, 50000),
134+
REGULATOR_LINEAR_RANGE(3300000, 0x36, 0x3F, 0),
135+
};
136+
133137
static const struct linear_range tps65219_ldo_2_range[] = {
134138
REGULATOR_LINEAR_RANGE(600000, 0x0, 0x37, 50000),
135139
REGULATOR_LINEAR_RANGE(3400000, 0x38, 0x3f, 0),
@@ -221,7 +225,7 @@ static const struct regulator_ops ldos_3_4_ops = {
221225
.map_voltage = regulator_map_voltage_linear_range,
222226
};
223227

224-
static const struct regulator_desc regulators[] = {
228+
static const struct regulator_desc common_regs[] = {
225229
TPS65219_REGULATOR("BUCK1", "buck1", TPS65219_BUCK_1,
226230
REGULATOR_VOLTAGE, bucks_ops, 64,
227231
TPS65219_REG_BUCK1_VOUT,
@@ -250,6 +254,20 @@ static const struct regulator_desc regulators[] = {
250254
TPS65219_REG_ENABLE_CTRL,
251255
TPS65219_ENABLE_LDO1_EN_MASK, 0, 0, ldo_1_range,
252256
2, 0, 0, NULL, 0, TPS65219_LDOS_BYP_CONFIG_MASK),
257+
};
258+
259+
static const struct regulator_desc tps65215_regs[] = {
260+
// TPS65215's LDO2 is the same as TPS65219's LDO3
261+
TPS65219_REGULATOR("LDO2", "ldo2", TPS65215_LDO_2,
262+
REGULATOR_VOLTAGE, ldos_3_4_ops, 64,
263+
TPS65215_REG_LDO2_VOUT,
264+
TPS65219_BUCKS_LDOS_VOUT_VSET_MASK,
265+
TPS65219_REG_ENABLE_CTRL,
266+
TPS65215_ENABLE_LDO2_EN_MASK, 0, 0, tps65215_ldo_2_range,
267+
3, 0, 0, NULL, 0, 0),
268+
};
269+
270+
static const struct regulator_desc tps65219_regs[] = {
253271
TPS65219_REGULATOR("LDO2", "ldo2", TPS65219_LDO_2,
254272
REGULATOR_VOLTAGE, ldos_1_2_ops, 64,
255273
TPS65219_REG_LDO2_VOUT,
@@ -292,28 +310,65 @@ static irqreturn_t tps65219_regulator_irq_handler(int irq, void *data)
292310
return IRQ_HANDLED;
293311
}
294312

313+
struct tps65219_chip_data {
314+
size_t rdesc_size;
315+
size_t common_rdesc_size;
316+
const struct regulator_desc *rdesc;
317+
const struct regulator_desc *common_rdesc;
318+
};
319+
320+
static struct tps65219_chip_data chip_info_table[] = {
321+
[TPS65215] = {
322+
.rdesc = tps65215_regs,
323+
.rdesc_size = ARRAY_SIZE(tps65215_regs),
324+
.common_rdesc = common_regs,
325+
.common_rdesc_size = ARRAY_SIZE(common_regs),
326+
},
327+
[TPS65219] = {
328+
.rdesc = tps65219_regs,
329+
.rdesc_size = ARRAY_SIZE(tps65219_regs),
330+
.common_rdesc = common_regs,
331+
.common_rdesc_size = ARRAY_SIZE(common_regs),
332+
},
333+
};
334+
295335
static int tps65219_regulator_probe(struct platform_device *pdev)
296336
{
297-
struct tps65219 *tps = dev_get_drvdata(pdev->dev.parent);
337+
struct tps65219_regulator_irq_data *irq_data;
338+
struct tps65219_regulator_irq_type *irq_type;
339+
340+
struct tps65219_chip_data *pmic;
298341
struct regulator_dev *rdev;
299-
struct regulator_config config = { };
300-
int i;
301342
int error;
302343
int irq;
303-
struct tps65219_regulator_irq_data *irq_data;
304-
struct tps65219_regulator_irq_type *irq_type;
344+
int i;
345+
346+
struct tps65219 *tps = dev_get_drvdata(pdev->dev.parent);
347+
struct regulator_config config = { };
348+
enum pmic_id chip = platform_get_device_id(pdev)->driver_data;
349+
350+
pmic = &chip_info_table[chip];
305351

306352
config.dev = tps->dev;
307353
config.driver_data = tps;
308354
config.regmap = tps->regmap;
309355

310-
for (i = 0; i < ARRAY_SIZE(regulators); i++) {
311-
rdev = devm_regulator_register(&pdev->dev, &regulators[i],
356+
for (i = 0; i < pmic->common_rdesc_size; i++) {
357+
rdev = devm_regulator_register(&pdev->dev, &pmic->common_rdesc[i],
358+
&config);
359+
if (IS_ERR(rdev))
360+
return dev_err_probe(tps->dev, PTR_ERR(rdev),
361+
"Failed to register %s regulator\n",
362+
pmic->common_rdesc[i].name);
363+
}
364+
365+
for (i = 0; i < pmic->rdesc_size; i++) {
366+
rdev = devm_regulator_register(&pdev->dev, &pmic->rdesc[i],
312367
&config);
313368
if (IS_ERR(rdev))
314369
return dev_err_probe(tps->dev, PTR_ERR(rdev),
315-
"Failed to register %s regulator\n",
316-
regulators[i].name);
370+
"Failed to register %s regulator\n",
371+
pmic->rdesc[i].name);
317372
}
318373

319374
irq_data = devm_kmalloc(tps->dev,
@@ -349,7 +404,8 @@ static int tps65219_regulator_probe(struct platform_device *pdev)
349404
}
350405

351406
static const struct platform_device_id tps65219_regulator_id_table[] = {
352-
{ "tps65219-regulator", },
407+
{ "tps65215-regulator", TPS65215 },
408+
{ "tps65219-regulator", TPS65219 },
353409
{ /* sentinel */ }
354410
};
355411
MODULE_DEVICE_TABLE(platform, tps65219_regulator_id_table);
@@ -366,5 +422,5 @@ static struct platform_driver tps65219_regulator_driver = {
366422
module_platform_driver(tps65219_regulator_driver);
367423

368424
MODULE_AUTHOR("Jerome Neanne <j-neanne@baylibre.com>");
369-
MODULE_DESCRIPTION("TPS65219 voltage regulator driver");
425+
MODULE_DESCRIPTION("TPS65215/TPS65219 voltage regulator driver");
370426
MODULE_LICENSE("GPL");

0 commit comments

Comments
 (0)