aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2014-10-06 19:18:38 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2014-10-06 19:18:38 -0400
commit4734c6efc8c691fda80f11ae00016bc3a8d9ebb5 (patch)
treeff27c54c0d9787e3321a8591005b356ea2305ecc
parent0f4685d0ec9aa1db99f014f8f774518cae085aca (diff)
parent7961bb722631cbf0cd68c57f3255ba66e1a879d9 (diff)
Merge branch 'pm-avs'
* pm-avs: MAINTAINERS: update entry for drivers/power/avs PM / AVS: rockchip-io: add driver handling Rockchip io domains regulator: core: Add REGULATOR_EVENT_PRE_VOLTAGE_CHANGE (and ABORT)
-rw-r--r--Documentation/devicetree/bindings/power/rockchip-io-domain.txt83
-rw-r--r--MAINTAINERS4
-rw-r--r--drivers/power/avs/Kconfig8
-rw-r--r--drivers/power/avs/Makefile1
-rw-r--r--drivers/power/avs/rockchip-io-domain.c351
-rw-r--r--drivers/regulator/core.c63
-rw-r--r--include/linux/regulator/consumer.h20
7 files changed, 521 insertions, 9 deletions
diff --git a/Documentation/devicetree/bindings/power/rockchip-io-domain.txt b/Documentation/devicetree/bindings/power/rockchip-io-domain.txt
new file mode 100644
index 000000000000..6fbf6e7ecde6
--- /dev/null
+++ b/Documentation/devicetree/bindings/power/rockchip-io-domain.txt
@@ -0,0 +1,83 @@
1Rockchip SRAM for IO Voltage Domains:
2-------------------------------------
3
4IO domain voltages on some Rockchip SoCs are variable but need to be
5kept in sync between the regulators and the SoC using a special
6register.
7
8A specific example using rk3288:
9- If the regulator hooked up to a pin like SDMMC0_VDD is 3.3V then
10 bit 7 of GRF_IO_VSEL needs to be 0. If the regulator hooked up to
11 that same pin is 1.8V then bit 7 of GRF_IO_VSEL needs to be 1.
12
13Said another way, this driver simply handles keeping bits in the SoC's
14general register file (GRF) in sync with the actual value of a voltage
15hooked up to the pins.
16
17Note that this driver specifically doesn't include:
18- any logic for deciding what voltage we should set regulators to
19- any logic for deciding whether regulators (or internal SoC blocks)
20 should have power or not have power
21
22If there were some other software that had the smarts of making
23decisions about regulators, it would work in conjunction with this
24driver. When that other software adjusted a regulator's voltage then
25this driver would handle telling the SoC about it. A good example is
26vqmmc for SD. In that case the dw_mmc driver simply is told about a
27regulator. It changes the regulator between 3.3V and 1.8V at the
28right time. This driver notices the change and makes sure that the
29SoC is on the same page.
30
31
32Required properties:
33- compatible: should be one of:
34 - "rockchip,rk3188-io-voltage-domain" for rk3188
35 - "rockchip,rk3288-io-voltage-domain" for rk3288
36- rockchip,grf: phandle to the syscon managing the "general register files"
37
38
39You specify supplies using the standard regulator bindings by including
40a phandle the the relevant regulator. All specified supplies must be able
41to report their voltage. The IO Voltage Domain for any non-specified
42supplies will be not be touched.
43
44Possible supplies for rk3188:
45- ap0-supply: The supply connected to AP0_VCC.
46- ap1-supply: The supply connected to AP1_VCC.
47- cif-supply: The supply connected to CIF_VCC.
48- flash-supply: The supply connected to FLASH_VCC.
49- lcdc0-supply: The supply connected to LCD0_VCC.
50- lcdc1-supply: The supply connected to LCD1_VCC.
51- vccio0-supply: The supply connected to VCCIO0.
52- vccio1-supply: The supply connected to VCCIO1.
53 Sometimes also labeled VCCIO1 and VCCIO2.
54
55Possible supplies for rk3288:
56- audio-supply: The supply connected to APIO4_VDD.
57- bb-supply: The supply connected to APIO5_VDD.
58- dvp-supply: The supply connected to DVPIO_VDD.
59- flash0-supply: The supply connected to FLASH0_VDD. Typically for eMMC
60- flash1-supply: The supply connected to FLASH1_VDD. Also known as SDIO1.
61- gpio30-supply: The supply connected to APIO1_VDD.
62- gpio1830 The supply connected to APIO2_VDD.
63- lcdc-supply: The supply connected to LCDC_VDD.
64- sdcard-supply: The supply connected to SDMMC0_VDD.
65- wifi-supply: The supply connected to APIO3_VDD. Also known as SDIO0.
66
67
68Example:
69
70 io-domains {
71 compatible = "rockchip,rk3288-io-voltage-domain";
72 rockchip,grf = <&grf>;
73
74 audio-supply = <&vcc18_codec>;
75 bb-supply = <&vcc33_io>;
76 dvp-supply = <&vcc_18>;
77 flash0-supply = <&vcc18_flashio>;
78 gpio1830-supply = <&vcc33_io>;
79 gpio30-supply = <&vcc33_pmuio>;
80 lcdc-supply = <&vcc33_lcd>;
81 sdcard-supply = <&vccio_sd>;
82 wifi-supply = <&vcc18_wl>;
83 };
diff --git a/MAINTAINERS b/MAINTAINERS
index f10ed3914ea8..fbafc94ac9ae 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -8414,11 +8414,11 @@ S: Maintained
8414F: Documentation/security/Smack.txt 8414F: Documentation/security/Smack.txt
8415F: security/smack/ 8415F: security/smack/
8416 8416
8417SMARTREFLEX DRIVERS FOR ADAPTIVE VOLTAGE SCALING (AVS) 8417DRIVERS FOR ADAPTIVE VOLTAGE SCALING (AVS)
8418M: Kevin Hilman <khilman@kernel.org> 8418M: Kevin Hilman <khilman@kernel.org>
8419M: Nishanth Menon <nm@ti.com> 8419M: Nishanth Menon <nm@ti.com>
8420S: Maintained 8420S: Maintained
8421F: drivers/power/avs/smartreflex.c 8421F: drivers/power/avs/
8422F: include/linux/power/smartreflex.h 8422F: include/linux/power/smartreflex.h
8423L: linux-pm@vger.kernel.org 8423L: linux-pm@vger.kernel.org
8424 8424
diff --git a/drivers/power/avs/Kconfig b/drivers/power/avs/Kconfig
index 2a1008b61121..7f3d389bd601 100644
--- a/drivers/power/avs/Kconfig
+++ b/drivers/power/avs/Kconfig
@@ -10,3 +10,11 @@ menuconfig POWER_AVS
10 AVS is also called SmartReflex on OMAP devices. 10 AVS is also called SmartReflex on OMAP devices.
11 11
12 Say Y here to enable Adaptive Voltage Scaling class support. 12 Say Y here to enable Adaptive Voltage Scaling class support.
13
14config ROCKCHIP_IODOMAIN
15 tristate "Rockchip IO domain support"
16 depends on ARCH_ROCKCHIP && OF
17 help
18 Say y here to enable support io domains on Rockchip SoCs. It is
19 necessary for the io domain setting of the SoC to match the
20 voltage supplied by the regulators.
diff --git a/drivers/power/avs/Makefile b/drivers/power/avs/Makefile
index 0843386a6c19..ba4c7bc69225 100644
--- a/drivers/power/avs/Makefile
+++ b/drivers/power/avs/Makefile
@@ -1 +1,2 @@
1obj-$(CONFIG_POWER_AVS_OMAP) += smartreflex.o 1obj-$(CONFIG_POWER_AVS_OMAP) += smartreflex.o
2obj-$(CONFIG_ROCKCHIP_IODOMAIN) += rockchip-io-domain.o
diff --git a/drivers/power/avs/rockchip-io-domain.c b/drivers/power/avs/rockchip-io-domain.c
new file mode 100644
index 000000000000..3ae35d0590d2
--- /dev/null
+++ b/drivers/power/avs/rockchip-io-domain.c
@@ -0,0 +1,351 @@
1/*
2 * Rockchip IO Voltage Domain driver
3 *
4 * Copyright 2014 MundoReader S.L.
5 * Copyright 2014 Google, Inc.
6 *
7 * This software is licensed under the terms of the GNU General Public
8 * License version 2, as published by the Free Software Foundation, and
9 * may be copied, distributed, and modified under those terms.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 */
16
17#include <linux/kernel.h>
18#include <linux/module.h>
19#include <linux/err.h>
20#include <linux/mfd/syscon.h>
21#include <linux/of.h>
22#include <linux/platform_device.h>
23#include <linux/regmap.h>
24#include <linux/regulator/consumer.h>
25
26#define MAX_SUPPLIES 16
27
28/*
29 * The max voltage for 1.8V and 3.3V come from the Rockchip datasheet under
30 * "Recommended Operating Conditions" for "Digital GPIO". When the typical
31 * is 3.3V the max is 3.6V. When the typical is 1.8V the max is 1.98V.
32 *
33 * They are used like this:
34 * - If the voltage on a rail is above the "1.8" voltage (1.98V) we'll tell the
35 * SoC we're at 3.3.
36 * - If the voltage on a rail is above the "3.3" voltage (3.6V) we'll consider
37 * that to be an error.
38 */
39#define MAX_VOLTAGE_1_8 1980000
40#define MAX_VOLTAGE_3_3 3600000
41
42#define RK3288_SOC_CON2 0x24c
43#define RK3288_SOC_CON2_FLASH0 BIT(7)
44#define RK3288_SOC_FLASH_SUPPLY_NUM 2
45
46struct rockchip_iodomain;
47
48/**
49 * @supplies: voltage settings matching the register bits.
50 */
51struct rockchip_iodomain_soc_data {
52 int grf_offset;
53 const char *supply_names[MAX_SUPPLIES];
54 void (*init)(struct rockchip_iodomain *iod);
55};
56
57struct rockchip_iodomain_supply {
58 struct rockchip_iodomain *iod;
59 struct regulator *reg;
60 struct notifier_block nb;
61 int idx;
62};
63
64struct rockchip_iodomain {
65 struct device *dev;
66 struct regmap *grf;
67 struct rockchip_iodomain_soc_data *soc_data;
68 struct rockchip_iodomain_supply supplies[MAX_SUPPLIES];
69};
70
71static int rockchip_iodomain_write(struct rockchip_iodomain_supply *supply,
72 int uV)
73{
74 struct rockchip_iodomain *iod = supply->iod;
75 u32 val;
76 int ret;
77
78 /* set value bit */
79 val = (uV > MAX_VOLTAGE_1_8) ? 0 : 1;
80 val <<= supply->idx;
81
82 /* apply hiword-mask */
83 val |= (BIT(supply->idx) << 16);
84
85 ret = regmap_write(iod->grf, iod->soc_data->grf_offset, val);
86 if (ret)
87 dev_err(iod->dev, "Couldn't write to GRF\n");
88
89 return ret;
90}
91
92static int rockchip_iodomain_notify(struct notifier_block *nb,
93 unsigned long event,
94 void *data)
95{
96 struct rockchip_iodomain_supply *supply =
97 container_of(nb, struct rockchip_iodomain_supply, nb);
98 int uV;
99 int ret;
100
101 /*
102 * According to Rockchip it's important to keep the SoC IO domain
103 * higher than (or equal to) the external voltage. That means we need
104 * to change it before external voltage changes happen in the case
105 * of an increase.
106 *
107 * Note that in the "pre" change we pick the max possible voltage that
108 * the regulator might end up at (the client requests a range and we
109 * don't know for certain the exact voltage). Right now we rely on the
110 * slop in MAX_VOLTAGE_1_8 and MAX_VOLTAGE_3_3 to save us if clients
111 * request something like a max of 3.6V when they really want 3.3V.
112 * We could attempt to come up with better rules if this fails.
113 */
114 if (event & REGULATOR_EVENT_PRE_VOLTAGE_CHANGE) {
115 struct pre_voltage_change_data *pvc_data = data;
116
117 uV = max_t(unsigned long, pvc_data->old_uV, pvc_data->max_uV);
118 } else if (event & (REGULATOR_EVENT_VOLTAGE_CHANGE |
119 REGULATOR_EVENT_ABORT_VOLTAGE_CHANGE)) {
120 uV = (unsigned long)data;
121 } else {
122 return NOTIFY_OK;
123 }
124
125 dev_dbg(supply->iod->dev, "Setting to %d\n", uV);
126
127 if (uV > MAX_VOLTAGE_3_3) {
128 dev_err(supply->iod->dev, "Voltage too high: %d\n", uV);
129
130 if (event == REGULATOR_EVENT_PRE_VOLTAGE_CHANGE)
131 return NOTIFY_BAD;
132 }
133
134 ret = rockchip_iodomain_write(supply, uV);
135 if (ret && event == REGULATOR_EVENT_PRE_VOLTAGE_CHANGE)
136 return NOTIFY_BAD;
137
138 dev_info(supply->iod->dev, "Setting to %d done\n", uV);
139 return NOTIFY_OK;
140}
141
142static void rk3288_iodomain_init(struct rockchip_iodomain *iod)
143{
144 int ret;
145 u32 val;
146
147 /* if no flash supply we should leave things alone */
148 if (!iod->supplies[RK3288_SOC_FLASH_SUPPLY_NUM].reg)
149 return;
150
151 /*
152 * set flash0 iodomain to also use this framework
153 * instead of a special gpio.
154 */
155 val = RK3288_SOC_CON2_FLASH0 | (RK3288_SOC_CON2_FLASH0 << 16);
156 ret = regmap_write(iod->grf, RK3288_SOC_CON2, val);
157 if (ret < 0)
158 dev_warn(iod->dev, "couldn't update flash0 ctrl\n");
159}
160
161/*
162 * On the rk3188 the io-domains are handled by a shared register with the
163 * lower 8 bits being still being continuing drive-strength settings.
164 */
165static const struct rockchip_iodomain_soc_data soc_data_rk3188 = {
166 .grf_offset = 0x104,
167 .supply_names = {
168 NULL,
169 NULL,
170 NULL,
171 NULL,
172 NULL,
173 NULL,
174 NULL,
175 NULL,
176 "ap0",
177 "ap1",
178 "cif",
179 "flash",
180 "vccio0",
181 "vccio1",
182 "lcdc0",
183 "lcdc1",
184 },
185};
186
187static const struct rockchip_iodomain_soc_data soc_data_rk3288 = {
188 .grf_offset = 0x380,
189 .supply_names = {
190 "lcdc", /* LCDC_VDD */
191 "dvp", /* DVPIO_VDD */
192 "flash0", /* FLASH0_VDD (emmc) */
193 "flash1", /* FLASH1_VDD (sdio1) */
194 "wifi", /* APIO3_VDD (sdio0) */
195 "bb", /* APIO5_VDD */
196 "audio", /* APIO4_VDD */
197 "sdcard", /* SDMMC0_VDD (sdmmc) */
198 "gpio30", /* APIO1_VDD */
199 "gpio1830", /* APIO2_VDD */
200 },
201 .init = rk3288_iodomain_init,
202};
203
204static const struct of_device_id rockchip_iodomain_match[] = {
205 {
206 .compatible = "rockchip,rk3188-io-voltage-domain",
207 .data = (void *)&soc_data_rk3188
208 },
209 {
210 .compatible = "rockchip,rk3288-io-voltage-domain",
211 .data = (void *)&soc_data_rk3288
212 },
213 { /* sentinel */ },
214};
215
216static int rockchip_iodomain_probe(struct platform_device *pdev)
217{
218 struct device_node *np = pdev->dev.of_node;
219 const struct of_device_id *match;
220 struct rockchip_iodomain *iod;
221 int i, ret = 0;
222
223 if (!np)
224 return -ENODEV;
225
226 iod = devm_kzalloc(&pdev->dev, sizeof(*iod), GFP_KERNEL);
227 if (!iod)
228 return -ENOMEM;
229
230 iod->dev = &pdev->dev;
231 platform_set_drvdata(pdev, iod);
232
233 match = of_match_node(rockchip_iodomain_match, np);
234 iod->soc_data = (struct rockchip_iodomain_soc_data *)match->data;
235
236 iod->grf = syscon_regmap_lookup_by_phandle(np, "rockchip,grf");
237 if (IS_ERR(iod->grf)) {
238 dev_err(&pdev->dev, "couldn't find grf regmap\n");
239 return PTR_ERR(iod->grf);
240 }
241
242 for (i = 0; i < MAX_SUPPLIES; i++) {
243 const char *supply_name = iod->soc_data->supply_names[i];
244 struct rockchip_iodomain_supply *supply = &iod->supplies[i];
245 struct regulator *reg;
246 int uV;
247
248 if (!supply_name)
249 continue;
250
251 reg = devm_regulator_get_optional(iod->dev, supply_name);
252 if (IS_ERR(reg)) {
253 ret = PTR_ERR(reg);
254
255 /* If a supply wasn't specified, that's OK */
256 if (ret == -ENODEV)
257 continue;
258 else if (ret != -EPROBE_DEFER)
259 dev_err(iod->dev, "couldn't get regulator %s\n",
260 supply_name);
261 goto unreg_notify;
262 }
263
264 /* set initial correct value */
265 uV = regulator_get_voltage(reg);
266
267 /* must be a regulator we can get the voltage of */
268 if (uV < 0) {
269 dev_err(iod->dev, "Can't determine voltage: %s\n",
270 supply_name);
271 goto unreg_notify;
272 }
273
274 if (uV > MAX_VOLTAGE_3_3) {
275 dev_crit(iod->dev,
276 "%d uV is too high. May damage SoC!\n",
277 uV);
278 ret = -EINVAL;
279 goto unreg_notify;
280 }
281
282 /* setup our supply */
283 supply->idx = i;
284 supply->iod = iod;
285 supply->reg = reg;
286 supply->nb.notifier_call = rockchip_iodomain_notify;
287
288 ret = rockchip_iodomain_write(supply, uV);
289 if (ret) {
290 supply->reg = NULL;
291 goto unreg_notify;
292 }
293
294 /* register regulator notifier */
295 ret = regulator_register_notifier(reg, &supply->nb);
296 if (ret) {
297 dev_err(&pdev->dev,
298 "regulator notifier request failed\n");
299 supply->reg = NULL;
300 goto unreg_notify;
301 }
302 }
303
304 if (iod->soc_data->init)
305 iod->soc_data->init(iod);
306
307 return 0;
308
309unreg_notify:
310 for (i = MAX_SUPPLIES - 1; i >= 0; i--) {
311 struct rockchip_iodomain_supply *io_supply = &iod->supplies[i];
312
313 if (io_supply->reg)
314 regulator_unregister_notifier(io_supply->reg,
315 &io_supply->nb);
316 }
317
318 return ret;
319}
320
321static int rockchip_iodomain_remove(struct platform_device *pdev)
322{
323 struct rockchip_iodomain *iod = platform_get_drvdata(pdev);
324 int i;
325
326 for (i = MAX_SUPPLIES - 1; i >= 0; i--) {
327 struct rockchip_iodomain_supply *io_supply = &iod->supplies[i];
328
329 if (io_supply->reg)
330 regulator_unregister_notifier(io_supply->reg,
331 &io_supply->nb);
332 }
333
334 return 0;
335}
336
337static struct platform_driver rockchip_iodomain_driver = {
338 .probe = rockchip_iodomain_probe,
339 .remove = rockchip_iodomain_remove,
340 .driver = {
341 .name = "rockchip-iodomain",
342 .of_match_table = rockchip_iodomain_match,
343 },
344};
345
346module_platform_driver(rockchip_iodomain_driver);
347
348MODULE_DESCRIPTION("Rockchip IO-domain driver");
349MODULE_AUTHOR("Heiko Stuebner <heiko@sntech.de>");
350MODULE_AUTHOR("Doug Anderson <dianders@chromium.org>");
351MODULE_LICENSE("GPL v2");
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index a3c3785901f5..dabc8e8862c8 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -102,7 +102,7 @@ static int _regulator_disable(struct regulator_dev *rdev);
102static int _regulator_get_voltage(struct regulator_dev *rdev); 102static int _regulator_get_voltage(struct regulator_dev *rdev);
103static int _regulator_get_current_limit(struct regulator_dev *rdev); 103static int _regulator_get_current_limit(struct regulator_dev *rdev);
104static unsigned int _regulator_get_mode(struct regulator_dev *rdev); 104static unsigned int _regulator_get_mode(struct regulator_dev *rdev);
105static void _notifier_call_chain(struct regulator_dev *rdev, 105static int _notifier_call_chain(struct regulator_dev *rdev,
106 unsigned long event, void *data); 106 unsigned long event, void *data);
107static int _regulator_do_set_voltage(struct regulator_dev *rdev, 107static int _regulator_do_set_voltage(struct regulator_dev *rdev,
108 int min_uV, int max_uV); 108 int min_uV, int max_uV);
@@ -2369,6 +2369,55 @@ int regulator_is_supported_voltage(struct regulator *regulator,
2369} 2369}
2370EXPORT_SYMBOL_GPL(regulator_is_supported_voltage); 2370EXPORT_SYMBOL_GPL(regulator_is_supported_voltage);
2371 2371
2372static int _regulator_call_set_voltage(struct regulator_dev *rdev,
2373 int min_uV, int max_uV,
2374 unsigned *selector)
2375{
2376 struct pre_voltage_change_data data;
2377 int ret;
2378
2379 data.old_uV = _regulator_get_voltage(rdev);
2380 data.min_uV = min_uV;
2381 data.max_uV = max_uV;
2382 ret = _notifier_call_chain(rdev, REGULATOR_EVENT_PRE_VOLTAGE_CHANGE,
2383 &data);
2384 if (ret & NOTIFY_STOP_MASK)
2385 return -EINVAL;
2386
2387 ret = rdev->desc->ops->set_voltage(rdev, min_uV, max_uV, selector);
2388 if (ret >= 0)
2389 return ret;
2390
2391 _notifier_call_chain(rdev, REGULATOR_EVENT_ABORT_VOLTAGE_CHANGE,
2392 (void *)data.old_uV);
2393
2394 return ret;
2395}
2396
2397static int _regulator_call_set_voltage_sel(struct regulator_dev *rdev,
2398 int uV, unsigned selector)
2399{
2400 struct pre_voltage_change_data data;
2401 int ret;
2402
2403 data.old_uV = _regulator_get_voltage(rdev);
2404 data.min_uV = uV;
2405 data.max_uV = uV;
2406 ret = _notifier_call_chain(rdev, REGULATOR_EVENT_PRE_VOLTAGE_CHANGE,
2407 &data);
2408 if (ret & NOTIFY_STOP_MASK)
2409 return -EINVAL;
2410
2411 ret = rdev->desc->ops->set_voltage_sel(rdev, selector);
2412 if (ret >= 0)
2413 return ret;
2414
2415 _notifier_call_chain(rdev, REGULATOR_EVENT_ABORT_VOLTAGE_CHANGE,
2416 (void *)data.old_uV);
2417
2418 return ret;
2419}
2420
2372static int _regulator_do_set_voltage(struct regulator_dev *rdev, 2421static int _regulator_do_set_voltage(struct regulator_dev *rdev,
2373 int min_uV, int max_uV) 2422 int min_uV, int max_uV)
2374{ 2423{
@@ -2396,8 +2445,8 @@ static int _regulator_do_set_voltage(struct regulator_dev *rdev,
2396 } 2445 }
2397 2446
2398 if (rdev->desc->ops->set_voltage) { 2447 if (rdev->desc->ops->set_voltage) {
2399 ret = rdev->desc->ops->set_voltage(rdev, min_uV, max_uV, 2448 ret = _regulator_call_set_voltage(rdev, min_uV, max_uV,
2400 &selector); 2449 &selector);
2401 2450
2402 if (ret >= 0) { 2451 if (ret >= 0) {
2403 if (rdev->desc->ops->list_voltage) 2452 if (rdev->desc->ops->list_voltage)
@@ -2432,8 +2481,8 @@ static int _regulator_do_set_voltage(struct regulator_dev *rdev,
2432 if (old_selector == selector) 2481 if (old_selector == selector)
2433 ret = 0; 2482 ret = 0;
2434 else 2483 else
2435 ret = rdev->desc->ops->set_voltage_sel( 2484 ret = _regulator_call_set_voltage_sel(
2436 rdev, ret); 2485 rdev, best_val, selector);
2437 } else { 2486 } else {
2438 ret = -EINVAL; 2487 ret = -EINVAL;
2439 } 2488 }
@@ -3079,11 +3128,11 @@ EXPORT_SYMBOL_GPL(regulator_unregister_notifier);
3079/* notify regulator consumers and downstream regulator consumers. 3128/* notify regulator consumers and downstream regulator consumers.
3080 * Note mutex must be held by caller. 3129 * Note mutex must be held by caller.
3081 */ 3130 */
3082static void _notifier_call_chain(struct regulator_dev *rdev, 3131static int _notifier_call_chain(struct regulator_dev *rdev,
3083 unsigned long event, void *data) 3132 unsigned long event, void *data)
3084{ 3133{
3085 /* call rdev chain first */ 3134 /* call rdev chain first */
3086 blocking_notifier_call_chain(&rdev->notifier, event, data); 3135 return blocking_notifier_call_chain(&rdev->notifier, event, data);
3087} 3136}
3088 3137
3089/** 3138/**
diff --git a/include/linux/regulator/consumer.h b/include/linux/regulator/consumer.h
index f8a8733068a7..d347c805f923 100644
--- a/include/linux/regulator/consumer.h
+++ b/include/linux/regulator/consumer.h
@@ -93,7 +93,12 @@ struct regmap;
93 * OVER_TEMP Regulator over temp. 93 * OVER_TEMP Regulator over temp.
94 * FORCE_DISABLE Regulator forcibly shut down by software. 94 * FORCE_DISABLE Regulator forcibly shut down by software.
95 * VOLTAGE_CHANGE Regulator voltage changed. 95 * VOLTAGE_CHANGE Regulator voltage changed.
96 * Data passed is old voltage cast to (void *).
96 * DISABLE Regulator was disabled. 97 * DISABLE Regulator was disabled.
98 * PRE_VOLTAGE_CHANGE Regulator is about to have voltage changed.
99 * Data passed is "struct pre_voltage_change_data"
100 * ABORT_VOLTAGE_CHANGE Regulator voltage change failed for some reason.
101 * Data passed is old voltage cast to (void *).
97 * 102 *
98 * NOTE: These events can be OR'ed together when passed into handler. 103 * NOTE: These events can be OR'ed together when passed into handler.
99 */ 104 */
@@ -106,6 +111,21 @@ struct regmap;
106#define REGULATOR_EVENT_FORCE_DISABLE 0x20 111#define REGULATOR_EVENT_FORCE_DISABLE 0x20
107#define REGULATOR_EVENT_VOLTAGE_CHANGE 0x40 112#define REGULATOR_EVENT_VOLTAGE_CHANGE 0x40
108#define REGULATOR_EVENT_DISABLE 0x80 113#define REGULATOR_EVENT_DISABLE 0x80
114#define REGULATOR_EVENT_PRE_VOLTAGE_CHANGE 0x100
115#define REGULATOR_EVENT_ABORT_VOLTAGE_CHANGE 0x200
116
117/**
118 * struct pre_voltage_change_data - Data sent with PRE_VOLTAGE_CHANGE event
119 *
120 * @old_uV: Current voltage before change.
121 * @min_uV: Min voltage we'll change to.
122 * @max_uV: Max voltage we'll change to.
123 */
124struct pre_voltage_change_data {
125 unsigned long old_uV;
126 unsigned long min_uV;
127 unsigned long max_uV;
128};
109 129
110struct regulator; 130struct regulator;
111 131