0001
0002 #include <linux/kernel.h>
0003 #include <linux/pci.h>
0004 #include <asm/pci-direct.h>
0005 #include <asm/io.h>
0006 #include <asm/pci_x86.h>
0007
0008
0009
0010
0011 u32 read_pci_config(u8 bus, u8 slot, u8 func, u8 offset)
0012 {
0013 u32 v;
0014 outl(0x80000000 | (bus<<16) | (slot<<11) | (func<<8) | offset, 0xcf8);
0015 v = inl(0xcfc);
0016 return v;
0017 }
0018
0019 u8 read_pci_config_byte(u8 bus, u8 slot, u8 func, u8 offset)
0020 {
0021 u8 v;
0022 outl(0x80000000 | (bus<<16) | (slot<<11) | (func<<8) | offset, 0xcf8);
0023 v = inb(0xcfc + (offset&3));
0024 return v;
0025 }
0026
0027 u16 read_pci_config_16(u8 bus, u8 slot, u8 func, u8 offset)
0028 {
0029 u16 v;
0030 outl(0x80000000 | (bus<<16) | (slot<<11) | (func<<8) | offset, 0xcf8);
0031 v = inw(0xcfc + (offset&2));
0032 return v;
0033 }
0034
0035 void write_pci_config(u8 bus, u8 slot, u8 func, u8 offset,
0036 u32 val)
0037 {
0038 outl(0x80000000 | (bus<<16) | (slot<<11) | (func<<8) | offset, 0xcf8);
0039 outl(val, 0xcfc);
0040 }
0041
0042 void write_pci_config_byte(u8 bus, u8 slot, u8 func, u8 offset, u8 val)
0043 {
0044 outl(0x80000000 | (bus<<16) | (slot<<11) | (func<<8) | offset, 0xcf8);
0045 outb(val, 0xcfc + (offset&3));
0046 }
0047
0048 void write_pci_config_16(u8 bus, u8 slot, u8 func, u8 offset, u16 val)
0049 {
0050 outl(0x80000000 | (bus<<16) | (slot<<11) | (func<<8) | offset, 0xcf8);
0051 outw(val, 0xcfc + (offset&2));
0052 }
0053
0054 int early_pci_allowed(void)
0055 {
0056 return (pci_probe & (PCI_PROBE_CONF1|PCI_PROBE_NOEARLY)) ==
0057 PCI_PROBE_CONF1;
0058 }
0059