* [PATCH 1/2] regulator: Allow regulators to set the initial operating mode
@ 2009-02-26 19:24 Mark Brown
2009-02-26 19:24 ` [PATCH 2/2] regulator: Fix get_mode() for WM835x DCDCs Mark Brown
2009-02-26 20:15 ` [PATCH 1/2] regulator: Allow regulators to set the initial operating mode Liam Girdwood
0 siblings, 2 replies; 4+ messages in thread
From: Mark Brown @ 2009-02-26 19:24 UTC (permalink / raw)
To: Liam Girdwood; +Cc: linux-kernel, Mark Brown
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>
---
drivers/regulator/core.c | 17 +++++++++++++++++
include/linux/regulator/machine.h | 4 ++++
2 files changed, 21 insertions(+), 0 deletions(-)
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index d55a25a..75abcd8 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -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 &&
diff --git a/include/linux/regulator/machine.h b/include/linux/regulator/machine.h
index 5aa00ee..1eb861c 100644
--- a/include/linux/regulator/machine.h
+++ b/include/linux/regulator/machine.h
@@ -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 */
--
1.6.1.3
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 2/2] regulator: Fix get_mode() for WM835x DCDCs
2009-02-26 19:24 [PATCH 1/2] regulator: Allow regulators to set the initial operating mode Mark Brown
@ 2009-02-26 19:24 ` Mark Brown
2009-02-26 20:17 ` Liam Girdwood
2009-02-26 20:15 ` [PATCH 1/2] regulator: Allow regulators to set the initial operating mode Liam Girdwood
1 sibling, 1 reply; 4+ messages in thread
From: Mark Brown @ 2009-02-26 19:24 UTC (permalink / raw)
To: Liam Girdwood; +Cc: linux-kernel, Mark Brown
The WM835x regulators need a different register checking for force
mode on each DCDC. Previously the force mode status for DCDC1 was
checked.
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
---
drivers/regulator/wm8350-regulator.c | 24 ++++++++++++++++++------
1 files changed, 18 insertions(+), 6 deletions(-)
diff --git a/drivers/regulator/wm8350-regulator.c b/drivers/regulator/wm8350-regulator.c
index 93e0ce5..261db94 100644
--- a/drivers/regulator/wm8350-regulator.c
+++ b/drivers/regulator/wm8350-regulator.c
@@ -1031,18 +1031,30 @@ static unsigned int wm8350_dcdc_get_mode(struct regulator_dev *rdev)
int dcdc = rdev_get_id(rdev);
u16 mask, sleep, active, force;
int mode = REGULATOR_MODE_NORMAL;
+ int reg;
- if (dcdc < WM8350_DCDC_1 || dcdc > WM8350_DCDC_6)
- return -EINVAL;
-
- if (dcdc == WM8350_DCDC_2 || dcdc == WM8350_DCDC_5)
+ switch (dcdc) {
+ case WM8350_DCDC_1:
+ reg = WM8350_DCDC1_FORCE_PWM;
+ break;
+ case WM8350_DCDC_3:
+ reg = WM8350_DCDC3_FORCE_PWM;
+ break;
+ case WM8350_DCDC_4:
+ reg = WM8350_DCDC4_FORCE_PWM;
+ break;
+ case WM8350_DCDC_6:
+ reg = WM8350_DCDC6_FORCE_PWM;
+ break;
+ default:
return -EINVAL;
+ }
mask = 1 << (dcdc - WM8350_DCDC_1);
active = wm8350_reg_read(wm8350, WM8350_DCDC_ACTIVE_OPTIONS) & mask;
+ force = wm8350_reg_read(wm8350, reg) & WM8350_DCDC1_FORCE_PWM_ENA;
sleep = wm8350_reg_read(wm8350, WM8350_DCDC_SLEEP_OPTIONS) & mask;
- force = wm8350_reg_read(wm8350, WM8350_DCDC1_FORCE_PWM)
- & WM8350_DCDC1_FORCE_PWM_ENA;
+
dev_dbg(wm8350->dev, "mask %x active %x sleep %x force %x",
mask, active, sleep, force);
--
1.6.1.3
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] regulator: Allow regulators to set the initial operating mode
2009-02-26 19:24 [PATCH 1/2] regulator: Allow regulators to set the initial operating mode Mark Brown
2009-02-26 19:24 ` [PATCH 2/2] regulator: Fix get_mode() for WM835x DCDCs Mark Brown
@ 2009-02-26 20:15 ` Liam Girdwood
1 sibling, 0 replies; 4+ messages in thread
From: Liam Girdwood @ 2009-02-26 20:15 UTC (permalink / raw)
To: Mark Brown; +Cc: linux-kernel
On Thu, 2009-02-26 at 19:24 +0000, Mark Brown wrote:
> 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>
> ---
> drivers/regulator/core.c | 17 +++++++++++++++++
> include/linux/regulator/machine.h | 4 ++++
> 2 files changed, 21 insertions(+), 0 deletions(-)
>
Applied.
Thanks
Liam
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] regulator: Fix get_mode() for WM835x DCDCs
2009-02-26 19:24 ` [PATCH 2/2] regulator: Fix get_mode() for WM835x DCDCs Mark Brown
@ 2009-02-26 20:17 ` Liam Girdwood
0 siblings, 0 replies; 4+ messages in thread
From: Liam Girdwood @ 2009-02-26 20:17 UTC (permalink / raw)
To: Mark Brown; +Cc: linux-kernel
On Thu, 2009-02-26 at 19:24 +0000, Mark Brown wrote:
> The WM835x regulators need a different register checking for force
> mode on each DCDC. Previously the force mode status for DCDC1 was
> checked.
>
> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
> ---
> drivers/regulator/wm8350-regulator.c | 24 ++++++++++++++++++------
> 1 files changed, 18 insertions(+), 6 deletions(-)
>
Applied.
Thanks
Liam
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-02-26 20:17 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-02-26 19:24 [PATCH 1/2] regulator: Allow regulators to set the initial operating mode Mark Brown
2009-02-26 19:24 ` [PATCH 2/2] regulator: Fix get_mode() for WM835x DCDCs Mark Brown
2009-02-26 20:17 ` Liam Girdwood
2009-02-26 20:15 ` [PATCH 1/2] regulator: Allow regulators to set the initial operating mode Liam Girdwood
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®