42 #include <linux/module.h>
44 #include <linux/kernel.h>
45 #include <linux/string.h>
52 #include <linux/stat.h>
67 static int qlcfg9 = ((
XTALFREQ + 4) / 5);
99 int qbase = priv->
qbase;
105 if (reqlen >= 128 && (
inb(qbase + 8) & 2)) {
106 insl(qbase + 4, request, 32);
110 while (reqlen >= 84 && !(j & 0xc0))
111 if ((j =
inb(qbase + 8)) & 4)
113 insl(qbase + 4, request, 21);
117 if (reqlen >= 44 && (
inb(qbase + 8) & 8)) {
118 insl(qbase + 4, request, 11);
126 while (reqlen && !((j & 0x10) && (j & 0xc0)))
130 while (reqlen && !((j =
inb(qbase + 8)) & 0x10))
132 *request++ =
inb(qbase + 4);
142 if (reqlen >= 128 &&
inb(qbase + 8) & 0x10) {
143 outsl(qbase + 4, request, 32);
147 while (reqlen >= 84 && !(j & 0xc0))
148 if (!((j =
inb(qbase + 8)) & 8)) {
149 outsl(qbase + 4, request, 21);
153 if (reqlen >= 40 && !(
inb(qbase + 8) & 4)) {
154 outsl(qbase + 4, request, 10);
162 while (reqlen && !((j & 2) && (j & 0xc0))) {
164 while (reqlen && !((j =
inb(qbase + 8)) & 2))
166 outb(*request++, qbase + 4);
174 return inb(qbase + 8) & 0xc0;
184 int qbase = priv->
qbase;
190 !((k =
inb(qbase + 4)) & 0xe0)) {
215 int qbase = priv->
qbase;
227 else if (
inb(qbase + 7) & 0x1f)
229 while (
inb(qbase + 5));
238 outb(qlcfgc, qbase + 0
xc);
241 outb(qlcfg7, qbase + 7);
242 outb(qlcfg6, qbase + 6);
243 outb(qlcfg5, qbase + 5);
244 outb(qlcfg9 & 7, qbase + 9);
248 for (i = 0; i < cmd->
cmd_len; i++)
252 outb(0x41, qbase + 3);
259 static unsigned int ql_pcmd(
struct scsi_cmnd *cmd)
270 int qbase = priv->
qbase;
292 if (j != 3 && j != 4) {
293 printk(
KERN_ERR "Ql:Bad sequence for command %d, int %02X, cmdleft = %d\n",
294 j, i,
inb(qbase + 7) & 0x1f);
299 if (
inb(qbase + 7) & 0x1f)
302 reqlen = scsi_bufflen(cmd);
304 if (reqlen && !((phase =
inb(qbase + 4)) & 6)) {
308 outb(reqlen >> 8, qbase + 1);
309 outb(reqlen >> 16, qbase + 0
xe);
310 outb(0x90, qbase + 3);
317 return ((priv->
qabort == 1 ?
321 if (ql_pdma(priv, phase, buf, sg->length))
330 if ((k = ql_wai(priv)))
339 k = jiffies + WATCHDOG;
342 !(
inb(qbase + 4) & 6))
351 while (
inb(qbase + 5))
357 outb(0x11, qbase + 3);
358 if ((k = ql_wai(priv)))
361 j =
inb(qbase + 7) & 0x1f;
362 status =
inb(qbase + 2);
363 message =
inb(qbase + 2);
369 if (!((i == 8 && j == 2) || (i == 0x10 && j == 1))) {
370 printk(
KERN_ERR "Ql:Error during status phase, int=%02X, %d bytes recd\n", i, j);
373 outb(0x12, qbase + 3);
375 if ((k = ql_wai(priv)))
383 while (!priv->qabort && ((i & 0x20) != 0x20)) {
400 static
void ql_ihandl(
void *
dev_id)
405 int qbase = priv->
qbase;
408 if (!(
inb(qbase + 4) & 0x80))
414 while (i-- &&
inb(qbase + 5));
418 icmd->
result = ql_pcmd(icmd);
434 spin_unlock_irqrestore(host->
host_lock, flags);
442 static int qlogicfas408_queuecommand_lck(
struct scsi_cmnd *cmd,
474 ip[2] = (
unsigned long) capacity / (ip[0] * ip[1]);
478 ip[2] = (
unsigned long) capacity / (ip[0] * ip[1]);
514 spin_unlock_irqrestore(cmd->
device->host->host_lock, flags);
536 return inb(qbase + 0xe) & 0xf8;
547 outb(0x40 | qlcfg8 |
id, qbase + 8);
548 outb(qlcfg5, qbase + 5);
549 outb(qlcfg9, qbase + 9);
551 #if QL_RESET_AT_START
556 while (
inb(qbase + 0xf) & 4)
570 return (((
inb(qbase + 0xe) ^
inb(qbase + 0xe)) == 7) &&
571 ((
inb(qbase + 0xe) ^
inb(qbase + 0xe)) == 7));
580 int qbase = priv->
qbase;
591 static int __init qlogicfas408_init(
void)
596 static void __exit qlogicfas408_exit(
void)