isa_machdep.c revision 1.9 1 /* $NetBSD: isa_machdep.c,v 1.9 2009/08/18 17:02:00 dyoung 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 Jesse Off
9 *
10 * This code is derived from software contributed to The NetBSD Foundation
11 * by Mark Brinicombe, Charles M. Hannum and by Jason R. Thorpe of the
12 * Numerical Aerospace Simulation Facility, NASA Ames Research Center.
13 *
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions
16 * are met:
17 * 1. Redistributions of source code must retain the above copyright
18 * notice, this list of conditions and the following disclaimer.
19 * 2. Redistributions in binary form must reproduce the above copyright
20 * notice, this list of conditions and the following disclaimer in the
21 * documentation and/or other materials provided with the distribution.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
24 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
25 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
26 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
27 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 * POSSIBILITY OF SUCH DAMAGE.
34 */
35
36 /*-
37 * Copyright (c) 1991 The Regents of the University of California.
38 * All rights reserved.
39 *
40 * This code is derived from software contributed to Berkeley by
41 * William Jolitz.
42 *
43 * Redistribution and use in source and binary forms, with or without
44 * modification, are permitted provided that the following conditions
45 * are met:
46 * 1. Redistributions of source code must retain the above copyright
47 * notice, this list of conditions and the following disclaimer.
48 * 2. Redistributions in binary form must reproduce the above copyright
49 * notice, this list of conditions and the following disclaimer in the
50 * documentation and/or other materials provided with the distribution.
51 * 3. Neither the name of the University nor the names of its contributors
52 * may be used to endorse or promote products derived from this software
53 * without specific prior written permission.
54 *
55 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
56 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
57 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
58 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
59 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
60 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
61 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
62 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
63 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
64 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
65 * SUCH DAMAGE.
66 *
67 * @(#)isa.c 7.2 (Berkeley) 5/13/91
68 */
69
70 #include <sys/cdefs.h>
71 __KERNEL_RCSID(0, "$NetBSD: isa_machdep.c,v 1.9 2009/08/18 17:02:00 dyoung Exp $");
72
73 #include "opt_irqstats.h"
74
75 #include <sys/param.h>
76 #include <sys/systm.h>
77 #include <sys/kernel.h>
78 #include <sys/syslog.h>
79 #include <sys/device.h>
80 #include <sys/malloc.h>
81 #include <sys/proc.h>
82
83 #include <machine/bus.h>
84
85 #include <machine/intr.h>
86 #include <machine/pio.h>
87 #include <machine/bootconfig.h>
88 #include <machine/isa_machdep.h>
89
90 #include <dev/isa/isareg.h>
91 #include <dev/isa/isavar.h>
92
93 #include <arm/ep93xx/ep93xxvar.h>
94 #include <uvm/uvm_extern.h>
95
96 /* prototypes */
97 void isa_tsarm_init(u_int, u_int);
98 struct arm32_isa_chipset isa_chipset_tag;
99
100 static unsigned int ep93xxirq[3] = { 20, 33, 40 };
101 /* only have 3 irqs connected to real lines on TS-7xxx */
102 static unsigned int isairq[3] = { 5, 6, 7 };
103 static unsigned int isairq_nhandlers[3] = { 0, 0, 0 };
104
105 int
106 isa_intr_alloc(isa_chipset_tag_t ic, int mask, int type, int *irq)
107 {
108 int i, bestirq, count;
109
110 if (type == IST_NONE)
111 panic("intr_alloc: bogus type");
112
113 bestirq = -1;
114 count = -1;
115
116 /* some interrupts should never be dynamically allocated */
117 mask &= 0x00e0;
118
119 for (i = 0; i < sizeof(isairq); i++) {
120 if ((mask & (1<<isairq[i])) == 0)
121 continue;
122 if (isairq_nhandlers[i] < count || count == -1) {
123 bestirq = isairq[i];
124 count = isairq_nhandlers[i];
125 }
126 }
127
128 if (bestirq == -1)
129 return (1);
130
131 *irq = bestirq;
132
133 return (0);
134 }
135
136 const struct evcnt *
137 isa_intr_evcnt(isa_chipset_tag_t ic, int irq)
138 {
139 return NULL;
140 }
141
142 /*
143 * Set up an interrupt handler to start being called.
144 */
145 void *
146 isa_intr_establish(isa_chipset_tag_t ic, int irq, int type, int level, int (*ih_fun)(void *), void *ih_arg)
147 {
148 int epirq = -1, i;
149 /* Find real EP93XX irq number */
150 for(i = 0; i < sizeof(isairq); i++) {
151 if (irq == isairq[i]) epirq = ep93xxirq[i];
152 }
153
154 if (epirq == -1)
155 return NULL;
156 else
157 return (ep93xx_intr_establish(epirq, level, ih_fun, ih_arg));
158 }
159
160 /*
161 * Deregister an interrupt handler.
162 */
163 void
164 isa_intr_disestablish(isa_chipset_tag_t ic, void *arg)
165 {
166 ep93xx_intr_disestablish(arg);
167 }
168
169 void
170 isa_tsarm_init(u_int iobase16, u_int membase16)
171 {
172 isa_io_init(iobase16, membase16);
173 }
174
175
176 /*
177 * isa_intr_init()
178 *
179 * TODO: Set up ISA IRQ 5 on GPIO pin
180 */
181 void
182 isa_intr_init(void)
183 {
184 }
185
186 void
187 isa_attach_hook(struct device *parent, struct device *self, struct isabus_attach_args *iba)
188 {
189 /*
190 * Since we can only have one ISA bus, we just use a single
191 * statically allocated ISA chipset structure. Pass it up
192 * now.
193 */
194 iba->iba_ic = &isa_chipset_tag;
195 printf(": PC/104 expansion bus");
196 }
197
198 void
199 isa_detach_hook(device_t self)
200 {
201 }
202