Skip to content

Commit 7f9ed27

Browse files
shramamoorthylag-linaro
authored andcommitted
mfd: tps65219: Add support for TI TPS65215 PMIC
Use chip ID and chip_data struct to differentiate between devices in probe(). Add TPS65215 resource information. Update descriptions and copyright information to reflect the driver supports 2 PMIC devices. Signed-off-by: Shree Ramamoorthy <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Lee Jones <[email protected]>
1 parent 76b58d5 commit 7f9ed27

File tree

2 files changed

+209
-12
lines changed

2 files changed

+209
-12
lines changed

drivers/mfd/tps65219.c

Lines changed: 144 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
// SPDX-License-Identifier: GPL-2.0
22
//
3-
// Driver for TPS65219 Integrated Power Management Integrated Chips (PMIC)
3+
// Driver for TPS65215/TPS65219 Power Management Integrated Chips (PMIC)
44
//
55
// Copyright (C) 2022 BayLibre Incorporated - https://www.baylibre.com/
6+
// Copyright (C) 2024 Texas Instruments Incorporated - https://www.ti.com/
67

78
#include <linux/i2c.h>
89
#include <linux/reboot.h>
@@ -59,6 +60,46 @@ static const struct resource tps65219_pwrbutton_resources[] = {
5960
DEFINE_RES_IRQ_NAMED(TPS65219_INT_PB_RISING_EDGE_DETECT, "rising"),
6061
};
6162

