From e953583456005823d7c20fefe5212f0f60a93fb6 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Sun, 1 Jun 2014 19:15:16 +0100 Subject: regulator: Don't disable unused regulators we don't have permission for In the spirit of conservatism that governs our general approach to permissions it is better if we don't touch regulators we weren't explicitly given permissions to control. This avoids the need to explicitly specify unknown regulators in DT as always on, if a regulator is not otherwise involved in software control it can be omitted from the DT. Regulators explicitly given constraints in DT still need to have an always on constraint specified as before. Signed-off-by: Mark Brown --- drivers/regulator/core.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'drivers/regulator') diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 9a09f3cdbabb..e3cb9b66731f 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -3819,8 +3819,9 @@ static int __init regulator_init_complete(void) mutex_lock(®ulator_list_mutex); /* If we have a full configuration then disable any regulators - * which are not in use or always_on. This will become the - * default behaviour in the future. + * we have permission to change the status for and which are + * not in use or always_on. This is effectively the default + * for DT and ACPI as they have full constraints. */ list_for_each_entry(rdev, ®ulator_list, list) { ops = rdev->desc->ops; @@ -3829,6 +3830,9 @@ static int __init regulator_init_complete(void) if (c && c->always_on) continue; + if (c && !(c->valid_ops_mask & REGULATOR_CHANGE_STATUS)) + continue; + mutex_lock(&rdev->mutex); if (rdev->use_count) -- cgit v1.2.3 From fd482a3e3e20cddfb6d775ec0382f98a92b8a25e Mon Sep 17 00:00:00 2001 From: Saravana Kannan Date: Wed, 23 Apr 2014 18:10:50 -0500 Subject: regulator: core: Disable unused regulators after deferred probing is done regulator_init_complete does a scan of regulators which dont have always-on or consumers are automatically disabled as being unused. However, with deferred probing, late_initcall() is too soon to declare a regulator as unused as the regulator itself might not have registered due to defferal - Example: A regulator deffered due to i2bus not available which in turn is deffered due to pinctrl availability. Since deferred probing is done in late_initcall(), do the cleanup of unused regulators by regulator_init_complete in late_initcall_sync instead of late_initcall. Cc: Liam Girdwood Cc: Mark Brown Cc: Markus Pargmann Signed-off-by: Saravana Kannan [nm@ti.com: minor rewording] Signed-off-by: Nishanth Menon Signed-off-by: Mark Brown --- drivers/regulator/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/regulator') diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index e3cb9b66731f..236ca3f1df73 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -3871,4 +3871,4 @@ unlock: return 0; } -late_initcall(regulator_init_complete); +late_initcall_sync(regulator_init_complete); -- cgit v1.2.3 From 064d5cd110f94ce41ca5681dcda8b77fa63d5b95 Mon Sep 17 00:00:00 2001 From: Alban Bedel Date: Tue, 20 May 2014 12:12:16 +0200 Subject: regulator: core: Fix the init of DT defined fixed regulators When a regulator is defined using DT and it has a single voltage the regulator init always tries to apply this voltage. However it fails if the regulator isn't settable because it is using an internal low level function. To overcome this we now first query the regulator and only set it if needed. Signed-off-by: Alban Bedel Signed-off-by: Mark Brown --- drivers/regulator/core.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'drivers/regulator') diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 236ca3f1df73..d70f00f8fc66 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -844,13 +844,22 @@ static int machine_constraints_voltage(struct regulator_dev *rdev, /* do we need to apply the constraint voltage */ if (rdev->constraints->apply_uV && rdev->constraints->min_uV == rdev->constraints->max_uV) { - ret = _regulator_do_set_voltage(rdev, - rdev->constraints->min_uV, - rdev->constraints->max_uV); - if (ret < 0) { - rdev_err(rdev, "failed to apply %duV constraint\n", - rdev->constraints->min_uV); - return ret; + int current_uV = _regulator_get_voltage(rdev); + if (current_uV < 0) { + rdev_err(rdev, "failed to get the current voltage\n"); + return current_uV; + } + if (current_uV < rdev->constraints->min_uV || + current_uV > rdev->constraints->max_uV) { + ret = _regulator_do_set_voltage( + rdev, rdev->constraints->min_uV, + rdev->constraints->max_uV); + if (ret < 0) { + rdev_err(rdev, + "failed to apply %duV constraint\n", + rdev->constraints->min_uV); + return ret; + } } } -- cgit v1.2.3