Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 292008
b: refs/heads/master
c: 6219929
h: refs/heads/master
v: v3
  • Loading branch information
Laxman Dewangan authored and Mark Brown committed Jan 20, 2012
1 parent e12dc08 commit dffaada
Show file tree
Hide file tree
Showing 7 changed files with 585 additions and 30 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 16fbcc3b1139e90fe560fde5619169db74dc02c2
refs/heads/master: 6219929f5f82708309b3054ec7db6cb6e3ee47d5
10 changes: 10 additions & 0 deletions trunk/drivers/regulator/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,16 @@ config REGULATOR_TPS65910
help
This driver supports TPS65910 voltage regulator chips.

config REGULATOR_TPS62360
tristate "TI TPS62360 Power Regulator"
depends on I2C
select REGMAP_I2C
help
This driver supports TPS62360 voltage regulator chip. This
regulator is meant for processor core supply. This chip is
high-frequency synchronous step down dc-dc converter optimized
for battery-powered portable applications.

config REGULATOR_AAT2870
tristate "AnalogicTech AAT2870 Regulators"
depends on MFD_AAT2870_CORE
Expand Down
1 change: 1 addition & 0 deletions trunk/drivers/regulator/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ obj-$(CONFIG_REGULATOR_ISL6271A) += isl6271a-regulator.o
obj-$(CONFIG_REGULATOR_AB8500) += ab8500.o
obj-$(CONFIG_REGULATOR_DB8500_PRCMU) += db8500-prcmu.o
obj-$(CONFIG_REGULATOR_TPS65910) += tps65910-regulator.o
obj-$(CONFIG_REGULATOR_TPS62360) += tps62360-regulator.o
obj-$(CONFIG_REGULATOR_AAT2870) += aat2870-regulator.o

ccflags-$(CONFIG_REGULATOR_DEBUG) += -DDEBUG
67 changes: 40 additions & 27 deletions trunk/drivers/regulator/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
*
*/

#define pr_fmt(fmt) "%s: " fmt, __func__

#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/debugfs.h>
Expand Down Expand Up @@ -52,7 +54,9 @@ static LIST_HEAD(regulator_map_list);
static bool has_full_constraints;
static bool board_wants_dummy_regulator;

#ifdef CONFIG_DEBUG_FS
static struct dentry *debugfs_root;
#endif

