1
1
// SPDX-License-Identifier: GPL-2.0
2
2
// Copyright (c) 2018-2021, The Linux Foundation. All rights reserved.
3
+ // Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
3
4
4
5
#define pr_fmt (fmt ) "%s: " fmt, __func__
5
6
@@ -68,10 +69,11 @@ enum rpmh_regulator_type {
68
69
* @regulator_type: RPMh accelerator type used to manage this
69
70
* regulator
70
71
* @ops: Pointer to regulator ops callback structure
71
- * @voltage_range: The single range of voltages supported by this
72
- * PMIC regulator type
72
+ * @voltage_ranges: The possible ranges of voltages supported by this
73
+ * PMIC regulator type
74
+ * @n_linear_ranges: Number of entries in voltage_ranges
73
75
* @n_voltages: The number of unique voltage set points defined
74
- * by voltage_range
76
+ * by voltage_ranges
75
77
* @hpm_min_load_uA: Minimum load current in microamps that requires
76
78
* high power mode (HPM) operation. This is used
77
79
* for LDO hardware type regulators only.
@@ -85,7 +87,8 @@ enum rpmh_regulator_type {
85
87
struct rpmh_vreg_hw_data {
86
88
enum rpmh_regulator_type regulator_type ;
87
89
const struct regulator_ops * ops ;
88
- const struct linear_range voltage_range ;
90
+ const struct linear_range * voltage_ranges ;
91
+ int n_linear_ranges ;
89
92
int n_voltages ;
90
93
int hpm_min_load_uA ;
91
94
const int * pmic_mode_map ;
@@ -449,8 +452,8 @@ static int rpmh_regulator_init_vreg(struct rpmh_vreg *vreg, struct device *dev,
449
452
vreg -> mode = REGULATOR_MODE_INVALID ;
450
453
451
454
if (rpmh_data -> hw_data -> n_voltages ) {
452
- vreg -> rdesc .linear_ranges = & rpmh_data -> hw_data -> voltage_range ;
453
- vreg -> rdesc .n_linear_ranges = 1 ;
455
+ vreg -> rdesc .linear_ranges = rpmh_data -> hw_data -> voltage_ranges ;
456
+ vreg -> rdesc .n_linear_ranges = rpmh_data -> hw_data -> n_linear_ranges ;
454
457
vreg -> rdesc .n_voltages = rpmh_data -> hw_data -> n_voltages ;
455
458
}
456
459
@@ -613,7 +616,10 @@ static unsigned int rpmh_regulator_pmic4_bob_of_map_mode(unsigned int rpmh_mode)
613
616
static const struct rpmh_vreg_hw_data pmic4_pldo = {
614
617
.regulator_type = VRM ,
615
618
.ops = & rpmh_regulator_vrm_drms_ops ,
616
- .voltage_range = REGULATOR_LINEAR_RANGE (1664000 , 0 , 255 , 8000 ),
619
+ .voltage_ranges = (struct linear_range []) {
620
+ REGULATOR_LINEAR_RANGE (1664000 , 0 , 255 , 8000 ),
621
+ },
622
+ .n_linear_ranges = 1 ,
617
623
.n_voltages = 256 ,
618
624
.hpm_min_load_uA = 10000 ,
619
625
.pmic_mode_map = pmic_mode_map_pmic4_ldo ,
@@ -623,7 +629,10 @@ static const struct rpmh_vreg_hw_data pmic4_pldo = {
623
629
static const struct rpmh_vreg_hw_data pmic4_pldo_lv = {
624
630
.regulator_type = VRM ,
625
631
.ops = & rpmh_regulator_vrm_drms_ops ,
626
- .voltage_range = REGULATOR_LINEAR_RANGE (1256000 , 0 , 127 , 8000 ),
632
+ .voltage_ranges = (struct linear_range []) {
633
+ REGULATOR_LINEAR_RANGE (1256000 , 0 , 127 , 8000 ),
634
+ },
635
+ .n_linear_ranges = 1 ,
627
636
.n_voltages = 128 ,
628
637
.hpm_min_load_uA = 10000 ,
629
638
.pmic_mode_map = pmic_mode_map_pmic4_ldo ,
@@ -633,7 +642,10 @@ static const struct rpmh_vreg_hw_data pmic4_pldo_lv = {
633
642
static const struct rpmh_vreg_hw_data pmic4_nldo = {
634
643
.regulator_type = VRM ,
635
644
.ops = & rpmh_regulator_vrm_drms_ops ,
636
- .voltage_range = REGULATOR_LINEAR_RANGE (312000 , 0 , 127 , 8000 ),
645
+ .voltage_ranges = (struct linear_range []) {
646
+ REGULATOR_LINEAR_RANGE (312000 , 0 , 127 , 8000 ),
647
+ },
648
+ .n_linear_ranges = 1 ,
637
649
.n_voltages = 128 ,
638
650
.hpm_min_load_uA = 30000 ,
639
651
.pmic_mode_map = pmic_mode_map_pmic4_ldo ,
@@ -643,7 +655,10 @@ static const struct rpmh_vreg_hw_data pmic4_nldo = {
643
655
static const struct rpmh_vreg_hw_data pmic4_hfsmps3 = {
644
656
.regulator_type = VRM ,
645
657
.ops = & rpmh_regulator_vrm_ops ,
646
- .voltage_range = REGULATOR_LINEAR_RANGE (320000 , 0 , 215 , 8000 ),
658
+ .voltage_ranges = (struct linear_range []) {
659
+ REGULATOR_LINEAR_RANGE (320000 , 0 , 215 , 8000 ),
660
+ },
661
+ .n_linear_ranges = 1 ,
647
662
.n_voltages = 216 ,
648
663
.pmic_mode_map = pmic_mode_map_pmic4_smps ,
649
664
.of_map_mode = rpmh_regulator_pmic4_smps_of_map_mode ,
@@ -652,7 +667,10 @@ static const struct rpmh_vreg_hw_data pmic4_hfsmps3 = {
652
667
static const struct rpmh_vreg_hw_data pmic4_ftsmps426 = {
653
668
.regulator_type = VRM ,
654
669
.ops = & rpmh_regulator_vrm_ops ,
655
- .voltage_range = REGULATOR_LINEAR_RANGE (320000 , 0 , 258 , 4000 ),
670
+ .voltage_ranges = (struct linear_range []) {
671
+ REGULATOR_LINEAR_RANGE (320000 , 0 , 258 , 4000 ),
672
+ },
673
+ .n_linear_ranges = 1 ,
656
674
.n_voltages = 259 ,
657
675
.pmic_mode_map = pmic_mode_map_pmic4_smps ,
658
676
.of_map_mode = rpmh_regulator_pmic4_smps_of_map_mode ,
@@ -661,7 +679,10 @@ static const struct rpmh_vreg_hw_data pmic4_ftsmps426 = {
661
679
static const struct rpmh_vreg_hw_data pmic4_bob = {
662
680
.regulator_type = VRM ,
663
681
.ops = & rpmh_regulator_vrm_bypass_ops ,
664
- .voltage_range = REGULATOR_LINEAR_RANGE (1824000 , 0 , 83 , 32000 ),
682
+ .voltage_ranges = (struct linear_range []) {
683
+ REGULATOR_LINEAR_RANGE (1824000 , 0 , 83 , 32000 ),
684
+ },
685
+ .n_linear_ranges = 1 ,
665
686
.n_voltages = 84 ,
666
687
.pmic_mode_map = pmic_mode_map_pmic4_bob ,
667
688
.of_map_mode = rpmh_regulator_pmic4_bob_of_map_mode ,
@@ -676,7 +697,10 @@ static const struct rpmh_vreg_hw_data pmic4_lvs = {
676
697
static const struct rpmh_vreg_hw_data pmic5_pldo = {
677
698
.regulator_type = VRM ,
678
699
.ops = & rpmh_regulator_vrm_drms_ops ,
679
- .voltage_range = REGULATOR_LINEAR_RANGE (1504000 , 0 , 255 , 8000 ),
700
+ .voltage_ranges = (struct linear_range []) {
701
+ REGULATOR_LINEAR_RANGE (1504000 , 0 , 255 , 8000 ),
702
+ },
703
+ .n_linear_ranges = 1 ,
680
704
.n_voltages = 256 ,
681
705
.hpm_min_load_uA = 10000 ,
682
706
.pmic_mode_map = pmic_mode_map_pmic5_ldo ,
@@ -686,7 +710,10 @@ static const struct rpmh_vreg_hw_data pmic5_pldo = {
686
710
static const struct rpmh_vreg_hw_data pmic5_pldo_lv = {
687
711
.regulator_type = VRM ,
688
712
.ops = & rpmh_regulator_vrm_drms_ops ,
689
- .voltage_range = REGULATOR_LINEAR_RANGE (1504000 , 0 , 62 , 8000 ),
713
+ .voltage_ranges = (struct linear_range []) {
714
+ REGULATOR_LINEAR_RANGE (1504000 , 0 , 62 , 8000 ),
715
+ },
716
+ .n_linear_ranges = 1 ,
690
717
.n_voltages = 63 ,
691
718
.hpm_min_load_uA = 10000 ,
692
719
.pmic_mode_map = pmic_mode_map_pmic5_ldo ,
@@ -696,7 +723,10 @@ static const struct rpmh_vreg_hw_data pmic5_pldo_lv = {
696
723
static const struct rpmh_vreg_hw_data pmic5_pldo515_mv = {
697
724
.regulator_type = VRM ,
698
725
.ops = & rpmh_regulator_vrm_drms_ops ,
699
- .voltage_range = REGULATOR_LINEAR_RANGE (1800000 , 0 , 187 , 8000 ),
726
+ .voltage_ranges = (struct linear_range []) {
727
+ REGULATOR_LINEAR_RANGE (1800000 , 0 , 187 , 8000 ),
728
+ },
729
+ .n_linear_ranges = 1 ,
700
730
.n_voltages = 188 ,
701
731
.hpm_min_load_uA = 10000 ,
702
732
.pmic_mode_map = pmic_mode_map_pmic5_ldo ,
@@ -706,7 +736,10 @@ static const struct rpmh_vreg_hw_data pmic5_pldo515_mv = {
706
736
static const struct rpmh_vreg_hw_data pmic5_nldo = {
707
737
.regulator_type = VRM ,
708
738
.ops = & rpmh_regulator_vrm_drms_ops ,
709
- .voltage_range = REGULATOR_LINEAR_RANGE (320000 , 0 , 123 , 8000 ),
739
+ .voltage_ranges = (struct linear_range []) {
740
+ REGULATOR_LINEAR_RANGE (320000 , 0 , 123 , 8000 ),
741
+ },
742
+ .n_linear_ranges = 1 ,
710
743
.n_voltages = 124 ,
711
744
.hpm_min_load_uA = 30000 ,
712
745
.pmic_mode_map = pmic_mode_map_pmic5_ldo ,
@@ -716,7 +749,10 @@ static const struct rpmh_vreg_hw_data pmic5_nldo = {
716
749
static const struct rpmh_vreg_hw_data pmic5_nldo515 = {
717
750
.regulator_type = VRM ,
718
751
.ops = & rpmh_regulator_vrm_drms_ops ,
719
- .voltage_range = REGULATOR_LINEAR_RANGE (320000 , 0 , 210 , 8000 ),
752
+ .voltage_ranges = (struct linear_range []) {
753
+ REGULATOR_LINEAR_RANGE (320000 , 0 , 210 , 8000 ),
754
+ },
755
+ .n_linear_ranges = 1 ,
720
756
.n_voltages = 211 ,
721
757
.hpm_min_load_uA = 30000 ,
722
758
.pmic_mode_map = pmic_mode_map_pmic5_ldo ,
@@ -726,7 +762,10 @@ static const struct rpmh_vreg_hw_data pmic5_nldo515 = {
726
762
static const struct rpmh_vreg_hw_data pmic5_hfsmps510 = {
727
763
.regulator_type = VRM ,
728
764
.ops = & rpmh_regulator_vrm_ops ,
729
- .voltage_range = REGULATOR_LINEAR_RANGE (320000 , 0 , 215 , 8000 ),
765
+ .voltage_ranges = (struct linear_range []) {
766
+ REGULATOR_LINEAR_RANGE (320000 , 0 , 215 , 8000 ),
767
+ },
768
+ .n_linear_ranges = 1 ,
730
769
.n_voltages = 216 ,
731
770
.pmic_mode_map = pmic_mode_map_pmic5_smps ,
732
771
.of_map_mode = rpmh_regulator_pmic4_smps_of_map_mode ,
@@ -735,7 +774,10 @@ static const struct rpmh_vreg_hw_data pmic5_hfsmps510 = {
735
774
static const struct rpmh_vreg_hw_data pmic5_ftsmps510 = {
736
775
.regulator_type = VRM ,
737
776
.ops = & rpmh_regulator_vrm_ops ,
738
- .voltage_range = REGULATOR_LINEAR_RANGE (300000 , 0 , 263 , 4000 ),
777
+ .voltage_ranges = (struct linear_range []) {
778
+ REGULATOR_LINEAR_RANGE (300000 , 0 , 263 , 4000 ),
779
+ },
780
+ .n_linear_ranges = 1 ,
739
781
.n_voltages = 264 ,
740
782
.pmic_mode_map = pmic_mode_map_pmic5_smps ,
741
783
.of_map_mode = rpmh_regulator_pmic4_smps_of_map_mode ,
@@ -744,7 +786,10 @@ static const struct rpmh_vreg_hw_data pmic5_ftsmps510 = {
744
786
static const struct rpmh_vreg_hw_data pmic5_ftsmps520 = {
745
787
.regulator_type = VRM ,
746
788
.ops = & rpmh_regulator_vrm_ops ,
747
- .voltage_range = REGULATOR_LINEAR_RANGE (300000 , 0 , 263 , 4000 ),
789
+ .voltage_ranges = (struct linear_range []) {
790
+ REGULATOR_LINEAR_RANGE (300000 , 0 , 263 , 4000 ),
791
+ },
792
+ .n_linear_ranges = 1 ,
748
793
.n_voltages = 264 ,
749
794
.pmic_mode_map = pmic_mode_map_pmic5_smps ,
750
795
.of_map_mode = rpmh_regulator_pmic4_smps_of_map_mode ,
@@ -753,7 +798,10 @@ static const struct rpmh_vreg_hw_data pmic5_ftsmps520 = {
753
798
static const struct rpmh_vreg_hw_data pmic5_ftsmps525_lv = {
754
799
.regulator_type = VRM ,
755
800
.ops = & rpmh_regulator_vrm_ops ,
756
- .voltage_range = REGULATOR_LINEAR_RANGE (300000 , 0 , 267 , 4000 ),
801
+ .voltage_ranges = (struct linear_range []) {
802
+ REGULATOR_LINEAR_RANGE (300000 , 0 , 267 , 4000 ),
803
+ },
804
+ .n_linear_ranges = 1 ,
757
805
.n_voltages = 268 ,
758
806
.pmic_mode_map = pmic_mode_map_pmic5_smps ,
759
807
.of_map_mode = rpmh_regulator_pmic4_smps_of_map_mode ,
@@ -762,7 +810,10 @@ static const struct rpmh_vreg_hw_data pmic5_ftsmps525_lv = {
762
810
static const struct rpmh_vreg_hw_data pmic5_ftsmps525_mv = {
763
811
.regulator_type = VRM ,
764
812
.ops = & rpmh_regulator_vrm_ops ,
765
- .voltage_range = REGULATOR_LINEAR_RANGE (600000 , 0 , 267 , 8000 ),
813
+ .voltage_ranges = (struct linear_range []) {
814
+ REGULATOR_LINEAR_RANGE (600000 , 0 , 267 , 8000 ),
815
+ },
816
+ .n_linear_ranges = 1 ,
766
817
.n_voltages = 268 ,
767
818
.pmic_mode_map = pmic_mode_map_pmic5_smps ,
768
819
.of_map_mode = rpmh_regulator_pmic4_smps_of_map_mode ,
@@ -771,7 +822,10 @@ static const struct rpmh_vreg_hw_data pmic5_ftsmps525_mv = {
771
822
static const struct rpmh_vreg_hw_data pmic5_ftsmps527 = {
772
823
.regulator_type = VRM ,
773
824
.ops = & rpmh_regulator_vrm_ops ,
774
- .voltage_range = REGULATOR_LINEAR_RANGE (320000 , 0 , 215 , 8000 ),
825
+ .voltage_ranges = (struct linear_range []) {
826
+ REGULATOR_LINEAR_RANGE (320000 , 0 , 215 , 8000 ),
827
+ },
828
+ .n_linear_ranges = 1 ,
775
829
.n_voltages = 215 ,
776
830
.pmic_mode_map = pmic_mode_map_pmic5_smps ,
777
831
.of_map_mode = rpmh_regulator_pmic4_smps_of_map_mode ,
@@ -780,7 +834,10 @@ static const struct rpmh_vreg_hw_data pmic5_ftsmps527 = {
780
834
static const struct rpmh_vreg_hw_data pmic5_hfsmps515 = {
781
835
.regulator_type = VRM ,
782
836
.ops = & rpmh_regulator_vrm_ops ,
783
- .voltage_range = REGULATOR_LINEAR_RANGE (320000 , 0 , 235 , 16000 ),
837
+ .voltage_ranges = (struct linear_range []) {
838
+ REGULATOR_LINEAR_RANGE (320000 , 0 , 235 , 16000 ),
839
+ },
840
+ .n_linear_ranges = 1 ,
784
841
.n_voltages = 236 ,
785
842
.pmic_mode_map = pmic_mode_map_pmic5_smps ,
786
843
.of_map_mode = rpmh_regulator_pmic4_smps_of_map_mode ,
@@ -789,7 +846,10 @@ static const struct rpmh_vreg_hw_data pmic5_hfsmps515 = {
789
846
static const struct rpmh_vreg_hw_data pmic5_hfsmps515_1 = {
790
847
.regulator_type = VRM ,
791
848
.ops = & rpmh_regulator_vrm_ops ,
792
- .voltage_range = REGULATOR_LINEAR_RANGE (900000 , 0 , 4 , 16000 ),
849
+ .voltage_ranges = (struct linear_range []) {
850
+ REGULATOR_LINEAR_RANGE (900000 , 0 , 4 , 16000 ),
851
+ },
852
+ .n_linear_ranges = 1 ,
793
853
.n_voltages = 5 ,
794
854
.pmic_mode_map = pmic_mode_map_pmic5_smps ,
795
855
.of_map_mode = rpmh_regulator_pmic4_smps_of_map_mode ,
@@ -798,7 +858,10 @@ static const struct rpmh_vreg_hw_data pmic5_hfsmps515_1 = {
798
858
static const struct rpmh_vreg_hw_data pmic5_bob = {
799
859
.regulator_type = VRM ,
800
860
.ops = & rpmh_regulator_vrm_bypass_ops ,
801
- .voltage_range = REGULATOR_LINEAR_RANGE (3000000 , 0 , 31 , 32000 ),
861
+ .voltage_ranges = (struct linear_range []) {
862
+ REGULATOR_LINEAR_RANGE (3000000 , 0 , 31 , 32000 ),
863
+ },
864
+ .n_linear_ranges = 1 ,
802
865
.n_voltages = 32 ,
803
866
.pmic_mode_map = pmic_mode_map_pmic5_bob ,
804
867
.of_map_mode = rpmh_regulator_pmic4_bob_of_map_mode ,
0 commit comments