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 IRQs

Isolate all changes involving regulator IRQ types:
- Adding in TPS65215 resources
- Organize what resources are common vs device-specific
- How the chip_data uses these resource structs
- Restructure the probe() for multi-PMIC support.

Signed-off-by: Shree Ramamoorthy <s-ramamoorthy@ti.com>
Link: https://patch.msgid.link/20250425205736.76433-4-s-ramamoorthy@ti.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Shree Ramamoorthy and committed by
Mark Brown
38c9f98d 3f2e457e

+51 -19
+51 -19
drivers/regulator/tps65219-regulator.c
··· 36 36 { "LDO4_SCG", "LDO4", "short circuit to ground", REGULATOR_EVENT_REGULATION_OUT }, 37 37 { "LDO4_OC", "LDO4", "overcurrent", REGULATOR_EVENT_OVER_CURRENT }, 38 38 { "LDO4_UV", "LDO4", "undervoltage", REGULATOR_EVENT_UNDER_VOLTAGE }, 39 + { "LDO3_RV", "LDO3", "residual voltage", REGULATOR_EVENT_OVER_VOLTAGE_WARN }, 40 + { "LDO4_RV", "LDO4", "residual voltage", REGULATOR_EVENT_OVER_VOLTAGE_WARN }, 41 + { "LDO3_RV_SD", "LDO3", "residual voltage on shutdown", REGULATOR_EVENT_OVER_VOLTAGE_WARN }, 42 + { "LDO4_RV_SD", "LDO4", "residual voltage on shutdown", REGULATOR_EVENT_OVER_VOLTAGE_WARN }, 43 + }; 44 + 45 + /* All of TPS65215's irq types are the same as common_regulator_irq_types */ 46 + static struct tps65219_regulator_irq_type common_regulator_irq_types[] = { 39 47 { "LDO1_SCG", "LDO1", "short circuit to ground", REGULATOR_EVENT_REGULATION_OUT }, 40 48 { "LDO1_OC", "LDO1", "overcurrent", REGULATOR_EVENT_OVER_CURRENT }, 41 49 { "LDO1_UV", "LDO1", "undervoltage", REGULATOR_EVENT_UNDER_VOLTAGE }, ··· 67 59 { "BUCK3_RV", "BUCK3", "residual voltage", REGULATOR_EVENT_OVER_VOLTAGE_WARN }, 68 60 { "LDO1_RV", "LDO1", "residual voltage", REGULATOR_EVENT_OVER_VOLTAGE_WARN }, 69 61 { "LDO2_RV", "LDO2", "residual voltage", REGULATOR_EVENT_OVER_VOLTAGE_WARN }, 70 - { "LDO3_RV", "LDO3", "residual voltage", REGULATOR_EVENT_OVER_VOLTAGE_WARN }, 71 - { "LDO4_RV", "LDO4", "residual voltage", REGULATOR_EVENT_OVER_VOLTAGE_WARN }, 72 62 { "BUCK1_RV_SD", "BUCK1", "residual voltage on shutdown", 73 63 REGULATOR_EVENT_OVER_VOLTAGE_WARN }, 74 64 { "BUCK2_RV_SD", "BUCK2", "residual voltage on shutdown", ··· 75 69 REGULATOR_EVENT_OVER_VOLTAGE_WARN }, 76 70 { "LDO1_RV_SD", "LDO1", "residual voltage on shutdown", REGULATOR_EVENT_OVER_VOLTAGE_WARN }, 77 71 { "LDO2_RV_SD", "LDO2", "residual voltage on shutdown", REGULATOR_EVENT_OVER_VOLTAGE_WARN }, 78 - { "LDO3_RV_SD", "LDO3", "residual voltage on shutdown", REGULATOR_EVENT_OVER_VOLTAGE_WARN }, 79 - { "LDO4_RV_SD", "LDO4", "residual voltage on shutdown", REGULATOR_EVENT_OVER_VOLTAGE_WARN }, 80 72 { "SENSOR_3_WARM", "SENSOR3", "warm temperature", REGULATOR_EVENT_OVER_TEMP_WARN}, 81 73 { "SENSOR_2_WARM", "SENSOR2", "warm temperature", REGULATOR_EVENT_OVER_TEMP_WARN }, 82 74 { "SENSOR_1_WARM", "SENSOR1", "warm temperature", REGULATOR_EVENT_OVER_TEMP_WARN }, ··· 268 264 TPS65219_BUCKS_LDOS_VOUT_VSET_MASK, 269 265 TPS65219_REG_ENABLE_CTRL, 270 266 TPS65215_ENABLE_LDO2_EN_MASK, 0, 0, tps65215_ldo_2_range, 271 - 3, 0, 0, NULL, 0, 0), 267 + 2, 0, 0, NULL, 0, 0), 272 268 }; 273 269 274 270 static const struct regulator_desc tps65219_regs[] = { ··· 317 313 struct tps65219_chip_data { 318 314 size_t rdesc_size; 319 315 size_t common_rdesc_size; 316 + size_t dev_irq_size; 317 + size_t common_irq_size; 320 318 const struct regulator_desc *rdesc; 321 319 const struct regulator_desc *common_rdesc; 320 + struct tps65219_regulator_irq_type *irq_types; 321 + struct tps65219_regulator_irq_type *common_irq_types; 322 322 }; 323 323 324 324 static struct tps65219_chip_data chip_info_table[] = { ··· 331 323 .rdesc_size = ARRAY_SIZE(tps65215_regs), 332 324 .common_rdesc = common_regs, 333 325 .common_rdesc_size = ARRAY_SIZE(common_regs), 326 + .irq_types = NULL, 327 + .dev_irq_size = 0, 328 + .common_irq_types = common_regulator_irq_types, 329 + .common_irq_size = ARRAY_SIZE(common_regulator_irq_types), 334 330 }, 335 331 [TPS65219] = { 336 332 .rdesc = tps65219_regs, 337 333 .rdesc_size = ARRAY_SIZE(tps65219_regs), 338 334 .common_rdesc = common_regs, 339 335 .common_rdesc_size = ARRAY_SIZE(common_regs), 336 + .irq_types = tps65219_regulator_irq_types, 337 + .dev_irq_size = ARRAY_SIZE(tps65219_regulator_irq_types), 338 + .common_irq_types = common_regulator_irq_types, 339 + .common_irq_size = ARRAY_SIZE(common_regulator_irq_types), 340 340 }, 341 341 }; 342 342 ··· 352 336 { 353 337 struct tps65219_regulator_irq_data *irq_data; 354 338 struct tps65219_regulator_irq_type *irq_type; 355 - 356 339 struct tps65219_chip_data *pmic; 357 340 struct regulator_dev *rdev; 358 341 int error; ··· 386 371 pmic->rdesc[i].name); 387 372 } 388 373 389 - irq_data = devm_kmalloc(tps->dev, 390 - ARRAY_SIZE(tps65219_regulator_irq_types) * 391 - sizeof(struct tps65219_regulator_irq_data), 392 - GFP_KERNEL); 374 + irq_data = devm_kmalloc(tps->dev, pmic->common_irq_size, GFP_KERNEL); 393 375 if (!irq_data) 394 376 return -ENOMEM; 395 377 396 - for (i = 0; i < ARRAY_SIZE(tps65219_regulator_irq_types); ++i) { 397 - irq_type = &tps65219_regulator_irq_types[i]; 398 - 378 + for (i = 0; i < pmic->common_irq_size; ++i) { 379 + irq_type = &pmic->common_irq_types[i]; 399 380 irq = platform_get_irq_byname(pdev, irq_type->irq_name); 400 381 if (irq < 0) 401 382 return -EINVAL; 402 383 403 384 irq_data[i].dev = tps->dev; 404 385 irq_data[i].type = irq_type; 405 - 406 386 error = devm_request_threaded_irq(tps->dev, irq, NULL, 407 387 tps65219_regulator_irq_handler, 408 388 IRQF_ONESHOT, 409 389 irq_type->irq_name, 410 390 &irq_data[i]); 411 - if (error) { 412 - dev_err(tps->dev, "failed to request %s IRQ %d: %d\n", 413 - irq_type->irq_name, irq, error); 414 - return error; 415 - } 391 + if (error) 392 + return dev_err_probe(tps->dev, PTR_ERR(rdev), 393 + "Failed to request %s IRQ %d: %d\n", 394 + irq_type->irq_name, irq, error); 395 + } 396 + 397 + irq_data = devm_kmalloc(tps->dev, pmic->dev_irq_size, GFP_KERNEL); 398 + if (!irq_data) 399 + return -ENOMEM; 400 + 401 + for (i = 0; i < pmic->dev_irq_size; ++i) { 402 + irq_type = &pmic->irq_types[i]; 403 + irq = platform_get_irq_byname(pdev, irq_type->irq_name); 404 + if (irq < 0) 405 + return -EINVAL; 406 + 407 + irq_data[i].dev = tps->dev; 408 + irq_data[i].type = irq_type; 409 + error = devm_request_threaded_irq(tps->dev, irq, NULL, 410 + tps65219_regulator_irq_handler, 411 + IRQF_ONESHOT, 412 + irq_type->irq_name, 413 + &irq_data[i]); 414 + if (error) 415 + return dev_err_probe(tps->dev, PTR_ERR(rdev), 416 + "Failed to request %s IRQ %d: %d\n", 417 + irq_type->irq_name, irq, error); 416 418 } 417 419 418 420 return 0;