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