blob: 60886c19065e290a4475822d183aa92c8dc4de0c [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>
Linus Torvalds1da177e2005-04-16 15:20:36 -070053#include <linux/in.h>
54#include <linux/pci.h>
55#include <linux/proc_fs.h>
56#include <linux/interrupt.h>
57#include <linux/blkdev.h>
58#include <linux/spinlock.h>
59#include <linux/delay.h>
60
61#include <asm/io.h>
62
63#include <scsi/scsi.h>
64#include <scsi/scsi_cmnd.h>
65#include <scsi/scsi_device.h>
66#include <scsi/scsi_host.h>
67
68#include "eata_generic.h"
69#include "eata_pio.h"
70
71
Alan Cox1a68d412006-09-18 19:18:34 +010072static unsigned int ISAbases[MAXISA] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070073 0x1F0, 0x170, 0x330, 0x230
74};
75
Alan Cox1a68d412006-09-18 19:18:34 +010076static unsigned int ISAirqs[MAXISA] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070077 14, 12, 15, 11
78};
79
80static unsigned char EISAbases[] = {
81 1, 1, 1, 1, 1, 1, 1, 1,
82 1, 1, 1, 1, 1, 1, 1, 1
83};
84
Alan Cox1a68d412006-09-18 19:18:34 +010085static unsigned int registered_HBAs;
Linus Torvalds1da177e2005-04-16 15:20:36 -070086static struct Scsi_Host *last_HBA;
87static struct Scsi_Host *first_HBA;
88static unsigned char reg_IRQ[16];
89static unsigned char reg_IRQL[16];
90static unsigned long int_counter;
91static unsigned long queue_counter;
92
93static struct scsi_host_template driver_template;
94
95/*
96 * eata_proc_info
97 * inout : decides on the direction of the dataflow and the meaning of the
98 * variables
99 * buffer: If inout==FALSE data is being written to it else read from it
100 * *start: If inout==FALSE start of the valid data in the buffer
101 * offset: If inout==FALSE offset from the beginning of the imaginary file
102 * from which we start writing into the buffer
103 * length: If inout==FALSE max number of bytes to be written into the buffer
104 * else number of bytes in the buffer
105 */
106static int eata_pio_proc_info(struct Scsi_Host *shost, char *buffer, char **start, off_t offset,
107 int length, int rw)
108{
Alan Cox1a1d6412007-09-20 15:15:27 +0100109 int len = 0;
110 off_t begin = 0, pos = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700111
Alan Cox1a1d6412007-09-20 15:15:27 +0100112 if (rw)
113 return -ENOSYS;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700114
Alan Cox1a1d6412007-09-20 15:15:27 +0100115 len += sprintf(buffer+len, "EATA (Extended Attachment) PIO driver version: "
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116 "%d.%d%s\n",VER_MAJOR, VER_MINOR, VER_SUB);
Alan Cox1a1d6412007-09-20 15:15:27 +0100117 len += sprintf(buffer + len, "queued commands: %10ld\n"
Linus Torvalds1da177e2005-04-16 15:20:36 -0700118 "processed interrupts:%10ld\n", queue_counter, int_counter);
Alan Cox1a1d6412007-09-20 15:15:27 +0100119 len += sprintf(buffer + len, "\nscsi%-2d: HBA %.10s\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700120 shost->host_no, SD(shost)->name);
Alan Cox1a1d6412007-09-20 15:15:27 +0100121 len += sprintf(buffer + len, "Firmware revision: v%s\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700122 SD(shost)->revision);
Alan Cox1a1d6412007-09-20 15:15:27 +0100123 len += sprintf(buffer + len, "IO: PIO\n");
124 len += sprintf(buffer + len, "Base IO : %#.4x\n", (u32) shost->base);
125 len += sprintf(buffer + len, "Host Bus: %s\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700126 (SD(shost)->bustype == 'P')?"PCI ":
127 (SD(shost)->bustype == 'E')?"EISA":"ISA ");
128
Alan Cox1a1d6412007-09-20 15:15:27 +0100129 pos = begin + len;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700130
Alan Cox1a1d6412007-09-20 15:15:27 +0100131 if (pos < offset) {
132 len = 0;
133 begin = pos;
134 }
135 if (pos > offset + length)
136 goto stop_output;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700137
Alan Cox1a1d6412007-09-20 15:15:27 +0100138stop_output:
139 DBG(DBG_PROC, printk("2pos: %ld offset: %ld len: %d\n", pos, offset, len));
140 *start = buffer + (offset - begin); /* Start of wanted data */
141 len -= (offset - begin); /* Start slop */
142 if (len > length)
143 len = length; /* Ending slop */
144 DBG(DBG_PROC, printk("3pos: %ld offset: %ld len: %d\n", pos, offset, len));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700145
Alan Cox1a1d6412007-09-20 15:15:27 +0100146 return len;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700147}
148
149static int eata_pio_release(struct Scsi_Host *sh)
150{
Alan Cox1a68d412006-09-18 19:18:34 +0100151 hostdata *hd = SD(sh);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700152 if (sh->irq && reg_IRQ[sh->irq] == 1)
153 free_irq(sh->irq, NULL);
154 else
155 reg_IRQ[sh->irq]--;
156 if (SD(sh)->channel == 0) {
157 if (sh->io_port && sh->n_io_port)
158 release_region(sh->io_port, sh->n_io_port);
159 }
Alan Cox1a68d412006-09-18 19:18:34 +0100160 /* At this point the PCI reference can go */
161 if (hd->pdev)
162 pci_dev_put(hd->pdev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700163 return 1;
164}
165
Alan Cox1a68d412006-09-18 19:18:34 +0100166static void IncStat(struct scsi_pointer *SCp, unsigned int Increment)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700167{
168 SCp->ptr += Increment;
169 if ((SCp->this_residual -= Increment) == 0) {
170 if ((--SCp->buffers_residual) == 0)
171 SCp->Status = 0;
172 else {
173 SCp->buffer++;
Jens Axboe45711f12007-10-22 21:19:53 +0200174 SCp->ptr = sg_virt(SCp->buffer);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700175 SCp->this_residual = SCp->buffer->length;
176 }
177 }
178}
179
David Howells7d12e782006-10-05 14:55:46 +0100180static irqreturn_t eata_pio_int_handler(int irq, void *dev_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700181
David Howells7d12e782006-10-05 14:55:46 +0100182static irqreturn_t do_eata_pio_int_handler(int irq, void *dev_id)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700183{
184 unsigned long flags;
185 struct Scsi_Host *dev = dev_id;
Alan Cox1a68d412006-09-18 19:18:34 +0100186 irqreturn_t ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700187
188 spin_lock_irqsave(dev->host_lock, flags);
Alan Coxa31baca2006-10-19 23:28:33 -0700189 ret = eata_pio_int_handler(irq, dev_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700190 spin_unlock_irqrestore(dev->host_lock, flags);
Alan Cox1a68d412006-09-18 19:18:34 +0100191 return ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700192}
193
David Howells7d12e782006-10-05 14:55:46 +0100194static irqreturn_t eata_pio_int_handler(int irq, void *dev_id)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700195{
Alan Cox1a68d412006-09-18 19:18:34 +0100196 unsigned int eata_stat = 0xfffff;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700197 struct scsi_cmnd *cmd;
198 hostdata *hd;
199 struct eata_ccb *cp;
Alan Cox1a68d412006-09-18 19:18:34 +0100200 unsigned long base;
201 unsigned int x, z;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700202 struct Scsi_Host *sh;
203 unsigned short zwickel = 0;
204 unsigned char stat, odd;
Alan Cox1a68d412006-09-18 19:18:34 +0100205 irqreturn_t ret = IRQ_NONE;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700206
207 for (x = 1, sh = first_HBA; x <= registered_HBAs; x++, sh = SD(sh)->prev)
208 {
209 if (sh->irq != irq)
210 continue;
Alan Cox1a68d412006-09-18 19:18:34 +0100211 if (inb(sh->base + HA_RSTATUS) & HA_SBUSY)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700212 continue;
213
214 int_counter++;
Alan Cox1a68d412006-09-18 19:18:34 +0100215 ret = IRQ_HANDLED;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700216
217 hd = SD(sh);
218
219 cp = &hd->ccb[0];
220 cmd = cp->cmd;
Alan Cox1a68d412006-09-18 19:18:34 +0100221 base = cmd->device->host->base;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700222
223 do {
224 stat = inb(base + HA_RSTATUS);
225 if (stat & HA_SDRQ) {
226 if (cp->DataIn) {
227 z = 256;
228 odd = 0;
229 while ((cmd->SCp.Status) && ((z > 0) || (odd))) {
230 if (odd) {
231 *(cmd->SCp.ptr) = zwickel >> 8;
232 IncStat(&cmd->SCp, 1);
233 odd = 0;
234 }
235 x = min_t(unsigned int, z, cmd->SCp.this_residual / 2);
236 insw(base + HA_RDATA, cmd->SCp.ptr, x);
237 z -= x;
238 IncStat(&cmd->SCp, 2 * x);
239 if ((z > 0) && (cmd->SCp.this_residual == 1)) {
240 zwickel = inw(base + HA_RDATA);
241 *(cmd->SCp.ptr) = zwickel & 0xff;
242 IncStat(&cmd->SCp, 1);
243 z--;
244 odd = 1;
245 }
246 }
247 while (z > 0) {
248 zwickel = inw(base + HA_RDATA);
249 z--;
250 }
251 } else { /* cp->DataOut */
252
253 odd = 0;
254 z = 256;
255 while ((cmd->SCp.Status) && ((z > 0) || (odd))) {
256 if (odd) {
257 zwickel += *(cmd->SCp.ptr) << 8;
258 IncStat(&cmd->SCp, 1);
259 outw(zwickel, base + HA_RDATA);
260 z--;
261 odd = 0;
262 }
263 x = min_t(unsigned int, z, cmd->SCp.this_residual / 2);
264 outsw(base + HA_RDATA, cmd->SCp.ptr, x);
265 z -= x;
266 IncStat(&cmd->SCp, 2 * x);
267 if ((z > 0) && (cmd->SCp.this_residual == 1)) {
268 zwickel = *(cmd->SCp.ptr);
269 zwickel &= 0xff;
270 IncStat(&cmd->SCp, 1);
271 odd = 1;
272 }
273 }
274 while (z > 0 || odd) {
275 outw(zwickel, base + HA_RDATA);
276 z--;
277 odd = 0;
278 }
279 }
280 }
281 }
282 while ((stat & HA_SDRQ) || ((stat & HA_SMORE) && hd->moresupport));
283
284 /* terminate handler if HBA goes busy again, i.e. transfers
285 * more data */
286
287 if (stat & HA_SBUSY)
288 break;
289
290 /* OK, this is quite stupid, but I haven't found any correct
291 * way to get HBA&SCSI status so far */
292
293 if (!(inb(base + HA_RSTATUS) & HA_SERROR)) {
294 cmd->result = (DID_OK << 16);
295 hd->devflags |= (1 << cp->cp_id);
Alan Cox1a68d412006-09-18 19:18:34 +0100296 } else if (hd->devflags & (1 << cp->cp_id))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700297 cmd->result = (DID_OK << 16) + 0x02;
298 else
299 cmd->result = (DID_NO_CONNECT << 16);
300
301 if (cp->status == LOCKED) {
302 cp->status = FREE;
303 eata_stat = inb(base + HA_RSTATUS);
304 printk(KERN_CRIT "eata_pio: int_handler, freeing locked " "queueslot\n");
Alan Cox1a68d412006-09-18 19:18:34 +0100305 return ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700306 }
307#if DBG_INTR2
308 if (stat != 0x50)
309 printk(KERN_DEBUG "stat: %#.2x, result: %#.8x\n", stat, cmd->result);
310#endif
311
312 cp->status = FREE; /* now we can release the slot */
313
314 cmd->scsi_done(cmd);
315 }
316
Alan Cox1a68d412006-09-18 19:18:34 +0100317 return ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700318}
319
Alan Cox1a68d412006-09-18 19:18:34 +0100320static inline unsigned int eata_pio_send_command(unsigned long base, unsigned char command)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700321{
Alan Cox1a68d412006-09-18 19:18:34 +0100322 unsigned int loop = 50;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700323
324 while (inb(base + HA_RSTATUS) & HA_SBUSY)
325 if (--loop == 0)
326 return 1;
327
328 /* Enable interrupts for HBA. It is not the best way to do it at this
329 * place, but I hope that it doesn't interfere with the IDE driver
330 * initialization this way */
331
332 outb(HA_CTRL_8HEADS, base + HA_CTRLREG);
333
334 outb(command, base + HA_WCOMMAND);
335 return 0;
336}
337
338static int eata_pio_queue(struct scsi_cmnd *cmd,
339 void (*done)(struct scsi_cmnd *))
340{
Alan Cox1a68d412006-09-18 19:18:34 +0100341 unsigned int x, y;
342 unsigned long base;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700343
344 hostdata *hd;
345 struct Scsi_Host *sh;
346 struct eata_ccb *cp;
347
348 queue_counter++;
349
350 hd = HD(cmd);
351 sh = cmd->device->host;
Alan Cox1a68d412006-09-18 19:18:34 +0100352 base = sh->base;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700353
354 /* use only slot 0, as 2001 can handle only one cmd at a time */
355
356 y = x = 0;
357
358 if (hd->ccb[y].status != FREE) {
359
360 DBG(DBG_QUEUE, printk(KERN_EMERG "can_queue %d, x %d, y %d\n", sh->can_queue, x, y));
361#if DEBUG_EATA
362 panic(KERN_EMERG "eata_pio: run out of queue slots cmdno:%ld " "intrno: %ld\n", queue_counter, int_counter);
363#else
364 panic(KERN_EMERG "eata_pio: run out of queue slots....\n");
365#endif
366 }
367
368 cp = &hd->ccb[y];
369
370 memset(cp, 0, sizeof(struct eata_ccb));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700371
372 cp->status = USED; /* claim free slot */
373
Jeff Garzik017560f2005-10-24 18:04:36 -0400374 DBG(DBG_QUEUE, scmd_printk(KERN_DEBUG, cmd,
375 "eata_pio_queue pid %ld, y %d\n",
Matthew Wilcox12a44162007-09-18 19:54:43 -0600376 cmd->serial_number, y));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700377
378 cmd->scsi_done = (void *) done;
379
380 if (cmd->sc_data_direction == DMA_TO_DEVICE)
381 cp->DataOut = 1; /* Output mode */
382 else
383 cp->DataIn = 0; /* Input mode */
384
385 cp->Interpret = (cmd->device->id == hd->hostid);
Boaz Harrosh7410d842007-09-09 21:10:27 +0300386 cp->cp_datalen = cpu_to_be32(scsi_bufflen(cmd));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700387 cp->Auto_Req_Sen = 0;
Alan Cox1a68d412006-09-18 19:18:34 +0100388 cp->cp_reqDMA = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700389 cp->reqlen = 0;
390
391 cp->cp_id = cmd->device->id;
392 cp->cp_lun = cmd->device->lun;
393 cp->cp_dispri = 0;
394 cp->cp_identify = 1;
395 memcpy(cp->cp_cdb, cmd->cmnd, COMMAND_SIZE(*cmd->cmnd));
396
Alan Cox1a68d412006-09-18 19:18:34 +0100397 cp->cp_statDMA = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700398
399 cp->cp_viraddr = cp;
400 cp->cmd = cmd;
401 cmd->host_scribble = (char *) &hd->ccb[y];
402
Boaz Harrosh7410d842007-09-09 21:10:27 +0300403 if (!scsi_bufflen(cmd)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700404 cmd->SCp.buffers_residual = 1;
Boaz Harrosh7410d842007-09-09 21:10:27 +0300405 cmd->SCp.ptr = NULL;
406 cmd->SCp.this_residual = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700407 cmd->SCp.buffer = NULL;
408 } else {
Boaz Harrosh7410d842007-09-09 21:10:27 +0300409 cmd->SCp.buffer = scsi_sglist(cmd);
410 cmd->SCp.buffers_residual = scsi_sg_count(cmd);
Jens Axboe45711f12007-10-22 21:19:53 +0200411 cmd->SCp.ptr = sg_virt(cmd->SCp.buffer);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700412 cmd->SCp.this_residual = cmd->SCp.buffer->length;
413 }
414 cmd->SCp.Status = (cmd->SCp.this_residual != 0); /* TRUE as long as bytes
415 * are to transfer */
416
417 if (eata_pio_send_command(base, EATA_CMD_PIO_SEND_CP)) {
418 cmd->result = DID_BUS_BUSY << 16;
Jeff Garzik017560f2005-10-24 18:04:36 -0400419 scmd_printk(KERN_NOTICE, cmd,
420 "eata_pio_queue pid %ld, HBA busy, "
Matthew Wilcox12a44162007-09-18 19:54:43 -0600421 "returning DID_BUS_BUSY, done.\n", cmd->serial_number);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700422 done(cmd);
423 cp->status = FREE;
Alan Cox1a1d6412007-09-20 15:15:27 +0100424 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700425 }
426 /* FIXME: timeout */
427 while (!(inb(base + HA_RSTATUS) & HA_SDRQ))
428 cpu_relax();
429 outsw(base + HA_RDATA, cp, hd->cplen);
430 outb(EATA_CMD_PIO_TRUNC, base + HA_WCOMMAND);
431 for (x = 0; x < hd->cppadlen; x++)
432 outw(0, base + HA_RDATA);
433
Jeff Garzik017560f2005-10-24 18:04:36 -0400434 DBG(DBG_QUEUE, scmd_printk(KERN_DEBUG, cmd,
435 "Queued base %#.4lx pid: %ld "
Matthew Wilcox12a44162007-09-18 19:54:43 -0600436 "slot %d irq %d\n", sh->base, cmd->serial_number, y, sh->irq));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700437
Alan Cox1a1d6412007-09-20 15:15:27 +0100438 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700439}
440
441static int eata_pio_abort(struct scsi_cmnd *cmd)
442{
Alan Cox1a68d412006-09-18 19:18:34 +0100443 unsigned int loop = 100;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700444
Jeff Garzik017560f2005-10-24 18:04:36 -0400445 DBG(DBG_ABNORM, scmd_printk(KERN_WARNING, cmd,
446 "eata_pio_abort called pid: %ld\n",
Matthew Wilcox12a44162007-09-18 19:54:43 -0600447 cmd->serial_number));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700448
449 while (inb(cmd->device->host->base + HA_RAUXSTAT) & HA_ABUSY)
450 if (--loop == 0) {
451 printk(KERN_WARNING "eata_pio: abort, timeout error.\n");
452 return FAILED;
453 }
454 if (CD(cmd)->status == FREE) {
455 DBG(DBG_ABNORM, printk(KERN_WARNING "Returning: SCSI_ABORT_NOT_RUNNING\n"));
456 return FAILED;
457 }
458 if (CD(cmd)->status == USED) {
459 DBG(DBG_ABNORM, printk(KERN_WARNING "Returning: SCSI_ABORT_BUSY\n"));
460 /* We want to sleep a bit more here */
461 return FAILED; /* SNOOZE */
462 }
463 if (CD(cmd)->status == RESET) {
464 printk(KERN_WARNING "eata_pio: abort, command reset error.\n");
465 return FAILED;
466 }
467 if (CD(cmd)->status == LOCKED) {
468 DBG(DBG_ABNORM, printk(KERN_WARNING "eata_pio: abort, queue slot " "locked.\n"));
469 return FAILED;
470 }
471 panic("eata_pio: abort: invalid slot status\n");
472}
473
474static int eata_pio_host_reset(struct scsi_cmnd *cmd)
475{
Alan Cox1a68d412006-09-18 19:18:34 +0100476 unsigned int x, limit = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700477 unsigned char success = 0;
478 struct scsi_cmnd *sp;
479 struct Scsi_Host *host = cmd->device->host;
480
Jeff Garzik017560f2005-10-24 18:04:36 -0400481 DBG(DBG_ABNORM, scmd_printk(KERN_WARNING, cmd,
482 "eata_pio_reset called pid:%ld\n",
Matthew Wilcox12a44162007-09-18 19:54:43 -0600483 cmd->serial_number));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700484
Jeff Garzik df0ae242005-05-28 07:57:14 -0400485 spin_lock_irq(host->host_lock);
486
Linus Torvalds1da177e2005-04-16 15:20:36 -0700487 if (HD(cmd)->state == RESET) {
488 printk(KERN_WARNING "eata_pio_reset: exit, already in reset.\n");
Jeff Garzik df0ae242005-05-28 07:57:14 -0400489 spin_unlock_irq(host->host_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700490 return FAILED;
491 }
492
493 /* force all slots to be free */
494
495 for (x = 0; x < cmd->device->host->can_queue; x++) {
496
497 if (HD(cmd)->ccb[x].status == FREE)
498 continue;
499
500 sp = HD(cmd)->ccb[x].cmd;
501 HD(cmd)->ccb[x].status = RESET;
Matthew Wilcox12a44162007-09-18 19:54:43 -0600502 printk(KERN_WARNING "eata_pio_reset: slot %d in reset, pid %ld.\n", x, sp->serial_number);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700503
504 if (sp == NULL)
505 panic("eata_pio_reset: slot %d, sp==NULL.\n", x);
506 }
507
508 /* hard reset the HBA */
Alan Cox1a68d412006-09-18 19:18:34 +0100509 outb(EATA_CMD_RESET, cmd->device->host->base + HA_WCOMMAND);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700510
511 DBG(DBG_ABNORM, printk(KERN_WARNING "eata_pio_reset: board reset done.\n"));
512 HD(cmd)->state = RESET;
513
514 spin_unlock_irq(host->host_lock);
515 msleep(3000);
516 spin_lock_irq(host->host_lock);
517
518 DBG(DBG_ABNORM, printk(KERN_WARNING "eata_pio_reset: interrupts disabled, " "loops %d.\n", limit));
519
520 for (x = 0; x < cmd->device->host->can_queue; x++) {
521
522 /* Skip slots already set free by interrupt */
523 if (HD(cmd)->ccb[x].status != RESET)
524 continue;
525
526 sp = HD(cmd)->ccb[x].cmd;
527 sp->result = DID_RESET << 16;
528
529 /* This mailbox is terminated */
530 printk(KERN_WARNING "eata_pio_reset: reset ccb %d.\n", x);
531 HD(cmd)->ccb[x].status = FREE;
532
533 sp->scsi_done(sp);
534 }
535
536 HD(cmd)->state = 0;
537
Jeff Garzik df0ae242005-05-28 07:57:14 -0400538 spin_unlock_irq(host->host_lock);
539
Linus Torvalds1da177e2005-04-16 15:20:36 -0700540 if (success) { /* hmmm... */
541 DBG(DBG_ABNORM, printk(KERN_WARNING "eata_pio_reset: exit, success.\n"));
542 return SUCCESS;
543 } else {
544 DBG(DBG_ABNORM, printk(KERN_WARNING "eata_pio_reset: exit, wakeup.\n"));
545 return FAILED;
546 }
547}
548
Alan Cox1a68d412006-09-18 19:18:34 +0100549static 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 -0700550{
551 struct eata_ccb cp;
552 static char buff[256];
553 int z;
554
555 memset(&cp, 0, sizeof(struct eata_ccb));
556 memset(buff, 0, sizeof(buff));
557
558 cp.DataIn = 1;
559 cp.Interpret = 1; /* Interpret command */
560
Alan Cox1a68d412006-09-18 19:18:34 +0100561 cp.cp_datalen = cpu_to_be32(254);
562 cp.cp_dataDMA = cpu_to_be32(0);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700563
564 cp.cp_id = id;
565 cp.cp_lun = 0;
566
567 cp.cp_cdb[0] = INQUIRY;
568 cp.cp_cdb[1] = 0;
569 cp.cp_cdb[2] = 0;
570 cp.cp_cdb[3] = 0;
571 cp.cp_cdb[4] = 254;
572 cp.cp_cdb[5] = 0;
573
Alan Cox1a68d412006-09-18 19:18:34 +0100574 if (eata_pio_send_command(base, EATA_CMD_PIO_SEND_CP))
Alan Cox1a1d6412007-09-20 15:15:27 +0100575 return NULL;
576
577 while (!(inb(base + HA_RSTATUS) & HA_SDRQ))
578 cpu_relax();
579
Linus Torvalds1da177e2005-04-16 15:20:36 -0700580 outsw(base + HA_RDATA, &cp, cplen);
581 outb(EATA_CMD_PIO_TRUNC, base + HA_WCOMMAND);
582 for (z = 0; z < cppadlen; z++)
583 outw(0, base + HA_RDATA);
584
Alan Cox1a1d6412007-09-20 15:15:27 +0100585 while (inb(base + HA_RSTATUS) & HA_SBUSY)
586 cpu_relax();
587
Linus Torvalds1da177e2005-04-16 15:20:36 -0700588 if (inb(base + HA_RSTATUS) & HA_SERROR)
Alan Cox1a1d6412007-09-20 15:15:27 +0100589 return NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700590 else if (!(inb(base + HA_RSTATUS) & HA_SDRQ))
Alan Cox1a1d6412007-09-20 15:15:27 +0100591 return NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700592 else {
593 insw(base + HA_RDATA, &buff, 127);
594 while (inb(base + HA_RSTATUS) & HA_SDRQ)
595 inw(base + HA_RDATA);
Alan Cox1a1d6412007-09-20 15:15:27 +0100596 return buff;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700597 }
598}
599
Alan Cox1a68d412006-09-18 19:18:34 +0100600static int get_pio_conf_PIO(unsigned long base, struct get_conf *buf)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700601{
602 unsigned long loop = HZ / 2;
603 int z;
604 unsigned short *p;
605
606 if (!request_region(base, 9, "eata_pio"))
607 return 0;
608
609 memset(buf, 0, sizeof(struct get_conf));
610
611 while (inb(base + HA_RSTATUS) & HA_SBUSY)
612 if (--loop == 0)
613 goto fail;
614
Alan Cox1a68d412006-09-18 19:18:34 +0100615 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 -0700616 eata_pio_send_command(base, EATA_CMD_PIO_READ_CONFIG);
617
Alan Cox1a68d412006-09-18 19:18:34 +0100618 loop = 50;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700619 for (p = (unsigned short *) buf; (long) p <= ((long) buf + (sizeof(struct get_conf) / 2)); p++) {
620 while (!(inb(base + HA_RSTATUS) & HA_SDRQ))
621 if (--loop == 0)
622 goto fail;
623
Alan Cox1a68d412006-09-18 19:18:34 +0100624 loop = 50;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700625 *p = inw(base + HA_RDATA);
626 }
627 if (inb(base + HA_RSTATUS) & HA_SERROR) {
628 DBG(DBG_PROBE, printk("eata_dma: get_conf_PIO, error during "
Alan Cox1a68d412006-09-18 19:18:34 +0100629 "transfer for HBA at %lx\n", base));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700630 goto fail;
631 }
632
Alan Cox1a68d412006-09-18 19:18:34 +0100633 if (cpu_to_be32(EATA_SIGNATURE) != buf->signature)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700634 goto fail;
635
636 DBG(DBG_PIO && DBG_PROBE, printk(KERN_NOTICE "EATA Controller found "
Alan Cox1a68d412006-09-18 19:18:34 +0100637 "at %#4lx EATA Level: %x\n",
638 base, (unsigned int) (buf->version)));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700639
640 while (inb(base + HA_RSTATUS) & HA_SDRQ)
641 inw(base + HA_RDATA);
642
643 if (!ALLOW_DMA_BOARDS) {
644 for (z = 0; z < MAXISA; z++)
645 if (base == ISAbases[z]) {
646 buf->IRQ = ISAirqs[z];
647 break;
648 }
649 }
650
651 return 1;
652
653 fail:
654 release_region(base, 9);
655 return 0;
656}
657
658static void print_pio_config(struct get_conf *gc)
659{
660 printk("Please check values: (read config data)\n");
Alan Cox1a68d412006-09-18 19:18:34 +0100661 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);
662 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 -0700663 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);
664}
665
Alan Cox1a68d412006-09-18 19:18:34 +0100666static unsigned int print_selftest(unsigned int base)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700667{
668 unsigned char buffer[512];
669#ifdef VERBOSE_SETUP
670 int z;
671#endif
672
673 printk("eata_pio: executing controller self test & setup...\n");
674 while (inb(base + HA_RSTATUS) & HA_SBUSY);
675 outb(EATA_CMD_PIO_SETUPTEST, base + HA_WCOMMAND);
676 do {
677 while (inb(base + HA_RSTATUS) & HA_SBUSY)
678 /* nothing */ ;
679 if (inb(base + HA_RSTATUS) & HA_SDRQ) {
680 insw(base + HA_RDATA, &buffer, 256);
681#ifdef VERBOSE_SETUP
682 /* no beeps please... */
683 for (z = 0; z < 511 && buffer[z]; z++)
684 if (buffer[z] != 7)
685 printk("%c", buffer[z]);
686#endif
687 }
688 } while (inb(base + HA_RSTATUS) & (HA_SBUSY | HA_SDRQ));
689
690 return (!(inb(base + HA_RSTATUS) & HA_SERROR));
691}
692
Alan Cox1a68d412006-09-18 19:18:34 +0100693static int register_pio_HBA(long base, struct get_conf *gc, struct pci_dev *pdev)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700694{
695 unsigned long size = 0;
696 char *buff;
697 unsigned long cplen;
698 unsigned short cppadlen;
699 struct Scsi_Host *sh;
700 hostdata *hd;
701
702 DBG(DBG_REGISTER, print_pio_config(gc));
703
704 if (gc->DMA_support) {
705 printk("HBA at %#.4lx supports DMA. Please use EATA-DMA driver.\n", base);
706 if (!ALLOW_DMA_BOARDS)
707 return 0;
708 }
709
Alan Cox1a68d412006-09-18 19:18:34 +0100710 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) {
711 printk("HBA at %#lx didn't react on INQUIRY. Sorry.\n", base);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700712 return 0;
713 }
714
715 if (!print_selftest(base) && !ALLOW_DMA_BOARDS) {
Alan Cox1a68d412006-09-18 19:18:34 +0100716 printk("HBA at %#lx failed while performing self test & setup.\n", base);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700717 return 0;
718 }
719
Alan Cox1a68d412006-09-18 19:18:34 +0100720 size = sizeof(hostdata) + (sizeof(struct eata_ccb) * be16_to_cpu(gc->queuesiz));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700721
722 sh = scsi_register(&driver_template, size);
723 if (sh == NULL)
724 return 0;
725
726 if (!reg_IRQ[gc->IRQ]) { /* Interrupt already registered ? */
Thomas Gleixner1d6f3592006-07-01 19:29:42 -0700727 if (!request_irq(gc->IRQ, do_eata_pio_int_handler, IRQF_DISABLED, "EATA-PIO", sh)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700728 reg_IRQ[gc->IRQ]++;
729 if (!gc->IRQ_TR)
730 reg_IRQL[gc->IRQ] = 1; /* IRQ is edge triggered */
731 } else {
732 printk("Couldn't allocate IRQ %d, Sorry.\n", gc->IRQ);
733 return 0;
734 }
735 } else { /* More than one HBA on this IRQ */
736 if (reg_IRQL[gc->IRQ]) {
737 printk("Can't support more than one HBA on this IRQ,\n" " if the IRQ is edge triggered. Sorry.\n");
738 return 0;
739 } else
740 reg_IRQ[gc->IRQ]++;
741 }
742
743 hd = SD(sh);
744
Alan Cox1a68d412006-09-18 19:18:34 +0100745 memset(hd->ccb, 0, (sizeof(struct eata_ccb) * be16_to_cpu(gc->queuesiz)));
746 memset(hd->reads, 0, sizeof(hd->reads));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700747
748 strlcpy(SD(sh)->vendor, &buff[8], sizeof(SD(sh)->vendor));
749 strlcpy(SD(sh)->name, &buff[16], sizeof(SD(sh)->name));
750 SD(sh)->revision[0] = buff[32];
751 SD(sh)->revision[1] = buff[33];
752 SD(sh)->revision[2] = buff[34];
753 SD(sh)->revision[3] = '.';
754 SD(sh)->revision[4] = buff[35];
755 SD(sh)->revision[5] = 0;
756
Alan Cox1a68d412006-09-18 19:18:34 +0100757 switch (be32_to_cpu(gc->len)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700758 case 0x1c:
759 SD(sh)->EATA_revision = 'a';
760 break;
761 case 0x1e:
762 SD(sh)->EATA_revision = 'b';
763 break;
764 case 0x22:
765 SD(sh)->EATA_revision = 'c';
766 break;
767 case 0x24:
768 SD(sh)->EATA_revision = 'z';
769 default:
770 SD(sh)->EATA_revision = '?';
771 }
772
Alan Cox1a68d412006-09-18 19:18:34 +0100773 if (be32_to_cpu(gc->len) >= 0x22) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700774 if (gc->is_PCI)
775 hd->bustype = IS_PCI;
776 else if (gc->is_EISA)
777 hd->bustype = IS_EISA;
778 else
779 hd->bustype = IS_ISA;
780 } else {
781 if (buff[21] == '4')
782 hd->bustype = IS_PCI;
783 else if (buff[21] == '2')
784 hd->bustype = IS_EISA;
785 else
786 hd->bustype = IS_ISA;
787 }
788
789 SD(sh)->cplen = cplen;
790 SD(sh)->cppadlen = cppadlen;
791 SD(sh)->hostid = gc->scsi_id[3];
792 SD(sh)->devflags = 1 << gc->scsi_id[3];
793 SD(sh)->moresupport = gc->MORE_support;
794 sh->unique_id = base;
795 sh->base = base;
796 sh->io_port = base;
797 sh->n_io_port = 9;
798 sh->irq = gc->IRQ;
799 sh->dma_channel = PIO;
800 sh->this_id = gc->scsi_id[3];
801 sh->can_queue = 1;
802 sh->cmd_per_lun = 1;
803 sh->sg_tablesize = SG_ALL;
804
805 hd->channel = 0;
806
Alan Cox1a68d412006-09-18 19:18:34 +0100807 hd->pdev = pci_dev_get(pdev); /* Keep a PCI reference */
808
Linus Torvalds1da177e2005-04-16 15:20:36 -0700809 sh->max_id = 8;
810 sh->max_lun = 8;
811
812 if (gc->SECOND)
813 hd->primary = 0;
814 else
815 hd->primary = 1;
816
Linus Torvalds1da177e2005-04-16 15:20:36 -0700817 hd->next = NULL; /* build a linked list of all HBAs */
818 hd->prev = last_HBA;
819 if (hd->prev != NULL)
820 SD(hd->prev)->next = sh;
821 last_HBA = sh;
822 if (first_HBA == NULL)
823 first_HBA = sh;
824 registered_HBAs++;
825 return (1);
826}
827
828static void find_pio_ISA(struct get_conf *buf)
829{
830 int i;
831
832 for (i = 0; i < MAXISA; i++) {
833 if (!ISAbases[i])
834 continue;
835 if (!get_pio_conf_PIO(ISAbases[i], buf))
836 continue;
Alan Cox1a68d412006-09-18 19:18:34 +0100837 if (!register_pio_HBA(ISAbases[i], buf, NULL))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700838 release_region(ISAbases[i], 9);
839 else
840 ISAbases[i] = 0;
841 }
842 return;
843}
844
845static void find_pio_EISA(struct get_conf *buf)
846{
847 u32 base;
848 int i;
849
850#ifdef CHECKPAL
851 u8 pal1, pal2, pal3;
852#endif
853
854 for (i = 0; i < MAXEISA; i++) {
855 if (EISAbases[i]) { /* Still a possibility ? */
856
857 base = 0x1c88 + (i * 0x1000);
858#ifdef CHECKPAL
859 pal1 = inb((u16) base - 8);
860 pal2 = inb((u16) base - 7);
861 pal3 = inb((u16) base - 6);
862
863 if (((pal1 == 0x12) && (pal2 == 0x14)) || ((pal1 == 0x38) && (pal2 == 0xa3) && (pal3 == 0x82)) || ((pal1 == 0x06) && (pal2 == 0x94) && (pal3 == 0x24))) {
864 DBG(DBG_PROBE, printk(KERN_NOTICE "EISA EATA id tags found: " "%x %x %x \n", (int) pal1, (int) pal2, (int) pal3));
865#endif
866 if (get_pio_conf_PIO(base, buf)) {
867 DBG(DBG_PROBE && DBG_EISA, print_pio_config(buf));
868 if (buf->IRQ) {
Alan Cox1a68d412006-09-18 19:18:34 +0100869 if (!register_pio_HBA(base, buf, NULL))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700870 release_region(base, 9);
871 } else {
872 printk(KERN_NOTICE "eata_dma: No valid IRQ. HBA " "removed from list\n");
873 release_region(base, 9);
874 }
875 }
876 /* Nothing found here so we take it from the list */
877 EISAbases[i] = 0;
878#ifdef CHECKPAL
879 }
880#endif
881 }
882 }
883 return;
884}
885
886static void find_pio_PCI(struct get_conf *buf)
887{
888#ifndef CONFIG_PCI
889 printk("eata_dma: kernel PCI support not enabled. Skipping scan for PCI HBAs.\n");
890#else
891 struct pci_dev *dev = NULL;
Alan Cox1a68d412006-09-18 19:18:34 +0100892 unsigned long base, x;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700893
Alan Cox1a68d412006-09-18 19:18:34 +0100894 while ((dev = pci_get_device(PCI_VENDOR_ID_DPT, PCI_DEVICE_ID_DPT, dev)) != NULL) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700895 DBG(DBG_PROBE && DBG_PCI, printk("eata_pio: find_PCI, HBA at %s\n", pci_name(dev)));
896 if (pci_enable_device(dev))
897 continue;
898 pci_set_master(dev);
899 base = pci_resource_flags(dev, 0);
900 if (base & IORESOURCE_MEM) {
901 printk("eata_pio: invalid base address of device %s\n", pci_name(dev));
902 continue;
903 }
904 base = pci_resource_start(dev, 0);
905 /* EISA tag there ? */
906 if ((inb(base) == 0x12) && (inb(base + 1) == 0x14))
907 continue; /* Jep, it's forced, so move on */
908 base += 0x10; /* Now, THIS is the real address */
909 if (base != 0x1f8) {
910 /* We didn't find it in the primary search */
911 if (get_pio_conf_PIO(base, buf)) {
912 if (buf->FORCADR) { /* If the address is forced */
913 release_region(base, 9);
914 continue; /* we'll find it later */
915 }
916
917 /* OK. We made it till here, so we can go now
918 * and register it. We only have to check and
919 * eventually remove it from the EISA and ISA list
920 */
921
Alan Cox1a68d412006-09-18 19:18:34 +0100922 if (!register_pio_HBA(base, buf, dev)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700923 release_region(base, 9);
924 continue;
925 }
926
927 if (base < 0x1000) {
928 for (x = 0; x < MAXISA; ++x) {
929 if (ISAbases[x] == base) {
930 ISAbases[x] = 0;
931 break;
932 }
933 }
934 } else if ((base & 0x0fff) == 0x0c88) {
935 x = (base >> 12) & 0x0f;
936 EISAbases[x] = 0;
937 }
938 }
939#ifdef CHECK_BLINK
940 else if (check_blink_state(base)) {
941 printk("eata_pio: HBA is in BLINK state.\n" "Consult your HBAs manual to correct this.\n");
942 }
943#endif
944 }
945 }
946#endif /* #ifndef CONFIG_PCI */
947}
948
949static int eata_pio_detect(struct scsi_host_template *tpnt)
950{
951 struct Scsi_Host *HBA_ptr;
952 struct get_conf gc;
953 int i;
954
955 find_pio_PCI(&gc);
956 find_pio_EISA(&gc);
957 find_pio_ISA(&gc);
958
959 for (i = 0; i <= MAXIRQ; i++)
960 if (reg_IRQ[i])
Thomas Gleixner1d6f3592006-07-01 19:29:42 -0700961 request_irq(i, do_eata_pio_int_handler, IRQF_DISABLED, "EATA-PIO", NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700962
963 HBA_ptr = first_HBA;
964
965 if (registered_HBAs != 0) {
966 printk("EATA (Extended Attachment) PIO driver version: %d.%d%s\n"
967 "(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);
968
969 printk("Registered HBAs:\n");
970 printk("HBA no. Boardtype: Revis: EATA: Bus: BaseIO: IRQ: Ch: ID: Pr:" " QS: SG: CPL:\n");
971 for (i = 1; i <= registered_HBAs; i++) {
Alan Cox1a68d412006-09-18 19:18:34 +0100972 printk("scsi%-2d: %.10s v%s 2.0%c %s %#.4lx %2d %d %d %c"
Linus Torvalds1da177e2005-04-16 15:20:36 -0700973 " %2d %2d %2d\n",
974 HBA_ptr->host_no, SD(HBA_ptr)->name, SD(HBA_ptr)->revision,
975 SD(HBA_ptr)->EATA_revision, (SD(HBA_ptr)->bustype == 'P') ?
976 "PCI " : (SD(HBA_ptr)->bustype == 'E') ? "EISA" : "ISA ",
Alan Cox1a68d412006-09-18 19:18:34 +0100977 HBA_ptr->base, HBA_ptr->irq, SD(HBA_ptr)->channel, HBA_ptr->this_id,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700978 SD(HBA_ptr)->primary ? 'Y' : 'N', HBA_ptr->can_queue,
979 HBA_ptr->sg_tablesize, HBA_ptr->cmd_per_lun);
980 HBA_ptr = SD(HBA_ptr)->next;
981 }
982 }
983 return (registered_HBAs);
984}
985
986static struct scsi_host_template driver_template = {
987 .proc_name = "eata_pio",
988 .name = "EATA (Extended Attachment) PIO driver",
989 .proc_info = eata_pio_proc_info,
990 .detect = eata_pio_detect,
991 .release = eata_pio_release,
992 .queuecommand = eata_pio_queue,
993 .eh_abort_handler = eata_pio_abort,
994 .eh_host_reset_handler = eata_pio_host_reset,
995 .use_clustering = ENABLE_CLUSTERING,
996};
997
998MODULE_AUTHOR("Michael Neuffer, Alfred Arnold");
999MODULE_DESCRIPTION("EATA SCSI PIO driver");
1000MODULE_LICENSE("GPL");
1001
1002#include "scsi_module.c"