]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blob - drivers/scsi/g_NCR5380.c
ncr5380: Cleanup host info() methods
[mirror_ubuntu-zesty-kernel.git] / drivers / scsi / g_NCR5380.c
1 /*
2 * Generic Generic NCR5380 driver
3 *
4 * Copyright 1993, Drew Eckhardt
5 * Visionary Computing
6 * (Unix and Linux consulting and custom programming)
7 * drew@colorado.edu
8 * +1 (303) 440-4894
9 *
10 * NCR53C400 extensions (c) 1994,1995,1996, Kevin Lentin
11 * K.Lentin@cs.monash.edu.au
12 *
13 * NCR53C400A extensions (c) 1996, Ingmar Baumgart
14 * ingmar@gonzo.schwaben.de
15 *
16 * DTC3181E extensions (c) 1997, Ronald van Cuijlenborg
17 * ronald.van.cuijlenborg@tip.nl or nutty@dds.nl
18 *
19 * Added ISAPNP support for DTC436 adapters,
20 * Thomas Sailer, sailer@ife.ee.ethz.ch
21 *
22 * ALPHA RELEASE 1.
23 */
24
25 /*
26 * TODO : flesh out DMA support, find some one actually using this (I have
27 * a memory mapped Trantor board that works fine)
28 */
29
30 /*
31 * The card is detected and initialized in one of several ways :
32 * 1. With command line overrides - NCR5380=port,irq may be
33 * used on the LILO command line to override the defaults.
34 *
35 * 2. With the GENERIC_NCR5380_OVERRIDE compile time define. This is
36 * specified as an array of address, irq, dma, board tuples. Ie, for
37 * one board at 0x350, IRQ5, no dma, I could say
38 * -DGENERIC_NCR5380_OVERRIDE={{0xcc000, 5, DMA_NONE, BOARD_NCR5380}}
39 *
40 * -1 should be specified for no or DMA interrupt, -2 to autoprobe for an
41 * IRQ line if overridden on the command line.
42 *
43 * 3. When included as a module, with arguments passed on the command line:
44 * ncr_irq=xx the interrupt
45 * ncr_addr=xx the port or base address (for port or memory
46 * mapped, resp.)
47 * ncr_dma=xx the DMA
48 * ncr_5380=1 to set up for a NCR5380 board
49 * ncr_53c400=1 to set up for a NCR53C400 board
50 * e.g.
51 * modprobe g_NCR5380 ncr_irq=5 ncr_addr=0x350 ncr_5380=1
52 * for a port mapped NCR5380 board or
53 * modprobe g_NCR5380 ncr_irq=255 ncr_addr=0xc8000 ncr_53c400=1
54 * for a memory mapped NCR53C400 board with interrupts disabled.
55 *
56 * 255 should be specified for no or DMA interrupt, 254 to autoprobe for an
57 * IRQ line if overridden on the command line.
58 *
59 */
60
61 /* settings for DTC3181E card with only Mustek scanner attached */
62 #define USLEEP_POLL 1
63 #define USLEEP_SLEEP 20
64 #define USLEEP_WAITLONG 500
65
66 #define AUTOPROBE_IRQ
67
68 #ifdef CONFIG_SCSI_GENERIC_NCR53C400
69 #define NCR53C400_PSEUDO_DMA 1
70 #define PSEUDO_DMA
71 #define NCR53C400
72 #endif
73
74 #include <asm/io.h>
75 #include <linux/signal.h>
76 #include <linux/blkdev.h>
77 #include "scsi.h"
78 #include <scsi/scsi_host.h>
79 #include "g_NCR5380.h"
80 #include "NCR5380.h"
81 #include <linux/stat.h>
82 #include <linux/init.h>
83 #include <linux/ioport.h>
84 #include <linux/isapnp.h>
85 #include <linux/delay.h>
86 #include <linux/interrupt.h>
87
88 #define NCR_NOT_SET 0
89 static int ncr_irq = NCR_NOT_SET;
90 static int ncr_dma = NCR_NOT_SET;
91 static int ncr_addr = NCR_NOT_SET;
92 static int ncr_5380 = NCR_NOT_SET;
93 static int ncr_53c400 = NCR_NOT_SET;
94 static int ncr_53c400a = NCR_NOT_SET;
95 static int dtc_3181e = NCR_NOT_SET;
96
97 static struct override {
98 NCR5380_map_type NCR5380_map_name;
99 int irq;
100 int dma;
101 int board; /* Use NCR53c400, Ricoh, etc. extensions ? */
102 } overrides
103 #ifdef GENERIC_NCR5380_OVERRIDE
104 [] __initdata = GENERIC_NCR5380_OVERRIDE;
105 #else
106 [1] __initdata = { { 0,},};
107 #endif
108
109 #define NO_OVERRIDES ARRAY_SIZE(overrides)
110
111 #ifndef MODULE
112
113 /**
114 * internal_setup - handle lilo command string override
115 * @board: BOARD_* identifier for the board
116 * @str: unused
117 * @ints: numeric parameters
118 *
119 * Do LILO command line initialization of the overrides array. Display
120 * errors when needed
121 *
122 * Locks: none
123 */
124
125 static void __init internal_setup(int board, char *str, int *ints)
126 {
127 static int commandline_current = 0;
128 switch (board) {
129 case BOARD_NCR5380:
130 if (ints[0] != 2 && ints[0] != 3) {
131 printk(KERN_ERR "generic_NCR5380_setup : usage ncr5380=" STRVAL(NCR5380_map_name) ",irq,dma\n");
132 return;
133 }
134 break;
135 case BOARD_NCR53C400:
136 if (ints[0] != 2) {
137 printk(KERN_ERR "generic_NCR53C400_setup : usage ncr53c400=" STRVAL(NCR5380_map_name) ",irq\n");
138 return;
139 }
140 break;
141 case BOARD_NCR53C400A:
142 if (ints[0] != 2) {
143 printk(KERN_ERR "generic_NCR53C400A_setup : usage ncr53c400a=" STRVAL(NCR5380_map_name) ",irq\n");
144 return;
145 }
146 break;
147 case BOARD_DTC3181E:
148 if (ints[0] != 2) {
149 printk("generic_DTC3181E_setup : usage dtc3181e=" STRVAL(NCR5380_map_name) ",irq\n");
150 return;
151 }
152 break;
153 }
154
155 if (commandline_current < NO_OVERRIDES) {
156 overrides[commandline_current].NCR5380_map_name = (NCR5380_map_type) ints[1];
157 overrides[commandline_current].irq = ints[2];
158 if (ints[0] == 3)
159 overrides[commandline_current].dma = ints[3];
160 else
161 overrides[commandline_current].dma = DMA_NONE;
162 overrides[commandline_current].board = board;
163 ++commandline_current;
164 }
165 }
166
167
168 /**
169 * do_NCR53C80_setup - set up entry point
170 * @str: unused
171 *
172 * Setup function invoked at boot to parse the ncr5380= command
173 * line.
174 */
175
176 static int __init do_NCR5380_setup(char *str)
177 {
178 int ints[10];
179
180 get_options(str, ARRAY_SIZE(ints), ints);
181 internal_setup(BOARD_NCR5380, str, ints);
182 return 1;
183 }
184
185 /**
186 * do_NCR53C400_setup - set up entry point
187 * @str: unused
188 * @ints: integer parameters from kernel setup code
189 *
190 * Setup function invoked at boot to parse the ncr53c400= command
191 * line.
192 */
193
194 static int __init do_NCR53C400_setup(char *str)
195 {
196 int ints[10];
197
198 get_options(str, ARRAY_SIZE(ints), ints);
199 internal_setup(BOARD_NCR53C400, str, ints);
200 return 1;
201 }
202
203 /**
204 * do_NCR53C400A_setup - set up entry point
205 * @str: unused
206 * @ints: integer parameters from kernel setup code
207 *
208 * Setup function invoked at boot to parse the ncr53c400a= command
209 * line.
210 */
211
212 static int __init do_NCR53C400A_setup(char *str)
213 {
214 int ints[10];
215
216 get_options(str, ARRAY_SIZE(ints), ints);
217 internal_setup(BOARD_NCR53C400A, str, ints);
218 return 1;
219 }
220
221 /**
222 * do_DTC3181E_setup - set up entry point
223 * @str: unused
224 * @ints: integer parameters from kernel setup code
225 *
226 * Setup function invoked at boot to parse the dtc3181e= command
227 * line.
228 */
229
230 static int __init do_DTC3181E_setup(char *str)
231 {
232 int ints[10];
233
234 get_options(str, ARRAY_SIZE(ints), ints);
235 internal_setup(BOARD_DTC3181E, str, ints);
236 return 1;
237 }
238
239 #endif
240
241 /**
242 * generic_NCR5380_detect - look for NCR5380 controllers
243 * @tpnt: the scsi template
244 *
245 * Scan for the present of NCR5380, NCR53C400, NCR53C400A, DTC3181E
246 * and DTC436(ISAPnP) controllers. If overrides have been set we use
247 * them.
248 *
249 * The caller supplied NCR5380_init function is invoked from here, before
250 * the interrupt line is taken.
251 *
252 * Locks: none
253 */
254
255 static int __init generic_NCR5380_detect(struct scsi_host_template *tpnt)
256 {
257 static int current_override = 0;
258 int count;
259 unsigned int *ports;
260 #ifndef SCSI_G_NCR5380_MEM
261 int i;
262 unsigned long region_size = 16;
263 #endif
264 static unsigned int __initdata ncr_53c400a_ports[] = {
265 0x280, 0x290, 0x300, 0x310, 0x330, 0x340, 0x348, 0x350, 0
266 };
267 static unsigned int __initdata dtc_3181e_ports[] = {
268 0x220, 0x240, 0x280, 0x2a0, 0x2c0, 0x300, 0x320, 0x340, 0
269 };
270 int flags = 0;
271 struct Scsi_Host *instance;
272 #ifdef SCSI_G_NCR5380_MEM
273 unsigned long base;
274 void __iomem *iomem;
275 #endif
276
277 if (ncr_irq != NCR_NOT_SET)
278 overrides[0].irq = ncr_irq;
279 if (ncr_dma != NCR_NOT_SET)
280 overrides[0].dma = ncr_dma;
281 if (ncr_addr != NCR_NOT_SET)
282 overrides[0].NCR5380_map_name = (NCR5380_map_type) ncr_addr;
283 if (ncr_5380 != NCR_NOT_SET)
284 overrides[0].board = BOARD_NCR5380;
285 else if (ncr_53c400 != NCR_NOT_SET)
286 overrides[0].board = BOARD_NCR53C400;
287 else if (ncr_53c400a != NCR_NOT_SET)
288 overrides[0].board = BOARD_NCR53C400A;
289 else if (dtc_3181e != NCR_NOT_SET)
290 overrides[0].board = BOARD_DTC3181E;
291 #ifndef SCSI_G_NCR5380_MEM
292 if (!current_override && isapnp_present()) {
293 struct pnp_dev *dev = NULL;
294 count = 0;
295 while ((dev = pnp_find_dev(NULL, ISAPNP_VENDOR('D', 'T', 'C'), ISAPNP_FUNCTION(0x436e), dev))) {
296 if (count >= NO_OVERRIDES)
297 break;
298 if (pnp_device_attach(dev) < 0)
299 continue;
300 if (pnp_activate_dev(dev) < 0) {
301 printk(KERN_ERR "dtc436e probe: activate failed\n");
302 pnp_device_detach(dev);
303 continue;
304 }
305 if (!pnp_port_valid(dev, 0)) {
306 printk(KERN_ERR "dtc436e probe: no valid port\n");
307 pnp_device_detach(dev);
308 continue;
309 }
310 if (pnp_irq_valid(dev, 0))
311 overrides[count].irq = pnp_irq(dev, 0);
312 else
313 overrides[count].irq = NO_IRQ;
314 if (pnp_dma_valid(dev, 0))
315 overrides[count].dma = pnp_dma(dev, 0);
316 else
317 overrides[count].dma = DMA_NONE;
318 overrides[count].NCR5380_map_name = (NCR5380_map_type) pnp_port_start(dev, 0);
319 overrides[count].board = BOARD_DTC3181E;
320 count++;
321 }
322 }
323 #endif
324 tpnt->proc_name = "g_NCR5380";
325
326 for (count = 0; current_override < NO_OVERRIDES; ++current_override) {
327 if (!(overrides[current_override].NCR5380_map_name))
328 continue;
329
330 ports = NULL;
331 switch (overrides[current_override].board) {
332 case BOARD_NCR5380:
333 flags = FLAG_NO_PSEUDO_DMA;
334 break;
335 case BOARD_NCR53C400:
336 flags = FLAG_NCR53C400;
337 break;
338 case BOARD_NCR53C400A:
339 flags = FLAG_NO_PSEUDO_DMA;
340 ports = ncr_53c400a_ports;
341 break;
342 case BOARD_DTC3181E:
343 flags = FLAG_NO_PSEUDO_DMA | FLAG_DTC3181E;
344 ports = dtc_3181e_ports;
345 break;
346 }
347
348 #ifndef SCSI_G_NCR5380_MEM
349 if (ports) {
350 /* wakeup sequence for the NCR53C400A and DTC3181E */
351
352 /* Disable the adapter and look for a free io port */
353 outb(0x59, 0x779);
354 outb(0xb9, 0x379);
355 outb(0xc5, 0x379);
356 outb(0xae, 0x379);
357 outb(0xa6, 0x379);
358 outb(0x00, 0x379);
359
360 if (overrides[current_override].NCR5380_map_name != PORT_AUTO)
361 for (i = 0; ports[i]; i++) {
362 if (!request_region(ports[i], 16, "ncr53c80"))
363 continue;
364 if (overrides[current_override].NCR5380_map_name == ports[i])
365 break;
366 release_region(ports[i], 16);
367 } else
368 for (i = 0; ports[i]; i++) {
369 if (!request_region(ports[i], 16, "ncr53c80"))
370 continue;
371 if (inb(ports[i]) == 0xff)
372 break;
373 release_region(ports[i], 16);
374 }
375 if (ports[i]) {
376 /* At this point we have our region reserved */
377 outb(0x59, 0x779);
378 outb(0xb9, 0x379);
379 outb(0xc5, 0x379);
380 outb(0xae, 0x379);
381 outb(0xa6, 0x379);
382 outb(0x80 | i, 0x379); /* set io port to be used */
383 outb(0xc0, ports[i] + 9);
384 if (inb(ports[i] + 9) != 0x80)
385 continue;
386 else
387 overrides[current_override].NCR5380_map_name = ports[i];
388 } else
389 continue;
390 }
391 else
392 {
393 /* Not a 53C400A style setup - just grab */
394 if(!(request_region(overrides[current_override].NCR5380_map_name, NCR5380_region_size, "ncr5380")))
395 continue;
396 region_size = NCR5380_region_size;
397 }
398 #else
399 base = overrides[current_override].NCR5380_map_name;
400 if (!request_mem_region(base, NCR5380_region_size, "ncr5380"))
401 continue;
402 iomem = ioremap(base, NCR5380_region_size);
403 if (!iomem) {
404 release_mem_region(base, NCR5380_region_size);
405 continue;
406 }
407 #endif
408 instance = scsi_register(tpnt, sizeof(struct NCR5380_hostdata));
409 if (instance == NULL) {
410 #ifndef SCSI_G_NCR5380_MEM
411 release_region(overrides[current_override].NCR5380_map_name, region_size);
412 #else
413 iounmap(iomem);
414 release_mem_region(base, NCR5380_region_size);
415 #endif
416 continue;
417 }
418
419 instance->NCR5380_instance_name = overrides[current_override].NCR5380_map_name;
420 #ifndef SCSI_G_NCR5380_MEM
421 instance->n_io_port = region_size;
422 #else
423 ((struct NCR5380_hostdata *)instance->hostdata)->iomem = iomem;
424 #endif
425
426 NCR5380_init(instance, flags);
427
428 if (overrides[current_override].irq != IRQ_AUTO)
429 instance->irq = overrides[current_override].irq;
430 else
431 instance->irq = NCR5380_probe_irq(instance, 0xffff);
432
433 /* Compatibility with documented NCR5380 kernel parameters */
434 if (instance->irq == 255)
435 instance->irq = NO_IRQ;
436
437 if (instance->irq != NO_IRQ)
438 if (request_irq(instance->irq, generic_NCR5380_intr,
439 0, "NCR5380", instance)) {
440 printk(KERN_WARNING "scsi%d : IRQ%d not free, interrupts disabled\n", instance->host_no, instance->irq);
441 instance->irq = NO_IRQ;
442 }
443
444 if (instance->irq == NO_IRQ) {
445 printk(KERN_INFO "scsi%d : interrupts not enabled. for better interactive performance,\n", instance->host_no);
446 printk(KERN_INFO "scsi%d : please jumper the board for a free IRQ.\n", instance->host_no);
447 }
448
449 ++current_override;
450 ++count;
451 }
452 return count;
453 }
454
455 /**
456 * generic_NCR5380_release_resources - free resources
457 * @instance: host adapter to clean up
458 *
459 * Free the generic interface resources from this adapter.
460 *
461 * Locks: none
462 */
463
464 static int generic_NCR5380_release_resources(struct Scsi_Host *instance)
465 {
466 NCR5380_local_declare();
467 NCR5380_setup(instance);
468
469 if (instance->irq != NO_IRQ)
470 free_irq(instance->irq, instance);
471 NCR5380_exit(instance);
472
473 #ifndef SCSI_G_NCR5380_MEM
474 release_region(instance->NCR5380_instance_name, instance->n_io_port);
475 #else
476 iounmap(((struct NCR5380_hostdata *)instance->hostdata)->iomem);
477 release_mem_region(instance->NCR5380_instance_name, NCR5380_region_size);
478 #endif
479
480
481 return 0;
482 }
483
484 #ifdef BIOSPARAM
485 /**
486 * generic_NCR5380_biosparam
487 * @disk: disk to compute geometry for
488 * @dev: device identifier for this disk
489 * @ip: sizes to fill in
490 *
491 * Generates a BIOS / DOS compatible H-C-S mapping for the specified
492 * device / size.
493 *
494 * XXX Most SCSI boards use this mapping, I could be incorrect. Someone
495 * using hard disks on a trantor should verify that this mapping
496 * corresponds to that used by the BIOS / ASPI driver by running the linux
497 * fdisk program and matching the H_C_S coordinates to what DOS uses.
498 *
499 * Locks: none
500 */
501
502 static int
503 generic_NCR5380_biosparam(struct scsi_device *sdev, struct block_device *bdev,
504 sector_t capacity, int *ip)
505 {
506 ip[0] = 64;
507 ip[1] = 32;
508 ip[2] = capacity >> 11;
509 return 0;
510 }
511 #endif
512
513 #ifdef NCR53C400_PSEUDO_DMA
514
515 /**
516 * NCR5380_pread - pseudo DMA read
517 * @instance: adapter to read from
518 * @dst: buffer to read into
519 * @len: buffer length
520 *
521 * Perform a pseudo DMA mode read from an NCR53C400 or equivalent
522 * controller
523 */
524
525 static inline int NCR5380_pread(struct Scsi_Host *instance, unsigned char *dst, int len)
526 {
527 int blocks = len / 128;
528 int start = 0;
529 int bl;
530
531 NCR5380_local_declare();
532 NCR5380_setup(instance);
533
534 NCR5380_write(C400_CONTROL_STATUS_REG, CSR_BASE | CSR_TRANS_DIR);
535 NCR5380_write(C400_BLOCK_COUNTER_REG, blocks);
536 while (1) {
537 if ((bl = NCR5380_read(C400_BLOCK_COUNTER_REG)) == 0) {
538 break;
539 }
540 if (NCR5380_read(C400_CONTROL_STATUS_REG) & CSR_GATED_53C80_IRQ) {
541 printk(KERN_ERR "53C400r: Got 53C80_IRQ start=%d, blocks=%d\n", start, blocks);
542 return -1;
543 }
544 while (NCR5380_read(C400_CONTROL_STATUS_REG) & CSR_HOST_BUF_NOT_RDY);
545
546 #ifndef SCSI_G_NCR5380_MEM
547 {
548 int i;
549 for (i = 0; i < 128; i++)
550 dst[start + i] = NCR5380_read(C400_HOST_BUFFER);
551 }
552 #else
553 /* implies SCSI_G_NCR5380_MEM */
554 memcpy_fromio(dst + start, iomem + NCR53C400_host_buffer, 128);
555 #endif
556 start += 128;
557 blocks--;
558 }
559
560 if (blocks) {
561 while (NCR5380_read(C400_CONTROL_STATUS_REG) & CSR_HOST_BUF_NOT_RDY)
562 {
563 // FIXME - no timeout
564 }
565
566 #ifndef SCSI_G_NCR5380_MEM
567 {
568 int i;
569 for (i = 0; i < 128; i++)
570 dst[start + i] = NCR5380_read(C400_HOST_BUFFER);
571 }
572 #else
573 /* implies SCSI_G_NCR5380_MEM */
574 memcpy_fromio(dst + start, iomem + NCR53C400_host_buffer, 128);
575 #endif
576 start += 128;
577 blocks--;
578 }
579
580 if (!(NCR5380_read(C400_CONTROL_STATUS_REG) & CSR_GATED_53C80_IRQ))
581 printk("53C400r: no 53C80 gated irq after transfer");
582
583 #if 0
584 /*
585 * DON'T DO THIS - THEY NEVER ARRIVE!
586 */
587 printk("53C400r: Waiting for 53C80 registers\n");
588 while (NCR5380_read(C400_CONTROL_STATUS_REG) & CSR_53C80_REG)
589 ;
590 #endif
591 if (!(NCR5380_read(BUS_AND_STATUS_REG) & BASR_END_DMA_TRANSFER))
592 printk(KERN_ERR "53C400r: no end dma signal\n");
593
594 NCR5380_write(MODE_REG, MR_BASE);
595 NCR5380_read(RESET_PARITY_INTERRUPT_REG);
596 return 0;
597 }
598
599 /**
600 * NCR5380_write - pseudo DMA write
601 * @instance: adapter to read from
602 * @dst: buffer to read into
603 * @len: buffer length
604 *
605 * Perform a pseudo DMA mode read from an NCR53C400 or equivalent
606 * controller
607 */
608
609 static inline int NCR5380_pwrite(struct Scsi_Host *instance, unsigned char *src, int len)
610 {
611 int blocks = len / 128;
612 int start = 0;
613 int bl;
614 int i;
615
616 NCR5380_local_declare();
617 NCR5380_setup(instance);
618
619 NCR5380_write(C400_CONTROL_STATUS_REG, CSR_BASE);
620 NCR5380_write(C400_BLOCK_COUNTER_REG, blocks);
621 while (1) {
622 if (NCR5380_read(C400_CONTROL_STATUS_REG) & CSR_GATED_53C80_IRQ) {
623 printk(KERN_ERR "53C400w: Got 53C80_IRQ start=%d, blocks=%d\n", start, blocks);
624 return -1;
625 }
626
627 if ((bl = NCR5380_read(C400_BLOCK_COUNTER_REG)) == 0) {
628 break;
629 }
630 while (NCR5380_read(C400_CONTROL_STATUS_REG) & CSR_HOST_BUF_NOT_RDY)
631 ; // FIXME - timeout
632 #ifndef SCSI_G_NCR5380_MEM
633 {
634 for (i = 0; i < 128; i++)
635 NCR5380_write(C400_HOST_BUFFER, src[start + i]);
636 }
637 #else
638 /* implies SCSI_G_NCR5380_MEM */
639 memcpy_toio(iomem + NCR53C400_host_buffer, src + start, 128);
640 #endif
641 start += 128;
642 blocks--;
643 }
644 if (blocks) {
645 while (NCR5380_read(C400_CONTROL_STATUS_REG) & CSR_HOST_BUF_NOT_RDY)
646 ; // FIXME - no timeout
647
648 #ifndef SCSI_G_NCR5380_MEM
649 {
650 for (i = 0; i < 128; i++)
651 NCR5380_write(C400_HOST_BUFFER, src[start + i]);
652 }
653 #else
654 /* implies SCSI_G_NCR5380_MEM */
655 memcpy_toio(iomem + NCR53C400_host_buffer, src + start, 128);
656 #endif
657 start += 128;
658 blocks--;
659 }
660
661 #if 0
662 printk("53C400w: waiting for registers to be available\n");
663 THEY NEVER DO ! while (NCR5380_read(C400_CONTROL_STATUS_REG) & CSR_53C80_REG);
664 printk("53C400w: Got em\n");
665 #endif
666
667 /* Let's wait for this instead - could be ugly */
668 /* All documentation says to check for this. Maybe my hardware is too
669 * fast. Waiting for it seems to work fine! KLL
670 */
671 while (!(i = NCR5380_read(C400_CONTROL_STATUS_REG) & CSR_GATED_53C80_IRQ))
672 ; // FIXME - no timeout
673
674 /*
675 * I know. i is certainly != 0 here but the loop is new. See previous
676 * comment.
677 */
678 if (i) {
679 if (!((i = NCR5380_read(BUS_AND_STATUS_REG)) & BASR_END_DMA_TRANSFER))
680 printk(KERN_ERR "53C400w: No END OF DMA bit - WHOOPS! BASR=%0x\n", i);
681 } else
682 printk(KERN_ERR "53C400w: no 53C80 gated irq after transfer (last block)\n");
683
684 #if 0
685 if (!(NCR5380_read(BUS_AND_STATUS_REG) & BASR_END_DMA_TRANSFER)) {
686 printk(KERN_ERR "53C400w: no end dma signal\n");
687 }
688 #endif
689 while (!(NCR5380_read(TARGET_COMMAND_REG) & TCR_LAST_BYTE_SENT))
690 ; // TIMEOUT
691 return 0;
692 }
693 #endif /* PSEUDO_DMA */
694
695 /*
696 * Include the NCR5380 core code that we build our driver around
697 */
698
699 #include "NCR5380.c"
700
701 static struct scsi_host_template driver_template = {
702 .show_info = generic_NCR5380_show_info,
703 .name = "Generic NCR5380/NCR53C400 SCSI",
704 .detect = generic_NCR5380_detect,
705 .release = generic_NCR5380_release_resources,
706 .info = generic_NCR5380_info,
707 .queuecommand = generic_NCR5380_queue_command,
708 .eh_abort_handler = generic_NCR5380_abort,
709 .eh_bus_reset_handler = generic_NCR5380_bus_reset,
710 .bios_param = NCR5380_BIOSPARAM,
711 .can_queue = CAN_QUEUE,
712 .this_id = 7,
713 .sg_tablesize = SG_ALL,
714 .cmd_per_lun = CMD_PER_LUN,
715 .use_clustering = DISABLE_CLUSTERING,
716 };
717 #include <linux/module.h>
718 #include "scsi_module.c"
719
720 module_param(ncr_irq, int, 0);
721 module_param(ncr_dma, int, 0);
722 module_param(ncr_addr, int, 0);
723 module_param(ncr_5380, int, 0);
724 module_param(ncr_53c400, int, 0);
725 module_param(ncr_53c400a, int, 0);
726 module_param(dtc_3181e, int, 0);
727 MODULE_LICENSE("GPL");
728
729 #ifndef SCSI_G_NCR5380_MEM
730 static struct isapnp_device_id id_table[] = {
731 {
732 ISAPNP_ANY_ID, ISAPNP_ANY_ID,
733 ISAPNP_VENDOR('D', 'T', 'C'), ISAPNP_FUNCTION(0x436e),
734 0},
735 {0}
736 };
737
738 MODULE_DEVICE_TABLE(isapnp, id_table);
739 #endif
740
741 __setup("ncr5380=", do_NCR5380_setup);
742 __setup("ncr53c400=", do_NCR53C400_setup);
743 __setup("ncr53c400a=", do_NCR53C400A_setup);
744 __setup("dtc3181e=", do_DTC3181E_setup);