aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator/fan53555.c
diff options
context:
space:
mode:
authorHeiko Stuebner <heiko@sntech.de>2014-09-16 15:22:54 -0400
committerMark Brown <broonie@kernel.org>2014-09-16 19:09:32 -0400
commitee30928ab616786cae926c5c2efaa4303ba66802 (patch)
tree1ef5e87a9167f017d16caa119e26a60f4fb511c9 /drivers/regulator/fan53555.c
parent91f23d8fb67c90a50676e4db9260a21647ef753f (diff)
regulator: fan53555: add support for Silergy SYR82x regulators
Silergy SYR82x regulators share the exact same functionality and register layout as the Fairchild FAN53555 regulators. Therefore extend the driver to add support for them. Both types use the same vendor id in their ID1 register, so it's not possible to distinguish them automatically. Similarly, the types also do not match. Type 8 used by the SYR827 and SYR828 start at 712.5mV and increment in 12.5mv steps, while the FAN53555 type 8 starts at 600mV and increments in 10mV steps. Signed-off-by: Heiko Stuebner <heiko@sntech.de> Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/regulator/fan53555.c')
-rw-r--r--drivers/regulator/fan53555.c102
1 files changed, 87 insertions, 15 deletions
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
55enum fan53555_vendor {
56 FAN53555_VENDOR_FAIRCHILD = 0,
57 FAN53555_VENDOR_SILERGY,
58};
59
55/* IC Type */ 60/* IC Type */
56enum { 61enum {
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
70enum {
71 SILERGY_SYR82X = 8,
72};
73
65struct fan53555_device_info { 74struct 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
196static 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
220static 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 = {
191static int fan53555_device_setup(struct fan53555_device_info *di, 242static 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
230static int fan53555_regulator_register(struct fan53555_device_info *di, 278static int fan53555_regulator_register(struct fan53555_device_info *di,
@@ -278,6 +326,13 @@ static struct fan53555_platform_data *fan53555_parse_dt(struct device *dev,
278static const struct of_device_id fan53555_dt_ids[] = { 326static 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
365static const struct i2c_device_id fan53555_id[] = { 431static 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