hc
2024-05-10 9999e48639b3cecb08ffb37358bcba3b48161b29
kernel/drivers/regulator/mt6397-regulator.c
....@@ -1,16 +1,7 @@
1
-/*
2
- * Copyright (c) 2014 MediaTek Inc.
3
- * Author: Flora Fu <flora.fu@mediatek.com>
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 as
7
- * 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.
13
- */
1
+// SPDX-License-Identifier: GPL-2.0
2
+//
3
+// Copyright (c) 2014 MediaTek Inc.
4
+// Author: Flora Fu <flora.fu@mediatek.com>
145
156 #include <linux/module.h>
167 #include <linux/of.h>
....@@ -22,9 +13,7 @@
2213 #include <linux/regulator/machine.h>
2314 #include <linux/regulator/mt6397-regulator.h>
2415 #include <linux/regulator/of_regulator.h>
25
-
26
-#define MT6397_BUCK_MODE_AUTO 0
27
-#define MT6397_BUCK_MODE_FORCE_PWM 1
16
+#include <dt-bindings/regulator/mediatek,mt6397-regulator.h>
2817
2918 /*
3019 * MT6397 regulators' information
....@@ -64,6 +53,7 @@
6453 .vsel_mask = vosel_mask, \
6554 .enable_reg = enreg, \
6655 .enable_mask = BIT(0), \
56
+ .of_map_mode = mt6397_map_mode, \
6757 }, \
6858 .qi = BIT(13), \
6959 .vselon_reg = voselon, \
....@@ -111,50 +101,62 @@
111101 .qi = BIT(15), \
112102 }
113103
114
-static const struct regulator_linear_range buck_volt_range1[] = {
104
+static const struct linear_range buck_volt_range1[] = {
115105 REGULATOR_LINEAR_RANGE(700000, 0, 0x7f, 6250),
116106 };
117107
118
-static const struct regulator_linear_range buck_volt_range2[] = {
108
+static const struct linear_range buck_volt_range2[] = {
119109 REGULATOR_LINEAR_RANGE(800000, 0, 0x7f, 6250),
120110 };
121111
122
-static const struct regulator_linear_range buck_volt_range3[] = {
112
+static const struct linear_range buck_volt_range3[] = {
123113 REGULATOR_LINEAR_RANGE(1500000, 0, 0x1f, 20000),
124114 };
125115
126
-static const u32 ldo_volt_table1[] = {
116
+static const unsigned int ldo_volt_table1[] = {
127117 1500000, 1800000, 2500000, 2800000,
128118 };
129119
130
-static const u32 ldo_volt_table2[] = {
120
+static const unsigned int ldo_volt_table2[] = {
131121 1800000, 3300000,
132122 };
133123
134
-static const u32 ldo_volt_table3[] = {
124
+static const unsigned int ldo_volt_table3[] = {
135125 3000000, 3300000,
136126 };
137127
138
-static const u32 ldo_volt_table4[] = {
128
+static const unsigned int ldo_volt_table4[] = {
139129 1220000, 1300000, 1500000, 1800000, 2500000, 2800000, 3000000, 3300000,
140130 };
141131
142
-static const u32 ldo_volt_table5[] = {
132
+static const unsigned int ldo_volt_table5[] = {
143133 1200000, 1300000, 1500000, 1800000, 2500000, 2800000, 3000000, 3300000,
144134 };
145135
146
-static const u32 ldo_volt_table5_v2[] = {
136
+static const unsigned int ldo_volt_table5_v2[] = {
147137 1200000, 1000000, 1500000, 1800000, 2500000, 2800000, 3000000, 3300000,
148138 };
149139
150
-static const u32 ldo_volt_table6[] = {
140
+static const unsigned int ldo_volt_table6[] = {
151141 1200000, 1300000, 1500000, 1800000, 2500000, 2800000, 3000000, 2000000,
152142 };
153143
154
-static const u32 ldo_volt_table7[] = {
144
+static const unsigned int ldo_volt_table7[] = {
155145 1300000, 1500000, 1800000, 2000000, 2500000, 2800000, 3000000, 3300000,
156146 };
157147
148
+static unsigned int mt6397_map_mode(unsigned int mode)
149
+{
150
+ switch (mode) {
151
+ case MT6397_BUCK_MODE_AUTO:
152
+ return REGULATOR_MODE_NORMAL;
153
+ case MT6397_BUCK_MODE_FORCE_PWM:
154
+ return REGULATOR_MODE_FAST;
155
+ default:
156
+ return REGULATOR_MODE_INVALID;
157
+ }
158
+}
159
+
158160 static int mt6397_regulator_set_mode(struct regulator_dev *rdev,
159161 unsigned int mode)
160162 {