This source file includes following definitions.
- enable_board
- init_board
- pas16_hw_detect
- pas16_setup
- pas16_detect
- pas16_biosparam
- NCR5380_pread
- NCR5380_pwrite
- pas16_info
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 #include <asm/system.h>
84 #include <linux/signal.h>
85 #include <linux/sched.h>
86 #include <asm/io.h>
87 #include "../block/blk.h"
88 #include "scsi.h"
89 #include "hosts.h"
90 #include "pas16.h"
91 #define AUTOPROBE_IRQ
92 #include "NCR5380.h"
93 #include "constants.h"
94
95
96
97 int scsi_irq_translate[] =
98 { 0, 0, 1, 2, 3, 4, 5, 6, 0, 0, 7, 8, 9, 0, 10, 11 };
99
100
101
102
103
104
105 int default_irqs[] = { PAS16_DEFAULT_BOARD_1_IRQ,
106 PAS16_DEFAULT_BOARD_2_IRQ,
107 PAS16_DEFAULT_BOARD_3_IRQ,
108 PAS16_DEFAULT_BOARD_4_IRQ
109 };
110
111 static struct override {
112 unsigned short io_port;
113 int irq;
114 } overrides
115 #ifdef PAS16_OVERRIDE
116 [] = PAS16_OVERRIDE;
117 #else
118 [4] = {{0,IRQ_AUTO}, {0,IRQ_AUTO}, {0,IRQ_AUTO},
119 {0,IRQ_AUTO}};
120 #endif
121
122 #define NO_OVERRIDES (sizeof(overrides) / sizeof(struct override))
123
124 static struct base {
125 unsigned short io_port;
126 int noauto;
127 } bases[] = { {PAS16_DEFAULT_BASE_1, 0},
128 {PAS16_DEFAULT_BASE_2, 0},
129 {PAS16_DEFAULT_BASE_3, 0},
130 {PAS16_DEFAULT_BASE_4, 0}
131 };
132
133 #define NO_BASES (sizeof (bases) / sizeof (struct base))
134
135 unsigned short pas16_offset[ 8 ] =
136 {
137 0x1c00,
138 0x1c01,
139 0x1c02,
140 0x1c03,
141 0x3c00,
142 0x3c01,
143 0x3c02,
144
145
146 0x3c03,
147
148
149 };
150
151
152
153
154
155
156
157
158
159
160
161
162 void enable_board( int board_num, unsigned short port )
163 {
164 outb( 0xbc + board_num, MASTER_ADDRESS_PTR );
165 outb( port >> 2, MASTER_ADDRESS_PTR );
166 }
167
168
169
170
171
172
173
174
175
176
177
178
179
180 void init_board( unsigned short io_port, int irq )
181 {
182 unsigned int tmp;
183
184
185
186 outb( 0x30, io_port + P_TIMEOUT_COUNTER_REG );
187 outb( 0x01, io_port + P_TIMEOUT_STATUS_REG_OFFSET );
188 outb( 0x01, io_port + WAIT_STATE );
189
190 NCR5380_read( RESET_PARITY_INTERRUPT_REG );
191
192
193
194
195 tmp = inb( io_port + IO_CONFIG_3 );
196 tmp = ( tmp & 0x0f ) | ( scsi_irq_translate[irq] << 4 );
197 outb( tmp, io_port + IO_CONFIG_3 );
198
199
200 outb( 0x6d, io_port + SYS_CONFIG_4 );
201 }
202
203
204
205
206
207
208
209
210
211
212
213
214 int pas16_hw_detect( unsigned short board_num )
215 {
216 unsigned char board_rev, tmp;
217 unsigned short port = bases[ board_num ].io_port;
218
219
220
221
222
223
224
225
226 enable_board( board_num, port );
227
228
229 board_rev = inb( port + PCB_CONFIG );
230
231 if( board_rev == 0xff )
232 return 0;
233
234 tmp = board_rev ^ 0xe0;
235
236 outb( tmp, port + PCB_CONFIG );
237 tmp = inb( port + PCB_CONFIG );
238 outb( board_rev, port + PCB_CONFIG );
239
240 if( board_rev != tmp )
241 return 0;
242
243 if( ( inb( port + OPERATION_MODE_1 ) & 0x03 ) != 0x03 )
244 return 0;
245
246 return 1;
247 }
248
249
250
251
252
253
254
255
256
257
258
259
260 void pas16_setup(char *str, int *ints) {
261 static int commandline_current = 0;
262 int i;
263 if (ints[0] != 2)
264 printk("pas16_setup : usage pas16=io_port,irq\n");
265 else
266 if (commandline_current < NO_OVERRIDES) {
267 overrides[commandline_current].io_port = (unsigned short) ints[1];
268 overrides[commandline_current].irq = ints[2];
269 for (i = 0; i < NO_BASES; ++i)
270 if (bases[i].io_port == (unsigned short) ints[1]) {
271 bases[i].noauto = 1;
272 break;
273 }
274 ++commandline_current;
275 }
276 }
277
278 static struct sigaction pas16_sigaction = { pas16_intr, 0, SA_INTERRUPT , NULL };
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293 int pas16_detect(int hostno) {
294 static int current_override = 0;
295 static unsigned short current_base = 0;
296 struct Scsi_Host *instance;
297 unsigned short io_port;
298 int count;
299
300 for (count = 0; current_override < NO_OVERRIDES; ++current_override) {
301 io_port = 0;
302
303 if (overrides[current_override].io_port)
304 {
305 io_port = overrides[current_override].io_port;
306 enable_board( current_override, io_port );
307 init_board( io_port, overrides[current_override].irq );
308 }
309 else
310 for (; !io_port && (current_base < NO_BASES); ++current_base) {
311 #if (PDEBUG & PDEBUG_INIT)
312 printk("scsi%d : probing io_port %04x\n", hostno, (unsigned int) bases[current_base].io_port);
313 #endif
314 if ( !bases[current_base].noauto &&
315 pas16_hw_detect( current_base ) ){
316 io_port = bases[current_base].io_port;
317 init_board( io_port, default_irqs[ current_base ] );
318 #if (PDEBUG & PDEBUG_INIT)
319 printk("scsi%d : detected board.\n", hostno);
320 #endif
321 }
322 }
323
324
325 #if defined(PDEBUG) && (PDEBUG & PDEBUG_INIT)
326 printk("scsi%d : io_port = %04x\n", hostno, (unsigned int) io_port);
327 #endif
328
329 if (!io_port)
330 break;
331
332 instance = scsi_register (hostno, sizeof(struct NCR5380_hostdata));
333 instance->io_port = io_port;
334
335 NCR5380_init(instance);
336
337 if (overrides[current_override].irq != IRQ_AUTO)
338 instance->irq = overrides[current_override].irq;
339 else
340 instance->irq = NCR5380_probe_irq(instance, PAS16_IRQS);
341
342 if (instance->irq != IRQ_NONE)
343 if (irqaction (instance->irq, &pas16_sigaction)) {
344 printk("scsi%d : IRQ%d not free, interrupts disabled\n",
345 hostno, instance->irq);
346 instance->irq = IRQ_NONE;
347 }
348
349 if (instance->irq == IRQ_NONE) {
350 printk("scsi%d : interrupts not enabled. for better interactive performance,\n", hostno);
351 printk("scsi%d : please jumper the board for a free IRQ.\n", hostno);
352 }
353
354 #if defined(PDEBUG) && (PDEBUG & PDEBUG_INIT)
355 printk("scsi%d : irq = %d\n", hostno, instance->irq);
356 #endif
357
358 printk("scsi%d : at 0x%04x", instance->host_no, (int)
359 instance->io_port);
360 if (instance->irq == IRQ_NONE)
361 printk (" interrupts disabled");
362 else
363 printk (" irq %d", instance->irq);
364 printk(" options CAN_QUEUE=%d CMD_PER_LUN=%d release=%d",
365 CAN_QUEUE, CMD_PER_LUN, PAS16_PUBLIC_RELEASE);
366 NCR5380_print_options(instance);
367 printk("\n");
368
369 ++current_override;
370 ++count;
371 ++hostno;
372 }
373 return count;
374 }
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396 int pas16_biosparam(int size, int dev, int * ip)
397 {
398 ip[0] = 64;
399 ip[1] = 32;
400 ip[2] = size >> 11;
401 return 0;
402 }
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417 static inline int NCR5380_pread (struct Scsi_Host *instance, unsigned char *dst,
418 int len) {
419 register unsigned char *d = dst;
420 register unsigned short reg = (unsigned short) (instance->io_port +
421 P_DATA_REG_OFFSET);
422 register i = len;
423
424 while ( inb(instance->io_port + P_STATUS_REG_OFFSET) & P_ST_RDY );
425
426 for (; i; --i)
427 *d++ = (unsigned char) inb(reg);
428
429 if ( inb(instance->io_port + P_TIMEOUT_STATUS_REG_OFFSET) & P_TS_TIM) {
430 outb( P_TS_CT, instance->io_port + P_TIMEOUT_STATUS_REG_OFFSET);
431 printk("scsi%d : watchdog timer fired in NCR5480_pread()\n",
432 instance->host_no);
433 return -1;
434 } else
435 return 0;
436 }
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451 static inline int NCR5380_pwrite (struct Scsi_Host *instance, unsigned char *src,
452 int len) {
453 register unsigned char *s = src;
454 register unsigned short reg = (instance->io_port + P_DATA_REG_OFFSET);
455 register i = len;
456
457 while ( ( inb( instance->io_port + P_STATUS_REG_OFFSET ) ) & P_ST_RDY );
458 for (; i; --i)
459 outb( *s++, reg );
460
461 if (inb(instance->io_port + P_TIMEOUT_STATUS_REG_OFFSET) & P_TS_TIM) {
462 outb( P_TS_CT, instance->io_port + P_TIMEOUT_STATUS_REG_OFFSET);
463 printk("scsi%d : watchdog timer fired in NCR5480_pwrite()\n",
464 instance->host_no);
465 return -1;
466 } else
467 return 0;
468 }
469
470
471
472
473
474
475
476
477
478 const char *pas16_info (void) {
479 static const char string[]="";
480 return string;
481 }
482
483 #include "NCR5380.c"