After this has been brought up many times before, rename src/arch/i386 to
[coreboot.git] / src / arch / x86 / lib / pci_ops_mmconf.c
1 #if CONFIG_MMCONF_SUPPORT
2
3 #include <console/console.h>
4 #include <arch/io.h>
5 #include <arch/pciconf.h>
6 #include <device/pci.h>
7 #include <device/pci_ids.h>
8 #include <device/pci_ops.h>
9
10
11 /*
12  * Functions for accessing PCI configuration space with mmconf accesses
13  */
14
15 #define PCI_MMIO_ADDR(SEGBUS, DEVFN, WHERE) ( \
16         CONFIG_MMCONF_BASE_ADDRESS | \
17         (((SEGBUS) & 0xFFF) << 20) | \
18         (((DEVFN) & 0xFF) << 12) | \
19         ((WHERE) & 0xFFF))
20
21 #include <arch/mmio_conf.h>
22
23 static uint8_t pci_mmconf_read_config8(struct bus *pbus, int bus, int devfn, int where)
24 {
25                 return (read8x(PCI_MMIO_ADDR(bus, devfn, where)));
26 }
27
28 static uint16_t pci_mmconf_read_config16(struct bus *pbus, int bus, int devfn, int where)
29 {
30                 return (read16x(PCI_MMIO_ADDR(bus, devfn, where) & ~1));
31 }
32
33 static uint32_t pci_mmconf_read_config32(struct bus *pbus, int bus, int devfn, int where)
34 {
35                 return (read32x(PCI_MMIO_ADDR(bus, devfn, where) & ~3));
36 }
37
38 static void  pci_mmconf_write_config8(struct bus *pbus, int bus, int devfn, int where, uint8_t value)
39 {
40                 write8x(PCI_MMIO_ADDR(bus, devfn, where), value);
41 }
42
43 static void pci_mmconf_write_config16(struct bus *pbus, int bus, int devfn, int where, uint16_t value)
44 {
45                 write16x(PCI_MMIO_ADDR(bus, devfn, where) & ~1, value);
46 }
47
48 static void pci_mmconf_write_config32(struct bus *pbus, int bus, int devfn, int where, uint32_t value)
49 {
50                 write32x(PCI_MMIO_ADDR(bus, devfn, where) & ~3, value);
51 }
52
53
54 const struct pci_bus_operations pci_ops_mmconf =
55 {
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,
62 };
63
64 #endif