All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/1] TWL: USB: disable VUSB regulators
@ 2009-01-21 13:15 Kalle Jokiniemi
  2009-01-21 13:15 ` [PATCH 1/1] TWL: USB: disable VUSB regulators when cable unplugged Kalle Jokiniemi
  2009-01-21 20:38 ` [PATCH 0/1] TWL: USB: disable VUSB regulators David Brownell
  0 siblings, 2 replies; 10+ messages in thread
From: Kalle Jokiniemi @ 2009-01-21 13:15 UTC (permalink / raw)
  To: linux-omap; +Cc: felipe.balbi, david-b

The TWL5030/4030 internal VUSB regulators are eating current
like small piggies. The following patch makes an aptempt at
making the twl4030-usb consumer driver dynamically disable
and enable the regulators it needs.

This regulator fw stuff is fairly new so any comments are
appreciated.

Tested on custom omap3430 hw. Build tested on beagle and
SDP defconfigs. If anyone could test this on public hw, that
would be great. There should be a noticeable drop in power
consumption when usb cable is unplugged with this patch. 


Kalle Jokiniemi (1):
      TWL: USB: disable VUSB regulators when cable unplugged




^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 1/1] TWL: USB: disable VUSB regulators when cable unplugged
  2009-01-21 13:15 [PATCH 0/1] TWL: USB: disable VUSB regulators Kalle Jokiniemi
@ 2009-01-21 13:15 ` Kalle Jokiniemi
  2009-01-22 17:55   ` David Brownell
  2009-01-21 20:38 ` [PATCH 0/1] TWL: USB: disable VUSB regulators David Brownell
  1 sibling, 1 reply; 10+ messages in thread
From: Kalle Jokiniemi @ 2009-01-21 13:15 UTC (permalink / raw)
  To: linux-omap; +Cc: felipe.balbi, david-b, Kalle Jokiniemi

This patch disables USB regulators VUSB1V5, VUSB1V8, and VUSB3V1
when the USB cable is unplugged to reduce power consumption.

Signed-off-by: Kalle Jokiniemi <kalle.jokiniemi@digia.com>
---
 drivers/usb/otg/twl4030-usb.c |   30 ++++++++++++++++++++++++------
 1 files changed, 24 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/otg/twl4030-usb.c b/drivers/usb/otg/twl4030-usb.c
index 416e441..105ab55 100644
--- a/drivers/usb/otg/twl4030-usb.c
+++ b/drivers/usb/otg/twl4030-usb.c
@@ -34,6 +34,7 @@
 #include <linux/delay.h>
 #include <linux/usb/otg.h>
 #include <linux/i2c/twl4030.h>
+#include <linux/regulator/consumer.h>
 
 
 /* Register defines */
@@ -246,6 +247,11 @@ struct twl4030_usb {
 	struct otg_transceiver	otg;
 	struct device		*dev;
 
+	/* TWL4030 internal USB regulator supplies */
+	struct regulator	*usb1v5;
+	struct regulator	*usb1v8;
+	struct regulator	*usb3v1;
+
 	/* for vbus reporting with irqs disabled */
 	spinlock_t		lock;
 
@@ -434,6 +440,9 @@ static void twl4030_phy_power(struct twl4030_usb *twl, int on)
 
 	pwr = twl4030_usb_read(twl, PHY_PWR_CTRL);
 	if (on) {
+		regulator_enable(twl->usb1v5);
+		regulator_enable(twl->usb1v8);
+		regulator_enable(twl->usb3v1);
 		pwr &= ~PHY_PWR_PHYPWD;
 		WARN_ON(twl4030_usb_write_verify(twl, PHY_PWR_CTRL, pwr) < 0);
 		twl4030_usb_write(twl, PHY_CLK_CTRL,
@@ -443,6 +452,9 @@ static void twl4030_phy_power(struct twl4030_usb *twl, int on)
 	} else  {
 		pwr |= PHY_PWR_PHYPWD;
 		WARN_ON(twl4030_usb_write_verify(twl, PHY_PWR_CTRL, pwr) < 0);
+		regulator_disable(twl->usb1v5);
+		regulator_disable(twl->usb1v8);
+		regulator_disable(twl->usb3v1);
 	}
 }
 
@@ -480,16 +492,19 @@ static void twl4030_usb_ldo_init(struct twl4030_usb *twl)
 	/* input to VUSB3V1 LDO is from VBAT, not VBUS */
 	twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0x14, VUSB_DEDICATED1);
 
-	/* turn on 3.1V regulator */
-	twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0x20, VUSB3V1_DEV_GRP);
+	/* Initialize 3.1V regulator */
+	twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0, VUSB3V1_DEV_GRP);
+	twl->usb3v1 = regulator_get(twl->dev, "usb3v1");
 	twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0, VUSB3V1_TYPE);
 
-	/* turn on 1.5V regulator */
-	twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0x20, VUSB1V5_DEV_GRP);
+	/* Initialize 1.5V regulator */
+	twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0, VUSB1V5_DEV_GRP);
+	twl->usb1v5 = regulator_get(twl->dev, "usb1v5");
 	twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0, VUSB1V5_TYPE);
 
-	/* turn on 1.8V regulator */
-	twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0x20, VUSB1V8_DEV_GRP);
+	/* Initialize 1.8V regulator */
+	twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0, VUSB1V8_DEV_GRP);
+	twl->usb1v8 = regulator_get(twl->dev, "usb1v8");
 	twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0, VUSB1V8_TYPE);
 
 	/* disable access to power configuration registers */
@@ -688,6 +703,9 @@ static int __exit twl4030_usb_remove(struct platform_device *pdev)
 	twl4030_usb_clear_bits(twl, POWER_CTRL, POWER_CTRL_OTG_ENAB);
 
 	twl4030_phy_power(twl, 0);
+	regulator_put(twl->usb1v5);
+	regulator_put(twl->usb1v8);
+	regulator_put(twl->usb3v1);
 
 	kfree(twl);
 
-- 
1.5.6.5


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH 0/1] TWL: USB: disable VUSB regulators
  2009-01-21 13:15 [PATCH 0/1] TWL: USB: disable VUSB regulators Kalle Jokiniemi
  2009-01-21 13:15 ` [PATCH 1/1] TWL: USB: disable VUSB regulators when cable unplugged Kalle Jokiniemi
