pcib.c revision 1.9.76.1 1 /* $NetBSD: pcib.c,v 1.9.76.1 2008/05/18 12:32:31 yamt Exp $ */
2
3 /*-
4 * Copyright (c) 1996, 1998 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Jason R. Thorpe.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 *
31 * from: i386/pci/pcib.c,v 1.12
32 */
33
34 #include <sys/cdefs.h>
35 __KERNEL_RCSID(0, "$NetBSD: pcib.c,v 1.9.76.1 2008/05/18 12:32:31 yamt Exp $");
36
37 #include <sys/param.h>
38 #include <sys/systm.h>
39 #include <sys/device.h>
40
41 #include <machine/bus.h>
42
43 #include <dev/isa/isavar.h>
44
45 #include <dev/pci/pcivar.h>
46 #include <dev/pci/pcireg.h>
47
48 #include <dev/pci/pcidevs.h>
49
50 #include "isadma.h"
51
52 int pcibmatch __P((struct device *, struct cfdata *, void *));
53 void pcibattach __P((struct device *, struct device *, void *));
54
55 CFATTACH_DECL(pcib, sizeof(struct device),
56 pcibmatch, pcibattach, NULL, NULL);
57
58 void pcib_callback __P((struct device *));
59
60 int
61 pcibmatch(parent, match, aux)
62 struct device *parent;
63 struct cfdata *match;
64 void *aux;
65 {
66 struct pci_attach_args *pa = aux;
67
68 /*
69 * Match tested PCI-ISA bridges.
70 */
71 switch (PCI_VENDOR(pa->pa_id)) {
72 case PCI_VENDOR_WINBOND:
73 switch (PCI_PRODUCT(pa->pa_id)) {
74 case PCI_PRODUCT_WINBOND_W83C553F_0:
75 return (1);
76 }
77 break;
78
79 case PCI_VENDOR_SYMPHONY:
80 switch (PCI_PRODUCT(pa->pa_id)) {
81 case PCI_PRODUCT_SYMPHONY_83C553:
82 return (1);
83 }
84 break;
85 }
86
87 return (0);
88 }
89
90 void
91 pcibattach(parent, self, aux)
92 struct device *parent, *self;
93 void *aux;
94 {
95 struct pci_attach_args *pa = aux;
96 char devinfo[256];
97
98 printf("\n");
99
100 /*
101 * Just print out a description and set the ISA bus
102 * callback.
103 */
104 pci_devinfo(pa->pa_id, pa->pa_class, 0, devinfo, sizeof(devinfo));
105 printf("%s: %s (rev. 0x%02x)\n", self->dv_xname, devinfo,
106 PCI_REVISION(pa->pa_class));
107
108 /* Set the ISA bus callback */
109 config_defer(self, pcib_callback);
110 }
111
112 void
113 pcib_callback(self)
114 struct device *self;
115 {
116 struct isabus_attach_args iba;
117
118 /*
119 * Attach the ISA bus behind this bridge.
120 */
121 memset(&iba, 0, sizeof(iba));
122 iba.iba_iot = &isa_io_bs_tag;
123 iba.iba_memt = &isa_mem_bs_tag;
124 #if NISADMA > 0
125 iba.iba_dmat = &isa_bus_dma_tag;
126 #endif
127 config_found_ia(self, "isabus", &iba, isabusprint);
128 }
129