1 /************************************************************
3 * Linux EATA SCSI PIO driver *
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. *
9 * The driver currently: *
10 * -supports all EATA-PIO boards *
11 * -only supports DASD devices *
13 * (c)1993-96 Michael Neuffer, Alfred Arnold *
14 * neuffer@goofy.zdv.uni-mainz.de *
15 * a.arnold@kfa-juelich.de *
17 * This program is free software; you can redistribute it *
18 * and/or modify it under the terms of the GNU General *
19 * Public License as published by the Free Software *
20 * Foundation; either version 2 of the License, or *
21 * (at your option) any later version. *
23 * This program is distributed in the hope that it will be *
24 * useful, but WITHOUT ANY WARRANTY; without even the *
25 * implied warranty of MERCHANTABILITY or FITNESS FOR A *
26 * PARTICULAR PURPOSE. See the GNU General Public License *
29 * You should have received a copy of the GNU General *
30 * Public License along with this kernel; if not, write to *
31 * the Free Software Foundation, Inc., 675 Mass Ave, *
32 * Cambridge, MA 02139, USA. *
34 ************************************************************
35 * last change: 96/07/16 OS: Linux 2.0.8 *
36 ************************************************************/
38 /* Look in eata_pio.h for configuration information */
40 #include <linux/module.h>
42 #include <linux/kernel.h>
43 #include <linux/sched.h>
44 #include <linux/string.h>
45 #include <linux/ioport.h>
46 #include <linux/malloc.h>
48 #include <linux/pci.h>
49 #include <linux/proc_fs.h>
52 #include "eata_dma_proc.h"
56 #include <linux/stat.h>
57 #include <linux/config.h> /* for CONFIG_PCI */
58 #include <linux/blk.h>
59 #include <linux/spinlock.h>
61 static uint ISAbases
[MAXISA
] =
62 {0x1F0, 0x170, 0x330, 0x230};
63 static uint ISAirqs
[MAXISA
] =
65 static unchar EISAbases
[] =
66 {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
67 static uint registered_HBAs
= 0;
68 static struct Scsi_Host
*last_HBA
= NULL
;
69 static struct Scsi_Host
*first_HBA
= NULL
;
70 static unchar reg_IRQ
[] =
71 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
72 static unchar reg_IRQL
[] =
73 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
75 static ulong int_counter
= 0;
76 static ulong queue_counter
= 0;
78 #include "eata_pio_proc.c"
81 int eata_pio_release(struct Scsi_Host
*sh
)
83 if (sh
->irq
&& reg_IRQ
[sh
->irq
] == 1) free_irq(sh
->irq
, NULL
);
84 else reg_IRQ
[sh
->irq
]--;
85 if (SD(sh
)->channel
== 0) {
86 if (sh
->io_port
&& sh
->n_io_port
)
87 release_region(sh
->io_port
, sh
->n_io_port
);
93 void IncStat(Scsi_Pointer
*SCp
, uint Increment
)
96 if ((SCp
->this_residual
-=Increment
)==0)
98 if ((--SCp
->buffers_residual
)==0) SCp
->Status
=FALSE
;
102 SCp
->ptr
=SCp
->buffer
->address
;
103 SCp
->this_residual
=SCp
->buffer
->length
;
108 void eata_pio_int_handler(int irq
, void *dev_id
, struct pt_regs
* regs
);
110 void do_eata_pio_int_handler(int irq
, void *dev_id
, struct pt_regs
* regs
)
114 spin_lock_irqsave(&io_request_lock
, flags
);
115 eata_pio_int_handler(irq
, dev_id
, regs
);
116 spin_unlock_irqrestore(&io_request_lock
, flags
);
119 void eata_pio_int_handler(int irq
, void *dev_id
, struct pt_regs
* regs
)
121 uint eata_stat
= 0xfffff;
128 struct Scsi_Host
*sh
;
135 for (x
= 1, sh
= first_HBA
; x
<= registered_HBAs
; x
++, sh
= SD(sh
)->prev
) {
138 if (inb((uint
)sh
->base
+ HA_RSTATUS
) & HA_SBUSY
)
147 base
= (uint
) cmd
->host
->base
;
151 stat
=inb(base
+HA_RSTATUS
);
156 while ((cmd
->SCp
.Status
)&&((z
>0)||(odd
)))
160 *(cmd
->SCp
.ptr
)=zwickel
>>8;
161 IncStat(&cmd
->SCp
,1);
164 x
=min(z
,cmd
->SCp
.this_residual
/2);
165 insw(base
+HA_RDATA
,cmd
->SCp
.ptr
,x
);
167 IncStat(&cmd
->SCp
,2*x
);
168 if ((z
>0)&&(cmd
->SCp
.this_residual
==1))
170 zwickel
=inw(base
+HA_RDATA
);
171 *(cmd
->SCp
.ptr
)=zwickel
&0xff;
172 IncStat(&cmd
->SCp
,1); z
--;
177 zwickel
=inw(base
+HA_RDATA
);
181 else /* cp->DataOut */
184 while ((cmd
->SCp
.Status
)&&((z
>0)||(odd
)))
188 zwickel
+=*(cmd
->SCp
.ptr
)<<8;
189 IncStat(&cmd
->SCp
,1);
190 outw(zwickel
,base
+HA_RDATA
);
194 x
=min(z
,cmd
->SCp
.this_residual
/2);
195 outsw(base
+HA_RDATA
,cmd
->SCp
.ptr
,x
);
197 IncStat(&cmd
->SCp
,2*x
);
198 if ((z
>0)&&(cmd
->SCp
.this_residual
==1))
200 zwickel
=*(cmd
->SCp
.ptr
);
202 IncStat(&cmd
->SCp
,1);
207 outw(zwickel
,base
+HA_RDATA
);
214 while ((stat
&HA_SDRQ
)||((stat
&HA_SMORE
)&&hd
->moresupport
));
216 /* terminate handler if HBA goes busy again, i.e. transfers
219 if (stat
&HA_SBUSY
) break;
221 /* OK, this is quite stupid, but I haven't found any correct
222 * way to get HBA&SCSI status so far */
224 if (!(inb(base
+HA_RSTATUS
)&HA_SERROR
))
226 cmd
->result
=(DID_OK
<<16);
227 hd
->devflags
|=(1<<cp
->cp_id
);
229 else if (hd
->devflags
&1<<cp
->cp_id
)
230 cmd
->result
=(DID_OK
<<16)+0x02;
231 else cmd
->result
=(DID_NO_CONNECT
<<16);
233 if (cp
->status
== LOCKED
) {
235 eata_stat
= inb(base
+ HA_RSTATUS
);
236 printk(KERN_NOTICE
"eata_pio: int_handler, freeing locked "
238 DBG(DBG_INTR
&&DBG_DELAY
,DELAY(1));
239 restore_flags(flags
);
245 printk(KERN_DEBUG
"stat: %#.2x, result: %#.8x\n", stat
,
247 DBG(DBG_INTR
&&DBG_DELAY
,DELAY(1));
250 cp
->status
= FREE
; /* now we can release the slot */
252 restore_flags(flags
);
257 restore_flags(flags
);
262 inline uint
eata_pio_send_command(uint base
, unchar command
)
266 while (inb(base
+ HA_RSTATUS
) & HA_SBUSY
)
270 /* Enable interrupts for HBA. It is not the best way to do it at this
271 * place, but I hope that it doesn't interfere with the IDE driver
272 * initialization this way */
274 outb(HA_CTRL_8HEADS
,base
+HA_CTRLREG
);
276 outb(command
, base
+ HA_WCOMMAND
);
280 int eata_pio_queue(Scsi_Cmnd
* cmd
, void (*done
) (Scsi_Cmnd
*))
287 struct Scsi_Host
*sh
;
297 base
= (uint
) sh
->base
;
299 /* use only slot 0, as 2001 can handle only one cmd at a time */
303 if (hd
->ccb
[y
].status
!=FREE
) {
305 DBG(DBG_QUEUE
, printk(KERN_EMERG
"can_queue %d, x %d, y %d\n",
308 panic(KERN_EMERG
"eata_pio: run out of queue slots cmdno:%ld "
309 "intrno: %ld\n", queue_counter
, int_counter
);
311 panic(KERN_EMERG
"eata_pio: run out of queue slots....\n");
317 memset(cp
, 0, sizeof(struct eata_ccb
));
318 memset(cmd
->sense_buffer
, 0, sizeof(cmd
->sense_buffer
));
320 cp
->status
= USED
; /* claim free slot */
322 DBG(DBG_QUEUE
, printk(KERN_DEBUG
"eata_pio_queue pid %ld, target: %x, lun:"
323 " %x, y %d\n", cmd
->pid
, cmd
->target
, cmd
->lun
, y
));
324 DBG(DBG_QUEUE
&& DBG_DELAY
, DELAY(1));
326 cmd
->scsi_done
= (void *)done
;
328 switch (cmd
->cmnd
[0]) {
329 case CHANGE_DEFINITION
: case COMPARE
: case COPY
:
330 case COPY_VERIFY
: case LOG_SELECT
: case MODE_SELECT
:
331 case MODE_SELECT_10
: case SEND_DIAGNOSTIC
: case WRITE_BUFFER
:
332 case FORMAT_UNIT
: case REASSIGN_BLOCKS
: case RESERVE
:
333 case SEARCH_EQUAL
: case SEARCH_HIGH
: case SEARCH_LOW
:
334 case WRITE_6
: case WRITE_10
: case WRITE_VERIFY
:
335 case UPDATE_BLOCK
: case WRITE_LONG
: case WRITE_SAME
:
336 case SEARCH_HIGH_12
: case SEARCH_EQUAL_12
: case SEARCH_LOW_12
:
337 case WRITE_12
: case WRITE_VERIFY_12
: case SET_WINDOW
:
338 case MEDIUM_SCAN
: case SEND_VOLUME_TAG
:
339 case 0xea: /* alternate number for WRITE LONG */
340 cp
->DataOut
= TRUE
; /* Output mode */
342 case TEST_UNIT_READY
:
344 cp
->DataIn
= TRUE
; /* Input mode */
347 cp
->Interpret
= (cmd
->target
== hd
->hostid
);
348 cp
->cp_datalen
= htonl((ulong
)cmd
->request_bufflen
);
349 cp
->Auto_Req_Sen
= FALSE
;
350 cp
->cp_reqDMA
= htonl(0);
353 cp
->cp_id
= cmd
->target
;
354 cp
->cp_lun
= cmd
->lun
;
355 cp
->cp_dispri
= FALSE
;
356 cp
->cp_identify
= TRUE
;
357 memcpy(cp
->cp_cdb
, cmd
->cmnd
, COMMAND_SIZE(*cmd
->cmnd
));
359 cp
->cp_statDMA
= htonl(0);
363 cmd
->host_scribble
= (char *)&hd
->ccb
[y
];
365 if (cmd
->use_sg
== 0)
367 cmd
->SCp
.buffers_residual
=1;
368 cmd
->SCp
.ptr
= cmd
->request_buffer
;
369 cmd
->SCp
.this_residual
= cmd
->request_bufflen
;
370 cmd
->SCp
.buffer
= NULL
;
372 cmd
->SCp
.buffer
= cmd
->request_buffer
;
373 cmd
->SCp
.buffers_residual
= cmd
->use_sg
;
374 cmd
->SCp
.ptr
= cmd
->SCp
.buffer
->address
;
375 cmd
->SCp
.this_residual
= cmd
->SCp
.buffer
->length
;
377 cmd
->SCp
.Status
= (cmd
->SCp
.this_residual
!= 0); /* TRUE as long as bytes
380 if (eata_pio_send_command(base
, EATA_CMD_PIO_SEND_CP
))
382 cmd
->result
= DID_BUS_BUSY
<< 16;
383 printk(KERN_NOTICE
"eata_pio_queue target %d, pid %ld, HBA busy, "
384 "returning DID_BUS_BUSY, done.\n", cmd
->target
, cmd
->pid
);
387 restore_flags(flags
);
390 while (!(inb(base
+ HA_RSTATUS
) & HA_SDRQ
));
391 outsw(base
+ HA_RDATA
, cp
, hd
->cplen
);
392 outb(EATA_CMD_PIO_TRUNC
, base
+ HA_WCOMMAND
);
393 for (x
= 0; x
< hd
->cppadlen
; x
++) outw(0, base
+ HA_RDATA
);
395 DBG(DBG_QUEUE
,printk(KERN_DEBUG
"Queued base %#.4lx pid: %ld target: %x "
396 "lun: %x slot %d irq %d\n", (long)sh
->base
, cmd
->pid
,
397 cmd
->target
, cmd
->lun
, y
, sh
->irq
));
398 DBG(DBG_QUEUE
&& DBG_DELAY
, DELAY(1));
400 restore_flags(flags
);
404 int eata_pio_abort(Scsi_Cmnd
* cmd
)
412 DBG(DBG_ABNORM
, printk(KERN_WARNING
"eata_pio_abort called pid: %ld "
413 "target: %x lun: %x reason %x\n", cmd
->pid
,
414 cmd
->target
, cmd
->lun
, cmd
->abort_reason
));
415 DBG(DBG_ABNORM
&& DBG_DELAY
, DELAY(1));
418 while (inb((uint
)(cmd
->host
->base
) + HA_RAUXSTAT
) & HA_ABUSY
)
420 printk(KERN_WARNING
"eata_pio: abort, timeout error.\n");
421 restore_flags(flags
);
422 DBG(DBG_ABNORM
&& DBG_DELAY
, DELAY(1));
423 return (SCSI_ABORT_ERROR
);
425 if (CD(cmd
)->status
== FREE
) {
426 DBG(DBG_ABNORM
, printk(KERN_WARNING
"Returning: SCSI_ABORT_NOT_RUNNING\n"));
427 restore_flags(flags
);
428 return (SCSI_ABORT_NOT_RUNNING
);
430 if (CD(cmd
)->status
== USED
) {
431 DBG(DBG_ABNORM
, printk(KERN_WARNING
"Returning: SCSI_ABORT_BUSY\n"));
432 restore_flags(flags
);
433 return (SCSI_ABORT_BUSY
); /* SNOOZE */
435 if (CD(cmd
)->status
== RESET
) {
436 restore_flags(flags
);
437 printk(KERN_WARNING
"eata_pio: abort, command reset error.\n");
438 DBG(DBG_ABNORM
&& DBG_DELAY
, DELAY(1));
439 return (SCSI_ABORT_ERROR
);
441 if (CD(cmd
)->status
== LOCKED
) {
442 restore_flags(flags
);
443 DBG(DBG_ABNORM
, printk(KERN_WARNING
"eata_pio: abort, queue slot "
445 DBG(DBG_ABNORM
&& DBG_DELAY
, DELAY(1));
446 return (SCSI_ABORT_NOT_RUNNING
);
448 restore_flags(flags
);
449 panic("eata_pio: abort: invalid slot status\n");
452 int eata_pio_reset(Scsi_Cmnd
* cmd
, unsigned int dummy
)
454 uint x
, time
, limit
= 0;
456 unchar success
= FALSE
;
461 DBG(DBG_ABNORM
, printk(KERN_WARNING
"eata_pio_reset called pid:%ld target:"
462 " %x lun: %x reason %x\n", cmd
->pid
, cmd
->target
,
463 cmd
->lun
, cmd
->abort_reason
));
465 if (HD(cmd
)->state
== RESET
) {
466 printk(KERN_WARNING
"eata_pio_reset: exit, already in reset.\n");
467 restore_flags(flags
);
468 DBG(DBG_ABNORM
&& DBG_DELAY
, DELAY(1));
469 return (SCSI_RESET_ERROR
);
472 /* force all slots to be free */
474 for (x
= 0; x
< cmd
->host
->can_queue
; x
++) {
476 if (HD(cmd
)->ccb
[x
].status
== FREE
)
479 sp
= HD(cmd
)->ccb
[x
].cmd
;
480 HD(cmd
)->ccb
[x
].status
= RESET
;
481 printk(KERN_WARNING
"eata_pio_reset: slot %d in reset, pid %ld.\n", x
,
483 DBG(DBG_ABNORM
&& DBG_DELAY
, DELAY(1));
486 panic("eata_pio_reset: slot %d, sp==NULL.\n", x
);
487 DBG(DBG_ABNORM
&& DBG_DELAY
, DELAY(1));
490 /* hard reset the HBA */
491 outb(EATA_CMD_RESET
, (uint
) cmd
->host
->base
+HA_WCOMMAND
);
493 DBG(DBG_ABNORM
, printk(KERN_WARNING
"eata_pio_reset: board reset done.\n"));
494 HD(cmd
)->state
= RESET
;
497 while (time_before(jiffies
, time
+ 3 * HZ
) && limit
++ < 10000000);
499 DBG(DBG_ABNORM
, printk(KERN_WARNING
"eata_pio_reset: interrupts disabled, "
500 "loops %d.\n", limit
));
501 DBG(DBG_ABNORM
&& DBG_DELAY
, DELAY(1));
503 for (x
= 0; x
< cmd
->host
->can_queue
; x
++) {
505 /* Skip slots already set free by interrupt */
506 if (HD(cmd
)->ccb
[x
].status
!= RESET
)
509 sp
= HD(cmd
)->ccb
[x
].cmd
;
510 sp
->result
= DID_RESET
<< 16;
512 /* This mailbox is terminated */
513 printk(KERN_WARNING
"eata_pio_reset: reset ccb %d.\n",x
);
514 HD(cmd
)->ccb
[x
].status
= FREE
;
516 restore_flags(flags
);
521 HD(cmd
)->state
= FALSE
;
522 restore_flags(flags
);
524 if (success
) { /* hmmm... */
525 DBG(DBG_ABNORM
, printk(KERN_WARNING
"eata_pio_reset: exit, success.\n"));
526 DBG(DBG_ABNORM
&& DBG_DELAY
, DELAY(1));
527 return (SCSI_RESET_SUCCESS
);
529 DBG(DBG_ABNORM
, printk(KERN_WARNING
"eata_pio_reset: exit, wakeup.\n"));
530 DBG(DBG_ABNORM
&& DBG_DELAY
, DELAY(1));
531 return (SCSI_RESET_PUNT
);
535 char * get_pio_board_data(ulong base
, uint irq
, uint id
, ulong cplen
, ushort cppadlen
)
538 static char buff
[256];
541 memset(&cp
, 0, sizeof(struct eata_ccb
));
542 memset(buff
, 0, sizeof(buff
));
545 cp
.Interpret
= TRUE
; /* Interpret command */
547 cp
.cp_datalen
= htonl(254);
548 cp
.cp_dataDMA
= htonl(0);
553 cp
.cp_cdb
[0] = INQUIRY
;
560 if (eata_pio_send_command((uint
) base
, EATA_CMD_PIO_SEND_CP
))
562 while (!(inb(base
+ HA_RSTATUS
) & HA_SDRQ
));
563 outsw(base
+ HA_RDATA
, &cp
, cplen
);
564 outb(EATA_CMD_PIO_TRUNC
, base
+ HA_WCOMMAND
);
565 for (z
= 0; z
< cppadlen
; z
++) outw(0, base
+ HA_RDATA
);
567 while (inb(base
+ HA_RSTATUS
) & HA_SBUSY
);
568 if (inb(base
+ HA_RSTATUS
) & HA_SERROR
)
570 else if (!(inb(base
+ HA_RSTATUS
) & HA_SDRQ
))
574 insw(base
+HA_RDATA
, &buff
, 127);
575 while (inb(base
+ HA_RSTATUS
)&HA_SDRQ
) inw(base
+ HA_RDATA
);
580 int get_pio_conf_PIO(u32 base
, struct get_conf
*buf
)
586 if(check_region(base
, 9))
589 memset(buf
, 0, sizeof(struct get_conf
));
591 while (inb(base
+ HA_RSTATUS
) & HA_SBUSY
)
595 DBG(DBG_PIO
&& DBG_PROBE
,
596 printk(KERN_DEBUG
"Issuing PIO READ CONFIG to HBA at %#x\n", base
));
597 eata_pio_send_command(base
, EATA_CMD_PIO_READ_CONFIG
);
600 for (p
= (ushort
*) buf
;
601 (long)p
<= ((long)buf
+ (sizeof(struct get_conf
) / 2)); p
++) {
602 while (!(inb(base
+ HA_RSTATUS
) & HA_SDRQ
))
607 *p
= inw(base
+ HA_RDATA
);
609 if (!(inb(base
+ HA_RSTATUS
) & HA_SERROR
)) { /* Error ? */
610 if (htonl(EATA_SIGNATURE
) == buf
->signature
) {
611 DBG(DBG_PIO
&&DBG_PROBE
, printk(KERN_NOTICE
"EATA Controller found "
612 "at %#4x EATA Level: %x\n", base
,
613 (uint
) (buf
->version
)));
615 while (inb(base
+ HA_RSTATUS
) & HA_SDRQ
)
616 inw(base
+ HA_RDATA
);
617 if(ALLOW_DMA_BOARDS
== FALSE
) {
618 for (z
= 0; z
< MAXISA
; z
++)
619 if (base
== ISAbases
[z
]) {
620 buf
->IRQ
= ISAirqs
[z
];
627 DBG(DBG_PROBE
, printk("eata_dma: get_conf_PIO, error during transfer "
628 "for HBA at %x\n", base
));
633 void print_pio_config(struct get_conf
*gc
)
635 printk("Please check values: (read config data)\n");
636 printk("LEN: %d ver:%d OCS:%d TAR:%d TRNXFR:%d MORES:%d\n",
637 (uint
) ntohl(gc
->len
), gc
->version
,
638 gc
->OCS_enabled
, gc
->TAR_support
, gc
->TRNXFR
, gc
->MORE_support
);
639 printk("HAAV:%d SCSIID0:%d ID1:%d ID2:%d QUEUE:%d SG:%d SEC:%d\n",
640 gc
->HAA_valid
, gc
->scsi_id
[3], gc
->scsi_id
[2],
641 gc
->scsi_id
[1], ntohs(gc
->queuesiz
), ntohs(gc
->SGsiz
), gc
->SECOND
);
642 printk("IRQ:%d IRQT:%d FORCADR:%d MCH:%d RIDQ:%d\n",
643 gc
->IRQ
, gc
->IRQ_TR
, gc
->FORCADR
,
644 gc
->MAX_CHAN
, gc
->ID_qest
);
645 DBG(DPT_DEBUG
, DELAY(14));
648 static uint
print_selftest(uint base
)
655 printk("eata_pio: executing controller self test & setup...\n");
656 while (inb(base
+ HA_RSTATUS
) & HA_SBUSY
);
657 outb(EATA_CMD_PIO_SETUPTEST
, base
+ HA_WCOMMAND
);
659 while (inb(base
+ HA_RSTATUS
) & HA_SBUSY
)
661 if (inb(base
+ HA_RSTATUS
) & HA_SDRQ
)
663 insw(base
+ HA_RDATA
, &buffer
, 256);
665 /* no beeps please... */
666 for (z
= 0; z
< 511 && buffer
[z
]; z
++)
667 if (buffer
[z
] != 7) printk("%c", buffer
[z
]);
670 } while (inb(base
+HA_RSTATUS
) & (HA_SBUSY
|HA_SDRQ
));
672 return (!(inb(base
+HA_RSTATUS
) & HA_SERROR
));
675 int register_pio_HBA(long base
, struct get_conf
*gc
, Scsi_Host_Template
* tpnt
)
681 struct Scsi_Host
*sh
;
684 DBG(DBG_REGISTER
, print_pio_config(gc
));
686 if (gc
->DMA_support
== TRUE
) {
687 printk("HBA at %#.4lx supports DMA. Please use EATA-DMA driver.\n",base
);
688 if(ALLOW_DMA_BOARDS
== FALSE
)
692 if ((buff
= get_pio_board_data((uint
)base
, gc
->IRQ
, gc
->scsi_id
[3],
693 cplen
=(htonl(gc
->cplen
)+1)/2,
694 cppadlen
=(htons(gc
->cppadlen
)+1)/2)) == NULL
)
696 printk("HBA at %#lx didn't react on INQUIRY. Sorry.\n", (ulong
) base
);
700 if (print_selftest(base
) == FALSE
&& ALLOW_DMA_BOARDS
== FALSE
)
702 printk("HBA at %#lx failed while performing self test & setup.\n",
707 if (!reg_IRQ
[gc
->IRQ
]) { /* Interrupt already registered ? */
708 if (!request_irq(gc
->IRQ
, do_eata_pio_int_handler
, SA_INTERRUPT
,
712 reg_IRQL
[gc
->IRQ
] = TRUE
; /* IRQ is edge triggered */
714 printk("Couldn't allocate IRQ %d, Sorry.\n", gc
->IRQ
);
717 } else { /* More than one HBA on this IRQ */
718 if (reg_IRQL
[gc
->IRQ
] == TRUE
) {
719 printk("Can't support more than one HBA on this IRQ,\n"
720 " if the IRQ is edge triggered. Sorry.\n");
726 request_region(base
, 8, "eata_pio");
728 size
= sizeof(hostdata
) + (sizeof(struct eata_ccb
) * ntohs(gc
->queuesiz
));
730 sh
= scsi_register(tpnt
, size
);
733 memset(hd
->ccb
, 0, (sizeof(struct eata_ccb
) * ntohs(gc
->queuesiz
)));
734 memset(hd
->reads
, 0, sizeof(ulong
) * 26);
736 strncpy(SD(sh
)->vendor
, &buff
[8], 8);
737 SD(sh
)->vendor
[8] = 0;
738 strncpy(SD(sh
)->name
, &buff
[16], 17);
739 SD(sh
)->name
[17] = 0;
740 SD(sh
)->revision
[0] = buff
[32];
741 SD(sh
)->revision
[1] = buff
[33];
742 SD(sh
)->revision
[2] = buff
[34];
743 SD(sh
)->revision
[3] = '.';
744 SD(sh
)->revision
[4] = buff
[35];
745 SD(sh
)->revision
[5] = 0;
747 switch (ntohl(gc
->len
)) {
749 SD(sh
)->EATA_revision
= 'a';
752 SD(sh
)->EATA_revision
= 'b';
755 SD(sh
)->EATA_revision
= 'c';
758 SD(sh
)->EATA_revision
= 'z';
760 SD(sh
)->EATA_revision
= '?';
763 if(ntohl(gc
->len
) >= 0x22) {
764 if (gc
->is_PCI
== TRUE
)
765 hd
->bustype
= IS_PCI
;
766 else if (gc
->is_EISA
== TRUE
)
767 hd
->bustype
= IS_EISA
;
769 hd
->bustype
= IS_ISA
;
772 hd
->bustype
= IS_PCI
;
773 else if (buff
[21] == '2')
774 hd
->bustype
= IS_EISA
;
776 hd
->bustype
= IS_ISA
;
780 SD(sh
)->cppadlen
=cppadlen
;
781 SD(sh
)->hostid
=gc
->scsi_id
[3];
782 SD(sh
)->devflags
=1<<gc
->scsi_id
[3];
783 SD(sh
)->moresupport
=gc
->MORE_support
;
784 sh
->unique_id
= base
;
789 sh
->dma_channel
= PIO
;
790 sh
->this_id
= gc
->scsi_id
[3];
793 sh
->sg_tablesize
= SG_ALL
;
805 sh
->unchecked_isa_dma
= FALSE
; /* We can only do PIO */
807 hd
->next
= NULL
; /* build a linked list of all HBAs */
810 SD(hd
->prev
)->next
= sh
;
812 if (first_HBA
== NULL
)
818 void find_pio_ISA(struct get_conf
*buf
, Scsi_Host_Template
* tpnt
)
822 for (i
= 0; i
< MAXISA
; i
++) {
824 if (get_pio_conf_PIO(ISAbases
[i
], buf
) == TRUE
){
825 register_pio_HBA(ISAbases
[i
], buf
, tpnt
);
833 void find_pio_EISA(struct get_conf
*buf
, Scsi_Host_Template
* tpnt
)
842 for (i
= 0; i
< MAXEISA
; i
++) {
843 if (EISAbases
[i
] == TRUE
) { /* Still a possibility ? */
845 base
= 0x1c88 + (i
* 0x1000);
847 pal1
= inb((u16
)base
- 8);
848 pal2
= inb((u16
)base
- 7);
849 pal3
= inb((u16
)base
- 6);
851 if (((pal1
== 0x12) && (pal2
== 0x14)) ||
852 ((pal1
== 0x38) && (pal2
== 0xa3) && (pal3
== 0x82)) ||
853 ((pal1
== 0x06) && (pal2
== 0x94) && (pal3
== 0x24))) {
854 DBG(DBG_PROBE
, printk(KERN_NOTICE
"EISA EATA id tags found: "
856 (int)pal1
, (int)pal2
, (int)pal3
));
858 if (get_pio_conf_PIO(base
, buf
) == TRUE
) {
859 DBG(DBG_PROBE
&& DBG_EISA
, print_pio_config(buf
));
861 register_pio_HBA(base
, buf
, tpnt
);
863 printk(KERN_NOTICE
"eata_dma: No valid IRQ. HBA "
864 "removed from list\n");
866 /* Nothing found here so we take it from the list */
876 void find_pio_PCI(struct get_conf
*buf
, Scsi_Host_Template
* tpnt
)
879 printk("eata_dma: kernel PCI support not enabled. Skipping scan for PCI HBAs.\n");
881 struct pci_dev
*dev
= NULL
;
884 while ((dev
= pci_find_device(PCI_VENDOR_ID_DPT
, PCI_DEVICE_ID_DPT
, dev
)) != NULL
) {
885 DBG(DBG_PROBE
&& DBG_PCI
,
886 printk("eata_pio: find_PCI, HBA at %s\n", dev
->name
));
887 if (pci_enable_device(dev
))
890 base
= pci_resource_flags(dev
, 0);
891 if (base
& IORESOURCE_MEM
) {
892 printk("eata_pio: invalid base address of device %s\n", dev
->name
);
895 base
= pci_resource_start(dev
, 0);
896 /* EISA tag there ? */
897 if ((inb(base
) == 0x12) && (inb(base
+ 1) == 0x14))
898 continue; /* Jep, it's forced, so move on */
899 base
+= 0x10; /* Now, THIS is the real address */
901 /* We didn't find it in the primary search */
902 if (get_pio_conf_PIO(base
, buf
) == TRUE
) {
903 if (buf
->FORCADR
) /* If the address is forced */
904 continue; /* we'll find it later */
906 /* OK. We made it till here, so we can go now
907 * and register it. We only have to check and
908 * eventually remove it from the EISA and ISA list
911 register_pio_HBA(base
, buf
, tpnt
);
914 for (x
= 0; x
< MAXISA
; ++x
) {
915 if (ISAbases
[x
] == base
) {
920 } else if ((base
& 0x0fff) == 0x0c88) {
921 x
= (base
>> 12) & 0x0f;
926 else if (check_blink_state(base
) == TRUE
) {
927 printk("eata_pio: HBA is in BLINK state.\n"
928 "Consult your HBAs manual to correct this.\n");
933 #endif /* #ifndef CONFIG_PCI */
937 int eata_pio_detect(Scsi_Host_Template
* tpnt
)
939 struct Scsi_Host
*HBA_ptr
;
943 DBG((DBG_PROBE
&& DBG_DELAY
) || DPT_DEBUG
,
944 printk("Using lots of delays to let you read the debugging output\n"));
946 tpnt
->proc_name
= "eata_pio";
948 find_pio_PCI(&gc
, tpnt
);
950 find_pio_EISA(&gc
, tpnt
);
952 find_pio_ISA(&gc
, tpnt
);
954 for (i
= 0; i
<= MAXIRQ
; i
++)
956 request_irq(i
, do_eata_pio_int_handler
, SA_INTERRUPT
, "EATA-PIO", NULL
);
960 if (registered_HBAs
!= 0) {
961 printk("EATA (Extended Attachment) PIO driver version: %d.%d%s\n"
962 "(c) 1993-95 Michael Neuffer, neuffer@goofy.zdv.uni-mainz.de\n"
963 " Alfred Arnold, a.arnold@kfa-juelich.de\n"
964 "This release only supports DASD devices (harddisks)\n",
965 VER_MAJOR
, VER_MINOR
, VER_SUB
);
967 printk("Registered HBAs:\n");
968 printk("HBA no. Boardtype: Revis: EATA: Bus: BaseIO: IRQ: Ch: ID: Pr:"
970 for (i
= 1; i
<= registered_HBAs
; i
++) {
971 printk("scsi%-2d: %.10s v%s 2.0%c %s %#.4x %2d %d %d %c"
973 HBA_ptr
->host_no
, SD(HBA_ptr
)->name
, SD(HBA_ptr
)->revision
,
974 SD(HBA_ptr
)->EATA_revision
, (SD(HBA_ptr
)->bustype
== 'P')?
975 "PCI ":(SD(HBA_ptr
)->bustype
== 'E')?"EISA":"ISA ",
976 (uint
) HBA_ptr
->base
, HBA_ptr
->irq
, SD(HBA_ptr
)->channel
,
977 HBA_ptr
->this_id
, (SD(HBA_ptr
)->primary
== TRUE
)?'Y':'N',
978 HBA_ptr
->can_queue
, HBA_ptr
->sg_tablesize
,
979 HBA_ptr
->cmd_per_lun
);
980 HBA_ptr
= SD(HBA_ptr
)->next
;
983 DBG(DPT_DEBUG
,DELAY(12));
985 return (registered_HBAs
);
989 /* Eventually this will go into an include file, but this will be later */
990 Scsi_Host_Template driver_template
= EATA_PIO
;
992 #include "scsi_module.c"
996 * Overrides for Emacs so that we almost follow Linus's tabbing style.
997 * Emacs will notice this stuff at the end of the file and automatically
998 * adjust the settings for this buffer only. This must remain at the end
1000 * ---------------------------------------------------------------------------
1003 * c-brace-imaginary-offset: 0
1004 * c-brace-offset: -4
1005 * c-argdecl-indent: 4
1006 * c-label-offset: -4
1007 * c-continued-statement-offset: 4
1008 * c-continued-brace-offset: 0
1009 * indent-tabs-mode: nil