@@ -400,7 +400,7 @@ struct spmi_voltage_range {
400
400
* so that range[i].set_point_max_uV < range[i+1].set_point_min_uV.
401
401
*/
402
402
struct spmi_voltage_set_points {
403
- struct spmi_voltage_range * range ;
403
+ const struct spmi_voltage_range * range ;
404
404
int count ;
405
405
unsigned n_voltages ;
406
406
};
@@ -474,6 +474,9 @@ struct spmi_regulator_data {
474
474
.set_point_max_uV = _set_point_max_uV, \
475
475
.step_uV = _step_uV, \
476
476
.range_sel = _range_sel, \
477
+ .n_voltages = (_set_point_max_uV != 0) ? \
478
+ ((_set_point_max_uV - _set_point_min_uV) / _step_uV) + 1 : \
479
+ 0, \
477
480
}
478
481
479
482
#define DEFINE_SPMI_SET_POINTS (name ) \
@@ -489,110 +492,110 @@ struct spmi_voltage_set_points name##_set_points = { \
489
492
* increasing and unique. The set_voltage callback functions expect these
490
493
* properties to hold.
491
494
*/
492
- static struct spmi_voltage_range pldo_ranges [] = {
495
+ static const struct spmi_voltage_range pldo_ranges [] = {
493
496
SPMI_VOLTAGE_RANGE (2 , 750000 , 750000 , 1537500 , 1537500 , 12500 ),
494
497
SPMI_VOLTAGE_RANGE (3 , 1500000 , 1550000 , 3075000 , 3075000 , 25000 ),
495
498
SPMI_VOLTAGE_RANGE (4 , 1750000 , 3100000 , 4900000 , 4900000 , 50000 ),
496
499
};
497
500
498
- static struct spmi_voltage_range nldo1_ranges [] = {
501
+ static const struct spmi_voltage_range nldo1_ranges [] = {
499
502
SPMI_VOLTAGE_RANGE (2 , 750000 , 750000 , 1537500 , 1537500 , 12500 ),
500
503
};
501
504
502
- static struct spmi_voltage_range nldo2_ranges [] = {
505
+ static const struct spmi_voltage_range nldo2_ranges [] = {
503
506
SPMI_VOLTAGE_RANGE (0 , 375000 , 0 , 0 , 1537500 , 12500 ),
504
507
SPMI_VOLTAGE_RANGE (1 , 375000 , 375000 , 768750 , 768750 , 6250 ),
505
508
SPMI_VOLTAGE_RANGE (2 , 750000 , 775000 , 1537500 , 1537500 , 12500 ),
506
509
};
507
510
508
- static struct spmi_voltage_range nldo3_ranges [] = {
511
+ static const struct spmi_voltage_range nldo3_ranges [] = {
509
512
SPMI_VOLTAGE_RANGE (0 , 375000 , 375000 , 1537500 , 1537500 , 12500 ),
510
513
SPMI_VOLTAGE_RANGE (1 , 375000 , 0 , 0 , 1537500 , 12500 ),
511
514
SPMI_VOLTAGE_RANGE (2 , 750000 , 0 , 0 , 1537500 , 12500 ),
512
515
};
513
516
514
- static struct spmi_voltage_range ln_ldo_ranges [] = {
517
+ static const struct spmi_voltage_range ln_ldo_ranges [] = {
515
518
SPMI_VOLTAGE_RANGE (1 , 690000 , 690000 , 1110000 , 1110000 , 60000 ),
516
519
SPMI_VOLTAGE_RANGE (0 , 1380000 , 1380000 , 2220000 , 2220000 , 120000 ),
517
520
};
518
521
519
- static struct spmi_voltage_range smps_ranges [] = {
522
+ static const struct spmi_voltage_range smps_ranges [] = {
520
523
SPMI_VOLTAGE_RANGE (0 , 375000 , 375000 , 1562500 , 1562500 , 12500 ),
521
524
SPMI_VOLTAGE_RANGE (1 , 1550000 , 1575000 , 3125000 , 3125000 , 25000 ),
522
525
};
523
526
524
- static struct spmi_voltage_range ftsmps_ranges [] = {
527
+ static const struct spmi_voltage_range ftsmps_ranges [] = {
525
528
SPMI_VOLTAGE_RANGE (0 , 0 , 350000 , 1275000 , 1275000 , 5000 ),
526
529
SPMI_VOLTAGE_RANGE (1 , 0 , 1280000 , 2040000 , 2040000 , 10000 ),
527
530
};
528
531
529
- static struct spmi_voltage_range ftsmps2p5_ranges [] = {
532
+ static const struct spmi_voltage_range ftsmps2p5_ranges [] = {
530
533
SPMI_VOLTAGE_RANGE (0 , 80000 , 350000 , 1355000 , 1355000 , 5000 ),
531
534
SPMI_VOLTAGE_RANGE (1 , 160000 , 1360000 , 2200000 , 2200000 , 10000 ),
532
535
};
533
536
534
- static struct spmi_voltage_range ftsmps426_ranges [] = {
537
+ static const struct spmi_voltage_range ftsmps426_ranges [] = {
535
538
SPMI_VOLTAGE_RANGE (0 , 0 , 320000 , 1352000 , 1352000 , 4000 ),
536
539
};
537
540
538
- static struct spmi_voltage_range boost_ranges [] = {
541
+ static const struct spmi_voltage_range boost_ranges [] = {
539
542
SPMI_VOLTAGE_RANGE (0 , 4000000 , 4000000 , 5550000 , 5550000 , 50000 ),
540
543
};
541
544
542
- static struct spmi_voltage_range boost_byp_ranges [] = {
545
+ static const struct spmi_voltage_range boost_byp_ranges [] = {
543
546
SPMI_VOLTAGE_RANGE (0 , 2500000 , 2500000 , 5200000 , 5650000 , 50000 ),
544
547
};
545
548
546
- static struct spmi_voltage_range ult_lo_smps_ranges [] = {
549
+ static const struct spmi_voltage_range ult_lo_smps_ranges [] = {
547
550
SPMI_VOLTAGE_RANGE (0 , 375000 , 375000 , 1562500 , 1562500 , 12500 ),
548
551
SPMI_VOLTAGE_RANGE (1 , 750000 , 0 , 0 , 1525000 , 25000 ),
549
552
};
550
553
551
- static struct spmi_voltage_range ult_ho_smps_ranges [] = {
554
+ static const struct spmi_voltage_range ult_ho_smps_ranges [] = {
552
555
SPMI_VOLTAGE_RANGE (0 , 1550000 , 1550000 , 2325000 , 2325000 , 25000 ),
553
556
};
554
557
555
- static struct spmi_voltage_range ult_nldo_ranges [] = {
558
+ static const struct spmi_voltage_range ult_nldo_ranges [] = {
556
559
SPMI_VOLTAGE_RANGE (0 , 375000 , 375000 , 1537500 , 1537500 , 12500 ),
557
560
};
558
561
559
- static struct spmi_voltage_range ult_pldo_ranges [] = {
562
+ static const struct spmi_voltage_range ult_pldo_ranges [] = {
560
563
SPMI_VOLTAGE_RANGE (0 , 1750000 , 1750000 , 3337500 , 3337500 , 12500 ),
561
564
};
562
565
563
- static struct spmi_voltage_range pldo660_ranges [] = {
566
+ static const struct spmi_voltage_range pldo660_ranges [] = {
564
567
SPMI_VOLTAGE_RANGE (0 , 1504000 , 1504000 , 3544000 , 3544000 , 8000 ),
565
568
};
566
569
567
- static struct spmi_voltage_range nldo660_ranges [] = {
570
+ static const struct spmi_voltage_range nldo660_ranges [] = {
568
571
SPMI_VOLTAGE_RANGE (0 , 320000 , 320000 , 1304000 , 1304000 , 8000 ),
569
572
};
570
573
571
- static struct spmi_voltage_range ht_lvpldo_ranges [] = {
574
+ static const struct spmi_voltage_range ht_lvpldo_ranges [] = {
572
575
SPMI_VOLTAGE_RANGE (0 , 1504000 , 1504000 , 2000000 , 2000000 , 8000 ),
573
576
};
574
577
575
- static struct spmi_voltage_range ht_nldo_ranges [] = {
578
+ static const struct spmi_voltage_range ht_nldo_ranges [] = {
576
579
SPMI_VOLTAGE_RANGE (0 , 312000 , 312000 , 1304000 , 1304000 , 8000 ),
577
580
};
578
581
579
- static struct spmi_voltage_range hfs430_ranges [] = {
582
+ static const struct spmi_voltage_range hfs430_ranges [] = {
580
583
SPMI_VOLTAGE_RANGE (0 , 320000 , 320000 , 2040000 , 2040000 , 8000 ),
581
584
};
582
585
583
- static struct spmi_voltage_range ht_p150_ranges [] = {
586
+ static const struct spmi_voltage_range ht_p150_ranges [] = {
584
587
SPMI_VOLTAGE_RANGE (0 , 1616000 , 1616000 , 3304000 , 3304000 , 8000 ),
585
588
};
586
589
587
- static struct spmi_voltage_range ht_p600_ranges [] = {
590
+ static const struct spmi_voltage_range ht_p600_ranges [] = {
588
591
SPMI_VOLTAGE_RANGE (0 , 1704000 , 1704000 , 1896000 , 1896000 , 8000 ),
589
592
};
590
593
591
- static struct spmi_voltage_range nldo_510_ranges [] = {
594
+ static const struct spmi_voltage_range nldo_510_ranges [] = {
592
595
SPMI_VOLTAGE_RANGE (0 , 320000 , 320000 , 1304000 , 1304000 , 8000 ),
593
596
};
594
597
595
- static struct spmi_voltage_range ftsmps510_ranges [] = {
598
+ static const struct spmi_voltage_range ftsmps510_ranges [] = {
596
599
SPMI_VOLTAGE_RANGE (0 , 300000 , 300000 , 1372000 , 1372000 , 4000 ),
597
600
};
598
601
@@ -1676,18 +1679,10 @@ static const struct spmi_regulator_mapping supported_regulators[] = {
1676
1679
1677
1680
static void spmi_calculate_num_voltages (struct spmi_voltage_set_points * points )
1678
1681
{
1679
- unsigned int n ;
1680
- struct spmi_voltage_range * range = points -> range ;
1681
-
1682
- for (; range < points -> range + points -> count ; range ++ ) {
1683
- n = 0 ;
1684
- if (range -> set_point_max_uV ) {
1685
- n = range -> set_point_max_uV - range -> set_point_min_uV ;
1686
- n = (n / range -> step_uV ) + 1 ;
1687
- }
1688
- range -> n_voltages = n ;
1689
- points -> n_voltages += n ;
1690
- }
1682
+ const struct spmi_voltage_range * range = points -> range ;
1683
+
1684
+ for (; range < points -> range + points -> count ; range ++ )
1685
+ points -> n_voltages += range -> n_voltages ;
1691
1686
}
1692
1687
1693
1688
static int spmi_regulator_match (struct spmi_regulator * vreg , u16 force_type )
0 commit comments