[PATCH 1/2] usb: musb-new: sunxi: only perform SRAM initialization when necessary

Andre Przywara andre.przywara at arm.com
Fri Jun 9 12:00:51 CEST 2023


On Wed,  7 Jun 2023 17:16:43 -0600
Sam Edwards <cfsworks at gmail.com> wrote:

Hi,

> Only the older (ca. A10, A20) sunxis need this poke for the MUSB to
> function. Mimic the Linux kernel and add a `has_sram` flag to the config
> structure that is only set for the specific compatibles that require
> this initialization.

So I grabbed a BananaPi (A20) and played with it a little. Gadgets still
work with this patch, also I can confirm that this bit is necessary
(turned it off with mw.l, and the gadget stopped working), and also
that the bit flip works (set "has_sram = false;" and it didn't work anymore).

Also tested on an OrangePi Zero (H3), which doesn't need the SRAM switch.
It worked with both the bit set and cleared, also before and after the
patch, so it's all fine.

> Signed-off-by: Sam Edwards <CFSworks at gmail.com>

Reviewed-by: Andre Przywara <andre.przywara at arm.com>
Tested-by: Andre Przywara <andre.przywara at arm.com>

Thanks,
Andre

> ---
>  drivers/usb/musb-new/sunxi.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/musb-new/sunxi.c b/drivers/usb/musb-new/sunxi.c
> index ab55d68620..c05c0d5561 100644
> --- a/drivers/usb/musb-new/sunxi.c
> +++ b/drivers/usb/musb-new/sunxi.c
> @@ -85,6 +85,7 @@
>  
>  struct sunxi_musb_config {
>  	struct musb_hdrc_config *config;
> +	bool has_sram;
>  };
>  
>  struct sunxi_glue {
> @@ -313,7 +314,10 @@ static int sunxi_musb_init(struct musb *musb)
>  
>  	musb->isr = sunxi_musb_interrupt;
>  
> -	USBC_ConfigFIFO_Base();
> +	if (glue->cfg->has_sram) {
> +		USBC_ConfigFIFO_Base();
> +	}
> +
>  	USBC_EnableDpDmPullUp(musb->mregs);
>  	USBC_EnableIdPullUp(musb->mregs);
>  
> @@ -525,6 +529,7 @@ static int musb_usb_remove(struct udevice *dev)
>  
>  static const struct sunxi_musb_config sun4i_a10_cfg = {
>  	.config = &musb_config,
> +	.has_sram = true,
>  };
>  
>  static const struct sunxi_musb_config sun6i_a31_cfg = {



More information about the U-Boot mailing list