aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator
diff options
context:
space:
mode:
authorMark Brown <broonie@linaro.org>2013-07-01 06:17:06 -0400
committerMark Brown <broonie@linaro.org>2013-07-01 06:17:06 -0400
commitc84130e7006cacf05e8691ed4d6e5796910dac03 (patch)
treecab75a73d18547cf7857b417c4d44fb6aa23f688 /drivers/regulator
parent28120bf84929167d2a712f037a960add5e1584f5 (diff)
parent08d49f4372ebee2b06d6988ecca37612fdc5b897 (diff)
Merge remote-tracking branch 'regulator/topic/ab8500' into regulator-next
Diffstat (limited to 'drivers/regulator')
-rw-r--r--drivers/regulator/Makefile2
-rw-r--r--drivers/regulator/ab8500-ext.c82
-rw-r--r--drivers/regulator/ab8500.c20
3 files changed, 84 insertions, 20 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
12obj-$(CONFIG_REGULATOR_88PM8607) += 88pm8607.o 12obj-$(CONFIG_REGULATOR_88PM8607) += 88pm8607.o
13obj-$(CONFIG_REGULATOR_AAT2870) += aat2870-regulator.o 13obj-$(CONFIG_REGULATOR_AAT2870) += aat2870-regulator.o
14obj-$(CONFIG_REGULATOR_AB3100) += ab3100.o 14obj-$(CONFIG_REGULATOR_AB3100) += ab3100.o
15obj-$(CONFIG_REGULATOR_AB8500) += ab8500.o ab8500-ext.o 15obj-$(CONFIG_REGULATOR_AB8500) += ab8500-ext.o ab8500.o
16obj-$(CONFIG_REGULATOR_AD5398) += ad5398.o 16obj-$(CONFIG_REGULATOR_AD5398) += ad5398.o
17obj-$(CONFIG_REGULATOR_ANATOP) += anatop-regulator.o 17obj-$(CONFIG_REGULATOR_ANATOP) += anatop-regulator.o
18obj-$(CONFIG_REGULATOR_ARIZONA) += arizona-micsupp.o arizona-ldo1.o 18obj-$(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 @@
16#include <linux/kernel.h> 16#include <linux/kernel.h>
17#include <linux/err.h> 17#include <linux/err.h>
18#include <linux/module.h> 18#include <linux/module.h>
19#include <linux/of.h>
19#include <linux/platform_device.h> 20#include <linux/platform_device.h>
20#include <linux/regulator/driver.h> 21#include <linux/regulator/driver.h>
21#include <linux/regulator/machine.h> 22#include <linux/regulator/machine.h>
23#include <linux/regulator/of_regulator.h>
22#include <linux/mfd/abx500.h> 24#include <linux/mfd/abx500.h>
23#include <linux/mfd/abx500/ab8500.h> 25#include <linux/mfd/abx500/ab8500.h>
24#include <linux/regulator/ab8500.h> 26#include <linux/regulator/ab8500.h>
@@ -229,6 +231,28 @@ static unsigned int ab8500_ext_regulator_get_mode(struct regulator_dev *rdev)
229 return ret; 231 return ret;
230} 232}
231 233
234static int ab8500_ext_set_voltage(struct regulator_dev *rdev, int min_uV,
235 int max_uV, unsigned *selector)
236{
237 struct regulation_constraints *regu_constraints = rdev->constraints;
238
239 if (!regu_constraints) {
240 dev_err(rdev_get_dev(rdev), "No regulator constraints\n");
241 return -EINVAL;
242 }
243
244 if (regu_constraints->min_uV == min_uV &&
245 regu_constraints->max_uV == max_uV)
246 return 0;
247
248 dev_err(rdev_get_dev(rdev),
249 "Requested min %duV max %duV != constrained min %duV max %duV\n",
250 min_uV, max_uV,
251 regu_constraints->min_uV, regu_constraints->max_uV);
252
253 return -EINVAL;
254}
255
232static int ab8500_ext_list_voltage(struct regulator_dev *rdev, 256static int ab8500_ext_list_voltage(struct regulator_dev *rdev,
233 unsigned selector) 257 unsigned selector)
234{ 258{
@@ -252,6 +276,7 @@ static struct regulator_ops ab8500_ext_regulator_ops = {
252 .is_enabled = ab8500_ext_regulator_is_enabled, 276 .is_enabled = ab8500_ext_regulator_is_enabled,
253 .set_mode = ab8500_ext_regulator_set_mode, 277 .set_mode = ab8500_ext_regulator_set_mode,
254 .get_mode = ab8500_ext_regulator_get_mode, 278 .get_mode = ab8500_ext_regulator_get_mode,
279 .set_voltage = ab8500_ext_set_voltage,
255 .list_voltage = ab8500_ext_list_voltage, 280 .list_voltage = ab8500_ext_list_voltage,
256}; 281};
257 282
@@ -310,18 +335,37 @@ static struct ab8500_ext_regulator_info
310 }, 335 },
311}; 336};
312 337
313int ab8500_ext_regulator_init(struct platform_device *pdev) 338static struct of_regulator_match ab8500_ext_regulator_match[] = {
339 { .name = "ab8500_ext1", .driver_data = (void *) AB8500_EXT_SUPPLY1, },
340 { .name = "ab8500_ext2", .driver_data = (void *) AB8500_EXT_SUPPLY2, },
341 { .name = "ab8500_ext3", .driver_data = (void *) AB8500_EXT_SUPPLY3, },
342};
343
344static int ab8500_ext_regulator_probe(struct platform_device *pdev)
314{ 345{
315 struct ab8500 *ab8500 = dev_get_drvdata(pdev->dev.parent); 346 struct ab8500 *ab8500 = dev_get_drvdata(pdev->dev.parent);
316 struct ab8500_platform_data *ppdata; 347 struct ab8500_platform_data *ppdata;
317 struct ab8500_regulator_platform_data *pdata; 348 struct ab8500_regulator_platform_data *pdata;
349 struct device_node *np = pdev->dev.of_node;
318 struct regulator_config config = { }; 350 struct regulator_config config = { };
319 int i, err; 351 int i, err;
320 352
353 if (np) {
354 err = of_regulator_match(&pdev->dev, np,
355 ab8500_ext_regulator_match,
356 ARRAY_SIZE(ab8500_ext_regulator_match));
357 if (err < 0) {
358 dev_err(&pdev->dev,
359 "Error parsing regulator init data: %d\n", err);
360 return err;
361 }
362 }
363
321 if (!ab8500) { 364 if (!ab8500) {
322 dev_err(&pdev->dev, "null mfd parent\n"); 365 dev_err(&pdev->dev, "null mfd parent\n");
323 return -EINVAL; 366 return -EINVAL;
324 } 367 }
368
325 ppdata = dev_get_platdata(ab8500->dev); 369 ppdata = dev_get_platdata(ab8500->dev);
326 if (!ppdata) { 370 if (!ppdata) {
327 dev_err(&pdev->dev, "null parent pdata\n"); 371 dev_err(&pdev->dev, "null parent pdata\n");
@@ -362,8 +406,11 @@ int ab8500_ext_regulator_init(struct platform_device *pdev)
362 pdata->ext_regulator[i].driver_data; 406 pdata->ext_regulator[i].driver_data;
363 407
364 config.dev = &pdev->dev; 408 config.dev = &pdev->dev;
365 config.init_data = &pdata->ext_regulator[i];
366 config.driver_data = info; 409 config.driver_data = info;
410 config.of_node = ab8500_ext_regulator_match[i].of_node;
411 config.init_data = (np) ?
412 ab8500_ext_regulator_match[i].init_data :
413 &pdata->ext_regulator[i];
367 414
368 /* register regulator with framework */ 415 /* register regulator with framework */
369 info->rdev = regulator_register(&info->desc, &config); 416 info->rdev = regulator_register(&info->desc, &config);
@@ -386,7 +433,7 @@ int ab8500_ext_regulator_init(struct platform_device *pdev)
386 return 0; 433 return 0;
387} 434}
388 435
389void ab8500_ext_regulator_exit(struct platform_device *pdev) 436static int ab8500_ext_regulator_remove(struct platform_device *pdev)
390{ 437{
391 int i; 438 int i;
392 439
@@ -399,7 +446,36 @@ void ab8500_ext_regulator_exit(struct platform_device *pdev)
399 446
400 regulator_unregister(info->rdev); 447 regulator_unregister(info->rdev);
401 } 448 }
449
450 return 0;
451}
452
453static struct platform_driver ab8500_ext_regulator_driver = {
454 .probe = ab8500_ext_regulator_probe,
455 .remove = ab8500_ext_regulator_remove,
456 .driver = {
457 .name = "ab8500-ext-regulator",
458 .owner = THIS_MODULE,
459 },
460};
461
462static int __init ab8500_ext_regulator_init(void)
463{
464 int ret;
465
466 ret = platform_driver_register(&ab8500_ext_regulator_driver);
467 if (ret)
468 pr_err("Failed to register ab8500 ext regulator: %d\n", ret);
469
470 return ret;
471}
472subsys_initcall(ab8500_ext_regulator_init);
473
474static void __exit ab8500_ext_regulator_exit(void)
475{
476 platform_driver_unregister(&ab8500_ext_regulator_driver);
402} 477}
478module_exit(ab8500_ext_regulator_exit);
403 479
404MODULE_LICENSE("GPL v2"); 480MODULE_LICENSE("GPL v2");
405MODULE_AUTHOR("Bengt Jonsson <bengt.g.jonsson@stericsson.com>"); 481MODULE_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
719 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages), 719 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
720 .volt_table = ldo_vauxn_voltages, 720 .volt_table = ldo_vauxn_voltages,
721 .enable_time = 200, 721 .enable_time = 200,
722 .supply_name = "vin",
722 }, 723 },
723 .load_lp_uA = 5000, 724 .load_lp_uA = 5000,
724 .update_bank = 0x04, 725 .update_bank = 0x04,
@@ -741,6 +742,7 @@ static struct ab8500_regulator_info
741 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages), 742 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
742 .volt_table = ldo_vauxn_voltages, 743 .volt_table = ldo_vauxn_voltages,
743 .enable_time = 200, 744 .enable_time = 200,
745 .supply_name = "vin",
744 }, 746 },
745 .load_lp_uA = 5000, 747 .load_lp_uA = 5000,
746 .update_bank = 0x04, 748 .update_bank = 0x04,
@@ -763,6 +765,7 @@ static struct ab8500_regulator_info
763 .n_voltages = ARRAY_SIZE(ldo_vaux3_voltages), 765 .n_voltages = ARRAY_SIZE(ldo_vaux3_voltages),
764 .volt_table = ldo_vaux3_voltages, 766 .volt_table = ldo_vaux3_voltages,
765 .enable_time = 450, 767 .enable_time = 450,
768 .supply_name = "vin",
766 }, 769 },
767 .load_lp_uA = 5000, 770 .load_lp_uA = 5000,
768 .update_bank = 0x04, 771 .update_bank = 0x04,
@@ -3156,22 +3159,12 @@ static int ab8500_regulator_probe(struct platform_device *pdev)
3156 return err; 3159 return err;
3157 } 3160 }
3158 3161
3159 if (!is_ab8505(ab8500)) {
3160 /* register external regulators (before Vaux1, 2 and 3) */
3161 err = ab8500_ext_regulator_init(pdev);
3162 if (err)
3163 return err;
3164 }
3165
3166 /* register all regulators */ 3162 /* register all regulators */
3167 for (i = 0; i < abx500_regulator.info_size; i++) { 3163 for (i = 0; i < abx500_regulator.info_size; i++) {
3168 err = ab8500_regulator_register(pdev, &pdata->regulator[i], 3164 err = ab8500_regulator_register(pdev, &pdata->regulator[i],
3169 i, NULL); 3165 i, NULL);
3170 if (err < 0) { 3166 if (err < 0)
3171 if (!is_ab8505(ab8500))
3172 ab8500_ext_regulator_exit(pdev);
3173 return err; 3167 return err;
3174 }
3175 } 3168 }
3176 3169
3177 return 0; 3170 return 0;
@@ -3180,7 +3173,6 @@ static int ab8500_regulator_probe(struct platform_device *pdev)
3180static int ab8500_regulator_remove(struct platform_device *pdev) 3173static int ab8500_regulator_remove(struct platform_device *pdev)
3181{ 3174{
3182 int i, err; 3175 int i, err;
3183 struct ab8500 *ab8500 = dev_get_drvdata(pdev->dev.parent);
3184 3176
3185 for (i = 0; i < abx500_regulator.info_size; i++) { 3177 for (i = 0; i < abx500_regulator.info_size; i++) {
3186 struct ab8500_regulator_info *info = NULL; 3178 struct ab8500_regulator_info *info = NULL;
@@ -3192,10 +3184,6 @@ static int ab8500_regulator_remove(struct platform_device *pdev)
3192 regulator_unregister(info->regulator); 3184 regulator_unregister(info->regulator);
3193 } 3185 }
3194 3186
3195 /* remove external regulators (after Vaux1, 2 and 3) */
3196 if (!is_ab8505(ab8500))
3197 ab8500_ext_regulator_exit(pdev);
3198
3199 /* remove regulator debug */ 3187 /* remove regulator debug */
3200 err = ab8500_regulator_debug_exit(pdev); 3188 err = ab8500_regulator_debug_exit(pdev);
3201 if (err) 3189 if (err)