11// SPDX-License-Identifier: GPL-2.0
22// Copyright (c) 2018-2021, The Linux Foundation. All rights reserved.
3+ // Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
34
45#define pr_fmt (fmt ) "%s: " fmt, __func__
56
@@ -68,10 +69,11 @@ enum rpmh_regulator_type {
6869 * @regulator_type: RPMh accelerator type used to manage this
6970 * regulator
7071 * @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
7375 * @n_voltages: The number of unique voltage set points defined
74- * by voltage_range
76+ * by voltage_ranges
7577 * @hpm_min_load_uA: Minimum load current in microamps that requires
7678 * high power mode (HPM) operation. This is used
7779 * for LDO hardware type regulators only.
@@ -85,7 +87,8 @@ enum rpmh_regulator_type {
8587struct rpmh_vreg_hw_data {
8688 enum rpmh_regulator_type regulator_type ;
8789 const struct regulator_ops * ops ;
88- const struct linear_range voltage_range ;
90+ const struct linear_range * voltage_ranges ;
91+ int n_linear_ranges ;
8992 int n_voltages ;
9093 int hpm_min_load_uA ;
9194 const int * pmic_mode_map ;
@@ -449,8 +452,8 @@ static int rpmh_regulator_init_vreg(struct rpmh_vreg *vreg, struct device *dev,
449452 vreg -> mode = REGULATOR_MODE_INVALID ;
450453
451454 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 ;
454457 vreg -> rdesc .n_voltages = rpmh_data -> hw_data -> n_voltages ;
455458 }
456459
@@ -613,7 +616,10 @@ static unsigned int rpmh_regulator_pmic4_bob_of_map_mode(unsigned int rpmh_mode)
613616static const struct rpmh_vreg_hw_data pmic4_pldo = {
614617 .regulator_type = VRM ,
615618 .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 ,
617623 .n_voltages = 256 ,
618624 .hpm_min_load_uA = 10000 ,
619625 .pmic_mode_map = pmic_mode_map_pmic4_ldo ,
@@ -623,7 +629,10 @@ static const struct rpmh_vreg_hw_data pmic4_pldo = {
623629static const struct rpmh_vreg_hw_data pmic4_pldo_lv = {
624630 .regulator_type = VRM ,
625631 .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 ,
627636 .n_voltages = 128 ,
628637 .hpm_min_load_uA = 10000 ,
629638 .pmic_mode_map = pmic_mode_map_pmic4_ldo ,
@@ -633,7 +642,10 @@ static const struct rpmh_vreg_hw_data pmic4_pldo_lv = {
633642static const struct rpmh_vreg_hw_data pmic4_nldo = {
634643 .regulator_type = VRM ,
635644 .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 ,
637649 .n_voltages = 128 ,
638650 .hpm_min_load_uA = 30000 ,
639651 .pmic_mode_map = pmic_mode_map_pmic4_ldo ,
@@ -643,7 +655,10 @@ static const struct rpmh_vreg_hw_data pmic4_nldo = {
643655static const struct rpmh_vreg_hw_data pmic4_hfsmps3 = {
644656 .regulator_type = VRM ,
645657 .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 ,
647662 .n_voltages = 216 ,
648663 .pmic_mode_map = pmic_mode_map_pmic4_smps ,
649664 .of_map_mode = rpmh_regulator_pmic4_smps_of_map_mode ,
@@ -652,7 +667,10 @@ static const struct rpmh_vreg_hw_data pmic4_hfsmps3 = {
652667static const struct rpmh_vreg_hw_data pmic4_ftsmps426 = {
653668 .regulator_type = VRM ,
654669 .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 ,
656674 .n_voltages = 259 ,
657675 .pmic_mode_map = pmic_mode_map_pmic4_smps ,
658676 .of_map_mode = rpmh_regulator_pmic4_smps_of_map_mode ,
@@ -661,7 +679,10 @@ static const struct rpmh_vreg_hw_data pmic4_ftsmps426 = {
661679static const struct rpmh_vreg_hw_data pmic4_bob = {
662680 .regulator_type = VRM ,
663681 .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 ,
665686 .n_voltages = 84 ,
666687 .pmic_mode_map = pmic_mode_map_pmic4_bob ,
667688 .of_map_mode = rpmh_regulator_pmic4_bob_of_map_mode ,
@@ -676,7 +697,10 @@ static const struct rpmh_vreg_hw_data pmic4_lvs = {
676697static const struct rpmh_vreg_hw_data pmic5_pldo = {
677698 .regulator_type = VRM ,
678699 .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 ,
680704 .n_voltages = 256 ,
681705 .hpm_min_load_uA = 10000 ,
682706 .pmic_mode_map = pmic_mode_map_pmic5_ldo ,
@@ -686,7 +710,10 @@ static const struct rpmh_vreg_hw_data pmic5_pldo = {
686710static const struct rpmh_vreg_hw_data pmic5_pldo_lv = {
687711 .regulator_type = VRM ,
688712 .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 ,
690717 .n_voltages = 63 ,
691718 .hpm_min_load_uA = 10000 ,
692719 .pmic_mode_map = pmic_mode_map_pmic5_ldo ,
@@ -696,7 +723,10 @@ static const struct rpmh_vreg_hw_data pmic5_pldo_lv = {
696723static const struct rpmh_vreg_hw_data pmic5_pldo515_mv = {
697724 .regulator_type = VRM ,
698725 .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 ,
700730 .n_voltages = 188 ,
701731 .hpm_min_load_uA = 10000 ,
702732 .pmic_mode_map = pmic_mode_map_pmic5_ldo ,
@@ -706,7 +736,10 @@ static const struct rpmh_vreg_hw_data pmic5_pldo515_mv = {
706736static const struct rpmh_vreg_hw_data pmic5_nldo = {
707737 .regulator_type = VRM ,
708738 .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 ,
710743 .n_voltages = 124 ,
711744 .hpm_min_load_uA = 30000 ,
712745 .pmic_mode_map = pmic_mode_map_pmic5_ldo ,
@@ -716,7 +749,10 @@ static const struct rpmh_vreg_hw_data pmic5_nldo = {
716749static const struct rpmh_vreg_hw_data pmic5_nldo515 = {
717750 .regulator_type = VRM ,
718751 .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 ,
720756 .n_voltages = 211 ,
721757 .hpm_min_load_uA = 30000 ,
722758 .pmic_mode_map = pmic_mode_map_pmic5_ldo ,
@@ -726,7 +762,10 @@ static const struct rpmh_vreg_hw_data pmic5_nldo515 = {
726762static const struct rpmh_vreg_hw_data pmic5_hfsmps510 = {
727763 .regulator_type = VRM ,
728764 .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 ,
730769 .n_voltages = 216 ,
731770 .pmic_mode_map = pmic_mode_map_pmic5_smps ,
732771 .of_map_mode = rpmh_regulator_pmic4_smps_of_map_mode ,
@@ -735,7 +774,10 @@ static const struct rpmh_vreg_hw_data pmic5_hfsmps510 = {
735774static const struct rpmh_vreg_hw_data pmic5_ftsmps510 = {
736775 .regulator_type = VRM ,
737776 .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 ,
739781 .n_voltages = 264 ,
740782 .pmic_mode_map = pmic_mode_map_pmic5_smps ,
741783 .of_map_mode = rpmh_regulator_pmic4_smps_of_map_mode ,
@@ -744,7 +786,10 @@ static const struct rpmh_vreg_hw_data pmic5_ftsmps510 = {
744786static const struct rpmh_vreg_hw_data pmic5_ftsmps520 = {
745787 .regulator_type = VRM ,
746788 .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 ,
748793 .n_voltages = 264 ,
749794 .pmic_mode_map = pmic_mode_map_pmic5_smps ,
750795 .of_map_mode = rpmh_regulator_pmic4_smps_of_map_mode ,
@@ -753,7 +798,10 @@ static const struct rpmh_vreg_hw_data pmic5_ftsmps520 = {
753798static const struct rpmh_vreg_hw_data pmic5_ftsmps525_lv = {
754799 .regulator_type = VRM ,
755800 .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 ,
757805 .n_voltages = 268 ,
758806 .pmic_mode_map = pmic_mode_map_pmic5_smps ,
759807 .of_map_mode = rpmh_regulator_pmic4_smps_of_map_mode ,
@@ -762,7 +810,10 @@ static const struct rpmh_vreg_hw_data pmic5_ftsmps525_lv = {
762810static const struct rpmh_vreg_hw_data pmic5_ftsmps525_mv = {
763811 .regulator_type = VRM ,
764812 .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 ,
766817 .n_voltages = 268 ,
767818 .pmic_mode_map = pmic_mode_map_pmic5_smps ,
768819 .of_map_mode = rpmh_regulator_pmic4_smps_of_map_mode ,
@@ -771,7 +822,10 @@ static const struct rpmh_vreg_hw_data pmic5_ftsmps525_mv = {
771822static const struct rpmh_vreg_hw_data pmic5_ftsmps527 = {
772823 .regulator_type = VRM ,
773824 .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 ,
775829 .n_voltages = 215 ,
776830 .pmic_mode_map = pmic_mode_map_pmic5_smps ,
777831 .of_map_mode = rpmh_regulator_pmic4_smps_of_map_mode ,
@@ -780,7 +834,10 @@ static const struct rpmh_vreg_hw_data pmic5_ftsmps527 = {
780834static const struct rpmh_vreg_hw_data pmic5_hfsmps515 = {
781835 .regulator_type = VRM ,
782836 .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 ,
784841 .n_voltages = 236 ,
785842 .pmic_mode_map = pmic_mode_map_pmic5_smps ,
786843 .of_map_mode = rpmh_regulator_pmic4_smps_of_map_mode ,
@@ -789,7 +846,10 @@ static const struct rpmh_vreg_hw_data pmic5_hfsmps515 = {
789846static const struct rpmh_vreg_hw_data pmic5_hfsmps515_1 = {
790847 .regulator_type = VRM ,
791848 .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 ,
793853 .n_voltages = 5 ,
794854 .pmic_mode_map = pmic_mode_map_pmic5_smps ,
795855 .of_map_mode = rpmh_regulator_pmic4_smps_of_map_mode ,
@@ -798,7 +858,10 @@ static const struct rpmh_vreg_hw_data pmic5_hfsmps515_1 = {
798858static const struct rpmh_vreg_hw_data pmic5_bob = {
799859 .regulator_type = VRM ,
800860 .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 ,
802865 .n_voltages = 32 ,
803866 .pmic_mode_map = pmic_mode_map_pmic5_bob ,
804867 .of_map_mode = rpmh_regulator_pmic4_bob_of_map_mode ,
0 commit comments