aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator/of_regulator.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-07-22 13:05:23 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2012-07-22 13:05:23 -0700
commit4d460fd3abf9a14e21d55ab9b67b6c58e26398eb (patch)
tree601bded16bf110f72d2c9c04d121325387440a6a /drivers/regulator/of_regulator.c
parentMerge tag 'regmap-3.6' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap (diff)
parentMerge branch 'regulator-drivers' into regulator-next (diff)
downloadlinux-dev-4d460fd3abf9a14e21d55ab9b67b6c58e26398eb.tar.xz
linux-dev-4d460fd3abf9a14e21d55ab9b67b6c58e26398eb.zip
Merge tag 'regulator-3.6' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator
Pull regulator updates from Mark Brown: "Lots and lots of fixes from Axel and some others here, plus some framework enhancements which continue the theme of factoring code out of the drivers and into the core. - Initial framework support for GPIO controlled enable signals, saving a bunch of code in drivers. - Move fixed regulator enable time and voltage mapping table specifications to data. - Used some of the recent framework enhancements to make voltage change notifications more useful, passing the voltage in as an argument to the notification. - Fixed the pattern used for finding individual regulators on a device to not rely on the node name, supporting the use of multiple PMICs of the same type in the system. - New drivers for Maxim MAX77686, TI LP872x and LP8788, Samsung S2MPS11, and Wolfson Arizona microphone supplies and LDOs." * tag 'regulator-3.6' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator: (176 commits) regulator: add new lp8788 regulator driver regulator: mc13xxx: Remove extern function declaration for mc13xxx_sw_regulator regulator: tps65910: set input_supply on desc unconditionally regulator: palmas: Fix calcuating selector in palmas_map_voltage_smps regulator: lp872x: Simplify implementation of lp872x_find_regulator_init_data() regulator: twl: Fix list_voltate for twl6030ldo_ops regulator: twl: Convert twl6030ldo_ops to [get|set]_voltage_sel regulator: twl: Fix the formula to calculate vsel and voltage for twl6030ldo regulator: s5m8767: Properly handle gpio_request failure regulator: max8997: Properly handle gpio_request failure regulator: tps62360: use devm_* for gpio request regulator: tps6586x: add support for input supply regulator: tps65217: Add device tree support regulator: aat2870: Remove unused min_uV and max_uV from struct aat2870_regulator regulator: aat2870: Convert to regulator_list_voltage_table regulator: da9052: initialize of_node param for regulator register regulator: Add REGULATOR_STATUS_UNDEFINED. regulator: Fix a typo in regulator_mode_to_status() core function. regulator: s2mps11: Use sec_reg_write rather than sec_reg_update when mask is 0xff regulator: s2mps11: Fix wrong setting for config.dev ...
Diffstat (limited to 'drivers/regulator/of_regulator.c')
-rw-r--r--drivers/regulator/of_regulator.c57
1 files changed, 38 insertions, 19 deletions
diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regulator.c
index 56593b75168a..3e4106f2bda9 100644
--- a/drivers/regulator/of_regulator.c
+++ b/drivers/regulator/of_regulator.c
@@ -20,7 +20,7 @@ static void of_get_regulation_constraints(struct device_node *np,
struct regulator_init_data **init_data)
{
const __be32 *min_uV, *max_uV, *uV_offset;
- const __be32 *min_uA, *max_uA;
+ const __be32 *min_uA, *max_uA, *ramp_delay;
struct regulation_constraints *constraints = &(*init_data)->constraints;
constraints->name = of_get_property(np, "regulator-name", NULL);
@@ -60,6 +60,10 @@ static void of_get_regulation_constraints(struct device_node *np,
constraints->always_on = true;
else /* status change should be possible if not always on. */
constraints->valid_ops_mask |= REGULATOR_CHANGE_STATUS;
+
+ ramp_delay = of_get_property(np, "regulator-ramp-delay", NULL);
+ if (ramp_delay)
+ constraints->ramp_delay = be32_to_cpu(*ramp_delay);
}
/**
@@ -88,15 +92,17 @@ struct regulator_init_data *of_get_regulator_init_data(struct device *dev,
EXPORT_SYMBOL_GPL(of_get_regulator_init_data);
/**
- * of_regulator_match - extract regulator init data
+ * of_regulator_match - extract regulator init data when node
+ * property "regulator-compatible" matches with the regulator name.
* @dev: device requesting the data
* @node: parent device node of the regulators
* @matches: match table for the regulators
* @num_matches: number of entries in match table
*
* This function uses a match table specified by the regulator driver and
- * looks up the corresponding init data in the device tree. Note that the
- * match table is modified in place.
+ * looks up the corresponding init data in the device tree if
+ * regulator-compatible matches. Note that the match table is modified
+ * in place.
*
* Returns the number of matches found or a negative error code on failure.
*/
@@ -106,27 +112,40 @@ int of_regulator_match(struct device *dev, struct device_node *node,
{
unsigned int count = 0;
unsigned int i;
+ const char *regulator_comp;
+ struct device_node *child;
if (!dev || !node)
return -EINVAL;
- for (i = 0; i < num_matches; i++) {
- struct of_regulator_match *match = &matches[i];
- struct device_node *child;
-
- child = of_find_node_by_name(node, match->name);
- if (!child)
- continue;
-
- match->init_data = of_get_regulator_init_data(dev, child);
- if (!match->init_data) {
- dev_err(dev, "failed to parse DT for regulator %s\n",
+ for_each_child_of_node(node, child) {
+ regulator_comp = of_get_property(child,
+ "regulator-compatible", NULL);
+ if (!regulator_comp) {
+ dev_err(dev, "regulator-compatible is missing for node %s\n",
child->name);
- return -EINVAL;
+ continue;
+ }
+ for (i = 0; i < num_matches; i++) {
+ struct of_regulator_match *match = &matches[i];
+ if (match->of_node)
+ continue;
+
+ if (strcmp(match->name, regulator_comp))
+ continue;
+
+ match->init_data =
+ of_get_regulator_init_data(dev, child);
+ if (!match->init_data) {
+ dev_err(dev,
+ "failed to parse DT for regulator %s\n",
+ child->name);
+ return -EINVAL;
+ }
+ match->of_node = child;
+ count++;
+ break;
}
-
- match->of_node = child;
- count++;
}
return count;