aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Brown <broonie@linaro.org>2013-07-01 11:17:06 +0100
committerMark Brown <broonie@linaro.org>2013-07-01 11:17:06 +0100
commitc84130e7006cacf05e8691ed4d6e5796910dac03 (patch)
treecab75a73d18547cf7857b417c4d44fb6aa23f688
parentMerge remote-tracking branch 'regulator/fix/max77693' into regulator-linus (diff)
parentregulator: ab8500-ext: Staticize local symbols (diff)
downloadlinux-dev-c84130e7006cacf05e8691ed4d6e5796910dac03.tar.xz
linux-dev-c84130e7006cacf05e8691ed4d6e5796910dac03.zip
Merge remote-tracking branch 'regulator/topic/ab8500' into regulator-next
-rw-r--r--drivers/regulator/Makefile2
-rw-r--r--drivers/regulator/ab8500-ext.c82
-rw-r--r--drivers/regulator/ab8500.c20
-rw-r--r--include/linux/regulator/ab8500.h4
4 files changed, 84 insertions, 24 deletions
diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile
index a4094cd274be..c4b50fc7f44f 100644
--- a/drivers/regulator/Makefile
+++ b/drivers/regulator/Makefile
@@ -12,7 +12,7 @@ obj-$(CONFIG_REGULATOR_USERSPACE_CONSUMER) += userspace-consumer.o
obj-$(CONFIG_REGULATOR_88PM8607) += 88pm8607.o
obj-$(CONFIG_REGULATOR_AAT2870) += aat2870-regulator.o
obj-$(CONFIG_REGULATOR_AB3100) += ab3100.o
-obj-$(CONFIG_REGULATOR_AB8500) += ab8500.o ab8500-ext.o
+obj-$(CONFIG_REGULATOR_AB8500) += ab8500-ext.o ab8500.o
obj-$(CONFIG_REGULATOR_AD5398) += ad5398.o
obj-$(CONFIG_REGULATOR_ANATOP) += anatop-regulator.o
obj-$(CONFIG_REGULATOR_ARIZONA) += arizona-micsupp.o arizona-ldo1.o
diff --git a/drivers/regulator/ab8500-ext.c b/drivers/regulator/ab8500-ext.c
index b4d45472aae6..02ff691cdb8b 100644
--- a/drivers/regulator/ab8500-ext.c
+++ b/drivers/regulator/ab8500-ext.c
@@ -16,9 +16,11 @@
#include <linux/kernel.h>
#include <linux/err.h>
#include <linux/module.h>
+#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/regulator/driver.h>
#include <linux/regulator/machine.h>
+#include <linux/regulator/of_regulator.h>
#include <linux/mfd/abx500.h>
#include <linux/mfd/abx500/ab8500.h>
#include <linux/regulator/ab8500.h>
@@ -229,6 +231,28 @@ static unsigned int ab8500_ext_regulator_get_mode(struct regulator_dev *rdev)
return ret;
}
+static int ab8500_ext_set_voltage(struct regulator_dev *rdev, int min_uV,
+ int max_uV, unsigned *selector)
+{
+ struct regulation_constraints *regu_constraints = rdev->constraints;
+
+ if (!regu_constraints) {
+ dev_err(rdev_get_dev(rdev), "No regulator constraints\n");
+ return -EINVAL;
+ }
+
+ if (regu_constraints->min_uV == min_uV &&
+ regu_constraints->max_uV == max_uV)
+ return 0;
+
+ dev_err(rdev_get_dev(rdev),
+ "Requested min %duV max %duV != constrained min %duV max %duV\n",
+ min_uV, max_uV,
+ regu_constraints->min_uV, regu_constraints->max_uV);
+
+ return -EINVAL;
+}
+
static int ab8500_ext_list_voltage(struct regulator_dev *rdev,
unsigned selector)
{
@@ -252,6 +276,7 @@ static struct regulator_ops ab8500_ext_regulator_ops = {
.is_enabled = ab8500_ext_regulator_is_enabled,
.set_mode = ab8500_ext_regulator_set_mode,
.get_mode = ab8500_ext_regulator_get_mode,
+ .set_voltage = ab8500_ext_set_voltage,
.list_voltage = ab8500_ext_list_voltage,
};
@@ -310,18 +335,37 @@ static struct ab8500_ext_regulator_info
},
};
-int ab8500_ext_regulator_init(struct platform_device *pdev)
+static struct of_regulator_match ab8500_ext_regulator_match[] = {
+ { .name = "ab8500_ext1", .driver_data = (void *) AB8500_EXT_SUPPLY1, },
+ { .name = "ab8500_ext2", .driver_data = (void *) AB8500_EXT_SUPPLY2, },
+ { .name = "ab8500_ext3", .driver_data = (void *) AB8500_EXT_SUPPLY3, },
+};
+
+static int ab8500_ext_regulator_probe(struct platform_device *pdev)
{
struct ab8500 *ab8500 = dev_get_drvdata(pdev->dev.parent);
struct ab8500_platform_data *ppdata;
struct ab8500_regulator_platform_data *pdata;
+ struct device_node *np = pdev->dev.of_node;
struct regulator_config config = { };
int i, err;
+ if (np) {
+ err = of_regulator_match(&pdev->dev, np,
+ ab8500_ext_regulator_match,
+ ARRAY_SIZE(ab8500_ext_regulator_match));
+ if (err < 0) {
+ dev_err(&pdev->dev,
+ "Error parsing regulator init data: %d\n", err);
+ return err;
+ }
+ }
+
if (!ab8500) {
dev_err(&pdev->dev, "null mfd parent\n");
return -EINVAL;
}
+
ppdata = dev_get_platdata(ab8500->dev);
if (!ppdata) {
dev_err(&pdev->dev, "null parent pdata\n");
@@ -362,8 +406,11 @@ int ab8500_ext_regulator_init(struct platform_device *pdev)
pdata->ext_regulator[i].driver_data;
config.dev = &pdev->dev;
- config.init_data = &pdata->ext_regulator[i];
config.driver_data = info;
+ config.of_node = ab8500_ext_regulator_match[i].of_node;
+ config.init_data = (np) ?
+ ab8500_ext_regulator_match[i].init_data :
+ &pdata->ext_regulator[i];
/* register regulator with framework */
info->rdev = regulator_register(&info->desc, &config);
@@ -386,7 +433,7 @@ int ab8500_ext_regulator_init(struct platform_device *pdev)
return 0;
}
-void ab8500_ext_regulator_exit(struct platform_device *pdev)
+static int ab8500_ext_regulator_remove(struct platform_device *pdev)
{
int i;
@@ -399,7 +446,36 @@ void ab8500_ext_regulator_exit(struct platform_device *pdev)
regulator_unregister(info->rdev);
}
+
+ return 0;
+}
+
+static struct platform_driver ab8500_ext_regulator_driver = {
+ .probe = ab8500_ext_regulator_probe,
+ .remove = ab8500_ext_regulator_remove,
+ .driver = {
+ .name = "ab8500-ext-regulator",
+ .owner = THIS_MODULE,
+ },
+};
+
+static int __init ab8500_ext_regulator_init(void)
+{
+ int ret;
+
+ ret = platform_driver_register(&ab8500_ext_regulator_driver);
+ if (ret)
+ pr_err("Failed to register ab8500 ext regulator: %d\n", ret);
+
+ return ret;
+}
+subsys_initcall(ab8500_ext_regulator_init);
+
+static void __exit ab8500_ext_regulator_exit(void)
+{
+ platform_driver_unregister(&ab8500_ext_regulator_driver);
}
+module_exit(ab8500_ext_regulator_exit);
MODULE_LICENSE("GPL v2");
MODULE_AUTHOR("Bengt Jonsson <bengt.g.jonsson@stericsson.com>");
diff --git a/drivers/regulator/ab8500.c b/drivers/regulator/ab8500.c
index f6656b8c28b6..bb02108c95e1 100644
--- a/drivers/regulator/ab8500.c
+++ b/drivers/regulator/ab8500.c
@@ -719,6 +719,7 @@ static struct ab8500_regulator_info
.n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
.volt_table = ldo_vauxn_voltages,
.enable_time = 200,
+ .supply_name = "vin",
},
.load_lp_uA = 5000,
.update_bank = 0x04,
@@ -741,6 +742,7 @@ static struct ab8500_regulator_info
.n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
.volt_table = ldo_vauxn_voltages,
.enable_time = 200,
+ .supply_name = "vin",
},
.load_lp_uA = 5000,
.update_bank = 0x04,
@@ -763,6 +765,7 @@ static struct ab8500_regulator_info
.n_voltages = ARRAY_SIZE(ldo_vaux3_voltages),
.volt_table = ldo_vaux3_voltages,
.enable_time = 450,
+ .supply_name = "vin",
},
.load_lp_uA = 5000,
.update_bank = 0x04,
@@ -3156,22 +3159,12 @@ static int ab8500_regulator_probe(struct platform_device *pdev)
return err;
}
- if (!is_ab8505(ab8500)) {
- /* register external regulators (before Vaux1, 2 and 3) */
- err = ab8500_ext_regulator_init(pdev);
- if (err)
- return err;
- }
-
/* register all regulators */
for (i = 0; i < abx500_regulator.info_size; i++) {
err = ab8500_regulator_register(pdev, &pdata->regulator[i],
i, NULL);
- if (err < 0) {
- if (!is_ab8505(ab8500))
- ab8500_ext_regulator_exit(pdev);
+ if (err < 0)
return err;
- }
}
return 0;
@@ -3180,7 +3173,6 @@ static int ab8500_regulator_probe(struct platform_device *pdev)
static int ab8500_regulator_remove(struct platform_device *pdev)
{
int i, err;
- struct ab8500 *ab8500 = dev_get_drvdata(pdev->dev.parent);
for (i = 0; i < abx500_regulator.info_size; i++) {
struct ab8500_regulator_info *info = NULL;
@@ -3192,10 +3184,6 @@ static int ab8500_regulator_remove(struct platform_device *pdev)
regulator_unregister(info->regulator);
}
- /* remove external regulators (after Vaux1, 2 and 3) */
- if (!is_ab8505(ab8500))
- ab8500_ext_regulator_exit(pdev);
-
/* remove regulator debug */
err = ab8500_regulator_debug_exit(pdev);
if (err)
diff --git a/include/linux/regulator/ab8500.h b/include/linux/regulator/ab8500.h
index 7c5ff0c55773..75307447cef9 100644
--- a/include/linux/regulator/ab8500.h
+++ b/include/linux/regulator/ab8500.h
@@ -336,8 +336,4 @@ static inline int ab8500_regulator_debug_exit(struct platform_device *pdev)
}
#endif
-/* AB8500 external regulator functions. */
-int ab8500_ext_regulator_init(struct platform_device *pdev);
-void ab8500_ext_regulator_exit(struct platform_device *pdev);
-
#endif