This source file includes following definitions.
- t128_detect
- t128_biosparam
- NCR5380_pread
- NCR5380_pwrite
1 #define AUTOSENSE
2 #define PSEUDO_DMA
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 #include <asm/system.h>
110 #include <linux/signal.h>
111 #include <linux/sched.h>
112 #include <asm/io.h>
113 #include <linux/blk.h>
114 #include "scsi.h"
115 #include "hosts.h"
116 #include "t128.h"
117 #define AUTOPROBE_IRQ
118 #include "NCR5380.h"
119 #include "constants.h"
120 #include "sd.h"
121 #include<linux/stat.h>
122
123 struct proc_dir_entry proc_scsi_t128 = {
124 PROC_SCSI_T128, 4, "t128",
125 S_IFDIR | S_IRUGO | S_IXUGO, 2
126 };
127
128
129 static struct override {
130 unsigned char *address;
131 int irq;
132 } overrides
133 #ifdef T128_OVERRIDE
134 [] = T128_OVERRIDE;
135 #else
136 [4] = {{NULL,IRQ_AUTO}, {NULL,IRQ_AUTO}, {NULL,IRQ_AUTO},
137 {NULL,IRQ_AUTO}};
138 #endif
139
140 #define NO_OVERRIDES (sizeof(overrides) / sizeof(struct override))
141
142 static struct base {
143 unsigned char *address;
144 int noauto;
145 } bases[] = {{(unsigned char *) 0xcc000, 0}, {(unsigned char *) 0xc8000, 0},
146 {(unsigned char *) 0xdc000, 0}, {(unsigned char *) 0xd8000, 0}};
147
148 #define NO_BASES (sizeof (bases) / sizeof (struct base))
149
150 static const struct signature {
151 const char *string;
152 int offset;
153 } signatures[] = {
154 {"TSROM: SCSI BIOS, Version 1.12", 0x36},
155 };
156
157 #define NO_SIGNATURES (sizeof (signatures) / sizeof (struct signature))
158
159
160
161
162
163
164
165
166
167
168
169 void t128_setup(char *str, int *ints) {
170 static int commandline_current = 0;
171 int i;
172 if (ints[0] != 2)
173 printk("t128_setup : usage t128=address,irq\n");
174 else
175 if (commandline_current < NO_OVERRIDES) {
176 overrides[commandline_current].address = (unsigned char *) ints[1];
177 overrides[commandline_current].irq = ints[2];
178 for (i = 0; i < NO_BASES; ++i)
179 if (bases[i].address == (unsigned char *) ints[1]) {
180 bases[i].noauto = 1;
181 break;
182 }
183 ++commandline_current;
184 }
185 }
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200 int t128_detect(Scsi_Host_Template * tpnt) {
201 static int current_override = 0, current_base = 0;
202 struct Scsi_Host *instance;
203 unsigned char *base;
204 int sig, count;
205
206 tpnt->proc_dir = &proc_scsi_t128;
207
208 for (count = 0; current_override < NO_OVERRIDES; ++current_override) {
209 base = NULL;
210
211 if (overrides[current_override].address)
212 base = overrides[current_override].address;
213 else
214 for (; !base && (current_base < NO_BASES); ++current_base) {
215 #if (TDEBUG & TDEBUG_INIT)
216 printk("scsi : probing address %08x\n", (unsigned int) bases[current_base].address);
217 #endif
218 for (sig = 0; sig < NO_SIGNATURES; ++sig)
219 if (!bases[current_base].noauto && !memcmp
220 (bases[current_base].address + signatures[sig].offset,
221 signatures[sig].string, strlen(signatures[sig].string))) {
222 base = bases[current_base].address;
223 #if (TDEBUG & TDEBUG_INIT)
224 printk("scsi-t128 : detected board.\n");
225 #endif
226 break;
227 }
228 }
229
230 #if defined(TDEBUG) && (TDEBUG & TDEBUG_INIT)
231 printk("scsi-t128 : base = %08x\n", (unsigned int) base);
232 #endif
233
234 if (!base)
235 break;
236
237 instance = scsi_register (tpnt, sizeof(struct NCR5380_hostdata));
238 instance->base = base;
239
240 NCR5380_init(instance, 0);
241
242 if (overrides[current_override].irq != IRQ_AUTO)
243 instance->irq = overrides[current_override].irq;
244 else
245 instance->irq = NCR5380_probe_irq(instance, T128_IRQS);
246
247 if (instance->irq != IRQ_NONE)
248 if (request_irq(instance->irq, t128_intr, SA_INTERRUPT, "t128", NULL)) {
249 printk("scsi%d : IRQ%d not free, interrupts disabled\n",
250 instance->host_no, instance->irq);
251 instance->irq = IRQ_NONE;
252 }
253
254 if (instance->irq == IRQ_NONE) {
255 printk("scsi%d : interrupts not enabled. for better interactive performance,\n", instance->host_no);
256 printk("scsi%d : please jumper the board for a free IRQ.\n", instance->host_no);
257 }
258
259 #if defined(TDEBUG) && (TDEBUG & TDEBUG_INIT)
260 printk("scsi%d : irq = %d\n", instance->host_no, instance->irq);
261 #endif
262
263 printk("scsi%d : at 0x%08x", instance->host_no, (int)
264 instance->base);
265 if (instance->irq == IRQ_NONE)
266 printk (" interrupts disabled");
267 else
268 printk (" irq %d", instance->irq);
269 printk(" options CAN_QUEUE=%d CMD_PER_LUN=%d release=%d",
270 CAN_QUEUE, CMD_PER_LUN, T128_PUBLIC_RELEASE);
271 NCR5380_print_options(instance);
272 printk("\n");
273
274 ++current_override;
275 ++count;
276 }
277 return count;
278 }
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300 int t128_biosparam(Disk * disk, kdev_t dev, int * ip)
301 {
302 int size = disk->capacity;
303 ip[0] = 64;
304 ip[1] = 32;
305 ip[2] = size >> 11;
306 return 0;
307 }
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322 static inline int NCR5380_pread (struct Scsi_Host *instance, unsigned char *dst,
323 int len) {
324 register unsigned char *reg = (unsigned char *) (instance->base +
325 T_DATA_REG_OFFSET), *d = dst;
326 register i = len;
327
328
329 #if 0
330 for (; i; --i) {
331 while (!(instance->base[T_STATUS_REG_OFFSET]) & T_ST_RDY) barrier();
332 #else
333 while (!(instance->base[T_STATUS_REG_OFFSET]) & T_ST_RDY) barrier();
334 for (; i; --i) {
335 #endif
336 *d++ = *reg;
337 }
338
339 if (*(instance->base + T_STATUS_REG_OFFSET) & T_ST_TIM) {
340 unsigned char tmp;
341 volatile unsigned char *foo;
342 foo = instance->base + T_CONTROL_REG_OFFSET;
343 tmp = *foo;
344 *foo = tmp | T_CR_CT;
345 *foo = tmp;
346 printk("scsi%d : watchdog timer fired in NCR5380_pread()\n",
347 instance->host_no);
348 return -1;
349 } else
350 return 0;
351 }
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366 static inline int NCR5380_pwrite (struct Scsi_Host *instance, unsigned char *src,
367 int len) {
368 register unsigned char *reg = (unsigned char *) (instance->base +
369 T_DATA_REG_OFFSET), *s = src;
370 register i = len;
371
372 #if 0
373 for (; i; --i) {
374 while (!(instance->base[T_STATUS_REG_OFFSET]) & T_ST_RDY) barrier();
375 #else
376 while (!(instance->base[T_STATUS_REG_OFFSET]) & T_ST_RDY) barrier();
377 for (; i; --i) {
378 #endif
379 *reg = *s++;
380 }
381
382 if (*(instance->base + T_STATUS_REG_OFFSET) & T_ST_TIM) {
383 unsigned char tmp;
384 volatile unsigned char *foo;
385 foo = instance->base + T_CONTROL_REG_OFFSET;
386 tmp = *foo;
387 *foo = tmp | T_CR_CT;
388 *foo = tmp;
389 printk("scsi%d : watchdog timer fired in NCR5380_pwrite()\n",
390 instance->host_no);
391 return -1;
392 } else
393 return 0;
394 }
395
396 #include "NCR5380.c"
397
398 #ifdef MODULE
399
400 Scsi_Host_Template driver_template = TRANTOR_T128;
401
402 #include "scsi_module.c"
403 #endif