16 #define PCI_CONF1_ADDRESS(bus, devfn, reg) \
17 (0x80000000 | ((reg & 0xF00) << 16) | (bus << 16) \
18 | (devfn << 8) | (reg & 0xFC))
20 static int pci_conf1_read(
unsigned int seg,
unsigned int bus,
25 if (seg || (bus > 255) || (devfn > 255) || (reg > 4095)) {
36 *value =
inb(0xCFC + (reg & 3));
39 *value =
inw(0xCFC + (reg & 2));
51 static int pci_conf1_write(
unsigned int seg,
unsigned int bus,
56 if (seg || (bus > 255) || (devfn > 255) || (reg > 4095))
65 outb((
u8)value, 0xCFC + (reg & 3));
68 outw((
u16)value, 0xCFC + (reg & 2));
80 #undef PCI_CONF1_ADDRESS
83 .read = pci_conf1_read,
84 .write = pci_conf1_write,
92 #define PCI_CONF2_ADDRESS(dev, reg) (u16)(0xC000 | (dev << 8) | reg)
94 static int pci_conf2_read(
unsigned int seg,
unsigned int bus,
95 unsigned int devfn,
int reg,
int len,
u32 *value)
101 if ((bus > 255) || (devfn > 255) || (reg > 255)) {
114 outb((
u8)(0xF0 | (fn << 1)), 0xCF8);
136 static int pci_conf2_write(
unsigned int seg,
unsigned int bus,
137 unsigned int devfn,
int reg,
int len,
u32 value)
143 if ((bus > 255) || (devfn > 255) || (reg > 255))
154 outb((
u8)(0xF0 | (fn << 1)), 0xCF8);
176 #undef PCI_CONF2_ADDRESS
178 static const struct pci_raw_ops pci_direct_conf2 = {
179 .read = pci_conf2_read,
180 .write = pci_conf2_write,
207 for (devfn = 0; devfn < 0x100; devfn++) {
223 static int __init pci_check_type1(
void)
233 outl(0x80000000, 0xCF8);
234 if (
inl(0xCF8) == 0x80000000 && pci_sanity_check(&pci_direct_conf1)) {
243 static int __init pci_check_type2(
void)
253 if (
inb(0xCF8) == 0x00 &&
inb(0xCFA) == 0x00 &&
254 pci_sanity_check(&pci_direct_conf2)) {
276 "for extended access\n");
290 if (pci_check_type1()) {
305 if (pci_check_type2()) {