eisa_machdep.c revision 1.1.16.2 1 1.1.16.2 yamt /* $NetBSD: eisa_machdep.c,v 1.1.16.2 2006/06/21 14:55:11 yamt Exp $ */
2 1.1.16.2 yamt
3 1.1.16.2 yamt /*-
4 1.1.16.2 yamt * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
5 1.1.16.2 yamt * All rights reserved.
6 1.1.16.2 yamt *
7 1.1.16.2 yamt * This code is derived from software contributed to The NetBSD Foundation
8 1.1.16.2 yamt * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
9 1.1.16.2 yamt * NASA Ames Research Center.
10 1.1.16.2 yamt *
11 1.1.16.2 yamt * Redistribution and use in source and binary forms, with or without
12 1.1.16.2 yamt * modification, are permitted provided that the following conditions
13 1.1.16.2 yamt * are met:
14 1.1.16.2 yamt * 1. Redistributions of source code must retain the above copyright
15 1.1.16.2 yamt * notice, this list of conditions and the following disclaimer.
16 1.1.16.2 yamt * 2. Redistributions in binary form must reproduce the above copyright
17 1.1.16.2 yamt * notice, this list of conditions and the following disclaimer in the
18 1.1.16.2 yamt * documentation and/or other materials provided with the distribution.
19 1.1.16.2 yamt * 3. All advertising materials mentioning features or use of this software
20 1.1.16.2 yamt * must display the following acknowledgement:
21 1.1.16.2 yamt * This product includes software developed by the NetBSD
22 1.1.16.2 yamt * Foundation, Inc. and its contributors.
23 1.1.16.2 yamt * 4. Neither the name of The NetBSD Foundation nor the names of its
24 1.1.16.2 yamt * contributors may be used to endorse or promote products derived
25 1.1.16.2 yamt * from this software without specific prior written permission.
26 1.1.16.2 yamt *
27 1.1.16.2 yamt * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
28 1.1.16.2 yamt * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
29 1.1.16.2 yamt * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
30 1.1.16.2 yamt * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
31 1.1.16.2 yamt * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32 1.1.16.2 yamt * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33 1.1.16.2 yamt * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34 1.1.16.2 yamt * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35 1.1.16.2 yamt * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36 1.1.16.2 yamt * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37 1.1.16.2 yamt * POSSIBILITY OF SUCH DAMAGE.
38 1.1.16.2 yamt */
39 1.1.16.2 yamt
40 1.1.16.2 yamt /*
41 1.1.16.2 yamt * Copyright (c) 1996 Christopher G. Demetriou. All rights reserved.
42 1.1.16.2 yamt *
43 1.1.16.2 yamt * Redistribution and use in source and binary forms, with or without
44 1.1.16.2 yamt * modification, are permitted provided that the following conditions
45 1.1.16.2 yamt * are met:
46 1.1.16.2 yamt * 1. Redistributions of source code must retain the above copyright
47 1.1.16.2 yamt * notice, this list of conditions and the following disclaimer.
48 1.1.16.2 yamt * 2. Redistributions in binary form must reproduce the above copyright
49 1.1.16.2 yamt * notice, this list of conditions and the following disclaimer in the
50 1.1.16.2 yamt * documentation and/or other materials provided with the distribution.
51 1.1.16.2 yamt * 3. All advertising materials mentioning features or use of this software
52 1.1.16.2 yamt * must display the following acknowledgement:
53 1.1.16.2 yamt * This product includes software developed by Christopher G. Demetriou
54 1.1.16.2 yamt * for the NetBSD Project.
55 1.1.16.2 yamt * 4. The name of the author may not be used to endorse or promote products
56 1.1.16.2 yamt * derived from this software without specific prior written permission
57 1.1.16.2 yamt *
58 1.1.16.2 yamt * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
59 1.1.16.2 yamt * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
60 1.1.16.2 yamt * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
61 1.1.16.2 yamt * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
62 1.1.16.2 yamt * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
63 1.1.16.2 yamt * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
64 1.1.16.2 yamt * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
65 1.1.16.2 yamt * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
66 1.1.16.2 yamt * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
67 1.1.16.2 yamt * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
68 1.1.16.2 yamt */
69 1.1.16.2 yamt
70 1.1.16.2 yamt /*
71 1.1.16.2 yamt * Machine-specific functions for EISA autoconfiguration.
72 1.1.16.2 yamt */
73 1.1.16.2 yamt
74 1.1.16.2 yamt #include <sys/cdefs.h>
75 1.1.16.2 yamt __KERNEL_RCSID(0, "$NetBSD: eisa_machdep.c,v 1.1.16.2 2006/06/21 14:55:11 yamt Exp $");
76 1.1.16.2 yamt
77 1.1.16.2 yamt #include <sys/types.h>
78 1.1.16.2 yamt #include <sys/param.h>
79 1.1.16.2 yamt #include <sys/time.h>
80 1.1.16.2 yamt #include <sys/systm.h>
81 1.1.16.2 yamt #include <sys/errno.h>
82 1.1.16.2 yamt #include <sys/device.h>
83 1.1.16.2 yamt #include <sys/extent.h>
84 1.1.16.2 yamt
85 1.1.16.2 yamt #define _POWERPC_BUS_DMA_PRIVATE
86 1.1.16.2 yamt #include <machine/bus.h>
87 1.1.16.2 yamt #include <machine/pio.h>
88 1.1.16.2 yamt #include <machine/intr.h>
89 1.1.16.2 yamt
90 1.1.16.2 yamt #include <dev/isa/isareg.h>
91 1.1.16.2 yamt #include <dev/isa/isavar.h>
92 1.1.16.2 yamt #include <dev/eisa/eisavar.h>
93 1.1.16.2 yamt
94 1.1.16.2 yamt /*
95 1.1.16.2 yamt * EISA doesn't have any special needs; just use the generic versions
96 1.1.16.2 yamt * of these funcions.
97 1.1.16.2 yamt */
98 1.1.16.2 yamt struct powerpc_bus_dma_tag eisa_bus_dma_tag = {
99 1.1.16.2 yamt 0, /* _bounce_thresh */
100 1.1.16.2 yamt _bus_dmamap_create,
101 1.1.16.2 yamt _bus_dmamap_destroy,
102 1.1.16.2 yamt _bus_dmamap_load,
103 1.1.16.2 yamt _bus_dmamap_load_mbuf,
104 1.1.16.2 yamt _bus_dmamap_load_uio,
105 1.1.16.2 yamt _bus_dmamap_load_raw,
106 1.1.16.2 yamt _bus_dmamap_unload,
107 1.1.16.2 yamt NULL, /* _dmamap_sync */
108 1.1.16.2 yamt _bus_dmamem_alloc,
109 1.1.16.2 yamt _bus_dmamem_free,
110 1.1.16.2 yamt _bus_dmamem_map,
111 1.1.16.2 yamt _bus_dmamem_unmap,
112 1.1.16.2 yamt _bus_dmamem_mmap,
113 1.1.16.2 yamt };
114 1.1.16.2 yamt
115 1.1.16.2 yamt void
116 1.1.16.2 yamt eisa_attach_hook(struct device *parent, struct device *self,
117 1.1.16.2 yamt struct eisabus_attach_args *eba)
118 1.1.16.2 yamt {
119 1.1.16.2 yamt /* Nothing to do. */
120 1.1.16.2 yamt }
121 1.1.16.2 yamt
122 1.1.16.2 yamt int
123 1.1.16.2 yamt eisa_maxslots(eisa_chipset_tag_t ec)
124 1.1.16.2 yamt {
125 1.1.16.2 yamt
126 1.1.16.2 yamt /*
127 1.1.16.2 yamt * Always try 16 slots.
128 1.1.16.2 yamt */
129 1.1.16.2 yamt return (16);
130 1.1.16.2 yamt }
131 1.1.16.2 yamt
132 1.1.16.2 yamt int
133 1.1.16.2 yamt eisa_intr_map(eisa_chipset_tag_t ec, u_int irq, eisa_intr_handle_t *ihp)
134 1.1.16.2 yamt {
135 1.1.16.2 yamt if (irq >= I8259_INTR_NUM) {
136 1.1.16.2 yamt printf("eisa_intr_map: bad IRQ %d\n", irq);
137 1.1.16.2 yamt *ihp = -1;
138 1.1.16.2 yamt return 1;
139 1.1.16.2 yamt }
140 1.1.16.2 yamt if (irq == 2) {
141 1.1.16.2 yamt printf("eisa_intr_map: changed IRQ 2 to IRQ 9\n");
142 1.1.16.2 yamt irq = 9;
143 1.1.16.2 yamt }
144 1.1.16.2 yamt
145 1.1.16.2 yamt *ihp = irq;
146 1.1.16.2 yamt return 0;
147 1.1.16.2 yamt }
148 1.1.16.2 yamt
149 1.1.16.2 yamt const char *
150 1.1.16.2 yamt eisa_intr_string(eisa_chipset_tag_t ec, eisa_intr_handle_t ih)
151 1.1.16.2 yamt {
152 1.1.16.2 yamt static char irqstr[8]; /* 4 + 2 + NULL + sanity */
153 1.1.16.2 yamt
154 1.1.16.2 yamt if (ih == 0 || (ih & 0xff) >= I8259_INTR_NUM || ih == 2)
155 1.1.16.2 yamt panic("eisa_intr_string: bogus handle 0x%x", ih);
156 1.1.16.2 yamt
157 1.1.16.2 yamt snprintf(irqstr, sizeof(irqstr), "irq %d", ih);
158 1.1.16.2 yamt return (irqstr);
159 1.1.16.2 yamt
160 1.1.16.2 yamt }
161 1.1.16.2 yamt
162 1.1.16.2 yamt const struct evcnt *
163 1.1.16.2 yamt eisa_intr_evcnt(eisa_chipset_tag_t ec, eisa_intr_handle_t ih)
164 1.1.16.2 yamt {
165 1.1.16.2 yamt
166 1.1.16.2 yamt /* XXX for now, no evcnt parent reported */
167 1.1.16.2 yamt return NULL;
168 1.1.16.2 yamt }
169 1.1.16.2 yamt
170 1.1.16.2 yamt void *
171 1.1.16.2 yamt eisa_intr_establish(eisa_chipset_tag_t ec, eisa_intr_handle_t ih,
172 1.1.16.2 yamt int type, int level, int (*func)(void *), void *arg)
173 1.1.16.2 yamt {
174 1.1.16.2 yamt int irq;
175 1.1.16.2 yamt
176 1.1.16.2 yamt irq = ih;
177 1.1.16.2 yamt return (void *)intr_establish(irq, type, level, func, arg);
178 1.1.16.2 yamt }
179 1.1.16.2 yamt
180 1.1.16.2 yamt void
181 1.1.16.2 yamt eisa_intr_disestablish(eisa_chipset_tag_t ec, void *cookie)
182 1.1.16.2 yamt {
183 1.1.16.2 yamt
184 1.1.16.2 yamt intr_disestablish(cookie);
185 1.1.16.2 yamt }
186 1.1.16.2 yamt
187 1.1.16.2 yamt int
188 1.1.16.2 yamt eisa_conf_read_mem(eisa_chipset_tag_t ec, int slot, int func, int entry,
189 1.1.16.2 yamt struct eisa_cfg_mem *ecm)
190 1.1.16.2 yamt {
191 1.1.16.2 yamt
192 1.1.16.2 yamt /* XXX XXX XXX */
193 1.1.16.2 yamt return (ENOENT);
194 1.1.16.2 yamt }
195 1.1.16.2 yamt
196 1.1.16.2 yamt int
197 1.1.16.2 yamt eisa_conf_read_irq(eisa_chipset_tag_t ec, int slot, int func, int entry,
198 1.1.16.2 yamt struct eisa_cfg_irq *eci)
199 1.1.16.2 yamt {
200 1.1.16.2 yamt
201 1.1.16.2 yamt /* XXX XXX XXX */
202 1.1.16.2 yamt return (ENOENT);
203 1.1.16.2 yamt }
204 1.1.16.2 yamt
205 1.1.16.2 yamt int
206 1.1.16.2 yamt eisa_conf_read_dma(eisa_chipset_tag_t ec, int slot, int func, int entry,
207 1.1.16.2 yamt struct eisa_cfg_dma *ecd)
208 1.1.16.2 yamt {
209 1.1.16.2 yamt
210 1.1.16.2 yamt /* XXX XXX XXX */
211 1.1.16.2 yamt return (ENOENT);
212 1.1.16.2 yamt }
213 1.1.16.2 yamt
214 1.1.16.2 yamt int
215 1.1.16.2 yamt eisa_conf_read_io(eisa_chipset_tag_t ec, int slot, int func, int entry,
216 1.1.16.2 yamt struct eisa_cfg_io *ecio)
217 1.1.16.2 yamt {
218 1.1.16.2 yamt
219 1.1.16.2 yamt /* XXX XXX XXX */
220 1.1.16.2 yamt return (ENOENT);
221 1.1.16.2 yamt }
222