aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-10-04 23:01:30 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-10-04 23:01:30 -0400
commit578f1ef91aa92beb571bfb9af8f4d18f405f3b9e (patch)
tree8ff59e772d09180b7e7f952a8c90a1bcf25e1d19 /drivers/regulator
parentecefbd94b834fa32559d854646d777c56749ef1c (diff)
parent74d8378159de16a0a1d1975d4778120d263d6000 (diff)
Merge tag 'mfd-3.7-1' of git://git.kernel.org/pub/scm/linux/kernel/git/sameo/mfd-2.6
Pull MFD changes from Samuel Ortiz: "MFD bits for the 3.7 merge window. As usual we have a few new drivers: - TI LP8788 - TI OMAP USB TLL - Maxim MAX8907 - SMSC ECE1099 - Dialog Semiconductor DA9055 - A simpler syscon driver that allow us to get rid of the anatop one. Drivers are also gradually getting Device Tree and IRQ domain support. The following drivers got DT support: - palmas, 88pm860x, tc3589x and twl4030-audio And those ones now use the IRQ domain APIs: - 88pm860x, tc3589x, db8500_prcmu Also some other interesting changes: - Intel's ICH LPC now supports Lynx Point - TI's twl4030-audio added a GPO child - tps6527 enabled its backlight subdevice - The twl6030 pwm driver moved to the new PWM subsystem And finally a bunch of cleanup and casual fixes for mc13xxx, 88pm860x, palmas, ab8500, wm8994, wm5110, max8907 and the tps65xxx family." Fix up various annoying conflicts: the DT and IRQ domain support came in twice and was already in 3.6. And then it was apparently rebased. Guys, DON'T REBASE! * tag 'mfd-3.7-1' of git://git.kernel.org/pub/scm/linux/kernel/git/sameo/mfd-2.6: (89 commits) ARM: dts: Enable 88pm860x pmic mfd: 88pm860x: Move gpadc init into touch mfd: 88pm860x: Device tree support mfd: 88pm860x: Use irqdomain mfd: smsc: Add support for smsc gpio io/keypad driver backlight: tps65217_bl: Add missing platform_set_drvdata in tps65217_bl_probe mfd: DA9055 core driver mfd: tps65910: Add alarm interrupt of TPS65910 RTC to mfd device list mfd: wm5110: Add register patches for revision B mfd: wm5110: Disable control interface error report for WM5110 rev B mfd: max8907: Remove regulator-compatible from DT docs backlight: Add TPS65217 WLED driver mfd: Add backlight as subdevice to the tps65217 mfd: Provide the PRCMU with its own IRQ domain mfd: Fix max8907 sparse warning mfd: Add lp8788 mfd driver mfd: dbx500: Provide a more accurate smp_twd clock mfd: rc5t583: Fix warning messages regulator: palmas: Add DT support mfd: palmas: Change regulator defns to better suite DT ...
Diffstat (limited to 'drivers/regulator')
-rw-r--r--drivers/regulator/88pm8607.c136
-rw-r--r--drivers/regulator/Kconfig2
-rw-r--r--drivers/regulator/ab3100.c1
-rw-r--r--drivers/regulator/anatop-regulator.c31
-rw-r--r--drivers/regulator/max8925-regulator.c35
-rw-r--r--drivers/regulator/palmas-regulator.c127
-rw-r--r--drivers/regulator/wm831x-dcdc.c12
-rw-r--r--drivers/regulator/wm831x-isink.c4
-rw-r--r--drivers/regulator/wm831x-ldo.c12
9 files changed, 293 insertions, 67 deletions
diff --git a/drivers/regulator/88pm8607.c b/drivers/regulator/88pm8607.c
index c3482b954cb7..1c5ab0172ea2 100644
--- a/drivers/regulator/88pm8607.c
+++ b/drivers/regulator/88pm8607.c
@@ -12,6 +12,8 @@
12#include <linux/init.h> 12#include <linux/init.h>
13#include <linux/err.h> 13#include <linux/err.h>
14#include <linux/i2c.h> 14#include <linux/i2c.h>
15#include <linux/of.h>
16#include <linux/regulator/of_regulator.h>
15#include <linux/platform_device.h> 17#include <linux/platform_device.h>
16#include <linux/regulator/driver.h> 18#include <linux/regulator/driver.h>
17#include <linux/regulator/machine.h> 19#include <linux/regulator/machine.h>
@@ -23,6 +25,7 @@ struct pm8607_regulator_info {
23 struct pm860x_chip *chip; 25 struct pm860x_chip *chip;
24 struct regulator_dev *regulator; 26 struct regulator_dev *regulator;
25 struct i2c_client *i2c; 27 struct i2c_client *i2c;
28 struct i2c_client *i2c_8606;
26 29
27 unsigned int *vol_table; 30 unsigned int *vol_table;
28 unsigned int *vol_suspend; 31 unsigned int *vol_suspend;
@@ -242,6 +245,35 @@ static int pm8607_set_voltage_sel(struct regulator_dev *rdev, unsigned selector)
242 return ret; 245 return ret;
243} 246}
244 247
248static int pm8606_preg_enable(struct regulator_dev *rdev)
249{
250 struct pm8607_regulator_info *info = rdev_get_drvdata(rdev);
251
252 return pm860x_set_bits(info->i2c, rdev->desc->enable_reg,
253 1 << rdev->desc->enable_mask, 0);
254}
255
256static int pm8606_preg_disable(struct regulator_dev *rdev)
257{
258 struct pm8607_regulator_info *info = rdev_get_drvdata(rdev);
259
260 return pm860x_set_bits(info->i2c, rdev->desc->enable_reg,
261 1 << rdev->desc->enable_mask,
262 1 << rdev->desc->enable_mask);
263}
264
265static int pm8606_preg_is_enabled(struct regulator_dev *rdev)
266{
267 struct pm8607_regulator_info *info = rdev_get_drvdata(rdev);
268 int ret;
269
270 ret = pm860x_reg_read(info->i2c, rdev->desc->enable_reg);
271 if (ret < 0)
272 return ret;
273
274 return !((unsigned char)ret & (1 << rdev->desc->enable_mask));
275}
276
245static struct regulator_ops pm8607_regulator_ops = { 277static struct regulator_ops pm8607_regulator_ops = {
246 .list_voltage = pm8607_list_voltage, 278 .list_voltage = pm8607_list_voltage,
247 .set_voltage_sel = pm8607_set_voltage_sel, 279 .set_voltage_sel = pm8607_set_voltage_sel,
@@ -251,6 +283,25 @@ static struct regulator_ops pm8607_regulator_ops = {
251 .is_enabled = regulator_is_enabled_regmap, 283 .is_enabled = regulator_is_enabled_regmap,
252}; 284};
253 285
286static struct regulator_ops pm8606_preg_ops = {
287 .enable = pm8606_preg_enable,
288 .disable = pm8606_preg_disable,
289 .is_enabled = pm8606_preg_is_enabled,
290};
291
292#define PM8606_PREG(ereg, ebit) \
293{ \
294 .desc = { \
295 .name = "PREG", \
296 .ops = &pm8606_preg_ops, \
297 .type = REGULATOR_CURRENT, \
298 .id = PM8606_ID_PREG, \
299 .owner = THIS_MODULE, \
300 .enable_reg = PM8606_##ereg, \
301 .enable_mask = (ebit), \
302 }, \
303}
304
254#define PM8607_DVC(vreg, ureg, ubit, ereg, ebit) \ 305#define PM8607_DVC(vreg, ureg, ubit, ereg, ebit) \
255{ \ 306{ \
256 .desc = { \ 307 .desc = { \
@@ -311,6 +362,38 @@ static struct pm8607_regulator_info pm8607_regulator_info[] = {
311 PM8607_LDO(14, LDO14, 0, SUPPLIES_EN12, 6), 362 PM8607_LDO(14, LDO14, 0, SUPPLIES_EN12, 6),
312}; 363};
313 364
365static struct pm8607_regulator_info pm8606_regulator_info[] = {
366 PM8606_PREG(PREREGULATORB, 5),
367};
368
369#ifdef CONFIG_OF
370static int pm8607_regulator_dt_init(struct platform_device *pdev,
371 struct pm8607_regulator_info *info,
372 struct regulator_config *config)
373{
374 struct device_node *nproot, *np;
375 nproot = pdev->dev.parent->of_node;
376 if (!nproot)
377 return -ENODEV;
378 nproot = of_find_node_by_name(nproot, "regulators");
379 if (!nproot) {
380 dev_err(&pdev->dev, "failed to find regulators node\n");
381 return -ENODEV;
382 }
383 for_each_child_of_node(nproot, np) {
384 if (!of_node_cmp(np->name, info->desc.name)) {
385 config->init_data =
386 of_get_regulator_init_data(&pdev->dev, np);
387 config->of_node = np;
388 break;
389 }
390 }
391 return 0;
392}
393#else
394#define pm8607_regulator_dt_init(x, y, z) (-1)
395#endif
396
314static int __devinit pm8607_regulator_probe(struct platform_device *pdev) 397static int __devinit pm8607_regulator_probe(struct platform_device *pdev)
315{ 398{
316 struct pm860x_chip *chip = dev_get_drvdata(pdev->dev.parent); 399 struct pm860x_chip *chip = dev_get_drvdata(pdev->dev.parent);
@@ -320,22 +403,28 @@ static int __devinit pm8607_regulator_probe(struct platform_device *pdev)
320 struct resource *res; 403 struct resource *res;
321 int i; 404 int i;
322 405
323 res = platform_get_resource(pdev, IORESOURCE_IO, 0); 406 res = platform_get_resource(pdev, IORESOURCE_REG, 0);
324 if (res == NULL) { 407 if (res) {
325 dev_err(&pdev->dev, "No I/O resource!\n"); 408 /* There're resources in 88PM8607 regulator driver */
326 return -EINVAL; 409 for (i = 0; i < ARRAY_SIZE(pm8607_regulator_info); i++) {
327 } 410 info = &pm8607_regulator_info[i];
328 for (i = 0; i < ARRAY_SIZE(pm8607_regulator_info); i++) { 411 if (info->desc.vsel_reg == res->start)
329 info = &pm8607_regulator_info[i]; 412 break;
330 if (info->desc.id == res->start) 413 }
331 break; 414 if (i == ARRAY_SIZE(pm8607_regulator_info)) {
332 } 415 dev_err(&pdev->dev, "Failed to find regulator %llu\n",
333 if (i == ARRAY_SIZE(pm8607_regulator_info)) { 416 (unsigned long long)res->start);
334 dev_err(&pdev->dev, "Failed to find regulator %llu\n", 417 return -EINVAL;
335 (unsigned long long)res->start); 418 }
336 return -EINVAL; 419 } else {
420 /* There's no resource in 88PM8606 PREG regulator driver */
421 info = &pm8606_regulator_info[0];
422 /* i is used to check regulator ID */
423 i = -1;
337 } 424 }
338 info->i2c = (chip->id == CHIP_PM8607) ? chip->client : chip->companion; 425 info->i2c = (chip->id == CHIP_PM8607) ? chip->client : chip->companion;
426 info->i2c_8606 = (chip->id == CHIP_PM8607) ? chip->companion :
427 chip->client;
339 info->chip = chip; 428 info->chip = chip;
340 429
341 /* check DVC ramp slope double */ 430 /* check DVC ramp slope double */
@@ -343,15 +432,17 @@ static int __devinit pm8607_regulator_probe(struct platform_device *pdev)
343 info->slope_double = 1; 432 info->slope_double = 1;
344 433
345 config.dev = &pdev->dev; 434 config.dev = &pdev->dev;
346 config.init_data = pdata;
347 config.driver_data = info; 435 config.driver_data = info;
348 436
437 if (pm8607_regulator_dt_init(pdev, info, &config))
438 if (pdata)
439 config.init_data = pdata;
440
349 if (chip->id == CHIP_PM8607) 441 if (chip->id == CHIP_PM8607)
350 config.regmap = chip->regmap; 442 config.regmap = chip->regmap;
351 else 443 else
352 config.regmap = chip->regmap_companion; 444 config.regmap = chip->regmap_companion;
353 445
354 /* replace driver_data with info */
355 info->regulator = regulator_register(&info->desc, &config); 446 info->regulator = regulator_register(&info->desc, &config);
356 if (IS_ERR(info->regulator)) { 447 if (IS_ERR(info->regulator)) {
357 dev_err(&pdev->dev, "failed to register regulator %s\n", 448 dev_err(&pdev->dev, "failed to register regulator %s\n",
@@ -372,6 +463,18 @@ static int __devexit pm8607_regulator_remove(struct platform_device *pdev)
372 return 0; 463 return 0;
373} 464}
374 465
466static struct platform_device_id pm8607_regulator_driver_ids[] = {
467 {
468 .name = "88pm860x-regulator",
469 .driver_data = 0,
470 }, {
471 .name = "88pm860x-preg",
472 .driver_data = 0,
473 },
474 { },
475};
476MODULE_DEVICE_TABLE(platform, pm8607_regulator_driver_ids);
477
375static struct platform_driver pm8607_regulator_driver = { 478static struct platform_driver pm8607_regulator_driver = {
376 .driver = { 479 .driver = {
377 .name = "88pm860x-regulator", 480 .name = "88pm860x-regulator",
@@ -379,6 +482,7 @@ static struct platform_driver pm8607_regulator_driver = {
379 }, 482 },
380 .probe = pm8607_regulator_probe, 483 .probe = pm8607_regulator_probe,
381 .remove = __devexit_p(pm8607_regulator_remove), 484 .remove = __devexit_p(pm8607_regulator_remove),
485 .id_table = pm8607_regulator_driver_ids,
382}; 486};
383 487
384static int __init pm8607_regulator_init(void) 488static int __init pm8607_regulator_init(void)
diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index e98a5e7827df..67d47b59a66d 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -122,7 +122,7 @@ config REGULATOR_FAN53555
122 122
123config REGULATOR_ANATOP 123config REGULATOR_ANATOP
124 tristate "Freescale i.MX on-chip ANATOP LDO regulators" 124 tristate "Freescale i.MX on-chip ANATOP LDO regulators"
125 depends on MFD_ANATOP 125 depends on MFD_SYSCON
126 help 126 help
127 Say y here to support Freescale i.MX on-chip ANATOP LDOs 127 Say y here to support Freescale i.MX on-chip ANATOP LDOs
128 regulators. It is recommended that this option be 128 regulators. It is recommended that this option be
diff --git a/drivers/regulator/ab3100.c b/drivers/regulator/ab3100.c
index 65ad2b36ce36..df4ad8927f0c 100644
--- a/drivers/regulator/ab3100.c
+++ b/drivers/regulator/ab3100.c
@@ -15,6 +15,7 @@
15#include <linux/err.h> 15#include <linux/err.h>
16#include <linux/platform_device.h> 16#include <linux/platform_device.h>
17#include <linux/regulator/driver.h> 17#include <linux/regulator/driver.h>
18#include <linux/mfd/ab3100.h>
18#include <linux/mfd/abx500.h> 19#include <linux/mfd/abx500.h>
19 20
20/* LDO registers and some handy masking definitions for AB3100 */ 21/* LDO registers and some handy masking definitions for AB3100 */
diff --git a/drivers/regulator/anatop-regulator.c b/drivers/regulator/anatop-regulator.c
index ce0fe72a428e..1af97686f444 100644
--- a/drivers/regulator/anatop-regulator.c
+++ b/drivers/regulator/anatop-regulator.c
@@ -21,19 +21,20 @@
21#include <linux/slab.h> 21#include <linux/slab.h>
22#include <linux/device.h> 22#include <linux/device.h>
23#include <linux/module.h> 23#include <linux/module.h>
24#include <linux/mfd/syscon.h>
24#include <linux/err.h> 25#include <linux/err.h>
25#include <linux/io.h> 26#include <linux/io.h>
26#include <linux/platform_device.h> 27#include <linux/platform_device.h>
27#include <linux/of.h> 28#include <linux/of.h>
28#include <linux/of_address.h> 29#include <linux/of_address.h>
29#include <linux/mfd/anatop.h> 30#include <linux/regmap.h>
30#include <linux/regulator/driver.h> 31#include <linux/regulator/driver.h>
31#include <linux/regulator/of_regulator.h> 32#include <linux/regulator/of_regulator.h>
32 33
33struct anatop_regulator { 34struct anatop_regulator {
34 const char *name; 35 const char *name;
35 u32 control_reg; 36 u32 control_reg;
36 struct anatop *mfd; 37 struct regmap *anatop;
37 int vol_bit_shift; 38 int vol_bit_shift;
38 int vol_bit_width; 39 int vol_bit_width;
39 int min_bit_val; 40 int min_bit_val;
@@ -43,7 +44,8 @@ struct anatop_regulator {
43 struct regulator_init_data *initdata; 44 struct regulator_init_data *initdata;
44}; 45};
45 46
46static int anatop_set_voltage_sel(struct regulator_dev *reg, unsigned selector) 47static int anatop_regmap_set_voltage_sel(struct regulator_dev *reg,
48 unsigned selector)
47{ 49{
48 struct anatop_regulator *anatop_reg = rdev_get_drvdata(reg); 50 struct anatop_regulator *anatop_reg = rdev_get_drvdata(reg);
49 u32 val, mask; 51 u32 val, mask;
@@ -56,12 +58,13 @@ static int anatop_set_voltage_sel(struct regulator_dev *reg, unsigned selector)
56 mask = ((1 << anatop_reg->vol_bit_width) - 1) << 58 mask = ((1 << anatop_reg->vol_bit_width) - 1) <<
57 anatop_reg->vol_bit_shift; 59 anatop_reg->vol_bit_shift;
58 val <<= anatop_reg->vol_bit_shift; 60 val <<= anatop_reg->vol_bit_shift;
59 anatop_write_reg(anatop_reg->mfd, anatop_reg->control_reg, val, mask); 61 regmap_update_bits(anatop_reg->anatop, anatop_reg->control_reg,
62 mask, val);
60 63
61 return 0; 64 return 0;
62} 65}
63 66
64static int anatop_get_voltage_sel(struct regulator_dev *reg) 67static int anatop_regmap_get_voltage_sel(struct regulator_dev *reg)
65{ 68{
66 struct anatop_regulator *anatop_reg = rdev_get_drvdata(reg); 69 struct anatop_regulator *anatop_reg = rdev_get_drvdata(reg);
67 u32 val, mask; 70 u32 val, mask;
@@ -69,7 +72,7 @@ static int anatop_get_voltage_sel(struct regulator_dev *reg)
69 if (!anatop_reg->control_reg) 72 if (!anatop_reg->control_reg)
70 return -ENOTSUPP; 73 return -ENOTSUPP;
71 74
72 val = anatop_read_reg(anatop_reg->mfd, anatop_reg->control_reg); 75 regmap_read(anatop_reg->anatop, anatop_reg->control_reg, &val);
73 mask = ((1 << anatop_reg->vol_bit_width) - 1) << 76 mask = ((1 << anatop_reg->vol_bit_width) - 1) <<
74 anatop_reg->vol_bit_shift; 77 anatop_reg->vol_bit_shift;
75 val = (val & mask) >> anatop_reg->vol_bit_shift; 78 val = (val & mask) >> anatop_reg->vol_bit_shift;
@@ -78,8 +81,8 @@ static int anatop_get_voltage_sel(struct regulator_dev *reg)
78} 81}
79 82
80static struct regulator_ops anatop_rops = { 83static struct regulator_ops anatop_rops = {
81 .set_voltage_sel = anatop_set_voltage_sel, 84 .set_voltage_sel = anatop_regmap_set_voltage_sel,
82 .get_voltage_sel = anatop_get_voltage_sel, 85 .get_voltage_sel = anatop_regmap_get_voltage_sel,
83 .list_voltage = regulator_list_voltage_linear, 86 .list_voltage = regulator_list_voltage_linear,
84 .map_voltage = regulator_map_voltage_linear, 87 .map_voltage = regulator_map_voltage_linear,
85}; 88};
@@ -88,11 +91,11 @@ static int __devinit anatop_regulator_probe(struct platform_device *pdev)
88{ 91{
89 struct device *dev = &pdev->dev; 92 struct device *dev = &pdev->dev;
90 struct device_node *np = dev->of_node; 93 struct device_node *np = dev->of_node;
94 struct device_node *anatop_np;
91 struct regulator_desc *rdesc; 95 struct regulator_desc *rdesc;
92 struct regulator_dev *rdev; 96 struct regulator_dev *rdev;
93 struct anatop_regulator *sreg; 97 struct anatop_regulator *sreg;
94 struct regulator_init_data *initdata; 98 struct regulator_init_data *initdata;
95 struct anatop *anatopmfd = dev_get_drvdata(pdev->dev.parent);
96 struct regulator_config config = { }; 99 struct regulator_config config = { };
97 int ret = 0; 100 int ret = 0;
98 101
@@ -109,7 +112,15 @@ static int __devinit anatop_regulator_probe(struct platform_device *pdev)
109 rdesc->ops = &anatop_rops; 112 rdesc->ops = &anatop_rops;
110 rdesc->type = REGULATOR_VOLTAGE; 113 rdesc->type = REGULATOR_VOLTAGE;
111 rdesc->owner = THIS_MODULE; 114 rdesc->owner = THIS_MODULE;
112 sreg->mfd = anatopmfd; 115
116 anatop_np = of_get_parent(np);
117 if (!anatop_np)
118 return -ENODEV;
119 sreg->anatop = syscon_node_to_regmap(anatop_np);
120 of_node_put(anatop_np);
121 if (IS_ERR(sreg->anatop))
122 return PTR_ERR(sreg->anatop);
123
113 ret = of_property_read_u32(np, "anatop-reg-offset", 124 ret = of_property_read_u32(np, "anatop-reg-offset",
114 &sreg->control_reg); 125 &sreg->control_reg);
115 if (ret) { 126 if (ret) {
diff --git a/drivers/regulator/max8925-regulator.c b/drivers/regulator/max8925-regulator.c
index 43dc97ec3932..9bb0be37495f 100644
--- a/drivers/regulator/max8925-regulator.c
+++ b/drivers/regulator/max8925-regulator.c
@@ -214,37 +214,36 @@ static struct max8925_regulator_info max8925_regulator_info[] = {
214 MAX8925_LDO(20, 750, 3900, 50), 214 MAX8925_LDO(20, 750, 3900, 50),
215}; 215};
216 216
217static struct max8925_regulator_info * __devinit find_regulator_info(int id)
218{
219 struct max8925_regulator_info *ri;
220 int i;
221
222 for (i = 0; i < ARRAY_SIZE(max8925_regulator_info); i++) {
223 ri = &max8925_regulator_info[i];
224 if (ri->desc.id == id)
225 return ri;
226 }
227 return NULL;
228}
229
230static int __devinit max8925_regulator_probe(struct platform_device *pdev) 217static int __devinit max8925_regulator_probe(struct platform_device *pdev)
231{ 218{
232 struct max8925_chip *chip = dev_get_drvdata(pdev->dev.parent); 219 struct max8925_chip *chip = dev_get_drvdata(pdev->dev.parent);
233 struct max8925_platform_data *pdata = chip->dev->platform_data; 220 struct regulator_init_data *pdata = pdev->dev.platform_data;
234 struct regulator_config config = { }; 221 struct regulator_config config = { };
235 struct max8925_regulator_info *ri; 222 struct max8925_regulator_info *ri;
223 struct resource *res;
236 struct regulator_dev *rdev; 224 struct regulator_dev *rdev;
225 int i;
237 226
238 ri = find_regulator_info(pdev->id); 227 res = platform_get_resource(pdev, IORESOURCE_REG, 0);
239 if (ri == NULL) { 228 if (!res) {
240 dev_err(&pdev->dev, "invalid regulator ID specified\n"); 229 dev_err(&pdev->dev, "No REG resource!\n");
230 return -EINVAL;
231 }
232 for (i = 0; i < ARRAY_SIZE(max8925_regulator_info); i++) {
233 ri = &max8925_regulator_info[i];
234 if (ri->vol_reg == res->start)
235 break;
236 }
237 if (i == ARRAY_SIZE(max8925_regulator_info)) {
238 dev_err(&pdev->dev, "Failed to find regulator %llu\n",
239 (unsigned long long)res->start);
241 return -EINVAL; 240 return -EINVAL;
242 } 241 }
243 ri->i2c = chip->i2c; 242 ri->i2c = chip->i2c;
244 ri->chip = chip; 243 ri->chip = chip;
245 244
246 config.dev = &pdev->dev; 245 config.dev = &pdev->dev;
247 config.init_data = pdata->regulator[pdev->id]; 246 config.init_data = pdata;
248 config.driver_data = ri; 247 config.driver_data = ri;
249 248
250 rdev = regulator_register(&ri->desc, &config); 249 rdev = regulator_register(&ri->desc, &config);
diff --git a/drivers/regulator/palmas-regulator.c b/drivers/regulator/palmas-regulator.c
index 2ba7502fa3b2..07aee694ba92 100644
--- a/drivers/regulator/palmas-regulator.c
+++ b/drivers/regulator/palmas-regulator.c
@@ -22,6 +22,9 @@
22#include <linux/slab.h> 22#include <linux/slab.h>
23#include <linux/regmap.h> 23#include <linux/regmap.h>
24#include <linux/mfd/palmas.h> 24#include <linux/mfd/palmas.h>
25#include <linux/of.h>
26#include <linux/of_platform.h>
27#include <linux/regulator/of_regulator.h>
25 28
26struct regs_info { 29struct regs_info {
27 char *name; 30 char *name;
@@ -568,10 +571,103 @@ static int palmas_ldo_init(struct palmas *palmas, int id,
568 return 0; 571 return 0;
569} 572}
570 573
574static struct of_regulator_match palmas_matches[] = {
575 { .name = "smps12", },
576 { .name = "smps123", },
577 { .name = "smps3", },
578 { .name = "smps45", },
579 { .name = "smps457", },
580 { .name = "smps6", },
581 { .name = "smps7", },
582 { .name = "smps8", },
583 { .name = "smps9", },
584 { .name = "smps10", },
585 { .name = "ldo1", },
586 { .name = "ldo2", },
587 { .name = "ldo3", },
588 { .name = "ldo4", },
589 { .name = "ldo5", },
590 { .name = "ldo6", },
591 { .name = "ldo7", },
592 { .name = "ldo8", },
593 { .name = "ldo9", },
594 { .name = "ldoln", },
595 { .name = "ldousb", },
596};
597
598static void __devinit palmas_dt_to_pdata(struct device *dev,
599 struct device_node *node,
600 struct palmas_pmic_platform_data *pdata)
601{
602 struct device_node *regulators;
603 u32 prop;
604 int idx, ret;
605
606 regulators = of_find_node_by_name(node, "regulators");
607 if (!regulators) {
608 dev_info(dev, "regulator node not found\n");
609 return;
610 }
611
612 ret = of_regulator_match(dev, regulators, palmas_matches,
613 PALMAS_NUM_REGS);
614 if (ret < 0) {
615 dev_err(dev, "Error parsing regulator init data: %d\n", ret);
616 return;
617 }
618
619 for (idx = 0; idx < PALMAS_NUM_REGS; idx++) {
620 if (!palmas_matches[idx].init_data ||
621 !palmas_matches[idx].of_node)
622 continue;
623
624 pdata->reg_data[idx] = palmas_matches[idx].init_data;
625
626 pdata->reg_init[idx] = devm_kzalloc(dev,
627 sizeof(struct palmas_reg_init), GFP_KERNEL);
628
629 ret = of_property_read_u32(palmas_matches[idx].of_node,
630 "ti,warm_reset", &prop);
631 if (!ret)
632 pdata->reg_init[idx]->warm_reset = prop;
633
634 ret = of_property_read_u32(palmas_matches[idx].of_node,
635 "ti,roof_floor", &prop);
636 if (!ret)
637 pdata->reg_init[idx]->roof_floor = prop;
638
639 ret = of_property_read_u32(palmas_matches[idx].of_node,
640 "ti,mode_sleep", &prop);
641 if (!ret)
642 pdata->reg_init[idx]->mode_sleep = prop;
643
644 ret = of_property_read_u32(palmas_matches[idx].of_node,
645 "ti,warm_reset", &prop);
646 if (!ret)
647 pdata->reg_init[idx]->warm_reset = prop;
648
649 ret = of_property_read_u32(palmas_matches[idx].of_node,
650 "ti,tstep", &prop);
651 if (!ret)
652 pdata->reg_init[idx]->tstep = prop;
653
654 ret = of_property_read_u32(palmas_matches[idx].of_node,
655 "ti,vsel", &prop);
656 if (!ret)
657 pdata->reg_init[idx]->vsel = prop;
658 }
659
660 ret = of_property_read_u32(node, "ti,ldo6_vibrator", &prop);
661 if (!ret)
662 pdata->ldo6_vibrator = prop;
663}
664
665
571static __devinit int palmas_probe(struct platform_device *pdev) 666static __devinit int palmas_probe(struct platform_device *pdev)
572{ 667{
573 struct palmas *palmas = dev_get_drvdata(pdev->dev.parent); 668 struct palmas *palmas = dev_get_drvdata(pdev->dev.parent);
574 struct palmas_pmic_platform_data *pdata = pdev->dev.platform_data; 669 struct palmas_pmic_platform_data *pdata = pdev->dev.platform_data;
670 struct device_node *node = pdev->dev.of_node;
575 struct regulator_dev *rdev; 671 struct regulator_dev *rdev;
576 struct regulator_config config = { }; 672 struct regulator_config config = { };
577 struct palmas_pmic *pmic; 673 struct palmas_pmic *pmic;
@@ -579,10 +675,14 @@ static __devinit int palmas_probe(struct platform_device *pdev)
579 int id = 0, ret; 675 int id = 0, ret;
580 unsigned int addr, reg; 676 unsigned int addr, reg;
581 677
582 if (!pdata) 678 if (node && !pdata) {
583 return -EINVAL; 679 pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
584 if (!pdata->reg_data) 680
585 return -EINVAL; 681 if (!pdata)
682 return -ENOMEM;
683
684 palmas_dt_to_pdata(&pdev->dev, node, pdata);
685 }
586 686
587 pmic = devm_kzalloc(&pdev->dev, sizeof(*pmic), GFP_KERNEL); 687 pmic = devm_kzalloc(&pdev->dev, sizeof(*pmic), GFP_KERNEL);
588 if (!pmic) 688 if (!pmic)
@@ -661,7 +761,7 @@ static __devinit int palmas_probe(struct platform_device *pdev)
661 pmic->desc[id].owner = THIS_MODULE; 761 pmic->desc[id].owner = THIS_MODULE;
662 762
663 /* Initialise sleep/init values from platform data */ 763 /* Initialise sleep/init values from platform data */
664 if (pdata && pdata->reg_init) { 764 if (pdata) {
665 reg_init = pdata->reg_init[id]; 765 reg_init = pdata->reg_init[id];
666 if (reg_init) { 766 if (reg_init) {
667 ret = palmas_smps_init(palmas, id, reg_init); 767 ret = palmas_smps_init(palmas, id, reg_init);
@@ -685,11 +785,13 @@ static __devinit int palmas_probe(struct platform_device *pdev)
685 pmic->range[id] = 1; 785 pmic->range[id] = 1;
686 } 786 }
687 787
688 if (pdata && pdata->reg_data) 788 if (pdata)
689 config.init_data = pdata->reg_data[id]; 789 config.init_data = pdata->reg_data[id];
690 else 790 else
691 config.init_data = NULL; 791 config.init_data = NULL;
692 792
793 config.of_node = palmas_matches[id].of_node;
794
693 rdev = regulator_register(&pmic->desc[id], &config); 795 rdev = regulator_register(&pmic->desc[id], &config);
694 if (IS_ERR(rdev)) { 796 if (IS_ERR(rdev)) {
695 dev_err(&pdev->dev, 797 dev_err(&pdev->dev,
@@ -726,11 +828,13 @@ static __devinit int palmas_probe(struct platform_device *pdev)
726 palmas_regs_info[id].ctrl_addr); 828 palmas_regs_info[id].ctrl_addr);
727 pmic->desc[id].enable_mask = PALMAS_LDO1_CTRL_MODE_ACTIVE; 829 pmic->desc[id].enable_mask = PALMAS_LDO1_CTRL_MODE_ACTIVE;
728 830
729 if (pdata && pdata->reg_data) 831 if (pdata)
730 config.init_data = pdata->reg_data[id]; 832 config.init_data = pdata->reg_data[id];
731 else 833 else
732 config.init_data = NULL; 834 config.init_data = NULL;
733 835
836 config.of_node = palmas_matches[id].of_node;
837
734 rdev = regulator_register(&pmic->desc[id], &config); 838 rdev = regulator_register(&pmic->desc[id], &config);
735 if (IS_ERR(rdev)) { 839 if (IS_ERR(rdev)) {
736 dev_err(&pdev->dev, 840 dev_err(&pdev->dev,
@@ -744,7 +848,7 @@ static __devinit int palmas_probe(struct platform_device *pdev)
744 pmic->rdev[id] = rdev; 848 pmic->rdev[id] = rdev;
745 849
746 /* Initialise sleep/init values from platform data */ 850 /* Initialise sleep/init values from platform data */
747 if (pdata->reg_init) { 851 if (pdata) {
748 reg_init = pdata->reg_init[id]; 852 reg_init = pdata->reg_init[id];
749 if (reg_init) { 853 if (reg_init) {
750 ret = palmas_ldo_init(palmas, id, reg_init); 854 ret = palmas_ldo_init(palmas, id, reg_init);
@@ -774,9 +878,15 @@ static int __devexit palmas_remove(struct platform_device *pdev)
774 return 0; 878 return 0;
775} 879}
776 880
881static struct of_device_id __devinitdata of_palmas_match_tbl[] = {
882 { .compatible = "ti,palmas-pmic", },
883 { /* end */ }
884};
885
777static struct platform_driver palmas_driver = { 886static struct platform_driver palmas_driver = {
778 .driver = { 887 .driver = {
779 .name = "palmas-pmic", 888 .name = "palmas-pmic",
889 .of_match_table = of_palmas_match_tbl,
780 .owner = THIS_MODULE, 890 .owner = THIS_MODULE,
781 }, 891 },
782 .probe = palmas_probe, 892 .probe = palmas_probe,
@@ -799,3 +909,4 @@ MODULE_AUTHOR("Graeme Gregory <gg@slimlogic.co.uk>");
799MODULE_DESCRIPTION("Palmas voltage regulator driver"); 909MODULE_DESCRIPTION("Palmas voltage regulator driver");
800MODULE_LICENSE("GPL"); 910MODULE_LICENSE("GPL");
801MODULE_ALIAS("platform:palmas-pmic"); 911MODULE_ALIAS("platform:palmas-pmic");
912MODULE_DEVICE_TABLE(of, of_palmas_match_tbl);
diff --git a/drivers/regulator/wm831x-dcdc.c b/drivers/regulator/wm831x-dcdc.c
index 90cbcc683704..782c228a19bd 100644
--- a/drivers/regulator/wm831x-dcdc.c
+++ b/drivers/regulator/wm831x-dcdc.c
@@ -475,9 +475,9 @@ static __devinit int wm831x_buckv_probe(struct platform_device *pdev)
475 475
476 dcdc->wm831x = wm831x; 476 dcdc->wm831x = wm831x;
477 477
478 res = platform_get_resource(pdev, IORESOURCE_IO, 0); 478 res = platform_get_resource(pdev, IORESOURCE_REG, 0);
479 if (res == NULL) { 479 if (res == NULL) {
480 dev_err(&pdev->dev, "No I/O resource\n"); 480 dev_err(&pdev->dev, "No REG resource\n");
481 ret = -EINVAL; 481 ret = -EINVAL;
482 goto err; 482 goto err;
483 } 483 }
@@ -650,9 +650,9 @@ static __devinit int wm831x_buckp_probe(struct platform_device *pdev)
650 650
651 dcdc->wm831x = wm831x; 651 dcdc->wm831x = wm831x;
652 652
653 res = platform_get_resource(pdev, IORESOURCE_IO, 0); 653 res = platform_get_resource(pdev, IORESOURCE_REG, 0);
654 if (res == NULL) { 654 if (res == NULL) {
655 dev_err(&pdev->dev, "No I/O resource\n"); 655 dev_err(&pdev->dev, "No REG resource\n");
656 ret = -EINVAL; 656 ret = -EINVAL;
657 goto err; 657 goto err;
658 } 658 }
@@ -794,9 +794,9 @@ static __devinit int wm831x_boostp_probe(struct platform_device *pdev)
794 794
795 dcdc->wm831x = wm831x; 795 dcdc->wm831x = wm831x;
796 796
797 res = platform_get_resource(pdev, IORESOURCE_IO, 0); 797 res = platform_get_resource(pdev, IORESOURCE_REG, 0);
798 if (res == NULL) { 798 if (res == NULL) {
799 dev_err(&pdev->dev, "No I/O resource\n"); 799 dev_err(&pdev->dev, "No REG resource\n");
800 ret = -EINVAL; 800 ret = -EINVAL;
801 goto err; 801 goto err;
802 } 802 }
diff --git a/drivers/regulator/wm831x-isink.c b/drivers/regulator/wm831x-isink.c
index 0d207c297714..2646a1902b33 100644
--- a/drivers/regulator/wm831x-isink.c
+++ b/drivers/regulator/wm831x-isink.c
@@ -172,9 +172,9 @@ static __devinit int wm831x_isink_probe(struct platform_device *pdev)
172 172
173 isink->wm831x = wm831x; 173 isink->wm831x = wm831x;
174 174
175 res = platform_get_resource(pdev, IORESOURCE_IO, 0); 175 res = platform_get_resource(pdev, IORESOURCE_REG, 0);
176 if (res == NULL) { 176 if (res == NULL) {
177 dev_err(&pdev->dev, "No I/O resource\n"); 177 dev_err(&pdev->dev, "No REG resource\n");
178 ret = -EINVAL; 178 ret = -EINVAL;
179 goto err; 179 goto err;
180 } 180 }
diff --git a/drivers/regulator/wm831x-ldo.c b/drivers/regulator/wm831x-ldo.c
index 9af512672be1..c2dc03993dc7 100644
--- a/drivers/regulator/wm831x-ldo.c
+++ b/drivers/regulator/wm831x-ldo.c
@@ -273,9 +273,9 @@ static __devinit int wm831x_gp_ldo_probe(struct platform_device *pdev)
273 273
274 ldo->wm831x = wm831x; 274 ldo->wm831x = wm831x;
275 275
276 res = platform_get_resource(pdev, IORESOURCE_IO, 0); 276 res = platform_get_resource(pdev, IORESOURCE_REG, 0);
277 if (res == NULL) { 277 if (res == NULL) {
278 dev_err(&pdev->dev, "No I/O resource\n"); 278 dev_err(&pdev->dev, "No REG resource\n");
279 ret = -EINVAL; 279 ret = -EINVAL;
280 goto err; 280 goto err;
281 } 281 }
@@ -530,9 +530,9 @@ static __devinit int wm831x_aldo_probe(struct platform_device *pdev)
530 530
531 ldo->wm831x = wm831x; 531 ldo->wm831x = wm831x;
532 532
533 res = platform_get_resource(pdev, IORESOURCE_IO, 0); 533 res = platform_get_resource(pdev, IORESOURCE_REG, 0);
534 if (res == NULL) { 534 if (res == NULL) {
535 dev_err(&pdev->dev, "No I/O resource\n"); 535 dev_err(&pdev->dev, "No REG resource\n");
536 ret = -EINVAL; 536 ret = -EINVAL;
537 goto err; 537 goto err;
538 } 538 }
@@ -687,9 +687,9 @@ static __devinit int wm831x_alive_ldo_probe(struct platform_device *pdev)
687 687
688 ldo->wm831x = wm831x; 688 ldo->wm831x = wm831x;
689 689
690 res = platform_get_resource(pdev, IORESOURCE_IO, 0); 690 res = platform_get_resource(pdev, IORESOURCE_REG, 0);
691 if (res == NULL) { 691 if (res == NULL) {
692 dev_err(&pdev->dev, "No I/O resource\n"); 692 dev_err(&pdev->dev, "No REG resource\n");
693 ret = -EINVAL; 693 ret = -EINVAL;
694 goto err; 694 goto err;
695 } 695 }