blob: 267f950864214ac987cc1751991f077ff970f662 [file] [log] [blame]
Angel Pons32859fc2020-04-02 23:48:27 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Elyes HAOUASe3682b62018-12-03 09:32:31 +01002
3#ifndef DEVICE_PCI_TYPE_H
4#define DEVICE_PCI_TYPE_H
5
6#include <stdint.h>
7
8typedef u32 pci_devfn_t;
Elyes HAOUASe3682b62018-12-03 09:32:31 +01009
Kyösti Mälkkid2cdfff2019-03-05 07:56:38 +020010/* 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älkki371f0482019-01-23 16:02:28 +020014#define PCI_DEV(SEGBUS, DEV, FN) ( \
15 (((SEGBUS) & 0xFFF) << 20) | \
16 (((DEV) & 0x1F) << 15) | \
17 (((FN) & 0x07) << 12))
18
Michael Niewöhner405f2292020-12-21 03:46:58 +010019#define PCI_DEV_INVALID (0xffffffffU)
20#define PCI_DEVFN_INVALID (0xffffffffU)
Kyösti Mälkki371f0482019-01-23 16:02:28 +020021
Kyösti Mälkki34cf5612019-03-11 20:34:26 +020022#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 HAOUASe3682b62018-12-03 09:32:31 +010033#endif /* DEVICE_PCI_TYPE_H */