[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <200811091531.46003.david-b@pacbell.net>
Date: Sun, 9 Nov 2008 15:31:45 -0800
From: David Brownell <david-b@...bell.net>
To: broonie@...nsource.wolfsonmicro.com, lrg@...mlogic.co.uk
Cc: lkml <linux-kernel@...r.kernel.org>
Subject: [patch 2.6.28-rc3] regulator: add REGULATOR_MODE_OFF
From: David Brownell <dbrownell@...rs.sourceforge.net>
The regulator framework needs to expose an OFF mode for regulators
with a single state machine. Example: TWL4030 regulators each
have a status register exposing the current mode, which will be
either ACTIVE, STANDBY, or OFF. But regulator_ops.get_mode()
currently has no way to report that third (OFF) mode.
Add such an OFF mode, reporting it in the standard ways.
In the spirit of the existing interface, disable() operations are
still used to enter this mode:
- regulator_set_mode() rejects it; drivers doing runtime power
management must use regulator_disable().
- the PM_SUSPEND_* notifier goes down the set_suspend_disable()
path, not requiring set_suspend_mode() to handle OFF mode.
This doesn't address any other enable/disable issues... like the
way regulator_disable() clobbers state even on failure paths, or
refcounting isssues (e.g. two clients enable, one disables, then
the regulator should stay active.)
Signed-off-by: David Brownell <dbrownell@...rs.sourceforge.net>
---
drivers/regulator/core.c | 16 +++++++++++++---
include/linux/regulator/consumer.h | 4 ++++
2 files changed, 17 insertions(+), 3 deletions(-)
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -272,6 +272,8 @@ static ssize_t regulator_opmode_show(str
return sprintf(buf, "idle\n");
case REGULATOR_MODE_STANDBY:
return sprintf(buf, "standby\n");
+ case REGULATOR_MODE_OFF:
+ return sprintf(buf, "off\n");
}
return sprintf(buf, "unknown\n");
}
@@ -411,6 +413,8 @@ static ssize_t suspend_opmode_show(struc
return sprintf(buf, "idle\n");
case REGULATOR_MODE_STANDBY:
return sprintf(buf, "standby\n");
+ case REGULATOR_MODE_OFF:
+ return sprintf(buf, "off\n");
}
return sprintf(buf, "unknown\n");
}
@@ -589,7 +593,7 @@ static int suspend_set_state(struct regu
return -EINVAL;
}
- if (rstate->enabled)
+ if (rstate->enabled && rstate->mode != REGULATOR_MODE_OFF)
ret = rdev->desc->ops->set_suspend_enable(rdev);
else
ret = rdev->desc->ops->set_suspend_disable(rdev);
@@ -668,7 +672,9 @@ static void print_constraints(struct reg
if (constraints->valid_modes_mask & REGULATOR_MODE_IDLE)
count += sprintf(buf + count, "idle ");
if (constraints->valid_modes_mask & REGULATOR_MODE_STANDBY)
- count += sprintf(buf + count, "standby");
+ count += sprintf(buf + count, "standby ");
+ if (constraints->valid_modes_mask & REGULATOR_MODE_OFF)
+ count += sprintf(buf + count, "off ");
printk(KERN_INFO "regulator: %s: %s\n", rdev->desc->name, buf);
}
@@ -1362,7 +1368,8 @@ EXPORT_SYMBOL_GPL(regulator_get_current_
* @mode: operating mode - one of the REGULATOR_MODE constants
*
* Set regulator operating mode to increase regulator efficiency or improve
- * regulation performance.
+ * regulation performance. You may not pass REGULATOR_MODE_OFF; to achieve
+ * that effect, call regulator_disable().
*
* NOTE: Regulator system constraints must be set for this regulator before
* calling this function otherwise this call will fail.
@@ -1372,6 +1379,9 @@ int regulator_set_mode(struct regulator
struct regulator_dev *rdev = regulator->rdev;
int ret;
+ if (mode == REGULATOR_MODE_OFF)
+ return -EINVAL;
+
mutex_lock(&rdev->mutex);
/* sanity check */
--- a/include/linux/regulator/consumer.h
+++ b/include/linux/regulator/consumer.h
@@ -68,6 +68,9 @@
* the most noisy and may not be able to handle fast load
* switching.
*
+ * OFF Regulator is disabled. This mode may be observed from
+ * some hardware after invoking disable() primitives.
+ *
* NOTE: Most regulators will only support a subset of these modes. Some
* will only just support NORMAL.
*
@@ -78,6 +81,7 @@
#define REGULATOR_MODE_NORMAL 0x2
#define REGULATOR_MODE_IDLE 0x4
#define REGULATOR_MODE_STANDBY 0x8
+#define REGULATOR_MODE_OFF 0x10
/*
* Regulator notifier events.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists