| 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> | 
 | 8 | #include <asm/pci-direct.h> | 
 | 9 | #include <asm/acpi.h> | 
 | 10 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 11 | static int __init check_bridge(int vendor, int device) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | { | 
 | 13 | 	/* According to Nvidia all timer overrides are bogus. Just ignore | 
 | 14 | 	   them all. */ | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 15 | 	if (vendor == PCI_VENDOR_ID_NVIDIA) { | 
 | 16 | 		acpi_skip_timer_override = 1; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | 	} | 
 | 18 | 	return 0; | 
 | 19 | } | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 20 |  | 
 | 21 | void __init check_acpi_pci(void) | 
 | 22 | { | 
 | 23 | 	int num, slot, func; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 |  | 
 | 25 | 	/* Assume the machine supports type 1. If not it will  | 
 | 26 | 	   always read ffffffff and should not have any side effect. */ | 
 | 27 |  | 
 | 28 | 	/* Poor man's PCI discovery */ | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 29 | 	for (num = 0; num < 32; num++) { | 
 | 30 | 		for (slot = 0; slot < 32; slot++) { | 
 | 31 | 			for (func = 0; func < 8; func++) { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | 				u32 class; | 
 | 33 | 				u32 vendor; | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 34 | 				class = read_pci_config(num, slot, func, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | 							PCI_CLASS_REVISION); | 
 | 36 | 				if (class == 0xffffffff) | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 37 | 					break; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 |  | 
 | 39 | 				if ((class >> 16) != PCI_CLASS_BRIDGE_PCI) | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 40 | 					continue; | 
 | 41 |  | 
 | 42 | 				vendor = read_pci_config(num, slot, func, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | 							 PCI_VENDOR_ID); | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 44 |  | 
 | 45 | 				if (check_bridge(vendor & 0xffff, vendor >> 16)) | 
 | 46 | 					return; | 
 | 47 | 			} | 
 | 48 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | 		} | 
 | 50 | 	} | 
 | 51 | } |