Skip to content

Commit 0c1ff10

Browse files
committed
regulator: Merge tps6594 driver changes
This will be needed to add support for TPS652G1 which also has regulator dependencies.
2 parents 5054740 + d90171b commit 0c1ff10

File tree

7 files changed

+156
-20
lines changed

7 files changed

+156
-20
lines changed

Documentation/devicetree/bindings/mfd/ti,tps6594.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ properties:
2222
- ti,tps6593-q1
2323
- ti,tps6594-q1
2424
- ti,tps65224-q1
25+
- ti,tps652g1
2526

2627
reg:
2728
description: I2C slave address or SPI chip select number.

drivers/mfd/tps6594-core.c

Lines changed: 82 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
// SPDX-License-Identifier: GPL-2.0
22
/*
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
49
*
510
* Copyright (C) 2023 BayLibre Incorporated - https://www.baylibre.com/
611
*/
@@ -414,6 +419,61 @@ static const unsigned int tps65224_irq_reg[] = {
414419
TPS6594_REG_INT_FSM_ERR,
415420
};
416421

422+
/* TPS652G1 Resources */
423+
424+
static const struct mfd_cell tps652g1_common_cells[] = {
425+
MFD_CELL_RES("tps6594-pfsm", tps65224_pfsm_resources),
426+
MFD_CELL_RES("tps6594-pinctrl", tps65224_pinctrl_resources),
427+
MFD_CELL_NAME("tps6594-regulator"),
428+
};
429+
430+
static const struct regmap_irq tps652g1_irqs[] = {
431+
/* INT_GPIO register */
432+
REGMAP_IRQ_REG(TPS65224_IRQ_GPIO1, 2, TPS65224_BIT_GPIO1_INT),
433+
REGMAP_IRQ_REG(TPS65224_IRQ_GPIO2, 2, TPS65224_BIT_GPIO2_INT),
434+
REGMAP_IRQ_REG(TPS65224_IRQ_GPIO3, 2, TPS65224_BIT_GPIO3_INT),
435+
REGMAP_IRQ_REG(TPS65224_IRQ_GPIO4, 2, TPS65224_BIT_GPIO4_INT),
436+
REGMAP_IRQ_REG(TPS65224_IRQ_GPIO5, 2, TPS65224_BIT_GPIO5_INT),
437+
REGMAP_IRQ_REG(TPS65224_IRQ_GPIO6, 2, TPS65224_BIT_GPIO6_INT),
438+
439+
/* INT_STARTUP register */
440+
REGMAP_IRQ_REG(TPS65224_IRQ_VSENSE, 3, TPS65224_BIT_VSENSE_INT),
441+
REGMAP_IRQ_REG(TPS65224_IRQ_ENABLE, 3, TPS6594_BIT_ENABLE_INT),
442+
REGMAP_IRQ_REG(TPS65224_IRQ_PB_SHORT, 3, TPS65224_BIT_PB_SHORT_INT),
443+
REGMAP_IRQ_REG(TPS65224_IRQ_FSD, 3, TPS6594_BIT_FSD_INT),
444+
REGMAP_IRQ_REG(TPS65224_IRQ_SOFT_REBOOT, 3, TPS6594_BIT_SOFT_REBOOT_INT),
445+
446+
/* INT_MISC register */
447+
REGMAP_IRQ_REG(TPS65224_IRQ_BIST_PASS, 4, TPS6594_BIT_BIST_PASS_INT),
448+
REGMAP_IRQ_REG(TPS65224_IRQ_EXT_CLK, 4, TPS6594_BIT_EXT_CLK_INT),
449+
REGMAP_IRQ_REG(TPS65224_IRQ_REG_UNLOCK, 4, TPS65224_BIT_REG_UNLOCK_INT),
450+
REGMAP_IRQ_REG(TPS65224_IRQ_TWARN, 4, TPS6594_BIT_TWARN_INT),
451+
REGMAP_IRQ_REG(TPS65224_IRQ_PB_LONG, 4, TPS65224_BIT_PB_LONG_INT),
452+
REGMAP_IRQ_REG(TPS65224_IRQ_PB_FALL, 4, TPS65224_BIT_PB_FALL_INT),
453+
REGMAP_IRQ_REG(TPS65224_IRQ_PB_RISE, 4, TPS65224_BIT_PB_RISE_INT),
454+
REGMAP_IRQ_REG(TPS65224_IRQ_ADC_CONV_READY, 4, TPS65224_BIT_ADC_CONV_READY_INT),
455+
456+
/* INT_MODERATE_ERR register */
457+
REGMAP_IRQ_REG(TPS65224_IRQ_TSD_ORD, 5, TPS6594_BIT_TSD_ORD_INT),
458+
REGMAP_IRQ_REG(TPS65224_IRQ_BIST_FAIL, 5, TPS6594_BIT_BIST_FAIL_INT),
459+
REGMAP_IRQ_REG(TPS65224_IRQ_REG_CRC_ERR, 5, TPS6594_BIT_REG_CRC_ERR_INT),
460+
REGMAP_IRQ_REG(TPS65224_IRQ_RECOV_CNT, 5, TPS6594_BIT_RECOV_CNT_INT),
461+
462+
/* INT_SEVERE_ERR register */
463+
REGMAP_IRQ_REG(TPS65224_IRQ_TSD_IMM, 6, TPS6594_BIT_TSD_IMM_INT),
464+
REGMAP_IRQ_REG(TPS65224_IRQ_VCCA_OVP, 6, TPS6594_BIT_VCCA_OVP_INT),
465+
REGMAP_IRQ_REG(TPS65224_IRQ_PFSM_ERR, 6, TPS6594_BIT_PFSM_ERR_INT),
466+
REGMAP_IRQ_REG(TPS65224_IRQ_BG_XMON, 6, TPS65224_BIT_BG_XMON_INT),
467+
468+
/* INT_FSM_ERR register */
469+
REGMAP_IRQ_REG(TPS65224_IRQ_IMM_SHUTDOWN, 7, TPS6594_BIT_IMM_SHUTDOWN_INT),
470+
REGMAP_IRQ_REG(TPS65224_IRQ_ORD_SHUTDOWN, 7, TPS6594_BIT_ORD_SHUTDOWN_INT),
471+
REGMAP_IRQ_REG(TPS65224_IRQ_MCU_PWR_ERR, 7, TPS6594_BIT_MCU_PWR_ERR_INT),
472+
REGMAP_IRQ_REG(TPS65224_IRQ_SOC_PWR_ERR, 7, TPS6594_BIT_SOC_PWR_ERR_INT),
473+
REGMAP_IRQ_REG(TPS65224_IRQ_COMM_ERR, 7, TPS6594_BIT_COMM_ERR_INT),
474+
REGMAP_IRQ_REG(TPS65224_IRQ_I2C2_ERR, 7, TPS65224_BIT_I2C2_ERR_INT),
475+
};
476+
417477
static inline unsigned int tps6594_get_irq_reg(struct regmap_irq_chip_data *data,
418478
unsigned int base, int index)
419479
{
@@ -443,7 +503,7 @@ static int tps6594_handle_post_irq(void *irq_drv_data)
443503
* a new interrupt.
444504
*/
445505
if (tps->use_crc) {
446-
if (tps->chip_id == TPS65224) {
506+
if (tps->chip_id == TPS65224 || tps->chip_id == TPS652G1) {
447507
regmap_reg = TPS6594_REG_INT_FSM_ERR;
448508
mask_val = TPS6594_BIT_COMM_ERR_INT;
449509
} else {
@@ -481,6 +541,18 @@ static struct regmap_irq_chip tps65224_irq_chip = {
481541
.handle_post_irq = tps6594_handle_post_irq,
482542
};
483543

544+
static struct regmap_irq_chip tps652g1_irq_chip = {
545+
.ack_base = TPS6594_REG_INT_BUCK,
546+
.ack_invert = 1,
547+
.clear_ack = 1,
548+
.init_ack_masked = 1,
549+
.num_regs = ARRAY_SIZE(tps65224_irq_reg),
550+
.irqs = tps652g1_irqs,
551+
.num_irqs = ARRAY_SIZE(tps652g1_irqs),
552+
.get_irq_reg = tps65224_get_irq_reg,
553+
.handle_post_irq = tps6594_handle_post_irq,
554+
};
555+
484556
static const struct regmap_range tps6594_volatile_ranges[] = {
485557
regmap_reg_range(TPS6594_REG_INT_TOP, TPS6594_REG_STAT_READBACK_ERR),
486558
regmap_reg_range(TPS6594_REG_RTC_STATUS, TPS6594_REG_RTC_STATUS),
@@ -507,7 +579,7 @@ static int tps6594_check_crc_mode(struct tps6594 *tps, bool primary_pmic)
507579
int ret;
508580
unsigned int regmap_reg, mask_val;
509581

510-
if (tps->chip_id == TPS65224) {
582+
if (tps->chip_id == TPS65224 || tps->chip_id == TPS652G1) {
511583
regmap_reg = TPS6594_REG_CONFIG_2;
512584
mask_val = TPS65224_BIT_I2C1_SPI_CRC_EN;
513585
} else {
@@ -537,7 +609,7 @@ static int tps6594_set_crc_feature(struct tps6594 *tps)
537609
int ret;
538610
unsigned int regmap_reg, mask_val;
539611

540-
if (tps->chip_id == TPS65224) {
612+
if (tps->chip_id == TPS65224 || tps->chip_id == TPS652G1) {
541613
regmap_reg = TPS6594_REG_CONFIG_2;
542614
mask_val = TPS65224_BIT_I2C1_SPI_CRC_EN;
543615
} else {
@@ -628,6 +700,10 @@ int tps6594_device_init(struct tps6594 *tps, bool enable_crc)
628700
irq_chip = &tps65224_irq_chip;
629701
n_cells = ARRAY_SIZE(tps65224_common_cells);
630702
cells = tps65224_common_cells;
703+
} else if (tps->chip_id == TPS652G1) {
704+
irq_chip = &tps652g1_irq_chip;
705+
n_cells = ARRAY_SIZE(tps652g1_common_cells);
706+
cells = tps652g1_common_cells;
631707
} else {
632708
irq_chip = &tps6594_irq_chip;
633709
n_cells = ARRAY_SIZE(tps6594_common_cells);
@@ -651,8 +727,8 @@ int tps6594_device_init(struct tps6594 *tps, bool enable_crc)
651727
if (ret)
652728
return dev_err_probe(dev, ret, "Failed to add common child devices\n");
653729

654-
/* No RTC for LP8764 and TPS65224 */
655-
if (tps->chip_id != LP8764 && tps->chip_id != TPS65224) {
730+
/* No RTC for LP8764, TPS65224 and TPS652G1 */
731+
if (tps->chip_id != LP8764 && tps->chip_id != TPS65224 && tps->chip_id != TPS652G1) {
656732
ret = devm_mfd_add_devices(dev, PLATFORM_DEVID_AUTO, tps6594_rtc_cells,
657733
ARRAY_SIZE(tps6594_rtc_cells), NULL, 0,
658734
regmap_irq_get_domain(tps->irq_data));

drivers/mfd/tps6594-i2c.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
// SPDX-License-Identifier: GPL-2.0
22
/*
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
49
*
510
* Copyright (C) 2023 BayLibre Incorporated - https://www.baylibre.com/
611
*/
@@ -197,6 +202,7 @@ static const struct of_device_id tps6594_i2c_of_match_table[] = {
197202
{ .compatible = "ti,tps6593-q1", .data = (void *)TPS6593, },
198203
{ .compatible = "ti,lp8764-q1", .data = (void *)LP8764, },
199204
{ .compatible = "ti,tps65224-q1", .data = (void *)TPS65224, },
205+
{ .compatible = "ti,tps652g1", .data = (void *)TPS652G1, },
200206
{}
201207
};
202208
MODULE_DEVICE_TABLE(of, tps6594_i2c_of_match_table);
@@ -222,7 +228,7 @@ static int tps6594_i2c_probe(struct i2c_client *client)
222228
return dev_err_probe(dev, -EINVAL, "Failed to find matching chip ID\n");
223229
tps->chip_id = (unsigned long)match->data;
224230

225-
if (tps->chip_id == TPS65224)
231+
if (tps->chip_id == TPS65224 || tps->chip_id == TPS652G1)
226232
tps6594_i2c_regmap_config.volatile_table = &tps65224_volatile_table;
227233

228234
tps->regmap = devm_regmap_init(dev, NULL, client, &tps6594_i2c_regmap_config);

drivers/mfd/tps6594-spi.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
// SPDX-License-Identifier: GPL-2.0
22
/*
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
49
*
510
* Copyright (C) 2023 BayLibre Incorporated - https://www.baylibre.com/
611
*/
@@ -82,6 +87,7 @@ static const struct of_device_id tps6594_spi_of_match_table[] = {
8287
{ .compatible = "ti,tps6593-q1", .data = (void *)TPS6593, },
8388
{ .compatible = "ti,lp8764-q1", .data = (void *)LP8764, },
8489
{ .compatible = "ti,tps65224-q1", .data = (void *)TPS65224, },
90+
{ .compatible = "ti,tps652g1", .data = (void *)TPS652G1, },
8591
{}
8692
};
8793
MODULE_DEVICE_TABLE(of, tps6594_spi_of_match_table);
@@ -107,7 +113,7 @@ static int tps6594_spi_probe(struct spi_device *spi)
107113
return dev_err_probe(dev, -EINVAL, "Failed to find matching chip ID\n");
108114
tps->chip_id = (unsigned long)match->data;
109115

110-
if (tps->chip_id == TPS65224)
116+
if (tps->chip_id == TPS65224 || tps->chip_id == TPS652G1)
111117
tps6594_spi_regmap_config.volatile_table = &tps65224_volatile_table;
112118

113119
tps->regmap = devm_regmap_init(dev, NULL, spi, &tps6594_spi_regmap_config);

drivers/misc/tps6594-pfsm.c

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
// SPDX-License-Identifier: GPL-2.0
22
/*
3-
* PFSM (Pre-configurable Finite State Machine) driver for TI TPS65224/TPS6594/TPS6593/LP8764 PMICs
3+
* PFSM (Pre-configurable Finite State Machine) driver for the following
4+
* PMICs:
5+
* - LP8764
6+
* - TPS65224
7+
* - TPS652G1
8+
* - TPS6594
9+
* - TPS6593
410
*
511
* Copyright (C) 2023 BayLibre Incorporated - https://www.baylibre.com/
612
*/
@@ -141,7 +147,7 @@ static long tps6594_pfsm_ioctl(struct file *f, unsigned int cmd, unsigned long a
141147
switch (cmd) {
142148
case PMIC_GOTO_STANDBY:
143149
/* Disable LP mode on TPS6594 Family PMIC */
144-
if (pfsm->chip_id != TPS65224) {
150+
if (pfsm->chip_id != TPS65224 && pfsm->chip_id != TPS652G1) {
145151
ret = regmap_clear_bits(pfsm->regmap, TPS6594_REG_RTC_CTRL_2,
146152
TPS6594_BIT_LP_STANDBY_SEL);
147153

@@ -154,8 +160,8 @@ static long tps6594_pfsm_ioctl(struct file *f, unsigned int cmd, unsigned long a
154160
TPS6594_BIT_TRIGGER_I2C(0), TPS6594_BIT_TRIGGER_I2C(0));
155161
break;
156162
case PMIC_GOTO_LP_STANDBY:
157-
/* TPS65224 does not support LP STANDBY */
158-
if (pfsm->chip_id == TPS65224)
163+
/* TPS65224/TPS652G1 does not support LP STANDBY */
164+
if (pfsm->chip_id == TPS65224 || pfsm->chip_id == TPS652G1)
159165
return ret;
160166

161167
/* Enable LP mode */
@@ -179,8 +185,8 @@ static long tps6594_pfsm_ioctl(struct file *f, unsigned int cmd, unsigned long a
179185
TPS6594_BIT_NSLEEP1B | TPS6594_BIT_NSLEEP2B);
180186
break;
181187
case PMIC_SET_MCU_ONLY_STATE:
182-
/* TPS65224 does not support MCU_ONLY_STATE */
183-
if (pfsm->chip_id == TPS65224)
188+
/* TPS65224/TPS652G1 does not support MCU_ONLY_STATE */
189+
if (pfsm->chip_id == TPS65224 || pfsm->chip_id == TPS652G1)
184190
return ret;
185191

186192
if (copy_from_user(&state_opt, argp, sizeof(state_opt)))
@@ -206,7 +212,7 @@ static long tps6594_pfsm_ioctl(struct file *f, unsigned int cmd, unsigned long a
206212
return -EFAULT;
207213

208214
/* Configure wake-up destination */
209-
if (pfsm->chip_id == TPS65224) {
215+
if (pfsm->chip_id == TPS65224 || pfsm->chip_id == TPS652G1) {
210216
regmap_reg = TPS65224_REG_STARTUP_CTRL;
211217
mask = TPS65224_MASK_STARTUP_DEST;
212218
} else {
@@ -230,9 +236,14 @@ static long tps6594_pfsm_ioctl(struct file *f, unsigned int cmd, unsigned long a
230236
return ret;
231237

232238
/* Modify NSLEEP1-2 bits */
233-
ret = regmap_clear_bits(pfsm->regmap, TPS6594_REG_FSM_NSLEEP_TRIGGERS,
234-
pfsm->chip_id == TPS65224 ?
235-
TPS6594_BIT_NSLEEP1B : TPS6594_BIT_NSLEEP2B);
239+
if (pfsm->chip_id == TPS65224 || pfsm->chip_id == TPS652G1)
240+
ret = regmap_clear_bits(pfsm->regmap,
241+
TPS6594_REG_FSM_NSLEEP_TRIGGERS,
242+
TPS6594_BIT_NSLEEP1B);
243+
else
244+
ret = regmap_clear_bits(pfsm->regmap,
245+
TPS6594_REG_FSM_NSLEEP_TRIGGERS,
246+
TPS6594_BIT_NSLEEP2B);
236247
break;
237248
}
238249

drivers/pinctrl/pinctrl-tps6594.c

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,10 @@ static const char *const tps65224_nerr_mcu_func_group_names[] = {
226226
"GPIO5",
227227
};
228228

229+
static const char *const tps652g1_cs_spi_func_group_names[] = {
230+
"GPIO1",
231+
};
232+
229233
struct tps6594_pinctrl_function {
230234
struct pinfunction pinfunction;
231235
u8 muxval;
@@ -287,6 +291,18 @@ static const struct tps6594_pinctrl_function tps65224_pinctrl_functions[] = {
287291
FUNCTION(tps65224, nerr_mcu, TPS65224_PINCTRL_NERR_MCU_FUNCTION),
288292
};
289293

294+
static const struct tps6594_pinctrl_function tps652g1_pinctrl_functions[] = {
295+
FUNCTION(tps65224, gpio, TPS6594_PINCTRL_GPIO_FUNCTION),
296+
FUNCTION(tps65224, sda_i2c2_sdo_spi, TPS65224_PINCTRL_SDA_I2C2_SDO_SPI_FUNCTION),
297+
FUNCTION(tps65224, nsleep2, TPS65224_PINCTRL_NSLEEP2_FUNCTION),
298+
FUNCTION(tps65224, nint, TPS65224_PINCTRL_NINT_FUNCTION),
299+
FUNCTION(tps652g1, cs_spi, TPS65224_PINCTRL_SCL_I2C2_CS_SPI_FUNCTION),
300+
FUNCTION(tps65224, nsleep1, TPS65224_PINCTRL_NSLEEP1_FUNCTION),
301+
FUNCTION(tps65224, pb, TPS65224_PINCTRL_PB_FUNCTION),
302+
FUNCTION(tps65224, wkup, TPS65224_PINCTRL_WKUP_FUNCTION),
303+
FUNCTION(tps65224, syncclkin, TPS65224_PINCTRL_SYNCCLKIN_FUNCTION),
304+
};
305+
290306
struct tps6594_pinctrl {
291307
struct tps6594 *tps;
292308
struct gpio_regmap *gpio_regmap;
@@ -300,6 +316,16 @@ struct tps6594_pinctrl {
300316
struct muxval_remap *remap;
301317
};
302318

319+
static struct tps6594_pinctrl tps652g1_template_pinctrl = {
320+
.funcs = tps652g1_pinctrl_functions,
321+
.func_cnt = ARRAY_SIZE(tps652g1_pinctrl_functions),
322+
.pins = tps65224_pins,
323+
.num_pins = ARRAY_SIZE(tps65224_pins),
324+
.mux_sel_mask = TPS65224_MASK_GPIO_SEL,
325+
.remap = tps65224_muxval_remap,
326+
.remap_cnt = ARRAY_SIZE(tps65224_muxval_remap),
327+
};
328+
303329
static struct tps6594_pinctrl tps65224_template_pinctrl = {
304330
.funcs = tps65224_pinctrl_functions,
305331
.func_cnt = ARRAY_SIZE(tps65224_pinctrl_functions),
@@ -475,6 +501,15 @@ static int tps6594_pinctrl_probe(struct platform_device *pdev)
475501
return -ENOMEM;
476502

477503
switch (tps->chip_id) {
504+
case TPS652G1:
505+
pctrl_desc->pins = tps65224_pins;
506+
pctrl_desc->npins = ARRAY_SIZE(tps65224_pins);
507+
508+
*pinctrl = tps652g1_template_pinctrl;
509+
510+
config.ngpio = ARRAY_SIZE(tps65224_gpio_func_group_names);
511+
config.ngpio_per_reg = TPS65224_NGPIO_PER_REG;
512+
break;
478513
case TPS65224:
479514
pctrl_desc->pins = tps65224_pins;
480515
pctrl_desc->npins = ARRAY_SIZE(tps65224_pins);

include/linux/mfd/tps6594.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ enum pmic_id {
1919
TPS6593,
2020
LP8764,
2121
TPS65224,
22+
TPS652G1,
2223
};
2324

2425
/* Macro to get page index from register address */

0 commit comments

Comments
 (0)