blob: 8f7efd38254d47afd953054fa8cbf42e47d1dff8 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Do early PCI probing for bug detection when the main PCI subsystem is
3 * not up yet.
4 */
5#include <linux/init.h>
6#include <linux/kernel.h>
7#include <linux/pci.h>
Andy Curridd44647b2006-06-08 00:43:38 -07008#include <linux/acpi.h>
9
Linus Torvalds1da177e2005-04-16 15:20:36 -070010#include <asm/pci-direct.h>
11#include <asm/acpi.h>
Andi Kleenf9262c12006-03-08 17:57:25 -080012#include <asm/apic.h>
Siddha, Suresh Bb0d0a4b2006-12-07 02:14:10 +010013#include <asm/irq.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070014
Andy Curridd44647b2006-06-08 00:43:38 -070015#ifdef CONFIG_ACPI
16
Alexey Starikovskiyceb6c462007-02-02 19:48:22 +030017static int __init nvidia_hpet_check(struct acpi_table_header *header)
Andy Curridd44647b2006-06-08 00:43:38 -070018{
Andy Curridd44647b2006-06-08 00:43:38 -070019 return 0;
20}
21#endif
22
Len Brown4be44fc2005-08-05 00:44:28 -040023static int __init check_bridge(int vendor, int device)
Linus Torvalds1da177e2005-04-16 15:20:36 -070024{
Andi Kleenf9262c12006-03-08 17:57:25 -080025#ifdef CONFIG_ACPI
Zachary Amsdenafd38102007-04-25 15:32:23 -040026 static int warned;
Andy Curridd44647b2006-06-08 00:43:38 -070027 /* According to Nvidia all timer overrides are bogus unless HPET
28 is enabled. */
Andi Kleenfa18f472006-11-14 16:57:46 +010029 if (!acpi_use_timer_override && vendor == PCI_VENDOR_ID_NVIDIA) {
Thierry Vignaudb2983f12007-04-25 15:31:30 -040030 if (!warned && acpi_table_parse(ACPI_SIG_HPET,
31 nvidia_hpet_check)) {
32 warned = 1;
Andy Curridd44647b2006-06-08 00:43:38 -070033 acpi_skip_timer_override = 1;
Andi Kleenfa18f472006-11-14 16:57:46 +010034 printk(KERN_INFO "Nvidia board "
35 "detected. Ignoring ACPI "
36 "timer override.\n");
37 printk(KERN_INFO "If you got timer trouble "
38 "try acpi_use_timer_override\n");
39
Andy Curridd44647b2006-06-08 00:43:38 -070040 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070041 }
Andi Kleenf9262c12006-03-08 17:57:25 -080042#endif
43 if (vendor == PCI_VENDOR_ID_ATI && timer_over_8254 == 1) {
44 timer_over_8254 = 0;
45 printk(KERN_INFO "ATI board detected. Disabling timer routing "
46 "over 8254.\n");
47 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070048 return 0;
49}
Len Brown4be44fc2005-08-05 00:44:28 -040050
Siddha, Suresh Bb0d0a4b2006-12-07 02:14:10 +010051static void check_intel(void)
52{
53 u16 vendor, device;
54
55 vendor = read_pci_config_16(0, 0, 0, PCI_VENDOR_ID);
56
57 if (vendor != PCI_VENDOR_ID_INTEL)
58 return;
59
60 device = read_pci_config_16(0, 0, 0, PCI_DEVICE_ID);
61#ifdef CONFIG_SMP
62 if (device == PCI_DEVICE_ID_INTEL_E7320_MCH ||
63 device == PCI_DEVICE_ID_INTEL_E7520_MCH ||
64 device == PCI_DEVICE_ID_INTEL_E7525_MCH)
65 quirk_intel_irqbalance();
66#endif
67}
68
Len Brown4be44fc2005-08-05 00:44:28 -040069void __init check_acpi_pci(void)
70{
71 int num, slot, func;
Linus Torvalds1da177e2005-04-16 15:20:36 -070072
73 /* Assume the machine supports type 1. If not it will
Andi Kleen0637a702006-09-26 10:52:41 +020074 always read ffffffff and should not have any side effect.
75 Actually a few buggy systems can machine check. Allow the user
76 to disable it by command line option at least -AK */
77 if (!early_pci_allowed())
78 return;
Linus Torvalds1da177e2005-04-16 15:20:36 -070079
Siddha, Suresh Bb0d0a4b2006-12-07 02:14:10 +010080 check_intel();
81
Linus Torvalds1da177e2005-04-16 15:20:36 -070082 /* Poor man's PCI discovery */
Len Brown4be44fc2005-08-05 00:44:28 -040083 for (num = 0; num < 32; num++) {
84 for (slot = 0; slot < 32; slot++) {
85 for (func = 0; func < 8; func++) {
Linus Torvalds1da177e2005-04-16 15:20:36 -070086 u32 class;
87 u32 vendor;
Len Brown4be44fc2005-08-05 00:44:28 -040088 class = read_pci_config(num, slot, func,
Linus Torvalds1da177e2005-04-16 15:20:36 -070089 PCI_CLASS_REVISION);
90 if (class == 0xffffffff)
Len Brown4be44fc2005-08-05 00:44:28 -040091 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -070092
93 if ((class >> 16) != PCI_CLASS_BRIDGE_PCI)
Len Brown4be44fc2005-08-05 00:44:28 -040094 continue;
95
96 vendor = read_pci_config(num, slot, func,
Linus Torvalds1da177e2005-04-16 15:20:36 -070097 PCI_VENDOR_ID);
Len Brown4be44fc2005-08-05 00:44:28 -040098
99 if (check_bridge(vendor & 0xffff, vendor >> 16))
100 return;
101 }
102
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103 }
104 }
105}