pci_alphabook1.c revision 1.2 1 /* $NetBSD: pci_alphabook1.c,v 1.2 1998/11/19 02:35:39 ross Exp $ */
2
3 /*-
4 * Copyright (c) 1998 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
9 * NASA Ames Research Center.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * 3. All advertising materials mentioning features or use of this software
20 * must display the following acknowledgement:
21 * This product includes software developed by the NetBSD
22 * Foundation, Inc. and its contributors.
23 * 4. Neither the name of The NetBSD Foundation nor the names of its
24 * contributors may be used to endorse or promote products derived
25 * from this software without specific prior written permission.
26 *
27 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
28 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
29 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
30 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
31 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37 * POSSIBILITY OF SUCH DAMAGE.
38 */
39
40 /*
41 * Copyright (c) 1995, 1996 Carnegie-Mellon University.
42 * All rights reserved.
43 *
44 * Authors: Jeffrey Hsu and Chris G. Demetriou
45 *
46 * Permission to use, copy, modify and distribute this software and
47 * its documentation is hereby granted, provided that both the copyright
48 * notice and this permission notice appear in all copies of the
49 * software, derivative works or modified versions, and any portions
50 * thereof, and that both notices appear in supporting documentation.
51 *
52 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
53 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
54 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
55 *
56 * Carnegie Mellon requests users of this software to return to
57 *
58 * Software Distribution Coordinator or Software.Distribution (at) CS.CMU.EDU
59 * School of Computer Science
60 * Carnegie Mellon University
61 * Pittsburgh PA 15213-3890
62 *
63 * any improvements or extensions that they make and grant Carnegie the
64 * rights to redistribute these changes.
65 */
66
67 #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
68
69 __KERNEL_RCSID(0, "$NetBSD: pci_alphabook1.c,v 1.2 1998/11/19 02:35:39 ross Exp $");
70
71 #include <sys/types.h>
72 #include <sys/param.h>
73 #include <sys/time.h>
74 #include <sys/systm.h>
75 #include <sys/errno.h>
76 #include <sys/device.h>
77 #include <vm/vm.h>
78
79 #include <machine/autoconf.h>
80 #include <machine/bus.h>
81 #include <machine/intr.h>
82 #include <machine/intrcnt.h>
83
84 #include <dev/isa/isavar.h>
85 #include <dev/pci/pcireg.h>
86 #include <dev/pci/pcivar.h>
87
88 #include <alpha/pci/lcavar.h>
89
90 #include <alpha/pci/pci_alphabook1.h>
91 #include <alpha/pci/siovar.h>
92 #include <alpha/pci/sioreg.h>
93
94 #include "sio.h"
95
96 int dec_alphabook1_intr_map __P((void *, pcitag_t, int, int,
97 pci_intr_handle_t *));
98 const char *dec_alphabook1_intr_string __P((void *, pci_intr_handle_t));
99 void *dec_alphabook1_intr_establish __P((void *, pci_intr_handle_t,
100 int, int (*func)(void *), void *));
101 void dec_alphabook1_intr_disestablish __P((void *, void *));
102
103 #define LCA_SIO_DEVICE 7 /* XXX */
104
105 void
106 pci_alphabook1_pickintr(lcp)
107 struct lca_config *lcp;
108 {
109 bus_space_tag_t iot = &lcp->lc_iot;
110 pci_chipset_tag_t pc = &lcp->lc_pc;
111 pcireg_t sioclass;
112 int sioII;
113
114 /* XXX MAGIC NUMBER */
115 sioclass = pci_conf_read(pc, pci_make_tag(pc, 0, LCA_SIO_DEVICE, 0),
116 PCI_CLASS_REG);
117 sioII = (sioclass & 0xff) >= 3;
118
119 if (!sioII)
120 printf("WARNING: SIO NOT SIO II... NO BETS...\n");
121
122 pc->pc_intr_v = lcp;
123 pc->pc_intr_map = dec_alphabook1_intr_map;
124 pc->pc_intr_string = dec_alphabook1_intr_string;
125 pc->pc_intr_establish = dec_alphabook1_intr_establish;
126 pc->pc_intr_disestablish = dec_alphabook1_intr_disestablish;
127
128 /* Not supported on AlphaBook. */
129 pc->pc_pciide_compat_intr_establish = NULL;
130
131 #if NSIO
132 sio_intr_setup(pc, iot);
133 set_iointr(&sio_iointr);
134 #else
135 panic("pci_alphabook1_pickintr: no I/O interrupt handler (no sio)");
136 #endif
137 }
138
139 int
140 dec_alphabook1_intr_map(lcv, bustag, buspin, line, ihp)
141 void *lcv;
142 pcitag_t bustag;
143 int buspin, line;
144 pci_intr_handle_t *ihp;
145 {
146 struct lca_config *lcp = lcv;
147 pci_chipset_tag_t pc = &lcp->lc_pc;
148 int device, irq;
149
150 if (buspin == 0) {
151 /* No IRQ used. */
152 return 1;
153 }
154 if (buspin > 4) {
155 printf("dec_alphabook1_intr_map: bad interrupt pin %d\n",
156 buspin);
157 return 1;
158 }
159
160 alpha_pci_decompose_tag(pc, bustag, NULL, &device, NULL);
161
162 /*
163 * There is only one interrupting PCI device on the AlphaBook: an
164 * NCR SCSI at device 6. Devices 7 and 8 are the SIO and a
165 * Cirrus PD6729 PCMCIA controller. There are no option slots
166 * available.
167 *
168 * NOTE! Apparently, there was a later AlphaBook which uses
169 * a different interrupt scheme, and has a built-in Tulip Ethernet
170 * interface! We do not handle that here!
171 */
172
173 switch (device) {
174 case 6: /* NCR SCSI */
175 irq = 14;
176 break;
177
178 default:
179 printf("dec_alphabook1_intr_map: weird device number %d\n",
180 device);
181 return 1;
182 }
183
184 *ihp = irq;
185 return (0);
186 }
187
188 const char *
189 dec_alphabook1_intr_string(lcv, ih)
190 void *lcv;
191 pci_intr_handle_t ih;
192 {
193 #if 0
194 struct lca_config *lcp = lcv;
195 #endif
196
197 return sio_intr_string(NULL /*XXX*/, ih);
198 }
199
200 void *
201 dec_alphabook1_intr_establish(lcv, ih, level, func, arg)
202 void *lcv, *arg;
203 pci_intr_handle_t ih;
204 int level;
205 int (*func) __P((void *));
206 {
207 #if 0
208 struct lca_config *lcp = lcv;
209 #endif
210
211 return sio_intr_establish(NULL /*XXX*/, ih, IST_LEVEL, level, func,
212 arg);
213 }
214
215 void
216 dec_alphabook1_intr_disestablish(lcv, cookie)
217 void *lcv, *cookie;
218 {
219 #if 0
220 struct lca_config *lcp = lcv;
221 #endif
222
223 sio_intr_disestablish(NULL /*XXX*/, cookie);
224 }
225