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