fixup_pci.c revision 119285
1141296Sdas/*-
2141296Sdas * Copyright (c) 1994,1995 Stefan Esser, Wolfgang StanglMeier
32116Sjkh * Copyright (c) 2000 Michael Smith <msmith@freebsd.org>
42116Sjkh * Copyright (c) 2000 BSDi
52116Sjkh * All rights reserved.
62116Sjkh *
7141296Sdas * Redistribution and use in source and binary forms, with or without
82116Sjkh * modification, are permitted provided that the following conditions
9141296Sdas * are met:
102116Sjkh * 1. Redistributions of source code must retain the above copyright
112116Sjkh *    notice, this list of conditions and the following disclaimer.
12141296Sdas * 2. Redistributions in binary form must reproduce the above copyright
132116Sjkh *    notice, this list of conditions and the following disclaimer in the
142116Sjkh *    documentation and/or other materials provided with the distribution.
15176451Sdas * 3. The name of the author may not be used to endorse or promote products
16176451Sdas *    derived from this software without specific prior written permission.
172116Sjkh *
182116Sjkh * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
192116Sjkh * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
202116Sjkh * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
212116Sjkh * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
222116Sjkh * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
232116Sjkh * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24271651Skargl * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25271651Skargl * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
262116Sjkh * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
272116Sjkh * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
282116Sjkh * SUCH DAMAGE.
292116Sjkh *
302116Sjkh *	$FreeBSD: head/sys/dev/pci/fixup_pci.c 119285 2003-08-22 06:42:59Z imp $
3197413Salfred */
3297413Salfred
332116Sjkh#include <sys/param.h>
342116Sjkh#include <sys/systm.h>
352116Sjkh#include <sys/malloc.h>
36271651Skargl#include <sys/kernel.h>
37271651Skargl#include <sys/bus.h>
38271651Skargl
39271651Skargl#include <dev/pci/pcivar.h>
40#include <dev/pci/pcireg.h>
41
42/*
43 * Chipset fixups.
44 *
45 * These routines are invoked during the probe phase for devices which
46 * typically don't have specific device drivers, but which require
47 * some cleaning up.
48 */
49
50static int	fixup_pci_probe(device_t dev);
51static void	fixwsc_natoma(device_t dev);
52
53static device_method_t fixup_pci_methods[] = {
54    /* Device interface */
55    DEVMETHOD(device_probe,		fixup_pci_probe),
56    DEVMETHOD(device_attach,		bus_generic_attach),
57    { 0, 0 }
58};
59
60static driver_t fixup_pci_driver = {
61    "fixup_pci",
62    fixup_pci_methods,
63    0,
64};
65
66static devclass_t fixup_pci_devclass;
67
68DRIVER_MODULE(fixup_pci, pci, fixup_pci_driver, fixup_pci_devclass, 0, 0);
69
70static int
71fixup_pci_probe(device_t dev)
72{
73    switch (pci_get_devid(dev)) {
74    case 0x12378086:		/* Intel 82440FX (Natoma) */
75	fixwsc_natoma(dev);
76	break;
77    }
78    return(ENXIO);
79}
80
81static void
82fixwsc_natoma(device_t dev)
83{
84    int		pmccfg;
85
86    pmccfg = pci_read_config(dev, 0x50, 2);
87#if defined(SMP)
88    if (pmccfg & 0x8000) {
89	printf("Correcting Natoma config for SMP\n");
90	pmccfg &= ~0x8000;
91	pci_write_config(dev, 0x50, pmccfg, 2);
92    }
93#else
94    if ((pmccfg & 0x8000) == 0) {
95	printf("Correcting Natoma config for non-SMP\n");
96	pmccfg |= 0x8000;
97	pci_write_config(dev, 0x50, pmccfg, 2);
98    }
99#endif
100}
101