isavar.h revision 1.49 1 1.49 ad /* $NetBSD: isavar.h,v 1.49 2007/10/19 12:00:19 ad Exp $ */
2 1.26 thorpej
3 1.26 thorpej /*-
4 1.39 thorpej * Copyright (c) 1997, 2001 The NetBSD Foundation, Inc.
5 1.26 thorpej * All rights reserved.
6 1.26 thorpej *
7 1.26 thorpej * This code is derived from software contributed to The NetBSD Foundation
8 1.39 thorpej * by Jason R. Thorpe of Wasabi Systems, Inc.
9 1.26 thorpej *
10 1.26 thorpej * Redistribution and use in source and binary forms, with or without
11 1.26 thorpej * modification, are permitted provided that the following conditions
12 1.26 thorpej * are met:
13 1.26 thorpej * 1. Redistributions of source code must retain the above copyright
14 1.26 thorpej * notice, this list of conditions and the following disclaimer.
15 1.26 thorpej * 2. Redistributions in binary form must reproduce the above copyright
16 1.26 thorpej * notice, this list of conditions and the following disclaimer in the
17 1.26 thorpej * documentation and/or other materials provided with the distribution.
18 1.26 thorpej * 3. All advertising materials mentioning features or use of this software
19 1.26 thorpej * must display the following acknowledgement:
20 1.26 thorpej * This product includes software developed by the NetBSD
21 1.26 thorpej * Foundation, Inc. and its contributors.
22 1.26 thorpej * 4. Neither the name of The NetBSD Foundation nor the names of its
23 1.26 thorpej * contributors may be used to endorse or promote products derived
24 1.26 thorpej * from this software without specific prior written permission.
25 1.26 thorpej *
26 1.26 thorpej * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 1.26 thorpej * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 1.26 thorpej * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 1.26 thorpej * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 1.26 thorpej * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 1.26 thorpej * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 1.26 thorpej * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 1.26 thorpej * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 1.26 thorpej * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 1.26 thorpej * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 1.26 thorpej * POSSIBILITY OF SUCH DAMAGE.
37 1.26 thorpej */
38 1.11 cgd
39 1.8 mycroft /*
40 1.15 cgd * Copyright (c) 1995 Chris G. Demetriou
41 1.8 mycroft * Copyright (c) 1992 Berkeley Software Design, Inc.
42 1.8 mycroft * All rights reserved.
43 1.7 mycroft *
44 1.8 mycroft * Redistribution and use in source and binary forms, with or without
45 1.8 mycroft * modification, are permitted provided that the following conditions
46 1.8 mycroft * are met:
47 1.8 mycroft * 1. Redistributions of source code must retain the above copyright
48 1.8 mycroft * notice, this list of conditions and the following disclaimer.
49 1.8 mycroft * 2. Redistributions in binary form must reproduce the above copyright
50 1.8 mycroft * notice, this list of conditions and the following disclaimer in the
51 1.8 mycroft * documentation and/or other materials provided with the distribution.
52 1.8 mycroft * 3. All advertising materials mentioning features or use of this software
53 1.8 mycroft * must display the following acknowledgement:
54 1.8 mycroft * This product includes software developed by Berkeley Software
55 1.8 mycroft * Design, Inc.
56 1.8 mycroft * 4. The name of Berkeley Software Design must not be used to endorse
57 1.8 mycroft * or promote products derived from this software without specific
58 1.8 mycroft * prior written permission.
59 1.8 mycroft *
60 1.8 mycroft * THIS SOFTWARE IS PROVIDED BY BERKELEY SOFTWARE DESIGN, INC. ``AS IS'' AND
61 1.8 mycroft * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
62 1.8 mycroft * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
63 1.8 mycroft * ARE DISCLAIMED. IN NO EVENT SHALL BERKELEY SOFTWARE DESIGN, INC. BE LIABLE
64 1.8 mycroft * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
65 1.8 mycroft * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
66 1.8 mycroft * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
67 1.8 mycroft * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
68 1.8 mycroft * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
69 1.8 mycroft * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
70 1.8 mycroft * SUCH DAMAGE.
71 1.8 mycroft *
72 1.46 perry * BSDI Id: isavar.h,v 1.5 1992/12/01 18:06:00 karels Exp
73 1.7 mycroft */
74 1.7 mycroft
75 1.19 cgd #ifndef _DEV_ISA_ISAVAR_H_
76 1.19 cgd #define _DEV_ISA_ISAVAR_H_
77 1.19 cgd
78 1.7 mycroft /*
79 1.15 cgd * Definitions for ISA autoconfiguration.
80 1.15 cgd */
81 1.15 cgd
82 1.15 cgd #include <sys/queue.h>
83 1.49 ad #include <sys/bus.h>
84 1.18 cgd
85 1.46 perry /*
86 1.21 cgd * Structures and definitions needed by the machine-dependent header.
87 1.21 cgd */
88 1.21 cgd struct isabus_attach_args;
89 1.21 cgd
90 1.37 cgd #include <machine/isa_machdep.h>
91 1.21 cgd
92 1.18 cgd /*
93 1.18 cgd * ISA bus attach arguments
94 1.18 cgd */
95 1.18 cgd struct isabus_attach_args {
96 1.47 christos const char *_iba_busname; /* XXX placeholder */
97 1.24 thorpej bus_space_tag_t iba_iot; /* isa i/o space tag */
98 1.24 thorpej bus_space_tag_t iba_memt; /* isa mem space tag */
99 1.26 thorpej bus_dma_tag_t iba_dmat; /* isa DMA tag */
100 1.21 cgd isa_chipset_tag_t iba_ic;
101 1.18 cgd };
102 1.15 cgd
103 1.15 cgd /*
104 1.39 thorpej * ISA bus resources.
105 1.39 thorpej */
106 1.39 thorpej
107 1.39 thorpej struct isa_io {
108 1.39 thorpej int ir_addr;
109 1.39 thorpej int ir_size;
110 1.39 thorpej };
111 1.39 thorpej
112 1.39 thorpej struct isa_iomem {
113 1.39 thorpej int ir_addr;
114 1.39 thorpej int ir_size;
115 1.39 thorpej };
116 1.39 thorpej
117 1.39 thorpej struct isa_irq {
118 1.39 thorpej int ir_irq;
119 1.39 thorpej };
120 1.39 thorpej
121 1.39 thorpej struct isa_drq {
122 1.39 thorpej int ir_drq;
123 1.39 thorpej };
124 1.39 thorpej
125 1.39 thorpej struct isa_pnpname {
126 1.39 thorpej struct isa_pnpname *ipn_next;
127 1.39 thorpej char *ipn_name;
128 1.39 thorpej };
129 1.39 thorpej
130 1.39 thorpej /*
131 1.39 thorpej * Machine-dependent code provides a list of these to describe
132 1.39 thorpej * devices on the ISA bus which should be attached via direct
133 1.39 thorpej * configuration.
134 1.39 thorpej *
135 1.39 thorpej * All of this information is dynamically allocated, so that
136 1.39 thorpej * the ISA bus driver may free all of this information if the
137 1.39 thorpej * bus does not support dynamic attach/detach of devices (e.g.
138 1.39 thorpej * on a docking station).
139 1.39 thorpej *
140 1.39 thorpej * Some info on the "ik_key" field: This is a unique number for
141 1.39 thorpej * each knowndev node. If, when we need to re-enumerate the
142 1.39 thorpej * knowndevs, we discover that a node with key N is in the old
143 1.39 thorpej * list but not in the new, the device has disappeared. Similarly,
144 1.39 thorpej * if a node with key M is in the new list but not in the old,
145 1.39 thorpej * the device is new. Note that the knowndevs list must be
146 1.39 thorpej * sorted in ascending "key" order.
147 1.39 thorpej */
148 1.39 thorpej struct isa_knowndev {
149 1.39 thorpej TAILQ_ENTRY(isa_knowndev) ik_list;
150 1.39 thorpej uintptr_t ik_key;
151 1.39 thorpej struct device *ik_claimed;
152 1.39 thorpej
153 1.39 thorpej /*
154 1.39 thorpej * The rest of these fields correspond to isa_attach_args
155 1.39 thorpej * fields.
156 1.39 thorpej */
157 1.39 thorpej char *ik_pnpname;
158 1.39 thorpej struct isa_pnpname *ik_pnpcompatnames;
159 1.39 thorpej
160 1.39 thorpej struct isa_io *ik_io;
161 1.39 thorpej int ik_nio;
162 1.39 thorpej
163 1.39 thorpej struct isa_iomem *ik_iomem;
164 1.39 thorpej int ik_niomem;
165 1.39 thorpej
166 1.39 thorpej struct isa_irq *ik_irq;
167 1.39 thorpej int ik_nirq;
168 1.39 thorpej
169 1.39 thorpej struct isa_drq *ik_drq;
170 1.39 thorpej int ik_ndrq;
171 1.39 thorpej };
172 1.39 thorpej
173 1.39 thorpej /*
174 1.7 mycroft * ISA driver attach arguments
175 1.7 mycroft */
176 1.7 mycroft struct isa_attach_args {
177 1.24 thorpej bus_space_tag_t ia_iot; /* isa i/o space tag */
178 1.24 thorpej bus_space_tag_t ia_memt; /* isa mem space tag */
179 1.26 thorpej bus_dma_tag_t ia_dmat; /* DMA tag */
180 1.24 thorpej
181 1.21 cgd isa_chipset_tag_t ia_ic;
182 1.19 cgd
183 1.39 thorpej /*
184 1.39 thorpej * PNP (or other) names to with which we can match a device
185 1.39 thorpej * driver to a device that machine-dependent code tells us
186 1.39 thorpej * is there (i.e. support for direct-configuration of ISA
187 1.39 thorpej * devices).
188 1.39 thorpej */
189 1.39 thorpej char *ia_pnpname;
190 1.39 thorpej struct isa_pnpname *ia_pnpcompatnames;
191 1.39 thorpej
192 1.39 thorpej struct isa_io *ia_io; /* I/O resources */
193 1.39 thorpej int ia_nio;
194 1.39 thorpej
195 1.39 thorpej struct isa_iomem *ia_iomem; /* memory resources */
196 1.39 thorpej int ia_niomem;
197 1.39 thorpej
198 1.39 thorpej struct isa_irq *ia_irq; /* IRQ resources */
199 1.39 thorpej int ia_nirq;
200 1.39 thorpej
201 1.39 thorpej struct isa_drq *ia_drq; /* DRQ resources */
202 1.39 thorpej int ia_ndrq;
203 1.39 thorpej
204 1.7 mycroft void *ia_aux; /* driver specific */
205 1.7 mycroft };
206 1.7 mycroft
207 1.39 thorpej /*
208 1.39 thorpej * Test to determine if a given call to an ISA device probe routine
209 1.39 thorpej * is actually an attempt to do direct configuration.
210 1.39 thorpej */
211 1.39 thorpej #define ISA_DIRECT_CONFIG(ia) \
212 1.39 thorpej ((ia)->ia_pnpname != NULL || (ia)->ia_pnpcompatnames != NULL)
213 1.39 thorpej
214 1.7 mycroft /*
215 1.15 cgd * ISA master bus
216 1.7 mycroft */
217 1.7 mycroft struct isa_softc {
218 1.7 mycroft struct device sc_dev; /* base device */
219 1.19 cgd
220 1.24 thorpej bus_space_tag_t sc_iot; /* isa io space tag */
221 1.24 thorpej bus_space_tag_t sc_memt; /* isa mem space tag */
222 1.26 thorpej bus_dma_tag_t sc_dmat; /* isa DMA tag */
223 1.24 thorpej
224 1.21 cgd isa_chipset_tag_t sc_ic;
225 1.39 thorpej
226 1.39 thorpej TAILQ_HEAD(, isa_knowndev) sc_knowndevs;
227 1.39 thorpej int sc_dynamicdevs;
228 1.7 mycroft };
229 1.26 thorpej
230 1.44 drochner /*
231 1.44 drochner * These must be in sync with the ISACF_XXX_DEFAULT definitions
232 1.44 drochner * in "locators.h" (generated from files.isa).
233 1.44 drochner * (not including "locators.h" here to avoid dependency)
234 1.44 drochner */
235 1.44 drochner #define ISA_UNKNOWN_PORT (-1)
236 1.44 drochner #define ISA_UNKNOWN_IOMEM (-1)
237 1.44 drochner #define ISA_UNKNOWN_IOSIZ (0)
238 1.44 drochner #define ISA_UNKNOWN_IRQ (-1)
239 1.44 drochner #define ISA_UNKNOWN_DRQ (-1)
240 1.44 drochner #define ISA_UNKNOWN_DRQ2 (-1)
241 1.7 mycroft
242 1.42 drochner int isabusprint(void *, const char *);
243 1.42 drochner
244 1.7 mycroft /*
245 1.15 cgd * ISA interrupt handler manipulation.
246 1.46 perry *
247 1.15 cgd * To establish an ISA interrupt handler, a driver calls isa_intr_establish()
248 1.15 cgd * with the interrupt number, type, level, function, and function argument of
249 1.15 cgd * the interrupt it wants to handle. Isa_intr_establish() returns an opaque
250 1.35 leo * handle to an event descriptor if it succeeds, and returns NULL on failure.
251 1.35 leo * (XXX: some drivers can't handle this, since the former behaviour was to
252 1.35 leo * invoke panic() on failure). When the system does not accept any of the
253 1.35 leo * interrupt types supported by the driver, the driver should fail the attach.
254 1.35 leo * Interrupt handlers should return 0 for "interrupt not for me", 1 for
255 1.35 leo * "I took care of it", or -1 for "I guess it was mine, but I wasn't
256 1.35 leo * expecting it."
257 1.15 cgd *
258 1.46 perry * To remove an interrupt handler, the driver calls isa_intr_disestablish()
259 1.15 cgd * with the handle returned by isa_intr_establish() for that handler.
260 1.38 cgd *
261 1.38 cgd * The event counter (struct evcnt) associated with an interrupt line
262 1.38 cgd * (to be used as 'parent' for an ISA device's interrupt handler's evcnt)
263 1.38 cgd * can be obtained with isa_intr_evcnt().
264 1.15 cgd */
265 1.15 cgd
266 1.15 cgd /* ISA interrupt sharing types */
267 1.47 christos const char *isa_intr_typename(int);
268 1.26 thorpej
269 1.26 thorpej /*
270 1.26 thorpej * Some ISA devices (e.g. on a VLB) can perform 32-bit DMA. This
271 1.26 thorpej * flag is passed to bus_dmamap_create() to indicate that fact.
272 1.26 thorpej */
273 1.26 thorpej #define ISABUS_DMA_32BIT BUS_DMA_BUS1
274 1.40 fvdl
275 1.40 fvdl /*
276 1.40 fvdl * This flag indicates that the DMA channel should not yet be reserved,
277 1.40 fvdl * even if BUS_DMA_ALLOCNOW is specified.
278 1.40 fvdl */
279 1.40 fvdl #define ISABUS_DMA_DEFERCHAN BUS_DMA_BUS2
280 1.19 cgd
281 1.19 cgd #endif /* _DEV_ISA_ISAVAR_H_ */
282