forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-02-20 ea08eeccae9297f7aabd2ef7f0c2517ac4549acc
kernel/drivers/regulator/rk808-regulator.c
....@@ -1,5 +1,6 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
2
- * Regulator driver for Rockchip RK808/RK818
3
+ * Regulator driver for Rockchip RK805/RK808/RK818
34 *
45 * Copyright (c) 2014, Fuzhou Rockchip Electronics Co., Ltd
56 *
....@@ -9,15 +10,6 @@
910 * Copyright (C) 2016 PHYTEC Messtechnik GmbH
1011 *
1112 * Author: Wadim Egorov <w.egorov@phytec.de>
12
- *
13
- * This program is free software; you can redistribute it and/or modify it
14
- * under the terms and conditions of the GNU General Public License,
15
- * version 2, as published by the Free Software Foundation.
16
- *
17
- * This program is distributed in the hope it will be useful, but WITHOUT
18
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
19
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
20
- * more details.
2113 */
2214
2315 #include <linux/delay.h>
....@@ -36,16 +28,16 @@
3628 #define RK808_BUCK4_VSEL_MASK 0xf
3729 #define RK808_LDO_VSEL_MASK 0x1f
3830
39
-#define RK809_BUCK5_VSEL_MASK 0x7
31
+#define RK809_BUCK5_VSEL_MASK 0x7
32
+
33
+#define RK817_LDO_VSEL_MASK 0x7f
34
+#define RK817_BOOST_VSEL_MASK 0x7
35
+#define RK817_BUCK_VSEL_MASK 0x7f
4036
4137 #define RK816_DCDC_SLP_EN_REG_OFFSET 2
4238 #define RK816_SWITCH_SLP_EN_REG_OFFSET 1
4339 #define RK816_LDO1_4_SLP_EN_REG_OFFSET 1
4440 #define RK816_LDO5_6_SLP_EN_REG_OFFSET 2
45
-
46
-#define RK817_LDO_VSEL_MASK 0x7f
47
-#define RK817_BOOST_VSEL_MASK 0x7
48
-#define RK817_BUCK_VSEL_MASK 0x7f
4941
5042 #define RK818_BUCK_VSEL_MASK 0x3f
5143 #define RK818_BUCK4_VSEL_MASK 0x1f
....@@ -183,36 +175,36 @@
183175 RK808_BUCK4_CONFIG_REG,
184176 };
185177
186
-static const struct regulator_linear_range rk805_buck_1_2_voltage_ranges[] = {
178
+static const struct linear_range rk805_buck_1_2_voltage_ranges[] = {
187179 REGULATOR_LINEAR_RANGE(712500, 0, 59, 12500), /* 0.7125v - 1.45v */
188180 REGULATOR_LINEAR_RANGE(1800000, 60, 62, 200000),/* 1.8v - 2.2v */
189181 REGULATOR_LINEAR_RANGE(2300000, 63, 63, 0), /* 2.3v - 2.3v */
190182 };
191183
192
-static const struct regulator_linear_range rk805_buck4_voltage_ranges[] = {
184
+static const struct linear_range rk805_buck4_voltage_ranges[] = {
193185 REGULATOR_LINEAR_RANGE(800000, 0, 26, 100000), /* 0.8v - 3.4v */
194186 REGULATOR_LINEAR_RANGE(3500000, 27, 31, 0), /* 3.5v */
195187 };
196188
197
-static const struct regulator_linear_range rk808_ldo3_voltage_ranges[] = {
189
+static const struct linear_range rk808_ldo3_voltage_ranges[] = {
198190 REGULATOR_LINEAR_RANGE(800000, 0, 13, 100000),
199191 REGULATOR_LINEAR_RANGE(2500000, 15, 15, 0),
200192 };
201193
202
-static const struct regulator_linear_range rk816_buck_voltage_ranges[] = {
194
+static const struct linear_range rk816_buck_voltage_ranges[] = {
203195 REGULATOR_LINEAR_RANGE(712500, 0, 59, 12500), /* 0.7125v - 1.45v */
204196 REGULATOR_LINEAR_RANGE(1800000, 60, 62, 200000),/* 1.8v - 2.2v */
205197 REGULATOR_LINEAR_RANGE(2300000, 63, 63, 0), /* 2.3v - 2.3v */
206198 };
207199
208
-static const struct regulator_linear_range rk816_buck4_voltage_ranges[] = {
200
+static const struct linear_range rk816_buck4_voltage_ranges[] = {
209201 REGULATOR_LINEAR_RANGE(800000, 0, 26, 100000), /* 0.8v - 3.4 */
210202 REGULATOR_LINEAR_RANGE(3500000, 27, 31, 0), /* 3.5v */
211203 };
212204
213205 #define RK809_BUCK5_SEL_CNT (8)
214206
215
-static const struct regulator_linear_range rk809_buck5_voltage_ranges[] = {
207
+static const struct linear_range rk809_buck5_voltage_ranges[] = {
216208 REGULATOR_LINEAR_RANGE(1500000, 0, 0, 0),
217209 REGULATOR_LINEAR_RANGE(1800000, 1, 3, 200000),
218210 REGULATOR_LINEAR_RANGE(2800000, 4, 5, 200000),
....@@ -241,14 +233,14 @@
241233 #define RK817_BUCK1_SEL_CNT (RK817_BUCK1_SEL0 + RK817_BUCK1_SEL1 + 1)
242234 #define RK817_BUCK3_SEL_CNT (RK817_BUCK1_SEL0 + RK817_BUCK3_SEL1 + 1)
243235
244
-static const struct regulator_linear_range rk817_buck1_voltage_ranges[] = {
236
+static const struct linear_range rk817_buck1_voltage_ranges[] = {
245237 REGULATOR_LINEAR_RANGE(RK817_BUCK1_MIN0, 0,
246238 RK817_BUCK1_SEL0, RK817_BUCK1_STP0),
247239 REGULATOR_LINEAR_RANGE(RK817_BUCK1_MIN1, RK817_BUCK1_SEL0 + 1,
248240 RK817_BUCK1_SEL_CNT, RK817_BUCK1_STP1),
249241 };
250242
251
-static const struct regulator_linear_range rk817_buck3_voltage_ranges[] = {
243
+static const struct linear_range rk817_buck3_voltage_ranges[] = {
252244 REGULATOR_LINEAR_RANGE(RK817_BUCK1_MIN0, 0,
253245 RK817_BUCK1_SEL0, RK817_BUCK1_STP0),
254246 REGULATOR_LINEAR_RANGE(RK817_BUCK1_MIN1, RK817_BUCK1_SEL0 + 1,
....@@ -327,7 +319,7 @@
327319 return ret;
328320 }
329321
330
-#ifdef CONFIG_CPU_RK312X
322
+#ifdef CONFIG_CLK_RK312X
331323 extern void rkclk_cpuclk_div_setting(int div);
332324 #else
333325 static inline void rkclk_cpuclk_div_setting(int div) {}
....@@ -517,7 +509,7 @@
517509 break;
518510 default:
519511 dev_warn(&rdev->dev,
520
- "%s ramp_delay: %d not supported, setting 10000\n",
512
+ "%s ramp_delay: %d not supported, setting 25000\n",
521513 rdev->desc->name, ramp_delay);
522514 }
523515
....@@ -530,21 +522,6 @@
530522 unsigned int reg;
531523 int sel = regulator_map_voltage_linear(rdev, uv, uv);
532524
533
- if (sel < 0)
534
- return -EINVAL;
535
-
536
- reg = rdev->desc->vsel_reg + RK808_SLP_REG_OFFSET;
537
-
538
- return regmap_update_bits(rdev->regmap, reg,
539
- rdev->desc->vsel_mask,
540
- sel);
541
-}
542
-
543
-static int rk817_set_suspend_voltage(struct regulator_dev *rdev, int uv)
544
-{
545
- unsigned int reg;
546
- int sel = regulator_map_voltage_linear(rdev, uv, uv);
547
- /* only ldo1~ldo9 */
548525 if (sel < 0)
549526 return -EINVAL;
550527
....@@ -811,7 +788,7 @@
811788 case 2:
812789 return REGULATOR_MODE_NORMAL;
813790 default:
814
- return -EINVAL;
791
+ return REGULATOR_MODE_INVALID;
815792 }
816793 }
817794
....@@ -891,7 +868,7 @@
891868 .set_suspend_disable = rk808_set_suspend_disable,
892869 };
893870
894
-static struct regulator_ops rk809_buck5_ops_range = {
871
+static const struct regulator_ops rk809_buck5_ops_range = {
895872 .list_voltage = regulator_list_voltage_linear_range,
896873 .map_voltage = regulator_map_voltage_linear_range,
897874 .get_voltage_sel = regulator_get_voltage_sel_regmap,
....@@ -905,7 +882,7 @@
905882 .set_suspend_disable = rk817_set_suspend_disable,
906883 };
907884
908
-static struct regulator_ops rk817_reg_ops = {
885
+static const struct regulator_ops rk817_reg_ops = {
909886 .list_voltage = regulator_list_voltage_linear,
910887 .map_voltage = regulator_map_voltage_linear,
911888 .get_voltage_sel = regulator_get_voltage_sel_regmap,
....@@ -913,12 +890,12 @@
913890 .enable = rk8xx_enabled_wmsk_regmap,
914891 .disable = rk8xx_disabled_wmsk_regmap,
915892 .is_enabled = rk8xx_is_enabled_wmsk_regmap,
916
- .set_suspend_voltage = rk817_set_suspend_voltage,
893
+ .set_suspend_voltage = rk808_set_suspend_voltage,
917894 .set_suspend_enable = rk817_set_suspend_enable,
918895 .set_suspend_disable = rk817_set_suspend_disable,
919896 };
920897
921
-static struct regulator_ops rk817_boost_ops = {
898
+static const struct regulator_ops rk817_boost_ops = {
922899 .list_voltage = regulator_list_voltage_linear,
923900 .map_voltage = regulator_map_voltage_linear,
924901 .get_voltage_sel = regulator_get_voltage_sel_regmap,
....@@ -930,7 +907,7 @@
930907 .set_suspend_disable = rk817_set_suspend_disable,
931908 };
932909
933
-static struct regulator_ops rk817_buck_ops_range = {
910
+static const struct regulator_ops rk817_buck_ops_range = {
934911 .list_voltage = regulator_list_voltage_linear_range,
935912 .map_voltage = regulator_map_voltage_linear_range,
936913 .get_voltage_sel = regulator_get_voltage_sel_regmap,
....@@ -948,7 +925,7 @@
948925 .set_suspend_disable = rk817_set_suspend_disable,
949926 };
950927
951
-static struct regulator_ops rk817_switch_ops = {
928
+static const struct regulator_ops rk817_switch_ops = {
952929 .enable = rk8xx_enabled_wmsk_regmap,
953930 .disable = rk8xx_disabled_wmsk_regmap,
954931 .is_enabled = rk8xx_is_enabled_wmsk_regmap,
....@@ -1135,7 +1112,6 @@
11351112 RK8XX_DESC_SWITCH(RK808_ID_SWITCH2, "SWITCH_REG2", "vcc12",
11361113 RK808_DCDC_EN_REG, BIT(6)),
11371114 };
1138
-
11391115
11401116 static const struct regulator_desc rk816_reg[] = {
11411117 {
....@@ -1730,7 +1706,7 @@
17301706 module_platform_driver(rk808_regulator_driver);
17311707 #endif
17321708
1733
-MODULE_DESCRIPTION("regulator driver for the RK805/RK808/RK809/RK817/RK818 series PMICs");
1709
+MODULE_DESCRIPTION("regulator driver for the RK805/RK808/RK816/RK818 series PMICs");
17341710 MODULE_AUTHOR("Tony xie <tony.xie@rock-chips.com>");
17351711 MODULE_AUTHOR("Chris Zhong <zyw@rock-chips.com>");
17361712 MODULE_AUTHOR("Zhang Qing <zhangqing@rock-chips.com>");