88 #define USLEEP_SLEEP 20
89 #define USLEEP_WAITLONG 500
95 #ifdef CONFIG_SCSI_GENERIC_NCR53C400
96 #define NCR53C400_PSEUDO_DMA 1
100 #undef NCR5380_STAT_LIMIT
104 #include <linux/signal.h>
110 #include <linux/stat.h>
117 #define NCR_NOT_SET 0
126 static struct override {
132 #ifdef GENERIC_NCR5380_OVERRIDE
135 [1] __initdata = { { 0,},};
138 #define NO_OVERRIDES ARRAY_SIZE(overrides)
154 static void __init internal_setup(
int board,
char *
str,
int *ints)
156 static int commandline_current = 0;
159 if (ints[0] != 2 && ints[0] != 3) {
186 overrides[commandline_current].irq = ints[2];
188 overrides[commandline_current].dma = ints[3];
191 overrides[commandline_current].board = board;
192 ++commandline_current;
205 static int __init do_NCR5380_setup(
char *
str)
223 static int __init do_NCR53C400_setup(
char *str)
241 static int __init do_NCR53C400A_setup(
char *str)
259 static int __init do_DTC3181E_setup(
char *str)
286 static int current_override = 0;
289 #ifndef SCSI_G_NCR5380_MEM
291 unsigned long region_size = 16;
293 static unsigned int __initdata ncr_53c400a_ports[] = {
294 0x280, 0x290, 0x300, 0x310, 0x330, 0x340, 0x348, 0x350, 0
296 static unsigned int __initdata dtc_3181e_ports[] = {
297 0x220, 0x240, 0x280, 0x2a0, 0x2c0, 0x300, 0x320, 0x340, 0
301 #ifdef SCSI_G_NCR5380_MEM
320 #ifndef SCSI_G_NCR5380_MEM
334 if (!pnp_port_valid(dev, 0)) {
339 if (pnp_irq_valid(dev, 0))
343 if (pnp_dma_valid(dev, 0))
355 for (count = 0; current_override <
NO_OVERRIDES; ++current_override) {
369 ports = ncr_53c400a_ports;
373 ports = dtc_3181e_ports;
377 #ifndef SCSI_G_NCR5380_MEM
390 for (i = 0; ports[
i]; i++) {
393 if (
overrides[current_override].NCR5380_map_name == ports[i])
397 for (i = 0; ports[
i]; i++) {
400 if (
inb(ports[i]) == 0xff)
411 outb(0x80 | i, 0x379);
412 outb(0xc0, ports[i] + 9);
413 if (
inb(ports[i] + 9) != 0x80)
416 overrides[current_override].NCR5380_map_name = ports[
i];
428 base =
overrides[current_override].NCR5380_map_name;
438 if (instance ==
NULL) {
439 #ifndef SCSI_G_NCR5380_MEM
448 instance->NCR5380_instance_name =
overrides[current_override].NCR5380_map_name;
449 #ifndef SCSI_G_NCR5380_MEM
455 NCR5380_init(instance, flags);
460 instance->
irq = NCR5380_probe_irq(instance, 0xffff);
470 printk(
KERN_INFO "scsi%d : interrupts not enabled. for better interactive performance,\n", instance->
host_no);
476 printk(
" interrupts disabled");
480 NCR5380_print_options(instance);
498 static const char string[] =
"Generic NCR5380/53C400 Driver";
518 NCR5380_exit(instance);
520 #ifndef SCSI_G_NCR5380_MEM
555 ip[2] = capacity >> 11;
560 #ifdef NCR53C400_PSEUDO_DMA
574 int blocks = len / 128;
588 printk(
KERN_ERR "53C400r: Got 53C80_IRQ start=%d, blocks=%d\n", start, blocks);
593 #ifndef SCSI_G_NCR5380_MEM
596 for (i = 0; i < 128; i++)
601 memcpy_fromio(dst + start, iomem + NCR53C400_host_buffer, 128);
613 #ifndef SCSI_G_NCR5380_MEM
616 for (i = 0; i < 128; i++)
621 memcpy_fromio(dst + start, iomem + NCR53C400_host_buffer, 128);
628 printk(
"53C400r: no 53C80 gated irq after transfer");
634 printk(
"53C400r: Waiting for 53C80 registers\n");
658 int blocks = len / 128;
670 printk(
KERN_ERR "53C400w: Got 53C80_IRQ start=%d, blocks=%d\n", start, blocks);
679 #ifndef SCSI_G_NCR5380_MEM
681 for (i = 0; i < 128; i++)
686 memcpy_toio(iomem + NCR53C400_host_buffer, src + start, 128);
695 #ifndef SCSI_G_NCR5380_MEM
697 for (i = 0; i < 128; i++)
702 memcpy_toio(iomem + NCR53C400_host_buffer, src + start, 128);
709 printk(
"53C400w: waiting for registers to be available\n");
711 printk(
"53C400w: Got em\n");
727 printk(
KERN_ERR "53C400w: No END OF DMA bit - WHOOPS! BASR=%0x\n", i);
729 printk(
KERN_ERR "53C400w: no 53C80 gated irq after transfer (last block)\n");
748 #define PRINTP(x) len += sprintf(buffer+len, x)
751 static int sprint_opcode(
char *
buffer,
int len,
int opcode)
758 static int sprint_command(
char *
buffer,
int len,
unsigned char *
command)
760 int i,
s, start = len;
761 len += sprint_opcode(buffer, len, command[0]);
777 static int sprint_Scsi_Cmnd(
char *buffer,
int len,
Scsi_Cmnd *
cmd)
782 len += sprint_command(buffer, len, cmd->
cmnd);
803 static int generic_NCR5380_proc_info(
struct Scsi_Host *scsi_ptr,
char *buffer,
char **start,
off_t offset,
int length,
int inout)
826 # if NCR53C400_PSEUDO_DMA
827 PRINTP(
"NCR53C400 pseudo DMA used\n");
830 PRINTP(
"NO NCR53C400 driver extensions\n");
840 PRINTP(
"There are commands pending, transfer rates may be crud\n");
841 if (hostdata->pendingr)
842 PRINTP(
" %d pending reads" ANDP hostdata->pendingr);
843 if (hostdata->pendingw)
844 PRINTP(
" %d pending writes" ANDP hostdata->pendingw);
845 if (hostdata->pendingr || hostdata->pendingw)
848 unsigned long br = hostdata->bytes_read[dev->
id];
849 unsigned long bw = hostdata->bytes_write[dev->
id];
850 long tr = hostdata->time_read[dev->
id] /
HZ;
851 long tw = hostdata->time_write[dev->
id] /
HZ;
854 for (i = 0; i < 8; i++)
855 if (dev->
vendor[i] >= 0x20)
856 *(buffer + (len++)) = dev->
vendor[
i];
857 *(buffer + (len++)) =
' ';
858 for (i = 0; i < 16; i++)
859 if (dev->
model[i] >= 0x20)
860 *(buffer + (len++)) = dev->
model[
i];
861 *(buffer + (len++)) =
' ';
862 for (i = 0; i < 4; i++)
863 if (dev->
rev[i] >= 0x20)
864 *(buffer + (len++)) = dev->
rev[
i];
865 *(buffer + (len++)) =
' ';
880 PRINTP(
"REQ not asserted, phase unknown.\n");
887 PRINTP(
"No currently connected command\n");
895 len += sprint_Scsi_Cmnd(buffer, len, ptr);
897 PRINTP(
"disconnected_queue\n");
900 len += sprint_Scsi_Cmnd(buffer, len, ptr);
906 spin_unlock_irqrestore(scsi_ptr->
host_lock, flags);
914 .proc_info = generic_NCR5380_proc_info,
915 .name =
"Generic NCR5380/NCR53C400 Scsi Driver",
919 .queuecommand = generic_NCR5380_queue_command,
920 .eh_abort_handler = generic_NCR5380_abort,
921 .eh_bus_reset_handler = generic_NCR5380_bus_reset,
929 #include <linux/module.h>
941 #ifndef SCSI_G_NCR5380_MEM
953 __setup(
"ncr5380=", do_NCR5380_setup);
954 __setup(
"ncr53c400=", do_NCR53C400_setup);
955 __setup(
"ncr53c400a=", do_NCR53C400A_setup);
956 __setup(
"dtc3181e=", do_DTC3181E_setup);