Skip to content

Commit

Permalink
Merge branch 'for-linus' of git://opensource.wolfsonmicro.com/regulator
Browse files Browse the repository at this point in the history
* 'for-linus' of git://opensource.wolfsonmicro.com/regulator: (22 commits)
  regulator: Constify constraints name
  regulator: Fix possible nullpointer dereference in regulator_enable()
  regulator: gpio-regulator add dependency on GENERIC_GPIO
  regulator: Add module.h include to gpio-regulator
  regulator: Add driver for gpio-controlled regulators
  regulator: remove duplicate REG_CTRL2 defines in tps65023
  regulator: Clarify documentation for regulator-regulator supplies
  regulator: Fix some bitrot in the machine driver documentation
  regulator: tps65023: Added support for the similiar TPS65020 chip
  regulator: tps65023: Setting correct core regulator for tps65021
  regulator: tps65023: Set missing bit for update core-voltage
  regulator: tps65023: Fixes i2c configuration issues
  regulator: Add debugfs file showing the supply map table
  regulator: tps6586x: add SMx slew rate setting
  regulator: tps65023: Fixes i2c configuration issues
  regulator: tps6507x: Remove num_voltages array
  regulator: max8952: removed unused mutex.
  regulator: fix regulator/consumer.h kernel-doc warning
  regulator: Ensure enough enable time for max8649
  regulator: 88pm8607: Fix off-by-one value range checking in the case of no id is matched
  ...
  • Loading branch information
Linus Torvalds committed Nov 1, 2011
2 parents c18ae42 + 0151546 commit f3c3f06
Show file tree
Hide file tree
Showing 16 changed files with 721 additions and 48 deletions.
19 changes: 13 additions & 6 deletions Documentation/power/regulator/machine.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,21 @@ initialisation code by creating a struct regulator_consumer_supply for
each regulator.

struct regulator_consumer_supply {
struct device *dev; /* consumer */
const char *dev_name; /* consumer dev_name() */
const char *supply; /* consumer supply - e.g. "vcc" */
};

e.g. for the machine above

static struct regulator_consumer_supply regulator1_consumers[] = {
{
.dev = &platform_consumerB_device.dev,
.supply = "Vcc",
.dev_name = "dev_name(consumer B)",
.supply = "Vcc",
},};

static struct regulator_consumer_supply regulator2_consumers[] = {
{
.dev = &platform_consumerA_device.dev,
.dev = "dev_name(consumer A"),
.supply = "Vcc",
},};

Expand All @@ -43,6 +43,7 @@ to their supply regulator :-

static struct regulator_init_data regulator1_data = {
.constraints = {
.name = "Regulator-1",
.min_uV = 3300000,
.max_uV = 3300000,
.valid_modes_mask = REGULATOR_MODE_NORMAL,
Expand All @@ -51,13 +52,19 @@ static struct regulator_init_data regulator1_data = {
.consumer_supplies = regulator1_consumers,
};

The name field should be set to something that is usefully descriptive
for the board for configuration of supplies for other regulators and
for use in logging and other diagnostic output. Normally the name
used for the supply rail in the schematic is a good choice. If no
name is provided then the subsystem will choose one.

Regulator-1 supplies power to Regulator-2. This relationship must be registered
with the core so that Regulator-1 is also enabled when Consumer A enables its
supply (Regulator-2). The supply regulator is set by the supply_regulator
field below:-
field below and co:-

static struct regulator_init_data regulator2_data = {
.supply_regulator = "regulator_name",
.supply_regulator = "Regulator-1",
.constraints = {
.min_uV = 1800000,
.max_uV = 2000000,
Expand Down
2 changes: 1 addition & 1 deletion drivers/regulator/88pm8607.c
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ static int __devinit pm8607_regulator_probe(struct platform_device *pdev)
if (info->desc.id == res->start)
break;
}
if ((i < 0) || (i > PM8607_ID_RG_MAX)) {
if (i == ARRAY_SIZE(pm8607_regulator_info)) {
dev_err(&pdev->dev, "Failed to find regulator %llu\n",
(unsigned long long)res->start);
return -EINVAL;
Expand Down
10 changes: 10 additions & 0 deletions drivers/regulator/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,16 @@ config REGULATOR_USERSPACE_CONSUMER

If unsure, say no.

config REGULATOR_GPIO
tristate "GPIO regulator support"
depends on GENERIC_GPIO
help
This driver provides support for regulators that can be
controlled via gpios.
It is capable of supporting current and voltage regulators
and the platform has to provide a mapping of GPIO-states
to target volts/amps.

config REGULATOR_BQ24022
tristate "TI bq24022 Dual Input 1-Cell Li-Ion Charger IC"
help
Expand Down
1 change: 1 addition & 0 deletions drivers/regulator/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ obj-$(CONFIG_REGULATOR_FIXED_VOLTAGE) += fixed.o
obj-$(CONFIG_REGULATOR_VIRTUAL_CONSUMER) += virtual.o
obj-$(CONFIG_REGULATOR_USERSPACE_CONSUMER) += userspace-consumer.o

obj-$(CONFIG_REGULATOR_GPIO) += gpio-regulator.o
obj-$(CONFIG_REGULATOR_AD5398) += ad5398.o
obj-$(CONFIG_REGULATOR_BQ24022) += bq24022.o
obj-$(CONFIG_REGULATOR_LP3971) += lp3971.o
Expand Down
1 change: 1 addition & 0 deletions drivers/regulator/aat2870-regulator.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/err.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/delay.h>
#include <linux/platform_device.h>
Expand Down
43 changes: 42 additions & 1 deletion drivers/regulator/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1425,7 +1425,7 @@ int regulator_enable(struct regulator *regulator)
ret = _regulator_enable(rdev);
mutex_unlock(&rdev->mutex);

if (ret != 0)
if (ret != 0 && rdev->supply)
regulator_disable(rdev->supply);

return ret;
Expand Down Expand Up @@ -2971,6 +2971,43 @@ void *regulator_get_init_drvdata(struct regulator_init_data *reg_init_data)
}
EXPORT_SYMBOL_GPL(regulator_get_init_drvdata);

#ifdef CONFIG_DEBUG_FS
static ssize_t supply_map_read_file(struct file *file, char __user *user_buf,
size_t count, loff_t *ppos)
{
char *buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
ssize_t len, ret = 0;
struct regulator_map *map;

if (!buf)
return -ENOMEM;

list_for_each_entry(map, &regulator_map_list, list) {
len = snprintf(buf + ret, PAGE_SIZE - ret,
"%s -> %s.%s\n",
rdev_get_name(map->regulator), map->dev_name,
map->supply);
if (len >= 0)
ret += len;
if (ret > PAGE_SIZE) {
ret = PAGE_SIZE;
break;
}
}

ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret);

kfree(buf);

return ret;
}

static const struct file_operations supply_map_fops = {
.read = supply_map_read_file,
.llseek = default_llseek,
};
#endif

static int __init regulator_init(void)
{
int ret;
Expand All @@ -2983,6 +3020,10 @@ static int __init regulator_init(void)
pr_warn("regulator: Failed to create debugfs directory\n");
debugfs_root = NULL;
}

if (IS_ERR(debugfs_create_file("supply_map", 0444, debugfs_root,
NULL, &supply_map_fops)))
pr_warn("regulator: Failed to create supplies debugfs\n");
#endif

regulator_dummy_init();
Expand Down
Loading

0 comments on commit f3c3f06

Please sign in to comment.