blob: 152dd15db276c42af82ccc39bde3ed0d9d346cb3 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/************************************************************
2 * *
3 * Linux EATA SCSI PIO driver *
4 * *
5 * based on the CAM document CAM/89-004 rev. 2.0c, *
6 * DPT's driver kit, some internal documents and source, *
7 * and several other Linux scsi drivers and kernel docs. *
8 * *
9 * The driver currently: *
10 * -supports all EATA-PIO boards *
11 * -only supports DASD devices *
12 * *
13 * (c)1993-96 Michael Neuffer, Alfred Arnold *
14 * neuffer@goofy.zdv.uni-mainz.de *
15 * a.arnold@kfa-juelich.de *
16 * *
Alan Coxfa195af2008-10-27 15:16:36 +000017 * Updated 2002 by Alan Cox <alan@lxorguk.ukuu.org.uk> for *
18 * Linux 2.5.x and the newer locking and error handling *
Linus Torvalds1da177e2005-04-16 15:20:36 -070019 * *
20 * This program is free software; you can redistribute it *
21 * and/or modify it under the terms of the GNU General *
22 * Public License as published by the Free Software *
23 * Foundation; either version 2 of the License, or *
24 * (at your option) any later version. *
25 * *
26 * This program is distributed in the hope that it will be *
27 * useful, but WITHOUT ANY WARRANTY; without even the *
28 * implied warranty of MERCHANTABILITY or FITNESS FOR A *
29 * PARTICULAR PURPOSE. See the GNU General Public License *
30 * for more details. *
31 * *
32 * You should have received a copy of the GNU General *
33 * Public License along with this kernel; if not, write to *
34 * the Free Software Foundation, Inc., 675 Mass Ave, *
35 * Cambridge, MA 02139, USA. *
36 * *
37 * For the avoidance of doubt the "preferred form" of this *
38 * code is one which is in an open non patent encumbered *
39 * format. Where cryptographic key signing forms part of *
40 * the process of creating an executable the information *
41 * including keys needed to generate an equivalently *
42 * functional executable are deemed to be part of the *
43 * source code are deemed to be part of the source code. *
44 * *
45 ************************************************************
46 * last change: 2002/11/02 OS: Linux 2.5.45 *
47 ************************************************************/
48
Linus Torvalds1da177e2005-04-16 15:20:36 -070049#include <linux/module.h>
50#include <linux/kernel.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070051#include <linux/string.h>
52#include <linux/ioport.h>
53#include <linux/slab.h>
54#include <linux/in.h>
55#include <linux/pci.h>
56#include <linux/proc_fs.h>
57#include <linux/interrupt.h>
58#include <linux/blkdev.h>
59#include <linux/spinlock.h>
60#include <linux/delay.h>
61
62#include <asm/io.h>
63
64#include <scsi/scsi.h>
65#include <scsi/scsi_cmnd.h>
66#include <scsi/scsi_device.h>
67#include <scsi/scsi_host.h>
68
69#include "eata_generic.h"
70#include "eata_pio.h"
71
72
Alan Cox1a68d412006-09-18 19:18:34 +010073static unsigned int ISAbases[MAXISA] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070074 0x1F0, 0x170, 0x330, 0x230
75};
76
Alan Cox1a68d412006-09-18 19:18:34 +010077static unsigned int ISAirqs[MAXISA] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070078 14, 12, 15, 11
79};
80
81static unsigned char EISAbases[] = {
82 1, 1, 1, 1, 1, 1, 1, 1,
83 1, 1, 1, 1, 1, 1, 1, 1
84};
85
Alan Cox1a68d412006-09-18 19:18:34 +010086static unsigned int registered_HBAs;
Linus Torvalds1da177e2005-04-16 15:20:36 -070087static struct Scsi_Host *last_HBA;
88static struct Scsi_Host *first_HBA;
89static unsigned char reg_IRQ[16];
90static unsigned char reg_IRQL[16];
91static unsigned long int_counter;
92static unsigned long queue_counter;
93
94static struct scsi_host_template driver_template;
95
96/*
97 * eata_proc_info
98 * inout : decides on the direction of the dataflow and the meaning of the
99 * variables
100 * buffer: If inout==FALSE data is being written to it else read from it
101 * *start: If inout==FALSE start of the valid data in the buffer
102 * offset: If inout==FALSE offset from the beginning of the imaginary file
103 * from which we start writing into the buffer
104 * length: If inout==FALSE max number of bytes to be written into the buffer
105 * else number of bytes in the buffer
106 */
107static int eata_pio_proc_info(struct Scsi_Host *shost, char *buffer, char **start, off_t offset,
108 int length, int rw)
109{
Alan Cox1a1d6412007-09-20 15:15:27 +0100110 int len = 0;
111 off_t begin = 0, pos = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700112
Alan Cox1a1d6412007-09-20 15:15:27 +0100113 if (rw)
114 return -ENOSYS;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115
Alan Cox1a1d6412007-09-20 15:15:27 +0100116 len += sprintf(buffer+len, "EATA (Extended Attachment) PIO driver version: "
Linus Torvalds1da177e2005-04-16 15:20:36 -0700117 "%d.%d%s\n",VER_MAJOR, VER_MINOR, VER_SUB);
Alan Cox1a1d6412007-09-20 15:15:27 +0100118 len += sprintf(buffer + len, "queued commands: %10ld\n"
Linus Torvalds1da177e2005-04-16 15:20:36 -0700119 "processed interrupts:%10ld\n", queue_counter, int_counter);
Alan Cox1a1d6412007-09-20 15:15:27 +0100120 len += sprintf(buffer + len, "\nscsi%-2d: HBA %.10s\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700121 shost->host_no, SD(shost)->name);
Alan Cox1a1d6412007-09-20 15:15:27 +0100122 len += sprintf(buffer + len, "Firmware revision: v%s\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700123 SD(shost)->revision);
Alan Cox1a1d6412007-09-20 15:15:27 +0100124 len += sprintf(buffer + len, "IO: PIO\n");
125 len += sprintf(buffer + len, "Base IO : %#.4x\n", (u32) shost->base);
126 len += sprintf(buffer + len, "Host Bus: %s\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700127 (SD(shost)->bustype == 'P')?"PCI ":
128 (SD(shost)->bustype == 'E')?"EISA":"ISA ");
129
Alan Cox1a1d6412007-09-20 15:15:27 +0100130 pos = begin + len;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700131
Alan Cox1a1d6412007-09-20 15:15:27 +0100132 if (pos < offset) {
133 len = 0;
134 begin = pos;
135 }
136 if (pos > offset + length)
137 goto stop_output;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700138
Alan Cox1a1d6412007-09-20 15:15:27 +0100139stop_output:
140 DBG(DBG_PROC, printk("2pos: %ld offset: %ld len: %d\n", pos, offset, len));
141 *start = buffer + (offset - begin); /* Start of wanted data */
142 len -= (offset - begin); /* Start slop */
143 if (len > length)
144 len = length; /* Ending slop */
145 DBG(DBG_PROC, printk("3pos: %ld offset: %ld len: %d\n", pos, offset, len));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146
Alan Cox1a1d6412007-09-20 15:15:27 +0100147 return len;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700148}
149
150static int eata_pio_release(struct Scsi_Host *sh)
151{
Alan Cox1a68d412006-09-18 19:18:34 +0100152 hostdata *hd = SD(sh);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700153 if (sh->irq && reg_IRQ[sh->irq] == 1)
154 free_irq(sh->irq, NULL);
155 else
156 reg_IRQ[sh->irq]--;
157 if (SD(sh)->channel == 0) {
158 if (sh->io_port && sh->n_io_port)
159 release_region(sh->io_port, sh->n_io_port);
160 }
Alan Cox1a68d412006-09-18 19:18:34 +0100161 /* At this point the PCI reference can go */
162 if (hd->pdev)
163 pci_dev_put(hd->pdev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700164 return 1;
165}
166
Alan Cox1a68d412006-09-18 19:18:34 +0100167static void IncStat(struct scsi_pointer *SCp, unsigned int Increment)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700168{
169 SCp->ptr += Increment;
170 if ((SCp->this_residual -= Increment) == 0) {
171 if ((--SCp->buffers_residual) == 0)
172 SCp->Status = 0;
173 else {
174 SCp->buffer++;
Jens Axboe45711f12007-10-22 21:19:53 +0200175 SCp->ptr = sg_virt(SCp->buffer);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700176 SCp->this_residual = SCp->buffer->length;
177 }
178 }
179}
180
David Howells7d12e782006-10-05 14:55:46 +0100181static irqreturn_t eata_pio_int_handler(int irq, void *dev_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700182
David Howells7d12e782006-10-05 14:55:46 +0100183static irqreturn_t do_eata_pio_int_handler(int irq, void *dev_id)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700184{
185 unsigned long flags;
186 struct Scsi_Host *dev = dev_id;
Alan Cox1a68d412006-09-18 19:18:34 +0100187 irqreturn_t ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700188
189 spin_lock_irqsave(dev->host_lock, flags);
Alan Coxa31baca2006-10-19 23:28:33 -0700190 ret = eata_pio_int_handler(irq, dev_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700191 spin_unlock_irqrestore(dev->host_lock, flags);
Alan Cox1a68d412006-09-18 19:18:34 +0100192 return ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700193}
194
David Howells7d12e782006-10-05 14:55:46 +0100195static irqreturn_t eata_pio_int_handler(int irq, void *dev_id)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700196{
Alan Cox1a68d412006-09-18 19:18:34 +0100197 unsigned int eata_stat = 0xfffff;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700198 struct scsi_cmnd *cmd;
199 hostdata *hd;
200 struct eata_ccb *cp;
Alan Cox1a68d412006-09-18 19:18:34 +0100201 unsigned long base;
202 unsigned int x, z;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700203 struct Scsi_Host *sh;
204 unsigned short zwickel = 0;
205 unsigned char stat, odd;
Alan Cox1a68d412006-09-18 19:18:34 +0100206 irqreturn_t ret = IRQ_NONE;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700207
208 for (x = 1, sh = first_HBA; x <= registered_HBAs; x++, sh = SD(sh)->prev)
209 {
210 if (sh->irq != irq)
211 continue;
Alan Cox1a68d412006-09-18 19:18:34 +0100212 if (inb(sh->base + HA_RSTATUS) & HA_SBUSY)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700213 continue;
214
215 int_counter++;
Alan Cox1a68d412006-09-18 19:18:34 +0100216 ret = IRQ_HANDLED;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700217
218 hd = SD(sh);
219
220 cp = &hd->ccb[0];
221 cmd = cp->cmd;
Alan Cox1a68d412006-09-18 19:18:34 +0100222 base = cmd->device->host->base;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700223
224 do {
225 stat = inb(base + HA_RSTATUS);
226 if (stat & HA_SDRQ) {
227 if (cp->DataIn) {
228 z = 256;
229 odd = 0;
230 while ((cmd->SCp.Status) && ((z > 0) || (odd))) {
231 if (odd) {
232 *(cmd->SCp.ptr) = zwickel >> 8;
233 IncStat(&cmd->SCp, 1);
234 odd = 0;
235 }
236 x = min_t(unsigned int, z, cmd->SCp.this_residual / 2);
237 insw(base + HA_RDATA, cmd->SCp.ptr, x);
238 z -= x;
239 IncStat(&cmd->SCp, 2 * x);
240 if ((z > 0) && (cmd->SCp.this_residual == 1)) {
241 zwickel = inw(base + HA_RDATA);
242 *(cmd->SCp.ptr) = zwickel & 0xff;
243 IncStat(&cmd->SCp, 1);
244 z--;
245 odd = 1;
246 }
247 }
248 while (z > 0) {
249 zwickel = inw(base + HA_RDATA);
250 z--;
251 }
252 } else { /* cp->DataOut */
253
254 odd = 0;
255 z = 256;
256 while ((cmd->SCp.Status) && ((z > 0) || (odd))) {
257 if (odd) {
258 zwickel += *(cmd->SCp.ptr) << 8;
259 IncStat(&cmd->SCp, 1);
260 outw(zwickel, base + HA_RDATA);
261 z--;
262 odd = 0;
263 }
264 x = min_t(unsigned int, z, cmd->SCp.this_residual / 2);
265 outsw(base + HA_RDATA, cmd->SCp.ptr, x);
266 z -= x;
267 IncStat(&cmd->SCp, 2 * x);
268 if ((z > 0) && (cmd->SCp.this_residual == 1)) {
269 zwickel = *(cmd->SCp.ptr);
270 zwickel &= 0xff;
271 IncStat(&cmd->SCp, 1);
272 odd = 1;
273 }
274 }
275 while (z > 0 || odd) {
276 outw(zwickel, base + HA_RDATA);
277 z--;
278 odd = 0;
279 }
280 }
281 }
282 }
283 while ((stat & HA_SDRQ) || ((stat & HA_SMORE) && hd->moresupport));
284
285 /* terminate handler if HBA goes busy again, i.e. transfers
286 * more data */
287
288 if (stat & HA_SBUSY)
289 break;
290
291 /* OK, this is quite stupid, but I haven't found any correct
292 * way to get HBA&SCSI status so far */
293
294 if (!(inb(base + HA_RSTATUS) & HA_SERROR)) {
295 cmd->result = (DID_OK << 16);
296 hd->devflags |= (1 << cp->cp_id);
Alan Cox1a68d412006-09-18 19:18:34 +0100297 } else if (hd->devflags & (1 << cp->cp_id))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700298 cmd->result = (DID_OK << 16) + 0x02;
299 else
300 cmd->result = (DID_NO_CONNECT << 16);
301
302 if (cp->status == LOCKED) {
303 cp->status = FREE;
304 eata_stat = inb(base + HA_RSTATUS);
305 printk(KERN_CRIT "eata_pio: int_handler, freeing locked " "queueslot\n");
Alan Cox1a68d412006-09-18 19:18:34 +0100306 return ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700307 }
308#if DBG_INTR2
309 if (stat != 0x50)
310 printk(KERN_DEBUG "stat: %#.2x, result: %#.8x\n", stat, cmd->result);
311#endif
312
313 cp->status = FREE; /* now we can release the slot */
314
315 cmd->scsi_done(cmd);
316 }
317
Alan Cox1a68d412006-09-18 19:18:34 +0100318 return ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700319}
320
Alan Cox1a68d412006-09-18 19:18:34 +0100321static inline unsigned int eata_pio_send_command(unsigned long base, unsigned char command)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700322{
Alan Cox1a68d412006-09-18 19:18:34 +0100323 unsigned int loop = 50;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700324
325 while (inb(base + HA_RSTATUS) & HA_SBUSY)
326 if (--loop == 0)
327 return 1;
328
329 /* Enable interrupts for HBA. It is not the best way to do it at this
330 * place, but I hope that it doesn't interfere with the IDE driver
331 * initialization this way */
332
333 outb(HA_CTRL_8HEADS, base + HA_CTRLREG);
334
335 outb(command, base + HA_WCOMMAND);
336 return 0;
337}
338
339static int eata_pio_queue(struct scsi_cmnd *cmd,
340 void (*done)(struct scsi_cmnd *))
341{
Alan Cox1a68d412006-09-18 19:18:34 +0100342 unsigned int x, y;
343 unsigned long base;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700344
345 hostdata *hd;
346 struct Scsi_Host *sh;
347 struct eata_ccb *cp;
348
349 queue_counter++;
350
351 hd = HD(cmd);
352 sh = cmd->device->host;
Alan Cox1a68d412006-09-18 19:18:34 +0100353 base = sh->base;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700354
355 /* use only slot 0, as 2001 can handle only one cmd at a time */
356
357 y = x = 0;
358
359 if (hd->ccb[y].status != FREE) {
360
361 DBG(DBG_QUEUE, printk(KERN_EMERG "can_queue %d, x %d, y %d\n", sh->can_queue, x, y));
362#if DEBUG_EATA
363 panic(KERN_EMERG "eata_pio: run out of queue slots cmdno:%ld " "intrno: %ld\n", queue_counter, int_counter);
364#else
365 panic(KERN_EMERG "eata_pio: run out of queue slots....\n");
366#endif
367 }
368
369 cp = &hd->ccb[y];
370
371 memset(cp, 0, sizeof(struct eata_ccb));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700372
373 cp->status = USED; /* claim free slot */
374
Jeff Garzik017560f2005-10-24 18:04:36 -0400375 DBG(DBG_QUEUE, scmd_printk(KERN_DEBUG, cmd,
376 "eata_pio_queue pid %ld, y %d\n",
Matthew Wilcox12a44162007-09-18 19:54:43 -0600377 cmd->serial_number, y));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700378
379 cmd->scsi_done = (void *) done;
380
381 if (cmd->sc_data_direction == DMA_TO_DEVICE)
382 cp->DataOut = 1; /* Output mode */
383 else
384 cp->DataIn = 0; /* Input mode */
385
386 cp->Interpret = (cmd->device->id == hd->hostid);
Boaz Harrosh7410d842007-09-09 21:10:27 +0300387 cp->cp_datalen = cpu_to_be32(scsi_bufflen(cmd));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700388 cp->Auto_Req_Sen = 0;
Alan Cox1a68d412006-09-18 19:18:34 +0100389 cp->cp_reqDMA = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700390 cp->reqlen = 0;
391
392 cp->cp_id = cmd->device->id;
393 cp->cp_lun = cmd->device->lun;
394 cp->cp_dispri = 0;
395 cp->cp_identify = 1;
396 memcpy(cp->cp_cdb, cmd->cmnd, COMMAND_SIZE(*cmd->cmnd));
397
Alan Cox1a68d412006-09-18 19:18:34 +0100398 cp->cp_statDMA = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700399
400 cp->cp_viraddr = cp;
401 cp->cmd = cmd;
402 cmd->host_scribble = (char *) &hd->ccb[y];
403
Boaz Harrosh7410d842007-09-09 21:10:27 +0300404 if (!scsi_bufflen(cmd)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700405 cmd->SCp.buffers_residual = 1;
Boaz Harrosh7410d842007-09-09 21:10:27 +0300406 cmd->SCp.ptr = NULL;
407 cmd->SCp.this_residual = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700408 cmd->SCp.buffer = NULL;
409 } else {
Boaz Harrosh7410d842007-09-09 21:10:27 +0300410 cmd->SCp.buffer = scsi_sglist(cmd);
411 cmd->SCp.buffers_residual = scsi_sg_count(cmd);
Jens Axboe45711f12007-10-22 21:19:53 +0200412 cmd->SCp.ptr = sg_virt(cmd->SCp.buffer);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700413 cmd->SCp.this_residual = cmd->SCp.buffer->length;
414 }
415 cmd->SCp.Status = (cmd->SCp.this_residual != 0); /* TRUE as long as bytes
416 * are to transfer */
417
418 if (eata_pio_send_command(base, EATA_CMD_PIO_SEND_CP)) {
419 cmd->result = DID_BUS_BUSY << 16;
Jeff Garzik017560f2005-10-24 18:04:36 -0400420 scmd_printk(KERN_NOTICE, cmd,
421 "eata_pio_queue pid %ld, HBA busy, "
Matthew Wilcox12a44162007-09-18 19:54:43 -0600422 "returning DID_BUS_BUSY, done.\n", cmd->serial_number);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700423 done(cmd);
424 cp->status = FREE;
Alan Cox1a1d6412007-09-20 15:15:27 +0100425 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700426 }
427 /* FIXME: timeout */
428 while (!(inb(base + HA_RSTATUS) & HA_SDRQ))
429 cpu_relax();
430 outsw(base + HA_RDATA, cp, hd->cplen);
431 outb(EATA_CMD_PIO_TRUNC, base + HA_WCOMMAND);
432 for (x = 0; x < hd->cppadlen; x++)
433 outw(0, base + HA_RDATA);
434
Jeff Garzik017560f2005-10-24 18:04:36 -0400435 DBG(DBG_QUEUE, scmd_printk(KERN_DEBUG, cmd,
436 "Queued base %#.4lx pid: %ld "
Matthew Wilcox12a44162007-09-18 19:54:43 -0600437 "slot %d irq %d\n", sh->base, cmd->serial_number, y, sh->irq));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700438
Alan Cox1a1d6412007-09-20 15:15:27 +0100439 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700440}
441
442static int eata_pio_abort(struct scsi_cmnd *cmd)
443{
Alan Cox1a68d412006-09-18 19:18:34 +0100444 unsigned int loop = 100;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700445
Jeff Garzik017560f2005-10-24 18:04:36 -0400446 DBG(DBG_ABNORM, scmd_printk(KERN_WARNING, cmd,
447 "eata_pio_abort called pid: %ld\n",
Matthew Wilcox12a44162007-09-18 19:54:43 -0600448 cmd->serial_number));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700449
450 while (inb(cmd->device->host->base + HA_RAUXSTAT) & HA_ABUSY)
451 if (--loop == 0) {
452 printk(KERN_WARNING "eata_pio: abort, timeout error.\n");
453 return FAILED;
454 }
455 if (CD(cmd)->status == FREE) {
456 DBG(DBG_ABNORM, printk(KERN_WARNING "Returning: SCSI_ABORT_NOT_RUNNING\n"));
457 return FAILED;
458 }
459 if (CD(cmd)->status == USED) {
460 DBG(DBG_ABNORM, printk(KERN_WARNING "Returning: SCSI_ABORT_BUSY\n"));
461 /* We want to sleep a bit more here */
462 return FAILED; /* SNOOZE */
463 }
464 if (CD(cmd)->status == RESET) {
465 printk(KERN_WARNING "eata_pio: abort, command reset error.\n");
466 return FAILED;
467 }
468 if (CD(cmd)->status == LOCKED) {
469 DBG(DBG_ABNORM, printk(KERN_WARNING "eata_pio: abort, queue slot " "locked.\n"));
470 return FAILED;
471 }
472 panic("eata_pio: abort: invalid slot status\n");
473}
474
475static int eata_pio_host_reset(struct scsi_cmnd *cmd)
476{
Alan Cox1a68d412006-09-18 19:18:34 +0100477 unsigned int x, limit = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700478 unsigned char success = 0;
479 struct scsi_cmnd *sp;
480 struct Scsi_Host *host = cmd->device->host;
481
Jeff Garzik017560f2005-10-24 18:04:36 -0400482 DBG(DBG_ABNORM, scmd_printk(KERN_WARNING, cmd,
483 "eata_pio_reset called pid:%ld\n",
Matthew Wilcox12a44162007-09-18 19:54:43 -0600484 cmd->serial_number));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700485
Jeff Garzik df0ae242005-05-28 07:57:14 -0400486 spin_lock_irq(host->host_lock);
487
Linus Torvalds1da177e2005-04-16 15:20:36 -0700488 if (HD(cmd)->state == RESET) {
489 printk(KERN_WARNING "eata_pio_reset: exit, already in reset.\n");
Jeff Garzik df0ae242005-05-28 07:57:14 -0400490 spin_unlock_irq(host->host_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700491 return FAILED;
492 }
493
494 /* force all slots to be free */
495
496 for (x = 0; x < cmd->device->host->can_queue; x++) {
497
498 if (HD(cmd)->ccb[x].status == FREE)
499 continue;
500
501 sp = HD(cmd)->ccb[x].cmd;
502 HD(cmd)->ccb[x].status = RESET;
Matthew Wilcox12a44162007-09-18 19:54:43 -0600503 printk(KERN_WARNING "eata_pio_reset: slot %d in reset, pid %ld.\n", x, sp->serial_number);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700504
505 if (sp == NULL)
506 panic("eata_pio_reset: slot %d, sp==NULL.\n", x);
507 }
508
509 /* hard reset the HBA */
Alan Cox1a68d412006-09-18 19:18:34 +0100510 outb(EATA_CMD_RESET, cmd->device->host->base + HA_WCOMMAND);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700511
512 DBG(DBG_ABNORM, printk(KERN_WARNING "eata_pio_reset: board reset done.\n"));
513 HD(cmd)->state = RESET;
514
515 spin_unlock_irq(host->host_lock);
516 msleep(3000);
517 spin_lock_irq(host->host_lock);
518
519 DBG(DBG_ABNORM, printk(KERN_WARNING "eata_pio_reset: interrupts disabled, " "loops %d.\n", limit));
520
521 for (x = 0; x < cmd->device->host->can_queue; x++) {
522
523 /* Skip slots already set free by interrupt */
524 if (HD(cmd)->ccb[x].status != RESET)
525 continue;
526
527 sp = HD(cmd)->ccb[x].cmd;
528 sp->result = DID_RESET << 16;
529
530 /* This mailbox is terminated */
531 printk(KERN_WARNING "eata_pio_reset: reset ccb %d.\n", x);
532 HD(cmd)->ccb[x].status = FREE;
533
534 sp->scsi_done(sp);
535 }
536
537 HD(cmd)->state = 0;
538
Jeff Garzik df0ae242005-05-28 07:57:14 -0400539 spin_unlock_irq(host->host_lock);
540
Linus Torvalds1da177e2005-04-16 15:20:36 -0700541 if (success) { /* hmmm... */
542 DBG(DBG_ABNORM, printk(KERN_WARNING "eata_pio_reset: exit, success.\n"));
543 return SUCCESS;
544 } else {
545 DBG(DBG_ABNORM, printk(KERN_WARNING "eata_pio_reset: exit, wakeup.\n"));
546 return FAILED;
547 }
548}
549
Alan Cox1a68d412006-09-18 19:18:34 +0100550static char *get_pio_board_data(unsigned long base, unsigned int irq, unsigned int id, unsigned long cplen, unsigned short cppadlen)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700551{
552 struct eata_ccb cp;
553 static char buff[256];
554 int z;
555
556 memset(&cp, 0, sizeof(struct eata_ccb));
557 memset(buff, 0, sizeof(buff));
558
559 cp.DataIn = 1;
560 cp.Interpret = 1; /* Interpret command */
561
Alan Cox1a68d412006-09-18 19:18:34 +0100562 cp.cp_datalen = cpu_to_be32(254);
563 cp.cp_dataDMA = cpu_to_be32(0);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700564
565 cp.cp_id = id;
566 cp.cp_lun = 0;
567
568 cp.cp_cdb[0] = INQUIRY;
569 cp.cp_cdb[1] = 0;
570 cp.cp_cdb[2] = 0;
571 cp.cp_cdb[3] = 0;
572 cp.cp_cdb[4] = 254;
573 cp.cp_cdb[5] = 0;
574
Alan Cox1a68d412006-09-18 19:18:34 +0100575 if (eata_pio_send_command(base, EATA_CMD_PIO_SEND_CP))
Alan Cox1a1d6412007-09-20 15:15:27 +0100576 return NULL;
577
578 while (!(inb(base + HA_RSTATUS) & HA_SDRQ))
579 cpu_relax();
580
Linus Torvalds1da177e2005-04-16 15:20:36 -0700581 outsw(base + HA_RDATA, &cp, cplen);
582 outb(EATA_CMD_PIO_TRUNC, base + HA_WCOMMAND);
583 for (z = 0; z < cppadlen; z++)
584 outw(0, base + HA_RDATA);
585
Alan Cox1a1d6412007-09-20 15:15:27 +0100586 while (inb(base + HA_RSTATUS) & HA_SBUSY)
587 cpu_relax();
588
Linus Torvalds1da177e2005-04-16 15:20:36 -0700589 if (inb(base + HA_RSTATUS) & HA_SERROR)
Alan Cox1a1d6412007-09-20 15:15:27 +0100590 return NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700591 else if (!(inb(base + HA_RSTATUS) & HA_SDRQ))
Alan Cox1a1d6412007-09-20 15:15:27 +0100592 return NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700593 else {
594 insw(base + HA_RDATA, &buff, 127);
595 while (inb(base + HA_RSTATUS) & HA_SDRQ)
596 inw(base + HA_RDATA);
Alan Cox1a1d6412007-09-20 15:15:27 +0100597 return buff;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700598 }
599}
600
Alan Cox1a68d412006-09-18 19:18:34 +0100601static int get_pio_conf_PIO(unsigned long base, struct get_conf *buf)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700602{
603 unsigned long loop = HZ / 2;
604 int z;
605 unsigned short *p;
606
607 if (!request_region(base, 9, "eata_pio"))
608 return 0;
609
610 memset(buf, 0, sizeof(struct get_conf));
611
612 while (inb(base + HA_RSTATUS) & HA_SBUSY)
613 if (--loop == 0)
614 goto fail;
615
Alan Cox1a68d412006-09-18 19:18:34 +0100616 DBG(DBG_PIO && DBG_PROBE, printk(KERN_DEBUG "Issuing PIO READ CONFIG to HBA at %#lx\n", base));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700617 eata_pio_send_command(base, EATA_CMD_PIO_READ_CONFIG);
618
Alan Cox1a68d412006-09-18 19:18:34 +0100619 loop = 50;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700620 for (p = (unsigned short *) buf; (long) p <= ((long) buf + (sizeof(struct get_conf) / 2)); p++) {
621 while (!(inb(base + HA_RSTATUS) & HA_SDRQ))
622 if (--loop == 0)
623 goto fail;
624
Alan Cox1a68d412006-09-18 19:18:34 +0100625 loop = 50;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700626 *p = inw(base + HA_RDATA);
627 }
628 if (inb(base + HA_RSTATUS) & HA_SERROR) {
629 DBG(DBG_PROBE, printk("eata_dma: get_conf_PIO, error during "
Alan Cox1a68d412006-09-18 19:18:34 +0100630 "transfer for HBA at %lx\n", base));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700631 goto fail;
632 }
633
Alan Cox1a68d412006-09-18 19:18:34 +0100634 if (cpu_to_be32(EATA_SIGNATURE) != buf->signature)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700635 goto fail;
636
637 DBG(DBG_PIO && DBG_PROBE, printk(KERN_NOTICE "EATA Controller found "
Alan Cox1a68d412006-09-18 19:18:34 +0100638 "at %#4lx EATA Level: %x\n",
639 base, (unsigned int) (buf->version)));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700640
641 while (inb(base + HA_RSTATUS) & HA_SDRQ)
642 inw(base + HA_RDATA);
643
644 if (!ALLOW_DMA_BOARDS) {
645 for (z = 0; z < MAXISA; z++)
646 if (base == ISAbases[z]) {
647 buf->IRQ = ISAirqs[z];
648 break;
649 }
650 }
651
652 return 1;
653
654 fail:
655 release_region(base, 9);
656 return 0;
657}
658
659static void print_pio_config(struct get_conf *gc)
660{
661 printk("Please check values: (read config data)\n");
Alan Cox1a68d412006-09-18 19:18:34 +0100662 printk("LEN: %d ver:%d OCS:%d TAR:%d TRNXFR:%d MORES:%d\n", be32_to_cpu(gc->len), gc->version, gc->OCS_enabled, gc->TAR_support, gc->TRNXFR, gc->MORE_support);
663 printk("HAAV:%d SCSIID0:%d ID1:%d ID2:%d QUEUE:%d SG:%d SEC:%d\n", gc->HAA_valid, gc->scsi_id[3], gc->scsi_id[2], gc->scsi_id[1], be16_to_cpu(gc->queuesiz), be16_to_cpu(gc->SGsiz), gc->SECOND);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700664 printk("IRQ:%d IRQT:%d FORCADR:%d MCH:%d RIDQ:%d\n", gc->IRQ, gc->IRQ_TR, gc->FORCADR, gc->MAX_CHAN, gc->ID_qest);
665}
666
Alan Cox1a68d412006-09-18 19:18:34 +0100667static unsigned int print_selftest(unsigned int base)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700668{
669 unsigned char buffer[512];
670#ifdef VERBOSE_SETUP
671 int z;
672#endif
673
674 printk("eata_pio: executing controller self test & setup...\n");
675 while (inb(base + HA_RSTATUS) & HA_SBUSY);
676 outb(EATA_CMD_PIO_SETUPTEST, base + HA_WCOMMAND);
677 do {
678 while (inb(base + HA_RSTATUS) & HA_SBUSY)
679 /* nothing */ ;
680 if (inb(base + HA_RSTATUS) & HA_SDRQ) {
681 insw(base + HA_RDATA, &buffer, 256);
682#ifdef VERBOSE_SETUP
683 /* no beeps please... */
684 for (z = 0; z < 511 && buffer[z]; z++)
685 if (buffer[z] != 7)
686 printk("%c", buffer[z]);
687#endif
688 }
689 } while (inb(base + HA_RSTATUS) & (HA_SBUSY | HA_SDRQ));
690
691 return (!(inb(base + HA_RSTATUS) & HA_SERROR));
692}
693
Alan Cox1a68d412006-09-18 19:18:34 +0100694static int register_pio_HBA(long base, struct get_conf *gc, struct pci_dev *pdev)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700695{
696 unsigned long size = 0;
697 char *buff;
698 unsigned long cplen;
699 unsigned short cppadlen;
700 struct Scsi_Host *sh;
701 hostdata *hd;
702
703 DBG(DBG_REGISTER, print_pio_config(gc));
704
705 if (gc->DMA_support) {
706 printk("HBA at %#.4lx supports DMA. Please use EATA-DMA driver.\n", base);
707 if (!ALLOW_DMA_BOARDS)
708 return 0;
709 }
710
Alan Cox1a68d412006-09-18 19:18:34 +0100711 if ((buff = get_pio_board_data(base, gc->IRQ, gc->scsi_id[3], cplen = (cpu_to_be32(gc->cplen) + 1) / 2, cppadlen = (cpu_to_be16(gc->cppadlen) + 1) / 2)) == NULL) {
712 printk("HBA at %#lx didn't react on INQUIRY. Sorry.\n", base);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700713 return 0;
714 }
715
716 if (!print_selftest(base) && !ALLOW_DMA_BOARDS) {
Alan Cox1a68d412006-09-18 19:18:34 +0100717 printk("HBA at %#lx failed while performing self test & setup.\n", base);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700718 return 0;
719 }
720
Alan Cox1a68d412006-09-18 19:18:34 +0100721 size = sizeof(hostdata) + (sizeof(struct eata_ccb) * be16_to_cpu(gc->queuesiz));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700722
723 sh = scsi_register(&driver_template, size);
724 if (sh == NULL)
725 return 0;
726
727 if (!reg_IRQ[gc->IRQ]) { /* Interrupt already registered ? */
Thomas Gleixner1d6f3592006-07-01 19:29:42 -0700728 if (!request_irq(gc->IRQ, do_eata_pio_int_handler, IRQF_DISABLED, "EATA-PIO", sh)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700729 reg_IRQ[gc->IRQ]++;
730 if (!gc->IRQ_TR)
731 reg_IRQL[gc->IRQ] = 1; /* IRQ is edge triggered */
732 } else {
733 printk("Couldn't allocate IRQ %d, Sorry.\n", gc->IRQ);
734 return 0;
735 }
736 } else { /* More than one HBA on this IRQ */
737 if (reg_IRQL[gc->IRQ]) {
738 printk("Can't support more than one HBA on this IRQ,\n" " if the IRQ is edge triggered. Sorry.\n");
739 return 0;
740 } else
741 reg_IRQ[gc->IRQ]++;
742 }
743
744 hd = SD(sh);
745
Alan Cox1a68d412006-09-18 19:18:34 +0100746 memset(hd->ccb, 0, (sizeof(struct eata_ccb) * be16_to_cpu(gc->queuesiz)));
747 memset(hd->reads, 0, sizeof(hd->reads));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700748
749 strlcpy(SD(sh)->vendor, &buff[8], sizeof(SD(sh)->vendor));
750 strlcpy(SD(sh)->name, &buff[16], sizeof(SD(sh)->name));
751 SD(sh)->revision[0] = buff[32];
752 SD(sh)->revision[1] = buff[33];
753 SD(sh)->revision[2] = buff[34];
754 SD(sh)->revision[3] = '.';
755 SD(sh)->revision[4] = buff[35];
756 SD(sh)->revision[5] = 0;
757
Alan Cox1a68d412006-09-18 19:18:34 +0100758 switch (be32_to_cpu(gc->len)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700759 case 0x1c:
760 SD(sh)->EATA_revision = 'a';
761 break;
762 case 0x1e:
763 SD(sh)->EATA_revision = 'b';
764 break;
765 case 0x22:
766 SD(sh)->EATA_revision = 'c';
767 break;
768 case 0x24:
769 SD(sh)->EATA_revision = 'z';
770 default:
771 SD(sh)->EATA_revision = '?';
772 }
773
Alan Cox1a68d412006-09-18 19:18:34 +0100774 if (be32_to_cpu(gc->len) >= 0x22) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700775 if (gc->is_PCI)
776 hd->bustype = IS_PCI;
777 else if (gc->is_EISA)
778 hd->bustype = IS_EISA;
779 else
780 hd->bustype = IS_ISA;
781 } else {
782 if (buff[21] == '4')
783 hd->bustype = IS_PCI;
784 else if (buff[21] == '2')
785 hd->bustype = IS_EISA;
786 else
787 hd->bustype = IS_ISA;
788 }
789
790 SD(sh)->cplen = cplen;
791 SD(sh)->cppadlen = cppadlen;
792 SD(sh)->hostid = gc->scsi_id[3];
793 SD(sh)->devflags = 1 << gc->scsi_id[3];
794 SD(sh)->moresupport = gc->MORE_support;
795 sh->unique_id = base;
796 sh->base = base;
797 sh->io_port = base;
798 sh->n_io_port = 9;
799 sh->irq = gc->IRQ;
800 sh->dma_channel = PIO;
801 sh->this_id = gc->scsi_id[3];
802 sh->can_queue = 1;
803 sh->cmd_per_lun = 1;
804 sh->sg_tablesize = SG_ALL;
805
806 hd->channel = 0;
807
Alan Cox1a68d412006-09-18 19:18:34 +0100808 hd->pdev = pci_dev_get(pdev); /* Keep a PCI reference */
809
Linus Torvalds1da177e2005-04-16 15:20:36 -0700810 sh->max_id = 8;
811 sh->max_lun = 8;
812
813 if (gc->SECOND)
814 hd->primary = 0;
815 else
816 hd->primary = 1;
817
Linus Torvalds1da177e2005-04-16 15:20:36 -0700818 hd->next = NULL; /* build a linked list of all HBAs */
819 hd->prev = last_HBA;
820 if (hd->prev != NULL)
821 SD(hd->prev)->next = sh;
822 last_HBA = sh;
823 if (first_HBA == NULL)
824 first_HBA = sh;
825 registered_HBAs++;
826 return (1);
827}
828
829static void find_pio_ISA(struct get_conf *buf)
830{
831 int i;
832
833 for (i = 0; i < MAXISA; i++) {
834 if (!ISAbases[i])
835 continue;
836 if (!get_pio_conf_PIO(ISAbases[i], buf))
837 continue;
Alan Cox1a68d412006-09-18 19:18:34 +0100838 if (!register_pio_HBA(ISAbases[i], buf, NULL))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700839 release_region(ISAbases[i], 9);
840 else
841 ISAbases[i] = 0;
842 }
843 return;
844}
845
846static void find_pio_EISA(struct get_conf *buf)
847{
848 u32 base;
849 int i;
850
851#ifdef CHECKPAL
852 u8 pal1, pal2, pal3;
853#endif
854
855 for (i = 0; i < MAXEISA; i++) {
856 if (EISAbases[i]) { /* Still a possibility ? */
857
858 base = 0x1c88 + (i * 0x1000);
859#ifdef CHECKPAL
860 pal1 = inb((u16) base - 8);
861 pal2 = inb((u16) base - 7);
862 pal3 = inb((u16) base - 6);
863
864 if (((pal1 == 0x12) && (pal2 == 0x14)) || ((pal1 == 0x38) && (pal2 == 0xa3) && (pal3 == 0x82)) || ((pal1 == 0x06) && (pal2 == 0x94) && (pal3 == 0x24))) {
865 DBG(DBG_PROBE, printk(KERN_NOTICE "EISA EATA id tags found: " "%x %x %x \n", (int) pal1, (int) pal2, (int) pal3));
866#endif
867 if (get_pio_conf_PIO(base, buf)) {
868 DBG(DBG_PROBE && DBG_EISA, print_pio_config(buf));
869 if (buf->IRQ) {
Alan Cox1a68d412006-09-18 19:18:34 +0100870 if (!register_pio_HBA(base, buf, NULL))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700871 release_region(base, 9);
872 } else {
873 printk(KERN_NOTICE "eata_dma: No valid IRQ. HBA " "removed from list\n");
874 release_region(base, 9);
875 }
876 }
877 /* Nothing found here so we take it from the list */
878 EISAbases[i] = 0;
879#ifdef CHECKPAL
880 }
881#endif
882 }
883 }
884 return;
885}
886
887static void find_pio_PCI(struct get_conf *buf)
888{
889#ifndef CONFIG_PCI
890 printk("eata_dma: kernel PCI support not enabled. Skipping scan for PCI HBAs.\n");
891#else
892 struct pci_dev *dev = NULL;
Alan Cox1a68d412006-09-18 19:18:34 +0100893 unsigned long base, x;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700894
Alan Cox1a68d412006-09-18 19:18:34 +0100895 while ((dev = pci_get_device(PCI_VENDOR_ID_DPT, PCI_DEVICE_ID_DPT, dev)) != NULL) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700896 DBG(DBG_PROBE && DBG_PCI, printk("eata_pio: find_PCI, HBA at %s\n", pci_name(dev)));
897 if (pci_enable_device(dev))
898 continue;
899 pci_set_master(dev);
900 base = pci_resource_flags(dev, 0);
901 if (base & IORESOURCE_MEM) {
902 printk("eata_pio: invalid base address of device %s\n", pci_name(dev));
903 continue;
904 }
905 base = pci_resource_start(dev, 0);
906 /* EISA tag there ? */
907 if ((inb(base) == 0x12) && (inb(base + 1) == 0x14))
908 continue; /* Jep, it's forced, so move on */
909 base += 0x10; /* Now, THIS is the real address */
910 if (base != 0x1f8) {
911 /* We didn't find it in the primary search */
912 if (get_pio_conf_PIO(base, buf)) {
913 if (buf->FORCADR) { /* If the address is forced */
914 release_region(base, 9);
915 continue; /* we'll find it later */
916 }
917
918 /* OK. We made it till here, so we can go now
919 * and register it. We only have to check and
920 * eventually remove it from the EISA and ISA list
921 */
922
Alan Cox1a68d412006-09-18 19:18:34 +0100923 if (!register_pio_HBA(base, buf, dev)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700924 release_region(base, 9);
925 continue;
926 }
927
928 if (base < 0x1000) {
929 for (x = 0; x < MAXISA; ++x) {
930 if (ISAbases[x] == base) {
931 ISAbases[x] = 0;
932 break;
933 }
934 }
935 } else if ((base & 0x0fff) == 0x0c88) {
936 x = (base >> 12) & 0x0f;
937 EISAbases[x] = 0;
938 }
939 }
940#ifdef CHECK_BLINK
941 else if (check_blink_state(base)) {
942 printk("eata_pio: HBA is in BLINK state.\n" "Consult your HBAs manual to correct this.\n");
943 }
944#endif
945 }
946 }
947#endif /* #ifndef CONFIG_PCI */
948}
949
950static int eata_pio_detect(struct scsi_host_template *tpnt)
951{
952 struct Scsi_Host *HBA_ptr;
953 struct get_conf gc;
954 int i;
955
956 find_pio_PCI(&gc);
957 find_pio_EISA(&gc);
958 find_pio_ISA(&gc);
959
960 for (i = 0; i <= MAXIRQ; i++)
961 if (reg_IRQ[i])
Thomas Gleixner1d6f3592006-07-01 19:29:42 -0700962 request_irq(i, do_eata_pio_int_handler, IRQF_DISABLED, "EATA-PIO", NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700963
964 HBA_ptr = first_HBA;
965
966 if (registered_HBAs != 0) {
967 printk("EATA (Extended Attachment) PIO driver version: %d.%d%s\n"
968 "(c) 1993-95 Michael Neuffer, neuffer@goofy.zdv.uni-mainz.de\n" " Alfred Arnold, a.arnold@kfa-juelich.de\n" "This release only supports DASD devices (harddisks)\n", VER_MAJOR, VER_MINOR, VER_SUB);
969
970 printk("Registered HBAs:\n");
971 printk("HBA no. Boardtype: Revis: EATA: Bus: BaseIO: IRQ: Ch: ID: Pr:" " QS: SG: CPL:\n");
972 for (i = 1; i <= registered_HBAs; i++) {
Alan Cox1a68d412006-09-18 19:18:34 +0100973 printk("scsi%-2d: %.10s v%s 2.0%c %s %#.4lx %2d %d %d %c"
Linus Torvalds1da177e2005-04-16 15:20:36 -0700974 " %2d %2d %2d\n",
975 HBA_ptr->host_no, SD(HBA_ptr)->name, SD(HBA_ptr)->revision,
976 SD(HBA_ptr)->EATA_revision, (SD(HBA_ptr)->bustype == 'P') ?
977 "PCI " : (SD(HBA_ptr)->bustype == 'E') ? "EISA" : "ISA ",
Alan Cox1a68d412006-09-18 19:18:34 +0100978 HBA_ptr->base, HBA_ptr->irq, SD(HBA_ptr)->channel, HBA_ptr->this_id,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700979 SD(HBA_ptr)->primary ? 'Y' : 'N', HBA_ptr->can_queue,
980 HBA_ptr->sg_tablesize, HBA_ptr->cmd_per_lun);
981 HBA_ptr = SD(HBA_ptr)->next;
982 }
983 }
984 return (registered_HBAs);
985}
986
987static struct scsi_host_template driver_template = {
988 .proc_name = "eata_pio",
989 .name = "EATA (Extended Attachment) PIO driver",
990 .proc_info = eata_pio_proc_info,
991 .detect = eata_pio_detect,
992 .release = eata_pio_release,
993 .queuecommand = eata_pio_queue,
994 .eh_abort_handler = eata_pio_abort,
995 .eh_host_reset_handler = eata_pio_host_reset,
996 .use_clustering = ENABLE_CLUSTERING,
997};
998
999MODULE_AUTHOR("Michael Neuffer, Alfred Arnold");
1000MODULE_DESCRIPTION("EATA SCSI PIO driver");
1001MODULE_LICENSE("GPL");
1002
1003#include "scsi_module.c"