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: tps6594-regulator: Add TI TPS65224 PMIC regulators

Add support for TPS65224 regulators (bucks and LDOs) to TPS6594 driver as
they have significant functional overlap. TPS65224 PMIC has 4 buck
regulators and 3 LDOs. BUCK12 can operate in dual phase.
The output voltages are configurable and are meant to supply power to the
main processor and other components.

Signed-off-by: Nirmala Devi Mal Nadar <m.nirmaladevi@ltts.com>
Signed-off-by: Bhargav Raviprakash <bhargav.r@ltts.com>
Reviewed-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/0109018f2fdcc305-3b817569-21b6-42a7-942c-8edbff3848f2-000000@ap-south-1.amazonses.com
Signed-off-by: Lee Jones <lee@kernel.org>

authored by

Nirmala Devi Mal Nadar and committed by
Lee Jones
00c82652 91020aec

+271 -73
+3 -1
drivers/regulator/Kconfig
··· 1563 1563 depends on MFD_TPS6594 && OF 1564 1564 default MFD_TPS6594 1565 1565 help 1566 - This driver supports TPS6594 voltage regulator chips. 1566 + This driver supports TPS6594 series and TPS65224 voltage regulator chips. 1567 1567 TPS6594 series of PMICs have 5 BUCKs and 4 LDOs 1568 1568 voltage regulators. 1569 1569 BUCKs 1,2,3,4 can be used in single phase or multiphase mode. 1570 1570 Part number defines which single or multiphase mode is i used. 1571 1571 It supports software based voltage control 1572 1572 for different voltage domains. 1573 + TPS65224 PMIC has 4 BUCKs and 3 LDOs. BUCK12 can be used in dual phase. 1574 + All BUCKs and LDOs volatge can be controlled through software. 1573 1575 1574 1576 config REGULATOR_TPS6524X 1575 1577 tristate "TI TPS6524X Power regulators"
+268 -72
drivers/regulator/tps6594-regulator.c
··· 18 18 19 19 #include <linux/mfd/tps6594.h> 20 20 21 - #define BUCK_NB 5 22 - #define LDO_NB 4 23 - #define MULTI_PHASE_NB 4 24 - #define REGS_INT_NB 4 21 + #define BUCK_NB 5 22 + #define LDO_NB 4 23 + #define MULTI_PHASE_NB 4 24 + /* TPS6593 and LP8764 supports OV, UV, SC, ILIM */ 25 + #define REGS_INT_NB 4 26 + /* TPS65224 supports OV or UV */ 27 + #define TPS65224_REGS_INT_NB 1 25 28 26 29 enum tps6594_regulator_id { 27 30 /* DCDC's */ ··· 67 64 { TPS6594_IRQ_NAME_VMON2_UV, "VMON2", "undervoltage", REGULATOR_EVENT_UNDER_VOLTAGE }, 68 65 { TPS6594_IRQ_NAME_VMON2_RV, "VMON2", "residual voltage", 69 66 REGULATOR_EVENT_OVER_VOLTAGE_WARN }, 67 + }; 68 + 69 + static struct tps6594_regulator_irq_type tps65224_ext_regulator_irq_types[] = { 70 + { TPS65224_IRQ_NAME_VCCA_UVOV, "VCCA", "voltage out of range", 71 + REGULATOR_EVENT_REGULATION_OUT }, 72 + { TPS65224_IRQ_NAME_VMON1_UVOV, "VMON1", "voltage out of range", 73 + REGULATOR_EVENT_REGULATION_OUT }, 74 + { TPS65224_IRQ_NAME_VMON2_UVOV, "VMON2", "voltage out of range", 75 + REGULATOR_EVENT_REGULATION_OUT }, 70 76 }; 71 77 72 78 struct tps6594_regulator_irq_data { ··· 132 120 133 121 static const struct linear_range ldos_4_ranges[] = { 134 122 REGULATOR_LINEAR_RANGE(1200000, 0x20, 0x74, 25000), 123 + }; 124 + 125 + /* Voltage range for TPS65224 Bucks and LDOs */ 126 + static const struct linear_range tps65224_bucks_1_ranges[] = { 127 + REGULATOR_LINEAR_RANGE(500000, 0x0a, 0x0e, 20000), 128 + REGULATOR_LINEAR_RANGE(600000, 0x0f, 0x72, 5000), 129 + REGULATOR_LINEAR_RANGE(1100000, 0x73, 0xaa, 10000), 130 + REGULATOR_LINEAR_RANGE(1660000, 0xab, 0xfd, 20000), 131 + }; 132 + 133 + static const struct linear_range tps65224_bucks_2_3_4_ranges[] = { 134 + REGULATOR_LINEAR_RANGE(500000, 0x0, 0x1a, 25000), 135 + REGULATOR_LINEAR_RANGE(1200000, 0x1b, 0x45, 50000), 136 + }; 137 + 138 + static const struct linear_range tps65224_ldos_1_ranges[] = { 139 + REGULATOR_LINEAR_RANGE(1200000, 0xC, 0x36, 50000), 140 + }; 141 + 142 + static const struct linear_range tps65224_ldos_2_3_ranges[] = { 143 + REGULATOR_LINEAR_RANGE(600000, 0x0, 0x38, 50000), 135 144 }; 136 145 137 146 /* Operations permitted on BUCK1/2/3/4/5 */ ··· 230 197 4, 0, 0, NULL, 0, 0), 231 198 }; 232 199 200 + /* Buck configuration for TPS65224 */ 201 + static const struct regulator_desc tps65224_buck_regs[] = { 202 + TPS6594_REGULATOR("BUCK1", "buck1", TPS6594_BUCK_1, 203 + REGULATOR_VOLTAGE, tps6594_bucks_ops, TPS65224_MASK_BUCK1_VSET, 204 + TPS6594_REG_BUCKX_VOUT_1(0), 205 + TPS65224_MASK_BUCK1_VSET, 206 + TPS6594_REG_BUCKX_CTRL(0), 207 + TPS6594_BIT_BUCK_EN, 0, 0, tps65224_bucks_1_ranges, 208 + 4, 0, 0, NULL, 0, 0), 209 + TPS6594_REGULATOR("BUCK2", "buck2", TPS6594_BUCK_2, 210 + REGULATOR_VOLTAGE, tps6594_bucks_ops, TPS65224_MASK_BUCKS_VSET, 211 + TPS6594_REG_BUCKX_VOUT_1(1), 212 + TPS65224_MASK_BUCKS_VSET, 213 + TPS6594_REG_BUCKX_CTRL(1), 214 + TPS6594_BIT_BUCK_EN, 0, 0, tps65224_bucks_2_3_4_ranges, 215 + 4, 0, 0, NULL, 0, 0), 216 + TPS6594_REGULATOR("BUCK3", "buck3", TPS6594_BUCK_3, 217 + REGULATOR_VOLTAGE, tps6594_bucks_ops, TPS65224_MASK_BUCKS_VSET, 218 + TPS6594_REG_BUCKX_VOUT_1(2), 219 + TPS65224_MASK_BUCKS_VSET, 220 + TPS6594_REG_BUCKX_CTRL(2), 221 + TPS6594_BIT_BUCK_EN, 0, 0, tps65224_bucks_2_3_4_ranges, 222 + 4, 0, 0, NULL, 0, 0), 223 + TPS6594_REGULATOR("BUCK4", "buck4", TPS6594_BUCK_4, 224 + REGULATOR_VOLTAGE, tps6594_bucks_ops, TPS65224_MASK_BUCKS_VSET, 225 + TPS6594_REG_BUCKX_VOUT_1(3), 226 + TPS65224_MASK_BUCKS_VSET, 227 + TPS6594_REG_BUCKX_CTRL(3), 228 + TPS6594_BIT_BUCK_EN, 0, 0, tps65224_bucks_2_3_4_ranges, 229 + 4, 0, 0, NULL, 0, 0), 230 + }; 231 + 233 232 static struct tps6594_regulator_irq_type tps6594_buck1_irq_types[] = { 234 233 { TPS6594_IRQ_NAME_BUCK1_OV, "BUCK1", "overvoltage", REGULATOR_EVENT_OVER_VOLTAGE_WARN }, 235 234 { TPS6594_IRQ_NAME_BUCK1_UV, "BUCK1", "undervoltage", REGULATOR_EVENT_UNDER_VOLTAGE }, ··· 334 269 REGULATOR_EVENT_OVER_CURRENT }, 335 270 }; 336 271 272 + static struct tps6594_regulator_irq_type tps65224_buck1_irq_types[] = { 273 + { TPS65224_IRQ_NAME_BUCK1_UVOV, "BUCK1", "voltage out of range", 274 + REGULATOR_EVENT_REGULATION_OUT }, 275 + }; 276 + 277 + static struct tps6594_regulator_irq_type tps65224_buck2_irq_types[] = { 278 + { TPS65224_IRQ_NAME_BUCK2_UVOV, "BUCK2", "voltage out of range", 279 + REGULATOR_EVENT_REGULATION_OUT }, 280 + }; 281 + 282 + static struct tps6594_regulator_irq_type tps65224_buck3_irq_types[] = { 283 + { TPS65224_IRQ_NAME_BUCK3_UVOV, "BUCK3", "voltage out of range", 284 + REGULATOR_EVENT_REGULATION_OUT }, 285 + }; 286 + 287 + static struct tps6594_regulator_irq_type tps65224_buck4_irq_types[] = { 288 + { TPS65224_IRQ_NAME_BUCK4_UVOV, "BUCK4", "voltage out of range", 289 + REGULATOR_EVENT_REGULATION_OUT }, 290 + }; 291 + 292 + static struct tps6594_regulator_irq_type tps65224_ldo1_irq_types[] = { 293 + { TPS65224_IRQ_NAME_LDO1_UVOV, "LDO1", "voltage out of range", 294 + REGULATOR_EVENT_REGULATION_OUT }, 295 + }; 296 + 297 + static struct tps6594_regulator_irq_type tps65224_ldo2_irq_types[] = { 298 + { TPS65224_IRQ_NAME_LDO2_UVOV, "LDO2", "voltage out of range", 299 + REGULATOR_EVENT_REGULATION_OUT }, 300 + }; 301 + 302 + static struct tps6594_regulator_irq_type tps65224_ldo3_irq_types[] = { 303 + { TPS65224_IRQ_NAME_LDO3_UVOV, "LDO3", "voltage out of range", 304 + REGULATOR_EVENT_REGULATION_OUT }, 305 + }; 306 + 337 307 static struct tps6594_regulator_irq_type *tps6594_bucks_irq_types[] = { 338 308 tps6594_buck1_irq_types, 339 309 tps6594_buck2_irq_types, ··· 384 284 tps6594_ldo4_irq_types, 385 285 }; 386 286 387 - static const struct regulator_desc multi_regs[] = { 287 + static struct tps6594_regulator_irq_type *tps65224_bucks_irq_types[] = { 288 + tps65224_buck1_irq_types, 289 + tps65224_buck2_irq_types, 290 + tps65224_buck3_irq_types, 291 + tps65224_buck4_irq_types, 292 + }; 293 + 294 + static struct tps6594_regulator_irq_type *tps65224_ldos_irq_types[] = { 295 + tps65224_ldo1_irq_types, 296 + tps65224_ldo2_irq_types, 297 + tps65224_ldo3_irq_types, 298 + }; 299 + 300 + static const struct regulator_desc tps6594_multi_regs[] = { 388 301 TPS6594_REGULATOR("BUCK12", "buck12", TPS6594_BUCK_1, 389 302 REGULATOR_VOLTAGE, tps6594_bucks_ops, TPS6594_MASK_BUCKS_VSET, 390 303 TPS6594_REG_BUCKX_VOUT_1(1), ··· 428 315 4, 4000, 0, NULL, 0, 0), 429 316 }; 430 317 431 - static const struct regulator_desc ldo_regs[] = { 318 + static const struct regulator_desc tps65224_multi_regs[] = { 319 + TPS6594_REGULATOR("BUCK12", "buck12", TPS6594_BUCK_1, 320 + REGULATOR_VOLTAGE, tps6594_bucks_ops, TPS65224_MASK_BUCK1_VSET, 321 + TPS6594_REG_BUCKX_VOUT_1(0), 322 + TPS65224_MASK_BUCK1_VSET, 323 + TPS6594_REG_BUCKX_CTRL(0), 324 + TPS6594_BIT_BUCK_EN, 0, 0, tps65224_bucks_1_ranges, 325 + 4, 4000, 0, NULL, 0, 0), 326 + }; 327 + 328 + static const struct regulator_desc tps6594_ldo_regs[] = { 432 329 TPS6594_REGULATOR("LDO1", "ldo1", TPS6594_LDO_1, 433 330 REGULATOR_VOLTAGE, tps6594_ldos_1_2_3_ops, TPS6594_MASK_LDO123_VSET, 434 331 TPS6594_REG_LDOX_VOUT(0), ··· 469 346 1, 0, 0, NULL, 0, 0), 470 347 }; 471 348 349 + static const struct regulator_desc tps65224_ldo_regs[] = { 350 + TPS6594_REGULATOR("LDO1", "ldo1", TPS6594_LDO_1, 351 + REGULATOR_VOLTAGE, tps6594_ldos_1_2_3_ops, TPS6594_MASK_LDO123_VSET, 352 + TPS6594_REG_LDOX_VOUT(0), 353 + TPS6594_MASK_LDO123_VSET, 354 + TPS6594_REG_LDOX_CTRL(0), 355 + TPS6594_BIT_LDO_EN, 0, 0, tps65224_ldos_1_ranges, 356 + 1, 0, 0, NULL, 0, TPS6594_BIT_LDO_BYPASS), 357 + TPS6594_REGULATOR("LDO2", "ldo2", TPS6594_LDO_2, 358 + REGULATOR_VOLTAGE, tps6594_ldos_1_2_3_ops, TPS6594_MASK_LDO123_VSET, 359 + TPS6594_REG_LDOX_VOUT(1), 360 + TPS6594_MASK_LDO123_VSET, 361 + TPS6594_REG_LDOX_CTRL(1), 362 + TPS6594_BIT_LDO_EN, 0, 0, tps65224_ldos_2_3_ranges, 363 + 1, 0, 0, NULL, 0, TPS6594_BIT_LDO_BYPASS), 364 + TPS6594_REGULATOR("LDO3", "ldo3", TPS6594_LDO_3, 365 + REGULATOR_VOLTAGE, tps6594_ldos_1_2_3_ops, TPS6594_MASK_LDO123_VSET, 366 + TPS6594_REG_LDOX_VOUT(2), 367 + TPS6594_MASK_LDO123_VSET, 368 + TPS6594_REG_LDOX_CTRL(2), 369 + TPS6594_BIT_LDO_EN, 0, 0, tps65224_ldos_2_3_ranges, 370 + 1, 0, 0, NULL, 0, TPS6594_BIT_LDO_BYPASS), 371 + }; 372 + 472 373 static irqreturn_t tps6594_regulator_irq_handler(int irq, void *data) 473 374 { 474 375 struct tps6594_regulator_irq_data *irq_data = data; ··· 516 369 static int tps6594_request_reg_irqs(struct platform_device *pdev, 517 370 struct regulator_dev *rdev, 518 371 struct tps6594_regulator_irq_data *irq_data, 519 - struct tps6594_regulator_irq_type *tps6594_regs_irq_types, 372 + struct tps6594_regulator_irq_type *regs_irq_types, 373 + size_t interrupt_cnt, 520 374 int *irq_idx) 521 375 { 522 376 struct tps6594_regulator_irq_type *irq_type; 523 377 struct tps6594 *tps = dev_get_drvdata(pdev->dev.parent); 524 - int j; 378 + size_t j; 525 379 int irq; 526 380 int error; 527 381 528 - for (j = 0; j < REGS_INT_NB; j++) { 529 - irq_type = &tps6594_regs_irq_types[j]; 382 + for (j = 0; j < interrupt_cnt; j++) { 383 + irq_type = &regs_irq_types[j]; 530 384 irq = platform_get_irq_byname(pdev, irq_type->irq_name); 531 385 if (irq < 0) 532 386 return -EINVAL; ··· 559 411 struct tps6594_regulator_irq_data *irq_data; 560 412 struct tps6594_ext_regulator_irq_data *irq_ext_reg_data; 561 413 struct tps6594_regulator_irq_type *irq_type; 562 - u8 buck_configured[BUCK_NB] = { 0 }; 563 - u8 buck_multi[MULTI_PHASE_NB] = { 0 }; 564 - static const char * const multiphases[] = {"buck12", "buck123", "buck1234", "buck34"}; 414 + struct tps6594_regulator_irq_type *irq_types; 415 + bool buck_configured[BUCK_NB] = { false }; 416 + bool buck_multi[MULTI_PHASE_NB] = { false }; 417 + 565 418 static const char *npname; 566 - int error, i, irq, multi, delta; 419 + int error, i, irq, multi; 567 420 int irq_idx = 0; 568 421 int buck_idx = 0; 569 - size_t ext_reg_irq_nb = 2; 422 + int nr_ldo; 423 + int nr_buck; 424 + int nr_types; 425 + unsigned int irq_count; 426 + unsigned int multi_phase_cnt; 570 427 size_t reg_irq_nb; 428 + struct tps6594_regulator_irq_type **bucks_irq_types; 429 + const struct regulator_desc *multi_regs; 430 + struct tps6594_regulator_irq_type **ldos_irq_types; 431 + const struct regulator_desc *ldo_regs; 432 + size_t interrupt_count; 433 + 434 + if (tps->chip_id == TPS65224) { 435 + bucks_irq_types = tps65224_bucks_irq_types; 436 + interrupt_count = ARRAY_SIZE(tps65224_buck1_irq_types); 437 + multi_regs = tps65224_multi_regs; 438 + ldos_irq_types = tps65224_ldos_irq_types; 439 + ldo_regs = tps65224_ldo_regs; 440 + multi_phase_cnt = ARRAY_SIZE(tps65224_multi_regs); 441 + } else { 442 + bucks_irq_types = tps6594_bucks_irq_types; 443 + interrupt_count = ARRAY_SIZE(tps6594_buck1_irq_types); 444 + multi_regs = tps6594_multi_regs; 445 + ldos_irq_types = tps6594_ldos_irq_types; 446 + ldo_regs = tps6594_ldo_regs; 447 + multi_phase_cnt = ARRAY_SIZE(tps6594_multi_regs); 448 + } 449 + 571 450 enum { 572 451 MULTI_BUCK12, 452 + MULTI_BUCK12_34, 573 453 MULTI_BUCK123, 574 454 MULTI_BUCK1234, 575 - MULTI_BUCK12_34, 576 - MULTI_FIRST = MULTI_BUCK12, 577 - MULTI_LAST = MULTI_BUCK12_34, 578 - MULTI_NUM = MULTI_LAST - MULTI_FIRST + 1 579 455 }; 580 456 581 457 config.dev = tps->dev; ··· 614 442 * In case of Multiphase configuration, value should be defined for 615 443 * buck_configured to avoid creating bucks for every buck in multiphase 616 444 */ 617 - for (multi = MULTI_FIRST; multi < MULTI_NUM; multi++) { 618 - np = of_find_node_by_name(tps->dev->of_node, multiphases[multi]); 445 + for (multi = 0; multi < multi_phase_cnt; multi++) { 446 + np = of_find_node_by_name(tps->dev->of_node, multi_regs[multi].supply_name); 619 447 npname = of_node_full_name(np); 620 448 np_pmic_parent = of_get_parent(of_get_parent(np)); 621 449 if (of_node_cmp(of_node_full_name(np_pmic_parent), tps->dev->of_node->full_name)) 622 450 continue; 623 - delta = strcmp(npname, multiphases[multi]); 624 - if (!delta) { 451 + if (strcmp(npname, multi_regs[multi].supply_name) == 0) { 625 452 switch (multi) { 626 453 case MULTI_BUCK12: 627 - buck_multi[0] = 1; 628 - buck_configured[0] = 1; 629 - buck_configured[1] = 1; 454 + buck_multi[0] = true; 455 + buck_configured[0] = true; 456 + buck_configured[1] = true; 630 457 break; 631 458 /* multiphase buck34 is supported only with buck12 */ 632 459 case MULTI_BUCK12_34: 633 - buck_multi[0] = 1; 634 - buck_multi[1] = 1; 635 - buck_configured[0] = 1; 636 - buck_configured[1] = 1; 637 - buck_configured[2] = 1; 638 - buck_configured[3] = 1; 460 + buck_multi[0] = true; 461 + buck_multi[1] = true; 462 + buck_configured[0] = true; 463 + buck_configured[1] = true; 464 + buck_configured[2] = true; 465 + buck_configured[3] = true; 639 466 break; 640 467 case MULTI_BUCK123: 641 - buck_multi[2] = 1; 642 - buck_configured[0] = 1; 643 - buck_configured[1] = 1; 644 - buck_configured[2] = 1; 468 + buck_multi[2] = true; 469 + buck_configured[0] = true; 470 + buck_configured[1] = true; 471 + buck_configured[2] = true; 645 472 break; 646 473 case MULTI_BUCK1234: 647 - buck_multi[3] = 1; 648 - buck_configured[0] = 1; 649 - buck_configured[1] = 1; 650 - buck_configured[2] = 1; 651 - buck_configured[3] = 1; 474 + buck_multi[3] = true; 475 + buck_configured[0] = true; 476 + buck_configured[1] = true; 477 + buck_configured[2] = true; 478 + buck_configured[3] = true; 652 479 break; 653 480 } 654 481 } 655 482 } 656 483 657 484 if (tps->chip_id == LP8764) { 658 - /* There is only 4 buck on LP8764 */ 659 - buck_configured[4] = 1; 660 - reg_irq_nb = size_mul(REGS_INT_NB, (BUCK_NB - 1)); 485 + nr_buck = ARRAY_SIZE(buck_regs); 486 + nr_ldo = 0; 487 + nr_types = REGS_INT_NB; 488 + } else if (tps->chip_id == TPS65224) { 489 + nr_buck = ARRAY_SIZE(tps65224_buck_regs); 490 + nr_ldo = ARRAY_SIZE(tps65224_ldo_regs); 491 + nr_types = REGS_INT_NB; 661 492 } else { 662 - reg_irq_nb = size_mul(REGS_INT_NB, (size_add(BUCK_NB, LDO_NB))); 493 + nr_buck = ARRAY_SIZE(buck_regs); 494 + nr_ldo = ARRAY_SIZE(tps6594_ldo_regs); 495 + nr_types = TPS65224_REGS_INT_NB; 663 496 } 497 + 498 + reg_irq_nb = nr_types * (nr_buck + nr_ldo); 664 499 665 500 irq_data = devm_kmalloc_array(tps->dev, reg_irq_nb, 666 501 sizeof(struct tps6594_regulator_irq_data), GFP_KERNEL); 667 502 if (!irq_data) 668 503 return -ENOMEM; 669 504 670 - for (i = 0; i < MULTI_PHASE_NB; i++) { 671 - if (buck_multi[i] == 0) 505 + for (i = 0; i < multi_phase_cnt; i++) { 506 + if (!buck_multi[i]) 672 507 continue; 673 508 674 509 rdev = devm_regulator_register(&pdev->dev, &multi_regs[i], &config); ··· 685 506 pdev->name); 686 507 687 508 /* config multiphase buck12+buck34 */ 688 - if (i == 1) 509 + if (i == MULTI_BUCK12_34) 689 510 buck_idx = 2; 511 + 690 512 error = tps6594_request_reg_irqs(pdev, rdev, irq_data, 691 - tps6594_bucks_irq_types[buck_idx], &irq_idx); 692 - if (error) 693 - return error; 694 - error = tps6594_request_reg_irqs(pdev, rdev, irq_data, 695 - tps6594_bucks_irq_types[buck_idx + 1], &irq_idx); 513 + bucks_irq_types[buck_idx], 514 + interrupt_count, &irq_idx); 696 515 if (error) 697 516 return error; 698 517 699 - if (i == 2 || i == 3) { 518 + error = tps6594_request_reg_irqs(pdev, rdev, irq_data, 519 + bucks_irq_types[buck_idx + 1], 520 + interrupt_count, &irq_idx); 521 + if (error) 522 + return error; 523 + 524 + if (i == MULTI_BUCK123 || i == MULTI_BUCK1234) { 700 525 error = tps6594_request_reg_irqs(pdev, rdev, irq_data, 701 526 tps6594_bucks_irq_types[buck_idx + 2], 527 + interrupt_count, 702 528 &irq_idx); 703 529 if (error) 704 530 return error; 705 531 } 706 - if (i == 3) { 532 + if (i == MULTI_BUCK1234) { 707 533 error = tps6594_request_reg_irqs(pdev, rdev, irq_data, 708 534 tps6594_bucks_irq_types[buck_idx + 3], 535 + interrupt_count, 709 536 &irq_idx); 710 537 if (error) 711 538 return error; 712 539 } 713 540 } 714 541 715 - for (i = 0; i < BUCK_NB; i++) { 716 - if (buck_configured[i] == 1) 542 + for (i = 0; i < nr_buck; i++) { 543 + if (buck_configured[i]) 717 544 continue; 718 545 719 - rdev = devm_regulator_register(&pdev->dev, &buck_regs[i], &config); 546 + const struct regulator_desc *buck_cfg = (tps->chip_id == TPS65224) ? 547 + tps65224_buck_regs : buck_regs; 548 + 549 + rdev = devm_regulator_register(&pdev->dev, &buck_cfg[i], &config); 720 550 if (IS_ERR(rdev)) 721 551 return dev_err_probe(tps->dev, PTR_ERR(rdev), 722 - "failed to register %s regulator\n", 723 - pdev->name); 552 + "failed to register %s regulator\n", pdev->name); 724 553 725 554 error = tps6594_request_reg_irqs(pdev, rdev, irq_data, 726 - tps6594_bucks_irq_types[i], &irq_idx); 555 + bucks_irq_types[i], interrupt_count, &irq_idx); 727 556 if (error) 728 557 return error; 729 558 } 730 559 731 - /* LP8764 dosen't have LDO */ 560 + /* LP8764 doesn't have LDO */ 732 561 if (tps->chip_id != LP8764) { 733 - for (i = 0; i < ARRAY_SIZE(ldo_regs); i++) { 562 + for (i = 0; i < nr_ldo; i++) { 734 563 rdev = devm_regulator_register(&pdev->dev, &ldo_regs[i], &config); 735 564 if (IS_ERR(rdev)) 736 565 return dev_err_probe(tps->dev, PTR_ERR(rdev), ··· 746 559 pdev->name); 747 560 748 561 error = tps6594_request_reg_irqs(pdev, rdev, irq_data, 749 - tps6594_ldos_irq_types[i], 562 + ldos_irq_types[i], interrupt_count, 750 563 &irq_idx); 751 564 if (error) 752 565 return error; 753 566 } 754 567 } 755 568 756 - if (tps->chip_id == LP8764) 757 - ext_reg_irq_nb = ARRAY_SIZE(tps6594_ext_regulator_irq_types); 569 + if (tps->chip_id == TPS65224) { 570 + irq_types = tps65224_ext_regulator_irq_types; 571 + irq_count = ARRAY_SIZE(tps65224_ext_regulator_irq_types); 572 + } else { 573 + irq_types = tps6594_ext_regulator_irq_types; 574 + if (tps->chip_id == LP8764) 575 + irq_count = ARRAY_SIZE(tps6594_ext_regulator_irq_types); 576 + else 577 + /* TPS6593 supports only VCCA OV and UV */ 578 + irq_count = 2; 579 + } 758 580 759 581 irq_ext_reg_data = devm_kmalloc_array(tps->dev, 760 - ext_reg_irq_nb, 761 - sizeof(struct tps6594_ext_regulator_irq_data), 762 - GFP_KERNEL); 582 + irq_count, 583 + sizeof(struct tps6594_ext_regulator_irq_data), 584 + GFP_KERNEL); 763 585 if (!irq_ext_reg_data) 764 586 return -ENOMEM; 765 587 766 - for (i = 0; i < ext_reg_irq_nb; ++i) { 767 - irq_type = &tps6594_ext_regulator_irq_types[i]; 768 - 588 + for (i = 0; i < irq_count; ++i) { 589 + irq_type = &irq_types[i]; 769 590 irq = platform_get_irq_byname(pdev, irq_type->irq_name); 770 591 if (irq < 0) 771 592 return -EINVAL; ··· 805 610 806 611 MODULE_ALIAS("platform:tps6594-regulator"); 807 612 MODULE_AUTHOR("Jerome Neanne <jneanne@baylibre.com>"); 613 + MODULE_AUTHOR("Nirmala Devi Mal Nadar <m.nirmaladevi@ltts.com>"); 808 614 MODULE_DESCRIPTION("TPS6594 voltage regulator driver"); 809 615 MODULE_LICENSE("GPL");