1
1
// SPDX-License-Identifier: GPL-2.0
2
2
//
3
- // Driver for TPS65219 Integrated Power Management Integrated Chips (PMIC)
3
+ // Driver for TPS65215/ TPS65219 Power Management Integrated Chips (PMIC)
4
4
//
5
5
// Copyright (C) 2022 BayLibre Incorporated - https://www.baylibre.com/
6
+ // Copyright (C) 2024 Texas Instruments Incorporated - https://www.ti.com/
6
7
7
8
#include <linux/i2c.h>
8
9
#include <linux/reboot.h>
@@ -59,6 +60,46 @@ static const struct resource tps65219_pwrbutton_resources[] = {
59
60
DEFINE_RES_IRQ_NAMED (TPS65219_INT_PB_RISING_EDGE_DETECT , "rising" ),
60
61
};
61
62
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
+
62
103
static const struct resource tps65219_regulator_resources [] = {
63
104
DEFINE_RES_IRQ_NAMED (TPS65219_INT_LDO3_SCG , "LDO3_SCG" ),
64
105
DEFINE_RES_IRQ_NAMED (TPS65219_INT_LDO3_OC , "LDO3_OC" ),
@@ -109,6 +150,11 @@ static const struct resource tps65219_regulator_resources[] = {
109
150
DEFINE_RES_IRQ_NAMED (TPS65219_INT_SENSOR_0_HOT , "SENSOR_0_HOT" ),
110
151
};
111
152
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
+
112
158
static const struct mfd_cell tps65219_cells [] = {
113
159
MFD_CELL_RES ("tps65219-regulator" , tps65219_regulator_resources ),
114
160
MFD_CELL_NAME ("tps65219-gpio" ),
@@ -136,6 +182,8 @@ static unsigned int bit3_offsets[] = { TPS65219_REG_INT_BUCK_1_2_POS }; /* Buck
136
182
static unsigned int bit4_offsets [] = { TPS65219_REG_INT_BUCK_3_POS }; /* Buck 3 */
137
183
static unsigned int bit5_offsets [] = { TPS65219_REG_INT_LDO_1_2_POS }; /* LDO 1-2 */
138
184
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 };
139
187
static unsigned int bit7_offsets [] = { TPS65219_REG_INT_PB_POS }; /* Power Button */
140
188
141
189
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[] = {
149
197
REGMAP_IRQ_MAIN_REG_OFFSET (bit7_offsets ),
150
198
};
151
199
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
+
152
211
#define TPS65219_REGMAP_IRQ_REG (int_name , register_position ) \
153
212
REGMAP_IRQ_REG(int_name, register_position, int_name##_MASK)
154
213
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
+
155
256
static const struct regmap_irq tps65219_irqs [] = {
156
257
TPS65219_REGMAP_IRQ_REG (TPS65219_INT_LDO3_SCG , TPS65219_REG_INT_LDO_3_4_POS ),
157
258
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[] = {
204
305
TPS65219_REGMAP_IRQ_REG (TPS65219_INT_PB_RISING_EDGE_DETECT , TPS65219_REG_INT_PB_POS ),
205
306
};
206
307
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
+
207
322
static const struct regmap_irq_chip tps65219_irq_chip = {
208
323
.name = "tps65219_irq" ,
209
324
.main_status = TPS65219_REG_INT_SOURCE ,
@@ -218,9 +333,29 @@ static const struct regmap_irq_chip tps65219_irq_chip = {
218
333
.sub_reg_offsets = tps65219_sub_irq_offsets ,
219
334
};
220
335
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
+
221
355
static int tps65219_probe (struct i2c_client * client )
222
356
{
223
357
struct tps65219 * tps ;
358
+ struct tps65219_chip_data * pmic ;
224
359
bool pwr_button ;
225
360
int ret ;
226
361
@@ -231,6 +366,8 @@ static int tps65219_probe(struct i2c_client *client)
231
366
i2c_set_clientdata (client , tps );
232
367
233
368
tps -> dev = & client -> dev ;
369
+ tps -> chip_id = (uintptr_t )i2c_get_match_data (client );
370
+ pmic = & chip_info_table [tps -> chip_id ];
234
371
235
372
tps -> regmap = devm_regmap_init_i2c (client , & tps65219_regmap_config );
236
373
if (IS_ERR (tps -> regmap )) {
@@ -239,14 +376,14 @@ static int tps65219_probe(struct i2c_client *client)
239
376
return ret ;
240
377
}
241
378
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 ,
244
381
& tps -> irq_data );
245
382
if (ret )
246
383
return ret ;
247
384
248
385
ret = devm_mfd_add_devices (tps -> dev , PLATFORM_DEVID_AUTO ,
249
- tps65219_cells , ARRAY_SIZE ( tps65219_cells ) ,
386
+ pmic -> cells , pmic -> n_cells ,
250
387
NULL , 0 , regmap_irq_get_domain (tps -> irq_data ));
251
388
if (ret ) {
252
389
dev_err (tps -> dev , "Failed to add child devices: %d\n" , ret );
@@ -284,7 +421,8 @@ static int tps65219_probe(struct i2c_client *client)
284
421
}
285
422
286
423
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 , },
288
426
{}
289
427
};
290
428
MODULE_DEVICE_TABLE (of , of_tps65219_match_table );
@@ -299,5 +437,5 @@ static struct i2c_driver tps65219_driver = {
299
437
module_i2c_driver (tps65219_driver );
300
438
301
439
MODULE_AUTHOR (
"Jerome Neanne <[email protected] >" );
302
- MODULE_DESCRIPTION ("TPS65219 power management IC driver" );
440
+ MODULE_DESCRIPTION ("TPS65215/ TPS65219 PMIC driver" );
303
441
MODULE_LICENSE ("GPL" );
0 commit comments