All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] i.MX53 USB Client not working
@ 2015-05-14 22:39 Matthew Starr
  2015-05-20  2:45 ` Fabio Estevam
  0 siblings, 1 reply; 5+ messages in thread
From: Matthew Starr @ 2015-05-14 22:39 UTC (permalink / raw)
  To: u-boot

It appears that setting CONFIG_MXC_USB_PORT to 0 then loads the OTG port on the i.MX53.  The code appears to be in drivers/usb/host/ehci-mx5.c.    The problem then is that the USB host port is then not usable since my i.MX53 board dedicates the OTG port to USB client functionality only.

Now I am trying to get both USB Host port 1 and USB OTG port 0 working at the same time.  Does u-boot allow using multiple USB controller ports at the same time?

Best regards,
 Matthew Starr

> -----Original Message-----
> From: U-Boot [mailto:u-boot-bounces at lists.denx.de] On Behalf Of Matthew
> Starr
> Sent: Thursday, May 14, 2015 9:37 AM
> To: u-boot at lists.denx.de
> Subject: [U-Boot] i.MX53 USB Client not working
> 
> I have a custom board loosely based off the i.MX53 QSB with a dedicated USB
> client port and separate dedicated USB host port.  I am trying to get USB
> client functionality working in mainline u-boot 2015.04.  I have verified that
> USB client/gadget functionality works when booted into Linux on the board.
> In u-boot I have tried testing USB client with USB Mass Storage, DFU, and
> FastBoot and none of them seem to work.
> 
> Here is my USB client #defines from my config header file:
> #define CONFIG_CI_UDC
> #define CONFIG_USBD_HS
> #define CONFIG_USB_GADGET_DUALSPEED
> #define CONFIG_USB_GADGET
> #define CONFIG_CMD_USB_MASS_STORAGE
> #define CONFIG_USB_GADGET_MASS_STORAGE
> #define CONFIG_USBDOWNLOAD_GADGET
> #define CONFIG_USB_GADGET_VBUS_DRAW     2
> #define CONFIG_USB_ETHER
> #define CONFIG_USB_ETH_CDC
> #define CONFIG_G_DNL_VENDOR_NUM         0x0525
> #define CONFIG_G_DNL_PRODUCT_NUM        0xa4a5
> #define CONFIG_G_DNL_MANUFACTURER       "FSL"
> #define CONFIG_SYS_CACHELINE_SIZE       64
> 
> Additionally here are my #defines for the USB host functionality:
> /* USB Host Configs */
> #define CONFIG_CMD_USB
> #define CONFIG_USB_EHCI
> #define CONFIG_USB_EHCI_MX5
> #define CONFIG_USB_STORAGE
> #define CONFIG_USB_HOST_ETHER
> #define CONFIG_USB_ETHER_ASIX
> #define CONFIG_USB_ETHER_MCS7830
> #define CONFIG_USB_ETHER_SMSC95XX
> #define CONFIG_MXC_USB_PORT     1
> #define CONFIG_MXC_USB_PORTSC   (PORT_PTS_UTMI | PORT_PTS_PTW)
> #define CONFIG_MXC_USB_FLAGS    0
> 
> Here is my board file content related to USB:
>  #ifdef CONFIG_USB_EHCI_MX5
> static void setup_usb(void)
> {
>         imx_iomux_v3_setup_pad(MX53_PAD_GPIO_0__GPIO1_0);
> }
> 
>  int board_ehci_hcd_init(int port)
> {
>         /* Enable USB_H1_VBUS power with GPIO1_0 */
>         gpio_direction_output(IMX_GPIO_NR(1, 0), 1);
>         return 0;
> }
> #endif
> 
> int board_usb_phy_mode(int port)
> {
>         if (port == 1)
>                 return USB_INIT_HOST;
>         else
>                 return USB_INIT_DEVICE;
> }
> 
> Then later on in board_init(), I have:
> #ifdef CONFIG_USB_EHCI_MX5
>         setup_usb();
> #endif
> 
> When I run the 'ums 0 mmc 0' command, I get the following:
> UMS: disk start sector: 0x0, count: 0xe88000 and then I get an infinite
> spinning progress indicator.  At this point when I connect the USB cable to a
> Host PC, I see nothing on the host PC side (Windows or Liunx).
> 
> Any ideas on what I am missing to get USB client working or any hints on how
> to debug this further.
> 
> Best regards,
> ?Matthew Starr
> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [U-Boot] i.MX53 USB Client not working
  2015-05-14 22:39 [U-Boot] i.MX53 USB Client not working Matthew Starr
@ 2015-05-20  2:45 ` Fabio Estevam
  2015-05-20 19:59   ` Matthew Starr
  0 siblings, 1 reply; 5+ messages in thread
From: Fabio Estevam @ 2015-05-20  2:45 UTC (permalink / raw)
  To: u-boot

Hi Matthew,

On Thu, May 14, 2015 at 7:39 PM, Matthew Starr <mstarr@hedonline.com> wrote:
> It appears that setting CONFIG_MXC_USB_PORT to 0 then loads the OTG port on the i.MX53.  The code appears to be in drivers/usb/host/ehci-mx5.c.    The problem then is that the USB host port is then not usable since my i.MX53 board dedicates the OTG port to USB client functionality only.
>
> Now I am trying to get both USB Host port 1 and USB OTG port 0 working at the same time.  Does u-boot allow using multiple USB controller ports at the same time?

Yes, you can use both ports.

In order to do so, you need to pass #define
CONFIG_USB_MAX_CONTROLLER_COUNT 2 in your config file.

Regards,

Fabio Estevam

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [U-Boot] i.MX53 USB Client not working
  2015-05-20  2:45 ` Fabio Estevam
