[2/2] usb: phy: omap_usb_phy: implement usb_phy_power() for AM437x

Message ID 1403558739-24461-2-git-send-email-balbi@ti.com
State New
Headers show

Commit Message

Felipe Balbi June 23, 2014, 9:25 p.m.
Newer AM437x silicon requires us to explicitly power up
the USB2 PHY. By implementing usb_phy_power() we can
achieve that.

Signed-off-by: Felipe Balbi <balbi@ti.com>
---
 drivers/usb/phy/omap_usb_phy.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

Comments

Michael Trimarchi June 23, 2014, 9:28 p.m. | #1
Hi

Il 23/giu/2014 23:26 "Felipe Balbi" <balbi@ti.com> ha scritto:
>
> Newer AM437x silicon requires us to explicitly power up
> the USB2 PHY. By implementing usb_phy_power() we can
> achieve that.
>
> Signed-off-by: Felipe Balbi <balbi@ti.com>
> ---
>  drivers/usb/phy/omap_usb_phy.c | 17 ++++++++++++++++-
>  1 file changed, 16 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/usb/phy/omap_usb_phy.c
b/drivers/usb/phy/omap_usb_phy.c
> index af46db2..0ed3e70 100644
> --- a/drivers/usb/phy/omap_usb_phy.c
> +++ b/drivers/usb/phy/omap_usb_phy.c
> @@ -222,7 +222,22 @@ static void am437x_enable_usb2_phy2(struct omap_xhci
*omap)
>
>  void usb_phy_power(int on)
>  {
> -       return;
> +       u32 val;
> +
> +       /* USB1_CTRL */
> +       val = readl(0x44e10628);

Can you please describe 0x44e...

> +       if (on) {
> +               /*
> +                * these bits are re-used on AM437x to power up/down the
USB
> +                * CM and OTG PHYs, if we don't toggle them, USB will not
be
> +                * functional on newer silicon revisions
> +                */
> +               val &= ~0x3;
> +       } else {
> +               val |= 0x3;

ditto

> +       }
> +
> +       writel(val, 0x44e10628);

ditto

>  }
>  #endif /* CONFIG_AM437X_USB2PHY2_HOST */
>

Michael

> --
> 2.0.0.390.gcb682f8
>
> _______________________________________________
> U-Boot mailing list
> U-Boot@lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot
Felipe Balbi June 23, 2014, 9:58 p.m. | #2
Hi,

On Mon, Jun 23, 2014 at 11:28:30PM +0200, Michael Trimarchi wrote:
> > @@ -222,7 +222,22 @@ static void am437x_enable_usb2_phy2(struct omap_xhci
> *omap)
> >
> >  void usb_phy_power(int on)
> >  {
> > -       return;
> > +       u32 val;
> > +
> > +       /* USB1_CTRL */
> > +       val = readl(0x44e10628);
> 
> Can you please describe 0x44e...

describe in what way ? The comment right above it, tells you what it is,
so does the comment in the if block. Now, if what you're asking is for
#defines for those constants, sure, I can do that.
Michael Trimarchi June 23, 2014, 10:02 p.m. | #3
Hi

Il 23/giu/2014 23:58 "Felipe Balbi" <balbi@ti.com> ha scritto:
>
> Hi,
>
> On Mon, Jun 23, 2014 at 11:28:30PM +0200, Michael Trimarchi wrote:
> > > @@ -222,7 +222,22 @@ static void am437x_enable_usb2_phy2(struct
omap_xhci
> > *omap)
> > >
> > >  void usb_phy_power(int on)
> > >  {
> > > -       return;
> > > +       u32 val;
> > > +
> > > +       /* USB1_CTRL */
> > > +       val = readl(0x44e10628);
> >
> > Can you please describe 0x44e...
>
> describe in what way ? The comment right above it, tells you what it is,
> so does the comment in the if block. Now, if what you're asking is for
> #defines for those constants, sure, I can do that.

Yes, this was the suggestione

>
> --
> balbi

Patch

diff --git a/drivers/usb/phy/omap_usb_phy.c b/drivers/usb/phy/omap_usb_phy.c
index af46db2..0ed3e70 100644
--- a/drivers/usb/phy/omap_usb_phy.c
+++ b/drivers/usb/phy/omap_usb_phy.c
@@ -222,7 +222,22 @@  static void am437x_enable_usb2_phy2(struct omap_xhci *omap)
 
 void usb_phy_power(int on)
 {
-	return;
+	u32 val;
+
+	/* USB1_CTRL */
+	val = readl(0x44e10628);
+	if (on) {
+		/*
+		 * these bits are re-used on AM437x to power up/down the USB
+		 * CM and OTG PHYs, if we don't toggle them, USB will not be
+		 * functional on newer silicon revisions
+		 */
+		val &= ~0x3;
+	} else {
+		val |= 0x3;
+	}
+
+	writel(val, 0x44e10628);
 }
 #endif /* CONFIG_AM437X_USB2PHY2_HOST */