[ARM] rpc: update Acorn SCSI drivers to modern ecard interfaces

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>

authored by Russell King and committed by Russell King 8b801ead 13d5fadf

+187 -250
+101 -108
drivers/scsi/arm/cumana_1.c
··· 24 25 #define CUMANASCSI_PUBLIC_RELEASE 1 26 27 - #define NCR5380_implementation_fields int port, ctrl 28 #define NCR5380_local_declare() struct Scsi_Host *_instance 29 #define NCR5380_setup(instance) _instance = instance 30 #define NCR5380_read(reg) cumanascsi_read(_instance, reg) ··· 32 #define NCR5380_intr cumanascsi_intr 33 #define NCR5380_queue_command cumanascsi_queue_command 34 #define NCR5380_proc_info cumanascsi_proc_info 35 36 #define BOARD_NORMAL 0 37 #define BOARD_NCR53C400 1 ··· 52 return ""; 53 } 54 55 - #ifdef NOT_EFFICIENT 56 - #define CTRL(p,v) outb(*ctrl = (v), (p) - 577) 57 - #define STAT(p) inb((p)+1) 58 - #define IN(p) inb((p)) 59 - #define OUT(v,p) outb((v), (p)) 60 - #else 61 - #define CTRL(p,v) (p[-2308] = (*ctrl = (v))) 62 - #define STAT(p) (p[4]) 63 - #define IN(p) (*(p)) 64 - #define IN2(p) ((unsigned short)(*(volatile unsigned long *)(p))) 65 - #define OUT(v,p) (*(p) = (v)) 66 - #define OUT2(v,p) (*((volatile unsigned long *)(p)) = (v)) 67 - #endif 68 - #define L(v) (((v)<<16)|((v) & 0x0000ffff)) 69 - #define H(v) (((v)>>16)|((v) & 0xffff0000)) 70 71 static inline int 72 - NCR5380_pwrite(struct Scsi_Host *instance, unsigned char *addr, int len) 73 { 74 - int *ctrl = &((struct NCR5380_hostdata *)instance->hostdata)->ctrl; 75 - int oldctrl = *ctrl; 76 unsigned long *laddr; 77 - #ifdef NOT_EFFICIENT 78 - int iobase = instance->io_port; 79 - int dma_io = iobase & ~(0x3C0000>>2); 80 - #else 81 - volatile unsigned char *iobase = (unsigned char *)ioaddr(instance->io_port); 82 - volatile unsigned char *dma_io = (unsigned char *)((int)iobase & ~0x3C0000); 83 - #endif 84 85 if(!len) return 0; 86 87 - CTRL(iobase, 0x02); 88 laddr = (unsigned long *)addr; 89 while(len >= 32) 90 { 91 - int status; 92 unsigned long v; 93 - status = STAT(iobase); 94 if(status & 0x80) 95 goto end; 96 if(!(status & 0x40)) 97 continue; 98 - v=*laddr++; OUT2(L(v),dma_io); OUT2(H(v),dma_io); 99 - v=*laddr++; OUT2(L(v),dma_io); OUT2(H(v),dma_io); 100 - v=*laddr++; OUT2(L(v),dma_io); OUT2(H(v),dma_io); 101 - v=*laddr++; OUT2(L(v),dma_io); OUT2(H(v),dma_io); 102 - v=*laddr++; OUT2(L(v),dma_io); OUT2(H(v),dma_io); 103 - v=*laddr++; OUT2(L(v),dma_io); OUT2(H(v),dma_io); 104 - v=*laddr++; OUT2(L(v),dma_io); OUT2(H(v),dma_io); 105 - v=*laddr++; OUT2(L(v),dma_io); OUT2(H(v),dma_io); 106 len -= 32; 107 if(len == 0) 108 break; 109 } 110 111 addr = (unsigned char *)laddr; 112 - CTRL(iobase, 0x12); 113 while(len > 0) 114 { 115 - int status; 116 - status = STAT(iobase); 117 if(status & 0x80) 118 goto end; 119 if(status & 0x40) 120 { 121 - OUT(*addr++, dma_io); 122 if(--len == 0) 123 break; 124 } 125 126 - status = STAT(iobase); 127 if(status & 0x80) 128 goto end; 129 if(status & 0x40) 130 { 131 - OUT(*addr++, dma_io); 132 if(--len == 0) 133 break; 134 } 135 } 136 end: 137 - CTRL(iobase, oldctrl|0x40); 138 return len; 139 } 140 141 static inline int 142 - NCR5380_pread(struct Scsi_Host *instance, unsigned char *addr, int len) 143 { 144 - int *ctrl = &((struct NCR5380_hostdata *)instance->hostdata)->ctrl; 145 - int oldctrl = *ctrl; 146 unsigned long *laddr; 147 - #ifdef NOT_EFFICIENT 148 - int iobase = instance->io_port; 149 - int dma_io = iobase & ~(0x3C0000>>2); 150 - #else 151 - volatile unsigned char *iobase = (unsigned char *)ioaddr(instance->io_port); 152 - volatile unsigned char *dma_io = (unsigned char *)((int)iobase & ~0x3C0000); 153 - #endif 154 155 if(!len) return 0; 156 157 - CTRL(iobase, 0x00); 158 laddr = (unsigned long *)addr; 159 while(len >= 32) 160 { 161 - int status; 162 - status = STAT(iobase); 163 if(status & 0x80) 164 goto end; 165 if(!(status & 0x40)) 166 continue; 167 - *laddr++ = IN2(dma_io)|(IN2(dma_io)<<16); 168 - *laddr++ = IN2(dma_io)|(IN2(dma_io)<<16); 169 - *laddr++ = IN2(dma_io)|(IN2(dma_io)<<16); 170 - *laddr++ = IN2(dma_io)|(IN2(dma_io)<<16); 171 - *laddr++ = IN2(dma_io)|(IN2(dma_io)<<16); 172 - *laddr++ = IN2(dma_io)|(IN2(dma_io)<<16); 173 - *laddr++ = IN2(dma_io)|(IN2(dma_io)<<16); 174 - *laddr++ = IN2(dma_io)|(IN2(dma_io)<<16); 175 len -= 32; 176 if(len == 0) 177 break; 178 } 179 180 addr = (unsigned char *)laddr; 181 - CTRL(iobase, 0x10); 182 while(len > 0) 183 { 184 - int status; 185 - status = STAT(iobase); 186 if(status & 0x80) 187 goto end; 188 if(status & 0x40) 189 { 190 - *addr++ = IN(dma_io); 191 if(--len == 0) 192 break; 193 } 194 195 - status = STAT(iobase); 196 if(status & 0x80) 197 goto end; 198 if(status & 0x40) 199 { 200 - *addr++ = IN(dma_io); 201 if(--len == 0) 202 break; 203 } 204 } 205 end: 206 - CTRL(iobase, oldctrl|0x40); 207 return len; 208 } 209 210 - #undef STAT 211 - #undef CTRL 212 - #undef IN 213 - #undef OUT 214 - 215 - #define CTRL(p,v) outb(*ctrl = (v), (p) - 577) 216 - 217 - static char cumanascsi_read(struct Scsi_Host *instance, int reg) 218 { 219 - unsigned int iobase = instance->io_port; 220 - int i; 221 - int *ctrl = &((struct NCR5380_hostdata *)instance->hostdata)->ctrl; 222 223 - CTRL(iobase, 0); 224 - i = inb(iobase + 64 + reg); 225 - CTRL(iobase, 0x40); 226 227 - return i; 228 } 229 230 - static void cumanascsi_write(struct Scsi_Host *instance, int reg, int value) 231 { 232 - int iobase = instance->io_port; 233 - int *ctrl = &((struct NCR5380_hostdata *)instance->hostdata)->ctrl; 234 235 - CTRL(iobase, 0); 236 - outb(value, iobase + 64 + reg); 237 - CTRL(iobase, 0x40); 238 } 239 - 240 - #undef CTRL 241 242 #include "../NCR5380.c" 243 ··· 231 cumanascsi1_probe(struct expansion_card *ec, const struct ecard_id *id) 232 { 233 struct Scsi_Host *host; 234 - int ret = -ENOMEM; 235 236 - host = scsi_host_alloc(&cumanascsi_template, sizeof(struct NCR5380_hostdata)); 237 - if (!host) 238 goto out; 239 240 - host->io_port = ecard_address(ec, ECARD_IOC, ECARD_SLOW) + 0x800; 241 host->irq = ec->irq; 242 243 NCR5380_init(host, 0); 244 245 host->n_io_port = 255; 246 if (!(request_region(host->io_port, host->n_io_port, "CumanaSCSI-1"))) { 247 ret = -EBUSY; 248 - goto out_free; 249 } 250 - 251 - ((struct NCR5380_hostdata *)host->hostdata)->ctrl = 0; 252 - outb(0x00, host->io_port - 577); 253 254 ret = request_irq(host->irq, cumanascsi_intr, IRQF_DISABLED, 255 "CumanaSCSI-1", host); 256 if (ret) { 257 printk("scsi%d: IRQ%d not free: %d\n", 258 host->host_no, host->irq, ret); 259 - goto out_release; 260 } 261 262 printk("scsi%d: at port 0x%08lx irq %d", ··· 290 291 out_free_irq: 292 free_irq(host->irq, host); 293 - out_release: 294 - release_region(host->io_port, host->n_io_port); 295 - out_free: 296 scsi_host_put(host); 297 out: 298 return ret; 299 } ··· 309 scsi_remove_host(host); 310 free_irq(host->irq, host); 311 NCR5380_exit(host); 312 - release_region(host->io_port, host->n_io_port); 313 scsi_host_put(host); 314 } 315 316 static const struct ecard_id cumanascsi1_cids[] = {
··· 24 25 #define CUMANASCSI_PUBLIC_RELEASE 1 26 27 + #define priv(host) ((struct NCR5380_hostdata *)(host)->hostdata) 28 #define NCR5380_local_declare() struct Scsi_Host *_instance 29 #define NCR5380_setup(instance) _instance = instance 30 #define NCR5380_read(reg) cumanascsi_read(_instance, reg) ··· 32 #define NCR5380_intr cumanascsi_intr 33 #define NCR5380_queue_command cumanascsi_queue_command 34 #define NCR5380_proc_info cumanascsi_proc_info 35 + 36 + #define NCR5380_implementation_fields \ 37 + unsigned ctrl; \ 38 + void __iomem *base; \ 39 + void __iomem *dma 40 41 #define BOARD_NORMAL 0 42 #define BOARD_NCR53C400 1 ··· 47 return ""; 48 } 49 50 + #define CTRL 0x16fc 51 + #define STAT 0x2004 52 + #define L(v) (((v)<<16)|((v) & 0x0000ffff)) 53 + #define H(v) (((v)>>16)|((v) & 0xffff0000)) 54 55 static inline int 56 + NCR5380_pwrite(struct Scsi_Host *host, unsigned char *addr, int len) 57 { 58 unsigned long *laddr; 59 + void __iomem *dma = priv(host)->dma + 0x2000; 60 61 if(!len) return 0; 62 63 + writeb(0x02, priv(host)->base + CTRL); 64 laddr = (unsigned long *)addr; 65 while(len >= 32) 66 { 67 + unsigned int status; 68 unsigned long v; 69 + status = readb(priv(host)->base + STAT); 70 if(status & 0x80) 71 goto end; 72 if(!(status & 0x40)) 73 continue; 74 + v=*laddr++; writew(L(v), dma); writew(H(v), dma); 75 + v=*laddr++; writew(L(v), dma); writew(H(v), dma); 76 + v=*laddr++; writew(L(v), dma); writew(H(v), dma); 77 + v=*laddr++; writew(L(v), dma); writew(H(v), dma); 78 + v=*laddr++; writew(L(v), dma); writew(H(v), dma); 79 + v=*laddr++; writew(L(v), dma); writew(H(v), dma); 80 + v=*laddr++; writew(L(v), dma); writew(H(v), dma); 81 + v=*laddr++; writew(L(v), dma); writew(H(v), dma); 82 len -= 32; 83 if(len == 0) 84 break; 85 } 86 87 addr = (unsigned char *)laddr; 88 + writeb(0x12, priv(host)->base + CTRL); 89 + 90 while(len > 0) 91 { 92 + unsigned int status; 93 + status = readb(priv(host)->base + STAT); 94 if(status & 0x80) 95 goto end; 96 if(status & 0x40) 97 { 98 + writeb(*addr++, dma); 99 if(--len == 0) 100 break; 101 } 102 103 + status = readb(priv(host)->base + STAT); 104 if(status & 0x80) 105 goto end; 106 if(status & 0x40) 107 { 108 + writeb(*addr++, dma); 109 if(--len == 0) 110 break; 111 } 112 } 113 end: 114 + writeb(priv(host)->ctrl | 0x40, priv(host)->base + CTRL); 115 return len; 116 } 117 118 static inline int 119 + NCR5380_pread(struct Scsi_Host *host, unsigned char *addr, int len) 120 { 121 unsigned long *laddr; 122 + void __iomem *dma = priv(host)->dma + 0x2000; 123 124 if(!len) return 0; 125 126 + writeb(0x00, priv(host)->base + CTRL); 127 laddr = (unsigned long *)addr; 128 while(len >= 32) 129 { 130 + unsigned int status; 131 + status = readb(priv(host)->base + STAT); 132 if(status & 0x80) 133 goto end; 134 if(!(status & 0x40)) 135 continue; 136 + *laddr++ = readw(dma) | (readw(dma) << 16); 137 + *laddr++ = readw(dma) | (readw(dma) << 16); 138 + *laddr++ = readw(dma) | (readw(dma) << 16); 139 + *laddr++ = readw(dma) | (readw(dma) << 16); 140 + *laddr++ = readw(dma) | (readw(dma) << 16); 141 + *laddr++ = readw(dma) | (readw(dma) << 16); 142 + *laddr++ = readw(dma) | (readw(dma) << 16); 143 + *laddr++ = readw(dma) | (readw(dma) << 16); 144 len -= 32; 145 if(len == 0) 146 break; 147 } 148 149 addr = (unsigned char *)laddr; 150 + writeb(0x10, priv(host)->base + CTRL); 151 + 152 while(len > 0) 153 { 154 + unsigned int status; 155 + status = readb(priv(host)->base + STAT); 156 if(status & 0x80) 157 goto end; 158 if(status & 0x40) 159 { 160 + *addr++ = readb(dma); 161 if(--len == 0) 162 break; 163 } 164 165 + status = readb(priv(host)->base + STAT); 166 if(status & 0x80) 167 goto end; 168 if(status & 0x40) 169 { 170 + *addr++ = readb(dma); 171 if(--len == 0) 172 break; 173 } 174 } 175 end: 176 + writeb(priv(host)->ctrl | 0x40, priv(host)->base + CTRL); 177 return len; 178 } 179 180 + static unsigned char cumanascsi_read(struct Scsi_Host *host, unsigned int reg) 181 { 182 + void __iomem *base = priv(host)->base; 183 + unsigned char val; 184 185 + writeb(0, base + CTRL); 186 187 + val = readb(base + 0x2100 + (reg << 2)); 188 + 189 + priv(host)->ctrl = 0x40; 190 + writeb(0x40, base + CTRL); 191 + 192 + return val; 193 } 194 195 + static void cumanascsi_write(struct Scsi_Host *host, unsigned int reg, unsigned int value) 196 { 197 + void __iomem *base = priv(host)->base; 198 199 + writeb(0, base + CTRL); 200 + 201 + writeb(value, base + 0x2100 + (reg << 2)); 202 + 203 + priv(host)->ctrl = 0x40; 204 + writeb(0x40, base + CTRL); 205 } 206 207 #include "../NCR5380.c" 208 ··· 256 cumanascsi1_probe(struct expansion_card *ec, const struct ecard_id *id) 257 { 258 struct Scsi_Host *host; 259 + int ret; 260 261 + ret = ecard_request_resources(ec); 262 + if (ret) 263 goto out; 264 265 + host = scsi_host_alloc(&cumanascsi_template, sizeof(struct NCR5380_hostdata)); 266 + if (!host) { 267 + ret = -ENOMEM; 268 + goto out_release; 269 + } 270 + 271 + priv(host)->base = ioremap(ecard_resource_start(ec, ECARD_RES_IOCSLOW), 272 + ecard_resource_len(ec, ECARD_RES_IOCSLOW)); 273 + priv(host)->dma = ioremap(ecard_resource_start(ec, ECARD_RES_MEMC), 274 + ecard_resource_len(ec, ECARD_RES_MEMC)); 275 + if (!priv(host)->base || !priv(host)->dma) { 276 + ret = -ENOMEM; 277 + goto out_unmap; 278 + } 279 + 280 host->irq = ec->irq; 281 282 NCR5380_init(host, 0); 283 284 + priv(host)->ctrl = 0; 285 + writeb(0, priv(host)->base + CTRL); 286 + 287 host->n_io_port = 255; 288 if (!(request_region(host->io_port, host->n_io_port, "CumanaSCSI-1"))) { 289 ret = -EBUSY; 290 + goto out_unmap; 291 } 292 293 ret = request_irq(host->irq, cumanascsi_intr, IRQF_DISABLED, 294 "CumanaSCSI-1", host); 295 if (ret) { 296 printk("scsi%d: IRQ%d not free: %d\n", 297 host->host_no, host->irq, ret); 298 + goto out_unmap; 299 } 300 301 printk("scsi%d: at port 0x%08lx irq %d", ··· 301 302 out_free_irq: 303 free_irq(host->irq, host); 304 + out_unmap: 305 + iounmap(priv(host)->base); 306 + iounmap(priv(host)->dma); 307 scsi_host_put(host); 308 + out_release: 309 + ecard_release_resources(ec); 310 out: 311 return ret; 312 } ··· 318 scsi_remove_host(host); 319 free_irq(host->irq, host); 320 NCR5380_exit(host); 321 + iounmap(priv(host)->base); 322 + iounmap(priv(host)->dma); 323 scsi_host_put(host); 324 + ecard_release_resources(ec); 325 } 326 327 static const struct ecard_id cumanascsi1_cids[] = {
+42 -112
drivers/scsi/arm/ecoscsi.c
··· 34 #include "../scsi.h" 35 #include <scsi/scsi_host.h> 36 37 - #define NCR5380_implementation_fields int port, ctrl 38 - #define NCR5380_local_declare() struct Scsi_Host *_instance 39 - #define NCR5380_setup(instance) _instance = instance 40 41 - #define NCR5380_read(reg) ecoscsi_read(_instance, reg) 42 - #define NCR5380_write(reg, value) ecoscsi_write(_instance, reg, value) 43 44 #define NCR5380_intr ecoscsi_intr 45 #define NCR5380_queue_command ecoscsi_queue_command 46 #define NCR5380_proc_info ecoscsi_proc_info 47 48 #include "../NCR5380.h" 49 50 #define ECOSCSI_PUBLIC_RELEASE 1 51 - 52 - static char ecoscsi_read(struct Scsi_Host *instance, int reg) 53 - { 54 - int iobase = instance->io_port; 55 - outb(reg | 8, iobase); 56 - return inb(iobase + 1); 57 - } 58 - 59 - static void ecoscsi_write(struct Scsi_Host *instance, int reg, int value) 60 - { 61 - int iobase = instance->io_port; 62 - outb(reg | 8, iobase); 63 - outb(value, iobase + 1); 64 - } 65 66 /* 67 * Function : ecoscsi_setup(char *str, int *ints) ··· 71 { 72 return ""; 73 } 74 - 75 - #if 0 76 - #define STAT(p) inw(p + 144) 77 - 78 - static inline int NCR5380_pwrite(struct Scsi_Host *host, unsigned char *addr, 79 - int len) 80 - { 81 - int iobase = host->io_port; 82 - printk("writing %p len %d\n",addr, len); 83 - if(!len) return -1; 84 - 85 - while(1) 86 - { 87 - int status; 88 - while(((status = STAT(iobase)) & 0x100)==0); 89 - } 90 - } 91 - 92 - static inline int NCR5380_pread(struct Scsi_Host *host, unsigned char *addr, 93 - int len) 94 - { 95 - int iobase = host->io_port; 96 - int iobase2= host->io_port + 0x100; 97 - unsigned char *start = addr; 98 - int s; 99 - printk("reading %p len %d\n",addr, len); 100 - outb(inb(iobase + 128), iobase + 135); 101 - while(len > 0) 102 - { 103 - int status,b,i, timeout; 104 - timeout = 0x07FFFFFF; 105 - while(((status = STAT(iobase)) & 0x100)==0) 106 - { 107 - timeout--; 108 - if(status & 0x200 || !timeout) 109 - { 110 - printk("status = %p\n",status); 111 - outb(0, iobase + 135); 112 - return 1; 113 - } 114 - } 115 - if(len >= 128) 116 - { 117 - for(i=0; i<64; i++) 118 - { 119 - b = inw(iobase + 136); 120 - *addr++ = b; 121 - *addr++ = b>>8; 122 - } 123 - len -= 128; 124 - } 125 - else 126 - { 127 - b = inw(iobase + 136); 128 - *addr ++ = b; 129 - len -= 1; 130 - if(len) 131 - *addr ++ = b>>8; 132 - len -= 1; 133 - } 134 - } 135 - outb(0, iobase + 135); 136 - printk("first bytes = %02X %02X %02X %20X %02X %02X %02X\n",*start, start[1], start[2], start[3], start[4], start[5], start[6]); 137 - return 1; 138 - } 139 - #endif 140 - #undef STAT 141 142 #define BOARD_NORMAL 0 143 #define BOARD_NCR53C400 1 ··· 96 97 static int __init ecoscsi_init(void) 98 { 99 100 host = scsi_host_alloc(tpnt, sizeof(struct NCR5380_hostdata)); 101 - if (!host) 102 - return 0; 103 104 - host->io_port = 0x80ce8000; 105 - host->n_io_port = 144; 106 host->irq = IRQ_NONE; 107 - 108 - if (!(request_region(host->io_port, host->n_io_port, "ecoscsi")) ) 109 - goto unregister_scsi; 110 - 111 - ecoscsi_write(host, MODE_REG, 0x20); /* Is it really SCSI? */ 112 - if (ecoscsi_read(host, MODE_REG) != 0x20) /* Write to a reg. */ 113 - goto release_reg; 114 - 115 - ecoscsi_write(host, MODE_REG, 0x00 ); /* it back. */ 116 - if (ecoscsi_read(host, MODE_REG) != 0x00) 117 - goto release_reg; 118 119 NCR5380_init(host, 0); 120 ··· 140 scsi_scan_host(host); 141 return 0; 142 143 - release_reg: 144 - release_region(host->io_port, host->n_io_port); 145 - unregister_scsi: 146 - scsi_host_put(host); 147 - return -ENODEV; 148 } 149 150 static void __exit ecoscsi_exit(void) 151 { 152 scsi_remove_host(host); 153 - 154 - if (shpnt->irq != IRQ_NONE) 155 - free_irq(shpnt->irq, NULL); 156 NCR5380_exit(host); 157 - if (shpnt->io_port) 158 - release_region(shpnt->io_port, shpnt->n_io_port); 159 - 160 scsi_host_put(host); 161 return 0; 162 } 163
··· 34 #include "../scsi.h" 35 #include <scsi/scsi_host.h> 36 37 + #define priv(host) ((struct NCR5380_hostdata *)(host)->hostdata) 38 39 + #define NCR5380_local_declare() void __iomem *_base 40 + #define NCR5380_setup(host) _base = priv(host)->base 41 + 42 + #define NCR5380_read(reg) ({ writeb(reg | 8, _base); readb(_base + 4); }) 43 + #define NCR5380_write(reg, value) ({ writeb(reg | 8, _base); writeb(value, _base + 4); }) 44 45 #define NCR5380_intr ecoscsi_intr 46 #define NCR5380_queue_command ecoscsi_queue_command 47 #define NCR5380_proc_info ecoscsi_proc_info 48 49 + #define NCR5380_implementation_fields \ 50 + void __iomem *base 51 + 52 #include "../NCR5380.h" 53 54 #define ECOSCSI_PUBLIC_RELEASE 1 55 56 /* 57 * Function : ecoscsi_setup(char *str, int *ints) ··· 81 { 82 return ""; 83 } 84 85 #define BOARD_NORMAL 0 86 #define BOARD_NCR53C400 1 ··· 173 174 static int __init ecoscsi_init(void) 175 { 176 + void __iomem *_base; 177 + int ret; 178 + 179 + if (!request_mem_region(0x33a0000, 4096, "ecoscsi")) { 180 + ret = -EBUSY; 181 + goto out; 182 + } 183 + 184 + _base = ioremap(0x33a0000, 4096); 185 + if (!_base) { 186 + ret = -ENOMEM; 187 + goto out_release; 188 + } 189 + 190 + NCR5380_write(MODE_REG, 0x20); /* Is it really SCSI? */ 191 + if (NCR5380_read(MODE_REG) != 0x20) /* Write to a reg. */ 192 + goto out_unmap; 193 + 194 + NCR5380_write(MODE_REG, 0x00); /* it back. */ 195 + if (NCR5380_read(MODE_REG) != 0x00) 196 + goto out_unmap; 197 198 host = scsi_host_alloc(tpnt, sizeof(struct NCR5380_hostdata)); 199 + if (!host) { 200 + ret = -ENOMEM; 201 + goto out_unmap; 202 + } 203 204 + priv(host)->base = _base; 205 host->irq = IRQ_NONE; 206 207 NCR5380_init(host, 0); 208 ··· 206 scsi_scan_host(host); 207 return 0; 208 209 + out_unmap: 210 + iounmap(_base); 211 + out_release: 212 + release_mem_region(0x33a0000, 4096); 213 + out: 214 + return ret; 215 } 216 217 static void __exit ecoscsi_exit(void) 218 { 219 scsi_remove_host(host); 220 NCR5380_exit(host); 221 scsi_host_put(host); 222 + release_mem_region(0x33a0000, 4096); 223 return 0; 224 } 225
+44 -30
drivers/scsi/arm/oak.c
··· 23 24 #define OAKSCSI_PUBLIC_RELEASE 1 25 26 - #define NCR5380_read(reg) oakscsi_read(_instance, reg) 27 - #define NCR5380_write(reg, value) oakscsi_write(_instance, reg, value) 28 #define NCR5380_intr oakscsi_intr 29 #define NCR5380_queue_command oakscsi_queue_command 30 #define NCR5380_proc_info oakscsi_proc_info 31 32 - #define NCR5380_implementation_fields int port, ctrl 33 - #define NCR5380_local_declare() struct Scsi_Host *_instance 34 - #define NCR5380_setup(instance) _instance = instance 35 36 #define BOARD_NORMAL 0 37 #define BOARD_NCR53C400 1 ··· 42 #include "../NCR5380.h" 43 44 #undef START_DMA_INITIATOR_RECEIVE_REG 45 - #define START_DMA_INITIATOR_RECEIVE_REG (7 + 128) 46 47 const char * oakscsi_info (struct Scsi_Host *spnt) 48 { 49 return ""; 50 } 51 52 - #define STAT(p) inw(p + 144) 53 - extern void inswb(int from, void *to, int len); 54 55 static inline int NCR5380_pwrite(struct Scsi_Host *instance, unsigned char *addr, 56 int len) 57 { 58 - int iobase = instance->io_port; 59 printk("writing %p len %d\n",addr, len); 60 if(!len) return -1; 61 62 while(1) 63 { 64 int status; 65 - while(((status = STAT(iobase)) & 0x100)==0); 66 } 67 } 68 69 static inline int NCR5380_pread(struct Scsi_Host *instance, unsigned char *addr, 70 int len) 71 { 72 - int iobase = instance->io_port; 73 printk("reading %p len %d\n", addr, len); 74 while(len > 0) 75 { 76 - int status, timeout; 77 unsigned long b; 78 79 timeout = 0x01FFFFFF; 80 81 - while(((status = STAT(iobase)) & 0x100)==0) 82 { 83 timeout--; 84 if(status & 0x200 || !timeout) 85 { 86 - printk("status = %08X\n",status); 87 return 1; 88 } 89 } 90 if(len >= 128) 91 { 92 - inswb(iobase + 136, addr, 128); 93 addr += 128; 94 len -= 128; 95 } 96 else 97 { 98 - b = (unsigned long) inw(iobase + 136); 99 *addr ++ = b; 100 len -= 1; 101 if(len) ··· 108 return 0; 109 } 110 111 - #define oakscsi_read(instance,reg) (inb((instance)->io_port + (reg))) 112 - #define oakscsi_write(instance,reg,val) (outb((val), (instance)->io_port + (reg))) 113 - 114 #undef STAT 115 116 #include "../NCR5380.c" 117 ··· 135 struct Scsi_Host *host; 136 int ret = -ENOMEM; 137 138 - host = scsi_host_alloc(&oakscsi_template, sizeof(struct NCR5380_hostdata)); 139 - if (!host) 140 goto out; 141 142 - host->io_port = ecard_address(ec, ECARD_MEMC, 0); 143 host->irq = IRQ_NONE; 144 host->n_io_port = 255; 145 - 146 - ret = -EBUSY; 147 - if (!request_region (host->io_port, host->n_io_port, "Oak SCSI")) 148 - goto unreg; 149 150 NCR5380_init(host, 0); 151 ··· 167 168 ret = scsi_add_host(host, &ec->dev); 169 if (ret) 170 - goto out_release; 171 172 scsi_scan_host(host); 173 goto out; 174 175 - out_release: 176 - release_region(host->io_port, host->n_io_port); 177 unreg: 178 scsi_host_put(host); 179 out: 180 return ret; 181 } ··· 190 scsi_remove_host(host); 191 192 NCR5380_exit(host); 193 - release_region(host->io_port, host->n_io_port); 194 scsi_host_put(host); 195 } 196 197 static const struct ecard_id oakscsi_cids[] = {
··· 23 24 #define OAKSCSI_PUBLIC_RELEASE 1 25 26 + #define priv(host) ((struct NCR5380_hostdata *)(host)->hostdata) 27 + #define NCR5380_local_declare() void __iomem *_base 28 + #define NCR5380_setup(host) _base = priv(host)->base 29 + 30 + #define NCR5380_read(reg) readb(_base + ((reg) << 2)) 31 + #define NCR5380_write(reg, value) writeb(value, _base + ((reg) << 2)) 32 #define NCR5380_intr oakscsi_intr 33 #define NCR5380_queue_command oakscsi_queue_command 34 #define NCR5380_proc_info oakscsi_proc_info 35 36 + #define NCR5380_implementation_fields \ 37 + void __iomem *base 38 39 #define BOARD_NORMAL 0 40 #define BOARD_NCR53C400 1 ··· 39 #include "../NCR5380.h" 40 41 #undef START_DMA_INITIATOR_RECEIVE_REG 42 + #define START_DMA_INITIATOR_RECEIVE_REG (128 + 7) 43 44 const char * oakscsi_info (struct Scsi_Host *spnt) 45 { 46 return ""; 47 } 48 49 + #define STAT ((128 + 16) << 2) 50 + #define DATA ((128 + 8) << 2) 51 52 static inline int NCR5380_pwrite(struct Scsi_Host *instance, unsigned char *addr, 53 int len) 54 { 55 + void __iomem *base = priv(instance)->base; 56 + 57 printk("writing %p len %d\n",addr, len); 58 if(!len) return -1; 59 60 while(1) 61 { 62 int status; 63 + while (((status = readw(base + STAT)) & 0x100)==0); 64 } 65 } 66 67 static inline int NCR5380_pread(struct Scsi_Host *instance, unsigned char *addr, 68 int len) 69 { 70 + void __iomem *base = priv(instance)->base; 71 printk("reading %p len %d\n", addr, len); 72 while(len > 0) 73 { 74 + unsigned int status, timeout; 75 unsigned long b; 76 77 timeout = 0x01FFFFFF; 78 79 + while (((status = readw(base + STAT)) & 0x100)==0) 80 { 81 timeout--; 82 if(status & 0x200 || !timeout) 83 { 84 + printk("status = %08X\n", status); 85 return 1; 86 } 87 } 88 + 89 if(len >= 128) 90 { 91 + readsw(base + DATA, addr, 128); 92 addr += 128; 93 len -= 128; 94 } 95 else 96 { 97 + b = (unsigned long) readw(base + DATA); 98 *addr ++ = b; 99 len -= 1; 100 if(len) ··· 103 return 0; 104 } 105 106 #undef STAT 107 + #undef DATA 108 109 #include "../NCR5380.c" 110 ··· 132 struct Scsi_Host *host; 133 int ret = -ENOMEM; 134 135 + ret = ecard_request_resources(ec); 136 + if (ret) 137 goto out; 138 139 + host = scsi_host_alloc(&oakscsi_template, sizeof(struct NCR5380_hostdata)); 140 + if (!host) { 141 + ret = -ENOMEM; 142 + goto release; 143 + } 144 + 145 + priv(host)->base = ioremap(ecard_resource_start(ec, ECARD_RES_MEMC), 146 + ecard_resource_len(ec, ECARD_RES_MEMC)); 147 + if (!priv(host)->base) { 148 + ret = -ENOMEM; 149 + goto unreg; 150 + } 151 + 152 host->irq = IRQ_NONE; 153 host->n_io_port = 255; 154 155 NCR5380_init(host, 0); 156 ··· 156 157 ret = scsi_add_host(host, &ec->dev); 158 if (ret) 159 + goto out_unmap; 160 161 scsi_scan_host(host); 162 goto out; 163 164 + out_unmap: 165 + iounmap(priv(host)->base); 166 unreg: 167 scsi_host_put(host); 168 + release: 169 + ecard_release_resources(ec); 170 out: 171 return ret; 172 } ··· 177 scsi_remove_host(host); 178 179 NCR5380_exit(host); 180 + iounmap(priv(host)->base); 181 scsi_host_put(host); 182 + ecard_release_resources(ec); 183 } 184 185 static const struct ecard_id oakscsi_cids[] = {