Skip to content

Commit

Permalink
Merge branches 'topic/tps51632', 'topic/tps80031', 'topic/vexpress', …
Browse files Browse the repository at this point in the history
…'topic/max8925', 'topic/gpio' and 'topic/tps65090' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator into regulator-hotplug
  • Loading branch information
Mark Brown committed Nov 20, 2012
7 parents f4a75d2 + 7bde767 + b92f787 + 9f4e45f + 560615e + 216f2b9 + f329b17 commit f86221d
Show file tree
Hide file tree
Showing 16 changed files with 1,854 additions and 116 deletions.
37 changes: 37 additions & 0 deletions Documentation/devicetree/bindings/regulator/gpio-regulator.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
GPIO controlled regulators

Required properties:
- compatible : Must be "regulator-gpio".
- states : Selection of available voltages and GPIO configs.
if there are no states, then use a fixed regulator

Optional properties:
- enable-gpio : GPIO to use to enable/disable the regulator.
- gpios : GPIO group used to control voltage.
- startup-delay-us : Startup time in microseconds.
- enable-active-high : Polarity of GPIO is active high (default is low).

Any property defined as part of the core regulator binding defined in
regulator.txt can also be used.

Example:

mmciv: gpio-regulator {
compatible = "regulator-gpio";

regulator-name = "mmci-gpio-supply";
regulator-min-microvolt = <1800000>;
regulator-max-microvolt = <2600000>;
regulator-boot-on;

enable-gpio = <&gpio0 23 0x4>;
gpios = <&gpio0 24 0x4
&gpio0 25 0x4>;
states = <1800000 0x3
2200000 0x2
2600000 0x1
2900000 0x0>;

startup-delay-us = <100000>;
enable-active-high;
};
40 changes: 40 additions & 0 deletions Documentation/devicetree/bindings/regulator/max8925-regulator.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
Max8925 Voltage regulators

Required nodes:
-nodes:
- SDV1 for SDV SDV1
- SDV2 for SDV SDV2
- SDV3 for SDV SDV3
- LDO1 for LDO LDO1
- LDO2 for LDO LDO2
- LDO3 for LDO LDO3
- LDO4 for LDO LDO4
- LDO5 for LDO LDO5
- LDO6 for LDO LDO6
- LDO7 for LDO LDO7
- LDO8 for LDO LDO8
- LDO9 for LDO LDO9
- LDO10 for LDO LDO10
- LDO11 for LDO LDO11
- LDO12 for LDO LDO12
- LDO13 for LDO LDO13
- LDO14 for LDO LDO14
- LDO15 for LDO LDO15
- LDO16 for LDO LDO16
- LDO17 for LDO LDO17
- LDO18 for LDO LDO18
- LDO19 for LDO LDO19
- LDO20 for LDO LDO20

Optional properties:
- Any optional property defined in bindings/regulator/regulator.txt

Example:

SDV1 {
regulator-min-microvolt = <637500>;
regulator-max-microvolt = <1425000>;
regulator-boot-on;
regulator-always-on;
};

32 changes: 32 additions & 0 deletions Documentation/devicetree/bindings/regulator/vexpress.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
Versatile Express voltage regulators
------------------------------------

Requires node properties:
- "compatible" value: "arm,vexpress-volt"
- "arm,vexpress-sysreg,func" when controlled via vexpress-sysreg
(see Documentation/devicetree/bindings/arm/vexpress-sysreg.txt
for more details)

Required regulator properties:
- "regulator-name"
- "regulator-always-on"

Optional regulator properties:
- "regulator-min-microvolt"
- "regulator-max-microvolt"

See Documentation/devicetree/bindings/regulator/regulator.txt
for more details about the regulator properties.

When no "regulator-[min|max]-microvolt" properties are defined,
the device is treated as fixed (or rather "read-only") regulator.

Example:
volt@0 {
compatible = "arm,vexpress-volt";
arm,vexpress-sysreg,func = <2 0>;
regulator-name = "Cores";
regulator-min-microvolt = <800000>;
regulator-max-microvolt = <1050000>;
regulator-always-on;
};
27 changes: 27 additions & 0 deletions drivers/regulator/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,17 @@ config REGULATOR_PALMAS
on the muxing. This is handled automatically in the driver by
reading the mux info from OTP.

config REGULATOR_TPS51632
tristate "TI TPS51632 Power Regulator"
depends on I2C
select REGMAP_I2C
help
This driver supports TPS51632 voltage regulator chip.
The TPS51632 is 3-2-1 Phase D-Cap+ Step Down Driverless Controller
with Serial VID control and DVFS.
The voltage output can be configure through I2C interface or PWM
interface.

config REGULATOR_TPS6105X
tristate "TI TPS6105X Power regulators"
depends on TPS6105X
Expand Down Expand Up @@ -415,13 +426,29 @@ config REGULATOR_TPS65912
help
This driver supports TPS65912 voltage regulator chip.

config REGULATOR_TPS80031
tristate "TI TPS80031/TPS80032 power regualtor driver"
depends on MFD_TPS80031
help
TPS80031/ TPS80032 Fully Integrated Power Management with Power
Path and Battery Charger. It has 5 configurable step-down
converters, 11 general purpose LDOs, VBUS generator and digital
output to control regulators.

config REGULATOR_TWL4030
bool "TI TWL4030/TWL5030/TWL6030/TPS659x0 PMIC"
depends on TWL4030_CORE
help
This driver supports the voltage regulators provided by
this family of companion chips.

config REGULATOR_VEXPRESS
tristate "Versatile Express regulators"
depends on VEXPRESS_CONFIG
help
This driver provides support for voltage regulators available
on the ARM Ltd's Versatile Express platform.

config REGULATOR_WM831X
tristate "Wolfson Microelectronics WM831x PMIC regulators"
depends on MFD_WM831X
Expand Down
3 changes: 3 additions & 0 deletions drivers/regulator/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ obj-$(CONFIG_REGULATOR_MC13783) += mc13783-regulator.o
obj-$(CONFIG_REGULATOR_MC13892) += mc13892-regulator.o
obj-$(CONFIG_REGULATOR_MC13XXX_CORE) += mc13xxx-regulator-core.o
obj-$(CONFIG_REGULATOR_PALMAS) += palmas-regulator.o
obj-$(CONFIG_REGULATOR_TPS51632) += tps51632-regulator.o
obj-$(CONFIG_REGULATOR_PCAP) += pcap-regulator.o
obj-$(CONFIG_REGULATOR_PCF50633) += pcf50633-regulator.o
obj-$(CONFIG_REGULATOR_RC5T583) += rc5t583-regulator.o
Expand All @@ -56,7 +57,9 @@ obj-$(CONFIG_REGULATOR_TPS6524X) += tps6524x-regulator.o
obj-$(CONFIG_REGULATOR_TPS6586X) += tps6586x-regulator.o
obj-$(CONFIG_REGULATOR_TPS65910) += tps65910-regulator.o
obj-$(CONFIG_REGULATOR_TPS65912) += tps65912-regulator.o
obj-$(CONFIG_REGULATOR_TPS80031) += tps80031-regulator.o
obj-$(CONFIG_REGULATOR_TWL4030) += twl-regulator.o
obj-$(CONFIG_REGULATOR_VEXPRESS) += vexpress.o
obj-$(CONFIG_REGULATOR_WM831X) += wm831x-dcdc.o
obj-$(CONFIG_REGULATOR_WM831X) += wm831x-isink.o
obj-$(CONFIG_REGULATOR_WM831X) += wm831x-ldo.o
Expand Down
5 changes: 5 additions & 0 deletions drivers/regulator/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1985,6 +1985,11 @@ int regulator_is_supported_voltage(struct regulator *regulator,
return ret;
}

/* Any voltage within constrains range is fine? */
if (rdev->desc->continuous_voltage_range)
return min_uV >= rdev->constraints->min_uV &&
max_uV <= rdev->constraints->max_uV;

ret = regulator_count_voltages(regulator);
if (ret < 0)
return ret;
Expand Down
100 changes: 100 additions & 0 deletions drivers/regulator/gpio-regulator.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,12 @@
#include <linux/platform_device.h>
#include <linux/regulator/driver.h>
#include <linux/regulator/machine.h>
#include <linux/regulator/of_regulator.h>
#include <linux/regulator/gpio-regulator.h>
#include <linux/gpio.h>
#include <linux/slab.h>
#include <linux/of.h>
#include <linux/of_gpio.h>

