Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 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 Currid | d44647b | 2006-06-08 00:43:38 -0700 | [diff] [blame] | 8 | #include <linux/acpi.h> |
| 9 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | #include <asm/pci-direct.h> |
| 11 | #include <asm/acpi.h> |
Andi Kleen | f9262c1 | 2006-03-08 17:57:25 -0800 | [diff] [blame] | 12 | #include <asm/apic.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | |
Andy Currid | d44647b | 2006-06-08 00:43:38 -0700 | [diff] [blame] | 14 | #ifdef CONFIG_ACPI |
| 15 | |
| 16 | static int nvidia_hpet_detected __initdata; |
| 17 | |
| 18 | static 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 Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 25 | static int __init check_bridge(int vendor, int device) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | { |
Andi Kleen | f9262c1 | 2006-03-08 17:57:25 -0800 | [diff] [blame] | 27 | #ifdef CONFIG_ACPI |
Andy Currid | d44647b | 2006-06-08 00:43:38 -0700 | [diff] [blame] | 28 | /* According to Nvidia all timer overrides are bogus unless HPET |
| 29 | is enabled. */ |
Andi Kleen | fa18f47 | 2006-11-14 16:57:46 +0100 | [diff] [blame] | 30 | if (!acpi_use_timer_override && vendor == PCI_VENDOR_ID_NVIDIA) { |
Andy Currid | d44647b | 2006-06-08 00:43:38 -0700 | [diff] [blame] | 31 | 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; |
Andi Kleen | fa18f47 | 2006-11-14 16:57:46 +0100 | [diff] [blame] | 35 | printk(KERN_INFO "Nvidia board " |
| 36 | "detected. Ignoring ACPI " |
| 37 | "timer override.\n"); |
| 38 | printk(KERN_INFO "If you got timer trouble " |
| 39 | "try acpi_use_timer_override\n"); |
| 40 | |
Andy Currid | d44647b | 2006-06-08 00:43:38 -0700 | [diff] [blame] | 41 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | } |
Andi Kleen | f9262c1 | 2006-03-08 17:57:25 -0800 | [diff] [blame] | 43 | #endif |
| 44 | if (vendor == PCI_VENDOR_ID_ATI && timer_over_8254 == 1) { |
| 45 | timer_over_8254 = 0; |
| 46 | printk(KERN_INFO "ATI board detected. Disabling timer routing " |
| 47 | "over 8254.\n"); |
| 48 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | return 0; |
| 50 | } |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 51 | |
| 52 | void __init check_acpi_pci(void) |
| 53 | { |
| 54 | int num, slot, func; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 55 | |
| 56 | /* Assume the machine supports type 1. If not it will |
Andi Kleen | 0637a70 | 2006-09-26 10:52:41 +0200 | [diff] [blame] | 57 | always read ffffffff and should not have any side effect. |
| 58 | Actually a few buggy systems can machine check. Allow the user |
| 59 | to disable it by command line option at least -AK */ |
| 60 | if (!early_pci_allowed()) |
| 61 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | |
| 63 | /* Poor man's PCI discovery */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 64 | for (num = 0; num < 32; num++) { |
| 65 | for (slot = 0; slot < 32; slot++) { |
| 66 | for (func = 0; func < 8; func++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 67 | u32 class; |
| 68 | u32 vendor; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 69 | class = read_pci_config(num, slot, func, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | PCI_CLASS_REVISION); |
| 71 | if (class == 0xffffffff) |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 72 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 73 | |
| 74 | if ((class >> 16) != PCI_CLASS_BRIDGE_PCI) |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 75 | continue; |
| 76 | |
| 77 | vendor = read_pci_config(num, slot, func, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 78 | PCI_VENDOR_ID); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 79 | |
| 80 | if (check_bridge(vendor & 0xffff, vendor >> 16)) |
| 81 | return; |
| 82 | } |
| 83 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 84 | } |
| 85 | } |
| 86 | } |