1
0
mirror of https://xff.cz/git/u-boot/ synced 2025-09-01 08:42:12 +02:00

dm: pci: Add APIs to find next capability and extended capability

This introduces two new APIs dm_pci_find_next_capability() and
dm_pci_find_next_ext_capability() to get PCI capability address
and PCI express extended capability address for a given PCI device
starting from a given offset.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Bin Meng
2018-10-15 02:21:21 -07:00
committed by Simon Glass
parent c80c7798cf
commit a8c5f8d3d0
2 changed files with 84 additions and 15 deletions

View File

@@ -1312,6 +1312,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
*
@@ -1334,6 +1357,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
*