aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Brown <broonie@linaro.org>2013-09-01 08:50:04 -0400
committerMark Brown <broonie@linaro.org>2013-09-01 08:50:04 -0400
commit28c37c9ce824c46db5891f6230c90bd0334f2cce (patch)
tree0098c1f4a2021a0deb512282a8c9b11cbabcc9d0
parentd8dfad3876e4386666b759da3c833d62fb8b2267 (diff)
parent720c027303b91ea7320dc9da51b502633c9fece4 (diff)
Merge remote-tracking branch 'regulator/topic/88pm800' into regulator-next
-rw-r--r--Documentation/devicetree/bindings/regulator/88pm800.txt38
-rw-r--r--drivers/regulator/88pm800.c383
-rw-r--r--drivers/regulator/Kconfig254
-rw-r--r--drivers/regulator/Makefile3
-rw-r--r--drivers/regulator/core.c95
-rw-r--r--drivers/regulator/wm831x-ldo.c104
-rw-r--r--drivers/regulator/wm8350-regulator.c55
-rw-r--r--drivers/regulator/wm8400-regulator.c50
-rw-r--r--include/linux/regulator/driver.h25
9 files changed, 732 insertions, 275 deletions
diff --git a/Documentation/devicetree/bindings/regulator/88pm800.txt b/Documentation/devicetree/bindings/regulator/88pm800.txt
new file mode 100644
index 000000000000..e8a54c2a5821
--- /dev/null
+++ b/Documentation/devicetree/bindings/regulator/88pm800.txt
@@ -0,0 +1,38 @@
1Marvell 88PM800 regulator
2
3Required properties:
4- compatible: "marvell,88pm800"
5- reg: I2C slave address
6- regulators: A node that houses a sub-node for each regulator within the
7 device. Each sub-node is identified using the node's name (or the deprecated
8 regulator-compatible property if present), with valid values listed below.
9 The content of each sub-node is defined by the standard binding for
10 regulators; see regulator.txt.
11
12The valid names for regulators are:
13
14 buck1, buck2, buck3, buck4, buck5, ldo1, ldo2, ldo3, ldo4, ldo5, ldo6, ldo7,
15 ldo8, ldo9, ldo10, ldo11, ldo12, ldo13, ldo14, ldo15, ldo16, ldo17, ldo18, ldo19
16
17Example:
18
19 pmic: 88pm800@31 {
20 compatible = "marvell,88pm800";
21 reg = <0x31>;
22
23 regulators {
24 buck1 {
25 regulator-min-microvolt = <600000>;
26 regulator-max-microvolt = <3950000>;
27 regulator-boot-on;
28 regulator-always-on;
29 };
30 ldo1 {
31 regulator-min-microvolt = <600000>;
32 regulator-max-microvolt = <15000000>;
33 regulator-boot-on;
34 regulator-always-on;
35 };
36...
37 };
38 };
diff --git a/drivers/regulator/88pm800.c b/drivers/regulator/88pm800.c
new file mode 100644
index 000000000000..b30f5ce659d1
--- /dev/null
+++ b/drivers/regulator/88pm800.c
@@ -0,0 +1,383 @@
1/*
2 * Regulators driver for Marvell 88PM800
3 *
4 * Copyright (C) 2012 Marvell International Ltd.
5 * Joseph(Yossi) Hanin <yhanin@marvell.com>
6 * Yi Zhang <yizhang@marvell.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12#include <linux/module.h>
13#include <linux/moduleparam.h>
14#include <linux/init.h>
15#include <linux/err.h>
16#include <linux/regmap.h>
17#include <linux/regulator/driver.h>
18#include <linux/regulator/machine.h>
19#include <linux/mfd/88pm80x.h>
20#include <linux/delay.h>
21#include <linux/io.h>
22#include <linux/of.h>
23#include <linux/regulator/of_regulator.h>
24
25/* LDO1 with DVC[0..3] */
26#define PM800_LDO1_VOUT (0x08) /* VOUT1 */
27#define PM800_LDO1_VOUT_2 (0x09)
28#define PM800_LDO1_VOUT_3 (0x0A)
29#define PM800_LDO2_VOUT (0x0B)
30#define PM800_LDO3_VOUT (0x0C)
31#define PM800_LDO4_VOUT (0x0D)
32#define PM800_LDO5_VOUT (0x0E)
33#define PM800_LDO6_VOUT (0x0F)
34#define PM800_LDO7_VOUT (0x10)
35#define PM800_LDO8_VOUT (0x11)
36#define PM800_LDO9_VOUT (0x12)
37#define PM800_LDO10_VOUT (0x13)
38#define PM800_LDO11_VOUT (0x14)
39#define PM800_LDO12_VOUT (0x15)
40#define PM800_LDO13_VOUT (0x16)
41#define PM800_LDO14_VOUT (0x17)
42#define PM800_LDO15_VOUT (0x18)
43#define PM800_LDO16_VOUT (0x19)
44#define PM800_LDO17_VOUT (0x1A)
45#define PM800_LDO18_VOUT (0x1B)
46#define PM800_LDO19_VOUT (0x1C)
47
48/* BUCK1 with DVC[0..3] */
49#define PM800_BUCK1 (0x3C)
50#define PM800_BUCK1_1 (0x3D)
51#define PM800_BUCK1_2 (0x3E)
52#define PM800_BUCK1_3 (0x3F)
53#define PM800_BUCK2 (0x40)
54#define PM800_BUCK3 (0x41)
55#define PM800_BUCK3 (0x41)
56#define PM800_BUCK4 (0x42)
57#define PM800_BUCK4_1 (0x43)
58#define PM800_BUCK4_2 (0x44)
59#define PM800_BUCK4_3 (0x45)
60#define PM800_BUCK5 (0x46)
61
62#define PM800_BUCK_ENA (0x50)
63#define PM800_LDO_ENA1_1 (0x51)
64#define PM800_LDO_ENA1_2 (0x52)
65#define PM800_LDO_ENA1_3 (0x53)
66
67#define PM800_LDO_ENA2_1 (0x56)
68#define PM800_LDO_ENA2_2 (0x57)
69#define PM800_LDO_ENA2_3 (0x58)
70
71#define PM800_BUCK1_MISC1 (0x78)
72#define PM800_BUCK3_MISC1 (0x7E)
73#define PM800_BUCK4_MISC1 (0x81)
74#define PM800_BUCK5_MISC1 (0x84)
75
76struct pm800_regulator_info {
77 struct regulator_desc desc;
78 int max_ua;
79};
80
81struct pm800_regulators {
82 struct regulator_dev *regulators[PM800_ID_RG_MAX];
83 struct pm80x_chip *chip;
84 struct regmap *map;
85};
86
87/*
88 * vreg - the buck regs string.
89 * ereg - the string for the enable register.
90 * ebit - the bit number in the enable register.
91 * amax - the current
92 * Buck has 2 kinds of voltage steps. It is easy to find voltage by ranges,
93 * not the constant voltage table.
94 * n_volt - Number of available selectors
95 */
96#define PM800_BUCK(vreg, ereg, ebit, amax, volt_ranges, n_volt) \
97{ \
98 .desc = { \
99 .name = #vreg, \
100 .ops = &pm800_volt_range_ops, \
101 .type = REGULATOR_VOLTAGE, \
102 .id = PM800_ID_##vreg, \
103 .owner = THIS_MODULE, \
104 .n_voltages = n_volt, \
105 .linear_ranges = volt_ranges, \
106 .n_linear_ranges = ARRAY_SIZE(volt_ranges), \
107 .vsel_reg = PM800_##vreg, \
108 .vsel_mask = 0x7f, \
109 .enable_reg = PM800_##ereg, \
110 .enable_mask = 1 << (ebit), \
111 }, \
112 .max_ua = (amax), \
113}
114
115/*
116 * vreg - the LDO regs string
117 * ereg - the string for the enable register.
118 * ebit - the bit number in the enable register.
119 * amax - the current
120 * volt_table - the LDO voltage table
121 * For all the LDOes, there are too many ranges. Using volt_table will be
122 * simpler and faster.
123 */
124#define PM800_LDO(vreg, ereg, ebit, amax, ldo_volt_table) \
125{ \
126 .desc = { \
127 .name = #vreg, \
128 .ops = &pm800_volt_table_ops, \
129 .type = REGULATOR_VOLTAGE, \
130 .id = PM800_ID_##vreg, \
131 .owner = THIS_MODULE, \
132 .n_voltages = ARRAY_SIZE(ldo_volt_table), \
133 .vsel_reg = PM800_##vreg##_VOUT, \
134 .vsel_mask = 0x1f, \
135 .enable_reg = PM800_##ereg, \
136 .enable_mask = 1 << (ebit), \
137 .volt_table = ldo_volt_table, \
138 }, \
139 .max_ua = (amax), \
140}
141
142/* Ranges are sorted in ascending order. */
143static const struct regulator_linear_range buck1_volt_range[] = {
144 { .min_uV = 600000, .max_uV = 1587500, .min_sel = 0, .max_sel = 0x4f,
145 .uV_step = 12500 },
146 { .min_uV = 1600000, .max_uV = 1800000, .min_sel = 0x50,
147 .max_sel = 0x54, .uV_step = 50000 },
148};
149
150/* BUCK 2~5 have same ranges. */
151static const struct regulator_linear_range buck2_5_volt_range[] = {
152 { .min_uV = 600000, .max_uV = 1587500, .min_sel = 0, .max_sel = 0x4f,
153 .uV_step = 12500 },
154 { .min_uV = 1600000, .max_uV = 3300000, .min_sel = 0x50,
155 .max_sel = 0x72, .uV_step = 50000 },
156};
157
158static const unsigned int ldo1_volt_table[] = {
159 600000, 650000, 700000, 750000, 800000, 850000, 900000, 950000,
160 1000000, 1050000, 1100000, 1150000, 1200000, 1300000, 1400000, 1500000,
161};
162
163static const unsigned int ldo2_volt_table[] = {
164 1700000, 1800000, 1900000, 2000000, 2100000, 2500000, 2700000, 2800000,
165};
166
167/* LDO 3~17 have same voltage table. */
168static const unsigned int ldo3_17_volt_table[] = {
169 1200000, 1250000, 1700000, 1800000, 1850000, 1900000, 2500000, 2600000,
170 2700000, 2750000, 2800000, 2850000, 2900000, 3000000, 3100000, 3300000,
171};
172
173/* LDO 18~19 have same voltage table. */
174static const unsigned int ldo18_19_volt_table[] = {
175 1700000, 1800000, 1900000, 2500000, 2800000, 2900000, 3100000, 3300000,
176};
177
178static int pm800_get_current_limit(struct regulator_dev *rdev)
179{
180 struct pm800_regulator_info *info = rdev_get_drvdata(rdev);
181
182 return info->max_ua;
183}
184
185static struct regulator_ops pm800_volt_range_ops = {
186 .list_voltage = regulator_list_voltage_linear_range,
187 .map_voltage = regulator_map_voltage_linear_range,
188 .set_voltage_sel = regulator_set_voltage_sel_regmap,
189 .get_voltage_sel = regulator_get_voltage_sel_regmap,
190 .enable = regulator_enable_regmap,
191 .disable = regulator_disable_regmap,
192 .is_enabled = regulator_is_enabled_regmap,
193 .get_current_limit = pm800_get_current_limit,
194};
195
196static struct regulator_ops pm800_volt_table_ops = {
197 .list_voltage = regulator_list_voltage_table,
198 .map_voltage = regulator_map_voltage_iterate,
199 .set_voltage_sel = regulator_set_voltage_sel_regmap,
200 .get_voltage_sel = regulator_get_voltage_sel_regmap,
201 .enable = regulator_enable_regmap,
202 .disable = regulator_disable_regmap,
203 .is_enabled = regulator_is_enabled_regmap,
204 .get_current_limit = pm800_get_current_limit,
205};
206
207/* The array is indexed by id(PM800_ID_XXX) */
208static struct pm800_regulator_info pm800_regulator_info[] = {
209 PM800_BUCK(BUCK1, BUCK_ENA, 0, 3000000, buck1_volt_range, 0x55),
210 PM800_BUCK(BUCK2, BUCK_ENA, 1, 1200000, buck2_5_volt_range, 0x73),
211 PM800_BUCK(BUCK3, BUCK_ENA, 2, 1200000, buck2_5_volt_range, 0x73),
212 PM800_BUCK(BUCK4, BUCK_ENA, 3, 1200000, buck2_5_volt_range, 0x73),
213 PM800_BUCK(BUCK5, BUCK_ENA, 4, 1200000, buck2_5_volt_range, 0x73),
214
215 PM800_LDO(LDO1, LDO_ENA1_1, 0, 200000, ldo1_volt_table),
216 PM800_LDO(LDO2, LDO_ENA1_1, 1, 10000, ldo2_volt_table),
217 PM800_LDO(LDO3, LDO_ENA1_1, 2, 300000, ldo3_17_volt_table),
218 PM800_LDO(LDO4, LDO_ENA1_1, 3, 300000, ldo3_17_volt_table),
219 PM800_LDO(LDO5, LDO_ENA1_1, 4, 300000, ldo3_17_volt_table),
220 PM800_LDO(LDO6, LDO_ENA1_1, 5, 300000, ldo3_17_volt_table),
221 PM800_LDO(LDO7, LDO_ENA1_1, 6, 300000, ldo3_17_volt_table),
222 PM800_LDO(LDO8, LDO_ENA1_1, 7, 300000, ldo3_17_volt_table),
223 PM800_LDO(LDO9, LDO_ENA1_2, 0, 300000, ldo3_17_volt_table),
224 PM800_LDO(LDO10, LDO_ENA1_2, 1, 300000, ldo3_17_volt_table),
225 PM800_LDO(LDO11, LDO_ENA1_2, 2, 300000, ldo3_17_volt_table),
226 PM800_LDO(LDO12, LDO_ENA1_2, 3, 300000, ldo3_17_volt_table),
227 PM800_LDO(LDO13, LDO_ENA1_2, 4, 300000, ldo3_17_volt_table),
228 PM800_LDO(LDO14, LDO_ENA1_2, 5, 300000, ldo3_17_volt_table),
229 PM800_LDO(LDO15, LDO_ENA1_2, 6, 300000, ldo3_17_volt_table),
230 PM800_LDO(LDO16, LDO_ENA1_2, 7, 300000, ldo3_17_volt_table),
231 PM800_LDO(LDO17, LDO_ENA1_3, 0, 300000, ldo3_17_volt_table),
232 PM800_LDO(LDO18, LDO_ENA1_3, 1, 200000, ldo18_19_volt_table),
233 PM800_LDO(LDO19, LDO_ENA1_3, 2, 200000, ldo18_19_volt_table),
234};
235
236#define PM800_REGULATOR_OF_MATCH(_name, _id) \
237 [PM800_ID_##_id] = { \
238 .name = #_name, \
239 .driver_data = &pm800_regulator_info[PM800_ID_##_id], \
240 }
241
242static struct of_regulator_match pm800_regulator_matches[] = {
243 PM800_REGULATOR_OF_MATCH(buck1, BUCK1),
244 PM800_REGULATOR_OF_MATCH(buck2, BUCK2),
245 PM800_REGULATOR_OF_MATCH(buck3, BUCK3),
246 PM800_REGULATOR_OF_MATCH(buck4, BUCK4),
247 PM800_REGULATOR_OF_MATCH(buck5, BUCK5),
248 PM800_REGULATOR_OF_MATCH(ldo1, LDO1),
249 PM800_REGULATOR_OF_MATCH(ldo2, LDO2),
250 PM800_REGULATOR_OF_MATCH(ldo3, LDO3),
251 PM800_REGULATOR_OF_MATCH(ldo4, LDO4),
252 PM800_REGULATOR_OF_MATCH(ldo5, LDO5),
253 PM800_REGULATOR_OF_MATCH(ldo6, LDO6),
254 PM800_REGULATOR_OF_MATCH(ldo7, LDO7),
255 PM800_REGULATOR_OF_MATCH(ldo8, LDO8),
256 PM800_REGULATOR_OF_MATCH(ldo9, LDO9),
257 PM800_REGULATOR_OF_MATCH(ldo10, LDO10),
258 PM800_REGULATOR_OF_MATCH(ldo11, LDO11),
259 PM800_REGULATOR_OF_MATCH(ldo12, LDO12),
260 PM800_REGULATOR_OF_MATCH(ldo13, LDO13),
261 PM800_REGULATOR_OF_MATCH(ldo14, LDO14),
262 PM800_REGULATOR_OF_MATCH(ldo15, LDO15),
263 PM800_REGULATOR_OF_MATCH(ldo16, LDO16),
264 PM800_REGULATOR_OF_MATCH(ldo17, LDO17),
265 PM800_REGULATOR_OF_MATCH(ldo18, LDO18),
266 PM800_REGULATOR_OF_MATCH(ldo19, LDO19),
267};
268
269static int pm800_regulator_dt_init(struct platform_device *pdev)
270{
271 struct device_node *np = pdev->dev.of_node;
272 int ret;
273
274 ret = of_regulator_match(&pdev->dev, np,
275 pm800_regulator_matches,
276 ARRAY_SIZE(pm800_regulator_matches));
277 if (ret < 0)
278 return ret;
279
280 return 0;
281}
282
283static int pm800_regulator_probe(struct platform_device *pdev)
284{
285 struct pm80x_chip *chip = dev_get_drvdata(pdev->dev.parent);
286 struct pm80x_platform_data *pdata = pdev->dev.parent->platform_data;
287 struct pm800_regulators *pm800_data;
288 struct pm800_regulator_info *info;
289 struct regulator_config config = { };
290 struct regulator_init_data *init_data;
291 int i, ret;
292
293 if (!pdata || pdata->num_regulators == 0) {
294 if (IS_ENABLED(CONFIG_OF)) {
295 ret = pm800_regulator_dt_init(pdev);
296 if (ret)
297 return ret;
298 } else {
299 return -ENODEV;
300 }
301 } else if (pdata->num_regulators) {
302 unsigned int count = 0;
303
304 /* Check whether num_regulator is valid. */
305 for (i = 0; i < ARRAY_SIZE(pdata->regulators); i++) {
306 if (pdata->regulators[i])
307 count++;
308 }
309 if (count != pdata->num_regulators)
310 return -EINVAL;
311 } else {
312 return -EINVAL;
313 }
314
315 pm800_data = devm_kzalloc(&pdev->dev, sizeof(*pm800_data),
316 GFP_KERNEL);
317 if (!pm800_data) {
318 dev_err(&pdev->dev, "Failed to allocate pm800_regualtors");
319 return -ENOMEM;
320 }
321
322 pm800_data->map = chip->subchip->regmap_power;
323 pm800_data->chip = chip;
324
325 platform_set_drvdata(pdev, pm800_data);
326
327 for (i = 0; i < PM800_ID_RG_MAX; i++) {
328 if (!pdata || pdata->num_regulators == 0)
329 init_data = pm800_regulator_matches[i].init_data;
330 else
331 init_data = pdata->regulators[i];
332 if (!init_data)
333 continue;
334 info = pm800_regulator_matches[i].driver_data;
335 config.dev = &pdev->dev;
336 config.init_data = init_data;
337 config.driver_data = info;
338 config.regmap = pm800_data->map;
339 config.of_node = pm800_regulator_matches[i].of_node;
340
341 pm800_data->regulators[i] =
342 regulator_register(&info->desc, &config);
343 if (IS_ERR(pm800_data->regulators[i])) {
344 ret = PTR_ERR(pm800_data->regulators[i]);
345 dev_err(&pdev->dev, "Failed to register %s\n",
346 info->desc.name);
347
348 while (--i >= 0)
349 regulator_unregister(pm800_data->regulators[i]);
350
351 return ret;
352 }
353 }
354
355 return 0;
356}
357
358static int pm800_regulator_remove(struct platform_device *pdev)
359{
360 struct pm800_regulators *pm800_data = platform_get_drvdata(pdev);
361 int i;
362
363 for (i = 0; i < PM800_ID_RG_MAX; i++)
364 regulator_unregister(pm800_data->regulators[i]);
365
366 return 0;
367}
368
369static struct platform_driver pm800_regulator_driver = {
370 .driver = {
371 .name = "88pm80x-regulator",
372 .owner = THIS_MODULE,
373 },
374 .probe = pm800_regulator_probe,
375 .remove = pm800_regulator_remove,
376};
377
378module_platform_driver(pm800_regulator_driver);
379
380MODULE_LICENSE("GPL");
381MODULE_AUTHOR("Joseph(Yossi) Hanin <yhanin@marvell.com>");
382MODULE_DESCRIPTION("Regulator Driver for Marvell 88PM800 PMIC");
383MODULE_ALIAS("platform:88pm800-regulator");
diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index f1e6ad98eeba..b05fa9009e82 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -64,15 +64,21 @@ config REGULATOR_USERSPACE_CONSUMER
64 64
65 If unsure, say no. 65 If unsure, say no.
66 66
67config REGULATOR_GPIO 67config REGULATOR_88PM800
68 tristate "GPIO regulator support" 68 tristate "Marvell 88PM800 Power regulators"
69 depends on GPIOLIB 69 depends on MFD_88PM800
70 help 70 help
71 This driver provides support for regulators that can be 71 This driver supports Marvell 88PM800 voltage regulator chips.
72 controlled via gpios. 72 It delivers digitally programmable output,
73 It is capable of supporting current and voltage regulators 73 the voltage is programmed via I2C interface.
74 and the platform has to provide a mapping of GPIO-states 74 It's suitable to support PXA988 chips to control VCC_MAIN and
75 to target volts/amps. 75 various voltages.
76
77config REGULATOR_88PM8607
78 bool "Marvell 88PM8607 Power regulators"
79 depends on MFD_88PM860X=y
80 help
81 This driver supports 88PM8607 voltage regulator chips.
76 82
77config REGULATOR_AD5398 83config REGULATOR_AD5398
78 tristate "Analog Devices AD5398/AD5821 regulators" 84 tristate "Analog Devices AD5398/AD5821 regulators"
@@ -81,6 +87,14 @@ config REGULATOR_AD5398
81 This driver supports AD5398 and AD5821 current regulator chips. 87 This driver supports AD5398 and AD5821 current regulator chips.
82 If building into module, its name is ad5398.ko. 88 If building into module, its name is ad5398.ko.
83 89
90config REGULATOR_ANATOP
91 tristate "Freescale i.MX on-chip ANATOP LDO regulators"
92 depends on MFD_SYSCON
93 help
94 Say y here to support Freescale i.MX on-chip ANATOP LDOs
95 regulators. It is recommended that this option be
96 enabled on i.MX6 platform.
97
84config REGULATOR_AAT2870 98config REGULATOR_AAT2870
85 tristate "AnalogicTech AAT2870 Regulators" 99 tristate "AnalogicTech AAT2870 Regulators"
86 depends on MFD_AAT2870_CORE 100 depends on MFD_AAT2870_CORE
@@ -88,6 +102,22 @@ config REGULATOR_AAT2870
88 If you have a AnalogicTech AAT2870 say Y to enable the 102 If you have a AnalogicTech AAT2870 say Y to enable the
89 regulator driver. 103 regulator driver.
90 104
105config REGULATOR_AB3100
106 tristate "ST-Ericsson AB3100 Regulator functions"
107 depends on AB3100_CORE
108 default y if AB3100_CORE
109 help
110 These regulators correspond to functionality in the
111 AB3100 analog baseband dealing with power regulators
112 for the system.
113
114config REGULATOR_AB8500
115 bool "ST-Ericsson AB8500 Power Regulators"
116 depends on AB8500_CORE
117 help
118 This driver supports the regulators found on the ST-Ericsson mixed
119 signal AB8500 PMIC
120
91config REGULATOR_ARIZONA 121config REGULATOR_ARIZONA
92 tristate "Wolfson Arizona class devices" 122 tristate "Wolfson Arizona class devices"
93 depends on MFD_ARIZONA 123 depends on MFD_ARIZONA
@@ -96,6 +126,13 @@ config REGULATOR_ARIZONA
96 Support for the regulators found on Wolfson Arizona class 126 Support for the regulators found on Wolfson Arizona class
97 devices. 127 devices.
98 128
129config REGULATOR_AS3711
130 tristate "AS3711 PMIC"
131 depends on MFD_AS3711
132 help
133 This driver provides support for the voltage regulators on the
134 AS3711 PMIC
135
99config REGULATOR_DA903X 136config REGULATOR_DA903X
100 tristate "Dialog Semiconductor DA9030/DA9034 regulators" 137 tristate "Dialog Semiconductor DA9030/DA9034 regulators"
101 depends on PMIC_DA903X 138 depends on PMIC_DA903X
@@ -120,6 +157,17 @@ config REGULATOR_DA9055
120 This driver can also be built as a module. If so, the module 157 This driver can also be built as a module. If so, the module
121 will be called da9055-regulator. 158 will be called da9055-regulator.
122 159
160config REGULATOR_DBX500_PRCMU
161 bool
162
163config REGULATOR_DB8500_PRCMU
164 bool "ST-Ericsson DB8500 Voltage Domain Regulators"
165 depends on MFD_DB8500_PRCMU
166 select REGULATOR_DBX500_PRCMU
167 help
168 This driver supports the voltage domain regulators controlled by the
169 DB8500 PRCMU
170
123config REGULATOR_FAN53555 171config REGULATOR_FAN53555
124 tristate "Fairchild FAN53555 Regulator" 172 tristate "Fairchild FAN53555 Regulator"
125 depends on I2C 173 depends on I2C
@@ -131,44 +179,57 @@ config REGULATOR_FAN53555
131 input voltage supply of 2.5V to 5.5V. The output voltage is 179 input voltage supply of 2.5V to 5.5V. The output voltage is
132 programmed through an I2C interface. 180 programmed through an I2C interface.
133 181
134config REGULATOR_ANATOP 182config REGULATOR_GPIO
135 tristate "Freescale i.MX on-chip ANATOP LDO regulators" 183 tristate "GPIO regulator support"
136 depends on MFD_SYSCON 184 depends on GPIOLIB
137 help 185 help
138 Say y here to support Freescale i.MX on-chip ANATOP LDOs 186 This driver provides support for regulators that can be
139 regulators. It is recommended that this option be 187 controlled via gpios.
140 enabled on i.MX6 platform. 188 It is capable of supporting current and voltage regulators
189 and the platform has to provide a mapping of GPIO-states
190 to target volts/amps.
141 191
142config REGULATOR_MC13XXX_CORE 192config REGULATOR_ISL6271A
143 tristate 193 tristate "Intersil ISL6271A Power regulator"
194 depends on I2C
195 help
196 This driver supports ISL6271A voltage regulator chip.
144 197
145config REGULATOR_MC13783 198config REGULATOR_LP3971
146 tristate "Freescale MC13783 regulator driver" 199 tristate "National Semiconductors LP3971 PMIC regulator driver"
147 depends on MFD_MC13783 200 depends on I2C
148 select REGULATOR_MC13XXX_CORE
149 help 201 help
150 Say y here to support the regulators found on the Freescale MC13783 202 Say Y here to support the voltage regulators and convertors
151 PMIC. 203 on National Semiconductors LP3971 PMIC
152 204
153config REGULATOR_MC13892 205config REGULATOR_LP3972
154 tristate "Freescale MC13892 regulator driver" 206 tristate "National Semiconductors LP3972 PMIC regulator driver"
155 depends on MFD_MC13XXX 207 depends on I2C
156 select REGULATOR_MC13XXX_CORE
157 help 208 help
158 Say y here to support the regulators found on the Freescale MC13892 209 Say Y here to support the voltage regulators and convertors
159 PMIC. 210 on National Semiconductors LP3972 PMIC
160 211
161config REGULATOR_ISL6271A 212config REGULATOR_LP872X
162 tristate "Intersil ISL6271A Power regulator" 213 bool "TI/National Semiconductor LP8720/LP8725 voltage regulators"
214 depends on I2C=y
215 select REGMAP_I2C
216 help
217 This driver supports LP8720/LP8725 PMIC
218
219config REGULATOR_LP8755
220 tristate "TI LP8755 High Performance PMU driver"
163 depends on I2C 221 depends on I2C
222 select REGMAP_I2C
164 help 223 help
165 This driver supports ISL6271A voltage regulator chip. 224 This driver supports LP8755 High Performance PMU driver. This
225 chip contains six step-down DC/DC converters which can support
226 9 mode multiphase configuration.
166 227
167config REGULATOR_88PM8607 228config REGULATOR_LP8788
168 bool "Marvell 88PM8607 Power regulators" 229 bool "TI LP8788 Power Regulators"
169 depends on MFD_88PM860X=y 230 depends on MFD_LP8788
170 help 231 help
171 This driver supports 88PM8607 voltage regulator chips. 232 This driver supports LP8788 voltage regulator chip.
172 233
173config REGULATOR_MAX1586 234config REGULATOR_MAX1586
174 tristate "Maxim 1586/1587 voltage regulator" 235 tristate "Maxim 1586/1587 voltage regulator"
@@ -259,48 +320,43 @@ config REGULATOR_MAX77693
259 and one current regulator 'CHARGER'. This is suitable for 320 and one current regulator 'CHARGER'. This is suitable for
260 Exynos-4x12 chips. 321 Exynos-4x12 chips.
261 322
262config REGULATOR_PCAP 323config REGULATOR_MC13XXX_CORE
263 tristate "Motorola PCAP2 regulator driver" 324 tristate
264 depends on EZX_PCAP
265 help
266 This driver provides support for the voltage regulators of the
267 PCAP2 PMIC.
268 325
269config REGULATOR_LP3971 326config REGULATOR_MC13783
270 tristate "National Semiconductors LP3971 PMIC regulator driver" 327 tristate "Freescale MC13783 regulator driver"
271 depends on I2C 328 depends on MFD_MC13783
329 select REGULATOR_MC13XXX_CORE
272 help 330 help
273 Say Y here to support the voltage regulators and convertors 331 Say y here to support the regulators found on the Freescale MC13783
274 on National Semiconductors LP3971 PMIC 332 PMIC.
275 333
276config REGULATOR_LP3972 334config REGULATOR_MC13892
277 tristate "National Semiconductors LP3972 PMIC regulator driver" 335 tristate "Freescale MC13892 regulator driver"
278 depends on I2C 336 depends on MFD_MC13XXX
337 select REGULATOR_MC13XXX_CORE
279 help 338 help
280 Say Y here to support the voltage regulators and convertors 339 Say y here to support the regulators found on the Freescale MC13892
281 on National Semiconductors LP3972 PMIC 340 PMIC.
282 341
283config REGULATOR_LP872X 342config REGULATOR_PALMAS
284 bool "TI/National Semiconductor LP8720/LP8725 voltage regulators" 343 tristate "TI Palmas PMIC Regulators"
285 depends on I2C=y 344 depends on MFD_PALMAS
286 select REGMAP_I2C
287 help 345 help
288 This driver supports LP8720/LP8725 PMIC 346 If you wish to control the regulators on the Palmas series of
347 chips say Y here. This will enable support for all the software
348 controllable SMPS/LDO regulators.
289 349
290config REGULATOR_LP8755 350 The regulators available on Palmas series chips vary depending
291 tristate "TI LP8755 High Performance PMU driver" 351 on the muxing. This is handled automatically in the driver by
292 depends on I2C 352 reading the mux info from OTP.
293 select REGMAP_I2C
294 help
295 This driver supports LP8755 High Performance PMU driver. This
296 chip contains six step-down DC/DC converters which can support
297 9 mode multiphase configuration.
298 353
299config REGULATOR_LP8788 354config REGULATOR_PCAP
300 bool "TI LP8788 Power Regulators" 355 tristate "Motorola PCAP2 regulator driver"
301 depends on MFD_LP8788 356 depends on EZX_PCAP
302 help 357 help
303 This driver supports LP8788 voltage regulator chip. 358 This driver provides support for the voltage regulators of the
359 PCAP2 PMIC.
304 360
305config REGULATOR_PCF50633 361config REGULATOR_PCF50633
306 tristate "NXP PCF50633 regulator driver" 362 tristate "NXP PCF50633 regulator driver"
@@ -335,44 +391,15 @@ config REGULATOR_S5M8767
335 via I2C bus. S5M8767A have 9 Bucks and 28 LDOs output and 391 via I2C bus. S5M8767A have 9 Bucks and 28 LDOs output and
336 supports DVS mode with 8bits of output voltage control. 392 supports DVS mode with 8bits of output voltage control.
337 393
338config REGULATOR_AB3100 394config REGULATOR_TI_ABB
339 tristate "ST-Ericsson AB3100 Regulator functions" 395 bool "TI Adaptive Body Bias on-chip LDO"
340 depends on AB3100_CORE 396 depends on ARCH_OMAP
341 default y if AB3100_CORE
342 help
343 These regulators correspond to functionality in the
344 AB3100 analog baseband dealing with power regulators
345 for the system.
346
347config REGULATOR_AB8500
348 bool "ST-Ericsson AB8500 Power Regulators"
349 depends on AB8500_CORE
350 help
351 This driver supports the regulators found on the ST-Ericsson mixed
352 signal AB8500 PMIC
353
354config REGULATOR_DBX500_PRCMU
355 bool
356
357config REGULATOR_DB8500_PRCMU
358 bool "ST-Ericsson DB8500 Voltage Domain Regulators"
359 depends on MFD_DB8500_PRCMU
360 select REGULATOR_DBX500_PRCMU
361 help
362 This driver supports the voltage domain regulators controlled by the
363 DB8500 PRCMU
364
365config REGULATOR_PALMAS
366 tristate "TI Palmas PMIC Regulators"
367 depends on MFD_PALMAS
368 help 397 help
369 If you wish to control the regulators on the Palmas series of 398 Select this option to support Texas Instruments' on-chip Adaptive Body
370 chips say Y here. This will enable support for all the software 399 Bias (ABB) LDO regulators. It is recommended that this option be
371 controllable SMPS/LDO regulators. 400 enabled on required TI SoC. Certain Operating Performance Points
372 401 on TI SoCs may be unstable without enabling this as it provides
373 The regulators available on Palmas series chips vary depending 402 device specific optimized bias to allow/optimize functionality.
374 on the muxing. This is handled automatically in the driver by
375 reading the mux info from OTP.
376 403
377config REGULATOR_TPS51632 404config REGULATOR_TPS51632
378 tristate "TI TPS51632 Power Regulator" 405 tristate "TI TPS51632 Power Regulator"
@@ -481,16 +508,6 @@ config REGULATOR_TWL4030
481 This driver supports the voltage regulators provided by 508 This driver supports the voltage regulators provided by
482 this family of companion chips. 509 this family of companion chips.
483 510
484config REGULATOR_TI_ABB
485 bool "TI Adaptive Body Bias on-chip LDO"
486 depends on ARCH_OMAP
487 help
488 Select this option to support Texas Instruments' on-chip Adaptive Body
489 Bias (ABB) LDO regulators. It is recommended that this option be
490 enabled on required TI SoC. Certain Operating Performance Points
491 on TI SoCs may be unstable without enabling this as it provides
492 device specific optimized bias to allow/optimize functionality.
493
494config REGULATOR_VEXPRESS 511config REGULATOR_VEXPRESS
495 tristate "Versatile Express regulators" 512 tristate "Versatile Express regulators"
496 depends on VEXPRESS_CONFIG 513 depends on VEXPRESS_CONFIG
@@ -526,12 +543,5 @@ config REGULATOR_WM8994
526 This driver provides support for the voltage regulators on the 543 This driver provides support for the voltage regulators on the
527 WM8994 CODEC. 544 WM8994 CODEC.
528 545
529config REGULATOR_AS3711
530 tristate "AS3711 PMIC"
531 depends on MFD_AS3711
532 help
533 This driver provides support for the voltage regulators on the
534 AS3711 PMIC
535
536endif 546endif
537 547
diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile
index ba4a3cf3afec..e292f26a1fbd 100644
--- a/drivers/regulator/Makefile
+++ b/drivers/regulator/Makefile
@@ -9,6 +9,7 @@ obj-$(CONFIG_REGULATOR_FIXED_VOLTAGE) += fixed.o
9obj-$(CONFIG_REGULATOR_VIRTUAL_CONSUMER) += virtual.o 9obj-$(CONFIG_REGULATOR_VIRTUAL_CONSUMER) += virtual.o
10obj-$(CONFIG_REGULATOR_USERSPACE_CONSUMER) += userspace-consumer.o 10obj-$(CONFIG_REGULATOR_USERSPACE_CONSUMER) += userspace-consumer.o
11 11
12obj-$(CONFIG_REGULATOR_88PM800) += 88pm800.o
12obj-$(CONFIG_REGULATOR_88PM8607) += 88pm8607.o 13obj-$(CONFIG_REGULATOR_88PM8607) += 88pm8607.o
13obj-$(CONFIG_REGULATOR_AAT2870) += aat2870-regulator.o 14obj-$(CONFIG_REGULATOR_AAT2870) += aat2870-regulator.o
14obj-$(CONFIG_REGULATOR_AB3100) += ab3100.o 15obj-$(CONFIG_REGULATOR_AB3100) += ab3100.o
@@ -52,6 +53,7 @@ obj-$(CONFIG_REGULATOR_PCF50633) += pcf50633-regulator.o
52obj-$(CONFIG_REGULATOR_RC5T583) += rc5t583-regulator.o 53obj-$(CONFIG_REGULATOR_RC5T583) += rc5t583-regulator.o
53obj-$(CONFIG_REGULATOR_S2MPS11) += s2mps11.o 54obj-$(CONFIG_REGULATOR_S2MPS11) += s2mps11.o
54obj-$(CONFIG_REGULATOR_S5M8767) += s5m8767.o 55obj-$(CONFIG_REGULATOR_S5M8767) += s5m8767.o
56obj-$(CONFIG_REGULATOR_TI_ABB) += ti-abb-regulator.o
55obj-$(CONFIG_REGULATOR_TPS6105X) += tps6105x-regulator.o 57obj-$(CONFIG_REGULATOR_TPS6105X) += tps6105x-regulator.o
56obj-$(CONFIG_REGULATOR_TPS62360) += tps62360-regulator.o 58obj-$(CONFIG_REGULATOR_TPS62360) += tps62360-regulator.o
57obj-$(CONFIG_REGULATOR_TPS65023) += tps65023-regulator.o 59obj-$(CONFIG_REGULATOR_TPS65023) += tps65023-regulator.o
@@ -64,7 +66,6 @@ obj-$(CONFIG_REGULATOR_TPS65910) += tps65910-regulator.o
64obj-$(CONFIG_REGULATOR_TPS65912) += tps65912-regulator.o 66obj-$(CONFIG_REGULATOR_TPS65912) += tps65912-regulator.o
65obj-$(CONFIG_REGULATOR_TPS80031) += tps80031-regulator.o 67obj-$(CONFIG_REGULATOR_TPS80031) += tps80031-regulator.o
66obj-$(CONFIG_REGULATOR_TWL4030) += twl-regulator.o 68obj-$(CONFIG_REGULATOR_TWL4030) += twl-regulator.o
67obj-$(CONFIG_REGULATOR_TI_ABB) += ti-abb-regulator.o
68obj-$(CONFIG_REGULATOR_VEXPRESS) += vexpress.o 69obj-$(CONFIG_REGULATOR_VEXPRESS) += vexpress.o
69obj-$(CONFIG_REGULATOR_WM831X) += wm831x-dcdc.o 70obj-$(CONFIG_REGULATOR_WM831X) += wm831x-dcdc.o
70obj-$(CONFIG_REGULATOR_WM831X) += wm831x-isink.o 71obj-$(CONFIG_REGULATOR_WM831X) += wm831x-isink.o
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 288c75abc190..42ae134797e0 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -2079,6 +2079,43 @@ int regulator_list_voltage_linear(struct regulator_dev *rdev,
2079EXPORT_SYMBOL_GPL(regulator_list_voltage_linear); 2079EXPORT_SYMBOL_GPL(regulator_list_voltage_linear);
2080 2080
2081/** 2081/**
2082 * regulator_list_voltage_linear_range - List voltages for linear ranges
2083 *
2084 * @rdev: Regulator device
2085 * @selector: Selector to convert into a voltage
2086 *
2087 * Regulators with a series of simple linear mappings between voltages
2088 * and selectors can set linear_ranges in the regulator descriptor and
2089 * then use this function as their list_voltage() operation,
2090 */
2091int regulator_list_voltage_linear_range(struct regulator_dev *rdev,
2092 unsigned int selector)
2093{
2094 const struct regulator_linear_range *range;
2095 int i;
2096
2097 if (!rdev->desc->n_linear_ranges) {
2098 BUG_ON(!rdev->desc->n_linear_ranges);
2099 return -EINVAL;
2100 }
2101
2102 for (i = 0; i < rdev->desc->n_linear_ranges; i++) {
2103 range = &rdev->desc->linear_ranges[i];
2104
2105 if (!(selector >= range->min_sel &&
2106 selector <= range->max_sel))
2107 continue;
2108
2109 selector -= range->min_sel;
2110
2111 return range->min_uV + (range->uV_step * selector);
2112 }
2113
2114 return -EINVAL;
2115}
2116EXPORT_SYMBOL_GPL(regulator_list_voltage_linear_range);
2117
2118/**
2082 * regulator_list_voltage_table - List voltages with table based mapping 2119 * regulator_list_voltage_table - List voltages with table based mapping
2083 * 2120 *
2084 * @rdev: Regulator device 2121 * @rdev: Regulator device
@@ -2368,6 +2405,64 @@ int regulator_map_voltage_linear(struct regulator_dev *rdev,
2368} 2405}
2369EXPORT_SYMBOL_GPL(regulator_map_voltage_linear); 2406EXPORT_SYMBOL_GPL(regulator_map_voltage_linear);
2370 2407
2408/**
2409 * regulator_map_voltage_linear - map_voltage() for multiple linear ranges
2410 *
2411 * @rdev: Regulator to operate on
2412 * @min_uV: Lower bound for voltage
2413 * @max_uV: Upper bound for voltage
2414 *
2415 * Drivers providing linear_ranges in their descriptor can use this as
2416 * their map_voltage() callback.
2417 */
2418int regulator_map_voltage_linear_range(struct regulator_dev *rdev,
2419 int min_uV, int max_uV)
2420{
2421 const struct regulator_linear_range *range;
2422 int ret = -EINVAL;
2423 int voltage, i;
2424
2425 if (!rdev->desc->n_linear_ranges) {
2426 BUG_ON(!rdev->desc->n_linear_ranges);
2427 return -EINVAL;
2428 }
2429
2430 for (i = 0; i < rdev->desc->n_linear_ranges; i++) {
2431 range = &rdev->desc->linear_ranges[i];
2432
2433 if (!(min_uV <= range->max_uV && max_uV >= range->min_uV))
2434 continue;
2435
2436 if (min_uV <= range->min_uV)
2437 min_uV = range->min_uV;
2438
2439 /* range->uV_step == 0 means fixed voltage range */
2440 if (range->uV_step == 0) {
2441 ret = 0;
2442 } else {
2443 ret = DIV_ROUND_UP(min_uV - range->min_uV,
2444 range->uV_step);
2445 if (ret < 0)
2446 return ret;
2447 }
2448
2449 ret += range->min_sel;
2450
2451 break;
2452 }
2453
2454 if (i == rdev->desc->n_linear_ranges)
2455 return -EINVAL;
2456
2457 /* Map back into a voltage to verify we're still in bounds */
2458 voltage = rdev->desc->ops->list_voltage(rdev, ret);
2459 if (voltage < min_uV || voltage > max_uV)
2460 return -EINVAL;
2461
2462 return ret;
2463}
2464EXPORT_SYMBOL_GPL(regulator_map_voltage_linear_range);
2465
2371static int _regulator_do_set_voltage(struct regulator_dev *rdev, 2466static int _regulator_do_set_voltage(struct regulator_dev *rdev,
2372 int min_uV, int max_uV) 2467 int min_uV, int max_uV)
2373{ 2468{
diff --git a/drivers/regulator/wm831x-ldo.c b/drivers/regulator/wm831x-ldo.c
index 9ff883f80878..76792c7d86f3 100644
--- a/drivers/regulator/wm831x-ldo.c
+++ b/drivers/regulator/wm831x-ldo.c
@@ -62,41 +62,12 @@ static irqreturn_t wm831x_ldo_uv_irq(int irq, void *data)
62 * General purpose LDOs 62 * General purpose LDOs
63 */ 63 */
64 64
65#define WM831X_GP_LDO_SELECTOR_LOW 0xe 65static const struct regulator_linear_range wm831x_gp_ldo_ranges[] = {
66#define WM831X_GP_LDO_MAX_SELECTOR 0x1f 66 { .min_uV = 900000, .max_uV = 1650000, .min_sel = 0, .max_sel = 14,
67 67 .uV_step = 50000 },
68static int wm831x_gp_ldo_list_voltage(struct regulator_dev *rdev, 68 { .min_uV = 1700000, .max_uV = 3300000, .min_sel = 15, .max_sel = 31,
69 unsigned int selector) 69 .uV_step = 100000 },
70{ 70};
71 /* 0.9-1.6V in 50mV steps */
72 if (selector <= WM831X_GP_LDO_SELECTOR_LOW)
73 return 900000 + (selector * 50000);
74 /* 1.7-3.3V in 100mV steps */
75 if (selector <= WM831X_GP_LDO_MAX_SELECTOR)
76 return 1600000 + ((selector - WM831X_GP_LDO_SELECTOR_LOW)
77 * 100000);
78 return -EINVAL;
79}
80
81static int wm831x_gp_ldo_map_voltage(struct regulator_dev *rdev,
82 int min_uV, int max_uV)
83{
84 int volt, vsel;
85
86 if (min_uV < 900000)
87 vsel = 0;
88 else if (min_uV < 1700000)
89 vsel = ((min_uV - 900000) / 50000);
90 else
91 vsel = ((min_uV - 1700000) / 100000)
92 + WM831X_GP_LDO_SELECTOR_LOW + 1;
93
94 volt = wm831x_gp_ldo_list_voltage(rdev, vsel);
95 if (volt < min_uV || volt > max_uV)
96 return -EINVAL;
97
98 return vsel;
99}
100 71
101static int wm831x_gp_ldo_set_suspend_voltage(struct regulator_dev *rdev, 72static int wm831x_gp_ldo_set_suspend_voltage(struct regulator_dev *rdev,
102 int uV) 73 int uV)
@@ -105,7 +76,7 @@ static int wm831x_gp_ldo_set_suspend_voltage(struct regulator_dev *rdev,
105 struct wm831x *wm831x = ldo->wm831x; 76 struct wm831x *wm831x = ldo->wm831x;
106 int sel, reg = ldo->base + WM831X_LDO_SLEEP_CONTROL; 77 int sel, reg = ldo->base + WM831X_LDO_SLEEP_CONTROL;
107 78
108 sel = wm831x_gp_ldo_map_voltage(rdev, uV, uV); 79 sel = regulator_map_voltage_linear_range(rdev, uV, uV);
109 if (sel < 0) 80 if (sel < 0)
110 return sel; 81 return sel;
111 82
@@ -230,8 +201,8 @@ static unsigned int wm831x_gp_ldo_get_optimum_mode(struct regulator_dev *rdev,
230 201
231 202
232static struct regulator_ops wm831x_gp_ldo_ops = { 203static struct regulator_ops wm831x_gp_ldo_ops = {
233 .list_voltage = wm831x_gp_ldo_list_voltage, 204 .list_voltage = regulator_list_voltage_linear_range,
234 .map_voltage = wm831x_gp_ldo_map_voltage, 205 .map_voltage = regulator_map_voltage_linear_range,
235 .get_voltage_sel = regulator_get_voltage_sel_regmap, 206 .get_voltage_sel = regulator_get_voltage_sel_regmap,
236 .set_voltage_sel = regulator_set_voltage_sel_regmap, 207 .set_voltage_sel = regulator_set_voltage_sel_regmap,
237 .set_suspend_voltage = wm831x_gp_ldo_set_suspend_voltage, 208 .set_suspend_voltage = wm831x_gp_ldo_set_suspend_voltage,
@@ -290,7 +261,7 @@ static int wm831x_gp_ldo_probe(struct platform_device *pdev)
290 261
291 ldo->desc.id = id; 262 ldo->desc.id = id;
292 ldo->desc.type = REGULATOR_VOLTAGE; 263 ldo->desc.type = REGULATOR_VOLTAGE;
293 ldo->desc.n_voltages = WM831X_GP_LDO_MAX_SELECTOR + 1; 264 ldo->desc.n_voltages = 32;
294 ldo->desc.ops = &wm831x_gp_ldo_ops; 265 ldo->desc.ops = &wm831x_gp_ldo_ops;
295 ldo->desc.owner = THIS_MODULE; 266 ldo->desc.owner = THIS_MODULE;
296 ldo->desc.vsel_reg = ldo->base + WM831X_LDO_ON_CONTROL; 267 ldo->desc.vsel_reg = ldo->base + WM831X_LDO_ON_CONTROL;
@@ -299,6 +270,8 @@ static int wm831x_gp_ldo_probe(struct platform_device *pdev)
299 ldo->desc.enable_mask = 1 << id; 270 ldo->desc.enable_mask = 1 << id;
300 ldo->desc.bypass_reg = ldo->base; 271 ldo->desc.bypass_reg = ldo->base;
301 ldo->desc.bypass_mask = WM831X_LDO1_SWI; 272 ldo->desc.bypass_mask = WM831X_LDO1_SWI;
273 ldo->desc.linear_ranges = wm831x_gp_ldo_ranges;
274 ldo->desc.n_linear_ranges = ARRAY_SIZE(wm831x_gp_ldo_ranges);
302 275
303 config.dev = pdev->dev.parent; 276 config.dev = pdev->dev.parent;
304 if (pdata) 277 if (pdata)
@@ -358,43 +331,12 @@ static struct platform_driver wm831x_gp_ldo_driver = {
358 * Analogue LDOs 331 * Analogue LDOs
359 */ 332 */
360 333
361 334static const struct regulator_linear_range wm831x_aldo_ranges[] = {
362#define WM831X_ALDO_SELECTOR_LOW 0xc 335 { .min_uV = 1000000, .max_uV = 1650000, .min_sel = 0, .max_sel = 12,
363#define WM831X_ALDO_MAX_SELECTOR 0x1f 336 .uV_step = 50000 },
364 337 { .min_uV = 1700000, .max_uV = 3500000, .min_sel = 13, .max_sel = 31,
365static int wm831x_aldo_list_voltage(struct regulator_dev *rdev, 338 .uV_step = 100000 },
366 unsigned int selector) 339};
367{
368 /* 1-1.6V in 50mV steps */
369 if (selector <= WM831X_ALDO_SELECTOR_LOW)
370 return 1000000 + (selector * 50000);
371 /* 1.7-3.5V in 100mV steps */
372 if (selector <= WM831X_ALDO_MAX_SELECTOR)
373 return 1600000 + ((selector - WM831X_ALDO_SELECTOR_LOW)
374 * 100000);
375 return -EINVAL;
376}
377
378static int wm831x_aldo_map_voltage(struct regulator_dev *rdev,
379 int min_uV, int max_uV)
380{
381 int volt, vsel;
382
383 if (min_uV < 1000000)
384 vsel = 0;
385 else if (min_uV < 1700000)
386 vsel = ((min_uV - 1000000) / 50000);
387 else
388 vsel = ((min_uV - 1700000) / 100000)
389 + WM831X_ALDO_SELECTOR_LOW + 1;
390
391 volt = wm831x_aldo_list_voltage(rdev, vsel);
392 if (volt < min_uV || volt > max_uV)
393 return -EINVAL;
394
395 return vsel;
396
397}
398 340
399static int wm831x_aldo_set_suspend_voltage(struct regulator_dev *rdev, 341static int wm831x_aldo_set_suspend_voltage(struct regulator_dev *rdev,
400 int uV) 342 int uV)
@@ -403,7 +345,7 @@ static int wm831x_aldo_set_suspend_voltage(struct regulator_dev *rdev,
403 struct wm831x *wm831x = ldo->wm831x; 345 struct wm831x *wm831x = ldo->wm831x;
404 int sel, reg = ldo->base + WM831X_LDO_SLEEP_CONTROL; 346 int sel, reg = ldo->base + WM831X_LDO_SLEEP_CONTROL;
405 347
406 sel = wm831x_aldo_map_voltage(rdev, uV, uV); 348 sel = regulator_map_voltage_linear_range(rdev, uV, uV);
407 if (sel < 0) 349 if (sel < 0)
408 return sel; 350 return sel;
409 351
@@ -486,8 +428,8 @@ static int wm831x_aldo_get_status(struct regulator_dev *rdev)
486} 428}
487 429
488static struct regulator_ops wm831x_aldo_ops = { 430static struct regulator_ops wm831x_aldo_ops = {
489 .list_voltage = wm831x_aldo_list_voltage, 431 .list_voltage = regulator_list_voltage_linear_range,
490 .map_voltage = wm831x_aldo_map_voltage, 432 .map_voltage = regulator_map_voltage_linear_range,
491 .get_voltage_sel = regulator_get_voltage_sel_regmap, 433 .get_voltage_sel = regulator_get_voltage_sel_regmap,
492 .set_voltage_sel = regulator_set_voltage_sel_regmap, 434 .set_voltage_sel = regulator_set_voltage_sel_regmap,
493 .set_suspend_voltage = wm831x_aldo_set_suspend_voltage, 435 .set_suspend_voltage = wm831x_aldo_set_suspend_voltage,
@@ -545,7 +487,9 @@ static int wm831x_aldo_probe(struct platform_device *pdev)
545 487
546 ldo->desc.id = id; 488 ldo->desc.id = id;
547 ldo->desc.type = REGULATOR_VOLTAGE; 489 ldo->desc.type = REGULATOR_VOLTAGE;
548 ldo->desc.n_voltages = WM831X_ALDO_MAX_SELECTOR + 1; 490 ldo->desc.n_voltages = 32;
491 ldo->desc.linear_ranges = wm831x_aldo_ranges;
492 ldo->desc.n_linear_ranges = ARRAY_SIZE(wm831x_aldo_ranges);
549 ldo->desc.ops = &wm831x_aldo_ops; 493 ldo->desc.ops = &wm831x_aldo_ops;
550 ldo->desc.owner = THIS_MODULE; 494 ldo->desc.owner = THIS_MODULE;
551 ldo->desc.vsel_reg = ldo->base + WM831X_LDO_ON_CONTROL; 495 ldo->desc.vsel_reg = ldo->base + WM831X_LDO_ON_CONTROL;
diff --git a/drivers/regulator/wm8350-regulator.c b/drivers/regulator/wm8350-regulator.c
index 7f0fa22ef2aa..5453dd0105ed 100644
--- a/drivers/regulator/wm8350-regulator.c
+++ b/drivers/regulator/wm8350-regulator.c
@@ -542,41 +542,12 @@ static int wm8350_dcdc_set_suspend_mode(struct regulator_dev *rdev,
542 return 0; 542 return 0;
543} 543}
544 544
545static int wm8350_ldo_list_voltage(struct regulator_dev *rdev, 545static const struct regulator_linear_range wm8350_ldo_ranges[] = {
546 unsigned selector) 546 { .min_uV = 900000, .max_uV = 1750000, .min_sel = 0, .max_sel = 15,
547{ 547 .uV_step = 50000 },
548 if (selector > WM8350_LDO1_VSEL_MASK) 548 { .min_uV = 1800000, .max_uV = 3300000, .min_sel = 16, .max_sel = 31,
549 return -EINVAL; 549 .uV_step = 100000 },
550 550};
551 if (selector < 16)
552 return (selector * 50000) + 900000;
553 else
554 return ((selector - 16) * 100000) + 1800000;
555}
556
557static int wm8350_ldo_map_voltage(struct regulator_dev *rdev, int min_uV,
558 int max_uV)
559{
560 int volt, sel;
561 int min_mV = min_uV / 1000;
562 int max_mV = max_uV / 1000;
563
564 if (min_mV < 900 || min_mV > 3300)
565 return -EINVAL;
566 if (max_mV < 900 || max_mV > 3300)
567 return -EINVAL;
568
569 if (min_mV < 1800) /* step size is 50mV < 1800mV */
570 sel = DIV_ROUND_UP(min_uV - 900, 50);
571 else /* step size is 100mV > 1800mV */
572 sel = DIV_ROUND_UP(min_uV - 1800, 100) + 16;
573
574 volt = wm8350_ldo_list_voltage(rdev, sel);
575 if (volt < min_uV || volt > max_uV)
576 return -EINVAL;
577
578 return sel;
579}
580 551
581static int wm8350_ldo_set_suspend_voltage(struct regulator_dev *rdev, int uV) 552static int wm8350_ldo_set_suspend_voltage(struct regulator_dev *rdev, int uV)
582{ 553{
@@ -603,7 +574,7 @@ static int wm8350_ldo_set_suspend_voltage(struct regulator_dev *rdev, int uV)
603 return -EINVAL; 574 return -EINVAL;
604 } 575 }
605 576
606 sel = wm8350_ldo_map_voltage(rdev, uV, uV); 577 sel = regulator_map_voltage_linear_range(rdev, uV, uV);
607 if (sel < 0) 578 if (sel < 0)
608 return -EINVAL; 579 return -EINVAL;
609 580
@@ -998,10 +969,10 @@ static struct regulator_ops wm8350_dcdc2_5_ops = {
998}; 969};
999 970
1000static struct regulator_ops wm8350_ldo_ops = { 971static struct regulator_ops wm8350_ldo_ops = {
1001 .map_voltage = wm8350_ldo_map_voltage, 972 .map_voltage = regulator_map_voltage_linear_range,
1002 .set_voltage_sel = regulator_set_voltage_sel_regmap, 973 .set_voltage_sel = regulator_set_voltage_sel_regmap,
1003 .get_voltage_sel = regulator_get_voltage_sel_regmap, 974 .get_voltage_sel = regulator_get_voltage_sel_regmap,
1004 .list_voltage = wm8350_ldo_list_voltage, 975 .list_voltage = regulator_list_voltage_linear_range,
1005 .enable = regulator_enable_regmap, 976 .enable = regulator_enable_regmap,
1006 .disable = regulator_disable_regmap, 977 .disable = regulator_disable_regmap,
1007 .is_enabled = regulator_is_enabled_regmap, 978 .is_enabled = regulator_is_enabled_regmap,
@@ -1108,6 +1079,8 @@ static const struct regulator_desc wm8350_reg[NUM_WM8350_REGULATORS] = {
1108 .irq = WM8350_IRQ_UV_LDO1, 1079 .irq = WM8350_IRQ_UV_LDO1,
1109 .type = REGULATOR_VOLTAGE, 1080 .type = REGULATOR_VOLTAGE,
1110 .n_voltages = WM8350_LDO1_VSEL_MASK + 1, 1081 .n_voltages = WM8350_LDO1_VSEL_MASK + 1,
1082 .linear_ranges = wm8350_ldo_ranges,
1083 .n_linear_ranges = ARRAY_SIZE(wm8350_ldo_ranges),
1111 .vsel_reg = WM8350_LDO1_CONTROL, 1084 .vsel_reg = WM8350_LDO1_CONTROL,
1112 .vsel_mask = WM8350_LDO1_VSEL_MASK, 1085 .vsel_mask = WM8350_LDO1_VSEL_MASK,
1113 .enable_reg = WM8350_DCDC_LDO_REQUESTED, 1086 .enable_reg = WM8350_DCDC_LDO_REQUESTED,
@@ -1121,6 +1094,8 @@ static const struct regulator_desc wm8350_reg[NUM_WM8350_REGULATORS] = {
1121 .irq = WM8350_IRQ_UV_LDO2, 1094 .irq = WM8350_IRQ_UV_LDO2,
1122 .type = REGULATOR_VOLTAGE, 1095 .type = REGULATOR_VOLTAGE,
1123 .n_voltages = WM8350_LDO2_VSEL_MASK + 1, 1096 .n_voltages = WM8350_LDO2_VSEL_MASK + 1,
1097 .linear_ranges = wm8350_ldo_ranges,
1098 .n_linear_ranges = ARRAY_SIZE(wm8350_ldo_ranges),
1124 .vsel_reg = WM8350_LDO2_CONTROL, 1099 .vsel_reg = WM8350_LDO2_CONTROL,
1125 .vsel_mask = WM8350_LDO2_VSEL_MASK, 1100 .vsel_mask = WM8350_LDO2_VSEL_MASK,
1126 .enable_reg = WM8350_DCDC_LDO_REQUESTED, 1101 .enable_reg = WM8350_DCDC_LDO_REQUESTED,
@@ -1134,6 +1109,8 @@ static const struct regulator_desc wm8350_reg[NUM_WM8350_REGULATORS] = {
1134 .irq = WM8350_IRQ_UV_LDO3, 1109 .irq = WM8350_IRQ_UV_LDO3,
1135 .type = REGULATOR_VOLTAGE, 1110 .type = REGULATOR_VOLTAGE,
1136 .n_voltages = WM8350_LDO3_VSEL_MASK + 1, 1111 .n_voltages = WM8350_LDO3_VSEL_MASK + 1,
1112 .linear_ranges = wm8350_ldo_ranges,
1113 .n_linear_ranges = ARRAY_SIZE(wm8350_ldo_ranges),
1137 .vsel_reg = WM8350_LDO3_CONTROL, 1114 .vsel_reg = WM8350_LDO3_CONTROL,
1138 .vsel_mask = WM8350_LDO3_VSEL_MASK, 1115 .vsel_mask = WM8350_LDO3_VSEL_MASK,
1139 .enable_reg = WM8350_DCDC_LDO_REQUESTED, 1116 .enable_reg = WM8350_DCDC_LDO_REQUESTED,
@@ -1147,6 +1124,8 @@ static const struct regulator_desc wm8350_reg[NUM_WM8350_REGULATORS] = {
1147 .irq = WM8350_IRQ_UV_LDO4, 1124 .irq = WM8350_IRQ_UV_LDO4,
1148 .type = REGULATOR_VOLTAGE, 1125 .type = REGULATOR_VOLTAGE,
1149 .n_voltages = WM8350_LDO4_VSEL_MASK + 1, 1126 .n_voltages = WM8350_LDO4_VSEL_MASK + 1,
1127 .linear_ranges = wm8350_ldo_ranges,
1128 .n_linear_ranges = ARRAY_SIZE(wm8350_ldo_ranges),
1150 .vsel_reg = WM8350_LDO4_CONTROL, 1129 .vsel_reg = WM8350_LDO4_CONTROL,
1151 .vsel_mask = WM8350_LDO4_VSEL_MASK, 1130 .vsel_mask = WM8350_LDO4_VSEL_MASK,
1152 .enable_reg = WM8350_DCDC_LDO_REQUESTED, 1131 .enable_reg = WM8350_DCDC_LDO_REQUESTED,
diff --git a/drivers/regulator/wm8400-regulator.c b/drivers/regulator/wm8400-regulator.c
index a09f03ee5506..2ac7e1aceb05 100644
--- a/drivers/regulator/wm8400-regulator.c
+++ b/drivers/regulator/wm8400-regulator.c
@@ -19,47 +19,21 @@
19#include <linux/regulator/driver.h> 19#include <linux/regulator/driver.h>
20#include <linux/mfd/wm8400-private.h> 20#include <linux/mfd/wm8400-private.h>
21 21
22static int wm8400_ldo_list_voltage(struct regulator_dev *dev, 22static const struct regulator_linear_range wm8400_ldo_ranges[] = {
23 unsigned selector) 23 { .min_uV = 900000, .max_uV = 1600000, .min_sel = 0, .max_sel = 14,
24{ 24 .uV_step = 50000 },
25 if (selector > WM8400_LDO1_VSEL_MASK) 25 { .min_uV = 1700000, .max_uV = 3300000, .min_sel = 15, .max_sel = 31,
26 return -EINVAL; 26 .uV_step = 100000 },
27 27};
28 if (selector < 15)
29 return 900000 + (selector * 50000);
30 else
31 return 1700000 + ((selector - 15) * 100000);
32}
33
34static int wm8400_ldo_map_voltage(struct regulator_dev *dev,
35 int min_uV, int max_uV)
36{
37 u16 val;
38 int volt;
39
40 if (min_uV < 900000 || min_uV > 3300000)
41 return -EINVAL;
42
43 if (min_uV < 1700000) /* Steps of 50mV from 900mV; */
44 val = DIV_ROUND_UP(min_uV - 900000, 50000);
45 else /* Steps of 100mV from 1700mV */
46 val = DIV_ROUND_UP(min_uV - 1700000, 100000) + 15;
47
48 volt = wm8400_ldo_list_voltage(dev, val);
49 if (volt < min_uV || volt > max_uV)
50 return -EINVAL;
51
52 return val;
53}
54 28
55static struct regulator_ops wm8400_ldo_ops = { 29static struct regulator_ops wm8400_ldo_ops = {
56 .is_enabled = regulator_is_enabled_regmap, 30 .is_enabled = regulator_is_enabled_regmap,
57 .enable = regulator_enable_regmap, 31 .enable = regulator_enable_regmap,
58 .disable = regulator_disable_regmap, 32 .disable = regulator_disable_regmap,
59 .list_voltage = wm8400_ldo_list_voltage, 33 .list_voltage = regulator_list_voltage_linear_range,
60 .get_voltage_sel = regulator_get_voltage_sel_regmap, 34 .get_voltage_sel = regulator_get_voltage_sel_regmap,
61 .set_voltage_sel = regulator_set_voltage_sel_regmap, 35 .set_voltage_sel = regulator_set_voltage_sel_regmap,
62 .map_voltage = wm8400_ldo_map_voltage, 36 .map_voltage = regulator_map_voltage_linear_range,
63}; 37};
64 38
65static unsigned int wm8400_dcdc_get_mode(struct regulator_dev *dev) 39static unsigned int wm8400_dcdc_get_mode(struct regulator_dev *dev)
@@ -155,6 +129,8 @@ static struct regulator_desc regulators[] = {
155 .enable_reg = WM8400_LDO1_CONTROL, 129 .enable_reg = WM8400_LDO1_CONTROL,
156 .enable_mask = WM8400_LDO1_ENA, 130 .enable_mask = WM8400_LDO1_ENA,
157 .n_voltages = WM8400_LDO1_VSEL_MASK + 1, 131 .n_voltages = WM8400_LDO1_VSEL_MASK + 1,
132 .linear_ranges = wm8400_ldo_ranges,
133 .n_linear_ranges = ARRAY_SIZE(wm8400_ldo_ranges),
158 .vsel_reg = WM8400_LDO1_CONTROL, 134 .vsel_reg = WM8400_LDO1_CONTROL,
159 .vsel_mask = WM8400_LDO1_VSEL_MASK, 135 .vsel_mask = WM8400_LDO1_VSEL_MASK,
160 .type = REGULATOR_VOLTAGE, 136 .type = REGULATOR_VOLTAGE,
@@ -167,6 +143,8 @@ static struct regulator_desc regulators[] = {
167 .enable_reg = WM8400_LDO2_CONTROL, 143 .enable_reg = WM8400_LDO2_CONTROL,
168 .enable_mask = WM8400_LDO2_ENA, 144 .enable_mask = WM8400_LDO2_ENA,
169 .n_voltages = WM8400_LDO2_VSEL_MASK + 1, 145 .n_voltages = WM8400_LDO2_VSEL_MASK + 1,
146 .linear_ranges = wm8400_ldo_ranges,
147 .n_linear_ranges = ARRAY_SIZE(wm8400_ldo_ranges),
170 .type = REGULATOR_VOLTAGE, 148 .type = REGULATOR_VOLTAGE,
171 .vsel_reg = WM8400_LDO2_CONTROL, 149 .vsel_reg = WM8400_LDO2_CONTROL,
172 .vsel_mask = WM8400_LDO2_VSEL_MASK, 150 .vsel_mask = WM8400_LDO2_VSEL_MASK,
@@ -179,6 +157,8 @@ static struct regulator_desc regulators[] = {
179 .enable_reg = WM8400_LDO3_CONTROL, 157 .enable_reg = WM8400_LDO3_CONTROL,
180 .enable_mask = WM8400_LDO3_ENA, 158 .enable_mask = WM8400_LDO3_ENA,
181 .n_voltages = WM8400_LDO3_VSEL_MASK + 1, 159 .n_voltages = WM8400_LDO3_VSEL_MASK + 1,
160 .linear_ranges = wm8400_ldo_ranges,
161 .n_linear_ranges = ARRAY_SIZE(wm8400_ldo_ranges),
182 .vsel_reg = WM8400_LDO3_CONTROL, 162 .vsel_reg = WM8400_LDO3_CONTROL,
183 .vsel_mask = WM8400_LDO3_VSEL_MASK, 163 .vsel_mask = WM8400_LDO3_VSEL_MASK,
184 .type = REGULATOR_VOLTAGE, 164 .type = REGULATOR_VOLTAGE,
@@ -191,6 +171,8 @@ static struct regulator_desc regulators[] = {
191 .enable_reg = WM8400_LDO4_CONTROL, 171 .enable_reg = WM8400_LDO4_CONTROL,
192 .enable_mask = WM8400_LDO4_ENA, 172 .enable_mask = WM8400_LDO4_ENA,
193 .n_voltages = WM8400_LDO4_VSEL_MASK + 1, 173 .n_voltages = WM8400_LDO4_VSEL_MASK + 1,
174 .linear_ranges = wm8400_ldo_ranges,
175 .n_linear_ranges = ARRAY_SIZE(wm8400_ldo_ranges),
194 .vsel_reg = WM8400_LDO4_CONTROL, 176 .vsel_reg = WM8400_LDO4_CONTROL,
195 .vsel_mask = WM8400_LDO4_VSEL_MASK, 177 .vsel_mask = WM8400_LDO4_VSEL_MASK,
196 .type = REGULATOR_VOLTAGE, 178 .type = REGULATOR_VOLTAGE,
diff --git a/include/linux/regulator/driver.h b/include/linux/regulator/driver.h
index 6700cc94bdd1..67e13aa5a478 100644
--- a/include/linux/regulator/driver.h
+++ b/include/linux/regulator/driver.h
@@ -40,6 +40,24 @@ enum regulator_status {
40}; 40};
41 41
42/** 42/**
43 * Specify a range of voltages for regulator_map_linar_range() and
44 * regulator_list_linear_range().
45 *
46 * @min_uV: Lowest voltage in range
47 * @max_uV: Highest voltage in range
48 * @min_sel: Lowest selector for range
49 * @max_sel: Highest selector for range
50 * @uV_step: Step size
51 */
52struct regulator_linear_range {
53 unsigned int min_uV;
54 unsigned int max_uV;
55 unsigned int min_sel;
56 unsigned int max_sel;
57 unsigned int uV_step;
58};
59
60/**
43 * struct regulator_ops - regulator operations. 61 * struct regulator_ops - regulator operations.
44 * 62 *
45 * @enable: Configure the regulator as enabled. 63 * @enable: Configure the regulator as enabled.
@@ -223,6 +241,9 @@ struct regulator_desc {
223 unsigned int linear_min_sel; 241 unsigned int linear_min_sel;
224 unsigned int ramp_delay; 242 unsigned int ramp_delay;
225 243
244 const struct regulator_linear_range *linear_ranges;
245 int n_linear_ranges;
246
226 const unsigned int *volt_table; 247 const unsigned int *volt_table;
227 248
228 unsigned int vsel_reg; 249 unsigned int vsel_reg;
@@ -326,10 +347,14 @@ int regulator_mode_to_status(unsigned int);
326 347
327int regulator_list_voltage_linear(struct regulator_dev *rdev, 348int regulator_list_voltage_linear(struct regulator_dev *rdev,
328 unsigned int selector); 349 unsigned int selector);
350int regulator_list_voltage_linear_range(struct regulator_dev *rdev,
351 unsigned int selector);
329int regulator_list_voltage_table(struct regulator_dev *rdev, 352int regulator_list_voltage_table(struct regulator_dev *rdev,
330 unsigned int selector); 353 unsigned int selector);
331int regulator_map_voltage_linear(struct regulator_dev *rdev, 354int regulator_map_voltage_linear(struct regulator_dev *rdev,
332 int min_uV, int max_uV); 355 int min_uV, int max_uV);
356int regulator_map_voltage_linear_range(struct regulator_dev *rdev,
357 int min_uV, int max_uV);
333int regulator_map_voltage_iterate(struct regulator_dev *rdev, 358int regulator_map_voltage_iterate(struct regulator_dev *rdev,
334 int min_uV, int max_uV); 359 int min_uV, int max_uV);
335int regulator_map_voltage_ascend(struct regulator_dev *rdev, 360int regulator_map_voltage_ascend(struct regulator_dev *rdev,