aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/devicetree/bindings/regulator/act8865-regulator.txt27
-rw-r--r--Documentation/power/regulator/consumer.txt2
-rw-r--r--drivers/gpu/drm/msm/edp/edp_ctrl.c6
-rw-r--r--drivers/phy/phy-qcom-ufs.c4
-rw-r--r--drivers/regulator/act8865-regulator.c161
-rw-r--r--drivers/regulator/arizona-ldo1.c5
-rw-r--r--drivers/regulator/arizona-micsupp.c5
-rw-r--r--drivers/regulator/core.c259
-rw-r--r--drivers/regulator/da9211-regulator.c8
-rw-r--r--drivers/regulator/dbx500-prcmu.c32
-rw-r--r--drivers/regulator/devres.c85
-rw-r--r--drivers/regulator/max77693.c93
-rw-r--r--drivers/regulator/max8660.c9
-rw-r--r--drivers/regulator/palmas-regulator.c11
-rw-r--r--drivers/regulator/qcom_rpm-regulator.c312
-rw-r--r--drivers/regulator/stw481x-vmmc.c8
-rw-r--r--drivers/regulator/wm8350-regulator.c5
-rw-r--r--drivers/scsi/ufs/ufshcd.c27
-rw-r--r--drivers/usb/phy/phy-ab8500-usb.c4
-rw-r--r--drivers/usb/phy/phy-msm-usb.c15
-rw-r--r--include/linux/mfd/max77693.h12
-rw-r--r--include/linux/mfd/palmas.h1
-rw-r--r--include/linux/mfd/stw481x.h4
-rw-r--r--include/linux/regulator/act8865.h14
-rw-r--r--include/linux/regulator/consumer.h23
-rw-r--r--include/linux/regulator/driver.h4
26 files changed, 778 insertions, 358 deletions
diff --git a/Documentation/devicetree/bindings/regulator/act8865-regulator.txt b/Documentation/devicetree/bindings/regulator/act8865-regulator.txt
index dad6358074ac..e91485d11241 100644
--- a/Documentation/devicetree/bindings/regulator/act8865-regulator.txt
+++ b/Documentation/devicetree/bindings/regulator/act8865-regulator.txt
@@ -2,13 +2,35 @@ ACT88xx regulators
2------------------- 2-------------------
3 3
4Required properties: 4Required properties:
5- compatible: "active-semi,act8846" or "active-semi,act8865" 5- compatible: "active-semi,act8846" or "active-semi,act8865" or "active-semi,act8600"
6- reg: I2C slave address 6- reg: I2C slave address
7 7
8Optional properties: 8Optional properties:
9- system-power-controller: Telling whether or not this pmic is controlling 9- system-power-controller: Telling whether or not this pmic is controlling
10 the system power. See Documentation/devicetree/bindings/power/power-controller.txt . 10 the system power. See Documentation/devicetree/bindings/power/power-controller.txt .
11 11
12Optional input supply properties:
13- for act8600:
14 - vp1-supply: The input supply for DCDC_REG1
15 - vp2-supply: The input supply for DCDC_REG2
16 - vp3-supply: The input supply for DCDC_REG3
17 - inl-supply: The input supply for LDO_REG5, LDO_REG6, LDO_REG7 and LDO_REG8
18 SUDCDC_REG4, LDO_REG9 and LDO_REG10 do not have separate supplies.
19- for act8846:
20 - vp1-supply: The input supply for REG1
21 - vp2-supply: The input supply for REG2
22 - vp3-supply: The input supply for REG3
23 - vp4-supply: The input supply for REG4
24 - inl1-supply: The input supply for REG5, REG6 and REG7
25 - inl2-supply: The input supply for REG8 and LDO_REG9
26 - inl3-supply: The input supply for REG10, REG11 and REG12
27- for act8865:
28 - vp1-supply: The input supply for DCDC_REG1
29 - vp2-supply: The input supply for DCDC_REG2
30 - vp3-supply: The input supply for DCDC_REG3
31 - inl45-supply: The input supply for LDO_REG1 and LDO_REG2
32 - inl67-supply: The input supply for LDO_REG3 and LDO_REG4
33
12Any standard regulator properties can be used to configure the single regulator. 34Any standard regulator properties can be used to configure the single regulator.
13 35
14The valid names for regulators are: 36The valid names for regulators are:
@@ -16,6 +38,9 @@ The valid names for regulators are:
16 REG1, REG2, REG3, REG4, REG5, REG6, REG7, REG8, REG9, REG10, REG11, REG12 38 REG1, REG2, REG3, REG4, REG5, REG6, REG7, REG8, REG9, REG10, REG11, REG12
17 - for act8865: 39 - for act8865:
18 DCDC_REG1, DCDC_REG2, DCDC_REG3, LDO_REG1, LDO_REG2, LDO_REG3, LDO_REG4. 40 DCDC_REG1, DCDC_REG2, DCDC_REG3, LDO_REG1, LDO_REG2, LDO_REG3, LDO_REG4.
41 - for act8600:
42 DCDC_REG1, DCDC_REG2, DCDC_REG3, SUDCDC_REG4, LDO_REG5, LDO_REG6, LDO_REG7,
43 LDO_REG8, LDO_REG9, LDO_REG10,
19 44
20Example: 45Example:
21-------- 46--------
diff --git a/Documentation/power/regulator/consumer.txt b/Documentation/power/regulator/consumer.txt
index 8afb236ca765..e51564c1a140 100644
--- a/Documentation/power/regulator/consumer.txt
+++ b/Documentation/power/regulator/consumer.txt
@@ -137,7 +137,7 @@ Indirect operating mode control.
137Consumer drivers can request a change in their supply regulator operating mode 137Consumer drivers can request a change in their supply regulator operating mode
138by calling :- 138by calling :-
139 139
140int regulator_set_optimum_mode(struct regulator *regulator, int load_uA); 140int regulator_set_load(struct regulator *regulator, int load_uA);
141 141
142This will cause the core to recalculate the total load on the regulator (based 142This will cause the core to recalculate the total load on the regulator (based
143on all its consumers) and change operating mode (if necessary and permitted) 143on all its consumers) and change operating mode (if necessary and permitted)
diff --git a/drivers/gpu/drm/msm/edp/edp_ctrl.c b/drivers/gpu/drm/msm/edp/edp_ctrl.c
index 3e246210c46f..0ec5abdba5c4 100644
--- a/drivers/gpu/drm/msm/edp/edp_ctrl.c
+++ b/drivers/gpu/drm/msm/edp/edp_ctrl.c
@@ -332,7 +332,7 @@ static int edp_regulator_enable(struct edp_ctrl *ctrl)
332 goto vdda_set_fail; 332 goto vdda_set_fail;
333 } 333 }
334 334
335 ret = regulator_set_optimum_mode(ctrl->vdda_vreg, VDDA_UA_ON_LOAD); 335 ret = regulator_set_load(ctrl->vdda_vreg, VDDA_UA_ON_LOAD);
336 if (ret < 0) { 336 if (ret < 0) {
337 pr_err("%s: vdda_vreg set regulator mode failed.\n", __func__); 337 pr_err("%s: vdda_vreg set regulator mode failed.\n", __func__);
338 goto vdda_set_fail; 338 goto vdda_set_fail;
@@ -356,7 +356,7 @@ static int edp_regulator_enable(struct edp_ctrl *ctrl)
356lvl_enable_fail: 356lvl_enable_fail:
357 regulator_disable(ctrl->vdda_vreg); 357 regulator_disable(ctrl->vdda_vreg);
358vdda_enable_fail: 358vdda_enable_fail:
359 regulator_set_optimum_mode(ctrl->vdda_vreg, VDDA_UA_OFF_LOAD); 359 regulator_set_load(ctrl->vdda_vreg, VDDA_UA_OFF_LOAD);
360vdda_set_fail: 360vdda_set_fail:
361 return ret; 361 return ret;
362} 362}
@@ -365,7 +365,7 @@ static void edp_regulator_disable(struct edp_ctrl *ctrl)
365{ 365{
366 regulator_disable(ctrl->lvl_vreg); 366 regulator_disable(ctrl->lvl_vreg);
367 regulator_disable(ctrl->vdda_vreg); 367 regulator_disable(ctrl->vdda_vreg);
368 regulator_set_optimum_mode(ctrl->vdda_vreg, VDDA_UA_OFF_LOAD); 368 regulator_set_load(ctrl->vdda_vreg, VDDA_UA_OFF_LOAD);
369} 369}
370 370
371static int edp_gpio_config(struct edp_ctrl *ctrl) 371static int edp_gpio_config(struct edp_ctrl *ctrl)
diff --git a/drivers/phy/phy-qcom-ufs.c b/drivers/phy/phy-qcom-ufs.c
index 44ee983d57fe..86665e9dc399 100644
--- a/drivers/phy/phy-qcom-ufs.c
+++ b/drivers/phy/phy-qcom-ufs.c
@@ -346,10 +346,10 @@ int ufs_qcom_phy_cfg_vreg(struct phy *phy,
346 goto out; 346 goto out;
347 } 347 }
348 uA_load = on ? vreg->max_uA : 0; 348 uA_load = on ? vreg->max_uA : 0;
349 ret = regulator_set_optimum_mode(reg, uA_load); 349 ret = regulator_set_load(reg, uA_load);
350 if (ret >= 0) { 350 if (ret >= 0) {
351 /* 351 /*
352 * regulator_set_optimum_mode() returns new regulator 352 * regulator_set_load() returns new regulator
353 * mode upon success. 353 * mode upon success.
354 */ 354 */
355 ret = 0; 355 ret = 0;
diff --git a/drivers/regulator/act8865-regulator.c b/drivers/regulator/act8865-regulator.c
index 9eec453b745d..2ff73d72ca34 100644
--- a/drivers/regulator/act8865-regulator.c
+++ b/drivers/regulator/act8865-regulator.c
@@ -29,6 +29,35 @@
29#include <linux/regmap.h> 29#include <linux/regmap.h>
30 30
31/* 31/*
32 * ACT8600 Global Register Map.
33 */
34#define ACT8600_SYS_MODE 0x00
35#define ACT8600_SYS_CTRL 0x01
36#define ACT8600_DCDC1_VSET 0x10
37#define ACT8600_DCDC1_CTRL 0x12
38#define ACT8600_DCDC2_VSET 0x20
39#define ACT8600_DCDC2_CTRL 0x22
40#define ACT8600_DCDC3_VSET 0x30
41#define ACT8600_DCDC3_CTRL 0x32
42#define ACT8600_SUDCDC4_VSET 0x40
43#define ACT8600_SUDCDC4_CTRL 0x41
44#define ACT8600_LDO5_VSET 0x50
45#define ACT8600_LDO5_CTRL 0x51
46#define ACT8600_LDO6_VSET 0x60
47#define ACT8600_LDO6_CTRL 0x61
48#define ACT8600_LDO7_VSET 0x70
49#define ACT8600_LDO7_CTRL 0x71
50#define ACT8600_LDO8_VSET 0x80
51#define ACT8600_LDO8_CTRL 0x81
52#define ACT8600_LDO910_CTRL 0x91
53#define ACT8600_APCH0 0xA1
54#define ACT8600_APCH1 0xA8
55#define ACT8600_APCH2 0xA9
56#define ACT8600_APCH_STAT 0xAA
57#define ACT8600_OTG0 0xB0
58#define ACT8600_OTG1 0xB2
59
60/*
32 * ACT8846 Global Register Map. 61 * ACT8846 Global Register Map.
33 */ 62 */
34#define ACT8846_SYS0 0x00 63#define ACT8846_SYS0 0x00
@@ -94,10 +123,15 @@
94#define ACT8865_ENA 0x80 /* ON - [7] */ 123#define ACT8865_ENA 0x80 /* ON - [7] */
95#define ACT8865_VSEL_MASK 0x3F /* VSET - [5:0] */ 124#define ACT8865_VSEL_MASK 0x3F /* VSET - [5:0] */
96 125
126
127#define ACT8600_LDO10_ENA 0x40 /* ON - [6] */
128#define ACT8600_SUDCDC_VSEL_MASK 0xFF /* SUDCDC VSET - [7:0] */
129
97/* 130/*
98 * ACT8865 voltage number 131 * ACT8865 voltage number
99 */ 132 */
100#define ACT8865_VOLTAGE_NUM 64 133#define ACT8865_VOLTAGE_NUM 64
134#define ACT8600_SUDCDC_VOLTAGE_NUM 255
101 135
102struct act8865 { 136struct act8865 {
103 struct regmap *regmap; 137 struct regmap *regmap;
@@ -116,6 +150,13 @@ static const struct regulator_linear_range act8865_voltage_ranges[] = {
116 REGULATOR_LINEAR_RANGE(2400000, 48, 63, 100000), 150 REGULATOR_LINEAR_RANGE(2400000, 48, 63, 100000),
117}; 151};
118 152
153static const struct regulator_linear_range act8600_sudcdc_voltage_ranges[] = {
154 REGULATOR_LINEAR_RANGE(3000000, 0, 63, 0),
155 REGULATOR_LINEAR_RANGE(3000000, 64, 159, 100000),
156 REGULATOR_LINEAR_RANGE(12600000, 160, 191, 200000),
157 REGULATOR_LINEAR_RANGE(19000000, 191, 255, 400000),
158};
159
119static struct regulator_ops act8865_ops = { 160static struct regulator_ops act8865_ops = {
120 .list_voltage = regulator_list_voltage_linear_range, 161 .list_voltage = regulator_list_voltage_linear_range,
121 .map_voltage = regulator_map_voltage_linear_range, 162 .map_voltage = regulator_map_voltage_linear_range,
@@ -126,9 +167,16 @@ static struct regulator_ops act8865_ops = {
126 .is_enabled = regulator_is_enabled_regmap, 167 .is_enabled = regulator_is_enabled_regmap,
127}; 168};
128 169
129#define ACT88xx_REG(_name, _family, _id, _vsel_reg) \ 170static struct regulator_ops act8865_ldo_ops = {
171 .enable = regulator_enable_regmap,
172 .disable = regulator_disable_regmap,
173 .is_enabled = regulator_is_enabled_regmap,
174};
175
176#define ACT88xx_REG(_name, _family, _id, _vsel_reg, _supply) \
130 [_family##_ID_##_id] = { \ 177 [_family##_ID_##_id] = { \
131 .name = _name, \ 178 .name = _name, \
179 .supply_name = _supply, \
132 .id = _family##_ID_##_id, \ 180 .id = _family##_ID_##_id, \
133 .type = REGULATOR_VOLTAGE, \ 181 .type = REGULATOR_VOLTAGE, \
134 .ops = &act8865_ops, \ 182 .ops = &act8865_ops, \
@@ -142,33 +190,80 @@ static struct regulator_ops act8865_ops = {
142 .owner = THIS_MODULE, \ 190 .owner = THIS_MODULE, \
143 } 191 }
144 192
193static const struct regulator_desc act8600_regulators[] = {
194 ACT88xx_REG("DCDC1", ACT8600, DCDC1, VSET, "vp1"),
195 ACT88xx_REG("DCDC2", ACT8600, DCDC2, VSET, "vp2"),
196 ACT88xx_REG("DCDC3", ACT8600, DCDC3, VSET, "vp3"),
197 {
198 .name = "SUDCDC_REG4",
199 .id = ACT8600_ID_SUDCDC4,
200 .ops = &act8865_ops,
201 .type = REGULATOR_VOLTAGE,
202 .n_voltages = ACT8600_SUDCDC_VOLTAGE_NUM,
203 .linear_ranges = act8600_sudcdc_voltage_ranges,
204 .n_linear_ranges = ARRAY_SIZE(act8600_sudcdc_voltage_ranges),
205 .vsel_reg = ACT8600_SUDCDC4_VSET,
206 .vsel_mask = ACT8600_SUDCDC_VSEL_MASK,
207 .enable_reg = ACT8600_SUDCDC4_CTRL,
208 .enable_mask = ACT8865_ENA,
209 .owner = THIS_MODULE,
210 },
211 ACT88xx_REG("LDO5", ACT8600, LDO5, VSET, "inl"),
212 ACT88xx_REG("LDO6", ACT8600, LDO6, VSET, "inl"),
213 ACT88xx_REG("LDO7", ACT8600, LDO7, VSET, "inl"),
214 ACT88xx_REG("LDO8", ACT8600, LDO8, VSET, "inl"),
215 {
216 .name = "LDO_REG9",
217 .id = ACT8600_ID_LDO9,
218 .ops = &act8865_ldo_ops,
219 .type = REGULATOR_VOLTAGE,
220 .n_voltages = 1,
221 .fixed_uV = 1800000,
222 .enable_reg = ACT8600_LDO910_CTRL,
223 .enable_mask = ACT8865_ENA,
224 .owner = THIS_MODULE,
225 },
226 {
227 .name = "LDO_REG10",
228 .id = ACT8600_ID_LDO10,
229 .ops = &act8865_ldo_ops,
230 .type = REGULATOR_VOLTAGE,
231 .n_voltages = 1,
232 .fixed_uV = 1200000,
233 .enable_reg = ACT8600_LDO910_CTRL,
234 .enable_mask = ACT8600_LDO10_ENA,
235 .owner = THIS_MODULE,
236 },
237};
238
145static const struct regulator_desc act8846_regulators[] = { 239static const struct regulator_desc act8846_regulators[] = {
146 ACT88xx_REG("REG1", ACT8846, REG1, VSET), 240 ACT88xx_REG("REG1", ACT8846, REG1, VSET, "vp1"),
147 ACT88xx_REG("REG2", ACT8846, REG2, VSET0), 241 ACT88xx_REG("REG2", ACT8846, REG2, VSET0, "vp2"),
148 ACT88xx_REG("REG3", ACT8846, REG3, VSET0), 242 ACT88xx_REG("REG3", ACT8846, REG3, VSET0, "vp3"),
149 ACT88xx_REG("REG4", ACT8846, REG4, VSET0), 243 ACT88xx_REG("REG4", ACT8846, REG4, VSET0, "vp4"),
150 ACT88xx_REG("REG5", ACT8846, REG5, VSET), 244 ACT88xx_REG("REG5", ACT8846, REG5, VSET, "inl1"),
151 ACT88xx_REG("REG6", ACT8846, REG6, VSET), 245 ACT88xx_REG("REG6", ACT8846, REG6, VSET, "inl1"),
152 ACT88xx_REG("REG7", ACT8846, REG7, VSET), 246 ACT88xx_REG("REG7", ACT8846, REG7, VSET, "inl1"),
153 ACT88xx_REG("REG8", ACT8846, REG8, VSET), 247 ACT88xx_REG("REG8", ACT8846, REG8, VSET, "inl2"),
154 ACT88xx_REG("REG9", ACT8846, REG9, VSET), 248 ACT88xx_REG("REG9", ACT8846, REG9, VSET, "inl2"),
155 ACT88xx_REG("REG10", ACT8846, REG10, VSET), 249 ACT88xx_REG("REG10", ACT8846, REG10, VSET, "inl3"),
156 ACT88xx_REG("REG11", ACT8846, REG11, VSET), 250 ACT88xx_REG("REG11", ACT8846, REG11, VSET, "inl3"),
157 ACT88xx_REG("REG12", ACT8846, REG12, VSET), 251 ACT88xx_REG("REG12", ACT8846, REG12, VSET, "inl3"),
158}; 252};
159 253
160static const struct regulator_desc act8865_regulators[] = { 254static const struct regulator_desc act8865_regulators[] = {
161 ACT88xx_REG("DCDC_REG1", ACT8865, DCDC1, VSET1), 255 ACT88xx_REG("DCDC_REG1", ACT8865, DCDC1, VSET1, "vp1"),
162 ACT88xx_REG("DCDC_REG2", ACT8865, DCDC2, VSET1), 256 ACT88xx_REG("DCDC_REG2", ACT8865, DCDC2, VSET1, "vp2"),
163 ACT88xx_REG("DCDC_REG3", ACT8865, DCDC3, VSET1), 257 ACT88xx_REG("DCDC_REG3", ACT8865, DCDC3, VSET1, "vp3"),
164 ACT88xx_REG("LDO_REG1", ACT8865, LDO1, VSET), 258 ACT88xx_REG("LDO_REG1", ACT8865, LDO1, VSET, "inl45"),
165 ACT88xx_REG("LDO_REG2", ACT8865, LDO2, VSET), 259 ACT88xx_REG("LDO_REG2", ACT8865, LDO2, VSET, "inl45"),
166 ACT88xx_REG("LDO_REG3", ACT8865, LDO3, VSET), 260 ACT88xx_REG("LDO_REG3", ACT8865, LDO3, VSET, "inl67"),
167 ACT88xx_REG("LDO_REG4", ACT8865, LDO4, VSET), 261 ACT88xx_REG("LDO_REG4", ACT8865, LDO4, VSET, "inl67"),
168}; 262};
169 263
170#ifdef CONFIG_OF 264#ifdef CONFIG_OF
171static const struct of_device_id act8865_dt_ids[] = { 265static const struct of_device_id act8865_dt_ids[] = {
266 { .compatible = "active-semi,act8600", .data = (void *)ACT8600 },
172 { .compatible = "active-semi,act8846", .data = (void *)ACT8846 }, 267 { .compatible = "active-semi,act8846", .data = (void *)ACT8846 },
173 { .compatible = "active-semi,act8865", .data = (void *)ACT8865 }, 268 { .compatible = "active-semi,act8865", .data = (void *)ACT8865 },
174 { } 269 { }
@@ -200,6 +295,19 @@ static struct of_regulator_match act8865_matches[] = {
200 [ACT8865_ID_LDO4] = { .name = "LDO_REG4"}, 295 [ACT8865_ID_LDO4] = { .name = "LDO_REG4"},
201}; 296};
202 297
298static struct of_regulator_match act8600_matches[] = {
299 [ACT8600_ID_DCDC1] = { .name = "DCDC_REG1"},
300 [ACT8600_ID_DCDC2] = { .name = "DCDC_REG2"},
301 [ACT8600_ID_DCDC3] = { .name = "DCDC_REG3"},
302 [ACT8600_ID_SUDCDC4] = { .name = "SUDCDC_REG4"},
303 [ACT8600_ID_LDO5] = { .name = "LDO_REG5"},
304 [ACT8600_ID_LDO6] = { .name = "LDO_REG6"},
305 [ACT8600_ID_LDO7] = { .name = "LDO_REG7"},
306 [ACT8600_ID_LDO8] = { .name = "LDO_REG8"},
307 [ACT8600_ID_LDO9] = { .name = "LDO_REG9"},
308 [ACT8600_ID_LDO10] = { .name = "LDO_REG10"},
309};
310
203static int act8865_pdata_from_dt(struct device *dev, 311static int act8865_pdata_from_dt(struct device *dev,
204 struct device_node **of_node, 312 struct device_node **of_node,
205 struct act8865_platform_data *pdata, 313 struct act8865_platform_data *pdata,
@@ -217,6 +325,10 @@ static int act8865_pdata_from_dt(struct device *dev,
217 } 325 }
218 326
219 switch (type) { 327 switch (type) {
328 case ACT8600:
329 matches = act8600_matches;
330 num_matches = ARRAY_SIZE(act8600_matches);
331 break;
220 case ACT8846: 332 case ACT8846:
221 matches = act8846_matches; 333 matches = act8846_matches;
222 num_matches = ARRAY_SIZE(act8846_matches); 334 num_matches = ARRAY_SIZE(act8846_matches);
@@ -317,6 +429,12 @@ static int act8865_pmic_probe(struct i2c_client *client,
317 } 429 }
318 430
319 switch (type) { 431 switch (type) {
432 case ACT8600:
433 regulators = act8600_regulators;
434 num_regulators = ARRAY_SIZE(act8600_regulators);
435 off_reg = -1;
436 off_mask = -1;
437 break;
320 case ACT8846: 438 case ACT8846:
321 regulators = act8846_regulators; 439 regulators = act8846_regulators;
322 num_regulators = ARRAY_SIZE(act8846_regulators); 440 num_regulators = ARRAY_SIZE(act8846_regulators);
@@ -366,7 +484,7 @@ static int act8865_pmic_probe(struct i2c_client *client,
366 } 484 }
367 485
368 if (of_device_is_system_power_controller(dev->of_node)) { 486 if (of_device_is_system_power_controller(dev->of_node)) {
369 if (!pm_power_off) { 487 if (!pm_power_off && (off_reg > 0)) {
370 act8865_i2c_client = client; 488 act8865_i2c_client = client;
371 act8865->off_reg = off_reg; 489 act8865->off_reg = off_reg;
372 act8865->off_mask = off_mask; 490 act8865->off_mask = off_mask;
@@ -402,6 +520,7 @@ static int act8865_pmic_probe(struct i2c_client *client,
402} 520}
403 521
404static const struct i2c_device_id act8865_ids[] = { 522static const struct i2c_device_id act8865_ids[] = {
523 { .name = "act8600", .driver_data = ACT8600 },
405 { .name = "act8846", .driver_data = ACT8846 }, 524 { .name = "act8846", .driver_data = ACT8846 },
406 { .name = "act8865", .driver_data = ACT8865 }, 525 { .name = "act8865", .driver_data = ACT8865 },
407 { }, 526 { },
diff --git a/drivers/regulator/arizona-ldo1.c b/drivers/regulator/arizona-ldo1.c
index 8169165904c0..a1d07d347c20 100644
--- a/drivers/regulator/arizona-ldo1.c
+++ b/drivers/regulator/arizona-ldo1.c
@@ -282,6 +282,9 @@ static int arizona_ldo1_probe(struct platform_device *pdev)
282 arizona->external_dcvdd = true; 282 arizona->external_dcvdd = true;
283 283
284 ldo1->regulator = devm_regulator_register(&pdev->dev, desc, &config); 284 ldo1->regulator = devm_regulator_register(&pdev->dev, desc, &config);
285
286 of_node_put(config.of_node);
287
285 if (IS_ERR(ldo1->regulator)) { 288 if (IS_ERR(ldo1->regulator)) {
286 ret = PTR_ERR(ldo1->regulator); 289 ret = PTR_ERR(ldo1->regulator);
287 dev_err(arizona->dev, "Failed to register LDO1 supply: %d\n", 290 dev_err(arizona->dev, "Failed to register LDO1 supply: %d\n",
@@ -289,8 +292,6 @@ static int arizona_ldo1_probe(struct platform_device *pdev)
289 return ret; 292 return ret;
290 } 293 }
291 294
292 of_node_put(config.of_node);
293
294 platform_set_drvdata(pdev, ldo1); 295 platform_set_drvdata(pdev, ldo1);
295 296
296 return 0; 297 return 0;
diff --git a/drivers/regulator/arizona-micsupp.c b/drivers/regulator/arizona-micsupp.c
index 20079006459a..4116e74effa4 100644
--- a/drivers/regulator/arizona-micsupp.c
+++ b/drivers/regulator/arizona-micsupp.c
@@ -284,6 +284,9 @@ static int arizona_micsupp_probe(struct platform_device *pdev)
284 micsupp->regulator = devm_regulator_register(&pdev->dev, 284 micsupp->regulator = devm_regulator_register(&pdev->dev,
285 desc, 285 desc,
286 &config); 286 &config);
287
288 of_node_put(config.of_node);
289
287 if (IS_ERR(micsupp->regulator)) { 290 if (IS_ERR(micsupp->regulator)) {
288 ret = PTR_ERR(micsupp->regulator); 291 ret = PTR_ERR(micsupp->regulator);
289 dev_err(arizona->dev, "Failed to register mic supply: %d\n", 292 dev_err(arizona->dev, "Failed to register mic supply: %d\n",
@@ -291,8 +294,6 @@ static int arizona_micsupp_probe(struct platform_device *pdev)
291 return ret; 294 return ret;
292 } 295 }
293 296
294 of_node_put(config.of_node);
295
296 platform_set_drvdata(pdev, micsupp); 297 platform_set_drvdata(pdev, micsupp);
297 298
298 return 0; 299 return 0;
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index a4a8a6dc60c4..443eaab933fc 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -648,10 +648,12 @@ static int drms_uA_update(struct regulator_dev *rdev)
648 if (err < 0) 648 if (err < 0)
649 return 0; 649 return 0;
650 650
651 if (!rdev->desc->ops->get_optimum_mode) 651 if (!rdev->desc->ops->get_optimum_mode &&
652 !rdev->desc->ops->set_load)
652 return 0; 653 return 0;
653 654
654 if (!rdev->desc->ops->set_mode) 655 if (!rdev->desc->ops->set_mode &&
656 !rdev->desc->ops->set_load)
655 return -EINVAL; 657 return -EINVAL;
656 658
657 /* get output voltage */ 659 /* get output voltage */
@@ -676,22 +678,29 @@ static int drms_uA_update(struct regulator_dev *rdev)
676 list_for_each_entry(sibling, &rdev->consumer_list, list) 678 list_for_each_entry(sibling, &rdev->consumer_list, list)
677 current_uA += sibling->uA_load; 679 current_uA += sibling->uA_load;
678 680
679 /* now get the optimum mode for our new total regulator load */ 681 if (rdev->desc->ops->set_load) {
680 mode = rdev->desc->ops->get_optimum_mode(rdev, input_uV, 682 /* set the optimum mode for our new total regulator load */
681 output_uV, current_uA); 683 err = rdev->desc->ops->set_load(rdev, current_uA);
684 if (err < 0)
685 rdev_err(rdev, "failed to set load %d\n", current_uA);
686 } else {
687 /* now get the optimum mode for our new total regulator load */
688 mode = rdev->desc->ops->get_optimum_mode(rdev, input_uV,
689 output_uV, current_uA);
690
691 /* check the new mode is allowed */
692 err = regulator_mode_constrain(rdev, &mode);
693 if (err < 0) {
694 rdev_err(rdev, "failed to get optimum mode @ %d uA %d -> %d uV\n",
695 current_uA, input_uV, output_uV);
696 return err;
697 }
682 698
683 /* check the new mode is allowed */ 699 err = rdev->desc->ops->set_mode(rdev, mode);
684 err = regulator_mode_constrain(rdev, &mode); 700 if (err < 0)
685 if (err < 0) { 701 rdev_err(rdev, "failed to set optimum mode %x\n", mode);
686 rdev_err(rdev, "failed to get optimum mode @ %d uA %d -> %d uV\n",
687 current_uA, input_uV, output_uV);
688 return err;
689 } 702 }
690 703
691 err = rdev->desc->ops->set_mode(rdev, mode);
692 if (err < 0)
693 rdev_err(rdev, "failed to set optimum mode %x\n", mode);
694
695 return err; 704 return err;
696} 705}
697 706
@@ -1316,6 +1325,54 @@ static struct regulator_dev *regulator_dev_lookup(struct device *dev,
1316 return NULL; 1325 return NULL;
1317} 1326}
1318 1327
1328static int regulator_resolve_supply(struct regulator_dev *rdev)
1329{
1330 struct regulator_dev *r;
1331 struct device *dev = rdev->dev.parent;
1332 int ret;
1333
1334 /* No supply to resovle? */
1335 if (!rdev->supply_name)
1336 return 0;
1337
1338 /* Supply already resolved? */
1339 if (rdev->supply)
1340 return 0;
1341
1342 r = regulator_dev_lookup(dev, rdev->supply_name, &ret);
1343 if (ret == -ENODEV) {
1344 /*
1345 * No supply was specified for this regulator and
1346 * there will never be one.
1347 */
1348 return 0;
1349 }
1350
1351 if (!r) {
1352 dev_err(dev, "Failed to resolve %s-supply for %s\n",
1353 rdev->supply_name, rdev->desc->name);
1354 return -EPROBE_DEFER;
1355 }
1356
1357 /* Recursively resolve the supply of the supply */
1358 ret = regulator_resolve_supply(r);
1359 if (ret < 0)
1360 return ret;
1361
1362 ret = set_supply(rdev, r);
1363 if (ret < 0)
1364 return ret;
1365
1366 /* Cascade always-on state to supply */
1367 if (_regulator_is_enabled(rdev)) {
1368 ret = regulator_enable(rdev->supply);
1369 if (ret < 0)
1370 return ret;
1371 }
1372
1373 return 0;
1374}
1375
1319/* Internal regulator request function */ 1376/* Internal regulator request function */
1320static struct regulator *_regulator_get(struct device *dev, const char *id, 1377static struct regulator *_regulator_get(struct device *dev, const char *id,
1321 bool exclusive, bool allow_dummy) 1378 bool exclusive, bool allow_dummy)
@@ -1385,6 +1442,12 @@ found:
1385 goto out; 1442 goto out;
1386 } 1443 }
1387 1444
1445 ret = regulator_resolve_supply(rdev);
1446 if (ret < 0) {
1447 regulator = ERR_PTR(ret);
1448 goto out;
1449 }
1450
1388 if (!try_module_get(rdev->owner)) 1451 if (!try_module_get(rdev->owner))
1389 goto out; 1452 goto out;
1390 1453
@@ -2998,7 +3061,7 @@ unsigned int regulator_get_mode(struct regulator *regulator)
2998EXPORT_SYMBOL_GPL(regulator_get_mode); 3061EXPORT_SYMBOL_GPL(regulator_get_mode);
2999 3062
3000/** 3063/**
3001 * regulator_set_optimum_mode - set regulator optimum operating mode 3064 * regulator_set_load - set regulator load
3002 * @regulator: regulator source 3065 * @regulator: regulator source
3003 * @uA_load: load current 3066 * @uA_load: load current
3004 * 3067 *
@@ -3021,9 +3084,9 @@ EXPORT_SYMBOL_GPL(regulator_get_mode);
3021 * DRMS will sum the total requested load on the regulator and change 3084 * DRMS will sum the total requested load on the regulator and change
3022 * to the most efficient operating mode if platform constraints allow. 3085 * to the most efficient operating mode if platform constraints allow.
3023 * 3086 *
3024 * Returns the new regulator mode or error. 3087 * On error a negative errno is returned.
3025 */ 3088 */
3026int regulator_set_optimum_mode(struct regulator *regulator, int uA_load) 3089int regulator_set_load(struct regulator *regulator, int uA_load)
3027{ 3090{
3028 struct regulator_dev *rdev = regulator->rdev; 3091 struct regulator_dev *rdev = regulator->rdev;
3029 int ret; 3092 int ret;
@@ -3035,7 +3098,7 @@ int regulator_set_optimum_mode(struct regulator *regulator, int uA_load)
3035 3098
3036 return ret; 3099 return ret;
3037} 3100}
3038EXPORT_SYMBOL_GPL(regulator_set_optimum_mode); 3101EXPORT_SYMBOL_GPL(regulator_set_load);
3039 3102
3040/** 3103/**
3041 * regulator_allow_bypass - allow the regulator to go into bypass mode 3104 * regulator_allow_bypass - allow the regulator to go into bypass mode
@@ -3499,7 +3562,18 @@ static struct class regulator_class = {
3499 3562
3500static void rdev_init_debugfs(struct regulator_dev *rdev) 3563static void rdev_init_debugfs(struct regulator_dev *rdev)
3501{ 3564{
3502 rdev->debugfs = debugfs_create_dir(rdev_get_name(rdev), debugfs_root); 3565 struct device *parent = rdev->dev.parent;
3566 const char *rname = rdev_get_name(rdev);
3567 char name[NAME_MAX];
3568
3569 /* Avoid duplicate debugfs directory names */
3570 if (parent && rname == rdev->desc->name) {
3571 snprintf(name, sizeof(name), "%s-%s", dev_name(parent),
3572 rname);
3573 rname = name;
3574 }
3575
3576 rdev->debugfs = debugfs_create_dir(rname, debugfs_root);
3503 if (!rdev->debugfs) { 3577 if (!rdev->debugfs) {
3504 rdev_warn(rdev, "Failed to create debugfs directory\n"); 3578 rdev_warn(rdev, "Failed to create debugfs directory\n");
3505 return; 3579 return;
@@ -3533,7 +3607,6 @@ regulator_register(const struct regulator_desc *regulator_desc,
3533 struct regulator_dev *rdev; 3607 struct regulator_dev *rdev;
3534 struct device *dev; 3608 struct device *dev;
3535 int ret, i; 3609 int ret, i;
3536 const char *supply = NULL;
3537 3610
3538 if (regulator_desc == NULL || cfg == NULL) 3611 if (regulator_desc == NULL || cfg == NULL)
3539 return ERR_PTR(-EINVAL); 3612 return ERR_PTR(-EINVAL);
@@ -3641,41 +3714,10 @@ regulator_register(const struct regulator_desc *regulator_desc,
3641 goto scrub; 3714 goto scrub;
3642 3715
3643 if (init_data && init_data->supply_regulator) 3716 if (init_data && init_data->supply_regulator)
3644 supply = init_data->supply_regulator; 3717 rdev->supply_name = init_data->supply_regulator;
3645 else if (regulator_desc->supply_name) 3718 else if (regulator_desc->supply_name)
3646 supply = regulator_desc->supply_name; 3719 rdev->supply_name = regulator_desc->supply_name;
3647
3648 if (supply) {
3649 struct regulator_dev *r;
3650 3720
3651 r = regulator_dev_lookup(dev, supply, &ret);
3652
3653 if (ret == -ENODEV) {
3654 /*
3655 * No supply was specified for this regulator and
3656 * there will never be one.
3657 */
3658 ret = 0;
3659 goto add_dev;
3660 } else if (!r) {
3661 dev_err(dev, "Failed to find supply %s\n", supply);
3662 ret = -EPROBE_DEFER;
3663 goto scrub;
3664 }
3665
3666 ret = set_supply(rdev, r);
3667 if (ret < 0)
3668 goto scrub;
3669
3670 /* Enable supply if rail is enabled */
3671 if (_regulator_is_enabled(rdev)) {
3672 ret = regulator_enable(rdev->supply);
3673 if (ret < 0)
3674 goto scrub;
3675 }
3676 }
3677
3678add_dev:
3679 /* add consumers devices */ 3721 /* add consumers devices */
3680 if (init_data) { 3722 if (init_data) {
3681 for (i = 0; i < init_data->num_consumer_supplies; i++) { 3723 for (i = 0; i < init_data->num_consumer_supplies; i++) {
@@ -3702,8 +3744,6 @@ unset_supplies:
3702 unset_regulator_supplies(rdev); 3744 unset_regulator_supplies(rdev);
3703 3745
3704scrub: 3746scrub:
3705 if (rdev->supply)
3706 _regulator_put(rdev->supply);
3707 regulator_ena_gpio_free(rdev); 3747 regulator_ena_gpio_free(rdev);
3708 kfree(rdev->constraints); 3748 kfree(rdev->constraints);
3709wash: 3749wash:
@@ -3936,6 +3976,110 @@ static const struct file_operations supply_map_fops = {
3936#endif 3976#endif
3937}; 3977};
3938 3978
3979#ifdef CONFIG_DEBUG_FS
3980static void regulator_summary_show_subtree(struct seq_file *s,
3981 struct regulator_dev *rdev,
3982 int level)
3983{
3984 struct list_head *list = s->private;
3985 struct regulator_dev *child;
3986 struct regulation_constraints *c;
3987 struct regulator *consumer;
3988
3989 if (!rdev)
3990 return;
3991
3992 seq_printf(s, "%*s%-*s %3d %4d %6d ",
3993 level * 3 + 1, "",
3994 30 - level * 3, rdev_get_name(rdev),
3995 rdev->use_count, rdev->open_count, rdev->bypass_count);
3996
3997 seq_printf(s, "%5dmV ", _regulator_get_voltage(rdev) / 1000);
3998 seq_printf(s, "%5dmA ", _regulator_get_current_limit(rdev) / 1000);
3999
4000 c = rdev->constraints;
4001 if (c) {
4002 switch (rdev->desc->type) {
4003 case REGULATOR_VOLTAGE:
4004 seq_printf(s, "%5dmV %5dmV ",
4005 c->min_uV / 1000, c->max_uV / 1000);
4006 break;
4007 case REGULATOR_CURRENT:
4008 seq_printf(s, "%5dmA %5dmA ",
4009 c->min_uA / 1000, c->max_uA / 1000);
4010 break;
4011 }
4012 }
4013
4014 seq_puts(s, "\n");
4015
4016 list_for_each_entry(consumer, &rdev->consumer_list, list) {
4017 if (consumer->dev->class == &regulator_class)
4018 continue;
4019
4020 seq_printf(s, "%*s%-*s ",
4021 (level + 1) * 3 + 1, "",
4022 30 - (level + 1) * 3, dev_name(consumer->dev));
4023
4024 switch (rdev->desc->type) {
4025 case REGULATOR_VOLTAGE:
4026 seq_printf(s, "%37dmV %5dmV",
4027 consumer->min_uV / 1000,
4028 consumer->max_uV / 1000);
4029 break;
4030 case REGULATOR_CURRENT:
4031 break;
4032 }
4033
4034 seq_puts(s, "\n");
4035 }
4036
4037 list_for_each_entry(child, list, list) {
4038 /* handle only non-root regulators supplied by current rdev */
4039 if (!child->supply || child->supply->rdev != rdev)
4040 continue;
4041
4042 regulator_summary_show_subtree(s, child, level + 1);
4043 }
4044}
4045
4046static int regulator_summary_show(struct seq_file *s, void *data)
4047{
4048 struct list_head *list = s->private;
4049 struct regulator_dev *rdev;
4050
4051 seq_puts(s, " regulator use open bypass voltage current min max\n");
4052 seq_puts(s, "-------------------------------------------------------------------------------\n");
4053
4054 mutex_lock(&regulator_list_mutex);
4055
4056 list_for_each_entry(rdev, list, list) {
4057 if (rdev->supply)
4058 continue;
4059
4060 regulator_summary_show_subtree(s, rdev, 0);
4061 }
4062
4063 mutex_unlock(&regulator_list_mutex);
4064
4065 return 0;
4066}
4067
4068static int regulator_summary_open(struct inode *inode, struct file *file)
4069{
4070 return single_open(file, regulator_summary_show, inode->i_private);
4071}
4072#endif
4073
4074static const struct file_operations regulator_summary_fops = {
4075#ifdef CONFIG_DEBUG_FS
4076 .open = regulator_summary_open,
4077 .read = seq_read,
4078 .llseek = seq_lseek,
4079 .release = single_release,
4080#endif
4081};
4082
3939static int __init regulator_init(void) 4083static int __init regulator_init(void)
3940{ 4084{
3941 int ret; 4085 int ret;
@@ -3949,6 +4093,9 @@ static int __init regulator_init(void)
3949 debugfs_create_file("supply_map", 0444, debugfs_root, NULL, 4093 debugfs_create_file("supply_map", 0444, debugfs_root, NULL,
3950 &supply_map_fops); 4094 &supply_map_fops);
3951 4095
4096 debugfs_create_file("regulator_summary", 0444, debugfs_root,
4097 &regulator_list, &regulator_summary_fops);
4098
3952 regulator_dummy_init(); 4099 regulator_dummy_init();
3953 4100
3954 return ret; 4101 return ret;
diff --git a/drivers/regulator/da9211-regulator.c b/drivers/regulator/da9211-regulator.c
index 01343419555e..df79e4b1946e 100644
--- a/drivers/regulator/da9211-regulator.c
+++ b/drivers/regulator/da9211-regulator.c
@@ -305,8 +305,7 @@ static irqreturn_t da9211_irq_handler(int irq, void *data)
305 305
306 if (reg_val & DA9211_E_OV_CURR_A) { 306 if (reg_val & DA9211_E_OV_CURR_A) {
307 regulator_notifier_call_chain(chip->rdev[0], 307 regulator_notifier_call_chain(chip->rdev[0],
308 REGULATOR_EVENT_OVER_CURRENT, 308 REGULATOR_EVENT_OVER_CURRENT, NULL);
309 rdev_get_drvdata(chip->rdev[0]));
310 309
311 err = regmap_write(chip->regmap, DA9211_REG_EVENT_B, 310 err = regmap_write(chip->regmap, DA9211_REG_EVENT_B,
312 DA9211_E_OV_CURR_A); 311 DA9211_E_OV_CURR_A);
@@ -318,8 +317,7 @@ static irqreturn_t da9211_irq_handler(int irq, void *data)
318 317
319 if (reg_val & DA9211_E_OV_CURR_B) { 318 if (reg_val & DA9211_E_OV_CURR_B) {
320 regulator_notifier_call_chain(chip->rdev[1], 319 regulator_notifier_call_chain(chip->rdev[1],
321 REGULATOR_EVENT_OVER_CURRENT, 320 REGULATOR_EVENT_OVER_CURRENT, NULL);
322 rdev_get_drvdata(chip->rdev[1]));
323 321
324 err = regmap_write(chip->regmap, DA9211_REG_EVENT_B, 322 err = regmap_write(chip->regmap, DA9211_REG_EVENT_B,
325 DA9211_E_OV_CURR_B); 323 DA9211_E_OV_CURR_B);
@@ -344,7 +342,7 @@ static int da9211_regulator_init(struct da9211 *chip)
344 342
345 ret = regmap_read(chip->regmap, DA9211_REG_CONFIG_E, &data); 343 ret = regmap_read(chip->regmap, DA9211_REG_CONFIG_E, &data);
346 if (ret < 0) { 344 if (ret < 0) {
347 dev_err(chip->dev, "Failed to read CONTROL_E reg: %d\n", ret); 345 dev_err(chip->dev, "Failed to read CONFIG_E reg: %d\n", ret);
348 return ret; 346 return ret;
349 } 347 }
350 348
diff --git a/drivers/regulator/dbx500-prcmu.c b/drivers/regulator/dbx500-prcmu.c
index 2d16b9f16de7..3963dfad766c 100644
--- a/drivers/regulator/dbx500-prcmu.c
+++ b/drivers/regulator/dbx500-prcmu.c
@@ -95,14 +95,9 @@ void ux500_regulator_resume_debug(void)
95 95
96static int ux500_regulator_power_state_cnt_print(struct seq_file *s, void *p) 96static int ux500_regulator_power_state_cnt_print(struct seq_file *s, void *p)
97{ 97{
98 struct device *dev = s->private;
99 int err;
100
101 /* print power state count */ 98 /* print power state count */
102 err = seq_printf(s, "ux500-regulator power state count: %i\n", 99 seq_printf(s, "ux500-regulator power state count: %i\n",
103 power_state_active_get()); 100 power_state_active_get());
104 if (err < 0)
105 dev_err(dev, "seq_printf overflow\n");
106 101
107 return 0; 102 return 0;
108} 103}
@@ -124,19 +119,11 @@ static const struct file_operations ux500_regulator_power_state_cnt_fops = {
124 119
125static int ux500_regulator_status_print(struct seq_file *s, void *p) 120static int ux500_regulator_status_print(struct seq_file *s, void *p)
126{ 121{
127 struct device *dev = s->private;
128 int err;
129 int i; 122 int i;
130 123
131 /* print dump header */ 124 /* print dump header */
132 err = seq_puts(s, "ux500-regulator status:\n"); 125 seq_puts(s, "ux500-regulator status:\n");
133 if (err < 0) 126 seq_printf(s, "%31s : %8s : %8s\n", "current", "before", "after");
134 dev_err(dev, "seq_puts overflow\n");
135
136 err = seq_printf(s, "%31s : %8s : %8s\n", "current",
137 "before", "after");
138 if (err < 0)
139 dev_err(dev, "seq_printf overflow\n");
140 127
141 for (i = 0; i < rdebug.num_regulators; i++) { 128 for (i = 0; i < rdebug.num_regulators; i++) {
142 struct dbx500_regulator_info *info; 129 struct dbx500_regulator_info *info;
@@ -144,12 +131,11 @@ static int ux500_regulator_status_print(struct seq_file *s, void *p)
144 info = &rdebug.regulator_array[i]; 131 info = &rdebug.regulator_array[i];
145 132
146 /* print status */ 133 /* print status */
147 err = seq_printf(s, "%20s : %8s : %8s : %8s\n", info->desc.name, 134 seq_printf(s, "%20s : %8s : %8s : %8s\n",
148 info->is_enabled ? "enabled" : "disabled", 135 info->desc.name,
149 rdebug.state_before_suspend[i] ? "enabled" : "disabled", 136 info->is_enabled ? "enabled" : "disabled",
150 rdebug.state_after_suspend[i] ? "enabled" : "disabled"); 137 rdebug.state_before_suspend[i] ? "enabled" : "disabled",
151 if (err < 0) 138 rdebug.state_after_suspend[i] ? "enabled" : "disabled");
152 dev_err(dev, "seq_printf overflow\n");
153 } 139 }
154 140
155 return 0; 141 return 0;
diff --git a/drivers/regulator/devres.c b/drivers/regulator/devres.c
index 8f785bc9e510..6ec1d400adae 100644
--- a/drivers/regulator/devres.c
+++ b/drivers/regulator/devres.c
@@ -413,3 +413,88 @@ void devm_regulator_bulk_unregister_supply_alias(struct device *dev,
413 devm_regulator_unregister_supply_alias(dev, id[i]); 413 devm_regulator_unregister_supply_alias(dev, id[i]);
414} 414}
415EXPORT_SYMBOL_GPL(devm_regulator_bulk_unregister_supply_alias); 415EXPORT_SYMBOL_GPL(devm_regulator_bulk_unregister_supply_alias);
416
417struct regulator_notifier_match {
418 struct regulator *regulator;
419 struct notifier_block *nb;
420};
421
422static int devm_regulator_match_notifier(struct device *dev, void *res,
423 void *data)
424{
425 struct regulator_notifier_match *match = res;
426 struct regulator_notifier_match *target = data;
427
428 return match->regulator == target->regulator && match->nb == target->nb;
429}
430
431static void devm_regulator_destroy_notifier(struct device *dev, void *res)
432{
433 struct regulator_notifier_match *match = res;
434
435 regulator_unregister_notifier(match->regulator, match->nb);
436}
437
438/**
439 * devm_regulator_register_notifier - Resource managed
440 * regulator_register_notifier
441 *
442 * @regulator: regulator source
443 * @nb: notifier block
444 *
445 * The notifier will be registers under the consumer device and be
446 * automatically be unregistered when the source device is unbound.
447 */
448int devm_regulator_register_notifier(struct regulator *regulator,
449 struct notifier_block *nb)
450{
451 struct regulator_notifier_match *match;
452 int ret;
453
454 match = devres_alloc(devm_regulator_destroy_notifier,
455 sizeof(struct regulator_notifier_match),
456 GFP_KERNEL);
457 if (!match)
458 return -ENOMEM;
459
460 match->regulator = regulator;
461 match->nb = nb;
462
463 ret = regulator_register_notifier(regulator, nb);
464 if (ret < 0) {
465 devres_free(match);
466 return ret;
467 }
468
469 devres_add(regulator->dev, match);
470
471 return 0;
472}
473EXPORT_SYMBOL_GPL(devm_regulator_register_notifier);
474
475/**
476 * devm_regulator_unregister_notifier - Resource managed
477 * regulator_unregister_notifier()
478 *
479 * @regulator: regulator source
480 * @nb: notifier block
481 *
482 * Unregister a notifier registered with devm_regulator_register_notifier().
483 * Normally this function will not need to be called and the resource
484 * management code will ensure that the resource is freed.
485 */
486void devm_regulator_unregister_notifier(struct regulator *regulator,
487 struct notifier_block *nb)
488{
489 struct regulator_notifier_match match;
490 int rc;
491
492 match.regulator = regulator;
493 match.nb = nb;
494
495 rc = devres_release(regulator->dev, devm_regulator_destroy_notifier,
496 devm_regulator_match_notifier, &match);
497 if (rc != 0)
498 WARN_ON(rc);
499}
500EXPORT_SYMBOL_GPL(devm_regulator_unregister_notifier);
diff --git a/drivers/regulator/max77693.c b/drivers/regulator/max77693.c
index 07b313e51b21..9665a488e2f1 100644
--- a/drivers/regulator/max77693.c
+++ b/drivers/regulator/max77693.c
@@ -128,6 +128,8 @@ static struct regulator_ops max77693_charger_ops = {
128#define regulator_desc_esafeout(_num) { \ 128#define regulator_desc_esafeout(_num) { \
129 .name = "ESAFEOUT"#_num, \ 129 .name = "ESAFEOUT"#_num, \
130 .id = MAX77693_ESAFEOUT##_num, \ 130 .id = MAX77693_ESAFEOUT##_num, \
131 .of_match = of_match_ptr("ESAFEOUT"#_num), \
132 .regulators_node = of_match_ptr("regulators"), \
131 .n_voltages = 4, \ 133 .n_voltages = 4, \
132 .ops = &max77693_safeout_ops, \ 134 .ops = &max77693_safeout_ops, \
133 .type = REGULATOR_VOLTAGE, \ 135 .type = REGULATOR_VOLTAGE, \
@@ -145,6 +147,8 @@ static const struct regulator_desc regulators[] = {
145 { 147 {
146 .name = "CHARGER", 148 .name = "CHARGER",
147 .id = MAX77693_CHARGER, 149 .id = MAX77693_CHARGER,
150 .of_match = of_match_ptr("CHARGER"),
151 .regulators_node = of_match_ptr("regulators"),
148 .ops = &max77693_charger_ops, 152 .ops = &max77693_charger_ops,
149 .type = REGULATOR_CURRENT, 153 .type = REGULATOR_CURRENT,
150 .owner = THIS_MODULE, 154 .owner = THIS_MODULE,
@@ -154,102 +158,23 @@ static const struct regulator_desc regulators[] = {
154 }, 158 },
155}; 159};
156 160
157#ifdef CONFIG_OF
158static int max77693_pmic_dt_parse_rdata(struct device *dev,
159 struct max77693_regulator_data **rdata)
160{
161 struct device_node *np;
162 struct of_regulator_match *rmatch;
163 struct max77693_regulator_data *tmp;
164 int i, matched = 0;
165
166 np = of_get_child_by_name(dev->parent->of_node, "regulators");
167 if (!np)
168 return -EINVAL;
169
170 rmatch = devm_kzalloc(dev,
171 sizeof(*rmatch) * ARRAY_SIZE(regulators), GFP_KERNEL);
172 if (!rmatch) {
173 of_node_put(np);
174 return -ENOMEM;
175 }
176
177 for (i = 0; i < ARRAY_SIZE(regulators); i++)
178 rmatch[i].name = regulators[i].name;
179
180 matched = of_regulator_match(dev, np, rmatch, ARRAY_SIZE(regulators));
181 of_node_put(np);
182 if (matched <= 0)
183 return matched;
184 *rdata = devm_kzalloc(dev, sizeof(**rdata) * matched, GFP_KERNEL);
185 if (!(*rdata))
186 return -ENOMEM;
187
188 tmp = *rdata;
189
190 for (i = 0; i < matched; i++) {
191 tmp->initdata = rmatch[i].init_data;
192 tmp->of_node = rmatch[i].of_node;
193 tmp->id = regulators[i].id;
194 tmp++;
195 }
196
197 return matched;
198}
199#else
200static int max77693_pmic_dt_parse_rdata(struct device *dev,
201 struct max77693_regulator_data **rdata)
202{
203 return 0;
204}
205#endif /* CONFIG_OF */
206
207static int max77693_pmic_init_rdata(struct device *dev,
208 struct max77693_regulator_data **rdata)
209{
210 struct max77693_platform_data *pdata;
211 int num_regulators = 0;
212
213 pdata = dev_get_platdata(dev->parent);
214 if (pdata) {
215 *rdata = pdata->regulators;
216 num_regulators = pdata->num_regulators;
217 }
218
219 if (!(*rdata) && dev->parent->of_node)
220 num_regulators = max77693_pmic_dt_parse_rdata(dev, rdata);
221
222 return num_regulators;
223}
224
225static int max77693_pmic_probe(struct platform_device *pdev) 161static int max77693_pmic_probe(struct platform_device *pdev)
226{ 162{
227 struct max77693_dev *iodev = dev_get_drvdata(pdev->dev.parent); 163 struct max77693_dev *iodev = dev_get_drvdata(pdev->dev.parent);
228 struct max77693_regulator_data *rdata = NULL; 164 int i;
229 int num_rdata, i;
230 struct regulator_config config = { }; 165 struct regulator_config config = { };
231 166
232 num_rdata = max77693_pmic_init_rdata(&pdev->dev, &rdata); 167 config.dev = iodev->dev;
233 if (!rdata || num_rdata <= 0) {
234 dev_err(&pdev->dev, "No init data supplied.\n");
235 return -ENODEV;
236 }
237
238 config.dev = &pdev->dev;
239 config.regmap = iodev->regmap; 168 config.regmap = iodev->regmap;
240 169
241 for (i = 0; i < num_rdata; i++) { 170 for (i = 0; i < ARRAY_SIZE(regulators); i++) {
242 int id = rdata[i].id;
243 struct regulator_dev *rdev; 171 struct regulator_dev *rdev;
244 172
245 config.init_data = rdata[i].initdata;
246 config.of_node = rdata[i].of_node;
247
248 rdev = devm_regulator_register(&pdev->dev, 173 rdev = devm_regulator_register(&pdev->dev,
249 &regulators[id], &config); 174 &regulators[i], &config);
250 if (IS_ERR(rdev)) { 175 if (IS_ERR(rdev)) {
251 dev_err(&pdev->dev, 176 dev_err(&pdev->dev,
252 "Failed to initialize regulator-%d\n", id); 177 "Failed to initialize regulator-%d\n", i);
253 return PTR_ERR(rdev); 178 return PTR_ERR(rdev);
254 } 179 }
255 } 180 }
diff --git a/drivers/regulator/max8660.c b/drivers/regulator/max8660.c
index 7eee2ca18541..4071d74fa828 100644
--- a/drivers/regulator/max8660.c
+++ b/drivers/regulator/max8660.c
@@ -382,7 +382,7 @@ static int max8660_probe(struct i2c_client *client,
382 const struct i2c_device_id *i2c_id) 382 const struct i2c_device_id *i2c_id)
383{ 383{
384 struct device *dev = &client->dev; 384 struct device *dev = &client->dev;
385 struct max8660_platform_data *pdata = dev_get_platdata(dev); 385 struct max8660_platform_data pdata_of, *pdata = dev_get_platdata(dev);
386 struct regulator_config config = { }; 386 struct regulator_config config = { };
387 struct max8660 *max8660; 387 struct max8660 *max8660;
388 int boot_on, i, id, ret = -EINVAL; 388 int boot_on, i, id, ret = -EINVAL;
@@ -391,7 +391,6 @@ static int max8660_probe(struct i2c_client *client,
391 391
392 if (dev->of_node && !pdata) { 392 if (dev->of_node && !pdata) {
393 const struct of_device_id *id; 393 const struct of_device_id *id;
394 struct max8660_platform_data pdata_of;
395 394
396 id = of_match_device(of_match_ptr(max8660_dt_ids), dev); 395 id = of_match_device(of_match_ptr(max8660_dt_ids), dev);
397 if (!id) 396 if (!id)
@@ -443,9 +442,9 @@ static int max8660_probe(struct i2c_client *client,
443 for (i = 0; i < pdata->num_subdevs; i++) { 442 for (i = 0; i < pdata->num_subdevs; i++) {
444 443
445 if (!pdata->subdevs[i].platform_data) 444 if (!pdata->subdevs[i].platform_data)
446 return ret; 445 boot_on = false;
447 446 else
448 boot_on = pdata->subdevs[i].platform_data->constraints.boot_on; 447 boot_on = pdata->subdevs[i].platform_data->constraints.boot_on;
449 448
450 switch (pdata->subdevs[i].id) { 449 switch (pdata->subdevs[i].id) {
451 case MAX8660_V3: 450 case MAX8660_V3:
diff --git a/drivers/regulator/palmas-regulator.c b/drivers/regulator/palmas-regulator.c
index 18198316b6cf..8217613807d3 100644
--- a/drivers/regulator/palmas-regulator.c
+++ b/drivers/regulator/palmas-regulator.c
@@ -916,6 +916,9 @@ static int palmas_ldo_registration(struct palmas_pmic *pmic,
916 (id == PALMAS_REG_LDO6)) 916 (id == PALMAS_REG_LDO6))
917 desc->enable_time = 2000; 917 desc->enable_time = 2000;
918 } else { 918 } else {
919 if (!ddata->has_regen3 && id == PALMAS_REG_REGEN3)
920 continue;
921
919 desc->n_voltages = 1; 922 desc->n_voltages = 1;
920 if (reg_init && reg_init->roof_floor) 923 if (reg_init && reg_init->roof_floor)
921 desc->ops = &palmas_ops_ext_control_extreg; 924 desc->ops = &palmas_ops_ext_control_extreg;
@@ -1398,6 +1401,7 @@ static struct palmas_pmic_driver_data palmas_ddata = {
1398 .ldo_begin = PALMAS_REG_LDO1, 1401 .ldo_begin = PALMAS_REG_LDO1,
1399 .ldo_end = PALMAS_REG_LDOUSB, 1402 .ldo_end = PALMAS_REG_LDOUSB,
1400 .max_reg = PALMAS_NUM_REGS, 1403 .max_reg = PALMAS_NUM_REGS,
1404 .has_regen3 = true,
1401 .palmas_regs_info = palmas_generic_regs_info, 1405 .palmas_regs_info = palmas_generic_regs_info,
1402 .palmas_matches = palmas_matches, 1406 .palmas_matches = palmas_matches,
1403 .sleep_req_info = palma_sleep_req_info, 1407 .sleep_req_info = palma_sleep_req_info,
@@ -1411,6 +1415,7 @@ static struct palmas_pmic_driver_data tps65917_ddata = {
1411 .ldo_begin = TPS65917_REG_LDO1, 1415 .ldo_begin = TPS65917_REG_LDO1,
1412 .ldo_end = TPS65917_REG_LDO5, 1416 .ldo_end = TPS65917_REG_LDO5,
1413 .max_reg = TPS65917_NUM_REGS, 1417 .max_reg = TPS65917_NUM_REGS,
1418 .has_regen3 = true,
1414 .palmas_regs_info = tps65917_regs_info, 1419 .palmas_regs_info = tps65917_regs_info,
1415 .palmas_matches = tps65917_matches, 1420 .palmas_matches = tps65917_matches,
1416 .sleep_req_info = tps65917_sleep_req_info, 1421 .sleep_req_info = tps65917_sleep_req_info,
@@ -1505,7 +1510,7 @@ static void palmas_dt_to_pdata(struct device *dev,
1505 pdata->ldo6_vibrator = of_property_read_bool(node, "ti,ldo6-vibrator"); 1510 pdata->ldo6_vibrator = of_property_read_bool(node, "ti,ldo6-vibrator");
1506} 1511}
1507 1512
1508static struct of_device_id of_palmas_match_tbl[] = { 1513static const struct of_device_id of_palmas_match_tbl[] = {
1509 { 1514 {
1510 .compatible = "ti,palmas-pmic", 1515 .compatible = "ti,palmas-pmic",
1511 .data = &palmas_ddata, 1516 .data = &palmas_ddata,
@@ -1572,9 +1577,11 @@ static int palmas_regulators_probe(struct platform_device *pdev)
1572 if (!pmic) 1577 if (!pmic)
1573 return -ENOMEM; 1578 return -ENOMEM;
1574 1579
1575 if (of_device_is_compatible(node, "ti,tps659038-pmic")) 1580 if (of_device_is_compatible(node, "ti,tps659038-pmic")) {
1576 palmas_generic_regs_info[PALMAS_REG_REGEN2].ctrl_addr = 1581 palmas_generic_regs_info[PALMAS_REG_REGEN2].ctrl_addr =
1577 TPS659038_REGEN2_CTRL; 1582 TPS659038_REGEN2_CTRL;
1583 palmas_ddata.has_regen3 = false;
1584 }
1578 1585
1579 pmic->dev = &pdev->dev; 1586 pmic->dev = &pdev->dev;
1580 pmic->palmas = palmas; 1587 pmic->palmas = palmas;
diff --git a/drivers/regulator/qcom_rpm-regulator.c b/drivers/regulator/qcom_rpm-regulator.c
index 00c5cc3d9546..e254272585b2 100644
--- a/drivers/regulator/qcom_rpm-regulator.c
+++ b/drivers/regulator/qcom_rpm-regulator.c
@@ -393,6 +393,28 @@ static int rpm_reg_is_enabled(struct regulator_dev *rdev)
393 return vreg->is_enabled; 393 return vreg->is_enabled;
394} 394}
395 395
396static int rpm_reg_set_load(struct regulator_dev *rdev, int load_uA)
397{
398 struct qcom_rpm_reg *vreg = rdev_get_drvdata(rdev);
399 const struct rpm_reg_parts *parts = vreg->parts;
400 const struct request_member *req = &parts->ia;
401 int load_mA = load_uA / 1000;
402 int max_mA = req->mask >> req->shift;
403 int ret;
404
405 if (req->mask == 0)
406 return -EINVAL;
407
408 if (load_mA > max_mA)
409 load_mA = max_mA;
410
411 mutex_lock(&vreg->lock);
412 ret = rpm_reg_write(vreg, req, load_mA);
413 mutex_unlock(&vreg->lock);
414
415 return ret;
416}
417
396static struct regulator_ops uV_ops = { 418static struct regulator_ops uV_ops = {
397 .list_voltage = regulator_list_voltage_linear_range, 419 .list_voltage = regulator_list_voltage_linear_range,
398 420
@@ -402,6 +424,8 @@ static struct regulator_ops uV_ops = {
402 .enable = rpm_reg_uV_enable, 424 .enable = rpm_reg_uV_enable,
403 .disable = rpm_reg_uV_disable, 425 .disable = rpm_reg_uV_disable,
404 .is_enabled = rpm_reg_is_enabled, 426 .is_enabled = rpm_reg_is_enabled,
427
428 .set_load = rpm_reg_set_load,
405}; 429};
406 430
407static struct regulator_ops mV_ops = { 431static struct regulator_ops mV_ops = {
@@ -413,6 +437,8 @@ static struct regulator_ops mV_ops = {
413 .enable = rpm_reg_mV_enable, 437 .enable = rpm_reg_mV_enable,
414 .disable = rpm_reg_mV_disable, 438 .disable = rpm_reg_mV_disable,
415 .is_enabled = rpm_reg_is_enabled, 439 .is_enabled = rpm_reg_is_enabled,
440
441 .set_load = rpm_reg_set_load,
416}; 442};
417 443
418static struct regulator_ops switch_ops = { 444static struct regulator_ops switch_ops = {
@@ -581,31 +607,6 @@ static const struct qcom_rpm_reg smb208_smps = {
581 .supports_force_mode_bypass = false, 607 .supports_force_mode_bypass = false,
582}; 608};
583 609
584static const struct of_device_id rpm_of_match[] = {
585 { .compatible = "qcom,rpm-pm8058-pldo", .data = &pm8058_pldo },
586 { .compatible = "qcom,rpm-pm8058-nldo", .data = &pm8058_nldo },
587 { .compatible = "qcom,rpm-pm8058-smps", .data = &pm8058_smps },
588 { .compatible = "qcom,rpm-pm8058-ncp", .data = &pm8058_ncp },
589 { .compatible = "qcom,rpm-pm8058-switch", .data = &pm8058_switch },
590
591 { .compatible = "qcom,rpm-pm8901-pldo", .data = &pm8901_pldo },
592 { .compatible = "qcom,rpm-pm8901-nldo", .data = &pm8901_nldo },
593 { .compatible = "qcom,rpm-pm8901-ftsmps", .data = &pm8901_ftsmps },
594 { .compatible = "qcom,rpm-pm8901-switch", .data = &pm8901_switch },
595
596 { .compatible = "qcom,rpm-pm8921-pldo", .data = &pm8921_pldo },
597 { .compatible = "qcom,rpm-pm8921-nldo", .data = &pm8921_nldo },
598 { .compatible = "qcom,rpm-pm8921-nldo1200", .data = &pm8921_nldo1200 },
599 { .compatible = "qcom,rpm-pm8921-smps", .data = &pm8921_smps },
600 { .compatible = "qcom,rpm-pm8921-ftsmps", .data = &pm8921_ftsmps },
601 { .compatible = "qcom,rpm-pm8921-ncp", .data = &pm8921_ncp },
602 { .compatible = "qcom,rpm-pm8921-switch", .data = &pm8921_switch },
603
604 { .compatible = "qcom,rpm-smb208", .data = &smb208_smps },
605 { }
606};
607MODULE_DEVICE_TABLE(of, rpm_of_match);
608
609static int rpm_reg_set(struct qcom_rpm_reg *vreg, 610static int rpm_reg_set(struct qcom_rpm_reg *vreg,
610 const struct request_member *req, 611 const struct request_member *req,
611 const int value) 612 const int value)
@@ -619,7 +620,9 @@ static int rpm_reg_set(struct qcom_rpm_reg *vreg,
619 return 0; 620 return 0;
620} 621}
621 622
622static int rpm_reg_of_parse_freq(struct device *dev, struct qcom_rpm_reg *vreg) 623static int rpm_reg_of_parse_freq(struct device *dev,
624 struct device_node *node,
625 struct qcom_rpm_reg *vreg)
623{ 626{
624 static const int freq_table[] = { 627 static const int freq_table[] = {
625 19200000, 9600000, 6400000, 4800000, 3840000, 3200000, 2740000, 628 19200000, 9600000, 6400000, 4800000, 3840000, 3200000, 2740000,
@@ -633,7 +636,7 @@ static int rpm_reg_of_parse_freq(struct device *dev, struct qcom_rpm_reg *vreg)
633 int i; 636 int i;
634 637
635 key = "qcom,switch-mode-frequency"; 638 key = "qcom,switch-mode-frequency";
636 ret = of_property_read_u32(dev->of_node, key, &freq); 639 ret = of_property_read_u32(node, key, &freq);
637 if (ret) { 640 if (ret) {
638 dev_err(dev, "regulator requires %s property\n", key); 641 dev_err(dev, "regulator requires %s property\n", key);
639 return -EINVAL; 642 return -EINVAL;
@@ -650,84 +653,40 @@ static int rpm_reg_of_parse_freq(struct device *dev, struct qcom_rpm_reg *vreg)
650 return -EINVAL; 653 return -EINVAL;
651} 654}
652 655
653static int rpm_reg_probe(struct platform_device *pdev) 656static int rpm_reg_of_parse(struct device_node *node,
657 const struct regulator_desc *desc,
658 struct regulator_config *config)
654{ 659{
655 struct regulator_init_data *initdata; 660 struct qcom_rpm_reg *vreg = config->driver_data;
656 const struct qcom_rpm_reg *template; 661 struct device *dev = config->dev;
657 const struct of_device_id *match;
658 struct regulator_config config = { };
659 struct regulator_dev *rdev;
660 struct qcom_rpm_reg *vreg;
661 const char *key; 662 const char *key;
662 u32 force_mode; 663 u32 force_mode;
663 bool pwm; 664 bool pwm;
664 u32 val; 665 u32 val;
665 int ret; 666 int ret;
666 667
667 match = of_match_device(rpm_of_match, &pdev->dev);
668 template = match->data;
669
670 vreg = devm_kmalloc(&pdev->dev, sizeof(*vreg), GFP_KERNEL);
671 if (!vreg) {
672 dev_err(&pdev->dev, "failed to allocate vreg\n");
673 return -ENOMEM;
674 }
675 memcpy(vreg, template, sizeof(*vreg));
676 mutex_init(&vreg->lock);
677 vreg->dev = &pdev->dev;
678 vreg->desc.id = -1;
679 vreg->desc.owner = THIS_MODULE;
680 vreg->desc.type = REGULATOR_VOLTAGE;
681 vreg->desc.name = pdev->dev.of_node->name;
682 vreg->desc.supply_name = "vin";
683
684 vreg->rpm = dev_get_drvdata(pdev->dev.parent);
685 if (!vreg->rpm) {
686 dev_err(&pdev->dev, "unable to retrieve handle to rpm\n");
687 return -ENODEV;
688 }
689
690 initdata = of_get_regulator_init_data(&pdev->dev, pdev->dev.of_node,
691 &vreg->desc);
692 if (!initdata)
693 return -EINVAL;
694
695 key = "reg";
696 ret = of_property_read_u32(pdev->dev.of_node, key, &val);
697 if (ret) {
698 dev_err(&pdev->dev, "failed to read %s\n", key);
699 return ret;
700 }
701 vreg->resource = val;
702
703 if ((vreg->parts->uV.mask || vreg->parts->mV.mask) &&
704 (!initdata->constraints.min_uV || !initdata->constraints.max_uV)) {
705 dev_err(&pdev->dev, "no voltage specified for regulator\n");
706 return -EINVAL;
707 }
708
709 key = "bias-pull-down"; 668 key = "bias-pull-down";
710 if (of_property_read_bool(pdev->dev.of_node, key)) { 669 if (of_property_read_bool(node, key)) {
711 ret = rpm_reg_set(vreg, &vreg->parts->pd, 1); 670 ret = rpm_reg_set(vreg, &vreg->parts->pd, 1);
712 if (ret) { 671 if (ret) {
713 dev_err(&pdev->dev, "%s is invalid", key); 672 dev_err(dev, "%s is invalid", key);
714 return ret; 673 return ret;
715 } 674 }
716 } 675 }
717 676
718 if (vreg->parts->freq.mask) { 677 if (vreg->parts->freq.mask) {
719 ret = rpm_reg_of_parse_freq(&pdev->dev, vreg); 678 ret = rpm_reg_of_parse_freq(dev, node, vreg);
720 if (ret < 0) 679 if (ret < 0)
721 return ret; 680 return ret;
722 } 681 }
723 682
724 if (vreg->parts->pm.mask) { 683 if (vreg->parts->pm.mask) {
725 key = "qcom,power-mode-hysteretic"; 684 key = "qcom,power-mode-hysteretic";
726 pwm = !of_property_read_bool(pdev->dev.of_node, key); 685 pwm = !of_property_read_bool(node, key);
727 686
728 ret = rpm_reg_set(vreg, &vreg->parts->pm, pwm); 687 ret = rpm_reg_set(vreg, &vreg->parts->pm, pwm);
729 if (ret) { 688 if (ret) {
730 dev_err(&pdev->dev, "failed to set power mode\n"); 689 dev_err(dev, "failed to set power mode\n");
731 return ret; 690 return ret;
732 } 691 }
733 } 692 }
@@ -736,11 +695,11 @@ static int rpm_reg_probe(struct platform_device *pdev)
736 force_mode = -1; 695 force_mode = -1;
737 696
738 key = "qcom,force-mode"; 697 key = "qcom,force-mode";
739 ret = of_property_read_u32(pdev->dev.of_node, key, &val); 698 ret = of_property_read_u32(node, key, &val);
740 if (ret == -EINVAL) { 699 if (ret == -EINVAL) {
741 val = QCOM_RPM_FORCE_MODE_NONE; 700 val = QCOM_RPM_FORCE_MODE_NONE;
742 } else if (ret < 0) { 701 } else if (ret < 0) {
743 dev_err(&pdev->dev, "failed to read %s\n", key); 702 dev_err(dev, "failed to read %s\n", key);
744 return ret; 703 return ret;
745 } 704 }
746 705
@@ -775,25 +734,192 @@ static int rpm_reg_probe(struct platform_device *pdev)
775 } 734 }
776 735
777 if (force_mode == -1) { 736 if (force_mode == -1) {
778 dev_err(&pdev->dev, "invalid force mode\n"); 737 dev_err(dev, "invalid force mode\n");
779 return -EINVAL; 738 return -EINVAL;
780 } 739 }
781 740
782 ret = rpm_reg_set(vreg, &vreg->parts->fm, force_mode); 741 ret = rpm_reg_set(vreg, &vreg->parts->fm, force_mode);
783 if (ret) { 742 if (ret) {
784 dev_err(&pdev->dev, "failed to set force mode\n"); 743 dev_err(dev, "failed to set force mode\n");
785 return ret; 744 return ret;
786 } 745 }
787 } 746 }
788 747
789 config.dev = &pdev->dev; 748 return 0;
790 config.init_data = initdata; 749}
791 config.driver_data = vreg; 750
792 config.of_node = pdev->dev.of_node; 751struct rpm_regulator_data {
793 rdev = devm_regulator_register(&pdev->dev, &vreg->desc, &config); 752 const char *name;
794 if (IS_ERR(rdev)) { 753 int resource;
795 dev_err(&pdev->dev, "can't register regulator\n"); 754 const struct qcom_rpm_reg *template;
796 return PTR_ERR(rdev); 755 const char *supply;
756};
757
758static const struct rpm_regulator_data rpm_pm8058_regulators[] = {
759 { "l0", QCOM_RPM_PM8058_LDO0, &pm8058_nldo, "vdd_l0_l1_lvs" },
760 { "l1", QCOM_RPM_PM8058_LDO1, &pm8058_nldo, "vdd_l0_l1_lvs" },
761 { "l2", QCOM_RPM_PM8058_LDO2, &pm8058_pldo, "vdd_l2_l11_l12" },
762 { "l3", QCOM_RPM_PM8058_LDO3, &pm8058_pldo, "vdd_l3_l4_l5" },
763 { "l4", QCOM_RPM_PM8058_LDO4, &pm8058_pldo, "vdd_l3_l4_l5" },
764 { "l5", QCOM_RPM_PM8058_LDO5, &pm8058_pldo, "vdd_l3_l4_l5" },
765 { "l6", QCOM_RPM_PM8058_LDO6, &pm8058_pldo, "vdd_l6_l7" },
766 { "l7", QCOM_RPM_PM8058_LDO7, &pm8058_pldo, "vdd_l6_l7" },
767 { "l8", QCOM_RPM_PM8058_LDO8, &pm8058_pldo, "vdd_l8" },
768 { "l9", QCOM_RPM_PM8058_LDO9, &pm8058_pldo, "vdd_l9" },
769 { "l10", QCOM_RPM_PM8058_LDO10, &pm8058_pldo, "vdd_l10" },
770 { "l11", QCOM_RPM_PM8058_LDO11, &pm8058_pldo, "vdd_l2_l11_l12" },
771 { "l12", QCOM_RPM_PM8058_LDO12, &pm8058_pldo, "vdd_l2_l11_l12" },
772 { "l13", QCOM_RPM_PM8058_LDO13, &pm8058_pldo, "vdd_l13_l16" },
773 { "l14", QCOM_RPM_PM8058_LDO14, &pm8058_pldo, "vdd_l14_l15" },
774 { "l15", QCOM_RPM_PM8058_LDO15, &pm8058_pldo, "vdd_l14_l15" },
775 { "l16", QCOM_RPM_PM8058_LDO16, &pm8058_pldo, "vdd_l13_l16" },
776 { "l17", QCOM_RPM_PM8058_LDO17, &pm8058_pldo, "vdd_l17_l18" },
777 { "l18", QCOM_RPM_PM8058_LDO18, &pm8058_pldo, "vdd_l17_l18" },
778 { "l19", QCOM_RPM_PM8058_LDO19, &pm8058_pldo, "vdd_l19_l20" },
779 { "l20", QCOM_RPM_PM8058_LDO20, &pm8058_pldo, "vdd_l19_l20" },
780 { "l21", QCOM_RPM_PM8058_LDO21, &pm8058_nldo, "vdd_l21" },
781 { "l22", QCOM_RPM_PM8058_LDO22, &pm8058_nldo, "vdd_l22" },
782 { "l23", QCOM_RPM_PM8058_LDO23, &pm8058_nldo, "vdd_l23_l24_l25" },
783 { "l24", QCOM_RPM_PM8058_LDO24, &pm8058_nldo, "vdd_l23_l24_l25" },
784 { "l25", QCOM_RPM_PM8058_LDO25, &pm8058_nldo, "vdd_l23_l24_l25" },
785
786 { "s0", QCOM_RPM_PM8058_SMPS0, &pm8058_smps, "vdd_s0" },
787 { "s1", QCOM_RPM_PM8058_SMPS1, &pm8058_smps, "vdd_s1" },
788 { "s2", QCOM_RPM_PM8058_SMPS2, &pm8058_smps, "vdd_s2" },
789 { "s3", QCOM_RPM_PM8058_SMPS3, &pm8058_smps, "vdd_s3" },
790 { "s4", QCOM_RPM_PM8058_SMPS4, &pm8058_smps, "vdd_s4" },
791
792 { "lvs0", QCOM_RPM_PM8058_LVS0, &pm8058_switch, "vdd_l0_l1_lvs" },
793 { "lvs1", QCOM_RPM_PM8058_LVS1, &pm8058_switch, "vdd_l0_l1_lvs" },
794
795 { "ncp", QCOM_RPM_PM8058_NCP, &pm8058_ncp, "vdd_ncp" },
796 { }
797};
798
799static const struct rpm_regulator_data rpm_pm8901_regulators[] = {
800 { "l0", QCOM_RPM_PM8901_LDO0, &pm8901_nldo, "vdd_l0" },
801 { "l1", QCOM_RPM_PM8901_LDO1, &pm8901_pldo, "vdd_l1" },
802 { "l2", QCOM_RPM_PM8901_LDO2, &pm8901_pldo, "vdd_l2" },
803 { "l3", QCOM_RPM_PM8901_LDO3, &pm8901_pldo, "vdd_l3" },
804 { "l4", QCOM_RPM_PM8901_LDO4, &pm8901_pldo, "vdd_l4" },
805 { "l5", QCOM_RPM_PM8901_LDO5, &pm8901_pldo, "vdd_l5" },
806 { "l6", QCOM_RPM_PM8901_LDO6, &pm8901_pldo, "vdd_l6" },
807
808 { "s0", QCOM_RPM_PM8901_SMPS0, &pm8901_ftsmps, "vdd_s0" },
809 { "s1", QCOM_RPM_PM8901_SMPS1, &pm8901_ftsmps, "vdd_s1" },
810 { "s2", QCOM_RPM_PM8901_SMPS2, &pm8901_ftsmps, "vdd_s2" },
811 { "s3", QCOM_RPM_PM8901_SMPS3, &pm8901_ftsmps, "vdd_s3" },
812 { "s4", QCOM_RPM_PM8901_SMPS4, &pm8901_ftsmps, "vdd_s4" },
813
814 { "lvs0", QCOM_RPM_PM8901_LVS0, &pm8901_switch, "lvs0_in" },
815 { "lvs1", QCOM_RPM_PM8901_LVS1, &pm8901_switch, "lvs1_in" },
816 { "lvs2", QCOM_RPM_PM8901_LVS2, &pm8901_switch, "lvs2_in" },
817 { "lvs3", QCOM_RPM_PM8901_LVS3, &pm8901_switch, "lvs3_in" },
818
819 { "mvs", QCOM_RPM_PM8901_MVS, &pm8901_switch, "mvs_in" },
820 { }
821};
822
823static const struct rpm_regulator_data rpm_pm8921_regulators[] = {
824 { "s1", QCOM_RPM_PM8921_SMPS1, &pm8921_smps, "vdd_s1" },
825 { "s2", QCOM_RPM_PM8921_SMPS2, &pm8921_smps, "vdd_s2" },
826 { "s3", QCOM_RPM_PM8921_SMPS3, &pm8921_smps },
827 { "s4", QCOM_RPM_PM8921_SMPS4, &pm8921_smps, "vdd_s4" },
828 { "s7", QCOM_RPM_PM8921_SMPS7, &pm8921_smps, "vdd_s7" },
829 { "s8", QCOM_RPM_PM8921_SMPS8, &pm8921_smps, "vdd_s8" },
830
831 { "l1", QCOM_RPM_PM8921_LDO1, &pm8921_nldo, "vdd_l1_l2_l12_l18" },
832 { "l2", QCOM_RPM_PM8921_LDO2, &pm8921_nldo, "vdd_l1_l2_l12_l18" },
833 { "l3", QCOM_RPM_PM8921_LDO3, &pm8921_pldo, "vdd_l3_l15_l17" },
834 { "l4", QCOM_RPM_PM8921_LDO4, &pm8921_pldo, "vdd_l4_l14" },
835 { "l5", QCOM_RPM_PM8921_LDO5, &pm8921_pldo, "vdd_l5_l8_l16" },
836 { "l6", QCOM_RPM_PM8921_LDO6, &pm8921_pldo, "vdd_l6_l7" },
837 { "l7", QCOM_RPM_PM8921_LDO7, &pm8921_pldo, "vdd_l6_l7" },
838 { "l8", QCOM_RPM_PM8921_LDO8, &pm8921_pldo, "vdd_l5_l8_l16" },
839 { "l9", QCOM_RPM_PM8921_LDO9, &pm8921_pldo, "vdd_l9_l11" },
840 { "l10", QCOM_RPM_PM8921_LDO10, &pm8921_pldo, "vdd_l10_l22" },
841 { "l11", QCOM_RPM_PM8921_LDO11, &pm8921_pldo, "vdd_l9_l11" },
842 { "l12", QCOM_RPM_PM8921_LDO12, &pm8921_nldo, "vdd_l1_l2_l12_l18" },
843 { "l14", QCOM_RPM_PM8921_LDO14, &pm8921_pldo, "vdd_l4_l14" },
844 { "l15", QCOM_RPM_PM8921_LDO15, &pm8921_pldo, "vdd_l3_l15_l17" },
845 { "l16", QCOM_RPM_PM8921_LDO16, &pm8921_pldo, "vdd_l5_l8_l16" },
846 { "l17", QCOM_RPM_PM8921_LDO17, &pm8921_pldo, "vdd_l3_l15_l17" },
847 { "l18", QCOM_RPM_PM8921_LDO18, &pm8921_nldo, "vdd_l1_l2_l12_l18" },
848 { "l21", QCOM_RPM_PM8921_LDO21, &pm8921_pldo, "vdd_l21_l23_l29" },
849 { "l22", QCOM_RPM_PM8921_LDO22, &pm8921_pldo, "vdd_l10_l22" },
850 { "l23", QCOM_RPM_PM8921_LDO23, &pm8921_pldo, "vdd_l21_l23_l29" },
851 { "l24", QCOM_RPM_PM8921_LDO24, &pm8921_nldo1200, "vdd_l24" },
852 { "l25", QCOM_RPM_PM8921_LDO25, &pm8921_nldo1200, "vdd_l25" },
853 { "l26", QCOM_RPM_PM8921_LDO26, &pm8921_nldo1200, "vdd_l26" },
854 { "l27", QCOM_RPM_PM8921_LDO27, &pm8921_nldo1200, "vdd_l27" },
855 { "l28", QCOM_RPM_PM8921_LDO28, &pm8921_nldo1200, "vdd_l28" },
856 { "l29", QCOM_RPM_PM8921_LDO29, &pm8921_pldo, "vdd_l21_l23_l29" },
857
858 { "lvs1", QCOM_RPM_PM8921_LVS1, &pm8921_switch, "vin_lvs1_3_6" },
859 { "lvs2", QCOM_RPM_PM8921_LVS2, &pm8921_switch, "vin_lvs2" },
860 { "lvs3", QCOM_RPM_PM8921_LVS3, &pm8921_switch, "vin_lvs1_3_6" },
861 { "lvs4", QCOM_RPM_PM8921_LVS4, &pm8921_switch, "vin_lvs4_5_7" },
862 { "lvs5", QCOM_RPM_PM8921_LVS5, &pm8921_switch, "vin_lvs4_5_7" },
863 { "lvs6", QCOM_RPM_PM8921_LVS6, &pm8921_switch, "vin_lvs1_3_6" },
864 { "lvs7", QCOM_RPM_PM8921_LVS7, &pm8921_switch, "vin_lvs4_5_7" },
865
866 { "usb-switch", QCOM_RPM_USB_OTG_SWITCH, &pm8921_switch, "vin_5vs" },
867 { "hdmi-switch", QCOM_RPM_HDMI_SWITCH, &pm8921_switch, "vin_5vs" },
868 { "ncp", QCOM_RPM_PM8921_NCP, &pm8921_ncp, "vdd_ncp" },
869 { }
870};
871
872static const struct of_device_id rpm_of_match[] = {
873 { .compatible = "qcom,rpm-pm8058-regulators", .data = &rpm_pm8058_regulators },
874 { .compatible = "qcom,rpm-pm8901-regulators", .data = &rpm_pm8901_regulators },
875 { .compatible = "qcom,rpm-pm8921-regulators", .data = &rpm_pm8921_regulators },
876 { }
877};
878MODULE_DEVICE_TABLE(of, rpm_of_match);
879
880static int rpm_reg_probe(struct platform_device *pdev)
881{
882 const struct rpm_regulator_data *reg;
883 const struct of_device_id *match;
884 struct regulator_config config = { };
885 struct regulator_dev *rdev;
886 struct qcom_rpm_reg *vreg;
887 struct qcom_rpm *rpm;
888
889 rpm = dev_get_drvdata(pdev->dev.parent);
890 if (!rpm) {
891 dev_err(&pdev->dev, "unable to retrieve handle to rpm\n");
892 return -ENODEV;
893 }
894
895 match = of_match_device(rpm_of_match, &pdev->dev);
896 for (reg = match->data; reg->name; reg++) {
897 vreg = devm_kmalloc(&pdev->dev, sizeof(*vreg), GFP_KERNEL);
898 if (!vreg)
899 return -ENOMEM;
900
901 memcpy(vreg, reg->template, sizeof(*vreg));
902 mutex_init(&vreg->lock);
903
904 vreg->dev = &pdev->dev;
905 vreg->resource = reg->resource;
906 vreg->rpm = rpm;
907
908 vreg->desc.id = -1;
909 vreg->desc.owner = THIS_MODULE;
910 vreg->desc.type = REGULATOR_VOLTAGE;
911 vreg->desc.name = reg->name;
912 vreg->desc.supply_name = reg->supply;
913 vreg->desc.of_match = reg->name;
914 vreg->desc.of_parse_cb = rpm_reg_of_parse;
915
916 config.dev = &pdev->dev;
917 config.driver_data = vreg;
918 rdev = devm_regulator_register(&pdev->dev, &vreg->desc, &config);
919 if (IS_ERR(rdev)) {
920 dev_err(&pdev->dev, "failed to register %s\n", reg->name);
921 return PTR_ERR(rdev);
922 }
797 } 923 }
798 924
799 return 0; 925 return 0;
diff --git a/drivers/regulator/stw481x-vmmc.c b/drivers/regulator/stw481x-vmmc.c
index 89025f560259..7d2ae3e9e942 100644
--- a/drivers/regulator/stw481x-vmmc.c
+++ b/drivers/regulator/stw481x-vmmc.c
@@ -56,6 +56,7 @@ static int stw481x_vmmc_regulator_probe(struct platform_device *pdev)
56{ 56{
57 struct stw481x *stw481x = dev_get_platdata(&pdev->dev); 57 struct stw481x *stw481x = dev_get_platdata(&pdev->dev);
58 struct regulator_config config = { }; 58 struct regulator_config config = { };
59 struct regulator_dev *rdev;
59 int ret; 60 int ret;
60 61
61 /* First disable the external VMMC if it's active */ 62 /* First disable the external VMMC if it's active */
@@ -75,12 +76,11 @@ static int stw481x_vmmc_regulator_probe(struct platform_device *pdev)
75 pdev->dev.of_node, 76 pdev->dev.of_node,
76 &vmmc_regulator); 77 &vmmc_regulator);
77 78
78 stw481x->vmmc_regulator = devm_regulator_register(&pdev->dev, 79 rdev = devm_regulator_register(&pdev->dev, &vmmc_regulator, &config);
79 &vmmc_regulator, &config); 80 if (IS_ERR(rdev)) {
80 if (IS_ERR(stw481x->vmmc_regulator)) {
81 dev_err(&pdev->dev, 81 dev_err(&pdev->dev,
82 "error initializing STw481x VMMC regulator\n"); 82 "error initializing STw481x VMMC regulator\n");
83 return PTR_ERR(stw481x->vmmc_regulator); 83 return PTR_ERR(rdev);
84 } 84 }
85 85
86 dev_info(&pdev->dev, "initialized STw481x VMMC regulator\n"); 86 dev_info(&pdev->dev, "initialized STw481x VMMC regulator\n");
diff --git a/drivers/regulator/wm8350-regulator.c b/drivers/regulator/wm8350-regulator.c
index 7ec7c390eeda..95f6b040186e 100644
--- a/drivers/regulator/wm8350-regulator.c
+++ b/drivers/regulator/wm8350-regulator.c
@@ -1151,17 +1151,16 @@ static const struct regulator_desc wm8350_reg[NUM_WM8350_REGULATORS] = {
1151static irqreturn_t pmic_uv_handler(int irq, void *data) 1151static irqreturn_t pmic_uv_handler(int irq, void *data)
1152{ 1152{
1153 struct regulator_dev *rdev = (struct regulator_dev *)data; 1153 struct regulator_dev *rdev = (struct regulator_dev *)data;
1154 struct wm8350 *wm8350 = rdev_get_drvdata(rdev);
1155 1154
1156 mutex_lock(&rdev->mutex); 1155 mutex_lock(&rdev->mutex);
1157 if (irq == WM8350_IRQ_CS1 || irq == WM8350_IRQ_CS2) 1156 if (irq == WM8350_IRQ_CS1 || irq == WM8350_IRQ_CS2)
1158 regulator_notifier_call_chain(rdev, 1157 regulator_notifier_call_chain(rdev,
1159 REGULATOR_EVENT_REGULATION_OUT, 1158 REGULATOR_EVENT_REGULATION_OUT,
1160 wm8350); 1159 NULL);
1161 else 1160 else
1162 regulator_notifier_call_chain(rdev, 1161 regulator_notifier_call_chain(rdev,
1163 REGULATOR_EVENT_UNDER_VOLTAGE, 1162 REGULATOR_EVENT_UNDER_VOLTAGE,
1164 wm8350); 1163 NULL);
1165 mutex_unlock(&rdev->mutex); 1164 mutex_unlock(&rdev->mutex);
1166 1165
1167 return IRQ_HANDLED; 1166 return IRQ_HANDLED;
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 5d60a868830d..2aa85e398f76 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -4225,22 +4225,15 @@ static struct scsi_host_template ufshcd_driver_template = {
4225static int ufshcd_config_vreg_load(struct device *dev, struct ufs_vreg *vreg, 4225static int ufshcd_config_vreg_load(struct device *dev, struct ufs_vreg *vreg,
4226 int ua) 4226 int ua)
4227{ 4227{
4228 int ret = 0; 4228 int ret;
4229 struct regulator *reg = vreg->reg;
4230 const char *name = vreg->name;
4231 4229
4232 BUG_ON(!vreg); 4230 if (!vreg)
4231 return 0;
4233 4232
4234 ret = regulator_set_optimum_mode(reg, ua); 4233 ret = regulator_set_load(vreg->reg, ua);
4235 if (ret >= 0) { 4234 if (ret < 0) {
4236 /* 4235 dev_err(dev, "%s: %s set load (ua=%d) failed, err=%d\n",
4237 * regulator_set_optimum_mode() returns new regulator 4236 __func__, vreg->name, ua, ret);
4238 * mode upon success.
4239 */
4240 ret = 0;
4241 } else {
4242 dev_err(dev, "%s: %s set optimum mode(ua=%d) failed, err=%d\n",
4243 __func__, name, ua, ret);
4244 } 4237 }
4245 4238
4246 return ret; 4239 return ret;
@@ -4249,18 +4242,12 @@ static int ufshcd_config_vreg_load(struct device *dev, struct ufs_vreg *vreg,
4249static inline int ufshcd_config_vreg_lpm(struct ufs_hba *hba, 4242static inline int ufshcd_config_vreg_lpm(struct ufs_hba *hba,
4250 struct ufs_vreg *vreg) 4243 struct ufs_vreg *vreg)
4251{ 4244{
4252 if (!vreg)
4253 return 0;
4254
4255 return ufshcd_config_vreg_load(hba->dev, vreg, UFS_VREG_LPM_LOAD_UA); 4245 return ufshcd_config_vreg_load(hba->dev, vreg, UFS_VREG_LPM_LOAD_UA);
4256} 4246}
4257 4247
4258static inline int ufshcd_config_vreg_hpm(struct ufs_hba *hba, 4248static inline int ufshcd_config_vreg_hpm(struct ufs_hba *hba,
4259 struct ufs_vreg *vreg) 4249 struct ufs_vreg *vreg)
4260{ 4250{
4261 if (!vreg)
4262 return 0;
4263
4264 return ufshcd_config_vreg_load(hba->dev, vreg, vreg->max_uA); 4251 return ufshcd_config_vreg_load(hba->dev, vreg, vreg->max_uA);
4265} 4252}
4266 4253
diff --git a/drivers/usb/phy/phy-ab8500-usb.c b/drivers/usb/phy/phy-ab8500-usb.c
index 0b1bd2369293..f5b3b928941b 100644
--- a/drivers/usb/phy/phy-ab8500-usb.c
+++ b/drivers/usb/phy/phy-ab8500-usb.c
@@ -277,7 +277,7 @@ static void ab8500_usb_regulator_enable(struct ab8500_usb *ab)
277 dev_err(ab->dev, "Failed to set the Vintcore to 1.3V, ret=%d\n", 277 dev_err(ab->dev, "Failed to set the Vintcore to 1.3V, ret=%d\n",
278 ret); 278 ret);
279 279
280 ret = regulator_set_optimum_mode(ab->v_ulpi, 28000); 280 ret = regulator_set_load(ab->v_ulpi, 28000);
281 if (ret < 0) 281 if (ret < 0)
282 dev_err(ab->dev, "Failed to set optimum mode (ret=%d)\n", 282 dev_err(ab->dev, "Failed to set optimum mode (ret=%d)\n",
283 ret); 283 ret);
@@ -317,7 +317,7 @@ static void ab8500_usb_regulator_disable(struct ab8500_usb *ab)
317 ab->saved_v_ulpi, ret); 317 ab->saved_v_ulpi, ret);
318 } 318 }
319 319
320 ret = regulator_set_optimum_mode(ab->v_ulpi, 0); 320 ret = regulator_set_load(ab->v_ulpi, 0);
321 if (ret < 0) 321 if (ret < 0)
322 dev_err(ab->dev, "Failed to set optimum mode (ret=%d)\n", 322 dev_err(ab->dev, "Failed to set optimum mode (ret=%d)\n",
323 ret); 323 ret);
diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
index 000fd892455f..6ed67ea4ef7e 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -142,27 +142,22 @@ static int msm_hsusb_ldo_set_mode(struct msm_otg *motg, int on)
142 int ret = 0; 142 int ret = 0;
143 143
144 if (on) { 144 if (on) {
145 ret = regulator_set_optimum_mode(motg->v1p8, 145 ret = regulator_set_load(motg->v1p8, USB_PHY_1P8_HPM_LOAD);
146 USB_PHY_1P8_HPM_LOAD);
147 if (ret < 0) { 146 if (ret < 0) {
148 pr_err("Could not set HPM for v1p8\n"); 147 pr_err("Could not set HPM for v1p8\n");
149 return ret; 148 return ret;
150 } 149 }
151 ret = regulator_set_optimum_mode(motg->v3p3, 150 ret = regulator_set_load(motg->v3p3, USB_PHY_3P3_HPM_LOAD);
152 USB_PHY_3P3_HPM_LOAD);
153 if (ret < 0) { 151 if (ret < 0) {
154 pr_err("Could not set HPM for v3p3\n"); 152 pr_err("Could not set HPM for v3p3\n");
155 regulator_set_optimum_mode(motg->v1p8, 153 regulator_set_load(motg->v1p8, USB_PHY_1P8_LPM_LOAD);
156 USB_PHY_1P8_LPM_LOAD);
157 return ret; 154 return ret;
158 } 155 }
159 } else { 156 } else {
160 ret = regulator_set_optimum_mode(motg->v1p8, 157 ret = regulator_set_load(motg->v1p8, USB_PHY_1P8_LPM_LOAD);
161 USB_PHY_1P8_LPM_LOAD);
162 if (ret < 0) 158 if (ret < 0)
163 pr_err("Could not set LPM for v1p8\n"); 159 pr_err("Could not set LPM for v1p8\n");
164 ret = regulator_set_optimum_mode(motg->v3p3, 160 ret = regulator_set_load(motg->v3p3, USB_PHY_3P3_LPM_LOAD);
165 USB_PHY_3P3_LPM_LOAD);
166 if (ret < 0) 161 if (ret < 0)
167 pr_err("Could not set LPM for v3p3\n"); 162 pr_err("Could not set LPM for v3p3\n");
168 } 163 }
diff --git a/include/linux/mfd/max77693.h b/include/linux/mfd/max77693.h
index f0b6585cd874..09a4dedaeea8 100644
--- a/include/linux/mfd/max77693.h
+++ b/include/linux/mfd/max77693.h
@@ -30,7 +30,7 @@
30#ifndef __LINUX_MFD_MAX77693_H 30#ifndef __LINUX_MFD_MAX77693_H
31#define __LINUX_MFD_MAX77693_H 31#define __LINUX_MFD_MAX77693_H
32 32
33/* MAX77686 regulator IDs */ 33/* MAX77693 regulator IDs */
34enum max77693_regulators { 34enum max77693_regulators {
35 MAX77693_ESAFEOUT1 = 0, 35 MAX77693_ESAFEOUT1 = 0,
36 MAX77693_ESAFEOUT2, 36 MAX77693_ESAFEOUT2,
@@ -38,12 +38,6 @@ enum max77693_regulators {
38 MAX77693_REG_MAX, 38 MAX77693_REG_MAX,
39}; 39};
40 40
41struct max77693_regulator_data {
42 int id;
43 struct regulator_init_data *initdata;
44 struct device_node *of_node;
45};
46
47struct max77693_reg_data { 41struct max77693_reg_data {
48 u8 addr; 42 u8 addr;
49 u8 data; 43 u8 data;
@@ -103,10 +97,6 @@ struct max77693_led_platform_data {
103/* MAX77693 */ 97/* MAX77693 */
104 98
105struct max77693_platform_data { 99struct max77693_platform_data {
106 /* regulator data */
107 struct max77693_regulator_data *regulators;
108 int num_regulators;
109
110 /* muic data */ 100 /* muic data */
111 struct max77693_muic_platform_data *muic_data; 101 struct max77693_muic_platform_data *muic_data;
112 struct max77693_led_platform_data *led_data; 102 struct max77693_led_platform_data *led_data;
diff --git a/include/linux/mfd/palmas.h b/include/linux/mfd/palmas.h
index ee7b1ce7a6f8..bb270bd03eed 100644
--- a/include/linux/mfd/palmas.h
+++ b/include/linux/mfd/palmas.h
@@ -117,6 +117,7 @@ struct palmas_pmic_driver_data {
117 int ldo_begin; 117 int ldo_begin;
118 int ldo_end; 118 int ldo_end;
119 int max_reg; 119 int max_reg;
120 bool has_regen3;
120 struct palmas_regs_info *palmas_regs_info; 121 struct palmas_regs_info *palmas_regs_info;
121 struct of_regulator_match *palmas_matches; 122 struct of_regulator_match *palmas_matches;
122 struct palmas_sleep_requestor_info *sleep_req_info; 123 struct palmas_sleep_requestor_info *sleep_req_info;
diff --git a/include/linux/mfd/stw481x.h b/include/linux/mfd/stw481x.h
index eda121556e5d..833074b766bd 100644
--- a/include/linux/mfd/stw481x.h
+++ b/include/linux/mfd/stw481x.h
@@ -41,15 +41,11 @@
41 41
42/** 42/**
43 * struct stw481x - state holder for the Stw481x drivers 43 * struct stw481x - state holder for the Stw481x drivers
44 * @mutex: mutex to serialize I2C accesses
45 * @i2c_client: corresponding I2C client 44 * @i2c_client: corresponding I2C client
46 * @regulator: regulator device for regulator children
47 * @map: regmap handle to access device registers 45 * @map: regmap handle to access device registers
48 */ 46 */
49struct stw481x { 47struct stw481x {
50 struct mutex lock;
51 struct i2c_client *client; 48 struct i2c_client *client;
52 struct regulator_dev *vmmc_regulator;
53 struct regmap *map; 49 struct regmap *map;
54}; 50};
55 51
diff --git a/include/linux/regulator/act8865.h b/include/linux/regulator/act8865.h
index b6c4909b33af..15fa8f2d35c9 100644
--- a/include/linux/regulator/act8865.h
+++ b/include/linux/regulator/act8865.h
@@ -19,6 +19,19 @@
19#include <linux/regulator/machine.h> 19#include <linux/regulator/machine.h>
20 20
21enum { 21enum {
22 ACT8600_ID_DCDC1,
23 ACT8600_ID_DCDC2,
24 ACT8600_ID_DCDC3,
25 ACT8600_ID_SUDCDC4,
26 ACT8600_ID_LDO5,
27 ACT8600_ID_LDO6,
28 ACT8600_ID_LDO7,
29 ACT8600_ID_LDO8,
30 ACT8600_ID_LDO9,
31 ACT8600_ID_LDO10,
32};
33
34enum {
22 ACT8865_ID_DCDC1, 35 ACT8865_ID_DCDC1,
23 ACT8865_ID_DCDC2, 36 ACT8865_ID_DCDC2,
24 ACT8865_ID_DCDC3, 37 ACT8865_ID_DCDC3,
@@ -46,6 +59,7 @@ enum {
46}; 59};
47 60
48enum { 61enum {
62 ACT8600,
49 ACT8865, 63 ACT8865,
50 ACT8846, 64 ACT8846,
51}; 65};
diff --git a/include/linux/regulator/consumer.h b/include/linux/regulator/consumer.h
index d17e1ff7ad01..f8a689ed62a5 100644
--- a/include/linux/regulator/consumer.h
+++ b/include/linux/regulator/consumer.h
@@ -114,7 +114,7 @@ struct regmap;
114#define REGULATOR_EVENT_OVER_TEMP 0x10 114#define REGULATOR_EVENT_OVER_TEMP 0x10
115#define REGULATOR_EVENT_FORCE_DISABLE 0x20 115#define REGULATOR_EVENT_FORCE_DISABLE 0x20
116#define REGULATOR_EVENT_VOLTAGE_CHANGE 0x40 116#define REGULATOR_EVENT_VOLTAGE_CHANGE 0x40
117#define REGULATOR_EVENT_DISABLE 0x80 117#define REGULATOR_EVENT_DISABLE 0x80
118#define REGULATOR_EVENT_PRE_VOLTAGE_CHANGE 0x100 118#define REGULATOR_EVENT_PRE_VOLTAGE_CHANGE 0x100
119#define REGULATOR_EVENT_ABORT_VOLTAGE_CHANGE 0x200 119#define REGULATOR_EVENT_ABORT_VOLTAGE_CHANGE 0x200
120#define REGULATOR_EVENT_PRE_DISABLE 0x400 120#define REGULATOR_EVENT_PRE_DISABLE 0x400
@@ -238,7 +238,7 @@ int regulator_get_current_limit(struct regulator *regulator);
238 238
239int regulator_set_mode(struct regulator *regulator, unsigned int mode); 239int regulator_set_mode(struct regulator *regulator, unsigned int mode);
240unsigned int regulator_get_mode(struct regulator *regulator); 240unsigned int regulator_get_mode(struct regulator *regulator);
241int regulator_set_optimum_mode(struct regulator *regulator, int load_uA); 241int regulator_set_load(struct regulator *regulator, int load_uA);
242 242
243int regulator_allow_bypass(struct regulator *regulator, bool allow); 243int regulator_allow_bypass(struct regulator *regulator, bool allow);
244 244
@@ -252,8 +252,12 @@ int regulator_list_hardware_vsel(struct regulator *regulator,
252/* regulator notifier block */ 252/* regulator notifier block */
253int regulator_register_notifier(struct regulator *regulator, 253int regulator_register_notifier(struct regulator *regulator,
254 struct notifier_block *nb); 254 struct notifier_block *nb);
255int devm_regulator_register_notifier(struct regulator *regulator,
256 struct notifier_block *nb);
255int regulator_unregister_notifier(struct regulator *regulator, 257int regulator_unregister_notifier(struct regulator *regulator,
256 struct notifier_block *nb); 258 struct notifier_block *nb);
259void devm_regulator_unregister_notifier(struct regulator *regulator,
260 struct notifier_block *nb);
257 261
258/* driver data - core doesn't touch */ 262/* driver data - core doesn't touch */
259void *regulator_get_drvdata(struct regulator *regulator); 263void *regulator_get_drvdata(struct regulator *regulator);
@@ -479,8 +483,7 @@ static inline unsigned int regulator_get_mode(struct regulator *regulator)
479 return REGULATOR_MODE_NORMAL; 483 return REGULATOR_MODE_NORMAL;
480} 484}
481 485
482static inline int regulator_set_optimum_mode(struct regulator *regulator, 486static inline int regulator_set_load(struct regulator *regulator, int load_uA)
483 int load_uA)
484{ 487{
485 return REGULATOR_MODE_NORMAL; 488 return REGULATOR_MODE_NORMAL;
486} 489}
@@ -515,12 +518,24 @@ static inline int regulator_register_notifier(struct regulator *regulator,
515 return 0; 518 return 0;
516} 519}
517 520
521static inline int devm_regulator_register_notifier(struct regulator *regulator,
522 struct notifier_block *nb)
523{
524 return 0;
525}
526
518static inline int regulator_unregister_notifier(struct regulator *regulator, 527static inline int regulator_unregister_notifier(struct regulator *regulator,
519 struct notifier_block *nb) 528 struct notifier_block *nb)
520{ 529{
521 return 0; 530 return 0;
522} 531}
523 532
533static inline int devm_regulator_unregister_notifier(struct regulator *regulator,
534 struct notifier_block *nb)
535{
536 return 0;
537}
538
524static inline void *regulator_get_drvdata(struct regulator *regulator) 539static inline void *regulator_get_drvdata(struct regulator *regulator)
525{ 540{
526 return NULL; 541 return NULL;
diff --git a/include/linux/regulator/driver.h b/include/linux/regulator/driver.h
index 045f709cb89b..fffa688ac3a7 100644
--- a/include/linux/regulator/driver.h
+++ b/include/linux/regulator/driver.h
@@ -98,6 +98,7 @@ struct regulator_linear_range {
98 * REGULATOR_STATUS value (or negative errno) 98 * REGULATOR_STATUS value (or negative errno)
99 * @get_optimum_mode: Get the most efficient operating mode for the regulator 99 * @get_optimum_mode: Get the most efficient operating mode for the regulator
100 * when running with the specified parameters. 100 * when running with the specified parameters.
101 * @set_load: Set the load for the regulator.
101 * 102 *
102 * @set_bypass: Set the regulator in bypass mode. 103 * @set_bypass: Set the regulator in bypass mode.
103 * @get_bypass: Get the regulator bypass mode state. 104 * @get_bypass: Get the regulator bypass mode state.
@@ -167,6 +168,8 @@ struct regulator_ops {
167 /* get most efficient regulator operating mode for load */ 168 /* get most efficient regulator operating mode for load */
168 unsigned int (*get_optimum_mode) (struct regulator_dev *, int input_uV, 169 unsigned int (*get_optimum_mode) (struct regulator_dev *, int input_uV,
169 int output_uV, int load_uA); 170 int output_uV, int load_uA);
171 /* set the load on the regulator */
172 int (*set_load)(struct regulator_dev *, int load_uA);
170 173
171 /* control and report on bypass mode */ 174 /* control and report on bypass mode */
172 int (*set_bypass)(struct regulator_dev *dev, bool enable); 175 int (*set_bypass)(struct regulator_dev *dev, bool enable);
@@ -367,6 +370,7 @@ struct regulator_dev {
367 struct device dev; 370 struct device dev;
368 struct regulation_constraints *constraints; 371 struct regulation_constraints *constraints;
369 struct regulator *supply; /* for tree */ 372 struct regulator *supply; /* for tree */
373 const char *supply_name;
370 struct regmap *regmap; 374 struct regmap *regmap;
371 375
372 struct delayed_work disable_work; 376 struct delayed_work disable_work;