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