summaryrefslogtreecommitdiff
path: root/include/pci.h
diff options
context:
space:
mode:
authorBin Meng <bmeng.cn@gmail.com>2018-08-03 01:14:52 -0700
committerSimon Glass <sjg@chromium.org>2018-08-08 12:49:31 +0100
commitdac01fd89d41d98cd4ce040a0d10eb67c523f63a (patch)
treef230ada01af1198cdfcfadfafa03fe6107235eba /include/pci.h
parent5d544f962f7b970c118eaa13f1b874572ab5c28f (diff)
downloadu-boot-dac01fd89d41d98cd4ce040a0d10eb67c523f63a.tar.gz
u-boot-dac01fd89d41d98cd4ce040a0d10eb67c523f63a.tar.bz2
u-boot-dac01fd89d41d98cd4ce040a0d10eb67c523f63a.zip
dm: pci: Add APIs to find capability and extended capability
This introduces two new APIs dm_pci_find_capability() and dm_pci_find_ext_capability() to get PCI capability address and PCI express extended capability address for a given PCI device. Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'include/pci.h')
-rw-r--r--include/pci.h46
1 files changed, 46 insertions, 0 deletions
diff --git a/include/pci.h b/include/pci.h
index 83a40a5adf..938a8390cb 100644
--- a/include/pci.h
+++ b/include/pci.h
@@ -17,6 +17,7 @@
* Under PCI, each device has 256 bytes of configuration address space,
* of which the first 64 bytes are standardized as follows:
*/
+#define PCI_STD_HEADER_SIZEOF 64
#define PCI_VENDOR_ID 0x00 /* 16 bits */
#define PCI_DEVICE_ID 0x02 /* 16 bits */
#define PCI_COMMAND 0x04 /* 16 bits */
@@ -1311,6 +1312,51 @@ pci_addr_t dm_pci_phys_to_bus(struct udevice *dev, phys_addr_t addr,
*/
void *dm_pci_map_bar(struct udevice *dev, int bar, int flags);
+/**
+ * dm_pci_find_capability() - find a capability
+ *
+ * Tell if a device supports a given PCI capability. Returns the
+ * address of the requested capability structure within the device's
+ * PCI configuration space or 0 in case the device does not support it.
+ *
+ * Possible values for @cap:
+ *
+ * %PCI_CAP_ID_MSI Message Signalled Interrupts
+ * %PCI_CAP_ID_PCIX PCI-X
+ * %PCI_CAP_ID_EXP PCI Express
+ * %PCI_CAP_ID_MSIX MSI-X
+ *
+ * See PCI_CAP_ID_xxx for the complete capability ID codes.
+ *
+ * @dev: PCI device to query
+ * @cap: capability code
+ * @return: capability address or 0 if not supported
+ */
+int dm_pci_find_capability(struct udevice *dev, int cap);
+
+/**
+ * dm_pci_find_ext_capability() - find an extended capability
+ *
+ * Tell if a device supports a given PCI express extended capability.
+ * Returns the address of the requested extended capability structure
+ * within the device's PCI configuration space or 0 in case the device
+ * does not support it.
+ *
+ * Possible values for @cap:
+ *
+ * %PCI_EXT_CAP_ID_ERR Advanced Error Reporting
+ * %PCI_EXT_CAP_ID_VC Virtual Channel
+ * %PCI_EXT_CAP_ID_DSN Device Serial Number
+ * %PCI_EXT_CAP_ID_PWR Power Budgeting
+ *
+ * See PCI_EXT_CAP_ID_xxx for the complete extended capability ID codes.
+ *
+ * @dev: PCI device to query
+ * @cap: extended capability code
+ * @return: extended capability address or 0 if not supported
+ */
+int dm_pci_find_ext_capability(struct udevice *dev, int cap);
+
#define dm_pci_virt_to_bus(dev, addr, flags) \
dm_pci_phys_to_bus(dev, (virt_to_phys(addr)), (flags))
#define dm_pci_bus_to_virt(dev, addr, flags, len, map_flags) \