aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-12-13 15:04:35 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2012-12-13 15:04:35 -0500
commit8b0cab14951fbf8126795ab301835a8f8126a988 (patch)
tree2bf23662944ac9bfcd34d13ef81a6e331266ebf9
parentfd62c5450324af7f6cc12897b09b77285cd48a92 (diff)
parent4ffc45c3604dd8e283884ce006faf0e955cbd9e6 (diff)
Merge tag 'regulator-3.8' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator
Pull regulator updates from Mark Brown: "A fairly quiet release again, a couple of relatively small new features and a bunch of driver specific work including yet more code elimination and fixes from Axel Lin. - Addidion of linear_min_sel for offsetting linear selectors in the helpers. - Support for continuous voltage ranges for regulators with extremely high resolution. - Drivers for AS3711, DA9055, MAX9873, TPS51632, TPS80031 and ARM vexpress." Fix up trivial conflict (due to typo fix) in palmas-regulator.c * tag 'regulator-3.8' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator: (80 commits) regulator: core: Fix logic to determinate if regulator can change voltage regulator: s5m8767: Fix to work even if no DVS gpio present regulator: s5m8767: Fix to read the first DVS register. regulator: s5m8767: Fix to work when platform registers less regulators regulator: gpio-regulator: gpio_set_value should use cansleep regulator: gpio-regulator: Fix logical error in for() loop regulator: anatop: Use regulator_[get|set]_voltage_sel_regmap regulator: anatop: Use linear_min_sel with linear mapping regulator: max1586: Implement get_voltage_sel callback regulator: lp8788-buck: Kill _gpio_request function regulator: tps80031: Convert tps80031_ldo_ops to linear_min_sel and list_voltage_linear regulator: lp8788-ldo: Remove val array in lp8788_config_ldo_enable_mode regulator: gpio-regulator: Add ifdef CONFIG_OF guard for regulator_gpio_of_match regulator: palmas: Convert palmas_ops_smps to regulator_[get|set]_voltage_sel_regmap regulator: palmas: Return raw register values as the selectors in [get|set]_voltage_sel regulators: add regulator_can_change_voltage() function regulator: tps51632: Ensure [base|max]_voltage_uV pdata settings are valid regulator: wm831x-dcdc: Add MODULE_ALIAS for wm831x-boostp regulator: wm831x-dcdc: Ensure selected voltage falls within requested range regulator: tps51632: Use linear_min_sel and regulator_[map|list]_voltage_linear ...
-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/max8997-regulator.txt146
-rw-r--r--Documentation/devicetree/bindings/regulator/vexpress.txt32
-rw-r--r--drivers/mfd/Kconfig1
-rw-r--r--drivers/mfd/max8997.c73
-rw-r--r--drivers/mfd/tps6586x.c76
-rw-r--r--drivers/mfd/wm5102-tables.c3
-rw-r--r--drivers/regulator/88pm8607.c6
-rw-r--r--drivers/regulator/Kconfig54
-rw-r--r--drivers/regulator/Makefile6
-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.c34
-rw-r--r--drivers/regulator/arizona-ldo1.c136
-rw-r--r--drivers/regulator/arizona-micsupp.c8
-rw-r--r--drivers/regulator/as3711-regulator.c369
-rw-r--r--drivers/regulator/core.c42
-rw-r--r--drivers/regulator/da903x.c6
-rw-r--r--drivers/regulator/da9052-regulator.c16
-rw-r--r--drivers/regulator/da9055-regulator.c641
-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.c112
-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.c24
-rw-r--r--drivers/regulator/lp8788-ldo.c25
-rw-r--r--drivers/regulator/max1586.c50
-rw-r--r--drivers/regulator/max77686.c170
-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/max8973-regulator.c505
-rw-r--r--drivers/regulator/max8997.c187
-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.c166
-rw-r--r--drivers/regulator/pcap-regulator.c6
-rw-r--r--drivers/regulator/pcf50633-regulator.c182
-rw-r--r--drivers/regulator/rc5t583-regulator.c6
-rw-r--r--drivers/regulator/s2mps11.c16
-rw-r--r--drivers/regulator/s5m8767.c46
-rw-r--r--drivers/regulator/tps51632-regulator.c342
-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.c254
-rw-r--r--drivers/regulator/tps65217-regulator.c6
-rw-r--r--drivers/regulator/tps6524x-regulator.c4
-rw-r--r--drivers/regulator/tps6586x-regulator.c189
-rw-r--r--drivers/regulator/tps65910-regulator.c13
-rw-r--r--drivers/regulator/tps65912-regulator.c6
-rw-r--r--drivers/regulator/tps80031-regulator.c788
-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.c31
-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/arizona/registers.h16
-rw-r--r--include/linux/mfd/da9055/pdata.h27
-rw-r--r--include/linux/mfd/max8997-private.h1
-rw-r--r--include/linux/mfd/max8997.h1
-rw-r--r--include/linux/mfd/tps65090.h35
-rw-r--r--include/linux/mfd/tps6586x.h3
-rw-r--r--include/linux/regulator/consumer.h13
-rw-r--r--include/linux/regulator/driver.h5
-rw-r--r--include/linux/regulator/max8973-regulator.h72
-rw-r--r--include/linux/regulator/tps51632-regulator.h47
-rw-r--r--include/linux/regulator/tps65090-regulator.h50
85 files changed, 4772 insertions, 775 deletions
diff --git a/Documentation/devicetree/bindings/regulator/gpio-regulator.txt b/Documentation/devicetree/bindings/regulator/gpio-regulator.txt
new file mode 100644
index 000000000000..63c659800c03
--- /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 000000000000..0057695aae8f
--- /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/max8997-regulator.txt b/Documentation/devicetree/bindings/regulator/max8997-regulator.txt
new file mode 100644
index 000000000000..9fd69a18b0ba
--- /dev/null
+++ b/Documentation/devicetree/bindings/regulator/max8997-regulator.txt
@@ -0,0 +1,146 @@
1* Maxim MAX8997 Voltage and Current Regulator
2
3The Maxim MAX8997 is a multi-function device which includes volatage and
4current regulators, rtc, charger controller and other sub-blocks. It is
5interfaced to the host controller using a i2c interface. Each sub-block is
6addressed by the host system using different i2c slave address. This document
7describes the bindings for 'pmic' sub-block of max8997.
8
9Required properties:
10- compatible: Should be "maxim,max8997-pmic".
11- reg: Specifies the i2c slave address of the pmic block. It should be 0x66.
12
13- max8997,pmic-buck1-dvs-voltage: A set of 8 voltage values in micro-volt (uV)
14 units for buck1 when changing voltage using gpio dvs. Refer to [1] below
15 for additional information.
16
17- max8997,pmic-buck2-dvs-voltage: A set of 8 voltage values in micro-volt (uV)
18 units for buck2 when changing voltage using gpio dvs. Refer to [1] below
19 for additional information.
20
21- max8997,pmic-buck5-dvs-voltage: A set of 8 voltage values in micro-volt (uV)
22 units for buck5 when changing voltage using gpio dvs. Refer to [1] below
23 for additional information.
24
25[1] If none of the 'max8997,pmic-buck[1/2/5]-uses-gpio-dvs' optional
26 property is specified, the 'max8997,pmic-buck[1/2/5]-dvs-voltage'
27 property should specify atleast one voltage level (which would be a
28 safe operating voltage).
29
30 If either of the 'max8997,pmic-buck[1/2/5]-uses-gpio-dvs' optional
31 property is specified, then all the eigth voltage values for the
32 'max8997,pmic-buck[1/2/5]-dvs-voltage' should be specified.
33
34Optional properties:
35- interrupt-parent: Specifies the phandle of the interrupt controller to which
36 the interrupts from max8997 are delivered to.
37- interrupts: Interrupt specifiers for two interrupt sources.
38 - First interrupt specifier is for 'irq1' interrupt.
39 - Second interrupt specifier is for 'alert' interrupt.
40- max8997,pmic-buck1-uses-gpio-dvs: 'buck1' can be controlled by gpio dvs.
41- max8997,pmic-buck2-uses-gpio-dvs: 'buck2' can be controlled by gpio dvs.
42- max8997,pmic-buck5-uses-gpio-dvs: 'buck5' can be controlled by gpio dvs.
43
44Additional properties required if either of the optional properties are used:
45- max8997,pmic-ignore-gpiodvs-side-effect: When GPIO-DVS mode is used for
46 multiple bucks, changing the voltage value of one of the bucks may affect
47 that of another buck, which is the side effect of the change (set_voltage).
48 Use this property to ignore such side effects and change the voltage.
49
50- max8997,pmic-buck125-default-dvs-idx: Default voltage setting selected from
51 the possible 8 options selectable by the dvs gpios. The value of this
52 property should be between 0 and 7. If not specified or if out of range, the
53 default value of this property is set to 0.
54
55- max8997,pmic-buck125-dvs-gpios: GPIO specifiers for three host gpio's used
56 for dvs. The format of the gpio specifier depends in the gpio controller.
57
58Regulators: The regulators of max8997 that have to be instantiated should be
59included in a sub-node named 'regulators'. Regulator nodes included in this
60sub-node should be of the format as listed below.
61
62 regulator_name {
63 standard regulator bindings here
64 };
65
66The following are the names of the regulators that the max8997 pmic block
67supports. Note: The 'n' in LDOn and BUCKn represents the LDO or BUCK number
68as per the datasheet of max8997.
69
70 - LDOn
71 - valid values for n are 1 to 18 and 21
72 - Example: LDO0, LD01, LDO2, LDO21
73 - BUCKn
74 - valid values for n are 1 to 7.
75 - Example: BUCK1, BUCK2, BUCK3, BUCK7
76
77 - ENVICHG: Battery Charging Current Monitor Output. This is a fixed
78 voltage type regulator
79
80 - ESAFEOUT1: (ldo19)
81 - ESAFEOUT2: (ld020)
82
83 - CHARGER_CV: main battery charger voltage control
84 - CHARGER: main battery charger current control
85 - CHARGER_TOPOFF: end of charge current threshold level
86
87The bindings inside the regulator nodes use the standard regulator bindings
88which are documented elsewhere.
89
90Example:
91
92 max8997_pmic@66 {
93 compatible = "maxim,max8997-pmic";
94 interrupt-parent = <&wakeup_eint>;
95 reg = <0x66>;
96 interrupts = <4 0>, <3 0>;
97
98 max8997,pmic-buck1-uses-gpio-dvs;
99 max8997,pmic-buck2-uses-gpio-dvs;
100 max8997,pmic-buck5-uses-gpio-dvs;
101
102 max8997,pmic-ignore-gpiodvs-side-effect;
103 max8997,pmic-buck125-default-dvs-idx = <0>;
104
105 max8997,pmic-buck125-dvs-gpios = <&gpx0 0 1 0 0>, /* SET1 */
106 <&gpx0 1 1 0 0>, /* SET2 */
107 <&gpx0 2 1 0 0>; /* SET3 */
108
109 max8997,pmic-buck1-dvs-voltage = <1350000>, <1300000>,
110 <1250000>, <1200000>,
111 <1150000>, <1100000>,
112 <1000000>, <950000>;
113
114 max8997,pmic-buck2-dvs-voltage = <1100000>, <1100000>,
115 <1100000>, <1100000>,
116 <1000000>, <1000000>,
117 <1000000>, <1000000>;
118
119 max8997,pmic-buck5-dvs-voltage = <1200000>, <1200000>,
120 <1200000>, <1200000>,
121 <1200000>, <1200000>,
122 <1200000>, <1200000>;
123
124 regulators {
125 ldo1_reg: LDO1 {
126 regulator-name = "VDD_ABB_3.3V";
127 regulator-min-microvolt = <3300000>;
128 regulator-max-microvolt = <3300000>;
129 };
130
131 ldo2_reg: LDO2 {
132 regulator-name = "VDD_ALIVE_1.1V";
133 regulator-min-microvolt = <1100000>;
134 regulator-max-microvolt = <1100000>;
135 regulator-always-on;
136 };
137
138 buck1_reg: BUCK1 {
139 regulator-name = "VDD_ARM_1.2V";
140 regulator-min-microvolt = <950000>;
141 regulator-max-microvolt = <1350000>;
142 regulator-always-on;
143 regulator-boot-on;
144 };
145 };
146 };
diff --git a/Documentation/devicetree/bindings/regulator/vexpress.txt b/Documentation/devicetree/bindings/regulator/vexpress.txt
new file mode 100644
index 000000000000..d775f72487aa
--- /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 94bdf83b4bc8..b63987c6ed20 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -211,7 +211,6 @@ config MFD_TPS6586X
211 depends on I2C=y && GENERIC_HARDIRQS 211 depends on I2C=y && GENERIC_HARDIRQS
212 select MFD_CORE 212 select MFD_CORE
213 select REGMAP_I2C 213 select REGMAP_I2C
214 depends on REGULATOR
215 help 214 help
216 If you say yes here you get support for the TPS6586X series of 215 If you say yes here you get support for the TPS6586X series of
217 Power Management chips. 216 Power Management chips.
diff --git a/drivers/mfd/max8997.c b/drivers/mfd/max8997.c
index f123517065ec..abd5c80c7cf5 100644
--- a/drivers/mfd/max8997.c
+++ b/drivers/mfd/max8997.c
@@ -21,8 +21,10 @@
21 * This driver is based on max8998.c 21 * This driver is based on max8998.c
22 */ 22 */
23 23
24#include <linux/err.h>
24#include <linux/slab.h> 25#include <linux/slab.h>
25#include <linux/i2c.h> 26#include <linux/i2c.h>
27#include <linux/of_irq.h>
26#include <linux/interrupt.h> 28#include <linux/interrupt.h>
27#include <linux/pm_runtime.h> 29#include <linux/pm_runtime.h>
28#include <linux/module.h> 30#include <linux/module.h>
@@ -47,6 +49,13 @@ static struct mfd_cell max8997_devs[] = {
47 { .name = "max8997-led", .id = 2 }, 49 { .name = "max8997-led", .id = 2 },
48}; 50};
49 51
52#ifdef CONFIG_OF
53static struct of_device_id __devinitdata max8997_pmic_dt_match[] = {
54 { .compatible = "maxim,max8997-pmic", .data = TYPE_MAX8997 },
55 {},
56};
57#endif
58
50int max8997_read_reg(struct i2c_client *i2c, u8 reg, u8 *dest) 59int max8997_read_reg(struct i2c_client *i2c, u8 reg, u8 *dest)
51{ 60{
52 struct max8997_dev *max8997 = i2c_get_clientdata(i2c); 61 struct max8997_dev *max8997 = i2c_get_clientdata(i2c);
@@ -123,6 +132,58 @@ int max8997_update_reg(struct i2c_client *i2c, u8 reg, u8 val, u8 mask)
123} 132}
124EXPORT_SYMBOL_GPL(max8997_update_reg); 133EXPORT_SYMBOL_GPL(max8997_update_reg);
125 134
135#ifdef CONFIG_OF
136/*
137 * Only the common platform data elements for max8997 are parsed here from the
138 * device tree. Other sub-modules of max8997 such as pmic, rtc and others have
139 * to parse their own platform data elements from device tree.
140 *
141 * The max8997 platform data structure is instantiated here and the drivers for
142 * the sub-modules need not instantiate another instance while parsing their
143 * platform data.
144 */
145static struct max8997_platform_data *max8997_i2c_parse_dt_pdata(
146 struct device *dev)
147{
148 struct max8997_platform_data *pd;
149
150 pd = devm_kzalloc(dev, sizeof(*pd), GFP_KERNEL);
151 if (!pd) {
152 dev_err(dev, "could not allocate memory for pdata\n");
153 return ERR_PTR(-ENOMEM);
154 }
155
156 pd->ono = irq_of_parse_and_map(dev->of_node, 1);
157
158 /*
159 * ToDo: the 'wakeup' member in the platform data is more of a linux
160 * specfic information. Hence, there is no binding for that yet and
161 * not parsed here.
162 */
163
164 return pd;
165}
166#else
167static struct max8997_platform_data *max8997_i2c_parse_dt_pdata(
168 struct device *dev)
169{
170 return 0;
171}
172#endif
173
174static inline int max8997_i2c_get_driver_data(struct i2c_client *i2c,
175 const struct i2c_device_id *id)
176{
177#ifdef CONFIG_OF
178 if (i2c->dev.of_node) {
179 const struct of_device_id *match;
180 match = of_match_node(max8997_pmic_dt_match, i2c->dev.of_node);
181 return (int)match->data;
182 }
183#endif
184 return (int)id->driver_data;
185}
186
126static int max8997_i2c_probe(struct i2c_client *i2c, 187static int max8997_i2c_probe(struct i2c_client *i2c,
127 const struct i2c_device_id *id) 188 const struct i2c_device_id *id)
128{ 189{
@@ -137,12 +198,21 @@ static int max8997_i2c_probe(struct i2c_client *i2c,
137 i2c_set_clientdata(i2c, max8997); 198 i2c_set_clientdata(i2c, max8997);
138 max8997->dev = &i2c->dev; 199 max8997->dev = &i2c->dev;
139 max8997->i2c = i2c; 200 max8997->i2c = i2c;
140 max8997->type = id->driver_data; 201 max8997->type = max8997_i2c_get_driver_data(i2c, id);
141 max8997->irq = i2c->irq; 202 max8997->irq = i2c->irq;
142 203
204 if (max8997->dev->of_node) {
205 pdata = max8997_i2c_parse_dt_pdata(max8997->dev);
206 if (IS_ERR(pdata)) {
207 ret = PTR_ERR(pdata);
208 goto err;
209 }
210 }
211
143 if (!pdata) 212 if (!pdata)
144 goto err; 213 goto err;
145 214
215 max8997->pdata = pdata;
146 max8997->ono = pdata->ono; 216 max8997->ono = pdata->ono;
147 217
148 mutex_init(&max8997->iolock); 218 mutex_init(&max8997->iolock);
@@ -434,6 +504,7 @@ static struct i2c_driver max8997_i2c_driver = {
434 .name = "max8997", 504 .name = "max8997",
435 .owner = THIS_MODULE, 505 .owner = THIS_MODULE,
436 .pm = &max8997_pm, 506 .pm = &max8997_pm,
507 .of_match_table = of_match_ptr(max8997_pmic_dt_match),
437 }, 508 },
438 .probe = max8997_i2c_probe, 509 .probe = max8997_i2c_probe,
439 .remove = max8997_i2c_remove, 510 .remove = max8997_i2c_remove,
diff --git a/drivers/mfd/tps6586x.c b/drivers/mfd/tps6586x.c
index 9f92c3b22093..87ba7ada3bbc 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/mfd/wm5102-tables.c b/drivers/mfd/wm5102-tables.c
index 14490cc785d2..3141c4a173a7 100644
--- a/drivers/mfd/wm5102-tables.c
+++ b/drivers/mfd/wm5102-tables.c
@@ -258,6 +258,7 @@ static const struct reg_default wm5102_reg_default[] = {
258 { 0x00000154, 0x0000 }, /* R340 - Rate Estimator 3 */ 258 { 0x00000154, 0x0000 }, /* R340 - Rate Estimator 3 */
259 { 0x00000155, 0x0000 }, /* R341 - Rate Estimator 4 */ 259 { 0x00000155, 0x0000 }, /* R341 - Rate Estimator 4 */
260 { 0x00000156, 0x0000 }, /* R342 - Rate Estimator 5 */ 260 { 0x00000156, 0x0000 }, /* R342 - Rate Estimator 5 */
261 { 0x00000161, 0x0000 }, /* R353 - Dynamic Frequency Scaling 1 */
261 { 0x00000171, 0x0000 }, /* R369 - FLL1 Control 1 */ 262 { 0x00000171, 0x0000 }, /* R369 - FLL1 Control 1 */
262 { 0x00000172, 0x0008 }, /* R370 - FLL1 Control 2 */ 263 { 0x00000172, 0x0008 }, /* R370 - FLL1 Control 2 */
263 { 0x00000173, 0x0018 }, /* R371 - FLL1 Control 3 */ 264 { 0x00000173, 0x0018 }, /* R371 - FLL1 Control 3 */
@@ -1047,6 +1048,7 @@ static bool wm5102_readable_register(struct device *dev, unsigned int reg)
1047 case ARIZONA_RATE_ESTIMATOR_3: 1048 case ARIZONA_RATE_ESTIMATOR_3:
1048 case ARIZONA_RATE_ESTIMATOR_4: 1049 case ARIZONA_RATE_ESTIMATOR_4:
1049 case ARIZONA_RATE_ESTIMATOR_5: 1050 case ARIZONA_RATE_ESTIMATOR_5:
1051 case ARIZONA_DYNAMIC_FREQUENCY_SCALING_1:
1050 case ARIZONA_FLL1_CONTROL_1: 1052 case ARIZONA_FLL1_CONTROL_1:
1051 case ARIZONA_FLL1_CONTROL_2: 1053 case ARIZONA_FLL1_CONTROL_2:
1052 case ARIZONA_FLL1_CONTROL_3: 1054 case ARIZONA_FLL1_CONTROL_3:
@@ -1079,6 +1081,7 @@ static bool wm5102_readable_register(struct device *dev, unsigned int reg)
1079 case ARIZONA_FLL2_GPIO_CLOCK: 1081 case ARIZONA_FLL2_GPIO_CLOCK:
1080 case ARIZONA_MIC_CHARGE_PUMP_1: 1082 case ARIZONA_MIC_CHARGE_PUMP_1:
1081 case ARIZONA_LDO1_CONTROL_1: 1083 case ARIZONA_LDO1_CONTROL_1:
1084 case ARIZONA_LDO1_CONTROL_2:
1082 case ARIZONA_LDO2_CONTROL_1: 1085 case ARIZONA_LDO2_CONTROL_1:
1083 case ARIZONA_MIC_BIAS_CTRL_1: 1086 case ARIZONA_MIC_BIAS_CTRL_1:
1084 case ARIZONA_MIC_BIAS_CTRL_2: 1087 case ARIZONA_MIC_BIAS_CTRL_2:
diff --git a/drivers/regulator/88pm8607.c b/drivers/regulator/88pm8607.c
index 1c5ab0172ea2..2b557119adad 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 67d47b59a66d..551a22b07538 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -109,6 +109,16 @@ config REGULATOR_DA9052
109 This driver supports the voltage regulators of DA9052-BC and 109 This driver supports the voltage regulators of DA9052-BC and
110 DA9053-AA/Bx PMIC. 110 DA9053-AA/Bx PMIC.
111 111
112config REGULATOR_DA9055
113 tristate "Dialog Semiconductor DA9055 regulators"
114 depends on MFD_DA9055
115 help
116 Say y here to support the BUCKs and LDOs regulators found on
117 Dialog Semiconductor DA9055 PMIC.
118
119 This driver can also be built as a module. If so, the module
120 will be called da9055-regulator.
121
112config REGULATOR_FAN53555 122config REGULATOR_FAN53555
113 tristate "Fairchild FAN53555 Regulator" 123 tristate "Fairchild FAN53555 Regulator"
114 depends on I2C 124 depends on I2C
@@ -204,6 +214,16 @@ config REGULATOR_MAX8952
204 via I2C bus. Maxim 8952 has one voltage output and supports 4 DVS 214 via I2C bus. Maxim 8952 has one voltage output and supports 4 DVS
205 modes ranging from 0.77V to 1.40V by 0.01V steps. 215 modes ranging from 0.77V to 1.40V by 0.01V steps.
206 216
217config REGULATOR_MAX8973
218 tristate "Maxim MAX8973 voltage regulator "
219 depends on I2C
220 select REGMAP_I2C
221 help
222 The MAXIM MAX8973 high-efficiency. three phase, DC-DC step-down
223 switching regulator delievers up to 9A of output current. Each
224 phase operates at a 2MHz fixed frequency with a 120 deg shift
225 from the adjacent phase, allowing the use of small magnetic component.
226
207config REGULATOR_MAX8997 227config REGULATOR_MAX8997
208 tristate "Maxim 8997/8966 regulator" 228 tristate "Maxim 8997/8966 regulator"
209 depends on MFD_MAX8997 229 depends on MFD_MAX8997
@@ -335,6 +355,17 @@ config REGULATOR_PALMAS
335 on the muxing. This is handled automatically in the driver by 355 on the muxing. This is handled automatically in the driver by
336 reading the mux info from OTP. 356 reading the mux info from OTP.
337 357
358config REGULATOR_TPS51632
359 tristate "TI TPS51632 Power Regulator"
360 depends on I2C
361 select REGMAP_I2C
362 help
363 This driver supports TPS51632 voltage regulator chip.
364 The TPS51632 is 3-2-1 Phase D-Cap+ Step Down Driverless Controller
365 with Serial VID control and DVFS.
366 The voltage output can be configure through I2C interface or PWM
367 interface.
368
338config REGULATOR_TPS6105X 369config REGULATOR_TPS6105X
339 tristate "TI TPS6105X Power regulators" 370 tristate "TI TPS6105X Power regulators"
340 depends on TPS6105X 371 depends on TPS6105X
@@ -415,6 +446,15 @@ config REGULATOR_TPS65912
415 help 446 help
416 This driver supports TPS65912 voltage regulator chip. 447 This driver supports TPS65912 voltage regulator chip.
417 448
449config REGULATOR_TPS80031
450 tristate "TI TPS80031/TPS80032 power regualtor driver"
451 depends on MFD_TPS80031
452 help
453 TPS80031/ TPS80032 Fully Integrated Power Management with Power
454 Path and Battery Charger. It has 5 configurable step-down
455 converters, 11 general purpose LDOs, VBUS generator and digital
456 output to control regulators.
457
418config REGULATOR_TWL4030 458config REGULATOR_TWL4030
419 bool "TI TWL4030/TWL5030/TWL6030/TPS659x0 PMIC" 459 bool "TI TWL4030/TWL5030/TWL6030/TPS659x0 PMIC"
420 depends on TWL4030_CORE 460 depends on TWL4030_CORE
@@ -422,6 +462,13 @@ config REGULATOR_TWL4030
422 This driver supports the voltage regulators provided by 462 This driver supports the voltage regulators provided by
423 this family of companion chips. 463 this family of companion chips.
424 464
465config REGULATOR_VEXPRESS
466 tristate "Versatile Express regulators"
467 depends on VEXPRESS_CONFIG
468 help
469 This driver provides support for voltage regulators available
470 on the ARM Ltd's Versatile Express platform.
471
425config REGULATOR_WM831X 472config REGULATOR_WM831X
426 tristate "Wolfson Microelectronics WM831x PMIC regulators" 473 tristate "Wolfson Microelectronics WM831x PMIC regulators"
427 depends on MFD_WM831X 474 depends on MFD_WM831X
@@ -450,5 +497,12 @@ config REGULATOR_WM8994
450 This driver provides support for the voltage regulators on the 497 This driver provides support for the voltage regulators on the
451 WM8994 CODEC. 498 WM8994 CODEC.
452 499
500config REGULATOR_AS3711
501 tristate "AS3711 PMIC"
502 depends on MFD_AS3711
503 help
504 This driver provides support for the voltage regulators on the
505 AS3711 PMIC
506
453endif 507endif
454 508
diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile
index e431eed8a878..b802b0c7fb02 100644
--- a/drivers/regulator/Makefile
+++ b/drivers/regulator/Makefile
@@ -16,8 +16,10 @@ obj-$(CONFIG_REGULATOR_AB8500) += ab8500.o
16obj-$(CONFIG_REGULATOR_AD5398) += ad5398.o 16obj-$(CONFIG_REGULATOR_AD5398) += ad5398.o
17obj-$(CONFIG_REGULATOR_ANATOP) += anatop-regulator.o 17obj-$(CONFIG_REGULATOR_ANATOP) += anatop-regulator.o
18obj-$(CONFIG_REGULATOR_ARIZONA) += arizona-micsupp.o arizona-ldo1.o 18obj-$(CONFIG_REGULATOR_ARIZONA) += arizona-micsupp.o arizona-ldo1.o
19obj-$(CONFIG_REGULATOR_AS3711) += as3711-regulator.o
19obj-$(CONFIG_REGULATOR_DA903X) += da903x.o 20obj-$(CONFIG_REGULATOR_DA903X) += da903x.o
20obj-$(CONFIG_REGULATOR_DA9052) += da9052-regulator.o 21obj-$(CONFIG_REGULATOR_DA9052) += da9052-regulator.o
22obj-$(CONFIG_REGULATOR_DA9055) += da9055-regulator.o
21obj-$(CONFIG_REGULATOR_DBX500_PRCMU) += dbx500-prcmu.o 23obj-$(CONFIG_REGULATOR_DBX500_PRCMU) += dbx500-prcmu.o
22obj-$(CONFIG_REGULATOR_DB8500_PRCMU) += db8500-prcmu.o 24obj-$(CONFIG_REGULATOR_DB8500_PRCMU) += db8500-prcmu.o
23obj-$(CONFIG_REGULATOR_FAN53555) += fan53555.o 25obj-$(CONFIG_REGULATOR_FAN53555) += fan53555.o
@@ -34,6 +36,7 @@ obj-$(CONFIG_REGULATOR_MAX8660) += max8660.o
34obj-$(CONFIG_REGULATOR_MAX8907) += max8907-regulator.o 36obj-$(CONFIG_REGULATOR_MAX8907) += max8907-regulator.o
35obj-$(CONFIG_REGULATOR_MAX8925) += max8925-regulator.o 37obj-$(CONFIG_REGULATOR_MAX8925) += max8925-regulator.o
36obj-$(CONFIG_REGULATOR_MAX8952) += max8952.o 38obj-$(CONFIG_REGULATOR_MAX8952) += max8952.o
39obj-$(CONFIG_REGULATOR_MAX8973) += max8973-regulator.o
37obj-$(CONFIG_REGULATOR_MAX8997) += max8997.o 40obj-$(CONFIG_REGULATOR_MAX8997) += max8997.o
38obj-$(CONFIG_REGULATOR_MAX8998) += max8998.o 41obj-$(CONFIG_REGULATOR_MAX8998) += max8998.o
39obj-$(CONFIG_REGULATOR_MAX77686) += max77686.o 42obj-$(CONFIG_REGULATOR_MAX77686) += max77686.o
@@ -41,6 +44,7 @@ obj-$(CONFIG_REGULATOR_MC13783) += mc13783-regulator.o
41obj-$(CONFIG_REGULATOR_MC13892) += mc13892-regulator.o 44obj-$(CONFIG_REGULATOR_MC13892) += mc13892-regulator.o
42obj-$(CONFIG_REGULATOR_MC13XXX_CORE) += mc13xxx-regulator-core.o 45obj-$(CONFIG_REGULATOR_MC13XXX_CORE) += mc13xxx-regulator-core.o
43obj-$(CONFIG_REGULATOR_PALMAS) += palmas-regulator.o 46obj-$(CONFIG_REGULATOR_PALMAS) += palmas-regulator.o
47obj-$(CONFIG_REGULATOR_TPS51632) += tps51632-regulator.o
44obj-$(CONFIG_REGULATOR_PCAP) += pcap-regulator.o 48obj-$(CONFIG_REGULATOR_PCAP) += pcap-regulator.o
45obj-$(CONFIG_REGULATOR_PCF50633) += pcf50633-regulator.o 49obj-$(CONFIG_REGULATOR_PCF50633) += pcf50633-regulator.o
46obj-$(CONFIG_REGULATOR_RC5T583) += rc5t583-regulator.o 50obj-$(CONFIG_REGULATOR_RC5T583) += rc5t583-regulator.o
@@ -56,7 +60,9 @@ obj-$(CONFIG_REGULATOR_TPS6524X) += tps6524x-regulator.o
56obj-$(CONFIG_REGULATOR_TPS6586X) += tps6586x-regulator.o 60obj-$(CONFIG_REGULATOR_TPS6586X) += tps6586x-regulator.o
57obj-$(CONFIG_REGULATOR_TPS65910) += tps65910-regulator.o 61obj-$(CONFIG_REGULATOR_TPS65910) += tps65910-regulator.o
58obj-$(CONFIG_REGULATOR_TPS65912) += tps65912-regulator.o 62obj-$(CONFIG_REGULATOR_TPS65912) += tps65912-regulator.o
63obj-$(CONFIG_REGULATOR_TPS80031) += tps80031-regulator.o
59obj-$(CONFIG_REGULATOR_TWL4030) += twl-regulator.o 64obj-$(CONFIG_REGULATOR_TWL4030) += twl-regulator.o
65obj-$(CONFIG_REGULATOR_VEXPRESS) += vexpress.o
60obj-$(CONFIG_REGULATOR_WM831X) += wm831x-dcdc.o 66obj-$(CONFIG_REGULATOR_WM831X) += wm831x-dcdc.o
61obj-$(CONFIG_REGULATOR_WM831X) += wm831x-isink.o 67obj-$(CONFIG_REGULATOR_WM831X) += wm831x-isink.o
62obj-$(CONFIG_REGULATOR_WM831X) += wm831x-ldo.o 68obj-$(CONFIG_REGULATOR_WM831X) += wm831x-ldo.o
diff --git a/drivers/regulator/aat2870-regulator.c b/drivers/regulator/aat2870-regulator.c
index 167c93f21981..8b5876356db9 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 df4ad8927f0c..111ec69a3e94 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 e3d1d063025a..09014f38a948 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 f123f7e3b752..6b981b5faa70 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 1af97686f444..0199eeea63b1 100644
--- a/drivers/regulator/anatop-regulator.c
+++ b/drivers/regulator/anatop-regulator.c
@@ -48,36 +48,21 @@ static int anatop_regmap_set_voltage_sel(struct regulator_dev *reg,
48 unsigned selector) 48 unsigned selector)
49{ 49{
50 struct anatop_regulator *anatop_reg = rdev_get_drvdata(reg); 50 struct anatop_regulator *anatop_reg = rdev_get_drvdata(reg);
51 u32 val, mask;
52 51
53 if (!anatop_reg->control_reg) 52 if (!anatop_reg->control_reg)
54 return -ENOTSUPP; 53 return -ENOTSUPP;
55 54
56 val = anatop_reg->min_bit_val + selector; 55 return regulator_set_voltage_sel_regmap(reg, selector);
57 dev_dbg(&reg->dev, "%s: calculated val %d\n", __func__, val);
58 mask = ((1 << anatop_reg->vol_bit_width) - 1) <<
59 anatop_reg->vol_bit_shift;
60 val <<= anatop_reg->vol_bit_shift;
61 regmap_update_bits(anatop_reg->anatop, anatop_reg->control_reg,
62 mask, val);
63
64 return 0;
65} 56}
66 57
67static int anatop_regmap_get_voltage_sel(struct regulator_dev *reg) 58static int anatop_regmap_get_voltage_sel(struct regulator_dev *reg)
68{ 59{
69 struct anatop_regulator *anatop_reg = rdev_get_drvdata(reg); 60 struct anatop_regulator *anatop_reg = rdev_get_drvdata(reg);
70 u32 val, mask;
71 61
72 if (!anatop_reg->control_reg) 62 if (!anatop_reg->control_reg)
73 return -ENOTSUPP; 63 return -ENOTSUPP;
74 64
75 regmap_read(anatop_reg->anatop, anatop_reg->control_reg, &val); 65 return regulator_get_voltage_sel_regmap(reg);
76 mask = ((1 << anatop_reg->vol_bit_width) - 1) <<
77 anatop_reg->vol_bit_shift;
78 val = (val & mask) >> anatop_reg->vol_bit_shift;
79
80 return val - anatop_reg->min_bit_val;
81} 66}
82 67
83static struct regulator_ops anatop_rops = { 68static struct regulator_ops anatop_rops = {
@@ -87,7 +72,7 @@ static struct regulator_ops anatop_rops = {
87 .map_voltage = regulator_map_voltage_linear, 72 .map_voltage = regulator_map_voltage_linear,
88}; 73};
89 74
90static int __devinit anatop_regulator_probe(struct platform_device *pdev) 75static int anatop_regulator_probe(struct platform_device *pdev)
91{ 76{
92 struct device *dev = &pdev->dev; 77 struct device *dev = &pdev->dev;
93 struct device_node *np = dev->of_node; 78 struct device_node *np = dev->of_node;
@@ -158,15 +143,20 @@ static int __devinit anatop_regulator_probe(struct platform_device *pdev)
158 goto anatop_probe_end; 143 goto anatop_probe_end;
159 } 144 }
160 145
161 rdesc->n_voltages = (sreg->max_voltage - sreg->min_voltage) 146 rdesc->n_voltages = (sreg->max_voltage - sreg->min_voltage) / 25000 + 1
162 / 25000 + 1; 147 + sreg->min_bit_val;
163 rdesc->min_uV = sreg->min_voltage; 148 rdesc->min_uV = sreg->min_voltage;
164 rdesc->uV_step = 25000; 149 rdesc->uV_step = 25000;
150 rdesc->linear_min_sel = sreg->min_bit_val;
151 rdesc->vsel_reg = sreg->control_reg;
152 rdesc->vsel_mask = ((1 << sreg->vol_bit_width) - 1) <<
153 sreg->vol_bit_shift;
165 154
166 config.dev = &pdev->dev; 155 config.dev = &pdev->dev;
167 config.init_data = initdata; 156 config.init_data = initdata;
168 config.driver_data = sreg; 157 config.driver_data = sreg;
169 config.of_node = pdev->dev.of_node; 158 config.of_node = pdev->dev.of_node;
159 config.regmap = sreg->anatop;
170 160
171 /* register regulator */ 161 /* register regulator */
172 rdev = regulator_register(rdesc, &config); 162 rdev = regulator_register(rdesc, &config);
@@ -186,7 +176,7 @@ anatop_probe_end:
186 return ret; 176 return ret;
187} 177}
188 178
189static int __devexit anatop_regulator_remove(struct platform_device *pdev) 179static int anatop_regulator_remove(struct platform_device *pdev)
190{ 180{
191 struct regulator_dev *rdev = platform_get_drvdata(pdev); 181 struct regulator_dev *rdev = platform_get_drvdata(pdev);
192 struct anatop_regulator *sreg = rdev_get_drvdata(rdev); 182 struct anatop_regulator *sreg = rdev_get_drvdata(rdev);
@@ -210,7 +200,7 @@ static struct platform_driver anatop_regulator_driver = {
210 .of_match_table = of_anatop_regulator_match_tbl, 200 .of_match_table = of_anatop_regulator_match_tbl,
211 }, 201 },
212 .probe = anatop_regulator_probe, 202 .probe = anatop_regulator_probe,
213 .remove = __devexit_p(anatop_regulator_remove), 203 .remove = anatop_regulator_remove,
214}; 204};
215 205
216static int __init anatop_regulator_init(void) 206static int __init anatop_regulator_init(void)
diff --git a/drivers/regulator/arizona-ldo1.c b/drivers/regulator/arizona-ldo1.c
index d184aa35abcb..ed7beec53af8 100644
--- a/drivers/regulator/arizona-ldo1.c
+++ b/drivers/regulator/arizona-ldo1.c
@@ -34,6 +34,108 @@ struct arizona_ldo1 {
34 struct regulator_init_data init_data; 34 struct regulator_init_data init_data;
35}; 35};
36 36
37static int arizona_ldo1_hc_list_voltage(struct regulator_dev *rdev,
38 unsigned int selector)
39{
40 if (selector >= rdev->desc->n_voltages)
41 return -EINVAL;
42
43 if (selector == rdev->desc->n_voltages - 1)
44 return 1800000;
45 else
46 return rdev->desc->min_uV + (rdev->desc->uV_step * selector);
47}
48
49static int arizona_ldo1_hc_map_voltage(struct regulator_dev *rdev,
50 int min_uV, int max_uV)
51{
52 int sel;
53
54 sel = DIV_ROUND_UP(min_uV - rdev->desc->min_uV, rdev->desc->uV_step);
55 if (sel >= rdev->desc->n_voltages)
56 sel = rdev->desc->n_voltages - 1;
57
58 return sel;
59}
60
61static int arizona_ldo1_hc_set_voltage_sel(struct regulator_dev *rdev,
62 unsigned sel)
63{
64 struct arizona_ldo1 *ldo = rdev_get_drvdata(rdev);
65 struct regmap *regmap = ldo->arizona->regmap;
66 unsigned int val;
67 int ret;
68
69 if (sel == rdev->desc->n_voltages - 1)
70 val = ARIZONA_LDO1_HI_PWR;
71 else
72 val = 0;
73
74 ret = regmap_update_bits(regmap, ARIZONA_LDO1_CONTROL_2,
75 ARIZONA_LDO1_HI_PWR, val);
76 if (ret != 0)
77 return ret;
78
79 ret = regmap_update_bits(regmap, ARIZONA_DYNAMIC_FREQUENCY_SCALING_1,
80 ARIZONA_SUBSYS_MAX_FREQ, val);
81 if (ret != 0)
82 return ret;
83
84 if (val)
85 return 0;
86
87 val = sel << ARIZONA_LDO1_VSEL_SHIFT;
88
89 return regmap_update_bits(regmap, ARIZONA_LDO1_CONTROL_1,
90 ARIZONA_LDO1_VSEL_MASK, val);
91}
92
93static int arizona_ldo1_hc_get_voltage_sel(struct regulator_dev *rdev)
94{
95 struct arizona_ldo1 *ldo = rdev_get_drvdata(rdev);
96 struct regmap *regmap = ldo->arizona->regmap;
97 unsigned int val;
98 int ret;
99
100 ret = regmap_read(regmap, ARIZONA_LDO1_CONTROL_2, &val);
101 if (ret != 0)
102 return ret;
103
104 if (val & ARIZONA_LDO1_HI_PWR)
105 return rdev->desc->n_voltages - 1;
106
107 ret = regmap_read(regmap, ARIZONA_LDO1_CONTROL_1, &val);
108 if (ret != 0)
109 return ret;
110
111 return (val & ARIZONA_LDO1_VSEL_MASK) >> ARIZONA_LDO1_VSEL_SHIFT;
112}
113
114static struct regulator_ops arizona_ldo1_hc_ops = {
115 .list_voltage = arizona_ldo1_hc_list_voltage,
116 .map_voltage = arizona_ldo1_hc_map_voltage,
117 .get_voltage_sel = arizona_ldo1_hc_get_voltage_sel,
118 .set_voltage_sel = arizona_ldo1_hc_set_voltage_sel,
119 .get_bypass = regulator_get_bypass_regmap,
120 .set_bypass = regulator_set_bypass_regmap,
121};
122
123static const struct regulator_desc arizona_ldo1_hc = {
124 .name = "LDO1",
125 .supply_name = "LDOVDD",
126 .type = REGULATOR_VOLTAGE,
127 .ops = &arizona_ldo1_hc_ops,
128
129 .bypass_reg = ARIZONA_LDO1_CONTROL_1,
130 .bypass_mask = ARIZONA_LDO1_BYPASS,
131 .min_uV = 900000,
132 .uV_step = 50000,
133 .n_voltages = 8,
134 .enable_time = 500,
135
136 .owner = THIS_MODULE,
137};
138
37static struct regulator_ops arizona_ldo1_ops = { 139static struct regulator_ops arizona_ldo1_ops = {
38 .list_voltage = regulator_list_voltage_linear, 140 .list_voltage = regulator_list_voltage_linear,
39 .map_voltage = regulator_map_voltage_linear, 141 .map_voltage = regulator_map_voltage_linear,
@@ -55,11 +157,22 @@ static const struct regulator_desc arizona_ldo1 = {
55 .bypass_mask = ARIZONA_LDO1_BYPASS, 157 .bypass_mask = ARIZONA_LDO1_BYPASS,
56 .min_uV = 900000, 158 .min_uV = 900000,
57 .uV_step = 50000, 159 .uV_step = 50000,
58 .n_voltages = 6, 160 .n_voltages = 7,
161 .enable_time = 500,
59 162
60 .owner = THIS_MODULE, 163 .owner = THIS_MODULE,
61}; 164};
62 165
166static const struct regulator_init_data arizona_ldo1_dvfs = {
167 .constraints = {
168 .min_uV = 1200000,
169 .max_uV = 1800000,
170 .valid_ops_mask = REGULATOR_CHANGE_STATUS |
171 REGULATOR_CHANGE_VOLTAGE,
172 },
173 .num_consumer_supplies = 1,
174};
175
63static const struct regulator_init_data arizona_ldo1_default = { 176static const struct regulator_init_data arizona_ldo1_default = {
64 .constraints = { 177 .constraints = {
65 .valid_ops_mask = REGULATOR_CHANGE_STATUS, 178 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
@@ -67,9 +180,10 @@ static const struct regulator_init_data arizona_ldo1_default = {
67 .num_consumer_supplies = 1, 180 .num_consumer_supplies = 1,
68}; 181};
69 182
70static __devinit int arizona_ldo1_probe(struct platform_device *pdev) 183static int arizona_ldo1_probe(struct platform_device *pdev)
71{ 184{
72 struct arizona *arizona = dev_get_drvdata(pdev->dev.parent); 185 struct arizona *arizona = dev_get_drvdata(pdev->dev.parent);
186 const struct regulator_desc *desc;
73 struct regulator_config config = { }; 187 struct regulator_config config = { };
74 struct arizona_ldo1 *ldo1; 188 struct arizona_ldo1 *ldo1;
75 int ret; 189 int ret;
@@ -87,7 +201,17 @@ static __devinit int arizona_ldo1_probe(struct platform_device *pdev)
87 * default init_data for it. This will be overridden with 201 * default init_data for it. This will be overridden with
88 * platform data if provided. 202 * platform data if provided.
89 */ 203 */
90 ldo1->init_data = arizona_ldo1_default; 204 switch (arizona->type) {
205 case WM5102:
206 desc = &arizona_ldo1_hc;
207 ldo1->init_data = arizona_ldo1_dvfs;
208 break;
209 default:
210 desc = &arizona_ldo1;
211 ldo1->init_data = arizona_ldo1_default;
212 break;
213 }
214
91 ldo1->init_data.consumer_supplies = &ldo1->supply; 215 ldo1->init_data.consumer_supplies = &ldo1->supply;
92 ldo1->supply.supply = "DCVDD"; 216 ldo1->supply.supply = "DCVDD";
93 ldo1->supply.dev_name = dev_name(arizona->dev); 217 ldo1->supply.dev_name = dev_name(arizona->dev);
@@ -102,7 +226,7 @@ static __devinit int arizona_ldo1_probe(struct platform_device *pdev)
102 else 226 else
103 config.init_data = &ldo1->init_data; 227 config.init_data = &ldo1->init_data;
104 228
105 ldo1->regulator = regulator_register(&arizona_ldo1, &config); 229 ldo1->regulator = regulator_register(desc, &config);
106 if (IS_ERR(ldo1->regulator)) { 230 if (IS_ERR(ldo1->regulator)) {
107 ret = PTR_ERR(ldo1->regulator); 231 ret = PTR_ERR(ldo1->regulator);
108 dev_err(arizona->dev, "Failed to register LDO1 supply: %d\n", 232 dev_err(arizona->dev, "Failed to register LDO1 supply: %d\n",
@@ -115,7 +239,7 @@ static __devinit int arizona_ldo1_probe(struct platform_device *pdev)
115 return 0; 239 return 0;
116} 240}
117 241
118static __devexit int arizona_ldo1_remove(struct platform_device *pdev) 242static int arizona_ldo1_remove(struct platform_device *pdev)
119{ 243{
120 struct arizona_ldo1 *ldo1 = platform_get_drvdata(pdev); 244 struct arizona_ldo1 *ldo1 = platform_get_drvdata(pdev);
121 245
@@ -126,7 +250,7 @@ static __devexit int arizona_ldo1_remove(struct platform_device *pdev)
126 250
127static struct platform_driver arizona_ldo1_driver = { 251static struct platform_driver arizona_ldo1_driver = {
128 .probe = arizona_ldo1_probe, 252 .probe = arizona_ldo1_probe,
129 .remove = __devexit_p(arizona_ldo1_remove), 253 .remove = arizona_ldo1_remove,
130 .driver = { 254 .driver = {
131 .name = "arizona-ldo1", 255 .name = "arizona-ldo1",
132 .owner = THIS_MODULE, 256 .owner = THIS_MODULE,
diff --git a/drivers/regulator/arizona-micsupp.c b/drivers/regulator/arizona-micsupp.c
index d9b1f82cc5bd..a6d040cbf8ac 100644
--- a/drivers/regulator/arizona-micsupp.c
+++ b/drivers/regulator/arizona-micsupp.c
@@ -101,6 +101,8 @@ static const struct regulator_desc arizona_micsupp = {
101 .bypass_reg = ARIZONA_MIC_CHARGE_PUMP_1, 101 .bypass_reg = ARIZONA_MIC_CHARGE_PUMP_1,
102 .bypass_mask = ARIZONA_CPMIC_BYPASS, 102 .bypass_mask = ARIZONA_CPMIC_BYPASS,
103 103
104 .enable_time = 3000,
105
104 .owner = THIS_MODULE, 106 .owner = THIS_MODULE,
105}; 107};
106 108
@@ -115,7 +117,7 @@ static const struct regulator_init_data arizona_micsupp_default = {
115 .num_consumer_supplies = 1, 117 .num_consumer_supplies = 1,
116}; 118};
117 119
118static __devinit int arizona_micsupp_probe(struct platform_device *pdev) 120static int arizona_micsupp_probe(struct platform_device *pdev)
119{ 121{
120 struct arizona *arizona = dev_get_drvdata(pdev->dev.parent); 122 struct arizona *arizona = dev_get_drvdata(pdev->dev.parent);
121 struct regulator_config config = { }; 123 struct regulator_config config = { };
@@ -166,7 +168,7 @@ static __devinit int arizona_micsupp_probe(struct platform_device *pdev)
166 return 0; 168 return 0;
167} 169}
168 170
169static __devexit int arizona_micsupp_remove(struct platform_device *pdev) 171static int arizona_micsupp_remove(struct platform_device *pdev)
170{ 172{
171 struct arizona_micsupp *micsupp = platform_get_drvdata(pdev); 173 struct arizona_micsupp *micsupp = platform_get_drvdata(pdev);
172 174
@@ -177,7 +179,7 @@ static __devexit int arizona_micsupp_remove(struct platform_device *pdev)
177 179
178static struct platform_driver arizona_micsupp_driver = { 180static struct platform_driver arizona_micsupp_driver = {
179 .probe = arizona_micsupp_probe, 181 .probe = arizona_micsupp_probe,
180 .remove = __devexit_p(arizona_micsupp_remove), 182 .remove = arizona_micsupp_remove,
181 .driver = { 183 .driver = {
182 .name = "arizona-micsupp", 184 .name = "arizona-micsupp",
183 .owner = THIS_MODULE, 185 .owner = THIS_MODULE,
diff --git a/drivers/regulator/as3711-regulator.c b/drivers/regulator/as3711-regulator.c
new file mode 100644
index 000000000000..2f1341db38a0
--- /dev/null
+++ b/drivers/regulator/as3711-regulator.c
@@ -0,0 +1,369 @@
1/*
2 * AS3711 PMIC regulator driver, using DCDC Step Down and LDO supplies
3 *
4 * Copyright (C) 2012 Renesas Electronics Corporation
5 * Author: Guennadi Liakhovetski, <g.liakhovetski@gmx.de>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the version 2 of the GNU General Public License as
9 * published by the Free Software Foundation
10 */
11
12#include <linux/err.h>
13#include <linux/init.h>
14#include <linux/mfd/as3711.h>
15#include <linux/module.h>
16#include <linux/platform_device.h>
17#include <linux/regmap.h>
18#include <linux/regulator/driver.h>
19#include <linux/slab.h>
20
21struct as3711_regulator_info {
22 struct regulator_desc desc;
23 unsigned int max_uV;
24};
25
26struct as3711_regulator {
27 struct as3711_regulator_info *reg_info;
28 struct regulator_dev *rdev;
29};
30
31static int as3711_list_voltage_sd(struct regulator_dev *rdev,
32 unsigned int selector)
33{
34 if (selector >= rdev->desc->n_voltages)
35 return -EINVAL;
36
37 if (!selector)
38 return 0;
39 if (selector < 0x41)
40 return 600000 + selector * 12500;
41 if (selector < 0x71)
42 return 1400000 + (selector - 0x40) * 25000;
43 return 2600000 + (selector - 0x70) * 50000;
44}
45
46static int as3711_list_voltage_aldo(struct regulator_dev *rdev,
47 unsigned int selector)
48{
49 if (selector >= rdev->desc->n_voltages)
50 return -EINVAL;
51
52 if (selector < 0x10)
53 return 1200000 + selector * 50000;
54 return 1800000 + (selector - 0x10) * 100000;
55}
56
57static int as3711_list_voltage_dldo(struct regulator_dev *rdev,
58 unsigned int selector)
59{
60 if (selector >= rdev->desc->n_voltages ||
61 (selector > 0x10 && selector < 0x20))
62 return -EINVAL;
63
64 if (selector < 0x11)
65 return 900000 + selector * 50000;
66 return 1750000 + (selector - 0x20) * 50000;
67}
68
69static int as3711_bound_check(struct regulator_dev *rdev,
70 int *min_uV, int *max_uV)
71{
72 struct as3711_regulator *reg = rdev_get_drvdata(rdev);
73 struct as3711_regulator_info *info = reg->reg_info;
74
75 dev_dbg(&rdev->dev, "%s(), %d, %d, %d\n", __func__,
76 *min_uV, rdev->desc->min_uV, info->max_uV);
77
78 if (*max_uV < *min_uV ||
79 *min_uV > info->max_uV || rdev->desc->min_uV > *max_uV)
80 return -EINVAL;
81
82 if (rdev->desc->n_voltages == 1)
83 return 0;
84
85 if (*max_uV > info->max_uV)
86 *max_uV = info->max_uV;
87
88 if (*min_uV < rdev->desc->min_uV)
89 *min_uV = rdev->desc->min_uV;
90
91 return *min_uV;
92}
93
94static int as3711_sel_check(int min, int max, int bottom, int step)
95{
96 int sel, voltage;
97
98 /* Round up min, when dividing: keeps us within the range */
99 sel = DIV_ROUND_UP(min - bottom, step);
100 voltage = sel * step + bottom;
101 pr_debug("%s(): select %d..%d in %d+N*%d: %d\n", __func__,
102 min, max, bottom, step, sel);
103 if (voltage > max)
104 return -EINVAL;
105
106 return sel;
107}
108
109static int as3711_map_voltage_sd(struct regulator_dev *rdev,
110 int min_uV, int max_uV)
111{
112 int ret;
113
114 ret = as3711_bound_check(rdev, &min_uV, &max_uV);
115 if (ret <= 0)
116 return ret;
117
118 if (min_uV <= 1400000)
119 return as3711_sel_check(min_uV, max_uV, 600000, 12500);
120
121 if (min_uV <= 2600000)
122 return as3711_sel_check(min_uV, max_uV, 1400000, 25000) + 0x40;
123
124 return as3711_sel_check(min_uV, max_uV, 2600000, 50000) + 0x70;
125}
126
127/*
128 * The regulator API supports 4 modes of operataion: FAST, NORMAL, IDLE and
129 * STANDBY. We map them in the following way to AS3711 SD1-4 DCDC modes:
130 * FAST: sdX_fast=1
131 * NORMAL: low_noise=1
132 * IDLE: low_noise=0
133 */
134
135static int as3711_set_mode_sd(struct regulator_dev *rdev, unsigned int mode)
136{
137 unsigned int fast_bit = rdev->desc->enable_mask,
138 low_noise_bit = fast_bit << 4;
139 u8 val;
140
141 switch (mode) {
142 case REGULATOR_MODE_FAST:
143 val = fast_bit | low_noise_bit;
144 break;
145 case REGULATOR_MODE_NORMAL:
146 val = low_noise_bit;
147 break;
148 case REGULATOR_MODE_IDLE:
149 val = 0;
150 break;
151 default:
152 return -EINVAL;
153 }
154
155 return regmap_update_bits(rdev->regmap, AS3711_SD_CONTROL_1,
156 low_noise_bit | fast_bit, val);
157}
158
159static unsigned int as3711_get_mode_sd(struct regulator_dev *rdev)
160{
161 unsigned int fast_bit = rdev->desc->enable_mask,
162 low_noise_bit = fast_bit << 4, mask = fast_bit | low_noise_bit;
163 unsigned int val;
164 int ret = regmap_read(rdev->regmap, AS3711_SD_CONTROL_1, &val);
165
166 if (ret < 0)
167 return ret;
168
169 if ((val & mask) == mask)
170 return REGULATOR_MODE_FAST;
171
172 if ((val & mask) == low_noise_bit)
173 return REGULATOR_MODE_NORMAL;
174
175 if (!(val & mask))
176 return REGULATOR_MODE_IDLE;
177
178 return -EINVAL;
179}
180
181static int as3711_map_voltage_aldo(struct regulator_dev *rdev,
182 int min_uV, int max_uV)
183{
184 int ret;
185
186 ret = as3711_bound_check(rdev, &min_uV, &max_uV);
187 if (ret <= 0)
188 return ret;
189
190 if (min_uV <= 1800000)
191 return as3711_sel_check(min_uV, max_uV, 1200000, 50000);
192
193 return as3711_sel_check(min_uV, max_uV, 1800000, 100000) + 0x10;
194}
195
196static int as3711_map_voltage_dldo(struct regulator_dev *rdev,
197 int min_uV, int max_uV)
198{
199 int ret;
200
201 ret = as3711_bound_check(rdev, &min_uV, &max_uV);
202 if (ret <= 0)
203 return ret;
204
205 if (min_uV <= 1700000)
206 return as3711_sel_check(min_uV, max_uV, 900000, 50000);
207
208 return as3711_sel_check(min_uV, max_uV, 1750000, 50000) + 0x20;
209}
210
211static struct regulator_ops as3711_sd_ops = {
212 .is_enabled = regulator_is_enabled_regmap,
213 .enable = regulator_enable_regmap,
214 .disable = regulator_disable_regmap,
215 .get_voltage_sel = regulator_get_voltage_sel_regmap,
216 .set_voltage_sel = regulator_set_voltage_sel_regmap,
217 .list_voltage = as3711_list_voltage_sd,
218 .map_voltage = as3711_map_voltage_sd,
219 .get_mode = as3711_get_mode_sd,
220 .set_mode = as3711_set_mode_sd,
221};
222
223static struct regulator_ops as3711_aldo_ops = {
224 .is_enabled = regulator_is_enabled_regmap,
225 .enable = regulator_enable_regmap,
226 .disable = regulator_disable_regmap,
227 .get_voltage_sel = regulator_get_voltage_sel_regmap,
228 .set_voltage_sel = regulator_set_voltage_sel_regmap,
229 .list_voltage = as3711_list_voltage_aldo,
230 .map_voltage = as3711_map_voltage_aldo,
231};
232
233static struct regulator_ops as3711_dldo_ops = {
234 .is_enabled = regulator_is_enabled_regmap,
235 .enable = regulator_enable_regmap,
236 .disable = regulator_disable_regmap,
237 .get_voltage_sel = regulator_get_voltage_sel_regmap,
238 .set_voltage_sel = regulator_set_voltage_sel_regmap,
239 .list_voltage = as3711_list_voltage_dldo,
240 .map_voltage = as3711_map_voltage_dldo,
241};
242
243#define AS3711_REG(_id, _en_reg, _en_bit, _vmask, _vshift, _min_uV, _max_uV, _sfx) \
244 [AS3711_REGULATOR_ ## _id] = { \
245 .desc = { \
246 .name = "as3711-regulator-" # _id, \
247 .id = AS3711_REGULATOR_ ## _id, \
248 .n_voltages = (_vmask + 1), \
249 .ops = &as3711_ ## _sfx ## _ops, \
250 .type = REGULATOR_VOLTAGE, \
251 .owner = THIS_MODULE, \
252 .vsel_reg = AS3711_ ## _id ## _VOLTAGE, \
253 .vsel_mask = _vmask << _vshift, \
254 .enable_reg = AS3711_ ## _en_reg, \
255 .enable_mask = BIT(_en_bit), \
256 .min_uV = _min_uV, \
257 }, \
258 .max_uV = _max_uV, \
259}
260
261static struct as3711_regulator_info as3711_reg_info[] = {
262 AS3711_REG(SD_1, SD_CONTROL, 0, 0x7f, 0, 612500, 3350000, sd),
263 AS3711_REG(SD_2, SD_CONTROL, 1, 0x7f, 0, 612500, 3350000, sd),
264 AS3711_REG(SD_3, SD_CONTROL, 2, 0x7f, 0, 612500, 3350000, sd),
265 AS3711_REG(SD_4, SD_CONTROL, 3, 0x7f, 0, 612500, 3350000, sd),
266 AS3711_REG(LDO_1, LDO_1_VOLTAGE, 7, 0x1f, 0, 1200000, 3300000, aldo),
267 AS3711_REG(LDO_2, LDO_2_VOLTAGE, 7, 0x1f, 0, 1200000, 3300000, aldo),
268 AS3711_REG(LDO_3, LDO_3_VOLTAGE, 7, 0x3f, 0, 900000, 3300000, dldo),
269 AS3711_REG(LDO_4, LDO_4_VOLTAGE, 7, 0x3f, 0, 900000, 3300000, dldo),
270 AS3711_REG(LDO_5, LDO_5_VOLTAGE, 7, 0x3f, 0, 900000, 3300000, dldo),
271 AS3711_REG(LDO_6, LDO_6_VOLTAGE, 7, 0x3f, 0, 900000, 3300000, dldo),
272 AS3711_REG(LDO_7, LDO_7_VOLTAGE, 7, 0x3f, 0, 900000, 3300000, dldo),
273 AS3711_REG(LDO_8, LDO_8_VOLTAGE, 7, 0x3f, 0, 900000, 3300000, dldo),
274 /* StepUp output voltage depends on supplying regulator */
275};
276
277#define AS3711_REGULATOR_NUM ARRAY_SIZE(as3711_reg_info)
278
279static int as3711_regulator_probe(struct platform_device *pdev)
280{
281 struct as3711_regulator_pdata *pdata = dev_get_platdata(&pdev->dev);
282 struct as3711 *as3711 = dev_get_drvdata(pdev->dev.parent);
283 struct regulator_init_data *reg_data;
284 struct regulator_config config = {.dev = &pdev->dev,};
285 struct as3711_regulator *reg = NULL;
286 struct as3711_regulator *regs;
287 struct regulator_dev *rdev;
288 struct as3711_regulator_info *ri;
289 int ret;
290 int id;
291
292 if (!pdata)
293 dev_dbg(&pdev->dev, "No platform data...\n");
294
295 regs = devm_kzalloc(&pdev->dev, AS3711_REGULATOR_NUM *
296 sizeof(struct as3711_regulator), GFP_KERNEL);
297 if (!regs) {
298 dev_err(&pdev->dev, "Memory allocation failed exiting..\n");
299 return -ENOMEM;
300 }
301
302 for (id = 0, ri = as3711_reg_info; id < AS3711_REGULATOR_NUM; ++id, ri++) {
303 reg_data = pdata ? pdata->init_data[id] : NULL;
304
305 /* No need to register if there is no regulator data */
306 if (!ri->desc.name)
307 continue;
308
309 reg = &regs[id];
310 reg->reg_info = ri;
311
312 config.init_data = reg_data;
313 config.driver_data = reg;
314 config.regmap = as3711->regmap;
315
316 rdev = regulator_register(&ri->desc, &config);
317 if (IS_ERR(rdev)) {
318 dev_err(&pdev->dev, "Failed to register regulator %s\n",
319 ri->desc.name);
320 ret = PTR_ERR(rdev);
321 goto eregreg;
322 }
323 reg->rdev = rdev;
324 }
325 platform_set_drvdata(pdev, regs);
326 return 0;
327
328eregreg:
329 while (--id >= 0)
330 regulator_unregister(regs[id].rdev);
331
332 return ret;
333}
334
335static int as3711_regulator_remove(struct platform_device *pdev)
336{
337 struct as3711_regulator *regs = platform_get_drvdata(pdev);
338 int id;
339
340 for (id = 0; id < AS3711_REGULATOR_NUM; ++id)
341 regulator_unregister(regs[id].rdev);
342 return 0;
343}
344
345static struct platform_driver as3711_regulator_driver = {
346 .driver = {
347 .name = "as3711-regulator",
348 .owner = THIS_MODULE,
349 },
350 .probe = as3711_regulator_probe,
351 .remove = as3711_regulator_remove,
352};
353
354static int __init as3711_regulator_init(void)
355{
356 return platform_driver_register(&as3711_regulator_driver);
357}
358subsys_initcall(as3711_regulator_init);
359
360static void __exit as3711_regulator_exit(void)
361{
362 platform_driver_unregister(&as3711_regulator_driver);
363}
364module_exit(as3711_regulator_exit);
365
366MODULE_AUTHOR("Guennadi Liakhovetski <g.liakhovetski@gmx.de>");
367MODULE_DESCRIPTION("AS3711 regulator driver");
368MODULE_ALIAS("platform:as3711-regulator");
369MODULE_LICENSE("GPL v2");
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index e872c8be080e..0f65b246cc0c 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -199,8 +199,11 @@ static int regulator_check_consumers(struct regulator_dev *rdev,
199 *min_uV = regulator->min_uV; 199 *min_uV = regulator->min_uV;
200 } 200 }
201 201
202 if (*min_uV > *max_uV) 202 if (*min_uV > *max_uV) {
203 dev_err(regulator->dev, "Restricting voltage, %u-%uuV\n",
204 regulator->min_uV, regulator->max_uV);
203 return -EINVAL; 205 return -EINVAL;
206 }
204 207
205 return 0; 208 return 0;
206} 209}
@@ -880,7 +883,9 @@ static int machine_constraints_voltage(struct regulator_dev *rdev,
880 883
881 /* final: [min_uV..max_uV] valid iff constraints valid */ 884 /* final: [min_uV..max_uV] valid iff constraints valid */
882 if (max_uV < min_uV) { 885 if (max_uV < min_uV) {
883 rdev_err(rdev, "unsupportable voltage constraints\n"); 886 rdev_err(rdev,
887 "unsupportable voltage constraints %u-%uuV\n",
888 min_uV, max_uV);
884 return -EINVAL; 889 return -EINVAL;
885 } 890 }
886 891
@@ -1867,6 +1872,28 @@ int regulator_is_enabled(struct regulator *regulator)
1867EXPORT_SYMBOL_GPL(regulator_is_enabled); 1872EXPORT_SYMBOL_GPL(regulator_is_enabled);
1868 1873
1869/** 1874/**
1875 * regulator_can_change_voltage - check if regulator can change voltage
1876 * @regulator: regulator source
1877 *
1878 * Returns positive if the regulator driver backing the source/client
1879 * can change its voltage, false otherwise. Usefull for detecting fixed
1880 * or dummy regulators and disabling voltage change logic in the client
1881 * driver.
1882 */
1883int regulator_can_change_voltage(struct regulator *regulator)
1884{
1885 struct regulator_dev *rdev = regulator->rdev;
1886
1887 if (rdev->constraints &&
1888 rdev->constraints->valid_ops_mask & REGULATOR_CHANGE_VOLTAGE &&
1889 (rdev->desc->n_voltages - rdev->desc->linear_min_sel) > 1)
1890 return 1;
1891
1892 return 0;
1893}
1894EXPORT_SYMBOL_GPL(regulator_can_change_voltage);
1895
1896/**
1870 * regulator_count_voltages - count regulator_list_voltage() selectors 1897 * regulator_count_voltages - count regulator_list_voltage() selectors
1871 * @regulator: regulator source 1898 * @regulator: regulator source
1872 * 1899 *
@@ -1897,6 +1924,10 @@ int regulator_list_voltage_linear(struct regulator_dev *rdev,
1897{ 1924{
1898 if (selector >= rdev->desc->n_voltages) 1925 if (selector >= rdev->desc->n_voltages)
1899 return -EINVAL; 1926 return -EINVAL;
1927 if (selector < rdev->desc->linear_min_sel)
1928 return 0;
1929
1930 selector -= rdev->desc->linear_min_sel;
1900 1931
1901 return rdev->desc->min_uV + (rdev->desc->uV_step * selector); 1932 return rdev->desc->min_uV + (rdev->desc->uV_step * selector);
1902} 1933}
@@ -1985,6 +2016,11 @@ int regulator_is_supported_voltage(struct regulator *regulator,
1985 return ret; 2016 return ret;
1986 } 2017 }
1987 2018
2019 /* Any voltage within constrains range is fine? */
2020 if (rdev->desc->continuous_voltage_range)
2021 return min_uV >= rdev->constraints->min_uV &&
2022 max_uV <= rdev->constraints->max_uV;
2023
1988 ret = regulator_count_voltages(regulator); 2024 ret = regulator_count_voltages(regulator);
1989 if (ret < 0) 2025 if (ret < 0)
1990 return ret; 2026 return ret;
@@ -2120,6 +2156,8 @@ int regulator_map_voltage_linear(struct regulator_dev *rdev,
2120 if (ret < 0) 2156 if (ret < 0)
2121 return ret; 2157 return ret;
2122 2158
2159 ret += rdev->desc->linear_min_sel;
2160
2123 /* Map back into a voltage to verify we're still in bounds */ 2161 /* Map back into a voltage to verify we're still in bounds */
2124 voltage = rdev->desc->ops->list_voltage(rdev, ret); 2162 voltage = rdev->desc->ops->list_voltage(rdev, ret);
2125 if (voltage < min_uV || voltage > max_uV) 2163 if (voltage < min_uV || voltage > max_uV)
diff --git a/drivers/regulator/da903x.c b/drivers/regulator/da903x.c
index 36c5b92fe0af..2afa5730f324 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 27355b1199e5..d0963090442d 100644
--- a/drivers/regulator/da9052-regulator.c
+++ b/drivers/regulator/da9052-regulator.c
@@ -129,17 +129,17 @@ static int da9052_dcdc_set_current_limit(struct regulator_dev *rdev, int min_uA,
129 else if (offset == 0) 129 else if (offset == 0)
130 row = 1; 130 row = 1;
131 131
132 if (min_uA > da9052_current_limits[row][DA9052_MAX_UA] ||
133 max_uA < da9052_current_limits[row][DA9052_MIN_UA])
134 return -EINVAL;
135
136 for (i = DA9052_CURRENT_RANGE - 1; i >= 0; i--) { 132 for (i = DA9052_CURRENT_RANGE - 1; i >= 0; i--) {
137 if (da9052_current_limits[row][i] <= max_uA) { 133 if ((min_uA <= da9052_current_limits[row][i]) &&
134 (da9052_current_limits[row][i] <= max_uA)) {
138 reg_val = i; 135 reg_val = i;
139 break; 136 break;
140 } 137 }
141 } 138 }
142 139
140 if (i < 0)
141 return -EINVAL;
142
143 /* Determine the even or odd position of the buck current limit 143 /* Determine the even or odd position of the buck current limit
144 * register field 144 * register field
145 */ 145 */
@@ -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/da9055-regulator.c b/drivers/regulator/da9055-regulator.c
new file mode 100644
index 000000000000..a4b9cb8c4317
--- /dev/null
+++ b/drivers/regulator/da9055-regulator.c
@@ -0,0 +1,641 @@
1/*
2* Regulator driver for DA9055 PMIC
3*
4* Copyright(c) 2012 Dialog Semiconductor Ltd.
5*
6* Author: David Dajun Chen <dchen@diasemi.com>
7*
8* This program is free software; you can redistribute it and/or modify
9* it under the terms of the GNU General Public License as published by
10* the Free Software Foundation; either version 2 of the License, or
11* (at your option) any later version.
12*
13*/
14
15#include <linux/module.h>
16#include <linux/init.h>
17#include <linux/err.h>
18#include <linux/gpio.h>
19#include <linux/platform_device.h>
20#include <linux/regulator/driver.h>
21#include <linux/regulator/machine.h>
22
23#include <linux/mfd/da9055/core.h>
24#include <linux/mfd/da9055/reg.h>
25#include <linux/mfd/da9055/pdata.h>
26
27#define DA9055_MIN_UA 0
28#define DA9055_MAX_UA 3
29
30#define DA9055_LDO_MODE_SYNC 0
31#define DA9055_LDO_MODE_SLEEP 1
32
33#define DA9055_BUCK_MODE_SLEEP 1
34#define DA9055_BUCK_MODE_SYNC 2
35#define DA9055_BUCK_MODE_AUTO 3
36
37/* DA9055 REGULATOR IDs */
38#define DA9055_ID_BUCK1 0
39#define DA9055_ID_BUCK2 1
40#define DA9055_ID_LDO1 2
41#define DA9055_ID_LDO2 3
42#define DA9055_ID_LDO3 4
43#define DA9055_ID_LDO4 5
44#define DA9055_ID_LDO5 6
45#define DA9055_ID_LDO6 7
46
47/* DA9055 BUCK current limit */
48static const int da9055_current_limits[] = { 500000, 600000, 700000, 800000 };
49
50struct da9055_conf_reg {
51 int reg;
52 int sel_mask;
53 int en_mask;
54};
55
56struct da9055_volt_reg {
57 int reg_a;
58 int reg_b;
59 int sl_shift;
60 int v_mask;
61 int v_shift;
62};
63
64struct da9055_mode_reg {
65 int reg;
66 int mask;
67 int shift;
68};
69
70struct da9055_regulator_info {
71 struct regulator_desc reg_desc;
72 struct da9055_conf_reg conf;
73 struct da9055_volt_reg volt;
74 struct da9055_mode_reg mode;
75};
76
77struct da9055_regulator {
78 struct da9055 *da9055;
79 struct da9055_regulator_info *info;
80 struct regulator_dev *rdev;
81 enum gpio_select reg_rselect;
82};
83
84static unsigned int da9055_buck_get_mode(struct regulator_dev *rdev)
85{
86 struct da9055_regulator *regulator = rdev_get_drvdata(rdev);
87 struct da9055_regulator_info *info = regulator->info;
88 int ret, mode = 0;
89
90 ret = da9055_reg_read(regulator->da9055, info->mode.reg);
91 if (ret < 0)
92 return ret;
93
94 switch ((ret & info->mode.mask) >> info->mode.shift) {
95 case DA9055_BUCK_MODE_SYNC:
96 mode = REGULATOR_MODE_FAST;
97 break;
98 case DA9055_BUCK_MODE_AUTO:
99 mode = REGULATOR_MODE_NORMAL;
100 break;
101 case DA9055_BUCK_MODE_SLEEP:
102 mode = REGULATOR_MODE_STANDBY;
103 break;
104 }
105
106 return mode;
107}
108
109static int da9055_buck_set_mode(struct regulator_dev *rdev,
110 unsigned int mode)
111{
112 struct da9055_regulator *regulator = rdev_get_drvdata(rdev);
113 struct da9055_regulator_info *info = regulator->info;
114 int val = 0;
115
116 switch (mode) {
117 case REGULATOR_MODE_FAST:
118 val = DA9055_BUCK_MODE_SYNC << info->mode.shift;
119 break;
120 case REGULATOR_MODE_NORMAL:
121 val = DA9055_BUCK_MODE_AUTO << info->mode.shift;
122 break;
123 case REGULATOR_MODE_STANDBY:
124 val = DA9055_BUCK_MODE_SLEEP << info->mode.shift;
125 break;
126 }
127
128 return da9055_reg_update(regulator->da9055, info->mode.reg,
129 info->mode.mask, val);
130}
131
132static unsigned int da9055_ldo_get_mode(struct regulator_dev *rdev)
133{
134 struct da9055_regulator *regulator = rdev_get_drvdata(rdev);
135 struct da9055_regulator_info *info = regulator->info;
136 int ret;
137
138 ret = da9055_reg_read(regulator->da9055, info->volt.reg_b);
139 if (ret < 0)
140 return ret;
141
142 if (ret >> info->volt.sl_shift)
143 return REGULATOR_MODE_STANDBY;
144 else
145 return REGULATOR_MODE_NORMAL;
146}
147
148static int da9055_ldo_set_mode(struct regulator_dev *rdev, unsigned int mode)
149{
150 struct da9055_regulator *regulator = rdev_get_drvdata(rdev);
151 struct da9055_regulator_info *info = regulator->info;
152 struct da9055_volt_reg volt = info->volt;
153 int val = 0;
154
155 switch (mode) {
156 case REGULATOR_MODE_NORMAL:
157 case REGULATOR_MODE_FAST:
158 val = DA9055_LDO_MODE_SYNC;
159 break;
160 case REGULATOR_MODE_STANDBY:
161 val = DA9055_LDO_MODE_SLEEP;
162 break;
163 }
164
165 return da9055_reg_update(regulator->da9055, volt.reg_b,
166 1 << volt.sl_shift,
167 val << volt.sl_shift);
168}
169
170static int da9055_buck_get_current_limit(struct regulator_dev *rdev)
171{
172 struct da9055_regulator *regulator = rdev_get_drvdata(rdev);
173 struct da9055_regulator_info *info = regulator->info;
174 int ret;
175
176 ret = da9055_reg_read(regulator->da9055, DA9055_REG_BUCK_LIM);
177 if (ret < 0)
178 return ret;
179
180 ret &= info->mode.mask;
181 return da9055_current_limits[ret >> info->mode.shift];
182}
183
184static int da9055_buck_set_current_limit(struct regulator_dev *rdev, int min_uA,
185 int max_uA)
186{
187 struct da9055_regulator *regulator = rdev_get_drvdata(rdev);
188 struct da9055_regulator_info *info = regulator->info;
189 int i;
190
191 for (i = ARRAY_SIZE(da9055_current_limits) - 1; i >= 0; i--) {
192 if ((min_uA <= da9055_current_limits[i]) &&
193 (da9055_current_limits[i] <= max_uA))
194 return da9055_reg_update(regulator->da9055,
195 DA9055_REG_BUCK_LIM,
196 info->mode.mask,
197 i << info->mode.shift);
198 }
199
200 return -EINVAL;
201}
202
203static int da9055_regulator_get_voltage_sel(struct regulator_dev *rdev)
204{
205 struct da9055_regulator *regulator = rdev_get_drvdata(rdev);
206 struct da9055_regulator_info *info = regulator->info;
207 struct da9055_volt_reg volt = info->volt;
208 int ret, sel;
209
210 /*
211 * There are two voltage register set A & B for voltage ramping but
212 * either one of then can be active therefore we first determine
213 * the active register set.
214 */
215 ret = da9055_reg_read(regulator->da9055, info->conf.reg);
216 if (ret < 0)
217 return ret;
218
219 ret &= info->conf.sel_mask;
220
221 /* Get the voltage for the active register set A/B */
222 if (ret == DA9055_REGUALTOR_SET_A)
223 ret = da9055_reg_read(regulator->da9055, volt.reg_a);
224 else
225 ret = da9055_reg_read(regulator->da9055, volt.reg_b);
226
227 if (ret < 0)
228 return ret;
229
230 sel = (ret & volt.v_mask);
231 return sel;
232}
233
234static int da9055_regulator_set_voltage_sel(struct regulator_dev *rdev,
235 unsigned int selector)
236{
237 struct da9055_regulator *regulator = rdev_get_drvdata(rdev);
238 struct da9055_regulator_info *info = regulator->info;
239 int ret;
240
241 /*
242 * Regulator register set A/B is not selected through GPIO therefore
243 * we use default register set A for voltage ramping.
244 */
245 if (regulator->reg_rselect == NO_GPIO) {
246 /* Select register set A */
247 ret = da9055_reg_update(regulator->da9055, info->conf.reg,
248 info->conf.sel_mask, DA9055_SEL_REG_A);
249 if (ret < 0)
250 return ret;
251
252 /* Set the voltage */
253 return da9055_reg_update(regulator->da9055, info->volt.reg_a,
254 info->volt.v_mask, selector);
255 }
256
257 /*
258 * Here regulator register set A/B is selected through GPIO.
259 * Therefore we first determine the selected register set A/B and
260 * then set the desired voltage for that register set A/B.
261 */
262 ret = da9055_reg_read(regulator->da9055, info->conf.reg);
263 if (ret < 0)
264 return ret;
265
266 ret &= info->conf.sel_mask;
267
268 /* Set the voltage */
269 if (ret == DA9055_REGUALTOR_SET_A)
270 return da9055_reg_update(regulator->da9055, info->volt.reg_a,
271 info->volt.v_mask, selector);
272 else
273 return da9055_reg_update(regulator->da9055, info->volt.reg_b,
274 info->volt.v_mask, selector);
275}
276
277static int da9055_regulator_set_suspend_voltage(struct regulator_dev *rdev,
278 int uV)
279{
280 struct da9055_regulator *regulator = rdev_get_drvdata(rdev);
281 struct da9055_regulator_info *info = regulator->info;
282 int ret;
283
284 /* Select register set B for suspend voltage ramping. */
285 if (regulator->reg_rselect == NO_GPIO) {
286 ret = da9055_reg_update(regulator->da9055, info->conf.reg,
287 info->conf.sel_mask, DA9055_SEL_REG_B);
288 if (ret < 0)
289 return ret;
290 }
291
292 ret = regulator_map_voltage_linear(rdev, uV, uV);
293 if (ret < 0)
294 return ret;
295
296 return da9055_reg_update(regulator->da9055, info->volt.reg_b,
297 info->volt.v_mask, ret);
298}
299
300static int da9055_suspend_enable(struct regulator_dev *rdev)
301{
302 struct da9055_regulator *regulator = rdev_get_drvdata(rdev);
303 struct da9055_regulator_info *info = regulator->info;
304
305 /* Select register set B for voltage ramping. */
306 if (regulator->reg_rselect == NO_GPIO)
307 return da9055_reg_update(regulator->da9055, info->conf.reg,
308 info->conf.sel_mask, DA9055_SEL_REG_B);
309 else
310 return 0;
311}
312
313static int da9055_suspend_disable(struct regulator_dev *rdev)
314{
315 struct da9055_regulator *regulator = rdev_get_drvdata(rdev);
316 struct da9055_regulator_info *info = regulator->info;
317
318 /* Diselect register set B. */
319 if (regulator->reg_rselect == NO_GPIO)
320 return da9055_reg_update(regulator->da9055, info->conf.reg,
321 info->conf.sel_mask, DA9055_SEL_REG_A);
322 else
323 return 0;
324}
325
326static struct regulator_ops da9055_buck_ops = {
327 .get_mode = da9055_buck_get_mode,
328 .set_mode = da9055_buck_set_mode,
329
330 .get_current_limit = da9055_buck_get_current_limit,
331 .set_current_limit = da9055_buck_set_current_limit,
332
333 .get_voltage_sel = da9055_regulator_get_voltage_sel,
334 .set_voltage_sel = da9055_regulator_set_voltage_sel,
335 .list_voltage = regulator_list_voltage_linear,
336 .map_voltage = regulator_map_voltage_linear,
337 .is_enabled = regulator_is_enabled_regmap,
338 .enable = regulator_enable_regmap,
339 .disable = regulator_disable_regmap,
340
341 .set_suspend_voltage = da9055_regulator_set_suspend_voltage,
342 .set_suspend_enable = da9055_suspend_enable,
343 .set_suspend_disable = da9055_suspend_disable,
344 .set_suspend_mode = da9055_buck_set_mode,
345};
346
347static struct regulator_ops da9055_ldo_ops = {
348 .get_mode = da9055_ldo_get_mode,
349 .set_mode = da9055_ldo_set_mode,
350
351 .get_voltage_sel = da9055_regulator_get_voltage_sel,
352 .set_voltage_sel = da9055_regulator_set_voltage_sel,
353 .list_voltage = regulator_list_voltage_linear,
354 .map_voltage = regulator_map_voltage_linear,
355 .is_enabled = regulator_is_enabled_regmap,
356 .enable = regulator_enable_regmap,
357 .disable = regulator_disable_regmap,
358
359 .set_suspend_voltage = da9055_regulator_set_suspend_voltage,
360 .set_suspend_enable = da9055_suspend_enable,
361 .set_suspend_disable = da9055_suspend_disable,
362 .set_suspend_mode = da9055_ldo_set_mode,
363
364};
365
366#define DA9055_LDO(_id, step, min, max, vbits, voffset) \
367{\
368 .reg_desc = {\
369 .name = #_id,\
370 .ops = &da9055_ldo_ops,\
371 .type = REGULATOR_VOLTAGE,\
372 .id = DA9055_ID_##_id,\
373 .n_voltages = (max - min) / step + 1 + (voffset), \
374 .enable_reg = DA9055_REG_BCORE_CONT + DA9055_ID_##_id, \
375 .enable_mask = 1, \
376 .min_uV = (min) * 1000,\
377 .uV_step = (step) * 1000,\
378 .linear_min_sel = (voffset),\
379 .owner = THIS_MODULE,\
380 },\
381 .conf = {\
382 .reg = DA9055_REG_BCORE_CONT + DA9055_ID_##_id, \
383 .sel_mask = (1 << 4),\
384 .en_mask = 1,\
385 },\
386 .volt = {\
387 .reg_a = DA9055_REG_VBCORE_A + DA9055_ID_##_id, \
388 .reg_b = DA9055_REG_VBCORE_B + DA9055_ID_##_id, \
389 .sl_shift = 7,\
390 .v_mask = (1 << (vbits)) - 1,\
391 .v_shift = (vbits),\
392 },\
393}
394
395#define DA9055_BUCK(_id, step, min, max, vbits, voffset, mbits, sbits) \
396{\
397 .reg_desc = {\
398 .name = #_id,\
399 .ops = &da9055_buck_ops,\
400 .type = REGULATOR_VOLTAGE,\
401 .id = DA9055_ID_##_id,\
402 .n_voltages = (max - min) / step + 1 + (voffset), \
403 .enable_reg = DA9055_REG_BCORE_CONT + DA9055_ID_##_id, \
404 .enable_mask = 1,\
405 .min_uV = (min) * 1000,\
406 .uV_step = (step) * 1000,\
407 .linear_min_sel = (voffset),\
408 .owner = THIS_MODULE,\
409 },\
410 .conf = {\
411 .reg = DA9055_REG_BCORE_CONT + DA9055_ID_##_id, \
412 .sel_mask = (1 << 4),\
413 .en_mask = 1,\
414 },\
415 .volt = {\
416 .reg_a = DA9055_REG_VBCORE_A + DA9055_ID_##_id, \
417 .reg_b = DA9055_REG_VBCORE_B + DA9055_ID_##_id, \
418 .sl_shift = 7,\
419 .v_mask = (1 << (vbits)) - 1,\
420 .v_shift = (vbits),\
421 },\
422 .mode = {\
423 .reg = DA9055_REG_BCORE_MODE,\
424 .mask = (mbits),\
425 .shift = (sbits),\
426 },\
427}
428
429static struct da9055_regulator_info da9055_regulator_info[] = {
430 DA9055_BUCK(BUCK1, 25, 725, 2075, 6, 9, 0xc, 2),
431 DA9055_BUCK(BUCK2, 25, 925, 2500, 6, 0, 3, 0),
432 DA9055_LDO(LDO1, 50, 900, 3300, 6, 2),
433 DA9055_LDO(LDO2, 50, 900, 3300, 6, 3),
434 DA9055_LDO(LDO3, 50, 900, 3300, 6, 2),
435 DA9055_LDO(LDO4, 50, 900, 3300, 6, 2),
436 DA9055_LDO(LDO5, 50, 900, 2750, 6, 2),
437 DA9055_LDO(LDO6, 20, 900, 3300, 7, 0),
438};
439
440/*
441 * Configures regulator to be controlled either through GPIO 1 or 2.
442 * GPIO can control regulator state and/or select the regulator register
443 * set A/B for voltage ramping.
444 */
445static __devinit int da9055_gpio_init(struct da9055_regulator *regulator,
446 struct regulator_config *config,
447 struct da9055_pdata *pdata, int id)
448{
449 struct da9055_regulator_info *info = regulator->info;
450 int ret = 0;
451
452 if (pdata->gpio_ren && pdata->gpio_ren[id]) {
453 char name[18];
454 int gpio_mux = pdata->gpio_ren[id];
455
456 config->ena_gpio = pdata->ena_gpio[id];
457 config->ena_gpio_flags = GPIOF_OUT_INIT_HIGH;
458 config->ena_gpio_invert = 1;
459
460 /*
461 * GPI pin is muxed with regulator to control the
462 * regulator state.
463 */
464 sprintf(name, "DA9055 GPI %d", gpio_mux);
465 ret = devm_gpio_request_one(config->dev, gpio_mux, GPIOF_DIR_IN,
466 name);
467 if (ret < 0)
468 goto err;
469
470 /*
471 * Let the regulator know that its state is controlled
472 * through GPI.
473 */
474 ret = da9055_reg_update(regulator->da9055, info->conf.reg,
475 DA9055_E_GPI_MASK,
476 pdata->reg_ren[id]
477 << DA9055_E_GPI_SHIFT);
478 if (ret < 0)
479 goto err;
480 }
481
482 if (pdata->gpio_rsel && pdata->gpio_rsel[id]) {
483 char name[18];
484 int gpio_mux = pdata->gpio_rsel[id];
485
486 regulator->reg_rselect = pdata->reg_rsel[id];
487
488 /*
489 * GPI pin is muxed with regulator to select the
490 * regulator register set A/B for voltage ramping.
491 */
492 sprintf(name, "DA9055 GPI %d", gpio_mux);
493 ret = devm_gpio_request_one(config->dev, gpio_mux, GPIOF_DIR_IN,
494 name);
495 if (ret < 0)
496 goto err;
497
498 /*
499 * Let the regulator know that its register set A/B
500 * will be selected through GPI for voltage ramping.
501 */
502 ret = da9055_reg_update(regulator->da9055, info->conf.reg,
503 DA9055_V_GPI_MASK,
504 pdata->reg_rsel[id]
505 << DA9055_V_GPI_SHIFT);
506 }
507
508err:
509 return ret;
510}
511
512static irqreturn_t da9055_ldo5_6_oc_irq(int irq, void *data)
513{
514 struct da9055_regulator *regulator = data;
515
516 regulator_notifier_call_chain(regulator->rdev,
517 REGULATOR_EVENT_OVER_CURRENT, NULL);
518
519 return IRQ_HANDLED;
520}
521
522static inline struct da9055_regulator_info *find_regulator_info(int id)
523{
524 struct da9055_regulator_info *info;
525 int i;
526
527 for (i = 0; i < ARRAY_SIZE(da9055_regulator_info); i++) {
528 info = &da9055_regulator_info[i];
529 if (info->reg_desc.id == id)
530 return info;
531 }
532
533 return NULL;
534}
535
536static int __devinit da9055_regulator_probe(struct platform_device *pdev)
537{
538 struct regulator_config config = { };
539 struct da9055_regulator *regulator;
540 struct da9055 *da9055 = dev_get_drvdata(pdev->dev.parent);
541 struct da9055_pdata *pdata = da9055->dev->platform_data;
542 int ret, irq;
543
544 if (pdata == NULL || pdata->regulators[pdev->id] == NULL)
545 return -ENODEV;
546
547 regulator = devm_kzalloc(&pdev->dev, sizeof(struct da9055_regulator),
548 GFP_KERNEL);
549 if (!regulator)
550 return -ENOMEM;
551
552 regulator->info = find_regulator_info(pdev->id);
553 if (regulator->info == NULL) {
554 dev_err(&pdev->dev, "invalid regulator ID specified\n");
555 return -EINVAL;
556 }
557
558 regulator->da9055 = da9055;
559 config.dev = &pdev->dev;
560 config.driver_data = regulator;
561 config.regmap = da9055->regmap;
562
563 if (pdata && pdata->regulators)
564 config.init_data = pdata->regulators[pdev->id];
565
566 ret = da9055_gpio_init(regulator, &config, pdata, pdev->id);
567 if (ret < 0)
568 return ret;
569
570 regulator->rdev = regulator_register(&regulator->info->reg_desc,
571 &config);
572 if (IS_ERR(regulator->rdev)) {
573 dev_err(&pdev->dev, "Failed to register regulator %s\n",
574 regulator->info->reg_desc.name);
575 ret = PTR_ERR(regulator->rdev);
576 return ret;
577 }
578
579 /* Only LDO 5 and 6 has got the over current interrupt */
580 if (pdev->id == DA9055_ID_LDO5 || pdev->id == DA9055_ID_LDO6) {
581 irq = platform_get_irq_byname(pdev, "REGULATOR");
582 irq = regmap_irq_get_virq(da9055->irq_data, irq);
583 ret = devm_request_threaded_irq(&pdev->dev, irq, NULL,
584 da9055_ldo5_6_oc_irq,
585 IRQF_TRIGGER_HIGH |
586 IRQF_ONESHOT |
587 IRQF_PROBE_SHARED,
588 pdev->name, regulator);
589 if (ret != 0) {
590 if (ret != -EBUSY) {
591 dev_err(&pdev->dev,
592 "Failed to request Regulator IRQ %d: %d\n",
593 irq, ret);
594 goto err_regulator;
595 }
596 }
597 }
598
599 platform_set_drvdata(pdev, regulator);
600
601 return 0;
602
603err_regulator:
604 regulator_unregister(regulator->rdev);
605 return ret;
606}
607
608static int __devexit da9055_regulator_remove(struct platform_device *pdev)
609{
610 struct da9055_regulator *regulator = platform_get_drvdata(pdev);
611
612 regulator_unregister(regulator->rdev);
613
614 return 0;
615}
616
617static struct platform_driver da9055_regulator_driver = {
618 .probe = da9055_regulator_probe,
619 .remove = __devexit_p(da9055_regulator_remove),
620 .driver = {
621 .name = "da9055-regulator",
622 .owner = THIS_MODULE,
623 },
624};
625
626static int __init da9055_regulator_init(void)
627{
628 return platform_driver_register(&da9055_regulator_driver);
629}
630subsys_initcall(da9055_regulator_init);
631
632static void __exit da9055_regulator_exit(void)
633{
634 platform_driver_unregister(&da9055_regulator_driver);
635}
636module_exit(da9055_regulator_exit);
637
638MODULE_AUTHOR("David Dajun Chen <dchen@diasemi.com>");
639MODULE_DESCRIPTION("Power Regulator driver for Dialog DA9055 PMIC");
640MODULE_LICENSE("GPL");
641MODULE_ALIAS("platform:da9055-regulator");
diff --git a/drivers/regulator/db8500-prcmu.c b/drivers/regulator/db8500-prcmu.c
index 359f8d18fc3f..219d162b651e 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 f2e5ecdc5864..261f3d2299bc 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 03a1d7c11ef2..df9f42524abb 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 339f4d732e97..9165b0c40ed3 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 185468c4d38f..48d5b7608b00 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 8b5944f2d7d1..8ae288fc150b 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;
@@ -79,7 +82,7 @@ static int gpio_regulator_set_voltage(struct regulator_dev *dev,
79 82
80 for (ptr = 0; ptr < data->nr_gpios; ptr++) { 83 for (ptr = 0; ptr < data->nr_gpios; ptr++) {
81 state = (target & (1 << ptr)) >> ptr; 84 state = (target & (1 << ptr)) >> ptr;
82 gpio_set_value(data->gpios[ptr].gpio, state); 85 gpio_set_value_cansleep(data->gpios[ptr].gpio, state);
83 } 86 }
84 data->state = target; 87 data->state = target;
85 88
@@ -116,7 +119,7 @@ static int gpio_regulator_set_current_limit(struct regulator_dev *dev,
116 119
117 for (ptr = 0; ptr < data->nr_gpios; ptr++) { 120 for (ptr = 0; ptr < data->nr_gpios; ptr++) {
118 state = (target & (1 << ptr)) >> ptr; 121 state = (target & (1 << ptr)) >> ptr;
119 gpio_set_value(data->gpios[ptr].gpio, state); 122 gpio_set_value_cansleep(data->gpios[ptr].gpio, state);
120 } 123 }
121 data->state = target; 124 data->state = target;
122 125
@@ -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; i < 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,20 @@ static int __devexit gpio_regulator_remove(struct platform_device *pdev)
270 return 0; 364 return 0;
271} 365}
272 366
367#if defined(CONFIG_OF)
368static const struct of_device_id regulator_gpio_of_match[] __devinitconst = {
369 { .compatible = "regulator-gpio", },
370 {},
371};
372#endif
373
273static struct platform_driver gpio_regulator_driver = { 374static struct platform_driver gpio_regulator_driver = {
274 .probe = gpio_regulator_probe, 375 .probe = gpio_regulator_probe,
275 .remove = __devexit_p(gpio_regulator_remove), 376 .remove = gpio_regulator_remove,
276 .driver = { 377 .driver = {
277 .name = "gpio-regulator", 378 .name = "gpio-regulator",
278 .owner = THIS_MODULE, 379 .owner = THIS_MODULE,
380 .of_match_table = of_match_ptr(regulator_gpio_of_match),
279 }, 381 },
280}; 382};
281 383
diff --git a/drivers/regulator/isl6271a-regulator.c b/drivers/regulator/isl6271a-regulator.c
index d8ecf49a5777..d1e5bee2a26b 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 7c6e3b8ff484..5f68ff11a298 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 3cdc755d9b22..69c42c318b87 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 708f4b6a17dc..9289ead715ca 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 ba3e0aa402de..aef3f2b0c5ea 100644
--- a/drivers/regulator/lp8788-buck.c
+++ b/drivers/regulator/lp8788-buck.c
@@ -429,18 +429,6 @@ static struct regulator_desc lp8788_buck_desc[] = {
429 }, 429 },
430}; 430};
431 431
432static int _gpio_request(struct lp8788_buck *buck, int gpio, char *name)
433{
434 struct device *dev = buck->lp->dev;
435
436 if (!gpio_is_valid(gpio)) {
437 dev_err(dev, "invalid gpio: %d\n", gpio);
438 return -EINVAL;
439 }
440
441 return devm_gpio_request_one(dev, gpio, DVS_LOW, name);
442}
443
444static int lp8788_dvs_gpio_request(struct lp8788_buck *buck, 432static int lp8788_dvs_gpio_request(struct lp8788_buck *buck,
445 enum lp8788_buck_id id) 433 enum lp8788_buck_id id)
446{ 434{
@@ -452,7 +440,8 @@ static int lp8788_dvs_gpio_request(struct lp8788_buck *buck,
452 switch (id) { 440 switch (id) {
453 case BUCK1: 441 case BUCK1:
454 gpio = pdata->buck1_dvs->gpio; 442 gpio = pdata->buck1_dvs->gpio;
455 ret = _gpio_request(buck, gpio, b1_name); 443 ret = devm_gpio_request_one(buck->lp->dev, gpio, DVS_LOW,
444 b1_name);
456 if (ret) 445 if (ret)
457 return ret; 446 return ret;
458 447
@@ -461,7 +450,8 @@ static int lp8788_dvs_gpio_request(struct lp8788_buck *buck,
461 case BUCK2: 450 case BUCK2:
462 for (i = 0 ; i < LP8788_NUM_BUCK2_DVS ; i++) { 451 for (i = 0 ; i < LP8788_NUM_BUCK2_DVS ; i++) {
463 gpio = pdata->buck2_dvs->gpio[i]; 452 gpio = pdata->buck2_dvs->gpio[i];
464 ret = _gpio_request(buck, gpio, b2_name[i]); 453 ret = devm_gpio_request_one(buck->lp->dev, gpio,
454 DVS_LOW, b2_name[i]);
465 if (ret) 455 if (ret)
466 return ret; 456 return ret;
467 } 457 }
@@ -504,7 +494,7 @@ set_default_dvs_mode:
504 default_dvs_mode[id]); 494 default_dvs_mode[id]);
505} 495}
506 496
507static __devinit int lp8788_buck_probe(struct platform_device *pdev) 497static int lp8788_buck_probe(struct platform_device *pdev)
508{ 498{
509 struct lp8788 *lp = dev_get_drvdata(pdev->dev.parent); 499 struct lp8788 *lp = dev_get_drvdata(pdev->dev.parent);
510 int id = pdev->id; 500 int id = pdev->id;
@@ -542,7 +532,7 @@ static __devinit int lp8788_buck_probe(struct platform_device *pdev)
542 return 0; 532 return 0;
543} 533}
544 534
545static int __devexit lp8788_buck_remove(struct platform_device *pdev) 535static int lp8788_buck_remove(struct platform_device *pdev)
546{ 536{
547 struct lp8788_buck *buck = platform_get_drvdata(pdev); 537 struct lp8788_buck *buck = platform_get_drvdata(pdev);
548 538
@@ -554,7 +544,7 @@ static int __devexit lp8788_buck_remove(struct platform_device *pdev)
554 544
555static struct platform_driver lp8788_buck_driver = { 545static struct platform_driver lp8788_buck_driver = {
556 .probe = lp8788_buck_probe, 546 .probe = lp8788_buck_probe,
557 .remove = __devexit_p(lp8788_buck_remove), 547 .remove = lp8788_buck_remove,
558 .driver = { 548 .driver = {
559 .name = LP8788_DEV_BUCK, 549 .name = LP8788_DEV_BUCK,
560 .owner = THIS_MODULE, 550 .owner = THIS_MODULE,
diff --git a/drivers/regulator/lp8788-ldo.c b/drivers/regulator/lp8788-ldo.c
index 6796eeb47dc6..3792741708ce 100644
--- a/drivers/regulator/lp8788-ldo.c
+++ b/drivers/regulator/lp8788-ldo.c
@@ -126,7 +126,7 @@ struct lp8788_ldo {
126}; 126};
127 127
128/* DLDO 1, 2, 3, 9 voltage table */ 128/* DLDO 1, 2, 3, 9 voltage table */
129const int lp8788_dldo1239_vtbl[] = { 129static const int lp8788_dldo1239_vtbl[] = {
130 1800000, 1900000, 2000000, 2100000, 2200000, 2300000, 2400000, 2500000, 130 1800000, 1900000, 2000000, 2100000, 2200000, 2300000, 2400000, 2500000,
131 2600000, 2700000, 2800000, 2900000, 3000000, 2850000, 2850000, 2850000, 131 2600000, 2700000, 2800000, 2900000, 3000000, 2850000, 2850000, 2850000,
132 2850000, 2850000, 2850000, 2850000, 2850000, 2850000, 2850000, 2850000, 132 2850000, 2850000, 2850000, 2850000, 2850000, 2850000, 2850000, 2850000,
@@ -662,14 +662,6 @@ static int lp8788_config_ldo_enable_mode(struct lp8788_ldo *ldo,
662 [EN_DLDO7] = LP8788_EN_SEL_DLDO7_M, 662 [EN_DLDO7] = LP8788_EN_SEL_DLDO7_M,
663 [EN_DLDO911] = LP8788_EN_SEL_DLDO911_M, 663 [EN_DLDO911] = LP8788_EN_SEL_DLDO911_M,
664 }; 664 };
665 u8 val[] = {
666 [EN_ALDO1] = 0 << 5,
667 [EN_ALDO234] = 0 << 4,
668 [EN_ALDO5] = 0 << 3,
669 [EN_ALDO7] = 0 << 2,
670 [EN_DLDO7] = 0 << 1,
671 [EN_DLDO911] = 0 << 0,
672 };
673 665
674 switch (id) { 666 switch (id) {
675 case DLDO7: 667 case DLDO7:
@@ -708,11 +700,10 @@ static int lp8788_config_ldo_enable_mode(struct lp8788_ldo *ldo,
708 return ret; 700 return ret;
709 701
710set_default_ldo_enable_mode: 702set_default_ldo_enable_mode:
711 return lp8788_update_bits(lp, LP8788_EN_SEL, en_mask[enable_id], 703 return lp8788_update_bits(lp, LP8788_EN_SEL, en_mask[enable_id], 0);
712 val[enable_id]);
713} 704}
714 705
715static __devinit int lp8788_dldo_probe(struct platform_device *pdev) 706static int lp8788_dldo_probe(struct platform_device *pdev)
716{ 707{
717 struct lp8788 *lp = dev_get_drvdata(pdev->dev.parent); 708 struct lp8788 *lp = dev_get_drvdata(pdev->dev.parent);
718 int id = pdev->id; 709 int id = pdev->id;
@@ -749,7 +740,7 @@ static __devinit int lp8788_dldo_probe(struct platform_device *pdev)
749 return 0; 740 return 0;
750} 741}
751 742
752static int __devexit lp8788_dldo_remove(struct platform_device *pdev) 743static int lp8788_dldo_remove(struct platform_device *pdev)
753{ 744{
754 struct lp8788_ldo *ldo = platform_get_drvdata(pdev); 745 struct lp8788_ldo *ldo = platform_get_drvdata(pdev);
755 746
@@ -761,14 +752,14 @@ static int __devexit lp8788_dldo_remove(struct platform_device *pdev)
761 752
762static struct platform_driver lp8788_dldo_driver = { 753static struct platform_driver lp8788_dldo_driver = {
763 .probe = lp8788_dldo_probe, 754 .probe = lp8788_dldo_probe,
764 .remove = __devexit_p(lp8788_dldo_remove), 755 .remove = lp8788_dldo_remove,
765 .driver = { 756 .driver = {
766 .name = LP8788_DEV_DLDO, 757 .name = LP8788_DEV_DLDO,
767 .owner = THIS_MODULE, 758 .owner = THIS_MODULE,
768 }, 759 },
769}; 760};
770 761
771static __devinit int lp8788_aldo_probe(struct platform_device *pdev) 762static int lp8788_aldo_probe(struct platform_device *pdev)
772{ 763{
773 struct lp8788 *lp = dev_get_drvdata(pdev->dev.parent); 764 struct lp8788 *lp = dev_get_drvdata(pdev->dev.parent);
774 int id = pdev->id; 765 int id = pdev->id;
@@ -805,7 +796,7 @@ static __devinit int lp8788_aldo_probe(struct platform_device *pdev)
805 return 0; 796 return 0;
806} 797}
807 798
808static int __devexit lp8788_aldo_remove(struct platform_device *pdev) 799static int lp8788_aldo_remove(struct platform_device *pdev)
809{ 800{
810 struct lp8788_ldo *ldo = platform_get_drvdata(pdev); 801 struct lp8788_ldo *ldo = platform_get_drvdata(pdev);
811 802
@@ -817,7 +808,7 @@ static int __devexit lp8788_aldo_remove(struct platform_device *pdev)
817 808
818static struct platform_driver lp8788_aldo_driver = { 809static struct platform_driver lp8788_aldo_driver = {
819 .probe = lp8788_aldo_probe, 810 .probe = lp8788_aldo_probe,
820 .remove = __devexit_p(lp8788_aldo_remove), 811 .remove = lp8788_aldo_remove,
821 .driver = { 812 .driver = {
822 .name = LP8788_DEV_ALDO, 813 .name = LP8788_DEV_ALDO,
823 .owner = THIS_MODULE, 814 .owner = THIS_MODULE,
diff --git a/drivers/regulator/max1586.c b/drivers/regulator/max1586.c
index f67af3c1b963..8c5a54f541b5 100644
--- a/drivers/regulator/max1586.c
+++ b/drivers/regulator/max1586.c
@@ -44,6 +44,9 @@ struct max1586_data {
44 unsigned int min_uV; 44 unsigned int min_uV;
45 unsigned int max_uV; 45 unsigned int max_uV;
46 46
47 unsigned int v3_curr_sel;
48 unsigned int v6_curr_sel;
49
47 struct regulator_dev *rdev[0]; 50 struct regulator_dev *rdev[0];
48}; 51};
49 52
@@ -63,31 +66,60 @@ static int v6_voltages_uv[] = { 1, 1800000, 2500000, 3000000 };
63 * R24 and R25=100kOhm as described in the data sheet. 66 * R24 and R25=100kOhm as described in the data sheet.
64 * The gain is approximately: 1 + R24/R25 + R24/185.5kOhm 67 * The gain is approximately: 1 + R24/R25 + R24/185.5kOhm
65 */ 68 */
69static int max1586_v3_get_voltage_sel(struct regulator_dev *rdev)
70{
71 struct max1586_data *max1586 = rdev_get_drvdata(rdev);
72
73 return max1586->v3_curr_sel;
74}
75
66static int max1586_v3_set_voltage_sel(struct regulator_dev *rdev, 76static int max1586_v3_set_voltage_sel(struct regulator_dev *rdev,
67 unsigned selector) 77 unsigned selector)
68{ 78{
69 struct max1586_data *max1586 = rdev_get_drvdata(rdev); 79 struct max1586_data *max1586 = rdev_get_drvdata(rdev);
70 struct i2c_client *client = max1586->client; 80 struct i2c_client *client = max1586->client;
81 int ret;
71 u8 v3_prog; 82 u8 v3_prog;
72 83
73 dev_dbg(&client->dev, "changing voltage v3 to %dmv\n", 84 dev_dbg(&client->dev, "changing voltage v3 to %dmv\n",
74 regulator_list_voltage_linear(rdev, selector) / 1000); 85 regulator_list_voltage_linear(rdev, selector) / 1000);
75 86
76 v3_prog = I2C_V3_SELECT | (u8) selector; 87 v3_prog = I2C_V3_SELECT | (u8) selector;
77 return i2c_smbus_write_byte(client, v3_prog); 88 ret = i2c_smbus_write_byte(client, v3_prog);
89 if (ret)
90 return ret;
91
92 max1586->v3_curr_sel = selector;
93
94 return 0;
95}
96
97static int max1586_v6_get_voltage_sel(struct regulator_dev *rdev)
98{
99 struct max1586_data *max1586 = rdev_get_drvdata(rdev);
100
101 return max1586->v6_curr_sel;
78} 102}
79 103
80static int max1586_v6_set_voltage_sel(struct regulator_dev *rdev, 104static int max1586_v6_set_voltage_sel(struct regulator_dev *rdev,
81 unsigned int selector) 105 unsigned int selector)
82{ 106{
83 struct i2c_client *client = rdev_get_drvdata(rdev); 107 struct max1586_data *max1586 = rdev_get_drvdata(rdev);
108 struct i2c_client *client = max1586->client;
84 u8 v6_prog; 109 u8 v6_prog;
110 int ret;
85 111
86 dev_dbg(&client->dev, "changing voltage v6 to %dmv\n", 112 dev_dbg(&client->dev, "changing voltage v6 to %dmv\n",
87 rdev->desc->volt_table[selector] / 1000); 113 rdev->desc->volt_table[selector] / 1000);
88 114
89 v6_prog = I2C_V6_SELECT | (u8) selector; 115 v6_prog = I2C_V6_SELECT | (u8) selector;
90 return i2c_smbus_write_byte(client, v6_prog); 116 ret = i2c_smbus_write_byte(client, v6_prog);
117 if (ret)
118 return ret;
119
120 max1586->v6_curr_sel = selector;
121
122 return 0;
91} 123}
92 124
93/* 125/*
@@ -95,12 +127,14 @@ static int max1586_v6_set_voltage_sel(struct regulator_dev *rdev,
95 * the set up value. 127 * the set up value.
96 */ 128 */
97static struct regulator_ops max1586_v3_ops = { 129static struct regulator_ops max1586_v3_ops = {
130 .get_voltage_sel = max1586_v3_get_voltage_sel,
98 .set_voltage_sel = max1586_v3_set_voltage_sel, 131 .set_voltage_sel = max1586_v3_set_voltage_sel,
99 .list_voltage = regulator_list_voltage_linear, 132 .list_voltage = regulator_list_voltage_linear,
100 .map_voltage = regulator_map_voltage_linear, 133 .map_voltage = regulator_map_voltage_linear,
101}; 134};
102 135
103static struct regulator_ops max1586_v6_ops = { 136static struct regulator_ops max1586_v6_ops = {
137 .get_voltage_sel = max1586_v6_get_voltage_sel,
104 .set_voltage_sel = max1586_v6_set_voltage_sel, 138 .set_voltage_sel = max1586_v6_set_voltage_sel,
105 .list_voltage = regulator_list_voltage_table, 139 .list_voltage = regulator_list_voltage_table,
106}; 140};
@@ -125,7 +159,7 @@ static struct regulator_desc max1586_reg[] = {
125 }, 159 },
126}; 160};
127 161
128static int __devinit max1586_pmic_probe(struct i2c_client *client, 162static int max1586_pmic_probe(struct i2c_client *client,
129 const struct i2c_device_id *i2c_id) 163 const struct i2c_device_id *i2c_id)
130{ 164{
131 struct regulator_dev **rdev; 165 struct regulator_dev **rdev;
@@ -148,6 +182,10 @@ static int __devinit max1586_pmic_probe(struct i2c_client *client,
148 max1586->min_uV = MAX1586_V3_MIN_UV / 1000 * pdata->v3_gain / 1000; 182 max1586->min_uV = MAX1586_V3_MIN_UV / 1000 * pdata->v3_gain / 1000;
149 max1586->max_uV = MAX1586_V3_MAX_UV / 1000 * pdata->v3_gain / 1000; 183 max1586->max_uV = MAX1586_V3_MAX_UV / 1000 * pdata->v3_gain / 1000;
150 184
185 /* Set curr_sel to default voltage on power-up */
186 max1586->v3_curr_sel = 24; /* 1.3V */
187 max1586->v6_curr_sel = 0;
188
151 rdev = max1586->rdev; 189 rdev = max1586->rdev;
152 for (i = 0; i < pdata->num_subdevs && i <= MAX1586_V6; i++) { 190 for (i = 0; i < pdata->num_subdevs && i <= MAX1586_V6; i++) {
153 id = pdata->subdevs[i].id; 191 id = pdata->subdevs[i].id;
@@ -188,7 +226,7 @@ err:
188 return ret; 226 return ret;
189} 227}
190 228
191static int __devexit max1586_pmic_remove(struct i2c_client *client) 229static int max1586_pmic_remove(struct i2c_client *client)
192{ 230{
193 struct max1586_data *max1586 = i2c_get_clientdata(client); 231 struct max1586_data *max1586 = i2c_get_clientdata(client);
194 int i; 232 int i;
@@ -207,7 +245,7 @@ MODULE_DEVICE_TABLE(i2c, max1586_id);
207 245
208static struct i2c_driver max1586_pmic_driver = { 246static struct i2c_driver max1586_pmic_driver = {
209 .probe = max1586_pmic_probe, 247 .probe = max1586_pmic_probe,
210 .remove = __devexit_p(max1586_pmic_remove), 248 .remove = max1586_pmic_remove,
211 .driver = { 249 .driver = {
212 .name = "max1586", 250 .name = "max1586",
213 .owner = THIS_MODULE, 251 .owner = THIS_MODULE,
diff --git a/drivers/regulator/max77686.c b/drivers/regulator/max77686.c
index 2a67d08658ad..b85040caaea3 100644
--- a/drivers/regulator/max77686.c
+++ b/drivers/regulator/max77686.c
@@ -67,8 +67,94 @@ enum max77686_ramp_rate {
67 67
68struct max77686_data { 68struct max77686_data {
69 struct regulator_dev *rdev[MAX77686_REGULATORS]; 69 struct regulator_dev *rdev[MAX77686_REGULATORS];
70 unsigned int opmode[MAX77686_REGULATORS];
70}; 71};
71 72
73/* Some BUCKS supports Normal[ON/OFF] mode during suspend */
74static int max77686_buck_set_suspend_disable(struct regulator_dev *rdev)
75{
76 unsigned int val;
77 struct max77686_data *max77686 = rdev_get_drvdata(rdev);
78
79 if (rdev->desc->id == MAX77686_BUCK1)
80 val = 0x1;
81 else
82 val = 0x1 << MAX77686_OPMODE_BUCK234_SHIFT;
83
84 max77686->opmode[rdev->desc->id] = val;
85 return regmap_update_bits(rdev->regmap, rdev->desc->enable_reg,
86 rdev->desc->enable_mask,
87 val);
88}
89
90/* Some LDOs supports [LPM/Normal]ON mode during suspend state */
91static int max77686_set_suspend_mode(struct regulator_dev *rdev,
92 unsigned int mode)
93{
94 struct max77686_data *max77686 = rdev_get_drvdata(rdev);
95 unsigned int val;
96
97 /* BUCK[5-9] doesn't support this feature */
98 if (rdev->desc->id >= MAX77686_BUCK5)
99 return 0;
100
101 switch (mode) {
102 case REGULATOR_MODE_IDLE: /* ON in LP Mode */
103 val = 0x2 << MAX77686_OPMODE_SHIFT;
104 break;
105 case REGULATOR_MODE_NORMAL: /* ON in Normal Mode */
106 val = 0x3 << MAX77686_OPMODE_SHIFT;
107 break;
108 default:
109 pr_warn("%s: regulator_suspend_mode : 0x%x not supported\n",
110 rdev->desc->name, mode);
111 return -EINVAL;
112 }
113
114 max77686->opmode[rdev->desc->id] = val;
115 return regmap_update_bits(rdev->regmap, rdev->desc->enable_reg,
116 rdev->desc->enable_mask,
117 val);
118}
119
120/* Some LDOs supports LPM-ON/OFF/Normal-ON mode during suspend state */
121static int max77686_ldo_set_suspend_mode(struct regulator_dev *rdev,
122 unsigned int mode)
123{
124 unsigned int val;
125 struct max77686_data *max77686 = rdev_get_drvdata(rdev);
126
127 switch (mode) {
128 case REGULATOR_MODE_STANDBY: /* switch off */
129 val = 0x1 << MAX77686_OPMODE_SHIFT;
130 break;
131 case REGULATOR_MODE_IDLE: /* ON in LP Mode */
132 val = 0x2 << MAX77686_OPMODE_SHIFT;
133 break;
134 case REGULATOR_MODE_NORMAL: /* ON in Normal Mode */
135 val = 0x3 << MAX77686_OPMODE_SHIFT;
136 break;
137 default:
138 pr_warn("%s: regulator_suspend_mode : 0x%x not supported\n",
139 rdev->desc->name, mode);
140 return -EINVAL;
141 }
142
143 max77686->opmode[rdev->desc->id] = val;
144 return regmap_update_bits(rdev->regmap, rdev->desc->enable_reg,
145 rdev->desc->enable_mask,
146 val);
147}
148
149static int max77686_enable(struct regulator_dev *rdev)
150{
151 struct max77686_data *max77686 = rdev_get_drvdata(rdev);
152
153 return regmap_update_bits(rdev->regmap, rdev->desc->enable_reg,
154 rdev->desc->enable_mask,
155 max77686->opmode[rdev->desc->id]);
156}
157
72static int max77686_set_ramp_delay(struct regulator_dev *rdev, int ramp_delay) 158static int max77686_set_ramp_delay(struct regulator_dev *rdev, int ramp_delay)
73{ 159{
74 unsigned int ramp_value = RAMP_RATE_NO_CTRL; 160 unsigned int ramp_value = RAMP_RATE_NO_CTRL;
@@ -98,23 +184,49 @@ static struct regulator_ops max77686_ops = {
98 .list_voltage = regulator_list_voltage_linear, 184 .list_voltage = regulator_list_voltage_linear,
99 .map_voltage = regulator_map_voltage_linear, 185 .map_voltage = regulator_map_voltage_linear,
100 .is_enabled = regulator_is_enabled_regmap, 186 .is_enabled = regulator_is_enabled_regmap,
101 .enable = regulator_enable_regmap, 187 .enable = max77686_enable,
188 .disable = regulator_disable_regmap,
189 .get_voltage_sel = regulator_get_voltage_sel_regmap,
190 .set_voltage_sel = regulator_set_voltage_sel_regmap,
191 .set_voltage_time_sel = regulator_set_voltage_time_sel,
192 .set_suspend_mode = max77686_set_suspend_mode,
193};
194
195static struct regulator_ops max77686_ldo_ops = {
196 .list_voltage = regulator_list_voltage_linear,
197 .map_voltage = regulator_map_voltage_linear,
198 .is_enabled = regulator_is_enabled_regmap,
199 .enable = max77686_enable,
102 .disable = regulator_disable_regmap, 200 .disable = regulator_disable_regmap,
103 .get_voltage_sel = regulator_get_voltage_sel_regmap, 201 .get_voltage_sel = regulator_get_voltage_sel_regmap,
104 .set_voltage_sel = regulator_set_voltage_sel_regmap, 202 .set_voltage_sel = regulator_set_voltage_sel_regmap,
105 .set_voltage_time_sel = regulator_set_voltage_time_sel, 203 .set_voltage_time_sel = regulator_set_voltage_time_sel,
204 .set_suspend_mode = max77686_ldo_set_suspend_mode,
205};
206
207static struct regulator_ops max77686_buck1_ops = {
208 .list_voltage = regulator_list_voltage_linear,
209 .map_voltage = regulator_map_voltage_linear,
210 .is_enabled = regulator_is_enabled_regmap,
211 .enable = max77686_enable,
212 .disable = regulator_disable_regmap,
213 .get_voltage_sel = regulator_get_voltage_sel_regmap,
214 .set_voltage_sel = regulator_set_voltage_sel_regmap,
215 .set_voltage_time_sel = regulator_set_voltage_time_sel,
216 .set_suspend_disable = max77686_buck_set_suspend_disable,
106}; 217};
107 218
108static struct regulator_ops max77686_buck_dvs_ops = { 219static struct regulator_ops max77686_buck_dvs_ops = {
109 .list_voltage = regulator_list_voltage_linear, 220 .list_voltage = regulator_list_voltage_linear,
110 .map_voltage = regulator_map_voltage_linear, 221 .map_voltage = regulator_map_voltage_linear,
111 .is_enabled = regulator_is_enabled_regmap, 222 .is_enabled = regulator_is_enabled_regmap,
112 .enable = regulator_enable_regmap, 223 .enable = max77686_enable,
113 .disable = regulator_disable_regmap, 224 .disable = regulator_disable_regmap,
114 .get_voltage_sel = regulator_get_voltage_sel_regmap, 225 .get_voltage_sel = regulator_get_voltage_sel_regmap,
115 .set_voltage_sel = regulator_set_voltage_sel_regmap, 226 .set_voltage_sel = regulator_set_voltage_sel_regmap,
116 .set_voltage_time_sel = regulator_set_voltage_time_sel, 227 .set_voltage_time_sel = regulator_set_voltage_time_sel,
117 .set_ramp_delay = max77686_set_ramp_delay, 228 .set_ramp_delay = max77686_set_ramp_delay,
229 .set_suspend_disable = max77686_buck_set_suspend_disable,
118}; 230};
119 231
120#define regulator_desc_ldo(num) { \ 232#define regulator_desc_ldo(num) { \
@@ -133,9 +245,41 @@ static struct regulator_ops max77686_buck_dvs_ops = {
133 .enable_mask = MAX77686_OPMODE_MASK \ 245 .enable_mask = MAX77686_OPMODE_MASK \
134 << MAX77686_OPMODE_SHIFT, \ 246 << MAX77686_OPMODE_SHIFT, \
135} 247}
248#define regulator_desc_lpm_ldo(num) { \
249 .name = "LDO"#num, \
250 .id = MAX77686_LDO##num, \
251 .ops = &max77686_ldo_ops, \
252 .type = REGULATOR_VOLTAGE, \
253 .owner = THIS_MODULE, \
254 .min_uV = MAX77686_LDO_MINUV, \
255 .uV_step = MAX77686_LDO_UVSTEP, \
256 .ramp_delay = MAX77686_RAMP_DELAY, \
257 .n_voltages = MAX77686_VSEL_MASK + 1, \
258 .vsel_reg = MAX77686_REG_LDO1CTRL1 + num - 1, \
259 .vsel_mask = MAX77686_VSEL_MASK, \
260 .enable_reg = MAX77686_REG_LDO1CTRL1 + num - 1, \
261 .enable_mask = MAX77686_OPMODE_MASK \
262 << MAX77686_OPMODE_SHIFT, \
263}
136#define regulator_desc_ldo_low(num) { \ 264#define regulator_desc_ldo_low(num) { \
137 .name = "LDO"#num, \ 265 .name = "LDO"#num, \
138 .id = MAX77686_LDO##num, \ 266 .id = MAX77686_LDO##num, \
267 .ops = &max77686_ldo_ops, \
268 .type = REGULATOR_VOLTAGE, \
269 .owner = THIS_MODULE, \
270 .min_uV = MAX77686_LDO_LOW_MINUV, \
271 .uV_step = MAX77686_LDO_LOW_UVSTEP, \
272 .ramp_delay = MAX77686_RAMP_DELAY, \
273 .n_voltages = MAX77686_VSEL_MASK + 1, \
274 .vsel_reg = MAX77686_REG_LDO1CTRL1 + num - 1, \
275 .vsel_mask = MAX77686_VSEL_MASK, \
276 .enable_reg = MAX77686_REG_LDO1CTRL1 + num - 1, \
277 .enable_mask = MAX77686_OPMODE_MASK \
278 << MAX77686_OPMODE_SHIFT, \
279}
280#define regulator_desc_ldo1_low(num) { \
281 .name = "LDO"#num, \
282 .id = MAX77686_LDO##num, \
139 .ops = &max77686_ops, \ 283 .ops = &max77686_ops, \
140 .type = REGULATOR_VOLTAGE, \ 284 .type = REGULATOR_VOLTAGE, \
141 .owner = THIS_MODULE, \ 285 .owner = THIS_MODULE, \
@@ -167,7 +311,7 @@ static struct regulator_ops max77686_buck_dvs_ops = {
167#define regulator_desc_buck1(num) { \ 311#define regulator_desc_buck1(num) { \
168 .name = "BUCK"#num, \ 312 .name = "BUCK"#num, \
169 .id = MAX77686_BUCK##num, \ 313 .id = MAX77686_BUCK##num, \
170 .ops = &max77686_ops, \ 314 .ops = &max77686_buck1_ops, \
171 .type = REGULATOR_VOLTAGE, \ 315 .type = REGULATOR_VOLTAGE, \
172 .owner = THIS_MODULE, \ 316 .owner = THIS_MODULE, \
173 .min_uV = MAX77686_BUCK_MINUV, \ 317 .min_uV = MAX77686_BUCK_MINUV, \
@@ -197,7 +341,7 @@ static struct regulator_ops max77686_buck_dvs_ops = {
197} 341}
198 342
199static struct regulator_desc regulators[] = { 343static struct regulator_desc regulators[] = {
200 regulator_desc_ldo_low(1), 344 regulator_desc_ldo1_low(1),
201 regulator_desc_ldo_low(2), 345 regulator_desc_ldo_low(2),
202 regulator_desc_ldo(3), 346 regulator_desc_ldo(3),
203 regulator_desc_ldo(4), 347 regulator_desc_ldo(4),
@@ -206,13 +350,13 @@ static struct regulator_desc regulators[] = {
206 regulator_desc_ldo_low(7), 350 regulator_desc_ldo_low(7),
207 regulator_desc_ldo_low(8), 351 regulator_desc_ldo_low(8),
208 regulator_desc_ldo(9), 352 regulator_desc_ldo(9),
209 regulator_desc_ldo(10), 353 regulator_desc_lpm_ldo(10),
210 regulator_desc_ldo(11), 354 regulator_desc_lpm_ldo(11),
211 regulator_desc_ldo(12), 355 regulator_desc_lpm_ldo(12),
212 regulator_desc_ldo(13), 356 regulator_desc_ldo(13),
213 regulator_desc_ldo(14), 357 regulator_desc_lpm_ldo(14),
214 regulator_desc_ldo_low(15), 358 regulator_desc_ldo_low(15),
215 regulator_desc_ldo(16), 359 regulator_desc_lpm_ldo(16),
216 regulator_desc_ldo(17), 360 regulator_desc_ldo(17),
217 regulator_desc_ldo(18), 361 regulator_desc_ldo(18),
218 regulator_desc_ldo(19), 362 regulator_desc_ldo(19),
@@ -280,7 +424,7 @@ static int max77686_pmic_dt_parse_pdata(struct max77686_dev *iodev,
280} 424}
281#endif /* CONFIG_OF */ 425#endif /* CONFIG_OF */
282 426
283static __devinit int max77686_pmic_probe(struct platform_device *pdev) 427static int max77686_pmic_probe(struct platform_device *pdev)
284{ 428{
285 struct max77686_dev *iodev = dev_get_drvdata(pdev->dev.parent); 429 struct max77686_dev *iodev = dev_get_drvdata(pdev->dev.parent);
286 struct max77686_platform_data *pdata = dev_get_platdata(iodev->dev); 430 struct max77686_platform_data *pdata = dev_get_platdata(iodev->dev);
@@ -314,12 +458,14 @@ static __devinit int max77686_pmic_probe(struct platform_device *pdev)
314 458
315 config.dev = &pdev->dev; 459 config.dev = &pdev->dev;
316 config.regmap = iodev->regmap; 460 config.regmap = iodev->regmap;
461 config.driver_data = max77686;
317 platform_set_drvdata(pdev, max77686); 462 platform_set_drvdata(pdev, max77686);
318 463
319 for (i = 0; i < MAX77686_REGULATORS; i++) { 464 for (i = 0; i < MAX77686_REGULATORS; i++) {
320 config.init_data = pdata->regulators[i].initdata; 465 config.init_data = pdata->regulators[i].initdata;
321 config.of_node = pdata->regulators[i].of_node; 466 config.of_node = pdata->regulators[i].of_node;
322 467
468 max77686->opmode[i] = regulators[i].enable_mask;
323 max77686->rdev[i] = regulator_register(&regulators[i], &config); 469 max77686->rdev[i] = regulator_register(&regulators[i], &config);
324 if (IS_ERR(max77686->rdev[i])) { 470 if (IS_ERR(max77686->rdev[i])) {
325 ret = PTR_ERR(max77686->rdev[i]); 471 ret = PTR_ERR(max77686->rdev[i]);
@@ -337,7 +483,7 @@ err:
337 return ret; 483 return ret;
338} 484}
339 485
340static int __devexit max77686_pmic_remove(struct platform_device *pdev) 486static int max77686_pmic_remove(struct platform_device *pdev)
341{ 487{
342 struct max77686_data *max77686 = platform_get_drvdata(pdev); 488 struct max77686_data *max77686 = platform_get_drvdata(pdev);
343 int i; 489 int i;
@@ -360,7 +506,7 @@ static struct platform_driver max77686_pmic_driver = {
360 .owner = THIS_MODULE, 506 .owner = THIS_MODULE,
361 }, 507 },
362 .probe = max77686_pmic_probe, 508 .probe = max77686_pmic_probe,
363 .remove = __devexit_p(max77686_pmic_remove), 509 .remove = max77686_pmic_remove,
364 .id_table = max77686_pmic_id, 510 .id_table = max77686_pmic_id,
365}; 511};
366 512
diff --git a/drivers/regulator/max8649.c b/drivers/regulator/max8649.c
index 9d540cd02dab..3ca14380f22d 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 8d531742f593..4d7c635c36c2 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 af7607515ab9..d1a77512d83e 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 9bb0be37495f..446a85445553 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 355ca7bad9d5..fc7935a19e3a 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/max8973-regulator.c b/drivers/regulator/max8973-regulator.c
new file mode 100644
index 000000000000..3ee26387b121
--- /dev/null
+++ b/drivers/regulator/max8973-regulator.c
@@ -0,0 +1,505 @@
1/*
2 * max8973-regulator.c -- Maxim max8973
3 *
4 * Regulator driver for MAXIM 8973 DC-DC step-down switching regulator.
5 *
6 * Copyright (c) 2012, NVIDIA Corporation.
7 *
8 * Author: Laxman Dewangan <ldewangan@nvidia.com>
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License as
12 * published by the Free Software Foundation version 2.
13 *
14 * This program is distributed "as is" WITHOUT ANY WARRANTY of any kind,
15 * whether express or implied; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
22 * 02111-1307, USA
23 */
24
25#include <linux/kernel.h>
26#include <linux/module.h>
27#include <linux/init.h>
28#include <linux/err.h>
29#include <linux/platform_device.h>
30#include <linux/regulator/driver.h>
31#include <linux/regulator/machine.h>
32#include <linux/regulator/max8973-regulator.h>
33#include <linux/gpio.h>
34#include <linux/i2c.h>
35#include <linux/slab.h>
36#include <linux/regmap.h>
37
38/* Register definitions */
39#define MAX8973_VOUT 0x0
40#define MAX8973_VOUT_DVS 0x1
41#define MAX8973_CONTROL1 0x2
42#define MAX8973_CONTROL2 0x3
43#define MAX8973_CHIPID1 0x4
44#define MAX8973_CHIPID2 0x5
45
46#define MAX8973_MAX_VOUT_REG 2
47
48/* MAX8973_VOUT */
49#define MAX8973_VOUT_ENABLE BIT(7)
50#define MAX8973_VOUT_MASK 0x7F
51
52/* MAX8973_VOUT_DVS */
53#define MAX8973_DVS_VOUT_MASK 0x7F
54
55/* MAX8973_CONTROL1 */
56#define MAX8973_SNS_ENABLE BIT(7)
57#define MAX8973_FPWM_EN_M BIT(6)
58#define MAX8973_NFSR_ENABLE BIT(5)
59#define MAX8973_AD_ENABLE BIT(4)
60#define MAX8973_BIAS_ENABLE BIT(3)
61#define MAX8973_FREQSHIFT_9PER BIT(2)
62
63#define MAX8973_RAMP_12mV_PER_US 0x0
64#define MAX8973_RAMP_25mV_PER_US 0x1
65#define MAX8973_RAMP_50mV_PER_US 0x2
66#define MAX8973_RAMP_200mV_PER_US 0x3
67
68/* MAX8973_CONTROL2 */
69#define MAX8973_WDTMR_ENABLE BIT(6)
70#define MAX8973_DISCH_ENBABLE BIT(5)
71#define MAX8973_FT_ENABLE BIT(4)
72
73#define MAX8973_CKKADV_TRIP_DISABLE 0xC
74#define MAX8973_CKKADV_TRIP_75mV_PER_US 0x0
75#define MAX8973_CKKADV_TRIP_150mV_PER_US 0x4
76#define MAX8973_CKKADV_TRIP_75mV_PER_US_HIST_DIS 0x8
77#define MAX8973_CONTROL_CLKADV_TRIP_MASK 0x00030000
78
79#define MAX8973_INDUCTOR_MIN_30_PER 0x0
80#define MAX8973_INDUCTOR_NOMINAL 0x1
81#define MAX8973_INDUCTOR_PLUS_30_PER 0x2
82#define MAX8973_INDUCTOR_PLUS_60_PER 0x3
83#define MAX8973_CONTROL_INDUCTOR_VALUE_MASK 0x00300000
84
85#define MAX8973_MIN_VOLATGE 606250
86#define MAX8973_MAX_VOLATGE 1400000
87#define MAX8973_VOLATGE_STEP 6250
88#define MAX8973_BUCK_N_VOLTAGE 0x80
89
90/* Maxim 8973 chip information */
91struct max8973_chip {
92 struct device *dev;
93 struct regulator_desc desc;
94 struct regulator_dev *rdev;
95 struct regmap *regmap;
96 bool enable_external_control;
97 int dvs_gpio;
98 int lru_index[MAX8973_MAX_VOUT_REG];
99 int curr_vout_val[MAX8973_MAX_VOUT_REG];
100 int curr_vout_reg;
101 int curr_gpio_val;
102 bool valid_dvs_gpio;
103};
104
105/*
106 * find_voltage_set_register: Find new voltage configuration register (VOUT).
107 * The finding of the new VOUT register will be based on the LRU mechanism.
108 * Each VOUT register will have different voltage configured . This
109 * Function will look if any of the VOUT register have requested voltage set
110 * or not.
111 * - If it is already there then it will make that register as most
112 * recently used and return as found so that caller need not to set
113 * the VOUT register but need to set the proper gpios to select this
114 * VOUT register.
115 * - If requested voltage is not found then it will use the least
116 * recently mechanism to get new VOUT register for new configuration
117 * and will return not_found so that caller need to set new VOUT
118 * register and then gpios (both).
119 */
120static bool find_voltage_set_register(struct max8973_chip *tps,
121 int req_vsel, int *vout_reg, int *gpio_val)
122{
123 int i;
124 bool found = false;
125 int new_vout_reg = tps->lru_index[MAX8973_MAX_VOUT_REG - 1];
126 int found_index = MAX8973_MAX_VOUT_REG - 1;
127
128 for (i = 0; i < MAX8973_MAX_VOUT_REG; ++i) {
129 if (tps->curr_vout_val[tps->lru_index[i]] == req_vsel) {
130 new_vout_reg = tps->lru_index[i];
131 found_index = i;
132 found = true;
133 goto update_lru_index;
134 }
135 }
136
137update_lru_index:
138 for (i = found_index; i > 0; i--)
139 tps->lru_index[i] = tps->lru_index[i - 1];
140
141 tps->lru_index[0] = new_vout_reg;
142 *gpio_val = new_vout_reg;
143 *vout_reg = MAX8973_VOUT + new_vout_reg;
144 return found;
145}
146
147static int max8973_dcdc_get_voltage_sel(struct regulator_dev *rdev)
148{
149 struct max8973_chip *max = rdev_get_drvdata(rdev);
150 unsigned int data;
151 int ret;
152
153 ret = regmap_read(max->regmap, max->curr_vout_reg, &data);
154 if (ret < 0) {
155 dev_err(max->dev, "register %d read failed, err = %d\n",
156 max->curr_vout_reg, ret);
157 return ret;
158 }
159 return data & MAX8973_VOUT_MASK;
160}
161
162static int max8973_dcdc_set_voltage_sel(struct regulator_dev *rdev,
163 unsigned vsel)
164{
165 struct max8973_chip *max = rdev_get_drvdata(rdev);
166 int ret;
167 bool found = false;
168 int vout_reg = max->curr_vout_reg;
169 int gpio_val = max->curr_gpio_val;
170
171 /*
172 * If gpios are available to select the VOUT register then least
173 * recently used register for new configuration.
174 */
175 if (max->valid_dvs_gpio)
176 found = find_voltage_set_register(max, vsel,
177 &vout_reg, &gpio_val);
178
179 if (!found) {
180 ret = regmap_update_bits(max->regmap, vout_reg,
181 MAX8973_VOUT_MASK, vsel);
182 if (ret < 0) {
183 dev_err(max->dev, "register %d update failed, err %d\n",
184 vout_reg, ret);
185 return ret;
186 }
187 max->curr_vout_reg = vout_reg;
188 max->curr_vout_val[gpio_val] = vsel;
189 }
190
191 /* Select proper VOUT register vio gpios */
192 if (max->valid_dvs_gpio) {
193 gpio_set_value_cansleep(max->dvs_gpio, gpio_val & 0x1);
194 max->curr_gpio_val = gpio_val;
195 }
196 return 0;
197}
198
199static int max8973_dcdc_set_mode(struct regulator_dev *rdev, unsigned int mode)
200{
201 struct max8973_chip *max = rdev_get_drvdata(rdev);
202 int ret;
203 int pwm;
204
205 /* Enable force PWM mode in FAST mode only. */
206 switch (mode) {
207 case REGULATOR_MODE_FAST:
208 pwm = MAX8973_FPWM_EN_M;
209 break;
210
211 case REGULATOR_MODE_NORMAL:
212 pwm = 0;
213 break;
214
215 default:
216 return -EINVAL;
217 }
218
219 ret = regmap_update_bits(max->regmap, MAX8973_CONTROL1,
220 MAX8973_FPWM_EN_M, pwm);
221 if (ret < 0)
222 dev_err(max->dev, "register %d update failed, err %d\n",
223 MAX8973_CONTROL1, ret);
224 return ret;
225}
226
227static unsigned int max8973_dcdc_get_mode(struct regulator_dev *rdev)
228{
229 struct max8973_chip *max = rdev_get_drvdata(rdev);
230 unsigned int data;
231 int ret;
232
233 ret = regmap_read(max->regmap, MAX8973_CONTROL1, &data);
234 if (ret < 0) {
235 dev_err(max->dev, "register %d read failed, err %d\n",
236 MAX8973_CONTROL1, ret);
237 return ret;
238 }
239 return (data & MAX8973_FPWM_EN_M) ?
240 REGULATOR_MODE_FAST : REGULATOR_MODE_NORMAL;
241}
242
243static struct regulator_ops max8973_dcdc_ops = {
244 .get_voltage_sel = max8973_dcdc_get_voltage_sel,
245 .set_voltage_sel = max8973_dcdc_set_voltage_sel,
246 .list_voltage = regulator_list_voltage_linear,
247 .set_mode = max8973_dcdc_set_mode,
248 .get_mode = max8973_dcdc_get_mode,
249};
250
251static int __devinit max8973_init_dcdc(struct max8973_chip *max,
252 struct max8973_regulator_platform_data *pdata)
253{
254 int ret;
255 uint8_t control1 = 0;
256 uint8_t control2 = 0;
257
258 if (pdata->control_flags & MAX8973_CONTROL_REMOTE_SENSE_ENABLE)
259 control1 |= MAX8973_SNS_ENABLE;
260
261 if (!(pdata->control_flags & MAX8973_CONTROL_FALLING_SLEW_RATE_ENABLE))
262 control1 |= MAX8973_NFSR_ENABLE;
263
264 if (pdata->control_flags & MAX8973_CONTROL_OUTPUT_ACTIVE_DISCH_ENABLE)
265 control1 |= MAX8973_AD_ENABLE;
266
267 if (pdata->control_flags & MAX8973_CONTROL_BIAS_ENABLE)
268 control1 |= MAX8973_BIAS_ENABLE;
269
270 if (pdata->control_flags & MAX8973_CONTROL_FREQ_SHIFT_9PER_ENABLE)
271 control1 |= MAX8973_FREQSHIFT_9PER;
272
273 /* Set ramp delay */
274 if (pdata->reg_init_data &&
275 pdata->reg_init_data->constraints.ramp_delay) {
276 if (pdata->reg_init_data->constraints.ramp_delay < 25000)
277 control1 = MAX8973_RAMP_12mV_PER_US;
278 else if (pdata->reg_init_data->constraints.ramp_delay < 50000)
279 control1 = MAX8973_RAMP_25mV_PER_US;
280 else if (pdata->reg_init_data->constraints.ramp_delay < 200000)
281 control1 = MAX8973_RAMP_50mV_PER_US;
282 else
283 control1 = MAX8973_RAMP_200mV_PER_US;
284 } else {
285 control1 = MAX8973_RAMP_12mV_PER_US;
286 max->desc.ramp_delay = 12500;
287 }
288
289 if (!(pdata->control_flags & MAX8973_CONTROL_PULL_DOWN_ENABLE))
290 control2 |= MAX8973_DISCH_ENBABLE;
291
292 /* Clock advance trip configuration */
293 switch (pdata->control_flags & MAX8973_CONTROL_CLKADV_TRIP_MASK) {
294 case MAX8973_CONTROL_CLKADV_TRIP_DISABLED:
295 control2 |= MAX8973_CKKADV_TRIP_DISABLE;
296 break;
297
298 case MAX8973_CONTROL_CLKADV_TRIP_75mV_PER_US:
299 control2 |= MAX8973_CKKADV_TRIP_75mV_PER_US;
300 break;
301
302 case MAX8973_CONTROL_CLKADV_TRIP_150mV_PER_US:
303 control2 |= MAX8973_CKKADV_TRIP_150mV_PER_US;
304 break;
305
306 case MAX8973_CONTROL_CLKADV_TRIP_75mV_PER_US_HIST_DIS:
307 control2 |= MAX8973_CKKADV_TRIP_75mV_PER_US_HIST_DIS;
308 break;
309 }
310
311 /* Configure inductor value */
312 switch (pdata->control_flags & MAX8973_CONTROL_INDUCTOR_VALUE_MASK) {
313 case MAX8973_CONTROL_INDUCTOR_VALUE_NOMINAL:
314 control2 |= MAX8973_INDUCTOR_NOMINAL;
315 break;
316
317 case MAX8973_CONTROL_INDUCTOR_VALUE_MINUS_30_PER:
318 control2 |= MAX8973_INDUCTOR_MIN_30_PER;
319 break;
320
321 case MAX8973_CONTROL_INDUCTOR_VALUE_PLUS_30_PER:
322 control2 |= MAX8973_INDUCTOR_PLUS_30_PER;
323 break;
324
325 case MAX8973_CONTROL_INDUCTOR_VALUE_PLUS_60_PER:
326 control2 |= MAX8973_INDUCTOR_PLUS_60_PER;
327 break;
328 }
329
330 ret = regmap_write(max->regmap, MAX8973_CONTROL1, control1);
331 if (ret < 0) {
332 dev_err(max->dev, "register %d write failed, err = %d",
333 MAX8973_CONTROL1, ret);
334 return ret;
335 }
336
337 ret = regmap_write(max->regmap, MAX8973_CONTROL2, control2);
338 if (ret < 0) {
339 dev_err(max->dev, "register %d write failed, err = %d",
340 MAX8973_CONTROL2, ret);
341 return ret;
342 }
343
344 /* If external control is enabled then disable EN bit */
345 if (max->enable_external_control) {
346 ret = regmap_update_bits(max->regmap, MAX8973_VOUT,
347 MAX8973_VOUT_ENABLE, 0);
348 if (ret < 0)
349 dev_err(max->dev, "register %d update failed, err = %d",
350 MAX8973_VOUT, ret);
351 }
352 return ret;
353}
354
355static const struct regmap_config max8973_regmap_config = {
356 .reg_bits = 8,
357 .val_bits = 8,
358 .max_register = MAX8973_CHIPID2,
359 .cache_type = REGCACHE_RBTREE,
360};
361
362static int __devinit max8973_probe(struct i2c_client *client,
363 const struct i2c_device_id *id)
364{
365 struct max8973_regulator_platform_data *pdata;
366 struct regulator_config config = { };
367 struct regulator_dev *rdev;
368 struct max8973_chip *max;
369 int ret;
370
371 pdata = client->dev.platform_data;
372 if (!pdata) {
373 dev_err(&client->dev, "No Platform data");
374 return -EIO;
375 }
376
377 max = devm_kzalloc(&client->dev, sizeof(*max), GFP_KERNEL);
378 if (!max) {
379 dev_err(&client->dev, "Memory allocation for max failed\n");
380 return -ENOMEM;
381 }
382
383 max->regmap = devm_regmap_init_i2c(client, &max8973_regmap_config);
384 if (IS_ERR(max->regmap)) {
385 ret = PTR_ERR(max->regmap);
386 dev_err(&client->dev, "regmap init failed, err %d\n", ret);
387 return ret;
388 }
389
390 i2c_set_clientdata(client, max);
391 max->dev = &client->dev;
392 max->desc.name = id->name;
393 max->desc.id = 0;
394 max->desc.ops = &max8973_dcdc_ops;
395 max->desc.type = REGULATOR_VOLTAGE;
396 max->desc.owner = THIS_MODULE;
397 max->desc.min_uV = MAX8973_MIN_VOLATGE;
398 max->desc.uV_step = MAX8973_VOLATGE_STEP;
399 max->desc.n_voltages = MAX8973_BUCK_N_VOLTAGE;
400
401 if (!pdata->enable_ext_control) {
402 max->desc.enable_reg = MAX8973_VOUT;
403 max->desc.enable_mask = MAX8973_VOUT_ENABLE;
404 max8973_dcdc_ops.enable = regulator_enable_regmap;
405 max8973_dcdc_ops.disable = regulator_disable_regmap;
406 max8973_dcdc_ops.is_enabled = regulator_is_enabled_regmap;
407 }
408
409 max->enable_external_control = pdata->enable_ext_control;
410 max->dvs_gpio = pdata->dvs_gpio;
411 max->curr_gpio_val = pdata->dvs_def_state;
412 max->curr_vout_reg = MAX8973_VOUT + pdata->dvs_def_state;
413 max->lru_index[0] = max->curr_vout_reg;
414 max->valid_dvs_gpio = false;
415
416 if (gpio_is_valid(max->dvs_gpio)) {
417 int gpio_flags;
418 int i;
419
420 gpio_flags = (pdata->dvs_def_state) ?
421 GPIOF_OUT_INIT_HIGH : GPIOF_OUT_INIT_LOW;
422 ret = devm_gpio_request_one(&client->dev, max->dvs_gpio,
423 gpio_flags, "max8973-dvs");
424 if (ret) {
425 dev_err(&client->dev,
426 "gpio_request for gpio %d failed, err = %d\n",
427 max->dvs_gpio, ret);
428 return ret;
429 }
430 max->valid_dvs_gpio = true;
431
432 /*
433 * Initialize the lru index with vout_reg id
434 * The index 0 will be most recently used and
435 * set with the max->curr_vout_reg */
436 for (i = 0; i < MAX8973_MAX_VOUT_REG; ++i)
437 max->lru_index[i] = i;
438 max->lru_index[0] = max->curr_vout_reg;
439 max->lru_index[max->curr_vout_reg] = 0;
440 }
441
442 ret = max8973_init_dcdc(max, pdata);
443 if (ret < 0) {
444 dev_err(max->dev, "Max8973 Init failed, err = %d\n", ret);
445 return ret;
446 }
447
448 config.dev = &client->dev;
449 config.init_data = pdata->reg_init_data;
450 config.driver_data = max;
451 config.of_node = client->dev.of_node;
452 config.regmap = max->regmap;
453
454 /* Register the regulators */
455 rdev = regulator_register(&max->desc, &config);
456 if (IS_ERR(rdev)) {
457 ret = PTR_ERR(rdev);
458 dev_err(max->dev, "regulator register failed, err %d\n", ret);
459 return ret;
460 }
461
462 max->rdev = rdev;
463 return 0;
464}
465
466static int __devexit max8973_remove(struct i2c_client *client)
467{
468 struct max8973_chip *max = i2c_get_clientdata(client);
469
470 regulator_unregister(max->rdev);
471 return 0;
472}
473
474static const struct i2c_device_id max8973_id[] = {
475 {.name = "max8973",},
476 {},
477};
478
479MODULE_DEVICE_TABLE(i2c, max8973_id);
480
481static struct i2c_driver max8973_i2c_driver = {
482 .driver = {
483 .name = "max8973",
484 .owner = THIS_MODULE,
485 },
486 .probe = max8973_probe,
487 .remove = __devexit_p(max8973_remove),
488 .id_table = max8973_id,
489};
490
491static int __init max8973_init(void)
492{
493 return i2c_add_driver(&max8973_i2c_driver);
494}
495subsys_initcall(max8973_init);
496
497static void __exit max8973_cleanup(void)
498{
499 i2c_del_driver(&max8973_i2c_driver);
500}
501module_exit(max8973_cleanup);
502
503MODULE_AUTHOR("Laxman Dewangan <ldewangan@nvidia.com>");
504MODULE_DESCRIPTION("MAX8973 voltage regulator driver");
505MODULE_LICENSE("GPL v2");
diff --git a/drivers/regulator/max8997.c b/drivers/regulator/max8997.c
index e39a0c7260dc..df0eafb0dc7e 100644
--- a/drivers/regulator/max8997.c
+++ b/drivers/regulator/max8997.c
@@ -24,6 +24,7 @@
24#include <linux/bug.h> 24#include <linux/bug.h>
25#include <linux/err.h> 25#include <linux/err.h>
26#include <linux/gpio.h> 26#include <linux/gpio.h>
27#include <linux/of_gpio.h>
27#include <linux/slab.h> 28#include <linux/slab.h>
28#include <linux/module.h> 29#include <linux/module.h>
29#include <linux/platform_device.h> 30#include <linux/platform_device.h>
@@ -31,6 +32,7 @@
31#include <linux/regulator/machine.h> 32#include <linux/regulator/machine.h>
32#include <linux/mfd/max8997.h> 33#include <linux/mfd/max8997.h>
33#include <linux/mfd/max8997-private.h> 34#include <linux/mfd/max8997-private.h>
35#include <linux/regulator/of_regulator.h>
34 36
35struct max8997_data { 37struct max8997_data {
36 struct device *dev; 38 struct device *dev;
@@ -933,22 +935,163 @@ static struct regulator_desc regulators[] = {
933 max8997_charger_fixedstate_ops), 935 max8997_charger_fixedstate_ops),
934}; 936};
935 937
936static __devinit int max8997_pmic_probe(struct platform_device *pdev) 938#ifdef CONFIG_OF
939static int max8997_pmic_dt_parse_dvs_gpio(struct max8997_dev *iodev,
940 struct max8997_platform_data *pdata,
941 struct device_node *pmic_np)
942{
943 int i, gpio;
944
945 for (i = 0; i < 3; i++) {
946 gpio = of_get_named_gpio(pmic_np,
947 "max8997,pmic-buck125-dvs-gpios", i);
948 if (!gpio_is_valid(gpio)) {
949 dev_err(iodev->dev, "invalid gpio[%d]: %d\n", i, gpio);
950 return -EINVAL;
951 }
952 pdata->buck125_gpios[i] = gpio;
953 }
954 return 0;
955}
956
957static int max8997_pmic_dt_parse_pdata(struct max8997_dev *iodev,
958 struct max8997_platform_data *pdata)
959{
960 struct device_node *pmic_np, *regulators_np, *reg_np;
961 struct max8997_regulator_data *rdata;
962 unsigned int i, dvs_voltage_nr = 1, ret;
963
964 pmic_np = iodev->dev->of_node;
965 if (!pmic_np) {
966 dev_err(iodev->dev, "could not find pmic sub-node\n");
967 return -ENODEV;
968 }
969
970 regulators_np = of_find_node_by_name(pmic_np, "regulators");
971 if (!regulators_np) {
972 dev_err(iodev->dev, "could not find regulators sub-node\n");
973 return -EINVAL;
974 }
975
976 /* count the number of regulators to be supported in pmic */
977 pdata->num_regulators = 0;
978 for_each_child_of_node(regulators_np, reg_np)
979 pdata->num_regulators++;
980
981 rdata = devm_kzalloc(iodev->dev, sizeof(*rdata) *
982 pdata->num_regulators, GFP_KERNEL);
983 if (!rdata) {
984 dev_err(iodev->dev, "could not allocate memory for "
985 "regulator data\n");
986 return -ENOMEM;
987 }
988
989 pdata->regulators = rdata;
990 for_each_child_of_node(regulators_np, reg_np) {
991 for (i = 0; i < ARRAY_SIZE(regulators); i++)
992 if (!of_node_cmp(reg_np->name, regulators[i].name))
993 break;
994
995 if (i == ARRAY_SIZE(regulators)) {
996 dev_warn(iodev->dev, "don't know how to configure "
997 "regulator %s\n", reg_np->name);
998 continue;
999 }
1000
1001 rdata->id = i;
1002 rdata->initdata = of_get_regulator_init_data(
1003 iodev->dev, reg_np);
1004 rdata->reg_node = reg_np;
1005 rdata++;
1006 }
1007
1008 if (of_get_property(pmic_np, "max8997,pmic-buck1-uses-gpio-dvs", NULL))
1009 pdata->buck1_gpiodvs = true;
1010
1011 if (of_get_property(pmic_np, "max8997,pmic-buck2-uses-gpio-dvs", NULL))
1012 pdata->buck2_gpiodvs = true;
1013
1014 if (of_get_property(pmic_np, "max8997,pmic-buck5-uses-gpio-dvs", NULL))
1015 pdata->buck5_gpiodvs = true;
1016
1017 if (pdata->buck1_gpiodvs || pdata->buck2_gpiodvs ||
1018 pdata->buck5_gpiodvs) {
1019 ret = max8997_pmic_dt_parse_dvs_gpio(iodev, pdata, pmic_np);
1020 if (ret)
1021 return -EINVAL;
1022
1023 if (of_property_read_u32(pmic_np,
1024 "max8997,pmic-buck125-default-dvs-idx",
1025 &pdata->buck125_default_idx)) {
1026 pdata->buck125_default_idx = 0;
1027 } else {
1028 if (pdata->buck125_default_idx >= 8) {
1029 pdata->buck125_default_idx = 0;
1030 dev_info(iodev->dev, "invalid value for "
1031 "default dvs index, using 0 instead\n");
1032 }
1033 }
1034
1035 if (of_get_property(pmic_np,
1036 "max8997,pmic-ignore-gpiodvs-side-effect", NULL))
1037 pdata->ignore_gpiodvs_side_effect = true;
1038
1039 dvs_voltage_nr = 8;
1040 }
1041
1042 if (of_property_read_u32_array(pmic_np,
1043 "max8997,pmic-buck1-dvs-voltage",
1044 pdata->buck1_voltage, dvs_voltage_nr)) {
1045 dev_err(iodev->dev, "buck1 voltages not specified\n");
1046 return -EINVAL;
1047 }
1048
1049 if (of_property_read_u32_array(pmic_np,
1050 "max8997,pmic-buck2-dvs-voltage",
1051 pdata->buck2_voltage, dvs_voltage_nr)) {
1052 dev_err(iodev->dev, "buck2 voltages not specified\n");
1053 return -EINVAL;
1054 }
1055
1056 if (of_property_read_u32_array(pmic_np,
1057 "max8997,pmic-buck5-dvs-voltage",
1058 pdata->buck5_voltage, dvs_voltage_nr)) {
1059 dev_err(iodev->dev, "buck5 voltages not specified\n");
1060 return -EINVAL;
1061 }
1062
1063 return 0;
1064}
1065#else
1066static int max8997_pmic_dt_parse_pdata(struct max8997_dev *iodev,
1067 struct max8997_platform_data *pdata)
1068{
1069 return 0;
1070}
1071#endif /* CONFIG_OF */
1072
1073static int max8997_pmic_probe(struct platform_device *pdev)
937{ 1074{
938 struct max8997_dev *iodev = dev_get_drvdata(pdev->dev.parent); 1075 struct max8997_dev *iodev = dev_get_drvdata(pdev->dev.parent);
939 struct max8997_platform_data *pdata = dev_get_platdata(iodev->dev); 1076 struct max8997_platform_data *pdata = iodev->pdata;
940 struct regulator_config config = { }; 1077 struct regulator_config config = { };
941 struct regulator_dev **rdev; 1078 struct regulator_dev **rdev;
942 struct max8997_data *max8997; 1079 struct max8997_data *max8997;
943 struct i2c_client *i2c; 1080 struct i2c_client *i2c;
944 int i, ret, size; 1081 int i, ret, size, nr_dvs;
945 u8 max_buck1 = 0, max_buck2 = 0, max_buck5 = 0; 1082 u8 max_buck1 = 0, max_buck2 = 0, max_buck5 = 0;
946 1083
947 if (!pdata) { 1084 if (IS_ERR_OR_NULL(pdata)) {
948 dev_err(pdev->dev.parent, "No platform init data supplied.\n"); 1085 dev_err(pdev->dev.parent, "No platform init data supplied.\n");
949 return -ENODEV; 1086 return -ENODEV;
950 } 1087 }
951 1088
1089 if (iodev->dev->of_node) {
1090 ret = max8997_pmic_dt_parse_pdata(iodev, pdata);
1091 if (ret)
1092 return ret;
1093 }
1094
952 max8997 = devm_kzalloc(&pdev->dev, sizeof(struct max8997_data), 1095 max8997 = devm_kzalloc(&pdev->dev, sizeof(struct max8997_data),
953 GFP_KERNEL); 1096 GFP_KERNEL);
954 if (!max8997) 1097 if (!max8997)
@@ -973,7 +1116,10 @@ static __devinit int max8997_pmic_probe(struct platform_device *pdev)
973 memcpy(max8997->buck125_gpios, pdata->buck125_gpios, sizeof(int) * 3); 1116 memcpy(max8997->buck125_gpios, pdata->buck125_gpios, sizeof(int) * 3);
974 max8997->ignore_gpiodvs_side_effect = pdata->ignore_gpiodvs_side_effect; 1117 max8997->ignore_gpiodvs_side_effect = pdata->ignore_gpiodvs_side_effect;
975 1118
976 for (i = 0; i < 8; i++) { 1119 nr_dvs = (pdata->buck1_gpiodvs || pdata->buck2_gpiodvs ||
1120 pdata->buck5_gpiodvs) ? 8 : 1;
1121
1122 for (i = 0; i < nr_dvs; i++) {
977 max8997->buck1_vol[i] = ret = 1123 max8997->buck1_vol[i] = ret =
978 max8997_get_voltage_proper_val( 1124 max8997_get_voltage_proper_val(
979 &buck1245_voltage_map_desc, 1125 &buck1245_voltage_map_desc,
@@ -1019,6 +1165,19 @@ static __devinit int max8997_pmic_probe(struct platform_device *pdev)
1019 max_buck5, 0x3f); 1165 max_buck5, 0x3f);
1020 } 1166 }
1021 1167
1168 /* Initialize all the DVS related BUCK registers */
1169 for (i = 0; i < nr_dvs; i++) {
1170 max8997_update_reg(i2c, MAX8997_REG_BUCK1DVS1 + i,
1171 max8997->buck1_vol[i],
1172 0x3f);
1173 max8997_update_reg(i2c, MAX8997_REG_BUCK2DVS1 + i,
1174 max8997->buck2_vol[i],
1175 0x3f);
1176 max8997_update_reg(i2c, MAX8997_REG_BUCK5DVS1 + i,
1177 max8997->buck5_vol[i],
1178 0x3f);
1179 }
1180
1022 /* 1181 /*
1023 * If buck 1, 2, and 5 do not care DVS GPIO settings, ignore them. 1182 * If buck 1, 2, and 5 do not care DVS GPIO settings, ignore them.
1024 * If at least one of them cares, set gpios. 1183 * If at least one of them cares, set gpios.
@@ -1068,19 +1227,6 @@ static __devinit int max8997_pmic_probe(struct platform_device *pdev)
1068 max8997_update_reg(i2c, MAX8997_REG_BUCK5CTRL, (pdata->buck5_gpiodvs) ? 1227 max8997_update_reg(i2c, MAX8997_REG_BUCK5CTRL, (pdata->buck5_gpiodvs) ?
1069 (1 << 1) : (0 << 1), 1 << 1); 1228 (1 << 1) : (0 << 1), 1 << 1);
1070 1229
1071 /* Initialize all the DVS related BUCK registers */
1072 for (i = 0; i < 8; i++) {
1073 max8997_update_reg(i2c, MAX8997_REG_BUCK1DVS1 + i,
1074 max8997->buck1_vol[i],
1075 0x3f);
1076 max8997_update_reg(i2c, MAX8997_REG_BUCK2DVS1 + i,
1077 max8997->buck2_vol[i],
1078 0x3f);
1079 max8997_update_reg(i2c, MAX8997_REG_BUCK5DVS1 + i,
1080 max8997->buck5_vol[i],
1081 0x3f);
1082 }
1083
1084 /* Misc Settings */ 1230 /* Misc Settings */
1085 max8997->ramp_delay = 10; /* set 10mV/us, which is the default */ 1231 max8997->ramp_delay = 10; /* set 10mV/us, which is the default */
1086 max8997_write_reg(i2c, MAX8997_REG_BUCKRAMP, (0xf << 4) | 0x9); 1232 max8997_write_reg(i2c, MAX8997_REG_BUCKRAMP, (0xf << 4) | 0x9);
@@ -1101,6 +1247,7 @@ static __devinit int max8997_pmic_probe(struct platform_device *pdev)
1101 config.dev = max8997->dev; 1247 config.dev = max8997->dev;
1102 config.init_data = pdata->regulators[i].initdata; 1248 config.init_data = pdata->regulators[i].initdata;
1103 config.driver_data = max8997; 1249 config.driver_data = max8997;
1250 config.of_node = pdata->regulators[i].reg_node;
1104 1251
1105 rdev[i] = regulator_register(&regulators[id], &config); 1252 rdev[i] = regulator_register(&regulators[id], &config);
1106 if (IS_ERR(rdev[i])) { 1253 if (IS_ERR(rdev[i])) {
@@ -1120,7 +1267,7 @@ err_out:
1120 return ret; 1267 return ret;
1121} 1268}
1122 1269
1123static int __devexit max8997_pmic_remove(struct platform_device *pdev) 1270static int max8997_pmic_remove(struct platform_device *pdev)
1124{ 1271{
1125 struct max8997_data *max8997 = platform_get_drvdata(pdev); 1272 struct max8997_data *max8997 = platform_get_drvdata(pdev);
1126 struct regulator_dev **rdev = max8997->rdev; 1273 struct regulator_dev **rdev = max8997->rdev;
@@ -1143,7 +1290,7 @@ static struct platform_driver max8997_pmic_driver = {
1143 .owner = THIS_MODULE, 1290 .owner = THIS_MODULE,
1144 }, 1291 },
1145 .probe = max8997_pmic_probe, 1292 .probe = max8997_pmic_probe,
1146 .remove = __devexit_p(max8997_pmic_remove), 1293 .remove = max8997_pmic_remove,
1147 .id_table = max8997_pmic_id, 1294 .id_table = max8997_pmic_id,
1148}; 1295};
1149 1296
diff --git a/drivers/regulator/max8998.c b/drivers/regulator/max8998.c
index 5dfa920ff0c8..b821d08eb64a 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 0801a6d0c122..c46c6705cd74 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 1fa63812f7ac..0d84b1f33199 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 88cbb832d555..4ed89c654110 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 08fec06dba50..e915629a25cf 100644
--- a/drivers/regulator/palmas-regulator.c
+++ b/drivers/regulator/palmas-regulator.c
@@ -309,68 +309,22 @@ static int palmas_list_voltage_smps(struct regulator_dev *dev,
309 int id = rdev_get_id(dev); 309 int id = rdev_get_id(dev);
310 int mult = 1; 310 int mult = 1;
311 311
312 if (!selector)
313 return 0;
314
315 /* Read the multiplier set in VSEL register to return 312 /* Read the multiplier set in VSEL register to return
316 * the correct voltage. 313 * the correct voltage.
317 */ 314 */
318 if (pmic->range[id]) 315 if (pmic->range[id])
319 mult = 2; 316 mult = 2;
320 317
321 /* Voltage is (0.49V + (selector * 0.01V)) * RANGE 318 if (selector == 0)
322 * as defined in data sheet. RANGE is either x1 or x2 319 return 0;
323 */ 320 else if (selector < 6)
324 return (490000 + (selector * 10000)) * mult; 321 return 500000 * mult;
325} 322 else
326 323 /* Voltage is linear mapping starting from selector 6,
327static int palmas_get_voltage_smps_sel(struct regulator_dev *dev) 324 * volt = (0.49V + ((selector - 5) * 0.01V)) * RANGE
328{ 325 * RANGE is either x1 or x2
329 struct palmas_pmic *pmic = rdev_get_drvdata(dev); 326 */
330 int id = rdev_get_id(dev); 327 return (490000 + ((selector - 5) * 10000)) * mult;
331 int selector;
332 unsigned int reg;
333 unsigned int addr;
334
335 addr = palmas_regs_info[id].vsel_addr;
336
337 palmas_smps_read(pmic->palmas, addr, &reg);
338
339 selector = reg & PALMAS_SMPS12_VOLTAGE_VSEL_MASK;
340
341 /* Adjust selector to match list_voltage ranges */
342 if ((selector > 0) && (selector < 6))
343 selector = 6;
344 if (!selector)
345 selector = 5;
346 if (selector > 121)
347 selector = 121;
348 selector -= 5;
349
350 return selector;
351}
352
353static int palmas_set_voltage_smps_sel(struct regulator_dev *dev,
354 unsigned selector)
355{
356 struct palmas_pmic *pmic = rdev_get_drvdata(dev);
357 int id = rdev_get_id(dev);
358 unsigned int reg = 0;
359 unsigned int addr;
360
361 addr = palmas_regs_info[id].vsel_addr;
362
363 /* Make sure we don't change the value of RANGE */
364 if (pmic->range[id])
365 reg |= PALMAS_SMPS12_VOLTAGE_RANGE;
366
367 /* Adjust the linux selector into range used in VSEL register */
368 if (selector)
369 reg |= selector + 5;
370
371 palmas_smps_write(pmic->palmas, addr, reg);
372
373 return 0;
374} 328}
375 329
376static int palmas_map_voltage_smps(struct regulator_dev *rdev, 330static int palmas_map_voltage_smps(struct regulator_dev *rdev,
@@ -386,11 +340,11 @@ static int palmas_map_voltage_smps(struct regulator_dev *rdev,
386 if (pmic->range[id]) { /* RANGE is x2 */ 340 if (pmic->range[id]) { /* RANGE is x2 */
387 if (min_uV < 1000000) 341 if (min_uV < 1000000)
388 min_uV = 1000000; 342 min_uV = 1000000;
389 ret = DIV_ROUND_UP(min_uV - 1000000, 20000) + 1; 343 ret = DIV_ROUND_UP(min_uV - 1000000, 20000) + 6;
390 } else { /* RANGE is x1 */ 344 } else { /* RANGE is x1 */
391 if (min_uV < 500000) 345 if (min_uV < 500000)
392 min_uV = 500000; 346 min_uV = 500000;
393 ret = DIV_ROUND_UP(min_uV - 500000, 10000) + 1; 347 ret = DIV_ROUND_UP(min_uV - 500000, 10000) + 6;
394 } 348 }
395 349
396 /* Map back into a voltage to verify we're still in bounds */ 350 /* Map back into a voltage to verify we're still in bounds */
@@ -407,8 +361,8 @@ static struct regulator_ops palmas_ops_smps = {
407 .disable = palmas_disable_smps, 361 .disable = palmas_disable_smps,
408 .set_mode = palmas_set_mode_smps, 362 .set_mode = palmas_set_mode_smps,
409 .get_mode = palmas_get_mode_smps, 363 .get_mode = palmas_get_mode_smps,
410 .get_voltage_sel = palmas_get_voltage_smps_sel, 364 .get_voltage_sel = regulator_get_voltage_sel_regmap,
411 .set_voltage_sel = palmas_set_voltage_smps_sel, 365 .set_voltage_sel = regulator_set_voltage_sel_regmap,
412 .list_voltage = palmas_list_voltage_smps, 366 .list_voltage = palmas_list_voltage_smps,
413 .map_voltage = palmas_map_voltage_smps, 367 .map_voltage = palmas_map_voltage_smps,
414}; 368};
@@ -436,44 +390,14 @@ static int palmas_is_enabled_ldo(struct regulator_dev *dev)
436 return !!(reg); 390 return !!(reg);
437} 391}
438 392
439static int palmas_list_voltage_ldo(struct regulator_dev *dev,
440 unsigned selector)
441{
442 if (!selector)
443 return 0;
444
445 /* voltage is 0.85V + (selector * 0.05v) */
446 return 850000 + (selector * 50000);
447}
448
449static int palmas_map_voltage_ldo(struct regulator_dev *rdev,
450 int min_uV, int max_uV)
451{
452 int ret, voltage;
453
454 if (min_uV == 0)
455 return 0;
456
457 if (min_uV < 900000)
458 min_uV = 900000;
459 ret = DIV_ROUND_UP(min_uV - 900000, 50000) + 1;
460
461 /* Map back into a voltage to verify we're still in bounds */
462 voltage = palmas_list_voltage_ldo(rdev, ret);
463 if (voltage < min_uV || voltage > max_uV)
464 return -EINVAL;
465
466 return ret;
467}
468
469static struct regulator_ops palmas_ops_ldo = { 393static struct regulator_ops palmas_ops_ldo = {
470 .is_enabled = palmas_is_enabled_ldo, 394 .is_enabled = palmas_is_enabled_ldo,
471 .enable = regulator_enable_regmap, 395 .enable = regulator_enable_regmap,
472 .disable = regulator_disable_regmap, 396 .disable = regulator_disable_regmap,
473 .get_voltage_sel = regulator_get_voltage_sel_regmap, 397 .get_voltage_sel = regulator_get_voltage_sel_regmap,
474 .set_voltage_sel = regulator_set_voltage_sel_regmap, 398 .set_voltage_sel = regulator_set_voltage_sel_regmap,
475 .list_voltage = palmas_list_voltage_ldo, 399 .list_voltage = regulator_list_voltage_linear,
476 .map_voltage = palmas_map_voltage_ldo, 400 .map_voltage = regulator_map_voltage_linear,
477}; 401};
478 402
479/* 403/*
@@ -595,7 +519,7 @@ static struct of_regulator_match palmas_matches[] = {
595 { .name = "ldousb", }, 519 { .name = "ldousb", },
596}; 520};
597 521
598static void __devinit palmas_dt_to_pdata(struct device *dev, 522static void palmas_dt_to_pdata(struct device *dev,
599 struct device_node *node, 523 struct device_node *node,
600 struct palmas_pmic_platform_data *pdata) 524 struct palmas_pmic_platform_data *pdata)
601{ 525{
@@ -663,7 +587,7 @@ static void __devinit palmas_dt_to_pdata(struct device *dev,
663} 587}
664 588
665 589
666static __devinit int palmas_probe(struct platform_device *pdev) 590static int palmas_probe(struct platform_device *pdev)
667{ 591{
668 struct palmas *palmas = dev_get_drvdata(pdev->dev.parent); 592 struct palmas *palmas = dev_get_drvdata(pdev->dev.parent);
669 struct palmas_pmic_platform_data *pdata = pdev->dev.platform_data; 593 struct palmas_pmic_platform_data *pdata = pdev->dev.platform_data;
@@ -733,6 +657,14 @@ static __devinit int palmas_probe(struct platform_device *pdev)
733 continue; 657 continue;
734 } 658 }
735 659
660 /* Initialise sleep/init values from platform data */
661 if (pdata && pdata->reg_init[id]) {
662 reg_init = pdata->reg_init[id];
663 ret = palmas_smps_init(palmas, id, reg_init);
664 if (ret)
665 goto err_unregister_regulator;
666 }
667
736 /* Register the regulators */ 668 /* Register the regulators */
737 pmic->desc[id].name = palmas_regs_info[id].name; 669 pmic->desc[id].name = palmas_regs_info[id].name;
738 pmic->desc[id].id = id; 670 pmic->desc[id].id = id;
@@ -753,29 +685,11 @@ static __devinit int palmas_probe(struct platform_device *pdev)
753 pmic->desc[id].uV_step = 1250000; 685 pmic->desc[id].uV_step = 1250000;
754 break; 686 break;
755 default: 687 default:
756 pmic->desc[id].ops = &palmas_ops_smps; 688 /*
757 pmic->desc[id].n_voltages = PALMAS_SMPS_NUM_VOLTAGES; 689 * Read and store the RANGE bit for later use
758 } 690 * This must be done before regulator is probed,
759 691 * otherwise we error in probe with unsupportable ranges.
760 pmic->desc[id].type = REGULATOR_VOLTAGE; 692 */
761 pmic->desc[id].owner = THIS_MODULE;
762
763 /* Initialise sleep/init values from platform data */
764 if (pdata) {
765 reg_init = pdata->reg_init[id];
766 if (reg_init) {
767 ret = palmas_smps_init(palmas, id, reg_init);
768 if (ret)
769 goto err_unregister_regulator;
770 }
771 }
772
773 /*
774 * read and store the RANGE bit for later use
775 * This must be done before regulator is probed otherwise
776 * we error in probe with unsupportable ranges.
777 */
778 if (id != PALMAS_REG_SMPS10) {
779 addr = palmas_regs_info[id].vsel_addr; 693 addr = palmas_regs_info[id].vsel_addr;
780 694
781 ret = palmas_smps_read(pmic->palmas, addr, &reg); 695 ret = palmas_smps_read(pmic->palmas, addr, &reg);
@@ -783,8 +697,19 @@ static __devinit int palmas_probe(struct platform_device *pdev)
783 goto err_unregister_regulator; 697 goto err_unregister_regulator;
784 if (reg & PALMAS_SMPS12_VOLTAGE_RANGE) 698 if (reg & PALMAS_SMPS12_VOLTAGE_RANGE)
785 pmic->range[id] = 1; 699 pmic->range[id] = 1;
700
701 pmic->desc[id].ops = &palmas_ops_smps;
702 pmic->desc[id].n_voltages = PALMAS_SMPS_NUM_VOLTAGES;
703 pmic->desc[id].vsel_reg =
704 PALMAS_BASE_TO_REG(PALMAS_SMPS_BASE,
705 palmas_regs_info[id].vsel_addr);
706 pmic->desc[id].vsel_mask =
707 PALMAS_SMPS12_VOLTAGE_VSEL_MASK;
786 } 708 }
787 709
710 pmic->desc[id].type = REGULATOR_VOLTAGE;
711 pmic->desc[id].owner = THIS_MODULE;
712
788 if (pdata) 713 if (pdata)
789 config.init_data = pdata->reg_data[id]; 714 config.init_data = pdata->reg_data[id];
790 else 715 else
@@ -821,6 +746,9 @@ static __devinit int palmas_probe(struct platform_device *pdev)
821 746
822 pmic->desc[id].type = REGULATOR_VOLTAGE; 747 pmic->desc[id].type = REGULATOR_VOLTAGE;
823 pmic->desc[id].owner = THIS_MODULE; 748 pmic->desc[id].owner = THIS_MODULE;
749 pmic->desc[id].min_uV = 900000;
750 pmic->desc[id].uV_step = 50000;
751 pmic->desc[id].linear_min_sel = 1;
824 pmic->desc[id].vsel_reg = PALMAS_BASE_TO_REG(PALMAS_LDO_BASE, 752 pmic->desc[id].vsel_reg = PALMAS_BASE_TO_REG(PALMAS_LDO_BASE,
825 palmas_regs_info[id].vsel_addr); 753 palmas_regs_info[id].vsel_addr);
826 pmic->desc[id].vsel_mask = PALMAS_LDO1_VOLTAGE_VSEL_MASK; 754 pmic->desc[id].vsel_mask = PALMAS_LDO1_VOLTAGE_VSEL_MASK;
@@ -868,7 +796,7 @@ err_unregister_regulator:
868 return ret; 796 return ret;
869} 797}
870 798
871static int __devexit palmas_remove(struct platform_device *pdev) 799static int palmas_remove(struct platform_device *pdev)
872{ 800{
873 struct palmas_pmic *pmic = platform_get_drvdata(pdev); 801 struct palmas_pmic *pmic = platform_get_drvdata(pdev);
874 int id; 802 int id;
@@ -890,7 +818,7 @@ static struct platform_driver palmas_driver = {
890 .owner = THIS_MODULE, 818 .owner = THIS_MODULE,
891 }, 819 },
892 .probe = palmas_probe, 820 .probe = palmas_probe,
893 .remove = __devexit_p(palmas_remove), 821 .remove = palmas_remove,
894}; 822};
895 823
896static int __init palmas_init(void) 824static int __init palmas_init(void)
diff --git a/drivers/regulator/pcap-regulator.c b/drivers/regulator/pcap-regulator.c
index 68777acc099f..4899342f1fc1 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 092e5cb848a1..534075e13d6d 100644
--- a/drivers/regulator/pcf50633-regulator.c
+++ b/drivers/regulator/pcf50633-regulator.c
@@ -24,12 +24,15 @@
24#include <linux/mfd/pcf50633/core.h> 24#include <linux/mfd/pcf50633/core.h>
25#include <linux/mfd/pcf50633/pmic.h> 25#include <linux/mfd/pcf50633/pmic.h>
26 26
27#define PCF50633_REGULATOR(_name, _id, _n) \ 27#define PCF50633_REGULATOR(_name, _id, _min_uV, _uV_step, _min_sel, _n) \
28 { \ 28 { \
29 .name = _name, \ 29 .name = _name, \
30 .id = PCF50633_REGULATOR_##_id, \ 30 .id = PCF50633_REGULATOR_##_id, \
31 .ops = &pcf50633_regulator_ops, \ 31 .ops = &pcf50633_regulator_ops, \
32 .n_voltages = _n, \ 32 .n_voltages = _n, \
33 .min_uV = _min_uV, \
34 .uV_step = _uV_step, \
35 .linear_min_sel = _min_sel, \
33 .type = REGULATOR_VOLTAGE, \ 36 .type = REGULATOR_VOLTAGE, \
34 .owner = THIS_MODULE, \ 37 .owner = THIS_MODULE, \
35 .vsel_reg = PCF50633_REG_##_id##OUT, \ 38 .vsel_reg = PCF50633_REG_##_id##OUT, \
@@ -38,165 +41,42 @@
38 .enable_mask = PCF50633_REGULATOR_ON, \ 41 .enable_mask = PCF50633_REGULATOR_ON, \
39 } 42 }
40 43
41/* Bits from voltage value */
42static u8 auto_voltage_bits(unsigned int millivolts)
43{
44 if (millivolts < 1800)
45 return 0x2f;
46 if (millivolts > 3800)
47 return 0xff;
48
49 millivolts -= 625;
50
51 return millivolts / 25;
52}
53
54static u8 down_voltage_bits(unsigned int millivolts)
55{
56 if (millivolts < 625)
57 return 0;
58 else if (millivolts > 3000)
59 return 0xff;
60
61 millivolts -= 625;
62
63 return millivolts / 25;
64}
65
66static u8 ldo_voltage_bits(unsigned int millivolts)
67{
68 if (millivolts < 900)
69 return 0;
70 else if (millivolts > 3600)
71 return 0x1f;
72
73 millivolts -= 900;
74 return millivolts / 100;
75}
76
77/* Obtain voltage value from bits */
78static unsigned int auto_voltage_value(u8 bits)
79{
80 /* AUTOOUT: 00000000 to 00101110 are reserved.
81 * Return 0 for bits in reserved range, which means this selector code
82 * can't be used on this system */
83 if (bits < 0x2f)
84 return 0;
85
86 return 625 + (bits * 25);
87}
88
89
90static unsigned int down_voltage_value(u8 bits)
91{
92 return 625 + (bits * 25);
93}
94
95
96static unsigned int ldo_voltage_value(u8 bits)
97{
98 bits &= 0x1f;
99
100 return 900 + (bits * 100);
101}
102
103static int pcf50633_regulator_map_voltage(struct regulator_dev *rdev,
104 int min_uV, int max_uV)
105{
106 struct pcf50633 *pcf;
107 int regulator_id, millivolts;
108 u8 volt_bits;
109
110 pcf = rdev_get_drvdata(rdev);
111
112 regulator_id = rdev_get_id(rdev);
113 if (regulator_id >= PCF50633_NUM_REGULATORS)
114 return -EINVAL;
115
116 millivolts = min_uV / 1000;
117
118 switch (regulator_id) {
119 case PCF50633_REGULATOR_AUTO:
120 volt_bits = auto_voltage_bits(millivolts);
121 break;
122 case PCF50633_REGULATOR_DOWN1:
123 case PCF50633_REGULATOR_DOWN2:
124 volt_bits = down_voltage_bits(millivolts);
125 break;
126 case PCF50633_REGULATOR_LDO1:
127 case PCF50633_REGULATOR_LDO2:
128 case PCF50633_REGULATOR_LDO3:
129 case PCF50633_REGULATOR_LDO4:
130 case PCF50633_REGULATOR_LDO5:
131 case PCF50633_REGULATOR_LDO6:
132 case PCF50633_REGULATOR_HCLDO:
133 case PCF50633_REGULATOR_MEMLDO:
134 volt_bits = ldo_voltage_bits(millivolts);
135 break;
136 default:
137 return -EINVAL;
138 }
139
140 return volt_bits;
141}
142
143static int pcf50633_regulator_list_voltage(struct regulator_dev *rdev,
144 unsigned int index)
145{
146 int regulator_id = rdev_get_id(rdev);
147
148 int millivolts;
149
150 switch (regulator_id) {
151 case PCF50633_REGULATOR_AUTO:
152 millivolts = auto_voltage_value(index);
153 break;
154 case PCF50633_REGULATOR_DOWN1:
155 case PCF50633_REGULATOR_DOWN2:
156 millivolts = down_voltage_value(index);
157 break;
158 case PCF50633_REGULATOR_LDO1:
159 case PCF50633_REGULATOR_LDO2:
160 case PCF50633_REGULATOR_LDO3:
161 case PCF50633_REGULATOR_LDO4:
162 case PCF50633_REGULATOR_LDO5:
163 case PCF50633_REGULATOR_LDO6:
164 case PCF50633_REGULATOR_HCLDO:
165 case PCF50633_REGULATOR_MEMLDO:
166 millivolts = ldo_voltage_value(index);
167 break;
168 default:
169 return -EINVAL;
170 }
171
172 return millivolts * 1000;
173}
174
175static struct regulator_ops pcf50633_regulator_ops = { 44static struct regulator_ops pcf50633_regulator_ops = {
176 .set_voltage_sel = regulator_set_voltage_sel_regmap, 45 .set_voltage_sel = regulator_set_voltage_sel_regmap,
177 .get_voltage_sel = regulator_get_voltage_sel_regmap, 46 .get_voltage_sel = regulator_get_voltage_sel_regmap,
178 .list_voltage = pcf50633_regulator_list_voltage, 47 .list_voltage = regulator_list_voltage_linear,
179 .map_voltage = pcf50633_regulator_map_voltage, 48 .map_voltage = regulator_map_voltage_linear,
180 .enable = regulator_enable_regmap, 49 .enable = regulator_enable_regmap,
181 .disable = regulator_disable_regmap, 50 .disable = regulator_disable_regmap,
182 .is_enabled = regulator_is_enabled_regmap, 51 .is_enabled = regulator_is_enabled_regmap,
183}; 52};
184 53
185static const struct regulator_desc regulators[] = { 54static const struct regulator_desc regulators[] = {
186 [PCF50633_REGULATOR_AUTO] = PCF50633_REGULATOR("auto", AUTO, 128), 55 [PCF50633_REGULATOR_AUTO] =
187 [PCF50633_REGULATOR_DOWN1] = PCF50633_REGULATOR("down1", DOWN1, 96), 56 PCF50633_REGULATOR("auto", AUTO, 1800000, 25000, 0x2f, 128),
188 [PCF50633_REGULATOR_DOWN2] = PCF50633_REGULATOR("down2", DOWN2, 96), 57 [PCF50633_REGULATOR_DOWN1] =
189 [PCF50633_REGULATOR_LDO1] = PCF50633_REGULATOR("ldo1", LDO1, 28), 58 PCF50633_REGULATOR("down1", DOWN1, 625000, 25000, 0, 96),
190 [PCF50633_REGULATOR_LDO2] = PCF50633_REGULATOR("ldo2", LDO2, 28), 59 [PCF50633_REGULATOR_DOWN2] =
191 [PCF50633_REGULATOR_LDO3] = PCF50633_REGULATOR("ldo3", LDO3, 28), 60 PCF50633_REGULATOR("down2", DOWN2, 625000, 25000, 0, 96),
192 [PCF50633_REGULATOR_LDO4] = PCF50633_REGULATOR("ldo4", LDO4, 28), 61 [PCF50633_REGULATOR_LDO1] =
193 [PCF50633_REGULATOR_LDO5] = PCF50633_REGULATOR("ldo5", LDO5, 28), 62 PCF50633_REGULATOR("ldo1", LDO1, 900000, 100000, 0, 28),
194 [PCF50633_REGULATOR_LDO6] = PCF50633_REGULATOR("ldo6", LDO6, 28), 63 [PCF50633_REGULATOR_LDO2] =
195 [PCF50633_REGULATOR_HCLDO] = PCF50633_REGULATOR("hcldo", HCLDO, 28), 64 PCF50633_REGULATOR("ldo2", LDO2, 900000, 100000, 0, 28),
196 [PCF50633_REGULATOR_MEMLDO] = PCF50633_REGULATOR("memldo", MEMLDO, 28), 65 [PCF50633_REGULATOR_LDO3] =
66 PCF50633_REGULATOR("ldo3", LDO3, 900000, 100000, 0, 28),
67 [PCF50633_REGULATOR_LDO4] =
68 PCF50633_REGULATOR("ldo4", LDO4, 900000, 100000, 0, 28),
69 [PCF50633_REGULATOR_LDO5] =
70 PCF50633_REGULATOR("ldo5", LDO5, 900000, 100000, 0, 28),
71 [PCF50633_REGULATOR_LDO6] =
72 PCF50633_REGULATOR("ldo6", LDO6, 900000, 100000, 0, 28),
73 [PCF50633_REGULATOR_HCLDO] =
74 PCF50633_REGULATOR("hcldo", HCLDO, 900000, 100000, 0, 28),
75 [PCF50633_REGULATOR_MEMLDO] =
76 PCF50633_REGULATOR("memldo", MEMLDO, 900000, 100000, 0, 28),
197}; 77};
198 78
199static int __devinit pcf50633_regulator_probe(struct platform_device *pdev) 79static int pcf50633_regulator_probe(struct platform_device *pdev)
200{ 80{
201 struct regulator_dev *rdev; 81 struct regulator_dev *rdev;
202 struct pcf50633 *pcf; 82 struct pcf50633 *pcf;
@@ -222,7 +102,7 @@ static int __devinit pcf50633_regulator_probe(struct platform_device *pdev)
222 return 0; 102 return 0;
223} 103}
224 104
225static int __devexit pcf50633_regulator_remove(struct platform_device *pdev) 105static int pcf50633_regulator_remove(struct platform_device *pdev)
226{ 106{
227 struct regulator_dev *rdev = platform_get_drvdata(pdev); 107 struct regulator_dev *rdev = platform_get_drvdata(pdev);
228 108
@@ -237,7 +117,7 @@ static struct platform_driver pcf50633_regulator_driver = {
237 .name = "pcf50633-regltr", 117 .name = "pcf50633-regltr",
238 }, 118 },
239 .probe = pcf50633_regulator_probe, 119 .probe = pcf50633_regulator_probe,
240 .remove = __devexit_p(pcf50633_regulator_remove), 120 .remove = pcf50633_regulator_remove,
241}; 121};
242 122
243static int __init pcf50633_regulator_init(void) 123static int __init pcf50633_regulator_init(void)
diff --git a/drivers/regulator/rc5t583-regulator.c b/drivers/regulator/rc5t583-regulator.c
index 8bf4e8c9de9a..9e6f78694bf1 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 926f9c8f2fac..bd062a2ffbe2 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);
@@ -269,16 +269,16 @@ static __devinit int s2mps11_pmic_probe(struct platform_device *pdev)
269 269
270 if (ramp_enable) { 270 if (ramp_enable) {
271 if (s2mps11->buck2_ramp) 271 if (s2mps11->buck2_ramp)
272 ramp_reg |= get_ramp_delay(s2mps11->ramp_delay2) >> 6; 272 ramp_reg |= get_ramp_delay(s2mps11->ramp_delay2) << 6;
273 if (s2mps11->buck3_ramp || s2mps11->buck4_ramp) 273 if (s2mps11->buck3_ramp || s2mps11->buck4_ramp)
274 ramp_reg |= get_ramp_delay(s2mps11->ramp_delay34) >> 4; 274 ramp_reg |= get_ramp_delay(s2mps11->ramp_delay34) << 4;
275 sec_reg_write(iodev, S2MPS11_REG_RAMP, ramp_reg | ramp_enable); 275 sec_reg_write(iodev, S2MPS11_REG_RAMP, ramp_reg | ramp_enable);
276 } 276 }
277 277
278 ramp_reg &= 0x00; 278 ramp_reg &= 0x00;
279 ramp_reg |= get_ramp_delay(s2mps11->ramp_delay5) >> 6; 279 ramp_reg |= get_ramp_delay(s2mps11->ramp_delay5) << 6;
280 ramp_reg |= get_ramp_delay(s2mps11->ramp_delay16) >> 4; 280 ramp_reg |= get_ramp_delay(s2mps11->ramp_delay16) << 4;
281 ramp_reg |= get_ramp_delay(s2mps11->ramp_delay7810) >> 2; 281 ramp_reg |= get_ramp_delay(s2mps11->ramp_delay7810) << 2;
282 ramp_reg |= get_ramp_delay(s2mps11->ramp_delay9); 282 ramp_reg |= get_ramp_delay(s2mps11->ramp_delay9);
283 sec_reg_write(iodev, S2MPS11_REG_RAMP_BUCK, ramp_reg); 283 sec_reg_write(iodev, S2MPS11_REG_RAMP_BUCK, ramp_reg);
284 284
@@ -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 abe64a32aedf..9f991f2c525a 100644
--- a/drivers/regulator/s5m8767.c
+++ b/drivers/regulator/s5m8767.c
@@ -168,7 +168,7 @@ static unsigned int s5m8767_opmode_reg[][4] = {
168static int s5m8767_get_register(struct regulator_dev *rdev, int *reg, 168static int s5m8767_get_register(struct regulator_dev *rdev, int *reg,
169 int *enable_ctrl) 169 int *enable_ctrl)
170{ 170{
171 int reg_id = rdev_get_id(rdev); 171 int i, reg_id = rdev_get_id(rdev);
172 unsigned int mode; 172 unsigned int mode;
173 struct s5m8767_info *s5m8767 = rdev_get_drvdata(rdev); 173 struct s5m8767_info *s5m8767 = rdev_get_drvdata(rdev);
174 174
@@ -195,8 +195,17 @@ static int s5m8767_get_register(struct regulator_dev *rdev, int *reg,
195 return -EINVAL; 195 return -EINVAL;
196 } 196 }
197 197
198 mode = s5m8767->opmode[reg_id].mode; 198 for (i = 0; i < s5m8767->num_regulators; i++) {
199 *enable_ctrl = s5m8767_opmode_reg[reg_id][mode] << S5M8767_ENCTRL_SHIFT; 199 if (s5m8767->opmode[i].id == reg_id) {
200 mode = s5m8767->opmode[i].mode;
201 break;
202 }
203 }
204
205 if (i < s5m8767->num_regulators)
206 *enable_ctrl =
207 s5m8767_opmode_reg[reg_id][mode] << S5M8767_ENCTRL_SHIFT;
208
200 return 0; 209 return 0;
201} 210}
202 211
@@ -263,17 +272,17 @@ static int s5m8767_get_voltage_register(struct regulator_dev *rdev, int *_reg)
263 reg = S5M8767_REG_BUCK1CTRL2; 272 reg = S5M8767_REG_BUCK1CTRL2;
264 break; 273 break;
265 case S5M8767_BUCK2: 274 case S5M8767_BUCK2:
266 reg = S5M8767_REG_BUCK2DVS2; 275 reg = S5M8767_REG_BUCK2DVS1;
267 if (s5m8767->buck2_gpiodvs) 276 if (s5m8767->buck2_gpiodvs)
268 reg += s5m8767->buck_gpioindex; 277 reg += s5m8767->buck_gpioindex;
269 break; 278 break;
270 case S5M8767_BUCK3: 279 case S5M8767_BUCK3:
271 reg = S5M8767_REG_BUCK3DVS2; 280 reg = S5M8767_REG_BUCK3DVS1;
272 if (s5m8767->buck3_gpiodvs) 281 if (s5m8767->buck3_gpiodvs)
273 reg += s5m8767->buck_gpioindex; 282 reg += s5m8767->buck_gpioindex;
274 break; 283 break;
275 case S5M8767_BUCK4: 284 case S5M8767_BUCK4:
276 reg = S5M8767_REG_BUCK4DVS2; 285 reg = S5M8767_REG_BUCK4DVS1;
277 if (s5m8767->buck4_gpiodvs) 286 if (s5m8767->buck4_gpiodvs)
278 reg += s5m8767->buck_gpioindex; 287 reg += s5m8767->buck_gpioindex;
279 break; 288 break;
@@ -499,7 +508,7 @@ static struct regulator_desc regulators[] = {
499 s5m8767_regulator_desc(BUCK9), 508 s5m8767_regulator_desc(BUCK9),
500}; 509};
501 510
502static __devinit int s5m8767_pmic_probe(struct platform_device *pdev) 511static int s5m8767_pmic_probe(struct platform_device *pdev)
503{ 512{
504 struct sec_pmic_dev *iodev = dev_get_drvdata(pdev->dev.parent); 513 struct sec_pmic_dev *iodev = dev_get_drvdata(pdev->dev.parent);
505 struct sec_platform_data *pdata = dev_get_platdata(iodev->dev); 514 struct sec_platform_data *pdata = dev_get_platdata(iodev->dev);
@@ -547,7 +556,7 @@ static __devinit int s5m8767_pmic_probe(struct platform_device *pdev)
547 rdev = s5m8767->rdev; 556 rdev = s5m8767->rdev;
548 s5m8767->dev = &pdev->dev; 557 s5m8767->dev = &pdev->dev;
549 s5m8767->iodev = iodev; 558 s5m8767->iodev = iodev;
550 s5m8767->num_regulators = S5M8767_REG_MAX - 2; 559 s5m8767->num_regulators = pdata->num_regulators;
551 platform_set_drvdata(pdev, s5m8767); 560 platform_set_drvdata(pdev, s5m8767);
552 561
553 s5m8767->buck_gpioindex = pdata->buck_default_idx; 562 s5m8767->buck_gpioindex = pdata->buck_default_idx;
@@ -617,9 +626,16 @@ static __devinit int s5m8767_pmic_probe(struct platform_device *pdev)
617 } 626 }
618 } 627 }
619 628
620 if (gpio_is_valid(pdata->buck_gpios[0]) && 629 if (pdata->buck2_gpiodvs || pdata->buck3_gpiodvs ||
621 gpio_is_valid(pdata->buck_gpios[1]) && 630 pdata->buck4_gpiodvs) {
622 gpio_is_valid(pdata->buck_gpios[2])) { 631
632 if (!gpio_is_valid(pdata->buck_gpios[0]) ||
633 !gpio_is_valid(pdata->buck_gpios[1]) ||
634 !gpio_is_valid(pdata->buck_gpios[2])) {
635 dev_err(&pdev->dev, "GPIO NOT VALID\n");
636 return -EINVAL;
637 }
638
623 ret = devm_gpio_request(&pdev->dev, pdata->buck_gpios[0], 639 ret = devm_gpio_request(&pdev->dev, pdata->buck_gpios[0],
624 "S5M8767 SET1"); 640 "S5M8767 SET1");
625 if (ret) 641 if (ret)
@@ -644,10 +660,6 @@ static __devinit int s5m8767_pmic_probe(struct platform_device *pdev)
644 /* SET3 GPIO */ 660 /* SET3 GPIO */
645 gpio_direction_output(pdata->buck_gpios[2], 661 gpio_direction_output(pdata->buck_gpios[2],
646 (s5m8767->buck_gpioindex >> 0) & 0x1); 662 (s5m8767->buck_gpioindex >> 0) & 0x1);
647 } else {
648 dev_err(&pdev->dev, "GPIO NOT VALID\n");
649 ret = -EINVAL;
650 return ret;
651 } 663 }
652 664
653 ret = devm_gpio_request(&pdev->dev, pdata->buck_ds[0], "S5M8767 DS2"); 665 ret = devm_gpio_request(&pdev->dev, pdata->buck_ds[0], "S5M8767 DS2");
@@ -773,7 +785,7 @@ err:
773 return ret; 785 return ret;
774} 786}
775 787
776static int __devexit s5m8767_pmic_remove(struct platform_device *pdev) 788static int s5m8767_pmic_remove(struct platform_device *pdev)
777{ 789{
778 struct s5m8767_info *s5m8767 = platform_get_drvdata(pdev); 790 struct s5m8767_info *s5m8767 = platform_get_drvdata(pdev);
779 struct regulator_dev **rdev = s5m8767->rdev; 791 struct regulator_dev **rdev = s5m8767->rdev;
@@ -798,7 +810,7 @@ static struct platform_driver s5m8767_pmic_driver = {
798 .owner = THIS_MODULE, 810 .owner = THIS_MODULE,
799 }, 811 },
800 .probe = s5m8767_pmic_probe, 812 .probe = s5m8767_pmic_probe,
801 .remove = __devexit_p(s5m8767_pmic_remove), 813 .remove = s5m8767_pmic_remove,
802 .id_table = s5m8767_pmic_id, 814 .id_table = s5m8767_pmic_id,
803}; 815};
804 816
diff --git a/drivers/regulator/tps51632-regulator.c b/drivers/regulator/tps51632-regulator.c
new file mode 100644
index 000000000000..ab21133e6784
--- /dev/null
+++ b/drivers/regulator/tps51632-regulator.c
@@ -0,0 +1,342 @@
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 return vsel;
110}
111
112static int tps51632_dcdc_set_voltage_sel(struct regulator_dev *rdev,
113 unsigned selector)
114{
115 struct tps51632_chip *tps = rdev_get_drvdata(rdev);
116 int ret;
117 unsigned int reg = TPS51632_VOLTAGE_SELECT_REG;
118
119 if (tps->enable_pwm_dvfs)
120 reg = TPS51632_VOLTAGE_BASE_REG;
121
122 if (selector > TPS51632_MAX_VSEL)
123 return -EINVAL;
124
125 ret = regmap_write(tps->regmap, reg, selector);
126 if (ret < 0)
127 dev_err(tps->dev, "reg write failed, err %d\n", ret);
128 return ret;
129}
130
131static int tps51632_dcdc_set_ramp_delay(struct regulator_dev *rdev,
132 int ramp_delay)
133{
134 struct tps51632_chip *tps = rdev_get_drvdata(rdev);
135 int bit = ramp_delay/6000;
136 int ret;
137
138 if (bit)
139 bit--;
140 ret = regmap_write(tps->regmap, TPS51632_SLEW_REGS, BIT(bit));
141 if (ret < 0)
142 dev_err(tps->dev, "SLEW reg write failed, err %d\n", ret);
143 return ret;
144}
145
146static struct regulator_ops tps51632_dcdc_ops = {
147 .get_voltage_sel = tps51632_dcdc_get_voltage_sel,
148 .set_voltage_sel = tps51632_dcdc_set_voltage_sel,
149 .list_voltage = regulator_list_voltage_linear,
150 .set_voltage_time_sel = regulator_set_voltage_time_sel,
151 .set_ramp_delay = tps51632_dcdc_set_ramp_delay,
152};
153
154static int tps51632_init_dcdc(struct tps51632_chip *tps,
155 struct tps51632_regulator_platform_data *pdata)
156{
157 int ret;
158 uint8_t control = 0;
159 int vsel;
160
161 if (!pdata->enable_pwm_dvfs)
162 goto skip_pwm_config;
163
164 control |= TPS51632_DVFS_PWMEN;
165 tps->enable_pwm_dvfs = pdata->enable_pwm_dvfs;
166 vsel = TPS51632_VOLT_VSEL(pdata->base_voltage_uV);
167 ret = regmap_write(tps->regmap, TPS51632_VOLTAGE_BASE_REG, vsel);
168 if (ret < 0) {
169 dev_err(tps->dev, "BASE reg write failed, err %d\n", ret);
170 return ret;
171 }
172
173 if (pdata->dvfs_step_20mV)
174 control |= TPS51632_DVFS_STEP_20;
175
176 if (pdata->max_voltage_uV) {
177 unsigned int vmax;
178 /**
179 * TPS51632 hw behavior: VMAX register can be write only
180 * once as it get locked after first write. The lock get
181 * reset only when device is power-reset.
182 * Write register only when lock bit is not enabled.
183 */
184 ret = regmap_read(tps->regmap, TPS51632_VMAX_REG, &vmax);
185 if (ret < 0) {
186 dev_err(tps->dev, "VMAX read failed, err %d\n", ret);
187 return ret;
188 }
189 if (!(vmax & TPS51632_VMAX_LOCK)) {
190 vsel = TPS51632_VOLT_VSEL(pdata->max_voltage_uV);
191 ret = regmap_write(tps->regmap, TPS51632_VMAX_REG,
192 vsel);
193 if (ret < 0) {
194 dev_err(tps->dev,
195 "VMAX write failed, err %d\n", ret);
196 return ret;
197 }
198 }
199 }
200
201skip_pwm_config:
202 ret = regmap_write(tps->regmap, TPS51632_DVFS_CONTROL_REG, control);
203 if (ret < 0)
204 dev_err(tps->dev, "DVFS reg write failed, err %d\n", ret);
205 return ret;
206}
207
208static bool rd_wr_reg(struct device *dev, unsigned int reg)
209{
210 if ((reg >= 0x8) && (reg <= 0x10))
211 return false;
212 return true;
213}
214
215static const struct regmap_config tps51632_regmap_config = {
216 .reg_bits = 8,
217 .val_bits = 8,
218 .writeable_reg = rd_wr_reg,
219 .readable_reg = rd_wr_reg,
220 .max_register = TPS51632_MAX_REG - 1,
221 .cache_type = REGCACHE_RBTREE,
222};
223
224static int tps51632_probe(struct i2c_client *client,
225 const struct i2c_device_id *id)
226{
227 struct tps51632_regulator_platform_data *pdata;
228 struct regulator_dev *rdev;
229 struct tps51632_chip *tps;
230 int ret;
231 struct regulator_config config = { };
232
233 pdata = client->dev.platform_data;
234 if (!pdata) {
235 dev_err(&client->dev, "No Platform data\n");
236 return -EINVAL;
237 }
238
239 if (pdata->enable_pwm_dvfs) {
240 if ((pdata->base_voltage_uV < TPS51632_MIN_VOLATGE) ||
241 (pdata->base_voltage_uV > TPS51632_MAX_VOLATGE)) {
242 dev_err(&client->dev, "Invalid base_voltage_uV setting\n");
243 return -EINVAL;
244 }
245
246 if ((pdata->max_voltage_uV) &&
247 ((pdata->max_voltage_uV < TPS51632_MIN_VOLATGE) ||
248 (pdata->max_voltage_uV > TPS51632_MAX_VOLATGE))) {
249 dev_err(&client->dev, "Invalid max_voltage_uV setting\n");
250 return -EINVAL;
251 }
252 }
253
254 tps = devm_kzalloc(&client->dev, sizeof(*tps), GFP_KERNEL);
255 if (!tps) {
256 dev_err(&client->dev, "Memory allocation failed\n");
257 return -ENOMEM;
258 }
259
260 tps->dev = &client->dev;
261 tps->desc.name = id->name;
262 tps->desc.id = 0;
263 tps->desc.ramp_delay = TPS51632_DEFAULT_RAMP_DELAY;
264 tps->desc.min_uV = TPS51632_MIN_VOLATGE;
265 tps->desc.uV_step = TPS51632_VOLATGE_STEP_10mV;
266 tps->desc.linear_min_sel = TPS51632_MIN_VSEL;
267 tps->desc.n_voltages = TPS51632_MAX_VSEL + 1;
268 tps->desc.ops = &tps51632_dcdc_ops;
269 tps->desc.type = REGULATOR_VOLTAGE;
270 tps->desc.owner = THIS_MODULE;
271
272 tps->regmap = devm_regmap_init_i2c(client, &tps51632_regmap_config);
273 if (IS_ERR(tps->regmap)) {
274 ret = PTR_ERR(tps->regmap);
275 dev_err(&client->dev, "regmap init failed, err %d\n", ret);
276 return ret;
277 }
278 i2c_set_clientdata(client, tps);
279
280 ret = tps51632_init_dcdc(tps, pdata);
281 if (ret < 0) {
282 dev_err(tps->dev, "Init failed, err = %d\n", ret);
283 return ret;
284 }
285
286 /* Register the regulators */
287 config.dev = &client->dev;
288 config.init_data = pdata->reg_init_data;
289 config.driver_data = tps;
290 config.regmap = tps->regmap;
291 config.of_node = client->dev.of_node;
292
293 rdev = regulator_register(&tps->desc, &config);
294 if (IS_ERR(rdev)) {
295 dev_err(tps->dev, "regulator register failed\n");
296 return PTR_ERR(rdev);
297 }
298
299 tps->rdev = rdev;
300 return 0;
301}
302
303static int tps51632_remove(struct i2c_client *client)
304{
305 struct tps51632_chip *tps = i2c_get_clientdata(client);
306
307 regulator_unregister(tps->rdev);
308 return 0;
309}
310
311static const struct i2c_device_id tps51632_id[] = {
312 {.name = "tps51632",},
313 {},
314};
315
316MODULE_DEVICE_TABLE(i2c, tps51632_id);
317
318static struct i2c_driver tps51632_i2c_driver = {
319 .driver = {
320 .name = "tps51632",
321 .owner = THIS_MODULE,
322 },
323 .probe = tps51632_probe,
324 .remove = tps51632_remove,
325 .id_table = tps51632_id,
326};
327
328static int __init tps51632_init(void)
329{
330 return i2c_add_driver(&tps51632_i2c_driver);
331}
332subsys_initcall(tps51632_init);
333
334static void __exit tps51632_cleanup(void)
335{
336 i2c_del_driver(&tps51632_i2c_driver);
337}
338module_exit(tps51632_cleanup);
339
340MODULE_AUTHOR("Laxman Dewangan <ldewangan@nvidia.com>");
341MODULE_DESCRIPTION("TPS51632 voltage regulator driver");
342MODULE_LICENSE("GPL v2");
diff --git a/drivers/regulator/tps6105x-regulator.c b/drivers/regulator/tps6105x-regulator.c
index 1378409efaec..ec9453ffb77f 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 68729a7c8709..acbd63fde415 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 6998d579d07b..9b9af6d889c8 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 07d01ccdf308..0233cfb56560 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 001ad554ac62..41c391789c97 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)
@@ -148,3 +269,4 @@ module_exit(tps65090_regulator_exit);
148MODULE_DESCRIPTION("tps65090 regulator driver"); 269MODULE_DESCRIPTION("tps65090 regulator driver");
149MODULE_AUTHOR("Venu Byravarasu <vbyravarasu@nvidia.com>"); 270MODULE_AUTHOR("Venu Byravarasu <vbyravarasu@nvidia.com>");
150MODULE_LICENSE("GPL v2"); 271MODULE_LICENSE("GPL v2");
272MODULE_ALIAS("platform:tps65090-pmic");
diff --git a/drivers/regulator/tps65217-regulator.c b/drivers/regulator/tps65217-regulator.c
index ab00cab905b7..73dce7664126 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 058d2f2675e9..843ee0a9bb92 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 ce1e7cb8d513..f86da672c758 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\n");
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 793adda560c3..59c3770fa77d 100644
--- a/drivers/regulator/tps65910-regulator.c
+++ b/drivers/regulator/tps65910-regulator.c
@@ -38,6 +38,11 @@ static const unsigned int VIO_VSEL_table[] = {
38 38
39/* VSEL tables for TPS65910 specific LDOs and dcdc's */ 39/* VSEL tables for TPS65910 specific LDOs and dcdc's */
40 40
41/* supported VRTC voltages in microvolts */
42static const unsigned int VRTC_VSEL_table[] = {
43 1800000,
44};
45
41/* supported VDD3 voltages in microvolts */ 46/* supported VDD3 voltages in microvolts */
42static const unsigned int VDD3_VSEL_table[] = { 47static const unsigned int VDD3_VSEL_table[] = {
43 5000000, 48 5000000,
@@ -95,6 +100,8 @@ static struct tps_info tps65910_regs[] = {
95 { 100 {
96 .name = "vrtc", 101 .name = "vrtc",
97 .vin_name = "vcc7", 102 .vin_name = "vcc7",
103 .n_voltages = ARRAY_SIZE(VRTC_VSEL_table),
104 .voltage_table = VRTC_VSEL_table,
98 .enable_time_us = 2200, 105 .enable_time_us = 2200,
99 }, 106 },
100 { 107 {
@@ -1026,7 +1033,7 @@ static inline struct tps65910_board *tps65910_parse_dt_reg_data(
1026} 1033}
1027#endif 1034#endif
1028 1035
1029static __devinit int tps65910_probe(struct platform_device *pdev) 1036static int tps65910_probe(struct platform_device *pdev)
1030{ 1037{
1031 struct tps65910 *tps65910 = dev_get_drvdata(pdev->dev.parent); 1038 struct tps65910 *tps65910 = dev_get_drvdata(pdev->dev.parent);
1032 struct regulator_config config = { }; 1039 struct regulator_config config = { };
@@ -1184,7 +1191,7 @@ err_unregister_regulator:
1184 return err; 1191 return err;
1185} 1192}
1186 1193
1187static int __devexit tps65910_remove(struct platform_device *pdev) 1194static int tps65910_remove(struct platform_device *pdev)
1188{ 1195{
1189 struct tps65910_reg *pmic = platform_get_drvdata(pdev); 1196 struct tps65910_reg *pmic = platform_get_drvdata(pdev);
1190 int i; 1197 int i;
@@ -1231,7 +1238,7 @@ static struct platform_driver tps65910_driver = {
1231 .owner = THIS_MODULE, 1238 .owner = THIS_MODULE,
1232 }, 1239 },
1233 .probe = tps65910_probe, 1240 .probe = tps65910_probe,
1234 .remove = __devexit_p(tps65910_remove), 1241 .remove = tps65910_remove,
1235 .shutdown = tps65910_shutdown, 1242 .shutdown = tps65910_shutdown,
1236}; 1243};
1237 1244
diff --git a/drivers/regulator/tps65912-regulator.c b/drivers/regulator/tps65912-regulator.c
index 18b2a1dcb4b5..17e994e47dc1 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 000000000000..b15d711bc8c6
--- /dev/null
+++ b/drivers/regulator/tps80031-regulator.c
@@ -0,0 +1,788 @@
1/*
2 * tps80031-regulator.c -- TI TPS80031 regulator driver.
3 *
4 * Regulator driver for TI TPS80031/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_vbus_is_enabled(struct regulator_dev *rdev)
288{
289 struct tps80031_regulator *ri = rdev_get_drvdata(rdev);
290 struct device *parent = to_tps80031_dev(rdev);
291 int ret = -EIO;
292 uint8_t ctrl1 = 0;
293 uint8_t ctrl3 = 0;
294
295 ret = tps80031_read(parent, TPS80031_SLAVE_ID2,
296 TPS80031_CHARGERUSB_CTRL1, &ctrl1);
297 if (ret < 0) {
298 dev_err(ri->dev, "reg 0x%02x read failed, e = %d\n",
299 TPS80031_CHARGERUSB_CTRL1, ret);
300 return ret;
301 }
302 ret = tps80031_read(parent, TPS80031_SLAVE_ID2,
303 TPS80031_CHARGERUSB_CTRL3, &ctrl3);
304 if (ret < 0) {
305 dev_err(ri->dev, "reg 0x%02x read failed, e = %d\n",
306 TPS80031_CHARGERUSB_CTRL3, ret);
307 return ret;
308 }
309 if ((ctrl1 & OPA_MODE_EN) && (ctrl3 & BOOST_HW_PWR_EN))
310 return 1;
311 return ret;
312}
313
314static int tps80031_vbus_enable(struct regulator_dev *rdev)
315{
316 struct tps80031_regulator *ri = rdev_get_drvdata(rdev);
317 struct device *parent = to_tps80031_dev(rdev);
318 int ret;
319
320 ret = tps80031_set_bits(parent, TPS80031_SLAVE_ID2,
321 TPS80031_CHARGERUSB_CTRL1, OPA_MODE_EN);
322 if (ret < 0) {
323 dev_err(ri->dev, "reg 0x%02x read failed, e = %d\n",
324 TPS80031_CHARGERUSB_CTRL1, ret);
325 return ret;
326 }
327
328 ret = tps80031_set_bits(parent, TPS80031_SLAVE_ID2,
329 TPS80031_CHARGERUSB_CTRL3, BOOST_HW_PWR_EN);
330 if (ret < 0) {
331 dev_err(ri->dev, "reg 0x%02x read failed, e = %d\n",
332 TPS80031_CHARGERUSB_CTRL3, ret);
333 return ret;
334 }
335 return ret;
336}
337
338static int tps80031_vbus_disable(struct regulator_dev *rdev)
339{
340 struct tps80031_regulator *ri = rdev_get_drvdata(rdev);
341 struct device *parent = to_tps80031_dev(rdev);
342 int ret = 0;
343
344 if (ri->config_flags & TPS80031_VBUS_DISCHRG_EN_PDN) {
345 ret = tps80031_write(parent, TPS80031_SLAVE_ID2,
346 USB_VBUS_CTRL_SET, VBUS_DISCHRG);
347 if (ret < 0) {
348 dev_err(ri->dev, "reg 0x%02x write failed, e = %d\n",
349 USB_VBUS_CTRL_SET, ret);
350 return ret;
351 }
352 }
353
354 ret = tps80031_clr_bits(parent, TPS80031_SLAVE_ID2,
355 TPS80031_CHARGERUSB_CTRL1, OPA_MODE_EN);
356 if (ret < 0) {
357 dev_err(ri->dev, "reg 0x%02x clearbit failed, e = %d\n",
358 TPS80031_CHARGERUSB_CTRL1, ret);
359 return ret;
360 }
361
362 ret = tps80031_clr_bits(parent, TPS80031_SLAVE_ID2,
363 TPS80031_CHARGERUSB_CTRL3, BOOST_HW_PWR_EN);
364 if (ret < 0) {
365 dev_err(ri->dev, "reg 0x%02x clearbit failed, e = %d\n",
366 TPS80031_CHARGERUSB_CTRL3, ret);
367 return ret;
368 }
369
370 mdelay(DIV_ROUND_UP(ri->rinfo->desc.enable_time, 1000));
371 if (ri->config_flags & TPS80031_VBUS_DISCHRG_EN_PDN) {
372 ret = tps80031_write(parent, TPS80031_SLAVE_ID2,
373 USB_VBUS_CTRL_CLR, VBUS_DISCHRG);
374 if (ret < 0) {
375 dev_err(ri->dev, "reg 0x%02x write failed, e = %d\n",
376 USB_VBUS_CTRL_CLR, ret);
377 return ret;
378 }
379 }
380 return ret;
381}
382
383static struct regulator_ops tps80031_dcdc_ops = {
384 .list_voltage = tps80031_dcdc_list_voltage,
385 .set_voltage_sel = tps80031_dcdc_set_voltage_sel,
386 .get_voltage_sel = tps80031_dcdc_get_voltage_sel,
387 .enable = tps80031_reg_enable,
388 .disable = tps80031_reg_disable,
389 .is_enabled = tps80031_reg_is_enabled,
390};
391
392static struct regulator_ops tps80031_ldo_ops = {
393 .list_voltage = regulator_list_voltage_linear,
394 .set_voltage_sel = tps80031_ldo_set_voltage_sel,
395 .get_voltage_sel = tps80031_ldo_get_voltage_sel,
396 .enable = tps80031_reg_enable,
397 .disable = tps80031_reg_disable,
398 .is_enabled = tps80031_reg_is_enabled,
399};
400
401static struct regulator_ops tps80031_vbus_sw_ops = {
402 .list_voltage = regulator_list_voltage_linear,
403 .enable = tps80031_vbus_enable,
404 .disable = tps80031_vbus_disable,
405 .is_enabled = tps80031_vbus_is_enabled,
406};
407
408static struct regulator_ops tps80031_vbus_hw_ops = {
409 .list_voltage = regulator_list_voltage_linear,
410};
411
412static struct regulator_ops tps80031_ext_reg_ops = {
413 .list_voltage = regulator_list_voltage_linear,
414 .enable = tps80031_reg_enable,
415 .disable = tps80031_reg_disable,
416 .is_enabled = tps80031_reg_is_enabled,
417};
418
419/* Non-exiting default definition for some register */
420#define TPS80031_SMPS3_CFG_FORCE 0
421#define TPS80031_SMPS4_CFG_FORCE 0
422
423#define TPS80031_VBUS_CFG_TRANS 0
424#define TPS80031_VBUS_CFG_STATE 0
425
426#define TPS80031_REG_SMPS(_id, _volt_id, _pbit) \
427{ \
428 .trans_reg = TPS80031_##_id##_CFG_TRANS, \
429 .state_reg = TPS80031_##_id##_CFG_STATE, \
430 .force_reg = TPS80031_##_id##_CFG_FORCE, \
431 .volt_reg = TPS80031_##_id##_CFG_VOLTAGE, \
432 .volt_id = TPS80031_SLAVE_##_volt_id, \
433 .preq_bit = _pbit, \
434 .desc = { \
435 .name = "tps80031_"#_id, \
436 .id = TPS80031_REGULATOR_##_id, \
437 .n_voltages = 63, \
438 .ops = &tps80031_dcdc_ops, \
439 .type = REGULATOR_VOLTAGE, \
440 .owner = THIS_MODULE, \
441 .enable_time = 500, \
442 }, \
443}
444
445#define TPS80031_REG_LDO(_id, _preq_bit) \
446{ \
447 .trans_reg = TPS80031_##_id##_CFG_TRANS, \
448 .state_reg = TPS80031_##_id##_CFG_STATE, \
449 .volt_reg = TPS80031_##_id##_CFG_VOLTAGE, \
450 .volt_id = TPS80031_SLAVE_ID1, \
451 .preq_bit = _preq_bit, \
452 .desc = { \
453 .owner = THIS_MODULE, \
454 .name = "tps80031_"#_id, \
455 .id = TPS80031_REGULATOR_##_id, \
456 .ops = &tps80031_ldo_ops, \
457 .type = REGULATOR_VOLTAGE, \
458 .min_uV = 1000000, \
459 .uV_step = 100000, \
460 .linear_min_sel = 1, \
461 .n_voltages = 25, \
462 .vsel_mask = LDO_VSEL_MASK, \
463 .enable_time = 500, \
464 }, \
465}
466
467#define TPS80031_REG_FIXED(_id, max_mV, _ops, _delay, _pbit) \
468{ \
469 .trans_reg = TPS80031_##_id##_CFG_TRANS, \
470 .state_reg = TPS80031_##_id##_CFG_STATE, \
471 .volt_id = TPS80031_SLAVE_ID1, \
472 .preq_bit = _pbit, \
473 .desc = { \
474 .name = "tps80031_"#_id, \
475 .id = TPS80031_REGULATOR_##_id, \
476 .min_uV = max_mV * 1000, \
477 .n_voltages = 1, \
478 .ops = &_ops, \
479 .type = REGULATOR_VOLTAGE, \
480 .owner = THIS_MODULE, \
481 .enable_time = _delay, \
482 }, \
483}
484
485static struct tps80031_regulator_info tps80031_rinfo[TPS80031_REGULATOR_MAX] = {
486 TPS80031_REG_SMPS(VIO, ID0, 4),
487 TPS80031_REG_SMPS(SMPS1, ID0, 0),
488 TPS80031_REG_SMPS(SMPS2, ID0, 1),
489 TPS80031_REG_SMPS(SMPS3, ID1, 2),
490 TPS80031_REG_SMPS(SMPS4, ID1, 3),
491 TPS80031_REG_LDO(VANA, -1),
492 TPS80031_REG_LDO(LDO1, 8),
493 TPS80031_REG_LDO(LDO2, 9),
494 TPS80031_REG_LDO(LDO3, 10),
495 TPS80031_REG_LDO(LDO4, 11),
496 TPS80031_REG_LDO(LDO5, 12),
497 TPS80031_REG_LDO(LDO6, 13),
498 TPS80031_REG_LDO(LDO7, 14),
499 TPS80031_REG_LDO(LDOLN, 15),
500 TPS80031_REG_LDO(LDOUSB, 5),
501 TPS80031_REG_FIXED(VBUS, 5000, tps80031_vbus_hw_ops, 100000, -1),
502 TPS80031_REG_FIXED(REGEN1, 3300, tps80031_ext_reg_ops, 0, 16),
503 TPS80031_REG_FIXED(REGEN2, 3300, tps80031_ext_reg_ops, 0, 17),
504 TPS80031_REG_FIXED(SYSEN, 3300, tps80031_ext_reg_ops, 0, 18),
505};
506
507static int tps80031_power_req_config(struct device *parent,
508 struct tps80031_regulator *ri,
509 struct tps80031_regulator_platform_data *tps80031_pdata)
510{
511 int ret = 0;
512
513 if (ri->rinfo->preq_bit < 0)
514 goto skip_pwr_req_config;
515
516 ret = tps80031_ext_power_req_config(parent, ri->ext_ctrl_flag,
517 ri->rinfo->preq_bit, ri->rinfo->state_reg,
518 ri->rinfo->trans_reg);
519 if (ret < 0) {
520 dev_err(ri->dev, "ext powerreq config failed, err = %d\n", ret);
521 return ret;
522 }
523
524skip_pwr_req_config:
525 if (tps80031_pdata->ext_ctrl_flag & TPS80031_PWR_ON_ON_SLEEP) {
526 ret = tps80031_update(parent, TPS80031_SLAVE_ID1,
527 ri->rinfo->trans_reg, TPS80031_TRANS_SLEEP_ON,
528 TPS80031_TRANS_SLEEP_MASK);
529 if (ret < 0) {
530 dev_err(ri->dev, "Reg 0x%02x update failed, e %d\n",
531 ri->rinfo->trans_reg, ret);
532 return ret;
533 }
534 }
535 return ret;
536}
537
538static int tps80031_regulator_config(struct device *parent,
539 struct tps80031_regulator *ri,
540 struct tps80031_regulator_platform_data *tps80031_pdata)
541{
542 int ret = 0;
543
544 switch (ri->rinfo->desc.id) {
545 case TPS80031_REGULATOR_LDOUSB:
546 if (ri->config_flags & (TPS80031_USBLDO_INPUT_VSYS |
547 TPS80031_USBLDO_INPUT_PMID)) {
548 unsigned val = 0;
549 if (ri->config_flags & TPS80031_USBLDO_INPUT_VSYS)
550 val = MISC2_LDOUSB_IN_VSYS;
551 else
552 val = MISC2_LDOUSB_IN_PMID;
553
554 ret = tps80031_update(parent, TPS80031_SLAVE_ID1,
555 TPS80031_MISC2, val,
556 MISC2_LDOUSB_IN_MASK);
557 if (ret < 0) {
558 dev_err(ri->dev,
559 "LDOUSB config failed, e= %d\n", ret);
560 return ret;
561 }
562 }
563 break;
564
565 case TPS80031_REGULATOR_LDO3:
566 if (ri->config_flags & TPS80031_LDO3_OUTPUT_VIB) {
567 ret = tps80031_update(parent, TPS80031_SLAVE_ID1,
568 TPS80031_MISC2, MISC2_LDO3_SEL_VIB_VAL,
569 MISC2_LDO3_SEL_VIB_MASK);
570 if (ret < 0) {
571 dev_err(ri->dev,
572 "LDO3 config failed, e = %d\n", ret);
573 return ret;
574 }
575 }
576 break;
577
578 case TPS80031_REGULATOR_VBUS:
579 /* Provide SW control Ops if VBUS is SW control */
580 if (!(ri->config_flags & TPS80031_VBUS_SW_ONLY))
581 ri->rinfo->desc.ops = &tps80031_vbus_sw_ops;
582 break;
583 default:
584 break;
585 }
586
587 /* Configure Active state to ON, SLEEP to OFF and OFF_state to OFF */
588 ret = tps80031_update(parent, TPS80031_SLAVE_ID1, ri->rinfo->trans_reg,
589 TPS80031_TRANS_ACTIVE_ON | TPS80031_TRANS_SLEEP_OFF |
590 TPS80031_TRANS_OFF_OFF, TPS80031_TRANS_ACTIVE_MASK |
591 TPS80031_TRANS_SLEEP_MASK | TPS80031_TRANS_OFF_MASK);
592 if (ret < 0) {
593 dev_err(ri->dev, "trans reg update failed, e %d\n", ret);
594 return ret;
595 }
596
597 return ret;
598}
599
600static int check_smps_mode_mult(struct device *parent,
601 struct tps80031_regulator *ri)
602{
603 int mult_offset;
604 int ret;
605 u8 smps_offset;
606 u8 smps_mult;
607
608 ret = tps80031_read(parent, TPS80031_SLAVE_ID1,
609 TPS80031_SMPS_OFFSET, &smps_offset);
610 if (ret < 0) {
611 dev_err(parent, "Error in reading smps offset register\n");
612 return ret;
613 }
614
615 ret = tps80031_read(parent, TPS80031_SLAVE_ID1,
616 TPS80031_SMPS_MULT, &smps_mult);
617 if (ret < 0) {
618 dev_err(parent, "Error in reading smps mult register\n");
619 return ret;
620 }
621
622 switch (ri->rinfo->desc.id) {
623 case TPS80031_REGULATOR_VIO:
624 mult_offset = SMPS_MULTOFFSET_VIO;
625 break;
626 case TPS80031_REGULATOR_SMPS1:
627 mult_offset = SMPS_MULTOFFSET_SMPS1;
628 break;
629 case TPS80031_REGULATOR_SMPS2:
630 mult_offset = SMPS_MULTOFFSET_SMPS2;
631 break;
632 case TPS80031_REGULATOR_SMPS3:
633 mult_offset = SMPS_MULTOFFSET_SMPS3;
634 break;
635 case TPS80031_REGULATOR_SMPS4:
636 mult_offset = SMPS_MULTOFFSET_SMPS4;
637 break;
638 case TPS80031_REGULATOR_LDO2:
639 ri->device_flags = smps_mult & BIT(5) ? TRACK_MODE_ENABLE : 0;
640 /* TRACK mode the ldo2 varies from 600mV to 1300mV */
641 if (ri->device_flags & TRACK_MODE_ENABLE) {
642 ri->rinfo->desc.min_uV = 600000;
643 ri->rinfo->desc.uV_step = 12500;
644 ri->rinfo->desc.n_voltages = 57;
645 ri->rinfo->desc.vsel_mask = LDO_TRACK_VSEL_MASK;
646 }
647 return 0;
648 default:
649 return 0;
650 }
651
652 ri->device_flags = (smps_offset & mult_offset) ? DCDC_OFFSET_EN : 0;
653 ri->device_flags |= (smps_mult & mult_offset) ? DCDC_EXTENDED_EN : 0;
654 switch (ri->device_flags) {
655 case 0:
656 ri->rinfo->desc.min_uV = 607700;
657 ri->rinfo->desc.uV_step = 12660;
658 break;
659 case DCDC_OFFSET_EN:
660 ri->rinfo->desc.min_uV = 700000;
661 ri->rinfo->desc.uV_step = 12500;
662 break;
663 case DCDC_EXTENDED_EN:
664 ri->rinfo->desc.min_uV = 1852000;
665 ri->rinfo->desc.uV_step = 38600;
666 break;
667 case DCDC_OFFSET_EN | DCDC_EXTENDED_EN:
668 ri->rinfo->desc.min_uV = 2161000;
669 ri->rinfo->desc.uV_step = 38600;
670 break;
671 }
672 return 0;
673}
674
675static int tps80031_regulator_probe(struct platform_device *pdev)
676{
677 struct tps80031_platform_data *pdata;
678 struct tps80031_regulator_platform_data *tps_pdata;
679 struct tps80031_regulator *ri;
680 struct tps80031_regulator *pmic;
681 struct regulator_dev *rdev;
682 struct regulator_config config = { };
683 int ret;
684 int num;
685
686 pdata = dev_get_platdata(pdev->dev.parent);
687
688 if (!pdata) {
689 dev_err(&pdev->dev, "No platform data\n");
690 return -EINVAL;
691 }
692
693 pmic = devm_kzalloc(&pdev->dev,
694 TPS80031_REGULATOR_MAX * sizeof(*pmic), GFP_KERNEL);
695 if (!pmic) {
696 dev_err(&pdev->dev, "mem alloc for pmic failed\n");
697 return -ENOMEM;
698 }
699
700 for (num = 0; num < TPS80031_REGULATOR_MAX; ++num) {
701 tps_pdata = pdata->regulator_pdata[num];
702 ri = &pmic[num];
703 ri->rinfo = &tps80031_rinfo[num];
704 ri->dev = &pdev->dev;
705
706 check_smps_mode_mult(pdev->dev.parent, ri);
707 config.dev = &pdev->dev;
708 config.init_data = NULL;
709 config.driver_data = ri;
710 if (tps_pdata) {
711 config.init_data = tps_pdata->reg_init_data;
712 ri->config_flags = tps_pdata->config_flags;
713 ri->ext_ctrl_flag = tps_pdata->ext_ctrl_flag;
714 ret = tps80031_regulator_config(pdev->dev.parent,
715 ri, tps_pdata);
716 if (ret < 0) {
717 dev_err(&pdev->dev,
718 "regulator config failed, e %d\n", ret);
719 goto fail;
720 }
721
722 ret = tps80031_power_req_config(pdev->dev.parent,
723 ri, tps_pdata);
724 if (ret < 0) {
725 dev_err(&pdev->dev,
726 "pwr_req config failed, err %d\n", ret);
727 goto fail;
728 }
729 }
730 rdev = regulator_register(&ri->rinfo->desc, &config);
731 if (IS_ERR_OR_NULL(rdev)) {
732 dev_err(&pdev->dev,
733 "register regulator failed %s\n",
734 ri->rinfo->desc.name);
735 ret = PTR_ERR(rdev);
736 goto fail;
737 }
738 ri->rdev = rdev;
739 }
740
741 platform_set_drvdata(pdev, pmic);
742 return 0;
743fail:
744 while (--num >= 0) {
745 ri = &pmic[num];
746 regulator_unregister(ri->rdev);
747 }
748 return ret;
749}
750
751static int tps80031_regulator_remove(struct platform_device *pdev)
752{
753 struct tps80031_regulator *pmic = platform_get_drvdata(pdev);
754 struct tps80031_regulator *ri = NULL;
755 int num;
756
757 for (num = 0; num < TPS80031_REGULATOR_MAX; ++num) {
758 ri = &pmic[num];
759 regulator_unregister(ri->rdev);
760 }
761 return 0;
762}
763
764static struct platform_driver tps80031_regulator_driver = {
765 .driver = {
766 .name = "tps80031-pmic",
767 .owner = THIS_MODULE,
768 },
769 .probe = tps80031_regulator_probe,
770 .remove = tps80031_regulator_remove,
771};
772
773static int __init tps80031_regulator_init(void)
774{
775 return platform_driver_register(&tps80031_regulator_driver);
776}
777subsys_initcall(tps80031_regulator_init);
778
779static void __exit tps80031_regulator_exit(void)
780{
781 platform_driver_unregister(&tps80031_regulator_driver);
782}
783module_exit(tps80031_regulator_exit);
784
785MODULE_ALIAS("platform:tps80031-regulator");
786MODULE_DESCRIPTION("Regulator Driver for TI TPS80031/TPS80032 PMIC");
787MODULE_AUTHOR("Laxman Dewangan <ldewangan@nvidia.com>");
788MODULE_LICENSE("GPL v2");
diff --git a/drivers/regulator/twl-regulator.c b/drivers/regulator/twl-regulator.c
index 7eb986a40746..493c8c6a241f 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 000000000000..4668c7f8133d
--- /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 c038e7422538..01c66e9712a4 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 782c228a19bd..0af6898bcd79 100644
--- a/drivers/regulator/wm831x-dcdc.c
+++ b/drivers/regulator/wm831x-dcdc.c
@@ -223,7 +223,7 @@ static int wm831x_buckv_map_voltage(struct regulator_dev *rdev,
223 if (min_uV < 600000) 223 if (min_uV < 600000)
224 vsel = 0; 224 vsel = 0;
225 else if (min_uV <= 1800000) 225 else if (min_uV <= 1800000)
226 vsel = ((min_uV - 600000) / 12500) + 8; 226 vsel = DIV_ROUND_UP(min_uV - 600000, 12500) + 8;
227 else 227 else
228 return -EINVAL; 228 return -EINVAL;
229 229
@@ -290,7 +290,7 @@ static int wm831x_buckv_set_voltage_sel(struct regulator_dev *rdev,
290 if (vsel > dcdc->dvs_vsel) { 290 if (vsel > dcdc->dvs_vsel) {
291 ret = wm831x_set_bits(wm831x, dvs_reg, 291 ret = wm831x_set_bits(wm831x, dvs_reg,
292 WM831X_DC1_DVS_VSEL_MASK, 292 WM831X_DC1_DVS_VSEL_MASK,
293 dcdc->dvs_vsel); 293 vsel);
294 if (ret == 0) 294 if (ret == 0)
295 dcdc->dvs_vsel = vsel; 295 dcdc->dvs_vsel = vsel;
296 else 296 else
@@ -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,
@@ -993,4 +993,5 @@ MODULE_DESCRIPTION("WM831x DC-DC convertor driver");
993MODULE_LICENSE("GPL"); 993MODULE_LICENSE("GPL");
994MODULE_ALIAS("platform:wm831x-buckv"); 994MODULE_ALIAS("platform:wm831x-buckv");
995MODULE_ALIAS("platform:wm831x-buckp"); 995MODULE_ALIAS("platform:wm831x-buckp");
996MODULE_ALIAS("platform:wm831x-boostp");
996MODULE_ALIAS("platform:wm831x-epe"); 997MODULE_ALIAS("platform:wm831x-epe");
diff --git a/drivers/regulator/wm831x-isink.c b/drivers/regulator/wm831x-isink.c
index 2646a1902b33..68586ee3e1cb 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 c2dc03993dc7..1ec379a9a95c 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 27c746ef0636..c6a32ea80b9d 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 86bb48db149e..6ff872342648 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/arizona/registers.h b/include/linux/mfd/arizona/registers.h
index 7671a287dfee..ba26e99c388d 100644
--- a/include/linux/mfd/arizona/registers.h
+++ b/include/linux/mfd/arizona/registers.h
@@ -76,6 +76,7 @@
76#define ARIZONA_RATE_ESTIMATOR_3 0x154 76#define ARIZONA_RATE_ESTIMATOR_3 0x154
77#define ARIZONA_RATE_ESTIMATOR_4 0x155 77#define ARIZONA_RATE_ESTIMATOR_4 0x155
78#define ARIZONA_RATE_ESTIMATOR_5 0x156 78#define ARIZONA_RATE_ESTIMATOR_5 0x156
79#define ARIZONA_DYNAMIC_FREQUENCY_SCALING_1 0x161
79#define ARIZONA_FLL1_CONTROL_1 0x171 80#define ARIZONA_FLL1_CONTROL_1 0x171
80#define ARIZONA_FLL1_CONTROL_2 0x172 81#define ARIZONA_FLL1_CONTROL_2 0x172
81#define ARIZONA_FLL1_CONTROL_3 0x173 82#define ARIZONA_FLL1_CONTROL_3 0x173
@@ -110,6 +111,7 @@
110#define ARIZONA_FLL2_GPIO_CLOCK 0x1AA 111#define ARIZONA_FLL2_GPIO_CLOCK 0x1AA
111#define ARIZONA_MIC_CHARGE_PUMP_1 0x200 112#define ARIZONA_MIC_CHARGE_PUMP_1 0x200
112#define ARIZONA_LDO1_CONTROL_1 0x210 113#define ARIZONA_LDO1_CONTROL_1 0x210
114#define ARIZONA_LDO1_CONTROL_2 0x212
113#define ARIZONA_LDO2_CONTROL_1 0x213 115#define ARIZONA_LDO2_CONTROL_1 0x213
114#define ARIZONA_MIC_BIAS_CTRL_1 0x218 116#define ARIZONA_MIC_BIAS_CTRL_1 0x218
115#define ARIZONA_MIC_BIAS_CTRL_2 0x219 117#define ARIZONA_MIC_BIAS_CTRL_2 0x219
@@ -1574,6 +1576,13 @@
1574#define ARIZONA_SAMPLE_RATE_DETECT_D_WIDTH 5 /* SAMPLE_RATE_DETECT_D - [4:0] */ 1576#define ARIZONA_SAMPLE_RATE_DETECT_D_WIDTH 5 /* SAMPLE_RATE_DETECT_D - [4:0] */
1575 1577
1576/* 1578/*
1579 * R353 (0x161) - Dynamic Frequency Scaling 1
1580 */
1581#define ARIZONA_SUBSYS_MAX_FREQ 0x0001 /* SUBSYS_MAX_FREQ */
1582#define ARIZONA_SUBSYS_MAX_FREQ_SHIFT 0 /* SUBSYS_MAX_FREQ */
1583#define ARIZONA_SUBSYS_MAX_FREQ_WIDTH 1 /* SUBSYS_MAX_FREQ */
1584
1585/*
1577 * R369 (0x171) - FLL1 Control 1 1586 * R369 (0x171) - FLL1 Control 1
1578 */ 1587 */
1579#define ARIZONA_FLL1_FREERUN 0x0002 /* FLL1_FREERUN */ 1588#define ARIZONA_FLL1_FREERUN 0x0002 /* FLL1_FREERUN */
@@ -1889,6 +1898,13 @@
1889#define ARIZONA_LDO1_ENA_WIDTH 1 /* LDO1_ENA */ 1898#define ARIZONA_LDO1_ENA_WIDTH 1 /* LDO1_ENA */
1890 1899
1891/* 1900/*
1901 * R530 (0x212) - LDO1 Control 2
1902 */
1903#define ARIZONA_LDO1_HI_PWR 0x0001 /* LDO1_HI_PWR */
1904#define ARIZONA_LDO1_HI_PWR_SHIFT 0 /* LDO1_HI_PWR */
1905#define ARIZONA_LDO1_HI_PWR_WIDTH 1 /* LDO1_HI_PWR */
1906
1907/*
1892 * R531 (0x213) - LDO2 Control 1 1908 * R531 (0x213) - LDO2 Control 1
1893 */ 1909 */
1894#define ARIZONA_LDO2_VSEL_MASK 0x07E0 /* LDO2_VSEL - [10:5] */ 1910#define ARIZONA_LDO2_VSEL_MASK 0x07E0 /* LDO2_VSEL - [10:5] */
diff --git a/include/linux/mfd/da9055/pdata.h b/include/linux/mfd/da9055/pdata.h
index 147293b4471d..f87a6c172a91 100644
--- a/include/linux/mfd/da9055/pdata.h
+++ b/include/linux/mfd/da9055/pdata.h
@@ -25,8 +25,29 @@ struct da9055_pdata {
25 int gpio_base; 25 int gpio_base;
26 26
27 struct regulator_init_data *regulators[DA9055_MAX_REGULATORS]; 27 struct regulator_init_data *regulators[DA9055_MAX_REGULATORS];
28 bool reset_enable; /* Enable RTC in RESET Mode */ 28 /* Enable RTC in RESET Mode */
29 enum gpio_select *gpio_rsel; /* Select regulator set thru GPIO 1/2 */ 29 bool reset_enable;
30 enum gpio_select *gpio_ren; /* Enable regulator thru GPIO 1/2 */ 30 /*
31 * GPI muxed pin to control
32 * regulator state A/B, 0 if not available.
33 */
34 int *gpio_ren;
35 /*
36 * GPI muxed pin to control
37 * regulator set, 0 if not available.
38 */
39 int *gpio_rsel;
40 /*
41 * Regulator mode control bits value (GPI offset) that
42 * that controls the regulator state, 0 if not available.
43 */
44 enum gpio_select *reg_ren;
45 /*
46 * Regulator mode control bits value (GPI offset) that
47 * controls the regulator set A/B, 0 if not available.
48 */
49 enum gpio_select *reg_rsel;
50 /* GPIOs to enable regulator, 0 if not available */
51 int *ena_gpio;
31}; 52};
32#endif /* __DA9055_PDATA_H */ 53#endif /* __DA9055_PDATA_H */
diff --git a/include/linux/mfd/max8997-private.h b/include/linux/mfd/max8997-private.h
index 830152cfae33..6ae21bf47d64 100644
--- a/include/linux/mfd/max8997-private.h
+++ b/include/linux/mfd/max8997-private.h
@@ -316,6 +316,7 @@ enum max8997_irq {
316#define MAX8997_NUM_GPIO 12 316#define MAX8997_NUM_GPIO 12
317struct max8997_dev { 317struct max8997_dev {
318 struct device *dev; 318 struct device *dev;
319 struct max8997_platform_data *pdata;
319 struct i2c_client *i2c; /* 0xcc / PMIC, Battery Control, and FLASH */ 320 struct i2c_client *i2c; /* 0xcc / PMIC, Battery Control, and FLASH */
320 struct i2c_client *rtc; /* slave addr 0x0c */ 321 struct i2c_client *rtc; /* slave addr 0x0c */
321 struct i2c_client *haptic; /* slave addr 0x90 */ 322 struct i2c_client *haptic; /* slave addr 0x90 */
diff --git a/include/linux/mfd/max8997.h b/include/linux/mfd/max8997.h
index 328d8e24b533..1d4a4fe6ac33 100644
--- a/include/linux/mfd/max8997.h
+++ b/include/linux/mfd/max8997.h
@@ -75,6 +75,7 @@ enum max8998_regulators {
75struct max8997_regulator_data { 75struct max8997_regulator_data {
76 int id; 76 int id;
77 struct regulator_init_data *initdata; 77 struct regulator_init_data *initdata;
78 struct device_node *reg_node;
78}; 79};
79 80
80enum max8997_muic_usb_type { 81enum max8997_muic_usb_type {
diff --git a/include/linux/mfd/tps65090.h b/include/linux/mfd/tps65090.h
index 6bc31d854626..804e280c1e1d 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 2dd123194958..f8da0e152567 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/consumer.h b/include/linux/regulator/consumer.h
index c43cd3556b1f..7bc732ce6e50 100644
--- a/include/linux/regulator/consumer.h
+++ b/include/linux/regulator/consumer.h
@@ -160,6 +160,7 @@ int regulator_bulk_force_disable(int num_consumers,
160void regulator_bulk_free(int num_consumers, 160void regulator_bulk_free(int num_consumers,
161 struct regulator_bulk_data *consumers); 161 struct regulator_bulk_data *consumers);
162 162
163int regulator_can_change_voltage(struct regulator *regulator);
163int regulator_count_voltages(struct regulator *regulator); 164int regulator_count_voltages(struct regulator *regulator);
164int regulator_list_voltage(struct regulator *regulator, unsigned selector); 165int regulator_list_voltage(struct regulator *regulator, unsigned selector);
165int regulator_is_supported_voltage(struct regulator *regulator, 166int regulator_is_supported_voltage(struct regulator *regulator,
@@ -358,6 +359,10 @@ static inline void regulator_set_drvdata(struct regulator *regulator,
358{ 359{
359} 360}
360 361
362static inline int regulator_count_voltages(struct regulator *regulator)
363{
364 return 0;
365}
361#endif 366#endif
362 367
363static inline int regulator_set_voltage_tol(struct regulator *regulator, 368static inline int regulator_set_voltage_tol(struct regulator *regulator,
@@ -367,4 +372,12 @@ static inline int regulator_set_voltage_tol(struct regulator *regulator,
367 new_uV - tol_uV, new_uV + tol_uV); 372 new_uV - tol_uV, new_uV + tol_uV);
368} 373}
369 374
375static inline int regulator_is_supported_voltage_tol(struct regulator *regulator,
376 int target_uV, int tol_uV)
377{
378 return regulator_is_supported_voltage(regulator,
379 target_uV - tol_uV,
380 target_uV + tol_uV);
381}
382
370#endif 383#endif
diff --git a/include/linux/regulator/driver.h b/include/linux/regulator/driver.h
index 7932a3bf21bd..d10bb0f39c5e 100644
--- a/include/linux/regulator/driver.h
+++ b/include/linux/regulator/driver.h
@@ -181,10 +181,13 @@ 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)
187 * @uV_step: Voltage increase with each selector (if linear mapping) 189 * @uV_step: Voltage increase with each selector (if linear mapping)
190 * @linear_min_sel: Minimal selector for starting linear mapping
188 * @ramp_delay: Time to settle down after voltage change (unit: uV/us) 191 * @ramp_delay: Time to settle down after voltage change (unit: uV/us)
189 * @volt_table: Voltage mapping table (if table based mapping) 192 * @volt_table: Voltage mapping table (if table based mapping)
190 * 193 *
@@ -199,6 +202,7 @@ struct regulator_desc {
199 const char *name; 202 const char *name;
200 const char *supply_name; 203 const char *supply_name;
201 int id; 204 int id;
205 bool continuous_voltage_range;
202 unsigned n_voltages; 206 unsigned n_voltages;
203 struct regulator_ops *ops; 207 struct regulator_ops *ops;
204 int irq; 208 int irq;
@@ -207,6 +211,7 @@ struct regulator_desc {
207 211
208 unsigned int min_uV; 212 unsigned int min_uV;
209 unsigned int uV_step; 213 unsigned int uV_step;
214 unsigned int linear_min_sel;
210 unsigned int ramp_delay; 215 unsigned int ramp_delay;
211 216
212 const unsigned int *volt_table; 217 const unsigned int *volt_table;
diff --git a/include/linux/regulator/max8973-regulator.h b/include/linux/regulator/max8973-regulator.h
new file mode 100644
index 000000000000..f8acc052e353
--- /dev/null
+++ b/include/linux/regulator/max8973-regulator.h
@@ -0,0 +1,72 @@
1/*
2 * max8973-regulator.h -- MAXIM 8973 regulator
3 *
4 * Interface for regulator driver for MAXIM 8973 DC-DC step-down
5 * switching regulator.
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_MAX8973_H
28#define __LINUX_REGULATOR_MAX8973_H
29
30/*
31 * Control flags for configuration of the device.
32 * Client need to pass this information with ORed
33 */
34#define MAX8973_CONTROL_REMOTE_SENSE_ENABLE 0x00000001
35#define MAX8973_CONTROL_FALLING_SLEW_RATE_ENABLE 0x00000002
36#define MAX8973_CONTROL_OUTPUT_ACTIVE_DISCH_ENABLE 0x00000004
37#define MAX8973_CONTROL_BIAS_ENABLE 0x00000008
38#define MAX8973_CONTROL_PULL_DOWN_ENABLE 0x00000010
39#define MAX8973_CONTROL_FREQ_SHIFT_9PER_ENABLE 0x00000020
40
41#define MAX8973_CONTROL_CLKADV_TRIP_DISABLED 0x00000000
42#define MAX8973_CONTROL_CLKADV_TRIP_75mV_PER_US 0x00010000
43#define MAX8973_CONTROL_CLKADV_TRIP_150mV_PER_US 0x00020000
44#define MAX8973_CONTROL_CLKADV_TRIP_75mV_PER_US_HIST_DIS 0x00030000
45
46#define MAX8973_CONTROL_INDUCTOR_VALUE_NOMINAL 0x00000000
47#define MAX8973_CONTROL_INDUCTOR_VALUE_MINUS_30_PER 0x00100000
48#define MAX8973_CONTROL_INDUCTOR_VALUE_PLUS_30_PER 0x00200000
49#define MAX8973_CONTROL_INDUCTOR_VALUE_PLUS_60_PER 0x00300000
50
51/*
52 * struct max8973_regulator_platform_data - max8973 regulator platform data.
53 *
54 * @reg_init_data: The regulator init data.
55 * @control_flags: Control flags which are ORed value of above flags to
56 * configure device.
57 * @enable_ext_control: Enable the voltage enable/disable through external
58 * control signal from EN input pin. If it is false then
59 * voltage output will be enabled/disabled through EN bit of
60 * device register.
61 * @dvs_gpio: GPIO for dvs. It should be -1 if this is tied with fixed logic.
62 * @dvs_def_state: Default state of dvs. 1 if it is high else 0.
63 */
64struct max8973_regulator_platform_data {
65 struct regulator_init_data *reg_init_data;
66 unsigned long control_flags;
67 bool enable_ext_control;
68 int dvs_gpio;
69 unsigned dvs_def_state:1;
70};
71
72#endif /* __LINUX_REGULATOR_MAX8973_H */
diff --git a/include/linux/regulator/tps51632-regulator.h b/include/linux/regulator/tps51632-regulator.h
new file mode 100644
index 000000000000..d00841e1a75a
--- /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 0fa04b64db3e..000000000000
--- 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 */