common.c 16.7 KB
Newer Older
L
Linus Torvalds 已提交
1 2 3 4 5 6 7 8
/*
 *	Low-Level PCI Support for PC
 *
 *	(c) 1999--2000 Martin Mares <mj@ucw.cz>
 */

#include <linux/sched.h>
#include <linux/pci.h>
9
#include <linux/pci-acpi.h>
L
Linus Torvalds 已提交
10 11
#include <linux/ioport.h>
#include <linux/init.h>
12
#include <linux/dmi.h>
13
#include <linux/slab.h>
L
Linus Torvalds 已提交
14

15
#include <asm-generic/pci-bridge.h>
L
Linus Torvalds 已提交
16 17 18 19
#include <asm/acpi.h>
#include <asm/segment.h>
#include <asm/io.h>
#include <asm/smp.h>
20
#include <asm/pci_x86.h>
M
Matthew Garrett 已提交
21
#include <asm/setup.h>
L
Linus Torvalds 已提交
22 23 24 25

unsigned int pci_probe = PCI_PROBE_BIOS | PCI_PROBE_CONF1 | PCI_PROBE_CONF2 |
				PCI_PROBE_MMCONF;

26
unsigned int pci_early_dump_regs;
27
static int pci_bf_sort;
28
static int smbios_type_b1_flag;
L
Linus Torvalds 已提交
29
int pci_routeirq;
30
int noioapicquirk;
31 32 33
#ifdef CONFIG_X86_REROUTE_FOR_BROKEN_BOOT_IRQS
int noioapicreroute = 0;
#else
34
int noioapicreroute = 1;
35
#endif
L
Linus Torvalds 已提交
36
int pcibios_last_bus = -1;
37
unsigned long pirq_table_addr;
J
Jan Beulich 已提交
38 39
const struct pci_raw_ops *__read_mostly raw_pci_ops;
const struct pci_raw_ops *__read_mostly raw_pci_ext_ops;
40 41 42 43

int raw_pci_read(unsigned int domain, unsigned int bus, unsigned int devfn,
						int reg, int len, u32 *val)
{
44
	if (domain == 0 && reg < 256 && raw_pci_ops)
45 46 47 48 49 50 51 52 53
		return raw_pci_ops->read(domain, bus, devfn, reg, len, val);
	if (raw_pci_ext_ops)
		return raw_pci_ext_ops->read(domain, bus, devfn, reg, len, val);
	return -EINVAL;
}

int raw_pci_write(unsigned int domain, unsigned int bus, unsigned int devfn,
						int reg, int len, u32 val)
{
54
	if (domain == 0 && reg < 256 && raw_pci_ops)
55 56 57 58 59
		return raw_pci_ops->write(domain, bus, devfn, reg, len, val);
	if (raw_pci_ext_ops)
		return raw_pci_ext_ops->write(domain, bus, devfn, reg, len, val);
	return -EINVAL;
}
L
Linus Torvalds 已提交
60 61 62

static int pci_read(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 *value)
{
63
	return raw_pci_read(pci_domain_nr(bus), bus->number,
64
				 devfn, where, size, value);
L
Linus Torvalds 已提交
65 66 67 68
}

static int pci_write(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 value)
{
69
	return raw_pci_write(pci_domain_nr(bus), bus->number,
70
				  devfn, where, size, value);
L
Linus Torvalds 已提交
71 72 73 74 75 76 77 78 79 80 81
}

struct pci_ops pci_root_ops = {
	.read = pci_read,
	.write = pci_write,
};

/*
 * This interrupt-safe spinlock protects all accesses to PCI
 * configuration space.
 */
82
DEFINE_RAW_SPINLOCK(pci_config_lock);
L
Linus Torvalds 已提交
83

84
static int __init can_skip_ioresource_align(const struct dmi_system_id *d)
85 86 87 88 89 90
{
	pci_probe |= PCI_CAN_SKIP_ISA_ALIGN;
	printk(KERN_INFO "PCI: %s detected, can skip ISA alignment\n", d->ident);
	return 0;
}

