nappi_nppb.c revision 1.1 1 /* $NetBSD: nappi_nppb.c,v 1.1 2002/07/15 17:13:34 ichiro Exp $ */
2 /*
3 * Copyright (c) 2002
4 * Ichiro FUKUHARA <ichiro (at) ichiro.org>.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by Ichiro FUKUHARA.
18 * 4. The name of the company nor the name of the author may be used to
19 * endorse or promote products derived from this software without specific
20 * prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY ICHIRO FUKUHARA ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 * IN NO EVENT SHALL ICHIRO FUKUHARA OR THE VOICES IN HIS HEAD BE LIABLE FOR
26 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
33 */
34
35 #include "pci.h"
36 #include "opt_pci.h"
37
38 #include <sys/types.h>
39 #include <sys/param.h>
40 #include <sys/systm.h>
41 #include <sys/device.h>
42 #include <sys/extent.h>
43 #include <sys/malloc.h>
44
45 #include <machine/bus.h>
46
47 #include <dev/pci/pcivar.h>
48 #include <dev/pci/pcireg.h>
49 #include <dev/pci/pcidevs.h>
50 #include <dev/pci/pciconf.h>
51
52 static int nppbmatch(struct device *, struct cfdata *, void *);
53 static void nppbattach(struct device *, struct device *, void *);
54
55 struct cfattach nppb_ca = {
56 sizeof(struct device), nppbmatch, nppbattach
57 };
58
59 static int
60 nppbmatch(struct device *parent, struct cfdata *cf, void *aux)
61 {
62 struct pci_attach_args *pa = aux;
63 u_int32_t class, id;
64
65 class = pa->pa_class;
66 id = pa->pa_id;
67
68 if (PCI_CLASS(class) == PCI_CLASS_BRIDGE &&
69 PCI_SUBCLASS(class) == PCI_SUBCLASS_BRIDGE_MISC) {
70 #ifdef PCI_DEBUG
71 printf("pci vendor = 0x%08x\n", PCI_VENDOR(id));
72 printf("pci class = 0x%08x\n", PCI_CLASS(class));
73 printf("pci subclass = 0x%08x\n", PCI_SUBCLASS(class));
74 #endif
75 switch (PCI_VENDOR(id)) {
76 case PCI_VENDOR_INTEL:
77 switch (PCI_PRODUCT(id)) {
78 case PCI_PRODUCT_INTEL_21555:
79 return(1);
80 }
81 break;
82 }
83 }
84 return(0);
85 }
86
87 static void
88 nppbattach(struct device *parent, struct device *self, void *aux)
89 {
90 struct pci_attach_args *pa = aux;
91 char devinfo[256];
92
93 printf("\n");
94
95 pci_devinfo(pa->pa_id, pa->pa_class, 0, devinfo);
96 printf("%s: %s (rev. 0x%02x)\n", self->dv_xname, devinfo,
97 PCI_REVISION(pa->pa_class));
98 }
99