@ 2009-01-21 20:38 ` David Brownell
  2009-01-21 21:19   ` Woodruff, Richard
  2009-01-23 10:55   ` Kalle Jokiniemi
  1 sibling, 2 replies; 10+ messages in thread
From: David Brownell @ 2009-01-21 20:38 UTC (permalink / raw)
  To: Kalle Jokiniemi; +Cc: linux-omap, felipe.balbi

On Wednesday 21 January 2009, Kalle Jokiniemi wrote:
> The TWL5030/4030 internal VUSB regulators are eating current
> like small piggies.

Feral pigs are a big problem in many places ...
no surprise that feral code is too!


> The following patch makes an aptempt at 
> making the twl4030-usb consumer driver dynamically disable
> and enable the regulators it needs.

Thanks, I'll have a look.  It's a bit different
from some old hacks I didn't finish debugging.

Shouldn't the power down sequence mirror the
power up sequence?  Up 1.5, 1.8, 3.1 ... then
down 3.1, 1.8, 1.5?  Or does that matter?

Also, I'm thinking that the DEV_GRP and TYPE
register updates belong in regulator code, not
transceiver code.  That's something to take care
of with a separate patch though.

- Dave

^ permalink raw reply	[flat|nested] 10+ messages in thread

* RE: [PATCH 0/1] TWL: USB: disable VUSB regulators
  2009-01-21 20:38 ` [PATCH 0/1] TWL: USB: disable VUSB regulators David Brownell
@ 2009-01-21 21:19   ` Woodruff, Richard
  2009-01-21 21:47     ` David Brownell
  2009-01-23 10:55   ` Kalle Jokiniemi
  1 sibling, 1 reply; 10+ messages in thread
From: Woodruff, Richard @ 2009-01-21 21:19 UTC (permalink / raw)
  To: David Brownell, Kalle Jokiniemi; +Cc: linux-omap, felipe.balbi

On Wednesday 21 January 2009, Kalle Jokiniemi wrote:
> > The TWL5030/4030 internal VUSB regulators are eating current
> > like small piggies.
>
> Feral pigs are a big problem in many places ...
> no surprise that feral code is too!

A simple but impacting point is a LDO when left on, wastes a lot of system power.

If you have say 4.4v battery and it goes to a LDO which supports a 1.8v IO.  The LDO will drop a lot of power on the floor.  A design with a 3.6v batter to the same LDO drops less power.  Twl5030 can consume a lot of power if your not watching at the system level.

For processor rails VCORE (omap2), VDD1/VDD2 (omap3) at least there is a DCDC switcher which is somewhat efficient. This gives you your 1.2v with out dumping everything.

Didn't know Dave was such a poet :)

Regards,
Richard W.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 0/1] TWL: USB: disable VUSB regulators
  2009-01-21 21:19   ` Woodruff, Richard
