From: Jonathan Cameron <jic23@cam.ac.uk>
To: LKML <linux-kernel@vger.kernel.org>
Cc: Mark Brown <broonie@sirena.org.uk>, Liam Girdwood <lrg@kernel.org>
Subject: regulator: Add always off to constraints.
Date: Tue, 20 Jan 2009 12:07:05 +0000 [thread overview]
Message-ID: <4975BE69.5040106@cam.ac.uk> (raw)
Dear All,
There are cases where particular ldo's aren't actually connected
to anything and currently there is no easy way of disabling them
if the pmic brings them up by default. I propose adding an always
off parameter to the constraints to allow a minimal way of specifying
this within board configs. I haven't submitted this as a formal
patch as it is currently based on top of the patch pushing
locks out of _notifier_call_chain which I posted yesterday.
If people are happy I can produce a version not dependent on that.
Problems I can see with this small change are:
1) interaction between always on and always off. Obviously it's
a bit odd if both are set. Currently I'm giving always on preference.
2) Doesn't really make sense to have regulators that are always
disabled available under sysfs etc. Perhaps there is a lower
level way of doing this that I'm missing? There is not easy
way of permanently saving this stuff on the da9030 that I'm
using and moving it into the bootloader would be a pain.
There's actually no problem with leaving these regs running
and unmanaged except for the small amount of power being wasted
and a desire for tidiness ;)
---
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 245eee1..d11b5cf 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -722,6 +722,16 @@ static int set_machine_constraints(struct regulator_dev *rdev,
rdev->constraints = NULL;
goto out;
}
+ } else if (constraints->always_off && ops->disable &&
+ ((ops->is_enabled && ops->is_enabled(rdev)) ||
+ (!ops->is_enabled && constraints->boot_on))) {
+ ret = ops->disable(rdev);
+ if (ret < 0) {
+ printk(KERN_ERR "%s: failed to disable %s\n",
+ __func__, name);
+ rdev->constraints = NULL;
+ goto out;
+ }
}
print_constraints(rdev);
@@ -1002,7 +1012,7 @@ static int _regulator_enable(struct regulator_dev *rdev)
}
/* check voltage and requested load before enabling */
- if (rdev->desc->ops->enable) {
+ if (rdev->desc->ops->enable && !rdev->constraints->always_off) {
if (rdev->constraints &&
(rdev->constraints->valid_ops_mask &
diff --git a/include/linux/regulator/machine.h b/include/linux/regulator/machine.h
index 3794773..56bbb89 100644
--- a/include/linux/regulator/machine.h
+++ b/include/linux/regulator/machine.h
@@ -113,6 +113,7 @@ struct regulation_constraints {
/* constriant flags */
unsigned always_on:1; /* regulator never off when system is on */
+ unsigned always_off:1; /* regulator never on under any circumstances */
unsigned boot_on:1; /* bootloader/firmware enabled regulator */
unsigned apply_uV:1; /* apply uV constraint iff min == max */
};
next reply other threads:[~2009-01-20 12:07 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-01-20 12:07 Jonathan Cameron [this message]
2009-01-20 12:43 ` regulator: Add always off to constraints Mark Brown
2009-01-20 13:00 ` Jonathan Cameron
2009-01-20 13:19 ` regulator: Add disable_on_boot flag " Jonathan Cameron
2009-01-20 20:14 ` Liam Girdwood
2009-01-21 14:44 ` Jonathan Cameron
2009-03-29 19:25 ` Jonathan Cameron
2009-03-30 9:52 ` Mark Brown
2009-03-31 10:55 ` Mark Brown
2009-01-20 20:25 ` Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4975BE69.5040106@cam.ac.uk \
--to=jic23@cam.ac.uk \
--cc=broonie@sirena.org.uk \
--cc=linux-kernel@vger.kernel.org \
--cc=lrg@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.