Skip to content

Commit f86221d

Browse files
committed
Merge branches 'topic/tps51632', 'topic/tps80031', 'topic/vexpress', 'topic/max8925', 'topic/gpio' and 'topic/tps65090' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator into regulator-hotplug
7 parents f4a75d2 + 7bde767 + b92f787 + 9f4e45f + 560615e + 216f2b9 + f329b17 commit f86221d

16 files changed

Lines changed: 1854 additions & 116 deletions

File tree

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
GPIO controlled regulators
2+
3+
Required properties:
4+
- compatible : Must be "regulator-gpio".
5+
- states : Selection of available voltages and GPIO configs.
6+
if there are no states, then use a fixed regulator
7+
8+
Optional properties:
9+
- enable-gpio : GPIO to use to enable/disable the regulator.
10+
- gpios : GPIO group used to control voltage.
11+
- startup-delay-us : Startup time in microseconds.
12+
- enable-active-high : Polarity of GPIO is active high (default is low).
13+
14+
Any property defined as part of the core regulator binding defined in
15+
regulator.txt can also be used.
16+
17+
Example:
18+
19+
mmciv: gpio-regulator {
20+
compatible = "regulator-gpio";
21+
22+
regulator-name = "mmci-gpio-supply";
23+
regulator-min-microvolt = <1800000>;
24+
regulator-max-microvolt = <2600000>;
25+
regulator-boot-on;
26+
27+
enable-gpio = <&gpio0 23 0x4>;
28+
gpios = <&gpio0 24 0x4
29+
&gpio0 25 0x4>;
30+
states = <1800000 0x3
31+
2200000 0x2
32+
2600000 0x1
33+
2900000 0x0>;
34+
35+
startup-delay-us = <100000>;
36+
enable-active-high;
37+
};
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
Max8925 Voltage regulators
2+
3+
Required nodes:
4+
-nodes:
5+
- SDV1 for SDV SDV1
6+
- SDV2 for SDV SDV2
7+
- SDV3 for SDV SDV3
8+
- LDO1 for LDO LDO1
9+
- LDO2 for LDO LDO2
10+
- LDO3 for LDO LDO3
11+
- LDO4 for LDO LDO4
12+
- LDO5 for LDO LDO5
13+
- LDO6 for LDO LDO6
14+
- LDO7 for LDO LDO7
15+
- LDO8 for LDO LDO8
16+
- LDO9 for LDO LDO9
17+
- LDO10 for LDO LDO10
18+
- LDO11 for LDO LDO11
19+
- LDO12 for LDO LDO12
20+
- LDO13 for LDO LDO13
21+
- LDO14 for LDO LDO14
22+
- LDO15 for LDO LDO15
23+
- LDO16 for LDO LDO16
24+
- LDO17 for LDO LDO17
25+
- LDO18 for LDO LDO18
26+
- LDO19 for LDO LDO19
27+
- LDO20 for LDO LDO20
28+
29+
Optional properties:
30+
- Any optional property defined in bindings/regulator/regulator.txt
31+
32+
Example:
33+
34+
SDV1 {
35+
regulator-min-microvolt = <637500>;
36+
regulator-max-microvolt = <1425000>;
37+
regulator-boot-on;
38+
regulator-always-on;
39+
};
40+
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
Versatile Express voltage regulators
2+
------------------------------------
3+
4+
Requires node properties:
5+
- "compatible" value: "arm,vexpress-volt"
6+
- "arm,vexpress-sysreg,func" when controlled via vexpress-sysreg
7+
(see Documentation/devicetree/bindings/arm/vexpress-sysreg.txt
8+
for more details)
9+
10+
Required regulator properties:
11+
- "regulator-name"
12+
- "regulator-always-on"
13+
14+
Optional regulator properties:
15+
- "regulator-min-microvolt"
16+
- "regulator-max-microvolt"
17+
18+
See Documentation/devicetree/bindings/regulator/regulator.txt
19+
for more details about the regulator properties.
20+
21+
When no "regulator-[min|max]-microvolt" properties are defined,
22+
the device is treated as fixed (or rather "read-only") regulator.
23+
24+
Example:
25+
volt@0 {
26+
compatible = "arm,vexpress-volt";
27+
arm,vexpress-sysreg,func = <2 0>;
28+
regulator-name = "Cores";
29+
regulator-min-microvolt = <800000>;
30+
regulator-max-microvolt = <1050000>;
31+
regulator-always-on;
32+
};

‎drivers/regulator/Kconfig‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,17 @@ config REGULATOR_PALMAS
335335
on the muxing. This is handled automatically in the driver by
336336
reading the mux info from OTP.
337337

