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

mfd: tps6594: Add TI TPS652G1 support

The TPS652G1 is a stripped down version of the TPS65224. From a software
point of view, it lacks any voltage monitoring, the watchdog, the ESM
and the ADC.

Signed-off-by: Michael Walle <mwalle@kernel.org>
Link: https://lore.kernel.org/r/20250613114518.1772109-2-mwalle@kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>

authored by

Michael Walle and committed by
Lee Jones
626bb0a4 19272b37

+99 -10
+82 -6
drivers/mfd/tps6594-core.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 2 2 /* 3 - * Core functions for TI TPS65224/TPS6594/TPS6593/LP8764 PMICs 3 + * Core functions for following TI PMICs: 4 + * - LP8764 5 + * - TPS65224 6 + * - TPS652G1 7 + * - TPS6593 8 + * - TPS6594 4 9 * 5 10 * Copyright (C) 2023 BayLibre Incorporated - https://www.baylibre.com/ 6 11 */ ··· 419 414 TPS6594_REG_INT_FSM_ERR, 420 415 }; 421 416 417 + /* TPS652G1 Resources */ 418 + 419 + static const struct mfd_cell tps652g1_common_cells[] = { 420 + MFD_CELL_RES("tps6594-pfsm", tps65224_pfsm_resources), 421 + MFD_CELL_RES("tps6594-pinctrl", tps65224_pinctrl_resources), 422 + MFD_CELL_NAME("tps6594-regulator"), 423 + }; 424 + 425 + static const struct regmap_irq tps652g1_irqs[] = { 426 + /* INT_GPIO register */ 427 + REGMAP_IRQ_REG(TPS65224_IRQ_GPIO1, 2, TPS65224_BIT_GPIO1_INT), 428 + REGMAP_IRQ_REG(TPS65224_IRQ_GPIO2, 2, TPS65224_BIT_GPIO2_INT), 429 + REGMAP_IRQ_REG(TPS65224_IRQ_GPIO3, 2, TPS65224_BIT_GPIO3_INT), 430 + REGMAP_IRQ_REG(TPS65224_IRQ_GPIO4, 2, TPS65224_BIT_GPIO4_INT), 431 + REGMAP_IRQ_REG(TPS65224_IRQ_GPIO5, 2, TPS65224_BIT_GPIO5_INT), 432 + REGMAP_IRQ_REG(TPS65224_IRQ_GPIO6, 2, TPS65224_BIT_GPIO6_INT), 433 + 434 + /* INT_STARTUP register */ 435 + REGMAP_IRQ_REG(TPS65224_IRQ_VSENSE, 3, TPS65224_BIT_VSENSE_INT), 436 + REGMAP_IRQ_REG(TPS65224_IRQ_ENABLE, 3, TPS6594_BIT_ENABLE_INT), 437 + REGMAP_IRQ_REG(TPS65224_IRQ_PB_SHORT, 3, TPS65224_BIT_PB_SHORT_INT), 438 + REGMAP_IRQ_REG(TPS65224_IRQ_FSD, 3, TPS6594_BIT_FSD_INT), 439 + REGMAP_IRQ_REG(TPS65224_IRQ_SOFT_REBOOT, 3, TPS6594_BIT_SOFT_REBOOT_INT), 440 + 441 + /* INT_MISC register */ 442 + REGMAP_IRQ_REG(TPS65224_IRQ_BIST_PASS, 4, TPS6594_BIT_BIST_PASS_INT), 443 + REGMAP_IRQ_REG(TPS65224_IRQ_EXT_CLK, 4, TPS6594_BIT_EXT_CLK_INT), 444 + REGMAP_IRQ_REG(TPS65224_IRQ_REG_UNLOCK, 4, TPS65224_BIT_REG_UNLOCK_INT), 445 + REGMAP_IRQ_REG(TPS65224_IRQ_TWARN, 4, TPS6594_BIT_TWARN_INT), 446 + REGMAP_IRQ_REG(TPS65224_IRQ_PB_LONG, 4, TPS65224_BIT_PB_LONG_INT), 447 + REGMAP_IRQ_REG(TPS65224_IRQ_PB_FALL, 4, TPS65224_BIT_PB_FALL_INT), 448 + REGMAP_IRQ_REG(TPS65224_IRQ_PB_RISE, 4, TPS65224_BIT_PB_RISE_INT), 449 + REGMAP_IRQ_REG(TPS65224_IRQ_ADC_CONV_READY, 4, TPS65224_BIT_ADC_CONV_READY_INT), 450 + 451 + /* INT_MODERATE_ERR register */ 452 + REGMAP_IRQ_REG(TPS65224_IRQ_TSD_ORD, 5, TPS6594_BIT_TSD_ORD_INT), 453 + REGMAP_IRQ_REG(TPS65224_IRQ_BIST_FAIL, 5, TPS6594_BIT_BIST_FAIL_INT), 454 + REGMAP_IRQ_REG(TPS65224_IRQ_REG_CRC_ERR, 5, TPS6594_BIT_REG_CRC_ERR_INT), 455 + REGMAP_IRQ_REG(TPS65224_IRQ_RECOV_CNT, 5, TPS6594_BIT_RECOV_CNT_INT), 456 + 457 + /* INT_SEVERE_ERR register */ 458 + REGMAP_IRQ_REG(TPS65224_IRQ_TSD_IMM, 6, TPS6594_BIT_TSD_IMM_INT), 459 + REGMAP_IRQ_REG(TPS65224_IRQ_VCCA_OVP, 6, TPS6594_BIT_VCCA_OVP_INT), 460 + REGMAP_IRQ_REG(TPS65224_IRQ_PFSM_ERR, 6, TPS6594_BIT_PFSM_ERR_INT), 461 + REGMAP_IRQ_REG(TPS65224_IRQ_BG_XMON, 6, TPS65224_BIT_BG_XMON_INT), 462 + 463 + /* INT_FSM_ERR register */ 464 + REGMAP_IRQ_REG(TPS65224_IRQ_IMM_SHUTDOWN, 7, TPS6594_BIT_IMM_SHUTDOWN_INT), 465 + REGMAP_IRQ_REG(TPS65224_IRQ_ORD_SHUTDOWN, 7, TPS6594_BIT_ORD_SHUTDOWN_INT), 466 + REGMAP_IRQ_REG(TPS65224_IRQ_MCU_PWR_ERR, 7, TPS6594_BIT_MCU_PWR_ERR_INT), 467 + REGMAP_IRQ_REG(TPS65224_IRQ_SOC_PWR_ERR, 7, TPS6594_BIT_SOC_PWR_ERR_INT), 468 + REGMAP_IRQ_REG(TPS65224_IRQ_COMM_ERR, 7, TPS6594_BIT_COMM_ERR_INT), 469 + REGMAP_IRQ_REG(TPS65224_IRQ_I2C2_ERR, 7, TPS65224_BIT_I2C2_ERR_INT), 470 + }; 471 + 422 472 static inline unsigned int tps6594_get_irq_reg(struct regmap_irq_chip_data *data, 423 473 unsigned int base, int index) 424 474 { ··· 503 443 * a new interrupt. 504 444 */ 505 445 if (tps->use_crc) { 506 - if (tps->chip_id == TPS65224) { 446 + if (tps->chip_id == TPS65224 || tps->chip_id == TPS652G1) { 507 447 regmap_reg = TPS6594_REG_INT_FSM_ERR; 508 448 mask_val = TPS6594_BIT_COMM_ERR_INT; 509 449 } else { ··· 541 481 .handle_post_irq = tps6594_handle_post_irq, 542 482 }; 543 483 484 + static struct regmap_irq_chip tps652g1_irq_chip = { 485 + .ack_base = TPS6594_REG_INT_BUCK, 486 + .ack_invert = 1, 487 + .clear_ack = 1, 488 + .init_ack_masked = 1, 489 + .num_regs = ARRAY_SIZE(tps65224_irq_reg), 490 + .irqs = tps652g1_irqs, 491 + .num_irqs = ARRAY_SIZE(tps652g1_irqs), 492 + .get_irq_reg = tps65224_get_irq_reg, 493 + .handle_post_irq = tps6594_handle_post_irq, 494 + }; 495 + 544 496 static const struct regmap_range tps6594_volatile_ranges[] = { 545 497 regmap_reg_range(TPS6594_REG_INT_TOP, TPS6594_REG_STAT_READBACK_ERR), 546 498 regmap_reg_range(TPS6594_REG_RTC_STATUS, TPS6594_REG_RTC_STATUS), ··· 579 507 int ret; 580 508 unsigned int regmap_reg, mask_val; 581 509 582 - if (tps->chip_id == TPS65224) { 510 + if (tps->chip_id == TPS65224 || tps->chip_id == TPS652G1) { 583 511 regmap_reg = TPS6594_REG_CONFIG_2; 584 512 mask_val = TPS65224_BIT_I2C1_SPI_CRC_EN; 585 513 } else { ··· 609 537 int ret; 610 538 unsigned int regmap_reg, mask_val; 611 539 612 - if (tps->chip_id == TPS65224) { 540 + if (tps->chip_id == TPS65224 || tps->chip_id == TPS652G1) { 613 541 regmap_reg = TPS6594_REG_CONFIG_2; 614 542 mask_val = TPS65224_BIT_I2C1_SPI_CRC_EN; 615 543 } else { ··· 700 628 irq_chip = &tps65224_irq_chip; 701 629 n_cells = ARRAY_SIZE(tps65224_common_cells); 702 630 cells = tps65224_common_cells; 631 + } else if (tps->chip_id == TPS652G1) { 632 + irq_chip = &tps652g1_irq_chip; 633 + n_cells = ARRAY_SIZE(tps652g1_common_cells); 634 + cells = tps652g1_common_cells; 703 635 } else { 704 636 irq_chip = &tps6594_irq_chip; 705 637 n_cells = ARRAY_SIZE(tps6594_common_cells); ··· 727 651 if (ret) 728 652 return dev_err_probe(dev, ret, "Failed to add common child devices\n"); 729 653 730 - /* No RTC for LP8764 and TPS65224 */ 731 - if (tps->chip_id != LP8764 && tps->chip_id != TPS65224) { 654 + /* No RTC for LP8764, TPS65224 and TPS652G1 */ 655 + if (tps->chip_id != LP8764 && tps->chip_id != TPS65224 && tps->chip_id != TPS652G1) { 732 656 ret = devm_mfd_add_devices(dev, PLATFORM_DEVID_AUTO, tps6594_rtc_cells, 733 657 ARRAY_SIZE(tps6594_rtc_cells), NULL, 0, 734 658 regmap_irq_get_domain(tps->irq_data));
+8 -2
drivers/mfd/tps6594-i2c.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 2 2 /* 3 - * I2C access driver for TI TPS65224/TPS6594/TPS6593/LP8764 PMICs 3 + * I2C access driver for the following TI PMICs: 4 + * - LP8764 5 + * - TPS65224 6 + * - TPS652G1 7 + * - TPS6593 8 + * - TPS6594 4 9 * 5 10 * Copyright (C) 2023 BayLibre Incorporated - https://www.baylibre.com/ 6 11 */ ··· 202 197 { .compatible = "ti,tps6593-q1", .data = (void *)TPS6593, }, 203 198 { .compatible = "ti,lp8764-q1", .data = (void *)LP8764, }, 204 199 { .compatible = "ti,tps65224-q1", .data = (void *)TPS65224, }, 200 + { .compatible = "ti,tps652g1", .data = (void *)TPS652G1, }, 205 201 {} 206 202 }; 207 203 MODULE_DEVICE_TABLE(of, tps6594_i2c_of_match_table); ··· 228 222 return dev_err_probe(dev, -EINVAL, "Failed to find matching chip ID\n"); 229 223 tps->chip_id = (unsigned long)match->data; 230 224 231 - if (tps->chip_id == TPS65224) 225 + if (tps->chip_id == TPS65224 || tps->chip_id == TPS652G1) 232 226 tps6594_i2c_regmap_config.volatile_table = &tps65224_volatile_table; 233 227 234 228 tps->regmap = devm_regmap_init(dev, NULL, client, &tps6594_i2c_regmap_config);
+8 -2
drivers/mfd/tps6594-spi.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 2 2 /* 3 - * SPI access driver for TI TPS65224/TPS6594/TPS6593/LP8764 PMICs 3 + * SPI access driver for the following TI PMICs: 4 + * - LP8764 5 + * - TPS65224 6 + * - TPS652G1 7 + * - TPS6593 8 + * - TPS6594 4 9 * 5 10 * Copyright (C) 2023 BayLibre Incorporated - https://www.baylibre.com/ 6 11 */ ··· 87 82 { .compatible = "ti,tps6593-q1", .data = (void *)TPS6593, }, 88 83 { .compatible = "ti,lp8764-q1", .data = (void *)LP8764, }, 89 84 { .compatible = "ti,tps65224-q1", .data = (void *)TPS65224, }, 85 + { .compatible = "ti,tps652g1", .data = (void *)TPS652G1, }, 90 86 {} 91 87 }; 92 88 MODULE_DEVICE_TABLE(of, tps6594_spi_of_match_table); ··· 113 107 return dev_err_probe(dev, -EINVAL, "Failed to find matching chip ID\n"); 114 108 tps->chip_id = (unsigned long)match->data; 115 109 116 - if (tps->chip_id == TPS65224) 110 + if (tps->chip_id == TPS65224 || tps->chip_id == TPS652G1) 117 111 tps6594_spi_regmap_config.volatile_table = &tps65224_volatile_table; 118 112 119 113 tps->regmap = devm_regmap_init(dev, NULL, spi, &tps6594_spi_regmap_config);
+1
include/linux/mfd/tps6594.h
··· 19 19 TPS6593, 20 20 LP8764, 21 21 TPS65224, 22 + TPS652G1, 22 23 }; 23 24 24 25 /* Macro to get page index from register address */