]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
regulator: Add over current protection (OCP) support
authorStephen Boyd <sboyd@codeaurora.org>
Fri, 17 Jul 2015 21:41:54 +0000 (14:41 -0700)
committerMark Brown <broonie@kernel.org>
Fri, 24 Jul 2015 17:28:46 +0000 (18:28 +0100)
Some regulators can automatically shut down when they detect an
over current event. Add an op (set_over_current_protection) and a
DT property + constraint to support this capability.

Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
Documentation/devicetree/bindings/regulator/regulator.txt
drivers/regulator/core.c
drivers/regulator/of_regulator.c
include/linux/regulator/driver.h
include/linux/regulator/machine.h

index db88feb28c0313bc9914eb2bcb4fc33dde264295..24bd422cecd5857c7fcf07403f5b600fd6310f3c 100644 (file)
@@ -42,6 +42,7 @@ Optional properties:
 - regulator-system-load: Load in uA present on regulator that is not captured by
   any consumer request.
 - regulator-pull-down: Enable pull down resistor when the regulator is disabled.
+- regulator-over-current-protection: Enable over current protection.
 
 Deprecated properties:
 - regulator-compatible: If a regulator chip contains multiple
index c9f72019bd689afbb4e51528932689dc097b191b..520413e2bca00577c35ddc2dfe8d0a5cccb50795 100644 (file)
@@ -1081,6 +1081,15 @@ static int set_machine_constraints(struct regulator_dev *rdev,
                }
        }
 
+       if (rdev->constraints->over_current_protection
+               && ops->set_over_current_protection) {
+               ret = ops->set_over_current_protection(rdev);
+               if (ret < 0) {
+                       rdev_err(rdev, "failed to set over current protection\n");
+                       goto out;
+               }
+       }
+
        print_constraints(rdev);
        return 0;
 out:
index b1c485b24ab246234edbab2dfb4217e4fe1df833..250700c853bfa524991f6721256fb02876f54799 100644 (file)
@@ -107,6 +107,9 @@ static void of_get_regulation_constraints(struct device_node *np,
        if (!of_property_read_u32(np, "regulator-system-load", &pval))
                constraints->system_load = pval;
 
+       constraints->over_current_protection = of_property_read_bool(np,
+                                       "regulator-over-current-protection");
+
        for (i = 0; i < ARRAY_SIZE(regulator_states); i++) {
                switch (i) {
                case PM_SUSPEND_MEM:
index 4db9fbe4889d3c54f76c2c2c1e3d50ce404d0965..45932228cbf5924c507bbc4b39c405bb9ab750f7 100644 (file)
@@ -148,6 +148,7 @@ struct regulator_ops {
        int (*get_current_limit) (struct regulator_dev *);
 
        int (*set_input_current_limit) (struct regulator_dev *, int lim_uA);
+       int (*set_over_current_protection) (struct regulator_dev *);
 
        /* enable/disable regulator */
        int (*enable) (struct regulator_dev *);
index b11be126012974ebf4877220c8949310d649ddea..a1067d0b39916b869eebc6a179c3696a115e3996 100644 (file)
@@ -147,6 +147,7 @@ struct regulation_constraints {
        unsigned ramp_disable:1; /* disable ramp delay */
        unsigned soft_start:1;  /* ramp voltage slowly */
        unsigned pull_down:1;   /* pull down resistor when regulator off */
+       unsigned over_current_protection:1; /* auto disable on over current */
 };
 
 /**