1 /**************************************************************************
3 ** $FreeBSD: src/sys/pci/pcisupport.c,v 1.154.2.15 2003/04/29 15:55:06 simokawa Exp $
4 ** $DragonFly: src/sys/bus/pci/pcisupport.c,v 1.20 2006/12/22 23:12:17 swildner Exp $
6 ** Device driver for DEC/INTEL PCI chipsets.
10 **-------------------------------------------------------------------------
12 ** Written for FreeBSD by
13 ** wolf@cologne.de Wolfgang Stanglmeier
14 ** se@mi.Uni-Koeln.de Stefan Esser
16 **-------------------------------------------------------------------------
18 ** Copyright (c) 1994,1995 Stefan Esser. All rights reserved.
20 ** Redistribution and use in source and binary forms, with or without
21 ** modification, are permitted provided that the following conditions
23 ** 1. Redistributions of source code must retain the above copyright
24 ** notice, this list of conditions and the following disclaimer.
25 ** 2. Redistributions in binary form must reproduce the above copyright
26 ** notice, this list of conditions and the following disclaimer in the
27 ** documentation and/or other materials provided with the distribution.
28 ** 3. The name of the author may not be used to endorse or promote products
29 ** derived from this software without specific prior written permission.
31 ** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
32 ** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
33 ** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
34 ** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
35 ** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
36 ** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
37 ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
38 ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
39 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
40 ** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
42 ***************************************************************************
48 #include <sys/param.h>
49 #include <sys/systm.h>
50 #include <sys/malloc.h>
51 #include <sys/kernel.h>
59 #include <vm/vm_object.h>
63 #include "pcib_private.h"
65 /*---------------------------------------------------------
67 ** Intel chipsets for 486 / Pentium processor
69 **---------------------------------------------------------
73 fixbushigh_i1225(device_t dev
)
77 sublementarybus
= pci_read_config(dev
, 0x41, 1);
78 if (sublementarybus
!= 0xff) {
79 pci_set_secondarybus(dev
, sublementarybus
+ 1);
80 pci_set_subordinatebus(dev
, sublementarybus
+ 1);
85 fixwsc_natoma(device_t dev
)
89 pmccfg
= pci_read_config(dev
, 0x50, 2);
91 if (pmccfg
& 0x8000) {
92 kprintf("Correcting Natoma config for SMP\n");
94 pci_write_config(dev
, 0x50, pmccfg
, 2);
97 if ((pmccfg
& 0x8000) == 0) {
98 kprintf("Correcting Natoma config for non-SMP\n");
100 pci_write_config(dev
, 0x50, pmccfg
, 2);
106 pci_bridge_type(device_t dev
)
108 char *descr
, tmpbuf
[120];
110 if (pci_get_class(dev
) != PCIC_BRIDGE
)
113 switch (pci_get_subclass(dev
)) {
114 case PCIS_BRIDGE_HOST
: strcpy(tmpbuf
, "Host to PCI"); break;
115 case PCIS_BRIDGE_ISA
: strcpy(tmpbuf
, "PCI to ISA"); break;
116 case PCIS_BRIDGE_EISA
: strcpy(tmpbuf
, "PCI to EISA"); break;
117 case PCIS_BRIDGE_MCA
: strcpy(tmpbuf
, "PCI to MCA"); break;
118 case PCIS_BRIDGE_PCI
: strcpy(tmpbuf
, "PCI to PCI"); break;
119 case PCIS_BRIDGE_PCMCIA
: strcpy(tmpbuf
, "PCI to PCMCIA"); break;
120 case PCIS_BRIDGE_NUBUS
: strcpy(tmpbuf
, "PCI to NUBUS"); break;
121 case PCIS_BRIDGE_CARDBUS
: strcpy(tmpbuf
, "PCI to CardBus"); break;
122 case PCIS_BRIDGE_OTHER
: strcpy(tmpbuf
, "PCI to Other"); break;
124 ksnprintf(tmpbuf
, sizeof(tmpbuf
),
125 "PCI to 0x%x", pci_get_subclass(dev
));
128 ksnprintf(tmpbuf
+strlen(tmpbuf
), sizeof(tmpbuf
)-strlen(tmpbuf
),
129 " bridge (vendor=%04x device=%04x)",
130 pci_get_vendor(dev
), pci_get_device(dev
));
131 descr
= kmalloc (strlen(tmpbuf
) +1, M_DEVBUF
, M_WAITOK
);
132 strcpy(descr
, tmpbuf
);
137 pci_usb_match(device_t dev
)
139 switch (pci_get_devid(dev
)) {
141 /* Intel -- vendor 0x8086 */
143 return ("Intel 82371SB (PIIX3) USB controller");
145 return ("Intel 82371AB/EB (PIIX4) USB controller");
147 return ("Intel 82801AA (ICH) USB controller");
149 return ("Intel 82801AB (ICH0) USB controller");
151 return ("Intel 82801BA/BAM (ICH2) USB controller USB-A");
153 return ("Intel 82801BA/BAM (ICH2) USB controller USB-B");
155 /* VIA Technologies -- vendor 0x1106 (0x1107 on the Apollo Master) */
157 return ("VIA 83C572 USB controller");
159 /* AcerLabs -- vendor 0x10b9 */
161 return ("AcerLabs M5237 (Aladdin-V) USB controller");
163 /* OPTi -- vendor 0x1045 */
165 return ("OPTi 82C861 (FireLink) USB controller");
167 /* NEC -- vendor 0x1033 */
169 return ("NEC uPD 9210 USB controller");
171 /* CMD Tech -- vendor 0x1095 */
173 return ("CMD Tech 670 (USB0670) USB controller");
175 return ("CMD Tech 673 (USB0673) USB controller");
178 if (pci_get_class(dev
) == PCIC_SERIALBUS
179 && pci_get_subclass(dev
) == PCIS_SERIALBUS_USB
) {
180 if (pci_get_progif(dev
) == 0x00 /* UHCI */ ) {
181 return ("UHCI USB controller");
182 } else if (pci_get_progif(dev
) == 0x10 /* OHCI */ ) {
183 return ("OHCI USB controller");
185 return ("USB controller");
192 pci_ata_match(device_t dev
)
195 switch (pci_get_devid(dev
)) {
197 /* Intel -- vendor 0x8086 */
199 return ("Intel PIIX ATA controller");
201 return ("Intel PIIX3 ATA controller");
203 return ("Intel PIIX4 ATA controller");
205 return ("Intel 82371MX mobile PCI ATA accelerator (MPIIX)");
207 /* Promise -- vendor 0x105a */
209 return ("Promise Ultra/33 ATA controller");
211 return ("Promise Ultra/66 ATA controller");
213 /* AcerLabs -- vendor 0x10b9 */
215 return ("AcerLabs Aladdin ATA controller");
217 /* VIA Technologies -- vendor 0x1106 (0x1107 on the Apollo Master) */
219 switch (pci_read_config(dev
, 0x08, 1)) {
221 return ("VIA 85C586 ATA controller");
223 return ("VIA 85C586 ATA controller");
227 return ("VIA Apollo ATA controller");
229 /* CMD Tech -- vendor 0x1095 */
231 return ("CMD 640 ATA controller");
233 return ("CMD 646 ATA controller");
235 /* Cypress -- vendor 0x1080 */
237 return ("Cypress 82C693 ATA controller");
239 /* Cyrix -- vendor 0x1078 */
241 return ("Cyrix 5530 ATA controller");
243 /* SiS -- vendor 0x1039 */
245 return ("SiS 5591 ATA controller");
247 /* Highpoint tech -- vendor 0x1103 */
249 return ("HighPoint HPT366 ATA controller");
252 if (pci_get_class(dev
) == PCIC_STORAGE
&&
253 pci_get_subclass(dev
) == PCIS_STORAGE_IDE
)
254 return ("Unknown PCI ATA controller");
261 pci_chip_match(device_t dev
)
265 switch (pci_get_devid(dev
)) {
266 /* Intel -- vendor 0x8086 */
268 /* Silently ignore this one! What is it, anyway ??? */
272 * On my laptop (Tecra 8000DVD), this device has a
273 * bogus subclass 0x80 so make sure that it doesn't
274 * match the generic 'chip' driver by accident.
278 fixbushigh_i1225(dev
);
279 return ("Intel 824?? host to PCI bridge");
281 return ("Intel 82443LX (440 LX) host to PCI bridge");
283 return ("Intel 82443BX (440 BX) host to PCI bridge");
285 return ("Intel 82443BX host to PCI bridge (AGP disabled)");
287 return ("Intel 82443GX host to PCI bridge");
289 return ("Intel 82443GX host to AGP bridge");
291 return ("Intel 82443GX host to PCI bridge (AGP disabled)");
293 return ("Intel 82454KX/GX (Orion) host to PCI bridge");
295 return ("Intel 82451NX Memory and I/O controller");
297 return ("Intel 82425EX PCI system controller");
299 return ("Intel 82424ZX (Saturn) cache DRAM controller");
301 rev
= pci_get_revid(dev
);
302 if (rev
== 16 || rev
== 17)
303 return ("Intel 82434NX (Neptune) PCI cache memory controller");
304 return ("Intel 82434LX (Mercury) PCI cache memory controller");
306 return ("Intel 82437FX PCI cache memory controller");
308 return ("Intel 82437MX mobile PCI cache memory controller");
310 return ("Intel 82439HX PCI cache memory controller");
312 return ("Intel 82437VX PCI cache memory controller");
314 return ("Intel 82439TX System controller (MTXC)");
316 return ("Intel 82371AB Power management controller");
318 return ("Intel 82443MX Power management controller");
321 return ("Intel 82440FX (Natoma) PCI and memory controller");
323 return ("Intel 82453KX/GX (Orion) PCI memory controller");
325 return ("Intel 82810 (i810 GMCH) Host To Hub bridge");
327 return ("Intel 82810-DC100 (i810-DC100 GMCH) Host To Hub bridge");
329 return ("Intel 82810E (i810E GMCH) Host To Hub bridge");
331 return ("Intel 82801AA (ICH) AC'97 Audio Controller");
333 return ("Intel 82801AB (ICH0) AC'97 Audio Controller");
335 /* Sony -- vendor 0x104d */
337 return ("Sony CXD1947A FireWire Host Controller");
339 /* SiS -- vendor 0x1039 */
341 return ("SiS 85c496 PCI/VL Bridge");
343 return ("SiS 85c501");
345 return ("SiS 85c601");
347 return ("SiS 5591 host to PCI bridge");
349 return ("SiS 5591 host to AGP bridge");
351 /* VLSI -- vendor 0x1004 */
353 return ("VLSI 82C592 Host to PCI bridge");
355 return ("VLSI 82C532 Eagle II Peripheral controller");
357 return ("VLSI 82C535 Eagle II System controller");
359 return ("VLSI 82C147 IrDA controller");
361 /* VIA Technologies -- vendor 0x1106 (0x1107 on the Apollo Master) */
363 return ("VIA 82C570 (Apollo Master) system controller");
365 return ("VIA 82C585 (Apollo VP1/VPX) system controller");
368 return ("VIA 82C595 (Apollo VP2) system controller");
370 return ("VIA 82C597 (Apollo VP3) system controller");
371 /* XXX Here is MVP3, I got the datasheet but NO M/B to test it */
372 /* totally. Please let me know if anything wrong. -F */
373 /* XXX need info on the MVP3 -- any takers? */
375 return ("VIA 82C598MVP (Apollo MVP3) host bridge");
381 return ("VIA 82C686 AC97 Audio");
383 return ("VIA 82C686 AC97 Modem");
385 /* AMD -- vendor 0x1022 */
387 return ("AMD-751 host to PCI bridge");
389 return ("AMD-761 host to PCI bridge");
391 /* AcerLabs -- vendor 0x10b9 */
392 /* Funny : The datasheet told me vendor id is "10b8",sub-vendor */
393 /* id is '10b9" but the register always shows "10b9". -Foxfair */
395 return ("AcerLabs M1541 (Aladdin-V) PCI host bridge");
397 return ("AcerLabs M15x3 Power Management Unit");
399 /* OPTi -- vendor 0x1045 */
401 return ("Opti 82C557 (Viper-M) host to PCI bridge");
403 return ("Opti 82C558 (Viper-M) ISA+IDE");
405 return ("OPTi 82C822 host to PCI Bridge");
407 /* Texas Instruments -- vendor 0x104c */
409 return ("Texas Instruments PCI1225 CardBus controller");
411 return ("Texas Instruments PCI1410 CardBus controller");
413 return ("Texas Instruments PCI1420 CardBus controller");
415 return ("Texas Instruments PCI1450 CardBus controller");
417 return ("Texas Instruments PCI1451 CardBus controller");
419 /* NeoMagic -- vendor 0x10c8 */
421 return ("NeoMagic MagicMedia 256AX Audio controller");
423 return ("NeoMagic MagicMedia 256ZX Audio controller");
425 /* ESS Technology Inc -- vendor 0x125d */
427 return ("ESS Technology Maestro 2E Audio controller");
429 /* Toshiba -- vendor 0x1179 */
431 return ("Toshiba Fast Infra Red controller");
434 if (pci_get_class(dev
) == PCIC_BRIDGE
435 && pci_get_subclass(dev
) != PCIS_BRIDGE_PCI
436 && pci_get_subclass(dev
) != PCIS_BRIDGE_ISA
437 && pci_get_subclass(dev
) != PCIS_BRIDGE_EISA
)
438 return pci_bridge_type(dev
);
443 /*---------------------------------------------------------
445 ** Catchall driver for VGA devices
447 ** By Garrett Wollman
448 ** <wollman@halloran-eldar.lcs.mit.edu>
450 **---------------------------------------------------------
454 pci_vga_match(device_t dev
)
456 u_int id
= pci_get_devid(dev
);
457 const char *vendor
, *chip
, *type
;
459 vendor
= chip
= type
= 0;
460 switch (id
& 0xffff) {
465 chip
= "i740"; break;
472 chip
= "MagicGraph 128ZV"; break;
474 chip
= "MagicGraph 128XD"; break;
476 chip
= "MagicMedia 256AV"; break;
478 chip
= "MagicMedia 256ZX"; break;
483 type
= "graphics accelerator";
486 chip
= "Voodoo"; break;
488 chip
= "Voodoo 2"; break;
490 chip
= "Voodoo Banshee"; break;
492 chip
= "Voodoo 3"; break;
497 type
= "graphics accelerator";
500 chip
= "MGA 2085PX"; break;
502 chip
= "MGA Millennium 2064W"; break;
504 chip
= "MGA 1024SG/1064SG/1164SG"; break;
506 chip
= "MGA Millennium II 2164W"; break;
508 chip
= "MGA Millennium II 2164WA-B AG"; break;
510 chip
= "MGA G200"; break;
512 chip
= "MGA G200 AGP"; break;
514 chip
= "MGA G400 AGP"; break;
516 chip
= "MGA Impression"; break;
518 chip
= "MGA G100"; break;
520 chip
= "MGA G100 AGP"; break;
522 chip
= "MGA G550 AGP"; break;
528 type
= "graphics accelerator";
531 chip
= "Mach32"; break;
533 chip
= "Mach64-CT"; break;
535 chip
= "Mach64-CX"; break;
537 chip
= "Mach64-ET"; break;
540 chip
= "Mach64-VT"; break;
542 chip
= "Mach64-GB"; break;
544 chip
= "Mach64-GD"; break;
546 chip
= "Mach64-GI"; break;
548 chip
= "Mach64-GM"; break;
550 chip
= "Mach64-GN"; break;
552 chip
= "Mach64-GO"; break;
554 chip
= "Mach64-GP"; break;
556 chip
= "Mach64-GQ"; break;
558 chip
= "Mach64-GR"; break;
560 chip
= "Mach64-GS"; break;
562 chip
= "Mach64-GT"; break;
564 chip
= "Mach64-GU"; break;
566 chip
= "Mach64-GV"; break;
568 chip
= "Mach64-GW"; break;
570 chip
= "Mach64-GX"; break;
572 chip
= "Mobility-1"; break;
574 chip
= "RageMobility-P/M"; break;
576 chip
= "Mach64-GZ"; break;
578 chip
= "Rage128-RE"; break;
580 chip
= "Rage128-RF"; break;
582 chip
= "Rage128-RK"; break;
584 chip
= "Rage128-RL"; break;
588 vendor
= "Avance Logic";
591 chip
= "ALG2301"; break;
593 chip
= "ALG2302"; break;
597 vendor
= "Tseng Labs";
598 type
= "graphics accelerator";
604 chip
= "ET4000 W32P"; break;
606 chip
= "ET6000/ET6100"; break;
608 chip
= "ET6300"; break;
613 type
= "graphics accelerator";
616 chip
= "P9000"; break;
618 chip
= "P9100"; break;
622 vendor
= "Cirrus Logic";
625 chip
= "GD7548"; break;
627 chip
= "GD7555"; break;
629 chip
= "GD7556"; break;
631 chip
= "GD5430"; break;
634 chip
= "GD5434"; break;
636 chip
= "GD5436"; break;
638 chip
= "GD5446"; break;
640 chip
= "GD5480"; break;
642 chip
= "GD5462"; break;
645 chip
= "GD5464"; break;
647 chip
= "GD5465"; break;
649 chip
= "GD7542"; break;
651 chip
= "GD7543"; break;
653 chip
= "GD7541"; break;
658 break; /* let default deal with it */
660 vendor
= "Chips & Technologies";
663 chip
= "64310"; break;
665 chip
= "65545"; break;
667 chip
= "65548"; break;
669 chip
= "69000"; break;
671 chip
= "65550"; break;
673 chip
= "65554"; break;
675 chip
= "65555"; break;
677 chip
= "68554"; break;
684 chip
= "86c201"; break;
686 chip
= "86c202"; break;
688 chip
= "86c205"; break;
690 chip
= "86c215"; break;
692 chip
= "86c225"; break;
694 chip
= "5597/98"; break;
696 chip
= "6326"; break;
698 chip
= "530/620"; break;
702 vendor
= "Number Nine";
703 type
= "graphics accelerator";
706 chip
= "Imagine 128"; break;
708 chip
= "Imagine 128 II"; break;
715 chip
= "PM6410"; break;
717 chip
= "PM6422"; break;
719 chip
= "PMAT24"; break;
723 vendor
= "Rendition Verite";
726 chip
= "V1000"; break;
728 chip
= "V2000"; break;
732 vendor
= "Sigma Designs";
733 if ((id
>> 16) == 0x6401)
734 chip
= "REALmagic64/GX";
738 type
= "graphics accelerator";
741 chip
= "Trio"; break;
743 chip
= "Aurora 64"; break;
745 chip
= "Trio 64UV+"; break;
747 chip
= "Trio 64V2/DX/GX"; break;
749 chip
= "Plato"; break;
751 chip
= "Trio3D"; break;
765 chip
= "ViRGE"; break;
767 chip
= "ViRGE VX"; break;
769 chip
= "ViRGE DX/GX"; break;
771 chip
= "ViRGE GX2"; break;
773 chip
= "Trio3D/2X"; break;
776 chip
= "Savage3D"; break;
778 chip
= "Savage 4"; break;
780 chip
= "ViRGE MX"; break;
782 chip
= "ViRGE MX+"; break;
786 vendor
= "ARK Logic";
789 chip
= "1000PV"; break;
791 chip
= "2000PV"; break;
793 chip
= "2000MT"; break;
795 chip
= "2000MI"; break;
800 type
= "graphics accelerator";
803 chip
= "300SX"; break;
805 chip
= "500TX"; break;
807 chip
= "Delta"; break;
809 chip
= "PerMedia"; break;
814 type
= "graphics accelerator";
819 chip
= "Riva TNT"; break;
821 chip
= "Riva TNT2"; break;
823 chip
= "Riva Ultra TNT2"; break;
825 chip
= "Riva Vanta TNT2"; break;
827 chip
= "Riva Ultra Vanta TNT2"; break;
829 chip
= "Riva Integrated TNT2"; break;
831 chip
= "GeForce 256"; break;
833 chip
= "GeForce DDR"; break;
835 chip
= "Quadro"; break;
839 chip
= "GeForce2 GTS"; break;
841 chip
= "Quadro2"; break;
845 vendor
= "NVidia/SGS-Thomson";
846 type
= "graphics accelerator";
849 chip
= "Riva128"; break;
853 vendor
= "SGS-Thomson";
856 chip
= "STG2000"; break;
863 chip
= "82810 (i810 GMCH)"; break;
865 chip
= "82810-DC100 (i810-DC100 GMCH)"; break;
867 chip
= "82810E (i810E GMCH)"; break;
869 chip
= "i740 AGP"; break;
873 vendor
= "Intergraphics";
876 chip
= "IGA-1680"; break;
878 chip
= "IGA-1682"; break;
883 if (vendor
&& chip
) {
888 type
= "SVGA controller";
890 len
= strlen(vendor
) + strlen(chip
) + strlen(type
) + 4;
891 MALLOC(buf
, char *, len
, M_TEMP
, M_WAITOK
);
892 ksprintf(buf
, "%s %s %s", vendor
, chip
, type
);
896 switch (pci_get_class(dev
)) {
899 if (pci_get_subclass(dev
) != PCIS_OLD_VGA
)
902 type
= "VGA-compatible display device";
907 if (pci_get_subclass(dev
) == PCIS_DISPLAY_VGA
)
908 type
= "VGA-compatible display device";
911 * If it isn't a vga display device,
912 * don't pretend we found one.
923 * If we got here, we know for sure it's some sort of display
924 * device, but we weren't able to identify it specifically.
925 * At a minimum we can return the type, but we'd like to
926 * identify the vendor and chip ID if at all possible.
927 * (Some of the checks above intentionally don't bother for
928 * vendors where we know the chip ID is the same as the
935 len
= strlen(vendor
) + 7 + 4 + 1 + strlen(type
) + 1;
936 MALLOC(buf
, char *, len
, M_TEMP
, M_WAITOK
);
937 ksprintf(buf
, "%s model %04x %s", vendor
, id
>> 16, type
);
943 /*---------------------------------------------------------
947 **---------------------------------------------------------
951 ign_match(device_t dev
)
953 switch (pci_get_devid(dev
)) {
955 case 0x10001042ul
: /* wd */
956 return ("SMC FDC 37c665");
963 ign_probe(device_t dev
)
969 device_set_desc(dev
, s
);
977 ign_attach(device_t dev
)
982 static device_method_t ign_methods
[] = {
983 /* Device interface */
984 DEVMETHOD(device_probe
, ign_probe
),
985 DEVMETHOD(device_attach
, ign_attach
),
990 static driver_t ign_driver
= {
996 static devclass_t ign_devclass
;
998 DRIVER_MODULE(ign
, pci
, ign_driver
, ign_devclass
, 0, 0);