]> rtime.felk.cvut.cz Git - sojka/nv-tegra/linux-3.10.git/commitdiff
regulator: core: add support for disabling parent after enabling rail.
authorLaxman Dewangan <ldewangan@nvidia.com>
Tue, 3 Jun 2014 07:02:11 +0000 (12:32 +0530)
committerTony Ly <tly@nvidia.com>
Thu, 5 Jun 2014 18:59:12 +0000 (11:59 -0700)
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>
drivers/regulator/core.c
drivers/regulator/of_regulator.c
include/linux/regulator/machine.h

index c097ab289e782d8967912a981d67dafd51940154..b48f84c8a63b4dabded649f5327c7752a58b374f 100644 (file)
@@ -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;
 }
index 880879e719672614e0794b4d05c95728f603c782..c6be1d3dcefcdf57741bb4ab289066cd8d8a6f3f 100644 (file)
@@ -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;
 }
 
 /**
index c94cb5fdb18def479543df505cfc545a1dfb708a..d1a6e677a5e9ac81f300514f797f7db2ae6de598 100644 (file)
@@ -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 */
 };
 
 /**