All of lore.kernel.org
 help / color / mirror / Atom feed
From: Felipe Balbi <balbi-l0cyMroinI0@public.gmane.org>
To: Grazvydas Ignotas <notasas-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: balbi-l0cyMroinI0@public.gmane.org,
	linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-omap-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	NeilBrown <neilb-l3A5Bk7waGM@public.gmane.org>,
	kishon <kishon-l0cyMroinI0@public.gmane.org>
Subject: Re: [PATCHv2 5/7] usb: phy: twl4030-usb: check if vbus is driven by twl itself
Date: Thu, 21 Mar 2013 18:43:32 +0200	[thread overview]
Message-ID: <20130321164332.GD15740@arwen.pp.htv.fi> (raw)
In-Reply-To: <CANOLnOOS6X95ijodL903zqLn3emNZ-rDX0xrxYQUXFJ1PR-PZw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>

[-- Attachment #1: Type: text/plain, Size: 2759 bytes --]

Hi,

On Thu, Mar 21, 2013 at 03:42:46PM +0200, Grazvydas Ignotas wrote:
> >> At least on pandora, STS_VBUS gets set even when VBUS is driven by twl
> >> itself. Reporting VBUS in this case confuses OMAP musb glue and charger
> >> driver, so check if OTG VBUS charge pump is on before reporting VBUS
> >> event to avoid this problem.
> >>
> >> Signed-off-by: Grazvydas Ignotas <notasas-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> >> ---
> >>  drivers/usb/phy/phy-twl4030-usb.c |   36 +++++++++++++++++++++++++++++++-----
> >>  1 file changed, 31 insertions(+), 5 deletions(-)
> >>
> >> diff --git a/drivers/usb/phy/phy-twl4030-usb.c b/drivers/usb/phy/phy-twl4030-usb.c
> >> index 425c18a..87bf11d 100644
> >> --- a/drivers/usb/phy/phy-twl4030-usb.c
> >> +++ b/drivers/usb/phy/phy-twl4030-usb.c
> >> @@ -248,11 +248,31 @@ twl4030_usb_clear_bits(struct twl4030_usb *twl, u8 reg, u8 bits)
> >>
> >>  /*-------------------------------------------------------------------------*/
> >>
> >> +static bool twl4030_is_driving_vbus(struct twl4030_usb *twl)
> >> +{
> >> +     int ret;
> >> +
> >> +     ret = twl4030_usb_read(twl, PHY_CLK_CTRL_STS);
> >> +     if (ret < 0 || !(ret & PHY_DPLL_CLK))
> >> +             /*
> >> +              * if clocks are off, registers are not updated,
> >> +              * but we can assume we don't drive VBUS in this case
> >> +              */
> >> +             return false;
> >> +
> >> +     ret = twl4030_usb_read(twl, ULPI_OTG_CTRL);
> >> +     if (ret < 0)
> >> +             return false;
> >> +
> >> +     return (ret & (ULPI_OTG_DRVVBUS | ULPI_OTG_CHRGVBUS)) ? true : false;
> >> +}
> >> +
> >>  static enum omap_musb_vbus_id_status
> >>       twl4030_usb_linkstat(struct twl4030_usb *twl)
> >>  {
> >>       int     status;
> >>       enum omap_musb_vbus_id_status linkstat = OMAP_MUSB_UNKNOWN;
> >> +     bool    driving_vbus = false;
> >>
> >>       twl->vbus_supplied = false;
> >>
> >> @@ -270,20 +290,26 @@ static enum omap_musb_vbus_id_status
> >>       if (status < 0)
> >>               dev_err(twl->dev, "USB link status err %d\n", status);
> >>       else if (status & (BIT(7) | BIT(2))) {
> >> -             if (status & (BIT(7)))
> >> -                        twl->vbus_supplied = true;
> >> +             if (status & BIT(7)) {
> >> +                     driving_vbus = twl4030_is_driving_vbus(twl);
> >> +                     if (driving_vbus)
> >
> > how about just:
> >
> > if (twl4030_is_driving_vbus(twl))
> >         status &= ~BIT(7);
> >
> > ????
> 
> I'm logging driving_vbus below with dev_dbg(), so that it's easier to
> see what going on..

is that really necessary ? Don't we expose it through sysfs already ?

-- 
balbi

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

  parent reply	other threads:[~2013-03-21 16:43 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-17 18:23 [PATCHv2 0/7] usb: phy: twl4030-usb fixes Grazvydas Ignotas
2013-03-17 18:23 ` [PATCHv2 3/7] usb: phy: twl4030-usb: don't switch the phy on/off needlessly Grazvydas Ignotas
2013-03-17 18:23 ` [PATCHv2 6/7] usb: musb: omap2430: turn off vbus on cable disconnect Grazvydas Ignotas
2013-03-17 18:23 ` [PATCHv2 7/7] usb: musb: gadget: use platform callback to enable vbus Grazvydas Ignotas
     [not found] ` <1363544607-17634-1-git-send-email-notasas-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-03-17 18:23   ` [PATCHv2 1/7] usb: phy: twl4030-usb: don't enable PHY during init Grazvydas Ignotas
2013-03-17 18:23   ` [PATCHv2 2/7] usb: phy: twl4030-usb: ignore duplicate events Grazvydas Ignotas
2013-03-17 18:23   ` [PATCHv2 4/7] usb: phy: twl4030-usb: poll for ID disconnect Grazvydas Ignotas
2013-03-17 18:23   ` [PATCHv2 5/7] usb: phy: twl4030-usb: check if vbus is driven by twl itself Grazvydas Ignotas
     [not found]     ` <1363544607-17634-6-git-send-email-notasas-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-03-20 13:07       ` Felipe Balbi
     [not found]         ` <20130320130750.GR29659-S8G//mZuvNWo5Im9Ml3/Zg@public.gmane.org>
2013-03-21 13:42           ` Grazvydas Ignotas
     [not found]             ` <CANOLnOOS6X95ijodL903zqLn3emNZ-rDX0xrxYQUXFJ1PR-PZw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-03-21 16:43               ` Felipe Balbi [this message]
2013-03-20 12:54   ` [PATCHv2 0/7] usb: phy: twl4030-usb fixes Felipe Balbi
     [not found]     ` <20130320125425.GQ29659-S8G//mZuvNWo5Im9Ml3/Zg@public.gmane.org>
2013-03-20 13:08       ` Felipe Balbi

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=20130321164332.GD15740@arwen.pp.htv.fi \
    --to=balbi-l0cymroini0@public.gmane.org \
    --cc=kishon-l0cyMroinI0@public.gmane.org \
    --cc=linux-omap-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=neilb-l3A5Bk7waGM@public.gmane.org \
    --cc=notasas-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.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.