Skip to content

Commit

Permalink
Merge remote-tracking branch 'regulator/topic/drivers' into regulator…
Browse files Browse the repository at this point in the history
…-next

Conflicts:
	drivers/regulator/88pm8607.c (simple overlap with a bugfix in v3.4)
  • Loading branch information
Mark Brown committed May 12, 2012
2 parents 178e43a + 411a2df commit 5949a7e
Show file tree
Hide file tree
Showing 33 changed files with 559 additions and 304 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ Optional properties:
- startup-delay-us: startup time in microseconds
- enable-active-high: Polarity of GPIO is Active high
If this property is missing, the default assumed is Active low.
- gpio-open-drain: GPIO is open drain type.
If this property is missing then default assumption is false.

Any property defined as part of the core regulator
binding, defined in regulator.txt, can also be used.
Expand All @@ -25,5 +27,6 @@ Example:
gpio = <&gpio1 16 0>;
startup-delay-us = <70000>;
enable-active-high;
regulator-boot-on
regulator-boot-on;
gpio-open-drain;
};
97 changes: 97 additions & 0 deletions Documentation/devicetree/bindings/regulator/tps6586x.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
TPS6586x family of regulators

Required properties:
- compatible: "ti,tps6586x"
- reg: I2C slave address
- interrupts: the interrupt outputs of the controller
- #gpio-cells: number of cells to describe a GPIO
- gpio-controller: mark the device as a GPIO controller
- regulators: list of regulators provided by this controller, must be named
after their hardware counterparts: sm[0-2], ldo[0-9] and ldo_rtc

Each regulator is defined using the standard binding for regulators.

Example:

pmu: tps6586x@34 {
compatible = "ti,tps6586x";
reg = <0x34>;
interrupts = <0 88 0x4>;

#gpio-cells = <2>;
gpio-controller;

regulators {
sm0_reg: sm0 {
regulator-min-microvolt = < 725000>;
regulator-max-microvolt = <1500000>;
regulator-boot-on;
regulator-always-on;
};

sm1_reg: sm1 {
regulator-min-microvolt = < 725000>;
regulator-max-microvolt = <1500000>;
regulator-boot-on;
regulator-always-on;
};

sm2_reg: sm2 {
regulator-min-microvolt = <3000000>;
regulator-max-microvolt = <4550000>;
regulator-boot-on;
regulator-always-on;
};

ldo0_reg: ldo0 {
regulator-name = "PCIE CLK";
regulator-min-microvolt = <3300000>;
regulator-max-microvolt = <3300000>;
};

ldo1_reg: ldo1 {
regulator-min-microvolt = < 725000>;
regulator-max-microvolt = <1500000>;
};

ldo2_reg: ldo2 {
regulator-min-microvolt = < 725000>;
regulator-max-microvolt = <1500000>;
};

ldo3_reg: ldo3 {
regulator-min-microvolt = <1250000>;
regulator-max-microvolt = <3300000>;
};

ldo4_reg: ldo4 {
regulator-min-microvolt = <1700000>;
regulator-max-microvolt = <2475000>;
};

ldo5_reg: ldo5 {
regulator-min-microvolt = <1250000>;
regulator-max-microvolt = <3300000>;
};

ldo6_reg: ldo6 {
regulator-min-microvolt = <1250000>;
regulator-max-microvolt = <3300000>;
};

ldo7_reg: ldo7 {
regulator-min-microvolt = <1250000>;
regulator-max-microvolt = <3300000>;
};

ldo8_reg: ldo8 {
regulator-min-microvolt = <1250000>;
regulator-max-microvolt = <3300000>;
};

ldo9_reg: ldo9 {
regulator-min-microvolt = <1250000>;
regulator-max-microvolt = <3300000>;
};
};
};
86 changes: 86 additions & 0 deletions drivers/mfd/tps6586x.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <linux/slab.h>
#include <linux/gpio.h>
#include <linux/i2c.h>
#include <linux/regulator/of_regulator.h>

#include <linux/mfd/core.h>
#include <linux/mfd/tps6586x.h>
Expand Down Expand Up @@ -460,6 +461,7 @@ static int __devinit tps6586x_add_subdevs(struct tps6586x *tps6586x,

pdev->dev.parent = tps6586x->dev;
pdev->dev.platform_data = subdev->platform_data;
pdev->dev.of_node = subdev->of_node;

ret = platform_device_add(pdev);
if (ret) {
Expand All @@ -474,13 +476,96 @@ static int __devinit tps6586x_add_subdevs(struct tps6586x *tps6586x,
return ret;
}

#ifdef CONFIG_OF
static struct of_regulator_match tps6586x_matches[] = {
{ .name = "sm0", .driver_data = (void *)TPS6586X_ID_SM_0 },
{ .name = "sm1", .driver_data = (void *)TPS6586X_ID_SM_1 },
{ .name = "sm2", .driver_data = (void *)TPS6586X_ID_SM_2 },
{ .name = "ldo0", .driver_data = (void *)TPS6586X_ID_LDO_0 },
{ .name = "ldo1", .driver_data = (void *)TPS6586X_ID_LDO_1 },
{ .name = "ldo2", .driver_data = (void *)TPS6586X_ID_LDO_2 },
{ .name = "ldo3", .driver_data = (void *)TPS6586X_ID_LDO_3 },
{ .name = "ldo4", .driver_data = (void *)TPS6586X_ID_LDO_4 },
{ .name = "ldo5", .driver_data = (void *)TPS6586X_ID_LDO_5 },
{ .name = "ldo6", .driver_data = (void *)TPS6586X_ID_LDO_6 },
{ .name = "ldo7", .driver_data = (void *)TPS6586X_ID_LDO_7 },
{ .name = "ldo8", .driver_data = (void *)TPS6586X_ID_LDO_8 },
{ .name = "ldo9", .driver_data = (void *)TPS6586X_ID_LDO_9 },
{ .name = "ldo_rtc", .driver_data = (void *)TPS6586X_ID_LDO_RTC },
};

static struct tps6586x_platform_data *tps6586x_parse_dt(struct i2c_client *client)
{
const unsigned int num = ARRAY_SIZE(tps6586x_matches);
struct device_node *np = client->dev.of_node;
struct tps6586x_platform_data *pdata;
struct tps6586x_subdev_info *devs;
struct device_node *regs;
unsigned int count;
unsigned int i, j;
int err;

regs = of_find_node_by_name(np, "regulators");
if (!regs)
return NULL;

err = of_regulator_match(&client->dev, regs, tps6586x_matches, num);
if (err < 0) {
of_node_put(regs);
return NULL;
}

of_node_put(regs);
count = err;

devs = devm_kzalloc(&client->dev, count * sizeof(*devs), GFP_KERNEL);
if (!devs)
return NULL;

for (i = 0, j = 0; i < num && j < count; i++) {
if (!tps6586x_matches[i].init_data)
continue;

devs[j].name = "tps6586x-regulator";
devs[j].platform_data = tps6586x_matches[i].init_data;
devs[j].id = (int)tps6586x_matches[i].driver_data;
devs[j].of_node = tps6586x_matches[i].of_node;
j++;
}

pdata = devm_kzalloc(&client->dev, sizeof(*pdata), GFP_KERNEL);
if (!pdata)
return NULL;

pdata->num_subdevs = count;
pdata->subdevs = devs;
pdata->gpio_base = -1;
pdata->irq_base = -1;

return pdata;
}

static struct of_device_id tps6586x_of_match[] = {
{ .compatible = "ti,tps6586x", },
{ },
};
#else
static struct tps6586x_platform_data *tps6586x_parse_dt(struct i2c_client *client)
{
return NULL;
}
#endif

static int __devinit tps6586x_i2c_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
struct tps6586x_platform_data *pdata = client->dev.platform_data;
struct tps6586x *tps6586x;
int ret;

if (!pdata && client->dev.of_node)
pdata = tps6586x_parse_dt(client);

if (!pdata) {
dev_err(&client->dev, "tps6586x requires platform data\n");
return -ENOTSUPP;
Expand Down Expand Up @@ -573,6 +658,7 @@ static struct i2c_driver tps6586x_driver = {
.driver = {
.name = "tps6586x",
.owner = THIS_MODULE,
.of_match_table = of_match_ptr(tps6586x_of_match),
},
.probe = tps6586x_i2c_probe,
.remove = __devexit_p(tps6586x_i2c_remove),
Expand Down
7 changes: 0 additions & 7 deletions drivers/mfd/twl-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,13 +224,6 @@
#define HIGH_PERF_SQ (1 << 3)
#define CK32K_LOWPWR_EN (1 << 7)


/* chip-specific feature flags, for i2c_device_id.driver_data */
#define TWL4030_VAUX2 BIT(0) /* pre-5030 voltage ranges */
#define TPS_SUBSET BIT(1) /* tps659[23]0 have fewer LDOs */
#define TWL5031 BIT(2) /* twl5031 has different registers */
#define TWL6030_CLASS BIT(3) /* TWL6030 class */

/*----------------------------------------------------------------------*/

/* is driver active, bound to a chip? */
Expand Down
1 change: 0 additions & 1 deletion drivers/regulator/aat2870-regulator.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include <linux/err.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/delay.h>
#include <linux/platform_device.h>
#include <linux/regulator/driver.h>
#include <linux/regulator/machine.h>
Expand Down
1 change: 0 additions & 1 deletion drivers/regulator/ab3100.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/err.h>
#include <linux/delay.h>
#include <linux/platform_device.h>
#include <linux/regulator/driver.h>
#include <linux/mfd/abx500.h>
Expand Down
3 changes: 2 additions & 1 deletion drivers/regulator/da9052-regulator.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <linux/regulator/driver.h>
#include <linux/regulator/machine.h>
#ifdef CONFIG_OF
#include <linux/of.h>
#include <linux/regulator/of_regulator.h>
#endif

Expand Down Expand Up @@ -393,7 +394,7 @@ static int __devinit da9052_regulator_probe(struct platform_device *pdev)
if (!nproot)
return -ENODEV;

for (np = of_get_next_child(nproot, NULL); !np;
for (np = of_get_next_child(nproot, NULL); np;
np = of_get_next_child(nproot, np)) {
if (!of_node_cmp(np->name,
regulator->info->reg_desc.name)) {
Expand Down
4 changes: 3 additions & 1 deletion drivers/regulator/fixed.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#include <linux/regulator/driver.h>
#include <linux/regulator/fixed.h>
#include <linux/gpio.h>
#include <linux/delay.h>
#include <linux/slab.h>
#include <linux/of.h>
#include <linux/of_gpio.h>
Expand Down Expand Up @@ -91,6 +90,9 @@ of_get_fixed_voltage_config(struct device *dev)
if (of_find_property(np, "enable-active-high", NULL))
config->enable_high = true;

if (of_find_property(np, "gpio-open-drain", NULL))
config->gpio_is_open_drain = true;

return config;
}

Expand Down
1 change: 0 additions & 1 deletion drivers/regulator/gpio-regulator.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#include <linux/regulator/machine.h>
#include <linux/regulator/gpio-regulator.h>
#include <linux/gpio.h>
#include <linux/delay.h>
#include <linux/slab.h>

struct gpio_regulator_data {
Expand Down
1 change: 0 additions & 1 deletion drivers/regulator/isl6271a-regulator.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include <linux/platform_device.h>
#include <linux/regulator/driver.h>
#include <linux/i2c.h>
#include <linux/delay.h>
#include <linux/slab.h>

#define ISL6271A_VOLTAGE_MIN 850000
Expand Down
2 changes: 1 addition & 1 deletion drivers/regulator/max8660.c
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ static int __devinit max8660_probe(struct i2c_client *client,
return -EINVAL;
}

max8660 = kzalloc(sizeof(struct max8660) +
max8660 = devm_kzalloc(&client->dev, sizeof(struct max8660) +
sizeof(struct regulator_dev *) * MAX8660_V_END,
GFP_KERNEL);
if (!max8660)
Expand Down
13 changes: 4 additions & 9 deletions drivers/regulator/max8952.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,6 @@ static int max8952_write_reg(struct max8952_data *max8952,
return i2c_smbus_write_byte_data(max8952->client, reg, value);
}

static int max8952_voltage(struct max8952_data *max8952, u8 mode)
{
return (max8952->pdata->dvs_mode[mode] * 10 + 770) * 1000;
}

static int max8952_list_voltage(struct regulator_dev *rdev,
unsigned int selector)
{
Expand All @@ -82,7 +77,7 @@ static int max8952_list_voltage(struct regulator_dev *rdev,
if (rdev_get_id(rdev) != 0)
return -EINVAL;

return max8952_voltage(max8952, selector);
return (max8952->pdata->dvs_mode[selector] * 10 + 770) * 1000;
}

static int max8952_is_enabled(struct regulator_dev *rdev)
Expand Down Expand Up @@ -117,7 +112,7 @@ static int max8952_disable(struct regulator_dev *rdev)
return 0;
}

static int max8952_get_voltage(struct regulator_dev *rdev)
static int max8952_get_voltage_sel(struct regulator_dev *rdev)
{
struct max8952_data *max8952 = rdev_get_drvdata(rdev);
u8 vid = 0;
Expand All @@ -127,7 +122,7 @@ static int max8952_get_voltage(struct regulator_dev *rdev)
if (max8952->vid1)
vid += 2;

return max8952_voltage(max8952, vid);
return vid;
}

static int max8952_set_voltage_sel(struct regulator_dev *rdev,
Expand All @@ -154,7 +149,7 @@ static struct regulator_ops max8952_ops = {
.is_enabled = max8952_is_enabled,
.enable = max8952_enable,
.disable = max8952_disable,
.get_voltage = max8952_get_voltage,
.get_voltage_sel = max8952_get_voltage_sel,
.set_voltage_sel = max8952_set_voltage_sel,
.set_suspend_disable = max8952_disable,
};
Expand Down
Loading

0 comments on commit 5949a7e

Please sign in to comment.