From patchwork Tue Mar 12 13:45:31 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 227027 X-Patchwork-Delegate: marek.vasut@gmail.com 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 373B82C029F for ; Wed, 13 Mar 2013 00:45:50 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 68BB64A233; Tue, 12 Mar 2013 14:45:43 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de 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 lV9L79qc69tz; Tue, 12 Mar 2013 14:45:43 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 48C8B4A22A; Tue, 12 Mar 2013 14:45:42 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 9A6364A22A for ; Tue, 12 Mar 2013 14:45:40 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de 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 Ev-ntqbCjp00 for ; Tue, 12 Mar 2013 14:45:39 +0100 (CET) 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-qc0-f201.google.com (mail-qc0-f201.google.com [209.85.216.201]) by theia.denx.de (Postfix) with ESMTPS id 0F7FB4A228 for ; Tue, 12 Mar 2013 14:45:37 +0100 (CET) Received: by mail-qc0-f201.google.com with SMTP id o22so424334qcr.2 for ; Tue, 12 Mar 2013 06:45:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer :x-gm-message-state; bh=u4/ef6rHacrnC5tgaF3xwN/6BdoA6P0fPofOjDSJjs0=; b=QJxX7kSYJzUwsYqzWCMII3xco3cz7kQqoLa5ps5bHaSi8INtm7IwpTInXj+OGxH6di c5bwdeahHGmv6oRVU2BqTFp2rHefiWB7iPeLHStwgx1anKevTjpH1gRfAgtmR7uqO9Qo zpTD0eYQC3KrJW8LEQAzTwr55yzWJj3FTtw0FV3jVujb9eOG9ZVDSm0iLbGYdJ15bCkR DVpZY0AYBoez6ma5fm4TAcJ5N2B5pPgyxv9r8lUYqGSBgkvj4FAZyVaR5gF72xtGlRfz d3PwELTb4fR/OvcChdHVJIvfb/UWWghOhtiSEZYHJmGkCid0izi1Ubq/WzR6D0Li8vV6 Gg2w== X-Received: by 10.236.171.103 with SMTP id q67mr10441519yhl.35.1363095934762; Tue, 12 Mar 2013 06:45:34 -0700 (PDT) Received: from corp2gmr1-2.hot.corp.google.com (corp2gmr1-2.hot.corp.google.com [172.24.189.93]) by gmr-mx.google.com with ESMTPS id u21si1341575yhj.0.2013.03.12.06.45.34 (version=TLSv1.1 cipher=AES128-SHA bits=128/128); Tue, 12 Mar 2013 06:45:34 -0700 (PDT) Received: from kaka.mtv.corp.google.com (kaka.mtv.corp.google.com [172.22.73.79]) by corp2gmr1-2.hot.corp.google.com (Postfix) with ESMTP id 98E0E5A4174; Tue, 12 Mar 2013 06:45:34 -0700 (PDT) Received: by kaka.mtv.corp.google.com (Postfix, from userid 121222) id 3A8651606D8; Tue, 12 Mar 2013 06:45:34 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Date: Tue, 12 Mar 2013 06:45:31 -0700 Message-Id: <1363095931-10943-1-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 1.8.1.3 X-Gm-Message-State: ALoCoQk5Vrurg9KDV4F1/KwH3qRIDUm5A8UHKgEyMeZ8ibs2U8DMv/JkjRr8iQIC/pPMEaq87qnZSQO+sUewMwaC5pyTMI2r2FuG9wDYdfpXF4ml2E/Pals8OOKj1O04/jBKbVPU7MfPW3SosVzM4o4FHOCKz19TPFkC13UT4XD8BJBoh7EpKYqD/P1xX/NxvlaIOFFmdR6h Cc: Vincent Palatin Subject: [U-Boot] [PATCH v5] usb: Add multiple controllers support for EHCI PCI X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de From: Vincent Palatin Use the ability to have several active EHCI controller on a system in the PCI EHCI controller implementation. Signed-off-by: Simon Glass --- Changes in v5: - Rebase to usb/master Changes in v4: - Add errno.h header file to ehci-pci Changes in v2: - Add blank line before function return drivers/usb/host/ehci-pci.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c index 001d141..90d7a6f 100644 --- a/drivers/usb/host/ehci-pci.c +++ b/drivers/usb/host/ehci-pci.c @@ -34,7 +34,7 @@ static struct pci_device_id ehci_pci_ids[] = { {0, 0} }; #else -static pci_dev_t ehci_find_class(void) +static pci_dev_t ehci_find_class(int index) { int bus; int devnum; @@ -54,7 +54,8 @@ static pci_dev_t ehci_find_class(void) bdf += PCI_BDF(0, 0, 1)) { pci_read_config_dword(bdf, PCI_CLASS_REVISION, &class); - if (class >> 8 == PCI_CLASS_SERIAL_USB_EHCI) + if ((class >> 8 == PCI_CLASS_SERIAL_USB_EHCI) + && !index--) return bdf; } } @@ -68,29 +69,35 @@ static pci_dev_t ehci_find_class(void) * Create the appropriate control structures to manage * a new EHCI host controller. */ -int ehci_hcd_init(int index, struct ehci_hccr **hccr, struct ehci_hcor **hcor) +int ehci_hcd_init(int index, struct ehci_hccr **ret_hccr, + struct ehci_hcor **ret_hcor) { pci_dev_t pdev; uint32_t cmd; + struct ehci_hccr *hccr; + struct ehci_hcor *hcor; #ifdef CONFIG_PCI_EHCI_DEVICE pdev = pci_find_devices(ehci_pci_ids, CONFIG_PCI_EHCI_DEVICE); #else - pdev = ehci_find_class(); + pdev = ehci_find_class(index); #endif if (pdev < 0) { printf("EHCI host controller not found\n"); return -1; } - *hccr = (struct ehci_hccr *)pci_map_bar(pdev, + hccr = (struct ehci_hccr *)pci_map_bar(pdev, PCI_BASE_ADDRESS_0, PCI_REGION_MEM); - *hcor = (struct ehci_hcor *)((uint32_t) *hccr + - HC_LENGTH(ehci_readl(&(*hccr)->cr_capbase))); + hcor = (struct ehci_hcor *)((uint32_t) hccr + + HC_LENGTH(ehci_readl(&hccr->cr_capbase))); debug("EHCI-PCI init hccr 0x%x and hcor 0x%x hc_length %d\n", - (uint32_t)*hccr, (uint32_t)*hcor, - (uint32_t)HC_LENGTH(ehci_readl(&(*hccr)->cr_capbase))); + (uint32_t)hccr, (uint32_t)hcor, + (uint32_t)HC_LENGTH(ehci_readl(&hccr->cr_capbase))); + + *ret_hccr = hccr; + *ret_hcor = hcor; /* enable busmaster */ pci_read_config_dword(pdev, PCI_COMMAND, &cmd);