@ 2009-01-21 21:47     ` David Brownell
  0 siblings, 0 replies; 10+ messages in thread
From: David Brownell @ 2009-01-21 21:47 UTC (permalink / raw)
  To: Woodruff, Richard; +Cc: Kalle Jokiniemi, linux-omap, felipe.balbi

On Wednesday 21 January 2009, Woodruff, Richard wrote:
> A simple but impacting point is a LDO when left on, wastes a lot of system power.

So I guess I'll poke a bit harder at finding ways to
make sure the LDOs on the twl4030 get turned off..
this patch looks like a good start (since the VUSB
regulators are completely set up).

VAUX3 seems to be inappropriately enabled on a lot
of OMAP3 boards; short of fixing u-boot, that'd be
another bit of low-hanging fruit.


> Didn't know Dave was such a poet :)

Well, I dunno about the rhyme or scansion, but I
do sort of like the "feral code" imagery.  It seems
to highlight some key behaviors better than many
more familiar terms!

- Dave

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/1] TWL: USB: disable VUSB regulators when cable unplugged
  2009-01-21 13:15 ` [PATCH 1/1] TWL: USB: disable VUSB regulators when cable unplugged Kalle Jokiniemi
@ 2009-01-22 17:55   ` David Brownell
  2009-01-27  9:50     ` Kalle Jokiniemi
  0 siblings, 1 reply; 10+ messages in thread
From: David Brownell @ 2009-01-22 17:55 UTC (permalink / raw)
  To: Kalle Jokiniemi; +Cc: linux-omap, felipe.balbi

On Wednesday 21 January 2009, Kalle Jokiniemi wrote:
> This patch disables USB regulators VUSB1V5, VUSB1V8, and VUSB3V1
> when the USB cable is unplugged to reduce power consumption.

Worked fine on a Beagle, now I'm trying to find out
what's borked on an Overo ...

- Dave


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 0/1] TWL: USB: disable VUSB regulators
  2009-01-21 20:38 ` [PATCH 0/1] TWL: USB: disable VUSB regulators David Brownell
  2009-01-21 21:19   ` Woodruff, Richard
@ 2009-01-23 10:55   ` Kalle Jokiniemi
  1 sibling, 0 replies; 10+ messages in thread
From: Kalle Jokiniemi @ 2009-01-23 10:55 UTC (permalink / raw)
  To: David Brownell; +Cc: linux-omap, felipe.balbi

Hi Dave,

Sorry for the late response, I was out of office yesterday.

On Wed, 2009-01-21 at 12:38 -0800, David Brownell wrote:
> On Wednesday 21 January 2009, Kalle Jokiniemi wrote:
> > The TWL5030/4030 internal VUSB regulators are eating current
> > like small piggies.
> 
> Feral pigs are a big problem in many places ...
> no surprise that feral code is too!
> 
> 
> > The following patch makes an aptempt at 
> > making the twl4030-usb consumer driver dynamically disable
> > and enable the regulators it needs.
> 
> Thanks, I'll have a look.  It's a bit different
> from some old hacks I didn't finish debugging.
> 
> Shouldn't the power down sequence mirror the
> power up sequence?  Up 1.5, 1.8, 3.1 ... then
> down 3.1, 1.8, 1.5?  Or does that matter?

Good question. The TRM tells quite little on these VUSB regulators,
other than they supply the USB sub-chip in TWL. For VUSB3V1 there is a
bit more information, telling that it supplies USB PHY, CEA Carkit
modules and MCPC (seems to be some special usb UART specification). 

I would think they all can be shut down in whatever order, if there is
nothing connected to the usb connector.

> 
> Also, I'm thinking that the DEV_GRP and TYPE
> register updates belong in regulator code, not
> transceiver code.  That's something to take care
> of with a separate patch though.

I agree.

- Kalle 

> 
> - Dave

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/1] TWL: USB: disable VUSB regulators when cable unplugged
  2009-01-22 17:55   ` David Brownell
@ 2009-01-27  9:50     ` Kalle Jokiniemi
  2009-01-28  2:02       ` David Brownell
  0 siblings, 1 reply; 10+ messages in thread
