regulator: Add system_load constraint
authorStephen Boyd <sboyd@codeaurora.org>
Fri, 12 Jun 2015 00:37:03 +0000 (17:37 -0700)
committerMark Brown <broonie@kernel.org>
Fri, 12 Jun 2015 12:05:11 +0000 (13:05 +0100)
Some regulators have a fixed load that isn't captured by
consumers that the kernel knows about. Add a constraint to
support this.

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/machine.h

index abb26b58c83eea4eb60170f56700f9fa20aa8f88..553d2d0fe6d915325788ce55b46bbaee3ca05598 100644 (file)
@@ -37,6 +37,8 @@ Optional properties:
 - regulator-initial-mode: initial operating mode. The set of possible operating
   modes depends on the capabilities of every hardware so each device binding
   documentation explains which values the regulator supports.
+- regulator-system-load: Load in uA present on regulator that is not captured by
+  any consumer request.
 
 Deprecated properties:
 - regulator-compatible: If a regulator chip contains multiple
index 443eaab933fcfe680d5e402f72bbe7c55c3ae391..c8d5e2b05fdf93c09e99fd7e1b62d72dd2279354 100644 (file)
@@ -678,6 +678,8 @@ static int drms_uA_update(struct regulator_dev *rdev)
        list_for_each_entry(sibling, &rdev->consumer_list, list)
                current_uA += sibling->uA_load;
 
+       current_uA += rdev->constraints->system_load;
+
        if (rdev->desc->ops->set_load) {
                /* set the optimum mode for our new total regulator load */
                err = rdev->desc->ops->set_load(rdev, current_uA);
index 24e812c48d93076a36039e991c51bb371fb26d6e..482a86f90839c15e4a6166a5cb2c07981a022b4a 100644 (file)
@@ -95,6 +95,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;
+
        for (i = 0; i < ARRAY_SIZE(regulator_states); i++) {
                switch (i) {
                case PM_SUSPEND_MEM:
index b07562e082c416a2b98fc08818f35111c8237288..01526559c8c362125353d019378e82637f8798c6 100644 (file)
@@ -75,6 +75,7 @@ struct regulator_state {
  *
  * @min_uA: Smallest current consumers may set.
  * @max_uA: Largest current consumers may set.
+ * @system_load: Load that isn't captured by any consumer requests.
  *
  * @valid_modes_mask: Mask of modes which may be configured by consumers.
  * @valid_ops_mask: Operations which may be performed by consumers.
@@ -112,6 +113,8 @@ struct regulation_constraints {
        int min_uA;
        int max_uA;
 
+       int system_load;
+
        /* valid regulator operating modes for this machine */
        unsigned int valid_modes_mask;