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
307
308
309
310
311
312
313
314
315
316
317
318
319 int pas16_detect(Scsi_Host_Template * tpnt) {
320 static int current_override = 0;
321 static unsigned short current_base = 0;
322 struct Scsi_Host *instance;
323 unsigned short io_port;
324 int count;
325
326 for (count = 0; current_override < NO_OVERRIDES; ++current_override) {
327 io_port = 0;
328
329 if (overrides[current_override].io_port)
330 {
331 io_port = overrides[current_override].io_port;
332 enable_board( current_override, io_port );
333 init_board( io_port, overrides[current_override].irq, 1 );
334 }
335 else
336 for (; !io_port && (current_base < NO_BASES); ++current_base) {
337 #if (PDEBUG & PDEBUG_INIT)
338 printk("scsi-pas16 : probing io_port %04x\n", (unsigned int) bases[current_base].io_port);
339 #endif
340 if ( !bases[current_base].noauto &&
341 pas16_hw_detect( current_base ) ){
342 io_port = bases[current_base].io_port;
343 init_board( io_port, default_irqs[ current_base ], 0 );
344 #if (PDEBUG & PDEBUG_INIT)
345 printk("scsi-pas16 : detected board.\n");
346 #endif
347 }
348 }
349
350
351 #if defined(PDEBUG) && (PDEBUG & PDEBUG_INIT)
352 printk("scsi-pas16 : io_port = %04x\n", (unsigned int) io_port);
353 #endif
354
355 if (!io_port)
356 break;
357
358 instance = scsi_register (tpnt, sizeof(struct NCR5380_hostdata));
359 instance->io_port = io_port;
360
361 NCR5380_init(instance, 0);
362
363 if (overrides[current_override].irq != IRQ_AUTO)
364 instance->irq = overrides[current_override].irq;
365 else
366 instance->irq = NCR5380_probe_irq(instance, PAS16_IRQS);
367
368 if (instance->irq != IRQ_NONE)
369 if (request_irq(instance->irq, pas16_intr, SA_INTERRUPT, "pas16")) {
370 printk("scsi%d : IRQ%d not free, interrupts disabled\n",
371 instance->host_no, instance->irq);
372 instance->irq = IRQ_NONE;
373 }
374
375 if (instance->irq == IRQ_NONE) {
376 printk("scsi%d : interrupts not enabled. for better interactive performance,\n", instance->host_no);
377 printk("scsi%d : please jumper the board for a free IRQ.\n", instance->host_no);
378
379 outb( 0x4d, io_port + SYS_CONFIG_4 );
380 }
381
382 #if defined(PDEBUG) && (PDEBUG & PDEBUG_INIT)
383 printk("scsi%d : irq = %d\n", instance->host_no, instance->irq);
384 #endif
385
386 printk("scsi%d : at 0x%04x", instance->host_no, (int)
387 instance->io_port);
388 if (instance->irq == IRQ_NONE)
389 printk (" interrupts disabled");
390 else
391 printk (" irq %d", instance->irq);
392 printk(" options CAN_QUEUE=%d CMD_PER_LUN=%d release=%d",
393 CAN_QUEUE, CMD_PER_LUN, PAS16_PUBLIC_RELEASE);
394 NCR5380_print_options(instance);
395 printk("\n");
396
397 ++current_override;
398 ++count;
399 }
400 return count;
401 }
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423 int pas16_biosparam(Disk * disk, int dev, int * ip)
424 {
425 int size = disk->capacity;
426 ip[0] = 64;
427 ip[1] = 32;
428 ip[2] = size >> 11;
429 return 0;
430 }
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445 static inline int NCR5380_pread (struct Scsi_Host *instance, unsigned char *dst,
446 int len) {
447 register unsigned char *d = dst;
448 register unsigned short reg = (unsigned short) (instance->io_port +
449 P_DATA_REG_OFFSET);
450 register i = len;
451
452 while ( inb(instance->io_port + P_STATUS_REG_OFFSET) & P_ST_RDY );
453
454 for (; i; --i)
455 *d++ = (unsigned char) inb(reg);
456
457 if ( inb(instance->io_port + P_TIMEOUT_STATUS_REG_OFFSET) & P_TS_TIM) {
458 outb( P_TS_CT, instance->io_port + P_TIMEOUT_STATUS_REG_OFFSET);
459 printk("scsi%d : watchdog timer fired in NCR5480_pread()\n",
460 instance->host_no);
461 return -1;
462 } else
463 return 0;
464 }
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479 static inline int NCR5380_pwrite (struct Scsi_Host *instance, unsigned char *src,
480 int len) {
481 register unsigned char *s = src;
482 register unsigned short reg = (instance->io_port + P_DATA_REG_OFFSET);
483 register i = len;
484
485 while ( ( inb( instance->io_port + P_STATUS_REG_OFFSET ) ) & P_ST_RDY );
486 for (; i; --i)
487 outb( *s++, reg );
488
489 if (inb(instance->io_port + P_TIMEOUT_STATUS_REG_OFFSET) & P_TS_TIM) {
490 outb( P_TS_CT, instance->io_port + P_TIMEOUT_STATUS_REG_OFFSET);
491 printk("scsi%d : watchdog timer fired in NCR5480_pwrite()\n",
492 instance->host_no);
493 return -1;
494 } else
495 return 0;
496 }
497
498
499
500
501
502
503
504
505
506 const char *pas16_info (void) {
507 static const char string[]="";
508 return string;
509 }
510
511 #include "NCR5380.c"