1 #if CONFIG_MMCONF_SUPPORT
3 #include <console/console.h>
5 #include <arch/pciconf.h>
6 #include <device/pci.h>
7 #include <device/pci_ids.h>
8 #include <device/pci_ops.h>
12 * Functions for accessing PCI configuration space with mmconf accesses
15 #define PCI_MMIO_ADDR(SEGBUS, DEVFN, WHERE) ( \
16 CONFIG_MMCONF_BASE_ADDRESS | \
17 (((SEGBUS) & 0xFFF) << 20) | \
18 (((DEVFN) & 0xFF) << 12) | \
21 #include <arch/mmio_conf.h>
23 static uint8_t pci_mmconf_read_config8(struct bus *pbus, int bus, int devfn, int where)
25 return (read8x(PCI_MMIO_ADDR(bus, devfn, where)));
28 static uint16_t pci_mmconf_read_config16(struct bus *pbus, int bus, int devfn, int where)
30 return (read16x(PCI_MMIO_ADDR(bus, devfn, where) & ~1));
33 static uint32_t pci_mmconf_read_config32(struct bus *pbus, int bus, int devfn, int where)
35 return (read32x(PCI_MMIO_ADDR(bus, devfn, where) & ~3));
38 static void pci_mmconf_write_config8(struct bus *pbus, int bus, int devfn, int where, uint8_t value)
40 write8x(PCI_MMIO_ADDR(bus, devfn, where), value);
43 static void pci_mmconf_write_config16(struct bus *pbus, int bus, int devfn, int where, uint16_t value)
45 write16x(PCI_MMIO_ADDR(bus, devfn, where) & ~1, value);
48 static void pci_mmconf_write_config32(struct bus *pbus, int bus, int devfn, int where, uint32_t value)
50 write32x(PCI_MMIO_ADDR(bus, devfn, where) & ~3, value);
54 const struct pci_bus_operations pci_ops_mmconf =
56 .read8 = pci_mmconf_read_config8,
57 .read16 = pci_mmconf_read_config16,
58 .read32 = pci_mmconf_read_config32,
59 .write8 = pci_mmconf_write_config8,
60 .write16 = pci_mmconf_write_config16,
61 .write32 = pci_mmconf_write_config32,