diff options
-rw-r--r-- | Documentation/devicetree/bindings/regulator/fan53555.txt | 2 | ||||
-rw-r--r-- | Documentation/devicetree/bindings/vendor-prefixes.txt | 1 | ||||
-rw-r--r-- | drivers/regulator/fan53555.c | 102 |
3 files changed, 89 insertions, 16 deletions
diff --git a/Documentation/devicetree/bindings/regulator/fan53555.txt b/Documentation/devicetree/bindings/regulator/fan53555.txt index b183738d6ca9..54a3f2c80e3a 100644 --- a/Documentation/devicetree/bindings/regulator/fan53555.txt +++ b/Documentation/devicetree/bindings/regulator/fan53555.txt | |||
@@ -1,7 +1,7 @@ | |||
1 | Binding for Fairchild FAN53555 regulators | 1 | Binding for Fairchild FAN53555 regulators |
2 | 2 | ||
3 | Required properties: | 3 | Required properties: |
4 | - compatible: "fcs,fan53555" | 4 | - compatible: one of "fcs,fan53555", "silergy,syr827", "silergy,syr828" |
5 | - reg: I2C address | 5 | - reg: I2C address |
6 | 6 | ||
7 | Optional properties: | 7 | Optional properties: |
diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt b/Documentation/devicetree/bindings/vendor-prefixes.txt index 24b92b31f2b5..6073e76575ea 100644 --- a/Documentation/devicetree/bindings/vendor-prefixes.txt +++ b/Documentation/devicetree/bindings/vendor-prefixes.txt | |||
@@ -125,6 +125,7 @@ sil Silicon Image | |||
125 | silabs Silicon Laboratories | 125 | silabs Silicon Laboratories |
126 | simtek | 126 | simtek |
127 | sii Seiko Instruments, Inc. | 127 | sii Seiko Instruments, Inc. |
128 | silergy Silergy Corp. | ||
128 | sirf SiRF Technology, Inc. | 129 | sirf SiRF Technology, Inc. |
129 | smsc Standard Microsystems Corporation | 130 | smsc Standard Microsystems Corporation |
130 | snps Synopsys, Inc. | 131 | snps Synopsys, Inc. |
diff --git a/drivers/regulator/fan53555.c b/drivers/regulator/fan53555.c index fa29ba052841..f2f5535099a0 100644 --- a/drivers/regulator/fan53555.c +++ b/drivers/regulator/fan53555.c | |||
@@ -52,6 +52,11 @@ | |||
52 | 52 | ||
53 | #define FAN53555_NVOLTAGES 64 /* Numbers of voltages */ | 53 | #define FAN53555_NVOLTAGES 64 /* Numbers of voltages */ |
54 | 54 | ||
55 | enum fan53555_vendor { | ||
56 | FAN53555_VENDOR_FAIRCHILD = 0, | ||
57 | FAN53555_VENDOR_SILERGY, | ||
58 | }; | ||
59 | |||
55 | /* IC Type */ | 60 | /* IC Type */ |
56 | enum { | 61 | enum { |
57 | FAN53555_CHIP_ID_00 = 0, | 62 | FAN53555_CHIP_ID_00 = 0, |
@@ -62,7 +67,12 @@ enum { | |||
62 | FAN53555_CHIP_ID_05, | 67 | FAN53555_CHIP_ID_05, |
63 | }; | 68 | }; |
64 | 69 | ||
70 | enum { | ||
71 | SILERGY_SYR82X = 8, | ||
72 | }; | ||
73 | |||
65 | struct fan53555_device_info { | 74 | struct fan53555_device_info { |
75 | enum fan53555_vendor vendor; | ||
66 | struct regmap *regmap; | 76 | struct regmap *regmap; |
67 | struct device *dev; | 77 | struct device *dev; |
68 | struct regulator_desc desc; | 78 | struct regulator_desc desc; |
@@ -183,6 +193,47 @@ static struct regulator_ops fan53555_regulator_ops = { | |||
183 | .set_ramp_delay = fan53555_set_ramp, | 193 | .set_ramp_delay = fan53555_set_ramp, |
184 | }; | 194 | }; |
185 | 195 | ||
196 | static int fan53555_voltages_setup_fairchild(struct fan53555_device_info *di) | ||
197 | { | ||
198 | /* Init voltage range and step */ | ||
199 | switch (di->chip_id) { | ||
200 | case FAN53555_CHIP_ID_00: | ||
201 | case FAN53555_CHIP_ID_01: | ||
202 | case FAN53555_CHIP_ID_03: | ||
203 | case FAN53555_CHIP_ID_05: | ||
204 | di->vsel_min = 600000; | ||
205 | di->vsel_step = 10000; | ||
206 | break; | ||
207 | case FAN53555_CHIP_ID_04: | ||
208 | di->vsel_min = 603000; | ||
209 | di->vsel_step = 12826; | ||
210 | break; | ||
211 | default: | ||
212 | dev_err(di->dev, | ||
213 | "Chip ID %d not supported!\n", di->chip_id); | ||
214 | return -EINVAL; | ||
215 | } | ||
216 | |||
217 | return 0; | ||
218 | } | ||
219 | |||
220 | static int fan53555_voltages_setup_silergy(struct fan53555_device_info *di) | ||
221 | { | ||
222 | /* Init voltage range and step */ | ||
223 | switch (di->chip_id) { | ||
224 | case SILERGY_SYR82X: | ||
225 | di->vsel_min = 712500; | ||
226 | di->vsel_step = 12500; | ||
227 | break; | ||
228 | default: | ||
229 | dev_err(di->dev, | ||
230 | "Chip ID %d not supported!\n", di->chip_id); | ||
231 | return -EINVAL; | ||
232 | } | ||
233 | |||
234 | return 0; | ||
235 | } | ||
236 | |||
186 | /* For 00,01,03,05 options: | 237 | /* For 00,01,03,05 options: |
187 | * VOUT = 0.60V + NSELx * 10mV, from 0.60 to 1.23V. | 238 | * VOUT = 0.60V + NSELx * 10mV, from 0.60 to 1.23V. |
188 | * For 04 option: | 239 | * For 04 option: |
@@ -191,6 +242,8 @@ static struct regulator_ops fan53555_regulator_ops = { | |||
191 | static int fan53555_device_setup(struct fan53555_device_info *di, | 242 | static int fan53555_device_setup(struct fan53555_device_info *di, |
192 | struct fan53555_platform_data *pdata) | 243 | struct fan53555_platform_data *pdata) |
193 | { | 244 | { |
245 | int ret = 0; | ||
246 | |||
194 | /* Setup voltage control register */ | 247 | /* Setup voltage control register */ |
195 | switch (pdata->sleep_vsel_id) { | 248 | switch (pdata->sleep_vsel_id) { |
196 | case FAN53555_VSEL_ID_0: | 249 | case FAN53555_VSEL_ID_0: |
@@ -205,26 +258,21 @@ static int fan53555_device_setup(struct fan53555_device_info *di, | |||
205 | dev_err(di->dev, "Invalid VSEL ID!\n"); | 258 | dev_err(di->dev, "Invalid VSEL ID!\n"); |
206 | return -EINVAL; | 259 | return -EINVAL; |
207 | } | 260 | } |
208 | /* Init voltage range and step */ | 261 | |
209 | switch (di->chip_id) { | 262 | switch (di->vendor) { |
210 | case FAN53555_CHIP_ID_00: | 263 | case FAN53555_VENDOR_FAIRCHILD: |
211 | case FAN53555_CHIP_ID_01: | 264 | ret = fan53555_voltages_setup_fairchild(di); |
212 | case FAN53555_CHIP_ID_03: | ||
213 | case FAN53555_CHIP_ID_05: | ||
214 | di->vsel_min = 600000; | ||
215 | di->vsel_step = 10000; | ||
216 | break; | 265 | break; |
217 | case FAN53555_CHIP_ID_04: | 266 | case FAN53555_VENDOR_SILERGY: |
218 | di->vsel_min = 603000; | 267 | ret = fan53555_voltages_setup_silergy(di); |
219 | di->vsel_step = 12826; | ||
220 | break; | 268 | break; |
221 | default: | 269 | default: |
222 | dev_err(di->dev, | 270 | dev_err(di->dev, |
223 | "Chip ID[%d]\n not supported!\n", di->chip_id); | 271 | "vendor %d not supported!\n", di->chip_id); |
224 | return -EINVAL; | 272 | return -EINVAL; |
225 | } | 273 | } |
226 | 274 | ||
227 | return 0; | 275 | return ret; |
228 | } | 276 | } |
229 | 277 | ||
230 | static int fan53555_regulator_register(struct fan53555_device_info *di, | 278 | static int fan53555_regulator_register(struct fan53555_device_info *di, |
@@ -278,6 +326,13 @@ static struct fan53555_platform_data *fan53555_parse_dt(struct device *dev, | |||
278 | static const struct of_device_id fan53555_dt_ids[] = { | 326 | static const struct of_device_id fan53555_dt_ids[] = { |
279 | { | 327 | { |
280 | .compatible = "fcs,fan53555", | 328 | .compatible = "fcs,fan53555", |
329 | .data = (void *)FAN53555_VENDOR_FAIRCHILD | ||
330 | }, { | ||
331 | .compatible = "silergy,syr827", | ||
332 | .data = (void *)FAN53555_VENDOR_SILERGY, | ||
333 | }, { | ||
334 | .compatible = "silergy,syr828", | ||
335 | .data = (void *)FAN53555_VENDOR_SILERGY, | ||
281 | }, | 336 | }, |
282 | { } | 337 | { } |
283 | }; | 338 | }; |
@@ -307,7 +362,16 @@ static int fan53555_regulator_probe(struct i2c_client *client, | |||
307 | if (!di) | 362 | if (!di) |
308 | return -ENOMEM; | 363 | return -ENOMEM; |
309 | 364 | ||
310 | if (!client->dev.of_node) { | 365 | if (client->dev.of_node) { |
366 | const struct of_device_id *match; | ||
367 | |||
368 | match = of_match_device(of_match_ptr(fan53555_dt_ids), | ||
369 | &client->dev); | ||
370 | if (!match) | ||
371 | return -ENODEV; | ||
372 | |||
373 | di->vendor = (int) match->data; | ||
374 | } else { | ||
311 | /* if no ramp constraint set, get the pdata ramp_delay */ | 375 | /* if no ramp constraint set, get the pdata ramp_delay */ |
312 | if (!di->regulator->constraints.ramp_delay) { | 376 | if (!di->regulator->constraints.ramp_delay) { |
313 | int slew_idx = (pdata->slew_rate & 0x7) | 377 | int slew_idx = (pdata->slew_rate & 0x7) |
@@ -316,6 +380,8 @@ static int fan53555_regulator_probe(struct i2c_client *client, | |||
316 | di->regulator->constraints.ramp_delay | 380 | di->regulator->constraints.ramp_delay |
317 | = slew_rates[slew_idx]; | 381 | = slew_rates[slew_idx]; |
318 | } | 382 | } |
383 | |||
384 | di->vendor = id->driver_data; | ||
319 | } | 385 | } |
320 | 386 | ||
321 | di->regmap = devm_regmap_init_i2c(client, &fan53555_regmap_config); | 387 | di->regmap = devm_regmap_init_i2c(client, &fan53555_regmap_config); |
@@ -363,7 +429,13 @@ static int fan53555_regulator_probe(struct i2c_client *client, | |||
363 | } | 429 | } |
364 | 430 | ||
365 | static const struct i2c_device_id fan53555_id[] = { | 431 | static const struct i2c_device_id fan53555_id[] = { |
366 | {"fan53555", -1}, | 432 | { |
433 | .name = "fan53555", | ||
434 | .driver_data = FAN53555_VENDOR_FAIRCHILD | ||
435 | }, { | ||
436 | .name = "syr82x", | ||
437 | .driver_data = FAN53555_VENDOR_SILERGY | ||
438 | }, | ||
367 | { }, | 439 | { }, |
368 | }; | 440 | }; |
369 | 441 | ||