91
static const struct dmi_system_id can_skip_pciprobe_dmi_table[] __initconst = {
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
/*
 * Systems where PCI IO resource ISA alignment can be skipped
 * when the ISA enable bit in the bridge control is not set
 */
	{
		.callback = can_skip_ioresource_align,
		.ident = "IBM System x3800",
		.matches = {
			DMI_MATCH(DMI_SYS_VENDOR, "IBM"),
			DMI_MATCH(DMI_PRODUCT_NAME, "x3800"),
		},
	},
	{
		.callback = can_skip_ioresource_align,
		.ident = "IBM System x3850",
		.matches = {
			DMI_MATCH(DMI_SYS_VENDOR, "IBM"),
			DMI_MATCH(DMI_PRODUCT_NAME, "x3850"),
		},
	},
	{
		.callback = can_skip_ioresource_align,
		.ident = "IBM System x3950",
		.matches = {
			DMI_MATCH(DMI_SYS_VENDOR, "IBM"),
			DMI_MATCH(DMI_PRODUCT_NAME, "x3950"),
		},
	},
	{}
};

void __init dmi_check_skip_isa_align(void)
{
	dmi_check_system(can_skip_pciprobe_dmi_table);
}

128
static void pcibios_fixup_device_resources(struct pci_dev *dev)
129 130
{
	struct resource *rom_r = &dev->resource[PCI_ROM_RESOURCE];
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
	struct resource *bar_r;
	int bar;

	if (pci_probe & PCI_NOASSIGN_BARS) {
		/*
		* If the BIOS did not assign the BAR, zero out the
		* resource so the kernel doesn't attmept to assign
		* it later on in pci_assign_unassigned_resources
		*/
		for (bar = 0; bar <= PCI_STD_RESOURCE_END; bar++) {
			bar_r = &dev->resource[bar];
			if (bar_r->start == 0 && bar_r->end != 0) {
				bar_r->flags = 0;
				bar_r->end = 0;
			}
		}
	}
148 149 150 151 152 153 154 155 156 157 158 159

	if (pci_probe & PCI_NOASSIGN_ROMS) {
		if (rom_r->parent)
			return;
		if (rom_r->start) {
			/* we deal with BIOS assigned ROM later */
			return;
		}
		rom_r->start = rom_r->end = rom_r->flags = 0;
	}
}

L
Linus Torvalds 已提交
160 161 162 163 164
/*
 *  Called after each bus is probed, but before its children
 *  are examined.
 */

165
void pcibios_fixup_bus(struct pci_bus *b)
L
Linus Torvalds 已提交
166
{
167 168
	struct pci_dev *dev;

L
Linus Torvalds 已提交
169
	pci_read_bridge_bases(b);
170 171
	list_for_each_entry(dev, &b->devices, bus_list)
		pcibios_fixup_device_resources(dev);
L
Linus Torvalds 已提交
172 173
}

174 175 176 177 178 179 180 181 182 183
void pcibios_add_bus(struct pci_bus *bus)
{
	acpi_pci_add_bus(bus);
}

void pcibios_remove_bus(struct pci_bus *bus)
{
	acpi_pci_remove_bus(bus);
}

184 185 186 187 188
/*
 * Only use DMI information to set this if nothing was passed
 * on the kernel command line (which was parsed earlier).
 */

189
static int __init set_bf_sort(const struct dmi_system_id *d)
190 191 192 193 194 195 196 197
{
	if (pci_bf_sort == pci_bf_sort_default) {
		pci_bf_sort = pci_dmi_bf;
		printk(KERN_INFO "PCI: %s detected, enabling pci=bfsort.\n", d->ident);
	}
	return 0;
}

198 199
static void __init read_dmi_type_b1(const struct dmi_header *dm,
				    void *private_data)