@ 2015-05-20 19:59   ` Matthew Starr
  2015-05-20 21:30     ` Fabio Estevam
  0 siblings, 1 reply; 5+ messages in thread
From: Matthew Starr @ 2015-05-20 19:59 UTC (permalink / raw)
  To: u-boot

Fabio,

I added the '#define CONFIG_USB_MAX_CONTROLLER_COUNT 2' to my include config file and I see that it loads both USB port 0 and 1.

To me it looks like using CONFIG_USB_MAX_CONTROLLER_COUNT produces that number of duplicate devices all of the USB port defined by CONFIG_MXC_USB_PORT.

If CONFIG_MXC_USB_PORT is set 0, I only get port 0 duplicated CONFIG_USB_MAX_CONTROLLER_COUNT times.   The ums command works, but I don't see any USB devices connected to port 1.
If CONFIG_MXC_USB_PORT is set 1, I only get port 1 duplicated CONFIG_USB_MAX_CONTROLLER_COUNT times.  The ums command shows nothing on the host side, but I can see USB devices (although multiple of the same single device, one on each port)

I looked at drivers/usb/host/ehci-mx5.c and found that the loading of USB is not dynamic and depends on the CONFIG_MXC_USB_PORT value.  In drivers/usb/host/ehci-hcd.c, the CONFIG_USB_MAX_CONTROLLER_COUNT value defines how many devices to create and the index of the current device is passed to the  usb_lowlevel_init() function in drivers/usb/host/ehci-mx5.c but is ignored.

Here is the output when running 'usb start' and then 'usb tree' when CONFIG_MXC_USB_PORT is 1 and CONFIG_USB_MAX_CONTROLLER_COUNT is 2 and a USB mass storage device is only connected to port 1:

U-Boot > usb start
starting USB...
USB0:   USB EHCI 1.00
scanning bus 0 for devices... 2 USB Device(s) found
USB1:   USB EHCI 1.00
scanning bus 1 for devices... 2 USB Device(s) found
       scanning usb for storage devices... EHCI timed out on TD - token=0x80008c80
EHCI timed out on TD - token=0x80008d80
EHCI timed out on TD - token=0x80008d80
EHCI timed out on TD - token=0x80008d80
EHCI timed out on TD - token=0x80008d80
EHCI timed out on TD - token=0x80008d80
error in inquiry
1 Storage Device(s) found
       scanning usb for ethernet devices... 0 Ethernet Device(s) found
U-Boot > usb tree
USB device tree:
  1  Hub (480 Mb/s, 0mA)
  |  u-boot EHCI Host Controller 
  |
  +-2  Mass Storage (480 Mb/s, 100mA)
       Generic Mass Storage 30820100
     
  3  Hub (480 Mb/s, 0mA)
  |  u-boot EHCI Host Controller 
  |
  +-4  Mass Storage (480 Mb/s, 100mA)
       Generic Mass Storage 30820100

