Two hda_verb.h files: Add more comments.
[coreboot.git] / src / arch / i386 / lib / pci_ops_conf1.c
1 #include <console/console.h>
2 #include <arch/io.h>
3 #include <arch/pciconf.h>
4 #include <device/pci.h>
5 #include <device/pci_ids.h>
6 #include <device/pci_ops.h>
7 /*
8  * Functions for accessing PCI configuration space with type 1 accesses
9  */
10
11 #if CONFIG_PCI_IO_CFG_EXT == 0
12 #define CONFIG_CMD(bus,devfn, where)   (0x80000000 | (bus << 16) | (devfn << 8) | (where & ~3))
13 #else
14 #define CONFIG_CMD(bus,devfn, where)   (0x80000000 | (bus << 16) | (devfn << 8) | ((where & 0xff) & ~3) | ((where & 0xf00)<<16) )
15 #endif
16
17 static uint8_t pci_conf1_read_config8(struct bus *pbus, int bus, int devfn, int where)
18 {
19                 outl(CONFIG_CMD(bus, devfn, where), 0xCF8);
20                 return inb(0xCFC + (where & 3));
21 }
22
23 static uint16_t pci_conf1_read_config16(struct bus *pbus, int bus, int devfn, int where)
24 {
25                 outl(CONFIG_CMD(bus, devfn, where), 0xCF8);
26                 return inw(0xCFC + (where & 2));
27 }
28
29 static uint32_t pci_conf1_read_config32(struct bus *pbus, int bus, int devfn, int where)
30 {
31                 outl(CONFIG_CMD(bus, devfn, where), 0xCF8);
32                 return inl(0xCFC);
33 }
34
35 static void  pci_conf1_write_config8(struct bus *pbus, int bus, int devfn, int where, uint8_t value)
36 {
37                 outl(CONFIG_CMD(bus, devfn, where), 0xCF8);
38                 outb(value, 0xCFC + (where & 3));
39 }
40
41 static void pci_conf1_write_config16(struct bus *pbus, int bus, int devfn, int where, uint16_t value)
42 {
43                 outl(CONFIG_CMD(bus, devfn, where), 0xCF8);
44                 outw(value, 0xCFC + (where & 2));
45 }
46
47 static void pci_conf1_write_config32(struct bus *pbus, int bus, int devfn, int where, uint32_t value)
48 {
49                 outl(CONFIG_CMD(bus, devfn, where), 0xCF8);
50                 outl(value, 0xCFC);
51 }
52
53 #undef CONFIG_CMD
54
55 const struct pci_bus_operations pci_cf8_conf1 =
56 {
57         .read8  = pci_conf1_read_config8,
58         .read16 = pci_conf1_read_config16,
59         .read32 = pci_conf1_read_config32,
60         .write8  = pci_conf1_write_config8,
61         .write16 = pci_conf1_write_config16,
62         .write32 = pci_conf1_write_config32,
63 };