1
1
// SPDX-License-Identifier: GPL-2.0
2
2
//
3
- // tps65219-regulator.c
4
- //
5
- // Regulator driver for TPS65219 PMIC
3
+ // Regulator driver for TPS65215/TPS65219 PMIC
6
4
//
7
5
// Copyright (C) 2022 BayLibre Incorporated - https://www.baylibre.com/
6
+ // Copyright (C) 2024 Texas Instruments Incorporated - https://www.ti.com/
8
7
//
9
8
// This implementation derived from tps65218 authored by
10
9
// "J Keerthy <j-keerthy@ti.com>"
@@ -130,6 +129,11 @@ static const struct linear_range ldo_1_range[] = {
130
129
REGULATOR_LINEAR_RANGE (3400000 , 0x38 , 0x3f , 0 ),
131
130
};
132
131
132
+ static const struct linear_range tps65215_ldo_2_range [] = {
133
+ REGULATOR_LINEAR_RANGE (1200000 , 0x0 , 0xC , 50000 ),
134
+ REGULATOR_LINEAR_RANGE (3300000 , 0x36 , 0x3F , 0 ),
135
+ };
136
+
133
137
static const struct linear_range tps65219_ldo_2_range [] = {
134
138
REGULATOR_LINEAR_RANGE (600000 , 0x0 , 0x37 , 50000 ),
135
139
REGULATOR_LINEAR_RANGE (3400000 , 0x38 , 0x3f , 0 ),
@@ -221,7 +225,7 @@ static const struct regulator_ops ldos_3_4_ops = {
221
225
.map_voltage = regulator_map_voltage_linear_range ,
222
226
};
223
227
224
- static const struct regulator_desc regulators [] = {
228
+ static const struct regulator_desc common_regs [] = {
225
229
TPS65219_REGULATOR ("BUCK1" , "buck1" , TPS65219_BUCK_1 ,
226
230
REGULATOR_VOLTAGE , bucks_ops , 64 ,
227
231
TPS65219_REG_BUCK1_VOUT ,
@@ -250,6 +254,20 @@ static const struct regulator_desc regulators[] = {
250
254
TPS65219_REG_ENABLE_CTRL ,
251
255
TPS65219_ENABLE_LDO1_EN_MASK , 0 , 0 , ldo_1_range ,
252
256
2 , 0 , 0 , NULL , 0 , TPS65219_LDOS_BYP_CONFIG_MASK ),
257
+ };
258
+
259
+ static const struct regulator_desc tps65215_regs [] = {
260
+ // TPS65215's LDO2 is the same as TPS65219's LDO3
261
+ TPS65219_REGULATOR ("LDO2" , "ldo2" , TPS65215_LDO_2 ,
262
+ REGULATOR_VOLTAGE , ldos_3_4_ops , 64 ,
263
+ TPS65215_REG_LDO2_VOUT ,
264
+ TPS65219_BUCKS_LDOS_VOUT_VSET_MASK ,
265
+ TPS65219_REG_ENABLE_CTRL ,
266
+ TPS65215_ENABLE_LDO2_EN_MASK , 0 , 0 , tps65215_ldo_2_range ,
267
+ 3 , 0 , 0 , NULL , 0 , 0 ),
268
+ };
269
+
270
+ static const struct regulator_desc tps65219_regs [] = {
253
271
TPS65219_REGULATOR ("LDO2" , "ldo2" , TPS65219_LDO_2 ,
254
272
REGULATOR_VOLTAGE , ldos_1_2_ops , 64 ,
255
273
TPS65219_REG_LDO2_VOUT ,
@@ -292,28 +310,65 @@ static irqreturn_t tps65219_regulator_irq_handler(int irq, void *data)
292
310
return IRQ_HANDLED ;
293
311
}
294
312
313
+ struct tps65219_chip_data {
314
+ size_t rdesc_size ;
315
+ size_t common_rdesc_size ;
316
+ const struct regulator_desc * rdesc ;
317
+ const struct regulator_desc * common_rdesc ;
318
+ };
319
+
320
+ static struct tps65219_chip_data chip_info_table [] = {
321
+ [TPS65215 ] = {
322
+ .rdesc = tps65215_regs ,
323
+ .rdesc_size = ARRAY_SIZE (tps65215_regs ),
324
+ .common_rdesc = common_regs ,
325
+ .common_rdesc_size = ARRAY_SIZE (common_regs ),
326
+ },
327
+ [TPS65219 ] = {
328
+ .rdesc = tps65219_regs ,
329
+ .rdesc_size = ARRAY_SIZE (tps65219_regs ),
330
+ .common_rdesc = common_regs ,
331
+ .common_rdesc_size = ARRAY_SIZE (common_regs ),
332
+ },
333
+ };
334
+
295
335
static int tps65219_regulator_probe (struct platform_device * pdev )
296
336
{
297
- struct tps65219 * tps = dev_get_drvdata (pdev -> dev .parent );
337
+ struct tps65219_regulator_irq_data * irq_data ;
338
+ struct tps65219_regulator_irq_type * irq_type ;
339
+
340
+ struct tps65219_chip_data * pmic ;
298
341
struct regulator_dev * rdev ;
299
- struct regulator_config config = { };
300
- int i ;
301
342
int error ;
302
343
int irq ;
303
- struct tps65219_regulator_irq_data * irq_data ;
304
- struct tps65219_regulator_irq_type * irq_type ;
344
+ int i ;
345
+
346
+ struct tps65219 * tps = dev_get_drvdata (pdev -> dev .parent );
347
+ struct regulator_config config = { };
348
+ enum pmic_id chip = platform_get_device_id (pdev )-> driver_data ;
349
+
350
+ pmic = & chip_info_table [chip ];
305
351
306
352
config .dev = tps -> dev ;
307
353
config .driver_data = tps ;
308
354
config .regmap = tps -> regmap ;
309
355
310
- for (i = 0 ; i < ARRAY_SIZE (regulators ); i ++ ) {
311
- rdev = devm_regulator_register (& pdev -> dev , & regulators [i ],
356
+ for (i = 0 ; i < pmic -> common_rdesc_size ; i ++ ) {
357
+ rdev = devm_regulator_register (& pdev -> dev , & pmic -> common_rdesc [i ],
358
+ & config );
359
+ if (IS_ERR (rdev ))
360
+ return dev_err_probe (tps -> dev , PTR_ERR (rdev ),
361
+ "Failed to register %s regulator\n" ,
362
+ pmic -> common_rdesc [i ].name );
363
+ }
364
+
365
+ for (i = 0 ; i < pmic -> rdesc_size ; i ++ ) {
366
+ rdev = devm_regulator_register (& pdev -> dev , & pmic -> rdesc [i ],
312
367
& config );
313
368
if (IS_ERR (rdev ))
314
369
return dev_err_probe (tps -> dev , PTR_ERR (rdev ),
315
- "Failed to register %s regulator\n" ,
316
- regulators [i ].name );
370
+ "Failed to register %s regulator\n" ,
371
+ pmic -> rdesc [i ].name );
317
372
}
318
373
319
374
irq_data = devm_kmalloc (tps -> dev ,
@@ -349,7 +404,8 @@ static int tps65219_regulator_probe(struct platform_device *pdev)
349
404
}
350
405
351
406
static const struct platform_device_id tps65219_regulator_id_table [] = {
352
- { "tps65219-regulator" , },
407
+ { "tps65215-regulator" , TPS65215 },
408
+ { "tps65219-regulator" , TPS65219 },
353
409
{ /* sentinel */ }
354
410
};
355
411
MODULE_DEVICE_TABLE (platform , tps65219_regulator_id_table );
@@ -366,5 +422,5 @@ static struct platform_driver tps65219_regulator_driver = {
366
422
module_platform_driver (tps65219_regulator_driver );
367
423
368
424
MODULE_AUTHOR ("Jerome Neanne <j-neanne@baylibre.com>" );
369
- MODULE_DESCRIPTION ("TPS65219 voltage regulator driver" );
425
+ MODULE_DESCRIPTION ("TPS65215/ TPS65219 voltage regulator driver" );
370
426
MODULE_LICENSE ("GPL" );
0 commit comments