I fixed the issues by switching all instances of CONFIG_MXC_USB_PORT with index in drivers/usb/host/ehci-mx5.c and CONFIG_MXC_USB_PORT is no longer used.  Even if index is used in place of CONFIG_MXC_USB_PORT, if you wanted to just use port 1 you would need to populate both port 0 and 1 by setting CONFIG_USB_MAX_CONTROLLER_COUNT to 2.

Here is the patch I made to drivers/usb/host/ehci-hcd.c to make USB client work on port 0 and USB host work on port 1 at the same time:

diff --git a/drivers/usb/host/ehci-mx5.c b/drivers/usb/host/ehci-mx5.c
index 7566c61..f7ecff5 100644
--- a/drivers/usb/host/ehci-mx5.c
+++ b/drivers/usb/host/ehci-mx5.c
@@ -231,10 +231,10 @@ int ehci_hcd_init(int index, enum usb_init_type init,
 	mdelay(1);
 
 	/* Do board specific initialization */
-	board_ehci_hcd_init(CONFIG_MXC_USB_PORT);
+	board_ehci_hcd_init(index);
 
 	ehci = (struct usb_ehci *)(OTG_BASE_ADDR +
-		(0x200 * CONFIG_MXC_USB_PORT));
+		(0x200 * index));
 	*hccr = (struct ehci_hccr *)((uint32_t)&ehci->caplength);
 	*hcor = (struct ehci_hcor *)((uint32_t)*hccr +
 			HC_LENGTH(ehci_readl(&(*hccr)->cr_capbase)));
@@ -243,11 +243,11 @@ int ehci_hcd_init(int index, enum usb_init_type init,
 	__raw_writel(CONFIG_MXC_USB_PORTSC, &ehci->portsc);
 	setbits_le32(&ehci->portsc, USB_EN);
 
-	mxc_set_usbcontrol(CONFIG_MXC_USB_PORT, CONFIG_MXC_USB_FLAGS);
+	mxc_set_usbcontrol(index, CONFIG_MXC_USB_FLAGS);
 	mdelay(10);
 
 	/* Do board specific post-initialization */
-	board_ehci_hcd_postinit(ehci, CONFIG_MXC_USB_PORT);
+	board_ehci_hcd_postinit(ehci, index);
 
 	return 0;
 }

Regards,

Matthew Starr



> -----Original Message-----
> From: Fabio Estevam [mailto:festevam at gmail.com]
> Sent: Tuesday, May 19, 2015 9:45 PM
> To: Matthew Starr
> Cc: U-Boot-Denx; Marek Va?ut
> Subject: Re: [U-Boot] i.MX53 USB Client not working
> 
> Hi Matthew,
> 
> On Thu, May 14, 2015 at 7:39 PM, Matthew Starr <mstarr@hedonline.com>
> wrote:
> > It appears that setting CONFIG_MXC_USB_PORT to 0 then loads the OTG
> port on the i.MX53.  The code appears to be in drivers/usb/host/ehci-mx5.c.
> The problem then is that the USB host port is then not usable since my
> i.MX53 board dedicates the OTG port to USB client functionality only.
> >
> > Now I am trying to get both USB Host port 1 and USB OTG port 0 working at
> the same time.  Does u-boot allow using multiple USB controller ports at the
> same time?
> 
> Yes, you can use both ports.
> 
> In order to do so, you need to pass #define
> CONFIG_USB_MAX_CONTROLLER_COUNT 2 in your config file.
> 
> Regards,
> 
> Fabio Estevam

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [U-Boot] i.MX53 USB Client not working
  2015-05-20 19:59   ` Matthew Starr
@ 2015-05-20 21:30     ` Fabio Estevam
  0 siblings, 0 replies; 5+ messages in thread
From: Fabio Estevam @ 2015-05-20 21:30 UTC (permalink / raw)
  To: u-boot

Hi Matthew,

On Wed, May 20, 2015 at 4:59 PM, Matthew Starr <mstarr@hedonline.com> wrote:

