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