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
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
|
/*
* Product specific probe and attach routines for:
* Buslogic BT74x SCSI controllers
*
* Copyright (c) 1995 Justin T. Gibbs
* All rights reserved.
*
* 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 immediately at the beginning of the file, without modification,
* 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.
* 3. Absolutely no warranty of function or purpose is made by the author
* Justin T. Gibbs.
* 4. Modifications may be freely made to this file if the above conditions
* are met.
*
* $Id: bt74x.c,v 1.5 1996/02/26 01:01:41 gibbs Exp $
*/
#include "eisa.h"
#if NEISA > 0
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/devconf.h>
#include <sys/kernel.h>
#include <scsi/scsi_all.h>
#include <scsi/scsiconf.h>
#include <machine/clock.h>
#include <i386/eisa/eisaconf.h>
#include <i386/scsi/btreg.h>
#define EISA_DEVICE_ID_BUSLOGIC_74X_B 0x0ab34201
#define EISA_DEVICE_ID_BUSLOGIC_74X_C 0x0ab34202
#define EISA_DEVICE_ID_AMI_4801 0x05a94801
#define BT_IOSIZE 0x04 /* Move to central header */
#define BT_EISA_IOSIZE 0x100
#define BT_EISA_SLOT_OFFSET 0xc00
#define EISA_IOCONF 0x08C
#define PORTADDR 0x07
#define PORT_330 0x00
#define PORT_334 0x01
#define PORT_230 0x02
#define PORT_234 0x03
#define PORT_130 0x04
#define PORT_134 0x05
#define IRQ_CHANNEL 0xe0
#define INT_11 0x40
#define INT_10 0x20
#define INT_15 0xa0
#define INT_12 0x60
#define INT_14 0x80
#define INT_9 0x00
#define EISA_IRQ_TYPE 0x08D
#define LEVEL 0x40
/* Definitions for the AMI Series 48 controler */
#define AMI_EISA_IOSIZE 0x500 /* Two separate ranges?? */
#define AMI_EISA_SLOT_OFFSET 0x800
#define AMI_EISA_IOCONF 0x000
#define AMI_DMA_CHANNEL 0x03
#define AMI_IRQ_CHANNEL 0x1c
#define AMI_INT_15 0x14
#define AMI_INT_14 0x10
#define AMI_INT_12 0x0c
#define AMI_INT_11 0x00
#define AMI_INT_10 0x08
#define AMI_INT_9 0x04
#define AMI_BIOS_ADDR 0xe0
#define AMI_EISA_IOCONF1 0x001
#define AMI_PORTADDR 0x0e
#define AMI_PORT_334 0x08
#define AMI_PORT_330 0x00
#define AMI_PORT_234 0x0c
#define AMI_PORT_230 0x04
#define AMI_PORT_134 0x0a
#define AMI_PORT_130 0x02
#define AMI_IRQ_LEVEL 0x01
#define AMI_MISC2_OPTIONS 0x49E
#define AMI_ENABLE_ISA_DMA 0x08
static int bt_eisa_probe __P((void));
static int bt_eisa_attach __P((struct eisa_device *e_dev));
struct eisa_driver bt_eisa_driver = {
"bt",
bt_eisa_probe,
bt_eisa_attach,
/*shutdown*/NULL,
&bt_unit
};
DATA_SET (eisadriver_set, bt_eisa_driver);
static struct kern_devconf kdc_eisa_bt = {
0, 0, 0, /* filled in by dev_attach */
"bt", 0, { MDDT_EISA, 0, "bio" },
eisa_generic_externalize, 0, 0, EISA_EXTERNALLEN,
&kdc_eisa0, /* parent */
0, /* parentdata */
DC_UNCONFIGURED, /* always start out here */
NULL,
DC_CLS_MISC /* host adapters aren't special */
};
static char *bt_match __P((eisa_id_t type));
static char*
bt_match(type)
eisa_id_t type;
{
switch(type) {
case EISA_DEVICE_ID_BUSLOGIC_74X_B:
return ("Buslogic 74xB SCSI host adapter");
break;
case EISA_DEVICE_ID_BUSLOGIC_74X_C:
return ("Buslogic 74xC SCSI host adapter");
break;
case EISA_DEVICE_ID_AMI_4801:
return ("AMI Series 48 SCSI host adapter");
break;
default:
break;
}
return (NULL);
}
static int
bt_eisa_probe(void)
{
u_long iobase;
struct eisa_device *e_dev = NULL;
int count;
count = 0;
while ((e_dev = eisa_match_dev(e_dev, bt_match))) {
u_char ioconf;
u_long port;
int irq;
iobase = (e_dev->ioconf.slot * EISA_SLOT_SIZE);
if(e_dev->id == EISA_DEVICE_ID_AMI_4801) {
u_char ioconf1;
iobase += AMI_EISA_SLOT_OFFSET;
eisa_add_iospace(e_dev, iobase, AMI_EISA_IOSIZE,
RESVADDR_NONE);
ioconf = inb(iobase + AMI_EISA_IOCONF);
ioconf1 = inb(iobase + AMI_EISA_IOCONF1);
/* Determine "ISA" I/O port */
switch (ioconf1 & AMI_PORTADDR) {
case AMI_PORT_330:
port = 0x330;
break;
case AMI_PORT_334:
port = 0x334;
break;
case AMI_PORT_230:
port = 0x230;
break;
case AMI_PORT_234:
port = 0x234;
break;
case AMI_PORT_134:
port = 0x134;
break;
case AMI_PORT_130:
port = 0x130;
break;
default:
/* Disabled */
printf("bt: AMI EISA Adapter at "
"slot %d has a disabled I/O "
"port. Cannot attach.\n",
e_dev->ioconf.slot);
continue;
}
eisa_add_iospace(e_dev, port, BT_IOSIZE, RESVADDR_NONE);
/* Determine our IRQ */
switch (ioconf & AMI_IRQ_CHANNEL) {
case AMI_INT_11:
irq = 11;
break;
case AMI_INT_10:
irq = 10;
break;
case AMI_INT_15:
irq = 15;
break;
case AMI_INT_12:
irq = 12;
break;
case AMI_INT_14:
irq = 14;
break;
case AMI_INT_9:
irq = 9;
break;
default:
/* Disabled */
printf("bt: AMI EISA Adapter at "
"slot %d has its IRQ disabled. "
"Cannot attach.\n",
e_dev->ioconf.slot);
continue;
}
}
else {
iobase += BT_EISA_SLOT_OFFSET;
eisa_add_iospace(e_dev, iobase, BT_EISA_IOSIZE,
RESVADDR_NONE);
ioconf = inb(iobase + EISA_IOCONF);
/* Determine "ISA" I/O port */
switch (ioconf & PORTADDR) {
case PORT_330:
port = 0x330;
break;
case PORT_334:
port = 0x334;
break;
case PORT_230:
port = 0x230;
break;
case PORT_234:
port = 0x234;
break;
case PORT_130:
port = 0x130;
break;
case PORT_134:
port = 0x134;
break;
default:
/* Disabled */
printf("bt: Buslogic EISA Adapter at "
"slot %d has a disabled I/O "
"port. Cannot attach.\n",
e_dev->ioconf.slot);
continue;
}
eisa_add_iospace(e_dev, port, BT_IOSIZE, RESVADDR_NONE);
/* Determine our IRQ */
switch (ioconf & IRQ_CHANNEL) {
case INT_11:
irq = 11;
break;
case INT_10:
irq = 10;
break;
case INT_15:
irq = 15;
break;
case INT_12:
irq = 12;
break;
case INT_14:
irq = 14;
break;
case INT_9:
irq = 9;
break;
default:
/* Disabled */
printf("bt: Buslogic EISA Adapter at "
"slot %d has its IRQ disabled. "
"Cannot attach.\n",
e_dev->ioconf.slot);
continue;
}
}
eisa_add_intr(e_dev, irq);
eisa_registerdev(e_dev, &bt_eisa_driver, &kdc_eisa_bt);
count++;
}
return count;
}
static int
bt_eisa_attach(e_dev)
struct eisa_device *e_dev;
{
struct bt_data *bt;
int unit = e_dev->unit;
int irq = ffs(e_dev->ioconf.irq) - 1;
resvaddr_t *ioport;
resvaddr_t *eisa_ioport;
u_char level_intr;
/*
* The addresses are sorted in increasing order
* so we know the port to pass to the core bt
* driver comes first.
*/
ioport = e_dev->ioconf.ioaddrs.lh_first;
if(!ioport)
return -1;
eisa_ioport = ioport->links.le_next;
if(!eisa_ioport)
return -1;
if(e_dev->id == EISA_DEVICE_ID_AMI_4801)
level_intr = inb(eisa_ioport->addr + AMI_EISA_IOCONF1)
& AMI_IRQ_LEVEL;
else
level_intr = inb(eisa_ioport->addr + EISA_IRQ_TYPE)
& LEVEL;
eisa_reg_start(e_dev);
if(eisa_reg_iospace(e_dev, ioport))
return -1;
if(eisa_reg_iospace(e_dev, eisa_ioport))
return -1;
if(!(bt = bt_alloc(unit, ioport->addr)))
return -1;
if(eisa_reg_intr(e_dev, irq, bt_intr, (void *)bt, &bio_imask,
/*shared ==*/level_intr)) {
bt_free(bt);
return -1;
}
eisa_reg_end(e_dev);
/*
* Now that we know we own the resources we need, do the full
* card initialization.
*/
if(bt_init(bt)){
bt_free(bt);
/*
* The board's IRQ line will not be left enabled
* if we can't intialize correctly, so its safe
* to release the irq.
*/
eisa_release_intr(e_dev, irq, bt_intr);
return -1;
}
e_dev->kdc->kdc_state = DC_BUSY; /* host adapters always busy */
/* Attach sub-devices - always succeeds */
bt_attach(bt);
if(eisa_enable_intr(e_dev, irq)) {
bt_free(bt);
eisa_release_intr(e_dev, irq, bt_intr);
return -1;
}
return 0;
}
#endif /* NEISA > 0 */
|