1 /* aha152x.c -- Adaptec AHA-152x driver 2 * Author: Jürgen E. Fischer, fischer@et-inf.fho-emden.de 3 * Copyright 1993, 1994, 1995, 1996 Jürgen E. Fischer 6 * This driver is based on 7 * fdomain.c -- Future Domain TMC-16x0 driver 9 * Copyright 1992, 1993 Rickard E. Faith (faith@cs.unc.edu) 12 * This program is free software; you can redistribute it and/or modify it 13 * under the terms of the GNU General Public License as published by the 14 * Free Software Foundation; either version 2, or (at your option) any 17 * This program is distributed in the hope that it will be useful, but 18 * WITHOUT ANY WARRANTY; without even the implied warranty of 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 * General Public License for more details. 23 * $Id: aha152x.c,v 1.18 1996/09/07 20:10:40 fischer Exp $ 26 * Revision 1.18 1996/09/07 20:10:40 fischer 27 * - fixed can_queue handling (multiple outstanding commands working again) 29 * Revision 1.17 1996/08/17 16:05:14 fischer 30 * - biosparam improved 31 * - interrupt verification 32 * - updated documentation 35 * Revision 1.16 1996/06/09 00:04:56 root 36 * - added configuration symbols for insmod (aha152x/aha152x1) 38 * Revision 1.15 1996/04/30 14:52:06 fischer 40 * - support for extended translation for >1GB disks 42 * Revision 1.14 1996/01/17 15:11:20 fischer 43 * - fixed lockup in MESSAGE IN phase after reconnection 45 * Revision 1.13 1996/01/09 02:15:53 fischer 47 * - moved request_irq behind controller initialization 48 * (to avoid spurious interrupts) 50 * Revision 1.12 1995/12/16 12:26:07 fischer 52 * - configurable RESET delay added 54 * Revision 1.11 1995/12/06 21:18:35 fischer 55 * - some minor updates 57 * Revision 1.10 1995/07/22 19:18:45 fischer 58 * - support for 2 controllers 59 * - started synchronous data transfers (not working yet) 61 * Revision 1.9 1995/03/18 09:20:24 root 62 * - patches for PCMCIA and modules 64 * Revision 1.8 1995/01/21 22:07:19 root 65 * - snarf_region => request_region 66 * - aha152x_intr interface change 68 * Revision 1.7 1995/01/02 23:19:36 root 69 * - updated COMMAND_SIZE to cmd_len 70 * - changed sti() to restore_flags() 71 * - fixed some #ifdef which generated warnings 73 * Revision 1.6 1994/11/24 20:35:27 root 74 * - problem with odd number of bytes in fifo fixed 76 * Revision 1.5 1994/10/30 14:39:56 root 78 * - debugging improved 80 * Revision 1.4 1994/09/12 11:33:01 root 81 * - irqaction to request_irq 84 * Revision 1.3 1994/08/04 13:53:05 root 85 * - updates for mid-level-driver changes 86 * - accept unexpected BUSFREE phase as error condition 87 * - parity check now configurable 89 * Revision 1.2 1994/07/03 12:56:36 root 90 * - cleaned up debugging code 91 * - more tweaking on reset delays 92 * - updated abort/reset code (pretty untested...) 94 * Revision 1.1 1994/05/28 21:18:49 root 95 * - update for mid-level interface change (abort-reset) 96 * - delays after resets adjusted for some slow devices 98 * Revision 1.0 1994/03/25 12:52:00 root 99 * - Fixed "more data than expected" problem 100 * - added new BIOS signatures 102 * Revision 0.102 1994/01/31 20:44:12 root 103 * - minor changes in insw/outsw handling 105 * Revision 0.101 1993/12/13 01:16:27 root 106 * - fixed STATUS phase (non-GOOD stati were dropped sometimes; 107 * fixes problems with CD-ROM sector size detection & media change) 109 * Revision 0.100 1993/12/10 16:58:47 root 110 * - fix for unsuccessful selections in case of non-continuous id assignments 113 * Revision 0.99 1993/10/24 16:19:59 root 114 * - fixed DATA IN (rare read errors gone) 116 * Revision 0.98 1993/10/17 12:54:44 root 117 * - fixed some recent fixes (shame on me) 118 * - moved initialization of scratch area to aha152x_queue 120 * Revision 0.97 1993/10/09 18:53:53 root 121 * - DATA IN fixed. Rarely left data in the fifo. 123 * Revision 0.96 1993/10/03 00:53:59 root 124 * - minor changes on DATA IN 126 * Revision 0.95 1993/09/24 10:36:01 root 127 * - change handling of MSGI after reselection 131 * Revision 0.94 1993/09/18 14:08:22 root 132 * - fixed bug in multiple outstanding command code 133 * - changed detection 134 * - support for kernel command line configuration 136 * - changed message handling 138 * Revision 0.93 1993/09/15 20:41:19 root 139 * - fixed bugs with multiple outstanding commands 141 * Revision 0.92 1993/09/13 02:46:33 root 142 * - multiple outstanding commands work (no problems with IBM drive) 144 * Revision 0.91 1993/09/12 20:51:46 root 145 * added multiple outstanding commands 146 * (some problem with this $%&? IBM device remain) 148 * Revision 0.9 1993/09/12 11:11:22 root 149 * - corrected auto-configuration 150 * - changed the auto-configuration (added some '#define's) 151 * - added support for dis-/reconnection 153 * Revision 0.8 1993/09/06 23:09:39 root 154 * - added support for the drive activity light 157 * Revision 0.7 1993/09/05 14:30:15 root 158 * - improved phase detection 159 * - now using the new snarf_region code of 0.99pl13 161 * Revision 0.6 1993/09/02 11:01:38 root 162 * first public release; added some signatures and biosparam() 164 * Revision 0.5 1993/08/30 10:23:30 root 165 * fixed timing problems with my IBM drive 167 * Revision 0.4 1993/08/29 14:06:52 root 168 * fixed some problems with timeouts due incomplete commands 170 * Revision 0.3 1993/08/28 15:55:03 root 171 * writing data works too. mounted and worked on a dos partition 173 * Revision 0.2 1993/08/27 22:42:07 root 174 * reading data works. Mounted a msdos partition. 176 * Revision 0.1 1993/08/25 13:38:30 root 177 * first "damn thing doesn't work" version 179 * Revision 0.0 1993/08/14 19:54:25 root 180 * empty function bodies; detect() works. 183 ************************************************************************** 189 This is the Linux low-level SCSI driver for Adaptec AHA-1520/1522 SCSI 193 CONFIGURATION ARGUMENTS: 195 IOPORT base io address (0x340/0x140) 196 IRQ interrupt level (9-12; default 11) 197 SCSI_ID scsi id of controller (0-7; default 7) 198 RECONNECT allow targets to disconnect from the bus (0/1; default 1 [on]) 199 PARITY enable parity checking (0/1; default 1 [on]) 200 SYNCHRONOUS enable synchronous transfers (0/1; default 0 [off]) 202 DELAY: bus reset delay (default 100) 203 EXT_TRANS: enable extended translation (0/1: default 0 [off]) 206 COMPILE TIME CONFIGURATION (put into AHA152X in drivers/scsi/Makefile): 209 use configuration the controller reports (AHA-152x only) 212 Don't test for BIOS signature (AHA-1510 or disabled BIOS) 214 -DSETUP0="{ IOPORT, IRQ, SCSI_ID, RECONNECT, PARITY, SYNCHRONOUS, DELAY, EXT_TRANS }" 215 override for the first controller 217 -DSETUP1="{ IOPORT, IRQ, SCSI_ID, RECONNECT, PARITY, SYNCHRONOUS, DELAY, EXT_TRANS }" 218 override for the second controller 221 LILO COMMAND LINE OPTIONS: 223 aha152x=<IOPORT>[,<IRQ>[,<SCSI-ID>[,<RECONNECT>[,<PARITY>[,<SYNCHRONOUS>[,<DELAY> [,<EXT_TRANS]]]]]]] 225 The normal configuration can be overridden by specifying a command line. 226 When you do this, the BIOS test is skipped. Entered values have to be 227 valid (known). Don't use values that aren't supported under normal 228 operation. If you think that you need other values: contact me. 229 For two controllers use the aha152x statement twice. 232 SYMBOLS FOR MODULE CONFIGURATION: 234 aha152x=IOPORT,IRQ,SCSI_ID,RECONNECT,PARITY,SYNCHRONOUS,DELAY,EXT_TRANS 235 configuration override of first controller 238 aha152x1=IOPORT,IRQ,SCSI_ID,RECONNECT,PARITY,SYNCHRONOUS,DELAY,EXT_TRANS 239 configuration override of second controller 244 SCSI uses block numbers to address blocks/sectors on a device. 245 The BIOS uses a cylinder/head/sector addressing scheme (C/H/S) 246 scheme instead. DOS expects a BIOS or driver that understands this 249 The number of cylinders/heads/sectors is called geometry and is required 250 as base for requests in C/H/S addressing. SCSI only knows about the 251 total capacity of disks in blocks (sectors). 253 Therefore the SCSI BIOS/DOS driver has to calculate a logical/virtual 254 geometry just to be able to support that addressing scheme. The geometry 255 returned by the SCSI BIOS is a pure calculation and has nothing to 256 do with the real/physical geometry of the disk (which is usually 259 Basically this has no impact at all on Linux, because it also uses block 260 instead of C/H/S addressing. Unfortunately C/H/S addressing is also used 261 in the partition table and therefore every operating system has to know 262 the right geometry to be able to interpret it. 264 Moreover there are certain limitations to the C/H/S addressing scheme, 265 namely the address space is limited to upto 255 heads, upto 63 sectors 266 and a maximum of 1023 cylinders. 268 The AHA-1522 BIOS calculates the geometry by fixing the number of heads 269 to 64, the number of sectors to 32 and by calculating the number of 270 cylinders by dividing the capacity reported by the disk by 64*32 (1 MB). 271 This is considered to be the default translation. 273 With respect to the limit of 1023 cylinders using C/H/S you can only 274 address the first GB of your disk in the partition table. Therefore 275 BIOSes of some newer controllers based on the AIC-6260/6360 support 276 extended translation. This means that the BIOS uses 255 for heads, 277 63 for sectors and then divides the capacity of the disk by 255*63 278 (about 8 MB), as soon it sees a disk greater than 1 GB. That results 279 in a maximum of about 8 GB addressable diskspace in the partition table 280 (but there are already bigger disks out there today). 282 To make it even more complicated the translation mode might/might 283 not be configurable in certain BIOS setups. 285 This driver does some more or less failsafe guessing to get the 286 geometry right in most cases: 288 - for disks<1GB: use default translation (C/32/64) 290 - take current geometry from the partition table 291 (using scsicam_bios_param and accept only `valid' geometries, 292 ie. either (C/32/64) or (C/63/255)). This can be extended 293 translation even if it's not enabled in the driver. 294 - if that fails, take extended translation if enabled by override, 295 kernel or module parameter, otherwise take default translation and 296 ask the user for verification. This might on not yet partitioned 302 "AIC-6260 SCSI Chip Specification", Adaptec Corporation. 304 "SCSI COMPUTER SYSTEM INTERFACE - 2 (SCSI-2)", X3T9.2/86-109 rev. 10h 306 "Writing a SCSI device driver for Linux", Rik Faith (faith@cs.unc.edu) 308 "Kernel Hacker's Guide", Michael K. Johnson (johnsonm@sunsite.unc.edu) 310 "Adaptec 1520/1522 User's Guide", Adaptec Corporation. 312 Michael K. Johnson (johnsonm@sunsite.unc.edu) 314 Drew Eckhardt (drew@cs.colorado.edu) 316 Eric Youngdale (ericy@cais.com) 318 special thanks to Eric Youngdale for the free(!) supplying the 319 documentation on the chip. 321 **************************************************************************/ 327 #include <linux/module.h> 333 #include <linux/sched.h> 335 #include <linux/blk.h> 339 #include"constants.h" 340 #include <asm/system.h> 341 #include <linux/errno.h> 342 #include <linux/string.h> 343 #include <linux/wait.h> 344 #include <linux/ioport.h> 345 #include <linux/proc_fs.h> 346 #include <linux/interrupt.h> 349 #include <linux/stat.h> 351 #include <scsi/scsicam.h> 353 struct proc_dir_entry proc_scsi_aha152x
= 355 PROC_SCSI_AHA152X
,7,"aha152x", 356 S_IFDIR
| S_IRUGO
| S_IXUGO
,2 361 /* For PCMCIA cards, always use AUTOCONF */ 362 #if defined(PCMCIA) || defined(MODULE) 363 #if !defined(AUTOCONF) 368 #if !defined(AUTOCONF) && !defined(SETUP0) 369 #error define AUTOCONF or SETUP0 372 #if defined(DEBUG_AHA152X) 374 #undef SKIP_PORTS/* don't display ports */ 376 #undef DEBUG_QUEUE/* debug queue() */ 377 #undef DEBUG_RESET/* debug reset() */ 378 #undef DEBUG_INTR/* debug intr() */ 379 #undef DEBUG_SELECTION/* debug selection part in intr() */ 380 #undef DEBUG_MSGO/* debug message out phase in intr() */ 381 #undef DEBUG_MSGI/* debug message in phase in intr() */ 382 #undef DEBUG_STATUS/* debug status phase in intr() */ 383 #undef DEBUG_CMD/* debug command phase in intr() */ 384 #undef DEBUG_DATAI/* debug data in phase in intr() */ 385 #undef DEBUG_DATAO/* debug data out phase in intr() */ 386 #undef DEBUG_ABORT/* debug abort() */ 387 #undef DEBUG_DONE/* debug done() */ 388 #undef DEBUG_BIOSPARAM/* debug biosparam() */ 390 #undef DEBUG_RACE/* debug race conditions */ 391 #undef DEBUG_PHASES/* debug phases (useful to trace) */ 392 #undef DEBUG_QUEUES/* debug reselection */ 394 /* recently used for debugging */ 398 #define DEBUG_SELECTION 403 #define DEBUG_DEFAULT (debug_reset|debug_abort) 409 externlong loops_per_sec
; 411 #define DELAY_DEFAULT 100 413 /* some additional "phases" for getphase() */ 417 /* possible irq range */ 425 #define IRQS IRQ_MAX-IRQ_MIN+1 429 in_selection
=0x0002, 430 disconnected
=0x0004, 439 #if defined(DEBUG_AHA152X) 441 {0,11,7,1,1,0, DELAY_DEFAULT
,0, DEBUG_DEFAULT
}; 443 {0,11,7,1,1,0, DELAY_DEFAULT
,0, DEBUG_DEFAULT
}; 444 MODULE_PARM(aha152x
,"1-9i"); 445 MODULE_PARM(aha152x1
,"1-9i"); 448 {0,11,7,1,1,0, DELAY_DEFAULT
,0}; 450 {0,11,7,1,1,0, DELAY_DEFAULT
,0}; 451 MODULE_PARM(aha152x
,"1-8i"); 452 MODULE_PARM(aha152x1
,"1-8i"); 456 /* set by aha152x_setup according to the command line */ 457 static int setup_count
=0; 458 static int registered_count
=0; 459 static struct aha152x_setup
{ 474 static struct Scsi_Host
*aha152x_host
[IRQS
]; 476 #define HOSTDATA(shpnt) ((struct aha152x_hostdata *) &shpnt->hostdata) 477 #define CURRENT_SC (HOSTDATA(shpnt)->current_SC) 478 #define ISSUE_SC (HOSTDATA(shpnt)->issue_SC) 479 #define DISCONNECTED_SC (HOSTDATA(shpnt)->disconnected_SC) 480 #define DELAY (HOSTDATA(shpnt)->delay) 481 #define EXT_TRANS (HOSTDATA(shpnt)->ext_trans) 482 #define SYNCRATE (HOSTDATA(shpnt)->syncrate[CURRENT_SC->target]) 483 #define MSG(i) (HOSTDATA(shpnt)->message[i]) 484 #define MSGLEN (HOSTDATA(shpnt)->message_len) 485 #define ADDMSG(x) (MSG(MSGLEN++)=x) 487 struct aha152x_hostdata
{ 489 Scsi_Cmnd
*current_SC
; 490 Scsi_Cmnd
*disconnected_SC
; 492 int abortion_complete
; 505 unsigned char syncrate
[8]; 507 unsigned char message
[256]; 515 static voidaha152x_intr(int irq
,void*dev_id
,struct pt_regs
*); 516 voidaha152x_done(struct Scsi_Host
*shpnt
,int error
); 517 voidaha152x_setup(char*str
,int*ints
); 518 intaha152x_checksetup(struct aha152x_setup
*setup
); 520 static voidaha152x_reset_ports(struct Scsi_Host
*shpnt
); 521 static voidaha152x_panic(struct Scsi_Host
*shpnt
,char*msg
); 523 static voiddisp_ports(struct Scsi_Host
*shpnt
); 524 static voidshow_command(Scsi_Cmnd
* ptr
); 525 static voidshow_queues(struct Scsi_Host
*shpnt
); 526 static voiddisp_enintr(struct Scsi_Host
*shpnt
); 528 #if defined(DEBUG_RACE) 529 static voidenter_driver(const char*); 530 static voidleave_driver(const char*); 533 /* possible i/o addresses for the AIC-6260 */ 534 static unsigned short ports
[] = 536 0x340,/* default first */ 539 #define PORT_COUNT (sizeof(ports) / sizeof(unsigned short)) 541 #if !defined(SKIP_BIOSTEST) 542 /* possible locations for the Adaptec BIOS */ 543 static unsigned int addresses
[] = 545 0xdc000,/* default first */ 552 0xeb800,/* VTech Platinum SMP */ 555 #define ADDRESS_COUNT (sizeof(addresses) / sizeof(unsigned int)) 557 /* signatures for various AIC-6[23]60 based controllers. 558 The point in detecting signatures is to avoid useless and maybe 559 harmful probes on ports. I'm not sure that all listed boards pass 560 auto-configuration. For those which fail the BIOS signature is 561 obsolete, because user intervention to supply the configuration is 562 needed anyway. May be an information whether or not the BIOS supports 563 extended translation could be also useful here. */ 564 static struct signature
{ 565 unsigned char*signature
; 572 "Adaptec AHA-1520 BIOS",0x102e,21 575 "Adaptec AHA-1520B",0x0b,19 576 },/* Adaptec 152x rev B */ 578 "Adaptec ASW-B626 BIOS",0x1029,21 579 },/* on-board controller */ 581 "Adaptec BIOS: ASW-B626",0x0f,22 582 },/* on-board controller */ 584 "Adaptec ASW-B626 S2",0x2e6c,19 585 },/* on-board controller */ 587 "Adaptec BIOS:AIC-6360",0xc,21 588 },/* on-board controller */ 590 "ScsiPro SP-360 BIOS",0x2873,19 591 },/* ScsiPro-Controller */ 593 "GA-400 LOCAL BUS SCSI BIOS",0x102e,26 594 },/* Gigabyte Local-Bus-SCSI */ 596 "Adaptec BIOS:AVA-282X",0xc,21 599 "Adaptec IBM Dock II SCSI",0x2edd,24 600 },/* IBM Thinkpad Dock II */ 602 "Adaptec BIOS:AHA-1532P",0x1c,22 603 },/* IBM Thinkpad Dock II SCSI */ 605 "DTC3520A Host Adapter BIOS",0x318a,26 606 },/* DTC 3520A ISA SCSI */ 609 #define SIGNATURE_COUNT (sizeof(signatures) / sizeof(struct signature)) 613 static voiddo_pause(unsigned amount
) 614 {/* Pause for amount*10 milliseconds */ 615 unsigned long the_time
= jiffies
+ amount
;/* 0.01 seconds per jiffy */ 617 while(time_before(jiffies
, the_time
)) 624 staticinlinevoidappend_SC(Scsi_Cmnd
** SC
, Scsi_Cmnd
* new_SC
) 628 new_SC
->host_scribble
= (unsigned char*) NULL
; 632 for(end
= *SC
; end
->host_scribble
; end
= (Scsi_Cmnd
*) end
->host_scribble
); 633 end
->host_scribble
= (unsigned char*) new_SC
; 637 staticinline Scsi_Cmnd
*remove_first_SC(Scsi_Cmnd
** SC
) 643 *SC
= (Scsi_Cmnd
*) (*SC
)->host_scribble
; 647 staticinline Scsi_Cmnd
*remove_SC(Scsi_Cmnd
** SC
,int target
,int lun
) 649 Scsi_Cmnd
*ptr
, *prev
; 651 for(ptr
= *SC
, prev
= NULL
; 652 ptr
&& ((ptr
->target
!= target
) || (ptr
->lun
!= lun
)); 653 prev
= ptr
, ptr
= (Scsi_Cmnd
*) ptr
->host_scribble
); 657 prev
->host_scribble
= ptr
->host_scribble
; 659 *SC
= (Scsi_Cmnd
*) ptr
->host_scribble
; 665 * read inbound byte and wait for ACK to get low 667 static voidmake_acklow(struct Scsi_Host
*shpnt
) 669 SETPORT(SXFRCTL0
, CH1
| SPIOEN
); 671 SETPORT(SXFRCTL0
, CH1
); 673 while(TESTHI(SCSISIG
, ACKI
)) 678 * detect current phase more reliable: 679 * phase is valid, when the target asserts REQ after we've deasserted ACK. 681 * return value is a valid phase or an error code. 684 * P_BUSFREE BUS FREE phase detected 685 * P_PARITY parity error in DATA phase 687 static intgetphase(struct Scsi_Host
*shpnt
) 693 while(!((sstat1
=GETPORT(SSTAT1
)) & (BUSFREE
| SCSIRSTI
| REQINIT
))) 697 if(sstat1
& SCSIRSTI
) { 698 printk("aha152x: RESET IN\n"); 699 SETPORT(SSTAT1
, SCSIRSTI
); 701 }while(TESTHI(SCSISIG
, ACKI
) ||TESTLO(SSTAT1
, REQINIT
)); 703 SETPORT(SSTAT1
, CLRSCSIPERR
); 705 phase
=GETPORT(SCSISIG
) & P_MASK
; 707 if(TESTHI(SSTAT1
, SCSIPERR
)) { 708 if((phase
& (CDO
| MSGO
)) ==0)/* DATA phase */ 717 /* called from init/main.c */ 718 voidaha152x_setup(char*str
,int*ints
) 721 panic("aha152x: you can only configure up to two controllers\n"); 723 setup
[setup_count
].conf
= str
; 724 setup
[setup_count
].io_port
= ints
[0] >=1? ints
[1] :0x340; 725 setup
[setup_count
].irq
= ints
[0] >=2? ints
[2] :11; 726 setup
[setup_count
].scsiid
= ints
[0] >=3? ints
[3] :7; 727 setup
[setup_count
].reconnect
= ints
[0] >=4? ints
[4] :1; 728 setup
[setup_count
].parity
= ints
[0] >=5? ints
[5] :1; 729 setup
[setup_count
].synchronous
= ints
[0] >=6? ints
[6] :0/* FIXME: 1 */; 730 setup
[setup_count
].delay
= ints
[0] >=7? ints
[7] : DELAY_DEFAULT
; 731 setup
[setup_count
].ext_trans
= ints
[0] >=8? ints
[8] :0; 733 setup
[setup_count
].debug
= ints
[0] >=9? ints
[9] : DEBUG_DEFAULT
; 735 printk("aha152x: usage: aha152x=<IOBASE>[,<IRQ>[,<SCSI ID>" 736 "[,<RECONNECT>[,<PARITY>[,<SYNCHRONOUS>[,<DELAY>[,<EXT_TRANS>[,<DEBUG>]]]]]]]]\n"); 739 printk("aha152x: usage: aha152x=<IOBASE>[,<IRQ>[,<SCSI ID>" 740 "[,<RECONNECT>[,<PARITY>[,<SYNCHRONOUS>[,<DELAY>[,<EXT_TRANS>]]]]]]]\n"); 747 * Test, if port_base is valid. 749 static intaha152x_porttest(int io_port
) 753 if(check_region(io_port
, IO_RANGE
)) 756 SETPORT(io_port
+ O_DMACNTRL1
,0);/* reset stack pointer */ 757 for(i
=0; i
<16; i
++) 758 SETPORT(io_port
+ O_STACK
, i
); 760 SETPORT(io_port
+ O_DMACNTRL1
,0);/* reset stack pointer */ 761 for(i
=0; i
<16&&GETPORT(io_port
+ O_STACK
) == i
; i
++); 766 intaha152x_checksetup(struct aha152x_setup
*setup
) 771 for(i
=0; i
< PORT_COUNT
&& (setup
->io_port
!= ports
[i
]); i
++); 777 if(!aha152x_porttest(setup
->io_port
)) 780 if((setup
->irq
< IRQ_MIN
) || (setup
->irq
> IRQ_MAX
)) 783 if((setup
->scsiid
<0) || (setup
->scsiid
>7)) 786 if((setup
->reconnect
<0) || (setup
->reconnect
>1)) 789 if((setup
->parity
<0) || (setup
->parity
>1)) 792 if((setup
->synchronous
<0) || (setup
->synchronous
>1)) 795 if((setup
->ext_trans
<0) || (setup
->ext_trans
>1)) 802 voidaha152x_swintr(int irqno
,void*dev_id
,struct pt_regs
*regs
) 804 struct Scsi_Host
*shpnt
= aha152x_host
[irqno
- IRQ_MIN
]; 807 panic("aha152x: catched software interrupt for unknown controller.\n"); 809 HOSTDATA(shpnt
)->swint
++; 813 intaha152x_detect(Scsi_Host_Template
* tpnt
) 816 #if defined(AUTOCONF) 820 tpnt
->proc_dir
= &proc_scsi_aha152x
; 822 for(i
=0; i
< IRQS
; i
++) 823 aha152x_host
[i
] = (struct Scsi_Host
*) NULL
; 826 printk("aha152x: processing commandline: "); 828 for(i
=0; i
< setup_count
; i
++) 829 if(!aha152x_checksetup(&setup
[i
])) { 830 printk("\naha152x: %s\n", setup
[i
].conf
); 831 printk("aha152x: invalid line (controller=%d)\n", i
+1); 837 struct aha152x_setup override
= SETUP0
; 839 if(setup_count
==0|| (override
.io_port
!= setup
[0].io_port
)) 840 if(!aha152x_checksetup(&override
)) { 841 printk("\naha152x: invalid override SETUP0={0x%x,%d,%d,%d,%d,%d,%d,%d}\n", 847 override
.synchronous
, 851 setup
[setup_count
++] = override
; 857 struct aha152x_setup override
= SETUP1
; 859 if(setup_count
==0|| (override
.io_port
!= setup
[0].io_port
)) 860 if(!aha152x_checksetup(&override
)) { 861 printk("\naha152x: invalid override SETUP1={0x%x,%d,%d,%d,%d,%d,%d,%d}\n", 867 override
.synchronous
, 871 setup
[setup_count
++] = override
; 876 if(setup_count
<2&& aha152x
[0] !=0) { 877 setup
[setup_count
].conf
=""; 878 setup
[setup_count
].io_port
= aha152x
[0]; 879 setup
[setup_count
].irq
= aha152x
[1]; 880 setup
[setup_count
].scsiid
= aha152x
[2]; 881 setup
[setup_count
].reconnect
= aha152x
[3]; 882 setup
[setup_count
].parity
= aha152x
[4]; 883 setup
[setup_count
].synchronous
= aha152x
[5]; 884 setup
[setup_count
].delay
= aha152x
[6]; 885 setup
[setup_count
].ext_trans
= aha152x
[7]; 887 setup
[setup_count
].debug
= aha152x
[8]; 889 if(aha152x_checksetup(&setup
[setup_count
])) 892 printk("\naha152x: invalid module argument aha152x=0x%x,%d,%d,%d,%d,%d,%d,%d\n", 893 setup
[setup_count
].io_port
, 894 setup
[setup_count
].irq
, 895 setup
[setup_count
].scsiid
, 896 setup
[setup_count
].reconnect
, 897 setup
[setup_count
].parity
, 898 setup
[setup_count
].synchronous
, 899 setup
[setup_count
].delay
, 900 setup
[setup_count
].ext_trans
); 902 if(setup_count
<2&& aha152x1
[0] !=0) { 903 setup
[setup_count
].conf
=""; 904 setup
[setup_count
].io_port
= aha152x1
[0]; 905 setup
[setup_count
].irq
= aha152x1
[1]; 906 setup
[setup_count
].scsiid
= aha152x1
[2]; 907 setup
[setup_count
].reconnect
= aha152x1
[3]; 908 setup
[setup_count
].parity
= aha152x1
[4]; 909 setup
[setup_count
].synchronous
= aha152x1
[5]; 910 setup
[setup_count
].delay
= aha152x1
[6]; 911 setup
[setup_count
].ext_trans
= aha152x1
[7]; 913 setup
[setup_count
].debug
= aha152x1
[8]; 915 if(aha152x_checksetup(&setup
[setup_count
])) 918 printk("\naha152x: invalid module argument aha152x1=0x%x,%d,%d,%d,%d,%d,%d,%d\n", 919 setup
[setup_count
].io_port
, 920 setup
[setup_count
].irq
, 921 setup
[setup_count
].scsiid
, 922 setup
[setup_count
].reconnect
, 923 setup
[setup_count
].parity
, 924 setup
[setup_count
].synchronous
, 925 setup
[setup_count
].delay
, 926 setup
[setup_count
].ext_trans
); 930 #if defined(AUTOCONF) 932 #if !defined(SKIP_BIOSTEST) 934 for(i
=0; i
< ADDRESS_COUNT
&& !ok
; i
++) 935 for(j
=0; (j
< SIGNATURE_COUNT
) && !ok
; j
++) 936 ok
=check_signature(addresses
[i
] + signatures
[j
].sig_offset
, 937 signatures
[j
].signature
, signatures
[j
].sig_length
); 939 if(!ok
&& setup_count
==0) 942 printk("aha152x: BIOS test: passed, "); 945 #endif/* !SKIP_BIOSTEST */ 948 for(i
=0; i
< PORT_COUNT
&& setup_count
<2; i
++) { 949 if((setup_count
==1) && (setup
[0].io_port
== ports
[i
])) 952 if(aha152x_porttest(ports
[i
])) { 954 setup
[setup_count
].io_port
= ports
[i
]; 957 (GETPORT(ports
[i
] + O_PORTA
) <<8) +GETPORT(ports
[i
] + O_PORTB
); 959 setup
[setup_count
].irq
= IRQ_MIN
+ conf
.cf_irq
; 960 setup
[setup_count
].scsiid
= conf
.cf_id
; 961 setup
[setup_count
].reconnect
= conf
.cf_tardisc
; 962 setup
[setup_count
].parity
= !conf
.cf_parity
; 963 setup
[setup_count
].synchronous
=0/* FIXME: conf.cf_syncneg */; 964 setup
[setup_count
].delay
= DELAY_DEFAULT
; 965 setup
[setup_count
].ext_trans
=0; 967 setup
[setup_count
].debug
= DEBUG_DEFAULT
; 974 printk("auto configuration: ok, "); 978 printk("detected %d controller(s)\n", setup_count
); 980 for(i
=0; i
< setup_count
; i
++) { 981 struct Scsi_Host
*shpnt
; 982 unsigned long int the_time
; 984 shpnt
= aha152x_host
[setup
[i
].irq
- IRQ_MIN
] = 985 scsi_register(tpnt
,sizeof(struct aha152x_hostdata
)); 988 shpnt
->io_port
= setup
[i
].io_port
; 989 shpnt
->n_io_port
= IO_RANGE
; 990 shpnt
->irq
= setup
[i
].irq
; 992 ISSUE_SC
= (Scsi_Cmnd
*) NULL
; 993 CURRENT_SC
= (Scsi_Cmnd
*) NULL
; 994 DISCONNECTED_SC
= (Scsi_Cmnd
*) NULL
; 996 HOSTDATA(shpnt
)->reconnect
= setup
[i
].reconnect
; 997 HOSTDATA(shpnt
)->parity
= setup
[i
].parity
; 998 HOSTDATA(shpnt
)->synchronous
= setup
[i
].synchronous
; 999 HOSTDATA(shpnt
)->delay
= setup
[i
].delay
; 1000 HOSTDATA(shpnt
)->ext_trans
= setup
[i
].ext_trans
; 1001 #ifdef DEBUG_AHA152X 1002 HOSTDATA(shpnt
)->debug
= setup
[i
].debug
; 1005 HOSTDATA(shpnt
)->aborting
=0; 1006 HOSTDATA(shpnt
)->abortion_complete
=0; 1007 HOSTDATA(shpnt
)->abort_result
=0; 1008 HOSTDATA(shpnt
)->commands
=0; 1010 HOSTDATA(shpnt
)->message_len
=0; 1012 for(j
=0; j
<8; j
++) 1013 HOSTDATA(shpnt
)->syncrate
[j
] =0; 1015 SETPORT(SCSIID
, setup
[i
].scsiid
<<4); 1016 shpnt
->this_id
= setup
[i
].scsiid
; 1018 if(setup
[i
].reconnect
) 1019 shpnt
->can_queue
= AHA152X_MAXQUEUE
; 1022 SETBITS(SCSISEQ
, SCSIRSTO
); 1024 CLRBITS(SCSISEQ
, SCSIRSTO
); 1025 do_pause(setup
[i
].delay
); 1027 aha152x_reset_ports(shpnt
); 1029 printk("aha152x%d: vital data: PORTBASE=0x%03lx, IRQ=%d, SCSI ID=%d," 1030 " reconnect=%s, parity=%s, synchronous=%s, delay=%d, extended translation=%s\n", 1035 HOSTDATA(shpnt
)->reconnect
?"enabled":"disabled", 1036 HOSTDATA(shpnt
)->parity
?"enabled":"disabled", 1037 HOSTDATA(shpnt
)->synchronous
?"enabled":"disabled", 1038 HOSTDATA(shpnt
)->delay
, 1039 HOSTDATA(shpnt
)->ext_trans
?"enabled":"disabled"); 1041 request_region(shpnt
->io_port
, IO_RANGE
,"aha152x");/* Register */ 1043 /* not expecting any interrupts */ 1047 SETBITS(DMACNTRL0
, INTEN
); 1049 ok
=request_irq(shpnt
->irq
, aha152x_swintr
, SA_INTERRUPT
,"aha152x", shpnt
); 1052 printk("aha152x%d: bad IRQ %d.\n", i
, shpnt
->irq
); 1053 else if(ok
== -EBUSY
) 1054 printk("aha152x%d: IRQ %d already in use.\n", i
, shpnt
->irq
); 1056 printk("\naha152x%d: Unexpected error code %d on requesting IRQ %d.\n", i
, ok
, shpnt
->irq
); 1057 printk("aha152x: driver needs an IRQ.\n"); 1059 scsi_unregister(shpnt
); 1061 release_region(shpnt
->io_port
, IO_RANGE
); 1062 shpnt
= aha152x_host
[shpnt
->irq
- IRQ_MIN
] =0; 1065 HOSTDATA(shpnt
)->swint
=0; 1067 printk("aha152x: trying software interrupt, "); 1068 SETBITS(DMACNTRL0
, SWINT
); 1070 the_time
= jiffies
+100; 1071 while(!HOSTDATA(shpnt
)->swint
&&time_before(jiffies
, the_time
)) 1074 free_irq(shpnt
->irq
, shpnt
); 1076 if(!HOSTDATA(shpnt
)->swint
) { 1077 if(TESTHI(DMASTAT
, INTSTAT
)) { 1080 printk("failed.\n"); 1083 printk("aha152x: IRQ %d possibly wrong. Please verify.\n", shpnt
->irq
); 1085 scsi_unregister(shpnt
); 1087 release_region(shpnt
->io_port
, IO_RANGE
); 1088 shpnt
= aha152x_host
[shpnt
->irq
- IRQ_MIN
] =0; 1093 CLRBITS(DMACNTRL0
, SWINT
); 1095 /* clear interrupts */ 1096 SETPORT(SSTAT0
,0x7f); 1097 SETPORT(SSTAT1
,0xef); 1099 if(request_irq(shpnt
->irq
, aha152x_intr
, SA_INTERRUPT
,"aha152x", shpnt
) <0) { 1100 printk("aha152x: failed to reassign interrupt.\n"); 1104 return(registered_count
>0); 1108 intaha152x_release(struct Scsi_Host
*shpnt
) 1111 free_irq(shpnt
->irq
, shpnt
); 1113 release_region(shpnt
->io_port
, IO_RANGE
); 1119 * Queue a command and setup interrupts for a free bus. 1121 intaha152x_queue(Scsi_Cmnd
* SCpnt
,void(*done
) (Scsi_Cmnd
*)) 1123 struct Scsi_Host
*shpnt
= SCpnt
->host
; 1124 unsigned long flags
; 1126 #if defined(DEBUG_RACE) 1127 enter_driver("queue"); 1129 #if defined(DEBUG_QUEUE) 1130 if(HOSTDATA(shpnt
)->debug
& debug_queue
) 1131 printk("aha152x: queue(), "); 1135 #if defined(DEBUG_QUEUE) 1136 if(HOSTDATA(shpnt
)->debug
& debug_queue
) { 1137 printk("SCpnt (target = %d lun = %d cmnd = ", 1138 SCpnt
->target
, SCpnt
->lun
); 1139 print_command(SCpnt
->cmnd
); 1140 printk(", cmd_len=%d, pieces = %d size = %u), ", 1141 SCpnt
->cmd_len
, SCpnt
->use_sg
, SCpnt
->request_bufflen
); 1146 SCpnt
->scsi_done
= done
; 1148 /* setup scratch area 1149 SCp.ptr : buffer pointer 1150 SCp.this_residual : buffer length 1151 SCp.buffer : next buffer 1152 SCp.buffers_residual : left buffers in list 1153 SCp.phase : current state of the command */ 1154 SCpnt
->SCp
.phase
= not_issued
; 1156 SCpnt
->SCp
.buffer
= (struct scatterlist
*) SCpnt
->request_buffer
; 1157 SCpnt
->SCp
.ptr
= SCpnt
->SCp
.buffer
->address
; 1158 SCpnt
->SCp
.this_residual
= SCpnt
->SCp
.buffer
->length
; 1159 SCpnt
->SCp
.buffers_residual
= SCpnt
->use_sg
-1; 1161 SCpnt
->SCp
.ptr
= (char*) SCpnt
->request_buffer
; 1162 SCpnt
->SCp
.this_residual
= SCpnt
->request_bufflen
; 1163 SCpnt
->SCp
.buffer
= NULL
; 1164 SCpnt
->SCp
.buffers_residual
=0; 1167 SCpnt
->SCp
.Status
= CHECK_CONDITION
; 1168 SCpnt
->SCp
.Message
=0; 1169 SCpnt
->SCp
.have_data_in
=0; 1170 SCpnt
->SCp
.sent_command
=0; 1172 /* Turn led on, when this is the first command. */ 1175 HOSTDATA(shpnt
)->commands
++; 1176 if(HOSTDATA(shpnt
)->commands
==1) 1179 #if defined(DEBUG_QUEUES) 1180 if(HOSTDATA(shpnt
)->debug
& debug_queues
) 1181 printk("i+ (%d), ",HOSTDATA(shpnt
)->commands
); 1183 append_SC(&ISSUE_SC
, SCpnt
); 1185 /* Enable bus free interrupt, when we aren't currently on the bus */ 1187 SETPORT(SIMODE0
, DISCONNECTED_SC
? ENSELDI
:0); 1188 SETPORT(SIMODE1
, ISSUE_SC
? ENBUSFREE
:0); 1190 restore_flags(flags
); 1192 #if defined(DEBUG_RACE) 1193 leave_driver("queue"); 1200 * We only support commands in interrupt-driven fashion 1202 intaha152x_command(Scsi_Cmnd
* SCpnt
) 1204 printk("aha152x: interrupt driven driver; use aha152x_queue()\n"); 1209 * Abort a queued command 1210 * (commands that are on the bus can't be aborted easily) 1212 intaha152x_abort(Scsi_Cmnd
* SCpnt
) 1214 struct Scsi_Host
*shpnt
= SCpnt
->host
; 1215 unsigned long flags
; 1216 Scsi_Cmnd
*ptr
, *prev
; 1221 #if defined(DEBUG_ABORT) 1222 if(HOSTDATA(shpnt
)->debug
& debug_abort
) { 1223 printk("aha152x: abort(), SCpnt=0x%08x, ", (unsigned int) SCpnt
); 1228 /* look for command in issue queue */ 1229 for(ptr
= ISSUE_SC
, prev
= NULL
; 1230 ptr
&& ptr
!= SCpnt
; 1231 prev
= ptr
, ptr
= (Scsi_Cmnd
*) ptr
->host_scribble
); 1236 prev
->host_scribble
= ptr
->host_scribble
; 1238 ISSUE_SC
= (Scsi_Cmnd
*) ptr
->host_scribble
; 1240 HOSTDATA(shpnt
)->commands
--; 1242 restore_flags(flags
); 1244 ptr
->host_scribble
= NULL
; 1245 ptr
->result
= DID_ABORT
<<16; 1246 spin_lock_irqsave(&io_request_lock
, flags
); 1247 ptr
->scsi_done(ptr
); 1248 spin_unlock_irqrestore(&io_request_lock
, flags
); 1250 return SCSI_ABORT_SUCCESS
; 1252 /* if the bus is busy or a command is currently processed, 1253 we can't do anything more */ 1254 if(TESTLO(SSTAT1
, BUSFREE
) || (CURRENT_SC
&& CURRENT_SC
!= SCpnt
)) { 1255 /* fail abortion, if bus is busy */ 1258 printk("bus busy w/o current command, "); 1260 restore_flags(flags
); 1262 return SCSI_ABORT_BUSY
; 1267 HOSTDATA(shpnt
)->commands
--; 1269 /* target entered bus free before COMMAND COMPLETE, nothing to abort */ 1270 restore_flags(flags
); 1271 spin_lock_irqsave(&io_request_lock
, flags
); 1272 CURRENT_SC
->result
= DID_ERROR
<<16; 1273 CURRENT_SC
->scsi_done(CURRENT_SC
); 1274 CURRENT_SC
= (Scsi_Cmnd
*) NULL
; 1275 spin_unlock_irqrestore(&io_request_lock
, flags
); 1277 return SCSI_ABORT_SUCCESS
; 1279 /* look for command in disconnected queue */ 1280 for(ptr
= DISCONNECTED_SC
, prev
= NULL
; 1281 ptr
&& ptr
!= SCpnt
; 1282 prev
= ptr
, ptr
= (Scsi_Cmnd
*) ptr
->host_scribble
); 1285 /* command wasn't found */ 1286 printk("command not found\n"); 1287 restore_flags(flags
); 1289 return SCSI_ABORT_NOT_RUNNING
; 1291 if(!HOSTDATA(shpnt
)->aborting
) { 1294 prev
->host_scribble
= ptr
->host_scribble
; 1296 DISCONNECTED_SC
= (Scsi_Cmnd
*) ptr
->host_scribble
; 1298 HOSTDATA(shpnt
)->commands
--; 1300 /* set command current and initiate selection, 1301 let the interrupt routine take care of the abortion */ 1303 ptr
->SCp
.phase
= in_selection
| aborted
; 1304 SETPORT(SCSIID
, (shpnt
->this_id
<< OID_
) | CURRENT_SC
->target
); 1308 /* enable interrupts for SELECTION OUT DONE and SELECTION TIME OUT */ 1309 SETPORT(SIMODE0
, ENSELDO
| (DISCONNECTED_SC
? ENSELDI
:0)); 1310 SETPORT(SIMODE1
, ENSELTIMO
); 1312 /* Enable SELECTION OUT sequence */ 1313 SETBITS(SCSISEQ
, ENSELO
| ENAUTOATNO
); 1315 SETBITS(DMACNTRL0
, INTEN
); 1316 HOSTDATA(shpnt
)->abort_result
= SCSI_ABORT_SUCCESS
; 1317 HOSTDATA(shpnt
)->aborting
++; 1318 HOSTDATA(shpnt
)->abortion_complete
=0; 1320 restore_flags(flags
); 1322 /* sleep until the abortion is complete */ 1323 while(!HOSTDATA(shpnt
)->abortion_complete
) 1325 HOSTDATA(shpnt
)->aborting
=0; 1327 returnHOSTDATA(shpnt
)->abort_result
; 1329 /* we're already aborting a command */ 1330 restore_flags(flags
); 1332 return SCSI_ABORT_BUSY
; 1337 * Restore default values to the AIC-6260 registers and reset the fifos 1339 static voidaha152x_reset_ports(struct Scsi_Host
*shpnt
) 1341 /* disable interrupts */ 1342 SETPORT(DMACNTRL0
, RSTFIFO
); 1346 SETPORT(SXFRCTL1
,0); 1348 SETPORT(SCSIRATE
,0); 1350 /* clear all interrupt conditions */ 1351 SETPORT(SSTAT0
,0x7f); 1352 SETPORT(SSTAT1
,0xef); 1354 SETPORT(SSTAT4
, SYNCERR
| FWERR
| FRERR
); 1356 SETPORT(DMACNTRL0
,0); 1357 SETPORT(DMACNTRL1
,0); 1359 SETPORT(BRSTCNTRL
,0xf1); 1361 /* clear SCSI fifo and transfer count */ 1362 SETPORT(SXFRCTL0
, CH1
| CLRCH1
| CLRSTCNT
); 1363 SETPORT(SXFRCTL0
, CH1
); 1365 /* enable interrupts */ 1366 SETPORT(SIMODE0
, DISCONNECTED_SC
? ENSELDI
:0); 1367 SETPORT(SIMODE1
, ISSUE_SC
? ENBUSFREE
:0); 1371 * Reset registers, reset a hanging bus and 1372 * kill active and disconnected commands for target w/o soft reset 1374 intaha152x_reset(Scsi_Cmnd
* SCpnt
,unsigned int unused
) 1376 struct Scsi_Host
*shpnt
= SCpnt
->host
; 1377 unsigned long flags
; 1378 Scsi_Cmnd
*ptr
, *prev
, *next
; 1380 aha152x_reset_ports(shpnt
); 1382 /* Reset, if bus hangs */ 1383 if(TESTLO(SSTAT1
, BUSFREE
)) { 1384 CLRBITS(DMACNTRL0
, INTEN
); 1386 #if defined(DEBUG_RESET) 1387 if(HOSTDATA(shpnt
)->debug
& debug_reset
) { 1388 printk("aha152x: reset(), bus not free: SCSI RESET OUT\n"); 1394 if(ptr
&& !ptr
->device
->soft_reset
) { 1395 ptr
->host_scribble
= NULL
; 1396 ptr
->result
= DID_RESET
<<16; 1397 ptr
->scsi_done(CURRENT_SC
); 1403 ptr
= DISCONNECTED_SC
; 1405 if(!ptr
->device
->soft_reset
) { 1407 prev
->host_scribble
= ptr
->host_scribble
; 1409 DISCONNECTED_SC
= (Scsi_Cmnd
*) ptr
->host_scribble
; 1411 next
= (Scsi_Cmnd
*) ptr
->host_scribble
; 1413 ptr
->host_scribble
= NULL
; 1414 ptr
->result
= DID_RESET
<<16; 1415 spin_lock_irqsave(&io_request_lock
, flags
); 1416 ptr
->scsi_done(ptr
); 1417 spin_unlock_irqrestore(&io_request_lock
, flags
); 1422 ptr
= (Scsi_Cmnd
*) ptr
->host_scribble
; 1425 restore_flags(flags
); 1427 #if defined(DEBUG_RESET) 1428 if(HOSTDATA(shpnt
)->debug
& debug_reset
) { 1429 printk("commands on targets w/ soft-resets:\n"); 1435 SETPORT(SCSISEQ
, SCSIRSTO
); 1440 SETPORT(SIMODE0
, DISCONNECTED_SC
? ENSELDI
:0); 1441 SETPORT(SIMODE1
, ISSUE_SC
? ENBUSFREE
:0); 1443 SETPORT(DMACNTRL0
, INTEN
); 1445 return SCSI_RESET_SUCCESS
; 1449 * Return the "logical geometry" 1451 intaha152x_biosparam(Scsi_Disk
* disk
, kdev_t dev
,int*info_array
) 1453 struct Scsi_Host
*shpnt
= disk
->device
->host
; 1455 #if defined(DEBUG_BIOSPARAM) 1456 if(HOSTDATA(shpnt
)->debug
& debug_biosparam
) 1457 printk("aha152x_biosparam: dev=%s, size=%d, ", 1458 kdevname(dev
), disk
->capacity
); 1461 /* try default translation */ 1464 info_array
[2] = disk
->capacity
/ (64*32); 1466 /* for disks >1GB do some guessing */ 1467 if(info_array
[2] >=1024) { 1470 /* try to figure out the geometry from the partition table */ 1471 if(scsicam_bios_param(disk
, dev
, info
) <0|| 1472 !((info
[0] ==64&& info
[1] ==32) || (info
[0] ==255&& info
[1] ==63))) { 1474 printk("aha152x: unable to verify geometry for disk with >1GB.\n" 1475 " using extended translation.\n"); 1478 info_array
[2] = disk
->capacity
/ (255*63); 1480 printk("aha152x: unable to verify geometry for disk with >1GB.\n" 1481 " Using default translation. Please verify yourself.\n" 1482 " Perhaps you need to enable extended translation in the driver.\n" 1483 " See /usr/src/linux/drivers/scsi/aha152x.c for details.\n"); 1486 info_array
[0] = info
[0]; 1487 info_array
[1] = info
[1]; 1488 info_array
[2] = info
[2]; 1490 if(info
[0] ==255&& !EXT_TRANS
) { 1491 printk("aha152x: current partition table is using extended translation.\n" 1492 " using it also, although it's not explicty enabled.\n"); 1496 #if defined(DEBUG_BIOSPARAM) 1497 if(HOSTDATA(shpnt
)->debug
& debug_biosparam
) { 1498 printk("bios geometry: head=%d, sec=%d, cyl=%d\n", 1499 info_array
[0], info_array
[1], info_array
[2]); 1500 printk("WARNING: check, if the bios geometry is correct.\n"); 1508 * Internal done function 1510 voidaha152x_done(struct Scsi_Host
*shpnt
,int error
) 1512 unsigned long flags
; 1515 #if defined(DEBUG_DONE) 1516 if(HOSTDATA(shpnt
)->debug
& debug_done
) { 1517 printk("\naha152x: done(), "); 1523 #if defined(DEBUG_DONE) 1524 if(HOSTDATA(shpnt
)->debug
& debug_done
) 1525 printk("done(%x), ", error
); 1531 done_SC
= CURRENT_SC
; 1534 /* turn led off, when no commands are in the driver */ 1535 HOSTDATA(shpnt
)->commands
--; 1536 if(!HOSTDATA(shpnt
)->commands
) 1537 SETPORT(PORTA
,0);/* turn led off */ 1539 #if defined(DEBUG_QUEUES) 1540 if(HOSTDATA(shpnt
)->debug
& debug_queues
) 1541 printk("ok (%d), ",HOSTDATA(shpnt
)->commands
); 1543 restore_flags(flags
); 1545 SETPORT(SIMODE0
, DISCONNECTED_SC
? ENSELDI
:0); 1546 SETPORT(SIMODE1
, ISSUE_SC
? ENBUSFREE
:0); 1549 /* Why poll for the BUS FREE phase, when we have setup the interrupt!? */ 1550 #if defined(DEBUG_PHASES) 1551 if(HOSTDATA(shpnt
)->debug
& debug_phases
) 1552 printk("BUS FREE loop, "); 1554 while(TESTLO(SSTAT1
, BUSFREE
)) 1556 #if defined(DEBUG_PHASES) 1557 if(HOSTDATA(shpnt
)->debug
& debug_phases
) 1558 printk("BUS FREE\n"); 1562 done_SC
->result
= error
; 1563 if(done_SC
->scsi_done
) { 1564 #if defined(DEBUG_DONE) 1565 if(HOSTDATA(shpnt
)->debug
& debug_done
) 1566 printk("calling scsi_done, "); 1568 spin_lock_irqsave(&io_request_lock
, flags
); 1569 done_SC
->scsi_done(done_SC
); 1570 spin_unlock_irqrestore(&io_request_lock
, flags
); 1571 #if defined(DEBUG_DONE) 1572 if(HOSTDATA(shpnt
)->debug
& debug_done
) 1573 printk("done returned, "); 1576 panic("aha152x: current_SC->scsi_done() == NULL"); 1578 aha152x_panic(shpnt
,"done() called outside of command"); 1582 static voidaha152x_complete(struct Scsi_Host
*); 1584 static struct tq_struct aha152x_tq
; 1587 * Run service completions on the card with interrupts enabled. 1590 static voidaha152x_run(void) 1593 for(i
=0; i
< IRQS
; i
++) { 1594 struct Scsi_Host
*shpnt
= aha152x_host
[i
]; 1595 if(shpnt
&&HOSTDATA(shpnt
)->service
) { 1596 HOSTDATA(shpnt
)->service
=0; 1597 aha152x_complete(shpnt
); 1603 * Interrupts handler (main routine of the driver) 1606 static voidaha152x_intr(int irqno
,void*dev_id
,struct pt_regs
*regs
) 1608 struct Scsi_Host
*shpnt
= aha152x_host
[irqno
- IRQ_MIN
]; 1610 #if defined(DEBUG_RACE) 1611 enter_driver("intr"); 1613 #if defined(DEBUG_INTR) 1614 if(HOSTDATA(shpnt
)->debug
& debug_intr
) 1615 printk("\naha152x: intr(), "); 1620 panic("aha152x: catched interrupt for unknown controller.\n"); 1622 /* no more interrupts from the controller, while we're busy. 1623 INTEN is restored by the BH handler */ 1625 CLRBITS(DMACNTRL0
, INTEN
); 1627 /* Poke the BH handler */ 1629 HOSTDATA(shpnt
)->service
=1; 1630 aha152x_tq
.routine
= (void*) aha152x_run
; 1631 queue_task(&aha152x_tq
, &tq_immediate
); 1632 mark_bh(IMMEDIATE_BH
); 1635 static voidaha152x_complete(struct Scsi_Host
*shpnt
) 1640 /* disconnected target is trying to reconnect. 1641 Only possible, if we have disconnected nexuses and 1642 nothing is occupying the bus. 1645 if(TESTHI(SSTAT0
, SELDI
) && 1647 (!CURRENT_SC
|| (CURRENT_SC
->SCp
.phase
& in_selection
))) { 1648 int identify_msg
, target
, i
; 1650 /* Avoid conflicts when a target reconnects 1651 while we are trying to connect to another. */ 1653 #if defined(DEBUG_QUEUES) 1654 if(HOSTDATA(shpnt
)->debug
& debug_queues
) 1659 append_SC(&ISSUE_SC
, CURRENT_SC
); 1661 restore_flags(flags
); 1663 /* disable sequences */ 1665 SETPORT(SSTAT0
, CLRSELDI
); 1666 SETPORT(SSTAT1
, CLRBUSFREE
); 1668 #if defined(DEBUG_QUEUES) || defined(DEBUG_PHASES) 1669 if(HOSTDATA(shpnt
)->debug
& (debug_queues
| debug_phases
)) 1670 printk("reselected, "); 1673 i
=GETPORT(SELID
) & ~(1<< shpnt
->this_id
); 1677 aha152x_panic(shpnt
,"reconnecting target unknown"); 1679 for(; (i
&1) ==0; target
++, i
>>=1); 1681 #if defined(DEBUG_QUEUES) 1682 if(HOSTDATA(shpnt
)->debug
& debug_queues
) 1683 printk("SELID=%02x, target=%d, ",GETPORT(SELID
), target
); 1685 SETPORT(SCSIID
, (shpnt
->this_id
<< OID_
) | target
); 1686 SETPORT(SCSISEQ
, ENRESELI
); 1688 if(TESTLO(SSTAT0
, SELDI
)) 1689 aha152x_panic(shpnt
,"RESELI failed"); 1691 SETPORT(SCSIRATE
,HOSTDATA(shpnt
)->syncrate
[target
] &0x7f); 1693 SETPORT(SCSISIG
, P_MSGI
); 1695 /* Get identify message */ 1696 if((i
=getphase(shpnt
)) != P_MSGI
) { 1697 printk("target doesn't enter MSGI to identify (phase=%02x)\n", i
); 1698 aha152x_panic(shpnt
,"unknown lun"); 1702 SETPORT(SXFRCTL0
, CH1
); 1704 identify_msg
=GETPORT(SCSIBUS
); 1706 if(!(identify_msg
& IDENTIFY_BASE
)) { 1707 printk("target=%d, inbound message (%02x) != IDENTIFY\n", 1708 target
, identify_msg
); 1709 aha152x_panic(shpnt
,"unknown lun"); 1711 #if defined(DEBUG_QUEUES) 1712 if(HOSTDATA(shpnt
)->debug
& debug_queues
) 1713 printk("identify=%02x, lun=%d, ", identify_msg
, identify_msg
&0x3f); 1719 #if defined(DEBUG_QUEUES) 1720 if(HOSTDATA(shpnt
)->debug
& debug_queues
) 1723 CURRENT_SC
=remove_SC(&DISCONNECTED_SC
, target
, identify_msg
&0x3f); 1726 printk("lun=%d, ", identify_msg
&0x3f); 1727 aha152x_panic(shpnt
,"no disconnected command for that lun"); 1729 CURRENT_SC
->SCp
.phase
&= ~disconnected
; 1730 restore_flags(flags
); 1733 if(getphase(shpnt
) != P_MSGI
) { 1735 SETPORT(SIMODE1
, ENPHASEMIS
| ENBUSFREE
); 1736 #if defined(DEBUG_RACE) 1737 leave_driver("(reselected) intr"); 1739 SETBITS(DMACNTRL0
, INTEN
); 1743 /* Check, if we aren't busy with a command */ 1745 /* bus is free to issue a queued command */ 1746 if(TESTHI(SSTAT1
, BUSFREE
) && ISSUE_SC
) { 1749 #if defined(DEBUG_QUEUES) 1750 if(HOSTDATA(shpnt
)->debug
& debug_queues
) 1753 CURRENT_SC
=remove_first_SC(&ISSUE_SC
); 1754 restore_flags(flags
); 1756 #if defined(DEBUG_INTR) || defined(DEBUG_SELECTION) || defined(DEBUG_PHASES) 1757 if(HOSTDATA(shpnt
)->debug
& (debug_intr
| debug_selection
| debug_phases
)) 1758 printk("issuing command, "); 1760 CURRENT_SC
->SCp
.phase
= in_selection
; 1762 #if defined(DEBUG_INTR) || defined(DEBUG_SELECTION) || defined(DEBUG_PHASES) 1763 if(HOSTDATA(shpnt
)->debug
& (debug_intr
| debug_selection
| debug_phases
)) 1764 printk("selecting %d, ", CURRENT_SC
->target
); 1766 SETPORT(SCSIID
, (shpnt
->this_id
<< OID_
) | CURRENT_SC
->target
); 1768 /* Enable interrupts for SELECTION OUT DONE and SELECTION OUT INITIATED */ 1769 SETPORT(SXFRCTL1
,HOSTDATA(shpnt
)->parity
? (ENSPCHK
| ENSTIMER
) : ENSTIMER
); 1771 /* enable interrupts for SELECTION OUT DONE and SELECTION TIME OUT */ 1772 SETPORT(SIMODE0
, ENSELDO
| (DISCONNECTED_SC
? ENSELDI
:0)); 1773 SETPORT(SIMODE1
, ENSELTIMO
); 1775 /* Enable SELECTION OUT sequence */ 1776 SETBITS(SCSISEQ
, ENSELO
| ENAUTOATNO
); 1779 /* No command we are busy with and no new to issue */ 1780 printk("aha152x: ignoring spurious interrupt, nothing to do\n"); 1781 if(TESTHI(DMACNTRL0
, SWINT
)) { 1782 printk("aha152x: SWINT is set! Why?\n"); 1783 CLRBITS(DMACNTRL0
, SWINT
); 1788 #if defined(DEBUG_RACE) 1789 leave_driver("(selecting) intr"); 1791 SETBITS(DMACNTRL0
, INTEN
); 1794 /* the bus is busy with something */ 1796 #if defined(DEBUG_INTR) 1797 if(HOSTDATA(shpnt
)->debug
& debug_intr
) 1801 /* we are waiting for the result of a selection attempt */ 1802 if(CURRENT_SC
->SCp
.phase
& in_selection
) { 1803 if(TESTLO(SSTAT1
, SELTO
)) { 1805 if(TESTHI(SSTAT0
, SELDO
)) { 1806 /* clear BUS FREE interrupt */ 1807 SETPORT(SSTAT1
, CLRBUSFREE
); 1809 /* Disable SELECTION OUT sequence */ 1810 CLRBITS(SCSISEQ
, ENSELO
| ENAUTOATNO
); 1812 /* Disable SELECTION OUT DONE interrupt */ 1813 CLRBITS(SIMODE0
, ENSELDO
); 1814 CLRBITS(SIMODE1
, ENSELTIMO
); 1816 if(TESTLO(SSTAT0
, SELDO
)) { 1817 printk("aha152x: passing bus free condition\n"); 1819 #if defined(DEBUG_RACE) 1820 leave_driver("(passing bus free) intr"); 1822 SETBITS(DMACNTRL0
, INTEN
); 1824 if(CURRENT_SC
->SCp
.phase
& aborted
) { 1825 HOSTDATA(shpnt
)->abort_result
= SCSI_ABORT_ERROR
; 1826 HOSTDATA(shpnt
)->abortion_complete
++; 1828 aha152x_done(shpnt
, DID_NO_CONNECT
<<16); 1832 #if defined(DEBUG_SELECTION) || defined(DEBUG_PHASES) 1833 if(HOSTDATA(shpnt
)->debug
& (debug_selection
| debug_phases
)) 1834 printk("SELDO (SELID=%x), ",GETPORT(SELID
)); 1837 /* selection was done */ 1838 SETPORT(SSTAT0
, CLRSELDO
); 1840 #if defined(DEBUG_ABORT) 1841 if((HOSTDATA(shpnt
)->debug
& debug_abort
) && (CURRENT_SC
->SCp
.phase
& aborted
)) 1842 printk("(ABORT) target selected, "); 1845 CURRENT_SC
->SCp
.phase
&= ~in_selection
; 1846 CURRENT_SC
->SCp
.phase
|= in_other
; 1848 ADDMSG(IDENTIFY(HOSTDATA(shpnt
)->reconnect
, CURRENT_SC
->lun
)); 1850 if(!(SYNCRATE
&0x80) &&HOSTDATA(shpnt
)->synchronous
) { 1851 ADDMSG(EXTENDED_MESSAGE
); 1853 ADDMSG(EXTENDED_SDTR
); 1857 printk("outbound SDTR: "); 1858 print_msg(&MSG(MSGLEN
-5)); 1861 CURRENT_SC
->SCp
.phase
|= in_sync
; 1863 #if defined(DEBUG_RACE) 1864 leave_driver("(SELDO) intr"); 1866 SETPORT(SCSIRATE
, SYNCRATE
&0x7f); 1868 SETPORT(SCSISIG
, P_MSGO
); 1871 SETPORT(SIMODE1
, ENREQINIT
| ENBUSFREE
); 1872 SETBITS(DMACNTRL0
, INTEN
); 1876 aha152x_panic(shpnt
,"neither timeout nor selection\007"); 1878 #if defined(DEBUG_SELECTION) || defined(DEBUG_PHASES) 1879 if(HOSTDATA(shpnt
)->debug
& (debug_selection
| debug_phases
)) 1882 /* end selection attempt */ 1883 CLRBITS(SCSISEQ
, ENSELO
| ENAUTOATNO
); 1886 SETPORT(SSTAT1
, CLRSELTIMO
); 1888 SETPORT(SIMODE0
, DISCONNECTED_SC
? ENSELDI
:0); 1889 SETPORT(SIMODE1
, ISSUE_SC
? ENBUSFREE
:0); 1890 SETBITS(DMACNTRL0
, INTEN
); 1891 #if defined(DEBUG_RACE) 1892 leave_driver("(SELTO) intr"); 1895 if(CURRENT_SC
->SCp
.phase
& aborted
) { 1896 #if defined(DEBUG_ABORT) 1897 if(HOSTDATA(shpnt
)->debug
& debug_abort
) 1898 printk("(ABORT) selection timeout, "); 1900 HOSTDATA(shpnt
)->abort_result
= SCSI_ABORT_ERROR
; 1901 HOSTDATA(shpnt
)->abortion_complete
++; 1903 if(TESTLO(SSTAT0
, SELINGO
)) 1904 /* ARBITRATION not won */ 1905 aha152x_done(shpnt
, DID_BUS_BUSY
<<16); 1907 /* ARBITRATION won, but SELECTION failed */ 1908 aha152x_done(shpnt
, DID_NO_CONNECT
<<16); 1913 /* enable interrupt, when target leaves current phase */ 1914 phase
=getphase(shpnt
); 1915 if(!(phase
& ~P_MASK
))/* "real" phase */ 1916 SETPORT(SCSISIG
, phase
); 1917 SETPORT(SSTAT1
, CLRPHASECHG
); 1918 CURRENT_SC
->SCp
.phase
= 1919 (CURRENT_SC
->SCp
.phase
& ~((P_MASK
|1) <<16)) | (phase
<<16); 1921 /* information transfer phase */ 1923 case P_MSGO
:/* MESSAGE OUT */ 1925 int i
, identify
=0, abort
=0; 1927 #if defined(DEBUG_INTR) || defined(DEBUG_MSGO) || defined(DEBUG_PHASES) 1928 if(HOSTDATA(shpnt
)->debug
& (debug_intr
| debug_msgo
| debug_phases
)) 1929 printk("MESSAGE OUT, "); 1932 ADDMSG(MESSAGE_REJECT
); 1933 #if defined(DEBUG_MSGO) 1934 if(HOSTDATA(shpnt
)->debug
& debug_msgo
) 1935 printk("unexpected MESSAGE OUT phase; rejecting, "); 1938 CLRBITS(SXFRCTL0
, ENDMA
); 1941 SETPORT(SIMODE1
, ENPHASEMIS
| ENREQINIT
| ENBUSFREE
); 1943 /* wait for data latch to become ready or a phase change */ 1944 while(TESTLO(DMASTAT
, INTSTAT
)) 1947 #if defined(DEBUG_MSGO) 1948 if(HOSTDATA(shpnt
)->debug
& debug_msgo
) { 1951 printk("messages ("); 1952 for(i
=0; i
< MSGLEN
; i
+=print_msg(&MSG(i
)),printk(" ")); 1957 for(i
=0; i
< MSGLEN
&&TESTLO(SSTAT1
, PHASEMIS
); i
++) { 1958 #if defined(DEBUG_MSGO) 1959 if(HOSTDATA(shpnt
)->debug
& debug_msgo
) 1960 printk("%x ",MSG(i
)); 1962 if(i
== MSGLEN
-1) { 1963 /* Leave MESSAGE OUT after transfer */ 1964 SETPORT(SSTAT1
, CLRATNO
); 1966 SETPORT(SCSIDAT
,MSG(i
)); 1971 if(MSG(i
) ==IDENTIFY(HOSTDATA(shpnt
)->reconnect
, CURRENT_SC
->lun
)) 1982 CURRENT_SC
->SCp
.phase
|= sent_ident
; 1985 /* revive abort(); abort() enables interrupts */ 1986 HOSTDATA(shpnt
)->abort_result
= SCSI_ABORT_SUCCESS
; 1987 HOSTDATA(shpnt
)->abortion_complete
++; 1989 CURRENT_SC
->SCp
.phase
&= ~(P_MASK
<<16); 1992 SETBITS(DMACNTRL0
, INTEN
); 1993 #if defined(DEBUG_RACE) 1994 leave_driver("(ABORT) intr"); 1996 aha152x_done(shpnt
, DID_ABORT
<<16); 2003 case P_CMD
:/* COMMAND phase */ 2004 #if defined(DEBUG_INTR) || defined(DEBUG_CMD) || defined(DEBUG_PHASES) 2005 if(HOSTDATA(shpnt
)->debug
& (debug_intr
| debug_cmd
| debug_phases
)) 2006 printk("COMMAND, "); 2008 if(!(CURRENT_SC
->SCp
.sent_command
)) { 2011 CLRBITS(SXFRCTL0
, ENDMA
); 2014 SETPORT(SIMODE1
, ENPHASEMIS
| ENREQINIT
| ENBUSFREE
); 2016 /* wait for data latch to become ready or a phase change */ 2017 while(TESTLO(DMASTAT
, INTSTAT
)) 2020 for(i
=0; i
< CURRENT_SC
->cmd_len
&&TESTLO(SSTAT1
, PHASEMIS
); i
++) { 2021 SETPORT(SCSIDAT
, CURRENT_SC
->cmnd
[i
]); 2027 if(i
< CURRENT_SC
->cmd_len
&&TESTHI(SSTAT1
, PHASEMIS
)) 2028 aha152x_panic(shpnt
,"target left COMMAND"); 2030 CURRENT_SC
->SCp
.sent_command
++; 2032 aha152x_panic(shpnt
,"Nothing to send while in COMMAND"); 2035 case P_MSGI
:/* MESSAGE IN phase */ 2039 #if defined(DEBUG_INTR) || defined(DEBUG_MSGI) || defined(DEBUG_PHASES) 2040 if(HOSTDATA(shpnt
)->debug
& (debug_intr
| debug_msgi
| debug_phases
)) 2041 printk("MESSAGE IN, "); 2043 SETPORT(SXFRCTL0
, CH1
); 2046 SETPORT(SIMODE1
, ENBUSFREE
); 2048 while(phase
== P_MSGI
) { 2049 CURRENT_SC
->SCp
.Message
=GETPORT(SCSIDAT
); 2050 switch(CURRENT_SC
->SCp
.Message
) { 2052 #if defined(DEBUG_MSGI) || defined(DEBUG_PHASES) 2053 if(HOSTDATA(shpnt
)->debug
& (debug_msgi
| debug_phases
)) 2054 printk("target disconnected, "); 2056 CURRENT_SC
->SCp
.Message
=0; 2057 CURRENT_SC
->SCp
.phase
|= disconnected
; 2058 if(!HOSTDATA(shpnt
)->reconnect
) 2059 aha152x_panic(shpnt
,"target was not allowed to disconnect"); 2063 case COMMAND_COMPLETE
: 2064 #if defined(DEBUG_MSGI) || defined(DEBUG_PHASES) 2065 if(HOSTDATA(shpnt
)->debug
& (debug_msgi
| debug_phases
)) 2066 printk("inbound message (COMMAND COMPLETE), "); 2071 case MESSAGE_REJECT
: 2072 if(CURRENT_SC
->SCp
.phase
& in_sync
) { 2073 CURRENT_SC
->SCp
.phase
&= ~in_sync
; 2075 printk("synchronous rejected, "); 2077 printk("inbound message (MESSAGE REJECT), "); 2078 #if defined(DEBUG_MSGI) 2079 if(HOSTDATA(shpnt
)->debug
& debug_msgi
) 2080 printk("inbound message (MESSAGE REJECT), "); 2085 #if defined(DEBUG_MSGI) 2086 if(HOSTDATA(shpnt
)->debug
& debug_msgi
) 2087 printk("inbound message (SAVE DATA POINTERS), "); 2091 case RESTORE_POINTERS
: 2092 #if defined(DEBUG_MSGI) 2093 if(HOSTDATA(shpnt
)->debug
& debug_msgi
) 2094 printk("inbound message (RESTORE DATA POINTERS), "); 2098 case EXTENDED_MESSAGE
: 2103 #if defined(DEBUG_MSGI) 2104 if(HOSTDATA(shpnt
)->debug
& debug_msgi
) 2105 printk("inbound message (EXTENDED MESSAGE), "); 2108 if(getphase(shpnt
) != P_MSGI
) 2111 buffer
[0] = EXTENDED_MESSAGE
; 2112 buffer
[1] =GETPORT(SCSIDAT
); 2114 for(i
=0; i
< buffer
[1] && 2115 (make_acklow(shpnt
),getphase(shpnt
) == P_MSGI
); i
++) 2116 buffer
[2+ i
] =GETPORT(SCSIDAT
); 2118 #if defined(DEBUG_MSGI) 2119 if(HOSTDATA(shpnt
)->debug
& debug_msgi
) 2129 aha152x_panic(shpnt
,"SDTR message length != 3"); 2131 if(!HOSTDATA(shpnt
)->synchronous
) 2134 printk("inbound SDTR: "); 2137 ticks
= (buffer
[3] *4+49) /50; 2139 if(CURRENT_SC
->SCp
.phase
& in_sync
) { 2140 /* we initiated SDTR */ 2141 if(ticks
>9|| buffer
[4] <1|| buffer
[4] >8) 2142 aha152x_panic(shpnt
,"received SDTR invalid"); 2144 SYNCRATE
|= ((ticks
-2) <<4) + buffer
[4]; 2145 }else if(ticks
<=9&& buffer
[4] >=1) { 2149 ADDMSG(EXTENDED_MESSAGE
); 2151 ADDMSG(EXTENDED_SDTR
); 2160 printk("outbound SDTR: "); 2161 print_msg(&MSG(MSGLEN
-5)); 2163 CURRENT_SC
->SCp
.phase
|= in_sync
; 2165 SYNCRATE
|= ((ticks
-2) <<4) + buffer
[4]; 2169 /* requested SDTR is too slow, do it asynchronously */ 2170 ADDMSG(MESSAGE_REJECT
); 2174 SETPORT(SCSIRATE
, SYNCRATE
&0x7f); 2178 case EXTENDED_MODIFY_DATA_POINTER
: 2179 case EXTENDED_EXTENDED_IDENTIFY
: 2182 ADDMSG(MESSAGE_REJECT
); 2189 printk("unsupported inbound message %x, ", CURRENT_SC
->SCp
.Message
); 2195 phase
=getphase(shpnt
); 2199 CURRENT_SC
->SCp
.phase
|= in_sync
; 2201 CURRENT_SC
->SCp
.phase
&= ~in_sync
; 2204 SETPORT(SCSISIG
, P_MSGI
| ATNO
); 2206 /* clear SCSI fifo on BUSFREE */ 2207 if(phase
== P_BUSFREE
) 2208 SETPORT(SXFRCTL0
, CH1
| CLRCH1
); 2210 if(CURRENT_SC
->SCp
.phase
& disconnected
) { 2213 #if defined(DEBUG_QUEUES) 2214 if(HOSTDATA(shpnt
)->debug
& debug_queues
) 2217 append_SC(&DISCONNECTED_SC
, CURRENT_SC
); 2218 CURRENT_SC
->SCp
.phase
|=1<<16; 2220 restore_flags(flags
); 2222 SETBITS(SCSISEQ
, ENRESELI
); 2224 SETPORT(SIMODE0
, DISCONNECTED_SC
? ENSELDI
:0); 2225 SETPORT(SIMODE1
, ISSUE_SC
? ENBUSFREE
:0); 2227 SETBITS(DMACNTRL0
, INTEN
); 2234 case P_STATUS
:/* STATUS IN phase */ 2235 #if defined(DEBUG_STATUS) || defined(DEBUG_INTR) || defined(DEBUG_PHASES) 2236 if(HOSTDATA(shpnt
)->debug
& (debug_status
| debug_intr
| debug_phases
)) 2239 SETPORT(SXFRCTL0
, CH1
); 2242 SETPORT(SIMODE1
, ENREQINIT
| ENBUSFREE
); 2244 if(TESTHI(SSTAT1
, PHASEMIS
)) 2245 printk("aha152x: passing STATUS phase"); 2247 CURRENT_SC
->SCp
.Status
=GETPORT(SCSIBUS
); 2251 #if defined(DEBUG_STATUS) 2252 if(HOSTDATA(shpnt
)->debug
& debug_status
) { 2253 printk("inbound status "); 2254 print_status(CURRENT_SC
->SCp
.Status
); 2260 case P_DATAI
:/* DATA IN phase */ 2262 int fifodata
, data_count
, done
; 2264 #if defined(DEBUG_DATAI) || defined(DEBUG_INTR) || defined(DEBUG_PHASES) 2265 if(HOSTDATA(shpnt
)->debug
& (debug_datai
| debug_intr
| debug_phases
)) 2266 printk("DATA IN, "); 2270 if(GETPORT(FIFOSTAT
) ||GETPORT(SSTAT2
) & (SFULL
| SFCNT
)) 2271 printk("aha152x: P_DATAI: %d(%d) bytes left in FIFO, resetting\n", 2272 GETPORT(FIFOSTAT
),GETPORT(SSTAT2
) & (SFULL
| SFCNT
)); 2275 /* reset host fifo */ 2276 SETPORT(DMACNTRL0
, RSTFIFO
); 2277 SETPORT(DMACNTRL0
, RSTFIFO
| ENDMA
); 2279 SETPORT(SXFRCTL0
, CH1
| SCSIEN
| DMAEN
); 2282 SETPORT(SIMODE1
, ENPHASEMIS
| ENBUSFREE
); 2284 /* done is set when the FIFO is empty after the target left DATA IN */ 2287 /* while the target stays in DATA to transfer data */ 2289 #if defined(DEBUG_DATAI) 2290 if(HOSTDATA(shpnt
)->debug
& debug_datai
) 2291 printk("expecting data, "); 2293 /* wait for PHASEMIS or full FIFO */ 2294 while(TESTLO(DMASTAT
, DFIFOFULL
| INTSTAT
)) 2297 #if defined(DEBUG_DATAI) 2298 if(HOSTDATA(shpnt
)->debug
& debug_datai
) 2302 if(TESTHI(DMASTAT
, DFIFOFULL
)) 2303 fifodata
=GETPORT(FIFOSTAT
); 2305 /* wait for SCSI fifo to get empty */ 2306 while(TESTLO(SSTAT2
, SEMPTY
)) 2309 /* rest of data in FIFO */ 2310 fifodata
=GETPORT(FIFOSTAT
); 2311 #if defined(DEBUG_DATAI) 2312 if(HOSTDATA(shpnt
)->debug
& debug_datai
) 2313 printk("last transfer, "); 2318 #if defined(DEBUG_DATAI) 2319 if(HOSTDATA(shpnt
)->debug
& debug_datai
) 2320 printk("fifodata=%d, ", fifodata
); 2323 while(fifodata
&& CURRENT_SC
->SCp
.this_residual
) { 2324 data_count
= fifodata
; 2326 /* limit data transfer to size of first sg buffer */ 2327 if(data_count
> CURRENT_SC
->SCp
.this_residual
) 2328 data_count
= CURRENT_SC
->SCp
.this_residual
; 2330 fifodata
-= data_count
; 2332 #if defined(DEBUG_DATAI) 2333 if(HOSTDATA(shpnt
)->debug
& debug_datai
) 2334 printk("data_count=%d, ", data_count
); 2338 /* get a single byte in byte mode */ 2339 SETBITS(DMACNTRL0
, _8BIT
); 2340 *CURRENT_SC
->SCp
.ptr
++ =GETPORT(DATAPORT
); 2341 CURRENT_SC
->SCp
.this_residual
--; 2344 CLRBITS(DMACNTRL0
, _8BIT
); 2345 data_count
>>=1;/* Number of words */ 2346 insw(DATAPORT
, CURRENT_SC
->SCp
.ptr
, data_count
); 2347 #if defined(DEBUG_DATAI) 2348 if(HOSTDATA(shpnt
)->debug
& debug_datai
) 2349 /* show what comes with the last transfer */ 2356 printk("data on last transfer (%d bytes) ", 2359 printk("data on last transfer (%d bytes: ", 2361 data
= (unsigned char*) CURRENT_SC
->SCp
.ptr
; 2362 for(i
=0; i
<2* data_count
; i
++) 2363 printk("%2x ", *data
++); 2368 CURRENT_SC
->SCp
.ptr
+=2* data_count
; 2369 CURRENT_SC
->SCp
.this_residual
-=2* data_count
; 2371 /* if this buffer is full and there are more buffers left */ 2372 if(!CURRENT_SC
->SCp
.this_residual
&& 2373 CURRENT_SC
->SCp
.buffers_residual
) { 2374 /* advance to next buffer */ 2375 CURRENT_SC
->SCp
.buffers_residual
--; 2376 CURRENT_SC
->SCp
.buffer
++; 2377 CURRENT_SC
->SCp
.ptr
= CURRENT_SC
->SCp
.buffer
->address
; 2378 CURRENT_SC
->SCp
.this_residual
= CURRENT_SC
->SCp
.buffer
->length
; 2383 * FIFO should be empty 2386 printk("aha152x: more data than expected (%d bytes)\n", 2388 SETBITS(DMACNTRL0
, _8BIT
); 2389 printk("aha152x: data ("); 2391 printk("%2x ",GETPORT(DATAPORT
)); 2394 #if defined(DEBUG_DATAI) 2395 if(HOSTDATA(shpnt
)->debug
& debug_datai
) 2397 printk("fifo empty, "); 2399 printk("something left in fifo, "); 2403 #if defined(DEBUG_DATAI) 2404 if((HOSTDATA(shpnt
)->debug
& debug_datai
) && 2405 (CURRENT_SC
->SCp
.buffers_residual
|| 2406 CURRENT_SC
->SCp
.this_residual
)) 2407 printk("left buffers (buffers=%d, bytes=%d), ", 2408 CURRENT_SC
->SCp
.buffers_residual
, CURRENT_SC
->SCp
.this_residual
); 2410 /* transfer can be considered ended, when SCSIEN reads back zero */ 2411 CLRBITS(SXFRCTL0
, SCSIEN
| DMAEN
); 2412 while(TESTHI(SXFRCTL0
, SCSIEN
)) 2414 CLRBITS(DMACNTRL0
, ENDMA
); 2416 #if defined(DEBUG_DATAI) || defined(DEBUG_INTR) 2417 if(HOSTDATA(shpnt
)->debug
& (debug_datai
| debug_intr
)) 2418 printk("got %d bytes, ",GETSTCNT()); 2421 CURRENT_SC
->SCp
.have_data_in
++; 2425 case P_DATAO
:/* DATA OUT phase */ 2429 #if defined(DEBUG_DATAO) || defined(DEBUG_INTR) || defined(DEBUG_PHASES) 2430 if(HOSTDATA(shpnt
)->debug
& (debug_datao
| debug_intr
| debug_phases
)) 2431 printk("DATA OUT, "); 2433 #if defined(DEBUG_DATAO) 2434 if(HOSTDATA(shpnt
)->debug
& debug_datao
) 2435 printk("got data to send (bytes=%d, buffers=%d), ", 2436 CURRENT_SC
->SCp
.this_residual
, 2437 CURRENT_SC
->SCp
.buffers_residual
); 2440 if(GETPORT(FIFOSTAT
) ||GETPORT(SSTAT2
) & (SFULL
| SFCNT
)) { 2441 printk("%d(%d) left in FIFO, ", 2442 GETPORT(FIFOSTAT
),GETPORT(SSTAT2
) & (SFULL
| SFCNT
)); 2443 aha152x_panic(shpnt
,"FIFO should be empty"); 2445 SETPORT(SXFRCTL0
, CH1
| CLRSTCNT
| CLRCH1
); 2446 SETPORT(SXFRCTL0
, SCSIEN
| DMAEN
| CH1
); 2448 SETPORT(DMACNTRL0
, WRITE_READ
| RSTFIFO
); 2449 SETPORT(DMACNTRL0
, ENDMA
| WRITE_READ
); 2452 SETPORT(SIMODE1
, ENPHASEMIS
| ENBUSFREE
); 2454 /* while current buffer is not empty or 2455 there are more buffers to transfer */ 2456 while(TESTLO(SSTAT1
, PHASEMIS
) && 2457 (CURRENT_SC
->SCp
.this_residual
|| 2458 CURRENT_SC
->SCp
.buffers_residual
)) { 2459 #if defined(DEBUG_DATAO) 2460 if(HOSTDATA(shpnt
)->debug
& debug_datao
) 2461 printk("sending data (left: bytes=%d, buffers=%d), waiting, ", 2462 CURRENT_SC
->SCp
.this_residual
, 2463 CURRENT_SC
->SCp
.buffers_residual
); 2465 /* transfer rest of buffer, but max. 128 byte */ 2467 CURRENT_SC
->SCp
.this_residual
>128? 2468 128: CURRENT_SC
->SCp
.this_residual
; 2470 #if defined(DEBUG_DATAO) 2471 if(HOSTDATA(shpnt
)->debug
& debug_datao
) 2472 printk("data_count=%d, ", data_count
); 2476 /* put a single byte in byte mode */ 2477 SETBITS(DMACNTRL0
, _8BIT
); 2478 SETPORT(DATAPORT
, *CURRENT_SC
->SCp
.ptr
++); 2479 CURRENT_SC
->SCp
.this_residual
--; 2482 CLRBITS(DMACNTRL0
, _8BIT
); 2483 data_count
>>=1;/* number of words */ 2484 outsw(DATAPORT
, CURRENT_SC
->SCp
.ptr
, data_count
); 2485 CURRENT_SC
->SCp
.ptr
+=2* data_count
; 2486 CURRENT_SC
->SCp
.this_residual
-=2* data_count
; 2488 /* wait for FIFO to get empty */ 2489 while(TESTLO(DMASTAT
, DFIFOEMP
| INTSTAT
)) 2492 #if defined(DEBUG_DATAO) 2493 if(HOSTDATA(shpnt
)->debug
& debug_datao
) 2494 printk("fifo (%d bytes), transfered (%d bytes), ", 2495 GETPORT(FIFOSTAT
),GETSTCNT()); 2498 /* if this buffer is empty and there are more buffers left */ 2499 if(TESTLO(SSTAT1
, PHASEMIS
) && 2500 !CURRENT_SC
->SCp
.this_residual
&& 2501 CURRENT_SC
->SCp
.buffers_residual
) { 2502 /* advance to next buffer */ 2503 CURRENT_SC
->SCp
.buffers_residual
--; 2504 CURRENT_SC
->SCp
.buffer
++; 2505 CURRENT_SC
->SCp
.ptr
= CURRENT_SC
->SCp
.buffer
->address
; 2506 CURRENT_SC
->SCp
.this_residual
= CURRENT_SC
->SCp
.buffer
->length
; 2510 if(CURRENT_SC
->SCp
.this_residual
|| CURRENT_SC
->SCp
.buffers_residual
) { 2511 /* target leaves DATA OUT for an other phase (perhaps disconnect) */ 2513 /* data in fifos has to be resend */ 2514 data_count
=GETPORT(SSTAT2
) & (SFULL
| SFCNT
); 2516 data_count
+=GETPORT(FIFOSTAT
); 2517 CURRENT_SC
->SCp
.ptr
-= data_count
; 2518 CURRENT_SC
->SCp
.this_residual
+= data_count
; 2519 #if defined(DEBUG_DATAO) 2520 if(HOSTDATA(shpnt
)->debug
& debug_datao
) 2521 printk("left data (bytes=%d, buffers=%d), fifos (bytes=%d), " 2522 "transfer incomplete, resetting fifo, ", 2523 CURRENT_SC
->SCp
.this_residual
, 2524 CURRENT_SC
->SCp
.buffers_residual
, 2527 SETPORT(DMACNTRL0
, WRITE_READ
| RSTFIFO
); 2528 CLRBITS(SXFRCTL0
, SCSIEN
| DMAEN
); 2529 CLRBITS(DMACNTRL0
, ENDMA
); 2531 #if defined(DEBUG_DATAO) 2532 if(HOSTDATA(shpnt
)->debug
& debug_datao
) 2533 printk("waiting for SCSI fifo to get empty, "); 2535 /* wait for SCSI fifo to get empty */ 2536 while(TESTLO(SSTAT2
, SEMPTY
)) 2538 #if defined(DEBUG_DATAO) 2539 if(HOSTDATA(shpnt
)->debug
& debug_datao
) 2540 printk("ok, left data (bytes=%d, buffers=%d) ", 2541 CURRENT_SC
->SCp
.this_residual
, 2542 CURRENT_SC
->SCp
.buffers_residual
); 2544 CLRBITS(SXFRCTL0
, SCSIEN
| DMAEN
); 2546 /* transfer can be considered ended, when SCSIEN reads back zero */ 2547 while(TESTHI(SXFRCTL0
, SCSIEN
)) 2550 CLRBITS(DMACNTRL0
, ENDMA
); 2553 #if defined(DEBUG_DATAO) || defined(DEBUG_INTR) 2554 if(HOSTDATA(shpnt
)->debug
& (debug_datao
| debug_intr
)) 2555 printk("sent %d data bytes, ",GETSTCNT()); 2560 case P_BUSFREE
:/* BUSFREE */ 2561 #if defined(DEBUG_RACE) 2562 leave_driver("(BUSFREE) intr"); 2564 #if defined(DEBUG_PHASES) 2565 if(HOSTDATA(shpnt
)->debug
& debug_phases
) 2566 printk("unexpected BUS FREE, "); 2568 CURRENT_SC
->SCp
.phase
&= ~(P_MASK
<<16); 2570 aha152x_done(shpnt
, DID_ERROR
<<16);/* Don't know any better */ 2574 case P_PARITY
:/* parity error in DATA phase */ 2575 #if defined(DEBUG_RACE) 2576 leave_driver("(DID_PARITY) intr"); 2578 printk("PARITY error in DATA phase, "); 2580 CURRENT_SC
->SCp
.phase
&= ~(P_MASK
<<16); 2582 SETBITS(DMACNTRL0
, INTEN
); 2583 aha152x_done(shpnt
, DID_PARITY
<<16); 2588 printk("aha152x: unexpected phase\n"); 2593 #if defined(DEBUG_INTR) 2594 if(HOSTDATA(shpnt
)->debug
& debug_intr
) 2595 printk("command done.\n"); 2597 #if defined(DEBUG_RACE) 2598 leave_driver("(done) intr"); 2601 SETPORT(SIMODE0
, DISCONNECTED_SC
? ENSELDI
:0); 2602 SETPORT(SIMODE1
, ISSUE_SC
? ENBUSFREE
:0); 2603 SETPORT(SCSISEQ
, DISCONNECTED_SC
? ENRESELI
:0); 2605 SETBITS(DMACNTRL0
, INTEN
); 2608 (CURRENT_SC
->SCp
.Status
&0xff) 2609 | ((CURRENT_SC
->SCp
.Message
&0xff) <<8) 2612 #if defined(DEBUG_RACE) 2613 printk("done returned (DID_OK: Status=%x; Message=%x).\n", 2614 CURRENT_SC
->SCp
.Status
, CURRENT_SC
->SCp
.Message
); 2619 CURRENT_SC
->SCp
.phase
|=1<<16; 2622 SETPORT(SIMODE1
, ENPHASEMIS
| ENBUSFREE
); 2623 #if defined(DEBUG_INTR) 2624 if(HOSTDATA(shpnt
)->debug
& debug_intr
) 2627 #if defined(DEBUG_RACE) 2628 leave_driver("(PHASEEND) intr"); 2631 SETBITS(DMACNTRL0
, INTEN
); 2636 * Dump the current driver status and panic... 2638 static voidaha152x_panic(struct Scsi_Host
*shpnt
,char*msg
) 2640 printk("\naha152x: %s\n", msg
); 2642 panic("aha152x panic"); 2646 * Display registers of AIC-6260 2648 static voiddisp_ports(struct Scsi_Host
*shpnt
) 2650 #ifdef DEBUG_AHA152X 2654 if(HOSTDATA(shpnt
)->debug
& debug_skipports
) 2658 printk("\n%s: ", CURRENT_SC
?"on bus":"waiting"); 2660 s
=GETPORT(SCSISEQ
); 2661 printk("SCSISEQ ("); 2663 printk("TARGET MODE "); 2671 printk("AUTOATNO "); 2673 printk("AUTOATNI "); 2675 printk("AUTOATNP "); 2677 printk("SCSIRSTO "); 2680 printk(" SCSISIG ("); 2681 s
=GETPORT(SCSISIG
); 2682 switch(s
& P_MASK
) { 2696 printk("MESSAGE OUT"); 2699 printk("MESSAGE IN"); 2702 printk("*illegal*"); 2708 printk("INTSTAT (%s); ",TESTHI(DMASTAT
, INTSTAT
) ?"hi":"lo"); 2735 printk("SCSIRSTI "); 2737 printk("PHASEMIS "); 2741 printk("SCSIPERR "); 2743 printk("PHASECHG "); 2751 s
=GETPORT(SSTAT0
) &GETPORT(SIMODE0
); 2770 s
=GETPORT(SSTAT1
) &GETPORT(SIMODE1
); 2777 printk("SCSIRSTI "); 2779 printk("PHASEMIS "); 2783 printk("SCSIPERR "); 2785 printk("PHASECHG "); 2790 printk("SXFRCTL0 ("); 2792 s
=GETPORT(SXFRCTL0
); 2800 printk("CLRSTCNT "); 2809 s
=GETPORT(SCSISIG
); 2822 printk("SELID (%02x), ",GETPORT(SELID
)); 2833 printk("); SFCNT (%d); ", s
& (SFULL
| SFCNT
)); 2836 printk("SCSICNT (%d), OFFCNT(%d), ", (s
&0xf0) >>4, s
&0x0f); 2848 printk("DMACNTRL0 ("); 2849 s
=GETPORT(DMACNTRL0
); 2850 printk("%s ", s
& _8BIT
?"8BIT":"16BIT"); 2851 printk("%s ", s
& DMA
?"DMA":"PIO"); 2852 printk("%s ", s
& WRITE_READ
?"WRITE":"READ"); 2863 printk("DMASTAT ("); 2864 s
=GETPORT(DMASTAT
); 2870 printk("DFIFOFULL "); 2872 printk("DFIFOEMP "); 2880 * display enabled interrupts 2882 static voiddisp_enintr(struct Scsi_Host
*shpnt
) 2886 printk("enabled interrupts ("); 2888 s
=GETPORT(SIMODE0
); 2894 printk("ENSELINGO "); 2900 printk("ENSPIORDY "); 2902 printk("ENDMADONE "); 2904 s
=GETPORT(SIMODE1
); 2906 printk("ENSELTIMO "); 2908 printk("ENATNTARG "); 2910 printk("ENPHASEMIS "); 2912 printk("ENBUSFREE "); 2914 printk("ENSCSIPERR "); 2916 printk("ENPHASECHG "); 2918 printk("ENREQINIT "); 2922 #if defined(DEBUG_RACE) 2924 static const char*should_leave
; 2925 static int in_driver
=0; 2928 * Only one routine can be in the driver at once. 2930 static voidenter_driver(const char*func
) 2932 unsigned long flags
; 2936 printk("aha152x: entering %s() (%x)\n", func
, jiffies
); 2938 printk("%s should leave first.\n", should_leave
); 2939 panic("aha152x: already in driver\n"); 2942 should_leave
= func
; 2943 restore_flags(flags
); 2946 static voidleave_driver(const char*func
) 2948 unsigned long flags
; 2952 printk("\naha152x: leaving %s() (%x)\n", func
, jiffies
); 2954 printk("aha152x: %s already left.\n", should_leave
); 2955 panic("aha152x: %s already left driver.\n"); 2958 should_leave
= func
; 2959 restore_flags(flags
); 2964 * Show the command data of a command 2966 static voidshow_command(Scsi_Cmnd
* ptr
) 2968 printk("0x%08x: target=%d; lun=%d; cmnd=(", 2969 (unsigned int) ptr
, ptr
->target
, ptr
->lun
); 2971 print_command(ptr
->cmnd
); 2973 printk("); residual=%d; buffers=%d; phase |", 2974 ptr
->SCp
.this_residual
, ptr
->SCp
.buffers_residual
); 2976 if(ptr
->SCp
.phase
& not_issued
) 2977 printk("not issued|"); 2978 if(ptr
->SCp
.phase
& in_selection
) 2979 printk("in selection|"); 2980 if(ptr
->SCp
.phase
& disconnected
) 2981 printk("disconnected|"); 2982 if(ptr
->SCp
.phase
& aborted
) 2984 if(ptr
->SCp
.phase
& sent_ident
) 2985 printk("send_ident|"); 2986 if(ptr
->SCp
.phase
& in_other
) { 2987 printk("; in other("); 2988 switch((ptr
->SCp
.phase
>>16) & P_MASK
) { 3002 printk("MESSAGE OUT"); 3005 printk("MESSAGE IN"); 3008 printk("*illegal*"); 3012 if(ptr
->SCp
.phase
& (1<<16)) 3013 printk("; phaseend"); 3015 printk("; next=0x%08x\n", (unsigned int) ptr
->host_scribble
); 3019 * Dump the queued data 3021 static voidshow_queues(struct Scsi_Host
*shpnt
) 3023 unsigned long flags
; 3028 printk("QUEUE STATUS:\nissue_SC:\n"); 3029 for(ptr
= ISSUE_SC
; ptr
; ptr
= (Scsi_Cmnd
*) ptr
->host_scribble
) 3032 printk("current_SC:\n"); 3034 show_command(CURRENT_SC
); 3038 printk("disconnected_SC:\n"); 3039 for(ptr
= DISCONNECTED_SC
; ptr
; ptr
= (Scsi_Cmnd
*) ptr
->host_scribble
) 3044 restore_flags(flags
); 3047 intaha152x_set_info(char*buffer
,int length
,struct Scsi_Host
*shpnt
) 3049 return(-ENOSYS
);/* Currently this is a no-op */ 3053 #define SPRINTF(args...) pos += sprintf(pos, ## args) 3055 static intget_command(char*pos
, Scsi_Cmnd
* ptr
) 3060 SPRINTF("0x%08x: target=%d; lun=%d; cmnd=( ", 3061 (unsigned int) ptr
, ptr
->target
, ptr
->lun
); 3063 for(i
=0; i
<COMMAND_SIZE(ptr
->cmnd
[0]); i
++) 3064 SPRINTF("0x%02x ", ptr
->cmnd
[i
]); 3066 SPRINTF("); residual=%d; buffers=%d; phase |", 3067 ptr
->SCp
.this_residual
, ptr
->SCp
.buffers_residual
); 3069 if(ptr
->SCp
.phase
& not_issued
) 3070 SPRINTF("not issued|"); 3071 if(ptr
->SCp
.phase
& in_selection
) 3072 SPRINTF("in selection|"); 3073 if(ptr
->SCp
.phase
& disconnected
) 3074 SPRINTF("disconnected|"); 3075 if(ptr
->SCp
.phase
& aborted
) 3076 SPRINTF("aborted|"); 3077 if(ptr
->SCp
.phase
& sent_ident
) 3078 SPRINTF("send_ident|"); 3079 if(ptr
->SCp
.phase
& in_other
) { 3080 SPRINTF("; in other("); 3081 switch((ptr
->SCp
.phase
>>16) & P_MASK
) { 3083 SPRINTF("DATA OUT"); 3095 SPRINTF("MESSAGE OUT"); 3098 SPRINTF("MESSAGE IN"); 3101 SPRINTF("*illegal*"); 3105 if(ptr
->SCp
.phase
& (1<<16)) 3106 SPRINTF("; phaseend"); 3108 SPRINTF("; next=0x%08x\n", (unsigned int) ptr
->host_scribble
); 3110 return(pos
- start
); 3113 static intget_ports(struct Scsi_Host
*shpnt
,char*pos
) 3119 if(HOSTDATA(shpnt
)->debug
& debug_skipports
) 3123 SPRINTF("\n%s: ", CURRENT_SC
?"on bus":"waiting"); 3125 s
=GETPORT(SCSISEQ
); 3126 SPRINTF("SCSISEQ ("); 3128 SPRINTF("TARGET MODE "); 3136 SPRINTF("AUTOATNO "); 3138 SPRINTF("AUTOATNI "); 3140 SPRINTF("AUTOATNP "); 3142 SPRINTF("SCSIRSTO "); 3145 SPRINTF(" SCSISIG ("); 3146 s
=GETPORT(SCSISIG
); 3147 switch(s
& P_MASK
) { 3149 SPRINTF("DATA OUT"); 3161 SPRINTF("MESSAGE OUT"); 3164 SPRINTF("MESSAGE IN"); 3167 SPRINTF("*illegal*"); 3173 SPRINTF("INTSTAT (%s); ",TESTHI(DMASTAT
, INTSTAT
) ?"hi":"lo"); 3184 SPRINTF("SELINGO "); 3190 SPRINTF("SPIORDY "); 3192 SPRINTF("DMADONE "); 3198 SPRINTF("ATNTARG "); 3200 SPRINTF("SCSIRSTI "); 3202 SPRINTF("PHASEMIS "); 3204 SPRINTF("BUSFREE "); 3206 SPRINTF("SCSIPERR "); 3208 SPRINTF("PHASECHG "); 3210 SPRINTF("REQINIT "); 3216 s
=GETPORT(SSTAT0
) &GETPORT(SIMODE0
); 3225 SPRINTF("SELINGO "); 3231 SPRINTF("SPIORDY "); 3233 SPRINTF("DMADONE "); 3235 s
=GETPORT(SSTAT1
) &GETPORT(SIMODE1
); 3240 SPRINTF("ATNTARG "); 3242 SPRINTF("SCSIRSTI "); 3244 SPRINTF("PHASEMIS "); 3246 SPRINTF("BUSFREE "); 3248 SPRINTF("SCSIPERR "); 3250 SPRINTF("PHASECHG "); 3252 SPRINTF("REQINIT "); 3255 SPRINTF("SXFRCTL0 ("); 3257 s
=GETPORT(SXFRCTL0
); 3265 SPRINTF("CLRSTCNT "); 3272 SPRINTF("SIGNAL ("); 3274 s
=GETPORT(SCSISIG
); 3287 SPRINTF("SELID (%02x), ",GETPORT(SELID
)); 3289 SPRINTF("SSTAT2 ("); 3293 SPRINTF("SOFFSET "); 3298 SPRINTF("); SFCNT (%d); ", s
& (SFULL
| SFCNT
)); 3301 SPRINTF("SCSICNT (%d), OFFCNT(%d), ", (s
&0xf0) >>4, s
&0x0f); 3303 SPRINTF("SSTAT4 ("); 3306 SPRINTF("SYNCERR "); 3313 SPRINTF("DMACNTRL0 ("); 3314 s
=GETPORT(DMACNTRL0
); 3315 SPRINTF("%s ", s
& _8BIT
?"8BIT":"16BIT"); 3316 SPRINTF("%s ", s
& DMA
?"DMA":"PIO"); 3317 SPRINTF("%s ", s
& WRITE_READ
?"WRITE":"READ"); 3323 SPRINTF("RSTFIFO "); 3328 SPRINTF("DMASTAT ("); 3329 s
=GETPORT(DMASTAT
); 3333 SPRINTF("WORDRDY "); 3335 SPRINTF("DFIFOFULL "); 3337 SPRINTF("DFIFOEMP "); 3340 SPRINTF("enabled interrupts ("); 3342 s
=GETPORT(SIMODE0
); 3344 SPRINTF("ENSELDO "); 3346 SPRINTF("ENSELDI "); 3348 SPRINTF("ENSELINGO "); 3350 SPRINTF("ENSWRAP "); 3352 SPRINTF("ENSDONE "); 3354 SPRINTF("ENSPIORDY "); 3356 SPRINTF("ENDMADONE "); 3358 s
=GETPORT(SIMODE1
); 3360 SPRINTF("ENSELTIMO "); 3362 SPRINTF("ENATNTARG "); 3364 SPRINTF("ENPHASEMIS "); 3366 SPRINTF("ENBUSFREE "); 3368 SPRINTF("ENSCSIPERR "); 3370 SPRINTF("ENPHASECHG "); 3372 SPRINTF("ENREQINIT "); 3375 return(pos
- start
); 3379 #define SPRINTF(args...) do { if(pos < buffer + length) pos += sprintf(pos, ## args); } while(0) 3381 intaha152x_proc_info(char*buffer
,char**start
, 3382 off_t offset
,int length
,int hostno
,int inout
) 3386 struct Scsi_Host
*shpnt
; 3387 unsigned long flags
; 3390 for(i
=0, shpnt
= (struct Scsi_Host
*) NULL
; i
< IRQS
; i
++) 3391 if(aha152x_host
[i
] && aha152x_host
[i
]->host_no
== hostno
) 3392 shpnt
= aha152x_host
[i
]; 3397 if(inout
)/* Has data been written to the file ? */ 3398 return(aha152x_set_info(buffer
, length
, shpnt
)); 3400 SPRINTF(AHA152X_REVID
"\n"); 3405 SPRINTF("ioports 0x%04lx to 0x%04lx\n", 3406 shpnt
->io_port
, shpnt
->io_port
+ shpnt
->n_io_port
-1); 3407 SPRINTF("interrupt 0x%02x\n", shpnt
->irq
); 3408 SPRINTF("disconnection/reconnection %s\n", 3409 HOSTDATA(shpnt
)->reconnect
?"enabled":"disabled"); 3410 SPRINTF("parity checking %s\n", 3411 HOSTDATA(shpnt
)->parity
?"enabled":"disabled"); 3412 SPRINTF("synchronous transfers %s\n", 3413 HOSTDATA(shpnt
)->synchronous
?"enabled":"disabled"); 3414 SPRINTF("%d commands currently queued\n",HOSTDATA(shpnt
)->commands
); 3416 if(HOSTDATA(shpnt
)->synchronous
) { 3418 SPRINTF("synchronously operating targets (tick=%ld ns):\n", 3419 250000000/ loops_per_sec
); 3420 for(i
=0; i
<8; i
++) 3421 if(HOSTDATA(shpnt
)->syncrate
[i
] &0x7f) 3422 SPRINTF("target %d: period %dT/%ldns; req/ack offset %d\n", 3424 (((HOSTDATA(shpnt
)->syncrate
[i
] &0x70) >>4) +2), 3425 (((HOSTDATA(shpnt
)->syncrate
[i
] &0x70) >>4) +2) * 3426 250000000/ loops_per_sec
, 3427 HOSTDATA(shpnt
)->syncrate
[i
] &0x0f); 3429 SPRINTF("synchronously operating targets (tick=50 ns):\n"); 3430 for(i
=0; i
<8; i
++) 3431 if(HOSTDATA(shpnt
)->syncrate
[i
] &0x7f) 3432 SPRINTF("target %d: period %dT/%dns; req/ack offset %d\n", 3434 (((HOSTDATA(shpnt
)->syncrate
[i
] &0x70) >>4) +2), 3435 (((HOSTDATA(shpnt
)->syncrate
[i
] &0x70) >>4) +2) *50, 3436 HOSTDATA(shpnt
)->syncrate
[i
] &0x0f); 3439 #ifdef DEBUG_AHA152X 3440 #define PDEBUG(flags,txt) if(HOSTDATA(shpnt)->debug & flags) SPRINTF("(%s) ", txt); 3442 SPRINTF("enabled debugging options: "); 3444 PDEBUG(debug_skipports
,"skip ports"); 3445 PDEBUG(debug_queue
,"queue"); 3446 PDEBUG(debug_intr
,"interrupt"); 3447 PDEBUG(debug_selection
,"selection"); 3448 PDEBUG(debug_msgo
,"message out"); 3449 PDEBUG(debug_msgi
,"message in"); 3450 PDEBUG(debug_status
,"status"); 3451 PDEBUG(debug_cmd
,"command"); 3452 PDEBUG(debug_datai
,"data in"); 3453 PDEBUG(debug_datao
,"data out"); 3454 PDEBUG(debug_abort
,"abort"); 3455 PDEBUG(debug_done
,"done"); 3456 PDEBUG(debug_biosparam
,"bios parameters"); 3457 PDEBUG(debug_phases
,"phases"); 3458 PDEBUG(debug_queues
,"queues"); 3459 PDEBUG(debug_reset
,"reset"); 3464 SPRINTF("\nqueue status:\n"); 3466 SPRINTF("not yet issued commands:\n"); 3467 for(ptr
= ISSUE_SC
; ptr
; ptr
= (Scsi_Cmnd
*) ptr
->host_scribble
) 3468 pos
+=get_command(pos
, ptr
); 3470 SPRINTF("no not yet issued commands\n"); 3473 SPRINTF("current command:\n"); 3474 pos
+=get_command(pos
, CURRENT_SC
); 3476 SPRINTF("no current command\n"); 3478 if(DISCONNECTED_SC
) { 3479 SPRINTF("disconnected commands:\n"); 3480 for(ptr
= DISCONNECTED_SC
; ptr
; ptr
= (Scsi_Cmnd
*) ptr
->host_scribble
) 3481 pos
+=get_command(pos
, ptr
); 3483 SPRINTF("no disconnected commands\n"); 3485 restore_flags(flags
); 3487 pos
+=get_ports(shpnt
, pos
); 3489 *start
= buffer
+ offset
; 3490 if(pos
- buffer
< offset
) 3492 else if(pos
- buffer
- offset
< length
) 3493 return pos
- buffer
- offset
; 3499 /* Eventually this will go into an include file, but this will be later */ 3500 Scsi_Host_Template driver_template
= AHA152X
; 3502 #include"scsi_module.c"