Split off the PCI-PCI bridge and the PCI-ISA bridge code from
[dragonfly.git] / sys / bus / pci / pcisupport.c
1 /**************************************************************************
2 **
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.13 2004/02/24 15:21:25 joerg Exp $
5 **
6 **  Device driver for DEC/INTEL PCI chipsets.
7 **
8 **  FreeBSD
9 **
10 **-------------------------------------------------------------------------
11 **
12 **  Written for FreeBSD by
13 **      wolf@cologne.de         Wolfgang Stanglmeier
14 **      se@mi.Uni-Koeln.de      Stefan Esser
15 **
16 **-------------------------------------------------------------------------
17 **
18 ** Copyright (c) 1994,1995 Stefan Esser.  All rights reserved.
19 **
20 ** Redistribution and use in source and binary forms, with or without
21 ** modification, are permitted provided that the following conditions
22 ** are met:
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.
30 **
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.
41 **
42 ***************************************************************************
43 */
44
45 #include "opt_bus.h"
46 #include "opt_pci.h"
47
48 #include <sys/param.h>
49 #include <sys/systm.h>
50 #include <sys/malloc.h>
51 #include <sys/kernel.h>
52 #include <sys/bus.h>
53 #include <sys/rman.h>
54
55 #include <machine/resource.h>
56
57 #include "pcivar.h"
58 #include "pcireg.h"
59
60 #include <vm/vm.h>
61 #include <vm/vm_object.h>
62 #include <vm/pmap.h>
63
64 #include "pcib_if.h"
65 #include "pcib_private.h"
66
67 /*---------------------------------------------------------
68 **
69 **      Intel chipsets for 486 / Pentium processor
70 **
71 **---------------------------------------------------------
72 */
73
74 static void
75 fixbushigh_i1225(device_t dev)
76 {
77         int sublementarybus;
78
79         sublementarybus = pci_read_config(dev, 0x41, 1);
80         if (sublementarybus != 0xff) {
81                 pci_set_secondarybus(dev, sublementarybus + 1);
82                 pci_set_subordinatebus(dev, sublementarybus + 1);
83         }
84 }
85
86 static void
87 fixwsc_natoma(device_t dev)
88 {
89         int pmccfg;
90
91         pmccfg = pci_read_config(dev, 0x50, 2);
92 #if defined(SMP)
93         if (pmccfg & 0x8000) {
94                 printf("Correcting Natoma config for SMP\n");
95                 pmccfg &= ~0x8000;
96                 pci_write_config(dev, 0x50, pmccfg, 2);
97         }
98 #else
99         if ((pmccfg & 0x8000) == 0) {
100                 printf("Correcting Natoma config for non-SMP\n");
101                 pmccfg |= 0x8000;
102                 pci_write_config(dev, 0x50, pmccfg, 2);
103         }
104 #endif
105 }
106
107 const char *
108 pci_bridge_type(device_t dev)
109 {
110     char *descr, tmpbuf[120];
111
112     if (pci_get_class(dev) != PCIC_BRIDGE)
113             return NULL;
114
115     switch (pci_get_subclass(dev)) {
116     case PCIS_BRIDGE_HOST:      strcpy(tmpbuf, "Host to PCI"); break;
117     case PCIS_BRIDGE_ISA:       strcpy(tmpbuf, "PCI to ISA"); break;
118     case PCIS_BRIDGE_EISA:      strcpy(tmpbuf, "PCI to EISA"); break;
119     case PCIS_BRIDGE_MCA:       strcpy(tmpbuf, "PCI to MCA"); break;
120     case PCIS_BRIDGE_PCI:       strcpy(tmpbuf, "PCI to PCI"); break;
121     case PCIS_BRIDGE_PCMCIA:    strcpy(tmpbuf, "PCI to PCMCIA"); break;
122     case PCIS_BRIDGE_NUBUS:     strcpy(tmpbuf, "PCI to NUBUS"); break;
123     case PCIS_BRIDGE_CARDBUS:   strcpy(tmpbuf, "PCI to CardBus"); break;
124     case PCIS_BRIDGE_OTHER:     strcpy(tmpbuf, "PCI to Other"); break;
125     default: 
126             snprintf(tmpbuf, sizeof(tmpbuf),
127                      "PCI to 0x%x", pci_get_subclass(dev)); 
128             break;
129     }
130     snprintf(tmpbuf+strlen(tmpbuf), sizeof(tmpbuf)-strlen(tmpbuf),
131              " bridge (vendor=%04x device=%04x)",
132              pci_get_vendor(dev), pci_get_device(dev));
133     descr = malloc (strlen(tmpbuf) +1, M_DEVBUF, M_WAITOK);
134     strcpy(descr, tmpbuf);
135     return descr;
136 }
137
138 const char *
139 pci_usb_match(device_t dev)
140 {
141         switch (pci_get_devid(dev)) {
142
143         /* Intel -- vendor 0x8086 */
144         case 0x70208086:
145                 return ("Intel 82371SB (PIIX3) USB controller");
146         case 0x71128086:
147                 return ("Intel 82371AB/EB (PIIX4) USB controller");
148         case 0x24128086:
149                 return ("Intel 82801AA (ICH) USB controller");
150         case 0x24228086:
151                 return ("Intel 82801AB (ICH0) USB controller");
152         case 0x24428086:
153                 return ("Intel 82801BA/BAM (ICH2) USB controller USB-A");
154         case 0x24448086:
155                 return ("Intel 82801BA/BAM (ICH2) USB controller USB-B");
156
157         /* VIA Technologies -- vendor 0x1106 (0x1107 on the Apollo Master) */
158         case 0x30381106:
159                 return ("VIA 83C572 USB controller");
160
161         /* AcerLabs -- vendor 0x10b9 */
162         case 0x523710b9:
163                 return ("AcerLabs M5237 (Aladdin-V) USB controller");
164
165         /* OPTi -- vendor 0x1045 */
166         case 0xc8611045:
167                 return ("OPTi 82C861 (FireLink) USB controller");
168
169         /* NEC -- vendor 0x1033 */
170         case 0x00351033:
171                 return ("NEC uPD 9210 USB controller");
172
173         /* CMD Tech -- vendor 0x1095 */
174         case 0x06701095:
175                 return ("CMD Tech 670 (USB0670) USB controller");
176         case 0x06731095:
177                 return ("CMD Tech 673 (USB0673) USB controller");
178         }
179
180         if (pci_get_class(dev) == PCIC_SERIALBUS
181             && pci_get_subclass(dev) == PCIS_SERIALBUS_USB) {
182                 if (pci_get_progif(dev) == 0x00 /* UHCI */ ) {
183                         return ("UHCI USB controller");
184                 } else if (pci_get_progif(dev) == 0x10 /* OHCI */ ) {
185                         return ("OHCI USB controller");
186                 } else {
187                         return ("USB controller");
188                 }
189         }
190         return NULL;
191 }
192
193 const char *
194 pci_ata_match(device_t dev)
195 {
196
197         switch (pci_get_devid(dev)) {
198
199         /* Intel -- vendor 0x8086 */
200         case 0x12308086:
201                 return ("Intel PIIX ATA controller");
202         case 0x70108086:
203                 return ("Intel PIIX3 ATA controller");
204         case 0x71118086:
205                 return ("Intel PIIX4 ATA controller");
206         case 0x12348086:
207                 return ("Intel 82371MX mobile PCI ATA accelerator (MPIIX)");
208
209         /* Promise -- vendor 0x105a */
210         case 0x4d33105a:
211                 return ("Promise Ultra/33 ATA controller");
212         case 0x4d38105a:
213                 return ("Promise Ultra/66 ATA controller");
214
215         /* AcerLabs -- vendor 0x10b9 */
216         case 0x522910b9:
217                 return ("AcerLabs Aladdin ATA controller");
218
219         /* VIA Technologies -- vendor 0x1106 (0x1107 on the Apollo Master) */
220         case 0x05711106:
221                 switch (pci_read_config(dev, 0x08, 1)) {
222                 case 1:
223                         return ("VIA 85C586 ATA controller");
224                 case 6:
225                         return ("VIA 85C586 ATA controller");
226                 }
227                 /* FALL THROUGH */
228         case 0x15711106:
229                 return ("VIA Apollo ATA controller");
230
231         /* CMD Tech -- vendor 0x1095 */
232         case 0x06401095:
233                 return ("CMD 640 ATA controller");
234         case 0x06461095:
235                 return ("CMD 646 ATA controller");
236
237         /* Cypress -- vendor 0x1080 */
238         case 0xc6931080:
239                 return ("Cypress 82C693 ATA controller");
240
241         /* Cyrix -- vendor 0x1078 */
242         case 0x01021078:
243                 return ("Cyrix 5530 ATA controller");
244
245         /* SiS -- vendor 0x1039 */
246         case 0x55131039:
247                 return ("SiS 5591 ATA controller");
248
249         /* Highpoint tech -- vendor 0x1103 */
250         case 0x00041103:
251                 return ("HighPoint HPT366 ATA controller");
252         }
253
254         if (pci_get_class(dev) == PCIC_STORAGE &&
255             pci_get_subclass(dev) == PCIS_STORAGE_IDE)
256                 return ("Unknown PCI ATA controller");
257
258         return NULL;
259 }
260
261
262 const char*
263 pci_chip_match(device_t dev)
264 {
265         unsigned        rev;
266
267         switch (pci_get_devid(dev)) {
268         /* Intel -- vendor 0x8086 */
269         case 0x00088086:
270                 /* Silently ignore this one! What is it, anyway ??? */
271                 return ("");
272         case 0x71108086:
273                 /*
274                  * On my laptop (Tecra 8000DVD), this device has a
275                  * bogus subclass 0x80 so make sure that it doesn't
276                  * match the generic 'chip' driver by accident.
277                  */
278                 return NULL;
279         case 0x12258086:
280                 fixbushigh_i1225(dev);
281                 return ("Intel 824?? host to PCI bridge");
282         case 0x71808086:
283                 return ("Intel 82443LX (440 LX) host to PCI bridge");
284         case 0x71908086:
285                 return ("Intel 82443BX (440 BX) host to PCI bridge");
286         case 0x71928086:
287                 return ("Intel 82443BX host to PCI bridge (AGP disabled)");
288         case 0x71a08086:
289                 return ("Intel 82443GX host to PCI bridge");
290         case 0x71a18086:
291                 return ("Intel 82443GX host to AGP bridge");
292         case 0x71a28086:
293                 return ("Intel 82443GX host to PCI bridge (AGP disabled)");
294         case 0x84c48086:
295                 return ("Intel 82454KX/GX (Orion) host to PCI bridge");
296         case 0x84ca8086:
297                 return ("Intel 82451NX Memory and I/O controller");
298         case 0x04868086:
299                 return ("Intel 82425EX PCI system controller");
300         case 0x04838086:
301                 return ("Intel 82424ZX (Saturn) cache DRAM controller");
302         case 0x04a38086:
303                 rev = pci_get_revid(dev);
304                 if (rev == 16 || rev == 17)
305                     return ("Intel 82434NX (Neptune) PCI cache memory controller");
306                 return ("Intel 82434LX (Mercury) PCI cache memory controller");
307         case 0x122d8086:
308                 return ("Intel 82437FX PCI cache memory controller");
309         case 0x12358086:
310                 return ("Intel 82437MX mobile PCI cache memory controller");
311         case 0x12508086:
312                 return ("Intel 82439HX PCI cache memory controller");
313         case 0x70308086:
314                 return ("Intel 82437VX PCI cache memory controller");
315         case 0x71008086:
316                 return ("Intel 82439TX System controller (MTXC)");
317         case 0x71138086:
318                 return ("Intel 82371AB Power management controller");
319         case 0x719b8086:
320                 return ("Intel 82443MX Power management controller");
321         case 0x12378086:
322                 fixwsc_natoma(dev);
323                 return ("Intel 82440FX (Natoma) PCI and memory controller");
324         case 0x84c58086:
325                 return ("Intel 82453KX/GX (Orion) PCI memory controller");
326         case 0x71208086:
327                 return ("Intel 82810 (i810 GMCH) Host To Hub bridge");
328         case 0x71228086:
329         return ("Intel 82810-DC100 (i810-DC100 GMCH) Host To Hub bridge");
330         case 0x71248086:
331         return ("Intel 82810E (i810E GMCH) Host To Hub bridge");
332         case 0x24158086:
333                 return ("Intel 82801AA (ICH) AC'97 Audio Controller");
334         case 0x24258086:
335                 return ("Intel 82801AB (ICH0) AC'97 Audio Controller");
336
337         /* Sony -- vendor 0x104d */
338         case 0x8009104d:
339                 return ("Sony CXD1947A FireWire Host Controller");
340
341         /* SiS -- vendor 0x1039 */
342         case 0x04961039:
343                 return ("SiS 85c496 PCI/VL Bridge");
344         case 0x04061039:
345                 return ("SiS 85c501");
346         case 0x06011039:
347                 return ("SiS 85c601");
348         case 0x55911039:
349                 return ("SiS 5591 host to PCI bridge");
350         case 0x00011039:
351                 return ("SiS 5591 host to AGP bridge");
352         
353         /* VLSI -- vendor 0x1004 */
354         case 0x00051004:
355                 return ("VLSI 82C592 Host to PCI bridge");
356         case 0x01011004:
357                 return ("VLSI 82C532 Eagle II Peripheral controller");
358         case 0x01041004:
359                 return ("VLSI 82C535 Eagle II System controller");
360         case 0x01051004:
361                 return ("VLSI 82C147 IrDA controller");
362
363         /* VIA Technologies -- vendor 0x1106 (0x1107 on the Apollo Master) */
364         case 0x15761107:
365                 return ("VIA 82C570 (Apollo Master) system controller");
366         case 0x05851106:
367                 return ("VIA 82C585 (Apollo VP1/VPX) system controller");
368         case 0x05951106:
369         case 0x15951106:
370                 return ("VIA 82C595 (Apollo VP2) system controller");
371         case 0x05971106:
372                 return ("VIA 82C597 (Apollo VP3) system controller");
373         /* XXX Here is MVP3, I got the datasheet but NO M/B to test it  */
374         /* totally. Please let me know if anything wrong.            -F */
375         /* XXX need info on the MVP3 -- any takers? */
376         case 0x05981106:
377                 return ("VIA 82C598MVP (Apollo MVP3) host bridge");
378         case 0x30401106:
379         case 0x30501106:
380         case 0x30571106:
381                 return NULL;
382         case 0x30581106:
383                 return ("VIA 82C686 AC97 Audio");
384         case 0x30681106:
385                 return ("VIA 82C686 AC97 Modem");
386
387         /* AMD -- vendor 0x1022 */
388         case 0x70061022:
389                 return ("AMD-751 host to PCI bridge");
390         case 0x700e1022:
391                 return ("AMD-761 host to PCI bridge");
392
393         /* NEC -- vendor 0x1033 */
394         case 0x00021033:
395                 return ("NEC 0002 PCI to PC-98 local bus bridge");
396         case 0x00161033:
397                 return ("NEC 0016 PCI to PC-98 local bus bridge");
398
399         /* AcerLabs -- vendor 0x10b9 */
400         /* Funny : The datasheet told me vendor id is "10b8",sub-vendor */
401         /* id is '10b9" but the register always shows "10b9". -Foxfair  */
402         case 0x154110b9:
403                 return ("AcerLabs M1541 (Aladdin-V) PCI host bridge");
404         case 0x710110b9:
405                 return ("AcerLabs M15x3 Power Management Unit");
406
407         /* OPTi -- vendor 0x1045 */
408         case 0xc5571045:
409                 return ("Opti 82C557 (Viper-M) host to PCI bridge");
410         case 0xc5581045:
411                 return ("Opti 82C558 (Viper-M) ISA+IDE");
412         case 0xc8221045:
413                 return ("OPTi 82C822 host to PCI Bridge");
414
415         /* Texas Instruments -- vendor 0x104c */
416         case 0xac1c104c:
417                 return ("Texas Instruments PCI1225 CardBus controller");
418         case 0xac50104c:
419                 return ("Texas Instruments PCI1410 CardBus controller");
420         case 0xac51104c:
421                 return ("Texas Instruments PCI1420 CardBus controller");
422         case 0xac1b104c:
423                 return ("Texas Instruments PCI1450 CardBus controller");
424         case 0xac52104c:
425                 return ("Texas Instruments PCI1451 CardBus controller");
426
427         /* NeoMagic -- vendor 0x10c8 */
428         case 0x800510c8:
429                 return ("NeoMagic MagicMedia 256AX Audio controller");
430         case 0x800610c8:
431                 return ("NeoMagic MagicMedia 256ZX Audio controller");
432
433         /* ESS Technology Inc -- vendor 0x125d */
434         case 0x1978125d:
435                 return ("ESS Technology Maestro 2E Audio controller");
436
437         /* Toshiba -- vendor 0x1179 */
438         case 0x07011179:
439                 return ("Toshiba Fast Infra Red controller");
440
441         /* NEC -- vendor 0x1033 */
442
443         /* PCI to C-bus bridge */
444         /* The following chipsets are PCI to PC98 C-bus bridge.
445          * The C-bus is the 16-bits bus on PC98 and it should be probed as
446          * PCI to ISA bridge.  Because class of the C-bus is not defined,
447          * C-bus bridges are recognized as "other bridge."  To make C-bus
448          * bridge be recognized as ISA bridge, this function returns NULL.
449          */
450         case 0x00011033:
451         case 0x002c1033:
452         case 0x003b1033:
453                 return NULL;
454         };
455
456         if (pci_get_class(dev) == PCIC_BRIDGE
457             && pci_get_subclass(dev) != PCIS_BRIDGE_PCI
458             && pci_get_subclass(dev) != PCIS_BRIDGE_ISA
459             && pci_get_subclass(dev) != PCIS_BRIDGE_EISA)
460                 return pci_bridge_type(dev);
461
462         return NULL;
463 }
464
465 /*---------------------------------------------------------
466 **
467 **      Catchall driver for VGA devices
468 **
469 **      By Garrett Wollman
470 **      <wollman@halloran-eldar.lcs.mit.edu>
471 **
472 **---------------------------------------------------------
473 */
474
475 const char* pci_vga_match(device_t dev)
476 {
477         u_int id = pci_get_devid(dev);
478         const char *vendor, *chip, *type;
479
480         vendor = chip = type = 0;
481         switch (id & 0xffff) {
482         case 0x003d:
483                 vendor = "Real 3D";
484                 switch (id >> 16) {
485                 case 0x00d1:
486                         chip = "i740"; break;
487                 }
488                 break;
489         case 0x10c8:
490                 vendor = "NeoMagic";
491                 switch (id >> 16) {
492                 case 0x0003:
493                         chip = "MagicGraph 128ZV"; break;
494                 case 0x0004:
495                         chip = "MagicGraph 128XD"; break;
496                 case 0x0005:
497                         chip = "MagicMedia 256AV"; break;
498                 case 0x0006:
499                         chip = "MagicMedia 256ZX"; break;
500                 }
501                 break;
502         case 0x121a:
503                 vendor = "3Dfx";
504                 type = "graphics accelerator";
505                 switch (id >> 16) {
506                 case 0x0001:
507                         chip = "Voodoo"; break;
508                 case 0x0002:
509                         chip = "Voodoo 2"; break;
510                 case 0x0003:
511                         chip = "Voodoo Banshee"; break;
512                 case 0x0005:
513                         chip = "Voodoo 3"; break;
514                 }
515                 break;
516         case 0x102b:
517                 vendor = "Matrox";
518                 type = "graphics accelerator";
519                 switch (id >> 16) {
520                 case 0x0518:
521                         chip = "MGA 2085PX"; break;
522                 case 0x0519:
523                         chip = "MGA Millennium 2064W"; break;
524                 case 0x051a:
525                         chip = "MGA 1024SG/1064SG/1164SG"; break;
526                 case 0x051b:
527                         chip = "MGA Millennium II 2164W"; break;
528                 case 0x051f:
529                         chip = "MGA Millennium II 2164WA-B AG"; break;
530                 case 0x0520:
531                         chip = "MGA G200"; break;
532                 case 0x0521:
533                         chip = "MGA G200 AGP"; break;
534                 case 0x0525:
535                         chip = "MGA G400 AGP"; break;
536                 case 0x0d10:
537                         chip = "MGA Impression"; break;
538                 case 0x1000:
539                         chip = "MGA G100"; break;
540                 case 0x1001:
541                         chip = "MGA G100 AGP"; break;
542                 case 0x2527:
543                         chip = "MGA G550 AGP"; break;
544
545                 }
546                 break;
547         case 0x1002:
548                 vendor = "ATI";
549                 type = "graphics accelerator";
550                 switch (id >> 16) {
551                 case 0x4158:
552                         chip = "Mach32"; break;
553                 case 0x4354:
554                         chip = "Mach64-CT"; break;
555                 case 0x4358:
556                         chip = "Mach64-CX"; break;
557                 case 0x4554:
558                         chip = "Mach64-ET"; break;
559                 case 0x4654:
560                 case 0x5654:
561                         chip = "Mach64-VT"; break;
562                 case 0x4742:
563                         chip = "Mach64-GB"; break;
564                 case 0x4744:
565                         chip = "Mach64-GD"; break;
566                 case 0x4749:
567                         chip = "Mach64-GI"; break;
568                 case 0x474d:
569                         chip = "Mach64-GM"; break;
570                 case 0x474e:
571                         chip = "Mach64-GN"; break;
572                 case 0x474f:
573                         chip = "Mach64-GO"; break;
574                 case 0x4750:
575                         chip = "Mach64-GP"; break;
576                 case 0x4751:
577                         chip = "Mach64-GQ"; break;
578                 case 0x4752:
579                         chip = "Mach64-GR"; break;
580                 case 0x4753:
581                         chip = "Mach64-GS"; break;
582                 case 0x4754:
583                         chip = "Mach64-GT"; break;
584                 case 0x4755:
585                         chip = "Mach64-GU"; break;
586                 case 0x4756:
587                         chip = "Mach64-GV"; break;
588                 case 0x4757:
589                         chip = "Mach64-GW"; break;
590                 case 0x4758:
591                         chip = "Mach64-GX"; break;
592                 case 0x4c4d:
593                         chip = "Mobility-1"; break;
594                 case 0x4c52:
595                         chip = "RageMobility-P/M"; break;
596                 case 0x475a:
597                         chip = "Mach64-GZ"; break;
598                 case 0x5245:
599                         chip = "Rage128-RE"; break;
600                 case 0x5246:
601                         chip = "Rage128-RF"; break;
602                 case 0x524b:
603                         chip = "Rage128-RK"; break;
604                 case 0x524c:
605                         chip = "Rage128-RL"; break;
606                 }
607                 break;
608         case 0x1005:
609                 vendor = "Avance Logic";
610                 switch (id >> 16) {
611                 case 0x2301:
612                         chip = "ALG2301"; break;
613                 case 0x2302:
614                         chip = "ALG2302"; break;
615                 }
616                 break;
617         case 0x100c:
618                 vendor = "Tseng Labs";
619                 type = "graphics accelerator";
620                 switch (id >> 16) {
621                 case 0x3202:
622                 case 0x3205:
623                 case 0x3206:
624                 case 0x3207:
625                         chip = "ET4000 W32P"; break;
626                 case 0x3208:
627                         chip = "ET6000/ET6100"; break;
628                 case 0x4702:
629                         chip = "ET6300"; break;
630                 }
631                 break;
632         case 0x100e:
633                 vendor = "Weitek";
634                 type = "graphics accelerator";
635                 switch (id >> 16) {
636                 case 0x9001:
637                         chip = "P9000"; break;
638                 case 0x9100:
639                         chip = "P9100"; break;
640                 }
641                 break;
642         case 0x1013:
643                 vendor = "Cirrus Logic";
644                 switch (id >> 16) {
645                 case 0x0038:
646                         chip = "GD7548"; break;
647                 case 0x0040:
648                         chip = "GD7555"; break;
649                 case 0x004c:
650                         chip = "GD7556"; break;
651                 case 0x00a0:
652                         chip = "GD5430"; break;
653                 case 0x00a4:
654                 case 0x00a8:
655                         chip = "GD5434"; break;
656                 case 0x00ac:
657                         chip = "GD5436"; break;
658                 case 0x00b8:
659                         chip = "GD5446"; break;
660                 case 0x00bc:
661                         chip = "GD5480"; break;
662                 case 0x00d0:
663                         chip = "GD5462"; break;
664                 case 0x00d4:
665                 case 0x00d5:
666                         chip = "GD5464"; break;
667                 case 0x00d6:
668                         chip = "GD5465"; break;
669                 case 0x1200:
670                         chip = "GD7542"; break;
671                 case 0x1202:
672                         chip = "GD7543"; break;
673                 case 0x1204:
674                         chip = "GD7541"; break;
675                 }
676                 break;
677         case 0x1023:
678                 vendor = "Trident";
679                 break;          /* let default deal with it */
680         case 0x102c:
681                 vendor = "Chips & Technologies";
682                 switch (id >> 16) {
683                 case 0x00b8:
684                         chip = "64310"; break;
685                 case 0x00d8:
686                         chip = "65545"; break;
687                 case 0x00dc:
688                         chip = "65548"; break;
689                 case 0x00c0:
690                         chip = "69000"; break;
691                 case 0x00e0:
692                         chip = "65550"; break;
693                 case 0x00e4:
694                         chip = "65554"; break;
695                 case 0x00e5:
696                         chip = "65555"; break;
697                 case 0x00f4:
698                         chip = "68554"; break;
699                 }
700                 break;
701         case 0x1033:
702                 vendor = "NEC";
703                 switch (id >> 16) {
704                 case 0x0009:
705                         type = "PCI to PC-98 Core Graph bridge";
706                         break;
707                 }
708                 break;
709         case 0x1039:
710                 vendor = "SiS";
711                 switch (id >> 16) {
712                 case 0x0001:
713                         chip = "86c201"; break;
714                 case 0x0002:
715                         chip = "86c202"; break;
716                 case 0x0205:
717                         chip = "86c205"; break;
718                 case 0x0215:
719                         chip = "86c215"; break;
720                 case 0x0225:
721                         chip = "86c225"; break;
722                 case 0x0200:
723                         chip = "5597/98"; break;
724                 case 0x6326:
725                         chip = "6326"; break;
726                 case 0x6306:
727                         chip = "530/620"; break;
728                 }
729                 break;
730         case 0x105d:
731                 vendor = "Number Nine";
732                 type = "graphics accelerator";
733                 switch (id >> 16) {
734                 case 0x2309:
735                         chip = "Imagine 128"; break;
736                 case 0x2339:
737                         chip = "Imagine 128 II"; break;
738                 }
739                 break;
740         case 0x1142:
741                 vendor = "Alliance";
742                 switch (id >> 16) {
743                 case 0x3210:
744                         chip = "PM6410"; break;
745                 case 0x6422:
746                         chip = "PM6422"; break;
747                 case 0x6424:
748                         chip = "PMAT24"; break;
749                 }
750                 break;
751         case 0x1163:
752                 vendor = "Rendition Verite";
753                 switch (id >> 16) {
754                 case 0x0001:
755                         chip = "V1000"; break;
756                 case 0x2000:
757                         chip = "V2000"; break;
758                 }
759                 break;
760         case 0x1236:
761                 vendor = "Sigma Designs";
762                 if ((id >> 16) == 0x6401)
763                         chip = "REALmagic64/GX";
764                 break;
765         case 0x5333:
766                 vendor = "S3";
767                 type = "graphics accelerator";
768                 switch (id >> 16) {
769                 case 0x8811:
770                         chip = "Trio"; break;
771                 case 0x8812:
772                         chip = "Aurora 64"; break;
773                 case 0x8814:
774                         chip = "Trio 64UV+"; break;
775                 case 0x8901:
776                         chip = "Trio 64V2/DX/GX"; break;
777                 case 0x8902:
778                         chip = "Plato"; break;
779                 case 0x8904:
780                         chip = "Trio3D"; break;
781                 case 0x8880:
782                         chip = "868"; break;
783                 case 0x88b0:
784                         chip = "928"; break;
785                 case 0x88c0:
786                 case 0x88c1:
787                         chip = "864"; break;
788                 case 0x88d0:
789                 case 0x88d1:
790                         chip = "964"; break;
791                 case 0x88f0:
792                         chip = "968"; break;
793                 case 0x5631:
794                         chip = "ViRGE"; break;
795                 case 0x883d:
796                         chip = "ViRGE VX"; break;
797                 case 0x8a01:
798                         chip = "ViRGE DX/GX"; break;
799                 case 0x8a10:
800                         chip = "ViRGE GX2"; break;
801                 case 0x8a13:
802                         chip = "Trio3D/2X"; break;
803                 case 0x8a20:
804                 case 0x8a21:
805                         chip = "Savage3D"; break;
806                 case 0x8a22:
807                         chip = "Savage 4"; break;
808                 case 0x8c01:
809                         chip = "ViRGE MX"; break;
810                 case 0x8c03:
811                         chip = "ViRGE MX+"; break;
812                 }
813                 break;
814         case 0xedd8:
815                 vendor = "ARK Logic";
816                 switch (id >> 16) {
817                 case 0xa091:
818                         chip = "1000PV"; break;
819                 case 0xa099:
820                         chip = "2000PV"; break;
821                 case 0xa0a1:
822                         chip = "2000MT"; break;
823                 case 0xa0a9:
824                         chip = "2000MI"; break;
825                 }
826                 break;
827         case 0x3d3d:
828                 vendor = "3D Labs";
829                 type = "graphics accelerator";
830                 switch (id >> 16) {
831                 case 0x0001:
832                         chip = "300SX"; break;
833                 case 0x0002:
834                         chip = "500TX"; break;
835                 case 0x0003:
836                         chip = "Delta"; break;
837                 case 0x0004:
838                         chip = "PerMedia"; break;
839                 }
840                 break;
841         case 0x10de:
842                 vendor = "NVidia";
843                 type = "graphics accelerator";
844                 switch (id >> 16) {
845                 case 0x0008:
846                         chip = "NV1"; break;
847                 case 0x0020:
848                         chip = "Riva TNT"; break;       
849                 case 0x0028:
850                         chip = "Riva TNT2"; break;
851                 case 0x0029:
852                         chip = "Riva Ultra TNT2"; break;
853                 case 0x002c:
854                         chip = "Riva Vanta TNT2"; break;
855                 case 0x002d:
856                         chip = "Riva Ultra Vanta TNT2"; break;
857                 case 0x00a0:
858                         chip = "Riva Integrated TNT2"; break;
859                 case 0x0100:
860                         chip = "GeForce 256"; break;
861                 case 0x0101:
862                         chip = "GeForce DDR"; break;
863                 case 0x0103:
864                         chip = "Quadro"; break;
865                 case 0x0150:
866                 case 0x0151:
867                 case 0x0152:
868                         chip = "GeForce2 GTS"; break;
869                 case 0x0153:
870                         chip = "Quadro2"; break;
871                 }
872                 break;
873         case 0x12d2:
874                 vendor = "NVidia/SGS-Thomson";
875                 type = "graphics accelerator";
876                 switch (id >> 16) {
877                 case 0x0018:
878                         chip = "Riva128"; break;        
879                 }
880                 break;
881         case 0x104a:
882                 vendor = "SGS-Thomson";
883                 switch (id >> 16) {
884                 case 0x0008:
885                         chip = "STG2000"; break;
886                 }
887                 break;
888         case 0x8086:
889                 vendor = "Intel";
890                 switch (id >> 16) {
891                 case 0x7121:
892                         chip = "82810 (i810 GMCH)"; break;
893                 case 0x7123:
894                         chip = "82810-DC100 (i810-DC100 GMCH)"; break;
895                 case 0x7125:
896                         chip = "82810E (i810E GMCH)"; break;
897                 case 0x7800:
898                         chip = "i740 AGP"; break;
899                 }
900                 break;
901         case 0x10ea:
902                 vendor = "Intergraphics";
903                 switch (id >> 16) {
904                 case 0x1680:
905                         chip = "IGA-1680"; break;
906                 case 0x1682:
907                         chip = "IGA-1682"; break;
908                 }
909                 break;
910         }
911
912         if (vendor && chip) {
913                 char *buf;
914                 int len;
915
916                 if (type == 0)
917                         type = "SVGA controller";
918
919                 len = strlen(vendor) + strlen(chip) + strlen(type) + 4;
920                 MALLOC(buf, char *, len, M_TEMP, M_NOWAIT);
921                 if (buf)
922                         sprintf(buf, "%s %s %s", vendor, chip, type);
923                 return buf;
924         }
925
926         switch (pci_get_class(dev)) {
927
928         case PCIC_OLD:
929                 if (pci_get_subclass(dev) != PCIS_OLD_VGA)
930                         return 0;
931                 if (type == 0)
932                         type = "VGA-compatible display device";
933                 break;
934
935         case PCIC_DISPLAY:
936                 if (type == 0) {
937                         if (pci_get_subclass(dev) == PCIS_DISPLAY_VGA)
938                                 type = "VGA-compatible display device";
939                         else {
940                                 /*
941                                  * If it isn't a vga display device,
942                                  * don't pretend we found one.
943                                  */
944                                 return 0;
945                         }
946                 }
947                 break;
948
949         default:
950                 return 0;
951         };
952         /*
953          * If we got here, we know for sure it's some sort of display
954          * device, but we weren't able to identify it specifically.
955          * At a minimum we can return the type, but we'd like to
956          * identify the vendor and chip ID if at all possible.
957          * (Some of the checks above intentionally don't bother for
958          * vendors where we know the chip ID is the same as the
959          * model number.)
960          */
961         if (vendor) {
962                 char *buf;
963                 int len;
964
965                 len = strlen(vendor) + strlen(type) + 2 + 6 + 4 + 1;
966                 MALLOC(buf, char *, len, M_TEMP, M_NOWAIT);
967                 if (buf)
968                         sprintf(buf, "%s model %04x %s", vendor, id >> 16, type);
969                 return buf;
970         }
971         return type;
972 }
973
974 /*---------------------------------------------------------
975 **
976 **      Devices to ignore
977 **
978 **---------------------------------------------------------
979 */
980
981 static const char*
982 ign_match(device_t dev)
983 {
984         switch (pci_get_devid(dev)) {
985
986         case 0x10001042ul:      /* wd */
987                 return ("SMC FDC 37c665");
988         };
989
990         return NULL;
991 }
992
993 static int
994 ign_probe(device_t dev)
995 {
996         const char *s;
997
998         s = ign_match(dev);
999         if (s) {
1000                 device_set_desc(dev, s);
1001                 device_quiet(dev);
1002                 return -1000;
1003         }
1004         return ENXIO;
1005 }
1006
1007 static int
1008 ign_attach(device_t dev)
1009 {
1010         return 0;
1011 }
1012
1013 static device_method_t ign_methods[] = {
1014         /* Device interface */
1015         DEVMETHOD(device_probe,         ign_probe),
1016         DEVMETHOD(device_attach,        ign_attach),
1017
1018         { 0, 0 }
1019 };
1020
1021 static driver_t ign_driver = {
1022         "ign",
1023         ign_methods,
1024         1,
1025 };
1026
1027 static devclass_t ign_devclass;
1028
1029 DRIVER_MODULE(ign, pci, ign_driver, ign_devclass, 0, 0);