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