blob: 1649a175a206ab4bd6ed0add0040580ff83d036e [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>
Linus Torvalds1da177e2005-04-16 15:20:36 -070013
Andy Curridd44647b2006-06-08 00:43:38 -070014#ifdef CONFIG_ACPI
15
16static int nvidia_hpet_detected __initdata;
17
18static int __init nvidia_hpet_check(unsigned long phys, unsigned long size)
19{
20 nvidia_hpet_detected = 1;
21 return 0;
22}
23#endif
24
Len Brown4be44fc2005-08-05 00:44:28 -040025static int __init check_bridge(int vendor, int device)
Linus Torvalds1da177e2005-04-16 15:20:36 -070026{
Andi Kleenf9262c12006-03-08 17:57:25 -080027#ifdef CONFIG_ACPI
Andy Curridd44647b2006-06-08 00:43:38 -070028 /* According to Nvidia all timer overrides are bogus unless HPET
29 is enabled. */
Len Brown4be44fc2005-08-05 00:44:28 -040030 if (vendor == PCI_VENDOR_ID_NVIDIA) {
Andy Curridd44647b2006-06-08 00:43:38 -070031 nvidia_hpet_detected = 0;
32 acpi_table_parse(ACPI_HPET, nvidia_hpet_check);
33 if (nvidia_hpet_detected == 0) {
34 acpi_skip_timer_override = 1;
35 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070036 }
Andi Kleenf9262c12006-03-08 17:57:25 -080037#endif
38 if (vendor == PCI_VENDOR_ID_ATI && timer_over_8254 == 1) {
39 timer_over_8254 = 0;
40 printk(KERN_INFO "ATI board detected. Disabling timer routing "
41 "over 8254.\n");
42 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070043 return 0;
44}
Len Brown4be44fc2005-08-05 00:44:28 -040045
46void __init check_acpi_pci(void)
47{
48 int num, slot, func;
Linus Torvalds1da177e2005-04-16 15:20:36 -070049
50 /* Assume the machine supports type 1. If not it will
51 always read ffffffff and should not have any side effect. */
52
53 /* Poor man's PCI discovery */
Len Brown4be44fc2005-08-05 00:44:28 -040054 for (num = 0; num < 32; num++) {
55 for (slot = 0; slot < 32; slot++) {
56 for (func = 0; func < 8; func++) {
Linus Torvalds1da177e2005-04-16 15:20:36 -070057 u32 class;
58 u32 vendor;
Len Brown4be44fc2005-08-05 00:44:28 -040059 class = read_pci_config(num, slot, func,
Linus Torvalds1da177e2005-04-16 15:20:36 -070060 PCI_CLASS_REVISION);
61 if (class == 0xffffffff)
Len Brown4be44fc2005-08-05 00:44:28 -040062 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -070063
64 if ((class >> 16) != PCI_CLASS_BRIDGE_PCI)
Len Brown4be44fc2005-08-05 00:44:28 -040065 continue;
66
67 vendor = read_pci_config(num, slot, func,
Linus Torvalds1da177e2005-04-16 15:20:36 -070068 PCI_VENDOR_ID);
Len Brown4be44fc2005-08-05 00:44:28 -040069
70 if (check_bridge(vendor & 0xffff, vendor >> 16))
71 return;
72 }
73
Linus Torvalds1da177e2005-04-16 15:20:36 -070074 }
75 }
76}