forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-31 f70575805708cabdedea7498aaa3f710fde4d920
kernel/drivers/regulator/qcom_rpm-regulator.c
....@@ -1,15 +1,7 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright (c) 2014, Sony Mobile Communications AB.
34 * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
4
- *
5
- * This program is free software; you can redistribute it and/or modify
6
- * it under the terms of the GNU General Public License version 2 and
7
- * only version 2 as published by the Free Software Foundation.
8
- *
9
- * This program is distributed in the hope that it will be useful,
10
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
- * GNU General Public License for more details.
135 */
146
157 #include <linux/module.h>
....@@ -156,41 +148,41 @@
156148 /*
157149 * Physically available PMIC regulator voltage ranges
158150 */
159
-static const struct regulator_linear_range pldo_ranges[] = {
151
+static const struct linear_range pldo_ranges[] = {
160152 REGULATOR_LINEAR_RANGE( 750000, 0, 59, 12500),
161153 REGULATOR_LINEAR_RANGE(1500000, 60, 123, 25000),
162154 REGULATOR_LINEAR_RANGE(3100000, 124, 160, 50000),
163155 };
164156
165
-static const struct regulator_linear_range nldo_ranges[] = {
157
+static const struct linear_range nldo_ranges[] = {
166158 REGULATOR_LINEAR_RANGE( 750000, 0, 63, 12500),
167159 };
168160
169
-static const struct regulator_linear_range nldo1200_ranges[] = {
161
+static const struct linear_range nldo1200_ranges[] = {
170162 REGULATOR_LINEAR_RANGE( 375000, 0, 59, 6250),
171163 REGULATOR_LINEAR_RANGE( 750000, 60, 123, 12500),
172164 };
173165
174
-static const struct regulator_linear_range smps_ranges[] = {
166
+static const struct linear_range smps_ranges[] = {
175167 REGULATOR_LINEAR_RANGE( 375000, 0, 29, 12500),
176168 REGULATOR_LINEAR_RANGE( 750000, 30, 89, 12500),
177169 REGULATOR_LINEAR_RANGE(1500000, 90, 153, 25000),
178170 };
179171
180
-static const struct regulator_linear_range ftsmps_ranges[] = {
172
+static const struct linear_range ftsmps_ranges[] = {
181173 REGULATOR_LINEAR_RANGE( 350000, 0, 6, 50000),
182174 REGULATOR_LINEAR_RANGE( 700000, 7, 63, 12500),
183175 REGULATOR_LINEAR_RANGE(1500000, 64, 100, 50000),
184176 };
185177
186
-static const struct regulator_linear_range smb208_ranges[] = {
178
+static const struct linear_range smb208_ranges[] = {
187179 REGULATOR_LINEAR_RANGE( 375000, 0, 29, 12500),
188180 REGULATOR_LINEAR_RANGE( 750000, 30, 89, 12500),
189181 REGULATOR_LINEAR_RANGE(1500000, 90, 153, 25000),
190182 REGULATOR_LINEAR_RANGE(3100000, 154, 234, 25000),
191183 };
192184
193
-static const struct regulator_linear_range ncp_ranges[] = {
185
+static const struct linear_range ncp_ranges[] = {
194186 REGULATOR_LINEAR_RANGE(1500000, 0, 31, 50000),
195187 };
196188
....@@ -415,7 +407,7 @@
415407 return ret;
416408 }
417409
418
-static struct regulator_ops uV_ops = {
410
+static const struct regulator_ops uV_ops = {
419411 .list_voltage = regulator_list_voltage_linear_range,
420412
421413 .set_voltage_sel = rpm_reg_set_uV_sel,
....@@ -428,7 +420,7 @@
428420 .set_load = rpm_reg_set_load,
429421 };
430422
431
-static struct regulator_ops mV_ops = {
423
+static const struct regulator_ops mV_ops = {
432424 .list_voltage = regulator_list_voltage_linear_range,
433425
434426 .set_voltage_sel = rpm_reg_set_mV_sel,
....@@ -441,7 +433,7 @@
441433 .set_load = rpm_reg_set_load,
442434 };
443435
444
-static struct regulator_ops switch_ops = {
436
+static const struct regulator_ops switch_ops = {
445437 .enable = rpm_reg_switch_enable,
446438 .disable = rpm_reg_switch_disable,
447439 .is_enabled = rpm_reg_is_enabled,
....@@ -606,16 +598,6 @@
606598 .desc.linear_ranges = smps_ranges,
607599 .desc.n_linear_ranges = ARRAY_SIZE(smps_ranges),
608600 .desc.n_voltages = 154,
609
- .desc.ops = &uV_ops,
610
- .parts = &rpm8960_smps_parts,
611
- .supports_force_mode_auto = true,
612
- .supports_force_mode_bypass = false,
613
-};
614
-
615
-static const struct qcom_rpm_reg pm8921_ftsmps = {
616
- .desc.linear_ranges = ftsmps_ranges,
617
- .desc.n_linear_ranges = ARRAY_SIZE(ftsmps_ranges),
618
- .desc.n_voltages = 101,
619601 .desc.ops = &uV_ops,
620602 .parts = &rpm8960_smps_parts,
621603 .supports_force_mode_auto = true,
....@@ -820,6 +802,12 @@
820802 };
821803
822804 static const struct rpm_regulator_data rpm_pm8058_regulators[] = {
805
+ { "s0", QCOM_RPM_PM8058_SMPS0, &pm8058_smps, "vdd_s0" },
806
+ { "s1", QCOM_RPM_PM8058_SMPS1, &pm8058_smps, "vdd_s1" },
807
+ { "s2", QCOM_RPM_PM8058_SMPS2, &pm8058_smps, "vdd_s2" },
808
+ { "s3", QCOM_RPM_PM8058_SMPS3, &pm8058_smps, "vdd_s3" },
809
+ { "s4", QCOM_RPM_PM8058_SMPS4, &pm8058_smps, "vdd_s4" },
810
+
823811 { "l0", QCOM_RPM_PM8058_LDO0, &pm8058_nldo, "vdd_l0_l1_lvs" },
824812 { "l1", QCOM_RPM_PM8058_LDO1, &pm8058_nldo, "vdd_l0_l1_lvs" },
825813 { "l2", QCOM_RPM_PM8058_LDO2, &pm8058_pldo, "vdd_l2_l11_l12" },
....@@ -847,12 +835,6 @@
847835 { "l24", QCOM_RPM_PM8058_LDO24, &pm8058_nldo, "vdd_l23_l24_l25" },
848836 { "l25", QCOM_RPM_PM8058_LDO25, &pm8058_nldo, "vdd_l23_l24_l25" },
849837
850
- { "s0", QCOM_RPM_PM8058_SMPS0, &pm8058_smps, "vdd_s0" },
851
- { "s1", QCOM_RPM_PM8058_SMPS1, &pm8058_smps, "vdd_s1" },
852
- { "s2", QCOM_RPM_PM8058_SMPS2, &pm8058_smps, "vdd_s2" },
853
- { "s3", QCOM_RPM_PM8058_SMPS3, &pm8058_smps, "vdd_s3" },
854
- { "s4", QCOM_RPM_PM8058_SMPS4, &pm8058_smps, "vdd_s4" },
855
-
856838 { "lvs0", QCOM_RPM_PM8058_LVS0, &pm8058_switch, "vdd_l0_l1_lvs" },
857839 { "lvs1", QCOM_RPM_PM8058_LVS1, &pm8058_switch, "vdd_l0_l1_lvs" },
858840
....@@ -861,6 +843,12 @@
861843 };
862844
863845 static const struct rpm_regulator_data rpm_pm8901_regulators[] = {
846
+ { "s0", QCOM_RPM_PM8901_SMPS0, &pm8901_ftsmps, "vdd_s0" },
847
+ { "s1", QCOM_RPM_PM8901_SMPS1, &pm8901_ftsmps, "vdd_s1" },
848
+ { "s2", QCOM_RPM_PM8901_SMPS2, &pm8901_ftsmps, "vdd_s2" },
849
+ { "s3", QCOM_RPM_PM8901_SMPS3, &pm8901_ftsmps, "vdd_s3" },
850
+ { "s4", QCOM_RPM_PM8901_SMPS4, &pm8901_ftsmps, "vdd_s4" },
851
+
864852 { "l0", QCOM_RPM_PM8901_LDO0, &pm8901_nldo, "vdd_l0" },
865853 { "l1", QCOM_RPM_PM8901_LDO1, &pm8901_pldo, "vdd_l1" },
866854 { "l2", QCOM_RPM_PM8901_LDO2, &pm8901_pldo, "vdd_l2" },
....@@ -868,12 +856,6 @@
868856 { "l4", QCOM_RPM_PM8901_LDO4, &pm8901_pldo, "vdd_l4" },
869857 { "l5", QCOM_RPM_PM8901_LDO5, &pm8901_pldo, "vdd_l5" },
870858 { "l6", QCOM_RPM_PM8901_LDO6, &pm8901_pldo, "vdd_l6" },
871
-
872
- { "s0", QCOM_RPM_PM8901_SMPS0, &pm8901_ftsmps, "vdd_s0" },
873
- { "s1", QCOM_RPM_PM8901_SMPS1, &pm8901_ftsmps, "vdd_s1" },
874
- { "s2", QCOM_RPM_PM8901_SMPS2, &pm8901_ftsmps, "vdd_s2" },
875
- { "s3", QCOM_RPM_PM8901_SMPS3, &pm8901_ftsmps, "vdd_s3" },
876
- { "s4", QCOM_RPM_PM8901_SMPS4, &pm8901_ftsmps, "vdd_s4" },
877859
878860 { "lvs0", QCOM_RPM_PM8901_LVS0, &pm8901_switch, "lvs0_in" },
879861 { "lvs1", QCOM_RPM_PM8901_LVS1, &pm8901_switch, "lvs1_in" },
....@@ -933,12 +915,21 @@
933915 { }
934916 };
935917
918
+static const struct rpm_regulator_data rpm_smb208_regulators[] = {
919
+ { "s1a", QCOM_RPM_SMB208_S1a, &smb208_smps, "vin_s1a" },
920
+ { "s1b", QCOM_RPM_SMB208_S1b, &smb208_smps, "vin_s1b" },
921
+ { "s2a", QCOM_RPM_SMB208_S2a, &smb208_smps, "vin_s2a" },
922
+ { "s2b", QCOM_RPM_SMB208_S2b, &smb208_smps, "vin_s2b" },
923
+ { }
924
+};
925
+
936926 static const struct of_device_id rpm_of_match[] = {
937927 { .compatible = "qcom,rpm-pm8018-regulators",
938928 .data = &rpm_pm8018_regulators },
939929 { .compatible = "qcom,rpm-pm8058-regulators", .data = &rpm_pm8058_regulators },
940930 { .compatible = "qcom,rpm-pm8901-regulators", .data = &rpm_pm8901_regulators },
941931 { .compatible = "qcom,rpm-pm8921-regulators", .data = &rpm_pm8921_regulators },
932
+ { .compatible = "qcom,rpm-smb208-regulators", .data = &rpm_smb208_regulators },
942933 { }
943934 };
944935 MODULE_DEVICE_TABLE(of, rpm_of_match);