1 /* SPDX-License-Identifier: GPL-2.0-only */ 2 3 #ifndef DEVICE_PCI_TYPE_H 4 #define DEVICE_PCI_TYPE_H 5 6 #include <stdint.h> 7 8 typedef u32 pci_devfn_t; 9 10 /* Convert pci_devfn_t to offset in MMCONF space. 11 * As it is one-to-one, nothing needs to be done. */ 12 #define PCI_DEVFN_OFFSET(x) ((x)) 13 14 #define PCI_DEV(SEGBUS, DEV, FN) ( \ 15 (((SEGBUS) & 0xFFF) << 20) | \ 16 (((DEV) & 0x1F) << 15) | \ 17 (((FN) & 0x07) << 12)) 18 19 #define PCI_DEV_INVALID (0xffffffffU) 20 #define PCI_DEVFN_INVALID (0xffffffffU) 21 22 #if 1 23 /* FIXME: For most of the time in ramstage, we get valid device pointer 24 * from calling the driver entry points. The assert should only be used 25 * with searches like pcidev_behind(), and only if caller does not make 26 * the check themselves. 27 */ 28 #define PCI_BDF(dev) pcidev_assert((dev)) 29 #else 30 #define PCI_BDF(dev) pcidev_bdf((dev)) 31 #endif 32 33 #endif /* DEVICE_PCI_TYPE_H */ 34