linux-sunxi.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Andre Przywara <andre.przywara@arm.com>
To: Paul Kocialkowski <contact@paulk.fr>
Cc: Jagan Teki <jagan@amarulasolutions.com>,
	u-boot@lists.denx.de, Jernej Skrabec <jernej.skrabec@gmail.com>,
	Samuel Holland <samuel@sholland.org>,
	Icenowy Zheng <icenowy@aosc.io>,
	linux-sunxi@lists.linux.dev
Subject: Re: [PATCH] phy: sun4i-usb: Fix PHY0 routing and passby configuration for MUSB
Date: Wed, 26 May 2021 12:29:41 +0100	[thread overview]
Message-ID: <20210526122941.4e8ae3eb@slackpad.fritz.box> (raw)
In-Reply-To: <YK4ne9OtEON85akS@collins>

On Wed, 26 May 2021 12:48:27 +0200
Paul Kocialkowski <contact@paulk.fr> wrote:

Hi Paul,

> Le Wed 26 May 21, 01:57, Andre Przywara a écrit :
> > From: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
> > 
> > Recent Allwinner platforms (starting with the H3) only use the MUSB
> > controller for peripheral mode and use HCI for host mode. As a result,
> > extra steps need to be taken to properly route USB signals to one or
> > the other. More precisely, the following is required:
> > * Routing the pins to either HCI/MUSB (controlled by PHY);
> > * Enabling USB PHY passby in HCI mode (controlled by PMU).
> > 
> > The current code will enable passby for each PHY and reroute PHY0 to
> > MUSB, which is inconsistent and results in broken USB host support
> > for port 0.
> > 
> > Passby on PHY0 must only be enabled when we want to use HCI. Since
> > host/device mode detection is not available from the PHY code and
> > because U-Boot does not support changing the mode dynamically anyway,
> > we can just mux the controller to MUSB if it is enabled and mux it to
> > HCI otherwise.
> > 
> > This fixes USB host support for port 0 on platforms with PHY0 dual-route,
> > especially on boards like Pine64 (with only USB-A host ports) and
> > TV boxes without OTG ports.
> > 
> > Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
> > [Andre: tweak commit message, use IS_ENABLED()]
> > Signed-off-by: Andre Przywara <andre.przywara@arm.com>
> > ---
> > Hi,
> > 
> > for H6 boards to work this requires a DT update (to get the <&usbphy 0>
> > links between HCI and PHY), which I will send later.
> > Tested on Pine H64, Pine64-LTS, OrangePi Zero, OrangePi PC 2, BananaPi M64,
> > BananaPi M1.  
> 
> Thanks for resending this, I've also had to revive this patch lately to get
> USB working on the V3 so I definitely second that it's still relevant!

Great! I had this under observation for quite a while, but was somewhat
puzzled because your original commit message mentioned that OTG was
broken, which worked fine for me. Maybe this was fixed meanwhile?

But what was still broken for me is host port 0, which disables one of
the two USB-A ports on the Pine64 boards (Pine64+, Pine64-LTS,
Pine-H64), also on those TV boxes. This makes connecting a keyboard and
an USB stick at the same time complicated.
But even with this patch alone it doesn't work, because the DTs are
(were) missing the phys property for ehci0/ohci0 (which I meanwhile
fixed in Linux, for exactly that reason). We synced the A64 DTs already
back into U-Boot, and I will send the H3/H5/H6 parts today.

So can you confirm that this now works for you, ideally with both OTG
and host ports on the same device? I tried this with enforcing OTG
on the Pine64, but would love to see reports from others.
Please respond with a Tested-by: tag then!

Thanks!
Andre

P.S. I kept your bootlin address as the author (that's what we do at
work in those cases: keep attribution to the employer sponsoring the
work at the time), please let me know if I should change this. I can add
your current address in some other tag, to have a working contact.

> 
> Paul
> 
> > Cheers,
> > Andre
> > 
> >  drivers/phy/allwinner/phy-sun4i-usb.c | 16 ++++++++++++++--
> >  1 file changed, 14 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/phy/allwinner/phy-sun4i-usb.c b/drivers/phy/allwinner/phy-sun4i-usb.c
> > index 5723c980323..e6ceafc7648 100644
> > --- a/drivers/phy/allwinner/phy-sun4i-usb.c
> > +++ b/drivers/phy/allwinner/phy-sun4i-usb.c
> > @@ -313,9 +313,21 @@ static int sun4i_usb_phy_init(struct phy *phy)
> >  				    data->cfg->disc_thresh, PHY_DISCON_TH_LEN);
> >  	}
> >  
> > -	sun4i_usb_phy_passby(phy, true);
> > +	if (IS_ENABLED(CONFIG_USB_MUSB_SUNXI)) {
> > +		/* Needed for HCI and conflicts with MUSB, keep PHY0 on MUSB */
> > +		if (usb_phy->id != 0)
> > +			sun4i_usb_phy_passby(phy, true);
> > +
> > +		/* Route PHY0 to MUSB to allow USB gadget */
> > +		if (data->cfg->phy0_dual_route)
> > +			sun4i_usb_phy0_reroute(data, true);
> > +	} else {
> > +		sun4i_usb_phy_passby(phy, true);
> >  
> > -	sun4i_usb_phy0_reroute(data, true);
> > +		/* Route PHY0 to HCI to allow USB host */
> > +		if (data->cfg->phy0_dual_route)
> > +			sun4i_usb_phy0_reroute(data, false);
> > +	}
> >  
> >  	return 0;
> >  }
> > -- 
> > 2.17.5
> >   
> 


  reply	other threads:[~2021-05-26 11:30 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-26  0:57 [PATCH] phy: sun4i-usb: Fix PHY0 routing and passby configuration for MUSB Andre Przywara
2021-05-26 10:48 ` Paul Kocialkowski
2021-05-26 11:29   ` Andre Przywara [this message]
2021-05-26 17:07 ` Jagan Teki
2021-05-26 17:31   ` Andre Przywara
2021-05-26 18:21     ` Jagan Teki
2021-05-26 19:08       ` Andre Przywara
2021-05-27 11:33         ` Jagan Teki

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=20210526122941.4e8ae3eb@slackpad.fritz.box \
    --to=andre.przywara@arm.com \
    --cc=contact@paulk.fr \
    --cc=icenowy@aosc.io \
    --cc=jagan@amarulasolutions.com \
    --cc=jernej.skrabec@gmail.com \
    --cc=linux-sunxi@lists.linux.dev \
    --cc=samuel@sholland.org \
    --cc=u-boot@lists.denx.de \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).