aboutsummaryrefslogtreecommitdiff
path: root/include/pci.h
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2019-09-25 08:56:06 -0600
committerBin Meng <bmeng.cn@gmail.com>2019-10-08 13:57:40 +0800
commit37a1cf9c9c4c670e074feb8fb2fc6b4a40a80b1b (patch)
tree3424513b1fc8f6a8864b5ceaa5e075dde0222510 /include/pci.h
parentfae2c16ede7bf00c8f7873a96fc2b34d5345d751 (diff)
downloadu-boot-37a1cf9c9c4c670e074feb8fb2fc6b4a40a80b1b.zip
u-boot-37a1cf9c9c4c670e074feb8fb2fc6b4a40a80b1b.tar.gz
u-boot-37a1cf9c9c4c670e074feb8fb2fc6b4a40a80b1b.tar.bz2
sandbox: pci: Move pci_offset_to_barnum() to pci.h
This function is useful in PCI emulators. More it into the header file to avoid duplicating it in other drivers. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Diffstat (limited to 'include/pci.h')
-rw-r--r--include/pci.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/include/pci.h b/include/pci.h
index 999a594..2b82b2c 100644
--- a/include/pci.h
+++ b/include/pci.h
@@ -215,6 +215,10 @@
#define PCI_BASE_ADDRESS_IO_MASK (~0x03ULL)
/* bit 1 is reserved if address_space = 1 */
+/* Convert a regsister address (e.g. PCI_BASE_ADDRESS_1) to a bar # (e.g. 1) */
+#define pci_offset_to_barnum(offset) \
+ (((offset) - PCI_BASE_ADDRESS_0) / sizeof(u32))
+
/* Header type 0 (normal devices) */
#define PCI_CARDBUS_CIS 0x28
#define PCI_SUBSYSTEM_VENDOR_ID 0x2c