blob: bb1a01f089e29c817432907a820ca7a06f727347 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Low-Level PCI Support for PC
3 *
4 * (c) 1999--2000 Martin Mares <mj@ucw.cz>
5 */
6
7#include <linux/sched.h>
8#include <linux/pci.h>
9#include <linux/ioport.h>
10#include <linux/init.h>
Bernhard Kaindl8c4b2cf2006-02-18 01:36:55 -080011#include <linux/dmi.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070012
13#include <asm/acpi.h>
14#include <asm/segment.h>
15#include <asm/io.h>
16#include <asm/smp.h>
17
18#include "pci.h"
19
Linus Torvalds1da177e2005-04-16 15:20:36 -070020unsigned int pci_probe = PCI_PROBE_BIOS | PCI_PROBE_CONF1 | PCI_PROBE_CONF2 |
21 PCI_PROBE_MMCONF;
22
Yinghai Lue3f2bae2008-05-22 14:35:11 -070023unsigned int pci_early_dump_regs;
Adrian Bunk2b290da2006-11-16 13:16:23 +010024static int pci_bf_sort;
Linus Torvalds1da177e2005-04-16 15:20:36 -070025int pci_routeirq;
Stefan Assmanna9322f62008-06-11 16:35:14 +020026int noioapicquirk;
Stefan Assmann41b9eb22008-07-15 13:48:55 +020027#ifdef CONFIG_X86_REROUTE_FOR_BROKEN_BOOT_IRQS
28int noioapicreroute = 0;
29#else
Stefan Assmann91979792008-06-11 16:35:15 +020030int noioapicreroute = 1;
Stefan Assmann41b9eb22008-07-15 13:48:55 +020031#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070032int pcibios_last_bus = -1;
jayalk@intworks.biz120bb422005-03-21 20:20:42 -080033unsigned long pirq_table_addr;
34struct pci_bus *pci_root_bus;
Linus Torvalds1da177e2005-04-16 15:20:36 -070035struct pci_raw_ops *raw_pci_ops;
Matthew Wilcoxb6ce0682008-02-10 09:45:28 -050036struct pci_raw_ops *raw_pci_ext_ops;
37
38int raw_pci_read(unsigned int domain, unsigned int bus, unsigned int devfn,
39 int reg, int len, u32 *val)
40{
Matthew Wilcoxbeef3122008-07-11 15:21:17 -060041 if (domain == 0 && reg < 256 && raw_pci_ops)
Matthew Wilcoxb6ce0682008-02-10 09:45:28 -050042 return raw_pci_ops->read(domain, bus, devfn, reg, len, val);
43 if (raw_pci_ext_ops)
44 return raw_pci_ext_ops->read(domain, bus, devfn, reg, len, val);
45 return -EINVAL;
46}
47
48int raw_pci_write(unsigned int domain, unsigned int bus, unsigned int devfn,
49 int reg, int len, u32 val)
50{
Matthew Wilcoxbeef3122008-07-11 15:21:17 -060051 if (domain == 0 && reg < 256 && raw_pci_ops)
Matthew Wilcoxb6ce0682008-02-10 09:45:28 -050052 return raw_pci_ops->write(domain, bus, devfn, reg, len, val);
53 if (raw_pci_ext_ops)
54 return raw_pci_ext_ops->write(domain, bus, devfn, reg, len, val);
55 return -EINVAL;
56}
Linus Torvalds1da177e2005-04-16 15:20:36 -070057
58static int pci_read(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 *value)
59{
Matthew Wilcoxb6ce0682008-02-10 09:45:28 -050060 return raw_pci_read(pci_domain_nr(bus), bus->number,
Jeff Garzika79e4192007-10-11 16:58:30 -040061 devfn, where, size, value);
Linus Torvalds1da177e2005-04-16 15:20:36 -070062}
63
64static int pci_write(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 value)
65{
Matthew Wilcoxb6ce0682008-02-10 09:45:28 -050066 return raw_pci_write(pci_domain_nr(bus), bus->number,
Jeff Garzika79e4192007-10-11 16:58:30 -040067 devfn, where, size, value);
Linus Torvalds1da177e2005-04-16 15:20:36 -070068}
69
70struct pci_ops pci_root_ops = {
71 .read = pci_read,
72 .write = pci_write,
73};
74
75/*
76 * legacy, numa, and acpi all want to call pcibios_scan_root
77 * from their initcalls. This flag prevents that.
78 */
79int pcibios_scanned;
80
81/*
82 * This interrupt-safe spinlock protects all accesses to PCI
83 * configuration space.
84 */
85DEFINE_SPINLOCK(pci_config_lock);
86
Yinghai Lu13a6ddb2008-03-27 01:31:18 -070087static int __devinit can_skip_ioresource_align(const struct dmi_system_id *d)
88{
89 pci_probe |= PCI_CAN_SKIP_ISA_ALIGN;
90 printk(KERN_INFO "PCI: %s detected, can skip ISA alignment\n", d->ident);
91 return 0;
92}
93
94static struct dmi_system_id can_skip_pciprobe_dmi_table[] __devinitdata = {
95/*
96 * Systems where PCI IO resource ISA alignment can be skipped
97 * when the ISA enable bit in the bridge control is not set
98 */
99 {
100 .callback = can_skip_ioresource_align,
101 .ident = "IBM System x3800",
102 .matches = {
103 DMI_MATCH(DMI_SYS_VENDOR, "IBM"),
104 DMI_MATCH(DMI_PRODUCT_NAME, "x3800"),
105 },
106 },
107 {
108 .callback = can_skip_ioresource_align,
109 .ident = "IBM System x3850",
110 .matches = {
111 DMI_MATCH(DMI_SYS_VENDOR, "IBM"),
112 DMI_MATCH(DMI_PRODUCT_NAME, "x3850"),
113 },
114 },
115 {
116 .callback = can_skip_ioresource_align,
117 .ident = "IBM System x3950",
118 .matches = {
119 DMI_MATCH(DMI_SYS_VENDOR, "IBM"),
120 DMI_MATCH(DMI_PRODUCT_NAME, "x3950"),
121 },
122 },
123 {}
124};
125
126void __init dmi_check_skip_isa_align(void)
127{
128 dmi_check_system(can_skip_pciprobe_dmi_table);
129}
130
Gary Hadebb71ad82008-05-12 13:57:46 -0700131static void __devinit pcibios_fixup_device_resources(struct pci_dev *dev)
132{
133 struct resource *rom_r = &dev->resource[PCI_ROM_RESOURCE];
134
135 if (pci_probe & PCI_NOASSIGN_ROMS) {
136 if (rom_r->parent)
137 return;
138 if (rom_r->start) {
139 /* we deal with BIOS assigned ROM later */
140 return;
141 }
142 rom_r->start = rom_r->end = rom_r->flags = 0;
143 }
144}
145
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146/*
147 * Called after each bus is probed, but before its children
148 * are examined.
149 */
150
151void __devinit pcibios_fixup_bus(struct pci_bus *b)
152{
Gary Hadebb71ad82008-05-12 13:57:46 -0700153 struct pci_dev *dev;
154
Linus Torvalds1da177e2005-04-16 15:20:36 -0700155 pci_read_bridge_bases(b);
Gary Hadebb71ad82008-05-12 13:57:46 -0700156 list_for_each_entry(dev, &b->devices, bus_list)
157 pcibios_fixup_device_resources(dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700158}
159
Bernhard Kaindl8c4b2cf2006-02-18 01:36:55 -0800160/*
Matt Domsch6b4b78f2006-09-29 15:23:23 -0500161 * Only use DMI information to set this if nothing was passed
162 * on the kernel command line (which was parsed earlier).
163 */
164
Jeff Garzik18552562007-10-03 15:15:40 -0400165static int __devinit set_bf_sort(const struct dmi_system_id *d)
Matt Domsch6b4b78f2006-09-29 15:23:23 -0500166{
167 if (pci_bf_sort == pci_bf_sort_default) {
168 pci_bf_sort = pci_dmi_bf;
169 printk(KERN_INFO "PCI: %s detected, enabling pci=bfsort.\n", d->ident);
170 }
171 return 0;
172}
173
174/*
Bernhard Kaindl8c4b2cf2006-02-18 01:36:55 -0800175 * Enable renumbering of PCI bus# ranges to reach all PCI busses (Cardbus)
176 */
177#ifdef __i386__
Jeff Garzik18552562007-10-03 15:15:40 -0400178static int __devinit assign_all_busses(const struct dmi_system_id *d)
Bernhard Kaindl8c4b2cf2006-02-18 01:36:55 -0800179{
180 pci_probe |= PCI_ASSIGN_ALL_BUSSES;
181 printk(KERN_INFO "%s detected: enabling PCI bus# renumbering"
182 " (pci=assign-busses)\n", d->ident);
183 return 0;
184}
185#endif
186
Matt Domsch6b4b78f2006-09-29 15:23:23 -0500187static struct dmi_system_id __devinitdata pciprobe_dmi_table[] = {
188#ifdef __i386__
Bernhard Kaindl8c4b2cf2006-02-18 01:36:55 -0800189/*
190 * Laptops which need pci=assign-busses to see Cardbus cards
191 */
Bernhard Kaindl8c4b2cf2006-02-18 01:36:55 -0800192 {
193 .callback = assign_all_busses,
194 .ident = "Samsung X20 Laptop",
195 .matches = {
196 DMI_MATCH(DMI_SYS_VENDOR, "Samsung Electronics"),
197 DMI_MATCH(DMI_PRODUCT_NAME, "SX20S"),
198 },
199 },
200#endif /* __i386__ */
Matt Domsch6b4b78f2006-09-29 15:23:23 -0500201 {
202 .callback = set_bf_sort,
203 .ident = "Dell PowerEdge 1950",
204 .matches = {
205 DMI_MATCH(DMI_SYS_VENDOR, "Dell"),
206 DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge 1950"),
207 },
208 },
209 {
210 .callback = set_bf_sort,
211 .ident = "Dell PowerEdge 1955",
212 .matches = {
213 DMI_MATCH(DMI_SYS_VENDOR, "Dell"),
214 DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge 1955"),
215 },
216 },
217 {
218 .callback = set_bf_sort,
219 .ident = "Dell PowerEdge 2900",
220 .matches = {
221 DMI_MATCH(DMI_SYS_VENDOR, "Dell"),
222 DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge 2900"),
223 },
224 },
225 {
226 .callback = set_bf_sort,
227 .ident = "Dell PowerEdge 2950",
228 .matches = {
229 DMI_MATCH(DMI_SYS_VENDOR, "Dell"),
230 DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge 2950"),
231 },
232 },
Andy Gospodarekf52383d2007-02-05 16:36:10 -0800233 {
234 .callback = set_bf_sort,
Matt Domschf7a9dae2007-03-23 23:58:07 -0500235 .ident = "Dell PowerEdge R900",
236 .matches = {
237 DMI_MATCH(DMI_SYS_VENDOR, "Dell"),
238 DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge R900"),
239 },
240 },
241 {
242 .callback = set_bf_sort,
Andy Gospodarekf52383d2007-02-05 16:36:10 -0800243 .ident = "HP ProLiant BL20p G3",
244 .matches = {
245 DMI_MATCH(DMI_SYS_VENDOR, "HP"),
246 DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL20p G3"),
247 },
248 },
249 {
250 .callback = set_bf_sort,
251 .ident = "HP ProLiant BL20p G4",
252 .matches = {
253 DMI_MATCH(DMI_SYS_VENDOR, "HP"),
254 DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL20p G4"),
255 },
256 },
257 {
258 .callback = set_bf_sort,
259 .ident = "HP ProLiant BL30p G1",
260 .matches = {
261 DMI_MATCH(DMI_SYS_VENDOR, "HP"),
262 DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL30p G1"),
263 },
264 },
265 {
266 .callback = set_bf_sort,
267 .ident = "HP ProLiant BL25p G1",
268 .matches = {
269 DMI_MATCH(DMI_SYS_VENDOR, "HP"),
270 DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL25p G1"),
271 },
272 },
273 {
274 .callback = set_bf_sort,
275 .ident = "HP ProLiant BL35p G1",
276 .matches = {
277 DMI_MATCH(DMI_SYS_VENDOR, "HP"),
278 DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL35p G1"),
279 },
280 },
281 {
282 .callback = set_bf_sort,
283 .ident = "HP ProLiant BL45p G1",
284 .matches = {
285 DMI_MATCH(DMI_SYS_VENDOR, "HP"),
286 DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL45p G1"),
287 },
288 },
289 {
290 .callback = set_bf_sort,
291 .ident = "HP ProLiant BL45p G2",
292 .matches = {
293 DMI_MATCH(DMI_SYS_VENDOR, "HP"),
294 DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL45p G2"),
295 },
296 },
297 {
298 .callback = set_bf_sort,
299 .ident = "HP ProLiant BL460c G1",
300 .matches = {
301 DMI_MATCH(DMI_SYS_VENDOR, "HP"),
302 DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL460c G1"),
303 },
304 },
305 {
306 .callback = set_bf_sort,
307 .ident = "HP ProLiant BL465c G1",
308 .matches = {
309 DMI_MATCH(DMI_SYS_VENDOR, "HP"),
310 DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL465c G1"),
311 },
312 },
313 {
314 .callback = set_bf_sort,
315 .ident = "HP ProLiant BL480c G1",
316 .matches = {
317 DMI_MATCH(DMI_SYS_VENDOR, "HP"),
318 DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL480c G1"),
319 },
320 },
321 {
322 .callback = set_bf_sort,
323 .ident = "HP ProLiant BL685c G1",
324 .matches = {
325 DMI_MATCH(DMI_SYS_VENDOR, "HP"),
326 DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL685c G1"),
327 },
328 },
Michal Schmidt8f8ae1a2007-10-17 18:04:35 +0200329 {
330 .callback = set_bf_sort,
Tony Camuso8d64c782008-05-15 14:40:14 -0400331 .ident = "HP ProLiant DL360",
Michal Schmidt8f8ae1a2007-10-17 18:04:35 +0200332 .matches = {
333 DMI_MATCH(DMI_SYS_VENDOR, "HP"),
Tony Camuso8d64c782008-05-15 14:40:14 -0400334 DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant DL360"),
Michal Schmidt8f8ae1a2007-10-17 18:04:35 +0200335 },
336 },
337 {
338 .callback = set_bf_sort,
Tony Camuso8d64c782008-05-15 14:40:14 -0400339 .ident = "HP ProLiant DL380",
Michal Schmidt8f8ae1a2007-10-17 18:04:35 +0200340 .matches = {
341 DMI_MATCH(DMI_SYS_VENDOR, "HP"),
Tony Camuso8d64c782008-05-15 14:40:14 -0400342 DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant DL380"),
Michal Schmidt8f8ae1a2007-10-17 18:04:35 +0200343 },
344 },
Juha Laiho5b1ea822007-09-13 21:21:34 +0300345#ifdef __i386__
346 {
347 .callback = assign_all_busses,
348 .ident = "Compaq EVO N800c",
349 .matches = {
350 DMI_MATCH(DMI_SYS_VENDOR, "Compaq"),
351 DMI_MATCH(DMI_PRODUCT_NAME, "EVO N800c"),
352 },
353 },
354#endif
Michal Schmidtc82bc5a2007-11-26 20:42:19 +0100355 {
356 .callback = set_bf_sort,
Jesse Barnes739db072008-07-07 09:55:26 -0700357 .ident = "HP ProLiant DL385 G2",
Michal Schmidtc82bc5a2007-11-26 20:42:19 +0100358 .matches = {
359 DMI_MATCH(DMI_SYS_VENDOR, "HP"),
Jesse Barnes739db072008-07-07 09:55:26 -0700360 DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant DL385 G2"),
Michal Schmidtc82bc5a2007-11-26 20:42:19 +0100361 },
362 },
363 {
364 .callback = set_bf_sort,
Jesse Barnes739db072008-07-07 09:55:26 -0700365 .ident = "HP ProLiant DL585 G2",
Michal Schmidtc82bc5a2007-11-26 20:42:19 +0100366 .matches = {
367 DMI_MATCH(DMI_SYS_VENDOR, "HP"),
Jesse Barnes739db072008-07-07 09:55:26 -0700368 DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant DL585 G2"),
Michal Schmidtc82bc5a2007-11-26 20:42:19 +0100369 },
370 },
Bernhard Kaindl8c4b2cf2006-02-18 01:36:55 -0800371 {}
372};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700373
Yinghai Lu0df18ff2008-04-14 15:40:37 -0700374void __init dmi_check_pciprobe(void)
375{
376 dmi_check_system(pciprobe_dmi_table);
377}
378
Linus Torvalds1da177e2005-04-16 15:20:36 -0700379struct pci_bus * __devinit pcibios_scan_root(int busnum)
380{
381 struct pci_bus *bus = NULL;
Muli Ben-Yehuda08f1c192007-07-22 00:23:39 +0300382 struct pci_sysdata *sd;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700383
384 while ((bus = pci_find_next_bus(bus)) != NULL) {
385 if (bus->number == busnum) {
386 /* Already scanned */
387 return bus;
388 }
389 }
390
Muli Ben-Yehuda08f1c192007-07-22 00:23:39 +0300391 /* Allocate per-root-bus (not per bus) arch-specific data.
392 * TODO: leak; this memory is never freed.
393 * It's arguable whether it's worth the trouble to care.
394 */
395 sd = kzalloc(sizeof(*sd), GFP_KERNEL);
396 if (!sd) {
397 printk(KERN_ERR "PCI: OOM, not probing PCI bus %02x\n", busnum);
398 return NULL;
399 }
400
Yinghai Lu871d5f82008-02-19 03:20:09 -0800401 sd->node = get_mp_bus_to_node(busnum);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700402
Yinghai Lu871d5f82008-02-19 03:20:09 -0800403 printk(KERN_DEBUG "PCI: Probing PCI hardware (bus %02x)\n", busnum);
404 bus = pci_scan_bus_parented(NULL, busnum, &pci_root_ops, sd);
405 if (!bus)
406 kfree(sd);
407
408 return bus;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700409}
410
411extern u8 pci_cache_line_size;
412
Robert Richter8dd779b2008-07-02 22:50:29 +0200413int __init pcibios_init(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700414{
415 struct cpuinfo_x86 *c = &boot_cpu_data;
416
417 if (!raw_pci_ops) {
Daniel Marjamäkiadcb89072005-11-23 15:44:49 -0800418 printk(KERN_WARNING "PCI: System does not support PCI\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700419 return 0;
420 }
421
422 /*
423 * Assume PCI cacheline size of 32 bytes for all x86s except K7/K8
424 * and P4. It's also good for 386/486s (which actually have 16)
425 * as quite a few PCI devices do not support smaller values.
426 */
427 pci_cache_line_size = 32 >> 2;
428 if (c->x86 >= 6 && c->x86_vendor == X86_VENDOR_AMD)
429 pci_cache_line_size = 64 >> 2; /* K7 & K8 */
430 else if (c->x86 > 6 && c->x86_vendor == X86_VENDOR_INTEL)
431 pci_cache_line_size = 128 >> 2; /* P4 */
432
433 pcibios_resource_survey();
434
Matt Domsch6b4b78f2006-09-29 15:23:23 -0500435 if (pci_bf_sort >= pci_force_bf)
436 pci_sort_breadthfirst();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700437 return 0;
438}
439
Linus Torvalds1da177e2005-04-16 15:20:36 -0700440char * __devinit pcibios_setup(char *str)
441{
442 if (!strcmp(str, "off")) {
443 pci_probe = 0;
444 return NULL;
Matt Domsch6b4b78f2006-09-29 15:23:23 -0500445 } else if (!strcmp(str, "bfsort")) {
446 pci_bf_sort = pci_force_bf;
447 return NULL;
448 } else if (!strcmp(str, "nobfsort")) {
449 pci_bf_sort = pci_force_nobf;
450 return NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700451 }
452#ifdef CONFIG_PCI_BIOS
453 else if (!strcmp(str, "bios")) {
454 pci_probe = PCI_PROBE_BIOS;
455 return NULL;
456 } else if (!strcmp(str, "nobios")) {
457 pci_probe &= ~PCI_PROBE_BIOS;
458 return NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700459 } else if (!strcmp(str, "biosirq")) {
460 pci_probe |= PCI_BIOS_IRQ_SCAN;
461 return NULL;
jayalk@intworks.biz120bb422005-03-21 20:20:42 -0800462 } else if (!strncmp(str, "pirqaddr=", 9)) {
463 pirq_table_addr = simple_strtoul(str+9, NULL, 0);
464 return NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700465 }
466#endif
467#ifdef CONFIG_PCI_DIRECT
468 else if (!strcmp(str, "conf1")) {
469 pci_probe = PCI_PROBE_CONF1 | PCI_NO_CHECKS;
470 return NULL;
471 }
472 else if (!strcmp(str, "conf2")) {
473 pci_probe = PCI_PROBE_CONF2 | PCI_NO_CHECKS;
474 return NULL;
475 }
476#endif
477#ifdef CONFIG_PCI_MMCONFIG
478 else if (!strcmp(str, "nommconf")) {
479 pci_probe &= ~PCI_PROBE_MMCONF;
480 return NULL;
481 }
Yinghai Lu5f0b2972008-04-14 16:08:25 -0700482 else if (!strcmp(str, "check_enable_amd_mmconf")) {
483 pci_probe |= PCI_CHECK_ENABLE_AMD_MMCONF;
484 return NULL;
485 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700486#endif
487 else if (!strcmp(str, "noacpi")) {
488 acpi_noirq_set();
489 return NULL;
490 }
Andi Kleen0637a702006-09-26 10:52:41 +0200491 else if (!strcmp(str, "noearly")) {
492 pci_probe |= PCI_PROBE_NOEARLY;
493 return NULL;
494 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700495#ifndef CONFIG_X86_VISWS
496 else if (!strcmp(str, "usepirqmask")) {
497 pci_probe |= PCI_USE_PIRQ_MASK;
498 return NULL;
499 } else if (!strncmp(str, "irqmask=", 8)) {
500 pcibios_irq_mask = simple_strtol(str+8, NULL, 0);
501 return NULL;
502 } else if (!strncmp(str, "lastbus=", 8)) {
503 pcibios_last_bus = simple_strtol(str+8, NULL, 0);
504 return NULL;
505 }
506#endif
507 else if (!strcmp(str, "rom")) {
508 pci_probe |= PCI_ASSIGN_ROMS;
509 return NULL;
Gary Hadebb71ad82008-05-12 13:57:46 -0700510 } else if (!strcmp(str, "norom")) {
511 pci_probe |= PCI_NOASSIGN_ROMS;
512 return NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700513 } else if (!strcmp(str, "assign-busses")) {
514 pci_probe |= PCI_ASSIGN_ALL_BUSSES;
515 return NULL;
Gary Hade62f420f2007-10-03 15:56:51 -0700516 } else if (!strcmp(str, "use_crs")) {
517 pci_probe |= PCI_USE__CRS;
518 return NULL;
Yinghai Lue3f2bae2008-05-22 14:35:11 -0700519 } else if (!strcmp(str, "earlydump")) {
520 pci_early_dump_regs = 1;
521 return NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700522 } else if (!strcmp(str, "routeirq")) {
523 pci_routeirq = 1;
524 return NULL;
Yinghai Lu13a6ddb2008-03-27 01:31:18 -0700525 } else if (!strcmp(str, "skip_isa_align")) {
526 pci_probe |= PCI_CAN_SKIP_ISA_ALIGN;
527 return NULL;
Stefan Assmanna9322f62008-06-11 16:35:14 +0200528 } else if (!strcmp(str, "noioapicquirk")) {
529 noioapicquirk = 1;
530 return NULL;
Stefan Assmann91979792008-06-11 16:35:15 +0200531 } else if (!strcmp(str, "ioapicreroute")) {
532 if (noioapicreroute != -1)
533 noioapicreroute = 0;
534 return NULL;
Stefan Assmann41b9eb22008-07-15 13:48:55 +0200535 } else if (!strcmp(str, "noioapicreroute")) {
536 if (noioapicreroute != -1)
537 noioapicreroute = 1;
538 return NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700539 }
540 return str;
541}
542
543unsigned int pcibios_assign_all_busses(void)
544{
545 return (pci_probe & PCI_ASSIGN_ALL_BUSSES) ? 1 : 0;
546}
547
548int pcibios_enable_device(struct pci_dev *dev, int mask)
549{
550 int err;
551
Bjorn Helgaasb81d9882008-03-04 11:57:01 -0700552 if ((err = pci_enable_resources(dev, mask)) < 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700553 return err;
554
Eric W. Biedermanbba6f6f2007-03-28 15:36:09 +0200555 if (!dev->msi_enabled)
556 return pcibios_enable_irq(dev);
557 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700558}
David Shaohua Li87bec662005-07-27 23:02:00 -0400559
560void pcibios_disable_device (struct pci_dev *dev)
561{
Eric W. Biedermanbba6f6f2007-03-28 15:36:09 +0200562 if (!dev->msi_enabled && pcibios_disable_irq)
David Shaohua Li87bec662005-07-27 23:02:00 -0400563 pcibios_disable_irq(dev);
564}
Muli Ben-Yehuda73c59af2007-08-10 13:01:19 -0700565
Sam Ravnborg98db6f12008-04-29 22:38:48 +0200566struct pci_bus * __devinit pci_scan_bus_on_node(int busno, struct pci_ops *ops, int node)
Muli Ben-Yehuda73c59af2007-08-10 13:01:19 -0700567{
568 struct pci_bus *bus = NULL;
569 struct pci_sysdata *sd;
570
571 /*
572 * Allocate per-root-bus (not per bus) arch-specific data.
573 * TODO: leak; this memory is never freed.
574 * It's arguable whether it's worth the trouble to care.
575 */
576 sd = kzalloc(sizeof(*sd), GFP_KERNEL);
577 if (!sd) {
578 printk(KERN_ERR "PCI: OOM, skipping PCI bus %02x\n", busno);
579 return NULL;
580 }
Yinghai Lu871d5f82008-02-19 03:20:09 -0800581 sd->node = node;
582 bus = pci_scan_bus(busno, ops, sd);
Muli Ben-Yehuda73c59af2007-08-10 13:01:19 -0700583 if (!bus)
584 kfree(sd);
585
586 return bus;
587}
Yinghai Lu871d5f82008-02-19 03:20:09 -0800588
Sam Ravnborg98db6f12008-04-29 22:38:48 +0200589struct pci_bus * __devinit pci_scan_bus_with_sysdata(int busno)
Yinghai Lu871d5f82008-02-19 03:20:09 -0800590{
591 return pci_scan_bus_on_node(busno, &pci_root_ops, -1);
592}