From patchwork Wed May 20 19:59:00 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Matthew Starr X-Patchwork-Id: 474641 X-Patchwork-Delegate: sbabic@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id B923A14029E for ; Thu, 21 May 2015 06:43:13 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id A02474A033; Wed, 20 May 2015 22:43:10 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id OJpnJ0Z5oKiT; Wed, 20 May 2015 22:43:10 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id C9FAE4A03A; Wed, 20 May 2015 22:42:09 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id A5D774B681 for ; Wed, 20 May 2015 22:24:46 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id WW0bitkbzjZ5 for ; Wed, 20 May 2015 22:24:46 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail.hedonline.com (mail.hedonline.com [12.133.124.242]) by theia.denx.de (Postfix) with ESMTP id 30E594B700 for ; Wed, 20 May 2015 22:01:17 +0200 (CEST) X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Date: Wed, 20 May 2015 14:59:00 -0500 Message-ID: <64CA5C49A43E314D9F7DAE05370E2F7B06771049@hed-dc01.hed.local> In-Reply-To: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [U-Boot] i.MX53 USB Client not working Thread-Index: AdCSprkwohT96EMwQ9Kxfj1srs4VAAAh+e9A References: <64CA5C49A43E314D9F7DAE05370E2F7B0677103D@hed-dc01.hed.local> From: "Matthew Starr" To: "Fabio Estevam" Cc: =?utf-8?B?TWFyZWsgVmHFoXV0?= , U-Boot-Denx Subject: Re: [U-Boot] i.MX53 USB Client not working X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "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: Regards, Matthew Starr > -----Original Message----- > From: Fabio Estevam [mailto:festevam@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 > 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 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; }