Angel Pons | 32859fc | 2020-04-02 23:48:27 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Elyes HAOUAS | e3682b6 | 2018-12-03 09:32:31 +0100 | [diff] [blame] | 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; |
Elyes HAOUAS | e3682b6 | 2018-12-03 09:32:31 +0100 | [diff] [blame] | 9 | |
Kyösti Mälkki | d2cdfff | 2019-03-05 07:56:38 +0200 | [diff] [blame] | 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 | |
Kyösti Mälkki | 371f048 | 2019-01-23 16:02:28 +0200 | [diff] [blame] | 14 | #define PCI_DEV(SEGBUS, DEV, FN) ( \ |
| 15 | (((SEGBUS) & 0xFFF) << 20) | \ |
| 16 | (((DEV) & 0x1F) << 15) | \ |
| 17 | (((FN) & 0x07) << 12)) |
| 18 | |
Michael Niewöhner | 405f229 | 2020-12-21 03:46:58 +0100 | [diff] [blame] | 19 | #define PCI_DEV_INVALID (0xffffffffU) |
| 20 | #define PCI_DEVFN_INVALID (0xffffffffU) |
Kyösti Mälkki | 371f048 | 2019-01-23 16:02:28 +0200 | [diff] [blame] | 21 | |
Kyösti Mälkki | 34cf561 | 2019-03-11 20:34:26 +0200 | [diff] [blame] | 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 | |
Elyes HAOUAS | e3682b6 | 2018-12-03 09:32:31 +0100 | [diff] [blame] | 33 | #endif /* DEVICE_PCI_TYPE_H */ |