X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Fscsi%2Ffdomain.c;h=a78b6f257b3df58a506efc4235232825283fa1fe;hb=6367666f534ee8fa9c6a7b667f38b5e445f85918;hp=075312fcc3f47cbbff0a020bc6757ba0fcd1cf27;hpb=8d40237c730b8be87c1b80a5d96b9c603fefa829;p=linux-2.6.git diff --git a/drivers/scsi/fdomain.c b/drivers/scsi/fdomain.c index 075312fcc..a78b6f257 100644 --- a/drivers/scsi/fdomain.c +++ b/drivers/scsi/fdomain.c @@ -384,7 +384,6 @@ enum out_port_type { /* .bss will zero all the static variables below */ static int port_base; static unsigned long bios_base; -static void __iomem * bios_mem; static int bios_major; static int bios_minor; static int PCI_bus; @@ -401,6 +400,20 @@ static int setup_called; static volatile int in_interrupt_flag; #endif +static int SCSI_Mode_Cntl_port; +static int FIFO_Data_Count_port; +static int Interrupt_Cntl_port; +static int Interrupt_Status_port; +static int Read_FIFO_port; +static int Read_SCSI_Data_port; +static int SCSI_Cntl_port; +static int SCSI_Data_NoACK_port; +static int SCSI_Status_port; +static int TMC_Cntl_port; +static int TMC_Status_port; +static int Write_FIFO_port; +static int Write_SCSI_Data_port; + static int FIFO_Size = 0x2000; /* 8k FIFO for pre-tmc18c30 chips */ @@ -459,7 +472,7 @@ static unsigned short ints[] = { 3, 5, 10, 11, 12, 14, 15, 0 }; */ -static struct signature { +struct signature { const char *signature; int sig_offset; int sig_length; @@ -572,12 +585,12 @@ static void do_pause(unsigned amount) /* Pause for amount*10 milliseconds */ inline static void fdomain_make_bus_idle( void ) { - outb(0, port_base + SCSI_Cntl); - outb(0, port_base + SCSI_Mode_Cntl); + outb( 0, SCSI_Cntl_port ); + outb( 0, SCSI_Mode_Cntl_port ); if (chip == tmc18c50 || chip == tmc18c30) - outb(0x21 | PARITY_MASK, port_base + TMC_Cntl); /* Clear forced intr. */ + outb( 0x21 | PARITY_MASK, TMC_Cntl_port ); /* Clear forced intr. */ else - outb(0x01 | PARITY_MASK, port_base + TMC_Cntl); + outb( 0x01 | PARITY_MASK, TMC_Cntl_port ); } static int fdomain_is_valid_port( int port ) @@ -677,15 +690,12 @@ static int fdomain_isa_detect( int *irq, int *iobase ) printk( "scsi: fdomain_isa_detect:" ); #endif - for (i = 0; i < ADDRESS_COUNT; i++) { - void __iomem *p = ioremap(addresses[i], 0x2000); - if (!p) - continue; + for (i = 0; !bios_base && i < ADDRESS_COUNT; i++) { #if DEBUG_DETECT printk( " %lx(%lx),", addresses[i], bios_base ); #endif - for (j = 0; j < SIGNATURE_COUNT; j++) { - if (check_signature(p + signatures[j].sig_offset, + for (j = 0; !bios_base && j < SIGNATURE_COUNT; j++) { + if (isa_check_signature(addresses[i] + signatures[j].sig_offset, signatures[j].signature, signatures[j].sig_length )) { bios_major = signatures[j].major_bios_version; @@ -693,14 +703,10 @@ static int fdomain_isa_detect( int *irq, int *iobase ) PCI_bus = (signatures[j].flag == 1); Quantum = (signatures[j].flag > 1) ? signatures[j].flag : 0; bios_base = addresses[i]; - bios_mem = p; - goto found; } } - iounmap(p); } - -found: + if (bios_major == 2) { /* The TMC-1660/TMC-1680 has a RAM area just after the BIOS ROM. Assuming the ROM is enabled (otherwise we wouldn't have been @@ -713,13 +719,13 @@ found: switch (Quantum) { case 2: /* ISA_200S */ case 3: /* ISA_250MG */ - base = readb(bios_mem + 0x1fa2) + (readb(bios_mem + 0x1fa3) << 8); + base = isa_readb(bios_base + 0x1fa2) + (isa_readb(bios_base + 0x1fa3) << 8); break; case 4: /* ISA_200S (another one) */ - base = readb(bios_mem + 0x1fa3) + (readb(bios_mem + 0x1fa4) << 8); + base = isa_readb(bios_base + 0x1fa3) + (isa_readb(bios_base + 0x1fa4) << 8); break; default: - base = readb(bios_mem + 0x1fcc) + (readb(bios_mem + 0x1fcd) << 8); + base = isa_readb(bios_base + 0x1fcc) + (isa_readb(bios_base + 0x1fcd) << 8); break; } @@ -904,6 +910,20 @@ struct Scsi_Host *__fdomain_16x0_detect(struct scsi_host_template *tpnt ) } } + SCSI_Mode_Cntl_port = port_base + SCSI_Mode_Cntl; + FIFO_Data_Count_port = port_base + FIFO_Data_Count; + Interrupt_Cntl_port = port_base + Interrupt_Cntl; + Interrupt_Status_port = port_base + Interrupt_Status; + Read_FIFO_port = port_base + Read_FIFO; + Read_SCSI_Data_port = port_base + Read_SCSI_Data; + SCSI_Cntl_port = port_base + SCSI_Cntl; + SCSI_Data_NoACK_port = port_base + SCSI_Data_NoACK; + SCSI_Status_port = port_base + SCSI_Status; + TMC_Cntl_port = port_base + TMC_Cntl; + TMC_Status_port = port_base + TMC_Status; + Write_FIFO_port = port_base + Write_FIFO; + Write_SCSI_Data_port = port_base + Write_SCSI_Data; + fdomain_16x0_bus_reset(NULL); if (fdomain_test_loopback()) { @@ -1012,13 +1032,13 @@ static int fdomain_arbitrate( void ) printk( "fdomain_arbitrate()\n" ); #endif - outb(0x00, port_base + SCSI_Cntl); /* Disable data drivers */ - outb(adapter_mask, port_base + SCSI_Data_NoACK); /* Set our id bit */ - outb(0x04 | PARITY_MASK, port_base + TMC_Cntl); /* Start arbitration */ + outb( 0x00, SCSI_Cntl_port ); /* Disable data drivers */ + outb( adapter_mask, port_base + SCSI_Data_NoACK ); /* Set our id bit */ + outb( 0x04 | PARITY_MASK, TMC_Cntl_port ); /* Start arbitration */ timeout = 500; do { - status = inb(port_base + TMC_Status); /* Read adapter status */ + status = inb( TMC_Status_port ); /* Read adapter status */ if (status & 0x02) /* Arbitration complete */ return 0; mdelay(1); /* Wait one millisecond */ @@ -1045,19 +1065,19 @@ static int fdomain_select( int target ) static int flag = 0; #endif - outb(0x82, port_base + SCSI_Cntl); /* Bus Enable + Select */ - outb(adapter_mask | (1 << target), port_base + SCSI_Data_NoACK); + outb( 0x82, SCSI_Cntl_port ); /* Bus Enable + Select */ + outb( adapter_mask | (1 << target), SCSI_Data_NoACK_port ); /* Stop arbitration and enable parity */ - outb(PARITY_MASK, port_base + TMC_Cntl); + outb( PARITY_MASK, TMC_Cntl_port ); timeout = 350; /* 350 msec */ do { - status = inb(port_base + SCSI_Status); /* Read adapter status */ + status = inb( SCSI_Status_port ); /* Read adapter status */ if (status & 1) { /* Busy asserted */ /* Enable SCSI Bus (on error, should make bus idle with 0) */ - outb(0x80, port_base + SCSI_Cntl); + outb( 0x80, SCSI_Cntl_port ); return 0; } mdelay(1); /* wait one msec */ @@ -1082,7 +1102,7 @@ static void my_done(int error) { if (in_command) { in_command = 0; - outb(0x00, port_base + Interrupt_Cntl); + outb( 0x00, Interrupt_Cntl_port ); fdomain_make_bus_idle(); current_SC->result = error; if (current_SC->scsi_done) @@ -1111,11 +1131,11 @@ static irqreturn_t do_fdomain_16x0_intr(int irq, void *dev_id, running. */ /* Check for other IRQ sources */ - if ((inb(port_base + TMC_Status) & 0x01) == 0) + if((inb(TMC_Status_port)&0x01)==0) return IRQ_NONE; /* It is our IRQ */ - outb(0x00, port_base + Interrupt_Cntl); + outb( 0x00, Interrupt_Cntl_port ); /* We usually have one spurious interrupt after each command. Ignore it. */ if (!in_command || !current_SC) { /* Spurious interrupt */ @@ -1140,7 +1160,7 @@ static irqreturn_t do_fdomain_16x0_intr(int irq, void *dev_id, #endif if (current_SC->SCp.phase & in_arbitration) { - status = inb(port_base + TMC_Status); /* Read adapter status */ + status = inb( TMC_Status_port ); /* Read adapter status */ if (!(status & 0x02)) { #if EVERY_ACCESS printk( " AFAIL " ); @@ -1152,19 +1172,19 @@ static irqreturn_t do_fdomain_16x0_intr(int irq, void *dev_id, } current_SC->SCp.phase = in_selection; - outb(0x40 | FIFO_COUNT, port_base + Interrupt_Cntl); + outb( 0x40 | FIFO_COUNT, Interrupt_Cntl_port ); - outb(0x82, port_base + SCSI_Cntl); /* Bus Enable + Select */ - outb(adapter_mask | (1 << current_SC->device->id), port_base + SCSI_Data_NoACK); + outb( 0x82, SCSI_Cntl_port ); /* Bus Enable + Select */ + outb( adapter_mask | (1 << current_SC->device->id), SCSI_Data_NoACK_port ); /* Stop arbitration and enable parity */ - outb(0x10 | PARITY_MASK, port_base + TMC_Cntl); + outb( 0x10 | PARITY_MASK, TMC_Cntl_port ); #if DEBUG_RACE in_interrupt_flag = 0; #endif return IRQ_HANDLED; } else if (current_SC->SCp.phase & in_selection) { - status = inb(port_base + SCSI_Status); + status = inb( SCSI_Status_port ); if (!(status & 0x01)) { /* Try again, for slow devices */ if (fdomain_select( current_SC->device->id )) { @@ -1180,12 +1200,12 @@ static irqreturn_t do_fdomain_16x0_intr(int irq, void *dev_id, printk( " AltSel " ); #endif /* Stop arbitration and enable parity */ - outb(0x10 | PARITY_MASK, port_base + TMC_Cntl); + outb( 0x10 | PARITY_MASK, TMC_Cntl_port ); } } current_SC->SCp.phase = in_other; - outb(0x90 | FIFO_COUNT, port_base + Interrupt_Cntl); - outb(0x80, port_base + SCSI_Cntl); + outb( 0x90 | FIFO_COUNT, Interrupt_Cntl_port ); + outb( 0x80, SCSI_Cntl_port ); #if DEBUG_RACE in_interrupt_flag = 0; #endif @@ -1194,15 +1214,15 @@ static irqreturn_t do_fdomain_16x0_intr(int irq, void *dev_id, /* current_SC->SCp.phase == in_other: this is the body of the routine */ - status = inb(port_base + SCSI_Status); + status = inb( SCSI_Status_port ); if (status & 0x10) { /* REQ */ switch (status & 0x0e) { case 0x08: /* COMMAND OUT */ - outb(current_SC->cmnd[current_SC->SCp.sent_command++], - port_base + Write_SCSI_Data); + outb( current_SC->cmnd[current_SC->SCp.sent_command++], + Write_SCSI_Data_port ); #if EVERY_ACCESS printk( "CMD = %x,", current_SC->cmnd[ current_SC->SCp.sent_command - 1] ); @@ -1211,17 +1231,17 @@ static irqreturn_t do_fdomain_16x0_intr(int irq, void *dev_id, case 0x00: /* DATA OUT -- tmc18c50/tmc18c30 only */ if (chip != tmc1800 && !current_SC->SCp.have_data_in) { current_SC->SCp.have_data_in = -1; - outb(0xd0 | PARITY_MASK, port_base + TMC_Cntl); + outb( 0xd0 | PARITY_MASK, TMC_Cntl_port ); } break; case 0x04: /* DATA IN -- tmc18c50/tmc18c30 only */ if (chip != tmc1800 && !current_SC->SCp.have_data_in) { current_SC->SCp.have_data_in = 1; - outb(0x90 | PARITY_MASK, port_base + TMC_Cntl); + outb( 0x90 | PARITY_MASK, TMC_Cntl_port ); } break; case 0x0c: /* STATUS IN */ - current_SC->SCp.Status = inb(port_base + Read_SCSI_Data); + current_SC->SCp.Status = inb( Read_SCSI_Data_port ); #if EVERY_ACCESS printk( "Status = %x, ", current_SC->SCp.Status ); #endif @@ -1237,10 +1257,10 @@ static irqreturn_t do_fdomain_16x0_intr(int irq, void *dev_id, #endif break; case 0x0a: /* MESSAGE OUT */ - outb(MESSAGE_REJECT, port_base + Write_SCSI_Data); /* Reject */ + outb( MESSAGE_REJECT, Write_SCSI_Data_port ); /* Reject */ break; case 0x0e: /* MESSAGE IN */ - current_SC->SCp.Message = inb(port_base + Read_SCSI_Data); + current_SC->SCp.Message = inb( Read_SCSI_Data_port ); #if EVERY_ACCESS printk( "Message = %x, ", current_SC->SCp.Message ); #endif @@ -1261,17 +1281,17 @@ static irqreturn_t do_fdomain_16x0_intr(int irq, void *dev_id, if(current_SC->sc_data_direction == DMA_TO_DEVICE) { current_SC->SCp.have_data_in = -1; - outb(0xd0 | PARITY_MASK, port_base + TMC_Cntl); + outb( 0xd0 | PARITY_MASK, TMC_Cntl_port ); } else { current_SC->SCp.have_data_in = 1; - outb(0x90 | PARITY_MASK, port_base + TMC_Cntl); + outb( 0x90 | PARITY_MASK, TMC_Cntl_port ); } } if (current_SC->SCp.have_data_in == -1) { /* DATA OUT */ - while ((data_count = FIFO_Size - inw(port_base + FIFO_Data_Count)) > 512) { + while ( (data_count = FIFO_Size - inw( FIFO_Data_Count_port )) > 512 ) { #if EVERY_ACCESS printk( "DC=%d, ", data_count ) ; #endif @@ -1282,11 +1302,11 @@ static irqreturn_t do_fdomain_16x0_intr(int irq, void *dev_id, printk( "%d OUT, ", data_count ); #endif if (data_count == 1) { - outb(*current_SC->SCp.ptr++, port_base + Write_FIFO); + outb( *current_SC->SCp.ptr++, Write_FIFO_port ); --current_SC->SCp.this_residual; } else { data_count >>= 1; - outsw(port_base + Write_FIFO, current_SC->SCp.ptr, data_count); + outsw( Write_FIFO_port, current_SC->SCp.ptr, data_count ); current_SC->SCp.ptr += 2 * data_count; current_SC->SCp.this_residual -= 2 * data_count; } @@ -1304,7 +1324,7 @@ static irqreturn_t do_fdomain_16x0_intr(int irq, void *dev_id, } if (current_SC->SCp.have_data_in == 1) { /* DATA IN */ - while ((data_count = inw(port_base + FIFO_Data_Count)) > 0) { + while ((data_count = inw( FIFO_Data_Count_port )) > 0) { #if EVERY_ACCESS printk( "DC=%d, ", data_count ); #endif @@ -1315,11 +1335,11 @@ static irqreturn_t do_fdomain_16x0_intr(int irq, void *dev_id, printk( "%d IN, ", data_count ); #endif if (data_count == 1) { - *current_SC->SCp.ptr++ = inb(port_base + Read_FIFO); + *current_SC->SCp.ptr++ = inb( Read_FIFO_port ); --current_SC->SCp.this_residual; } else { data_count >>= 1; /* Number of words */ - insw(port_base + Read_FIFO, current_SC->SCp.ptr, data_count); + insw( Read_FIFO_port, current_SC->SCp.ptr, data_count ); current_SC->SCp.ptr += 2 * data_count; current_SC->SCp.this_residual -= 2 * data_count; } @@ -1379,10 +1399,10 @@ static irqreturn_t do_fdomain_16x0_intr(int irq, void *dev_id, } else { if (current_SC->SCp.phase & disconnect) { - outb(0xd0 | FIFO_COUNT, port_base + Interrupt_Cntl); - outb(0x00, port_base + SCSI_Cntl); + outb( 0xd0 | FIFO_COUNT, Interrupt_Cntl_port ); + outb( 0x00, SCSI_Cntl_port ); } else { - outb(0x90 | FIFO_COUNT, port_base + Interrupt_Cntl); + outb( 0x90 | FIFO_COUNT, Interrupt_Cntl_port ); } } #if DEBUG_RACE @@ -1433,12 +1453,12 @@ static int fdomain_16x0_queue(struct scsi_cmnd *SCpnt, current_SC->SCp.phase = in_arbitration; /* Start arbitration */ - outb(0x00, port_base + Interrupt_Cntl); - outb(0x00, port_base + SCSI_Cntl); /* Disable data drivers */ - outb(adapter_mask, port_base + SCSI_Data_NoACK); /* Set our id bit */ + outb( 0x00, Interrupt_Cntl_port ); + outb( 0x00, SCSI_Cntl_port ); /* Disable data drivers */ + outb( adapter_mask, SCSI_Data_NoACK_port ); /* Set our id bit */ ++in_command; - outb(0x20, port_base + Interrupt_Cntl); - outb(0x14 | PARITY_MASK, port_base + TMC_Cntl); /* Start arbitration */ + outb( 0x20, Interrupt_Cntl_port ); + outb( 0x14 | PARITY_MASK, TMC_Cntl_port ); /* Start arbitration */ return 0; } @@ -1494,17 +1514,17 @@ static void print_info(struct scsi_cmnd *SCpnt) printk( " (masked)" ); printk( ", IRR = 0x%04x, ISR = 0x%04x\n", irr, isr ); - printk( "SCSI Status = 0x%02x\n", inb(port_base + SCSI_Status)); - printk( "TMC Status = 0x%02x", inb(port_base + TMC_Status)); - if (inb((port_base + TMC_Status) & 1)) + printk( "SCSI Status = 0x%02x\n", inb( SCSI_Status_port ) ); + printk( "TMC Status = 0x%02x", inb( TMC_Status_port ) ); + if (inb( TMC_Status_port & 1)) printk( " (interrupt)" ); printk( "\n" ); - printk("Interrupt Status = 0x%02x", inb(port_base + Interrupt_Status)); - if (inb(port_base + Interrupt_Status) & 0x08) + printk( "Interrupt Status = 0x%02x", inb( Interrupt_Status_port ) ); + if (inb( Interrupt_Status_port ) & 0x08) printk( " (enabled)" ); printk( "\n" ); if (chip == tmc18c50 || chip == tmc18c30) { - printk("FIFO Status = 0x%02x\n", inb(port_base + FIFO_Status)); + printk( "FIFO Status = 0x%02x\n", inb( port_base + FIFO_Status ) ); printk( "Int. Condition = 0x%02x\n", inb( port_base + Interrupt_Cond ) ); } @@ -1543,12 +1563,12 @@ static int fdomain_16x0_abort(struct scsi_cmnd *SCpnt) int fdomain_16x0_bus_reset(struct scsi_cmnd *SCpnt) { - outb(1, port_base + SCSI_Cntl); + outb( 1, SCSI_Cntl_port ); do_pause( 2 ); - outb(0, port_base + SCSI_Cntl); + outb( 0, SCSI_Cntl_port ); do_pause( 115 ); - outb(0, port_base + SCSI_Mode_Cntl); - outb(PARITY_MASK, port_base + TMC_Cntl); + outb( 0, SCSI_Mode_Cntl_port ); + outb( PARITY_MASK, TMC_Cntl_port ); return SUCCESS; } @@ -1619,26 +1639,26 @@ static int fdomain_16x0_biosparam(struct scsi_device *sdev, case 2: /* ISA_200S */ /* The value of 25 has never been verified. It should probably be 15. */ - offset = 0x1f33 + drive * 25; + offset = bios_base + 0x1f33 + drive * 25; break; case 3: /* ISA_250MG */ - offset = 0x1f36 + drive * 15; + offset = bios_base + 0x1f36 + drive * 15; break; case 4: /* ISA_200S (another one) */ - offset = 0x1f34 + drive * 15; + offset = bios_base + 0x1f34 + drive * 15; break; default: - offset = 0x1f31 + drive * 25; + offset = bios_base + 0x1f31 + drive * 25; break; } - memcpy_fromio( &i, bios_mem + offset, sizeof( struct drive_info ) ); + isa_memcpy_fromio( &i, offset, sizeof( struct drive_info ) ); info_array[0] = i.heads; info_array[1] = i.sectors; info_array[2] = i.cylinders; } else if (bios_major == 3 && bios_minor >= 0 && bios_minor < 4) { /* 3.0 and 3.2 BIOS */ - memcpy_fromio( &i, bios_mem + 0x1f71 + drive * 10, + memcpy_fromio( &i, bios_base + 0x1f71 + drive * 10, sizeof( struct drive_info ) ); info_array[0] = i.heads + 1; info_array[1] = i.sectors;