aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2012-11-27 15:06:08 -0500
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-11-27 15:06:08 -0500
commitb87d07b13c779c42e4929e590003c9eb8c2f06fa (patch)
tree9fbe55b61e176e783e5c6d6063733079d0274948
parent77b71b370ed06c75bdebef09be438d5275f70fc1 (diff)
parent8dc995f56ef7aedb41873fdeaa1971f3aa166ebd (diff)
Merge branch 'topic/hotplug' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator into regulator-max8997
Conflicts: drivers/regulator/max8997.c
-rw-r--r--Documentation/devicetree/bindings/regulator/gpio-regulator.txt37
-rw-r--r--Documentation/devicetree/bindings/regulator/max8925-regulator.txt40
-rw-r--r--Documentation/devicetree/bindings/regulator/vexpress.txt32
-rw-r--r--drivers/mfd/Kconfig1
-rw-r--r--drivers/mfd/tps6586x.c76
-rw-r--r--drivers/regulator/88pm8607.c6
-rw-r--r--drivers/regulator/Kconfig27
-rw-r--r--drivers/regulator/Makefile3
-rw-r--r--drivers/regulator/aat2870-regulator.c4
-rw-r--r--drivers/regulator/ab3100.c6
-rw-r--r--drivers/regulator/ab8500.c12
-rw-r--r--drivers/regulator/ad5398.c6
-rw-r--r--drivers/regulator/anatop-regulator.c6
-rw-r--r--drivers/regulator/arizona-ldo1.c6
-rw-r--r--drivers/regulator/arizona-micsupp.c6
-rw-r--r--drivers/regulator/core.c5
-rw-r--r--drivers/regulator/da903x.c6
-rw-r--r--drivers/regulator/da9052-regulator.c6
-rw-r--r--drivers/regulator/db8500-prcmu.c6
-rw-r--r--drivers/regulator/dbx500-prcmu.c4
-rw-r--r--drivers/regulator/dummy.c2
-rw-r--r--drivers/regulator/fan53555.c6
-rw-r--r--drivers/regulator/fixed.c6
-rw-r--r--drivers/regulator/gpio-regulator.c106
-rw-r--r--drivers/regulator/isl6271a-regulator.c6
-rw-r--r--drivers/regulator/lp3971.c8
-rw-r--r--drivers/regulator/lp3972.c8
-rw-r--r--drivers/regulator/lp872x.c4
-rw-r--r--drivers/regulator/lp8788-buck.c6
-rw-r--r--drivers/regulator/lp8788-ldo.c12
-rw-r--r--drivers/regulator/max1586.c6
-rw-r--r--drivers/regulator/max77686.c6
-rw-r--r--drivers/regulator/max8649.c6
-rw-r--r--drivers/regulator/max8660.c6
-rw-r--r--drivers/regulator/max8907-regulator.c6
-rw-r--r--drivers/regulator/max8925-regulator.c78
-rw-r--r--drivers/regulator/max8952.c6
-rw-r--r--drivers/regulator/max8997.c6
-rw-r--r--drivers/regulator/max8998.c6
-rw-r--r--drivers/regulator/mc13783-regulator.c6
-rw-r--r--drivers/regulator/mc13892-regulator.c6
-rw-r--r--drivers/regulator/mc13xxx-regulator-core.c4
-rw-r--r--drivers/regulator/palmas-regulator.c8
-rw-r--r--drivers/regulator/pcap-regulator.c6
-rw-r--r--drivers/regulator/pcf50633-regulator.c6
-rw-r--r--drivers/regulator/rc5t583-regulator.c6
-rw-r--r--drivers/regulator/s2mps11.c6
-rw-r--r--drivers/regulator/s5m8767.c6
-rw-r--r--drivers/regulator/tps51632-regulator.c332
-rw-r--r--drivers/regulator/tps6105x-regulator.c6
-rw-r--r--drivers/regulator/tps62360-regulator.c8
-rw-r--r--drivers/regulator/tps65023-regulator.c6
-rw-r--r--drivers/regulator/tps6507x-regulator.c6
-rw-r--r--drivers/regulator/tps65090-regulator.c253
-rw-r--r--drivers/regulator/tps65217-regulator.c6
-rw-r--r--drivers/regulator/tps6524x-regulator.c4
-rw-r--r--drivers/regulator/tps6586x-regulator.c187
-rw-r--r--drivers/regulator/tps65910-regulator.c6
-rw-r--r--drivers/regulator/tps65912-regulator.c6
-rw-r--r--drivers/regulator/tps80031-regulator.c793
-rw-r--r--drivers/regulator/twl-regulator.c6
-rw-r--r--drivers/regulator/vexpress.c147
-rw-r--r--drivers/regulator/virtual.c6
-rw-r--r--drivers/regulator/wm831x-dcdc.c26
-rw-r--r--drivers/regulator/wm831x-isink.c6
-rw-r--r--drivers/regulator/wm831x-ldo.c18
-rw-r--r--drivers/regulator/wm8400-regulator.c6
-rw-r--r--drivers/regulator/wm8994-regulator.c6
-rw-r--r--include/linux/mfd/tps65090.h35
-rw-r--r--include/linux/mfd/tps6586x.h3
-rw-r--r--include/linux/regulator/driver.h3
-rw-r--r--include/linux/regulator/tps51632-regulator.h47
-rw-r--r--include/linux/regulator/tps65090-regulator.h50
73 files changed, 2210 insertions, 401 deletions
diff --git a/Documentation/devicetree/bindings/regulator/gpio-regulator.txt b/Documentation/devicetree/bindings/regulator/gpio-regulator.txt
new file mode 100644
index 00000000000..63c659800c0
--- /dev/null
+++ b/Documentation/devicetree/bindings/regulator/gpio-regulator.txt
@@ -0,0 +1,37 @@
1GPIO controlled regulators
2
3Required properties:
4- compatible : Must be "regulator-gpio".
5- states : Selection of available voltages and GPIO configs.
6 if there are no states, then use a fixed regulator
7
8Optional properties:
9- enable-gpio : GPIO to use to enable/disable the regulator.
10- gpios : GPIO group used to control voltage.
11- startup-delay-us : Startup time in microseconds.
12- enable-active-high : Polarity of GPIO is active high (default is low).
13
14Any property defined as part of the core regulator binding defined in
15regulator.txt can also be used.
16
17Example:
18
19 mmciv: gpio-regulator {
20 compatible = "regulator-gpio";
21
22 regulator-name = "mmci-gpio-supply";
23 regulator-min-microvolt = <1800000>;
24 regulator-max-microvolt = <2600000>;
25 regulator-boot-on;
26
27 enable-gpio = <&gpio0 23 0x4>;
28 gpios = <&gpio0 24 0x4
29 &gpio0 25 0x4>;
30 states = <1800000 0x3
31 2200000 0x2
32 2600000 0x1
33 2900000 0x0>;
34
35 startup-delay-us = <100000>;
36 enable-active-high;
37 };
diff --git a/Documentation/devicetree/bindings/regulator/max8925-regulator.txt b/Documentation/devicetree/bindings/regulator/max8925-regulator.txt
new file mode 100644
index 00000000000..0057695aae8
--- /dev/null
+++ b/Documentation/devicetree/bindings/regulator/max8925-regulator.txt
@@ -0,0 +1,40 @@
1Max8925 Voltage regulators
2
3Required nodes:
4-nodes:
5 - SDV1 for SDV SDV1
6 - SDV2 for SDV SDV2
7 - SDV3 for SDV SDV3
8 - LDO1 for LDO LDO1
9 - LDO2 for LDO LDO2
10 - LDO3 for LDO LDO3
11 - LDO4 for LDO LDO4
12 - LDO5 for LDO LDO5
13 - LDO6 for LDO LDO6
14 - LDO7 for LDO LDO7
15 - LDO8 for LDO LDO8
16 - LDO9 for LDO LDO9
17 - LDO10 for LDO LDO10
18 - LDO11 for LDO LDO11
19 - LDO12 for LDO LDO12
20 - LDO13 for LDO LDO13
21 - LDO14 for LDO LDO14
22 - LDO15 for LDO LDO15
23 - LDO16 for LDO LDO16
24 - LDO17 for LDO LDO17
25 - LDO18 for LDO LDO18
26 - LDO19 for LDO LDO19
27 - LDO20 for LDO LDO20
28
29Optional properties:
30- Any optional property defined in bindings/regulator/regulator.txt
31
32Example:
33
34 SDV1 {
35 regulator-min-microvolt = <637500>;
36 regulator-max-microvolt = <1425000>;
37 regulator-boot-on;
38 regulator-always-on;
39 };
40
diff --git a/Documentation/devicetree/bindings/regulator/vexpress.txt b/Documentation/devicetree/bindings/regulator/vexpress.txt
new file mode 100644
index 00000000000..d775f72487a
--- /dev/null
+++ b/Documentation/devicetree/bindings/regulator/vexpress.txt
@@ -0,0 +1,32 @@
1Versatile Express voltage regulators
2------------------------------------
3
4Requires node properties:
5- "compatible" value: "arm,vexpress-volt"
6- "arm,vexpress-sysreg,func" when controlled via vexpress-sysreg
7 (see Documentation/devicetree/bindings/arm/vexpress-sysreg.txt
8 for more details)
9
10Required regulator properties:
11- "regulator-name"
12- "regulator-always-on"
13
14Optional regulator properties:
15- "regulator-min-microvolt"
16- "regulator-max-microvolt"
17
18See Documentation/devicetree/bindings/regulator/regulator.txt
19for more details about the regulator properties.
20
21When no "regulator-[min|max]-microvolt" properties are defined,
22the device is treated as fixed (or rather "read-only") regulator.
23
24Example:
25 volt@0 {
26 compatible = "arm,vexpress-volt";
27 arm,vexpress-sysreg,func = <2 0>;
28 regulator-name = "Cores";
29 regulator-min-microvolt = <800000>;
30 regulator-max-microvolt = <1050000>;
31 regulator-always-on;
32 };
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index acab3ef8a31..05acef8c764 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -201,7 +201,6 @@ config MFD_TPS6586X
201 depends on I2C=y && GENERIC_HARDIRQS 201 depends on I2C=y && GENERIC_HARDIRQS
202 select MFD_CORE 202 select MFD_CORE
203 select REGMAP_I2C 203 select REGMAP_I2C
204 depends on REGULATOR
205 help 204 help
206 If you say yes here you get support for the TPS6586X series of 205 If you say yes here you get support for the TPS6586X series of
207 Power Management chips. 206 Power Management chips.
diff --git a/drivers/mfd/tps6586x.c b/drivers/mfd/tps6586x.c
index 46746436877..9d67bd92edf 100644
--- a/drivers/mfd/tps6586x.c
+++ b/drivers/mfd/tps6586x.c
@@ -24,8 +24,6 @@
24#include <linux/err.h> 24#include <linux/err.h>
25#include <linux/i2c.h> 25#include <linux/i2c.h>
26#include <linux/regmap.h> 26#include <linux/regmap.h>
27#include <linux/regulator/of_regulator.h>
28#include <linux/regulator/machine.h>
29 27
30#include <linux/mfd/core.h> 28#include <linux/mfd/core.h>
31#include <linux/mfd/tps6586x.h> 29#include <linux/mfd/tps6586x.h>
@@ -99,6 +97,9 @@ static struct mfd_cell tps6586x_cell[] = {
99 .name = "tps6586x-gpio", 97 .name = "tps6586x-gpio",
100 }, 98 },
101 { 99 {
100 .name = "tps6586x-pmic",
101 },
102 {
102 .name = "tps6586x-rtc", 103 .name = "tps6586x-rtc",
103 }, 104 },
104 { 105 {
@@ -350,80 +351,19 @@ failed:
350} 351}
351 352
352#ifdef CONFIG_OF 353#ifdef CONFIG_OF
353static struct of_regulator_match tps6586x_matches[] = {
354 { .name = "sys", .driver_data = (void *)TPS6586X_ID_SYS },
355 { .name = "sm0", .driver_data = (void *)TPS6586X_ID_SM_0 },
356 { .name = "sm1", .driver_data = (void *)TPS6586X_ID_SM_1 },
357 { .name = "sm2", .driver_data = (void *)TPS6586X_ID_SM_2 },
358 { .name = "ldo0", .driver_data = (void *)TPS6586X_ID_LDO_0 },
359 { .name = "ldo1", .driver_data = (void *)TPS6586X_ID_LDO_1 },
360 { .name = "ldo2", .driver_data = (void *)TPS6586X_ID_LDO_2 },
361 { .name = "ldo3", .driver_data = (void *)TPS6586X_ID_LDO_3 },
362 { .name = "ldo4", .driver_data = (void *)TPS6586X_ID_LDO_4 },
363 { .name = "ldo5", .driver_data = (void *)TPS6586X_ID_LDO_5 },
364 { .name = "ldo6", .driver_data = (void *)TPS6586X_ID_LDO_6 },
365 { .name = "ldo7", .driver_data = (void *)TPS6586X_ID_LDO_7 },
366 { .name = "ldo8", .driver_data = (void *)TPS6586X_ID_LDO_8 },
367 { .name = "ldo9", .driver_data = (void *)TPS6586X_ID_LDO_9 },
368 { .name = "ldo_rtc", .driver_data = (void *)TPS6586X_ID_LDO_RTC },
369};
370
371static struct tps6586x_platform_data *tps6586x_parse_dt(struct i2c_client *client) 354static struct tps6586x_platform_data *tps6586x_parse_dt(struct i2c_client *client)
372{ 355{
373 const unsigned int num = ARRAY_SIZE(tps6586x_matches);
374 struct device_node *np = client->dev.of_node; 356 struct device_node *np = client->dev.of_node;
375 struct tps6586x_platform_data *pdata; 357 struct tps6586x_platform_data *pdata;
376 struct tps6586x_subdev_info *devs;
377 struct device_node *regs;
378 const char *sys_rail_name = NULL;
379 unsigned int count;
380 unsigned int i, j;
381 int err;
382
383 regs = of_find_node_by_name(np, "regulators");
384 if (!regs)
385 return NULL;
386
387 err = of_regulator_match(&client->dev, regs, tps6586x_matches, num);
388 if (err < 0) {
389 of_node_put(regs);
390 return NULL;
391 }
392
393 of_node_put(regs);
394 count = err;
395
396 devs = devm_kzalloc(&client->dev, count * sizeof(*devs), GFP_KERNEL);
397 if (!devs)
398 return NULL;
399
400 for (i = 0, j = 0; i < num && j < count; i++) {
401 struct regulator_init_data *reg_idata;
402
403 if (!tps6586x_matches[i].init_data)
404 continue;
405
406 reg_idata = tps6586x_matches[i].init_data;
407 devs[j].name = "tps6586x-regulator";
408 devs[j].platform_data = tps6586x_matches[i].init_data;
409 devs[j].id = (int)tps6586x_matches[i].driver_data;
410 if (devs[j].id == TPS6586X_ID_SYS)
411 sys_rail_name = reg_idata->constraints.name;
412
413 if ((devs[j].id == TPS6586X_ID_LDO_5) ||
414 (devs[j].id == TPS6586X_ID_LDO_RTC))
415 reg_idata->supply_regulator = sys_rail_name;
416
417 devs[j].of_node = tps6586x_matches[i].of_node;
418 j++;
419 }
420 358
421 pdata = devm_kzalloc(&client->dev, sizeof(*pdata), GFP_KERNEL); 359 pdata = devm_kzalloc(&client->dev, sizeof(*pdata), GFP_KERNEL);
422 if (!pdata) 360 if (!pdata) {
361 dev_err(&client->dev, "Memory allocation failed\n");
423 return NULL; 362 return NULL;
363 }
424 364
425 pdata->num_subdevs = count; 365 pdata->num_subdevs = 0;
426 pdata->subdevs = devs; 366 pdata->subdevs = NULL;
427 pdata->gpio_base = -1; 367 pdata->gpio_base = -1;
428 pdata->irq_base = -1; 368 pdata->irq_base = -1;
429 pdata->pm_off = of_property_read_bool(np, "ti,system-power-controller"); 369 pdata->pm_off = of_property_read_bool(np, "ti,system-power-controller");
diff --git a/drivers/regulator/88pm8607.c b/drivers/regulator/88pm8607.c
index 1c5ab0172ea..2b557119ada 100644
--- a/drivers/regulator/88pm8607.c
+++ b/drivers/regulator/88pm8607.c
@@ -394,7 +394,7 @@ static int pm8607_regulator_dt_init(struct platform_device *pdev,
394#define pm8607_regulator_dt_init(x, y, z) (-1) 394#define pm8607_regulator_dt_init(x, y, z) (-1)
395#endif 395#endif
396 396
397static int __devinit pm8607_regulator_probe(struct platform_device *pdev) 397static int pm8607_regulator_probe(struct platform_device *pdev)
398{ 398{
399 struct pm860x_chip *chip = dev_get_drvdata(pdev->dev.parent); 399 struct pm860x_chip *chip = dev_get_drvdata(pdev->dev.parent);
400 struct pm8607_regulator_info *info = NULL; 400 struct pm8607_regulator_info *info = NULL;
@@ -454,7 +454,7 @@ static int __devinit pm8607_regulator_probe(struct platform_device *pdev)
454 return 0; 454 return 0;
455} 455}
456 456
457static int __devexit pm8607_regulator_remove(struct platform_device *pdev) 457static int pm8607_regulator_remove(struct platform_device *pdev)
458{ 458{
459 struct pm8607_regulator_info *info = platform_get_drvdata(pdev); 459 struct pm8607_regulator_info *info = platform_get_drvdata(pdev);
460 460
@@ -481,7 +481,7 @@ static struct platform_driver pm8607_regulator_driver = {
481 .owner = THIS_MODULE, 481 .owner = THIS_MODULE,
482 }, 482 },
483 .probe = pm8607_regulator_probe, 483 .probe = pm8607_regulator_probe,
484 .remove = __devexit_p(pm8607_regulator_remove), 484 .remove = pm8607_regulator_remove,
485 .id_table = pm8607_regulator_driver_ids, 485 .id_table = pm8607_regulator_driver_ids,
486}; 486};
487 487
diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index 67d47b59a66..0ae658f048e 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -335,6 +335,17 @@ config REGULATOR_PALMAS
335 on the muxing. This is handled automatically in the driver by 335 on the muxing. This is handled automatically in the driver by
336 reading the mux info from OTP. 336 reading the mux info from OTP.
337 337
338config REGULATOR_TPS51632
339 tristate "TI TPS51632 Power Regulator"
340 depends on I2C
341 select REGMAP_I2C
342 help
343 This driver supports TPS51632 voltage regulator chip.
344 The TPS51632 is 3-2-1 Phase D-Cap+ Step Down Driverless Controller
345 with Serial VID control and DVFS.
346 The voltage output can be configure through I2C interface or PWM
347 interface.
348
338config REGULATOR_TPS6105X 349config REGULATOR_TPS6105X
339 tristate "TI TPS6105X Power regulators" 350 tristate "TI TPS6105X Power regulators"
340 depends on TPS6105X 351 depends on TPS6105X
@@ -415,6 +426,15 @@ config REGULATOR_TPS65912
415 help 426 help
416 This driver supports TPS65912 voltage regulator chip. 427 This driver supports TPS65912 voltage regulator chip.
417 428
429config REGULATOR_TPS80031
430 tristate "TI TPS80031/TPS80032 power regualtor driver"
431 depends on MFD_TPS80031
432 help
433 TPS80031/ TPS80032 Fully Integrated Power Management with Power
434 Path and Battery Charger. It has 5 configurable step-down
435 converters, 11 general purpose LDOs, VBUS generator and digital
436 output to control regulators.
437
418config REGULATOR_TWL4030 438config REGULATOR_TWL4030
419 bool "TI TWL4030/TWL5030/TWL6030/TPS659x0 PMIC" 439 bool "TI TWL4030/TWL5030/TWL6030/TPS659x0 PMIC"
420 depends on TWL4030_CORE 440 depends on TWL4030_CORE
@@ -422,6 +442,13 @@ config REGULATOR_TWL4030
422 This driver supports the voltage regulators provided by 442 This driver supports the voltage regulators provided by
423 this family of companion chips. 443 this family of companion chips.
424 444
445config REGULATOR_VEXPRESS
446 tristate "Versatile Express regulators"
447 depends on VEXPRESS_CONFIG
448 help
449 This driver provides support for voltage regulators available
450 on the ARM Ltd's Versatile Express platform.
451
425config REGULATOR_WM831X 452config REGULATOR_WM831X
426 tristate "Wolfson Microelectronics WM831x PMIC regulators" 453 tristate "Wolfson Microelectronics WM831x PMIC regulators"
427 depends on MFD_WM831X 454 depends on MFD_WM831X
diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile
index e431eed8a87..6166d122d12 100644
--- a/drivers/regulator/Makefile
+++ b/drivers/regulator/Makefile
@@ -41,6 +41,7 @@ obj-$(CONFIG_REGULATOR_MC13783) += mc13783-regulator.o
41obj-$(CONFIG_REGULATOR_MC13892) += mc13892-regulator.o 41obj-$(CONFIG_REGULATOR_MC13892) += mc13892-regulator.o
42obj-$(CONFIG_REGULATOR_MC13XXX_CORE) += mc13xxx-regulator-core.o 42obj-$(CONFIG_REGULATOR_MC13XXX_CORE) += mc13xxx-regulator-core.o
43obj-$(CONFIG_REGULATOR_PALMAS) += palmas-regulator.o 43obj-$(CONFIG_REGULATOR_PALMAS) += palmas-regulator.o
44obj-$(CONFIG_REGULATOR_TPS51632) += tps51632-regulator.o
44obj-$(CONFIG_REGULATOR_PCAP) += pcap-regulator.o 45obj-$(CONFIG_REGULATOR_PCAP) += pcap-regulator.o
45obj-$(CONFIG_REGULATOR_PCF50633) += pcf50633-regulator.o 46obj-$(CONFIG_REGULATOR_PCF50633) += pcf50633-regulator.o
46obj-$(CONFIG_REGULATOR_RC5T583) += rc5t583-regulator.o 47obj-$(CONFIG_REGULATOR_RC5T583) += rc5t583-regulator.o
@@ -56,7 +57,9 @@ obj-$(CONFIG_REGULATOR_TPS6524X) += tps6524x-regulator.o
56obj-$(CONFIG_REGULATOR_TPS6586X) += tps6586x-regulator.o 57obj-$(CONFIG_REGULATOR_TPS6586X) += tps6586x-regulator.o
57obj-$(CONFIG_REGULATOR_TPS65910) += tps65910-regulator.o 58obj-$(CONFIG_REGULATOR_TPS65910) += tps65910-regulator.o
58obj-$(CONFIG_REGULATOR_TPS65912) += tps65912-regulator.o 59obj-$(CONFIG_REGULATOR_TPS65912) += tps65912-regulator.o
60obj-$(CONFIG_REGULATOR_TPS80031) += tps80031-regulator.o
59obj-$(CONFIG_REGULATOR_TWL4030) += twl-regulator.o 61obj-$(CONFIG_REGULATOR_TWL4030) += twl-regulator.o
62obj-$(CONFIG_REGULATOR_VEXPRESS) += vexpress.o
60obj-$(CONFIG_REGULATOR_WM831X) += wm831x-dcdc.o 63obj-$(CONFIG_REGULATOR_WM831X) += wm831x-dcdc.o
61obj-$(CONFIG_REGULATOR_WM831X) += wm831x-isink.o 64obj-$(CONFIG_REGULATOR_WM831X) += wm831x-isink.o
62obj-$(CONFIG_REGULATOR_WM831X) += wm831x-ldo.o 65obj-$(CONFIG_REGULATOR_WM831X) += wm831x-ldo.o
diff --git a/drivers/regulator/aat2870-regulator.c b/drivers/regulator/aat2870-regulator.c
index 167c93f2198..8b5876356db 100644
--- a/drivers/regulator/aat2870-regulator.c
+++ b/drivers/regulator/aat2870-regulator.c
@@ -187,7 +187,7 @@ static int aat2870_regulator_probe(struct platform_device *pdev)
187 return 0; 187 return 0;
188} 188}
189 189
190static int __devexit aat2870_regulator_remove(struct platform_device *pdev) 190static int aat2870_regulator_remove(struct platform_device *pdev)
191{ 191{
192 struct regulator_dev *rdev = platform_get_drvdata(pdev); 192 struct regulator_dev *rdev = platform_get_drvdata(pdev);
193 193
@@ -201,7 +201,7 @@ static struct platform_driver aat2870_regulator_driver = {
201 .owner = THIS_MODULE, 201 .owner = THIS_MODULE,
202 }, 202 },
203 .probe = aat2870_regulator_probe, 203 .probe = aat2870_regulator_probe,
204 .remove = __devexit_p(aat2870_regulator_remove), 204 .remove = aat2870_regulator_remove,
205}; 205};
206 206
207static int __init aat2870_regulator_init(void) 207static int __init aat2870_regulator_init(void)
diff --git a/drivers/regulator/ab3100.c b/drivers/regulator/ab3100.c
index df4ad8927f0..111ec69a3e9 100644
--- a/drivers/regulator/ab3100.c
+++ b/drivers/regulator/ab3100.c
@@ -494,7 +494,7 @@ ab3100_regulator_desc[AB3100_NUM_REGULATORS] = {
494 * for all the different regulators. 494 * for all the different regulators.
495 */ 495 */
496 496
497static int __devinit ab3100_regulators_probe(struct platform_device *pdev) 497static int ab3100_regulators_probe(struct platform_device *pdev)
498{ 498{
499 struct ab3100_platform_data *plfdata = pdev->dev.platform_data; 499 struct ab3100_platform_data *plfdata = pdev->dev.platform_data;
500 struct regulator_config config = { }; 500 struct regulator_config config = { };
@@ -571,7 +571,7 @@ static int __devinit ab3100_regulators_probe(struct platform_device *pdev)
571 return 0; 571 return 0;
572} 572}
573 573
574static int __devexit ab3100_regulators_remove(struct platform_device *pdev) 574static int ab3100_regulators_remove(struct platform_device *pdev)
575{ 575{
576 int i; 576 int i;
577 577
@@ -589,7 +589,7 @@ static struct platform_driver ab3100_regulators_driver = {
589 .owner = THIS_MODULE, 589 .owner = THIS_MODULE,
590 }, 590 },
591 .probe = ab3100_regulators_probe, 591 .probe = ab3100_regulators_probe,
592 .remove = __devexit_p(ab3100_regulators_remove), 592 .remove = ab3100_regulators_remove,
593}; 593};
594 594
595static __init int ab3100_regulators_init(void) 595static __init int ab3100_regulators_init(void)
diff --git a/drivers/regulator/ab8500.c b/drivers/regulator/ab8500.c
index e3d1d063025..09014f38a94 100644
--- a/drivers/regulator/ab8500.c
+++ b/drivers/regulator/ab8500.c
@@ -641,7 +641,7 @@ static struct ab8500_reg_init ab8500_reg_init[] = {
641 REG_INIT(AB8500_REGUCTRLDISCH2, 0x04, 0x44, 0x16), 641 REG_INIT(AB8500_REGUCTRLDISCH2, 0x04, 0x44, 0x16),
642}; 642};
643 643
644static __devinit int 644static int
645ab8500_regulator_init_registers(struct platform_device *pdev, int id, int value) 645ab8500_regulator_init_registers(struct platform_device *pdev, int id, int value)
646{ 646{
647 int err; 647 int err;
@@ -676,7 +676,7 @@ ab8500_regulator_init_registers(struct platform_device *pdev, int id, int value)
676 return 0; 676 return 0;
677} 677}
678 678
679static __devinit int ab8500_regulator_register(struct platform_device *pdev, 679static int ab8500_regulator_register(struct platform_device *pdev,
680 struct regulator_init_data *init_data, 680 struct regulator_init_data *init_data,
681 int id, 681 int id,
682 struct device_node *np) 682 struct device_node *np)
@@ -735,7 +735,7 @@ static struct of_regulator_match ab8500_regulator_matches[] = {
735 { .name = "ab8500_ldo_ana", .driver_data = (void *) AB8500_LDO_ANA, }, 735 { .name = "ab8500_ldo_ana", .driver_data = (void *) AB8500_LDO_ANA, },
736}; 736};
737 737
738static __devinit int 738static int
739ab8500_regulator_of_probe(struct platform_device *pdev, struct device_node *np) 739ab8500_regulator_of_probe(struct platform_device *pdev, struct device_node *np)
740{ 740{
741 int err, i; 741 int err, i;
@@ -751,7 +751,7 @@ ab8500_regulator_of_probe(struct platform_device *pdev, struct device_node *np)
751 return 0; 751 return 0;
752} 752}
753 753
754static __devinit int ab8500_regulator_probe(struct platform_device *pdev) 754static int ab8500_regulator_probe(struct platform_device *pdev)
755{ 755{
756 struct ab8500 *ab8500 = dev_get_drvdata(pdev->dev.parent); 756 struct ab8500 *ab8500 = dev_get_drvdata(pdev->dev.parent);
757 struct ab8500_platform_data *pdata; 757 struct ab8500_platform_data *pdata;
@@ -817,7 +817,7 @@ static __devinit int ab8500_regulator_probe(struct platform_device *pdev)
817 return 0; 817 return 0;
818} 818}
819 819
820static __devexit int ab8500_regulator_remove(struct platform_device *pdev) 820static int ab8500_regulator_remove(struct platform_device *pdev)
821{ 821{
822 int i; 822 int i;
823 823
@@ -836,7 +836,7 @@ static __devexit int ab8500_regulator_remove(struct platform_device *pdev)
836 836
837static struct platform_driver ab8500_regulator_driver = { 837static struct platform_driver ab8500_regulator_driver = {
838 .probe = ab8500_regulator_probe, 838 .probe = ab8500_regulator_probe,
839 .remove = __devexit_p(ab8500_regulator_remove), 839 .remove = ab8500_regulator_remove,
840 .driver = { 840 .driver = {
841 .name = "ab8500-regulator", 841 .name = "ab8500-regulator",
842 .owner = THIS_MODULE, 842 .owner = THIS_MODULE,
diff --git a/drivers/regulator/ad5398.c b/drivers/regulator/ad5398.c
index f123f7e3b75..6b981b5faa7 100644
--- a/drivers/regulator/ad5398.c
+++ b/drivers/regulator/ad5398.c
@@ -211,7 +211,7 @@ static const struct i2c_device_id ad5398_id[] = {
211}; 211};
212MODULE_DEVICE_TABLE(i2c, ad5398_id); 212MODULE_DEVICE_TABLE(i2c, ad5398_id);
213 213
214static int __devinit ad5398_probe(struct i2c_client *client, 214static int ad5398_probe(struct i2c_client *client,
215 const struct i2c_device_id *id) 215 const struct i2c_device_id *id)
216{ 216{
217 struct regulator_init_data *init_data = client->dev.platform_data; 217 struct regulator_init_data *init_data = client->dev.platform_data;
@@ -256,7 +256,7 @@ err:
256 return ret; 256 return ret;
257} 257}
258 258
259static int __devexit ad5398_remove(struct i2c_client *client) 259static int ad5398_remove(struct i2c_client *client)
260{ 260{
261 struct ad5398_chip_info *chip = i2c_get_clientdata(client); 261 struct ad5398_chip_info *chip = i2c_get_clientdata(client);
262 262
@@ -266,7 +266,7 @@ static int __devexit ad5398_remove(struct i2c_client *client)
266 266
267static struct i2c_driver ad5398_driver = { 267static struct i2c_driver ad5398_driver = {
268 .probe = ad5398_probe, 268 .probe = ad5398_probe,
269 .remove = __devexit_p(ad5398_remove), 269 .remove = ad5398_remove,
270 .driver = { 270 .driver = {
271 .name = "ad5398", 271 .name = "ad5398",
272 }, 272 },
diff --git a/drivers/regulator/anatop-regulator.c b/drivers/regulator/anatop-regulator.c
index 1af97686f44..1aa5246c79d 100644
--- a/drivers/regulator/anatop-regulator.c
+++ b/drivers/regulator/anatop-regulator.c
@@ -87,7 +87,7 @@ static struct regulator_ops anatop_rops = {
87 .map_voltage = regulator_map_voltage_linear, 87 .map_voltage = regulator_map_voltage_linear,
88}; 88};
89 89
90static int __devinit anatop_regulator_probe(struct platform_device *pdev) 90static int anatop_regulator_probe(struct platform_device *pdev)
91{ 91{
92 struct device *dev = &pdev->dev; 92 struct device *dev = &pdev->dev;
93 struct device_node *np = dev->of_node; 93 struct device_node *np = dev->of_node;
@@ -186,7 +186,7 @@ anatop_probe_end:
186 return ret; 186 return ret;
187} 187}
188 188
189static int __devexit anatop_regulator_remove(struct platform_device *pdev) 189static int anatop_regulator_remove(struct platform_device *pdev)
190{ 190{
191 struct regulator_dev *rdev = platform_get_drvdata(pdev); 191 struct regulator_dev *rdev = platform_get_drvdata(pdev);
192 struct anatop_regulator *sreg = rdev_get_drvdata(rdev); 192 struct anatop_regulator *sreg = rdev_get_drvdata(rdev);
@@ -210,7 +210,7 @@ static struct platform_driver anatop_regulator_driver = {
210 .of_match_table = of_anatop_regulator_match_tbl, 210 .of_match_table = of_anatop_regulator_match_tbl,
211 }, 211 },
212 .probe = anatop_regulator_probe, 212 .probe = anatop_regulator_probe,
213 .remove = __devexit_p(anatop_regulator_remove), 213 .remove = anatop_regulator_remove,
214}; 214};
215 215
216static int __init anatop_regulator_init(void) 216static int __init anatop_regulator_init(void)
diff --git a/drivers/regulator/arizona-ldo1.c b/drivers/regulator/arizona-ldo1.c
index d184aa35abc..b44fa6f0e94 100644
--- a/drivers/regulator/arizona-ldo1.c
+++ b/drivers/regulator/arizona-ldo1.c
@@ -67,7 +67,7 @@ static const struct regulator_init_data arizona_ldo1_default = {
67 .num_consumer_supplies = 1, 67 .num_consumer_supplies = 1,
68}; 68};
69 69
70static __devinit int arizona_ldo1_probe(struct platform_device *pdev) 70static int arizona_ldo1_probe(struct platform_device *pdev)
71{ 71{
72 struct arizona *arizona = dev_get_drvdata(pdev->dev.parent); 72 struct arizona *arizona = dev_get_drvdata(pdev->dev.parent);
73 struct regulator_config config = { }; 73 struct regulator_config config = { };
@@ -115,7 +115,7 @@ static __devinit int arizona_ldo1_probe(struct platform_device *pdev)
115 return 0; 115 return 0;
116} 116}
117 117
118static __devexit int arizona_ldo1_remove(struct platform_device *pdev) 118static int arizona_ldo1_remove(struct platform_device *pdev)
119{ 119{
120 struct arizona_ldo1 *ldo1 = platform_get_drvdata(pdev); 120 struct arizona_ldo1 *ldo1 = platform_get_drvdata(pdev);
121 121
@@ -126,7 +126,7 @@ static __devexit int arizona_ldo1_remove(struct platform_device *pdev)
126 126
127static struct platform_driver arizona_ldo1_driver = { 127static struct platform_driver arizona_ldo1_driver = {
128 .probe = arizona_ldo1_probe, 128 .probe = arizona_ldo1_probe,
129 .remove = __devexit_p(arizona_ldo1_remove), 129 .remove = arizona_ldo1_remove,
130 .driver = { 130 .driver = {
131 .name = "arizona-ldo1", 131 .name = "arizona-ldo1",
132 .owner = THIS_MODULE, 132 .owner = THIS_MODULE,
diff --git a/drivers/regulator/arizona-micsupp.c b/drivers/regulator/arizona-micsupp.c
index d9b1f82cc5b..5ae2d3e794b 100644
--- a/drivers/regulator/arizona-micsupp.c
+++ b/drivers/regulator/arizona-micsupp.c
@@ -115,7 +115,7 @@ static const struct regulator_init_data arizona_micsupp_default = {
115 .num_consumer_supplies = 1, 115 .num_consumer_supplies = 1,
116}; 116};
117 117
118static __devinit int arizona_micsupp_probe(struct platform_device *pdev) 118static int arizona_micsupp_probe(struct platform_device *pdev)
119{ 119{
120 struct arizona *arizona = dev_get_drvdata(pdev->dev.parent); 120 struct arizona *arizona = dev_get_drvdata(pdev->dev.parent);
121 struct regulator_config config = { }; 121 struct regulator_config config = { };
@@ -166,7 +166,7 @@ static __devinit int arizona_micsupp_probe(struct platform_device *pdev)
166 return 0; 166 return 0;
167} 167}
168 168
169static __devexit int arizona_micsupp_remove(struct platform_device *pdev) 169static int arizona_micsupp_remove(struct platform_device *pdev)
170{ 170{
171 struct arizona_micsupp *micsupp = platform_get_drvdata(pdev); 171 struct arizona_micsupp *micsupp = platform_get_drvdata(pdev);
172 172
@@ -177,7 +177,7 @@ static __devexit int arizona_micsupp_remove(struct platform_device *pdev)
177 177
178static struct platform_driver arizona_micsupp_driver = { 178static struct platform_driver arizona_micsupp_driver = {
179 .probe = arizona_micsupp_probe, 179 .probe = arizona_micsupp_probe,
180 .remove = __devexit_p(arizona_micsupp_remove), 180 .remove = arizona_micsupp_remove,
181 .driver = { 181 .driver = {
182 .name = "arizona-micsupp", 182 .name = "arizona-micsupp",
183 .owner = THIS_MODULE, 183 .owner = THIS_MODULE,
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index e872c8be080..3db1e011d22 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -1985,6 +1985,11 @@ int regulator_is_supported_voltage(struct regulator *regulator,
1985 return ret; 1985 return ret;
1986 } 1986 }
1987 1987
1988 /* Any voltage within constrains range is fine? */
1989 if (rdev->desc->continuous_voltage_range)
1990 return min_uV >= rdev->constraints->min_uV &&
1991 max_uV <= rdev->constraints->max_uV;
1992
1988 ret = regulator_count_voltages(regulator); 1993 ret = regulator_count_voltages(regulator);
1989 if (ret < 0) 1994 if (ret < 0)
1990 return ret; 1995 return ret;
diff --git a/drivers/regulator/da903x.c b/drivers/regulator/da903x.c
index 36c5b92fe0a..2afa5730f32 100644
--- a/drivers/regulator/da903x.c
+++ b/drivers/regulator/da903x.c
@@ -460,7 +460,7 @@ static inline struct da903x_regulator_info *find_regulator_info(int id)
460 return NULL; 460 return NULL;
461} 461}
462 462
463static int __devinit da903x_regulator_probe(struct platform_device *pdev) 463static int da903x_regulator_probe(struct platform_device *pdev)
464{ 464{
465 struct da903x_regulator_info *ri = NULL; 465 struct da903x_regulator_info *ri = NULL;
466 struct regulator_dev *rdev; 466 struct regulator_dev *rdev;
@@ -499,7 +499,7 @@ static int __devinit da903x_regulator_probe(struct platform_device *pdev)
499 return 0; 499 return 0;
500} 500}
501 501
502static int __devexit da903x_regulator_remove(struct platform_device *pdev) 502static int da903x_regulator_remove(struct platform_device *pdev)
503{ 503{
504 struct regulator_dev *rdev = platform_get_drvdata(pdev); 504 struct regulator_dev *rdev = platform_get_drvdata(pdev);
505 505
@@ -513,7 +513,7 @@ static struct platform_driver da903x_regulator_driver = {
513 .owner = THIS_MODULE, 513 .owner = THIS_MODULE,
514 }, 514 },
515 .probe = da903x_regulator_probe, 515 .probe = da903x_regulator_probe,
516 .remove = __devexit_p(da903x_regulator_remove), 516 .remove = da903x_regulator_remove,
517}; 517};
518 518
519static int __init da903x_regulator_init(void) 519static int __init da903x_regulator_init(void)
diff --git a/drivers/regulator/da9052-regulator.c b/drivers/regulator/da9052-regulator.c
index 27355b1199e..d6fbfd3dced 100644
--- a/drivers/regulator/da9052-regulator.c
+++ b/drivers/regulator/da9052-regulator.c
@@ -365,7 +365,7 @@ static inline struct da9052_regulator_info *find_regulator_info(u8 chip_id,
365 return NULL; 365 return NULL;
366} 366}
367 367
368static int __devinit da9052_regulator_probe(struct platform_device *pdev) 368static int da9052_regulator_probe(struct platform_device *pdev)
369{ 369{
370 struct regulator_config config = { }; 370 struct regulator_config config = { };
371 struct da9052_regulator *regulator; 371 struct da9052_regulator *regulator;
@@ -430,7 +430,7 @@ static int __devinit da9052_regulator_probe(struct platform_device *pdev)
430 return 0; 430 return 0;
431} 431}
432 432
433static int __devexit da9052_regulator_remove(struct platform_device *pdev) 433static int da9052_regulator_remove(struct platform_device *pdev)
434{ 434{
435 struct da9052_regulator *regulator = platform_get_drvdata(pdev); 435 struct da9052_regulator *regulator = platform_get_drvdata(pdev);
436 436
@@ -440,7 +440,7 @@ static int __devexit da9052_regulator_remove(struct platform_device *pdev)
440 440
441static struct platform_driver da9052_regulator_driver = { 441static struct platform_driver da9052_regulator_driver = {
442 .probe = da9052_regulator_probe, 442 .probe = da9052_regulator_probe,
443 .remove = __devexit_p(da9052_regulator_remove), 443 .remove = da9052_regulator_remove,
444 .driver = { 444 .driver = {
445 .name = "da9052-regulator", 445 .name = "da9052-regulator",
446 .owner = THIS_MODULE, 446 .owner = THIS_MODULE,
diff --git a/drivers/regulator/db8500-prcmu.c b/drivers/regulator/db8500-prcmu.c
index 359f8d18fc3..219d162b651 100644
--- a/drivers/regulator/db8500-prcmu.c
+++ b/drivers/regulator/db8500-prcmu.c
@@ -412,7 +412,7 @@ dbx500_regulator_info[DB8500_NUM_REGULATORS] = {
412 }, 412 },
413}; 413};
414 414
415static __devinit int db8500_regulator_register(struct platform_device *pdev, 415static int db8500_regulator_register(struct platform_device *pdev,
416 struct regulator_init_data *init_data, 416 struct regulator_init_data *init_data,
417 int id, 417 int id,
418 struct device_node *np) 418 struct device_node *np)
@@ -474,7 +474,7 @@ static struct of_regulator_match db8500_regulator_matches[] = {
474 { .name = "db8500_esram34_ret", .driver_data = (void *) DB8500_REGULATOR_SWITCH_ESRAM34RET, }, 474 { .name = "db8500_esram34_ret", .driver_data = (void *) DB8500_REGULATOR_SWITCH_ESRAM34RET, },
475}; 475};
476 476
477static __devinit int 477static int
478db8500_regulator_of_probe(struct platform_device *pdev, 478db8500_regulator_of_probe(struct platform_device *pdev,
479 struct device_node *np) 479 struct device_node *np)
480{ 480{
@@ -491,7 +491,7 @@ db8500_regulator_of_probe(struct platform_device *pdev,
491 return 0; 491 return 0;
492} 492}
493 493
494static int __devinit db8500_regulator_probe(struct platform_device *pdev) 494static int db8500_regulator_probe(struct platform_device *pdev)
495{ 495{
496 struct regulator_init_data *db8500_init_data = 496 struct regulator_init_data *db8500_init_data =
497 dev_get_platdata(&pdev->dev); 497 dev_get_platdata(&pdev->dev);
diff --git a/drivers/regulator/dbx500-prcmu.c b/drivers/regulator/dbx500-prcmu.c
index f2e5ecdc586..261f3d2299b 100644
--- a/drivers/regulator/dbx500-prcmu.c
+++ b/drivers/regulator/dbx500-prcmu.c
@@ -173,7 +173,7 @@ int __attribute__((weak)) dbx500_regulator_testcase(
173 return 0; 173 return 0;
174} 174}
175 175
176int __devinit 176int
177ux500_regulator_debug_init(struct platform_device *pdev, 177ux500_regulator_debug_init(struct platform_device *pdev,
178 struct dbx500_regulator_info *regulator_info, 178 struct dbx500_regulator_info *regulator_info,
179 int num_regulators) 179 int num_regulators)
@@ -230,7 +230,7 @@ exit_no_debugfs:
230 return -ENOMEM; 230 return -ENOMEM;
231} 231}
232 232
233int __devexit ux500_regulator_debug_exit(void) 233int ux500_regulator_debug_exit(void)
234{ 234{
235 debugfs_remove_recursive(rdebug.dir); 235 debugfs_remove_recursive(rdebug.dir);
236 kfree(rdebug.state_after_suspend); 236 kfree(rdebug.state_after_suspend);
diff --git a/drivers/regulator/dummy.c b/drivers/regulator/dummy.c
index 03a1d7c11ef..df9f42524ab 100644
--- a/drivers/regulator/dummy.c
+++ b/drivers/regulator/dummy.c
@@ -37,7 +37,7 @@ static struct regulator_desc dummy_desc = {
37 .ops = &dummy_ops, 37 .ops = &dummy_ops,
38}; 38};
39 39
40static int __devinit dummy_regulator_probe(struct platform_device *pdev) 40static int dummy_regulator_probe(struct platform_device *pdev)
41{ 41{
42 struct regulator_config config = { }; 42 struct regulator_config config = { };
43 int ret; 43 int ret;
diff --git a/drivers/regulator/fan53555.c b/drivers/regulator/fan53555.c
index 339f4d732e9..9165b0c40ed 100644
--- a/drivers/regulator/fan53555.c
+++ b/drivers/regulator/fan53555.c
@@ -230,7 +230,7 @@ static struct regmap_config fan53555_regmap_config = {
230 .val_bits = 8, 230 .val_bits = 8,
231}; 231};
232 232
233static int __devinit fan53555_regulator_probe(struct i2c_client *client, 233static int fan53555_regulator_probe(struct i2c_client *client,
234 const struct i2c_device_id *id) 234 const struct i2c_device_id *id)
235{ 235{
236 struct fan53555_device_info *di; 236 struct fan53555_device_info *di;
@@ -293,7 +293,7 @@ static int __devinit fan53555_regulator_probe(struct i2c_client *client,
293 293
294} 294}
295 295
296static int __devexit fan53555_regulator_remove(struct i2c_client *client) 296static int fan53555_regulator_remove(struct i2c_client *client)
297{ 297{
298 struct fan53555_device_info *di = i2c_get_clientdata(client); 298 struct fan53555_device_info *di = i2c_get_clientdata(client);
299 299
@@ -311,7 +311,7 @@ static struct i2c_driver fan53555_regulator_driver = {
311 .name = "fan53555-regulator", 311 .name = "fan53555-regulator",
312 }, 312 },
313 .probe = fan53555_regulator_probe, 313 .probe = fan53555_regulator_probe,
314 .remove = __devexit_p(fan53555_regulator_remove), 314 .remove = fan53555_regulator_remove,
315 .id_table = fan53555_id, 315 .id_table = fan53555_id,
316}; 316};
317 317
diff --git a/drivers/regulator/fixed.c b/drivers/regulator/fixed.c
index 185468c4d38..48d5b7608b0 100644
--- a/drivers/regulator/fixed.c
+++ b/drivers/regulator/fixed.c
@@ -134,7 +134,7 @@ static struct regulator_ops fixed_voltage_ops = {
134 .list_voltage = fixed_voltage_list_voltage, 134 .list_voltage = fixed_voltage_list_voltage,
135}; 135};
136 136
137static int __devinit reg_fixed_voltage_probe(struct platform_device *pdev) 137static int reg_fixed_voltage_probe(struct platform_device *pdev)
138{ 138{
139 struct fixed_voltage_config *config; 139 struct fixed_voltage_config *config;
140 struct fixed_voltage_data *drvdata; 140 struct fixed_voltage_data *drvdata;
@@ -234,7 +234,7 @@ err:
234 return ret; 234 return ret;
235} 235}
236 236
237static int __devexit reg_fixed_voltage_remove(struct platform_device *pdev) 237static int reg_fixed_voltage_remove(struct platform_device *pdev)
238{ 238{
239 struct fixed_voltage_data *drvdata = platform_get_drvdata(pdev); 239 struct fixed_voltage_data *drvdata = platform_get_drvdata(pdev);
240 240
@@ -255,7 +255,7 @@ MODULE_DEVICE_TABLE(of, fixed_of_match);
255 255
256static struct platform_driver regulator_fixed_voltage_driver = { 256static struct platform_driver regulator_fixed_voltage_driver = {
257 .probe = reg_fixed_voltage_probe, 257 .probe = reg_fixed_voltage_probe,
258 .remove = __devexit_p(reg_fixed_voltage_remove), 258 .remove = reg_fixed_voltage_remove,
259 .driver = { 259 .driver = {
260 .name = "reg-fixed-voltage", 260 .name = "reg-fixed-voltage",
261 .owner = THIS_MODULE, 261 .owner = THIS_MODULE,
diff --git a/drivers/regulator/gpio-regulator.c b/drivers/regulator/gpio-regulator.c
index 8b5944f2d7d..3ee79c83ae5 100644
--- a/drivers/regulator/gpio-regulator.c
+++ b/drivers/regulator/gpio-regulator.c
@@ -28,9 +28,12 @@
28#include <linux/platform_device.h> 28#include <linux/platform_device.h>
29#include <linux/regulator/driver.h> 29#include <linux/regulator/driver.h>
30#include <linux/regulator/machine.h> 30#include <linux/regulator/machine.h>
31#include <linux/regulator/of_regulator.h>
31#include <linux/regulator/gpio-regulator.h> 32#include <linux/regulator/gpio-regulator.h>
32#include <linux/gpio.h> 33#include <linux/gpio.h>
33#include <linux/slab.h> 34#include <linux/slab.h>
35#include <linux/of.h>
36#include <linux/of_gpio.h>
34 37
35struct gpio_regulator_data { 38struct gpio_regulator_data {
36 struct regulator_desc desc; 39 struct regulator_desc desc;
@@ -129,18 +132,108 @@ static struct regulator_ops gpio_regulator_voltage_ops = {
129 .list_voltage = gpio_regulator_list_voltage, 132 .list_voltage = gpio_regulator_list_voltage,
130}; 133};
131 134
135struct gpio_regulator_config *
136of_get_gpio_regulator_config(struct device *dev, struct device_node *np)
137{
138 struct gpio_regulator_config *config;
139 struct property *prop;
140 const char *regtype;
141 int proplen, gpio, i;
142
143 config = devm_kzalloc(dev,
144 sizeof(struct gpio_regulator_config),
145 GFP_KERNEL);
146 if (!config)
147 return ERR_PTR(-ENOMEM);
148
149 config->init_data = of_get_regulator_init_data(dev, np);
150 if (!config->init_data)
151 return ERR_PTR(-EINVAL);
152
153 config->supply_name = config->init_data->constraints.name;
154
155 if (of_property_read_bool(np, "enable-active-high"))
156 config->enable_high = true;
157
158 if (of_property_read_bool(np, "enable-at-boot"))
159 config->enabled_at_boot = true;
160
161 of_property_read_u32(np, "startup-delay-us", &config->startup_delay);
162
163 config->enable_gpio = of_get_named_gpio(np, "enable-gpio", 0);
164
165 /* Fetch GPIOs. */
166 for (i = 0; ; i++)
167 if (of_get_named_gpio(np, "gpios", i) < 0)
168 break;
169 config->nr_gpios = i;
170
171 config->gpios = devm_kzalloc(dev,
172 sizeof(struct gpio) * config->nr_gpios,
173 GFP_KERNEL);
174 if (!config->gpios)
175 return ERR_PTR(-ENOMEM);
176
177 for (i = 0; config->nr_gpios; i++) {
178 gpio = of_get_named_gpio(np, "gpios", i);
179 if (gpio < 0)
180 break;
181 config->gpios[i].gpio = gpio;
182 }
183
184 /* Fetch states. */
185 prop = of_find_property(np, "states", NULL);
186 if (!prop) {
187 dev_err(dev, "No 'states' property found\n");
188 return ERR_PTR(-EINVAL);
189 }
190
191 proplen = prop->length / sizeof(int);
192
193 config->states = devm_kzalloc(dev,
194 sizeof(struct gpio_regulator_state)
195 * (proplen / 2),
196 GFP_KERNEL);
197 if (!config->states)
198 return ERR_PTR(-ENOMEM);
199
200 for (i = 0; i < proplen / 2; i++) {
201 config->states[i].value =
202 be32_to_cpup((int *)prop->value + (i * 2));
203 config->states[i].gpios =
204 be32_to_cpup((int *)prop->value + (i * 2 + 1));
205 }
206 config->nr_states = i;
207
208 of_property_read_string(np, "regulator-type", &regtype);
209
210 if (!strncmp("voltage", regtype, 7))
211 config->type = REGULATOR_VOLTAGE;
212 else if (!strncmp("current", regtype, 7))
213 config->type = REGULATOR_CURRENT;
214
215 return config;
216}
217
132static struct regulator_ops gpio_regulator_current_ops = { 218static struct regulator_ops gpio_regulator_current_ops = {
133 .get_current_limit = gpio_regulator_get_value, 219 .get_current_limit = gpio_regulator_get_value,
134 .set_current_limit = gpio_regulator_set_current_limit, 220 .set_current_limit = gpio_regulator_set_current_limit,
135}; 221};
136 222
137static int __devinit gpio_regulator_probe(struct platform_device *pdev) 223static int gpio_regulator_probe(struct platform_device *pdev)
138{ 224{
139 struct gpio_regulator_config *config = pdev->dev.platform_data; 225 struct gpio_regulator_config *config = pdev->dev.platform_data;
226 struct device_node *np = pdev->dev.of_node;
140 struct gpio_regulator_data *drvdata; 227 struct gpio_regulator_data *drvdata;
141 struct regulator_config cfg = { }; 228 struct regulator_config cfg = { };
142 int ptr, ret, state; 229 int ptr, ret, state;
143 230
231 if (np) {
232 config = of_get_gpio_regulator_config(&pdev->dev, np);
233 if (IS_ERR(config))
234 return PTR_ERR(config);
235 }
236
144 drvdata = devm_kzalloc(&pdev->dev, sizeof(struct gpio_regulator_data), 237 drvdata = devm_kzalloc(&pdev->dev, sizeof(struct gpio_regulator_data),
145 GFP_KERNEL); 238 GFP_KERNEL);
146 if (drvdata == NULL) { 239 if (drvdata == NULL) {
@@ -215,6 +308,7 @@ static int __devinit gpio_regulator_probe(struct platform_device *pdev)
215 cfg.dev = &pdev->dev; 308 cfg.dev = &pdev->dev;
216 cfg.init_data = config->init_data; 309 cfg.init_data = config->init_data;
217 cfg.driver_data = drvdata; 310 cfg.driver_data = drvdata;
311 cfg.of_node = np;
218 312
219 if (config->enable_gpio >= 0) 313 if (config->enable_gpio >= 0)
220 cfg.ena_gpio = config->enable_gpio; 314 cfg.ena_gpio = config->enable_gpio;
@@ -254,7 +348,7 @@ err:
254 return ret; 348 return ret;
255} 349}
256 350
257static int __devexit gpio_regulator_remove(struct platform_device *pdev) 351static int gpio_regulator_remove(struct platform_device *pdev)
258{ 352{
259 struct gpio_regulator_data *drvdata = platform_get_drvdata(pdev); 353 struct gpio_regulator_data *drvdata = platform_get_drvdata(pdev);
260 354
@@ -270,12 +364,18 @@ static int __devexit gpio_regulator_remove(struct platform_device *pdev)
270 return 0; 364 return 0;
271} 365}
272 366
367static const struct of_device_id regulator_gpio_of_match[] __devinitconst = {
368 { .compatible = "regulator-gpio", },
369 {},
370};
371
273static struct platform_driver gpio_regulator_driver = { 372static struct platform_driver gpio_regulator_driver = {
274 .probe = gpio_regulator_probe, 373 .probe = gpio_regulator_probe,
275 .remove = __devexit_p(gpio_regulator_remove), 374 .remove = gpio_regulator_remove,
276 .driver = { 375 .driver = {
277 .name = "gpio-regulator", 376 .name = "gpio-regulator",
278 .owner = THIS_MODULE, 377 .owner = THIS_MODULE,
378 .of_match_table = regulator_gpio_of_match,
279 }, 379 },
280}; 380};
281 381
diff --git a/drivers/regulator/isl6271a-regulator.c b/drivers/regulator/isl6271a-regulator.c
index d8ecf49a577..d1e5bee2a26 100644
--- a/drivers/regulator/isl6271a-regulator.c
+++ b/drivers/regulator/isl6271a-regulator.c
@@ -106,7 +106,7 @@ static const struct regulator_desc isl_rd[] = {
106 }, 106 },
107}; 107};
108 108
109static int __devinit isl6271a_probe(struct i2c_client *i2c, 109static int isl6271a_probe(struct i2c_client *i2c,
110 const struct i2c_device_id *id) 110 const struct i2c_device_id *id)
111{ 111{
112 struct regulator_config config = { }; 112 struct regulator_config config = { };
@@ -151,7 +151,7 @@ error:
151 return err; 151 return err;
152} 152}
153 153
154static int __devexit isl6271a_remove(struct i2c_client *i2c) 154static int isl6271a_remove(struct i2c_client *i2c)
155{ 155{
156 struct isl_pmic *pmic = i2c_get_clientdata(i2c); 156 struct isl_pmic *pmic = i2c_get_clientdata(i2c);
157 int i; 157 int i;
@@ -174,7 +174,7 @@ static struct i2c_driver isl6271a_i2c_driver = {
174 .owner = THIS_MODULE, 174 .owner = THIS_MODULE,
175 }, 175 },
176 .probe = isl6271a_probe, 176 .probe = isl6271a_probe,
177 .remove = __devexit_p(isl6271a_remove), 177 .remove = isl6271a_remove,
178 .id_table = isl6271a_id, 178 .id_table = isl6271a_id,
179}; 179};
180 180
diff --git a/drivers/regulator/lp3971.c b/drivers/regulator/lp3971.c
index 7c6e3b8ff48..5f68ff11a29 100644
--- a/drivers/regulator/lp3971.c
+++ b/drivers/regulator/lp3971.c
@@ -386,7 +386,7 @@ static int lp3971_set_bits(struct lp3971 *lp3971, u8 reg, u16 mask, u16 val)
386 return ret; 386 return ret;
387} 387}
388 388
389static int __devinit setup_regulators(struct lp3971 *lp3971, 389static int setup_regulators(struct lp3971 *lp3971,
390 struct lp3971_platform_data *pdata) 390 struct lp3971_platform_data *pdata)
391{ 391{
392 int i, err; 392 int i, err;
@@ -429,7 +429,7 @@ err_nomem:
429 return err; 429 return err;
430} 430}
431 431
432static int __devinit lp3971_i2c_probe(struct i2c_client *i2c, 432static int lp3971_i2c_probe(struct i2c_client *i2c,
433 const struct i2c_device_id *id) 433 const struct i2c_device_id *id)
434{ 434{
435 struct lp3971 *lp3971; 435 struct lp3971 *lp3971;
@@ -472,7 +472,7 @@ err_detect:
472 return ret; 472 return ret;
473} 473}
474 474
475static int __devexit lp3971_i2c_remove(struct i2c_client *i2c) 475static int lp3971_i2c_remove(struct i2c_client *i2c)
476{ 476{
477 struct lp3971 *lp3971 = i2c_get_clientdata(i2c); 477 struct lp3971 *lp3971 = i2c_get_clientdata(i2c);
478 int i; 478 int i;
@@ -498,7 +498,7 @@ static struct i2c_driver lp3971_i2c_driver = {
498 .owner = THIS_MODULE, 498 .owner = THIS_MODULE,
499 }, 499 },
500 .probe = lp3971_i2c_probe, 500 .probe = lp3971_i2c_probe,
501 .remove = __devexit_p(lp3971_i2c_remove), 501 .remove = lp3971_i2c_remove,
502 .id_table = lp3971_i2c_id, 502 .id_table = lp3971_i2c_id,
503}; 503};
504 504
diff --git a/drivers/regulator/lp3972.c b/drivers/regulator/lp3972.c
index 3cdc755d9b2..69c42c318b8 100644
--- a/drivers/regulator/lp3972.c
+++ b/drivers/regulator/lp3972.c
@@ -481,7 +481,7 @@ static const struct regulator_desc regulators[] = {
481 }, 481 },
482}; 482};
483 483
484static int __devinit setup_regulators(struct lp3972 *lp3972, 484static int setup_regulators(struct lp3972 *lp3972,
485 struct lp3972_platform_data *pdata) 485 struct lp3972_platform_data *pdata)
486{ 486{
487 int i, err; 487 int i, err;
@@ -523,7 +523,7 @@ err_nomem:
523 return err; 523 return err;
524} 524}
525 525
526static int __devinit lp3972_i2c_probe(struct i2c_client *i2c, 526static int lp3972_i2c_probe(struct i2c_client *i2c,
527 const struct i2c_device_id *id) 527 const struct i2c_device_id *id)
528{ 528{
529 struct lp3972 *lp3972; 529 struct lp3972 *lp3972;
@@ -569,7 +569,7 @@ err_detect:
569 return ret; 569 return ret;
570} 570}
571 571
572static int __devexit lp3972_i2c_remove(struct i2c_client *i2c) 572static int lp3972_i2c_remove(struct i2c_client *i2c)
573{ 573{
574 struct lp3972 *lp3972 = i2c_get_clientdata(i2c); 574 struct lp3972 *lp3972 = i2c_get_clientdata(i2c);
575 int i; 575 int i;
@@ -594,7 +594,7 @@ static struct i2c_driver lp3972_i2c_driver = {
594 .owner = THIS_MODULE, 594 .owner = THIS_MODULE,
595 }, 595 },
596 .probe = lp3972_i2c_probe, 596 .probe = lp3972_i2c_probe,
597 .remove = __devexit_p(lp3972_i2c_remove), 597 .remove = lp3972_i2c_remove,
598 .id_table = lp3972_i2c_id, 598 .id_table = lp3972_i2c_id,
599}; 599};
600 600
diff --git a/drivers/regulator/lp872x.c b/drivers/regulator/lp872x.c
index 708f4b6a17d..9289ead715c 100644
--- a/drivers/regulator/lp872x.c
+++ b/drivers/regulator/lp872x.c
@@ -893,7 +893,7 @@ err_dev:
893 return ret; 893 return ret;
894} 894}
895 895
896static int __devexit lp872x_remove(struct i2c_client *cl) 896static int lp872x_remove(struct i2c_client *cl)
897{ 897{
898 struct lp872x *lp = i2c_get_clientdata(cl); 898 struct lp872x *lp = i2c_get_clientdata(cl);
899 899
@@ -914,7 +914,7 @@ static struct i2c_driver lp872x_driver = {
914 .owner = THIS_MODULE, 914 .owner = THIS_MODULE,
915 }, 915 },
916 .probe = lp872x_probe, 916 .probe = lp872x_probe,
917 .remove = __devexit_p(lp872x_remove), 917 .remove = lp872x_remove,
918 .id_table = lp872x_ids, 918 .id_table = lp872x_ids,
919}; 919};
920 920
diff --git a/drivers/regulator/lp8788-buck.c b/drivers/regulator/lp8788-buck.c
index ba3e0aa402d..6cc02c35ddb 100644
--- a/drivers/regulator/lp8788-buck.c
+++ b/drivers/regulator/lp8788-buck.c
@@ -504,7 +504,7 @@ set_default_dvs_mode:
504 default_dvs_mode[id]); 504 default_dvs_mode[id]);
505} 505}
506 506
507static __devinit int lp8788_buck_probe(struct platform_device *pdev) 507static int lp8788_buck_probe(struct platform_device *pdev)
508{ 508{
509 struct lp8788 *lp = dev_get_drvdata(pdev->dev.parent); 509 struct lp8788 *lp = dev_get_drvdata(pdev->dev.parent);
510 int id = pdev->id; 510 int id = pdev->id;
@@ -542,7 +542,7 @@ static __devinit int lp8788_buck_probe(struct platform_device *pdev)
542 return 0; 542 return 0;
543} 543}
544 544
545static int __devexit lp8788_buck_remove(struct platform_device *pdev) 545static int lp8788_buck_remove(struct platform_device *pdev)
546{ 546{
547 struct lp8788_buck *buck = platform_get_drvdata(pdev); 547 struct lp8788_buck *buck = platform_get_drvdata(pdev);
548 548
@@ -554,7 +554,7 @@ static int __devexit lp8788_buck_remove(struct platform_device *pdev)
554 554
555static struct platform_driver lp8788_buck_driver = { 555static struct platform_driver lp8788_buck_driver = {
556 .probe = lp8788_buck_probe, 556 .probe = lp8788_buck_probe,
557 .remove = __devexit_p(lp8788_buck_remove), 557 .remove = lp8788_buck_remove,
558 .driver = { 558 .driver = {
559 .name = LP8788_DEV_BUCK, 559 .name = LP8788_DEV_BUCK,
560 .owner = THIS_MODULE, 560 .owner = THIS_MODULE,
diff --git a/drivers/regulator/lp8788-ldo.c b/drivers/regulator/lp8788-ldo.c
index 6796eeb47dc..26753a01378 100644
--- a/drivers/regulator/lp8788-ldo.c
+++ b/drivers/regulator/lp8788-ldo.c
@@ -712,7 +712,7 @@ set_default_ldo_enable_mode:
712 val[enable_id]); 712 val[enable_id]);
713} 713}
714 714
715static __devinit int lp8788_dldo_probe(struct platform_device *pdev) 715static int lp8788_dldo_probe(struct platform_device *pdev)
716{ 716{
717 struct lp8788 *lp = dev_get_drvdata(pdev->dev.parent); 717 struct lp8788 *lp = dev_get_drvdata(pdev->dev.parent);
718 int id = pdev->id; 718 int id = pdev->id;
@@ -749,7 +749,7 @@ static __devinit int lp8788_dldo_probe(struct platform_device *pdev)
749 return 0; 749 return 0;
750} 750}
751 751
752static int __devexit lp8788_dldo_remove(struct platform_device *pdev) 752static int lp8788_dldo_remove(struct platform_device *pdev)
753{ 753{
754 struct lp8788_ldo *ldo = platform_get_drvdata(pdev); 754 struct lp8788_ldo *ldo = platform_get_drvdata(pdev);
755 755
@@ -761,14 +761,14 @@ static int __devexit lp8788_dldo_remove(struct platform_device *pdev)
761 761
762static struct platform_driver lp8788_dldo_driver = { 762static struct platform_driver lp8788_dldo_driver = {
763 .probe = lp8788_dldo_probe, 763 .probe = lp8788_dldo_probe,
764 .remove = __devexit_p(lp8788_dldo_remove), 764 .remove = lp8788_dldo_remove,
765 .driver = { 765 .driver = {
766 .name = LP8788_DEV_DLDO, 766 .name = LP8788_DEV_DLDO,
767 .owner = THIS_MODULE, 767 .owner = THIS_MODULE,
768 }, 768 },
769}; 769};
770 770
771static __devinit int lp8788_aldo_probe(struct platform_device *pdev) 771static int lp8788_aldo_probe(struct platform_device *pdev)
772{ 772{
773 struct lp8788 *lp = dev_get_drvdata(pdev->dev.parent); 773 struct lp8788 *lp = dev_get_drvdata(pdev->dev.parent);
774 int id = pdev->id; 774 int id = pdev->id;
@@ -805,7 +805,7 @@ static __devinit int lp8788_aldo_probe(struct platform_device *pdev)
805 return 0; 805 return 0;
806} 806}
807 807
808static int __devexit lp8788_aldo_remove(struct platform_device *pdev) 808static int lp8788_aldo_remove(struct platform_device *pdev)
809{ 809{
810 struct lp8788_ldo *ldo = platform_get_drvdata(pdev); 810 struct lp8788_ldo *ldo = platform_get_drvdata(pdev);
811 811
@@ -817,7 +817,7 @@ static int __devexit lp8788_aldo_remove(struct platform_device *pdev)
817 817
818static struct platform_driver lp8788_aldo_driver = { 818static struct platform_driver lp8788_aldo_driver = {
819 .probe = lp8788_aldo_probe, 819 .probe = lp8788_aldo_probe,
820 .remove = __devexit_p(lp8788_aldo_remove), 820 .remove = lp8788_aldo_remove,
821 .driver = { 821 .driver = {
822 .name = LP8788_DEV_ALDO, 822 .name = LP8788_DEV_ALDO,
823 .owner = THIS_MODULE, 823 .owner = THIS_MODULE,
diff --git a/drivers/regulator/max1586.c b/drivers/regulator/max1586.c
index f67af3c1b96..3a035ece83c 100644
--- a/drivers/regulator/max1586.c
+++ b/drivers/regulator/max1586.c
@@ -125,7 +125,7 @@ static struct regulator_desc max1586_reg[] = {
125 }, 125 },
126}; 126};
127 127
128static int __devinit max1586_pmic_probe(struct i2c_client *client, 128static int max1586_pmic_probe(struct i2c_client *client,
129 const struct i2c_device_id *i2c_id) 129 const struct i2c_device_id *i2c_id)
130{ 130{
131 struct regulator_dev **rdev; 131 struct regulator_dev **rdev;
@@ -188,7 +188,7 @@ err:
188 return ret; 188 return ret;
189} 189}
190 190
191static int __devexit max1586_pmic_remove(struct i2c_client *client) 191static int max1586_pmic_remove(struct i2c_client *client)
192{ 192{
193 struct max1586_data *max1586 = i2c_get_clientdata(client); 193 struct max1586_data *max1586 = i2c_get_clientdata(client);
194 int i; 194 int i;
@@ -207,7 +207,7 @@ MODULE_DEVICE_TABLE(i2c, max1586_id);
207 207
208static struct i2c_driver max1586_pmic_driver = { 208static struct i2c_driver max1586_pmic_driver = {
209 .probe = max1586_pmic_probe, 209 .probe = max1586_pmic_probe,
210 .remove = __devexit_p(max1586_pmic_remove), 210 .remove = max1586_pmic_remove,
211 .driver = { 211 .driver = {
212 .name = "max1586", 212 .name = "max1586",
213 .owner = THIS_MODULE, 213 .owner = THIS_MODULE,
diff --git a/drivers/regulator/max77686.c b/drivers/regulator/max77686.c
index 2a67d08658a..cb99e9031a6 100644
--- a/drivers/regulator/max77686.c
+++ b/drivers/regulator/max77686.c
@@ -280,7 +280,7 @@ static int max77686_pmic_dt_parse_pdata(struct max77686_dev *iodev,
280} 280}
281#endif /* CONFIG_OF */ 281#endif /* CONFIG_OF */
282 282
283static __devinit int max77686_pmic_probe(struct platform_device *pdev) 283static int max77686_pmic_probe(struct platform_device *pdev)
284{ 284{
285 struct max77686_dev *iodev = dev_get_drvdata(pdev->dev.parent); 285 struct max77686_dev *iodev = dev_get_drvdata(pdev->dev.parent);
286 struct max77686_platform_data *pdata = dev_get_platdata(iodev->dev); 286 struct max77686_platform_data *pdata = dev_get_platdata(iodev->dev);
@@ -337,7 +337,7 @@ err:
337 return ret; 337 return ret;
338} 338}
339 339
340static int __devexit max77686_pmic_remove(struct platform_device *pdev) 340static int max77686_pmic_remove(struct platform_device *pdev)
341{ 341{
342 struct max77686_data *max77686 = platform_get_drvdata(pdev); 342 struct max77686_data *max77686 = platform_get_drvdata(pdev);
343 int i; 343 int i;
@@ -360,7 +360,7 @@ static struct platform_driver max77686_pmic_driver = {
360 .owner = THIS_MODULE, 360 .owner = THIS_MODULE,
361 }, 361 },
362 .probe = max77686_pmic_probe, 362 .probe = max77686_pmic_probe,
363 .remove = __devexit_p(max77686_pmic_remove), 363 .remove = max77686_pmic_remove,
364 .id_table = max77686_pmic_id, 364 .id_table = max77686_pmic_id,
365}; 365};
366 366
diff --git a/drivers/regulator/max8649.c b/drivers/regulator/max8649.c
index 9d540cd02da..3ca14380f22 100644
--- a/drivers/regulator/max8649.c
+++ b/drivers/regulator/max8649.c
@@ -176,7 +176,7 @@ static struct regmap_config max8649_regmap_config = {
176 .val_bits = 8, 176 .val_bits = 8,
177}; 177};
178 178
179static int __devinit max8649_regulator_probe(struct i2c_client *client, 179static int max8649_regulator_probe(struct i2c_client *client,
180 const struct i2c_device_id *id) 180 const struct i2c_device_id *id)
181{ 181{
182 struct max8649_platform_data *pdata = client->dev.platform_data; 182 struct max8649_platform_data *pdata = client->dev.platform_data;
@@ -271,7 +271,7 @@ static int __devinit max8649_regulator_probe(struct i2c_client *client,
271 return 0; 271 return 0;
272} 272}
273 273
274static int __devexit max8649_regulator_remove(struct i2c_client *client) 274static int max8649_regulator_remove(struct i2c_client *client)
275{ 275{
276 struct max8649_regulator_info *info = i2c_get_clientdata(client); 276 struct max8649_regulator_info *info = i2c_get_clientdata(client);
277 277
@@ -291,7 +291,7 @@ MODULE_DEVICE_TABLE(i2c, max8649_id);
291 291
292static struct i2c_driver max8649_driver = { 292static struct i2c_driver max8649_driver = {
293 .probe = max8649_regulator_probe, 293 .probe = max8649_regulator_probe,
294 .remove = __devexit_p(max8649_regulator_remove), 294 .remove = max8649_regulator_remove,
295 .driver = { 295 .driver = {
296 .name = "max8649", 296 .name = "max8649",
297 }, 297 },
diff --git a/drivers/regulator/max8660.c b/drivers/regulator/max8660.c
index 8d531742f59..4d7c635c36c 100644
--- a/drivers/regulator/max8660.c
+++ b/drivers/regulator/max8660.c
@@ -305,7 +305,7 @@ static const struct regulator_desc max8660_reg[] = {
305 }, 305 },
306}; 306};
307 307
308static int __devinit max8660_probe(struct i2c_client *client, 308static int max8660_probe(struct i2c_client *client,
309 const struct i2c_device_id *i2c_id) 309 const struct i2c_device_id *i2c_id)
310{ 310{
311 struct regulator_dev **rdev; 311 struct regulator_dev **rdev;
@@ -420,7 +420,7 @@ err_out:
420 return ret; 420 return ret;
421} 421}
422 422
423static int __devexit max8660_remove(struct i2c_client *client) 423static int max8660_remove(struct i2c_client *client)
424{ 424{
425 struct max8660 *max8660 = i2c_get_clientdata(client); 425 struct max8660 *max8660 = i2c_get_clientdata(client);
426 int i; 426 int i;
@@ -440,7 +440,7 @@ MODULE_DEVICE_TABLE(i2c, max8660_id);
440 440
441static struct i2c_driver max8660_driver = { 441static struct i2c_driver max8660_driver = {
442 .probe = max8660_probe, 442 .probe = max8660_probe,
443 .remove = __devexit_p(max8660_remove), 443 .remove = max8660_remove,
444 .driver = { 444 .driver = {
445 .name = "max8660", 445 .name = "max8660",
446 .owner = THIS_MODULE, 446 .owner = THIS_MODULE,
diff --git a/drivers/regulator/max8907-regulator.c b/drivers/regulator/max8907-regulator.c
index af7607515ab..d1a77512d83 100644
--- a/drivers/regulator/max8907-regulator.c
+++ b/drivers/regulator/max8907-regulator.c
@@ -275,7 +275,7 @@ static inline struct device_node *match_of_node(int index)
275} 275}
276#endif 276#endif
277 277
278static __devinit int max8907_regulator_probe(struct platform_device *pdev) 278static int max8907_regulator_probe(struct platform_device *pdev)
279{ 279{
280 struct max8907 *max8907 = dev_get_drvdata(pdev->dev.parent); 280 struct max8907 *max8907 = dev_get_drvdata(pdev->dev.parent);
281 struct max8907_platform_data *pdata = dev_get_platdata(max8907->dev); 281 struct max8907_platform_data *pdata = dev_get_platdata(max8907->dev);
@@ -368,7 +368,7 @@ err_unregister_regulator:
368 return ret; 368 return ret;
369} 369}
370 370
371static __devexit int max8907_regulator_remove(struct platform_device *pdev) 371static int max8907_regulator_remove(struct platform_device *pdev)
372{ 372{
373 struct max8907_regulator *pmic = platform_get_drvdata(pdev); 373 struct max8907_regulator *pmic = platform_get_drvdata(pdev);
374 int i; 374 int i;
@@ -385,7 +385,7 @@ static struct platform_driver max8907_regulator_driver = {
385 .owner = THIS_MODULE, 385 .owner = THIS_MODULE,
386 }, 386 },
387 .probe = max8907_regulator_probe, 387 .probe = max8907_regulator_probe,
388 .remove = __devexit_p(max8907_regulator_remove), 388 .remove = max8907_regulator_remove,
389}; 389};
390 390
391static int __init max8907_regulator_init(void) 391static int __init max8907_regulator_init(void)
diff --git a/drivers/regulator/max8925-regulator.c b/drivers/regulator/max8925-regulator.c
index 9bb0be37495..446a8544555 100644
--- a/drivers/regulator/max8925-regulator.c
+++ b/drivers/regulator/max8925-regulator.c
@@ -17,6 +17,8 @@
17#include <linux/regulator/driver.h> 17#include <linux/regulator/driver.h>
18#include <linux/regulator/machine.h> 18#include <linux/regulator/machine.h>
19#include <linux/mfd/max8925.h> 19#include <linux/mfd/max8925.h>
20#include <linux/of.h>
21#include <linux/regulator/of_regulator.h>
20 22
21#define SD1_DVM_VMIN 850000 23#define SD1_DVM_VMIN 850000
22#define SD1_DVM_VMAX 1000000 24#define SD1_DVM_VMAX 1000000
@@ -187,6 +189,34 @@ static struct regulator_ops max8925_regulator_ldo_ops = {
187 .enable_reg = MAX8925_LDOCTL##_id, \ 189 .enable_reg = MAX8925_LDOCTL##_id, \
188} 190}
189 191
192#ifdef CONFIG_OF
193static struct of_regulator_match max8925_regulator_matches[] = {
194 { .name = "SDV1",},
195 { .name = "SDV2",},
196 { .name = "SDV3",},
197 { .name = "LDO1",},
198 { .name = "LDO2",},
199 { .name = "LDO3",},
200 { .name = "LDO4",},
201 { .name = "LDO5",},
202 { .name = "LDO6",},
203 { .name = "LDO7",},
204 { .name = "LDO8",},
205 { .name = "LDO9",},
206 { .name = "LDO10",},
207 { .name = "LDO11",},
208 { .name = "LDO12",},
209 { .name = "LDO13",},
210 { .name = "LDO14",},
211 { .name = "LDO15",},
212 { .name = "LDO16",},
213 { .name = "LDO17",},
214 { .name = "LDO18",},
215 { .name = "LDO19",},
216 { .name = "LDO20",},
217};
218#endif
219
190static struct max8925_regulator_info max8925_regulator_info[] = { 220static struct max8925_regulator_info max8925_regulator_info[] = {
191 MAX8925_SDV(1, 637.5, 1425, 12.5), 221 MAX8925_SDV(1, 637.5, 1425, 12.5),
192 MAX8925_SDV(2, 650, 2225, 25), 222 MAX8925_SDV(2, 650, 2225, 25),
@@ -214,7 +244,37 @@ static struct max8925_regulator_info max8925_regulator_info[] = {
214 MAX8925_LDO(20, 750, 3900, 50), 244 MAX8925_LDO(20, 750, 3900, 50),
215}; 245};
216 246
217static int __devinit max8925_regulator_probe(struct platform_device *pdev) 247#ifdef CONFIG_OF
248static int max8925_regulator_dt_init(struct platform_device *pdev,
249 struct max8925_regulator_info *info,
250 struct regulator_config *config,
251 int ridx)
252{
253 struct device_node *nproot, *np;
254 int rcount;
255 nproot = pdev->dev.parent->of_node;
256 if (!nproot)
257 return -ENODEV;
258 np = of_find_node_by_name(nproot, "regulators");
259 if (!np) {
260 dev_err(&pdev->dev, "failed to find regulators node\n");
261 return -ENODEV;
262 }
263
264 rcount = of_regulator_match(&pdev->dev, np,
265 &max8925_regulator_matches[ridx], 1);
266 if (rcount < 0)
267 return -ENODEV;
268 config->init_data = max8925_regulator_matches[ridx].init_data;
269 config->of_node = max8925_regulator_matches[ridx].of_node;
270
271 return 0;
272}
273#else
274#define max8925_regulator_dt_init(w, x, y, z) (-1)
275#endif
276
277static int max8925_regulator_probe(struct platform_device *pdev)
218{ 278{
219 struct max8925_chip *chip = dev_get_drvdata(pdev->dev.parent); 279 struct max8925_chip *chip = dev_get_drvdata(pdev->dev.parent);
220 struct regulator_init_data *pdata = pdev->dev.platform_data; 280 struct regulator_init_data *pdata = pdev->dev.platform_data;
@@ -222,7 +282,7 @@ static int __devinit max8925_regulator_probe(struct platform_device *pdev)
222 struct max8925_regulator_info *ri; 282 struct max8925_regulator_info *ri;
223 struct resource *res; 283 struct resource *res;
224 struct regulator_dev *rdev; 284 struct regulator_dev *rdev;
225 int i; 285 int i, regulator_idx;
226 286
227 res = platform_get_resource(pdev, IORESOURCE_REG, 0); 287 res = platform_get_resource(pdev, IORESOURCE_REG, 0);
228 if (!res) { 288 if (!res) {
@@ -231,9 +291,12 @@ static int __devinit max8925_regulator_probe(struct platform_device *pdev)
231 } 291 }
232 for (i = 0; i < ARRAY_SIZE(max8925_regulator_info); i++) { 292 for (i = 0; i < ARRAY_SIZE(max8925_regulator_info); i++) {
233 ri = &max8925_regulator_info[i]; 293 ri = &max8925_regulator_info[i];
234 if (ri->vol_reg == res->start) 294 if (ri->vol_reg == res->start) {
295 regulator_idx = i;
235 break; 296 break;
297 }
236 } 298 }
299
237 if (i == ARRAY_SIZE(max8925_regulator_info)) { 300 if (i == ARRAY_SIZE(max8925_regulator_info)) {
238 dev_err(&pdev->dev, "Failed to find regulator %llu\n", 301 dev_err(&pdev->dev, "Failed to find regulator %llu\n",
239 (unsigned long long)res->start); 302 (unsigned long long)res->start);
@@ -243,9 +306,12 @@ static int __devinit max8925_regulator_probe(struct platform_device *pdev)
243 ri->chip = chip; 306 ri->chip = chip;
244 307
245 config.dev = &pdev->dev; 308 config.dev = &pdev->dev;
246 config.init_data = pdata;
247 config.driver_data = ri; 309 config.driver_data = ri;
248 310
311 if (max8925_regulator_dt_init(pdev, ri, &config, regulator_idx))
312 if (pdata)
313 config.init_data = pdata;
314
249 rdev = regulator_register(&ri->desc, &config); 315 rdev = regulator_register(&ri->desc, &config);
250 if (IS_ERR(rdev)) { 316 if (IS_ERR(rdev)) {
251 dev_err(&pdev->dev, "failed to register regulator %s\n", 317 dev_err(&pdev->dev, "failed to register regulator %s\n",
@@ -257,7 +323,7 @@ static int __devinit max8925_regulator_probe(struct platform_device *pdev)
257 return 0; 323 return 0;
258} 324}
259 325
260static int __devexit max8925_regulator_remove(struct platform_device *pdev) 326static int max8925_regulator_remove(struct platform_device *pdev)
261{ 327{
262 struct regulator_dev *rdev = platform_get_drvdata(pdev); 328 struct regulator_dev *rdev = platform_get_drvdata(pdev);
263 329
@@ -273,7 +339,7 @@ static struct platform_driver max8925_regulator_driver = {
273 .owner = THIS_MODULE, 339 .owner = THIS_MODULE,
274 }, 340 },
275 .probe = max8925_regulator_probe, 341 .probe = max8925_regulator_probe,
276 .remove = __devexit_p(max8925_regulator_remove), 342 .remove = max8925_regulator_remove,
277}; 343};
278 344
279static int __init max8925_regulator_init(void) 345static int __init max8925_regulator_init(void)
diff --git a/drivers/regulator/max8952.c b/drivers/regulator/max8952.c
index 355ca7bad9d..fc7935a19e3 100644
--- a/drivers/regulator/max8952.c
+++ b/drivers/regulator/max8952.c
@@ -126,7 +126,7 @@ static const struct regulator_desc regulator = {
126 .owner = THIS_MODULE, 126 .owner = THIS_MODULE,
127}; 127};
128 128
129static int __devinit max8952_pmic_probe(struct i2c_client *client, 129static int max8952_pmic_probe(struct i2c_client *client,
130 const struct i2c_device_id *i2c_id) 130 const struct i2c_device_id *i2c_id)
131{ 131{
132 struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent); 132 struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent);
@@ -247,7 +247,7 @@ static int __devinit max8952_pmic_probe(struct i2c_client *client,
247 return 0; 247 return 0;
248} 248}
249 249
250static int __devexit max8952_pmic_remove(struct i2c_client *client) 250static int max8952_pmic_remove(struct i2c_client *client)
251{ 251{
252 struct max8952_data *max8952 = i2c_get_clientdata(client); 252 struct max8952_data *max8952 = i2c_get_clientdata(client);
253 struct max8952_platform_data *pdata = max8952->pdata; 253 struct max8952_platform_data *pdata = max8952->pdata;
@@ -268,7 +268,7 @@ MODULE_DEVICE_TABLE(i2c, max8952_ids);
268 268
269static struct i2c_driver max8952_pmic_driver = { 269static struct i2c_driver max8952_pmic_driver = {
270 .probe = max8952_pmic_probe, 270 .probe = max8952_pmic_probe,
271 .remove = __devexit_p(max8952_pmic_remove), 271 .remove = max8952_pmic_remove,
272 .driver = { 272 .driver = {
273 .name = "max8952", 273 .name = "max8952",
274 }, 274 },
diff --git a/drivers/regulator/max8997.c b/drivers/regulator/max8997.c
index b56c4326853..df0eafb0dc7 100644
--- a/drivers/regulator/max8997.c
+++ b/drivers/regulator/max8997.c
@@ -1070,7 +1070,7 @@ static int max8997_pmic_dt_parse_pdata(struct max8997_dev *iodev,
1070} 1070}
1071#endif /* CONFIG_OF */ 1071#endif /* CONFIG_OF */
1072 1072
1073static __devinit int max8997_pmic_probe(struct platform_device *pdev) 1073static int max8997_pmic_probe(struct platform_device *pdev)
1074{ 1074{
1075 struct max8997_dev *iodev = dev_get_drvdata(pdev->dev.parent); 1075 struct max8997_dev *iodev = dev_get_drvdata(pdev->dev.parent);
1076 struct max8997_platform_data *pdata = iodev->pdata; 1076 struct max8997_platform_data *pdata = iodev->pdata;
@@ -1267,7 +1267,7 @@ err_out:
1267 return ret; 1267 return ret;
1268} 1268}
1269 1269
1270static int __devexit max8997_pmic_remove(struct platform_device *pdev) 1270static int max8997_pmic_remove(struct platform_device *pdev)
1271{ 1271{
1272 struct max8997_data *max8997 = platform_get_drvdata(pdev); 1272 struct max8997_data *max8997 = platform_get_drvdata(pdev);
1273 struct regulator_dev **rdev = max8997->rdev; 1273 struct regulator_dev **rdev = max8997->rdev;
@@ -1290,7 +1290,7 @@ static struct platform_driver max8997_pmic_driver = {
1290 .owner = THIS_MODULE, 1290 .owner = THIS_MODULE,
1291 }, 1291 },
1292 .probe = max8997_pmic_probe, 1292 .probe = max8997_pmic_probe,
1293 .remove = __devexit_p(max8997_pmic_remove), 1293 .remove = max8997_pmic_remove,
1294 .id_table = max8997_pmic_id, 1294 .id_table = max8997_pmic_id,
1295}; 1295};
1296 1296
diff --git a/drivers/regulator/max8998.c b/drivers/regulator/max8998.c
index 5dfa920ff0c..b821d08eb64 100644
--- a/drivers/regulator/max8998.c
+++ b/drivers/regulator/max8998.c
@@ -633,7 +633,7 @@ static struct regulator_desc regulators[] = {
633 } 633 }
634}; 634};
635 635
636static __devinit int max8998_pmic_probe(struct platform_device *pdev) 636static int max8998_pmic_probe(struct platform_device *pdev)
637{ 637{
638 struct max8998_dev *iodev = dev_get_drvdata(pdev->dev.parent); 638 struct max8998_dev *iodev = dev_get_drvdata(pdev->dev.parent);
639 struct max8998_platform_data *pdata = dev_get_platdata(iodev->dev); 639 struct max8998_platform_data *pdata = dev_get_platdata(iodev->dev);
@@ -818,7 +818,7 @@ err_out:
818 return ret; 818 return ret;
819} 819}
820 820
821static int __devexit max8998_pmic_remove(struct platform_device *pdev) 821static int max8998_pmic_remove(struct platform_device *pdev)
822{ 822{
823 struct max8998_data *max8998 = platform_get_drvdata(pdev); 823 struct max8998_data *max8998 = platform_get_drvdata(pdev);
824 struct regulator_dev **rdev = max8998->rdev; 824 struct regulator_dev **rdev = max8998->rdev;
@@ -842,7 +842,7 @@ static struct platform_driver max8998_pmic_driver = {
842 .owner = THIS_MODULE, 842 .owner = THIS_MODULE,
843 }, 843 },
844 .probe = max8998_pmic_probe, 844 .probe = max8998_pmic_probe,
845 .remove = __devexit_p(max8998_pmic_remove), 845 .remove = max8998_pmic_remove,
846 .id_table = max8998_pmic_id, 846 .id_table = max8998_pmic_id,
847}; 847};
848 848
diff --git a/drivers/regulator/mc13783-regulator.c b/drivers/regulator/mc13783-regulator.c
index 0801a6d0c12..c46c6705cd7 100644
--- a/drivers/regulator/mc13783-regulator.c
+++ b/drivers/regulator/mc13783-regulator.c
@@ -392,7 +392,7 @@ static struct regulator_ops mc13783_gpo_regulator_ops = {
392 .set_voltage = mc13xxx_fixed_regulator_set_voltage, 392 .set_voltage = mc13xxx_fixed_regulator_set_voltage,
393}; 393};
394 394
395static int __devinit mc13783_regulator_probe(struct platform_device *pdev) 395static int mc13783_regulator_probe(struct platform_device *pdev)
396{ 396{
397 struct mc13xxx_regulator_priv *priv; 397 struct mc13xxx_regulator_priv *priv;
398 struct mc13xxx *mc13783 = dev_get_drvdata(pdev->dev.parent); 398 struct mc13xxx *mc13783 = dev_get_drvdata(pdev->dev.parent);
@@ -445,7 +445,7 @@ err:
445 return ret; 445 return ret;
446} 446}
447 447
448static int __devexit mc13783_regulator_remove(struct platform_device *pdev) 448static int mc13783_regulator_remove(struct platform_device *pdev)
449{ 449{
450 struct mc13xxx_regulator_priv *priv = platform_get_drvdata(pdev); 450 struct mc13xxx_regulator_priv *priv = platform_get_drvdata(pdev);
451 struct mc13xxx_regulator_platform_data *pdata = 451 struct mc13xxx_regulator_platform_data *pdata =
@@ -465,7 +465,7 @@ static struct platform_driver mc13783_regulator_driver = {
465 .name = "mc13783-regulator", 465 .name = "mc13783-regulator",
466 .owner = THIS_MODULE, 466 .owner = THIS_MODULE,
467 }, 467 },
468 .remove = __devexit_p(mc13783_regulator_remove), 468 .remove = mc13783_regulator_remove,
469 .probe = mc13783_regulator_probe, 469 .probe = mc13783_regulator_probe,
470}; 470};
471 471
diff --git a/drivers/regulator/mc13892-regulator.c b/drivers/regulator/mc13892-regulator.c
index 1fa63812f7a..0d84b1f3319 100644
--- a/drivers/regulator/mc13892-regulator.c
+++ b/drivers/regulator/mc13892-regulator.c
@@ -486,7 +486,7 @@ static unsigned int mc13892_vcam_get_mode(struct regulator_dev *rdev)
486} 486}
487 487
488 488
489static int __devinit mc13892_regulator_probe(struct platform_device *pdev) 489static int mc13892_regulator_probe(struct platform_device *pdev)
490{ 490{
491 struct mc13xxx_regulator_priv *priv; 491 struct mc13xxx_regulator_priv *priv;
492 struct mc13xxx *mc13892 = dev_get_drvdata(pdev->dev.parent); 492 struct mc13xxx *mc13892 = dev_get_drvdata(pdev->dev.parent);
@@ -588,7 +588,7 @@ err_unlock:
588 return ret; 588 return ret;
589} 589}
590 590
591static int __devexit mc13892_regulator_remove(struct platform_device *pdev) 591static int mc13892_regulator_remove(struct platform_device *pdev)
592{ 592{
593 struct mc13xxx_regulator_priv *priv = platform_get_drvdata(pdev); 593 struct mc13xxx_regulator_priv *priv = platform_get_drvdata(pdev);
594 int i; 594 int i;
@@ -606,7 +606,7 @@ static struct platform_driver mc13892_regulator_driver = {
606 .name = "mc13892-regulator", 606 .name = "mc13892-regulator",
607 .owner = THIS_MODULE, 607 .owner = THIS_MODULE,
608 }, 608 },
609 .remove = __devexit_p(mc13892_regulator_remove), 609 .remove = mc13892_regulator_remove,
610 .probe = mc13892_regulator_probe, 610 .probe = mc13892_regulator_probe,
611}; 611};
612 612
diff --git a/drivers/regulator/mc13xxx-regulator-core.c b/drivers/regulator/mc13xxx-regulator-core.c
index 88cbb832d55..4ed89c65411 100644
--- a/drivers/regulator/mc13xxx-regulator-core.c
+++ b/drivers/regulator/mc13xxx-regulator-core.c
@@ -162,7 +162,7 @@ struct regulator_ops mc13xxx_fixed_regulator_ops = {
162EXPORT_SYMBOL_GPL(mc13xxx_fixed_regulator_ops); 162EXPORT_SYMBOL_GPL(mc13xxx_fixed_regulator_ops);
163 163
164#ifdef CONFIG_OF 164#ifdef CONFIG_OF
165int __devinit mc13xxx_get_num_regulators_dt(struct platform_device *pdev) 165int mc13xxx_get_num_regulators_dt(struct platform_device *pdev)
166{ 166{
167 struct device_node *parent, *child; 167 struct device_node *parent, *child;
168 int num = 0; 168 int num = 0;
@@ -179,7 +179,7 @@ int __devinit mc13xxx_get_num_regulators_dt(struct platform_device *pdev)
179} 179}
180EXPORT_SYMBOL_GPL(mc13xxx_get_num_regulators_dt); 180EXPORT_SYMBOL_GPL(mc13xxx_get_num_regulators_dt);
181 181
182struct mc13xxx_regulator_init_data * __devinit mc13xxx_parse_regulators_dt( 182struct mc13xxx_regulator_init_data *mc13xxx_parse_regulators_dt(
183 struct platform_device *pdev, struct mc13xxx_regulator *regulators, 183 struct platform_device *pdev, struct mc13xxx_regulator *regulators,
184 int num_regulators) 184 int num_regulators)
185{ 185{
diff --git a/drivers/regulator/palmas-regulator.c b/drivers/regulator/palmas-regulator.c
index 07aee694ba9..3d445929cc8 100644
--- a/drivers/regulator/palmas-regulator.c
+++ b/drivers/regulator/palmas-regulator.c
@@ -595,7 +595,7 @@ static struct of_regulator_match palmas_matches[] = {
595 { .name = "ldousb", }, 595 { .name = "ldousb", },
596}; 596};
597 597
598static void __devinit palmas_dt_to_pdata(struct device *dev, 598static void palmas_dt_to_pdata(struct device *dev,
599 struct device_node *node, 599 struct device_node *node,
600 struct palmas_pmic_platform_data *pdata) 600 struct palmas_pmic_platform_data *pdata)
601{ 601{
@@ -663,7 +663,7 @@ static void __devinit palmas_dt_to_pdata(struct device *dev,
663} 663}
664 664
665 665
666static __devinit int palmas_probe(struct platform_device *pdev) 666static int palmas_probe(struct platform_device *pdev)
667{ 667{
668 struct palmas *palmas = dev_get_drvdata(pdev->dev.parent); 668 struct palmas *palmas = dev_get_drvdata(pdev->dev.parent);
669 struct palmas_pmic_platform_data *pdata = pdev->dev.platform_data; 669 struct palmas_pmic_platform_data *pdata = pdev->dev.platform_data;
@@ -868,7 +868,7 @@ err_unregister_regulator:
868 return ret; 868 return ret;
869} 869}
870 870
871static int __devexit palmas_remove(struct platform_device *pdev) 871static int palmas_remove(struct platform_device *pdev)
872{ 872{
873 struct palmas_pmic *pmic = platform_get_drvdata(pdev); 873 struct palmas_pmic *pmic = platform_get_drvdata(pdev);
874 int id; 874 int id;
@@ -890,7 +890,7 @@ static struct platform_driver palmas_driver = {
890 .owner = THIS_MODULE, 890 .owner = THIS_MODULE,
891 }, 891 },
892 .probe = palmas_probe, 892 .probe = palmas_probe,
893 .remove = __devexit_p(palmas_remove), 893 .remove = palmas_remove,
894}; 894};
895 895
896static int __init palmas_init(void) 896static int __init palmas_init(void)
diff --git a/drivers/regulator/pcap-regulator.c b/drivers/regulator/pcap-regulator.c
index 68777acc099..4899342f1fc 100644
--- a/drivers/regulator/pcap-regulator.c
+++ b/drivers/regulator/pcap-regulator.c
@@ -236,7 +236,7 @@ static const struct regulator_desc pcap_regulators[] = {
236 VREG(VAUX4), VREG(VSIM), VREG(VSIM2), VREG(VVIB), VREG(SW1), VREG(SW2), 236 VREG(VAUX4), VREG(VSIM), VREG(VSIM2), VREG(VVIB), VREG(SW1), VREG(SW2),
237}; 237};
238 238
239static int __devinit pcap_regulator_probe(struct platform_device *pdev) 239static int pcap_regulator_probe(struct platform_device *pdev)
240{ 240{
241 struct regulator_dev *rdev; 241 struct regulator_dev *rdev;
242 void *pcap = dev_get_drvdata(pdev->dev.parent); 242 void *pcap = dev_get_drvdata(pdev->dev.parent);
@@ -255,7 +255,7 @@ static int __devinit pcap_regulator_probe(struct platform_device *pdev)
255 return 0; 255 return 0;
256} 256}
257 257
258static int __devexit pcap_regulator_remove(struct platform_device *pdev) 258static int pcap_regulator_remove(struct platform_device *pdev)
259{ 259{
260 struct regulator_dev *rdev = platform_get_drvdata(pdev); 260 struct regulator_dev *rdev = platform_get_drvdata(pdev);
261 261
@@ -271,7 +271,7 @@ static struct platform_driver pcap_regulator_driver = {
271 .owner = THIS_MODULE, 271 .owner = THIS_MODULE,
272 }, 272 },
273 .probe = pcap_regulator_probe, 273 .probe = pcap_regulator_probe,
274 .remove = __devexit_p(pcap_regulator_remove), 274 .remove = pcap_regulator_remove,
275}; 275};
276 276
277static int __init pcap_regulator_init(void) 277static int __init pcap_regulator_init(void)
diff --git a/drivers/regulator/pcf50633-regulator.c b/drivers/regulator/pcf50633-regulator.c
index 092e5cb848a..d776f518aa0 100644
--- a/drivers/regulator/pcf50633-regulator.c
+++ b/drivers/regulator/pcf50633-regulator.c
@@ -196,7 +196,7 @@ static const struct regulator_desc regulators[] = {
196 [PCF50633_REGULATOR_MEMLDO] = PCF50633_REGULATOR("memldo", MEMLDO, 28), 196 [PCF50633_REGULATOR_MEMLDO] = PCF50633_REGULATOR("memldo", MEMLDO, 28),
197}; 197};
198 198
199static int __devinit pcf50633_regulator_probe(struct platform_device *pdev) 199static int pcf50633_regulator_probe(struct platform_device *pdev)
200{ 200{
201 struct regulator_dev *rdev; 201 struct regulator_dev *rdev;
202 struct pcf50633 *pcf; 202 struct pcf50633 *pcf;
@@ -222,7 +222,7 @@ static int __devinit pcf50633_regulator_probe(struct platform_device *pdev)
222 return 0; 222 return 0;
223} 223}
224 224
225static int __devexit pcf50633_regulator_remove(struct platform_device *pdev) 225static int pcf50633_regulator_remove(struct platform_device *pdev)
226{ 226{
227 struct regulator_dev *rdev = platform_get_drvdata(pdev); 227 struct regulator_dev *rdev = platform_get_drvdata(pdev);
228 228
@@ -237,7 +237,7 @@ static struct platform_driver pcf50633_regulator_driver = {
237 .name = "pcf50633-regltr", 237 .name = "pcf50633-regltr",
238 }, 238 },
239 .probe = pcf50633_regulator_probe, 239 .probe = pcf50633_regulator_probe,
240 .remove = __devexit_p(pcf50633_regulator_remove), 240 .remove = pcf50633_regulator_remove,
241}; 241};
242 242
243static int __init pcf50633_regulator_init(void) 243static int __init pcf50633_regulator_init(void)
diff --git a/drivers/regulator/rc5t583-regulator.c b/drivers/regulator/rc5t583-regulator.c
index 8bf4e8c9de9..9e6f78694bf 100644
--- a/drivers/regulator/rc5t583-regulator.c
+++ b/drivers/regulator/rc5t583-regulator.c
@@ -119,7 +119,7 @@ static struct rc5t583_regulator_info rc5t583_reg_info[RC5T583_REGULATOR_MAX] = {
119 RC5T583_REG(LDO9, LDOEN1, 1, LDODIS1, 1, 0x7F, 900, 3400, 25000, 133), 119 RC5T583_REG(LDO9, LDOEN1, 1, LDODIS1, 1, 0x7F, 900, 3400, 25000, 133),
120}; 120};
121 121
122static int __devinit rc5t583_regulator_probe(struct platform_device *pdev) 122static int rc5t583_regulator_probe(struct platform_device *pdev)
123{ 123{
124 struct rc5t583 *rc5t583 = dev_get_drvdata(pdev->dev.parent); 124 struct rc5t583 *rc5t583 = dev_get_drvdata(pdev->dev.parent);
125 struct rc5t583_platform_data *pdata = dev_get_platdata(rc5t583->dev); 125 struct rc5t583_platform_data *pdata = dev_get_platdata(rc5t583->dev);
@@ -198,7 +198,7 @@ clean_exit:
198 return ret; 198 return ret;
199} 199}
200 200
201static int __devexit rc5t583_regulator_remove(struct platform_device *pdev) 201static int rc5t583_regulator_remove(struct platform_device *pdev)
202{ 202{
203 struct rc5t583_regulator *regs = platform_get_drvdata(pdev); 203 struct rc5t583_regulator *regs = platform_get_drvdata(pdev);
204 int id; 204 int id;
@@ -214,7 +214,7 @@ static struct platform_driver rc5t583_regulator_driver = {
214 .owner = THIS_MODULE, 214 .owner = THIS_MODULE,
215 }, 215 },
216 .probe = rc5t583_regulator_probe, 216 .probe = rc5t583_regulator_probe,
217 .remove = __devexit_p(rc5t583_regulator_remove), 217 .remove = rc5t583_regulator_remove,
218}; 218};
219 219
220static int __init rc5t583_regulator_init(void) 220static int __init rc5t583_regulator_init(void)
diff --git a/drivers/regulator/s2mps11.c b/drivers/regulator/s2mps11.c
index 926f9c8f2fa..85fc086c131 100644
--- a/drivers/regulator/s2mps11.c
+++ b/drivers/regulator/s2mps11.c
@@ -231,7 +231,7 @@ static struct regulator_desc regulators[] = {
231 regulator_desc_buck10, 231 regulator_desc_buck10,
232}; 232};
233 233
234static __devinit int s2mps11_pmic_probe(struct platform_device *pdev) 234static int s2mps11_pmic_probe(struct platform_device *pdev)
235{ 235{
236 struct sec_pmic_dev *iodev = dev_get_drvdata(pdev->dev.parent); 236 struct sec_pmic_dev *iodev = dev_get_drvdata(pdev->dev.parent);
237 struct sec_platform_data *pdata = dev_get_platdata(iodev->dev); 237 struct sec_platform_data *pdata = dev_get_platdata(iodev->dev);
@@ -307,7 +307,7 @@ err:
307 return ret; 307 return ret;
308} 308}
309 309
310static int __devexit s2mps11_pmic_remove(struct platform_device *pdev) 310static int s2mps11_pmic_remove(struct platform_device *pdev)
311{ 311{
312 struct s2mps11_info *s2mps11 = platform_get_drvdata(pdev); 312 struct s2mps11_info *s2mps11 = platform_get_drvdata(pdev);
313 int i; 313 int i;
@@ -330,7 +330,7 @@ static struct platform_driver s2mps11_pmic_driver = {
330 .owner = THIS_MODULE, 330 .owner = THIS_MODULE,
331 }, 331 },
332 .probe = s2mps11_pmic_probe, 332 .probe = s2mps11_pmic_probe,
333 .remove = __devexit_p(s2mps11_pmic_remove), 333 .remove = s2mps11_pmic_remove,
334 .id_table = s2mps11_pmic_id, 334 .id_table = s2mps11_pmic_id,
335}; 335};
336 336
diff --git a/drivers/regulator/s5m8767.c b/drivers/regulator/s5m8767.c
index abe64a32aed..2b822bec3c2 100644
--- a/drivers/regulator/s5m8767.c
+++ b/drivers/regulator/s5m8767.c
@@ -499,7 +499,7 @@ static struct regulator_desc regulators[] = {
499 s5m8767_regulator_desc(BUCK9), 499 s5m8767_regulator_desc(BUCK9),
500}; 500};
501 501
502static __devinit int s5m8767_pmic_probe(struct platform_device *pdev) 502static int s5m8767_pmic_probe(struct platform_device *pdev)
503{ 503{
504 struct sec_pmic_dev *iodev = dev_get_drvdata(pdev->dev.parent); 504 struct sec_pmic_dev *iodev = dev_get_drvdata(pdev->dev.parent);
505 struct sec_platform_data *pdata = dev_get_platdata(iodev->dev); 505 struct sec_platform_data *pdata = dev_get_platdata(iodev->dev);
@@ -773,7 +773,7 @@ err:
773 return ret; 773 return ret;
774} 774}
775 775
776static int __devexit s5m8767_pmic_remove(struct platform_device *pdev) 776static int s5m8767_pmic_remove(struct platform_device *pdev)
777{ 777{
778 struct s5m8767_info *s5m8767 = platform_get_drvdata(pdev); 778 struct s5m8767_info *s5m8767 = platform_get_drvdata(pdev);
779 struct regulator_dev **rdev = s5m8767->rdev; 779 struct regulator_dev **rdev = s5m8767->rdev;
@@ -798,7 +798,7 @@ static struct platform_driver s5m8767_pmic_driver = {
798 .owner = THIS_MODULE, 798 .owner = THIS_MODULE,
799 }, 799 },
800 .probe = s5m8767_pmic_probe, 800 .probe = s5m8767_pmic_probe,
801 .remove = __devexit_p(s5m8767_pmic_remove), 801 .remove = s5m8767_pmic_remove,
802 .id_table = s5m8767_pmic_id, 802 .id_table = s5m8767_pmic_id,
803}; 803};
804 804
diff --git a/drivers/regulator/tps51632-regulator.c b/drivers/regulator/tps51632-regulator.c
new file mode 100644
index 00000000000..a9c3a4a6cca
--- /dev/null
+++ b/drivers/regulator/tps51632-regulator.c
@@ -0,0 +1,332 @@
1/*
2 * tps51632-regulator.c -- TI TPS51632
3 *
4 * Regulator driver for TPS51632 3-2-1 Phase D-Cap Step Down Driverless
5 * Controller with serial VID control and DVFS.
6 *
7 * Copyright (c) 2012, NVIDIA Corporation.
8 *
9 * Author: Laxman Dewangan <ldewangan@nvidia.com>
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License as
13 * published by the Free Software Foundation version 2.
14 *
15 * This program is distributed "as is" WITHOUT ANY WARRANTY of any kind,
16 * whether express or implied; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
23 * 02111-1307, USA
24 */
25
26#include <linux/err.h>
27#include <linux/i2c.h>
28#include <linux/init.h>
29#include <linux/kernel.h>
30#include <linux/module.h>
31#include <linux/platform_device.h>
32#include <linux/regmap.h>
33#include <linux/regulator/driver.h>
34#include <linux/regulator/machine.h>
35#include <linux/regulator/tps51632-regulator.h>
36#include <linux/slab.h>
37
38/* Register definitions */
39#define TPS51632_VOLTAGE_SELECT_REG 0x0
40#define TPS51632_VOLTAGE_BASE_REG 0x1
41#define TPS51632_OFFSET_REG 0x2
42#define TPS51632_IMON_REG 0x3
43#define TPS51632_VMAX_REG 0x4
44#define TPS51632_DVFS_CONTROL_REG 0x5
45#define TPS51632_POWER_STATE_REG 0x6
46#define TPS51632_SLEW_REGS 0x7
47#define TPS51632_FAULT_REG 0x14
48
49#define TPS51632_MAX_REG 0x15
50
51#define TPS51632_VOUT_MASK 0x7F
52#define TPS51632_VOUT_OFFSET_MASK 0x1F
53#define TPS51632_VMAX_MASK 0x7F
54#define TPS51632_VMAX_LOCK 0x80
55
56/* TPS51632_DVFS_CONTROL_REG */
57#define TPS51632_DVFS_PWMEN 0x1
58#define TPS51632_DVFS_STEP_20 0x2
59#define TPS51632_DVFS_VMAX_PG 0x4
60#define TPS51632_DVFS_PWMRST 0x8
61#define TPS51632_DVFS_OCA_EN 0x10
62#define TPS51632_DVFS_FCCM 0x20
63
64/* TPS51632_POWER_STATE_REG */
65#define TPS51632_POWER_STATE_MASK 0x03
66#define TPS51632_POWER_STATE_MULTI_PHASE_CCM 0x0
67#define TPS51632_POWER_STATE_SINGLE_PHASE_CCM 0x1
68#define TPS51632_POWER_STATE_SINGLE_PHASE_DCM 0x2
69
70#define TPS51632_MIN_VOLATGE 500000
71#define TPS51632_MAX_VOLATGE 1520000
72#define TPS51632_VOLATGE_STEP_10mV 10000
73#define TPS51632_VOLATGE_STEP_20mV 20000
74#define TPS51632_MAX_VSEL 0x7F
75#define TPS51632_MIN_VSEL 0x19
76#define TPS51632_DEFAULT_RAMP_DELAY 6000
77#define TPS51632_VOLT_VSEL(uV) \
78 (DIV_ROUND_UP(uV - TPS51632_MIN_VOLATGE, \
79 TPS51632_VOLATGE_STEP_10mV) + \
80 TPS51632_MIN_VSEL)
81
82/* TPS51632 chip information */
83struct tps51632_chip {
84 struct device *dev;
85 struct regulator_desc desc;
86 struct regulator_dev *rdev;
87 struct regmap *regmap;
88 bool enable_pwm_dvfs;
89};
90
91static int tps51632_dcdc_get_voltage_sel(struct regulator_dev *rdev)
92{
93 struct tps51632_chip *tps = rdev_get_drvdata(rdev);
94 unsigned int data;
95 int ret;
96 unsigned int reg = TPS51632_VOLTAGE_SELECT_REG;
97 int vsel;
98
99 if (tps->enable_pwm_dvfs)
100 reg = TPS51632_VOLTAGE_BASE_REG;
101
102 ret = regmap_read(tps->regmap, reg, &data);
103 if (ret < 0) {
104 dev_err(tps->dev, "reg read failed, err %d\n", ret);
105 return ret;
106 }
107
108 vsel = data & TPS51632_VOUT_MASK;
109
110 if (vsel < TPS51632_MIN_VSEL)
111 return 0;
112 else
113 return vsel - TPS51632_MIN_VSEL;
114}
115
116static int tps51632_dcdc_set_voltage_sel(struct regulator_dev *rdev,
117 unsigned selector)
118{
119 struct tps51632_chip *tps = rdev_get_drvdata(rdev);
120 int vsel;
121 int ret;
122 unsigned int reg = TPS51632_VOLTAGE_SELECT_REG;
123
124 if (tps->enable_pwm_dvfs)
125 reg = TPS51632_VOLTAGE_BASE_REG;
126
127 vsel = selector + TPS51632_MIN_VSEL;
128 if (vsel > TPS51632_MAX_VSEL)
129 return -EINVAL;
130
131 ret = regmap_write(tps->regmap, TPS51632_VOLTAGE_SELECT_REG, vsel);
132 if (ret < 0)
133 dev_err(tps->dev, "reg write failed, err %d\n", ret);
134 return ret;
135}
136
137static int tps51632_dcdc_set_ramp_delay(struct regulator_dev *rdev,
138 int ramp_delay)
139{
140 struct tps51632_chip *tps = rdev_get_drvdata(rdev);
141 int bit = ramp_delay/6000;
142 int ret;
143
144 if (bit)
145 bit--;
146 ret = regmap_write(tps->regmap, TPS51632_SLEW_REGS, BIT(bit));
147 if (ret < 0)
148 dev_err(tps->dev, "SLEW reg write failed, err %d\n", ret);
149 return ret;
150}
151
152static struct regulator_ops tps51632_dcdc_ops = {
153 .get_voltage_sel = tps51632_dcdc_get_voltage_sel,
154 .set_voltage_sel = tps51632_dcdc_set_voltage_sel,
155 .list_voltage = regulator_list_voltage_linear,
156 .set_voltage_time_sel = regulator_set_voltage_time_sel,
157 .set_ramp_delay = tps51632_dcdc_set_ramp_delay,
158};
159
160static int tps51632_init_dcdc(struct tps51632_chip *tps,
161 struct tps51632_regulator_platform_data *pdata)
162{
163 int ret;
164 uint8_t control = 0;
165 int vsel;
166
167 if (!pdata->enable_pwm_dvfs)
168 goto skip_pwm_config;
169
170 control |= TPS51632_DVFS_PWMEN;
171 tps->enable_pwm_dvfs = pdata->enable_pwm_dvfs;
172 vsel = TPS51632_VOLT_VSEL(pdata->base_voltage_uV);
173 ret = regmap_write(tps->regmap, TPS51632_VOLTAGE_BASE_REG, vsel);
174 if (ret < 0) {
175 dev_err(tps->dev, "BASE reg write failed, err %d\n", ret);
176 return ret;
177 }
178
179 if (pdata->dvfs_step_20mV)
180 control |= TPS51632_DVFS_STEP_20;
181
182 if (pdata->max_voltage_uV) {
183 unsigned int vmax;
184 /**
185 * TPS51632 hw behavior: VMAX register can be write only
186 * once as it get locked after first write. The lock get
187 * reset only when device is power-reset.
188 * Write register only when lock bit is not enabled.
189 */
190 ret = regmap_read(tps->regmap, TPS51632_VMAX_REG, &vmax);
191 if (ret < 0) {
192 dev_err(tps->dev, "VMAX read failed, err %d\n", ret);
193 return ret;
194 }
195 if (!(vmax & TPS51632_VMAX_LOCK)) {
196 vsel = TPS51632_VOLT_VSEL(pdata->max_voltage_uV);
197 ret = regmap_write(tps->regmap, TPS51632_VMAX_REG,
198 vsel);
199 if (ret < 0) {
200 dev_err(tps->dev,
201 "VMAX write failed, err %d\n", ret);
202 return ret;
203 }
204 }
205 }
206
207skip_pwm_config:
208 ret = regmap_write(tps->regmap, TPS51632_DVFS_CONTROL_REG, control);
209 if (ret < 0)
210 dev_err(tps->dev, "DVFS reg write failed, err %d\n", ret);
211 return ret;
212}
213
214static bool rd_wr_reg(struct device *dev, unsigned int reg)
215{
216 if ((reg >= 0x8) && (reg <= 0x10))
217 return false;
218 return true;
219}
220
221static const struct regmap_config tps51632_regmap_config = {
222 .reg_bits = 8,
223 .val_bits = 8,
224 .writeable_reg = rd_wr_reg,
225 .readable_reg = rd_wr_reg,
226 .max_register = TPS51632_MAX_REG - 1,
227 .cache_type = REGCACHE_RBTREE,
228};
229
230static int tps51632_probe(struct i2c_client *client,
231 const struct i2c_device_id *id)
232{
233 struct tps51632_regulator_platform_data *pdata;
234 struct regulator_dev *rdev;
235 struct tps51632_chip *tps;
236 int ret;
237 struct regulator_config config = { };
238
239 pdata = client->dev.platform_data;
240 if (!pdata) {
241 dev_err(&client->dev, "No Platform data\n");
242 return -EINVAL;
243 }
244
245 tps = devm_kzalloc(&client->dev, sizeof(*tps), GFP_KERNEL);
246 if (!tps) {
247 dev_err(&client->dev, "Memory allocation failed\n");
248 return -ENOMEM;
249 }
250
251 tps->dev = &client->dev;
252 tps->desc.name = id->name;
253 tps->desc.id = 0;
254 tps->desc.ramp_delay = TPS51632_DEFAULT_RAMP_DELAY;
255 tps->desc.min_uV = TPS51632_MIN_VOLATGE;
256 tps->desc.uV_step = TPS51632_VOLATGE_STEP_10mV;
257 tps->desc.n_voltages = (TPS51632_MAX_VSEL - TPS51632_MIN_VSEL) + 1;
258 tps->desc.ops = &tps51632_dcdc_ops;
259 tps->desc.type = REGULATOR_VOLTAGE;
260 tps->desc.owner = THIS_MODULE;
261
262 tps->regmap = devm_regmap_init_i2c(client, &tps51632_regmap_config);
263 if (IS_ERR(tps->regmap)) {
264 ret = PTR_ERR(tps->regmap);
265 dev_err(&client->dev, "regmap init failed, err %d\n", ret);
266 return ret;
267 }
268 i2c_set_clientdata(client, tps);
269
270 ret = tps51632_init_dcdc(tps, pdata);
271 if (ret < 0) {
272 dev_err(tps->dev, "Init failed, err = %d\n", ret);
273 return ret;
274 }
275
276 /* Register the regulators */
277 config.dev = &client->dev;
278 config.init_data = pdata->reg_init_data;
279 config.driver_data = tps;
280 config.regmap = tps->regmap;
281 config.of_node = client->dev.of_node;
282
283 rdev = regulator_register(&tps->desc, &config);
284 if (IS_ERR(rdev)) {
285 dev_err(tps->dev, "regulator register failed\n");
286 return PTR_ERR(rdev);
287 }
288
289 tps->rdev = rdev;
290 return 0;
291}
292
293static int tps51632_remove(struct i2c_client *client)
294{
295 struct tps51632_chip *tps = i2c_get_clientdata(client);
296
297 regulator_unregister(tps->rdev);
298 return 0;
299}
300
301static const struct i2c_device_id tps51632_id[] = {
302 {.name = "tps51632",},
303 {},
304};
305
306MODULE_DEVICE_TABLE(i2c, tps51632_id);
307
308static struct i2c_driver tps51632_i2c_driver = {
309 .driver = {
310 .name = "tps51632",
311 .owner = THIS_MODULE,
312 },
313 .probe = tps51632_probe,
314 .remove = tps51632_remove,
315 .id_table = tps51632_id,
316};
317
318static int __init tps51632_init(void)
319{
320 return i2c_add_driver(&tps51632_i2c_driver);
321}
322subsys_initcall(tps51632_init);
323
324static void __exit tps51632_cleanup(void)
325{
326 i2c_del_driver(&tps51632_i2c_driver);
327}
328module_exit(tps51632_cleanup);
329
330MODULE_AUTHOR("Laxman Dewangan <ldewangan@nvidia.com>");
331MODULE_DESCRIPTION("TPS51632 voltage regulator driver");
332MODULE_LICENSE("GPL v2");
diff --git a/drivers/regulator/tps6105x-regulator.c b/drivers/regulator/tps6105x-regulator.c
index 1378409efae..ec9453ffb77 100644
--- a/drivers/regulator/tps6105x-regulator.c
+++ b/drivers/regulator/tps6105x-regulator.c
@@ -127,7 +127,7 @@ static const struct regulator_desc tps6105x_regulator_desc = {
127/* 127/*
128 * Registers the chip as a voltage regulator 128 * Registers the chip as a voltage regulator
129 */ 129 */
130static int __devinit tps6105x_regulator_probe(struct platform_device *pdev) 130static int tps6105x_regulator_probe(struct platform_device *pdev)
131{ 131{
132 struct tps6105x *tps6105x = dev_get_platdata(&pdev->dev); 132 struct tps6105x *tps6105x = dev_get_platdata(&pdev->dev);
133 struct tps6105x_platform_data *pdata = tps6105x->pdata; 133 struct tps6105x_platform_data *pdata = tps6105x->pdata;
@@ -159,7 +159,7 @@ static int __devinit tps6105x_regulator_probe(struct platform_device *pdev)
159 return 0; 159 return 0;
160} 160}
161 161
162static int __devexit tps6105x_regulator_remove(struct platform_device *pdev) 162static int tps6105x_regulator_remove(struct platform_device *pdev)
163{ 163{
164 struct tps6105x *tps6105x = dev_get_platdata(&pdev->dev); 164 struct tps6105x *tps6105x = dev_get_platdata(&pdev->dev);
165 regulator_unregister(tps6105x->regulator); 165 regulator_unregister(tps6105x->regulator);
@@ -172,7 +172,7 @@ static struct platform_driver tps6105x_regulator_driver = {
172 .owner = THIS_MODULE, 172 .owner = THIS_MODULE,
173 }, 173 },
174 .probe = tps6105x_regulator_probe, 174 .probe = tps6105x_regulator_probe,
175 .remove = __devexit_p(tps6105x_regulator_remove), 175 .remove = tps6105x_regulator_remove,
176}; 176};
177 177
178static __init int tps6105x_regulator_init(void) 178static __init int tps6105x_regulator_init(void)
diff --git a/drivers/regulator/tps62360-regulator.c b/drivers/regulator/tps62360-regulator.c
index 68729a7c870..acbd63fde41 100644
--- a/drivers/regulator/tps62360-regulator.c
+++ b/drivers/regulator/tps62360-regulator.c
@@ -243,7 +243,7 @@ static struct regulator_ops tps62360_dcdc_ops = {
243 .get_mode = tps62360_get_mode, 243 .get_mode = tps62360_get_mode,
244}; 244};
245 245
246static int __devinit tps62360_init_dcdc(struct tps62360_chip *tps, 246static int tps62360_init_dcdc(struct tps62360_chip *tps,
247 struct tps62360_regulator_platform_data *pdata) 247 struct tps62360_regulator_platform_data *pdata)
248{ 248{
249 int ret; 249 int ret;
@@ -339,7 +339,7 @@ static const struct of_device_id tps62360_of_match[] = {
339MODULE_DEVICE_TABLE(of, tps62360_of_match); 339MODULE_DEVICE_TABLE(of, tps62360_of_match);
340#endif 340#endif
341 341
342static int __devinit tps62360_probe(struct i2c_client *client, 342static int tps62360_probe(struct i2c_client *client,
343 const struct i2c_device_id *id) 343 const struct i2c_device_id *id)
344{ 344{
345 struct regulator_config config = { }; 345 struct regulator_config config = { };
@@ -490,7 +490,7 @@ static int __devinit tps62360_probe(struct i2c_client *client,
490 * 490 *
491 * Unregister TPS driver as an i2c client device driver 491 * Unregister TPS driver as an i2c client device driver
492 */ 492 */
493static int __devexit tps62360_remove(struct i2c_client *client) 493static int tps62360_remove(struct i2c_client *client)
494{ 494{
495 struct tps62360_chip *tps = i2c_get_clientdata(client); 495 struct tps62360_chip *tps = i2c_get_clientdata(client);
496 496
@@ -531,7 +531,7 @@ static struct i2c_driver tps62360_i2c_driver = {
531 .of_match_table = of_match_ptr(tps62360_of_match), 531 .of_match_table = of_match_ptr(tps62360_of_match),
532 }, 532 },
533 .probe = tps62360_probe, 533 .probe = tps62360_probe,
534 .remove = __devexit_p(tps62360_remove), 534 .remove = tps62360_remove,
535 .shutdown = tps62360_shutdown, 535 .shutdown = tps62360_shutdown,
536 .id_table = tps62360_id, 536 .id_table = tps62360_id,
537}; 537};
diff --git a/drivers/regulator/tps65023-regulator.c b/drivers/regulator/tps65023-regulator.c
index 6998d579d07..9b9af6d889c 100644
--- a/drivers/regulator/tps65023-regulator.c
+++ b/drivers/regulator/tps65023-regulator.c
@@ -219,7 +219,7 @@ static struct regmap_config tps65023_regmap_config = {
219 .val_bits = 8, 219 .val_bits = 8,
220}; 220};
221 221
222static int __devinit tps_65023_probe(struct i2c_client *client, 222static int tps_65023_probe(struct i2c_client *client,
223 const struct i2c_device_id *id) 223 const struct i2c_device_id *id)
224{ 224{
225 const struct tps_driver_data *drv_data = (void *)id->driver_data; 225 const struct tps_driver_data *drv_data = (void *)id->driver_data;
@@ -319,7 +319,7 @@ static int __devinit tps_65023_probe(struct i2c_client *client,
319 return error; 319 return error;
320} 320}
321 321
322static int __devexit tps_65023_remove(struct i2c_client *client) 322static int tps_65023_remove(struct i2c_client *client)
323{ 323{
324 struct tps_pmic *tps = i2c_get_clientdata(client); 324 struct tps_pmic *tps = i2c_get_clientdata(client);
325 int i; 325 int i;
@@ -446,7 +446,7 @@ static struct i2c_driver tps_65023_i2c_driver = {
446 .owner = THIS_MODULE, 446 .owner = THIS_MODULE,
447 }, 447 },
448 .probe = tps_65023_probe, 448 .probe = tps_65023_probe,
449 .remove = __devexit_p(tps_65023_remove), 449 .remove = tps_65023_remove,
450 .id_table = tps_65023_id, 450 .id_table = tps_65023_id,
451}; 451};
452 452
diff --git a/drivers/regulator/tps6507x-regulator.c b/drivers/regulator/tps6507x-regulator.c
index 07d01ccdf30..0233cfb5656 100644
--- a/drivers/regulator/tps6507x-regulator.c
+++ b/drivers/regulator/tps6507x-regulator.c
@@ -356,7 +356,7 @@ static struct regulator_ops tps6507x_pmic_ops = {
356 .list_voltage = regulator_list_voltage_table, 356 .list_voltage = regulator_list_voltage_table,
357}; 357};
358 358
359static __devinit int tps6507x_pmic_probe(struct platform_device *pdev) 359static int tps6507x_pmic_probe(struct platform_device *pdev)
360{ 360{
361 struct tps6507x_dev *tps6507x_dev = dev_get_drvdata(pdev->dev.parent); 361 struct tps6507x_dev *tps6507x_dev = dev_get_drvdata(pdev->dev.parent);
362 struct tps_info *info = &tps6507x_pmic_regs[0]; 362 struct tps_info *info = &tps6507x_pmic_regs[0];
@@ -439,7 +439,7 @@ fail:
439 return error; 439 return error;
440} 440}
441 441
442static int __devexit tps6507x_pmic_remove(struct platform_device *pdev) 442static int tps6507x_pmic_remove(struct platform_device *pdev)
443{ 443{
444 struct tps6507x_dev *tps6507x_dev = platform_get_drvdata(pdev); 444 struct tps6507x_dev *tps6507x_dev = platform_get_drvdata(pdev);
445 struct tps6507x_pmic *tps = tps6507x_dev->pmic; 445 struct tps6507x_pmic *tps = tps6507x_dev->pmic;
@@ -456,7 +456,7 @@ static struct platform_driver tps6507x_pmic_driver = {
456 .owner = THIS_MODULE, 456 .owner = THIS_MODULE,
457 }, 457 },
458 .probe = tps6507x_pmic_probe, 458 .probe = tps6507x_pmic_probe,
459 .remove = __devexit_p(tps6507x_pmic_remove), 459 .remove = tps6507x_pmic_remove,
460}; 460};
461 461
462static int __init tps6507x_pmic_init(void) 462static int __init tps6507x_pmic_init(void)
diff --git a/drivers/regulator/tps65090-regulator.c b/drivers/regulator/tps65090-regulator.c
index 001ad554ac6..3974a992220 100644
--- a/drivers/regulator/tps65090-regulator.c
+++ b/drivers/regulator/tps65090-regulator.c
@@ -18,119 +18,240 @@
18 18
19#include <linux/module.h> 19#include <linux/module.h>
20#include <linux/init.h> 20#include <linux/init.h>
21#include <linux/gpio.h>
21#include <linux/slab.h> 22#include <linux/slab.h>
22#include <linux/err.h> 23#include <linux/err.h>
23#include <linux/platform_device.h> 24#include <linux/platform_device.h>
24#include <linux/regulator/driver.h> 25#include <linux/regulator/driver.h>
25#include <linux/regulator/machine.h> 26#include <linux/regulator/machine.h>
26#include <linux/mfd/tps65090.h> 27#include <linux/mfd/tps65090.h>
27#include <linux/regulator/tps65090-regulator.h>
28 28
29struct tps65090_regulator { 29struct tps65090_regulator {
30 int id;
31 /* used by regulator core */
32 struct regulator_desc desc;
33
34 /* Device */
35 struct device *dev; 30 struct device *dev;
31 struct regulator_desc *desc;
32 struct regulator_dev *rdev;
33};
34
35static struct regulator_ops tps65090_ext_control_ops = {
36};
37
38static struct regulator_ops tps65090_reg_contol_ops = {
39 .enable = regulator_enable_regmap,
40 .disable = regulator_disable_regmap,
41 .is_enabled = regulator_is_enabled_regmap,
36}; 42};
37 43
38static struct regulator_ops tps65090_ops = { 44static struct regulator_ops tps65090_ldo_ops = {
39 .enable = regulator_enable_regmap,
40 .disable = regulator_disable_regmap,
41 .is_enabled = regulator_is_enabled_regmap,
42}; 45};
43 46
44#define tps65090_REG(_id) \ 47#define tps65090_REG_DESC(_id, _sname, _en_reg, _ops) \
45{ \ 48{ \
46 .id = TPS65090_ID_##_id, \ 49 .name = "TPS65090_RAILS"#_id, \
47 .desc = { \ 50 .supply_name = _sname, \
48 .name = tps65090_rails(_id), \ 51 .id = TPS65090_REGULATOR_##_id, \
49 .id = TPS65090_ID_##_id, \ 52 .ops = &_ops, \
50 .ops = &tps65090_ops, \ 53 .enable_reg = _en_reg, \
51 .type = REGULATOR_VOLTAGE, \ 54 .enable_mask = BIT(0), \
52 .owner = THIS_MODULE, \ 55 .type = REGULATOR_VOLTAGE, \
53 .enable_reg = (TPS65090_ID_##_id) + 12, \ 56 .owner = THIS_MODULE, \
54 .enable_mask = BIT(0), \
55 }, \
56} 57}
57 58
58static struct tps65090_regulator TPS65090_regulator[] = { 59static struct regulator_desc tps65090_regulator_desc[] = {
59 tps65090_REG(DCDC1), 60 tps65090_REG_DESC(DCDC1, "vsys1", 0x0C, tps65090_reg_contol_ops),
60 tps65090_REG(DCDC2), 61 tps65090_REG_DESC(DCDC2, "vsys2", 0x0D, tps65090_reg_contol_ops),
61 tps65090_REG(DCDC3), 62 tps65090_REG_DESC(DCDC3, "vsys3", 0x0E, tps65090_reg_contol_ops),
62 tps65090_REG(FET1), 63 tps65090_REG_DESC(FET1, "infet1", 0x0F, tps65090_reg_contol_ops),
63 tps65090_REG(FET2), 64 tps65090_REG_DESC(FET2, "infet2", 0x10, tps65090_reg_contol_ops),
64 tps65090_REG(FET3), 65 tps65090_REG_DESC(FET3, "infet3", 0x11, tps65090_reg_contol_ops),
65 tps65090_REG(FET4), 66 tps65090_REG_DESC(FET4, "infet4", 0x12, tps65090_reg_contol_ops),
66 tps65090_REG(FET5), 67 tps65090_REG_DESC(FET5, "infet5", 0x13, tps65090_reg_contol_ops),
67 tps65090_REG(FET6), 68 tps65090_REG_DESC(FET6, "infet6", 0x14, tps65090_reg_contol_ops),
68 tps65090_REG(FET7), 69 tps65090_REG_DESC(FET7, "infet7", 0x15, tps65090_reg_contol_ops),
70 tps65090_REG_DESC(LDO1, "vsys_l1", 0, tps65090_ldo_ops),
71 tps65090_REG_DESC(LDO2, "vsys_l2", 0, tps65090_ldo_ops),
69}; 72};
70 73
71static inline struct tps65090_regulator *find_regulator_info(int id) 74static inline bool is_dcdc(int id)
72{ 75{
73 struct tps65090_regulator *ri; 76 switch (id) {
74 int i; 77 case TPS65090_REGULATOR_DCDC1:
78 case TPS65090_REGULATOR_DCDC2:
79 case TPS65090_REGULATOR_DCDC3:
80 return true;
81 default:
82 return false;
83 }
84}
85
86static int tps65090_config_ext_control(
87 struct tps65090_regulator *ri, bool enable)
88{
89 int ret;
90 struct device *parent = ri->dev->parent;
91 unsigned int reg_en_reg = ri->desc->enable_reg;
92
93 if (enable)
94 ret = tps65090_set_bits(parent, reg_en_reg, 1);
95 else
96 ret = tps65090_clr_bits(parent, reg_en_reg, 1);
97 if (ret < 0)
98 dev_err(ri->dev, "Error in updating reg 0x%x\n", reg_en_reg);
99 return ret;
100}
101
102static int tps65090_regulator_disable_ext_control(
103 struct tps65090_regulator *ri,
104 struct tps65090_regulator_plat_data *tps_pdata)
105{
106 int ret = 0;
107 struct device *parent = ri->dev->parent;
108 unsigned int reg_en_reg = ri->desc->enable_reg;
109
110 /*
111 * First enable output for internal control if require.
112 * And then disable external control.
113 */
114 if (tps_pdata->reg_init_data->constraints.always_on ||
115 tps_pdata->reg_init_data->constraints.boot_on) {
116 ret = tps65090_set_bits(parent, reg_en_reg, 0);
117 if (ret < 0) {
118 dev_err(ri->dev, "Error in set reg 0x%x\n", reg_en_reg);
119 return ret;
120 }
121 }
122 return tps65090_config_ext_control(ri, false);
123}
124
125static void tps65090_configure_regulator_config(
126 struct tps65090_regulator_plat_data *tps_pdata,
127 struct regulator_config *config)
128{
129 if (gpio_is_valid(tps_pdata->gpio)) {
130 int gpio_flag = GPIOF_OUT_INIT_LOW;
131
132 if (tps_pdata->reg_init_data->constraints.always_on ||
133 tps_pdata->reg_init_data->constraints.boot_on)
134 gpio_flag = GPIOF_OUT_INIT_HIGH;
75 135
76 for (i = 0; i < ARRAY_SIZE(TPS65090_regulator); i++) { 136 config->ena_gpio = tps_pdata->gpio;
77 ri = &TPS65090_regulator[i]; 137 config->ena_gpio_flags = gpio_flag;
78 if (ri->desc.id == id)
79 return ri;
80 } 138 }
81 return NULL;
82} 139}
83 140
84static int __devinit tps65090_regulator_probe(struct platform_device *pdev) 141static int tps65090_regulator_probe(struct platform_device *pdev)
85{ 142{
86 struct tps65090 *tps65090_mfd = dev_get_drvdata(pdev->dev.parent); 143 struct tps65090 *tps65090_mfd = dev_get_drvdata(pdev->dev.parent);
87 struct tps65090_regulator *ri = NULL; 144 struct tps65090_regulator *ri = NULL;
88 struct regulator_config config = { }; 145 struct regulator_config config = { };
89 struct regulator_dev *rdev; 146 struct regulator_dev *rdev;
90 struct tps65090_regulator_platform_data *tps_pdata; 147 struct tps65090_regulator_plat_data *tps_pdata;
91 int id = pdev->id; 148 struct tps65090_regulator *pmic;
149 struct tps65090_platform_data *tps65090_pdata;
150 int num;
151 int ret;
92 152
93 dev_dbg(&pdev->dev, "Probing regulator %d\n", id); 153 dev_dbg(&pdev->dev, "Probing regulator\n");
94 154
95 ri = find_regulator_info(id); 155 tps65090_pdata = dev_get_platdata(pdev->dev.parent);
96 if (ri == NULL) { 156 if (!tps65090_pdata) {
97 dev_err(&pdev->dev, "invalid regulator ID specified\n"); 157 dev_err(&pdev->dev, "Platform data missing\n");
98 return -EINVAL; 158 return -EINVAL;
99 } 159 }
100 tps_pdata = pdev->dev.platform_data; 160
101 ri->dev = &pdev->dev; 161 pmic = devm_kzalloc(&pdev->dev, TPS65090_REGULATOR_MAX * sizeof(*pmic),
102 162 GFP_KERNEL);
103 config.dev = &pdev->dev; 163 if (!pmic) {
104 config.init_data = &tps_pdata->regulator; 164 dev_err(&pdev->dev, "mem alloc for pmic failed\n");
105 config.driver_data = ri; 165 return -ENOMEM;
106 config.regmap = tps65090_mfd->rmap; 166 }
107 167
108 rdev = regulator_register(&ri->desc, &config); 168 for (num = 0; num < TPS65090_REGULATOR_MAX; num++) {
109 if (IS_ERR(rdev)) { 169 tps_pdata = tps65090_pdata->reg_pdata[num];
110 dev_err(&pdev->dev, "failed to register regulator %s\n", 170
111 ri->desc.name); 171 ri = &pmic[num];
112 return PTR_ERR(rdev); 172 ri->dev = &pdev->dev;
173 ri->desc = &tps65090_regulator_desc[num];
174
175 /*
176 * TPS5090 DCDC support the control from external digital input.
177 * Configure it as per platform data.
178 */
179 if (tps_pdata && is_dcdc(num) && tps_pdata->reg_init_data) {
180 if (tps_pdata->enable_ext_control) {
181 tps65090_configure_regulator_config(
182 tps_pdata, &config);
183 ri->desc->ops = &tps65090_ext_control_ops;
184 } else {
185 ret = tps65090_regulator_disable_ext_control(
186 ri, tps_pdata);
187 if (ret < 0) {
188 dev_err(&pdev->dev,
189 "failed disable ext control\n");
190 goto scrub;
191 }
192 }
193 }
194
195 config.dev = &pdev->dev;
196 config.driver_data = ri;
197 config.regmap = tps65090_mfd->rmap;
198 if (tps_pdata)
199 config.init_data = tps_pdata->reg_init_data;
200 else
201 config.init_data = NULL;
202
203 rdev = regulator_register(ri->desc, &config);
204 if (IS_ERR(rdev)) {
205 dev_err(&pdev->dev, "failed to register regulator %s\n",
206 ri->desc->name);
207 ret = PTR_ERR(rdev);
208 goto scrub;
209 }
210 ri->rdev = rdev;
211
212 /* Enable external control if it is require */
213 if (tps_pdata && is_dcdc(num) && tps_pdata->reg_init_data &&
214 tps_pdata->enable_ext_control) {
215 ret = tps65090_config_ext_control(ri, true);
216 if (ret < 0) {
217 /* Increment num to get unregister rdev */
218 num++;
219 goto scrub;
220 }
221 }
113 } 222 }
114 223
115 platform_set_drvdata(pdev, rdev); 224 platform_set_drvdata(pdev, pmic);
116 return 0; 225 return 0;
226
227scrub:
228 while (--num >= 0) {
229 ri = &pmic[num];
230 regulator_unregister(ri->rdev);
231 }
232 return ret;
117} 233}
118 234
119static int __devexit tps65090_regulator_remove(struct platform_device *pdev) 235static int tps65090_regulator_remove(struct platform_device *pdev)
120{ 236{
121 struct regulator_dev *rdev = platform_get_drvdata(pdev); 237 struct tps65090_regulator *pmic = platform_get_drvdata(pdev);
238 struct tps65090_regulator *ri;
239 int num;
122 240
123 regulator_unregister(rdev); 241 for (num = 0; num < TPS65090_REGULATOR_MAX; ++num) {
242 ri = &pmic[num];
243 regulator_unregister(ri->rdev);
244 }
124 return 0; 245 return 0;
125} 246}
126 247
127static struct platform_driver tps65090_regulator_driver = { 248static struct platform_driver tps65090_regulator_driver = {
128 .driver = { 249 .driver = {
129 .name = "tps65090-regulator", 250 .name = "tps65090-pmic",
130 .owner = THIS_MODULE, 251 .owner = THIS_MODULE,
131 }, 252 },
132 .probe = tps65090_regulator_probe, 253 .probe = tps65090_regulator_probe,
133 .remove = __devexit_p(tps65090_regulator_remove), 254 .remove = tps65090_regulator_remove,
134}; 255};
135 256
136static int __init tps65090_regulator_init(void) 257static int __init tps65090_regulator_init(void)
diff --git a/drivers/regulator/tps65217-regulator.c b/drivers/regulator/tps65217-regulator.c
index ab00cab905b..73dce766412 100644
--- a/drivers/regulator/tps65217-regulator.c
+++ b/drivers/regulator/tps65217-regulator.c
@@ -332,7 +332,7 @@ static struct tps65217_board *tps65217_parse_dt(struct platform_device *pdev)
332} 332}
333#endif 333#endif
334 334
335static int __devinit tps65217_regulator_probe(struct platform_device *pdev) 335static int tps65217_regulator_probe(struct platform_device *pdev)
336{ 336{
337 struct tps65217 *tps = dev_get_drvdata(pdev->dev.parent); 337 struct tps65217 *tps = dev_get_drvdata(pdev->dev.parent);
338 struct tps65217_board *pdata = dev_get_platdata(tps->dev); 338 struct tps65217_board *pdata = dev_get_platdata(tps->dev);
@@ -397,7 +397,7 @@ err_unregister_regulator:
397 return ret; 397 return ret;
398} 398}
399 399
400static int __devexit tps65217_regulator_remove(struct platform_device *pdev) 400static int tps65217_regulator_remove(struct platform_device *pdev)
401{ 401{
402 struct tps65217 *tps = platform_get_drvdata(pdev); 402 struct tps65217 *tps = platform_get_drvdata(pdev);
403 unsigned int i; 403 unsigned int i;
@@ -415,7 +415,7 @@ static struct platform_driver tps65217_regulator_driver = {
415 .name = "tps65217-pmic", 415 .name = "tps65217-pmic",
416 }, 416 },
417 .probe = tps65217_regulator_probe, 417 .probe = tps65217_regulator_probe,
418 .remove = __devexit_p(tps65217_regulator_remove), 418 .remove = tps65217_regulator_remove,
419}; 419};
420 420
421static int __init tps65217_regulator_init(void) 421static int __init tps65217_regulator_init(void)
diff --git a/drivers/regulator/tps6524x-regulator.c b/drivers/regulator/tps6524x-regulator.c
index 058d2f2675e..843ee0a9bb9 100644
--- a/drivers/regulator/tps6524x-regulator.c
+++ b/drivers/regulator/tps6524x-regulator.c
@@ -592,7 +592,7 @@ static int pmic_remove(struct spi_device *spi)
592 return 0; 592 return 0;
593} 593}
594 594
595static int __devinit pmic_probe(struct spi_device *spi) 595static int pmic_probe(struct spi_device *spi)
596{ 596{
597 struct tps6524x *hw; 597 struct tps6524x *hw;
598 struct device *dev = &spi->dev; 598 struct device *dev = &spi->dev;
@@ -649,7 +649,7 @@ fail:
649 649
650static struct spi_driver pmic_driver = { 650static struct spi_driver pmic_driver = {
651 .probe = pmic_probe, 651 .probe = pmic_probe,
652 .remove = __devexit_p(pmic_remove), 652 .remove = pmic_remove,
653 .driver = { 653 .driver = {
654 .name = "tps6524x", 654 .name = "tps6524x",
655 .owner = THIS_MODULE, 655 .owner = THIS_MODULE,
diff --git a/drivers/regulator/tps6586x-regulator.c b/drivers/regulator/tps6586x-regulator.c
index ce1e7cb8d51..9ce44109f2a 100644
--- a/drivers/regulator/tps6586x-regulator.c
+++ b/drivers/regulator/tps6586x-regulator.c
@@ -17,10 +17,12 @@
17#include <linux/module.h> 17#include <linux/module.h>
18#include <linux/init.h> 18#include <linux/init.h>
19#include <linux/err.h> 19#include <linux/err.h>
20#include <linux/of.h>
20#include <linux/slab.h> 21#include <linux/slab.h>
21#include <linux/platform_device.h> 22#include <linux/platform_device.h>
22#include <linux/regulator/driver.h> 23#include <linux/regulator/driver.h>
23#include <linux/regulator/machine.h> 24#include <linux/regulator/machine.h>
25#include <linux/regulator/of_regulator.h>
24#include <linux/mfd/tps6586x.h> 26#include <linux/mfd/tps6586x.h>
25 27
26/* supply control and voltage setting */ 28/* supply control and voltage setting */
@@ -255,10 +257,10 @@ static inline int tps6586x_regulator_preinit(struct device *parent,
255 1 << ri->enable_bit[1]); 257 1 << ri->enable_bit[1]);
256} 258}
257 259
258static int tps6586x_regulator_set_slew_rate(struct platform_device *pdev) 260static int tps6586x_regulator_set_slew_rate(struct platform_device *pdev,
261 int id, struct regulator_init_data *p)
259{ 262{
260 struct device *parent = pdev->dev.parent; 263 struct device *parent = pdev->dev.parent;
261 struct regulator_init_data *p = pdev->dev.platform_data;
262 struct tps6586x_settings *setting = p->driver_data; 264 struct tps6586x_settings *setting = p->driver_data;
263 uint8_t reg; 265 uint8_t reg;
264 266
@@ -269,7 +271,7 @@ static int tps6586x_regulator_set_slew_rate(struct platform_device *pdev)
269 return 0; 271 return 0;
270 272
271 /* only SM0 and SM1 can have the slew rate settings */ 273 /* only SM0 and SM1 can have the slew rate settings */
272 switch (pdev->id) { 274 switch (id) {
273 case TPS6586X_ID_SM_0: 275 case TPS6586X_ID_SM_0:
274 reg = TPS6586X_SM0SL; 276 reg = TPS6586X_SM0SL;
275 break; 277 break;
@@ -298,58 +300,185 @@ static inline struct tps6586x_regulator *find_regulator_info(int id)
298 return NULL; 300 return NULL;
299} 301}
300 302
301static int __devinit tps6586x_regulator_probe(struct platform_device *pdev) 303#ifdef CONFIG_OF
304static struct of_regulator_match tps6586x_matches[] = {
305 { .name = "sys", .driver_data = (void *)TPS6586X_ID_SYS },
306 { .name = "sm0", .driver_data = (void *)TPS6586X_ID_SM_0 },
307 { .name = "sm1", .driver_data = (void *)TPS6586X_ID_SM_1 },
308 { .name = "sm2", .driver_data = (void *)TPS6586X_ID_SM_2 },
309 { .name = "ldo0", .driver_data = (void *)TPS6586X_ID_LDO_0 },
310 { .name = "ldo1", .driver_data = (void *)TPS6586X_ID_LDO_1 },
311 { .name = "ldo2", .driver_data = (void *)TPS6586X_ID_LDO_2 },
312 { .name = "ldo3", .driver_data = (void *)TPS6586X_ID_LDO_3 },
313 { .name = "ldo4", .driver_data = (void *)TPS6586X_ID_LDO_4 },
314 { .name = "ldo5", .driver_data = (void *)TPS6586X_ID_LDO_5 },
315 { .name = "ldo6", .driver_data = (void *)TPS6586X_ID_LDO_6 },
316 { .name = "ldo7", .driver_data = (void *)TPS6586X_ID_LDO_7 },
317 { .name = "ldo8", .driver_data = (void *)TPS6586X_ID_LDO_8 },
318 { .name = "ldo9", .driver_data = (void *)TPS6586X_ID_LDO_9 },
319 { .name = "ldo_rtc", .driver_data = (void *)TPS6586X_ID_LDO_RTC },
320};
321
322static struct tps6586x_platform_data *tps6586x_parse_regulator_dt(
323 struct platform_device *pdev,
324 struct of_regulator_match **tps6586x_reg_matches)
325{
326 const unsigned int num = ARRAY_SIZE(tps6586x_matches);
327 struct device_node *np = pdev->dev.parent->of_node;
328 struct device_node *regs;
329 const char *sys_rail = NULL;
330 unsigned int i;
331 struct tps6586x_platform_data *pdata;
332 int err;
333
334 regs = of_find_node_by_name(np, "regulators");
335 if (!regs) {
336 dev_err(&pdev->dev, "regulator node not found\n");
337 return NULL;
338 }
339
340 err = of_regulator_match(&pdev->dev, regs, tps6586x_matches, num);
341 if (err < 0) {
342 dev_err(&pdev->dev, "Regulator match failed, e %d\n", err);
343 of_node_put(regs);
344 return NULL;
345 }
346
347 of_node_put(regs);
348
349 pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
350 if (!pdata) {
351 dev_err(&pdev->dev, "Memory alloction failed\n");
352 return NULL;
353 }
354
355 for (i = 0; i < num; i++) {
356 int id;
357 if (!tps6586x_matches[i].init_data)
358 continue;
359
360 pdata->reg_init_data[i] = tps6586x_matches[i].init_data;
361 id = (int)tps6586x_matches[i].driver_data;
362 if (id == TPS6586X_ID_SYS)
363 sys_rail = pdata->reg_init_data[i]->constraints.name;
364
365 if ((id == TPS6586X_ID_LDO_5) || (id == TPS6586X_ID_LDO_RTC))
366 pdata->reg_init_data[i]->supply_regulator = sys_rail;
367 }
368 *tps6586x_reg_matches = tps6586x_matches;
369 return pdata;
370}
371#else
372static struct tps6586x_platform_data *tps6586x_parse_regulator_dt(
373 struct platform_device *pdev,
374 struct of_regulator_match **tps6586x_reg_matches)
375{
376 *tps6586x_reg_matches = NULL;
377 return NULL;
378}
379#endif
380
381static int tps6586x_regulator_probe(struct platform_device *pdev)
302{ 382{
303 struct tps6586x_regulator *ri = NULL; 383 struct tps6586x_regulator *ri = NULL;
304 struct regulator_config config = { }; 384 struct regulator_config config = { };
305 struct regulator_dev *rdev; 385 struct regulator_dev **rdev;
306 int id = pdev->id; 386 struct regulator_init_data *reg_data;
387 struct tps6586x_platform_data *pdata;
388 struct of_regulator_match *tps6586x_reg_matches = NULL;
389 int id;
307 int err; 390 int err;
308 391
309 dev_dbg(&pdev->dev, "Probing regulator %d\n", id); 392 dev_dbg(&pdev->dev, "Probing regulator %d\n", id);
310 393
311 ri = find_regulator_info(id); 394 pdata = dev_get_platdata(pdev->dev.parent);
312 if (ri == NULL) { 395 if ((!pdata) && (pdev->dev.parent->of_node))
313 dev_err(&pdev->dev, "invalid regulator ID specified\n"); 396 pdata = tps6586x_parse_regulator_dt(pdev,
314 return -EINVAL; 397 &tps6586x_reg_matches);
315 }
316 398
317 err = tps6586x_regulator_preinit(pdev->dev.parent, ri); 399 if (!pdata) {
318 if (err) 400 dev_err(&pdev->dev, "Platform data not available, exiting\n");
319 return err; 401 return -ENODEV;
402 }
320 403
321 config.dev = pdev->dev.parent; 404 rdev = devm_kzalloc(&pdev->dev, TPS6586X_ID_MAX_REGULATOR *
322 config.of_node = pdev->dev.of_node; 405 sizeof(*rdev), GFP_KERNEL);
323 config.init_data = pdev->dev.platform_data; 406 if (!rdev) {
324 config.driver_data = ri; 407 dev_err(&pdev->dev, "Mmemory alloc failed\n");
408 return -ENOMEM;
409 }
325 410
326 rdev = regulator_register(&ri->desc, &config); 411 for (id = 0; id < TPS6586X_ID_MAX_REGULATOR; ++id) {
327 if (IS_ERR(rdev)) { 412 reg_data = pdata->reg_init_data[id];
328 dev_err(&pdev->dev, "failed to register regulator %s\n", 413
329 ri->desc.name); 414 ri = find_regulator_info(id);
330 return PTR_ERR(rdev); 415 if (!ri) {
416 dev_err(&pdev->dev, "invalid regulator ID specified\n");
417 err = -EINVAL;
418 goto fail;
419 }
420
421 err = tps6586x_regulator_preinit(pdev->dev.parent, ri);
422 if (err) {
423 dev_err(&pdev->dev,
424 "regulator %d preinit failed, e %d\n", id, err);
425 goto fail;
426 }
427
428 config.dev = pdev->dev.parent;
429 config.init_data = reg_data;
430 config.driver_data = ri;
431
432 if (tps6586x_reg_matches)
433 config.of_node = tps6586x_reg_matches[id].of_node;
434
435 rdev[id] = regulator_register(&ri->desc, &config);
436 if (IS_ERR(rdev[id])) {
437 dev_err(&pdev->dev, "failed to register regulator %s\n",
438 ri->desc.name);
439 err = PTR_ERR(rdev[id]);
440 goto fail;
441 }
442
443 if (reg_data) {
444 err = tps6586x_regulator_set_slew_rate(pdev, id,
445 reg_data);
446 if (err < 0) {
447 dev_err(&pdev->dev,
448 "Slew rate config failed, e %d\n", err);
449 regulator_unregister(rdev[id]);
450 goto fail;
451 }
452 }
331 } 453 }
332 454
333 platform_set_drvdata(pdev, rdev); 455 platform_set_drvdata(pdev, rdev);
456 return 0;
334 457
335 return tps6586x_regulator_set_slew_rate(pdev); 458fail:
459 while (--id >= 0)
460 regulator_unregister(rdev[id]);
461 return err;
336} 462}
337 463
338static int __devexit tps6586x_regulator_remove(struct platform_device *pdev) 464static int tps6586x_regulator_remove(struct platform_device *pdev)
339{ 465{
340 struct regulator_dev *rdev = platform_get_drvdata(pdev); 466 struct regulator_dev **rdev = platform_get_drvdata(pdev);
467 int id = TPS6586X_ID_MAX_REGULATOR;
468
469 while (--id >= 0)
470 regulator_unregister(rdev[id]);
341 471
342 regulator_unregister(rdev);
343 return 0; 472 return 0;
344} 473}
345 474
346static struct platform_driver tps6586x_regulator_driver = { 475static struct platform_driver tps6586x_regulator_driver = {
347 .driver = { 476 .driver = {
348 .name = "tps6586x-regulator", 477 .name = "tps6586x-pmic",
349 .owner = THIS_MODULE, 478 .owner = THIS_MODULE,
350 }, 479 },
351 .probe = tps6586x_regulator_probe, 480 .probe = tps6586x_regulator_probe,
352 .remove = __devexit_p(tps6586x_regulator_remove), 481 .remove = tps6586x_regulator_remove,
353}; 482};
354 483
355static int __init tps6586x_regulator_init(void) 484static int __init tps6586x_regulator_init(void)
diff --git a/drivers/regulator/tps65910-regulator.c b/drivers/regulator/tps65910-regulator.c
index 793adda560c..6b77bbf32eb 100644
--- a/drivers/regulator/tps65910-regulator.c
+++ b/drivers/regulator/tps65910-regulator.c
@@ -1026,7 +1026,7 @@ static inline struct tps65910_board *tps65910_parse_dt_reg_data(
1026} 1026}
1027#endif 1027#endif
1028 1028
1029static __devinit int tps65910_probe(struct platform_device *pdev) 1029static int tps65910_probe(struct platform_device *pdev)
1030{ 1030{
1031 struct tps65910 *tps65910 = dev_get_drvdata(pdev->dev.parent); 1031 struct tps65910 *tps65910 = dev_get_drvdata(pdev->dev.parent);
1032 struct regulator_config config = { }; 1032 struct regulator_config config = { };
@@ -1184,7 +1184,7 @@ err_unregister_regulator:
1184 return err; 1184 return err;
1185} 1185}
1186 1186
1187static int __devexit tps65910_remove(struct platform_device *pdev) 1187static int tps65910_remove(struct platform_device *pdev)
1188{ 1188{
1189 struct tps65910_reg *pmic = platform_get_drvdata(pdev); 1189 struct tps65910_reg *pmic = platform_get_drvdata(pdev);
1190 int i; 1190 int i;
@@ -1231,7 +1231,7 @@ static struct platform_driver tps65910_driver = {
1231 .owner = THIS_MODULE, 1231 .owner = THIS_MODULE,
1232 }, 1232 },
1233 .probe = tps65910_probe, 1233 .probe = tps65910_probe,
1234 .remove = __devexit_p(tps65910_remove), 1234 .remove = tps65910_remove,
1235 .shutdown = tps65910_shutdown, 1235 .shutdown = tps65910_shutdown,
1236}; 1236};
1237 1237
diff --git a/drivers/regulator/tps65912-regulator.c b/drivers/regulator/tps65912-regulator.c
index 18b2a1dcb4b..17e994e47dc 100644
--- a/drivers/regulator/tps65912-regulator.c
+++ b/drivers/regulator/tps65912-regulator.c
@@ -459,7 +459,7 @@ static struct regulator_ops tps65912_ops_ldo = {
459 .list_voltage = tps65912_list_voltage, 459 .list_voltage = tps65912_list_voltage,
460}; 460};
461 461
462static __devinit int tps65912_probe(struct platform_device *pdev) 462static int tps65912_probe(struct platform_device *pdev)
463{ 463{
464 struct tps65912 *tps65912 = dev_get_drvdata(pdev->dev.parent); 464 struct tps65912 *tps65912 = dev_get_drvdata(pdev->dev.parent);
465 struct regulator_config config = { }; 465 struct regulator_config config = { };
@@ -525,7 +525,7 @@ err:
525 return err; 525 return err;
526} 526}
527 527
528static int __devexit tps65912_remove(struct platform_device *pdev) 528static int tps65912_remove(struct platform_device *pdev)
529{ 529{
530 struct tps65912_reg *tps65912_reg = platform_get_drvdata(pdev); 530 struct tps65912_reg *tps65912_reg = platform_get_drvdata(pdev);
531 int i; 531 int i;
@@ -541,7 +541,7 @@ static struct platform_driver tps65912_driver = {
541 .owner = THIS_MODULE, 541 .owner = THIS_MODULE,
542 }, 542 },
543 .probe = tps65912_probe, 543 .probe = tps65912_probe,
544 .remove = __devexit_p(tps65912_remove), 544 .remove = tps65912_remove,
545}; 545};
546 546
547static int __init tps65912_init(void) 547static int __init tps65912_init(void)
diff --git a/drivers/regulator/tps80031-regulator.c b/drivers/regulator/tps80031-regulator.c
new file mode 100644
index 00000000000..127d1754fcd
--- /dev/null
+++ b/drivers/regulator/tps80031-regulator.c
@@ -0,0 +1,793 @@
1/*
2 * tps80031-regulator.c -- TI TPS80031 regulator driver.
3 *
4 * Regulator driver for TITPS80031/TPS80032 Fully Integrated Power
5 * Management with Power Path and Battery Charger.
6 *
7 * Copyright (c) 2012, NVIDIA Corporation.
8 *
9 * Author: Laxman Dewangan <ldewangan@nvidia.com>
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License as
13 * published by the Free Software Foundation version 2.
14 *
15 * This program is distributed "as is" WITHOUT ANY WARRANTY of any kind,
16 * whether express or implied; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
23 * 02111-1307, USA
24 */
25
26#include <linux/delay.h>
27#include <linux/err.h>
28#include <linux/init.h>
29#include <linux/kernel.h>
30#include <linux/mfd/tps80031.h>
31#include <linux/module.h>
32#include <linux/platform_device.h>
33#include <linux/regulator/driver.h>
34#include <linux/regulator/machine.h>
35#include <linux/slab.h>
36
37/* Flags for DCDC Voltage reading */
38#define DCDC_OFFSET_EN BIT(0)
39#define DCDC_EXTENDED_EN BIT(1)
40#define TRACK_MODE_ENABLE BIT(2)
41
42#define SMPS_MULTOFFSET_VIO BIT(1)
43#define SMPS_MULTOFFSET_SMPS1 BIT(3)
44#define SMPS_MULTOFFSET_SMPS2 BIT(4)
45#define SMPS_MULTOFFSET_SMPS3 BIT(6)
46#define SMPS_MULTOFFSET_SMPS4 BIT(0)
47
48#define SMPS_CMD_MASK 0xC0
49#define SMPS_VSEL_MASK 0x3F
50#define LDO_VSEL_MASK 0x1F
51#define LDO_TRACK_VSEL_MASK 0x3F
52
53#define MISC2_LDOUSB_IN_VSYS BIT(4)
54#define MISC2_LDOUSB_IN_PMID BIT(3)
55#define MISC2_LDOUSB_IN_MASK 0x18
56
57#define MISC2_LDO3_SEL_VIB_VAL BIT(0)
58#define MISC2_LDO3_SEL_VIB_MASK 0x1
59
60#define BOOST_HW_PWR_EN BIT(5)
61#define BOOST_HW_PWR_EN_MASK BIT(5)
62
63#define OPA_MODE_EN BIT(6)
64#define OPA_MODE_EN_MASK BIT(6)
65
66#define USB_VBUS_CTRL_SET 0x04
67#define USB_VBUS_CTRL_CLR 0x05
68#define VBUS_DISCHRG 0x20
69
70struct tps80031_regulator_info {
71 /* Regulator register address.*/
72 u8 trans_reg;
73 u8 state_reg;
74 u8 force_reg;
75 u8 volt_reg;
76 u8 volt_id;
77
78 /*Power request bits */
79 int preq_bit;
80
81 /* used by regulator core */
82 struct regulator_desc desc;
83
84};
85
86struct tps80031_regulator {
87 struct device *dev;
88 struct regulator_dev *rdev;
89 struct tps80031_regulator_info *rinfo;
90
91 u8 device_flags;
92 unsigned int config_flags;
93 unsigned int ext_ctrl_flag;
94};
95
96static inline struct device *to_tps80031_dev(struct regulator_dev *rdev)
97{
98 return rdev_get_dev(rdev)->parent->parent;
99}
100
101static int tps80031_reg_is_enabled(struct regulator_dev *rdev)
102{
103 struct tps80031_regulator *ri = rdev_get_drvdata(rdev);
104 struct device *parent = to_tps80031_dev(rdev);
105 u8 reg_val;
106 int ret;
107
108 if (ri->ext_ctrl_flag & TPS80031_EXT_PWR_REQ)
109 return true;
110
111 ret = tps80031_read(parent, TPS80031_SLAVE_ID1, ri->rinfo->state_reg,
112 &reg_val);
113 if (ret < 0) {
114 dev_err(&rdev->dev, "Reg 0x%02x read failed, err = %d\n",
115 ri->rinfo->state_reg, ret);
116 return ret;
117 }
118 return ((reg_val & TPS80031_STATE_MASK) == TPS80031_STATE_ON);
119}
120
121static int tps80031_reg_enable(struct regulator_dev *rdev)
122{
123 struct tps80031_regulator *ri = rdev_get_drvdata(rdev);
124 struct device *parent = to_tps80031_dev(rdev);
125 int ret;
126
127 if (ri->ext_ctrl_flag & TPS80031_EXT_PWR_REQ)
128 return 0;
129
130 ret = tps80031_update(parent, TPS80031_SLAVE_ID1, ri->rinfo->state_reg,
131 TPS80031_STATE_ON, TPS80031_STATE_MASK);
132 if (ret < 0) {
133 dev_err(&rdev->dev, "Reg 0x%02x update failed, err = %d\n",
134 ri->rinfo->state_reg, ret);
135 return ret;
136 }
137 return ret;
138}
139
140static int tps80031_reg_disable(struct regulator_dev *rdev)
141{
142 struct tps80031_regulator *ri = rdev_get_drvdata(rdev);
143 struct device *parent = to_tps80031_dev(rdev);
144 int ret;
145
146 if (ri->ext_ctrl_flag & TPS80031_EXT_PWR_REQ)
147 return 0;
148
149 ret = tps80031_update(parent, TPS80031_SLAVE_ID1, ri->rinfo->state_reg,
150 TPS80031_STATE_OFF, TPS80031_STATE_MASK);
151 if (ret < 0)
152 dev_err(&rdev->dev, "Reg 0x%02x update failed, err = %d\n",
153 ri->rinfo->state_reg, ret);
154 return ret;
155}
156
157/* DCDC voltages for the selector of 58 to 63 */
158static int tps80031_dcdc_voltages[4][5] = {
159 { 1350, 1500, 1800, 1900, 2100},
160 { 1350, 1500, 1800, 1900, 2100},
161 { 2084, 2315, 2778, 2932, 3241},
162 { 4167, 2315, 2778, 2932, 3241},
163};
164
165static int tps80031_dcdc_list_voltage(struct regulator_dev *rdev, unsigned sel)
166{
167 struct tps80031_regulator *ri = rdev_get_drvdata(rdev);
168 int volt_index = ri->device_flags & 0x3;
169
170 if (sel == 0)
171 return 0;
172 else if (sel < 58)
173 return regulator_list_voltage_linear(rdev, sel - 1);
174 else
175 return tps80031_dcdc_voltages[volt_index][sel - 58] * 1000;
176}
177
178static int tps80031_dcdc_set_voltage_sel(struct regulator_dev *rdev,
179 unsigned vsel)
180{
181 struct tps80031_regulator *ri = rdev_get_drvdata(rdev);
182 struct device *parent = to_tps80031_dev(rdev);
183 int ret;
184 u8 reg_val;
185
186 if (ri->rinfo->force_reg) {
187 ret = tps80031_read(parent, ri->rinfo->volt_id,
188 ri->rinfo->force_reg, &reg_val);
189 if (ret < 0) {
190 dev_err(ri->dev, "reg 0x%02x read failed, e = %d\n",
191 ri->rinfo->force_reg, ret);
192 return ret;
193 }
194 if (!(reg_val & SMPS_CMD_MASK)) {
195 ret = tps80031_update(parent, ri->rinfo->volt_id,
196 ri->rinfo->force_reg, vsel, SMPS_VSEL_MASK);
197 if (ret < 0)
198 dev_err(ri->dev,
199 "reg 0x%02x update failed, e = %d\n",
200 ri->rinfo->force_reg, ret);
201 return ret;
202 }
203 }
204 ret = tps80031_update(parent, ri->rinfo->volt_id,
205 ri->rinfo->volt_reg, vsel, SMPS_VSEL_MASK);
206 if (ret < 0)
207 dev_err(ri->dev, "reg 0x%02x update failed, e = %d\n",
208 ri->rinfo->volt_reg, ret);
209 return ret;
210}
211
212static int tps80031_dcdc_get_voltage_sel(struct regulator_dev *rdev)
213{
214 struct tps80031_regulator *ri = rdev_get_drvdata(rdev);
215 struct device *parent = to_tps80031_dev(rdev);
216 uint8_t vsel = 0;
217 int ret;
218
219 if (ri->rinfo->force_reg) {
220 ret = tps80031_read(parent, ri->rinfo->volt_id,
221 ri->rinfo->force_reg, &vsel);
222 if (ret < 0) {
223 dev_err(ri->dev, "reg 0x%02x read failed, e = %d\n",
224 ri->rinfo->force_reg, ret);
225 return ret;
226 }
227
228 if (!(vsel & SMPS_CMD_MASK))
229 return vsel & SMPS_VSEL_MASK;
230 }
231 ret = tps80031_read(parent, ri->rinfo->volt_id,
232 ri->rinfo->volt_reg, &vsel);
233 if (ret < 0) {
234 dev_err(ri->dev, "reg 0x%02x read failed, e = %d\n",
235 ri->rinfo->volt_reg, ret);
236 return ret;
237 }
238 return vsel & SMPS_VSEL_MASK;
239}
240
241static int tps80031_ldo_set_voltage_sel(struct regulator_dev *rdev,
242 unsigned sel)
243{
244 struct tps80031_regulator *ri = rdev_get_drvdata(rdev);
245 struct device *parent = to_tps80031_dev(rdev);
246 int ret;
247
248 /* Check for valid setting for TPS80031 or TPS80032-ES1.0 */
249 if ((ri->rinfo->desc.id == TPS80031_REGULATOR_LDO2) &&
250 (ri->device_flags & TRACK_MODE_ENABLE)) {
251 unsigned nvsel = (sel) & 0x1F;
252 if (((tps80031_get_chip_info(parent) == TPS80031) ||
253 ((tps80031_get_chip_info(parent) == TPS80032) &&
254 (tps80031_get_pmu_version(parent) == 0x0))) &&
255 ((nvsel == 0x0) || (nvsel >= 0x19 && nvsel <= 0x1F))) {
256 dev_err(ri->dev,
257 "Invalid sel %d in track mode LDO2\n",
258 nvsel);
259 return -EINVAL;
260 }
261 }
262
263 ret = tps80031_write(parent, ri->rinfo->volt_id,
264 ri->rinfo->volt_reg, sel);
265 if (ret < 0)
266 dev_err(ri->dev, "Error in writing reg 0x%02x, e = %d\n",
267 ri->rinfo->volt_reg, ret);
268 return ret;
269}
270
271static int tps80031_ldo_get_voltage_sel(struct regulator_dev *rdev)
272{
273 struct tps80031_regulator *ri = rdev_get_drvdata(rdev);
274 struct device *parent = to_tps80031_dev(rdev);
275 uint8_t vsel;
276 int ret;
277
278 ret = tps80031_read(parent, ri->rinfo->volt_id,
279 ri->rinfo->volt_reg, &vsel);
280 if (ret < 0) {
281 dev_err(ri->dev, "Error in writing the Voltage register\n");
282 return ret;
283 }
284 return vsel & rdev->desc->vsel_mask;
285}
286
287static int tps80031_ldo_list_voltage(struct regulator_dev *rdev, unsigned sel)
288{
289 if (sel == 0)
290 return 0;
291 else
292 return regulator_list_voltage_linear(rdev, sel - 1);
293}
294
295static int tps80031_vbus_is_enabled(struct regulator_dev *rdev)
296{
297 struct tps80031_regulator *ri = rdev_get_drvdata(rdev);
298 struct device *parent = to_tps80031_dev(rdev);
299 int ret = -EIO;
300 uint8_t ctrl1 = 0;
301 uint8_t ctrl3 = 0;
302
303 ret = tps80031_read(parent, TPS80031_SLAVE_ID2,
304 TPS80031_CHARGERUSB_CTRL1, &ctrl1);
305 if (ret < 0) {
306 dev_err(ri->dev, "reg 0x%02x read failed, e = %d\n",
307 TPS80031_CHARGERUSB_CTRL1, ret);
308 return ret;
309 }
310 ret = tps80031_read(parent, TPS80031_SLAVE_ID2,
311 TPS80031_CHARGERUSB_CTRL3, &ctrl3);
312 if (ret < 0) {
313 dev_err(ri->dev, "reg 0x%02x read failed, e = %d\n",
314 TPS80031_CHARGERUSB_CTRL1, ret);
315 return ret;
316 }
317 if ((ctrl1 & OPA_MODE_EN) && (ctrl3 & BOOST_HW_PWR_EN))
318 return 1;
319 return ret;
320}
321
322static int tps80031_vbus_enable(struct regulator_dev *rdev)
323{
324 struct tps80031_regulator *ri = rdev_get_drvdata(rdev);
325 struct device *parent = to_tps80031_dev(rdev);
326 int ret;
327
328 ret = tps80031_set_bits(parent, TPS80031_SLAVE_ID2,
329 TPS80031_CHARGERUSB_CTRL1, OPA_MODE_EN);
330 if (ret < 0) {
331 dev_err(ri->dev, "reg 0x%02x read failed, e = %d\n",
332 TPS80031_CHARGERUSB_CTRL1, ret);
333 return ret;
334 }
335
336 ret = tps80031_set_bits(parent, TPS80031_SLAVE_ID2,
337 TPS80031_CHARGERUSB_CTRL3, BOOST_HW_PWR_EN);
338 if (ret < 0) {
339 dev_err(ri->dev, "reg 0x%02x read failed, e = %d\n",
340 TPS80031_CHARGERUSB_CTRL3, ret);
341 return ret;
342 }
343 return ret;
344}
345
346static int tps80031_vbus_disable(struct regulator_dev *rdev)
347{
348 struct tps80031_regulator *ri = rdev_get_drvdata(rdev);
349 struct device *parent = to_tps80031_dev(rdev);
350 int ret = 0;
351
352 if (ri->config_flags & TPS80031_VBUS_DISCHRG_EN_PDN) {
353 ret = tps80031_write(parent, TPS80031_SLAVE_ID2,
354 USB_VBUS_CTRL_SET, VBUS_DISCHRG);
355 if (ret < 0) {
356 dev_err(ri->dev, "reg 0x%02x write failed, e = %d\n",
357 USB_VBUS_CTRL_SET, ret);
358 return ret;
359 }
360 }
361
362 ret = tps80031_clr_bits(parent, TPS80031_SLAVE_ID2,
363 TPS80031_CHARGERUSB_CTRL1, OPA_MODE_EN);
364 if (ret < 0) {
365 dev_err(ri->dev, "reg 0x%02x clearbit failed, e = %d\n",
366 TPS80031_CHARGERUSB_CTRL1, ret);
367 return ret;
368 }
369
370 ret = tps80031_clr_bits(parent, TPS80031_SLAVE_ID2,
371 TPS80031_CHARGERUSB_CTRL3, BOOST_HW_PWR_EN);
372 if (ret < 0) {
373 dev_err(ri->dev, "reg 0x%02x clearbit failed, e = %d\n",
374 TPS80031_CHARGERUSB_CTRL3, ret);
375 return ret;
376 }
377
378 mdelay(DIV_ROUND_UP(ri->rinfo->desc.enable_time, 1000));
379 if (ri->config_flags & TPS80031_VBUS_DISCHRG_EN_PDN) {
380 ret = tps80031_write(parent, TPS80031_SLAVE_ID2,
381 USB_VBUS_CTRL_CLR, VBUS_DISCHRG);
382 if (ret < 0) {
383 dev_err(ri->dev, "reg 0x%02x write failed, e = %d\n",
384 USB_VBUS_CTRL_CLR, ret);
385 return ret;
386 }
387 }
388 return ret;
389}
390
391static struct regulator_ops tps80031_dcdc_ops = {
392 .list_voltage = tps80031_dcdc_list_voltage,
393 .set_voltage_sel = tps80031_dcdc_set_voltage_sel,
394 .get_voltage_sel = tps80031_dcdc_get_voltage_sel,
395 .enable = tps80031_reg_enable,
396 .disable = tps80031_reg_disable,
397 .is_enabled = tps80031_reg_is_enabled,
398};
399
400static struct regulator_ops tps80031_ldo_ops = {
401 .list_voltage = tps80031_ldo_list_voltage,
402 .set_voltage_sel = tps80031_ldo_set_voltage_sel,
403 .get_voltage_sel = tps80031_ldo_get_voltage_sel,
404 .enable = tps80031_reg_enable,
405 .disable = tps80031_reg_disable,
406 .is_enabled = tps80031_reg_is_enabled,
407};
408
409static struct regulator_ops tps80031_vbus_sw_ops = {
410 .enable = tps80031_vbus_enable,
411 .disable = tps80031_vbus_disable,
412 .is_enabled = tps80031_vbus_is_enabled,
413};
414
415static struct regulator_ops tps80031_vbus_hw_ops = {
416};
417
418static struct regulator_ops tps80031_ext_reg_ops = {
419 .enable = tps80031_reg_enable,
420 .disable = tps80031_reg_disable,
421 .is_enabled = tps80031_reg_is_enabled,
422};
423
424/* Non-exiting default definition for some register */
425#define TPS80031_SMPS3_CFG_FORCE 0
426#define TPS80031_SMPS4_CFG_FORCE 0
427
428#define TPS80031_VBUS_CFG_TRANS 0
429#define TPS80031_VBUS_CFG_STATE 0
430
431#define TPS80031_REG_SMPS(_id, _volt_id, _pbit) \
432{ \
433 .trans_reg = TPS80031_##_id##_CFG_TRANS, \
434 .state_reg = TPS80031_##_id##_CFG_STATE, \
435 .force_reg = TPS80031_##_id##_CFG_FORCE, \
436 .volt_reg = TPS80031_##_id##_CFG_VOLTAGE, \
437 .volt_id = TPS80031_SLAVE_##_volt_id, \
438 .preq_bit = _pbit, \
439 .desc = { \
440 .name = "tps80031_"#_id, \
441 .id = TPS80031_REGULATOR_##_id, \
442 .n_voltages = 63, \
443 .ops = &tps80031_dcdc_ops, \
444 .type = REGULATOR_VOLTAGE, \
445 .owner = THIS_MODULE, \
446 .enable_time = 500, \
447 }, \
448}
449
450#define TPS80031_REG_LDO(_id, _preq_bit) \
451{ \
452 .trans_reg = TPS80031_##_id##_CFG_TRANS, \
453 .state_reg = TPS80031_##_id##_CFG_STATE, \
454 .volt_reg = TPS80031_##_id##_CFG_VOLTAGE, \
455 .volt_id = TPS80031_SLAVE_ID1, \
456 .preq_bit = _preq_bit, \
457 .desc = { \
458 .owner = THIS_MODULE, \
459 .name = "tps80031_"#_id, \
460 .id = TPS80031_REGULATOR_##_id, \
461 .ops = &tps80031_ldo_ops, \
462 .type = REGULATOR_VOLTAGE, \
463 .min_uV = 1000000, \
464 .uV_step = 100000, \
465 .n_voltages = 25, \
466 .vsel_mask = LDO_VSEL_MASK, \
467 .enable_time = 500, \
468 }, \
469}
470
471#define TPS80031_REG_FIXED(_id, max_mV, _ops, _delay, _pbit) \
472{ \
473 .trans_reg = TPS80031_##_id##_CFG_TRANS, \
474 .state_reg = TPS80031_##_id##_CFG_STATE, \
475 .volt_id = TPS80031_SLAVE_ID1, \
476 .preq_bit = _pbit, \
477 .desc = { \
478 .name = "tps80031_"#_id, \
479 .id = TPS80031_REGULATOR_##_id, \
480 .n_voltages = 2, \
481 .ops = &_ops, \
482 .type = REGULATOR_VOLTAGE, \
483 .owner = THIS_MODULE, \
484 .enable_time = _delay, \
485 }, \
486}
487
488static struct tps80031_regulator_info tps80031_rinfo[TPS80031_REGULATOR_MAX] = {
489 TPS80031_REG_SMPS(VIO, ID0, 4),
490 TPS80031_REG_SMPS(SMPS1, ID0, 0),
491 TPS80031_REG_SMPS(SMPS2, ID0, 1),
492 TPS80031_REG_SMPS(SMPS3, ID1, 2),
493 TPS80031_REG_SMPS(SMPS4, ID1, 3),
494 TPS80031_REG_LDO(VANA, -1),
495 TPS80031_REG_LDO(LDO1, 8),
496 TPS80031_REG_LDO(LDO2, 9),
497 TPS80031_REG_LDO(LDO3, 10),
498 TPS80031_REG_LDO(LDO4, 11),
499 TPS80031_REG_LDO(LDO5, 12),
500 TPS80031_REG_LDO(LDO6, 13),
501 TPS80031_REG_LDO(LDO7, 14),
502 TPS80031_REG_LDO(LDOLN, 15),
503 TPS80031_REG_LDO(LDOUSB, 5),
504 TPS80031_REG_FIXED(VBUS, 5000, tps80031_vbus_hw_ops, 100000, -1),
505 TPS80031_REG_FIXED(REGEN1, 3300, tps80031_ext_reg_ops, 0, 16),
506 TPS80031_REG_FIXED(REGEN2, 3300, tps80031_ext_reg_ops, 0, 17),
507 TPS80031_REG_FIXED(SYSEN, 3300, tps80031_ext_reg_ops, 0, 18),
508};
509
510static int tps80031_power_req_config(struct device *parent,
511 struct tps80031_regulator *ri,
512 struct tps80031_regulator_platform_data *tps80031_pdata)
513{
514 int ret = 0;
515
516 if (ri->rinfo->preq_bit < 0)
517 goto skip_pwr_req_config;
518
519 ret = tps80031_ext_power_req_config(parent, ri->ext_ctrl_flag,
520 ri->rinfo->preq_bit, ri->rinfo->state_reg,
521 ri->rinfo->trans_reg);
522 if (ret < 0) {
523 dev_err(ri->dev, "ext powerreq config failed, err = %d\n", ret);
524 return ret;
525 }
526
527skip_pwr_req_config:
528 if (tps80031_pdata->ext_ctrl_flag & TPS80031_PWR_ON_ON_SLEEP) {
529 ret = tps80031_update(parent, TPS80031_SLAVE_ID1,
530 ri->rinfo->trans_reg, TPS80031_TRANS_SLEEP_ON,
531 TPS80031_TRANS_SLEEP_MASK);
532 if (ret < 0) {
533 dev_err(ri->dev, "Reg 0x%02x update failed, e %d\n",
534 ri->rinfo->trans_reg, ret);
535 return ret;
536 }
537 }
538 return ret;
539}
540
541static int tps80031_regulator_config(struct device *parent,
542 struct tps80031_regulator *ri,
543 struct tps80031_regulator_platform_data *tps80031_pdata)
544{
545 int ret = 0;
546
547 switch (ri->rinfo->desc.id) {
548 case TPS80031_REGULATOR_LDOUSB:
549 if (ri->config_flags & (TPS80031_USBLDO_INPUT_VSYS |
550 TPS80031_USBLDO_INPUT_PMID)) {
551 unsigned val = 0;
552 if (ri->config_flags & TPS80031_USBLDO_INPUT_VSYS)
553 val = MISC2_LDOUSB_IN_VSYS;
554 else
555 val = MISC2_LDOUSB_IN_PMID;
556
557 ret = tps80031_update(parent, TPS80031_SLAVE_ID1,
558 TPS80031_MISC2, val,
559 MISC2_LDOUSB_IN_MASK);
560 if (ret < 0) {
561 dev_err(ri->dev,
562 "LDOUSB config failed, e= %d\n", ret);
563 return ret;
564 }
565 }
566 break;
567
568 case TPS80031_REGULATOR_LDO3:
569 if (ri->config_flags & TPS80031_LDO3_OUTPUT_VIB) {
570 ret = tps80031_update(parent, TPS80031_SLAVE_ID1,
571 TPS80031_MISC2, MISC2_LDO3_SEL_VIB_VAL,
572 MISC2_LDO3_SEL_VIB_MASK);
573 if (ret < 0) {
574 dev_err(ri->dev,
575 "LDO3 config failed, e = %d\n", ret);
576 return ret;
577 }
578 }
579 break;
580
581 case TPS80031_REGULATOR_VBUS:
582 /* Provide SW control Ops if VBUS is SW control */
583 if (!(ri->config_flags & TPS80031_VBUS_SW_ONLY))
584 ri->rinfo->desc.ops = &tps80031_vbus_sw_ops;
585 break;
586 default:
587 break;
588 }
589
590 /* Configure Active state to ON, SLEEP to OFF and OFF_state to OFF */
591 ret = tps80031_update(parent, TPS80031_SLAVE_ID1, ri->rinfo->trans_reg,
592 TPS80031_TRANS_ACTIVE_ON | TPS80031_TRANS_SLEEP_OFF |
593 TPS80031_TRANS_OFF_OFF, TPS80031_TRANS_ACTIVE_MASK |
594 TPS80031_TRANS_SLEEP_MASK | TPS80031_TRANS_OFF_MASK);
595 if (ret < 0) {
596 dev_err(ri->dev, "trans reg update failed, e %d\n", ret);
597 return ret;
598 }
599
600 return ret;
601}
602
603static int check_smps_mode_mult(struct device *parent,
604 struct tps80031_regulator *ri)
605{
606 int mult_offset;
607 int ret;
608 u8 smps_offset;
609 u8 smps_mult;
610
611 ret = tps80031_read(parent, TPS80031_SLAVE_ID1,
612 TPS80031_SMPS_OFFSET, &smps_offset);
613 if (ret < 0) {
614 dev_err(parent, "Error in reading smps offset register\n");
615 return ret;
616 }
617
618 ret = tps80031_read(parent, TPS80031_SLAVE_ID1,
619 TPS80031_SMPS_MULT, &smps_mult);
620 if (ret < 0) {
621 dev_err(parent, "Error in reading smps mult register\n");
622 return ret;
623 }
624
625 switch (ri->rinfo->desc.id) {
626 case TPS80031_REGULATOR_VIO:
627 mult_offset = SMPS_MULTOFFSET_VIO;
628 break;
629 case TPS80031_REGULATOR_SMPS1:
630 mult_offset = SMPS_MULTOFFSET_SMPS1;
631 break;
632 case TPS80031_REGULATOR_SMPS2:
633 mult_offset = SMPS_MULTOFFSET_SMPS2;
634 break;
635 case TPS80031_REGULATOR_SMPS3:
636 mult_offset = SMPS_MULTOFFSET_SMPS3;
637 break;
638 case TPS80031_REGULATOR_SMPS4:
639 mult_offset = SMPS_MULTOFFSET_SMPS4;
640 break;
641 case TPS80031_REGULATOR_LDO2:
642 ri->device_flags = smps_mult & BIT(5) ? TRACK_MODE_ENABLE : 0;
643 /* TRACK mode the ldo2 varies from 600mV to 1300mV */
644 if (ri->device_flags & TRACK_MODE_ENABLE) {
645 ri->rinfo->desc.min_uV = 600000;
646 ri->rinfo->desc.uV_step = 12500;
647 ri->rinfo->desc.n_voltages = 57;
648 ri->rinfo->desc.vsel_mask = LDO_TRACK_VSEL_MASK;
649 }
650 return 0;
651 default:
652 return 0;
653 }
654
655 ri->device_flags = (smps_offset & mult_offset) ? DCDC_OFFSET_EN : 0;
656 ri->device_flags |= (smps_mult & mult_offset) ? DCDC_EXTENDED_EN : 0;
657 switch (ri->device_flags) {
658 case 0:
659 ri->rinfo->desc.min_uV = 607700;
660 ri->rinfo->desc.uV_step = 12660;
661 break;
662 case DCDC_OFFSET_EN:
663 ri->rinfo->desc.min_uV = 700000;
664 ri->rinfo->desc.uV_step = 12500;
665 break;
666 case DCDC_EXTENDED_EN:
667 ri->rinfo->desc.min_uV = 1852000;
668 ri->rinfo->desc.uV_step = 38600;
669 break;
670 case DCDC_OFFSET_EN | DCDC_EXTENDED_EN:
671 ri->rinfo->desc.min_uV = 2161000;
672 ri->rinfo->desc.uV_step = 38600;
673 break;
674 }
675 return 0;
676}
677
678static int tps80031_regulator_probe(struct platform_device *pdev)
679{
680 struct tps80031_platform_data *pdata;
681 struct tps80031_regulator_platform_data *tps_pdata;
682 struct tps80031_regulator_info *rinfo;
683 struct tps80031_regulator *ri;
684 struct tps80031_regulator *pmic;
685 struct regulator_dev *rdev;
686 struct regulator_config config = { };
687 int ret;
688 int num;
689
690 pdata = dev_get_platdata(pdev->dev.parent);
691
692 if (!pdata) {
693 dev_err(&pdev->dev, "No platform data\n");
694 return -EINVAL;
695 }
696
697 pmic = devm_kzalloc(&pdev->dev,
698 TPS80031_REGULATOR_MAX * sizeof(*pmic), GFP_KERNEL);
699 if (!pmic) {
700 dev_err(&pdev->dev, "mem alloc for pmic failed\n");
701 return -ENOMEM;
702 }
703
704 for (num = 0; num < TPS80031_REGULATOR_MAX; ++num) {
705 tps_pdata = pdata->regulator_pdata[num];
706 rinfo = &tps80031_rinfo[num];
707 ri = &pmic[num];
708 ri->rinfo = rinfo;
709 ri->dev = &pdev->dev;
710
711 check_smps_mode_mult(pdev->dev.parent, ri);
712 config.dev = &pdev->dev;
713 config.init_data = NULL;
714 config.driver_data = ri;
715 if (tps_pdata) {
716 config.init_data = tps_pdata->reg_init_data;
717 ri->config_flags = tps_pdata->config_flags;
718 ri->ext_ctrl_flag = tps_pdata->ext_ctrl_flag;
719 ret = tps80031_regulator_config(pdev->dev.parent,
720 ri, tps_pdata);
721 if (ret < 0) {
722 dev_err(&pdev->dev,
723 "regulator config failed, e %d\n", ret);
724 goto fail;
725 }
726
727 ret = tps80031_power_req_config(pdev->dev.parent,
728 ri, tps_pdata);
729 if (ret < 0) {
730 dev_err(&pdev->dev,
731 "pwr_req config failed, err %d\n", ret);
732 goto fail;
733 }
734 }
735 rdev = regulator_register(&ri->rinfo->desc, &config);
736 if (IS_ERR_OR_NULL(rdev)) {
737 dev_err(&pdev->dev,
738 "register regulator failed %s\n",
739 ri->rinfo->desc.name);
740 ret = PTR_ERR(rdev);
741 goto fail;
742 }
743 ri->rdev = rdev;
744 }
745
746 platform_set_drvdata(pdev, pmic);
747 return 0;
748fail:
749 while (--num >= 0) {
750 ri = &pmic[num];
751 regulator_unregister(ri->rdev);
752 }
753 return ret;
754}
755
756static int tps80031_regulator_remove(struct platform_device *pdev)
757{
758 struct tps80031_regulator *pmic = platform_get_drvdata(pdev);
759 struct tps80031_regulator *ri = NULL;
760 int num;
761
762 for (num = 0; num < TPS80031_REGULATOR_MAX; ++num) {
763 ri = &pmic[num];
764 regulator_unregister(ri->rdev);
765 }
766 return 0;
767}
768
769static struct platform_driver tps80031_regulator_driver = {
770 .driver = {
771 .name = "tps80031-pmic",
772 .owner = THIS_MODULE,
773 },
774 .probe = tps80031_regulator_probe,
775 .remove = tps80031_regulator_remove,
776};
777
778static int __init tps80031_regulator_init(void)
779{
780 return platform_driver_register(&tps80031_regulator_driver);
781}
782subsys_initcall(tps80031_regulator_init);
783
784static void __exit tps80031_regulator_exit(void)
785{
786 platform_driver_unregister(&tps80031_regulator_driver);
787}
788module_exit(tps80031_regulator_exit);
789
790MODULE_ALIAS("platform:tps80031-regulator");
791MODULE_DESCRIPTION("Regulator Driver for TI TPS80031 PMIC");
792MODULE_AUTHOR("Laxman Dewangan <ldewangan@nvidia.com>");
793MODULE_LICENSE("GPL v2");
diff --git a/drivers/regulator/twl-regulator.c b/drivers/regulator/twl-regulator.c
index 7eb986a4074..493c8c6a241 100644
--- a/drivers/regulator/twl-regulator.c
+++ b/drivers/regulator/twl-regulator.c
@@ -1116,7 +1116,7 @@ static const struct of_device_id twl_of_match[] __devinitconst = {
1116}; 1116};
1117MODULE_DEVICE_TABLE(of, twl_of_match); 1117MODULE_DEVICE_TABLE(of, twl_of_match);
1118 1118
1119static int __devinit twlreg_probe(struct platform_device *pdev) 1119static int twlreg_probe(struct platform_device *pdev)
1120{ 1120{
1121 int i, id; 1121 int i, id;
1122 struct twlreg_info *info; 1122 struct twlreg_info *info;
@@ -1241,7 +1241,7 @@ static int __devinit twlreg_probe(struct platform_device *pdev)
1241 return 0; 1241 return 0;
1242} 1242}
1243 1243
1244static int __devexit twlreg_remove(struct platform_device *pdev) 1244static int twlreg_remove(struct platform_device *pdev)
1245{ 1245{
1246 struct regulator_dev *rdev = platform_get_drvdata(pdev); 1246 struct regulator_dev *rdev = platform_get_drvdata(pdev);
1247 struct twlreg_info *info = rdev->reg_data; 1247 struct twlreg_info *info = rdev->reg_data;
@@ -1255,7 +1255,7 @@ MODULE_ALIAS("platform:twl_reg");
1255 1255
1256static struct platform_driver twlreg_driver = { 1256static struct platform_driver twlreg_driver = {
1257 .probe = twlreg_probe, 1257 .probe = twlreg_probe,
1258 .remove = __devexit_p(twlreg_remove), 1258 .remove = twlreg_remove,
1259 /* NOTE: short name, to work around driver model truncation of 1259 /* NOTE: short name, to work around driver model truncation of
1260 * "twl_regulator.12" (and friends) to "twl_regulator.1". 1260 * "twl_regulator.12" (and friends) to "twl_regulator.1".
1261 */ 1261 */
diff --git a/drivers/regulator/vexpress.c b/drivers/regulator/vexpress.c
new file mode 100644
index 00000000000..4668c7f8133
--- /dev/null
+++ b/drivers/regulator/vexpress.c
@@ -0,0 +1,147 @@
1/*
2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License version 2 as
4 * published by the Free Software Foundation.
5 *
6 * This program is distributed in the hope that it will be useful,
7 * but WITHOUT ANY WARRANTY; without even the implied warranty of
8 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 * GNU General Public License for more details.
10 *
11 * Copyright (C) 2012 ARM Limited
12 */
13
14#define DRVNAME "vexpress-regulator"
15#define pr_fmt(fmt) DRVNAME ": " fmt
16
17#include <linux/device.h>
18#include <linux/err.h>
19#include <linux/module.h>
20#include <linux/of_device.h>
21#include <linux/regulator/driver.h>
22#include <linux/regulator/machine.h>
23#include <linux/regulator/of_regulator.h>
24#include <linux/vexpress.h>
25
26struct vexpress_regulator {
27 struct regulator_desc desc;
28 struct regulator_dev *regdev;
29 struct vexpress_config_func *func;
30};
31
32static int vexpress_regulator_get_voltage(struct regulator_dev *regdev)
33{
34 struct vexpress_regulator *reg = rdev_get_drvdata(regdev);
35 u32 uV;
36 int err = vexpress_config_read(reg->func, 0, &uV);
37
38 return err ? err : uV;
39}
40
41static int vexpress_regulator_set_voltage(struct regulator_dev *regdev,
42 int min_uV, int max_uV, unsigned *selector)
43{
44 struct vexpress_regulator *reg = rdev_get_drvdata(regdev);
45
46 return vexpress_config_write(reg->func, 0, min_uV);
47}
48
49static struct regulator_ops vexpress_regulator_ops_ro = {
50 .get_voltage = vexpress_regulator_get_voltage,
51};
52
53static struct regulator_ops vexpress_regulator_ops = {
54 .get_voltage = vexpress_regulator_get_voltage,
55 .set_voltage = vexpress_regulator_set_voltage,
56};
57
58static int vexpress_regulator_probe(struct platform_device *pdev)
59{
60 int err;
61 struct vexpress_regulator *reg;
62 struct regulator_init_data *init_data;
63 struct regulator_config config = { };
64
65 reg = devm_kzalloc(&pdev->dev, sizeof(*reg), GFP_KERNEL);
66 if (!reg) {
67 err = -ENOMEM;
68 goto error_kzalloc;
69 }
70
71 reg->func = vexpress_config_func_get_by_dev(&pdev->dev);
72 if (!reg->func) {
73 err = -ENXIO;
74 goto error_get_func;
75 }
76
77 reg->desc.name = dev_name(&pdev->dev);
78 reg->desc.type = REGULATOR_VOLTAGE;
79 reg->desc.owner = THIS_MODULE;
80 reg->desc.continuous_voltage_range = true;
81
82 init_data = of_get_regulator_init_data(&pdev->dev, pdev->dev.of_node);
83 if (!init_data) {
84 err = -EINVAL;
85 goto error_get_regulator_init_data;
86 }
87
88 init_data->constraints.apply_uV = 0;
89 if (init_data->constraints.min_uV && init_data->constraints.max_uV)
90 reg->desc.ops = &vexpress_regulator_ops;
91 else
92 reg->desc.ops = &vexpress_regulator_ops_ro;
93
94 config.dev = &pdev->dev;
95 config.init_data = init_data;
96 config.driver_data = reg;
97 config.of_node = pdev->dev.of_node;
98
99 reg->regdev = regulator_register(&reg->desc, &config);
100 if (IS_ERR(reg->regdev)) {
101 err = PTR_ERR(reg->regdev);
102 goto error_regulator_register;
103 }
104
105 platform_set_drvdata(pdev, reg);
106
107 return 0;
108
109error_regulator_register:
110error_get_regulator_init_data:
111 vexpress_config_func_put(reg->func);
112error_get_func:
113error_kzalloc:
114 return err;
115}
116
117static int vexpress_regulator_remove(struct platform_device *pdev)
118{
119 struct vexpress_regulator *reg = platform_get_drvdata(pdev);
120
121 vexpress_config_func_put(reg->func);
122 regulator_unregister(reg->regdev);
123
124 return 0;
125}
126
127static struct of_device_id vexpress_regulator_of_match[] = {
128 { .compatible = "arm,vexpress-volt", },
129 { }
130};
131
132static struct platform_driver vexpress_regulator_driver = {
133 .probe = vexpress_regulator_probe,
134 .remove = vexpress_regulator_remove,
135 .driver = {
136 .name = DRVNAME,
137 .owner = THIS_MODULE,
138 .of_match_table = vexpress_regulator_of_match,
139 },
140};
141
142module_platform_driver(vexpress_regulator_driver);
143
144MODULE_AUTHOR("Pawel Moll <pawel.moll@arm.com>");
145MODULE_DESCRIPTION("Versatile Express regulator");
146MODULE_LICENSE("GPL");
147MODULE_ALIAS("platform:vexpress-regulator");
diff --git a/drivers/regulator/virtual.c b/drivers/regulator/virtual.c
index c038e742253..01c66e9712a 100644
--- a/drivers/regulator/virtual.c
+++ b/drivers/regulator/virtual.c
@@ -285,7 +285,7 @@ static const struct attribute_group regulator_virtual_attr_group = {
285 .attrs = regulator_virtual_attributes, 285 .attrs = regulator_virtual_attributes,
286}; 286};
287 287
288static int __devinit regulator_virtual_probe(struct platform_device *pdev) 288static int regulator_virtual_probe(struct platform_device *pdev)
289{ 289{
290 char *reg_id = pdev->dev.platform_data; 290 char *reg_id = pdev->dev.platform_data;
291 struct virtual_consumer_data *drvdata; 291 struct virtual_consumer_data *drvdata;
@@ -321,7 +321,7 @@ static int __devinit regulator_virtual_probe(struct platform_device *pdev)
321 return 0; 321 return 0;
322} 322}
323 323
324static int __devexit regulator_virtual_remove(struct platform_device *pdev) 324static int regulator_virtual_remove(struct platform_device *pdev)
325{ 325{
326 struct virtual_consumer_data *drvdata = platform_get_drvdata(pdev); 326 struct virtual_consumer_data *drvdata = platform_get_drvdata(pdev);
327 327
@@ -337,7 +337,7 @@ static int __devexit regulator_virtual_remove(struct platform_device *pdev)
337 337
338static struct platform_driver regulator_virtual_consumer_driver = { 338static struct platform_driver regulator_virtual_consumer_driver = {
339 .probe = regulator_virtual_probe, 339 .probe = regulator_virtual_probe,
340 .remove = __devexit_p(regulator_virtual_remove), 340 .remove = regulator_virtual_remove,
341 .driver = { 341 .driver = {
342 .name = "reg-virt-consumer", 342 .name = "reg-virt-consumer",
343 .owner = THIS_MODULE, 343 .owner = THIS_MODULE,
diff --git a/drivers/regulator/wm831x-dcdc.c b/drivers/regulator/wm831x-dcdc.c
index 782c228a19b..33297bcce3f 100644
--- a/drivers/regulator/wm831x-dcdc.c
+++ b/drivers/regulator/wm831x-dcdc.c
@@ -387,7 +387,7 @@ static struct regulator_ops wm831x_buckv_ops = {
387 * Set up DVS control. We just log errors since we can still run 387 * Set up DVS control. We just log errors since we can still run
388 * (with reduced performance) if we fail. 388 * (with reduced performance) if we fail.
389 */ 389 */
390static __devinit void wm831x_buckv_dvs_init(struct wm831x_dcdc *dcdc, 390static void wm831x_buckv_dvs_init(struct wm831x_dcdc *dcdc,
391 struct wm831x_buckv_pdata *pdata) 391 struct wm831x_buckv_pdata *pdata)
392{ 392{
393 struct wm831x *wm831x = dcdc->wm831x; 393 struct wm831x *wm831x = dcdc->wm831x;
@@ -448,7 +448,7 @@ static __devinit void wm831x_buckv_dvs_init(struct wm831x_dcdc *dcdc,
448 } 448 }
449} 449}
450 450
451static __devinit int wm831x_buckv_probe(struct platform_device *pdev) 451static int wm831x_buckv_probe(struct platform_device *pdev)
452{ 452{
453 struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent); 453 struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent);
454 struct wm831x_pdata *pdata = wm831x->dev->platform_data; 454 struct wm831x_pdata *pdata = wm831x->dev->platform_data;
@@ -562,7 +562,7 @@ err:
562 return ret; 562 return ret;
563} 563}
564 564
565static __devexit int wm831x_buckv_remove(struct platform_device *pdev) 565static int wm831x_buckv_remove(struct platform_device *pdev)
566{ 566{
567 struct wm831x_dcdc *dcdc = platform_get_drvdata(pdev); 567 struct wm831x_dcdc *dcdc = platform_get_drvdata(pdev);
568 struct wm831x *wm831x = dcdc->wm831x; 568 struct wm831x *wm831x = dcdc->wm831x;
@@ -582,7 +582,7 @@ static __devexit int wm831x_buckv_remove(struct platform_device *pdev)
582 582
583static struct platform_driver wm831x_buckv_driver = { 583static struct platform_driver wm831x_buckv_driver = {
584 .probe = wm831x_buckv_probe, 584 .probe = wm831x_buckv_probe,
585 .remove = __devexit_p(wm831x_buckv_remove), 585 .remove = wm831x_buckv_remove,
586 .driver = { 586 .driver = {
587 .name = "wm831x-buckv", 587 .name = "wm831x-buckv",
588 .owner = THIS_MODULE, 588 .owner = THIS_MODULE,
@@ -623,7 +623,7 @@ static struct regulator_ops wm831x_buckp_ops = {
623 .set_suspend_mode = wm831x_dcdc_set_suspend_mode, 623 .set_suspend_mode = wm831x_dcdc_set_suspend_mode,
624}; 624};
625 625
626static __devinit int wm831x_buckp_probe(struct platform_device *pdev) 626static int wm831x_buckp_probe(struct platform_device *pdev)
627{ 627{
628 struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent); 628 struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent);
629 struct wm831x_pdata *pdata = wm831x->dev->platform_data; 629 struct wm831x_pdata *pdata = wm831x->dev->platform_data;
@@ -710,7 +710,7 @@ err:
710 return ret; 710 return ret;
711} 711}
712 712
713static __devexit int wm831x_buckp_remove(struct platform_device *pdev) 713static int wm831x_buckp_remove(struct platform_device *pdev)
714{ 714{
715 struct wm831x_dcdc *dcdc = platform_get_drvdata(pdev); 715 struct wm831x_dcdc *dcdc = platform_get_drvdata(pdev);
716 716
@@ -725,7 +725,7 @@ static __devexit int wm831x_buckp_remove(struct platform_device *pdev)
725 725
726static struct platform_driver wm831x_buckp_driver = { 726static struct platform_driver wm831x_buckp_driver = {
727 .probe = wm831x_buckp_probe, 727 .probe = wm831x_buckp_probe,
728 .remove = __devexit_p(wm831x_buckp_remove), 728 .remove = wm831x_buckp_remove,
729 .driver = { 729 .driver = {
730 .name = "wm831x-buckp", 730 .name = "wm831x-buckp",
731 .owner = THIS_MODULE, 731 .owner = THIS_MODULE,
@@ -771,7 +771,7 @@ static struct regulator_ops wm831x_boostp_ops = {
771 .disable = regulator_disable_regmap, 771 .disable = regulator_disable_regmap,
772}; 772};
773 773
774static __devinit int wm831x_boostp_probe(struct platform_device *pdev) 774static int wm831x_boostp_probe(struct platform_device *pdev)
775{ 775{
776 struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent); 776 struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent);
777 struct wm831x_pdata *pdata = wm831x->dev->platform_data; 777 struct wm831x_pdata *pdata = wm831x->dev->platform_data;
@@ -845,7 +845,7 @@ err:
845 return ret; 845 return ret;
846} 846}
847 847
848static __devexit int wm831x_boostp_remove(struct platform_device *pdev) 848static int wm831x_boostp_remove(struct platform_device *pdev)
849{ 849{
850 struct wm831x_dcdc *dcdc = platform_get_drvdata(pdev); 850 struct wm831x_dcdc *dcdc = platform_get_drvdata(pdev);
851 851
@@ -860,7 +860,7 @@ static __devexit int wm831x_boostp_remove(struct platform_device *pdev)
860 860
861static struct platform_driver wm831x_boostp_driver = { 861static struct platform_driver wm831x_boostp_driver = {
862 .probe = wm831x_boostp_probe, 862 .probe = wm831x_boostp_probe,
863 .remove = __devexit_p(wm831x_boostp_remove), 863 .remove = wm831x_boostp_remove,
864 .driver = { 864 .driver = {
865 .name = "wm831x-boostp", 865 .name = "wm831x-boostp",
866 .owner = THIS_MODULE, 866 .owner = THIS_MODULE,
@@ -883,7 +883,7 @@ static struct regulator_ops wm831x_epe_ops = {
883 .get_status = wm831x_dcdc_get_status, 883 .get_status = wm831x_dcdc_get_status,
884}; 884};
885 885
886static __devinit int wm831x_epe_probe(struct platform_device *pdev) 886static int wm831x_epe_probe(struct platform_device *pdev)
887{ 887{
888 struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent); 888 struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent);
889 struct wm831x_pdata *pdata = wm831x->dev->platform_data; 889 struct wm831x_pdata *pdata = wm831x->dev->platform_data;
@@ -936,7 +936,7 @@ err:
936 return ret; 936 return ret;
937} 937}
938 938
939static __devexit int wm831x_epe_remove(struct platform_device *pdev) 939static int wm831x_epe_remove(struct platform_device *pdev)
940{ 940{
941 struct wm831x_dcdc *dcdc = platform_get_drvdata(pdev); 941 struct wm831x_dcdc *dcdc = platform_get_drvdata(pdev);
942 942
@@ -948,7 +948,7 @@ static __devexit int wm831x_epe_remove(struct platform_device *pdev)
948 948
949static struct platform_driver wm831x_epe_driver = { 949static struct platform_driver wm831x_epe_driver = {
950 .probe = wm831x_epe_probe, 950 .probe = wm831x_epe_probe,
951 .remove = __devexit_p(wm831x_epe_remove), 951 .remove = wm831x_epe_remove,
952 .driver = { 952 .driver = {
953 .name = "wm831x-epe", 953 .name = "wm831x-epe",
954 .owner = THIS_MODULE, 954 .owner = THIS_MODULE,
diff --git a/drivers/regulator/wm831x-isink.c b/drivers/regulator/wm831x-isink.c
index 2646a1902b3..68586ee3e1c 100644
--- a/drivers/regulator/wm831x-isink.c
+++ b/drivers/regulator/wm831x-isink.c
@@ -148,7 +148,7 @@ static irqreturn_t wm831x_isink_irq(int irq, void *data)
148} 148}
149 149
150 150
151static __devinit int wm831x_isink_probe(struct platform_device *pdev) 151static int wm831x_isink_probe(struct platform_device *pdev)
152{ 152{
153 struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent); 153 struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent);
154 struct wm831x_pdata *pdata = wm831x->dev->platform_data; 154 struct wm831x_pdata *pdata = wm831x->dev->platform_data;
@@ -221,7 +221,7 @@ err:
221 return ret; 221 return ret;
222} 222}
223 223
224static __devexit int wm831x_isink_remove(struct platform_device *pdev) 224static int wm831x_isink_remove(struct platform_device *pdev)
225{ 225{
226 struct wm831x_isink *isink = platform_get_drvdata(pdev); 226 struct wm831x_isink *isink = platform_get_drvdata(pdev);
227 227
@@ -236,7 +236,7 @@ static __devexit int wm831x_isink_remove(struct platform_device *pdev)
236 236
237static struct platform_driver wm831x_isink_driver = { 237static struct platform_driver wm831x_isink_driver = {
238 .probe = wm831x_isink_probe, 238 .probe = wm831x_isink_probe,
239 .remove = __devexit_p(wm831x_isink_remove), 239 .remove = wm831x_isink_remove,
240 .driver = { 240 .driver = {
241 .name = "wm831x-isink", 241 .name = "wm831x-isink",
242 .owner = THIS_MODULE, 242 .owner = THIS_MODULE,
diff --git a/drivers/regulator/wm831x-ldo.c b/drivers/regulator/wm831x-ldo.c
index c2dc03993dc..1ec379a9a95 100644
--- a/drivers/regulator/wm831x-ldo.c
+++ b/drivers/regulator/wm831x-ldo.c
@@ -247,7 +247,7 @@ static struct regulator_ops wm831x_gp_ldo_ops = {
247 .disable = regulator_disable_regmap, 247 .disable = regulator_disable_regmap,
248}; 248};
249 249
250static __devinit int wm831x_gp_ldo_probe(struct platform_device *pdev) 250static int wm831x_gp_ldo_probe(struct platform_device *pdev)
251{ 251{
252 struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent); 252 struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent);
253 struct wm831x_pdata *pdata = wm831x->dev->platform_data; 253 struct wm831x_pdata *pdata = wm831x->dev->platform_data;
@@ -334,7 +334,7 @@ err:
334 return ret; 334 return ret;
335} 335}
336 336
337static __devexit int wm831x_gp_ldo_remove(struct platform_device *pdev) 337static int wm831x_gp_ldo_remove(struct platform_device *pdev)
338{ 338{
339 struct wm831x_ldo *ldo = platform_get_drvdata(pdev); 339 struct wm831x_ldo *ldo = platform_get_drvdata(pdev);
340 340
@@ -349,7 +349,7 @@ static __devexit int wm831x_gp_ldo_remove(struct platform_device *pdev)
349 349
350static struct platform_driver wm831x_gp_ldo_driver = { 350static struct platform_driver wm831x_gp_ldo_driver = {
351 .probe = wm831x_gp_ldo_probe, 351 .probe = wm831x_gp_ldo_probe,
352 .remove = __devexit_p(wm831x_gp_ldo_remove), 352 .remove = wm831x_gp_ldo_remove,
353 .driver = { 353 .driver = {
354 .name = "wm831x-ldo", 354 .name = "wm831x-ldo",
355 .owner = THIS_MODULE, 355 .owner = THIS_MODULE,
@@ -504,7 +504,7 @@ static struct regulator_ops wm831x_aldo_ops = {
504 .disable = regulator_disable_regmap, 504 .disable = regulator_disable_regmap,
505}; 505};
506 506
507static __devinit int wm831x_aldo_probe(struct platform_device *pdev) 507static int wm831x_aldo_probe(struct platform_device *pdev)
508{ 508{
509 struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent); 509 struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent);
510 struct wm831x_pdata *pdata = wm831x->dev->platform_data; 510 struct wm831x_pdata *pdata = wm831x->dev->platform_data;
@@ -590,7 +590,7 @@ err:
590 return ret; 590 return ret;
591} 591}
592 592
593static __devexit int wm831x_aldo_remove(struct platform_device *pdev) 593static int wm831x_aldo_remove(struct platform_device *pdev)
594{ 594{
595 struct wm831x_ldo *ldo = platform_get_drvdata(pdev); 595 struct wm831x_ldo *ldo = platform_get_drvdata(pdev);
596 596
@@ -603,7 +603,7 @@ static __devexit int wm831x_aldo_remove(struct platform_device *pdev)
603 603
604static struct platform_driver wm831x_aldo_driver = { 604static struct platform_driver wm831x_aldo_driver = {
605 .probe = wm831x_aldo_probe, 605 .probe = wm831x_aldo_probe,
606 .remove = __devexit_p(wm831x_aldo_remove), 606 .remove = wm831x_aldo_remove,
607 .driver = { 607 .driver = {
608 .name = "wm831x-aldo", 608 .name = "wm831x-aldo",
609 .owner = THIS_MODULE, 609 .owner = THIS_MODULE,
@@ -660,7 +660,7 @@ static struct regulator_ops wm831x_alive_ldo_ops = {
660 .disable = regulator_disable_regmap, 660 .disable = regulator_disable_regmap,
661}; 661};
662 662
663static __devinit int wm831x_alive_ldo_probe(struct platform_device *pdev) 663static int wm831x_alive_ldo_probe(struct platform_device *pdev)
664{ 664{
665 struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent); 665 struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent);
666 struct wm831x_pdata *pdata = wm831x->dev->platform_data; 666 struct wm831x_pdata *pdata = wm831x->dev->platform_data;
@@ -737,7 +737,7 @@ err:
737 return ret; 737 return ret;
738} 738}
739 739
740static __devexit int wm831x_alive_ldo_remove(struct platform_device *pdev) 740static int wm831x_alive_ldo_remove(struct platform_device *pdev)
741{ 741{
742 struct wm831x_ldo *ldo = platform_get_drvdata(pdev); 742 struct wm831x_ldo *ldo = platform_get_drvdata(pdev);
743 743
@@ -748,7 +748,7 @@ static __devexit int wm831x_alive_ldo_remove(struct platform_device *pdev)
748 748
749static struct platform_driver wm831x_alive_ldo_driver = { 749static struct platform_driver wm831x_alive_ldo_driver = {
750 .probe = wm831x_alive_ldo_probe, 750 .probe = wm831x_alive_ldo_probe,
751 .remove = __devexit_p(wm831x_alive_ldo_remove), 751 .remove = wm831x_alive_ldo_remove,
752 .driver = { 752 .driver = {
753 .name = "wm831x-alive-ldo", 753 .name = "wm831x-alive-ldo",
754 .owner = THIS_MODULE, 754 .owner = THIS_MODULE,
diff --git a/drivers/regulator/wm8400-regulator.c b/drivers/regulator/wm8400-regulator.c
index 27c746ef063..c6a32ea80b9 100644
--- a/drivers/regulator/wm8400-regulator.c
+++ b/drivers/regulator/wm8400-regulator.c
@@ -226,7 +226,7 @@ static struct regulator_desc regulators[] = {
226 }, 226 },
227}; 227};
228 228
229static int __devinit wm8400_regulator_probe(struct platform_device *pdev) 229static int wm8400_regulator_probe(struct platform_device *pdev)
230{ 230{
231 struct wm8400 *wm8400 = container_of(pdev, struct wm8400, regulators[pdev->id]); 231 struct wm8400 *wm8400 = container_of(pdev, struct wm8400, regulators[pdev->id]);
232 struct regulator_config config = { }; 232 struct regulator_config config = { };
@@ -246,7 +246,7 @@ static int __devinit wm8400_regulator_probe(struct platform_device *pdev)
246 return 0; 246 return 0;
247} 247}
248 248
249static int __devexit wm8400_regulator_remove(struct platform_device *pdev) 249static int wm8400_regulator_remove(struct platform_device *pdev)
250{ 250{
251 struct regulator_dev *rdev = platform_get_drvdata(pdev); 251 struct regulator_dev *rdev = platform_get_drvdata(pdev);
252 252
@@ -261,7 +261,7 @@ static struct platform_driver wm8400_regulator_driver = {
261 .name = "wm8400-regulator", 261 .name = "wm8400-regulator",
262 }, 262 },
263 .probe = wm8400_regulator_probe, 263 .probe = wm8400_regulator_probe,
264 .remove = __devexit_p(wm8400_regulator_remove), 264 .remove = wm8400_regulator_remove,
265}; 265};
266 266
267/** 267/**
diff --git a/drivers/regulator/wm8994-regulator.c b/drivers/regulator/wm8994-regulator.c
index 86bb48db149..6ff87234264 100644
--- a/drivers/regulator/wm8994-regulator.c
+++ b/drivers/regulator/wm8994-regulator.c
@@ -99,7 +99,7 @@ static const struct regulator_desc wm8994_ldo_desc[] = {
99 }, 99 },
100}; 100};
101 101
102static __devinit int wm8994_ldo_probe(struct platform_device *pdev) 102static int wm8994_ldo_probe(struct platform_device *pdev)
103{ 103{
104 struct wm8994 *wm8994 = dev_get_drvdata(pdev->dev.parent); 104 struct wm8994 *wm8994 = dev_get_drvdata(pdev->dev.parent);
105 struct wm8994_pdata *pdata = wm8994->dev->platform_data; 105 struct wm8994_pdata *pdata = wm8994->dev->platform_data;
@@ -142,7 +142,7 @@ err:
142 return ret; 142 return ret;
143} 143}
144 144
145static __devexit int wm8994_ldo_remove(struct platform_device *pdev) 145static int wm8994_ldo_remove(struct platform_device *pdev)
146{ 146{
147 struct wm8994_ldo *ldo = platform_get_drvdata(pdev); 147 struct wm8994_ldo *ldo = platform_get_drvdata(pdev);
148 148
@@ -155,7 +155,7 @@ static __devexit int wm8994_ldo_remove(struct platform_device *pdev)
155 155
156static struct platform_driver wm8994_ldo_driver = { 156static struct platform_driver wm8994_ldo_driver = {
157 .probe = wm8994_ldo_probe, 157 .probe = wm8994_ldo_probe,
158 .remove = __devexit_p(wm8994_ldo_remove), 158 .remove = wm8994_ldo_remove,
159 .driver = { 159 .driver = {
160 .name = "wm8994-ldo", 160 .name = "wm8994-ldo",
161 .owner = THIS_MODULE, 161 .owner = THIS_MODULE,
diff --git a/include/linux/mfd/tps65090.h b/include/linux/mfd/tps65090.h
index 6bc31d85462..804e280c1e1 100644
--- a/include/linux/mfd/tps65090.h
+++ b/include/linux/mfd/tps65090.h
@@ -24,6 +24,25 @@
24 24
25#include <linux/irq.h> 25#include <linux/irq.h>
26 26
27/* TPS65090 Regulator ID */
28enum {
29 TPS65090_REGULATOR_DCDC1,
30 TPS65090_REGULATOR_DCDC2,
31 TPS65090_REGULATOR_DCDC3,
32 TPS65090_REGULATOR_FET1,
33 TPS65090_REGULATOR_FET2,
34 TPS65090_REGULATOR_FET3,
35 TPS65090_REGULATOR_FET4,
36 TPS65090_REGULATOR_FET5,
37 TPS65090_REGULATOR_FET6,
38 TPS65090_REGULATOR_FET7,
39 TPS65090_REGULATOR_LDO1,
40 TPS65090_REGULATOR_LDO2,
41
42 /* Last entry for maximum ID */
43 TPS65090_REGULATOR_MAX,
44};
45
27struct tps65090 { 46struct tps65090 {
28 struct mutex lock; 47 struct mutex lock;
29 struct device *dev; 48 struct device *dev;
@@ -41,10 +60,26 @@ struct tps65090_subdev_info {
41 void *platform_data; 60 void *platform_data;
42}; 61};
43 62
63/*
64 * struct tps65090_regulator_plat_data
65 *
66 * @reg_init_data: The regulator init data.
67 * @enable_ext_control: Enable extrenal control or not. Only available for
68 * DCDC1, DCDC2 and DCDC3.
69 * @gpio: Gpio number if external control is enabled and controlled through
70 * gpio.
71 */
72struct tps65090_regulator_plat_data {
73 struct regulator_init_data *reg_init_data;
74 bool enable_ext_control;
75 int gpio;
76};
77
44struct tps65090_platform_data { 78struct tps65090_platform_data {
45 int irq_base; 79 int irq_base;
46 int num_subdevs; 80 int num_subdevs;
47 struct tps65090_subdev_info *subdevs; 81 struct tps65090_subdev_info *subdevs;
82 struct tps65090_regulator_plat_data *reg_pdata[TPS65090_REGULATOR_MAX];
48}; 83};
49 84
50/* 85/*
diff --git a/include/linux/mfd/tps6586x.h b/include/linux/mfd/tps6586x.h
index 2dd12319495..f8da0e15256 100644
--- a/include/linux/mfd/tps6586x.h
+++ b/include/linux/mfd/tps6586x.h
@@ -29,6 +29,7 @@ enum {
29 TPS6586X_ID_LDO_8, 29 TPS6586X_ID_LDO_8,
30 TPS6586X_ID_LDO_9, 30 TPS6586X_ID_LDO_9,
31 TPS6586X_ID_LDO_RTC, 31 TPS6586X_ID_LDO_RTC,
32 TPS6586X_ID_MAX_REGULATOR,
32}; 33};
33 34
34enum { 35enum {
@@ -79,6 +80,8 @@ struct tps6586x_platform_data {
79 int gpio_base; 80 int gpio_base;
80 int irq_base; 81 int irq_base;
81 bool pm_off; 82 bool pm_off;
83
84 struct regulator_init_data *reg_init_data[TPS6586X_ID_MAX_REGULATOR];
82}; 85};
83 86
84/* 87/*
diff --git a/include/linux/regulator/driver.h b/include/linux/regulator/driver.h
index 7932a3bf21b..f2b72b230b9 100644
--- a/include/linux/regulator/driver.h
+++ b/include/linux/regulator/driver.h
@@ -181,6 +181,8 @@ enum regulator_type {
181 * @type: Indicates if the regulator is a voltage or current regulator. 181 * @type: Indicates if the regulator is a voltage or current regulator.
182 * @owner: Module providing the regulator, used for refcounting. 182 * @owner: Module providing the regulator, used for refcounting.
183 * 183 *
184 * @continuous_voltage_range: Indicates if the regulator can set any
185 * voltage within constrains range.
184 * @n_voltages: Number of selectors available for ops.list_voltage(). 186 * @n_voltages: Number of selectors available for ops.list_voltage().
185 * 187 *
186 * @min_uV: Voltage given by the lowest selector (if linear mapping) 188 * @min_uV: Voltage given by the lowest selector (if linear mapping)
@@ -199,6 +201,7 @@ struct regulator_desc {
199 const char *name; 201 const char *name;
200 const char *supply_name; 202 const char *supply_name;
201 int id; 203 int id;
204 bool continuous_voltage_range;
202 unsigned n_voltages; 205 unsigned n_voltages;
203 struct regulator_ops *ops; 206 struct regulator_ops *ops;
204 int irq; 207 int irq;
diff --git a/include/linux/regulator/tps51632-regulator.h b/include/linux/regulator/tps51632-regulator.h
new file mode 100644
index 00000000000..d00841e1a75
--- /dev/null
+++ b/include/linux/regulator/tps51632-regulator.h
@@ -0,0 +1,47 @@
1/*
2 * tps51632-regulator.h -- TPS51632 regulator
3 *
4 * Interface for regulator driver for TPS51632 3-2-1 Phase D-Cap Step Down
5 * Driverless Controller with serial VID control and DVFS.
6 *
7 * Copyright (C) 2012 NVIDIA Corporation
8
9 * Author: Laxman Dewangan <ldewangan@nvidia.com>
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful, but WITHOUT
17 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
19 * more details.
20 *
21 * You should have received a copy of the GNU General Public License along
22 * with this program; if not, write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24 *
25 */
26
27#ifndef __LINUX_REGULATOR_TPS51632_H
28#define __LINUX_REGULATOR_TPS51632_H
29
30/*
31 * struct tps51632_regulator_platform_data - tps51632 regulator platform data.
32 *
33 * @reg_init_data: The regulator init data.
34 * @enable_pwm_dvfs: Enable PWM DVFS or not.
35 * @dvfs_step_20mV: Step for DVFS is 20mV or 10mV.
36 * @max_voltage_uV: Maximum possible voltage in PWM-DVFS mode.
37 * @base_voltage_uV: Base voltage when PWM-DVFS enabled.
38 */
39struct tps51632_regulator_platform_data {
40 struct regulator_init_data *reg_init_data;
41 bool enable_pwm_dvfs;
42 bool dvfs_step_20mV;
43 int max_voltage_uV;
44 int base_voltage_uV;
45};
46
47#endif /* __LINUX_REGULATOR_TPS51632_H */
diff --git a/include/linux/regulator/tps65090-regulator.h b/include/linux/regulator/tps65090-regulator.h
deleted file mode 100644
index 0fa04b64db3..00000000000
--- a/include/linux/regulator/tps65090-regulator.h
+++ /dev/null
@@ -1,50 +0,0 @@
1/*
2 * Regulator driver interface for TI TPS65090 PMIC family
3 *
4 * Copyright (c) 2012, NVIDIA CORPORATION. All rights reserved.
5
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
9
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef __REGULATOR_TPS65090_H
20#define __REGULATOR_TPS65090_H
21
22#include <linux/regulator/machine.h>
23
24#define tps65090_rails(_name) "tps65090_"#_name
25
26enum {
27 TPS65090_ID_DCDC1,
28 TPS65090_ID_DCDC2,
29 TPS65090_ID_DCDC3,
30 TPS65090_ID_FET1,
31 TPS65090_ID_FET2,
32 TPS65090_ID_FET3,
33 TPS65090_ID_FET4,
34 TPS65090_ID_FET5,
35 TPS65090_ID_FET6,
36 TPS65090_ID_FET7,
37};
38
39/*
40 * struct tps65090_regulator_platform_data
41 *
42 * @regulator: The regulator init data.
43 * @slew_rate_uV_per_us: Slew rate microvolt per microsec.
44 */
45
46struct tps65090_regulator_platform_data {
47 struct regulator_init_data regulator;
48};
49
50#endif /* __REGULATOR_TPS65090_H */