@@ -49,6 +49,7 @@ struct twlreg_info {
49
49
50
50
/* chip constraints on regulator behavior */
51
51
u16 min_mV ;
52
+ u16 max_mV ;
52
53
53
54
/* used by regulator core */
54
55
struct regulator_desc desc ;
@@ -318,31 +319,8 @@ static const u16 VIO_VSEL_table[] = {
318
319
static const u16 VINTANA2_VSEL_table [] = {
319
320
2500 , 2750 ,
320
321
};
321
- static const u16 VAUX1_6030_VSEL_table [] = {
322
- 1000 , 1300 , 1800 , 2500 ,
323
- 2800 , 2900 , 3000 , 3000 ,
324
- };
325
- static const u16 VAUX2_6030_VSEL_table [] = {
326
- 1200 , 1800 , 2500 , 2750 ,
327
- 2800 , 2800 , 2800 , 2800 ,
328
- };
329
- static const u16 VAUX3_6030_VSEL_table [] = {
330
- 1000 , 1200 , 1300 , 1800 ,
331
- 2500 , 2800 , 3000 , 3000 ,
332
- };
333
- static const u16 VMMC_VSEL_table [] = {
334
- 1200 , 1800 , 2800 , 2900 ,
335
- 3000 , 3000 , 3000 , 3000 ,
336
- };
337
- static const u16 VPP_VSEL_table [] = {
338
- 1800 , 1900 , 2000 , 2100 ,
339
- 2200 , 2300 , 2400 , 2500 ,
340
- };
341
- static const u16 VUSIM_VSEL_table [] = {
342
- 1200 , 1800 , 2500 , 2900 ,
343
- };
344
322
345
- static int twlldo_list_voltage (struct regulator_dev * rdev , unsigned index )
323
+ static int twl4030ldo_list_voltage (struct regulator_dev * rdev , unsigned index )
346
324
{
347
325
struct twlreg_info * info = rdev_get_drvdata (rdev );
348
326
int mV = info -> table [index ];
@@ -351,7 +329,7 @@ static int twlldo_list_voltage(struct regulator_dev *rdev, unsigned index)
351
329
}
352
330
353
331
static int
354
- twlldo_set_voltage (struct regulator_dev * rdev , int min_uV , int max_uV )
332
+ twl4030ldo_set_voltage (struct regulator_dev * rdev , int min_uV , int max_uV )
355
333
{
356
334
struct twlreg_info * info = rdev_get_drvdata (rdev );
357
335
int vsel ;
@@ -375,7 +353,7 @@ twlldo_set_voltage(struct regulator_dev *rdev, int min_uV, int max_uV)
375
353
return - EDOM ;
376
354
}
377
355
378
- static int twlldo_get_voltage (struct regulator_dev * rdev )
356
+ static int twl4030ldo_get_voltage (struct regulator_dev * rdev )
379
357
{
380
358
struct twlreg_info * info = rdev_get_drvdata (rdev );
381
359
int vsel = twlreg_read (info , TWL_MODULE_PM_RECEIVER ,
@@ -388,11 +366,67 @@ static int twlldo_get_voltage(struct regulator_dev *rdev)
388
366
return LDO_MV (info -> table [vsel ]) * 1000 ;
389
367
}
390
368
391
- static struct regulator_ops twlldo_ops = {
392
- .list_voltage = twlldo_list_voltage ,
369
+ static struct regulator_ops twl4030ldo_ops = {
370
+ .list_voltage = twl4030ldo_list_voltage ,
393
371
394
- .set_voltage = twlldo_set_voltage ,
395
- .get_voltage = twlldo_get_voltage ,
372
+ .set_voltage = twl4030ldo_set_voltage ,
373
+ .get_voltage = twl4030ldo_get_voltage ,
374
+
375
+ .enable = twlreg_enable ,
376
+ .disable = twlreg_disable ,
377
+ .is_enabled = twlreg_is_enabled ,
378
+
379
+ .set_mode = twlreg_set_mode ,
380
+
381
+ .get_status = twlreg_get_status ,
382
+ };
383
+
384
+ static int twl6030ldo_list_voltage (struct regulator_dev * rdev , unsigned index )
385
+ {
386
+ struct twlreg_info * info = rdev_get_drvdata (rdev );
387
+
388
+ return ((info -> min_mV + (index * 100 )) * 1000 );
389
+ }
390
+
391
+ static int
392
+ twl6030ldo_set_voltage (struct regulator_dev * rdev , int min_uV , int max_uV )
393
+ {
394
+ struct twlreg_info * info = rdev_get_drvdata (rdev );
395
+ int vsel ;
396
+
397
+ if ((min_uV /1000 < info -> min_mV ) || (max_uV /1000 > info -> max_mV ))
398
+ return - EDOM ;
399
+
400
+ /*
401
+ * Use the below formula to calculate vsel
402
+ * mV = 1000mv + 100mv * (vsel - 1)
403
+ */
404
+ vsel = (min_uV /1000 - 1000 )/100 + 1 ;
405
+ return twlreg_write (info , TWL_MODULE_PM_RECEIVER , VREG_VOLTAGE , vsel );
406
+
407
+ }
408
+
409
+ static int twl6030ldo_get_voltage (struct regulator_dev * rdev )
410
+ {
411
+ struct twlreg_info * info = rdev_get_drvdata (rdev );
412
+ int vsel = twlreg_read (info , TWL_MODULE_PM_RECEIVER ,
413
+ VREG_VOLTAGE );
414
+
415
+ if (vsel < 0 )
416
+ return vsel ;
417
+
418
+ /*
419
+ * Use the below formula to calculate vsel
420
+ * mV = 1000mv + 100mv * (vsel - 1)
421
+ */
422
+ return (1000 + (100 * (vsel - 1 ))) * 1000 ;
423
+ }
424
+
425
+ static struct regulator_ops twl6030ldo_ops = {
426
+ .list_voltage = twl6030ldo_list_voltage ,
427
+
428
+ .set_voltage = twl6030ldo_set_voltage ,
429
+ .get_voltage = twl6030ldo_get_voltage ,
396
430
397
431
.enable = twlreg_enable ,
398
432
.disable = twlreg_disable ,
@@ -438,24 +472,16 @@ static struct regulator_ops twlfixed_ops = {
438
472
439
473
/*----------------------------------------------------------------------*/
440
474
441
- #define TWL4030_ADJUSTABLE_LDO (label , offset , num , turnon_delay , remap_conf ) \
442
- TWL_ADJUSTABLE_LDO(label, offset, num, turnon_delay, \
443
- remap_conf, TWL4030)
444
475
#define TWL4030_FIXED_LDO (label , offset , mVolts , num , turnon_delay , \
445
476
remap_conf ) \
446
477
TWL_FIXED_LDO(label, offset, mVolts, num, turnon_delay, \
447
478
remap_conf, TWL4030)
448
- #define TWL6030_ADJUSTABLE_LDO (label , offset , num , turnon_delay , \
449
- remap_conf ) \
450
- TWL_ADJUSTABLE_LDO(label, offset, num, turnon_delay, \
451
- remap_conf, TWL6030)
452
479
#define TWL6030_FIXED_LDO (label , offset , mVolts , num , turnon_delay , \
453
480
remap_conf ) \
454
481
TWL_FIXED_LDO(label, offset, mVolts, num, turnon_delay, \
455
482
remap_conf, TWL6030)
456
483
457
- #define TWL_ADJUSTABLE_LDO (label , offset , num , turnon_delay , remap_conf , \
458
- family ) { \
484
+ #define TWL4030_ADJUSTABLE_LDO (label , offset , num , turnon_delay , remap_conf ) { \
459
485
.base = offset, \
460
486
.id = num, \
461
487
.table_len = ARRAY_SIZE(label##_VSEL_table), \
@@ -464,14 +490,32 @@ static struct regulator_ops twlfixed_ops = {
464
490
.remap = remap_conf, \
465
491
.desc = { \
466
492
.name = #label, \
467
- .id = family##_REG_ ##label, \
493
+ .id = TWL4030_REG_ ##label, \
468
494
.n_voltages = ARRAY_SIZE(label##_VSEL_table), \
469
- .ops = &twlldo_ops , \
495
+ .ops = &twl4030ldo_ops , \
470
496
.type = REGULATOR_VOLTAGE, \
471
497
.owner = THIS_MODULE, \
472
498
}, \
473
499
}
474
500
501
+ #define TWL6030_ADJUSTABLE_LDO (label , offset , min_mVolts , max_mVolts , num , \
502
+ remap_conf ) { \
503
+ .base = offset, \
504
+ .id = num, \
505
+ .min_mV = min_mVolts, \
506
+ .max_mV = max_mVolts, \
507
+ .remap = remap_conf, \
508
+ .desc = { \
509
+ .name = #label, \
510
+ .id = TWL6030_REG_##label, \
511
+ .n_voltages = (max_mVolts - min_mVolts)/100, \
512
+ .ops = &twl6030ldo_ops, \
513
+ .type = REGULATOR_VOLTAGE, \
514
+ .owner = THIS_MODULE, \
515
+ }, \
516
+ }
517
+
518
+
475
519
#define TWL_FIXED_LDO (label , offset , mVolts , num , turnon_delay , remap_conf , \
476
520
family ) { \
477
521
.base = offset, \
@@ -519,12 +563,12 @@ static struct twlreg_info twl_regs[] = {
519
563
/* 6030 REG with base as PMC Slave Misc : 0x0030 */
520
564
/* Turnon-delay and remap configuration values for 6030 are not
521
565
verified since the specification is not public */
522
- TWL6030_ADJUSTABLE_LDO (VAUX1_6030 , 0x54 , 1 , 0 , 0x21 ),
523
- TWL6030_ADJUSTABLE_LDO (VAUX2_6030 , 0x58 , 2 , 0 , 0x21 ),
524
- TWL6030_ADJUSTABLE_LDO (VAUX3_6030 , 0x5c , 3 , 0 , 0x21 ),
525
- TWL6030_ADJUSTABLE_LDO (VMMC , 0x68 , 4 , 0 , 0x21 ),
526
- TWL6030_ADJUSTABLE_LDO (VPP , 0x6c , 5 , 0 , 0x21 ),
527
- TWL6030_ADJUSTABLE_LDO (VUSIM , 0x74 , 7 , 0 , 0x21 ),
566
+ TWL6030_ADJUSTABLE_LDO (VAUX1_6030 , 0x54 , 1000 , 3300 , 1 , 0x21 ),
567
+ TWL6030_ADJUSTABLE_LDO (VAUX2_6030 , 0x58 , 1000 , 3300 , 2 , 0x21 ),
568
+ TWL6030_ADJUSTABLE_LDO (VAUX3_6030 , 0x5c , 1000 , 3300 , 3 , 0x21 ),
569
+ TWL6030_ADJUSTABLE_LDO (VMMC , 0x68 , 1000 , 3300 , 4 , 0x21 ),
570
+ TWL6030_ADJUSTABLE_LDO (VPP , 0x6c , 1000 , 3300 , 5 , 0x21 ),
571
+ TWL6030_ADJUSTABLE_LDO (VUSIM , 0x74 , 1000 , 3300 , 7 , 0x21 ),
528
572
TWL6030_FIXED_LDO (VANA , 0x50 , 2100 , 15 , 0 , 0x21 ),
529
573
TWL6030_FIXED_LDO (VCXIO , 0x60 , 1800 , 16 , 0 , 0x21 ),
530
574
TWL6030_FIXED_LDO (VDAC , 0x64 , 1800 , 17 , 0 , 0x21 ),
0 commit comments