338+
config REGULATOR_TPS51632
339+
tristate "TI TPS51632 Power Regulator"
340+
depends on I2C
341+
select REGMAP_I2C
342+
help
343+
This driver supports TPS51632 voltage regulator chip.
344+
The TPS51632 is 3-2-1 Phase D-Cap+ Step Down Driverless Controller
345+
with Serial VID control and DVFS.
346+
The voltage output can be configure through I2C interface or PWM
347+
interface.
348+
338349
config REGULATOR_TPS6105X
339350
tristate "TI TPS6105X Power regulators"
340351
depends on TPS6105X
@@ -415,13 +426,29 @@ config REGULATOR_TPS65912
415426
help
416427
This driver supports TPS65912 voltage regulator chip.
417428

429+
config REGULATOR_TPS80031
430+
tristate "TI TPS80031/TPS80032 power regualtor driver"
431+
depends on MFD_TPS80031
432+
help
433+
TPS80031/ TPS80032 Fully Integrated Power Management with Power
434+
Path and Battery Charger. It has 5 configurable step-down
435+
converters, 11 general purpose LDOs, VBUS generator and digital
436+
output to control regulators.
437+
418438
config REGULATOR_TWL4030
419439
bool "TI TWL4030/TWL5030/TWL6030/TPS659x0 PMIC"
420440
depends on TWL4030_CORE
421441
help
422442
This driver supports the voltage regulators provided by
423443
this family of companion chips.
424444

445+
config REGULATOR_VEXPRESS
446+
tristate "Versatile Express regulators"
447+
depends on VEXPRESS_CONFIG
448+
help
449+
This driver provides support for voltage regulators available
450+
on the ARM Ltd's Versatile Express platform.
451+
425452
config REGULATOR_WM831X
426453
tristate "Wolfson Microelectronics WM831x PMIC regulators"
427454
depends on MFD_WM831X

‎drivers/regulator/Makefile‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ obj-$(CONFIG_REGULATOR_MC13783) += mc13783-regulator.o
4141
obj-$(CONFIG_REGULATOR_MC13892) += mc13892-regulator.o
4242
obj-$(CONFIG_REGULATOR_MC13XXX_CORE) += mc13xxx-regulator-core.o
4343
obj-$(CONFIG_REGULATOR_PALMAS) += palmas-regulator.o
44+
obj-$(CONFIG_REGULATOR_TPS51632) += tps51632-regulator.o
4445
obj-$(CONFIG_REGULATOR_PCAP) += pcap-regulator.o
4546
obj-$(CONFIG_REGULATOR_PCF50633) += pcf50633-regulator.o
4647
obj-$(CONFIG_REGULATOR_RC5T583) += rc5t583-regulator.o
@@ -56,7 +57,9 @@ obj-$(CONFIG_REGULATOR_TPS6524X) += tps6524x-regulator.o
5657
obj-$(CONFIG_REGULATOR_TPS6586X) += tps6586x-regulator.o
5758
obj-$(CONFIG_REGULATOR_TPS65910) += tps65910-regulator.o
5859
obj-$(CONFIG_REGULATOR_TPS65912) += tps65912-regulator.o
60+
obj-$(CONFIG_REGULATOR_TPS80031) += tps80031-regulator.o
5961
obj-$(CONFIG_REGULATOR_TWL4030) += twl-regulator.o
62+
obj-$(CONFIG_REGULATOR_VEXPRESS) += vexpress.o
6063
obj-$(CONFIG_REGULATOR_WM831X) += wm831x-dcdc.o
6164
obj-$(CONFIG_REGULATOR_WM831X) += wm831x-isink.o
6265
obj-$(CONFIG_REGULATOR_WM831X) += wm831x-ldo.o

‎drivers/regulator/core.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1985,6 +1985,11 @@ int regulator_is_supported_voltage(struct regulator *regulator,
19851985
return ret;
19861986
}
19871987

1988+
/* Any voltage within constrains range is fine? */
1989+
if (rdev->desc->continuous_voltage_range)
1990+
return min_uV >= rdev->constraints->min_uV &&
1991+
max_uV <= rdev->constraints->max_uV;
1992+
19881993
ret = regulator_count_voltages(regulator);
19891994
if (ret < 0)
19901995
return ret;

‎drivers/regulator/gpio-regulator.c‎

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,12 @@
2828
#include <linux/platform_device.h>
2929
#include <linux/regulator/driver.h>
3030
#include <linux/regulator/machine.h>
31+
#include <linux/regulator/of_regulator.h>
3132
#include <linux/regulator/gpio-regulator.h>
3233
#include <linux/gpio.h>
3334
#include <linux/slab.h>
35+
#include <linux/of.h>
36+
#include <linux/of_gpio.h>
3437

