]> asedeno.scripts.mit.edu Git - linux.git/blob - drivers/scsi/arm/cumana_1.c
scsi: cumana_1: Remove unused cumanascsi_setup() function
[linux.git] / drivers / scsi / arm / cumana_1.c
1 /*
2  * Generic Generic NCR5380 driver
3  *
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>
10
11 #include <asm/ecard.h>
12 #include <asm/io.h>
13
14 #include <scsi/scsi_host.h>
15
16 #define priv(host)                      ((struct NCR5380_hostdata *)(host)->hostdata)
17 #define NCR5380_read(reg)               cumanascsi_read(instance, reg)
18 #define NCR5380_write(reg, value)       cumanascsi_write(instance, reg, value)
19
20 #define NCR5380_dma_xfer_len(instance, cmd, phase)      (cmd->transfersize)
21 #define NCR5380_dma_recv_setup          cumanascsi_pread
22 #define NCR5380_dma_send_setup          cumanascsi_pwrite
23 #define NCR5380_dma_residual(instance)  (0)
24
25 #define NCR5380_intr                    cumanascsi_intr
26 #define NCR5380_queue_command           cumanascsi_queue_command
27 #define NCR5380_info                    cumanascsi_info
28
29 #define NCR5380_implementation_fields   \
30         unsigned ctrl;                  \
31         void __iomem *base;             \
32         void __iomem *dma
33
34 #include "../NCR5380.h"
35
36 #define CTRL    0x16fc
37 #define STAT    0x2004
38 #define L(v)    (((v)<<16)|((v) & 0x0000ffff))
39 #define H(v)    (((v)>>16)|((v) & 0xffff0000))
40
41 static inline int cumanascsi_pwrite(struct Scsi_Host *host,
42                                     unsigned char *addr, int len)
43 {
44   unsigned long *laddr;
45   void __iomem *dma = priv(host)->dma + 0x2000;
46
47   if(!len) return 0;
48
49   writeb(0x02, priv(host)->base + CTRL);
50   laddr = (unsigned long *)addr;
51   while(len >= 32)
52   {
53     unsigned int status;
54     unsigned long v;
55     status = readb(priv(host)->base + STAT);
56     if(status & 0x80)
57       goto end;
58     if(!(status & 0x40))
59       continue;
60     v=*laddr++; writew(L(v), dma); writew(H(v), dma);
61     v=*laddr++; writew(L(v), dma); writew(H(v), dma);
62     v=*laddr++; writew(L(v), dma); writew(H(v), dma);
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     len -= 32;
69     if(len == 0)
70       break;
71   }
72
73   addr = (unsigned char *)laddr;
74   writeb(0x12, priv(host)->base + CTRL);
75
76   while(len > 0)
77   {
78     unsigned int status;
79     status = readb(priv(host)->base + STAT);
80     if(status & 0x80)
81       goto end;
82     if(status & 0x40)
83     {
84       writeb(*addr++, dma);
85       if(--len == 0)
86         break;
87     }
88
89     status = readb(priv(host)->base + STAT);
90     if(status & 0x80)
91       goto end;
92     if(status & 0x40)
93     {
94       writeb(*addr++, dma);
95       if(--len == 0)
96         break;
97     }
98   }
99 end:
100   writeb(priv(host)->ctrl | 0x40, priv(host)->base + CTRL);
101
102         if (len)
103                 return -1;
104         return 0;
105 }
106
107 static inline int cumanascsi_pread(struct Scsi_Host *host,
108                                    unsigned char *addr, int len)
109 {
110   unsigned long *laddr;
111   void __iomem *dma = priv(host)->dma + 0x2000;
112
113   if(!len) return 0;
114
115   writeb(0x00, priv(host)->base + CTRL);
116   laddr = (unsigned long *)addr;
117   while(len >= 32)
118   {
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;
136   }
137
138   addr = (unsigned char *)laddr;
139   writeb(0x10, priv(host)->base + CTRL);
140
141   while(len > 0)
142   {
143     unsigned int status;
144     status = readb(priv(host)->base + STAT);
145     if(status & 0x80)
146       goto end;
147     if(status & 0x40)
148     {
149       *addr++ = readb(dma);
150       if(--len == 0)
151         break;
152     }
153
154     status = readb(priv(host)->base + STAT);
155     if(status & 0x80)
156       goto end;
157     if(status & 0x40)
158     {
159       *addr++ = readb(dma);
160       if(--len == 0)
161         break;
162     }
163   }
164 end:
165   writeb(priv(host)->ctrl | 0x40, priv(host)->base + CTRL);
166
167         if (len)
168                 return -1;
169         return 0;
170 }
171
172 static unsigned char cumanascsi_read(struct Scsi_Host *host, unsigned int reg)
173 {
174         void __iomem *base = priv(host)->base;
175         unsigned char val;
176
177         writeb(0, base + CTRL);
178
179         val = readb(base + 0x2100 + (reg << 2));
180
181         priv(host)->ctrl = 0x40;
182         writeb(0x40, base + CTRL);
183
184         return val;
185 }
186
187 static void cumanascsi_write(struct Scsi_Host *host, unsigned int reg, unsigned int value)
188 {
189         void __iomem *base = priv(host)->base;
190
191         writeb(0, base + CTRL);
192
193         writeb(value, base + 0x2100 + (reg << 2));
194
195         priv(host)->ctrl = 0x40;
196         writeb(0x40, base + CTRL);
197 }
198
199 #include "../NCR5380.c"
200
201 static struct scsi_host_template cumanascsi_template = {
202         .module                 = THIS_MODULE,
203         .name                   = "Cumana 16-bit SCSI",
204         .info                   = cumanascsi_info,
205         .queuecommand           = cumanascsi_queue_command,
206         .eh_abort_handler       = NCR5380_abort,
207         .eh_bus_reset_handler   = NCR5380_bus_reset,
208         .can_queue              = 16,
209         .this_id                = 7,
210         .sg_tablesize           = SG_ALL,
211         .cmd_per_lun            = 2,
212         .use_clustering         = DISABLE_CLUSTERING,
213         .proc_name              = "CumanaSCSI-1",
214         .cmd_size               = NCR5380_CMD_SIZE,
215         .max_sectors            = 128,
216 };
217
218 static int cumanascsi1_probe(struct expansion_card *ec,
219                              const struct ecard_id *id)
220 {
221         struct Scsi_Host *host;
222         int ret;
223
224         ret = ecard_request_resources(ec);
225         if (ret)
226                 goto out;
227
228         host = scsi_host_alloc(&cumanascsi_template, sizeof(struct NCR5380_hostdata));
229         if (!host) {
230                 ret = -ENOMEM;
231                 goto out_release;
232         }
233
234         priv(host)->base = ioremap(ecard_resource_start(ec, ECARD_RES_IOCSLOW),
235                                    ecard_resource_len(ec, ECARD_RES_IOCSLOW));
236         priv(host)->dma = ioremap(ecard_resource_start(ec, ECARD_RES_MEMC),
237                                   ecard_resource_len(ec, ECARD_RES_MEMC));
238         if (!priv(host)->base || !priv(host)->dma) {
239                 ret = -ENOMEM;
240                 goto out_unmap;
241         }
242
243         host->irq = ec->irq;
244
245         ret = NCR5380_init(host, FLAG_DMA_FIXUP | FLAG_LATE_DMA_SETUP);
246         if (ret)
247                 goto out_unmap;
248
249         NCR5380_maybe_reset_bus(host);
250
251         priv(host)->ctrl = 0;
252         writeb(0, priv(host)->base + CTRL);
253
254         ret = request_irq(host->irq, cumanascsi_intr, 0,
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_exit;
260         }
261
262         ret = scsi_add_host(host, &ec->dev);
263         if (ret)
264                 goto out_free_irq;
265
266         scsi_scan_host(host);
267         goto out;
268
269  out_free_irq:
270         free_irq(host->irq, host);
271  out_exit:
272         NCR5380_exit(host);
273  out_unmap:
274         iounmap(priv(host)->base);
275         iounmap(priv(host)->dma);
276         scsi_host_put(host);
277  out_release:
278         ecard_release_resources(ec);
279  out:
280         return ret;
281 }
282
283 static void cumanascsi1_remove(struct expansion_card *ec)
284 {
285         struct Scsi_Host *host = ecard_get_drvdata(ec);
286
287         ecard_set_drvdata(ec, NULL);
288
289         scsi_remove_host(host);
290         free_irq(host->irq, host);
291         NCR5380_exit(host);
292         iounmap(priv(host)->base);
293         iounmap(priv(host)->dma);
294         scsi_host_put(host);
295         ecard_release_resources(ec);
296 }
297
298 static const struct ecard_id cumanascsi1_cids[] = {
299         { MANU_CUMANA, PROD_CUMANA_SCSI_1 },
300         { 0xffff, 0xffff }
301 };
302
303 static struct ecard_driver cumanascsi1_driver = {
304         .probe          = cumanascsi1_probe,
305         .remove         = cumanascsi1_remove,
306         .id_table       = cumanascsi1_cids,
307         .drv = {
308                 .name           = "cumanascsi1",
309         },
310 };
311
312 static int __init cumanascsi_init(void)
313 {
314         return ecard_register_driver(&cumanascsi1_driver);
315 }
316
317 static void __exit cumanascsi_exit(void)
318 {
319         ecard_remove_driver(&cumanascsi1_driver);
320 }
321
322 module_init(cumanascsi_init);
323 module_exit(cumanascsi_exit);
324
325 MODULE_DESCRIPTION("Cumana SCSI-1 driver for Acorn machines");
326 MODULE_LICENSE("GPL");