1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
|
/* $NetBSD: sio.c,v 1.57 2021/08/07 16:18:41 thorpej Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Jason R. Thorpe.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/*
* Copyright (c) 1995, 1996 Carnegie-Mellon University.
* All rights reserved.
*
* Author: Chris G. Demetriou
*
* Permission to use, copy, modify and distribute this software and
* its documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
*
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
* FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*
* Carnegie Mellon requests users of this software to return to
*
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
*
* any improvements or extensions that they make and grant Carnegie the
* rights to redistribute these changes.
*/
#include "opt_dec_2100_a500.h"
#include "opt_dec_2100a_a500.h"
#include "eisa.h"
#include "sio.h"
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
__KERNEL_RCSID(0, "$NetBSD: sio.c,v 1.57 2021/08/07 16:18:41 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/device.h>
#include <sys/kmem.h>
#include <machine/intr.h>
#include <sys/bus.h>
#include <machine/rpb.h>
#include <dev/isa/isavar.h>
#include <dev/eisa/eisavar.h>
#include <dev/pci/pcireg.h>
#include <dev/pci/pcivar.h>
#include <dev/pci/pcidevs.h>
#include <alpha/pci/siovar.h>
#if defined(DEC_2100_A500) || defined(DEC_2100A_A500)
#include <alpha/pci/pci_2100_a500.h>
#include <alpha/sableio/sableiovar.h>
#endif
struct sio_softc {
device_t sc_dev;
pci_chipset_tag_t sc_pc;
bus_space_tag_t sc_iot, sc_memt;
bus_dma_tag_t sc_parent_dmat;
#if NPCEB > 0
int sc_haseisa;
#endif
int sc_is82c693;
/* ISA chipset must persist; it's used after autoconfig. */
isa_chipset_tag_t sc_ic;
};
static int siomatch(device_t, cfdata_t, void *);
static void sioattach(device_t, device_t, void *);
CFATTACH_DECL_NEW(sio, sizeof(struct sio_softc),
siomatch, sioattach, NULL, NULL);
#if NPCEB > 0
static int pcebmatch(device_t, cfdata_t, void *);
CFATTACH_DECL_NEW(pceb, sizeof(struct sio_softc),
pcebmatch, sioattach, NULL, NULL);
#endif
union sio_attach_args {
struct isabus_attach_args sa_iba;
struct eisabus_attach_args sa_eba;
};
static void sio_isa_attach_hook(device_t, device_t,
struct isabus_attach_args *);
static void sio_isa_detach_hook(isa_chipset_tag_t, device_t);
#if NPCEB > 0
static void sio_eisa_attach_hook(device_t, device_t,
struct eisabus_attach_args *);
static int sio_eisa_maxslots(void *);
static int sio_eisa_intr_map(void *, u_int, eisa_intr_handle_t *);
#endif
static void sio_bridge_callback(device_t);
static int
siomatch(device_t parent, cfdata_t match, void *aux)
{
struct pci_attach_args *pa = aux;
/*
* The Cypress 82C693 is more-or-less an SIO, but with
* indirect register access. (XXX for everything, or
* just the ELCR?)
*/
if (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_CONTAQ &&
PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_CONTAQ_82C693 &&
pa->pa_function == 0)
return (1);
if (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_INTEL &&
PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_INTEL_SIO)
return (1);
if (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_ALI &&
PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_ALI_M1533)
return (1);
return (0);
}
#if NPCEB > 0
static int
pcebmatch(device_t parent, cfdata_t match, void *aux)
{
struct pci_attach_args *pa = aux;
if (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_INTEL &&
PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_INTEL_PCEB)
return (1);
return (0);
}
#endif
static void
sioattach(device_t parent, device_t self, void *aux)
{
struct sio_softc *sc = device_private(self);
struct pci_attach_args *pa = aux;
char devinfo[256];
pci_devinfo(pa->pa_id, pa->pa_class, 0, devinfo, sizeof(devinfo));
aprint_normal(": %s (rev. 0x%02x)\n", devinfo,
PCI_REVISION(pa->pa_class));
sc->sc_dev = self;
sc->sc_pc = pa->pa_pc;
sc->sc_iot = pa->pa_iot;
sc->sc_memt = pa->pa_memt;
sc->sc_parent_dmat = pa->pa_dmat;
#if NPCEB > 0
sc->sc_haseisa = (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_INTEL &&
PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_INTEL_PCEB);
#endif
sc->sc_is82c693 = (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_CONTAQ &&
PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_CONTAQ_82C693);
config_defer(self, sio_bridge_callback);
}
static void
sio_bridge_callback(device_t self)
{
struct sio_softc *sc = device_private(self);
union sio_attach_args sa;
#if NPCEB > 0
struct alpha_eisa_chipset ec;
if (sc->sc_haseisa) {
ec.ec_v = NULL;
ec.ec_attach_hook = sio_eisa_attach_hook;
ec.ec_maxslots = sio_eisa_maxslots;
/*
* Deal with platforms that hook EISA interrupts
* up differently.
*/
switch (cputype) {
#if defined(DEC_2100_A500) || defined(DEC_2100A_A500)
case ST_DEC_2100_A500:
case ST_DEC_2100A_A500:
pci_2100_a500_eisa_pickintr(sc->sc_pc, &ec);
break;
#endif
default:
ec.ec_intr_map = sio_eisa_intr_map;
ec.ec_intr_string = sio_intr_string;
ec.ec_intr_evcnt = sio_intr_evcnt;
ec.ec_intr_establish = sio_isa_intr_establish;
ec.ec_intr_disestablish = sio_intr_disestablish;
}
sa.sa_eba.eba_iot = sc->sc_iot;
sa.sa_eba.eba_memt = sc->sc_memt;
sa.sa_eba.eba_dmat =
alphabus_dma_get_tag(sc->sc_parent_dmat, ALPHA_BUS_EISA);
sa.sa_eba.eba_ec = &ec;
config_found(sc->sc_dev, &sa.sa_eba, eisabusprint,
CFARGS(.iattr = "eisabus"));
}
#endif /* NPCEB */
/*
* Deal with platforms which have Odd ISA DMA needs.
*/
switch (cputype) {
#if defined(DEC_2100_A500) || defined(DEC_2100A_A500)
case ST_DEC_2100_A500:
case ST_DEC_2100A_A500:
sc->sc_ic = sableio_pickisa();
break;
#endif
default:
sc->sc_ic = kmem_zalloc(sizeof(*sc->sc_ic), KM_SLEEP);
}
sc->sc_ic->ic_v = NULL;
sc->sc_ic->ic_attach_hook = sio_isa_attach_hook;
sc->sc_ic->ic_detach_hook = sio_isa_detach_hook;
/*
* Deal with platforms that hook up ISA interrupts differently.
*/
switch (cputype) {
#if defined(DEC_2100_A500) || defined(DEC_2100A_A500)
case ST_DEC_2100_A500:
case ST_DEC_2100A_A500:
pci_2100_a500_isa_pickintr(sc->sc_pc, sc->sc_ic);
break;
#endif
default:
sc->sc_ic->ic_intr_evcnt = sio_intr_evcnt;
sc->sc_ic->ic_intr_establish = sio_isa_intr_establish;
sc->sc_ic->ic_intr_disestablish = sio_intr_disestablish;
sc->sc_ic->ic_intr_alloc = sio_intr_alloc;
}
sa.sa_iba.iba_iot = sc->sc_iot;
sa.sa_iba.iba_memt = sc->sc_memt;
sa.sa_iba.iba_dmat =
alphabus_dma_get_tag(sc->sc_parent_dmat, ALPHA_BUS_ISA);
sa.sa_iba.iba_ic = sc->sc_ic;
config_found(sc->sc_dev, &sa.sa_iba, isabusprint,
CFARGS(.iattr = "isabus"));
}
static void
sio_isa_attach_hook(device_t parent, device_t self, struct isabus_attach_args *iba)
{
/* Nothing to do. */
}
static void
sio_isa_detach_hook(isa_chipset_tag_t ic, device_t self)
{
/* Nothing to do. */
}
#if NPCEB > 0
static void
sio_eisa_attach_hook(device_t parent, device_t self, struct eisabus_attach_args *eba)
{
#if NEISA > 0
eisa_init(eba->eba_ec);
#endif
}
static int
sio_eisa_maxslots(void *v)
{
return 16; /* as good a number as any. only 8, maybe? */
}
static int
sio_eisa_intr_map(void *v, u_int irq, eisa_intr_handle_t *ihp)
{
#define ICU_LEN 16 /* number of ISA IRQs (XXX) */
if (irq >= ICU_LEN) {
printf("sio_eisa_intr_map: bad IRQ %d\n", irq);
*ihp = -1;
return 1;
}
if (irq == 2) {
printf("sio_eisa_intr_map: changed IRQ 2 to IRQ 9\n");
irq = 9;
}
*ihp = irq;
return 0;
}
#endif /* NPCEB */
|