From patchwork Thu Dec 13 01:55:23 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 205703 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 93FB22C0093 for ; Thu, 13 Dec 2012 12:57:55 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 937954A1D9; Thu, 13 Dec 2012 02:57:53 +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 7vOpSBYAU24d; Thu, 13 Dec 2012 02:57:52 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id D617F4A1CE; Thu, 13 Dec 2012 02:57:47 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 114D94A1B9 for ; Thu, 13 Dec 2012 02:57:46 +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 X0uEU4fcECsE for ; Thu, 13 Dec 2012 02:57:45 +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-wg0-f74.google.com (mail-wg0-f74.google.com [74.125.82.74]) by theia.denx.de (Postfix) with ESMTPS id 5423A4A1A8 for ; Thu, 13 Dec 2012 02:57:43 +0100 (CET) Received: by mail-wg0-f74.google.com with SMTP id dt14so74715wgb.3 for ; Wed, 12 Dec 2012 17:57:43 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=2Zos5AowIfx2HzPPnrleeN2E1gcvBEbVCz8zGBPSWVs=; b=XdeduFOlPimq0aJ2Z8cGhdiAi0A0gQVYJ4Hwikn9LfdutXkDYvFIJXLHHIw6Ra3fjQ mwCjhPV0MveHF06oMgWDJhVPVf2JZpwDAMPBJMLNGaphwhxvDUYoZ4coyQ1qlA5Y/4pF s7rBMOV2GCix7OBFDIVbD7OMHXeE1bvUhQU4SzlwFMKCJ2dfzr5CdC1+DSVe5CZ5vkH7 1Iga7dC5AfxnzD2LDLyu0cKeHthLMQtlHQMsR49nzmvnxFEWk0uNIvd7WWiLBlnNRXWV wfStmbA6DxBByx+pZbqDv0h0Lmi9j+N6mbq7ZeS1LXDPeLIENKsvd2fOVXJxQadvjIB6 b+Jw== Received: by 10.14.208.198 with SMTP id q46mr289232eeo.0.1355363863370; Wed, 12 Dec 2012 17:57:43 -0800 (PST) Received: from hpza10.eem.corp.google.com ([74.125.121.33]) by gmr-mx.google.com with ESMTPS id g9si29047eeo.1.2012.12.12.17.57.43 (version=TLSv1/SSLv3 cipher=AES128-SHA); Wed, 12 Dec 2012 17:57:43 -0800 (PST) Received: from kaka.mtv.corp.google.com (kaka.mtv.corp.google.com [172.22.73.79]) by hpza10.eem.corp.google.com (Postfix) with ESMTP id 06BEE200059; Wed, 12 Dec 2012 17:57:43 -0800 (PST) Received: by kaka.mtv.corp.google.com (Postfix, from userid 121222) id 5BF641608F3; Wed, 12 Dec 2012 17:57:42 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Date: Wed, 12 Dec 2012 17:55:23 -0800 Message-Id: <1355363731-10103-4-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 1.7.7.3 In-Reply-To: <1355363731-10103-1-git-send-email-sjg@chromium.org> References: <1355363731-10103-1-git-send-email-sjg@chromium.org> X-Gm-Message-State: ALoCoQmYvC5ZP5M3wRJdEkNzYHNNzG00CdpXh0CcQp92Hb34X9HDY9rTz3+DtmFGUU6A11ezJqGT6B76Dzke/YrBQdvCWSdW6JAEsD/D23S/F1T0JFTytlGGCHMtW7f5nqx3LUgzEG9lJ6/furQwcK7yQOKYLDbVachf0a+hLNfljNQl/pBGXv2UYriw0OrNxVAfbfudtLYN Cc: Vincent Palatin Subject: [U-Boot] [PATCH 03/11] usb: ehci: generic PCI support 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 Instead of hardcoding the PCI IDs on the USB controller, use the PCI class to detect them. Ensure the busmaster bit is properly set in the PCI configuration. Signed-off-by: Simon Glass --- drivers/usb/host/ehci-pci.c | 37 +++++++++++++++++++++++++++++++++++++ 1 files changed, 37 insertions(+), 0 deletions(-) diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c index 29af02d..0dc0e6e 100644 --- a/drivers/usb/host/ehci-pci.c +++ b/drivers/usb/host/ehci-pci.c @@ -32,6 +32,34 @@ static struct pci_device_id ehci_pci_ids[] = { {0x12D8, 0x400F}, /* Pericom */ {0, 0} }; +#else +static pci_dev_t ehci_find_class(void) +{ + int bus; + int devnum; + pci_dev_t bdf; + uint32_t class; + + for (bus = 0; bus < pci_last_busno(); bus++) { + for (devnum = 0; devnum < PCI_MAX_PCI_DEVICES-1; devnum++) { + pci_read_config_dword(PCI_BDF(bus, devnum, 0), + PCI_CLASS_REVISION, &class); + if (class >> 16 == 0xffff) + continue; + + for (bdf = PCI_BDF(bus, devnum, 0); + bdf <= PCI_BDF(bus, devnum, + PCI_MAX_PCI_FUNCTIONS - 1); + bdf += PCI_BDF(0, 0, 1)) { + pci_read_config_dword(bdf, PCI_CLASS_REVISION, + &class); + if (class >> 8 == 0x0c0320) + return bdf; + } + } + } + return -1; +} #endif /* @@ -41,8 +69,13 @@ static struct pci_device_id ehci_pci_ids[] = { int ehci_hcd_init(int index, struct ehci_hccr **hccr, struct ehci_hcor **hcor) { pci_dev_t pdev; + uint32_t cmd; +#ifdef CONFIG_PCI_EHCI_DEVICE pdev = pci_find_devices(ehci_pci_ids, CONFIG_PCI_EHCI_DEVICE); +#else + pdev = ehci_find_class(); +#endif if (pdev == -1) { printf("EHCI host controller not found\n"); return -1; @@ -57,6 +90,10 @@ int ehci_hcd_init(int index, struct ehci_hccr **hccr, struct ehci_hcor **hcor) (uint32_t)*hccr, (uint32_t)*hcor, (uint32_t)HC_LENGTH(ehci_readl(&(*hccr)->cr_capbase))); + /* enable busmaster */ + pci_read_config_dword(pdev, PCI_COMMAND, &cmd); + cmd |= PCI_COMMAND_MASTER; + pci_write_config_dword(pdev, PCI_COMMAND, cmd); return 0; }