* [PATCH 0/2] TWL: USB: Start using twl4030/5030 regulator driver
@ 2009-02-11 7:06 Kalle Jokiniemi
[not found] ` <1234336002-26372-1-git-send-email-kalle.jokiniemi-sMOQStClEysAvxtiuMwx3w@public.gmane.org>
0 siblings, 1 reply; 8+ messages in thread
From: Kalle Jokiniemi @ 2009-02-11 7:06 UTC (permalink / raw)
To: david-b; +Cc: lrg, linux-kernel, linux-usb, linux-omap, jouni.hogander, broonie
These couple of patches enable dynamic swithcing of the
regulators used by twl4030 usb tranceiver.
This set replaces the single patch "USB: disable twl4030
USB regulators when cable unplugged" sent previously.
The change to previous version is that possible errors
in regulator_get are now handled and the twl4030 usb
driver requires TWL_REGULATOR support to be compiled.
Thanks to Aaro Koskinen for reporing these problems.
Original patch by Kalle Jokiniemi, fixes by Jouni
Hogander.
Jouni Hogander (2):
TWL: USB: disable VUSB regulators when cable unplugged
USB: OTG: Twl4030 depends on REGULATOR_TWL4030
drivers/usb/otg/Kconfig | 2 +-
drivers/usb/otg/twl4030-usb.c | 45 +++++++++++++++++++++++++++++++++++-----
2 files changed, 40 insertions(+), 7 deletions(-)
^ permalink raw reply [flat|nested] 8+ messages in thread[parent not found: <1234336002-26372-1-git-send-email-kalle.jokiniemi-sMOQStClEysAvxtiuMwx3w@public.gmane.org>]
* [PATCH 1/2] TWL: USB: disable VUSB regulators when cable unplugged [not found] ` <1234336002-26372-1-git-send-email-kalle.jokiniemi-sMOQStClEysAvxtiuMwx3w@public.gmane.org> @ 2009-02-11 7:06 ` Kalle Jokiniemi 2009-02-11 7:06 ` [PATCH 2/2] USB: OTG: Twl4030 depends on REGULATOR_TWL4030 Kalle Jokiniemi 2009-02-11 7:23 ` [PATCH 0/2] TWL: USB: Start using twl4030/5030 regulator driver David Brownell 1 sibling, 1 reply; 8+ messages in thread From: Kalle Jokiniemi @ 2009-02-11 7:06 UTC (permalink / raw) To: david-b-yBeKhBN/0LDR7s880joybQ Cc: lrg-kDsPt+C1G03kYMGBc/C6ZA, linux-kernel-u79uwXL29TY76Z2rM5mHXA, linux-usb-u79uwXL29TY76Z2rM5mHXA, linux-omap-u79uwXL29TY76Z2rM5mHXA, jouni.hogander-xNZwKgViW5gAvxtiuMwx3w, broonie-GFdadSzt00ze9xe1eoZjHA, Kalle Jokiniemi From: Jouni Hogander <jouni.hogander-xNZwKgViW5gAvxtiuMwx3w@public.gmane.org> This patch disables USB regulators VUSB1V5, VUSB1V8, and VUSB3V1 when the USB cable is unplugged to reduce power consumption. Signed-off-by: Jouni Hogander <jouni.hogander-xNZwKgViW5gAvxtiuMwx3w@public.gmane.org> Signed-off-by: Kalle Jokiniemi <kalle.jokiniemi-sMOQStClEysAvxtiuMwx3w@public.gmane.org> --- drivers/usb/otg/twl4030-usb.c | 45 +++++++++++++++++++++++++++++++++++----- 1 files changed, 39 insertions(+), 6 deletions(-) diff --git a/drivers/usb/otg/twl4030-usb.c b/drivers/usb/otg/twl4030-usb.c index 416e441..29df421 100644 --- a/drivers/usb/otg/twl4030-usb.c +++ b/drivers/usb/otg/twl4030-usb.c @@ -34,6 +34,8 @@ #include <linux/delay.h> #include <linux/usb/otg.h> #include <linux/i2c/twl4030.h> +#include <linux/regulator/consumer.h> +#include <linux/err.h> /* Register defines */ @@ -246,6 +248,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 +441,12 @@ static void twl4030_phy_power(struct twl4030_usb *twl, int on) pwr = twl4030_usb_read(twl, PHY_PWR_CTRL); if (on) { + if (twl->usb1v5) + regulator_enable(twl->usb1v5); + if (twl->usb1v8) + regulator_enable(twl->usb1v8); + if (twl->usb3v1) + 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 +456,12 @@ 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); + if (twl->usb1v5) + regulator_disable(twl->usb1v5); + if (twl->usb1v8) + regulator_disable(twl->usb1v8); + if (twl->usb3v1) + regulator_disable(twl->usb3v1); } } @@ -470,6 +489,8 @@ static void twl4030_phy_resume(struct twl4030_usb *twl) static void twl4030_usb_ldo_init(struct twl4030_usb *twl) { + struct regulator *reg; + /* Enable writing to power configuration registers */ twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, 0xC0, PROTECT_KEY); twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, 0x0C, PROTECT_KEY); @@ -480,16 +501,25 @@ 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); + reg = regulator_get(twl->dev, "usb3v1"); + if (!IS_ERR(reg)) + twl->usb3v1 = reg; 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); + reg = regulator_get(twl->dev, "usb1v5"); + if (!IS_ERR(reg)) + twl->usb1v5 = reg; 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); + reg = regulator_get(twl->dev, "usb1v8"); + if (!IS_ERR(reg)) + twl->usb1v8 = reg; twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0, VUSB1V8_TYPE); /* disable access to power configuration registers */ @@ -688,6 +718,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.4.3 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/2] USB: OTG: Twl4030 depends on REGULATOR_TWL4030 2009-02-11 7:06 ` [PATCH 1/2] TWL: USB: disable VUSB regulators when cable unplugged Kalle Jokiniemi @ 2009-02-11 7:06 ` Kalle Jokiniemi 0 siblings, 0 replies; 8+ messages in thread From: Kalle Jokiniemi @ 2009-02-11 7:06 UTC (permalink / raw) To: david-b Cc: lrg, linux-kernel, linux-usb, linux-omap, jouni.hogander, broonie, Kalle Jokiniemi From: Jouni Hogander <jouni.hogander@nokia.com> Twl4030 doesn't work without twl4030-regulator so it should depend on that. Signed-off-by: Jouni Hogander <jouni.hogander@nokia.com> Signed-off-by: Kalle Jokiniemi <kalle.jokiniemi@digia.com> --- drivers/usb/otg/Kconfig | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/drivers/usb/otg/Kconfig b/drivers/usb/otg/Kconfig index ee55b44..5790a5b 100644 --- a/drivers/usb/otg/Kconfig +++ b/drivers/usb/otg/Kconfig @@ -43,7 +43,7 @@ config ISP1301_OMAP config TWL4030_USB tristate "TWL4030 USB Transceiver Driver" - depends on TWL4030_CORE + depends on TWL4030_CORE && REGULATOR_TWL4030 select USB_OTG_UTILS help Enable this to support the USB OTG transceiver on TWL4030 -- 1.5.4.3 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 0/2] TWL: USB: Start using twl4030/5030 regulator driver [not found] ` <1234336002-26372-1-git-send-email-kalle.jokiniemi-sMOQStClEysAvxtiuMwx3w@public.gmane.org> 2009-02-11 7:06 ` [PATCH 1/2] TWL: USB: disable VUSB regulators when cable unplugged Kalle Jokiniemi @ 2009-02-11 7:23 ` David Brownell [not found] ` <200902102323.30395.david-b-yBeKhBN/0LDR7s880joybQ@public.gmane.org> 1 sibling, 1 reply; 8+ messages in thread From: David Brownell @ 2009-02-11 7:23 UTC (permalink / raw) To: Kalle Jokiniemi Cc: lrg-kDsPt+C1G03kYMGBc/C6ZA, linux-kernel-u79uwXL29TY76Z2rM5mHXA, linux-usb-u79uwXL29TY76Z2rM5mHXA, linux-omap-u79uwXL29TY76Z2rM5mHXA, jouni.hogander-xNZwKgViW5gAvxtiuMwx3w, broonie-GFdadSzt00ze9xe1eoZjHA On Tuesday 10 February 2009, Kalle Jokiniemi wrote: > These couple of patches enable dynamic swithcing of the > regulators used by twl4030 usb tranceiver. > > This set replaces the single patch "USB: disable twl4030 > USB regulators when cable unplugged" sent previously. > The change to previous version is that possible errors > in regulator_get are now handled and the twl4030 usb > driver requires TWL_REGULATOR support to be compiled. It'd make more sense to me as a single patch ... :) And also, instead of *continuing* after the regulators can't be acquired, it's better to abort. It's not going to be able to do anything ... so don't finish probing, and don't register this "dead" transceiver. - Dave -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 8+ messages in thread
[parent not found: <200902102323.30395.david-b-yBeKhBN/0LDR7s880joybQ@public.gmane.org>]
* Re: [PATCH 0/2] TWL: USB: Start using twl4030/5030 regulator driver [not found] ` <200902102323.30395.david-b-yBeKhBN/0LDR7s880joybQ@public.gmane.org> @ 2009-02-11 10:47 ` Kalle Jokiniemi 2009-02-13 9:57 ` Kalle Jokiniemi 0 siblings, 1 reply; 8+ messages in thread From: Kalle Jokiniemi @ 2009-02-11 10:47 UTC (permalink / raw) To: David Brownell Cc: lrg-kDsPt+C1G03kYMGBc/C6ZA, linux-kernel-u79uwXL29TY76Z2rM5mHXA, linux-usb-u79uwXL29TY76Z2rM5mHXA, linux-omap-u79uwXL29TY76Z2rM5mHXA, jouni.hogander-xNZwKgViW5gAvxtiuMwx3w, broonie-GFdadSzt00ze9xe1eoZjHA On Tue, 2009-02-10 at 23:23 -0800, David Brownell wrote: > On Tuesday 10 February 2009, Kalle Jokiniemi wrote: > > These couple of patches enable dynamic swithcing of the > > regulators used by twl4030 usb tranceiver. > > > > This set replaces the single patch "USB: disable twl4030 > > USB regulators when cable unplugged" sent previously. > > The change to previous version is that possible errors > > in regulator_get are now handled and the twl4030 usb > > driver requires TWL_REGULATOR support to be compiled. > > It'd make more sense to me as a single patch ... :) OK, I'll put them together. > > And also, instead of *continuing* after the regulators > can't be acquired, it's better to abort. It's not > going to be able to do anything ... so don't finish > probing, and don't register this "dead" transceiver. Makes sense. I'll fix that. -Kalle > > - Dave -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 0/2] TWL: USB: Start using twl4030/5030 regulator driver 2009-02-11 10:47 ` Kalle Jokiniemi @ 2009-02-13 9:57 ` Kalle Jokiniemi 2009-02-13 22:35 ` David Brownell 0 siblings, 1 reply; 8+ messages in thread From: Kalle Jokiniemi @ 2009-02-13 9:57 UTC (permalink / raw) To: David Brownell Cc: lrg-kDsPt+C1G03kYMGBc/C6ZA, linux-usb-u79uwXL29TY76Z2rM5mHXA, linux-omap-u79uwXL29TY76Z2rM5mHXA, jouni.hogander-xNZwKgViW5gAvxtiuMwx3w, broonie-GFdadSzt00ze9xe1eoZjHA On Wed, 2009-02-11 at 12:47 +0200, Kalle Jokiniemi wrote: > On Tue, 2009-02-10 at 23:23 -0800, David Brownell wrote: > > On Tuesday 10 February 2009, Kalle Jokiniemi wrote: > > > These couple of patches enable dynamic swithcing of the > > > regulators used by twl4030 usb tranceiver. > > > > > > This set replaces the single patch "USB: disable twl4030 > > > USB regulators when cable unplugged" sent previously. > > > The change to previous version is that possible errors > > > in regulator_get are now handled and the twl4030 usb > > > driver requires TWL_REGULATOR support to be compiled. > > > > It'd make more sense to me as a single patch ... :) > > OK, I'll put them together. > > > > > And also, instead of *continuing* after the regulators > > can't be acquired, it's better to abort. It's not > > going to be able to do anything ... so don't finish > > probing, and don't register this "dead" transceiver. > > Makes sense. I'll fix that. I ran into some trouble with the merged fix. For some reason clearing the VUSB3V1_DEV_GRP register causes VUSB_DEDICATED2.VUSB3V1_SLEEP bit to be enabled. This means that once VUSB3V1_DEV_GRP is put back to enabled state (VUSB3V1 changed to be part of P1 group again), VUSB3V1 does not go ACTIVE, but SLEEP state instead. Anyone have a clue what might cause this? The VUSB_DEDICATED2.VUSB3V1_SLEEP bit remaps ACTIVE state to SLEEP. I tested with the original patch as well and it has the same behaviour. But I'm quite sure that I did not see this when I was doing the original patch. I can workaround this by clearing the VUSB_DEDICATED2.VUSB3V1_SLEEP every time we enable the VUSB3V1 regulator, but I'd rather know why it changes in the first place. Dropped LKM from the cc... - Kalle > > -Kalle > > > > > - Dave > -- > To unsubscribe from this list: send the line "unsubscribe linux-omap" in > the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org > More majordomo info at http://vger.kernel.org/majordomo-info.html -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 0/2] TWL: USB: Start using twl4030/5030 regulator driver 2009-02-13 9:57 ` Kalle Jokiniemi @ 2009-02-13 22:35 ` David Brownell 2009-02-20 8:56 ` Kalle Jokiniemi 0 siblings, 1 reply; 8+ messages in thread From: David Brownell @ 2009-02-13 22:35 UTC (permalink / raw) To: Kalle Jokiniemi; +Cc: lrg, linux-usb, linux-omap, jouni.hogander, broonie On Friday 13 February 2009, Kalle Jokiniemi wrote: > I ran into some trouble with the merged fix. For some reason clearing > the VUSB3V1_DEV_GRP register causes VUSB_DEDICATED2.VUSB3V1_SLEEP bit to > be enabled. This means that once VUSB3V1_DEV_GRP is put back to enabled > state (VUSB3V1 changed to be part of P1 group again), VUSB3V1 does not > go ACTIVE, but SLEEP state instead. > > Anyone have a clue what might cause this? Curious. No ... is that specific to some TWL revision? I'll poke around after I get this new board working better for me. - Dave ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 0/2] TWL: USB: Start using twl4030/5030 regulator driver 2009-02-13 22:35 ` David Brownell @ 2009-02-20 8:56 ` Kalle Jokiniemi 0 siblings, 0 replies; 8+ messages in thread From: Kalle Jokiniemi @ 2009-02-20 8:56 UTC (permalink / raw) To: David Brownell; +Cc: lrg, linux-usb, linux-omap, jouni.hogander, broonie On Fri, 2009-02-13 at 14:35 -0800, David Brownell wrote: > On Friday 13 February 2009, Kalle Jokiniemi wrote: > > I ran into some trouble with the merged fix. For some reason clearing > > the VUSB3V1_DEV_GRP register causes VUSB_DEDICATED2.VUSB3V1_SLEEP bit to > > be enabled. This means that once VUSB3V1_DEV_GRP is put back to enabled > > state (VUSB3V1 changed to be part of P1 group again), VUSB3V1 does not > > go ACTIVE, but SLEEP state instead. > > > > Anyone have a clue what might cause this? > > Curious. No ... is that specific to some TWL revision? TWL5030, I think the revision is ES1.0. I got additional info from TI that when the LDO goes into off state, the sleep bit indeed resets back to default value of 1. Which is to remap active state to sleep. So I have a patch that takes this into account by clearing the remap bit every time we wake up the VUSB3V1 regulator. - Kalle > > I'll poke around after I get this new board working better for me. > > - Dave ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2009-02-20 8:56 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-11 7:06 [PATCH 0/2] TWL: USB: Start using twl4030/5030 regulator driver Kalle Jokiniemi
[not found] ` <1234336002-26372-1-git-send-email-kalle.jokiniemi-sMOQStClEysAvxtiuMwx3w@public.gmane.org>
2009-02-11 7:06 ` [PATCH 1/2] TWL: USB: disable VUSB regulators when cable unplugged Kalle Jokiniemi
2009-02-11 7:06 ` [PATCH 2/2] USB: OTG: Twl4030 depends on REGULATOR_TWL4030 Kalle Jokiniemi
2009-02-11 7:23 ` [PATCH 0/2] TWL: USB: Start using twl4030/5030 regulator driver David Brownell
[not found] ` <200902102323.30395.david-b-yBeKhBN/0LDR7s880joybQ@public.gmane.org>
2009-02-11 10:47 ` Kalle Jokiniemi
2009-02-13 9:57 ` Kalle Jokiniemi
2009-02-13 22:35 ` David Brownell
2009-02-20 8:56 ` Kalle Jokiniemi
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox