1 /*
2  *	Low-Level PCI Support for PC
3  *
4  *	(c) 1999--2000 Martin Mares <mj@ucw.cz>
5  * 	2001 Andi Kleen. Cleanup for x86-64. Removed PCI-BIOS access and fixups
6  *	for hardware that is unlikely to exist on any Hammer platform.
7  *
8  * 	On x86-64 we don't have any access to the PCI-BIOS in long mode, so we
9  *	cannot sort the pci device table based on what the BIOS did. This might
10  *	change the probing order of some devices compared to an i386 kernel.
11  * 	May need to use ACPI to fix this.
12  */
13 
14 #include <linux/config.h>
15 #include <linux/types.h>
16 #include <linux/kernel.h>
17 #include <linux/sched.h>
18 #include <linux/pci.h>
19 #include <linux/init.h>
20 #include <linux/ioport.h>
21 #include <linux/acpi.h>
22 
23 #include <asm/segment.h>
24 #include <asm/io.h>
25 #include <asm/mpspec.h>
26 #include <asm/proto.h>
27 
28 #include "pci-x86_64.h"
29 
30 unsigned int pci_probe = PCI_PROBE_CONF1 | PCI_PROBE_CONF2;
31 
32 int pcibios_last_bus = -1;
33 struct pci_bus *pci_root_bus;
34 struct pci_ops *pci_root_ops;
35 
36 int (*pci_config_read)(int seg, int bus, int dev, int fn, int reg, int len, u32 *value) = NULL;
37 int (*pci_config_write)(int seg, int bus, int dev, int fn, int reg, int len, u32 value) = NULL;
38 
39 static int pci_using_acpi_prt = 0;
40 
41 /* XXX: not taken by all accesses currently */
42 static spinlock_t pci_config_lock = SPIN_LOCK_UNLOCKED;
43 
44 /*
45  * Direct access to PCI hardware...
46  */
47 
48 #ifdef CONFIG_PCI_DIRECT
49 
50 /*
51  * Functions for accessing PCI configuration space with type 1 accesses
52  */
53 
54 #define CONFIG_CMD(dev, where)   (0x80000000 | (dev->bus->number << 16) | (dev->devfn << 8) | (where & ~3))
55 
56 #define PCI_CONF1_ADDRESS(bus, dev, fn, reg) \
57 	(0x80000000 | (bus << 16) | (dev << 11) | (fn << 8) | (reg & ~3))
58 
pci_conf1_read(int seg,int bus,int dev,int fn,int reg,int len,u32 * value)59 static int pci_conf1_read (int seg, int bus, int dev, int fn, int reg, int len,
60 			   u32 *value)
61 {
62 	unsigned long flags;
63 
64 	if (!value || (bus > 255) || (dev > 31) || (fn > 7) || (reg > 255))
65 		return -EINVAL;
66 
67 	spin_lock_irqsave(&pci_config_lock, flags);
68 
69 	outl(PCI_CONF1_ADDRESS(bus, dev, fn, reg), 0xCF8);
70 
71 	switch (len) {
72 	case 1:
73 		*value = inb(0xCFC + (reg & 3));
74 		break;
75 	case 2:
76 		*value = inw(0xCFC + (reg & 2));
77 		break;
78 	case 4:
79 		*value = inl(0xCFC);
80 		break;
81 	}
82 
83 	spin_unlock_irqrestore(&pci_config_lock, flags);
84 
85 	return 0;
86 }
87 
pci_conf1_write(int seg,int bus,int dev,int fn,int reg,int len,u32 value)88 static int pci_conf1_write (int seg, int bus, int dev, int fn, int reg, int len, u32 value)
89 {
90 	unsigned long flags;
91 
92 	if ((bus > 255) || (dev > 31) || (fn > 7) || (reg > 255))
93 		return -EINVAL;
94 
95 	spin_lock_irqsave(&pci_config_lock, flags);
96 
97 	outl(PCI_CONF1_ADDRESS(bus, dev, fn, reg), 0xCF8);
98 
99 	switch (len) {
100 	case 1:
101 		outb((u8)value, 0xCFC + (reg & 3));
102 		break;
103 	case 2:
104 		outw((u16)value, 0xCFC + (reg & 2));
105 		break;
106 	case 4:
107 		outl((u32)value, 0xCFC);
108 		break;
109 	}
110 
111 	spin_unlock_irqrestore(&pci_config_lock, flags);
112 
113 	return 0;
114 }
115 
pci_conf1_read_config_byte(struct pci_dev * dev,int where,u8 * value)116 static int pci_conf1_read_config_byte(struct pci_dev *dev, int where, u8 *value)
117 {
118 	int result;
119 	u32 data;
120 
121 	if (!value)
122 		return -EINVAL;
123 
124 	result = pci_conf1_read(0, dev->bus->number, PCI_SLOT(dev->devfn),
125 		 		PCI_FUNC(dev->devfn), where, 1, &data);
126 
127 	*value = (u8)data;
128 
129 	return result;
130 }
131 
pci_conf1_read_config_word(struct pci_dev * dev,int where,u16 * value)132 static int pci_conf1_read_config_word(struct pci_dev *dev, int where, u16 *value)
133 {
134 	int result;
135 	u32 data;
136 
137 	if (!value)
138 		return -EINVAL;
139 
140 	result = pci_conf1_read(0, dev->bus->number, PCI_SLOT(dev->devfn),
141 		 		PCI_FUNC(dev->devfn), where, 2, &data);
142 
143 	*value = (u16)data;
144 
145 	return result;
146 }
147 
pci_conf1_read_config_dword(struct pci_dev * dev,int where,u32 * value)148 static int pci_conf1_read_config_dword(struct pci_dev *dev, int where, u32 *value)
149 {
150 	return pci_conf1_read(0, dev->bus->number, PCI_SLOT(dev->devfn),
151 			      PCI_FUNC(dev->devfn), where, 4, value);
152 
153 }
154 
pci_conf1_write_config_byte(struct pci_dev * dev,int where,u8 value)155 static int pci_conf1_write_config_byte(struct pci_dev *dev, int where, u8 value)
156 {
157 	return pci_conf1_write(0, dev->bus->number, PCI_SLOT(dev->devfn),
158 			       PCI_FUNC(dev->devfn), where, 1, value);
159 }
160 
pci_conf1_write_config_word(struct pci_dev * dev,int where,u16 value)161 static int pci_conf1_write_config_word(struct pci_dev *dev, int where, u16 value)
162 {
163 	return pci_conf1_write(0, dev->bus->number, PCI_SLOT(dev->devfn),
164 			       PCI_FUNC(dev->devfn), where, 2, value);
165 }
166 
pci_conf1_write_config_dword(struct pci_dev * dev,int where,u32 value)167 static int pci_conf1_write_config_dword(struct pci_dev *dev, int where, u32 value)
168 {
169 	return pci_conf1_write(0, dev->bus->number, PCI_SLOT(dev->devfn),
170 			       PCI_FUNC(dev->devfn), where, 4, value);
171 }
172 
173 #undef CONFIG_CMD
174 
175 static struct pci_ops pci_direct_conf1 = {
176 	pci_conf1_read_config_byte,
177 	pci_conf1_read_config_word,
178 	pci_conf1_read_config_dword,
179 	pci_conf1_write_config_byte,
180 	pci_conf1_write_config_word,
181 	pci_conf1_write_config_dword
182 };
183 
184 /*
185  * Functions for accessing PCI configuration space with type 2 accesses
186  */
187 
188 #define IOADDR(devfn, where)	((0xC000 | ((devfn & 0x78) << 5)) + where)
189 #define FUNC(devfn)		(((devfn & 7) << 1) | 0xf0)
190 #define SET(dev)		if (dev->devfn & 0x80) return PCIBIOS_DEVICE_NOT_FOUND;		\
191 				outb(FUNC(dev->devfn), 0xCF8);					\
192 				outb(dev->bus->number, 0xCFA);
193 
194 #define PCI_CONF2_ADDRESS(dev, reg)	(u16)(0xC000 | (dev << 8) | reg)
195 
pci_conf2_read(int seg,int bus,int dev,int fn,int reg,int len,u32 * value)196 static int pci_conf2_read (int seg, int bus, int dev, int fn, int reg, int len, u32 *value)
197 {
198 	unsigned long flags;
199 
200 	if (!value || (bus > 255) || (dev > 31) || (fn > 7) || (reg > 255))
201 		return -EINVAL;
202 
203 	if (dev & 0x10)
204 		return PCIBIOS_DEVICE_NOT_FOUND;
205 
206 	spin_lock_irqsave(&pci_config_lock, flags);
207 
208 	outb((u8)(0xF0 | (fn << 1)), 0xCF8);
209 	outb((u8)bus, 0xCFA);
210 
211 	switch (len) {
212 	case 1:
213 		*value = inb(PCI_CONF2_ADDRESS(dev, reg));
214 		break;
215 	case 2:
216 		*value = inw(PCI_CONF2_ADDRESS(dev, reg));
217 		break;
218 	case 4:
219 		*value = inl(PCI_CONF2_ADDRESS(dev, reg));
220 		break;
221 	}
222 
223 	outb (0, 0xCF8);
224 
225 	spin_unlock_irqrestore(&pci_config_lock, flags);
226 
227 	return 0;
228 }
229 
pci_conf2_write(int seg,int bus,int dev,int fn,int reg,int len,u32 value)230 static int pci_conf2_write (int seg, int bus, int dev, int fn, int reg, int len, u32 value)
231 {
232 	unsigned long flags;
233 
234 	if ((bus > 255) || (dev > 31) || (fn > 7) || (reg > 255))
235 		return -EINVAL;
236 
237 	if (dev & 0x10)
238 		return PCIBIOS_DEVICE_NOT_FOUND;
239 
240 	spin_lock_irqsave(&pci_config_lock, flags);
241 
242 	outb((u8)(0xF0 | (fn << 1)), 0xCF8);
243 	outb((u8)bus, 0xCFA);
244 
245 	switch (len) {
246 	case 1:
247 		outb ((u8)value, PCI_CONF2_ADDRESS(dev, reg));
248 		break;
249 	case 2:
250 		outw ((u16)value, PCI_CONF2_ADDRESS(dev, reg));
251 		break;
252 	case 4:
253 		outl ((u32)value, PCI_CONF2_ADDRESS(dev, reg));
254 		break;
255 	}
256 
257 	outb (0, 0xCF8);
258 
259 	spin_unlock_irqrestore(&pci_config_lock, flags);
260 
261 	return 0;
262 }
263 
pci_conf2_read_config_byte(struct pci_dev * dev,int where,u8 * value)264 static int pci_conf2_read_config_byte(struct pci_dev *dev, int where, u8 *value)
265 {
266 	int result;
267 	u32 data;
268 
269 	if (!value)
270 		return -EINVAL;
271 
272 	result = pci_conf2_read(0, dev->bus->number, PCI_SLOT(dev->devfn),
273 				PCI_FUNC(dev->devfn), where, 1, &data);
274 
275 	*value = (u8)data;
276 
277 	return result;
278 }
279 
pci_conf2_read_config_word(struct pci_dev * dev,int where,u16 * value)280 static int pci_conf2_read_config_word(struct pci_dev *dev, int where, u16 *value)
281 {
282 	int result;
283 	u32 data;
284 
285 	if (!value)
286 		return -EINVAL;
287 
288 	result = pci_conf2_read(0, dev->bus->number, PCI_SLOT(dev->devfn),
289 				PCI_FUNC(dev->devfn), where, 2, &data);
290 
291 	*value = (u16)data;
292 
293 	return result;
294 }
295 
pci_conf2_read_config_dword(struct pci_dev * dev,int where,u32 * value)296 static int pci_conf2_read_config_dword(struct pci_dev *dev, int where, u32 *value)
297 {
298 	return pci_conf2_read(0, dev->bus->number, PCI_SLOT(dev->devfn),
299 			      PCI_FUNC(dev->devfn), where, 4, value);
300 }
301 
pci_conf2_write_config_byte(struct pci_dev * dev,int where,u8 value)302 static int pci_conf2_write_config_byte(struct pci_dev *dev, int where, u8 value)
303 {
304 	return pci_conf2_write(0, dev->bus->number, PCI_SLOT(dev->devfn),
305 			       PCI_FUNC(dev->devfn), where, 1, value);
306 }
307 
pci_conf2_write_config_word(struct pci_dev * dev,int where,u16 value)308 static int pci_conf2_write_config_word(struct pci_dev *dev, int where, u16 value)
309 {
310 	return pci_conf2_write(0, dev->bus->number, PCI_SLOT(dev->devfn),
311 			       PCI_FUNC(dev->devfn), where, 2, value);
312 }
313 
pci_conf2_write_config_dword(struct pci_dev * dev,int where,u32 value)314 static int pci_conf2_write_config_dword(struct pci_dev *dev, int where, u32 value)
315 {
316 	return pci_conf2_write(0, dev->bus->number, PCI_SLOT(dev->devfn),
317 			       PCI_FUNC(dev->devfn), where, 4, value);
318 }
319 
320 #undef SET
321 #undef IOADDR
322 #undef FUNC
323 
324 static struct pci_ops pci_direct_conf2 = {
325 	pci_conf2_read_config_byte,
326 	pci_conf2_read_config_word,
327 	pci_conf2_read_config_dword,
328 	pci_conf2_write_config_byte,
329 	pci_conf2_write_config_word,
330 	pci_conf2_write_config_dword
331 };
332 
333 /*
334  * Before we decide to use direct hardware access mechanisms, we try to do some
335  * trivial checks to ensure it at least _seems_ to be working -- we just test
336  * whether bus 00 contains a host bridge (this is similar to checking
337  * techniques used in XFree86, but ours should be more reliable since we
338  * attempt to make use of direct access hints provided by the PCI BIOS).
339  *
340  * This should be close to trivial, but it isn't, because there are buggy
341  * chipsets (yes, you guessed it, by Intel and Compaq) that have no class ID.
342  */
pci_sanity_check(struct pci_ops * o)343 static int __devinit pci_sanity_check(struct pci_ops *o)
344 {
345 	u16 x;
346 	struct pci_bus bus;		/* Fake bus and device */
347 	struct pci_dev dev;
348 
349 	if (pci_probe & PCI_NO_CHECKS)
350 		return 1;
351 	bus.number = 0;
352 	dev.bus = &bus;
353 	for(dev.devfn=0; dev.devfn < 0x100; dev.devfn++)
354 		if ((!o->read_word(&dev, PCI_CLASS_DEVICE, &x) &&
355 		     (x == PCI_CLASS_BRIDGE_HOST || x == PCI_CLASS_DISPLAY_VGA)) ||
356 		    (!o->read_word(&dev, PCI_VENDOR_ID, &x) &&
357 		     (x == PCI_VENDOR_ID_INTEL || x == PCI_VENDOR_ID_COMPAQ)))
358 			return 1;
359 	DBG("PCI: Sanity check failed\n");
360 	return 0;
361 }
362 
pci_check_direct(void)363 static struct pci_ops * __devinit pci_check_direct(void)
364 {
365 	unsigned int tmp;
366 	unsigned long flags;
367 
368 	__save_flags(flags); __cli();
369 
370 	/*
371 	 * Check if configuration type 1 works.
372 	 */
373 	if (pci_probe & PCI_PROBE_CONF1) {
374 		outb (0x01, 0xCFB);
375 		tmp = inl (0xCF8);
376 		outl (0x80000000, 0xCF8);
377 		if (inl (0xCF8) == 0x80000000 &&
378 		    pci_sanity_check(&pci_direct_conf1)) {
379 			outl (tmp, 0xCF8);
380 			__restore_flags(flags);
381 			printk(KERN_INFO "PCI: Using configuration type 1\n");
382 			request_region(0xCF8, 8, "PCI conf1");
383 			return &pci_direct_conf1;
384 		}
385 		outl (tmp, 0xCF8);
386 	}
387 
388 	/*
389 	 * Check if configuration type 2 works.
390 	 */
391 	if (pci_probe & PCI_PROBE_CONF2) {
392 		outb (0x00, 0xCFB);
393 		outb (0x00, 0xCF8);
394 		outb (0x00, 0xCFA);
395 		if (inb (0xCF8) == 0x00 && inb (0xCFA) == 0x00 &&
396 		    pci_sanity_check(&pci_direct_conf2)) {
397 			__restore_flags(flags);
398 			printk(KERN_INFO "PCI: Using configuration type 2\n");
399 			request_region(0xCF8, 4, "PCI conf2");
400 			return &pci_direct_conf2;
401 		}
402 	}
403 
404 	__restore_flags(flags);
405 	return NULL;
406 }
407 
408 #endif
409 
pcibios_scan_root(int busnum)410 struct pci_bus * __devinit pcibios_scan_root(int busnum)
411 {
412 	struct list_head *list;
413 	struct pci_bus *bus;
414 
415 	list_for_each(list, &pci_root_buses) {
416 		bus = pci_bus_b(list);
417 		if (bus->number == busnum) {
418 			/* Already scanned */
419 			return bus;
420 		}
421 	}
422 
423 	printk("PCI: Probing PCI hardware (bus %02x)\n", busnum);
424 
425 	return pci_scan_bus(busnum, pci_root_ops, NULL);
426 }
427 
428 /*
429  * Several buggy motherboards address only 16 devices and mirror
430  * them to next 16 IDs. We try to detect this `feature' on all
431  * primary buses (those containing host bridges as they are
432  * expected to be unique) and remove the ghost devices.
433  */
434 
pcibios_fixup_ghosts(struct pci_bus * b)435 static void __devinit pcibios_fixup_ghosts(struct pci_bus *b)
436 {
437 	struct list_head *ln, *mn;
438 	struct pci_dev *d, *e;
439 	int mirror = PCI_DEVFN(16,0);
440 	int seen_host_bridge = 0;
441 	int i;
442 
443 	DBG("PCI: Scanning for ghost devices on bus %d\n", b->number);
444 	for (ln=b->devices.next; ln != &b->devices; ln=ln->next) {
445 		d = pci_dev_b(ln);
446 		if ((d->class >> 8) == PCI_CLASS_BRIDGE_HOST)
447 			seen_host_bridge++;
448 		for (mn=ln->next; mn != &b->devices; mn=mn->next) {
449 			e = pci_dev_b(mn);
450 			if (e->devfn != d->devfn + mirror ||
451 			    e->vendor != d->vendor ||
452 			    e->device != d->device ||
453 			    e->class != d->class)
454 				continue;
455 			for(i=0; i<PCI_NUM_RESOURCES; i++)
456 				if (e->resource[i].start != d->resource[i].start ||
457 				    e->resource[i].end != d->resource[i].end ||
458 				    e->resource[i].flags != d->resource[i].flags)
459 					continue;
460 			break;
461 		}
462 		if (mn == &b->devices)
463 			return;
464 	}
465 	if (!seen_host_bridge)
466 		return;
467 	printk(KERN_INFO "PCI: Ignoring ghost devices on bus %02x\n", b->number);
468 
469 	ln = &b->devices;
470 	while (ln->next != &b->devices) {
471 		d = pci_dev_b(ln->next);
472 		if (d->devfn >= mirror) {
473 			list_del(&d->global_list);
474 			list_del(&d->bus_list);
475 			kfree(d);
476 		} else
477 			ln = ln->next;
478 	}
479 }
480 
481 /*
482  * Discover remaining PCI buses in case there are peer host bridges.
483  */
pcibios_fixup_peer_bridges(void)484 static void __devinit pcibios_fixup_peer_bridges(void)
485 {
486 	int n;
487 	struct pci_bus bus;
488 	struct pci_dev dev;
489 	u16 l;
490 
491 	if (pcibios_last_bus <= 0 || pcibios_last_bus >= 0xff)
492 		return;
493 	DBG("PCI: Peer bridge fixup\n");
494 	for (n=0; n <= pcibios_last_bus; n++) {
495 		if (pci_bus_exists(&pci_root_buses, n))
496 			continue;
497 		bus.number = n;
498 		bus.ops = pci_root_ops;
499 		dev.bus = &bus;
500 		for(dev.devfn=0; dev.devfn<256; dev.devfn += 8)
501 			if (!pci_read_config_word(&dev, PCI_VENDOR_ID, &l) &&
502 			    l != 0x0000 && l != 0xffff) {
503 				DBG("Found device at %02x:%02x [%04x]\n", n, dev.devfn, l);
504 				printk(KERN_INFO "PCI: Discovered peer bus %02x\n", n);
505 				pci_scan_bus(n, pci_root_ops, NULL);
506 				break;
507 			}
508 	}
509 }
510 
pci_scan_mptable(void)511 static void __devinit pci_scan_mptable(void)
512 {
513 	int i;
514 
515 	/* Handle ACPI here */
516 	if (!smp_found_config) {
517 		printk(KERN_WARNING "PCI: Warning: no mptable. Scanning busses upto 0xff\n");
518 		pcibios_last_bus = 0xff;
519 		return;
520 	}
521 
522 	pcibios_last_bus = 0xff;
523 
524 	for (i = 0; i < MAX_MP_BUSSES; i++) {
525 		int n = mp_bus_id_to_pci_bus[i];
526 		if (n < 0 || n >= 0xff)
527 			continue;
528 		if (pci_bus_exists(&pci_root_buses, n))
529 			continue;
530 		printk(KERN_INFO "PCI: Scanning bus %02x from mptable\n", n);
531 		pci_scan_bus(n, pci_root_ops, NULL);
532 	}
533 }
534 
pci_fixup_ide_bases(struct pci_dev * d)535 static void __devinit pci_fixup_ide_bases(struct pci_dev *d)
536 {
537 	int i;
538 
539 	/*
540 	 * PCI IDE controllers use non-standard I/O port decoding, respect it.
541 	 */
542 	if ((d->class >> 8) != PCI_CLASS_STORAGE_IDE)
543 		return;
544 	DBG("PCI: IDE base address fixup for %s\n", d->slot_name);
545 	for(i=0; i<4; i++) {
546 		struct resource *r = &d->resource[i];
547 		if ((r->start & ~0x80) == 0x374) {
548 			r->start |= 2;
549 			r->end = r->start;
550 		}
551 	}
552 }
553 
554 struct pci_fixup pcibios_fixups[] = {
555 	{ PCI_FIXUP_HEADER, PCI_ANY_ID,	PCI_ANY_ID, pci_fixup_ide_bases },
556 	{ 0 }
557 };
558 
559 /*
560  *  Called after each bus is probed, but before its children
561  *  are examined.
562  */
563 
pcibios_fixup_bus(struct pci_bus * b)564 void __devinit pcibios_fixup_bus(struct pci_bus *b)
565 {
566 	pcibios_fixup_ghosts(b);
567 	pci_read_bridge_bases(b);
568 }
569 
pcibios_config_init(void)570 void __devinit pcibios_config_init(void)
571 {
572 	/*
573 	 * Try all known PCI access methods. Note that we support using
574 	 * both PCI BIOS and direct access, with a preference for direct.
575 	 */
576 
577 #ifdef CONFIG_PCI_DIRECT
578 	if ((pci_probe & (PCI_PROBE_CONF1 | PCI_PROBE_CONF2))
579 		&& (pci_root_ops = pci_check_direct())) {
580 		if (pci_root_ops == &pci_direct_conf1) {
581 			pci_config_read = pci_conf1_read;
582 			pci_config_write = pci_conf1_write;
583 		}
584 		else {
585 			pci_config_read = pci_conf2_read;
586 			pci_config_write = pci_conf2_write;
587 		}
588 	} else
589 		printk("??? no pci access\n");
590 #endif
591 
592 	return;
593 }
594 
pcibios_init(void)595 void __devinit pcibios_init(void)
596 {
597 	struct pci_ops *dir = NULL;
598 
599 	if (!pci_root_ops)
600 		pcibios_config_init();
601 
602 #ifdef CONFIG_PCI_DIRECT
603 	if (pci_probe & (PCI_PROBE_CONF1 | PCI_PROBE_CONF2))
604 		dir = pci_check_direct();
605 #endif
606 	if (dir)
607 		pci_root_ops = dir;
608 	else {
609 		printk(KERN_INFO "PCI: No PCI bus detected\n");
610 		return;
611 	}
612 
613 	printk(KERN_INFO "PCI: Probing PCI hardware\n");
614 #ifdef CONFIG_ACPI_PCI
615  	if (!acpi_disabled && !acpi_noirq && !acpi_pci_irq_init())
616  		pci_using_acpi_prt = 1;
617 #endif
618  	if (!pci_using_acpi_prt) {
619  		pci_root_bus = pcibios_scan_root(0);
620 	pcibios_irq_init();
621 	pci_scan_mptable();
622 	pcibios_fixup_peer_bridges();
623 	pcibios_fixup_irqs();
624  	}
625 
626 	pcibios_resource_survey();
627 
628 #ifdef CONFIG_GART_IOMMU
629 	pci_iommu_init();
630 #endif
631 }
632 
pcibios_setup(char * str)633 char * __devinit pcibios_setup(char *str)
634 {
635 	if (!strcmp(str, "off")) {
636 		pci_probe = 0;
637 		return NULL;
638 	}
639 	else if (!strncmp(str, "bios", 4)) {
640 		printk(KERN_WARNING "PCI: No PCI bios access on x86-64. BIOS hint ignored.\n");
641 		return NULL;
642 	} else if (!strcmp(str, "nobios")) {
643 		pci_probe &= ~PCI_PROBE_BIOS;
644 		return NULL;
645 	} else if (!strcmp(str, "nosort")) { /* Default */
646 		pci_probe |= PCI_NO_SORT;
647 		return NULL;
648 	}
649 #ifdef CONFIG_PCI_DIRECT
650 	else if (!strcmp(str, "conf1")) {
651 		pci_probe = PCI_PROBE_CONF1 | PCI_NO_CHECKS;
652 		return NULL;
653 	}
654 	else if (!strcmp(str, "conf2")) {
655 		pci_probe = PCI_PROBE_CONF2 | PCI_NO_CHECKS;
656 		return NULL;
657 	}
658 #endif
659 	else if (!strcmp(str, "rom")) {
660 		pci_probe |= PCI_ASSIGN_ROMS;
661 		return NULL;
662 	} else if (!strcmp(str, "assign-busses")) {
663 		pci_probe |= PCI_ASSIGN_ALL_BUSSES;
664 		return NULL;
665 	} else if (!strncmp(str, "irqmask=", 8)) {
666 		pcibios_irq_mask = simple_strtol(str+8, NULL, 0);
667 		return NULL;
668 	} else if (!strncmp(str, "lastbus=", 8)) {
669 		pcibios_last_bus = simple_strtol(str+8, NULL, 0);
670 		return NULL;
671 	} else if (!strncmp(str, "noacpi", 6)) {
672 		acpi_disable_pci();
673 		return NULL;
674 	}
675 	return str;
676 }
677 
pcibios_assign_all_busses(void)678 unsigned int pcibios_assign_all_busses(void)
679 {
680 	return (pci_probe & PCI_ASSIGN_ALL_BUSSES) ? 1 : 0;
681 }
682 
pcibios_enable_device(struct pci_dev * dev,int mask)683 int pcibios_enable_device(struct pci_dev *dev, int mask)
684 {
685 	int err;
686 
687 	if ((err = pcibios_enable_resources(dev, mask)) < 0)
688 		return err;
689 
690 #ifdef CONFIG_ACPI_PCI
691 	if (!acpi_noirq && pci_using_acpi_prt) {
692 		acpi_pci_irq_enable(dev);
693 		return 0;
694 	}
695 #endif
696 
697 	pcibios_enable_irq(dev);
698 
699 	return 0;
700 }
701