200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219
{
	u8 *d = (u8 *)dm + 4;

	if (dm->type != 0xB1)
		return;
	switch (((*(u32 *)d) >> 9) & 0x03) {
	case 0x00:
		printk(KERN_INFO "dmi type 0xB1 record - unknown flag\n");
		break;
	case 0x01: /* set pci=bfsort */
		smbios_type_b1_flag = 1;
		break;
	case 0x02: /* do not set pci=bfsort */
		smbios_type_b1_flag = 2;
		break;
	default:
		break;
	}
}

220
static int __init find_sort_method(const struct dmi_system_id *d)
221 222 223 224 225 226 227 228 229 230
{
	dmi_walk(read_dmi_type_b1, NULL);

	if (smbios_type_b1_flag == 1) {
		set_bf_sort(d);
		return 0;
	}
	return -1;
}

231 232 233 234
/*
 * Enable renumbering of PCI bus# ranges to reach all PCI busses (Cardbus)
 */
#ifdef __i386__
235
static int __init assign_all_busses(const struct dmi_system_id *d)
236 237 238 239 240 241 242 243
{
	pci_probe |= PCI_ASSIGN_ALL_BUSSES;
	printk(KERN_INFO "%s detected: enabling PCI bus# renumbering"
			" (pci=assign-busses)\n", d->ident);
	return 0;
}
#endif

244
static int __init set_scan_all(const struct dmi_system_id *d)
245 246 247 248 249 250 251
{
	printk(KERN_INFO "PCI: %s detected, enabling pci=pcie_scan_all\n",
	       d->ident);
	pci_add_flags(PCI_SCAN_ALL_PCIE_DEVS);
	return 0;
}

