@@ -36,6 +36,14 @@ static struct tps65219_regulator_irq_type tps65219_regulator_irq_types[] = {
3636 { "LDO4_SCG" , "LDO4" , "short circuit to ground" , REGULATOR_EVENT_REGULATION_OUT },
3737 { "LDO4_OC" , "LDO4" , "overcurrent" , REGULATOR_EVENT_OVER_CURRENT },
3838 { "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 [] = {
3947 { "LDO1_SCG" , "LDO1" , "short circuit to ground" , REGULATOR_EVENT_REGULATION_OUT },
4048 { "LDO1_OC" , "LDO1" , "overcurrent" , REGULATOR_EVENT_OVER_CURRENT },
4149 { "LDO1_UV" , "LDO1" , "undervoltage" , REGULATOR_EVENT_UNDER_VOLTAGE },
@@ -59,8 +67,6 @@ static struct tps65219_regulator_irq_type tps65219_regulator_irq_types[] = {
5967 { "BUCK3_RV" , "BUCK3" , "residual voltage" , REGULATOR_EVENT_OVER_VOLTAGE_WARN },
6068 { "LDO1_RV" , "LDO1" , "residual voltage" , REGULATOR_EVENT_OVER_VOLTAGE_WARN },
6169 { "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 },
6470 { "BUCK1_RV_SD" , "BUCK1" , "residual voltage on shutdown" ,
6571 REGULATOR_EVENT_OVER_VOLTAGE_WARN },
6672 { "BUCK2_RV_SD" , "BUCK2" , "residual voltage on shutdown" ,
@@ -69,8 +75,6 @@ static struct tps65219_regulator_irq_type tps65219_regulator_irq_types[] = {
6975 REGULATOR_EVENT_OVER_VOLTAGE_WARN },
7076 { "LDO1_RV_SD" , "LDO1" , "residual voltage on shutdown" , REGULATOR_EVENT_OVER_VOLTAGE_WARN },
7177 { "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 },
7478 { "SENSOR_3_WARM" , "SENSOR3" , "warm temperature" , REGULATOR_EVENT_OVER_TEMP_WARN },
7579 { "SENSOR_2_WARM" , "SENSOR2" , "warm temperature" , REGULATOR_EVENT_OVER_TEMP_WARN },
7680 { "SENSOR_1_WARM" , "SENSOR1" , "warm temperature" , REGULATOR_EVENT_OVER_TEMP_WARN },
@@ -264,7 +268,7 @@ static const struct regulator_desc tps65215_regs[] = {
264268 TPS65219_BUCKS_LDOS_VOUT_VSET_MASK ,
265269 TPS65219_REG_ENABLE_CTRL ,
266270 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 ),
268272};
269273
270274static const struct regulator_desc tps65219_regs [] = {
@@ -313,8 +317,12 @@ static irqreturn_t tps65219_regulator_irq_handler(int irq, void *data)
313317struct tps65219_chip_data {
314318 size_t rdesc_size ;
315319 size_t common_rdesc_size ;
320+ size_t dev_irq_size ;
321+ size_t common_irq_size ;
316322 const struct regulator_desc * rdesc ;
317323 const struct regulator_desc * common_rdesc ;
324+ struct tps65219_regulator_irq_type * irq_types ;
325+ struct tps65219_regulator_irq_type * common_irq_types ;
318326};
319327
320328static struct tps65219_chip_data chip_info_table [] = {
@@ -323,20 +331,27 @@ static struct tps65219_chip_data chip_info_table[] = {
323331 .rdesc_size = ARRAY_SIZE (tps65215_regs ),
324332 .common_rdesc = common_regs ,
325333 .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 ),
326338 },
327339 [TPS65219 ] = {
328340 .rdesc = tps65219_regs ,
329341 .rdesc_size = ARRAY_SIZE (tps65219_regs ),
330342 .common_rdesc = common_regs ,
331343 .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 ),
332348 },
333349};
334350
335351static int tps65219_regulator_probe (struct platform_device * pdev )
336352{
337353 struct tps65219_regulator_irq_data * irq_data ;
338354 struct tps65219_regulator_irq_type * irq_type ;
339-
340355 struct tps65219_chip_data * pmic ;
341356 struct regulator_dev * rdev ;
342357 int error ;
@@ -371,33 +386,50 @@ static int tps65219_regulator_probe(struct platform_device *pdev)
371386 pmic -> rdesc [i ].name );
372387 }
373388
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 );
378390 if (!irq_data )
379391 return - ENOMEM ;
380392
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 ];
384395 irq = platform_get_irq_byname (pdev , irq_type -> irq_name );
385396 if (irq < 0 )
386397 return - EINVAL ;
387398
388399 irq_data [i ].dev = tps -> dev ;
389400 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 ;
390415
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 ;
391424 error = devm_request_threaded_irq (tps -> dev , irq , NULL ,
392425 tps65219_regulator_irq_handler ,
393426 IRQF_ONESHOT ,
394427 irq_type -> irq_name ,
395428 & 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 );
401433 }
402434
403435 return 0 ;
0 commit comments