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>
11 * Functions for accessing PCI configuration space with mmconf accesses
14 #define PCI_MMIO_ADDR(SEGBUS, DEVFN, WHERE) \
15 (CONFIG_MMCONF_BASE_ADDRESS |\
16 (((SEGBUS) & 0xFFF) << 20) |\
17 (((DEVFN) & 0xFF) << 12) |\
20 #include <arch/mmio_conf.h>
22 static uint8_t pci_mmconf_read_config8(struct bus *pbus, int bus, int devfn,
25 return (read8x(PCI_MMIO_ADDR(bus, devfn, where)));
28 static uint16_t pci_mmconf_read_config16(struct bus *pbus, int bus, int devfn,
31 return (read16x(PCI_MMIO_ADDR(bus, devfn, where) & ~1));
34 static uint32_t pci_mmconf_read_config32(struct bus *pbus, int bus, int devfn,
37 return (read32x(PCI_MMIO_ADDR(bus, devfn, where) & ~3));
40 static void pci_mmconf_write_config8(struct bus *pbus, int bus, int devfn,
41 int where, uint8_t value)
43 write8x(PCI_MMIO_ADDR(bus, devfn, where), value);
46 static void pci_mmconf_write_config16(struct bus *pbus, int bus, int devfn,
47 int where, uint16_t value)
49 write16x(PCI_MMIO_ADDR(bus, devfn, where) & ~1, value);
52 static void pci_mmconf_write_config32(struct bus *pbus, int bus, int devfn,
53 int where, uint32_t value)
55 write32x(PCI_MMIO_ADDR(bus, devfn, where) & ~3, value);
58 const struct pci_bus_operations pci_ops_mmconf = {
59 .read8 = pci_mmconf_read_config8,
60 .read16 = pci_mmconf_read_config16,
61 .read32 = pci_mmconf_read_config32,
62 .write8 = pci_mmconf_write_config8,
63 .write16 = pci_mmconf_write_config16,
64 .write32 = pci_mmconf_write_config32,