252
static const struct dmi_system_id pciprobe_dmi_table[] __initconst = {
253
#ifdef __i386__
254 255 256 257 258 259 260 261 262 263 264 265
/*
 * Laptops which need pci=assign-busses to see Cardbus cards
 */
	{
		.callback = assign_all_busses,
		.ident = "Samsung X20 Laptop",
		.matches = {
			DMI_MATCH(DMI_SYS_VENDOR, "Samsung Electronics"),
			DMI_MATCH(DMI_PRODUCT_NAME, "SX20S"),
		},
	},
#endif		/* __i386__ */
266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297
	{
		.callback = set_bf_sort,
		.ident = "Dell PowerEdge 1950",
		.matches = {
			DMI_MATCH(DMI_SYS_VENDOR, "Dell"),
			DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge 1950"),
		},
	},
	{
		.callback = set_bf_sort,
		.ident = "Dell PowerEdge 1955",
		.matches = {
			DMI_MATCH(DMI_SYS_VENDOR, "Dell"),
			DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge 1955"),
		},
	},
	{
		.callback = set_bf_sort,
		.ident = "Dell PowerEdge 2900",
		.matches = {
			DMI_MATCH(DMI_SYS_VENDOR, "Dell"),
			DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge 2900"),
		},
	},
	{
		.callback = set_bf_sort,
		.ident = "Dell PowerEdge 2950",
		.matches = {
			DMI_MATCH(DMI_SYS_VENDOR, "Dell"),
			DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge 2950"),
		},
	},
298 299 300 301 302 303 304 305
	{
		.callback = set_bf_sort,
		.ident = "Dell PowerEdge R900",
		.matches = {
			DMI_MATCH(DMI_SYS_VENDOR, "Dell"),
			DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge R900"),
		},
	},
306 307 308 309 310 311 312
	{
		.callback = find_sort_method,
		.ident = "Dell System",
		.matches = {
			DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc"),
		},
	},
313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400
	{
		.callback = set_bf_sort,
		.ident = "HP ProLiant BL20p G3",
		.matches = {
			DMI_MATCH(DMI_SYS_VENDOR, "HP"),
			DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL20p G3"),
		},
	},
	{
		.callback = set_bf_sort,
		.ident = "HP ProLiant BL20p G4",
		.matches = {
			DMI_MATCH(DMI_SYS_VENDOR, "HP"),
			DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL20p G4"),
		},
	},
	{
		.callback = set_bf_sort,
		.ident = "HP ProLiant BL30p G1",
		.matches = {
			DMI_MATCH(DMI_SYS_VENDOR, "HP"),
			DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL30p G1"),
		},
	},
	{
		.callback = set_bf_sort,
		.ident = "HP ProLiant BL25p G1",
		.matches = {
			DMI_MATCH(DMI_SYS_VENDOR, "HP"),
			DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL25p G1"),
		},
	},
	{
		.callback = set_bf_sort,
		.ident = "HP ProLiant BL35p G1",
		.matches = {
			DMI_MATCH(DMI_SYS_VENDOR, "HP"),
			DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL35p G1"),
		},
	},
	{
		.callback = set_bf_sort,
		.ident = "HP ProLiant BL45p G1",
		.matches = {
			DMI_MATCH(DMI_SYS_VENDOR, "HP"),
			DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL45p G1"),
		},
	},
	{
		.callback = set_bf_sort,
		.ident = "HP ProLiant BL45p G2",
		.matches = {
			DMI_MATCH(DMI_SYS_VENDOR, "HP"),
			DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL45p G2"),
		},
	},
	{
		.callback = set_bf_sort,
		.ident = "HP ProLiant BL460c G1",
		.matches = {
			DMI_MATCH(DMI_SYS_VENDOR, "HP"),
			DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL460c G1"),
		},
	},
	{
		.callback = set_bf_sort,
		.ident = "HP ProLiant BL465c G1",
		.matches = {
			DMI_MATCH(DMI_SYS_VENDOR, "HP"),
			DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL465c G1"),
		},
	},
	{
		.callback = set_bf_sort,
		.ident = "HP ProLiant BL480c G1",
		.matches = {
			DMI_MATCH(DMI_SYS_VENDOR, "HP"),
			DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL480c G1"),
		},
	},
	{
		.callback = set_bf_sort,
		.ident = "HP ProLiant BL685c G1",
		.matches = {
			DMI_MATCH(DMI_SYS_VENDOR, "HP"),
			DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL685c G1"),
		},
	},
401 402
	{
		.callback = set_bf_sort,
403
		.ident = "HP ProLiant DL360",
404 405
		.matches = {
			DMI_MATCH(DMI_SYS_VENDOR, "HP"),
406
			DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant DL360"),
407 408 409 410
		},
	},
	{
		.callback = set_bf_sort,
411
		.ident = "HP ProLiant DL380",
412 413
		.matches = {
			DMI_MATCH(DMI_SYS_VENDOR, "HP"),
414
			DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant DL380"),
415 416
		},
	},
417 418 419 420 421 422 423 424 425 426
#ifdef __i386__
	{
		.callback = assign_all_busses,
		.ident = "Compaq EVO N800c",
		.matches = {
			DMI_MATCH(DMI_SYS_VENDOR, "Compaq"),
			DMI_MATCH(DMI_PRODUCT_NAME, "EVO N800c"),
		},
	},
#endif
427 428
	{
		.callback = set_bf_sort,
429
		.ident = "HP ProLiant DL385 G2",
430 431
		.matches = {
			DMI_MATCH(DMI_SYS_VENDOR, "HP"),
432
			DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant DL385 G2"),
433 434 435 436
		},
	},
	{
		.callback = set_bf_sort,
437
		.ident = "HP ProLiant DL585 G2",
438 439
		.matches = {
			DMI_MATCH(DMI_SYS_VENDOR, "HP"),
440
			DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant DL585 G2"),
441 442
		},
	},
443 444 445 446
	{
		.callback = set_scan_all,
		.ident = "Stratus/NEC ftServer",
		.matches = {
447 448
			DMI_MATCH(DMI_SYS_VENDOR, "Stratus"),
			DMI_MATCH(DMI_PRODUCT_NAME, "ftServer"),
449 450
		},
	},
451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466
        {
                .callback = set_scan_all,
                .ident = "Stratus/NEC ftServer",
                .matches = {
                        DMI_MATCH(DMI_SYS_VENDOR, "NEC"),
                        DMI_MATCH(DMI_PRODUCT_NAME, "Express5800/R32"),
                },
        },
        {
                .callback = set_scan_all,
                .ident = "Stratus/NEC ftServer",
                .matches = {
                        DMI_MATCH(DMI_SYS_VENDOR, "NEC"),
                        DMI_MATCH(DMI_PRODUCT_NAME, "Express5800/R31"),
                },
        },
467 468
	{}
};
L
Linus Torvalds 已提交
469

