aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Gong <b38343@freescale.com>2014-03-04 04:40:36 -0500
committerMark Brown <broonie@linaro.org>2014-03-04 04:40:31 -0500
commitf2518480c7b744296a5587990a54e3a284d932b8 (patch)
tree2b03c9778e043b212a88e7bfbe0a254b7c0796b7
parent6428789e11f056d58ed59c0c0aa7d381d0bf50f8 (diff)
regulator: pfuze100: add pfuze200 support
support pfuze200 chip which remove SW1C and SW4 based on pfuze100. Signed-off-by: Robin Gong <b38343@freescale.com> Signed-off-by: Mark Brown <broonie@linaro.org>
-rw-r--r--Documentation/devicetree/bindings/regulator/pfuze100.txt96
-rw-r--r--drivers/regulator/pfuze100-regulator.c196
-rw-r--r--include/linux/regulator/pfuze100.h14
3 files changed, 251 insertions, 55 deletions
diff --git a/Documentation/devicetree/bindings/regulator/pfuze100.txt b/Documentation/devicetree/bindings/regulator/pfuze100.txt
index fc989b2e8057..34ef5d16d0f1 100644
--- a/Documentation/devicetree/bindings/regulator/pfuze100.txt
+++ b/Documentation/devicetree/bindings/regulator/pfuze100.txt
@@ -1,7 +1,7 @@
1PFUZE100 family of regulators 1PFUZE100 family of regulators
2 2
3Required properties: 3Required properties:
4- compatible: "fsl,pfuze100" 4- compatible: "fsl,pfuze100" or "fsl,pfuze200"
5- reg: I2C slave address 5- reg: I2C slave address
6 6
7Required child node: 7Required child node:
@@ -10,11 +10,14 @@ Required child node:
10 Documentation/devicetree/bindings/regulator/regulator.txt. 10 Documentation/devicetree/bindings/regulator/regulator.txt.
11 11
12 The valid names for regulators are: 12 The valid names for regulators are:
13 --PFUZE100
13 sw1ab,sw1c,sw2,sw3a,sw3b,sw4,swbst,vsnvs,vrefddr,vgen1~vgen6 14 sw1ab,sw1c,sw2,sw3a,sw3b,sw4,swbst,vsnvs,vrefddr,vgen1~vgen6
15 --PFUZE200
16 sw1ab,sw2,sw3a,sw3b,swbst,vsnvs,vrefddr,vgen1~vgen6
14 17
15Each regulator is defined using the standard binding for regulators. 18Each regulator is defined using the standard binding for regulators.
16 19
17Example: 20Example 1: PFUZE100
18 21
19 pmic: pfuze100@08 { 22 pmic: pfuze100@08 {
20 compatible = "fsl,pfuze100"; 23 compatible = "fsl,pfuze100";
@@ -113,3 +116,92 @@ Example:
113 }; 116 };
114 }; 117 };
115 }; 118 };
119
120
121Example 2: PFUZE200
122
123 pmic: pfuze200@08 {
124 compatible = "fsl,pfuze200";
125 reg = <0x08>;
126
127 regulators {
128 sw1a_reg: sw1ab {
129 regulator-min-microvolt = <300000>;
130 regulator-max-microvolt = <1875000>;
131 regulator-boot-on;
132 regulator-always-on;
133 regulator-ramp-delay = <6250>;
134 };
135
136 sw2_reg: sw2 {
137 regulator-min-microvolt = <800000>;
138 regulator-max-microvolt = <3300000>;
139 regulator-boot-on;
140 regulator-always-on;
141 };
142
143 sw3a_reg: sw3a {
144 regulator-min-microvolt = <400000>;
145 regulator-max-microvolt = <1975000>;
146 regulator-boot-on;
147 regulator-always-on;
148 };
149
150 sw3b_reg: sw3b {
151 regulator-min-microvolt = <400000>;
152 regulator-max-microvolt = <1975000>;
153 regulator-boot-on;
154 regulator-always-on;
155 };
156
157 swbst_reg: swbst {
158 regulator-min-microvolt = <5000000>;
159 regulator-max-microvolt = <5150000>;
160 };
161
162 snvs_reg: vsnvs {
163 regulator-min-microvolt = <1000000>;
164 regulator-max-microvolt = <3000000>;
165 regulator-boot-on;
166 regulator-always-on;
167 };
168
169 vref_reg: vrefddr {
170 regulator-boot-on;
171 regulator-always-on;
172 };
173
174 vgen1_reg: vgen1 {
175 regulator-min-microvolt = <800000>;
176 regulator-max-microvolt = <1550000>;
177 };
178
179 vgen2_reg: vgen2 {
180 regulator-min-microvolt = <800000>;
181 regulator-max-microvolt = <1550000>;
182 };
183
184 vgen3_reg: vgen3 {
185 regulator-min-microvolt = <1800000>;
186 regulator-max-microvolt = <3300000>;
187 };
188
189 vgen4_reg: vgen4 {
190 regulator-min-microvolt = <1800000>;
191 regulator-max-microvolt = <3300000>;
192 regulator-always-on;
193 };
194
195 vgen5_reg: vgen5 {
196 regulator-min-microvolt = <1800000>;
197 regulator-max-microvolt = <3300000>;
198 regulator-always-on;
199 };
200
201 vgen6_reg: vgen6 {
202 regulator-min-microvolt = <1800000>;
203 regulator-max-microvolt = <3300000>;
204 regulator-always-on;
205 };
206 };
207 };
diff --git a/drivers/regulator/pfuze100-regulator.c b/drivers/regulator/pfuze100-regulator.c
index 371a55374edc..ef330e69336a 100644
--- a/drivers/regulator/pfuze100-regulator.c
+++ b/drivers/regulator/pfuze100-regulator.c
@@ -56,6 +56,8 @@
56#define PFUZE100_VGEN5VOL 0x70 56#define PFUZE100_VGEN5VOL 0x70
57#define PFUZE100_VGEN6VOL 0x71 57#define PFUZE100_VGEN6VOL 0x71
58 58
59enum chips {PFUZE100, PFUZE200, PFUZE_NUM};
60
59struct pfuze_regulator { 61struct pfuze_regulator {
60 struct regulator_desc desc; 62 struct regulator_desc desc;
61 unsigned char stby_reg; 63 unsigned char stby_reg;
@@ -63,6 +65,7 @@ struct pfuze_regulator {
63}; 65};
64 66
65struct pfuze_chip { 67struct pfuze_chip {
68 int chip_id;
66 struct regmap *regmap; 69 struct regmap *regmap;
67 struct device *dev; 70 struct device *dev;
68 struct pfuze_regulator regulator_descs[PFUZE100_MAX_REGULATOR]; 71 struct pfuze_regulator regulator_descs[PFUZE100_MAX_REGULATOR];
@@ -77,15 +80,15 @@ static const int pfuze100_vsnvs[] = {
77 1000000, 1100000, 1200000, 1300000, 1500000, 1800000, 3000000, 80 1000000, 1100000, 1200000, 1300000, 1500000, 1800000, 3000000,
78}; 81};
79 82
80static const struct i2c_device_id pfuze_device_id[] = { 83static const struct i2c_device_id pfuze_device_id[PFUZE_NUM] = {
81 {.name = "pfuze100"}, 84 {.name = "pfuze100", .driver_data = PFUZE100},
82 {}, 85 {.name = "pfuze200", .driver_data = PFUZE200},
83}; 86};
84MODULE_DEVICE_TABLE(i2c, pfuze_device_id); 87MODULE_DEVICE_TABLE(i2c, pfuze_device_id);
85 88
86static const struct of_device_id pfuze_dt_ids[] = { 89static const struct of_device_id pfuze_dt_ids[PFUZE_NUM] = {
87 { .compatible = "fsl,pfuze100" }, 90 { .compatible = "fsl,pfuze100", .data = (void *)PFUZE100},
88 {}, 91 { .compatible = "fsl,pfuze200", .data = (void *)PFUZE200},
89}; 92};
90MODULE_DEVICE_TABLE(of, pfuze_dt_ids); 93MODULE_DEVICE_TABLE(of, pfuze_dt_ids);
91 94
@@ -139,14 +142,14 @@ static struct regulator_ops pfuze100_swb_regulator_ops = {
139 142
140}; 143};
141 144
142#define PFUZE100_FIXED_REG(_name, base, voltage) \ 145#define PFUZE100_FIXED_REG(_chip, _name, base, voltage) \
143 [PFUZE100_ ## _name] = { \ 146 [_chip ## _ ## _name] = { \
144 .desc = { \ 147 .desc = { \
145 .name = #_name, \ 148 .name = #_name, \
146 .n_voltages = 1, \ 149 .n_voltages = 1, \
147 .ops = &pfuze100_fixed_regulator_ops, \ 150 .ops = &pfuze100_fixed_regulator_ops, \
148 .type = REGULATOR_VOLTAGE, \ 151 .type = REGULATOR_VOLTAGE, \
149 .id = PFUZE100_ ## _name, \ 152 .id = _chip ## _ ## _name, \
150 .owner = THIS_MODULE, \ 153 .owner = THIS_MODULE, \
151 .min_uV = (voltage), \ 154 .min_uV = (voltage), \
152 .enable_reg = (base), \ 155 .enable_reg = (base), \
@@ -154,14 +157,14 @@ static struct regulator_ops pfuze100_swb_regulator_ops = {
154 }, \ 157 }, \
155 } 158 }
156 159
157#define PFUZE100_SW_REG(_name, base, min, max, step) \ 160#define PFUZE100_SW_REG(_chip, _name, base, min, max, step) \
158 [PFUZE100_ ## _name] = { \ 161 [_chip ## _ ## _name] = { \
159 .desc = { \ 162 .desc = { \
160 .name = #_name,\ 163 .name = #_name,\
161 .n_voltages = ((max) - (min)) / (step) + 1, \ 164 .n_voltages = ((max) - (min)) / (step) + 1, \
162 .ops = &pfuze100_sw_regulator_ops, \ 165 .ops = &pfuze100_sw_regulator_ops, \
163 .type = REGULATOR_VOLTAGE, \ 166 .type = REGULATOR_VOLTAGE, \
164 .id = PFUZE100_ ## _name, \ 167 .id = _chip ## _ ## _name, \
165 .owner = THIS_MODULE, \ 168 .owner = THIS_MODULE, \
166 .min_uV = (min), \ 169 .min_uV = (min), \
167 .uV_step = (step), \ 170 .uV_step = (step), \
@@ -172,14 +175,14 @@ static struct regulator_ops pfuze100_swb_regulator_ops = {
172 .stby_mask = 0x3f, \ 175 .stby_mask = 0x3f, \
173 } 176 }
174 177
175#define PFUZE100_SWB_REG(_name, base, mask, voltages) \ 178#define PFUZE100_SWB_REG(_chip, _name, base, mask, voltages) \
176 [PFUZE100_ ## _name] = { \ 179 [_chip ## _ ## _name] = { \
177 .desc = { \ 180 .desc = { \
178 .name = #_name, \ 181 .name = #_name, \
179 .n_voltages = ARRAY_SIZE(voltages), \ 182 .n_voltages = ARRAY_SIZE(voltages), \
180 .ops = &pfuze100_swb_regulator_ops, \ 183 .ops = &pfuze100_swb_regulator_ops, \
181 .type = REGULATOR_VOLTAGE, \ 184 .type = REGULATOR_VOLTAGE, \
182 .id = PFUZE100_ ## _name, \ 185 .id = _chip ## _ ## _name, \
183 .owner = THIS_MODULE, \ 186 .owner = THIS_MODULE, \
184 .volt_table = voltages, \ 187 .volt_table = voltages, \
185 .vsel_reg = (base), \ 188 .vsel_reg = (base), \
@@ -187,14 +190,14 @@ static struct regulator_ops pfuze100_swb_regulator_ops = {
187 }, \ 190 }, \
188 } 191 }
189 192
190#define PFUZE100_VGEN_REG(_name, base, min, max, step) \ 193#define PFUZE100_VGEN_REG(_chip, _name, base, min, max, step) \
191 [PFUZE100_ ## _name] = { \ 194 [_chip ## _ ## _name] = { \
192 .desc = { \ 195 .desc = { \
193 .name = #_name, \ 196 .name = #_name, \
194 .n_voltages = ((max) - (min)) / (step) + 1, \ 197 .n_voltages = ((max) - (min)) / (step) + 1, \
195 .ops = &pfuze100_ldo_regulator_ops, \ 198 .ops = &pfuze100_ldo_regulator_ops, \
196 .type = REGULATOR_VOLTAGE, \ 199 .type = REGULATOR_VOLTAGE, \
197 .id = PFUZE100_ ## _name, \ 200 .id = _chip ## _ ## _name, \
198 .owner = THIS_MODULE, \ 201 .owner = THIS_MODULE, \
199 .min_uV = (min), \ 202 .min_uV = (min), \
200 .uV_step = (step), \ 203 .uV_step = (step), \
@@ -207,25 +210,45 @@ static struct regulator_ops pfuze100_swb_regulator_ops = {
207 .stby_mask = 0x20, \ 210 .stby_mask = 0x20, \
208 } 211 }
209 212
213/* PFUZE100 */
210static struct pfuze_regulator pfuze100_regulators[] = { 214static struct pfuze_regulator pfuze100_regulators[] = {
211 PFUZE100_SW_REG(SW1AB, PFUZE100_SW1ABVOL, 300000, 1875000, 25000), 215 PFUZE100_SW_REG(PFUZE100, SW1AB, PFUZE100_SW1ABVOL, 300000, 1875000, 25000),
212 PFUZE100_SW_REG(SW1C, PFUZE100_SW1CVOL, 300000, 1875000, 25000), 216 PFUZE100_SW_REG(PFUZE100, SW1C, PFUZE100_SW1CVOL, 300000, 1875000, 25000),
213 PFUZE100_SW_REG(SW2, PFUZE100_SW2VOL, 400000, 1975000, 25000), 217 PFUZE100_SW_REG(PFUZE100, SW2, PFUZE100_SW2VOL, 400000, 1975000, 25000),
214 PFUZE100_SW_REG(SW3A, PFUZE100_SW3AVOL, 400000, 1975000, 25000), 218 PFUZE100_SW_REG(PFUZE100, SW3A, PFUZE100_SW3AVOL, 400000, 1975000, 25000),
215 PFUZE100_SW_REG(SW3B, PFUZE100_SW3BVOL, 400000, 1975000, 25000), 219 PFUZE100_SW_REG(PFUZE100, SW3B, PFUZE100_SW3BVOL, 400000, 1975000, 25000),
216 PFUZE100_SW_REG(SW4, PFUZE100_SW4VOL, 400000, 1975000, 25000), 220 PFUZE100_SW_REG(PFUZE100, SW4, PFUZE100_SW4VOL, 400000, 1975000, 25000),
217 PFUZE100_SWB_REG(SWBST, PFUZE100_SWBSTCON1, 0x3 , pfuze100_swbst), 221 PFUZE100_SWB_REG(PFUZE100, SWBST, PFUZE100_SWBSTCON1, 0x3 , pfuze100_swbst),
218 PFUZE100_SWB_REG(VSNVS, PFUZE100_VSNVSVOL, 0x7, pfuze100_vsnvs), 222 PFUZE100_SWB_REG(PFUZE100, VSNVS, PFUZE100_VSNVSVOL, 0x7, pfuze100_vsnvs),
219 PFUZE100_FIXED_REG(VREFDDR, PFUZE100_VREFDDRCON, 750000), 223 PFUZE100_FIXED_REG(PFUZE100, VREFDDR, PFUZE100_VREFDDRCON, 750000),
220 PFUZE100_VGEN_REG(VGEN1, PFUZE100_VGEN1VOL, 800000, 1550000, 50000), 224 PFUZE100_VGEN_REG(PFUZE100, VGEN1, PFUZE100_VGEN1VOL, 800000, 1550000, 50000),
221 PFUZE100_VGEN_REG(VGEN2, PFUZE100_VGEN2VOL, 800000, 1550000, 50000), 225 PFUZE100_VGEN_REG(PFUZE100, VGEN2, PFUZE100_VGEN2VOL, 800000, 1550000, 50000),
222 PFUZE100_VGEN_REG(VGEN3, PFUZE100_VGEN3VOL, 1800000, 3300000, 100000), 226 PFUZE100_VGEN_REG(PFUZE100, VGEN3, PFUZE100_VGEN3VOL, 1800000, 3300000, 100000),
223 PFUZE100_VGEN_REG(VGEN4, PFUZE100_VGEN4VOL, 1800000, 3300000, 100000), 227 PFUZE100_VGEN_REG(PFUZE100, VGEN4, PFUZE100_VGEN4VOL, 1800000, 3300000, 100000),
224 PFUZE100_VGEN_REG(VGEN5, PFUZE100_VGEN5VOL, 1800000, 3300000, 100000), 228 PFUZE100_VGEN_REG(PFUZE100, VGEN5, PFUZE100_VGEN5VOL, 1800000, 3300000, 100000),
225 PFUZE100_VGEN_REG(VGEN6, PFUZE100_VGEN6VOL, 1800000, 3300000, 100000), 229 PFUZE100_VGEN_REG(PFUZE100, VGEN6, PFUZE100_VGEN6VOL, 1800000, 3300000, 100000),
230};
231
232static struct pfuze_regulator pfuze200_regulators[] = {
233 PFUZE100_SW_REG(PFUZE200, SW1AB, PFUZE100_SW1ABVOL, 300000, 1875000, 25000),
234 PFUZE100_SW_REG(PFUZE200, SW2, PFUZE100_SW2VOL, 400000, 1975000, 25000),
235 PFUZE100_SW_REG(PFUZE200, SW3A, PFUZE100_SW3AVOL, 400000, 1975000, 25000),
236 PFUZE100_SW_REG(PFUZE200, SW3B, PFUZE100_SW3BVOL, 400000, 1975000, 25000),
237 PFUZE100_SWB_REG(PFUZE200, SWBST, PFUZE100_SWBSTCON1, 0x3 , pfuze100_swbst),
238 PFUZE100_SWB_REG(PFUZE200, VSNVS, PFUZE100_VSNVSVOL, 0x7, pfuze100_vsnvs),
239 PFUZE100_FIXED_REG(PFUZE200, VREFDDR, PFUZE100_VREFDDRCON, 750000),
240 PFUZE100_VGEN_REG(PFUZE200, VGEN1, PFUZE100_VGEN1VOL, 800000, 1550000, 50000),
241 PFUZE100_VGEN_REG(PFUZE200, VGEN2, PFUZE100_VGEN2VOL, 800000, 1550000, 50000),
242 PFUZE100_VGEN_REG(PFUZE200, VGEN3, PFUZE100_VGEN3VOL, 1800000, 3300000, 100000),
243 PFUZE100_VGEN_REG(PFUZE200, VGEN4, PFUZE100_VGEN4VOL, 1800000, 3300000, 100000),
244 PFUZE100_VGEN_REG(PFUZE200, VGEN5, PFUZE100_VGEN5VOL, 1800000, 3300000, 100000),
245 PFUZE100_VGEN_REG(PFUZE200, VGEN6, PFUZE100_VGEN6VOL, 1800000, 3300000, 100000),
226}; 246};
227 247
248static struct pfuze_regulator *pfuze_regulators;
249
228#ifdef CONFIG_OF 250#ifdef CONFIG_OF
251/* PFUZE100 */
229static struct of_regulator_match pfuze100_matches[] = { 252static struct of_regulator_match pfuze100_matches[] = {
230 { .name = "sw1ab", }, 253 { .name = "sw1ab", },
231 { .name = "sw1c", }, 254 { .name = "sw1c", },
@@ -244,6 +267,26 @@ static struct of_regulator_match pfuze100_matches[] = {
244 { .name = "vgen6", }, 267 { .name = "vgen6", },
245}; 268};
246 269
270/* PFUZE200 */
271static struct of_regulator_match pfuze200_matches[] = {
272
273 { .name = "sw1ab", },
274 { .name = "sw2", },
275 { .name = "sw3a", },
276 { .name = "sw3b", },
277 { .name = "swbst", },
278 { .name = "vsnvs", },
279 { .name = "vrefddr", },
280 { .name = "vgen1", },
281 { .name = "vgen2", },
282 { .name = "vgen3", },
283 { .name = "vgen4", },
284 { .name = "vgen5", },
285 { .name = "vgen6", },
286};
287
288static struct of_regulator_match *pfuze_matches;
289
247static int pfuze_parse_regulators_dt(struct pfuze_chip *chip) 290static int pfuze_parse_regulators_dt(struct pfuze_chip *chip)
248{ 291{
249 struct device *dev = chip->dev; 292 struct device *dev = chip->dev;
@@ -260,8 +303,20 @@ static int pfuze_parse_regulators_dt(struct pfuze_chip *chip)
260 return -EINVAL; 303 return -EINVAL;
261 } 304 }
262 305
263 ret = of_regulator_match(dev, parent, pfuze100_matches, 306 switch (chip->chip_id) {
264 ARRAY_SIZE(pfuze100_matches)); 307 case PFUZE200:
308 pfuze_matches = pfuze200_matches;
309 ret = of_regulator_match(dev, parent, pfuze200_matches,
310 ARRAY_SIZE(pfuze200_matches));
311 break;
312
313 case PFUZE100:
314 default:
315 pfuze_matches = pfuze100_matches;
316 ret = of_regulator_match(dev, parent, pfuze100_matches,
317 ARRAY_SIZE(pfuze100_matches));
318 break;
319 }
265 320
266 of_node_put(parent); 321 of_node_put(parent);
267 if (ret < 0) { 322 if (ret < 0) {
@@ -275,12 +330,12 @@ static int pfuze_parse_regulators_dt(struct pfuze_chip *chip)
275 330
276static inline struct regulator_init_data *match_init_data(int index) 331static inline struct regulator_init_data *match_init_data(int index)
277{ 332{
278 return pfuze100_matches[index].init_data; 333 return pfuze_matches[index].init_data;
279} 334}
280 335
281static inline struct device_node *match_of_node(int index) 336static inline struct device_node *match_of_node(int index)
282{ 337{
283 return pfuze100_matches[index].of_node; 338 return pfuze_matches[index].of_node;
284} 339}
285#else 340#else
286static int pfuze_parse_regulators_dt(struct pfuze_chip *chip) 341static int pfuze_parse_regulators_dt(struct pfuze_chip *chip)
@@ -308,16 +363,14 @@ static int pfuze_identify(struct pfuze_chip *pfuze_chip)
308 if (ret) 363 if (ret)
309 return ret; 364 return ret;
310 365
311 switch (value & 0x0f) { 366 if (((value & 0x0f) == 0x8) && (pfuze_chip->chip_id == PFUZE100)) {
312 /* 367 /*
313 * Freescale misprogrammed 1-3% of parts prior to week 8 of 2013 368 * Freescale misprogrammed 1-3% of parts prior to week 8 of 2013
314 * as ID=8 369 * as ID=8 in PFUZE100
315 */ 370 */
316 case 0x8:
317 dev_info(pfuze_chip->dev, "Assuming misprogrammed ID=0x8"); 371 dev_info(pfuze_chip->dev, "Assuming misprogrammed ID=0x8");
318 case 0x0: 372 } else if ((value & 0x0f) != pfuze_chip->chip_id) {
319 break; 373 /* device id NOT match with your setting */
320 default:
321 dev_warn(pfuze_chip->dev, "Illegal ID: %x\n", value); 374 dev_warn(pfuze_chip->dev, "Illegal ID: %x\n", value);
322 return -ENODEV; 375 return -ENODEV;
323 } 376 }
@@ -353,17 +406,31 @@ static int pfuze100_regulator_probe(struct i2c_client *client,
353 dev_get_platdata(&client->dev); 406 dev_get_platdata(&client->dev);
354 struct regulator_config config = { }; 407 struct regulator_config config = { };
355 int i, ret; 408 int i, ret;
409 const struct of_device_id *match;
410 u32 regulator_num;
411 u32 sw_check_start, sw_check_end;
356 412
357 pfuze_chip = devm_kzalloc(&client->dev, sizeof(*pfuze_chip), 413 pfuze_chip = devm_kzalloc(&client->dev, sizeof(*pfuze_chip),
358 GFP_KERNEL); 414 GFP_KERNEL);
359 if (!pfuze_chip) 415 if (!pfuze_chip)
360 return -ENOMEM; 416 return -ENOMEM;
361 417
362 i2c_set_clientdata(client, pfuze_chip); 418 if (client->dev.of_node) {
363 419 match = of_match_device(of_match_ptr(pfuze_dt_ids),
364 memcpy(pfuze_chip->regulator_descs, pfuze100_regulators, 420 &client->dev);
365 sizeof(pfuze_chip->regulator_descs)); 421 if (!match) {
422 dev_err(&client->dev, "Error: No device match found\n");
423 return -ENODEV;
424 }
425 pfuze_chip->chip_id = (int)(long)match->data;
426 } else if (id) {
427 pfuze_chip->chip_id = id->driver_data;
428 } else {
429 dev_err(&client->dev, "No dts match or id table match found\n");
430 return -ENODEV;
431 }
366 432
433 i2c_set_clientdata(client, pfuze_chip);
367 pfuze_chip->dev = &client->dev; 434 pfuze_chip->dev = &client->dev;
368 435
369 pfuze_chip->regmap = devm_regmap_init_i2c(client, &pfuze_regmap_config); 436 pfuze_chip->regmap = devm_regmap_init_i2c(client, &pfuze_regmap_config);
@@ -380,11 +447,34 @@ static int pfuze100_regulator_probe(struct i2c_client *client,
380 return ret; 447 return ret;
381 } 448 }
382 449
450 /* use the right regulators after identify the right device */
451 switch (pfuze_chip->chip_id) {
452 case PFUZE200:
453 pfuze_regulators = pfuze200_regulators;
454 regulator_num = ARRAY_SIZE(pfuze200_regulators);
455 sw_check_start = PFUZE200_SW2;
456 sw_check_end = PFUZE200_SW3B;
457 break;
458
459 case PFUZE100:
460 default:
461 pfuze_regulators = pfuze100_regulators;
462 regulator_num = ARRAY_SIZE(pfuze100_regulators);
463 sw_check_start = PFUZE100_SW2;
464 sw_check_end = PFUZE100_SW4;
465 break;
466 }
467 dev_info(&client->dev, "pfuze%s found.\n",
468 (pfuze_chip->chip_id == PFUZE100) ? "100" : "200");
469
470 memcpy(pfuze_chip->regulator_descs, pfuze_regulators,
471 sizeof(pfuze_chip->regulator_descs));
472
383 ret = pfuze_parse_regulators_dt(pfuze_chip); 473 ret = pfuze_parse_regulators_dt(pfuze_chip);
384 if (ret) 474 if (ret)
385 return ret; 475 return ret;
386 476
387 for (i = 0; i < PFUZE100_MAX_REGULATOR; i++) { 477 for (i = 0; i < regulator_num; i++) {
388 struct regulator_init_data *init_data; 478 struct regulator_init_data *init_data;
389 struct regulator_desc *desc; 479 struct regulator_desc *desc;
390 int val; 480 int val;
@@ -397,7 +487,7 @@ static int pfuze100_regulator_probe(struct i2c_client *client,
397 init_data = match_init_data(i); 487 init_data = match_init_data(i);
398 488
399 /* SW2~SW4 high bit check and modify the voltage value table */ 489 /* SW2~SW4 high bit check and modify the voltage value table */
400 if (i > PFUZE100_SW1C && i < PFUZE100_SWBST) { 490 if (i >= sw_check_start && i <= sw_check_end) {
401 regmap_read(pfuze_chip->regmap, desc->vsel_reg, &val); 491 regmap_read(pfuze_chip->regmap, desc->vsel_reg, &val);
402 if (val & 0x40) { 492 if (val & 0x40) {
403 desc->min_uV = 800000; 493 desc->min_uV = 800000;
@@ -415,7 +505,7 @@ static int pfuze100_regulator_probe(struct i2c_client *client,
415 devm_regulator_register(&client->dev, desc, &config); 505 devm_regulator_register(&client->dev, desc, &config);
416 if (IS_ERR(pfuze_chip->regulators[i])) { 506 if (IS_ERR(pfuze_chip->regulators[i])) {
417 dev_err(&client->dev, "register regulator%s failed\n", 507 dev_err(&client->dev, "register regulator%s failed\n",
418 pfuze100_regulators[i].desc.name); 508 pfuze_regulators[i].desc.name);
419 return PTR_ERR(pfuze_chip->regulators[i]); 509 return PTR_ERR(pfuze_chip->regulators[i]);
420 } 510 }
421 } 511 }
diff --git a/include/linux/regulator/pfuze100.h b/include/linux/regulator/pfuze100.h
index 65d550bf3954..364f7a7c43db 100644
--- a/include/linux/regulator/pfuze100.h
+++ b/include/linux/regulator/pfuze100.h
@@ -35,6 +35,20 @@
35#define PFUZE100_VGEN6 14 35#define PFUZE100_VGEN6 14
36#define PFUZE100_MAX_REGULATOR 15 36#define PFUZE100_MAX_REGULATOR 15
37 37
38#define PFUZE200_SW1AB 0
39#define PFUZE200_SW2 1
40#define PFUZE200_SW3A 2
41#define PFUZE200_SW3B 3
42#define PFUZE200_SWBST 4
43#define PFUZE200_VSNVS 5
44#define PFUZE200_VREFDDR 6
45#define PFUZE200_VGEN1 7
46#define PFUZE200_VGEN2 8
47#define PFUZE200_VGEN3 9
48#define PFUZE200_VGEN4 10
49#define PFUZE200_VGEN5 11
50#define PFUZE200_VGEN6 12
51
38struct regulator_init_data; 52struct regulator_init_data;
39 53
40struct pfuze_regulator_platform_data { 54struct pfuze_regulator_platform_data {