fixup_pci.c revision 129876
169783Smsmith/*- 269783Smsmith * Copyright (c) 1994,1995 Stefan Esser, Wolfgang StanglMeier 369783Smsmith * Copyright (c) 2000 Michael Smith <msmith@freebsd.org> 469783Smsmith * Copyright (c) 2000 BSDi 569783Smsmith * All rights reserved. 669783Smsmith * 769783Smsmith * Redistribution and use in source and binary forms, with or without 869783Smsmith * modification, are permitted provided that the following conditions 969783Smsmith * are met: 1069783Smsmith * 1. Redistributions of source code must retain the above copyright 1169783Smsmith * notice, this list of conditions and the following disclaimer. 1269783Smsmith * 2. Redistributions in binary form must reproduce the above copyright 1369783Smsmith * notice, this list of conditions and the following disclaimer in the 1469783Smsmith * documentation and/or other materials provided with the distribution. 1569783Smsmith * 3. The name of the author may not be used to endorse or promote products 1669783Smsmith * derived from this software without specific prior written permission. 1769783Smsmith * 1869783Smsmith * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1969783Smsmith * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2069783Smsmith * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2169783Smsmith * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 2269783Smsmith * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2369783Smsmith * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2469783Smsmith * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2569783Smsmith * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2669783Smsmith * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2769783Smsmith * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2869783Smsmith * SUCH DAMAGE. 2969783Smsmith */ 3069783Smsmith 31119418Sobrien#include <sys/cdefs.h> 32119418Sobrien__FBSDID("$FreeBSD: head/sys/dev/pci/fixup_pci.c 129876 2004-05-30 17:57:46Z phk $"); 33119418Sobrien 3469783Smsmith#include <sys/param.h> 35129876Sphk#include <sys/kernel.h> 36129876Sphk#include <sys/malloc.h> 37129876Sphk#include <sys/module.h> 3869783Smsmith#include <sys/systm.h> 3969783Smsmith#include <sys/bus.h> 4069783Smsmith 41119285Simp#include <dev/pci/pcivar.h> 42119285Simp#include <dev/pci/pcireg.h> 4369783Smsmith 4469783Smsmith/* 4569783Smsmith * Chipset fixups. 4669783Smsmith * 4769783Smsmith * These routines are invoked during the probe phase for devices which 4869783Smsmith * typically don't have specific device drivers, but which require 4969783Smsmith * some cleaning up. 5069783Smsmith */ 5169783Smsmith 5269783Smsmithstatic int fixup_pci_probe(device_t dev); 5369783Smsmithstatic void fixwsc_natoma(device_t dev); 5469783Smsmith 5569783Smsmithstatic device_method_t fixup_pci_methods[] = { 5669783Smsmith /* Device interface */ 5769783Smsmith DEVMETHOD(device_probe, fixup_pci_probe), 5869783Smsmith DEVMETHOD(device_attach, bus_generic_attach), 5969783Smsmith { 0, 0 } 6069783Smsmith}; 6169783Smsmith 6269783Smsmithstatic driver_t fixup_pci_driver = { 6369783Smsmith "fixup_pci", 6469783Smsmith fixup_pci_methods, 6569783Smsmith 0, 6669783Smsmith}; 6769783Smsmith 6869783Smsmithstatic devclass_t fixup_pci_devclass; 6969783Smsmith 7069783SmsmithDRIVER_MODULE(fixup_pci, pci, fixup_pci_driver, fixup_pci_devclass, 0, 0); 7169783Smsmith 7269783Smsmithstatic int 7369783Smsmithfixup_pci_probe(device_t dev) 7469783Smsmith{ 7569783Smsmith switch (pci_get_devid(dev)) { 7669783Smsmith case 0x12378086: /* Intel 82440FX (Natoma) */ 7769783Smsmith fixwsc_natoma(dev); 7869783Smsmith break; 7969783Smsmith } 8069783Smsmith return(ENXIO); 8169783Smsmith} 8269783Smsmith 8369783Smsmithstatic void 8469783Smsmithfixwsc_natoma(device_t dev) 8569783Smsmith{ 8669783Smsmith int pmccfg; 8769783Smsmith 8869783Smsmith pmccfg = pci_read_config(dev, 0x50, 2); 8969783Smsmith#if defined(SMP) 9069783Smsmith if (pmccfg & 0x8000) { 9169783Smsmith printf("Correcting Natoma config for SMP\n"); 9269783Smsmith pmccfg &= ~0x8000; 9377649Speter pci_write_config(dev, 0x50, pmccfg, 2); 9469783Smsmith } 9569783Smsmith#else 9669783Smsmith if ((pmccfg & 0x8000) == 0) { 9769783Smsmith printf("Correcting Natoma config for non-SMP\n"); 9869783Smsmith pmccfg |= 0x8000; 9977649Speter pci_write_config(dev, 0x50, pmccfg, 2); 10069783Smsmith } 10169783Smsmith#endif 10269783Smsmith} 103