dm: pci: Add APIs to find next capability and extended capability
[platform/kernel/u-boot.git] / include / pci.h
index 938a839..785d7d2 100644 (file)
@@ -1313,6 +1313,29 @@ 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_next_capability() - find a capability starting from an offset
+ *
+ * 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
+ * @start:     offset to start from
+ * @cap:       capability code
+ * @return:    capability address or 0 if not supported
+ */
+int dm_pci_find_next_capability(struct udevice *dev, u8 start, int cap);
+
+/**
  * dm_pci_find_capability() - find a capability
  *
  * Tell if a device supports a given PCI capability. Returns the
@@ -1335,6 +1358,31 @@ void *dm_pci_map_bar(struct udevice *dev, int bar, int flags);
 int dm_pci_find_capability(struct udevice *dev, int cap);
 
 /**
+ * dm_pci_find_next_ext_capability() - find an extended capability
+ *                                    starting from an offset
+ *
+ * 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
+ * @start:     offset to start from
+ * @cap:       extended capability code
+ * @return:    extended capability address or 0 if not supported
+ */
+int dm_pci_find_next_ext_capability(struct udevice *dev, int start, int cap);
+
+/**
  * dm_pci_find_ext_capability() - find an extended capability
  *
  * Tell if a device supports a given PCI express extended capability.