Y
Yinghai Lu 已提交
470 471 472 473 474
void __init dmi_check_pciprobe(void)
{
	dmi_check_system(pciprobe_dmi_table);
}

475
void pcibios_scan_root(int busnum)
L
Linus Torvalds 已提交
476
{
477 478 479 480 481 482 483
	struct pci_bus *bus;
	struct pci_sysdata *sd;
	LIST_HEAD(resources);

	sd = kzalloc(sizeof(*sd), GFP_KERNEL);
	if (!sd) {
		printk(KERN_ERR "PCI: OOM, skipping PCI bus %02x\n", busnum);
484
		return;
485
	}
486
	sd->node = x86_pci_root_bus_node(busnum);
487 488 489 490 491 492 493
	x86_pci_root_bus_resources(busnum, &resources);
	printk(KERN_DEBUG "PCI: Probing PCI hardware (bus %02x)\n", busnum);
	bus = pci_scan_root_bus(NULL, busnum, &pci_root_ops, sd, &resources);
	if (!bus) {
		pci_free_resource_list(&resources);
		kfree(sd);
	}
L
Linus Torvalds 已提交
494
}
495

A
Alex Nixon 已提交
496
void __init pcibios_set_cache_line_size(void)
L
Linus Torvalds 已提交
497 498 499 500
{
	struct cpuinfo_x86 *c = &boot_cpu_data;

	/*
501 502 503
	 * Set PCI cacheline size to that of the CPU if the CPU has reported it.
	 * (For older CPUs that don't support cpuid, we se it to 32 bytes
	 * It's also good for 386/486s (which actually have 16)
L
Linus Torvalds 已提交
504 505
	 * as quite a few PCI devices do not support smaller values.
	 */
506 507 508 509 510 511 512 513
	if (c->x86_clflush_size > 0) {
		pci_dfl_cache_line_size = c->x86_clflush_size >> 2;
		printk(KERN_DEBUG "PCI: pci_cache_line_size set to %d bytes\n",
			pci_dfl_cache_line_size << 2);
	} else {
 		pci_dfl_cache_line_size = 32 >> 2;
		printk(KERN_DEBUG "PCI: Unknown cacheline size. Setting to 32 bytes\n");
	}
A
Alex Nixon 已提交
514 515
}

516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540
/*
 * Some device drivers assume dev->irq won't change after calling
 * pci_disable_device(). So delay releasing of IRQ resource to driver
 * unbinding time. Otherwise it will break PM subsystem and drivers
 * like xen-pciback etc.
 */
static int pci_irq_notifier(struct notifier_block *nb, unsigned long action,
			    void *data)
{
	struct pci_dev *dev = to_pci_dev(data);

	if (action != BUS_NOTIFY_UNBOUND_DRIVER)
		return NOTIFY_DONE;

	if (pcibios_disable_irq)
		pcibios_disable_irq(dev);

	return NOTIFY_OK;
}

static struct notifier_block pci_irq_nb = {
	.notifier_call = pci_irq_notifier,
	.priority = INT_MIN,
};

