Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Shree Ramamoorthy and committed by
Mark Brown
3f2e457e 8c04144e

+76 -19
+4 -3
drivers/regulator/Kconfig
··· 1590 1590 tristate "TI TPS65219 Power regulators" 1591 1591 depends on MFD_TPS65219 && OF 1592 1592 help 1593 - This driver supports TPS65219 voltage regulator chips. 1593 + This driver supports TPS65219 series and TPS65215 voltage regulator chips. 1594 1594 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. 1597 1598 1598 1599 config REGULATOR_TPS6594 1599 1600 tristate "TI TPS6594 Power regulators"
+72 -16
drivers/regulator/tps65219-regulator.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 2 2 // 3 - // tps65219-regulator.c 4 - // 5 - // Regulator driver for TPS65219 PMIC 3 + // Regulator driver for TPS65215/TPS65219 PMIC 6 4 // 7 5 // Copyright (C) 2022 BayLibre Incorporated - https://www.baylibre.com/ 6 + // Copyright (C) 2024 Texas Instruments Incorporated - https://www.ti.com/ 8 7 // 9 8 // This implementation derived from tps65218 authored by 10 9 // "J Keerthy <j-keerthy@ti.com>" ··· 129 130 REGULATOR_LINEAR_RANGE(3400000, 0x38, 0x3f, 0), 130 131 }; 131 132 133 + static const struct linear_range tps65215_ldo_2_range[] = { 134 + REGULATOR_LINEAR_RANGE(1200000, 0x0, 0xC, 50000), 135 + REGULATOR_LINEAR_RANGE(3300000, 0x36, 0x3F, 0), 136 + }; 137 + 132 138 static const struct linear_range tps65219_ldo_2_range[] = { 133 139 REGULATOR_LINEAR_RANGE(600000, 0x0, 0x37, 50000), 134 140 REGULATOR_LINEAR_RANGE(3400000, 0x38, 0x3f, 0), ··· 225 221 .map_voltage = regulator_map_voltage_linear_range, 226 222 }; 227 223 228 - static const struct regulator_desc regulators[] = { 224 + static const struct regulator_desc common_regs[] = { 229 225 TPS65219_REGULATOR("BUCK1", "buck1", TPS65219_BUCK_1, 230 226 REGULATOR_VOLTAGE, bucks_ops, 64, 231 227 TPS65219_REG_BUCK1_VOUT, ··· 254 250 TPS65219_REG_ENABLE_CTRL, 255 251 TPS65219_ENABLE_LDO1_EN_MASK, 0, 0, ldo_1_range, 256 252 2, 0, 0, NULL, 0, TPS65219_LDOS_BYP_CONFIG_MASK), 253 + }; 254 + 255 + static const struct regulator_desc tps65215_regs[] = { 256 + // TPS65215's LDO2 is the same as TPS65219's LDO3 257 + TPS65219_REGULATOR("LDO2", "ldo2", TPS65215_LDO_2, 258 + REGULATOR_VOLTAGE, ldos_3_4_ops, 64, 259 + TPS65215_REG_LDO2_VOUT, 260 + TPS65219_BUCKS_LDOS_VOUT_VSET_MASK, 261 + TPS65219_REG_ENABLE_CTRL, 262 + TPS65215_ENABLE_LDO2_EN_MASK, 0, 0, tps65215_ldo_2_range, 263 + 3, 0, 0, NULL, 0, 0), 264 + }; 265 + 266 + static const struct regulator_desc tps65219_regs[] = { 257 267 TPS65219_REGULATOR("LDO2", "ldo2", TPS65219_LDO_2, 258 268 REGULATOR_VOLTAGE, ldos_1_2_ops, 64, 259 269 TPS65219_REG_LDO2_VOUT, ··· 310 292 return IRQ_HANDLED; 311 293 } 312 294 295 + struct tps65219_chip_data { 296 + size_t rdesc_size; 297 + size_t common_rdesc_size; 298 + const struct regulator_desc *rdesc; 299 + const struct regulator_desc *common_rdesc; 300 + }; 301 + 302 + static struct tps65219_chip_data chip_info_table[] = { 303 + [TPS65215] = { 304 + .rdesc = tps65215_regs, 305 + .rdesc_size = ARRAY_SIZE(tps65215_regs), 306 + .common_rdesc = common_regs, 307 + .common_rdesc_size = ARRAY_SIZE(common_regs), 308 + }, 309 + [TPS65219] = { 310 + .rdesc = tps65219_regs, 311 + .rdesc_size = ARRAY_SIZE(tps65219_regs), 312 + .common_rdesc = common_regs, 313 + .common_rdesc_size = ARRAY_SIZE(common_regs), 314 + }, 315 + }; 316 + 313 317 static int tps65219_regulator_probe(struct platform_device *pdev) 314 318 { 315 - struct tps65219 *tps = dev_get_drvdata(pdev->dev.parent); 316 - struct regulator_dev *rdev; 317 - struct regulator_config config = { }; 318 - int i; 319 - int error; 320 - int irq; 321 319 struct tps65219_regulator_irq_data *irq_data; 322 320 struct tps65219_regulator_irq_type *irq_type; 321 + 322 + struct tps65219_chip_data *pmic; 323 + struct regulator_dev *rdev; 324 + int error; 325 + int irq; 326 + int i; 327 + 328 + struct tps65219 *tps = dev_get_drvdata(pdev->dev.parent); 329 + struct regulator_config config = { }; 330 + enum pmic_id chip = platform_get_device_id(pdev)->driver_data; 331 + 332 + pmic = &chip_info_table[chip]; 323 333 324 334 config.dev = tps->dev; 325 335 config.driver_data = tps; 326 336 config.regmap = tps->regmap; 327 337 328 - for (i = 0; i < ARRAY_SIZE(regulators); i++) { 329 - rdev = devm_regulator_register(&pdev->dev, &regulators[i], 338 + for (i = 0; i < pmic->common_rdesc_size; i++) { 339 + rdev = devm_regulator_register(&pdev->dev, &pmic->common_rdesc[i], 330 340 &config); 331 341 if (IS_ERR(rdev)) 332 342 return dev_err_probe(tps->dev, PTR_ERR(rdev), 333 - "Failed to register %s regulator\n", 334 - regulators[i].name); 343 + "Failed to register %s regulator\n", 344 + pmic->common_rdesc[i].name); 345 + } 346 + 347 + for (i = 0; i < pmic->rdesc_size; i++) { 348 + rdev = devm_regulator_register(&pdev->dev, &pmic->rdesc[i], 349 + &config); 350 + if (IS_ERR(rdev)) 351 + return dev_err_probe(tps->dev, PTR_ERR(rdev), 352 + "Failed to register %s regulator\n", 353 + pmic->rdesc[i].name); 335 354 } 336 355 337 356 irq_data = devm_kmalloc(tps->dev, ··· 404 349 } 405 350 406 351 static const struct platform_device_id tps65219_regulator_id_table[] = { 407 - { "tps65219-regulator", }, 352 + { "tps65215-regulator", TPS65215 }, 353 + { "tps65219-regulator", TPS65219 }, 408 354 { /* sentinel */ } 409 355 }; 410 356 MODULE_DEVICE_TABLE(platform, tps65219_regulator_id_table); ··· 422 366 module_platform_driver(tps65219_regulator_driver); 423 367 424 368 MODULE_AUTHOR("Jerome Neanne <j-neanne@baylibre.com>"); 425 - MODULE_DESCRIPTION("TPS65219 voltage regulator driver"); 369 + MODULE_DESCRIPTION("TPS65215/TPS65219 voltage regulator driver"); 426 370 MODULE_LICENSE("GPL");