[U-Boot] [PATCH 1/4] sunxi: musb: Fix some lo speed devices not working with musb host
Paul Kocialkowski
contact at paulk.fr
Mon Mar 30 15:27:46 CEST 2015
Le vendredi 27 mars 2015 à 22:06 +0100, Hans de Goede a écrit :
> The usb0 / otg phy on sunxi boards has a bug where it wrongly detects a
> high speed squelch on usb reset deassert when a lo speed device is plugged in.
>
> The android kernel has a work around for this in the form of temporary
> disabling the phy's squelch detection on reset deassert, this commit adds
> the same workaround to the u-boot sunxi musb code, thereby fixing various usb
> lo speed devices not working.
>
> Tested with a (before non working) usb keyboard and a usb 2.4 GHz wireless
> keyboard/mouse combo receiver.
This also made my USB low speed keyboard work with U-Boot, but I'm
getting the following message after USB init:
musb_h_ep0_irq 1069: no URB for end 0
In addition, enabling caps lock or num lock (which should trigger a LED)
makes the keyboard stop working until I reset the board. On an USB2
keyboard, caps lock and num lock work just fine.
I'll try to investigate that when I have time, thanks for working on
this!
> Signed-off-by: Hans de Goede <hdegoede at redhat.com>
> ---
> arch/arm/cpu/armv7/sunxi/usbc.c | 7 +++++++
> arch/arm/include/asm/arch-sunxi/usbc.h | 1 +
> drivers/usb/musb-new/musb_uboot.c | 14 ++++++++++++++
> 3 files changed, 22 insertions(+)
>
> diff --git a/arch/arm/cpu/armv7/sunxi/usbc.c b/arch/arm/cpu/armv7/sunxi/usbc.c
> index d2d9891..1c777aa 100644
> --- a/arch/arm/cpu/armv7/sunxi/usbc.c
> +++ b/arch/arm/cpu/armv7/sunxi/usbc.c
> @@ -182,6 +182,13 @@ static void sunxi_usb_passby(struct sunxi_usbc_hcd *sunxi_usbc, int enable)
> return;
> }
>
> +void sunxi_usbc_enable_squelch_detect(int index, int enable)
> +{
> + struct sunxi_usbc_hcd *sunxi_usbc = &sunxi_usbc_hcd[index];
> +
> + usb_phy_write(sunxi_usbc, 0x3c, enable ? 0 : 2, 2);
> +}
> +
> int sunxi_usbc_request_resources(int index)
> {
> struct sunxi_usbc_hcd *sunxi_usbc = &sunxi_usbc_hcd[index];
> diff --git a/arch/arm/include/asm/arch-sunxi/usbc.h b/arch/arm/include/asm/arch-sunxi/usbc.h
> index 67281ec..ab0f272 100644
> --- a/arch/arm/include/asm/arch-sunxi/usbc.h
> +++ b/arch/arm/include/asm/arch-sunxi/usbc.h
> @@ -21,3 +21,4 @@ void sunxi_usbc_disable(int index);
> void sunxi_usbc_vbus_enable(int index);
> void sunxi_usbc_vbus_disable(int index);
> int sunxi_usbc_vbus_detect(int index);
> +void sunxi_usbc_enable_squelch_detect(int index, int enable);
> diff --git a/drivers/usb/musb-new/musb_uboot.c b/drivers/usb/musb-new/musb_uboot.c
> index 6e58ddf..51fb3fd 100644
> --- a/drivers/usb/musb-new/musb_uboot.c
> +++ b/drivers/usb/musb-new/musb_uboot.c
> @@ -1,5 +1,8 @@
> #include <common.h>
> #include <watchdog.h>
> +#ifdef CONFIG_ARCH_SUNXI
> +#include <asm/arch/usbc.h>
> +#endif
> #include <asm/errno.h>
> #include <linux/usb/ch9.h>
> #include <linux/usb/gadget.h>
> @@ -186,8 +189,19 @@ void usb_reset_root_port(void)
> power &= 0xf0;
> musb_writeb(mbase, MUSB_POWER, MUSB_POWER_RESET | power);
> mdelay(50);
> +#ifdef CONFIG_ARCH_SUNXI
> + /*
> + * sunxi phy has a bug and it will wrongly detect high speed squelch
> + * when clearing reset on low-speed devices, temporary disable
> + * squelch detection to work around this.
> + */
> + sunxi_usbc_enable_squelch_detect(0, 0);
> +#endif
> power = musb_readb(mbase, MUSB_POWER);
> musb_writeb(mbase, MUSB_POWER, ~MUSB_POWER_RESET & power);
> +#ifdef CONFIG_ARCH_SUNXI
> + sunxi_usbc_enable_squelch_detect(0, 1);
> +#endif
> host->isr(0, host);
> host_speed = (musb_readb(mbase, MUSB_POWER) & MUSB_POWER_HSMODE) ?
> USB_SPEED_HIGH :
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150330/4be7c767/attachment.sig>
More information about the U-Boot
mailing list