pci_eb164.c revision 1.2 1 /* $NetBSD: pci_eb164.c,v 1.2 1996/11/13 21:13:30 cgd Exp $ */
2
3 /*
4 * Copyright (c) 1995, 1996 Carnegie-Mellon University.
5 * All rights reserved.
6 *
7 * Author: Chris G. Demetriou
8 *
9 * Permission to use, copy, modify and distribute this software and
10 * its documentation is hereby granted, provided that both the copyright
11 * notice and this permission notice appear in all copies of the
12 * software, derivative works or modified versions, and any portions
13 * thereof, and that both notices appear in supporting documentation.
14 *
15 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
16 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
17 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
18 *
19 * Carnegie Mellon requests users of this software to return to
20 *
21 * Software Distribution Coordinator or Software.Distribution (at) CS.CMU.EDU
22 * School of Computer Science
23 * Carnegie Mellon University
24 * Pittsburgh PA 15213-3890
25 *
26 * any improvements or extensions that they make and grant Carnegie the
27 * rights to redistribute these changes.
28 */
29
30 #include <sys/types.h>
31 #include <sys/param.h>
32 #include <sys/time.h>
33 #include <sys/systm.h>
34 #include <sys/errno.h>
35 #include <sys/malloc.h>
36 #include <sys/device.h>
37 #include <sys/syslog.h>
38
39 #include <vm/vm.h>
40
41 #include <machine/autoconf.h>
42
43 #include <dev/pci/pcireg.h>
44 #include <dev/pci/pcivar.h>
45
46 #include <alpha/pci/ciareg.h>
47 #include <alpha/pci/ciavar.h>
48
49 #include <alpha/pci/pci_eb164.h>
50
51 #ifndef EVCNT_COUNTERS
52 #include <machine/intrcnt.h>
53 #endif
54
55 #include "sio.h"
56 #if NSIO
57 #include <alpha/pci/siovar.h>
58 #endif
59
60 int dec_eb164_intr_map __P((void *, pcitag_t, int, int,
61 pci_intr_handle_t *));
62 const char *dec_eb164_intr_string __P((void *, pci_intr_handle_t));
63 void *dec_eb164_intr_establish __P((void *, pci_intr_handle_t,
64 int, int (*func)(void *), void *));
65 void dec_eb164_intr_disestablish __P((void *, void *));
66
67 void eb164_pci_strayintr __P((int irq));
68 void eb164_iointr __P((void *framep, unsigned long vec));
69
70 void
71 pci_eb164_pickintr(ccp)
72 struct cia_config *ccp;
73 {
74 bus_space_tag_t iot = ccp->cc_iot;
75 pci_chipset_tag_t pc = &ccp->cc_pc;
76
77 pc->pc_intr_v = ccp;
78 pc->pc_intr_map = dec_eb164_intr_map;
79 pc->pc_intr_string = dec_eb164_intr_string;
80 pc->pc_intr_establish = dec_eb164_intr_establish;
81 pc->pc_intr_disestablish = dec_eb164_intr_disestablish;
82
83 #if NSIO
84 sio_intr_setup(iot);
85 #endif
86
87 set_iointr(eb164_iointr);
88
89 #if 0 /* XXX */
90 #if NSIO
91 eb164_enable_intr(KN20AA_PCEB_IRQ);
92 #if 0 /* XXX init PCEB interrupt handler? */
93 eb164_attach_intr(&eb164_pci_intrs[KN20AA_PCEB_IRQ], ???, ???, ???);
94 #endif
95 #endif
96 #endif /* 0 XXX */
97 }
98
99 int
100 dec_eb164_intr_map(ccv, bustag, buspin, line, ihp)
101 void *ccv;
102 pcitag_t bustag;
103 int buspin, line;
104 pci_intr_handle_t *ihp;
105 {
106
107 printf("dec_eb164_intr_map(0x%lx, %d, %d)\n", bustag, buspin, line);
108 return 0;
109
110 #if 0
111 struct cia_config *ccp = ccv;
112 pci_chipset_tag_t pc = &ccp->cc_pc;
113 int device;
114 int eb164_irq;
115 void *ih;
116
117 if (buspin == 0) {
118 /* No IRQ used. */
119 return 1;
120 }
121 if (buspin > 4) {
122 printf("pci_map_int: bad interrupt pin %d\n", buspin);
123 return 1;
124 }
125
126 /*
127 * Slot->interrupt translation. Appears to work, though it
128 * may not hold up forever.
129 *
130 * The DEC engineers who did this hardware obviously engaged
131 * in random drug testing.
132 */
133 pci_decompose_tag(pc, bustag, NULL, &device, NULL);
134 switch (device) {
135 case 11:
136 case 12:
137 eb164_irq = ((device - 11) + 0) * 4;
138 break;
139
140 case 7:
141 eb164_irq = 8;
142 break;
143
144 case 9:
145 eb164_irq = 12;
146 break;
147
148 case 6: /* 21040 on AlphaStation 500 */
149 eb164_irq = 13;
150 break;
151
152 case 8:
153 eb164_irq = 16;
154 break;
155
156 default:
157 #ifdef KN20AA_BOGUS_IRQ_FROB
158 *ihp = 0xdeadbeef;
159 printf("\n\n BOGUS INTERRUPT MAPPING: dev %d, pin %d\n",
160 device, buspin);
161 return (0);
162 #endif
163 panic("pci_eb164_map_int: invalid device number %d\n",
164 device);
165 }
166
167 eb164_irq += buspin - 1;
168 if (eb164_irq > KN20AA_MAX_IRQ)
169 panic("pci_eb164_map_int: eb164_irq too large (%d)\n",
170 eb164_irq);
171
172 *ihp = eb164_irq;
173 return (0);
174 #endif
175 }
176
177 const char *
178 dec_eb164_intr_string(ccv, ih)
179 void *ccv;
180 pci_intr_handle_t ih;
181 {
182 #if 0
183 struct cia_config *ccp = ccv;
184 #endif
185 static char irqstr[15]; /* 11 + 2 + NULL + sanity */
186
187 sprintf(irqstr, "BOGUS");
188 return (irqstr);
189
190 #if 0 /* XXX */
191 #ifdef KN20AA_BOGUS_IRQ_FROB
192 if (ih == 0xdeadbeef) {
193 sprintf(irqstr, "BOGUS");
194 return (irqstr);
195 }
196 #endif
197 if (ih > KN20AA_MAX_IRQ)
198 panic("dec_eb164_a50_intr_string: bogus eb164 IRQ 0x%x\n",
199 ih);
200
201 sprintf(irqstr, "eb164 irq %d", ih);
202 return (irqstr);
203 #endif /* 0 XXX */
204 }
205
206 void *
207 dec_eb164_intr_establish(ccv, ih, level, func, arg)
208 void *ccv, *arg;
209 pci_intr_handle_t ih;
210 int level;
211 int (*func) __P((void *));
212 {
213
214 printf("dec_eb164_intr_establish(0x%lx, %d, %p, %p)\n", ih, level, func, arg);
215 return ((void *)0xbabefacedeadbeef);
216
217 #if 0 /* XXX */
218 struct cia_config *ccp = ccv;
219 void *cookie;
220
221 #ifdef KN20AA_BOGUS_IRQ_FROB
222 if (ih == 0xdeadbeef) {
223 int i;
224 char chars[10];
225
226 printf("dec_eb164_intr_establish: BOGUS IRQ\n");
227 do {
228 printf("IRQ to enable? ");
229 getstr(chars, 10);
230 i = atoi(chars);
231 } while (i < 0 || i > 32);
232 printf("ENABLING IRQ %d\n", i);
233 eb164_enable_intr(i);
234 return ((void *)0xbabefacedeadbeef);
235 }
236 #endif
237 if (ih > KN20AA_MAX_IRQ)
238 panic("dec_eb164_intr_establish: bogus eb164 IRQ 0x%x\n",
239 ih);
240
241 cookie = eb164_attach_intr(&eb164_pci_intrs[ih], level, func, arg);
242 eb164_enable_intr(ih);
243 return (cookie);
244 #endif /* XXX */
245 }
246
247 void
248 dec_eb164_intr_disestablish(ccv, cookie)
249 void *ccv, *cookie;
250 {
251
252 panic("dec_eb164_intr_disestablish not implemented"); /* XXX */
253 }
254
255 void
256 eb164_iointr(framep, vec)
257 void *framep;
258 unsigned long vec;
259 {
260
261 panic("eb164_iointr: weird vec 0x%x\n", vec);
262 }
263