regulator: Allow regulators to set the initial operating mode
authorMark Brown <broonie@opensource.wolfsonmicro.com>
Thu, 26 Feb 2009 19:24:19 +0000 (19:24 +0000)
committerLiam Girdwood <lrg@slimlogic.co.uk>
Tue, 31 Mar 2009 08:56:24 +0000 (09:56 +0100)
This is useful when wishing to run in a fixed operating mode that isn't
the default.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
drivers/regulator/core.c
include/linux/regulator/machine.h

index d55a25a6fab27afc8b448f15456e9450e0d6a83d..75abcd85e51bdfa72d5e4a53f3b0bfa4dd4c747c 100644 (file)
@@ -724,6 +724,23 @@ static int set_machine_constraints(struct regulator_dev *rdev,
                }
        }
 
+       if (constraints->initial_mode) {
+               if (!ops->set_mode) {
+                       printk(KERN_ERR "%s: no set_mode operation for %s\n",
+                              __func__, name);
+                       ret = -EINVAL;
+                       goto out;
+               }
+
+               ret = ops->set_mode(rdev, constraints->initial_mode);
+               if (ret < 0) {
+                       printk(KERN_ERR
+                              "%s: failed to set initial mode for %s: %d\n",
+                              __func__, name, ret);
+                       goto out;
+               }
+       }
+
        /* if always_on is set then turn the regulator on if it's not
         * already on. */
        if (constraints->always_on && ops->enable &&
index 5aa00ee36a3d518cfede4d9f6861e2911f5e441a..1eb861cf4b2c610ae2969de43f2aaa5dcf42f84e 100644 (file)
@@ -83,6 +83,7 @@ struct regulator_state {
  * @state_standby: State for regulator when system is suspended in standby
  *                 mode.
  * @initial_state: Suspend state to set by default.
+ * @initial_mode: Mode to set at startup.
  */
 struct regulation_constraints {
 
@@ -111,6 +112,9 @@ struct regulation_constraints {
        struct regulator_state state_standby;
        suspend_state_t initial_state; /* suspend state to set at init */
 
+       /* mode to set on startup */
+       unsigned int initial_mode;
+
        /* constriant flags */
        unsigned always_on:1;   /* regulator never off when system is on */
        unsigned boot_on:1;     /* bootloader/firmware enabled regulator */