From 1e1bb58da2ae080002578c35f80495dadda50940 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Fri, 7 Jun 2013 17:11:24 +0100 Subject: regulator: ab8500: Ensure AB8500 external registers are probed first This patch changes the order in which the AB8500 regulator drivers are registered and subsequently probed. It saves a lot of -EPROBE_DEFEER nonsense and bootlog noise, as some AB8500 core regulators depend on the external ones for supply voltage. Signed-off-by: Lee Jones Signed-off-by: Mark Brown --- drivers/regulator/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/regulator') diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile index 47a34ff88f98..0f4964ee5d30 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 -- cgit 1.4.1 From 33fb880249b1f2f349461c64d19bdfe2e969c1ba Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Fri, 7 Jun 2013 17:11:25 +0100 Subject: regulator: ab8500-ext: Provide a set_voltage call-back operation When registering regulators which have a single voltage through Device Tree, the framework insists that the specified voltage is actually set. Well in order to do that we need to provide this call-back, where we check that the value is sane and return without error. Not that the selector isn't populated, but in our case list_voltage doesn't actually use it, so we're good. Signed-off-by: Lee Jones Signed-off-by: Mark Brown --- drivers/regulator/ab8500-ext.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'drivers/regulator') diff --git a/drivers/regulator/ab8500-ext.c b/drivers/regulator/ab8500-ext.c index b4d45472aae6..e4975bc61e81 100644 --- a/drivers/regulator/ab8500-ext.c +++ b/drivers/regulator/ab8500-ext.c @@ -229,6 +229,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 +274,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, }; -- cgit 1.4.1 From 5a49b4a527e5b72ae3a4f64f078759f83fbd98b5 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Fri, 7 Jun 2013 17:11:26 +0100 Subject: regulator: ab8500-ext: Register as a device in its own right Some platforms don't support the AB8500 external regulators, so instead of having a list of is_() calls prior to calling ab8500_ext_regulator_init() from ab8500_regulator_probe(), we can only register as a platform device on platforms which require them. It means we also have more control over them when booting with Device Tree. Signed-off-by: Lee Jones Signed-off-by: Mark Brown --- drivers/regulator/ab8500-ext.c | 33 +++++++++++++++++++++++++++++++-- drivers/regulator/ab8500.c | 17 +---------------- include/linux/regulator/ab8500.h | 4 ---- 3 files changed, 32 insertions(+), 22 deletions(-) (limited to 'drivers/regulator') diff --git a/drivers/regulator/ab8500-ext.c b/drivers/regulator/ab8500-ext.c index e4975bc61e81..95f495f51d00 100644 --- a/drivers/regulator/ab8500-ext.c +++ b/drivers/regulator/ab8500-ext.c @@ -333,7 +333,7 @@ static struct ab8500_ext_regulator_info }, }; -int ab8500_ext_regulator_init(struct platform_device *pdev) +int ab8500_ext_regulator_probe(struct platform_device *pdev) { struct ab8500 *ab8500 = dev_get_drvdata(pdev->dev.parent); struct ab8500_platform_data *ppdata; @@ -409,7 +409,7 @@ int ab8500_ext_regulator_init(struct platform_device *pdev) return 0; } -void ab8500_ext_regulator_exit(struct platform_device *pdev) +int ab8500_ext_regulator_remove(struct platform_device *pdev) { int i; @@ -422,7 +422,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 "); diff --git a/drivers/regulator/ab8500.c b/drivers/regulator/ab8500.c index f6656b8c28b6..dfc790196b34 100644 --- a/drivers/regulator/ab8500.c +++ b/drivers/regulator/ab8500.c @@ -3156,22 +3156,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 +3170,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 +3181,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 -- cgit 1.4.1 From 30aa4b26c00f5c5ae6081f85e7adca47dcb24e29 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Fri, 7 Jun 2013 17:11:27 +0100 Subject: regulator: ab8500-ext: Enable for Device Tree Here we use the OF regulator match facility to collect and populate initialisation data from Device Tree if we're booting with it enabled. Signed-off-by: Lee Jones Signed-off-by: Mark Brown --- drivers/regulator/ab8500-ext.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'drivers/regulator') diff --git a/drivers/regulator/ab8500-ext.c b/drivers/regulator/ab8500-ext.c index 95f495f51d00..4137a2fe42c3 100644 --- a/drivers/regulator/ab8500-ext.c +++ b/drivers/regulator/ab8500-ext.c @@ -16,9 +16,11 @@ #include #include #include +#include #include #include #include +#include #include #include #include @@ -333,18 +335,37 @@ static struct ab8500_ext_regulator_info }, }; +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, }, +}; + 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"); @@ -385,8 +406,11 @@ int ab8500_ext_regulator_probe(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); -- cgit 1.4.1 From ce6f5ea3a7240c15e5775d5b9c5c57629943ca6c Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Fri, 7 Jun 2013 17:11:28 +0100 Subject: regulator: ab8500: Provide supply names for the AUX regulators On some platforms the AUX[1|2|3] regulators are supplied voltage by a separate regulator. For example on Snowball these are provided by the EXT3. If we list them here, we can supply voltage to them by simply listing them in as a consumer of EXT3 in the Snowball case. Signed-off-by: Lee Jones Signed-off-by: Mark Brown --- drivers/regulator/ab8500.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'drivers/regulator') diff --git a/drivers/regulator/ab8500.c b/drivers/regulator/ab8500.c index dfc790196b34..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, -- cgit 1.4.1 From 08d49f4372ebee2b06d6988ecca37612fdc5b897 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Wed, 26 Jun 2013 10:13:37 +0530 Subject: regulator: ab8500-ext: Staticize local symbols Local symbols used only in this file are made static. Signed-off-by: Sachin Kamat Signed-off-by: Mark Brown --- drivers/regulator/ab8500-ext.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/regulator') diff --git a/drivers/regulator/ab8500-ext.c b/drivers/regulator/ab8500-ext.c index 4137a2fe42c3..02ff691cdb8b 100644 --- a/drivers/regulator/ab8500-ext.c +++ b/drivers/regulator/ab8500-ext.c @@ -341,7 +341,7 @@ static struct of_regulator_match ab8500_ext_regulator_match[] = { { .name = "ab8500_ext3", .driver_data = (void *) AB8500_EXT_SUPPLY3, }, }; -int ab8500_ext_regulator_probe(struct platform_device *pdev) +static int ab8500_ext_regulator_probe(struct platform_device *pdev) { struct ab8500 *ab8500 = dev_get_drvdata(pdev->dev.parent); struct ab8500_platform_data *ppdata; @@ -433,7 +433,7 @@ int ab8500_ext_regulator_probe(struct platform_device *pdev) return 0; } -int ab8500_ext_regulator_remove(struct platform_device *pdev) +static int ab8500_ext_regulator_remove(struct platform_device *pdev) { int i; -- cgit 1.4.1