Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Generic Generic NCR5380 driver |
| 3 | * |
| 4 | * Copyright 1995-2002, Russell King |
| 5 | */ |
| 6 | #include <linux/module.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | #include <linux/ioport.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | #include <linux/blkdev.h> |
| 9 | #include <linux/init.h> |
| 10 | |
| 11 | #include <asm/ecard.h> |
| 12 | #include <asm/io.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | #include <scsi/scsi_host.h> |
| 15 | |
Russell King | 8b801ea | 2007-07-20 10:38:54 +0100 | [diff] [blame] | 16 | #define priv(host) ((struct NCR5380_hostdata *)(host)->hostdata) |
Finn Thain | 61e1ce5 | 2016-10-10 00:46:53 -0400 | [diff] [blame] | 17 | #define NCR5380_read(reg) cumanascsi_read(hostdata, reg) |
| 18 | #define NCR5380_write(reg, value) cumanascsi_write(hostdata, reg, value) |
Finn Thain | ff3d457 | 2016-01-03 16:05:25 +1100 | [diff] [blame] | 19 | |
Finn Thain | 4a98f89 | 2016-10-10 00:46:53 -0400 | [diff] [blame] | 20 | #define NCR5380_dma_xfer_len cumanascsi_dma_xfer_len |
Finn Thain | 6c4b88c | 2016-03-23 21:10:17 +1100 | [diff] [blame] | 21 | #define NCR5380_dma_recv_setup cumanascsi_pread |
| 22 | #define NCR5380_dma_send_setup cumanascsi_pwrite |
Finn Thain | 4a98f89 | 2016-10-10 00:46:53 -0400 | [diff] [blame] | 23 | #define NCR5380_dma_residual NCR5380_dma_residual_none |
Finn Thain | ff3d457 | 2016-01-03 16:05:25 +1100 | [diff] [blame] | 24 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | #define NCR5380_intr cumanascsi_intr |
| 26 | #define NCR5380_queue_command cumanascsi_queue_command |
Finn Thain | 8c32513 | 2014-11-12 16:11:58 +1100 | [diff] [blame] | 27 | #define NCR5380_info cumanascsi_info |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | |
Russell King | 8b801ea | 2007-07-20 10:38:54 +0100 | [diff] [blame] | 29 | #define NCR5380_implementation_fields \ |
Finn Thain | 820682b | 2016-10-10 00:46:53 -0400 | [diff] [blame] | 30 | unsigned ctrl |
Russell King | 8b801ea | 2007-07-20 10:38:54 +0100 | [diff] [blame] | 31 | |
Finn Thain | 7c60663 | 2016-10-10 00:46:53 -0400 | [diff] [blame] | 32 | struct NCR5380_hostdata; |
| 33 | static u8 cumanascsi_read(struct NCR5380_hostdata *, unsigned int); |
| 34 | static void cumanascsi_write(struct NCR5380_hostdata *, unsigned int, u8); |
| 35 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | #include "../NCR5380.h" |
| 37 | |
Russell King | 8b801ea | 2007-07-20 10:38:54 +0100 | [diff] [blame] | 38 | #define CTRL 0x16fc |
| 39 | #define STAT 0x2004 |
| 40 | #define L(v) (((v)<<16)|((v) & 0x0000ffff)) |
| 41 | #define H(v) (((v)>>16)|((v) & 0xffff0000)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | |
Finn Thain | 4a98f89 | 2016-10-10 00:46:53 -0400 | [diff] [blame] | 43 | static inline int cumanascsi_pwrite(struct NCR5380_hostdata *hostdata, |
Finn Thain | 6c4b88c | 2016-03-23 21:10:17 +1100 | [diff] [blame] | 44 | unsigned char *addr, int len) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | unsigned long *laddr; |
Finn Thain | 4a98f89 | 2016-10-10 00:46:53 -0400 | [diff] [blame] | 47 | u8 __iomem *base = hostdata->io; |
| 48 | u8 __iomem *dma = hostdata->pdma_io + 0x2000; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | |
| 50 | if(!len) return 0; |
| 51 | |
Finn Thain | 820682b | 2016-10-10 00:46:53 -0400 | [diff] [blame] | 52 | writeb(0x02, base + CTRL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | laddr = (unsigned long *)addr; |
| 54 | while(len >= 32) |
| 55 | { |
Russell King | 8b801ea | 2007-07-20 10:38:54 +0100 | [diff] [blame] | 56 | unsigned int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | unsigned long v; |
Finn Thain | 820682b | 2016-10-10 00:46:53 -0400 | [diff] [blame] | 58 | status = readb(base + STAT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | if(status & 0x80) |
| 60 | goto end; |
| 61 | if(!(status & 0x40)) |
| 62 | continue; |
Russell King | 8b801ea | 2007-07-20 10:38:54 +0100 | [diff] [blame] | 63 | v=*laddr++; writew(L(v), dma); writew(H(v), dma); |
| 64 | v=*laddr++; writew(L(v), dma); writew(H(v), dma); |
| 65 | v=*laddr++; writew(L(v), dma); writew(H(v), dma); |
| 66 | v=*laddr++; writew(L(v), dma); writew(H(v), dma); |
| 67 | v=*laddr++; writew(L(v), dma); writew(H(v), dma); |
| 68 | v=*laddr++; writew(L(v), dma); writew(H(v), dma); |
| 69 | v=*laddr++; writew(L(v), dma); writew(H(v), dma); |
| 70 | v=*laddr++; writew(L(v), dma); writew(H(v), dma); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 71 | len -= 32; |
| 72 | if(len == 0) |
| 73 | break; |
| 74 | } |
| 75 | |
| 76 | addr = (unsigned char *)laddr; |
Finn Thain | 820682b | 2016-10-10 00:46:53 -0400 | [diff] [blame] | 77 | writeb(0x12, base + CTRL); |
Russell King | 8b801ea | 2007-07-20 10:38:54 +0100 | [diff] [blame] | 78 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 79 | while(len > 0) |
| 80 | { |
Russell King | 8b801ea | 2007-07-20 10:38:54 +0100 | [diff] [blame] | 81 | unsigned int status; |
Finn Thain | 820682b | 2016-10-10 00:46:53 -0400 | [diff] [blame] | 82 | status = readb(base + STAT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 83 | if(status & 0x80) |
| 84 | goto end; |
| 85 | if(status & 0x40) |
| 86 | { |
Russell King | 8b801ea | 2007-07-20 10:38:54 +0100 | [diff] [blame] | 87 | writeb(*addr++, dma); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 88 | if(--len == 0) |
| 89 | break; |
| 90 | } |
| 91 | |
Finn Thain | 820682b | 2016-10-10 00:46:53 -0400 | [diff] [blame] | 92 | status = readb(base + STAT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 93 | if(status & 0x80) |
| 94 | goto end; |
| 95 | if(status & 0x40) |
| 96 | { |
Russell King | 8b801ea | 2007-07-20 10:38:54 +0100 | [diff] [blame] | 97 | writeb(*addr++, dma); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 98 | if(--len == 0) |
| 99 | break; |
| 100 | } |
| 101 | } |
| 102 | end: |
Finn Thain | 4a98f89 | 2016-10-10 00:46:53 -0400 | [diff] [blame] | 103 | writeb(hostdata->ctrl | 0x40, base + CTRL); |
Finn Thain | 438af51 | 2016-03-23 21:10:18 +1100 | [diff] [blame] | 104 | |
| 105 | if (len) |
| 106 | return -1; |
| 107 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 108 | } |
| 109 | |
Finn Thain | 4a98f89 | 2016-10-10 00:46:53 -0400 | [diff] [blame] | 110 | static inline int cumanascsi_pread(struct NCR5380_hostdata *hostdata, |
Finn Thain | 6c4b88c | 2016-03-23 21:10:17 +1100 | [diff] [blame] | 111 | unsigned char *addr, int len) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 112 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 113 | unsigned long *laddr; |
Finn Thain | 4a98f89 | 2016-10-10 00:46:53 -0400 | [diff] [blame] | 114 | u8 __iomem *base = hostdata->io; |
| 115 | u8 __iomem *dma = hostdata->pdma_io + 0x2000; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 116 | |
| 117 | if(!len) return 0; |
| 118 | |
Finn Thain | 820682b | 2016-10-10 00:46:53 -0400 | [diff] [blame] | 119 | writeb(0x00, base + CTRL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 120 | laddr = (unsigned long *)addr; |
| 121 | while(len >= 32) |
| 122 | { |
Russell King | 8b801ea | 2007-07-20 10:38:54 +0100 | [diff] [blame] | 123 | unsigned int status; |
Finn Thain | 820682b | 2016-10-10 00:46:53 -0400 | [diff] [blame] | 124 | status = readb(base + STAT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 125 | if(status & 0x80) |
| 126 | goto end; |
| 127 | if(!(status & 0x40)) |
| 128 | continue; |
Russell King | 8b801ea | 2007-07-20 10:38:54 +0100 | [diff] [blame] | 129 | *laddr++ = readw(dma) | (readw(dma) << 16); |
| 130 | *laddr++ = readw(dma) | (readw(dma) << 16); |
| 131 | *laddr++ = readw(dma) | (readw(dma) << 16); |
| 132 | *laddr++ = readw(dma) | (readw(dma) << 16); |
| 133 | *laddr++ = readw(dma) | (readw(dma) << 16); |
| 134 | *laddr++ = readw(dma) | (readw(dma) << 16); |
| 135 | *laddr++ = readw(dma) | (readw(dma) << 16); |
| 136 | *laddr++ = readw(dma) | (readw(dma) << 16); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 137 | len -= 32; |
| 138 | if(len == 0) |
| 139 | break; |
| 140 | } |
| 141 | |
| 142 | addr = (unsigned char *)laddr; |
Finn Thain | 820682b | 2016-10-10 00:46:53 -0400 | [diff] [blame] | 143 | writeb(0x10, base + CTRL); |
Russell King | 8b801ea | 2007-07-20 10:38:54 +0100 | [diff] [blame] | 144 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 145 | while(len > 0) |
| 146 | { |
Russell King | 8b801ea | 2007-07-20 10:38:54 +0100 | [diff] [blame] | 147 | unsigned int status; |
Finn Thain | 820682b | 2016-10-10 00:46:53 -0400 | [diff] [blame] | 148 | status = readb(base + STAT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 149 | if(status & 0x80) |
| 150 | goto end; |
| 151 | if(status & 0x40) |
| 152 | { |
Russell King | 8b801ea | 2007-07-20 10:38:54 +0100 | [diff] [blame] | 153 | *addr++ = readb(dma); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 154 | if(--len == 0) |
| 155 | break; |
| 156 | } |
| 157 | |
Finn Thain | 820682b | 2016-10-10 00:46:53 -0400 | [diff] [blame] | 158 | status = readb(base + STAT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 159 | if(status & 0x80) |
| 160 | goto end; |
| 161 | if(status & 0x40) |
| 162 | { |
Russell King | 8b801ea | 2007-07-20 10:38:54 +0100 | [diff] [blame] | 163 | *addr++ = readb(dma); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 164 | if(--len == 0) |
| 165 | break; |
| 166 | } |
| 167 | } |
| 168 | end: |
Finn Thain | 4a98f89 | 2016-10-10 00:46:53 -0400 | [diff] [blame] | 169 | writeb(hostdata->ctrl | 0x40, base + CTRL); |
Finn Thain | 438af51 | 2016-03-23 21:10:18 +1100 | [diff] [blame] | 170 | |
| 171 | if (len) |
| 172 | return -1; |
| 173 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 174 | } |
| 175 | |
Finn Thain | 4a98f89 | 2016-10-10 00:46:53 -0400 | [diff] [blame] | 176 | static int cumanascsi_dma_xfer_len(struct NCR5380_hostdata *hostdata, |
| 177 | struct scsi_cmnd *cmd) |
| 178 | { |
| 179 | return cmd->transfersize; |
| 180 | } |
| 181 | |
Finn Thain | 61e1ce5 | 2016-10-10 00:46:53 -0400 | [diff] [blame] | 182 | static u8 cumanascsi_read(struct NCR5380_hostdata *hostdata, |
| 183 | unsigned int reg) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 184 | { |
Finn Thain | 61e1ce5 | 2016-10-10 00:46:53 -0400 | [diff] [blame] | 185 | u8 __iomem *base = hostdata->io; |
| 186 | u8 val; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 187 | |
Russell King | 8b801ea | 2007-07-20 10:38:54 +0100 | [diff] [blame] | 188 | writeb(0, base + CTRL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 189 | |
Russell King | 8b801ea | 2007-07-20 10:38:54 +0100 | [diff] [blame] | 190 | val = readb(base + 0x2100 + (reg << 2)); |
| 191 | |
Finn Thain | 61e1ce5 | 2016-10-10 00:46:53 -0400 | [diff] [blame] | 192 | hostdata->ctrl = 0x40; |
Russell King | 8b801ea | 2007-07-20 10:38:54 +0100 | [diff] [blame] | 193 | writeb(0x40, base + CTRL); |
| 194 | |
| 195 | return val; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 196 | } |
| 197 | |
Finn Thain | 61e1ce5 | 2016-10-10 00:46:53 -0400 | [diff] [blame] | 198 | static void cumanascsi_write(struct NCR5380_hostdata *hostdata, |
| 199 | unsigned int reg, u8 value) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 200 | { |
Finn Thain | 61e1ce5 | 2016-10-10 00:46:53 -0400 | [diff] [blame] | 201 | u8 __iomem *base = hostdata->io; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 202 | |
Russell King | 8b801ea | 2007-07-20 10:38:54 +0100 | [diff] [blame] | 203 | writeb(0, base + CTRL); |
| 204 | |
| 205 | writeb(value, base + 0x2100 + (reg << 2)); |
| 206 | |
Finn Thain | 61e1ce5 | 2016-10-10 00:46:53 -0400 | [diff] [blame] | 207 | hostdata->ctrl = 0x40; |
Russell King | 8b801ea | 2007-07-20 10:38:54 +0100 | [diff] [blame] | 208 | writeb(0x40, base + CTRL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 209 | } |
| 210 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 211 | #include "../NCR5380.c" |
| 212 | |
Christoph Hellwig | d0be4a7d | 2005-10-31 18:31:40 +0100 | [diff] [blame] | 213 | static struct scsi_host_template cumanascsi_template = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 214 | .module = THIS_MODULE, |
| 215 | .name = "Cumana 16-bit SCSI", |
| 216 | .info = cumanascsi_info, |
| 217 | .queuecommand = cumanascsi_queue_command, |
| 218 | .eh_abort_handler = NCR5380_abort, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 219 | .eh_bus_reset_handler = NCR5380_bus_reset, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 220 | .can_queue = 16, |
| 221 | .this_id = 7, |
| 222 | .sg_tablesize = SG_ALL, |
| 223 | .cmd_per_lun = 2, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 224 | .use_clustering = DISABLE_CLUSTERING, |
| 225 | .proc_name = "CumanaSCSI-1", |
Finn Thain | 32b26a1 | 2016-01-03 16:05:58 +1100 | [diff] [blame] | 226 | .cmd_size = NCR5380_CMD_SIZE, |
Finn Thain | 0a4e361 | 2016-01-03 16:06:07 +1100 | [diff] [blame] | 227 | .max_sectors = 128, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 228 | }; |
| 229 | |
Greg Kroah-Hartman | 6f03979 | 2012-12-21 13:08:55 -0800 | [diff] [blame] | 230 | static int cumanascsi1_probe(struct expansion_card *ec, |
| 231 | const struct ecard_id *id) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 232 | { |
| 233 | struct Scsi_Host *host; |
Russell King | 8b801ea | 2007-07-20 10:38:54 +0100 | [diff] [blame] | 234 | int ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 235 | |
Russell King | 8b801ea | 2007-07-20 10:38:54 +0100 | [diff] [blame] | 236 | ret = ecard_request_resources(ec); |
| 237 | if (ret) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 238 | goto out; |
| 239 | |
Russell King | 8b801ea | 2007-07-20 10:38:54 +0100 | [diff] [blame] | 240 | host = scsi_host_alloc(&cumanascsi_template, sizeof(struct NCR5380_hostdata)); |
| 241 | if (!host) { |
| 242 | ret = -ENOMEM; |
| 243 | goto out_release; |
| 244 | } |
| 245 | |
Finn Thain | 820682b | 2016-10-10 00:46:53 -0400 | [diff] [blame] | 246 | priv(host)->io = ioremap(ecard_resource_start(ec, ECARD_RES_IOCSLOW), |
| 247 | ecard_resource_len(ec, ECARD_RES_IOCSLOW)); |
| 248 | priv(host)->pdma_io = ioremap(ecard_resource_start(ec, ECARD_RES_MEMC), |
| 249 | ecard_resource_len(ec, ECARD_RES_MEMC)); |
| 250 | if (!priv(host)->io || !priv(host)->pdma_io) { |
Russell King | 8b801ea | 2007-07-20 10:38:54 +0100 | [diff] [blame] | 251 | ret = -ENOMEM; |
| 252 | goto out_unmap; |
| 253 | } |
| 254 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 255 | host->irq = ec->irq; |
| 256 | |
Finn Thain | 8053b0e | 2016-03-23 21:10:19 +1100 | [diff] [blame] | 257 | ret = NCR5380_init(host, FLAG_DMA_FIXUP | FLAG_LATE_DMA_SETUP); |
Finn Thain | 0ad0eff | 2016-01-03 16:05:21 +1100 | [diff] [blame] | 258 | if (ret) |
| 259 | goto out_unmap; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 260 | |
Finn Thain | b6488f9 | 2016-01-03 16:05:08 +1100 | [diff] [blame] | 261 | NCR5380_maybe_reset_bus(host); |
| 262 | |
Russell King | 8b801ea | 2007-07-20 10:38:54 +0100 | [diff] [blame] | 263 | priv(host)->ctrl = 0; |
Finn Thain | 820682b | 2016-10-10 00:46:53 -0400 | [diff] [blame] | 264 | writeb(0, priv(host)->io + CTRL); |
Russell King | 8b801ea | 2007-07-20 10:38:54 +0100 | [diff] [blame] | 265 | |
Michael Opdenacker | 4909cc2 | 2014-03-05 06:09:41 +0100 | [diff] [blame] | 266 | ret = request_irq(host->irq, cumanascsi_intr, 0, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 267 | "CumanaSCSI-1", host); |
| 268 | if (ret) { |
| 269 | printk("scsi%d: IRQ%d not free: %d\n", |
| 270 | host->host_no, host->irq, ret); |
Finn Thain | 0ad0eff | 2016-01-03 16:05:21 +1100 | [diff] [blame] | 271 | goto out_exit; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 272 | } |
| 273 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 274 | ret = scsi_add_host(host, &ec->dev); |
| 275 | if (ret) |
| 276 | goto out_free_irq; |
| 277 | |
| 278 | scsi_scan_host(host); |
| 279 | goto out; |
| 280 | |
| 281 | out_free_irq: |
| 282 | free_irq(host->irq, host); |
Finn Thain | 0ad0eff | 2016-01-03 16:05:21 +1100 | [diff] [blame] | 283 | out_exit: |
| 284 | NCR5380_exit(host); |
Russell King | 8b801ea | 2007-07-20 10:38:54 +0100 | [diff] [blame] | 285 | out_unmap: |
Finn Thain | 820682b | 2016-10-10 00:46:53 -0400 | [diff] [blame] | 286 | iounmap(priv(host)->io); |
| 287 | iounmap(priv(host)->pdma_io); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 288 | scsi_host_put(host); |
Russell King | 8b801ea | 2007-07-20 10:38:54 +0100 | [diff] [blame] | 289 | out_release: |
| 290 | ecard_release_resources(ec); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 291 | out: |
| 292 | return ret; |
| 293 | } |
| 294 | |
Greg Kroah-Hartman | 6f03979 | 2012-12-21 13:08:55 -0800 | [diff] [blame] | 295 | static void cumanascsi1_remove(struct expansion_card *ec) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 296 | { |
| 297 | struct Scsi_Host *host = ecard_get_drvdata(ec); |
Finn Thain | 820682b | 2016-10-10 00:46:53 -0400 | [diff] [blame] | 298 | void __iomem *base = priv(host)->io; |
| 299 | void __iomem *dma = priv(host)->pdma_io; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 300 | |
| 301 | ecard_set_drvdata(ec, NULL); |
| 302 | |
| 303 | scsi_remove_host(host); |
| 304 | free_irq(host->irq, host); |
| 305 | NCR5380_exit(host); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 306 | scsi_host_put(host); |
Finn Thain | 820682b | 2016-10-10 00:46:53 -0400 | [diff] [blame] | 307 | iounmap(base); |
| 308 | iounmap(dma); |
Russell King | 8b801ea | 2007-07-20 10:38:54 +0100 | [diff] [blame] | 309 | ecard_release_resources(ec); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 310 | } |
| 311 | |
| 312 | static const struct ecard_id cumanascsi1_cids[] = { |
| 313 | { MANU_CUMANA, PROD_CUMANA_SCSI_1 }, |
| 314 | { 0xffff, 0xffff } |
| 315 | }; |
| 316 | |
| 317 | static struct ecard_driver cumanascsi1_driver = { |
| 318 | .probe = cumanascsi1_probe, |
Greg Kroah-Hartman | 6f03979 | 2012-12-21 13:08:55 -0800 | [diff] [blame] | 319 | .remove = cumanascsi1_remove, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 320 | .id_table = cumanascsi1_cids, |
| 321 | .drv = { |
| 322 | .name = "cumanascsi1", |
| 323 | }, |
| 324 | }; |
| 325 | |
| 326 | static int __init cumanascsi_init(void) |
| 327 | { |
| 328 | return ecard_register_driver(&cumanascsi1_driver); |
| 329 | } |
| 330 | |
| 331 | static void __exit cumanascsi_exit(void) |
| 332 | { |
| 333 | ecard_remove_driver(&cumanascsi1_driver); |
| 334 | } |
| 335 | |
| 336 | module_init(cumanascsi_init); |
| 337 | module_exit(cumanascsi_exit); |
| 338 | |
| 339 | MODULE_DESCRIPTION("Cumana SCSI-1 driver for Acorn machines"); |
| 340 | MODULE_LICENSE("GPL"); |