[PATCH] phy: sun4i-usb: Fix PHY0 routing and passby configuration for MUSB

Paul Kocialkowski contact at paulk.fr
Wed May 26 12:48:27 CEST 2021


Hi Andre,

Le Wed 26 May 21, 01:57, Andre Przywara a écrit :
> From: Paul Kocialkowski <paul.kocialkowski at 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 at bootlin.com>
> [Andre: tweak commit message, use IS_ENABLED()]
> Signed-off-by: Andre Przywara <andre.przywara at 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!

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
> 

-- 
Developer of free digital technology and hardware support.

Website: https://www.paulk.fr/
Coding blog: https://code.paulk.fr/
Git repositories: https://git.paulk.fr/ https://git.code.paulk.fr/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20210526/3a167a94/attachment.sig>


More information about the U-Boot mailing list