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