struct gpio_regulator_data {
struct regulator_desc desc;
Expand Down Expand Up @@ -129,6 +132,89 @@ static struct regulator_ops gpio_regulator_voltage_ops = {
.list_voltage = gpio_regulator_list_voltage,
};

struct gpio_regulator_config *
of_get_gpio_regulator_config(struct device *dev, struct device_node *np)
{
struct gpio_regulator_config *config;
struct property *prop;
const char *regtype;
int proplen, gpio, i;

config = devm_kzalloc(dev,
sizeof(struct gpio_regulator_config),
GFP_KERNEL);
if (!config)
return ERR_PTR(-ENOMEM);

config->init_data = of_get_regulator_init_data(dev, np);
if (!config->init_data)
return ERR_PTR(-EINVAL);

config->supply_name = config->init_data->constraints.name;

if (of_property_read_bool(np, "enable-active-high"))
config->enable_high = true;

if (of_property_read_bool(np, "enable-at-boot"))
config->enabled_at_boot = true;

of_property_read_u32(np, "startup-delay-us", &config->startup_delay);

config->enable_gpio = of_get_named_gpio(np, "enable-gpio", 0);

/* Fetch GPIOs. */
for (i = 0; ; i++)
if (of_get_named_gpio(np, "gpios", i) < 0)
break;
config->nr_gpios = i;

config->gpios = devm_kzalloc(dev,
sizeof(struct gpio) * config->nr_gpios,
GFP_KERNEL);
if (!config->gpios)
return ERR_PTR(-ENOMEM);

for (i = 0; config->nr_gpios; i++) {
gpio = of_get_named_gpio(np, "gpios", i);
if (gpio < 0)
break;
config->gpios[i].gpio = gpio;
}

/* Fetch states. */
prop = of_find_property(np, "states", NULL);
if (!prop) {
dev_err(dev, "No 'states' property found\n");
return ERR_PTR(-EINVAL);
}

proplen = prop->length / sizeof(int);

config->states = devm_kzalloc(dev,
sizeof(struct gpio_regulator_state)
* (proplen / 2),
GFP_KERNEL);
if (!config->states)
return ERR_PTR(-ENOMEM);

for (i = 0; i < proplen / 2; i++) {
config->states[i].value =
be32_to_cpup((int *)prop->value + (i * 2));
config->states[i].gpios =
be32_to_cpup((int *)prop->value + (i * 2 + 1));
}
config->nr_states = i;

of_property_read_string(np, "regulator-type", &regtype);

if (!strncmp("voltage", regtype, 7))
config->type = REGULATOR_VOLTAGE;
else if (!strncmp("current", regtype, 7))
config->type = REGULATOR_CURRENT;

return config;
}

static struct regulator_ops gpio_regulator_current_ops = {
.get_current_limit = gpio_regulator_get_value,
.set_current_limit = gpio_regulator_set_current_limit,
Expand All @@ -137,10 +223,17 @@ static struct regulator_ops gpio_regulator_current_ops = {
static int __devinit gpio_regulator_probe(struct platform_device *pdev)
{
struct gpio_regulator_config *config = pdev->dev.platform_data;
struct device_node *np = pdev->dev.of_node;
struct gpio_regulator_data *drvdata;
struct regulator_config cfg = { };
int ptr, ret, state;

if (np) {
config = of_get_gpio_regulator_config(&pdev->dev, np);
if (IS_ERR(config))
return PTR_ERR(config);
}

drvdata = devm_kzalloc(&pdev->dev, sizeof(struct gpio_regulator_data),
GFP_KERNEL);
if (drvdata == NULL) {
Expand Down Expand Up @@ -215,6 +308,7 @@ static int __devinit gpio_regulator_probe(struct platform_device *pdev)
cfg.dev = &pdev->dev;
cfg.init_data = config->init_data;
cfg.driver_data = drvdata;
cfg.of_node = np;

if (config->enable_gpio >= 0)
cfg.ena_gpio = config->enable_gpio;
Expand Down Expand Up @@ -270,12 +364,18 @@ static int __devexit gpio_regulator_remove(struct platform_device *pdev)
return 0;
}

static const struct of_device_id regulator_gpio_of_match[] __devinitconst = {
{ .compatible = "regulator-gpio", },
{},
};

static struct platform_driver gpio_regulator_driver = {
.probe = gpio_regulator_probe,
.remove = __devexit_p(gpio_regulator_remove),
.driver = {
.name = "gpio-regulator",
.owner = THIS_MODULE,
.of_match_table = regulator_gpio_of_match,
},
};

Expand Down
Loading

0 comments on commit f86221d

Please sign in to comment.