summaryrefslogtreecommitdiff
path: root/drivers/regulator/mc13xxx-regulator-core.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-01-10 22:20:34 +0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-01-10 22:20:34 +0400
commit269d430131b699c2cadf58495f025a4092959ef5 (patch)
treed9972cd7e03f82b6ac59bc471fb59e49dc6fcaab /drivers/regulator/mc13xxx-regulator-core.c
parentd52739c62e0096dccea59f012d80256c6e359a98 (diff)
parent0c437c4ae71c0a8110eb21c06b99853c7056b317 (diff)
downloadlinux-269d430131b699c2cadf58495f025a4092959ef5.tar.xz
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator: (40 commits) regulator: set constraints.apply_uV to 0 in of_get_fixed_voltage_config regulator: max8925: fix enabled/disabled judgement mistake regulator: add regulator_bulk_force_disable function regulator: pass regulator_register of_node in fixed voltage driver regulator: add regulator_force_disable() definition for !CONFIG_REGULATOR regulator: Enable supply regulator if child rail is enabled. regulator: mc13892: Convert to devm_kzalloc() regulator: mc13783: Convert to devm_kzalloc() regulator: Fix checking return value of create_regulator regulator: Fix the error handling if create_regulator fails regulator: Export regulator_is_supported_voltage() regulator: mc13892: add device tree probe support regulator: mc13892: remove the unnecessary prefix from regulator name regulator: Convert wm831x regulator drivers to devm_kzalloc() regulator: da9052: Staticize non-exported symbols regulator: Replace kzalloc with devm_kzalloc and if-else with a switch-case for da9052-regulator regulator: Update da9052-regulator for DT changes regulator: DA9052/53 Regulator support regulator: pass device_node to of_get_regulator_init_data() regulator: If a single voltage is set with device tree then set apply_uV ...
Diffstat (limited to 'drivers/regulator/mc13xxx-regulator-core.c')
-rw-r--r--drivers/regulator/mc13xxx-regulator-core.c57
1 files changed, 57 insertions, 0 deletions
diff --git a/drivers/regulator/mc13xxx-regulator-core.c b/drivers/regulator/mc13xxx-regulator-core.c
index 6532853a6ef5..80ecafef1bc3 100644
--- a/drivers/regulator/mc13xxx-regulator-core.c
+++ b/drivers/regulator/mc13xxx-regulator-core.c
@@ -18,12 +18,14 @@
#include <linux/mfd/mc13xxx.h>
#include <linux/regulator/machine.h>
#include <linux/regulator/driver.h>
+#include <linux/regulator/of_regulator.h>
#include <linux/platform_device.h>
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/init.h>
#include <linux/err.h>
#include <linux/module.h>
+#include <linux/of.h>
#include "mc13xxx.h"
static int mc13xxx_regulator_enable(struct regulator_dev *rdev)
@@ -236,6 +238,61 @@ int mc13xxx_sw_regulator_is_enabled(struct regulator_dev *rdev)
}
EXPORT_SYMBOL_GPL(mc13xxx_sw_regulator_is_enabled);
+#ifdef CONFIG_OF
+int __devinit mc13xxx_get_num_regulators_dt(struct platform_device *pdev)
+{
+ struct device_node *parent, *child;
+ int num = 0;
+
+ of_node_get(pdev->dev.parent->of_node);
+ parent = of_find_node_by_name(pdev->dev.parent->of_node, "regulators");
+ if (!parent)
+ return -ENODEV;
+
+ for_each_child_of_node(parent, child)
+ num++;
+
+ return num;
+}
+
+struct mc13xxx_regulator_init_data * __devinit mc13xxx_parse_regulators_dt(
+ struct platform_device *pdev, struct mc13xxx_regulator *regulators,
+ int num_regulators)
+{
+ struct mc13xxx_regulator_priv *priv = platform_get_drvdata(pdev);
+ struct mc13xxx_regulator_init_data *data, *p;
+ struct device_node *parent, *child;
+ int i;
+
+ of_node_get(pdev->dev.parent->of_node);
+ parent = of_find_node_by_name(pdev->dev.parent->of_node, "regulators");
+ if (!parent)
+ return NULL;
+
+ data = devm_kzalloc(&pdev->dev, sizeof(*data) * priv->num_regulators,
+ GFP_KERNEL);
+ if (!data)
+ return NULL;
+ p = data;
+
+ for_each_child_of_node(parent, child) {
+ for (i = 0; i < num_regulators; i++) {
+ if (!of_node_cmp(child->name,
+ regulators[i].desc.name)) {
+ p->id = i;
+ p->init_data = of_get_regulator_init_data(
+ &pdev->dev, child);
+ p->node = child;
+ p++;
+ break;
+ }
+ }
+ }
+
+ return data;
+}
+#endif
+
MODULE_LICENSE("GPL v2");
MODULE_AUTHOR("Yong Shen <yong.shen@linaro.org>");
MODULE_DESCRIPTION("Regulator Driver for Freescale MC13xxx PMIC");