@@ -36,6 +36,14 @@ static struct tps65219_regulator_irq_type tps65219_regulator_irq_types[] = {
36
36
{ "LDO4_SCG" , "LDO4" , "short circuit to ground" , REGULATOR_EVENT_REGULATION_OUT },
37
37
{ "LDO4_OC" , "LDO4" , "overcurrent" , REGULATOR_EVENT_OVER_CURRENT },
38
38
{ "LDO4_UV" , "LDO4" , "undervoltage" , REGULATOR_EVENT_UNDER_VOLTAGE },
39
+ { "LDO3_RV" , "LDO3" , "residual voltage" , REGULATOR_EVENT_OVER_VOLTAGE_WARN },
40
+ { "LDO4_RV" , "LDO4" , "residual voltage" , REGULATOR_EVENT_OVER_VOLTAGE_WARN },
41
+ { "LDO3_RV_SD" , "LDO3" , "residual voltage on shutdown" , REGULATOR_EVENT_OVER_VOLTAGE_WARN },
42
+ { "LDO4_RV_SD" , "LDO4" , "residual voltage on shutdown" , REGULATOR_EVENT_OVER_VOLTAGE_WARN },
43
+ };
44
+
45
+ /* All of TPS65215's irq types are the same as common_regulator_irq_types */
46
+ static struct tps65219_regulator_irq_type common_regulator_irq_types [] = {
39
47
{ "LDO1_SCG" , "LDO1" , "short circuit to ground" , REGULATOR_EVENT_REGULATION_OUT },
40
48
{ "LDO1_OC" , "LDO1" , "overcurrent" , REGULATOR_EVENT_OVER_CURRENT },
41
49
{ "LDO1_UV" , "LDO1" , "undervoltage" , REGULATOR_EVENT_UNDER_VOLTAGE },
@@ -59,8 +67,6 @@ static struct tps65219_regulator_irq_type tps65219_regulator_irq_types[] = {
59
67
{ "BUCK3_RV" , "BUCK3" , "residual voltage" , REGULATOR_EVENT_OVER_VOLTAGE_WARN },
60
68
{ "LDO1_RV" , "LDO1" , "residual voltage" , REGULATOR_EVENT_OVER_VOLTAGE_WARN },
61
69
{ "LDO2_RV" , "LDO2" , "residual voltage" , REGULATOR_EVENT_OVER_VOLTAGE_WARN },
62
- { "LDO3_RV" , "LDO3" , "residual voltage" , REGULATOR_EVENT_OVER_VOLTAGE_WARN },
63
- { "LDO4_RV" , "LDO4" , "residual voltage" , REGULATOR_EVENT_OVER_VOLTAGE_WARN },
64
70
{ "BUCK1_RV_SD" , "BUCK1" , "residual voltage on shutdown" ,
65
71
REGULATOR_EVENT_OVER_VOLTAGE_WARN },
66
72
{ "BUCK2_RV_SD" , "BUCK2" , "residual voltage on shutdown" ,
@@ -69,8 +75,6 @@ static struct tps65219_regulator_irq_type tps65219_regulator_irq_types[] = {
69
75
REGULATOR_EVENT_OVER_VOLTAGE_WARN },
70
76
{ "LDO1_RV_SD" , "LDO1" , "residual voltage on shutdown" , REGULATOR_EVENT_OVER_VOLTAGE_WARN },
71
77
{ "LDO2_RV_SD" , "LDO2" , "residual voltage on shutdown" , REGULATOR_EVENT_OVER_VOLTAGE_WARN },
72
- { "LDO3_RV_SD" , "LDO3" , "residual voltage on shutdown" , REGULATOR_EVENT_OVER_VOLTAGE_WARN },
73
- { "LDO4_RV_SD" , "LDO4" , "residual voltage on shutdown" , REGULATOR_EVENT_OVER_VOLTAGE_WARN },
74
78
{ "SENSOR_3_WARM" , "SENSOR3" , "warm temperature" , REGULATOR_EVENT_OVER_TEMP_WARN },
75
79
{ "SENSOR_2_WARM" , "SENSOR2" , "warm temperature" , REGULATOR_EVENT_OVER_TEMP_WARN },
76
80
{ "SENSOR_1_WARM" , "SENSOR1" , "warm temperature" , REGULATOR_EVENT_OVER_TEMP_WARN },
@@ -264,7 +268,7 @@ static const struct regulator_desc tps65215_regs[] = {
264
268
TPS65219_BUCKS_LDOS_VOUT_VSET_MASK ,
265
269
TPS65219_REG_ENABLE_CTRL ,
266
270
TPS65215_ENABLE_LDO2_EN_MASK , 0 , 0 , tps65215_ldo_2_range ,
267
- 3 , 0 , 0 , NULL , 0 , 0 ),
271
+ 2 , 0 , 0 , NULL , 0 , 0 ),
268
272
};
269
273
270
274
static const struct regulator_desc tps65219_regs [] = {
@@ -313,8 +317,12 @@ static irqreturn_t tps65219_regulator_irq_handler(int irq, void *data)
313
317
struct tps65219_chip_data {
314
318
size_t rdesc_size ;
315
319
size_t common_rdesc_size ;
320
+ size_t dev_irq_size ;
321
+ size_t common_irq_size ;
316
322
const struct regulator_desc * rdesc ;
317
323
const struct regulator_desc * common_rdesc ;
324
+ struct tps65219_regulator_irq_type * irq_types ;
325
+ struct tps65219_regulator_irq_type * common_irq_types ;
318
326
};
319
327
320
328
static struct tps65219_chip_data chip_info_table [] = {
@@ -323,20 +331,27 @@ static struct tps65219_chip_data chip_info_table[] = {
323
331
.rdesc_size = ARRAY_SIZE (tps65215_regs ),
324
332
.common_rdesc = common_regs ,
325
333
.common_rdesc_size = ARRAY_SIZE (common_regs ),
334
+ .irq_types = NULL ,
335
+ .dev_irq_size = 0 ,
336
+ .common_irq_types = common_regulator_irq_types ,
337
+ .common_irq_size = ARRAY_SIZE (common_regulator_irq_types ),
326
338
},
327
339
[TPS65219 ] = {
328
340
.rdesc = tps65219_regs ,
329
341
.rdesc_size = ARRAY_SIZE (tps65219_regs ),
330
342
.common_rdesc = common_regs ,
331
343
.common_rdesc_size = ARRAY_SIZE (common_regs ),
344
+ .irq_types = tps65219_regulator_irq_types ,
345
+ .dev_irq_size = ARRAY_SIZE (tps65219_regulator_irq_types ),
346
+ .common_irq_types = common_regulator_irq_types ,
347
+ .common_irq_size = ARRAY_SIZE (common_regulator_irq_types ),
332
348
},
333
349
};
334
350
335
351
static int tps65219_regulator_probe (struct platform_device * pdev )
336
352
{
337
353
struct tps65219_regulator_irq_data * irq_data ;
338
354
struct tps65219_regulator_irq_type * irq_type ;
339
-
340
355
struct tps65219_chip_data * pmic ;
341
356
struct regulator_dev * rdev ;
342
357
int error ;
@@ -371,33 +386,50 @@ static int tps65219_regulator_probe(struct platform_device *pdev)
371
386
pmic -> rdesc [i ].name );
372
387
}
373
388
374
- irq_data = devm_kmalloc (tps -> dev ,
375
- ARRAY_SIZE (tps65219_regulator_irq_types ) *
376
- sizeof (struct tps65219_regulator_irq_data ),
377
- GFP_KERNEL );
389
+ irq_data = devm_kmalloc (tps -> dev , pmic -> common_irq_size , GFP_KERNEL );
378
390
if (!irq_data )
379
391
return - ENOMEM ;
380
392
381
- for (i = 0 ; i < ARRAY_SIZE (tps65219_regulator_irq_types ); ++ i ) {
382
- irq_type = & tps65219_regulator_irq_types [i ];
383
-
393
+ for (i = 0 ; i < pmic -> common_irq_size ; ++ i ) {
394
+ irq_type = & pmic -> common_irq_types [i ];
384
395
irq = platform_get_irq_byname (pdev , irq_type -> irq_name );
385
396
if (irq < 0 )
386
397
return - EINVAL ;
387
398
388
399
irq_data [i ].dev = tps -> dev ;
389
400
irq_data [i ].type = irq_type ;
401
+ error = devm_request_threaded_irq (tps -> dev , irq , NULL ,
402
+ tps65219_regulator_irq_handler ,
403
+ IRQF_ONESHOT ,
404
+ irq_type -> irq_name ,
405
+ & irq_data [i ]);
406
+ if (error )
407
+ return dev_err_probe (tps -> dev , PTR_ERR (rdev ),
408
+ "Failed to request %s IRQ %d: %d\n" ,
409
+ irq_type -> irq_name , irq , error );
410
+ }
411
+
412
+ irq_data = devm_kmalloc (tps -> dev , pmic -> dev_irq_size , GFP_KERNEL );
413
+ if (!irq_data )
414
+ return - ENOMEM ;
390
415
416
+ for (i = 0 ; i < pmic -> dev_irq_size ; ++ i ) {
417
+ irq_type = & pmic -> irq_types [i ];
418
+ irq = platform_get_irq_byname (pdev , irq_type -> irq_name );
419
+ if (irq < 0 )
420
+ return - EINVAL ;
421
+
422
+ irq_data [i ].dev = tps -> dev ;
423
+ irq_data [i ].type = irq_type ;
391
424
error = devm_request_threaded_irq (tps -> dev , irq , NULL ,
392
425
tps65219_regulator_irq_handler ,
393
426
IRQF_ONESHOT ,
394
427
irq_type -> irq_name ,
395
428
& irq_data [i ]);
396
- if (error ) {
397
- dev_err (tps -> dev , "failed to request %s IRQ %d: %d\n" ,
398
- irq_type -> irq_name , irq , error );
399
- return error ;
400
- }
429
+ if (error )
430
+ return dev_err_probe (tps -> dev , PTR_ERR (rdev ),
431
+ "Failed to request %s IRQ %d: %d\n" ,
432
+ irq_type -> irq_name , irq , error );
401
433
}
402
434
403
435
return 0 ;
0 commit comments