> I fixed the issues by switching all instances of CONFIG_MXC_USB_PORT with index in drivers/usb/host/ehci-mx5.c and CONFIG_MXC_USB_PORT is no longer used.  Even if index is used in place of CONFIG_MXC_USB_PORT, if you wanted to just use port 1 you would need to populate both port 0 and 1 by setting CONFIG_USB_MAX_CONTROLLER_COUNT to 2.
>
> Here is the patch I made to drivers/usb/host/ehci-hcd.c to make USB client work on port 0 and USB host work on port 1 at the same time:

Please send it as a formal patch to this list.

Regards,

Fabio Estevam

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [U-Boot] i.MX53 USB Client not working
@ 2015-05-14 14:37 Matthew Starr
  0 siblings, 0 replies; 5+ messages in thread
From: Matthew Starr @ 2015-05-14 14:37 UTC (permalink / raw)
  To: u-boot

I have a custom board loosely based off the i.MX53 QSB with a dedicated USB client port and separate dedicated USB host port.  I am trying to get USB client functionality working in mainline u-boot 2015.04.  I have verified that USB client/gadget functionality works when booted into Linux on the board.  In u-boot I have tried testing USB client with USB Mass Storage, DFU, and FastBoot and none of them seem to work.
 
Here is my USB client #defines from my config header file:
#define CONFIG_CI_UDC
#define CONFIG_USBD_HS
#define CONFIG_USB_GADGET_DUALSPEED
#define CONFIG_USB_GADGET
#define CONFIG_CMD_USB_MASS_STORAGE
#define CONFIG_USB_GADGET_MASS_STORAGE
#define CONFIG_USBDOWNLOAD_GADGET
#define CONFIG_USB_GADGET_VBUS_DRAW     2
#define CONFIG_USB_ETHER
#define CONFIG_USB_ETH_CDC
#define CONFIG_G_DNL_VENDOR_NUM         0x0525
#define CONFIG_G_DNL_PRODUCT_NUM        0xa4a5
#define CONFIG_G_DNL_MANUFACTURER       "FSL"
#define CONFIG_SYS_CACHELINE_SIZE       64

Additionally here are my #defines for the USB host functionality:
/* USB Host Configs */
#define CONFIG_CMD_USB
#define CONFIG_USB_EHCI
#define CONFIG_USB_EHCI_MX5
#define CONFIG_USB_STORAGE
#define CONFIG_USB_HOST_ETHER
#define CONFIG_USB_ETHER_ASIX
#define CONFIG_USB_ETHER_MCS7830
#define CONFIG_USB_ETHER_SMSC95XX
#define CONFIG_MXC_USB_PORT     1
#define CONFIG_MXC_USB_PORTSC   (PORT_PTS_UTMI | PORT_PTS_PTW)
#define CONFIG_MXC_USB_FLAGS    0

Here is my board file content related to USB:
 #ifdef CONFIG_USB_EHCI_MX5
static void setup_usb(void)
{
        imx_iomux_v3_setup_pad(MX53_PAD_GPIO_0__GPIO1_0);
}
 
 int board_ehci_hcd_init(int port)
{
        /* Enable USB_H1_VBUS power with GPIO1_0 */
        gpio_direction_output(IMX_GPIO_NR(1, 0), 1);
        return 0;
}
#endif
 
int board_usb_phy_mode(int port)
{      
        if (port == 1)
                return USB_INIT_HOST;
        else   
                return USB_INIT_DEVICE;
}
 
Then later on in board_init(), I have:
#ifdef CONFIG_USB_EHCI_MX5
        setup_usb();
#endif

When I run the 'ums 0 mmc 0' command, I get the following:
UMS: disk start sector: 0x0, count: 0xe88000
and then I get an infinite spinning progress indicator.  At this point when I connect the USB cable to a Host PC, I see nothing on the host PC side (Windows or Liunx).
 
Any ideas on what I am missing to get USB client working or any hints on how to debug this further.

Best regards,
?Matthew Starr

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-05-20 21:30 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-14 22:39 [U-Boot] i.MX53 USB Client not working Matthew Starr
2015-05-20  2:45 ` Fabio Estevam
2015-05-20 19:59   ` Matthew Starr
2015-05-20 21:30     ` Fabio Estevam
  -- strict thread matches above, loose matches on Subject: below --
2015-05-14 14:37 Matthew Starr

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.