pcib.c revision 1.1.10.2 1 1.1.10.2 bouyer /* $NetBSD: pcib.c,v 1.1.10.2 2007/11/13 16:00:20 bouyer Exp $ */
2 1.1.10.2 bouyer
3 1.1.10.2 bouyer /*-
4 1.1.10.2 bouyer * Copyright (c) 1996, 1998 The NetBSD Foundation, Inc.
5 1.1.10.2 bouyer * All rights reserved.
6 1.1.10.2 bouyer *
7 1.1.10.2 bouyer * This code is derived from software contributed to The NetBSD Foundation
8 1.1.10.2 bouyer * by Jason R. Thorpe.
9 1.1.10.2 bouyer *
10 1.1.10.2 bouyer * Redistribution and use in source and binary forms, with or without
11 1.1.10.2 bouyer * modification, are permitted provided that the following conditions
12 1.1.10.2 bouyer * are met:
13 1.1.10.2 bouyer * 1. Redistributions of source code must retain the above copyright
14 1.1.10.2 bouyer * notice, this list of conditions and the following disclaimer.
15 1.1.10.2 bouyer * 2. Redistributions in binary form must reproduce the above copyright
16 1.1.10.2 bouyer * notice, this list of conditions and the following disclaimer in the
17 1.1.10.2 bouyer * documentation and/or other materials provided with the distribution.
18 1.1.10.2 bouyer * 3. All advertising materials mentioning features or use of this software
19 1.1.10.2 bouyer * must display the following acknowledgement:
20 1.1.10.2 bouyer * This product includes software developed by the NetBSD
21 1.1.10.2 bouyer * Foundation, Inc. and its contributors.
22 1.1.10.2 bouyer * 4. Neither the name of The NetBSD Foundation nor the names of its
23 1.1.10.2 bouyer * contributors may be used to endorse or promote products derived
24 1.1.10.2 bouyer * from this software without specific prior written permission.
25 1.1.10.2 bouyer *
26 1.1.10.2 bouyer * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 1.1.10.2 bouyer * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 1.1.10.2 bouyer * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 1.1.10.2 bouyer * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 1.1.10.2 bouyer * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 1.1.10.2 bouyer * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 1.1.10.2 bouyer * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 1.1.10.2 bouyer * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 1.1.10.2 bouyer * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 1.1.10.2 bouyer * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 1.1.10.2 bouyer * POSSIBILITY OF SUCH DAMAGE.
37 1.1.10.2 bouyer */
38 1.1.10.2 bouyer
39 1.1.10.2 bouyer #include <sys/cdefs.h>
40 1.1.10.2 bouyer __KERNEL_RCSID(0, "$NetBSD: pcib.c,v 1.1.10.2 2007/11/13 16:00:20 bouyer Exp $");
41 1.1.10.2 bouyer
42 1.1.10.2 bouyer #include <sys/types.h>
43 1.1.10.2 bouyer #include <sys/param.h>
44 1.1.10.2 bouyer #include <sys/systm.h>
45 1.1.10.2 bouyer #include <sys/device.h>
46 1.1.10.2 bouyer
47 1.1.10.2 bouyer #include <machine/bus.h>
48 1.1.10.2 bouyer
49 1.1.10.2 bouyer #include <dev/isa/isavar.h>
50 1.1.10.2 bouyer
51 1.1.10.2 bouyer #include <dev/pci/pcivar.h>
52 1.1.10.2 bouyer #include <dev/pci/pcireg.h>
53 1.1.10.2 bouyer
54 1.1.10.2 bouyer #include <dev/pci/pcidevs.h>
55 1.1.10.2 bouyer
56 1.1.10.2 bouyer #include "isa.h"
57 1.1.10.2 bouyer
58 1.1.10.2 bouyer int pcibmatch(struct device *, struct cfdata *, void *);
59 1.1.10.2 bouyer void pcibattach(struct device *, struct device *, void *);
60 1.1.10.2 bouyer
61 1.1.10.2 bouyer CFATTACH_DECL(pcib, sizeof(struct device),
62 1.1.10.2 bouyer pcibmatch, pcibattach, NULL, NULL);
63 1.1.10.2 bouyer
64 1.1.10.2 bouyer void pcib_callback(struct device *);
65 1.1.10.2 bouyer
66 1.1.10.2 bouyer int
67 1.1.10.2 bouyer pcibmatch(struct device *parent, struct cfdata *match, void *aux)
68 1.1.10.2 bouyer {
69 1.1.10.2 bouyer struct pci_attach_args *pa = aux;
70 1.1.10.2 bouyer
71 1.1.10.2 bouyer #if 0
72 1.1.10.2 bouyer /*
73 1.1.10.2 bouyer * PCI-ISA bridges are matched on class/subclass.
74 1.1.10.2 bouyer * This list contains only the bridges where correct
75 1.1.10.2 bouyer * (or incorrect) behaviour is not yet confirmed.
76 1.1.10.2 bouyer */
77 1.1.10.2 bouyer switch (PCI_VENDOR(pa->pa_id)) {
78 1.1.10.2 bouyer case PCI_VENDOR_INTEL:
79 1.1.10.2 bouyer switch (PCI_PRODUCT(pa->pa_id)) {
80 1.1.10.2 bouyer case PCI_PRODUCT_INTEL_82426EX:
81 1.1.10.2 bouyer case PCI_PRODUCT_INTEL_82380AB:
82 1.1.10.2 bouyer return (1);
83 1.1.10.2 bouyer }
84 1.1.10.2 bouyer break;
85 1.1.10.2 bouyer
86 1.1.10.2 bouyer case PCI_VENDOR_UMC:
87 1.1.10.2 bouyer switch (PCI_PRODUCT(pa->pa_id)) {
88 1.1.10.2 bouyer case PCI_PRODUCT_UMC_UM8886F:
89 1.1.10.2 bouyer case PCI_PRODUCT_UMC_UM82C886:
90 1.1.10.2 bouyer return (1);
91 1.1.10.2 bouyer }
92 1.1.10.2 bouyer break;
93 1.1.10.2 bouyer case PCI_VENDOR_ALI:
94 1.1.10.2 bouyer switch (PCI_PRODUCT(pa->pa_id)) {
95 1.1.10.2 bouyer case PCI_PRODUCT_ALI_M1449:
96 1.1.10.2 bouyer case PCI_PRODUCT_ALI_M1543:
97 1.1.10.2 bouyer return (1);
98 1.1.10.2 bouyer }
99 1.1.10.2 bouyer break;
100 1.1.10.2 bouyer case PCI_VENDOR_COMPAQ:
101 1.1.10.2 bouyer switch (PCI_PRODUCT(pa->pa_id)) {
102 1.1.10.2 bouyer case PCI_PRODUCT_COMPAQ_PCI_ISA_BRIDGE:
103 1.1.10.2 bouyer return (1);
104 1.1.10.2 bouyer }
105 1.1.10.2 bouyer break;
106 1.1.10.2 bouyer case PCI_VENDOR_VIATECH:
107 1.1.10.2 bouyer switch (PCI_PRODUCT(pa->pa_id)) {
108 1.1.10.2 bouyer case PCI_PRODUCT_VIATECH_VT82C570MV:
109 1.1.10.2 bouyer case PCI_PRODUCT_VIATECH_VT82C586_ISA:
110 1.1.10.2 bouyer return (1);
111 1.1.10.2 bouyer }
112 1.1.10.2 bouyer break;
113 1.1.10.2 bouyer }
114 1.1.10.2 bouyer #endif
115 1.1.10.2 bouyer
116 1.1.10.2 bouyer /*
117 1.1.10.2 bouyer * some special cases:
118 1.1.10.2 bouyer */
119 1.1.10.2 bouyer switch (PCI_VENDOR(pa->pa_id)) {
120 1.1.10.2 bouyer case PCI_VENDOR_INTEL:
121 1.1.10.2 bouyer switch (PCI_PRODUCT(pa->pa_id)) {
122 1.1.10.2 bouyer case PCI_PRODUCT_INTEL_SIO:
123 1.1.10.2 bouyer /*
124 1.1.10.2 bouyer * The Intel SIO identifies itself as a
125 1.1.10.2 bouyer * miscellaneous prehistoric.
126 1.1.10.2 bouyer */
127 1.1.10.2 bouyer case PCI_PRODUCT_INTEL_82371MX:
128 1.1.10.2 bouyer /*
129 1.1.10.2 bouyer * The Intel 82371MX identifies itself erroneously as a
130 1.1.10.2 bouyer * miscellaneous bridge.
131 1.1.10.2 bouyer */
132 1.1.10.2 bouyer case PCI_PRODUCT_INTEL_82371AB_ISA:
133 1.1.10.2 bouyer /*
134 1.1.10.2 bouyer * Some Intel 82371AB PCI-ISA bridge identifies
135 1.1.10.2 bouyer * itself as miscellaneous bridge.
136 1.1.10.2 bouyer */
137 1.1.10.2 bouyer return (1);
138 1.1.10.2 bouyer }
139 1.1.10.2 bouyer break;
140 1.1.10.2 bouyer case PCI_VENDOR_SIS:
141 1.1.10.2 bouyer switch (PCI_PRODUCT(pa->pa_id)) {
142 1.1.10.2 bouyer case PCI_PRODUCT_SIS_85C503:
143 1.1.10.2 bouyer /*
144 1.1.10.2 bouyer * The SIS 85C503 identifies itself as a
145 1.1.10.2 bouyer * miscellaneous prehistoric.
146 1.1.10.2 bouyer */
147 1.1.10.2 bouyer return (1);
148 1.1.10.2 bouyer }
149 1.1.10.2 bouyer break;
150 1.1.10.2 bouyer case PCI_VENDOR_VIATECH:
151 1.1.10.2 bouyer switch (PCI_PRODUCT(pa->pa_id)) {
152 1.1.10.2 bouyer case PCI_PRODUCT_VIATECH_VT82C686A_SMB:
153 1.1.10.2 bouyer /*
154 1.1.10.2 bouyer * The VIA VT82C686A SMBus Controller itself as
155 1.1.10.2 bouyer * ISA bridge, but it's wrong !
156 1.1.10.2 bouyer */
157 1.1.10.2 bouyer return (0);
158 1.1.10.2 bouyer }
159 1.1.10.2 bouyer /*
160 1.1.10.2 bouyer * The Cyrix cs5530 PCI host bridge does not have a broken
161 1.1.10.2 bouyer * latch on the i8254 clock core, unlike its predecessors
162 1.1.10.2 bouyer * the cs5510 and cs5520. This reverses the setting from
163 1.1.10.2 bouyer * i386/i386/identcpu.c where it arguably should not have
164 1.1.10.2 bouyer * been set in the first place. XXX
165 1.1.10.2 bouyer */
166 1.1.10.2 bouyer case PCI_VENDOR_CYRIX:
167 1.1.10.2 bouyer switch (PCI_PRODUCT(pa->pa_id)) {
168 1.1.10.2 bouyer case PCI_PRODUCT_CYRIX_CX5530_PCIB:
169 1.1.10.2 bouyer {
170 1.1.10.2 bouyer extern int clock_broken_latch;
171 1.1.10.2 bouyer
172 1.1.10.2 bouyer clock_broken_latch = 0;
173 1.1.10.2 bouyer }
174 1.1.10.2 bouyer return(1);
175 1.1.10.2 bouyer }
176 1.1.10.2 bouyer break;
177 1.1.10.2 bouyer }
178 1.1.10.2 bouyer
179 1.1.10.2 bouyer if (PCI_CLASS(pa->pa_class) == PCI_CLASS_BRIDGE &&
180 1.1.10.2 bouyer PCI_SUBCLASS(pa->pa_class) == PCI_SUBCLASS_BRIDGE_ISA) {
181 1.1.10.2 bouyer return (1);
182 1.1.10.2 bouyer }
183 1.1.10.2 bouyer
184 1.1.10.2 bouyer return (0);
185 1.1.10.2 bouyer }
186 1.1.10.2 bouyer
187 1.1.10.2 bouyer void
188 1.1.10.2 bouyer pcibattach(struct device *parent, struct device *self, void *aux)
189 1.1.10.2 bouyer {
190 1.1.10.2 bouyer struct pci_attach_args *pa = aux;
191 1.1.10.2 bouyer char devinfo[256];
192 1.1.10.2 bouyer
193 1.1.10.2 bouyer aprint_naive("\n");
194 1.1.10.2 bouyer aprint_normal("\n");
195 1.1.10.2 bouyer
196 1.1.10.2 bouyer /*
197 1.1.10.2 bouyer * Just print out a description and defer configuration
198 1.1.10.2 bouyer * until all PCI devices have been attached.
199 1.1.10.2 bouyer */
200 1.1.10.2 bouyer pci_devinfo(pa->pa_id, pa->pa_class, 0, devinfo, sizeof(devinfo));
201 1.1.10.2 bouyer aprint_normal("%s: %s (rev. 0x%02x)\n", self->dv_xname, devinfo,
202 1.1.10.2 bouyer PCI_REVISION(pa->pa_class));
203 1.1.10.2 bouyer
204 1.1.10.2 bouyer config_defer(self, pcib_callback);
205 1.1.10.2 bouyer }
206 1.1.10.2 bouyer
207 1.1.10.2 bouyer void
208 1.1.10.2 bouyer pcib_callback(struct device *self)
209 1.1.10.2 bouyer {
210 1.1.10.2 bouyer struct isabus_attach_args iba;
211 1.1.10.2 bouyer
212 1.1.10.2 bouyer /*
213 1.1.10.2 bouyer * Attach the ISA bus behind this bridge.
214 1.1.10.2 bouyer */
215 1.1.10.2 bouyer memset(&iba, 0, sizeof(iba));
216 1.1.10.2 bouyer iba.iba_iot = X86_BUS_SPACE_IO;
217 1.1.10.2 bouyer iba.iba_memt = X86_BUS_SPACE_MEM;
218 1.1.10.2 bouyer #if NISA > 0
219 1.1.10.2 bouyer iba.iba_dmat = &isa_bus_dma_tag;
220 1.1.10.2 bouyer #endif
221 1.1.10.2 bouyer config_found_ia(self, "isabus", &iba, isabusprint);
222 1.1.10.2 bouyer }
223