EDAC: i7core, sb_edac: Don't return NOTIFY_BAD from mce_decoder callback
[linux/fpc-iii.git] / drivers / scsi / arm / cumana_1.c
blob221f18c5df9363c704d8289c2baab4b10dd89db6
1 /*
2 * Generic Generic NCR5380 driver
4 * Copyright 1995-2002, Russell King
5 */
6 #include <linux/module.h>
7 #include <linux/ioport.h>
8 #include <linux/blkdev.h>
9 #include <linux/init.h>
11 #include <asm/ecard.h>
12 #include <asm/io.h>
14 #include <scsi/scsi_host.h>
16 #define PSEUDO_DMA
18 #define priv(host) ((struct NCR5380_hostdata *)(host)->hostdata)
19 #define NCR5380_read(reg) cumanascsi_read(instance, reg)
20 #define NCR5380_write(reg, value) cumanascsi_write(instance, reg, value)
22 #define NCR5380_dma_xfer_len(instance, cmd, phase) (cmd->transfersize)
24 #define NCR5380_intr cumanascsi_intr
25 #define NCR5380_queue_command cumanascsi_queue_command
26 #define NCR5380_info cumanascsi_info
28 #define NCR5380_implementation_fields \
29 unsigned ctrl; \
30 void __iomem *base; \
31 void __iomem *dma
33 #include "../NCR5380.h"
35 void cumanascsi_setup(char *str, int *ints)
39 #define CTRL 0x16fc
40 #define STAT 0x2004
41 #define L(v) (((v)<<16)|((v) & 0x0000ffff))
42 #define H(v) (((v)>>16)|((v) & 0xffff0000))
44 static inline int
45 NCR5380_pwrite(struct Scsi_Host *host, unsigned char *addr, int len)
47 unsigned long *laddr;
48 void __iomem *dma = priv(host)->dma + 0x2000;
50 if(!len) return 0;
52 writeb(0x02, priv(host)->base + CTRL);
53 laddr = (unsigned long *)addr;
54 while(len >= 32)
56 unsigned int status;
57 unsigned long v;
58 status = readb(priv(host)->base + STAT);
59 if(status & 0x80)
60 goto end;
61 if(!(status & 0x40))
62 continue;
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);
71 len -= 32;
72 if(len == 0)
73 break;
76 addr = (unsigned char *)laddr;
77 writeb(0x12, priv(host)->base + CTRL);
79 while(len > 0)
81 unsigned int status;
82 status = readb(priv(host)->base + STAT);
83 if(status & 0x80)
84 goto end;
85 if(status & 0x40)
87 writeb(*addr++, dma);
88 if(--len == 0)
89 break;
92 status = readb(priv(host)->base + STAT);
93 if(status & 0x80)
94 goto end;
95 if(status & 0x40)
97 writeb(*addr++, dma);
98 if(--len == 0)
99 break;
102 end:
103 writeb(priv(host)->ctrl | 0x40, priv(host)->base + CTRL);
104 return len;
107 static inline int
108 NCR5380_pread(struct Scsi_Host *host, unsigned char *addr, int len)
110 unsigned long *laddr;
111 void __iomem *dma = priv(host)->dma + 0x2000;
113 if(!len) return 0;
115 writeb(0x00, priv(host)->base + CTRL);
116 laddr = (unsigned long *)addr;
117 while(len >= 32)
119 unsigned int status;
120 status = readb(priv(host)->base + STAT);
121 if(status & 0x80)
122 goto end;
123 if(!(status & 0x40))
124 continue;
125 *laddr++ = readw(dma) | (readw(dma) << 16);
126 *laddr++ = readw(dma) | (readw(dma) << 16);
127 *laddr++ = readw(dma) | (readw(dma) << 16);
128 *laddr++ = readw(dma) | (readw(dma) << 16);
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 len -= 32;
134 if(len == 0)
135 break;
138 addr = (unsigned char *)laddr;
139 writeb(0x10, priv(host)->base + CTRL);
141 while(len > 0)
143 unsigned int status;
144 status = readb(priv(host)->base + STAT);
145 if(status & 0x80)
146 goto end;
147 if(status & 0x40)
149 *addr++ = readb(dma);
150 if(--len == 0)
151 break;
154 status = readb(priv(host)->base + STAT);
155 if(status & 0x80)
156 goto end;
157 if(status & 0x40)
159 *addr++ = readb(dma);
160 if(--len == 0)
161 break;
164 end:
165 writeb(priv(host)->ctrl | 0x40, priv(host)->base + CTRL);
166 return len;
169 static unsigned char cumanascsi_read(struct Scsi_Host *host, unsigned int reg)
171 void __iomem *base = priv(host)->base;
172 unsigned char val;
174 writeb(0, base + CTRL);
176 val = readb(base + 0x2100 + (reg << 2));
178 priv(host)->ctrl = 0x40;
179 writeb(0x40, base + CTRL);
181 return val;
184 static void cumanascsi_write(struct Scsi_Host *host, unsigned int reg, unsigned int value)
186 void __iomem *base = priv(host)->base;
188 writeb(0, base + CTRL);
190 writeb(value, base + 0x2100 + (reg << 2));
192 priv(host)->ctrl = 0x40;
193 writeb(0x40, base + CTRL);
196 #include "../NCR5380.c"
198 static struct scsi_host_template cumanascsi_template = {
199 .module = THIS_MODULE,
200 .name = "Cumana 16-bit SCSI",
201 .info = cumanascsi_info,
202 .queuecommand = cumanascsi_queue_command,
203 .eh_abort_handler = NCR5380_abort,
204 .eh_bus_reset_handler = NCR5380_bus_reset,
205 .can_queue = 16,
206 .this_id = 7,
207 .sg_tablesize = SG_ALL,
208 .cmd_per_lun = 2,
209 .use_clustering = DISABLE_CLUSTERING,
210 .proc_name = "CumanaSCSI-1",
211 .cmd_size = NCR5380_CMD_SIZE,
212 .max_sectors = 128,
215 static int cumanascsi1_probe(struct expansion_card *ec,
216 const struct ecard_id *id)
218 struct Scsi_Host *host;
219 int ret;
221 ret = ecard_request_resources(ec);
222 if (ret)
223 goto out;
225 host = scsi_host_alloc(&cumanascsi_template, sizeof(struct NCR5380_hostdata));
226 if (!host) {
227 ret = -ENOMEM;
228 goto out_release;
231 priv(host)->base = ioremap(ecard_resource_start(ec, ECARD_RES_IOCSLOW),
232 ecard_resource_len(ec, ECARD_RES_IOCSLOW));
233 priv(host)->dma = ioremap(ecard_resource_start(ec, ECARD_RES_MEMC),
234 ecard_resource_len(ec, ECARD_RES_MEMC));
235 if (!priv(host)->base || !priv(host)->dma) {
236 ret = -ENOMEM;
237 goto out_unmap;
240 host->irq = ec->irq;
242 ret = NCR5380_init(host, 0);
243 if (ret)
244 goto out_unmap;
246 NCR5380_maybe_reset_bus(host);
248 priv(host)->ctrl = 0;
249 writeb(0, priv(host)->base + CTRL);
251 ret = request_irq(host->irq, cumanascsi_intr, 0,
252 "CumanaSCSI-1", host);
253 if (ret) {
254 printk("scsi%d: IRQ%d not free: %d\n",
255 host->host_no, host->irq, ret);
256 goto out_exit;
259 ret = scsi_add_host(host, &ec->dev);
260 if (ret)
261 goto out_free_irq;
263 scsi_scan_host(host);
264 goto out;
266 out_free_irq:
267 free_irq(host->irq, host);
268 out_exit:
269 NCR5380_exit(host);
270 out_unmap:
271 iounmap(priv(host)->base);
272 iounmap(priv(host)->dma);
273 scsi_host_put(host);
274 out_release:
275 ecard_release_resources(ec);
276 out:
277 return ret;
280 static void cumanascsi1_remove(struct expansion_card *ec)
282 struct Scsi_Host *host = ecard_get_drvdata(ec);
284 ecard_set_drvdata(ec, NULL);
286 scsi_remove_host(host);
287 free_irq(host->irq, host);
288 NCR5380_exit(host);
289 iounmap(priv(host)->base);
290 iounmap(priv(host)->dma);
291 scsi_host_put(host);
292 ecard_release_resources(ec);
295 static const struct ecard_id cumanascsi1_cids[] = {
296 { MANU_CUMANA, PROD_CUMANA_SCSI_1 },
297 { 0xffff, 0xffff }
300 static struct ecard_driver cumanascsi1_driver = {
301 .probe = cumanascsi1_probe,
302 .remove = cumanascsi1_remove,
303 .id_table = cumanascsi1_cids,
304 .drv = {
305 .name = "cumanascsi1",
309 static int __init cumanascsi_init(void)
311 return ecard_register_driver(&cumanascsi1_driver);
314 static void __exit cumanascsi_exit(void)
316 ecard_remove_driver(&cumanascsi1_driver);
319 module_init(cumanascsi_init);
320 module_exit(cumanascsi_exit);
322 MODULE_DESCRIPTION("Cumana SCSI-1 driver for Acorn machines");
323 MODULE_LICENSE("GPL");