A
Alex Nixon 已提交
541 542 543 544 545 546
int __init pcibios_init(void)
{
	if (!raw_pci_ops) {
		printk(KERN_WARNING "PCI: System does not support PCI\n");
		return 0;
	}
L
Linus Torvalds 已提交
547

A
Alex Nixon 已提交
548
	pcibios_set_cache_line_size();
L
Linus Torvalds 已提交
549 550
	pcibios_resource_survey();

551 552
	if (pci_bf_sort >= pci_force_bf)
		pci_sort_breadthfirst();
553 554 555

	bus_register_notifier(&pci_bus_type, &pci_irq_nb);

L
Linus Torvalds 已提交
556 557 558
	return 0;
}

559
char *__init pcibios_setup(char *str)
L
Linus Torvalds 已提交
560 561 562 563
{
	if (!strcmp(str, "off")) {
		pci_probe = 0;
		return NULL;
564 565 566 567 568 569
	} else if (!strcmp(str, "bfsort")) {
		pci_bf_sort = pci_force_bf;
		return NULL;
	} else if (!strcmp(str, "nobfsort")) {
		pci_bf_sort = pci_force_nobf;
		return NULL;
L
Linus Torvalds 已提交
570 571 572 573 574 575 576 577 578 579 580
	}
#ifdef CONFIG_PCI_BIOS
	else if (!strcmp(str, "bios")) {
		pci_probe = PCI_PROBE_BIOS;
		return NULL;
	} else if (!strcmp(str, "nobios")) {
		pci_probe &= ~PCI_PROBE_BIOS;
		return NULL;
	} else if (!strcmp(str, "biosirq")) {
		pci_probe |= PCI_BIOS_IRQ_SCAN;
		return NULL;
581 582 583
	} else if (!strncmp(str, "pirqaddr=", 9)) {
		pirq_table_addr = simple_strtoul(str+9, NULL, 0);
		return NULL;
L
Linus Torvalds 已提交
584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600
	}
#endif
#ifdef CONFIG_PCI_DIRECT
	else if (!strcmp(str, "conf1")) {
		pci_probe = PCI_PROBE_CONF1 | PCI_NO_CHECKS;
		return NULL;
	}
	else if (!strcmp(str, "conf2")) {
		pci_probe = PCI_PROBE_CONF2 | PCI_NO_CHECKS;
		return NULL;
	}
#endif
#ifdef CONFIG_PCI_MMCONFIG
	else if (!strcmp(str, "nommconf")) {
		pci_probe &= ~PCI_PROBE_MMCONF;
		return NULL;
	}
601 602 603 604
	else if (!strcmp(str, "check_enable_amd_mmconf")) {
		pci_probe |= PCI_CHECK_ENABLE_AMD_MMCONF;
		return NULL;
	}
L
Linus Torvalds 已提交
605 606 607 608 609
#endif
	else if (!strcmp(str, "noacpi")) {
		acpi_noirq_set();
		return NULL;
	}
610 611 612 613
	else if (!strcmp(str, "noearly")) {
		pci_probe |= PCI_PROBE_NOEARLY;
		return NULL;
	}
L
Linus Torvalds 已提交
614 615 616 617 618 619 620 621 622
	else if (!strcmp(str, "usepirqmask")) {
		pci_probe |= PCI_USE_PIRQ_MASK;
		return NULL;
	} else if (!strncmp(str, "irqmask=", 8)) {
		pcibios_irq_mask = simple_strtol(str+8, NULL, 0);
		return NULL;
	} else if (!strncmp(str, "lastbus=", 8)) {
		pcibios_last_bus = simple_strtol(str+8, NULL, 0);
		return NULL;
623
	} else if (!strcmp(str, "rom")) {
L
Linus Torvalds 已提交
624 625
		pci_probe |= PCI_ASSIGN_ROMS;
		return NULL;
626 627 628
	} else if (!strcmp(str, "norom")) {
		pci_probe |= PCI_NOASSIGN_ROMS;
		return NULL;
629 630 631
	} else if (!strcmp(str, "nobar")) {
		pci_probe |= PCI_NOASSIGN_BARS;
		return NULL;
L
Linus Torvalds 已提交
632 633 634
	} else if (!strcmp(str, "assign-busses")) {
		pci_probe |= PCI_ASSIGN_ALL_BUSSES;
		return NULL;
635 636
	} else if (!strcmp(str, "use_crs")) {
		pci_probe |= PCI_USE__CRS;
637
		return NULL;
638 639 640
	} else if (!strcmp(str, "nocrs")) {
		pci_probe |= PCI_ROOT_NO_CRS;
		return NULL;
641 642 643
	} else if (!strcmp(str, "earlydump")) {
		pci_early_dump_regs = 1;
		return NULL;
L
Linus Torvalds 已提交
644 645 646
	} else if (!strcmp(str, "routeirq")) {
		pci_routeirq = 1;
		return NULL;
647 648 649
	} else if (!strcmp(str, "skip_isa_align")) {
		pci_probe |= PCI_CAN_SKIP_ISA_ALIGN;
		return NULL;
650 651 652
	} else if (!strcmp(str, "noioapicquirk")) {
		noioapicquirk = 1;
		return NULL;
653 654 655 656
	} else if (!strcmp(str, "ioapicreroute")) {
		if (noioapicreroute != -1)
			noioapicreroute = 0;
		return NULL;
657 658 659 660
	} else if (!strcmp(str, "noioapicreroute")) {
		if (noioapicreroute != -1)
			noioapicreroute = 1;
		return NULL;
L
Linus Torvalds 已提交
661 662 663 664 665 666 667 668 669
	}
	return str;
}

unsigned int pcibios_assign_all_busses(void)
{
	return (pci_probe & PCI_ASSIGN_ALL_BUSSES) ? 1 : 0;
}

M
Matthew Garrett 已提交
670 671 672 673 674 675 676 677
int pcibios_add_device(struct pci_dev *dev)
{
	struct setup_data *data;
	struct pci_setup_rom *rom;
	u64 pa_data;

	pa_data = boot_params.hdr.setup_data;
	while (pa_data) {
678 679 680
		data = ioremap(pa_data, sizeof(*rom));
		if (!data)
			return -ENOMEM;
M
Matthew Garrett 已提交
681 682 683 684 685 686 687 688 689 690

		if (data->type == SETUP_PCI) {
			rom = (struct pci_setup_rom *)data;

			if ((pci_domain_nr(dev->bus) == rom->segment) &&
			    (dev->bus->number == rom->bus) &&
			    (PCI_SLOT(dev->devfn) == rom->device) &&
			    (PCI_FUNC(dev->devfn) == rom->function) &&
			    (dev->vendor == rom->vendor) &&
			    (dev->device == rom->devid)) {
691 692
				dev->rom = pa_data +
				      offsetof(struct pci_setup_rom, romdata);
M
Matthew Garrett 已提交
693 694 695 696
				dev->romlen = rom->pcilen;
			}
		}
		pa_data = data->next;
697
		iounmap(data);
M
Matthew Garrett 已提交
698 699 700 701
	}
	return 0;
}

L
Linus Torvalds 已提交
702 703 704 705
int pcibios_enable_device(struct pci_dev *dev, int mask)
{
	int err;

706
	if ((err = pci_enable_resources(dev, mask)) < 0)
L
Linus Torvalds 已提交
707 708
		return err;

709
	if (!pci_dev_msi_enabled(dev))
710 711
		return pcibios_enable_irq(dev);
	return 0;
L
Linus Torvalds 已提交
712
}
713

714
int pci_ext_cfg_avail(void)
715 716 717 718 719 720
{
	if (raw_pci_ext_ops)
		return 1;
	else
		return 0;
}