/*
* struct regulator_map
Expand Down Expand Up @@ -80,7 +84,9 @@ struct regulator {
char *supply_name;
struct device_attribute dev_attr;
struct regulator_dev *rdev;
#ifdef CONFIG_DEBUG_FS
struct dentry *debugfs;
#endif
};

static int _regulator_is_enabled(struct regulator_dev *rdev);
Expand Down Expand Up @@ -148,7 +154,7 @@ static struct device_node *of_get_regulator(struct device *dev, const char *supp
regnode = of_parse_phandle(dev->of_node, prop_name, 0);

if (!regnode) {
dev_dbg(dev, "Looking up %s property in node %s failed",
dev_warn(dev, "%s property in node %s references invalid phandle",
prop_name, dev->of_node->full_name);
return NULL;
}
Expand Down Expand Up @@ -801,11 +807,6 @@ static void print_constraints(struct regulator_dev *rdev)
count += sprintf(buf + count, "standby");

rdev_info(rdev, "%s\n", buf);

if ((constraints->min_uV != constraints->max_uV) &&
!(constraints->valid_ops_mask & REGULATOR_CHANGE_VOLTAGE))
rdev_warn(rdev,
"Voltage range but no REGULATOR_CHANGE_VOLTAGE\n");
}

static int machine_constraints_voltage(struct regulator_dev *rdev,
Expand Down Expand Up @@ -1141,10 +1142,12 @@ static struct regulator *create_regulator(struct regulator_dev *rdev,
goto attr_err;
}

#ifdef CONFIG_DEBUG_FS
regulator->debugfs = debugfs_create_dir(regulator->supply_name,
rdev->debugfs);
if (!regulator->debugfs) {
if (IS_ERR_OR_NULL(regulator->debugfs)) {
rdev_warn(rdev, "Failed to create debugfs directory\n");
regulator->debugfs = NULL;
} else {
debugfs_create_u32("uA_load", 0444, regulator->debugfs,
&regulator->uA_load);
Expand All @@ -1153,6 +1156,7 @@ static struct regulator *create_regulator(struct regulator_dev *rdev,
debugfs_create_u32("max_uV", 0444, regulator->debugfs,
&regulator->max_uV);
}
#endif

mutex_unlock(&rdev->mutex);
return regulator;
Expand Down Expand Up @@ -1361,7 +1365,9 @@ void regulator_put(struct regulator *regulator)
mutex_lock(&regulator_list_mutex);
rdev = regulator->rdev;

#ifdef CONFIG_DEBUG_FS
debugfs_remove_recursive(regulator->debugfs);
#endif

/* remove any sysfs entries */
if (regulator->dev) {
Expand Down Expand Up @@ -1836,12 +1842,8 @@ static int _regulator_do_set_voltage(struct regulator_dev *rdev,
if (ret < 0)
return ret;
old_selector = ret;
ret = rdev->desc->ops->set_voltage_time_sel(rdev,
delay = rdev->desc->ops->set_voltage_time_sel(rdev,
old_selector, selector);
if (ret < 0)
rdev_warn(rdev, "set_voltage_time_sel() failed: %d\n", ret);
else
delay = ret;
}

if (best_val != INT_MAX) {
Expand Down Expand Up @@ -2392,7 +2394,7 @@ int regulator_bulk_get(struct device *dev, int num_consumers,
return 0;

err:
while (--i >= 0)
for (i = 0; i < num_consumers && consumers[i].consumer; i++)
regulator_put(consumers[i].consumer);

return ret;
Expand Down Expand Up @@ -2442,9 +2444,12 @@ int regulator_bulk_enable(int num_consumers,
return 0;

err:
pr_err("Failed to enable %s: %d\n", consumers[i].supply, ret);
while (--i >= 0)
regulator_disable(consumers[i].consumer);
for (i = 0; i < num_consumers; i++)
if (consumers[i].ret == 0)
regulator_disable(consumers[i].consumer);
else
pr_err("Failed to enable %s: %d\n",
consumers[i].supply, consumers[i].ret);

return ret;
}
Expand All @@ -2458,8 +2463,8 @@ EXPORT_SYMBOL_GPL(regulator_bulk_enable);
* @return 0 on success, an errno on failure
*
* This convenience API allows consumers to disable multiple regulator
* clients in a single API call. If any consumers cannot be disabled
* then any others that were disabled will be enabled again prior to
* clients in a single API call. If any consumers cannot be enabled
* then any others that were disabled will be disabled again prior to
* return.
*/
int regulator_bulk_disable(int num_consumers,
Expand All @@ -2468,7 +2473,7 @@ int regulator_bulk_disable(int num_consumers,
int i;
int ret;

for (i = num_consumers - 1; i >= 0; --i) {
for (i = 0; i < num_consumers; i++) {
ret = regulator_disable(consumers[i].consumer);
if (ret != 0)
goto err;
Expand All @@ -2478,7 +2483,7 @@ int regulator_bulk_disable(int num_consumers,

err:
pr_err("Failed to disable %s: %d\n", consumers[i].supply, ret);
for (++i; i < num_consumers; ++i)
for (--i; i >= 0; --i)
regulator_enable(consumers[i].consumer);

return ret;
Expand Down Expand Up @@ -2705,16 +2710,19 @@ static int add_regulator_attributes(struct regulator_dev *rdev)

static void rdev_init_debugfs(struct regulator_dev *rdev)
{
#ifdef CONFIG_DEBUG_FS
rdev->debugfs = debugfs_create_dir(rdev_get_name(rdev), debugfs_root);
if (!rdev->debugfs) {
if (IS_ERR(rdev->debugfs) || !rdev->debugfs) {
rdev_warn(rdev, "Failed to create debugfs directory\n");
rdev->debugfs = NULL;
return;
}

debugfs_create_u32("use_count", 0444, rdev->debugfs,
&rdev->use_count);
debugfs_create_u32("open_count", 0444, rdev->debugfs,
&rdev->open_count);
#endif
}

/**
Expand Down Expand Up @@ -2892,7 +2900,9 @@ void regulator_unregister(struct regulator_dev *rdev)
return;

mutex_lock(&regulator_list_mutex);
#ifdef CONFIG_DEBUG_FS
debugfs_remove_recursive(rdev->debugfs);
#endif
flush_work_sync(&rdev->disable_work.work);
WARN_ON(rdev->open_count);
unset_regulator_supplies(rdev);
Expand Down Expand Up @@ -3102,27 +3112,30 @@ static ssize_t supply_map_read_file(struct file *file, char __user *user_buf,

return ret;
}
#endif

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

static int __init regulator_init(void)
{
int ret;

ret = class_register(&regulator_class);

#ifdef CONFIG_DEBUG_FS
debugfs_root = debugfs_create_dir("regulator", NULL);
if (!debugfs_root)
if (IS_ERR(debugfs_root) || !debugfs_root) {
pr_warn("regulator: Failed to create debugfs directory\n");
debugfs_root = NULL;
}

debugfs_create_file("supply_map", 0444, debugfs_root, NULL,
&supply_map_fops);
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 dffaada

Please sign in to comment.