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> |
Siddha, Suresh B | b0d0a4b | 2006-12-07 02:14:10 +0100 | [diff] [blame] | 13 | #include <asm/irq.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | |
Andy Currid | d44647b | 2006-06-08 00:43:38 -0700 | [diff] [blame] | 15 | #ifdef CONFIG_ACPI |
| 16 | |
Alexey Starikovskiy | ceb6c46 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 17 | static int __init nvidia_hpet_check(struct acpi_table_header *header) |
Andy Currid | d44647b | 2006-06-08 00:43:38 -0700 | [diff] [blame] | 18 | { |
Andy Currid | d44647b | 2006-06-08 00:43:38 -0700 | [diff] [blame] | 19 | return 0; |
| 20 | } |
| 21 | #endif |
| 22 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 23 | static int __init check_bridge(int vendor, int device) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | { |
Andi Kleen | f9262c1 | 2006-03-08 17:57:25 -0800 | [diff] [blame] | 25 | #ifdef CONFIG_ACPI |
Andy Currid | d44647b | 2006-06-08 00:43:38 -0700 | [diff] [blame] | 26 | /* According to Nvidia all timer overrides are bogus unless HPET |
| 27 | is enabled. */ |
Andi Kleen | fa18f47 | 2006-11-14 16:57:46 +0100 | [diff] [blame] | 28 | if (!acpi_use_timer_override && vendor == PCI_VENDOR_ID_NVIDIA) { |
Dave Jones | d0035ae | 2007-03-08 23:47:35 -0500 | [diff] [blame] | 29 | if (acpi_table_parse(ACPI_SIG_HPET, nvidia_hpet_check)) { |
Andy Currid | d44647b | 2006-06-08 00:43:38 -0700 | [diff] [blame] | 30 | acpi_skip_timer_override = 1; |
Andi Kleen | fa18f47 | 2006-11-14 16:57:46 +0100 | [diff] [blame] | 31 | printk(KERN_INFO "Nvidia board " |
| 32 | "detected. Ignoring ACPI " |
| 33 | "timer override.\n"); |
| 34 | printk(KERN_INFO "If you got timer trouble " |
| 35 | "try acpi_use_timer_override\n"); |
| 36 | |
Andy Currid | d44647b | 2006-06-08 00:43:38 -0700 | [diff] [blame] | 37 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | } |
Andi Kleen | f9262c1 | 2006-03-08 17:57:25 -0800 | [diff] [blame] | 39 | #endif |
| 40 | if (vendor == PCI_VENDOR_ID_ATI && timer_over_8254 == 1) { |
| 41 | timer_over_8254 = 0; |
| 42 | printk(KERN_INFO "ATI board detected. Disabling timer routing " |
| 43 | "over 8254.\n"); |
| 44 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | return 0; |
| 46 | } |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 47 | |
Siddha, Suresh B | b0d0a4b | 2006-12-07 02:14:10 +0100 | [diff] [blame] | 48 | static void check_intel(void) |
| 49 | { |
| 50 | u16 vendor, device; |
| 51 | |
| 52 | vendor = read_pci_config_16(0, 0, 0, PCI_VENDOR_ID); |
| 53 | |
| 54 | if (vendor != PCI_VENDOR_ID_INTEL) |
| 55 | return; |
| 56 | |
| 57 | device = read_pci_config_16(0, 0, 0, PCI_DEVICE_ID); |
| 58 | #ifdef CONFIG_SMP |
| 59 | if (device == PCI_DEVICE_ID_INTEL_E7320_MCH || |
| 60 | device == PCI_DEVICE_ID_INTEL_E7520_MCH || |
| 61 | device == PCI_DEVICE_ID_INTEL_E7525_MCH) |
| 62 | quirk_intel_irqbalance(); |
| 63 | #endif |
| 64 | } |
| 65 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 66 | void __init check_acpi_pci(void) |
| 67 | { |
| 68 | int num, slot, func; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | |
| 70 | /* Assume the machine supports type 1. If not it will |
Andi Kleen | 0637a70 | 2006-09-26 10:52:41 +0200 | [diff] [blame] | 71 | always read ffffffff and should not have any side effect. |
| 72 | Actually a few buggy systems can machine check. Allow the user |
| 73 | to disable it by command line option at least -AK */ |
| 74 | if (!early_pci_allowed()) |
| 75 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | |
Siddha, Suresh B | b0d0a4b | 2006-12-07 02:14:10 +0100 | [diff] [blame] | 77 | check_intel(); |
| 78 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 79 | /* Poor man's PCI discovery */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 80 | for (num = 0; num < 32; num++) { |
| 81 | for (slot = 0; slot < 32; slot++) { |
| 82 | for (func = 0; func < 8; func++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 83 | u32 class; |
| 84 | u32 vendor; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 85 | class = read_pci_config(num, slot, func, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 86 | PCI_CLASS_REVISION); |
| 87 | if (class == 0xffffffff) |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 88 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 89 | |
| 90 | if ((class >> 16) != PCI_CLASS_BRIDGE_PCI) |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 91 | continue; |
| 92 | |
| 93 | vendor = read_pci_config(num, slot, func, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 94 | PCI_VENDOR_ID); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 95 | |
| 96 | if (check_bridge(vendor & 0xffff, vendor >> 16)) |
| 97 | return; |
| 98 | } |
| 99 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 100 | } |
| 101 | } |
| 102 | } |