3538
struct gpio_regulator_data {
3639
struct regulator_desc desc;
@@ -129,6 +132,89 @@ static struct regulator_ops gpio_regulator_voltage_ops = {
129132
.list_voltage = gpio_regulator_list_voltage,
130133
};
131134

135+
struct gpio_regulator_config *
136+
of_get_gpio_regulator_config(struct device *dev, struct device_node *np)
137+
{
138+
struct gpio_regulator_config *config;
139+
struct property *prop;
140+
const char *regtype;
141+
int proplen, gpio, i;
142+
143+
config = devm_kzalloc(dev,
144+
sizeof(struct gpio_regulator_config),
145+
GFP_KERNEL);
146+
if (!config)
147+
return ERR_PTR(-ENOMEM);
148+
149+
config->init_data = of_get_regulator_init_data(dev, np);
150+
if (!config->init_data)
151+
return ERR_PTR(-EINVAL);
152+
153+
config->supply_name = config->init_data->constraints.name;
154+
155+
if (of_property_read_bool(np, "enable-active-high"))
156+
config->enable_high = true;
157+
158+
if (of_property_read_bool(np, "enable-at-boot"))
159+
config->enabled_at_boot = true;
160+
161+
of_property_read_u32(np, "startup-delay-us", &config->startup_delay);
162+
163+
config->enable_gpio = of_get_named_gpio(np, "enable-gpio", 0);
164+
165+
/* Fetch GPIOs. */
166+
for (i = 0; ; i++)
167+
if (of_get_named_gpio(np, "gpios", i) < 0)
168+
break;
169+
config->nr_gpios = i;
170+
171+
config->gpios = devm_kzalloc(dev,
172+
sizeof(struct gpio) * config->nr_gpios,
173+
GFP_KERNEL);
174+
if (!config->gpios)
175+
return ERR_PTR(-ENOMEM);
176+
177+
for (i = 0; config->nr_gpios; i++) {
178+
gpio = of_get_named_gpio(np, "gpios", i);
179+
if (gpio < 0)
180+
break;
181+
config->gpios[i].gpio = gpio;
182+
}
183+
184+
/* Fetch states. */
185+
prop = of_find_property(np, "states", NULL);
186+
if (!prop) {
187+
dev_err(dev, "No 'states' property found\n");
188+
return ERR_PTR(-EINVAL);
189+
}
190+
191+
proplen = prop->length / sizeof(int);
192+
193+
config->states = devm_kzalloc(dev,
194+
sizeof(struct gpio_regulator_state)
195+
* (proplen / 2),
196+
GFP_KERNEL);
197+
if (!config->states)
198+
return ERR_PTR(-ENOMEM);
199+
200+
for (i = 0; i < proplen / 2; i++) {
201+
config->states[i].value =
202+
be32_to_cpup((int *)prop->value + (i * 2));
203+
config->states[i].gpios =
204+
be32_to_cpup((int *)prop->value + (i * 2 + 1));
205+
}
206+
config->nr_states = i;
207+
208+
of_property_read_string(np, "regulator-type", &regtype);
209+
210+
if (!strncmp("voltage", regtype, 7))
211+
config->type = REGULATOR_VOLTAGE;
212+
else if (!strncmp("current", regtype, 7))
213+
config->type = REGULATOR_CURRENT;
214+
215+
return config;
216+
}
217+
132218
static struct regulator_ops gpio_regulator_current_ops = {
133219
.get_current_limit = gpio_regulator_get_value,
134220
.set_current_limit = gpio_regulator_set_current_limit,
@@ -137,10 +223,17 @@ static struct regulator_ops gpio_regulator_current_ops = {
137223
static int __devinit gpio_regulator_probe(struct platform_device *pdev)
138224
{
139225
struct gpio_regulator_config *config = pdev->dev.platform_data;
226+
struct device_node *np = pdev->dev.of_node;
140227
struct gpio_regulator_data *drvdata;
141228
struct regulator_config cfg = { };
142229
int ptr, ret, state;
143230

231+
if (np) {
232+
config = of_get_gpio_regulator_config(&pdev->dev, np);
233+
if (IS_ERR(config))
234+
return PTR_ERR(config);
235+
}
236+
144237
drvdata = devm_kzalloc(&pdev->dev, sizeof(struct gpio_regulator_data),
145238
GFP_KERNEL);
146239
if (drvdata == NULL) {
@@ -215,6 +308,7 @@ static int __devinit gpio_regulator_probe(struct platform_device *pdev)
215308
cfg.dev = &pdev->dev;
216309
cfg.init_data = config->init_data;
217310
cfg.driver_data = drvdata;
311+
cfg.of_node = np;
218312

219313
if (config->enable_gpio >= 0)
220314
cfg.ena_gpio = config->enable_gpio;
@@ -270,12 +364,18 @@ static int __devexit gpio_regulator_remove(struct platform_device *pdev)
270364
return 0;
271365
}
272366

367+
static const struct of_device_id regulator_gpio_of_match[] __devinitconst = {
368+
{ .compatible = "regulator-gpio", },
369+
{},
370+
};
371+
273372
static struct platform_driver gpio_regulator_driver = {
274373
.probe = gpio_regulator_probe,
275374
.remove = __devexit_p(gpio_regulator_remove),
276375
.driver = {
277376
.name = "gpio-regulator",
278377
.owner = THIS_MODULE,
378+
.of_match_table = regulator_gpio_of_match,
279379
},
280380
};
281381

0 commit comments

Comments
 (0)