summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaxman Dewangan <ldewangan@nvidia.com>2014-06-03 12:32:11 +0530
committerTony Ly <tly@nvidia.com>2014-06-05 11:59:12 -0700
commit92ff6eb49b90fc33fd5072025d8a9263b0eb4ca6 (patch)
tree2ef7a8f2650c0affd50d3885632419d427e25a82
parent7b984f4acadbd156a8925120b580e92a6b55e1ac (diff)
regulator: core: add support for disabling parent after enabling rail.
Add support on core driver of regulator to disable parent once the regulator enable. This is needed for some specific purpose to handle overcurrent on parent rail due to enabling the rail. bug 1494740 Change-Id: I95084243975ca5298abbaa23a31007413bdca7a9 Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com> Reviewed-on: http://git-master/r/418143 (cherry picked from commit a65d4377c02067d8b6105c7fcd1931e20d9e8995) Reviewed-on: http://git-master/r/419335 Tested-by: Venkat Reddy Talla <vreddytalla@nvidia.com>
-rw-r--r--drivers/regulator/core.c12
-rw-r--r--drivers/regulator/of_regulator.c2
-rw-r--r--include/linux/regulator/machine.h1
3 files changed, 11 insertions, 4 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index c097ab289e78..b48f84c8a63b 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -1960,9 +1960,11 @@ int regulator_enable(struct regulator *regulator)
ret = _regulator_enable(rdev);
mutex_unlock(&rdev->mutex);
- if (ret != 0 && rdev->supply)
+ if (rdev->supply &&
+ (ret || rdev->constraints->disable_parent_after_enable)) {
+ rdev_info(rdev, "Disabling parent\n");
regulator_disable(rdev->supply);
-
+ }
return ret;
}
EXPORT_SYMBOL_GPL(regulator_enable);
@@ -2067,8 +2069,10 @@ int regulator_disable(struct regulator *regulator)
ret = _regulator_disable(rdev);
mutex_unlock(&rdev->mutex);
- if (ret == 0 && rdev->supply)
- regulator_disable(rdev->supply);
+ if (ret == 0 && rdev->supply) {
+ if (!rdev->constraints->disable_parent_after_enable)
+ regulator_disable(rdev->supply);
+ }
return ret;
}
diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regulator.c
index 880879e71967..c6be1d3dcefc 100644
--- a/drivers/regulator/of_regulator.c
+++ b/drivers/regulator/of_regulator.c
@@ -139,6 +139,8 @@ static void of_get_regulation_constraints(struct device_node *np,
ret = of_property_read_u32(np, "regulator-init-mode", &pval);
if (!ret)
constraints->initial_mode = pval;
+ if (of_find_property(np, "regulator-disable-parent-after-enable", NULL))
+ constraints->disable_parent_after_enable = true;
}
/**
diff --git a/include/linux/regulator/machine.h b/include/linux/regulator/machine.h
index c94cb5fdb18d..d1a6e677a5e9 100644
--- a/include/linux/regulator/machine.h
+++ b/include/linux/regulator/machine.h
@@ -152,6 +152,7 @@ struct regulation_constraints {
unsigned apply_uV:1; /* apply uV constraint if min == max */
unsigned boot_off:1; /* bootloader/firmware disabled regulator */
unsigned int ignore_current_constraint_init:1;
+ unsigned disable_parent_after_enable:1; /* SW based overcurrent protection */
};
/**