47c0f952272b8c67e89a464e754e6107167c5bbe
[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.15 2005/06/27 02:27:10 swildner 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         /* AcerLabs -- vendor 0x10b9 */
394         /* Funny : The datasheet told me vendor id is "10b8",sub-vendor */
395         /* id is '10b9" but the register always shows "10b9". -Foxfair  */
396         case 0x154110b9:
397                 return ("AcerLabs M1541 (Aladdin-V) PCI host bridge");
398         case 0x710110b9:
399                 return ("AcerLabs M15x3 Power Management Unit");
400
401         /* OPTi -- vendor 0x1045 */
402         case 0xc5571045:
403                 return ("Opti 82C557 (Viper-M) host to PCI bridge");
404         case 0xc5581045:
405                 return ("Opti 82C558 (Viper-M) ISA+IDE");
406         case 0xc8221045:
407                 return ("OPTi 82C822 host to PCI Bridge");
408
409         /* Texas Instruments -- vendor 0x104c */
410         case 0xac1c104c:
411                 return ("Texas Instruments PCI1225 CardBus controller");
412         case 0xac50104c:
413                 return ("Texas Instruments PCI1410 CardBus controller");
414         case 0xac51104c:
415                 return ("Texas Instruments PCI1420 CardBus controller");
416         case 0xac1b104c:
417                 return ("Texas Instruments PCI1450 CardBus controller");
418         case 0xac52104c:
419                 return ("Texas Instruments PCI1451 CardBus controller");
420
421         /* NeoMagic -- vendor 0x10c8 */
422         case 0x800510c8:
423                 return ("NeoMagic MagicMedia 256AX Audio controller");
424         case 0x800610c8:
425                 return ("NeoMagic MagicMedia 256ZX Audio controller");
426
427         /* ESS Technology Inc -- vendor 0x125d */
428         case 0x1978125d:
429                 return ("ESS Technology Maestro 2E Audio controller");
430
431         /* Toshiba -- vendor 0x1179 */
432         case 0x07011179:
433                 return ("Toshiba Fast Infra Red controller");
434         };
435
436         if (pci_get_class(dev) == PCIC_BRIDGE
437             && pci_get_subclass(dev) != PCIS_BRIDGE_PCI
438             && pci_get_subclass(dev) != PCIS_BRIDGE_ISA
439             && pci_get_subclass(dev) != PCIS_BRIDGE_EISA)
440                 return pci_bridge_type(dev);
441
442         return NULL;
443 }
444
445 /*---------------------------------------------------------
446 **
447 **      Catchall driver for VGA devices
448 **
449 **      By Garrett Wollman
450 **      <wollman@halloran-eldar.lcs.mit.edu>
451 **
452 **---------------------------------------------------------
453 */
454
455 const char* pci_vga_match(device_t dev)
456 {
457         u_int id = pci_get_devid(dev);
458         const char *vendor, *chip, *type;
459
460         vendor = chip = type = 0;
461         switch (id & 0xffff) {
462         case 0x003d:
463                 vendor = "Real 3D";
464                 switch (id >> 16) {
465                 case 0x00d1:
466                         chip = "i740"; break;
467                 }
468                 break;
469         case 0x10c8:
470                 vendor = "NeoMagic";
471                 switch (id >> 16) {
472                 case 0x0003:
473                         chip = "MagicGraph 128ZV"; break;
474                 case 0x0004:
475                         chip = "MagicGraph 128XD"; break;
476                 case 0x0005:
477                         chip = "MagicMedia 256AV"; break;
478                 case 0x0006:
479                         chip = "MagicMedia 256ZX"; break;
480                 }
481                 break;
482         case 0x121a:
483                 vendor = "3Dfx";
484                 type = "graphics accelerator";
485                 switch (id >> 16) {
486                 case 0x0001:
487                         chip = "Voodoo"; break;
488                 case 0x0002:
489                         chip = "Voodoo 2"; break;
490                 case 0x0003:
491                         chip = "Voodoo Banshee"; break;
492                 case 0x0005:
493                         chip = "Voodoo 3"; break;
494                 }
495                 break;
496         case 0x102b:
497                 vendor = "Matrox";
498                 type = "graphics accelerator";
499                 switch (id >> 16) {
500                 case 0x0518:
501                         chip = "MGA 2085PX"; break;
502                 case 0x0519:
503                         chip = "MGA Millennium 2064W"; break;
504                 case 0x051a:
505                         chip = "MGA 1024SG/1064SG/1164SG"; break;
506                 case 0x051b:
507                         chip = "MGA Millennium II 2164W"; break;
508                 case 0x051f:
509                         chip = "MGA Millennium II 2164WA-B AG"; break;
510                 case 0x0520:
511                         chip = "MGA G200"; break;
512                 case 0x0521:
513                         chip = "MGA G200 AGP"; break;
514                 case 0x0525:
515                         chip = "MGA G400 AGP"; break;
516                 case 0x0d10:
517                         chip = "MGA Impression"; break;
518                 case 0x1000:
519                         chip = "MGA G100"; break;
520                 case 0x1001:
521                         chip = "MGA G100 AGP"; break;
522                 case 0x2527:
523                         chip = "MGA G550 AGP"; break;
524
525                 }
526                 break;
527         case 0x1002:
528                 vendor = "ATI";
529                 type = "graphics accelerator";
530                 switch (id >> 16) {
531                 case 0x4158:
532                         chip = "Mach32"; break;
533                 case 0x4354:
534                         chip = "Mach64-CT"; break;
535                 case 0x4358:
536                         chip = "Mach64-CX"; break;
537                 case 0x4554:
538                         chip = "Mach64-ET"; break;
539                 case 0x4654:
540                 case 0x5654:
541                         chip = "Mach64-VT"; break;
542                 case 0x4742:
543                         chip = "Mach64-GB"; break;
544                 case 0x4744:
545                         chip = "Mach64-GD"; break;
546                 case 0x4749:
547                         chip = "Mach64-GI"; break;
548                 case 0x474d:
549                         chip = "Mach64-GM"; break;
550                 case 0x474e:
551                         chip = "Mach64-GN"; break;
552                 case 0x474f:
553                         chip = "Mach64-GO"; break;
554                 case 0x4750:
555                         chip = "Mach64-GP"; break;
556                 case 0x4751:
557                         chip = "Mach64-GQ"; break;
558                 case 0x4752:
559                         chip = "Mach64-GR"; break;
560                 case 0x4753:
561                         chip = "Mach64-GS"; break;
562                 case 0x4754:
563                         chip = "Mach64-GT"; break;
564                 case 0x4755:
565                         chip = "Mach64-GU"; break;
566                 case 0x4756:
567                         chip = "Mach64-GV"; break;
568                 case 0x4757:
569                         chip = "Mach64-GW"; break;
570                 case 0x4758:
571                         chip = "Mach64-GX"; break;
572                 case 0x4c4d:
573                         chip = "Mobility-1"; break;
574                 case 0x4c52:
575                         chip = "RageMobility-P/M"; break;
576                 case 0x475a:
577                         chip = "Mach64-GZ"; break;
578                 case 0x5245:
579                         chip = "Rage128-RE"; break;
580                 case 0x5246:
581                         chip = "Rage128-RF"; break;
582                 case 0x524b:
583                         chip = "Rage128-RK"; break;
584                 case 0x524c:
585                         chip = "Rage128-RL"; break;
586                 }
587                 break;
588         case 0x1005:
589                 vendor = "Avance Logic";
590                 switch (id >> 16) {
591                 case 0x2301:
592                         chip = "ALG2301"; break;
593                 case 0x2302:
594                         chip = "ALG2302"; break;
595                 }
596                 break;
597         case 0x100c:
598                 vendor = "Tseng Labs";
599                 type = "graphics accelerator";
600                 switch (id >> 16) {
601                 case 0x3202:
602                 case 0x3205:
603                 case 0x3206:
604                 case 0x3207:
605                         chip = "ET4000 W32P"; break;
606                 case 0x3208:
607                         chip = "ET6000/ET6100"; break;
608                 case 0x4702:
609                         chip = "ET6300"; break;
610                 }
611                 break;
612         case 0x100e:
613                 vendor = "Weitek";
614                 type = "graphics accelerator";
615                 switch (id >> 16) {
616                 case 0x9001:
617                         chip = "P9000"; break;
618                 case 0x9100:
619                         chip = "P9100"; break;
620                 }
621                 break;
622         case 0x1013:
623                 vendor = "Cirrus Logic";
624                 switch (id >> 16) {
625                 case 0x0038:
626                         chip = "GD7548"; break;
627                 case 0x0040:
628                         chip = "GD7555"; break;
629                 case 0x004c:
630                         chip = "GD7556"; break;
631                 case 0x00a0:
632                         chip = "GD5430"; break;
633                 case 0x00a4:
634                 case 0x00a8:
635                         chip = "GD5434"; break;
636                 case 0x00ac:
637                         chip = "GD5436"; break;
638                 case 0x00b8:
639                         chip = "GD5446"; break;
640                 case 0x00bc:
641                         chip = "GD5480"; break;
642                 case 0x00d0:
643                         chip = "GD5462"; break;
644                 case 0x00d4:
645                 case 0x00d5:
646                         chip = "GD5464"; break;
647                 case 0x00d6:
648                         chip = "GD5465"; break;
649                 case 0x1200:
650                         chip = "GD7542"; break;
651                 case 0x1202:
652                         chip = "GD7543"; break;
653                 case 0x1204:
654                         chip = "GD7541"; break;
655                 }
656                 break;
657         case 0x1023:
658                 vendor = "Trident";
659                 break;          /* let default deal with it */
660         case 0x102c:
661                 vendor = "Chips & Technologies";
662                 switch (id >> 16) {
663                 case 0x00b8:
664                         chip = "64310"; break;
665                 case 0x00d8:
666                         chip = "65545"; break;
667                 case 0x00dc:
668                         chip = "65548"; break;
669                 case 0x00c0:
670                         chip = "69000"; break;
671                 case 0x00e0:
672                         chip = "65550"; break;
673                 case 0x00e4:
674                         chip = "65554"; break;
675                 case 0x00e5:
676                         chip = "65555"; break;
677                 case 0x00f4:
678                         chip = "68554"; break;
679                 }
680                 break;
681         case 0x1039:
682                 vendor = "SiS";
683                 switch (id >> 16) {
684                 case 0x0001:
685                         chip = "86c201"; break;
686                 case 0x0002:
687                         chip = "86c202"; break;
688                 case 0x0205:
689                         chip = "86c205"; break;
690                 case 0x0215:
691                         chip = "86c215"; break;
692                 case 0x0225:
693                         chip = "86c225"; break;
694                 case 0x0200:
695                         chip = "5597/98"; break;
696                 case 0x6326:
697                         chip = "6326"; break;
698                 case 0x6306:
699                         chip = "530/620"; break;
700                 }
701                 break;
702         case 0x105d:
703                 vendor = "Number Nine";
704                 type = "graphics accelerator";
705                 switch (id >> 16) {
706                 case 0x2309:
707                         chip = "Imagine 128"; break;
708                 case 0x2339:
709                         chip = "Imagine 128 II"; break;
710                 }
711                 break;
712         case 0x1142:
713                 vendor = "Alliance";
714                 switch (id >> 16) {
715                 case 0x3210:
716                         chip = "PM6410"; break;
717                 case 0x6422:
718                         chip = "PM6422"; break;
719                 case 0x6424:
720                         chip = "PMAT24"; break;
721                 }
722                 break;
723         case 0x1163:
724                 vendor = "Rendition Verite";
725                 switch (id >> 16) {
726                 case 0x0001:
727                         chip = "V1000"; break;
728                 case 0x2000:
729                         chip = "V2000"; break;
730                 }
731                 break;
732         case 0x1236:
733                 vendor = "Sigma Designs";
734                 if ((id >> 16) == 0x6401)
735                         chip = "REALmagic64/GX";
736                 break;
737         case 0x5333:
738                 vendor = "S3";
739                 type = "graphics accelerator";
740                 switch (id >> 16) {
741                 case 0x8811:
742                         chip = "Trio"; break;
743                 case 0x8812:
744                         chip = "Aurora 64"; break;
745                 case 0x8814:
746                         chip = "Trio 64UV+"; break;
747                 case 0x8901:
748                         chip = "Trio 64V2/DX/GX"; break;
749                 case 0x8902:
750                         chip = "Plato"; break;
751                 case 0x8904:
752                         chip = "Trio3D"; break;
753                 case 0x8880:
754                         chip = "868"; break;
755                 case 0x88b0:
756                         chip = "928"; break;
757                 case 0x88c0:
758                 case 0x88c1:
759                         chip = "864"; break;
760                 case 0x88d0:
761                 case 0x88d1:
762                         chip = "964"; break;
763                 case 0x88f0:
764                         chip = "968"; break;
765                 case 0x5631:
766                         chip = "ViRGE"; break;
767                 case 0x883d:
768                         chip = "ViRGE VX"; break;
769                 case 0x8a01:
770                         chip = "ViRGE DX/GX"; break;
771                 case 0x8a10:
772                         chip = "ViRGE GX2"; break;
773                 case 0x8a13:
774                         chip = "Trio3D/2X"; break;
775                 case 0x8a20:
776                 case 0x8a21:
777                         chip = "Savage3D"; break;
778                 case 0x8a22:
779                         chip = "Savage 4"; break;
780                 case 0x8c01:
781                         chip = "ViRGE MX"; break;
782                 case 0x8c03:
783                         chip = "ViRGE MX+"; break;
784                 }
785                 break;
786         case 0xedd8:
787                 vendor = "ARK Logic";
788                 switch (id >> 16) {
789                 case 0xa091:
790                         chip = "1000PV"; break;
791                 case 0xa099:
792                         chip = "2000PV"; break;
793                 case 0xa0a1:
794                         chip = "2000MT"; break;
795                 case 0xa0a9:
796                         chip = "2000MI"; break;
797                 }
798                 break;
799         case 0x3d3d:
800                 vendor = "3D Labs";
801                 type = "graphics accelerator";
802                 switch (id >> 16) {
803                 case 0x0001:
804                         chip = "300SX"; break;
805                 case 0x0002:
806                         chip = "500TX"; break;
807                 case 0x0003:
808                         chip = "Delta"; break;
809                 case 0x0004:
810                         chip = "PerMedia"; break;
811                 }
812                 break;
813         case 0x10de:
814                 vendor = "NVidia";
815                 type = "graphics accelerator";
816                 switch (id >> 16) {
817                 case 0x0008:
818                         chip = "NV1"; break;
819                 case 0x0020:
820                         chip = "Riva TNT"; break;       
821                 case 0x0028:
822                         chip = "Riva TNT2"; break;
823                 case 0x0029:
824                         chip = "Riva Ultra TNT2"; break;
825                 case 0x002c:
826                         chip = "Riva Vanta TNT2"; break;
827                 case 0x002d:
828                         chip = "Riva Ultra Vanta TNT2"; break;
829                 case 0x00a0:
830                         chip = "Riva Integrated TNT2"; break;
831                 case 0x0100:
832                         chip = "GeForce 256"; break;
833                 case 0x0101:
834                         chip = "GeForce DDR"; break;
835                 case 0x0103:
836                         chip = "Quadro"; break;
837                 case 0x0150:
838                 case 0x0151:
839                 case 0x0152:
840                         chip = "GeForce2 GTS"; break;
841                 case 0x0153:
842                         chip = "Quadro2"; break;
843                 }
844                 break;
845         case 0x12d2:
846                 vendor = "NVidia/SGS-Thomson";
847                 type = "graphics accelerator";
848                 switch (id >> 16) {
849                 case 0x0018:
850                         chip = "Riva128"; break;        
851                 }
852                 break;
853         case 0x104a:
854                 vendor = "SGS-Thomson";
855                 switch (id >> 16) {
856                 case 0x0008:
857                         chip = "STG2000"; break;
858                 }
859                 break;
860         case 0x8086:
861                 vendor = "Intel";
862                 switch (id >> 16) {
863                 case 0x7121:
864                         chip = "82810 (i810 GMCH)"; break;
865                 case 0x7123:
866                         chip = "82810-DC100 (i810-DC100 GMCH)"; break;
867                 case 0x7125:
868                         chip = "82810E (i810E GMCH)"; break;
869                 case 0x7800:
870                         chip = "i740 AGP"; break;
871                 }
872                 break;
873         case 0x10ea:
874                 vendor = "Intergraphics";
875                 switch (id >> 16) {
876                 case 0x1680:
877                         chip = "IGA-1680"; break;
878                 case 0x1682:
879                         chip = "IGA-1682"; break;
880                 }
881                 break;
882         }
883
884         if (vendor && chip) {
885                 char *buf;
886                 int len;
887
888                 if (type == 0)
889                         type = "SVGA controller";
890
891                 len = strlen(vendor) + strlen(chip) + strlen(type) + 4;
892                 MALLOC(buf, char *, len, M_TEMP, M_WAITOK);
893                 sprintf(buf, "%s %s %s", vendor, chip, type);
894                 return buf;
895         }
896
897         switch (pci_get_class(dev)) {
898
899         case PCIC_OLD:
900                 if (pci_get_subclass(dev) != PCIS_OLD_VGA)
901                         return 0;
902                 if (type == 0)
903                         type = "VGA-compatible display device";
904                 break;
905
906         case PCIC_DISPLAY:
907                 if (type == 0) {
908                         if (pci_get_subclass(dev) == PCIS_DISPLAY_VGA)
909                                 type = "VGA-compatible display device";
910                         else {
911                                 /*
912                                  * If it isn't a vga display device,
913                                  * don't pretend we found one.
914                                  */
915                                 return 0;
916                         }
917                 }
918                 break;
919
920         default:
921                 return 0;
922         };
923         /*
924          * If we got here, we know for sure it's some sort of display
925          * device, but we weren't able to identify it specifically.
926          * At a minimum we can return the type, but we'd like to
927          * identify the vendor and chip ID if at all possible.
928          * (Some of the checks above intentionally don't bother for
929          * vendors where we know the chip ID is the same as the
930          * model number.)
931          */
932         if (vendor) {
933                 char *buf;
934                 int len;
935
936                 len = strlen(vendor) + 7 + 4 + 1 + strlen(type) + 1;
937                 MALLOC(buf, char *, len, M_TEMP, M_WAITOK);
938                 sprintf(buf, "%s model %04x %s", vendor, id >> 16, type);
939                 return buf;
940         }
941         return type;
942 }
943
944 /*---------------------------------------------------------
945 **
946 **      Devices to ignore
947 **
948 **---------------------------------------------------------
949 */
950
951 static const char*
952 ign_match(device_t dev)
953 {
954         switch (pci_get_devid(dev)) {
955
956         case 0x10001042ul:      /* wd */
957                 return ("SMC FDC 37c665");
958         };
959
960         return NULL;
961 }
962
963 static int
964 ign_probe(device_t dev)
965 {
966         const char *s;
967
968         s = ign_match(dev);
969         if (s) {
970                 device_set_desc(dev, s);
971                 device_quiet(dev);
972                 return -1000;
973         }
974         return ENXIO;
975 }
976
977 static int
978 ign_attach(device_t dev)
979 {
980         return 0;
981 }
982
983 static device_method_t ign_methods[] = {
984         /* Device interface */
985         DEVMETHOD(device_probe,         ign_probe),
986         DEVMETHOD(device_attach,        ign_attach),
987
988         { 0, 0 }
989 };
990
991 static driver_t ign_driver = {
992         "ign",
993         ign_methods,
994         1,
995 };
996
997 static devclass_t ign_devclass;
998
999 DRIVER_MODULE(ign, pci, ign_driver, ign_devclass, 0, 0);