* [PATCH 2/3] regulator: add set_pulldown in regulator operations
@ 2012-02-17 6:41 Kim, Milo
2012-02-17 7:25 ` Mark Brown
0 siblings, 1 reply; 2+ messages in thread
From: Kim, Milo @ 2012-02-17 6:41 UTC (permalink / raw)
To: Mark Brown; +Cc: linux-kernel@vger.kernel.org
Some PMUs provide programmable active shutdown switches
that help discharge the load if the supply is off.
For providing this feature, set_pulldown() is added in the ops.
The set_pulldown() is not exported function.
This function is called internally when the regulator is disabled.
Then pull-down bits can be programmed in each regulator driver.
* patch base version : linux-3.2.4
Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
---
drivers/regulator/core.c | 18 ++++++++++++++++++
include/linux/regulator/driver.h | 2 ++
2 files changed, 20 insertions(+), 0 deletions(-)
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 938398f..3053f4f 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -1457,6 +1457,15 @@ static int _regulator_disable(struct regulator_dev *rdev)
return ret;
}
+ if (rdev->desc->ops->set_pulldown) {
+ ret = rdev->desc->ops->set_pulldown(rdev);
+ if (ret < 0) {
+ rdev_err(rdev,
+ "failed to set pulldown\n");
+ return ret;
+ }
+ }
+
trace_regulator_disable_complete(rdev_get_name(rdev));
_notifier_call_chain(rdev, REGULATOR_EVENT_DISABLE,
@@ -1518,6 +1527,15 @@ static int _regulator_force_disable(struct regulator_dev *rdev)
rdev_err(rdev, "failed to force disable\n");
return ret;
}
+
+ if (rdev->desc->ops->set_pulldown) {
+ ret = rdev->desc->ops->set_pulldown(rdev);
+ if (ret < 0) {
+ rdev_err(rdev, "failed to set pulldown\n");
+ return ret;
+ }
+ }
+
/* notify other consumers that power has been forced off */
_notifier_call_chain(rdev, REGULATOR_EVENT_FORCE_DISABLE |
REGULATOR_EVENT_DISABLE, NULL);
diff --git a/include/linux/regulator/driver.h b/include/linux/regulator/driver.h
index df6e9ec..081f91d 100644
--- a/include/linux/regulator/driver.h
+++ b/include/linux/regulator/driver.h
@@ -38,6 +38,7 @@ enum regulator_status {
*
* @enable: Configure the regulator as enabled.
* @disable: Configure the regulator as disabled.
+ * @set_pulldown : Configure pulldown setting when the regulator is disabled.
* @is_enabled: Return 1 if the regulator is enabled, 0 if not.
* May also return negative errno.
*
@@ -102,6 +103,7 @@ struct regulator_ops {
/* enable/disable regulator */
int (*enable) (struct regulator_dev *);
int (*disable) (struct regulator_dev *);
+ int (*set_pulldown) (struct regulator_dev *);
int (*is_enabled) (struct regulator_dev *);
/* get/set regulator operating mode (defined in consumer.h) */
--
1.7.4.1
Best Regards,
Milo (Woogyom) Kim
Texas Instruments Incorporated
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 2/3] regulator: add set_pulldown in regulator operations
2012-02-17 6:41 [PATCH 2/3] regulator: add set_pulldown in regulator operations Kim, Milo
@ 2012-02-17 7:25 ` Mark Brown
0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2012-02-17 7:25 UTC (permalink / raw)
To: Kim, Milo; +Cc: linux-kernel@vger.kernel.org
[-- Attachment #1: Type: text/plain, Size: 1382 bytes --]
On Thu, Feb 16, 2012 at 10:41:45PM -0800, Kim, Milo wrote:
> Some PMUs provide programmable active shutdown switches
> that help discharge the load if the supply is off.
> For providing this feature, set_pulldown() is added in the ops.
> The set_pulldown() is not exported function.
> This function is called internally when the regulator is disabled.
> Then pull-down bits can be programmed in each regulator driver.
There's several problems here. One is that "pulldown" is a really
confusing name as a pulldown is usually a feature of open drain logic.
"Discharge" would be a better term.
> + if (rdev->desc->ops->set_pulldown) {
> + ret = rdev->desc->ops->set_pulldown(rdev);
> + if (ret < 0) {
> + rdev_err(rdev,
> + "failed to set pulldown\n");
> + return ret;
> + }
Another is that since the operation is defined not to take any arguments
there's no need to have an operation - the driver may as well just
enable the discharge unconditionally at system startup as it can never
be disabled. For a lot of hardware this is all that's needed anyway as
the device is smart enough to remove the discharge when the regulator is
enabled.
It's also not altogether clear that actively discharging regulators is
a good default - often it'll increase leakage current a tiny amount and
nothing really cares that much about how quickly the voltage collapses.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-02-17 7:25 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-17 6:41 [PATCH 2/3] regulator: add set_pulldown in regulator operations Kim, Milo
2012-02-17 7:25 ` Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox