blob: bf86f7662d8b7a4c6210ff6e537502db624e27b6 [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
17static int nvidia_hpet_detected __initdata;
18
Alexey Starikovskiyceb6c462007-02-02 19:48:22 +030019static int __init nvidia_hpet_check(struct acpi_table_header *header)
Andy Curridd44647b2006-06-08 00:43:38 -070020{
21 nvidia_hpet_detected = 1;
22 return 0;
23}
24#endif
25
Len Brown4be44fc2005-08-05 00:44:28 -040026static int __init check_bridge(int vendor, int device)
Linus Torvalds1da177e2005-04-16 15:20:36 -070027{
Andi Kleenf9262c12006-03-08 17:57:25 -080028#ifdef CONFIG_ACPI
Andy Curridd44647b2006-06-08 00:43:38 -070029 /* According to Nvidia all timer overrides are bogus unless HPET
30 is enabled. */
Andi Kleenfa18f472006-11-14 16:57:46 +010031 if (!acpi_use_timer_override && vendor == PCI_VENDOR_ID_NVIDIA) {
Andy Curridd44647b2006-06-08 00:43:38 -070032 nvidia_hpet_detected = 0;
Alexey Starikovskiy15a58ed2007-02-02 19:48:22 +030033 acpi_table_parse(ACPI_SIG_HPET, nvidia_hpet_check);
Andy Curridd44647b2006-06-08 00:43:38 -070034 if (nvidia_hpet_detected == 0) {
35 acpi_skip_timer_override = 1;
Andi Kleenfa18f472006-11-14 16:57:46 +010036 printk(KERN_INFO "Nvidia board "
37 "detected. Ignoring ACPI "
38 "timer override.\n");
39 printk(KERN_INFO "If you got timer trouble "
40 "try acpi_use_timer_override\n");
41
Andy Curridd44647b2006-06-08 00:43:38 -070042 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070043 }
Andi Kleenf9262c12006-03-08 17:57:25 -080044#endif
45 if (vendor == PCI_VENDOR_ID_ATI && timer_over_8254 == 1) {
46 timer_over_8254 = 0;
47 printk(KERN_INFO "ATI board detected. Disabling timer routing "
48 "over 8254.\n");
49 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070050 return 0;
51}
Len Brown4be44fc2005-08-05 00:44:28 -040052
Siddha, Suresh Bb0d0a4b2006-12-07 02:14:10 +010053static void check_intel(void)
54{
55 u16 vendor, device;
56
57 vendor = read_pci_config_16(0, 0, 0, PCI_VENDOR_ID);
58
59 if (vendor != PCI_VENDOR_ID_INTEL)
60 return;
61
62 device = read_pci_config_16(0, 0, 0, PCI_DEVICE_ID);
63#ifdef CONFIG_SMP
64 if (device == PCI_DEVICE_ID_INTEL_E7320_MCH ||
65 device == PCI_DEVICE_ID_INTEL_E7520_MCH ||
66 device == PCI_DEVICE_ID_INTEL_E7525_MCH)
67 quirk_intel_irqbalance();
68#endif
69}
70
Len Brown4be44fc2005-08-05 00:44:28 -040071void __init check_acpi_pci(void)
72{
73 int num, slot, func;
Linus Torvalds1da177e2005-04-16 15:20:36 -070074
75 /* Assume the machine supports type 1. If not it will
Andi Kleen0637a702006-09-26 10:52:41 +020076 always read ffffffff and should not have any side effect.
77 Actually a few buggy systems can machine check. Allow the user
78 to disable it by command line option at least -AK */
79 if (!early_pci_allowed())
80 return;
Linus Torvalds1da177e2005-04-16 15:20:36 -070081
Siddha, Suresh Bb0d0a4b2006-12-07 02:14:10 +010082 check_intel();
83
Linus Torvalds1da177e2005-04-16 15:20:36 -070084 /* Poor man's PCI discovery */
Len Brown4be44fc2005-08-05 00:44:28 -040085 for (num = 0; num < 32; num++) {
86 for (slot = 0; slot < 32; slot++) {
87 for (func = 0; func < 8; func++) {
Linus Torvalds1da177e2005-04-16 15:20:36 -070088 u32 class;
89 u32 vendor;
Len Brown4be44fc2005-08-05 00:44:28 -040090 class = read_pci_config(num, slot, func,
Linus Torvalds1da177e2005-04-16 15:20:36 -070091 PCI_CLASS_REVISION);
92 if (class == 0xffffffff)
Len Brown4be44fc2005-08-05 00:44:28 -040093 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -070094
95 if ((class >> 16) != PCI_CLASS_BRIDGE_PCI)
Len Brown4be44fc2005-08-05 00:44:28 -040096 continue;
97
98 vendor = read_pci_config(num, slot, func,
Linus Torvalds1da177e2005-04-16 15:20:36 -070099 PCI_VENDOR_ID);
Len Brown4be44fc2005-08-05 00:44:28 -0400100
101 if (check_bridge(vendor & 0xffff, vendor >> 16))
102 return;
103 }
104
Linus Torvalds1da177e2005-04-16 15:20:36 -0700105 }
106 }
107}