1 /*- 2 * Copyright (c) 1994,1995 Stefan Esser, Wolfgang StanglMeier 3 * Copyright (c) 2000 Michael Smith <msmith@freebsd.org> 4 * Copyright (c) 2000 BSDi 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 3. The name of the author may not be used to endorse or promote products 16 * derived from this software without specific prior written permission. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 * SUCH DAMAGE. 29 */ 30 31 #include <sys/cdefs.h> 32 __FBSDID("$FreeBSD$"); 33 34 #include <sys/param.h> 35 #include <sys/systm.h> 36 #include <sys/malloc.h> 37 #include <sys/kernel.h> 38 #include <sys/bus.h> 39 40 #include <dev/pci/pcivar.h> 41 #include <dev/pci/pcireg.h> 42 43 /* 44 * Chipset fixups. 45 * 46 * These routines are invoked during the probe phase for devices which 47 * typically don't have specific device drivers, but which require 48 * some cleaning up. 49 */ 50 51 static int fixup_pci_probe(device_t dev); 52 static void fixwsc_natoma(device_t dev); 53 54 static device_method_t fixup_pci_methods[] = { 55 /* Device interface */ 56 DEVMETHOD(device_probe, fixup_pci_probe), 57 DEVMETHOD(device_attach, bus_generic_attach), 58 { 0, 0 } 59 }; 60 61 static driver_t fixup_pci_driver = { 62 "fixup_pci", 63 fixup_pci_methods, 64 0, 65 }; 66 67 static devclass_t fixup_pci_devclass; 68 69 DRIVER_MODULE(fixup_pci, pci, fixup_pci_driver, fixup_pci_devclass, 0, 0); 70 71 static int 72 fixup_pci_probe(device_t dev) 73 { 74 switch (pci_get_devid(dev)) { 75 case 0x12378086: /* Intel 82440FX (Natoma) */ 76 fixwsc_natoma(dev); 77 break; 78 } 79 return(ENXIO); 80 } 81 82 static void 83 fixwsc_natoma(device_t dev) 84 { 85 int pmccfg; 86 87 pmccfg = pci_read_config(dev, 0x50, 2); 88 #if defined(SMP) 89 if (pmccfg & 0x8000) { 90 printf("Correcting Natoma config for SMP\n"); 91 pmccfg &= ~0x8000; 92 pci_write_config(dev, 0x50, pmccfg, 2); 93 } 94 #else 95 if ((pmccfg & 0x8000) == 0) { 96 printf("Correcting Natoma config for non-SMP\n"); 97 pmccfg |= 0x8000; 98 pci_write_config(dev, 0x50, pmccfg, 2); 99 } 100 #endif 101 } 102