From: Kalle Jokiniemi @ 2009-01-27  9:50 UTC (permalink / raw)
  To: David Brownell; +Cc: linux-omap, felipe.balbi

On Thu, 2009-01-22 at 09:55 -0800, David Brownell wrote:
> On Wednesday 21 January 2009, Kalle Jokiniemi wrote:
> > This patch disables USB regulators VUSB1V5, VUSB1V8, and VUSB3V1
> > when the USB cable is unplugged to reduce power consumption.
> 
> Worked fine on a Beagle, now I'm trying to find out
> what's borked on an Overo ...

Did you manage to get it working on Overo? 

BTW. Should I post this patch to linux-usb as well?

- Kalle

> 
> - Dave
> 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/1] TWL: USB: disable VUSB regulators when cable unplugged
  2009-01-27  9:50     ` Kalle Jokiniemi
@ 2009-01-28  2:02       ` David Brownell
  2009-01-28  6:36         ` Kalle Jokiniemi
  0 siblings, 1 reply; 10+ messages in thread
From: David Brownell @ 2009-01-28  2:02 UTC (permalink / raw)
  To: Kalle Jokiniemi; +Cc: linux-omap, felipe.balbi

On Tuesday 27 January 2009, Kalle Jokiniemi wrote:
> On Thu, 2009-01-22 at 09:55 -0800, David Brownell wrote:
> > On Wednesday 21 January 2009, Kalle Jokiniemi wrote:
> > > This patch disables USB regulators VUSB1V5, VUSB1V8, and VUSB3V1
> > > when the USB cable is unplugged to reduce power consumption.
> > 
> > Worked fine on a Beagle, now I'm trying to find out
> > what's borked on an Overo ...
> 
> Did you manage to get it working on Overo? 

Yes.  It must have either been a bad build, or an issue
with one of the other patches, or something.


> BTW. Should I post this patch to linux-usb as well?

If you like, but it can't merge yet ... the twl4030
regulator code isn't in mainline yet.  I think it's
ready given the patches I posted earlier.

- Dave
 



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/1] TWL: USB: disable VUSB regulators when cable unplugged
  2009-01-28  2:02       ` David Brownell
@ 2009-01-28  6:36         ` Kalle Jokiniemi
  0 siblings, 0 replies; 10+ messages in thread
From: Kalle Jokiniemi @ 2009-01-28  6:36 UTC (permalink / raw)
  To: David Brownell; +Cc: linux-omap, felipe.balbi

On Tue, 2009-01-27 at 18:02 -0800, David Brownell wrote:
> On Tuesday 27 January 2009, Kalle Jokiniemi wrote:
> > On Thu, 2009-01-22 at 09:55 -0800, David Brownell wrote:
> > > On Wednesday 21 January 2009, Kalle Jokiniemi wrote:
> > > > This patch disables USB regulators VUSB1V5, VUSB1V8, and VUSB3V1
> > > > when the USB cable is unplugged to reduce power consumption.
> > > 
> > > Worked fine on a Beagle, now I'm trying to find out
> > > what's borked on an Overo ...
> > 
> > Did you manage to get it working on Overo? 
> 
> Yes.  It must have either been a bad build, or an issue
> with one of the other patches, or something.

OK, great :)

> 
> 
> > BTW. Should I post this patch to linux-usb as well?
> 
> If you like, but it can't merge yet ... the twl4030
> regulator code isn't in mainline yet.  I think it's
> ready given the patches I posted earlier.

Oh, so it seems. I guess I'll have to wait for the regulator code to hit
mainline.

- Kalle

> 
> - Dave
>  
> 
> 

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2009-01-28  6:37 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-01-21 13:15 [PATCH 0/1] TWL: USB: disable VUSB regulators Kalle Jokiniemi
2009-01-21 13:15 ` [PATCH 1/1] TWL: USB: disable VUSB regulators when cable unplugged Kalle Jokiniemi
2009-01-22 17:55   ` David Brownell
2009-01-27  9:50     ` Kalle Jokiniemi
2009-01-28  2:02       ` David Brownell
2009-01-28  6:36         ` Kalle Jokiniemi
2009-01-21 20:38 ` [PATCH 0/1] TWL: USB: disable VUSB regulators David Brownell
2009-01-21 21:19   ` Woodruff, Richard
2009-01-21 21:47     ` David Brownell
2009-01-23 10:55   ` Kalle Jokiniemi

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.