1 /* qlogicpti.c: Performance Technologies QlogicISP sbus card driver.
3 * Copyright (C) 1996 David S. Miller (davem@caipfs.rutgers.edu)
5 * A lot of this driver was directly stolen from Erik H. Moe's PCI
6 * Qlogic ISP driver. Mucho kudos to him for this code.
8 * An even bigger kudos to John Grana at Performance Technologies
9 * for providing me with the hardware to write this driver, you rule
12 * May, 2, 1997: Added support for QLGC,isp --jj
15 #include <linux/kernel.h>
16 #include <linux/delay.h>
17 #include <linux/types.h>
18 #include <linux/string.h>
19 #include <linux/malloc.h>
20 #include <linux/blk.h>
21 #include <linux/proc_fs.h>
22 #include <linux/stat.h>
23 #include <linux/init.h>
24 #include <linux/spinlock.h>
26 #include <asm/byteorder.h>
30 #include "qlogicpti.h"
34 #include <asm/system.h>
35 #include <asm/machines.h>
36 #include <asm/ptrace.h>
37 #include <asm/pgtable.h>
38 #include <asm/oplib.h>
39 #include <asm/vaddrs.h>
43 #include <linux/module.h>
45 #define MAX_TARGETS 16
48 #define DEFAULT_LOOP_COUNT 1000000
50 #include "qlogicpti_asm.c"
52 static struct qlogicpti
*qptichain
;
53 static int qptis_running
= 0;
55 #define PACKB(a, b) (((a)<<4)|(b))
57 const u_char mbox_param
[] = {
58 PACKB(1, 1), /* MBOX_NO_OP */
59 PACKB(5, 5), /* MBOX_LOAD_RAM */
60 PACKB(2, 0), /* MBOX_EXEC_FIRMWARE */
61 PACKB(5, 5), /* MBOX_DUMP_RAM */
62 PACKB(3, 3), /* MBOX_WRITE_RAM_WORD */
63 PACKB(2, 3), /* MBOX_READ_RAM_WORD */
64 PACKB(6, 6), /* MBOX_MAILBOX_REG_TEST */
65 PACKB(2, 3), /* MBOX_VERIFY_CHECKSUM */
66 PACKB(1, 3), /* MBOX_ABOUT_FIRMWARE */
67 PACKB(0, 0), /* 0x0009 */
68 PACKB(0, 0), /* 0x000a */
69 PACKB(0, 0), /* 0x000b */
70 PACKB(0, 0), /* 0x000c */
71 PACKB(0, 0), /* 0x000d */
72 PACKB(1, 2), /* MBOX_CHECK_FIRMWARE */
73 PACKB(0, 0), /* 0x000f */
74 PACKB(5, 5), /* MBOX_INIT_REQ_QUEUE */
75 PACKB(6, 6), /* MBOX_INIT_RES_QUEUE */
76 PACKB(4, 4), /* MBOX_EXECUTE_IOCB */
77 PACKB(2, 2), /* MBOX_WAKE_UP */
78 PACKB(1, 6), /* MBOX_STOP_FIRMWARE */
79 PACKB(4, 4), /* MBOX_ABORT */
80 PACKB(2, 2), /* MBOX_ABORT_DEVICE */
81 PACKB(3, 3), /* MBOX_ABORT_TARGET */
82 PACKB(2, 2), /* MBOX_BUS_RESET */
83 PACKB(2, 3), /* MBOX_STOP_QUEUE */
84 PACKB(2, 3), /* MBOX_START_QUEUE */
85 PACKB(2, 3), /* MBOX_SINGLE_STEP_QUEUE */
86 PACKB(2, 3), /* MBOX_ABORT_QUEUE */
87 PACKB(2, 4), /* MBOX_GET_DEV_QUEUE_STATUS */
88 PACKB(0, 0), /* 0x001e */
89 PACKB(1, 3), /* MBOX_GET_FIRMWARE_STATUS */
90 PACKB(1, 2), /* MBOX_GET_INIT_SCSI_ID */
91 PACKB(1, 2), /* MBOX_GET_SELECT_TIMEOUT */
92 PACKB(1, 3), /* MBOX_GET_RETRY_COUNT */
93 PACKB(1, 2), /* MBOX_GET_TAG_AGE_LIMIT */
94 PACKB(1, 2), /* MBOX_GET_CLOCK_RATE */
95 PACKB(1, 2), /* MBOX_GET_ACT_NEG_STATE */
96 PACKB(1, 2), /* MBOX_GET_ASYNC_DATA_SETUP_TIME */
97 PACKB(1, 3), /* MBOX_GET_SBUS_PARAMS */
98 PACKB(2, 4), /* MBOX_GET_TARGET_PARAMS */
99 PACKB(2, 4), /* MBOX_GET_DEV_QUEUE_PARAMS */
100 PACKB(0, 0), /* 0x002a */
101 PACKB(0, 0), /* 0x002b */
102 PACKB(0, 0), /* 0x002c */
103 PACKB(0, 0), /* 0x002d */
104 PACKB(0, 0), /* 0x002e */
105 PACKB(0, 0), /* 0x002f */
106 PACKB(2, 2), /* MBOX_SET_INIT_SCSI_ID */
107 PACKB(2, 2), /* MBOX_SET_SELECT_TIMEOUT */
108 PACKB(3, 3), /* MBOX_SET_RETRY_COUNT */
109 PACKB(2, 2), /* MBOX_SET_TAG_AGE_LIMIT */
110 PACKB(2, 2), /* MBOX_SET_CLOCK_RATE */
111 PACKB(2, 2), /* MBOX_SET_ACTIVE_NEG_STATE */
112 PACKB(2, 2), /* MBOX_SET_ASYNC_DATA_SETUP_TIME */
113 PACKB(3, 3), /* MBOX_SET_SBUS_CONTROL_PARAMS */
114 PACKB(4, 4), /* MBOX_SET_TARGET_PARAMS */
115 PACKB(4, 4), /* MBOX_SET_DEV_QUEUE_PARAMS */
116 PACKB(0, 0), /* 0x003a */
117 PACKB(0, 0), /* 0x003b */
118 PACKB(0, 0), /* 0x003c */
119 PACKB(0, 0), /* 0x003d */
120 PACKB(0, 0), /* 0x003e */
121 PACKB(0, 0), /* 0x003f */
122 PACKB(0, 0), /* 0x0040 */
123 PACKB(0, 0), /* 0x0041 */
124 PACKB(0, 0) /* 0x0042 */
127 #define MAX_MBOX_COMMAND (sizeof(mbox_param)/sizeof(u_short))
129 /* queue length's _must_ be power of two: */
130 #define QUEUE_DEPTH(in, out, ql) ((in - out) & (ql))
131 #define REQ_QUEUE_DEPTH(in, out) QUEUE_DEPTH(in, out, \
132 QLOGICISP_REQ_QUEUE_LEN)
133 #define RES_QUEUE_DEPTH(in, out) QUEUE_DEPTH(in, out, RES_QUEUE_LEN)
135 static struct proc_dir_entry proc_scsi_qlogicpti
= {
136 PROC_SCSI_QLOGICPTI
, 7, "qlogicpti",
137 S_IFDIR
| S_IRUGO
| S_IXUGO
, 2
140 static inline void qlogicpti_enable_irqs(struct qlogicpti_regs
*qregs
)
142 qregs
->sbus_ctrl
= SBUS_CTRL_ERIRQ
| SBUS_CTRL_GENAB
;
146 static inline void qlogicpti_disable_irqs(struct qlogicpti_regs
*qregs
)
148 qregs
->sbus_ctrl
= 0;
151 static inline void set_sbus_cfg1(struct qlogicpti_regs
*qregs
, unsigned char bursts
)
153 if(bursts
& DMA_BURST32
) {
154 qregs
->sbus_cfg1
= (SBUS_CFG1_BENAB
| SBUS_CFG1_B32
);
155 } else if(bursts
& DMA_BURST16
) {
156 qregs
->sbus_cfg1
= (SBUS_CFG1_BENAB
| SBUS_CFG1_B16
);
157 } else if(bursts
& DMA_BURST8
) {
158 qregs
->sbus_cfg1
= (SBUS_CFG1_BENAB
| SBUS_CFG1_B8
);
160 qregs
->sbus_cfg1
= 0; /* No sbus bursts for you... */
164 static int qlogicpti_mbox_command(struct qlogicpti
*qpti
, u_short param
[], int force
)
166 struct qlogicpti_regs
*qregs
= qpti
->qregs
;
169 if(mbox_param
[param
[0]] == 0)
172 loop_count
= DEFAULT_LOOP_COUNT
;
173 while(--loop_count
&& (qregs
->hcctrl
& HCCTRL_HIRQ
))
176 printk(KERN_EMERG
"qlogicpti: mbox_command loop timeout #1\n");
178 switch(mbox_param
[param
[0]] >> 4) {
179 case 6: qregs
->mbox5
= param
[5];
180 case 5: qregs
->mbox4
= param
[4];
181 case 4: qregs
->mbox3
= param
[3];
182 case 3: qregs
->mbox2
= param
[2];
183 case 2: qregs
->mbox1
= param
[1];
184 case 1: qregs
->mbox0
= param
[0];
187 qregs
->hcctrl
|= HCCTRL_SHIRQ
;
189 loop_count
= DEFAULT_LOOP_COUNT
;
190 while(--loop_count
&& !(qregs
->sbus_semaphore
& SBUS_SEMAPHORE_LCK
))
193 printk(KERN_EMERG
"qlogicpti: mbox_command loop timeout #2\n");
195 loop_count
= DEFAULT_LOOP_COUNT
;
196 while(--loop_count
&& (qregs
->mbox0
== 0x04))
199 printk(KERN_EMERG
"qlogicpti: mbox_command loop timeout #3\n");
202 qregs
->hcctrl
= HCCTRL_CRIRQ
;
204 if((qregs
->mbox5
- qpti
->res_out_ptr
) == 0)
205 qregs
->hcctrl
= HCCTRL_CRIRQ
;
208 switch(mbox_param
[param
[0]] & 0xf) {
209 case 6: param
[5] = qregs
->mbox5
;
210 case 5: param
[4] = qregs
->mbox4
;
211 case 4: param
[3] = qregs
->mbox3
;
212 case 3: param
[2] = qregs
->mbox2
;
213 case 2: param
[1] = qregs
->mbox1
;
214 case 1: param
[0] = qregs
->mbox0
;
217 qregs
->sbus_semaphore
&= ~(SBUS_SEMAPHORE_LCK
);
221 static int qlogicpti_reset_hardware(struct Scsi_Host
*host
)
223 struct qlogicpti
*qpti
= (struct qlogicpti
*) host
->hostdata
;
224 struct qlogicpti_regs
*qregs
= qpti
->qregs
;
226 unsigned short risc_code_addr
;
230 if(qpti
->is_pti
!= 0)
231 risc_code_addr
= pti_risc_code_addr01
;
233 risc_code_addr
= sbus_risc_code_addr01
;
235 save_flags(flags
); cli();
237 qregs
->hcctrl
= HCCTRL_PAUSE
;
239 /* Only reset the scsi bus if it is not free. */
240 if(qregs
->cpu_pctrl
& CPU_PCTRL_BSY
) {
241 qregs
->cpu_oride
= CPU_ORIDE_RMOD
;
242 qregs
->cpu_cmd
= CPU_CMD_BRESET
;
246 qregs
->sbus_ctrl
= SBUS_CTRL_RESET
;
247 qregs
->cmd_dma_ctrl
= (DMA_CTRL_CCLEAR
| DMA_CTRL_CIRQ
);
248 qregs
->data_dma_ctrl
= (DMA_CTRL_CCLEAR
| DMA_CTRL_CIRQ
);
250 loop_count
= DEFAULT_LOOP_COUNT
;
251 while(--loop_count
&& ((qregs
->mbox0
& 0xff) == 0x04))
254 printk(KERN_EMERG
"qlogicpti: reset_hardware loop timeout\n");
256 qregs
->hcctrl
= HCCTRL_PAUSE
;
257 set_sbus_cfg1(qregs
, qpti
->bursts
);
258 qlogicpti_enable_irqs(qregs
);
260 if(qregs
->risc_psr
& RISC_PSR_ULTRA
) {
262 qregs
->risc_mtreg
= (RISC_MTREG_P0ULTRA
| RISC_MTREG_P1ULTRA
);
265 qregs
->risc_mtreg
= (RISC_MTREG_P0DFLT
| RISC_MTREG_P1DFLT
);
268 /* Release the RISC processor. */
269 qregs
->hcctrl
= HCCTRL_REL
;
271 /* Get RISC to start executing the firmware code. */
272 param
[0] = MBOX_EXEC_FIRMWARE
;
273 param
[1] = risc_code_addr
;
274 if(qlogicpti_mbox_command(qpti
, param
, 1)) {
275 printk(KERN_EMERG
"qlogicpti%d: Cannot execute ISP firmware.\n",
277 restore_flags(flags
);
281 /* Set initiator scsi ID. */
282 param
[0] = MBOX_SET_INIT_SCSI_ID
;
283 param
[1] = qpti
->host_param
.initiator_scsi_id
;
284 if(qlogicpti_mbox_command(qpti
, param
, 1) ||
285 (param
[0] != MBOX_COMMAND_COMPLETE
)) {
286 printk(KERN_EMERG
"qlogicpti%d: Cannot set initiator SCSI ID.\n",
288 restore_flags(flags
);
292 /* Initialize state of the queues, both hw and sw. */
293 qpti
->req_in_ptr
= qpti
->res_out_ptr
= 0;
295 param
[0] = MBOX_INIT_RES_QUEUE
;
296 param
[1] = RES_QUEUE_LEN
+ 1;
297 param
[2] = (u_short
) (qpti
->res_dvma
>> 16);
298 param
[3] = (u_short
) (qpti
->res_dvma
& 0xffff);
299 param
[4] = param
[5] = 0;
300 if(qlogicpti_mbox_command(qpti
, param
, 1)) {
301 printk(KERN_EMERG
"qlogicpti%d: Cannot init response queue.\n",
303 restore_flags(flags
);
307 param
[0] = MBOX_INIT_REQ_QUEUE
;
308 param
[1] = QLOGICISP_REQ_QUEUE_LEN
+ 1;
309 param
[2] = (u_short
) (qpti
->req_dvma
>> 16);
310 param
[3] = (u_short
) (qpti
->req_dvma
& 0xffff);
311 param
[4] = param
[5] = 0;
312 if(qlogicpti_mbox_command(qpti
, param
, 1)) {
313 printk(KERN_EMERG
"qlogicpti%d: Cannot init request queue.\n",
315 restore_flags(flags
);
319 param
[0] = MBOX_SET_RETRY_COUNT
;
320 param
[1] = qpti
->host_param
.retry_count
;
321 param
[2] = qpti
->host_param
.retry_delay
;
322 qlogicpti_mbox_command(qpti
, param
, 0);
324 param
[0] = MBOX_SET_TAG_AGE_LIMIT
;
325 param
[1] = qpti
->host_param
.tag_aging
;
326 qlogicpti_mbox_command(qpti
, param
, 0);
328 for(i
= 0; i
< MAX_TARGETS
; i
++) {
329 param
[0] = MBOX_GET_DEV_QUEUE_PARAMS
;
331 qlogicpti_mbox_command(qpti
, param
, 0);
334 param
[0] = MBOX_GET_FIRMWARE_STATUS
;
335 qlogicpti_mbox_command(qpti
, param
, 0);
337 param
[0] = MBOX_SET_SELECT_TIMEOUT
;
338 param
[1] = qpti
->host_param
.selection_timeout
;
339 qlogicpti_mbox_command(qpti
, param
, 0);
341 for(i
= 0; i
< MAX_TARGETS
; i
++) {
342 param
[0] = MBOX_SET_TARGET_PARAMS
;
344 param
[2] = (qpti
->dev_param
[i
].device_flags
<< 8);
345 param
[3] = (qpti
->dev_param
[i
].synchronous_offset
<< 8) |
346 qpti
->dev_param
[i
].synchronous_period
;
347 qlogicpti_mbox_command(qpti
, param
, 0);
350 restore_flags(flags
);
354 #define PTI_RESET_LIMIT 400
356 static int __init
qlogicpti_load_firmware(struct qlogicpti
*qpti
)
358 struct qlogicpti_regs
*qregs
= qpti
->qregs
;
359 unsigned short csum
= 0;
360 unsigned short param
[6];
361 unsigned short *risc_code
, risc_code_addr
, risc_code_length
;
363 #if !defined(MODULE) && !defined(__sparc_v9__)
364 unsigned long dvma_addr
;
368 if(qpti
->is_pti
!= 0) {
369 risc_code
= &pti_risc_code01
[0];
370 risc_code_addr
= pti_risc_code_addr01
;
371 risc_code_length
= pti_risc_code_length01
;
373 risc_code
= &sbus_risc_code01
[0];
374 risc_code_addr
= sbus_risc_code_addr01
;
375 risc_code_length
= sbus_risc_code_length01
;
378 save_flags(flags
); cli();
380 /* Verify the checksum twice, one before loading it, and once
381 * afterwards via the mailbox commands.
383 for(i
= 0; i
< risc_code_length
; i
++)
384 csum
+= risc_code
[i
];
386 printk(KERN_EMERG
"qlogicpti%d: Aieee, firmware checksum failed!",
390 qregs
->sbus_ctrl
= SBUS_CTRL_RESET
;
391 qregs
->cmd_dma_ctrl
= (DMA_CTRL_CCLEAR
| DMA_CTRL_CIRQ
);
392 qregs
->data_dma_ctrl
= (DMA_CTRL_CCLEAR
| DMA_CTRL_CIRQ
);
393 timeout
= PTI_RESET_LIMIT
;
394 while(--timeout
&& (qregs
->sbus_ctrl
& SBUS_CTRL_RESET
))
397 printk(KERN_EMERG
"qlogicpti%d: Cannot reset the ISP.", qpti
->qpti_id
);
401 qregs
->hcctrl
= HCCTRL_RESET
;
404 qregs
->sbus_ctrl
= (SBUS_CTRL_GENAB
| SBUS_CTRL_ERIRQ
);
405 set_sbus_cfg1(qregs
, qpti
->bursts
);
406 qregs
->sbus_semaphore
= 0;
408 if(qregs
->risc_psr
& RISC_PSR_ULTRA
) {
410 qregs
->risc_mtreg
= (RISC_MTREG_P0ULTRA
| RISC_MTREG_P1ULTRA
);
413 qregs
->risc_mtreg
= (RISC_MTREG_P0DFLT
| RISC_MTREG_P1DFLT
);
416 qregs
->hcctrl
= HCCTRL_REL
;
418 /* Pin lines are only stable while RISC is paused. */
419 qregs
->hcctrl
= HCCTRL_PAUSE
;
420 if(qregs
->cpu_pdiff
& CPU_PDIFF_MODE
)
421 qpti
->differential
= 1;
423 qpti
->differential
= 0;
424 qregs
->hcctrl
= HCCTRL_REL
;
426 param
[0] = MBOX_STOP_FIRMWARE
;
427 param
[1] = param
[2] = param
[3] = param
[4] = param
[5] = 0;
428 if(qlogicpti_mbox_command(qpti
, param
, 1)) {
429 printk(KERN_EMERG
"qlogicpti%d: Cannot stop firmware for reload.\n",
431 restore_flags(flags
);
435 /* Load the firmware. */
436 #if !defined(MODULE) && !defined(__sparc_v9__)
437 if (sparc_cpu_model
!= sun4d
) {
438 dvma_addr
= (unsigned long) mmu_lockarea((char *)&risc_code
[0],
439 (sizeof(u_short
) * risc_code_length
));
440 param
[0] = MBOX_LOAD_RAM
;
441 param
[1] = risc_code_addr
;
442 param
[2] = (dvma_addr
>> 16);
443 param
[3] = (dvma_addr
& 0xffff);
444 param
[4] = (sizeof(u_short
) * risc_code_length
);
445 if(qlogicpti_mbox_command(qpti
, param
, 1) ||
446 (param
[0] != MBOX_COMMAND_COMPLETE
)) {
447 printk(KERN_EMERG
"qlogicpti%d: Firmware dload failed, I'm bolixed!\n",
449 restore_flags(flags
);
452 mmu_unlockarea((char *)dvma_addr
, (sizeof(u_short
) * risc_code_length
));
455 /* We need to do it this slow way always on Ultra, SS[12]000. */
456 for(i
= 0; i
< risc_code_length
; i
++) {
457 param
[0] = MBOX_WRITE_RAM_WORD
;
458 param
[1] = risc_code_addr
+ i
;
459 param
[2] = risc_code
[i
];
460 if(qlogicpti_mbox_command(qpti
, param
, 1) ||
461 param
[0] != MBOX_COMMAND_COMPLETE
) {
462 printk("qlogicpti%d: Firmware dload failed, I'm bolixed!\n",
464 restore_flags(flags
);
469 /* Reset the ISP again. */
470 qregs
->hcctrl
= HCCTRL_RESET
;
473 qlogicpti_enable_irqs(qregs
);
474 qregs
->sbus_semaphore
= 0;
475 qregs
->hcctrl
= HCCTRL_REL
;
477 /* Ask ISP to verify the checksum of the new code. */
478 param
[0] = MBOX_VERIFY_CHECKSUM
;
479 param
[1] = risc_code_addr
;
480 if(qlogicpti_mbox_command(qpti
, param
, 1) ||
481 (param
[0] != MBOX_COMMAND_COMPLETE
)) {
482 printk(KERN_EMERG
"qlogicpti%d: New firmware csum failure!\n",
484 restore_flags(flags
);
488 /* Start using newly downloaded firmware. */
489 param
[0] = MBOX_EXEC_FIRMWARE
;
490 param
[1] = risc_code_addr
;
491 qlogicpti_mbox_command(qpti
, param
, 1);
493 param
[0] = MBOX_ABOUT_FIRMWARE
;
494 if(qlogicpti_mbox_command(qpti
, param
, 1) ||
495 (param
[0] != MBOX_COMMAND_COMPLETE
)) {
496 printk(KERN_EMERG
"qlogicpti%d: AboutFirmware cmd fails.\n",
498 restore_flags(flags
);
502 /* Snag the major and minor revisions from the result. */
503 qpti
->fware_majrev
= param
[1];
504 qpti
->fware_minrev
= param
[2];
506 if(qpti
->is_pti
!= 0) {
507 /* Load scsi initiator ID and interrupt level into sbus static ram. */
508 param
[0] = MBOX_WRITE_RAM_WORD
;
510 param
[2] = (unsigned short) qpti
->scsi_id
;
511 qlogicpti_mbox_command(qpti
, param
, 1);
513 param
[0] = MBOX_WRITE_RAM_WORD
;
515 param
[2] = (unsigned short) 3;
516 qlogicpti_mbox_command(qpti
, param
, 1);
519 restore_flags(flags
);
523 static int qlogicpti_verify_tmon(struct qlogicpti
*qpti
)
525 int curstat
= *qpti
->sreg
;
528 if(!(curstat
& SREG_FUSE
) && (qpti
->swsreg
& SREG_FUSE
))
529 printk("qlogicpti%d: Fuse returned to normal state.\n", qpti
->qpti_id
);
530 if(!(curstat
& SREG_TPOWER
) && (qpti
->swsreg
& SREG_TPOWER
))
531 printk("qlogicpti%d: termpwr back to normal state.\n", qpti
->qpti_id
);
532 if(curstat
!= qpti
->swsreg
) {
534 if(curstat
& SREG_FUSE
) {
536 printk("qlogicpti%d: Fuse is open!\n", qpti
->qpti_id
);
538 if(curstat
& SREG_TPOWER
) {
540 printk("qlogicpti%d: termpwr failure\n", qpti
->qpti_id
);
542 if(qpti
->differential
&&
543 (curstat
& SREG_DSENSE
) != SREG_DSENSE
) {
545 printk("qlogicpti%d: You have a single ended device on a "
546 "differential bus! Please fix!\n", qpti
->qpti_id
);
548 qpti
->swsreg
= curstat
;
554 static inline void qlogicpti_set_hostdev_defaults(struct qlogicpti
*qpti
)
558 qpti
->host_param
.initiator_scsi_id
= qpti
->scsi_id
;
559 qpti
->host_param
.bus_reset_delay
= 3;
560 qpti
->host_param
.retry_count
= 0;
561 qpti
->host_param
.retry_delay
= 5;
562 qpti
->host_param
.async_data_setup_time
= 3;
563 qpti
->host_param
.req_ack_active_negation
= 1;
564 qpti
->host_param
.data_line_active_negation
= 1;
565 qpti
->host_param
.data_dma_burst_enable
= 1;
566 qpti
->host_param
.command_dma_burst_enable
= 1;
567 qpti
->host_param
.tag_aging
= 8;
568 qpti
->host_param
.selection_timeout
= 250;
569 qpti
->host_param
.max_queue_depth
= 256;
571 for(i
= 0; i
< MAX_TARGETS
; i
++) {
572 qpti
->dev_param
[i
].device_flags
= 0xf9;
573 qpti
->dev_param
[i
].execution_throttle
= 16;
574 qpti
->dev_param
[i
].synchronous_period
= 16;
575 qpti
->dev_param
[i
].synchronous_offset
= 12;
576 qpti
->dev_param
[i
].device_enable
= 1;
580 static void do_qlogicpti_intr_handler(int irq
, void *dev_id
, struct pt_regs
*regs
);
582 static void do_qlogicpti_intr_handler_sun4m(int irq
, void *dev_id
, struct pt_regs
*regs
);
585 /* Detect all PTI Qlogic ISP's in the machine. */
586 int __init
qlogicpti_detect(Scsi_Host_Template
*tpnt
)
588 struct qlogicpti
*qpti
, *qlink
;
589 struct Scsi_Host
*qpti_host
;
590 struct linux_sbus
*sbus
;
591 struct linux_sbus_device
*qpti_dev
, *sbdev_iter
;
592 struct qlogicpti_regs
*qregs
;
593 volatile unsigned char *sreg
;
594 unsigned char bsizes
, bsizes_more
;
595 int nqptis
= 0, nqptis_in_use
= 0;
599 tpnt
->proc_dir
= &proc_scsi_qlogicpti
;
603 for_each_sbus(sbus
) {
604 for_each_sbusdev(sbdev_iter
, sbus
) {
605 qpti_dev
= sbdev_iter
;
607 /* Is this a red snapper? */
608 if(strcmp(qpti_dev
->prom_name
, "ptisp") &&
609 strcmp(qpti_dev
->prom_name
, "PTI,ptisp") &&
610 strcmp(qpti_dev
->prom_name
, "QLGC,isp"))
613 /* Sometimes Antares cards come up not completely
614 * setup, and we get a report of a zero IRQ.
615 * Skip over them in such cases so we survive.
617 if(qpti_dev
->irqs
[0] == 0) {
618 printk("qpti%d: Adapter reports no interrupt, "
619 "skipping over this card.", nqptis
);
623 /* Yep, register and allocate software state. */
624 qpti_host
= scsi_register(tpnt
, sizeof(struct qlogicpti
));
626 panic("Cannot register PTI Qlogic ISP SCSI host");
627 qpti
= (struct qlogicpti
*) qpti_host
->hostdata
;
629 panic("No qpti in hostdata");
631 /* We are wide capable, 16 targets. */
632 qpti_host
->max_id
= MAX_TARGETS
;
635 qpti_host
->unchecked_isa_dma
= 1;
638 /* Setup back pointers and misc. state. */
639 qpti
->qhost
= qpti_host
;
640 qpti
->qdev
= qpti_dev
;
641 qpti
->qpti_id
= nqptis
++;
643 /* Insert this one into the global interrupt service chain. */
646 while(qlink
->next
) qlink
= qlink
->next
;
653 /* More misc. prom information. */
654 qpti_node
= qpti_dev
->prom_node
;
655 prom_getstring(qpti_node
, "name", qpti
->prom_name
,
656 sizeof(qpti
->prom_name
));
657 qpti
->prom_node
= qpti_node
;
659 qpti
->is_pti
= is_pti
=
660 (strcmp (qpti
->prom_name
, "QLGC,isp") != 0);
662 /* Setup the reg property for this device. */
663 prom_apply_sbus_ranges(qpti
->qdev
->my_bus
,
664 qpti
->qdev
->reg_addrs
,
667 /* Map in Qlogic,ISP regs and the PTI status reg. */
668 qpti
->qregs
= qregs
= (struct qlogicpti_regs
*)
669 sparc_alloc_io(qpti
->qdev
->reg_addrs
[0].phys_addr
, 0,
670 qpti
->qdev
->reg_addrs
[0].reg_size
,
671 "PTI Qlogic/ISP Registers",
672 qpti
->qdev
->reg_addrs
[0].which_io
, 0x0);
674 panic("PTI Qlogic/ISP registers unmappable");
677 /* Map this one read only. */
678 qpti
->sreg
= sreg
= (volatile unsigned char *)
679 sparc_alloc_io((qpti
->qdev
->reg_addrs
[0].phys_addr
+
681 sizeof(unsigned char),
682 "PTI Qlogic/ISP Status Reg",
683 qpti
->qdev
->reg_addrs
[0].which_io
, 1);
685 panic("PTI Qlogic/ISP status reg unmappable");
689 qpti_host
->base
= (unsigned char *)qregs
;
690 qpti_host
->io_port
= (unsigned int) ((unsigned long)qregs
);
691 qpti_host
->n_io_port
= (unsigned char)
692 qpti
->qdev
->reg_addrs
[0].reg_size
;
694 qpti_host
->irq
= qpti
->irq
= qpti
->qdev
->irqs
[0];
696 /* On Ultra and S{S1,C2}000 we must always call request_irq for each
697 * qpti, so that imap registers get setup etc.
698 * But irq values are different in that case anyway...
699 * Otherwise allocate the irq only if necessary.
701 for_each_qlogicpti(qlink
) {
702 if((qlink
!= qpti
) && (qpti
->irq
== qlink
->irq
)) {
703 goto qpti_irq_acquired
; /* BASIC rulez */
706 if(request_irq(qpti
->qhost
->irq
,
708 (sparc_cpu_model
== sun4m
|| sparc_cpu_model
== sun4c
) ?
709 do_qlogicpti_intr_handler_sun4m
:
711 do_qlogicpti_intr_handler
,
712 SA_SHIRQ
, "PTI Qlogic/ISP SCSI", qpti
)) {
713 printk("Cannot acquire PTI Qlogic/ISP irq line\n");
714 /* XXX Unmap regs, unregister scsi host, free things. */
718 printk("qpti%d: IRQ %s ",
719 qpti
->qpti_id
, __irq_itoa(qpti
->qhost
->irq
));
721 /* Figure out our scsi ID on the bus */
722 qpti
->scsi_id
= prom_getintdefault(qpti
->prom_node
,
725 if(qpti
->scsi_id
== -1)
726 qpti
->scsi_id
= prom_getintdefault(qpti
->prom_node
,
729 if(qpti
->scsi_id
== -1)
731 prom_getintdefault(qpti
->qdev
->my_bus
->prom_node
,
732 "scsi-initiator-id", 7);
733 qpti
->qhost
->this_id
= qpti
->scsi_id
;
734 printk("SCSI ID %d ", qpti
->scsi_id
);
736 /* Check for what the best SBUS burst we can use happens
737 * to be on this machine.
739 bsizes
= prom_getintdefault(qpti
->prom_node
,"burst-sizes",0xff);
741 bsizes_more
= prom_getintdefault(qpti
->qdev
->my_bus
->prom_node
,
742 "burst-sizes", 0xff);
743 if(bsizes_more
!= 0xff)
744 bsizes
&= bsizes_more
;
745 if(bsizes
== 0xff || (bsizes
& DMA_BURST16
)==0 ||
746 (bsizes
& DMA_BURST32
) == 0)
747 bsizes
= (DMA_BURST32
- 1);
748 qpti
->bursts
= bsizes
;
750 /* Clear out Scsi_Cmnd array. */
751 memset(qpti
->cmd_slots
, 0, sizeof(qpti
->cmd_slots
));
753 /* The request and response queues must each be aligned
757 #define QSIZE(entries) (((entries) + 1) * QUEUE_ENTRY_LEN)
759 qpti
->res_cpu
= sparc_dvma_malloc(QSIZE(RES_QUEUE_LEN
),
760 "PTISP Response Queue",
762 qpti
->req_cpu
= sparc_dvma_malloc(QSIZE(QLOGICISP_REQ_QUEUE_LEN
),
763 "PTISP Request Queue",
769 /* Set adapter and per-device default values. */
770 qlogicpti_set_hostdev_defaults(qpti
);
772 /* Load the firmware. */
773 /* XXX Find out where is it possible to download
774 our sbus_risc_code on non-PTI ISP1000. */
775 if(is_pti
&& qlogicpti_load_firmware(qpti
))
776 panic("SBUS Qlogic/ISP firmware load failed");
779 /* Check the PTI status reg. */
780 if(qlogicpti_verify_tmon(qpti
))
781 panic("PTI Qlogic/ISP tmon verification failed");
784 /* Reset the ISP and init res/req queues. */
785 if(qlogicpti_reset_hardware(qpti_host
))
786 panic("PTI Qlogic/ISP cannot be reset");
789 printk("(Firmware v%d.%d)",
790 qpti
->fware_majrev
, qpti
->fware_minrev
);
794 prom_getstring (qpti_node
, "isp-fcode", buffer
, 60);
796 printk("(Firmware %s)", buffer
);
797 if (prom_getbool(qpti_node
, "differential"))
798 qpti
->differential
= 1;
801 printk (" [%s Wide, using %s interface]\n",
802 (qpti
->ultra
? "Ultra" : "Fast"),
803 (qpti
->differential
? "differential" : "single ended"));
809 printk("QPTI: Total of %d PTI Qlogic/ISP hosts found, %d actually in use.\n",
810 nqptis
, nqptis_in_use
);
811 qptis_running
= nqptis_in_use
;
815 int qlogicpti_release(struct Scsi_Host
*host
)
817 struct qlogicpti
*qpti
= (struct qlogicpti
*) host
->hostdata
;
818 struct qlogicpti_regs
*qregs
= qpti
->qregs
;
820 /* Shut up the card. */
821 qregs
->sbus_ctrl
= 0;
823 /* Free IRQ handler and unmap Qlogic,ISP and PTI status regs. */
824 free_irq(host
->irq
, NULL
);
825 unmapioaddr((unsigned long)qregs
);
826 /* QLGC,isp doesn't have status reg */
827 if (strcmp (qpti
->prom_name
, "QLGC,isp"))
828 unmapioaddr((unsigned long)qpti
->sreg
);
833 const char *qlogicpti_info(struct Scsi_Host
*host
)
836 struct qlogicpti
*qpti
= (struct qlogicpti
*) host
->hostdata
;
838 sprintf(buf
, "PTI Qlogic,ISP SBUS SCSI irq %s regs at %08lx",
839 __irq_itoa(qpti
->qhost
->irq
), (unsigned long) qpti
->qregs
);
843 /* I am a certified frobtronicist. */
844 static inline void marker_frob(struct Command_Entry
*cmd
)
846 struct Marker_Entry
*marker
= (struct Marker_Entry
*) cmd
;
848 memset(marker
, 0, sizeof(struct Marker_Entry
));
849 marker
->hdr
.entry_cnt
= 1;
850 marker
->hdr
.entry_type
= ENTRY_MARKER
;
851 marker
->modifier
= SYNC_ALL
;
855 static inline void cmd_frob(struct Command_Entry
*cmd
, Scsi_Cmnd
*Cmnd
,
856 struct qlogicpti
*qpti
)
858 memset(cmd
, 0, sizeof(struct Command_Entry
));
859 cmd
->hdr
.entry_cnt
= 1;
860 cmd
->hdr
.entry_type
= ENTRY_COMMAND
;
861 cmd
->target_id
= Cmnd
->target
;
862 cmd
->target_lun
= Cmnd
->lun
;
863 cmd
->cdb_length
= Cmnd
->cmd_len
;
864 cmd
->control_flags
= 0;
865 if(Cmnd
->device
->tagged_supported
) {
866 if(qpti
->cmd_count
[Cmnd
->target
] == 0)
867 qpti
->tag_ages
[Cmnd
->target
] = jiffies
;
868 if((jiffies
- qpti
->tag_ages
[Cmnd
->target
]) > (5*HZ
)) {
869 cmd
->control_flags
= CFLAG_ORDERED_TAG
;
870 qpti
->tag_ages
[Cmnd
->target
] = jiffies
;
872 cmd
->control_flags
= CFLAG_SIMPLE_TAG
;
874 if((Cmnd
->cmnd
[0] == WRITE_6
) ||
875 (Cmnd
->cmnd
[0] == WRITE_10
) ||
876 (Cmnd
->cmnd
[0] == WRITE_12
))
877 cmd
->control_flags
|= CFLAG_WRITE
;
879 cmd
->control_flags
|= CFLAG_READ
;
881 memcpy(cmd
->cdb
, Cmnd
->cmnd
, Cmnd
->cmd_len
);
884 /* Do it to it baby. */
885 static inline u_int
load_cmd(Scsi_Cmnd
*Cmnd
, struct Command_Entry
*cmd
,
886 struct qlogicpti
*qpti
, struct qlogicpti_regs
*qregs
,
887 u_int in_ptr
, u_int out_ptr
)
890 struct scatterlist
*sg
;
891 int sg_count
= Cmnd
->use_sg
;
895 mmu_get_scsi_sgl((struct mmu_sglist
*)Cmnd
->buffer
, (Cmnd
->use_sg
- 1),
898 cmd
->segment_cnt
= sg_count
;
899 sg
= (struct scatterlist
*) Cmnd
->request_buffer
;
902 /* Fill in first four sg entries: */
906 for(i
= 0; i
< n
; i
++, sg
++) {
907 ds
[i
].d_base
= (u_int
) sg
->dvma_address
;
908 ds
[i
].d_count
= (u_int
) sg
->length
;
911 while(sg_count
> 0) {
912 struct Continuation_Entry
*cont
;
914 ++cmd
->hdr
.entry_cnt
;
915 cont
= (struct Continuation_Entry
*) &qpti
->req_cpu
[in_ptr
];
916 in_ptr
= NEXT_REQ_PTR(in_ptr
);
917 if(in_ptr
== out_ptr
) {
918 printk(KERN_EMERG
"qlogicpti: Unexpected request queue overflow\n");
921 cont
->hdr
.entry_type
= ENTRY_CONTINUATION
;
922 cont
->hdr
.entry_cnt
= 0;
923 cont
->hdr
.sys_def_1
= 0;
930 for(i
= 0; i
< n
; i
++, sg
++) {
931 ds
[i
].d_base
= (u_int
) sg
->dvma_address
;
932 ds
[i
].d_count
= (u_int
) sg
->length
;
937 /* XXX Casts are extremely gross, but with 64-bit cpu addresses
938 * XXX and 32-bit SBUS DVMA addresses what am I to do? -DaveM
940 Cmnd
->SCp
.ptr
= (char *)((unsigned long)
941 mmu_get_scsi_one((char *)Cmnd
->request_buffer
,
942 Cmnd
->request_bufflen
,
943 qpti
->qdev
->my_bus
));
945 cmd
->dataseg
[0].d_base
= (u_int
) ((unsigned long)Cmnd
->SCp
.ptr
);
946 cmd
->dataseg
[0].d_count
= Cmnd
->request_bufflen
;
947 cmd
->segment_cnt
= 1;
950 /* Committed, record Scsi_Cmd so we can find it later. */
951 cmd
->handle
= in_ptr
;
952 qpti
->cmd_slots
[in_ptr
] = Cmnd
;
954 qpti
->cmd_count
[Cmnd
->target
]++;
955 qregs
->mbox4
= in_ptr
;
956 qpti
->req_in_ptr
= in_ptr
;
961 static inline void update_can_queue(struct Scsi_Host
*host
, u_int in_ptr
, u_int out_ptr
)
963 /* Temporary workaround until bug is found and fixed (one bug has been found
964 already, but fixing it makes things even worse) -jj */
965 int num_free
= QLOGICISP_REQ_QUEUE_LEN
- REQ_QUEUE_DEPTH(in_ptr
, out_ptr
) - 64;
966 host
->can_queue
= host
->host_busy
+ num_free
;
967 host
->sg_tablesize
= QLOGICISP_MAX_SG(num_free
);
971 * The middle SCSI layer ensures that queuecommand never gets invoked
972 * concurrently with itself or the interrupt handler (though the
973 * interrupt handler may call this routine as part of
974 * request-completion handling).
976 * "This code must fly." -davem
978 int qlogicpti_queuecommand(Scsi_Cmnd
*Cmnd
, void (*done
)(Scsi_Cmnd
*))
980 struct Scsi_Host
*host
= Cmnd
->host
;
981 struct qlogicpti
*qpti
= (struct qlogicpti
*) host
->hostdata
;
982 struct qlogicpti_regs
*qregs
= qpti
->qregs
;
983 u_int in_ptr
= qpti
->req_in_ptr
;
984 u_int out_ptr
= qregs
->mbox4
;
985 struct Command_Entry
*cmd
= (struct Command_Entry
*) &qpti
->req_cpu
[in_ptr
];
987 Cmnd
->scsi_done
= done
;
988 in_ptr
= NEXT_REQ_PTR(in_ptr
);
989 if(in_ptr
== out_ptr
) {
990 printk(KERN_EMERG
"qlogicpti%d: request queue overflow\n",qpti
->qpti_id
);
992 /* Unfortunately, unless you use the new EH code, which
993 * we don't, the midlayer will ignore the return value,
994 * which is insane. We pick up the pieces like this.
996 Cmnd
->result
= DID_BUS_BUSY
;
1000 if(qpti
->send_marker
) {
1002 qpti
->send_marker
= 0;
1003 if(NEXT_REQ_PTR(in_ptr
) == out_ptr
) {
1004 qregs
->mbox4
= in_ptr
;
1005 qpti
->req_in_ptr
= in_ptr
;
1006 printk(KERN_EMERG
"qlogicpti%d: request queue overflow\n",
1009 /* Unfortunately, unless you use the new EH code, which
1010 * we don't, the midlayer will ignore the return value,
1011 * which is insane. We pick up the pieces like this.
1013 Cmnd
->result
= DID_BUS_BUSY
;
1017 cmd
= (struct Command_Entry
*) &qpti
->req_cpu
[in_ptr
];
1018 in_ptr
= NEXT_REQ_PTR(in_ptr
);
1020 cmd_frob(cmd
, Cmnd
, qpti
);
1021 if((in_ptr
= load_cmd(Cmnd
, cmd
, qpti
, qregs
, in_ptr
, out_ptr
)) == -1) {
1022 /* Unfortunately, unless you use the new EH code, which
1023 * we don't, the midlayer will ignore the return value,
1024 * which is insane. We pick up the pieces like this.
1026 Cmnd
->result
= DID_BUS_BUSY
;
1030 update_can_queue(host
, in_ptr
, out_ptr
);
1034 static int qlogicpti_return_status(struct Status_Entry
*sts
)
1036 int host_status
= DID_ERROR
;
1038 switch(sts
->completion_status
) {
1040 host_status
= DID_OK
;
1043 if (!(sts
->state_flags
& SF_GOT_BUS
))
1044 host_status
= DID_NO_CONNECT
;
1045 else if (!(sts
->state_flags
& SF_GOT_TARGET
))
1046 host_status
= DID_BAD_TARGET
;
1047 else if (!(sts
->state_flags
& SF_SENT_CDB
))
1048 host_status
= DID_ERROR
;
1049 else if (!(sts
->state_flags
& SF_TRANSFERRED_DATA
))
1050 host_status
= DID_ERROR
;
1051 else if (!(sts
->state_flags
& SF_GOT_STATUS
))
1052 host_status
= DID_ERROR
;
1053 else if (!(sts
->state_flags
& SF_GOT_SENSE
))
1054 host_status
= DID_ERROR
;
1057 case CS_TRANSPORT_ERROR
:
1058 host_status
= DID_ERROR
;
1060 case CS_RESET_OCCURRED
:
1062 host_status
= DID_RESET
;
1065 host_status
= DID_ABORT
;
1068 host_status
= DID_TIME_OUT
;
1070 case CS_DATA_OVERRUN
:
1071 case CS_COMMAND_OVERRUN
:
1072 case CS_STATUS_OVERRUN
:
1073 case CS_BAD_MESSAGE
:
1074 case CS_NO_MESSAGE_OUT
:
1075 case CS_EXT_ID_FAILED
:
1076 case CS_IDE_MSG_FAILED
:
1077 case CS_ABORT_MSG_FAILED
:
1078 case CS_NOP_MSG_FAILED
:
1079 case CS_PARITY_ERROR_MSG_FAILED
:
1080 case CS_DEVICE_RESET_MSG_FAILED
:
1081 case CS_ID_MSG_FAILED
:
1082 case CS_UNEXP_BUS_FREE
:
1083 host_status
= DID_ERROR
;
1085 case CS_DATA_UNDERRUN
:
1086 host_status
= DID_OK
;
1089 printk(KERN_EMERG
"qlogicpti : unknown completion status 0x%04x\n",
1090 sts
->completion_status
);
1091 host_status
= DID_ERROR
;
1095 return (sts
->scsi_status
& STATUS_MASK
) | (host_status
<< 16);
1098 static __inline__
int qlogicpti_intr_handler(struct qlogicpti
*qpti
)
1101 struct Status_Entry
*sts
;
1102 u_int in_ptr
, out_ptr
;
1103 struct qlogicpti_regs
*qregs
;
1105 if(!(qpti
->qregs
->sbus_stat
& SBUS_STAT_RINT
))
1108 qregs
= qpti
->qregs
;
1110 in_ptr
= qregs
->mbox5
;
1111 qregs
->hcctrl
= HCCTRL_CRIRQ
;
1112 if(qregs
->sbus_semaphore
& SBUS_SEMAPHORE_LCK
) {
1113 switch(qregs
->mbox0
) {
1114 case ASYNC_SCSI_BUS_RESET
:
1115 case EXECUTION_TIMEOUT_RESET
:
1116 qpti
->send_marker
= 1;
1118 case INVALID_COMMAND
:
1119 case HOST_INTERFACE_ERROR
:
1121 case COMMAND_PARAM_ERROR
:
1124 qregs
->sbus_semaphore
= 0;
1127 /* This looks like a network driver! */
1128 out_ptr
= qpti
->res_out_ptr
;
1129 while(out_ptr
!= in_ptr
) {
1132 sts
= (struct Status_Entry
*) &qpti
->res_cpu
[out_ptr
];
1133 out_ptr
= NEXT_RES_PTR(out_ptr
);
1135 /* We store an index in the handle, not the pointer in
1136 * some form. This avoids problems due to the fact
1137 * that the handle provided is only 32-bits. -DaveM
1139 cmd_slot
= sts
->handle
;
1140 Cmnd
= qpti
->cmd_slots
[cmd_slot
];
1141 qpti
->cmd_slots
[cmd_slot
] = NULL
;
1143 if(sts
->completion_status
== CS_RESET_OCCURRED
||
1144 sts
->completion_status
== CS_ABORTED
||
1145 (sts
->status_flags
& STF_BUS_RESET
))
1146 qpti
->send_marker
= 1;
1148 if(sts
->state_flags
& SF_GOT_SENSE
)
1149 memcpy(Cmnd
->sense_buffer
, sts
->req_sense_data
,
1150 sizeof(Cmnd
->sense_buffer
));
1152 if(sts
->hdr
.entry_type
== ENTRY_STATUS
)
1153 Cmnd
->result
= qlogicpti_return_status(sts
);
1155 Cmnd
->result
= DID_ERROR
<< 16;
1158 mmu_release_scsi_sgl((struct mmu_sglist
*)
1161 qpti
->qdev
->my_bus
);
1163 mmu_release_scsi_one((__u32
)((unsigned long)Cmnd
->SCp
.ptr
),
1164 Cmnd
->request_bufflen
,
1165 qpti
->qdev
->my_bus
);
1167 qpti
->cmd_count
[Cmnd
->target
]--;
1168 qregs
->mbox5
= out_ptr
;
1169 Cmnd
->scsi_done(Cmnd
);
1171 qpti
->res_out_ptr
= out_ptr
;
1175 #ifndef __sparc_v9__
1177 static void do_qlogicpti_intr_handler_sun4m(int irq
, void *dev_id
, struct pt_regs
*regs
)
1179 unsigned long flags
;
1180 struct qlogicpti
*qpti
;
1183 spin_lock_irqsave(&io_request_lock
, flags
);
1186 for_each_qlogicpti(qpti
)
1187 again
|= qlogicpti_intr_handler(qpti
);
1189 spin_unlock_irqrestore(&io_request_lock
, flags
);
1194 static void do_qlogicpti_intr_handler(int irq
, void *dev_id
, struct pt_regs
*regs
)
1196 unsigned long flags
;
1198 spin_lock_irqsave(&io_request_lock
, flags
);
1199 qlogicpti_intr_handler((struct qlogicpti
*)dev_id
);
1200 spin_unlock_irqrestore(&io_request_lock
, flags
);
1203 int qlogicpti_abort(Scsi_Cmnd
*Cmnd
)
1206 struct Scsi_Host
*host
= Cmnd
->host
;
1207 struct qlogicpti
*qpti
= (struct qlogicpti
*) host
->hostdata
;
1208 int return_status
= SCSI_ABORT_SUCCESS
;
1210 printk(KERN_WARNING
"qlogicpti : Aborting cmd for tgt[%d] lun[%d]\n",
1211 (int)Cmnd
->target
, (int)Cmnd
->lun
);
1212 qlogicpti_disable_irqs(qpti
->qregs
);
1213 param
[0] = MBOX_ABORT
;
1214 param
[1] = (((u_short
) Cmnd
->target
) << 8) | Cmnd
->lun
;
1215 param
[2] = ((unsigned int)((unsigned long)Cmnd
)) >> 16;
1216 param
[3] = ((unsigned int)((unsigned long)Cmnd
)) & 0xffff;
1217 if(qlogicpti_mbox_command(qpti
, param
, 0) ||
1218 (param
[0] != MBOX_COMMAND_COMPLETE
)) {
1219 printk(KERN_EMERG
"qlogicpti : scsi abort failure: %x\n", param
[0]);
1220 return_status
= SCSI_ABORT_ERROR
;
1222 qlogicpti_enable_irqs(qpti
->qregs
);
1223 return return_status
;
1226 int qlogicpti_reset(Scsi_Cmnd
*Cmnd
, unsigned int reset_flags
)
1229 struct Scsi_Host
*host
= Cmnd
->host
;
1230 struct qlogicpti
*qpti
= (struct qlogicpti
*) host
->hostdata
;
1231 int return_status
= SCSI_RESET_SUCCESS
;
1233 printk(KERN_WARNING
"qlogicpti : Resetting SCSI bus!\n");
1234 qlogicpti_disable_irqs(qpti
->qregs
);
1235 param
[0] = MBOX_BUS_RESET
;
1236 param
[1] = qpti
->host_param
.bus_reset_delay
;
1237 if(qlogicpti_mbox_command(qpti
, param
, 0) ||
1238 (param
[0] != MBOX_COMMAND_COMPLETE
)) {
1239 printk(KERN_EMERG
"qlogicisp : scsi bus reset failure: %x\n", param
[0]);
1240 return_status
= SCSI_RESET_ERROR
;
1242 qlogicpti_enable_irqs(qpti
->qregs
);
1243 return return_status
;
1247 Scsi_Host_Template driver_template
= QLOGICPTI
;
1249 #include "scsi_module.c"