Diff markup
1 /* 1 /*
2 * Generic Generic NCR5380 driver 2 * Generic Generic NCR5380 driver
3 * 3 *
4 * Copyright 1995-2002, Russell King 4 * Copyright 1995-2002, Russell King
5 */ 5 */
6 #include <linux/module.h> 6 #include <linux/module.h>
7 #include <linux/signal.h> 7 #include <linux/signal.h>
>> 8 #include <linux/sched.h>
8 #include <linux/ioport.h> 9 #include <linux/ioport.h>
9 #include <linux/delay.h> 10 #include <linux/delay.h>
10 #include <linux/blkdev.h> 11 #include <linux/blkdev.h>
11 #include <linux/init.h> 12 #include <linux/init.h>
12 13
13 #include <asm/ecard.h> 14 #include <asm/ecard.h>
14 #include <asm/io.h> 15 #include <asm/io.h>
>> 16 #include <asm/irq.h>
15 #include <asm/system.h> 17 #include <asm/system.h>
16 18
17 #include "../scsi.h" 19 #include "../scsi.h"
18 #include <scsi/scsi_host.h> 20 #include <scsi/scsi_host.h>
19 21
20 #include <scsi/scsicam.h> 22 #include <scsi/scsicam.h>
21 23
22 #define AUTOSENSE 24 #define AUTOSENSE
23 #define PSEUDO_DMA 25 #define PSEUDO_DMA
24 26
25 #define CUMANASCSI_PUBLIC_RELEASE 1 27 #define CUMANASCSI_PUBLIC_RELEASE 1
26 28
27 #define priv(host) ((stru !! 29 #define NCR5380_implementation_fields int port, ctrl
28 #define NCR5380_local_declare() struct 30 #define NCR5380_local_declare() struct Scsi_Host *_instance
29 #define NCR5380_setup(instance) _insta 31 #define NCR5380_setup(instance) _instance = instance
30 #define NCR5380_read(reg) cumana 32 #define NCR5380_read(reg) cumanascsi_read(_instance, reg)
31 #define NCR5380_write(reg, value) cumana 33 #define NCR5380_write(reg, value) cumanascsi_write(_instance, reg, value)
32 #define NCR5380_intr cumana 34 #define NCR5380_intr cumanascsi_intr
33 #define NCR5380_queue_command cumana 35 #define NCR5380_queue_command cumanascsi_queue_command
34 #define NCR5380_proc_info cumana 36 #define NCR5380_proc_info cumanascsi_proc_info
35 37
36 #define NCR5380_implementation_fields \ <<
37 unsigned ctrl; \ <<
38 void __iomem *base; \ <<
39 void __iomem *dma <<
40 <<
41 #define BOARD_NORMAL 0 38 #define BOARD_NORMAL 0
42 #define BOARD_NCR53C400 1 39 #define BOARD_NCR53C400 1
43 40
44 #include "../NCR5380.h" 41 #include "../NCR5380.h"
45 42
46 void cumanascsi_setup(char *str, int *ints) 43 void cumanascsi_setup(char *str, int *ints)
47 { 44 {
48 } 45 }
49 46
50 const char *cumanascsi_info(struct Scsi_Host * 47 const char *cumanascsi_info(struct Scsi_Host *spnt)
51 { 48 {
52 return ""; 49 return "";
53 } 50 }
54 51
55 #define CTRL 0x16fc !! 52 #ifdef NOT_EFFICIENT
56 #define STAT 0x2004 !! 53 #define CTRL(p,v) outb(*ctrl = (v), (p) - 577)
57 #define L(v) (((v)<<16)|((v) & 0x0000ffff)) !! 54 #define STAT(p) inb((p)+1)
58 #define H(v) (((v)>>16)|((v) & 0xffff0000)) !! 55 #define IN(p) inb((p))
>> 56 #define OUT(v,p) outb((v), (p))
>> 57 #else
>> 58 #define CTRL(p,v) (p[-2308] = (*ctrl = (v)))
>> 59 #define STAT(p) (p[4])
>> 60 #define IN(p) (*(p))
>> 61 #define IN2(p) ((unsigned short)(*(volatile unsigned long *)(p)))
>> 62 #define OUT(v,p) (*(p) = (v))
>> 63 #define OUT2(v,p) (*((volatile unsigned long *)(p)) = (v))
>> 64 #endif
>> 65 #define L(v) (((v)<<16)|((v) & 0x0000ffff))
>> 66 #define H(v) (((v)>>16)|((v) & 0xffff0000))
59 67
60 static inline int 68 static inline int
61 NCR5380_pwrite(struct Scsi_Host *host, unsigne !! 69 NCR5380_pwrite(struct Scsi_Host *instance, unsigned char *addr, int len)
62 { 70 {
>> 71 int *ctrl = &((struct NCR5380_hostdata *)instance->hostdata)->ctrl;
>> 72 int oldctrl = *ctrl;
63 unsigned long *laddr; 73 unsigned long *laddr;
64 void __iomem *dma = priv(host)->dma + 0x2000 !! 74 #ifdef NOT_EFFICIENT
>> 75 int iobase = instance->io_port;
>> 76 int dma_io = iobase & ~(0x3C0000>>2);
>> 77 #else
>> 78 volatile unsigned char *iobase = (unsigned char *)ioaddr(instance->io_port);
>> 79 volatile unsigned char *dma_io = (unsigned char *)((int)iobase & ~0x3C0000);
>> 80 #endif
65 81
66 if(!len) return 0; 82 if(!len) return 0;
67 83
68 writeb(0x02, priv(host)->base + CTRL); !! 84 CTRL(iobase, 0x02);
69 laddr = (unsigned long *)addr; 85 laddr = (unsigned long *)addr;
70 while(len >= 32) 86 while(len >= 32)
71 { 87 {
72 unsigned int status; !! 88 int status;
73 unsigned long v; 89 unsigned long v;
74 status = readb(priv(host)->base + STAT); !! 90 status = STAT(iobase);
75 if(status & 0x80) 91 if(status & 0x80)
76 goto end; 92 goto end;
77 if(!(status & 0x40)) 93 if(!(status & 0x40))
78 continue; 94 continue;
79 v=*laddr++; writew(L(v), dma); writew(H(v) !! 95 v=*laddr++; OUT2(L(v),dma_io); OUT2(H(v),dma_io);
80 v=*laddr++; writew(L(v), dma); writew(H(v) !! 96 v=*laddr++; OUT2(L(v),dma_io); OUT2(H(v),dma_io);
81 v=*laddr++; writew(L(v), dma); writew(H(v) !! 97 v=*laddr++; OUT2(L(v),dma_io); OUT2(H(v),dma_io);
82 v=*laddr++; writew(L(v), dma); writew(H(v) !! 98 v=*laddr++; OUT2(L(v),dma_io); OUT2(H(v),dma_io);
83 v=*laddr++; writew(L(v), dma); writew(H(v) !! 99 v=*laddr++; OUT2(L(v),dma_io); OUT2(H(v),dma_io);
84 v=*laddr++; writew(L(v), dma); writew(H(v) !! 100 v=*laddr++; OUT2(L(v),dma_io); OUT2(H(v),dma_io);
85 v=*laddr++; writew(L(v), dma); writew(H(v) !! 101 v=*laddr++; OUT2(L(v),dma_io); OUT2(H(v),dma_io);
86 v=*laddr++; writew(L(v), dma); writew(H(v) !! 102 v=*laddr++; OUT2(L(v),dma_io); OUT2(H(v),dma_io);
87 len -= 32; 103 len -= 32;
88 if(len == 0) 104 if(len == 0)
89 break; 105 break;
90 } 106 }
91 107
92 addr = (unsigned char *)laddr; 108 addr = (unsigned char *)laddr;
93 writeb(0x12, priv(host)->base + CTRL); !! 109 CTRL(iobase, 0x12);
94 <<
95 while(len > 0) 110 while(len > 0)
96 { 111 {
97 unsigned int status; !! 112 int status;
98 status = readb(priv(host)->base + STAT); !! 113 status = STAT(iobase);
99 if(status & 0x80) 114 if(status & 0x80)
100 goto end; 115 goto end;
101 if(status & 0x40) 116 if(status & 0x40)
102 { 117 {
103 writeb(*addr++, dma); !! 118 OUT(*addr++, dma_io);
104 if(--len == 0) 119 if(--len == 0)
105 break; 120 break;
106 } 121 }
107 122
108 status = readb(priv(host)->base + STAT); !! 123 status = STAT(iobase);
109 if(status & 0x80) 124 if(status & 0x80)
110 goto end; 125 goto end;
111 if(status & 0x40) 126 if(status & 0x40)
112 { 127 {
113 writeb(*addr++, dma); !! 128 OUT(*addr++, dma_io);
114 if(--len == 0) 129 if(--len == 0)
115 break; 130 break;
116 } 131 }
117 } 132 }
118 end: 133 end:
119 writeb(priv(host)->ctrl | 0x40, priv(host)-> !! 134 CTRL(iobase, oldctrl|0x40);
120 return len; 135 return len;
121 } 136 }
122 137
123 static inline int 138 static inline int
124 NCR5380_pread(struct Scsi_Host *host, unsigned !! 139 NCR5380_pread(struct Scsi_Host *instance, unsigned char *addr, int len)
125 { 140 {
>> 141 int *ctrl = &((struct NCR5380_hostdata *)instance->hostdata)->ctrl;
>> 142 int oldctrl = *ctrl;
126 unsigned long *laddr; 143 unsigned long *laddr;
127 void __iomem *dma = priv(host)->dma + 0x2000 !! 144 #ifdef NOT_EFFICIENT
>> 145 int iobase = instance->io_port;
>> 146 int dma_io = iobase & ~(0x3C0000>>2);
>> 147 #else
>> 148 volatile unsigned char *iobase = (unsigned char *)ioaddr(instance->io_port);
>> 149 volatile unsigned char *dma_io = (unsigned char *)((int)iobase & ~0x3C0000);
>> 150 #endif
128 151
129 if(!len) return 0; 152 if(!len) return 0;
130 153
131 writeb(0x00, priv(host)->base + CTRL); !! 154 CTRL(iobase, 0x00);
132 laddr = (unsigned long *)addr; 155 laddr = (unsigned long *)addr;
133 while(len >= 32) 156 while(len >= 32)
134 { 157 {
135 unsigned int status; !! 158 int status;
136 status = readb(priv(host)->base + STAT); !! 159 status = STAT(iobase);
137 if(status & 0x80) 160 if(status & 0x80)
138 goto end; 161 goto end;
139 if(!(status & 0x40)) 162 if(!(status & 0x40))
140 continue; 163 continue;
141 *laddr++ = readw(dma) | (readw(dma) << 16) !! 164 *laddr++ = IN2(dma_io)|(IN2(dma_io)<<16);
142 *laddr++ = readw(dma) | (readw(dma) << 16) !! 165 *laddr++ = IN2(dma_io)|(IN2(dma_io)<<16);
143 *laddr++ = readw(dma) | (readw(dma) << 16) !! 166 *laddr++ = IN2(dma_io)|(IN2(dma_io)<<16);
144 *laddr++ = readw(dma) | (readw(dma) << 16) !! 167 *laddr++ = IN2(dma_io)|(IN2(dma_io)<<16);
145 *laddr++ = readw(dma) | (readw(dma) << 16) !! 168 *laddr++ = IN2(dma_io)|(IN2(dma_io)<<16);
146 *laddr++ = readw(dma) | (readw(dma) << 16) !! 169 *laddr++ = IN2(dma_io)|(IN2(dma_io)<<16);
147 *laddr++ = readw(dma) | (readw(dma) << 16) !! 170 *laddr++ = IN2(dma_io)|(IN2(dma_io)<<16);
148 *laddr++ = readw(dma) | (readw(dma) << 16) !! 171 *laddr++ = IN2(dma_io)|(IN2(dma_io)<<16);
149 len -= 32; 172 len -= 32;
150 if(len == 0) 173 if(len == 0)
151 break; 174 break;
152 } 175 }
153 176
154 addr = (unsigned char *)laddr; 177 addr = (unsigned char *)laddr;
155 writeb(0x10, priv(host)->base + CTRL); !! 178 CTRL(iobase, 0x10);
156 <<
157 while(len > 0) 179 while(len > 0)
158 { 180 {
159 unsigned int status; !! 181 int status;
160 status = readb(priv(host)->base + STAT); !! 182 status = STAT(iobase);
161 if(status & 0x80) 183 if(status & 0x80)
162 goto end; 184 goto end;
163 if(status & 0x40) 185 if(status & 0x40)
164 { 186 {
165 *addr++ = readb(dma); !! 187 *addr++ = IN(dma_io);
166 if(--len == 0) 188 if(--len == 0)
167 break; 189 break;
168 } 190 }
169 191
170 status = readb(priv(host)->base + STAT); !! 192 status = STAT(iobase);
171 if(status & 0x80) 193 if(status & 0x80)
172 goto end; 194 goto end;
173 if(status & 0x40) 195 if(status & 0x40)
174 { 196 {
175 *addr++ = readb(dma); !! 197 *addr++ = IN(dma_io);
176 if(--len == 0) 198 if(--len == 0)
177 break; 199 break;
178 } 200 }
179 } 201 }
180 end: 202 end:
181 writeb(priv(host)->ctrl | 0x40, priv(host)-> !! 203 CTRL(iobase, oldctrl|0x40);
182 return len; 204 return len;
183 } 205 }
184 206
185 static unsigned char cumanascsi_read(struct Sc !! 207 #undef STAT
186 { !! 208 #undef CTRL
187 void __iomem *base = priv(host)->base; !! 209 #undef IN
188 unsigned char val; !! 210 #undef OUT
189 <<
190 writeb(0, base + CTRL); <<
191 211
192 val = readb(base + 0x2100 + (reg << 2) !! 212 #define CTRL(p,v) outb(*ctrl = (v), (p) - 577)
193 213
194 priv(host)->ctrl = 0x40; !! 214 static char cumanascsi_read(struct Scsi_Host *instance, int reg)
195 writeb(0x40, base + CTRL); !! 215 {
>> 216 unsigned int iobase = instance->io_port;
>> 217 int i;
>> 218 int *ctrl = &((struct NCR5380_hostdata *)instance->hostdata)->ctrl;
>> 219
>> 220 CTRL(iobase, 0);
>> 221 i = inb(iobase + 64 + reg);
>> 222 CTRL(iobase, 0x40);
196 223
197 return val; !! 224 return i;
198 } 225 }
199 226
200 static void cumanascsi_write(struct Scsi_Host !! 227 static void cumanascsi_write(struct Scsi_Host *instance, int reg, int value)
201 { 228 {
202 void __iomem *base = priv(host)->base; !! 229 int iobase = instance->io_port;
>> 230 int *ctrl = &((struct NCR5380_hostdata *)instance->hostdata)->ctrl;
203 231
204 writeb(0, base + CTRL); !! 232 CTRL(iobase, 0);
205 !! 233 outb(value, iobase + 64 + reg);
206 writeb(value, base + 0x2100 + (reg << !! 234 CTRL(iobase, 0x40);
207 <<
208 priv(host)->ctrl = 0x40; <<
209 writeb(0x40, base + CTRL); <<
210 } 235 }
211 236
>> 237 #undef CTRL
>> 238
212 #include "../NCR5380.c" 239 #include "../NCR5380.c"
213 240
214 static struct scsi_host_template cumanascsi_te !! 241 static Scsi_Host_Template cumanascsi_template = {
215 .module = THIS_MODULE, 242 .module = THIS_MODULE,
216 .name = "Cumana 16-b 243 .name = "Cumana 16-bit SCSI",
217 .info = cumanascsi_i 244 .info = cumanascsi_info,
218 .queuecommand = cumanascsi_q 245 .queuecommand = cumanascsi_queue_command,
219 .eh_abort_handler = NCR5380_abor 246 .eh_abort_handler = NCR5380_abort,
>> 247 .eh_device_reset_handler= NCR5380_device_reset,
220 .eh_bus_reset_handler = NCR5380_bus_ 248 .eh_bus_reset_handler = NCR5380_bus_reset,
>> 249 .eh_host_reset_handler = NCR5380_host_reset,
221 .can_queue = 16, 250 .can_queue = 16,
222 .this_id = 7, 251 .this_id = 7,
223 .sg_tablesize = SG_ALL, 252 .sg_tablesize = SG_ALL,
224 .cmd_per_lun = 2, 253 .cmd_per_lun = 2,
>> 254 .unchecked_isa_dma = 0,
225 .use_clustering = DISABLE_CLUS 255 .use_clustering = DISABLE_CLUSTERING,
226 .proc_name = "CumanaSCSI- 256 .proc_name = "CumanaSCSI-1",
227 }; 257 };
228 258
229 static int __devinit 259 static int __devinit
230 cumanascsi1_probe(struct expansion_card *ec, c 260 cumanascsi1_probe(struct expansion_card *ec, const struct ecard_id *id)
231 { 261 {
232 struct Scsi_Host *host; 262 struct Scsi_Host *host;
233 int ret; !! 263 int ret = -ENOMEM;
234 <<
235 ret = ecard_request_resources(ec); <<
236 if (ret) <<
237 goto out; <<
238 264
239 host = scsi_host_alloc(&cumanascsi_tem 265 host = scsi_host_alloc(&cumanascsi_template, sizeof(struct NCR5380_hostdata));
240 if (!host) { !! 266 if (!host)
241 ret = -ENOMEM; !! 267 goto out;
242 goto out_release; <<
243 } <<
244 <<
245 priv(host)->base = ioremap(ecard_resou <<
246 ecard_resou <<
247 priv(host)->dma = ioremap(ecard_resour <<
248 ecard_resour <<
249 if (!priv(host)->base || !priv(host)-> <<
250 ret = -ENOMEM; <<
251 goto out_unmap; <<
252 } <<
253 268
>> 269 host->io_port = ecard_address(ec, ECARD_IOC, ECARD_SLOW) + 0x800;
254 host->irq = ec->irq; 270 host->irq = ec->irq;
255 271
256 NCR5380_init(host, 0); 272 NCR5380_init(host, 0);
257 273
258 priv(host)->ctrl = 0; <<
259 writeb(0, priv(host)->base + CTRL); <<
260 <<
261 host->n_io_port = 255; 274 host->n_io_port = 255;
262 if (!(request_region(host->io_port, ho 275 if (!(request_region(host->io_port, host->n_io_port, "CumanaSCSI-1"))) {
263 ret = -EBUSY; 276 ret = -EBUSY;
264 goto out_unmap; !! 277 goto out_free;
265 } 278 }
266 279
267 ret = request_irq(host->irq, cumanascs !! 280 ((struct NCR5380_hostdata *)host->hostdata)->ctrl = 0;
>> 281 outb(0x00, host->io_port - 577);
>> 282
>> 283 ret = request_irq(host->irq, cumanascsi_intr, SA_INTERRUPT,
268 "CumanaSCSI-1", host 284 "CumanaSCSI-1", host);
269 if (ret) { 285 if (ret) {
270 printk("scsi%d: IRQ%d not free 286 printk("scsi%d: IRQ%d not free: %d\n",
271 host->host_no, host->irq, 287 host->host_no, host->irq, ret);
272 goto out_unmap; !! 288 goto out_release;
273 } 289 }
274 290
275 printk("scsi%d: at port 0x%08lx irq %d 291 printk("scsi%d: at port 0x%08lx irq %d",
276 host->host_no, host->io_port, 292 host->host_no, host->io_port, host->irq);
277 printk(" options CAN_QUEUE=%d CMD_PER_ 293 printk(" options CAN_QUEUE=%d CMD_PER_LUN=%d release=%d",
278 host->can_queue, host->cmd_per 294 host->can_queue, host->cmd_per_lun, CUMANASCSI_PUBLIC_RELEASE);
279 printk("\nscsi%d:", host->host_no); 295 printk("\nscsi%d:", host->host_no);
280 NCR5380_print_options(host); 296 NCR5380_print_options(host);
281 printk("\n"); 297 printk("\n");
282 298
283 ret = scsi_add_host(host, &ec->dev); 299 ret = scsi_add_host(host, &ec->dev);
284 if (ret) 300 if (ret)
285 goto out_free_irq; 301 goto out_free_irq;
286 302
287 scsi_scan_host(host); 303 scsi_scan_host(host);
288 goto out; 304 goto out;
289 305
290 out_free_irq: 306 out_free_irq:
291 free_irq(host->irq, host); 307 free_irq(host->irq, host);
292 out_unmap: <<
293 iounmap(priv(host)->base); <<
294 iounmap(priv(host)->dma); <<
295 scsi_host_put(host); <<
296 out_release: 308 out_release:
297 ecard_release_resources(ec); !! 309 release_region(host->io_port, host->n_io_port);
>> 310 out_free:
>> 311 scsi_host_put(host);
298 out: 312 out:
299 return ret; 313 return ret;
300 } 314 }
301 315
302 static void __devexit cumanascsi1_remove(struc 316 static void __devexit cumanascsi1_remove(struct expansion_card *ec)
303 { 317 {
304 struct Scsi_Host *host = ecard_get_drv 318 struct Scsi_Host *host = ecard_get_drvdata(ec);
305 319
306 ecard_set_drvdata(ec, NULL); 320 ecard_set_drvdata(ec, NULL);
307 321
308 scsi_remove_host(host); 322 scsi_remove_host(host);
309 free_irq(host->irq, host); 323 free_irq(host->irq, host);
310 NCR5380_exit(host); 324 NCR5380_exit(host);
311 iounmap(priv(host)->base); !! 325 release_region(host->io_port, host->n_io_port);
312 iounmap(priv(host)->dma); <<
313 scsi_host_put(host); 326 scsi_host_put(host);
314 ecard_release_resources(ec); <<
315 } 327 }
316 328
317 static const struct ecard_id cumanascsi1_cids[ 329 static const struct ecard_id cumanascsi1_cids[] = {
318 { MANU_CUMANA, PROD_CUMANA_SCSI_1 }, 330 { MANU_CUMANA, PROD_CUMANA_SCSI_1 },
319 { 0xffff, 0xffff } 331 { 0xffff, 0xffff }
320 }; 332 };
321 333
322 static struct ecard_driver cumanascsi1_driver 334 static struct ecard_driver cumanascsi1_driver = {
323 .probe = cumanascsi1_probe, 335 .probe = cumanascsi1_probe,
324 .remove = __devexit_p(cumanasc 336 .remove = __devexit_p(cumanascsi1_remove),
325 .id_table = cumanascsi1_cids, 337 .id_table = cumanascsi1_cids,
326 .drv = { 338 .drv = {
327 .name = "cumanascsi1 339 .name = "cumanascsi1",
328 }, 340 },
329 }; 341 };
330 342
331 static int __init cumanascsi_init(void) 343 static int __init cumanascsi_init(void)
332 { 344 {
333 return ecard_register_driver(&cumanasc 345 return ecard_register_driver(&cumanascsi1_driver);
334 } 346 }
335 347
336 static void __exit cumanascsi_exit(void) 348 static void __exit cumanascsi_exit(void)
337 { 349 {
338 ecard_remove_driver(&cumanascsi1_drive 350 ecard_remove_driver(&cumanascsi1_driver);
339 } 351 }
340 352
341 module_init(cumanascsi_init); 353 module_init(cumanascsi_init);
342 module_exit(cumanascsi_exit); 354 module_exit(cumanascsi_exit);
343 355
344 MODULE_DESCRIPTION("Cumana SCSI-1 driver for A 356 MODULE_DESCRIPTION("Cumana SCSI-1 driver for Acorn machines");
345 MODULE_LICENSE("GPL"); 357 MODULE_LICENSE("GPL");
346 358
|
This page was automatically generated by the
LXR engine.
|