diff mbox series

[v5,5/6] pci: Add a macro to convert BDF from linux to U-Boot

Message ID 20200408083251.v5.5.Ifb213e62095edbb017224d889263bb63c982c112@changeid
State Accepted
Commit f05970380e4c72a198cce29affc622a8e543b4de
Headers show
Series A few little patches | expand

Commit Message

Simon Glass April 8, 2020, 2:32 p.m. UTC
U-Boot's BDF format has its bits in the same position as the device tree
PCI definition.

Some x86 devices use linux format in their register format and it is
useful to be able to convert to U-Boot format. Add a macro for this.

Signed-off-by: Simon Glass <sjg at chromium.org>
---

Changes in v5: None
Changes in v4: None

 include/pci.h | 3 +++
 1 file changed, 3 insertions(+)

Comments

Tom Rini April 26, 2020, 11:26 a.m. UTC | #1
On Wed, Apr 08, 2020 at 08:32:59AM -0600, Simon Glass wrote:

> U-Boot's BDF format has its bits in the same position as the device tree
> PCI definition.
> 
> Some x86 devices use linux format in their register format and it is
> useful to be able to convert to U-Boot format. Add a macro for this.
> 
> Signed-off-by: Simon Glass <sjg at chromium.org>

Applied to u-boot/master, thanks!
diff mbox series

Patch

diff --git a/include/pci.h b/include/pci.h
index 174ddd4460d..aff56b24f92 100644
--- a/include/pci.h
+++ b/include/pci.h
@@ -543,6 +543,9 @@  typedef int pci_dev_t;
 #define PCI_VENDEV(v, d)	(((v) << 16) | (d))
 #define PCI_ANY_ID		(~0)
 
+/* Convert from Linux format to U-Boot format */
+#define PCI_TO_BDF(val)		((val) << 8)
+
 struct pci_device_id {
 	unsigned int vendor, device;	/* Vendor and device ID or PCI_ANY_ID */
 	unsigned int subvendor, subdevice; /* Subsystem ID's or PCI_ANY_ID */