From patchwork Mon Jul 6 22:47:46 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 491855 X-Patchwork-Delegate: sjg@chromium.org 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 571CC1402C4 for ; Tue, 7 Jul 2015 08:49:57 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b=I+fU30bV; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id A850B4B876; Tue, 7 Jul 2015 00:49:29 +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 nFkq7MdtSEKB; Tue, 7 Jul 2015 00:49:29 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 43A534B879; Tue, 7 Jul 2015 00:49:05 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 96CFC4B818 for ; Tue, 7 Jul 2015 00:48:42 +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 5428F2Zhz1DS for ; Tue, 7 Jul 2015 00:48:42 +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-ig0-f182.google.com (mail-ig0-f182.google.com [209.85.213.182]) by theia.denx.de (Postfix) with ESMTPS id 28E814B7F9 for ; Tue, 7 Jul 2015 00:48:36 +0200 (CEST) Received: by igcsj18 with SMTP id sj18so247029350igc.1 for ; Mon, 06 Jul 2015 15:48:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=B8GpztTJxuo/KqdLSw2m0CewFD5djsCNkUroRvOdz5A=; b=I+fU30bV/yZUDt+Pwuf+EMPzgyLz5o5Y8M465uQQkjK5fgk5OBUQXjI/gNGHpyJMkv yE2r40ojA7sfqOq4wj8BWlWZhFahFfE0u0GPHyEAzNGuuKUrlFmFflMVCKHop/YziWaf aRM+Lf5C18lnIs0fvPFBtcgSiC9TuwULDt+QrH813nuVCUVRGRycY/OC+U/f4xE70MEI 06wwqc5EW44lZ4AyorGgJpCqUcoPkxtSrXcw3CyhIHkFIvZPOZ364XJ7pOdVr8Cdqzr1 6RJJFvS4rz6ZfyQNQX1i74RHQmHioCyZQxM6tBZhzHiLiDI/fQl2Bjt426EXLHSvH7lz JOeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=B8GpztTJxuo/KqdLSw2m0CewFD5djsCNkUroRvOdz5A=; b=GpU6ZgYZSQdYkpZge3DlTFJJ/rvRJgmOfrS0LDoc7/ag+rH1s96OdxC1H1NsPgrnv9 4d8VFokaHgaAPw5rMPMvA2v118+JzW+KSC3/DtiHE/sopgB8pbOCMP9UANd0lIsXLTdK E2SW1szJoddKPpWRI/ZjU8UpKV7dKfKv6demJSc6mMoQhd44uVqMdjQdboDCAtC1x2Df h7gltk/9wM3mE4xDyOnUkqvzj6O6/SS863rXX09T71hmRf1WWfrwfJfBMfoLaWTXEMnY FIKYk4z1Qva5jRfBVv4FuipzqUkfRS74V6ODoINfaNl3rvdkwLzJAmviapLTnU3SuMti ijGQ== X-Gm-Message-State: ALoCoQnyJf5vJiO3GTIReUuYxJqvTBydXUyDoc+T3YPm+GPDmofdUB7hzyR0tC+TuGRL0sRHmaBj X-Received: by 10.42.167.129 with SMTP id s1mr40109541icy.54.1436222914862; Mon, 06 Jul 2015 15:48:34 -0700 (PDT) Received: from kaki.bld.corp.google.com ([172.29.216.32]) by mx.google.com with ESMTPSA id j20sm10602629igt.16.2015.07.06.15.48.31 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Jul 2015 15:48:33 -0700 (PDT) Received: by kaki.bld.corp.google.com (Postfix, from userid 121222) id F3F72220F0C; Mon, 6 Jul 2015 16:48:28 -0600 (MDT) From: Simon Glass To: U-Boot Mailing List Date: Mon, 6 Jul 2015 16:47:46 -0600 Message-Id: <1436222877-17548-8-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 2.4.3.573.g4eafbef In-Reply-To: <1436222877-17548-1-git-send-email-sjg@chromium.org> References: <1436222877-17548-1-git-send-email-sjg@chromium.org> Cc: Tom Rini , Masahiro Yamada , Joe Hershberger , Thierry Reding Subject: [U-Boot] [PATCH 07/18] dm: pci: Add a function to get the BDF for a device 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: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" It is useful to be able to find the full PCI address (bus, device and function) for a PCI device. Add a function to provide this. Adjust the existing code to use this. Signed-off-by: Simon Glass --- drivers/pci/pci-uclass.c | 15 +++++++++------ drivers/pci/pci_compat.c | 8 ++------ include/pci.h | 8 ++++++++ 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/drivers/pci/pci-uclass.c b/drivers/pci/pci-uclass.c index 41daa0d..3be76c9 100644 --- a/drivers/pci/pci-uclass.c +++ b/drivers/pci/pci-uclass.c @@ -30,6 +30,14 @@ struct pci_controller *pci_bus_to_hose(int busnum) return dev_get_uclass_priv(bus); } +pci_dev_t pci_get_bdf(struct udevice *dev) +{ + struct pci_child_platdata *pplat = dev_get_parent_platdata(dev); + struct udevice *bus = dev->parent; + + return PCI_ADD_BUS(bus->seq, pplat->devfn); +} + /** * pci_get_bus_max() - returns the bus number of the last active bus * @@ -295,19 +303,14 @@ int pci_auto_config_devices(struct udevice *bus) for (ret = device_find_first_child(bus, &dev); !ret && dev; ret = device_find_next_child(&dev)) { - struct pci_child_platdata *pplat; struct pci_controller *ctlr_hose; - - pplat = dev_get_parent_platdata(dev); unsigned int max_bus; - pci_dev_t bdf; - bdf = PCI_ADD_BUS(bus->seq, pplat->devfn); debug("%s: device %s\n", __func__, dev->name); /* The root controller has the region information */ ctlr_hose = hose->ctlr->uclass_priv; - max_bus = pciauto_config_device(ctlr_hose, bdf); + max_bus = pciauto_config_device(ctlr_hose, pci_get_bdf(dev)); sub_bus = max(sub_bus, max_bus); } debug("%s: done\n", __func__); diff --git a/drivers/pci/pci_compat.c b/drivers/pci/pci_compat.c index d6938c1..05c3510 100644 --- a/drivers/pci/pci_compat.c +++ b/drivers/pci/pci_compat.c @@ -31,13 +31,9 @@ PCI_HOSE_OP(write, dword, 32, u32) pci_dev_t pci_find_devices(struct pci_device_id *ids, int index) { - struct pci_child_platdata *pplat; - struct udevice *bus, *dev; + struct udevice *dev; if (pci_find_device_id(ids, index, &dev)) return -1; - bus = dev->parent; - pplat = dev_get_parent_platdata(dev); - - return PCI_ADD_BUS(bus->seq, pplat->devfn); + return pci_get_bdf(dev); } diff --git a/include/pci.h b/include/pci.h index d21fa8b..ae5c854 100644 --- a/include/pci.h +++ b/include/pci.h @@ -817,6 +817,14 @@ struct dm_pci_ops { #define pci_get_ops(dev) ((struct dm_pci_ops *)(dev)->driver->ops) /** + * pci_get_bdf() - Get the BDF value for a device + * + * @dev: Device to check + * @return bus/device/function value (see PCI_BDF()) + */ +pci_dev_t pci_get_bdf(struct udevice *dev); + +/** * pci_bind_bus_devices() - scan a PCI bus and bind devices * * Scan a PCI bus looking for devices. Bind each one that is found. If