1fb9aa6f1SThomas Gleixner /* 2fb9aa6f1SThomas Gleixner * Low-Level PCI Support for PC 3fb9aa6f1SThomas Gleixner * 4fb9aa6f1SThomas Gleixner * (c) 1999--2000 Martin Mares <mj@ucw.cz> 5fb9aa6f1SThomas Gleixner */ 6fb9aa6f1SThomas Gleixner 7fb9aa6f1SThomas Gleixner #include <linux/sched.h> 8fb9aa6f1SThomas Gleixner #include <linux/pci.h> 9fb9aa6f1SThomas Gleixner #include <linux/ioport.h> 10fb9aa6f1SThomas Gleixner #include <linux/init.h> 11fb9aa6f1SThomas Gleixner #include <linux/dmi.h> 12fb9aa6f1SThomas Gleixner 13fb9aa6f1SThomas Gleixner #include <asm/acpi.h> 14fb9aa6f1SThomas Gleixner #include <asm/segment.h> 15fb9aa6f1SThomas Gleixner #include <asm/io.h> 16fb9aa6f1SThomas Gleixner #include <asm/smp.h> 17fb9aa6f1SThomas Gleixner 18fb9aa6f1SThomas Gleixner #include "pci.h" 19fb9aa6f1SThomas Gleixner 20fb9aa6f1SThomas Gleixner unsigned int pci_probe = PCI_PROBE_BIOS | PCI_PROBE_CONF1 | PCI_PROBE_CONF2 | 21fb9aa6f1SThomas Gleixner PCI_PROBE_MMCONF; 22fb9aa6f1SThomas Gleixner 23fb9aa6f1SThomas Gleixner static int pci_bf_sort; 24fb9aa6f1SThomas Gleixner int pci_routeirq; 25fb9aa6f1SThomas Gleixner int pcibios_last_bus = -1; 26fb9aa6f1SThomas Gleixner unsigned long pirq_table_addr; 27fb9aa6f1SThomas Gleixner struct pci_bus *pci_root_bus; 28fb9aa6f1SThomas Gleixner struct pci_raw_ops *raw_pci_ops; 29b6ce068aSMatthew Wilcox struct pci_raw_ops *raw_pci_ext_ops; 30b6ce068aSMatthew Wilcox 31b6ce068aSMatthew Wilcox int raw_pci_read(unsigned int domain, unsigned int bus, unsigned int devfn, 32b6ce068aSMatthew Wilcox int reg, int len, u32 *val) 33b6ce068aSMatthew Wilcox { 34b6ce068aSMatthew Wilcox if (reg < 256 && raw_pci_ops) 35b6ce068aSMatthew Wilcox return raw_pci_ops->read(domain, bus, devfn, reg, len, val); 36b6ce068aSMatthew Wilcox if (raw_pci_ext_ops) 37b6ce068aSMatthew Wilcox return raw_pci_ext_ops->read(domain, bus, devfn, reg, len, val); 38b6ce068aSMatthew Wilcox return -EINVAL; 39b6ce068aSMatthew Wilcox } 40b6ce068aSMatthew Wilcox 41b6ce068aSMatthew Wilcox int raw_pci_write(unsigned int domain, unsigned int bus, unsigned int devfn, 42b6ce068aSMatthew Wilcox int reg, int len, u32 val) 43b6ce068aSMatthew Wilcox { 44b6ce068aSMatthew Wilcox if (reg < 256 && raw_pci_ops) 45b6ce068aSMatthew Wilcox return raw_pci_ops->write(domain, bus, devfn, reg, len, val); 46b6ce068aSMatthew Wilcox if (raw_pci_ext_ops) 47b6ce068aSMatthew Wilcox return raw_pci_ext_ops->write(domain, bus, devfn, reg, len, val); 48b6ce068aSMatthew Wilcox return -EINVAL; 49b6ce068aSMatthew Wilcox } 50fb9aa6f1SThomas Gleixner 51fb9aa6f1SThomas Gleixner static int pci_read(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 *value) 52fb9aa6f1SThomas Gleixner { 53b6ce068aSMatthew Wilcox return raw_pci_read(pci_domain_nr(bus), bus->number, 54a79e4198SJeff Garzik devfn, where, size, value); 55fb9aa6f1SThomas Gleixner } 56fb9aa6f1SThomas Gleixner 57fb9aa6f1SThomas Gleixner static int pci_write(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 value) 58fb9aa6f1SThomas Gleixner { 59b6ce068aSMatthew Wilcox return raw_pci_write(pci_domain_nr(bus), bus->number, 60a79e4198SJeff Garzik devfn, where, size, value); 61fb9aa6f1SThomas Gleixner } 62fb9aa6f1SThomas Gleixner 63fb9aa6f1SThomas Gleixner struct pci_ops pci_root_ops = { 64fb9aa6f1SThomas Gleixner .read = pci_read, 65fb9aa6f1SThomas Gleixner .write = pci_write, 66fb9aa6f1SThomas Gleixner }; 67fb9aa6f1SThomas Gleixner 68fb9aa6f1SThomas Gleixner /* 69fb9aa6f1SThomas Gleixner * legacy, numa, and acpi all want to call pcibios_scan_root 70fb9aa6f1SThomas Gleixner * from their initcalls. This flag prevents that. 71fb9aa6f1SThomas Gleixner */ 72fb9aa6f1SThomas Gleixner int pcibios_scanned; 73fb9aa6f1SThomas Gleixner 74fb9aa6f1SThomas Gleixner /* 75fb9aa6f1SThomas Gleixner * This interrupt-safe spinlock protects all accesses to PCI 76fb9aa6f1SThomas Gleixner * configuration space. 77fb9aa6f1SThomas Gleixner */ 78fb9aa6f1SThomas Gleixner DEFINE_SPINLOCK(pci_config_lock); 79fb9aa6f1SThomas Gleixner 8013a6ddb0SYinghai Lu static int __devinit can_skip_ioresource_align(const struct dmi_system_id *d) 8113a6ddb0SYinghai Lu { 8213a6ddb0SYinghai Lu pci_probe |= PCI_CAN_SKIP_ISA_ALIGN; 8313a6ddb0SYinghai Lu printk(KERN_INFO "PCI: %s detected, can skip ISA alignment\n", d->ident); 8413a6ddb0SYinghai Lu return 0; 8513a6ddb0SYinghai Lu } 8613a6ddb0SYinghai Lu 8713a6ddb0SYinghai Lu static struct dmi_system_id can_skip_pciprobe_dmi_table[] __devinitdata = { 8813a6ddb0SYinghai Lu /* 8913a6ddb0SYinghai Lu * Systems where PCI IO resource ISA alignment can be skipped 9013a6ddb0SYinghai Lu * when the ISA enable bit in the bridge control is not set 9113a6ddb0SYinghai Lu */ 9213a6ddb0SYinghai Lu { 9313a6ddb0SYinghai Lu .callback = can_skip_ioresource_align, 9413a6ddb0SYinghai Lu .ident = "IBM System x3800", 9513a6ddb0SYinghai Lu .matches = { 9613a6ddb0SYinghai Lu DMI_MATCH(DMI_SYS_VENDOR, "IBM"), 9713a6ddb0SYinghai Lu DMI_MATCH(DMI_PRODUCT_NAME, "x3800"), 9813a6ddb0SYinghai Lu }, 9913a6ddb0SYinghai Lu }, 10013a6ddb0SYinghai Lu { 10113a6ddb0SYinghai Lu .callback = can_skip_ioresource_align, 10213a6ddb0SYinghai Lu .ident = "IBM System x3850", 10313a6ddb0SYinghai Lu .matches = { 10413a6ddb0SYinghai Lu DMI_MATCH(DMI_SYS_VENDOR, "IBM"), 10513a6ddb0SYinghai Lu DMI_MATCH(DMI_PRODUCT_NAME, "x3850"), 10613a6ddb0SYinghai Lu }, 10713a6ddb0SYinghai Lu }, 10813a6ddb0SYinghai Lu { 10913a6ddb0SYinghai Lu .callback = can_skip_ioresource_align, 11013a6ddb0SYinghai Lu .ident = "IBM System x3950", 11113a6ddb0SYinghai Lu .matches = { 11213a6ddb0SYinghai Lu DMI_MATCH(DMI_SYS_VENDOR, "IBM"), 11313a6ddb0SYinghai Lu DMI_MATCH(DMI_PRODUCT_NAME, "x3950"), 11413a6ddb0SYinghai Lu }, 11513a6ddb0SYinghai Lu }, 11613a6ddb0SYinghai Lu {} 11713a6ddb0SYinghai Lu }; 11813a6ddb0SYinghai Lu 11913a6ddb0SYinghai Lu void __init dmi_check_skip_isa_align(void) 12013a6ddb0SYinghai Lu { 12113a6ddb0SYinghai Lu dmi_check_system(can_skip_pciprobe_dmi_table); 12213a6ddb0SYinghai Lu } 12313a6ddb0SYinghai Lu 124bb71ad88SGary Hade static void __devinit pcibios_fixup_device_resources(struct pci_dev *dev) 125bb71ad88SGary Hade { 126bb71ad88SGary Hade struct resource *rom_r = &dev->resource[PCI_ROM_RESOURCE]; 127bb71ad88SGary Hade 128bb71ad88SGary Hade if (pci_probe & PCI_NOASSIGN_ROMS) { 129bb71ad88SGary Hade if (rom_r->parent) 130bb71ad88SGary Hade return; 131bb71ad88SGary Hade if (rom_r->start) { 132bb71ad88SGary Hade /* we deal with BIOS assigned ROM later */ 133bb71ad88SGary Hade return; 134bb71ad88SGary Hade } 135bb71ad88SGary Hade rom_r->start = rom_r->end = rom_r->flags = 0; 136bb71ad88SGary Hade } 137bb71ad88SGary Hade } 138bb71ad88SGary Hade 139fb9aa6f1SThomas Gleixner /* 140fb9aa6f1SThomas Gleixner * Called after each bus is probed, but before its children 141fb9aa6f1SThomas Gleixner * are examined. 142fb9aa6f1SThomas Gleixner */ 143fb9aa6f1SThomas Gleixner 144fb9aa6f1SThomas Gleixner void __devinit pcibios_fixup_bus(struct pci_bus *b) 145fb9aa6f1SThomas Gleixner { 146bb71ad88SGary Hade struct pci_dev *dev; 147bb71ad88SGary Hade 148fb9aa6f1SThomas Gleixner pci_read_bridge_bases(b); 149bb71ad88SGary Hade list_for_each_entry(dev, &b->devices, bus_list) 150bb71ad88SGary Hade pcibios_fixup_device_resources(dev); 151fb9aa6f1SThomas Gleixner } 152fb9aa6f1SThomas Gleixner 153fb9aa6f1SThomas Gleixner /* 154fb9aa6f1SThomas Gleixner * Only use DMI information to set this if nothing was passed 155fb9aa6f1SThomas Gleixner * on the kernel command line (which was parsed earlier). 156fb9aa6f1SThomas Gleixner */ 157fb9aa6f1SThomas Gleixner 15819ad7ae4SLinus Torvalds static int __devinit set_bf_sort(const struct dmi_system_id *d) 159fb9aa6f1SThomas Gleixner { 160fb9aa6f1SThomas Gleixner if (pci_bf_sort == pci_bf_sort_default) { 161fb9aa6f1SThomas Gleixner pci_bf_sort = pci_dmi_bf; 162fb9aa6f1SThomas Gleixner printk(KERN_INFO "PCI: %s detected, enabling pci=bfsort.\n", d->ident); 163fb9aa6f1SThomas Gleixner } 164fb9aa6f1SThomas Gleixner return 0; 165fb9aa6f1SThomas Gleixner } 166fb9aa6f1SThomas Gleixner 167fb9aa6f1SThomas Gleixner /* 168fb9aa6f1SThomas Gleixner * Enable renumbering of PCI bus# ranges to reach all PCI busses (Cardbus) 169fb9aa6f1SThomas Gleixner */ 170fb9aa6f1SThomas Gleixner #ifdef __i386__ 17119ad7ae4SLinus Torvalds static int __devinit assign_all_busses(const struct dmi_system_id *d) 172fb9aa6f1SThomas Gleixner { 173fb9aa6f1SThomas Gleixner pci_probe |= PCI_ASSIGN_ALL_BUSSES; 174fb9aa6f1SThomas Gleixner printk(KERN_INFO "%s detected: enabling PCI bus# renumbering" 175fb9aa6f1SThomas Gleixner " (pci=assign-busses)\n", d->ident); 176fb9aa6f1SThomas Gleixner return 0; 177fb9aa6f1SThomas Gleixner } 178fb9aa6f1SThomas Gleixner #endif 179fb9aa6f1SThomas Gleixner 180fb9aa6f1SThomas Gleixner static struct dmi_system_id __devinitdata pciprobe_dmi_table[] = { 181fb9aa6f1SThomas Gleixner #ifdef __i386__ 182fb9aa6f1SThomas Gleixner /* 183fb9aa6f1SThomas Gleixner * Laptops which need pci=assign-busses to see Cardbus cards 184fb9aa6f1SThomas Gleixner */ 185fb9aa6f1SThomas Gleixner { 186fb9aa6f1SThomas Gleixner .callback = assign_all_busses, 187fb9aa6f1SThomas Gleixner .ident = "Samsung X20 Laptop", 188fb9aa6f1SThomas Gleixner .matches = { 189fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_SYS_VENDOR, "Samsung Electronics"), 190fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_PRODUCT_NAME, "SX20S"), 191fb9aa6f1SThomas Gleixner }, 192fb9aa6f1SThomas Gleixner }, 193fb9aa6f1SThomas Gleixner #endif /* __i386__ */ 194fb9aa6f1SThomas Gleixner { 195fb9aa6f1SThomas Gleixner .callback = set_bf_sort, 196fb9aa6f1SThomas Gleixner .ident = "Dell PowerEdge 1950", 197fb9aa6f1SThomas Gleixner .matches = { 198fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_SYS_VENDOR, "Dell"), 199fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge 1950"), 200fb9aa6f1SThomas Gleixner }, 201fb9aa6f1SThomas Gleixner }, 202fb9aa6f1SThomas Gleixner { 203fb9aa6f1SThomas Gleixner .callback = set_bf_sort, 204fb9aa6f1SThomas Gleixner .ident = "Dell PowerEdge 1955", 205fb9aa6f1SThomas Gleixner .matches = { 206fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_SYS_VENDOR, "Dell"), 207fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge 1955"), 208fb9aa6f1SThomas Gleixner }, 209fb9aa6f1SThomas Gleixner }, 210fb9aa6f1SThomas Gleixner { 211fb9aa6f1SThomas Gleixner .callback = set_bf_sort, 212fb9aa6f1SThomas Gleixner .ident = "Dell PowerEdge 2900", 213fb9aa6f1SThomas Gleixner .matches = { 214fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_SYS_VENDOR, "Dell"), 215fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge 2900"), 216fb9aa6f1SThomas Gleixner }, 217fb9aa6f1SThomas Gleixner }, 218fb9aa6f1SThomas Gleixner { 219fb9aa6f1SThomas Gleixner .callback = set_bf_sort, 220fb9aa6f1SThomas Gleixner .ident = "Dell PowerEdge 2950", 221fb9aa6f1SThomas Gleixner .matches = { 222fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_SYS_VENDOR, "Dell"), 223fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge 2950"), 224fb9aa6f1SThomas Gleixner }, 225fb9aa6f1SThomas Gleixner }, 226fb9aa6f1SThomas Gleixner { 227fb9aa6f1SThomas Gleixner .callback = set_bf_sort, 228fb9aa6f1SThomas Gleixner .ident = "Dell PowerEdge R900", 229fb9aa6f1SThomas Gleixner .matches = { 230fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_SYS_VENDOR, "Dell"), 231fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge R900"), 232fb9aa6f1SThomas Gleixner }, 233fb9aa6f1SThomas Gleixner }, 234fb9aa6f1SThomas Gleixner { 235fb9aa6f1SThomas Gleixner .callback = set_bf_sort, 236fb9aa6f1SThomas Gleixner .ident = "HP ProLiant BL20p G3", 237fb9aa6f1SThomas Gleixner .matches = { 238fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_SYS_VENDOR, "HP"), 239fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL20p G3"), 240fb9aa6f1SThomas Gleixner }, 241fb9aa6f1SThomas Gleixner }, 242fb9aa6f1SThomas Gleixner { 243fb9aa6f1SThomas Gleixner .callback = set_bf_sort, 244fb9aa6f1SThomas Gleixner .ident = "HP ProLiant BL20p G4", 245fb9aa6f1SThomas Gleixner .matches = { 246fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_SYS_VENDOR, "HP"), 247fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL20p G4"), 248fb9aa6f1SThomas Gleixner }, 249fb9aa6f1SThomas Gleixner }, 250fb9aa6f1SThomas Gleixner { 251fb9aa6f1SThomas Gleixner .callback = set_bf_sort, 252fb9aa6f1SThomas Gleixner .ident = "HP ProLiant BL30p G1", 253fb9aa6f1SThomas Gleixner .matches = { 254fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_SYS_VENDOR, "HP"), 255fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL30p G1"), 256fb9aa6f1SThomas Gleixner }, 257fb9aa6f1SThomas Gleixner }, 258fb9aa6f1SThomas Gleixner { 259fb9aa6f1SThomas Gleixner .callback = set_bf_sort, 260fb9aa6f1SThomas Gleixner .ident = "HP ProLiant BL25p G1", 261fb9aa6f1SThomas Gleixner .matches = { 262fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_SYS_VENDOR, "HP"), 263fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL25p G1"), 264fb9aa6f1SThomas Gleixner }, 265fb9aa6f1SThomas Gleixner }, 266fb9aa6f1SThomas Gleixner { 267fb9aa6f1SThomas Gleixner .callback = set_bf_sort, 268fb9aa6f1SThomas Gleixner .ident = "HP ProLiant BL35p G1", 269fb9aa6f1SThomas Gleixner .matches = { 270fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_SYS_VENDOR, "HP"), 271fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL35p G1"), 272fb9aa6f1SThomas Gleixner }, 273fb9aa6f1SThomas Gleixner }, 274fb9aa6f1SThomas Gleixner { 275fb9aa6f1SThomas Gleixner .callback = set_bf_sort, 276fb9aa6f1SThomas Gleixner .ident = "HP ProLiant BL45p G1", 277fb9aa6f1SThomas Gleixner .matches = { 278fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_SYS_VENDOR, "HP"), 279fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL45p G1"), 280fb9aa6f1SThomas Gleixner }, 281fb9aa6f1SThomas Gleixner }, 282fb9aa6f1SThomas Gleixner { 283fb9aa6f1SThomas Gleixner .callback = set_bf_sort, 284fb9aa6f1SThomas Gleixner .ident = "HP ProLiant BL45p G2", 285fb9aa6f1SThomas Gleixner .matches = { 286fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_SYS_VENDOR, "HP"), 287fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL45p G2"), 288fb9aa6f1SThomas Gleixner }, 289fb9aa6f1SThomas Gleixner }, 290fb9aa6f1SThomas Gleixner { 291fb9aa6f1SThomas Gleixner .callback = set_bf_sort, 292fb9aa6f1SThomas Gleixner .ident = "HP ProLiant BL460c G1", 293fb9aa6f1SThomas Gleixner .matches = { 294fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_SYS_VENDOR, "HP"), 295fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL460c G1"), 296fb9aa6f1SThomas Gleixner }, 297fb9aa6f1SThomas Gleixner }, 298fb9aa6f1SThomas Gleixner { 299fb9aa6f1SThomas Gleixner .callback = set_bf_sort, 300fb9aa6f1SThomas Gleixner .ident = "HP ProLiant BL465c G1", 301fb9aa6f1SThomas Gleixner .matches = { 302fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_SYS_VENDOR, "HP"), 303fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL465c G1"), 304fb9aa6f1SThomas Gleixner }, 305fb9aa6f1SThomas Gleixner }, 306fb9aa6f1SThomas Gleixner { 307fb9aa6f1SThomas Gleixner .callback = set_bf_sort, 308fb9aa6f1SThomas Gleixner .ident = "HP ProLiant BL480c G1", 309fb9aa6f1SThomas Gleixner .matches = { 310fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_SYS_VENDOR, "HP"), 311fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL480c G1"), 312fb9aa6f1SThomas Gleixner }, 313fb9aa6f1SThomas Gleixner }, 314fb9aa6f1SThomas Gleixner { 315fb9aa6f1SThomas Gleixner .callback = set_bf_sort, 316fb9aa6f1SThomas Gleixner .ident = "HP ProLiant BL685c G1", 317fb9aa6f1SThomas Gleixner .matches = { 318fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_SYS_VENDOR, "HP"), 319fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL685c G1"), 320fb9aa6f1SThomas Gleixner }, 321fb9aa6f1SThomas Gleixner }, 3228f8ae1a7SMichal Schmidt { 3238f8ae1a7SMichal Schmidt .callback = set_bf_sort, 3248d64c781STony Camuso .ident = "HP ProLiant DL360", 3258f8ae1a7SMichal Schmidt .matches = { 3268f8ae1a7SMichal Schmidt DMI_MATCH(DMI_SYS_VENDOR, "HP"), 3278d64c781STony Camuso DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant DL360"), 3288f8ae1a7SMichal Schmidt }, 3298f8ae1a7SMichal Schmidt }, 3308f8ae1a7SMichal Schmidt { 3318f8ae1a7SMichal Schmidt .callback = set_bf_sort, 3328d64c781STony Camuso .ident = "HP ProLiant DL380", 3338f8ae1a7SMichal Schmidt .matches = { 3348f8ae1a7SMichal Schmidt DMI_MATCH(DMI_SYS_VENDOR, "HP"), 3358d64c781STony Camuso DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant DL380"), 3368f8ae1a7SMichal Schmidt }, 3378f8ae1a7SMichal Schmidt }, 3385b1ea82fSJuha Laiho #ifdef __i386__ 3395b1ea82fSJuha Laiho { 3405b1ea82fSJuha Laiho .callback = assign_all_busses, 3415b1ea82fSJuha Laiho .ident = "Compaq EVO N800c", 3425b1ea82fSJuha Laiho .matches = { 3435b1ea82fSJuha Laiho DMI_MATCH(DMI_SYS_VENDOR, "Compaq"), 3445b1ea82fSJuha Laiho DMI_MATCH(DMI_PRODUCT_NAME, "EVO N800c"), 3455b1ea82fSJuha Laiho }, 3465b1ea82fSJuha Laiho }, 3475b1ea82fSJuha Laiho #endif 348c82bc5adSMichal Schmidt { 349c82bc5adSMichal Schmidt .callback = set_bf_sort, 350c82bc5adSMichal Schmidt .ident = "HP ProLiant DL385 G2", 351c82bc5adSMichal Schmidt .matches = { 352c82bc5adSMichal Schmidt DMI_MATCH(DMI_SYS_VENDOR, "HP"), 353c82bc5adSMichal Schmidt DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant DL385 G2"), 354c82bc5adSMichal Schmidt }, 355c82bc5adSMichal Schmidt }, 356c82bc5adSMichal Schmidt { 357c82bc5adSMichal Schmidt .callback = set_bf_sort, 358c82bc5adSMichal Schmidt .ident = "HP ProLiant DL585 G2", 359c82bc5adSMichal Schmidt .matches = { 360c82bc5adSMichal Schmidt DMI_MATCH(DMI_SYS_VENDOR, "HP"), 361c82bc5adSMichal Schmidt DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant DL585 G2"), 362c82bc5adSMichal Schmidt }, 363c82bc5adSMichal Schmidt }, 364fb9aa6f1SThomas Gleixner {} 365fb9aa6f1SThomas Gleixner }; 366fb9aa6f1SThomas Gleixner 3670df18ff3SYinghai Lu void __init dmi_check_pciprobe(void) 3680df18ff3SYinghai Lu { 3690df18ff3SYinghai Lu dmi_check_system(pciprobe_dmi_table); 3700df18ff3SYinghai Lu } 3710df18ff3SYinghai Lu 372fb9aa6f1SThomas Gleixner struct pci_bus * __devinit pcibios_scan_root(int busnum) 373fb9aa6f1SThomas Gleixner { 374fb9aa6f1SThomas Gleixner struct pci_bus *bus = NULL; 375fb9aa6f1SThomas Gleixner struct pci_sysdata *sd; 376fb9aa6f1SThomas Gleixner 377fb9aa6f1SThomas Gleixner while ((bus = pci_find_next_bus(bus)) != NULL) { 378fb9aa6f1SThomas Gleixner if (bus->number == busnum) { 379fb9aa6f1SThomas Gleixner /* Already scanned */ 380fb9aa6f1SThomas Gleixner return bus; 381fb9aa6f1SThomas Gleixner } 382fb9aa6f1SThomas Gleixner } 383fb9aa6f1SThomas Gleixner 384fb9aa6f1SThomas Gleixner /* Allocate per-root-bus (not per bus) arch-specific data. 385fb9aa6f1SThomas Gleixner * TODO: leak; this memory is never freed. 386fb9aa6f1SThomas Gleixner * It's arguable whether it's worth the trouble to care. 387fb9aa6f1SThomas Gleixner */ 388fb9aa6f1SThomas Gleixner sd = kzalloc(sizeof(*sd), GFP_KERNEL); 389fb9aa6f1SThomas Gleixner if (!sd) { 390fb9aa6f1SThomas Gleixner printk(KERN_ERR "PCI: OOM, not probing PCI bus %02x\n", busnum); 391fb9aa6f1SThomas Gleixner return NULL; 392fb9aa6f1SThomas Gleixner } 393fb9aa6f1SThomas Gleixner 394871d5f8dSYinghai Lu sd->node = get_mp_bus_to_node(busnum); 395fb9aa6f1SThomas Gleixner 396871d5f8dSYinghai Lu printk(KERN_DEBUG "PCI: Probing PCI hardware (bus %02x)\n", busnum); 397871d5f8dSYinghai Lu bus = pci_scan_bus_parented(NULL, busnum, &pci_root_ops, sd); 398871d5f8dSYinghai Lu if (!bus) 399871d5f8dSYinghai Lu kfree(sd); 400871d5f8dSYinghai Lu 401871d5f8dSYinghai Lu return bus; 402fb9aa6f1SThomas Gleixner } 403fb9aa6f1SThomas Gleixner 404fb9aa6f1SThomas Gleixner extern u8 pci_cache_line_size; 405fb9aa6f1SThomas Gleixner 406fb9aa6f1SThomas Gleixner static int __init pcibios_init(void) 407fb9aa6f1SThomas Gleixner { 408fb9aa6f1SThomas Gleixner struct cpuinfo_x86 *c = &boot_cpu_data; 409fb9aa6f1SThomas Gleixner 410fb9aa6f1SThomas Gleixner if (!raw_pci_ops) { 411fb9aa6f1SThomas Gleixner printk(KERN_WARNING "PCI: System does not support PCI\n"); 412fb9aa6f1SThomas Gleixner return 0; 413fb9aa6f1SThomas Gleixner } 414fb9aa6f1SThomas Gleixner 415fb9aa6f1SThomas Gleixner /* 416fb9aa6f1SThomas Gleixner * Assume PCI cacheline size of 32 bytes for all x86s except K7/K8 417fb9aa6f1SThomas Gleixner * and P4. It's also good for 386/486s (which actually have 16) 418fb9aa6f1SThomas Gleixner * as quite a few PCI devices do not support smaller values. 419fb9aa6f1SThomas Gleixner */ 420fb9aa6f1SThomas Gleixner pci_cache_line_size = 32 >> 2; 421fb9aa6f1SThomas Gleixner if (c->x86 >= 6 && c->x86_vendor == X86_VENDOR_AMD) 422fb9aa6f1SThomas Gleixner pci_cache_line_size = 64 >> 2; /* K7 & K8 */ 423fb9aa6f1SThomas Gleixner else if (c->x86 > 6 && c->x86_vendor == X86_VENDOR_INTEL) 424fb9aa6f1SThomas Gleixner pci_cache_line_size = 128 >> 2; /* P4 */ 425fb9aa6f1SThomas Gleixner 426fb9aa6f1SThomas Gleixner pcibios_resource_survey(); 427fb9aa6f1SThomas Gleixner 428fb9aa6f1SThomas Gleixner if (pci_bf_sort >= pci_force_bf) 429fb9aa6f1SThomas Gleixner pci_sort_breadthfirst(); 430fb9aa6f1SThomas Gleixner return 0; 431fb9aa6f1SThomas Gleixner } 432fb9aa6f1SThomas Gleixner 433fb9aa6f1SThomas Gleixner subsys_initcall(pcibios_init); 434fb9aa6f1SThomas Gleixner 435fb9aa6f1SThomas Gleixner char * __devinit pcibios_setup(char *str) 436fb9aa6f1SThomas Gleixner { 437fb9aa6f1SThomas Gleixner if (!strcmp(str, "off")) { 438fb9aa6f1SThomas Gleixner pci_probe = 0; 439fb9aa6f1SThomas Gleixner return NULL; 440fb9aa6f1SThomas Gleixner } else if (!strcmp(str, "bfsort")) { 441fb9aa6f1SThomas Gleixner pci_bf_sort = pci_force_bf; 442fb9aa6f1SThomas Gleixner return NULL; 443fb9aa6f1SThomas Gleixner } else if (!strcmp(str, "nobfsort")) { 444fb9aa6f1SThomas Gleixner pci_bf_sort = pci_force_nobf; 445fb9aa6f1SThomas Gleixner return NULL; 446fb9aa6f1SThomas Gleixner } 447fb9aa6f1SThomas Gleixner #ifdef CONFIG_PCI_BIOS 448fb9aa6f1SThomas Gleixner else if (!strcmp(str, "bios")) { 449fb9aa6f1SThomas Gleixner pci_probe = PCI_PROBE_BIOS; 450fb9aa6f1SThomas Gleixner return NULL; 451fb9aa6f1SThomas Gleixner } else if (!strcmp(str, "nobios")) { 452fb9aa6f1SThomas Gleixner pci_probe &= ~PCI_PROBE_BIOS; 453fb9aa6f1SThomas Gleixner return NULL; 454fb9aa6f1SThomas Gleixner } else if (!strcmp(str, "biosirq")) { 455fb9aa6f1SThomas Gleixner pci_probe |= PCI_BIOS_IRQ_SCAN; 456fb9aa6f1SThomas Gleixner return NULL; 457fb9aa6f1SThomas Gleixner } else if (!strncmp(str, "pirqaddr=", 9)) { 458fb9aa6f1SThomas Gleixner pirq_table_addr = simple_strtoul(str+9, NULL, 0); 459fb9aa6f1SThomas Gleixner return NULL; 460fb9aa6f1SThomas Gleixner } 461fb9aa6f1SThomas Gleixner #endif 462fb9aa6f1SThomas Gleixner #ifdef CONFIG_PCI_DIRECT 463fb9aa6f1SThomas Gleixner else if (!strcmp(str, "conf1")) { 464fb9aa6f1SThomas Gleixner pci_probe = PCI_PROBE_CONF1 | PCI_NO_CHECKS; 465fb9aa6f1SThomas Gleixner return NULL; 466fb9aa6f1SThomas Gleixner } 467fb9aa6f1SThomas Gleixner else if (!strcmp(str, "conf2")) { 468fb9aa6f1SThomas Gleixner pci_probe = PCI_PROBE_CONF2 | PCI_NO_CHECKS; 469fb9aa6f1SThomas Gleixner return NULL; 470fb9aa6f1SThomas Gleixner } 471fb9aa6f1SThomas Gleixner #endif 472fb9aa6f1SThomas Gleixner #ifdef CONFIG_PCI_MMCONFIG 473fb9aa6f1SThomas Gleixner else if (!strcmp(str, "nommconf")) { 474fb9aa6f1SThomas Gleixner pci_probe &= ~PCI_PROBE_MMCONF; 475fb9aa6f1SThomas Gleixner return NULL; 476fb9aa6f1SThomas Gleixner } 4775f0b2976SYinghai Lu else if (!strcmp(str, "check_enable_amd_mmconf")) { 4785f0b2976SYinghai Lu pci_probe |= PCI_CHECK_ENABLE_AMD_MMCONF; 4795f0b2976SYinghai Lu return NULL; 4805f0b2976SYinghai Lu } 481fb9aa6f1SThomas Gleixner #endif 482fb9aa6f1SThomas Gleixner else if (!strcmp(str, "noacpi")) { 483fb9aa6f1SThomas Gleixner acpi_noirq_set(); 484fb9aa6f1SThomas Gleixner return NULL; 485fb9aa6f1SThomas Gleixner } 486fb9aa6f1SThomas Gleixner else if (!strcmp(str, "noearly")) { 487fb9aa6f1SThomas Gleixner pci_probe |= PCI_PROBE_NOEARLY; 488fb9aa6f1SThomas Gleixner return NULL; 489fb9aa6f1SThomas Gleixner } 490fb9aa6f1SThomas Gleixner #ifndef CONFIG_X86_VISWS 491fb9aa6f1SThomas Gleixner else if (!strcmp(str, "usepirqmask")) { 492fb9aa6f1SThomas Gleixner pci_probe |= PCI_USE_PIRQ_MASK; 493fb9aa6f1SThomas Gleixner return NULL; 494fb9aa6f1SThomas Gleixner } else if (!strncmp(str, "irqmask=", 8)) { 495fb9aa6f1SThomas Gleixner pcibios_irq_mask = simple_strtol(str+8, NULL, 0); 496fb9aa6f1SThomas Gleixner return NULL; 497fb9aa6f1SThomas Gleixner } else if (!strncmp(str, "lastbus=", 8)) { 498fb9aa6f1SThomas Gleixner pcibios_last_bus = simple_strtol(str+8, NULL, 0); 499fb9aa6f1SThomas Gleixner return NULL; 500fb9aa6f1SThomas Gleixner } 501fb9aa6f1SThomas Gleixner #endif 502fb9aa6f1SThomas Gleixner else if (!strcmp(str, "rom")) { 503fb9aa6f1SThomas Gleixner pci_probe |= PCI_ASSIGN_ROMS; 504fb9aa6f1SThomas Gleixner return NULL; 505bb71ad88SGary Hade } else if (!strcmp(str, "norom")) { 506bb71ad88SGary Hade pci_probe |= PCI_NOASSIGN_ROMS; 507bb71ad88SGary Hade return NULL; 508fb9aa6f1SThomas Gleixner } else if (!strcmp(str, "assign-busses")) { 509fb9aa6f1SThomas Gleixner pci_probe |= PCI_ASSIGN_ALL_BUSSES; 510fb9aa6f1SThomas Gleixner return NULL; 51162f420f8SGary Hade } else if (!strcmp(str, "use_crs")) { 51262f420f8SGary Hade pci_probe |= PCI_USE__CRS; 51362f420f8SGary Hade return NULL; 514fb9aa6f1SThomas Gleixner } else if (!strcmp(str, "routeirq")) { 515fb9aa6f1SThomas Gleixner pci_routeirq = 1; 516fb9aa6f1SThomas Gleixner return NULL; 51713a6ddb0SYinghai Lu } else if (!strcmp(str, "skip_isa_align")) { 51813a6ddb0SYinghai Lu pci_probe |= PCI_CAN_SKIP_ISA_ALIGN; 51913a6ddb0SYinghai Lu return NULL; 520fb9aa6f1SThomas Gleixner } 521fb9aa6f1SThomas Gleixner return str; 522fb9aa6f1SThomas Gleixner } 523fb9aa6f1SThomas Gleixner 524fb9aa6f1SThomas Gleixner unsigned int pcibios_assign_all_busses(void) 525fb9aa6f1SThomas Gleixner { 526fb9aa6f1SThomas Gleixner return (pci_probe & PCI_ASSIGN_ALL_BUSSES) ? 1 : 0; 527fb9aa6f1SThomas Gleixner } 528fb9aa6f1SThomas Gleixner 529fb9aa6f1SThomas Gleixner int pcibios_enable_device(struct pci_dev *dev, int mask) 530fb9aa6f1SThomas Gleixner { 531fb9aa6f1SThomas Gleixner int err; 532fb9aa6f1SThomas Gleixner 533b81d988cSBjorn Helgaas if ((err = pci_enable_resources(dev, mask)) < 0) 534fb9aa6f1SThomas Gleixner return err; 535fb9aa6f1SThomas Gleixner 536fb9aa6f1SThomas Gleixner if (!dev->msi_enabled) 537fb9aa6f1SThomas Gleixner return pcibios_enable_irq(dev); 538fb9aa6f1SThomas Gleixner return 0; 539fb9aa6f1SThomas Gleixner } 540fb9aa6f1SThomas Gleixner 541fb9aa6f1SThomas Gleixner void pcibios_disable_device (struct pci_dev *dev) 542fb9aa6f1SThomas Gleixner { 543fb9aa6f1SThomas Gleixner if (!dev->msi_enabled && pcibios_disable_irq) 544fb9aa6f1SThomas Gleixner pcibios_disable_irq(dev); 545fb9aa6f1SThomas Gleixner } 546fb9aa6f1SThomas Gleixner 54798db6f19SSam Ravnborg struct pci_bus * __devinit pci_scan_bus_on_node(int busno, struct pci_ops *ops, int node) 548fb9aa6f1SThomas Gleixner { 549fb9aa6f1SThomas Gleixner struct pci_bus *bus = NULL; 550fb9aa6f1SThomas Gleixner struct pci_sysdata *sd; 551fb9aa6f1SThomas Gleixner 552fb9aa6f1SThomas Gleixner /* 553fb9aa6f1SThomas Gleixner * Allocate per-root-bus (not per bus) arch-specific data. 554fb9aa6f1SThomas Gleixner * TODO: leak; this memory is never freed. 555fb9aa6f1SThomas Gleixner * It's arguable whether it's worth the trouble to care. 556fb9aa6f1SThomas Gleixner */ 557fb9aa6f1SThomas Gleixner sd = kzalloc(sizeof(*sd), GFP_KERNEL); 558fb9aa6f1SThomas Gleixner if (!sd) { 559fb9aa6f1SThomas Gleixner printk(KERN_ERR "PCI: OOM, skipping PCI bus %02x\n", busno); 560fb9aa6f1SThomas Gleixner return NULL; 561fb9aa6f1SThomas Gleixner } 562871d5f8dSYinghai Lu sd->node = node; 563871d5f8dSYinghai Lu bus = pci_scan_bus(busno, ops, sd); 564fb9aa6f1SThomas Gleixner if (!bus) 565fb9aa6f1SThomas Gleixner kfree(sd); 566fb9aa6f1SThomas Gleixner 567fb9aa6f1SThomas Gleixner return bus; 568fb9aa6f1SThomas Gleixner } 569871d5f8dSYinghai Lu 57098db6f19SSam Ravnborg struct pci_bus * __devinit pci_scan_bus_with_sysdata(int busno) 571871d5f8dSYinghai Lu { 572871d5f8dSYinghai Lu return pci_scan_bus_on_node(busno, &pci_root_ops, -1); 573871d5f8dSYinghai Lu } 574