63+
static const struct resource tps65215_regulator_resources[] = {
64+
DEFINE_RES_IRQ_NAMED(TPS65215_INT_LDO1_SCG, "LDO1_SCG"),
65+
DEFINE_RES_IRQ_NAMED(TPS65215_INT_LDO1_OC, "LDO1_OC"),
66+
DEFINE_RES_IRQ_NAMED(TPS65215_INT_LDO1_UV, "LDO1_UV"),
67+
DEFINE_RES_IRQ_NAMED(TPS65215_INT_LDO2_SCG, "LDO2_SCG"),
68+
DEFINE_RES_IRQ_NAMED(TPS65215_INT_LDO2_OC, "LDO2_OC"),
69+
DEFINE_RES_IRQ_NAMED(TPS65215_INT_LDO2_UV, "LDO2_UV"),
70+
DEFINE_RES_IRQ_NAMED(TPS65219_INT_BUCK3_SCG, "BUCK3_SCG"),
71+
DEFINE_RES_IRQ_NAMED(TPS65219_INT_BUCK3_OC, "BUCK3_OC"),
72+
DEFINE_RES_IRQ_NAMED(TPS65219_INT_BUCK3_NEG_OC, "BUCK3_NEG_OC"),
73+
DEFINE_RES_IRQ_NAMED(TPS65219_INT_BUCK3_UV, "BUCK3_UV"),
74+
DEFINE_RES_IRQ_NAMED(TPS65219_INT_BUCK1_SCG, "BUCK1_SCG"),
75+
DEFINE_RES_IRQ_NAMED(TPS65219_INT_BUCK1_OC, "BUCK1_OC"),
76+
DEFINE_RES_IRQ_NAMED(TPS65219_INT_BUCK1_NEG_OC, "BUCK1_NEG_OC"),
77+
DEFINE_RES_IRQ_NAMED(TPS65219_INT_BUCK1_UV, "BUCK1_UV"),
78+
DEFINE_RES_IRQ_NAMED(TPS65219_INT_BUCK2_SCG, "BUCK2_SCG"),
79+
DEFINE_RES_IRQ_NAMED(TPS65219_INT_BUCK2_OC, "BUCK2_OC"),
80+
DEFINE_RES_IRQ_NAMED(TPS65219_INT_BUCK2_NEG_OC, "BUCK2_NEG_OC"),
81+
DEFINE_RES_IRQ_NAMED(TPS65219_INT_BUCK2_UV, "BUCK2_UV"),
82+
DEFINE_RES_IRQ_NAMED(TPS65219_INT_BUCK1_RV, "BUCK1_RV"),
83+
DEFINE_RES_IRQ_NAMED(TPS65219_INT_BUCK2_RV, "BUCK2_RV"),
84+
DEFINE_RES_IRQ_NAMED(TPS65219_INT_BUCK3_RV, "BUCK3_RV"),
85+
DEFINE_RES_IRQ_NAMED(TPS65219_INT_LDO1_RV, "LDO1_RV"),
86+
DEFINE_RES_IRQ_NAMED(TPS65215_INT_LDO2_RV, "LDO2_RV"),
87+
DEFINE_RES_IRQ_NAMED(TPS65219_INT_BUCK1_RV_SD, "BUCK1_RV_SD"),
88+
DEFINE_RES_IRQ_NAMED(TPS65219_INT_BUCK2_RV_SD, "BUCK2_RV_SD"),
89+
DEFINE_RES_IRQ_NAMED(TPS65219_INT_BUCK3_RV_SD, "BUCK3_RV_SD"),
90+
DEFINE_RES_IRQ_NAMED(TPS65219_INT_LDO1_RV_SD, "LDO1_RV_SD"),
91+
DEFINE_RES_IRQ_NAMED(TPS65215_INT_LDO2_RV_SD, "LDO2_RV_SD"),
92+
DEFINE_RES_IRQ_NAMED(TPS65219_INT_TIMEOUT, "TIMEOUT"),
93+
DEFINE_RES_IRQ_NAMED(TPS65219_INT_SENSOR_3_WARM, "SENSOR_3_WARM"),
94+
DEFINE_RES_IRQ_NAMED(TPS65219_INT_SENSOR_2_WARM, "SENSOR_2_WARM"),
95+
DEFINE_RES_IRQ_NAMED(TPS65219_INT_SENSOR_1_WARM, "SENSOR_1_WARM"),
96+
DEFINE_RES_IRQ_NAMED(TPS65219_INT_SENSOR_0_WARM, "SENSOR_0_WARM"),
97+
DEFINE_RES_IRQ_NAMED(TPS65219_INT_SENSOR_3_HOT, "SENSOR_3_HOT"),
98+
DEFINE_RES_IRQ_NAMED(TPS65219_INT_SENSOR_2_HOT, "SENSOR_2_HOT"),
99+
DEFINE_RES_IRQ_NAMED(TPS65219_INT_SENSOR_1_HOT, "SENSOR_1_HOT"),
100+
DEFINE_RES_IRQ_NAMED(TPS65219_INT_SENSOR_0_HOT, "SENSOR_0_HOT"),
101+
};
102+
62103
static const struct resource tps65219_regulator_resources[] = {
63104
DEFINE_RES_IRQ_NAMED(TPS65219_INT_LDO3_SCG, "LDO3_SCG"),
64105
DEFINE_RES_IRQ_NAMED(TPS65219_INT_LDO3_OC, "LDO3_OC"),
@@ -109,6 +150,11 @@ static const struct resource tps65219_regulator_resources[] = {
109150
DEFINE_RES_IRQ_NAMED(TPS65219_INT_SENSOR_0_HOT, "SENSOR_0_HOT"),
110151
};
111152

153+
static const struct mfd_cell tps65215_cells[] = {
154+
MFD_CELL_RES("tps65215-regulator", tps65215_regulator_resources),
155+
MFD_CELL_NAME("tps65215-gpio"),
156+
};
157+
112158
static const struct mfd_cell tps65219_cells[] = {
113159
MFD_CELL_RES("tps65219-regulator", tps65219_regulator_resources),
114160
MFD_CELL_NAME("tps65219-gpio"),
@@ -136,6 +182,8 @@ static unsigned int bit3_offsets[] = { TPS65219_REG_INT_BUCK_1_2_POS }; /* Buck
136182
static unsigned int bit4_offsets[] = { TPS65219_REG_INT_BUCK_3_POS }; /* Buck 3 */
137183
static unsigned int bit5_offsets[] = { TPS65219_REG_INT_LDO_1_2_POS }; /* LDO 1-2 */
138184
static unsigned int bit6_offsets[] = { TPS65219_REG_INT_LDO_3_4_POS }; /* LDO 3-4 */
185+
static unsigned int tps65215_bit5_offsets[] = { TPS65215_REG_INT_LDO_1_POS };
186+
static unsigned int tps65215_bit6_offsets[] = { TPS65215_REG_INT_LDO_2_POS };
139187
static unsigned int bit7_offsets[] = { TPS65219_REG_INT_PB_POS }; /* Power Button */
140188

141189
static struct regmap_irq_sub_irq_map tps65219_sub_irq_offsets[] = {
@@ -149,9 +197,62 @@ static struct regmap_irq_sub_irq_map tps65219_sub_irq_offsets[] = {
149197
REGMAP_IRQ_MAIN_REG_OFFSET(bit7_offsets),
150198
};
151199

200+
static struct regmap_irq_sub_irq_map tps65215_sub_irq_offsets[] = {
201+
REGMAP_IRQ_MAIN_REG_OFFSET(bit0_offsets),
202+
REGMAP_IRQ_MAIN_REG_OFFSET(bit1_offsets),
203+
REGMAP_IRQ_MAIN_REG_OFFSET(bit2_offsets),
204+
REGMAP_IRQ_MAIN_REG_OFFSET(bit3_offsets),
205+
REGMAP_IRQ_MAIN_REG_OFFSET(bit4_offsets),
206+
REGMAP_IRQ_MAIN_REG_OFFSET(tps65215_bit5_offsets),
207+
REGMAP_IRQ_MAIN_REG_OFFSET(tps65215_bit6_offsets),
208+
REGMAP_IRQ_MAIN_REG_OFFSET(bit7_offsets),
209+
};
210+
152211
#define TPS65219_REGMAP_IRQ_REG(int_name, register_position) \
153212
REGMAP_IRQ_REG(int_name, register_position, int_name##_MASK)
154213

214+
static const struct regmap_irq tps65215_irqs[] = {
215+
TPS65219_REGMAP_IRQ_REG(TPS65215_INT_LDO1_SCG, TPS65215_REG_INT_LDO_1_POS),
216+
TPS65219_REGMAP_IRQ_REG(TPS65215_INT_LDO1_OC, TPS65215_REG_INT_LDO_1_POS),
217+
TPS65219_REGMAP_IRQ_REG(TPS65215_INT_LDO1_UV, TPS65215_REG_INT_LDO_1_POS),
218+
TPS65219_REGMAP_IRQ_REG(TPS65215_INT_LDO2_SCG, TPS65215_REG_INT_LDO_2_POS),
219+
TPS65219_REGMAP_IRQ_REG(TPS65215_INT_LDO2_OC, TPS65215_REG_INT_LDO_2_POS),
220+
TPS65219_REGMAP_IRQ_REG(TPS65215_INT_LDO2_UV, TPS65215_REG_INT_LDO_2_POS),
221+
TPS65219_REGMAP_IRQ_REG(TPS65219_INT_BUCK3_SCG, TPS65219_REG_INT_BUCK_3_POS),
222+
TPS65219_REGMAP_IRQ_REG(TPS65219_INT_BUCK3_OC, TPS65219_REG_INT_BUCK_3_POS),
223+
TPS65219_REGMAP_IRQ_REG(TPS65219_INT_BUCK3_NEG_OC, TPS65219_REG_INT_BUCK_3_POS),
224+
TPS65219_REGMAP_IRQ_REG(TPS65219_INT_BUCK3_UV, TPS65219_REG_INT_BUCK_3_POS),
225+
TPS65219_REGMAP_IRQ_REG(TPS65219_INT_BUCK2_SCG, TPS65219_REG_INT_BUCK_1_2_POS),
226+
TPS65219_REGMAP_IRQ_REG(TPS65219_INT_BUCK2_OC, TPS65219_REG_INT_BUCK_1_2_POS),
227+
TPS65219_REGMAP_IRQ_REG(TPS65219_INT_BUCK2_NEG_OC, TPS65219_REG_INT_BUCK_1_2_POS),
228+
TPS65219_REGMAP_IRQ_REG(TPS65219_INT_BUCK2_UV, TPS65219_REG_INT_BUCK_1_2_POS),
229+
TPS65219_REGMAP_IRQ_REG(TPS65219_INT_BUCK1_SCG, TPS65219_REG_INT_BUCK_1_2_POS),
230+
TPS65219_REGMAP_IRQ_REG(TPS65219_INT_BUCK1_OC, TPS65219_REG_INT_BUCK_1_2_POS),
231+
TPS65219_REGMAP_IRQ_REG(TPS65219_INT_BUCK1_NEG_OC, TPS65219_REG_INT_BUCK_1_2_POS),
232+
TPS65219_REGMAP_IRQ_REG(TPS65219_INT_BUCK1_UV, TPS65219_REG_INT_BUCK_1_2_POS),
233+
TPS65219_REGMAP_IRQ_REG(TPS65219_INT_SENSOR_3_WARM, TPS65219_REG_INT_SYS_POS),
234+
TPS65219_REGMAP_IRQ_REG(TPS65219_INT_SENSOR_2_WARM, TPS65219_REG_INT_SYS_POS),
235+
TPS65219_REGMAP_IRQ_REG(TPS65219_INT_SENSOR_1_WARM, TPS65219_REG_INT_SYS_POS),
236+
TPS65219_REGMAP_IRQ_REG(TPS65219_INT_SENSOR_0_WARM, TPS65219_REG_INT_SYS_POS),
237+
TPS65219_REGMAP_IRQ_REG(TPS65219_INT_SENSOR_3_HOT, TPS65219_REG_INT_SYS_POS),
238+
TPS65219_REGMAP_IRQ_REG(TPS65219_INT_SENSOR_2_HOT, TPS65219_REG_INT_SYS_POS),
239+
TPS65219_REGMAP_IRQ_REG(TPS65219_INT_SENSOR_1_HOT, TPS65219_REG_INT_SYS_POS),
240+
TPS65219_REGMAP_IRQ_REG(TPS65219_INT_SENSOR_0_HOT, TPS65219_REG_INT_SYS_POS),
241+
TPS65219_REGMAP_IRQ_REG(TPS65219_INT_BUCK1_RV, TPS65219_REG_INT_RV_POS),
242+
TPS65219_REGMAP_IRQ_REG(TPS65219_INT_BUCK2_RV, TPS65219_REG_INT_RV_POS),
243+
TPS65219_REGMAP_IRQ_REG(TPS65219_INT_BUCK3_RV, TPS65219_REG_INT_RV_POS),
244+
TPS65219_REGMAP_IRQ_REG(TPS65219_INT_LDO1_RV, TPS65219_REG_INT_RV_POS),
245+
TPS65219_REGMAP_IRQ_REG(TPS65215_INT_LDO2_RV, TPS65219_REG_INT_RV_POS),
246+
TPS65219_REGMAP_IRQ_REG(TPS65219_INT_BUCK1_RV_SD, TPS65219_REG_INT_TO_RV_POS),
247+
TPS65219_REGMAP_IRQ_REG(TPS65219_INT_BUCK2_RV_SD, TPS65219_REG_INT_TO_RV_POS),
248+
TPS65219_REGMAP_IRQ_REG(TPS65219_INT_BUCK3_RV_SD, TPS65219_REG_INT_TO_RV_POS),
249+
TPS65219_REGMAP_IRQ_REG(TPS65219_INT_LDO1_RV_SD, TPS65219_REG_INT_TO_RV_POS),
250+
TPS65219_REGMAP_IRQ_REG(TPS65215_INT_LDO2_RV_SD, TPS65219_REG_INT_TO_RV_POS),
251+
TPS65219_REGMAP_IRQ_REG(TPS65219_INT_TIMEOUT, TPS65219_REG_INT_TO_RV_POS),
252+
TPS65219_REGMAP_IRQ_REG(TPS65219_INT_PB_FALLING_EDGE_DETECT, TPS65219_REG_INT_PB_POS),
253+
TPS65219_REGMAP_IRQ_REG(TPS65219_INT_PB_RISING_EDGE_DETECT, TPS65219_REG_INT_PB_POS),
254+
};
255+
155256
static const struct regmap_irq tps65219_irqs[] = {
156257
TPS65219_REGMAP_IRQ_REG(TPS65219_INT_LDO3_SCG, TPS65219_REG_INT_LDO_3_4_POS),
157258
TPS65219_REGMAP_IRQ_REG(TPS65219_INT_LDO3_OC, TPS65219_REG_INT_LDO_3_4_POS),
@@ -204,6 +305,20 @@ static const struct regmap_irq tps65219_irqs[] = {
204305
TPS65219_REGMAP_IRQ_REG(TPS65219_INT_PB_RISING_EDGE_DETECT, TPS65219_REG_INT_PB_POS),
205306
};
206307

308+
static const struct regmap_irq_chip tps65215_irq_chip = {
309+
.name = "tps65215_irq",
310+
.main_status = TPS65219_REG_INT_SOURCE,
311+
.num_main_regs = 1,
312+
.num_main_status_bits = 8,
313+
.irqs = tps65215_irqs,
314+
.num_irqs = ARRAY_SIZE(tps65215_irqs),
315+
.status_base = TPS65215_REG_INT_LDO_2,
316+
.ack_base = TPS65215_REG_INT_LDO_2,
317+
.clear_ack = 1,
318+
.num_regs = 8,
319+
.sub_reg_offsets = tps65215_sub_irq_offsets,
320+
};
321+
207322
static const struct regmap_irq_chip tps65219_irq_chip = {
208323
.name = "tps65219_irq",
209324
.main_status = TPS65219_REG_INT_SOURCE,
@@ -218,9 +333,29 @@ static const struct regmap_irq_chip tps65219_irq_chip = {
218333
.sub_reg_offsets = tps65219_sub_irq_offsets,
219334
};
220335

336+
struct tps65219_chip_data {
337+
const struct regmap_irq_chip *irq_chip;
338+
const struct mfd_cell *cells;
339+
int n_cells;
340+
};
341+
342+
static struct tps65219_chip_data chip_info_table[] = {
343+
[TPS65215] = {
344+
.irq_chip = &tps65215_irq_chip,
345+
.cells = tps65215_cells,
346+
.n_cells = ARRAY_SIZE(tps65215_cells),
347+
},
348+
[TPS65219] = {
349+
.irq_chip = &tps65219_irq_chip,
350+
.cells = tps65219_cells,
351+
.n_cells = ARRAY_SIZE(tps65219_cells),
352+
},
353+
};
354+
221355
static int tps65219_probe(struct i2c_client *client)
222356
{
223357
struct tps65219 *tps;
358+
struct tps65219_chip_data *pmic;
224359
bool pwr_button;
225360
int ret;
226361

@@ -231,6 +366,8 @@ static int tps65219_probe(struct i2c_client *client)
231366
i2c_set_clientdata(client, tps);
232367

233368
tps->dev = &client->dev;
369+
tps->chip_id = (uintptr_t)i2c_get_match_data(client);
370+
pmic = &chip_info_table[tps->chip_id];
234371

235372
tps->regmap = devm_regmap_init_i2c(client, &tps65219_regmap_config);
236373
if (IS_ERR(tps->regmap)) {
@@ -239,14 +376,14 @@ static int tps65219_probe(struct i2c_client *client)
239376
return ret;
240377
}
241378

242-
ret = devm_regmap_add_irq_chip(&client->dev, tps->regmap, client->irq,
243-
IRQF_ONESHOT, 0, &tps65219_irq_chip,
379+
ret = devm_regmap_add_irq_chip(tps->dev, tps->regmap, client->irq,
380+
IRQF_ONESHOT, 0, pmic->irq_chip,
244381
&tps->irq_data);
245382
if (ret)
246383
return ret;
247384

248385
ret = devm_mfd_add_devices(tps->dev, PLATFORM_DEVID_AUTO,
249-
tps65219_cells, ARRAY_SIZE(tps65219_cells),
386+
pmic->cells, pmic->n_cells,
250387
NULL, 0, regmap_irq_get_domain(tps->irq_data));
251388
if (ret) {
252389
dev_err(tps->dev, "Failed to add child devices: %d\n", ret);
@@ -284,7 +421,8 @@ static int tps65219_probe(struct i2c_client *client)
284421
}
285422

286423
static const struct of_device_id of_tps65219_match_table[] = {
287-
{ .compatible = "ti,tps65219", },
424+
{ .compatible = "ti,tps65215", .data = (void *)TPS65215, },
425+
{ .compatible = "ti,tps65219", .data = (void *)TPS65219, },
288426
{}
289427
};
290428
MODULE_DEVICE_TABLE(of, of_tps65219_match_table);
@@ -299,5 +437,5 @@ static struct i2c_driver tps65219_driver = {
299437
module_i2c_driver(tps65219_driver);
300438

301439
MODULE_AUTHOR("Jerome Neanne <[email protected]>");
302-
MODULE_DESCRIPTION("TPS65219 power management IC driver");
440+
MODULE_DESCRIPTION("TPS65215/TPS65219 PMIC driver");
303441
MODULE_LICENSE("GPL");

0 commit comments

Comments
 (0)