fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / drivers / scsi / t128.c
index 7e73fc2..0b7a70f 100644 (file)
 #include <asm/system.h>
 #include <linux/signal.h>
 #include <linux/sched.h>
-#include <asm/io.h>
+#include <linux/io.h>
 #include <linux/blkdev.h>
 #include <linux/interrupt.h>
 #include <linux/stat.h>
 static struct override {
     unsigned long address;
     int irq;
-} overrides 
+} overrides
 #ifdef T128_OVERRIDE
     [] __initdata = T128_OVERRIDE;
 #else
-    [4] __initdata = {{0, IRQ_AUTO}, {0, IRQ_AUTO}, 
+    [4] __initdata = {{0, IRQ_AUTO}, {0, IRQ_AUTO},
         {0 ,IRQ_AUTO}, {0, IRQ_AUTO}};
 #endif
 
-#define NO_OVERRIDES (sizeof(overrides) / sizeof(struct override))
+#define NO_OVERRIDES ARRAY_SIZE(overrides)
 
 static struct base {
     unsigned int address;
@@ -143,7 +143,7 @@ static struct base {
     { 0xcc000, 0}, { 0xc8000, 0}, { 0xdc000, 0}, { 0xd8000, 0}
 };
 
-#define NO_BASES (sizeof (bases) / sizeof (struct base))
+#define NO_BASES ARRAY_SIZE(bases)
 
 static struct signature {
     const char *string;
@@ -152,7 +152,7 @@ static struct signature {
 {"TSROM: SCSI BIOS, Version 1.12", 0x36},
 };
 
-#define NO_SIGNATURES (sizeof (signatures) /  sizeof (struct signature))
+#define NO_SIGNATURES ARRAY_SIZE(signatures)
 
 /*
  * Function : t128_setup(char *str, int *ints)
@@ -183,7 +183,7 @@ void __init t128_setup(char *str, int *ints){
 }
 
 /* 
- * Function : int t128_detect(Scsi_Host_Template * tpnt)
+ * Function : int t128_detect(struct scsi_host_template * tpnt)
  *
  * Purpose : detects and initializes T128,T128F, or T228 controllers
  *     that were autoprobed, overridden on the LILO command line, 
@@ -195,10 +195,11 @@ void __init t128_setup(char *str, int *ints){
  *
  */
 
-int __init t128_detect(Scsi_Host_Template * tpnt){
+int __init t128_detect(struct scsi_host_template * tpnt){
     static int current_override = 0, current_base = 0;
     struct Scsi_Host *instance;
     unsigned long base;
+    void __iomem *p;
     int sig, count;
 
     tpnt->proc_name = "t128";
@@ -206,26 +207,34 @@ int __init t128_detect(Scsi_Host_Template * tpnt){
 
     for (count = 0; current_override < NO_OVERRIDES; ++current_override) {
        base = 0;
+       p = NULL;
 
-       if (overrides[current_override].address)
+       if (overrides[current_override].address) {
            base = overrides[current_override].address;
-       else 
+           p = ioremap(bases[current_base].address, 0x2000);
+           if (!p)
+               base = 0;
+       } else 
            for (; !base && (current_base < NO_BASES); ++current_base) {
 #if (TDEBUG & TDEBUG_INIT)
     printk("scsi-t128 : probing address %08x\n", bases[current_base].address);
 #endif
+               if (bases[current_base].noauto)
+                       continue;
+               p = ioremap(bases[current_base].address, 0x2000);
+               if (!p)
+                       continue;
                for (sig = 0; sig < NO_SIGNATURES; ++sig) 
-                   if (!bases[current_base].noauto && 
-                       isa_check_signature(bases[current_base].address +
-                                       signatures[sig].offset,
+                   if (check_signature(p + signatures[sig].offset,
                                        signatures[sig].string,
                                        strlen(signatures[sig].string))) {
                        base = bases[current_base].address;
 #if (TDEBUG & TDEBUG_INIT)
                        printk("scsi-t128 : detected board.\n");
 #endif
-                       break;
+                       goto found;
                    }
+               iounmap(p);
            }
 
 #if defined(TDEBUG) && (TDEBUG & TDEBUG_INIT)
@@ -235,11 +244,13 @@ int __init t128_detect(Scsi_Host_Template * tpnt){
        if (!base)
            break;
 
+found:
        instance = scsi_register (tpnt, sizeof(struct NCR5380_hostdata));
        if(instance == NULL)
                break;
                
        instance->base = base;
+       ((struct NCR5380_hostdata *)instance->hostdata)->base = p;
 
        NCR5380_init(instance, 0);
 
@@ -249,7 +260,7 @@ int __init t128_detect(Scsi_Host_Template * tpnt){
            instance->irq = NCR5380_probe_irq(instance, T128_IRQS);
 
        if (instance->irq != SCSI_IRQ_NONE) 
-           if (request_irq(instance->irq, t128_intr, SA_INTERRUPT, "t128", instance)) {
+           if (request_irq(instance->irq, t128_intr, IRQF_DISABLED, "t128", instance)) {
                printk("scsi%d : IRQ%d not free, interrupts disabled\n", 
                    instance->host_no, instance->irq);
                instance->irq = SCSI_IRQ_NONE;
@@ -282,12 +293,15 @@ int __init t128_detect(Scsi_Host_Template * tpnt){
 
 static int t128_release(struct Scsi_Host *shost)
 {
+       NCR5380_local_declare();
+       NCR5380_setup(shost);
        if (shost->irq)
                free_irq(shost->irq, NULL);
        NCR5380_exit(shost);
        if (shost->io_port && shost->n_io_port)
                release_region(shost->io_port, shost->n_io_port);
        scsi_unregister(shost);
+       iounmap(base);
        return 0;
 }
 
@@ -335,28 +349,30 @@ int t128_biosparam(struct scsi_device *sdev, struct block_device *bdev,
 
 static inline int NCR5380_pread (struct Scsi_Host *instance, unsigned char *dst,
     int len) {
-    unsigned long reg = instance->base + T_DATA_REG_OFFSET;
+    NCR5380_local_declare();
+    void __iomem *reg;
     unsigned char *d = dst;
     register int i = len;
 
+    NCR5380_setup(instance);
+    reg = base + T_DATA_REG_OFFSET;
 
 #if 0
     for (; i; --i) {
-       while (!(isa_readb(instance->base+T_STATUS_REG_OFFSET) & T_ST_RDY)) barrier();
+       while (!(readb(base+T_STATUS_REG_OFFSET) & T_ST_RDY)) barrier();
 #else
-    while (!(isa_readb(instance->base+T_STATUS_REG_OFFSET) & T_ST_RDY)) barrier();
+    while (!(readb(base+T_STATUS_REG_OFFSET) & T_ST_RDY)) barrier();
     for (; i; --i) {
 #endif
-       *d++ = isa_readb(reg);
+       *d++ = readb(reg);
     }
 
-    if (isa_readb(instance->base + T_STATUS_REG_OFFSET) & T_ST_TIM) {
+    if (readb(base + T_STATUS_REG_OFFSET) & T_ST_TIM) {
        unsigned char tmp;
-       unsigned long foo;
-       foo = instance->base + T_CONTROL_REG_OFFSET;
-       tmp = isa_readb(foo);
-       isa_writeb(tmp | T_CR_CT, foo);
-       isa_writeb(tmp, foo);
+       void __iomem *foo = base + T_CONTROL_REG_OFFSET;
+       tmp = readb(foo);
+       writeb(tmp | T_CR_CT, foo);
+       writeb(tmp, foo);
        printk("scsi%d : watchdog timer fired in NCR5380_pread()\n",
            instance->host_no);
        return -1;
@@ -379,27 +395,30 @@ static inline int NCR5380_pread (struct Scsi_Host *instance, unsigned char *dst,
 
 static inline int NCR5380_pwrite (struct Scsi_Host *instance, unsigned char *src,
     int len) {
-    unsigned long reg = instance->base + T_DATA_REG_OFFSET;
+    NCR5380_local_declare();
+    void __iomem *reg;
     unsigned char *s = src;
     register int i = len;
 
+    NCR5380_setup(instance);
+    reg = base + T_DATA_REG_OFFSET;
+
 #if 0
     for (; i; --i) {
-       while (!(isa_readb(instance->base+T_STATUS_REG_OFFSET) & T_ST_RDY)) barrier();
+       while (!(readb(base+T_STATUS_REG_OFFSET) & T_ST_RDY)) barrier();
 #else
-    while (!(isa_readb(instance->base+T_STATUS_REG_OFFSET) & T_ST_RDY)) barrier();
+    while (!(readb(base+T_STATUS_REG_OFFSET) & T_ST_RDY)) barrier();
     for (; i; --i) {
 #endif
-       isa_writeb(*s++, reg);
+       writeb(*s++, reg);
     }
 
-    if (isa_readb(instance->base + T_STATUS_REG_OFFSET) & T_ST_TIM) {
+    if (readb(base + T_STATUS_REG_OFFSET) & T_ST_TIM) {
        unsigned char tmp;
-       unsigned long foo;
-       foo = instance->base + T_CONTROL_REG_OFFSET;
-       tmp = isa_readb(foo);
-       isa_writeb(tmp | T_CR_CT, foo);
-       isa_writeb(tmp, foo);
+       void __iomem *foo = base + T_CONTROL_REG_OFFSET;
+       tmp = readb(foo);
+       writeb(tmp | T_CR_CT, foo);
+       writeb(tmp, foo);
        printk("scsi%d : watchdog timer fired in NCR5380_pwrite()\n",
            instance->host_no);
        return -1;
@@ -411,15 +430,13 @@ MODULE_LICENSE("GPL");
 
 #include "NCR5380.c"
 
-static Scsi_Host_Template driver_template = {
+static struct scsi_host_template driver_template = {
        .name           = "Trantor T128/T128F/T228",
        .detect         = t128_detect,
        .release        = t128_release,
        .queuecommand   = t128_queue_command,
        .eh_abort_handler = t128_abort,
        .eh_bus_reset_handler    = t128_bus_reset,
-       .eh_host_reset_handler   = t128_host_reset,
-       .eh_device_reset_handler = t128_device_reset,
        .bios_param     = t128_biosparam,
        .can_queue      = CAN_QUEUE,
         .this_id        = 7,